@dereekb/firebase 10.0.19 → 10.0.21

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.
Files changed (31) hide show
  1. package/index.cjs.js +52 -27
  2. package/index.esm.js +57 -31
  3. package/package.json +1 -1
  4. package/src/lib/client/firestore/driver.query.d.ts +2 -2
  5. package/src/lib/client/function/development.function.d.ts +2 -2
  6. package/src/lib/client/function/function.callable.d.ts +2 -2
  7. package/src/lib/client/function/function.d.ts +2 -2
  8. package/src/lib/client/function/function.factory.d.ts +5 -5
  9. package/src/lib/client/function/model.function.factory.d.ts +5 -5
  10. package/src/lib/common/auth/auth.d.ts +21 -9
  11. package/src/lib/common/auth/auth.error.d.ts +3 -3
  12. package/src/lib/common/firestore/accessor/accessor.d.ts +2 -2
  13. package/src/lib/common/firestore/accessor/converter.d.ts +1 -1
  14. package/src/lib/common/firestore/collection/collection.key.d.ts +8 -8
  15. package/src/lib/common/firestore/query/accumulator.d.ts +2 -1
  16. package/src/lib/common/firestore/query/constraint.d.ts +15 -15
  17. package/src/lib/common/firestore/query/iterator.d.ts +3 -3
  18. package/src/lib/common/firestore/query/query.iterate.d.ts +20 -2
  19. package/src/lib/common/firestore/query/query.util.d.ts +3 -3
  20. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +9 -9
  21. package/src/lib/common/model/model/model.loader.d.ts +2 -2
  22. package/src/lib/common/storage/accessor/path.model.d.ts +1 -1
  23. package/src/lib/common/storage/context.d.ts +2 -2
  24. package/src/lib/common/storage/driver/accessor.d.ts +5 -5
  25. package/src/lib/common/storage/driver/driver.d.ts +2 -2
  26. package/src/lib/common/storage/storage.d.ts +4 -4
  27. package/src/lib/common/storage/types.d.ts +25 -25
  28. package/test/CHANGELOG.md +8 -0
  29. package/test/package.json +1 -1
  30. package/test/src/lib/common/firestore/test.driver.query.js +28 -0
  31. package/test/src/lib/common/firestore/test.driver.query.js.map +1 -1
package/index.cjs.js CHANGED
@@ -4105,8 +4105,14 @@ function firestoreObjectArray(config) {
4105
4105
  const sortFn = util.sortValuesFunctionOrMapIdentityWithSortRef(config);
4106
4106
  const {
4107
4107
  from,
4108
- to
4108
+ to: baseTo
4109
4109
  } = util.toModelMapFunctions(objectField);
4110
+ const to = x => {
4111
+ // remove null/undefined values from each field when converting to in order to mirror firestore usage (undefined is treated like null)
4112
+ const base = baseTo(x);
4113
+ const filtered = util.filterNullAndUndefinedValues(base);
4114
+ return filtered;
4115
+ };
4110
4116
  return firestoreField({
4111
4117
  default: (_b = config.default) !== null && _b !== void 0 ? _b : () => [],
4112
4118
  defaultBeforeSave: config.defaultBeforeSave,
@@ -4846,6 +4852,7 @@ function iterateFirestoreDocumentSnapshots(config) {
4846
4852
  snapshotsPerformTasksConfig
4847
4853
  } = config;
4848
4854
  return iterateFirestoreDocumentSnapshotBatches(Object.assign(Object.assign({}, config), {
4855
+ maxParallelCheckpoints: 1,
4849
4856
  iterateSnapshotBatch: docSnapshots => __awaiter(this, void 0, void 0, function* () {
4850
4857
  const performTasksResult = yield util.performAsyncTasks(docSnapshots, iterateSnapshot, Object.assign({
4851
4858
  sequential: true
@@ -4873,6 +4880,7 @@ function iterateFirestoreDocumentSnapshotPairBatches(config) {
4873
4880
  documentAccessor
4874
4881
  } = config;
4875
4882
  return iterateFirestoreDocumentSnapshotBatches(Object.assign(Object.assign({}, config), {
4883
+ maxParallelCheckpoints: 1,
4876
4884
  iterateSnapshotBatch: snapshots => __awaiter(this, void 0, void 0, function* () {
4877
4885
  const pairs = snapshots.map(snapshot => {
4878
4886
  const document = documentAccessor.loadDocument(snapshot.ref);
@@ -4942,16 +4950,28 @@ function iterateFirestoreDocumentSnapshotCheckpoints(config) {
4942
4950
  return __awaiter(this, void 0, void 0, function* () {
4943
4951
  const {
4944
4952
  iterateCheckpoint,
4953
+ waitBetweenCheckpoints,
4945
4954
  useCheckpointResult,
4946
4955
  constraintsFactory: inputConstraintsFactory,
4956
+ dynamicConstraints: inputDynamicConstraints,
4947
4957
  queryFactory,
4958
+ maxParallelCheckpoints = 1,
4948
4959
  limitPerCheckpoint,
4949
4960
  totalSnapshotsLimit = Number.MAX_SAFE_INTEGER
4950
4961
  } = config;
4951
- const constraintsFactory = util.asGetter(inputConstraintsFactory);
4952
- let i = 0;
4953
- function iterateFromCursor(cursorDocument) {
4962
+ const constraintsInputIsFactory = typeof inputConstraintsFactory === 'function';
4963
+ const constraintsFactory = constraintsInputIsFactory && inputDynamicConstraints !== false ? inputConstraintsFactory : util.asGetter(util.getValueFromGetter(inputConstraintsFactory));
4964
+ let currentIndex = 0;
4965
+ let hasReachedEnd = false;
4966
+ let totalSnapshotsVisited = 0;
4967
+ let cursorDocument;
4968
+ function taskInputFactory() {
4954
4969
  return __awaiter(this, void 0, void 0, function* () {
4970
+ // Perform another query, then pass the results to the task factory.
4971
+ if (hasReachedEnd) {
4972
+ return null; // issue no more tasks
4973
+ }
4974
+
4955
4975
  const constraints = constraintsFactory();
4956
4976
  const startAfterFilter = cursorDocument ? startAfter(cursorDocument) : undefined;
4957
4977
  if (startAfterFilter) {
@@ -4962,6 +4982,29 @@ function iterateFirestoreDocumentSnapshotCheckpoints(config) {
4962
4982
  }
4963
4983
  const query = queryFactory.query(constraints);
4964
4984
  const docQuerySnapshot = yield query.getDocs();
4985
+ const docSnapshots = docQuerySnapshot.docs;
4986
+ cursorDocument = util.lastValue(docSnapshots); // set the next cursor document
4987
+ const newSnapshotsVisited = docSnapshots.length;
4988
+ totalSnapshotsVisited += newSnapshotsVisited;
4989
+ if (!cursorDocument || totalSnapshotsVisited > totalSnapshotsLimit) {
4990
+ hasReachedEnd = true; // mark as having reached the end
4991
+ }
4992
+
4993
+ const i = currentIndex;
4994
+ currentIndex += 1; // increase our current index
4995
+ return {
4996
+ i,
4997
+ docQuerySnapshot
4998
+ };
4999
+ });
5000
+ }
5001
+ const performTaskFn = util.performTasksFromFactoryInParallelFunction({
5002
+ maxParallelTasks: maxParallelCheckpoints,
5003
+ waitBetweenTasks: waitBetweenCheckpoints,
5004
+ taskFactory: ({
5005
+ i,
5006
+ docQuerySnapshot
5007
+ }) => __awaiter(this, void 0, void 0, function* () {
4965
5008
  const docSnapshots = docQuerySnapshot.docs;
4966
5009
  const results = yield iterateCheckpoint(docSnapshots, docQuerySnapshot);
4967
5010
  const checkpointResults = {
@@ -4970,30 +5013,12 @@ function iterateFirestoreDocumentSnapshotCheckpoints(config) {
4970
5013
  results,
4971
5014
  docSnapshots
4972
5015
  };
4973
- return checkpointResults;
4974
- });
4975
- }
4976
- let cursorDocument;
4977
- let totalSnapshotsVisited = 0;
4978
- while (true) {
4979
- const iterateResults = yield iterateFromCursor(cursorDocument);
4980
- yield useCheckpointResult === null || useCheckpointResult === void 0 ? void 0 : useCheckpointResult(iterateResults);
4981
- const newSnapshotsVisited = iterateResults.docSnapshots.length;
4982
- const hasResults = newSnapshotsVisited > 0;
4983
- if (hasResults) {
4984
- cursorDocument = hasResults ? util.lastValue(iterateResults.docSnapshots) : undefined;
4985
- i += 1;
4986
- totalSnapshotsVisited += newSnapshotsVisited;
4987
- // if at the limit, bail out
4988
- if (totalSnapshotsVisited > totalSnapshotsLimit) {
4989
- break;
4990
- }
4991
- } else {
4992
- break;
4993
- }
4994
- }
5016
+ yield useCheckpointResult === null || useCheckpointResult === void 0 ? void 0 : useCheckpointResult(checkpointResults);
5017
+ })
5018
+ });
5019
+ yield performTaskFn(taskInputFactory);
4995
5020
  const result = {
4996
- totalCheckpoints: i,
5021
+ totalCheckpoints: currentIndex,
4997
5022
  totalSnapshotsVisited
4998
5023
  };
4999
5024
  return result;
package/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { increment, onSnapshot, getDoc, deleteDoc, setDoc, updateDoc, doc, collectionGroup, collection, runTransaction, writeBatch, limit as limit$1, limitToLast as limitToLast$1, orderBy as orderBy$1, documentId, where as where$1, startAt as startAt$1, startAfter as startAfter$1, endAt as endAt$1, endBefore as endBefore$1, getDocs, query } from 'firebase/firestore';
2
- import { cachedGetter, mergeModifiers, asArray, filterUndefinedValues, objectHasNoKeys, filterFalsyAndEmptyValues, build, wrapUseAsyncFunction, makeWithFactory, performMakeLoop, runAsyncTasksForValues, filterMaybeValues, useAsync, toModelFieldConversions, makeModelMapFunctions, modifyModelMapFunctions, assignValuesToPOJOFunction, KeyValueTypleValueFilter, asObjectCopyFactory, passThrough, isEqualToValueDecisionFunction, transformStringFunctionConfig, transformStringFunction, isDate, transformNumberFunction, sortValuesFunctionOrMapIdentityWithSortRef, isMapIdentityFunction, chainMapSameFunctions, filterUniqueFunction, unique, filterUniqueTransform, filterFromPOJOFunction, mapObjectMapFunction, copyObject, mapObjectMap, filterEmptyValues, modelFieldMapFunctions, toModelMapFunctions, latLngStringFunction, DEFAULT_LAT_LNG_STRING_VALUE, sortAscendingIndexNumberRefFunction, bitwiseSetDencoder, convertToArray, pushItemOrArrayItemsIntoArray, separateValues, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, mergeArraysIntoArray, lastValue, flattenArrayOrValueArray, performAsyncTasks, batch, asGetter, groupValues, forEachInIterable, arrayToObject, takeFront, isOddNumber, objectToMap, ServerErrorResponse, toReadableError, capitalizeFirstLetter, lowercaseFirstLetter, toRelativeSlashPathStartType, mappedUseFunction, iterableToArray, getValueFromGetter, setContainsAllValues, usePromise, slashPathFactory, errorMessageContainsString } from '@dereekb/util';
2
+ import { cachedGetter, mergeModifiers, asArray, filterUndefinedValues, objectHasNoKeys, filterFalsyAndEmptyValues, build, wrapUseAsyncFunction, makeWithFactory, performMakeLoop, runAsyncTasksForValues, filterMaybeValues, useAsync, toModelFieldConversions, makeModelMapFunctions, modifyModelMapFunctions, assignValuesToPOJOFunction, KeyValueTypleValueFilter, asObjectCopyFactory, passThrough, isEqualToValueDecisionFunction, transformStringFunctionConfig, transformStringFunction, isDate, transformNumberFunction, sortValuesFunctionOrMapIdentityWithSortRef, isMapIdentityFunction, chainMapSameFunctions, filterUniqueFunction, unique, filterUniqueTransform, filterFromPOJOFunction, mapObjectMapFunction, copyObject, mapObjectMap, filterEmptyValues, modelFieldMapFunctions, toModelMapFunctions, latLngStringFunction, DEFAULT_LAT_LNG_STRING_VALUE, sortAscendingIndexNumberRefFunction, bitwiseSetDencoder, filterNullAndUndefinedValues, convertToArray, pushItemOrArrayItemsIntoArray, separateValues, UTF_8_START_CHARACTER, UTF_PRIVATE_USAGE_AREA_START, mergeArraysIntoArray, lastValue, flattenArrayOrValueArray, performAsyncTasks, batch, asGetter, getValueFromGetter, performTasksFromFactoryInParallelFunction, groupValues, forEachInIterable, arrayToObject, takeFront, isOddNumber, objectToMap, ServerErrorResponse, toReadableError, capitalizeFirstLetter, lowercaseFirstLetter, toRelativeSlashPathStartType, mappedUseFunction, iterableToArray, setContainsAllValues, usePromise, slashPathFactory, errorMessageContainsString } from '@dereekb/util';
3
3
  import { filterMaybe, lazyFrom, itemAccumulator, ItemPageIterator, MappedPageItemIterationInstance } from '@dereekb/rxjs';
4
4
  import { from, map, combineLatest, shareReplay, of, exhaustMap, Observable, switchMap, timer, skip } from 'rxjs';
5
5
  import { UNKNOWN_WEBSITE_LINK_TYPE, decodeWebsiteLinkEncodedDataToWebsiteFileLink, encodeWebsiteFileLinkToWebsiteLinkEncodedData, AbstractModelPermissionService, grantedRoleMapReader, noAccessRoleMap, fullAccessRoleMap } from '@dereekb/model';
@@ -4327,8 +4327,14 @@ function firestoreObjectArray(config) {
4327
4327
  const sortFn = sortValuesFunctionOrMapIdentityWithSortRef(config);
4328
4328
  const {
4329
4329
  from,
4330
- to
4330
+ to: baseTo
4331
4331
  } = toModelMapFunctions(objectField);
4332
+ const to = x => {
4333
+ // remove null/undefined values from each field when converting to in order to mirror firestore usage (undefined is treated like null)
4334
+ const base = baseTo(x);
4335
+ const filtered = filterNullAndUndefinedValues(base);
4336
+ return filtered;
4337
+ };
4332
4338
  return firestoreField({
4333
4339
  default: (_config$default9 = config.default) != null ? _config$default9 : () => [],
4334
4340
  defaultBeforeSave: config.defaultBeforeSave,
@@ -5323,6 +5329,7 @@ async function iterateFirestoreDocumentSnapshots(config) {
5323
5329
  snapshotsPerformTasksConfig
5324
5330
  } = config;
5325
5331
  return iterateFirestoreDocumentSnapshotBatches(Object.assign({}, config, {
5332
+ maxParallelCheckpoints: 1,
5326
5333
  iterateSnapshotBatch: async docSnapshots => {
5327
5334
  const performTasksResult = await performAsyncTasks(docSnapshots, iterateSnapshot, Object.assign({
5328
5335
  sequential: true
@@ -5352,6 +5359,7 @@ async function iterateFirestoreDocumentSnapshotPairBatches(config) {
5352
5359
  documentAccessor
5353
5360
  } = config;
5354
5361
  return iterateFirestoreDocumentSnapshotBatches(Object.assign({}, config, {
5362
+ maxParallelCheckpoints: 1,
5355
5363
  iterateSnapshotBatch: async snapshots => {
5356
5364
  const pairs = snapshots.map(snapshot => {
5357
5365
  const document = documentAccessor.loadDocument(snapshot.ref);
@@ -5436,15 +5444,27 @@ async function iterateFirestoreDocumentSnapshotBatches(config) {
5436
5444
  async function iterateFirestoreDocumentSnapshotCheckpoints(config) {
5437
5445
  const {
5438
5446
  iterateCheckpoint,
5447
+ waitBetweenCheckpoints,
5439
5448
  useCheckpointResult,
5440
5449
  constraintsFactory: inputConstraintsFactory,
5450
+ dynamicConstraints: inputDynamicConstraints,
5441
5451
  queryFactory,
5452
+ maxParallelCheckpoints = 1,
5442
5453
  limitPerCheckpoint,
5443
5454
  totalSnapshotsLimit = Number.MAX_SAFE_INTEGER
5444
5455
  } = config;
5445
- const constraintsFactory = asGetter(inputConstraintsFactory);
5446
- let i = 0;
5447
- async function iterateFromCursor(cursorDocument) {
5456
+ const constraintsInputIsFactory = typeof inputConstraintsFactory === 'function';
5457
+ const constraintsFactory = constraintsInputIsFactory && inputDynamicConstraints !== false ? inputConstraintsFactory : asGetter(getValueFromGetter(inputConstraintsFactory));
5458
+ let currentIndex = 0;
5459
+ let hasReachedEnd = false;
5460
+ let totalSnapshotsVisited = 0;
5461
+ let cursorDocument;
5462
+ async function taskInputFactory() {
5463
+ // Perform another query, then pass the results to the task factory.
5464
+ if (hasReachedEnd) {
5465
+ return null; // issue no more tasks
5466
+ }
5467
+
5448
5468
  const constraints = constraintsFactory();
5449
5469
  const startAfterFilter = cursorDocument ? startAfter(cursorDocument) : undefined;
5450
5470
  if (startAfterFilter) {
@@ -5456,37 +5476,43 @@ async function iterateFirestoreDocumentSnapshotCheckpoints(config) {
5456
5476
  const query = queryFactory.query(constraints);
5457
5477
  const docQuerySnapshot = await query.getDocs();
5458
5478
  const docSnapshots = docQuerySnapshot.docs;
5459
- const results = await iterateCheckpoint(docSnapshots, docQuerySnapshot);
5460
- const checkpointResults = {
5479
+ cursorDocument = lastValue(docSnapshots); // set the next cursor document
5480
+
5481
+ const newSnapshotsVisited = docSnapshots.length;
5482
+ totalSnapshotsVisited += newSnapshotsVisited;
5483
+ if (!cursorDocument || totalSnapshotsVisited > totalSnapshotsLimit) {
5484
+ hasReachedEnd = true; // mark as having reached the end
5485
+ }
5486
+
5487
+ const i = currentIndex;
5488
+ currentIndex += 1; // increase our current index
5489
+
5490
+ return {
5461
5491
  i,
5462
- cursorDocument,
5463
- results,
5464
- docSnapshots
5492
+ docQuerySnapshot
5465
5493
  };
5466
- return checkpointResults;
5467
5494
  }
5468
- let cursorDocument;
5469
- let totalSnapshotsVisited = 0;
5470
- while (true) {
5471
- const iterateResults = await iterateFromCursor(cursorDocument);
5472
- await (useCheckpointResult == null ? void 0 : useCheckpointResult(iterateResults));
5473
- const newSnapshotsVisited = iterateResults.docSnapshots.length;
5474
- const hasResults = newSnapshotsVisited > 0;
5475
- if (hasResults) {
5476
- cursorDocument = hasResults ? lastValue(iterateResults.docSnapshots) : undefined;
5477
- i += 1;
5478
- totalSnapshotsVisited += newSnapshotsVisited;
5479
-
5480
- // if at the limit, bail out
5481
- if (totalSnapshotsVisited > totalSnapshotsLimit) {
5482
- break;
5483
- }
5484
- } else {
5485
- break;
5495
+ const performTaskFn = performTasksFromFactoryInParallelFunction({
5496
+ maxParallelTasks: maxParallelCheckpoints,
5497
+ waitBetweenTasks: waitBetweenCheckpoints,
5498
+ taskFactory: async ({
5499
+ i,
5500
+ docQuerySnapshot
5501
+ }) => {
5502
+ const docSnapshots = docQuerySnapshot.docs;
5503
+ const results = await iterateCheckpoint(docSnapshots, docQuerySnapshot);
5504
+ const checkpointResults = {
5505
+ i,
5506
+ cursorDocument,
5507
+ results,
5508
+ docSnapshots
5509
+ };
5510
+ await (useCheckpointResult == null ? void 0 : useCheckpointResult(checkpointResults));
5486
5511
  }
5487
- }
5512
+ });
5513
+ await performTaskFn(taskInputFactory);
5488
5514
  const result = {
5489
- totalCheckpoints: i,
5515
+ totalCheckpoints: currentIndex,
5490
5516
  totalSnapshotsVisited
5491
5517
  };
5492
5518
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/firebase",
3
- "version": "10.0.19",
3
+ "version": "10.0.21",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -4,8 +4,8 @@ import { type FullFirestoreQueryConstraintHandlersMapping } from './../../common
4
4
  import { type FirestoreQueryConstraintFunctionsDriver, type FirestoreQueryDriver } from '../../common/firestore/driver/query';
5
5
  import { type Query } from '../../common/firestore/types';
6
6
  export interface FirebaseFirestoreQueryBuilder {
7
- query: Query;
8
- constraints: QueryConstraint[];
7
+ readonly query: Query;
8
+ readonly constraints: QueryConstraint[];
9
9
  }
10
10
  export declare function addConstraintToBuilder(builder: FirebaseFirestoreQueryBuilder, constraint: ArrayOrValue<QueryConstraint>): FirebaseFirestoreQueryBuilder;
11
11
  export declare const FIRESTORE_CLIENT_QUERY_CONSTRAINT_HANDLER_MAPPING: FullFirestoreQueryConstraintHandlersMapping<FirebaseFirestoreQueryBuilder>;
@@ -8,7 +8,7 @@ export declare const FIREBASE_DEVELOPMENT_FUNCTIONS_MAP_KEY = "developmentFuncti
8
8
  * Base map of all development functions enabled by the server.
9
9
  */
10
10
  export type FirebaseDevelopmentFunctionTypeMap = {
11
- scheduledFunction: [ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFirebaseFunctionResult];
11
+ readonly scheduledFunction: [ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFirebaseFunctionResult];
12
12
  };
13
13
  /**
14
14
  * Base DevelopmentFirebaseFunctionMap for all development functions enabled by the server (via firebaseServerDevFunctions())
@@ -16,5 +16,5 @@ export type FirebaseDevelopmentFunctionTypeMap = {
16
16
  * Is used by dbx-firebase
17
17
  */
18
18
  export declare abstract class FirebaseDevelopmentFunctions {
19
- abstract scheduledFunction: FirebaseFunction<ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFirebaseFunctionResult>;
19
+ abstract readonly scheduledFunction: FirebaseFunction<ScheduledFunctionDevelopmentFirebaseFunctionParams, ScheduledFunctionDevelopmentFirebaseFunctionResult>;
20
20
  }
@@ -1,8 +1,8 @@
1
1
  import { type FactoryWithInput, type Maybe, type PromiseOrValue } from '@dereekb/util';
2
2
  import { type HttpsCallable } from 'firebase/functions';
3
3
  export interface MapHttpsCallable<I, O, A, B> {
4
- mapInput?: FactoryWithInput<PromiseOrValue<A>, Maybe<I>>;
5
- mapOutput?: FactoryWithInput<PromiseOrValue<O>, Maybe<B>>;
4
+ readonly mapInput?: FactoryWithInput<PromiseOrValue<A>, Maybe<I>>;
5
+ readonly mapOutput?: FactoryWithInput<PromiseOrValue<O>, Maybe<B>>;
6
6
  }
7
7
  /**
8
8
  * Maps input and output values when using HttpsCallable.
@@ -14,13 +14,13 @@ export type FirebaseFunction<I = unknown, O = unknown> = (input: I) => Promise<O
14
14
  * Type with keys corresponding to functions on the corresponding server for a client.
15
15
  */
16
16
  export type FirebaseFunctionTypeMap = {
17
- [key: FirebaseFunctionKey]: FirebaseFunctionType;
17
+ readonly [key: FirebaseFunctionKey]: FirebaseFunctionType;
18
18
  };
19
19
  /**
20
20
  * A FirebaseFunction map. Its types are relative to a FirebaseFunctionTypeMap.
21
21
  */
22
22
  export type FirebaseFunctionMap<M extends FirebaseFunctionTypeMap> = {
23
- [K in keyof M]: FirebaseFunctionMapFunction<M, K>;
23
+ readonly [K in keyof M]: FirebaseFunctionMapFunction<M, K>;
24
24
  };
25
25
  /**
26
26
  * Typings for a function within a FirebaseFunctionMap.
@@ -2,10 +2,10 @@ import { type ClassLikeType, type Getter, type Maybe } from '@dereekb/util';
2
2
  import { type Functions, type HttpsCallableOptions } from 'firebase/functions';
3
3
  import { type FirebaseFunctionMap, type FirebaseFunctionTypeMap } from './function';
4
4
  export interface FirebaseFunctionTypeConfig {
5
- options?: HttpsCallableOptions;
5
+ readonly options?: HttpsCallableOptions;
6
6
  }
7
7
  export type FirebaseFunctionTypeConfigMap<M extends FirebaseFunctionTypeMap> = {
8
- [K in keyof M]: Maybe<FirebaseFunctionTypeConfig>;
8
+ readonly [K in keyof M]: Maybe<FirebaseFunctionTypeConfig>;
9
9
  };
10
10
  /**
11
11
  * Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
@@ -21,10 +21,10 @@ export type FirebaseFunctionGetter<T> = Getter<T> & {
21
21
  * Map of all firebase functions in the app.
22
22
  */
23
23
  export type FirebaseFunctionsMap = {
24
- [key: FirebaseFunctionMapKey]: FirebaseFunctionTypeMap;
24
+ readonly [key: FirebaseFunctionMapKey]: FirebaseFunctionTypeMap;
25
25
  };
26
26
  export type FirebaseFunctionsConfigMap<M extends FirebaseFunctionsMap> = {
27
- [K in keyof M]: FirebaseFunctionsConfigMapEntry<M[K]>;
27
+ readonly [K in keyof M]: FirebaseFunctionsConfigMapEntry<M[K]>;
28
28
  };
29
29
  export type FirebaseFunctionsConfigMapEntry<M extends FirebaseFunctionTypeMap> = [ClassLikeType, FirebaseFunctionMapFactory<M>];
30
30
  /**
@@ -35,6 +35,6 @@ export type LazyFirebaseFunctionsFactory<M extends FirebaseFunctionsMap> = (func
35
35
  * Map of FirebaseFunctionGetter values that are lazy-loaded via the getter.
36
36
  */
37
37
  export type LazyFirebaseFunctions<M extends FirebaseFunctionsMap> = {
38
- [K in keyof M]: FirebaseFunctionGetter<FirebaseFunctionMap<M[K]>>;
38
+ readonly [K in keyof M]: FirebaseFunctionGetter<FirebaseFunctionMap<M[K]>>;
39
39
  };
40
40
  export declare function lazyFirebaseFunctionsFactory<M extends FirebaseFunctionsMap, C extends FirebaseFunctionsConfigMap<M> = FirebaseFunctionsConfigMap<M>>(configMap: C): LazyFirebaseFunctionsFactory<M>;
@@ -13,7 +13,7 @@ export type ModelFirebaseCrudFunctionSpecifier = string;
13
13
  * Provides a reference to a ModelFirebaseCrudFunctionSpecifier if available.
14
14
  */
15
15
  export type ModelFirebaseCrudFunctionSpecifierRef = {
16
- specifier?: ModelFirebaseCrudFunctionSpecifier;
16
+ readonly specifier?: ModelFirebaseCrudFunctionSpecifier;
17
17
  };
18
18
  export type ModelFirebaseCrudFunction<I, O = void> = FirebaseFunction<I, O>;
19
19
  export type ModelFirebaseCreateFunction<I, O extends OnCallCreateModelResult = OnCallCreateModelResult> = ModelFirebaseCrudFunction<I, O>;
@@ -27,16 +27,16 @@ export type ModelFirebaseCrudFunctionTypeMapEntry = MaybeNot | Partial<ModelFire
27
27
  export type ModelFirebaseCrudFunctionTypeMapEntryWithReturnType<I = unknown, O = unknown> = [I, O];
28
28
  export type ModelFirebaseCrudFunctionTypeSpecifierConfig = Record<string | number, unknown | ModelFirebaseCrudFunctionTypeMapEntryWithReturnType>;
29
29
  export type ModelFirebaseCrudFunctionCreateTypeConfig = {
30
- create: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
30
+ readonly create: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
31
31
  };
32
32
  export type ModelFirebaseCrudFunctionReadTypeConfig = {
33
- read: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
33
+ readonly read: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
34
34
  };
35
35
  export type ModelFirebaseCrudFunctionUpdateTypeConfig = {
36
- update: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
36
+ readonly update: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
37
37
  };
38
38
  export type ModelFirebaseCrudFunctionDeleteTypeConfig = {
39
- delete: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
39
+ readonly delete: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
40
40
  };
41
41
  export declare const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT = "_";
42
42
  export type ModelFirebaseCrudFunctionSpecifierDefault = typeof MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT;
@@ -20,16 +20,28 @@ export interface FirebaseAuthUserIdRef {
20
20
  * Firebase Auth Token interface
21
21
  */
22
22
  export interface FirebaseAuthToken {
23
- email?: Maybe<string>;
24
- emailVerified?: Maybe<boolean>;
25
- phoneNumber?: Maybe<PhoneNumber>;
26
- creationTime?: Maybe<ISO8601DateString>;
27
- lastSignInTime?: Maybe<ISO8601DateString>;
23
+ readonly email?: Maybe<string>;
24
+ readonly emailVerified?: Maybe<boolean>;
25
+ readonly phoneNumber?: Maybe<PhoneNumber>;
26
+ /**
27
+ * The date the user was created.
28
+ */
29
+ readonly creationTime?: Maybe<ISO8601DateString>;
30
+ /**
31
+ * The last time the user signed in.
32
+ *
33
+ * This is not necessarily the last time they used the app, just the last time the auth system gave them a refresh token.
34
+ */
35
+ readonly lastSignInTime?: Maybe<ISO8601DateString>;
36
+ /**
37
+ * The last time the user refreshed their token. The best indicator of recent activity.
38
+ */
39
+ readonly lastRefreshTime?: Maybe<ISO8601DateString>;
28
40
  }
29
- export interface FirebaseAuthDetails extends FirebaseAuthToken, FirebaseAuthUserIdRef {
30
- disabled?: Maybe<boolean>;
31
- displayName?: Maybe<string>;
32
- photoURL?: Maybe<WebsiteUrl>;
41
+ export interface FirebaseAuthDetails extends FirebaseAuthToken, Readonly<FirebaseAuthUserIdRef> {
42
+ readonly disabled?: Maybe<boolean>;
43
+ readonly displayName?: Maybe<string>;
44
+ readonly photoURL?: Maybe<WebsiteUrl>;
33
45
  }
34
46
  /**
35
47
  * A string key used to test for ownership of a particular set of objects.
@@ -1,9 +1,9 @@
1
1
  import { type ReadableError } from '@dereekb/util';
2
2
  import { type FirebaseErrorCode } from '../error';
3
3
  export interface FirebaseAuthError {
4
- code: FirebaseErrorCode;
5
- name: string;
6
- customData: unknown;
4
+ readonly code: FirebaseErrorCode;
5
+ readonly name: string;
6
+ readonly customData: unknown;
7
7
  }
8
8
  export declare const FIREBASE_AUTH_USER_NOT_FOUND_ERROR = "auth/user-not-found";
9
9
  export declare const FIREBASE_AUTH_WRONG_PASSWORD = "auth/wrong-password";
@@ -4,10 +4,10 @@ import { type Observable, type OperatorFunction } from 'rxjs';
4
4
  import { type DocumentReferenceRef } from '../reference';
5
5
  import { type PickProperties } from 'ts-essentials';
6
6
  export interface FirestoreDocumentDeleteParams {
7
- precondition?: Precondition;
7
+ readonly precondition?: Precondition;
8
8
  }
9
9
  export interface FirestoreDocumentUpdateParams {
10
- precondition?: Precondition;
10
+ readonly precondition?: Precondition;
11
11
  }
12
12
  /**
13
13
  * Used for performing increment updates.
@@ -8,7 +8,7 @@ export type FirestoreDataConverterFactory<T> = FactoryWithInput<FirestoreDataCon
8
8
  * Ref to a FirestoreDataConverterFactory.
9
9
  */
10
10
  export interface FirestoreDataConverterFactoryRef<T> {
11
- converterFactory: FirestoreDataConverterFactory<T>;
11
+ readonly converterFactory: FirestoreDataConverterFactory<T>;
12
12
  }
13
13
  /**
14
14
  * Factory used to provide an optional custom FirestoreDataConverter based on the input reference.
@@ -2,7 +2,7 @@ import { type GrantedRole } from '@dereekb/model';
2
2
  import { type FirebaseAuthUserId } from '../../auth';
3
3
  import { type FirestoreModelId, type FirestoreModelKey } from './collection';
4
4
  export type FirestoreModelKeyMap<T> = {
5
- [key: FirestoreModelKey]: T;
5
+ readonly [key: FirestoreModelKey]: T;
6
6
  };
7
7
  /**
8
8
  * Array of FirestoreModelKey values.
@@ -12,16 +12,16 @@ export type FirestoreModelKeyArray = FirestoreModelKey[];
12
12
  * A map with a single GrantedRole provided for a given model.
13
13
  */
14
14
  export type FirestoreModelKeyGrantedRoleMap<R extends GrantedRole> = {
15
- [key: FirestoreModelKey]: R;
15
+ readonly [key: FirestoreModelKey]: R;
16
16
  };
17
17
  /**
18
18
  * A map with multiple GrantedRoles provided for a given model.
19
19
  */
20
20
  export type FirestoreModelKeyGrantedRoleArrayMap<R extends GrantedRole> = {
21
- [key: FirestoreModelKey]: R[];
21
+ readonly [key: FirestoreModelKey]: R[];
22
22
  };
23
23
  export type FirestoreModelIdMap<T> = {
24
- [key: FirestoreModelId]: T;
24
+ readonly [key: FirestoreModelId]: T;
25
25
  };
26
26
  /**
27
27
  * Array of FirestoreModelId values.
@@ -31,23 +31,23 @@ export type FirestoreModelIdArray = FirestoreModelId[];
31
31
  * A map with a single GrantedRole provided for a given model.
32
32
  */
33
33
  export type FirestoreModelIdGrantedRoleMap<R extends GrantedRole> = {
34
- [key: FirestoreModelId]: R;
34
+ readonly [key: FirestoreModelId]: R;
35
35
  };
36
36
  /**
37
37
  * A map with multiple GrantedRoles provided for a given model.
38
38
  */
39
39
  export type FirestoreModelIdGrantedRoleArrayMap<R extends GrantedRole> = {
40
- [key: FirestoreModelId]: R[];
40
+ readonly [key: FirestoreModelId]: R[];
41
41
  };
42
42
  /**
43
43
  * A map with a single GrantedRole provided for a given user.
44
44
  */
45
45
  export type FirebaseAuthUserGrantedRoleMap<R extends GrantedRole> = {
46
- [key: FirebaseAuthUserId]: R;
46
+ readonly [key: FirebaseAuthUserId]: R;
47
47
  };
48
48
  /**
49
49
  * A map with multiple GrantedRoles provided for a given user.
50
50
  */
51
51
  export type FirebaseAuthUserRoleArrayMap<R extends GrantedRole> = {
52
- [key: FirestoreModelKey]: R[];
52
+ readonly [key: FirestoreModelKey]: R[];
53
53
  };
@@ -1,4 +1,4 @@
1
- import { type ItemAccumulatorInstance, type ItemAccumulatorMapFunction, type PageItemIteration } from '@dereekb/rxjs';
1
+ import { type ItemAccumulatorNextPageUntilResultsCountFunction, type ItemAccumulatorInstance, type ItemAccumulatorMapFunction, type PageItemIteration } from '@dereekb/rxjs';
2
2
  import { type MapFunction } from '@dereekb/util';
3
3
  import { type DocumentDataWithIdAndKey, type QueryDocumentSnapshotArray } from '../types';
4
4
  import { type FirestoreItemPageIterationInstance } from './iterator';
@@ -8,6 +8,7 @@ export type FirebaseQuerySnapshotAccumulator<T> = MappedFirebaseQuerySnapshotAcc
8
8
  * Mapped accumulator for QueryDocumentSnapshotArray values that returns the DocumentDataWithId values for the items returned in the query.
9
9
  */
10
10
  export type FirebaseQueryItemAccumulator<T> = MappedFirebaseQuerySnapshotAccumulator<DocumentDataWithIdAndKey<T>[], T>;
11
+ export type FirebaseQueryItemAccumulatorNextPageUntilResultsCountFunction<T> = ItemAccumulatorNextPageUntilResultsCountFunction<DocumentDataWithIdAndKey<T>[]>;
11
12
  /**
12
13
  * Wrapper for itemAccumulator that has typings for a FirestoreItemPageIterationInstance. Can optionally map the snapshots to another type.
13
14
  *
@@ -6,14 +6,14 @@ export type FirestoreQueryConstraintType = string;
6
6
  * A constraint. Used by drivers to apply native firebase query constraints.
7
7
  */
8
8
  export interface FirestoreQueryConstraint<T = unknown> {
9
- type: FirestoreQueryConstraintType;
10
- data: T;
9
+ readonly type: FirestoreQueryConstraintType;
10
+ readonly data: T;
11
11
  }
12
12
  export declare function firestoreQueryConstraint<T = unknown>(type: string, data: T): FirestoreQueryConstraint<T>;
13
13
  export declare function firestoreQueryConstraintFactory(type: string): <T = unknown>(data: T) => FirestoreQueryConstraint<T>;
14
14
  export declare const FIRESTORE_LIMIT_QUERY_CONSTRAINT_TYPE = "limit";
15
15
  export interface LimitQueryConstraintData {
16
- limit: number;
16
+ readonly limit: number;
17
17
  }
18
18
  /**
19
19
  * Limits the maximum number of documents to return.
@@ -24,7 +24,7 @@ export interface LimitQueryConstraintData {
24
24
  export declare function limit(limit: number): FirestoreQueryConstraint<LimitQueryConstraintData>;
25
25
  export declare const FIRESTORE_LIMIT_TO_LAST_QUERY_CONSTRAINT_TYPE = "limit_to_last";
26
26
  export interface LimitToLastQueryConstraintData {
27
- limit: number;
27
+ readonly limit: number;
28
28
  }
29
29
  /**
30
30
  * Returns the last matching documents in the query, up to the limit.
@@ -55,9 +55,9 @@ export type WhereFilterOp = WhereFilterOpValue | WhereFilterOpArrayValue;
55
55
  */
56
56
  export declare const FIRESTORE_MAX_WHERE_IN_FILTER_ARGS_COUNT = 10;
57
57
  export interface WhereQueryConstraintData {
58
- fieldPath: string | FieldPath;
59
- opStr: WhereFilterOp;
60
- value: unknown;
58
+ readonly fieldPath: string | FieldPath;
59
+ readonly opStr: WhereFilterOp;
60
+ readonly value: unknown;
61
61
  }
62
62
  /**
63
63
  * Configures a Firebase where query.
@@ -76,8 +76,8 @@ export declare function whereDocumentId(opStr: WhereFilterOp, value: unknown): F
76
76
  export declare const FIRESTORE_ORDER_BY_QUERY_CONSTRAINT_TYPE = "order_by";
77
77
  export type OrderByDirection = SortingOrder;
78
78
  export interface OrderByQueryConstraintData {
79
- fieldPath: FieldPathOrStringPath;
80
- directionStr?: OrderByDirection;
79
+ readonly fieldPath: FieldPathOrStringPath;
80
+ readonly directionStr?: OrderByDirection;
81
81
  }
82
82
  export declare function orderBy<T>(fieldPath: StringKeyPropertyKeys<T>, directionStr?: OrderByDirection): FirestoreQueryConstraint<OrderByQueryConstraintData>;
83
83
  export declare function orderBy(fieldPath: FieldPathOrStringPath, directionStr?: OrderByDirection): FirestoreQueryConstraint<OrderByQueryConstraintData>;
@@ -91,21 +91,21 @@ export interface StartAtQueryConstraintData<T = DocumentData> {
91
91
  export declare function startAt<T = DocumentData>(snapshot: DocumentSnapshot<T>): FirestoreQueryConstraint<StartAtQueryConstraintData<T>>;
92
92
  export declare const FIRESTORE_START_AT_VALUE_QUERY_CONSTRAINT_TYPE = "start_at_path";
93
93
  export interface StartAtValueQueryConstraintData {
94
- fieldValues: unknown[];
94
+ readonly fieldValues: unknown[];
95
95
  }
96
96
  export declare function startAtValue(...fieldValues: unknown[]): FirestoreQueryConstraint<StartAtValueQueryConstraintData>;
97
97
  export declare const FIRESTORE_START_AFTER_QUERY_CONSTRAINT_TYPE = "start_after";
98
98
  export interface StartAfterQueryConstraintData<T = DocumentData> {
99
- snapshot: DocumentSnapshot<T>;
99
+ readonly snapshot: DocumentSnapshot<T>;
100
100
  }
101
101
  export declare function startAfter<T = DocumentData>(snapshot: DocumentSnapshot<T>): FirestoreQueryConstraint<StartAfterQueryConstraintData<T>>;
102
102
  export declare const FIRESTORE_END_AT_QUERY_CONSTRAINT_TYPE = "end_at";
103
103
  export interface EndAtQueryConstraintData<T = DocumentData> {
104
- snapshot: DocumentSnapshot<T>;
104
+ readonly snapshot: DocumentSnapshot<T>;
105
105
  }
106
106
  export declare const FIRESTORE_END_AT_VALUE_QUERY_CONSTRAINT_TYPE = "end_at_path";
107
107
  export interface EndAtValueQueryConstraintData {
108
- fieldValues: unknown[];
108
+ readonly fieldValues: unknown[];
109
109
  }
110
110
  export declare function endAtValue(...fieldValues: unknown[]): FirestoreQueryConstraint<EndAtValueQueryConstraintData>;
111
111
  /**
@@ -116,7 +116,7 @@ export declare function endAtValue(...fieldValues: unknown[]): FirestoreQueryCon
116
116
  export declare function endAt<T = DocumentData>(snapshot: DocumentSnapshot<T>): FirestoreQueryConstraint<EndAtQueryConstraintData<T>>;
117
117
  export declare const FIRESTORE_END_BEFORE_QUERY_CONSTRAINT_TYPE = "end_before";
118
118
  export interface EndBeforeQueryConstraintData<T = DocumentData> {
119
- snapshot: DocumentSnapshot<T>;
119
+ readonly snapshot: DocumentSnapshot<T>;
120
120
  }
121
121
  /**
122
122
  *
@@ -129,7 +129,7 @@ export declare function endBefore<T = DocumentData>(snapshot: DocumentSnapshot<T
129
129
  */
130
130
  export type FirestoreQueryConstraintHandlerFunction<B, D = unknown> = (builder: B, data: D, constraint: FirestoreQueryConstraint<D>) => B;
131
131
  export type FirestoreQueryConstraintHandlerMap<B> = {
132
- [key: string]: Maybe<FirestoreQueryConstraintHandlerFunction<B, any>>;
132
+ readonly [key: string]: Maybe<FirestoreQueryConstraintHandlerFunction<B, any>>;
133
133
  };
134
134
  /**
135
135
  * The full list of known firestore query constraints, and the data associated with it.