@opencrvs/toolkit 2.1.0-rc.1dde62b → 2.1.0-rc.1f71eca

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 (66) hide show
  1. package/dist/application-config/index.js +3 -1
  2. package/dist/commons/api/router.d.ts +3623 -3361
  3. package/dist/commons/application-config/index.d.ts +6 -6
  4. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  5. package/dist/commons/events/ActionConfig.d.ts +112 -105
  6. package/dist/commons/events/ActionDocument.d.ts +119 -119
  7. package/dist/commons/events/ActionInput.d.ts +0 -6
  8. package/dist/commons/events/ActionType.d.ts +62 -62
  9. package/dist/commons/events/AdvancedSearchConfig.d.ts +513 -507
  10. package/dist/commons/events/AuditLog.d.ts +189 -42
  11. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  12. package/dist/commons/events/Conditional.d.ts +3 -3
  13. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  14. package/dist/commons/events/Draft.d.ts +37 -37
  15. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  16. package/dist/commons/events/EventConfig.d.ts +5 -5
  17. package/dist/commons/events/EventDocument.d.ts +48 -48
  18. package/dist/commons/events/EventIndex.d.ts +62 -62
  19. package/dist/commons/events/EventMetadata.d.ts +40 -40
  20. package/dist/commons/events/FieldConfig.d.ts +341 -336
  21. package/dist/commons/events/FieldType.d.ts +51 -51
  22. package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
  23. package/dist/commons/events/FieldValue.d.ts +12 -12
  24. package/dist/commons/events/Flag.d.ts +15 -15
  25. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  26. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  27. package/dist/commons/events/WorkqueueConfig.d.ts +826 -826
  28. package/dist/commons/events/deduplication.d.ts +1 -1
  29. package/dist/commons/events/event.d.ts +2 -2
  30. package/dist/commons/events/field.d.ts +69 -198
  31. package/dist/commons/events/index.d.ts +1 -0
  32. package/dist/commons/events/locationPayloads.d.ts +95 -0
  33. package/dist/commons/events/locations.d.ts +103 -6
  34. package/dist/commons/events/mocks.test.utils.d.ts +18 -4
  35. package/dist/commons/events/scopes.d.ts +4 -4
  36. package/dist/commons/events/state/index.d.ts +17 -17
  37. package/dist/commons/events/state/utils.d.ts +7 -7
  38. package/dist/commons/events/test.utils.d.ts +40 -43
  39. package/dist/commons/events/utils.d.ts +122 -114
  40. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  41. package/dist/conditionals/index.js +1 -0
  42. package/dist/environment/derived-variables.d.ts +119 -119
  43. package/dist/environment/derived-variables.d.ts.map +1 -1
  44. package/dist/environment/logger.d.ts +3 -12
  45. package/dist/environment/logger.d.ts.map +1 -1
  46. package/dist/environment/manage-users.js +17 -7
  47. package/dist/environment/questions.d.ts +75 -74
  48. package/dist/environment/questions.d.ts.map +1 -1
  49. package/dist/environment/setup-environment.js +8 -14
  50. package/dist/environment/swarm-to-k8s.js +17 -7
  51. package/dist/environment/update-workflows.js +17 -7
  52. package/dist/environment/users.js +17 -7
  53. package/dist/environment/utils.d.ts +1 -1
  54. package/dist/environment/utils.js +17 -7
  55. package/dist/events/deduplication.d.ts +1 -1
  56. package/dist/events/index.js +236 -70
  57. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  58. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  59. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  60. package/dist/notification/index.js +219 -93
  61. package/dist/scopes/index.d.ts +148 -146
  62. package/dist/scopes/index.js +1 -0
  63. package/opencrvs-toolkit-2.1.0-rc.1f71eca.tgz +0 -0
  64. package/package.json +5 -5
  65. package/tsconfig.tsbuildinfo +1 -1
  66. package/opencrvs-toolkit-2.1.0-rc.1dde62b.tgz +0 -0
@@ -80,6 +80,8 @@ __export(events_exports, {
80
80
  ConditionalType: () => ConditionalType,
81
81
  ConfirmableActions: () => ConfirmableActions,
82
82
  ContainsFlags: () => ContainsFlags,
83
+ CreateAdministrativeAreaPayload: () => CreateAdministrativeAreaPayload,
84
+ CreateLocationPayload: () => CreateLocationPayload,
83
85
  CustomActionInput: () => CustomActionInput,
84
86
  CustomFieldValue: () => CustomFieldValue,
85
87
  CustomFlag: () => CustomFlag,
@@ -161,7 +163,9 @@ __export(events_exports, {
161
163
  LanguageConfig: () => LanguageConfig,
162
164
  LegalStatuses: () => LegalStatuses,
163
165
  Location: () => Location,
166
+ LocationStatus: () => LocationStatus,
164
167
  LocationTypeV1: () => LocationTypeV1,
168
+ LocationVersion: () => LocationVersion,
165
169
  METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
166
170
  MarkAsDuplicateActionInput: () => MarkAsDuplicateActionInput,
167
171
  MarkNotDuplicateActionInput: () => MarkNotDuplicateActionInput,
@@ -201,6 +205,8 @@ __export(events_exports, {
201
205
  SelectDateRangeOption: () => SelectDateRangeOption,
202
206
  SelectDateRangeValue: () => SelectDateRangeValue,
203
207
  SelectOption: () => SelectOption,
208
+ SetAdministrativeAreaPayload: () => SetAdministrativeAreaPayload,
209
+ SetLocationPayload: () => SetLocationPayload,
204
210
  ShowConditional: () => ShowConditional,
205
211
  SignatureFieldValue: () => SignatureFieldValue,
206
212
  StaticDataEntry: () => StaticDataEntry,
@@ -216,6 +222,8 @@ __export(events_exports, {
216
222
  UUID: () => UUID,
217
223
  UnarchiveActionInput: () => UnarchiveActionInput,
218
224
  UnassignActionInput: () => UnassignActionInput,
225
+ UpdateAdministrativeAreaPayload: () => UpdateAdministrativeAreaPayload,
226
+ UpdateLocationPayload: () => UpdateLocationPayload,
219
227
  UserAuditRecordInput: () => UserAuditRecordInput,
220
228
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
221
229
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
@@ -225,6 +233,8 @@ __export(events_exports, {
225
233
  VerificationActionConfig: () => VerificationActionConfig,
226
234
  VerificationPageConfig: () => VerificationPageConfig,
227
235
  VerificationStatusValue: () => VerificationStatusValue,
236
+ WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
237
+ WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
228
238
  Within: () => Within,
229
239
  WorkqueueActionType: () => WorkqueueActionType,
230
240
  WorkqueueColumn: () => WorkqueueColumn,
@@ -313,6 +323,7 @@ __export(events_exports, {
313
323
  getActionAnnotation: () => getActionAnnotation,
314
324
  getActionAnnotationFields: () => getActionAnnotationFields,
315
325
  getActionConfig: () => getActionConfig,
326
+ getActionFormFields: () => getActionFormFields,
316
327
  getActionReview: () => getActionReview,
317
328
  getActionReviewFields: () => getActionReviewFields,
318
329
  getAdministrativeAreaHierarchy: () => getAdministrativeAreaHierarchy,
@@ -342,6 +353,7 @@ __export(events_exports, {
342
353
  getStatusFromActions: () => getStatusFromActions,
343
354
  getValidatorsForField: () => getValidatorsForField,
344
355
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
356
+ hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
345
357
  hasAnyOfScopes: () => hasAnyOfScopes,
346
358
  isActionAvailable: () => isActionAvailable,
347
359
  isActionConfigType: () => isActionConfigType,
@@ -432,6 +444,7 @@ __export(events_exports, {
432
444
  resolveDateOfEvent: () => resolveDateOfEvent,
433
445
  resolveEventCustomFlags: () => resolveEventCustomFlags,
434
446
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
447
+ resolveVersion: () => resolveVersion,
435
448
  runClientFunction: () => runClientFunction,
436
449
  runFieldValidations: () => runFieldValidations,
437
450
  runStructuralValidations: () => runStructuralValidations,
@@ -499,6 +512,7 @@ var PlainScopeType = z2.enum([
499
512
  "integration.create",
500
513
  "record.import",
501
514
  "config.update-all",
515
+ "location.edit",
502
516
  "attachment.upload",
503
517
  "profile.electronic-signature",
504
518
  "user.read-only-my-audit",
@@ -981,6 +995,82 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
981
995
  requestData: z5.object({ id: z5.string() }),
982
996
  responseSummary: z5.object({ clientId: z5.string() })
983
997
  });
998
+ var createdVersionFields = {
999
+ id: z5.string(),
1000
+ versionId: z5.string(),
1001
+ name: z5.string(),
1002
+ externalId: z5.string().nullish(),
1003
+ effectiveFrom: z5.string(),
1004
+ status: z5.string()
1005
+ };
1006
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
1007
+ operation: z5.literal("locations.create"),
1008
+ requestData: z5.object({
1009
+ ...createdVersionFields,
1010
+ administrativeAreaId: z5.string().nullish(),
1011
+ locationType: z5.string().nullish()
1012
+ })
1013
+ });
1014
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
1015
+ operation: z5.literal("administrativeAreas.create"),
1016
+ requestData: z5.object({
1017
+ ...createdVersionFields,
1018
+ parentId: z5.string().nullish()
1019
+ })
1020
+ });
1021
+ var ChangedStringField = z5.object({ from: z5.string(), to: z5.string() });
1022
+ var ChangedNullableStringField = z5.object({
1023
+ from: z5.string().nullable(),
1024
+ to: z5.string().nullable()
1025
+ });
1026
+ var updatedVersionRequestData = z5.object({
1027
+ id: z5.string(),
1028
+ versionId: z5.string(),
1029
+ name: z5.string(),
1030
+ externalId: z5.string().nullish(),
1031
+ status: z5.string(),
1032
+ effectiveFrom: z5.string(),
1033
+ lastVersionId: z5.string()
1034
+ });
1035
+ var updatedVersionResponseSummary = z5.object({
1036
+ previousVersionId: z5.string(),
1037
+ versionId: z5.string(),
1038
+ changed: z5.object({
1039
+ name: ChangedStringField.optional(),
1040
+ externalId: ChangedNullableStringField.optional(),
1041
+ status: ChangedStringField.optional()
1042
+ })
1043
+ });
1044
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
1045
+ operation: z5.literal("locations.update"),
1046
+ requestData: updatedVersionRequestData,
1047
+ responseSummary: updatedVersionResponseSummary
1048
+ });
1049
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
1050
+ operation: z5.literal("administrativeAreas.update"),
1051
+ requestData: updatedVersionRequestData,
1052
+ responseSummary: updatedVersionResponseSummary
1053
+ });
1054
+ var withdrawVersionRequestData = z5.object({
1055
+ id: z5.string(),
1056
+ versionId: z5.string()
1057
+ });
1058
+ var withdrawVersionResponseSummary = z5.object({
1059
+ effectiveFrom: z5.string(),
1060
+ name: z5.string(),
1061
+ externalId: z5.string().nullish(),
1062
+ status: z5.string()
1063
+ });
1064
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
1065
+ operation: z5.literal("locations.withdrawVersion"),
1066
+ requestData: withdrawVersionRequestData,
1067
+ responseSummary: withdrawVersionResponseSummary
1068
+ });
1069
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
1070
+ operation: z5.literal("administrativeAreas.withdrawVersion"),
1071
+ requestData: withdrawVersionRequestData,
1072
+ responseSummary: withdrawVersionResponseSummary
1073
+ });
984
1074
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
985
1075
  operation: z5.literal("attachments.upload"),
986
1076
  requestData: z5.object({
@@ -1056,6 +1146,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
1056
1146
  IntegrationActivateEntrySchema,
1057
1147
  IntegrationDeleteEntrySchema,
1058
1148
  IntegrationRefreshSecretEntrySchema,
1149
+ LocationCreateEntrySchema,
1150
+ LocationUpdateEntrySchema,
1151
+ AdministrativeAreaUpdateEntrySchema,
1152
+ LocationWithdrawEntrySchema,
1153
+ AdministrativeAreaWithdrawEntrySchema,
1154
+ AdministrativeAreaCreateEntrySchema,
1059
1155
  AttachmentUploadEntrySchema,
1060
1156
  UserCreateEntrySchema,
1061
1157
  UserReasonEntrySchema,
@@ -1675,9 +1771,10 @@ var NotifiedAction = ActionBase.extend(
1675
1771
  var EditAction = ActionBase.extend(
1676
1772
  z14.object({
1677
1773
  type: z14.literal(ActionType.EDIT),
1774
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1678
1775
  content: z14.object({
1679
1776
  comment: z14.string().describe("Comment for the edit action.").optional()
1680
- })
1777
+ }).optional()
1681
1778
  }).shape
1682
1779
  );
1683
1780
  var PrintContent = z14.object({
@@ -3238,6 +3335,9 @@ var ActionConfigBase = z24.object({
3238
3335
  var DeclarationActionBase = ActionConfigBase.extend({
3239
3336
  deduplication: DeduplicationConfig.optional()
3240
3337
  });
3338
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3339
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3340
+ );
3241
3341
  var ReadActionConfig = ActionConfigBase.extend(
3242
3342
  z24.object({
3243
3343
  type: z24.literal(ActionType.READ),
@@ -3249,7 +3349,8 @@ var ReadActionConfig = ActionConfigBase.extend(
3249
3349
  );
3250
3350
  var NotifyConfig = ActionConfigBase.extend(
3251
3351
  z24.object({
3252
- type: z24.literal(ActionType.NOTIFY)
3352
+ type: z24.literal(ActionType.NOTIFY),
3353
+ form: actionConfirmationForm
3253
3354
  }).shape
3254
3355
  );
3255
3356
  var DuplicateDetectedConfig = ActionConfigBase.extend(
@@ -3304,6 +3405,7 @@ var DeclareConfig = DeclarationActionBase.extend(
3304
3405
  review: DeclarationReviewConfig.describe(
3305
3406
  "Configuration of the review page fields."
3306
3407
  ),
3408
+ form: actionConfirmationForm,
3307
3409
  dialogCopy: z24.object({
3308
3410
  notify: TranslationConfig.describe(
3309
3411
  "Confirmation text for the notify action"
@@ -3319,7 +3421,8 @@ var DeclareConfig = DeclarationActionBase.extend(
3319
3421
  );
3320
3422
  var ArchiveConfig = ActionConfigBase.extend(
3321
3423
  z24.object({
3322
- type: z24.literal(ActionType.ARCHIVE)
3424
+ type: z24.literal(ActionType.ARCHIVE),
3425
+ form: actionConfirmationForm
3323
3426
  }).shape
3324
3427
  );
3325
3428
  var UnarchiveConfig = ActionConfigBase.extend(
@@ -3345,12 +3448,14 @@ var EditActionConfig = ActionConfigBase.extend(
3345
3448
  );
3346
3449
  var RejectConfig = ActionConfigBase.extend(
3347
3450
  z24.object({
3348
- type: z24.literal(ActionType.REJECT)
3451
+ type: z24.literal(ActionType.REJECT),
3452
+ form: actionConfirmationForm
3349
3453
  }).shape
3350
3454
  );
3351
3455
  var RegisterConfig = DeclarationActionBase.extend(
3352
3456
  z24.object({
3353
- type: z24.literal(ActionType.REGISTER)
3457
+ type: z24.literal(ActionType.REGISTER),
3458
+ form: actionConfirmationForm
3354
3459
  }).shape
3355
3460
  );
3356
3461
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -4624,7 +4729,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4624
4729
  customActionType,
4625
4730
  actionType: ActionType.CUSTOM
4626
4731
  });
4627
- if (!actionConfig || !("form" in actionConfig)) {
4732
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4733
+ return [];
4734
+ }
4735
+ return actionConfig.form;
4736
+ }
4737
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4738
+ const actionConfig = eventConfiguration.actions.find((a) => {
4739
+ if (a.type === ActionType.CUSTOM && customActionType) {
4740
+ return a.customActionType === customActionType;
4741
+ }
4742
+ return a.type === actionType;
4743
+ });
4744
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4628
4745
  return [];
4629
4746
  }
4630
4747
  return actionConfig.form;
@@ -4645,13 +4762,9 @@ var getActionAnnotationFields = (actionConfig) => {
4645
4762
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4646
4763
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4647
4764
  }
4648
- if (actionConfig.type === ActionType.CUSTOM) {
4649
- return actionConfig.form;
4650
- }
4651
- if ("review" in actionConfig && actionConfig.review != null) {
4652
- return actionConfig.review.fields;
4653
- }
4654
- return [];
4765
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4766
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4767
+ return [...reviewFields, ...formFields];
4655
4768
  };
4656
4769
  function getAllAnnotationFields(config) {
4657
4770
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -6398,10 +6511,7 @@ var DeclareActionInput = BaseActionInput.extend(
6398
6511
  );
6399
6512
  var EditActionInput = BaseActionInput.extend(
6400
6513
  z38.object({
6401
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
6402
- content: z38.object({
6403
- comment: z38.string().describe("Comment for the edit action.").optional()
6404
- })
6514
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
6405
6515
  }).shape
6406
6516
  );
6407
6517
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -9946,7 +10056,6 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9946
10056
  },
9947
10057
  edit: (eventId, input = {}) => ({
9948
10058
  type: ActionType.EDIT,
9949
- content: { comment: "Test comment" },
9950
10059
  transactionId: input.transactionId ?? getUUID(),
9951
10060
  declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
9952
10061
  annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
@@ -10452,21 +10561,60 @@ var LocationTypeV1 = z43.enum([
10452
10561
  "CRVS_OFFICE",
10453
10562
  "HEALTH_FACILITY"
10454
10563
  ]);
10564
+ var LocationStatus = z43.enum(["active", "inactive"]);
10565
+ var LocationVersion = z43.object({
10566
+ versionId: UUID,
10567
+ effectiveFrom: z43.iso.date(),
10568
+ name: z43.string(),
10569
+ externalId: z43.string().nullish(),
10570
+ status: LocationStatus
10571
+ });
10455
10572
  var AdministrativeArea = z43.object({
10456
10573
  id: UUID,
10457
10574
  name: z43.string(),
10458
10575
  externalId: z43.string().nullish(),
10459
10576
  parentId: UUID.nullable(),
10460
- validUntil: z43.iso.datetime().nullable()
10577
+ status: LocationStatus,
10578
+ versions: z43.array(LocationVersion)
10461
10579
  });
10462
10580
  var Location = z43.object({
10463
10581
  id: UUID,
10464
10582
  name: z43.string(),
10465
10583
  externalId: z43.string().nullish(),
10466
10584
  administrativeAreaId: UUID.nullable(),
10467
- validUntil: z43.iso.datetime().nullable(),
10585
+ locationType: z43.string().nullable(),
10586
+ status: LocationStatus,
10587
+ versions: z43.array(LocationVersion)
10588
+ });
10589
+ var SetLocationPayload = z43.object({
10590
+ id: UUID,
10591
+ name: z43.string(),
10592
+ externalId: z43.string().nullish(),
10593
+ administrativeAreaId: UUID.nullable(),
10468
10594
  locationType: z43.string().nullable()
10469
10595
  });
10596
+ var SetAdministrativeAreaPayload = z43.object({
10597
+ id: UUID,
10598
+ name: z43.string(),
10599
+ externalId: z43.string().nullish(),
10600
+ parentId: UUID.nullable()
10601
+ });
10602
+ function resolveVersion(versions, anchor) {
10603
+ let resolved = versions[0];
10604
+ for (const version of versions) {
10605
+ if (version.effectiveFrom <= anchor) {
10606
+ resolved = version;
10607
+ }
10608
+ }
10609
+ return resolved;
10610
+ }
10611
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10612
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10613
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10614
+ return [inEffectAtAnchor, ...laterVersions].some(
10615
+ (v) => v.externalId === externalId && v.status === "active"
10616
+ );
10617
+ }
10470
10618
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10471
10619
  if (!locationIds) {
10472
10620
  return false;
@@ -10946,75 +11094,80 @@ function getFilePathsFromEvent(event2) {
10946
11094
  }
10947
11095
 
10948
11096
  // ../commons/src/events/mocks.test.utils.ts
10949
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11097
+ function withVersionFields(entity) {
11098
+ return {
11099
+ ...entity,
11100
+ status: "active",
11101
+ versions: [
11102
+ {
11103
+ versionId: entity.id,
11104
+ effectiveFrom: "0001-01-01",
11105
+ name: entity.name,
11106
+ externalId: entity.externalId ?? null,
11107
+ status: "active"
11108
+ }
11109
+ ]
11110
+ };
11111
+ }
11112
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
10950
11113
  {
10951
11114
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10952
11115
  name: "Central",
10953
11116
  parentId: null,
10954
- validUntil: null,
10955
11117
  externalId: "ydyJb1RAy4U1"
10956
11118
  },
10957
11119
  {
10958
11120
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10959
11121
  name: "Sulaka",
10960
11122
  parentId: null,
10961
- validUntil: null,
10962
11123
  externalId: "pQ8nGxWmZ2Q3"
10963
11124
  },
10964
11125
  {
10965
11126
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10966
11127
  name: "Pualula",
10967
11128
  parentId: null,
10968
- validUntil: null,
10969
11129
  externalId: "Aq91DweLmT8k"
10970
11130
  },
10971
11131
  {
10972
11132
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10973
11133
  name: "Chuminga",
10974
11134
  parentId: null,
10975
- validUntil: null,
10976
11135
  externalId: "Rw0fYNh2Xk9a"
10977
11136
  },
10978
11137
  {
10979
11138
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10980
11139
  name: "Ibombo",
10981
11140
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10982
- validUntil: null,
10983
11141
  externalId: "k7DsP4vbN1Qe"
10984
11142
  },
10985
11143
  {
10986
11144
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
10987
11145
  name: "Isango",
10988
11146
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10989
- validUntil: null,
10990
11147
  externalId: "Gm3Z9eQpHw4L"
10991
11148
  },
10992
11149
  {
10993
11150
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
10994
11151
  name: "Isamba",
10995
11152
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10996
- validUntil: null,
10997
11153
  externalId: "sT0xVu1KqJ7r"
10998
11154
  },
10999
11155
  {
11000
11156
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11001
11157
  name: "Itambo",
11002
11158
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11003
- validUntil: null,
11004
11159
  externalId: "Nq6Bv2HpL9Te"
11005
11160
  },
11006
11161
  {
11007
11162
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11008
11163
  name: "Ezhi",
11009
11164
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11010
- validUntil: null,
11011
11165
  externalId: "xK8cQ0ZRy5Wd"
11012
11166
  },
11013
11167
  {
11014
11168
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11015
11169
  name: "Ilanga",
11016
11170
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11017
- validUntil: null,
11018
11171
  externalId: "Cq4Jm1XvN8Ls"
11019
11172
  },
11020
11173
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -11022,49 +11175,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11022
11175
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11023
11176
  name: "Klow",
11024
11177
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11025
- validUntil: null,
11026
11178
  externalId: "IkYcYBUcyY2"
11027
11179
  },
11028
11180
  {
11029
11181
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11030
11182
  name: "Mbondo",
11031
11183
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11032
- validUntil: null,
11033
11184
  externalId: "Qhvv5hvo3mY"
11034
11185
  },
11035
11186
  {
11036
11187
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11037
11188
  name: "Ndara",
11038
11189
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11039
- validUntil: null,
11040
11190
  externalId: "crXh068O9TR"
11041
11191
  },
11042
11192
  {
11043
11193
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11044
11194
  name: "Olani",
11045
11195
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11046
- validUntil: null,
11047
11196
  externalId: "r00It8Tvvp7"
11048
11197
  },
11049
11198
  {
11050
11199
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11051
11200
  name: "Pemba",
11052
11201
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11053
- validUntil: null,
11054
11202
  externalId: "ZnUWsbONIaH"
11055
11203
  },
11056
11204
  {
11057
11205
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11058
11206
  name: "Quanza",
11059
11207
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11060
- validUntil: null,
11061
11208
  externalId: "fDZycvQTa7l"
11062
11209
  },
11063
11210
  {
11064
11211
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11065
11212
  name: "Rivka",
11066
11213
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11067
- validUntil: null,
11068
11214
  externalId: "KqswxCGTELa"
11069
11215
  },
11070
11216
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -11072,35 +11218,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11072
11218
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11073
11219
  name: "Mbula",
11074
11220
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11075
- validUntil: null,
11076
11221
  externalId: "osEbKjRc9Kg"
11077
11222
  },
11078
11223
  {
11079
11224
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11080
11225
  name: "Ndoki",
11081
11226
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11082
- validUntil: null,
11083
11227
  externalId: "aq4daBUAGr3"
11084
11228
  },
11085
11229
  {
11086
11230
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11087
11231
  name: "Tsanga",
11088
11232
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11089
- validUntil: null,
11090
11233
  externalId: "cqis6Y8trbJ"
11091
11234
  },
11092
11235
  {
11093
11236
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11094
11237
  name: "Waziri",
11095
11238
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11096
- validUntil: null,
11097
11239
  externalId: "LMijHPyyx6d"
11098
11240
  },
11099
11241
  {
11100
11242
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11101
11243
  name: "Zimbi",
11102
11244
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11103
- validUntil: null,
11104
11245
  externalId: "pcQYbPuKGZ7"
11105
11246
  },
11106
11247
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -11108,67 +11249,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11108
11249
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11109
11250
  name: "Felani",
11110
11251
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11111
- validUntil: null,
11112
11252
  externalId: "gSqpoCGdMXp"
11113
11253
  },
11114
11254
  {
11115
11255
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11116
11256
  name: "Goroma",
11117
11257
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11118
- validUntil: null,
11119
11258
  externalId: "KvAAIaNqVrp"
11120
11259
  },
11121
11260
  {
11122
11261
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11123
11262
  name: "Halifu",
11124
11263
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11125
- validUntil: null,
11126
11264
  externalId: "qe4UnEVt1hv"
11127
11265
  },
11128
11266
  {
11129
11267
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11130
11268
  name: "Jabari",
11131
11269
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11132
- validUntil: null,
11133
11270
  externalId: "yHH9Nz4rLOt"
11134
11271
  },
11135
11272
  {
11136
11273
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11137
11274
  name: "Kifani",
11138
11275
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11139
- validUntil: null,
11140
11276
  externalId: "eSWmXIGeu1I"
11141
11277
  },
11142
11278
  {
11143
11279
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11144
11280
  name: "Lumela",
11145
11281
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11146
- validUntil: null,
11147
11282
  externalId: "bh0b3aI1uP3"
11148
11283
  }
11149
11284
  ];
11150
- var V2_DEFAULT_MOCK_LOCATIONS = [
11285
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11286
+ var MOCK_LOCATIONS_BASE = [
11151
11287
  {
11152
11288
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11153
11289
  name: "Central Provincial Office",
11154
11290
  locationType: "CRVS_OFFICE",
11155
11291
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11156
- validUntil: null,
11157
11292
  externalId: "Xr3Df8WpK6Ys"
11158
11293
  },
11159
11294
  {
11160
11295
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11161
11296
  name: "Central Health Post",
11162
11297
  locationType: "HEALTH_FACILITY",
11163
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11164
- validUntil: null
11298
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11165
11299
  },
11166
11300
  {
11167
11301
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11168
11302
  name: "Ibombo District Office",
11169
11303
  locationType: "CRVS_OFFICE",
11170
11304
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11171
- validUntil: null,
11172
11305
  externalId: "Sm4Nw7GrD2Vy"
11173
11306
  },
11174
11307
  {
@@ -11176,7 +11309,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11176
11309
  name: "Isamba District Office",
11177
11310
  locationType: "CRVS_OFFICE",
11178
11311
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11179
- validUntil: null,
11180
11312
  externalId: "Vg1Bq5XeH9Lt"
11181
11313
  },
11182
11314
  {
@@ -11184,7 +11316,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11184
11316
  name: "Isango District Office",
11185
11317
  locationType: "CRVS_OFFICE",
11186
11318
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11187
- validUntil: null,
11188
11319
  externalId: "Je7Lm2XqN9Vz"
11189
11320
  },
11190
11321
  {
@@ -11192,7 +11323,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11192
11323
  name: "Sulaka Provincial Office",
11193
11324
  locationType: "CRVS_OFFICE",
11194
11325
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11195
- validUntil: null,
11196
11326
  externalId: "Ht2Wp9KcX5Qv"
11197
11327
  },
11198
11328
  {
@@ -11200,7 +11330,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11200
11330
  name: "Ilanga District Office",
11201
11331
  locationType: "CRVS_OFFICE",
11202
11332
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11203
- validUntil: null,
11204
11333
  externalId: "Yp6Ds1WqN3Xz"
11205
11334
  },
11206
11335
  {
@@ -11208,7 +11337,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11208
11337
  name: "Chamakubi Health Post",
11209
11338
  locationType: "HEALTH_FACILITY",
11210
11339
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11211
- validUntil: null,
11212
11340
  externalId: "M1nFr8LbC2Qy"
11213
11341
  },
11214
11342
  {
@@ -11216,7 +11344,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11216
11344
  name: "Ibombo Rural Health Centre",
11217
11345
  locationType: "HEALTH_FACILITY",
11218
11346
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11219
- validUntil: null,
11220
11347
  externalId: "bT7pV6YrW0Xc"
11221
11348
  },
11222
11349
  {
@@ -11224,7 +11351,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11224
11351
  name: "Chikobo Rural Health Centre",
11225
11352
  locationType: "HEALTH_FACILITY",
11226
11353
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11227
- validUntil: null,
11228
11354
  externalId: "zE4qPn2SgJ5d"
11229
11355
  },
11230
11356
  {
@@ -11232,7 +11358,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11232
11358
  name: "Chilochabalenje Health Post",
11233
11359
  locationType: "HEALTH_FACILITY",
11234
11360
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11235
- validUntil: null,
11236
11361
  externalId: "H8vDs1MqR4Uf"
11237
11362
  },
11238
11363
  {
@@ -11240,7 +11365,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11240
11365
  name: "Chipeso Rural Health Centre",
11241
11366
  locationType: "HEALTH_FACILITY",
11242
11367
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11243
- validUntil: null,
11244
11368
  externalId: "Qw3uZ9KfX6Lm"
11245
11369
  },
11246
11370
  {
@@ -11248,7 +11372,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11248
11372
  name: "Chisamba Rural Health Centre",
11249
11373
  locationType: "HEALTH_FACILITY",
11250
11374
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11251
- validUntil: null,
11252
11375
  externalId: "Yr0pCg8LdM2s"
11253
11376
  },
11254
11377
  {
@@ -11256,7 +11379,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11256
11379
  name: "Chitanda Rural Health Centre",
11257
11380
  locationType: "HEALTH_FACILITY",
11258
11381
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11259
- validUntil: null,
11260
11382
  externalId: "tS9gJ4PwB1Qx"
11261
11383
  },
11262
11384
  {
@@ -11264,7 +11386,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11264
11386
  name: "Golden Valley Rural Health Centre",
11265
11387
  locationType: "HEALTH_FACILITY",
11266
11388
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11267
- validUntil: null,
11268
11389
  externalId: "Ld7Qm3XsA8Vr"
11269
11390
  },
11270
11391
  {
@@ -11272,7 +11393,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11272
11393
  name: "Ipongo Rural Health Centre",
11273
11394
  locationType: "HEALTH_FACILITY",
11274
11395
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11275
- validUntil: null,
11276
11396
  externalId: "kF2sW9DmH0Bt"
11277
11397
  },
11278
11398
  {
@@ -11280,7 +11400,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11280
11400
  name: "Itumbwe Health Post",
11281
11401
  locationType: "HEALTH_FACILITY",
11282
11402
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11283
- validUntil: null,
11284
11403
  externalId: "Ue5Xb3VaC7Pq"
11285
11404
  },
11286
11405
  {
@@ -11288,7 +11407,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11288
11407
  name: "Kabangalala Rural Health Centre",
11289
11408
  locationType: "HEALTH_FACILITY",
11290
11409
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11291
- validUntil: null,
11292
11410
  externalId: "Pz8Kc1TqH6Jn"
11293
11411
  },
11294
11412
  // Village offices
@@ -11297,13 +11415,61 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11297
11415
  name: "Klow Village Office",
11298
11416
  locationType: "CRVS_OFFICE",
11299
11417
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11300
- validUntil: null,
11301
11418
  externalId: "PmAyxAJkxiJ"
11302
11419
  }
11303
11420
  ];
11421
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11304
11422
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11305
11423
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11306
11424
  );
11307
11425
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11308
11426
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11309
11427
  );
11428
+
11429
+ // ../commons/src/events/locationPayloads.ts
11430
+ var z44 = __toESM(require("zod/v4"));
11431
+ var CreateLocationPayload = z44.object({
11432
+ id: UUID.optional(),
11433
+ versionId: UUID.optional(),
11434
+ name: z44.string(),
11435
+ externalId: z44.string().nullish(),
11436
+ administrativeAreaId: UUID.nullable(),
11437
+ locationType: z44.string().nullable(),
11438
+ effectiveFrom: z44.iso.date().optional(),
11439
+ status: LocationStatus.default("active")
11440
+ });
11441
+ var UpdateLocationPayload = z44.strictObject({
11442
+ id: UUID,
11443
+ versionId: UUID.optional(),
11444
+ name: z44.string(),
11445
+ externalId: z44.string().nullish(),
11446
+ status: LocationStatus,
11447
+ effectiveFrom: z44.iso.date().optional(),
11448
+ lastVersionId: UUID
11449
+ });
11450
+ var WithdrawLocationVersionPayload = z44.object({
11451
+ id: UUID,
11452
+ versionId: UUID
11453
+ });
11454
+ var CreateAdministrativeAreaPayload = z44.object({
11455
+ id: UUID.optional(),
11456
+ versionId: UUID.optional(),
11457
+ name: z44.string(),
11458
+ externalId: z44.string().nullish(),
11459
+ parentId: UUID.nullable(),
11460
+ effectiveFrom: z44.iso.date().optional(),
11461
+ status: LocationStatus.default("active")
11462
+ });
11463
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11464
+ id: UUID,
11465
+ versionId: UUID.optional(),
11466
+ name: z44.string(),
11467
+ externalId: z44.string().nullish(),
11468
+ status: LocationStatus,
11469
+ effectiveFrom: z44.iso.date().optional(),
11470
+ lastVersionId: UUID
11471
+ });
11472
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11473
+ id: UUID,
11474
+ versionId: UUID
11475
+ });