@dereekb/firebase 11.1.8 → 12.0.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 (87) hide show
  1. package/index.cjs.js +3749 -2018
  2. package/index.esm.d.ts +1 -0
  3. package/index.esm.js +3673 -3107
  4. package/package.json +7 -6
  5. package/src/lib/common/firestore/accessor/accessor.batch.d.ts +12 -0
  6. package/src/lib/common/firestore/accessor/accessor.d.ts +90 -30
  7. package/src/lib/common/firestore/accessor/accessor.default.d.ts +14 -0
  8. package/src/lib/common/firestore/accessor/accessor.transaction.d.ts +15 -0
  9. package/src/lib/common/firestore/accessor/accessor.wrap.d.ts +107 -2
  10. package/src/lib/common/firestore/accessor/context.batch.d.ts +31 -0
  11. package/src/lib/common/firestore/accessor/context.d.ts +28 -5
  12. package/src/lib/common/firestore/accessor/context.default.d.ts +21 -0
  13. package/src/lib/common/firestore/accessor/context.transaction.d.ts +31 -0
  14. package/src/lib/common/firestore/accessor/converter.d.ts +28 -3
  15. package/src/lib/common/firestore/accessor/document.rxjs.d.ts +37 -0
  16. package/src/lib/common/firestore/accessor/document.utility.d.ts +129 -8
  17. package/src/lib/common/firestore/collection/collection.d.ts +116 -8
  18. package/src/lib/common/firestore/collection/collection.group.d.ts +38 -3
  19. package/src/lib/common/firestore/collection/collection.key.d.ts +62 -2
  20. package/src/lib/common/firestore/collection/collection.query.d.ts +168 -8
  21. package/src/lib/common/firestore/collection/collection.single.d.ts +33 -0
  22. package/src/lib/common/firestore/collection/subcollection.d.ts +70 -5
  23. package/src/lib/common/firestore/collection/subcollection.single.d.ts +40 -0
  24. package/src/lib/common/firestore/context.d.ts +154 -5
  25. package/src/lib/common/firestore/query/accumulator.d.ts +78 -5
  26. package/src/lib/common/firestore/query/constraint.d.ts +401 -15
  27. package/src/lib/common/firestore/query/constraint.template.d.ts +133 -40
  28. package/src/lib/common/firestore/query/iterator.d.ts +200 -14
  29. package/src/lib/common/firestore/query/query.d.ts +120 -11
  30. package/src/lib/common/firestore/query/query.iterate.array.d.ts +113 -9
  31. package/src/lib/common/firestore/query/query.iterate.d.ts +136 -13
  32. package/src/lib/common/firestore/query/query.util.d.ts +74 -7
  33. package/src/lib/common/firestore/query/watcher.d.ts +133 -2
  34. package/src/lib/common/firestore/snapshot/snapshot.d.ts +26 -0
  35. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +513 -3
  36. package/src/lib/common/firestore/snapshot/snapshot.type.d.ts +86 -5
  37. package/src/lib/common/model/function.d.ts +1 -1
  38. package/src/lib/common/storage/driver/accessor.d.ts +0 -1
  39. package/src/lib/common/storage/types.d.ts +0 -1
  40. package/test/CHANGELOG.md +13 -0
  41. package/test/package.json +3 -2
  42. package/test/src/lib/client/firebase.authorized.d.ts +2 -2
  43. package/test/src/lib/client/firebase.authorized.js.map +1 -1
  44. package/test/src/lib/client/firebase.d.ts +13 -13
  45. package/test/src/lib/client/firebase.js +4 -4
  46. package/test/src/lib/client/firebase.js.map +1 -1
  47. package/test/src/lib/client/firestore.mock.item.fixture.authorized.d.ts +2 -2
  48. package/test/src/lib/common/firebase.instance.d.ts +6 -6
  49. package/test/src/lib/common/firebase.instance.js.map +1 -1
  50. package/test/src/lib/common/firestore/firestore.d.ts +1 -1
  51. package/test/src/lib/common/firestore/firestore.instance.d.ts +3 -3
  52. package/test/src/lib/common/firestore/firestore.instance.js.map +1 -1
  53. package/test/src/lib/common/firestore/firestore.js +3 -4
  54. package/test/src/lib/common/firestore/firestore.js.map +1 -1
  55. package/test/src/lib/common/firestore/test.driver.accessor.d.ts +3 -3
  56. package/test/src/lib/common/firestore/test.driver.accessor.js +5 -6
  57. package/test/src/lib/common/firestore/test.driver.accessor.js.map +1 -1
  58. package/test/src/lib/common/firestore/test.driver.query.d.ts +1 -1
  59. package/test/src/lib/common/firestore/test.driver.query.js +14 -10
  60. package/test/src/lib/common/firestore/test.driver.query.js.map +1 -1
  61. package/test/src/lib/common/firestore/test.iterator.d.ts +1 -1
  62. package/test/src/lib/common/firestore/test.iterator.js +1 -2
  63. package/test/src/lib/common/firestore/test.iterator.js.map +1 -1
  64. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +5 -5
  65. package/test/src/lib/common/mock/mock.item.collection.fixture.js +2 -2
  66. package/test/src/lib/common/mock/mock.item.collection.fixture.js.map +1 -1
  67. package/test/src/lib/common/mock/mock.item.d.ts +5 -5
  68. package/test/src/lib/common/mock/mock.item.id.d.ts +1 -1
  69. package/test/src/lib/common/mock/mock.item.js +19 -19
  70. package/test/src/lib/common/mock/mock.item.js.map +1 -1
  71. package/test/src/lib/common/mock/mock.item.query.d.ts +2 -2
  72. package/test/src/lib/common/mock/mock.item.query.js +3 -4
  73. package/test/src/lib/common/mock/mock.item.query.js.map +1 -1
  74. package/test/src/lib/common/mock/mock.item.service.d.ts +3 -3
  75. package/test/src/lib/common/mock/mock.item.service.js +2 -2
  76. package/test/src/lib/common/mock/mock.item.service.js.map +1 -1
  77. package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +4 -4
  78. package/test/src/lib/common/mock/mock.item.storage.fixture.js +2 -2
  79. package/test/src/lib/common/mock/mock.item.storage.fixture.js.map +1 -1
  80. package/test/src/lib/common/storage/storage.d.ts +1 -1
  81. package/test/src/lib/common/storage/storage.instance.d.ts +3 -3
  82. package/test/src/lib/common/storage/storage.instance.js.map +1 -1
  83. package/test/src/lib/common/storage/storage.js +2 -3
  84. package/test/src/lib/common/storage/storage.js.map +1 -1
  85. package/test/src/lib/common/storage/test.driver.accessor.d.ts +1 -1
  86. package/test/src/lib/common/storage/test.driver.accessor.js +1 -2
  87. package/test/src/lib/common/storage/test.driver.accessor.js.map +1 -1
@@ -2,9 +2,24 @@ import { type WebsiteLink, type GrantedRole, type WebsiteFileLink } from '@deree
2
2
  import { type DateCellRange, type DateCellSchedule } from '@dereekb/date';
3
3
  import { type ModelFieldMapFunctionsConfig, type GetterOrValue, type Maybe, type ModelFieldMapConvertFunction, type PrimativeKey, type ReadKeyFunction, type ModelFieldMapFunctionsWithDefaultsConfig, type FilterUniqueStringsTransformConfig, type MapFunction, type FilterKeyValueTuplesInput, type ModelKey, type ToModelMapFunctionsInput, type ModelMapFunctionsRef, type LatLngPrecision, type LatLngString, type TimezoneString, type PrimativeKeyStringDencoderFunction, type PrimativeKeyDencoderFunction, type UnitedStatesAddress, type ZoomLevel, type FilterUniqueFunction, type BitwiseEncodedSet, type BitwiseObjectDencoder, type SortCompareFunctionRef, type TransformNumberFunctionConfigInput, type TransformStringFunctionConfigInput, type DecisionFunction, type ISO8601DateString, type FilterFunction } from '@dereekb/util';
4
4
  import { type FirestoreModelData } from './snapshot.type';
5
+ /**
6
+ * Base configuration for Firestore field mapping.
7
+ *
8
+ * @template V - Value type for the field in the model
9
+ * @template D - Data type for the field in Firestore (defaults to unknown)
10
+ */
5
11
  export interface BaseFirestoreFieldConfig<V, D = unknown> {
12
+ /**
13
+ * Function to convert from Firestore data (D) to model value (V)
14
+ */
6
15
  fromData: ModelFieldMapConvertFunction<D, V>;
16
+ /**
17
+ * Function to convert from model value (V) to Firestore data (D)
18
+ */
7
19
  toData: ModelFieldMapConvertFunction<V, D>;
20
+ /**
21
+ * Optional default value to use before saving if the value is null/undefined
22
+ */
8
23
  defaultBeforeSave?: GetterOrValue<D | null>;
9
24
  }
10
25
  /**
@@ -29,19 +44,67 @@ export interface FirestoreFieldDefaultData<D = unknown> {
29
44
  */
30
45
  defaultData: GetterOrValue<D>;
31
46
  }
47
+ /**
48
+ * Configuration for Firestore field with a default value for the model.
49
+ *
50
+ * @template V - Value type for the field in the model
51
+ * @template D - Data type for the field in Firestore (defaults to unknown)
52
+ */
32
53
  export interface FirestoreFieldConfigWithDefault<V, D = unknown> extends BaseFirestoreFieldConfig<V, D>, FirestoreFieldDefault<V> {
33
54
  }
55
+ /**
56
+ * Configuration for Firestore field with a default value for the Firestore data.
57
+ *
58
+ * @template V - Value type for the field in the model
59
+ * @template D - Data type for the field in Firestore (defaults to unknown)
60
+ */
34
61
  export interface FirestoreFieldConfigWithDefaultData<V, D = unknown> extends BaseFirestoreFieldConfig<V, D>, FirestoreFieldDefaultData<D> {
35
62
  }
63
+ /**
64
+ * Configuration for Firestore field that can have either a default value for the model
65
+ * or a default value for the Firestore data.
66
+ *
67
+ * @template V - Value type for the field in the model
68
+ * @template D - Data type for the field in Firestore (defaults to unknown)
69
+ */
36
70
  export type FirestoreFieldConfig<V, D = unknown> = FirestoreFieldConfigWithDefault<V, D> | FirestoreFieldConfigWithDefaultData<V, D>;
37
71
  /**
38
72
  * All firebase ModelFieldMapFunctionsConfig are configured to handle the read field value as null/undefined. This implies that
39
73
  * by design, the firebase database documents do not need to be fully intact for the system to handle them properly.
40
74
  */
41
75
  export type FirestoreModelFieldMapFunctionsConfig<V, D> = ModelFieldMapFunctionsWithDefaultsConfig<V, Maybe<D>>;
76
+ /**
77
+ * Creates a Firestore field mapping configuration.
78
+ *
79
+ * This function generates the necessary mapping functions for converting between
80
+ * model values and Firestore data. It handles defaults and conversions in both directions.
81
+ *
82
+ * @template V - Value type for the field in the model
83
+ * @template D - Data type for the field in Firestore (defaults to unknown)
84
+ * @param config - Configuration for the Firestore field
85
+ * @returns A configured mapping between model and Firestore data
86
+ */
42
87
  export declare function firestoreField<V, D = unknown>(config: FirestoreFieldConfig<V, D>): FirestoreModelFieldMapFunctionsConfig<V, D>;
43
88
  export declare const FIRESTORE_PASSTHROUGH_FIELD: FirestoreModelFieldMapFunctionsConfig<unknown, unknown>;
89
+ /**
90
+ * Creates a pass-through field mapping configuration that doesn't transform the data.
91
+ *
92
+ * This is useful when the model field and Firestore field are the same type and
93
+ * no transformation is needed in either direction.
94
+ *
95
+ * @template T - Type for both the model field and Firestore field
96
+ * @returns A field mapping configuration that passes values through unchanged
97
+ */
44
98
  export declare function firestorePassThroughField<T>(): ModelFieldMapFunctionsConfig<T, T>;
99
+ /**
100
+ * Configuration for optional Firestore fields with conditional storage.
101
+ *
102
+ * This interface provides options for determining when fields should not be stored
103
+ * in Firestore and default values for reading.
104
+ *
105
+ * @template V - Value type for the field in the model
106
+ * @template D - Data type for the field in Firestore
107
+ */
45
108
  export interface OptionalFirestoreFieldConfig<V, D> {
46
109
  /**
47
110
  * Removes the value from the object if the decision returns true.
@@ -60,6 +123,11 @@ export interface OptionalFirestoreFieldConfig<V, D> {
60
123
  */
61
124
  readonly defaultReadValue?: GetterOrValue<D>;
62
125
  }
126
+ /**
127
+ * Configuration for optional Firestore fields with the same type for model and Firestore.
128
+ *
129
+ * @template T - Type for both the model field and Firestore field
130
+ */
63
131
  export interface OptionalOneTypeFirestoreFieldConfig<T> extends OptionalFirestoreFieldConfig<T, T> {
64
132
  /**
65
133
  * Defaults the dontStoreIfValue value to this value.
@@ -74,6 +142,12 @@ export interface OptionalOneTypeFirestoreFieldConfig<T> extends OptionalFirestor
74
142
  */
75
143
  readonly dontStoreIfValue?: T;
76
144
  }
145
+ /**
146
+ * Configuration for optional Firestore fields with different types and transformations.
147
+ *
148
+ * @template V - Value type for the field in the model
149
+ * @template D - Data type for the field in Firestore
150
+ */
77
151
  export interface OptionalFirestoreFieldConfigWithTwoTypeTransform<V, D> extends OptionalFirestoreFieldConfig<V, D> {
78
152
  /**
79
153
  * (Optional) Function to transform the data after it is read from Firestore.
@@ -92,6 +166,11 @@ export interface OptionalFirestoreFieldConfigWithTwoTypeTransform<V, D> extends
92
166
  */
93
167
  readonly transformToData?: MapFunction<V, D | null>;
94
168
  }
169
+ /**
170
+ * Configuration for optional Firestore fields with single type and transformation function.
171
+ *
172
+ * @template T - Type for both the model field and Firestore field
173
+ */
95
174
  export interface OptionalFirestoreFieldConfigWithOneTypeTransform<T> extends OptionalFirestoreFieldConfigWithTwoTypeTransform<T, T>, OptionalOneTypeFirestoreFieldConfig<T> {
96
175
  /**
97
176
  * (Optional) Function to transform the data before it is stored and after it is read.
@@ -100,47 +179,253 @@ export interface OptionalFirestoreFieldConfigWithOneTypeTransform<T> extends Opt
100
179
  */
101
180
  readonly transformData?: MapFunction<T, T>;
102
181
  }
182
+ /**
183
+ * Creates a field mapping configuration for optional Firestore fields.
184
+ *
185
+ * Handles transformation and conditional storage of values with different types.
186
+ *
187
+ * @template V - Value type for the field in the model
188
+ * @template D - Data type for the field in Firestore
189
+ * @param config - Configuration for the optional Firestore field
190
+ * @returns A field mapping configuration for optional values
191
+ */
103
192
  export declare function optionalFirestoreField<V, D>(config?: OptionalFirestoreFieldConfigWithTwoTypeTransform<V, D>): ModelFieldMapFunctionsConfig<Maybe<V>, Maybe<D>>;
193
+ /**
194
+ * Creates a field mapping configuration for optional Firestore fields with same type.
195
+ *
196
+ * Handles transformation and conditional storage of values of the same type.
197
+ *
198
+ * @template T - Type for both the model field and Firestore field
199
+ * @param config - Configuration for the optional Firestore field
200
+ * @returns A field mapping configuration for optional values
201
+ */
104
202
  export declare function optionalFirestoreField<T>(config?: OptionalFirestoreFieldConfigWithOneTypeTransform<T>): ModelFieldMapFunctionsConfig<Maybe<T>, Maybe<T>>;
203
+ /**
204
+ * Configuration for a Firestore field with default model value but without conversion functions.
205
+ *
206
+ * @template V - Value type for the field in the model
207
+ * @template D - Data type for the field in Firestore (defaults to unknown)
208
+ */
105
209
  export type MapConfiguredFirestoreFieldConfigWithDefault<V, D = unknown> = Omit<FirestoreFieldConfigWithDefault<V, D>, 'fromData' | 'toData'>;
210
+ /**
211
+ * Configuration for a Firestore field with default data value but without conversion functions.
212
+ *
213
+ * @template V - Value type for the field in the model
214
+ * @template D - Data type for the field in Firestore (defaults to unknown)
215
+ */
106
216
  export type MapConfiguredFirestoreFieldConfigWithDefaultData<V, D = unknown> = Omit<FirestoreFieldConfigWithDefaultData<V, D>, 'fromData' | 'toData'>;
217
+ /**
218
+ * Configuration for a Firestore field with default values but without conversion functions.
219
+ *
220
+ * @template V - Value type for the field in the model
221
+ * @template D - Data type for the field in Firestore (defaults to unknown)
222
+ */
107
223
  export type MapConfiguredFirestoreFieldConfig<V, D = unknown> = MapConfiguredFirestoreFieldConfigWithDefault<V, D> | MapConfiguredFirestoreFieldConfigWithDefaultData<V, D>;
224
+ /**
225
+ * Configuration for a Firestore field with optional default model value but without conversion functions.
226
+ *
227
+ * @template V - Value type for the field in the model
228
+ * @template D - Data type for the field in Firestore (defaults to unknown)
229
+ */
108
230
  export type DefaultMapConfiguredFirestoreFieldConfig<V, D = unknown> = Omit<FirestoreFieldConfigWithDefault<V, D>, 'fromData' | 'toData' | 'default'> & Partial<Pick<FirestoreFieldConfigWithDefault<V, D>, 'default'>>;
231
+ /**
232
+ * Configuration for an optional Firestore field without conversion functions or defaults.
233
+ *
234
+ * @template V - Value type for the field in the model
235
+ * @template D - Data type for the field in Firestore (defaults to unknown)
236
+ */
109
237
  export type OptionalMapConfiguredFirestoreFieldConfig<V, D = unknown> = Omit<BaseFirestoreFieldConfig<V, D>, 'fromData' | 'toData' | 'defaultBeforeSave'>;
238
+ /**
239
+ * Configuration for a Firestore string field with optional transformation.
240
+ *
241
+ * @template S - String type for the field (defaults to string)
242
+ */
110
243
  export interface FirestoreStringConfig<S extends string = string> extends DefaultMapConfiguredFirestoreFieldConfig<S, S> {
244
+ /**
245
+ * Optional transformation to apply to the string value
246
+ */
111
247
  readonly transform?: TransformStringFunctionConfigInput<S>;
112
248
  }
113
249
  export declare const DEFAULT_FIRESTORE_STRING_FIELD_VALUE = "";
250
+ /**
251
+ * Creates a field mapping configuration for Firestore string fields.
252
+ *
253
+ * @template S - String type for the field (defaults to string)
254
+ * @param config - Configuration for the string field
255
+ * @returns A field mapping configuration for string values
256
+ */
114
257
  export declare function firestoreString<S extends string = string>(config?: FirestoreStringConfig<S>): FirestoreModelFieldMapFunctionsConfig<S, S>;
258
+ /**
259
+ * Configuration for an optional Firestore string field with transformation.
260
+ *
261
+ * @template S - String type for the field (defaults to string)
262
+ */
115
263
  export type OptionalFirestoreString<S extends string = string> = OptionalOneTypeFirestoreFieldConfig<S> & Pick<FirestoreStringConfig<S>, 'transform'>;
264
+ /**
265
+ * Creates a field mapping configuration for optional Firestore string fields.
266
+ *
267
+ * @template S - String type for the field (defaults to string)
268
+ * @param config - Configuration for the optional string field
269
+ * @returns A field mapping configuration for optional string values
270
+ */
116
271
  export declare function optionalFirestoreString<S extends string = string>(config?: OptionalFirestoreString<S>): ModelFieldMapFunctionsConfig<Maybe<S>, Maybe<S>>;
272
+ /**
273
+ * Configuration for a Firestore enum field.
274
+ *
275
+ * @template S - Enum type (string or number)
276
+ */
117
277
  export type FirestoreEnumConfig<S extends string | number> = MapConfiguredFirestoreFieldConfigWithDefault<S, S>;
278
+ /**
279
+ * Creates a field mapping configuration for Firestore enum fields.
280
+ *
281
+ * @template S - Enum type (string or number)
282
+ * @param config - Configuration for the enum field
283
+ * @returns A field mapping configuration for enum values
284
+ */
118
285
  export declare function firestoreEnum<S extends string | number>(config: FirestoreEnumConfig<S>): FirestoreModelFieldMapFunctionsConfig<S, S>;
286
+ /**
287
+ * Configuration for an optional Firestore enum field.
288
+ *
289
+ * @template S - Enum type (string or number)
290
+ */
119
291
  export type OptionalFirestoreEnumConfig<S extends string | number> = OptionalOneTypeFirestoreFieldConfig<S>;
292
+ /**
293
+ * Creates a field mapping configuration for optional Firestore enum fields.
294
+ *
295
+ * @template S - Enum type (string or number)
296
+ * @param config - Configuration for the optional enum field
297
+ * @returns A field mapping configuration for optional enum values
298
+ */
120
299
  export declare function optionalFirestoreEnum<S extends string | number>(config?: OptionalFirestoreEnumConfig<S>): ModelFieldMapFunctionsConfig<Maybe<S>, Maybe<S>>;
300
+ /**
301
+ * Creates a field mapping configuration for Firestore UID fields.
302
+ *
303
+ * @returns A field mapping configuration for Firebase Auth user IDs
304
+ */
121
305
  export declare function firestoreUID(): FirestoreModelFieldMapFunctionsConfig<string, string>;
306
+ /**
307
+ * Creates a field mapping configuration for optional Firestore UID fields.
308
+ *
309
+ * @returns A field mapping configuration for optional Firebase Auth user IDs
310
+ */
122
311
  export declare function optionalFirestoreUID(): ModelFieldMapFunctionsConfig<Maybe<string>, Maybe<string>>;
123
312
  export declare const firestoreModelKeyString: FirestoreModelFieldMapFunctionsConfig<string, string>;
124
313
  export declare const firestoreModelIdString: FirestoreModelFieldMapFunctionsConfig<string, string>;
314
+ /**
315
+ * Configuration for a Firestore date field.
316
+ *
317
+ * @template Date - JavaScript Date object type
318
+ * @template string - ISO8601 date string format in Firestore
319
+ */
125
320
  export type FirestoreDateFieldConfig = DefaultMapConfiguredFirestoreFieldConfig<Date, string> & {
321
+ /**
322
+ * Whether to save the default date as the current timestamp
323
+ */
126
324
  readonly saveDefaultAsNow?: boolean;
127
325
  };
326
+ /**
327
+ * Creates a field mapping configuration for Firestore date fields.
328
+ *
329
+ * Handles conversion between JavaScript Date objects and ISO8601 strings stored in Firestore.
330
+ *
331
+ * @param config - Configuration for the date field
332
+ * @returns A field mapping configuration for Date values
333
+ */
128
334
  export declare function firestoreDate(config?: FirestoreDateFieldConfig): FirestoreModelFieldMapFunctionsConfig<Date, string>;
335
+ /**
336
+ * Configuration for an optional Firestore date field.
337
+ *
338
+ * @template Date - JavaScript Date object type
339
+ * @template ISO8601DateString - ISO8601 date string format in Firestore
340
+ */
129
341
  export type OptionalFirestoreDateFieldConfig = OptionalFirestoreFieldConfig<Date, ISO8601DateString>;
342
+ /**
343
+ * Creates a field mapping configuration for optional Firestore date fields.
344
+ *
345
+ * Handles conversion between JavaScript Date objects and ISO8601 strings stored in Firestore.
346
+ *
347
+ * @param config - Configuration for the optional date field
348
+ * @returns A field mapping configuration for optional Date values
349
+ */
130
350
  export declare function optionalFirestoreDate(config?: OptionalFirestoreDateFieldConfig): ModelFieldMapFunctionsConfig<Maybe<Date>, Maybe<string>>;
351
+ /**
352
+ * Configuration for a Firestore boolean field.
353
+ */
131
354
  export type FirestoreBooleanFieldConfig = MapConfiguredFirestoreFieldConfigWithDefault<boolean, boolean>;
355
+ /**
356
+ * Creates a field mapping configuration for Firestore boolean fields.
357
+ *
358
+ * @param config - Configuration for the boolean field
359
+ * @returns A field mapping configuration for boolean values
360
+ */
132
361
  export declare function firestoreBoolean(config: FirestoreBooleanFieldConfig): FirestoreModelFieldMapFunctionsConfig<boolean, boolean>;
362
+ /**
363
+ * Configuration for an optional Firestore boolean field.
364
+ */
133
365
  export type OptionalFirestoreBooleanFieldConfig = OptionalOneTypeFirestoreFieldConfig<boolean>;
366
+ /**
367
+ * Creates a field mapping configuration for optional Firestore boolean fields.
368
+ *
369
+ * @param config - Configuration for the optional boolean field
370
+ * @returns A field mapping configuration for optional boolean values
371
+ */
134
372
  export declare function optionalFirestoreBoolean(config?: OptionalFirestoreBooleanFieldConfig): ModelFieldMapFunctionsConfig<Maybe<boolean>, Maybe<boolean>>;
373
+ /**
374
+ * Configuration for a Firestore number field with optional transformation.
375
+ *
376
+ * @template N - Number type for the field (defaults to number)
377
+ */
135
378
  export interface FirestoreNumberConfig<N extends number = number> extends MapConfiguredFirestoreFieldConfigWithDefault<N, N> {
379
+ /**
380
+ * Whether to save the default value if no value is provided
381
+ */
136
382
  readonly saveDefault?: Maybe<boolean>;
383
+ /**
384
+ * Optional transformation to apply to the number value
385
+ */
137
386
  readonly transform?: TransformNumberFunctionConfigInput<N>;
138
387
  }
388
+ /**
389
+ * Creates a field mapping configuration for Firestore number fields.
390
+ *
391
+ * @template N - Number type for the field (defaults to number)
392
+ * @param config - Configuration for the number field
393
+ * @returns A field mapping configuration for number values
394
+ */
139
395
  export declare function firestoreNumber<N extends number = number>(config: FirestoreNumberConfig<N>): FirestoreModelFieldMapFunctionsConfig<N, N>;
396
+ /**
397
+ * Configuration for an optional Firestore number field with transformation.
398
+ *
399
+ * @template N - Number type for the field (defaults to number)
400
+ */
140
401
  export type OptionalFirestoreNumberFieldConfig<N extends number = number> = OptionalOneTypeFirestoreFieldConfig<N> & Pick<FirestoreNumberConfig<N>, 'transform'>;
402
+ /**
403
+ * Creates a field mapping configuration for optional Firestore number fields.
404
+ *
405
+ * @template N - Number type for the field (defaults to number)
406
+ * @param config - Configuration for the optional number field
407
+ * @returns A field mapping configuration for optional number values
408
+ */
141
409
  export declare function optionalFirestoreNumber<N extends number = number>(config?: OptionalFirestoreNumberFieldConfig<N>): ModelFieldMapFunctionsConfig<Maybe<N>, Maybe<N>>;
410
+ /**
411
+ * Configuration for a Firestore array field with optional sorting.
412
+ *
413
+ * @template T - Type of elements in the array
414
+ */
142
415
  export type FirestoreArrayFieldConfig<T> = DefaultMapConfiguredFirestoreFieldConfig<T[], T[]> & Partial<SortCompareFunctionRef<T>> & Partial<FirestoreFieldDefault<T[]>>;
416
+ /**
417
+ * Creates a field mapping configuration for Firestore array fields.
418
+ *
419
+ * @template T - Type of elements in the array
420
+ * @param config - Configuration for the array field
421
+ * @returns A field mapping configuration for array values
422
+ */
143
423
  export declare function firestoreArray<T>(config: FirestoreArrayFieldConfig<T>): FirestoreModelFieldMapFunctionsConfig<T[], T[]>;
424
+ /**
425
+ * Configuration for an optional Firestore array field with filtering and sorting options.
426
+ *
427
+ * @template T - Type of elements in the array
428
+ */
144
429
  export type OptionalFirestoreArrayFieldConfig<T> = Omit<OptionalFirestoreFieldConfigWithOneTypeTransform<T[]>, 'dontStoreIf' | 'dontStoreIfValue' | 'transformFromData' | 'transformToData'> & Pick<FirestoreArrayFieldConfig<T>, 'sortWith'> & {
145
430
  /**
146
431
  * Filters the function uniquely. If true uses the unique function.
@@ -157,15 +442,63 @@ export type OptionalFirestoreArrayFieldConfig<T> = Omit<OptionalFirestoreFieldCo
157
442
  */
158
443
  readonly dontStoreIfEmpty?: boolean;
159
444
  };
445
+ /**
446
+ * Creates a field mapping configuration for optional Firestore array fields.
447
+ *
448
+ * Supports unique filtering and conditional storage based on array content.
449
+ *
450
+ * @template T - Type of elements in the array
451
+ * @param config - Configuration for the optional array field
452
+ * @returns A field mapping configuration for optional array values
453
+ */
160
454
  export declare function optionalFirestoreArray<T>(config?: OptionalFirestoreArrayFieldConfig<T>): ModelFieldMapFunctionsConfig<Maybe<T[]>, Maybe<T[]>>;
455
+ /**
456
+ * Configuration for a Firestore array field with unique filtering.
457
+ *
458
+ * @template T - Type of elements in the array
459
+ * @template K - Key type for filtering uniqueness (defaults to T if it's a primative key)
460
+ */
161
461
  export type FirestoreUniqueArrayFieldConfig<T, K extends PrimativeKey = T extends PrimativeKey ? T : PrimativeKey> = FirestoreArrayFieldConfig<T> & Partial<SortCompareFunctionRef<T>> & {
462
+ /**
463
+ * Function to filter array elements for uniqueness
464
+ */
162
465
  readonly filterUnique: FilterUniqueFunction<T, K> | true;
163
466
  };
467
+ /**
468
+ * Creates a field mapping configuration for Firestore array fields with unique filtering.
469
+ *
470
+ * @template T - Type of elements in the array
471
+ * @template K - Key type for filtering uniqueness
472
+ * @param config - Configuration for the unique array field
473
+ * @returns A field mapping configuration for unique array values
474
+ */
164
475
  export declare function firestoreUniqueArray<T, K extends PrimativeKey = T extends PrimativeKey ? T : PrimativeKey>(config: FirestoreUniqueArrayFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<T[], T[]>;
476
+ /**
477
+ * Configuration for a Firestore array field with unique filtering based on a key function.
478
+ *
479
+ * @template T - Type of elements in the array
480
+ * @template K - Type of the key used for uniqueness (defaults to PrimativeKey)
481
+ */
165
482
  export type FirestoreUniqueKeyedArrayFieldConfig<T, K extends PrimativeKey = PrimativeKey> = FirestoreArrayFieldConfig<T> & {
483
+ /**
484
+ * Function to extract the key from an array element for uniqueness checking
485
+ */
166
486
  readonly readKey: ReadKeyFunction<T, K>;
167
487
  };
488
+ /**
489
+ * Creates a field mapping configuration for Firestore array fields with unique filtering based on a key function.
490
+ *
491
+ * @template T - Type of elements in the array
492
+ * @template K - Type of the key used for uniqueness
493
+ * @param config - Configuration for the keyed unique array field
494
+ * @returns A field mapping configuration for keyed unique array values
495
+ */
168
496
  export declare function firestoreUniqueKeyedArray<T, K extends PrimativeKey = PrimativeKey>(config: FirestoreUniqueKeyedArrayFieldConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<T[], T[]>;
497
+ /**
498
+ * Configuration for a Firestore array field of enum values.
499
+ *
500
+ * @template S - Enum type (string or number)
501
+ */
169
502
  export type FirestoreEnumArrayFieldConfig<S extends string | number> = Omit<FirestoreUniqueArrayFieldConfig<S>, 'filterUnique'>;
170
503
  /**
171
504
  * FirestoreField configuration for an array of unique enum values.
@@ -173,16 +506,62 @@ export type FirestoreEnumArrayFieldConfig<S extends string | number> = Omit<Fire
173
506
  * @param config
174
507
  * @returns
175
508
  */
509
+ /**
510
+ * Creates a field mapping configuration for Firestore array fields of enum values.
511
+ *
512
+ * @template S - Enum type (string or number)
513
+ * @param config - Configuration for the enum array field
514
+ * @returns A field mapping configuration for enum array values
515
+ */
176
516
  export declare function firestoreEnumArray<S extends string | number>(config?: FirestoreEnumArrayFieldConfig<S>): FirestoreModelFieldMapFunctionsConfig<S[], S[]>;
517
+ /**
518
+ * Configuration for a Firestore array field of unique string values.
519
+ *
520
+ * @template S - String type (defaults to string)
521
+ */
177
522
  export type FirestoreUniqueStringArrayFieldConfig<S extends string = string> = Omit<FirestoreUniqueArrayFieldConfig<S>, 'filterUnique'> & FilterUniqueStringsTransformConfig;
523
+ /**
524
+ * Creates a field mapping configuration for Firestore array fields of unique string values.
525
+ *
526
+ * @template S - String type (defaults to string)
527
+ * @param config - Configuration for the unique string array field
528
+ * @returns A field mapping configuration for unique string array values
529
+ */
178
530
  export declare function firestoreUniqueStringArray<S extends string = string>(config?: FirestoreUniqueStringArrayFieldConfig<S>): FirestoreModelFieldMapFunctionsConfig<S[], S[]>;
179
531
  export declare const firestoreModelKeyArrayField: FirestoreModelFieldMapFunctionsConfig<string[], string[]>;
180
532
  export declare const firestoreModelIdArrayField: FirestoreModelFieldMapFunctionsConfig<string[], string[]>;
533
+ /**
534
+ * Configuration for a Firestore array field of unique number values.
535
+ *
536
+ * @template S - Number type (defaults to number)
537
+ */
181
538
  export type FirestoreUniqueNumberArrayFieldConfig<S extends number = number> = Omit<FirestoreUniqueArrayFieldConfig<S>, 'filterUnique'>;
539
+ /**
540
+ * Creates a field mapping configuration for Firestore array fields of unique number values.
541
+ *
542
+ * @template S - Number type (defaults to number)
543
+ * @param config - Configuration for the unique number array field
544
+ * @returns A field mapping configuration for unique number array values
545
+ */
182
546
  export declare function firestoreUniqueNumberArray<S extends number = number>(config?: FirestoreUniqueNumberArrayFieldConfig<S>): FirestoreModelFieldMapFunctionsConfig<S[], S[]>;
547
+ /**
548
+ * Configuration for a Firestore array field with custom encoding/decoding of values.
549
+ *
550
+ * @template T - Type of elements in the model array
551
+ * @template E - Type of encoded elements in Firestore (string or number)
552
+ */
183
553
  export type FirestoreEncodedArrayFieldConfig<T, E extends string | number> = DefaultMapConfiguredFirestoreFieldConfig<T[], E[]> & Partial<SortCompareFunctionRef<T>> & {
554
+ /**
555
+ * Conversion functions for encoding/decoding array elements
556
+ */
184
557
  readonly convert: {
558
+ /**
559
+ * Function to convert from Firestore data to model value
560
+ */
185
561
  fromData: MapFunction<E, T>;
562
+ /**
563
+ * Function to convert from model value to Firestore data
564
+ */
186
565
  toData: MapFunction<T, E>;
187
566
  };
188
567
  };
@@ -192,8 +571,27 @@ export type FirestoreEncodedArrayFieldConfig<T, E extends string | number> = Def
192
571
  * @param config
193
572
  * @returns
194
573
  */
574
+ /**
575
+ * Creates a field mapping configuration for Firestore array fields with custom encoding.
576
+ *
577
+ * A Firestore array that encodes values to either string or number values using another FirestoreModelField config for encoding/decoding.
578
+ *
579
+ * @template T - Type of elements in the model array
580
+ * @template E - Type of encoded elements in Firestore (string or number)
581
+ * @param config - Configuration for the encoded array field
582
+ * @returns A field mapping configuration for encoded array values
583
+ */
195
584
  export declare function firestoreEncodedArray<T, E extends string | number>(config: FirestoreEncodedArrayFieldConfig<T, E>): FirestoreModelFieldMapFunctionsConfig<T[], E[]>;
585
+ /**
586
+ * Configuration for a Firestore array field with primative key encoding/decoding.
587
+ *
588
+ * @template D - Type of decoded elements in the model array
589
+ * @template E - Type of encoded elements in Firestore
590
+ */
196
591
  export type FirestoreDencoderArrayFieldConfig<D extends PrimativeKey, E extends PrimativeKey> = DefaultMapConfiguredFirestoreFieldConfig<D[], E[]> & {
592
+ /**
593
+ * Function that handles both encoding and decoding of array elements
594
+ */
197
595
  readonly dencoder: PrimativeKeyDencoderFunction<D, E>;
198
596
  };
199
597
  /**
@@ -202,15 +600,40 @@ export type FirestoreDencoderArrayFieldConfig<D extends PrimativeKey, E extends
202
600
  * @param config
203
601
  * @returns
204
602
  */
603
+ /**
604
+ * Creates a field mapping configuration for Firestore array fields with primative key encoding/decoding.
605
+ *
606
+ * An array that is stored as an array of encoded values using a PrimativeKeyDencoderFunction.
607
+ *
608
+ * @template D - Type of decoded elements in the model array
609
+ * @template E - Type of encoded elements in Firestore
610
+ * @param config - Configuration for the decoder array field
611
+ * @returns A field mapping configuration for encoded primative key array values
612
+ */
205
613
  export declare function firestoreDencoderArray<D extends PrimativeKey, E extends PrimativeKey>(config: FirestoreDencoderArrayFieldConfig<D, E>): FirestoreModelFieldMapFunctionsConfig<D[], E[]>;
614
+ /**
615
+ * Configuration for a Firestore array field that encodes primative keys to a string representation.
616
+ *
617
+ * @template D - Type of decoded elements in the model array
618
+ * @template E - Type of encoded elements (intermediate representation)
619
+ * @template S - String type for storage in Firestore
620
+ */
206
621
  export type FirestoreDencoderStringArrayFieldConfig<D extends PrimativeKey, E extends PrimativeKey, S extends string = string> = DefaultMapConfiguredFirestoreFieldConfig<D[], S> & {
207
- readonly dencoder: PrimativeKeyStringDencoderFunction<D, E>;
622
+ /**
623
+ * Function that handles both encoding and decoding of array elements to/from string
624
+ */
625
+ readonly dencoder: PrimativeKeyStringDencoderFunction<D, E, S>;
208
626
  };
209
627
  /**
628
+ * Creates a field mapping configuration for Firestore array fields that encode primative keys to a string representation.
629
+ *
210
630
  * An array that is stored as an encoded string using a PrimativeKeyDencoderString configuration.
211
631
  *
212
- * @param config
213
- * @returns
632
+ * @template D - Type of decoded elements in the model array
633
+ * @template E - Type of encoded elements (intermediate representation)
634
+ * @template S - String type for storage in Firestore
635
+ * @param config - Configuration for the string decoder array field
636
+ * @returns A field mapping configuration for string-encoded primative key array values
214
637
  */
215
638
  export declare function firestoreDencoderStringArray<D extends PrimativeKey, E extends PrimativeKey, S extends string = string>(config: FirestoreDencoderStringArrayFieldConfig<D, E, S>): FirestoreModelFieldMapFunctionsConfig<D[], S>;
216
639
  /**
@@ -398,11 +821,21 @@ export declare function firestoreTimezoneString(config?: FirestoreTimezoneString
398
821
  export declare const DEFAULT_WEBSITE_LINK: WebsiteLink;
399
822
  export declare const assignWebsiteLinkFunction: import("@dereekb/util").AssignValuesToPOJOFunction<WebsiteLink>;
400
823
  export declare const firestoreWebsiteLinkAssignFn: MapFunction<WebsiteLink, WebsiteLink>;
824
+ /**
825
+ * Creates a field mapping configuration for Firestore website link fields.
826
+ *
827
+ * @returns A field mapping configuration for website link values
828
+ */
401
829
  export declare function firestoreWebsiteLink(): FirestoreModelFieldMapFunctionsConfig<WebsiteLink, WebsiteLink>;
402
830
  export declare function firestoreWebsiteLinkArray(): FirestoreModelFieldMapFunctionsConfig<WebsiteLink[], WebsiteLink[]>;
403
831
  export declare const DEFAULT_FIRESTORE_WEBSITE_FILE_LINK_VALUE: WebsiteFileLink;
404
832
  export declare const assignWebsiteFileLinkFunction: import("@dereekb/util").AssignValuesToPOJOFunction<WebsiteFileLink>;
405
833
  export declare const firestoreWebsiteFileLinkAssignFn: MapFunction<WebsiteFileLink, WebsiteFileLink>;
834
+ /**
835
+ * Creates a field mapping configuration for Firestore website file link fields.
836
+ *
837
+ * @returns A field mapping configuration for website file link values
838
+ */
406
839
  export declare function firestoreWebsiteFileLink(): FirestoreModelFieldMapFunctionsConfig<WebsiteFileLink, WebsiteFileLink>;
407
840
  /**
408
841
  * Stores the array of WebsiteFileLink values as an array of objects.
@@ -415,32 +848,109 @@ export declare function firestoreWebsiteFileLinkEncodedArray(): FirestoreModelFi
415
848
  export declare const DEFAULT_DATE_CELL_RANGE_VALUE: DateCellRange;
416
849
  export declare const assignDateCellRangeFunction: import("@dereekb/util").AssignValuesToPOJOFunction<DateCellRange>;
417
850
  export declare const firestoreDateCellRangeAssignFn: MapFunction<DateCellRange, DateCellRange>;
851
+ /**
852
+ * Creates a field mapping configuration for Firestore date cell range fields.
853
+ *
854
+ * @returns A field mapping configuration for date cell range values
855
+ */
418
856
  export declare function firestoreDateCellRange(): FirestoreModelFieldMapFunctionsConfig<DateCellRange, DateCellRange>;
419
857
  export declare function firestoreDateCellRangeArray(sort?: boolean): FirestoreModelFieldMapFunctionsConfig<DateCellRange[], DateCellRange[]>;
420
858
  export declare const DEFAULT_FIRESTORE_DATE_CELL_SCHEDULE_VALUE: DateCellSchedule;
421
859
  export declare const assignDateCellScheduleFunction: import("@dereekb/util").AssignValuesToPOJOFunction<DateCellSchedule>;
422
860
  export declare const firestoreDateCellScheduleAssignFn: MapFunction<DateCellSchedule, DateCellSchedule>;
861
+ /**
862
+ * Creates a field mapping configuration for Firestore date cell schedule fields.
863
+ *
864
+ * @returns A field mapping configuration for date cell schedule values
865
+ */
423
866
  export declare function firestoreDateCellSchedule(): FirestoreModelFieldMapFunctionsConfig<DateCellSchedule, DateCellSchedule>;
424
867
  export declare const DEFAULT_FIRESTORE_UNITED_STATES_ADDRESS_VALUE: UnitedStatesAddress;
868
+ /**
869
+ * Function to assign values to a UnitedStatesAddress object while filtering specific keys and empty values.
870
+ */
425
871
  export declare const assignUnitedStatesAddressFunction: import("@dereekb/util").AssignValuesToPOJOFunction<UnitedStatesAddress>;
872
+ /**
873
+ * Function to assign values from an input UnitedStatesAddress to a default UnitedStatesAddress.
874
+ */
426
875
  export declare const firestoreUnitedStatesAddressAssignFn: MapFunction<UnitedStatesAddress, UnitedStatesAddress>;
876
+ /**
877
+ * Creates a field mapping configuration for Firestore United States address fields.
878
+ *
879
+ * @returns A field mapping configuration for United States address values
880
+ */
427
881
  export declare function firestoreUnitedStatesAddress(): FirestoreModelFieldMapFunctionsConfig<UnitedStatesAddress, UnitedStatesAddress>;
882
+ /**
883
+ * Creates a field mapping configuration for optional Firestore United States address fields.
884
+ *
885
+ * @returns A field mapping configuration for optional United States address values
886
+ */
428
887
  export declare function optionalFirestoreUnitedStatesAddress(): FirestoreModelFieldMapFunctionsConfig<Maybe<UnitedStatesAddress>, Maybe<UnitedStatesAddress>>;
429
888
  export declare const MIN_FIRESTORE_MAP_ZOOM_LEVEL_VALUE: ZoomLevel;
430
889
  export declare const MAX_FIRESTORE_MAP_ZOOM_LEVEL_VALUE: ZoomLevel;
431
890
  /**
891
+ * Field mapping configuration for Firestore map zoom level fields.
892
+ *
432
893
  * Convenience function for firestoreNumber() for storing an integer ZoomLevel value.
433
894
  */
434
895
  export declare const firestoreMapZoomLevel: FirestoreModelFieldMapFunctionsConfig<number, number>;
896
+ /**
897
+ * Configuration for a Firestore field that stores a set of numbers as a bitwise-encoded value.
898
+ *
899
+ * @template D - Type of number elements in the set (defaults to number)
900
+ */
435
901
  export interface FirestoreBitwiseSetConfig<D extends number = number> extends DefaultMapConfiguredFirestoreFieldConfig<Set<D>, BitwiseEncodedSet> {
902
+ /**
903
+ * Maximum index value to support in the bitwise encoding
904
+ */
436
905
  readonly maxIndex?: number;
437
906
  }
907
+ /**
908
+ * Creates a field mapping configuration for Firestore fields that store sets of numbers as bitwise-encoded values.
909
+ *
910
+ * @template D - Type of number elements in the set (defaults to number)
911
+ * @param config - Configuration for the bitwise set field
912
+ * @returns A field mapping configuration for bitwise-encoded set values
913
+ */
438
914
  export declare function firestoreBitwiseSet<D extends number = number>(config: FirestoreBitwiseSetConfig<D>): FirestoreModelFieldMapFunctionsConfig<Set<D>, number>;
915
+ /**
916
+ * Configuration for a Firestore field that maps objects with bitwise-encoded set values.
917
+ *
918
+ * @template D - Type of number elements in the sets (defaults to number)
919
+ * @template K - Type of keys in the object (string)
920
+ */
439
921
  export interface FirestoreBitwiseSetMapConfig<D extends number = number, K extends string = string> extends Omit<FirestoreEncodedObjectMapFieldConfig<Set<D>, BitwiseEncodedSet, K>, 'encoder' | 'decoder'> {
922
+ /**
923
+ * Maximum index value to support in the bitwise encoding
924
+ */
440
925
  readonly maxIndex?: number;
441
926
  }
927
+ /**
928
+ * Creates a field mapping configuration for Firestore fields that map objects with bitwise-encoded set values.
929
+ *
930
+ * @template D - Type of number elements in the sets (defaults to number)
931
+ * @template K - Type of keys in the object (string)
932
+ * @param config - Configuration for the bitwise set map field
933
+ * @returns A field mapping configuration for object maps with bitwise-encoded set values
934
+ */
442
935
  export declare function firestoreBitwiseSetMap<D extends number = number, K extends string = string>(config: FirestoreBitwiseSetMapConfig<D, K>): FirestoreModelFieldMapFunctionsConfig<FirestoreEncodedObjectMapFieldValueType<Set<D>, K>, FirestoreMapFieldType<number, K>>;
936
+ /**
937
+ * Configuration for a Firestore field that maps objects with bitwise-encoded object values.
938
+ *
939
+ * @template T - Type of object values in the map
940
+ * @template K - Type of keys in the object (string)
941
+ */
443
942
  export interface FirestoreBitwiseObjectMapConfig<T extends object, K extends string = string> extends Omit<FirestoreEncodedObjectMapFieldConfig<T, BitwiseEncodedSet, K>, 'encoder' | 'decoder'> {
943
+ /**
944
+ * Function that handles both encoding and decoding of object values to/from bitwise values
945
+ */
444
946
  readonly dencoder: BitwiseObjectDencoder<T>;
445
947
  }
948
+ /**
949
+ * Creates a field mapping configuration for Firestore fields that map objects with bitwise-encoded object values.
950
+ *
951
+ * @template T - Type of object values in the map
952
+ * @template K - Type of keys in the object (string)
953
+ * @param config - Configuration for the bitwise object map field
954
+ * @returns A field mapping configuration for object maps with bitwise-encoded object values
955
+ */
446
956
  export declare function firestoreBitwiseObjectMap<T extends object, K extends string = string>(config: FirestoreBitwiseObjectMapConfig<T, K>): FirestoreModelFieldMapFunctionsConfig<FirestoreEncodedObjectMapFieldValueType<T, K>, FirestoreMapFieldType<number, K>>;