@dereekb/firebase-server 13.4.1 → 13.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/index.cjs.js +405 -93
  2. package/index.esm.js +406 -94
  3. package/mailgun/package.json +9 -9
  4. package/model/index.cjs.js +639 -348
  5. package/model/index.esm.js +640 -349
  6. package/model/package.json +10 -10
  7. package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +1 -0
  8. package/model/src/lib/notification/index.d.ts +2 -2
  9. package/model/src/lib/notification/{notification.action.service.d.ts → notification.action.server.d.ts} +53 -1
  10. package/model/src/lib/notification/{notification.action.init.service.d.ts → notification.action.server.init.d.ts} +20 -0
  11. package/model/src/lib/notification/notification.config.service.d.ts +2 -0
  12. package/model/src/lib/notification/notification.create.run.d.ts +1 -0
  13. package/model/src/lib/notification/notification.error.d.ts +16 -0
  14. package/model/src/lib/notification/notification.expedite.service.d.ts +11 -3
  15. package/model/src/lib/notification/notification.module.d.ts +19 -6
  16. package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +1 -0
  17. package/model/src/lib/notification/notification.send.service.text.d.ts +2 -0
  18. package/model/src/lib/notification/notification.task.service.handler.d.ts +1 -0
  19. package/model/src/lib/notification/notification.task.service.util.d.ts +1 -0
  20. package/model/src/lib/notification/notification.task.subtask.handler.d.ts +3 -0
  21. package/model/src/lib/notification/notification.util.d.ts +4 -2
  22. package/model/src/lib/storagefile/index.d.ts +1 -1
  23. package/model/src/lib/storagefile/storagefile.action.server.d.ts +98 -1
  24. package/model/src/lib/storagefile/{storagefile.action.init.service.d.ts → storagefile.action.server.init.d.ts} +13 -2
  25. package/model/src/lib/storagefile/storagefile.error.d.ts +27 -0
  26. package/model/src/lib/storagefile/storagefile.module.d.ts +14 -4
  27. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +29 -7
  28. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +2 -0
  29. package/oidc/index.cjs.js +141 -31
  30. package/oidc/index.esm.js +141 -31
  31. package/oidc/package.json +11 -11
  32. package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +12 -0
  33. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +6 -0
  34. package/oidc/src/lib/model/jwks/jwks.d.ts +9 -0
  35. package/oidc/src/lib/model/jwks/jwks.query.d.ts +9 -0
  36. package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +13 -0
  37. package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +5 -1
  38. package/oidc/src/lib/oidc.config.d.ts +2 -1
  39. package/oidc/src/lib/oidc.module.d.ts +9 -2
  40. package/oidc/src/lib/service/oidc.account.service.d.ts +7 -0
  41. package/oidc/src/lib/service/oidc.adapter.service.d.ts +1 -0
  42. package/oidc/src/lib/service/oidc.config.service.d.ts +1 -0
  43. package/oidc/src/lib/service/oidc.encryption.service.d.ts +6 -0
  44. package/oidc/src/lib/service/oidc.interaction.service.d.ts +15 -0
  45. package/oidc/src/lib/service/oidc.jwks.service.d.ts +18 -2
  46. package/oidc/src/lib/service/oidc.service.d.ts +7 -3
  47. package/package.json +13 -13
  48. package/src/lib/auth/auth.context.d.ts +1 -0
  49. package/src/lib/auth/auth.service.d.ts +13 -0
  50. package/src/lib/env/env.config.d.ts +2 -0
  51. package/src/lib/env/env.service.d.ts +21 -7
  52. package/src/lib/firestore/array.d.ts +1 -0
  53. package/src/lib/firestore/driver.accessor.batch.d.ts +4 -0
  54. package/src/lib/firestore/driver.accessor.d.ts +4 -0
  55. package/src/lib/firestore/driver.accessor.default.d.ts +5 -1
  56. package/src/lib/firestore/driver.accessor.transaction.d.ts +4 -0
  57. package/src/lib/firestore/driver.d.ts +2 -0
  58. package/src/lib/firestore/driver.query.d.ts +4 -0
  59. package/src/lib/firestore/increment.d.ts +1 -0
  60. package/src/lib/function/assert.d.ts +7 -0
  61. package/src/lib/function/context.d.ts +4 -0
  62. package/src/lib/function/error.auth.d.ts +2 -0
  63. package/src/lib/function/error.d.ts +86 -11
  64. package/src/lib/index.d.ts +0 -1
  65. package/src/lib/nest/analytics/analytics.service.listener.d.ts +2 -0
  66. package/src/lib/nest/app.d.ts +6 -3
  67. package/src/lib/nest/auth/auth.module.d.ts +6 -0
  68. package/src/lib/nest/auth/auth.util.d.ts +19 -1
  69. package/src/lib/nest/development/development.app.function.d.ts +12 -4
  70. package/src/lib/nest/development/development.assert.function.d.ts +6 -2
  71. package/src/lib/nest/development/development.function.d.ts +6 -1
  72. package/src/lib/nest/development/development.schedule.function.d.ts +3 -1
  73. package/src/lib/nest/development/development.schedule.function.error.d.ts +8 -0
  74. package/src/lib/nest/env/env.service.d.ts +2 -0
  75. package/src/lib/nest/env/env.util.d.ts +6 -0
  76. package/src/lib/nest/firebase/firebase.module.d.ts +1 -0
  77. package/src/lib/nest/firestore/firestore.module.d.ts +8 -0
  78. package/src/lib/nest/function/context.d.ts +2 -0
  79. package/src/lib/nest/model/analytics.details.d.ts +21 -7
  80. package/src/lib/nest/model/analytics.emit.d.ts +3 -0
  81. package/src/lib/nest/model/analytics.handler.d.ts +30 -10
  82. package/src/lib/nest/model/api.details.d.ts +34 -1
  83. package/src/lib/nest/model/call.model.function.d.ts +20 -4
  84. package/src/lib/nest/model/create.model.function.d.ts +6 -1
  85. package/src/lib/nest/model/crud.assert.function.d.ts +12 -4
  86. package/src/lib/nest/model/delete.model.function.d.ts +6 -1
  87. package/src/lib/nest/model/permission.error.d.ts +7 -0
  88. package/src/lib/nest/model/read.model.function.d.ts +6 -1
  89. package/src/lib/nest/model/specifier.function.d.ts +3 -0
  90. package/src/lib/nest/model/update.model.function.d.ts +6 -1
  91. package/src/lib/nest/nest.provider.d.ts +10 -0
  92. package/src/lib/nest/storage/storage.module.d.ts +9 -0
  93. package/src/lib/storage/driver.accessor.d.ts +22 -0
  94. package/src/lib/storage/driver.d.ts +2 -0
  95. package/src/lib/storage/storage.d.ts +1 -0
  96. package/test/package.json +11 -11
  97. package/zoho/index.cjs.js +8 -6
  98. package/zoho/index.esm.js +8 -6
  99. package/zoho/package.json +9 -9
  100. package/zoho/src/lib/zoho.accounts.firebase.d.ts +2 -1
  101. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +2 -1
@@ -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, filterMaybeArrayValues, separateValues, 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';
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
@@ -323,6 +324,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
323
324
  * Creates an error indicating that a required notification ID was missing during creation.
324
325
  *
325
326
  * Thrown when attempting to create a {@link Notification} document without providing the mandatory ID field.
327
+ *
328
+ * @returns a precondition conflict error with the notification ID required error code
326
329
  */ function createNotificationIdRequiredError() {
327
330
  return preconditionConflictError({
328
331
  message: "The required id was not present when attempting to create a Notification.",
@@ -334,6 +337,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
334
337
  *
335
338
  * Thrown during initialization when `throwErrorIfAlreadyInitialized` is true and the model's
336
339
  * setup flag (`s`) indicates it was previously initialized.
340
+ *
341
+ * @returns a precondition conflict error with the already-initialized error code
337
342
  */ function notificationModelAlreadyInitializedError() {
338
343
  return preconditionConflictError({
339
344
  message: "This model has already been initialized.",
@@ -346,6 +351,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
346
351
  * Thrown when the model key's collection name does not match any registered notification model type.
347
352
  *
348
353
  * @param key - the Firestore model key that has no registered notification model type
354
+ * @returns a precondition conflict error with the unregistered model type error code
349
355
  */ function notificationBoxUnregistredModelTypeInitializationError(key) {
350
356
  return preconditionConflictError({
351
357
  message: "This NotificationBox is associated with an unregistered model type.",
@@ -359,6 +365,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
359
365
  * Creates an error indicating that no {@link NotificationBox} exists for the target model.
360
366
  *
361
367
  * Thrown when an operation requires a NotificationBox but none has been created for the given model key.
368
+ *
369
+ * @returns a precondition conflict error with the box-not-found error code
362
370
  */ function notificationBoxDoesNotExist() {
363
371
  return preconditionConflictError({
364
372
  message: "A NotificationBox does not exist for this model.",
@@ -370,6 +378,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
370
378
  *
371
379
  * Thrown when the target recipient on the {@link NotificationBox} does not exist on the box
372
380
  * or does not have a UID, making it ineligible for exclusion.
381
+ *
382
+ * @returns a precondition conflict error with the invalid exclusion target error code
373
383
  */ function notificationBoxExclusionTargetInvalidError() {
374
384
  return preconditionConflictError({
375
385
  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 +390,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
380
390
  * Creates an error indicating that a {@link NotificationBox} already exists for this model.
381
391
  *
382
392
  * Thrown when attempting to create a duplicate NotificationBox for a model that already has one.
393
+ *
394
+ * @returns a precondition conflict error with the box-exists error code
383
395
  */ function notificationBoxExistsForModelError() {
384
396
  return preconditionConflictError({
385
397
  message: "A NotificationBox already exists for this model.",
@@ -391,6 +403,8 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
391
403
  *
392
404
  * Thrown when attempting to update a recipient that is not registered on the box
393
405
  * and `insert=true` was not passed to allow creating a new recipient entry.
406
+ *
407
+ * @returns a precondition conflict error with the recipient-not-found error code
394
408
  */ function notificationBoxRecipientDoesNotExistsError() {
395
409
  return preconditionConflictError({
396
410
  message: "An existing NotificationBox recipient for the target does not exist. You must pass insert=true to create a new recipient.",
@@ -403,6 +417,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
403
417
  * Thrown during {@link NotificationUser} creation when the provided UID cannot be found in Firebase Auth.
404
418
  *
405
419
  * @param uid - the Firebase Auth user ID that was not found
420
+ * @returns a precondition conflict error with the invalid-uid error code
406
421
  */ function notificationUserInvalidUidForCreateError(uid) {
407
422
  return preconditionConflictError({
408
423
  message: "The user with the uid '".concat(uid, "' does not exist. Cannot create a NotificationUser for them."),
@@ -419,6 +434,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
419
434
  * and an operation attempts to insert them into a {@link NotificationBox}'s recipient list.
420
435
  *
421
436
  * @param uid - the Firebase Auth user ID of the blocked user
437
+ * @returns a precondition conflict error with the blocked-from-add error code
422
438
  */ function notificationUserBlockedFromBeingAddedToRecipientsError(uid) {
423
439
  return preconditionConflictError({
424
440
  message: "The user with the uid '".concat(uid, "' has blocked themselves from from being added recipients."),
@@ -435,6 +451,7 @@ var MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_DEFAULT_MAX_BATCH_SIZE_PER_REQUEST =
435
451
  * and an operation attempts to modify their recipient settings on a {@link NotificationBox}.
436
452
  *
437
453
  * @param uid - the Firebase Auth user ID of the locked user
454
+ * @returns a precondition conflict error with the locked-config error code
438
455
  */ function notificationUserLockedConfigFromBeingUpdatedError(uid) {
439
456
  return preconditionConflictError({
440
457
  message: "The user with the uid '".concat(uid, "' has locked their config from being updated."),
@@ -450,7 +467,7 @@ function _array_like_to_array$7(arr, len) {
450
467
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
451
468
  return arr2;
452
469
  }
453
- function _array_without_holes$5(arr) {
470
+ function _array_without_holes$6(arr) {
454
471
  if (Array.isArray(arr)) return _array_like_to_array$7(arr);
455
472
  }
456
473
  function asyncGeneratorStep$e(gen, resolve, reject, _next, _throw, key, arg) {
@@ -495,10 +512,10 @@ function _define_property$d(obj, key, value) {
495
512
  }
496
513
  return obj;
497
514
  }
498
- function _iterable_to_array$5(iter) {
515
+ function _iterable_to_array$6(iter) {
499
516
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
500
517
  }
501
- function _non_iterable_spread$5() {
518
+ function _non_iterable_spread$6() {
502
519
  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
520
  }
504
521
  function _object_spread$c(target) {
@@ -535,8 +552,8 @@ function _object_spread_props$b(target, source) {
535
552
  }
536
553
  return target;
537
554
  }
538
- function _to_consumable_array$5(arr) {
539
- return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$5();
555
+ function _to_consumable_array$6(arr) {
556
+ return _array_without_holes$6(arr) || _iterable_to_array$6(arr) || _unsupported_iterable_to_array$7(arr) || _non_iterable_spread$6();
540
557
  }
541
558
  function _unsupported_iterable_to_array$7(o, minLen) {
542
559
  if (!o) return;
@@ -653,6 +670,7 @@ function _ts_generator$e(thisArg, body) {
653
670
  * and initializes with an empty notifications array.
654
671
  *
655
672
  * @param model - the model key to associate the summary with
673
+ * @returns a blank {@link NotificationSummary} with creation timestamp and empty notifications
656
674
  *
657
675
  * @example
658
676
  * ```ts
@@ -675,8 +693,8 @@ function _ts_generator$e(thisArg, body) {
675
693
  *
676
694
  * 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
695
  *
678
- * @param input
679
- * @returns
696
+ * @param input - the notification, box, auth service, and recipient configuration
697
+ * @returns channel-specific recipient lists (email, text, notification summary) ready for delivery
680
698
  */ function expandNotificationRecipients(input) {
681
699
  return _async_to_generator$e(function() {
682
700
  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 +720,7 @@ function _ts_generator$e(thisArg, body) {
702
720
  onlyTextExplicitlyEnabledRecipients = inputOnlyTextExplicitlyEnabledRecipients !== false; // defaults to true
703
721
  onlySendToExplicitlyEnabledRecipients = inputOnlySendToExplicitlyEnabledRecipients === true; // defaults to false
704
722
  onlyEmailExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
723
+ // const onlySendPushNotificationExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
705
724
  onlySendNotificationSummaryExplicitlyEnabledRecipients = onlySendToExplicitlyEnabledRecipients;
706
725
  _allowedNotificationRecipients = allowedNotificationRecipients(recipientFlag), canSendToGlobalRecipients = _allowedNotificationRecipients.canSendToGlobalRecipients, canSendToBoxRecipients = _allowedNotificationRecipients.canSendToBoxRecipients, canSendToExplicitRecipients = _allowedNotificationRecipients.canSendToExplicitRecipients;
707
726
  initialExplicitRecipients = canSendToExplicitRecipients ? notification.r : [];
@@ -712,7 +731,7 @@ function _ts_generator$e(thisArg, body) {
712
731
  globalRecipients = initialGlobalRecipients.map(function(x) {
713
732
  return _object_spread$c({}, x, effectiveNotificationBoxRecipientTemplateConfig(x));
714
733
  });
715
- explicitAndGlobalRecipients = _to_consumable_array$5(explicitRecipients).concat(_to_consumable_array$5(globalRecipients));
734
+ explicitAndGlobalRecipients = _to_consumable_array$6(explicitRecipients).concat(_to_consumable_array$6(globalRecipients));
716
735
  allBoxRecipientConfigs = canSendToBoxRecipients && notificationBox ? notificationBox.r : [];
717
736
  recipientUids = new Set();
718
737
  relevantBoxRecipientConfigs = [];
@@ -749,7 +768,7 @@ function _ts_generator$e(thisArg, body) {
749
768
  3,
750
769
  2
751
770
  ];
752
- nonNotificationBoxRecipientUids = Array.from(nonNotificationBoxUidRecipientConfigs.keys());
771
+ nonNotificationBoxRecipientUids = _to_consumable_array$6(nonNotificationBoxUidRecipientConfigs.keys());
753
772
  notificationUserDocuments = loadDocumentsForIds(notificationUserAccessor, nonNotificationBoxRecipientUids);
754
773
  return [
755
774
  4,
@@ -813,7 +832,7 @@ function _ts_generator$e(thisArg, body) {
813
832
  });
814
833
  return [
815
834
  4,
816
- Promise.all(Array.from(recipientUids).map(function(uid) {
835
+ Promise.all(_to_consumable_array$6(recipientUids).map(function(uid) {
817
836
  return authService.userContext(uid).loadDetails().then(function(details) {
818
837
  return [
819
838
  uid,
@@ -1025,17 +1044,15 @@ function _ts_generator$e(thisArg, body) {
1025
1044
  } else if (x.s) {
1026
1045
  notificationSummaryId = x.s;
1027
1046
  }
1028
- if (notificationSummaryId) {
1029
- if (!notificationSummaryKeysSet.has(notificationSummaryId)) {
1030
- var name = displayName || x.n;
1031
- var notificationSummary = {
1032
- notificationSummaryId: notificationSummaryId,
1033
- otherRecipient: x,
1034
- name: name
1035
- };
1036
- notificationSummaries.push(notificationSummary);
1037
- explicitOtherRecipientNotificationSummaryIds.delete(notificationSummaryId);
1038
- }
1047
+ if (notificationSummaryId && !notificationSummaryKeysSet.has(notificationSummaryId)) {
1048
+ var name = displayName || x.n;
1049
+ var notificationSummary = {
1050
+ notificationSummaryId: notificationSummaryId,
1051
+ otherRecipient: x,
1052
+ name: name
1053
+ };
1054
+ notificationSummaries.push(notificationSummary);
1055
+ explicitOtherRecipientNotificationSummaryIds.delete(notificationSummaryId);
1039
1056
  }
1040
1057
  }
1041
1058
  }
@@ -1080,6 +1097,7 @@ function _ts_generator$e(thisArg, body) {
1080
1097
  * Also re-applies send exclusions to the updated config array.
1081
1098
  *
1082
1099
  * @param input - the current state and intended change
1100
+ * @returns the updated box config array and notification box recipient, if changes occurred
1083
1101
  * @throws notificationUserBlockedFromBeingAddedToRecipientsError when inserting a blocked user
1084
1102
  * @throws notificationUserLockedConfigFromBeingUpdatedError when updating a locked user's config
1085
1103
  */ function updateNotificationUserNotificationBoxRecipientConfig(input) {
@@ -1099,7 +1117,7 @@ function _ts_generator$e(thisArg, body) {
1099
1117
  // flag as removed in the NotificationUser details if not already flagged as such
1100
1118
  if (currentNotificationUserBoxIndexExists && currentNotificationUserBoxConfig.rm !== true) {
1101
1119
  var _currentNotificationUserBoxConfig_c;
1102
- updatedBc = _to_consumable_array$5(notificationUser.bc);
1120
+ updatedBc = _to_consumable_array$6(notificationUser.bc);
1103
1121
  updatedBc[currentNotificationUserBoxIndex] = _object_spread_props$b(_object_spread$c({}, currentNotificationUserBoxConfig), {
1104
1122
  nb: notificationBoxId,
1105
1123
  c: (_currentNotificationUserBoxConfig_c = currentNotificationUserBoxConfig.c) !== null && _currentNotificationUserBoxConfig_c !== void 0 ? _currentNotificationUserBoxConfig_c : {},
@@ -1145,7 +1163,7 @@ function _ts_generator$e(thisArg, body) {
1145
1163
  nb: notificationBoxId,
1146
1164
  rm: false // remove/clear the removed flag
1147
1165
  }), updateWithNotificationBoxRecipient);
1148
- updatedBc = _to_consumable_array$5(notificationUser.bc);
1166
+ updatedBc = _to_consumable_array$6(notificationUser.bc);
1149
1167
  if (currentNotificationUserBoxIndexExists) {
1150
1168
  updatedBc[currentNotificationUserBoxIndex] = updatedNotificationUserBoxEntry;
1151
1169
  } else {
@@ -1177,6 +1195,7 @@ function _ts_generator$e(thisArg, body) {
1177
1195
  *
1178
1196
  * @param inputCompletions - the current list of completed checkpoint strings
1179
1197
  * @param handleTaskResult - the handler result containing removal instructions
1198
+ * @returns the filtered completions array with specified checkpoints removed
1180
1199
  *
1181
1200
  * @example
1182
1201
  * ```ts
@@ -1210,7 +1229,7 @@ function _array_like_to_array$6(arr, len) {
1210
1229
  function _array_with_holes$2(arr) {
1211
1230
  if (Array.isArray(arr)) return arr;
1212
1231
  }
1213
- function _array_without_holes$4(arr) {
1232
+ function _array_without_holes$5(arr) {
1214
1233
  if (Array.isArray(arr)) return _array_like_to_array$6(arr);
1215
1234
  }
1216
1235
  function asyncGeneratorStep$d(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1260,7 +1279,7 @@ function _define_property$c(obj, key, value) {
1260
1279
  }
1261
1280
  return obj;
1262
1281
  }
1263
- function _iterable_to_array$4(iter) {
1282
+ function _iterable_to_array$5(iter) {
1264
1283
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
1265
1284
  }
1266
1285
  function _iterable_to_array_limit$2(arr, i) {
@@ -1290,7 +1309,7 @@ function _iterable_to_array_limit$2(arr, i) {
1290
1309
  function _non_iterable_rest$2() {
1291
1310
  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
1311
  }
1293
- function _non_iterable_spread$4() {
1312
+ function _non_iterable_spread$5() {
1294
1313
  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
1314
  }
1296
1315
  function _object_spread$b(target) {
@@ -1330,8 +1349,8 @@ function _object_spread_props$a(target, source) {
1330
1349
  function _sliced_to_array$2(arr, i) {
1331
1350
  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
1351
  }
1333
- function _to_consumable_array$4(arr) {
1334
- return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$4();
1352
+ function _to_consumable_array$5(arr) {
1353
+ return _array_without_holes$5(arr) || _iterable_to_array$5(arr) || _unsupported_iterable_to_array$6(arr) || _non_iterable_spread$5();
1335
1354
  }
1336
1355
  function _unsupported_iterable_to_array$6(o, minLen) {
1337
1356
  if (!o) return;
@@ -1472,6 +1491,7 @@ function _ts_generator$d(thisArg, body) {
1472
1491
  * to its factory function using the provided context.
1473
1492
  *
1474
1493
  * @param context - the fully assembled notification server actions context
1494
+ * @returns a fully wired {@link NotificationServerActions} instance
1475
1495
  *
1476
1496
  * @example
1477
1497
  * ```ts
@@ -1501,6 +1521,9 @@ function _ts_generator$d(thisArg, body) {
1501
1521
  *
1502
1522
  * Validates the UID exists in Firebase Auth, then creates a new {@link NotificationUser} document
1503
1523
  * with empty default and global configs. Throws if the UID is not found in Auth.
1524
+ *
1525
+ * @param context - the notification server actions context with auth and collection access
1526
+ * @returns a transform-and-validate function that creates a new notification user document
1504
1527
  */ function createNotificationUserFactory(context) {
1505
1528
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationUserCollection = context.notificationUserCollection, authService = context.authService;
1506
1529
  return firebaseServerActionTransformFunctionFactory(createNotificationUserParamsType, function(params) {
@@ -1565,6 +1588,9 @@ function _ts_generator$d(thisArg, body) {
1565
1588
  * Updates a {@link NotificationUser}'s default config (`dc`), global config (`gc`), and/or
1566
1589
  * box configs (`bc`). When the global config changes, iterates all box configs to propagate
1567
1590
  * effective recipient changes and marks affected entries for sync.
1591
+ *
1592
+ * @param context - the notification server actions context with Firestore and collection access
1593
+ * @returns a transform-and-validate function that updates an existing notification user document
1568
1594
  */ function updateNotificationUserFactory(context) {
1569
1595
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationUserCollection = context.notificationUserCollection, appNotificationTemplateTypeInfoRecordService = context.appNotificationTemplateTypeInfoRecordService;
1570
1596
  return firebaseServerActionTransformFunctionFactory(updateNotificationUserParamsType, function(params) {
@@ -1684,6 +1710,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1684
1710
  * entries flagged with `ns=true` (needs-sync), loading the corresponding {@link NotificationBox},
1685
1711
  * and merging the user's preferences back into the box's recipient list. Handles removed entries
1686
1712
  * and cleans up stale box references.
1713
+ *
1714
+ * @param context - the notification server actions context with Firestore and collection access
1715
+ * @returns a transform-and-validate function that resyncs a notification user's box configurations
1687
1716
  */ function resyncNotificationUserFactory(context) {
1688
1717
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection, appNotificationTemplateTypeInfoRecordService = context.appNotificationTemplateTypeInfoRecordService;
1689
1718
  return firebaseServerActionTransformFunctionFactory(resyncNotificationUserParamsType, function() {
@@ -1737,7 +1766,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1737
1766
  notificationBoxConfigsToSyncInThisBatchMap = makeModelMap(notificationBoxConfigsToSyncInThisBatch, function(x) {
1738
1767
  return x.nb;
1739
1768
  });
1740
- notificationBoxIdsToSyncInThisBatch = Array.from(notificationBoxConfigsToSyncInThisBatchMap.keys());
1769
+ notificationBoxIdsToSyncInThisBatch = _to_consumable_array$5(notificationBoxConfigsToSyncInThisBatchMap.keys());
1741
1770
  notificationBoxDocuments = loadDocumentsForIds(notificationBoxCollection.documentAccessorForTransaction(transaction), notificationBoxIdsToSyncInThisBatch);
1742
1771
  return [
1743
1772
  4,
@@ -1795,7 +1824,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1795
1824
  recipientHasChange = !areEqualPOJOValues(nextRecipient, recipient);
1796
1825
  // only update recipients if the next/new recipient is not equal to the existing one
1797
1826
  if (recipientHasChange) {
1798
- r = _to_consumable_array$4(notificationBox.r);
1827
+ r = _to_consumable_array$5(notificationBox.r);
1799
1828
  r[recipientIndex] = nextRecipient;
1800
1829
  nextRecipientsMap.set(nb, nextRecipient);
1801
1830
  } else {
@@ -1845,13 +1874,12 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1845
1874
  i: UNSET_INDEX_NUMBER
1846
1875
  });
1847
1876
  } else {
1848
- var _updatedRecipient_i;
1849
1877
  // else, use the updated recipient and keep/copy the
1850
1878
  var updatedRecipient = nextRecipientsMap.get(nb);
1851
1879
  nextConfig = _object_spread_props$a(_object_spread$b({}, existingConfig), {
1852
1880
  nb: nb,
1853
1881
  rm: false,
1854
- i: (_updatedRecipient_i = updatedRecipient.i) !== null && _updatedRecipient_i !== void 0 ? _updatedRecipient_i : UNSET_INDEX_NUMBER
1882
+ i: updatedRecipient.i
1855
1883
  });
1856
1884
  }
1857
1885
  }
@@ -1919,6 +1947,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1919
1947
  * Batch-processes all {@link NotificationUser} documents flagged for sync by querying
1920
1948
  * for entries with `ns=true`, then calling the resync logic for each in parallel
1921
1949
  * (up to 5 concurrent tasks). Loops until no more flagged users are found.
1950
+ *
1951
+ * @param context - the notification server actions context with collection access
1952
+ * @returns an async function that resyncs all flagged notification users and returns aggregate results
1922
1953
  */ function resyncAllNotificationUsersFactory(context) {
1923
1954
  var notificationUserCollection = context.notificationUserCollection;
1924
1955
  var resyncNotificationUser = resyncNotificationUserFactory(context);
@@ -2004,6 +2035,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2004
2035
  *
2005
2036
  * Creates a new {@link NotificationSummary} document for a model, generating the summary ID
2006
2037
  * from the model key and initializing it with a blank template.
2038
+ *
2039
+ * @param context - the notification server actions context with collection access
2040
+ * @returns a transform-and-validate function that creates a new notification summary document
2007
2041
  */ function createNotificationSummaryFactory(context) {
2008
2042
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection;
2009
2043
  return firebaseServerActionTransformFunctionFactory(createNotificationSummaryParamsType, function(params) {
@@ -2046,6 +2080,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2046
2080
  *
2047
2081
  * Updates an existing {@link NotificationSummary} document's owner or setup flag.
2048
2082
  * Runs within a Firestore transaction to ensure consistency.
2083
+ *
2084
+ * @param context - the notification server actions context
2085
+ * @returns a transform-and-validate function that updates an existing notification summary document
2049
2086
  */ function updateNotificationSummaryFactory(context) {
2050
2087
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2051
2088
  return firebaseServerActionTransformFunctionFactory(updateNotificationSummaryParamsType, function(params) {
@@ -2100,6 +2137,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2100
2137
  *
2101
2138
  * Checks for existing boxes and throws if one already exists for the model.
2102
2139
  * Also syncs initial recipients with their corresponding {@link NotificationUser} documents.
2140
+ *
2141
+ * @param context - the base notification server actions context with collection access
2142
+ * @returns an async function that creates a notification box within a transaction and returns the document and template
2103
2143
  */ function createNotificationBoxInTransactionFactory(context) {
2104
2144
  var notificationBoxCollection = context.notificationBoxCollection;
2105
2145
  return function(params, transaction) {
@@ -2148,6 +2188,9 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2148
2188
  *
2149
2189
  * Wraps {@link createNotificationBoxInTransactionFactory} in a Firestore transaction
2150
2190
  * and follows the transform-and-validate pattern.
2191
+ *
2192
+ * @param context - the notification server actions context with Firestore and collection access
2193
+ * @returns a transform-and-validate function that creates a new notification box document
2151
2194
  */ function createNotificationBoxFactory(context) {
2152
2195
  var firestoreContext = context.firestoreContext, notificationBoxCollection = context.notificationBoxCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2153
2196
  var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
@@ -2204,8 +2247,16 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2204
2247
  })();
2205
2248
  });
2206
2249
  }
2207
- function updateNotificationBoxFactory(param) {
2208
- var firebaseServerActionTransformFunctionFactory = param.firebaseServerActionTransformFunctionFactory;
2250
+ /**
2251
+ * Factory for the `updateNotificationBox` action.
2252
+ *
2253
+ * Currently a no-op placeholder that returns the document unchanged.
2254
+ * Reserved for future box-level update logic.
2255
+ *
2256
+ * @param context - the notification server actions context (destructured for the transform factory)
2257
+ * @returns a transform-and-validate function that returns the notification box document unchanged
2258
+ */ function updateNotificationBoxFactory(context) {
2259
+ var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2209
2260
  return firebaseServerActionTransformFunctionFactory(updateNotificationBoxParamsType, function() {
2210
2261
  return _async_to_generator$d(function() {
2211
2262
  return _ts_generator$d(this, function(_state) {
@@ -2232,6 +2283,9 @@ function updateNotificationBoxFactory(param) {
2232
2283
  *
2233
2284
  * Manages the exclusion list (`x`) on both the box recipient and the corresponding
2234
2285
  * {@link NotificationUser}'s send exclusion array, keeping them in sync.
2286
+ *
2287
+ * @param context - the base notification server actions context with collection access
2288
+ * @returns an async function that updates recipient exclusions within a transaction
2235
2289
  */ function updateNotificationBoxRecipientExclusionInTransactionFactory(context) {
2236
2290
  var notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection;
2237
2291
  return function(input, transaction) {
@@ -2267,7 +2321,7 @@ function updateNotificationBoxFactory(param) {
2267
2321
  targetRecipient = notificationBox.r.find(function(x) {
2268
2322
  return x.i === i;
2269
2323
  });
2270
- if (!targetRecipient || !targetRecipient.uid) {
2324
+ if (!(targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.uid)) {
2271
2325
  throw notificationBoxExclusionTargetInvalidError();
2272
2326
  } else {
2273
2327
  targetUid = targetRecipient.uid;
@@ -2277,21 +2331,16 @@ function updateNotificationBoxFactory(param) {
2277
2331
  if (!targetUid) {
2278
2332
  throw notificationBoxExclusionTargetInvalidError();
2279
2333
  }
2280
- return [
2281
- 4,
2282
- notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(targetUid)
2283
- ];
2284
- case 4:
2285
- notificationUserDocument = _state.sent();
2334
+ notificationUserDocument = notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(targetUid);
2286
2335
  return [
2287
2336
  4,
2288
2337
  notificationUserDocument.snapshotData()
2289
2338
  ];
2290
- case 5:
2339
+ case 4:
2291
2340
  notificationUser = _state.sent();
2292
2341
  if (!notificationUser) return [
2293
2342
  3,
2294
- 7
2343
+ 6
2295
2344
  ];
2296
2345
  // only update if the user exists
2297
2346
  targetExclusions = [
@@ -2306,13 +2355,13 @@ function updateNotificationBoxFactory(param) {
2306
2355
  4,
2307
2356
  notificationUserDocument.update(notificationUserUpdate)
2308
2357
  ];
2309
- case 6:
2358
+ case 5:
2310
2359
  _state.sent();
2311
2360
  result = {
2312
2361
  notificationUserUpdate: notificationUserUpdate
2313
2362
  };
2314
- _state.label = 7;
2315
- case 7:
2363
+ _state.label = 6;
2364
+ case 6:
2316
2365
  return [
2317
2366
  2,
2318
2367
  result
@@ -2328,6 +2377,9 @@ function updateNotificationBoxFactory(param) {
2328
2377
  * Handles inserting new recipients, updating existing ones, and removing recipients.
2329
2378
  * Syncs changes with the recipient's {@link NotificationUser} document and manages
2330
2379
  * recipient index assignment via a sorted-values free-index calculator.
2380
+ *
2381
+ * @param context - the base notification server actions context with auth and collection access
2382
+ * @returns an async function that updates a recipient on a notification box within a transaction
2331
2383
  */ function updateNotificationBoxRecipientInTransactionFactory(context) {
2332
2384
  var authService = context.authService, notificationBoxCollection = context.notificationBoxCollection, notificationUserCollection = context.notificationUserCollection;
2333
2385
  var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
@@ -2385,14 +2437,14 @@ function updateNotificationBoxFactory(param) {
2385
2437
  case 4:
2386
2438
  if (!notificationBox) return [
2387
2439
  3,
2388
- 18
2440
+ 17
2389
2441
  ];
2390
2442
  notificationBox.m;
2391
2443
  targetRecipientIndex = notificationBox.r.findIndex(findRecipientFn);
2392
2444
  targetRecipient = notificationBox.r[targetRecipientIndex];
2393
2445
  if (remove) {
2394
- if (targetRecipientIndex != null) {
2395
- r = _to_consumable_array$4(notificationBox.r); // remove if they exist.
2446
+ if (targetRecipientIndex !== -1) {
2447
+ r = _to_consumable_array$5(notificationBox.r); // remove if they exist.
2396
2448
  delete r[targetRecipientIndex];
2397
2449
  }
2398
2450
  } else {
@@ -2405,7 +2457,7 @@ function updateNotificationBoxFactory(param) {
2405
2457
  i: (_ref1 = targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.i) !== null && _ref1 !== void 0 ? _ref1 : UNSET_INDEX_NUMBER,
2406
2458
  c: c
2407
2459
  }, updateNotificationRecipient(targetRecipient !== null && targetRecipient !== void 0 ? targetRecipient : {}, params));
2408
- r = _to_consumable_array$4(notificationBox.r);
2460
+ r = _to_consumable_array$5(notificationBox.r);
2409
2461
  if (targetRecipient) {
2410
2462
  nextRecipient.i = targetRecipient.i;
2411
2463
  nextRecipient = mergeNotificationBoxRecipients(targetRecipient, nextRecipient);
@@ -2420,30 +2472,25 @@ function updateNotificationBoxFactory(param) {
2420
2472
  }
2421
2473
  if (!(r != null)) return [
2422
2474
  3,
2423
- 18
2475
+ 17
2424
2476
  ];
2425
2477
  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
2478
  if (!(notificationUserId != null)) return [
2427
2479
  3,
2428
- 13
2480
+ 12
2429
2481
  ];
2430
2482
  notificationBoxId = notificationBoxDocument.id;
2431
- return [
2432
- 4,
2433
- notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(notificationUserId)
2434
- ];
2435
- case 5:
2436
- notificationUserDocument = _state.sent();
2483
+ notificationUserDocument = notificationUserCollection.documentAccessorForTransaction(transaction).loadDocumentForId(notificationUserId);
2437
2484
  return [
2438
2485
  4,
2439
2486
  notificationUserDocument.snapshotData()
2440
2487
  ];
2441
- case 6:
2488
+ case 5:
2442
2489
  notificationUser = _state.sent();
2443
2490
  createNotificationUser = !notificationUser && !remove && insert;
2444
2491
  if (!createNotificationUser) return [
2445
2492
  3,
2446
- 8
2493
+ 7
2447
2494
  ];
2448
2495
  // assert they exist in the auth system
2449
2496
  userContext = authService.userContext(notificationUserId);
@@ -2451,7 +2498,7 @@ function updateNotificationBoxFactory(param) {
2451
2498
  4,
2452
2499
  userContext.exists()
2453
2500
  ];
2454
- case 7:
2501
+ case 6:
2455
2502
  userExistsInAuth = _state.sent();
2456
2503
  if (!userExistsInAuth) {
2457
2504
  throw notificationUserInvalidUidForCreateError(notificationUserId);
@@ -2470,11 +2517,11 @@ function updateNotificationBoxFactory(param) {
2470
2517
  }
2471
2518
  };
2472
2519
  notificationUser = notificationUserTemplate;
2473
- _state.label = 8;
2474
- case 8:
2520
+ _state.label = 7;
2521
+ case 7:
2475
2522
  if (!(notificationUser != null)) return [
2476
2523
  3,
2477
- 13
2524
+ 12
2478
2525
  ];
2479
2526
  _updateNotificationUserNotificationBoxRecipientConfig = updateNotificationUserNotificationBoxRecipientConfig({
2480
2527
  notificationBoxId: notificationBoxId,
@@ -2489,7 +2536,7 @@ function updateNotificationBoxFactory(param) {
2489
2536
  }) : undefined;
2490
2537
  if (!createNotificationUser) return [
2491
2538
  3,
2492
- 10
2539
+ 9
2493
2540
  ];
2494
2541
  newUserTemplate = _object_spread_props$a(_object_spread$b({}, notificationUser), {
2495
2542
  bc: updatedBc !== null && updatedBc !== void 0 ? updatedBc : [],
@@ -2499,16 +2546,16 @@ function updateNotificationBoxFactory(param) {
2499
2546
  4,
2500
2547
  notificationUserDocument.create(newUserTemplate)
2501
2548
  ];
2502
- case 9:
2549
+ case 8:
2503
2550
  _state.sent();
2504
2551
  return [
2505
2552
  3,
2506
- 12
2553
+ 11
2507
2554
  ];
2508
- case 10:
2555
+ case 9:
2509
2556
  if (!(updatedBc != null)) return [
2510
2557
  3,
2511
- 12
2558
+ 11
2512
2559
  ];
2513
2560
  return [
2514
2561
  4,
@@ -2517,53 +2564,53 @@ function updateNotificationBoxFactory(param) {
2517
2564
  b: updatedB
2518
2565
  })
2519
2566
  ];
2520
- case 11:
2567
+ case 10:
2521
2568
  _state.sent();
2522
- _state.label = 12;
2523
- case 12:
2569
+ _state.label = 11;
2570
+ case 11:
2524
2571
  // Set if nextRecipient is updated/influence from existing configuration
2525
- if (targetRecipientIndex != null && updatedNotificationBoxRecipient && !remove) {
2572
+ if (targetRecipientIndex !== -1 && updatedNotificationBoxRecipient && !remove) {
2526
2573
  r[targetRecipientIndex] = updatedNotificationBoxRecipient; // set the updated value in r
2527
2574
  }
2528
- _state.label = 13;
2529
- case 13:
2575
+ _state.label = 12;
2576
+ case 12:
2530
2577
  updatedNotificationBox = _object_spread_props$a(_object_spread$b({}, notificationBox), {
2531
2578
  r: r
2532
2579
  });
2533
2580
  notificationBoxWasCreated = false;
2534
2581
  if (!createNotificationBox) return [
2535
2582
  3,
2536
- 15
2583
+ 14
2537
2584
  ];
2538
2585
  return [
2539
2586
  4,
2540
2587
  notificationBoxDocument.create(updatedNotificationBox)
2541
2588
  ];
2542
- case 14:
2589
+ case 13:
2543
2590
  _state.sent();
2544
2591
  notificationBoxWasCreated = true;
2545
2592
  return [
2546
2593
  3,
2547
- 17
2594
+ 16
2548
2595
  ];
2549
- case 15:
2596
+ case 14:
2550
2597
  return [
2551
2598
  4,
2552
2599
  notificationBoxDocument.update({
2553
2600
  r: r
2554
2601
  })
2555
2602
  ];
2556
- case 16:
2603
+ case 15:
2557
2604
  _state.sent();
2558
- _state.label = 17;
2559
- case 17:
2605
+ _state.label = 16;
2606
+ case 16:
2560
2607
  result = {
2561
2608
  updatedNotificationBox: updatedNotificationBox,
2562
2609
  notificationBoxWasCreated: notificationBoxWasCreated,
2563
2610
  notificationBoxDocument: notificationBoxDocument
2564
2611
  };
2565
- _state.label = 18;
2566
- case 18:
2612
+ _state.label = 17;
2613
+ case 17:
2567
2614
  return [
2568
2615
  2,
2569
2616
  result
@@ -2578,6 +2625,9 @@ function updateNotificationBoxFactory(param) {
2578
2625
  *
2579
2626
  * Wraps the in-transaction recipient update logic, handling both recipient changes
2580
2627
  * and send exclusion updates in a single Firestore transaction.
2628
+ *
2629
+ * @param context - the notification server actions context with Firestore and collection access
2630
+ * @returns a transform-and-validate function that updates a recipient on a notification box
2581
2631
  */ function updateNotificationBoxRecipientFactory(context) {
2582
2632
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
2583
2633
  var updateNotificationBoxRecipientInTransaction = updateNotificationBoxRecipientInTransactionFactory(context);
@@ -2679,6 +2729,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
2679
2729
  *
2680
2730
  * Supports throttling via `sendAt` time, configurable send flags, and task-based
2681
2731
  * async workflows for notifications that require multi-step processing.
2732
+ *
2733
+ * @param context - the notification server actions context with template, send, and task services
2734
+ * @returns a transform-and-validate function that processes and sends a notification document
2682
2735
  */ function sendNotificationFactory(context) {
2683
2736
  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
2737
  var createNotificationBoxInTransaction = createNotificationBoxInTransactionFactory(context);
@@ -2759,7 +2812,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
2759
2812
  notificationTemplate.at = 0; // reset checkpoint attempt/delay count
2760
2813
  }
2761
2814
  // add the checkpoint to the notification
2762
- notificationTemplate.tpr = _to_consumable_array$4(removeFromCompletionsArrayWithTaskResult(notification.tpr, handleTaskResult)).concat(_to_consumable_array$4(asArray(completion)));
2815
+ notificationTemplate.tpr = _to_consumable_array$5(removeFromCompletionsArrayWithTaskResult(notification.tpr, handleTaskResult)).concat(_to_consumable_array$5(asArray(completion)));
2763
2816
  // calculate the updated notification item
2764
2817
  notificationTemplate.n = _object_spread_props$a(_object_spread$b({}, notification.n), {
2765
2818
  d: _object_spread$b({}, notification.n.d, updateMetadata ? filterOnlyUndefinedValues(updateMetadata) : undefined // ignore any undefined values
@@ -2769,7 +2822,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
2769
2822
  // if the tpr has not changed, then it is also considered a reversal
2770
2823
  if (tryRunNextPart) {
2771
2824
  tprChanged = !iterablesAreSetEquivalent(notification.tpr, notificationTemplate.tpr);
2772
- partTprReversal = !tprChanged || tprChanged && notificationTemplate.tpr.length <= notification.tpr.length;
2825
+ partTprReversal = !tprChanged || notificationTemplate.tpr.length <= notification.tpr.length;
2773
2826
  if (allCompletedSubTasks != null) {
2774
2827
  switch(allCompletedSubTasks){
2775
2828
  case true:
@@ -2778,11 +2831,13 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
2778
2831
  tryRunNextPart = !partTprReversal;
2779
2832
  break;
2780
2833
  default:
2781
- // check subtask tpr changes
2782
- nextCompleteSubTasks = asArray(allCompletedSubTasks);
2783
- subtaskTprChanged = !iterablesAreSetEquivalent(previouslyCompleteSubTasks, nextCompleteSubTasks);
2784
- partTprReversal = !subtaskTprChanged || subtaskTprChanged && nextCompleteSubTasks.length <= previouslyCompleteSubTasks.length;
2785
- break;
2834
+ {
2835
+ // check subtask tpr changes
2836
+ nextCompleteSubTasks = asArray(allCompletedSubTasks);
2837
+ subtaskTprChanged = !iterablesAreSetEquivalent(previouslyCompleteSubTasks, nextCompleteSubTasks);
2838
+ partTprReversal = !subtaskTprChanged || nextCompleteSubTasks.length <= previouslyCompleteSubTasks.length;
2839
+ break;
2840
+ }
2786
2841
  }
2787
2842
  }
2788
2843
  }
@@ -3001,7 +3056,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3001
3056
  ];
3002
3057
  case 2:
3003
3058
  _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, currentEsr = notification.esr, currentTsr = notification.tsr;
3059
+ es = notification.es, ts = notification.ts, ps = notification.ps, ns = notification.ns;
3060
+ currentEsr = notification.esr, currentTsr = notification.tsr;
3005
3061
  if (!(es === NotificationSendState.QUEUED || es === NotificationSendState.SENT_PARTIAL)) return [
3006
3062
  3,
3007
3063
  15
@@ -3108,9 +3164,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3108
3164
  case 13:
3109
3165
  if (sendEmailsResult != null) {
3110
3166
  success1 = sendEmailsResult.success, failed = sendEmailsResult.failed;
3111
- esr = success1.length ? currentEsr.concat(success1.map(function(x) {
3167
+ esr = success1.length ? _to_consumable_array$5(currentEsr).concat(_to_consumable_array$5(success1.map(function(x) {
3112
3168
  return x.toLowerCase();
3113
- })) : undefined;
3169
+ }))) : undefined;
3114
3170
  if (failed.length > 0) {
3115
3171
  es = NotificationSendState.SENT_PARTIAL;
3116
3172
  } else {
@@ -3229,7 +3285,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3229
3285
  case 26:
3230
3286
  if (sendTextsResult != null) {
3231
3287
  success2 = sendTextsResult.success, failed1 = sendTextsResult.failed;
3232
- tsr = success2.length ? currentTsr.concat(success2) : undefined;
3288
+ tsr = success2.length ? _to_consumable_array$5(currentTsr).concat(_to_consumable_array$5(success2)) : undefined;
3233
3289
  if (failed1.length > 0) {
3234
3290
  ts = NotificationSendState.SENT_PARTIAL;
3235
3291
  } else {
@@ -3437,6 +3493,10 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3437
3493
  // deleted successfully
3438
3494
  success = deletedNotification;
3439
3495
  break;
3496
+ case NotificationSendType.INIT_BOX_AND_SEND:
3497
+ case NotificationSendType.SEND_WITHOUT_CREATING_BOX:
3498
+ case NotificationSendType.TASK_NOTIFICATION:
3499
+ break;
3440
3500
  }
3441
3501
  _state.label = 48;
3442
3502
  case 48:
@@ -3457,7 +3517,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3457
3517
  4,
3458
3518
  firestoreContext.runTransaction(function(transaction) {
3459
3519
  return _async_to_generator$d(function() {
3460
- var notificationBoxDocument, notificationDocumentInTransaction, _ref, notificationBox, notification, model, isNotificationTask, tryRun, throttled, nextSat, createdBox, deletedNotification, notificationBoxNeedsInitialization, isKnownTemplateType, isConfiguredTemplateType, onlySendToExplicitlyEnabledRecipients, onlyTextExplicitlyEnabledRecipients, templateInstance, notificationTaskHandler, t // notification task/template type
3520
+ 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
3521
  , delay, _notification_ois, _notification_ots, templateTypeInfo, retryAttempts, delay1, _, notificationBoxTemplate, isAtMaxAttempts, a;
3462
3522
  function deleteNotification() {
3463
3523
  return _async_to_generator$d(function() {
@@ -3495,7 +3555,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3495
3555
  _ref = _sliced_to_array$2.apply(void 0, [
3496
3556
  _state.sent(),
3497
3557
  2
3498
- ]), notificationBox = _ref[0], notification = _ref[1];
3558
+ ]), initialNotificationBox = _ref[0], notification = _ref[1];
3559
+ notificationBox = initialNotificationBox;
3499
3560
  model = inferKeyFromTwoWayFlatFirestoreModelKey(notificationBoxDocument.id);
3500
3561
  isNotificationTask = (notification === null || notification === void 0 ? void 0 : notification.st) === NotificationSendType.TASK_NOTIFICATION;
3501
3562
  tryRun = true;
@@ -3523,7 +3584,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3523
3584
  notificationBoxNeedsInitialization = false;
3524
3585
  if (!(notification && tryRun)) return [
3525
3586
  3,
3526
- 18
3587
+ 19
3527
3588
  ];
3528
3589
  // if we're still trying to run, check the template is ok. If not, cancel the run.
3529
3590
  t = notification.n.t;
@@ -3580,7 +3641,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3580
3641
  case 7:
3581
3642
  return [
3582
3643
  3,
3583
- 18
3644
+ 19
3584
3645
  ];
3585
3646
  case 8:
3586
3647
  templateInstance = notificationTemplateService.templateInstanceForType(t);
@@ -3601,7 +3662,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3601
3662
  9
3602
3663
  ];
3603
3664
  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."));
3665
+ 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
3666
  } else {
3606
3667
  console.warn('Unknown template type of "'.concat(t, '" was found in a Notification. Send is being delayed by ').concat(delay1, " hours."));
3607
3668
  }
@@ -3625,7 +3686,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3625
3686
  case 11:
3626
3687
  if (!(!notificationBox && tryRun)) return [
3627
3688
  3,
3628
- 17
3689
+ 18
3629
3690
  ];
3630
3691
  _ = notification.st;
3631
3692
  switch(_){
@@ -3644,10 +3705,15 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3644
3705
  3,
3645
3706
  16
3646
3707
  ];
3708
+ case NotificationSendType.TASK_NOTIFICATION:
3709
+ return [
3710
+ 3,
3711
+ 17
3712
+ ];
3647
3713
  }
3648
3714
  return [
3649
3715
  3,
3650
- 17
3716
+ 18
3651
3717
  ];
3652
3718
  case 12:
3653
3719
  return [
@@ -3662,7 +3728,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3662
3728
  createdBox = true;
3663
3729
  return [
3664
3730
  3,
3665
- 17
3731
+ 18
3666
3732
  ];
3667
3733
  case 14:
3668
3734
  // delete the notification since it won't get sent.
@@ -3674,43 +3740,49 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3674
3740
  _state.sent();
3675
3741
  return [
3676
3742
  3,
3677
- 17
3743
+ 18
3678
3744
  ];
3679
3745
  case 16:
3680
3746
  // continue with current tryRun
3681
3747
  return [
3682
3748
  3,
3683
- 17
3749
+ 18
3684
3750
  ];
3685
3751
  case 17:
3752
+ // task notifications do not require a notification box; continue with current tryRun
3753
+ return [
3754
+ 3,
3755
+ 18
3756
+ ];
3757
+ case 18:
3686
3758
  // if the notification box is not initialized/synchronized yet, do not run.
3687
3759
  if (tryRun && notificationBox && notificationBox.s) {
3688
3760
  notificationBoxNeedsInitialization = true;
3689
3761
  tryRun = false;
3690
3762
  nextSat = addMinutes(now, NOTIFICATION_BOX_NOT_INITIALIZED_DELAY_MINUTES);
3691
3763
  }
3692
- _state.label = 18;
3693
- case 18:
3764
+ _state.label = 19;
3765
+ case 19:
3694
3766
  if (!(notification != null && nextSat != null && !deletedNotification)) return [
3695
3767
  3,
3696
- 22
3768
+ 23
3697
3769
  ];
3698
3770
  isAtMaxAttempts = notification.a >= NOTIFICATION_MAX_SEND_ATTEMPTS;
3699
3771
  if (!(isAtMaxAttempts && notificationBoxNeedsInitialization)) return [
3700
3772
  3,
3701
- 20
3773
+ 21
3702
3774
  ];
3703
3775
  return [
3704
3776
  4,
3705
3777
  deleteNotification()
3706
3778
  ];
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
3779
  case 20:
3780
+ _state.sent(); // just delete the notification if the box still hasn't been initialized successfully at this point.
3781
+ _state.label = 21;
3782
+ case 21:
3711
3783
  if (!!deletedNotification) return [
3712
3784
  3,
3713
- 22
3785
+ 23
3714
3786
  ];
3715
3787
  a = isNotificationTask && tryRun ? notification.a : notification.a + 1; // do not update a notification task's attempt count here, unless tryRun fails
3716
3788
  // 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 +3793,10 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3721
3793
  a: a
3722
3794
  })
3723
3795
  ];
3724
- case 21:
3725
- _state.sent();
3726
- _state.label = 22;
3727
3796
  case 22:
3797
+ _state.sent();
3798
+ _state.label = 23;
3799
+ case 23:
3728
3800
  return [
3729
3801
  2,
3730
3802
  {
@@ -3836,6 +3908,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3836
3908
  * and an optional {@link NotificationExpediteService} for immediate delivery.
3837
3909
  * Continues processing batches until no more queued notifications are found
3838
3910
  * or the time budget is exhausted.
3911
+ *
3912
+ * @param context - the notification server actions context with collection group and send factory access
3913
+ * @returns a transform-and-validate function that processes all queued notifications and returns aggregate results
3839
3914
  */ function sendQueuedNotificationsFactory(context) {
3840
3915
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationCollectionGroup = context.notificationCollectionGroup;
3841
3916
  var sendNotification = sendNotificationFactory(context);
@@ -3877,7 +3952,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3877
3952
  excessLoopsDetected = false;
3878
3953
  sendQueuedNotifications = function sendQueuedNotifications() {
3879
3954
  return _async_to_generator$d(function() {
3880
- var query, notificationDocuments, result;
3955
+ var query, notificationDocuments;
3881
3956
  return _ts_generator$d(this, function(_state) {
3882
3957
  switch(_state.label){
3883
3958
  case 0:
@@ -3889,7 +3964,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3889
3964
  case 1:
3890
3965
  notificationDocuments = _state.sent();
3891
3966
  return [
3892
- 4,
3967
+ 2,
3893
3968
  performAsyncTasks(notificationDocuments, function(notificationDocument) {
3894
3969
  return _async_to_generator$d(function() {
3895
3970
  var result;
@@ -3914,12 +3989,6 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
3914
3989
  maxParallelTasks: maxParallelTasks
3915
3990
  })
3916
3991
  ];
3917
- case 2:
3918
- result = _state.sent();
3919
- return [
3920
- 2,
3921
- result
3922
- ];
3923
3992
  }
3924
3993
  });
3925
3994
  })();
@@ -4009,6 +4078,9 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4009
4078
  * Queries for {@link Notification} documents that are ready for cleanup (fully sent,
4010
4079
  * past the retention window) and deletes them in batches. Continues until no more
4011
4080
  * cleanup-eligible notifications are found.
4081
+ *
4082
+ * @param context - the notification server actions context with Firestore and collection access
4083
+ * @returns a transform-and-validate function that cleans up sent notification documents and returns aggregate results
4012
4084
  */ function cleanupSentNotificationsFactory(context) {
4013
4085
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationCollectionGroup = context.notificationCollectionGroup, notificationBoxCollection = context.notificationBoxCollection, notificationWeekCollectionFactory = context.notificationWeekCollectionFactory;
4014
4086
  return firebaseServerActionTransformFunctionFactory(cleanupSentNotificationsParamsType, function() {
@@ -4021,7 +4093,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4021
4093
  var notificationBoxesUpdatesCount, notificationsDeleted, notificationTasksDeletedCount, notificationWeeksCreated, notificationWeeksUpdated, cleanupSentNotificationsResults, notificationBoxesUpdated, result;
4022
4094
  function cleanupSentNotifications() {
4023
4095
  return _async_to_generator$d(function() {
4024
- var query, notificationDocuments, notificationDocumentsGroupedByNotificationBox, result;
4096
+ var query, notificationDocuments, notificationDocumentsGroupedByNotificationBox;
4025
4097
  return _ts_generator$d(this, function(_state) {
4026
4098
  switch(_state.label){
4027
4099
  case 0:
@@ -4032,14 +4104,14 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4032
4104
  ];
4033
4105
  case 1:
4034
4106
  notificationDocuments = _state.sent();
4035
- notificationDocumentsGroupedByNotificationBox = Array.from(makeValuesGroupMap(notificationDocuments, function(x) {
4107
+ notificationDocumentsGroupedByNotificationBox = _to_consumable_array$5(makeValuesGroupMap(notificationDocuments, function(x) {
4036
4108
  return x.parent.id;
4037
4109
  }).values());
4038
4110
  return [
4039
- 4,
4111
+ 2,
4040
4112
  performAsyncTasks(notificationDocumentsGroupedByNotificationBox, function(notificationDocumentsInSameBox) {
4041
4113
  return _async_to_generator$d(function() {
4042
- var allPairs, allPairsWithDataAndMarkedDeleted, _separateValues, taskPairsWithDataAndMarkedDeleted, normalPairsWithDataAndMarkedDeleted, pairsGroupedByWeek, pairsGroupedByWeekInBatches, notificationBoxDocument, notificationWeekResults, writeBatch, writeBatchAccessor, weeksCreated, weeksUpdated, tasksDeleted, result;
4114
+ var allPairs, allPairsWithDataAndMarkedDeleted, _separateValues, taskPairsWithDataAndMarkedDeleted, normalPairsWithDataAndMarkedDeleted, pairsGroupedByWeek, pairsGroupedByWeekInBatches, notificationBoxDocument, notificationWeekResults, writeBatch, writeBatchAccessor, weeksCreated, weeksUpdated, tasksDeleted;
4043
4115
  return _ts_generator$d(this, function(_state) {
4044
4116
  switch(_state.label){
4045
4117
  case 0:
@@ -4057,11 +4129,11 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4057
4129
  var _x_data;
4058
4130
  return ((_x_data = x.data) === null || _x_data === void 0 ? void 0 : _x_data.st) === NotificationSendType.TASK_NOTIFICATION;
4059
4131
  }), taskPairsWithDataAndMarkedDeleted = _separateValues.included, normalPairsWithDataAndMarkedDeleted = _separateValues.excluded;
4060
- pairsGroupedByWeek = Array.from(makeValuesGroupMap(normalPairsWithDataAndMarkedDeleted, function(x) {
4132
+ pairsGroupedByWeek = _to_consumable_array$5(makeValuesGroupMap(normalPairsWithDataAndMarkedDeleted, function(x) {
4061
4133
  return yearWeekCode(x.data.sat);
4062
4134
  }).entries());
4063
4135
  // batch incase there are a lot of new notifications to move to week
4064
- pairsGroupedByWeekInBatches = pairsGroupedByWeek.map(function(x) {
4136
+ pairsGroupedByWeekInBatches = pairsGroupedByWeek.flatMap(function(x) {
4065
4137
  var batches = batch(x[1], 40);
4066
4138
  return batches.map(function(batch) {
4067
4139
  return [
@@ -4069,13 +4141,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4069
4141
  batch
4070
4142
  ];
4071
4143
  });
4072
- }).flat();
4073
- return [
4074
- 4,
4075
- notificationBoxCollection.documentAccessor().loadDocument(notificationDocumentsInSameBox[0].parent)
4076
- ];
4077
- case 2:
4078
- notificationBoxDocument = _state.sent();
4144
+ });
4145
+ notificationBoxDocument = notificationBoxCollection.documentAccessor().loadDocument(notificationDocumentsInSameBox[0].parent);
4079
4146
  return [
4080
4147
  4,
4081
4148
  performAsyncTasks(pairsGroupedByWeekInBatches, function(param) {
@@ -4105,7 +4172,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4105
4172
  var shouldSaveToNotificationWeek = shouldSaveNotificationToNotificationWeek(data);
4106
4173
  return shouldSaveToNotificationWeek ? data.n : undefined;
4107
4174
  }));
4108
- n = _to_consumable_array$4((_ref = notificationWeek === null || notificationWeek === void 0 ? void 0 : notificationWeek.n) !== null && _ref !== void 0 ? _ref : []).concat(_to_consumable_array$4(newItems));
4175
+ 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
4176
  if (!!notificationWeek) return [
4110
4177
  3,
4111
4178
  3
@@ -4160,7 +4227,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4160
4227
  })();
4161
4228
  })
4162
4229
  ];
4163
- case 3:
4230
+ case 2:
4164
4231
  notificationWeekResults = _state.sent();
4165
4232
  // delete all the task notifications
4166
4233
  writeBatch = firestoreContext.batch();
@@ -4171,13 +4238,13 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4171
4238
  return writeBatchAccessor.loadDocumentFrom(x.document).accessor.delete();
4172
4239
  }))
4173
4240
  ];
4174
- case 4:
4241
+ case 3:
4175
4242
  _state.sent();
4176
4243
  return [
4177
4244
  4,
4178
4245
  writeBatch.commit()
4179
4246
  ];
4180
- case 5:
4247
+ case 4:
4181
4248
  _state.sent();
4182
4249
  weeksCreated = 0;
4183
4250
  weeksUpdated = 0;
@@ -4189,15 +4256,14 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4189
4256
  weeksUpdated += 1;
4190
4257
  }
4191
4258
  });
4192
- result = {
4193
- weeksCreated: weeksCreated,
4194
- weeksUpdated: weeksUpdated,
4195
- itemsDeleted: allPairsWithDataAndMarkedDeleted.length,
4196
- tasksDeleted: tasksDeleted
4197
- };
4198
4259
  return [
4199
4260
  2,
4200
- result
4261
+ {
4262
+ weeksCreated: weeksCreated,
4263
+ weeksUpdated: weeksUpdated,
4264
+ itemsDeleted: allPairsWithDataAndMarkedDeleted.length,
4265
+ tasksDeleted: tasksDeleted
4266
+ }
4201
4267
  ];
4202
4268
  }
4203
4269
  });
@@ -4206,12 +4272,6 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = hoursToMilliseconds(NOTIFICATION_T
4206
4272
  maxParallelTasks: 10
4207
4273
  })
4208
4274
  ];
4209
- case 2:
4210
- result = _state.sent();
4211
- return [
4212
- 2,
4213
- result
4214
- ];
4215
4275
  }
4216
4276
  });
4217
4277
  })();
@@ -4476,6 +4536,7 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4476
4536
  * initialization action to its factory function.
4477
4537
  *
4478
4538
  * @param context - the initialization context with template functions and Firestore access
4539
+ * @returns a fully wired {@link NotificationInitServerActions} instance
4479
4540
  *
4480
4541
  * @example
4481
4542
  * ```ts
@@ -4502,6 +4563,7 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4502
4563
  * Skips initialization if the model is already initialized, optionally throwing an error.
4503
4564
  *
4504
4565
  * @param input - the document, transaction, template function, and options
4566
+ * @returns an object with `initialized` and `alreadyInitialized` boolean flags
4505
4567
  * @throws notificationModelAlreadyInitializedError when `throwErrorIfAlreadyInitialized` is true
4506
4568
  */ function initializeNotificationModelInTransaction(input) {
4507
4569
  return _async_to_generator$c(function() {
@@ -4603,6 +4665,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4603
4665
  *
4604
4666
  * Loads the box document in the transaction, reads its current data, and delegates
4605
4667
  * to {@link initializeNotificationModelInTransaction} with the box-specific template function.
4668
+ *
4669
+ * @param context - the initialization context with collection references and template functions
4670
+ * @returns an async function that initializes a notification box given params, document, and transaction
4606
4671
  */ function initializeNotificationBoxInTransactionFactory(context) {
4607
4672
  var notificationBoxCollection = context.notificationBoxCollection, makeTemplateForNotificationBoxInitialization = context.makeTemplateForNotificationBoxInitialization;
4608
4673
  return function(params, notificationBoxDocument, transaction) {
@@ -4639,6 +4704,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4639
4704
  *
4640
4705
  * Wraps the in-transaction initialization in a Firestore transaction
4641
4706
  * and follows the transform-and-validate pattern.
4707
+ *
4708
+ * @param context - the initialization context with Firestore access and template functions
4709
+ * @returns a transform-and-validate function that initializes a single notification box
4642
4710
  */ function initializeNotificationBoxFactory(context) {
4643
4711
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
4644
4712
  var initializeNotificationBoxInTransaction = initializeNotificationBoxInTransactionFactory(context);
@@ -4679,8 +4747,11 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4679
4747
  * Batch-processes all {@link NotificationBox} documents flagged for initialization
4680
4748
  * by querying for entries with `s=true` (setup needed), then initializing each in
4681
4749
  * parallel (up to 5 concurrent tasks). Loops until no more flagged boxes are found.
4750
+ *
4751
+ * @param context - the initialization context with Firestore access and collection references
4752
+ * @returns a transform-and-validate function that batch-initializes all applicable notification boxes
4682
4753
  */ function initializeAllApplicableNotificationBoxesFactory(context) {
4683
- var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection; context.notificationCollectionGroup;
4754
+ var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationBoxCollection = context.notificationBoxCollection;
4684
4755
  var initializeNotificationBoxInTransaction = initializeNotificationBoxInTransactionFactory(context);
4685
4756
  return firebaseServerActionTransformFunctionFactory(initializeAllApplicableNotificationBoxesParamsType, function() {
4686
4757
  return _async_to_generator$c(function() {
@@ -4796,6 +4867,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4796
4867
  *
4797
4868
  * Loads the summary document in the transaction, reads its current data, and delegates
4798
4869
  * to {@link initializeNotificationModelInTransaction} with the summary-specific template function.
4870
+ *
4871
+ * @param context - the initialization context with collection references and template functions
4872
+ * @returns an async function that initializes a notification summary given params, document, and transaction
4799
4873
  */ function initializeNotificationSummaryInTransactionFactory(context) {
4800
4874
  var notificationSummaryCollection = context.notificationSummaryCollection, makeTemplateForNotificationSummaryInitialization = context.makeTemplateForNotificationSummaryInitialization;
4801
4875
  return function(params, notificationSummaryDocument, transaction) {
@@ -4832,6 +4906,9 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4832
4906
  *
4833
4907
  * Wraps the in-transaction summary initialization in a Firestore transaction
4834
4908
  * and follows the transform-and-validate pattern.
4909
+ *
4910
+ * @param context - the initialization context with Firestore access and template functions
4911
+ * @returns a transform-and-validate function that initializes a single notification summary
4835
4912
  */ function initializeNotificationSummaryFactory(context) {
4836
4913
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
4837
4914
  var initializeNotificationSummaryInTransaction = initializeNotificationSummaryInTransactionFactory(context);
@@ -4872,8 +4949,11 @@ var MAKE_TEMPLATE_FOR_NOTIFICATION_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_
4872
4949
  * Batch-processes all {@link NotificationSummary} documents flagged for initialization
4873
4950
  * by querying for entries with `s=true` (setup needed), then initializing each in
4874
4951
  * parallel (up to 5 concurrent tasks). Loops until no more flagged summaries are found.
4952
+ *
4953
+ * @param context - the initialization context with Firestore access and collection references
4954
+ * @returns a transform-and-validate function that batch-initializes all applicable notification summaries
4875
4955
  */ function initializeAllApplicableNotificationSummariesFactory(context) {
4876
- var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection; context.notificationCollectionGroup;
4956
+ var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, notificationSummaryCollection = context.notificationSummaryCollection;
4877
4957
  var initializeNotificationSummaryInTransaction = initializeNotificationSummaryInTransactionFactory(context);
4878
4958
  return firebaseServerActionTransformFunctionFactory(initializeAllApplicableNotificationSummariesParamsType, function() {
4879
4959
  return _async_to_generator$c(function() {
@@ -5227,6 +5307,7 @@ function _ts_generator$b(thisArg, body) {
5227
5307
  * pre-wired with the resolved factory for that type.
5228
5308
  *
5229
5309
  * @param type - the notification template type
5310
+ * @returns a new {@link NotificationTemplateServiceInstance} bound to the given type
5230
5311
  */ key: "templateInstanceForType",
5231
5312
  value: function templateInstanceForType(type) {
5232
5313
  return notificationTemplateServiceInstance(this, type);
@@ -5248,6 +5329,7 @@ NotificationTemplateService = __decorate([
5248
5329
  *
5249
5330
  * @param service - the parent template service
5250
5331
  * @param type - the template type to bind
5332
+ * @returns a {@link NotificationTemplateServiceInstance} with the resolved factory for the type
5251
5333
  *
5252
5334
  * @example
5253
5335
  * ```ts
@@ -5469,6 +5551,7 @@ function _ts_generator$a(thisArg, body) {
5469
5551
  * Does not support Firestore transactions, as running should occur outside of a transaction.
5470
5552
  *
5471
5553
  * @param input - creation and run configuration
5554
+ * @returns the creation pair result with optional send/enqueue outcomes
5472
5555
  * @throws Error if the notification template is not flagged as unique
5473
5556
  *
5474
5557
  * @example
@@ -5827,8 +5910,8 @@ function _ts_generator$9(thisArg, body) {
5827
5910
  /**
5828
5911
  * Creates a new NotificationExpediteServiceInstance with the input NotificationExpediteService.
5829
5912
 
5830
- * @param notificationExpediteService
5831
- * @returns
5913
+ * @param notificationExpediteService - the expedite service to use for sending
5914
+ * @returns a new {@link NotificationExpediteServiceInstance} with an internal queue
5832
5915
  */ function notificationExpediteServiceInstance(notificationExpediteService) {
5833
5916
  var _documentsToSend = [];
5834
5917
  var initialize = function initialize() {
@@ -5847,28 +5930,18 @@ function _ts_generator$9(thisArg, body) {
5847
5930
  };
5848
5931
  var send = function send(options) {
5849
5932
  return _async_to_generator$9(function() {
5850
- var results;
5851
5933
  return _ts_generator$9(this, function(_state) {
5852
- switch(_state.label){
5853
- case 0:
5854
- return [
5855
- 4,
5856
- runAsyncTasksForValues(_documentsToSend, function(x) {
5857
- return notificationExpediteService.sendNotification(x, options);
5858
- }, {
5859
- nonConcurrentTaskKeyFactory: function nonConcurrentTaskKeyFactory(x) {
5860
- return x.parent.id // only send one notification at a time for a notification box
5861
- ;
5862
- }
5863
- })
5864
- ];
5865
- case 1:
5866
- results = _state.sent();
5867
- return [
5868
- 2,
5869
- results
5870
- ];
5871
- }
5934
+ return [
5935
+ 2,
5936
+ runAsyncTasksForValues(_documentsToSend, function(x) {
5937
+ return notificationExpediteService.sendNotification(x, options);
5938
+ }, {
5939
+ nonConcurrentTaskKeyFactory: function nonConcurrentTaskKeyFactory(x) {
5940
+ return x.parent.id // only send one notification at a time for a notification box
5941
+ ;
5942
+ }
5943
+ })
5944
+ ];
5872
5945
  });
5873
5946
  })();
5874
5947
  };
@@ -5896,6 +5969,8 @@ function _ts_generator$9(thisArg, body) {
5896
5969
  {
5897
5970
  /**
5898
5971
  * Returns the configured NotificationServerActions instance.
5972
+ *
5973
+ * @returns the current {@link NotificationServerActions} instance
5899
5974
  */ key: "getNotificationServerActions",
5900
5975
  value: function getNotificationServerActions() {
5901
5976
  return this._notificationServerActions;
@@ -5904,6 +5979,8 @@ function _ts_generator$9(thisArg, body) {
5904
5979
  {
5905
5980
  /**
5906
5981
  * Sets the NotificationServerActions instance to use.
5982
+ *
5983
+ * @param notificationServerActions - the actions instance to configure
5907
5984
  */ key: "setNotificationServerActions",
5908
5985
  value: function setNotificationServerActions(notificationServerActions) {
5909
5986
  this._notificationServerActions = notificationServerActions;
@@ -5951,6 +6028,8 @@ MutableNotificationExpediteService = __decorate([
5951
6028
  * Provides an instance of MutableNotificationExpediteService and NotificationExpediteService.
5952
6029
  *
5953
6030
  * This should generally be used in the global module of an app.
6031
+ *
6032
+ * @returns an array of NestJS providers for both MutableNotificationExpediteService and NotificationExpediteService
5954
6033
  */ function provideMutableNotificationExpediteService() {
5955
6034
  return [
5956
6035
  MutableNotificationExpediteService,
@@ -5964,6 +6043,8 @@ MutableNotificationExpediteService = __decorate([
5964
6043
  * Convenience function that exports NotificationExpediteService and MutableNotificationExpediteService.
5965
6044
  *
5966
6045
  * This should generally be used in the global module of an app.
6046
+ *
6047
+ * @returns an array of abstract classes to export from the NestJS module
5967
6048
  */ function exportMutableNotificationExpediteService() {
5968
6049
  return [
5969
6050
  NotificationExpediteService,
@@ -5976,7 +6057,7 @@ function _array_like_to_array$5(arr, len) {
5976
6057
  for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
5977
6058
  return arr2;
5978
6059
  }
5979
- function _array_without_holes$3(arr) {
6060
+ function _array_without_holes$4(arr) {
5980
6061
  if (Array.isArray(arr)) return _array_like_to_array$5(arr);
5981
6062
  }
5982
6063
  function _class_call_check$4(instance, Constructor) {
@@ -5997,10 +6078,10 @@ function _define_property$7(obj, key, value) {
5997
6078
  }
5998
6079
  return obj;
5999
6080
  }
6000
- function _iterable_to_array$3(iter) {
6081
+ function _iterable_to_array$4(iter) {
6001
6082
  if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
6002
6083
  }
6003
- function _non_iterable_spread$3() {
6084
+ function _non_iterable_spread$4() {
6004
6085
  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
6086
  }
6006
6087
  function _object_spread$7(target) {
@@ -6037,8 +6118,8 @@ function _object_spread_props$7(target, source) {
6037
6118
  }
6038
6119
  return target;
6039
6120
  }
6040
- function _to_consumable_array$3(arr) {
6041
- return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$3();
6121
+ function _to_consumable_array$4(arr) {
6122
+ return _array_without_holes$4(arr) || _iterable_to_array$4(arr) || _unsupported_iterable_to_array$5(arr) || _non_iterable_spread$4();
6042
6123
  }
6043
6124
  function _unsupported_iterable_to_array$5(o, minLen) {
6044
6125
  if (!o) return;
@@ -6052,7 +6133,15 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6052
6133
  /**
6053
6134
  * Factory that assembles the full {@link NotificationServerActionsContext} by combining
6054
6135
  * the base context with the template, send, task, and expedite services.
6055
- */ function notificationServerActionsContextFactory(context, notificationTemplateService, notificationSendService, notificationTaskService, notificationsExpediteService) {
6136
+ *
6137
+ * @param context - the base server actions context
6138
+ * @param notificationTemplateService - resolves message factories for notification template types
6139
+ * @param notificationSendService - handles sending notification messages
6140
+ * @param notificationTaskService - handles notification task dispatch
6141
+ * @param notificationsExpediteService - expedites immediate notification delivery
6142
+ * @returns the assembled {@link NotificationServerActionsContext}
6143
+ */ // eslint-disable-next-line @typescript-eslint/max-params
6144
+ function notificationServerActionsContextFactory(context, notificationTemplateService, notificationSendService, notificationTaskService, notificationsExpediteService) {
6056
6145
  return _object_spread_props$7(_object_spread$7({}, context), {
6057
6146
  notificationTemplateService: notificationTemplateService,
6058
6147
  notificationSendService: notificationSendService,
@@ -6062,12 +6151,19 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6062
6151
  }
6063
6152
  /**
6064
6153
  * Factory that creates a {@link NotificationServerActions} instance from the assembled context.
6065
- */ function notificationServerActionsFactory(context, mutableNotificationExpediteService) {
6154
+ *
6155
+ * @param context - the assembled notification server actions context
6156
+ * @returns a new {@link NotificationServerActions} instance
6157
+ */ function notificationServerActionsFactory(context) {
6066
6158
  return notificationServerActions(context);
6067
6159
  }
6068
6160
  /**
6069
6161
  * Factory that creates a {@link NotificationInitServerActions} instance by merging the
6070
6162
  * server actions context with the init-specific configuration.
6163
+ *
6164
+ * @param context - the assembled notification server actions context
6165
+ * @param notificationInitServerActionsContextConfig - init-specific configuration
6166
+ * @returns a new {@link NotificationInitServerActions} instance
6071
6167
  */ function notificationInitServerActionsFactory(context, notificationInitServerActionsContextConfig) {
6072
6168
  return notificationInitServerActions(_object_spread$7({}, context, notificationInitServerActionsContextConfig));
6073
6169
  }
@@ -6083,9 +6179,8 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6083
6179
  *
6084
6180
  * Be sure the class that delares the module using this function also extends AbstractAppNotificationModule.
6085
6181
  *
6086
- * @param provide
6087
- * @param useFactory
6088
- * @returns
6182
+ * @param config - module metadata configuration including dependency module and additional providers
6183
+ * @returns the assembled {@link ModuleMetadata} for the notification module
6089
6184
  */ function appNotificationModuleMetadata(config) {
6090
6185
  var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
6091
6186
  var dependencyModuleImport = dependencyModule ? [
@@ -6094,14 +6189,14 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6094
6189
  return {
6095
6190
  imports: [
6096
6191
  ConfigModule
6097
- ].concat(_to_consumable_array$3(dependencyModuleImport), _to_consumable_array$3(imports !== null && imports !== void 0 ? imports : [])),
6192
+ ].concat(_to_consumable_array$4(dependencyModuleImport), _to_consumable_array$4(imports !== null && imports !== void 0 ? imports : [])),
6098
6193
  exports: [
6099
6194
  NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN,
6100
6195
  NotificationExpediteService,
6101
6196
  NotificationTemplateService,
6102
6197
  NotificationServerActions,
6103
6198
  NotificationInitServerActions
6104
- ].concat(_to_consumable_array$3(exports$1 !== null && exports$1 !== void 0 ? exports$1 : [])),
6199
+ ].concat(_to_consumable_array$4(exports$1 !== null && exports$1 !== void 0 ? exports$1 : [])),
6105
6200
  providers: [
6106
6201
  {
6107
6202
  provide: NotificationExpediteService,
@@ -6126,8 +6221,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6126
6221
  provide: NotificationServerActions,
6127
6222
  useFactory: notificationServerActionsFactory,
6128
6223
  inject: [
6129
- NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN,
6130
- NotificationExpediteService
6224
+ NOTIFICATION_SERVER_ACTION_CONTEXT_TOKEN
6131
6225
  ]
6132
6226
  },
6133
6227
  {
@@ -6138,7 +6232,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
6138
6232
  NOTIFICATION_INIT_SERVER_ACTIONS_CONTEXT_CONFIG_TOKEN
6139
6233
  ]
6140
6234
  }
6141
- ].concat(_to_consumable_array$3(providers !== null && providers !== void 0 ? providers : []))
6235
+ ].concat(_to_consumable_array$4(providers !== null && providers !== void 0 ? providers : []))
6142
6236
  };
6143
6237
  }
6144
6238
  /**
@@ -6173,6 +6267,9 @@ function _array_like_to_array$4(arr, len) {
6173
6267
  function _array_with_holes$1(arr) {
6174
6268
  if (Array.isArray(arr)) return arr;
6175
6269
  }
6270
+ function _array_without_holes$3(arr) {
6271
+ if (Array.isArray(arr)) return _array_like_to_array$4(arr);
6272
+ }
6176
6273
  function asyncGeneratorStep$8(gen, resolve, reject, _next, _throw, key, arg) {
6177
6274
  try {
6178
6275
  var info = gen[key](arg);
@@ -6215,6 +6312,9 @@ function _define_property$6(obj, key, value) {
6215
6312
  }
6216
6313
  return obj;
6217
6314
  }
6315
+ function _iterable_to_array$3(iter) {
6316
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
6317
+ }
6218
6318
  function _iterable_to_array_limit$1(arr, i) {
6219
6319
  var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
6220
6320
  if (_i == null) return;
@@ -6242,6 +6342,9 @@ function _iterable_to_array_limit$1(arr, i) {
6242
6342
  function _non_iterable_rest$1() {
6243
6343
  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
6344
  }
6345
+ function _non_iterable_spread$3() {
6346
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
6347
+ }
6245
6348
  function _object_spread$6(target) {
6246
6349
  for(var i = 1; i < arguments.length; i++){
6247
6350
  var source = arguments[i] != null ? arguments[i] : {};
@@ -6279,6 +6382,9 @@ function _object_spread_props$6(target, source) {
6279
6382
  function _sliced_to_array$1(arr, i) {
6280
6383
  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
6384
  }
6385
+ function _to_consumable_array$3(arr) {
6386
+ return _array_without_holes$3(arr) || _iterable_to_array$3(arr) || _unsupported_iterable_to_array$4(arr) || _non_iterable_spread$3();
6387
+ }
6282
6388
  function _unsupported_iterable_to_array$4(o, minLen) {
6283
6389
  if (!o) return;
6284
6390
  if (typeof o === "string") return _array_like_to_array$4(o, minLen);
@@ -6397,6 +6503,7 @@ function _ts_generator$8(thisArg, body) {
6397
6503
  * Each summary update runs in a Firestore transaction to prevent concurrent write conflicts.
6398
6504
  *
6399
6505
  * @param config - service configuration including Firestore context and collection references
6506
+ * @returns a {@link NotificationSummarySendService} backed by Firestore
6400
6507
  *
6401
6508
  * @example
6402
6509
  * ```ts
@@ -6430,6 +6537,7 @@ function _ts_generator$8(thisArg, body) {
6430
6537
  cutMessage = cutStringFunction({
6431
6538
  maxLength: NOTIFICATION_SUMMARY_EMBEDDED_NOTIFICATION_ITEM_MESSAGE_MAX_LENGTH
6432
6539
  });
6540
+ // eslint-disable-next-line @typescript-eslint/no-empty-object-type
6433
6541
  messagesGroups = messagesGroupedByNotificationSummaryMapBuilder.entries();
6434
6542
  return [
6435
6543
  2,
@@ -6476,7 +6584,7 @@ function _ts_generator$8(thisArg, body) {
6476
6584
  });
6477
6585
  if (messagesToSend.length > 0) {
6478
6586
  // add the new items to existing n, then keep the last 1000
6479
- sortedN = existingMessages.concat(messagesToSend.map(function(x) {
6587
+ sortedN = _to_consumable_array$3(existingMessages).concat(_to_consumable_array$3(messagesToSend.map(function(x) {
6480
6588
  var message = '';
6481
6589
  if (x.content.openingMessage) {
6482
6590
  message = x.content.openingMessage;
@@ -6489,7 +6597,7 @@ function _ts_generator$8(thisArg, body) {
6489
6597
  g: cutMessage(message)
6490
6598
  });
6491
6599
  return item;
6492
- })).sort(sortNotificationItemsFunction);
6600
+ }))).sort(sortNotificationItemsFunction);
6493
6601
  n = takeLast(sortedN, NOTIFICATION_SUMMARY_ITEM_LIMIT);
6494
6602
  updateTemplate = {
6495
6603
  n: n,
@@ -6717,6 +6825,8 @@ function _ts_generator$7(thisArg, body) {
6717
6825
  * Useful as a placeholder when your app's notification pipeline is fully wired for SMS
6718
6826
  * but actual delivery is not yet enabled, avoiding the need for conditional logic elsewhere.
6719
6827
  *
6828
+ * @returns a no-op {@link NotificationTextSendService} that ignores all messages
6829
+ *
6720
6830
  * @example
6721
6831
  * ```ts
6722
6832
  * const textService = ignoreSendNotificationTextSendService();
@@ -6896,6 +7006,7 @@ function _ts_generator$6(thisArg, body) {
6896
7006
  * If all checkpoints are complete, the task is marked as done.
6897
7007
  *
6898
7008
  * @param config - handler configurations and optional validation list
7009
+ * @returns a {@link NotificationTaskService} that dispatches tasks to the registered handlers
6899
7010
  *
6900
7011
  * @example
6901
7012
  * ```ts
@@ -6941,14 +7052,16 @@ function _ts_generator$6(thisArg, body) {
6941
7052
  fn = (_this = (_nonCheckpointFlows_ = nonCheckpointFlows[0]) !== null && _nonCheckpointFlows_ !== void 0 ? _nonCheckpointFlows_ : checkpointFlows[0]) === null || _this === void 0 ? void 0 : _this.fn;
6942
7053
  break;
6943
7054
  default:
6944
- completedCheckpointsSet = new Set(completedCheckpoints);
6945
- /**
7055
+ {
7056
+ completedCheckpointsSet = new Set(completedCheckpoints);
7057
+ /**
6946
7058
  * Find the next flow function that hasn't had its checkpoint completed yet.
6947
7059
  */ nextCheckpoint = checkpointFlows.find(function(x) {
6948
- return !completedCheckpointsSet.has(x.checkpoint);
6949
- });
6950
- fn = nextCheckpoint === null || nextCheckpoint === void 0 ? void 0 : nextCheckpoint.fn;
6951
- break;
7060
+ return !completedCheckpointsSet.has(x.checkpoint);
7061
+ });
7062
+ fn = nextCheckpoint === null || nextCheckpoint === void 0 ? void 0 : nextCheckpoint.fn;
7063
+ break;
7064
+ }
6952
7065
  }
6953
7066
  if (!fn) return [
6954
7067
  3,
@@ -7275,6 +7388,7 @@ function _ts_generator$5(thisArg, body) {
7275
7388
  * such as storage file processing or other async workflows.
7276
7389
  *
7277
7390
  * @param factoryConfig - shared configuration including the input function, cleanup logic, and task type
7391
+ * @returns a factory function that produces {@link NotificationTaskServiceTaskHandlerConfig} entries
7278
7392
  *
7279
7393
  * @example
7280
7394
  * ```ts
@@ -7297,6 +7411,9 @@ function _ts_generator$5(thisArg, body) {
7297
7411
  return function(subtaskHandlerConfig) {
7298
7412
  var processorFunctionForConfig = /**
7299
7413
  * Structure is similar to notificationTaskService(), but contained to handle the subtasks.
7414
+ *
7415
+ * @param processorConfig - the processor configuration with target, flow, and cleanup
7416
+ * @returns a processor with process and optional cleanup functions
7300
7417
  */ function processorFunctionForConfig(processorConfig) {
7301
7418
  var inputFlows = processorConfig.flow, cleanup = processorConfig.cleanup, processorAllowRunMultipleParts = processorConfig.allowRunMultipleParts;
7302
7419
  var _separateValues = separateValues(inputFlows, function(x) {
@@ -7324,14 +7441,16 @@ function _ts_generator$5(thisArg, body) {
7324
7441
  fn = (_this = (_nonSubtaskFlows_ = nonSubtaskFlows[0]) !== null && _nonSubtaskFlows_ !== void 0 ? _nonSubtaskFlows_ : subtaskFlows[0]) === null || _this === void 0 ? void 0 : _this.fn;
7325
7442
  break;
7326
7443
  default:
7327
- completedSubtasksSet = new Set(completedSubtasks);
7328
- /**
7444
+ {
7445
+ completedSubtasksSet = new Set(completedSubtasks);
7446
+ /**
7329
7447
  * Find the next flow function that hasn't had its checkpoint completed yet.
7330
7448
  */ nextSubtask = subtaskFlows.find(function(x) {
7331
- return !completedSubtasksSet.has(x.subtask);
7332
- });
7333
- fn = nextSubtask === null || nextSubtask === void 0 ? void 0 : nextSubtask.fn;
7334
- break;
7449
+ return !completedSubtasksSet.has(x.subtask);
7450
+ });
7451
+ fn = nextSubtask === null || nextSubtask === void 0 ? void 0 : nextSubtask.fn;
7452
+ break;
7453
+ }
7335
7454
  }
7336
7455
  if (!fn) return [
7337
7456
  3,
@@ -7356,13 +7475,15 @@ function _ts_generator$5(thisArg, body) {
7356
7475
  sfps = removeFromCompletionsArrayWithTaskResult(sfps, subtaskResult);
7357
7476
  break;
7358
7477
  default:
7359
- sfps = unique(_to_consumable_array$2(removeFromCompletionsArrayWithTaskResult(sfps, subtaskResult)).concat(_to_consumable_array$2(asArray(subtaskCompletion))));
7360
- completedSubtasksSet1 = new Set(sfps);
7361
- incompleteSubtasks = allKnownSubtasks.filter(function(x) {
7362
- return !completedSubtasksSet1.has(x);
7363
- });
7364
- allSubtasksDone = incompleteSubtasks.length === 0;
7365
- break;
7478
+ {
7479
+ sfps = unique(_to_consumable_array$2(removeFromCompletionsArrayWithTaskResult(sfps, subtaskResult)).concat(_to_consumable_array$2(asArray(subtaskCompletion))));
7480
+ completedSubtasksSet1 = new Set(sfps);
7481
+ incompleteSubtasks = allKnownSubtasks.filter(function(x) {
7482
+ return !completedSubtasksSet1.has(x);
7483
+ });
7484
+ allSubtasksDone = incompleteSubtasks.length === 0;
7485
+ break;
7486
+ }
7366
7487
  }
7367
7488
  // configure the update metadata result
7368
7489
  sd = _object_spread$5({}, subtaskData, subtaskUpdateMetadata);
@@ -7576,7 +7697,7 @@ function _ts_generator$5(thisArg, body) {
7576
7697
  8
7577
7698
  ];
7578
7699
  processor = processors[target];
7579
- if (!(processor && processor.cleanup)) return [
7700
+ if (!(processor === null || processor === void 0 ? void 0 : processor.cleanup)) return [
7580
7701
  3,
7581
7702
  5
7582
7703
  ];
@@ -7689,12 +7810,16 @@ function _ts_generator$5(thisArg, body) {
7689
7810
  }(BaseError);
7690
7811
  /**
7691
7812
  * Creates a NotificationTaskSubTaskMissingRequiredDataTermination.
7813
+ *
7814
+ * @returns a new {@link NotificationTaskSubTaskMissingRequiredDataTermination} error instance
7692
7815
  */ function notificationTaskSubTaskMissingRequiredDataTermination() {
7693
7816
  return new NotificationTaskSubTaskMissingRequiredDataTermination();
7694
7817
  }
7695
7818
 
7696
7819
  /**
7697
7820
  * Creates an error indicating that a storage file model has already been initialized.
7821
+ *
7822
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_MODEL_ALREADY_INITIALIZED error code
7698
7823
  */ function storageFileModelAlreadyInitializedError() {
7699
7824
  return preconditionConflictError({
7700
7825
  message: "This model has already been initialized.",
@@ -7703,6 +7828,8 @@ function _ts_generator$5(thisArg, body) {
7703
7828
  }
7704
7829
  /**
7705
7830
  * Creates an error indicating that the StorageFile is not flagged for group sync.
7831
+ *
7832
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_NOT_FLAGGED_FOR_GROUPS_SYNC error code
7706
7833
  */ function storageFileNotFlaggedForGroupsSyncError() {
7707
7834
  return preconditionConflictError({
7708
7835
  message: "This StorageFile has not been flagged for sync with its groups.",
@@ -7711,6 +7838,8 @@ function _ts_generator$5(thisArg, body) {
7711
7838
  }
7712
7839
  /**
7713
7840
  * Creates an error indicating that the target uploaded file does not exist in storage.
7841
+ *
7842
+ * @returns a precondition-conflict HttpsError with the UPLOADED_FILE_DOES_NOT_EXIST error code
7714
7843
  */ function uploadedFileDoesNotExistError() {
7715
7844
  return preconditionConflictError({
7716
7845
  message: "The target uploaded file does not exist.",
@@ -7719,6 +7848,8 @@ function _ts_generator$5(thisArg, body) {
7719
7848
  }
7720
7849
  /**
7721
7850
  * Creates an error indicating that the file is not allowed to be initialized (rejected by the check function).
7851
+ *
7852
+ * @returns a precondition-conflict HttpsError with the UPLOADED_FILE_NOT_ALLOWED_TO_BE_INITIALIZED error code
7722
7853
  */ function uploadedFileIsNotAllowedToBeInitializedError() {
7723
7854
  return preconditionConflictError({
7724
7855
  message: "The target uploaded file is not allowed to be initialized.",
@@ -7729,6 +7860,7 @@ function _ts_generator$5(thisArg, body) {
7729
7860
  * Creates an error indicating that the file initialization failed with the given result type.
7730
7861
  *
7731
7862
  * @param data - error data containing the result type that caused the failure
7863
+ * @returns an internal-server HttpsError with the UPLOADED_FILE_INITIALIZATION_FAILED error code and the result type
7732
7864
  */ function uploadedFileInitializationFailedError(data) {
7733
7865
  return internalServerError({
7734
7866
  message: 'The target uploaded file initialization failed with result type "'.concat(data.resultType, '".'),
@@ -7740,6 +7872,8 @@ function _ts_generator$5(thisArg, body) {
7740
7872
  }
7741
7873
  /**
7742
7874
  * Creates an error indicating that the initialization result was discarded (e.g., the created file no longer exists).
7875
+ *
7876
+ * @returns an internal-server HttpsError with the UPLOADED_FILE_INITIALIZATION_DISCARDED error code
7743
7877
  */ function uploadedFileInitializationDiscardedError() {
7744
7878
  return internalServerError({
7745
7879
  message: "The target uploaded file initialization was discarded.",
@@ -7748,6 +7882,8 @@ function _ts_generator$5(thisArg, body) {
7748
7882
  }
7749
7883
  /**
7750
7884
  * Creates an error indicating that the StorageFile is not in a valid state for processing.
7885
+ *
7886
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_ALLOWED_FOR_INVALID_STATE error code
7751
7887
  */ function storageFileProcessingNotAllowedForInvalidStateError() {
7752
7888
  return preconditionConflictError({
7753
7889
  message: "The target StorageFileDocument must be in an OK state to be processed and processing not flagged as SHOULD_NOT_PROCESS.",
@@ -7756,6 +7892,8 @@ function _ts_generator$5(thisArg, body) {
7756
7892
  }
7757
7893
  /**
7758
7894
  * Creates an error indicating that the StorageFile is not queued for processing.
7895
+ *
7896
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_QUEUED_FOR_PROCESSING error code
7759
7897
  */ function storageFileProcessingNotQueuedForProcessingError() {
7760
7898
  return preconditionConflictError({
7761
7899
  message: "The target StorageFileDocument is not queued for processing.",
@@ -7764,6 +7902,8 @@ function _ts_generator$5(thisArg, body) {
7764
7902
  }
7765
7903
  /**
7766
7904
  * Creates an error indicating that no processor is configured for the StorageFile's type.
7905
+ *
7906
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_PROCESSING_NOT_AVAILABLE_FOR_TYPE error code
7767
7907
  */ function storageFileProcessingNotAvailableForTypeError() {
7768
7908
  return preconditionConflictError({
7769
7909
  message: "The target StorageFileDocument is not available for processing.",
@@ -7772,6 +7912,8 @@ function _ts_generator$5(thisArg, body) {
7772
7912
  }
7773
7913
  /**
7774
7914
  * Creates an error indicating that the StorageFile has already finished processing.
7915
+ *
7916
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_ALREADY_PROCESSED error code
7775
7917
  */ function storageFileAlreadyProcessedError() {
7776
7918
  return preconditionConflictError({
7777
7919
  message: "The target StorageFileDocument has already finished processing.",
@@ -7780,6 +7922,8 @@ function _ts_generator$5(thisArg, body) {
7780
7922
  }
7781
7923
  /**
7782
7924
  * Creates an error indicating that the StorageFile is not flagged for deletion.
7925
+ *
7926
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_NOT_FLAGGED_FOR_DELETION error code
7783
7927
  */ function storageFileNotFlaggedForDeletionError() {
7784
7928
  return preconditionConflictError({
7785
7929
  message: "The target StorageFileDocument is not flagged for deletion.",
@@ -7788,6 +7932,8 @@ function _ts_generator$5(thisArg, body) {
7788
7932
  }
7789
7933
  /**
7790
7934
  * Creates an error indicating that the StorageFile's scheduled deletion time has not yet passed.
7935
+ *
7936
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_CANNOT_BE_DELETED_YET error code
7791
7937
  */ function storageFileCannotBeDeletedYetError() {
7792
7938
  return preconditionConflictError({
7793
7939
  message: "The target StorageFileDocument cannot be deleted yet.",
@@ -7796,6 +7942,8 @@ function _ts_generator$5(thisArg, body) {
7796
7942
  }
7797
7943
  /**
7798
7944
  * Creates an error indicating that the StorageFileGroup is still queued for initialization and cannot be operated on.
7945
+ *
7946
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_GROUP_QUEUED_FOR_INITIALIZATION error code
7799
7947
  */ function storageFileGroupQueuedForInitializationError() {
7800
7948
  return preconditionConflictError({
7801
7949
  message: "The target StorageFileGroupDocument is queued for initialization.",
@@ -7804,6 +7952,8 @@ function _ts_generator$5(thisArg, body) {
7804
7952
  }
7805
7953
  /**
7806
7954
  * Creates an error indicating that the required model key or storageFileId is missing when creating a StorageFileGroup.
7955
+ *
7956
+ * @returns a precondition-conflict HttpsError with the STORAGE_FILE_GROUP_CREATE_INPUT error code
7807
7957
  */ function createStorageFileGroupInputError() {
7808
7958
  return preconditionConflictError({
7809
7959
  message: "The model or storageFileId is required for creating a StorageFileGroup.",
@@ -7893,10 +8043,6 @@ function _iterable_to_array_limit(arr, i) {
7893
8043
  function _non_iterable_rest() {
7894
8044
  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
8045
  }
7896
- function _object_destructuring_empty(o) {
7897
- if (o === null || o === void 0) throw new TypeError("Cannot destructure " + o);
7898
- return o;
7899
- }
7900
8046
  function _object_spread$4(target) {
7901
8047
  for(var i = 1; i < arguments.length; i++){
7902
8048
  var source = arguments[i] != null ? arguments[i] : {};
@@ -8073,6 +8219,9 @@ function _ts_generator$4(thisArg, body) {
8073
8219
  *
8074
8220
  * @param context - the fully assembled storage file server actions context
8075
8221
  *
8222
+ * @param context - the fully assembled storage file server actions context
8223
+ * @returns a concrete {@link StorageFileServerActions} with all action methods wired to their factories
8224
+ *
8076
8225
  * @example
8077
8226
  * ```ts
8078
8227
  * const actions = storageFileServerActions(context);
@@ -8103,23 +8252,23 @@ function _ts_generator$4(thisArg, body) {
8103
8252
  * Factory for the `createStorageFile` action.
8104
8253
  *
8105
8254
  * Creates a new {@link StorageFile} document using the provided template data.
8255
+ *
8256
+ * @param context - the base server actions context providing Firestore and storage access
8257
+ * @returns an async transform-and-validate function that creates a StorageFile document
8106
8258
  */ function createStorageFileFactory(context) {
8107
- context.storageFileCollection; context.firestoreContext; var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8259
+ var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8108
8260
  return firebaseServerActionTransformFunctionFactory(createStorageFileParamsType, function(params) {
8109
8261
  return _async_to_generator$4(function() {
8110
8262
  return _ts_generator$4(this, function(_state) {
8111
- _object_destructuring_empty(params);
8112
8263
  return [
8113
8264
  2,
8114
8265
  function() {
8115
8266
  return _async_to_generator$4(function() {
8116
- var storageFileDocument;
8117
8267
  return _ts_generator$4(this, function(_state) {
8118
- storageFileDocument = null;
8119
8268
  // TODO: check the file exists, and pull the metadata, and create the document
8120
8269
  return [
8121
8270
  2,
8122
- storageFileDocument
8271
+ null
8123
8272
  ];
8124
8273
  });
8125
8274
  })();
@@ -8135,6 +8284,9 @@ function _ts_generator$4(thisArg, body) {
8135
8284
  * Scans the uploads folder in Firebase Storage, identifies new uploaded files,
8136
8285
  * initializes each one via the upload service, and cleans up the source upload
8137
8286
  * on success. Failed initializations are logged but do not halt the batch.
8287
+ *
8288
+ * @param context - the storage file server actions context with storage service and upload initialization
8289
+ * @returns an async transform-and-validate function that returns batch initialization results
8138
8290
  */ function initializeAllStorageFilesFromUploadsFactory(context) {
8139
8291
  var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8140
8292
  var _initializeStorageFileFromUploadFile = _initializeStorageFileFromUploadFileFactory(context);
@@ -8228,7 +8380,15 @@ function _ts_generator$4(thisArg, body) {
8228
8380
  })();
8229
8381
  });
8230
8382
  }
8231
- function _initializeStorageFileFromUploadFileFactory(context) {
8383
+ /**
8384
+ * Internal factory that creates a function to initialize a {@link StorageFile} from an uploaded file.
8385
+ *
8386
+ * Validates the file exists and is allowed, runs the upload initializer, deletes the upload source
8387
+ * on success, and optionally expedites processing of the created storage file.
8388
+ *
8389
+ * @param context - the storage file server actions context
8390
+ * @returns an async function that accepts an upload file input and returns the created StorageFileDocument
8391
+ */ function _initializeStorageFileFromUploadFileFactory(context) {
8232
8392
  var firestoreContext = context.firestoreContext, storageFileInitializeFromUploadService = context.storageFileInitializeFromUploadService, notificationExpediteService = context.notificationExpediteService;
8233
8393
  var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
8234
8394
  return function(input) {
@@ -8356,7 +8516,7 @@ function _initializeStorageFileFromUploadFileFactory(context) {
8356
8516
  11
8357
8517
  ];
8358
8518
  storageFileDocument = initializationResult.storageFileDocument;
8359
- if (!(storageFileDocument != null && expediteProcessing)) return [
8519
+ if (!expediteProcessing) return [
8360
8520
  3,
8361
8521
  10
8362
8522
  ];
@@ -8492,6 +8652,9 @@ function _initializeStorageFileFromUploadFileFactory(context) {
8492
8652
  * Initializes a single {@link StorageFile} from an uploaded file at the given storage path.
8493
8653
  * Validates the file exists and is allowed, runs the type determiner and initializer,
8494
8654
  * then cleans up the upload source on success.
8655
+ *
8656
+ * @param context - the storage file server actions context with storage and upload services
8657
+ * @returns an async transform-and-validate function that creates a StorageFile from an upload
8495
8658
  */ function initializeStorageFileFromUploadFactory(context) {
8496
8659
  var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8497
8660
  var _initializeStorageFileFromUploadFile = _initializeStorageFileFromUploadFileFactory(context);
@@ -8525,8 +8688,15 @@ function _initializeStorageFileFromUploadFileFactory(context) {
8525
8688
  })();
8526
8689
  });
8527
8690
  }
8528
- function updateStorageFileFactory(context) {
8529
- context.storageFileCollection; context.firestoreContext; var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8691
+ /**
8692
+ * Factory for the `updateStorageFile` action.
8693
+ *
8694
+ * Updates an existing {@link StorageFile} document with the provided schedule-delete-at time.
8695
+ *
8696
+ * @param context - the base server actions context providing Firestore access
8697
+ * @returns an async transform-and-validate function that updates a StorageFile document
8698
+ */ function updateStorageFileFactory(context) {
8699
+ var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8530
8700
  return firebaseServerActionTransformFunctionFactory(updateStorageFileParamsType, function(params) {
8531
8701
  return _async_to_generator$4(function() {
8532
8702
  var sdat;
@@ -8562,7 +8732,15 @@ function updateStorageFileFactory(context) {
8562
8732
  })();
8563
8733
  });
8564
8734
  }
8565
- function updateStorageFileGroupFactory(context) {
8735
+ /**
8736
+ * Factory for the `updateStorageFileGroup` action.
8737
+ *
8738
+ * Updates embedded file entries within a {@link StorageFileGroup} document inside a
8739
+ * Firestore transaction, merging display name changes into the existing entries.
8740
+ *
8741
+ * @param context - the storage file server actions context
8742
+ * @returns an async transform-and-validate function that updates a StorageFileGroup document
8743
+ */ function updateStorageFileGroupFactory(context) {
8566
8744
  var firestoreContext = context.firestoreContext, storageFileGroupCollection = context.storageFileGroupCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8567
8745
  return firebaseServerActionTransformFunctionFactory(updateStorageFileGroupParamsType, function(params) {
8568
8746
  return _async_to_generator$4(function() {
@@ -8644,10 +8822,13 @@ function updateStorageFileGroupFactory(context) {
8644
8822
  * Batch-processes all {@link StorageFile} documents queued for processing. Creates a
8645
8823
  * processing notification task for each file and optionally expedites delivery.
8646
8824
  * Handles stuck-processing detection with a throttle check.
8825
+ *
8826
+ * @param context - the storage file server actions context
8827
+ * @returns an async transform-and-validate function that returns batch processing results
8647
8828
  */ function processAllQueuedStorageFilesFactory(context) {
8648
8829
  var storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8649
8830
  var processStorageFile = processStorageFileFactory(context);
8650
- return firebaseServerActionTransformFunctionFactory(processAllQueuedStorageFilesParamsType, function(params) {
8831
+ return firebaseServerActionTransformFunctionFactory(processAllQueuedStorageFilesParamsType, function(_params) {
8651
8832
  return _async_to_generator$4(function() {
8652
8833
  return _ts_generator$4(this, function(_state) {
8653
8834
  return [
@@ -8731,7 +8912,15 @@ function updateStorageFileGroupFactory(context) {
8731
8912
  })();
8732
8913
  });
8733
8914
  }
8734
- function _processStorageFileInTransactionFactory(context) {
8915
+ /**
8916
+ * Internal factory that creates a function for processing a {@link StorageFile} within a Firestore transaction.
8917
+ *
8918
+ * Creates or restarts a notification task for the file based on its current processing state,
8919
+ * handling stuck-processing detection, forced restarts, and re-processing of already-successful files.
8920
+ *
8921
+ * @param context - the storage file server actions context
8922
+ * @returns an async function that processes a storage file within a transaction
8923
+ */ function _processStorageFileInTransactionFactory(context) {
8735
8924
  var storageFileCollection = context.storageFileCollection, notificationCollectionGroup = context.notificationCollectionGroup;
8736
8925
  return function(input, transaction) {
8737
8926
  return _async_to_generator$4(function() {
@@ -8821,20 +9010,30 @@ function _processStorageFileInTransactionFactory(context) {
8821
9010
  3,
8822
9011
  10
8823
9012
  ];
8824
- case StorageFileProcessingState.DO_NOT_PROCESS:
9013
+ case StorageFileProcessingState.FAILED:
8825
9014
  return [
8826
9015
  3,
8827
9016
  20
8828
9017
  ];
9018
+ case StorageFileProcessingState.DO_NOT_PROCESS:
9019
+ return [
9020
+ 3,
9021
+ 22
9022
+ ];
8829
9023
  case StorageFileProcessingState.SUCCESS:
8830
9024
  return [
8831
9025
  3,
8832
- 21
9026
+ 23
9027
+ ];
9028
+ case StorageFileProcessingState.ARCHIVED:
9029
+ return [
9030
+ 3,
9031
+ 27
8833
9032
  ];
8834
9033
  }
8835
9034
  return [
8836
9035
  3,
8837
- 25
9036
+ 28
8838
9037
  ];
8839
9038
  case 4:
8840
9039
  if (!!storageFile.p) return [
@@ -8853,7 +9052,7 @@ function _processStorageFileInTransactionFactory(context) {
8853
9052
  case 7:
8854
9053
  return [
8855
9054
  3,
8856
- 25
9055
+ 28
8857
9056
  ];
8858
9057
  case 8:
8859
9058
  // begin processing
@@ -8865,7 +9064,7 @@ function _processStorageFileInTransactionFactory(context) {
8865
9064
  _state.sent();
8866
9065
  return [
8867
9066
  3,
8868
- 25
9067
+ 28
8869
9068
  ];
8870
9069
  case 10:
8871
9070
  // check if the processing task is still running
@@ -8939,33 +9138,47 @@ function _processStorageFileInTransactionFactory(context) {
8939
9138
  case 19:
8940
9139
  return [
8941
9140
  3,
8942
- 25
9141
+ 28
8943
9142
  ];
8944
9143
  case 20:
8945
- throw storageFileProcessingNotQueuedForProcessingError();
9144
+ // restart processing on failure
9145
+ return [
9146
+ 4,
9147
+ beginProcessing(true)
9148
+ ];
8946
9149
  case 21:
9150
+ _state.sent();
9151
+ return [
9152
+ 3,
9153
+ 28
9154
+ ];
9155
+ case 22:
9156
+ throw storageFileProcessingNotQueuedForProcessingError();
9157
+ case 23:
8947
9158
  if (!(forceRestartProcessing || processAgainIfSuccessful)) return [
8948
9159
  3,
8949
- 23
9160
+ 25
8950
9161
  ];
8951
9162
  return [
8952
9163
  4,
8953
9164
  beginProcessing(true)
8954
9165
  ];
8955
- case 22:
9166
+ case 24:
8956
9167
  _state.sent();
8957
9168
  return [
8958
9169
  3,
8959
- 24
9170
+ 26
8960
9171
  ];
8961
- case 23:
9172
+ case 25:
8962
9173
  throw storageFileAlreadyProcessedError();
8963
- case 24:
9174
+ case 26:
8964
9175
  return [
8965
9176
  3,
8966
- 25
9177
+ 28
8967
9178
  ];
8968
- case 25:
9179
+ case 27:
9180
+ throw storageFileProcessingNotQueuedForProcessingError();
9181
+ case 28:
8969
9182
  return [
8970
9183
  2
8971
9184
  ];
@@ -8979,6 +9192,9 @@ function _processStorageFileInTransactionFactory(context) {
8979
9192
  *
8980
9193
  * Processes a single {@link StorageFile} by creating a notification task for it
8981
9194
  * and marking it as processing. Validates the file is in a valid state for processing.
9195
+ *
9196
+ * @param context - the storage file server actions context
9197
+ * @returns an async transform-and-validate function that processes a single StorageFile
8982
9198
  */ function processStorageFileFactory(context) {
8983
9199
  var firestoreContext = context.firestoreContext, notificationExpediteService = context.notificationExpediteService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
8984
9200
  var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
@@ -9062,10 +9278,13 @@ function _processStorageFileInTransactionFactory(context) {
9062
9278
  * Batch-deletes all {@link StorageFile} documents flagged for deletion whose
9063
9279
  * scheduled delete time has passed. Removes both the Firestore document and
9064
9280
  * the associated file in Cloud Storage.
9281
+ *
9282
+ * @param context - the storage file server actions context
9283
+ * @returns an async transform-and-validate function that returns batch deletion results
9065
9284
  */ function deleteAllQueuedStorageFilesFactory(context) {
9066
9285
  var storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9067
9286
  var deleteStorageFile = deleteStorageFileFactory(context);
9068
- return firebaseServerActionTransformFunctionFactory(deleteAllQueuedStorageFilesParamsType, function(params) {
9287
+ return firebaseServerActionTransformFunctionFactory(deleteAllQueuedStorageFilesParamsType, function(_params) {
9069
9288
  return _async_to_generator$4(function() {
9070
9289
  return _ts_generator$4(this, function(_state) {
9071
9290
  return [
@@ -9156,6 +9375,9 @@ function _processStorageFileInTransactionFactory(context) {
9156
9375
  *
9157
9376
  * Deletes a single {@link StorageFile} document and its associated Cloud Storage file.
9158
9377
  * Validates the file is flagged for deletion and the scheduled delete time has passed.
9378
+ *
9379
+ * @param context - the storage file server actions context
9380
+ * @returns an async transform-and-validate function that deletes a StorageFile and its storage object
9159
9381
  */ function deleteStorageFileFactory(context) {
9160
9382
  var firestoreContext = context.firestoreContext, storageService = context.storageService, storageFileCollection = context.storageFileCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9161
9383
  var syncStorageFileWithGroupsInTransaction = _syncStorageFileWithGroupsInTransactionFactory(context);
@@ -9179,17 +9401,12 @@ function _processStorageFileInTransactionFactory(context) {
9179
9401
  return _ts_generator$4(this, function(_state) {
9180
9402
  switch(_state.label){
9181
9403
  case 0:
9182
- return [
9183
- 4,
9184
- storageFileCollection.documentAccessorForTransaction(transaction).loadDocumentFrom(inputStorageFileDocument)
9185
- ];
9186
- case 1:
9187
- storageFileDocument = _state.sent();
9404
+ storageFileDocument = storageFileCollection.documentAccessorForTransaction(transaction).loadDocumentFrom(inputStorageFileDocument);
9188
9405
  return [
9189
9406
  4,
9190
9407
  assertSnapshotData(storageFileDocument)
9191
9408
  ];
9192
- case 2:
9409
+ case 1:
9193
9410
  storageFile = _state.sent();
9194
9411
  fileAccessor = storageService.file(storageFile);
9195
9412
  if (!force) {
@@ -9209,7 +9426,7 @@ function _processStorageFileInTransactionFactory(context) {
9209
9426
  removeAllStorageFileGroups: true
9210
9427
  }, transaction)
9211
9428
  ];
9212
- case 3:
9429
+ case 2:
9213
9430
  _state.sent();
9214
9431
  // delete the file
9215
9432
  return [
@@ -9218,14 +9435,14 @@ function _processStorageFileInTransactionFactory(context) {
9218
9435
  return null;
9219
9436
  })
9220
9437
  ];
9221
- case 4:
9438
+ case 3:
9222
9439
  _state.sent();
9223
9440
  // delete the document
9224
9441
  return [
9225
9442
  4,
9226
9443
  storageFileDocument.accessor.delete()
9227
9444
  ];
9228
- case 5:
9445
+ case 4:
9229
9446
  _state.sent();
9230
9447
  return [
9231
9448
  2
@@ -9255,6 +9472,9 @@ function _processStorageFileInTransactionFactory(context) {
9255
9472
  * Generates a signed download URL for a {@link StorageFile}'s associated Cloud Storage file.
9256
9473
  * The URL expires after the configured duration. Supports loading the storage file document
9257
9474
  * by key if not provided directly.
9475
+ *
9476
+ * @param context - the storage file server actions context
9477
+ * @returns an async transform-and-validate function that generates a signed download URL
9258
9478
  */ function downloadStorageFileFactory(context) {
9259
9479
  var storageService = context.storageService, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileCollection = context.storageFileCollection;
9260
9480
  return firebaseServerActionTransformFunctionFactory(downloadStorageFileParamsType, function(params) {
@@ -9271,9 +9491,7 @@ function _processStorageFileInTransactionFactory(context) {
9271
9491
  switch(_state.label){
9272
9492
  case 0:
9273
9493
  // if the StorageFileDocument was not provided, set it from the target key
9274
- if (!storageFileDocument) {
9275
- storageFileDocument = storageFileCollection.documentAccessor().loadDocumentForKey(targetStorageFileDocumentKey);
9276
- }
9494
+ storageFileDocument !== null && storageFileDocument !== void 0 ? storageFileDocument : storageFileDocument = storageFileCollection.documentAccessor().loadDocumentForKey(targetStorageFileDocumentKey);
9277
9495
  return [
9278
9496
  4,
9279
9497
  assertSnapshotData(storageFileDocument)
@@ -9291,9 +9509,9 @@ function _processStorageFileInTransactionFactory(context) {
9291
9509
  expiresAt: expiresAt,
9292
9510
  expiresIn: expiresIn
9293
9511
  });
9294
- downloadUrlExpiresAt = expires.getExpirationDate();
9512
+ downloadUrlExpiresAt = expires.getExpirationDate(); // always returns a Date when defaultExpiresFromDateToNow and expiresIn are set
9295
9513
  // if they're not an admin, limit the expiration to a max of 30 days.
9296
- if (downloadUrlExpiresAt && !asAdmin) {
9514
+ if (!asAdmin) {
9297
9515
  maxExpirationDate = addDays(new Date(), 30);
9298
9516
  downloadUrlExpiresAt = findMinDate([
9299
9517
  downloadUrlExpiresAt,
@@ -9305,7 +9523,7 @@ function _processStorageFileInTransactionFactory(context) {
9305
9523
  Promise.all([
9306
9524
  fileAccessor.getSignedUrl({
9307
9525
  action: 'read',
9308
- expiresAt: downloadUrlExpiresAt !== null && downloadUrlExpiresAt !== void 0 ? downloadUrlExpiresAt : undefined,
9526
+ expiresAt: downloadUrlExpiresAt,
9309
9527
  responseDisposition: responseDisposition !== null && responseDisposition !== void 0 ? responseDisposition : undefined,
9310
9528
  responseType: asAdmin ? responseContentType !== null && responseContentType !== void 0 ? responseContentType : undefined : undefined // can only be set by admins
9311
9529
  }),
@@ -9343,7 +9561,16 @@ function _processStorageFileInTransactionFactory(context) {
9343
9561
  })();
9344
9562
  });
9345
9563
  }
9346
- function createStorageFileGroupInTransactionFactory(context) {
9564
+ /**
9565
+ * Internal factory that creates a function for creating a {@link StorageFileGroup} document
9566
+ * within a Firestore transaction.
9567
+ *
9568
+ * The created group is flagged for initialization (`s=true`) and uses a dummy owner key
9569
+ * that will be set during the initialization step.
9570
+ *
9571
+ * @param context - the storage file server actions context
9572
+ * @returns an async function that creates a StorageFileGroup within a transaction
9573
+ */ function createStorageFileGroupInTransactionFactory(context) {
9347
9574
  var storageFileGroupCollection = context.storageFileGroupCollection;
9348
9575
  return function(params, transaction) {
9349
9576
  return _async_to_generator$4(function() {
@@ -9389,6 +9616,9 @@ function createStorageFileGroupInTransactionFactory(context) {
9389
9616
  *
9390
9617
  * Creates a new {@link StorageFileGroup} document within a Firestore transaction,
9391
9618
  * associating it with a model key or storage file.
9619
+ *
9620
+ * @param context - the storage file server actions context
9621
+ * @returns an async transform-and-validate function that creates a new StorageFileGroup
9392
9622
  */ function createStorageFileGroupFactory(context) {
9393
9623
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9394
9624
  var createStorageFileGroupInTransaction = createStorageFileGroupInTransactionFactory(context);
@@ -9397,7 +9627,7 @@ function createStorageFileGroupInTransactionFactory(context) {
9397
9627
  var model, storageFileId, storageFileGroupRelatedModelKey;
9398
9628
  return _ts_generator$4(this, function(_state) {
9399
9629
  model = params.model, storageFileId = params.storageFileId;
9400
- storageFileGroupRelatedModelKey = model ? model : storageFileId ? inferKeyFromTwoWayFlatFirestoreModelKey(storageFileId) : undefined;
9630
+ storageFileGroupRelatedModelKey = model !== null && model !== void 0 ? model : storageFileId ? inferKeyFromTwoWayFlatFirestoreModelKey(storageFileId) : undefined;
9401
9631
  if (!storageFileGroupRelatedModelKey) {
9402
9632
  throw createStorageFileGroupInputError();
9403
9633
  }
@@ -9405,42 +9635,32 @@ function createStorageFileGroupInTransactionFactory(context) {
9405
9635
  2,
9406
9636
  function() {
9407
9637
  return _async_to_generator$4(function() {
9408
- var result;
9409
9638
  return _ts_generator$4(this, function(_state) {
9410
- switch(_state.label){
9411
- case 0:
9412
- return [
9413
- 4,
9414
- firestoreContext.runTransaction(function(transaction) {
9415
- return _async_to_generator$4(function() {
9416
- var storageFileGroupDocument;
9417
- return _ts_generator$4(this, function(_state) {
9418
- switch(_state.label){
9419
- case 0:
9420
- return [
9421
- 4,
9422
- createStorageFileGroupInTransaction({
9423
- storageFileGroupRelatedModelKey: storageFileGroupRelatedModelKey
9424
- }, transaction)
9425
- ];
9426
- case 1:
9427
- storageFileGroupDocument = _state.sent().storageFileGroupDocument;
9428
- return [
9429
- 2,
9430
- storageFileGroupDocument
9431
- ];
9432
- }
9433
- });
9434
- })();
9435
- })
9436
- ];
9437
- case 1:
9438
- result = _state.sent();
9439
- return [
9440
- 2,
9441
- result
9442
- ];
9443
- }
9639
+ return [
9640
+ 2,
9641
+ firestoreContext.runTransaction(function(transaction) {
9642
+ return _async_to_generator$4(function() {
9643
+ var storageFileGroupDocument;
9644
+ return _ts_generator$4(this, function(_state) {
9645
+ switch(_state.label){
9646
+ case 0:
9647
+ return [
9648
+ 4,
9649
+ createStorageFileGroupInTransaction({
9650
+ storageFileGroupRelatedModelKey: storageFileGroupRelatedModelKey
9651
+ }, transaction)
9652
+ ];
9653
+ case 1:
9654
+ storageFileGroupDocument = _state.sent().storageFileGroupDocument;
9655
+ return [
9656
+ 2,
9657
+ storageFileGroupDocument
9658
+ ];
9659
+ }
9660
+ });
9661
+ })();
9662
+ })
9663
+ ];
9444
9664
  });
9445
9665
  })();
9446
9666
  }
@@ -9449,12 +9669,21 @@ function createStorageFileGroupInTransactionFactory(context) {
9449
9669
  })();
9450
9670
  });
9451
9671
  }
9452
- function _syncStorageFileWithGroupsInTransactionFactory(context) {
9672
+ /**
9673
+ * Internal factory that creates a function for syncing a {@link StorageFile} with its
9674
+ * associated {@link StorageFileGroup} documents within a Firestore transaction.
9675
+ *
9676
+ * Adds the storage file to groups it is missing from, removes it from groups when requested,
9677
+ * and optionally creates new groups for references that do not yet exist.
9678
+ *
9679
+ * @param context - the storage file server actions context
9680
+ * @returns an async function that syncs a storage file with its groups within a transaction
9681
+ */ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9453
9682
  var storageFileCollection = context.storageFileCollection, storageFileGroupCollection = context.storageFileGroupCollection;
9454
9683
  var createStorageFileGroupInTransaction = createStorageFileGroupInTransactionFactory(context);
9455
9684
  return function(input, transaction) {
9456
9685
  return _async_to_generator$4(function() {
9457
- var _storageFile_g, storageFileDocument, inputStorageFile, force, removeAllStorageFileGroups, skipStorageFileUpdate, storageFileDocumentInTransaction, storageFileGroupDocumentAccessor, storageFile, _tmp, g, storageFileGroupDocuments, storageFileGroupPairs, storageFilesGroupsCreated, storageFilesGroupsUpdated, result;
9686
+ var storageFileDocument, inputStorageFile, force, removeAllStorageFileGroups, skipStorageFileUpdate, storageFileDocumentInTransaction, storageFileGroupDocumentAccessor, storageFile, _tmp, g, storageFileGroupDocuments, storageFileGroupPairs, storageFilesGroupsCreated, storageFilesGroupsUpdated, result;
9458
9687
  return _ts_generator$4(this, function(_state) {
9459
9688
  switch(_state.label){
9460
9689
  case 0:
@@ -9483,7 +9712,7 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9483
9712
  if (!storageFile.gs && !force) {
9484
9713
  throw storageFileNotFlaggedForGroupsSyncError();
9485
9714
  }
9486
- g = (_storageFile_g = storageFile.g) !== null && _storageFile_g !== void 0 ? _storageFile_g : [];
9715
+ g = storageFile.g;
9487
9716
  storageFileGroupDocuments = loadDocumentsForIds(storageFileGroupDocumentAccessor, g);
9488
9717
  return [
9489
9718
  4,
@@ -9517,10 +9746,15 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9517
9746
  3,
9518
9747
  6
9519
9748
  ];
9749
+ case undefined:
9750
+ return [
9751
+ 3,
9752
+ 8
9753
+ ];
9520
9754
  }
9521
9755
  return [
9522
9756
  3,
9523
- 8
9757
+ 9
9524
9758
  ];
9525
9759
  case 1:
9526
9760
  // add it if it doesn't exist
@@ -9567,7 +9801,7 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9567
9801
  case 5:
9568
9802
  return [
9569
9803
  3,
9570
- 8
9804
+ 9
9571
9805
  ];
9572
9806
  case 6:
9573
9807
  // remove it
@@ -9588,9 +9822,15 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9588
9822
  storageFilesGroupsUpdated += 1;
9589
9823
  return [
9590
9824
  3,
9591
- 8
9825
+ 9
9592
9826
  ];
9593
9827
  case 8:
9828
+ // no change needed
9829
+ return [
9830
+ 3,
9831
+ 9
9832
+ ];
9833
+ case 9:
9594
9834
  return [
9595
9835
  2
9596
9836
  ];
@@ -9633,8 +9873,11 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9633
9873
  *
9634
9874
  * Syncs a single {@link StorageFile}'s embedded data into its associated {@link StorageFileGroup}
9635
9875
  * documents and clears the sync flag on completion.
9876
+ *
9877
+ * @param context - the storage file server actions context
9878
+ * @returns an async transform-and-validate function that syncs a StorageFile with its groups
9636
9879
  */ function syncStorageFileWithGroupsFactory(context) {
9637
- var firestoreContext = context.firestoreContext; context.storageFileCollection; context.storageFileGroupCollection; var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9880
+ var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9638
9881
  var syncStorageFileWithGroupsInTransaction = _syncStorageFileWithGroupsInTransactionFactory(context);
9639
9882
  return firebaseServerActionTransformFunctionFactory(syncStorageFileWithGroupsParamsType, function(params) {
9640
9883
  return _async_to_generator$4(function() {
@@ -9676,10 +9919,13 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9676
9919
  * Batch-processes all {@link StorageFile} documents flagged for group sync,
9677
9920
  * updating their associated {@link StorageFileGroup} documents and flagging
9678
9921
  * groups for content regeneration when changes occur.
9922
+ *
9923
+ * @param context - the storage file server actions context
9924
+ * @returns an async transform-and-validate function that returns batch sync results
9679
9925
  */ function syncAllFlaggedStorageFilesWithGroupsFactory(context) {
9680
9926
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileCollection = context.storageFileCollection;
9681
9927
  var syncStorageFileWithGroups = syncStorageFileWithGroupsFactory(context);
9682
- return firebaseServerActionTransformFunctionFactory(syncAllFlaggedStorageFilesWithGroupsParamsType, function(params) {
9928
+ return firebaseServerActionTransformFunctionFactory(syncAllFlaggedStorageFilesWithGroupsParamsType, function(_params) {
9683
9929
  return _async_to_generator$4(function() {
9684
9930
  return _ts_generator$4(this, function(_state) {
9685
9931
  return [
@@ -9791,6 +10037,9 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9791
10037
  *
9792
10038
  * Regenerates the content of a single {@link StorageFileGroup}, including building a ZIP
9793
10039
  * archive from the group's embedded files and updating the group's content metadata.
10040
+ *
10041
+ * @param context - the storage file server actions context
10042
+ * @returns an async transform-and-validate function that regenerates a StorageFileGroup's content
9794
10043
  */ function regenerateStorageFileGroupContentFactory(context) {
9795
10044
  var firestoreContext = context.firestoreContext, storageService = context.storageService, storageFileCollection = context.storageFileCollection, storageFileGroupCollection = context.storageFileGroupCollection, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
9796
10045
  var processStorageFileInTransaction = _processStorageFileInTransactionFactory(context);
@@ -9930,10 +10179,13 @@ function _syncStorageFileWithGroupsInTransactionFactory(context) {
9930
10179
  *
9931
10180
  * Batch-processes all {@link StorageFileGroup} documents flagged for content regeneration,
9932
10181
  * rebuilding their ZIP archives and updating content metadata.
10182
+ *
10183
+ * @param context - the storage file server actions context
10184
+ * @returns an async transform-and-validate function that returns batch regeneration results
9933
10185
  */ function regenerateAllFlaggedStorageFileGroupsContentFactory(context) {
9934
10186
  var firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileGroupCollection = context.storageFileGroupCollection;
9935
10187
  var regenerateStorageFileGroupContent = regenerateStorageFileGroupContentFactory(context);
9936
- return firebaseServerActionTransformFunctionFactory(regenerateAllFlaggedStorageFileGroupsContentParamsType, function(params) {
10188
+ return firebaseServerActionTransformFunctionFactory(regenerateAllFlaggedStorageFileGroupsContentParamsType, function(_params) {
9937
10189
  return _async_to_generator$4(function() {
9938
10190
  return _ts_generator$4(this, function(_state) {
9939
10191
  return [
@@ -10218,6 +10470,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10218
10470
  * initialization action to its factory function.
10219
10471
  *
10220
10472
  * @param context - the initialization context with template function and Firestore access
10473
+ * @returns a {@link StorageFileInitServerActions} wired to the provided context
10221
10474
  */ function storageFileInitServerActions(context) {
10222
10475
  return {
10223
10476
  initializeStorageFileGroup: initializeStorageFileGroupFactory(context),
@@ -10233,6 +10486,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10233
10486
  * - Returns `false` → deletes the document entirely
10234
10487
  *
10235
10488
  * @param input - the document, transaction, template function, and options
10489
+ * @returns an object indicating whether the document was initialized or was already initialized
10236
10490
  * @throws storageFileModelAlreadyInitializedError when `throwErrorIfAlreadyInitialized` is true
10237
10491
  */ function initializeStorageFileModelInTransaction(input) {
10238
10492
  return _async_to_generator$3(function() {
@@ -10334,6 +10588,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10334
10588
  *
10335
10589
  * Applies the app-specific template function, restricting the template to only the `o` (owner)
10336
10590
  * and content flag properties, and always flags the group for content regeneration.
10591
+ *
10592
+ * @param context - the initialization context providing collection access and the template function
10593
+ * @returns an async function that initializes a storage file group document within a transaction
10337
10594
  */ function initializeStorageFileGroupInTransactionFactory(context) {
10338
10595
  var storageFileGroupCollection = context.storageFileGroupCollection, makeTemplateForStorageFileGroupInitialization = context.makeTemplateForStorageFileGroupInitialization;
10339
10596
  return function(params, storageFileGroupDocument, transaction) {
@@ -10394,6 +10651,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10394
10651
  *
10395
10652
  * Wraps the in-transaction group initialization in a Firestore transaction
10396
10653
  * and follows the transform-and-validate pattern.
10654
+ *
10655
+ * @param context - the initialization context with Firestore access and template function
10656
+ * @returns a transform-and-validate function for single storage file group initialization
10397
10657
  */ function initializeStorageFileGroupFactory(context) {
10398
10658
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory;
10399
10659
  var initializeStorageFileGroupInTransaction = initializeStorageFileGroupInTransactionFactory(context);
@@ -10434,6 +10694,9 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10434
10694
  * Batch-processes all {@link StorageFileGroup} documents flagged for initialization,
10435
10695
  * initializing each in parallel (up to 5 concurrent tasks). Loops until no more
10436
10696
  * flagged groups are found.
10697
+ *
10698
+ * @param context - the initialization context with Firestore access, collection, and template function
10699
+ * @returns a transform-and-validate function for batch storage file group initialization
10437
10700
  */ function initializeAllApplicableStorageFileGroupsFactory(context) {
10438
10701
  var firestoreContext = context.firestoreContext, firebaseServerActionTransformFunctionFactory = context.firebaseServerActionTransformFunctionFactory, storageFileGroupCollection = context.storageFileGroupCollection;
10439
10702
  var initializeStorageFileGroupInTransaction = initializeStorageFileGroupInTransactionFactory(context);
@@ -10447,7 +10710,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10447
10710
  var storageFileGroupsVisited, storageFileGroupsSucceeded, storageFileGroupsFailed, storageFileGroupsAlreadyInitialized, initializeStorageFileGroupParams, initializeStorageFileGroupsResults, found, result;
10448
10711
  function initializeStorageFileGroups() {
10449
10712
  return _async_to_generator$3(function() {
10450
- var query, storageFileGroupDocuments, result;
10713
+ var query, storageFileGroupDocuments;
10451
10714
  return _ts_generator$3(this, function(_state) {
10452
10715
  switch(_state.label){
10453
10716
  case 0:
@@ -10459,7 +10722,7 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10459
10722
  case 1:
10460
10723
  storageFileGroupDocuments = _state.sent();
10461
10724
  return [
10462
- 4,
10725
+ 2,
10463
10726
  performAsyncTasks(storageFileGroupDocuments, function(storageFileGroupDocument) {
10464
10727
  return _async_to_generator$3(function() {
10465
10728
  return _ts_generator$3(this, function(_state) {
@@ -10475,12 +10738,6 @@ var MAKE_TEMPLATE_FOR_STORAGEFILE_RELATED_MODEL_INITIALIZATION_FUNCTION_DELETE_R
10475
10738
  maxParallelTasks: 5
10476
10739
  })
10477
10740
  ];
10478
- case 2:
10479
- result = _state.sent();
10480
- return [
10481
- 2,
10482
- result
10483
- ];
10484
10741
  }
10485
10742
  });
10486
10743
  })();
@@ -10640,6 +10897,10 @@ function _unsupported_iterable_to_array$1(o, minLen) {
10640
10897
  /**
10641
10898
  * Factory that assembles the full {@link StorageFileServerActionsContext} by combining
10642
10899
  * the base context with the upload initialization service.
10900
+ *
10901
+ * @param context - the base server actions context providing Firebase infrastructure
10902
+ * @param storageFileInitializeFromUploadService - the service for initializing storage files from uploads
10903
+ * @returns the fully assembled StorageFileServerActionsContext
10643
10904
  */ function storageFileServerActionsContextFactory(context, storageFileInitializeFromUploadService) {
10644
10905
  return _object_spread_props$2(_object_spread$2({}, context), {
10645
10906
  storageFileInitializeFromUploadService: storageFileInitializeFromUploadService
@@ -10647,12 +10908,19 @@ function _unsupported_iterable_to_array$1(o, minLen) {
10647
10908
  }
10648
10909
  /**
10649
10910
  * Factory that creates a {@link StorageFileServerActions} instance from the assembled context.
10911
+ *
10912
+ * @param context - the fully assembled storage file server actions context
10913
+ * @returns a concrete StorageFileServerActions instance
10650
10914
  */ function storageFileServerActionsFactory(context) {
10651
10915
  return storageFileServerActions(context);
10652
10916
  }
10653
10917
  /**
10654
10918
  * Factory that creates a {@link StorageFileInitServerActions} instance by merging the
10655
10919
  * server actions context with the init-specific configuration.
10920
+ *
10921
+ * @param context - the storage file server actions context
10922
+ * @param storageFileInitServerActionsContextConfig - init-specific configuration with the template function
10923
+ * @returns a concrete StorageFileInitServerActions instance
10656
10924
  */ function storageFileInitServerActionsFactory(context, storageFileInitServerActionsContextConfig) {
10657
10925
  return storageFileInitServerActions(_object_spread$2({}, context, storageFileInitServerActionsContextConfig));
10658
10926
  }
@@ -10666,9 +10934,8 @@ function _unsupported_iterable_to_array$1(o, minLen) {
10666
10934
  *
10667
10935
  * Be sure the class that delares the module using this function also extends AbstractAppStorageFileModule.
10668
10936
  *
10669
- * @param provide
10670
- * @param useFactory
10671
- * @returns
10937
+ * @param config - the module configuration including optional dependency module, imports, exports, and providers
10938
+ * @returns the assembled {@link ModuleMetadata} for the storage file module
10672
10939
  */ function appStorageFileModuleMetadata(config) {
10673
10940
  var dependencyModule = config.dependencyModule, imports = config.imports, exports$1 = config.exports, providers = config.providers;
10674
10941
  var dependencyModuleImport = dependencyModule ? [
@@ -11132,6 +11399,13 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11132
11399
  };
11133
11400
  /**
11134
11401
  * Creates a NotificationTaskServiceTaskHandlerConfig that handles the StorageFileProcessingNotificationTask.
11402
+ *
11403
+ * Builds a subtask-based notification handler that loads the storage file document,
11404
+ * determines its purpose, and dispatches to the appropriate purpose-specific processor.
11405
+ * Includes optional StorageFileGroup processors (e.g., ZIP generation) by default.
11406
+ *
11407
+ * @param config - handler configuration including processors, storage accessor, and Firestore collections
11408
+ * @returns a NotificationTaskServiceTaskHandlerConfig wired for storage file processing
11135
11409
  */ function storageFileProcessingNotificationTaskHandler(config) {
11136
11410
  var inputProcessors = config.processors, storageAccessor = config.storageAccessor, storageFileFirestoreCollections = config.storageFileFirestoreCollections, allStorageFileGroupProcessorConfig = config.allStorageFileGroupProcessorConfig;
11137
11411
  var storageFileDocumentAccessor = storageFileFirestoreCollections.storageFileCollection.documentAccessor();
@@ -11150,16 +11424,11 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11150
11424
  subtaskHandlerFunctionName: 'storageFileProcessingNotificationTaskHandler',
11151
11425
  inputFunction: function inputFunction(data) {
11152
11426
  return _async_to_generator$1(function() {
11153
- var storageFileDocument, loadStorageFile, purpose, storagePath, file, fileDetailsAccessor, input;
11427
+ var storageFileDocument, loadStorageFile, purpose, storagePath, file, fileDetailsAccessor;
11154
11428
  return _ts_generator$1(this, function(_state) {
11155
11429
  switch(_state.label){
11156
11430
  case 0:
11157
- return [
11158
- 4,
11159
- storageFileDocumentAccessor.loadDocumentForId(data.storageFile)
11160
- ];
11161
- case 1:
11162
- storageFileDocument = _state.sent();
11431
+ storageFileDocument = storageFileDocumentAccessor.loadDocumentForId(data.storageFile);
11163
11432
  loadStorageFile = cachedGetter(function() {
11164
11433
  return _async_to_generator$1(function() {
11165
11434
  var storageFile;
@@ -11183,11 +11452,17 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11183
11452
  });
11184
11453
  })();
11185
11454
  });
11186
- purpose = data === null || data === void 0 ? void 0 : data.p;
11187
- if (!!purpose) return [
11455
+ purpose = data.p;
11456
+ if (!(// attempt to load the purpose from the storage file, if it exists.
11457
+ purpose !== null && purpose !== void 0)) return [
11458
+ 3,
11459
+ 1
11460
+ ];
11461
+ return [
11188
11462
  3,
11189
11463
  3
11190
11464
  ];
11465
+ case 1:
11191
11466
  return [
11192
11467
  4,
11193
11468
  loadStorageFile().then(function(x) {
@@ -11195,7 +11470,6 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11195
11470
  })
11196
11471
  ];
11197
11472
  case 2:
11198
- // attempt to load the purpose from the storage file, if it exists.
11199
11473
  purpose = _state.sent();
11200
11474
  _state.label = 3;
11201
11475
  case 3:
@@ -11224,15 +11498,14 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11224
11498
  case 6:
11225
11499
  file = storageAccessor.file(storagePath);
11226
11500
  fileDetailsAccessor = makeFileDetailsAccessor(file);
11227
- input = {
11228
- target: purpose,
11229
- loadStorageFile: loadStorageFile,
11230
- fileDetailsAccessor: fileDetailsAccessor,
11231
- storageFileDocument: storageFileDocument
11232
- };
11233
11501
  return [
11234
11502
  2,
11235
- input
11503
+ {
11504
+ target: purpose,
11505
+ loadStorageFile: loadStorageFile,
11506
+ fileDetailsAccessor: fileDetailsAccessor,
11507
+ storageFileDocument: storageFileDocument
11508
+ }
11236
11509
  ];
11237
11510
  }
11238
11511
  });
@@ -11285,7 +11558,12 @@ var storageFileProcessingNotificationTaskHandlerDefaultCleanup = function storag
11285
11558
  processors: processors
11286
11559
  }));
11287
11560
  }
11288
- function allStorageFileGroupStorageFileProcessingPurposeSubtaskProcessors(config) {
11561
+ /**
11562
+ * Assembles all built-in StorageFileGroup subtask processors, such as ZIP generation.
11563
+ *
11564
+ * @param config - configuration controlling which group processors to include
11565
+ * @returns an array of subtask processor configs for StorageFileGroup processing purposes
11566
+ */ function allStorageFileGroupStorageFileProcessingPurposeSubtaskProcessors(config) {
11289
11567
  var excludeZipProcessing = config.excludeZipProcessing;
11290
11568
  var processors = [];
11291
11569
  if (!excludeZipProcessing) {
@@ -11293,7 +11571,15 @@ function allStorageFileGroupStorageFileProcessingPurposeSubtaskProcessors(config
11293
11571
  }
11294
11572
  return processors;
11295
11573
  }
11296
- function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config) {
11574
+ /**
11575
+ * Creates the ZIP subtask processor for {@link StorageFileGroup} processing.
11576
+ *
11577
+ * This processor streams all files in the group into a ZIP archive, attaches an info JSON
11578
+ * manifest, and uploads the result to the group's designated storage path.
11579
+ *
11580
+ * @param config - configuration providing Firestore collections, storage accessor, and ZIP options
11581
+ * @returns a subtask processor config targeting the StorageFileGroup ZIP purpose
11582
+ */ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config) {
11297
11583
  var _ref;
11298
11584
  var storageFileFirestoreCollections = config.storageFileFirestoreCollections, storageAccessor = config.storageAccessor, zip = config.zip;
11299
11585
  var storageFileCollection = storageFileFirestoreCollections.storageFileCollection, storageFileGroupCollection = storageFileFirestoreCollections.storageFileGroupCollection;
@@ -11423,7 +11709,7 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
11423
11709
  4,
11424
11710
  performAsyncTasks(storageFileDataPairsToZip, function(storageFileDataPair) {
11425
11711
  return _async_to_generator$1(function() {
11426
- var storageFile, storageFileDisplayName, referencesStorageFileGroup, fileAccessor, metadata, fileSlashPathDetails, storageFileGroupEmbeddedFile, embeddedFileNameOverride, nameFromFactory, untypedName, extension, name, fileStream;
11712
+ var storageFile, storageFileDisplayName, referencesStorageFileGroup, fileAccessor, metadata, _ref, _ref1, fileSlashPathDetails, storageFileGroupEmbeddedFile, embeddedFileNameOverride, nameFromFactory, untypedName, extension, name, fileStream;
11427
11713
  return _ts_generator$1(this, function(_state) {
11428
11714
  switch(_state.label){
11429
11715
  case 0:
@@ -11434,9 +11720,7 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
11434
11720
  ];
11435
11721
  storageFileDisplayName = storageFile.n;
11436
11722
  // make sure it references the storage file group
11437
- referencesStorageFileGroup = storageFile.g.some(function(x) {
11438
- return x === storageFileGroupId;
11439
- });
11723
+ referencesStorageFileGroup = storageFile.g.includes(storageFileGroupId);
11440
11724
  if (!referencesStorageFileGroup) return [
11441
11725
  3,
11442
11726
  6
@@ -11469,15 +11753,20 @@ function storageFileGroupZipStorageFileProcessingPurposeSubtaskProcessor(config)
11469
11753
  ];
11470
11754
  case 2:
11471
11755
  nameFromFactory = _state.sent();
11472
- untypedName = nameFromFactory || storageFileDisplayName || embeddedFileNameOverride || fileSlashPathDetails.fileName;
11756
+ untypedName = (_ref = (_ref1 = nameFromFactory !== null && nameFromFactory !== void 0 ? nameFromFactory : storageFileDisplayName) !== null && _ref1 !== void 0 ? _ref1 : embeddedFileNameOverride) !== null && _ref !== void 0 ? _ref : fileSlashPathDetails.fileName;
11473
11757
  if (fileSlashPathDetails.typedFileExtension) {
11474
11758
  extension = fileSlashPathDetails.typedFileExtension;
11475
11759
  } else if (metadata.contentType) {
11476
11760
  extension = documentFileExtensionForMimeType(metadata.contentType);
11477
11761
  }
11478
11762
  // set the default name if still unset
11479
- untypedName = untypedName || "sf_".concat(storageFile.id);
11763
+ untypedName = untypedName !== null && untypedName !== void 0 ? untypedName : "sf_".concat(storageFile.id);
11480
11764
  name = extension ? "".concat(untypedName, ".").concat(extension) : untypedName;
11765
+ if (!fileAccessor.getStream) {
11766
+ return [
11767
+ 2
11768
+ ]; // skip files where getStream is not available
11769
+ }
11481
11770
  fileStream = fileAccessor.getStream();
11482
11771
  return [
11483
11772
  4,
@@ -11828,6 +12117,7 @@ function _ts_generator(thisArg, body) {
11828
12117
  *
11829
12118
  * @param error - the error that caused the permanent failure
11830
12119
  * @param createdFile - optional path to a file that was created before the error and should be deleted
12120
+ * @returns a permanent failure result with the error and optional created file reference
11831
12121
  */ function storageFileInitializeFromUploadServiceInitializerResultPermanentFailure(error, createdFile) {
11832
12122
  return {
11833
12123
  error: error,
@@ -11847,6 +12137,7 @@ function _ts_generator(thisArg, body) {
11847
12137
  * 4. Optionally, previous files for the same purpose/user are flagged for deletion
11848
12138
  *
11849
12139
  * @param config - service configuration including determiners, initializers, and storage references
12140
+ * @returns a {@link StorageFileInitializeFromUploadService} with type detection and upload initialization
11850
12141
  *
11851
12142
  * @example
11852
12143
  * ```ts
@@ -11883,10 +12174,9 @@ function _ts_generator(thisArg, body) {
11883
12174
  }
11884
12175
  });
11885
12176
  var determiner = combineUploadFileTypeDeterminers(_object_spread({
11886
- determiners: allDeterminers
11887
- }, _object_spread({
12177
+ determiners: allDeterminers,
11888
12178
  completeSearchOnFirstMatch: true
11889
- }, config.combineDeterminersConfig)));
12179
+ }, config.combineDeterminersConfig));
11890
12180
  // validate initializers
11891
12181
  if (validate) {
11892
12182
  var allInitializerTypes = Object.keys(initializers);
@@ -11914,6 +12204,7 @@ function _ts_generator(thisArg, body) {
11914
12204
  return {
11915
12205
  checkFileIsAllowedToBeInitialized: inputCheckFileIsAllowedToBeInitialized !== null && inputCheckFileIsAllowedToBeInitialized !== void 0 ? inputCheckFileIsAllowedToBeInitialized : asDecisionFunction(true),
11916
12206
  determineUploadFileType: determineUploadFileType,
12207
+ // eslint-disable-next-line sonarjs/cognitive-complexity
11917
12208
  initializeFromUpload: function initializeFromUpload(input) {
11918
12209
  return _async_to_generator(function() {
11919
12210
  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;