@opencrvs/toolkit 2.1.0-rc.9d2a1ba → 2.1.0-rc.9dce8c0

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.
@@ -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);
@@ -10466,21 +10515,85 @@ var LocationTypeV1 = z43.enum([
10466
10515
  "CRVS_OFFICE",
10467
10516
  "HEALTH_FACILITY"
10468
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
+ });
10469
10526
  var AdministrativeArea = z43.object({
10470
10527
  id: UUID,
10471
10528
  name: z43.string(),
10472
10529
  externalId: z43.string().nullish(),
10473
10530
  parentId: UUID.nullable(),
10474
- validUntil: z43.iso.datetime().nullable()
10531
+ status: LocationStatus,
10532
+ versions: z43.array(LocationVersion)
10475
10533
  });
10476
10534
  var Location = z43.object({
10477
10535
  id: UUID,
10478
10536
  name: z43.string(),
10479
10537
  externalId: z43.string().nullish(),
10480
10538
  administrativeAreaId: UUID.nullable(),
10481
- 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(),
10482
10573
  locationType: z43.string().nullable()
10483
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
+ }
10484
10597
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10485
10598
  if (!locationIds) {
10486
10599
  return false;
@@ -10656,6 +10769,16 @@ function getLocationHierarchy(selectedId, context) {
10656
10769
  );
10657
10770
  return hierarchy.reverse().map((area) => area.id);
10658
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
+ }
10659
10782
 
10660
10783
  // ../commons/src/events/scopes.ts
10661
10784
  var ACTION_SCOPE_MAP = {
@@ -10960,75 +11083,80 @@ function getFilePathsFromEvent(event2) {
10960
11083
  }
10961
11084
 
10962
11085
  // ../commons/src/events/mocks.test.utils.ts
10963
- 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 = [
10964
11102
  {
10965
11103
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10966
11104
  name: "Central",
10967
11105
  parentId: null,
10968
- validUntil: null,
10969
11106
  externalId: "ydyJb1RAy4U1"
10970
11107
  },
10971
11108
  {
10972
11109
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
10973
11110
  name: "Sulaka",
10974
11111
  parentId: null,
10975
- validUntil: null,
10976
11112
  externalId: "pQ8nGxWmZ2Q3"
10977
11113
  },
10978
11114
  {
10979
11115
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
10980
11116
  name: "Pualula",
10981
11117
  parentId: null,
10982
- validUntil: null,
10983
11118
  externalId: "Aq91DweLmT8k"
10984
11119
  },
10985
11120
  {
10986
11121
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
10987
11122
  name: "Chuminga",
10988
11123
  parentId: null,
10989
- validUntil: null,
10990
11124
  externalId: "Rw0fYNh2Xk9a"
10991
11125
  },
10992
11126
  {
10993
11127
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
10994
11128
  name: "Ibombo",
10995
11129
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
10996
- validUntil: null,
10997
11130
  externalId: "k7DsP4vbN1Qe"
10998
11131
  },
10999
11132
  {
11000
11133
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
11001
11134
  name: "Isango",
11002
11135
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11003
- validUntil: null,
11004
11136
  externalId: "Gm3Z9eQpHw4L"
11005
11137
  },
11006
11138
  {
11007
11139
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
11008
11140
  name: "Isamba",
11009
11141
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11010
- validUntil: null,
11011
11142
  externalId: "sT0xVu1KqJ7r"
11012
11143
  },
11013
11144
  {
11014
11145
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11015
11146
  name: "Itambo",
11016
11147
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11017
- validUntil: null,
11018
11148
  externalId: "Nq6Bv2HpL9Te"
11019
11149
  },
11020
11150
  {
11021
11151
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11022
11152
  name: "Ezhi",
11023
11153
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11024
- validUntil: null,
11025
11154
  externalId: "xK8cQ0ZRy5Wd"
11026
11155
  },
11027
11156
  {
11028
11157
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11029
11158
  name: "Ilanga",
11030
11159
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11031
- validUntil: null,
11032
11160
  externalId: "Cq4Jm1XvN8Ls"
11033
11161
  },
11034
11162
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -11036,49 +11164,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11036
11164
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11037
11165
  name: "Klow",
11038
11166
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11039
- validUntil: null,
11040
11167
  externalId: "IkYcYBUcyY2"
11041
11168
  },
11042
11169
  {
11043
11170
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11044
11171
  name: "Mbondo",
11045
11172
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11046
- validUntil: null,
11047
11173
  externalId: "Qhvv5hvo3mY"
11048
11174
  },
11049
11175
  {
11050
11176
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11051
11177
  name: "Ndara",
11052
11178
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11053
- validUntil: null,
11054
11179
  externalId: "crXh068O9TR"
11055
11180
  },
11056
11181
  {
11057
11182
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11058
11183
  name: "Olani",
11059
11184
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11060
- validUntil: null,
11061
11185
  externalId: "r00It8Tvvp7"
11062
11186
  },
11063
11187
  {
11064
11188
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11065
11189
  name: "Pemba",
11066
11190
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11067
- validUntil: null,
11068
11191
  externalId: "ZnUWsbONIaH"
11069
11192
  },
11070
11193
  {
11071
11194
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11072
11195
  name: "Quanza",
11073
11196
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11074
- validUntil: null,
11075
11197
  externalId: "fDZycvQTa7l"
11076
11198
  },
11077
11199
  {
11078
11200
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11079
11201
  name: "Rivka",
11080
11202
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11081
- validUntil: null,
11082
11203
  externalId: "KqswxCGTELa"
11083
11204
  },
11084
11205
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -11086,35 +11207,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11086
11207
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11087
11208
  name: "Mbula",
11088
11209
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11089
- validUntil: null,
11090
11210
  externalId: "osEbKjRc9Kg"
11091
11211
  },
11092
11212
  {
11093
11213
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11094
11214
  name: "Ndoki",
11095
11215
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11096
- validUntil: null,
11097
11216
  externalId: "aq4daBUAGr3"
11098
11217
  },
11099
11218
  {
11100
11219
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11101
11220
  name: "Tsanga",
11102
11221
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11103
- validUntil: null,
11104
11222
  externalId: "cqis6Y8trbJ"
11105
11223
  },
11106
11224
  {
11107
11225
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11108
11226
  name: "Waziri",
11109
11227
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11110
- validUntil: null,
11111
11228
  externalId: "LMijHPyyx6d"
11112
11229
  },
11113
11230
  {
11114
11231
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11115
11232
  name: "Zimbi",
11116
11233
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11117
- validUntil: null,
11118
11234
  externalId: "pcQYbPuKGZ7"
11119
11235
  },
11120
11236
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -11122,67 +11238,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11122
11238
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11123
11239
  name: "Felani",
11124
11240
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11125
- validUntil: null,
11126
11241
  externalId: "gSqpoCGdMXp"
11127
11242
  },
11128
11243
  {
11129
11244
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11130
11245
  name: "Goroma",
11131
11246
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11132
- validUntil: null,
11133
11247
  externalId: "KvAAIaNqVrp"
11134
11248
  },
11135
11249
  {
11136
11250
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11137
11251
  name: "Halifu",
11138
11252
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11139
- validUntil: null,
11140
11253
  externalId: "qe4UnEVt1hv"
11141
11254
  },
11142
11255
  {
11143
11256
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11144
11257
  name: "Jabari",
11145
11258
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11146
- validUntil: null,
11147
11259
  externalId: "yHH9Nz4rLOt"
11148
11260
  },
11149
11261
  {
11150
11262
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11151
11263
  name: "Kifani",
11152
11264
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11153
- validUntil: null,
11154
11265
  externalId: "eSWmXIGeu1I"
11155
11266
  },
11156
11267
  {
11157
11268
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11158
11269
  name: "Lumela",
11159
11270
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11160
- validUntil: null,
11161
11271
  externalId: "bh0b3aI1uP3"
11162
11272
  }
11163
11273
  ];
11164
- var V2_DEFAULT_MOCK_LOCATIONS = [
11274
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11275
+ var MOCK_LOCATIONS_BASE = [
11165
11276
  {
11166
11277
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11167
11278
  name: "Central Provincial Office",
11168
11279
  locationType: "CRVS_OFFICE",
11169
11280
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11170
- validUntil: null,
11171
11281
  externalId: "Xr3Df8WpK6Ys"
11172
11282
  },
11173
11283
  {
11174
11284
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11175
11285
  name: "Central Health Post",
11176
11286
  locationType: "HEALTH_FACILITY",
11177
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11178
- validUntil: null
11287
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11179
11288
  },
11180
11289
  {
11181
11290
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11182
11291
  name: "Ibombo District Office",
11183
11292
  locationType: "CRVS_OFFICE",
11184
11293
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11185
- validUntil: null,
11186
11294
  externalId: "Sm4Nw7GrD2Vy"
11187
11295
  },
11188
11296
  {
@@ -11190,7 +11298,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11190
11298
  name: "Isamba District Office",
11191
11299
  locationType: "CRVS_OFFICE",
11192
11300
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11193
- validUntil: null,
11194
11301
  externalId: "Vg1Bq5XeH9Lt"
11195
11302
  },
11196
11303
  {
@@ -11198,7 +11305,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11198
11305
  name: "Isango District Office",
11199
11306
  locationType: "CRVS_OFFICE",
11200
11307
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11201
- validUntil: null,
11202
11308
  externalId: "Je7Lm2XqN9Vz"
11203
11309
  },
11204
11310
  {
@@ -11206,7 +11312,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11206
11312
  name: "Sulaka Provincial Office",
11207
11313
  locationType: "CRVS_OFFICE",
11208
11314
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11209
- validUntil: null,
11210
11315
  externalId: "Ht2Wp9KcX5Qv"
11211
11316
  },
11212
11317
  {
@@ -11214,7 +11319,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11214
11319
  name: "Ilanga District Office",
11215
11320
  locationType: "CRVS_OFFICE",
11216
11321
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11217
- validUntil: null,
11218
11322
  externalId: "Yp6Ds1WqN3Xz"
11219
11323
  },
11220
11324
  {
@@ -11222,7 +11326,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11222
11326
  name: "Chamakubi Health Post",
11223
11327
  locationType: "HEALTH_FACILITY",
11224
11328
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11225
- validUntil: null,
11226
11329
  externalId: "M1nFr8LbC2Qy"
11227
11330
  },
11228
11331
  {
@@ -11230,7 +11333,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11230
11333
  name: "Ibombo Rural Health Centre",
11231
11334
  locationType: "HEALTH_FACILITY",
11232
11335
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11233
- validUntil: null,
11234
11336
  externalId: "bT7pV6YrW0Xc"
11235
11337
  },
11236
11338
  {
@@ -11238,7 +11340,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11238
11340
  name: "Chikobo Rural Health Centre",
11239
11341
  locationType: "HEALTH_FACILITY",
11240
11342
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11241
- validUntil: null,
11242
11343
  externalId: "zE4qPn2SgJ5d"
11243
11344
  },
11244
11345
  {
@@ -11246,7 +11347,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11246
11347
  name: "Chilochabalenje Health Post",
11247
11348
  locationType: "HEALTH_FACILITY",
11248
11349
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11249
- validUntil: null,
11250
11350
  externalId: "H8vDs1MqR4Uf"
11251
11351
  },
11252
11352
  {
@@ -11254,7 +11354,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11254
11354
  name: "Chipeso Rural Health Centre",
11255
11355
  locationType: "HEALTH_FACILITY",
11256
11356
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11257
- validUntil: null,
11258
11357
  externalId: "Qw3uZ9KfX6Lm"
11259
11358
  },
11260
11359
  {
@@ -11262,7 +11361,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11262
11361
  name: "Chisamba Rural Health Centre",
11263
11362
  locationType: "HEALTH_FACILITY",
11264
11363
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11265
- validUntil: null,
11266
11364
  externalId: "Yr0pCg8LdM2s"
11267
11365
  },
11268
11366
  {
@@ -11270,7 +11368,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11270
11368
  name: "Chitanda Rural Health Centre",
11271
11369
  locationType: "HEALTH_FACILITY",
11272
11370
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11273
- validUntil: null,
11274
11371
  externalId: "tS9gJ4PwB1Qx"
11275
11372
  },
11276
11373
  {
@@ -11278,7 +11375,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11278
11375
  name: "Golden Valley Rural Health Centre",
11279
11376
  locationType: "HEALTH_FACILITY",
11280
11377
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11281
- validUntil: null,
11282
11378
  externalId: "Ld7Qm3XsA8Vr"
11283
11379
  },
11284
11380
  {
@@ -11286,7 +11382,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11286
11382
  name: "Ipongo Rural Health Centre",
11287
11383
  locationType: "HEALTH_FACILITY",
11288
11384
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11289
- validUntil: null,
11290
11385
  externalId: "kF2sW9DmH0Bt"
11291
11386
  },
11292
11387
  {
@@ -11294,7 +11389,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11294
11389
  name: "Itumbwe Health Post",
11295
11390
  locationType: "HEALTH_FACILITY",
11296
11391
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11297
- validUntil: null,
11298
11392
  externalId: "Ue5Xb3VaC7Pq"
11299
11393
  },
11300
11394
  {
@@ -11302,7 +11396,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11302
11396
  name: "Kabangalala Rural Health Centre",
11303
11397
  locationType: "HEALTH_FACILITY",
11304
11398
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11305
- validUntil: null,
11306
11399
  externalId: "Pz8Kc1TqH6Jn"
11307
11400
  },
11308
11401
  // Village offices
@@ -11311,13 +11404,70 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11311
11404
  name: "Klow Village Office",
11312
11405
  locationType: "CRVS_OFFICE",
11313
11406
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11314
- validUntil: null,
11315
11407
  externalId: "PmAyxAJkxiJ"
11316
11408
  }
11317
11409
  ];
11410
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11318
11411
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11319
11412
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11320
11413
  );
11321
11414
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11322
11415
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11323
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
+ });