@opencrvs/toolkit 2.1.0-rc.b061691 → 2.1.0-rc.b263ac1

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 (80) hide show
  1. package/README.md +1 -0
  2. package/dist/application-config/index.js +34 -11
  3. package/dist/cli.js +174 -58
  4. package/dist/commons/api/router.d.ts +3528 -3251
  5. package/dist/commons/application-config/index.d.ts +6 -6
  6. package/dist/commons/conditionals/conditionals.d.ts +259 -2102
  7. package/dist/commons/conditionals/validate.d.ts +9 -3
  8. package/dist/commons/events/ActionConfig.d.ts +105 -126
  9. package/dist/commons/events/ActionDocument.d.ts +110 -110
  10. package/dist/commons/events/ActionStatus.d.ts +3 -3
  11. package/dist/commons/events/ActionType.d.ts +62 -62
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +525 -513
  13. package/dist/commons/events/AuditLog.d.ts +189 -42
  14. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  15. package/dist/commons/events/Conditional.d.ts +3 -3
  16. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -608
  17. package/dist/commons/events/Draft.d.ts +37 -37
  18. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  19. package/dist/commons/events/EventConfig.d.ts +8 -5
  20. package/dist/commons/events/EventDocument.d.ts +46 -46
  21. package/dist/commons/events/EventIndex.d.ts +48 -52
  22. package/dist/commons/events/EventMetadata.d.ts +40 -41
  23. package/dist/commons/events/FieldConfig.d.ts +413 -396
  24. package/dist/commons/events/FieldType.d.ts +51 -51
  25. package/dist/commons/events/FieldTypeMapping.d.ts +90 -90
  26. package/dist/commons/events/FieldValue.d.ts +14 -14
  27. package/dist/commons/events/Flag.d.ts +30 -36
  28. package/dist/commons/events/PlainDate.d.ts +8 -0
  29. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  30. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  31. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  32. package/dist/commons/events/WorkqueueConfig.d.ts +817 -829
  33. package/dist/commons/events/deduplication.d.ts +1 -1
  34. package/dist/commons/events/event.d.ts +14 -2
  35. package/dist/commons/events/field.d.ts +78 -895
  36. package/dist/commons/events/index.d.ts +1 -0
  37. package/dist/commons/events/locationPayloads.d.ts +95 -0
  38. package/dist/commons/events/locations.d.ts +192 -12
  39. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  40. package/dist/commons/events/scopes.d.ts +4 -4
  41. package/dist/commons/events/state/index.d.ts +17 -17
  42. package/dist/commons/events/state/utils.d.ts +7 -7
  43. package/dist/commons/events/test.utils.d.ts +40 -40
  44. package/dist/commons/events/utils.d.ts +114 -114
  45. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  46. package/dist/conditionals/index.js +6 -4
  47. package/dist/environment/derived-variables.d.ts +119 -119
  48. package/dist/environment/derived-variables.d.ts.map +1 -1
  49. package/dist/environment/index.d.ts +1 -0
  50. package/dist/environment/index.d.ts.map +1 -1
  51. package/dist/environment/index.js +10 -0
  52. package/dist/environment/logger.d.ts +12 -3
  53. package/dist/environment/logger.d.ts.map +1 -1
  54. package/dist/environment/paths.d.ts +7 -0
  55. package/dist/environment/paths.d.ts.map +1 -0
  56. package/dist/environment/paths.js +72 -0
  57. package/dist/environment/questions.d.ts +75 -74
  58. package/dist/environment/questions.d.ts.map +1 -1
  59. package/dist/environment/setup-environment.js +10 -15
  60. package/dist/environment/templates.d.ts.map +1 -1
  61. package/dist/environment/templates.js +2 -1
  62. package/dist/environment/update-workflows.d.ts.map +1 -1
  63. package/dist/environment/update-workflows.js +17 -5
  64. package/dist/environment/upgrade.d.ts +2 -0
  65. package/dist/environment/upgrade.d.ts.map +1 -0
  66. package/dist/environment/upgrade.js +82 -0
  67. package/dist/environment/users.js +11 -13
  68. package/dist/environment/utils.d.ts +1 -1
  69. package/dist/events/deduplication.d.ts +1 -1
  70. package/dist/events/index.js +568 -265
  71. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  72. package/dist/notification/index.js +578 -316
  73. package/dist/scopes/index.d.ts +350 -332
  74. package/dist/scopes/index.js +6 -4
  75. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  76. package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
  77. package/opencrvs-toolkit-2.1.0-rc.b263ac1.tgz +0 -0
  78. package/package.json +6 -6
  79. package/tsconfig.tsbuildinfo +1 -1
  80. package/opencrvs-toolkit-2.1.0-rc.b061691.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,
@@ -157,11 +161,14 @@ __export(events_exports, {
157
161
  HttpFieldValue: () => HttpFieldValue,
158
162
  IdReaderFieldValue: () => IdReaderFieldValue,
159
163
  ImageMimeType: () => ImageMimeType,
164
+ InfoBox: () => InfoBox,
160
165
  InherentFlags: () => InherentFlags,
161
166
  LanguageConfig: () => LanguageConfig,
162
167
  LegalStatuses: () => LegalStatuses,
163
168
  Location: () => Location,
169
+ LocationStatus: () => LocationStatus,
164
170
  LocationTypeV1: () => LocationTypeV1,
171
+ LocationVersion: () => LocationVersion,
165
172
  METADATA_FIELD_PREFIX: () => METADATA_FIELD_PREFIX,
166
173
  MarkAsDuplicateActionInput: () => MarkAsDuplicateActionInput,
167
174
  MarkNotDuplicateActionInput: () => MarkNotDuplicateActionInput,
@@ -201,6 +208,8 @@ __export(events_exports, {
201
208
  SelectDateRangeOption: () => SelectDateRangeOption,
202
209
  SelectDateRangeValue: () => SelectDateRangeValue,
203
210
  SelectOption: () => SelectOption,
211
+ SetAdministrativeAreaPayload: () => SetAdministrativeAreaPayload,
212
+ SetLocationPayload: () => SetLocationPayload,
204
213
  ShowConditional: () => ShowConditional,
205
214
  SignatureFieldValue: () => SignatureFieldValue,
206
215
  StaticDataEntry: () => StaticDataEntry,
@@ -216,15 +225,21 @@ __export(events_exports, {
216
225
  UUID: () => UUID,
217
226
  UnarchiveActionInput: () => UnarchiveActionInput,
218
227
  UnassignActionInput: () => UnassignActionInput,
228
+ UpdateAdministrativeAreaPayload: () => UpdateAdministrativeAreaPayload,
229
+ UpdateLocationPayload: () => UpdateLocationPayload,
219
230
  UserAuditRecordInput: () => UserAuditRecordInput,
220
231
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS,
221
232
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP,
233
+ V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP: () => V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP,
234
+ V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP,
222
235
  V2_DEFAULT_MOCK_LOCATIONS: () => V2_DEFAULT_MOCK_LOCATIONS,
223
236
  V2_DEFAULT_MOCK_LOCATIONS_MAP: () => V2_DEFAULT_MOCK_LOCATIONS_MAP,
224
237
  ValidationConfig: () => ValidationConfig,
225
238
  VerificationActionConfig: () => VerificationActionConfig,
226
239
  VerificationPageConfig: () => VerificationPageConfig,
227
240
  VerificationStatusValue: () => VerificationStatusValue,
241
+ WithdrawAdministrativeAreaVersionPayload: () => WithdrawAdministrativeAreaVersionPayload,
242
+ WithdrawLocationVersionPayload: () => WithdrawLocationVersionPayload,
228
243
  Within: () => Within,
229
244
  WorkqueueActionType: () => WorkqueueActionType,
230
245
  WorkqueueColumn: () => WorkqueueColumn,
@@ -343,6 +358,7 @@ __export(events_exports, {
343
358
  getStatusFromActions: () => getStatusFromActions,
344
359
  getValidatorsForField: () => getValidatorsForField,
345
360
  getVisibleVerificationPageIds: () => getVisibleVerificationPageIds,
361
+ hasActiveExternalIdOnOrAfter: () => hasActiveExternalIdOnOrAfter,
346
362
  hasAnyOfScopes: () => hasAnyOfScopes,
347
363
  isActionAvailable: () => isActionAvailable,
348
364
  isActionConfigType: () => isActionConfigType,
@@ -372,6 +388,7 @@ __export(events_exports, {
372
388
  isFieldEnabled: () => isFieldEnabled,
373
389
  isFieldGroupFieldType: () => isFieldGroupFieldType,
374
390
  isFieldReference: () => isFieldReference,
391
+ isFieldSecured: () => isFieldSecured,
375
392
  isFieldValue: () => isFieldValue,
376
393
  isFieldValueWithoutTemplates: () => isFieldValueWithoutTemplates,
377
394
  isFieldVisible: () => isFieldVisible,
@@ -432,13 +449,18 @@ __export(events_exports, {
432
449
  precompileActionSchemas: () => precompileActionSchemas,
433
450
  resolveDateOfEvent: () => resolveDateOfEvent,
434
451
  resolveEventCustomFlags: () => resolveEventCustomFlags,
452
+ resolvePath: () => resolvePath,
435
453
  resolvePlaceOfEvent: () => resolvePlaceOfEvent,
454
+ resolveVersion: () => resolveVersion,
436
455
  runClientFunction: () => runClientFunction,
437
456
  runFieldValidations: () => runFieldValidations,
438
457
  runStructuralValidations: () => runStructuralValidations,
439
458
  safeUnion: () => safeUnion,
440
459
  status: () => status,
441
460
  timePeriodToDateRange: () => timePeriodToDateRange,
461
+ toClientAdministrativeArea: () => toClientAdministrativeArea,
462
+ toClientLocation: () => toClientLocation,
463
+ toPlainDate: () => toPlainDate,
442
464
  todayISO: () => todayISO,
443
465
  user: () => user,
444
466
  userCanAccessEventWithScopes: () => userCanAccessEventWithScopes,
@@ -670,8 +692,7 @@ var InherentFlags = {
670
692
  *
671
693
  * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
672
694
  */
673
- EDIT_IN_PROGRESS: "edit-in-progress",
674
- SEALED: "sealed"
695
+ EDIT_IN_PROGRESS: "edit-in-progress"
675
696
  };
676
697
  var actionFlagPattern;
677
698
  function getActionFlagPattern() {
@@ -752,6 +773,7 @@ var PlainScopeType = z6.enum([
752
773
  "integration.create",
753
774
  "record.import",
754
775
  "config.update-all",
776
+ "location.edit",
755
777
  "attachment.upload",
756
778
  "profile.electronic-signature",
757
779
  "user.read-only-my-audit",
@@ -773,7 +795,8 @@ var userRole = z6.preprocess(
773
795
  ).describe("User role, e.g. admin, field agent");
774
796
  var scopeOptionsPlaceEvent = z6.object({
775
797
  event: scopeByEvent,
776
- placeOfEvent: JurisdictionFilter.optional()
798
+ placeOfEvent: JurisdictionFilter.optional(),
799
+ createdBy: UserFilter.optional()
777
800
  }).describe("Options applicable to all record scopes.");
778
801
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
779
802
  notifiedIn: JurisdictionFilter.optional(),
@@ -815,7 +838,8 @@ var AllScopeOptions = z6.object({
815
838
  var ScopeOptionKey = AllScopeOptions.keyof();
816
839
  var ResolvedScopeOptionsPlaceEvent = z6.object({
817
840
  event: scopeByEvent,
818
- placeOfEvent: UUID.nullish()
841
+ placeOfEvent: UUID.nullish(),
842
+ createdBy: z6.string().optional()
819
843
  }).describe(
820
844
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
821
845
  );
@@ -1122,6 +1146,82 @@ var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
1122
1146
  requestData: z8.object({ id: z8.string() }),
1123
1147
  responseSummary: z8.object({ clientId: z8.string() })
1124
1148
  });
1149
+ var createdVersionFields = {
1150
+ id: z8.string(),
1151
+ versionId: z8.string(),
1152
+ name: z8.string(),
1153
+ externalId: z8.string().nullish(),
1154
+ effectiveFrom: z8.string(),
1155
+ status: z8.string()
1156
+ };
1157
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
1158
+ operation: z8.literal("locations.create"),
1159
+ requestData: z8.object({
1160
+ ...createdVersionFields,
1161
+ administrativeAreaId: z8.string().nullish(),
1162
+ locationType: z8.string().nullish()
1163
+ })
1164
+ });
1165
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
1166
+ operation: z8.literal("administrativeAreas.create"),
1167
+ requestData: z8.object({
1168
+ ...createdVersionFields,
1169
+ parentId: z8.string().nullish()
1170
+ })
1171
+ });
1172
+ var ChangedStringField = z8.object({ from: z8.string(), to: z8.string() });
1173
+ var ChangedNullableStringField = z8.object({
1174
+ from: z8.string().nullable(),
1175
+ to: z8.string().nullable()
1176
+ });
1177
+ var updatedVersionRequestData = z8.object({
1178
+ id: z8.string(),
1179
+ versionId: z8.string(),
1180
+ name: z8.string(),
1181
+ externalId: z8.string().nullish(),
1182
+ status: z8.string(),
1183
+ effectiveFrom: z8.string(),
1184
+ lastVersionId: z8.string()
1185
+ });
1186
+ var updatedVersionResponseSummary = z8.object({
1187
+ previousVersionId: z8.string(),
1188
+ versionId: z8.string(),
1189
+ changed: z8.object({
1190
+ name: ChangedStringField.optional(),
1191
+ externalId: ChangedNullableStringField.optional(),
1192
+ status: ChangedStringField.optional()
1193
+ })
1194
+ });
1195
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
1196
+ operation: z8.literal("locations.update"),
1197
+ requestData: updatedVersionRequestData,
1198
+ responseSummary: updatedVersionResponseSummary
1199
+ });
1200
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
1201
+ operation: z8.literal("administrativeAreas.update"),
1202
+ requestData: updatedVersionRequestData,
1203
+ responseSummary: updatedVersionResponseSummary
1204
+ });
1205
+ var withdrawVersionRequestData = z8.object({
1206
+ id: z8.string(),
1207
+ versionId: z8.string()
1208
+ });
1209
+ var withdrawVersionResponseSummary = z8.object({
1210
+ effectiveFrom: z8.string(),
1211
+ name: z8.string(),
1212
+ externalId: z8.string().nullish(),
1213
+ status: z8.string()
1214
+ });
1215
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
1216
+ operation: z8.literal("locations.withdrawVersion"),
1217
+ requestData: withdrawVersionRequestData,
1218
+ responseSummary: withdrawVersionResponseSummary
1219
+ });
1220
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
1221
+ operation: z8.literal("administrativeAreas.withdrawVersion"),
1222
+ requestData: withdrawVersionRequestData,
1223
+ responseSummary: withdrawVersionResponseSummary
1224
+ });
1125
1225
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
1126
1226
  operation: z8.literal("attachments.upload"),
1127
1227
  requestData: z8.object({
@@ -1197,6 +1297,12 @@ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
1197
1297
  IntegrationActivateEntrySchema,
1198
1298
  IntegrationDeleteEntrySchema,
1199
1299
  IntegrationRefreshSecretEntrySchema,
1300
+ LocationCreateEntrySchema,
1301
+ LocationUpdateEntrySchema,
1302
+ AdministrativeAreaUpdateEntrySchema,
1303
+ LocationWithdrawEntrySchema,
1304
+ AdministrativeAreaWithdrawEntrySchema,
1305
+ AdministrativeAreaCreateEntrySchema,
1200
1306
  AttachmentUploadEntrySchema,
1201
1307
  UserCreateEntrySchema,
1202
1308
  UserReasonEntrySchema,
@@ -1432,6 +1538,9 @@ var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
1432
1538
  // ../commons/src/events/PlainDate.ts
1433
1539
  var import_zod = require("zod");
1434
1540
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1541
+ function toPlainDate(dateTime) {
1542
+ return dateTime.split("T")[0];
1543
+ }
1435
1544
  function plainDateToLocalDate(date) {
1436
1545
  const [year, month, day] = date.split("-").map(Number);
1437
1546
  return new Date(year, month - 1, day);
@@ -2294,8 +2403,8 @@ var BaseField = import_v43.default.object({
2294
2403
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
2295
2404
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
2296
2405
  ),
2297
- secured: import_v43.default.boolean().default(false).optional().describe(
2298
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
2406
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
2407
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
2299
2408
  ),
2300
2409
  placeholder: TranslationConfig.optional(),
2301
2410
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2693,7 +2802,13 @@ var AdministrativeAreaField = BaseField.extend({
2693
2802
  configuration: import_v43.default.object({
2694
2803
  partOf: FieldReference.optional().describe("Parent location"),
2695
2804
  type: AdministrativeAreas,
2696
- allowedLocations: AllowedLocations
2805
+ allowedLocations: AllowedLocations,
2806
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2807
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
2808
+ ),
2809
+ activeOnly: import_v43.default.boolean().optional().describe(
2810
+ "Advanced search: offer only currently-active locations; inactivated ones are excluded."
2811
+ )
2697
2812
  }).describe("Administrative area options")
2698
2813
  }).meta({
2699
2814
  description: "Administrative area input field",
@@ -2704,7 +2819,10 @@ var LocationInput = BaseField.extend({
2704
2819
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2705
2820
  configuration: import_v43.default.object({
2706
2821
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2707
- allowedLocations: AllowedLocations
2822
+ allowedLocations: AllowedLocations,
2823
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2824
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
2825
+ )
2708
2826
  }).optional()
2709
2827
  }).meta({
2710
2828
  description: "A field for selecting a location",
@@ -2730,12 +2848,18 @@ var FileUploadWithOptions = BaseField.extend({
2730
2848
  var Facility = BaseField.extend({
2731
2849
  type: import_v43.default.literal(FieldType.FACILITY),
2732
2850
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2733
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2851
+ configuration: import_v43.default.object({
2852
+ allowedLocations: AllowedLocations,
2853
+ listHistoricalNames: import_v43.default.boolean().optional()
2854
+ }).optional()
2734
2855
  }).describe("Input field for a facility");
2735
2856
  var Office = BaseField.extend({
2736
2857
  type: import_v43.default.literal(FieldType.OFFICE),
2737
2858
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2738
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2859
+ configuration: import_v43.default.object({
2860
+ allowedLocations: AllowedLocations,
2861
+ listHistoricalNames: import_v43.default.boolean().optional()
2862
+ }).optional()
2739
2863
  }).describe("Input field for an office");
2740
2864
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2741
2865
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2768,7 +2892,13 @@ var Address = BaseField.extend({
2768
2892
  parent: FieldReference.optional()
2769
2893
  })
2770
2894
  ).optional(),
2771
- allowedLocations: AllowedLocations
2895
+ allowedLocations: AllowedLocations,
2896
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2897
+ "Advanced search: list every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2898
+ ),
2899
+ activeOnly: import_v43.default.boolean().optional().describe(
2900
+ "Advanced search: offer only currently-active admin areas; inactivated ones are excluded. Propagated to the embedded admin-area selectors."
2901
+ )
2772
2902
  }).optional(),
2773
2903
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2774
2904
  }).meta({
@@ -3540,45 +3670,181 @@ var LanguageConfig = z26.object({
3540
3670
  });
3541
3671
 
3542
3672
  // ../commons/src/events/EventConfig.ts
3543
- var z33 = __toESM(require("zod/v4"));
3673
+ var z34 = __toESM(require("zod/v4"));
3544
3674
 
3545
3675
  // ../commons/src/events/SummaryConfig.ts
3676
+ var z28 = __toESM(require("zod/v4"));
3677
+
3678
+ // ../commons/src/icons.ts
3546
3679
  var z27 = __toESM(require("zod/v4"));
3547
- var BaseField2 = z27.object({
3680
+ var AvailableIcons = z27.enum([
3681
+ "Archived",
3682
+ "Assigned",
3683
+ "Briefcase",
3684
+ "Certified",
3685
+ "Close",
3686
+ "Collapse",
3687
+ "Draft",
3688
+ "DuplicateYellow",
3689
+ "Expand",
3690
+ "ExternalValidate",
3691
+ "FilledCheck",
3692
+ "InReview",
3693
+ "Offline",
3694
+ "Registered",
3695
+ "RequiresUpdates",
3696
+ "Sent",
3697
+ "Validated",
3698
+ "WaitingApproval",
3699
+ "ChartActivity",
3700
+ "Activity",
3701
+ "Archive",
3702
+ "ArchiveTray",
3703
+ "ArrowLeft",
3704
+ "ArrowRight",
3705
+ "Buildings",
3706
+ "Circle",
3707
+ "CaretDown",
3708
+ "CaretLeft",
3709
+ "CaretRight",
3710
+ "ChartBar",
3711
+ "ChartLine",
3712
+ "ChatCircle",
3713
+ "CheckSquare",
3714
+ "Compass",
3715
+ "Check",
3716
+ "Copy",
3717
+ "Database",
3718
+ "DotsThreeVertical",
3719
+ "ArrowCounterClockwise",
3720
+ "MagnifyingGlassMinus",
3721
+ "MagnifyingGlassPlus",
3722
+ "Export",
3723
+ "Eye",
3724
+ "EyeSlash",
3725
+ "Envelope",
3726
+ "File",
3727
+ "FileLock",
3728
+ "FileSearch",
3729
+ "FileMinus",
3730
+ "FilePlus",
3731
+ "FileText",
3732
+ "FileX",
3733
+ "Handshake",
3734
+ "Gear",
3735
+ "GitBranch",
3736
+ "IdentificationCard",
3737
+ "List",
3738
+ "ListBullets",
3739
+ "Lock",
3740
+ "MagnifyingGlass",
3741
+ "MapPin",
3742
+ "Medal",
3743
+ "NotePencil",
3744
+ "Paperclip",
3745
+ "PaperPlaneTilt",
3746
+ "Pen",
3747
+ "PenNib",
3748
+ "Pencil",
3749
+ "PencilSimpleLine",
3750
+ "Phone",
3751
+ "Plus",
3752
+ "Printer",
3753
+ "SignOut",
3754
+ "Stamp",
3755
+ "Star",
3756
+ "Target",
3757
+ "TextT",
3758
+ "Trash",
3759
+ "UploadSimple",
3760
+ "User",
3761
+ "UserPlus",
3762
+ "Users",
3763
+ "WarningCircle",
3764
+ "X",
3765
+ "ChatText",
3766
+ "CircleWavyCheck",
3767
+ "CircleWavyQuestion",
3768
+ "ArchiveBox",
3769
+ "ArrowCircleDown",
3770
+ "FileArrowUp",
3771
+ "FileDotted",
3772
+ "Files",
3773
+ "PencilLine",
3774
+ "PencilCircle",
3775
+ "UserCircle",
3776
+ "Clock",
3777
+ "QrCode",
3778
+ "Webcam",
3779
+ "Sun",
3780
+ "DeviceTabletCamera",
3781
+ "Globe",
3782
+ "Fingerprint",
3783
+ "PushPin",
3784
+ "Timer"
3785
+ ]);
3786
+
3787
+ // ../commons/src/events/SummaryConfig.ts
3788
+ var InfoBox = z28.object({
3789
+ type: z28.enum(["info", "positive", "warning", "negative"]).describe(
3790
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3791
+ ),
3792
+ background: z28.enum(["tinted", "white"]).default("tinted").optional().describe(
3793
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3794
+ ),
3795
+ icon: AvailableIcons.optional().describe(
3796
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3797
+ ),
3798
+ heading: TranslationConfig.describe(
3799
+ "Primary message. Short, sentence-case."
3800
+ ),
3801
+ description: TranslationConfig.optional().describe(
3802
+ "Secondary copy displayed below the heading, typically a suggested next step."
3803
+ ),
3804
+ conditionals: z28.array(ShowConditional).default([]).optional().describe(
3805
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3806
+ )
3807
+ }).describe(
3808
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3809
+ );
3810
+ var BaseField2 = z28.object({
3548
3811
  emptyValueMessage: TranslationConfig.optional().describe(
3549
3812
  "Default message displayed when the field value is empty."
3550
3813
  ),
3551
- conditionals: z27.array(ShowConditional).default([]).optional()
3814
+ conditionals: z28.array(ShowConditional).default([]).optional()
3552
3815
  });
3553
3816
  var ReferenceField = BaseField2.extend({
3554
- fieldId: z27.string(),
3817
+ fieldId: z28.string(),
3555
3818
  label: TranslationConfig.optional().describe(
3556
3819
  "Overrides the default label from the referenced field when provided."
3557
3820
  )
3558
3821
  }).describe("Field referencing existing event data by field ID.");
3559
3822
  var Field = BaseField2.extend({
3560
- id: z27.string().describe("Identifier of the summary field."),
3823
+ id: z28.string().describe("Identifier of the summary field."),
3561
3824
  value: TranslationConfig.describe(
3562
3825
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3563
3826
  ),
3564
3827
  label: TranslationConfig
3565
3828
  }).describe("Custom field defined for the summary view.");
3566
- var SummaryConfig = z27.object({
3567
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3829
+ var SummaryConfig = z28.object({
3830
+ banners: z28.array(InfoBox).default([]).optional().describe(
3831
+ "Info boxes displayed above the summary fields in the event overview."
3832
+ ),
3833
+ fields: z28.array(z28.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3568
3834
  }).meta({
3569
3835
  id: "SummaryConfig",
3570
3836
  description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3571
3837
  });
3572
3838
 
3573
3839
  // ../commons/src/events/AdvancedSearchConfig.ts
3574
- var z28 = __toESM(require("zod/v4"));
3575
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3576
- var BaseField3 = z28.object({
3577
- config: z28.object({
3840
+ var z29 = __toESM(require("zod/v4"));
3841
+ var MatchType = z29.enum(["fuzzy", "exact", "range", "within"]);
3842
+ var BaseField3 = z29.object({
3843
+ config: z29.object({
3578
3844
  type: MatchType.describe(
3579
3845
  "Determines the search type of field. How to match value."
3580
3846
  ),
3581
- searchFields: z28.array(z28.string()).optional().describe(
3847
+ searchFields: z29.array(z29.string()).optional().describe(
3582
3848
  `
3583
3849
  Defines multiple form fields that should be searched when this field has a value.
3584
3850
  All specified fields will be combined using OR logic.
@@ -3588,7 +3854,7 @@ var BaseField3 = z28.object({
3588
3854
  `
3589
3855
  )
3590
3856
  }),
3591
- type: z28.nativeEnum(FieldType).optional().describe(
3857
+ type: z29.nativeEnum(FieldType).optional().describe(
3592
3858
  `
3593
3859
  Explicitly specify the field type for searchFields.
3594
3860
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3602,7 +3868,7 @@ var BaseField3 = z28.object({
3602
3868
  This is required when searchFields is defined.
3603
3869
  `
3604
3870
  ),
3605
- options: z28.array(SelectOption).optional(),
3871
+ options: z29.array(SelectOption).optional(),
3606
3872
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3607
3873
  `
3608
3874
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3623,7 +3889,7 @@ var BaseField3 = z28.object({
3623
3889
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3624
3890
  `
3625
3891
  ),
3626
- conditionals: z28.array(FieldConditional).optional().describe(
3892
+ conditionals: z29.array(FieldConditional).optional().describe(
3627
3893
  `
3628
3894
  In advanced search, we sometimes need to override the default field visibility conditionals.
3629
3895
 
@@ -3637,23 +3903,23 @@ var BaseField3 = z28.object({
3637
3903
  are always rendered in the advanced search form.
3638
3904
  `
3639
3905
  ),
3640
- validations: z28.array(ValidationConfig).optional().describe(
3906
+ validations: z29.array(ValidationConfig).optional().describe(
3641
3907
  `Option for overriding the field validations specifically for advanced search form.`
3642
3908
  ),
3643
3909
  allowedLocations: JurisdictionReference.optional().describe(
3644
3910
  `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3645
3911
  )
3646
3912
  });
3647
- var SearchQueryParams = z28.object({
3648
- eventType: z28.string().optional().describe(
3913
+ var SearchQueryParams = z29.object({
3914
+ eventType: z29.string().optional().describe(
3649
3915
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3650
3916
  )
3651
3917
  }).catchall(FieldValue);
3652
3918
  var FieldConfigSchema = BaseField3.extend({
3653
- fieldId: z28.string(),
3654
- fieldType: z28.literal("field")
3919
+ fieldId: z29.string(),
3920
+ fieldType: z29.literal("field")
3655
3921
  });
3656
- var EventFieldIdInput = z28.enum([
3922
+ var EventFieldIdInput = z29.enum([
3657
3923
  "trackingId",
3658
3924
  "status",
3659
3925
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3662,7 +3928,7 @@ var EventFieldIdInput = z28.enum([
3662
3928
  "updatedAt"
3663
3929
  ]);
3664
3930
  var METADATA_FIELD_PREFIX = "event.";
3665
- var EventFieldId = z28.enum([
3931
+ var EventFieldId = z29.enum([
3666
3932
  `${METADATA_FIELD_PREFIX}trackingId`,
3667
3933
  `${METADATA_FIELD_PREFIX}status`,
3668
3934
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3672,29 +3938,29 @@ var EventFieldId = z28.enum([
3672
3938
  ]);
3673
3939
  var EventFieldConfigSchema = BaseField3.extend({
3674
3940
  fieldId: EventFieldId,
3675
- fieldType: z28.literal("event")
3941
+ fieldType: z29.literal("event")
3676
3942
  });
3677
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3943
+ var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3678
3944
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3679
3945
  if (!data.label) {
3680
3946
  ctx.addIssue({
3681
- code: z28.ZodIssueCode.custom,
3947
+ code: z29.ZodIssueCode.custom,
3682
3948
  message: "label is required when config.searchFields is defined.",
3683
3949
  path: ["label"]
3684
3950
  });
3685
3951
  }
3686
3952
  if (!data.type) {
3687
3953
  ctx.addIssue({
3688
- code: z28.ZodIssueCode.custom,
3954
+ code: z29.ZodIssueCode.custom,
3689
3955
  message: "type is required when config.searchFields is defined.",
3690
3956
  path: ["type"]
3691
3957
  });
3692
3958
  }
3693
3959
  }
3694
3960
  });
3695
- var AdvancedSearchConfig = z28.object({
3961
+ var AdvancedSearchConfig = z29.object({
3696
3962
  title: TranslationConfig.describe("Advanced search tab title"),
3697
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3963
+ fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3698
3964
  }).meta({
3699
3965
  id: "AdvancedSearchConfig",
3700
3966
  description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
@@ -3706,19 +3972,19 @@ var import_lodash4 = require("lodash");
3706
3972
  // ../commons/src/conditionals/validate.ts
3707
3973
  var import__ = __toESM(require("ajv/dist/2019"));
3708
3974
  var import_ajv_formats = __toESM(require("ajv-formats"));
3709
- var z32 = __toESM(require("zod/v4"));
3975
+ var z33 = __toESM(require("zod/v4"));
3710
3976
  var import_date_fns2 = require("date-fns");
3711
3977
 
3712
3978
  // ../commons/src/events/FieldTypeMapping.ts
3713
- var z30 = __toESM(require("zod/v4"));
3979
+ var z31 = __toESM(require("zod/v4"));
3714
3980
 
3715
3981
  // ../commons/src/events/DynamicFieldValue.ts
3716
- var z29 = __toESM(require("zod/v4"));
3982
+ var z30 = __toESM(require("zod/v4"));
3717
3983
  function getDynamicNameValue(field3) {
3718
3984
  const nameConfiguration = field3.configuration?.name;
3719
3985
  const firstnameRequired = nameConfiguration?.firstname?.required ?? field3.required;
3720
3986
  const surnameRequired = nameConfiguration?.surname?.required ?? field3.required;
3721
- return z29.object({
3987
+ return z30.object({
3722
3988
  firstname: firstnameRequired ? NonEmptyTextValue : TextValue,
3723
3989
  surname: surnameRequired ? NonEmptyTextValue : TextValue,
3724
3990
  middlename: nameConfiguration?.middlename?.required ? NonEmptyTextValue : TextValue.optional()
@@ -3749,7 +4015,7 @@ function mapFieldTypeToZod(field3, actionType) {
3749
4015
  let schema;
3750
4016
  switch (field3.type) {
3751
4017
  case FieldType.FIELD_GROUP: {
3752
- schema = z30.object(
4018
+ schema = z31.object(
3753
4019
  field3.fields.reduce((acc, subfield) => {
3754
4020
  acc[subfield.id] = mapFieldTypeToZod(subfield, actionType);
3755
4021
  return acc;
@@ -4074,7 +4340,7 @@ var isNonInteractiveFieldType = (field3) => {
4074
4340
  var import_lodash3 = require("lodash");
4075
4341
 
4076
4342
  // ../commons/src/utils.ts
4077
- var z31 = __toESM(require("zod/v4"));
4343
+ var z32 = __toESM(require("zod/v4"));
4078
4344
  var _ = __toESM(require("lodash"));
4079
4345
  function getOrThrow(x, message) {
4080
4346
  if (x === void 0 || x === null) {
@@ -4085,11 +4351,11 @@ function getOrThrow(x, message) {
4085
4351
  function joinValues(values, separator = " ") {
4086
4352
  return values.filter((value) => !!value).join(separator).trim();
4087
4353
  }
4088
- var FullNameV1 = z31.array(
4089
- z31.object({
4090
- use: z31.string(),
4091
- family: z31.string(),
4092
- given: z31.array(z31.string())
4354
+ var FullNameV1 = z32.array(
4355
+ z32.object({
4356
+ use: z32.string(),
4357
+ family: z32.string(),
4358
+ given: z32.array(z32.string())
4093
4359
  })
4094
4360
  );
4095
4361
  function omitKeyDeep(obj, keyToRemove) {
@@ -5313,9 +5579,9 @@ var ajv = new import__.default({
5313
5579
  strict: false
5314
5580
  // Allow minContains and other newer features
5315
5581
  });
5316
- var DataContext = z32.object({
5317
- rootData: z32.object({
5318
- $leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
5582
+ var DataContext = z33.object({
5583
+ rootData: z33.object({
5584
+ $leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
5319
5585
  })
5320
5586
  });
5321
5587
  function resolveDataPath(rootData, dataPath, instancePath) {
@@ -5352,8 +5618,22 @@ function compileClientFunction(code) {
5352
5618
  return fn;
5353
5619
  }
5354
5620
  (0, import_ajv_formats.default)(ajv);
5621
+ var inMemoryEventStateCache = /* @__PURE__ */ new WeakMap();
5622
+ function getInMemoryEventState(event2, config) {
5623
+ let stateByConfig = inMemoryEventStateCache.get(event2);
5624
+ if (!stateByConfig) {
5625
+ stateByConfig = /* @__PURE__ */ new WeakMap();
5626
+ inMemoryEventStateCache.set(event2, stateByConfig);
5627
+ }
5628
+ let state = stateByConfig.get(config);
5629
+ if (!state) {
5630
+ state = getCurrentEventState(event2, config);
5631
+ stateByConfig.set(config, state);
5632
+ }
5633
+ return state;
5634
+ }
5355
5635
  function buildClientFunctionContext(input) {
5356
- const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
5636
+ const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getInMemoryEventState(
5357
5637
  input.validatorContext?.event,
5358
5638
  input.validatorContext?.eventConfig
5359
5639
  )?.flags : [];
@@ -5531,6 +5811,20 @@ function areConditionsMet(conditions, values, context, event2) {
5531
5811
  (condition) => validate(condition.conditional, clientFunctionContext)
5532
5812
  );
5533
5813
  }
5814
+ function isFieldSecured(field3, event2, context = {}) {
5815
+ if (typeof field3.secured !== "object" || field3.secured === null) {
5816
+ return Boolean(field3.secured);
5817
+ }
5818
+ const clientFunctionContext = {
5819
+ ...buildClientFunctionContext({
5820
+ form: mergeWithBaseFormState(event2.declaration, context),
5821
+ validatorContext: context
5822
+ }),
5823
+ $flags: event2.flags,
5824
+ $status: event2.status
5825
+ };
5826
+ return validate(field3.secured, clientFunctionContext);
5827
+ }
5534
5828
  function isFieldConditionMet(field3, form, conditionalType, context) {
5535
5829
  const hasRule = (field3.conditionals ?? []).some(
5536
5830
  (conditional) => conditional.type === conditionalType
@@ -6400,11 +6694,11 @@ function validateActionOrder(event2, ctx) {
6400
6694
  }
6401
6695
 
6402
6696
  // ../commons/src/events/EventConfig.ts
6403
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
6697
+ var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
6404
6698
  "Reference to a field defined in the event metadata, using the field id."
6405
6699
  );
6406
- var _EventConfigBase = z33.object({
6407
- id: z33.string().describe(
6700
+ var _EventConfigBase = z34.object({
6701
+ id: z34.string().describe(
6408
6702
  'Machine-readable identifier of the event (e.g. "birth", "death").'
6409
6703
  ),
6410
6704
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -6423,23 +6717,26 @@ var _EventConfigBase = z33.object({
6423
6717
  "Summary information displayed in the event overview."
6424
6718
  ),
6425
6719
  label: TranslationConfig.describe("Human-readable label for the event type."),
6426
- actions: z33.array(ActionConfig).describe(
6720
+ actions: z34.array(ActionConfig).describe(
6427
6721
  "Configuration of core and custom actions associated with the event."
6428
6722
  ),
6429
- actionOrder: z33.array(z33.string()).optional().describe(
6723
+ actionOrder: z34.array(z34.string()).optional().describe(
6430
6724
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
6431
6725
  ),
6432
6726
  declaration: DeclarationFormConfig.describe(
6433
6727
  "Configuration of the form used to gather event data."
6434
6728
  ),
6435
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
6729
+ advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
6436
6730
  "Configuration of fields available in the advanced search feature."
6437
6731
  ),
6438
- flags: z33.array(FlagConfig).optional().default([]).describe(
6732
+ flags: z34.array(FlagConfig).optional().default([]).describe(
6439
6733
  "Configuration of custom flags associated with the actions of this event type."
6440
6734
  ),
6441
- analytics: z33.boolean().optional().default(true).describe(
6735
+ analytics: z34.boolean().optional().default(true).describe(
6442
6736
  "Indicates whether the records of this event type are included in analytics"
6737
+ ),
6738
+ icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
6739
+ 'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
6443
6740
  )
6444
6741
  });
6445
6742
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -6657,21 +6954,31 @@ var event = Object.assign(eventFn, {
6657
6954
  return {
6658
6955
  $event: field3
6659
6956
  };
6660
- }
6957
+ },
6958
+ /**
6959
+ * Checks if the event currently has the given status.
6960
+ * @param eventStatus - The status to check for.
6961
+ */
6962
+ hasStatus: (eventStatus) => status(eventStatus),
6963
+ /**
6964
+ * Checks if the event currently carries the given flag.
6965
+ * @param flagValue - The flag to check for.
6966
+ */
6967
+ hasFlag: (flagValue) => flag(flagValue)
6661
6968
  });
6662
6969
 
6663
6970
  // ../commons/src/events/WorkqueueColumnConfig.ts
6664
- var z34 = __toESM(require("zod/v4"));
6971
+ var z35 = __toESM(require("zod/v4"));
6665
6972
  var WorkqueueColumnKeysArray = [
6666
6973
  ...EventMetadataKeysArray,
6667
6974
  "title",
6668
6975
  "outbox"
6669
6976
  ];
6670
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
6671
- var WorkqueueColumnValue = z34.object({
6977
+ var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
6978
+ var WorkqueueColumnValue = z35.object({
6672
6979
  $event: WorkqueueColumnKeys
6673
6980
  });
6674
- var WorkqueueColumn = z34.object({
6981
+ var WorkqueueColumn = z35.object({
6675
6982
  label: TranslationConfig,
6676
6983
  value: WorkqueueColumnValue
6677
6984
  }).meta({
@@ -6685,164 +6992,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
6685
6992
  }
6686
6993
 
6687
6994
  // ../commons/src/events/CountryConfigQueryInput.ts
6688
- var z35 = __toESM(require("zod/v4"));
6689
- var SerializableExact = z35.object({
6690
- type: z35.literal("exact"),
6691
- term: z35.union([z35.string(), SerializedUserField])
6692
- });
6693
- var SerializableWithin = z35.object({
6694
- type: z35.literal("within"),
6695
- location: z35.union([z35.string(), SerializedUserField])
6696
- });
6697
- var SerializedQueryExpression = z35.object({
6698
- eventType: z35.string(),
6699
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
6700
- createdAt: z35.optional(DateCondition),
6701
- updatedAt: z35.optional(DateCondition),
6702
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
6703
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
6704
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
6705
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
6706
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
6707
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
6708
- createdAtLocation: z35.optional(
6709
- z35.union([SerializableWithin, SerializableExact])
6995
+ var z36 = __toESM(require("zod/v4"));
6996
+ var SerializableExact = z36.object({
6997
+ type: z36.literal("exact"),
6998
+ term: z36.union([z36.string(), SerializedUserField])
6999
+ });
7000
+ var SerializableWithin = z36.object({
7001
+ type: z36.literal("within"),
7002
+ location: z36.union([z36.string(), SerializedUserField])
7003
+ });
7004
+ var SerializedQueryExpression = z36.object({
7005
+ eventType: z36.string(),
7006
+ status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
7007
+ createdAt: z36.optional(DateCondition),
7008
+ updatedAt: z36.optional(DateCondition),
7009
+ "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
7010
+ "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
7011
+ "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
7012
+ "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
7013
+ "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
7014
+ "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
7015
+ createdAtLocation: z36.optional(
7016
+ z36.union([SerializableWithin, SerializableExact])
6710
7017
  ),
6711
- updatedAtLocation: z35.optional(
6712
- z35.union([SerializableWithin, SerializableExact])
7018
+ updatedAtLocation: z36.optional(
7019
+ z36.union([SerializableWithin, SerializableExact])
6713
7020
  ),
6714
- updatedByUserRole: z35.optional(SerializableExact),
6715
- assignedTo: z35.optional(SerializableExact),
6716
- createdBy: z35.optional(SerializableExact),
7021
+ updatedByUserRole: z36.optional(SerializableExact),
7022
+ assignedTo: z36.optional(SerializableExact),
7023
+ createdBy: z36.optional(SerializableExact),
6717
7024
  createdByUserType: ExactUserType,
6718
- updatedBy: z35.optional(SerializableExact),
6719
- trackingId: z35.optional(Exact),
6720
- flags: z35.optional(ContainsFlags),
7025
+ updatedBy: z36.optional(SerializableExact),
7026
+ trackingId: z36.optional(Exact),
7027
+ flags: z36.optional(ContainsFlags),
6721
7028
  data: QueryInput
6722
7029
  }).partial();
6723
- var Or2 = z35.object({
6724
- type: z35.literal("or"),
6725
- clauses: z35.array(SerializedQueryExpression)
7030
+ var Or2 = z36.object({
7031
+ type: z36.literal("or"),
7032
+ clauses: z36.array(SerializedQueryExpression)
6726
7033
  });
6727
- var And2 = z35.object({
6728
- type: z35.literal("and"),
6729
- clauses: z35.array(SerializedQueryExpression)
7034
+ var And2 = z36.object({
7035
+ type: z36.literal("and"),
7036
+ clauses: z36.array(SerializedQueryExpression)
6730
7037
  });
6731
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
6732
- var CountryConfigQueryInputType = z35.union([
7038
+ var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
7039
+ var CountryConfigQueryInputType = z36.union([
6733
7040
  SerializedQueryExpression,
6734
7041
  And2,
6735
7042
  Or2
6736
7043
  ]);
6737
7044
 
6738
- // ../commons/src/icons.ts
6739
- var z36 = __toESM(require("zod/v4"));
6740
- var AvailableIcons = z36.enum([
6741
- "Archived",
6742
- "Assigned",
6743
- "Briefcase",
6744
- "Certified",
6745
- "Close",
6746
- "Collapse",
6747
- "Draft",
6748
- "DuplicateYellow",
6749
- "Expand",
6750
- "ExternalValidate",
6751
- "FilledCheck",
6752
- "InReview",
6753
- "Offline",
6754
- "Registered",
6755
- "RequiresUpdates",
6756
- "Sent",
6757
- "Validated",
6758
- "WaitingApproval",
6759
- "ChartActivity",
6760
- "Activity",
6761
- "Archive",
6762
- "ArchiveTray",
6763
- "ArrowLeft",
6764
- "ArrowRight",
6765
- "Buildings",
6766
- "Circle",
6767
- "CaretDown",
6768
- "CaretLeft",
6769
- "CaretRight",
6770
- "ChartBar",
6771
- "ChartLine",
6772
- "ChatCircle",
6773
- "CheckSquare",
6774
- "Compass",
6775
- "Check",
6776
- "Copy",
6777
- "Database",
6778
- "DotsThreeVertical",
6779
- "ArrowCounterClockwise",
6780
- "MagnifyingGlassMinus",
6781
- "MagnifyingGlassPlus",
6782
- "Export",
6783
- "Eye",
6784
- "EyeSlash",
6785
- "Envelope",
6786
- "File",
6787
- "FileSearch",
6788
- "FileMinus",
6789
- "FilePlus",
6790
- "FileText",
6791
- "FileX",
6792
- "Handshake",
6793
- "Gear",
6794
- "GitBranch",
6795
- "IdentificationCard",
6796
- "List",
6797
- "ListBullets",
6798
- "Lock",
6799
- "MagnifyingGlass",
6800
- "MapPin",
6801
- "Medal",
6802
- "NotePencil",
6803
- "Paperclip",
6804
- "PaperPlaneTilt",
6805
- "Pen",
6806
- "PenNib",
6807
- "Pencil",
6808
- "PencilSimpleLine",
6809
- "Phone",
6810
- "Plus",
6811
- "Printer",
6812
- "SignOut",
6813
- "Stamp",
6814
- "Star",
6815
- "Target",
6816
- "TextT",
6817
- "Trash",
6818
- "UploadSimple",
6819
- "User",
6820
- "UserPlus",
6821
- "Users",
6822
- "WarningCircle",
6823
- "X",
6824
- "ChatText",
6825
- "CircleWavyCheck",
6826
- "CircleWavyQuestion",
6827
- "ArchiveBox",
6828
- "ArrowCircleDown",
6829
- "FileArrowUp",
6830
- "FileDotted",
6831
- "Files",
6832
- "PencilLine",
6833
- "PencilCircle",
6834
- "UserCircle",
6835
- "Clock",
6836
- "QrCode",
6837
- "Webcam",
6838
- "Sun",
6839
- "DeviceTabletCamera",
6840
- "Globe",
6841
- "Fingerprint",
6842
- "PushPin",
6843
- "Timer"
6844
- ]);
6845
-
6846
7045
  // ../commons/src/events/WorkqueueConfig.ts
6847
7046
  var mandatoryColumns = defineWorkqueuesColumns([
6848
7047
  {
@@ -10490,21 +10689,85 @@ var LocationTypeV1 = z43.enum([
10490
10689
  "CRVS_OFFICE",
10491
10690
  "HEALTH_FACILITY"
10492
10691
  ]);
10692
+ var LocationStatus = z43.enum(["active", "inactive"]);
10693
+ var LocationVersion = z43.object({
10694
+ versionId: UUID,
10695
+ effectiveFrom: z43.iso.date(),
10696
+ name: z43.string(),
10697
+ externalId: z43.string().nullish(),
10698
+ status: LocationStatus
10699
+ });
10493
10700
  var AdministrativeArea = z43.object({
10494
10701
  id: UUID,
10495
10702
  name: z43.string(),
10496
10703
  externalId: z43.string().nullish(),
10497
10704
  parentId: UUID.nullable(),
10498
- validUntil: z43.iso.datetime().nullable()
10705
+ status: LocationStatus,
10706
+ versions: z43.array(LocationVersion)
10499
10707
  });
10500
10708
  var Location = z43.object({
10501
10709
  id: UUID,
10502
10710
  name: z43.string(),
10503
10711
  externalId: z43.string().nullish(),
10504
10712
  administrativeAreaId: UUID.nullable(),
10505
- validUntil: z43.iso.datetime().nullable(),
10713
+ locationType: z43.string().nullable(),
10714
+ status: LocationStatus,
10715
+ versions: z43.array(LocationVersion)
10716
+ });
10717
+ var ClientAdministrativeArea = AdministrativeArea.omit({
10718
+ name: true,
10719
+ status: true,
10720
+ externalId: true
10721
+ });
10722
+ var ClientLocation = Location.omit({
10723
+ name: true,
10724
+ status: true,
10725
+ externalId: true
10726
+ });
10727
+ function toClientLocation(location) {
10728
+ return {
10729
+ id: location.id,
10730
+ administrativeAreaId: location.administrativeAreaId,
10731
+ locationType: location.locationType,
10732
+ versions: location.versions
10733
+ };
10734
+ }
10735
+ function toClientAdministrativeArea(area) {
10736
+ return {
10737
+ id: area.id,
10738
+ parentId: area.parentId,
10739
+ versions: area.versions
10740
+ };
10741
+ }
10742
+ var SetLocationPayload = z43.object({
10743
+ id: UUID,
10744
+ name: z43.string(),
10745
+ externalId: z43.string().nullish(),
10746
+ administrativeAreaId: UUID.nullable(),
10506
10747
  locationType: z43.string().nullable()
10507
10748
  });
10749
+ var SetAdministrativeAreaPayload = z43.object({
10750
+ id: UUID,
10751
+ name: z43.string(),
10752
+ externalId: z43.string().nullish(),
10753
+ parentId: UUID.nullable()
10754
+ });
10755
+ function resolveVersion(versions, anchor) {
10756
+ let resolved = versions[0];
10757
+ for (const version of versions) {
10758
+ if (version.effectiveFrom <= anchor) {
10759
+ resolved = version;
10760
+ }
10761
+ }
10762
+ return resolved;
10763
+ }
10764
+ function hasActiveExternalIdOnOrAfter(versions, externalId, anchor) {
10765
+ const inEffectAtAnchor = resolveVersion(versions, anchor);
10766
+ const laterVersions = versions.filter((v) => v.effectiveFrom > anchor);
10767
+ return [inEffectAtAnchor, ...laterVersions].some(
10768
+ (v) => v.externalId === externalId && v.status === "active"
10769
+ );
10770
+ }
10508
10771
  function matchesJurisdictionFilter(locationIds, filter, user2) {
10509
10772
  if (!locationIds) {
10510
10773
  return false;
@@ -10551,6 +10814,9 @@ function canAccessEventWithScope(event2, scope, user2, customActionType) {
10551
10814
  )) {
10552
10815
  return false;
10553
10816
  }
10817
+ if (opts?.createdBy === UserFilter.enum.user && event2.createdBy !== user2.id) {
10818
+ return false;
10819
+ }
10554
10820
  if (scopeUsesDeclaredOptions(scope)) {
10555
10821
  const { options } = scope;
10556
10822
  if (options?.notifiedBy === UserFilter.enum.user) {
@@ -10696,6 +10962,16 @@ function getLocationHierarchy(selectedId, context) {
10696
10962
  );
10697
10963
  return hierarchy.reverse().map((area) => area.id);
10698
10964
  }
10965
+ function resolvePath(locationId, anchor, context) {
10966
+ return getLocationHierarchy(locationId, context).flatMap((id) => {
10967
+ const node = context.locations.get(id) ?? context.administrativeAreas.get(id);
10968
+ if (!node) {
10969
+ return [];
10970
+ }
10971
+ const { name, status: status2 } = resolveVersion(node.versions, anchor);
10972
+ return [{ id, name, status: status2 }];
10973
+ });
10974
+ }
10699
10975
 
10700
10976
  // ../commons/src/events/scopes.ts
10701
10977
  var ACTION_SCOPE_MAP = {
@@ -11000,75 +11276,80 @@ function getFilePathsFromEvent(event2) {
11000
11276
  }
11001
11277
 
11002
11278
  // ../commons/src/events/mocks.test.utils.ts
11003
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11279
+ function withVersionFields(entity) {
11280
+ return {
11281
+ ...entity,
11282
+ status: "active",
11283
+ versions: [
11284
+ {
11285
+ versionId: entity.id,
11286
+ effectiveFrom: "0001-01-01",
11287
+ name: entity.name,
11288
+ externalId: entity.externalId ?? null,
11289
+ status: "active"
11290
+ }
11291
+ ]
11292
+ };
11293
+ }
11294
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
11004
11295
  {
11005
11296
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11006
11297
  name: "Central",
11007
11298
  parentId: null,
11008
- validUntil: null,
11009
11299
  externalId: "ydyJb1RAy4U1"
11010
11300
  },
11011
11301
  {
11012
11302
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11013
11303
  name: "Sulaka",
11014
11304
  parentId: null,
11015
- validUntil: null,
11016
11305
  externalId: "pQ8nGxWmZ2Q3"
11017
11306
  },
11018
11307
  {
11019
11308
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
11020
11309
  name: "Pualula",
11021
11310
  parentId: null,
11022
- validUntil: null,
11023
11311
  externalId: "Aq91DweLmT8k"
11024
11312
  },
11025
11313
  {
11026
11314
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
11027
11315
  name: "Chuminga",
11028
11316
  parentId: null,
11029
- validUntil: null,
11030
11317
  externalId: "Rw0fYNh2Xk9a"
11031
11318
  },
11032
11319
  {
11033
11320
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11034
11321
  name: "Ibombo",
11035
11322
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11036
- validUntil: null,
11037
11323
  externalId: "k7DsP4vbN1Qe"
11038
11324
  },
11039
11325
  {
11040
11326
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
11041
11327
  name: "Isango",
11042
11328
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11043
- validUntil: null,
11044
11329
  externalId: "Gm3Z9eQpHw4L"
11045
11330
  },
11046
11331
  {
11047
11332
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
11048
11333
  name: "Isamba",
11049
11334
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11050
- validUntil: null,
11051
11335
  externalId: "sT0xVu1KqJ7r"
11052
11336
  },
11053
11337
  {
11054
11338
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
11055
11339
  name: "Itambo",
11056
11340
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11057
- validUntil: null,
11058
11341
  externalId: "Nq6Bv2HpL9Te"
11059
11342
  },
11060
11343
  {
11061
11344
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
11062
11345
  name: "Ezhi",
11063
11346
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11064
- validUntil: null,
11065
11347
  externalId: "xK8cQ0ZRy5Wd"
11066
11348
  },
11067
11349
  {
11068
11350
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11069
11351
  name: "Ilanga",
11070
11352
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11071
- validUntil: null,
11072
11353
  externalId: "Cq4Jm1XvN8Ls"
11073
11354
  },
11074
11355
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -11076,49 +11357,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11076
11357
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11077
11358
  name: "Klow",
11078
11359
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11079
- validUntil: null,
11080
11360
  externalId: "IkYcYBUcyY2"
11081
11361
  },
11082
11362
  {
11083
11363
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
11084
11364
  name: "Mbondo",
11085
11365
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11086
- validUntil: null,
11087
11366
  externalId: "Qhvv5hvo3mY"
11088
11367
  },
11089
11368
  {
11090
11369
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
11091
11370
  name: "Ndara",
11092
11371
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11093
- validUntil: null,
11094
11372
  externalId: "crXh068O9TR"
11095
11373
  },
11096
11374
  {
11097
11375
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
11098
11376
  name: "Olani",
11099
11377
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11100
- validUntil: null,
11101
11378
  externalId: "r00It8Tvvp7"
11102
11379
  },
11103
11380
  {
11104
11381
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
11105
11382
  name: "Pemba",
11106
11383
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11107
- validUntil: null,
11108
11384
  externalId: "ZnUWsbONIaH"
11109
11385
  },
11110
11386
  {
11111
11387
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
11112
11388
  name: "Quanza",
11113
11389
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11114
- validUntil: null,
11115
11390
  externalId: "fDZycvQTa7l"
11116
11391
  },
11117
11392
  {
11118
11393
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
11119
11394
  name: "Rivka",
11120
11395
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11121
- validUntil: null,
11122
11396
  externalId: "KqswxCGTELa"
11123
11397
  },
11124
11398
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -11126,35 +11400,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11126
11400
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
11127
11401
  name: "Mbula",
11128
11402
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11129
- validUntil: null,
11130
11403
  externalId: "osEbKjRc9Kg"
11131
11404
  },
11132
11405
  {
11133
11406
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
11134
11407
  name: "Ndoki",
11135
11408
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11136
- validUntil: null,
11137
11409
  externalId: "aq4daBUAGr3"
11138
11410
  },
11139
11411
  {
11140
11412
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
11141
11413
  name: "Tsanga",
11142
11414
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11143
- validUntil: null,
11144
11415
  externalId: "cqis6Y8trbJ"
11145
11416
  },
11146
11417
  {
11147
11418
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
11148
11419
  name: "Waziri",
11149
11420
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11150
- validUntil: null,
11151
11421
  externalId: "LMijHPyyx6d"
11152
11422
  },
11153
11423
  {
11154
11424
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
11155
11425
  name: "Zimbi",
11156
11426
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11157
- validUntil: null,
11158
11427
  externalId: "pcQYbPuKGZ7"
11159
11428
  },
11160
11429
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -11162,67 +11431,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
11162
11431
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
11163
11432
  name: "Felani",
11164
11433
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11165
- validUntil: null,
11166
11434
  externalId: "gSqpoCGdMXp"
11167
11435
  },
11168
11436
  {
11169
11437
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
11170
11438
  name: "Goroma",
11171
11439
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11172
- validUntil: null,
11173
11440
  externalId: "KvAAIaNqVrp"
11174
11441
  },
11175
11442
  {
11176
11443
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
11177
11444
  name: "Halifu",
11178
11445
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11179
- validUntil: null,
11180
11446
  externalId: "qe4UnEVt1hv"
11181
11447
  },
11182
11448
  {
11183
11449
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
11184
11450
  name: "Jabari",
11185
11451
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11186
- validUntil: null,
11187
11452
  externalId: "yHH9Nz4rLOt"
11188
11453
  },
11189
11454
  {
11190
11455
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
11191
11456
  name: "Kifani",
11192
11457
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11193
- validUntil: null,
11194
11458
  externalId: "eSWmXIGeu1I"
11195
11459
  },
11196
11460
  {
11197
11461
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
11198
11462
  name: "Lumela",
11199
11463
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
11200
- validUntil: null,
11201
11464
  externalId: "bh0b3aI1uP3"
11202
11465
  }
11203
11466
  ];
11204
- var V2_DEFAULT_MOCK_LOCATIONS = [
11467
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
11468
+ var MOCK_LOCATIONS_BASE = [
11205
11469
  {
11206
11470
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
11207
11471
  name: "Central Provincial Office",
11208
11472
  locationType: "CRVS_OFFICE",
11209
11473
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11210
- validUntil: null,
11211
11474
  externalId: "Xr3Df8WpK6Ys"
11212
11475
  },
11213
11476
  {
11214
11477
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
11215
11478
  name: "Central Health Post",
11216
11479
  locationType: "HEALTH_FACILITY",
11217
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
11218
- validUntil: null
11480
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
11219
11481
  },
11220
11482
  {
11221
11483
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
11222
11484
  name: "Ibombo District Office",
11223
11485
  locationType: "CRVS_OFFICE",
11224
11486
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11225
- validUntil: null,
11226
11487
  externalId: "Sm4Nw7GrD2Vy"
11227
11488
  },
11228
11489
  {
@@ -11230,7 +11491,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11230
11491
  name: "Isamba District Office",
11231
11492
  locationType: "CRVS_OFFICE",
11232
11493
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
11233
- validUntil: null,
11234
11494
  externalId: "Vg1Bq5XeH9Lt"
11235
11495
  },
11236
11496
  {
@@ -11238,7 +11498,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11238
11498
  name: "Isango District Office",
11239
11499
  locationType: "CRVS_OFFICE",
11240
11500
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
11241
- validUntil: null,
11242
11501
  externalId: "Je7Lm2XqN9Vz"
11243
11502
  },
11244
11503
  {
@@ -11246,7 +11505,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11246
11505
  name: "Sulaka Provincial Office",
11247
11506
  locationType: "CRVS_OFFICE",
11248
11507
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
11249
- validUntil: null,
11250
11508
  externalId: "Ht2Wp9KcX5Qv"
11251
11509
  },
11252
11510
  {
@@ -11254,7 +11512,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11254
11512
  name: "Ilanga District Office",
11255
11513
  locationType: "CRVS_OFFICE",
11256
11514
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
11257
- validUntil: null,
11258
11515
  externalId: "Yp6Ds1WqN3Xz"
11259
11516
  },
11260
11517
  {
@@ -11262,7 +11519,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11262
11519
  name: "Chamakubi Health Post",
11263
11520
  locationType: "HEALTH_FACILITY",
11264
11521
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11265
- validUntil: null,
11266
11522
  externalId: "M1nFr8LbC2Qy"
11267
11523
  },
11268
11524
  {
@@ -11270,7 +11526,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11270
11526
  name: "Ibombo Rural Health Centre",
11271
11527
  locationType: "HEALTH_FACILITY",
11272
11528
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11273
- validUntil: null,
11274
11529
  externalId: "bT7pV6YrW0Xc"
11275
11530
  },
11276
11531
  {
@@ -11278,7 +11533,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11278
11533
  name: "Chikobo Rural Health Centre",
11279
11534
  locationType: "HEALTH_FACILITY",
11280
11535
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11281
- validUntil: null,
11282
11536
  externalId: "zE4qPn2SgJ5d"
11283
11537
  },
11284
11538
  {
@@ -11286,7 +11540,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11286
11540
  name: "Chilochabalenje Health Post",
11287
11541
  locationType: "HEALTH_FACILITY",
11288
11542
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11289
- validUntil: null,
11290
11543
  externalId: "H8vDs1MqR4Uf"
11291
11544
  },
11292
11545
  {
@@ -11294,7 +11547,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11294
11547
  name: "Chipeso Rural Health Centre",
11295
11548
  locationType: "HEALTH_FACILITY",
11296
11549
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11297
- validUntil: null,
11298
11550
  externalId: "Qw3uZ9KfX6Lm"
11299
11551
  },
11300
11552
  {
@@ -11302,7 +11554,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11302
11554
  name: "Chisamba Rural Health Centre",
11303
11555
  locationType: "HEALTH_FACILITY",
11304
11556
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11305
- validUntil: null,
11306
11557
  externalId: "Yr0pCg8LdM2s"
11307
11558
  },
11308
11559
  {
@@ -11310,7 +11561,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11310
11561
  name: "Chitanda Rural Health Centre",
11311
11562
  locationType: "HEALTH_FACILITY",
11312
11563
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11313
- validUntil: null,
11314
11564
  externalId: "tS9gJ4PwB1Qx"
11315
11565
  },
11316
11566
  {
@@ -11318,7 +11568,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11318
11568
  name: "Golden Valley Rural Health Centre",
11319
11569
  locationType: "HEALTH_FACILITY",
11320
11570
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11321
- validUntil: null,
11322
11571
  externalId: "Ld7Qm3XsA8Vr"
11323
11572
  },
11324
11573
  {
@@ -11326,7 +11575,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11326
11575
  name: "Ipongo Rural Health Centre",
11327
11576
  locationType: "HEALTH_FACILITY",
11328
11577
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11329
- validUntil: null,
11330
11578
  externalId: "kF2sW9DmH0Bt"
11331
11579
  },
11332
11580
  {
@@ -11334,7 +11582,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11334
11582
  name: "Itumbwe Health Post",
11335
11583
  locationType: "HEALTH_FACILITY",
11336
11584
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11337
- validUntil: null,
11338
11585
  externalId: "Ue5Xb3VaC7Pq"
11339
11586
  },
11340
11587
  {
@@ -11342,7 +11589,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11342
11589
  name: "Kabangalala Rural Health Centre",
11343
11590
  locationType: "HEALTH_FACILITY",
11344
11591
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
11345
- validUntil: null,
11346
11592
  externalId: "Pz8Kc1TqH6Jn"
11347
11593
  },
11348
11594
  // Village offices
@@ -11351,13 +11597,70 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
11351
11597
  name: "Klow Village Office",
11352
11598
  locationType: "CRVS_OFFICE",
11353
11599
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
11354
- validUntil: null,
11355
11600
  externalId: "PmAyxAJkxiJ"
11356
11601
  }
11357
11602
  ];
11603
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
11358
11604
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
11359
11605
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
11360
11606
  );
11361
11607
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
11362
11608
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
11363
11609
  );
11610
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
11611
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
11612
+ );
11613
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
11614
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
11615
+ a.id,
11616
+ toClientAdministrativeArea(a)
11617
+ ])
11618
+ );
11619
+
11620
+ // ../commons/src/events/locationPayloads.ts
11621
+ var z44 = __toESM(require("zod/v4"));
11622
+ var CreateLocationPayload = z44.object({
11623
+ id: UUID.optional(),
11624
+ versionId: UUID.optional(),
11625
+ name: z44.string(),
11626
+ externalId: z44.string().nullish(),
11627
+ administrativeAreaId: UUID.nullable(),
11628
+ locationType: z44.string().nullable(),
11629
+ effectiveFrom: z44.iso.date().optional(),
11630
+ status: LocationStatus.default("active")
11631
+ });
11632
+ var UpdateLocationPayload = z44.strictObject({
11633
+ id: UUID,
11634
+ versionId: UUID.optional(),
11635
+ name: z44.string(),
11636
+ externalId: z44.string().nullish(),
11637
+ status: LocationStatus,
11638
+ effectiveFrom: z44.iso.date().optional(),
11639
+ lastVersionId: UUID
11640
+ });
11641
+ var WithdrawLocationVersionPayload = z44.object({
11642
+ id: UUID,
11643
+ versionId: UUID
11644
+ });
11645
+ var CreateAdministrativeAreaPayload = z44.object({
11646
+ id: UUID.optional(),
11647
+ versionId: UUID.optional(),
11648
+ name: z44.string(),
11649
+ externalId: z44.string().nullish(),
11650
+ parentId: UUID.nullable(),
11651
+ effectiveFrom: z44.iso.date().optional(),
11652
+ status: LocationStatus.default("active")
11653
+ });
11654
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
11655
+ id: UUID,
11656
+ versionId: UUID.optional(),
11657
+ name: z44.string(),
11658
+ externalId: z44.string().nullish(),
11659
+ status: LocationStatus,
11660
+ effectiveFrom: z44.iso.date().optional(),
11661
+ lastVersionId: UUID
11662
+ });
11663
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
11664
+ id: UUID,
11665
+ versionId: UUID
11666
+ });