@opencrvs/toolkit 2.0.0-rc.31403f2 → 2.0.0-rc.315863

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 (34) hide show
  1. package/build.sh +2 -2
  2. package/dist/application-config/index.js +12 -0
  3. package/dist/cli.js +5110 -167
  4. package/dist/commons/api/router.d.ts +613 -20
  5. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  6. package/dist/commons/events/ActionConfig.d.ts +8 -158
  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/scopes.d.ts +1 -0
  17. package/dist/commons/events/test.utils.d.ts +9 -1
  18. package/dist/commons/events/utils.d.ts +15 -1
  19. package/dist/conditionals/index.js +2 -0
  20. package/dist/events/index.js +81 -103
  21. package/dist/migrations/v2.0/index.js +5146 -88
  22. package/dist/notification/index.js +43 -99
  23. package/dist/scopes/index.d.ts +7 -1
  24. package/dist/scopes/index.js +2 -0
  25. package/opencrvs-toolkit-2.0.0-rc.0315863.tgz +0 -0
  26. package/package.json +1 -1
  27. package/tsconfig.tsbuildinfo +1 -1
  28. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  29. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  30. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  31. package/dist/migrations/v2.1/index.d.ts +0 -6
  32. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  33. package/dist/migrations/v2.1/index.js +0 -218
  34. package/opencrvs-toolkit-2.0.0-rc.31403f2.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,52 +2708,6 @@ var NotifyConfig = ActionConfigBase.extend(
2695
2708
  type: z24.literal(ActionType.NOTIFY)
2696
2709
  }).shape
2697
2710
  );
2698
- var DuplicateDetectedConfig = ActionConfigBase.extend(
2699
- z24.object({
2700
- type: z24.literal(ActionType.DUPLICATE_DETECTED),
2701
- label: z24.never().optional().describe(
2702
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2703
- ),
2704
- supportingCopy: z24.never().optional(),
2705
- icon: z24.never().optional().describe(
2706
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2707
- ),
2708
- conditionals: z24.never().optional().describe(
2709
- "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2710
- )
2711
- }).shape
2712
- );
2713
- var MarkAsDuplicateConfig = ActionConfigBase.extend(
2714
- z24.object({
2715
- type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2716
- }).shape
2717
- );
2718
- var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2719
- z24.object({
2720
- type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2721
- }).shape
2722
- );
2723
- var AssignConfig = ActionConfigBase.extend(
2724
- z24.object({
2725
- type: z24.literal(ActionType.ASSIGN),
2726
- flags: z24.never().optional().describe(
2727
- "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2728
- )
2729
- }).shape
2730
- );
2731
- var UnassignConfig = ActionConfigBase.extend(
2732
- z24.object({
2733
- type: z24.literal(ActionType.UNASSIGN),
2734
- flags: z24.never().optional().describe(
2735
- "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2736
- )
2737
- }).shape
2738
- );
2739
- var DeleteConfig = ActionConfigBase.extend(
2740
- z24.object({
2741
- type: z24.literal(ActionType.DELETE)
2742
- }).shape
2743
- );
2744
2711
  var DeclareConfig = DeclarationActionBase.extend(
2745
2712
  z24.object({
2746
2713
  type: z24.literal(ActionType.DECLARE),
@@ -2765,6 +2732,11 @@ var ArchiveConfig = ActionConfigBase.extend(
2765
2732
  type: z24.literal(ActionType.ARCHIVE)
2766
2733
  }).shape
2767
2734
  );
2735
+ var UnarchiveConfig = ActionConfigBase.extend(
2736
+ z24.object({
2737
+ type: z24.literal(ActionType.UNARCHIVE)
2738
+ }).shape
2739
+ );
2768
2740
  var EditActionConfig = ActionConfigBase.extend(
2769
2741
  z24.object({
2770
2742
  type: z24.literal(ActionType.EDIT),
@@ -2803,17 +2775,7 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2803
2775
  correctionForm: ActionFormConfig
2804
2776
  }).shape
2805
2777
  );
2806
- var ApproveCorrectionConfig = ActionConfigBase.extend(
2807
- z24.object({
2808
- type: z24.literal(ActionType.APPROVE_CORRECTION)
2809
- }).shape
2810
- );
2811
- var RejectCorrectionConfig = ActionConfigBase.extend(
2812
- z24.object({
2813
- type: z24.literal(ActionType.REJECT_CORRECTION)
2814
- }).shape
2815
- );
2816
- var CustomActionConfig = ActionConfigBase.extend(
2778
+ var CustomActionConfig = ActionConfigBase.merge(
2817
2779
  z24.object({
2818
2780
  type: z24.literal(ActionType.CUSTOM),
2819
2781
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2824,7 +2786,7 @@ var CustomActionConfig = ActionConfigBase.extend(
2824
2786
  auditHistoryLabel: TranslationConfig.describe(
2825
2787
  'The label to show in audit history for this action. For example "Approved".'
2826
2788
  )
2827
- }).shape
2789
+ })
2828
2790
  );
2829
2791
  var ActionConfig = z24.discriminatedUnion("type", [
2830
2792
  /*
@@ -2835,18 +2797,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
2835
2797
  id: "ReadActionConfig",
2836
2798
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2837
2799
  }),
2838
- AssignConfig.meta({
2839
- id: "AssignActionConfig",
2840
- description: "Configuration for assigning a record to the current user."
2841
- }),
2842
- UnassignConfig.meta({
2843
- id: "UnassignActionConfig",
2844
- description: "Configuration for unassigning a record from its current assignee."
2845
- }),
2846
- DeleteConfig.meta({
2847
- id: "DeleteActionConfig",
2848
- description: "Configuration for deleting a draft record."
2849
- }),
2850
2800
  NotifyConfig.meta({
2851
2801
  id: "NotifyActionConfig",
2852
2802
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -2855,18 +2805,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
2855
2805
  id: "DeclareActionConfig",
2856
2806
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2857
2807
  }),
2858
- DuplicateDetectedConfig.meta({
2859
- id: "DuplicateDetectedActionConfig",
2860
- 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."
2861
- }),
2862
- MarkAsDuplicateConfig.meta({
2863
- id: "MarkAsDuplicateActionConfig",
2864
- description: "Configuration for marking a record as a duplicate."
2865
- }),
2866
- MarkAsNotDuplicateConfig.meta({
2867
- id: "MarkAsNotDuplicateActionConfig",
2868
- description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2869
- }),
2870
2808
  RejectConfig.meta({
2871
2809
  id: "RejectActionConfig",
2872
2810
  description: "Configuration for rejecting a record before registration."
@@ -2883,14 +2821,6 @@ var ActionConfig = z24.discriminatedUnion("type", [
2883
2821
  id: "RequestCorrectionActionConfig",
2884
2822
  description: "Configuration for requesting a correction on a registered record."
2885
2823
  }),
2886
- ApproveCorrectionConfig.meta({
2887
- id: "ApproveCorrectionActionConfig",
2888
- description: "Configuration for approving a requested correction."
2889
- }),
2890
- RejectCorrectionConfig.meta({
2891
- id: "RejectCorrectionActionConfig",
2892
- description: "Configuration for rejecting a requested correction."
2893
- }),
2894
2824
  EditActionConfig.meta({
2895
2825
  id: "EditActionConfig",
2896
2826
  description: "Configuration for editing a record before registration."
@@ -2899,6 +2829,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2899
2829
  id: "ArchiveActionConfig",
2900
2830
  description: "Configuration for archiving a record."
2901
2831
  }),
2832
+ UnarchiveConfig.meta({
2833
+ id: "UnarchiveActionConfig",
2834
+ description: "Configuration for unarchiving a record."
2835
+ }),
2902
2836
  CustomActionConfig.meta({
2903
2837
  id: "CustomActionConfig",
2904
2838
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4018,7 +3952,7 @@ function validateActionFlags(event2, ctx) {
4018
3952
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4019
3953
  const configuredFlagIds = event2.flags.map((flag) => flag.id);
4020
3954
  const actionFlagIds = event2.actions.flatMap(
4021
- (action) => (action.flags ?? []).map((flag) => flag.id)
3955
+ (action) => action.flags.map((flag) => flag.id)
4022
3956
  );
4023
3957
  for (const actionFlagId of actionFlagIds) {
4024
3958
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4671,6 +4605,11 @@ var ArchiveActionInput = BaseActionInput.extend(
4671
4605
  content: ReasonContent
4672
4606
  }).shape
4673
4607
  );
4608
+ var UnarchiveActionInput = BaseActionInput.extend(
4609
+ z38.object({
4610
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4611
+ }).shape
4612
+ );
4674
4613
  var AssignActionInput = BaseActionInput.extend(
4675
4614
  z38.object({
4676
4615
  type: z38.literal(ActionType.ASSIGN),
@@ -4732,6 +4671,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4732
4671
  id: "MarkNotDuplicateActionInput"
4733
4672
  }),
4734
4673
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
4674
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4735
4675
  AssignActionInput.meta({ id: "AssignActionInput" }),
4736
4676
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4737
4677
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4809,6 +4749,7 @@ var updateActions = ActionTypes.extract([
4809
4749
  ActionType.REGISTER,
4810
4750
  ActionType.REJECT,
4811
4751
  ActionType.ARCHIVE,
4752
+ ActionType.UNARCHIVE,
4812
4753
  ActionType.PRINT_CERTIFICATE,
4813
4754
  ActionType.REQUEST_CORRECTION,
4814
4755
  ActionType.APPROVE_CORRECTION,
@@ -4827,15 +4768,12 @@ var INHERENT_FLAG_RULES = [
4827
4768
  },
4828
4769
  {
4829
4770
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4830
- // other status-changing action (see getStatusFromActions).
4771
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4772
+ // are deliberately excluded so the flag freezes across an archive/unarchive
4773
+ // round trip and comes back exactly as it was.
4831
4774
  flag: InherentFlags.INCOMPLETE,
4832
4775
  setOn: [ActionType.NOTIFY],
4833
- resetOn: [
4834
- ActionType.CREATE,
4835
- ActionType.DECLARE,
4836
- ActionType.REGISTER,
4837
- ActionType.ARCHIVE
4838
- ]
4776
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4839
4777
  },
4840
4778
  {
4841
4779
  flag: InherentFlags.REJECTED,
@@ -7367,6 +7305,7 @@ var ACTION_SCOPE_MAP = {
7367
7305
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7368
7306
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7369
7307
  [ActionType.ARCHIVE]: ["record.archive"],
7308
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
7370
7309
  [ActionType.REJECT]: ["record.reject"],
7371
7310
  [ActionType.ASSIGN]: null,
7372
7311
  [ActionType.UNASSIGN]: null,
@@ -7409,7 +7348,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7409
7348
  ActionType.CUSTOM,
7410
7349
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7411
7350
  ],
7412
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7351
+ [EventStatus.enum.ARCHIVED]: [
7352
+ ActionType.READ,
7353
+ ActionType.CUSTOM,
7354
+ ActionType.UNARCHIVE
7355
+ ]
7413
7356
  };
7414
7357
  var ACTION_FILTERS = {
7415
7358
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
@@ -7422,6 +7365,7 @@ var ACTION_FILTERS = {
7422
7365
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7423
7366
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7424
7367
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7368
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7425
7369
  [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7426
7370
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7427
7371
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
@@ -25,6 +25,7 @@ export declare const RecordScopeTypeV2: z.ZodEnum<{
25
25
  "record.edit": "record.edit";
26
26
  "record.reject": "record.reject";
27
27
  "record.archive": "record.archive";
28
+ "record.unarchive": "record.unarchive";
28
29
  "record.review-duplicates": "record.review-duplicates";
29
30
  "record.register": "record.register";
30
31
  "record.print-certified-copies": "record.print-certified-copies";
@@ -97,6 +98,7 @@ export declare const ScopesWithDeclaredOptions: z.ZodEnum<{
97
98
  "record.edit": "record.edit";
98
99
  "record.reject": "record.reject";
99
100
  "record.archive": "record.archive";
101
+ "record.unarchive": "record.unarchive";
100
102
  "record.review-duplicates": "record.review-duplicates";
101
103
  "record.register": "record.register";
102
104
  }>;
@@ -126,6 +128,7 @@ export declare const RecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject<{
126
128
  "record.edit": "record.edit";
127
129
  "record.reject": "record.reject";
128
130
  "record.archive": "record.archive";
131
+ "record.unarchive": "record.unarchive";
129
132
  "record.review-duplicates": "record.review-duplicates";
130
133
  "record.register": "record.register";
131
134
  }>;
@@ -341,6 +344,7 @@ export declare const ResolvedRecordScopeV2: z.ZodDiscriminatedUnion<[z.ZodObject
341
344
  "record.edit": "record.edit";
342
345
  "record.reject": "record.reject";
343
346
  "record.archive": "record.archive";
347
+ "record.unarchive": "record.unarchive";
344
348
  "record.review-duplicates": "record.review-duplicates";
345
349
  "record.register": "record.register";
346
350
  }>;
@@ -423,6 +427,7 @@ export declare const Scope: z.ZodDiscriminatedUnion<[z.ZodObject<{
423
427
  "record.edit": "record.edit";
424
428
  "record.reject": "record.reject";
425
429
  "record.archive": "record.archive";
430
+ "record.unarchive": "record.unarchive";
426
431
  "record.review-duplicates": "record.review-duplicates";
427
432
  "record.register": "record.register";
428
433
  }>;
@@ -615,6 +620,7 @@ export declare const ScopeType: z.ZodEnum<{
615
620
  "record.edit": "record.edit";
616
621
  "record.reject": "record.reject";
617
622
  "record.archive": "record.archive";
623
+ "record.unarchive": "record.unarchive";
618
624
  "record.review-duplicates": "record.review-duplicates";
619
625
  "record.register": "record.register";
620
626
  "record.print-certified-copies": "record.print-certified-copies";
@@ -672,7 +678,7 @@ export declare const decodeScope: (encodedScope: EncodedScope) => {
672
678
  placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
673
679
  } | undefined;
674
680
  } | {
675
- type: "record.edit" | "record.reject" | "record.archive" | "record.review-duplicates" | "record.register";
681
+ type: "record.edit" | "record.reject" | "record.archive" | "record.unarchive" | "record.review-duplicates" | "record.register";
676
682
  options?: {
677
683
  event?: string[] | undefined;
678
684
  placeOfEvent?: "administrativeArea" | "location" | "all" | undefined;
@@ -110,6 +110,7 @@ var RecordScopeTypeV2 = z3.enum([
110
110
  "record.edit",
111
111
  "record.reject",
112
112
  "record.archive",
113
+ "record.unarchive",
113
114
  "record.review-duplicates",
114
115
  "record.register",
115
116
  "record.print-certified-copies",
@@ -215,6 +216,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
215
216
  "record.edit",
216
217
  "record.reject",
217
218
  "record.archive",
219
+ "record.unarchive",
218
220
  "record.review-duplicates",
219
221
  "record.register"
220
222
  ]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "2.0.0-rc.31403f2",
3
+ "version": "2.0.0-rc.0315863",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "bin": {
@@ -1 +1 @@
1
- {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/environment/custom-types.ts","./src/environment/derived-variables.ts","./src/environment/editor-questions.ts","./src/environment/git.ts","./src/environment/github.ts","./src/environment/index.ts","./src/environment/logger.ts","./src/environment/manage-users.ts","./src/environment/questions-helper.ts","./src/environment/questions.ts","./src/environment/setup-environment.ts","./src/environment/ssh-keygen.ts","./src/environment/swarm-to-k8s.ts","./src/environment/templates.ts","./src/environment/update-workflows.ts","./src/environment/users.ts","./src/environment/utils.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/fix-accept-requested-registration-function-type.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/migrations/v2.1/add-explicit-correction-flags.ts","./src/migrations/v2.1/index.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
1
+ {"root":["./src/cli.ts","./src/api/index.ts","./src/application-config/index.ts","./src/conditionals/index.ts","./src/environment/custom-types.ts","./src/environment/derived-variables.ts","./src/environment/editor-questions.ts","./src/environment/git.ts","./src/environment/github.ts","./src/environment/index.ts","./src/environment/logger.ts","./src/environment/manage-users.ts","./src/environment/questions-helper.ts","./src/environment/questions.ts","./src/environment/setup-environment.ts","./src/environment/ssh-keygen.ts","./src/environment/swarm-to-k8s.ts","./src/environment/templates.ts","./src/environment/update-workflows.ts","./src/environment/users.ts","./src/environment/utils.ts","./src/events/deduplication.ts","./src/events/index.ts","./src/migrations/v2.0/add-birth-certificate-issuance-flag.ts","./src/migrations/v2.0/add-resend-invite-notification.ts","./src/migrations/v2.0/checkout-upstream-files.ts","./src/migrations/v2.0/convert-config-files-to-ts.ts","./src/migrations/v2.0/convert-paragraph-to-heading.ts","./src/migrations/v2.0/create-events-index.ts","./src/migrations/v2.0/delete-infrastructure-directory.ts","./src/migrations/v2.0/fix-accept-requested-registration-function-type.ts","./src/migrations/v2.0/index.ts","./src/migrations/v2.0/make-built-in-validate-actions-custom.ts","./src/migrations/v2.0/merge-infrastructure-directory.ts","./src/migrations/v2.0/migrate-application-config-url.ts","./src/migrations/v2.0/migrate-scopes.ts","./src/migrations/v2.0/migrate-validated-workqueue-status-to-flag.ts","./src/migrations/v2.0/migrate-workqueue-configs.ts","./src/migrations/v2.0/remove-delete-actions.ts","./src/migrations/v2.0/remove-demo-scope.ts","./src/migrations/v2.0/remove-deprecated-imports.ts","./src/migrations/v2.0/remove-fhir-url-helpers.ts","./src/migrations/v2.0/remove-hearth-migrations.ts","./src/migrations/v2.0/remove-old-statistics-service.ts","./src/migrations/v2.0/remove-pending-certification-flag.ts","./src/migrations/v2.0/remove-review-from-register-action.ts","./src/migrations/v2.0/remove-unused-environment-variables.ts","./src/migrations/v2.0/rename-api-paths.ts","./src/migrations/v2.0/rename-location-parent-id.ts","./src/migrations/v2.0/simplify-analytics-precalculations.ts","./src/migrations/v2.0/update-package-json.ts","./src/notification/index.ts","./src/scopes/index.ts"],"version":"5.6.3"}
@@ -1,3 +0,0 @@
1
- declare function main(): Promise<void>;
2
- export { main };
3
- //# sourceMappingURL=add-explicit-correction-flags.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"add-explicit-correction-flags.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/add-explicit-correction-flags.ts"],"names":[],"mappings":"AAyPA,iBAAe,IAAI,kBA+ClB;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -1,234 +0,0 @@
1
- "use strict";
2
- /*
3
- * This Source Code Form is subject to the terms of the Mozilla Public
4
- * License, v. 2.0. If a copy of the MPL was not distributed with this
5
- * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
- *
7
- * OpenCRVS is also distributed under the terms of the Civil Registration
8
- * & Healthcare Disclaimer located at http://opencrvs.org/license.
9
- *
10
- * Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
11
- */
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __importDefault = (this && this.__importDefault) || function (mod) {
22
- return (mod && mod.__esModule) ? mod : { "default": mod };
23
- };
24
- Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.main = main;
26
- /**
27
- * Codemod: Add explicit `APPROVE_CORRECTION` / `REJECT_CORRECTION` action
28
- * configs when `REQUEST_CORRECTION` has `flags` and/or `conditionals`.
29
- *
30
- * Usage:
31
- * ts-node -r tsconfig-paths/register src/migrations/v2.1/add-explicit-correction-flags.ts
32
- *
33
- * Why:
34
- * `getActionConfig()` used to alias `APPROVE_CORRECTION` and
35
- * `REJECT_CORRECTION` to whatever was configured on `REQUEST_CORRECTION`
36
- * (label, flags, conditionals). As of v2.1, each resolves to its own
37
- * independent config, so `flags`/`conditionals` configured only on
38
- * `REQUEST_CORRECTION` would silently stop applying when an
39
- * `APPROVE_CORRECTION`/`REJECT_CORRECTION` action is accepted. See
40
- * CHANGELOG.md ("APPROVE_CORRECTION / REJECT_CORRECTION no longer inherit
41
- * REQUEST_CORRECTION's config").
42
- *
43
- * What it does:
44
- * - Scans all TypeScript files under `src/`
45
- * - Finds every `defineConfig({ ... })` call expression
46
- * - Inside the `actions` array, locates the `REQUEST_CORRECTION` action
47
- * - If it has a non-empty `flags` and/or `conditionals` array, inserts
48
- * sibling `APPROVE_CORRECTION` and `REJECT_CORRECTION` action objects
49
- * (carrying over the same `flags`/`conditionals`) immediately after it,
50
- * unless an action of that type already exists in the array
51
- * - Saves the modified files in-place
52
- */
53
- const ts_morph_1 = require("ts-morph");
54
- const path_1 = __importDefault(require("path"));
55
- const DEFINE_CONFIG_NAME = 'defineConfig';
56
- const ACTIONS_PROPERTY_NAME = 'actions';
57
- const TYPE_PROPERTY_NAME = 'type';
58
- const FLAGS_PROPERTY_NAME = 'flags';
59
- const CONDITIONALS_PROPERTY_NAME = 'conditionals';
60
- const ACTION_TYPE_ENUM_NAME = 'ActionType';
61
- const REQUEST_CORRECTION_TYPE = 'REQUEST_CORRECTION';
62
- const CORRECTION_ACTIONS_TO_ADD = [
63
- {
64
- actionType: 'APPROVE_CORRECTION',
65
- labelId: 'v2.events.correction.approve.label',
66
- defaultMessage: 'Approve correction',
67
- description: 'Label for the approve correction action'
68
- },
69
- {
70
- actionType: 'REJECT_CORRECTION',
71
- labelId: 'v2.events.correction.reject.label',
72
- defaultMessage: 'Reject correction',
73
- description: 'Label for the reject correction action'
74
- }
75
- ];
76
- /**
77
- * Returns true if the object's `type` property matches the given type name.
78
- * Handles both `ActionType.X` and the string literal `'X'` forms.
79
- */
80
- function isActionOfType(obj, typeName) {
81
- const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
82
- if (!typeProperty || !ts_morph_1.Node.isPropertyAssignment(typeProperty))
83
- return false;
84
- const typeInit = typeProperty.getInitializer();
85
- if (!typeInit)
86
- return false;
87
- if (ts_morph_1.Node.isPropertyAccessExpression(typeInit)) {
88
- return (typeInit.getExpression().getText() === ACTION_TYPE_ENUM_NAME &&
89
- typeInit.getName() === typeName);
90
- }
91
- if (ts_morph_1.Node.isStringLiteral(typeInit)) {
92
- return typeInit.getLiteralValue() === typeName;
93
- }
94
- return false;
95
- }
96
- /**
97
- * Returns whether `type` is written as `ActionType.X` (enum access) or as a
98
- * bare string literal, so newly inserted actions can mirror the same style.
99
- */
100
- function getTypeInitializerStyle(obj) {
101
- const typeProperty = obj.getProperty(TYPE_PROPERTY_NAME);
102
- if (typeProperty && ts_morph_1.Node.isPropertyAssignment(typeProperty)) {
103
- const typeInit = typeProperty.getInitializer();
104
- if (typeInit && ts_morph_1.Node.isPropertyAccessExpression(typeInit))
105
- return 'enum';
106
- }
107
- return 'string';
108
- }
109
- /**
110
- * Returns the source text of `obj[propName]` if it's an array literal with
111
- * at least one element, otherwise undefined.
112
- */
113
- function getNonEmptyArrayPropertyText(obj, propName) {
114
- const prop = obj.getProperty(propName);
115
- if (!prop || !ts_morph_1.Node.isPropertyAssignment(prop))
116
- return undefined;
117
- const init = prop.getInitializer();
118
- if (!init || !ts_morph_1.Node.isArrayLiteralExpression(init))
119
- return undefined;
120
- if (init.getElements().length === 0)
121
- return undefined;
122
- return init.getText();
123
- }
124
- function buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText) {
125
- const typeText = typeStyle === 'enum'
126
- ? `${ACTION_TYPE_ENUM_NAME}.${spec.actionType}`
127
- : `'${spec.actionType}'`;
128
- const lines = [
129
- `type: ${typeText}`,
130
- `label: {
131
- id: '${spec.labelId}',
132
- defaultMessage: '${spec.defaultMessage}',
133
- description: '${spec.description}'
134
- }`
135
- ];
136
- if (flagsText) {
137
- lines.push(`${FLAGS_PROPERTY_NAME}: ${flagsText}`);
138
- }
139
- if (conditionalsText) {
140
- lines.push(`${CONDITIONALS_PROPERTY_NAME}: ${conditionalsText}`);
141
- }
142
- return `{\n ${lines.join(',\n ')}\n}`;
143
- }
144
- function processFile(filePath, project) {
145
- const sourceFile = project.getSourceFile(filePath);
146
- if (!sourceFile)
147
- return 0;
148
- let changes = 0;
149
- const relPath = path_1.default.relative(process.cwd(), filePath);
150
- const callExpressions = sourceFile.getDescendantsOfKind(ts_morph_1.SyntaxKind.CallExpression);
151
- for (const call of callExpressions) {
152
- const expression = call.getExpression();
153
- if (!ts_morph_1.Node.isIdentifier(expression) ||
154
- expression.getText() !== DEFINE_CONFIG_NAME) {
155
- continue;
156
- }
157
- const args = call.getArguments();
158
- if (args.length === 0)
159
- continue;
160
- const configArg = args[0];
161
- if (!ts_morph_1.Node.isObjectLiteralExpression(configArg))
162
- continue;
163
- const actionsProperty = configArg.getProperty(ACTIONS_PROPERTY_NAME);
164
- if (!actionsProperty || !ts_morph_1.Node.isPropertyAssignment(actionsProperty))
165
- continue;
166
- const actionsInitializer = actionsProperty.getInitializer();
167
- if (!actionsInitializer ||
168
- !ts_morph_1.Node.isArrayLiteralExpression(actionsInitializer))
169
- continue;
170
- const elements = actionsInitializer.getElements();
171
- const requestCorrectionIndex = elements.findIndex((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
172
- isActionOfType(el, REQUEST_CORRECTION_TYPE));
173
- if (requestCorrectionIndex === -1)
174
- continue;
175
- const requestCorrection = elements[requestCorrectionIndex];
176
- const flagsText = getNonEmptyArrayPropertyText(requestCorrection, FLAGS_PROPERTY_NAME);
177
- const conditionalsText = getNonEmptyArrayPropertyText(requestCorrection, CONDITIONALS_PROPERTY_NAME);
178
- // Nothing on REQUEST_CORRECTION that approve/reject would need to inherit.
179
- if (!flagsText && !conditionalsText)
180
- continue;
181
- const typeStyle = getTypeInitializerStyle(requestCorrection);
182
- let insertAt = requestCorrectionIndex + 1;
183
- for (const spec of CORRECTION_ACTIONS_TO_ADD) {
184
- const alreadyPresent = actionsInitializer
185
- .getElements()
186
- .some((el) => ts_morph_1.Node.isObjectLiteralExpression(el) &&
187
- isActionOfType(el, spec.actionType));
188
- if (alreadyPresent)
189
- continue;
190
- const text = buildCorrectionActionText(spec, typeStyle, flagsText, conditionalsText);
191
- actionsInitializer.insertElement(insertAt, text);
192
- insertAt++;
193
- changes++;
194
- console.log(` [${relPath}] Added ${spec.actionType} action carrying over REQUEST_CORRECTION's flags/conditionals`);
195
- }
196
- }
197
- return changes;
198
- }
199
- function main() {
200
- return __awaiter(this, void 0, void 0, function* () {
201
- const srcDir = path_1.default.join(process.cwd(), 'src');
202
- console.log(`Scanning for defineConfig calls in: ${srcDir}\n`);
203
- const project = new ts_morph_1.Project({
204
- tsConfigFilePath: path_1.default.resolve(srcDir, '../tsconfig.json'),
205
- skipAddingFilesFromTsConfig: false
206
- });
207
- const sourceFiles = project.getSourceFiles().filter((sf) => {
208
- const fp = sf.getFilePath();
209
- return fp.includes('/src/') && !fp.includes('/node_modules/');
210
- });
211
- console.log(`Found ${sourceFiles.length} source file(s) to analyse.\n`);
212
- let totalChanges = 0;
213
- const modifiedFiles = [];
214
- for (const sourceFile of sourceFiles) {
215
- const filePath = sourceFile.getFilePath();
216
- const changes = processFile(filePath, project);
217
- if (changes > 0) {
218
- totalChanges += changes;
219
- modifiedFiles.push(filePath);
220
- }
221
- }
222
- if (modifiedFiles.length === 0) {
223
- console.log('No REQUEST_CORRECTION actions with flags/conditionals found. Nothing to do.');
224
- return;
225
- }
226
- console.log(`\nSaving ${modifiedFiles.length} modified file(s)...`);
227
- for (const filePath of modifiedFiles) {
228
- const sourceFile = project.getSourceFileOrThrow(filePath);
229
- yield sourceFile.save();
230
- console.log(` Saved: ${path_1.default.relative(process.cwd(), filePath)}`);
231
- }
232
- console.log(`\nDone. Added ${totalChanges} correction action config(s) across ${modifiedFiles.length} file(s).`);
233
- });
234
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Run the upgrade process for the country config in the current working
3
- * directory.
4
- */
5
- export declare function runUpgrade(dockerSwarm: boolean): Promise<void>;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.1/index.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,wBAAsB,UAAU,CAAC,WAAW,EAAE,OAAO,iBAEpD"}