@opencrvs/toolkit 2.1.0-rc.b0003b1 → 2.1.0-rc.b8f206f

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 (44) hide show
  1. package/build.sh +2 -2
  2. package/dist/application-config/index.js +12 -0
  3. package/dist/cli.js +165 -5106
  4. package/dist/commons/api/router.d.ts +723 -130
  5. package/dist/commons/conditionals/conditionals.d.ts +1589 -37
  6. package/dist/commons/events/ActionConfig.d.ts +209 -0
  7. package/dist/commons/events/ActionDocument.d.ts +44 -0
  8. package/dist/commons/events/ActionInput.d.ts +26 -0
  9. package/dist/commons/events/ActionType.d.ts +6 -1
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
  11. package/dist/commons/events/AuditLog.d.ts +2 -0
  12. package/dist/commons/events/Draft.d.ts +2 -0
  13. package/dist/commons/events/EventDocument.d.ts +22 -0
  14. package/dist/commons/events/FieldConfig.d.ts +5 -0
  15. package/dist/commons/events/WorkqueueConfig.d.ts +5 -2
  16. package/dist/commons/events/field.d.ts +722 -34
  17. package/dist/commons/events/scopes.d.ts +1 -0
  18. package/dist/commons/events/test.utils.d.ts +9 -1
  19. package/dist/commons/events/utils.d.ts +23 -1
  20. package/dist/conditionals/index.js +2 -0
  21. package/dist/environment/logger.d.ts +3 -12
  22. package/dist/environment/logger.d.ts.map +1 -1
  23. package/dist/environment/manage-users.js +17 -7
  24. package/dist/environment/swarm-to-k8s.js +17 -7
  25. package/dist/environment/update-workflows.js +17 -7
  26. package/dist/environment/users.js +17 -7
  27. package/dist/environment/utils.js +17 -7
  28. package/dist/events/index.js +195 -30
  29. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  30. package/dist/migrations/v2.0/index.js +88 -5144
  31. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  32. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  33. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  34. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  35. package/dist/migrations/v2.1/index.d.ts +6 -0
  36. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  37. package/dist/migrations/v2.1/index.js +218 -0
  38. package/dist/notification/index.js +146 -22
  39. package/dist/scopes/index.d.ts +7 -1
  40. package/dist/scopes/index.js +2 -0
  41. package/opencrvs-toolkit-2.1.0-rc.b8f206f.tgz +0 -0
  42. package/package.json +2 -2
  43. package/tsconfig.tsbuildinfo +1 -1
  44. package/opencrvs-toolkit-2.1.0-rc.b0003b1.tgz +0 -0
@@ -214,6 +214,7 @@ __export(events_exports, {
214
214
  TimeValue: () => TimeValue,
215
215
  TranslationConfig: () => TranslationConfig,
216
216
  UUID: () => UUID,
217
+ UnarchiveActionInput: () => UnarchiveActionInput,
217
218
  UnassignActionInput: () => UnassignActionInput,
218
219
  UserAuditRecordInput: () => UserAuditRecordInput,
219
220
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
@@ -312,6 +313,7 @@ __export(events_exports, {
312
313
  getActionAnnotation: () => getActionAnnotation,
313
314
  getActionAnnotationFields: () => getActionAnnotationFields,
314
315
  getActionConfig: () => getActionConfig,
316
+ getActionFormFields: () => getActionFormFields,
315
317
  getActionReview: () => getActionReview,
316
318
  getActionReviewFields: () => getActionReviewFields,
317
319
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -481,6 +483,7 @@ var RecordScopeTypeV2 = z2.enum([
481
483
  "record.edit",
482
484
  "record.reject",
483
485
  "record.archive",
486
+ "record.unarchive",
484
487
  "record.review-duplicates",
485
488
  "record.register",
486
489
  "record.print-certified-copies",
@@ -586,6 +589,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
586
589
  "record.edit",
587
590
  "record.reject",
588
591
  "record.archive",
592
+ "record.unarchive",
589
593
  "record.review-duplicates",
590
594
  "record.register"
591
595
  ]);
@@ -772,6 +776,7 @@ var ActionType = {
772
776
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
773
777
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
774
778
  ARCHIVE: "ARCHIVE",
779
+ UNARCHIVE: "UNARCHIVE",
775
780
  // Record actions
776
781
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
777
782
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -791,6 +796,7 @@ var ConfirmableActions = [
791
796
  ActionType.REGISTER,
792
797
  ActionType.REJECT,
793
798
  ActionType.ARCHIVE,
799
+ ActionType.UNARCHIVE,
794
800
  ActionType.PRINT_CERTIFICATE,
795
801
  ActionType.REQUEST_CORRECTION,
796
802
  ActionType.APPROVE_CORRECTION,
@@ -809,6 +815,7 @@ var ActionTypes = z4.enum([
809
815
  "MARK_AS_DUPLICATE",
810
816
  "MARK_AS_NOT_DUPLICATE",
811
817
  "ARCHIVE",
818
+ "UNARCHIVE",
812
819
  "PRINT_CERTIFICATE",
813
820
  "REQUEST_CORRECTION",
814
821
  "REJECT_CORRECTION",
@@ -852,6 +859,7 @@ var WorkqueueActionType = ActionTypes.extract([
852
859
  ActionType.REJECT,
853
860
  ActionType.MARK_AS_DUPLICATE,
854
861
  ActionType.ARCHIVE,
862
+ ActionType.UNARCHIVE,
855
863
  ActionType.PRINT_CERTIFICATE,
856
864
  ActionType.REQUEST_CORRECTION
857
865
  ]);
@@ -916,6 +924,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
916
924
  "event.actions.unassign.request",
917
925
  "event.actions.read.request",
918
926
  "event.actions.archive.request",
927
+ "event.actions.unarchive.request",
919
928
  "event.actions.reinstate.request",
920
929
  "event.actions.print_certificate.request",
921
930
  "event.actions.correction.request.request",
@@ -1649,6 +1658,11 @@ var ArchiveAction = ActionBase.extend(
1649
1658
  content: ReasonContent
1650
1659
  }).shape
1651
1660
  );
1661
+ var UnarchiveAction = ActionBase.extend(
1662
+ z14.object({
1663
+ type: z14.literal(ActionType.UNARCHIVE)
1664
+ }).shape
1665
+ );
1652
1666
  var CreatedAction = ActionBase.extend(
1653
1667
  z14.object({
1654
1668
  type: z14.literal(ActionType.CREATE)
@@ -1715,6 +1729,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1715
1729
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1716
1730
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1717
1731
  ArchiveAction.meta({ id: "ArchiveAction" }),
1732
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1718
1733
  NotifiedAction.meta({ id: "NotifiedAction" }),
1719
1734
  RegisterAction.meta({ id: "RegisterAction" }),
1720
1735
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -3224,6 +3239,9 @@ var ActionConfigBase = z24.object({
3224
3239
  var DeclarationActionBase = ActionConfigBase.extend({
3225
3240
  deduplication: DeduplicationConfig.optional()
3226
3241
  });
3242
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3243
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3244
+ );
3227
3245
  var ReadActionConfig = ActionConfigBase.extend(
3228
3246
  z24.object({
3229
3247
  type: z24.literal(ActionType.READ),
@@ -3235,7 +3253,54 @@ var ReadActionConfig = ActionConfigBase.extend(
3235
3253
  );
3236
3254
  var NotifyConfig = ActionConfigBase.extend(
3237
3255
  z24.object({
3238
- type: z24.literal(ActionType.NOTIFY)
3256
+ type: z24.literal(ActionType.NOTIFY),
3257
+ form: actionConfirmationForm
3258
+ }).shape
3259
+ );
3260
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
3261
+ z24.object({
3262
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
3263
+ label: z24.never().optional().describe(
3264
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
3265
+ ),
3266
+ supportingCopy: z24.never().optional(),
3267
+ icon: z24.never().optional().describe(
3268
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
3269
+ ),
3270
+ conditionals: z24.never().optional().describe(
3271
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
3272
+ )
3273
+ }).shape
3274
+ );
3275
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
3276
+ z24.object({
3277
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
3278
+ }).shape
3279
+ );
3280
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
3281
+ z24.object({
3282
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
3283
+ }).shape
3284
+ );
3285
+ var AssignConfig = ActionConfigBase.extend(
3286
+ z24.object({
3287
+ type: z24.literal(ActionType.ASSIGN),
3288
+ flags: z24.never().optional().describe(
3289
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3290
+ )
3291
+ }).shape
3292
+ );
3293
+ var UnassignConfig = ActionConfigBase.extend(
3294
+ z24.object({
3295
+ type: z24.literal(ActionType.UNASSIGN),
3296
+ flags: z24.never().optional().describe(
3297
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
3298
+ )
3299
+ }).shape
3300
+ );
3301
+ var DeleteConfig = ActionConfigBase.extend(
3302
+ z24.object({
3303
+ type: z24.literal(ActionType.DELETE)
3239
3304
  }).shape
3240
3305
  );
3241
3306
  var DeclareConfig = DeclarationActionBase.extend(
@@ -3244,6 +3309,7 @@ var DeclareConfig = DeclarationActionBase.extend(
3244
3309
  review: DeclarationReviewConfig.describe(
3245
3310
  "Configuration of the review page fields."
3246
3311
  ),
3312
+ form: actionConfirmationForm,
3247
3313
  dialogCopy: z24.object({
3248
3314
  notify: TranslationConfig.describe(
3249
3315
  "Confirmation text for the notify action"
@@ -3259,7 +3325,13 @@ var DeclareConfig = DeclarationActionBase.extend(
3259
3325
  );
3260
3326
  var ArchiveConfig = ActionConfigBase.extend(
3261
3327
  z24.object({
3262
- type: z24.literal(ActionType.ARCHIVE)
3328
+ type: z24.literal(ActionType.ARCHIVE),
3329
+ form: actionConfirmationForm
3330
+ }).shape
3331
+ );
3332
+ var UnarchiveConfig = ActionConfigBase.extend(
3333
+ z24.object({
3334
+ type: z24.literal(ActionType.UNARCHIVE)
3263
3335
  }).shape
3264
3336
  );
3265
3337
  var EditActionConfig = ActionConfigBase.extend(
@@ -3280,12 +3352,14 @@ var EditActionConfig = ActionConfigBase.extend(
3280
3352
  );
3281
3353
  var RejectConfig = ActionConfigBase.extend(
3282
3354
  z24.object({
3283
- type: z24.literal(ActionType.REJECT)
3355
+ type: z24.literal(ActionType.REJECT),
3356
+ form: actionConfirmationForm
3284
3357
  }).shape
3285
3358
  );
3286
3359
  var RegisterConfig = DeclarationActionBase.extend(
3287
3360
  z24.object({
3288
- type: z24.literal(ActionType.REGISTER)
3361
+ type: z24.literal(ActionType.REGISTER),
3362
+ form: actionConfirmationForm
3289
3363
  }).shape
3290
3364
  );
3291
3365
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3300,7 +3374,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3300
3374
  correctionForm: ActionFormConfig
3301
3375
  }).shape
3302
3376
  );
3303
- var CustomActionConfig = ActionConfigBase.merge(
3377
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
3378
+ z24.object({
3379
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
3380
+ }).shape
3381
+ );
3382
+ var RejectCorrectionConfig = ActionConfigBase.extend(
3383
+ z24.object({
3384
+ type: z24.literal(ActionType.REJECT_CORRECTION)
3385
+ }).shape
3386
+ );
3387
+ var CustomActionConfig = ActionConfigBase.extend(
3304
3388
  z24.object({
3305
3389
  type: z24.literal(ActionType.CUSTOM),
3306
3390
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3311,7 +3395,7 @@ var CustomActionConfig = ActionConfigBase.merge(
3311
3395
  auditHistoryLabel: TranslationConfig.describe(
3312
3396
  'The label to show in audit history for this action. For example "Approved".'
3313
3397
  )
3314
- })
3398
+ }).shape
3315
3399
  );
3316
3400
  var ActionConfig = z24.discriminatedUnion("type", [
3317
3401
  /*
@@ -3322,6 +3406,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
3322
3406
  id: "ReadActionConfig",
3323
3407
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3324
3408
  }),
3409
+ AssignConfig.meta({
3410
+ id: "AssignActionConfig",
3411
+ description: "Configuration for assigning a record to the current user."
3412
+ }),
3413
+ UnassignConfig.meta({
3414
+ id: "UnassignActionConfig",
3415
+ description: "Configuration for unassigning a record from its current assignee."
3416
+ }),
3417
+ DeleteConfig.meta({
3418
+ id: "DeleteActionConfig",
3419
+ description: "Configuration for deleting a draft record."
3420
+ }),
3325
3421
  NotifyConfig.meta({
3326
3422
  id: "NotifyActionConfig",
3327
3423
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -3330,6 +3426,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
3330
3426
  id: "DeclareActionConfig",
3331
3427
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3332
3428
  }),
3429
+ DuplicateDetectedConfig.meta({
3430
+ id: "DuplicateDetectedActionConfig",
3431
+ description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3432
+ }),
3433
+ MarkAsDuplicateConfig.meta({
3434
+ id: "MarkAsDuplicateActionConfig",
3435
+ description: "Configuration for marking a record as a duplicate."
3436
+ }),
3437
+ MarkAsNotDuplicateConfig.meta({
3438
+ id: "MarkAsNotDuplicateActionConfig",
3439
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
3440
+ }),
3333
3441
  RejectConfig.meta({
3334
3442
  id: "RejectActionConfig",
3335
3443
  description: "Configuration for rejecting a record before registration."
@@ -3346,6 +3454,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
3346
3454
  id: "RequestCorrectionActionConfig",
3347
3455
  description: "Configuration for requesting a correction on a registered record."
3348
3456
  }),
3457
+ ApproveCorrectionConfig.meta({
3458
+ id: "ApproveCorrectionActionConfig",
3459
+ description: "Configuration for approving a requested correction."
3460
+ }),
3461
+ RejectCorrectionConfig.meta({
3462
+ id: "RejectCorrectionActionConfig",
3463
+ description: "Configuration for rejecting a requested correction."
3464
+ }),
3349
3465
  EditActionConfig.meta({
3350
3466
  id: "EditActionConfig",
3351
3467
  description: "Configuration for editing a record before registration."
@@ -3354,6 +3470,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
3354
3470
  id: "ArchiveActionConfig",
3355
3471
  description: "Configuration for archiving a record."
3356
3472
  }),
3473
+ UnarchiveConfig.meta({
3474
+ id: "UnarchiveActionConfig",
3475
+ description: "Configuration for unarchiving a record."
3476
+ }),
3357
3477
  CustomActionConfig.meta({
3358
3478
  id: "CustomActionConfig",
3359
3479
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4504,9 +4624,6 @@ function getActionConfig({
4504
4624
  if (a.type === ActionType.CUSTOM && customActionType) {
4505
4625
  return a.customActionType === customActionType;
4506
4626
  }
4507
- if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4508
- return a.type === ActionType.REQUEST_CORRECTION;
4509
- }
4510
4627
  return a.type === actionType;
4511
4628
  });
4512
4629
  }
@@ -4516,7 +4633,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4516
4633
  customActionType,
4517
4634
  actionType: ActionType.CUSTOM
4518
4635
  });
4519
- if (!actionConfig || !("form" in actionConfig)) {
4636
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4637
+ return [];
4638
+ }
4639
+ return actionConfig.form;
4640
+ }
4641
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4642
+ const actionConfig = eventConfiguration.actions.find((a) => {
4643
+ if (a.type === ActionType.CUSTOM && customActionType) {
4644
+ return a.customActionType === customActionType;
4645
+ }
4646
+ return a.type === actionType;
4647
+ });
4648
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4520
4649
  return [];
4521
4650
  }
4522
4651
  return actionConfig.form;
@@ -4537,13 +4666,9 @@ var getActionAnnotationFields = (actionConfig) => {
4537
4666
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4538
4667
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4539
4668
  }
4540
- if (actionConfig.type === ActionType.CUSTOM) {
4541
- return actionConfig.form;
4542
- }
4543
- if ("review" in actionConfig && actionConfig.review != null) {
4544
- return actionConfig.review.fields;
4545
- }
4546
- return [];
4669
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4670
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4671
+ return [...reviewFields, ...formFields];
4547
4672
  };
4548
4673
  function getAllAnnotationFields(config) {
4549
4674
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -5660,7 +5785,7 @@ function validateActionFlags(event2, ctx) {
5660
5785
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5661
5786
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5662
5787
  const actionFlagIds = event2.actions.flatMap(
5663
- (action) => action.flags.map((flag2) => flag2.id)
5788
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
5664
5789
  );
5665
5790
  for (const actionFlagId of actionFlagIds) {
5666
5791
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -6335,6 +6460,11 @@ var ArchiveActionInput = BaseActionInput.extend(
6335
6460
  content: ReasonContent
6336
6461
  }).shape
6337
6462
  );
6463
+ var UnarchiveActionInput = BaseActionInput.extend(
6464
+ z38.object({
6465
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
6466
+ }).shape
6467
+ );
6338
6468
  var AssignActionInput = BaseActionInput.extend(
6339
6469
  z38.object({
6340
6470
  type: z38.literal(ActionType.ASSIGN),
@@ -6396,6 +6526,7 @@ var ActionInput = z38.discriminatedUnion("type", [
6396
6526
  id: "MarkNotDuplicateActionInput"
6397
6527
  }),
6398
6528
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
6529
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
6399
6530
  AssignActionInput.meta({ id: "AssignActionInput" }),
6400
6531
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
6401
6532
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -6510,6 +6641,7 @@ var updateActions = ActionTypes.extract([
6510
6641
  ActionType.REGISTER,
6511
6642
  ActionType.REJECT,
6512
6643
  ActionType.ARCHIVE,
6644
+ ActionType.UNARCHIVE,
6513
6645
  ActionType.PRINT_CERTIFICATE,
6514
6646
  ActionType.REQUEST_CORRECTION,
6515
6647
  ActionType.APPROVE_CORRECTION,
@@ -6631,15 +6763,12 @@ var INHERENT_FLAG_RULES = [
6631
6763
  },
6632
6764
  {
6633
6765
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6634
- // other status-changing action (see getStatusFromActions).
6766
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
6767
+ // are deliberately excluded so the flag freezes across an archive/unarchive
6768
+ // round trip and comes back exactly as it was.
6635
6769
  flag: InherentFlags.INCOMPLETE,
6636
6770
  setOn: [ActionType.NOTIFY],
6637
- resetOn: [
6638
- ActionType.CREATE,
6639
- ActionType.DECLARE,
6640
- ActionType.REGISTER,
6641
- ActionType.ARCHIVE
6642
- ]
6771
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
6643
6772
  },
6644
6773
  {
6645
6774
  flag: InherentFlags.REJECTED,
@@ -6703,7 +6832,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6703
6832
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6704
6833
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6705
6834
  const form = { ...declaration, ...annotation };
6706
- const flagsWithMetConditions = actionConfig.flags.filter(
6835
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6707
6836
  ({ conditional }) => (
6708
6837
  // If conditional is not provided, the flag is resolved
6709
6838
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -6749,7 +6878,27 @@ function getEventFlags(event2, config) {
6749
6878
 
6750
6879
  // ../commons/src/events/state/index.ts
6751
6880
  function getStatusFromActions(actions) {
6752
- return actions.filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce((status2, action) => {
6881
+ const acceptedActions = actions.filter(
6882
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6883
+ );
6884
+ const isCurrentlyArchived = acceptedActions.reduce(
6885
+ (archived, action) => {
6886
+ if (action.type === ActionType.ARCHIVE) {
6887
+ return true;
6888
+ }
6889
+ if (action.type === ActionType.UNARCHIVE) {
6890
+ return false;
6891
+ }
6892
+ return archived;
6893
+ },
6894
+ false
6895
+ );
6896
+ if (isCurrentlyArchived) {
6897
+ return EventStatus.enum.ARCHIVED;
6898
+ }
6899
+ return acceptedActions.filter(
6900
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
6901
+ ).reduce((status2, action) => {
6753
6902
  switch (action.type) {
6754
6903
  case ActionType.CREATE:
6755
6904
  return EventStatus.enum.CREATED;
@@ -6757,10 +6906,11 @@ function getStatusFromActions(actions) {
6757
6906
  return EventStatus.enum.DECLARED;
6758
6907
  case ActionType.REGISTER:
6759
6908
  return EventStatus.enum.REGISTERED;
6760
- case ActionType.ARCHIVE:
6761
- return EventStatus.enum.ARCHIVED;
6762
6909
  case ActionType.NOTIFY:
6763
6910
  return EventStatus.enum.NOTIFIED;
6911
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
6912
+ case ActionType.ARCHIVE:
6913
+ case ActionType.UNARCHIVE:
6764
6914
  case ActionType.CUSTOM:
6765
6915
  case ActionType.PRINT_CERTIFICATE:
6766
6916
  case ActionType.ASSIGN:
@@ -9845,6 +9995,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9845
9995
  },
9846
9996
  ...input
9847
9997
  }),
9998
+ unarchive: (eventId, input = {}) => ({
9999
+ type: ActionType.UNARCHIVE,
10000
+ transactionId: input.transactionId ?? getUUID(),
10001
+ declaration: {},
10002
+ annotation: {},
10003
+ eventId,
10004
+ ...input
10005
+ }),
9848
10006
  reject: (eventId, input = {}) => ({
9849
10007
  type: ActionType.REJECT,
9850
10008
  transactionId: input.transactionId ?? getUUID(),
@@ -10003,6 +10161,7 @@ function generateActionDocument({
10003
10161
  case ActionType.NOTIFY:
10004
10162
  case ActionType.REGISTER:
10005
10163
  case ActionType.REQUEST_CORRECTION:
10164
+ case ActionType.UNARCHIVE:
10006
10165
  return { ...actionBase, type: action };
10007
10166
  case ActionType.EDIT:
10008
10167
  return {
@@ -10521,6 +10680,7 @@ var ACTION_SCOPE_MAP = {
10521
10680
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
10522
10681
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
10523
10682
  [ActionType.ARCHIVE]: ["record.archive"],
10683
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
10524
10684
  [ActionType.REJECT]: ["record.reject"],
10525
10685
  [ActionType.ASSIGN]: null,
10526
10686
  [ActionType.UNASSIGN]: null,
@@ -10727,7 +10887,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
10727
10887
  ActionType.CUSTOM,
10728
10888
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
10729
10889
  ],
10730
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
10890
+ [EventStatus.enum.ARCHIVED]: [
10891
+ ActionType.READ,
10892
+ ActionType.CUSTOM,
10893
+ ActionType.UNARCHIVE
10894
+ ]
10731
10895
  };
10732
10896
  var ACTION_FILTERS = {
10733
10897
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -10740,6 +10904,7 @@ var ACTION_FILTERS = {
10740
10904
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
10741
10905
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
10742
10906
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10907
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10743
10908
  [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10744
10909
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10745
10910
  [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
@@ -25,13 +25,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
25
25
  }) : function(o, v) {
26
26
  o["default"] = v;
27
27
  });
28
- var __importStar = (this && this.__importStar) || function (mod) {
29
- if (mod && mod.__esModule) return mod;
30
- var result = {};
31
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
32
- __setModuleDefault(result, mod);
33
- return result;
34
- };
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
35
45
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
46
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
47
  return new (P || (P = Promise))(function (resolve, reject) {