@dereekb/firebase 13.2.2 → 13.3.1

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 (135) hide show
  1. package/index.cjs.js +12893 -4062
  2. package/index.esm.js +12872 -4065
  3. package/package.json +5 -5
  4. package/src/lib/client/error/error.d.ts +18 -3
  5. package/src/lib/client/firestore/array.d.ts +16 -3
  6. package/src/lib/client/firestore/driver.accessor.batch.d.ts +35 -4
  7. package/src/lib/client/firestore/driver.accessor.create.d.ts +15 -0
  8. package/src/lib/client/firestore/driver.accessor.d.ts +15 -0
  9. package/src/lib/client/firestore/driver.accessor.default.d.ts +32 -0
  10. package/src/lib/client/firestore/driver.accessor.transaction.d.ts +35 -4
  11. package/src/lib/client/firestore/driver.d.ts +16 -0
  12. package/src/lib/client/firestore/driver.query.d.ts +36 -0
  13. package/src/lib/client/firestore/firestore.d.ts +11 -1
  14. package/src/lib/client/firestore/increment.d.ts +12 -3
  15. package/src/lib/client/function/development.function.factory.d.ts +27 -2
  16. package/src/lib/client/function/error.d.ts +27 -0
  17. package/src/lib/client/function/function.callable.d.ts +50 -5
  18. package/src/lib/client/function/function.factory.d.ts +70 -4
  19. package/src/lib/client/function/model.function.factory.d.ts +64 -9
  20. package/src/lib/client/storage/driver.accessor.d.ts +93 -0
  21. package/src/lib/client/storage/driver.d.ts +15 -0
  22. package/src/lib/client/storage/storage.d.ts +10 -1
  23. package/src/lib/common/auth/auth.context.d.ts +17 -2
  24. package/src/lib/common/auth/auth.d.ts +38 -9
  25. package/src/lib/common/auth/auth.error.d.ts +25 -0
  26. package/src/lib/common/auth/auth.server.error.d.ts +6 -2
  27. package/src/lib/common/development/function.d.ts +17 -6
  28. package/src/lib/common/development/function.schedule.d.ts +30 -1
  29. package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +36 -12
  30. package/src/lib/common/firestore/accessor/array.d.ts +14 -4
  31. package/src/lib/common/firestore/accessor/document.d.ts +77 -2
  32. package/src/lib/common/firestore/accessor/increment.d.ts +15 -3
  33. package/src/lib/common/firestore/collection/collection.d.ts +22 -4
  34. package/src/lib/common/firestore/collection/collection.util.d.ts +12 -2
  35. package/src/lib/common/firestore/driver/accessor.d.ts +28 -1
  36. package/src/lib/common/firestore/driver/batch.d.ts +6 -4
  37. package/src/lib/common/firestore/driver/driver.d.ts +18 -1
  38. package/src/lib/common/firestore/driver/query.d.ts +20 -1
  39. package/src/lib/common/firestore/driver/query.handler.d.ts +23 -0
  40. package/src/lib/common/firestore/driver/transaction.d.ts +18 -6
  41. package/src/lib/common/firestore/error.d.ts +16 -4
  42. package/src/lib/common/firestore/query/iterator.d.ts +11 -0
  43. package/src/lib/common/firestore/reference.d.ts +11 -6
  44. package/src/lib/common/firestore/snapshot/snapshot.d.ts +4 -0
  45. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +263 -63
  46. package/src/lib/common/firestore/types.d.ts +39 -1
  47. package/src/lib/common/firestore/util/id.batch.d.ts +55 -3
  48. package/src/lib/common/function/action.d.ts +35 -0
  49. package/src/lib/common/model/context.d.ts +11 -1
  50. package/src/lib/common/model/function.d.ts +45 -9
  51. package/src/lib/common/model/model/model.loader.d.ts +37 -0
  52. package/src/lib/common/model/model/model.param.d.ts +24 -2
  53. package/src/lib/common/model/model.service.d.ts +126 -4
  54. package/src/lib/common/model/permission/permission.context.d.ts +15 -0
  55. package/src/lib/common/model/permission/permission.d.ts +16 -0
  56. package/src/lib/common/model/permission/permission.service.d.ts +24 -1
  57. package/src/lib/common/model/permission/permission.service.grant.d.ts +72 -28
  58. package/src/lib/common/model/permission/permission.service.role.d.ts +15 -0
  59. package/src/lib/common/storage/accessor/path.model.d.ts +25 -8
  60. package/src/lib/common/storage/context.d.ts +23 -6
  61. package/src/lib/common/storage/driver/accessor.d.ts +15 -4
  62. package/src/lib/common/storage/driver/accessor.iterate.d.ts +31 -8
  63. package/src/lib/common/storage/driver/accessor.util.d.ts +13 -6
  64. package/src/lib/common/storage/driver/driver.d.ts +10 -1
  65. package/src/lib/common/storage/driver/error.d.ts +16 -0
  66. package/src/lib/common/storage/driver/list.d.ts +30 -0
  67. package/src/lib/common/storage/storage.d.ts +76 -19
  68. package/src/lib/common/storage/types.d.ts +23 -5
  69. package/src/lib/model/index.d.ts +1 -0
  70. package/src/lib/model/notification/notification.action.d.ts +8 -0
  71. package/src/lib/model/notification/notification.api.d.ts +26 -0
  72. package/src/lib/model/notification/notification.api.error.d.ts +15 -0
  73. package/src/lib/model/notification/notification.api.util.d.ts +27 -12
  74. package/src/lib/model/notification/notification.config.d.ts +193 -64
  75. package/src/lib/model/notification/notification.create.d.ts +62 -13
  76. package/src/lib/model/notification/notification.create.task.d.ts +25 -4
  77. package/src/lib/model/notification/notification.d.ts +258 -99
  78. package/src/lib/model/notification/notification.details.d.ts +66 -18
  79. package/src/lib/model/notification/notification.id.d.ts +90 -12
  80. package/src/lib/model/notification/notification.item.d.ts +57 -16
  81. package/src/lib/model/notification/notification.message.d.ts +84 -18
  82. package/src/lib/model/notification/notification.query.d.ts +21 -24
  83. package/src/lib/model/notification/notification.send.d.ts +38 -5
  84. package/src/lib/model/notification/notification.task.d.ts +87 -16
  85. package/src/lib/model/notification/notification.task.subtask.d.ts +42 -13
  86. package/src/lib/model/notification/notification.util.d.ts +68 -18
  87. package/src/lib/model/oidcmodel/index.d.ts +8 -0
  88. package/src/lib/model/oidcmodel/oidcmodel.action.d.ts +37 -0
  89. package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +131 -0
  90. package/src/lib/model/oidcmodel/oidcmodel.d.ts +114 -0
  91. package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +17 -0
  92. package/src/lib/model/oidcmodel/oidcmodel.id.d.ts +18 -0
  93. package/src/lib/model/oidcmodel/oidcmodel.interaction.d.ts +40 -0
  94. package/src/lib/model/oidcmodel/oidcmodel.interaction.oauth.d.ts +73 -0
  95. package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +21 -0
  96. package/src/lib/model/storagefile/storagefile.action.d.ts +47 -0
  97. package/src/lib/model/storagefile/storagefile.api.d.ts +54 -4
  98. package/src/lib/model/storagefile/storagefile.create.d.ts +40 -3
  99. package/src/lib/model/storagefile/storagefile.d.ts +153 -16
  100. package/src/lib/model/storagefile/storagefile.file.d.ts +22 -7
  101. package/src/lib/model/storagefile/storagefile.group.d.ts +30 -1
  102. package/src/lib/model/storagefile/storagefile.group.processing.d.ts +20 -2
  103. package/src/lib/model/storagefile/storagefile.id.d.ts +44 -5
  104. package/src/lib/model/storagefile/storagefile.permission.d.ts +23 -4
  105. package/src/lib/model/storagefile/storagefile.query.d.ts +63 -11
  106. package/src/lib/model/storagefile/storagefile.task.d.ts +47 -4
  107. package/src/lib/model/storagefile/storagefile.upload.claims.d.ts +21 -4
  108. package/src/lib/model/storagefile/storagefile.upload.d.ts +41 -9
  109. package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +112 -20
  110. package/src/lib/model/storagefile/storagefile.util.d.ts +66 -3
  111. package/src/lib/model/system/system.action.d.ts +25 -0
  112. package/src/lib/model/system/system.d.ts +80 -4
  113. package/src/lib/model/user.d.ts +8 -2
  114. package/test/index.cjs.js +11168 -3295
  115. package/test/index.esm.js +11176 -3303
  116. package/test/package.json +6 -6
  117. package/test/src/lib/client/firebase.authorized.d.ts +18 -0
  118. package/test/src/lib/client/firebase.d.ts +60 -0
  119. package/test/src/lib/common/firebase.instance.d.ts +21 -0
  120. package/test/src/lib/common/firestore/firestore.d.ts +40 -0
  121. package/test/src/lib/common/firestore/firestore.instance.d.ts +16 -0
  122. package/test/src/lib/common/firestore/test.driver.accessor.d.ts +39 -2
  123. package/test/src/lib/common/firestore/test.driver.utility.d.ts +8 -2
  124. package/test/src/lib/common/firestore/test.iterator.d.ts +7 -2
  125. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +29 -1
  126. package/test/src/lib/common/mock/mock.item.d.ts +219 -5
  127. package/test/src/lib/common/mock/mock.item.id.d.ts +6 -0
  128. package/test/src/lib/common/mock/mock.item.query.d.ts +12 -0
  129. package/test/src/lib/common/mock/mock.item.service.d.ts +60 -0
  130. package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +28 -1
  131. package/test/src/lib/common/storage/storage.d.ts +30 -0
  132. package/test/src/lib/common/storage/storage.instance.d.ts +22 -0
  133. package/test/src/lib/common/storage/test.driver.accessor.d.ts +7 -2
  134. package/index.cjs.js.map +0 -1
  135. package/index.esm.js.map +0 -1
@@ -1,40 +1,106 @@
1
1
  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
+ /**
5
+ * Per-function configuration for creating `HttpsCallable` instances, allowing
6
+ * custom `HttpsCallableOptions` (e.g., timeout) per function key.
7
+ */
4
8
  export interface FirebaseFunctionTypeConfig {
5
9
  readonly options?: HttpsCallableOptions;
6
10
  }
11
+ /**
12
+ * Maps each function key in a {@link FirebaseFunctionTypeMap} to its optional configuration.
13
+ */
7
14
  export type FirebaseFunctionTypeConfigMap<M extends FirebaseFunctionTypeMap> = {
8
15
  readonly [K in keyof M]: Maybe<FirebaseFunctionTypeConfig>;
9
16
  };
10
17
  /**
11
- * Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
18
+ * Factory that creates a {@link FirebaseFunctionMap} for a given `Functions` instance.
19
+ *
20
+ * Call this with a live `Functions` instance to get a map of typed callable functions
21
+ * ready to invoke.
12
22
  */
13
23
  export type FirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap> = (functionsInstance: Functions) => FirebaseFunctionMap<M>;
24
+ /**
25
+ * Creates a {@link FirebaseFunctionMapFactory} from a configuration map.
26
+ *
27
+ * Each key in the config map becomes an `HttpsCallable` function wrapped with {@link directDataHttpsCallable}
28
+ * for direct data access. Per-key options (e.g., timeout) are applied if provided.
29
+ *
30
+ * @param configMap - maps function keys to their optional configuration
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * const factory = firebaseFunctionMapFactory<MyFunctionTypeMap>({
35
+ * createUser: { options: { timeout: 30000 } },
36
+ * deleteUser: null
37
+ * });
38
+ * const functions = factory(getFunctions());
39
+ * const result = await functions.createUser({ name: 'Alice' });
40
+ * ```
41
+ */
14
42
  export declare function firebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>): FirebaseFunctionMapFactory<M>;
43
+ /**
44
+ * String key used to identify a function group in the app-level functions map.
45
+ */
15
46
  export type FirebaseFunctionMapKey = string;
47
+ /**
48
+ * Lazy getter that also carries metadata about the function group's type and key.
49
+ *
50
+ * The `_type` property holds the class constructor for type identification (used by injection),
51
+ * and `_key` holds the string key in the app-level {@link FirebaseFunctionsMap}.
52
+ */
16
53
  export type FirebaseFunctionGetter<T> = Getter<T> & {
17
54
  _type: ClassLikeType<T>;
18
55
  _key: FirebaseFunctionMapKey;
19
56
  };
20
57
  /**
21
- * Map of all firebase functions in the app.
58
+ * Top-level map of all function groups in the app. Each key represents a logical function group
59
+ * (e.g., `'notificationFunctions'`, `'developmentFunctions'`) mapped to its {@link FirebaseFunctionTypeMap}.
22
60
  */
23
61
  export type FirebaseFunctionsMap = {
24
62
  readonly [key: FirebaseFunctionMapKey]: FirebaseFunctionTypeMap;
25
63
  };
64
+ /**
65
+ * Configuration map for building a {@link LazyFirebaseFunctions} instance.
66
+ * Each entry pairs a class type (for DI identification) with a factory function.
67
+ */
26
68
  export type FirebaseFunctionsConfigMap<M extends FirebaseFunctionsMap> = {
27
69
  readonly [K in keyof M]: FirebaseFunctionsConfigMapEntry<M[K]>;
28
70
  };
71
+ /**
72
+ * Tuple of `[ClassType, FactoryFunction]` for a single function group entry.
73
+ */
29
74
  export type FirebaseFunctionsConfigMapEntry<M extends FirebaseFunctionTypeMap> = [ClassLikeType, FirebaseFunctionMapFactory<M>];
30
75
  /**
31
- * Factory function for creating a FirebaseFunctionsMap for a given Functions instance.
76
+ * Factory that creates a {@link LazyFirebaseFunctions} map for a given `Functions` instance.
32
77
  */
33
78
  export type LazyFirebaseFunctionsFactory<M extends FirebaseFunctionsMap> = (functions: Functions) => LazyFirebaseFunctions<M>;
34
79
  /**
35
- * Map of FirebaseFunctionGetter values that are lazy-loaded via the getter.
80
+ * Map of lazy-loaded function groups. Each group is a {@link FirebaseFunctionGetter} that
81
+ * defers initialization until first access via `cachedGetter`, avoiding unnecessary
82
+ * `httpsCallable` instantiation for unused function groups.
36
83
  */
37
84
  export type LazyFirebaseFunctions<M extends FirebaseFunctionsMap> = {
38
85
  readonly [K in keyof M]: FirebaseFunctionGetter<FirebaseFunctionMap<M[K]>>;
39
86
  };
87
+ /**
88
+ * Creates a {@link LazyFirebaseFunctionsFactory} from a config map of function groups.
89
+ *
90
+ * Each function group is lazily initialized on first access using `cachedGetter`,
91
+ * so `httpsCallable` instances are only created when actually needed.
92
+ *
93
+ * @param configMap - maps each function group key to its `[ClassType, Factory]` tuple
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const factory = lazyFirebaseFunctionsFactory<AppFunctionsMap>({
98
+ * notificationFunctions: [NotificationFunctions, notificationFunctionMapFactory],
99
+ * developmentFunctions: [DevelopmentFunctions, devFunctionMapFactory]
100
+ * });
101
+ *
102
+ * const lazyFns = factory(getFunctions());
103
+ * const notifFns = lazyFns.notificationFunctions(); // initialized on first call
104
+ * ```
105
+ */
40
106
  export declare function lazyFirebaseFunctionsFactory<M extends FirebaseFunctionsMap, C extends FirebaseFunctionsConfigMap<M> = FirebaseFunctionsConfigMap<M>>(configMap: C): LazyFirebaseFunctionsFactory<M>;
@@ -6,23 +6,47 @@ import { type FirebaseFunctionTypeMap, type FirebaseFunctionMap, type FirebaseFu
6
6
  import { type FirebaseFunctionTypeConfigMap } from './function.factory';
7
7
  import { type OnCallCreateModelResult } from '../../common/model/function';
8
8
  /**
9
- * Used to specify which function to direct requests to.
9
+ * String identifier that routes a CRUD request to a specific sub-handler within a model's
10
+ * CRUD function. For example, a model's `update` might have specifiers like `'status'` or `'config'`
11
+ * to target different update behaviors.
10
12
  */
11
13
  export type ModelFirebaseCrudFunctionSpecifier = string;
12
14
  /**
13
- * Provides a reference to a ModelFirebaseCrudFunctionSpecifier if available.
15
+ * Optional reference to a {@link ModelFirebaseCrudFunctionSpecifier}, used to route CRUD requests
16
+ * to a specific sub-handler.
14
17
  */
15
18
  export type ModelFirebaseCrudFunctionSpecifierRef = {
16
19
  readonly specifier?: ModelFirebaseCrudFunctionSpecifier;
17
20
  };
21
+ /**
22
+ * Generic CRUD function for a Firestore model. Wraps {@link FirebaseFunction} with model-specific input/output types.
23
+ */
18
24
  export type ModelFirebaseCrudFunction<I, O = void> = FirebaseFunction<I, O>;
25
+ /**
26
+ * Create function for a model. Returns {@link OnCallCreateModelResult} containing the created document's key by default.
27
+ */
19
28
  export type ModelFirebaseCreateFunction<I, O extends OnCallCreateModelResult = OnCallCreateModelResult> = ModelFirebaseCrudFunction<I, O>;
29
+ /** Read function for a model, returning the read data. */
20
30
  export type ModelFirebaseReadFunction<I, O> = ModelFirebaseCrudFunction<I, O>;
31
+ /** Update function for a model. Returns void by default. */
21
32
  export type ModelFirebaseUpdateFunction<I, O = void> = ModelFirebaseCrudFunction<I, O>;
33
+ /** Delete function for a model. Returns void by default. */
22
34
  export type ModelFirebaseDeleteFunction<I, O = void> = ModelFirebaseCrudFunction<I, O>;
35
+ /**
36
+ * Maps each model type (from a {@link FirestoreModelIdentity}) to its CRUD function type configuration.
37
+ *
38
+ * Each entry defines which CRUD operations (create, read, update, delete) are available for
39
+ * that model type, along with optional specifiers for sub-operations.
40
+ */
23
41
  export type ModelFirebaseCrudFunctionTypeMap<T extends FirestoreModelIdentity = FirestoreModelIdentity> = {
24
42
  [K in FirestoreModelTypes<T>]: ModelFirebaseCrudFunctionTypeMapEntry;
25
43
  };
44
+ /**
45
+ * Entry for a single model type in a {@link ModelFirebaseCrudFunctionTypeMap}.
46
+ *
47
+ * Can be `null`/`undefined` (no CRUD functions for this model) or a partial record of
48
+ * create/read/update/delete configurations, each optionally with specifiers.
49
+ */
26
50
  export type ModelFirebaseCrudFunctionTypeMapEntry = MaybeNot | Partial<ModelFirebaseCrudFunctionCreateTypeConfig & ModelFirebaseCrudFunctionReadTypeConfig & ModelFirebaseCrudFunctionUpdateTypeConfig & ModelFirebaseCrudFunctionDeleteTypeConfig>;
27
51
  export type ModelFirebaseCrudFunctionTypeMapEntryWithReturnType<I = unknown, O = unknown> = [I, O];
28
52
  export type ModelFirebaseCrudFunctionTypeSpecifierConfig = Record<string | number, unknown | ModelFirebaseCrudFunctionTypeMapEntryWithReturnType>;
@@ -38,14 +62,23 @@ export type ModelFirebaseCrudFunctionUpdateTypeConfig = {
38
62
  export type ModelFirebaseCrudFunctionDeleteTypeConfig = {
39
63
  readonly delete: unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig;
40
64
  };
65
+ /**
66
+ * Default specifier string (`'_'`) used when a CRUD operation has specifiers but one
67
+ * should map to the base function name without a specifier suffix.
68
+ */
41
69
  export declare const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT = "_";
42
70
  export type ModelFirebaseCrudFunctionSpecifierDefault = typeof MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_DEFAULT;
71
+ /**
72
+ * Separator character (`','`) used to split multiple specifier keys in a config string.
73
+ * For example, `'update:status,config'` defines two update specifiers: `status` and `config`.
74
+ */
43
75
  export declare const MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER = ",";
44
76
  export type ModelFirebaseCrudFunctionSpecifierSplitter = typeof MODEL_FUNCTION_FIREBASE_CRUD_FUNCTION_SPECIFIER_SPLITTER;
45
77
  /**
46
- * The configuration for a types map.
78
+ * Configuration map that defines which CRUD operations and specifiers to generate for each model type.
47
79
  *
48
- * The FirestoreModelIdentities that are allowed are passed too which add type checking to make sure we're passing the expected identities.
80
+ * The {@link FirestoreModelIdentity} type parameter `T` constrains which model type keys are
81
+ * valid, providing compile-time safety. Entries are string arrays like `['create', 'update:status,config']`.
49
82
  */
50
83
  export type ModelFirebaseCrudFunctionConfigMap<C extends ModelFirebaseCrudFunctionTypeMap<T>, T extends FirestoreModelIdentity> = NonNever<{
51
84
  [K in FirestoreModelTypes<T>]: C[K] extends null ? never : ModelFirebaseCrudFunctionConfigMapEntry<C[K]>;
@@ -72,16 +105,38 @@ export type ModelFirebaseCrudFunctionMapEntrySpecifierShort<MODEL extends string
72
105
  [SPECIFIER in keyof M as SPECIFIER extends string ? (CRUD extends string ? (SPECIFIER extends ModelFirebaseCrudFunctionSpecifierDefault ? CRUD : SPECIFIER) : never) : never]: ModelFirebaseCrudFunctionMapEntryFunction<M, SPECIFIER, CRUD>;
73
106
  };
74
107
  export declare type ModelFirebaseCrudFunctionMapEntryFunction<E extends unknown | ModelFirebaseCrudFunctionTypeSpecifierConfig, K extends keyof E, CRUD extends string> = E[K] extends ModelFirebaseCrudFunctionTypeMapEntryWithReturnType<infer I, infer O> ? ModelFirebaseCrudFunction<I, O> : CRUD extends 'create' ? ModelFirebaseCreateFunction<E[K]> : ModelFirebaseCrudFunction<E[K]>;
108
+ /**
109
+ * Combined function map providing both custom functions ({@link FirebaseFunctionMap}) and
110
+ * auto-generated model CRUD functions ({@link ModelFirebaseCrudFunctionMap}).
111
+ */
75
112
  export type ModelFirebaseFunctionMap<M extends FirebaseFunctionTypeMap, C extends ModelFirebaseCrudFunctionTypeMap> = FirebaseFunctionMap<M> & ModelFirebaseCrudFunctionMap<C>;
76
113
  /**
77
- * Used for building a FirebaseFunctionMap<M> for a specific Functions instance.
114
+ * Factory that creates a {@link ModelFirebaseFunctionMap} for a given `Functions` instance.
78
115
  */
79
116
  export type ModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap> = (functionsInstance: Functions) => ModelFirebaseFunctionMap<M, U>;
80
117
  /**
81
- * Creates a ModelFirebaseFunctionMapFactory for the input config that targets the "callModel" Firebase function.
118
+ * Creates a {@link ModelFirebaseFunctionMapFactory} that routes model CRUD operations through the
119
+ * single `callModel` Cloud Function endpoint.
120
+ *
121
+ * Rather than creating separate `HttpsCallable` instances for each CRUD operation, all model
122
+ * operations are multiplexed through a single Firebase function (identified by {@link CALL_MODEL_APP_FUNCTION_KEY}).
123
+ * The model type, CRUD operation, and optional specifier are encoded into the request parameters
124
+ * via {@link onCallTypedModelParamsFunction}.
125
+ *
126
+ * Custom (non-CRUD) functions from `configMap` get their own individual `HttpsCallable` instances.
127
+ *
128
+ * @param configMap - configuration for custom (non-CRUD) functions
129
+ * @param crudConfigMap - configuration for model CRUD functions with optional specifiers
82
130
  *
83
- * @param configMap
84
- * @param crudConfigMap
85
- * @returns
131
+ * @example
132
+ * ```ts
133
+ * const factory = callModelFirebaseFunctionMapFactory<CustomFnMap, CrudMap>(
134
+ * { customFn: null },
135
+ * { notification: ['create', 'update:status,config', 'delete'] }
136
+ * );
137
+ * const fns = factory(getFunctions());
138
+ * await fns.createNotification(data);
139
+ * await fns.updateNotificationStatus(data);
140
+ * ```
86
141
  */
87
142
  export declare function callModelFirebaseFunctionMapFactory<M extends FirebaseFunctionTypeMap, U extends ModelFirebaseCrudFunctionTypeMap>(configMap: FirebaseFunctionTypeConfigMap<M>, crudConfigMap: ModelFirebaseCrudFunctionConfigMap<U, FirestoreModelIdentity>): ModelFirebaseFunctionMapFactory<M, U>;
@@ -2,16 +2,109 @@ import { type FirebaseStorageAccessorDriver, type FirebaseStorageAccessorFile, t
2
2
  import { type StoragePath } from '../../common/storage/storage';
3
3
  import { type ListResult, type StorageReference, type FirebaseStorage as ClientFirebaseStorage } from 'firebase/storage';
4
4
  import { type ErrorInput, type Maybe } from '@dereekb/util';
5
+ /**
6
+ * Checks whether an error is a Firebase Storage "object not found" error.
7
+ *
8
+ * Useful for distinguishing missing-file errors from other storage failures,
9
+ * e.g., to silently handle deletion of already-deleted files.
10
+ *
11
+ * @param input - the error or error message to check
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * try {
16
+ * await deleteObject(ref);
17
+ * } catch (e) {
18
+ * if (isFirebaseStorageObjectNotFoundError(e)) {
19
+ * // file already deleted, safe to ignore
20
+ * }
21
+ * }
22
+ * ```
23
+ */
5
24
  export declare function isFirebaseStorageObjectNotFoundError(input: Maybe<ErrorInput | string>): boolean;
25
+ /**
26
+ * Creates a `StorageReference` from an abstract {@link StoragePath} using the client `firebase/storage` SDK.
27
+ *
28
+ * @param storage - the client Firebase Storage instance
29
+ * @param path - abstract storage path to resolve
30
+ */
6
31
  export declare function firebaseStorageRefForStorageFilePath(storage: ClientFirebaseStorage, path: StoragePath): StorageReference;
32
+ /**
33
+ * Checks whether a file exists at the given `StorageReference` by attempting to read its metadata.
34
+ *
35
+ * Returns `true` if metadata is successfully retrieved, `false` for any error (including permission errors).
36
+ *
37
+ * @param ref - the storage reference to check
38
+ */
7
39
  export declare function firebaseStorageFileExists(ref: StorageReference): Promise<boolean>;
40
+ /**
41
+ * Client-side specialization of {@link FirebaseStorageAccessorFile} using `StorageReference` as the native reference type.
42
+ */
8
43
  export type FirebaseStorageClientAccessorFile = FirebaseStorageAccessorFile<StorageReference>;
44
+ /**
45
+ * Creates a client-side {@link FirebaseStorageAccessorFile} for a specific storage path.
46
+ *
47
+ * Provides all file operations (upload, download, metadata, delete, resumable upload) backed by
48
+ * the `firebase/storage` SDK. Resumable uploads expose an Observable stream of upload progress snapshots.
49
+ *
50
+ * @param storage - the client Firebase Storage instance
51
+ * @param storagePath - the abstract storage path for the file
52
+ *
53
+ * @example
54
+ * ```ts
55
+ * const file = firebaseStorageClientAccessorFile(storage, { bucketId: 'my-bucket', pathString: 'uploads/photo.jpg' });
56
+ * const url = await file.getDownloadUrl();
57
+ * ```
58
+ */
9
59
  export declare function firebaseStorageClientAccessorFile(storage: ClientFirebaseStorage, storagePath: StoragePath): FirebaseStorageClientAccessorFile;
60
+ /**
61
+ * Client-side specialization of {@link FirebaseStorageAccessorFolder} using `StorageReference` as the native reference type.
62
+ */
10
63
  export type FirebaseStorageClientAccessorFolder = FirebaseStorageAccessorFolder<StorageReference>;
64
+ /**
65
+ * Internal result wrapper for client-side storage list operations, holding the raw `ListResult`
66
+ * and the options used to produce it. Used by {@link firebaseStorageClientListFilesResultFactory}
67
+ * to support pagination and nested listing.
68
+ */
11
69
  export interface FirebaseStorageClientListResult {
12
70
  listResult: ListResult;
13
71
  options?: StorageListFilesOptions;
14
72
  }
73
+ /**
74
+ * Pre-configured {@link storageListFilesResultFactory} for the client `firebase/storage` SDK.
75
+ *
76
+ * Handles pagination tokens, nested folder traversal, and mapping between Firebase `ListResult`
77
+ * items and the abstract {@link StorageListItemResult} interface.
78
+ */
15
79
  export declare const firebaseStorageClientListFilesResultFactory: import("../..").StorageListFilesResultFactory<ClientFirebaseStorage, FirebaseStorageClientListResult>;
80
+ /**
81
+ * Creates a client-side {@link FirebaseStorageAccessorFolder} for a specific storage path.
82
+ *
83
+ * Supports existence checks, paginated file/folder listing, and recursive nested listing
84
+ * when `includeNestedResults` is enabled.
85
+ *
86
+ * @param storage - the client Firebase Storage instance
87
+ * @param storagePath - the abstract storage path for the folder
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const folder = firebaseStorageClientAccessorFolder(storage, { bucketId: 'my-bucket', pathString: 'uploads/' });
92
+ * const result = await folder.list({ maxResults: 10 });
93
+ * const files = result.files();
94
+ * ```
95
+ */
16
96
  export declare function firebaseStorageClientAccessorFolder(storage: ClientFirebaseStorage, storagePath: StoragePath): FirebaseStorageClientAccessorFolder;
97
+ /**
98
+ * Creates the client-side {@link FirebaseStorageAccessorDriver} that maps the abstract storage
99
+ * accessor interface to the `firebase/storage` SDK.
100
+ *
101
+ * Provides file and folder accessor factories and default bucket resolution.
102
+ * Used internally by {@link firebaseStorageClientDrivers}.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const driver = firebaseStorageClientAccessorDriver();
107
+ * const file = driver.file(storage, storagePath);
108
+ * ```
109
+ */
17
110
  export declare function firebaseStorageClientAccessorDriver(): FirebaseStorageAccessorDriver;
@@ -1,3 +1,18 @@
1
1
  import { type FirebaseStorageDrivers } from '../../common/storage/driver/driver';
2
+ /**
3
+ * Client-side {@link FirebaseStorageDrivers} using the `firebase/storage` SDK.
4
+ */
2
5
  export type FirebaseStorageClientDrivers = FirebaseStorageDrivers;
6
+ /**
7
+ * Creates the client-side {@link FirebaseStorageDrivers} that bind the abstract storage driver
8
+ * interfaces to the `firebase/storage` SDK (browser/client).
9
+ *
10
+ * Provides file and folder accessor operations for use with {@link clientFirebaseStorageContextFactory}.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const drivers = firebaseStorageClientDrivers();
15
+ * const contextFactory = firebaseStorageContextFactory(drivers);
16
+ * ```
17
+ */
3
18
  export declare function firebaseStorageClientDrivers(): FirebaseStorageClientDrivers;
@@ -1,5 +1,14 @@
1
1
  import { type FirebaseStorageContextFactory } from '../../common/storage/context';
2
2
  /**
3
- * Creates a FirebaseStorageContextFactory that uses the client @firebase/storage package.
3
+ * Pre-configured {@link FirebaseStorageContextFactory} for client-side (browser) Firebase Storage usage.
4
+ *
5
+ * Wires the client Storage drivers (from the `firebase/storage` SDK) into the abstract
6
+ * {@link FirebaseStorageContextFactory} so that file and folder operations use the client-side implementation.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const context = clientFirebaseStorageContextFactory(storage);
11
+ * const file = context.file({ bucketId: 'my-bucket', pathString: 'uploads/image.png' });
12
+ * ```
4
13
  */
5
14
  export declare const clientFirebaseStorageContextFactory: FirebaseStorageContextFactory;
@@ -1,13 +1,19 @@
1
1
  import { type AuthClaims, type AuthClaimsObject, type AuthRoleSet, type MappedUseFunction, type Maybe, type UseValue } from '@dereekb/util';
2
2
  import { type FirebaseAuthToken, type FirebaseAuthUserId } from './auth';
3
3
  /**
4
- * Provides a context containing FirebaseAuthContextInfo
4
+ * Context that optionally carries the current user's authentication state.
5
+ *
6
+ * Used throughout the Firebase model and permission system to determine what
7
+ * the current caller is authorized to do. A missing `auth` implies an unauthenticated request.
5
8
  */
6
9
  export interface FirebaseAuthContext {
7
10
  readonly auth?: Maybe<FirebaseAuthContextInfo>;
8
11
  }
9
12
  /**
10
- * Auth contextual information
13
+ * Resolved authentication information for the current request/context.
14
+ *
15
+ * Provides the user's UID, admin status, custom claims, and auth roles.
16
+ * Typically derived from a decoded Firebase ID token or the Firebase Admin SDK.
11
17
  */
12
18
  export interface FirebaseAuthContextInfo {
13
19
  /**
@@ -31,6 +37,15 @@ export interface FirebaseAuthContextInfo {
31
37
  */
32
38
  readonly token: FirebaseAuthToken;
33
39
  }
40
+ /**
41
+ * {@link UseValue} wrapper for {@link FirebaseAuthContextInfo}.
42
+ */
34
43
  export type UseFirebaseAuthContextInfo<I extends FirebaseAuthContextInfo = FirebaseAuthContextInfo> = UseValue<I>;
44
+ /**
45
+ * Extracts the {@link FirebaseAuthContextInfo} from a {@link FirebaseAuthContext}.
46
+ */
35
47
  export declare const useContextAuth: MappedUseFunction<FirebaseAuthContext, FirebaseAuthContextInfo>;
48
+ /**
49
+ * Extracts the user UID directly from a {@link FirebaseAuthContext}.
50
+ */
36
51
  export declare const useContextAuthUid: MappedUseFunction<FirebaseAuthContext, FirebaseAuthUserId>;
@@ -1,23 +1,36 @@
1
1
  import { type ISO8601DateString, type Maybe, type PasswordString, type PhoneNumber, type WebsiteUrl } from '@dereekb/util';
2
2
  /**
3
- * Don't use passwords smaller tahn 6.
3
+ * Minimum password length enforced by Firebase Authentication.
4
+ *
5
+ * Firebase requires at least 6 characters for password-based auth.
4
6
  */
5
7
  export declare const FIREBASE_AUTH_PASSWORD_MIN_LENGTH = 6;
6
8
  /**
7
- * Passwords longer than 128 characters are not useful...
9
+ * Practical maximum password length for Firebase Authentication.
8
10
  *
9
- * (but they are allowed by Firebase. There is no posted upper limit)
11
+ * Firebase has no posted upper limit, but passwords beyond 128 characters provide diminishing security value.
10
12
  */
11
13
  export declare const FIREBASE_AUTH_PASSWORD_MAX_LENGTH = 128;
12
14
  /**
13
- * Firebase User Identifier (UID)
15
+ * Unique identifier for a Firebase Authentication user (the `uid` from Firebase Auth).
14
16
  */
15
17
  export type FirebaseAuthUserId = string;
18
+ /**
19
+ * Contains a reference to a Firebase Auth user's UID.
20
+ */
16
21
  export interface FirebaseAuthUserIdRef {
17
22
  uid: FirebaseAuthUserId;
18
23
  }
19
24
  /**
20
- * Firebase Auth Token interface
25
+ * Raw encoded JWT for Firebase Auth.
26
+ *
27
+ * Corresponds with IdToken type in Firebase Auth.
28
+ */
29
+ export type FirebaseAuthIdToken = string;
30
+ /**
31
+ * Decoded Firebase Auth token information, containing user identity details from the authentication provider.
32
+ *
33
+ * These fields come from the Firebase Auth token and represent the user's current identity state.
21
34
  */
22
35
  export interface FirebaseAuthToken {
23
36
  readonly email?: Maybe<string>;
@@ -38,6 +51,11 @@ export interface FirebaseAuthToken {
38
51
  */
39
52
  readonly lastRefreshTime?: Maybe<ISO8601DateString>;
40
53
  }
54
+ /**
55
+ * Extended auth details combining token information with user profile fields.
56
+ *
57
+ * Represents the full set of user identity data available from Firebase Authentication.
58
+ */
41
59
  export interface FirebaseAuthDetails extends FirebaseAuthToken, Readonly<FirebaseAuthUserIdRef> {
42
60
  readonly disabled?: Maybe<boolean>;
43
61
  readonly displayName?: Maybe<string>;
@@ -55,25 +73,36 @@ export type FirebaseAuthOwnershipKey = string;
55
73
  export type FirebaseAuthSetupPassword = PasswordString;
56
74
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_PASSWORD_KEY = "setupPassword";
57
75
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_SETUP_LAST_COM_DATE_KEY = "setupCommunicationAt";
76
+ /**
77
+ * Custom claims data set on a newly-created Firebase Auth user to enable out-of-band account setup.
78
+ *
79
+ * The setup password is included in the invitation link so the user can verify ownership
80
+ * without requiring an immediate sign-in flow.
81
+ */
58
82
  export interface FirebaseAuthNewUserClaimsData {
59
83
  /**
60
- * Setup password
84
+ * One-time setup password embedded in the user's claims for account initialization.
61
85
  */
62
86
  readonly setupPassword: FirebaseAuthSetupPassword;
63
87
  /**
64
- * Last setup communication time.
88
+ * ISO 8601 timestamp of the last setup-related communication (e.g., invitation email).
65
89
  */
66
90
  readonly setupCommunicationAt: ISO8601DateString;
67
91
  }
68
92
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_RESET_PASSWORD_KEY = "resetPassword";
69
93
  export declare const FIREBASE_SERVER_AUTH_CLAIMS_RESET_LAST_COM_DATE_KEY = "resetCommunicationAt";
94
+ /**
95
+ * Custom claims data set on a Firebase Auth user during a password reset flow.
96
+ *
97
+ * Similar to {@link FirebaseAuthNewUserClaimsData} but for reset scenarios.
98
+ */
70
99
  export interface FirebaseAuthResetUserPasswordClaimsData {
71
100
  /**
72
- * Reset password
101
+ * One-time reset password embedded in the user's claims for password reset verification.
73
102
  */
74
103
  readonly resetPassword: FirebaseAuthSetupPassword;
75
104
  /**
76
- * Last reset communication time.
105
+ * ISO 8601 timestamp of the last reset-related communication (e.g., reset email).
77
106
  */
78
107
  readonly resetCommunicationAt: ISO8601DateString;
79
108
  }
@@ -1,12 +1,37 @@
1
1
  import { type ReadableError } from '@dereekb/util';
2
2
  import { type FirebaseErrorCode } from '../error';
3
+ /**
4
+ * Shape of a Firebase Authentication error, matching the error structure from the Firebase Auth SDK.
5
+ */
3
6
  export interface FirebaseAuthError {
4
7
  readonly code: FirebaseErrorCode;
5
8
  readonly name: string;
6
9
  readonly customData: unknown;
7
10
  }
11
+ /** Error code when the user account is not found. */
8
12
  export declare const FIREBASE_AUTH_USER_NOT_FOUND_ERROR = "auth/user-not-found";
13
+ /** Error code when the password is incorrect. */
9
14
  export declare const FIREBASE_AUTH_WRONG_PASSWORD = "auth/wrong-password";
15
+ /** Error code for a network request error (client SDK). */
10
16
  export declare const FIREBASE_AUTH_NETWORK_REQUEST_ERROR = "auth/network-request-error";
17
+ /** Error code for a failed network request (client SDK). */
11
18
  export declare const FIREBASE_AUTH_NETWORK_REQUEST_FAILED = "auth/network-request-failed";
19
+ /**
20
+ * Converts a {@link FirebaseAuthError} into a user-friendly {@link ReadableError} with a human-readable message.
21
+ *
22
+ * Maps known error codes (wrong password, user not found, network errors) to contextual messages
23
+ * suitable for display in the UI.
24
+ *
25
+ * @param inputError - the Firebase Auth error to convert
26
+ *
27
+ * @example
28
+ * ```ts
29
+ * try {
30
+ * await signIn(email, password);
31
+ * } catch (e) {
32
+ * const readable = firebaseAuthErrorToReadableError(e as FirebaseAuthError);
33
+ * showToast(readable.message);
34
+ * }
35
+ * ```
36
+ */
12
37
  export declare function firebaseAuthErrorToReadableError(inputError: FirebaseAuthError): ReadableError;
@@ -1,8 +1,12 @@
1
1
  /**
2
- * Thrown by a dbx-firebase server function when the input context does not have the expected auth data on a Firebase function call.
2
+ * Error code used when a Firebase Cloud Function is called without any authentication context.
3
+ *
4
+ * Typically caught by middleware that validates auth before allowing the function to proceed.
3
5
  */
4
6
  export declare const DBX_FIREBASE_SERVER_NO_AUTH_ERROR_CODE = "NO_AUTH";
5
7
  /**
6
- * Thrown by a dbx-firebase server function when the input context does not have a user uid on a Firebase function call.
8
+ * Error code used when a Firebase Cloud Function has an auth context but is missing the user UID.
9
+ *
10
+ * This can happen with anonymous or malformed tokens.
7
11
  */
8
12
  export declare const DBX_FIREBASE_SERVER_NO_UID_ERROR_CODE = "NO_USER_UID";
@@ -1,23 +1,34 @@
1
1
  /**
2
- * Used to specify which function to direct requests to.
2
+ * Identifies a specific development function endpoint to route requests to.
3
+ *
4
+ * Used in dev/test environments to invoke specific server-side functions by name.
3
5
  */
4
6
  export type DevelopmentFirebaseFunctionSpecifier = string;
5
7
  /**
6
- * Provides a reference to a DevelopmentFirebaseFunctionSpecifier if available.
8
+ * Contains a reference to a {@link DevelopmentFirebaseFunctionSpecifier}.
7
9
  */
8
10
  export type DevelopmentFirebaseFunctionSpecifierRef = {
9
11
  specifier: DevelopmentFirebaseFunctionSpecifier;
10
12
  };
13
+ /**
14
+ * Parameters for calling a development-only Firebase function via the `dev` endpoint.
15
+ *
16
+ * Routes the call to a specific function via `specifier` and passes arbitrary data.
17
+ */
11
18
  export interface OnCallDevelopmentParams<T = unknown> {
12
19
  specifier: string;
13
20
  data: T;
14
21
  }
15
22
  /**
16
- * Creates an OnCallDevelopmentParams
23
+ * Creates an {@link OnCallDevelopmentParams} envelope for a development function call.
24
+ *
25
+ * @param specifier - the development function to invoke
26
+ * @param data - the call payload
17
27
  *
18
- * @param modelType
19
- * @param data
20
- * @returns
28
+ * @example
29
+ * ```ts
30
+ * const params = onCallDevelopmentParams('resetDatabase', { confirm: true });
31
+ * ```
21
32
  */
22
33
  export declare function onCallDevelopmentParams<T>(specifier: string, data: T): OnCallDevelopmentParams<T>;
23
34
  /**