Skip to content

Releases: tylim88/FirelordJS

2.6.5

31 Jul 12:19
Compare
Choose a tag to compare
  1. improve collection JSDoc
	/**
	 * Gets a {@link CollectionReference} instance that refers to the collection at
	 * the specified absolute path.
	 *
	 *  related documentations:
	 *  - {@link https://firelordjs.com/guides/metatype child meta type}
	 *  - {@link https://firelordjs.com/quick_start#operations operation}
	 * @param documentIds
	 *  All the docID(s) needed to build this document path, eg
	 *  - for top-collection: example.collection()
	 *  - for sub-collection: example.collection(GrandParentDocId, ParentsDocId)
	 *
	 * @returns The {@link CollectionReference} instance.
	 */
  1. improve collectionGroup JSDoc
	/**
	 *  related documentations:
	 *  - {@link https://firelordjs.com/quick_start/#query query}
	 *  - {@link https://firelordjs.com/quick_start/#onsnapshot onSnapshot}
	 * @returns — The created {@link Query}.
	 */

2.6.4

30 Jul 09:51
Compare
Choose a tag to compare

expose types Unsubscribe and OnSnapshot

2.6.3

21 Jul 07:40
Compare
Choose a tag to compare
  1. better onSnapshot JSDoc
    /**
     * listen to filtered collection, entire collection or single document
     *
     * Attaches a listener for {@link DocumentSnapshot} Or {@link QuerySnapshot} events. You may either pass
     * individual {@link onNext} and {@link onError} callbacks. The listener can be cancelled by
     * calling the function that is returned when {@link OnSnapshot} is called.
     *
     * related documentation:
     *  - {@link https://firelordjs.com/quick_start#onsnapshot}
     *
     * @param reference
     *
     * Type 1: {@link Query} eg: query(example.collection(...), ...) listen to filtered collection
     *
     * Type 2: CollectionGroup({@link Query}) eg: query(example.collectionGroup(...), ...) listen to filtered {@link Query}
     *
     * Type 3: {@link CollectionReference} eg: example.collection(...) listen to entire collection
     *
     * Type 4: CollectionGroup({@link Query}) reference eg: example.collectionGroup(...) listen to entire {@link Query}
     *
     * Type 5: {@link DocumentReference} eg: example.doc(...) listen to a single document
     * @param onNext - A callback to be called every time a new {@link DocumentSnapshot} or {@link QuerySnapshot} is available.
     *
     * Type 1: receive {@link DocumentSnapshot} if {@link reference} is {@link DocumentReference} eg: (value: {@link DocumentSnapshot}) => { handle data here }
     *
     * Type 2: receive {@link QuerySnapshot} if {@link reference} is CollectionGroup or {@link Query} or {@link CollectionReference} eg: (value: {@link QuerySnapshot}) => { handle data here }
     *
     * @param onError - optional parameter.
     *
     * Type 1: a callback to be called if the listen fails or is cancelled. No further callbacks will occur. Eg: (error: {@link FirestoreError})=> { handle error here}
     *
     * Type 2: {@link SnapshotListenOptions} eg: { includeMetadataChanges: boolean }
     * @param options - optional parameter. If {@link onError} is {@link SnapshotListenOptions} eg: { includeMetadataChanges: boolean }, then this argument is never. Else it is {@link SnapshotListenOptions} eg: { includeMetadataChanges: boolean }
     * @returns An unsubscribe function that can be called to cancel
     * the snapshot listener.
     */
  1. remove onSnapshot overloading
  2. fix onSnapshot unable to infer type from collection reference

2.6.2

20 Jul 23:26
Compare
Choose a tag to compare

Object unions type was banned before v2.6.2 because it brings uncertainty that cannot be handled reasonably. For example, with {a:number}|{b:string}, you can set {a:1} then update {b:"x"}, in this case the type is no longer unions type but an intersection type: {a:number} & {b:string}. The reason I decided to lift the limitation is that I believe we should value functionalities over less practical strict typing. Plus in future update operation Mandatory Field could mitigate this problem.

2.6.1

20 Jul 21:07
Compare
Choose a tag to compare
  1. improve doc ref JSDoc, this is what user will see
    /**
     * Gets a `DocumentReference` instance that refers to the document at the
     * specified absolute path.
     *
     * @param documentIds_or_CollectionReference
     * Option 1: all the docID(s) needed to build this document path, eg
     *  - for top-collection: example.doc(SelfDocId)
     *  - for sub-collection: example.doc(GrandParentDocId, ParentsDocId, SelfDocId).
     *
     * Option 2: CollectionReference (to create auto id doc ref), eg
     *  - for top-collection: example.doc(example.collection())
     *  - for sub-collection: example.doc(example.collection(GrandParentCollectionID, ParenCollectionID))
     *
     *
     *  documentation:
     *  {@link https://firelordjs.com/guides/metatype child meta type}
     *  {@link https://firelordjs.com/quick_start#operations operation}
     * @returns The `DocumentReference` instance.
     */
  1. doc ref no longer overload function (function overloading is very messy in type hint) and use union instead
  2. suggesting turn off some eslint rules in readme because of false errors
{
	"rules": {
		"@typescript-eslint/no-unsafe-assignment": "off",
		"@typescript-eslint/no-unsafe-call": "off",
		"@typescript-eslint/no-redundant-type-constituents": "off",
		"@typescript-eslint/no-unsafe-return": "off",
		"@typescript-eslint/no-unsafe-member-access": "off"
	}
}

v2.6 will focus on improving JSDoc

2.6.0

15 Jul 21:10
Compare
Choose a tag to compare

(Web only)

  1. update peer dependency firebase to v10.0.0
  2. remove the rule Error: You can't order your query by a field included in an equality '==' or 'in' clause. Exceptions to this rule are order by '__name__' or 'documentId()' because firebase v10.0.0 removed this limitation. I think dev exp is better with this rule but the removal is harmless,

side note: If you are using @firebase/rules-unit-testing for testing, you have to use @firebase/rules-unit-testing v3. Firebase v10 does not work with v2 (peer dependency issue)

2.5.20

09 Jun 07:54
Compare
Choose a tag to compare

make getFirelord tree shakable

https://firelordjs.com/guides/tree_shaking_getFirelord

const getFirelord = getFirelordShakable({
    // all properties are optional
    // choose what to keep
    orCreator,
    andCreator,
    docCreator,
    collectionCreator,
    collectionGroupCreator,
})

const example = getFirelord<Example>(db, 'someCollectionId')

2.5.13, 2.5.14, 2.5.15

03 Jun 22:30
Compare
Choose a tag to compare
  1. add more in code documentation

internal:

  1. fill virtual types so they resemble the type of possible values at runtime (virtual type is type that exist just to make typing easier, it does not resemble the possible values at runtime), This update will not breaks your code unless you were trying to access undocumented API.
  2. lots of housekeeping and refactoring
  3. fix emulator not working properly
  4. replace documentId() in test with __name__

2.5.11

01 Jun 06:04
Compare
Choose a tag to compare
  1. Firestore need time to resolve sever time stamp, so it is possible to retrieve a null value if we read the value immediately after we write it. However this is a very rare case, for smoother coding experience, I decided not to union Server Timestamp read type(Timestamp) with null anymore. User can choose to union ServerTimestamp with null in Meta Type to deal with edge case. This change does not break existing code.
  2. (internal) remove unionReadTimestampWithNull

2.5.10

15 May 18:14
Compare
Choose a tag to compare
  1. support Record<string, something> data type
  2. new APIs: transaction.updateNoFlatten, batch.updateNoFlatten, and updateDocNoFlatten.

for more details see https://github.com/tylim88/Firelord/releases/tag/2.4.16