@dereekb/firebase-server 13.15.0 → 13.16.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.
@@ -251,9 +251,7 @@ var DEFAULT_MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_MAX_BATCH_SIZE_PER_REQUEST =
251
251
  return _ts_generator$h(this, function(_state) {
252
252
  sendTemplateNameToLowercase = sendTemplateName.toLowerCase();
253
253
  builderForKey = lowercaseKeysMessageBuilders[sendTemplateNameToLowercase];
254
- if (!builderForKey) {
255
- throw new Error('mailgunNotificationEmailSendService(): A template builder was not available for template type "'.concat(sendTemplateName, '".'));
256
- } else {
254
+ if (builderForKey) {
257
255
  input = {
258
256
  mailgunService: mailgunService,
259
257
  sendTemplateName: sendTemplateName,
@@ -264,6 +262,7 @@ var DEFAULT_MAILGUN_NOTIFICATION_EMAIL_SEND_SERVICE_MAX_BATCH_SIZE_PER_REQUEST =
264
262
  builderForKey(input)
265
263
  ];
266
264
  }
265
+ throw new Error('mailgunNotificationEmailSendService(): A template builder was not available for template type "'.concat(sendTemplateName, '".'));
267
266
  });
268
267
  })();
269
268
  }))
@@ -1214,13 +1213,13 @@ function _ts_generator$g(thisArg, body) {
1214
1213
  var result;
1215
1214
  if (removeAllCompletedCheckpoints) {
1216
1215
  result = [];
1217
- } else if (removeFromCompletedCheckpoints != null) {
1216
+ } else if (removeFromCompletedCheckpoints == null) {
1217
+ result = inputCompletions;
1218
+ } else {
1218
1219
  var removeFromCompletionsSet = new Set(util.asArray(removeFromCompletedCheckpoints));
1219
1220
  result = inputCompletions.filter(function(x) {
1220
1221
  return !removeFromCompletionsSet.has(x);
1221
1222
  });
1222
- } else {
1223
- result = inputCompletions;
1224
1223
  }
1225
1224
  return result;
1226
1225
  }
@@ -1797,17 +1796,10 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1797
1796
  notificationBox = notificationBoxDocumentSnapshotDataPair.data, document = notificationBoxDocumentSnapshotDataPair.document;
1798
1797
  nb = document.id;
1799
1798
  notificationUserNotificationBoxConfig = notificationBoxConfigsToSyncInThisBatchMap.get(nb); // always exists
1800
- if (!!notificationBox) return [
1801
- 3,
1802
- 1
1803
- ];
1804
- // if the entire NotificationBox no longer exists, flag to remove it from the user as a cleanup measure
1805
- notificationBoxConfigsToRemoveFromNotificationUser.add(nb);
1806
- return [
1799
+ if (!notificationBox) return [
1807
1800
  3,
1808
1801
  3
1809
1802
  ];
1810
- case 1:
1811
1803
  // update in the NotificationBox
1812
1804
  recipientIndex = notificationBox.r.findIndex(function(x) {
1813
1805
  return x.uid === notificationUser.uid;
@@ -1841,7 +1833,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1841
1833
  }
1842
1834
  if (!(r != null)) return [
1843
1835
  3,
1844
- 3
1836
+ 2
1845
1837
  ];
1846
1838
  return [
1847
1839
  4,
@@ -1849,11 +1841,20 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
1849
1841
  r: r
1850
1842
  })
1851
1843
  ];
1852
- case 2:
1844
+ case 1:
1853
1845
  _state.sent();
1854
1846
  notificationBoxesUpdatedInBatch += 1;
1855
- _state.label = 3;
1847
+ _state.label = 2;
1848
+ case 2:
1849
+ return [
1850
+ 3,
1851
+ 4
1852
+ ];
1856
1853
  case 3:
1854
+ // if the entire NotificationBox no longer exists, flag to remove it from the user as a cleanup measure
1855
+ notificationBoxConfigsToRemoveFromNotificationUser.add(nb);
1856
+ _state.label = 4;
1857
+ case 4:
1857
1858
  return [
1858
1859
  2
1859
1860
  ];
@@ -2459,7 +2460,7 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2459
2460
  if (!targetRecipient && !insert) {
2460
2461
  throw notificationBoxRecipientDoesNotExistsError();
2461
2462
  }
2462
- c = (_ref = inputC != null ? firebase.notificationBoxRecipientTemplateConfigArrayToRecord(inputC) : targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.c) !== null && _ref !== void 0 ? _ref : {};
2463
+ c = (_ref = inputC == null ? targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.c : firebase.notificationBoxRecipientTemplateConfigArrayToRecord(inputC)) !== null && _ref !== void 0 ? _ref : {};
2463
2464
  nextRecipient = _object_spread$c({
2464
2465
  uid: uid,
2465
2466
  i: (_ref1 = targetRecipient === null || targetRecipient === void 0 ? void 0 : targetRecipient.i) !== null && _ref1 !== void 0 ? _ref1 : util.UNSET_INDEX_NUMBER,
@@ -2657,14 +2658,15 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2657
2658
  return _ts_generator$f(this, function(_state) {
2658
2659
  switch(_state.label){
2659
2660
  case 0:
2660
- if (!(params.setExclusion != null)) return [
2661
+ if (!(params.setExclusion == null)) return [
2661
2662
  3,
2662
2663
  2
2663
2664
  ];
2664
2665
  return [
2665
2666
  4,
2666
- updateNotificationBoxRecipientExclusionInTransaction({
2667
+ updateNotificationBoxRecipientInTransaction({
2667
2668
  params: params,
2669
+ throwErrorIfNotificationBoxDoesNotExist: true,
2668
2670
  notificationBoxDocument: notificationBoxDocument
2669
2671
  }, transaction)
2670
2672
  ];
@@ -2677,9 +2679,8 @@ var MAX_NOTIFICATION_BOXES_TO_UPDATE_PER_BATCH = 50;
2677
2679
  case 2:
2678
2680
  return [
2679
2681
  4,
2680
- updateNotificationBoxRecipientInTransaction({
2682
+ updateNotificationBoxRecipientExclusionInTransaction({
2681
2683
  params: params,
2682
- throwErrorIfNotificationBoxDoesNotExist: true,
2683
2684
  notificationBoxDocument: notificationBoxDocument
2684
2685
  }, transaction)
2685
2686
  ];
@@ -3017,11 +3018,11 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3017
3018
  case 0:
3018
3019
  if (!(notification != null)) return [
3019
3020
  3,
3020
- 48
3021
+ 42
3021
3022
  ];
3022
3023
  if (!(tryRun && templateInstance != null)) return [
3023
3024
  3,
3024
- 47
3025
+ 41
3025
3026
  ];
3026
3027
  return [
3027
3028
  4,
@@ -3042,7 +3043,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3042
3043
  messageFunction = _state.sent();
3043
3044
  if (!messageFunction) return [
3044
3045
  3,
3045
- 46
3046
+ 40
3046
3047
  ];
3047
3048
  filterOutNoContentNotificationMessages = function filterOutNoContentNotificationMessages(messages) {
3048
3049
  return messages.filter(function(x) {
@@ -3069,7 +3070,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3069
3070
  currentEsr = notification.esr, currentTsr = notification.tsr;
3070
3071
  if (!(es === firebase.NotificationSendState.QUEUED || es === firebase.NotificationSendState.SENT_PARTIAL)) return [
3071
3072
  3,
3072
- 15
3073
+ 13
3073
3074
  ];
3074
3075
  emailRecipientsAlreadySentTo = new Set(currentEsr.map(function(x) {
3075
3076
  return x.toLowerCase();
@@ -3098,13 +3099,18 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3098
3099
  emailMessages = _state.sent();
3099
3100
  if (!(emailMessages === null || emailMessages === void 0 ? void 0 : emailMessages.length)) return [
3100
3101
  3,
3101
- 14
3102
+ 12
3102
3103
  ];
3103
- if (!(notificationSendService.emailSendService != null)) return [
3104
+ if (!(notificationSendService.emailSendService == null)) return [
3104
3105
  3,
3105
- 12
3106
+ 4
3107
+ ];
3108
+ console.error('Failed sending email notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no email service being configured.'));
3109
+ es = firebase.NotificationSendState.CONFIG_ERROR;
3110
+ return [
3111
+ 3,
3112
+ 11
3106
3113
  ];
3107
- _state.label = 4;
3108
3114
  case 4:
3109
3115
  _state.trys.push([
3110
3116
  4,
@@ -3162,15 +3168,6 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3162
3168
  11
3163
3169
  ];
3164
3170
  case 11:
3165
- return [
3166
- 3,
3167
- 13
3168
- ];
3169
- case 12:
3170
- console.error('Failed sending email notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no email service being configured.'));
3171
- es = firebase.NotificationSendState.CONFIG_ERROR;
3172
- _state.label = 13;
3173
- case 13:
3174
3171
  if (sendEmailsResult != null) {
3175
3172
  success1 = sendEmailsResult.success, failed = sendEmailsResult.failed;
3176
3173
  esr = success1.length ? _to_consumable_array$6(currentEsr).concat(_to_consumable_array$6(success1.map(function(x) {
@@ -3184,15 +3181,15 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3184
3181
  }
3185
3182
  return [
3186
3183
  3,
3187
- 15
3184
+ 13
3188
3185
  ];
3189
- case 14:
3186
+ case 12:
3190
3187
  es = firebase.NotificationSendState.SENT;
3191
- _state.label = 15;
3192
- case 15:
3188
+ _state.label = 13;
3189
+ case 13:
3193
3190
  if (!(ts === firebase.NotificationSendState.QUEUED || ts === firebase.NotificationSendState.SENT_PARTIAL)) return [
3194
3191
  3,
3195
- 28
3192
+ 24
3196
3193
  ];
3197
3194
  textRecipientsAlreadySentTo = new Set(currentTsr);
3198
3195
  textInputContexts = textRecipients.filter(function(x) {
@@ -3215,83 +3212,79 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3215
3212
  return undefined;
3216
3213
  })
3217
3214
  ];
3218
- case 16:
3215
+ case 14:
3219
3216
  textMessages = _state.sent();
3220
3217
  if (!(textMessages === null || textMessages === void 0 ? void 0 : textMessages.length)) return [
3221
3218
  3,
3222
- 27
3219
+ 23
3223
3220
  ];
3224
- if (!(notificationSendService.textSendService != null)) return [
3221
+ if (!(notificationSendService.textSendService == null)) return [
3225
3222
  3,
3226
- 25
3223
+ 15
3227
3224
  ];
3228
- _state.label = 17;
3229
- case 17:
3225
+ console.error('Failed sending text notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no text service being configured.'));
3226
+ ts = firebase.NotificationSendState.CONFIG_ERROR;
3227
+ return [
3228
+ 3,
3229
+ 22
3230
+ ];
3231
+ case 15:
3230
3232
  _state.trys.push([
3233
+ 15,
3231
3234
  17,
3232
- 19,
3233
3235
  ,
3234
- 20
3236
+ 18
3235
3237
  ]);
3236
3238
  return [
3237
3239
  4,
3238
3240
  notificationSendService.textSendService.buildSendInstanceForTextNotificationMessages(textMessages)
3239
3241
  ];
3240
- case 18:
3242
+ case 16:
3241
3243
  sendInstance1 = _state.sent();
3242
3244
  return [
3243
3245
  3,
3244
- 20
3246
+ 18
3245
3247
  ];
3246
- case 19:
3248
+ case 17:
3247
3249
  e2 = _state.sent();
3248
3250
  console.error('Failed building text send instance for notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '": '), e2);
3249
3251
  ts = firebase.NotificationSendState.CONFIG_ERROR;
3250
3252
  return [
3251
3253
  3,
3252
- 20
3254
+ 18
3253
3255
  ];
3254
- case 20:
3256
+ case 18:
3255
3257
  if (!sendInstance1) return [
3256
3258
  3,
3257
- 24
3259
+ 22
3258
3260
  ];
3259
- _state.label = 21;
3260
- case 21:
3261
+ _state.label = 19;
3262
+ case 19:
3261
3263
  _state.trys.push([
3264
+ 19,
3262
3265
  21,
3263
- 23,
3264
3266
  ,
3265
- 24
3267
+ 22
3266
3268
  ]);
3267
3269
  return [
3268
3270
  4,
3269
3271
  sendInstance1()
3270
3272
  ];
3271
- case 22:
3273
+ case 20:
3272
3274
  sendTextsResult = _state.sent();
3273
3275
  return [
3274
3276
  3,
3275
- 24
3277
+ 22
3276
3278
  ];
3277
- case 23:
3279
+ case 21:
3278
3280
  e3 = _state.sent();
3279
3281
  console.error('Failed sending text notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '": '), e3);
3280
3282
  ts = firebase.NotificationSendState.SEND_ERROR;
3281
3283
  return [
3282
3284
  3,
3283
- 24
3284
- ];
3285
- case 24:
3286
- return [
3287
- 3,
3288
- 26
3285
+ 22
3289
3286
  ];
3290
- case 25:
3291
- console.error('Failed sending text notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no text service being configured.'));
3292
- ts = firebase.NotificationSendState.CONFIG_ERROR;
3293
- _state.label = 26;
3294
- case 26:
3287
+ case 22:
3295
3288
  if (sendTextsResult != null) {
3296
3289
  success2 = sendTextsResult.success, failed1 = sendTextsResult.failed;
3297
3290
  tsr = success2.length ? _to_consumable_array$6(currentTsr).concat(_to_consumable_array$6(success2)) : undefined;
@@ -3303,16 +3296,16 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3303
3296
  }
3304
3297
  return [
3305
3298
  3,
3306
- 28
3299
+ 24
3307
3300
  ];
3308
- case 27:
3301
+ case 23:
3309
3302
  ts = firebase.NotificationSendState.SENT;
3310
- _state.label = 28;
3311
- case 28:
3303
+ _state.label = 24;
3304
+ case 24:
3312
3305
  ps = firebase.NotificationSendState.NO_TRY;
3313
3306
  if (!(ns === firebase.NotificationSendState.QUEUED || ns === firebase.NotificationSendState.SENT_PARTIAL)) return [
3314
3307
  3,
3315
- 41
3308
+ 35
3316
3309
  ];
3317
3310
  notificationSummaryInputContexts = notificationSummaryRecipients.map(function(x) {
3318
3311
  var _$context = {
@@ -3331,92 +3324,88 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3331
3324
  return undefined;
3332
3325
  })
3333
3326
  ];
3334
- case 29:
3327
+ case 25:
3335
3328
  notificationSummaryMessages = _state.sent();
3336
3329
  if (!(notificationSummaryMessages === null || notificationSummaryMessages === void 0 ? void 0 : notificationSummaryMessages.length)) return [
3337
3330
  3,
3338
- 40
3331
+ 34
3339
3332
  ];
3340
- if (!(notificationSendService.notificationSummarySendService != null)) return [
3333
+ if (!(notificationSendService.notificationSummarySendService == null)) return [
3341
3334
  3,
3342
- 38
3335
+ 26
3343
3336
  ];
3344
- _state.label = 30;
3345
- case 30:
3337
+ console.error('Failed sending notification summary notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no notification summary service being configured.'));
3338
+ ns = firebase.NotificationSendState.CONFIG_ERROR;
3339
+ return [
3340
+ 3,
3341
+ 33
3342
+ ];
3343
+ case 26:
3346
3344
  _state.trys.push([
3347
- 30,
3348
- 32,
3345
+ 26,
3346
+ 28,
3349
3347
  ,
3350
- 33
3348
+ 29
3351
3349
  ]);
3352
3350
  return [
3353
3351
  4,
3354
3352
  notificationSendService.notificationSummarySendService.buildSendInstanceForNotificationSummaryMessages(notificationSummaryMessages)
3355
3353
  ];
3356
- case 31:
3354
+ case 27:
3357
3355
  sendInstance2 = _state.sent();
3358
3356
  return [
3359
3357
  3,
3360
- 33
3358
+ 29
3361
3359
  ];
3362
- case 32:
3360
+ case 28:
3363
3361
  e4 = _state.sent();
3364
3362
  console.error('Failed building notification summary send instance for notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '": '), e4);
3365
3363
  ns = firebase.NotificationSendState.CONFIG_ERROR;
3366
3364
  return [
3367
3365
  3,
3368
- 33
3366
+ 29
3369
3367
  ];
3370
- case 33:
3368
+ case 29:
3371
3369
  if (!sendInstance2) return [
3372
3370
  3,
3373
- 37
3371
+ 33
3374
3372
  ];
3375
- _state.label = 34;
3376
- case 34:
3373
+ _state.label = 30;
3374
+ case 30:
3377
3375
  _state.trys.push([
3378
- 34,
3379
- 36,
3376
+ 30,
3377
+ 32,
3380
3378
  ,
3381
- 37
3379
+ 33
3382
3380
  ]);
3383
3381
  return [
3384
3382
  4,
3385
3383
  sendInstance2()
3386
3384
  ];
3387
- case 35:
3385
+ case 31:
3388
3386
  sendNotificationSummaryResult = _state.sent();
3389
3387
  ns = firebase.NotificationSendState.SENT;
3390
3388
  return [
3391
3389
  3,
3392
- 37
3390
+ 33
3393
3391
  ];
3394
- case 36:
3392
+ case 32:
3395
3393
  e5 = _state.sent();
3396
3394
  console.error('Failed sending notification summary notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '": '), e5);
3397
3395
  ns = firebase.NotificationSendState.SEND_ERROR;
3398
3396
  return [
3399
3397
  3,
3400
- 37
3401
- ];
3402
- case 37:
3403
- return [
3404
- 3,
3405
- 39
3398
+ 33
3406
3399
  ];
3407
- case 38:
3408
- console.error('Failed sending notification summary notification "'.concat(notification.id, '" with type "').concat(notificationTemplateType, '" due to no notification summary service being configured.'));
3409
- ns = firebase.NotificationSendState.CONFIG_ERROR;
3410
- _state.label = 39;
3411
- case 39:
3400
+ case 33:
3412
3401
  return [
3413
3402
  3,
3414
- 41
3403
+ 35
3415
3404
  ];
3416
- case 40:
3405
+ case 34:
3417
3406
  ns = firebase.NotificationSendState.SENT;
3418
- _state.label = 41;
3419
- case 41:
3407
+ _state.label = 35;
3408
+ case 35:
3420
3409
  // calculate results
3421
3410
  notificationTemplate = {
3422
3411
  es: es,
@@ -3439,7 +3428,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3439
3428
  4,
3440
3429
  notificationDocument.update(notificationTemplate)
3441
3430
  ];
3442
- case 42:
3431
+ case 36:
3443
3432
  _state.sent();
3444
3433
  notificationMarkedDone = notificationTemplate.d === true;
3445
3434
  callbackDetails = {
@@ -3452,7 +3441,7 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3452
3441
  onSendAttempted = messageFunction.onSendAttempted, onSendSuccess = messageFunction.onSendSuccess;
3453
3442
  if (!onSendAttempted) return [
3454
3443
  3,
3455
- 44
3444
+ 38
3456
3445
  ];
3457
3446
  return [
3458
3447
  4,
@@ -3467,13 +3456,13 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3467
3456
  };
3468
3457
  })
3469
3458
  ];
3470
- case 43:
3459
+ case 37:
3471
3460
  onSendAttemptedResult = _state.sent();
3472
- _state.label = 44;
3473
- case 44:
3461
+ _state.label = 38;
3462
+ case 38:
3474
3463
  if (!(notificationMarkedDone && onSendSuccess)) return [
3475
3464
  3,
3476
- 46
3465
+ 40
3477
3466
  ];
3478
3467
  return [
3479
3468
  4,
@@ -3488,15 +3477,15 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3488
3477
  };
3489
3478
  })
3490
3479
  ];
3491
- case 45:
3480
+ case 39:
3492
3481
  onSendSuccessResult = _state.sent();
3493
- _state.label = 46;
3494
- case 46:
3482
+ _state.label = 40;
3483
+ case 40:
3495
3484
  return [
3496
3485
  3,
3497
- 48
3486
+ 42
3498
3487
  ];
3499
- case 47:
3488
+ case 41:
3500
3489
  switch(notification.st){
3501
3490
  case firebase.NotificationSendType.SEND_IF_BOX_EXISTS:
3502
3491
  // deleted successfully
@@ -3508,8 +3497,8 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
3508
3497
  case firebase.NotificationSendType.LOGGED_EVENT:
3509
3498
  break;
3510
3499
  }
3511
- _state.label = 48;
3512
- case 48:
3500
+ _state.label = 42;
3501
+ case 42:
3513
3502
  return [
3514
3503
  2
3515
3504
  ];
@@ -4260,15 +4249,14 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
4260
4249
  return shouldSaveToNotificationWeek ? data.n : undefined;
4261
4250
  }));
4262
4251
  n = _to_consumable_array$6((_ref = notificationWeek === null || notificationWeek === void 0 ? void 0 : notificationWeek.n) !== null && _ref !== void 0 ? _ref : []).concat(_to_consumable_array$6(newItems));
4263
- if (!!notificationWeek) return [
4252
+ if (!notificationWeek) return [
4264
4253
  3,
4265
4254
  3
4266
4255
  ];
4267
- // create
4256
+ // update
4268
4257
  return [
4269
4258
  4,
4270
- notificationWeekDocument.create({
4271
- w: yearWeekCode,
4259
+ notificationWeekDocument.update({
4272
4260
  n: n
4273
4261
  })
4274
4262
  ];
@@ -4279,10 +4267,11 @@ var NOTIFICATION_TASK_TYPE_FAILURE_DELAY_MS = dateFns.hoursToMilliseconds(NOTIFI
4279
4267
  5
4280
4268
  ];
4281
4269
  case 3:
4282
- // update
4270
+ // create
4283
4271
  return [
4284
4272
  4,
4285
- notificationWeekDocument.update({
4273
+ notificationWeekDocument.create({
4274
+ w: yearWeekCode,
4286
4275
  n: n
4287
4276
  })
4288
4277
  ];
@@ -10347,46 +10336,49 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
10347
10336
  case firebase.StorageFileProcessingState.FAILED:
10348
10337
  return [
10349
10338
  3,
10350
- 20
10339
+ 21
10351
10340
  ];
10352
10341
  case firebase.StorageFileProcessingState.DO_NOT_PROCESS:
10353
10342
  return [
10354
10343
  3,
10355
- 22
10344
+ 23
10356
10345
  ];
10357
10346
  case firebase.StorageFileProcessingState.SUCCESS:
10358
10347
  return [
10359
10348
  3,
10360
- 23
10349
+ 24
10361
10350
  ];
10362
10351
  case firebase.StorageFileProcessingState.ARCHIVED:
10363
10352
  return [
10364
10353
  3,
10365
- 27
10354
+ 28
10366
10355
  ];
10367
10356
  }
10368
10357
  return [
10369
10358
  3,
10370
- 28
10359
+ 29
10371
10360
  ];
10372
10361
  case 4:
10373
- if (!!storageFile.p) return [
10362
+ if (!storageFile.p) return [
10374
10363
  3,
10375
- 5
10364
+ 6
10376
10365
  ];
10377
- throw storageFileProcessingNotAvailableForTypeError();
10378
- case 5:
10379
10366
  return [
10380
10367
  4,
10381
10368
  beginProcessing(false)
10382
10369
  ];
10383
- case 6:
10370
+ case 5:
10384
10371
  _state.sent();
10385
- _state.label = 7;
10372
+ return [
10373
+ 3,
10374
+ 7
10375
+ ];
10376
+ case 6:
10377
+ throw storageFileProcessingNotAvailableForTypeError();
10386
10378
  case 7:
10387
10379
  return [
10388
10380
  3,
10389
- 28
10381
+ 29
10390
10382
  ];
10391
10383
  case 8:
10392
10384
  // begin processing
@@ -10398,121 +10390,123 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
10398
10390
  _state.sent();
10399
10391
  return [
10400
10392
  3,
10401
- 28
10393
+ 29
10402
10394
  ];
10403
10395
  case 10:
10404
10396
  // check if the processing task is still running
10405
10397
  shouldCheckProcessing = !util.isThrottled(firebase.STORAGE_FILE_PROCESSING_STUCK_THROTTLE_CHECK_MS, storageFile.pat);
10406
- if (!!storageFile.pn) return [
10407
- 3,
10408
- 12
10409
- ];
10410
- return [
10411
- 4,
10412
- beginProcessing(true)
10413
- ];
10414
- case 11:
10415
- _state.sent(); // if no processing task is set, restart processing to recover from the broken state
10416
- return [
10398
+ if (!storageFile.pn) return [
10417
10399
  3,
10418
- 19
10400
+ 18
10419
10401
  ];
10420
- case 12:
10421
10402
  pn = storageFile.pn;
10422
10403
  notificationDocument = notificationCollectionGroup.documentAccessorForTransaction(transaction).loadDocumentForKey(pn);
10423
10404
  if (!(checkRetryProcessing || shouldCheckProcessing)) return [
10424
10405
  3,
10425
- 18
10406
+ 16
10426
10407
  ];
10427
10408
  return [
10428
10409
  4,
10429
10410
  notificationDocument.snapshotData()
10430
10411
  ];
10431
- case 13:
10412
+ case 11:
10432
10413
  notification = _state.sent();
10433
10414
  if (!!notification) return [
10434
10415
  3,
10435
- 15
10416
+ 13
10436
10417
  ];
10437
10418
  // the notification document is missing. Re-begin processing
10438
10419
  return [
10439
10420
  4,
10440
10421
  beginProcessing(true)
10441
10422
  ];
10442
- case 14:
10423
+ case 12:
10443
10424
  _state.sent();
10444
10425
  return [
10445
10426
  3,
10446
- 17
10427
+ 15
10447
10428
  ];
10448
- case 15:
10429
+ case 13:
10449
10430
  if (!(notification.d || forceRestartProcessing)) return [
10450
10431
  3,
10451
- 17
10432
+ 15
10452
10433
  ];
10453
10434
  // if the notification is somehow in the done state but the StorageFile never got notified in the same transaction, requeue.
10454
10435
  return [
10455
10436
  4,
10456
10437
  beginProcessing(true)
10457
10438
  ];
10458
- case 16:
10439
+ case 14:
10459
10440
  _state.sent();
10460
- _state.label = 17;
10461
- case 17:
10441
+ _state.label = 15;
10442
+ case 15:
10462
10443
  return [
10463
10444
  3,
10464
- 19
10445
+ 17
10465
10446
  ];
10466
- case 18:
10447
+ case 16:
10467
10448
  if (expediteInstance) {
10468
10449
  // enqueue the existing notification to be run in the expedite instance
10469
10450
  expediteInstance.enqueue(notificationDocument);
10470
10451
  }
10471
- _state.label = 19;
10472
- case 19:
10452
+ _state.label = 17;
10453
+ case 17:
10473
10454
  return [
10474
10455
  3,
10475
- 28
10456
+ 20
10476
10457
  ];
10458
+ case 18:
10459
+ return [
10460
+ 4,
10461
+ beginProcessing(true)
10462
+ ];
10463
+ case 19:
10464
+ _state.sent(); // if no processing task is set, restart processing to recover from the broken state
10465
+ _state.label = 20;
10477
10466
  case 20:
10467
+ return [
10468
+ 3,
10469
+ 29
10470
+ ];
10471
+ case 21:
10478
10472
  // restart processing on failure
10479
10473
  return [
10480
10474
  4,
10481
10475
  beginProcessing(true)
10482
10476
  ];
10483
- case 21:
10477
+ case 22:
10484
10478
  _state.sent();
10485
10479
  return [
10486
10480
  3,
10487
- 28
10481
+ 29
10488
10482
  ];
10489
- case 22:
10490
- throw storageFileProcessingNotQueuedForProcessingError();
10491
10483
  case 23:
10484
+ throw storageFileProcessingNotQueuedForProcessingError();
10485
+ case 24:
10492
10486
  if (!(forceRestartProcessing || processAgainIfSuccessful)) return [
10493
10487
  3,
10494
- 25
10488
+ 26
10495
10489
  ];
10496
10490
  return [
10497
10491
  4,
10498
10492
  beginProcessing(true)
10499
10493
  ];
10500
- case 24:
10494
+ case 25:
10501
10495
  _state.sent();
10502
10496
  return [
10503
10497
  3,
10504
- 26
10498
+ 27
10505
10499
  ];
10506
- case 25:
10507
- throw storageFileAlreadyProcessedError();
10508
10500
  case 26:
10501
+ throw storageFileAlreadyProcessedError();
10502
+ case 27:
10509
10503
  return [
10510
10504
  3,
10511
- 28
10505
+ 29
10512
10506
  ];
10513
- case 27:
10514
- throw storageFileProcessingNotQueuedForProcessingError();
10515
10507
  case 28:
10508
+ throw storageFileProcessingNotQueuedForProcessingError();
10509
+ case 29:
10516
10510
  return [
10517
10511
  2
10518
10512
  ];
@@ -11406,7 +11400,7 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
11406
11400
  existsInStorageFileGroup = storageFileGroup === null || storageFileGroup === void 0 ? void 0 : storageFileGroup.f.some(function(x) {
11407
11401
  return x.s === storageFileDocument.id;
11408
11402
  });
11409
- change = removeAllStorageFileGroups ? existsInStorageFileGroup ? 'remove' : undefined : !existsInStorageFileGroup ? 'add' : undefined;
11403
+ change = removeAllStorageFileGroups ? existsInStorageFileGroup ? 'remove' : undefined : existsInStorageFileGroup ? undefined : 'add';
11410
11404
  switch(change){
11411
11405
  case 'add':
11412
11406
  return [
@@ -11441,34 +11435,34 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
11441
11435
  ],
11442
11436
  allowRecalculateRegenerateFlag: false
11443
11437
  });
11444
- if (!!storageFileGroup) return [
11438
+ if (!storageFileGroup) return [
11445
11439
  3,
11446
11440
  3
11447
11441
  ];
11448
- // if the group does not exist, then create it
11442
+ // if the group exists, then update it
11449
11443
  return [
11450
11444
  4,
11451
- createStorageFileGroupInTransaction({
11452
- storageFileGroupDocument: storageFileGroupDocument,
11453
- template: createTemplate
11454
- }, transaction)
11445
+ storageFileGroupDocument.update(createTemplate)
11455
11446
  ];
11456
11447
  case 2:
11457
11448
  _state.sent();
11458
- storageFilesGroupsCreated += 1;
11449
+ storageFilesGroupsUpdated += 1;
11459
11450
  return [
11460
11451
  3,
11461
11452
  5
11462
11453
  ];
11463
11454
  case 3:
11464
- // if the group exists, then update it
11455
+ // if the group does not exist, then create it
11465
11456
  return [
11466
11457
  4,
11467
- storageFileGroupDocument.update(createTemplate)
11458
+ createStorageFileGroupInTransaction({
11459
+ storageFileGroupDocument: storageFileGroupDocument,
11460
+ template: createTemplate
11461
+ }, transaction)
11468
11462
  ];
11469
11463
  case 4:
11470
11464
  _state.sent();
11471
- storageFilesGroupsUpdated += 1;
11465
+ storageFilesGroupsCreated += 1;
11472
11466
  _state.label = 5;
11473
11467
  case 5:
11474
11468
  return [
@@ -11774,10 +11768,28 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
11774
11768
  3,
11775
11769
  7
11776
11770
  ];
11777
- if (!!(existingZipStorageFilePair === null || existingZipStorageFilePair === void 0 ? void 0 : existingZipStorageFilePair.data)) return [
11771
+ if (!(existingZipStorageFilePair === null || existingZipStorageFilePair === void 0 ? void 0 : existingZipStorageFilePair.data)) return [
11778
11772
  3,
11779
11773
  4
11780
11774
  ];
11775
+ // flag it for processing again
11776
+ return [
11777
+ 4,
11778
+ processStorageFileInTransaction({
11779
+ params: {
11780
+ processAgainIfSuccessful: true
11781
+ },
11782
+ storageFileDocument: existingZipStorageFilePair.document,
11783
+ storageFile: existingZipStorageFilePair.data
11784
+ }, transaction)
11785
+ ];
11786
+ case 3:
11787
+ _state.sent();
11788
+ return [
11789
+ 3,
11790
+ 6
11791
+ ];
11792
+ case 4:
11781
11793
  zipStorageFile = storageService.file(firebase.storageFileGroupZipFileStoragePath(storageFileGroupDocument.id));
11782
11794
  return [
11783
11795
  4,
@@ -11793,27 +11805,9 @@ function _resolveSignedUploadUrlFilenameOrThrow(policy, filename) {
11793
11805
  }
11794
11806
  })
11795
11807
  ];
11796
- case 3:
11808
+ case 5:
11797
11809
  storageFileDocument = _state.sent().storageFileDocument;
11798
11810
  updateTemplate.zsf = storageFileDocument.id;
11799
- return [
11800
- 3,
11801
- 6
11802
- ];
11803
- case 4:
11804
- // flag it for processing again
11805
- return [
11806
- 4,
11807
- processStorageFileInTransaction({
11808
- params: {
11809
- processAgainIfSuccessful: true
11810
- },
11811
- storageFileDocument: existingZipStorageFilePair.document,
11812
- storageFile: existingZipStorageFilePair.data
11813
- }, transaction)
11814
- ];
11815
- case 5:
11816
- _state.sent();
11817
11811
  _state.label = 6;
11818
11812
  case 6:
11819
11813
  contentStorageFilesFlaggedForProcessing += 1;