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

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 (73) 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 +3476 -2883
  5. package/dist/commons/application-config/index.d.ts +6 -6
  6. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  7. package/dist/commons/events/ActionConfig.d.ts +272 -70
  8. package/dist/commons/events/ActionDocument.d.ts +149 -105
  9. package/dist/commons/events/ActionInput.d.ts +26 -0
  10. package/dist/commons/events/ActionType.d.ts +63 -58
  11. package/dist/commons/events/AdvancedSearchConfig.d.ts +507 -501
  12. package/dist/commons/events/AuditLog.d.ts +43 -41
  13. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  14. package/dist/commons/events/Conditional.d.ts +3 -3
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  16. package/dist/commons/events/Draft.d.ts +37 -35
  17. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  18. package/dist/commons/events/EventConfig.d.ts +5 -5
  19. package/dist/commons/events/EventDocument.d.ts +64 -42
  20. package/dist/commons/events/EventIndex.d.ts +62 -62
  21. package/dist/commons/events/EventMetadata.d.ts +40 -40
  22. package/dist/commons/events/FieldConfig.d.ts +336 -331
  23. package/dist/commons/events/FieldType.d.ts +51 -51
  24. package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
  25. package/dist/commons/events/FieldValue.d.ts +12 -12
  26. package/dist/commons/events/Flag.d.ts +15 -15
  27. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  29. package/dist/commons/events/WorkqueueConfig.d.ts +827 -824
  30. package/dist/commons/events/deduplication.d.ts +1 -1
  31. package/dist/commons/events/event.d.ts +2 -2
  32. package/dist/commons/events/field.d.ts +69 -198
  33. package/dist/commons/events/locations.d.ts +4 -4
  34. package/dist/commons/events/mocks.test.utils.d.ts +2 -2
  35. package/dist/commons/events/scopes.d.ts +5 -4
  36. package/dist/commons/events/state/index.d.ts +17 -17
  37. package/dist/commons/events/state/utils.d.ts +7 -7
  38. package/dist/commons/events/test.utils.d.ts +40 -32
  39. package/dist/commons/events/utils.d.ts +119 -105
  40. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  41. package/dist/conditionals/index.js +2 -0
  42. package/dist/environment/derived-variables.d.ts +131 -131
  43. package/dist/environment/derived-variables.d.ts.map +1 -1
  44. package/dist/environment/logger.d.ts +3 -12
  45. package/dist/environment/logger.d.ts.map +1 -1
  46. package/dist/environment/manage-users.js +17 -7
  47. package/dist/environment/questions.d.ts +75 -74
  48. package/dist/environment/questions.d.ts.map +1 -1
  49. package/dist/environment/setup-environment.js +8 -14
  50. package/dist/environment/swarm-to-k8s.js +17 -7
  51. package/dist/environment/update-workflows.js +17 -7
  52. package/dist/environment/users.js +17 -7
  53. package/dist/environment/utils.d.ts +1 -1
  54. package/dist/environment/utils.js +17 -7
  55. package/dist/events/deduplication.d.ts +1 -1
  56. package/dist/events/index.js +166 -18
  57. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  58. package/dist/migrations/v2.0/index.js +88 -5144
  59. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  60. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  61. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  62. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  63. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  64. package/dist/migrations/v2.1/index.d.ts +6 -0
  65. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  66. package/dist/migrations/v2.1/index.js +218 -0
  67. package/dist/notification/index.js +131 -11
  68. package/dist/scopes/index.d.ts +146 -140
  69. package/dist/scopes/index.js +2 -0
  70. package/opencrvs-toolkit-2.1.0-rc.b89dfd1.tgz +0 -0
  71. package/package.json +2 -3
  72. package/tsconfig.tsbuildinfo +1 -1
  73. package/opencrvs-toolkit-2.1.0-rc.b0003b1.tgz +0 -0
@@ -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)
@@ -1257,6 +1269,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1257
1269
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1258
1270
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1259
1271
  ArchiveAction.meta({ id: "ArchiveAction" }),
1272
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1260
1273
  NotifiedAction.meta({ id: "NotifiedAction" }),
1261
1274
  RegisterAction.meta({ id: "RegisterAction" }),
1262
1275
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -2695,6 +2708,52 @@ var NotifyConfig = ActionConfigBase.extend(
2695
2708
  type: z24.literal(ActionType.NOTIFY)
2696
2709
  }).shape
2697
2710
  );
2711
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2712
+ z24.object({
2713
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
2714
+ label: z24.never().optional().describe(
2715
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2716
+ ),
2717
+ supportingCopy: z24.never().optional(),
2718
+ icon: z24.never().optional().describe(
2719
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2720
+ ),
2721
+ conditionals: z24.never().optional().describe(
2722
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2723
+ )
2724
+ }).shape
2725
+ );
2726
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2727
+ z24.object({
2728
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2729
+ }).shape
2730
+ );
2731
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2732
+ z24.object({
2733
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2734
+ }).shape
2735
+ );
2736
+ var AssignConfig = ActionConfigBase.extend(
2737
+ z24.object({
2738
+ type: z24.literal(ActionType.ASSIGN),
2739
+ flags: z24.never().optional().describe(
2740
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2741
+ )
2742
+ }).shape
2743
+ );
2744
+ var UnassignConfig = ActionConfigBase.extend(
2745
+ z24.object({
2746
+ type: z24.literal(ActionType.UNASSIGN),
2747
+ flags: z24.never().optional().describe(
2748
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2749
+ )
2750
+ }).shape
2751
+ );
2752
+ var DeleteConfig = ActionConfigBase.extend(
2753
+ z24.object({
2754
+ type: z24.literal(ActionType.DELETE)
2755
+ }).shape
2756
+ );
2698
2757
  var DeclareConfig = DeclarationActionBase.extend(
2699
2758
  z24.object({
2700
2759
  type: z24.literal(ActionType.DECLARE),
@@ -2719,6 +2778,11 @@ var ArchiveConfig = ActionConfigBase.extend(
2719
2778
  type: z24.literal(ActionType.ARCHIVE)
2720
2779
  }).shape
2721
2780
  );
2781
+ var UnarchiveConfig = ActionConfigBase.extend(
2782
+ z24.object({
2783
+ type: z24.literal(ActionType.UNARCHIVE)
2784
+ }).shape
2785
+ );
2722
2786
  var EditActionConfig = ActionConfigBase.extend(
2723
2787
  z24.object({
2724
2788
  type: z24.literal(ActionType.EDIT),
@@ -2757,7 +2821,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2757
2821
  correctionForm: ActionFormConfig
2758
2822
  }).shape
2759
2823
  );
2760
- var CustomActionConfig = ActionConfigBase.merge(
2824
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2825
+ z24.object({
2826
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
2827
+ }).shape
2828
+ );
2829
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2830
+ z24.object({
2831
+ type: z24.literal(ActionType.REJECT_CORRECTION)
2832
+ }).shape
2833
+ );
2834
+ var CustomActionConfig = ActionConfigBase.extend(
2761
2835
  z24.object({
2762
2836
  type: z24.literal(ActionType.CUSTOM),
2763
2837
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2768,7 +2842,7 @@ var CustomActionConfig = ActionConfigBase.merge(
2768
2842
  auditHistoryLabel: TranslationConfig.describe(
2769
2843
  'The label to show in audit history for this action. For example "Approved".'
2770
2844
  )
2771
- })
2845
+ }).shape
2772
2846
  );
2773
2847
  var ActionConfig = z24.discriminatedUnion("type", [
2774
2848
  /*
@@ -2779,6 +2853,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
2779
2853
  id: "ReadActionConfig",
2780
2854
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2781
2855
  }),
2856
+ AssignConfig.meta({
2857
+ id: "AssignActionConfig",
2858
+ description: "Configuration for assigning a record to the current user."
2859
+ }),
2860
+ UnassignConfig.meta({
2861
+ id: "UnassignActionConfig",
2862
+ description: "Configuration for unassigning a record from its current assignee."
2863
+ }),
2864
+ DeleteConfig.meta({
2865
+ id: "DeleteActionConfig",
2866
+ description: "Configuration for deleting a draft record."
2867
+ }),
2782
2868
  NotifyConfig.meta({
2783
2869
  id: "NotifyActionConfig",
2784
2870
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -2787,6 +2873,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
2787
2873
  id: "DeclareActionConfig",
2788
2874
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2789
2875
  }),
2876
+ DuplicateDetectedConfig.meta({
2877
+ id: "DuplicateDetectedActionConfig",
2878
+ 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."
2879
+ }),
2880
+ MarkAsDuplicateConfig.meta({
2881
+ id: "MarkAsDuplicateActionConfig",
2882
+ description: "Configuration for marking a record as a duplicate."
2883
+ }),
2884
+ MarkAsNotDuplicateConfig.meta({
2885
+ id: "MarkAsNotDuplicateActionConfig",
2886
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2887
+ }),
2790
2888
  RejectConfig.meta({
2791
2889
  id: "RejectActionConfig",
2792
2890
  description: "Configuration for rejecting a record before registration."
@@ -2803,6 +2901,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2803
2901
  id: "RequestCorrectionActionConfig",
2804
2902
  description: "Configuration for requesting a correction on a registered record."
2805
2903
  }),
2904
+ ApproveCorrectionConfig.meta({
2905
+ id: "ApproveCorrectionActionConfig",
2906
+ description: "Configuration for approving a requested correction."
2907
+ }),
2908
+ RejectCorrectionConfig.meta({
2909
+ id: "RejectCorrectionActionConfig",
2910
+ description: "Configuration for rejecting a requested correction."
2911
+ }),
2806
2912
  EditActionConfig.meta({
2807
2913
  id: "EditActionConfig",
2808
2914
  description: "Configuration for editing a record before registration."
@@ -2811,6 +2917,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2811
2917
  id: "ArchiveActionConfig",
2812
2918
  description: "Configuration for archiving a record."
2813
2919
  }),
2920
+ UnarchiveConfig.meta({
2921
+ id: "UnarchiveActionConfig",
2922
+ description: "Configuration for unarchiving a record."
2923
+ }),
2814
2924
  CustomActionConfig.meta({
2815
2925
  id: "CustomActionConfig",
2816
2926
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -3930,7 +4040,7 @@ function validateActionFlags(event2, ctx) {
3930
4040
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3931
4041
  const configuredFlagIds = event2.flags.map((flag) => flag.id);
3932
4042
  const actionFlagIds = event2.actions.flatMap(
3933
- (action) => action.flags.map((flag) => flag.id)
4043
+ (action) => (action.flags ?? []).map((flag) => flag.id)
3934
4044
  );
3935
4045
  for (const actionFlagId of actionFlagIds) {
3936
4046
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4583,6 +4693,11 @@ var ArchiveActionInput = BaseActionInput.extend(
4583
4693
  content: ReasonContent
4584
4694
  }).shape
4585
4695
  );
4696
+ var UnarchiveActionInput = BaseActionInput.extend(
4697
+ z38.object({
4698
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4699
+ }).shape
4700
+ );
4586
4701
  var AssignActionInput = BaseActionInput.extend(
4587
4702
  z38.object({
4588
4703
  type: z38.literal(ActionType.ASSIGN),
@@ -4644,6 +4759,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4644
4759
  id: "MarkNotDuplicateActionInput"
4645
4760
  }),
4646
4761
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
4762
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4647
4763
  AssignActionInput.meta({ id: "AssignActionInput" }),
4648
4764
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4649
4765
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4721,6 +4837,7 @@ var updateActions = ActionTypes.extract([
4721
4837
  ActionType.REGISTER,
4722
4838
  ActionType.REJECT,
4723
4839
  ActionType.ARCHIVE,
4840
+ ActionType.UNARCHIVE,
4724
4841
  ActionType.PRINT_CERTIFICATE,
4725
4842
  ActionType.REQUEST_CORRECTION,
4726
4843
  ActionType.APPROVE_CORRECTION,
@@ -4739,15 +4856,12 @@ var INHERENT_FLAG_RULES = [
4739
4856
  },
4740
4857
  {
4741
4858
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4742
- // other status-changing action (see getStatusFromActions).
4859
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4860
+ // are deliberately excluded so the flag freezes across an archive/unarchive
4861
+ // round trip and comes back exactly as it was.
4743
4862
  flag: InherentFlags.INCOMPLETE,
4744
4863
  setOn: [ActionType.NOTIFY],
4745
- resetOn: [
4746
- ActionType.CREATE,
4747
- ActionType.DECLARE,
4748
- ActionType.REGISTER,
4749
- ActionType.ARCHIVE
4750
- ]
4864
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4751
4865
  },
4752
4866
  {
4753
4867
  flag: InherentFlags.REJECTED,
@@ -7279,6 +7393,7 @@ var ACTION_SCOPE_MAP = {
7279
7393
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7280
7394
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7281
7395
  [ActionType.ARCHIVE]: ["record.archive"],
7396
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
7282
7397
  [ActionType.REJECT]: ["record.reject"],
7283
7398
  [ActionType.ASSIGN]: null,
7284
7399
  [ActionType.UNASSIGN]: null,
@@ -7321,7 +7436,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7321
7436
  ActionType.CUSTOM,
7322
7437
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7323
7438
  ],
7324
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7439
+ [EventStatus.enum.ARCHIVED]: [
7440
+ ActionType.READ,
7441
+ ActionType.CUSTOM,
7442
+ ActionType.UNARCHIVE
7443
+ ]
7325
7444
  };
7326
7445
  var ACTION_FILTERS = {
7327
7446
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
@@ -7334,6 +7453,7 @@ var ACTION_FILTERS = {
7334
7453
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7335
7454
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7336
7455
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7456
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7337
7457
  [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7338
7458
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7339
7459
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))