@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
@@ -4,10 +4,33 @@ import { type FirestoreCollection } from '../../common/firestore/collection/coll
4
4
  import { type FirestoreContext } from '../../common/firestore/context';
5
5
  import { type CollectionReference } from '../../common/firestore/types';
6
6
  import { type ModelFieldMapFunctionsConfig } from '@dereekb/util';
7
+ /**
8
+ * @module system
9
+ *
10
+ * Defines the SystemState Firestore model for storing system-wide singleton state and settings.
11
+ *
12
+ * Each {@link SystemState} document is identified by a {@link SystemStateTypeIdentifier} and acts
13
+ * as a singleton for that type — storing arbitrary key-value data about the state of a system
14
+ * subcomponent (e.g., last migration timestamp, feature flags, processing checkpoints).
15
+ *
16
+ * Supports per-type data conversion via the `converterFactory` pattern in
17
+ * {@link systemStateFirestoreCollection}.
18
+ */
19
+ /**
20
+ * Abstract base providing access to the SystemState Firestore collection.
21
+ *
22
+ * Implement this in your app module to wire up dependency injection.
23
+ */
7
24
  export declare abstract class SystemStateFirestoreCollections {
8
25
  abstract readonly systemStateCollection: SystemStateFirestoreCollection;
9
26
  }
27
+ /**
28
+ * Union of all SystemState-related model identity types.
29
+ */
10
30
  export type SystemStateTypes = typeof systemStateIdentity;
31
+ /**
32
+ * Model identity for the SystemState collection (collection name: `systemState`, prefix: `sys`).
33
+ */
11
34
  export declare const systemStateIdentity: import("../..").RootFirestoreModelIdentity<"systemState", "sys">;
12
35
  /**
13
36
  * Used to identify a SystemStateId.
@@ -22,28 +45,81 @@ export type SystemStateId = SystemStateTypeIdentifier;
22
45
  */
23
46
  export type SystemStateStoredData = Record<string, any>;
24
47
  /**
25
- * A collection used for recording the current state of system subcomponents. System states for a given identifier are treated as a system-wide singleton/state/setting.
48
+ * A singleton Firestore document storing the current state of a system subcomponent.
49
+ *
50
+ * Each document is identified by a {@link SystemStateTypeIdentifier} and stores arbitrary
51
+ * key-value data. Used for tracking migration progress, feature flags, processing checkpoints,
52
+ * or any system-wide state that needs persistence.
26
53
  *
27
- * For example, a SystemState with a specific SystemStateId may be relied on for information about the previous update, etc.
54
+ * @template T - shape of the stored data record
28
55
  */
29
56
  export interface SystemState<T extends SystemStateStoredData = SystemStateStoredData> {
30
57
  data: T;
31
58
  }
59
+ /**
60
+ * Permission roles for SystemState operations. Restricted to system administrators.
61
+ */
32
62
  export type SystemStateRoles = GrantedSysAdminRole;
33
63
  /**
34
- * Refers to a singleton SystemState based on this model's identifier.
64
+ * Firestore document wrapper for a {@link SystemState} singleton.
65
+ *
66
+ * The document ID serves as the {@link SystemStateTypeIdentifier}, making each
67
+ * SystemState a singleton keyed by its type.
68
+ *
69
+ * @template T - shape of the stored data record
35
70
  */
36
71
  export declare class SystemStateDocument<T extends SystemStateStoredData = SystemStateStoredData> extends AbstractFirestoreDocument<SystemState<T>, SystemStateDocument<T>, typeof systemStateIdentity> {
37
72
  get modelIdentity(): import("../..").RootFirestoreModelIdentity<"systemState", "sys">;
38
73
  }
74
+ /**
75
+ * Default snapshot converter for {@link SystemState} documents.
76
+ *
77
+ * Uses pass-through conversion for the `data` field. Per-type converters can be
78
+ * supplied via the `converterFactory` in {@link systemStateFirestoreCollection}.
79
+ */
39
80
  export declare const systemStateConverter: import("../..").SnapshotConverterFunctions<SystemState<SystemStateStoredData>, Partial<import("@dereekb/util").ReplaceType<SystemState<SystemStateStoredData>, import("@dereekb/util").MaybeMap<object>, any>>>;
81
+ /**
82
+ * Returns the raw Firestore CollectionReference for the SystemState collection.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const colRef = systemStateCollectionReference(firestoreContext);
87
+ * ```
88
+ */
40
89
  export declare function systemStateCollectionReference(context: FirestoreContext): CollectionReference<SystemState>;
41
90
  export type SystemStateFirestoreCollection<T extends SystemStateStoredData = SystemStateStoredData> = FirestoreCollection<SystemState<T>, SystemStateDocument<T>>;
42
91
  /**
43
- * A ModelFieldMapFunctionsConfig used for data conversion.
92
+ * Field conversion config for a specific SystemState data type.
93
+ *
94
+ * Maps the typed `data` field to/from Firestore using {@link ModelFieldMapFunctionsConfig}.
95
+ *
96
+ * @template T - shape of the stored data
44
97
  */
45
98
  export type SystemStateStoredDataFieldConverterConfig<T extends SystemStateStoredData = SystemStateStoredData> = ModelFieldMapFunctionsConfig<T, any>;
99
+ /**
100
+ * Map of {@link SystemStateTypeIdentifier} to their data field converters.
101
+ *
102
+ * Each entry defines how a specific SystemState type's `data` field is serialized/deserialized.
103
+ */
46
104
  export type SystemStateStoredDataConverterMap = {
47
105
  [key: string]: SystemStateStoredDataFieldConverterConfig<any>;
48
106
  };
107
+ /**
108
+ * Creates a {@link SystemStateFirestoreCollection} with per-type data converters.
109
+ *
110
+ * The `converters` map is used via a `converterFactory` that selects the appropriate
111
+ * converter based on the document ID (which is the {@link SystemStateTypeIdentifier}).
112
+ * Documents with no matching converter use the default pass-through converter.
113
+ *
114
+ * @param firestoreContext - the Firestore context
115
+ * @param converters - map of type identifiers to their data field converters
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * const collection = systemStateFirestoreCollection(firestoreContext, {
120
+ * 'migration_v2': { fields: { lastRun: firestoreDate() } }
121
+ * });
122
+ * const doc = collection.documentAccessor().loadDocumentForId('migration_v2');
123
+ * ```
124
+ */
49
125
  export declare function systemStateFirestoreCollection(firestoreContext: FirestoreContext, converters: SystemStateStoredDataConverterMap): SystemStateFirestoreCollection;
@@ -1,9 +1,15 @@
1
1
  import { type FirebaseAuthUserIdRef } from '../common/auth/auth';
2
2
  /**
3
- * The model is related to a user with the model's uid.
3
+ * Marker interface for models that are related to a user via a `uid` field.
4
+ *
5
+ * Extends {@link FirebaseAuthUserIdRef} to carry the Firebase Auth user ID.
6
+ * Use this when the model stores the user ID explicitly as a field.
4
7
  */
5
8
  export type UserRelated = FirebaseAuthUserIdRef;
6
9
  /**
7
- * The model is related to a user by the model's own identifier.
10
+ * Marker interface for models related to a user by the model's own document ID.
11
+ *
12
+ * The document ID itself is the user's Firebase Auth UID, so no separate `uid` field is needed.
13
+ * Use this for user-profile-style documents where the document key equals the user ID.
8
14
  */
9
15
  export type UserRelatedById = object;