@dereekb/firebase-server 13.2.1 → 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.
- package/index.cjs.js +7506 -1884
- package/index.esm.js +7505 -1890
- package/mailgun/index.cjs.js +333 -31
- package/mailgun/index.esm.js +333 -31
- package/mailgun/package.json +8 -8
- package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
- package/model/index.cjs.js +11334 -3830
- package/model/index.esm.js +11338 -3834
- package/model/package.json +8 -8
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
- package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
- package/model/src/lib/notification/notification.action.service.d.ts +151 -2
- package/model/src/lib/notification/notification.config.d.ts +19 -7
- package/model/src/lib/notification/notification.config.service.d.ts +44 -6
- package/model/src/lib/notification/notification.create.run.d.ts +33 -5
- package/model/src/lib/notification/notification.error.d.ts +63 -0
- package/model/src/lib/notification/notification.module.d.ts +11 -0
- package/model/src/lib/notification/notification.send.d.ts +8 -1
- package/model/src/lib/notification/notification.send.service.d.ts +7 -1
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
- package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
- package/model/src/lib/notification/notification.task.service.d.ts +13 -1
- package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
- package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
- package/model/src/lib/notification/notification.util.d.ts +70 -0
- package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
- package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
- package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
- package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
- package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
- package/oidc/index.cjs.default.js +1 -0
- package/oidc/index.cjs.js +5607 -0
- package/oidc/index.cjs.mjs +2 -0
- package/oidc/index.d.ts +1 -0
- package/oidc/index.esm.js +5560 -0
- package/oidc/package.json +26 -0
- package/oidc/src/index.d.ts +1 -0
- package/oidc/src/lib/controller/index.d.ts +3 -0
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
- package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
- package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
- package/oidc/src/lib/index.d.ts +6 -0
- package/oidc/src/lib/middleware/index.d.ts +3 -0
- package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
- package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
- package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
- package/oidc/src/lib/model/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/index.d.ts +3 -0
- package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
- package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
- package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
- package/oidc/src/lib/model/model.d.ts +12 -0
- package/oidc/src/lib/model/oidc/index.d.ts +2 -0
- package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
- package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
- package/oidc/src/lib/oidc.config.d.ts +175 -0
- package/oidc/src/lib/oidc.module.d.ts +100 -0
- package/oidc/src/lib/service/index.d.ts +10 -0
- package/oidc/src/lib/service/oidc.account.d.ts +36 -0
- package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
- package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
- package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
- package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
- package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
- package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
- package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
- package/oidc/src/lib/service/oidc.service.d.ts +55 -0
- package/package.json +15 -9
- package/src/lib/auth/auth.context.d.ts +22 -2
- package/src/lib/auth/auth.service.d.ts +5 -0
- package/src/lib/auth/auth.service.error.d.ts +2 -1
- package/src/lib/auth/auth.util.d.ts +15 -3
- package/src/lib/env/env.config.d.ts +42 -0
- package/src/lib/env/env.service.d.ts +17 -0
- package/src/lib/env/index.d.ts +1 -0
- package/src/lib/firestore/array.d.ts +11 -3
- package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
- package/src/lib/firestore/driver.accessor.d.ts +43 -0
- package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
- package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
- package/src/lib/firestore/driver.d.ts +14 -0
- package/src/lib/firestore/driver.query.d.ts +25 -0
- package/src/lib/firestore/increment.d.ts +13 -3
- package/src/lib/firestore/snapshot/index.d.ts +1 -1
- package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
- package/src/lib/function/assert.d.ts +32 -16
- package/src/lib/function/context.d.ts +26 -0
- package/src/lib/function/error.auth.d.ts +15 -0
- package/src/lib/function/error.d.ts +68 -4
- package/src/lib/nest/app.d.ts +53 -9
- package/src/lib/nest/app.module.d.ts +90 -0
- package/src/lib/nest/auth/auth.module.d.ts +30 -4
- package/src/lib/nest/auth/auth.util.d.ts +38 -0
- package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
- package/src/lib/nest/controller/index.d.ts +1 -0
- package/src/lib/nest/development/development.app.function.d.ts +45 -0
- package/src/lib/nest/development/development.assert.function.d.ts +19 -1
- package/src/lib/nest/development/development.function.d.ts +42 -3
- package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
- package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
- package/src/lib/nest/env/env.service.d.ts +9 -0
- package/src/lib/nest/env/env.util.d.ts +16 -0
- package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
- package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
- package/src/lib/nest/function/call.d.ts +75 -6
- package/src/lib/nest/function/context.d.ts +85 -2
- package/src/lib/nest/function/nest.d.ts +46 -0
- package/src/lib/nest/function/schedule.d.ts +49 -0
- package/src/lib/nest/function/v2/blocking.d.ts +92 -8
- package/src/lib/nest/function/v2/call.d.ts +38 -8
- package/src/lib/nest/function/v2/event.d.ts +67 -4
- package/src/lib/nest/function/v2/schedule.d.ts +36 -5
- package/src/lib/nest/index.d.ts +3 -0
- package/src/lib/nest/middleware/appcheck.d.ts +5 -0
- package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
- package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
- package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
- package/src/lib/nest/middleware/index.d.ts +2 -1
- package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
- package/src/lib/nest/model/call.model.function.d.ts +69 -3
- package/src/lib/nest/model/create.model.function.d.ts +66 -0
- package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
- package/src/lib/nest/model/delete.model.function.d.ts +55 -0
- package/src/lib/nest/model/permission.error.d.ts +15 -0
- package/src/lib/nest/model/read.model.function.d.ts +57 -0
- package/src/lib/nest/model/specifier.function.d.ts +58 -1
- package/src/lib/nest/model/update.model.function.d.ts +58 -0
- package/src/lib/nest/nest.provider.d.ts +24 -11
- package/src/lib/nest/nest.provider.server.d.ts +12 -0
- package/src/lib/nest/storage/storage.module.d.ts +30 -4
- package/src/lib/storage/driver.accessor.d.ts +33 -0
- package/src/lib/storage/driver.d.ts +14 -0
- package/src/lib/storage/storage.d.ts +11 -4
- package/src/lib/storage/storage.service.d.ts +10 -1
- package/src/lib/type.d.ts +7 -2
- package/test/index.cjs.js +4072 -757
- package/test/index.esm.js +4073 -761
- package/test/package.json +8 -8
- package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
- package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
- package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
- package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
- package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
- package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
- package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
- package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
- package/test/src/lib/firebase/firebase.d.ts +57 -2
- package/test/src/lib/firebase/firebase.function.d.ts +138 -0
- package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
- package/test/src/lib/firestore/firestore.d.ts +30 -0
- package/test/src/lib/storage/storage.admin.d.ts +9 -3
- package/test/src/lib/storage/storage.d.ts +30 -0
- package/zoho/index.cjs.js +406 -73
- package/zoho/index.esm.js +406 -73
- package/zoho/package.json +8 -8
- package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
- package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
- /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
|
@@ -1,11 +1,74 @@
|
|
|
1
1
|
import { type FirestoreModelKey, type FirebaseAuthUserId } from '@dereekb/firebase';
|
|
2
|
+
/**
|
|
3
|
+
* Creates an error indicating that a required notification ID was missing during creation.
|
|
4
|
+
*
|
|
5
|
+
* Thrown when attempting to create a {@link Notification} document without providing the mandatory ID field.
|
|
6
|
+
*/
|
|
2
7
|
export declare function createNotificationIdRequiredError(): import("firebase-functions/https").HttpsError;
|
|
8
|
+
/**
|
|
9
|
+
* Creates an error indicating that a notification model (box or summary) has already been initialized.
|
|
10
|
+
*
|
|
11
|
+
* Thrown during initialization when `throwErrorIfAlreadyInitialized` is true and the model's
|
|
12
|
+
* setup flag (`s`) indicates it was previously initialized.
|
|
13
|
+
*/
|
|
3
14
|
export declare function notificationModelAlreadyInitializedError(): import("firebase-functions/https").HttpsError;
|
|
15
|
+
/**
|
|
16
|
+
* Creates an error indicating that a {@link NotificationBox} is associated with an unregistered model type.
|
|
17
|
+
*
|
|
18
|
+
* Thrown when the model key's collection name does not match any registered notification model type.
|
|
19
|
+
*
|
|
20
|
+
* @param key - the Firestore model key that has no registered notification model type
|
|
21
|
+
*/
|
|
4
22
|
export declare function notificationBoxUnregistredModelTypeInitializationError(key: FirestoreModelKey): import("firebase-functions/https").HttpsError;
|
|
23
|
+
/**
|
|
24
|
+
* Creates an error indicating that no {@link NotificationBox} exists for the target model.
|
|
25
|
+
*
|
|
26
|
+
* Thrown when an operation requires a NotificationBox but none has been created for the given model key.
|
|
27
|
+
*/
|
|
5
28
|
export declare function notificationBoxDoesNotExist(): import("firebase-functions/https").HttpsError;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an error indicating that the exclusion target is invalid.
|
|
31
|
+
*
|
|
32
|
+
* Thrown when the target recipient on the {@link NotificationBox} does not exist on the box
|
|
33
|
+
* or does not have a UID, making it ineligible for exclusion.
|
|
34
|
+
*/
|
|
6
35
|
export declare function notificationBoxExclusionTargetInvalidError(): import("firebase-functions/https").HttpsError;
|
|
36
|
+
/**
|
|
37
|
+
* Creates an error indicating that a {@link NotificationBox} already exists for this model.
|
|
38
|
+
*
|
|
39
|
+
* Thrown when attempting to create a duplicate NotificationBox for a model that already has one.
|
|
40
|
+
*/
|
|
7
41
|
export declare function notificationBoxExistsForModelError(): import("firebase-functions/https").HttpsError;
|
|
42
|
+
/**
|
|
43
|
+
* Creates an error indicating that the target recipient does not exist on the {@link NotificationBox}.
|
|
44
|
+
*
|
|
45
|
+
* Thrown when attempting to update a recipient that is not registered on the box
|
|
46
|
+
* and `insert=true` was not passed to allow creating a new recipient entry.
|
|
47
|
+
*/
|
|
8
48
|
export declare function notificationBoxRecipientDoesNotExistsError(): import("firebase-functions/https").HttpsError;
|
|
49
|
+
/**
|
|
50
|
+
* Creates an error indicating that the given UID does not correspond to an existing Firebase Auth user.
|
|
51
|
+
*
|
|
52
|
+
* Thrown during {@link NotificationUser} creation when the provided UID cannot be found in Firebase Auth.
|
|
53
|
+
*
|
|
54
|
+
* @param uid - the Firebase Auth user ID that was not found
|
|
55
|
+
*/
|
|
9
56
|
export declare function notificationUserInvalidUidForCreateError(uid: FirebaseAuthUserId): import("firebase-functions/https").HttpsError;
|
|
57
|
+
/**
|
|
58
|
+
* Creates an error indicating that the user has blocked themselves from being added as a recipient.
|
|
59
|
+
*
|
|
60
|
+
* Thrown when a {@link NotificationUser} has the `bk` (blocked-from-add) flag set on their config
|
|
61
|
+
* and an operation attempts to insert them into a {@link NotificationBox}'s recipient list.
|
|
62
|
+
*
|
|
63
|
+
* @param uid - the Firebase Auth user ID of the blocked user
|
|
64
|
+
*/
|
|
10
65
|
export declare function notificationUserBlockedFromBeingAddedToRecipientsError(uid: FirebaseAuthUserId): import("firebase-functions/https").HttpsError;
|
|
66
|
+
/**
|
|
67
|
+
* Creates an error indicating that the user has locked their notification configuration from external updates.
|
|
68
|
+
*
|
|
69
|
+
* Thrown when a {@link NotificationUser} has the `lk` (locked) flag set on their config
|
|
70
|
+
* and an operation attempts to modify their recipient settings on a {@link NotificationBox}.
|
|
71
|
+
*
|
|
72
|
+
* @param uid - the Firebase Auth user ID of the locked user
|
|
73
|
+
*/
|
|
11
74
|
export declare function notificationUserLockedConfigFromBeingUpdatedError(uid: FirebaseAuthUserId): import("firebase-functions/https").HttpsError;
|
|
@@ -6,6 +6,10 @@ import { type Maybe } from '@dereekb/util';
|
|
|
6
6
|
import { NotificationSendService } from './notification.send.service';
|
|
7
7
|
import { NotificationTaskService } from './notification.task.service';
|
|
8
8
|
import { MutableNotificationExpediteService, NotificationExpediteService } from './notification.expedite.service';
|
|
9
|
+
/**
|
|
10
|
+
* Factory that assembles the full {@link NotificationServerActionsContext} by combining
|
|
11
|
+
* the base context with the template, send, task, and expedite services.
|
|
12
|
+
*/
|
|
9
13
|
export declare function notificationServerActionsContextFactory(context: BaseNotificationServerActionsContext, notificationTemplateService: NotificationTemplateService, notificationSendService: NotificationSendService, notificationTaskService: NotificationTaskService, notificationsExpediteService: NotificationExpediteService): {
|
|
10
14
|
notificationTemplateService: NotificationTemplateService;
|
|
11
15
|
notificationSendService: NotificationSendService;
|
|
@@ -23,7 +27,14 @@ export declare function notificationServerActionsContextFactory(context: BaseNot
|
|
|
23
27
|
authService: import("dist/packages/firebase-server/src").FirebaseServerAuthService<import("dist/packages/firebase-server/src").FirebaseServerAuthUserContext, import("dist/packages/firebase-server/src").FirebaseServerAuthContext<import("dist/packages/firebase-server/src").FirebaseServerAuthUserContext>>;
|
|
24
28
|
firestoreContext: import("@dereekb/firebase").FirestoreContext<import("@dereekb/firebase").Firestore>;
|
|
25
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Factory that creates a {@link NotificationServerActions} instance from the assembled context.
|
|
32
|
+
*/
|
|
26
33
|
export declare function notificationServerActionsFactory(context: NotificationServerActionsContext, mutableNotificationExpediteService: MutableNotificationExpediteService): NotificationServerActions;
|
|
34
|
+
/**
|
|
35
|
+
* Factory that creates a {@link NotificationInitServerActions} instance by merging the
|
|
36
|
+
* server actions context with the init-specific configuration.
|
|
37
|
+
*/
|
|
27
38
|
export declare function notificationInitServerActionsFactory(context: NotificationServerActionsContext, notificationInitServerActionsContextConfig: NotificationInitServerActionsContextConfig): NotificationInitServerActions;
|
|
28
39
|
export interface ProvideAppNotificationMetadataConfig extends Pick<ModuleMetadata, 'imports' | 'exports' | 'providers'> {
|
|
29
40
|
/**
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A function that
|
|
2
|
+
* A pre-configured function that sends notification messages through a specific channel (email, SMS, or summary)
|
|
3
|
+
* and returns the channel-specific result.
|
|
4
|
+
*
|
|
5
|
+
* Created by the `buildSendInstance*` methods on the various send services
|
|
6
|
+
* (e.g., {@link NotificationEmailSendService}, {@link NotificationTextSendService}).
|
|
7
|
+
* The messages and routing are captured at build time, so calling the instance simply triggers delivery.
|
|
8
|
+
*
|
|
9
|
+
* @template R - the channel-specific result type (e.g., {@link NotificationSendEmailMessagesResult})
|
|
3
10
|
*/
|
|
4
11
|
export type NotificationSendMessagesInstance<R> = () => Promise<R>;
|
|
@@ -8,7 +8,13 @@ export interface NotificationSendServiceRef {
|
|
|
8
8
|
readonly notificationSendService: NotificationSendService;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
11
|
+
* Abstract service that orchestrates notification delivery across multiple channels (email, SMS, notification summaries).
|
|
12
|
+
*
|
|
13
|
+
* Implementations provide the channel-specific send services and optionally a function to derive
|
|
14
|
+
* {@link NotificationSummaryId} values from UIDs for in-app notification storage.
|
|
15
|
+
*
|
|
16
|
+
* Used by {@link NotificationServerActions} during the `sendNotification` flow to build
|
|
17
|
+
* and dispatch messages to all applicable channels.
|
|
12
18
|
*/
|
|
13
19
|
export declare abstract class NotificationSendService {
|
|
14
20
|
/**
|
|
@@ -2,17 +2,47 @@ import { type NotificationFirestoreCollections, type FirestoreContextReference,
|
|
|
2
2
|
import { type FirebaseServerActionsContext } from '@dereekb/firebase-server';
|
|
3
3
|
import { type NotificationSummarySendService } from './notification.send.service';
|
|
4
4
|
import { type Maybe } from '@dereekb/util';
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for creating a {@link FirestoreNotificationSummarySendService}.
|
|
7
|
+
*/
|
|
5
8
|
export interface FirestoreNotificationSummarySendServiceConfig {
|
|
6
9
|
/**
|
|
7
|
-
* Whether
|
|
10
|
+
* Whether to allow creating new {@link NotificationSummary} documents when one does not exist for a recipient.
|
|
8
11
|
*
|
|
9
12
|
* Defaults to true.
|
|
10
13
|
*/
|
|
11
14
|
readonly allowCreateNotificationSummaries?: Maybe<boolean>;
|
|
15
|
+
/**
|
|
16
|
+
* Server context providing Firestore access, notification collections, and template type info.
|
|
17
|
+
*/
|
|
12
18
|
readonly context: FirebaseServerActionsContext & NotificationFirestoreCollections & FirestoreContextReference & AppNotificationTemplateTypeInfoRecordServiceRef;
|
|
13
19
|
}
|
|
14
20
|
/**
|
|
15
|
-
*
|
|
21
|
+
* Firestore-backed implementation of {@link NotificationSummarySendService} that persists
|
|
22
|
+
* notification items to {@link NotificationSummary} documents in Firestore.
|
|
16
23
|
*/
|
|
17
24
|
export type FirestoreNotificationSummarySendService = NotificationSummarySendService;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a {@link NotificationSummarySendService} that writes notification items to Firestore
|
|
27
|
+
* {@link NotificationSummary} documents.
|
|
28
|
+
*
|
|
29
|
+
* Groups messages by their target {@link NotificationSummaryId}, deduplicates against existing items,
|
|
30
|
+
* appends new items (capped at {@link NOTIFICATION_SUMMARY_ITEM_LIMIT}), and either updates the
|
|
31
|
+
* existing summary or creates a new one (if `allowCreateNotificationSummaries` is enabled).
|
|
32
|
+
*
|
|
33
|
+
* Each summary update runs in a Firestore transaction to prevent concurrent write conflicts.
|
|
34
|
+
*
|
|
35
|
+
* @param config - service configuration including Firestore context and collection references
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const sendService = firestoreNotificationSummarySendService({
|
|
40
|
+
* context: serverActionsContext,
|
|
41
|
+
* allowCreateNotificationSummaries: true
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const sendInstance = await sendService.buildSendInstanceForNotificationSummaryMessages(messages);
|
|
45
|
+
* const result = await sendInstance();
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
18
48
|
export declare function firestoreNotificationSummarySendService(config: FirestoreNotificationSummarySendServiceConfig): FirestoreNotificationSummarySendService;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { type NotificationTextSendService } from './notification.send.service';
|
|
2
2
|
/**
|
|
3
|
-
* NotificationTextSendService that
|
|
3
|
+
* Creates a no-op {@link NotificationTextSendService} that marks all messages as ignored
|
|
4
|
+
* without actually sending any SMS.
|
|
4
5
|
*
|
|
5
|
-
*
|
|
6
|
+
* Useful as a placeholder when your app's notification pipeline is fully wired for SMS
|
|
7
|
+
* but actual delivery is not yet enabled, avoiding the need for conditional logic elsewhere.
|
|
6
8
|
*
|
|
7
|
-
* @
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const textService = ignoreSendNotificationTextSendService();
|
|
12
|
+
* const sendInstance = await textService.buildSendInstanceForTextNotificationMessages(messages);
|
|
13
|
+
* const result = await sendInstance();
|
|
14
|
+
* // result.ignored contains all phone numbers; result.success and result.failed are empty
|
|
15
|
+
* ```
|
|
8
16
|
*/
|
|
9
17
|
export declare function ignoreSendNotificationTextSendService(): NotificationTextSendService;
|
|
@@ -7,7 +7,13 @@ export interface NotificationTaskServiceRef {
|
|
|
7
7
|
readonly notificationTaskService: NotificationTaskService;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Abstract service that dispatches {@link NotificationTask} instances to the appropriate
|
|
11
|
+
* {@link NotificationTaskServiceTaskHandler} based on the task's type.
|
|
12
|
+
*
|
|
13
|
+
* Implementations register handlers for each known {@link NotificationTaskType} and route
|
|
14
|
+
* incoming tasks during the notification send pipeline's task-processing phase.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link notificationTaskService} for the default implementation.
|
|
11
17
|
*/
|
|
12
18
|
export declare abstract class NotificationTaskService {
|
|
13
19
|
/**
|
|
@@ -19,6 +25,12 @@ export declare abstract class NotificationTaskService {
|
|
|
19
25
|
*/
|
|
20
26
|
abstract taskHandlerForNotificationTaskType(notificationTaskType: NotificationTaskType): Maybe<NotificationTaskServiceTaskHandler>;
|
|
21
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Function that processes a single {@link NotificationTask} and returns a result describing
|
|
30
|
+
* the completion state, any checkpoint progress, and optional metadata updates.
|
|
31
|
+
*
|
|
32
|
+
* @template D - the task's metadata type
|
|
33
|
+
*/
|
|
22
34
|
export type NotificationTaskServiceTaskHandlerFunction<D extends NotificationItemMetadata = {}> = (notificationTask: NotificationTask<D>) => Promise<NotificationTaskServiceHandleNotificationTaskResult<D>>;
|
|
23
35
|
/**
|
|
24
36
|
* Service dedicated to handling NotificationTask values.
|
|
@@ -26,17 +26,41 @@ export interface NotificationTaskServiceTaskHandlerConfig<D extends Notification
|
|
|
26
26
|
*/
|
|
27
27
|
readonly allowRunMultipleParts?: boolean;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for creating a {@link NotificationTaskService} via {@link notificationTaskService}.
|
|
31
|
+
*/
|
|
29
32
|
export interface NotificationTaskServiceConfig {
|
|
30
33
|
/**
|
|
31
|
-
* List of
|
|
34
|
+
* List of expected {@link NotificationTaskType} values, used to verify all types have registered handlers.
|
|
32
35
|
*/
|
|
33
36
|
readonly validate?: NotificationTaskType[];
|
|
34
37
|
/**
|
|
35
|
-
*
|
|
38
|
+
* Handler configurations that define the checkpoint-based flow for each task type.
|
|
36
39
|
*/
|
|
37
40
|
readonly handlers: NotificationTaskServiceTaskHandlerConfig<any, any>[];
|
|
38
41
|
}
|
|
39
42
|
/**
|
|
40
|
-
*
|
|
43
|
+
* Creates a {@link NotificationTaskService} from the provided handler configurations.
|
|
44
|
+
*
|
|
45
|
+
* Each handler defines a checkpoint-based flow: when a task is dispatched, the service
|
|
46
|
+
* finds the next uncompleted checkpoint in the flow and executes its handler function.
|
|
47
|
+
* If all checkpoints are complete, the task is marked as done.
|
|
48
|
+
*
|
|
49
|
+
* @param config - handler configurations and optional validation list
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* const taskService = notificationTaskService({
|
|
54
|
+
* handlers: [
|
|
55
|
+
* {
|
|
56
|
+
* type: 'process_file',
|
|
57
|
+
* flow: [
|
|
58
|
+
* { checkpoint: 'validate', fn: validateTask },
|
|
59
|
+
* { checkpoint: 'execute', fn: executeTask }
|
|
60
|
+
* ]
|
|
61
|
+
* }
|
|
62
|
+
* ]
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
41
65
|
*/
|
|
42
66
|
export declare function notificationTaskService(config: NotificationTaskServiceConfig): NotificationTaskService;
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { type NotificationTaskCheckpointString, type NotificationTaskServiceHandleNotificationTaskResult } from '@dereekb/firebase';
|
|
2
2
|
/**
|
|
3
|
-
* Removes
|
|
3
|
+
* Removes checkpoints from the completions array based on the task handler result's removal instructions.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* If `removeAllCompletedCheckpoints` is true, returns an empty array (resets all progress).
|
|
6
|
+
* If `removeFromCompletedCheckpoints` is set, removes only those specific checkpoints.
|
|
7
|
+
* Otherwise, returns the original array unchanged.
|
|
8
|
+
*
|
|
9
|
+
* @param inputCompletions - the current list of completed checkpoint strings
|
|
10
|
+
* @param handleTaskResult - the handler result containing removal instructions
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const remaining = removeFromCompletionsArrayWithTaskResult(
|
|
15
|
+
* ['validate', 'process', 'cleanup'],
|
|
16
|
+
* { removeFromCompletedCheckpoints: ['process'] }
|
|
17
|
+
* );
|
|
18
|
+
* // remaining === ['validate', 'cleanup']
|
|
19
|
+
* ```
|
|
8
20
|
*/
|
|
9
21
|
export declare function removeFromCompletionsArrayWithTaskResult<S extends NotificationTaskCheckpointString = NotificationTaskCheckpointString>(inputCompletions: S[], handleTaskResult: Pick<NotificationTaskServiceHandleNotificationTaskResult<any, S>, 'removeAllCompletedCheckpoints' | 'removeFromCompletedCheckpoints'>): S[];
|
|
@@ -205,7 +205,37 @@ export interface NotificationTaskSubtaskNotificationTaskHandlerConfig<I extends
|
|
|
205
205
|
readonly defaultAllowRunMultipleParts?: Maybe<boolean>;
|
|
206
206
|
}
|
|
207
207
|
/**
|
|
208
|
-
* Creates a
|
|
208
|
+
* Creates a reusable factory for building {@link NotificationTaskServiceTaskHandlerConfig} entries
|
|
209
|
+
* that implement the subtask processing pattern.
|
|
210
|
+
*
|
|
211
|
+
* The returned factory accepts a {@link NotificationTaskSubtaskNotificationTaskHandlerConfig}
|
|
212
|
+
* (per-app processors and their flows) and produces a handler config with two built-in checkpoints:
|
|
213
|
+
*
|
|
214
|
+
* 1. **Processing** — dispatches to the target-specific processor's subtask flow, advancing through
|
|
215
|
+
* subtask checkpoints until all are complete.
|
|
216
|
+
* 2. **Cleanup** — runs the cleanup function, with retry logic if cleanup fails (up to `maxCleanupRetryAttempts`).
|
|
217
|
+
*
|
|
218
|
+
* This is the primary entry point for building complex, multi-step notification task handlers
|
|
219
|
+
* such as storage file processing or other async workflows.
|
|
220
|
+
*
|
|
221
|
+
* @param factoryConfig - shared configuration including the input function, cleanup logic, and task type
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* ```ts
|
|
225
|
+
* const createHandler = notificationTaskSubtaskNotificationTaskHandlerFactory({
|
|
226
|
+
* taskType: 'process_upload',
|
|
227
|
+
* subtaskHandlerFunctionName: 'processUploadHandler',
|
|
228
|
+
* inputFunction: buildInputFromTask,
|
|
229
|
+
* defaultCleanup: defaultCleanupFn,
|
|
230
|
+
* cleanupFunction: cleanupFn
|
|
231
|
+
* });
|
|
232
|
+
*
|
|
233
|
+
* const handlerConfig = createHandler({
|
|
234
|
+
* processors: [
|
|
235
|
+
* { target: 'image', flow: [{ subtask: 'resize', fn: resizeImage }] }
|
|
236
|
+
* ]
|
|
237
|
+
* });
|
|
238
|
+
* ```
|
|
209
239
|
*/
|
|
210
240
|
export declare function notificationTaskSubtaskNotificationTaskHandlerFactory<I extends NotificationTaskSubtaskInput<D, M, S>, CUI extends NotificationTaskSubtaskCleanupInstructions, D extends NotificationTaskSubtaskData<M, S>, M extends NotificationTaskSubtaskMetadata = any, S extends NotificationTaskSubtaskCheckpointString = NotificationTaskSubtaskCheckpointString>(factoryConfig: NotificationTaskSubtaskNotificationTaskHandlerFactoryConfig<I, CUI, D, M, S>): NotificationTaskSubtaskNotificationTaskHandlerFactory<I, CUI, D, M, S>;
|
|
211
241
|
/**
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { type Notification, type NotificationBox, type NotificationBoxRecipient, type NotificationBoxRecipientTemplateConfig, NotificationRecipientSendFlag, type NotificationRecipientWithConfig, type FirebaseAuthDetails, type FirebaseAuthUserId, type NotificationSummaryId, type NotificationBoxId, type NotificationUser, type NotificationUserNotificationBoxRecipientConfig, type NotificationUserId, type FirestoreDocumentAccessor, type NotificationUserDocument, type NotificationUserDefaultNotificationBoxRecipientConfig, type NotificationSummaryIdForUidFunction, type NotificationSummary, type DocumentDataWithIdAndKey } from '@dereekb/firebase';
|
|
2
2
|
import { type FirebaseServerAuthService } from '@dereekb/firebase-server';
|
|
3
3
|
import { type E164PhoneNumber, type EmailAddress, type Maybe, type PhoneNumber, type ModelKey } from '@dereekb/util';
|
|
4
|
+
/**
|
|
5
|
+
* Creates a blank {@link NotificationSummary} template for a newly initialized model.
|
|
6
|
+
*
|
|
7
|
+
* Sets the creation timestamp to now, associates the summary with the given model key,
|
|
8
|
+
* and initializes with an empty notifications array.
|
|
9
|
+
*
|
|
10
|
+
* @param model - the model key to associate the summary with
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const template = makeNewNotificationSummaryTemplate('projects/abc');
|
|
15
|
+
* // template.m === 'projects/abc', template.n === []
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
4
18
|
export declare function makeNewNotificationSummaryTemplate(model: ModelKey): NotificationSummary;
|
|
19
|
+
/**
|
|
20
|
+
* Input for {@link expandNotificationRecipients}, providing the notification, its associated box,
|
|
21
|
+
* auth service for user lookup, and configuration for recipient filtering.
|
|
22
|
+
*/
|
|
5
23
|
export interface ExpandNotificationRecipientsInput {
|
|
6
24
|
readonly notification: Notification;
|
|
7
25
|
readonly notificationBox?: Maybe<DocumentDataWithIdAndKey<NotificationBox>>;
|
|
@@ -37,10 +55,17 @@ export interface ExpandNotificationRecipientsInput {
|
|
|
37
55
|
*/
|
|
38
56
|
readonly onlyTextExplicitlyEnabledRecipients?: Maybe<boolean>;
|
|
39
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* A resolved recipient paired with their effective template configuration for a specific notification type.
|
|
60
|
+
*/
|
|
40
61
|
export interface ExpandedNotificationRecipientConfig {
|
|
41
62
|
readonly recipient: Omit<NotificationBoxRecipient, 'i'>;
|
|
42
63
|
readonly effectiveTemplateConfig?: Maybe<NotificationBoxRecipientTemplateConfig>;
|
|
43
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Base shape for an expanded recipient, containing all resolved contact details
|
|
67
|
+
* and their source (box recipient, other user, or explicit/global recipient).
|
|
68
|
+
*/
|
|
44
69
|
export interface ExpandedNotificationRecipientBase {
|
|
45
70
|
readonly name?: Maybe<string>;
|
|
46
71
|
readonly emailAddress?: Maybe<EmailAddress>;
|
|
@@ -58,16 +83,32 @@ export interface ExpandedNotificationRecipientBase {
|
|
|
58
83
|
*/
|
|
59
84
|
readonly otherRecipient?: NotificationRecipientWithConfig;
|
|
60
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* An expanded recipient that has a resolved email address for email channel delivery.
|
|
88
|
+
*/
|
|
61
89
|
export interface ExpandedNotificationRecipientEmail extends ExpandedNotificationRecipientBase {
|
|
62
90
|
readonly emailAddress: EmailAddress;
|
|
63
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* An expanded recipient that has a resolved E.164 phone number for SMS/text channel delivery.
|
|
94
|
+
*/
|
|
64
95
|
export interface ExpandedNotificationRecipientPhone extends ExpandedNotificationRecipientBase {
|
|
65
96
|
readonly phoneNumber: E164PhoneNumber;
|
|
66
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Alias for text/SMS recipients, identical to phone recipients.
|
|
100
|
+
*/
|
|
67
101
|
export type ExpandedNotificationRecipientText = ExpandedNotificationRecipientPhone;
|
|
102
|
+
/**
|
|
103
|
+
* An expanded recipient that has a resolved {@link NotificationSummaryId} for in-app notification summary delivery.
|
|
104
|
+
*/
|
|
68
105
|
export interface ExpandedNotificationNotificationSummaryRecipient extends Pick<ExpandedNotificationRecipientBase, 'name' | 'boxRecipient' | 'otherRecipient'> {
|
|
69
106
|
readonly notificationSummaryId: NotificationSummaryId;
|
|
70
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Internal state built during recipient expansion, exposed for debugging and downstream processing.
|
|
110
|
+
* Contains the user detail map, recipient groupings, opt-out sets, and exclusion tracking.
|
|
111
|
+
*/
|
|
71
112
|
export interface ExpandNotificationRecipientsInternal {
|
|
72
113
|
readonly userDetailsMap: Map<string, FirebaseAuthDetails | undefined>;
|
|
73
114
|
readonly explicitRecipients: NotificationRecipientWithConfig[];
|
|
@@ -84,6 +125,10 @@ export interface ExpandNotificationRecipientsInternal {
|
|
|
84
125
|
readonly nonNotificationBoxUidRecipientConfigs: Map<FirebaseAuthUserId, NotificationRecipientWithConfig>;
|
|
85
126
|
readonly notificationUserRecipientConfigs: Map<NotificationUserId, NotificationUserDefaultNotificationBoxRecipientConfig>;
|
|
86
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Result of {@link expandNotificationRecipients}, containing channel-specific recipient lists
|
|
130
|
+
* (email, text, notification summary) ready for delivery.
|
|
131
|
+
*/
|
|
87
132
|
export interface ExpandNotificationRecipientsResult {
|
|
88
133
|
readonly _internal: ExpandNotificationRecipientsInternal;
|
|
89
134
|
readonly emails: ExpandedNotificationRecipientEmail[];
|
|
@@ -101,6 +146,12 @@ export interface ExpandNotificationRecipientsResult {
|
|
|
101
146
|
* @returns
|
|
102
147
|
*/
|
|
103
148
|
export declare function expandNotificationRecipients(input: ExpandNotificationRecipientsInput): Promise<ExpandNotificationRecipientsResult>;
|
|
149
|
+
/**
|
|
150
|
+
* Input for {@link updateNotificationUserNotificationBoxRecipientConfig}.
|
|
151
|
+
*
|
|
152
|
+
* Describes the current state of a recipient's relationship between a {@link NotificationUser}
|
|
153
|
+
* and a specific {@link NotificationBox}, plus the intended change (insert, remove, or update).
|
|
154
|
+
*/
|
|
104
155
|
export interface UpdateNotificationUserNotificationBoxRecipientConfigInput {
|
|
105
156
|
readonly notificationBoxId: NotificationBoxId;
|
|
106
157
|
readonly notificationBoxAssociatedModelKey: ModelKey;
|
|
@@ -122,6 +173,9 @@ export interface UpdateNotificationUserNotificationBoxRecipientConfigInput {
|
|
|
122
173
|
*/
|
|
123
174
|
readonly notificationBoxRecipient: Maybe<NotificationBoxRecipient>;
|
|
124
175
|
}
|
|
176
|
+
/**
|
|
177
|
+
* Result of {@link updateNotificationUserNotificationBoxRecipientConfig}.
|
|
178
|
+
*/
|
|
125
179
|
export interface UpdateNotificationUserNotificationBoxRecipientConfigResult {
|
|
126
180
|
/**
|
|
127
181
|
* New configs array, if changes occured.
|
|
@@ -132,4 +186,20 @@ export interface UpdateNotificationUserNotificationBoxRecipientConfigResult {
|
|
|
132
186
|
*/
|
|
133
187
|
readonly updatedNotificationBoxRecipient: Maybe<NotificationBoxRecipient>;
|
|
134
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* Updates a {@link NotificationUser}'s box-specific recipient configuration (`bc` array)
|
|
191
|
+
* based on the current state of their relationship with a {@link NotificationBox}.
|
|
192
|
+
*
|
|
193
|
+
* Handles three scenarios:
|
|
194
|
+
* - **Remove**: marks the user's box config entry with `rm=true` and clears the index.
|
|
195
|
+
* - **Insert**: merges the incoming recipient data with any existing user preferences, respecting
|
|
196
|
+
* the user's `bk` (blocked-from-add) and `lk` (locked) flags.
|
|
197
|
+
* - **Update**: merges changes from the box recipient, respecting `lk` (locked) and `ns` (needs-sync) flags.
|
|
198
|
+
*
|
|
199
|
+
* Also re-applies send exclusions to the updated config array.
|
|
200
|
+
*
|
|
201
|
+
* @param input - the current state and intended change
|
|
202
|
+
* @throws notificationUserBlockedFromBeingAddedToRecipientsError when inserting a blocked user
|
|
203
|
+
* @throws notificationUserLockedConfigFromBeingUpdatedError when updating a locked user's config
|
|
204
|
+
*/
|
|
135
205
|
export declare function updateNotificationUserNotificationBoxRecipientConfig(input: UpdateNotificationUserNotificationBoxRecipientConfigInput): UpdateNotificationUserNotificationBoxRecipientConfigResult;
|
|
@@ -4,15 +4,24 @@ import { type Maybe } from '@dereekb/util';
|
|
|
4
4
|
import { type TransformAndValidateFunctionResult } from '@dereekb/model';
|
|
5
5
|
import { type InjectionToken } from '@nestjs/common';
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* NestJS injection token for the {@link StorageFileInitServerActionsContextConfig},
|
|
8
|
+
* which provides the template function used during {@link StorageFileGroup} initialization.
|
|
8
9
|
*/
|
|
9
10
|
export declare const STORAGE_FILE_INIT_SERVER_ACTIONS_CONTEXT_CONFIG_TOKEN: InjectionToken;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration providing the template function that determines how {@link StorageFileGroup}
|
|
13
|
+
* documents are initialized for a given Firestore model.
|
|
14
|
+
*/
|
|
10
15
|
export interface StorageFileInitServerActionsContextConfig {
|
|
11
16
|
/**
|
|
12
17
|
* MakeTemplateForStorageFileGroupInitializationFunction used by the system for initializing the StorageFileGroups for models.
|
|
13
18
|
*/
|
|
14
19
|
readonly makeTemplateForStorageFileGroupInitialization: MakeTemplateForStorageFileGroupInitializationFunction;
|
|
15
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* Input passed to the template function during storage file model initialization,
|
|
23
|
+
* providing the Firestore transaction context and the model identity being initialized.
|
|
24
|
+
*/
|
|
16
25
|
export interface MakeTemplateForStorageFileRelatedModelInitializationFunctionInput {
|
|
17
26
|
readonly transaction: Transaction;
|
|
18
27
|
readonly flatModelKey: TwoWayFlatFirestoreModelKey;
|
|
@@ -36,13 +45,35 @@ export type MakeTemplateForStorageFileRelatedModelInitializationFunction<T> = (i
|
|
|
36
45
|
* Used for initializing a StorageFileGroup.
|
|
37
46
|
*/
|
|
38
47
|
export type MakeTemplateForStorageFileGroupInitializationFunction = MakeTemplateForStorageFileRelatedModelInitializationFunction<Pick<StorageFileGroup, 'o'> & StorageFileGroupContentFlagsData>;
|
|
48
|
+
/**
|
|
49
|
+
* Full context for storage file initialization actions, combining Firebase infrastructure,
|
|
50
|
+
* storage file Firestore collections, and the initialization template function.
|
|
51
|
+
*/
|
|
39
52
|
export interface StorageFileInitServerActionsContext extends FirebaseServerActionsContext, StorageFileFirestoreCollections, FirestoreContextReference, StorageFileInitServerActionsContextConfig {
|
|
40
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Abstract service defining initialization actions for storage file models.
|
|
56
|
+
*
|
|
57
|
+
* Provides methods to initialize individual {@link StorageFileGroup} documents
|
|
58
|
+
* or batch-process all uninitialized groups.
|
|
59
|
+
*
|
|
60
|
+
* @see {@link storageFileInitServerActions} for the concrete implementation factory.
|
|
61
|
+
*/
|
|
41
62
|
export declare abstract class StorageFileInitServerActions {
|
|
42
63
|
abstract initializeStorageFileGroup(params: InitializeStorageFileModelParams): AsyncStorageFileGroupUpdateAction<InitializeStorageFileModelParams>;
|
|
43
64
|
abstract initializeAllApplicableStorageFileGroups(params: InitializeAllApplicableStorageFileGroupsParams): Promise<TransformAndValidateFunctionResult<InitializeAllApplicableStorageFileGroupsParams, () => Promise<InitializeAllApplicableStorageFileGroupsResult>>>;
|
|
44
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Creates a concrete {@link StorageFileInitServerActions} implementation by wiring each
|
|
68
|
+
* initialization action to its factory function.
|
|
69
|
+
*
|
|
70
|
+
* @param context - the initialization context with template function and Firestore access
|
|
71
|
+
*/
|
|
45
72
|
export declare function storageFileInitServerActions(context: StorageFileInitServerActionsContext): StorageFileInitServerActions;
|
|
73
|
+
/**
|
|
74
|
+
* Input for {@link initializeStorageFileModelInTransaction}, providing the document,
|
|
75
|
+
* its current data, the template function, and the transaction context.
|
|
76
|
+
*/
|
|
46
77
|
export interface InitializeStorageFileModelInTransactionInput<D extends FirestoreDocument<InitializedStorageFileModel, any>> {
|
|
47
78
|
readonly makeTemplateFunction: MakeTemplateForStorageFileRelatedModelInitializationFunction<FirestoreDocumentData<D>>;
|
|
48
79
|
readonly throwErrorIfAlreadyInitialized?: Maybe<boolean>;
|
|
@@ -50,13 +81,43 @@ export interface InitializeStorageFileModelInTransactionInput<D extends Firestor
|
|
|
50
81
|
readonly document: D;
|
|
51
82
|
readonly data: FirestoreDocumentData<D>;
|
|
52
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Initializes a storage file model document (group) within a Firestore transaction.
|
|
86
|
+
*
|
|
87
|
+
* Uses the provided template function to determine the initial state:
|
|
88
|
+
* - Returns a partial template → applies it and marks as initialized (`s=null`)
|
|
89
|
+
* - Returns `null`/`undefined` → marks the model as invalid (`fi=true`)
|
|
90
|
+
* - Returns `false` → deletes the document entirely
|
|
91
|
+
*
|
|
92
|
+
* @param input - the document, transaction, template function, and options
|
|
93
|
+
* @throws storageFileModelAlreadyInitializedError when `throwErrorIfAlreadyInitialized` is true
|
|
94
|
+
*/
|
|
53
95
|
export declare function initializeStorageFileModelInTransaction<D extends FirestoreDocument<InitializedStorageFileModel, any>>(input: InitializeStorageFileModelInTransactionInput<D>): Promise<{
|
|
54
96
|
initialized: boolean;
|
|
55
97
|
alreadyInitialized: boolean;
|
|
56
98
|
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Factory for initializing a single {@link StorageFileGroup} within a Firestore transaction.
|
|
101
|
+
*
|
|
102
|
+
* Applies the app-specific template function, restricting the template to only the `o` (owner)
|
|
103
|
+
* and content flag properties, and always flags the group for content regeneration.
|
|
104
|
+
*/
|
|
57
105
|
export declare function initializeStorageFileGroupInTransactionFactory(context: StorageFileInitServerActionsContext): (params: InitializeStorageFileModelParams, storageFileGroupDocument: StorageFileGroupDocument, transaction: Transaction) => Promise<{
|
|
58
106
|
initialized: boolean;
|
|
59
107
|
alreadyInitialized: boolean;
|
|
60
108
|
}>;
|
|
109
|
+
/**
|
|
110
|
+
* Factory for the `initializeStorageFileGroup` action.
|
|
111
|
+
*
|
|
112
|
+
* Wraps the in-transaction group initialization in a Firestore transaction
|
|
113
|
+
* and follows the transform-and-validate pattern.
|
|
114
|
+
*/
|
|
61
115
|
export declare function initializeStorageFileGroupFactory(context: StorageFileInitServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<InitializeStorageFileModelParams, (storageFileGroupDocument: StorageFileGroupDocument) => Promise<StorageFileGroupDocument>, object, unknown>;
|
|
116
|
+
/**
|
|
117
|
+
* Factory for the `initializeAllApplicableStorageFileGroups` action.
|
|
118
|
+
*
|
|
119
|
+
* Batch-processes all {@link StorageFileGroup} documents flagged for initialization,
|
|
120
|
+
* initializing each in parallel (up to 5 concurrent tasks). Loops until no more
|
|
121
|
+
* flagged groups are found.
|
|
122
|
+
*/
|
|
62
123
|
export declare function initializeAllApplicableStorageFileGroupsFactory(context: StorageFileInitServerActionsContext): import("@dereekb/model").TransformAndValidateFunctionResultFunction<InitializeAllApplicableStorageFileGroupsParams, () => Promise<InitializeAllApplicableStorageFileGroupsResult>, object, unknown>;
|