@opencrvs/toolkit 2.1.0-rc.4308e66 → 2.1.0-rc.468b2be

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 (60) hide show
  1. package/dist/application-config/index.js +3 -1
  2. package/dist/commons/api/router.d.ts +3382 -3314
  3. package/dist/commons/application-config/index.d.ts +6 -6
  4. package/dist/commons/conditionals/conditionals.d.ts +259 -2102
  5. package/dist/commons/conditionals/validate.d.ts +3 -3
  6. package/dist/commons/events/ActionConfig.d.ts +105 -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 +79 -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 +14 -14
  25. package/dist/commons/events/Flag.d.ts +15 -15
  26. package/dist/commons/events/PlainDate.d.ts +8 -0
  27. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  28. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  29. package/dist/commons/events/WorkqueueConfig.d.ts +826 -826
  30. package/dist/commons/events/deduplication.d.ts +1 -1
  31. package/dist/commons/events/event.d.ts +2 -2
  32. package/dist/commons/events/field.d.ts +78 -895
  33. package/dist/commons/events/index.d.ts +1 -0
  34. package/dist/commons/events/locationPayloads.d.ts +95 -0
  35. package/dist/commons/events/locations.d.ts +192 -12
  36. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  37. package/dist/commons/events/scopes.d.ts +4 -4
  38. package/dist/commons/events/state/index.d.ts +17 -17
  39. package/dist/commons/events/state/utils.d.ts +7 -7
  40. package/dist/commons/events/test.utils.d.ts +40 -43
  41. package/dist/commons/events/utils.d.ts +114 -114
  42. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  43. package/dist/conditionals/index.js +1 -0
  44. package/dist/environment/derived-variables.d.ts +119 -119
  45. package/dist/environment/derived-variables.d.ts.map +1 -1
  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 -14
  50. package/dist/environment/utils.d.ts +1 -1
  51. package/dist/events/deduplication.d.ts +1 -1
  52. package/dist/events/index.js +205 -58
  53. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  54. package/dist/notification/index.js +181 -82
  55. package/dist/scopes/index.d.ts +148 -146
  56. package/dist/scopes/index.js +1 -0
  57. package/opencrvs-toolkit-2.1.0-rc.468b2be.tgz +0 -0
  58. package/package.json +5 -5
  59. package/tsconfig.tsbuildinfo +1 -1
  60. package/opencrvs-toolkit-2.1.0-rc.4308e66.tgz +0 -0
@@ -74,12 +74,16 @@ __export(events_exports, {
74
74
  CertificateTemplateConfig: () => CertificateTemplateConfig,
75
75
  CheckboxFieldValue: () => CheckboxFieldValue,
76
76
  Clause: () => Clause,
77
+ ClientAdministrativeArea: () => ClientAdministrativeArea,
78
+ ClientLocation: () => ClientLocation,
77
79
  ClientSpecificAction: () => ClientSpecificAction,
78
80
  ComputedDefaultValue: () => ComputedDefaultValue,
79
81
  Conditional: () => Conditional,
80
82
  ConditionalType: () => ConditionalType,
81
83
  ConfirmableActions: () => ConfirmableActions,
82
84
  ContainsFlags: () => ContainsFlags,
85
+ CreateAdministrativeAreaPayload: () => CreateAdministrativeAreaPayload,
86
+ CreateLocationPayload: () => CreateLocationPayload,
83
87
  CustomActionInput: () => CustomActionInput,
84
88
  CustomFieldValue: () => CustomFieldValue,
85
89
  CustomFlag: () => CustomFlag,
@@ -161,7 +165,9 @@ __export(events_exports, {
161
165
  LanguageConfig: () => LanguageConfig,
162
166
  LegalStatuses: () => LegalStatuses,
163
167
  Location: () => Location,
168
+ LocationStatus: () => LocationStatus,
164
169
  LocationTypeV1: () => LocationTypeV1,
170
+ LocationVersion: () => LocationVersion,
165
171
  METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
166
172
  MarkAsDuplicateActionInput: () => MarkAsDuplicateActionInput,
167
173
  MarkNotDuplicateActionInput: () => MarkNotDuplicateActionInput,
@@ -201,6 +207,8 @@ __export(events_exports, {
201
207
  SelectDateRangeOption: () => SelectDateRangeOption,
202
208
  SelectDateRangeValue: () => SelectDateRangeValue,
203
209
  SelectOption: () => SelectOption,
210
+ SetAdministrativeAreaPayload: () => SetAdministrativeAreaPayload,
211
+ SetLocationPayload: () => SetLocationPayload,
204
212
  ShowConditional: () => ShowConditional,
205
213
  SignatureFieldValue: () => SignatureFieldValue,
206
214
  StaticDataEntry: () => StaticDataEntry,
@@ -216,15 +224,21 @@ __export(events_exports, {
216
224
  UUID: () => UUID,
217
225
  UnarchiveActionInput: () => UnarchiveActionInput,
218
226
  UnassignActionInput: () => UnassignActionInput,
227
+ UpdateAdministrativeAreaPayload: () => UpdateAdministrativeAreaPayload,
228
+ UpdateLocationPayload: () => UpdateLocationPayload,
219
229
  UserAuditRecordInput: () => UserAuditRecordInput,
220
230
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
221
231
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
232
+ V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP,
233
+ V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP,
222
234
  V2_DEFAULT_MOCK_LOCATIONS: () => V2_DEFAULT_MOCK_LOCATIONS,
223
235
  V2_DEFAULT_MOCK_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_LOCATIONS_MAP,
224
236
  ValidationConfig: () => ValidationConfig,
225
237
  VerificationActionConfig: () => VerificationActionConfig,
226
238
  VerificationPageConfig: () => VerificationPageConfig,
227
239
  VerificationStatusValue: () => VerificationStatusValue,
240
+ WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
241
+ WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
228
242
  Within: () => Within,
229
243
  WorkqueueActionType: () => WorkqueueActionType,
230
244
  WorkqueueColumn: () => WorkqueueColumn,
@@ -343,6 +357,7 @@ __export(events_exports, {
343
357
  getStatusFromActions: () => getStatusFromActions,
344
358
  getValidatorsForField: () => getValidatorsForField,
345
359
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
360
+ hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
346
361
  hasAnyOfScopes: () => hasAnyOfScopes,
347
362
  isActionAvailable: () => isActionAvailable,
348
363
  isActionConfigType: () => isActionConfigType,
@@ -432,13 +447,18 @@ __export(events_exports, {
432
447
  precompileActionSchemas: () => precompileActionSchemas,
433
448
  resolveDateOfEvent: () => resolveDateOfEvent,
434
449
  resolveEventCustomFlags: () => resolveEventCustomFlags,
450
+ resolvePath: () => resolvePath,
435
451
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
452
+ resolveVersion: () => resolveVersion,
436
453
  runClientFunction: () => runClientFunction,
437
454
  runFieldValidations: () => runFieldValidations,
438
455
  runStructuralValidations: () => runStructuralValidations,
439
456
  safeUnion: () => safeUnion,
440
457
  status: () => status,
441
458
  timePeriodToDateRange: () => timePeriodToDateRange,
459
+ toClientAdministrativeArea: () => toClientAdministrativeArea,
460
+ toClientLocation: () => toClientLocation,
461
+ toPlainDate: () => toPlainDate,
442
462
  todayISO: () => todayISO,
443
463
  user: () => user,
444
464
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
@@ -500,6 +520,7 @@ var PlainScopeType = z2.enum([
500
520
  "integration.create",
501
521
  "record.import",
502
522
  "config.update-all",
523
+ "location.edit",
503
524
  "attachment.upload",
504
525
  "profile.electronic-signature",
505
526
  "user.read-only-my-audit",
@@ -982,6 +1003,29 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
982
1003
  requestData: z5.object({ id: z5.string() }),
983
1004
  responseSummary: z5.object({ clientId: z5.string() })
984
1005
  });
1006
+ var createdVersionFields = {
1007
+ id: z5.string(),
1008
+ versionId: z5.string(),
1009
+ name: z5.string(),
1010
+ externalId: z5.string().nullish(),
1011
+ effectiveFrom: z5.string(),
1012
+ status: z5.string()
1013
+ };
1014
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
1015
+ operation: z5.literal("locations.create"),
1016
+ requestData: z5.object({
1017
+ ...createdVersionFields,
1018
+ administrativeAreaId: z5.string().nullish(),
1019
+ locationType: z5.string().nullish()
1020
+ })
1021
+ });
1022
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
1023
+ operation: z5.literal("administrativeAreas.create"),
1024
+ requestData: z5.object({
1025
+ ...createdVersionFields,
1026
+ parentId: z5.string().nullish()
1027
+ })
1028
+ });
985
1029
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
986
1030
  operation: z5.literal("attachments.upload"),
987
1031
  requestData: z5.object({
@@ -1057,6 +1101,8 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
1057
1101
  IntegrationActivateEntrySchema,
1058
1102
  IntegrationDeleteEntrySchema,
1059
1103
  IntegrationRefreshSecretEntrySchema,
1104
+ LocationCreateEntrySchema,
1105
+ AdministrativeAreaCreateEntrySchema,
1060
1106
  AttachmentUploadEntrySchema,
1061
1107
  UserCreateEntrySchema,
1062
1108
  UserReasonEntrySchema,
@@ -1357,6 +1403,9 @@ var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1357
1403
  // ../commons/src/events/PlainDate.ts
1358
1404
  var import_zod = require("zod");
1359
1405
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1406
+ function toPlainDate(dateTime) {
1407
+ return dateTime.split("T")[0];
1408
+ }
1360
1409
  function plainDateToLocalDate(date) {
1361
1410
  const [year, month, day] = date.split("-").map(Number);
1362
1411
  return new Date(year, month - 1, day);
@@ -1676,9 +1725,10 @@ var NotifiedAction = ActionBase.extend(
1676
1725
  var EditAction = ActionBase.extend(
1677
1726
  z14.object({
1678
1727
  type: z14.literal(ActionType.EDIT),
1728
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1679
1729
  content: z14.object({
1680
1730
  comment: z14.string().describe("Comment for the edit action.").optional()
1681
- })
1731
+ }).optional()
1682
1732
  }).shape
1683
1733
  );
1684
1734
  var PrintContent = z14.object({
@@ -6415,10 +6465,7 @@ var DeclareActionInput = BaseActionInput.extend(
6415
6465
  );
6416
6466
  var EditActionInput = BaseActionInput.extend(
6417
6467
  z38.object({
6418
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
6419
- content: z38.object({
6420
- comment: z38.string().describe("Comment for the edit action.").optional()
6421
- })
6468
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
6422
6469
  }).shape
6423
6470
  );
6424
6471
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -9963,7 +10010,6 @@ function eventPayloadGenerator(rng, configuration = tennisClubMembershipEvent) {
9963
10010
  },
9964
10011
  edit: (eventId, input = {}) => ({
9965
10012
  type: ActionType.EDIT,
9966
- content: { comment: "Test comment" },
9967
10013
  transactionId: input.transactionId ?? getUUID(),
9968
10014
  declaration: input.declaration ?? generateActionDeclarationInput(configuration, ActionType.EDIT, rng),
9969
10015
  annotation: input.annotation ?? generateActionAnnotationInput(configuration, ActionType.EDIT, rng),
@@ -10469,21 +10515,85 @@ var LocationTypeV1 = z43.enum([
10469
10515
  "CRVS_OFFICE",
10470
10516
  "HEALTH_FACILITY"
10471
10517
  ]);
10518
+ var LocationStatus = z43.enum(["active", "inactive"]);
10519
+ var LocationVersion = z43.object({
10520
+ versionId: UUID,
10521
+ effectiveFrom: z43.iso.date(),
10522
+ name: z43.string(),
10523
+ externalId: z43.string().nullish(),
10524
+ status: LocationStatus
10525
+ });
10472
10526
  var AdministrativeArea = z43.object({
10473
10527
  id: UUID,
10474
10528
  name: z43.string(),
10475
10529
  externalId: z43.string().nullish(),
10476
10530
  parentId: UUID.nullable(),
10477
- validUntil: z43.iso.datetime().nullable()
10531
+ status: LocationStatus,
10532
+ versions: z43.array(LocationVersion)
10478
10533
  });
10479
10534
  var Location = z43.object({
10480
10535
  id: UUID,
10481
10536
  name: z43.string(),
10482
10537
  externalId: z43.string().nullish(),
10483
10538
  administrativeAreaId: UUID.nullable(),
10484
- validUntil: z43.iso.datetime().nullable(),
10539
+ locationType: z43.string().nullable(),
10540
+ status: LocationStatus,
10541
+ versions: z43.array(LocationVersion)
10542
+ });
10543
+ var ClientAdministrativeArea = AdministrativeArea.omit({
10544
+ name: true,
10545
+ status: true,
10546
+ externalId: true
10547
+ });
10548
+ var ClientLocation = Location.omit({
10549
+ name: true,
10550
+ status: true,
10551
+ externalId: true
10552
+ });
10553
+ function toClientLocation(location) {
10554
+ return {
10555
+ id: location.id,
10556
+ administrativeAreaId: location.administrativeAreaId,
10557
+ locationType: location.locationType,
10558
+ versions: location.versions
10559
+ };
10560
+ }
10561
+ function toClientAdministrativeArea(area) {
10562
+ return {
10563
+ id: area.id,
10564
+ parentId: area.parentId,
10565
+ versions: area.versions
10566
+ };
10567
+ }
10568
+ var SetLocationPayload = z43.object({
10569
+ id: UUID,
10570
+ name: z43.string(),
10571
+ externalId: z43.string().nullish(),
10572
+ administrativeAreaId: UUID.nullable(),
10485
10573
  locationType: z43.string().nullable()
10486
10574
  });
10575
+ var SetAdministrativeAreaPayload = z43.object({
10576
+ id: UUID,
10577
+ name: z43.string(),
10578
+ externalId: z43.string().nullish(),
10579
+ parentId: UUID.nullable()
10580
+ });
10581
+ function resolveVersion(versions, anchor) {
10582
+ let resolved = versions[0];
10583
+ for (const version of versions) {
10584
+ if (version.effectiveFrom <= anchor) {
10585
+ resolved = version;
10586
+ }
10587
+ }
10588
+ return resolved;
10589
+ }
10590
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10591
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10592
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10593
+ return [inEffectAtAnchor, ...laterVersions].some(
10594
+ (v) => v.externalId === externalId && v.status === "active"
10595
+ );
10596
+ }
10487
10597
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10488
10598
  if (!locationIds) {
10489
10599
  return false;
@@ -10659,6 +10769,16 @@ function getLocationHierarchy(selectedId, context) {
10659
10769
  );
10660
10770
  return hierarchy.reverse().map((area) => area.id);
10661
10771
  }
10772
+ function resolvePath(locationId, anchor, context) {
10773
+ return getLocationHierarchy(locationId, context).flatMap((id) => {
10774
+ const node = context.locations.get(id) ?? context.administrativeAreas.get(id);
10775
+ if (!node) {
10776
+ return [];
10777
+ }
10778
+ const { name, status: status2 } = resolveVersion(node.versions, anchor);
10779
+ return [{ id, name, status: status2 }];
10780
+ });
10781
+ }
10662
10782
 
10663
10783
  // ../commons/src/events/scopes.ts
10664
10784
  var ACTION_SCOPE_MAP = {
@@ -10963,75 +11083,80 @@ function getFilePathsFromEvent(event2) {
10963
11083
  }
10964
11084
 
10965
11085
  // ../commons/src/events/mocks.test.utils.ts
10966
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11086
+ function withVersionFields(entity) {
11087
+ return {
11088
+ ...entity,
11089
+ status: "active",
11090
+ versions: [
11091
+ {
11092
+ versionId: entity.id,
11093
+ effectiveFrom: "0001-01-01",
11094
+ name: entity.name,
11095
+ externalId: entity.externalId ?? null,
11096
+ status: "active"
11097
+ }
11098
+ ]
11099
+ };
11100
+ }
11101
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
10967
11102
  {
10968
11103
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10969
11104
  name: "Central",
10970
11105
  parentId: null,
10971
- validUntil: null,
10972
11106
  externalId: "ydyJb1RAy4U1"
10973
11107
  },
10974
11108
  {
10975
11109
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10976
11110
  name: "Sulaka",
10977
11111
  parentId: null,
10978
- validUntil: null,
10979
11112
  externalId: "pQ8nGxWmZ2Q3"
10980
11113
  },
10981
11114
  {
10982
11115
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10983
11116
  name: "Pualula",
10984
11117
  parentId: null,
10985
- validUntil: null,
10986
11118
  externalId: "Aq91DweLmT8k"
10987
11119
  },
10988
11120
  {
10989
11121
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10990
11122
  name: "Chuminga",
10991
11123
  parentId: null,
10992
- validUntil: null,
10993
11124
  externalId: "Rw0fYNh2Xk9a"
10994
11125
  },
10995
11126
  {
10996
11127
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10997
11128
  name: "Ibombo",
10998
11129
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10999
- validUntil: null,
11000
11130
  externalId: "k7DsP4vbN1Qe"
11001
11131
  },
11002
11132
  {
11003
11133
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
11004
11134
  name: "Isango",
11005
11135
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11006
- validUntil: null,
11007
11136
  externalId: "Gm3Z9eQpHw4L"
11008
11137
  },
11009
11138
  {
11010
11139
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
11011
11140
  name: "Isamba",
11012
11141
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11013
- validUntil: null,
11014
11142
  externalId: "sT0xVu1KqJ7r"
11015
11143
  },
11016
11144
  {
11017
11145
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11018
11146
  name: "Itambo",
11019
11147
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11020
- validUntil: null,
11021
11148
  externalId: "Nq6Bv2HpL9Te"
11022
11149
  },
11023
11150
  {
11024
11151
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11025
11152
  name: "Ezhi",
11026
11153
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11027
- validUntil: null,
11028
11154
  externalId: "xK8cQ0ZRy5Wd"
11029
11155
  },
11030
11156
  {
11031
11157
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11032
11158
  name: "Ilanga",
11033
11159
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11034
- validUntil: null,
11035
11160
  externalId: "Cq4Jm1XvN8Ls"
11036
11161
  },
11037
11162
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -11039,49 +11164,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11039
11164
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11040
11165
  name: "Klow",
11041
11166
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11042
- validUntil: null,
11043
11167
  externalId: "IkYcYBUcyY2"
11044
11168
  },
11045
11169
  {
11046
11170
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11047
11171
  name: "Mbondo",
11048
11172
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11049
- validUntil: null,
11050
11173
  externalId: "Qhvv5hvo3mY"
11051
11174
  },
11052
11175
  {
11053
11176
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11054
11177
  name: "Ndara",
11055
11178
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11056
- validUntil: null,
11057
11179
  externalId: "crXh068O9TR"
11058
11180
  },
11059
11181
  {
11060
11182
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11061
11183
  name: "Olani",
11062
11184
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11063
- validUntil: null,
11064
11185
  externalId: "r00It8Tvvp7"
11065
11186
  },
11066
11187
  {
11067
11188
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11068
11189
  name: "Pemba",
11069
11190
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11070
- validUntil: null,
11071
11191
  externalId: "ZnUWsbONIaH"
11072
11192
  },
11073
11193
  {
11074
11194
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11075
11195
  name: "Quanza",
11076
11196
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11077
- validUntil: null,
11078
11197
  externalId: "fDZycvQTa7l"
11079
11198
  },
11080
11199
  {
11081
11200
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11082
11201
  name: "Rivka",
11083
11202
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11084
- validUntil: null,
11085
11203
  externalId: "KqswxCGTELa"
11086
11204
  },
11087
11205
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -11089,35 +11207,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11089
11207
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11090
11208
  name: "Mbula",
11091
11209
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11092
- validUntil: null,
11093
11210
  externalId: "osEbKjRc9Kg"
11094
11211
  },
11095
11212
  {
11096
11213
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11097
11214
  name: "Ndoki",
11098
11215
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11099
- validUntil: null,
11100
11216
  externalId: "aq4daBUAGr3"
11101
11217
  },
11102
11218
  {
11103
11219
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11104
11220
  name: "Tsanga",
11105
11221
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11106
- validUntil: null,
11107
11222
  externalId: "cqis6Y8trbJ"
11108
11223
  },
11109
11224
  {
11110
11225
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11111
11226
  name: "Waziri",
11112
11227
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11113
- validUntil: null,
11114
11228
  externalId: "LMijHPyyx6d"
11115
11229
  },
11116
11230
  {
11117
11231
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11118
11232
  name: "Zimbi",
11119
11233
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11120
- validUntil: null,
11121
11234
  externalId: "pcQYbPuKGZ7"
11122
11235
  },
11123
11236
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -11125,67 +11238,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11125
11238
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11126
11239
  name: "Felani",
11127
11240
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11128
- validUntil: null,
11129
11241
  externalId: "gSqpoCGdMXp"
11130
11242
  },
11131
11243
  {
11132
11244
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11133
11245
  name: "Goroma",
11134
11246
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11135
- validUntil: null,
11136
11247
  externalId: "KvAAIaNqVrp"
11137
11248
  },
11138
11249
  {
11139
11250
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11140
11251
  name: "Halifu",
11141
11252
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11142
- validUntil: null,
11143
11253
  externalId: "qe4UnEVt1hv"
11144
11254
  },
11145
11255
  {
11146
11256
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11147
11257
  name: "Jabari",
11148
11258
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11149
- validUntil: null,
11150
11259
  externalId: "yHH9Nz4rLOt"
11151
11260
  },
11152
11261
  {
11153
11262
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11154
11263
  name: "Kifani",
11155
11264
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11156
- validUntil: null,
11157
11265
  externalId: "eSWmXIGeu1I"
11158
11266
  },
11159
11267
  {
11160
11268
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11161
11269
  name: "Lumela",
11162
11270
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11163
- validUntil: null,
11164
11271
  externalId: "bh0b3aI1uP3"
11165
11272
  }
11166
11273
  ];
11167
- var V2_DEFAULT_MOCK_LOCATIONS = [
11274
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11275
+ var MOCK_LOCATIONS_BASE = [
11168
11276
  {
11169
11277
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11170
11278
  name: "Central Provincial Office",
11171
11279
  locationType: "CRVS_OFFICE",
11172
11280
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11173
- validUntil: null,
11174
11281
  externalId: "Xr3Df8WpK6Ys"
11175
11282
  },
11176
11283
  {
11177
11284
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11178
11285
  name: "Central Health Post",
11179
11286
  locationType: "HEALTH_FACILITY",
11180
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11181
- validUntil: null
11287
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11182
11288
  },
11183
11289
  {
11184
11290
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11185
11291
  name: "Ibombo District Office",
11186
11292
  locationType: "CRVS_OFFICE",
11187
11293
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11188
- validUntil: null,
11189
11294
  externalId: "Sm4Nw7GrD2Vy"
11190
11295
  },
11191
11296
  {
@@ -11193,7 +11298,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11193
11298
  name: "Isamba District Office",
11194
11299
  locationType: "CRVS_OFFICE",
11195
11300
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11196
- validUntil: null,
11197
11301
  externalId: "Vg1Bq5XeH9Lt"
11198
11302
  },
11199
11303
  {
@@ -11201,7 +11305,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11201
11305
  name: "Isango District Office",
11202
11306
  locationType: "CRVS_OFFICE",
11203
11307
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11204
- validUntil: null,
11205
11308
  externalId: "Je7Lm2XqN9Vz"
11206
11309
  },
11207
11310
  {
@@ -11209,7 +11312,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11209
11312
  name: "Sulaka Provincial Office",
11210
11313
  locationType: "CRVS_OFFICE",
11211
11314
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11212
- validUntil: null,
11213
11315
  externalId: "Ht2Wp9KcX5Qv"
11214
11316
  },
11215
11317
  {
@@ -11217,7 +11319,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11217
11319
  name: "Ilanga District Office",
11218
11320
  locationType: "CRVS_OFFICE",
11219
11321
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11220
- validUntil: null,
11221
11322
  externalId: "Yp6Ds1WqN3Xz"
11222
11323
  },
11223
11324
  {
@@ -11225,7 +11326,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11225
11326
  name: "Chamakubi Health Post",
11226
11327
  locationType: "HEALTH_FACILITY",
11227
11328
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11228
- validUntil: null,
11229
11329
  externalId: "M1nFr8LbC2Qy"
11230
11330
  },
11231
11331
  {
@@ -11233,7 +11333,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11233
11333
  name: "Ibombo Rural Health Centre",
11234
11334
  locationType: "HEALTH_FACILITY",
11235
11335
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11236
- validUntil: null,
11237
11336
  externalId: "bT7pV6YrW0Xc"
11238
11337
  },
11239
11338
  {
@@ -11241,7 +11340,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11241
11340
  name: "Chikobo Rural Health Centre",
11242
11341
  locationType: "HEALTH_FACILITY",
11243
11342
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11244
- validUntil: null,
11245
11343
  externalId: "zE4qPn2SgJ5d"
11246
11344
  },
11247
11345
  {
@@ -11249,7 +11347,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11249
11347
  name: "Chilochabalenje Health Post",
11250
11348
  locationType: "HEALTH_FACILITY",
11251
11349
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11252
- validUntil: null,
11253
11350
  externalId: "H8vDs1MqR4Uf"
11254
11351
  },
11255
11352
  {
@@ -11257,7 +11354,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11257
11354
  name: "Chipeso Rural Health Centre",
11258
11355
  locationType: "HEALTH_FACILITY",
11259
11356
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11260
- validUntil: null,
11261
11357
  externalId: "Qw3uZ9KfX6Lm"
11262
11358
  },
11263
11359
  {
@@ -11265,7 +11361,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11265
11361
  name: "Chisamba Rural Health Centre",
11266
11362
  locationType: "HEALTH_FACILITY",
11267
11363
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11268
- validUntil: null,
11269
11364
  externalId: "Yr0pCg8LdM2s"
11270
11365
  },
11271
11366
  {
@@ -11273,7 +11368,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11273
11368
  name: "Chitanda Rural Health Centre",
11274
11369
  locationType: "HEALTH_FACILITY",
11275
11370
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11276
- validUntil: null,
11277
11371
  externalId: "tS9gJ4PwB1Qx"
11278
11372
  },
11279
11373
  {
@@ -11281,7 +11375,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11281
11375
  name: "Golden Valley Rural Health Centre",
11282
11376
  locationType: "HEALTH_FACILITY",
11283
11377
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11284
- validUntil: null,
11285
11378
  externalId: "Ld7Qm3XsA8Vr"
11286
11379
  },
11287
11380
  {
@@ -11289,7 +11382,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11289
11382
  name: "Ipongo Rural Health Centre",
11290
11383
  locationType: "HEALTH_FACILITY",
11291
11384
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11292
- validUntil: null,
11293
11385
  externalId: "kF2sW9DmH0Bt"
11294
11386
  },
11295
11387
  {
@@ -11297,7 +11389,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11297
11389
  name: "Itumbwe Health Post",
11298
11390
  locationType: "HEALTH_FACILITY",
11299
11391
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11300
- validUntil: null,
11301
11392
  externalId: "Ue5Xb3VaC7Pq"
11302
11393
  },
11303
11394
  {
@@ -11305,7 +11396,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11305
11396
  name: "Kabangalala Rural Health Centre",
11306
11397
  locationType: "HEALTH_FACILITY",
11307
11398
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11308
- validUntil: null,
11309
11399
  externalId: "Pz8Kc1TqH6Jn"
11310
11400
  },
11311
11401
  // Village offices
@@ -11314,13 +11404,70 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11314
11404
  name: "Klow Village Office",
11315
11405
  locationType: "CRVS_OFFICE",
11316
11406
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11317
- validUntil: null,
11318
11407
  externalId: "PmAyxAJkxiJ"
11319
11408
  }
11320
11409
  ];
11410
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11321
11411
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11322
11412
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11323
11413
  );
11324
11414
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11325
11415
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11326
11416
  );
11417
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
11418
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
11419
+ );
11420
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
11421
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
11422
+ a.id,
11423
+ toClientAdministrativeArea(a)
11424
+ ])
11425
+ );
11426
+
11427
+ // ../commons/src/events/locationPayloads.ts
11428
+ var z44 = __toESM(require("zod/v4"));
11429
+ var CreateLocationPayload = z44.object({
11430
+ id: UUID.optional(),
11431
+ versionId: UUID.optional(),
11432
+ name: z44.string(),
11433
+ externalId: z44.string().nullish(),
11434
+ administrativeAreaId: UUID.nullable(),
11435
+ locationType: z44.string().nullable(),
11436
+ effectiveFrom: z44.iso.date().optional(),
11437
+ status: LocationStatus.default("active")
11438
+ });
11439
+ var UpdateLocationPayload = z44.strictObject({
11440
+ id: UUID,
11441
+ versionId: UUID.optional(),
11442
+ name: z44.string(),
11443
+ externalId: z44.string().nullish(),
11444
+ status: LocationStatus,
11445
+ effectiveFrom: z44.iso.date().optional(),
11446
+ lastVersionId: UUID
11447
+ });
11448
+ var WithdrawLocationVersionPayload = z44.object({
11449
+ id: UUID,
11450
+ versionId: UUID
11451
+ });
11452
+ var CreateAdministrativeAreaPayload = z44.object({
11453
+ id: UUID.optional(),
11454
+ versionId: UUID.optional(),
11455
+ name: z44.string(),
11456
+ externalId: z44.string().nullish(),
11457
+ parentId: UUID.nullable(),
11458
+ effectiveFrom: z44.iso.date().optional(),
11459
+ status: LocationStatus.default("active")
11460
+ });
11461
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11462
+ id: UUID,
11463
+ versionId: UUID.optional(),
11464
+ name: z44.string(),
11465
+ externalId: z44.string().nullish(),
11466
+ status: LocationStatus,
11467
+ effectiveFrom: z44.iso.date().optional(),
11468
+ lastVersionId: UUID
11469
+ });
11470
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11471
+ id: UUID,
11472
+ versionId: UUID
11473
+ });