@opencrvs/toolkit 2.1.0 → 2.2.0-rc.90ed9cd

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 +36 -3
  4. package/dist/authentication/index.js +14 -1
  5. package/dist/cli.js +294 -1967
  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 +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 +192 -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 +41 -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 +216 -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 +302 -68
  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 +279 -88
  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.90ed9cd.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
@@ -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,
@@ -482,6 +485,7 @@ __export(events_exports, {
482
485
  validateFieldInput: () => validateFieldInput,
483
486
  validateValue: () => validateValue,
484
487
  window: () => window2,
488
+ withDeclaration: () => withDeclaration,
485
489
  writeActions: () => writeActions
486
490
  });
487
491
  module.exports = __toCommonJS(events_exports);
@@ -529,6 +533,8 @@ var ActionType = {
529
533
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
530
534
  REJECT_CORRECTION: "REJECT_CORRECTION",
531
535
  APPROVE_CORRECTION: "APPROVE_CORRECTION",
536
+ REVOKE_REGISTRATION: "REVOKE_REGISTRATION",
537
+ REINSTATE_REGISTRATION: "REINSTATE_REGISTRATION",
532
538
  // General actions
533
539
  READ: "READ",
534
540
  ASSIGN: "ASSIGN",
@@ -548,6 +554,8 @@ var ConfirmableActions = [
548
554
  ActionType.REQUEST_CORRECTION,
549
555
  ActionType.APPROVE_CORRECTION,
550
556
  ActionType.REJECT_CORRECTION,
557
+ ActionType.REVOKE_REGISTRATION,
558
+ ActionType.REINSTATE_REGISTRATION,
551
559
  ActionType.CUSTOM
552
560
  ];
553
561
  var ActionTypes = z2.enum([
@@ -567,6 +575,8 @@ var ActionTypes = z2.enum([
567
575
  "REQUEST_CORRECTION",
568
576
  "REJECT_CORRECTION",
569
577
  "APPROVE_CORRECTION",
578
+ "REVOKE_REGISTRATION",
579
+ "REINSTATE_REGISTRATION",
570
580
  "READ",
571
581
  "ASSIGN",
572
582
  "UNASSIGN",
@@ -608,7 +618,9 @@ var WorkqueueActionType = ActionTypes.extract([
608
618
  ActionType.ARCHIVE,
609
619
  ActionType.UNARCHIVE,
610
620
  ActionType.PRINT_CERTIFICATE,
611
- ActionType.REQUEST_CORRECTION
621
+ ActionType.REQUEST_CORRECTION,
622
+ ActionType.REVOKE_REGISTRATION,
623
+ ActionType.REINSTATE_REGISTRATION
612
624
  ]);
613
625
  var META_ACTIONS = [
614
626
  ActionType.ASSIGN,
@@ -763,6 +775,7 @@ var EventStatus = z6.enum([
763
775
  "NOTIFIED",
764
776
  "DECLARED",
765
777
  "REGISTERED",
778
+ "REVOKED",
766
779
  "ARCHIVED"
767
780
  ]);
768
781
 
@@ -786,6 +799,8 @@ var RecordScopeTypeV2 = z7.enum([
786
799
  "record.print-certified-copies",
787
800
  "record.request-correction",
788
801
  "record.correct",
802
+ "record.revoke-registration",
803
+ "record.reinstate-registration",
789
804
  "record.unassign-others",
790
805
  "record.custom-action",
791
806
  "record.action.accept",
@@ -912,6 +927,8 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
912
927
  "record.read",
913
928
  "record.request-correction",
914
929
  "record.correct",
930
+ "record.revoke-registration",
931
+ "record.reinstate-registration",
915
932
  "record.unassign-others",
916
933
  "record.review-duplicates"
917
934
  ]);
@@ -1156,6 +1173,8 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
1156
1173
  "event.actions.correction.request.request",
1157
1174
  "event.actions.correction.approve.request",
1158
1175
  "event.actions.correction.reject.request",
1176
+ "event.actions.revoke_registration.request",
1177
+ "event.actions.reinstate_registration.request",
1159
1178
  "event.actions.mark_as_duplicate.request",
1160
1179
  "event.actions.mark_as_not_duplicate.request"
1161
1180
  ]),
@@ -1910,6 +1929,16 @@ var UnarchiveAction = ActionBase.extend(
1910
1929
  type: z16.literal(ActionType.UNARCHIVE)
1911
1930
  }).shape
1912
1931
  );
1932
+ var RevokeRegistrationAction = ActionBase.extend(
1933
+ z16.object({
1934
+ type: z16.literal(ActionType.REVOKE_REGISTRATION)
1935
+ }).shape
1936
+ );
1937
+ var ReinstateRegistrationAction = ActionBase.extend(
1938
+ z16.object({
1939
+ type: z16.literal(ActionType.REINSTATE_REGISTRATION)
1940
+ }).shape
1941
+ );
1913
1942
  var CreatedAction = ActionBase.extend(
1914
1943
  z16.object({
1915
1944
  type: z16.literal(ActionType.CREATE)
@@ -1978,6 +2007,8 @@ var ActionDocument = z16.discriminatedUnion("type", [
1978
2007
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1979
2008
  ArchiveAction.meta({ id: "ArchiveAction" }),
1980
2009
  UnarchiveAction.meta({ id: "UnarchiveAction" }),
2010
+ RevokeRegistrationAction.meta({ id: "RevokeRegistrationAction" }),
2011
+ ReinstateRegistrationAction.meta({ id: "ReinstateRegistrationAction" }),
1981
2012
  NotifiedAction.meta({ id: "NotifiedAction" }),
1982
2013
  RegisterAction.meta({ id: "RegisterAction" }),
1983
2014
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -2026,7 +2057,8 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
2026
2057
  var LegalStatuses = z17.object({
2027
2058
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
2028
2059
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
2029
- [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
2060
+ [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish(),
2061
+ [EventStatus.enum.REVOKED]: ActionCreationMetadata.nullish()
2030
2062
  });
2031
2063
  var EventMetadata = z17.object({
2032
2064
  id: UUID,
@@ -2228,6 +2260,12 @@ var AnyOfStatus = import_v4.z.object({
2228
2260
  }).meta({
2229
2261
  id: "AnyOfStatus"
2230
2262
  });
2263
+ var NoneOfStatus = import_v4.z.object({
2264
+ type: import_v4.z.literal("noneOf"),
2265
+ terms: import_v4.z.array(EventStatus)
2266
+ }).meta({
2267
+ id: "NoneOfStatus"
2268
+ });
2231
2269
  var Range = import_v4.z.object({
2232
2270
  type: import_v4.z.literal("range"),
2233
2271
  gte: import_v4.z.string(),
@@ -2268,7 +2306,7 @@ var QueryInput = import_v4.z.lazy(
2268
2306
  var QueryExpression = import_v4.z.object({
2269
2307
  id: import_v4.z.optional(import_v4.z.string()),
2270
2308
  eventType: import_v4.z.string(),
2271
- status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, ExactStatus])),
2309
+ status: import_v4.z.optional(import_v4.z.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
2272
2310
  createdAt: import_v4.z.optional(DateCondition),
2273
2311
  updatedAt: import_v4.z.optional(DateCondition),
2274
2312
  "legalStatuses.DECLARED.createdAtLocation": import_v4.z.optional(Within).nullable(),
@@ -2277,6 +2315,7 @@ var QueryExpression = import_v4.z.object({
2277
2315
  "legalStatuses.REGISTERED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2278
2316
  "legalStatuses.REGISTERED.createdByRole": import_v4.z.optional(AnyOf),
2279
2317
  "legalStatuses.REGISTERED.registrationNumber": import_v4.z.optional(Exact),
2318
+ "legalStatuses.REVOKED.createdAtLocation": import_v4.z.optional(Within).nullable(),
2280
2319
  createdAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2281
2320
  updatedAtLocation: import_v4.z.optional(import_v4.z.union([Within, Exact])),
2282
2321
  assignedTo: import_v4.z.optional(Exact),
@@ -3529,6 +3568,9 @@ var DeleteConfig = ActionConfigBase.extend(
3529
3568
  var DeclareConfig = DeclarationActionBase.extend(
3530
3569
  z25.object({
3531
3570
  type: z25.literal(ActionType.DECLARE),
3571
+ declaration: DeclarationFormConfig.describe(
3572
+ "Configuration of the form used to gather event data."
3573
+ ),
3532
3574
  review: DeclarationReviewConfig.describe(
3533
3575
  "Configuration of the review page fields."
3534
3576
  ),
@@ -3557,6 +3599,18 @@ var UnarchiveConfig = ActionConfigBase.extend(
3557
3599
  type: z25.literal(ActionType.UNARCHIVE)
3558
3600
  }).shape
3559
3601
  );
3602
+ var RevokeRegistrationConfig = ActionConfigBase.extend(
3603
+ z25.object({
3604
+ type: z25.literal(ActionType.REVOKE_REGISTRATION),
3605
+ form: actionConfirmationForm
3606
+ }).shape
3607
+ );
3608
+ var ReinstateRegistrationConfig = ActionConfigBase.extend(
3609
+ z25.object({
3610
+ type: z25.literal(ActionType.REINSTATE_REGISTRATION),
3611
+ form: actionConfirmationForm
3612
+ }).shape
3613
+ );
3560
3614
  var EditActionConfig = ActionConfigBase.extend(
3561
3615
  z25.object({
3562
3616
  type: z25.literal(ActionType.EDIT),
@@ -3697,6 +3751,14 @@ var ActionConfig = z25.discriminatedUnion("type", [
3697
3751
  id: "UnarchiveActionConfig",
3698
3752
  description: "Configuration for unarchiving a record."
3699
3753
  }),
3754
+ RevokeRegistrationConfig.meta({
3755
+ id: "RevokeRegistrationActionConfig",
3756
+ description: "Configuration for revoking a registered record."
3757
+ }),
3758
+ ReinstateRegistrationConfig.meta({
3759
+ id: "ReinstateRegistrationActionConfig",
3760
+ description: "Configuration for reinstating a revoked record back to registered."
3761
+ }),
3700
3762
  CustomActionConfig.meta({
3701
3763
  id: "CustomActionConfig",
3702
3764
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -4508,6 +4570,8 @@ var updateActions = new Set(
4508
4570
  ActionType.REQUEST_CORRECTION,
4509
4571
  ActionType.APPROVE_CORRECTION,
4510
4572
  ActionType.REJECT_CORRECTION,
4573
+ ActionType.REVOKE_REGISTRATION,
4574
+ ActionType.REINSTATE_REGISTRATION,
4511
4575
  ActionType.CUSTOM
4512
4576
  ]).options
4513
4577
  );
@@ -4534,7 +4598,7 @@ function getActionUpdateMetadata(actions) {
4534
4598
  (0, import_lodash.pick)(createAction, metadataFields)
4535
4599
  );
4536
4600
  }
4537
- function getLegalStatuses(actions) {
4601
+ function getLegalStatuses(actions, status2) {
4538
4602
  return {
4539
4603
  [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
4540
4604
  ActionType.NOTIFY,
@@ -4547,7 +4611,12 @@ function getLegalStatuses(actions) {
4547
4611
  [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
4548
4612
  ActionType.REGISTER,
4549
4613
  actions
4550
- )
4614
+ ),
4615
+ // A later reinstate does not remove the revoke action, so only report it while the record is still revoked.
4616
+ [EventStatus.enum.REVOKED]: status2 === EventStatus.enum.REVOKED ? getDeclarationActionCreationMetadata(
4617
+ ActionType.REVOKE_REGISTRATION,
4618
+ actions
4619
+ ) : null
4551
4620
  };
4552
4621
  }
4553
4622
 
@@ -5417,6 +5486,10 @@ function getStatusFromActions(actions) {
5417
5486
  return EventStatus.enum.REGISTERED;
5418
5487
  case ActionType.NOTIFY:
5419
5488
  return EventStatus.enum.NOTIFIED;
5489
+ case ActionType.REVOKE_REGISTRATION:
5490
+ return EventStatus.enum.REVOKED;
5491
+ case ActionType.REINSTATE_REGISTRATION:
5492
+ return EventStatus.enum.REGISTERED;
5420
5493
  // Already filtered out above; listed here only to satisfy exhaustiveness.
5421
5494
  case ActionType.ARCHIVE:
5422
5495
  case ActionType.UNARCHIVE:
@@ -5534,7 +5607,7 @@ function getCurrentEventState(event2, config) {
5534
5607
  const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
5535
5608
  const declaration = aggregateActionDeclarations(event2);
5536
5609
  const status2 = getStatusFromActions(sortedActions);
5537
- const legalStatuses = getLegalStatuses(sortedActions);
5610
+ const legalStatuses = getLegalStatuses(sortedActions, status2);
5538
5611
  const base = deepDropNulls({
5539
5612
  id: event2.id,
5540
5613
  type: event2.type,
@@ -6209,14 +6282,22 @@ function ageToDate(age, asOfDate) {
6209
6282
  const date = plainDateToLocalDate(asOfDate);
6210
6283
  return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
6211
6284
  }
6212
- function getDeclarationFields(configuration) {
6213
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
6285
+ function getDeclaration(configuration) {
6286
+ const declareAction = configuration.actions.find(
6287
+ (action) => action.type === ActionType.DECLARE
6288
+ );
6289
+ if (!declareAction) {
6290
+ throw new Error(
6291
+ `Event '${configuration.id}' has no ${ActionType.DECLARE} action to read the declaration from`
6292
+ );
6293
+ }
6294
+ return declareAction.declaration;
6214
6295
  }
6215
6296
  function getDeclarationPages(configuration) {
6216
- return configuration.declaration.pages;
6297
+ return getDeclaration(configuration).pages;
6217
6298
  }
6218
- function getDeclaration(configuration) {
6219
- return configuration.declaration;
6299
+ function getDeclarationFields(configuration) {
6300
+ return getDeclarationPages(configuration).flatMap(({ fields }) => fields);
6220
6301
  }
6221
6302
  function isActionConfigType(type) {
6222
6303
  return actionConfigTypes.has(type);
@@ -6837,6 +6918,43 @@ function validateActionOrder(event2, ctx) {
6837
6918
  }
6838
6919
  }
6839
6920
  }
6921
+ function validateExactlyOneDeclareAction(event2, ctx) {
6922
+ const declareActionCount = event2.actions.filter(
6923
+ (action) => action.type === ActionType.DECLARE
6924
+ ).length;
6925
+ if (declareActionCount !== 1) {
6926
+ ctx.addIssue({
6927
+ code: "custom",
6928
+ message: `Event must have exactly one ${ActionType.DECLARE} action. Found ${declareActionCount} for event ${event2.id}`,
6929
+ path: ["actions"]
6930
+ });
6931
+ return false;
6932
+ }
6933
+ return true;
6934
+ }
6935
+ function validateDeclarationGivenExactlyOnce(config, ctx) {
6936
+ const declareActionIndex = config.actions.findIndex(
6937
+ (action) => action.type === ActionType.DECLARE
6938
+ );
6939
+ const declareAction = config.actions[declareActionIndex];
6940
+ const onDeclareAction = declareAction.type === ActionType.DECLARE && !!declareAction.declaration;
6941
+ const onTopLevel = !!config.declaration;
6942
+ const declareActionPath = `actions[${declareActionIndex}].declaration`;
6943
+ if (onTopLevel && onDeclareAction) {
6944
+ ctx.addIssue({
6945
+ code: "custom",
6946
+ 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.`,
6947
+ path: ["declaration"]
6948
+ });
6949
+ }
6950
+ if (!onTopLevel && !onDeclareAction) {
6951
+ ctx.addIssue({
6952
+ code: "custom",
6953
+ message: `Event '${config.id}' does not define \`declaration\`. Define it either at the top level or on the ${ActionType.DECLARE} action (\`${declareActionPath}\`).`,
6954
+ path: ["declaration"]
6955
+ });
6956
+ }
6957
+ }
6840
6958
 
6841
6959
  // ../commons/src/events/EventConfig.ts
6842
6960
  var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
@@ -6861,16 +6979,15 @@ var _EventConfigBase = z35.object({
6861
6979
  summary: SummaryConfig.describe(
6862
6980
  "Summary information displayed in the event overview."
6863
6981
  ),
6864
- label: TranslationConfig.describe("Human-readable label for the event type."),
6982
+ label: TranslationConfig.describe(
6983
+ "Human-readable label for the event type."
6984
+ ),
6865
6985
  actions: z35.array(ActionConfig).describe(
6866
6986
  "Configuration of core and custom actions associated with the event."
6867
6987
  ),
6868
6988
  actionOrder: z35.array(z35.string()).optional().describe(
6869
6989
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
6870
6990
  ),
6871
- declaration: DeclarationFormConfig.describe(
6872
- "Configuration of the form used to gather event data."
6873
- ),
6874
6991
  advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
6875
6992
  "Configuration of fields available in the advanced search feature."
6876
6993
  ),
@@ -6885,6 +7002,9 @@ var _EventConfigBase = z35.object({
6885
7002
  )
6886
7003
  });
6887
7004
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
7005
+ if (!validateExactlyOneDeclareAction(event2, ctx)) {
7006
+ return;
7007
+ }
6888
7008
  validateAdvancedSearchConfig(event2, ctx);
6889
7009
  validateDateOfEvent(event2, ctx);
6890
7010
  validatePlaceOfEvent(event2, ctx);
@@ -7148,7 +7268,7 @@ var SerializableWithin = z37.object({
7148
7268
  });
7149
7269
  var SerializedQueryExpression = z37.object({
7150
7270
  eventType: z37.string(),
7151
- status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
7271
+ status: z37.optional(z37.union([AnyOfStatus, NoneOfStatus, ExactStatus])),
7152
7272
  createdAt: z37.optional(DateCondition),
7153
7273
  updatedAt: z37.optional(DateCondition),
7154
7274
  "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
@@ -7157,6 +7277,7 @@ var SerializedQueryExpression = z37.object({
7157
7277
  "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
7158
7278
  "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
7159
7279
  "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
7280
+ "legalStatuses.REVOKED.createdAtLocation": z37.optional(SerializableWithin),
7160
7281
  createdAtLocation: z37.optional(
7161
7282
  z37.union([SerializableWithin, SerializableExact])
7162
7283
  ),
@@ -7389,6 +7510,16 @@ var UnarchiveActionInput = BaseActionInput.extend(
7389
7510
  type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
7390
7511
  }).shape
7391
7512
  );
7513
+ var RevokeRegistrationActionInput = BaseActionInput.extend(
7514
+ z39.object({
7515
+ type: z39.literal(ActionType.REVOKE_REGISTRATION).default(ActionType.REVOKE_REGISTRATION)
7516
+ }).shape
7517
+ );
7518
+ var ReinstateRegistrationActionInput = BaseActionInput.extend(
7519
+ z39.object({
7520
+ type: z39.literal(ActionType.REINSTATE_REGISTRATION).default(ActionType.REINSTATE_REGISTRATION)
7521
+ }).shape
7522
+ );
7392
7523
  var AssignActionInput = BaseActionInput.extend(
7393
7524
  z39.object({
7394
7525
  type: z39.literal(ActionType.ASSIGN),
@@ -7451,6 +7582,12 @@ var ActionInput = z39.discriminatedUnion("type", [
7451
7582
  }),
7452
7583
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
7453
7584
  UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
7585
+ RevokeRegistrationActionInput.meta({
7586
+ id: "RevokeRegistrationActionInput"
7587
+ }),
7588
+ ReinstateRegistrationActionInput.meta({
7589
+ id: "ReinstateRegistrationActionInput"
7590
+ }),
7454
7591
  AssignActionInput.meta({ id: "AssignActionInput" }),
7455
7592
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
7456
7593
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -7526,10 +7663,29 @@ var EventDocumentOnlyLastAction = EventDocument.extend({
7526
7663
  }).brand("EventDocumentOnlyLastAction");
7527
7664
 
7528
7665
  // ../commons/src/events/defineConfig.ts
7529
- var defineConfig = (config) => {
7530
- const input = EventConfig.parse(config);
7531
- return input;
7532
- };
7666
+ var z43 = __toESM(require("zod/v4"));
7667
+ function moveDeclarationToDeclareAction({
7668
+ declaration,
7669
+ ...config
7670
+ }) {
7671
+ if (declaration) {
7672
+ console.warn(
7673
+ `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.`
7674
+ );
7675
+ }
7676
+ return {
7677
+ ...config,
7678
+ actions: config.actions.map(
7679
+ (action) => action.type === ActionType.DECLARE && declaration ? { ...action, declaration } : action
7680
+ )
7681
+ };
7682
+ }
7683
+ var EventConfigDefinition = z43.custom().superRefine((config, ctx) => {
7684
+ if (validateExactlyOneDeclareAction(config, ctx)) {
7685
+ validateDeclarationGivenExactlyOnce(config, ctx);
7686
+ }
7687
+ }).transform(moveDeclarationToDeclareAction).pipe(EventConfig);
7688
+ var defineConfig = (config) => EventConfigDefinition.parse(config);
7533
7689
 
7534
7690
  // ../commons/src/events/transactions.ts
7535
7691
  function generateTransactionId() {
@@ -9523,7 +9679,24 @@ var libraryMembershipEvent = defineConfig({
9523
9679
  id: "event.library-membership.title"
9524
9680
  },
9525
9681
  summary: { fields: [] },
9526
- actions: [],
9682
+ actions: [
9683
+ {
9684
+ type: ActionType.DECLARE,
9685
+ label: {
9686
+ defaultMessage: "Declare",
9687
+ description: "This is shown as the action name anywhere the user can trigger the action from",
9688
+ id: "event.library-membership.action.declare.label"
9689
+ },
9690
+ review: {
9691
+ title: {
9692
+ defaultMessage: "Library membership application",
9693
+ description: "Title of the review page",
9694
+ id: "event.library-membership.action.declare.form.review.title"
9695
+ },
9696
+ fields: []
9697
+ }
9698
+ }
9699
+ ],
9527
9700
  declaration: libraryMembershipForm
9528
9701
  });
9529
9702
 
@@ -9969,6 +10142,22 @@ var digitalIdentityEvent = defineConfig({
9969
10142
  },
9970
10143
  summary: { fields: [] },
9971
10144
  actions: [
10145
+ {
10146
+ type: ActionType.DECLARE,
10147
+ label: {
10148
+ defaultMessage: "Declare",
10149
+ description: "This is shown as the action name anywhere the user can trigger the action from",
10150
+ id: "event.digital-identity.action.declare.label"
10151
+ },
10152
+ review: {
10153
+ title: {
10154
+ defaultMessage: "Digital identity issuance",
10155
+ description: "Title of the review page",
10156
+ id: "event.digital-identity.action.declare.form.review.title"
10157
+ },
10158
+ fields: []
10159
+ }
10160
+ },
9972
10161
  {
9973
10162
  type: ActionType.PRINT_CERTIFICATE,
9974
10163
  label: {
@@ -9983,45 +10172,45 @@ var digitalIdentityEvent = defineConfig({
9983
10172
  });
9984
10173
 
9985
10174
  // ../commons/src/events/test.utils.ts
9986
- var z44 = __toESM(require("zod/v4"));
10175
+ var z45 = __toESM(require("zod/v4"));
9987
10176
 
9988
10177
  // ../commons/src/events/locations.ts
9989
- var z43 = __toESM(require("zod/v4"));
9990
- var LocationTypeV1 = z43.enum([
10178
+ var z44 = __toESM(require("zod/v4"));
10179
+ var LocationTypeV1 = z44.enum([
9991
10180
  "ADMIN_STRUCTURE",
9992
10181
  "CRVS_OFFICE",
9993
10182
  "HEALTH_FACILITY"
9994
10183
  ]);
9995
- var LocationStatus = z43.enum(["active", "inactive"]);
10184
+ var LocationStatus = z44.enum(["active", "inactive"]);
9996
10185
  var InactiveOfficeError = class extends Error {
9997
10186
  constructor(message = "Assigned office is inactive") {
9998
10187
  super(message);
9999
10188
  this.name = "InactiveOfficeError";
10000
10189
  }
10001
10190
  };
10002
- var LocationVersion = z43.object({
10191
+ var LocationVersion = z44.object({
10003
10192
  versionId: UUID,
10004
- effectiveFrom: z43.iso.date(),
10005
- name: z43.string(),
10006
- externalId: z43.string().nullish(),
10193
+ effectiveFrom: z44.iso.date(),
10194
+ name: z44.string(),
10195
+ externalId: z44.string().nullish(),
10007
10196
  status: LocationStatus
10008
10197
  });
10009
- var AdministrativeArea = z43.object({
10198
+ var AdministrativeArea = z44.object({
10010
10199
  id: UUID,
10011
- name: z43.string(),
10012
- externalId: z43.string().nullish(),
10200
+ name: z44.string(),
10201
+ externalId: z44.string().nullish(),
10013
10202
  parentId: UUID.nullable(),
10014
10203
  status: LocationStatus,
10015
- versions: z43.array(LocationVersion)
10204
+ versions: z44.array(LocationVersion)
10016
10205
  });
10017
- var Location = z43.object({
10206
+ var Location = z44.object({
10018
10207
  id: UUID,
10019
- name: z43.string(),
10020
- externalId: z43.string().nullish(),
10208
+ name: z44.string(),
10209
+ externalId: z44.string().nullish(),
10021
10210
  administrativeAreaId: UUID.nullable(),
10022
- locationType: z43.string().nullable(),
10211
+ locationType: z44.string().nullable(),
10023
10212
  status: LocationStatus,
10024
- versions: z43.array(LocationVersion)
10213
+ versions: z44.array(LocationVersion)
10025
10214
  });
10026
10215
  var ClientAdministrativeArea = AdministrativeArea.omit({
10027
10216
  name: true,
@@ -10062,22 +10251,22 @@ function validateUniqueIds(versions, ctx) {
10062
10251
  ctx.addIssue("versions must not repeat a versionId");
10063
10252
  }
10064
10253
  }
10065
- var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10254
+ var SeededLocationVersions = z44.array(LocationVersion).min(1).superRefine((versions, ctx) => {
10066
10255
  validateAscendingDates(versions, ctx);
10067
10256
  validateUniqueIds(versions, ctx);
10068
10257
  });
10069
- var SetLocationPayload = z43.object({
10258
+ var SetLocationPayload = z44.object({
10070
10259
  id: UUID,
10071
- name: z43.string(),
10072
- externalId: z43.string().nullish(),
10260
+ name: z44.string(),
10261
+ externalId: z44.string().nullish(),
10073
10262
  administrativeAreaId: UUID.nullable(),
10074
- locationType: z43.string().nullable(),
10263
+ locationType: z44.string().nullable(),
10075
10264
  versions: SeededLocationVersions.optional()
10076
10265
  });
10077
- var SetAdministrativeAreaPayload = z43.object({
10266
+ var SetAdministrativeAreaPayload = z44.object({
10078
10267
  id: UUID,
10079
- name: z43.string(),
10080
- externalId: z43.string().nullish(),
10268
+ name: z44.string(),
10269
+ externalId: z44.string().nullish(),
10081
10270
  parentId: UUID.nullable(),
10082
10271
  versions: SeededLocationVersions.optional()
10083
10272
  });
@@ -10666,7 +10855,7 @@ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
10666
10855
 
10667
10856
  // ../commons/src/events/test.utils.ts
10668
10857
  var TEST_SYSTEM_IANA_TIMEZONE = "Asia/Dhaka";
10669
- var TestUserRole = z44.enum([
10858
+ var TestUserRole = z45.enum([
10670
10859
  "FIELD_AGENT",
10671
10860
  "LOCAL_REGISTRAR",
10672
10861
  "LOCAL_SYSTEM_ADMIN",
@@ -11076,6 +11265,22 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
11076
11265
  eventId,
11077
11266
  ...input
11078
11267
  }),
11268
+ revokeRegistration: (eventId, input = {}) => ({
11269
+ type: ActionType.REVOKE_REGISTRATION,
11270
+ transactionId: input.transactionId ?? getUUID(),
11271
+ declaration: {},
11272
+ annotation: {},
11273
+ eventId,
11274
+ ...input
11275
+ }),
11276
+ reinstateRegistration: (eventId, input = {}) => ({
11277
+ type: ActionType.REINSTATE_REGISTRATION,
11278
+ transactionId: input.transactionId ?? getUUID(),
11279
+ declaration: {},
11280
+ annotation: {},
11281
+ eventId,
11282
+ ...input
11283
+ }),
11079
11284
  reject: (eventId, input = {}) => ({
11080
11285
  type: ActionType.REJECT,
11081
11286
  transactionId: input.transactionId ?? getUUID(),
@@ -11244,6 +11449,8 @@ function generateActionDocument({
11244
11449
  case ActionType.REGISTER:
11245
11450
  case ActionType.REQUEST_CORRECTION:
11246
11451
  case ActionType.UNARCHIVE:
11452
+ case ActionType.REVOKE_REGISTRATION:
11453
+ case ActionType.REINSTATE_REGISTRATION:
11247
11454
  return { ...actionBase, type: action };
11248
11455
  case ActionType.EDIT:
11249
11456
  return {
@@ -11498,6 +11705,14 @@ var generateEventConfig = ({
11498
11705
  ]
11499
11706
  });
11500
11707
  };
11708
+ function withDeclaration(configuration, declaration) {
11709
+ return {
11710
+ ...configuration,
11711
+ actions: configuration.actions.map(
11712
+ (action) => action.type === ActionType.DECLARE ? { ...action, declaration } : action
11713
+ )
11714
+ };
11715
+ }
11501
11716
  function getLeafAdministrativeAreaIds(administrativeAreas) {
11502
11717
  const nonLeafAdministrativeAreaIds = /* @__PURE__ */ new Set();
11503
11718
  for (const [, location] of administrativeAreas) {
@@ -11604,6 +11819,8 @@ var ACTION_SCOPE_MAP = {
11604
11819
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
11605
11820
  [ActionType.REJECT_CORRECTION]: ["record.correct"],
11606
11821
  [ActionType.APPROVE_CORRECTION]: ["record.correct"],
11822
+ [ActionType.REVOKE_REGISTRATION]: ["record.revoke-registration"],
11823
+ [ActionType.REINSTATE_REGISTRATION]: ["record.reinstate-registration"],
11607
11824
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
11608
11825
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
11609
11826
  [ActionType.ARCHIVE]: ["record.archive"],
@@ -11626,6 +11843,8 @@ var DOCUMENT_DELETE_SCOPES = [
11626
11843
  "record.print-certified-copies",
11627
11844
  "record.request-correction",
11628
11845
  "record.correct",
11846
+ "record.revoke-registration",
11847
+ "record.reinstate-registration",
11629
11848
  "record.review-duplicates",
11630
11849
  "record.archive",
11631
11850
  "record.unarchive",
@@ -11765,6 +11984,10 @@ function deserializeQueryExpression(expression, user2) {
11765
11984
  expression["legalStatuses.REGISTERED.createdAtLocation"].location,
11766
11985
  user2
11767
11986
  ) : void 0;
11987
+ const revokedLocation = expression["legalStatuses.REVOKED.createdAtLocation"] ? userDeserializer(
11988
+ expression["legalStatuses.REVOKED.createdAtLocation"].location,
11989
+ user2
11990
+ ) : void 0;
11768
11991
  return {
11769
11992
  ...expression,
11770
11993
  assignedTo: expression.assignedTo && isDefined(assignedTo) ? { ...expression.assignedTo, term: assignedTo } : void 0,
@@ -11783,6 +12006,10 @@ function deserializeQueryExpression(expression, user2) {
11783
12006
  ["legalStatuses.REGISTERED.createdAtLocation"]: expression["legalStatuses.REGISTERED.createdAtLocation"] && isDefined(registeredLocation) ? {
11784
12007
  ...expression["legalStatuses.REGISTERED.createdAtLocation"],
11785
12008
  location: registeredLocation
12009
+ } : void 0,
12010
+ ["legalStatuses.REVOKED.createdAtLocation"]: expression["legalStatuses.REVOKED.createdAtLocation"] && isDefined(revokedLocation) ? {
12011
+ ...expression["legalStatuses.REVOKED.createdAtLocation"],
12012
+ location: revokedLocation
11786
12013
  } : void 0
11787
12014
  };
11788
12015
  }
@@ -11829,7 +12056,12 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
11829
12056
  ActionType.APPROVE_CORRECTION,
11830
12057
  ActionType.REJECT_CORRECTION,
11831
12058
  ActionType.CUSTOM,
11832
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
12059
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST,
12060
+ ActionType.REVOKE_REGISTRATION
12061
+ ],
12062
+ [EventStatus.enum.REVOKED]: [
12063
+ ActionType.READ,
12064
+ ActionType.REINSTATE_REGISTRATION
11833
12065
  ],
11834
12066
  [EventStatus.enum.ARCHIVED]: [
11835
12067
  ActionType.READ,
@@ -11843,6 +12075,8 @@ var ACTION_FILTERS = {
11843
12075
  [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11844
12076
  [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
11845
12077
  [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12078
+ [ActionType.REVOKE_REGISTRATION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
12079
+ [ActionType.REINSTATE_REGISTRATION]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
11846
12080
  [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11847
12081
  [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
11848
12082
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
@@ -11908,49 +12142,49 @@ function getFilePathsFromEvent(event2) {
11908
12142
  }
11909
12143
 
11910
12144
  // ../commons/src/events/locationPayloads.ts
11911
- var z45 = __toESM(require("zod/v4"));
11912
- var CreateLocationPayload = z45.object({
12145
+ var z46 = __toESM(require("zod/v4"));
12146
+ var CreateLocationPayload = z46.object({
11913
12147
  id: UUID.optional(),
11914
12148
  versionId: UUID.optional(),
11915
- name: z45.string(),
11916
- externalId: z45.string().nullish(),
12149
+ name: z46.string(),
12150
+ externalId: z46.string().nullish(),
11917
12151
  administrativeAreaId: UUID.nullable(),
11918
- locationType: z45.string().nullable(),
11919
- effectiveFrom: z45.iso.date().optional(),
12152
+ locationType: z46.string().nullable(),
12153
+ effectiveFrom: z46.iso.date().optional(),
11920
12154
  status: LocationStatus.default("active")
11921
12155
  });
11922
- var UpdateLocationPayload = z45.strictObject({
12156
+ var UpdateLocationPayload = z46.strictObject({
11923
12157
  id: UUID,
11924
12158
  versionId: UUID.optional(),
11925
- name: z45.string(),
11926
- externalId: z45.string().nullish(),
12159
+ name: z46.string(),
12160
+ externalId: z46.string().nullish(),
11927
12161
  status: LocationStatus,
11928
- effectiveFrom: z45.iso.date().optional(),
12162
+ effectiveFrom: z46.iso.date().optional(),
11929
12163
  lastVersionId: UUID
11930
12164
  });
11931
- var WithdrawLocationVersionPayload = z45.object({
12165
+ var WithdrawLocationVersionPayload = z46.object({
11932
12166
  id: UUID,
11933
12167
  versionId: UUID
11934
12168
  });
11935
- var CreateAdministrativeAreaPayload = z45.object({
12169
+ var CreateAdministrativeAreaPayload = z46.object({
11936
12170
  id: UUID.optional(),
11937
12171
  versionId: UUID.optional(),
11938
- name: z45.string(),
11939
- externalId: z45.string().nullish(),
12172
+ name: z46.string(),
12173
+ externalId: z46.string().nullish(),
11940
12174
  parentId: UUID.nullable(),
11941
- effectiveFrom: z45.iso.date().optional(),
12175
+ effectiveFrom: z46.iso.date().optional(),
11942
12176
  status: LocationStatus.default("active")
11943
12177
  });
11944
- var UpdateAdministrativeAreaPayload = z45.strictObject({
12178
+ var UpdateAdministrativeAreaPayload = z46.strictObject({
11945
12179
  id: UUID,
11946
12180
  versionId: UUID.optional(),
11947
- name: z45.string(),
11948
- externalId: z45.string().nullish(),
12181
+ name: z46.string(),
12182
+ externalId: z46.string().nullish(),
11949
12183
  status: LocationStatus,
11950
- effectiveFrom: z45.iso.date().optional(),
12184
+ effectiveFrom: z46.iso.date().optional(),
11951
12185
  lastVersionId: UUID
11952
12186
  });
11953
- var WithdrawAdministrativeAreaVersionPayload = z45.object({
12187
+ var WithdrawAdministrativeAreaVersionPayload = z46.object({
11954
12188
  id: UUID,
11955
12189
  versionId: UUID
11956
12190
  });