@dereekb/firebase-server 13.2.2 → 13.3.0

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 (166) hide show
  1. package/index.cjs.js +7506 -1884
  2. package/index.esm.js +7505 -1890
  3. package/mailgun/index.cjs.js +333 -31
  4. package/mailgun/index.esm.js +333 -31
  5. package/mailgun/package.json +8 -8
  6. package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
  7. package/model/index.cjs.js +11334 -3830
  8. package/model/index.esm.js +11338 -3834
  9. package/model/package.json +8 -8
  10. package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
  11. package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
  12. package/model/src/lib/notification/notification.action.service.d.ts +151 -2
  13. package/model/src/lib/notification/notification.config.d.ts +19 -7
  14. package/model/src/lib/notification/notification.config.service.d.ts +44 -6
  15. package/model/src/lib/notification/notification.create.run.d.ts +33 -5
  16. package/model/src/lib/notification/notification.error.d.ts +63 -0
  17. package/model/src/lib/notification/notification.module.d.ts +11 -0
  18. package/model/src/lib/notification/notification.send.d.ts +8 -1
  19. package/model/src/lib/notification/notification.send.service.d.ts +7 -1
  20. package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
  21. package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
  22. package/model/src/lib/notification/notification.task.service.d.ts +13 -1
  23. package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
  24. package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
  25. package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
  26. package/model/src/lib/notification/notification.util.d.ts +70 -0
  27. package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
  28. package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
  29. package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
  30. package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
  31. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
  32. package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
  33. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
  34. package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
  35. package/oidc/index.cjs.default.js +1 -0
  36. package/oidc/index.cjs.js +5607 -0
  37. package/oidc/index.cjs.mjs +2 -0
  38. package/oidc/index.d.ts +1 -0
  39. package/oidc/index.esm.js +5560 -0
  40. package/oidc/package.json +26 -0
  41. package/oidc/src/index.d.ts +1 -0
  42. package/oidc/src/lib/controller/index.d.ts +3 -0
  43. package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
  44. package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
  45. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
  46. package/oidc/src/lib/index.d.ts +6 -0
  47. package/oidc/src/lib/middleware/index.d.ts +3 -0
  48. package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
  49. package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
  50. package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
  51. package/oidc/src/lib/model/index.d.ts +3 -0
  52. package/oidc/src/lib/model/jwks/index.d.ts +3 -0
  53. package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
  54. package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
  55. package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
  56. package/oidc/src/lib/model/model.d.ts +12 -0
  57. package/oidc/src/lib/model/oidc/index.d.ts +2 -0
  58. package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
  59. package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
  60. package/oidc/src/lib/oidc.config.d.ts +175 -0
  61. package/oidc/src/lib/oidc.module.d.ts +100 -0
  62. package/oidc/src/lib/service/index.d.ts +10 -0
  63. package/oidc/src/lib/service/oidc.account.d.ts +36 -0
  64. package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
  65. package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
  66. package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
  67. package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
  68. package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
  69. package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
  70. package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
  71. package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
  72. package/oidc/src/lib/service/oidc.service.d.ts +55 -0
  73. package/package.json +15 -9
  74. package/src/lib/auth/auth.context.d.ts +22 -2
  75. package/src/lib/auth/auth.service.d.ts +5 -0
  76. package/src/lib/auth/auth.service.error.d.ts +2 -1
  77. package/src/lib/auth/auth.util.d.ts +15 -3
  78. package/src/lib/env/env.config.d.ts +42 -0
  79. package/src/lib/env/env.service.d.ts +17 -0
  80. package/src/lib/env/index.d.ts +1 -0
  81. package/src/lib/firestore/array.d.ts +11 -3
  82. package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
  83. package/src/lib/firestore/driver.accessor.d.ts +43 -0
  84. package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
  85. package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
  86. package/src/lib/firestore/driver.d.ts +14 -0
  87. package/src/lib/firestore/driver.query.d.ts +25 -0
  88. package/src/lib/firestore/increment.d.ts +13 -3
  89. package/src/lib/firestore/snapshot/index.d.ts +1 -1
  90. package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
  91. package/src/lib/function/assert.d.ts +32 -16
  92. package/src/lib/function/context.d.ts +26 -0
  93. package/src/lib/function/error.auth.d.ts +15 -0
  94. package/src/lib/function/error.d.ts +68 -4
  95. package/src/lib/nest/app.d.ts +53 -9
  96. package/src/lib/nest/app.module.d.ts +90 -0
  97. package/src/lib/nest/auth/auth.module.d.ts +30 -4
  98. package/src/lib/nest/auth/auth.util.d.ts +38 -0
  99. package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
  100. package/src/lib/nest/controller/index.d.ts +1 -0
  101. package/src/lib/nest/development/development.app.function.d.ts +45 -0
  102. package/src/lib/nest/development/development.assert.function.d.ts +19 -1
  103. package/src/lib/nest/development/development.function.d.ts +42 -3
  104. package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
  105. package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
  106. package/src/lib/nest/env/env.service.d.ts +9 -0
  107. package/src/lib/nest/env/env.util.d.ts +16 -0
  108. package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
  109. package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
  110. package/src/lib/nest/function/call.d.ts +75 -6
  111. package/src/lib/nest/function/context.d.ts +85 -2
  112. package/src/lib/nest/function/nest.d.ts +46 -0
  113. package/src/lib/nest/function/schedule.d.ts +49 -0
  114. package/src/lib/nest/function/v2/blocking.d.ts +92 -8
  115. package/src/lib/nest/function/v2/call.d.ts +38 -8
  116. package/src/lib/nest/function/v2/event.d.ts +67 -4
  117. package/src/lib/nest/function/v2/schedule.d.ts +36 -5
  118. package/src/lib/nest/index.d.ts +3 -0
  119. package/src/lib/nest/middleware/appcheck.d.ts +5 -0
  120. package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
  121. package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
  122. package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
  123. package/src/lib/nest/middleware/index.d.ts +2 -1
  124. package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
  125. package/src/lib/nest/model/call.model.function.d.ts +69 -3
  126. package/src/lib/nest/model/create.model.function.d.ts +66 -0
  127. package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
  128. package/src/lib/nest/model/delete.model.function.d.ts +55 -0
  129. package/src/lib/nest/model/permission.error.d.ts +15 -0
  130. package/src/lib/nest/model/read.model.function.d.ts +57 -0
  131. package/src/lib/nest/model/specifier.function.d.ts +58 -1
  132. package/src/lib/nest/model/update.model.function.d.ts +58 -0
  133. package/src/lib/nest/nest.provider.d.ts +24 -11
  134. package/src/lib/nest/nest.provider.server.d.ts +12 -0
  135. package/src/lib/nest/storage/storage.module.d.ts +30 -4
  136. package/src/lib/storage/driver.accessor.d.ts +33 -0
  137. package/src/lib/storage/driver.d.ts +14 -0
  138. package/src/lib/storage/storage.d.ts +11 -4
  139. package/src/lib/storage/storage.service.d.ts +10 -1
  140. package/src/lib/type.d.ts +7 -2
  141. package/test/index.cjs.js +4072 -757
  142. package/test/index.esm.js +4073 -761
  143. package/test/package.json +8 -8
  144. package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
  145. package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
  146. package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
  147. package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
  148. package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
  149. package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
  150. package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
  151. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
  152. package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
  153. package/test/src/lib/firebase/firebase.d.ts +57 -2
  154. package/test/src/lib/firebase/firebase.function.d.ts +138 -0
  155. package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
  156. package/test/src/lib/firestore/firestore.d.ts +30 -0
  157. package/test/src/lib/storage/storage.admin.d.ts +9 -3
  158. package/test/src/lib/storage/storage.d.ts +30 -0
  159. package/zoho/index.cjs.js +406 -73
  160. package/zoho/index.esm.js +406 -73
  161. package/zoho/package.json +8 -8
  162. package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
  163. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
  164. package/index.cjs.js.map +0 -1
  165. package/index.esm.js.map +0 -1
  166. /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
@@ -6,17 +6,43 @@ import { type NotificationExpediteServiceInstance, type NotificationExpediteServ
6
6
  import { type StorageFileInitializeFromUploadServiceRef } from './storagefile.upload.service';
7
7
  import { type Maybe } from '@dereekb/util';
8
8
  /**
9
- * Injection token for the BaseStorageFileServerActionsContext
9
+ * NestJS injection token for the {@link BaseStorageFileServerActionsContext}, providing
10
+ * Firebase infrastructure, storage service, notification collections, and Firestore collections
11
+ * needed by storage file actions.
10
12
  */
11
13
  export declare const BASE_STORAGE_FILE_SERVER_ACTION_CONTEXT_TOKEN: InjectionToken;
12
14
  /**
13
- * Injection token for the StorageFileServerActionsContext
15
+ * NestJS injection token for the fully assembled {@link StorageFileServerActionsContext},
16
+ * which adds the upload initialization service on top of the base context.
14
17
  */
15
18
  export declare const STORAGE_FILE_SERVER_ACTION_CONTEXT_TOKEN: InjectionToken;
19
+ /**
20
+ * Minimal context providing Firebase infrastructure, storage, notification, and Firestore
21
+ * collections needed by all storage file server actions.
22
+ */
16
23
  export interface BaseStorageFileServerActionsContext extends FirebaseServerActionsContext, NotificationFirestoreCollections, NotificationExpediteServiceRef, StorageFileFirestoreCollections, FirebaseServerAuthServiceRef, FirebaseServerStorageServiceRef, FirestoreContextReference {
17
24
  }
25
+ /**
26
+ * Full context for storage file server actions, extending the base with the
27
+ * upload initialization service.
28
+ */
18
29
  export interface StorageFileServerActionsContext extends BaseStorageFileServerActionsContext, StorageFileInitializeFromUploadServiceRef {
19
30
  }
31
+ /**
32
+ * Abstract service class defining all server-side storage file CRUD, upload processing, and group management actions.
33
+ *
34
+ * This is the central API surface for the storage file system's backend. It provides:
35
+ *
36
+ * - **File management**: create, update, delete, and download {@link StorageFile} documents
37
+ * - **Upload pipeline**: initialize storage files from uploaded files, with type detection and processing
38
+ * - **Batch processing**: process all queued files, delete all flagged files
39
+ * - **Group management**: create/update {@link StorageFileGroup} documents, sync files with groups,
40
+ * and regenerate group content (e.g., ZIP archives)
41
+ *
42
+ * Each method follows the transform-and-validate pattern used throughout the notification/storage system.
43
+ *
44
+ * @see {@link storageFileServerActions} for the concrete implementation factory.
45
+ */
20
46
  export declare abstract class StorageFileServerActions {
21
47
  abstract createStorageFile(params: CreateStorageFileParams): AsyncStorageFileCreateAction<CreateStorageFileParams>;
22
48
  abstract initializeAllStorageFilesFromUploads(params: InitializeAllStorageFilesFromUploadsParams): Promise<TransformAndValidateFunctionResult<InitializeAllStorageFilesFromUploadsParams, () => Promise<InitializeAllStorageFilesFromUploadsResult>>>;
@@ -34,8 +60,33 @@ export declare abstract class StorageFileServerActions {
34
60
  abstract regenerateStorageFileGroupContent(params: RegenerateStorageFileGroupContentParams): Promise<TransformAndValidateFunctionResult<RegenerateStorageFileGroupContentParams, (storageFileGroupDocument: StorageFileGroupDocument) => Promise<RegenerateStorageFileGroupContentResult>>>;
35
61
  abstract regenerateAllFlaggedStorageFileGroupsContent(params: RegenerateAllFlaggedStorageFileGroupsContentParams): Promise<TransformAndValidateFunctionResult<RegenerateAllFlaggedStorageFileGroupsContentParams, () => Promise<RegenerateAllFlaggedStorageFileGroupsContentResult>>>;
36
62
  }
63
+ /**
64
+ * Creates a concrete {@link StorageFileServerActions} implementation by wiring each action
65
+ * to its factory function using the provided context.
66
+ *
67
+ * @param context - the fully assembled storage file server actions context
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * const actions = storageFileServerActions(context);
72
+ * const initFn = await actions.initializeStorageFileFromUpload({ key, storagePath });
73
+ * const storageFileDoc = await initFn();
74
+ * ```
75
+ */
37
76
  export declare function storageFileServerActions(context: StorageFileServerActionsContext): StorageFileServerActions;
77
+ /**
78
+ * Factory for the `createStorageFile` action.
79
+ *
80
+ * Creates a new {@link StorageFile} document using the provided template data.
81
+ */
38
82
  export declare function createStorageFileFactory(context: BaseStorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<CreateStorageFileParams, () => Promise<any>, object, unknown>;
83
+ /**
84
+ * Factory for the `initializeAllStorageFilesFromUploads` action.
85
+ *
86
+ * Scans the uploads folder in Firebase Storage, identifies new uploaded files,
87
+ * initializes each one via the upload service, and cleans up the source upload
88
+ * on success. Failed initializations are logged but do not halt the batch.
89
+ */
39
90
  export declare function initializeAllStorageFilesFromUploadsFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<InitializeAllStorageFilesFromUploadsParams, () => Promise<InitializeAllStorageFilesFromUploadsResult>, object, unknown>;
40
91
  export interface InitializeStorageFileFromUploadFileInput {
41
92
  readonly file: FirebaseStorageAccessorFile;
@@ -47,9 +98,23 @@ export interface InitializeStorageFileFromUploadFileInput {
47
98
  readonly expediteProcessing?: Maybe<boolean>;
48
99
  }
49
100
  export declare function _initializeStorageFileFromUploadFileFactory(context: StorageFileServerActionsContext): (input: InitializeStorageFileFromUploadFileInput) => Promise<StorageFileDocument>;
101
+ /**
102
+ * Factory for the `initializeStorageFileFromUpload` action.
103
+ *
104
+ * Initializes a single {@link StorageFile} from an uploaded file at the given storage path.
105
+ * Validates the file exists and is allowed, runs the type determiner and initializer,
106
+ * then cleans up the upload source on success.
107
+ */
50
108
  export declare function initializeStorageFileFromUploadFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<InitializeStorageFileFromUploadParams, () => Promise<StorageFileDocument>, object, unknown>;
51
109
  export declare function updateStorageFileFactory(context: BaseStorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<UpdateStorageFileParams, (storageFileDocument: StorageFileDocument) => Promise<StorageFileDocument>, object, unknown>;
52
110
  export declare function updateStorageFileGroupFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<UpdateStorageFileGroupParams, (storageFileGroupDocument: StorageFileGroupDocument) => Promise<StorageFileGroupDocument>, object, unknown>;
111
+ /**
112
+ * Factory for the `processAllQueuedStorageFiles` action.
113
+ *
114
+ * Batch-processes all {@link StorageFile} documents queued for processing. Creates a
115
+ * processing notification task for each file and optionally expedites delivery.
116
+ * Handles stuck-processing detection with a throttle check.
117
+ */
53
118
  export declare function processAllQueuedStorageFilesFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<ProcessAllQueuedStorageFilesParams, () => Promise<ProcessAllQueuedStorageFilesResult>, object, unknown>;
54
119
  export interface ProcessStorageFileInTransactionInput {
55
120
  /**
@@ -70,9 +135,35 @@ export interface ProcessStorageFileInTransactionInput {
70
135
  readonly expediteInstance?: Maybe<NotificationExpediteServiceInstance>;
71
136
  }
72
137
  export declare function _processStorageFileInTransactionFactory(context: StorageFileServerActionsContext): (input: ProcessStorageFileInTransactionInput, transaction: Transaction) => Promise<void>;
138
+ /**
139
+ * Factory for the `processStorageFile` action.
140
+ *
141
+ * Processes a single {@link StorageFile} by creating a notification task for it
142
+ * and marking it as processing. Validates the file is in a valid state for processing.
143
+ */
73
144
  export declare function processStorageFileFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<ProcessStorageFileParams, (storageFileDocument: StorageFileDocument) => Promise<ProcessStorageFileResult>, object, unknown>;
145
+ /**
146
+ * Factory for the `deleteAllQueuedStorageFiles` action.
147
+ *
148
+ * Batch-deletes all {@link StorageFile} documents flagged for deletion whose
149
+ * scheduled delete time has passed. Removes both the Firestore document and
150
+ * the associated file in Cloud Storage.
151
+ */
74
152
  export declare function deleteAllQueuedStorageFilesFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<DeleteAllQueuedStorageFilesParams, () => Promise<DeleteAllQueuedStorageFilesResult>, object, unknown>;
153
+ /**
154
+ * Factory for the `deleteStorageFile` action.
155
+ *
156
+ * Deletes a single {@link StorageFile} document and its associated Cloud Storage file.
157
+ * Validates the file is flagged for deletion and the scheduled delete time has passed.
158
+ */
75
159
  export declare function deleteStorageFileFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<DeleteStorageFileParams, (inputStorageFileDocument: StorageFileDocument) => Promise<void>, object, unknown>;
160
+ /**
161
+ * Factory for the `downloadStorageFile` action.
162
+ *
163
+ * Generates a signed download URL for a {@link StorageFile}'s associated Cloud Storage file.
164
+ * The URL expires after the configured duration. Supports loading the storage file document
165
+ * by key if not provided directly.
166
+ */
76
167
  export declare function downloadStorageFileFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<DownloadStorageFileParams, (storageFileDocument?: Maybe<StorageFileDocument>) => Promise<DownloadStorageFileResult>, object, unknown>;
77
168
  /**
78
169
  * Used for creating a new NotificationBox within a transaction.
@@ -97,6 +188,12 @@ export declare function createStorageFileGroupInTransactionFactory(context: Stor
97
188
  storageFileGroupTemplate: StorageFileGroup;
98
189
  storageFileGroupDocument: StorageFileGroupDocument;
99
190
  }>;
191
+ /**
192
+ * Factory for the `createStorageFileGroup` action.
193
+ *
194
+ * Creates a new {@link StorageFileGroup} document within a Firestore transaction,
195
+ * associating it with a model key or storage file.
196
+ */
100
197
  export declare function createStorageFileGroupFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<CreateStorageFileGroupParams, () => Promise<StorageFileGroupDocument>, object, unknown>;
101
198
  export interface SyncStorageFileWithGroupsInTransactionInput {
102
199
  readonly storageFileDocument: StorageFileDocument;
@@ -120,7 +217,32 @@ export interface SyncStorageFileWithGroupsInTransactionInput {
120
217
  readonly skipStorageFileUpdate?: Maybe<boolean>;
121
218
  }
122
219
  export declare function _syncStorageFileWithGroupsInTransactionFactory(context: StorageFileServerActionsContext): (input: SyncStorageFileWithGroupsInTransactionInput, transaction: Transaction) => Promise<SyncStorageFileWithGroupsResult>;
220
+ /**
221
+ * Factory for the `syncStorageFileWithGroups` action.
222
+ *
223
+ * Syncs a single {@link StorageFile}'s embedded data into its associated {@link StorageFileGroup}
224
+ * documents and clears the sync flag on completion.
225
+ */
123
226
  export declare function syncStorageFileWithGroupsFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<SyncStorageFileWithGroupsParams, (storageFileDocument: StorageFileDocument) => Promise<SyncStorageFileWithGroupsResult>, object, unknown>;
227
+ /**
228
+ * Factory for the `syncAllFlaggedStorageFilesWithGroups` action.
229
+ *
230
+ * Batch-processes all {@link StorageFile} documents flagged for group sync,
231
+ * updating their associated {@link StorageFileGroup} documents and flagging
232
+ * groups for content regeneration when changes occur.
233
+ */
124
234
  export declare function syncAllFlaggedStorageFilesWithGroupsFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<SyncAllFlaggedStorageFilesWithGroupsParams, () => Promise<SyncAllFlaggedStorageFilesWithGroupsResult>, object, unknown>;
235
+ /**
236
+ * Factory for the `regenerateStorageFileGroupContent` action.
237
+ *
238
+ * Regenerates the content of a single {@link StorageFileGroup}, including building a ZIP
239
+ * archive from the group's embedded files and updating the group's content metadata.
240
+ */
125
241
  export declare function regenerateStorageFileGroupContentFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<RegenerateStorageFileGroupContentParams, (storageFileGroupDocument: StorageFileGroupDocument) => Promise<RegenerateStorageFileGroupContentResult>, object, unknown>;
242
+ /**
243
+ * Factory for the `regenerateAllFlaggedStorageFileGroupsContent` action.
244
+ *
245
+ * Batch-processes all {@link StorageFileGroup} documents flagged for content regeneration,
246
+ * rebuilding their ZIP archives and updating content metadata.
247
+ */
126
248
  export declare function regenerateAllFlaggedStorageFileGroupsContentFactory(context: StorageFileServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<RegenerateAllFlaggedStorageFileGroupsContentParams, () => Promise<RegenerateAllFlaggedStorageFileGroupsContentResult>, object, unknown>;
@@ -1,15 +1,59 @@
1
1
  import { type UploadedFileInitializationFailedErrorData } from '@dereekb/firebase';
2
+ /**
3
+ * Creates an error indicating that a storage file model has already been initialized.
4
+ */
2
5
  export declare function storageFileModelAlreadyInitializedError(): import("firebase-functions/https").HttpsError;
6
+ /**
7
+ * Creates an error indicating that the StorageFile is not flagged for group sync.
8
+ */
3
9
  export declare function storageFileNotFlaggedForGroupsSyncError(): import("firebase-functions/https").HttpsError;
10
+ /**
11
+ * Creates an error indicating that the target uploaded file does not exist in storage.
12
+ */
4
13
  export declare function uploadedFileDoesNotExistError(): import("firebase-functions/https").HttpsError;
14
+ /**
15
+ * Creates an error indicating that the file is not allowed to be initialized (rejected by the check function).
16
+ */
5
17
  export declare function uploadedFileIsNotAllowedToBeInitializedError(): import("firebase-functions/https").HttpsError;
18
+ /**
19
+ * Creates an error indicating that the file initialization failed with the given result type.
20
+ *
21
+ * @param data - error data containing the result type that caused the failure
22
+ */
6
23
  export declare function uploadedFileInitializationFailedError(data: UploadedFileInitializationFailedErrorData): import("firebase-functions/https").HttpsError;
24
+ /**
25
+ * Creates an error indicating that the initialization result was discarded (e.g., the created file no longer exists).
26
+ */
7
27
  export declare function uploadedFileInitializationDiscardedError(): import("firebase-functions/https").HttpsError;
28
+ /**
29
+ * Creates an error indicating that the StorageFile is not in a valid state for processing.
30
+ */
8
31
  export declare function storageFileProcessingNotAllowedForInvalidStateError(): import("firebase-functions/https").HttpsError;
32
+ /**
33
+ * Creates an error indicating that the StorageFile is not queued for processing.
34
+ */
9
35
  export declare function storageFileProcessingNotQueuedForProcessingError(): import("firebase-functions/https").HttpsError;
36
+ /**
37
+ * Creates an error indicating that no processor is configured for the StorageFile's type.
38
+ */
10
39
  export declare function storageFileProcessingNotAvailableForTypeError(): import("firebase-functions/https").HttpsError;
40
+ /**
41
+ * Creates an error indicating that the StorageFile has already finished processing.
42
+ */
11
43
  export declare function storageFileAlreadyProcessedError(): import("firebase-functions/https").HttpsError;
44
+ /**
45
+ * Creates an error indicating that the StorageFile is not flagged for deletion.
46
+ */
12
47
  export declare function storageFileNotFlaggedForDeletionError(): import("firebase-functions/https").HttpsError;
48
+ /**
49
+ * Creates an error indicating that the StorageFile's scheduled deletion time has not yet passed.
50
+ */
13
51
  export declare function storageFileCannotBeDeletedYetError(): import("firebase-functions/https").HttpsError;
52
+ /**
53
+ * Creates an error indicating that the StorageFileGroup is still queued for initialization and cannot be operated on.
54
+ */
14
55
  export declare function storageFileGroupQueuedForInitializationError(): import("firebase-functions/https").HttpsError;
56
+ /**
57
+ * Creates an error indicating that the required model key or storageFileId is missing when creating a StorageFileGroup.
58
+ */
15
59
  export declare function createStorageFileGroupInputError(): import("firebase-functions/https").HttpsError;
@@ -3,8 +3,19 @@ import { type Maybe } from '@dereekb/util';
3
3
  import { type BaseStorageFileServerActionsContext, StorageFileServerActions, type StorageFileServerActionsContext } from './storagefile.action.server';
4
4
  import { StorageFileInitializeFromUploadService } from './storagefile.upload.service';
5
5
  import { StorageFileInitServerActions, type StorageFileInitServerActionsContextConfig } from './storagefile.action.init.service';
6
+ /**
7
+ * Factory that assembles the full {@link StorageFileServerActionsContext} by combining
8
+ * the base context with the upload initialization service.
9
+ */
6
10
  export declare function storageFileServerActionsContextFactory(context: BaseStorageFileServerActionsContext, storageFileInitializeFromUploadService: StorageFileInitializeFromUploadService): StorageFileServerActionsContext;
11
+ /**
12
+ * Factory that creates a {@link StorageFileServerActions} instance from the assembled context.
13
+ */
7
14
  export declare function storageFileServerActionsFactory(context: StorageFileServerActionsContext): StorageFileServerActions;
15
+ /**
16
+ * Factory that creates a {@link StorageFileInitServerActions} instance by merging the
17
+ * server actions context with the init-specific configuration.
18
+ */
8
19
  export declare function storageFileInitServerActionsFactory(context: StorageFileServerActionsContext, storageFileInitServerActionsContextConfig: StorageFileInitServerActionsContextConfig): StorageFileInitServerActions;
9
20
  export interface ProvideAppStorageFileMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
10
21
  /**
@@ -5,7 +5,10 @@ import { type StorageFileQueueForDeleteTime } from './storagefile.util';
5
5
  import { type NotificationTaskSubtaskCleanupInstructions, type NotificationTaskSubtaskFlowEntry, type NotificationTaskSubtaskInput, type NotificationTaskSubtaskNotificationTaskHandlerConfig, type NotificationTaskSubtaskProcessorConfig } from '../notification/notification.task.subtask.handler';
6
6
  import archiver from 'archiver';
7
7
  /**
8
- * Input for a StorageFileProcessingPurposeSubtask.
8
+ * Input for a purpose-specific storage file processing subtask.
9
+ *
10
+ * Extends the generic subtask input with storage-file-specific context: the document reference,
11
+ * a lazy loader for the current file data, and a file reader for accessing the stored file's content.
9
12
  */
10
13
  export interface StorageFileProcessingPurposeSubtaskInput<M extends StorageFileProcessingSubtaskMetadata = any, S extends StorageFileProcessingSubtask = StorageFileProcessingSubtask> extends NotificationTaskSubtaskInput<StorageFileProcessingNotificationTaskData<M, S>, M, S> {
11
14
  /**
@@ -6,6 +6,9 @@ import { type Maybe, type PromiseOrValue } from '@dereekb/util';
6
6
  export interface StorageFileInitializeFromUploadServiceRef {
7
7
  readonly storageFileInitializeFromUploadService: StorageFileInitializeFromUploadService;
8
8
  }
9
+ /**
10
+ * Input for storage file upload initialization, containing the file to process.
11
+ */
9
12
  export interface StorageFileInitializeFromUploadInput {
10
13
  /**
11
14
  * The target file.
@@ -14,6 +17,10 @@ export interface StorageFileInitializeFromUploadInput {
14
17
  */
15
18
  readonly file: FirebaseStorageAccessorFile;
16
19
  }
20
+ /**
21
+ * Result of a storage file upload initialization, indicating success/failure,
22
+ * the created file path, and the initialized document.
23
+ */
17
24
  export interface StorageFileInitializeFromUploadResult {
18
25
  /**
19
26
  * Whether or not the initialization was successful.
@@ -39,7 +46,12 @@ export interface StorageFileInitializeFromUploadResult {
39
46
  readonly previousStorageFilesFlaggedForDeletion?: Maybe<number>;
40
47
  }
41
48
  /**
42
- * Service dedicated to initializing a StorageFileDocument value from an uploaded file.
49
+ * Abstract service responsible for the upload-to-StorageFile initialization pipeline.
50
+ *
51
+ * Implementations determine the uploaded file's type, validate it's allowed,
52
+ * and create the corresponding {@link StorageFile} document in Firestore.
53
+ *
54
+ * @see {@link storageFileInitializeFromUploadService} for the default implementation.
43
55
  */
44
56
  export declare abstract class StorageFileInitializeFromUploadService {
45
57
  /**
@@ -2,6 +2,10 @@ import { type CombineUploadFileTypeDeterminerConfig, type CreateStorageFileDocum
2
2
  import { type ArrayOrValue, type AsyncDecisionFunction, type Maybe } from '@dereekb/util';
3
3
  import { type StorageFileInitializeFromUploadService } from './storagefile.upload.service';
4
4
  import { type FirebaseServerStorageService } from '@dereekb/firebase-server';
5
+ /**
6
+ * Input for a storage file upload initializer, providing the type determination result
7
+ * and the file reader for accessing the uploaded file's content.
8
+ */
5
9
  export interface StorageFileInitializeFromUploadServiceInitializerInput {
6
10
  /**
7
11
  * The result of the determiner.
@@ -12,6 +16,12 @@ export interface StorageFileInitializeFromUploadServiceInitializerInput {
12
16
  */
13
17
  readonly fileDetailsAccessor: StoredFileReader;
14
18
  }
19
+ /**
20
+ * Union result type from a storage file upload initializer. Can be:
21
+ * - An error result (initialization failed)
22
+ * - A create result (new StorageFile document was created via pair factory)
23
+ * - A document result (StorageFile document was created/found directly)
24
+ */
15
25
  export type StorageFileInitializeFromUploadServiceInitializerResult = StorageFileInitializeFromUploadServiceInitializerStorageFileErrorResult | StorageFileInitializeFromUploadServiceInitializerCreateStorageFileResult | StorageFileInitializeFromUploadServiceInitializerStorageFileDocumentResult;
16
26
  export interface StorageFileInitializeFromUploadServiceInitializerStorageFileErrorResult {
17
27
  /**
@@ -55,6 +65,13 @@ export interface StorageFileInitializeFromUploadServiceInitializerStorageFileDoc
55
65
  */
56
66
  readonly flagPreviousForDelete?: Maybe<StorageFilePurposeAndUserQueryInput>;
57
67
  }
68
+ /**
69
+ * Convenience factory for creating a permanent failure result, indicating the file
70
+ * should be discarded and any created intermediate files cleaned up.
71
+ *
72
+ * @param error - the error that caused the permanent failure
73
+ * @param createdFile - optional path to a file that was created before the error and should be deleted
74
+ */
58
75
  export declare function storageFileInitializeFromUploadServiceInitializerResultPermanentFailure(error: unknown, createdFile?: Maybe<StoragePathRef>): StorageFileInitializeFromUploadServiceInitializerResult;
59
76
  /**
60
77
  * Processes the input details accessor and returns the results.
@@ -117,6 +134,31 @@ export interface StorageFileInitializeFromUploadServiceConfig {
117
134
  readonly initializer: StorageFileInitializeFromUploadServiceInitializer[];
118
135
  }
119
136
  /**
120
- * A basic StorageFileInitializeFromUploadService implementation.
137
+ * Creates a {@link StorageFileInitializeFromUploadService} from the provided configuration.
138
+ *
139
+ * Combines file type determiners with type-specific initializers to form a complete
140
+ * upload processing pipeline. When a file is uploaded:
141
+ *
142
+ * 1. The combined determiner identifies the file type
143
+ * 2. The corresponding initializer processes the file (copies, creates Firestore document, etc.)
144
+ * 3. The created file is linked back to the StorageFile document via custom metadata
145
+ * 4. Optionally, previous files for the same purpose/user are flagged for deletion
146
+ *
147
+ * @param config - service configuration including determiners, initializers, and storage references
148
+ *
149
+ * @example
150
+ * ```ts
151
+ * const service = storageFileInitializeFromUploadService({
152
+ * storageService,
153
+ * storageFileCollection,
154
+ * initializer: [
155
+ * {
156
+ * type: 'image',
157
+ * determiner: imageDeterminer,
158
+ * initialize: processImage
159
+ * }
160
+ * ]
161
+ * });
162
+ * ```
121
163
  */
122
164
  export declare function storageFileInitializeFromUploadService(config: StorageFileInitializeFromUploadServiceConfig): StorageFileInitializeFromUploadService;
@@ -8,6 +8,10 @@ import { type Maybe, type Milliseconds, type ArrayOrValue } from '@dereekb/util'
8
8
  * If a Date, the StorageFile will be queued for deletion at the specified date.
9
9
  */
10
10
  export type StorageFileQueueForDeleteTime = true | Milliseconds | Date;
11
+ /**
12
+ * Input for {@link queryAndFlagStorageFilesForDelete}, specifying the query constraints,
13
+ * collection, deletion timing, and optional keys to skip.
14
+ */
11
15
  export interface QueryAndFlagStorageFilesForDeleteInput {
12
16
  readonly storageFileCollection: StorageFileFirestoreCollection;
13
17
  readonly constraints: FirestoreQueryConstraint[];
@@ -17,6 +21,10 @@ export interface QueryAndFlagStorageFilesForDeleteInput {
17
21
  */
18
22
  readonly skipDeleteForKeys?: ArrayOrValue<StorageFileKey>;
19
23
  }
24
+ /**
25
+ * Result of {@link queryAndFlagStorageFilesForDelete}, reporting how many files were visited
26
+ * and how many were actually flagged for deletion.
27
+ */
20
28
  export interface QueryAndFlagStorageFilesForDeleteResult {
21
29
  readonly visitedCount: number;
22
30
  readonly queuedForDeleteCount: number;
@@ -0,0 +1 @@
1
+ exports._default = require('./index.cjs.js').default;