@dereekb/firebase-server 13.4.0 → 13.4.2
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 +553 -119
- package/index.esm.js +553 -121
- package/mailgun/package.json +9 -9
- package/model/index.cjs.js +645 -350
- package/model/index.esm.js +646 -351
- package/model/package.json +9 -9
- package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +1 -0
- package/model/src/lib/notification/index.d.ts +2 -2
- package/model/src/lib/notification/{notification.action.service.d.ts → notification.action.server.d.ts} +53 -1
- package/model/src/lib/notification/{notification.action.init.service.d.ts → notification.action.server.init.d.ts} +20 -0
- package/model/src/lib/notification/notification.config.service.d.ts +2 -0
- package/model/src/lib/notification/notification.create.run.d.ts +1 -0
- package/model/src/lib/notification/notification.error.d.ts +16 -0
- package/model/src/lib/notification/notification.expedite.service.d.ts +11 -3
- package/model/src/lib/notification/notification.module.d.ts +19 -6
- package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +1 -0
- package/model/src/lib/notification/notification.send.service.text.d.ts +2 -0
- package/model/src/lib/notification/notification.task.service.handler.d.ts +1 -0
- package/model/src/lib/notification/notification.task.service.util.d.ts +1 -0
- package/model/src/lib/notification/notification.task.subtask.handler.d.ts +3 -0
- package/model/src/lib/notification/notification.util.d.ts +4 -2
- package/model/src/lib/storagefile/index.d.ts +1 -1
- package/model/src/lib/storagefile/storagefile.action.server.d.ts +98 -1
- package/model/src/lib/storagefile/{storagefile.action.init.service.d.ts → storagefile.action.server.init.d.ts} +13 -2
- package/model/src/lib/storagefile/storagefile.error.d.ts +27 -0
- package/model/src/lib/storagefile/storagefile.module.d.ts +14 -4
- package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +29 -7
- package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +2 -0
- package/oidc/index.cjs.js +150 -32
- package/oidc/index.esm.js +150 -32
- package/oidc/package.json +10 -10
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +12 -0
- package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +6 -0
- package/oidc/src/lib/model/jwks/jwks.d.ts +9 -0
- package/oidc/src/lib/model/jwks/jwks.query.d.ts +9 -0
- package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +13 -0
- package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +5 -1
- package/oidc/src/lib/oidc.config.d.ts +2 -1
- package/oidc/src/lib/oidc.module.d.ts +9 -2
- package/oidc/src/lib/service/oidc.account.service.d.ts +7 -0
- package/oidc/src/lib/service/oidc.adapter.service.d.ts +1 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +1 -0
- package/oidc/src/lib/service/oidc.encryption.service.d.ts +6 -0
- package/oidc/src/lib/service/oidc.interaction.service.d.ts +15 -0
- package/oidc/src/lib/service/oidc.jwks.service.d.ts +18 -2
- package/oidc/src/lib/service/oidc.service.d.ts +7 -3
- package/package.json +10 -10
- package/src/lib/auth/auth.context.d.ts +1 -0
- package/src/lib/auth/auth.service.d.ts +17 -1
- package/src/lib/auth/auth.service.error.d.ts +46 -0
- package/src/lib/env/env.config.d.ts +2 -0
- package/src/lib/env/env.service.d.ts +21 -7
- package/src/lib/firestore/array.d.ts +1 -0
- package/src/lib/firestore/driver.accessor.batch.d.ts +4 -0
- package/src/lib/firestore/driver.accessor.d.ts +4 -0
- package/src/lib/firestore/driver.accessor.default.d.ts +5 -1
- package/src/lib/firestore/driver.accessor.transaction.d.ts +4 -0
- package/src/lib/firestore/driver.d.ts +2 -0
- package/src/lib/firestore/driver.query.d.ts +4 -0
- package/src/lib/firestore/increment.d.ts +1 -0
- package/src/lib/function/assert.d.ts +7 -0
- package/src/lib/function/context.d.ts +4 -0
- package/src/lib/function/error.auth.d.ts +2 -0
- package/src/lib/function/error.d.ts +86 -11
- package/src/lib/index.d.ts +0 -1
- package/src/lib/nest/analytics/analytics.service.listener.d.ts +2 -0
- package/src/lib/nest/app.d.ts +6 -3
- package/src/lib/nest/auth/auth.module.d.ts +6 -0
- package/src/lib/nest/auth/auth.util.d.ts +19 -1
- package/src/lib/nest/development/development.app.function.d.ts +12 -4
- package/src/lib/nest/development/development.assert.function.d.ts +6 -2
- package/src/lib/nest/development/development.function.d.ts +6 -1
- package/src/lib/nest/development/development.schedule.function.d.ts +3 -1
- package/src/lib/nest/development/development.schedule.function.error.d.ts +8 -0
- package/src/lib/nest/env/env.service.d.ts +2 -0
- package/src/lib/nest/env/env.util.d.ts +6 -0
- package/src/lib/nest/firebase/firebase.module.d.ts +1 -0
- package/src/lib/nest/firestore/firestore.module.d.ts +8 -0
- package/src/lib/nest/function/context.d.ts +2 -0
- package/src/lib/nest/model/analytics.details.d.ts +21 -7
- package/src/lib/nest/model/analytics.emit.d.ts +3 -0
- package/src/lib/nest/model/analytics.handler.d.ts +30 -10
- package/src/lib/nest/model/api.details.d.ts +34 -1
- package/src/lib/nest/model/call.model.function.d.ts +20 -4
- package/src/lib/nest/model/create.model.function.d.ts +6 -1
- package/src/lib/nest/model/crud.assert.function.d.ts +12 -4
- package/src/lib/nest/model/delete.model.function.d.ts +6 -1
- package/src/lib/nest/model/permission.error.d.ts +7 -0
- package/src/lib/nest/model/read.model.function.d.ts +6 -1
- package/src/lib/nest/model/specifier.function.d.ts +3 -0
- package/src/lib/nest/model/update.model.function.d.ts +6 -1
- package/src/lib/nest/nest.provider.d.ts +16 -2
- package/src/lib/nest/storage/storage.module.d.ts +9 -0
- package/src/lib/storage/driver.accessor.d.ts +22 -0
- package/src/lib/storage/driver.d.ts +2 -0
- package/src/lib/storage/storage.d.ts +1 -0
- package/test/package.json +10 -10
- package/zoho/index.cjs.js +8 -6
- package/zoho/index.esm.js +8 -6
- package/zoho/package.json +9 -9
- package/zoho/src/lib/zoho.accounts.firebase.d.ts +2 -1
- package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +2 -1
package/model/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mapObjectKeysToLowercase, multiValueMapBuilder, batch, runAsyncTasksForValues, asArray, pushArrayItemsIntoArray, UNSET_INDEX_NUMBER, areEqualPOJOValues, performAsyncTasks, removeValuesAtIndexesFromArrayCopy, takeFront, makeModelMap, computeNextFreeIndexOnSortedValuesFunction, readIndexNumber, asPromise, dateOrMillisecondsToDate, filterOnlyUndefinedValues, iterablesAreSetEquivalent, mapIdentityFunction, makeValuesGroupMap,
|
|
1
|
+
import { mapObjectKeysToLowercase, multiValueMapBuilder, batch, runAsyncTasksForValues, asArray, pushArrayItemsIntoArray, UNSET_INDEX_NUMBER, areEqualPOJOValues, performAsyncTasks, removeValuesAtIndexesFromArrayCopy, takeFront, makeModelMap, computeNextFreeIndexOnSortedValuesFunction, readIndexNumber, asPromise, dateOrMillisecondsToDate, filterOnlyUndefinedValues, iterablesAreSetEquivalent, mapIdentityFunction, makeValuesGroupMap, separateValues, filterMaybeArrayValues, cutStringFunction, takeLast, unique, mergeSlashPaths, ModelRelationUtility, isThrottled, isPast, unixDateTimeSecondsNumberFromDate, slashPathDetails, expirationDetails, MS_IN_MINUTE, dateFromDateOrTimeMillisecondsNumber, cachedGetter, MS_IN_HOUR, documentFileExtensionForMimeType, useCallback, ZIP_FILE_MIME_TYPE, MAP_IDENTITY, pushItemOrArrayItemsIntoArray, asDecisionFunction } from '@dereekb/util';
|
|
2
2
|
import { yearWeekCode, isSameDate, findMaxDate, findMinDate } from '@dereekb/date';
|
|
3
3
|
import { CREATE_NOTIFICATION_ID_REQUIRED_ERROR_CODE, NOTIFICATION_BOX_DOES_NOT_EXIST_ERROR_CODE, NOTIFICATION_BOX_EXCLUSION_TARGET_INVALID_ERROR_CODE, NOTIFICATION_BOX_EXISTS_FOR_MODEL_ERROR_CODE, NOTIFICATION_BOX_RECIPIENT_DOES_NOT_EXIST_ERROR_CODE, NOTIFICATION_MODEL_ALREADY_INITIALIZED_ERROR_CODE, NOTIFICATION_USER_BLOCKED_FROM_BEING_ADD_TO_RECIPIENTS_ERROR_CODE, NOTIFICATION_USER_INVALID_UID_FOR_CREATE_ERROR_CODE, NOTIFICATION_USER_LOCKED_CONFIG_FROM_BEING_UPDATED_ERROR_CODE, firestoreDummyKey, mergeNotificationBoxRecipients, mergeNotificationUserNotificationBoxRecipientConfigs, applyExclusionsToNotificationUserNotificationBoxRecipientConfigs, mergeNotificationBoxRecipientTemplateConfigs, effectiveNotificationBoxRecipientTemplateConfig, notificationSendExclusionCanSendFunction, mergeNotificationUserDefaultNotificationBoxRecipientConfig, DEFAULT_NOTIFICATION_TEMPLATE_TYPE, NotificationRecipientSendFlag, allowedNotificationRecipients, loadDocumentsForIds, getDocumentSnapshotDataPairsWithData, cleanupSentNotificationsParamsType, createNotificationBoxParamsType, createNotificationSummaryParamsType, createNotificationUserParamsType, resyncNotificationUserParamsType, sendNotificationParamsType, sendQueuedNotificationsParamsType, updateNotificationBoxParamsType, updateNotificationBoxRecipientParamsType, updateNotificationSummaryParamsType, updateNotificationUserParamsType, updateNotificationUserDefaultNotificationBoxRecipientConfig, effectiveNotificationBoxRecipientConfig, updateNotificationUserNotificationBoxRecipientConfigs, calculateNsForNotificationUserNotificationBoxRecipientConfigs, getDocumentSnapshotDataPairs, iterateFirestoreDocumentSnapshotPairs, notificationUsersFlaggedForNeedsSyncQuery, notificationSummaryIdForModel, loadNotificationBoxDocumentForReferencePair, updateNotificationUserNotificationSendExclusions, notificationBoxRecipientTemplateConfigArrayToRecord, updateNotificationRecipient, setIdAndKeyFromKeyIdRefOnDocumentData, inferKeyFromTwoWayFlatFirestoreModelKey, NotificationSendType, getDocumentSnapshotData, notificationSendFlagsImplyIsComplete, NotificationSendState, mergeNotificationSendMessagesResult, notificationsPastSendAtTimeQuery, shouldSaveNotificationToNotificationWeek, loadDocumentsForDocumentReferencesFromValues, notificationsReadyForCleanupQuery, initializeAllApplicableNotificationBoxesParamsType, initializeAllApplicableNotificationSummariesParamsType, initializeNotificationModelParamsType, firestoreModelKeyCollectionName, notificationBoxesFlaggedForNeedsInitializationQuery, notificationSummariesFlaggedForNeedsInitializationQuery, noContentNotificationMessageFunctionFactory, _createNotificationDocumentFromPair, createNotificationDocumentPair, NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_SUBJECT_MAX_LENGTH, NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_MESSAGE_MAX_LENGTH, sortNotificationItemsFunction, NOTIFICATION_SUMMARY_ITEM_LIMIT, NOTIFICATION_TASK_SUBTASK_CHECKPOINT_PROCESSING, NOTIFICATION_TASK_SUBTASK_CHECKPOINT_CLEANUP, completeSubtaskProcessingAndScheduleCleanupTaskResult, delayCompletion, notificationTaskComplete, notificationTaskDelayRetry, DEFAULT_NOTIFICATION_TASK_SUBTASK_CLEANUP_RETRY_DELAY, DEFAULT_NOTIFICATION_TASK_SUBTASK_CLEANUP_RETRY_ATTEMPTS, STORAGE_FILE_GROUP_CREATE_INPUT_ERROR_CODE, STORAGE_FILE_ALREADY_PROCESSED_ERROR_CODE, STORAGE_FILE_CANNOT_BE_DELETED_YET_ERROR_CODE, STORAGE_FILE_GROUP_QUEUED_FOR_INITIALIZATION_ERROR_CODE, STORAGE_FILE_MODEL_ALREADY_INITIALIZED_ERROR_CODE, STORAGE_FILE_NOT_FLAGGED_FOR_DELETION_ERROR_CODE, STORAGE_FILE_NOT_FLAGGED_FOR_GROUPS_SYNC_ERROR_CODE, STORAGE_FILE_PROCESSING_NOT_ALLOWED_FOR_INVALID_STATE_ERROR_CODE, STORAGE_FILE_PROCESSING_NOT_AVAILABLE_FOR_TYPE_ERROR_CODE, STORAGE_FILE_PROCESSING_NOT_QUEUED_FOR_PROCESSING_ERROR_CODE, UPLOADED_FILE_DOES_NOT_EXIST_ERROR_CODE, UPLOADED_FILE_INITIALIZATION_DISCARDED_ERROR_CODE, UPLOADED_FILE_INITIALIZATION_FAILED_ERROR_CODE, UPLOADED_FILE_NOT_ALLOWED_TO_BE_INITIALIZED_ERROR_CODE, createStorageFileParamsType, createStorageFileGroupParamsType, deleteAllQueuedStorageFilesParamsType, deleteStorageFileParamsType, downloadStorageFileParamsType, initializeAllStorageFilesFromUploadsParamsType, initializeStorageFileFromUploadParamsType, processAllQueuedStorageFilesParamsType, processStorageFileParamsType, regenerateAllFlaggedStorageFileGroupsContentParamsType, regenerateStorageFileGroupContentParamsType, syncAllFlaggedStorageFilesWithGroupsParamsType, syncStorageFileWithGroupsParamsType, updateStorageFileParamsType, updateStorageFileGroupParamsType, UPLOADS_FOLDER_PATH, iterateStorageListFilesByEachFile, StorageFileProcessingState, storageFilesQueuedForProcessingQuery, STORAGE_FILE_PROCESSING_STUCK_THROTTLE_CHECK_MS, StorageFileState, createNotificationDocument, storageFileProcessingNotificationTaskTemplate, storageFilesQueuedForDeleteQuery, loadStorageFileGroupDocumentForReferencePair, calculateStorageFileGroupEmbeddedFileUpdate, iterateFirestoreDocumentSnapshotPairBatches, storageFileFlaggedForSyncWithGroupsQuery, createStorageFileDocumentPairFactory, StorageFileCreationType, calculateStorageFileGroupRegeneration, storageFileGroupZipFileStoragePath, STORAGE_FILE_GROUP_ZIP_STORAGE_FILE_PURPOSE, getDocumentSnapshotDataPair, storageFileGroupsFlaggedForContentRegenerationQuery, initializeAllApplicableStorageFileGroupsParamsType, initializeStorageFileModelParamsType, storageFileGroupsFlaggedForNeedsInitializationQuery, STORAGE_FILE_GROUP_ZIP_STORAGE_FILE_PURPOSE_CREATE_ZIP_SUBTASK, storedFileReaderFactory, STORAGE_FILE_PROCESSING_NOTIFICATION_TASK_TYPE, copyStoragePath, notificationSubtaskComplete, STORAGE_FILE_GROUP_ZIP_INFO_JSON_FILE_NAME, limitUploadFileTypeDeterminer, combineUploadFileTypeDeterminers, STORAGEFILE_RELATED_FILE_METADATA_KEY, storageFilePurposeAndUserQuery } from '@dereekb/firebase';
|
|
4
4
|
import { preconditionConflictError, assertSnapshotData, internalServerError } from '@dereekb/firebase-server';
|
|
@@ -191,6 +191,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
191
191
|
* and dispatches them through the Mailgun API.
|
|
192
192
|
*
|
|
193
193
|
* @param config - service configuration including the Mailgun service, template builders, and batch size
|
|
194
|
+
* @returns a {@link NotificationEmailSendService} that batches and sends emails through Mailgun
|
|
194
195
|
*
|
|
195
196
|
* @example
|
|
196
197
|
* ```ts
|
|
@@ -245,6 +246,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
245
246
|
var sendTemplateNameToLowercase, builderForKey, input;
|
|
246
247
|
return _ts_generator$f(this, function(_state) {
|
|
247
248
|
sendTemplateNameToLowercase = sendTemplateName.toLowerCase();
|
|
249
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
248
250
|
builderForKey = lowercaseKeysMessageBuilders[sendTemplateNameToLowercase];
|
|
249
251
|
if (!builderForKey) {
|
|
250
252
|
throw new Error('mailgunNotificationEmailSendService(): A template builder was not available for template type "'.concat(sendTemplateName, '".'));
|
|
@@ -323,6 +325,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
323
325
|
* Creates an error indicating that a required notification ID was missing during creation.
|
|
324
326
|
*
|
|
325
327
|
* Thrown when attempting to create a {@link Notification} document without providing the mandatory ID field.
|
|
328
|
+
*
|
|
329
|
+
* @returns a precondition conflict error with the notification ID required error code
|
|
326
330
|
*/ function createNotificationIdRequiredError() {
|
|
327
331
|
return preconditionConflictError({
|
|
328
332
|
message: "The required id was not present when attempting to create a Notification.",
|
|
@@ -334,6 +338,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
334
338
|
*
|
|
335
339
|
* Thrown during initialization when `throwErrorIfAlreadyInitialized` is true and the model's
|
|
336
340
|
* setup flag (`s`) indicates it was previously initialized.
|
|
341
|
+
*
|
|
342
|
+
* @returns a precondition conflict error with the already-initialized error code
|
|
337
343
|
*/ function notificationModelAlreadyInitializedError() {
|
|
338
344
|
return preconditionConflictError({
|
|
339
345
|
message: "This model has already been initialized.",
|
|
@@ -346,6 +352,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
346
352
|
* Thrown when the model key's collection name does not match any registered notification model type.
|
|
347
353
|
*
|
|
348
354
|
* @param key - the Firestore model key that has no registered notification model type
|
|
355
|
+
* @returns a precondition conflict error with the unregistered model type error code
|
|
349
356
|
*/ function notificationBoxUnregistredModelTypeInitializationError(key) {
|
|
350
357
|
return preconditionConflictError({
|
|
351
358
|
message: "This NotificationBox is associated with an unregistered model type.",
|
|
@@ -359,6 +366,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
359
366
|
* Creates an error indicating that no {@link NotificationBox} exists for the target model.
|
|
360
367
|
*
|
|
361
368
|
* Thrown when an operation requires a NotificationBox but none has been created for the given model key.
|
|
369
|
+
*
|
|
370
|
+
* @returns a precondition conflict error with the box-not-found error code
|
|
362
371
|
*/ function notificationBoxDoesNotExist() {
|
|
363
372
|
return preconditionConflictError({
|
|
364
373
|
message: "A NotificationBox does not exist for this model.",
|
|
@@ -370,6 +379,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
370
379
|
*
|
|
371
380
|
* Thrown when the target recipient on the {@link NotificationBox} does not exist on the box
|
|
372
381
|
* or does not have a UID, making it ineligible for exclusion.
|
|
382
|
+
*
|
|
383
|
+
* @returns a precondition conflict error with the invalid exclusion target error code
|
|
373
384
|
*/ function notificationBoxExclusionTargetInvalidError() {
|
|
374
385
|
return preconditionConflictError({
|
|
375
386
|
message: "The target for exclusion is invalid. The target recipient on the NotificationBox must be exist on the NotificationBox and have a uid to be excluded.",
|
|
@@ -380,6 +391,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
380
391
|
* Creates an error indicating that a {@link NotificationBox} already exists for this model.
|
|
381
392
|
*
|
|
382
393
|
* Thrown when attempting to create a duplicate NotificationBox for a model that already has one.
|
|
394
|
+
*
|
|
395
|
+
* @returns a precondition conflict error with the box-exists error code
|
|
383
396
|
*/ function notificationBoxExistsForModelError() {
|
|
384
397
|
return preconditionConflictError({
|
|
385
398
|
message: "A NotificationBox already exists for this model.",
|
|
@@ -391,6 +404,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
391
404
|
*
|
|
392
405
|
* Thrown when attempting to update a recipient that is not registered on the box
|
|
393
406
|
* and `insert=true` was not passed to allow creating a new recipient entry.
|
|
407
|
+
*
|
|
408
|
+
* @returns a precondition conflict error with the recipient-not-found error code
|
|
394
409
|
*/ function notificationBoxRecipientDoesNotExistsError() {
|
|
395
410
|
return preconditionConflictError({
|
|
396
411
|
message: "An existing NotificationBox recipient for the target does not exist. You must pass insert=true to create a new recipient.",
|
|
@@ -403,6 +418,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
403
418
|
* Thrown during {@link NotificationUser} creation when the provided UID cannot be found in Firebase Auth.
|
|
404
419
|
*
|
|
405
420
|
* @param uid - the Firebase Auth user ID that was not found
|
|
421
|
+
* @returns a precondition conflict error with the invalid-uid error code
|
|
406
422
|
*/ function notificationUserInvalidUidForCreateError(uid) {
|
|
407
423
|
return preconditionConflictError({
|
|
408
424
|
message: "The user with the uid '".concat(uid, "' does not exist. Cannot create a NotificationUser for them."),
|
|
@@ -419,6 +435,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
419
435
|
* and an operation attempts to insert them into a {@link NotificationBox}'s recipient list.
|
|
420
436
|
*
|
|
421
437
|
* @param uid - the Firebase Auth user ID of the blocked user
|
|
438
|
+
* @returns a precondition conflict error with the blocked-from-add error code
|
|
422
439
|
*/ function notificationUserBlockedFromBeingAddedToRecipientsError(uid) {
|
|
423
440
|
return preconditionConflictError({
|
|
424
441
|
message: "The user with the uid '".concat(uid, "' has blocked themselves from from being added recipients."),
|
|
@@ -435,6 +452,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
|
|
|
435
452
|
* and an operation attempts to modify their recipient settings on a {@link NotificationBox}.
|
|
436
453
|
*
|
|
437
454
|
* @param uid - the Firebase Auth user ID of the locked user
|
|
455
|
+
* @returns a precondition conflict error with the locked-config error code
|
|
438
456
|
*/ function notificationUserLockedConfigFromBeingUpdatedError(uid) {
|
|
439
457
|
return preconditionConflictError({
|
|
440
458
|
message: "The user with the uid '".concat(uid, "' has locked their config from being updated."),
|
|
@@ -450,7 +468,7 @@ function _array_like_to_array$7(arr, len) {
|
|
|
450
468
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
451
469
|
return arr2;
|
|
452
470
|
}
|
|
453
|
-
function _array_without_holes$
|
|
471
|
+
function _array_without_holes$6(arr) {
|
|
454
472
|
if (Array.isArray(arr)) return _array_like_to_array$7(arr);
|
|
455
473
|
}
|
|
456
474
|
function asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -495,10 +513,10 @@ function _define_property$d(obj, key, value) {
|
|
|
495
513
|
}
|
|
496
514
|
return obj;
|
|
497
515
|
}
|
|
498
|
-
function _iterable_to_array$
|
|
516
|
+
function _iterable_to_array$6(iter) {
|
|
499
517
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
500
518
|
}
|
|
501
|
-
function _non_iterable_spread$
|
|
519
|
+
function _non_iterable_spread$6() {
|
|
502
520
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
503
521
|
}
|
|
504
522
|
function _object_spread$c(target) {
|
|
@@ -535,8 +553,8 @@ function _object_spread_props$b(target, source) {
|
|
|
535
553
|
}
|
|
536
554
|
return target;
|
|
537
555
|
}
|
|
538
|
-
function _to_consumable_array$
|
|
539
|
-
return _array_without_holes$
|
|
556
|
+
function _to_consumable_array$6(arr) {
|
|
557
|
+
return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$6();
|
|
540
558
|
}
|
|
541
559
|
function _unsupported_iterable_to_array$7(o, minLen) {
|
|
542
560
|
if (!o) return;
|
|
@@ -653,6 +671,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
653
671
|
* and initializes with an empty notifications array.
|
|
654
672
|
*
|
|
655
673
|
* @param model - the model key to associate the summary with
|
|
674
|
+
* @returns a blank {@link NotificationSummary} with creation timestamp and empty notifications
|
|
656
675
|
*
|
|
657
676
|
* @example
|
|
658
677
|
* ```ts
|
|
@@ -675,8 +694,8 @@ function _ts_generator$e(thisArg, body) {
|
|
|
675
694
|
*
|
|
676
695
|
* Recipients are each configurable and may be defined with as little info as a single contact info, or have multiple contact info pieces associated with them.
|
|
677
696
|
*
|
|
678
|
-
* @param input
|
|
679
|
-
* @returns
|
|
697
|
+
* @param input - the notification, box, auth service, and recipient configuration
|
|
698
|
+
* @returns channel-specific recipient lists (email, text, notification summary) ready for delivery
|
|
680
699
|
*/ function expandNotificationRecipients(input) {
|
|
681
700
|
return _async_to_generator$e(function() {
|
|
682
701
|
var _ref, notificationUserAccessor, authService, notification, notificationBox, inputGlobalRecipients, recipientFlagOverride, inputNotificationSummaryIdForUid, inputOnlySendToExplicitlyEnabledRecipients, inputOnlyTextExplicitlyEnabledRecipients, notificationBoxId, notificationSummaryIdForUid, notificationTemplateType, recipientFlag, onlyTextExplicitlyEnabledRecipients, onlySendToExplicitlyEnabledRecipients, onlyEmailExplicitlyEnabledRecipients, onlySendNotificationSummaryExplicitlyEnabledRecipients, _allowedNotificationRecipients, canSendToGlobalRecipients, canSendToBoxRecipients, canSendToExplicitRecipients, initialExplicitRecipients, initialGlobalRecipients, explicitRecipients, globalRecipients, explicitAndGlobalRecipients, allBoxRecipientConfigs, recipientUids, relevantBoxRecipientConfigs, nonNotificationBoxUidRecipientConfigs, otherNotificationUserUidOptOuts, otherNotificationUserUidSendExclusions, notificationUserRecipientConfigs, nonNotificationBoxRecipientUids, notificationUserDocuments, notificationUsers, otherRecipientConfigs, explicitOtherRecipientEmailAddresses, explicitOtherRecipientTextNumbers, explicitOtherRecipientNotificationSummaryIds, allUserDetails, userDetailsMap, _internal, emails, emailUidsSet, texts, textUidsSet, notificationSummaries, notificationSummaryKeysSet, notificationSummaryUidsSet, result;
|
|
@@ -702,6 +721,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
702
721
|
onlyTextExplicitlyEnabledRecipients = inputOnlyTextExplicitlyEnabledRecipients !== false; // defaults to true
|
|
703
722
|
onlySendToExplicitlyEnabledRecipients = inputOnlySendToExplicitlyEnabledRecipients === true; // defaults to false
|
|
704
723
|
onlyEmailExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
|
|
724
|
+
// const onlySendPushNotificationExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
|
|
705
725
|
onlySendNotificationSummaryExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
|
|
706
726
|
_allowedNotificationRecipients = allowedNotificationRecipients(recipientFlag), canSendToGlobalRecipients = _allowedNotificationRecipients.canSendToGlobalRecipients, canSendToBoxRecipients = _allowedNotificationRecipients.canSendToBoxRecipients, canSendToExplicitRecipients = _allowedNotificationRecipients.canSendToExplicitRecipients;
|
|
707
727
|
initialExplicitRecipients = canSendToExplicitRecipients ? notification.r : [];
|
|
@@ -712,7 +732,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
712
732
|
globalRecipients = initialGlobalRecipients.map(function(x) {
|
|
713
733
|
return _object_spread$c({}, x, effectiveNotificationBoxRecipientTemplateConfig(x));
|
|
714
734
|
});
|
|
715
|
-
explicitAndGlobalRecipients = _to_consumable_array$
|
|
735
|
+
explicitAndGlobalRecipients = _to_consumable_array$6(explicitRecipients).concat(_to_consumable_array$6(globalRecipients));
|
|
716
736
|
allBoxRecipientConfigs = canSendToBoxRecipients && notificationBox ? notificationBox.r : [];
|
|
717
737
|
recipientUids = new Set();
|
|
718
738
|
relevantBoxRecipientConfigs = [];
|
|
@@ -749,7 +769,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
749
769
|
3,
|
|
750
770
|
2
|
|
751
771
|
];
|
|
752
|
-
nonNotificationBoxRecipientUids =
|
|
772
|
+
nonNotificationBoxRecipientUids = _to_consumable_array$6(nonNotificationBoxUidRecipientConfigs.keys());
|
|
753
773
|
notificationUserDocuments = loadDocumentsForIds(notificationUserAccessor, nonNotificationBoxRecipientUids);
|
|
754
774
|
return [
|
|
755
775
|
4,
|
|
@@ -813,7 +833,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
813
833
|
});
|
|
814
834
|
return [
|
|
815
835
|
4,
|
|
816
|
-
Promise.all(
|
|
836
|
+
Promise.all(_to_consumable_array$6(recipientUids).map(function(uid) {
|
|
817
837
|
return authService.userContext(uid).loadDetails().then(function(details) {
|
|
818
838
|
return [
|
|
819
839
|
uid,
|
|
@@ -1025,17 +1045,15 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1025
1045
|
} else if (x.s) {
|
|
1026
1046
|
notificationSummaryId = x.s;
|
|
1027
1047
|
}
|
|
1028
|
-
if (notificationSummaryId) {
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
explicitOtherRecipientNotificationSummaryIds.delete(notificationSummaryId);
|
|
1038
|
-
}
|
|
1048
|
+
if (notificationSummaryId && !notificationSummaryKeysSet.has(notificationSummaryId)) {
|
|
1049
|
+
var name = displayName || x.n;
|
|
1050
|
+
var notificationSummary = {
|
|
1051
|
+
notificationSummaryId: notificationSummaryId,
|
|
1052
|
+
otherRecipient: x,
|
|
1053
|
+
name: name
|
|
1054
|
+
};
|
|
1055
|
+
notificationSummaries.push(notificationSummary);
|
|
1056
|
+
explicitOtherRecipientNotificationSummaryIds.delete(notificationSummaryId);
|
|
1039
1057
|
}
|
|
1040
1058
|
}
|
|
1041
1059
|
}
|
|
@@ -1080,6 +1098,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1080
1098
|
* Also re-applies send exclusions to the updated config array.
|
|
1081
1099
|
*
|
|
1082
1100
|
* @param input - the current state and intended change
|
|
1101
|
+
* @returns the updated box config array and notification box recipient, if changes occurred
|
|
1083
1102
|
* @throws notificationUserBlockedFromBeingAddedToRecipientsError when inserting a blocked user
|
|
1084
1103
|
* @throws notificationUserLockedConfigFromBeingUpdatedError when updating a locked user's config
|
|
1085
1104
|
*/ function updateNotificationUserNotificationBoxRecipientConfig(input) {
|
|
@@ -1099,7 +1118,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1099
1118
|
// flag as removed in the NotificationUser details if not already flagged as such
|
|
1100
1119
|
if (currentNotificationUserBoxIndexExists && currentNotificationUserBoxConfig.rm !== true) {
|
|
1101
1120
|
var _currentNotificationUserBoxConfig_c;
|
|
1102
|
-
updatedBc = _to_consumable_array$
|
|
1121
|
+
updatedBc = _to_consumable_array$6(notificationUser.bc);
|
|
1103
1122
|
updatedBc[currentNotificationUserBoxIndex] = _object_spread_props$b(_object_spread$c({}, currentNotificationUserBoxConfig), {
|
|
1104
1123
|
nb: notificationBoxId,
|
|
1105
1124
|
c: (_currentNotificationUserBoxConfig_c = currentNotificationUserBoxConfig.c) !== null && _currentNotificationUserBoxConfig_c !== void 0 ? _currentNotificationUserBoxConfig_c : {},
|
|
@@ -1145,7 +1164,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1145
1164
|
nb: notificationBoxId,
|
|
1146
1165
|
rm: false // remove/clear the removed flag
|
|
1147
1166
|
}), updateWithNotificationBoxRecipient);
|
|
1148
|
-
updatedBc = _to_consumable_array$
|
|
1167
|
+
updatedBc = _to_consumable_array$6(notificationUser.bc);
|
|
1149
1168
|
if (currentNotificationUserBoxIndexExists) {
|
|
1150
1169
|
updatedBc[currentNotificationUserBoxIndex] = updatedNotificationUserBoxEntry;
|
|
1151
1170
|
} else {
|
|
@@ -1177,6 +1196,7 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1177
1196
|
*
|
|
1178
1197
|
* @param inputCompletions - the current list of completed checkpoint strings
|
|
1179
1198
|
* @param handleTaskResult - the handler result containing removal instructions
|
|
1199
|
+
* @returns the filtered completions array with specified checkpoints removed
|
|
1180
1200
|
*
|
|
1181
1201
|
* @example
|
|
1182
1202
|
* ```ts
|
|
@@ -1186,7 +1206,8 @@ function _ts_generator$e(thisArg, body) {
|
|
|
1186
1206
|
* );
|
|
1187
1207
|
* // remaining === ['validate', 'cleanup']
|
|
1188
1208
|
* ```
|
|
1189
|
-
*/
|
|
1209
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1210
|
+
function removeFromCompletionsArrayWithTaskResult(inputCompletions, handleTaskResult) {
|
|
1190
1211
|
var removeAllCompletedCheckpoints = handleTaskResult.removeAllCompletedCheckpoints, removeFromCompletedCheckpoints = handleTaskResult.removeFromCompletedCheckpoints;
|
|
1191
1212
|
var result;
|
|
1192
1213
|
if (removeAllCompletedCheckpoints) {
|
|
@@ -1210,7 +1231,7 @@ function _array_like_to_array$6(arr, len) {
|
|
|
1210
1231
|
function _array_with_holes$2(arr) {
|
|
1211
1232
|
if (Array.isArray(arr)) return arr;
|
|
1212
1233
|
}
|
|
1213
|
-
function _array_without_holes$
|
|
1234
|
+
function _array_without_holes$5(arr) {
|
|
1214
1235
|
if (Array.isArray(arr)) return _array_like_to_array$6(arr);
|
|
1215
1236
|
}
|
|
1216
1237
|
function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
|
|
@@ -1260,7 +1281,7 @@ function _define_property$c(obj, key, value) {
|
|
|
1260
1281
|
}
|
|
1261
1282
|
return obj;
|
|
1262
1283
|
}
|
|
1263
|
-
function _iterable_to_array$
|
|
1284
|
+
function _iterable_to_array$5(iter) {
|
|
1264
1285
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
1265
1286
|
}
|
|
1266
1287
|
function _iterable_to_array_limit$2(arr, i) {
|
|
@@ -1290,7 +1311,7 @@ function _iterable_to_array_limit$2(arr, i) {
|
|
|
1290
1311
|
function _non_iterable_rest$2() {
|
|
1291
1312
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1292
1313
|
}
|
|
1293
|
-
function _non_iterable_spread$
|
|
1314
|
+
function _non_iterable_spread$5() {
|
|
1294
1315
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1295
1316
|
}
|
|
1296
1317
|
function _object_spread$b(target) {
|
|
@@ -1330,8 +1351,8 @@ function _object_spread_props$a(target, source) {
|
|
|
1330
1351
|
function _sliced_to_array$2(arr, i) {
|
|
1331
1352
|
return _array_with_holes$2(arr) || _iterable_to_array_limit$2(arr, i) || _unsupported_iterable_to_array$6(arr, i) || _non_iterable_rest$2();
|
|
1332
1353
|
}
|
|
1333
|
-
function _to_consumable_array$
|
|
1334
|
-
return _array_without_holes$
|
|
1354
|
+
function _to_consumable_array$5(arr) {
|
|
1355
|
+
return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$5();
|
|
1335
1356
|
}
|
|
1336
1357
|
function _unsupported_iterable_to_array$6(o, minLen) {
|
|
1337
1358
|
if (!o) return;
|
|
@@ -1472,6 +1493,7 @@ function _ts_generator$d(thisArg, body) {
|
|
|
1472
1493
|
* to its factory function using the provided context.
|
|
1473
1494
|
*
|
|
1474
1495
|
* @param context - the fully assembled notification server actions context
|
|
1496
|
+
* @returns a fully wired {@link NotificationServerActions} instance
|
|
1475
1497
|
*
|
|
1476
1498
|
* @example
|
|
1477
1499
|
* ```ts
|
|
@@ -1501,6 +1523,9 @@ function _ts_generator$d(thisArg, body) {
|
|
|
1501
1523
|
*
|
|
1502
1524
|
* Validates the UID exists in Firebase Auth, then creates a new {@link NotificationUser} document
|
|
1503
1525
|
* with empty default and global configs. Throws if the UID is not found in Auth.
|
|
1526
|
+
*
|
|
1527
|
+
* @param context - the notification server actions context with auth and collection access
|
|
1528
|
+
* @returns a transform-and-validate function that creates a new notification user document
|
|
1504
1529
|
*/ function createNotificationUserFactory(context) {
|
|
1505
1530
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationUserCollection = context.notificationUserCollection, authService = context.authService;
|
|
1506
1531
|
return firebaseServerActionTransformFunctionFactory(createNotificationUserParamsType, function(params) {
|
|
@@ -1565,6 +1590,9 @@ function _ts_generator$d(thisArg, body) {
|
|
|
1565
1590
|
* Updates a {@link NotificationUser}'s default config (`dc`), global config (`gc`), and/or
|
|
1566
1591
|
* box configs (`bc`). When the global config changes, iterates all box configs to propagate
|
|
1567
1592
|
* effective recipient changes and marks affected entries for sync.
|
|
1593
|
+
*
|
|
1594
|
+
* @param context - the notification server actions context with Firestore and collection access
|
|
1595
|
+
* @returns a transform-and-validate function that updates an existing notification user document
|
|
1568
1596
|
*/ function updateNotificationUserFactory(context) {
|
|
1569
1597
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationUserCollection = context.notificationUserCollection, appNotificationTemplateTypeInfoRecordService = context.appNotificationTemplateTypeInfoRecordService;
|
|
1570
1598
|
return firebaseServerActionTransformFunctionFactory(updateNotificationUserParamsType, function(params) {
|
|
@@ -1684,6 +1712,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
1684
1712
|
* entries flagged with `ns=true` (needs-sync), loading the corresponding {@link NotificationBox},
|
|
1685
1713
|
* and merging the user's preferences back into the box's recipient list. Handles removed entries
|
|
1686
1714
|
* and cleans up stale box references.
|
|
1715
|
+
*
|
|
1716
|
+
* @param context - the notification server actions context with Firestore and collection access
|
|
1717
|
+
* @returns a transform-and-validate function that resyncs a notification user's box configurations
|
|
1687
1718
|
*/ function resyncNotificationUserFactory(context) {
|
|
1688
1719
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection, appNotificationTemplateTypeInfoRecordService = context.appNotificationTemplateTypeInfoRecordService;
|
|
1689
1720
|
return firebaseServerActionTransformFunctionFactory(resyncNotificationUserParamsType, function() {
|
|
@@ -1737,7 +1768,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
1737
1768
|
notificationBoxConfigsToSyncInThisBatchMap = makeModelMap(notificationBoxConfigsToSyncInThisBatch, function(x) {
|
|
1738
1769
|
return x.nb;
|
|
1739
1770
|
});
|
|
1740
|
-
notificationBoxIdsToSyncInThisBatch =
|
|
1771
|
+
notificationBoxIdsToSyncInThisBatch = _to_consumable_array$5(notificationBoxConfigsToSyncInThisBatchMap.keys());
|
|
1741
1772
|
notificationBoxDocuments = loadDocumentsForIds(notificationBoxCollection.documentAccessorForTransaction(transaction), notificationBoxIdsToSyncInThisBatch);
|
|
1742
1773
|
return [
|
|
1743
1774
|
4,
|
|
@@ -1795,7 +1826,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
1795
1826
|
recipientHasChange = !areEqualPOJOValues(nextRecipient, recipient);
|
|
1796
1827
|
// only update recipients if the next/new recipient is not equal to the existing one
|
|
1797
1828
|
if (recipientHasChange) {
|
|
1798
|
-
r = _to_consumable_array$
|
|
1829
|
+
r = _to_consumable_array$5(notificationBox.r);
|
|
1799
1830
|
r[recipientIndex] = nextRecipient;
|
|
1800
1831
|
nextRecipientsMap.set(nb, nextRecipient);
|
|
1801
1832
|
} else {
|
|
@@ -1845,13 +1876,12 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
1845
1876
|
i: UNSET_INDEX_NUMBER
|
|
1846
1877
|
});
|
|
1847
1878
|
} else {
|
|
1848
|
-
var _updatedRecipient_i;
|
|
1849
1879
|
// else, use the updated recipient and keep/copy the
|
|
1850
1880
|
var updatedRecipient = nextRecipientsMap.get(nb);
|
|
1851
1881
|
nextConfig = _object_spread_props$a(_object_spread$b({}, existingConfig), {
|
|
1852
1882
|
nb: nb,
|
|
1853
1883
|
rm: false,
|
|
1854
|
-
i:
|
|
1884
|
+
i: updatedRecipient.i
|
|
1855
1885
|
});
|
|
1856
1886
|
}
|
|
1857
1887
|
}
|
|
@@ -1919,6 +1949,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
1919
1949
|
* Batch-processes all {@link NotificationUser} documents flagged for sync by querying
|
|
1920
1950
|
* for entries with `ns=true`, then calling the resync logic for each in parallel
|
|
1921
1951
|
* (up to 5 concurrent tasks). Loops until no more flagged users are found.
|
|
1952
|
+
*
|
|
1953
|
+
* @param context - the notification server actions context with collection access
|
|
1954
|
+
* @returns an async function that resyncs all flagged notification users and returns aggregate results
|
|
1922
1955
|
*/ function resyncAllNotificationUsersFactory(context) {
|
|
1923
1956
|
var notificationUserCollection = context.notificationUserCollection;
|
|
1924
1957
|
var resyncNotificationUser = resyncNotificationUserFactory(context);
|
|
@@ -2004,6 +2037,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
2004
2037
|
*
|
|
2005
2038
|
* Creates a new {@link NotificationSummary} document for a model, generating the summary ID
|
|
2006
2039
|
* from the model key and initializing it with a blank template.
|
|
2040
|
+
*
|
|
2041
|
+
* @param context - the notification server actions context with collection access
|
|
2042
|
+
* @returns a transform-and-validate function that creates a new notification summary document
|
|
2007
2043
|
*/ function createNotificationSummaryFactory(context) {
|
|
2008
2044
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection;
|
|
2009
2045
|
return firebaseServerActionTransformFunctionFactory(createNotificationSummaryParamsType, function(params) {
|
|
@@ -2046,6 +2082,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
2046
2082
|
*
|
|
2047
2083
|
* Updates an existing {@link NotificationSummary} document's owner or setup flag.
|
|
2048
2084
|
* Runs within a Firestore transaction to ensure consistency.
|
|
2085
|
+
*
|
|
2086
|
+
* @param context - the notification server actions context
|
|
2087
|
+
* @returns a transform-and-validate function that updates an existing notification summary document
|
|
2049
2088
|
*/ function updateNotificationSummaryFactory(context) {
|
|
2050
2089
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
2051
2090
|
return firebaseServerActionTransformFunctionFactory(updateNotificationSummaryParamsType, function(params) {
|
|
@@ -2100,6 +2139,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
2100
2139
|
*
|
|
2101
2140
|
* Checks for existing boxes and throws if one already exists for the model.
|
|
2102
2141
|
* Also syncs initial recipients with their corresponding {@link NotificationUser} documents.
|
|
2142
|
+
*
|
|
2143
|
+
* @param context - the base notification server actions context with collection access
|
|
2144
|
+
* @returns an async function that creates a notification box within a transaction and returns the document and template
|
|
2103
2145
|
*/ function createNotificationBoxInTransactionFactory(context) {
|
|
2104
2146
|
var notificationBoxCollection = context.notificationBoxCollection;
|
|
2105
2147
|
return function(params, transaction) {
|
|
@@ -2148,6 +2190,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
2148
2190
|
*
|
|
2149
2191
|
* Wraps {@link createNotificationBoxInTransactionFactory} in a Firestore transaction
|
|
2150
2192
|
* and follows the transform-and-validate pattern.
|
|
2193
|
+
*
|
|
2194
|
+
* @param context - the notification server actions context with Firestore and collection access
|
|
2195
|
+
* @returns a transform-and-validate function that creates a new notification box document
|
|
2151
2196
|
*/ function createNotificationBoxFactory(context) {
|
|
2152
2197
|
var firestoreContext = context.firestoreContext, notificationBoxCollection = context.notificationBoxCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
2153
2198
|
var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
|
|
@@ -2204,8 +2249,16 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
|
|
|
2204
2249
|
})();
|
|
2205
2250
|
});
|
|
2206
2251
|
}
|
|
2207
|
-
|
|
2208
|
-
|
|
2252
|
+
/**
|
|
2253
|
+
* Factory for the `updateNotificationBox` action.
|
|
2254
|
+
*
|
|
2255
|
+
* Currently a no-op placeholder that returns the document unchanged.
|
|
2256
|
+
* Reserved for future box-level update logic.
|
|
2257
|
+
*
|
|
2258
|
+
* @param context - the notification server actions context (destructured for the transform factory)
|
|
2259
|
+
* @returns a transform-and-validate function that returns the notification box document unchanged
|
|
2260
|
+
*/ function updateNotificationBoxFactory(context) {
|
|
2261
|
+
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
2209
2262
|
return firebaseServerActionTransformFunctionFactory(updateNotificationBoxParamsType, function() {
|
|
2210
2263
|
return _async_to_generator$d(function() {
|
|
2211
2264
|
return _ts_generator$d(this, function(_state) {
|
|
@@ -2232,6 +2285,9 @@ function updateNotificationBoxFactory(param) {
|
|
|
2232
2285
|
*
|
|
2233
2286
|
* Manages the exclusion list (`x`) on both the box recipient and the corresponding
|
|
2234
2287
|
* {@link NotificationUser}'s send exclusion array, keeping them in sync.
|
|
2288
|
+
*
|
|
2289
|
+
* @param context - the base notification server actions context with collection access
|
|
2290
|
+
* @returns an async function that updates recipient exclusions within a transaction
|
|
2235
2291
|
*/ function updateNotificationBoxRecipientExclusionInTransactionFactory(context) {
|
|
2236
2292
|
var notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection;
|
|
2237
2293
|
return function(input, transaction) {
|
|
@@ -2267,7 +2323,7 @@ function updateNotificationBoxFactory(param) {
|
|
|
2267
2323
|
targetRecipient = notificationBox.r.find(function(x) {
|
|
2268
2324
|
return x.i === i;
|
|
2269
2325
|
});
|
|
2270
|
-
if (!targetRecipient ||
|
|
2326
|
+
if (!(targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.uid)) {
|
|
2271
2327
|
throw notificationBoxExclusionTargetInvalidError();
|
|
2272
2328
|
} else {
|
|
2273
2329
|
targetUid = targetRecipient.uid;
|
|
@@ -2277,21 +2333,16 @@ function updateNotificationBoxFactory(param) {
|
|
|
2277
2333
|
if (!targetUid) {
|
|
2278
2334
|
throw notificationBoxExclusionTargetInvalidError();
|
|
2279
2335
|
}
|
|
2280
|
-
|
|
2281
|
-
4,
|
|
2282
|
-
notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(targetUid)
|
|
2283
|
-
];
|
|
2284
|
-
case 4:
|
|
2285
|
-
notificationUserDocument = _state.sent();
|
|
2336
|
+
notificationUserDocument = notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(targetUid);
|
|
2286
2337
|
return [
|
|
2287
2338
|
4,
|
|
2288
2339
|
notificationUserDocument.snapshotData()
|
|
2289
2340
|
];
|
|
2290
|
-
case
|
|
2341
|
+
case 4:
|
|
2291
2342
|
notificationUser = _state.sent();
|
|
2292
2343
|
if (!notificationUser) return [
|
|
2293
2344
|
3,
|
|
2294
|
-
|
|
2345
|
+
6
|
|
2295
2346
|
];
|
|
2296
2347
|
// only update if the user exists
|
|
2297
2348
|
targetExclusions = [
|
|
@@ -2306,13 +2357,13 @@ function updateNotificationBoxFactory(param) {
|
|
|
2306
2357
|
4,
|
|
2307
2358
|
notificationUserDocument.update(notificationUserUpdate)
|
|
2308
2359
|
];
|
|
2309
|
-
case
|
|
2360
|
+
case 5:
|
|
2310
2361
|
_state.sent();
|
|
2311
2362
|
result = {
|
|
2312
2363
|
notificationUserUpdate: notificationUserUpdate
|
|
2313
2364
|
};
|
|
2314
|
-
_state.label =
|
|
2315
|
-
case
|
|
2365
|
+
_state.label = 6;
|
|
2366
|
+
case 6:
|
|
2316
2367
|
return [
|
|
2317
2368
|
2,
|
|
2318
2369
|
result
|
|
@@ -2328,6 +2379,9 @@ function updateNotificationBoxFactory(param) {
|
|
|
2328
2379
|
* Handles inserting new recipients, updating existing ones, and removing recipients.
|
|
2329
2380
|
* Syncs changes with the recipient's {@link NotificationUser} document and manages
|
|
2330
2381
|
* recipient index assignment via a sorted-values free-index calculator.
|
|
2382
|
+
*
|
|
2383
|
+
* @param context - the base notification server actions context with auth and collection access
|
|
2384
|
+
* @returns an async function that updates a recipient on a notification box within a transaction
|
|
2331
2385
|
*/ function updateNotificationBoxRecipientInTransactionFactory(context) {
|
|
2332
2386
|
var authService = context.authService, notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection;
|
|
2333
2387
|
var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
|
|
@@ -2385,14 +2439,14 @@ function updateNotificationBoxFactory(param) {
|
|
|
2385
2439
|
case 4:
|
|
2386
2440
|
if (!notificationBox) return [
|
|
2387
2441
|
3,
|
|
2388
|
-
|
|
2442
|
+
17
|
|
2389
2443
|
];
|
|
2390
2444
|
notificationBox.m;
|
|
2391
2445
|
targetRecipientIndex = notificationBox.r.findIndex(findRecipientFn);
|
|
2392
2446
|
targetRecipient = notificationBox.r[targetRecipientIndex];
|
|
2393
2447
|
if (remove) {
|
|
2394
|
-
if (targetRecipientIndex
|
|
2395
|
-
r = _to_consumable_array$
|
|
2448
|
+
if (targetRecipientIndex !== -1) {
|
|
2449
|
+
r = _to_consumable_array$5(notificationBox.r); // remove if they exist.
|
|
2396
2450
|
delete r[targetRecipientIndex];
|
|
2397
2451
|
}
|
|
2398
2452
|
} else {
|
|
@@ -2405,7 +2459,7 @@ function updateNotificationBoxFactory(param) {
|
|
|
2405
2459
|
i: (_ref1 = targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.i) !== null && _ref1 !== void 0 ? _ref1 : UNSET_INDEX_NUMBER,
|
|
2406
2460
|
c: c
|
|
2407
2461
|
}, updateNotificationRecipient(targetRecipient !== null && targetRecipient !== void 0 ? targetRecipient : {}, params));
|
|
2408
|
-
r = _to_consumable_array$
|
|
2462
|
+
r = _to_consumable_array$5(notificationBox.r);
|
|
2409
2463
|
if (targetRecipient) {
|
|
2410
2464
|
nextRecipient.i = targetRecipient.i;
|
|
2411
2465
|
nextRecipient = mergeNotificationBoxRecipients(targetRecipient, nextRecipient);
|
|
@@ -2420,30 +2474,25 @@ function updateNotificationBoxFactory(param) {
|
|
|
2420
2474
|
}
|
|
2421
2475
|
if (!(r != null)) return [
|
|
2422
2476
|
3,
|
|
2423
|
-
|
|
2477
|
+
17
|
|
2424
2478
|
];
|
|
2425
2479
|
notificationUserId = (_ref2 = targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.uid) !== null && _ref2 !== void 0 ? _ref2 : nextRecipient === null || nextRecipient === void 0 ? void 0 : nextRecipient.uid;
|
|
2426
2480
|
if (!(notificationUserId != null)) return [
|
|
2427
2481
|
3,
|
|
2428
|
-
|
|
2482
|
+
12
|
|
2429
2483
|
];
|
|
2430
2484
|
notificationBoxId = notificationBoxDocument.id;
|
|
2431
|
-
|
|
2432
|
-
4,
|
|
2433
|
-
notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(notificationUserId)
|
|
2434
|
-
];
|
|
2435
|
-
case 5:
|
|
2436
|
-
notificationUserDocument = _state.sent();
|
|
2485
|
+
notificationUserDocument = notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(notificationUserId);
|
|
2437
2486
|
return [
|
|
2438
2487
|
4,
|
|
2439
2488
|
notificationUserDocument.snapshotData()
|
|
2440
2489
|
];
|
|
2441
|
-
case
|
|
2490
|
+
case 5:
|
|
2442
2491
|
notificationUser = _state.sent();
|
|
2443
2492
|
createNotificationUser = !notificationUser && !remove && insert;
|
|
2444
2493
|
if (!createNotificationUser) return [
|
|
2445
2494
|
3,
|
|
2446
|
-
|
|
2495
|
+
7
|
|
2447
2496
|
];
|
|
2448
2497
|
// assert they exist in the auth system
|
|
2449
2498
|
userContext = authService.userContext(notificationUserId);
|
|
@@ -2451,7 +2500,7 @@ function updateNotificationBoxFactory(param) {
|
|
|
2451
2500
|
4,
|
|
2452
2501
|
userContext.exists()
|
|
2453
2502
|
];
|
|
2454
|
-
case
|
|
2503
|
+
case 6:
|
|
2455
2504
|
userExistsInAuth = _state.sent();
|
|
2456
2505
|
if (!userExistsInAuth) {
|
|
2457
2506
|
throw notificationUserInvalidUidForCreateError(notificationUserId);
|
|
@@ -2470,11 +2519,11 @@ function updateNotificationBoxFactory(param) {
|
|
|
2470
2519
|
}
|
|
2471
2520
|
};
|
|
2472
2521
|
notificationUser = notificationUserTemplate;
|
|
2473
|
-
_state.label =
|
|
2474
|
-
case
|
|
2522
|
+
_state.label = 7;
|
|
2523
|
+
case 7:
|
|
2475
2524
|
if (!(notificationUser != null)) return [
|
|
2476
2525
|
3,
|
|
2477
|
-
|
|
2526
|
+
12
|
|
2478
2527
|
];
|
|
2479
2528
|
_updateNotificationUserNotificationBoxRecipientConfig = updateNotificationUserNotificationBoxRecipientConfig({
|
|
2480
2529
|
notificationBoxId: notificationBoxId,
|
|
@@ -2489,7 +2538,7 @@ function updateNotificationBoxFactory(param) {
|
|
|
2489
2538
|
}) : undefined;
|
|
2490
2539
|
if (!createNotificationUser) return [
|
|
2491
2540
|
3,
|
|
2492
|
-
|
|
2541
|
+
9
|
|
2493
2542
|
];
|
|
2494
2543
|
newUserTemplate = _object_spread_props$a(_object_spread$b({}, notificationUser), {
|
|
2495
2544
|
bc: updatedBc !== null && updatedBc !== void 0 ? updatedBc : [],
|
|
@@ -2499,16 +2548,16 @@ function updateNotificationBoxFactory(param) {
|
|
|
2499
2548
|
4,
|
|
2500
2549
|
notificationUserDocument.create(newUserTemplate)
|
|
2501
2550
|
];
|
|
2502
|
-
case
|
|
2551
|
+
case 8:
|
|
2503
2552
|
_state.sent();
|
|
2504
2553
|
return [
|
|
2505
2554
|
3,
|
|
2506
|
-
|
|
2555
|
+
11
|
|
2507
2556
|
];
|
|
2508
|
-
case
|
|
2557
|
+
case 9:
|
|
2509
2558
|
if (!(updatedBc != null)) return [
|
|
2510
2559
|
3,
|
|
2511
|
-
|
|
2560
|
+
11
|
|
2512
2561
|
];
|
|
2513
2562
|
return [
|
|
2514
2563
|
4,
|
|
@@ -2517,53 +2566,53 @@ function updateNotificationBoxFactory(param) {
|
|
|
2517
2566
|
b: updatedB
|
|
2518
2567
|
})
|
|
2519
2568
|
];
|
|
2520
|
-
case
|
|
2569
|
+
case 10:
|
|
2521
2570
|
_state.sent();
|
|
2522
|
-
_state.label =
|
|
2523
|
-
case
|
|
2571
|
+
_state.label = 11;
|
|
2572
|
+
case 11:
|
|
2524
2573
|
// Set if nextRecipient is updated/influence from existing configuration
|
|
2525
|
-
if (targetRecipientIndex
|
|
2574
|
+
if (targetRecipientIndex !== -1 && updatedNotificationBoxRecipient && !remove) {
|
|
2526
2575
|
r[targetRecipientIndex] = updatedNotificationBoxRecipient; // set the updated value in r
|
|
2527
2576
|
}
|
|
2528
|
-
_state.label =
|
|
2529
|
-
case
|
|
2577
|
+
_state.label = 12;
|
|
2578
|
+
case 12:
|
|
2530
2579
|
updatedNotificationBox = _object_spread_props$a(_object_spread$b({}, notificationBox), {
|
|
2531
2580
|
r: r
|
|
2532
2581
|
});
|
|
2533
2582
|
notificationBoxWasCreated = false;
|
|
2534
2583
|
if (!createNotificationBox) return [
|
|
2535
2584
|
3,
|
|
2536
|
-
|
|
2585
|
+
14
|
|
2537
2586
|
];
|
|
2538
2587
|
return [
|
|
2539
2588
|
4,
|
|
2540
2589
|
notificationBoxDocument.create(updatedNotificationBox)
|
|
2541
2590
|
];
|
|
2542
|
-
case
|
|
2591
|
+
case 13:
|
|
2543
2592
|
_state.sent();
|
|
2544
2593
|
notificationBoxWasCreated = true;
|
|
2545
2594
|
return [
|
|
2546
2595
|
3,
|
|
2547
|
-
|
|
2596
|
+
16
|
|
2548
2597
|
];
|
|
2549
|
-
case
|
|
2598
|
+
case 14:
|
|
2550
2599
|
return [
|
|
2551
2600
|
4,
|
|
2552
2601
|
notificationBoxDocument.update({
|
|
2553
2602
|
r: r
|
|
2554
2603
|
})
|
|
2555
2604
|
];
|
|
2556
|
-
case
|
|
2605
|
+
case 15:
|
|
2557
2606
|
_state.sent();
|
|
2558
|
-
_state.label =
|
|
2559
|
-
case
|
|
2607
|
+
_state.label = 16;
|
|
2608
|
+
case 16:
|
|
2560
2609
|
result = {
|
|
2561
2610
|
updatedNotificationBox: updatedNotificationBox,
|
|
2562
2611
|
notificationBoxWasCreated: notificationBoxWasCreated,
|
|
2563
2612
|
notificationBoxDocument: notificationBoxDocument
|
|
2564
2613
|
};
|
|
2565
|
-
_state.label =
|
|
2566
|
-
case
|
|
2614
|
+
_state.label = 17;
|
|
2615
|
+
case 17:
|
|
2567
2616
|
return [
|
|
2568
2617
|
2,
|
|
2569
2618
|
result
|
|
@@ -2578,6 +2627,9 @@ function updateNotificationBoxFactory(param) {
|
|
|
2578
2627
|
*
|
|
2579
2628
|
* Wraps the in-transaction recipient update logic, handling both recipient changes
|
|
2580
2629
|
* and send exclusion updates in a single Firestore transaction.
|
|
2630
|
+
*
|
|
2631
|
+
* @param context - the notification server actions context with Firestore and collection access
|
|
2632
|
+
* @returns a transform-and-validate function that updates a recipient on a notification box
|
|
2581
2633
|
*/ function updateNotificationBoxRecipientFactory(context) {
|
|
2582
2634
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
2583
2635
|
var updateNotificationBoxRecipientInTransaction = updateNotificationBoxRecipientInTransactionFactory(context);
|
|
@@ -2679,6 +2731,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
2679
2731
|
*
|
|
2680
2732
|
* Supports throttling via `sendAt` time, configurable send flags, and task-based
|
|
2681
2733
|
* async workflows for notifications that require multi-step processing.
|
|
2734
|
+
*
|
|
2735
|
+
* @param context - the notification server actions context with template, send, and task services
|
|
2736
|
+
* @returns a transform-and-validate function that processes and sends a notification document
|
|
2682
2737
|
*/ function sendNotificationFactory(context) {
|
|
2683
2738
|
var appNotificationTemplateTypeInfoRecordService = context.appNotificationTemplateTypeInfoRecordService, notificationSendService = context.notificationSendService, notificationTaskService = context.notificationTaskService, notificationTemplateService = context.notificationTemplateService, authService = context.authService, notificationBoxCollection = context.notificationBoxCollection, notificationCollectionGroup = context.notificationCollectionGroup, notificationUserCollection = context.notificationUserCollection, firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
2684
2739
|
var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
|
|
@@ -2759,7 +2814,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
2759
2814
|
notificationTemplate.at = 0; // reset checkpoint attempt/delay count
|
|
2760
2815
|
}
|
|
2761
2816
|
// add the checkpoint to the notification
|
|
2762
|
-
notificationTemplate.tpr = _to_consumable_array$
|
|
2817
|
+
notificationTemplate.tpr = _to_consumable_array$5(removeFromCompletionsArrayWithTaskResult(notification.tpr, handleTaskResult)).concat(_to_consumable_array$5(asArray(completion)));
|
|
2763
2818
|
// calculate the updated notification item
|
|
2764
2819
|
notificationTemplate.n = _object_spread_props$a(_object_spread$b({}, notification.n), {
|
|
2765
2820
|
d: _object_spread$b({}, notification.n.d, updateMetadata ? filterOnlyUndefinedValues(updateMetadata) : undefined // ignore any undefined values
|
|
@@ -2769,7 +2824,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
2769
2824
|
// if the tpr has not changed, then it is also considered a reversal
|
|
2770
2825
|
if (tryRunNextPart) {
|
|
2771
2826
|
tprChanged = !iterablesAreSetEquivalent(notification.tpr, notificationTemplate.tpr);
|
|
2772
|
-
partTprReversal = !tprChanged ||
|
|
2827
|
+
partTprReversal = !tprChanged || notificationTemplate.tpr.length <= notification.tpr.length;
|
|
2773
2828
|
if (allCompletedSubTasks != null) {
|
|
2774
2829
|
switch(allCompletedSubTasks){
|
|
2775
2830
|
case true:
|
|
@@ -2778,11 +2833,13 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
2778
2833
|
tryRunNextPart = !partTprReversal;
|
|
2779
2834
|
break;
|
|
2780
2835
|
default:
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2836
|
+
{
|
|
2837
|
+
// check subtask tpr changes
|
|
2838
|
+
nextCompleteSubTasks = asArray(allCompletedSubTasks);
|
|
2839
|
+
subtaskTprChanged = !iterablesAreSetEquivalent(previouslyCompleteSubTasks, nextCompleteSubTasks);
|
|
2840
|
+
partTprReversal = !subtaskTprChanged || nextCompleteSubTasks.length <= previouslyCompleteSubTasks.length;
|
|
2841
|
+
break;
|
|
2842
|
+
}
|
|
2786
2843
|
}
|
|
2787
2844
|
}
|
|
2788
2845
|
}
|
|
@@ -3001,7 +3058,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3001
3058
|
];
|
|
3002
3059
|
case 2:
|
|
3003
3060
|
_ref = _state.sent(), emailRecipients = _ref.emails, textRecipients = _ref.texts, notificationSummaryRecipients = _ref.notificationSummaries;
|
|
3004
|
-
es = notification.es, ts = notification.ts, ps = notification.ps, ns = notification.ns
|
|
3061
|
+
es = notification.es, ts = notification.ts, ps = notification.ps, ns = notification.ns;
|
|
3062
|
+
currentEsr = notification.esr, currentTsr = notification.tsr;
|
|
3005
3063
|
if (!(es === NotificationSendState.QUEUED || es === NotificationSendState.SENT_PARTIAL)) return [
|
|
3006
3064
|
3,
|
|
3007
3065
|
15
|
|
@@ -3108,9 +3166,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3108
3166
|
case 13:
|
|
3109
3167
|
if (sendEmailsResult != null) {
|
|
3110
3168
|
success1 = sendEmailsResult.success, failed = sendEmailsResult.failed;
|
|
3111
|
-
esr = success1.length ? currentEsr.concat(success1.map(function(x) {
|
|
3169
|
+
esr = success1.length ? _to_consumable_array$5(currentEsr).concat(_to_consumable_array$5(success1.map(function(x) {
|
|
3112
3170
|
return x.toLowerCase();
|
|
3113
|
-
})) : undefined;
|
|
3171
|
+
}))) : undefined;
|
|
3114
3172
|
if (failed.length > 0) {
|
|
3115
3173
|
es = NotificationSendState.SENT_PARTIAL;
|
|
3116
3174
|
} else {
|
|
@@ -3229,7 +3287,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3229
3287
|
case 26:
|
|
3230
3288
|
if (sendTextsResult != null) {
|
|
3231
3289
|
success2 = sendTextsResult.success, failed1 = sendTextsResult.failed;
|
|
3232
|
-
tsr = success2.length ? currentTsr.concat(success2) : undefined;
|
|
3290
|
+
tsr = success2.length ? _to_consumable_array$5(currentTsr).concat(_to_consumable_array$5(success2)) : undefined;
|
|
3233
3291
|
if (failed1.length > 0) {
|
|
3234
3292
|
ts = NotificationSendState.SENT_PARTIAL;
|
|
3235
3293
|
} else {
|
|
@@ -3437,6 +3495,10 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3437
3495
|
// deleted successfully
|
|
3438
3496
|
success = deletedNotification;
|
|
3439
3497
|
break;
|
|
3498
|
+
case NotificationSendType.INIT_BOX_AND_SEND:
|
|
3499
|
+
case NotificationSendType.SEND_WITHOUT_CREATING_BOX:
|
|
3500
|
+
case NotificationSendType.TASK_NOTIFICATION:
|
|
3501
|
+
break;
|
|
3440
3502
|
}
|
|
3441
3503
|
_state.label = 48;
|
|
3442
3504
|
case 48:
|
|
@@ -3457,7 +3519,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3457
3519
|
4,
|
|
3458
3520
|
firestoreContext.runTransaction(function(transaction) {
|
|
3459
3521
|
return _async_to_generator$d(function() {
|
|
3460
|
-
var notificationBoxDocument, notificationDocumentInTransaction, _ref,
|
|
3522
|
+
var notificationBoxDocument, notificationDocumentInTransaction, _ref, initialNotificationBox, notification, notificationBox, model, isNotificationTask, tryRun, throttled, nextSat, createdBox, deletedNotification, notificationBoxNeedsInitialization, isKnownTemplateType, isConfiguredTemplateType, onlySendToExplicitlyEnabledRecipients, onlyTextExplicitlyEnabledRecipients, templateInstance, notificationTaskHandler, t // notification task/template type
|
|
3461
3523
|
, delay, _notification_ois, _notification_ots, templateTypeInfo, retryAttempts, delay1, _, notificationBoxTemplate, isAtMaxAttempts, a;
|
|
3462
3524
|
function deleteNotification() {
|
|
3463
3525
|
return _async_to_generator$d(function() {
|
|
@@ -3495,7 +3557,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3495
3557
|
_ref = _sliced_to_array$2.apply(void 0, [
|
|
3496
3558
|
_state.sent(),
|
|
3497
3559
|
2
|
|
3498
|
-
]),
|
|
3560
|
+
]), initialNotificationBox = _ref[0], notification = _ref[1];
|
|
3561
|
+
notificationBox = initialNotificationBox;
|
|
3499
3562
|
model = inferKeyFromTwoWayFlatFirestoreModelKey(notificationBoxDocument.id);
|
|
3500
3563
|
isNotificationTask = (notification === null || notification === void 0 ? void 0 : notification.st) === NotificationSendType.TASK_NOTIFICATION;
|
|
3501
3564
|
tryRun = true;
|
|
@@ -3523,7 +3586,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3523
3586
|
notificationBoxNeedsInitialization = false;
|
|
3524
3587
|
if (!(notification && tryRun)) return [
|
|
3525
3588
|
3,
|
|
3526
|
-
|
|
3589
|
+
19
|
|
3527
3590
|
];
|
|
3528
3591
|
// if we're still trying to run, check the template is ok. If not, cancel the run.
|
|
3529
3592
|
t = notification.n.t;
|
|
@@ -3580,7 +3643,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3580
3643
|
case 7:
|
|
3581
3644
|
return [
|
|
3582
3645
|
3,
|
|
3583
|
-
|
|
3646
|
+
19
|
|
3584
3647
|
];
|
|
3585
3648
|
case 8:
|
|
3586
3649
|
templateInstance = notificationTemplateService.templateInstanceForType(t);
|
|
@@ -3601,7 +3664,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3601
3664
|
9
|
|
3602
3665
|
];
|
|
3603
3666
|
if (isKnownTemplateType) {
|
|
3604
|
-
console.warn('Unconfigured but known template type of "'.concat(t, '" (').concat(templateTypeInfo.name, ") was found in a Notification. Send is being delayed by ").concat(delay1, " hours."));
|
|
3667
|
+
console.warn('Unconfigured but known template type of "'.concat(t, '" (').concat(templateTypeInfo === null || templateTypeInfo === void 0 ? void 0 : templateTypeInfo.name, ") was found in a Notification. Send is being delayed by ").concat(delay1, " hours."));
|
|
3605
3668
|
} else {
|
|
3606
3669
|
console.warn('Unknown template type of "'.concat(t, '" was found in a Notification. Send is being delayed by ').concat(delay1, " hours."));
|
|
3607
3670
|
}
|
|
@@ -3625,7 +3688,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3625
3688
|
case 11:
|
|
3626
3689
|
if (!(!notificationBox && tryRun)) return [
|
|
3627
3690
|
3,
|
|
3628
|
-
|
|
3691
|
+
18
|
|
3629
3692
|
];
|
|
3630
3693
|
_ = notification.st;
|
|
3631
3694
|
switch(_){
|
|
@@ -3644,10 +3707,15 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3644
3707
|
3,
|
|
3645
3708
|
16
|
|
3646
3709
|
];
|
|
3710
|
+
case NotificationSendType.TASK_NOTIFICATION:
|
|
3711
|
+
return [
|
|
3712
|
+
3,
|
|
3713
|
+
17
|
|
3714
|
+
];
|
|
3647
3715
|
}
|
|
3648
3716
|
return [
|
|
3649
3717
|
3,
|
|
3650
|
-
|
|
3718
|
+
18
|
|
3651
3719
|
];
|
|
3652
3720
|
case 12:
|
|
3653
3721
|
return [
|
|
@@ -3662,7 +3730,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3662
3730
|
createdBox = true;
|
|
3663
3731
|
return [
|
|
3664
3732
|
3,
|
|
3665
|
-
|
|
3733
|
+
18
|
|
3666
3734
|
];
|
|
3667
3735
|
case 14:
|
|
3668
3736
|
// delete the notification since it won't get sent.
|
|
@@ -3674,43 +3742,49 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3674
3742
|
_state.sent();
|
|
3675
3743
|
return [
|
|
3676
3744
|
3,
|
|
3677
|
-
|
|
3745
|
+
18
|
|
3678
3746
|
];
|
|
3679
3747
|
case 16:
|
|
3680
3748
|
// continue with current tryRun
|
|
3681
3749
|
return [
|
|
3682
3750
|
3,
|
|
3683
|
-
|
|
3751
|
+
18
|
|
3684
3752
|
];
|
|
3685
3753
|
case 17:
|
|
3754
|
+
// task notifications do not require a notification box; continue with current tryRun
|
|
3755
|
+
return [
|
|
3756
|
+
3,
|
|
3757
|
+
18
|
|
3758
|
+
];
|
|
3759
|
+
case 18:
|
|
3686
3760
|
// if the notification box is not initialized/synchronized yet, do not run.
|
|
3687
3761
|
if (tryRun && notificationBox && notificationBox.s) {
|
|
3688
3762
|
notificationBoxNeedsInitialization = true;
|
|
3689
3763
|
tryRun = false;
|
|
3690
3764
|
nextSat = addMinutes(now, NOTIFICATION_BOX_NOT_INITIALIZED_DELAY_MINUTES);
|
|
3691
3765
|
}
|
|
3692
|
-
_state.label =
|
|
3693
|
-
case
|
|
3766
|
+
_state.label = 19;
|
|
3767
|
+
case 19:
|
|
3694
3768
|
if (!(notification != null && nextSat != null && !deletedNotification)) return [
|
|
3695
3769
|
3,
|
|
3696
|
-
|
|
3770
|
+
23
|
|
3697
3771
|
];
|
|
3698
3772
|
isAtMaxAttempts = notification.a >= NOTIFICATION_MAX_SEND_ATTEMPTS;
|
|
3699
3773
|
if (!(isAtMaxAttempts && notificationBoxNeedsInitialization)) return [
|
|
3700
3774
|
3,
|
|
3701
|
-
|
|
3775
|
+
21
|
|
3702
3776
|
];
|
|
3703
3777
|
return [
|
|
3704
3778
|
4,
|
|
3705
3779
|
deleteNotification()
|
|
3706
3780
|
];
|
|
3707
|
-
case 19:
|
|
3708
|
-
_state.sent(); // just delete the notification if the box still hasn't been initialized successfully at this point.
|
|
3709
|
-
_state.label = 20;
|
|
3710
3781
|
case 20:
|
|
3782
|
+
_state.sent(); // just delete the notification if the box still hasn't been initialized successfully at this point.
|
|
3783
|
+
_state.label = 21;
|
|
3784
|
+
case 21:
|
|
3711
3785
|
if (!!deletedNotification) return [
|
|
3712
3786
|
3,
|
|
3713
|
-
|
|
3787
|
+
23
|
|
3714
3788
|
];
|
|
3715
3789
|
a = isNotificationTask && tryRun ? notification.a : notification.a + 1; // do not update a notification task's attempt count here, unless tryRun fails
|
|
3716
3790
|
// NOTE: It is important to update sat so the notification task queue running doesn't get stuck in a query loop by notifications/tasks that have a sat value that is in the past, but was just run.
|
|
@@ -3721,10 +3795,10 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3721
3795
|
a: a
|
|
3722
3796
|
})
|
|
3723
3797
|
];
|
|
3724
|
-
case 21:
|
|
3725
|
-
_state.sent();
|
|
3726
|
-
_state.label = 22;
|
|
3727
3798
|
case 22:
|
|
3799
|
+
_state.sent();
|
|
3800
|
+
_state.label = 23;
|
|
3801
|
+
case 23:
|
|
3728
3802
|
return [
|
|
3729
3803
|
2,
|
|
3730
3804
|
{
|
|
@@ -3836,6 +3910,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3836
3910
|
* and an optional {@link NotificationExpediteService} for immediate delivery.
|
|
3837
3911
|
* Continues processing batches until no more queued notifications are found
|
|
3838
3912
|
* or the time budget is exhausted.
|
|
3913
|
+
*
|
|
3914
|
+
* @param context - the notification server actions context with collection group and send factory access
|
|
3915
|
+
* @returns a transform-and-validate function that processes all queued notifications and returns aggregate results
|
|
3839
3916
|
*/ function sendQueuedNotificationsFactory(context) {
|
|
3840
3917
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationCollectionGroup = context.notificationCollectionGroup;
|
|
3841
3918
|
var sendNotification = sendNotificationFactory(context);
|
|
@@ -3877,7 +3954,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3877
3954
|
excessLoopsDetected = false;
|
|
3878
3955
|
sendQueuedNotifications = function sendQueuedNotifications() {
|
|
3879
3956
|
return _async_to_generator$d(function() {
|
|
3880
|
-
var query, notificationDocuments
|
|
3957
|
+
var query, notificationDocuments;
|
|
3881
3958
|
return _ts_generator$d(this, function(_state) {
|
|
3882
3959
|
switch(_state.label){
|
|
3883
3960
|
case 0:
|
|
@@ -3889,7 +3966,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3889
3966
|
case 1:
|
|
3890
3967
|
notificationDocuments = _state.sent();
|
|
3891
3968
|
return [
|
|
3892
|
-
|
|
3969
|
+
2,
|
|
3893
3970
|
performAsyncTasks(notificationDocuments, function(notificationDocument) {
|
|
3894
3971
|
return _async_to_generator$d(function() {
|
|
3895
3972
|
var result;
|
|
@@ -3914,12 +3991,6 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
3914
3991
|
maxParallelTasks: maxParallelTasks
|
|
3915
3992
|
})
|
|
3916
3993
|
];
|
|
3917
|
-
case 2:
|
|
3918
|
-
result = _state.sent();
|
|
3919
|
-
return [
|
|
3920
|
-
2,
|
|
3921
|
-
result
|
|
3922
|
-
];
|
|
3923
3994
|
}
|
|
3924
3995
|
});
|
|
3925
3996
|
})();
|
|
@@ -4009,6 +4080,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4009
4080
|
* Queries for {@link Notification} documents that are ready for cleanup (fully sent,
|
|
4010
4081
|
* past the retention window) and deletes them in batches. Continues until no more
|
|
4011
4082
|
* cleanup-eligible notifications are found.
|
|
4083
|
+
*
|
|
4084
|
+
* @param context - the notification server actions context with Firestore and collection access
|
|
4085
|
+
* @returns a transform-and-validate function that cleans up sent notification documents and returns aggregate results
|
|
4012
4086
|
*/ function cleanupSentNotificationsFactory(context) {
|
|
4013
4087
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationCollectionGroup = context.notificationCollectionGroup, notificationBoxCollection = context.notificationBoxCollection, notificationWeekCollectionFactory = context.notificationWeekCollectionFactory;
|
|
4014
4088
|
return firebaseServerActionTransformFunctionFactory(cleanupSentNotificationsParamsType, function() {
|
|
@@ -4021,7 +4095,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4021
4095
|
var notificationBoxesUpdatesCount, notificationsDeleted, notificationTasksDeletedCount, notificationWeeksCreated, notificationWeeksUpdated, cleanupSentNotificationsResults, notificationBoxesUpdated, result;
|
|
4022
4096
|
function cleanupSentNotifications() {
|
|
4023
4097
|
return _async_to_generator$d(function() {
|
|
4024
|
-
var query, notificationDocuments, notificationDocumentsGroupedByNotificationBox
|
|
4098
|
+
var query, notificationDocuments, notificationDocumentsGroupedByNotificationBox;
|
|
4025
4099
|
return _ts_generator$d(this, function(_state) {
|
|
4026
4100
|
switch(_state.label){
|
|
4027
4101
|
case 0:
|
|
@@ -4032,14 +4106,14 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4032
4106
|
];
|
|
4033
4107
|
case 1:
|
|
4034
4108
|
notificationDocuments = _state.sent();
|
|
4035
|
-
notificationDocumentsGroupedByNotificationBox =
|
|
4109
|
+
notificationDocumentsGroupedByNotificationBox = _to_consumable_array$5(makeValuesGroupMap(notificationDocuments, function(x) {
|
|
4036
4110
|
return x.parent.id;
|
|
4037
4111
|
}).values());
|
|
4038
4112
|
return [
|
|
4039
|
-
|
|
4113
|
+
2,
|
|
4040
4114
|
performAsyncTasks(notificationDocumentsGroupedByNotificationBox, function(notificationDocumentsInSameBox) {
|
|
4041
4115
|
return _async_to_generator$d(function() {
|
|
4042
|
-
var allPairs, allPairsWithDataAndMarkedDeleted, _separateValues, taskPairsWithDataAndMarkedDeleted, normalPairsWithDataAndMarkedDeleted, pairsGroupedByWeek, pairsGroupedByWeekInBatches, notificationBoxDocument, notificationWeekResults, writeBatch, writeBatchAccessor, weeksCreated, weeksUpdated, tasksDeleted
|
|
4116
|
+
var allPairs, allPairsWithDataAndMarkedDeleted, _separateValues, taskPairsWithDataAndMarkedDeleted, normalPairsWithDataAndMarkedDeleted, pairsGroupedByWeek, pairsGroupedByWeekInBatches, notificationBoxDocument, notificationWeekResults, writeBatch, writeBatchAccessor, weeksCreated, weeksUpdated, tasksDeleted;
|
|
4043
4117
|
return _ts_generator$d(this, function(_state) {
|
|
4044
4118
|
switch(_state.label){
|
|
4045
4119
|
case 0:
|
|
@@ -4057,11 +4131,11 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4057
4131
|
var _x_data;
|
|
4058
4132
|
return ((_x_data = x.data) === null || _x_data === void 0 ? void 0 : _x_data.st) === NotificationSendType.TASK_NOTIFICATION;
|
|
4059
4133
|
}), taskPairsWithDataAndMarkedDeleted = _separateValues.included, normalPairsWithDataAndMarkedDeleted = _separateValues.excluded;
|
|
4060
|
-
pairsGroupedByWeek =
|
|
4134
|
+
pairsGroupedByWeek = _to_consumable_array$5(makeValuesGroupMap(normalPairsWithDataAndMarkedDeleted, function(x) {
|
|
4061
4135
|
return yearWeekCode(x.data.sat);
|
|
4062
4136
|
}).entries());
|
|
4063
4137
|
// batch incase there are a lot of new notifications to move to week
|
|
4064
|
-
pairsGroupedByWeekInBatches = pairsGroupedByWeek.
|
|
4138
|
+
pairsGroupedByWeekInBatches = pairsGroupedByWeek.flatMap(function(x) {
|
|
4065
4139
|
var batches = batch(x[1], 40);
|
|
4066
4140
|
return batches.map(function(batch) {
|
|
4067
4141
|
return [
|
|
@@ -4069,13 +4143,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4069
4143
|
batch
|
|
4070
4144
|
];
|
|
4071
4145
|
});
|
|
4072
|
-
})
|
|
4073
|
-
|
|
4074
|
-
4,
|
|
4075
|
-
notificationBoxCollection.documentAccessor().loadDocument(notificationDocumentsInSameBox[0].parent)
|
|
4076
|
-
];
|
|
4077
|
-
case 2:
|
|
4078
|
-
notificationBoxDocument = _state.sent();
|
|
4146
|
+
});
|
|
4147
|
+
notificationBoxDocument = notificationBoxCollection.documentAccessor().loadDocument(notificationDocumentsInSameBox[0].parent);
|
|
4079
4148
|
return [
|
|
4080
4149
|
4,
|
|
4081
4150
|
performAsyncTasks(pairsGroupedByWeekInBatches, function(param) {
|
|
@@ -4105,7 +4174,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4105
4174
|
var shouldSaveToNotificationWeek = shouldSaveNotificationToNotificationWeek(data);
|
|
4106
4175
|
return shouldSaveToNotificationWeek ? data.n : undefined;
|
|
4107
4176
|
}));
|
|
4108
|
-
n = _to_consumable_array$
|
|
4177
|
+
n = _to_consumable_array$5((_ref = notificationWeek === null || notificationWeek === void 0 ? void 0 : notificationWeek.n) !== null && _ref !== void 0 ? _ref : []).concat(_to_consumable_array$5(newItems));
|
|
4109
4178
|
if (!!notificationWeek) return [
|
|
4110
4179
|
3,
|
|
4111
4180
|
3
|
|
@@ -4160,7 +4229,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4160
4229
|
})();
|
|
4161
4230
|
})
|
|
4162
4231
|
];
|
|
4163
|
-
case
|
|
4232
|
+
case 2:
|
|
4164
4233
|
notificationWeekResults = _state.sent();
|
|
4165
4234
|
// delete all the task notifications
|
|
4166
4235
|
writeBatch = firestoreContext.batch();
|
|
@@ -4171,13 +4240,13 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4171
4240
|
return writeBatchAccessor.loadDocumentFrom(x.document).accessor.delete();
|
|
4172
4241
|
}))
|
|
4173
4242
|
];
|
|
4174
|
-
case
|
|
4243
|
+
case 3:
|
|
4175
4244
|
_state.sent();
|
|
4176
4245
|
return [
|
|
4177
4246
|
4,
|
|
4178
4247
|
writeBatch.commit()
|
|
4179
4248
|
];
|
|
4180
|
-
case
|
|
4249
|
+
case 4:
|
|
4181
4250
|
_state.sent();
|
|
4182
4251
|
weeksCreated = 0;
|
|
4183
4252
|
weeksUpdated = 0;
|
|
@@ -4189,15 +4258,14 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4189
4258
|
weeksUpdated += 1;
|
|
4190
4259
|
}
|
|
4191
4260
|
});
|
|
4192
|
-
result = {
|
|
4193
|
-
weeksCreated: weeksCreated,
|
|
4194
|
-
weeksUpdated: weeksUpdated,
|
|
4195
|
-
itemsDeleted: allPairsWithDataAndMarkedDeleted.length,
|
|
4196
|
-
tasksDeleted: tasksDeleted
|
|
4197
|
-
};
|
|
4198
4261
|
return [
|
|
4199
4262
|
2,
|
|
4200
|
-
|
|
4263
|
+
{
|
|
4264
|
+
weeksCreated: weeksCreated,
|
|
4265
|
+
weeksUpdated: weeksUpdated,
|
|
4266
|
+
itemsDeleted: allPairsWithDataAndMarkedDeleted.length,
|
|
4267
|
+
tasksDeleted: tasksDeleted
|
|
4268
|
+
}
|
|
4201
4269
|
];
|
|
4202
4270
|
}
|
|
4203
4271
|
});
|
|
@@ -4206,12 +4274,6 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
|
|
|
4206
4274
|
maxParallelTasks: 10
|
|
4207
4275
|
})
|
|
4208
4276
|
];
|
|
4209
|
-
case 2:
|
|
4210
|
-
result = _state.sent();
|
|
4211
|
-
return [
|
|
4212
|
-
2,
|
|
4213
|
-
result
|
|
4214
|
-
];
|
|
4215
4277
|
}
|
|
4216
4278
|
});
|
|
4217
4279
|
})();
|
|
@@ -4476,6 +4538,7 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4476
4538
|
* initialization action to its factory function.
|
|
4477
4539
|
*
|
|
4478
4540
|
* @param context - the initialization context with template functions and Firestore access
|
|
4541
|
+
* @returns a fully wired {@link NotificationInitServerActions} instance
|
|
4479
4542
|
*
|
|
4480
4543
|
* @example
|
|
4481
4544
|
* ```ts
|
|
@@ -4502,6 +4565,7 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4502
4565
|
* Skips initialization if the model is already initialized, optionally throwing an error.
|
|
4503
4566
|
*
|
|
4504
4567
|
* @param input - the document, transaction, template function, and options
|
|
4568
|
+
* @returns an object with `initialized` and `alreadyInitialized` boolean flags
|
|
4505
4569
|
* @throws notificationModelAlreadyInitializedError when `throwErrorIfAlreadyInitialized` is true
|
|
4506
4570
|
*/ function initializeNotificationModelInTransaction(input) {
|
|
4507
4571
|
return _async_to_generator$c(function() {
|
|
@@ -4603,6 +4667,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4603
4667
|
*
|
|
4604
4668
|
* Loads the box document in the transaction, reads its current data, and delegates
|
|
4605
4669
|
* to {@link initializeNotificationModelInTransaction} with the box-specific template function.
|
|
4670
|
+
*
|
|
4671
|
+
* @param context - the initialization context with collection references and template functions
|
|
4672
|
+
* @returns an async function that initializes a notification box given params, document, and transaction
|
|
4606
4673
|
*/ function initializeNotificationBoxInTransactionFactory(context) {
|
|
4607
4674
|
var notificationBoxCollection = context.notificationBoxCollection, makeTemplateForNotificationBoxInitialization = context.makeTemplateForNotificationBoxInitialization;
|
|
4608
4675
|
return function(params, notificationBoxDocument, transaction) {
|
|
@@ -4639,6 +4706,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4639
4706
|
*
|
|
4640
4707
|
* Wraps the in-transaction initialization in a Firestore transaction
|
|
4641
4708
|
* and follows the transform-and-validate pattern.
|
|
4709
|
+
*
|
|
4710
|
+
* @param context - the initialization context with Firestore access and template functions
|
|
4711
|
+
* @returns a transform-and-validate function that initializes a single notification box
|
|
4642
4712
|
*/ function initializeNotificationBoxFactory(context) {
|
|
4643
4713
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
4644
4714
|
var initializeNotificationBoxInTransaction = initializeNotificationBoxInTransactionFactory(context);
|
|
@@ -4679,8 +4749,11 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4679
4749
|
* Batch-processes all {@link NotificationBox} documents flagged for initialization
|
|
4680
4750
|
* by querying for entries with `s=true` (setup needed), then initializing each in
|
|
4681
4751
|
* parallel (up to 5 concurrent tasks). Loops until no more flagged boxes are found.
|
|
4752
|
+
*
|
|
4753
|
+
* @param context - the initialization context with Firestore access and collection references
|
|
4754
|
+
* @returns a transform-and-validate function that batch-initializes all applicable notification boxes
|
|
4682
4755
|
*/ function initializeAllApplicableNotificationBoxesFactory(context) {
|
|
4683
|
-
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection;
|
|
4756
|
+
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection;
|
|
4684
4757
|
var initializeNotificationBoxInTransaction = initializeNotificationBoxInTransactionFactory(context);
|
|
4685
4758
|
return firebaseServerActionTransformFunctionFactory(initializeAllApplicableNotificationBoxesParamsType, function() {
|
|
4686
4759
|
return _async_to_generator$c(function() {
|
|
@@ -4796,6 +4869,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4796
4869
|
*
|
|
4797
4870
|
* Loads the summary document in the transaction, reads its current data, and delegates
|
|
4798
4871
|
* to {@link initializeNotificationModelInTransaction} with the summary-specific template function.
|
|
4872
|
+
*
|
|
4873
|
+
* @param context - the initialization context with collection references and template functions
|
|
4874
|
+
* @returns an async function that initializes a notification summary given params, document, and transaction
|
|
4799
4875
|
*/ function initializeNotificationSummaryInTransactionFactory(context) {
|
|
4800
4876
|
var notificationSummaryCollection = context.notificationSummaryCollection, makeTemplateForNotificationSummaryInitialization = context.makeTemplateForNotificationSummaryInitialization;
|
|
4801
4877
|
return function(params, notificationSummaryDocument, transaction) {
|
|
@@ -4832,6 +4908,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4832
4908
|
*
|
|
4833
4909
|
* Wraps the in-transaction summary initialization in a Firestore transaction
|
|
4834
4910
|
* and follows the transform-and-validate pattern.
|
|
4911
|
+
*
|
|
4912
|
+
* @param context - the initialization context with Firestore access and template functions
|
|
4913
|
+
* @returns a transform-and-validate function that initializes a single notification summary
|
|
4835
4914
|
*/ function initializeNotificationSummaryFactory(context) {
|
|
4836
4915
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
4837
4916
|
var initializeNotificationSummaryInTransaction = initializeNotificationSummaryInTransactionFactory(context);
|
|
@@ -4872,8 +4951,11 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
|
|
|
4872
4951
|
* Batch-processes all {@link NotificationSummary} documents flagged for initialization
|
|
4873
4952
|
* by querying for entries with `s=true` (setup needed), then initializing each in
|
|
4874
4953
|
* parallel (up to 5 concurrent tasks). Loops until no more flagged summaries are found.
|
|
4954
|
+
*
|
|
4955
|
+
* @param context - the initialization context with Firestore access and collection references
|
|
4956
|
+
* @returns a transform-and-validate function that batch-initializes all applicable notification summaries
|
|
4875
4957
|
*/ function initializeAllApplicableNotificationSummariesFactory(context) {
|
|
4876
|
-
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection;
|
|
4958
|
+
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection;
|
|
4877
4959
|
var initializeNotificationSummaryInTransaction = initializeNotificationSummaryInTransactionFactory(context);
|
|
4878
4960
|
return firebaseServerActionTransformFunctionFactory(initializeAllApplicableNotificationSummariesParamsType, function() {
|
|
4879
4961
|
return _async_to_generator$c(function() {
|
|
@@ -5227,6 +5309,7 @@ function _ts_generator$b(thisArg, body) {
|
|
|
5227
5309
|
* pre-wired with the resolved factory for that type.
|
|
5228
5310
|
*
|
|
5229
5311
|
* @param type - the notification template type
|
|
5312
|
+
* @returns a new {@link NotificationTemplateServiceInstance} bound to the given type
|
|
5230
5313
|
*/ key: "templateInstanceForType",
|
|
5231
5314
|
value: function templateInstanceForType(type) {
|
|
5232
5315
|
return notificationTemplateServiceInstance(this, type);
|
|
@@ -5248,6 +5331,7 @@ NotificationTemplateService = __decorate([
|
|
|
5248
5331
|
*
|
|
5249
5332
|
* @param service - the parent template service
|
|
5250
5333
|
* @param type - the template type to bind
|
|
5334
|
+
* @returns a {@link NotificationTemplateServiceInstance} with the resolved factory for the type
|
|
5251
5335
|
*
|
|
5252
5336
|
* @example
|
|
5253
5337
|
* ```ts
|
|
@@ -5469,6 +5553,7 @@ function _ts_generator$a(thisArg, body) {
|
|
|
5469
5553
|
* Does not support Firestore transactions, as running should occur outside of a transaction.
|
|
5470
5554
|
*
|
|
5471
5555
|
* @param input - creation and run configuration
|
|
5556
|
+
* @returns the creation pair result with optional send/enqueue outcomes
|
|
5472
5557
|
* @throws Error if the notification template is not flagged as unique
|
|
5473
5558
|
*
|
|
5474
5559
|
* @example
|
|
@@ -5827,8 +5912,8 @@ function _ts_generator$9(thisArg, body) {
|
|
|
5827
5912
|
/**
|
|
5828
5913
|
* Creates a new NotificationExpediteServiceInstance with the input NotificationExpediteService.
|
|
5829
5914
|
|
|
5830
|
-
* @param notificationExpediteService
|
|
5831
|
-
* @returns
|
|
5915
|
+
* @param notificationExpediteService - the expedite service to use for sending
|
|
5916
|
+
* @returns a new {@link NotificationExpediteServiceInstance} with an internal queue
|
|
5832
5917
|
*/ function notificationExpediteServiceInstance(notificationExpediteService) {
|
|
5833
5918
|
var _documentsToSend = [];
|
|
5834
5919
|
var initialize = function initialize() {
|
|
@@ -5847,28 +5932,18 @@ function _ts_generator$9(thisArg, body) {
|
|
|
5847
5932
|
};
|
|
5848
5933
|
var send = function send(options) {
|
|
5849
5934
|
return _async_to_generator$9(function() {
|
|
5850
|
-
var results;
|
|
5851
5935
|
return _ts_generator$9(this, function(_state) {
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
})
|
|
5864
|
-
];
|
|
5865
|
-
case 1:
|
|
5866
|
-
results = _state.sent();
|
|
5867
|
-
return [
|
|
5868
|
-
2,
|
|
5869
|
-
results
|
|
5870
|
-
];
|
|
5871
|
-
}
|
|
5936
|
+
return [
|
|
5937
|
+
2,
|
|
5938
|
+
runAsyncTasksForValues(_documentsToSend, function(x) {
|
|
5939
|
+
return notificationExpediteService.sendNotification(x, options);
|
|
5940
|
+
}, {
|
|
5941
|
+
nonConcurrentTaskKeyFactory: function nonConcurrentTaskKeyFactory(x) {
|
|
5942
|
+
return x.parent.id // only send one notification at a time for a notification box
|
|
5943
|
+
;
|
|
5944
|
+
}
|
|
5945
|
+
})
|
|
5946
|
+
];
|
|
5872
5947
|
});
|
|
5873
5948
|
})();
|
|
5874
5949
|
};
|
|
@@ -5896,6 +5971,8 @@ function _ts_generator$9(thisArg, body) {
|
|
|
5896
5971
|
{
|
|
5897
5972
|
/**
|
|
5898
5973
|
* Returns the configured NotificationServerActions instance.
|
|
5974
|
+
*
|
|
5975
|
+
* @returns the current {@link NotificationServerActions} instance
|
|
5899
5976
|
*/ key: "getNotificationServerActions",
|
|
5900
5977
|
value: function getNotificationServerActions() {
|
|
5901
5978
|
return this._notificationServerActions;
|
|
@@ -5904,6 +5981,8 @@ function _ts_generator$9(thisArg, body) {
|
|
|
5904
5981
|
{
|
|
5905
5982
|
/**
|
|
5906
5983
|
* Sets the NotificationServerActions instance to use.
|
|
5984
|
+
*
|
|
5985
|
+
* @param notificationServerActions - the actions instance to configure
|
|
5907
5986
|
*/ key: "setNotificationServerActions",
|
|
5908
5987
|
value: function setNotificationServerActions(notificationServerActions) {
|
|
5909
5988
|
this._notificationServerActions = notificationServerActions;
|
|
@@ -5951,6 +6030,8 @@ MutableNotificationExpediteService = __decorate([
|
|
|
5951
6030
|
* Provides an instance of MutableNotificationExpediteService and NotificationExpediteService.
|
|
5952
6031
|
*
|
|
5953
6032
|
* This should generally be used in the global module of an app.
|
|
6033
|
+
*
|
|
6034
|
+
* @returns an array of NestJS providers for both MutableNotificationExpediteService and NotificationExpediteService
|
|
5954
6035
|
*/ function provideMutableNotificationExpediteService() {
|
|
5955
6036
|
return [
|
|
5956
6037
|
MutableNotificationExpediteService,
|
|
@@ -5964,7 +6045,10 @@ MutableNotificationExpediteService = __decorate([
|
|
|
5964
6045
|
* Convenience function that exports NotificationExpediteService and MutableNotificationExpediteService.
|
|
5965
6046
|
*
|
|
5966
6047
|
* This should generally be used in the global module of an app.
|
|
5967
|
-
|
|
6048
|
+
*
|
|
6049
|
+
* @returns an array of abstract classes to export from the NestJS module
|
|
6050
|
+
*/ // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6051
|
+
function exportMutableNotificationExpediteService() {
|
|
5968
6052
|
return [
|
|
5969
6053
|
NotificationExpediteService,
|
|
5970
6054
|
MutableNotificationExpediteService
|
|
@@ -5976,7 +6060,7 @@ function _array_like_to_array$5(arr, len) {
|
|
|
5976
6060
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
5977
6061
|
return arr2;
|
|
5978
6062
|
}
|
|
5979
|
-
function _array_without_holes$
|
|
6063
|
+
function _array_without_holes$4(arr) {
|
|
5980
6064
|
if (Array.isArray(arr)) return _array_like_to_array$5(arr);
|
|
5981
6065
|
}
|
|
5982
6066
|
function _class_call_check$4(instance, Constructor) {
|
|
@@ -5997,10 +6081,10 @@ function _define_property$7(obj, key, value) {
|
|
|
5997
6081
|
}
|
|
5998
6082
|
return obj;
|
|
5999
6083
|
}
|
|
6000
|
-
function _iterable_to_array$
|
|
6084
|
+
function _iterable_to_array$4(iter) {
|
|
6001
6085
|
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6002
6086
|
}
|
|
6003
|
-
function _non_iterable_spread$
|
|
6087
|
+
function _non_iterable_spread$4() {
|
|
6004
6088
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6005
6089
|
}
|
|
6006
6090
|
function _object_spread$7(target) {
|
|
@@ -6037,8 +6121,8 @@ function _object_spread_props$7(target, source) {
|
|
|
6037
6121
|
}
|
|
6038
6122
|
return target;
|
|
6039
6123
|
}
|
|
6040
|
-
function _to_consumable_array$
|
|
6041
|
-
return _array_without_holes$
|
|
6124
|
+
function _to_consumable_array$4(arr) {
|
|
6125
|
+
return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$4();
|
|
6042
6126
|
}
|
|
6043
6127
|
function _unsupported_iterable_to_array$5(o, minLen) {
|
|
6044
6128
|
if (!o) return;
|
|
@@ -6052,7 +6136,15 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6052
6136
|
/**
|
|
6053
6137
|
* Factory that assembles the full {@link NotificationServerActionsContext} by combining
|
|
6054
6138
|
* the base context with the template, send, task, and expedite services.
|
|
6055
|
-
|
|
6139
|
+
*
|
|
6140
|
+
* @param context - the base server actions context
|
|
6141
|
+
* @param notificationTemplateService - resolves message factories for notification template types
|
|
6142
|
+
* @param notificationSendService - handles sending notification messages
|
|
6143
|
+
* @param notificationTaskService - handles notification task dispatch
|
|
6144
|
+
* @param notificationsExpediteService - expedites immediate notification delivery
|
|
6145
|
+
* @returns the assembled {@link NotificationServerActionsContext}
|
|
6146
|
+
*/ // eslint-disable-next-line @typescript-eslint/max-params
|
|
6147
|
+
function notificationServerActionsContextFactory(context, notificationTemplateService, notificationSendService, notificationTaskService, notificationsExpediteService) {
|
|
6056
6148
|
return _object_spread_props$7(_object_spread$7({}, context), {
|
|
6057
6149
|
notificationTemplateService: notificationTemplateService,
|
|
6058
6150
|
notificationSendService: notificationSendService,
|
|
@@ -6062,12 +6154,19 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6062
6154
|
}
|
|
6063
6155
|
/**
|
|
6064
6156
|
* Factory that creates a {@link NotificationServerActions} instance from the assembled context.
|
|
6065
|
-
|
|
6157
|
+
*
|
|
6158
|
+
* @param context - the assembled notification server actions context
|
|
6159
|
+
* @returns a new {@link NotificationServerActions} instance
|
|
6160
|
+
*/ function notificationServerActionsFactory(context) {
|
|
6066
6161
|
return notificationServerActions(context);
|
|
6067
6162
|
}
|
|
6068
6163
|
/**
|
|
6069
6164
|
* Factory that creates a {@link NotificationInitServerActions} instance by merging the
|
|
6070
6165
|
* server actions context with the init-specific configuration.
|
|
6166
|
+
*
|
|
6167
|
+
* @param context - the assembled notification server actions context
|
|
6168
|
+
* @param notificationInitServerActionsContextConfig - init-specific configuration
|
|
6169
|
+
* @returns a new {@link NotificationInitServerActions} instance
|
|
6071
6170
|
*/ function notificationInitServerActionsFactory(context, notificationInitServerActionsContextConfig) {
|
|
6072
6171
|
return notificationInitServerActions(_object_spread$7({}, context, notificationInitServerActionsContextConfig));
|
|
6073
6172
|
}
|
|
@@ -6083,9 +6182,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6083
6182
|
*
|
|
6084
6183
|
* Be sure the class that delares the module using this function also extends AbstractAppNotificationModule.
|
|
6085
6184
|
*
|
|
6086
|
-
* @param
|
|
6087
|
-
* @
|
|
6088
|
-
* @returns
|
|
6185
|
+
* @param config - module metadata configuration including dependency module and additional providers
|
|
6186
|
+
* @returns the assembled {@link ModuleMetadata} for the notification module
|
|
6089
6187
|
*/ function appNotificationModuleMetadata(config) {
|
|
6090
6188
|
var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
|
|
6091
6189
|
var dependencyModuleImport = dependencyModule ? [
|
|
@@ -6094,14 +6192,14 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6094
6192
|
return {
|
|
6095
6193
|
imports: [
|
|
6096
6194
|
ConfigModule
|
|
6097
|
-
].concat(_to_consumable_array$
|
|
6195
|
+
].concat(_to_consumable_array$4(dependencyModuleImport), _to_consumable_array$4(imports !== null && imports !== void 0 ? imports : [])),
|
|
6098
6196
|
exports: [
|
|
6099
6197
|
NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN,
|
|
6100
6198
|
NotificationExpediteService,
|
|
6101
6199
|
NotificationTemplateService,
|
|
6102
6200
|
NotificationServerActions,
|
|
6103
6201
|
NotificationInitServerActions
|
|
6104
|
-
].concat(_to_consumable_array$
|
|
6202
|
+
].concat(_to_consumable_array$4(exports$1 !== null && exports$1 !== void 0 ? exports$1 : [])),
|
|
6105
6203
|
providers: [
|
|
6106
6204
|
{
|
|
6107
6205
|
provide: NotificationExpediteService,
|
|
@@ -6126,8 +6224,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6126
6224
|
provide: NotificationServerActions,
|
|
6127
6225
|
useFactory: notificationServerActionsFactory,
|
|
6128
6226
|
inject: [
|
|
6129
|
-
NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN
|
|
6130
|
-
NotificationExpediteService
|
|
6227
|
+
NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN
|
|
6131
6228
|
]
|
|
6132
6229
|
},
|
|
6133
6230
|
{
|
|
@@ -6138,7 +6235,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
6138
6235
|
NOTIFICATION_INIT_SERVER_ACTIONS_CONTEXT_CONFIG_TOKEN
|
|
6139
6236
|
]
|
|
6140
6237
|
}
|
|
6141
|
-
].concat(_to_consumable_array$
|
|
6238
|
+
].concat(_to_consumable_array$4(providers !== null && providers !== void 0 ? providers : []))
|
|
6142
6239
|
};
|
|
6143
6240
|
}
|
|
6144
6241
|
/**
|
|
@@ -6173,6 +6270,9 @@ function _array_like_to_array$4(arr, len) {
|
|
|
6173
6270
|
function _array_with_holes$1(arr) {
|
|
6174
6271
|
if (Array.isArray(arr)) return arr;
|
|
6175
6272
|
}
|
|
6273
|
+
function _array_without_holes$3(arr) {
|
|
6274
|
+
if (Array.isArray(arr)) return _array_like_to_array$4(arr);
|
|
6275
|
+
}
|
|
6176
6276
|
function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
|
|
6177
6277
|
try {
|
|
6178
6278
|
var info = gen[key](arg);
|
|
@@ -6215,6 +6315,9 @@ function _define_property$6(obj, key, value) {
|
|
|
6215
6315
|
}
|
|
6216
6316
|
return obj;
|
|
6217
6317
|
}
|
|
6318
|
+
function _iterable_to_array$3(iter) {
|
|
6319
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
6320
|
+
}
|
|
6218
6321
|
function _iterable_to_array_limit$1(arr, i) {
|
|
6219
6322
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
6220
6323
|
if (_i == null) return;
|
|
@@ -6242,6 +6345,9 @@ function _iterable_to_array_limit$1(arr, i) {
|
|
|
6242
6345
|
function _non_iterable_rest$1() {
|
|
6243
6346
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6244
6347
|
}
|
|
6348
|
+
function _non_iterable_spread$3() {
|
|
6349
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
6350
|
+
}
|
|
6245
6351
|
function _object_spread$6(target) {
|
|
6246
6352
|
for(var i = 1; i < arguments.length; i++){
|
|
6247
6353
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -6279,6 +6385,9 @@ function _object_spread_props$6(target, source) {
|
|
|
6279
6385
|
function _sliced_to_array$1(arr, i) {
|
|
6280
6386
|
return _array_with_holes$1(arr) || _iterable_to_array_limit$1(arr, i) || _unsupported_iterable_to_array$4(arr, i) || _non_iterable_rest$1();
|
|
6281
6387
|
}
|
|
6388
|
+
function _to_consumable_array$3(arr) {
|
|
6389
|
+
return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$3();
|
|
6390
|
+
}
|
|
6282
6391
|
function _unsupported_iterable_to_array$4(o, minLen) {
|
|
6283
6392
|
if (!o) return;
|
|
6284
6393
|
if (typeof o === "string") return _array_like_to_array$4(o, minLen);
|
|
@@ -6397,6 +6506,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
6397
6506
|
* Each summary update runs in a Firestore transaction to prevent concurrent write conflicts.
|
|
6398
6507
|
*
|
|
6399
6508
|
* @param config - service configuration including Firestore context and collection references
|
|
6509
|
+
* @returns a {@link NotificationSummarySendService} backed by Firestore
|
|
6400
6510
|
*
|
|
6401
6511
|
* @example
|
|
6402
6512
|
* ```ts
|
|
@@ -6430,6 +6540,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
6430
6540
|
cutMessage = cutStringFunction({
|
|
6431
6541
|
maxLength: NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_MESSAGE_MAX_LENGTH
|
|
6432
6542
|
});
|
|
6543
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
6433
6544
|
messagesGroups = messagesGroupedByNotificationSummaryMapBuilder.entries();
|
|
6434
6545
|
return [
|
|
6435
6546
|
2,
|
|
@@ -6476,7 +6587,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
6476
6587
|
});
|
|
6477
6588
|
if (messagesToSend.length > 0) {
|
|
6478
6589
|
// add the new items to existing n, then keep the last 1000
|
|
6479
|
-
sortedN = existingMessages.concat(messagesToSend.map(function(x) {
|
|
6590
|
+
sortedN = _to_consumable_array$3(existingMessages).concat(_to_consumable_array$3(messagesToSend.map(function(x) {
|
|
6480
6591
|
var message = '';
|
|
6481
6592
|
if (x.content.openingMessage) {
|
|
6482
6593
|
message = x.content.openingMessage;
|
|
@@ -6489,7 +6600,7 @@ function _ts_generator$8(thisArg, body) {
|
|
|
6489
6600
|
g: cutMessage(message)
|
|
6490
6601
|
});
|
|
6491
6602
|
return item;
|
|
6492
|
-
})).sort(sortNotificationItemsFunction);
|
|
6603
|
+
}))).sort(sortNotificationItemsFunction);
|
|
6493
6604
|
n = takeLast(sortedN, NOTIFICATION_SUMMARY_ITEM_LIMIT);
|
|
6494
6605
|
updateTemplate = {
|
|
6495
6606
|
n: n,
|
|
@@ -6717,6 +6828,8 @@ function _ts_generator$7(thisArg, body) {
|
|
|
6717
6828
|
* Useful as a placeholder when your app's notification pipeline is fully wired for SMS
|
|
6718
6829
|
* but actual delivery is not yet enabled, avoiding the need for conditional logic elsewhere.
|
|
6719
6830
|
*
|
|
6831
|
+
* @returns a no-op {@link NotificationTextSendService} that ignores all messages
|
|
6832
|
+
*
|
|
6720
6833
|
* @example
|
|
6721
6834
|
* ```ts
|
|
6722
6835
|
* const textService = ignoreSendNotificationTextSendService();
|
|
@@ -6896,6 +7009,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
6896
7009
|
* If all checkpoints are complete, the task is marked as done.
|
|
6897
7010
|
*
|
|
6898
7011
|
* @param config - handler configurations and optional validation list
|
|
7012
|
+
* @returns a {@link NotificationTaskService} that dispatches tasks to the registered handlers
|
|
6899
7013
|
*
|
|
6900
7014
|
* @example
|
|
6901
7015
|
* ```ts
|
|
@@ -6918,6 +7032,7 @@ function _ts_generator$6(thisArg, body) {
|
|
|
6918
7032
|
var type = handlerConfig.type;
|
|
6919
7033
|
handlers[type] = handlerForConfig(handlerConfig);
|
|
6920
7034
|
});
|
|
7035
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6921
7036
|
function handlerForConfig(handlerConfig) {
|
|
6922
7037
|
var inputFlows = handlerConfig.flow, allowRunMultipleParts = handlerConfig.allowRunMultipleParts;
|
|
6923
7038
|
var _separateValues = separateValues(inputFlows, function(x) {
|
|
@@ -6941,14 +7056,16 @@ function _ts_generator$6(thisArg, body) {
|
|
|
6941
7056
|
fn = (_this = (_nonCheckpointFlows_ = nonCheckpointFlows[0]) !== null && _nonCheckpointFlows_ !== void 0 ? _nonCheckpointFlows_ : checkpointFlows[0]) === null || _this === void 0 ? void 0 : _this.fn;
|
|
6942
7057
|
break;
|
|
6943
7058
|
default:
|
|
6944
|
-
|
|
6945
|
-
|
|
7059
|
+
{
|
|
7060
|
+
completedCheckpointsSet = new Set(completedCheckpoints);
|
|
7061
|
+
/**
|
|
6946
7062
|
* Find the next flow function that hasn't had its checkpoint completed yet.
|
|
6947
7063
|
*/ nextCheckpoint = checkpointFlows.find(function(x) {
|
|
6948
|
-
|
|
6949
|
-
|
|
6950
|
-
|
|
6951
|
-
|
|
7064
|
+
return !completedCheckpointsSet.has(x.checkpoint);
|
|
7065
|
+
});
|
|
7066
|
+
fn = nextCheckpoint === null || nextCheckpoint === void 0 ? void 0 : nextCheckpoint.fn;
|
|
7067
|
+
break;
|
|
7068
|
+
}
|
|
6952
7069
|
}
|
|
6953
7070
|
if (!fn) return [
|
|
6954
7071
|
3,
|
|
@@ -7275,6 +7392,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7275
7392
|
* such as storage file processing or other async workflows.
|
|
7276
7393
|
*
|
|
7277
7394
|
* @param factoryConfig - shared configuration including the input function, cleanup logic, and task type
|
|
7395
|
+
* @returns a factory function that produces {@link NotificationTaskServiceTaskHandlerConfig} entries
|
|
7278
7396
|
*
|
|
7279
7397
|
* @example
|
|
7280
7398
|
* ```ts
|
|
@@ -7297,6 +7415,9 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7297
7415
|
return function(subtaskHandlerConfig) {
|
|
7298
7416
|
var processorFunctionForConfig = /**
|
|
7299
7417
|
* Structure is similar to notificationTaskService(), but contained to handle the subtasks.
|
|
7418
|
+
*
|
|
7419
|
+
* @param processorConfig - the processor configuration with target, flow, and cleanup
|
|
7420
|
+
* @returns a processor with process and optional cleanup functions
|
|
7300
7421
|
*/ function processorFunctionForConfig(processorConfig) {
|
|
7301
7422
|
var inputFlows = processorConfig.flow, cleanup = processorConfig.cleanup, processorAllowRunMultipleParts = processorConfig.allowRunMultipleParts;
|
|
7302
7423
|
var _separateValues = separateValues(inputFlows, function(x) {
|
|
@@ -7324,14 +7445,16 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7324
7445
|
fn = (_this = (_nonSubtaskFlows_ = nonSubtaskFlows[0]) !== null && _nonSubtaskFlows_ !== void 0 ? _nonSubtaskFlows_ : subtaskFlows[0]) === null || _this === void 0 ? void 0 : _this.fn;
|
|
7325
7446
|
break;
|
|
7326
7447
|
default:
|
|
7327
|
-
|
|
7328
|
-
|
|
7448
|
+
{
|
|
7449
|
+
completedSubtasksSet = new Set(completedSubtasks);
|
|
7450
|
+
/**
|
|
7329
7451
|
* Find the next flow function that hasn't had its checkpoint completed yet.
|
|
7330
7452
|
*/ nextSubtask = subtaskFlows.find(function(x) {
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7453
|
+
return !completedSubtasksSet.has(x.subtask);
|
|
7454
|
+
});
|
|
7455
|
+
fn = nextSubtask === null || nextSubtask === void 0 ? void 0 : nextSubtask.fn;
|
|
7456
|
+
break;
|
|
7457
|
+
}
|
|
7335
7458
|
}
|
|
7336
7459
|
if (!fn) return [
|
|
7337
7460
|
3,
|
|
@@ -7356,13 +7479,15 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7356
7479
|
sfps = removeFromCompletionsArrayWithTaskResult(sfps, subtaskResult);
|
|
7357
7480
|
break;
|
|
7358
7481
|
default:
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7482
|
+
{
|
|
7483
|
+
sfps = unique(_to_consumable_array$2(removeFromCompletionsArrayWithTaskResult(sfps, subtaskResult)).concat(_to_consumable_array$2(asArray(subtaskCompletion))));
|
|
7484
|
+
completedSubtasksSet1 = new Set(sfps);
|
|
7485
|
+
incompleteSubtasks = allKnownSubtasks.filter(function(x) {
|
|
7486
|
+
return !completedSubtasksSet1.has(x);
|
|
7487
|
+
});
|
|
7488
|
+
allSubtasksDone = incompleteSubtasks.length === 0;
|
|
7489
|
+
break;
|
|
7490
|
+
}
|
|
7366
7491
|
}
|
|
7367
7492
|
// configure the update metadata result
|
|
7368
7493
|
sd = _object_spread$5({}, subtaskData, subtaskUpdateMetadata);
|
|
@@ -7576,7 +7701,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7576
7701
|
8
|
|
7577
7702
|
];
|
|
7578
7703
|
processor = processors[target];
|
|
7579
|
-
if (!(processor
|
|
7704
|
+
if (!(processor === null || processor === void 0 ? void 0 : processor.cleanup)) return [
|
|
7580
7705
|
3,
|
|
7581
7706
|
5
|
|
7582
7707
|
];
|
|
@@ -7689,12 +7814,16 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7689
7814
|
}(BaseError);
|
|
7690
7815
|
/**
|
|
7691
7816
|
* Creates a NotificationTaskSubTaskMissingRequiredDataTermination.
|
|
7817
|
+
*
|
|
7818
|
+
* @returns a new {@link NotificationTaskSubTaskMissingRequiredDataTermination} error instance
|
|
7692
7819
|
*/ function notificationTaskSubTaskMissingRequiredDataTermination() {
|
|
7693
7820
|
return new NotificationTaskSubTaskMissingRequiredDataTermination();
|
|
7694
7821
|
}
|
|
7695
7822
|
|
|
7696
7823
|
/**
|
|
7697
7824
|
* Creates an error indicating that a storage file model has already been initialized.
|
|
7825
|
+
*
|
|
7826
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_MODEL_ALREADY_INITIALIZED error code
|
|
7698
7827
|
*/ function storageFileModelAlreadyInitializedError() {
|
|
7699
7828
|
return preconditionConflictError({
|
|
7700
7829
|
message: "This model has already been initialized.",
|
|
@@ -7703,6 +7832,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7703
7832
|
}
|
|
7704
7833
|
/**
|
|
7705
7834
|
* Creates an error indicating that the StorageFile is not flagged for group sync.
|
|
7835
|
+
*
|
|
7836
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_NOT_FLAGGED_FOR_GROUPS_SYNC error code
|
|
7706
7837
|
*/ function storageFileNotFlaggedForGroupsSyncError() {
|
|
7707
7838
|
return preconditionConflictError({
|
|
7708
7839
|
message: "This StorageFile has not been flagged for sync with its groups.",
|
|
@@ -7711,6 +7842,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7711
7842
|
}
|
|
7712
7843
|
/**
|
|
7713
7844
|
* Creates an error indicating that the target uploaded file does not exist in storage.
|
|
7845
|
+
*
|
|
7846
|
+
* @returns a precondition-conflict HttpsError with the UPLOADED_FILE_DOES_NOT_EXIST error code
|
|
7714
7847
|
*/ function uploadedFileDoesNotExistError() {
|
|
7715
7848
|
return preconditionConflictError({
|
|
7716
7849
|
message: "The target uploaded file does not exist.",
|
|
@@ -7719,6 +7852,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7719
7852
|
}
|
|
7720
7853
|
/**
|
|
7721
7854
|
* Creates an error indicating that the file is not allowed to be initialized (rejected by the check function).
|
|
7855
|
+
*
|
|
7856
|
+
* @returns a precondition-conflict HttpsError with the UPLOADED_FILE_NOT_ALLOWED_TO_BE_INITIALIZED error code
|
|
7722
7857
|
*/ function uploadedFileIsNotAllowedToBeInitializedError() {
|
|
7723
7858
|
return preconditionConflictError({
|
|
7724
7859
|
message: "The target uploaded file is not allowed to be initialized.",
|
|
@@ -7729,6 +7864,7 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7729
7864
|
* Creates an error indicating that the file initialization failed with the given result type.
|
|
7730
7865
|
*
|
|
7731
7866
|
* @param data - error data containing the result type that caused the failure
|
|
7867
|
+
* @returns an internal-server HttpsError with the UPLOADED_FILE_INITIALIZATION_FAILED error code and the result type
|
|
7732
7868
|
*/ function uploadedFileInitializationFailedError(data) {
|
|
7733
7869
|
return internalServerError({
|
|
7734
7870
|
message: 'The target uploaded file initialization failed with result type "'.concat(data.resultType, '".'),
|
|
@@ -7740,6 +7876,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7740
7876
|
}
|
|
7741
7877
|
/**
|
|
7742
7878
|
* Creates an error indicating that the initialization result was discarded (e.g., the created file no longer exists).
|
|
7879
|
+
*
|
|
7880
|
+
* @returns an internal-server HttpsError with the UPLOADED_FILE_INITIALIZATION_DISCARDED error code
|
|
7743
7881
|
*/ function uploadedFileInitializationDiscardedError() {
|
|
7744
7882
|
return internalServerError({
|
|
7745
7883
|
message: "The target uploaded file initialization was discarded.",
|
|
@@ -7748,6 +7886,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7748
7886
|
}
|
|
7749
7887
|
/**
|
|
7750
7888
|
* Creates an error indicating that the StorageFile is not in a valid state for processing.
|
|
7889
|
+
*
|
|
7890
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_ALLOWED_FOR_INVALID_STATE error code
|
|
7751
7891
|
*/ function storageFileProcessingNotAllowedForInvalidStateError() {
|
|
7752
7892
|
return preconditionConflictError({
|
|
7753
7893
|
message: "The target StorageFileDocument must be in an OK state to be processed and processing not flagged as SHOULD_NOT_PROCESS.",
|
|
@@ -7756,6 +7896,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7756
7896
|
}
|
|
7757
7897
|
/**
|
|
7758
7898
|
* Creates an error indicating that the StorageFile is not queued for processing.
|
|
7899
|
+
*
|
|
7900
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_QUEUED_FOR_PROCESSING error code
|
|
7759
7901
|
*/ function storageFileProcessingNotQueuedForProcessingError() {
|
|
7760
7902
|
return preconditionConflictError({
|
|
7761
7903
|
message: "The target StorageFileDocument is not queued for processing.",
|
|
@@ -7764,6 +7906,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7764
7906
|
}
|
|
7765
7907
|
/**
|
|
7766
7908
|
* Creates an error indicating that no processor is configured for the StorageFile's type.
|
|
7909
|
+
*
|
|
7910
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_AVAILABLE_FOR_TYPE error code
|
|
7767
7911
|
*/ function storageFileProcessingNotAvailableForTypeError() {
|
|
7768
7912
|
return preconditionConflictError({
|
|
7769
7913
|
message: "The target StorageFileDocument is not available for processing.",
|
|
@@ -7772,6 +7916,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7772
7916
|
}
|
|
7773
7917
|
/**
|
|
7774
7918
|
* Creates an error indicating that the StorageFile has already finished processing.
|
|
7919
|
+
*
|
|
7920
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_ALREADY_PROCESSED error code
|
|
7775
7921
|
*/ function storageFileAlreadyProcessedError() {
|
|
7776
7922
|
return preconditionConflictError({
|
|
7777
7923
|
message: "The target StorageFileDocument has already finished processing.",
|
|
@@ -7780,6 +7926,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7780
7926
|
}
|
|
7781
7927
|
/**
|
|
7782
7928
|
* Creates an error indicating that the StorageFile is not flagged for deletion.
|
|
7929
|
+
*
|
|
7930
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_NOT_FLAGGED_FOR_DELETION error code
|
|
7783
7931
|
*/ function storageFileNotFlaggedForDeletionError() {
|
|
7784
7932
|
return preconditionConflictError({
|
|
7785
7933
|
message: "The target StorageFileDocument is not flagged for deletion.",
|
|
@@ -7788,6 +7936,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7788
7936
|
}
|
|
7789
7937
|
/**
|
|
7790
7938
|
* Creates an error indicating that the StorageFile's scheduled deletion time has not yet passed.
|
|
7939
|
+
*
|
|
7940
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_CANNOT_BE_DELETED_YET error code
|
|
7791
7941
|
*/ function storageFileCannotBeDeletedYetError() {
|
|
7792
7942
|
return preconditionConflictError({
|
|
7793
7943
|
message: "The target StorageFileDocument cannot be deleted yet.",
|
|
@@ -7796,6 +7946,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7796
7946
|
}
|
|
7797
7947
|
/**
|
|
7798
7948
|
* Creates an error indicating that the StorageFileGroup is still queued for initialization and cannot be operated on.
|
|
7949
|
+
*
|
|
7950
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_GROUP_QUEUED_FOR_INITIALIZATION error code
|
|
7799
7951
|
*/ function storageFileGroupQueuedForInitializationError() {
|
|
7800
7952
|
return preconditionConflictError({
|
|
7801
7953
|
message: "The target StorageFileGroupDocument is queued for initialization.",
|
|
@@ -7804,6 +7956,8 @@ function _ts_generator$5(thisArg, body) {
|
|
|
7804
7956
|
}
|
|
7805
7957
|
/**
|
|
7806
7958
|
* Creates an error indicating that the required model key or storageFileId is missing when creating a StorageFileGroup.
|
|
7959
|
+
*
|
|
7960
|
+
* @returns a precondition-conflict HttpsError with the STORAGE_FILE_GROUP_CREATE_INPUT error code
|
|
7807
7961
|
*/ function createStorageFileGroupInputError() {
|
|
7808
7962
|
return preconditionConflictError({
|
|
7809
7963
|
message: "The model or storageFileId is required for creating a StorageFileGroup.",
|
|
@@ -7893,10 +8047,6 @@ function _iterable_to_array_limit(arr, i) {
|
|
|
7893
8047
|
function _non_iterable_rest() {
|
|
7894
8048
|
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
7895
8049
|
}
|
|
7896
|
-
function _object_destructuring_empty(o) {
|
|
7897
|
-
if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
|
|
7898
|
-
return o;
|
|
7899
|
-
}
|
|
7900
8050
|
function _object_spread$4(target) {
|
|
7901
8051
|
for(var i = 1; i < arguments.length; i++){
|
|
7902
8052
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
@@ -8073,6 +8223,9 @@ function _ts_generator$4(thisArg, body) {
|
|
|
8073
8223
|
*
|
|
8074
8224
|
* @param context - the fully assembled storage file server actions context
|
|
8075
8225
|
*
|
|
8226
|
+
* @param context - the fully assembled storage file server actions context
|
|
8227
|
+
* @returns a concrete {@link StorageFileServerActions} with all action methods wired to their factories
|
|
8228
|
+
*
|
|
8076
8229
|
* @example
|
|
8077
8230
|
* ```ts
|
|
8078
8231
|
* const actions = storageFileServerActions(context);
|
|
@@ -8103,23 +8256,23 @@ function _ts_generator$4(thisArg, body) {
|
|
|
8103
8256
|
* Factory for the `createStorageFile` action.
|
|
8104
8257
|
*
|
|
8105
8258
|
* Creates a new {@link StorageFile} document using the provided template data.
|
|
8259
|
+
*
|
|
8260
|
+
* @param context - the base server actions context providing Firestore and storage access
|
|
8261
|
+
* @returns an async transform-and-validate function that creates a StorageFile document
|
|
8106
8262
|
*/ function createStorageFileFactory(context) {
|
|
8107
|
-
|
|
8263
|
+
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8108
8264
|
return firebaseServerActionTransformFunctionFactory(createStorageFileParamsType, function(params) {
|
|
8109
8265
|
return _async_to_generator$4(function() {
|
|
8110
8266
|
return _ts_generator$4(this, function(_state) {
|
|
8111
|
-
_object_destructuring_empty(params);
|
|
8112
8267
|
return [
|
|
8113
8268
|
2,
|
|
8114
8269
|
function() {
|
|
8115
8270
|
return _async_to_generator$4(function() {
|
|
8116
|
-
var storageFileDocument;
|
|
8117
8271
|
return _ts_generator$4(this, function(_state) {
|
|
8118
|
-
storageFileDocument = null;
|
|
8119
8272
|
// TODO: check the file exists, and pull the metadata, and create the document
|
|
8120
8273
|
return [
|
|
8121
8274
|
2,
|
|
8122
|
-
|
|
8275
|
+
null
|
|
8123
8276
|
];
|
|
8124
8277
|
});
|
|
8125
8278
|
})();
|
|
@@ -8135,6 +8288,9 @@ function _ts_generator$4(thisArg, body) {
|
|
|
8135
8288
|
* Scans the uploads folder in Firebase Storage, identifies new uploaded files,
|
|
8136
8289
|
* initializes each one via the upload service, and cleans up the source upload
|
|
8137
8290
|
* on success. Failed initializations are logged but do not halt the batch.
|
|
8291
|
+
*
|
|
8292
|
+
* @param context - the storage file server actions context with storage service and upload initialization
|
|
8293
|
+
* @returns an async transform-and-validate function that returns batch initialization results
|
|
8138
8294
|
*/ function initializeAllStorageFilesFromUploadsFactory(context) {
|
|
8139
8295
|
var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8140
8296
|
var _initializeStorageFileFromUploadFile = _initializeStorageFileFromUploadFileFactory(context);
|
|
@@ -8228,7 +8384,15 @@ function _ts_generator$4(thisArg, body) {
|
|
|
8228
8384
|
})();
|
|
8229
8385
|
});
|
|
8230
8386
|
}
|
|
8231
|
-
|
|
8387
|
+
/**
|
|
8388
|
+
* Internal factory that creates a function to initialize a {@link StorageFile} from an uploaded file.
|
|
8389
|
+
*
|
|
8390
|
+
* Validates the file exists and is allowed, runs the upload initializer, deletes the upload source
|
|
8391
|
+
* on success, and optionally expedites processing of the created storage file.
|
|
8392
|
+
*
|
|
8393
|
+
* @param context - the storage file server actions context
|
|
8394
|
+
* @returns an async function that accepts an upload file input and returns the created StorageFileDocument
|
|
8395
|
+
*/ function _initializeStorageFileFromUploadFileFactory(context) {
|
|
8232
8396
|
var firestoreContext = context.firestoreContext, storageFileInitializeFromUploadService = context.storageFileInitializeFromUploadService, notificationExpediteService = context.notificationExpediteService;
|
|
8233
8397
|
var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
|
|
8234
8398
|
return function(input) {
|
|
@@ -8356,7 +8520,7 @@ function _initializeStorageFileFromUploadFileFactory(context) {
|
|
|
8356
8520
|
11
|
|
8357
8521
|
];
|
|
8358
8522
|
storageFileDocument = initializationResult.storageFileDocument;
|
|
8359
|
-
if (!
|
|
8523
|
+
if (!expediteProcessing) return [
|
|
8360
8524
|
3,
|
|
8361
8525
|
10
|
|
8362
8526
|
];
|
|
@@ -8492,6 +8656,9 @@ function _initializeStorageFileFromUploadFileFactory(context) {
|
|
|
8492
8656
|
* Initializes a single {@link StorageFile} from an uploaded file at the given storage path.
|
|
8493
8657
|
* Validates the file exists and is allowed, runs the type determiner and initializer,
|
|
8494
8658
|
* then cleans up the upload source on success.
|
|
8659
|
+
*
|
|
8660
|
+
* @param context - the storage file server actions context with storage and upload services
|
|
8661
|
+
* @returns an async transform-and-validate function that creates a StorageFile from an upload
|
|
8495
8662
|
*/ function initializeStorageFileFromUploadFactory(context) {
|
|
8496
8663
|
var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8497
8664
|
var _initializeStorageFileFromUploadFile = _initializeStorageFileFromUploadFileFactory(context);
|
|
@@ -8525,8 +8692,15 @@ function _initializeStorageFileFromUploadFileFactory(context) {
|
|
|
8525
8692
|
})();
|
|
8526
8693
|
});
|
|
8527
8694
|
}
|
|
8528
|
-
|
|
8529
|
-
|
|
8695
|
+
/**
|
|
8696
|
+
* Factory for the `updateStorageFile` action.
|
|
8697
|
+
*
|
|
8698
|
+
* Updates an existing {@link StorageFile} document with the provided schedule-delete-at time.
|
|
8699
|
+
*
|
|
8700
|
+
* @param context - the base server actions context providing Firestore access
|
|
8701
|
+
* @returns an async transform-and-validate function that updates a StorageFile document
|
|
8702
|
+
*/ function updateStorageFileFactory(context) {
|
|
8703
|
+
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8530
8704
|
return firebaseServerActionTransformFunctionFactory(updateStorageFileParamsType, function(params) {
|
|
8531
8705
|
return _async_to_generator$4(function() {
|
|
8532
8706
|
var sdat;
|
|
@@ -8562,7 +8736,15 @@ function updateStorageFileFactory(context) {
|
|
|
8562
8736
|
})();
|
|
8563
8737
|
});
|
|
8564
8738
|
}
|
|
8565
|
-
|
|
8739
|
+
/**
|
|
8740
|
+
* Factory for the `updateStorageFileGroup` action.
|
|
8741
|
+
*
|
|
8742
|
+
* Updates embedded file entries within a {@link StorageFileGroup} document inside a
|
|
8743
|
+
* Firestore transaction, merging display name changes into the existing entries.
|
|
8744
|
+
*
|
|
8745
|
+
* @param context - the storage file server actions context
|
|
8746
|
+
* @returns an async transform-and-validate function that updates a StorageFileGroup document
|
|
8747
|
+
*/ function updateStorageFileGroupFactory(context) {
|
|
8566
8748
|
var firestoreContext = context.firestoreContext, storageFileGroupCollection = context.storageFileGroupCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8567
8749
|
return firebaseServerActionTransformFunctionFactory(updateStorageFileGroupParamsType, function(params) {
|
|
8568
8750
|
return _async_to_generator$4(function() {
|
|
@@ -8644,10 +8826,13 @@ function updateStorageFileGroupFactory(context) {
|
|
|
8644
8826
|
* Batch-processes all {@link StorageFile} documents queued for processing. Creates a
|
|
8645
8827
|
* processing notification task for each file and optionally expedites delivery.
|
|
8646
8828
|
* Handles stuck-processing detection with a throttle check.
|
|
8829
|
+
*
|
|
8830
|
+
* @param context - the storage file server actions context
|
|
8831
|
+
* @returns an async transform-and-validate function that returns batch processing results
|
|
8647
8832
|
*/ function processAllQueuedStorageFilesFactory(context) {
|
|
8648
8833
|
var storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8649
8834
|
var processStorageFile = processStorageFileFactory(context);
|
|
8650
|
-
return firebaseServerActionTransformFunctionFactory(processAllQueuedStorageFilesParamsType, function(
|
|
8835
|
+
return firebaseServerActionTransformFunctionFactory(processAllQueuedStorageFilesParamsType, function(_params) {
|
|
8651
8836
|
return _async_to_generator$4(function() {
|
|
8652
8837
|
return _ts_generator$4(this, function(_state) {
|
|
8653
8838
|
return [
|
|
@@ -8731,7 +8916,15 @@ function updateStorageFileGroupFactory(context) {
|
|
|
8731
8916
|
})();
|
|
8732
8917
|
});
|
|
8733
8918
|
}
|
|
8734
|
-
|
|
8919
|
+
/**
|
|
8920
|
+
* Internal factory that creates a function for processing a {@link StorageFile} within a Firestore transaction.
|
|
8921
|
+
*
|
|
8922
|
+
* Creates or restarts a notification task for the file based on its current processing state,
|
|
8923
|
+
* handling stuck-processing detection, forced restarts, and re-processing of already-successful files.
|
|
8924
|
+
*
|
|
8925
|
+
* @param context - the storage file server actions context
|
|
8926
|
+
* @returns an async function that processes a storage file within a transaction
|
|
8927
|
+
*/ function _processStorageFileInTransactionFactory(context) {
|
|
8735
8928
|
var storageFileCollection = context.storageFileCollection, notificationCollectionGroup = context.notificationCollectionGroup;
|
|
8736
8929
|
return function(input, transaction) {
|
|
8737
8930
|
return _async_to_generator$4(function() {
|
|
@@ -8821,20 +9014,30 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
8821
9014
|
3,
|
|
8822
9015
|
10
|
|
8823
9016
|
];
|
|
8824
|
-
case StorageFileProcessingState.
|
|
9017
|
+
case StorageFileProcessingState.FAILED:
|
|
8825
9018
|
return [
|
|
8826
9019
|
3,
|
|
8827
9020
|
20
|
|
8828
9021
|
];
|
|
9022
|
+
case StorageFileProcessingState.DO_NOT_PROCESS:
|
|
9023
|
+
return [
|
|
9024
|
+
3,
|
|
9025
|
+
22
|
|
9026
|
+
];
|
|
8829
9027
|
case StorageFileProcessingState.SUCCESS:
|
|
8830
9028
|
return [
|
|
8831
9029
|
3,
|
|
8832
|
-
|
|
9030
|
+
23
|
|
9031
|
+
];
|
|
9032
|
+
case StorageFileProcessingState.ARCHIVED:
|
|
9033
|
+
return [
|
|
9034
|
+
3,
|
|
9035
|
+
27
|
|
8833
9036
|
];
|
|
8834
9037
|
}
|
|
8835
9038
|
return [
|
|
8836
9039
|
3,
|
|
8837
|
-
|
|
9040
|
+
28
|
|
8838
9041
|
];
|
|
8839
9042
|
case 4:
|
|
8840
9043
|
if (!!storageFile.p) return [
|
|
@@ -8853,7 +9056,7 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
8853
9056
|
case 7:
|
|
8854
9057
|
return [
|
|
8855
9058
|
3,
|
|
8856
|
-
|
|
9059
|
+
28
|
|
8857
9060
|
];
|
|
8858
9061
|
case 8:
|
|
8859
9062
|
// begin processing
|
|
@@ -8865,7 +9068,7 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
8865
9068
|
_state.sent();
|
|
8866
9069
|
return [
|
|
8867
9070
|
3,
|
|
8868
|
-
|
|
9071
|
+
28
|
|
8869
9072
|
];
|
|
8870
9073
|
case 10:
|
|
8871
9074
|
// check if the processing task is still running
|
|
@@ -8939,33 +9142,47 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
8939
9142
|
case 19:
|
|
8940
9143
|
return [
|
|
8941
9144
|
3,
|
|
8942
|
-
|
|
9145
|
+
28
|
|
8943
9146
|
];
|
|
8944
9147
|
case 20:
|
|
8945
|
-
|
|
9148
|
+
// restart processing on failure
|
|
9149
|
+
return [
|
|
9150
|
+
4,
|
|
9151
|
+
beginProcessing(true)
|
|
9152
|
+
];
|
|
8946
9153
|
case 21:
|
|
9154
|
+
_state.sent();
|
|
9155
|
+
return [
|
|
9156
|
+
3,
|
|
9157
|
+
28
|
|
9158
|
+
];
|
|
9159
|
+
case 22:
|
|
9160
|
+
throw storageFileProcessingNotQueuedForProcessingError();
|
|
9161
|
+
case 23:
|
|
8947
9162
|
if (!(forceRestartProcessing || processAgainIfSuccessful)) return [
|
|
8948
9163
|
3,
|
|
8949
|
-
|
|
9164
|
+
25
|
|
8950
9165
|
];
|
|
8951
9166
|
return [
|
|
8952
9167
|
4,
|
|
8953
9168
|
beginProcessing(true)
|
|
8954
9169
|
];
|
|
8955
|
-
case
|
|
9170
|
+
case 24:
|
|
8956
9171
|
_state.sent();
|
|
8957
9172
|
return [
|
|
8958
9173
|
3,
|
|
8959
|
-
|
|
9174
|
+
26
|
|
8960
9175
|
];
|
|
8961
|
-
case
|
|
9176
|
+
case 25:
|
|
8962
9177
|
throw storageFileAlreadyProcessedError();
|
|
8963
|
-
case
|
|
9178
|
+
case 26:
|
|
8964
9179
|
return [
|
|
8965
9180
|
3,
|
|
8966
|
-
|
|
9181
|
+
28
|
|
8967
9182
|
];
|
|
8968
|
-
case
|
|
9183
|
+
case 27:
|
|
9184
|
+
throw storageFileProcessingNotQueuedForProcessingError();
|
|
9185
|
+
case 28:
|
|
8969
9186
|
return [
|
|
8970
9187
|
2
|
|
8971
9188
|
];
|
|
@@ -8979,6 +9196,9 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
8979
9196
|
*
|
|
8980
9197
|
* Processes a single {@link StorageFile} by creating a notification task for it
|
|
8981
9198
|
* and marking it as processing. Validates the file is in a valid state for processing.
|
|
9199
|
+
*
|
|
9200
|
+
* @param context - the storage file server actions context
|
|
9201
|
+
* @returns an async transform-and-validate function that processes a single StorageFile
|
|
8982
9202
|
*/ function processStorageFileFactory(context) {
|
|
8983
9203
|
var firestoreContext = context.firestoreContext, notificationExpediteService = context.notificationExpediteService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
8984
9204
|
var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
|
|
@@ -9062,10 +9282,13 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9062
9282
|
* Batch-deletes all {@link StorageFile} documents flagged for deletion whose
|
|
9063
9283
|
* scheduled delete time has passed. Removes both the Firestore document and
|
|
9064
9284
|
* the associated file in Cloud Storage.
|
|
9285
|
+
*
|
|
9286
|
+
* @param context - the storage file server actions context
|
|
9287
|
+
* @returns an async transform-and-validate function that returns batch deletion results
|
|
9065
9288
|
*/ function deleteAllQueuedStorageFilesFactory(context) {
|
|
9066
9289
|
var storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
9067
9290
|
var deleteStorageFile = deleteStorageFileFactory(context);
|
|
9068
|
-
return firebaseServerActionTransformFunctionFactory(deleteAllQueuedStorageFilesParamsType, function(
|
|
9291
|
+
return firebaseServerActionTransformFunctionFactory(deleteAllQueuedStorageFilesParamsType, function(_params) {
|
|
9069
9292
|
return _async_to_generator$4(function() {
|
|
9070
9293
|
return _ts_generator$4(this, function(_state) {
|
|
9071
9294
|
return [
|
|
@@ -9156,6 +9379,9 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9156
9379
|
*
|
|
9157
9380
|
* Deletes a single {@link StorageFile} document and its associated Cloud Storage file.
|
|
9158
9381
|
* Validates the file is flagged for deletion and the scheduled delete time has passed.
|
|
9382
|
+
*
|
|
9383
|
+
* @param context - the storage file server actions context
|
|
9384
|
+
* @returns an async transform-and-validate function that deletes a StorageFile and its storage object
|
|
9159
9385
|
*/ function deleteStorageFileFactory(context) {
|
|
9160
9386
|
var firestoreContext = context.firestoreContext, storageService = context.storageService, storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
9161
9387
|
var syncStorageFileWithGroupsInTransaction = _syncStorageFileWithGroupsInTransactionFactory(context);
|
|
@@ -9179,17 +9405,12 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9179
9405
|
return _ts_generator$4(this, function(_state) {
|
|
9180
9406
|
switch(_state.label){
|
|
9181
9407
|
case 0:
|
|
9182
|
-
|
|
9183
|
-
4,
|
|
9184
|
-
storageFileCollection.documentAccessorForTransaction(transaction).loadDocumentFrom(inputStorageFileDocument)
|
|
9185
|
-
];
|
|
9186
|
-
case 1:
|
|
9187
|
-
storageFileDocument = _state.sent();
|
|
9408
|
+
storageFileDocument = storageFileCollection.documentAccessorForTransaction(transaction).loadDocumentFrom(inputStorageFileDocument);
|
|
9188
9409
|
return [
|
|
9189
9410
|
4,
|
|
9190
9411
|
assertSnapshotData(storageFileDocument)
|
|
9191
9412
|
];
|
|
9192
|
-
case
|
|
9413
|
+
case 1:
|
|
9193
9414
|
storageFile = _state.sent();
|
|
9194
9415
|
fileAccessor = storageService.file(storageFile);
|
|
9195
9416
|
if (!force) {
|
|
@@ -9209,7 +9430,7 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9209
9430
|
removeAllStorageFileGroups: true
|
|
9210
9431
|
}, transaction)
|
|
9211
9432
|
];
|
|
9212
|
-
case
|
|
9433
|
+
case 2:
|
|
9213
9434
|
_state.sent();
|
|
9214
9435
|
// delete the file
|
|
9215
9436
|
return [
|
|
@@ -9218,14 +9439,14 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9218
9439
|
return null;
|
|
9219
9440
|
})
|
|
9220
9441
|
];
|
|
9221
|
-
case
|
|
9442
|
+
case 3:
|
|
9222
9443
|
_state.sent();
|
|
9223
9444
|
// delete the document
|
|
9224
9445
|
return [
|
|
9225
9446
|
4,
|
|
9226
9447
|
storageFileDocument.accessor.delete()
|
|
9227
9448
|
];
|
|
9228
|
-
case
|
|
9449
|
+
case 4:
|
|
9229
9450
|
_state.sent();
|
|
9230
9451
|
return [
|
|
9231
9452
|
2
|
|
@@ -9255,6 +9476,9 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9255
9476
|
* Generates a signed download URL for a {@link StorageFile}'s associated Cloud Storage file.
|
|
9256
9477
|
* The URL expires after the configured duration. Supports loading the storage file document
|
|
9257
9478
|
* by key if not provided directly.
|
|
9479
|
+
*
|
|
9480
|
+
* @param context - the storage file server actions context
|
|
9481
|
+
* @returns an async transform-and-validate function that generates a signed download URL
|
|
9258
9482
|
*/ function downloadStorageFileFactory(context) {
|
|
9259
9483
|
var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileCollection = context.storageFileCollection;
|
|
9260
9484
|
return firebaseServerActionTransformFunctionFactory(downloadStorageFileParamsType, function(params) {
|
|
@@ -9271,9 +9495,7 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9271
9495
|
switch(_state.label){
|
|
9272
9496
|
case 0:
|
|
9273
9497
|
// if the StorageFileDocument was not provided, set it from the target key
|
|
9274
|
-
|
|
9275
|
-
storageFileDocument = storageFileCollection.documentAccessor().loadDocumentForKey(targetStorageFileDocumentKey);
|
|
9276
|
-
}
|
|
9498
|
+
storageFileDocument !== null && storageFileDocument !== void 0 ? storageFileDocument : storageFileDocument = storageFileCollection.documentAccessor().loadDocumentForKey(targetStorageFileDocumentKey);
|
|
9277
9499
|
return [
|
|
9278
9500
|
4,
|
|
9279
9501
|
assertSnapshotData(storageFileDocument)
|
|
@@ -9291,9 +9513,9 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9291
9513
|
expiresAt: expiresAt,
|
|
9292
9514
|
expiresIn: expiresIn
|
|
9293
9515
|
});
|
|
9294
|
-
downloadUrlExpiresAt = expires.getExpirationDate();
|
|
9516
|
+
downloadUrlExpiresAt = expires.getExpirationDate(); // always returns a Date when defaultExpiresFromDateToNow and expiresIn are set
|
|
9295
9517
|
// if they're not an admin, limit the expiration to a max of 30 days.
|
|
9296
|
-
if (
|
|
9518
|
+
if (!asAdmin) {
|
|
9297
9519
|
maxExpirationDate = addDays(new Date(), 30);
|
|
9298
9520
|
downloadUrlExpiresAt = findMinDate([
|
|
9299
9521
|
downloadUrlExpiresAt,
|
|
@@ -9305,7 +9527,7 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9305
9527
|
Promise.all([
|
|
9306
9528
|
fileAccessor.getSignedUrl({
|
|
9307
9529
|
action: 'read',
|
|
9308
|
-
expiresAt: downloadUrlExpiresAt
|
|
9530
|
+
expiresAt: downloadUrlExpiresAt,
|
|
9309
9531
|
responseDisposition: responseDisposition !== null && responseDisposition !== void 0 ? responseDisposition : undefined,
|
|
9310
9532
|
responseType: asAdmin ? responseContentType !== null && responseContentType !== void 0 ? responseContentType : undefined : undefined // can only be set by admins
|
|
9311
9533
|
}),
|
|
@@ -9343,7 +9565,16 @@ function _processStorageFileInTransactionFactory(context) {
|
|
|
9343
9565
|
})();
|
|
9344
9566
|
});
|
|
9345
9567
|
}
|
|
9346
|
-
|
|
9568
|
+
/**
|
|
9569
|
+
* Internal factory that creates a function for creating a {@link StorageFileGroup} document
|
|
9570
|
+
* within a Firestore transaction.
|
|
9571
|
+
*
|
|
9572
|
+
* The created group is flagged for initialization (`s=true`) and uses a dummy owner key
|
|
9573
|
+
* that will be set during the initialization step.
|
|
9574
|
+
*
|
|
9575
|
+
* @param context - the storage file server actions context
|
|
9576
|
+
* @returns an async function that creates a StorageFileGroup within a transaction
|
|
9577
|
+
*/ function createStorageFileGroupInTransactionFactory(context) {
|
|
9347
9578
|
var storageFileGroupCollection = context.storageFileGroupCollection;
|
|
9348
9579
|
return function(params, transaction) {
|
|
9349
9580
|
return _async_to_generator$4(function() {
|
|
@@ -9389,6 +9620,9 @@ function createStorageFileGroupInTransactionFactory(context) {
|
|
|
9389
9620
|
*
|
|
9390
9621
|
* Creates a new {@link StorageFileGroup} document within a Firestore transaction,
|
|
9391
9622
|
* associating it with a model key or storage file.
|
|
9623
|
+
*
|
|
9624
|
+
* @param context - the storage file server actions context
|
|
9625
|
+
* @returns an async transform-and-validate function that creates a new StorageFileGroup
|
|
9392
9626
|
*/ function createStorageFileGroupFactory(context) {
|
|
9393
9627
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
9394
9628
|
var createStorageFileGroupInTransaction = createStorageFileGroupInTransactionFactory(context);
|
|
@@ -9397,7 +9631,7 @@ function createStorageFileGroupInTransactionFactory(context) {
|
|
|
9397
9631
|
var model, storageFileId, storageFileGroupRelatedModelKey;
|
|
9398
9632
|
return _ts_generator$4(this, function(_state) {
|
|
9399
9633
|
model = params.model, storageFileId = params.storageFileId;
|
|
9400
|
-
storageFileGroupRelatedModelKey = model ? model : storageFileId ? inferKeyFromTwoWayFlatFirestoreModelKey(storageFileId) : undefined;
|
|
9634
|
+
storageFileGroupRelatedModelKey = model !== null && model !== void 0 ? model : storageFileId ? inferKeyFromTwoWayFlatFirestoreModelKey(storageFileId) : undefined;
|
|
9401
9635
|
if (!storageFileGroupRelatedModelKey) {
|
|
9402
9636
|
throw createStorageFileGroupInputError();
|
|
9403
9637
|
}
|
|
@@ -9405,42 +9639,32 @@ function createStorageFileGroupInTransactionFactory(context) {
|
|
|
9405
9639
|
2,
|
|
9406
9640
|
function() {
|
|
9407
9641
|
return _async_to_generator$4(function() {
|
|
9408
|
-
var result;
|
|
9409
9642
|
return _ts_generator$4(this, function(_state) {
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
})
|
|
9436
|
-
];
|
|
9437
|
-
case 1:
|
|
9438
|
-
result = _state.sent();
|
|
9439
|
-
return [
|
|
9440
|
-
2,
|
|
9441
|
-
result
|
|
9442
|
-
];
|
|
9443
|
-
}
|
|
9643
|
+
return [
|
|
9644
|
+
2,
|
|
9645
|
+
firestoreContext.runTransaction(function(transaction) {
|
|
9646
|
+
return _async_to_generator$4(function() {
|
|
9647
|
+
var storageFileGroupDocument;
|
|
9648
|
+
return _ts_generator$4(this, function(_state) {
|
|
9649
|
+
switch(_state.label){
|
|
9650
|
+
case 0:
|
|
9651
|
+
return [
|
|
9652
|
+
4,
|
|
9653
|
+
createStorageFileGroupInTransaction({
|
|
9654
|
+
storageFileGroupRelatedModelKey: storageFileGroupRelatedModelKey
|
|
9655
|
+
}, transaction)
|
|
9656
|
+
];
|
|
9657
|
+
case 1:
|
|
9658
|
+
storageFileGroupDocument = _state.sent().storageFileGroupDocument;
|
|
9659
|
+
return [
|
|
9660
|
+
2,
|
|
9661
|
+
storageFileGroupDocument
|
|
9662
|
+
];
|
|
9663
|
+
}
|
|
9664
|
+
});
|
|
9665
|
+
})();
|
|
9666
|
+
})
|
|
9667
|
+
];
|
|
9444
9668
|
});
|
|
9445
9669
|
})();
|
|
9446
9670
|
}
|
|
@@ -9449,12 +9673,21 @@ function createStorageFileGroupInTransactionFactory(context) {
|
|
|
9449
9673
|
})();
|
|
9450
9674
|
});
|
|
9451
9675
|
}
|
|
9452
|
-
|
|
9676
|
+
/**
|
|
9677
|
+
* Internal factory that creates a function for syncing a {@link StorageFile} with its
|
|
9678
|
+
* associated {@link StorageFileGroup} documents within a Firestore transaction.
|
|
9679
|
+
*
|
|
9680
|
+
* Adds the storage file to groups it is missing from, removes it from groups when requested,
|
|
9681
|
+
* and optionally creates new groups for references that do not yet exist.
|
|
9682
|
+
*
|
|
9683
|
+
* @param context - the storage file server actions context
|
|
9684
|
+
* @returns an async function that syncs a storage file with its groups within a transaction
|
|
9685
|
+
*/ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
9453
9686
|
var storageFileCollection = context.storageFileCollection, storageFileGroupCollection = context.storageFileGroupCollection;
|
|
9454
9687
|
var createStorageFileGroupInTransaction = createStorageFileGroupInTransactionFactory(context);
|
|
9455
9688
|
return function(input, transaction) {
|
|
9456
9689
|
return _async_to_generator$4(function() {
|
|
9457
|
-
var
|
|
9690
|
+
var storageFileDocument, inputStorageFile, force, removeAllStorageFileGroups, skipStorageFileUpdate, storageFileDocumentInTransaction, storageFileGroupDocumentAccessor, storageFile, _tmp, g, storageFileGroupDocuments, storageFileGroupPairs, storageFilesGroupsCreated, storageFilesGroupsUpdated, result;
|
|
9458
9691
|
return _ts_generator$4(this, function(_state) {
|
|
9459
9692
|
switch(_state.label){
|
|
9460
9693
|
case 0:
|
|
@@ -9483,7 +9716,7 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9483
9716
|
if (!storageFile.gs && !force) {
|
|
9484
9717
|
throw storageFileNotFlaggedForGroupsSyncError();
|
|
9485
9718
|
}
|
|
9486
|
-
g =
|
|
9719
|
+
g = storageFile.g;
|
|
9487
9720
|
storageFileGroupDocuments = loadDocumentsForIds(storageFileGroupDocumentAccessor, g);
|
|
9488
9721
|
return [
|
|
9489
9722
|
4,
|
|
@@ -9517,10 +9750,15 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9517
9750
|
3,
|
|
9518
9751
|
6
|
|
9519
9752
|
];
|
|
9753
|
+
case undefined:
|
|
9754
|
+
return [
|
|
9755
|
+
3,
|
|
9756
|
+
8
|
|
9757
|
+
];
|
|
9520
9758
|
}
|
|
9521
9759
|
return [
|
|
9522
9760
|
3,
|
|
9523
|
-
|
|
9761
|
+
9
|
|
9524
9762
|
];
|
|
9525
9763
|
case 1:
|
|
9526
9764
|
// add it if it doesn't exist
|
|
@@ -9567,7 +9805,7 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9567
9805
|
case 5:
|
|
9568
9806
|
return [
|
|
9569
9807
|
3,
|
|
9570
|
-
|
|
9808
|
+
9
|
|
9571
9809
|
];
|
|
9572
9810
|
case 6:
|
|
9573
9811
|
// remove it
|
|
@@ -9588,9 +9826,15 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9588
9826
|
storageFilesGroupsUpdated += 1;
|
|
9589
9827
|
return [
|
|
9590
9828
|
3,
|
|
9591
|
-
|
|
9829
|
+
9
|
|
9592
9830
|
];
|
|
9593
9831
|
case 8:
|
|
9832
|
+
// no change needed
|
|
9833
|
+
return [
|
|
9834
|
+
3,
|
|
9835
|
+
9
|
|
9836
|
+
];
|
|
9837
|
+
case 9:
|
|
9594
9838
|
return [
|
|
9595
9839
|
2
|
|
9596
9840
|
];
|
|
@@ -9633,8 +9877,11 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9633
9877
|
*
|
|
9634
9878
|
* Syncs a single {@link StorageFile}'s embedded data into its associated {@link StorageFileGroup}
|
|
9635
9879
|
* documents and clears the sync flag on completion.
|
|
9880
|
+
*
|
|
9881
|
+
* @param context - the storage file server actions context
|
|
9882
|
+
* @returns an async transform-and-validate function that syncs a StorageFile with its groups
|
|
9636
9883
|
*/ function syncStorageFileWithGroupsFactory(context) {
|
|
9637
|
-
var firestoreContext = context.firestoreContext
|
|
9884
|
+
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
9638
9885
|
var syncStorageFileWithGroupsInTransaction = _syncStorageFileWithGroupsInTransactionFactory(context);
|
|
9639
9886
|
return firebaseServerActionTransformFunctionFactory(syncStorageFileWithGroupsParamsType, function(params) {
|
|
9640
9887
|
return _async_to_generator$4(function() {
|
|
@@ -9676,10 +9923,13 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9676
9923
|
* Batch-processes all {@link StorageFile} documents flagged for group sync,
|
|
9677
9924
|
* updating their associated {@link StorageFileGroup} documents and flagging
|
|
9678
9925
|
* groups for content regeneration when changes occur.
|
|
9926
|
+
*
|
|
9927
|
+
* @param context - the storage file server actions context
|
|
9928
|
+
* @returns an async transform-and-validate function that returns batch sync results
|
|
9679
9929
|
*/ function syncAllFlaggedStorageFilesWithGroupsFactory(context) {
|
|
9680
9930
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileCollection = context.storageFileCollection;
|
|
9681
9931
|
var syncStorageFileWithGroups = syncStorageFileWithGroupsFactory(context);
|
|
9682
|
-
return firebaseServerActionTransformFunctionFactory(syncAllFlaggedStorageFilesWithGroupsParamsType, function(
|
|
9932
|
+
return firebaseServerActionTransformFunctionFactory(syncAllFlaggedStorageFilesWithGroupsParamsType, function(_params) {
|
|
9683
9933
|
return _async_to_generator$4(function() {
|
|
9684
9934
|
return _ts_generator$4(this, function(_state) {
|
|
9685
9935
|
return [
|
|
@@ -9791,6 +10041,9 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9791
10041
|
*
|
|
9792
10042
|
* Regenerates the content of a single {@link StorageFileGroup}, including building a ZIP
|
|
9793
10043
|
* archive from the group's embedded files and updating the group's content metadata.
|
|
10044
|
+
*
|
|
10045
|
+
* @param context - the storage file server actions context
|
|
10046
|
+
* @returns an async transform-and-validate function that regenerates a StorageFileGroup's content
|
|
9794
10047
|
*/ function regenerateStorageFileGroupContentFactory(context) {
|
|
9795
10048
|
var firestoreContext = context.firestoreContext, storageService = context.storageService, storageFileCollection = context.storageFileCollection, storageFileGroupCollection = context.storageFileGroupCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
9796
10049
|
var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
|
|
@@ -9930,10 +10183,13 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
|
|
|
9930
10183
|
*
|
|
9931
10184
|
* Batch-processes all {@link StorageFileGroup} documents flagged for content regeneration,
|
|
9932
10185
|
* rebuilding their ZIP archives and updating content metadata.
|
|
10186
|
+
*
|
|
10187
|
+
* @param context - the storage file server actions context
|
|
10188
|
+
* @returns an async transform-and-validate function that returns batch regeneration results
|
|
9933
10189
|
*/ function regenerateAllFlaggedStorageFileGroupsContentFactory(context) {
|
|
9934
10190
|
var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileGroupCollection = context.storageFileGroupCollection;
|
|
9935
10191
|
var regenerateStorageFileGroupContent = regenerateStorageFileGroupContentFactory(context);
|
|
9936
|
-
return firebaseServerActionTransformFunctionFactory(regenerateAllFlaggedStorageFileGroupsContentParamsType, function(
|
|
10192
|
+
return firebaseServerActionTransformFunctionFactory(regenerateAllFlaggedStorageFileGroupsContentParamsType, function(_params) {
|
|
9937
10193
|
return _async_to_generator$4(function() {
|
|
9938
10194
|
return _ts_generator$4(this, function(_state) {
|
|
9939
10195
|
return [
|
|
@@ -10218,6 +10474,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10218
10474
|
* initialization action to its factory function.
|
|
10219
10475
|
*
|
|
10220
10476
|
* @param context - the initialization context with template function and Firestore access
|
|
10477
|
+
* @returns a {@link StorageFileInitServerActions} wired to the provided context
|
|
10221
10478
|
*/ function storageFileInitServerActions(context) {
|
|
10222
10479
|
return {
|
|
10223
10480
|
initializeStorageFileGroup: initializeStorageFileGroupFactory(context),
|
|
@@ -10233,6 +10490,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10233
10490
|
* - Returns `false` → deletes the document entirely
|
|
10234
10491
|
*
|
|
10235
10492
|
* @param input - the document, transaction, template function, and options
|
|
10493
|
+
* @returns an object indicating whether the document was initialized or was already initialized
|
|
10236
10494
|
* @throws storageFileModelAlreadyInitializedError when `throwErrorIfAlreadyInitialized` is true
|
|
10237
10495
|
*/ function initializeStorageFileModelInTransaction(input) {
|
|
10238
10496
|
return _async_to_generator$3(function() {
|
|
@@ -10334,6 +10592,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10334
10592
|
*
|
|
10335
10593
|
* Applies the app-specific template function, restricting the template to only the `o` (owner)
|
|
10336
10594
|
* and content flag properties, and always flags the group for content regeneration.
|
|
10595
|
+
*
|
|
10596
|
+
* @param context - the initialization context providing collection access and the template function
|
|
10597
|
+
* @returns an async function that initializes a storage file group document within a transaction
|
|
10337
10598
|
*/ function initializeStorageFileGroupInTransactionFactory(context) {
|
|
10338
10599
|
var storageFileGroupCollection = context.storageFileGroupCollection, makeTemplateForStorageFileGroupInitialization = context.makeTemplateForStorageFileGroupInitialization;
|
|
10339
10600
|
return function(params, storageFileGroupDocument, transaction) {
|
|
@@ -10394,6 +10655,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10394
10655
|
*
|
|
10395
10656
|
* Wraps the in-transaction group initialization in a Firestore transaction
|
|
10396
10657
|
* and follows the transform-and-validate pattern.
|
|
10658
|
+
*
|
|
10659
|
+
* @param context - the initialization context with Firestore access and template function
|
|
10660
|
+
* @returns a transform-and-validate function for single storage file group initialization
|
|
10397
10661
|
*/ function initializeStorageFileGroupFactory(context) {
|
|
10398
10662
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
|
|
10399
10663
|
var initializeStorageFileGroupInTransaction = initializeStorageFileGroupInTransactionFactory(context);
|
|
@@ -10434,6 +10698,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10434
10698
|
* Batch-processes all {@link StorageFileGroup} documents flagged for initialization,
|
|
10435
10699
|
* initializing each in parallel (up to 5 concurrent tasks). Loops until no more
|
|
10436
10700
|
* flagged groups are found.
|
|
10701
|
+
*
|
|
10702
|
+
* @param context - the initialization context with Firestore access, collection, and template function
|
|
10703
|
+
* @returns a transform-and-validate function for batch storage file group initialization
|
|
10437
10704
|
*/ function initializeAllApplicableStorageFileGroupsFactory(context) {
|
|
10438
10705
|
var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileGroupCollection = context.storageFileGroupCollection;
|
|
10439
10706
|
var initializeStorageFileGroupInTransaction = initializeStorageFileGroupInTransactionFactory(context);
|
|
@@ -10447,7 +10714,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10447
10714
|
var storageFileGroupsVisited, storageFileGroupsSucceeded, storageFileGroupsFailed, storageFileGroupsAlreadyInitialized, initializeStorageFileGroupParams, initializeStorageFileGroupsResults, found, result;
|
|
10448
10715
|
function initializeStorageFileGroups() {
|
|
10449
10716
|
return _async_to_generator$3(function() {
|
|
10450
|
-
var query, storageFileGroupDocuments
|
|
10717
|
+
var query, storageFileGroupDocuments;
|
|
10451
10718
|
return _ts_generator$3(this, function(_state) {
|
|
10452
10719
|
switch(_state.label){
|
|
10453
10720
|
case 0:
|
|
@@ -10459,7 +10726,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10459
10726
|
case 1:
|
|
10460
10727
|
storageFileGroupDocuments = _state.sent();
|
|
10461
10728
|
return [
|
|
10462
|
-
|
|
10729
|
+
2,
|
|
10463
10730
|
performAsyncTasks(storageFileGroupDocuments, function(storageFileGroupDocument) {
|
|
10464
10731
|
return _async_to_generator$3(function() {
|
|
10465
10732
|
return _ts_generator$3(this, function(_state) {
|
|
@@ -10475,12 +10742,6 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
|
|
|
10475
10742
|
maxParallelTasks: 5
|
|
10476
10743
|
})
|
|
10477
10744
|
];
|
|
10478
|
-
case 2:
|
|
10479
|
-
result = _state.sent();
|
|
10480
|
-
return [
|
|
10481
|
-
2,
|
|
10482
|
-
result
|
|
10483
|
-
];
|
|
10484
10745
|
}
|
|
10485
10746
|
});
|
|
10486
10747
|
})();
|
|
@@ -10640,6 +10901,10 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
10640
10901
|
/**
|
|
10641
10902
|
* Factory that assembles the full {@link StorageFileServerActionsContext} by combining
|
|
10642
10903
|
* the base context with the upload initialization service.
|
|
10904
|
+
*
|
|
10905
|
+
* @param context - the base server actions context providing Firebase infrastructure
|
|
10906
|
+
* @param storageFileInitializeFromUploadService - the service for initializing storage files from uploads
|
|
10907
|
+
* @returns the fully assembled StorageFileServerActionsContext
|
|
10643
10908
|
*/ function storageFileServerActionsContextFactory(context, storageFileInitializeFromUploadService) {
|
|
10644
10909
|
return _object_spread_props$2(_object_spread$2({}, context), {
|
|
10645
10910
|
storageFileInitializeFromUploadService: storageFileInitializeFromUploadService
|
|
@@ -10647,12 +10912,19 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
10647
10912
|
}
|
|
10648
10913
|
/**
|
|
10649
10914
|
* Factory that creates a {@link StorageFileServerActions} instance from the assembled context.
|
|
10915
|
+
*
|
|
10916
|
+
* @param context - the fully assembled storage file server actions context
|
|
10917
|
+
* @returns a concrete StorageFileServerActions instance
|
|
10650
10918
|
*/ function storageFileServerActionsFactory(context) {
|
|
10651
10919
|
return storageFileServerActions(context);
|
|
10652
10920
|
}
|
|
10653
10921
|
/**
|
|
10654
10922
|
* Factory that creates a {@link StorageFileInitServerActions} instance by merging the
|
|
10655
10923
|
* server actions context with the init-specific configuration.
|
|
10924
|
+
*
|
|
10925
|
+
* @param context - the storage file server actions context
|
|
10926
|
+
* @param storageFileInitServerActionsContextConfig - init-specific configuration with the template function
|
|
10927
|
+
* @returns a concrete StorageFileInitServerActions instance
|
|
10656
10928
|
*/ function storageFileInitServerActionsFactory(context, storageFileInitServerActionsContextConfig) {
|
|
10657
10929
|
return storageFileInitServerActions(_object_spread$2({}, context, storageFileInitServerActionsContextConfig));
|
|
10658
10930
|
}
|
|
@@ -10666,9 +10938,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
|
|
|
10666
10938
|
*
|
|
10667
10939
|
* Be sure the class that delares the module using this function also extends AbstractAppStorageFileModule.
|
|
10668
10940
|
*
|
|
10669
|
-
* @param
|
|
10670
|
-
* @
|
|
10671
|
-
* @returns
|
|
10941
|
+
* @param config - the module configuration including optional dependency module, imports, exports, and providers
|
|
10942
|
+
* @returns the assembled {@link ModuleMetadata} for the storage file module
|
|
10672
10943
|
*/ function appStorageFileModuleMetadata(config) {
|
|
10673
10944
|
var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
|
|
10674
10945
|
var dependencyModuleImport = dependencyModule ? [
|
|
@@ -11132,6 +11403,13 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11132
11403
|
};
|
|
11133
11404
|
/**
|
|
11134
11405
|
* Creates a NotificationTaskServiceTaskHandlerConfig that handles the StorageFileProcessingNotificationTask.
|
|
11406
|
+
*
|
|
11407
|
+
* Builds a subtask-based notification handler that loads the storage file document,
|
|
11408
|
+
* determines its purpose, and dispatches to the appropriate purpose-specific processor.
|
|
11409
|
+
* Includes optional StorageFileGroup processors (e.g., ZIP generation) by default.
|
|
11410
|
+
*
|
|
11411
|
+
* @param config - handler configuration including processors, storage accessor, and Firestore collections
|
|
11412
|
+
* @returns a NotificationTaskServiceTaskHandlerConfig wired for storage file processing
|
|
11135
11413
|
*/ function storageFileProcessingNotificationTaskHandler(config) {
|
|
11136
11414
|
var inputProcessors = config.processors, storageAccessor = config.storageAccessor, storageFileFirestoreCollections = config.storageFileFirestoreCollections, allStorageFileGroupProcessorConfig = config.allStorageFileGroupProcessorConfig;
|
|
11137
11415
|
var storageFileDocumentAccessor = storageFileFirestoreCollections.storageFileCollection.documentAccessor();
|
|
@@ -11150,16 +11428,11 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11150
11428
|
subtaskHandlerFunctionName: 'storageFileProcessingNotificationTaskHandler',
|
|
11151
11429
|
inputFunction: function inputFunction(data) {
|
|
11152
11430
|
return _async_to_generator$1(function() {
|
|
11153
|
-
var storageFileDocument, loadStorageFile, purpose, storagePath, file, fileDetailsAccessor
|
|
11431
|
+
var storageFileDocument, loadStorageFile, purpose, storagePath, file, fileDetailsAccessor;
|
|
11154
11432
|
return _ts_generator$1(this, function(_state) {
|
|
11155
11433
|
switch(_state.label){
|
|
11156
11434
|
case 0:
|
|
11157
|
-
|
|
11158
|
-
4,
|
|
11159
|
-
storageFileDocumentAccessor.loadDocumentForId(data.storageFile)
|
|
11160
|
-
];
|
|
11161
|
-
case 1:
|
|
11162
|
-
storageFileDocument = _state.sent();
|
|
11435
|
+
storageFileDocument = storageFileDocumentAccessor.loadDocumentForId(data.storageFile);
|
|
11163
11436
|
loadStorageFile = cachedGetter(function() {
|
|
11164
11437
|
return _async_to_generator$1(function() {
|
|
11165
11438
|
var storageFile;
|
|
@@ -11183,11 +11456,17 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11183
11456
|
});
|
|
11184
11457
|
})();
|
|
11185
11458
|
});
|
|
11186
|
-
purpose = data
|
|
11187
|
-
if (
|
|
11459
|
+
purpose = data.p;
|
|
11460
|
+
if (!(// attempt to load the purpose from the storage file, if it exists.
|
|
11461
|
+
purpose !== null && purpose !== void 0)) return [
|
|
11462
|
+
3,
|
|
11463
|
+
1
|
|
11464
|
+
];
|
|
11465
|
+
return [
|
|
11188
11466
|
3,
|
|
11189
11467
|
3
|
|
11190
11468
|
];
|
|
11469
|
+
case 1:
|
|
11191
11470
|
return [
|
|
11192
11471
|
4,
|
|
11193
11472
|
loadStorageFile().then(function(x) {
|
|
@@ -11195,7 +11474,6 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11195
11474
|
})
|
|
11196
11475
|
];
|
|
11197
11476
|
case 2:
|
|
11198
|
-
// attempt to load the purpose from the storage file, if it exists.
|
|
11199
11477
|
purpose = _state.sent();
|
|
11200
11478
|
_state.label = 3;
|
|
11201
11479
|
case 3:
|
|
@@ -11224,15 +11502,14 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11224
11502
|
case 6:
|
|
11225
11503
|
file = storageAccessor.file(storagePath);
|
|
11226
11504
|
fileDetailsAccessor = makeFileDetailsAccessor(file);
|
|
11227
|
-
input = {
|
|
11228
|
-
target: purpose,
|
|
11229
|
-
loadStorageFile: loadStorageFile,
|
|
11230
|
-
fileDetailsAccessor: fileDetailsAccessor,
|
|
11231
|
-
storageFileDocument: storageFileDocument
|
|
11232
|
-
};
|
|
11233
11505
|
return [
|
|
11234
11506
|
2,
|
|
11235
|
-
|
|
11507
|
+
{
|
|
11508
|
+
target: purpose,
|
|
11509
|
+
loadStorageFile: loadStorageFile,
|
|
11510
|
+
fileDetailsAccessor: fileDetailsAccessor,
|
|
11511
|
+
storageFileDocument: storageFileDocument
|
|
11512
|
+
}
|
|
11236
11513
|
];
|
|
11237
11514
|
}
|
|
11238
11515
|
});
|
|
@@ -11285,7 +11562,12 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
|
|
|
11285
11562
|
processors: processors
|
|
11286
11563
|
}));
|
|
11287
11564
|
}
|
|
11288
|
-
|
|
11565
|
+
/**
|
|
11566
|
+
* Assembles all built-in StorageFileGroup subtask processors, such as ZIP generation.
|
|
11567
|
+
*
|
|
11568
|
+
* @param config - configuration controlling which group processors to include
|
|
11569
|
+
* @returns an array of subtask processor configs for StorageFileGroup processing purposes
|
|
11570
|
+
*/ function allStorageFileGroupStorageFileProcessingPurposeSubtaskProcessors(config) {
|
|
11289
11571
|
var excludeZipProcessing = config.excludeZipProcessing;
|
|
11290
11572
|
var processors = [];
|
|
11291
11573
|
if (!excludeZipProcessing) {
|
|
@@ -11293,7 +11575,15 @@ function allStorageFileGroupStorageFileProcessingPurposeSubtaskProcessors(config
|
|
|
11293
11575
|
}
|
|
11294
11576
|
return processors;
|
|
11295
11577
|
}
|
|
11296
|
-
|
|
11578
|
+
/**
|
|
11579
|
+
* Creates the ZIP subtask processor for {@link StorageFileGroup} processing.
|
|
11580
|
+
*
|
|
11581
|
+
* This processor streams all files in the group into a ZIP archive, attaches an info JSON
|
|
11582
|
+
* manifest, and uploads the result to the group's designated storage path.
|
|
11583
|
+
*
|
|
11584
|
+
* @param config - configuration providing Firestore collections, storage accessor, and ZIP options
|
|
11585
|
+
* @returns a subtask processor config targeting the StorageFileGroup ZIP purpose
|
|
11586
|
+
*/ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config) {
|
|
11297
11587
|
var _ref;
|
|
11298
11588
|
var storageFileFirestoreCollections = config.storageFileFirestoreCollections, storageAccessor = config.storageAccessor, zip = config.zip;
|
|
11299
11589
|
var storageFileCollection = storageFileFirestoreCollections.storageFileCollection, storageFileGroupCollection = storageFileFirestoreCollections.storageFileGroupCollection;
|
|
@@ -11423,7 +11713,7 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
|
|
|
11423
11713
|
4,
|
|
11424
11714
|
performAsyncTasks(storageFileDataPairsToZip, function(storageFileDataPair) {
|
|
11425
11715
|
return _async_to_generator$1(function() {
|
|
11426
|
-
var storageFile, storageFileDisplayName, referencesStorageFileGroup, fileAccessor, metadata, fileSlashPathDetails, storageFileGroupEmbeddedFile, embeddedFileNameOverride, nameFromFactory, untypedName, extension, name, fileStream;
|
|
11716
|
+
var storageFile, storageFileDisplayName, referencesStorageFileGroup, fileAccessor, metadata, _ref, _ref1, fileSlashPathDetails, storageFileGroupEmbeddedFile, embeddedFileNameOverride, nameFromFactory, untypedName, extension, name, fileStream;
|
|
11427
11717
|
return _ts_generator$1(this, function(_state) {
|
|
11428
11718
|
switch(_state.label){
|
|
11429
11719
|
case 0:
|
|
@@ -11434,9 +11724,7 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
|
|
|
11434
11724
|
];
|
|
11435
11725
|
storageFileDisplayName = storageFile.n;
|
|
11436
11726
|
// make sure it references the storage file group
|
|
11437
|
-
referencesStorageFileGroup = storageFile.g.
|
|
11438
|
-
return x === storageFileGroupId;
|
|
11439
|
-
});
|
|
11727
|
+
referencesStorageFileGroup = storageFile.g.includes(storageFileGroupId);
|
|
11440
11728
|
if (!referencesStorageFileGroup) return [
|
|
11441
11729
|
3,
|
|
11442
11730
|
6
|
|
@@ -11469,15 +11757,20 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
|
|
|
11469
11757
|
];
|
|
11470
11758
|
case 2:
|
|
11471
11759
|
nameFromFactory = _state.sent();
|
|
11472
|
-
untypedName = nameFromFactory
|
|
11760
|
+
untypedName = (_ref = (_ref1 = nameFromFactory !== null && nameFromFactory !== void 0 ? nameFromFactory : storageFileDisplayName) !== null && _ref1 !== void 0 ? _ref1 : embeddedFileNameOverride) !== null && _ref !== void 0 ? _ref : fileSlashPathDetails.fileName;
|
|
11473
11761
|
if (fileSlashPathDetails.typedFileExtension) {
|
|
11474
11762
|
extension = fileSlashPathDetails.typedFileExtension;
|
|
11475
11763
|
} else if (metadata.contentType) {
|
|
11476
11764
|
extension = documentFileExtensionForMimeType(metadata.contentType);
|
|
11477
11765
|
}
|
|
11478
11766
|
// set the default name if still unset
|
|
11479
|
-
untypedName = untypedName
|
|
11767
|
+
untypedName = untypedName !== null && untypedName !== void 0 ? untypedName : "sf_".concat(storageFile.id);
|
|
11480
11768
|
name = extension ? "".concat(untypedName, ".").concat(extension) : untypedName;
|
|
11769
|
+
if (!fileAccessor.getStream) {
|
|
11770
|
+
return [
|
|
11771
|
+
2
|
|
11772
|
+
]; // skip files where getStream is not available
|
|
11773
|
+
}
|
|
11481
11774
|
fileStream = fileAccessor.getStream();
|
|
11482
11775
|
return [
|
|
11483
11776
|
4,
|
|
@@ -11828,6 +12121,7 @@ function _ts_generator(thisArg, body) {
|
|
|
11828
12121
|
*
|
|
11829
12122
|
* @param error - the error that caused the permanent failure
|
|
11830
12123
|
* @param createdFile - optional path to a file that was created before the error and should be deleted
|
|
12124
|
+
* @returns a permanent failure result with the error and optional created file reference
|
|
11831
12125
|
*/ function storageFileInitializeFromUploadServiceInitializerResultPermanentFailure(error, createdFile) {
|
|
11832
12126
|
return {
|
|
11833
12127
|
error: error,
|
|
@@ -11847,6 +12141,7 @@ function _ts_generator(thisArg, body) {
|
|
|
11847
12141
|
* 4. Optionally, previous files for the same purpose/user are flagged for deletion
|
|
11848
12142
|
*
|
|
11849
12143
|
* @param config - service configuration including determiners, initializers, and storage references
|
|
12144
|
+
* @returns a {@link StorageFileInitializeFromUploadService} with type detection and upload initialization
|
|
11850
12145
|
*
|
|
11851
12146
|
* @example
|
|
11852
12147
|
* ```ts
|
|
@@ -11883,10 +12178,9 @@ function _ts_generator(thisArg, body) {
|
|
|
11883
12178
|
}
|
|
11884
12179
|
});
|
|
11885
12180
|
var determiner = combineUploadFileTypeDeterminers(_object_spread({
|
|
11886
|
-
determiners: allDeterminers
|
|
11887
|
-
}, _object_spread({
|
|
12181
|
+
determiners: allDeterminers,
|
|
11888
12182
|
completeSearchOnFirstMatch: true
|
|
11889
|
-
}, config.combineDeterminersConfig))
|
|
12183
|
+
}, config.combineDeterminersConfig));
|
|
11890
12184
|
// validate initializers
|
|
11891
12185
|
if (validate) {
|
|
11892
12186
|
var allInitializerTypes = Object.keys(initializers);
|
|
@@ -11914,6 +12208,7 @@ function _ts_generator(thisArg, body) {
|
|
|
11914
12208
|
return {
|
|
11915
12209
|
checkFileIsAllowedToBeInitialized: inputCheckFileIsAllowedToBeInitialized !== null && inputCheckFileIsAllowedToBeInitialized !== void 0 ? inputCheckFileIsAllowedToBeInitialized : asDecisionFunction(true),
|
|
11916
12210
|
determineUploadFileType: determineUploadFileType,
|
|
12211
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
11917
12212
|
initializeFromUpload: function initializeFromUpload(input) {
|
|
11918
12213
|
return _async_to_generator(function() {
|
|
11919
12214
|
var determinerResult, resultType, createdFilePath, storageFileDocument, processorError, previousStorageFilesFlaggedForDeletion, fileDetailsAccessor, initializer, initializerResult, error, permanentFailure, createdFile, flagPreviousForDelete, createStorageFileResult, flagPreviousForDeleteResult, _createStorageFileResult_storageFile, p, pg, u, createdFile1, fileMetadata, e, flagForDeleteResult, e1, result;
|