@dereekb/firebase 13.11.2 → 13.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +2440 -575
- package/index.esm.js +2419 -579
- package/package.json +5 -5
- package/src/lib/client/firestore/array.d.ts +1 -0
- package/src/lib/client/firestore/driver.accessor.batch.d.ts +1 -0
- package/src/lib/client/firestore/driver.accessor.create.d.ts +1 -0
- package/src/lib/client/firestore/driver.accessor.d.ts +1 -0
- package/src/lib/client/firestore/driver.accessor.default.d.ts +1 -0
- package/src/lib/client/firestore/driver.accessor.transaction.d.ts +1 -0
- package/src/lib/client/firestore/increment.d.ts +1 -0
- package/src/lib/client/function/development.function.factory.d.ts +1 -0
- package/src/lib/client/function/function.factory.d.ts +2 -0
- package/src/lib/client/function/model.function.factory.d.ts +1 -0
- package/src/lib/common/firestore/accessor/accessor.d.ts +1 -0
- package/src/lib/common/firestore/accessor/accessor.wrap.d.ts +1 -0
- package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +4 -0
- package/src/lib/common/firestore/accessor/array.d.ts +1 -0
- package/src/lib/common/firestore/accessor/document.d.ts +4 -0
- package/src/lib/common/firestore/accessor/document.paged.d.ts +134 -0
- package/src/lib/common/firestore/accessor/document.utility.d.ts +195 -0
- package/src/lib/common/firestore/accessor/increment.d.ts +1 -0
- package/src/lib/common/firestore/accessor/index.d.ts +1 -0
- package/src/lib/common/firestore/cache/cache.d.ts +1 -0
- package/src/lib/common/firestore/cache/cache.memory.d.ts +3 -0
- package/src/lib/common/firestore/collection/collection.d.ts +29 -2
- package/src/lib/common/firestore/collection/collection.group.d.ts +1 -0
- package/src/lib/common/firestore/collection/collection.query.d.ts +1 -0
- package/src/lib/common/firestore/collection/collection.single.d.ts +1 -0
- package/src/lib/common/firestore/collection/collection.util.d.ts +1 -0
- package/src/lib/common/firestore/collection/index.d.ts +1 -0
- package/src/lib/common/firestore/collection/subcollection.d.ts +1 -0
- package/src/lib/common/firestore/collection/subcollection.paged.d.ts +226 -0
- package/src/lib/common/firestore/collection/subcollection.single.d.ts +1 -0
- package/src/lib/common/firestore/context.d.ts +37 -1
- package/src/lib/common/firestore/driver/query.handler.d.ts +1 -0
- package/src/lib/common/firestore/error.d.ts +1 -0
- package/src/lib/common/firestore/query/constraint.d.ts +2 -0
- package/src/lib/common/firestore/query/iterator.d.ts +5 -0
- package/src/lib/common/firestore/query/query.d.ts +1 -0
- package/src/lib/common/firestore/snapshot/snapshot.d.ts +1 -0
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +262 -0
- package/src/lib/common/firestore/util/id.batch.d.ts +1 -0
- package/src/lib/common/model/function.d.ts +1 -0
- package/src/lib/common/model/model.service.d.ts +8 -0
- package/src/lib/common/model/permission/permission.service.d.ts +1 -0
- package/src/lib/common/model/permission/permission.service.grant.d.ts +6 -0
- package/src/lib/common/storage/accessor/path.model.d.ts +1 -0
- package/src/lib/common/storage/context.d.ts +1 -0
- package/src/lib/common/storage/driver/accessor.iterate.d.ts +1 -0
- package/src/lib/common/storage/driver/list.d.ts +1 -0
- package/src/lib/common/storage/storage.d.ts +1 -0
- package/src/lib/model/notification/index.d.ts +2 -0
- package/src/lib/model/notification/notification.api.d.ts +36 -1
- package/src/lib/model/notification/notification.config.d.ts +1 -0
- package/src/lib/model/notification/notification.create.d.ts +2 -0
- package/src/lib/model/notification/notification.create.loggedevent.d.ts +33 -0
- package/src/lib/model/notification/notification.create.task.d.ts +1 -0
- package/src/lib/model/notification/notification.d.ts +179 -3
- package/src/lib/model/notification/notification.details.d.ts +1 -0
- package/src/lib/model/notification/notification.id.d.ts +23 -1
- package/src/lib/model/notification/notification.loggedevent.loader.d.ts +82 -0
- package/src/lib/model/notification/notification.message.d.ts +2 -0
- package/src/lib/model/notification/notification.query.d.ts +17 -0
- package/src/lib/model/notification/notification.util.d.ts +12 -1
- package/src/lib/model/storagefile/storagefile.create.d.ts +1 -0
- package/src/lib/model/storagefile/storagefile.d.ts +1 -0
- package/src/lib/model/storagefile/storagefile.file.d.ts +1 -0
- package/src/lib/model/storagefile/storagefile.permission.d.ts +1 -0
- package/src/lib/model/storagefile/storagefile.upload.d.ts +2 -0
- package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +2 -0
- package/test/index.cjs.js +1038 -1
- package/test/index.esm.js +1031 -3
- package/test/package.json +6 -6
- package/test/src/lib/common/mock/mock.item.d.ts +119 -2
- package/test/src/lib/common/mock/mock.item.service.d.ts +21 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase",
|
|
3
|
-
"version": "13.11.
|
|
3
|
+
"version": "13.11.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"exports": {
|
|
6
6
|
"./test": {
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@dereekb/util": "13.11.
|
|
22
|
-
"@dereekb/date": "13.11.
|
|
23
|
-
"@dereekb/model": "13.11.
|
|
24
|
-
"@dereekb/rxjs": "13.11.
|
|
21
|
+
"@dereekb/util": "13.11.3",
|
|
22
|
+
"@dereekb/date": "13.11.3",
|
|
23
|
+
"@dereekb/model": "13.11.3",
|
|
24
|
+
"@dereekb/rxjs": "13.11.3",
|
|
25
25
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
26
26
|
"arktype": "^2.2.0",
|
|
27
27
|
"date-fns": "^4.1.0",
|
|
@@ -18,5 +18,6 @@ import { type UpdateData } from '../../common/firestore/types';
|
|
|
18
18
|
* });
|
|
19
19
|
* await updateDoc(docRef, updateData);
|
|
20
20
|
* ```
|
|
21
|
+
* @__NO_SIDE_EFFECTS__
|
|
21
22
|
*/
|
|
22
23
|
export declare function firestoreClientArrayUpdateToUpdateData<T extends object>(input: FirestoreAccessorArrayUpdate<T>): UpdateData<T>;
|
|
@@ -32,6 +32,7 @@ export declare class WriteBatchFirestoreDocumentDataAccessor<T> extends DefaultF
|
|
|
32
32
|
* await accessor.set(data);
|
|
33
33
|
* await batch.commit();
|
|
34
34
|
* ```
|
|
35
|
+
* @__NO_SIDE_EFFECTS__
|
|
35
36
|
*/
|
|
36
37
|
export declare function writeBatchAccessorFactory<T>(writeBatch: FirebaseFirestoreWriteBatch): FirestoreDocumentDataAccessorFactory<T>;
|
|
37
38
|
/**
|
|
@@ -15,5 +15,6 @@ import { type WithFieldValue, type WriteResult } from '../../common/firestore/ty
|
|
|
15
15
|
* const create = createWithAccessor(accessor);
|
|
16
16
|
* await create({ name: 'New Item' }); // throws if document already exists
|
|
17
17
|
* ```
|
|
18
|
+
* @__NO_SIDE_EFFECTS__
|
|
18
19
|
*/
|
|
19
20
|
export declare function createWithAccessor<T>(accessor: FirestoreDocumentDataAccessor<T>): (data: WithFieldValue<T>) => Promise<void | WriteResult>;
|
|
@@ -15,5 +15,6 @@ import { type FirestoreAccessorDriver } from '../../common/firestore/driver/acce
|
|
|
15
15
|
* const driver = firestoreClientAccessorDriver();
|
|
16
16
|
* // Used internally by firebaseFirestoreClientDrivers()
|
|
17
17
|
* ```
|
|
18
|
+
* @__NO_SIDE_EFFECTS__
|
|
18
19
|
*/
|
|
19
20
|
export declare function firestoreClientAccessorDriver(): FirestoreAccessorDriver;
|
|
@@ -37,6 +37,7 @@ export declare class DefaultFirestoreDocumentDataAccessor<T> implements Firestor
|
|
|
37
37
|
* const accessor = factory.accessorFor(documentRef);
|
|
38
38
|
* const snapshot = await accessor.get();
|
|
39
39
|
* ```
|
|
40
|
+
* @__NO_SIDE_EFFECTS__
|
|
40
41
|
*/
|
|
41
42
|
export declare function defaultFirestoreAccessorFactory<T>(): FirestoreDocumentDataAccessorFactory<T>;
|
|
42
43
|
/**
|
|
@@ -41,6 +41,7 @@ export declare class TransactionFirestoreDocumentDataAccessor<T> implements Fire
|
|
|
41
41
|
* // ... modify and set
|
|
42
42
|
* });
|
|
43
43
|
* ```
|
|
44
|
+
* @__NO_SIDE_EFFECTS__
|
|
44
45
|
*/
|
|
45
46
|
export declare function transactionAccessorFactory<T>(transaction: FirebaseFirestoreTransaction): FirestoreDocumentDataAccessorFactory<T>;
|
|
46
47
|
/**
|
|
@@ -14,5 +14,6 @@ import { type FirestoreAccessorIncrementUpdate } from '../../common/firestore/ac
|
|
|
14
14
|
* const updateData = firestoreClientIncrementUpdateToUpdateData<MyModel>({ viewCount: 1, likeCount: -1 });
|
|
15
15
|
* await updateDoc(docRef, updateData);
|
|
16
16
|
* ```
|
|
17
|
+
* @__NO_SIDE_EFFECTS__
|
|
17
18
|
*/
|
|
18
19
|
export declare function firestoreClientIncrementUpdateToUpdateData<T extends object>(input: FirestoreAccessorIncrementUpdate<T>): UpdateData<T>;
|
|
@@ -36,5 +36,6 @@ export type DevelopmentFirebaseFunctionMapFactory<M extends DevelopmentFirebaseF
|
|
|
36
36
|
* const devFns = factory(getFunctions());
|
|
37
37
|
* await devFns.resetData();
|
|
38
38
|
* ```
|
|
39
|
+
* @__NO_SIDE_EFFECTS__
|
|
39
40
|
*/
|
|
40
41
|
export declare function developmentFirebaseFunctionMapFactory<M extends DevelopmentFirebaseFunctionTypeMap>(configMap: DevelopmentFirebaseFunctionConfigMap<M>): DevelopmentFirebaseFunctionMapFactory<M>;
|
|
@@ -39,6 +39,7 @@ export type FirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap> = (fun
|
|
|
39
39
|
* const functions = factory(getFunctions());
|
|
40
40
|
* const result = await functions.createUser({ name: 'Alice' });
|
|
41
41
|
* ```
|
|
42
|
+
* @__NO_SIDE_EFFECTS__
|
|
42
43
|
*/
|
|
43
44
|
export declare function firebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>): FirebaseFunctionMapFactory<M>;
|
|
44
45
|
/**
|
|
@@ -109,5 +110,6 @@ export type LazyFirebaseFunctions<M extends FirebaseFunctionsMap> = {
|
|
|
109
110
|
* const lazyFns = factory(getFunctions());
|
|
110
111
|
* const notifFns = lazyFns.notificationFunctions(); // initialized on first call
|
|
111
112
|
* ```
|
|
113
|
+
* @__NO_SIDE_EFFECTS__
|
|
112
114
|
*/
|
|
113
115
|
export declare function lazyFirebaseFunctionsFactory<M extends FirebaseFunctionsMap, C extends FirebaseFunctionsConfigMap<M> = FirebaseFunctionsConfigMap<M>>(configMap: C): LazyFirebaseFunctionsFactory<M>;
|
|
@@ -150,5 +150,6 @@ export type ModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U
|
|
|
150
150
|
* await fns.createNotification(data);
|
|
151
151
|
* await fns.updateNotificationStatus(data);
|
|
152
152
|
* ```
|
|
153
|
+
* @__NO_SIDE_EFFECTS__
|
|
153
154
|
*/
|
|
154
155
|
export declare function callModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>, crudConfigMap: ModelFirebaseCrudFunctionConfigMap<U, FirestoreModelIdentity>): ModelFirebaseFunctionMapFactory<M, U>;
|
|
@@ -242,5 +242,6 @@ export type UpdateWithAccessorUpdateAndConverterFunction<T> = (data: Partial<T>,
|
|
|
242
242
|
* @param accessor - The document accessor to use for updates
|
|
243
243
|
* @param converter - The data converter to transform input data to Firestore format
|
|
244
244
|
* @returns A function that updates the document with converted data
|
|
245
|
+
* @__NO_SIDE_EFFECTS__
|
|
245
246
|
*/
|
|
246
247
|
export declare function updateWithAccessorUpdateAndConverterFunction<T>(accessor: FirestoreDocumentDataAccessor<T>, converter: FirestoreDataConverter<T>): UpdateWithAccessorUpdateAndConverterFunction<T>;
|
|
@@ -136,5 +136,6 @@ export type InterceptAccessorFactoryFunction<T, D = DocumentData> = (input: Fire
|
|
|
136
136
|
* @template D - The raw document data type in Firestore
|
|
137
137
|
* @param wrap - Function to wrap each created accessor
|
|
138
138
|
* @returns A function that transforms accessor factories to use the wrapper
|
|
139
|
+
* @__NO_SIDE_EFFECTS__
|
|
139
140
|
*/
|
|
140
141
|
export declare function interceptAccessorFactoryFunction<T, D = DocumentData>(wrap: WrapFirestoreDocumentDataAccessorFunction<T, D>): InterceptAccessorFactoryFunction<T, D>;
|
|
@@ -60,6 +60,7 @@ export declare class ModifyBeforeSetFirestoreDocumentDataAccessorWrapper<T exten
|
|
|
60
60
|
*
|
|
61
61
|
* @param fieldName - The field to copy the document ID into
|
|
62
62
|
* @returns A modifier function that sets the field to the document's ID
|
|
63
|
+
* @__NO_SIDE_EFFECTS__
|
|
63
64
|
*/
|
|
64
65
|
export declare function copyDocumentIdToFieldModifierFunction<T extends object>(fieldName: keyof T): ModifyBeforeSetModifierFunction<T>;
|
|
65
66
|
/**
|
|
@@ -68,12 +69,14 @@ export declare function copyDocumentIdToFieldModifierFunction<T extends object>(
|
|
|
68
69
|
*
|
|
69
70
|
* @param config - The ModifyBeforeSetConfig defining when and how to modify documents
|
|
70
71
|
* @returns An InterceptAccessorFactoryFunction that wraps accessors with the modify-before-set behavior
|
|
72
|
+
* @__NO_SIDE_EFFECTS__
|
|
71
73
|
*/
|
|
72
74
|
export declare function modifyBeforeSetInterceptAccessorFactoryFunction<T extends object, D = DocumentData>(config: ModifyBeforeSetConfig<T>): InterceptAccessorFactoryFunction<T, D>;
|
|
73
75
|
/**
|
|
74
76
|
* Creates a modifier that copies the document ID to the `uid` field for {@link UserRelated} models.
|
|
75
77
|
*
|
|
76
78
|
* @returns A ModifyBeforeSetModifierFunction that sets the `uid` field to the document's ID
|
|
79
|
+
* @__NO_SIDE_EFFECTS__
|
|
77
80
|
*/
|
|
78
81
|
export declare function copyDocumentIdForUserRelatedModifierFunction<T extends UserRelated>(): ModifyBeforeSetModifierFunction<T>;
|
|
79
82
|
/**
|
|
@@ -92,5 +95,6 @@ export declare const COPY_USER_RELATED_DATA_ACCESSOR_FACTORY_FUNCTION: import("@
|
|
|
92
95
|
* document ID copy modifier to all accessors created by the factory.
|
|
93
96
|
*
|
|
94
97
|
* @returns A typed InterceptAccessorFactoryFunction with the UserRelated document ID copy modifier applied
|
|
98
|
+
* @__NO_SIDE_EFFECTS__
|
|
95
99
|
*/
|
|
96
100
|
export declare function copyUserRelatedDataAccessorFactoryFunction<T extends UserRelated, D = DocumentData>(): InterceptAccessorFactoryFunction<T, D>;
|
|
@@ -17,5 +17,6 @@ export type ArrayFieldUpdateWithAccessorFunction<T> = (data: FirestoreAccessorAr
|
|
|
17
17
|
* @returns A function that applies array updates to the document
|
|
18
18
|
*
|
|
19
19
|
* @see https://firebase.google.com/docs/firestore/manage-data/add-data#update_elements_in_an_array
|
|
20
|
+
* @__NO_SIDE_EFFECTS__
|
|
20
21
|
*/
|
|
21
22
|
export declare function arrayUpdateWithAccessorFunction<T>(accessor: FirestoreDocumentDataAccessor<T>): ArrayFieldUpdateWithAccessorFunction<T>;
|
|
@@ -300,6 +300,7 @@ export interface LimitedFirestoreDocumentAccessorFactoryConfig<T, D extends Fire
|
|
|
300
300
|
*
|
|
301
301
|
* @param config - Configuration including converter, accessor factory, and document factory
|
|
302
302
|
* @returns A factory function for creating LimitedFirestoreDocumentAccessor instances
|
|
303
|
+
* @__NO_SIDE_EFFECTS__
|
|
303
304
|
*/
|
|
304
305
|
export declare function limitedFirestoreDocumentAccessorFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: LimitedFirestoreDocumentAccessorFactoryConfig<T, D>): LimitedFirestoreDocumentAccessorFactoryFunction<T, D>;
|
|
305
306
|
/**
|
|
@@ -324,6 +325,7 @@ export interface FirestoreDocumentAccessorFactoryConfig<T, D extends FirestoreDo
|
|
|
324
325
|
*
|
|
325
326
|
* @param config - Configuration including the collection reference and document factory
|
|
326
327
|
* @returns A factory function for creating FirestoreDocumentAccessor instances
|
|
328
|
+
* @__NO_SIDE_EFFECTS__
|
|
327
329
|
*/
|
|
328
330
|
export declare function firestoreDocumentAccessorFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: FirestoreDocumentAccessorFactoryConfig<T, D>): FirestoreDocumentAccessorFactoryFunction<T, D>;
|
|
329
331
|
export interface LimitedFirestoreDocumentAccessorForTransactionFactory<T, D extends FirestoreDocument<T> = FirestoreDocument<T>, A extends LimitedFirestoreDocumentAccessor<T, D> = LimitedFirestoreDocumentAccessor<T, D>> {
|
|
@@ -357,6 +359,7 @@ export interface FirestoreDocumentAccessorContextExtension<T, D extends Firestor
|
|
|
357
359
|
* @param config.documentAccessor - The document accessor factory function
|
|
358
360
|
* @param config.firestoreAccessorDriver - The firestore accessor driver used to create transaction and write batch contexts
|
|
359
361
|
* @returns An extension object with document accessor factory methods for default, transaction, and write batch contexts
|
|
362
|
+
* @__NO_SIDE_EFFECTS__
|
|
360
363
|
*/
|
|
361
364
|
export declare function firestoreDocumentAccessorContextExtension<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>({ documentAccessor, firestoreAccessorDriver }: FirestoreDocumentAccessorContextExtensionConfig<T, D>): FirestoreDocumentAccessorContextExtension<T, D>;
|
|
362
365
|
export declare function firestoreDocumentAccessorContextExtension<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>({ documentAccessor, firestoreAccessorDriver }: LimitedFirestoreDocumentAccessorContextExtensionConfig<T, D>): LimitedFirestoreDocumentAccessorContextExtension<T, D>;
|
|
@@ -399,6 +402,7 @@ export interface FirestoreSingleDocumentAccessorConfig<T, D extends FirestoreDoc
|
|
|
399
402
|
*
|
|
400
403
|
* @param config - Configuration specifying the single item identifier and the document accessor context extension
|
|
401
404
|
* @returns A FirestoreSingleDocumentAccessor providing convenient access to the single document
|
|
405
|
+
* @__NO_SIDE_EFFECTS__
|
|
402
406
|
*/
|
|
403
407
|
export declare function firestoreSingleDocumentAccessor<T, D extends FirestoreDocument<T> = FirestoreDocument<T>>(config: FirestoreSingleDocumentAccessorConfig<T, D>): FirestoreSingleDocumentAccessor<T, D>;
|
|
404
408
|
/**
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module Firestore Paged Item Accessor
|
|
3
|
+
*
|
|
4
|
+
* Internal read/write orchestration for {@link PagedItemFirestoreCollection}.
|
|
5
|
+
* The accessor distributes a logical `T[]` across N page documents and a
|
|
6
|
+
* single index document under a parent, then merges them back on read.
|
|
7
|
+
*
|
|
8
|
+
* The accessor goes lower-level than the standard
|
|
9
|
+
* {@link FirestoreSingleDocumentAccessor}: it bypasses per-collection
|
|
10
|
+
* converters because page documents (`PagedItemPageData<T>`) and the index
|
|
11
|
+
* document (`PagedItemIndexData`) have different shapes that can't be
|
|
12
|
+
* expressed by a single document converter.
|
|
13
|
+
*/
|
|
14
|
+
import { type Maybe, type Building } from '@dereekb/util';
|
|
15
|
+
import { type Transaction } from '../types';
|
|
16
|
+
import { type FirestoreDocumentAccessorContextExtension } from './document';
|
|
17
|
+
import { type CollectionReferenceRef, type FirestoreContextReference } from '../reference';
|
|
18
|
+
import { type PagedItemConverter, type PagedItemDistributionScheme, type PagedItemIndexData, type PagedItemPageData } from '../collection/subcollection.paged';
|
|
19
|
+
/**
|
|
20
|
+
* Accessor for reading and writing paged item data.
|
|
21
|
+
*
|
|
22
|
+
* Replaces the per-page document accessor exposed on a standard
|
|
23
|
+
* {@link FirestoreCollectionWithParent}. All methods orchestrate the
|
|
24
|
+
* multi-document index/page layout internally.
|
|
25
|
+
*
|
|
26
|
+
* @template T - The item type stored across pages
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* // Read all items (loads index, then all pages in parallel)
|
|
31
|
+
* const allItems = await pagedCollection.loadAllItems();
|
|
32
|
+
*
|
|
33
|
+
* // Read specific pages (static mode — caller knows the scheme)
|
|
34
|
+
* const cItems = await pagedCollection.loadItemsForPages(['c']);
|
|
35
|
+
*
|
|
36
|
+
* // Replace the full T[] (collection handles distribution)
|
|
37
|
+
* await pagedCollection.writeAllItems(allItems);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
export interface FirestorePagedItemAccessor<T> {
|
|
41
|
+
/**
|
|
42
|
+
* ID of the index document.
|
|
43
|
+
*/
|
|
44
|
+
readonly indexDocumentId: string;
|
|
45
|
+
/**
|
|
46
|
+
* The static distribution scheme, if configured.
|
|
47
|
+
*/
|
|
48
|
+
readonly distributionScheme: Maybe<PagedItemDistributionScheme<T>>;
|
|
49
|
+
/**
|
|
50
|
+
* True when a static distribution scheme is configured.
|
|
51
|
+
*/
|
|
52
|
+
readonly isStaticDistribution: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Loads only the index document.
|
|
55
|
+
*
|
|
56
|
+
* Returns `undefined` when the paged collection has never been written
|
|
57
|
+
* (the index document does not yet exist).
|
|
58
|
+
*/
|
|
59
|
+
loadIndex(): Promise<Maybe<PagedItemIndexData>>;
|
|
60
|
+
/**
|
|
61
|
+
* Loads all pages and returns the merged `T[]`.
|
|
62
|
+
*
|
|
63
|
+
* Reads the index, then all listed pages in parallel, merging items in
|
|
64
|
+
* page order. Returns an empty array when the collection has never been
|
|
65
|
+
* written.
|
|
66
|
+
*/
|
|
67
|
+
loadAllItems(): Promise<T[]>;
|
|
68
|
+
/**
|
|
69
|
+
* Loads items from specific page IDs only.
|
|
70
|
+
*
|
|
71
|
+
* In static mode this skips the index read — callers know which pages to
|
|
72
|
+
* fetch from the distribution scheme. In dynamic mode the IDs are numeric
|
|
73
|
+
* strings (`'0'`, `'1'`, ...) and callers should typically discover them
|
|
74
|
+
* via {@link loadIndex} first.
|
|
75
|
+
*
|
|
76
|
+
* Pages that don't exist are silently skipped.
|
|
77
|
+
*
|
|
78
|
+
* @param pageIds - The page IDs to read
|
|
79
|
+
*/
|
|
80
|
+
loadItemsForPages(pageIds: string[]): Promise<T[]>;
|
|
81
|
+
/**
|
|
82
|
+
* Replaces the full `T[]` contents of the paged collection.
|
|
83
|
+
*
|
|
84
|
+
* Distributes items into pages, writes/updates page documents, deletes
|
|
85
|
+
* pages no longer needed, and updates the index — all in a single
|
|
86
|
+
* WriteBatch.
|
|
87
|
+
*
|
|
88
|
+
* @param items - The full set of items to store
|
|
89
|
+
*/
|
|
90
|
+
writeAllItems(items: T[]): Promise<void>;
|
|
91
|
+
/**
|
|
92
|
+
* Same as {@link writeAllItems} but participates in an existing transaction.
|
|
93
|
+
*
|
|
94
|
+
* The accessor reads existing pages within the transaction, computes the
|
|
95
|
+
* new distribution, and writes all changes within the same transaction.
|
|
96
|
+
*
|
|
97
|
+
* Cost: N reads (current pages) + M writes (new pages + deletes + index).
|
|
98
|
+
* For a typical 2–6 page collection this is well within Firestore's
|
|
99
|
+
* transaction limits.
|
|
100
|
+
*
|
|
101
|
+
* @param transaction - Active Firestore transaction
|
|
102
|
+
* @param items - The full set of items to store
|
|
103
|
+
*/
|
|
104
|
+
writeAllItemsInTransaction(transaction: Transaction, items: T[]): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Configuration for {@link extendFirestoreCollectionWithPagedItemAccessor}.
|
|
108
|
+
*
|
|
109
|
+
* @template T - The item type stored across pages
|
|
110
|
+
*/
|
|
111
|
+
export interface PagedItemAccessorExtensionConfig<T> {
|
|
112
|
+
readonly indexDocumentId: string;
|
|
113
|
+
readonly distributionScheme: Maybe<PagedItemDistributionScheme<T>>;
|
|
114
|
+
readonly maxItemsPerPage: number;
|
|
115
|
+
readonly itemConverter: Maybe<PagedItemConverter<T>>;
|
|
116
|
+
/**
|
|
117
|
+
* Standard document accessor extension for the underlying collection.
|
|
118
|
+
* Currently unused (page CRUD goes through the raw driver) but accepted
|
|
119
|
+
* for parity with {@link extendFirestoreCollectionWithSingleDocumentAccessor}
|
|
120
|
+
* and future use.
|
|
121
|
+
*/
|
|
122
|
+
readonly accessors: FirestoreDocumentAccessorContextExtension<PagedItemPageData<T>>;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Extends a Firestore collection object in-place with paged item accessor methods.
|
|
126
|
+
*
|
|
127
|
+
* The collection must already expose {@link CollectionReferenceRef} and
|
|
128
|
+
* {@link FirestoreContextReference} from its base — both are provided by
|
|
129
|
+
* {@link makeFirestoreCollectionWithParent}.
|
|
130
|
+
*
|
|
131
|
+
* @param x - The collection object to extend
|
|
132
|
+
* @param config - Paged accessor configuration
|
|
133
|
+
*/
|
|
134
|
+
export declare function extendFirestoreCollectionWithPagedItemAccessor<X extends FirestorePagedItemAccessor<T> & CollectionReferenceRef<unknown> & FirestoreContextReference, T>(x: Building<X>, config: PagedItemAccessorExtensionConfig<T>): void;
|