@opencrvs/toolkit 2.1.0-rc.e773220 → 2.1.0-rc.e8dd933

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 (42) hide show
  1. package/dist/application-config/index.js +14 -1
  2. package/dist/cli.js +0 -48
  3. package/dist/commons/api/router.d.ts +758 -201
  4. package/dist/commons/conditionals/conditionals.d.ts +1589 -37
  5. package/dist/commons/events/ActionConfig.d.ts +33 -0
  6. package/dist/commons/events/ActionDocument.d.ts +50 -6
  7. package/dist/commons/events/ActionInput.d.ts +26 -6
  8. package/dist/commons/events/ActionType.d.ts +6 -1
  9. package/dist/commons/events/AdvancedSearchConfig.d.ts +6 -0
  10. package/dist/commons/events/AuditLog.d.ts +2 -0
  11. package/dist/commons/events/Draft.d.ts +2 -0
  12. package/dist/commons/events/EventDocument.d.ts +24 -2
  13. package/dist/commons/events/FieldConfig.d.ts +5 -0
  14. package/dist/commons/events/WorkqueueConfig.d.ts +5 -2
  15. package/dist/commons/events/field.d.ts +722 -34
  16. package/dist/commons/events/scopes.d.ts +1 -0
  17. package/dist/commons/events/test.utils.d.ts +9 -4
  18. package/dist/commons/events/utils.d.ts +26 -4
  19. package/dist/conditionals/index.js +2 -0
  20. package/dist/environment/derived-variables.d.ts +0 -12
  21. package/dist/environment/derived-variables.d.ts.map +1 -1
  22. package/dist/environment/derived-variables.js +0 -14
  23. package/dist/environment/logger.d.ts +3 -12
  24. package/dist/environment/logger.d.ts.map +1 -1
  25. package/dist/environment/manage-users.js +17 -7
  26. package/dist/environment/setup-environment.js +0 -14
  27. package/dist/environment/swarm-to-k8s.js +17 -7
  28. package/dist/environment/update-workflows.js +17 -7
  29. package/dist/environment/users.js +17 -7
  30. package/dist/environment/utils.js +17 -7
  31. package/dist/events/index.js +106 -29
  32. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  33. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  34. package/dist/notification/index.js +58 -24
  35. package/dist/scopes/index.d.ts +7 -1
  36. package/dist/scopes/index.js +2 -0
  37. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  38. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  39. package/opencrvs-toolkit-2.1.0-rc.e8dd933.tgz +0 -0
  40. package/package.json +3 -3
  41. package/tsconfig.tsbuildinfo +1 -1
  42. package/opencrvs-toolkit-2.1.0-rc.e773220.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)
@@ -1662,9 +1676,10 @@ var NotifiedAction = ActionBase.extend(
1662
1676
  var EditAction = ActionBase.extend(
1663
1677
  z14.object({
1664
1678
  type: z14.literal(ActionType.EDIT),
1679
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1665
1680
  content: z14.object({
1666
1681
  comment: z14.string().describe("Comment for the edit action.").optional()
1667
- })
1682
+ }).optional()
1668
1683
  }).shape
1669
1684
  );
1670
1685
  var PrintContent = z14.object({
@@ -1715,6 +1730,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1715
1730
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1716
1731
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1717
1732
  ArchiveAction.meta({ id: "ArchiveAction" }),
1733
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1718
1734
  NotifiedAction.meta({ id: "NotifiedAction" }),
1719
1735
  RegisterAction.meta({ id: "RegisterAction" }),
1720
1736
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -3224,6 +3240,9 @@ var ActionConfigBase = z24.object({
3224
3240
  var DeclarationActionBase = ActionConfigBase.extend({
3225
3241
  deduplication: DeduplicationConfig.optional()
3226
3242
  });
3243
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3244
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3245
+ );
3227
3246
  var ReadActionConfig = ActionConfigBase.extend(
3228
3247
  z24.object({
3229
3248
  type: z24.literal(ActionType.READ),
@@ -3235,7 +3254,8 @@ var ReadActionConfig = ActionConfigBase.extend(
3235
3254
  );
3236
3255
  var NotifyConfig = ActionConfigBase.extend(
3237
3256
  z24.object({
3238
- type: z24.literal(ActionType.NOTIFY)
3257
+ type: z24.literal(ActionType.NOTIFY),
3258
+ form: actionConfirmationForm
3239
3259
  }).shape
3240
3260
  );
3241
3261
  var DuplicateDetectedConfig = ActionConfigBase.extend(
@@ -3290,6 +3310,7 @@ var DeclareConfig = DeclarationActionBase.extend(
3290
3310
  review: DeclarationReviewConfig.describe(
3291
3311
  "Configuration of the review page fields."
3292
3312
  ),
3313
+ form: actionConfirmationForm,
3293
3314
  dialogCopy: z24.object({
3294
3315
  notify: TranslationConfig.describe(
3295
3316
  "Confirmation text for the notify action"
@@ -3305,7 +3326,13 @@ var DeclareConfig = DeclarationActionBase.extend(
3305
3326
  );
3306
3327
  var ArchiveConfig = ActionConfigBase.extend(
3307
3328
  z24.object({
3308
- type: z24.literal(ActionType.ARCHIVE)
3329
+ type: z24.literal(ActionType.ARCHIVE),
3330
+ form: actionConfirmationForm
3331
+ }).shape
3332
+ );
3333
+ var UnarchiveConfig = ActionConfigBase.extend(
3334
+ z24.object({
3335
+ type: z24.literal(ActionType.UNARCHIVE)
3309
3336
  }).shape
3310
3337
  );
3311
3338
  var EditActionConfig = ActionConfigBase.extend(
@@ -3326,12 +3353,14 @@ var EditActionConfig = ActionConfigBase.extend(
3326
3353
  );
3327
3354
  var RejectConfig = ActionConfigBase.extend(
3328
3355
  z24.object({
3329
- type: z24.literal(ActionType.REJECT)
3356
+ type: z24.literal(ActionType.REJECT),
3357
+ form: actionConfirmationForm
3330
3358
  }).shape
3331
3359
  );
3332
3360
  var RegisterConfig = DeclarationActionBase.extend(
3333
3361
  z24.object({
3334
- type: z24.literal(ActionType.REGISTER)
3362
+ type: z24.literal(ActionType.REGISTER),
3363
+ form: actionConfirmationForm
3335
3364
  }).shape
3336
3365
  );
3337
3366
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3442,6 +3471,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
3442
3471
  id: "ArchiveActionConfig",
3443
3472
  description: "Configuration for archiving a record."
3444
3473
  }),
3474
+ UnarchiveConfig.meta({
3475
+ id: "UnarchiveActionConfig",
3476
+ description: "Configuration for unarchiving a record."
3477
+ }),
3445
3478
  CustomActionConfig.meta({
3446
3479
  id: "CustomActionConfig",
3447
3480
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4601,7 +4634,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4601
4634
  customActionType,
4602
4635
  actionType: ActionType.CUSTOM
4603
4636
  });
4604
- if (!actionConfig || !("form" in actionConfig)) {
4637
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4638
+ return [];
4639
+ }
4640
+ return actionConfig.form;
4641
+ }
4642
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4643
+ const actionConfig = eventConfiguration.actions.find((a) => {
4644
+ if (a.type === ActionType.CUSTOM && customActionType) {
4645
+ return a.customActionType === customActionType;
4646
+ }
4647
+ return a.type === actionType;
4648
+ });
4649
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4605
4650
  return [];
4606
4651
  }
4607
4652
  return actionConfig.form;
@@ -4622,13 +4667,9 @@ var getActionAnnotationFields = (actionConfig) => {
4622
4667
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4623
4668
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4624
4669
  }
4625
- if (actionConfig.type === ActionType.CUSTOM) {
4626
- return actionConfig.form;
4627
- }
4628
- if ("review" in actionConfig && actionConfig.review != null) {
4629
- return actionConfig.review.fields;
4630
- }
4631
- return [];
4670
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4671
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4672
+ return [...reviewFields, ...formFields];
4632
4673
  };
4633
4674
  function getAllAnnotationFields(config) {
4634
4675
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -6375,10 +6416,7 @@ var DeclareActionInput = BaseActionInput.extend(
6375
6416
  );
6376
6417
  var EditActionInput = BaseActionInput.extend(
6377
6418
  z38.object({
6378
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
6379
- content: z38.object({
6380
- comment: z38.string().describe("Comment for the edit action.").optional()
6381
- })
6419
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
6382
6420
  }).shape
6383
6421
  );
6384
6422
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -6420,6 +6458,11 @@ var ArchiveActionInput = BaseActionInput.extend(
6420
6458
  content: ReasonContent
6421
6459
  }).shape
6422
6460
  );
6461
+ var UnarchiveActionInput = BaseActionInput.extend(
6462
+ z38.object({
6463
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
6464
+ }).shape
6465
+ );
6423
6466
  var AssignActionInput = BaseActionInput.extend(
6424
6467
  z38.object({
6425
6468
  type: z38.literal(ActionType.ASSIGN),
@@ -6481,6 +6524,7 @@ var ActionInput = z38.discriminatedUnion("type", [
6481
6524
  id: "MarkNotDuplicateActionInput"
6482
6525
  }),
6483
6526
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
6527
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
6484
6528
  AssignActionInput.meta({ id: "AssignActionInput" }),
6485
6529
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
6486
6530
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -6595,6 +6639,7 @@ var updateActions = ActionTypes.extract([
6595
6639
  ActionType.REGISTER,
6596
6640
  ActionType.REJECT,
6597
6641
  ActionType.ARCHIVE,
6642
+ ActionType.UNARCHIVE,
6598
6643
  ActionType.PRINT_CERTIFICATE,
6599
6644
  ActionType.REQUEST_CORRECTION,
6600
6645
  ActionType.APPROVE_CORRECTION,
@@ -6716,15 +6761,12 @@ var INHERENT_FLAG_RULES = [
6716
6761
  },
6717
6762
  {
6718
6763
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6719
- // other status-changing action (see getStatusFromActions).
6764
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
6765
+ // are deliberately excluded so the flag freezes across an archive/unarchive
6766
+ // round trip and comes back exactly as it was.
6720
6767
  flag: InherentFlags.INCOMPLETE,
6721
6768
  setOn: [ActionType.NOTIFY],
6722
- resetOn: [
6723
- ActionType.CREATE,
6724
- ActionType.DECLARE,
6725
- ActionType.REGISTER,
6726
- ActionType.ARCHIVE
6727
- ]
6769
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
6728
6770
  },
6729
6771
  {
6730
6772
  flag: InherentFlags.REJECTED,
@@ -6834,7 +6876,27 @@ function getEventFlags(event2, config) {
6834
6876
 
6835
6877
  // ../commons/src/events/state/index.ts
6836
6878
  function getStatusFromActions(actions) {
6837
- return actions.filter(({ status: status2 }) => status2 === ActionStatus.Accepted).reduce((status2, action) => {
6879
+ const acceptedActions = actions.filter(
6880
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
6881
+ );
6882
+ const isCurrentlyArchived = acceptedActions.reduce(
6883
+ (archived, action) => {
6884
+ if (action.type === ActionType.ARCHIVE) {
6885
+ return true;
6886
+ }
6887
+ if (action.type === ActionType.UNARCHIVE) {
6888
+ return false;
6889
+ }
6890
+ return archived;
6891
+ },
6892
+ false
6893
+ );
6894
+ if (isCurrentlyArchived) {
6895
+ return EventStatus.enum.ARCHIVED;
6896
+ }
6897
+ return acceptedActions.filter(
6898
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
6899
+ ).reduce((status2, action) => {
6838
6900
  switch (action.type) {
6839
6901
  case ActionType.CREATE:
6840
6902
  return EventStatus.enum.CREATED;
@@ -6842,10 +6904,11 @@ function getStatusFromActions(actions) {
6842
6904
  return EventStatus.enum.DECLARED;
6843
6905
  case ActionType.REGISTER:
6844
6906
  return EventStatus.enum.REGISTERED;
6845
- case ActionType.ARCHIVE:
6846
- return EventStatus.enum.ARCHIVED;
6847
6907
  case ActionType.NOTIFY:
6848
6908
  return EventStatus.enum.NOTIFIED;
6909
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
6910
+ case ActionType.ARCHIVE:
6911
+ case ActionType.UNARCHIVE:
6849
6912
  case ActionType.CUSTOM:
6850
6913
  case ActionType.PRINT_CERTIFICATE:
6851
6914
  case ActionType.ASSIGN:
@@ -9898,7 +9961,6 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9898
9961
  },
9899
9962
  edit: (eventId, input = {}) => ({
9900
9963
  type: ActionType.EDIT,
9901
- content: { comment: "Test comment" },
9902
9964
  transactionId: input.transactionId ?? getUUID(),
9903
9965
  declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
9904
9966
  annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
@@ -9930,6 +9992,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9930
9992
  },
9931
9993
  ...input
9932
9994
  }),
9995
+ unarchive: (eventId, input = {}) => ({
9996
+ type: ActionType.UNARCHIVE,
9997
+ transactionId: input.transactionId ?? getUUID(),
9998
+ declaration: {},
9999
+ annotation: {},
10000
+ eventId,
10001
+ ...input
10002
+ }),
9933
10003
  reject: (eventId, input = {}) => ({
9934
10004
  type: ActionType.REJECT,
9935
10005
  transactionId: input.transactionId ?? getUUID(),
@@ -10088,6 +10158,7 @@ function generateActionDocument({
10088
10158
  case ActionType.NOTIFY:
10089
10159
  case ActionType.REGISTER:
10090
10160
  case ActionType.REQUEST_CORRECTION:
10161
+ case ActionType.UNARCHIVE:
10091
10162
  return { ...actionBase, type: action };
10092
10163
  case ActionType.EDIT:
10093
10164
  return {
@@ -10606,6 +10677,7 @@ var ACTION_SCOPE_MAP = {
10606
10677
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
10607
10678
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
10608
10679
  [ActionType.ARCHIVE]: ["record.archive"],
10680
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
10609
10681
  [ActionType.REJECT]: ["record.reject"],
10610
10682
  [ActionType.ASSIGN]: null,
10611
10683
  [ActionType.UNASSIGN]: null,
@@ -10812,7 +10884,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
10812
10884
  ActionType.CUSTOM,
10813
10885
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
10814
10886
  ],
10815
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
10887
+ [EventStatus.enum.ARCHIVED]: [
10888
+ ActionType.READ,
10889
+ ActionType.CUSTOM,
10890
+ ActionType.UNARCHIVE
10891
+ ]
10816
10892
  };
10817
10893
  var ACTION_FILTERS = {
10818
10894
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -10825,6 +10901,7 @@ var ACTION_FILTERS = {
10825
10901
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
10826
10902
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
10827
10903
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10904
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10828
10905
  [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10829
10906
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10830
10907
  [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) {
@@ -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) {
@@ -79,6 +79,7 @@ var RecordScopeTypeV2 = z2.enum([
79
79
  "record.edit",
80
80
  "record.reject",
81
81
  "record.archive",
82
+ "record.unarchive",
82
83
  "record.review-duplicates",
83
84
  "record.register",
84
85
  "record.print-certified-copies",
@@ -184,6 +185,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
184
185
  "record.edit",
185
186
  "record.reject",
186
187
  "record.archive",
188
+ "record.unarchive",
187
189
  "record.review-duplicates",
188
190
  "record.register"
189
191
  ]);
@@ -325,6 +327,7 @@ var ActionType = {
325
327
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
326
328
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
327
329
  ARCHIVE: "ARCHIVE",
330
+ UNARCHIVE: "UNARCHIVE",
328
331
  // Record actions
329
332
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
330
333
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -344,6 +347,7 @@ var ConfirmableActions = [
344
347
  ActionType.REGISTER,
345
348
  ActionType.REJECT,
346
349
  ActionType.ARCHIVE,
350
+ ActionType.UNARCHIVE,
347
351
  ActionType.PRINT_CERTIFICATE,
348
352
  ActionType.REQUEST_CORRECTION,
349
353
  ActionType.APPROVE_CORRECTION,
@@ -362,6 +366,7 @@ var ActionTypes = z4.enum([
362
366
  "MARK_AS_DUPLICATE",
363
367
  "MARK_AS_NOT_DUPLICATE",
364
368
  "ARCHIVE",
369
+ "UNARCHIVE",
365
370
  "PRINT_CERTIFICATE",
366
371
  "REQUEST_CORRECTION",
367
372
  "REJECT_CORRECTION",
@@ -405,6 +410,7 @@ var WorkqueueActionType = ActionTypes.extract([
405
410
  ActionType.REJECT,
406
411
  ActionType.MARK_AS_DUPLICATE,
407
412
  ActionType.ARCHIVE,
413
+ ActionType.UNARCHIVE,
408
414
  ActionType.PRINT_CERTIFICATE,
409
415
  ActionType.REQUEST_CORRECTION
410
416
  ]);
@@ -466,6 +472,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
466
472
  "event.actions.unassign.request",
467
473
  "event.actions.read.request",
468
474
  "event.actions.archive.request",
475
+ "event.actions.unarchive.request",
469
476
  "event.actions.reinstate.request",
470
477
  "event.actions.print_certificate.request",
471
478
  "event.actions.correction.request.request",
@@ -1191,6 +1198,11 @@ var ArchiveAction = ActionBase.extend(
1191
1198
  content: ReasonContent
1192
1199
  }).shape
1193
1200
  );
1201
+ var UnarchiveAction = ActionBase.extend(
1202
+ z14.object({
1203
+ type: z14.literal(ActionType.UNARCHIVE)
1204
+ }).shape
1205
+ );
1194
1206
  var CreatedAction = ActionBase.extend(
1195
1207
  z14.object({
1196
1208
  type: z14.literal(ActionType.CREATE)
@@ -1204,9 +1216,10 @@ var NotifiedAction = ActionBase.extend(
1204
1216
  var EditAction = ActionBase.extend(
1205
1217
  z14.object({
1206
1218
  type: z14.literal(ActionType.EDIT),
1219
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1207
1220
  content: z14.object({
1208
1221
  comment: z14.string().describe("Comment for the edit action.").optional()
1209
- })
1222
+ }).optional()
1210
1223
  }).shape
1211
1224
  );
1212
1225
  var PrintContent = z14.object({
@@ -1257,6 +1270,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1257
1270
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1258
1271
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1259
1272
  ArchiveAction.meta({ id: "ArchiveAction" }),
1273
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1260
1274
  NotifiedAction.meta({ id: "NotifiedAction" }),
1261
1275
  RegisterAction.meta({ id: "RegisterAction" }),
1262
1276
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -2681,6 +2695,9 @@ var ActionConfigBase = z24.object({
2681
2695
  var DeclarationActionBase = ActionConfigBase.extend({
2682
2696
  deduplication: DeduplicationConfig.optional()
2683
2697
  });
2698
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2699
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2700
+ );
2684
2701
  var ReadActionConfig = ActionConfigBase.extend(
2685
2702
  z24.object({
2686
2703
  type: z24.literal(ActionType.READ),
@@ -2692,7 +2709,8 @@ var ReadActionConfig = ActionConfigBase.extend(
2692
2709
  );
2693
2710
  var NotifyConfig = ActionConfigBase.extend(
2694
2711
  z24.object({
2695
- type: z24.literal(ActionType.NOTIFY)
2712
+ type: z24.literal(ActionType.NOTIFY),
2713
+ form: actionConfirmationForm
2696
2714
  }).shape
2697
2715
  );
2698
2716
  var DuplicateDetectedConfig = ActionConfigBase.extend(
@@ -2747,6 +2765,7 @@ var DeclareConfig = DeclarationActionBase.extend(
2747
2765
  review: DeclarationReviewConfig.describe(
2748
2766
  "Configuration of the review page fields."
2749
2767
  ),
2768
+ form: actionConfirmationForm,
2750
2769
  dialogCopy: z24.object({
2751
2770
  notify: TranslationConfig.describe(
2752
2771
  "Confirmation text for the notify action"
@@ -2762,7 +2781,13 @@ var DeclareConfig = DeclarationActionBase.extend(
2762
2781
  );
2763
2782
  var ArchiveConfig = ActionConfigBase.extend(
2764
2783
  z24.object({
2765
- type: z24.literal(ActionType.ARCHIVE)
2784
+ type: z24.literal(ActionType.ARCHIVE),
2785
+ form: actionConfirmationForm
2786
+ }).shape
2787
+ );
2788
+ var UnarchiveConfig = ActionConfigBase.extend(
2789
+ z24.object({
2790
+ type: z24.literal(ActionType.UNARCHIVE)
2766
2791
  }).shape
2767
2792
  );
2768
2793
  var EditActionConfig = ActionConfigBase.extend(
@@ -2783,12 +2808,14 @@ var EditActionConfig = ActionConfigBase.extend(
2783
2808
  );
2784
2809
  var RejectConfig = ActionConfigBase.extend(
2785
2810
  z24.object({
2786
- type: z24.literal(ActionType.REJECT)
2811
+ type: z24.literal(ActionType.REJECT),
2812
+ form: actionConfirmationForm
2787
2813
  }).shape
2788
2814
  );
2789
2815
  var RegisterConfig = DeclarationActionBase.extend(
2790
2816
  z24.object({
2791
- type: z24.literal(ActionType.REGISTER)
2817
+ type: z24.literal(ActionType.REGISTER),
2818
+ form: actionConfirmationForm
2792
2819
  }).shape
2793
2820
  );
2794
2821
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -2899,6 +2926,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2899
2926
  id: "ArchiveActionConfig",
2900
2927
  description: "Configuration for archiving a record."
2901
2928
  }),
2929
+ UnarchiveConfig.meta({
2930
+ id: "UnarchiveActionConfig",
2931
+ description: "Configuration for unarchiving a record."
2932
+ }),
2902
2933
  CustomActionConfig.meta({
2903
2934
  id: "CustomActionConfig",
2904
2935
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -3304,13 +3335,9 @@ var getActionAnnotationFields = (actionConfig) => {
3304
3335
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3305
3336
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3306
3337
  }
3307
- if (actionConfig.type === ActionType.CUSTOM) {
3308
- return actionConfig.form;
3309
- }
3310
- if ("review" in actionConfig && actionConfig.review != null) {
3311
- return actionConfig.review.fields;
3312
- }
3313
- return [];
3338
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3339
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3340
+ return [...reviewFields, ...formFields];
3314
3341
  };
3315
3342
  function getAllAnnotationFields(config) {
3316
3343
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -4626,10 +4653,7 @@ var DeclareActionInput = BaseActionInput.extend(
4626
4653
  );
4627
4654
  var EditActionInput = BaseActionInput.extend(
4628
4655
  z38.object({
4629
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4630
- content: z38.object({
4631
- comment: z38.string().describe("Comment for the edit action.").optional()
4632
- })
4656
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4633
4657
  }).shape
4634
4658
  );
4635
4659
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4671,6 +4695,11 @@ var ArchiveActionInput = BaseActionInput.extend(
4671
4695
  content: ReasonContent
4672
4696
  }).shape
4673
4697
  );
4698
+ var UnarchiveActionInput = BaseActionInput.extend(
4699
+ z38.object({
4700
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4701
+ }).shape
4702
+ );
4674
4703
  var AssignActionInput = BaseActionInput.extend(
4675
4704
  z38.object({
4676
4705
  type: z38.literal(ActionType.ASSIGN),
@@ -4732,6 +4761,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4732
4761
  id: "MarkNotDuplicateActionInput"
4733
4762
  }),
4734
4763
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
4764
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4735
4765
  AssignActionInput.meta({ id: "AssignActionInput" }),
4736
4766
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4737
4767
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4809,6 +4839,7 @@ var updateActions = ActionTypes.extract([
4809
4839
  ActionType.REGISTER,
4810
4840
  ActionType.REJECT,
4811
4841
  ActionType.ARCHIVE,
4842
+ ActionType.UNARCHIVE,
4812
4843
  ActionType.PRINT_CERTIFICATE,
4813
4844
  ActionType.REQUEST_CORRECTION,
4814
4845
  ActionType.APPROVE_CORRECTION,
@@ -4827,15 +4858,12 @@ var INHERENT_FLAG_RULES = [
4827
4858
  },
4828
4859
  {
4829
4860
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4830
- // other status-changing action (see getStatusFromActions).
4861
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4862
+ // are deliberately excluded so the flag freezes across an archive/unarchive
4863
+ // round trip and comes back exactly as it was.
4831
4864
  flag: InherentFlags.INCOMPLETE,
4832
4865
  setOn: [ActionType.NOTIFY],
4833
- resetOn: [
4834
- ActionType.CREATE,
4835
- ActionType.DECLARE,
4836
- ActionType.REGISTER,
4837
- ActionType.ARCHIVE
4838
- ]
4866
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4839
4867
  },
4840
4868
  {
4841
4869
  flag: InherentFlags.REJECTED,
@@ -7367,6 +7395,7 @@ var ACTION_SCOPE_MAP = {
7367
7395
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7368
7396
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7369
7397
  [ActionType.ARCHIVE]: ["record.archive"],
7398
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
7370
7399
  [ActionType.REJECT]: ["record.reject"],
7371
7400
  [ActionType.ASSIGN]: null,
7372
7401
  [ActionType.UNASSIGN]: null,
@@ -7409,7 +7438,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7409
7438
  ActionType.CUSTOM,
7410
7439
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7411
7440
  ],
7412
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7441
+ [EventStatus.enum.ARCHIVED]: [
7442
+ ActionType.READ,
7443
+ ActionType.CUSTOM,
7444
+ ActionType.UNARCHIVE
7445
+ ]
7413
7446
  };
7414
7447
  var ACTION_FILTERS = {
7415
7448
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
@@ -7422,6 +7455,7 @@ var ACTION_FILTERS = {
7422
7455
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7423
7456
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7424
7457
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7458
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7425
7459
  [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7426
7460
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7427
7461
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))