@opencrvs/toolkit 2.1.0-rc.7d9a8f9 → 2.1.0-rc.7f423f1

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 (62) hide show
  1. package/dist/application-config/index.js +3 -1
  2. package/dist/cli.js +0 -48
  3. package/dist/commons/api/router.d.ts +3453 -3313
  4. package/dist/commons/application-config/index.d.ts +6 -6
  5. package/dist/commons/conditionals/conditionals.d.ts +259 -2102
  6. package/dist/commons/events/ActionConfig.d.ts +112 -105
  7. package/dist/commons/events/ActionDocument.d.ts +119 -119
  8. package/dist/commons/events/ActionInput.d.ts +0 -6
  9. package/dist/commons/events/ActionType.d.ts +62 -62
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +513 -507
  11. package/dist/commons/events/AuditLog.d.ts +104 -42
  12. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  13. package/dist/commons/events/Conditional.d.ts +3 -3
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  15. package/dist/commons/events/Draft.d.ts +37 -37
  16. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  17. package/dist/commons/events/EventConfig.d.ts +5 -5
  18. package/dist/commons/events/EventDocument.d.ts +48 -48
  19. package/dist/commons/events/EventIndex.d.ts +62 -62
  20. package/dist/commons/events/EventMetadata.d.ts +40 -40
  21. package/dist/commons/events/FieldConfig.d.ts +341 -336
  22. package/dist/commons/events/FieldType.d.ts +51 -51
  23. package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
  24. package/dist/commons/events/FieldValue.d.ts +12 -12
  25. package/dist/commons/events/Flag.d.ts +15 -15
  26. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  27. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  28. package/dist/commons/events/WorkqueueConfig.d.ts +826 -826
  29. package/dist/commons/events/deduplication.d.ts +1 -1
  30. package/dist/commons/events/event.d.ts +2 -2
  31. package/dist/commons/events/field.d.ts +78 -895
  32. package/dist/commons/events/index.d.ts +1 -0
  33. package/dist/commons/events/locationPayloads.d.ts +95 -0
  34. package/dist/commons/events/locations.d.ts +103 -6
  35. package/dist/commons/events/mocks.test.utils.d.ts +18 -4
  36. package/dist/commons/events/scopes.d.ts +4 -4
  37. package/dist/commons/events/state/index.d.ts +17 -17
  38. package/dist/commons/events/state/utils.d.ts +7 -7
  39. package/dist/commons/events/test.utils.d.ts +40 -43
  40. package/dist/commons/events/utils.d.ts +122 -114
  41. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  42. package/dist/conditionals/index.js +1 -0
  43. package/dist/environment/derived-variables.d.ts +119 -131
  44. package/dist/environment/derived-variables.d.ts.map +1 -1
  45. package/dist/environment/derived-variables.js +0 -14
  46. package/dist/environment/logger.d.ts.map +1 -1
  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 -28
  50. package/dist/environment/utils.d.ts +1 -1
  51. package/dist/events/deduplication.d.ts +1 -1
  52. package/dist/events/index.js +201 -70
  53. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  54. package/dist/notification/index.js +184 -93
  55. package/dist/scopes/index.d.ts +148 -146
  56. package/dist/scopes/index.js +1 -0
  57. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  58. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  59. package/opencrvs-toolkit-2.1.0-rc.7f423f1.tgz +0 -0
  60. package/package.json +3 -4
  61. package/tsconfig.tsbuildinfo +1 -1
  62. package/opencrvs-toolkit-2.1.0-rc.7d9a8f9.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,51 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
981
995
  requestData: z5.object({ id: z5.string() }),
982
996
  responseSummary: z5.object({ clientId: z5.string() })
983
997
  });
998
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
999
+ operation: z5.enum(["locations.create", "administrativeAreas.create"]),
1000
+ requestData: z5.object({
1001
+ id: z5.string(),
1002
+ versionId: z5.string(),
1003
+ name: z5.string(),
1004
+ externalId: z5.string().nullish(),
1005
+ administrativeAreaId: z5.string().nullish(),
1006
+ // locations only
1007
+ parentId: z5.string().nullish(),
1008
+ // administrative areas only
1009
+ locationType: z5.string().nullish(),
1010
+ // locations only
1011
+ effectiveFrom: z5.string(),
1012
+ status: z5.string()
1013
+ })
1014
+ });
1015
+ var ChangedStringField = z5.object({ from: z5.string(), to: z5.string() });
1016
+ var ChangedNullableStringField = z5.object({
1017
+ from: z5.string().nullable(),
1018
+ to: z5.string().nullable()
1019
+ });
1020
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
1021
+ operation: z5.enum(["locations.update", "administrativeAreas.update"]),
1022
+ /** The submitted snapshot, with server-resolved `versionId`/`effectiveFrom`. */
1023
+ requestData: z5.object({
1024
+ id: z5.string(),
1025
+ versionId: z5.string(),
1026
+ name: z5.string(),
1027
+ externalId: z5.string().nullish(),
1028
+ status: z5.string(),
1029
+ effectiveFrom: z5.string(),
1030
+ lastVersionId: z5.string()
1031
+ }),
1032
+ /** The diff against the previous version — only fields that changed. */
1033
+ responseSummary: z5.object({
1034
+ previousVersionId: z5.string(),
1035
+ versionId: z5.string(),
1036
+ changed: z5.object({
1037
+ name: ChangedStringField.optional(),
1038
+ externalId: ChangedNullableStringField.optional(),
1039
+ status: ChangedStringField.optional()
1040
+ })
1041
+ })
1042
+ });
984
1043
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
985
1044
  operation: z5.literal("attachments.upload"),
986
1045
  requestData: z5.object({
@@ -1056,6 +1115,8 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
1056
1115
  IntegrationActivateEntrySchema,
1057
1116
  IntegrationDeleteEntrySchema,
1058
1117
  IntegrationRefreshSecretEntrySchema,
1118
+ LocationCreateEntrySchema,
1119
+ LocationUpdateEntrySchema,
1059
1120
  AttachmentUploadEntrySchema,
1060
1121
  UserCreateEntrySchema,
1061
1122
  UserReasonEntrySchema,
@@ -1675,9 +1736,10 @@ var NotifiedAction = ActionBase.extend(
1675
1736
  var EditAction = ActionBase.extend(
1676
1737
  z14.object({
1677
1738
  type: z14.literal(ActionType.EDIT),
1739
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1678
1740
  content: z14.object({
1679
1741
  comment: z14.string().describe("Comment for the edit action.").optional()
1680
- })
1742
+ }).optional()
1681
1743
  }).shape
1682
1744
  );
1683
1745
  var PrintContent = z14.object({
@@ -3238,6 +3300,9 @@ var ActionConfigBase = z24.object({
3238
3300
  var DeclarationActionBase = ActionConfigBase.extend({
3239
3301
  deduplication: DeduplicationConfig.optional()
3240
3302
  });
3303
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
3304
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
3305
+ );
3241
3306
  var ReadActionConfig = ActionConfigBase.extend(
3242
3307
  z24.object({
3243
3308
  type: z24.literal(ActionType.READ),
@@ -3249,7 +3314,8 @@ var ReadActionConfig = ActionConfigBase.extend(
3249
3314
  );
3250
3315
  var NotifyConfig = ActionConfigBase.extend(
3251
3316
  z24.object({
3252
- type: z24.literal(ActionType.NOTIFY)
3317
+ type: z24.literal(ActionType.NOTIFY),
3318
+ form: actionConfirmationForm
3253
3319
  }).shape
3254
3320
  );
3255
3321
  var DuplicateDetectedConfig = ActionConfigBase.extend(
@@ -3304,6 +3370,7 @@ var DeclareConfig = DeclarationActionBase.extend(
3304
3370
  review: DeclarationReviewConfig.describe(
3305
3371
  "Configuration of the review page fields."
3306
3372
  ),
3373
+ form: actionConfirmationForm,
3307
3374
  dialogCopy: z24.object({
3308
3375
  notify: TranslationConfig.describe(
3309
3376
  "Confirmation text for the notify action"
@@ -3319,7 +3386,8 @@ var DeclareConfig = DeclarationActionBase.extend(
3319
3386
  );
3320
3387
  var ArchiveConfig = ActionConfigBase.extend(
3321
3388
  z24.object({
3322
- type: z24.literal(ActionType.ARCHIVE)
3389
+ type: z24.literal(ActionType.ARCHIVE),
3390
+ form: actionConfirmationForm
3323
3391
  }).shape
3324
3392
  );
3325
3393
  var UnarchiveConfig = ActionConfigBase.extend(
@@ -3345,12 +3413,14 @@ var EditActionConfig = ActionConfigBase.extend(
3345
3413
  );
3346
3414
  var RejectConfig = ActionConfigBase.extend(
3347
3415
  z24.object({
3348
- type: z24.literal(ActionType.REJECT)
3416
+ type: z24.literal(ActionType.REJECT),
3417
+ form: actionConfirmationForm
3349
3418
  }).shape
3350
3419
  );
3351
3420
  var RegisterConfig = DeclarationActionBase.extend(
3352
3421
  z24.object({
3353
- type: z24.literal(ActionType.REGISTER)
3422
+ type: z24.literal(ActionType.REGISTER),
3423
+ form: actionConfirmationForm
3354
3424
  }).shape
3355
3425
  );
3356
3426
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -4624,7 +4694,19 @@ function getCustomActionFields(eventConfiguration, customActionType) {
4624
4694
  customActionType,
4625
4695
  actionType: ActionType.CUSTOM
4626
4696
  });
4627
- if (!actionConfig || !("form" in actionConfig)) {
4697
+ if (!actionConfig || actionConfig.type !== ActionType.CUSTOM) {
4698
+ return [];
4699
+ }
4700
+ return actionConfig.form;
4701
+ }
4702
+ function getActionFormFields(eventConfiguration, actionType, customActionType) {
4703
+ const actionConfig = eventConfiguration.actions.find((a) => {
4704
+ if (a.type === ActionType.CUSTOM && customActionType) {
4705
+ return a.customActionType === customActionType;
4706
+ }
4707
+ return a.type === actionType;
4708
+ });
4709
+ if (!actionConfig || !("form" in actionConfig) || actionConfig.form == null) {
4628
4710
  return [];
4629
4711
  }
4630
4712
  return actionConfig.form;
@@ -4645,13 +4727,9 @@ var getActionAnnotationFields = (actionConfig) => {
4645
4727
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4646
4728
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4647
4729
  }
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 [];
4730
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4731
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4732
+ return [...reviewFields, ...formFields];
4655
4733
  };
4656
4734
  function getAllAnnotationFields(config) {
4657
4735
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -6398,10 +6476,7 @@ var DeclareActionInput = BaseActionInput.extend(
6398
6476
  );
6399
6477
  var EditActionInput = BaseActionInput.extend(
6400
6478
  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
- })
6479
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
6405
6480
  }).shape
6406
6481
  );
6407
6482
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -9946,7 +10021,6 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9946
10021
  },
9947
10022
  edit: (eventId, input = {}) => ({
9948
10023
  type: ActionType.EDIT,
9949
- content: { comment: "Test comment" },
9950
10024
  transactionId: input.transactionId ?? getUUID(),
9951
10025
  declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
9952
10026
  annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
@@ -10452,21 +10526,60 @@ var LocationTypeV1 = z43.enum([
10452
10526
  "CRVS_OFFICE",
10453
10527
  "HEALTH_FACILITY"
10454
10528
  ]);
10529
+ var LocationStatus = z43.enum(["active", "inactive"]);
10530
+ var LocationVersion = z43.object({
10531
+ versionId: UUID,
10532
+ effectiveFrom: z43.iso.date(),
10533
+ name: z43.string(),
10534
+ externalId: z43.string().nullish(),
10535
+ status: LocationStatus
10536
+ });
10455
10537
  var AdministrativeArea = z43.object({
10456
10538
  id: UUID,
10457
10539
  name: z43.string(),
10458
10540
  externalId: z43.string().nullish(),
10459
10541
  parentId: UUID.nullable(),
10460
- validUntil: z43.iso.datetime().nullable()
10542
+ status: LocationStatus,
10543
+ versions: z43.array(LocationVersion)
10461
10544
  });
10462
10545
  var Location = z43.object({
10463
10546
  id: UUID,
10464
10547
  name: z43.string(),
10465
10548
  externalId: z43.string().nullish(),
10466
10549
  administrativeAreaId: UUID.nullable(),
10467
- validUntil: z43.iso.datetime().nullable(),
10550
+ locationType: z43.string().nullable(),
10551
+ status: LocationStatus,
10552
+ versions: z43.array(LocationVersion)
10553
+ });
10554
+ var SetLocationPayload = z43.object({
10555
+ id: UUID,
10556
+ name: z43.string(),
10557
+ externalId: z43.string().nullish(),
10558
+ administrativeAreaId: UUID.nullable(),
10468
10559
  locationType: z43.string().nullable()
10469
10560
  });
10561
+ var SetAdministrativeAreaPayload = z43.object({
10562
+ id: UUID,
10563
+ name: z43.string(),
10564
+ externalId: z43.string().nullish(),
10565
+ parentId: UUID.nullable()
10566
+ });
10567
+ function resolveVersion(versions, anchor) {
10568
+ let resolved = versions[0];
10569
+ for (const version of versions) {
10570
+ if (version.effectiveFrom <= anchor) {
10571
+ resolved = version;
10572
+ }
10573
+ }
10574
+ return resolved;
10575
+ }
10576
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10577
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10578
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10579
+ return [inEffectAtAnchor, ...laterVersions].some(
10580
+ (v) => v.externalId === externalId && v.status === "active"
10581
+ );
10582
+ }
10470
10583
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10471
10584
  if (!locationIds) {
10472
10585
  return false;
@@ -10946,75 +11059,80 @@ function getFilePathsFromEvent(event2) {
10946
11059
  }
10947
11060
 
10948
11061
  // ../commons/src/events/mocks.test.utils.ts
10949
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11062
+ function withVersionFields(entity) {
11063
+ return {
11064
+ ...entity,
11065
+ status: "active",
11066
+ versions: [
11067
+ {
11068
+ versionId: entity.id,
11069
+ effectiveFrom: "0001-01-01",
11070
+ name: entity.name,
11071
+ externalId: entity.externalId ?? null,
11072
+ status: "active"
11073
+ }
11074
+ ]
11075
+ };
11076
+ }
11077
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
10950
11078
  {
10951
11079
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10952
11080
  name: "Central",
10953
11081
  parentId: null,
10954
- validUntil: null,
10955
11082
  externalId: "ydyJb1RAy4U1"
10956
11083
  },
10957
11084
  {
10958
11085
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10959
11086
  name: "Sulaka",
10960
11087
  parentId: null,
10961
- validUntil: null,
10962
11088
  externalId: "pQ8nGxWmZ2Q3"
10963
11089
  },
10964
11090
  {
10965
11091
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10966
11092
  name: "Pualula",
10967
11093
  parentId: null,
10968
- validUntil: null,
10969
11094
  externalId: "Aq91DweLmT8k"
10970
11095
  },
10971
11096
  {
10972
11097
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10973
11098
  name: "Chuminga",
10974
11099
  parentId: null,
10975
- validUntil: null,
10976
11100
  externalId: "Rw0fYNh2Xk9a"
10977
11101
  },
10978
11102
  {
10979
11103
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10980
11104
  name: "Ibombo",
10981
11105
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10982
- validUntil: null,
10983
11106
  externalId: "k7DsP4vbN1Qe"
10984
11107
  },
10985
11108
  {
10986
11109
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
10987
11110
  name: "Isango",
10988
11111
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10989
- validUntil: null,
10990
11112
  externalId: "Gm3Z9eQpHw4L"
10991
11113
  },
10992
11114
  {
10993
11115
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
10994
11116
  name: "Isamba",
10995
11117
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10996
- validUntil: null,
10997
11118
  externalId: "sT0xVu1KqJ7r"
10998
11119
  },
10999
11120
  {
11000
11121
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11001
11122
  name: "Itambo",
11002
11123
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11003
- validUntil: null,
11004
11124
  externalId: "Nq6Bv2HpL9Te"
11005
11125
  },
11006
11126
  {
11007
11127
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11008
11128
  name: "Ezhi",
11009
11129
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11010
- validUntil: null,
11011
11130
  externalId: "xK8cQ0ZRy5Wd"
11012
11131
  },
11013
11132
  {
11014
11133
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11015
11134
  name: "Ilanga",
11016
11135
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11017
- validUntil: null,
11018
11136
  externalId: "Cq4Jm1XvN8Ls"
11019
11137
  },
11020
11138
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -11022,49 +11140,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11022
11140
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11023
11141
  name: "Klow",
11024
11142
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11025
- validUntil: null,
11026
11143
  externalId: "IkYcYBUcyY2"
11027
11144
  },
11028
11145
  {
11029
11146
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11030
11147
  name: "Mbondo",
11031
11148
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11032
- validUntil: null,
11033
11149
  externalId: "Qhvv5hvo3mY"
11034
11150
  },
11035
11151
  {
11036
11152
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11037
11153
  name: "Ndara",
11038
11154
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11039
- validUntil: null,
11040
11155
  externalId: "crXh068O9TR"
11041
11156
  },
11042
11157
  {
11043
11158
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11044
11159
  name: "Olani",
11045
11160
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11046
- validUntil: null,
11047
11161
  externalId: "r00It8Tvvp7"
11048
11162
  },
11049
11163
  {
11050
11164
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11051
11165
  name: "Pemba",
11052
11166
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11053
- validUntil: null,
11054
11167
  externalId: "ZnUWsbONIaH"
11055
11168
  },
11056
11169
  {
11057
11170
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11058
11171
  name: "Quanza",
11059
11172
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11060
- validUntil: null,
11061
11173
  externalId: "fDZycvQTa7l"
11062
11174
  },
11063
11175
  {
11064
11176
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11065
11177
  name: "Rivka",
11066
11178
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11067
- validUntil: null,
11068
11179
  externalId: "KqswxCGTELa"
11069
11180
  },
11070
11181
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -11072,35 +11183,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11072
11183
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11073
11184
  name: "Mbula",
11074
11185
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11075
- validUntil: null,
11076
11186
  externalId: "osEbKjRc9Kg"
11077
11187
  },
11078
11188
  {
11079
11189
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11080
11190
  name: "Ndoki",
11081
11191
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11082
- validUntil: null,
11083
11192
  externalId: "aq4daBUAGr3"
11084
11193
  },
11085
11194
  {
11086
11195
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11087
11196
  name: "Tsanga",
11088
11197
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11089
- validUntil: null,
11090
11198
  externalId: "cqis6Y8trbJ"
11091
11199
  },
11092
11200
  {
11093
11201
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11094
11202
  name: "Waziri",
11095
11203
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11096
- validUntil: null,
11097
11204
  externalId: "LMijHPyyx6d"
11098
11205
  },
11099
11206
  {
11100
11207
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11101
11208
  name: "Zimbi",
11102
11209
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11103
- validUntil: null,
11104
11210
  externalId: "pcQYbPuKGZ7"
11105
11211
  },
11106
11212
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -11108,67 +11214,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11108
11214
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11109
11215
  name: "Felani",
11110
11216
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11111
- validUntil: null,
11112
11217
  externalId: "gSqpoCGdMXp"
11113
11218
  },
11114
11219
  {
11115
11220
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11116
11221
  name: "Goroma",
11117
11222
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11118
- validUntil: null,
11119
11223
  externalId: "KvAAIaNqVrp"
11120
11224
  },
11121
11225
  {
11122
11226
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11123
11227
  name: "Halifu",
11124
11228
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11125
- validUntil: null,
11126
11229
  externalId: "qe4UnEVt1hv"
11127
11230
  },
11128
11231
  {
11129
11232
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11130
11233
  name: "Jabari",
11131
11234
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11132
- validUntil: null,
11133
11235
  externalId: "yHH9Nz4rLOt"
11134
11236
  },
11135
11237
  {
11136
11238
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11137
11239
  name: "Kifani",
11138
11240
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11139
- validUntil: null,
11140
11241
  externalId: "eSWmXIGeu1I"
11141
11242
  },
11142
11243
  {
11143
11244
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11144
11245
  name: "Lumela",
11145
11246
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11146
- validUntil: null,
11147
11247
  externalId: "bh0b3aI1uP3"
11148
11248
  }
11149
11249
  ];
11150
- var V2_DEFAULT_MOCK_LOCATIONS = [
11250
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11251
+ var MOCK_LOCATIONS_BASE = [
11151
11252
  {
11152
11253
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11153
11254
  name: "Central Provincial Office",
11154
11255
  locationType: "CRVS_OFFICE",
11155
11256
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11156
- validUntil: null,
11157
11257
  externalId: "Xr3Df8WpK6Ys"
11158
11258
  },
11159
11259
  {
11160
11260
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11161
11261
  name: "Central Health Post",
11162
11262
  locationType: "HEALTH_FACILITY",
11163
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11164
- validUntil: null
11263
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11165
11264
  },
11166
11265
  {
11167
11266
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11168
11267
  name: "Ibombo District Office",
11169
11268
  locationType: "CRVS_OFFICE",
11170
11269
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11171
- validUntil: null,
11172
11270
  externalId: "Sm4Nw7GrD2Vy"
11173
11271
  },
11174
11272
  {
@@ -11176,7 +11274,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11176
11274
  name: "Isamba District Office",
11177
11275
  locationType: "CRVS_OFFICE",
11178
11276
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11179
- validUntil: null,
11180
11277
  externalId: "Vg1Bq5XeH9Lt"
11181
11278
  },
11182
11279
  {
@@ -11184,7 +11281,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11184
11281
  name: "Isango District Office",
11185
11282
  locationType: "CRVS_OFFICE",
11186
11283
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11187
- validUntil: null,
11188
11284
  externalId: "Je7Lm2XqN9Vz"
11189
11285
  },
11190
11286
  {
@@ -11192,7 +11288,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11192
11288
  name: "Sulaka Provincial Office",
11193
11289
  locationType: "CRVS_OFFICE",
11194
11290
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11195
- validUntil: null,
11196
11291
  externalId: "Ht2Wp9KcX5Qv"
11197
11292
  },
11198
11293
  {
@@ -11200,7 +11295,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11200
11295
  name: "Ilanga District Office",
11201
11296
  locationType: "CRVS_OFFICE",
11202
11297
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11203
- validUntil: null,
11204
11298
  externalId: "Yp6Ds1WqN3Xz"
11205
11299
  },
11206
11300
  {
@@ -11208,7 +11302,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11208
11302
  name: "Chamakubi Health Post",
11209
11303
  locationType: "HEALTH_FACILITY",
11210
11304
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11211
- validUntil: null,
11212
11305
  externalId: "M1nFr8LbC2Qy"
11213
11306
  },
11214
11307
  {
@@ -11216,7 +11309,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11216
11309
  name: "Ibombo Rural Health Centre",
11217
11310
  locationType: "HEALTH_FACILITY",
11218
11311
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11219
- validUntil: null,
11220
11312
  externalId: "bT7pV6YrW0Xc"
11221
11313
  },
11222
11314
  {
@@ -11224,7 +11316,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11224
11316
  name: "Chikobo Rural Health Centre",
11225
11317
  locationType: "HEALTH_FACILITY",
11226
11318
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11227
- validUntil: null,
11228
11319
  externalId: "zE4qPn2SgJ5d"
11229
11320
  },
11230
11321
  {
@@ -11232,7 +11323,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11232
11323
  name: "Chilochabalenje Health Post",
11233
11324
  locationType: "HEALTH_FACILITY",
11234
11325
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11235
- validUntil: null,
11236
11326
  externalId: "H8vDs1MqR4Uf"
11237
11327
  },
11238
11328
  {
@@ -11240,7 +11330,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11240
11330
  name: "Chipeso Rural Health Centre",
11241
11331
  locationType: "HEALTH_FACILITY",
11242
11332
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11243
- validUntil: null,
11244
11333
  externalId: "Qw3uZ9KfX6Lm"
11245
11334
  },
11246
11335
  {
@@ -11248,7 +11337,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11248
11337
  name: "Chisamba Rural Health Centre",
11249
11338
  locationType: "HEALTH_FACILITY",
11250
11339
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11251
- validUntil: null,
11252
11340
  externalId: "Yr0pCg8LdM2s"
11253
11341
  },
11254
11342
  {
@@ -11256,7 +11344,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11256
11344
  name: "Chitanda Rural Health Centre",
11257
11345
  locationType: "HEALTH_FACILITY",
11258
11346
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11259
- validUntil: null,
11260
11347
  externalId: "tS9gJ4PwB1Qx"
11261
11348
  },
11262
11349
  {
@@ -11264,7 +11351,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11264
11351
  name: "Golden Valley Rural Health Centre",
11265
11352
  locationType: "HEALTH_FACILITY",
11266
11353
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11267
- validUntil: null,
11268
11354
  externalId: "Ld7Qm3XsA8Vr"
11269
11355
  },
11270
11356
  {
@@ -11272,7 +11358,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11272
11358
  name: "Ipongo Rural Health Centre",
11273
11359
  locationType: "HEALTH_FACILITY",
11274
11360
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11275
- validUntil: null,
11276
11361
  externalId: "kF2sW9DmH0Bt"
11277
11362
  },
11278
11363
  {
@@ -11280,7 +11365,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11280
11365
  name: "Itumbwe Health Post",
11281
11366
  locationType: "HEALTH_FACILITY",
11282
11367
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11283
- validUntil: null,
11284
11368
  externalId: "Ue5Xb3VaC7Pq"
11285
11369
  },
11286
11370
  {
@@ -11288,7 +11372,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11288
11372
  name: "Kabangalala Rural Health Centre",
11289
11373
  locationType: "HEALTH_FACILITY",
11290
11374
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11291
- validUntil: null,
11292
11375
  externalId: "Pz8Kc1TqH6Jn"
11293
11376
  },
11294
11377
  // Village offices
@@ -11297,13 +11380,61 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11297
11380
  name: "Klow Village Office",
11298
11381
  locationType: "CRVS_OFFICE",
11299
11382
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11300
- validUntil: null,
11301
11383
  externalId: "PmAyxAJkxiJ"
11302
11384
  }
11303
11385
  ];
11386
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11304
11387
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11305
11388
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11306
11389
  );
11307
11390
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11308
11391
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11309
11392
  );
11393
+
11394
+ // ../commons/src/events/locationPayloads.ts
11395
+ var z44 = __toESM(require("zod/v4"));
11396
+ var CreateLocationPayload = z44.object({
11397
+ id: UUID.optional(),
11398
+ versionId: UUID.optional(),
11399
+ name: z44.string(),
11400
+ externalId: z44.string().nullish(),
11401
+ administrativeAreaId: UUID.nullable(),
11402
+ locationType: z44.string().nullable(),
11403
+ effectiveFrom: z44.iso.date().optional(),
11404
+ status: LocationStatus.default("active")
11405
+ });
11406
+ var UpdateLocationPayload = z44.strictObject({
11407
+ id: UUID,
11408
+ versionId: UUID.optional(),
11409
+ name: z44.string(),
11410
+ externalId: z44.string().nullish(),
11411
+ status: LocationStatus,
11412
+ effectiveFrom: z44.iso.date().optional(),
11413
+ lastVersionId: UUID
11414
+ });
11415
+ var WithdrawLocationVersionPayload = z44.object({
11416
+ id: UUID,
11417
+ versionId: UUID
11418
+ });
11419
+ var CreateAdministrativeAreaPayload = z44.object({
11420
+ id: UUID.optional(),
11421
+ versionId: UUID.optional(),
11422
+ name: z44.string(),
11423
+ externalId: z44.string().nullish(),
11424
+ parentId: UUID.nullable(),
11425
+ effectiveFrom: z44.iso.date().optional(),
11426
+ status: LocationStatus.default("active")
11427
+ });
11428
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11429
+ id: UUID,
11430
+ versionId: UUID.optional(),
11431
+ name: z44.string(),
11432
+ externalId: z44.string().nullish(),
11433
+ status: LocationStatus,
11434
+ effectiveFrom: z44.iso.date().optional(),
11435
+ lastVersionId: UUID
11436
+ });
11437
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11438
+ id: UUID,
11439
+ versionId: UUID
11440
+ });