@opencrvs/toolkit 2.1.0 → 2.2.0-rc.9042a13

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 (59) hide show
  1. package/build.sh +2 -2
  2. package/create-countryconfig/package.json +1 -1
  3. package/dist/application-config/index.js +29 -2
  4. package/dist/authentication/index.js +14 -1
  5. package/dist/cli.js +294 -1967
  6. package/dist/commons/api/router.d.ts +1370 -73
  7. package/dist/commons/conditionals/conditionals.d.ts +3 -3
  8. package/dist/commons/events/ActionConfig.d.ts +133 -0
  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 +132 -0
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventConfig.d.ts +26 -6
  17. package/dist/commons/events/EventDocument.d.ts +88 -0
  18. package/dist/commons/events/EventIndex.d.ts +20 -0
  19. package/dist/commons/events/EventMetadata.d.ts +23 -0
  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/WorkqueueConfig.d.ts +154 -10
  23. package/dist/commons/events/eventConfigValidation.d.ts +17 -1
  24. package/dist/commons/events/scopes.d.ts +2 -0
  25. package/dist/commons/events/state/index.d.ts +10 -2
  26. package/dist/commons/events/state/utils.d.ts +11 -1
  27. package/dist/commons/events/test.utils.d.ts +28 -1
  28. package/dist/commons/events/utils.d.ts +43 -15
  29. package/dist/conditionals/index.js +14 -1
  30. package/dist/environment/derived-variables.d.ts +18 -0
  31. package/dist/environment/derived-variables.d.ts.map +1 -1
  32. package/dist/environment/derived-variables.js +22 -1
  33. package/dist/environment/setup-environment.d.ts.map +1 -1
  34. package/dist/environment/setup-environment.js +29 -10
  35. package/dist/events/index.js +293 -66
  36. package/dist/migrations/add-translations.d.ts +15 -0
  37. package/dist/migrations/add-translations.d.ts.map +1 -0
  38. package/dist/migrations/{v2.1/add-translations.js → add-translations.js} +16 -14
  39. package/dist/migrations/v2.1/index.js +35 -2155
  40. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts +3 -0
  41. package/dist/migrations/v2.1/migrate-infrastructure-to-assets.d.ts.map +1 -1
  42. package/dist/migrations/v2.1/upgrade-tilt.d.ts +3 -0
  43. package/dist/migrations/v2.1/upgrade-tilt.d.ts.map +1 -1
  44. package/dist/migrations/v2.2/index.d.ts +6 -0
  45. package/dist/migrations/v2.2/index.d.ts.map +1 -0
  46. package/dist/migrations/v2.2/index.js +456 -0
  47. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts +39 -0
  48. package/dist/migrations/v2.2/read-declaration-through-helper.d.ts.map +1 -0
  49. package/dist/migrations/v2.2/read-declaration-through-helper.js +257 -0
  50. package/dist/notification/index.js +271 -86
  51. package/dist/scopes/index.d.ts +29 -6
  52. package/dist/scopes/index.js +14 -1
  53. package/dist/templates/charts-values/traefik/values.yaml +2 -3
  54. package/opencrvs-toolkit-2.2.0-rc.9042a13.tgz +0 -0
  55. package/package.json +1 -1
  56. package/tsconfig.build.tsbuildinfo +1 -1
  57. package/dist/migrations/v2.1/add-translations.d.ts +0 -9
  58. package/dist/migrations/v2.1/add-translations.d.ts.map +0 -1
  59. package/opencrvs-toolkit-2.1.0.tgz +0 -0
@@ -203,10 +203,12 @@ __export(events_exports, {
203
203
  RegisterAction: () => RegisterAction,
204
204
  RegisterActionInput: () => RegisterActionInput,
205
205
  RegistrationCreationMetadata: () => RegistrationCreationMetadata,
206
+ ReinstateRegistrationActionInput: () => ReinstateRegistrationActionInput,
206
207
  RejectCorrectionActionInput: () => RejectCorrectionActionInput,
207
208
  RejectDeclarationActionInput: () => RejectDeclarationActionInput,
208
209
  RejectedCorrectionAction: () => RejectedCorrectionAction,
209
210
  RequestCorrectionActionInput: () => RequestCorrectionActionInput,
211
+ RevokeRegistrationActionInput: () => RevokeRegistrationActionInput,
210
212
  SearchQuery: () => SearchQuery,
211
213
  SearchQueryParams: () => SearchQueryParams,
212
214
  SeededLocationVersions: () => SeededLocationVersions,
@@ -482,6 +484,7 @@ __export(events_exports, {
482
484
  validateFieldInput: () => validateFieldInput,
483
485
  validateValue: () => validateValue,
484
486
  window: () => window2,
487
+ withDeclaration: () => withDeclaration,
485
488
  writeActions: () => writeActions
486
489
  });
487
490
  module.exports = __toCommonJS(events_exports);
@@ -529,6 +532,8 @@ var ActionType = {
529
532
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
530
533
  REJECT_CORRECTION: "REJECT_CORRECTION",
531
534
  APPROVE_CORRECTION: "APPROVE_CORRECTION",
535
+ REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
536
+ REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
532
537
  // General actions
533
538
  READ: "READ",
534
539
  ASSIGN: "ASSIGN",
@@ -548,6 +553,8 @@ var ConfirmableActions = [
548
553
  ActionType.REQUEST_CORRECTION,
549
554
  ActionType.APPROVE_CORRECTION,
550
555
  ActionType.REJECT_CORRECTION,
556
+ ActionType.REVOKE_REGISTRATION,
557
+ ActionType.REINSTATE_REGISTRATION,
551
558
  ActionType.CUSTOM
552
559
  ];
553
560
  var ActionTypes = z2.enum([
@@ -567,6 +574,8 @@ var ActionTypes = z2.enum([
567
574
  "REQUEST_CORRECTION",
568
575
  "REJECT_CORRECTION",
569
576
  "APPROVE_CORRECTION",
577
+ "REVOKE_REGISTRATION",
578
+ "REINSTATE_REGISTRATION",
570
579
  "READ",
571
580
  "ASSIGN",
572
581
  "UNASSIGN",
@@ -608,7 +617,9 @@ var WorkqueueActionType = ActionTypes.extract([
608
617
  ActionType.ARCHIVE,
609
618
  ActionType.UNARCHIVE,
610
619
  ActionType.PRINT_CERTIFICATE,
611
- ActionType.REQUEST_CORRECTION
620
+ ActionType.REQUEST_CORRECTION,
621
+ ActionType.REVOKE_REGISTRATION,
622
+ ActionType.REINSTATE_REGISTRATION
612
623
  ]);
613
624
  var META_ACTIONS = [
614
625
  ActionType.ASSIGN,
@@ -763,6 +774,7 @@ var EventStatus = z6.enum([
763
774
  "NOTIFIED",
764
775
  "DECLARED",
765
776
  "REGISTERED",
777
+ "REVOKED",
766
778
  "ARCHIVED"
767
779
  ]);
768
780
 
@@ -786,6 +798,8 @@ var RecordScopeTypeV2 = z7.enum([
786
798
  "record.print-certified-copies",
787
799
  "record.request-correction",
788
800
  "record.correct",
801
+ "record.revoke-registration",
802
+ "record.reinstate-registration",
789
803
  "record.unassign-others",
790
804
  "record.custom-action",
791
805
  "record.action.accept",
@@ -912,6 +926,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
912
926
  "record.read",
913
927
  "record.request-correction",
914
928
  "record.correct",
929
+ "record.revoke-registration",
930
+ "record.reinstate-registration",
915
931
  "record.unassign-others",
916
932
  "record.review-duplicates"
917
933
  ]);
@@ -1156,6 +1172,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
1156
1172
  "event.actions.correction.request.request",
1157
1173
  "event.actions.correction.approve.request",
1158
1174
  "event.actions.correction.reject.request",
1175
+ "event.actions.revoke_registration.request",
1176
+ "event.actions.reinstate_registration.request",
1159
1177
  "event.actions.mark_as_duplicate.request",
1160
1178
  "event.actions.mark_as_not_duplicate.request"
1161
1179
  ]),
@@ -1910,6 +1928,16 @@ var UnarchiveAction = ActionBase.extend(
1910
1928
  type: z16.literal(ActionType.UNARCHIVE)
1911
1929
  }).shape
1912
1930
  );
1931
+ var RevokeRegistrationAction = ActionBase.extend(
1932
+ z16.object({
1933
+ type: z16.literal(ActionType.REVOKE_REGISTRATION)
1934
+ }).shape
1935
+ );
1936
+ var ReinstateRegistrationAction = ActionBase.extend(
1937
+ z16.object({
1938
+ type: z16.literal(ActionType.REINSTATE_REGISTRATION)
1939
+ }).shape
1940
+ );
1913
1941
  var CreatedAction = ActionBase.extend(
1914
1942
  z16.object({
1915
1943
  type: z16.literal(ActionType.CREATE)
@@ -1978,6 +2006,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
1978
2006
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1979
2007
  ArchiveAction.meta({ id: "ArchiveAction" }),
1980
2008
  UnarchiveAction.meta({ id: "UnarchiveAction" }),
2009
+ RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
2010
+ ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
1981
2011
  NotifiedAction.meta({ id: "NotifiedAction" }),
1982
2012
  RegisterAction.meta({ id: "RegisterAction" }),
1983
2013
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -2026,7 +2056,8 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2026
2056
  var LegalStatuses = z17.object({
2027
2057
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
2028
2058
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2029
- [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2059
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
2060
+ [EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
2030
2061
  });
2031
2062
  var EventMetadata = z17.object({
2032
2063
  id: UUID,
@@ -2277,6 +2308,7 @@ var QueryExpression = import_v4.z.object({
2277
2308
  "legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2278
2309
  "legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
2279
2310
  "legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
2311
+ "legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2280
2312
  createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2281
2313
  updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2282
2314
  assignedTo: import_v4.z.optional(Exact),
@@ -3529,6 +3561,9 @@ var DeleteConfig = ActionConfigBase.extend(
3529
3561
  var DeclareConfig = DeclarationActionBase.extend(
3530
3562
  z25.object({
3531
3563
  type: z25.literal(ActionType.DECLARE),
3564
+ declaration: DeclarationFormConfig.describe(
3565
+ "Configuration of the form used to gather event data."
3566
+ ),
3532
3567
  review: DeclarationReviewConfig.describe(
3533
3568
  "Configuration of the review page fields."
3534
3569
  ),
@@ -3557,6 +3592,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
3557
3592
  type: z25.literal(ActionType.UNARCHIVE)
3558
3593
  }).shape
3559
3594
  );
3595
+ var RevokeRegistrationConfig = ActionConfigBase.extend(
3596
+ z25.object({
3597
+ type: z25.literal(ActionType.REVOKE_REGISTRATION),
3598
+ form: actionConfirmationForm
3599
+ }).shape
3600
+ );
3601
+ var ReinstateRegistrationConfig = ActionConfigBase.extend(
3602
+ z25.object({
3603
+ type: z25.literal(ActionType.REINSTATE_REGISTRATION),
3604
+ form: actionConfirmationForm
3605
+ }).shape
3606
+ );
3560
3607
  var EditActionConfig = ActionConfigBase.extend(
3561
3608
  z25.object({
3562
3609
  type: z25.literal(ActionType.EDIT),
@@ -3697,6 +3744,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
3697
3744
  id: "UnarchiveActionConfig",
3698
3745
  description: "Configuration for unarchiving a record."
3699
3746
  }),
3747
+ RevokeRegistrationConfig.meta({
3748
+ id: "RevokeRegistrationActionConfig",
3749
+ description: "Configuration for revoking a registered record."
3750
+ }),
3751
+ ReinstateRegistrationConfig.meta({
3752
+ id: "ReinstateRegistrationActionConfig",
3753
+ description: "Configuration for reinstating a revoked record back to registered."
3754
+ }),
3700
3755
  CustomActionConfig.meta({
3701
3756
  id: "CustomActionConfig",
3702
3757
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4508,6 +4563,8 @@ var updateActions = new Set(
4508
4563
  ActionType.REQUEST_CORRECTION,
4509
4564
  ActionType.APPROVE_CORRECTION,
4510
4565
  ActionType.REJECT_CORRECTION,
4566
+ ActionType.REVOKE_REGISTRATION,
4567
+ ActionType.REINSTATE_REGISTRATION,
4511
4568
  ActionType.CUSTOM
4512
4569
  ]).options
4513
4570
  );
@@ -4534,7 +4591,7 @@ function getActionUpdateMetadata(actions) {
4534
4591
  (0, import_lodash.pick)(createAction, metadataFields)
4535
4592
  );
4536
4593
  }
4537
- function getLegalStatuses(actions) {
4594
+ function getLegalStatuses(actions, status2) {
4538
4595
  return {
4539
4596
  [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
4540
4597
  ActionType.NOTIFY,
@@ -4547,7 +4604,12 @@ function getLegalStatuses(actions) {
4547
4604
  [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
4548
4605
  ActionType.REGISTER,
4549
4606
  actions
4550
- )
4607
+ ),
4608
+ // A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
4609
+ [EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
4610
+ ActionType.REVOKE_REGISTRATION,
4611
+ actions
4612
+ ) : null
4551
4613
  };
4552
4614
  }
4553
4615
 
@@ -5417,6 +5479,10 @@ function getStatusFromActions(actions) {
5417
5479
  return EventStatus.enum.REGISTERED;
5418
5480
  case ActionType.NOTIFY:
5419
5481
  return EventStatus.enum.NOTIFIED;
5482
+ case ActionType.REVOKE_REGISTRATION:
5483
+ return EventStatus.enum.REVOKED;
5484
+ case ActionType.REINSTATE_REGISTRATION:
5485
+ return EventStatus.enum.REGISTERED;
5420
5486
  // Already filtered out above; listed here only to satisfy exhaustiveness.
5421
5487
  case ActionType.ARCHIVE:
5422
5488
  case ActionType.UNARCHIVE:
@@ -5534,7 +5600,7 @@ function getCurrentEventState(event2, config) {
5534
5600
  const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
5535
5601
  const declaration = aggregateActionDeclarations(event2);
5536
5602
  const status2 = getStatusFromActions(sortedActions);
5537
- const legalStatuses = getLegalStatuses(sortedActions);
5603
+ const legalStatuses = getLegalStatuses(sortedActions, status2);
5538
5604
  const base = deepDropNulls({
5539
5605
  id: event2.id,
5540
5606
  type: event2.type,
@@ -6209,14 +6275,22 @@ function ageToDate(age, asOfDate) {
6209
6275
  const date = plainDateToLocalDate(asOfDate);
6210
6276
  return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
6211
6277
  }
6212
- function getDeclarationFields(configuration) {
6213
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
6278
+ function getDeclaration(configuration) {
6279
+ const declareAction = configuration.actions.find(
6280
+ (action) => action.type === ActionType.DECLARE
6281
+ );
6282
+ if (!declareAction) {
6283
+ throw new Error(
6284
+ `Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
6285
+ );
6286
+ }
6287
+ return declareAction.declaration;
6214
6288
  }
6215
6289
  function getDeclarationPages(configuration) {
6216
- return configuration.declaration.pages;
6290
+ return getDeclaration(configuration).pages;
6217
6291
  }
6218
- function getDeclaration(configuration) {
6219
- return configuration.declaration;
6292
+ function getDeclarationFields(configuration) {
6293
+ return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6220
6294
  }
6221
6295
  function isActionConfigType(type) {
6222
6296
  return actionConfigTypes.has(type);
@@ -6837,6 +6911,43 @@ function validateActionOrder(event2, ctx) {
6837
6911
  }
6838
6912
  }
6839
6913
  }
6914
+ function validateExactlyOneDeclareAction(event2, ctx) {
6915
+ const declareActionCount = event2.actions.filter(
6916
+ (action) => action.type === ActionType.DECLARE
6917
+ ).length;
6918
+ if (declareActionCount !== 1) {
6919
+ ctx.addIssue({
6920
+ code: "custom",
6921
+ message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
6922
+ path: ["actions"]
6923
+ });
6924
+ return false;
6925
+ }
6926
+ return true;
6927
+ }
6928
+ function validateDeclarationGivenExactlyOnce(config, ctx) {
6929
+ const declareActionIndex = config.actions.findIndex(
6930
+ (action) => action.type === ActionType.DECLARE
6931
+ );
6932
+ const declareAction = config.actions[declareActionIndex];
6933
+ const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
6934
+ const onTopLevel = !!config.declaration;
6935
+ const declareActionPath = `actions[${declareActionIndex}].declaration`;
6936
+ if (onTopLevel && onDeclareAction) {
6937
+ ctx.addIssue({
6938
+ code: "custom",
6939
+ 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.`,
6940
+ path: ["declaration"]
6941
+ });
6942
+ }
6943
+ if (!onTopLevel && !onDeclareAction) {
6944
+ ctx.addIssue({
6945
+ code: "custom",
6946
+ message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
6947
+ path: ["declaration"]
6948
+ });
6949
+ }
6950
+ }
6840
6951
 
6841
6952
  // ../commons/src/events/EventConfig.ts
6842
6953
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
@@ -6861,16 +6972,15 @@ var _EventConfigBase = z35.object({
6861
6972
  summary: SummaryConfig.describe(
6862
6973
  "Summary information displayed in the event overview."
6863
6974
  ),
6864
- label: TranslationConfig.describe("Human-readable label for the event type."),
6975
+ label: TranslationConfig.describe(
6976
+ "Human-readable label for the event type."
6977
+ ),
6865
6978
  actions: z35.array(ActionConfig).describe(
6866
6979
  "Configuration of core and custom actions associated with the event."
6867
6980
  ),
6868
6981
  actionOrder: z35.array(z35.string()).optional().describe(
6869
6982
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
6870
6983
  ),
6871
- declaration: DeclarationFormConfig.describe(
6872
- "Configuration of the form used to gather event data."
6873
- ),
6874
6984
  advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
6875
6985
  "Configuration of fields available in the advanced search feature."
6876
6986
  ),
@@ -6885,6 +6995,9 @@ var _EventConfigBase = z35.object({
6885
6995
  )
6886
6996
  });
6887
6997
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
6998
+ if (!validateExactlyOneDeclareAction(event2, ctx)) {
6999
+ return;
7000
+ }
6888
7001
  validateAdvancedSearchConfig(event2, ctx);
6889
7002
  validateDateOfEvent(event2, ctx);
6890
7003
  validatePlaceOfEvent(event2, ctx);
@@ -7157,6 +7270,7 @@ var SerializedQueryExpression = z37.object({
7157
7270
  "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
7158
7271
  "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
7159
7272
  "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
7273
+ "legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
7160
7274
  createdAtLocation: z37.optional(
7161
7275
  z37.union([SerializableWithin, SerializableExact])
7162
7276
  ),
@@ -7389,6 +7503,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
7389
7503
  type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
7390
7504
  }).shape
7391
7505
  );
7506
+ var RevokeRegistrationActionInput = BaseActionInput.extend(
7507
+ z39.object({
7508
+ type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
7509
+ }).shape
7510
+ );
7511
+ var ReinstateRegistrationActionInput = BaseActionInput.extend(
7512
+ z39.object({
7513
+ type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
7514
+ }).shape
7515
+ );
7392
7516
  var AssignActionInput = BaseActionInput.extend(
7393
7517
  z39.object({
7394
7518
  type: z39.literal(ActionType.ASSIGN),
@@ -7451,6 +7575,12 @@ var ActionInput = z39.discriminatedUnion("type", [
7451
7575
  }),
7452
7576
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
7453
7577
  UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
7578
+ RevokeRegistrationActionInput.meta({
7579
+ id: "RevokeRegistrationActionInput"
7580
+ }),
7581
+ ReinstateRegistrationActionInput.meta({
7582
+ id: "ReinstateRegistrationActionInput"
7583
+ }),
7454
7584
  AssignActionInput.meta({ id: "AssignActionInput" }),
7455
7585
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
7456
7586
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -7526,10 +7656,29 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
7526
7656
  }).brand("EventDocumentOnlyLastAction");
7527
7657
 
7528
7658
  // ../commons/src/events/defineConfig.ts
7529
- var defineConfig = (config) => {
7530
- const input = EventConfig.parse(config);
7531
- return input;
7532
- };
7659
+ var z43 = __toESM(require("zod/v4"));
7660
+ function moveDeclarationToDeclareAction({
7661
+ declaration,
7662
+ ...config
7663
+ }) {
7664
+ if (declaration) {
7665
+ console.warn(
7666
+ `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.`
7667
+ );
7668
+ }
7669
+ return {
7670
+ ...config,
7671
+ actions: config.actions.map(
7672
+ (action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
7673
+ )
7674
+ };
7675
+ }
7676
+ var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7677
+ if (validateExactlyOneDeclareAction(config, ctx)) {
7678
+ validateDeclarationGivenExactlyOnce(config, ctx);
7679
+ }
7680
+ }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
7681
+ var defineConfig = (config) => EventConfigDefinition.parse(config);
7533
7682
 
7534
7683
  // ../commons/src/events/transactions.ts
7535
7684
  function generateTransactionId() {
@@ -9523,7 +9672,24 @@ var libraryMembershipEvent = defineConfig({
9523
9672
  id: "event.library-membership.title"
9524
9673
  },
9525
9674
  summary: { fields: [] },
9526
- actions: [],
9675
+ actions: [
9676
+ {
9677
+ type: ActionType.DECLARE,
9678
+ label: {
9679
+ defaultMessage: "Declare",
9680
+ description: "This is shown as the action name anywhere the user can trigger the action from",
9681
+ id: "event.library-membership.action.declare.label"
9682
+ },
9683
+ review: {
9684
+ title: {
9685
+ defaultMessage: "Library membership application",
9686
+ description: "Title of the review page",
9687
+ id: "event.library-membership.action.declare.form.review.title"
9688
+ },
9689
+ fields: []
9690
+ }
9691
+ }
9692
+ ],
9527
9693
  declaration: libraryMembershipForm
9528
9694
  });
9529
9695
 
@@ -9969,6 +10135,22 @@ var digitalIdentityEvent = defineConfig({
9969
10135
  },
9970
10136
  summary: { fields: [] },
9971
10137
  actions: [
10138
+ {
10139
+ type: ActionType.DECLARE,
10140
+ label: {
10141
+ defaultMessage: "Declare",
10142
+ description: "This is shown as the action name anywhere the user can trigger the action from",
10143
+ id: "event.digital-identity.action.declare.label"
10144
+ },
10145
+ review: {
10146
+ title: {
10147
+ defaultMessage: "Digital identity issuance",
10148
+ description: "Title of the review page",
10149
+ id: "event.digital-identity.action.declare.form.review.title"
10150
+ },
10151
+ fields: []
10152
+ }
10153
+ },
9972
10154
  {
9973
10155
  type: ActionType.PRINT_CERTIFICATE,
9974
10156
  label: {
@@ -9983,45 +10165,45 @@ var digitalIdentityEvent = defineConfig({
9983
10165
  });
9984
10166
 
9985
10167
  // ../commons/src/events/test.utils.ts
9986
- var z44 = __toESM(require("zod/v4"));
10168
+ var z45 = __toESM(require("zod/v4"));
9987
10169
 
9988
10170
  // ../commons/src/events/locations.ts
9989
- var z43 = __toESM(require("zod/v4"));
9990
- var LocationTypeV1 = z43.enum([
10171
+ var z44 = __toESM(require("zod/v4"));
10172
+ var LocationTypeV1 = z44.enum([
9991
10173
  "ADMIN_STRUCTURE",
9992
10174
  "CRVS_OFFICE",
9993
10175
  "HEALTH_FACILITY"
9994
10176
  ]);
9995
- var LocationStatus = z43.enum(["active", "inactive"]);
10177
+ var LocationStatus = z44.enum(["active", "inactive"]);
9996
10178
  var InactiveOfficeError = class extends Error {
9997
10179
  constructor(message = "Assigned office is inactive") {
9998
10180
  super(message);
9999
10181
  this.name = "InactiveOfficeError";
10000
10182
  }
10001
10183
  };
10002
- var LocationVersion = z43.object({
10184
+ var LocationVersion = z44.object({
10003
10185
  versionId: UUID,
10004
- effectiveFrom: z43.iso.date(),
10005
- name: z43.string(),
10006
- externalId: z43.string().nullish(),
10186
+ effectiveFrom: z44.iso.date(),
10187
+ name: z44.string(),
10188
+ externalId: z44.string().nullish(),
10007
10189
  status: LocationStatus
10008
10190
  });
10009
- var AdministrativeArea = z43.object({
10191
+ var AdministrativeArea = z44.object({
10010
10192
  id: UUID,
10011
- name: z43.string(),
10012
- externalId: z43.string().nullish(),
10193
+ name: z44.string(),
10194
+ externalId: z44.string().nullish(),
10013
10195
  parentId: UUID.nullable(),
10014
10196
  status: LocationStatus,
10015
- versions: z43.array(LocationVersion)
10197
+ versions: z44.array(LocationVersion)
10016
10198
  });
10017
- var Location = z43.object({
10199
+ var Location = z44.object({
10018
10200
  id: UUID,
10019
- name: z43.string(),
10020
- externalId: z43.string().nullish(),
10201
+ name: z44.string(),
10202
+ externalId: z44.string().nullish(),
10021
10203
  administrativeAreaId: UUID.nullable(),
10022
- locationType: z43.string().nullable(),
10204
+ locationType: z44.string().nullable(),
10023
10205
  status: LocationStatus,
10024
- versions: z43.array(LocationVersion)
10206
+ versions: z44.array(LocationVersion)
10025
10207
  });
10026
10208
  var ClientAdministrativeArea = AdministrativeArea.omit({
10027
10209
  name: true,
@@ -10062,22 +10244,22 @@ function validateUniqueIds(versions, ctx) {
10062
10244
  ctx.addIssue("versions must not repeat a versionId");
10063
10245
  }
10064
10246
  }
10065
- var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10247
+ var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10066
10248
  validateAscendingDates(versions, ctx);
10067
10249
  validateUniqueIds(versions, ctx);
10068
10250
  });
10069
- var SetLocationPayload = z43.object({
10251
+ var SetLocationPayload = z44.object({
10070
10252
  id: UUID,
10071
- name: z43.string(),
10072
- externalId: z43.string().nullish(),
10253
+ name: z44.string(),
10254
+ externalId: z44.string().nullish(),
10073
10255
  administrativeAreaId: UUID.nullable(),
10074
- locationType: z43.string().nullable(),
10256
+ locationType: z44.string().nullable(),
10075
10257
  versions: SeededLocationVersions.optional()
10076
10258
  });
10077
- var SetAdministrativeAreaPayload = z43.object({
10259
+ var SetAdministrativeAreaPayload = z44.object({
10078
10260
  id: UUID,
10079
- name: z43.string(),
10080
- externalId: z43.string().nullish(),
10261
+ name: z44.string(),
10262
+ externalId: z44.string().nullish(),
10081
10263
  parentId: UUID.nullable(),
10082
10264
  versions: SeededLocationVersions.optional()
10083
10265
  });
@@ -10666,7 +10848,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
10666
10848
 
10667
10849
  // ../commons/src/events/test.utils.ts
10668
10850
  var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
10669
- var TestUserRole = z44.enum([
10851
+ var TestUserRole = z45.enum([
10670
10852
  "FIELD_AGENT",
10671
10853
  "LOCAL_REGISTRAR",
10672
10854
  "LOCAL_SYSTEM_ADMIN",
@@ -11076,6 +11258,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11076
11258
  eventId,
11077
11259
  ...input
11078
11260
  }),
11261
+ revokeRegistration: (eventId, input = {}) => ({
11262
+ type: ActionType.REVOKE_REGISTRATION,
11263
+ transactionId: input.transactionId ?? getUUID(),
11264
+ declaration: {},
11265
+ annotation: {},
11266
+ eventId,
11267
+ ...input
11268
+ }),
11269
+ reinstateRegistration: (eventId, input = {}) => ({
11270
+ type: ActionType.REINSTATE_REGISTRATION,
11271
+ transactionId: input.transactionId ?? getUUID(),
11272
+ declaration: {},
11273
+ annotation: {},
11274
+ eventId,
11275
+ ...input
11276
+ }),
11079
11277
  reject: (eventId, input = {}) => ({
11080
11278
  type: ActionType.REJECT,
11081
11279
  transactionId: input.transactionId ?? getUUID(),
@@ -11244,6 +11442,8 @@ function generateActionDocument({
11244
11442
  case ActionType.REGISTER:
11245
11443
  case ActionType.REQUEST_CORRECTION:
11246
11444
  case ActionType.UNARCHIVE:
11445
+ case ActionType.REVOKE_REGISTRATION:
11446
+ case ActionType.REINSTATE_REGISTRATION:
11247
11447
  return { ...actionBase, type: action };
11248
11448
  case ActionType.EDIT:
11249
11449
  return {
@@ -11498,6 +11698,14 @@ var generateEventConfig = ({
11498
11698
  ]
11499
11699
  });
11500
11700
  };
11701
+ function withDeclaration(configuration, declaration) {
11702
+ return {
11703
+ ...configuration,
11704
+ actions: configuration.actions.map(
11705
+ (action) => action.type === ActionType.DECLARE ? { ...action, declaration } : action
11706
+ )
11707
+ };
11708
+ }
11501
11709
  function getLeafAdministrativeAreaIds(administrativeAreas) {
11502
11710
  const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
11503
11711
  for (const [, location] of administrativeAreas) {
@@ -11604,6 +11812,8 @@ var ACTION_SCOPE_MAP = {
11604
11812
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
11605
11813
  [ActionType.REJECT_CORRECTION]: ["record.correct"],
11606
11814
  [ActionType.APPROVE_CORRECTION]: ["record.correct"],
11815
+ [ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
11816
+ [ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
11607
11817
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
11608
11818
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
11609
11819
  [ActionType.ARCHIVE]: ["record.archive"],
@@ -11626,6 +11836,8 @@ var DOCUMENT_DELETE_SCOPES = [
11626
11836
  "record.print-certified-copies",
11627
11837
  "record.request-correction",
11628
11838
  "record.correct",
11839
+ "record.revoke-registration",
11840
+ "record.reinstate-registration",
11629
11841
  "record.review-duplicates",
11630
11842
  "record.archive",
11631
11843
  "record.unarchive",
@@ -11765,6 +11977,10 @@ function deserializeQueryExpression(expression, user2) {
11765
11977
  expression["legalStatuses.REGISTERED.createdAtLocation"].location,
11766
11978
  user2
11767
11979
  ) : void 0;
11980
+ const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
11981
+ expression["legalStatuses.REVOKED.createdAtLocation"].location,
11982
+ user2
11983
+ ) : void 0;
11768
11984
  return {
11769
11985
  ...expression,
11770
11986
  assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
@@ -11783,6 +11999,10 @@ function deserializeQueryExpression(expression, user2) {
11783
11999
  ["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
11784
12000
  ...expression["legalStatuses.REGISTERED.createdAtLocation"],
11785
12001
  location: registeredLocation
12002
+ } : void 0,
12003
+ ["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
12004
+ ...expression["legalStatuses.REVOKED.createdAtLocation"],
12005
+ location: revokedLocation
11786
12006
  } : void 0
11787
12007
  };
11788
12008
  }
@@ -11829,7 +12049,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
11829
12049
  ActionType.APPROVE_CORRECTION,
11830
12050
  ActionType.REJECT_CORRECTION,
11831
12051
  ActionType.CUSTOM,
11832
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
12052
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
12053
+ ActionType.REVOKE_REGISTRATION
12054
+ ],
12055
+ [EventStatus.enum.REVOKED]: [
12056
+ ActionType.READ,
12057
+ ActionType.REINSTATE_REGISTRATION
11833
12058
  ],
11834
12059
  [EventStatus.enum.ARCHIVED]: [
11835
12060
  ActionType.READ,
@@ -11843,6 +12068,8 @@ var ACTION_FILTERS = {
11843
12068
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11844
12069
  [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11845
12070
  [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12071
+ [ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12072
+ [ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
11846
12073
  [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11847
12074
  [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11848
12075
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -11908,49 +12135,49 @@ function getFilePathsFromEvent(event2) {
11908
12135
  }
11909
12136
 
11910
12137
  // ../commons/src/events/locationPayloads.ts
11911
- var z45 = __toESM(require("zod/v4"));
11912
- var CreateLocationPayload = z45.object({
12138
+ var z46 = __toESM(require("zod/v4"));
12139
+ var CreateLocationPayload = z46.object({
11913
12140
  id: UUID.optional(),
11914
12141
  versionId: UUID.optional(),
11915
- name: z45.string(),
11916
- externalId: z45.string().nullish(),
12142
+ name: z46.string(),
12143
+ externalId: z46.string().nullish(),
11917
12144
  administrativeAreaId: UUID.nullable(),
11918
- locationType: z45.string().nullable(),
11919
- effectiveFrom: z45.iso.date().optional(),
12145
+ locationType: z46.string().nullable(),
12146
+ effectiveFrom: z46.iso.date().optional(),
11920
12147
  status: LocationStatus.default("active")
11921
12148
  });
11922
- var UpdateLocationPayload = z45.strictObject({
12149
+ var UpdateLocationPayload = z46.strictObject({
11923
12150
  id: UUID,
11924
12151
  versionId: UUID.optional(),
11925
- name: z45.string(),
11926
- externalId: z45.string().nullish(),
12152
+ name: z46.string(),
12153
+ externalId: z46.string().nullish(),
11927
12154
  status: LocationStatus,
11928
- effectiveFrom: z45.iso.date().optional(),
12155
+ effectiveFrom: z46.iso.date().optional(),
11929
12156
  lastVersionId: UUID
11930
12157
  });
11931
- var WithdrawLocationVersionPayload = z45.object({
12158
+ var WithdrawLocationVersionPayload = z46.object({
11932
12159
  id: UUID,
11933
12160
  versionId: UUID
11934
12161
  });
11935
- var CreateAdministrativeAreaPayload = z45.object({
12162
+ var CreateAdministrativeAreaPayload = z46.object({
11936
12163
  id: UUID.optional(),
11937
12164
  versionId: UUID.optional(),
11938
- name: z45.string(),
11939
- externalId: z45.string().nullish(),
12165
+ name: z46.string(),
12166
+ externalId: z46.string().nullish(),
11940
12167
  parentId: UUID.nullable(),
11941
- effectiveFrom: z45.iso.date().optional(),
12168
+ effectiveFrom: z46.iso.date().optional(),
11942
12169
  status: LocationStatus.default("active")
11943
12170
  });
11944
- var UpdateAdministrativeAreaPayload = z45.strictObject({
12171
+ var UpdateAdministrativeAreaPayload = z46.strictObject({
11945
12172
  id: UUID,
11946
12173
  versionId: UUID.optional(),
11947
- name: z45.string(),
11948
- externalId: z45.string().nullish(),
12174
+ name: z46.string(),
12175
+ externalId: z46.string().nullish(),
11949
12176
  status: LocationStatus,
11950
- effectiveFrom: z45.iso.date().optional(),
12177
+ effectiveFrom: z46.iso.date().optional(),
11951
12178
  lastVersionId: UUID
11952
12179
  });
11953
- var WithdrawAdministrativeAreaVersionPayload = z45.object({
12180
+ var WithdrawAdministrativeAreaVersionPayload = z46.object({
11954
12181
  id: UUID,
11955
12182
  versionId: UUID
11956
12183
  });