@opencrvs/toolkit 2.1.0 → 2.2.0-rc.3af310b

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 (136) hide show
  1. package/build.sh +2 -12
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +36 -4
  4. package/dist/authentication/index.js +14 -2
  5. package/dist/cli.js +961 -2033
  6. package/dist/commons/api/router.d.ts +1374 -71
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/events/ActionConfig.d.ts +146 -20
  9. package/dist/commons/events/ActionDocument.d.ts +88 -0
  10. package/dist/commons/events/ActionInput.d.ts +52 -0
  11. package/dist/commons/events/ActionType.d.ts +11 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/AuditLog.d.ts +4 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +192 -18
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventConfig.d.ts +36 -6
  17. package/dist/commons/events/EventDocument.d.ts +88 -0
  18. package/dist/commons/events/EventIndex.d.ts +41 -4
  19. package/dist/commons/events/EventMetadata.d.ts +23 -1
  20. package/dist/commons/events/EventStatus.d.ts +1 -0
  21. package/dist/commons/events/FieldConfig.d.ts +10 -0
  22. package/dist/commons/events/Flag.d.ts +0 -6
  23. package/dist/commons/events/WorkqueueConfig.d.ts +224 -33
  24. package/dist/commons/events/eventConfigValidation.d.ts +26 -1
  25. package/dist/commons/events/notificationFormFallback.d.ts +10 -0
  26. package/dist/commons/events/scopes.d.ts +2 -0
  27. package/dist/commons/events/state/flags.d.ts +1 -1
  28. package/dist/commons/events/state/index.d.ts +10 -2
  29. package/dist/commons/events/state/utils.d.ts +11 -1
  30. package/dist/commons/events/test.utils.d.ts +31 -1
  31. package/dist/commons/events/utils.d.ts +53 -20
  32. package/dist/conditionals/index.js +14 -2
  33. package/dist/environment/derived-variables.d.ts +24 -0
  34. package/dist/environment/derived-variables.d.ts.map +1 -1
  35. package/dist/environment/derived-variables.js +28 -0
  36. package/dist/environment/dockerhub.d.ts +15 -0
  37. package/dist/environment/dockerhub.d.ts.map +1 -0
  38. package/dist/environment/dockerhub.js +104 -0
  39. package/dist/environment/questions.js +1 -1
  40. package/dist/environment/setup-environment.d.ts.map +1 -1
  41. package/dist/environment/setup-environment.js +70 -12
  42. package/dist/environment/templates.d.ts.map +1 -1
  43. package/dist/events/index.js +461 -83
  44. package/dist/migrations/index.d.ts +9 -0
  45. package/dist/migrations/index.d.ts.map +1 -0
  46. package/dist/migrations/index.js +847 -0
  47. package/dist/migrations/move-declaration-to-declare-action.d.ts +38 -0
  48. package/dist/migrations/move-declaration-to-declare-action.d.ts.map +1 -0
  49. package/dist/migrations/move-declaration-to-declare-action.js +377 -0
  50. package/dist/migrations/{v2.1 → persistent}/add-translations.d.ts +7 -1
  51. package/dist/migrations/persistent/add-translations.d.ts.map +1 -0
  52. package/dist/migrations/{v2.1 → persistent}/add-translations.js +14 -12
  53. package/dist/migrations/persistent/check-upgrade-path.d.ts +36 -0
  54. package/dist/migrations/persistent/check-upgrade-path.d.ts.map +1 -0
  55. package/dist/migrations/persistent/check-upgrade-path.js +105 -0
  56. package/dist/migrations/persistent/update-toolkit-dependency.d.ts +7 -0
  57. package/dist/migrations/persistent/update-toolkit-dependency.d.ts.map +1 -0
  58. package/dist/migrations/persistent/update-toolkit-dependency.js +77 -0
  59. package/dist/migrations/read-declaration-through-helper.d.ts +39 -0
  60. package/dist/migrations/read-declaration-through-helper.d.ts.map +1 -0
  61. package/dist/migrations/read-declaration-through-helper.js +257 -0
  62. package/dist/migrations/replace-incomplete-flag.d.ts +26 -0
  63. package/dist/migrations/replace-incomplete-flag.d.ts.map +1 -0
  64. package/dist/migrations/replace-incomplete-flag.js +126 -0
  65. package/dist/notification/index.js +401 -100
  66. package/dist/scopes/index.d.ts +29 -39
  67. package/dist/scopes/index.js +14 -2
  68. package/dist/templates/charts-values/dependencies/values.yaml +1 -1
  69. package/dist/templates/charts-values/opencrvs-services/values.yaml +1 -2
  70. package/dist/templates/charts-values/traefik/values.yaml +4 -3
  71. package/opencrvs-toolkit-2.2.0-rc.3af310b.tgz +0 -0
  72. package/package.json +1 -1
  73. package/tsconfig.build.tsbuildinfo +1 -1
  74. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +0 -3
  75. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +0 -1
  76. package/dist/migrations/v2.1/add-explicit-correction-flags.js +0 -234
  77. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +0 -3
  78. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +0 -1
  79. package/dist/migrations/v2.1/add-recovery-link-notifications.js +0 -511
  80. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  81. package/dist/migrations/v2.1/enable-telemetry.d.ts +0 -3
  82. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +0 -1
  83. package/dist/migrations/v2.1/enable-telemetry.js +0 -455
  84. package/dist/migrations/v2.1/index.d.ts +0 -6
  85. package/dist/migrations/v2.1/index.d.ts.map +0 -1
  86. package/dist/migrations/v2.1/index.js +0 -2170
  87. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +0 -14
  88. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +0 -1
  89. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.js +0 -348
  90. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts +0 -2
  91. package/dist/migrations/v2.1/remove-metabase-package-installs.d.ts.map +0 -1
  92. package/dist/migrations/v2.1/remove-metabase-package-installs.js +0 -161
  93. package/dist/migrations/v2.1/remove-sentry.d.ts +0 -3
  94. package/dist/migrations/v2.1/remove-sentry.d.ts.map +0 -1
  95. package/dist/migrations/v2.1/remove-sentry.js +0 -354
  96. package/dist/migrations/v2.1/rename-trigger-paths.d.ts +0 -3
  97. package/dist/migrations/v2.1/rename-trigger-paths.d.ts.map +0 -1
  98. package/dist/migrations/v2.1/rename-trigger-paths.js +0 -216
  99. package/dist/migrations/v2.1/template-files.d.ts +0 -8
  100. package/dist/migrations/v2.1/template-files.d.ts.map +0 -1
  101. package/dist/migrations/v2.1/template-files.js +0 -49
  102. package/dist/migrations/v2.1/upgrade-tilt.d.ts +0 -8
  103. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +0 -1
  104. package/dist/migrations/v2.1/upgrade-tilt.js +0 -139
  105. package/dist/templates/countryconfig-template/.tiltignore +0 -1
  106. package/dist/templates/countryconfig-template/Dockerfile.assets +0 -7
  107. package/dist/templates/countryconfig-template/Tiltfile +0 -112
  108. package/dist/templates/countryconfig-template/assets/README.md +0 -1
  109. package/dist/templates/countryconfig-template/assets/clear-all-data-dev.sh +0 -61
  110. package/dist/templates/countryconfig-template/assets/deployment/deploy.sh +0 -455
  111. package/dist/templates/countryconfig-template/assets/deployment/reindex.sh +0 -168
  112. package/dist/templates/countryconfig-template/assets/deployment/validate-required-variables-in-compose-files.ts +0 -67
  113. package/dist/templates/countryconfig-template/assets/elasticsearch/reindex.sh +0 -168
  114. package/dist/templates/countryconfig-template/assets/metabase/README.md +0 -34
  115. package/dist/templates/countryconfig-template/assets/metabase/environment-configuration.sql +0 -36
  116. package/dist/templates/countryconfig-template/assets/metabase/initialize-database.sh +0 -46
  117. package/dist/templates/countryconfig-template/assets/metabase/metabase.init.db.sql +0 -27737
  118. package/dist/templates/countryconfig-template/assets/metabase/open-shell.sh +0 -21
  119. package/dist/templates/countryconfig-template/assets/metabase/package.json +0 -13
  120. package/dist/templates/countryconfig-template/assets/metabase/run-dev.sh +0 -108
  121. package/dist/templates/countryconfig-template/assets/metabase/run.sh +0 -120
  122. package/dist/templates/countryconfig-template/assets/metabase/update-database.sh +0 -40
  123. package/dist/templates/countryconfig-template/assets/postgres/setup-analytics.sh +0 -135
  124. package/dist/templates/countryconfig-template/assets/postgres/setup-reference-data.sh +0 -108
  125. package/dist/templates/countryconfig-template/tilt/clear-all-data.ps1 +0 -50
  126. package/dist/templates/countryconfig-template/tilt/clear-all-data.sh +0 -35
  127. package/dist/templates/countryconfig-template/tilt/common.tilt +0 -145
  128. package/dist/templates/countryconfig-template/tilt/examples/dependencies/values.yaml +0 -15
  129. package/dist/templates/countryconfig-template/tilt/examples/opencrvs-services/values.yaml +0 -56
  130. package/dist/templates/countryconfig-template/tilt/examples/traefik/values-minikube.yaml +0 -21
  131. package/dist/templates/countryconfig-template/tilt/examples/traefik/values.yaml +0 -38
  132. package/dist/templates/countryconfig-template/tilt/helm/dependencies/values.yaml +0 -17
  133. package/dist/templates/countryconfig-template/tilt/helm/opencrvs-services/values.yaml +0 -16
  134. package/dist/templates/countryconfig-template/tilt/lib.tilt +0 -95
  135. package/dist/templates/countryconfig-template/tilt/opencrvs.tilt +0 -136
  136. package/opencrvs-toolkit-2.1.0.tgz +0 -0
@@ -180,6 +180,7 @@ __export(events_exports, {
180
180
  NameFieldUpdateValue: () => NameFieldUpdateValue,
181
181
  NameFieldValue: () => NameFieldValue,
182
182
  NonEmptyTextValue: () => NonEmptyTextValue,
183
+ NoneOfStatus: () => NoneOfStatus,
183
184
  NotifyActionInput: () => NotifyActionInput,
184
185
  NumberFieldValue: () => NumberFieldValue,
185
186
  NumberWithUnitFieldUpdateValue: () => NumberWithUnitFieldUpdateValue,
@@ -203,10 +204,12 @@ __export(events_exports, {
203
204
  RegisterAction: () => RegisterAction,
204
205
  RegisterActionInput: () => RegisterActionInput,
205
206
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
207
+ ReinstateRegistrationActionInput: () => ReinstateRegistrationActionInput,
206
208
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
207
209
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
208
210
  RejectedCorrectionAction: () => RejectedCorrectionAction,
209
211
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
212
+ RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
210
213
  SearchQuery: () => SearchQuery,
211
214
  SearchQueryParams: () => SearchQueryParams,
212
215
  SeededLocationVersions: () => SeededLocationVersions,
@@ -364,6 +367,8 @@ __export(events_exports, {
364
367
  getLeafAdministrativeAreaIds: () => getLeafAdministrativeAreaIds,
365
368
  getLocationHierarchy: () => getLocationHierarchy,
366
369
  getMixedPath: () => getMixedPath,
370
+ getNotificationFields: () => getNotificationFields,
371
+ getNotificationForm: () => getNotificationForm,
367
372
  getPendingAction: () => getPendingAction,
368
373
  getPrintCertificatePages: () => getPrintCertificatePages,
369
374
  getRandomDate: () => getRandomDate,
@@ -482,6 +487,7 @@ __export(events_exports, {
482
487
  validateFieldInput: () => validateFieldInput,
483
488
  validateValue: () => validateValue,
484
489
  window: () => window2,
490
+ withDeclaration: () => withDeclaration,
485
491
  writeActions: () => writeActions
486
492
  });
487
493
  module.exports = __toCommonJS(events_exports);
@@ -529,6 +535,8 @@ var ActionType = {
529
535
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
530
536
  REJECT_CORRECTION: "REJECT_CORRECTION",
531
537
  APPROVE_CORRECTION: "APPROVE_CORRECTION",
538
+ REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
539
+ REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
532
540
  // General actions
533
541
  READ: "READ",
534
542
  ASSIGN: "ASSIGN",
@@ -548,6 +556,8 @@ var ConfirmableActions = [
548
556
  ActionType.REQUEST_CORRECTION,
549
557
  ActionType.APPROVE_CORRECTION,
550
558
  ActionType.REJECT_CORRECTION,
559
+ ActionType.REVOKE_REGISTRATION,
560
+ ActionType.REINSTATE_REGISTRATION,
551
561
  ActionType.CUSTOM
552
562
  ];
553
563
  var ActionTypes = z2.enum([
@@ -567,6 +577,8 @@ var ActionTypes = z2.enum([
567
577
  "REQUEST_CORRECTION",
568
578
  "REJECT_CORRECTION",
569
579
  "APPROVE_CORRECTION",
580
+ "REVOKE_REGISTRATION",
581
+ "REINSTATE_REGISTRATION",
570
582
  "READ",
571
583
  "ASSIGN",
572
584
  "UNASSIGN",
@@ -608,7 +620,9 @@ var WorkqueueActionType = ActionTypes.extract([
608
620
  ActionType.ARCHIVE,
609
621
  ActionType.UNARCHIVE,
610
622
  ActionType.PRINT_CERTIFICATE,
611
- ActionType.REQUEST_CORRECTION
623
+ ActionType.REQUEST_CORRECTION,
624
+ ActionType.REVOKE_REGISTRATION,
625
+ ActionType.REINSTATE_REGISTRATION
612
626
  ]);
613
627
  var META_ACTIONS = [
614
628
  ActionType.ASSIGN,
@@ -696,7 +710,6 @@ var FieldConditional = z4.discriminatedUnion("type", [
696
710
 
697
711
  // ../commons/src/events/Flag.ts
698
712
  var InherentFlags = {
699
- INCOMPLETE: "incomplete",
700
713
  REJECTED: "rejected",
701
714
  CORRECTION_REQUESTED: "correction-requested",
702
715
  POTENTIAL_DUPLICATE: "potential-duplicate",
@@ -763,6 +776,7 @@ var EventStatus = z6.enum([
763
776
  "NOTIFIED",
764
777
  "DECLARED",
765
778
  "REGISTERED",
779
+ "REVOKED",
766
780
  "ARCHIVED"
767
781
  ]);
768
782
 
@@ -786,6 +800,8 @@ var RecordScopeTypeV2 = z7.enum([
786
800
  "record.print-certified-copies",
787
801
  "record.request-correction",
788
802
  "record.correct",
803
+ "record.revoke-registration",
804
+ "record.reinstate-registration",
789
805
  "record.unassign-others",
790
806
  "record.custom-action",
791
807
  "record.action.accept",
@@ -912,6 +928,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
912
928
  "record.read",
913
929
  "record.request-correction",
914
930
  "record.correct",
931
+ "record.revoke-registration",
932
+ "record.reinstate-registration",
915
933
  "record.unassign-others",
916
934
  "record.review-duplicates"
917
935
  ]);
@@ -1156,6 +1174,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
1156
1174
  "event.actions.correction.request.request",
1157
1175
  "event.actions.correction.approve.request",
1158
1176
  "event.actions.correction.reject.request",
1177
+ "event.actions.revoke_registration.request",
1178
+ "event.actions.reinstate_registration.request",
1159
1179
  "event.actions.mark_as_duplicate.request",
1160
1180
  "event.actions.mark_as_not_duplicate.request"
1161
1181
  ]),
@@ -1910,6 +1930,16 @@ var UnarchiveAction = ActionBase.extend(
1910
1930
  type: z16.literal(ActionType.UNARCHIVE)
1911
1931
  }).shape
1912
1932
  );
1933
+ var RevokeRegistrationAction = ActionBase.extend(
1934
+ z16.object({
1935
+ type: z16.literal(ActionType.REVOKE_REGISTRATION)
1936
+ }).shape
1937
+ );
1938
+ var ReinstateRegistrationAction = ActionBase.extend(
1939
+ z16.object({
1940
+ type: z16.literal(ActionType.REINSTATE_REGISTRATION)
1941
+ }).shape
1942
+ );
1913
1943
  var CreatedAction = ActionBase.extend(
1914
1944
  z16.object({
1915
1945
  type: z16.literal(ActionType.CREATE)
@@ -1978,6 +2008,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
1978
2008
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1979
2009
  ArchiveAction.meta({ id: "ArchiveAction" }),
1980
2010
  UnarchiveAction.meta({ id: "UnarchiveAction" }),
2011
+ RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
2012
+ ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
1981
2013
  NotifiedAction.meta({ id: "NotifiedAction" }),
1982
2014
  RegisterAction.meta({ id: "RegisterAction" }),
1983
2015
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -2026,7 +2058,8 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2026
2058
  var LegalStatuses = z17.object({
2027
2059
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
2028
2060
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2029
- [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2061
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
2062
+ [EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
2030
2063
  });
2031
2064
  var EventMetadata = z17.object({
2032
2065
  id: UUID,
@@ -2228,6 +2261,12 @@ var AnyOfStatus = import_v4.z.object({
2228
2261
  }).meta({
2229
2262
  id: "AnyOfStatus"
2230
2263
  });
2264
+ var NoneOfStatus = import_v4.z.object({
2265
+ type: import_v4.z.literal("noneOf"),
2266
+ terms: import_v4.z.array(EventStatus)
2267
+ }).meta({
2268
+ id: "NoneOfStatus"
2269
+ });
2231
2270
  var Range = import_v4.z.object({
2232
2271
  type: import_v4.z.literal("range"),
2233
2272
  gte: import_v4.z.string(),
@@ -2268,7 +2307,7 @@ var QueryInput = import_v4.z.lazy(
2268
2307
  var QueryExpression = import_v4.z.object({
2269
2308
  id: import_v4.z.optional(import_v4.z.string()),
2270
2309
  eventType: import_v4.z.string(),
2271
- status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
2310
+ status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
2272
2311
  createdAt: import_v4.z.optional(DateCondition),
2273
2312
  updatedAt: import_v4.z.optional(DateCondition),
2274
2313
  "legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
@@ -2277,6 +2316,7 @@ var QueryExpression = import_v4.z.object({
2277
2316
  "legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2278
2317
  "legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
2279
2318
  "legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
2319
+ "legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2280
2320
  createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2281
2321
  updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2282
2322
  assignedTo: import_v4.z.optional(Exact),
@@ -3477,6 +3517,12 @@ var ReadActionConfig = ActionConfigBase.extend(
3477
3517
  var NotifyConfig = ActionConfigBase.extend(
3478
3518
  z25.object({
3479
3519
  type: z25.literal(ActionType.NOTIFY),
3520
+ notificationForm: DeclarationFormConfig.optional().describe(
3521
+ "Notification form configuration. Its fields must be a subset of the declaration form fields, with matching types. The values submitted on the notification form pre-fill the declaration. If not defined, the declare action's declaration is used (with all fields optional)."
3522
+ ),
3523
+ review: DeclarationReviewConfig.describe(
3524
+ "Review page configuration for the notify action. Values of its fields are stored as the NOTIFY action annotation. If not defined, defineConfig generates it from the declare action's review (with all fields optional)."
3525
+ ),
3480
3526
  form: actionConfirmationForm
3481
3527
  }).shape
3482
3528
  );
@@ -3529,6 +3575,9 @@ var DeleteConfig = ActionConfigBase.extend(
3529
3575
  var DeclareConfig = DeclarationActionBase.extend(
3530
3576
  z25.object({
3531
3577
  type: z25.literal(ActionType.DECLARE),
3578
+ declaration: DeclarationFormConfig.describe(
3579
+ "Configuration of the form used to gather event data."
3580
+ ),
3532
3581
  review: DeclarationReviewConfig.describe(
3533
3582
  "Configuration of the review page fields."
3534
3583
  ),
@@ -3557,6 +3606,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
3557
3606
  type: z25.literal(ActionType.UNARCHIVE)
3558
3607
  }).shape
3559
3608
  );
3609
+ var RevokeRegistrationConfig = ActionConfigBase.extend(
3610
+ z25.object({
3611
+ type: z25.literal(ActionType.REVOKE_REGISTRATION),
3612
+ form: actionConfirmationForm
3613
+ }).shape
3614
+ );
3615
+ var ReinstateRegistrationConfig = ActionConfigBase.extend(
3616
+ z25.object({
3617
+ type: z25.literal(ActionType.REINSTATE_REGISTRATION),
3618
+ form: actionConfirmationForm
3619
+ }).shape
3620
+ );
3560
3621
  var EditActionConfig = ActionConfigBase.extend(
3561
3622
  z25.object({
3562
3623
  type: z25.literal(ActionType.EDIT),
@@ -3643,11 +3704,11 @@ var ActionConfig = z25.discriminatedUnion("type", [
3643
3704
  }),
3644
3705
  NotifyConfig.meta({
3645
3706
  id: "NotifyActionConfig",
3646
- description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3707
+ description: "Configuration for the notify action, including the notification form and its review page. When undefined, it is generated using the DeclareActionConfig."
3647
3708
  }),
3648
3709
  DeclareConfig.meta({
3649
3710
  id: "DeclareActionConfig",
3650
- description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3711
+ description: "Configuration for the declare action. Includes the declaration form and review-page fields."
3651
3712
  }),
3652
3713
  DuplicateDetectedConfig.meta({
3653
3714
  id: "DuplicateDetectedActionConfig",
@@ -3697,6 +3758,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
3697
3758
  id: "UnarchiveActionConfig",
3698
3759
  description: "Configuration for unarchiving a record."
3699
3760
  }),
3761
+ RevokeRegistrationConfig.meta({
3762
+ id: "RevokeRegistrationActionConfig",
3763
+ description: "Configuration for revoking a registered record."
3764
+ }),
3765
+ ReinstateRegistrationConfig.meta({
3766
+ id: "ReinstateRegistrationActionConfig",
3767
+ description: "Configuration for reinstating a revoked record back to registered."
3768
+ }),
3700
3769
  CustomActionConfig.meta({
3701
3770
  id: "CustomActionConfig",
3702
3771
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4508,6 +4577,8 @@ var updateActions = new Set(
4508
4577
  ActionType.REQUEST_CORRECTION,
4509
4578
  ActionType.APPROVE_CORRECTION,
4510
4579
  ActionType.REJECT_CORRECTION,
4580
+ ActionType.REVOKE_REGISTRATION,
4581
+ ActionType.REINSTATE_REGISTRATION,
4511
4582
  ActionType.CUSTOM
4512
4583
  ]).options
4513
4584
  );
@@ -4534,7 +4605,7 @@ function getActionUpdateMetadata(actions) {
4534
4605
  (0, import_lodash.pick)(createAction, metadataFields)
4535
4606
  );
4536
4607
  }
4537
- function getLegalStatuses(actions) {
4608
+ function getLegalStatuses(actions, status2) {
4538
4609
  return {
4539
4610
  [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
4540
4611
  ActionType.NOTIFY,
@@ -4547,7 +4618,12 @@ function getLegalStatuses(actions) {
4547
4618
  [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
4548
4619
  ActionType.REGISTER,
4549
4620
  actions
4550
- )
4621
+ ),
4622
+ // A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
4623
+ [EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
4624
+ ActionType.REVOKE_REGISTRATION,
4625
+ actions
4626
+ ) : null
4551
4627
  };
4552
4628
  }
4553
4629
 
@@ -4624,15 +4700,6 @@ var INHERENT_FLAG_RULES = [
4624
4700
  setOn: [ActionType.REQUEST_CORRECTION],
4625
4701
  resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4626
4702
  },
4627
- {
4628
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4629
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4630
- // are deliberately excluded so the flag freezes across an archive/unarchive
4631
- // round trip and comes back exactly as it was.
4632
- flag: InherentFlags.INCOMPLETE,
4633
- setOn: [ActionType.NOTIFY],
4634
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4635
- },
4636
4703
  {
4637
4704
  flag: InherentFlags.REJECTED,
4638
4705
  setOn: [ActionType.REJECT],
@@ -5417,6 +5484,10 @@ function getStatusFromActions(actions) {
5417
5484
  return EventStatus.enum.REGISTERED;
5418
5485
  case ActionType.NOTIFY:
5419
5486
  return EventStatus.enum.NOTIFIED;
5487
+ case ActionType.REVOKE_REGISTRATION:
5488
+ return EventStatus.enum.REVOKED;
5489
+ case ActionType.REINSTATE_REGISTRATION:
5490
+ return EventStatus.enum.REGISTERED;
5420
5491
  // Already filtered out above; listed here only to satisfy exhaustiveness.
5421
5492
  case ActionType.ARCHIVE:
5422
5493
  case ActionType.UNARCHIVE:
@@ -5534,7 +5605,7 @@ function getCurrentEventState(event2, config) {
5534
5605
  const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
5535
5606
  const declaration = aggregateActionDeclarations(event2);
5536
5607
  const status2 = getStatusFromActions(sortedActions);
5537
- const legalStatuses = getLegalStatuses(sortedActions);
5608
+ const legalStatuses = getLegalStatuses(sortedActions, status2);
5538
5609
  const base = deepDropNulls({
5539
5610
  id: event2.id,
5540
5611
  type: event2.type,
@@ -6203,20 +6274,81 @@ function areCertificateConditionsMet(conditions, values) {
6203
6274
  });
6204
6275
  }
6205
6276
 
6277
+ // ../commons/src/events/notificationFormFallback.ts
6278
+ function toOptionalField(field3) {
6279
+ const { validation: _validation, ...rest } = field3;
6280
+ if (rest.type === FieldType.FIELD_GROUP && "fields" in rest) {
6281
+ return {
6282
+ ...rest,
6283
+ required: false,
6284
+ fields: rest.fields.map(toOptionalField)
6285
+ };
6286
+ }
6287
+ return { ...rest, required: false };
6288
+ }
6289
+ function deriveNotificationForm(declaration) {
6290
+ return {
6291
+ ...declaration,
6292
+ pages: declaration.pages.map((page) => ({
6293
+ ...page,
6294
+ fields: page.fields.map(toOptionalField)
6295
+ }))
6296
+ };
6297
+ }
6298
+ function generateNotifyReview(declareReview) {
6299
+ return {
6300
+ ...declareReview,
6301
+ fields: declareReview.fields.map(toOptionalField)
6302
+ };
6303
+ }
6304
+
6206
6305
  // ../commons/src/events/utils.ts
6207
6306
  var import_date_fns3 = require("date-fns");
6208
6307
  function ageToDate(age, asOfDate) {
6209
6308
  const date = plainDateToLocalDate(asOfDate);
6210
6309
  return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
6211
6310
  }
6212
- function getDeclarationFields(configuration) {
6213
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
6311
+ function getDeclaration(configuration) {
6312
+ const declareAction = configuration.actions.find(
6313
+ (action) => action.type === ActionType.DECLARE
6314
+ );
6315
+ if (!declareAction) {
6316
+ throw new Error(
6317
+ `Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
6318
+ );
6319
+ }
6320
+ return declareAction.declaration;
6214
6321
  }
6215
6322
  function getDeclarationPages(configuration) {
6216
- return configuration.declaration.pages;
6323
+ return getDeclaration(configuration).pages;
6217
6324
  }
6218
- function getDeclaration(configuration) {
6219
- return configuration.declaration;
6325
+ function getDeclarationFields(configuration) {
6326
+ return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6327
+ }
6328
+ function getConfiguredNotificationForm(configuration) {
6329
+ const notifyAction = configuration.actions.find(
6330
+ (action) => action.type === ActionType.NOTIFY
6331
+ );
6332
+ return notifyAction?.type === ActionType.NOTIFY ? notifyAction.notificationForm : void 0;
6333
+ }
6334
+ var derivedNotificationForms = /* @__PURE__ */ new WeakMap();
6335
+ function getNotificationForm(configuration) {
6336
+ const configured = getConfiguredNotificationForm(configuration);
6337
+ if (configured) {
6338
+ return configured;
6339
+ }
6340
+ const cached = derivedNotificationForms.get(configuration);
6341
+ if (cached) {
6342
+ return cached;
6343
+ }
6344
+ const derived = deriveNotificationForm(getDeclaration(configuration));
6345
+ derivedNotificationForms.set(configuration, derived);
6346
+ return derived;
6347
+ }
6348
+ function getNotificationFields(configuration) {
6349
+ return getNotificationForm(configuration).pages.flatMap(
6350
+ ({ fields }) => fields
6351
+ );
6220
6352
  }
6221
6353
  function isActionConfigType(type) {
6222
6354
  return actionConfigTypes.has(type);
@@ -6226,9 +6358,6 @@ function getActionConfig({
6226
6358
  actionType,
6227
6359
  customActionType
6228
6360
  }) {
6229
- if (actionType === ActionType.NOTIFY) {
6230
- return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
6231
- }
6232
6361
  return eventConfiguration.actions.find((a) => {
6233
6362
  if (a.type === ActionType.CUSTOM && customActionType) {
6234
6363
  return a.customActionType === customActionType;
@@ -6481,6 +6610,10 @@ function isWriteAction(actionType) {
6481
6610
  var findAllFields = (config) => {
6482
6611
  return (0, import_lodash4.flattenDeep)([
6483
6612
  ...getDeclarationFields(config),
6613
+ // Only a configured notification form: a derived one repeats the declaration fields.
6614
+ ...getConfiguredNotificationForm(config)?.pages.flatMap(
6615
+ ({ fields }) => fields
6616
+ ) ?? [],
6484
6617
  ...getAllAnnotationFields(config)
6485
6618
  ]);
6486
6619
  };
@@ -6837,6 +6970,82 @@ function validateActionOrder(event2, ctx) {
6837
6970
  }
6838
6971
  }
6839
6972
  }
6973
+ function validateExactlyOneDeclareAction(event2, ctx) {
6974
+ const declareActionCount = event2.actions.filter(
6975
+ (action) => action.type === ActionType.DECLARE
6976
+ ).length;
6977
+ if (declareActionCount !== 1) {
6978
+ ctx.addIssue({
6979
+ code: "custom",
6980
+ message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
6981
+ path: ["actions"]
6982
+ });
6983
+ return false;
6984
+ }
6985
+ return true;
6986
+ }
6987
+ function validateDeclarationGivenExactlyOnce(config, ctx) {
6988
+ const declareActionIndex = config.actions.findIndex(
6989
+ (action) => action.type === ActionType.DECLARE
6990
+ );
6991
+ const declareAction = config.actions[declareActionIndex];
6992
+ const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
6993
+ const onTopLevel = !!config.declaration;
6994
+ const declareActionPath = `actions[${declareActionIndex}].declaration`;
6995
+ if (onTopLevel && onDeclareAction) {
6996
+ ctx.addIssue({
6997
+ code: "custom",
6998
+ message: `Event '${config.id}' defines \`declaration\` both at the top level and on the ${ActionType.DECLARE} action (\`${declareActionPath}\`). Define it in only one of these places.`,
6999
+ path: ["declaration"]
7000
+ });
7001
+ }
7002
+ if (!onTopLevel && !onDeclareAction) {
7003
+ ctx.addIssue({
7004
+ code: "custom",
7005
+ message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
7006
+ path: ["declaration"]
7007
+ });
7008
+ }
7009
+ }
7010
+ function validateNotificationForm(event2, ctx) {
7011
+ const declarationFields = getDeclarationFields(event2);
7012
+ event2.actions.forEach((action, actionIndex) => {
7013
+ if (action.type !== ActionType.NOTIFY || !action.notificationForm) {
7014
+ return;
7015
+ }
7016
+ action.notificationForm.pages.forEach((page, pageIndex) => {
7017
+ page.fields.forEach((field3, fieldIndex) => {
7018
+ const path = [
7019
+ "actions",
7020
+ actionIndex,
7021
+ "notificationForm",
7022
+ "pages",
7023
+ pageIndex,
7024
+ "fields",
7025
+ fieldIndex
7026
+ ];
7027
+ const matchingFields = declarationFields.filter(
7028
+ ({ id }) => id === field3.id
7029
+ );
7030
+ if (matchingFields.length === 0) {
7031
+ ctx.addIssue({
7032
+ code: "custom",
7033
+ message: `Notification form field '${field3.id}' does not exist in the declaration form of event '${event2.id}'. Notification form fields must also be defined in the ${ActionType.DECLARE} action's declaration.`,
7034
+ path
7035
+ });
7036
+ return;
7037
+ }
7038
+ if (!matchingFields.some(({ type }) => type === field3.type)) {
7039
+ ctx.addIssue({
7040
+ code: "custom",
7041
+ message: `Notification form field '${field3.id}' is of type ${field3.type}, but the declaration form field with the same id in event '${event2.id}' is of type ${matchingFields[0].type}.`,
7042
+ path
7043
+ });
7044
+ }
7045
+ });
7046
+ });
7047
+ });
7048
+ }
6840
7049
 
6841
7050
  // ../commons/src/events/EventConfig.ts
6842
7051
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
@@ -6861,16 +7070,15 @@ var _EventConfigBase = z35.object({
6861
7070
  summary: SummaryConfig.describe(
6862
7071
  "Summary information displayed in the event overview."
6863
7072
  ),
6864
- label: TranslationConfig.describe("Human-readable label for the event type."),
7073
+ label: TranslationConfig.describe(
7074
+ "Human-readable label for the event type."
7075
+ ),
6865
7076
  actions: z35.array(ActionConfig).describe(
6866
7077
  "Configuration of core and custom actions associated with the event."
6867
7078
  ),
6868
7079
  actionOrder: z35.array(z35.string()).optional().describe(
6869
7080
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
6870
7081
  ),
6871
- declaration: DeclarationFormConfig.describe(
6872
- "Configuration of the form used to gather event data."
6873
- ),
6874
7082
  advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
6875
7083
  "Configuration of fields available in the advanced search feature."
6876
7084
  ),
@@ -6885,6 +7093,10 @@ var _EventConfigBase = z35.object({
6885
7093
  )
6886
7094
  });
6887
7095
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7096
+ if (!validateExactlyOneDeclareAction(event2, ctx)) {
7097
+ return;
7098
+ }
7099
+ validateNotificationForm(event2, ctx);
6888
7100
  validateAdvancedSearchConfig(event2, ctx);
6889
7101
  validateDateOfEvent(event2, ctx);
6890
7102
  validatePlaceOfEvent(event2, ctx);
@@ -7148,7 +7360,7 @@ var SerializableWithin = z37.object({
7148
7360
  });
7149
7361
  var SerializedQueryExpression = z37.object({
7150
7362
  eventType: z37.string(),
7151
- status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
7363
+ status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
7152
7364
  createdAt: z37.optional(DateCondition),
7153
7365
  updatedAt: z37.optional(DateCondition),
7154
7366
  "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
@@ -7157,6 +7369,7 @@ var SerializedQueryExpression = z37.object({
7157
7369
  "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
7158
7370
  "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
7159
7371
  "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
7372
+ "legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
7160
7373
  createdAtLocation: z37.optional(
7161
7374
  z37.union([SerializableWithin, SerializableExact])
7162
7375
  ),
@@ -7389,6 +7602,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
7389
7602
  type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
7390
7603
  }).shape
7391
7604
  );
7605
+ var RevokeRegistrationActionInput = BaseActionInput.extend(
7606
+ z39.object({
7607
+ type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
7608
+ }).shape
7609
+ );
7610
+ var ReinstateRegistrationActionInput = BaseActionInput.extend(
7611
+ z39.object({
7612
+ type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
7613
+ }).shape
7614
+ );
7392
7615
  var AssignActionInput = BaseActionInput.extend(
7393
7616
  z39.object({
7394
7617
  type: z39.literal(ActionType.ASSIGN),
@@ -7451,6 +7674,12 @@ var ActionInput = z39.discriminatedUnion("type", [
7451
7674
  }),
7452
7675
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
7453
7676
  UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
7677
+ RevokeRegistrationActionInput.meta({
7678
+ id: "RevokeRegistrationActionInput"
7679
+ }),
7680
+ ReinstateRegistrationActionInput.meta({
7681
+ id: "ReinstateRegistrationActionInput"
7682
+ }),
7454
7683
  AssignActionInput.meta({ id: "AssignActionInput" }),
7455
7684
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
7456
7685
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -7526,10 +7755,74 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
7526
7755
  }).brand("EventDocumentOnlyLastAction");
7527
7756
 
7528
7757
  // ../commons/src/events/defineConfig.ts
7529
- var defineConfig = (config) => {
7530
- const input = EventConfig.parse(config);
7531
- return input;
7532
- };
7758
+ var z43 = __toESM(require("zod/v4"));
7759
+ function moveDeclarationToDeclareAction({
7760
+ declaration,
7761
+ ...config
7762
+ }) {
7763
+ if (declaration) {
7764
+ console.warn(
7765
+ `Event '${config.id}' defines \`declaration\` at the top level, which is deprecated and will be removed in a future release. Define it on the ${ActionType.DECLARE} action instead.`
7766
+ );
7767
+ }
7768
+ return {
7769
+ ...config,
7770
+ actions: config.actions.map(
7771
+ (action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
7772
+ )
7773
+ };
7774
+ }
7775
+ function generateNotificationFormFallback(config) {
7776
+ const declareAction = config.actions.find(
7777
+ (action) => action.type === ActionType.DECLARE
7778
+ );
7779
+ const notifyAction = config.actions.find(
7780
+ (action) => action.type === ActionType.NOTIFY
7781
+ );
7782
+ if (!notifyAction?.notificationForm) {
7783
+ console.warn(
7784
+ `Event '${config.id}' has no ${ActionType.NOTIFY} form. Using the ${ActionType.DECLARE} form with all fields optional. Configure \`actions[${ActionType.NOTIFY}].notificationForm\`. This fallback will be removed in a future release.`
7785
+ );
7786
+ }
7787
+ if (notifyAction?.review) {
7788
+ return config;
7789
+ }
7790
+ if (!declareAction?.declaration) {
7791
+ throw new Error(
7792
+ `Event '${config.id}' has no ${ActionType.DECLARE} form. Configure \`actions[${ActionType.DECLARE}].declaration\`.`
7793
+ );
7794
+ }
7795
+ const review = generateNotifyReview(declareAction.review);
7796
+ if (notifyAction) {
7797
+ return {
7798
+ ...config,
7799
+ actions: config.actions.map(
7800
+ (action) => action === notifyAction ? { ...notifyAction, review } : action
7801
+ )
7802
+ };
7803
+ }
7804
+ const notifyFromDeclare = {
7805
+ type: ActionType.NOTIFY,
7806
+ label: declareAction.label,
7807
+ icon: declareAction.icon,
7808
+ conditionals: declareAction.conditionals,
7809
+ flags: declareAction.flags,
7810
+ supportingCopy: declareAction.dialogCopy?.notify,
7811
+ review
7812
+ };
7813
+ return {
7814
+ ...config,
7815
+ actions: config.actions.flatMap(
7816
+ (action) => action === declareAction ? [notifyFromDeclare, action] : [action]
7817
+ )
7818
+ };
7819
+ }
7820
+ var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7821
+ if (validateExactlyOneDeclareAction(config, ctx)) {
7822
+ validateDeclarationGivenExactlyOnce(config, ctx);
7823
+ }
7824
+ }).transform(moveDeclarationToDeclareAction).transform(generateNotificationFormFallback).pipe(EventConfig);
7825
+ var defineConfig = (config) => EventConfigDefinition.parse(config);
7533
7826
 
7534
7827
  // ../commons/src/events/transactions.ts
7535
7828
  function generateTransactionId() {
@@ -9523,7 +9816,24 @@ var libraryMembershipEvent = defineConfig({
9523
9816
  id: "event.library-membership.title"
9524
9817
  },
9525
9818
  summary: { fields: [] },
9526
- actions: [],
9819
+ actions: [
9820
+ {
9821
+ type: ActionType.DECLARE,
9822
+ label: {
9823
+ defaultMessage: "Declare",
9824
+ description: "This is shown as the action name anywhere the user can trigger the action from",
9825
+ id: "event.library-membership.action.declare.label"
9826
+ },
9827
+ review: {
9828
+ title: {
9829
+ defaultMessage: "Library membership application",
9830
+ description: "Title of the review page",
9831
+ id: "event.library-membership.action.declare.form.review.title"
9832
+ },
9833
+ fields: []
9834
+ }
9835
+ }
9836
+ ],
9527
9837
  declaration: libraryMembershipForm
9528
9838
  });
9529
9839
 
@@ -9969,6 +10279,22 @@ var digitalIdentityEvent = defineConfig({
9969
10279
  },
9970
10280
  summary: { fields: [] },
9971
10281
  actions: [
10282
+ {
10283
+ type: ActionType.DECLARE,
10284
+ label: {
10285
+ defaultMessage: "Declare",
10286
+ description: "This is shown as the action name anywhere the user can trigger the action from",
10287
+ id: "event.digital-identity.action.declare.label"
10288
+ },
10289
+ review: {
10290
+ title: {
10291
+ defaultMessage: "Digital identity issuance",
10292
+ description: "Title of the review page",
10293
+ id: "event.digital-identity.action.declare.form.review.title"
10294
+ },
10295
+ fields: []
10296
+ }
10297
+ },
9972
10298
  {
9973
10299
  type: ActionType.PRINT_CERTIFICATE,
9974
10300
  label: {
@@ -9983,45 +10309,45 @@ var digitalIdentityEvent = defineConfig({
9983
10309
  });
9984
10310
 
9985
10311
  // ../commons/src/events/test.utils.ts
9986
- var z44 = __toESM(require("zod/v4"));
10312
+ var z45 = __toESM(require("zod/v4"));
9987
10313
 
9988
10314
  // ../commons/src/events/locations.ts
9989
- var z43 = __toESM(require("zod/v4"));
9990
- var LocationTypeV1 = z43.enum([
10315
+ var z44 = __toESM(require("zod/v4"));
10316
+ var LocationTypeV1 = z44.enum([
9991
10317
  "ADMIN_STRUCTURE",
9992
10318
  "CRVS_OFFICE",
9993
10319
  "HEALTH_FACILITY"
9994
10320
  ]);
9995
- var LocationStatus = z43.enum(["active", "inactive"]);
10321
+ var LocationStatus = z44.enum(["active", "inactive"]);
9996
10322
  var InactiveOfficeError = class extends Error {
9997
10323
  constructor(message = "Assigned office is inactive") {
9998
10324
  super(message);
9999
10325
  this.name = "InactiveOfficeError";
10000
10326
  }
10001
10327
  };
10002
- var LocationVersion = z43.object({
10328
+ var LocationVersion = z44.object({
10003
10329
  versionId: UUID,
10004
- effectiveFrom: z43.iso.date(),
10005
- name: z43.string(),
10006
- externalId: z43.string().nullish(),
10330
+ effectiveFrom: z44.iso.date(),
10331
+ name: z44.string(),
10332
+ externalId: z44.string().nullish(),
10007
10333
  status: LocationStatus
10008
10334
  });
10009
- var AdministrativeArea = z43.object({
10335
+ var AdministrativeArea = z44.object({
10010
10336
  id: UUID,
10011
- name: z43.string(),
10012
- externalId: z43.string().nullish(),
10337
+ name: z44.string(),
10338
+ externalId: z44.string().nullish(),
10013
10339
  parentId: UUID.nullable(),
10014
10340
  status: LocationStatus,
10015
- versions: z43.array(LocationVersion)
10341
+ versions: z44.array(LocationVersion)
10016
10342
  });
10017
- var Location = z43.object({
10343
+ var Location = z44.object({
10018
10344
  id: UUID,
10019
- name: z43.string(),
10020
- externalId: z43.string().nullish(),
10345
+ name: z44.string(),
10346
+ externalId: z44.string().nullish(),
10021
10347
  administrativeAreaId: UUID.nullable(),
10022
- locationType: z43.string().nullable(),
10348
+ locationType: z44.string().nullable(),
10023
10349
  status: LocationStatus,
10024
- versions: z43.array(LocationVersion)
10350
+ versions: z44.array(LocationVersion)
10025
10351
  });
10026
10352
  var ClientAdministrativeArea = AdministrativeArea.omit({
10027
10353
  name: true,
@@ -10062,22 +10388,22 @@ function validateUniqueIds(versions, ctx) {
10062
10388
  ctx.addIssue("versions must not repeat a versionId");
10063
10389
  }
10064
10390
  }
10065
- var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10391
+ var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10066
10392
  validateAscendingDates(versions, ctx);
10067
10393
  validateUniqueIds(versions, ctx);
10068
10394
  });
10069
- var SetLocationPayload = z43.object({
10395
+ var SetLocationPayload = z44.object({
10070
10396
  id: UUID,
10071
- name: z43.string(),
10072
- externalId: z43.string().nullish(),
10397
+ name: z44.string(),
10398
+ externalId: z44.string().nullish(),
10073
10399
  administrativeAreaId: UUID.nullable(),
10074
- locationType: z43.string().nullable(),
10400
+ locationType: z44.string().nullable(),
10075
10401
  versions: SeededLocationVersions.optional()
10076
10402
  });
10077
- var SetAdministrativeAreaPayload = z43.object({
10403
+ var SetAdministrativeAreaPayload = z44.object({
10078
10404
  id: UUID,
10079
- name: z43.string(),
10080
- externalId: z43.string().nullish(),
10405
+ name: z44.string(),
10406
+ externalId: z44.string().nullish(),
10081
10407
  parentId: UUID.nullable(),
10082
10408
  versions: SeededLocationVersions.optional()
10083
10409
  });
@@ -10666,7 +10992,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
10666
10992
 
10667
10993
  // ../commons/src/events/test.utils.ts
10668
10994
  var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
10669
- var TestUserRole = z44.enum([
10995
+ var TestUserRole = z45.enum([
10670
10996
  "FIELD_AGENT",
10671
10997
  "LOCAL_REGISTRAR",
10672
10998
  "LOCAL_SYSTEM_ADMIN",
@@ -11076,6 +11402,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11076
11402
  eventId,
11077
11403
  ...input
11078
11404
  }),
11405
+ revokeRegistration: (eventId, input = {}) => ({
11406
+ type: ActionType.REVOKE_REGISTRATION,
11407
+ transactionId: input.transactionId ?? getUUID(),
11408
+ declaration: {},
11409
+ annotation: {},
11410
+ eventId,
11411
+ ...input
11412
+ }),
11413
+ reinstateRegistration: (eventId, input = {}) => ({
11414
+ type: ActionType.REINSTATE_REGISTRATION,
11415
+ transactionId: input.transactionId ?? getUUID(),
11416
+ declaration: {},
11417
+ annotation: {},
11418
+ eventId,
11419
+ ...input
11420
+ }),
11079
11421
  reject: (eventId, input = {}) => ({
11080
11422
  type: ActionType.REJECT,
11081
11423
  transactionId: input.transactionId ?? getUUID(),
@@ -11244,6 +11586,8 @@ function generateActionDocument({
11244
11586
  case ActionType.REGISTER:
11245
11587
  case ActionType.REQUEST_CORRECTION:
11246
11588
  case ActionType.UNARCHIVE:
11589
+ case ActionType.REVOKE_REGISTRATION:
11590
+ case ActionType.REINSTATE_REGISTRATION:
11247
11591
  return { ...actionBase, type: action };
11248
11592
  case ActionType.EDIT:
11249
11593
  return {
@@ -11498,6 +11842,21 @@ var generateEventConfig = ({
11498
11842
  ]
11499
11843
  });
11500
11844
  };
11845
+ function withDeclaration(configuration, declaration) {
11846
+ return {
11847
+ ...configuration,
11848
+ actions: configuration.actions.map((action) => {
11849
+ if (action.type === ActionType.DECLARE) {
11850
+ return { ...action, declaration };
11851
+ }
11852
+ if (action.type === ActionType.NOTIFY) {
11853
+ const { notificationForm: _notificationForm, ...notifyAction } = action;
11854
+ return notifyAction;
11855
+ }
11856
+ return action;
11857
+ })
11858
+ };
11859
+ }
11501
11860
  function getLeafAdministrativeAreaIds(administrativeAreas) {
11502
11861
  const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
11503
11862
  for (const [, location] of administrativeAreas) {
@@ -11604,6 +11963,8 @@ var ACTION_SCOPE_MAP = {
11604
11963
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
11605
11964
  [ActionType.REJECT_CORRECTION]: ["record.correct"],
11606
11965
  [ActionType.APPROVE_CORRECTION]: ["record.correct"],
11966
+ [ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
11967
+ [ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
11607
11968
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
11608
11969
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
11609
11970
  [ActionType.ARCHIVE]: ["record.archive"],
@@ -11626,6 +11987,8 @@ var DOCUMENT_DELETE_SCOPES = [
11626
11987
  "record.print-certified-copies",
11627
11988
  "record.request-correction",
11628
11989
  "record.correct",
11990
+ "record.revoke-registration",
11991
+ "record.reinstate-registration",
11629
11992
  "record.review-duplicates",
11630
11993
  "record.archive",
11631
11994
  "record.unarchive",
@@ -11765,6 +12128,10 @@ function deserializeQueryExpression(expression, user2) {
11765
12128
  expression["legalStatuses.REGISTERED.createdAtLocation"].location,
11766
12129
  user2
11767
12130
  ) : void 0;
12131
+ const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
12132
+ expression["legalStatuses.REVOKED.createdAtLocation"].location,
12133
+ user2
12134
+ ) : void 0;
11768
12135
  return {
11769
12136
  ...expression,
11770
12137
  assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
@@ -11783,6 +12150,10 @@ function deserializeQueryExpression(expression, user2) {
11783
12150
  ["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
11784
12151
  ...expression["legalStatuses.REGISTERED.createdAtLocation"],
11785
12152
  location: registeredLocation
12153
+ } : void 0,
12154
+ ["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
12155
+ ...expression["legalStatuses.REVOKED.createdAtLocation"],
12156
+ location: revokedLocation
11786
12157
  } : void 0
11787
12158
  };
11788
12159
  }
@@ -11829,7 +12200,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
11829
12200
  ActionType.APPROVE_CORRECTION,
11830
12201
  ActionType.REJECT_CORRECTION,
11831
12202
  ActionType.CUSTOM,
11832
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
12203
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
12204
+ ActionType.REVOKE_REGISTRATION
12205
+ ],
12206
+ [EventStatus.enum.REVOKED]: [
12207
+ ActionType.READ,
12208
+ ActionType.REINSTATE_REGISTRATION
11833
12209
  ],
11834
12210
  [EventStatus.enum.ARCHIVED]: [
11835
12211
  ActionType.READ,
@@ -11843,6 +12219,8 @@ var ACTION_FILTERS = {
11843
12219
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11844
12220
  [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11845
12221
  [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12222
+ [ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12223
+ [ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
11846
12224
  [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11847
12225
  [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11848
12226
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -11908,49 +12286,49 @@ function getFilePathsFromEvent(event2) {
11908
12286
  }
11909
12287
 
11910
12288
  // ../commons/src/events/locationPayloads.ts
11911
- var z45 = __toESM(require("zod/v4"));
11912
- var CreateLocationPayload = z45.object({
12289
+ var z46 = __toESM(require("zod/v4"));
12290
+ var CreateLocationPayload = z46.object({
11913
12291
  id: UUID.optional(),
11914
12292
  versionId: UUID.optional(),
11915
- name: z45.string(),
11916
- externalId: z45.string().nullish(),
12293
+ name: z46.string(),
12294
+ externalId: z46.string().nullish(),
11917
12295
  administrativeAreaId: UUID.nullable(),
11918
- locationType: z45.string().nullable(),
11919
- effectiveFrom: z45.iso.date().optional(),
12296
+ locationType: z46.string().nullable(),
12297
+ effectiveFrom: z46.iso.date().optional(),
11920
12298
  status: LocationStatus.default("active")
11921
12299
  });
11922
- var UpdateLocationPayload = z45.strictObject({
12300
+ var UpdateLocationPayload = z46.strictObject({
11923
12301
  id: UUID,
11924
12302
  versionId: UUID.optional(),
11925
- name: z45.string(),
11926
- externalId: z45.string().nullish(),
12303
+ name: z46.string(),
12304
+ externalId: z46.string().nullish(),
11927
12305
  status: LocationStatus,
11928
- effectiveFrom: z45.iso.date().optional(),
12306
+ effectiveFrom: z46.iso.date().optional(),
11929
12307
  lastVersionId: UUID
11930
12308
  });
11931
- var WithdrawLocationVersionPayload = z45.object({
12309
+ var WithdrawLocationVersionPayload = z46.object({
11932
12310
  id: UUID,
11933
12311
  versionId: UUID
11934
12312
  });
11935
- var CreateAdministrativeAreaPayload = z45.object({
12313
+ var CreateAdministrativeAreaPayload = z46.object({
11936
12314
  id: UUID.optional(),
11937
12315
  versionId: UUID.optional(),
11938
- name: z45.string(),
11939
- externalId: z45.string().nullish(),
12316
+ name: z46.string(),
12317
+ externalId: z46.string().nullish(),
11940
12318
  parentId: UUID.nullable(),
11941
- effectiveFrom: z45.iso.date().optional(),
12319
+ effectiveFrom: z46.iso.date().optional(),
11942
12320
  status: LocationStatus.default("active")
11943
12321
  });
11944
- var UpdateAdministrativeAreaPayload = z45.strictObject({
12322
+ var UpdateAdministrativeAreaPayload = z46.strictObject({
11945
12323
  id: UUID,
11946
12324
  versionId: UUID.optional(),
11947
- name: z45.string(),
11948
- externalId: z45.string().nullish(),
12325
+ name: z46.string(),
12326
+ externalId: z46.string().nullish(),
11949
12327
  status: LocationStatus,
11950
- effectiveFrom: z45.iso.date().optional(),
12328
+ effectiveFrom: z46.iso.date().optional(),
11951
12329
  lastVersionId: UUID
11952
12330
  });
11953
- var WithdrawAdministrativeAreaVersionPayload = z45.object({
12331
+ var WithdrawAdministrativeAreaVersionPayload = z46.object({
11954
12332
  id: UUID,
11955
12333
  versionId: UUID
11956
12334
  });