@opencrvs/toolkit 2.0.0 → 2.1.0-rc.0066f38

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 (106) hide show
  1. package/README.md +15 -0
  2. package/build.sh +5 -4
  3. package/create-countryconfig/package.json +1 -1
  4. package/dist/application-config/index.js +29 -6
  5. package/dist/cli.js +3186 -4921
  6. package/dist/commons/api/router.d.ts +623 -20
  7. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  8. package/dist/commons/events/ActionConfig.d.ts +237 -2
  9. package/dist/commons/events/ActionDocument.d.ts +44 -0
  10. package/dist/commons/events/ActionInput.d.ts +26 -0
  11. package/dist/commons/events/ActionType.d.ts +6 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +18 -0
  13. package/dist/commons/events/AuditLog.d.ts +2 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventConfig.d.ts +2 -0
  17. package/dist/commons/events/EventDocument.d.ts +22 -0
  18. package/dist/commons/events/EventIndex.d.ts +25 -0
  19. package/dist/commons/events/EventMetadata.d.ts +26 -0
  20. package/dist/commons/events/FieldConfig.d.ts +15 -0
  21. package/dist/commons/events/WorkqueueConfig.d.ts +44 -2
  22. package/dist/commons/events/locations.d.ts +1 -0
  23. package/dist/commons/events/scopes.d.ts +1 -0
  24. package/dist/commons/events/state/index.d.ts +8 -0
  25. package/dist/commons/events/state/utils.d.ts +9 -0
  26. package/dist/commons/events/test.utils.d.ts +9 -1
  27. package/dist/commons/events/utils.d.ts +23 -1
  28. package/dist/conditionals/index.js +12 -5
  29. package/dist/environment/custom-types.d.ts +33 -0
  30. package/dist/environment/custom-types.d.ts.map +1 -0
  31. package/dist/environment/custom-types.js +12 -0
  32. package/dist/environment/derived-variables.d.ts +134 -0
  33. package/dist/environment/derived-variables.d.ts.map +1 -0
  34. package/dist/environment/derived-variables.js +169 -0
  35. package/dist/environment/editor-questions.d.ts +4 -0
  36. package/dist/environment/editor-questions.d.ts.map +1 -0
  37. package/dist/environment/editor-questions.js +67 -0
  38. package/dist/environment/git.d.ts +5 -0
  39. package/dist/environment/git.d.ts.map +1 -0
  40. package/dist/environment/git.js +38 -0
  41. package/dist/environment/github.d.ts +26 -0
  42. package/dist/environment/github.d.ts.map +1 -0
  43. package/dist/environment/github.js +247 -0
  44. package/dist/environment/index.d.ts +5 -0
  45. package/dist/environment/index.d.ts.map +1 -0
  46. package/dist/environment/index.js +71 -0
  47. package/dist/environment/logger.d.ts +15 -0
  48. package/dist/environment/logger.d.ts.map +1 -0
  49. package/dist/environment/logger.js +25 -0
  50. package/dist/environment/manage-users.d.ts +11 -0
  51. package/dist/environment/manage-users.d.ts.map +1 -0
  52. package/dist/environment/manage-users.js +497 -0
  53. package/dist/environment/questions-helper.d.ts +15 -0
  54. package/dist/environment/questions-helper.d.ts.map +1 -0
  55. package/dist/environment/questions-helper.js +70 -0
  56. package/dist/environment/questions.d.ts +199 -0
  57. package/dist/environment/questions.d.ts.map +1 -0
  58. package/dist/environment/questions.js +412 -0
  59. package/dist/environment/setup-environment.d.ts +2 -0
  60. package/dist/environment/setup-environment.d.ts.map +1 -0
  61. package/dist/environment/setup-environment.js +794 -0
  62. package/dist/environment/ssh-keygen.d.ts +5 -0
  63. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  64. package/dist/environment/ssh-keygen.js +21 -0
  65. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  66. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  67. package/dist/environment/swarm-to-k8s.js +173 -0
  68. package/dist/environment/templates.d.ts +27 -0
  69. package/dist/environment/templates.d.ts.map +1 -0
  70. package/dist/environment/templates.js +163 -0
  71. package/dist/environment/update-workflows.d.ts +2 -0
  72. package/dist/environment/update-workflows.d.ts.map +1 -0
  73. package/dist/environment/update-workflows.js +169 -0
  74. package/dist/environment/users.d.ts +2 -0
  75. package/dist/environment/users.d.ts.map +1 -0
  76. package/dist/environment/users.js +112 -0
  77. package/dist/environment/utils.d.ts +18 -0
  78. package/dist/environment/utils.d.ts.map +1 -0
  79. package/dist/environment/utils.js +100 -0
  80. package/dist/events/index.js +272 -39
  81. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  82. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  83. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  84. package/dist/migrations/v2.0/index.js +88 -5139
  85. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  86. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  87. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  88. package/dist/migrations/v2.1/index.d.ts +6 -0
  89. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  90. package/dist/migrations/v2.1/index.js +218 -0
  91. package/dist/notification/index.js +197 -28
  92. package/dist/scopes/index.d.ts +96 -2
  93. package/dist/scopes/index.js +12 -5
  94. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  95. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  96. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  97. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  98. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  99. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  100. package/dist/templates/inventory/inventory.template.yml +100 -0
  101. package/dist/templates/inventory/production.example.yml +77 -0
  102. package/dist/templates/inventory/qa.example.yml +48 -0
  103. package/opencrvs-toolkit-2.1.0-rc.0066f38.tgz +0 -0
  104. package/package.json +15 -1
  105. package/tsconfig.tsbuildinfo +1 -1
  106. package/opencrvs-toolkit-2.0.0.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",
@@ -520,11 +523,13 @@ var scopeOptionsPlaceEvent = z2.object({
520
523
  event: scopeByEvent,
521
524
  placeOfEvent: JurisdictionFilter.optional()
522
525
  }).describe("Options applicable to all record scopes.");
523
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
526
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
527
+ notifiedIn: JurisdictionFilter.optional(),
528
+ notifiedBy: UserFilter.optional(),
524
529
  declaredIn: JurisdictionFilter.optional(),
525
530
  declaredBy: UserFilter.optional()
526
531
  }).describe("Options applicable to actions that may take place after DECLARE");
527
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
532
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
528
533
  registeredIn: JurisdictionFilter.optional(),
529
534
  registeredBy: UserFilter.optional()
530
535
  }).describe(
@@ -562,6 +567,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
562
567
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
563
568
  );
564
569
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
570
+ notifiedIn: UUID.nullish(),
571
+ notifiedBy: z2.string().optional(),
565
572
  declaredIn: UUID.nullish(),
566
573
  declaredBy: z2.string().optional()
567
574
  }).describe(
@@ -582,6 +589,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
582
589
  "record.edit",
583
590
  "record.reject",
584
591
  "record.archive",
592
+ "record.unarchive",
585
593
  "record.review-duplicates",
586
594
  "record.register"
587
595
  ]);
@@ -607,7 +615,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
607
615
  }),
608
616
  z2.object({
609
617
  type: ScopesWithDeclaredOptions,
610
- options: scopeOptionsDeclared.optional()
618
+ options: scopeOptionsDeclaredOrNotified.optional()
611
619
  }),
612
620
  z2.object({
613
621
  type: ScopesWithFullOptions,
@@ -730,8 +738,9 @@ var decodeScope = (encodedScope) => {
730
738
  var DEFAULT_SCOPE_OPTIONS = {
731
739
  placeOfEvent: JurisdictionFilter.enum.all,
732
740
  accessLevel: JurisdictionFilter.enum.all,
733
- registeredIn: JurisdictionFilter.enum.all,
734
- declaredIn: JurisdictionFilter.enum.all
741
+ notifiedIn: JurisdictionFilter.enum.all,
742
+ declaredIn: JurisdictionFilter.enum.all,
743
+ registeredIn: JurisdictionFilter.enum.all
735
744
  };
736
745
  function getAcceptedScopesByType({
737
746
  acceptedScopes,
@@ -767,6 +776,7 @@ var ActionType = {
767
776
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
768
777
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
769
778
  ARCHIVE: "ARCHIVE",
779
+ UNARCHIVE: "UNARCHIVE",
770
780
  // Record actions
771
781
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
772
782
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -786,6 +796,7 @@ var ConfirmableActions = [
786
796
  ActionType.REGISTER,
787
797
  ActionType.REJECT,
788
798
  ActionType.ARCHIVE,
799
+ ActionType.UNARCHIVE,
789
800
  ActionType.PRINT_CERTIFICATE,
790
801
  ActionType.REQUEST_CORRECTION,
791
802
  ActionType.APPROVE_CORRECTION,
@@ -804,6 +815,7 @@ var ActionTypes = z4.enum([
804
815
  "MARK_AS_DUPLICATE",
805
816
  "MARK_AS_NOT_DUPLICATE",
806
817
  "ARCHIVE",
818
+ "UNARCHIVE",
807
819
  "PRINT_CERTIFICATE",
808
820
  "REQUEST_CORRECTION",
809
821
  "REJECT_CORRECTION",
@@ -847,6 +859,7 @@ var WorkqueueActionType = ActionTypes.extract([
847
859
  ActionType.REJECT,
848
860
  ActionType.MARK_AS_DUPLICATE,
849
861
  ActionType.ARCHIVE,
862
+ ActionType.UNARCHIVE,
850
863
  ActionType.PRINT_CERTIFICATE,
851
864
  ActionType.REQUEST_CORRECTION
852
865
  ]);
@@ -911,6 +924,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
911
924
  "event.actions.unassign.request",
912
925
  "event.actions.read.request",
913
926
  "event.actions.archive.request",
927
+ "event.actions.unarchive.request",
914
928
  "event.actions.reinstate.request",
915
929
  "event.actions.print_certificate.request",
916
930
  "event.actions.correction.request.request",
@@ -1644,6 +1658,11 @@ var ArchiveAction = ActionBase.extend(
1644
1658
  content: ReasonContent
1645
1659
  }).shape
1646
1660
  );
1661
+ var UnarchiveAction = ActionBase.extend(
1662
+ z14.object({
1663
+ type: z14.literal(ActionType.UNARCHIVE)
1664
+ }).shape
1665
+ );
1647
1666
  var CreatedAction = ActionBase.extend(
1648
1667
  z14.object({
1649
1668
  type: z14.literal(ActionType.CREATE)
@@ -1710,6 +1729,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1710
1729
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1711
1730
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1712
1731
  ArchiveAction.meta({ id: "ArchiveAction" }),
1732
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1713
1733
  NotifiedAction.meta({ id: "NotifiedAction" }),
1714
1734
  RegisterAction.meta({ id: "RegisterAction" }),
1715
1735
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1815,6 +1835,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1815
1835
  )
1816
1836
  });
1817
1837
  var LegalStatuses = z16.object({
1838
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1818
1839
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1819
1840
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1820
1841
  });
@@ -1956,6 +1977,8 @@ var eventMetadataLabelMap = {
1956
1977
  var EventMetadataDateFieldIdInput = z16.enum([
1957
1978
  "createdAt",
1958
1979
  "updatedAt",
1980
+ "legalStatuses.NOTIFIED.createdAt",
1981
+ "legalStatuses.NOTIFIED.acceptedAt",
1959
1982
  "legalStatuses.DECLARED.createdAt",
1960
1983
  "legalStatuses.DECLARED.acceptedAt",
1961
1984
  "legalStatuses.REGISTERED.createdAt",
@@ -1964,6 +1987,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1964
1987
  var EventMetadataDateFieldId = z16.enum([
1965
1988
  "event.createdAt",
1966
1989
  "event.updatedAt",
1990
+ "event.legalStatuses.NOTIFIED.createdAt",
1991
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1967
1992
  "event.legalStatuses.DECLARED.createdAt",
1968
1993
  "event.legalStatuses.DECLARED.acceptedAt",
1969
1994
  "event.legalStatuses.REGISTERED.createdAt",
@@ -2023,7 +2048,8 @@ var Range = import_v4.z.object({
2023
2048
  });
2024
2049
  var ContainsFlags = import_v4.z.object({
2025
2050
  anyOf: import_v4.z.array(Flag).optional(),
2026
- noneOf: import_v4.z.array(Flag).optional()
2051
+ noneOf: import_v4.z.array(Flag).optional(),
2052
+ allOf: import_v4.z.array(Flag).optional()
2027
2053
  }).meta({
2028
2054
  id: "ContainsFlags"
2029
2055
  });
@@ -3213,6 +3239,9 @@ var ActionConfigBase = z24.object({
3213
3239
  var DeclarationActionBase = ActionConfigBase.extend({
3214
3240
  deduplication: DeduplicationConfig.optional()
3215
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
+ );
3216
3245
  var ReadActionConfig = ActionConfigBase.extend(
3217
3246
  z24.object({
3218
3247
  type: z24.literal(ActionType.READ),
@@ -3222,12 +3251,65 @@ var ReadActionConfig = ActionConfigBase.extend(
3222
3251
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
3223
3252
  }).shape
3224
3253
  );
3254
+ var NotifyConfig = ActionConfigBase.extend(
3255
+ z24.object({
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)
3304
+ }).shape
3305
+ );
3225
3306
  var DeclareConfig = DeclarationActionBase.extend(
3226
3307
  z24.object({
3227
3308
  type: z24.literal(ActionType.DECLARE),
3228
3309
  review: DeclarationReviewConfig.describe(
3229
3310
  "Configuration of the review page fields."
3230
3311
  ),
3312
+ form: actionConfirmationForm,
3231
3313
  dialogCopy: z24.object({
3232
3314
  notify: TranslationConfig.describe(
3233
3315
  "Confirmation text for the notify action"
@@ -3243,7 +3325,13 @@ var DeclareConfig = DeclarationActionBase.extend(
3243
3325
  );
3244
3326
  var ArchiveConfig = ActionConfigBase.extend(
3245
3327
  z24.object({
3246
- 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)
3247
3335
  }).shape
3248
3336
  );
3249
3337
  var EditActionConfig = ActionConfigBase.extend(
@@ -3264,12 +3352,14 @@ var EditActionConfig = ActionConfigBase.extend(
3264
3352
  );
3265
3353
  var RejectConfig = ActionConfigBase.extend(
3266
3354
  z24.object({
3267
- type: z24.literal(ActionType.REJECT)
3355
+ type: z24.literal(ActionType.REJECT),
3356
+ form: actionConfirmationForm
3268
3357
  }).shape
3269
3358
  );
3270
3359
  var RegisterConfig = DeclarationActionBase.extend(
3271
3360
  z24.object({
3272
- type: z24.literal(ActionType.REGISTER)
3361
+ type: z24.literal(ActionType.REGISTER),
3362
+ form: actionConfirmationForm
3273
3363
  }).shape
3274
3364
  );
3275
3365
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -3284,7 +3374,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
3284
3374
  correctionForm: ActionFormConfig
3285
3375
  }).shape
3286
3376
  );
3287
- 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(
3288
3388
  z24.object({
3289
3389
  type: z24.literal(ActionType.CUSTOM),
3290
3390
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -3295,7 +3395,7 @@ var CustomActionConfig = ActionConfigBase.merge(
3295
3395
  auditHistoryLabel: TranslationConfig.describe(
3296
3396
  'The label to show in audit history for this action. For example "Approved".'
3297
3397
  )
3298
- })
3398
+ }).shape
3299
3399
  );
3300
3400
  var ActionConfig = z24.discriminatedUnion("type", [
3301
3401
  /*
@@ -3306,9 +3406,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
3306
3406
  id: "ReadActionConfig",
3307
3407
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
3308
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
+ }),
3421
+ NotifyConfig.meta({
3422
+ id: "NotifyActionConfig",
3423
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3424
+ }),
3309
3425
  DeclareConfig.meta({
3310
3426
  id: "DeclareActionConfig",
3311
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
3427
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
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."
3312
3440
  }),
3313
3441
  RejectConfig.meta({
3314
3442
  id: "RejectActionConfig",
@@ -3326,6 +3454,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
3326
3454
  id: "RequestCorrectionActionConfig",
3327
3455
  description: "Configuration for requesting a correction on a registered record."
3328
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
+ }),
3329
3465
  EditActionConfig.meta({
3330
3466
  id: "EditActionConfig",
3331
3467
  description: "Configuration for editing a record before registration."
@@ -3334,6 +3470,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
3334
3470
  id: "ArchiveActionConfig",
3335
3471
  description: "Configuration for archiving a record."
3336
3472
  }),
3473
+ UnarchiveConfig.meta({
3474
+ id: "UnarchiveActionConfig",
3475
+ description: "Configuration for unarchiving a record."
3476
+ }),
3337
3477
  CustomActionConfig.meta({
3338
3478
  id: "CustomActionConfig",
3339
3479
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4477,16 +4617,13 @@ function getActionConfig({
4477
4617
  actionType,
4478
4618
  customActionType
4479
4619
  }) {
4620
+ if (actionType === ActionType.NOTIFY) {
4621
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4622
+ }
4480
4623
  return eventConfiguration.actions.find((a) => {
4481
4624
  if (a.type === ActionType.CUSTOM && customActionType) {
4482
4625
  return a.customActionType === customActionType;
4483
4626
  }
4484
- if (actionType === ActionType.NOTIFY) {
4485
- return a.type === ActionType.DECLARE;
4486
- }
4487
- if (actionType === ActionType.APPROVE_CORRECTION || actionType === ActionType.REJECT_CORRECTION) {
4488
- return a.type === ActionType.REQUEST_CORRECTION;
4489
- }
4490
4627
  return a.type === actionType;
4491
4628
  });
4492
4629
  }
@@ -4496,7 +4633,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4496
4633
  customActionType,
4497
4634
  actionType: ActionType.CUSTOM
4498
4635
  });
4499
- 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) {
4500
4649
  return [];
4501
4650
  }
4502
4651
  return actionConfig.form;
@@ -4517,13 +4666,9 @@ var getActionAnnotationFields = (actionConfig) => {
4517
4666
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4518
4667
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4519
4668
  }
4520
- if (actionConfig.type === ActionType.CUSTOM) {
4521
- return actionConfig.form;
4522
- }
4523
- if ("review" in actionConfig) {
4524
- return actionConfig.review.fields;
4525
- }
4526
- 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];
4527
4672
  };
4528
4673
  function getAllAnnotationFields(config) {
4529
4674
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -5640,7 +5785,7 @@ function validateActionFlags(event2, ctx) {
5640
5785
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
5641
5786
  const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
5642
5787
  const actionFlagIds = event2.actions.flatMap(
5643
- (action) => action.flags.map((flag2) => flag2.id)
5788
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
5644
5789
  );
5645
5790
  for (const actionFlagId of actionFlagIds) {
5646
5791
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -6315,6 +6460,11 @@ var ArchiveActionInput = BaseActionInput.extend(
6315
6460
  content: ReasonContent
6316
6461
  }).shape
6317
6462
  );
6463
+ var UnarchiveActionInput = BaseActionInput.extend(
6464
+ z38.object({
6465
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
6466
+ }).shape
6467
+ );
6318
6468
  var AssignActionInput = BaseActionInput.extend(
6319
6469
  z38.object({
6320
6470
  type: z38.literal(ActionType.ASSIGN),
@@ -6376,6 +6526,7 @@ var ActionInput = z38.discriminatedUnion("type", [
6376
6526
  id: "MarkNotDuplicateActionInput"
6377
6527
  }),
6378
6528
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
6529
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
6379
6530
  AssignActionInput.meta({ id: "AssignActionInput" }),
6380
6531
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
6381
6532
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -6490,6 +6641,7 @@ var updateActions = ActionTypes.extract([
6490
6641
  ActionType.REGISTER,
6491
6642
  ActionType.REJECT,
6492
6643
  ActionType.ARCHIVE,
6644
+ ActionType.UNARCHIVE,
6493
6645
  ActionType.PRINT_CERTIFICATE,
6494
6646
  ActionType.REQUEST_CORRECTION,
6495
6647
  ActionType.APPROVE_CORRECTION,
@@ -6521,6 +6673,10 @@ function getActionUpdateMetadata(actions) {
6521
6673
  }
6522
6674
  function getLegalStatuses(actions) {
6523
6675
  return {
6676
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
6677
+ ActionType.NOTIFY,
6678
+ actions
6679
+ ),
6524
6680
  [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
6525
6681
  ActionType.DECLARE,
6526
6682
  actions
@@ -6607,15 +6763,12 @@ var INHERENT_FLAG_RULES = [
6607
6763
  },
6608
6764
  {
6609
6765
  // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
6610
- // 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.
6611
6769
  flag: InherentFlags.INCOMPLETE,
6612
6770
  setOn: [ActionType.NOTIFY],
6613
- resetOn: [
6614
- ActionType.CREATE,
6615
- ActionType.DECLARE,
6616
- ActionType.REGISTER,
6617
- ActionType.ARCHIVE
6618
- ]
6771
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
6619
6772
  },
6620
6773
  {
6621
6774
  flag: InherentFlags.REJECTED,
@@ -6679,7 +6832,7 @@ function resolveEventCustomFlags(event2, eventConfiguration) {
6679
6832
  const declaration = aggregateActionDeclarations(eventUpToThisAction);
6680
6833
  const annotation = aggregateActionAnnotations(eventUpToThisAction);
6681
6834
  const form = { ...declaration, ...annotation };
6682
- const flagsWithMetConditions = actionConfig.flags.filter(
6835
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
6683
6836
  ({ conditional }) => (
6684
6837
  // If conditional is not provided, the flag is resolved
6685
6838
  conditional ? isFlagConditionMet(conditional, form, action) : true
@@ -6725,7 +6878,27 @@ function getEventFlags(event2, config) {
6725
6878
 
6726
6879
  // ../commons/src/events/state/index.ts
6727
6880
  function getStatusFromActions(actions) {
6728
- 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) => {
6729
6902
  switch (action.type) {
6730
6903
  case ActionType.CREATE:
6731
6904
  return EventStatus.enum.CREATED;
@@ -6733,10 +6906,11 @@ function getStatusFromActions(actions) {
6733
6906
  return EventStatus.enum.DECLARED;
6734
6907
  case ActionType.REGISTER:
6735
6908
  return EventStatus.enum.REGISTERED;
6736
- case ActionType.ARCHIVE:
6737
- return EventStatus.enum.ARCHIVED;
6738
6909
  case ActionType.NOTIFY:
6739
6910
  return EventStatus.enum.NOTIFIED;
6911
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
6912
+ case ActionType.ARCHIVE:
6913
+ case ActionType.UNARCHIVE:
6740
6914
  case ActionType.CUSTOM:
6741
6915
  case ActionType.PRINT_CERTIFICATE:
6742
6916
  case ActionType.ASSIGN:
@@ -8284,6 +8458,20 @@ var tennisClubMembershipEvent = defineConfig({
8284
8458
  },
8285
8459
  review: TENNIS_CLUB_DECLARATION_REVIEW
8286
8460
  },
8461
+ {
8462
+ type: ActionType.NOTIFY,
8463
+ label: {
8464
+ defaultMessage: "Notify health worker",
8465
+ description: "This is shown as the action name anywhere the user can trigger the action from",
8466
+ id: "event.tennis-club-membership.action.notify.label"
8467
+ },
8468
+ flags: [
8469
+ {
8470
+ id: "health-worker-notified",
8471
+ operation: "add"
8472
+ }
8473
+ ]
8474
+ },
8287
8475
  {
8288
8476
  type: ActionType.REJECT,
8289
8477
  label: {
@@ -8526,6 +8714,17 @@ var tennisClubMembershipEvent = defineConfig({
8526
8714
  }
8527
8715
  }
8528
8716
  ],
8717
+ flags: [
8718
+ {
8719
+ id: "health-worker-notified",
8720
+ requiresAction: false,
8721
+ label: {
8722
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
8723
+ defaultMessage: "Health worker notified",
8724
+ description: "Label for the health-worker-notified flag"
8725
+ }
8726
+ }
8727
+ ],
8529
8728
  advancedSearch: [
8530
8729
  {
8531
8730
  title: {
@@ -9796,6 +9995,14 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9796
9995
  },
9797
9996
  ...input
9798
9997
  }),
9998
+ unarchive: (eventId, input = {}) => ({
9999
+ type: ActionType.UNARCHIVE,
10000
+ transactionId: input.transactionId ?? getUUID(),
10001
+ declaration: {},
10002
+ annotation: {},
10003
+ eventId,
10004
+ ...input
10005
+ }),
9799
10006
  reject: (eventId, input = {}) => ({
9800
10007
  type: ActionType.REJECT,
9801
10008
  transactionId: input.transactionId ?? getUUID(),
@@ -9954,6 +10161,7 @@ function generateActionDocument({
9954
10161
  case ActionType.NOTIFY:
9955
10162
  case ActionType.REGISTER:
9956
10163
  case ActionType.REQUEST_CORRECTION:
10164
+ case ActionType.UNARCHIVE:
9957
10165
  return { ...actionBase, type: action };
9958
10166
  case ActionType.EDIT:
9959
10167
  return {
@@ -10311,6 +10519,25 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
10311
10519
  }
10312
10520
  if (scopeUsesDeclaredOptions(scope)) {
10313
10521
  const { options } = scope;
10522
+ if (options?.notifiedBy === UserFilter.enum.user) {
10523
+ if (event2.legalStatuses?.NOTIFIED?.createdBy !== user2.id) {
10524
+ return false;
10525
+ }
10526
+ }
10527
+ if (options?.notifiedIn === JurisdictionFilter.enum.location && !matchesJurisdictionFilter(
10528
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10529
+ JurisdictionFilter.enum.location,
10530
+ user2
10531
+ )) {
10532
+ return false;
10533
+ }
10534
+ if (options?.notifiedIn === JurisdictionFilter.enum.administrativeArea && !matchesJurisdictionFilter(
10535
+ event2.legalStatuses?.NOTIFIED?.createdAtLocation,
10536
+ JurisdictionFilter.enum.administrativeArea,
10537
+ user2
10538
+ )) {
10539
+ return false;
10540
+ }
10314
10541
  if (options?.declaredBy === UserFilter.enum.user) {
10315
10542
  if (event2.legalStatuses?.DECLARED?.createdBy !== user2.id) {
10316
10543
  return false;
@@ -10453,6 +10680,7 @@ var ACTION_SCOPE_MAP = {
10453
10680
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
10454
10681
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
10455
10682
  [ActionType.ARCHIVE]: ["record.archive"],
10683
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
10456
10684
  [ActionType.REJECT]: ["record.reject"],
10457
10685
  [ActionType.ASSIGN]: null,
10458
10686
  [ActionType.UNASSIGN]: null,
@@ -10659,7 +10887,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
10659
10887
  ActionType.CUSTOM,
10660
10888
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
10661
10889
  ],
10662
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
10890
+ [EventStatus.enum.ARCHIVED]: [
10891
+ ActionType.READ,
10892
+ ActionType.CUSTOM,
10893
+ ActionType.UNARCHIVE
10894
+ ]
10663
10895
  };
10664
10896
  var ACTION_FILTERS = {
10665
10897
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -10672,6 +10904,7 @@ var ACTION_FILTERS = {
10672
10904
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
10673
10905
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
10674
10906
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10907
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10675
10908
  [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10676
10909
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
10677
10910
  [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
@@ -1,5 +1,5 @@
1
1
  export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
2
- export declare const UPSTREAM_BRANCH = "release-v2.0.0";
2
+ export declare const UPSTREAM_BRANCH = "release/2.0.0";
3
3
  /**
4
4
  * Runs a git command in the country config working directory.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAc/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAc9C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -59,7 +59,7 @@ exports.main = main;
59
59
  */
60
60
  const child_process_1 = require("child_process");
61
61
  exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
62
- exports.UPSTREAM_BRANCH = 'release-v2.0.0';
62
+ exports.UPSTREAM_BRANCH = 'release/2.0.0';
63
63
  // Remote name used only for the duration of this codemod. Prefixed to avoid
64
64
  // clashing with remotes the user may have (origin, upstream, etc.).
65
65
  const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';