From ff6bd5db12b63f7a08ee02b327138a6bb3db6a84 Mon Sep 17 00:00:00 2001 From: "jude.kwashie" <judekwashie70@gmail.com> Date: Fri, 28 Feb 2025 11:31:18 +0000 Subject: [PATCH 1/8] fix(firestore): type definitions --- .../firestore/__tests__/firestore.test.ts | 10 +++ packages/firestore/lib/modular/FieldPath.d.ts | 7 ++ packages/firestore/lib/modular/FieldPath.js | 4 + .../firestore/lib/modular/VectorValue.d.ts | 0 packages/firestore/lib/modular/index.d.ts | 53 +++++++++---- packages/firestore/lib/modular/query.d.ts | 75 +++++++------------ packages/firestore/lib/modular/query.js | 30 ++++---- packages/firestore/lib/modular/snapshot.d.ts | 51 ++++++++++--- packages/firestore/lib/modular/snapshot.js | 13 ++++ 9 files changed, 152 insertions(+), 91 deletions(-) create mode 100644 packages/firestore/lib/modular/VectorValue.d.ts diff --git a/packages/firestore/__tests__/firestore.test.ts b/packages/firestore/__tests__/firestore.test.ts index 4dee5772d4..b408478d35 100644 --- a/packages/firestore/__tests__/firestore.test.ts +++ b/packages/firestore/__tests__/firestore.test.ts @@ -77,6 +77,8 @@ import firestore, { deleteAllPersistentCacheIndexes, disablePersistentCacheIndexAutoCreation, enablePersistentCacheIndexAutoCreation, + onSnapshotsInSync, + documentId, } from '../lib'; const COLLECTION = 'firestore'; @@ -736,6 +738,14 @@ describe('Firestore', function () { it('`sum` is properly exposed to end user', function () { expect(sum).toBeDefined(); }); + + it('`onSnapshotsInSync` is properly exposed to end user', function () { + expect(onSnapshotsInSync).toBeDefined(); + }); + + it('`documentId` is properly exposed to end user', function () { + expect(documentId).toBeDefined(); + }); }); describe('test `console.warn` is called for RNFB v8 API & not called for v9 API', function () { diff --git a/packages/firestore/lib/modular/FieldPath.d.ts b/packages/firestore/lib/modular/FieldPath.d.ts index f00fe5d5e3..b8d2038e5f 100644 --- a/packages/firestore/lib/modular/FieldPath.d.ts +++ b/packages/firestore/lib/modular/FieldPath.d.ts @@ -11,3 +11,10 @@ export declare class FieldPath { isEqual(other: FieldPath): boolean; } + +/** + * Returns a special sentinel FieldPath to refer to the ID of a document + * It can be used in queries to sort or filter by the document ID + */ + +export declare function documentId(): FieldPath; diff --git a/packages/firestore/lib/modular/FieldPath.js b/packages/firestore/lib/modular/FieldPath.js index 93792b6454..6497be2c59 100644 --- a/packages/firestore/lib/modular/FieldPath.js +++ b/packages/firestore/lib/modular/FieldPath.js @@ -1,3 +1,7 @@ import FirestoreFieldPath from '../FirestoreFieldPath'; export const FieldPath = FirestoreFieldPath; + +export function documentId() { + return FieldPath.documentId(); +} diff --git a/packages/firestore/lib/modular/VectorValue.d.ts b/packages/firestore/lib/modular/VectorValue.d.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/firestore/lib/modular/index.d.ts b/packages/firestore/lib/modular/index.d.ts index f0679ca42d..0dff797a08 100644 --- a/packages/firestore/lib/modular/index.d.ts +++ b/packages/firestore/lib/modular/index.d.ts @@ -185,11 +185,11 @@ export function doc( * a document. * @returns The `DocumentReference` instance. */ -export function doc<T>( - reference: CollectionReference<T>, +export declare function doc<AppModelType, DbModelType extends DocumentData>( + reference: CollectionReference<AppModelType, DbModelType>, path?: string, ...pathSegments: string[] -): DocumentReference<T>; +): DocumentReference<AppModelType, DbModelType>; /** * Gets a `DocumentReference` instance that refers to a document within @@ -203,11 +203,11 @@ export function doc<T>( * a document. * @returns The `DocumentReference` instance. */ -export function doc( - reference: DocumentReference<unknown>, +export declare function doc<AppModelType, DbModelType extends DocumentData>( + reference: DocumentReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[] -): DocumentReference<DocumentData>; +): DocumentReference<DocumentData, DocumentData>; export function doc<T>( parent: Firestore | CollectionReference<T> | DocumentReference<unknown>, @@ -231,7 +231,7 @@ export function collection( firestore: Firestore, path: string, ...pathSegments: string[] -): CollectionReference<DocumentData>; +): CollectionReference<DocumentData, DocumentData>; /** * Gets a `CollectionReference` instance that refers to a subcollection of @@ -245,11 +245,29 @@ export function collection( * to a collection. * @returns The `CollectionReference` instance. */ -export function collection( - reference: CollectionReference<unknown>, +export declare function collection<AppModelType, DbModelType extends DocumentData>( + reference: CollectionReference<AppModelType, DbModelType>, path: string, ...pathSegments: string[] -): CollectionReference<DocumentData>; +): CollectionReference<DocumentData, DocumentData>; + +/** + * Gets a `CollectionReference` instance that refers to a subcollection of + * `reference` at the specified relative path. + * + * @param reference - A reference to a document. + * @param path - A slash-separated path to a collection. + * @param pathSegments - Additional path segments to apply relative to the first + * argument. + * @throws If the final path has an even number of segments and does not point + * to a collection. + * @returns The `CollectionReference` instance. + */ +export declare function collection<AppModelType, DbModelType extends DocumentData>( + reference: DocumentReference<AppModelType, DbModelType>, + path: string, + ...pathSegments: string[] +): CollectionReference<DocumentData, DocumentData>; /** * Gets a `CollectionReference` instance that refers to a subcollection of @@ -302,7 +320,10 @@ export declare function refEqual<AppModelType, DbModelType extends DocumentData> * will be included. Cannot contain a slash. * @returns The created `Query`. */ -export function collectionGroup(firestore: Firestore, collectionId: string): Query<DocumentData>; +export function collectionGroup( + firestore: Firestore, + collectionId: string, +): Query<DocumentData, DocumentData>; /** * Writes to the document referred to by this `DocumentReference`. If the @@ -383,10 +404,10 @@ export function updateDoc( * newly created document after it has been written to the backend (Note that it * won't resolve while you're offline). */ -export function addDoc<T>( - reference: CollectionReference<T>, - data: WithFieldValue<T>, -): Promise<DocumentReference<T>>; +export declare function addDoc<AppModelType, DbModelType extends DocumentData>( + reference: CollectionReference<AppModelType, DbModelType>, + data: WithFieldValue<AppModelType>, +): Promise<DocumentReference<AppModelType, DbModelType>>; /** * Re-enables use of the network for this {@link Firestore} instance after a prior @@ -701,7 +722,7 @@ export function loadBundle( * @param name - The name of the query. * @returns A named Query. */ -export function namedQuery(firestore: Firestore, name: string): Query<DocumentData>; +export function namedQuery(firestore: Firestore, name: string): Promise<Query | null>; /** * Creates a write batch, used for performing multiple writes as a single diff --git a/packages/firestore/lib/modular/query.d.ts b/packages/firestore/lib/modular/query.d.ts index ffd857038b..81f7c1967a 100644 --- a/packages/firestore/lib/modular/query.d.ts +++ b/packages/firestore/lib/modular/query.d.ts @@ -100,11 +100,11 @@ export type QueryNonFilterConstraint = * @throws if any of the provided query constraints cannot be combined with the * existing or new constraints. */ -export function query<T>( - query: Query<T>, +export declare function query<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, compositeFilter: QueryCompositeFilterConstraint, ...queryConstraints: QueryNonFilterConstraint[] -): Query<T>; +): Query<AppModelType, DbModelType>; /** * Creates a new immutable instance of {@link Query} that is extended to also @@ -116,7 +116,10 @@ export function query<T>( * @throws if any of the provided query constraints cannot be combined with the * existing or new constraints. */ -export function query<T>(query: Query<T>, ...queryConstraints: IQueryConstraint[]): Query<T>; +export declare function query<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, + ...queryConstraints: QueryConstraint[] +): Query<AppModelType, DbModelType>; export function query<T>( query: Query<T>, @@ -173,7 +176,7 @@ export type OrderByDirection = 'desc' | 'asc'; */ export function orderBy( fieldPath: string | FieldPath, - directionStr: OrderByDirection = 'asc', + directionStr?: OrderByDirection, ): QueryOrderByConstraint; /** @@ -285,7 +288,9 @@ export declare function getDocFromServer<T>( * * @returns A `Promise` that will be resolved with the results of the query. */ -export function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>; +export declare function getDocs<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, +): Promise<QuerySnapshot<AppModelType, DbModelType>>; /** * Executes the query and returns the results as a `QuerySnapshot` from cache. @@ -294,7 +299,9 @@ export function getDocs<T>(query: Query<T>): Promise<QuerySnapshot<T>>; * * @returns A `Promise` that will be resolved with the results of the query. */ -export function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>; +export declare function getDocsFromCache<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, +): Promise<QuerySnapshot<AppModelType, DbModelType>>; /** * Executes the query and returns the results as a `QuerySnapshot` from the @@ -302,7 +309,9 @@ export function getDocsFromCache<T>(query: Query<T>): Promise<QuerySnapshot<T>>; * * @returns A `Promise` that will be resolved with the results of the query. */ -export function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>>; +export declare function getDocsFromServer<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, +): Promise<QuerySnapshot<AppModelType, DbModelType>>; /** * Deletes the document referred to by the specified `DocumentReference`. @@ -311,53 +320,25 @@ export function getDocsFromServer<T>(query: Query<T>): Promise<QuerySnapshot<T>> * @returns A Promise resolved once the document has been successfully * deleted from the backend (note that it won't resolve while you're offline). */ -export function deleteDoc(reference: DocumentReference<unknown>): Promise<void>; +export declare function deleteDoc<AppModelType, DbModelType extends DocumentData>( + reference: DocumentReference<AppModelType, DbModelType>, +): Promise<void>; /** - * Creates a `QueryConstraint` with the specified ending point. - * - * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()` - * allows you to choose arbitrary starting and ending points for your queries. - * - * The ending point is inclusive, so children with exactly the specified value - * will be included in the query. The optional key argument can be used to - * further limit the range of the query. If it is specified, then children that - * have exactly the specified value must also have a key name less than or equal - * to the specified key. + * Creates a QueryEndAtConstraint that modifies the result set to end at the provided fields relative to the order of the query. + * The order of the field values must match the order of the order by clauses of the query. * - * You can read more about `endAt()` in - * {@link https://firebase.google.com/docs/database/web/lists-of-data#filtering_data | Filtering data}. - * - * @param value - The value to end at. The argument type depends on which - * `orderBy*()` function was used in this query. Specify a value that matches - * the `orderBy*()` type. When used in combination with `orderByKey()`, the - * value must be a string. - * @param key - The child key to end at, among the children with the previously - * specified priority. This argument is only allowed if ordering by child, - * value, or priority. + * @param fieldValues */ -export function endAt(value: number | string | boolean | null, key?: string): QueryConstraint; +export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; /** - * Creates a `QueryConstraint` with the specified ending point (exclusive). - * - * Using `startAt()`, `startAfter()`, `endBefore()`, `endAt()` and `equalTo()` - * allows you to choose arbitrary starting and ending points for your queries. - * - * The ending point is exclusive. If only a value is provided, children - * with a value less than the specified value will be included in the query. - * If a key is specified, then children must have a value less than or equal - * to the specified value and a key name less than the specified key. + * Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. + * The order of the field values must match the order of the order by clauses of the query. * - * @param value - The value to end before. The argument type depends on which - * `orderBy*()` function was used in this query. Specify a value that matches - * the `orderBy*()` type. When used in combination with `orderByKey()`, the - * value must be a string. - * @param key - The child key to end before, among the children with the - * previously specified priority. This argument is only allowed if ordering by - * child, value, or priority. + * @param fieldValues */ -export function endBefore(value: number | string | boolean | null, key?: string): QueryConstraint; +export declare function endBefore(...fieldValues: unknown[]): QueryEndAtConstraint; /** * Creates a new `QueryConstraint` that is limited to return only the last diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index deeb1ceed4..9cebc3e5bf 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -130,27 +130,25 @@ export function startAfter(...docOrFields) { } /** - * @param {number | string | boolean | null} value - * @param {string?} key - * @returns {QueryConstraint} + * Creates a QueryEndAtConstraint that modifies the result set to end at the provided fields relative to the order of the query. + * The order of the field values must match the order of the order by clauses of the query. + * + * @param {*} fieldValues */ -export function endAt(value, key) { - if (!key) { - return new QueryConstraint('endAt', value); - } - return new QueryConstraint('endAt', value, key); +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function endAt(fieldValues) { + throw new Error('endAt is not implemented'); } /** - * @param {number | string | boolean | null} value - * @param {string?} key - * @returns {QueryConstraint} + * Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. + * The order of the field values must match the order of the order by clauses of the query. + * + * @param {*} fieldValues */ -export function endBefore(value, key) { - if (!key) { - return new QueryConstraint('endBefore', value); - } - return new QueryConstraint('endBefore', value, key); +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function endBefore(fieldValues) { + throw new Error('endBefore is not implemented'); } /** diff --git a/packages/firestore/lib/modular/snapshot.d.ts b/packages/firestore/lib/modular/snapshot.d.ts index 38384a5252..ebf9279e75 100644 --- a/packages/firestore/lib/modular/snapshot.d.ts +++ b/packages/firestore/lib/modular/snapshot.d.ts @@ -117,10 +117,10 @@ export function onSnapshot<T>( * @returns An unsubscribe function that can be called to cancel * the snapshot listener. */ -export function onSnapshot<T>( - query: Query<T>, +export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, observer: { - next?: (snapshot: QuerySnapshot<T>) => void; + next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void; error?: (error: FirestoreError) => void; complete?: () => void; }, @@ -140,11 +140,11 @@ export function onSnapshot<T>( * @returns An unsubscribe function that can be called to cancel * the snapshot listener. */ -export function onSnapshot<T>( - query: Query<T>, +export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, observer: { - next?: (snapshot: QuerySnapshot<T>) => void; + next?: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void; error?: (error: FirestoreError) => void; complete?: () => void; }, @@ -168,9 +168,9 @@ export function onSnapshot<T>( * @returns An unsubscribe function that can be called to cancel * the snapshot listener. */ -export function onSnapshot<T>( - query: Query<T>, - onNext: (snapshot: QuerySnapshot<T>) => void, +export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, + onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, ): Unsubscribe; @@ -194,10 +194,10 @@ export function onSnapshot<T>( * @returns An unsubscribe function that can be called to cancel * the snapshot listener. */ -export function onSnapshot<T>( - query: Query<T>, +export declare function onSnapshot<AppModelType, DbModelType extends DocumentData>( + query: Query<AppModelType, DbModelType>, options: SnapshotListenOptions, - onNext: (snapshot: QuerySnapshot<T>) => void, + onNext: (snapshot: QuerySnapshot<AppModelType, DbModelType>) => void, onError?: (error: FirestoreError) => void, onCompletion?: () => void, ): Unsubscribe; @@ -227,3 +227,30 @@ export declare function queryEqual<AppModelType, DbModelType extends DocumentDat left: Query<AppModelType, DbModelType>, right: Query<AppModelType, DbModelType>, ): boolean; + +/** + * Attaches a listener for a snapshots-in-sync event. + * The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if + * a single server-generated change affects multiple listeners. + * + * @param firestore + * @param observer + */ +export declare function onSnapshotsInSync( + firestore: Firestore, + observer: { + next?: (value: void) => void; + error?: (error: FirestoreError) => void; + complete?: () => void; + }, +): Unsubscribe; + +/** + * Attaches a listener for a snapshots-in-sync event. + * The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if + * a single server-generated change affects multiple listeners. + * + * @param firestore + * @param onSync + */ +export declare function onSnapshotsInSync(firestore: Firestore, onSync: () => void): Unsubscribe; diff --git a/packages/firestore/lib/modular/snapshot.js b/packages/firestore/lib/modular/snapshot.js index 946f1c819d..0247f4095d 100644 --- a/packages/firestore/lib/modular/snapshot.js +++ b/packages/firestore/lib/modular/snapshot.js @@ -18,3 +18,16 @@ export function onSnapshot(reference, ...args) { export function snapshotEqual(left, right) { return left.isEqual.call(left, right, MODULAR_DEPRECATION_ARG); } + +/** + * Attaches a listener for a snapshots-in-sync event. + * The snapshots-in-sync event indicates that all listeners affected by a given change have fired, even if + * a single server-generated change affects multiple listeners. + * + * @param {*} firestore + * @param {...any} args + */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +export function onSnapshotsInSync(firestore, ...args) { + throw new Error('onSnapshotsInSync() is not implemented'); +} From 536659e9d7ab5dfa14726279dc2e3661e8343635 Mon Sep 17 00:00:00 2001 From: "jude.kwashie" <judekwashie70@gmail.com> Date: Fri, 28 Feb 2025 15:25:38 +0000 Subject: [PATCH 2/8] chore: resolve comments --- packages/firestore/lib/modular/query.d.ts | 6 +++++- packages/firestore/lib/modular/query.js | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/packages/firestore/lib/modular/query.d.ts b/packages/firestore/lib/modular/query.d.ts index 81f7c1967a..e3f4cce7fc 100644 --- a/packages/firestore/lib/modular/query.d.ts +++ b/packages/firestore/lib/modular/query.d.ts @@ -176,7 +176,7 @@ export type OrderByDirection = 'desc' | 'asc'; */ export function orderBy( fieldPath: string | FieldPath, - directionStr?: OrderByDirection, + directionStr: OrderByDirection = 'asc', ): QueryOrderByConstraint; /** @@ -332,6 +332,10 @@ export declare function deleteDoc<AppModelType, DbModelType extends DocumentData */ export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +export function endAt<AppModelType, DbModelType extends DocumentData>( + snapshot: DocumentSnapshot<AppModelType, DbModelType> +): QueryEndAtConstraint; + /** * Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. * The order of the field values must match the order of the order by clauses of the query. diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index 9cebc3e5bf..9eebc5b740 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -136,8 +136,8 @@ export function startAfter(...docOrFields) { * @param {*} fieldValues */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function endAt(fieldValues) { - throw new Error('endAt is not implemented'); +export function endAt(...fieldValues) { + return new QueryConstraint('endAt', ...fieldValues); } /** @@ -147,8 +147,8 @@ export function endAt(fieldValues) { * @param {*} fieldValues */ // eslint-disable-next-line @typescript-eslint/no-unused-vars -export function endBefore(fieldValues) { - throw new Error('endBefore is not implemented'); +export function endBefore(...fieldValues) { + return new QueryConstraint('endBefore', ...fieldValues); } /** From 3d4e50aad5f059f30fc1e011751ff3f15e44dbd4 Mon Sep 17 00:00:00 2001 From: "jude.kwashie" <judekwashie70@gmail.com> Date: Fri, 28 Feb 2025 15:26:40 +0000 Subject: [PATCH 3/8] chore: resolve lint issues --- packages/firestore/lib/modular/query.d.ts | 2 +- packages/firestore/lib/modular/query.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/firestore/lib/modular/query.d.ts b/packages/firestore/lib/modular/query.d.ts index e3f4cce7fc..876710d83f 100644 --- a/packages/firestore/lib/modular/query.d.ts +++ b/packages/firestore/lib/modular/query.d.ts @@ -333,7 +333,7 @@ export declare function deleteDoc<AppModelType, DbModelType extends DocumentData export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; export function endAt<AppModelType, DbModelType extends DocumentData>( - snapshot: DocumentSnapshot<AppModelType, DbModelType> + snapshot: DocumentSnapshot<AppModelType, DbModelType>, ): QueryEndAtConstraint; /** diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index 9eebc5b740..ea4a9ea769 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -135,7 +135,7 @@ export function startAfter(...docOrFields) { * * @param {*} fieldValues */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars + export function endAt(...fieldValues) { return new QueryConstraint('endAt', ...fieldValues); } @@ -146,7 +146,7 @@ export function endAt(...fieldValues) { * * @param {*} fieldValues */ -// eslint-disable-next-line @typescript-eslint/no-unused-vars + export function endBefore(...fieldValues) { return new QueryConstraint('endBefore', ...fieldValues); } From 0f0d87cbf4f7abf9e020739bba55dde1256ec392 Mon Sep 17 00:00:00 2001 From: MichaelVerdon <mwverdon2000@gmail.com> Date: Tue, 29 Apr 2025 10:26:22 +0100 Subject: [PATCH 4/8] fix: make optional --- packages/firestore/lib/modular/query.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/lib/modular/query.d.ts b/packages/firestore/lib/modular/query.d.ts index 876710d83f..c534a56beb 100644 --- a/packages/firestore/lib/modular/query.d.ts +++ b/packages/firestore/lib/modular/query.d.ts @@ -176,7 +176,7 @@ export type OrderByDirection = 'desc' | 'asc'; */ export function orderBy( fieldPath: string | FieldPath, - directionStr: OrderByDirection = 'asc', + directionStr?: OrderByDirection = 'asc', ): QueryOrderByConstraint; /** From fe83a7b848271928079b0dfb764dfac8304e1f92 Mon Sep 17 00:00:00 2001 From: MichaelVerdon <mwverdon2000@gmail.com> Date: Tue, 29 Apr 2025 10:34:16 +0100 Subject: [PATCH 5/8] feat: endAt impl --- packages/firestore/lib/modular/query.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index ea4a9ea769..4c6da2a3eb 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -140,6 +140,14 @@ export function endAt(...fieldValues) { return new QueryConstraint('endAt', ...fieldValues); } +/** + * @param {DocumentSnapshot} snapshot + * @returns {QueryEndAtConstraint} + */ +export function endAt(snapshot){ + return new QueryConstraint('endAt', snapshot); +} + /** * Creates a QueryEndAtConstraint that modifies the result set to end before the provided fields relative to the order of the query. * The order of the field values must match the order of the order by clauses of the query. From eb835be60745051ef548559ca55ffb17ca0b6858 Mon Sep 17 00:00:00 2001 From: MichaelVerdon <mwverdon2000@gmail.com> Date: Tue, 29 Apr 2025 10:39:53 +0100 Subject: [PATCH 6/8] fix: formatting --- packages/firestore/lib/modular/query.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index 4c6da2a3eb..46f6788d4a 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -144,7 +144,7 @@ export function endAt(...fieldValues) { * @param {DocumentSnapshot} snapshot * @returns {QueryEndAtConstraint} */ -export function endAt(snapshot){ +export function endAt(snapshot) { return new QueryConstraint('endAt', snapshot); } From 76a4e3c4e6a9e9a042d25c416e94c801c7a676f1 Mon Sep 17 00:00:00 2001 From: MichaelVerdon <mwverdon2000@gmail.com> Date: Tue, 29 Apr 2025 10:43:20 +0100 Subject: [PATCH 7/8] feat: endAt --- packages/firestore/lib/modular/query.d.ts | 5 +++++ packages/firestore/lib/modular/query.js | 14 +++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/packages/firestore/lib/modular/query.d.ts b/packages/firestore/lib/modular/query.d.ts index c534a56beb..c4c4a31cbe 100644 --- a/packages/firestore/lib/modular/query.d.ts +++ b/packages/firestore/lib/modular/query.d.ts @@ -332,6 +332,11 @@ export declare function deleteDoc<AppModelType, DbModelType extends DocumentData */ export declare function endAt(...fieldValues: unknown[]): QueryEndAtConstraint; +/** + * reates a QueryEndAtConstraint that modifies the result set to end at the provided document (inclusive). + * The end position is relative to the order of the query. The document must contain all of the fields provided in the orderBy of the query. + * @param snapshot + */ export function endAt<AppModelType, DbModelType extends DocumentData>( snapshot: DocumentSnapshot<AppModelType, DbModelType>, ): QueryEndAtConstraint; diff --git a/packages/firestore/lib/modular/query.js b/packages/firestore/lib/modular/query.js index 46f6788d4a..d38bf762ad 100644 --- a/packages/firestore/lib/modular/query.js +++ b/packages/firestore/lib/modular/query.js @@ -133,19 +133,11 @@ export function startAfter(...docOrFields) { * Creates a QueryEndAtConstraint that modifies the result set to end at the provided fields relative to the order of the query. * The order of the field values must match the order of the order by clauses of the query. * - * @param {*} fieldValues + * @param {*} ...args Can be either a DocumentSnapshot or an array of field values. */ -export function endAt(...fieldValues) { - return new QueryConstraint('endAt', ...fieldValues); -} - -/** - * @param {DocumentSnapshot} snapshot - * @returns {QueryEndAtConstraint} - */ -export function endAt(snapshot) { - return new QueryConstraint('endAt', snapshot); +export function endAt(...args) { + return new QueryConstraint('endAt', ...args); } /** From 13411a2c4fedf088ff50ad17c6bbab26a3549d05 Mon Sep 17 00:00:00 2001 From: Mike Hardy <github@mikehardy.net> Date: Mon, 30 Jun 2025 19:47:43 -0500 Subject: [PATCH 8/8] fix: remove empty modular VectorValue.d.ts --- packages/firestore/lib/modular/VectorValue.d.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 packages/firestore/lib/modular/VectorValue.d.ts diff --git a/packages/firestore/lib/modular/VectorValue.d.ts b/packages/firestore/lib/modular/VectorValue.d.ts deleted file mode 100644 index e69de29bb2..0000000000