@opencrvs/toolkit 2.1.0-rc.edf2492 → 2.1.0-rc.f29a266

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 (92) hide show
  1. package/README.md +1 -0
  2. package/create-countryconfig/index.js +114 -66
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +256 -198
  6. package/dist/cli.js +195 -73
  7. package/dist/commons/api/router.d.ts +3924 -3326
  8. package/dist/commons/application-config/index.d.ts +6 -6
  9. package/dist/commons/conditionals/conditionals.d.ts +259 -2102
  10. package/dist/commons/conditionals/validate.d.ts +16 -5
  11. package/dist/commons/events/ActionConfig.d.ts +105 -105
  12. package/dist/commons/events/ActionDocument.d.ts +121 -127
  13. package/dist/commons/events/ActionInput.d.ts +4 -10
  14. package/dist/commons/events/ActionStatus.d.ts +14 -0
  15. package/dist/commons/events/ActionType.d.ts +62 -62
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +525 -507
  17. package/dist/commons/events/AuditLog.d.ts +189 -42
  18. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  19. package/dist/commons/events/Conditional.d.ts +3 -3
  20. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  21. package/dist/commons/events/Draft.d.ts +37 -37
  22. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  23. package/dist/commons/events/EventConfig.d.ts +8 -5
  24. package/dist/commons/events/EventDocument.d.ts +50 -50
  25. package/dist/commons/events/EventIndex.d.ts +49 -72
  26. package/dist/commons/events/EventMetadata.d.ts +40 -40
  27. package/dist/commons/events/FieldConfig.d.ts +419 -389
  28. package/dist/commons/events/FieldType.d.ts +51 -51
  29. package/dist/commons/events/FieldTypeMapping.d.ts +90 -90
  30. package/dist/commons/events/FieldValue.d.ts +14 -14
  31. package/dist/commons/events/Flag.d.ts +57 -15
  32. package/dist/commons/events/PlainDate.d.ts +8 -0
  33. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  34. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  35. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  36. package/dist/commons/events/WorkqueueConfig.d.ts +817 -814
  37. package/dist/commons/events/deduplication.d.ts +1 -1
  38. package/dist/commons/events/event.d.ts +14 -2
  39. package/dist/commons/events/field.d.ts +78 -895
  40. package/dist/commons/events/index.d.ts +1 -0
  41. package/dist/commons/events/locationPayloads.d.ts +95 -0
  42. package/dist/commons/events/locations.d.ts +241 -12
  43. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  44. package/dist/commons/events/scopes.d.ts +4 -4
  45. package/dist/commons/events/state/index.d.ts +17 -17
  46. package/dist/commons/events/state/utils.d.ts +7 -7
  47. package/dist/commons/events/test.utils.d.ts +47 -46
  48. package/dist/commons/events/utils.d.ts +114 -114
  49. package/dist/commons/notification/UserNotifications.d.ts +38 -10
  50. package/dist/conditionals/index.js +308 -55
  51. package/dist/environment/derived-variables.d.ts +119 -119
  52. package/dist/environment/derived-variables.d.ts.map +1 -1
  53. package/dist/environment/index.d.ts +1 -0
  54. package/dist/environment/index.d.ts.map +1 -1
  55. package/dist/environment/index.js +10 -0
  56. package/dist/environment/logger.d.ts +12 -3
  57. package/dist/environment/logger.d.ts.map +1 -1
  58. package/dist/environment/paths.d.ts +7 -0
  59. package/dist/environment/paths.d.ts.map +1 -0
  60. package/dist/environment/paths.js +72 -0
  61. package/dist/environment/questions.d.ts +75 -74
  62. package/dist/environment/questions.d.ts.map +1 -1
  63. package/dist/environment/questions.js +20 -14
  64. package/dist/environment/setup-environment.js +11 -16
  65. package/dist/environment/templates.d.ts.map +1 -1
  66. package/dist/environment/templates.js +2 -1
  67. package/dist/environment/update-workflows.d.ts.map +1 -1
  68. package/dist/environment/update-workflows.js +17 -5
  69. package/dist/environment/upgrade.d.ts +2 -0
  70. package/dist/environment/upgrade.d.ts.map +1 -0
  71. package/dist/environment/upgrade.js +82 -0
  72. package/dist/environment/users.js +11 -13
  73. package/dist/environment/utils.d.ts +1 -1
  74. package/dist/events/deduplication.d.ts +1 -1
  75. package/dist/events/index.js +3678 -3296
  76. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  77. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  78. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  79. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  80. package/dist/notification/index.js +1438 -1080
  81. package/dist/scopes/index.d.ts +396 -169
  82. package/dist/scopes/index.js +309 -55
  83. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  84. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  85. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  86. package/dist/templates/inventory/inventory.template.yml +1 -3
  87. package/opencrvs-toolkit-2.1.0-rc.f29a266.tgz +0 -0
  88. package/package.json +7 -7
  89. package/tsconfig.tsbuildinfo +1 -1
  90. package/dist/templates/inventory/production.example.yml +0 -77
  91. package/dist/templates/inventory/qa.example.yml +0 -48
  92. package/opencrvs-toolkit-2.1.0-rc.edf2492.tgz +0 -0
@@ -38,7 +38,7 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z45 = __toESM(require("zod/v4"));
41
+ var z46 = __toESM(require("zod/v4"));
42
42
 
43
43
  // ../commons/src/url.ts
44
44
  function joinUrl(base, path) {
@@ -47,14 +47,14 @@ function joinUrl(base, path) {
47
47
  }
48
48
 
49
49
  // ../commons/src/events/AuditLog.ts
50
- var z5 = __toESM(require("zod/v4"));
50
+ var z8 = __toESM(require("zod/v4"));
51
51
 
52
52
  // ../commons/src/authentication.ts
53
53
  var import_jwt_decode = __toESM(require("jwt-decode"));
54
- var z3 = __toESM(require("zod/v4"));
54
+ var z7 = __toESM(require("zod/v4"));
55
55
 
56
56
  // ../commons/src/scopes.ts
57
- var z2 = __toESM(require("zod/v4"));
57
+ var z6 = __toESM(require("zod/v4"));
58
58
  var qs = __toESM(require("qs"));
59
59
 
60
60
  // ../commons/src/uuid.ts
@@ -65,12 +65,260 @@ function getUUID() {
65
65
  return (0, import_uuid.v4)();
66
66
  }
67
67
 
68
+ // ../commons/src/events/ActionType.ts
69
+ var z2 = __toESM(require("zod/v4"));
70
+ var ActionType = {
71
+ // Pre-declaration actions
72
+ DELETE: "DELETE",
73
+ CREATE: "CREATE",
74
+ NOTIFY: "NOTIFY",
75
+ // Declaration actions
76
+ DECLARE: "DECLARE",
77
+ REGISTER: "REGISTER",
78
+ EDIT: "EDIT",
79
+ // Declaration system actions. Non-configurable.
80
+ DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
81
+ REJECT: "REJECT",
82
+ // REJECT_DECLARATION
83
+ MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
84
+ MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
85
+ ARCHIVE: "ARCHIVE",
86
+ UNARCHIVE: "UNARCHIVE",
87
+ // Record actions
88
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
89
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
90
+ REJECT_CORRECTION: "REJECT_CORRECTION",
91
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
92
+ // General actions
93
+ READ: "READ",
94
+ ASSIGN: "ASSIGN",
95
+ UNASSIGN: "UNASSIGN",
96
+ // Custom action
97
+ CUSTOM: "CUSTOM"
98
+ };
99
+ var ConfirmableActions = [
100
+ ActionType.NOTIFY,
101
+ ActionType.DECLARE,
102
+ ActionType.EDIT,
103
+ ActionType.REGISTER,
104
+ ActionType.REJECT,
105
+ ActionType.ARCHIVE,
106
+ ActionType.UNARCHIVE,
107
+ ActionType.PRINT_CERTIFICATE,
108
+ ActionType.REQUEST_CORRECTION,
109
+ ActionType.APPROVE_CORRECTION,
110
+ ActionType.REJECT_CORRECTION,
111
+ ActionType.CUSTOM
112
+ ];
113
+ var ActionTypes = z2.enum([
114
+ "DELETE",
115
+ "CREATE",
116
+ "NOTIFY",
117
+ "DECLARE",
118
+ "EDIT",
119
+ "REGISTER",
120
+ "DUPLICATE_DETECTED",
121
+ "REJECT",
122
+ "MARK_AS_DUPLICATE",
123
+ "MARK_AS_NOT_DUPLICATE",
124
+ "ARCHIVE",
125
+ "UNARCHIVE",
126
+ "PRINT_CERTIFICATE",
127
+ "REQUEST_CORRECTION",
128
+ "REJECT_CORRECTION",
129
+ "APPROVE_CORRECTION",
130
+ "READ",
131
+ "ASSIGN",
132
+ "UNASSIGN",
133
+ "CUSTOM"
134
+ ]);
135
+ var ClientSpecificAction = {
136
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
137
+ };
138
+ var declarationActionValues = [
139
+ ActionTypes.enum.DECLARE,
140
+ ActionTypes.enum.EDIT,
141
+ ActionTypes.enum.REGISTER,
142
+ ActionTypes.enum.NOTIFY,
143
+ ActionTypes.enum.DUPLICATE_DETECTED
144
+ ];
145
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
146
+ var declarationUpdateActionValues = [
147
+ ...declarationActionValues,
148
+ ActionTypes.enum.REQUEST_CORRECTION
149
+ ];
150
+ var DeclarationUpdateActions = ActionTypes.extract(
151
+ declarationUpdateActionValues
152
+ );
153
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
154
+ var writeActions = ActionTypes.exclude([
155
+ ActionType.CREATE,
156
+ ActionType.READ,
157
+ ActionType.ASSIGN,
158
+ ActionType.UNASSIGN
159
+ ]);
160
+ var WorkqueueActionType = ActionTypes.extract([
161
+ ActionType.READ,
162
+ ActionType.DELETE,
163
+ ActionType.DECLARE,
164
+ ActionType.REGISTER,
165
+ ActionType.EDIT,
166
+ ActionType.REJECT,
167
+ ActionType.MARK_AS_DUPLICATE,
168
+ ActionType.ARCHIVE,
169
+ ActionType.UNARCHIVE,
170
+ ActionType.PRINT_CERTIFICATE,
171
+ ActionType.REQUEST_CORRECTION
172
+ ]);
173
+ var META_ACTIONS = [
174
+ ActionType.ASSIGN,
175
+ ActionType.UNASSIGN,
176
+ ActionType.READ
177
+ ];
178
+
179
+ // ../commons/src/events/ActionStatus.ts
180
+ var ActionStatus = {
181
+ Requested: "Requested",
182
+ Accepted: "Accepted",
183
+ Rejected: "Rejected"
184
+ };
185
+
186
+ // ../commons/src/events/Flag.ts
187
+ var z5 = __toESM(require("zod/v4"));
188
+
189
+ // ../commons/src/events/TranslationConfig.ts
190
+ var z3 = __toESM(require("zod/v4"));
191
+ var TranslationConfig = z3.object({
192
+ id: z3.string().describe(
193
+ "The identifier of the translation referred in translation CSV files"
194
+ ),
195
+ defaultMessage: z3.string().describe("Default translation message"),
196
+ description: z3.string().describe(
197
+ "Describe the translation for a translator to be able to identify it."
198
+ )
199
+ }).meta({
200
+ description: "Translation configuration",
201
+ id: "TranslationConfig"
202
+ });
203
+
204
+ // ../commons/src/events/Conditional.ts
205
+ var z4 = __toESM(require("zod/v4"));
206
+ var Conditional = z4.any().describe("JSONSchema").meta({
207
+ description: "JSON schema conditional configuration",
208
+ id: "Conditional"
209
+ });
210
+ var ConditionalType = {
211
+ SHOW: "SHOW",
212
+ ENABLE: "ENABLE",
213
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
214
+ };
215
+ var ShowConditional = z4.object({
216
+ type: z4.literal(ConditionalType.SHOW),
217
+ conditional: Conditional
218
+ }).describe(
219
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
220
+ );
221
+ var EnableConditional = z4.object({
222
+ type: z4.literal(ConditionalType.ENABLE),
223
+ conditional: Conditional
224
+ }).describe(
225
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
226
+ );
227
+ var ActionConditional = z4.discriminatedUnion("type", [
228
+ // Action can be shown / hidden
229
+ ShowConditional,
230
+ // Action can be shown to the user in the list but as disabled
231
+ EnableConditional
232
+ ]).meta({
233
+ id: "ActionConditional",
234
+ description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
235
+ });
236
+ var DisplayOnReviewConditional = z4.object({
237
+ type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
238
+ conditional: Conditional
239
+ }).describe(
240
+ "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
241
+ );
242
+ var FieldConditional = z4.discriminatedUnion("type", [
243
+ // Field input can be shown / hidden
244
+ ShowConditional,
245
+ // Field input can be shown to the user but as disabled
246
+ EnableConditional,
247
+ // Field output can be shown / hidden on the review page
248
+ DisplayOnReviewConditional
249
+ ]).meta({
250
+ id: "FieldConditional",
251
+ description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
252
+ });
253
+
254
+ // ../commons/src/events/Flag.ts
255
+ var InherentFlags = {
256
+ INCOMPLETE: "incomplete",
257
+ REJECTED: "rejected",
258
+ CORRECTION_REQUESTED: "correction-requested",
259
+ POTENTIAL_DUPLICATE: "potential-duplicate",
260
+ /**
261
+ * This flag is set by the Edit-action and removed after the declaration or registration.
262
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
263
+ *
264
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
265
+ */
266
+ EDIT_IN_PROGRESS: "edit-in-progress"
267
+ };
268
+ var actionFlagPattern;
269
+ function getActionFlagPattern() {
270
+ actionFlagPattern ??= new RegExp(
271
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
272
+ ActionStatus
273
+ ).join("|").toLowerCase()})$`
274
+ );
275
+ return actionFlagPattern;
276
+ }
277
+ var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
278
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
279
+ });
280
+ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
281
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
282
+ InherentFlags
283
+ ).join(", ")}`
284
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
285
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
286
+ }).describe("Custom flag identifier defined by the country config.");
287
+ var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
288
+ var ContainsFlags = z5.object({
289
+ anyOf: z5.array(Flag).optional(),
290
+ noneOf: z5.array(Flag).optional(),
291
+ allOf: z5.array(Flag).optional()
292
+ }).meta({
293
+ id: "ContainsFlags"
294
+ });
295
+ var FlagConfig = z5.object({
296
+ id: CustomFlag,
297
+ requiresAction: z5.boolean().describe(
298
+ "Indicates if this flag expects an action to be performed to be cleared."
299
+ ),
300
+ label: TranslationConfig.describe("Human readable label of the flag.")
301
+ }).meta({
302
+ id: "FlagConfig",
303
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
304
+ });
305
+ var ActionFlagConfig = z5.object({
306
+ id: Flag,
307
+ operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
308
+ conditional: Conditional.optional().describe(
309
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
310
+ )
311
+ }).meta({
312
+ id: "ActionFlagConfig",
313
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
314
+ });
315
+
68
316
  // ../commons/src/scopes.ts
69
- var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
317
+ var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
70
318
  "Filters based on user jurisdiction relative to their office location in hierarchy."
71
319
  );
72
- var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
73
- var RecordScopeTypeV2 = z2.enum([
320
+ var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
321
+ var RecordScopeTypeV2 = z6.enum([
74
322
  "record.search",
75
323
  "record.create",
76
324
  "record.read",
@@ -88,14 +336,20 @@ var RecordScopeTypeV2 = z2.enum([
88
336
  "record.unassign-others",
89
337
  "record.custom-action"
90
338
  ]);
91
- var PlainScopeType = z2.enum([
339
+ var PlainScopeType = z6.enum([
92
340
  // Misc. system scopes
93
341
  "bypassratelimit",
94
342
  "record.reindex",
95
343
  "user.data-seeding",
96
344
  "integration.create",
345
+ // Reading an integration's audit log. Deliberately separate from
346
+ // 'integration.create' so read-only oversight can be granted on its own, and
347
+ // deliberately option-less: system clients have no office and no
348
+ // administrative area, so jurisdiction options would have nothing to bind to.
349
+ "integration.audit.read",
97
350
  "record.import",
98
351
  "config.update-all",
352
+ "location.edit",
99
353
  "attachment.upload",
100
354
  "profile.electronic-signature",
101
355
  "user.read-only-my-audit",
@@ -107,15 +361,15 @@ var PlainScopeType = z2.enum([
107
361
  "record.confirm-registration",
108
362
  "record.reject-registration"
109
363
  ]);
110
- var scopeByEvent = z2.preprocess(
364
+ var scopeByEvent = z6.preprocess(
111
365
  (val) => val === void 0 ? void 0 : [val].flat(),
112
- z2.array(z2.string()).optional()
366
+ z6.array(z6.string()).optional()
113
367
  ).describe("Event type, e.g. birth, death");
114
- var userRole = z2.preprocess(
368
+ var userRole = z6.preprocess(
115
369
  (val) => val === void 0 ? void 0 : [val].flat(),
116
- z2.array(z2.string()).optional()
370
+ z6.array(z6.string()).optional()
117
371
  ).describe("User role, e.g. admin, field agent");
118
- var scopeOptionsPlaceEvent = z2.object({
372
+ var scopeOptionsPlaceEvent = z6.object({
119
373
  event: scopeByEvent,
120
374
  placeOfEvent: JurisdictionFilter.optional()
121
375
  }).describe("Options applicable to all record scopes.");
@@ -127,36 +381,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
127
381
  }).describe("Options applicable to actions that may take place after DECLARE");
128
382
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
129
383
  registeredIn: JurisdictionFilter.optional(),
130
- registeredBy: UserFilter.optional()
384
+ registeredBy: UserFilter.optional(),
385
+ flags: ContainsFlags.optional()
131
386
  }).describe(
132
387
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
133
388
  );
134
389
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
135
- customActionTypes: z2.preprocess(
390
+ customActionTypes: z6.preprocess(
136
391
  (val) => val === void 0 ? void 0 : [val].flat(),
137
- z2.array(z2.string()).optional()
392
+ z6.array(z6.string()).optional()
138
393
  ).describe("Allowed custom action types")
139
394
  });
140
- var AccessLevelOptions = z2.object({
395
+ var AccessLevelOptions = z6.object({
141
396
  accessLevel: JurisdictionFilter.optional()
142
397
  });
143
398
  var AllUserScopeOptions = AccessLevelOptions.extend({
144
399
  role: userRole.optional()
145
400
  });
146
- var WorkqueueOrDashboardOptions = z2.object({
147
- ids: z2.preprocess(
401
+ var WorkqueueOrDashboardOptions = z6.object({
402
+ ids: z6.preprocess(
148
403
  (val) => val === void 0 ? void 0 : [val].flat(),
149
- z2.array(z2.string())
404
+ z6.array(z6.string())
150
405
  ).describe("Must contain a list of workqueue or dashboard ids.")
151
406
  });
152
- var AllScopeOptions = z2.object({
407
+ var AllScopeOptions = z6.object({
153
408
  ...AllRecordScopeOptions.shape,
154
409
  ...AccessLevelOptions.shape,
155
410
  ...AllUserScopeOptions.shape,
156
411
  ...WorkqueueOrDashboardOptions.shape
157
412
  });
158
413
  var ScopeOptionKey = AllScopeOptions.keyof();
159
- var ResolvedScopeOptionsPlaceEvent = z2.object({
414
+ var ResolvedScopeOptionsPlaceEvent = z6.object({
160
415
  event: scopeByEvent,
161
416
  placeOfEvent: UUID.nullish()
162
417
  }).describe(
@@ -164,15 +419,16 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
164
419
  );
165
420
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
166
421
  notifiedIn: UUID.nullish(),
167
- notifiedBy: z2.string().optional(),
422
+ notifiedBy: z6.string().optional(),
168
423
  declaredIn: UUID.nullish(),
169
- declaredBy: z2.string().optional()
424
+ declaredBy: z6.string().optional()
170
425
  }).describe(
171
426
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
172
427
  );
173
428
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
174
429
  registeredIn: UUID.nullish(),
175
- registeredBy: z2.string().optional()
430
+ registeredBy: z6.string().optional(),
431
+ flags: ContainsFlags.optional()
176
432
  }).describe(
177
433
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
178
434
  );
@@ -197,38 +453,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
197
453
  "record.unassign-others"
198
454
  ]);
199
455
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
200
- templates: z2.preprocess(
456
+ templates: z6.preprocess(
201
457
  (val) => val === void 0 ? void 0 : [val].flat(),
202
- z2.array(z2.string()).optional()
458
+ z6.array(z6.string()).optional()
203
459
  ).describe(
204
460
  "Template IDs for certified copies. Controls which certificate templates are returned to the client via the config service. Certificate printing is a client-side operation \u2014 this option is not validated when the printCertificate action is submitted."
205
461
  )
206
462
  });
207
- var RecordScopeV2 = z2.discriminatedUnion("type", [
208
- z2.object({
463
+ var RecordScopeV2 = z6.discriminatedUnion("type", [
464
+ z6.object({
209
465
  type: ScopesWithPlaceEventOptions,
210
466
  options: scopeOptionsPlaceEvent.optional()
211
467
  }),
212
- z2.object({
468
+ z6.object({
213
469
  type: ScopesWithDeclaredOptions,
214
470
  options: scopeOptionsDeclaredOrNotified.optional()
215
471
  }),
216
- z2.object({
472
+ z6.object({
217
473
  type: ScopesWithFullOptions,
218
474
  options: AllRecordScopeOptions.optional()
219
475
  }),
220
- z2.object({
221
- type: z2.literal("record.custom-action"),
476
+ z6.object({
477
+ type: z6.literal("record.custom-action"),
222
478
  options: CustomActionScopeOptions.optional()
223
479
  }),
224
- z2.object({
225
- type: z2.literal("record.print-certified-copies"),
480
+ z6.object({
481
+ type: z6.literal("record.print-certified-copies"),
226
482
  options: ScopeOptionsPrintCertifiedCopies.optional()
227
483
  })
228
484
  ]).describe(
229
485
  "Scopes used to check user's permission to perform actions on a record."
230
486
  );
231
- var SystemScopeType = z2.enum([
487
+ var SystemScopeType = z6.enum([
232
488
  "organisation.read-locations",
233
489
  "user.read",
234
490
  "user.create",
@@ -242,61 +498,61 @@ var UserScopeType = SystemScopeType.extract([
242
498
  "user.search"
243
499
  ]);
244
500
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
245
- var UserScopeV2 = z2.discriminatedUnion("type", [
246
- z2.object({
501
+ var UserScopeV2 = z6.discriminatedUnion("type", [
502
+ z6.object({
247
503
  type: ScopesWithRoleOption,
248
504
  options: AllUserScopeOptions.optional()
249
505
  }),
250
- z2.object({
506
+ z6.object({
251
507
  type: UserScopeType.extract(["user.read", "user.search"]),
252
508
  options: AccessLevelOptions.optional()
253
509
  })
254
510
  ]);
255
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
256
- z2.object({
511
+ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
512
+ z6.object({
257
513
  type: ScopesWithPlaceEventOptions,
258
514
  options: ResolvedScopeOptionsPlaceEvent.optional()
259
515
  }),
260
- z2.object({
516
+ z6.object({
261
517
  type: ScopesWithDeclaredOptions,
262
518
  options: ResolvedScopeOptionsDeclared.optional()
263
519
  }),
264
- z2.object({
520
+ z6.object({
265
521
  type: ScopesWithFullOptions,
266
522
  options: ResolvedScopeOptionsFull.optional()
267
523
  }),
268
- z2.object({
269
- type: z2.literal("record.print-certified-copies"),
524
+ z6.object({
525
+ type: z6.literal("record.print-certified-copies"),
270
526
  options: ResolvedScopeOptionsFull.extend({
271
- templates: z2.array(z2.string()).optional()
527
+ templates: z6.array(z6.string()).optional()
272
528
  }).optional()
273
529
  })
274
530
  ]).describe("Resolved scope with location/user IDs instead of filters.");
275
- var Scope = z2.discriminatedUnion("type", [
276
- z2.object({ type: PlainScopeType }),
531
+ var Scope = z6.discriminatedUnion("type", [
532
+ z6.object({ type: PlainScopeType }),
277
533
  ...RecordScopeV2.options,
278
534
  ...UserScopeV2.options,
279
- z2.object({
280
- type: z2.literal("organisation.read-locations"),
535
+ z6.object({
536
+ type: z6.literal("organisation.read-locations"),
281
537
  options: AccessLevelOptions.optional()
282
538
  }),
283
- z2.object({
284
- type: z2.literal("workqueue"),
539
+ z6.object({
540
+ type: z6.literal("workqueue"),
285
541
  options: WorkqueueOrDashboardOptions
286
542
  }),
287
- z2.object({
288
- type: z2.literal("dashboard.view"),
543
+ z6.object({
544
+ type: z6.literal("dashboard.view"),
289
545
  options: WorkqueueOrDashboardOptions
290
546
  })
291
547
  ]);
292
- var ScopeType = z2.enum([
548
+ var ScopeType = z6.enum([
293
549
  ...SystemScopeType.options,
294
550
  ...RecordScopeTypeV2.options,
295
551
  ...PlainScopeType.options,
296
552
  "workqueue",
297
553
  "dashboard.view"
298
554
  ]);
299
- var EncodedScope = z2.string().brand("EncodedScope");
555
+ var EncodedScope = z6.string().brand("EncodedScope");
300
556
  var DEFAULT_SCOPE_OPTIONS = {
301
557
  placeOfEvent: JurisdictionFilter.enum.all,
302
558
  accessLevel: JurisdictionFilter.enum.all,
@@ -306,162 +562,51 @@ var DEFAULT_SCOPE_OPTIONS = {
306
562
  };
307
563
 
308
564
  // ../commons/src/authentication.ts
309
- var TokenUserType = z3.enum(["user", "system"]);
310
- var TokenWithBearer = z3.string().regex(/^Bearer\s/);
311
-
312
- // ../commons/src/events/ActionType.ts
313
- var z4 = __toESM(require("zod/v4"));
314
- var ActionType = {
315
- // Pre-declaration actions
316
- DELETE: "DELETE",
317
- CREATE: "CREATE",
318
- NOTIFY: "NOTIFY",
319
- // Declaration actions
320
- DECLARE: "DECLARE",
321
- REGISTER: "REGISTER",
322
- EDIT: "EDIT",
323
- // Declaration system actions. Non-configurable.
324
- DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
325
- REJECT: "REJECT",
326
- // REJECT_DECLARATION
327
- MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
328
- MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
329
- ARCHIVE: "ARCHIVE",
330
- UNARCHIVE: "UNARCHIVE",
331
- // Record actions
332
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
333
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
334
- REJECT_CORRECTION: "REJECT_CORRECTION",
335
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
336
- // General actions
337
- READ: "READ",
338
- ASSIGN: "ASSIGN",
339
- UNASSIGN: "UNASSIGN",
340
- // Custom action
341
- CUSTOM: "CUSTOM"
342
- };
343
- var ConfirmableActions = [
344
- ActionType.NOTIFY,
345
- ActionType.DECLARE,
346
- ActionType.EDIT,
347
- ActionType.REGISTER,
348
- ActionType.REJECT,
349
- ActionType.ARCHIVE,
350
- ActionType.UNARCHIVE,
351
- ActionType.PRINT_CERTIFICATE,
352
- ActionType.REQUEST_CORRECTION,
353
- ActionType.APPROVE_CORRECTION,
354
- ActionType.REJECT_CORRECTION,
355
- ActionType.CUSTOM
356
- ];
357
- var ActionTypes = z4.enum([
358
- "DELETE",
359
- "CREATE",
360
- "NOTIFY",
361
- "DECLARE",
362
- "EDIT",
363
- "REGISTER",
364
- "DUPLICATE_DETECTED",
365
- "REJECT",
366
- "MARK_AS_DUPLICATE",
367
- "MARK_AS_NOT_DUPLICATE",
368
- "ARCHIVE",
369
- "UNARCHIVE",
370
- "PRINT_CERTIFICATE",
371
- "REQUEST_CORRECTION",
372
- "REJECT_CORRECTION",
373
- "APPROVE_CORRECTION",
374
- "READ",
375
- "ASSIGN",
376
- "UNASSIGN",
377
- "CUSTOM"
378
- ]);
379
- var ClientSpecificAction = {
380
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
381
- };
382
- var declarationActionValues = [
383
- ActionTypes.enum.DECLARE,
384
- ActionTypes.enum.EDIT,
385
- ActionTypes.enum.REGISTER,
386
- ActionTypes.enum.NOTIFY,
387
- ActionTypes.enum.DUPLICATE_DETECTED
388
- ];
389
- var DeclarationActions = ActionTypes.extract(declarationActionValues);
390
- var declarationUpdateActionValues = [
391
- ...declarationActionValues,
392
- ActionTypes.enum.REQUEST_CORRECTION
393
- ];
394
- var DeclarationUpdateActions = ActionTypes.extract(
395
- declarationUpdateActionValues
396
- );
397
- var annotationActions = ActionTypes.exclude(declarationActionValues);
398
- var writeActions = ActionTypes.exclude([
399
- ActionType.CREATE,
400
- ActionType.READ,
401
- ActionType.ASSIGN,
402
- ActionType.UNASSIGN
403
- ]);
404
- var WorkqueueActionType = ActionTypes.extract([
405
- ActionType.READ,
406
- ActionType.DELETE,
407
- ActionType.DECLARE,
408
- ActionType.REGISTER,
409
- ActionType.EDIT,
410
- ActionType.REJECT,
411
- ActionType.MARK_AS_DUPLICATE,
412
- ActionType.ARCHIVE,
413
- ActionType.UNARCHIVE,
414
- ActionType.PRINT_CERTIFICATE,
415
- ActionType.REQUEST_CORRECTION
416
- ]);
417
- var META_ACTIONS = [
418
- ActionType.ASSIGN,
419
- ActionType.UNASSIGN,
420
- ActionType.READ
421
- ];
565
+ var TokenUserType = z7.enum(["user", "system"]);
566
+ var TokenWithBearer = z7.string().regex(/^Bearer\s/);
422
567
 
423
568
  // ../commons/src/events/AuditLog.ts
424
- var AuditLogEntryBase = z5.object({
425
- id: z5.string(),
426
- clientId: z5.string(),
569
+ var AuditLogEntryBase = z8.object({
570
+ id: z8.string(),
571
+ clientId: z8.string(),
427
572
  clientType: TokenUserType,
428
- createdAt: z5.string()
573
+ createdAt: z8.string()
429
574
  });
430
575
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
431
- operation: z5.literal("event.create"),
432
- requestData: z5.object({
433
- transactionId: z5.string(),
434
- type: z5.string(),
435
- createdAtLocation: z5.string().nullable()
576
+ operation: z8.literal("event.create"),
577
+ requestData: z8.object({
578
+ transactionId: z8.string(),
579
+ type: z8.string(),
580
+ createdAtLocation: z8.string().nullable()
436
581
  }),
437
- responseSummary: z5.object({
438
- eventId: z5.string(),
439
- trackingId: z5.string()
582
+ responseSummary: z8.object({
583
+ eventId: z8.string(),
584
+ trackingId: z8.string()
440
585
  })
441
586
  });
442
587
  var EventGetEntrySchema = AuditLogEntryBase.extend({
443
- operation: z5.literal("event.get"),
444
- requestData: z5.object({ eventId: z5.string() }),
445
- responseSummary: z5.object({
446
- eventType: z5.string(),
447
- trackingId: z5.string()
588
+ operation: z8.literal("event.get"),
589
+ requestData: z8.object({ eventId: z8.string() }),
590
+ responseSummary: z8.object({
591
+ eventType: z8.string(),
592
+ trackingId: z8.string()
448
593
  })
449
594
  });
450
595
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
451
- operation: z5.literal("event.search"),
452
- clientType: z5.literal("system"),
453
- requestData: z5.object({
454
- query: z5.record(z5.string(), z5.unknown()).nullable(),
455
- limit: z5.number().nullable(),
456
- offset: z5.number().nullable()
596
+ operation: z8.literal("event.search"),
597
+ clientType: z8.literal("system"),
598
+ requestData: z8.object({
599
+ query: z8.record(z8.string(), z8.unknown()).nullable(),
600
+ limit: z8.number().nullable(),
601
+ offset: z8.number().nullable()
457
602
  }),
458
- responseSummary: z5.object({
459
- total: z5.number(),
460
- eventIds: z5.array(z5.string())
603
+ responseSummary: z8.object({
604
+ total: z8.number(),
605
+ eventIds: z8.array(z8.string())
461
606
  })
462
607
  });
463
608
  var EventActionEntrySchema = AuditLogEntryBase.extend({
464
- operation: z5.enum([
609
+ operation: z8.enum([
465
610
  "event.actions.notify.request",
466
611
  "event.actions.declare.request",
467
612
  "event.actions.register.request",
@@ -481,83 +626,159 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
481
626
  "event.actions.mark_as_duplicate.request",
482
627
  "event.actions.mark_as_not_duplicate.request"
483
628
  ]),
484
- requestData: z5.object({
485
- eventId: z5.string(),
486
- actionType: z5.string(),
487
- eventType: z5.string(),
488
- trackingId: z5.string(),
489
- transactionId: z5.string()
629
+ requestData: z8.object({
630
+ eventId: z8.string(),
631
+ actionType: z8.string(),
632
+ eventType: z8.string(),
633
+ trackingId: z8.string(),
634
+ transactionId: z8.string()
490
635
  })
491
636
  });
492
637
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
493
- operation: z5.literal("event.actions.custom.request"),
494
- requestData: z5.object({
495
- eventId: z5.string(),
496
- actionType: z5.literal(ActionType.CUSTOM),
497
- customAction: z5.string(),
498
- eventType: z5.string(),
499
- trackingId: z5.string(),
500
- transactionId: z5.string()
638
+ operation: z8.literal("event.actions.custom.request"),
639
+ requestData: z8.object({
640
+ eventId: z8.string(),
641
+ actionType: z8.literal(ActionType.CUSTOM),
642
+ customAction: z8.string(),
643
+ eventType: z8.string(),
644
+ trackingId: z8.string(),
645
+ transactionId: z8.string()
501
646
  })
502
647
  });
503
648
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
504
- operation: z5.literal("integrations.create"),
505
- requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
506
- responseSummary: z5.object({ clientId: z5.string() })
649
+ operation: z8.literal("integrations.create"),
650
+ requestData: z8.object({ name: z8.string(), scopes: z8.array(z8.string()) }),
651
+ responseSummary: z8.object({ clientId: z8.string() })
507
652
  });
508
653
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
509
- operation: z5.literal("integrations.refreshToken"),
510
- requestData: z5.object({ clientId: z5.string() }),
511
- responseSummary: z5.object({ clientId: z5.string() })
654
+ operation: z8.literal("integrations.refreshToken"),
655
+ requestData: z8.object({ clientId: z8.string() }),
656
+ responseSummary: z8.object({ clientId: z8.string() })
512
657
  });
513
658
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
514
- operation: z5.literal("integrations.deactivate"),
515
- requestData: z5.object({ id: z5.string() }),
516
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
659
+ operation: z8.literal("integrations.deactivate"),
660
+ requestData: z8.object({ id: z8.string() }),
661
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
517
662
  });
518
663
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
519
- operation: z5.literal("integrations.activate"),
520
- requestData: z5.object({ id: z5.string() }),
521
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
664
+ operation: z8.literal("integrations.activate"),
665
+ requestData: z8.object({ id: z8.string() }),
666
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
522
667
  });
523
668
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
524
- operation: z5.literal("integrations.delete"),
525
- requestData: z5.object({ id: z5.string() }),
526
- responseSummary: z5.object({ id: z5.string(), name: z5.string() })
669
+ operation: z8.literal("integrations.delete"),
670
+ requestData: z8.object({ id: z8.string() }),
671
+ responseSummary: z8.object({ id: z8.string(), name: z8.string() })
527
672
  });
528
673
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
529
- operation: z5.literal("integrations.refreshSecret"),
530
- requestData: z5.object({ id: z5.string() }),
531
- responseSummary: z5.object({ clientId: z5.string() })
674
+ operation: z8.literal("integrations.refreshSecret"),
675
+ requestData: z8.object({ id: z8.string() }),
676
+ responseSummary: z8.object({ clientId: z8.string() })
677
+ });
678
+ var createdVersionFields = {
679
+ id: z8.string(),
680
+ versionId: z8.string(),
681
+ name: z8.string(),
682
+ externalId: z8.string().nullish(),
683
+ effectiveFrom: z8.string(),
684
+ status: z8.string()
685
+ };
686
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
687
+ operation: z8.literal("locations.create"),
688
+ requestData: z8.object({
689
+ ...createdVersionFields,
690
+ administrativeAreaId: z8.string().nullish(),
691
+ locationType: z8.string().nullish()
692
+ })
693
+ });
694
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
695
+ operation: z8.literal("administrativeAreas.create"),
696
+ requestData: z8.object({
697
+ ...createdVersionFields,
698
+ parentId: z8.string().nullish()
699
+ })
700
+ });
701
+ var ChangedStringField = z8.object({ from: z8.string(), to: z8.string() });
702
+ var ChangedNullableStringField = z8.object({
703
+ from: z8.string().nullable(),
704
+ to: z8.string().nullable()
705
+ });
706
+ var updatedVersionRequestData = z8.object({
707
+ id: z8.string(),
708
+ versionId: z8.string(),
709
+ name: z8.string(),
710
+ externalId: z8.string().nullish(),
711
+ status: z8.string(),
712
+ effectiveFrom: z8.string(),
713
+ lastVersionId: z8.string()
714
+ });
715
+ var updatedVersionResponseSummary = z8.object({
716
+ previousVersionId: z8.string(),
717
+ versionId: z8.string(),
718
+ changed: z8.object({
719
+ name: ChangedStringField.optional(),
720
+ externalId: ChangedNullableStringField.optional(),
721
+ status: ChangedStringField.optional()
722
+ })
723
+ });
724
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
725
+ operation: z8.literal("locations.update"),
726
+ requestData: updatedVersionRequestData,
727
+ responseSummary: updatedVersionResponseSummary
728
+ });
729
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
730
+ operation: z8.literal("administrativeAreas.update"),
731
+ requestData: updatedVersionRequestData,
732
+ responseSummary: updatedVersionResponseSummary
733
+ });
734
+ var withdrawVersionRequestData = z8.object({
735
+ id: z8.string(),
736
+ versionId: z8.string()
737
+ });
738
+ var withdrawVersionResponseSummary = z8.object({
739
+ effectiveFrom: z8.string(),
740
+ name: z8.string(),
741
+ externalId: z8.string().nullish(),
742
+ status: z8.string()
743
+ });
744
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
745
+ operation: z8.literal("locations.withdrawVersion"),
746
+ requestData: withdrawVersionRequestData,
747
+ responseSummary: withdrawVersionResponseSummary
748
+ });
749
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
750
+ operation: z8.literal("administrativeAreas.withdrawVersion"),
751
+ requestData: withdrawVersionRequestData,
752
+ responseSummary: withdrawVersionResponseSummary
532
753
  });
533
754
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
534
- operation: z5.literal("attachments.upload"),
535
- requestData: z5.object({
536
- transactionId: z5.string(),
537
- path: z5.string().nullable()
755
+ operation: z8.literal("attachments.upload"),
756
+ requestData: z8.object({
757
+ transactionId: z8.string(),
758
+ path: z8.string().nullable()
538
759
  }),
539
- responseSummary: z5.object({ fileUrl: z5.string() })
760
+ responseSummary: z8.object({ fileUrl: z8.string() })
540
761
  });
541
- var subjectOnly = z5.object({ subjectId: z5.string() });
542
- var subjectWithReason = z5.object({
543
- subjectId: z5.string(),
544
- reason: z5.string(),
545
- comment: z5.string().optional()
762
+ var subjectOnly = z8.object({ subjectId: z8.string() });
763
+ var subjectWithReason = z8.object({
764
+ subjectId: z8.string(),
765
+ reason: z8.string(),
766
+ comment: z8.string().optional()
546
767
  });
547
768
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
548
- operation: z5.literal("user.create_user"),
549
- requestData: z5.object({
550
- subjectId: z5.string(),
551
- role: z5.string(),
552
- primaryOfficeId: z5.string()
769
+ operation: z8.literal("user.create_user"),
770
+ requestData: z8.object({
771
+ subjectId: z8.string(),
772
+ role: z8.string(),
773
+ primaryOfficeId: z8.string()
553
774
  })
554
775
  });
555
776
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
556
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
777
+ operation: z8.enum(["user.deactivate", "user.reactivate"]),
557
778
  requestData: subjectWithReason
558
779
  });
559
780
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
560
- operation: z5.enum([
781
+ operation: z8.enum([
561
782
  "user.edit_user",
562
783
  "user.logged_in",
563
784
  "user.logged_out",
@@ -571,14 +792,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
571
792
  requestData: subjectOnly
572
793
  });
573
794
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
574
- operation: z5.literal("user.email_address_changed"),
795
+ operation: z8.literal("user.email_address_changed"),
575
796
  requestData: subjectOnly,
576
- responseSummary: z5.object({ email: z5.string() })
797
+ responseSummary: z8.object({ email: z8.string() })
577
798
  });
578
799
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
579
- operation: z5.literal("user.phone_number_changed"),
800
+ operation: z8.literal("user.phone_number_changed"),
580
801
  requestData: subjectOnly,
581
- responseSummary: z5.object({ phoneNumber: z5.string() })
802
+ responseSummary: z8.object({ phoneNumber: z8.string() })
582
803
  });
583
804
  var userBaseOmit = {
584
805
  id: true,
@@ -586,14 +807,14 @@ var userBaseOmit = {
586
807
  clientType: true,
587
808
  createdAt: true
588
809
  };
589
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
810
+ var UserAuditRecordInput = z8.discriminatedUnion("operation", [
590
811
  UserCreateEntrySchema.omit(userBaseOmit),
591
812
  UserReasonEntrySchema.omit(userBaseOmit),
592
813
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
593
814
  UserEmailChangedEntrySchema.omit(userBaseOmit),
594
815
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
595
816
  ]);
596
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
817
+ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
597
818
  EventCreateEntrySchema,
598
819
  EventGetEntrySchema,
599
820
  EventSearchEntrySchema,
@@ -605,6 +826,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
605
826
  IntegrationActivateEntrySchema,
606
827
  IntegrationDeleteEntrySchema,
607
828
  IntegrationRefreshSecretEntrySchema,
829
+ LocationCreateEntrySchema,
830
+ LocationUpdateEntrySchema,
831
+ AdministrativeAreaUpdateEntrySchema,
832
+ LocationWithdrawEntrySchema,
833
+ AdministrativeAreaWithdrawEntrySchema,
834
+ AdministrativeAreaCreateEntrySchema,
608
835
  AttachmentUploadEntrySchema,
609
836
  UserCreateEntrySchema,
610
837
  UserReasonEntrySchema,
@@ -620,76 +847,11 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
620
847
  // ../commons/src/events/ActionConfig.ts
621
848
  var z24 = __toESM(require("zod/v4"));
622
849
 
623
- // ../commons/src/events/TranslationConfig.ts
624
- var z6 = __toESM(require("zod/v4"));
625
- var TranslationConfig = z6.object({
626
- id: z6.string().describe(
627
- "The identifier of the translation referred in translation CSV files"
628
- ),
629
- defaultMessage: z6.string().describe("Default translation message"),
630
- description: z6.string().describe(
631
- "Describe the translation for a translator to be able to identify it."
632
- )
633
- }).meta({
634
- description: "Translation configuration",
635
- id: "TranslationConfig"
636
- });
637
-
638
850
  // ../commons/src/events/FieldConfig.ts
639
851
  var import_v43 = __toESM(require("zod/v4"));
640
852
 
641
- // ../commons/src/events/Conditional.ts
642
- var z7 = __toESM(require("zod/v4"));
643
- var Conditional = z7.any().describe("JSONSchema").meta({
644
- description: "JSON schema conditional configuration",
645
- id: "Conditional"
646
- });
647
- var ConditionalType = {
648
- SHOW: "SHOW",
649
- ENABLE: "ENABLE",
650
- DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
651
- };
652
- var ShowConditional = z7.object({
653
- type: z7.literal(ConditionalType.SHOW),
654
- conditional: Conditional
655
- }).describe(
656
- "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
657
- );
658
- var EnableConditional = z7.object({
659
- type: z7.literal(ConditionalType.ENABLE),
660
- conditional: Conditional
661
- }).describe(
662
- "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
663
- );
664
- var ActionConditional = z7.discriminatedUnion("type", [
665
- // Action can be shown / hidden
666
- ShowConditional,
667
- // Action can be shown to the user in the list but as disabled
668
- EnableConditional
669
- ]).meta({
670
- id: "ActionConditional",
671
- description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
672
- });
673
- var DisplayOnReviewConditional = z7.object({
674
- type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
675
- conditional: Conditional
676
- }).describe(
677
- "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
678
- );
679
- var FieldConditional = z7.discriminatedUnion("type", [
680
- // Field input can be shown / hidden
681
- ShowConditional,
682
- // Field input can be shown to the user but as disabled
683
- EnableConditional,
684
- // Field output can be shown / hidden on the review page
685
- DisplayOnReviewConditional
686
- ]).meta({
687
- id: "FieldConditional",
688
- description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
689
- });
690
-
691
853
  // ../commons/src/events/FieldType.ts
692
- var z8 = __toESM(require("zod/v4"));
854
+ var z9 = __toESM(require("zod/v4"));
693
855
  var FieldType = {
694
856
  NAME: "NAME",
695
857
  PHONE: "PHONE",
@@ -753,7 +915,7 @@ var FieldType = {
753
915
  */
754
916
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
755
917
  };
756
- var FileFieldType = z8.enum([
918
+ var FileFieldType = z9.enum([
757
919
  FieldType.FILE,
758
920
  FieldType.FILE_WITH_OPTIONS,
759
921
  FieldType.SIGNATURE
@@ -789,160 +951,160 @@ var HiddenFieldTypes = [
789
951
  ];
790
952
 
791
953
  // ../commons/src/events/FieldValue.ts
792
- var z12 = __toESM(require("zod/v4"));
954
+ var z13 = __toESM(require("zod/v4"));
793
955
 
794
956
  // ../commons/src/documents.ts
795
- var z9 = __toESM(require("zod/v4"));
796
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
957
+ var z10 = __toESM(require("zod/v4"));
958
+ var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
797
959
  "A full url with protocol, host, bucket name, starting from the root of the S3 server, https://minio.opencrvs.com/bucket-name/document-id.jpg"
798
960
  );
799
- var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
961
+ var FullDocumentPath = z10.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
800
962
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
801
963
  );
802
- var DocumentPath = z9.string().brand("DocumentPath").describe(
964
+ var DocumentPath = z10.string().brand("DocumentPath").describe(
803
965
  "A relative path within the S3 bucket, never starting with /. e.g. document-id.jpg or directory/document-id.jpg. The document service constructs the full /bucket/path internally."
804
966
  );
805
967
 
806
968
  // ../commons/src/events/CompositeFieldValue.ts
807
- var z10 = __toESM(require("zod/v4"));
969
+ var z11 = __toESM(require("zod/v4"));
808
970
  var AddressType = {
809
971
  DOMESTIC: "DOMESTIC",
810
972
  INTERNATIONAL: "INTERNATIONAL"
811
973
  };
812
- var FileFieldValue = z10.object({
974
+ var FileFieldValue = z11.object({
813
975
  path: DocumentPath,
814
- originalFilename: z10.string(),
815
- type: z10.string()
816
- });
817
- var NameFieldValue = z10.object({
818
- firstname: z10.string(),
819
- surname: z10.string(),
820
- middlename: z10.string().optional()
821
- });
822
- var NameFieldUpdateValue = z10.object({
823
- firstname: z10.string().nullish(),
824
- surname: z10.string().nullish(),
825
- middlename: z10.string().nullish()
826
- }).or(z10.null()).or(z10.undefined());
827
- var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
828
- var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
829
- var BaseAddressFieldValue = z10.object({
830
- country: z10.string(),
976
+ originalFilename: z11.string(),
977
+ type: z11.string()
978
+ });
979
+ var NameFieldValue = z11.object({
980
+ firstname: z11.string(),
981
+ surname: z11.string(),
982
+ middlename: z11.string().optional()
983
+ });
984
+ var NameFieldUpdateValue = z11.object({
985
+ firstname: z11.string().nullish(),
986
+ surname: z11.string().nullish(),
987
+ middlename: z11.string().nullish()
988
+ }).or(z11.null()).or(z11.undefined());
989
+ var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
990
+ var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
991
+ var BaseAddressFieldValue = z11.object({
992
+ country: z11.string(),
831
993
  streetLevelDetails: StreetLevelDetailsValue
832
994
  });
833
- var BaseAddressFieldUpdateValue = z10.object({
834
- country: z10.string().nullish(),
995
+ var BaseAddressFieldUpdateValue = z11.object({
996
+ country: z11.string().nullish(),
835
997
  streetLevelDetails: StreetLevelDetailsUpdateValue
836
998
  });
837
999
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
838
- addressType: z10.literal(AddressType.DOMESTIC),
839
- administrativeArea: z10.string().uuid()
1000
+ addressType: z11.literal(AddressType.DOMESTIC),
1001
+ administrativeArea: z11.string().uuid()
840
1002
  });
841
1003
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
842
- addressType: z10.literal(AddressType.INTERNATIONAL)
1004
+ addressType: z11.literal(AddressType.INTERNATIONAL)
843
1005
  });
844
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
1006
+ var AddressFieldValue = z11.discriminatedUnion("addressType", [
845
1007
  DomesticAddressFieldValue,
846
1008
  InternationalAddressFieldValue
847
1009
  ]);
848
1010
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
849
- addressType: z10.literal(AddressType.DOMESTIC),
850
- administrativeArea: z10.string().uuid().nullish()
1011
+ addressType: z11.literal(AddressType.DOMESTIC),
1012
+ administrativeArea: z11.string().uuid().nullish()
851
1013
  /* Leaf level admin structure */
852
1014
  });
853
1015
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
854
1016
  {
855
- addressType: z10.literal(AddressType.INTERNATIONAL)
1017
+ addressType: z11.literal(AddressType.INTERNATIONAL)
856
1018
  }
857
1019
  );
858
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
1020
+ var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
859
1021
  DomesticAddressUpdateFieldValue,
860
1022
  InternationalAddressUpdateFieldValue
861
1023
  ]).nullish();
862
- var FileFieldValueWithOption = z10.object({
1024
+ var FileFieldValueWithOption = z11.object({
863
1025
  path: DocumentPath,
864
- originalFilename: z10.string(),
865
- type: z10.string(),
866
- option: z10.string()
867
- });
868
- var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
869
- var HttpFieldValue = z10.object({
870
- loading: z10.boolean(),
871
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
872
- data: z10.any()
873
- });
874
- var HttpFieldUpdateValue = z10.object({
875
- loading: z10.boolean().nullish(),
876
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
877
- data: z10.any().nullish()
878
- }).or(z10.null()).or(z10.undefined());
879
- var QueryParamReaderFieldValue = z10.object({
880
- data: z10.record(z10.string(), z10.string()),
881
- updatedAt: z10.iso.datetime()
1026
+ originalFilename: z11.string(),
1027
+ type: z11.string(),
1028
+ option: z11.string()
1029
+ });
1030
+ var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
1031
+ var HttpFieldValue = z11.object({
1032
+ loading: z11.boolean(),
1033
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1034
+ data: z11.any()
1035
+ });
1036
+ var HttpFieldUpdateValue = z11.object({
1037
+ loading: z11.boolean().nullish(),
1038
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1039
+ data: z11.any().nullish()
1040
+ }).or(z11.null()).or(z11.undefined());
1041
+ var QueryParamReaderFieldValue = z11.object({
1042
+ data: z11.record(z11.string(), z11.string()),
1043
+ updatedAt: z11.iso.datetime()
882
1044
  }).nullish();
883
- var QueryParamReaderFieldUpdateValue = z10.object({
884
- data: z10.record(z10.string(), z10.string())
1045
+ var QueryParamReaderFieldUpdateValue = z11.object({
1046
+ data: z11.record(z11.string(), z11.string())
885
1047
  });
886
- var ReadDataValue = z10.object({
887
- data: z10.any()
1048
+ var ReadDataValue = z11.object({
1049
+ data: z11.any()
888
1050
  });
889
1051
  var QrReaderFieldValue = ReadDataValue;
890
1052
  var IdReaderFieldValue = ReadDataValue;
891
- var NumberWithUnitFieldValue = z10.object({
892
- numericValue: z10.number(),
893
- unit: z10.string()
1053
+ var NumberWithUnitFieldValue = z11.object({
1054
+ numericValue: z11.number(),
1055
+ unit: z11.string()
894
1056
  });
895
- var NumberWithUnitFieldUpdateValue = z10.object({
896
- numericValue: z10.number().optional(),
897
- unit: z10.string().optional()
1057
+ var NumberWithUnitFieldUpdateValue = z11.object({
1058
+ numericValue: z11.number().optional(),
1059
+ unit: z11.string().optional()
898
1060
  });
899
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1061
+ var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
900
1062
 
901
1063
  // ../commons/src/events/PlainDate.ts
902
1064
  var import_zod = require("zod");
903
1065
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
904
1066
 
905
1067
  // ../commons/src/events/FieldValue.ts
906
- var TextValue = z12.string();
907
- var HiddenFieldValue = z12.string();
908
- var NonEmptyTextValue = z12.string().trim().min(1);
909
- var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
910
- var AgeValue = z12.object({
911
- age: z12.number(),
912
- asOfDateRef: z12.string()
1068
+ var TextValue = z13.string();
1069
+ var HiddenFieldValue = z13.string();
1070
+ var NonEmptyTextValue = z13.string().trim().min(1);
1071
+ var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
1072
+ var AgeValue = z13.object({
1073
+ age: z13.number(),
1074
+ asOfDateRef: z13.string()
913
1075
  });
914
1076
  var AgeUpdateValue = AgeValue.optional().nullable();
915
- var AutocompleteValue = z12.object({
916
- label: z12.string(),
917
- value: z12.string()
1077
+ var AutocompleteValue = z13.object({
1078
+ label: z13.string(),
1079
+ value: z13.string()
918
1080
  });
919
1081
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
920
- var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
921
- var DatetimeValue = z12.iso.datetime();
922
- var SelectDateRangeValue = z12.enum([
1082
+ var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1083
+ var DatetimeValue = z13.iso.datetime();
1084
+ var SelectDateRangeValue = z13.enum([
923
1085
  "last7Days",
924
1086
  "last30Days",
925
1087
  "last90Days",
926
1088
  "last365Days"
927
1089
  ]);
928
- var DateRangeFieldValue = z12.object({
1090
+ var DateRangeFieldValue = z13.object({
929
1091
  start: PlainDate,
930
1092
  end: PlainDate
931
1093
  }).or(PlainDate).describe(
932
1094
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
933
1095
  );
934
- var EmailValue = z12.email();
935
- var CheckboxFieldValue = z12.boolean();
936
- var NumberFieldValue = z12.number();
1096
+ var EmailValue = z13.email();
1097
+ var CheckboxFieldValue = z13.boolean();
1098
+ var NumberFieldValue = z13.number();
937
1099
  var SignatureFieldValue = FileFieldValue;
938
- var ButtonFieldValue = z12.number();
939
- var VerificationStatusValue = z12.enum([
1100
+ var ButtonFieldValue = z13.number();
1101
+ var VerificationStatusValue = z13.enum([
940
1102
  "verified",
941
1103
  "authenticated",
942
1104
  "failed",
943
1105
  "pending"
944
1106
  ]);
945
- var LeafFieldValues = z12.union([
1107
+ var LeafFieldValues = z13.union([
946
1108
  AddressFieldValue,
947
1109
  TextValue,
948
1110
  PlainDate,
@@ -968,11 +1130,11 @@ var LeafFieldValues = z12.union([
968
1130
  AutocompleteValue,
969
1131
  AutocompleteUpdateValue
970
1132
  ]);
971
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
972
- var DataFieldValue = z12.object({
973
- data: z12.record(z12.string(), LeafFieldValues)
1133
+ var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
1134
+ var DataFieldValue = z13.object({
1135
+ data: z13.record(z13.string(), LeafFieldValues)
974
1136
  }).nullish();
975
- var FieldValue = z12.union([
1137
+ var FieldValue = z13.union([
976
1138
  LeafFieldValues,
977
1139
  DataFieldValue,
978
1140
  FieldGroupValue
@@ -1006,7 +1168,7 @@ function safeUnion(schemas) {
1006
1168
  const sortedSchemas = [...schemas].sort(
1007
1169
  (a, b) => schemaPriority(a) - schemaPriority(b)
1008
1170
  );
1009
- return z12.any().superRefine((val, ctx) => {
1171
+ return z13.any().superRefine((val, ctx) => {
1010
1172
  for (const schema of sortedSchemas) {
1011
1173
  if (schema.safeParse(val).success) {
1012
1174
  return;
@@ -1045,9 +1207,9 @@ var FieldUpdateValue = safeUnion([
1045
1207
  ]);
1046
1208
 
1047
1209
  // ../commons/src/events/serializers/user/serializer.ts
1048
- var z13 = __toESM(require("zod/v4"));
1049
- var SerializedUserField = z13.object({
1050
- $userField: z13.enum([
1210
+ var z14 = __toESM(require("zod/v4"));
1211
+ var SerializedUserField = z14.object({
1212
+ $userField: z14.enum([
1051
1213
  "id",
1052
1214
  "name",
1053
1215
  "role",
@@ -1061,7 +1223,7 @@ var SerializedUserField = z13.object({
1061
1223
  "primaryOfficeId",
1062
1224
  "administrativeAreaId"
1063
1225
  ]),
1064
- $location: z13.string().optional()
1226
+ $location: z14.string().optional()
1065
1227
  });
1066
1228
  function userSerializer(userField) {
1067
1229
  return {
@@ -1087,27 +1249,22 @@ var import_v4 = require("zod/v4");
1087
1249
  var z16 = __toESM(require("zod/v4"));
1088
1250
 
1089
1251
  // ../commons/src/events/ActionDocument.ts
1090
- var z14 = __toESM(require("zod/v4"));
1091
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1252
+ var z15 = __toESM(require("zod/v4"));
1253
+ var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1092
1254
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1093
1255
  );
1094
- var EventState = z14.record(z14.string(), FieldValue).describe(
1256
+ var EventState = z15.record(z15.string(), FieldValue).describe(
1095
1257
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1096
1258
  );
1097
- var ActionStatus = {
1098
- Requested: "Requested",
1099
- Accepted: "Accepted",
1100
- Rejected: "Rejected"
1101
- };
1102
- var ActionBase = z14.object({
1259
+ var ActionBase = z15.object({
1103
1260
  id: UUID.describe("Unique identifier of the action."),
1104
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1261
+ transactionId: z15.string().describe("Unique identifier of the transaction."),
1105
1262
  createdByUserType: TokenUserType.describe(
1106
1263
  "Indicates whether the action was created by a human-user or by a system-user."
1107
1264
  ),
1108
- createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1109
- createdBy: z14.string().describe("Identifier of the user who created the action."),
1110
- createdByRole: z14.string().optional().describe("Role of the user who created the action."),
1265
+ createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1266
+ createdBy: z15.string().describe("Identifier of the user who created the action."),
1267
+ createdByRole: z15.string().optional().describe("Role of the user who created the action."),
1111
1268
  createdBySignature: DocumentPath.nullish().describe(
1112
1269
  "Reference to the signature of the user who created the action."
1113
1270
  ),
@@ -1119,7 +1276,7 @@ var ActionBase = z14.object({
1119
1276
  "Declaration data defined by the ActionConfig. Supports partial updates."
1120
1277
  ),
1121
1278
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1122
- status: z14.enum([
1279
+ status: z15.enum([
1123
1280
  ActionStatus.Requested,
1124
1281
  ActionStatus.Accepted,
1125
1282
  ActionStatus.Rejected
@@ -1131,138 +1288,143 @@ var ActionBase = z14.object({
1131
1288
  )
1132
1289
  });
1133
1290
  var AssignedAction = ActionBase.extend(
1134
- z14.object({
1135
- type: z14.literal(ActionType.ASSIGN),
1136
- assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
1291
+ z15.object({
1292
+ type: z15.literal(ActionType.ASSIGN),
1293
+ assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1137
1294
  // TODO move into 'content' property
1138
1295
  }).shape
1139
1296
  );
1140
1297
  var UnassignedAction = ActionBase.extend(
1141
- z14.object({
1142
- type: z14.literal(ActionType.UNASSIGN)
1298
+ z15.object({
1299
+ type: z15.literal(ActionType.UNASSIGN)
1143
1300
  }).shape
1144
1301
  );
1145
1302
  var RegisterAction = ActionBase.extend(
1146
- z14.object({
1147
- type: z14.literal(ActionType.REGISTER),
1148
- registrationNumber: z14.string().optional().describe(
1303
+ z15.object({
1304
+ type: z15.literal(ActionType.REGISTER),
1305
+ registrationNumber: z15.string().optional().describe(
1149
1306
  "Registration number of the event. Always present for accepted registrations."
1150
1307
  )
1151
1308
  // TODO move into 'content' property
1152
1309
  }).shape
1153
1310
  );
1154
1311
  var DeclareAction = ActionBase.extend(
1155
- z14.object({
1156
- type: z14.literal(ActionType.DECLARE)
1312
+ z15.object({
1313
+ type: z15.literal(ActionType.DECLARE)
1157
1314
  }).shape
1158
1315
  );
1159
- var ReasonContent = z14.object({
1160
- reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1316
+ var ReasonContent = z15.object({
1317
+ reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
1161
1318
  "Message describing the reason for rejecting or archiving the event."
1162
1319
  )
1163
1320
  });
1164
1321
  var RejectAction = ActionBase.extend(
1165
- z14.object({
1166
- type: z14.literal(ActionType.REJECT),
1322
+ z15.object({
1323
+ type: z15.literal(ActionType.REJECT),
1167
1324
  content: ReasonContent
1168
1325
  }).shape
1169
1326
  );
1170
- var PotentialDuplicate = z14.object({
1327
+ var PotentialDuplicate = z15.object({
1171
1328
  id: UUID,
1172
- trackingId: z14.string()
1329
+ trackingId: z15.string()
1173
1330
  });
1174
1331
  var DuplicateDetectedAction = ActionBase.extend(
1175
- z14.object({
1176
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1177
- content: z14.object({
1178
- duplicates: z14.array(PotentialDuplicate)
1332
+ z15.object({
1333
+ type: z15.literal(ActionType.DUPLICATE_DETECTED),
1334
+ content: z15.object({
1335
+ duplicates: z15.array(PotentialDuplicate)
1179
1336
  })
1180
1337
  }).shape
1181
1338
  );
1182
1339
  var MarkNotDuplicateAction = ActionBase.extend(
1183
- z14.object({
1184
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1340
+ z15.object({
1341
+ type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1185
1342
  }).shape
1186
1343
  );
1187
1344
  var MarkAsDuplicateAction = ActionBase.extend(
1188
- z14.object({
1189
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1190
- content: z14.object({
1345
+ z15.object({
1346
+ type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1347
+ content: z15.object({
1191
1348
  duplicateOf: UUID
1192
1349
  }).optional()
1193
1350
  }).shape
1194
1351
  );
1195
1352
  var ArchiveAction = ActionBase.extend(
1196
- z14.object({
1197
- type: z14.literal(ActionType.ARCHIVE),
1198
- content: ReasonContent
1353
+ z15.object({
1354
+ type: z15.literal(ActionType.ARCHIVE),
1355
+ /**
1356
+ * Archiving does not collect a reason on its own. Only the
1357
+ * "mark as duplicate" flow archives with a reason attached.
1358
+ */
1359
+ content: ReasonContent.optional()
1199
1360
  }).shape
1200
1361
  );
1201
1362
  var UnarchiveAction = ActionBase.extend(
1202
- z14.object({
1203
- type: z14.literal(ActionType.UNARCHIVE)
1363
+ z15.object({
1364
+ type: z15.literal(ActionType.UNARCHIVE)
1204
1365
  }).shape
1205
1366
  );
1206
1367
  var CreatedAction = ActionBase.extend(
1207
- z14.object({
1208
- type: z14.literal(ActionType.CREATE)
1368
+ z15.object({
1369
+ type: z15.literal(ActionType.CREATE)
1209
1370
  }).shape
1210
1371
  );
1211
1372
  var NotifiedAction = ActionBase.extend(
1212
- z14.object({
1213
- type: z14.literal(ActionType.NOTIFY)
1373
+ z15.object({
1374
+ type: z15.literal(ActionType.NOTIFY)
1214
1375
  }).shape
1215
1376
  );
1216
1377
  var EditAction = ActionBase.extend(
1217
- z14.object({
1218
- type: z14.literal(ActionType.EDIT),
1219
- content: z14.object({
1220
- comment: z14.string().describe("Comment for the edit action.").optional()
1221
- })
1378
+ z15.object({
1379
+ type: z15.literal(ActionType.EDIT),
1380
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1381
+ content: z15.object({
1382
+ comment: z15.string().describe("Comment for the edit action.").optional()
1383
+ }).optional()
1222
1384
  }).shape
1223
1385
  );
1224
- var PrintContent = z14.object({
1225
- templateId: z14.string().optional()
1386
+ var PrintContent = z15.object({
1387
+ templateId: z15.string().optional()
1226
1388
  });
1227
1389
  var PrintCertificateAction = ActionBase.extend(
1228
- z14.object({
1229
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1390
+ z15.object({
1391
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1230
1392
  content: PrintContent.optional().nullable()
1231
1393
  }).shape
1232
1394
  );
1233
1395
  var RequestedCorrectionAction = ActionBase.extend(
1234
- z14.object({
1235
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1396
+ z15.object({
1397
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1236
1398
  }).shape
1237
1399
  );
1238
1400
  var ApprovedCorrectionAction = ActionBase.extend(
1239
- z14.object({
1240
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1241
- requestId: z14.string(),
1401
+ z15.object({
1402
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1403
+ requestId: z15.string(),
1242
1404
  // TODO move into 'content' property
1243
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1405
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1244
1406
  }).shape
1245
1407
  );
1246
1408
  var RejectedCorrectionAction = ActionBase.extend(
1247
- z14.object({
1248
- type: z14.literal(ActionType.REJECT_CORRECTION),
1249
- requestId: z14.string(),
1409
+ z15.object({
1410
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1411
+ requestId: z15.string(),
1250
1412
  // TODO move into 'content' property
1251
1413
  content: ReasonContent
1252
1414
  }).shape
1253
1415
  );
1254
1416
  var ReadAction = ActionBase.extend(
1255
- z14.object({
1256
- type: z14.literal(ActionType.READ)
1417
+ z15.object({
1418
+ type: z15.literal(ActionType.READ)
1257
1419
  }).shape
1258
1420
  );
1259
1421
  var CustomAction = ActionBase.merge(
1260
- z14.object({
1261
- type: z14.literal(ActionType.CUSTOM),
1262
- customActionType: z14.string()
1422
+ z15.object({
1423
+ type: z15.literal(ActionType.CUSTOM),
1424
+ customActionType: z15.string()
1263
1425
  })
1264
1426
  );
1265
- var ActionDocument = z14.discriminatedUnion("type", [
1427
+ var ActionDocument = z15.discriminatedUnion("type", [
1266
1428
  CreatedAction.meta({ id: "CreatedAction" }),
1267
1429
  RejectAction.meta({ id: "RejectAction" }),
1268
1430
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1289,64 +1451,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1289
1451
  declaration: true,
1290
1452
  annotation: true
1291
1453
  }).extend(
1292
- z14.object({
1293
- type: z14.enum(ConfirmableActions),
1294
- status: z14.literal(ActionStatus.Rejected)
1454
+ z15.object({
1455
+ type: z15.enum(ConfirmableActions),
1456
+ status: z15.literal(ActionStatus.Rejected)
1295
1457
  }).shape
1296
1458
  );
1297
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1298
-
1299
- // ../commons/src/events/Flag.ts
1300
- var z15 = __toESM(require("zod/v4"));
1301
- var InherentFlags = {
1302
- INCOMPLETE: "incomplete",
1303
- REJECTED: "rejected",
1304
- CORRECTION_REQUESTED: "correction-requested",
1305
- POTENTIAL_DUPLICATE: "potential-duplicate",
1306
- /**
1307
- * This flag is set by the Edit-action and removed after the declaration or registration.
1308
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1309
- *
1310
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1311
- */
1312
- EDIT_IN_PROGRESS: "edit-in-progress"
1313
- };
1314
- var ActionFlag = z15.string().regex(
1315
- new RegExp(
1316
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1317
- ActionStatus
1318
- ).join("|").toLowerCase()})$`
1319
- ),
1320
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1321
- );
1322
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1323
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1324
- InherentFlags
1325
- ).join(", ")}`
1326
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1327
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1328
- }).describe("Custom flag identifier defined by the country config.");
1329
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1330
- var FlagConfig = z15.object({
1331
- id: CustomFlag,
1332
- requiresAction: z15.boolean().describe(
1333
- "Indicates if this flag expects an action to be performed to be cleared."
1334
- ),
1335
- label: TranslationConfig.describe("Human readable label of the flag.")
1336
- }).meta({
1337
- id: "FlagConfig",
1338
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1339
- });
1340
- var ActionFlagConfig = z15.object({
1341
- id: Flag,
1342
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1343
- conditional: Conditional.optional().describe(
1344
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1345
- )
1346
- }).meta({
1347
- id: "ActionFlagConfig",
1348
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1349
- });
1459
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1350
1460
 
1351
1461
  // ../commons/src/events/EventMetadata.ts
1352
1462
  var EventStatus = z16.enum([
@@ -1504,13 +1614,6 @@ var Range = import_v4.z.object({
1504
1614
  }).meta({
1505
1615
  id: "Range"
1506
1616
  });
1507
- var ContainsFlags = import_v4.z.object({
1508
- anyOf: import_v4.z.array(Flag).optional(),
1509
- noneOf: import_v4.z.array(Flag).optional(),
1510
- allOf: import_v4.z.array(Flag).optional()
1511
- }).meta({
1512
- id: "ContainsFlags"
1513
- });
1514
1617
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1515
1618
  id: "Within"
1516
1619
  });
@@ -1737,8 +1840,8 @@ var BaseField = import_v43.default.object({
1737
1840
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1738
1841
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1739
1842
  ),
1740
- secured: import_v43.default.boolean().default(false).optional().describe(
1741
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1843
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1844
+ "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."
1742
1845
  ),
1743
1846
  placeholder: TranslationConfig.optional(),
1744
1847
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2136,7 +2239,16 @@ var AdministrativeAreaField = BaseField.extend({
2136
2239
  configuration: import_v43.default.object({
2137
2240
  partOf: FieldReference.optional().describe("Parent location"),
2138
2241
  type: AdministrativeAreas,
2139
- allowedLocations: AllowedLocations
2242
+ allowedLocations: AllowedLocations,
2243
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2244
+ "List every historical name a location has had as a separate, selectable option."
2245
+ ),
2246
+ activeOnly: import_v43.default.boolean().optional().describe(
2247
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2248
+ ),
2249
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2250
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2251
+ )
2140
2252
  }).describe("Administrative area options")
2141
2253
  }).meta({
2142
2254
  description: "Administrative area input field",
@@ -2147,7 +2259,16 @@ var LocationInput = BaseField.extend({
2147
2259
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2148
2260
  configuration: import_v43.default.object({
2149
2261
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2150
- allowedLocations: AllowedLocations
2262
+ allowedLocations: AllowedLocations,
2263
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2264
+ "List every historical name a location has had as a separate, selectable option."
2265
+ ),
2266
+ activeOnly: import_v43.default.boolean().optional().describe(
2267
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2268
+ ),
2269
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2270
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2271
+ )
2151
2272
  }).optional()
2152
2273
  }).meta({
2153
2274
  description: "A field for selecting a location",
@@ -2173,12 +2294,22 @@ var FileUploadWithOptions = BaseField.extend({
2173
2294
  var Facility = BaseField.extend({
2174
2295
  type: import_v43.default.literal(FieldType.FACILITY),
2175
2296
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2176
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2297
+ configuration: import_v43.default.object({
2298
+ allowedLocations: AllowedLocations,
2299
+ listHistoricalNames: import_v43.default.boolean().optional(),
2300
+ activeOnly: import_v43.default.boolean().optional(),
2301
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2302
+ }).optional()
2177
2303
  }).describe("Input field for a facility");
2178
2304
  var Office = BaseField.extend({
2179
2305
  type: import_v43.default.literal(FieldType.OFFICE),
2180
2306
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2181
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2307
+ configuration: import_v43.default.object({
2308
+ allowedLocations: AllowedLocations,
2309
+ listHistoricalNames: import_v43.default.boolean().optional(),
2310
+ activeOnly: import_v43.default.boolean().optional(),
2311
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2312
+ }).optional()
2182
2313
  }).describe("Input field for an office");
2183
2314
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2184
2315
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2211,7 +2342,16 @@ var Address = BaseField.extend({
2211
2342
  parent: FieldReference.optional()
2212
2343
  })
2213
2344
  ).optional(),
2214
- allowedLocations: AllowedLocations
2345
+ allowedLocations: AllowedLocations,
2346
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2347
+ "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2348
+ ),
2349
+ activeOnly: import_v43.default.boolean().optional().describe(
2350
+ "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2351
+ ),
2352
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2353
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that. Propagated to the embedded admin-area selectors."
2354
+ )
2215
2355
  }).optional(),
2216
2356
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2217
2357
  }).meta({
@@ -2983,45 +3123,181 @@ var LanguageConfig = z26.object({
2983
3123
  });
2984
3124
 
2985
3125
  // ../commons/src/events/EventConfig.ts
2986
- var z33 = __toESM(require("zod/v4"));
3126
+ var z34 = __toESM(require("zod/v4"));
2987
3127
 
2988
3128
  // ../commons/src/events/SummaryConfig.ts
3129
+ var z28 = __toESM(require("zod/v4"));
3130
+
3131
+ // ../commons/src/icons.ts
2989
3132
  var z27 = __toESM(require("zod/v4"));
2990
- var BaseField2 = z27.object({
3133
+ var AvailableIcons = z27.enum([
3134
+ "Archived",
3135
+ "Assigned",
3136
+ "Briefcase",
3137
+ "Certified",
3138
+ "Close",
3139
+ "Collapse",
3140
+ "Draft",
3141
+ "DuplicateYellow",
3142
+ "Expand",
3143
+ "ExternalValidate",
3144
+ "FilledCheck",
3145
+ "InReview",
3146
+ "Offline",
3147
+ "Registered",
3148
+ "RequiresUpdates",
3149
+ "Sent",
3150
+ "Validated",
3151
+ "WaitingApproval",
3152
+ "ChartActivity",
3153
+ "Activity",
3154
+ "Archive",
3155
+ "ArchiveTray",
3156
+ "ArrowLeft",
3157
+ "ArrowRight",
3158
+ "Buildings",
3159
+ "Circle",
3160
+ "CaretDown",
3161
+ "CaretLeft",
3162
+ "CaretRight",
3163
+ "ChartBar",
3164
+ "ChartLine",
3165
+ "ChatCircle",
3166
+ "CheckSquare",
3167
+ "Compass",
3168
+ "Check",
3169
+ "Copy",
3170
+ "Database",
3171
+ "DotsThreeVertical",
3172
+ "ArrowCounterClockwise",
3173
+ "MagnifyingGlassMinus",
3174
+ "MagnifyingGlassPlus",
3175
+ "Export",
3176
+ "Eye",
3177
+ "EyeSlash",
3178
+ "Envelope",
3179
+ "File",
3180
+ "FileLock",
3181
+ "FileSearch",
3182
+ "FileMinus",
3183
+ "FilePlus",
3184
+ "FileText",
3185
+ "FileX",
3186
+ "Handshake",
3187
+ "Gear",
3188
+ "GitBranch",
3189
+ "IdentificationCard",
3190
+ "List",
3191
+ "ListBullets",
3192
+ "Lock",
3193
+ "MagnifyingGlass",
3194
+ "MapPin",
3195
+ "Medal",
3196
+ "NotePencil",
3197
+ "Paperclip",
3198
+ "PaperPlaneTilt",
3199
+ "Pen",
3200
+ "PenNib",
3201
+ "Pencil",
3202
+ "PencilSimpleLine",
3203
+ "Phone",
3204
+ "Plus",
3205
+ "Printer",
3206
+ "SignOut",
3207
+ "Stamp",
3208
+ "Star",
3209
+ "Target",
3210
+ "TextT",
3211
+ "Trash",
3212
+ "UploadSimple",
3213
+ "User",
3214
+ "UserPlus",
3215
+ "Users",
3216
+ "WarningCircle",
3217
+ "X",
3218
+ "ChatText",
3219
+ "CircleWavyCheck",
3220
+ "CircleWavyQuestion",
3221
+ "ArchiveBox",
3222
+ "ArrowCircleDown",
3223
+ "FileArrowUp",
3224
+ "FileDotted",
3225
+ "Files",
3226
+ "PencilLine",
3227
+ "PencilCircle",
3228
+ "UserCircle",
3229
+ "Clock",
3230
+ "QrCode",
3231
+ "Webcam",
3232
+ "Sun",
3233
+ "DeviceTabletCamera",
3234
+ "Globe",
3235
+ "Fingerprint",
3236
+ "PushPin",
3237
+ "Timer"
3238
+ ]);
3239
+
3240
+ // ../commons/src/events/SummaryConfig.ts
3241
+ var InfoBox = z28.object({
3242
+ type: z28.enum(["info", "positive", "warning", "negative"]).describe(
3243
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3244
+ ),
3245
+ background: z28.enum(["tinted", "white"]).default("tinted").optional().describe(
3246
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3247
+ ),
3248
+ icon: AvailableIcons.optional().describe(
3249
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3250
+ ),
3251
+ heading: TranslationConfig.describe(
3252
+ "Primary message. Short, sentence-case."
3253
+ ),
3254
+ description: TranslationConfig.optional().describe(
3255
+ "Secondary copy displayed below the heading, typically a suggested next step."
3256
+ ),
3257
+ conditionals: z28.array(ShowConditional).default([]).optional().describe(
3258
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3259
+ )
3260
+ }).describe(
3261
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3262
+ );
3263
+ var BaseField2 = z28.object({
2991
3264
  emptyValueMessage: TranslationConfig.optional().describe(
2992
3265
  "Default message displayed when the field value is empty."
2993
3266
  ),
2994
- conditionals: z27.array(ShowConditional).default([]).optional()
3267
+ conditionals: z28.array(ShowConditional).default([]).optional()
2995
3268
  });
2996
3269
  var ReferenceField = BaseField2.extend({
2997
- fieldId: z27.string(),
3270
+ fieldId: z28.string(),
2998
3271
  label: TranslationConfig.optional().describe(
2999
3272
  "Overrides the default label from the referenced field when provided."
3000
3273
  )
3001
3274
  }).describe("Field referencing existing event data by field ID.");
3002
3275
  var Field = BaseField2.extend({
3003
- id: z27.string().describe("Identifier of the summary field."),
3276
+ id: z28.string().describe("Identifier of the summary field."),
3004
3277
  value: TranslationConfig.describe(
3005
3278
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3006
3279
  ),
3007
3280
  label: TranslationConfig
3008
3281
  }).describe("Custom field defined for the summary view.");
3009
- var SummaryConfig = z27.object({
3010
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3282
+ var SummaryConfig = z28.object({
3283
+ banners: z28.array(InfoBox).default([]).optional().describe(
3284
+ "Info boxes displayed above the summary fields in the event overview."
3285
+ ),
3286
+ fields: z28.array(z28.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3011
3287
  }).meta({
3012
3288
  id: "SummaryConfig",
3013
3289
  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."
3014
3290
  });
3015
3291
 
3016
3292
  // ../commons/src/events/AdvancedSearchConfig.ts
3017
- var z28 = __toESM(require("zod/v4"));
3018
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3019
- var BaseField3 = z28.object({
3020
- config: z28.object({
3293
+ var z29 = __toESM(require("zod/v4"));
3294
+ var MatchType = z29.enum(["fuzzy", "exact", "range", "within"]);
3295
+ var BaseField3 = z29.object({
3296
+ config: z29.object({
3021
3297
  type: MatchType.describe(
3022
3298
  "Determines the search type of field. How to match value."
3023
3299
  ),
3024
- searchFields: z28.array(z28.string()).optional().describe(
3300
+ searchFields: z29.array(z29.string()).optional().describe(
3025
3301
  `
3026
3302
  Defines multiple form fields that should be searched when this field has a value.
3027
3303
  All specified fields will be combined using OR logic.
@@ -3031,7 +3307,7 @@ var BaseField3 = z28.object({
3031
3307
  `
3032
3308
  )
3033
3309
  }),
3034
- type: z28.nativeEnum(FieldType).optional().describe(
3310
+ type: z29.nativeEnum(FieldType).optional().describe(
3035
3311
  `
3036
3312
  Explicitly specify the field type for searchFields.
3037
3313
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3045,7 +3321,7 @@ var BaseField3 = z28.object({
3045
3321
  This is required when searchFields is defined.
3046
3322
  `
3047
3323
  ),
3048
- options: z28.array(SelectOption).optional(),
3324
+ options: z29.array(SelectOption).optional(),
3049
3325
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3050
3326
  `
3051
3327
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3066,7 +3342,7 @@ var BaseField3 = z28.object({
3066
3342
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3067
3343
  `
3068
3344
  ),
3069
- conditionals: z28.array(FieldConditional).optional().describe(
3345
+ conditionals: z29.array(FieldConditional).optional().describe(
3070
3346
  `
3071
3347
  In advanced search, we sometimes need to override the default field visibility conditionals.
3072
3348
 
@@ -3080,23 +3356,23 @@ var BaseField3 = z28.object({
3080
3356
  are always rendered in the advanced search form.
3081
3357
  `
3082
3358
  ),
3083
- validations: z28.array(ValidationConfig).optional().describe(
3359
+ validations: z29.array(ValidationConfig).optional().describe(
3084
3360
  `Option for overriding the field validations specifically for advanced search form.`
3085
3361
  ),
3086
3362
  allowedLocations: JurisdictionReference.optional().describe(
3087
3363
  `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.`
3088
3364
  )
3089
3365
  });
3090
- var SearchQueryParams = z28.object({
3091
- eventType: z28.string().optional().describe(
3366
+ var SearchQueryParams = z29.object({
3367
+ eventType: z29.string().optional().describe(
3092
3368
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3093
3369
  )
3094
3370
  }).catchall(FieldValue);
3095
3371
  var FieldConfigSchema = BaseField3.extend({
3096
- fieldId: z28.string(),
3097
- fieldType: z28.literal("field")
3372
+ fieldId: z29.string(),
3373
+ fieldType: z29.literal("field")
3098
3374
  });
3099
- var EventFieldIdInput = z28.enum([
3375
+ var EventFieldIdInput = z29.enum([
3100
3376
  "trackingId",
3101
3377
  "status",
3102
3378
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3105,7 +3381,7 @@ var EventFieldIdInput = z28.enum([
3105
3381
  "updatedAt"
3106
3382
  ]);
3107
3383
  var METADATA_FIELD_PREFIX = "event.";
3108
- var EventFieldId = z28.enum([
3384
+ var EventFieldId = z29.enum([
3109
3385
  `${METADATA_FIELD_PREFIX}trackingId`,
3110
3386
  `${METADATA_FIELD_PREFIX}status`,
3111
3387
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3115,186 +3391,51 @@ var EventFieldId = z28.enum([
3115
3391
  ]);
3116
3392
  var EventFieldConfigSchema = BaseField3.extend({
3117
3393
  fieldId: EventFieldId,
3118
- fieldType: z28.literal("event")
3394
+ fieldType: z29.literal("event")
3119
3395
  });
3120
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3396
+ var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3121
3397
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3122
3398
  if (!data.label) {
3123
3399
  ctx.addIssue({
3124
- code: z28.ZodIssueCode.custom,
3400
+ code: z29.ZodIssueCode.custom,
3125
3401
  message: "label is required when config.searchFields is defined.",
3126
3402
  path: ["label"]
3127
3403
  });
3128
3404
  }
3129
3405
  if (!data.type) {
3130
3406
  ctx.addIssue({
3131
- code: z28.ZodIssueCode.custom,
3407
+ code: z29.ZodIssueCode.custom,
3132
3408
  message: "type is required when config.searchFields is defined.",
3133
3409
  path: ["type"]
3134
3410
  });
3135
3411
  }
3136
3412
  }
3137
3413
  });
3138
- var AdvancedSearchConfig = z28.object({
3414
+ var AdvancedSearchConfig = z29.object({
3139
3415
  title: TranslationConfig.describe("Advanced search tab title"),
3140
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3416
+ fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3141
3417
  }).meta({
3142
3418
  id: "AdvancedSearchConfig",
3143
3419
  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()`)."
3144
3420
  });
3145
3421
 
3146
3422
  // ../commons/src/events/utils.ts
3147
- var import_lodash = require("lodash");
3423
+ var import_lodash4 = require("lodash");
3148
3424
 
3149
3425
  // ../commons/src/conditionals/validate.ts
3150
3426
  var import__ = __toESM(require("ajv/dist/2019"));
3151
3427
  var import_ajv_formats = __toESM(require("ajv-formats"));
3152
- var z31 = __toESM(require("zod/v4"));
3153
- var import_date_fns = require("date-fns");
3428
+ var z33 = __toESM(require("zod/v4"));
3429
+ var import_date_fns2 = require("date-fns");
3154
3430
 
3155
3431
  // ../commons/src/events/FieldTypeMapping.ts
3156
- var z30 = __toESM(require("zod/v4"));
3432
+ var z31 = __toESM(require("zod/v4"));
3157
3433
 
3158
3434
  // ../commons/src/events/DynamicFieldValue.ts
3159
- var z29 = __toESM(require("zod/v4"));
3435
+ var z30 = __toESM(require("zod/v4"));
3160
3436
 
3161
- // ../commons/src/conditionals/validate.ts
3162
- var ajv = new import__.default({
3163
- $data: true,
3164
- allowUnionTypes: true,
3165
- strict: false
3166
- // Allow minContains and other newer features
3167
- });
3168
- var DataContext = z31.object({
3169
- rootData: z31.object({
3170
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3171
- })
3172
- });
3173
- function resolveDataPath(rootData, dataPath, instancePath) {
3174
- const pathParts = dataPath.split("/");
3175
- const levels = parseInt(pathParts[0], 10);
3176
- const referencePath = pathParts.slice(1);
3177
- const instanceParts = instancePath.split("/").filter(Boolean);
3178
- const traversedParts = instanceParts.slice(0, -levels);
3179
- let current = rootData;
3180
- for (const part of traversedParts) {
3181
- if (current === null || current === void 0) {
3182
- return void 0;
3183
- }
3184
- current = current[part];
3185
- }
3186
- for (const part of referencePath) {
3187
- if (current === null || current === void 0) {
3188
- return void 0;
3189
- }
3190
- current = current[part];
3191
- }
3192
- return current;
3193
- }
3194
- function todayISO() {
3195
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3196
- }
3197
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3198
- function compileClientFunction(code) {
3199
- let fn = compiledFunctionCache.get(code);
3200
- if (!fn) {
3201
- fn = new Function(`return (${code})`)();
3202
- compiledFunctionCache.set(code, fn);
3203
- }
3204
- return fn;
3205
- }
3206
- (0, import_ajv_formats.default)(ajv);
3207
- function buildClientFunctionContext(input) {
3208
- return {
3209
- $form: input.form,
3210
- $now: todayISO(),
3211
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3212
- $online: isOnline(),
3213
- $user: input.validatorContext?.user,
3214
- $event: input.validatorContext?.event,
3215
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3216
- user: input.systemVariables?.user,
3217
- $window: input.systemVariables?.$window,
3218
- locations: input.locations,
3219
- adminLevelIds: input.adminLevelIds
3220
- };
3221
- }
3222
- function runClientFunction(code, data, context) {
3223
- return compileClientFunction(code)(data, context);
3224
- }
3225
- ajv.addKeyword({
3226
- keyword: "daysFromDate",
3227
- type: "string",
3228
- schemaType: "object",
3229
- $data: true,
3230
- errors: true,
3231
- validate(schema, data, _2, dataContext) {
3232
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3233
- throw new Error("Validation context must contain $now");
3234
- }
3235
- const { days, clause } = schema;
3236
- if (typeof data !== "string") {
3237
- return false;
3238
- }
3239
- const date = new Date(data);
3240
- if (isNaN(date.getTime())) {
3241
- return false;
3242
- }
3243
- let referenceDate = schema.referenceDate;
3244
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3245
- referenceDate = resolveDataPath(
3246
- dataContext.rootData,
3247
- referenceDate.$data,
3248
- dataContext.instancePath
3249
- );
3250
- }
3251
- if (!referenceDate) {
3252
- referenceDate = dataContext.rootData.$now;
3253
- }
3254
- const baseDate = new Date(referenceDate);
3255
- if (isNaN(baseDate.getTime())) {
3256
- return false;
3257
- }
3258
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3259
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3260
- }
3261
- });
3262
- ajv.addKeyword({
3263
- keyword: "isLeafLevelLocation",
3264
- type: "string",
3265
- schemaType: "boolean",
3266
- $data: true,
3267
- errors: true,
3268
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3269
- validate(_schema, data, _2, dataContext) {
3270
- const locationIdInput = data;
3271
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3272
- return locations.some((location) => location.id === locationIdInput);
3273
- }
3274
- });
3275
- ajv.addKeyword({
3276
- keyword: "customClientValidator",
3277
- schemaType: "object",
3278
- errors: true,
3279
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3280
- // `validate()` callers build root data via `buildClientFunctionContext`,
3281
- // so the cast holds.
3282
- validate(schema, data, _2, dataContext) {
3283
- return Boolean(
3284
- runClientFunction(
3285
- schema.code,
3286
- data,
3287
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3288
- )
3289
- );
3290
- }
3291
- });
3292
- function isOnline() {
3293
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3294
- return navigator.onLine;
3295
- }
3296
- return true;
3297
- }
3437
+ // ../commons/src/events/state/index.ts
3438
+ var import_lodash3 = require("lodash");
3298
3439
 
3299
3440
  // ../commons/src/utils.ts
3300
3441
  var z32 = __toESM(require("zod/v4"));
@@ -3322,35 +3463,62 @@ function omitKeyDeep(obj, keyToRemove) {
3322
3463
  return newObj;
3323
3464
  }
3324
3465
 
3325
- // ../commons/src/events/utils.ts
3326
- var import_date_fns2 = require("date-fns");
3327
- function getDeclarationFields(configuration) {
3328
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3329
- }
3330
- var getActionAnnotationFields = (actionConfig) => {
3331
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3332
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3333
- }
3334
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3335
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3336
- }
3337
- const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3338
- const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3339
- return [...reviewFields, ...formFields];
3340
- };
3341
- function getAllAnnotationFields(config) {
3342
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3343
- }
3344
- var findAllFields = (config) => {
3345
- return (0, import_lodash.flattenDeep)([
3346
- ...getDeclarationFields(config),
3347
- ...getAllAnnotationFields(config)
3348
- ]);
3349
- };
3350
- var EXCLUDED_ACTIONS = [
3351
- ActionType.REQUEST_CORRECTION,
3466
+ // ../commons/src/events/state/utils.ts
3467
+ var import_lodash = require("lodash");
3468
+ var updateActions = ActionTypes.extract([
3469
+ ActionType.CREATE,
3470
+ ActionType.NOTIFY,
3471
+ ActionType.EDIT,
3472
+ ActionType.DECLARE,
3473
+ ActionType.REGISTER,
3474
+ ActionType.REJECT,
3475
+ ActionType.ARCHIVE,
3476
+ ActionType.UNARCHIVE,
3352
3477
  ActionType.PRINT_CERTIFICATE,
3353
- ActionType.REJECT_CORRECTION
3478
+ ActionType.REQUEST_CORRECTION,
3479
+ ActionType.APPROVE_CORRECTION,
3480
+ ActionType.REJECT_CORRECTION,
3481
+ ActionType.CUSTOM
3482
+ ]);
3483
+
3484
+ // ../commons/src/events/state/flags.ts
3485
+ var import_lodash2 = require("lodash");
3486
+ var import_date_fns = require("date-fns");
3487
+ var INHERENT_FLAG_RULES = [
3488
+ {
3489
+ flag: InherentFlags.CORRECTION_REQUESTED,
3490
+ setOn: [ActionType.REQUEST_CORRECTION],
3491
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3492
+ },
3493
+ {
3494
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3495
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3496
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3497
+ // round trip and comes back exactly as it was.
3498
+ flag: InherentFlags.INCOMPLETE,
3499
+ setOn: [ActionType.NOTIFY],
3500
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3501
+ },
3502
+ {
3503
+ flag: InherentFlags.REJECTED,
3504
+ setOn: [ActionType.REJECT],
3505
+ resetOn: [
3506
+ ActionType.NOTIFY,
3507
+ ActionType.DECLARE,
3508
+ ActionType.EDIT,
3509
+ ActionType.REGISTER
3510
+ ]
3511
+ },
3512
+ {
3513
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3514
+ setOn: [ActionType.DUPLICATE_DETECTED],
3515
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3516
+ },
3517
+ {
3518
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3519
+ setOn: [ActionType.EDIT],
3520
+ resetOnAnyOtherAction: true
3521
+ }
3354
3522
  ];
3355
3523
 
3356
3524
  // ../commons/src/conditionals/conditionals.ts
@@ -3559,6 +3727,33 @@ function defineComparison(field3, value, keyword) {
3559
3727
  required: [field3.$$field]
3560
3728
  });
3561
3729
  }
3730
+ function flag(flagvalue) {
3731
+ return defineConditional({
3732
+ type: "object",
3733
+ properties: {
3734
+ $flags: {
3735
+ type: "array",
3736
+ contains: {
3737
+ type: "string",
3738
+ const: flagvalue
3739
+ }
3740
+ }
3741
+ },
3742
+ required: ["$flags"]
3743
+ });
3744
+ }
3745
+ function status(statusValue) {
3746
+ return defineConditional({
3747
+ type: "object",
3748
+ properties: {
3749
+ $status: {
3750
+ type: "string",
3751
+ const: statusValue
3752
+ }
3753
+ },
3754
+ required: ["$status"]
3755
+ });
3756
+ }
3562
3757
  function createFieldConditionals(fieldId) {
3563
3758
  const getDayRange = (field3, days, clause, referenceDate) => ({
3564
3759
  type: "object",
@@ -3960,6 +4155,176 @@ function createFieldConditionals(fieldId) {
3960
4155
  };
3961
4156
  }
3962
4157
 
4158
+ // ../commons/src/conditionals/validate.ts
4159
+ var ajv = new import__.default({
4160
+ $data: true,
4161
+ allowUnionTypes: true,
4162
+ strict: false
4163
+ // Allow minContains and other newer features
4164
+ });
4165
+ var DataContext = z33.object({
4166
+ rootData: z33.object({
4167
+ $leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
4168
+ })
4169
+ });
4170
+ function resolveDataPath(rootData, dataPath, instancePath) {
4171
+ const pathParts = dataPath.split("/");
4172
+ const levels = parseInt(pathParts[0], 10);
4173
+ const referencePath = pathParts.slice(1);
4174
+ const instanceParts = instancePath.split("/").filter(Boolean);
4175
+ const traversedParts = instanceParts.slice(0, -levels);
4176
+ let current = rootData;
4177
+ for (const part of traversedParts) {
4178
+ if (current === null || current === void 0) {
4179
+ return void 0;
4180
+ }
4181
+ current = current[part];
4182
+ }
4183
+ for (const part of referencePath) {
4184
+ if (current === null || current === void 0) {
4185
+ return void 0;
4186
+ }
4187
+ current = current[part];
4188
+ }
4189
+ return current;
4190
+ }
4191
+ function todayISO() {
4192
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4193
+ }
4194
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4195
+ function compileClientFunction(code) {
4196
+ let fn = compiledFunctionCache.get(code);
4197
+ if (!fn) {
4198
+ fn = new Function(`return (${code})`)();
4199
+ compiledFunctionCache.set(code, fn);
4200
+ }
4201
+ return fn;
4202
+ }
4203
+ (0, import_ajv_formats.default)(ajv);
4204
+ function buildClientFunctionContext(input) {
4205
+ return {
4206
+ $form: input.form,
4207
+ $flags: input.validatorContext?.event?.state.flags ?? [],
4208
+ $now: todayISO(),
4209
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4210
+ $online: isOnline(),
4211
+ $user: input.validatorContext?.user,
4212
+ $event: input.validatorContext?.event?.document,
4213
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4214
+ user: input.systemVariables?.user,
4215
+ $window: input.systemVariables?.$window,
4216
+ locations: input.locations,
4217
+ adminLevelIds: input.adminLevelIds
4218
+ };
4219
+ }
4220
+ function runClientFunction(code, data, context) {
4221
+ return compileClientFunction(code)(data, context);
4222
+ }
4223
+ ajv.addKeyword({
4224
+ keyword: "daysFromDate",
4225
+ type: "string",
4226
+ schemaType: "object",
4227
+ $data: true,
4228
+ errors: true,
4229
+ validate(schema, data, _2, dataContext) {
4230
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4231
+ throw new Error("Validation context must contain $now");
4232
+ }
4233
+ const { days, clause } = schema;
4234
+ if (typeof data !== "string") {
4235
+ return false;
4236
+ }
4237
+ const date = new Date(data);
4238
+ if (isNaN(date.getTime())) {
4239
+ return false;
4240
+ }
4241
+ let referenceDate = schema.referenceDate;
4242
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4243
+ referenceDate = resolveDataPath(
4244
+ dataContext.rootData,
4245
+ referenceDate.$data,
4246
+ dataContext.instancePath
4247
+ );
4248
+ }
4249
+ if (!referenceDate) {
4250
+ referenceDate = dataContext.rootData.$now;
4251
+ }
4252
+ const baseDate = new Date(referenceDate);
4253
+ if (isNaN(baseDate.getTime())) {
4254
+ return false;
4255
+ }
4256
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4257
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4258
+ }
4259
+ });
4260
+ ajv.addKeyword({
4261
+ keyword: "isLeafLevelLocation",
4262
+ type: "string",
4263
+ schemaType: "boolean",
4264
+ $data: true,
4265
+ errors: true,
4266
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4267
+ validate(_schema, data, _2, dataContext) {
4268
+ const locationIdInput = data;
4269
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4270
+ return locations.some((location) => location.id === locationIdInput);
4271
+ }
4272
+ });
4273
+ ajv.addKeyword({
4274
+ keyword: "customClientValidator",
4275
+ schemaType: "object",
4276
+ errors: true,
4277
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4278
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4279
+ // so the cast holds.
4280
+ validate(schema, data, _2, dataContext) {
4281
+ return Boolean(
4282
+ runClientFunction(
4283
+ schema.code,
4284
+ data,
4285
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4286
+ )
4287
+ );
4288
+ }
4289
+ });
4290
+ function isOnline() {
4291
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4292
+ return navigator.onLine;
4293
+ }
4294
+ return true;
4295
+ }
4296
+
4297
+ // ../commons/src/events/utils.ts
4298
+ var import_date_fns3 = require("date-fns");
4299
+ function getDeclarationFields(configuration) {
4300
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4301
+ }
4302
+ var getActionAnnotationFields = (actionConfig) => {
4303
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4304
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4305
+ }
4306
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4307
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4308
+ }
4309
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4310
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4311
+ return [...reviewFields, ...formFields];
4312
+ };
4313
+ function getAllAnnotationFields(config) {
4314
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4315
+ }
4316
+ var findAllFields = (config) => {
4317
+ return (0, import_lodash4.flattenDeep)([
4318
+ ...getDeclarationFields(config),
4319
+ ...getAllAnnotationFields(config)
4320
+ ]);
4321
+ };
4322
+ var EXCLUDED_ACTIONS = [
4323
+ ActionType.REQUEST_CORRECTION,
4324
+ ActionType.PRINT_CERTIFICATE,
4325
+ ActionType.REJECT_CORRECTION
4326
+ ];
4327
+
3963
4328
  // ../commons/src/events/eventConfigValidation.ts
3964
4329
  function validateAdvancedSearchConfig(event2, ctx) {
3965
4330
  const allFields = findAllFields(event2);
@@ -4042,9 +4407,9 @@ function validatePlaceOfEvent(event2, ctx) {
4042
4407
  }
4043
4408
  function validateActionFlags(event2, ctx) {
4044
4409
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4045
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4410
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4046
4411
  const actionFlagIds = event2.actions.flatMap(
4047
- (action) => (action.flags ?? []).map((flag) => flag.id)
4412
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4048
4413
  );
4049
4414
  for (const actionFlagId of actionFlagIds) {
4050
4415
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4080,11 +4445,11 @@ function validateActionOrder(event2, ctx) {
4080
4445
  }
4081
4446
 
4082
4447
  // ../commons/src/events/EventConfig.ts
4083
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4448
+ var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4084
4449
  "Reference to a field defined in the event metadata, using the field id."
4085
4450
  );
4086
- var _EventConfigBase = z33.object({
4087
- id: z33.string().describe(
4451
+ var _EventConfigBase = z34.object({
4452
+ id: z34.string().describe(
4088
4453
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4089
4454
  ),
4090
4455
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4103,23 +4468,26 @@ var _EventConfigBase = z33.object({
4103
4468
  "Summary information displayed in the event overview."
4104
4469
  ),
4105
4470
  label: TranslationConfig.describe("Human-readable label for the event type."),
4106
- actions: z33.array(ActionConfig).describe(
4471
+ actions: z34.array(ActionConfig).describe(
4107
4472
  "Configuration of core and custom actions associated with the event."
4108
4473
  ),
4109
- actionOrder: z33.array(z33.string()).optional().describe(
4474
+ actionOrder: z34.array(z34.string()).optional().describe(
4110
4475
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4111
4476
  ),
4112
4477
  declaration: DeclarationFormConfig.describe(
4113
4478
  "Configuration of the form used to gather event data."
4114
4479
  ),
4115
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4480
+ advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
4116
4481
  "Configuration of fields available in the advanced search feature."
4117
4482
  ),
4118
- flags: z33.array(FlagConfig).optional().default([]).describe(
4483
+ flags: z34.array(FlagConfig).optional().default([]).describe(
4119
4484
  "Configuration of custom flags associated with the actions of this event type."
4120
4485
  ),
4121
- analytics: z33.boolean().optional().default(true).describe(
4486
+ analytics: z34.boolean().optional().default(true).describe(
4122
4487
  "Indicates whether the records of this event type are included in analytics"
4488
+ ),
4489
+ icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
4490
+ '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.'
4123
4491
  )
4124
4492
  });
4125
4493
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4336,21 +4704,31 @@ var event = Object.assign(eventFn, {
4336
4704
  return {
4337
4705
  $event: field3
4338
4706
  };
4339
- }
4707
+ },
4708
+ /**
4709
+ * Checks if the event currently has the given status.
4710
+ * @param eventStatus - The status to check for.
4711
+ */
4712
+ hasStatus: (eventStatus) => status(eventStatus),
4713
+ /**
4714
+ * Checks if the event currently carries the given flag.
4715
+ * @param flagValue - The flag to check for.
4716
+ */
4717
+ hasFlag: (flagValue) => flag(flagValue)
4340
4718
  });
4341
4719
 
4342
4720
  // ../commons/src/events/WorkqueueColumnConfig.ts
4343
- var z34 = __toESM(require("zod/v4"));
4721
+ var z35 = __toESM(require("zod/v4"));
4344
4722
  var WorkqueueColumnKeysArray = [
4345
4723
  ...EventMetadataKeysArray,
4346
4724
  "title",
4347
4725
  "outbox"
4348
4726
  ];
4349
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4350
- var WorkqueueColumnValue = z34.object({
4727
+ var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
4728
+ var WorkqueueColumnValue = z35.object({
4351
4729
  $event: WorkqueueColumnKeys
4352
4730
  });
4353
- var WorkqueueColumn = z34.object({
4731
+ var WorkqueueColumn = z35.object({
4354
4732
  label: TranslationConfig,
4355
4733
  value: WorkqueueColumnValue
4356
4734
  }).meta({
@@ -4364,164 +4742,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4364
4742
  }
4365
4743
 
4366
4744
  // ../commons/src/events/CountryConfigQueryInput.ts
4367
- var z35 = __toESM(require("zod/v4"));
4368
- var SerializableExact = z35.object({
4369
- type: z35.literal("exact"),
4370
- term: z35.union([z35.string(), SerializedUserField])
4371
- });
4372
- var SerializableWithin = z35.object({
4373
- type: z35.literal("within"),
4374
- location: z35.union([z35.string(), SerializedUserField])
4375
- });
4376
- var SerializedQueryExpression = z35.object({
4377
- eventType: z35.string(),
4378
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4379
- createdAt: z35.optional(DateCondition),
4380
- updatedAt: z35.optional(DateCondition),
4381
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4382
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4383
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4384
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4385
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4386
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4387
- createdAtLocation: z35.optional(
4388
- z35.union([SerializableWithin, SerializableExact])
4745
+ var z36 = __toESM(require("zod/v4"));
4746
+ var SerializableExact = z36.object({
4747
+ type: z36.literal("exact"),
4748
+ term: z36.union([z36.string(), SerializedUserField])
4749
+ });
4750
+ var SerializableWithin = z36.object({
4751
+ type: z36.literal("within"),
4752
+ location: z36.union([z36.string(), SerializedUserField])
4753
+ });
4754
+ var SerializedQueryExpression = z36.object({
4755
+ eventType: z36.string(),
4756
+ status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
4757
+ createdAt: z36.optional(DateCondition),
4758
+ updatedAt: z36.optional(DateCondition),
4759
+ "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
4760
+ "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
4761
+ "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
4762
+ "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
4763
+ "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
4764
+ "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
4765
+ createdAtLocation: z36.optional(
4766
+ z36.union([SerializableWithin, SerializableExact])
4389
4767
  ),
4390
- updatedAtLocation: z35.optional(
4391
- z35.union([SerializableWithin, SerializableExact])
4768
+ updatedAtLocation: z36.optional(
4769
+ z36.union([SerializableWithin, SerializableExact])
4392
4770
  ),
4393
- updatedByUserRole: z35.optional(SerializableExact),
4394
- assignedTo: z35.optional(SerializableExact),
4395
- createdBy: z35.optional(SerializableExact),
4771
+ updatedByUserRole: z36.optional(SerializableExact),
4772
+ assignedTo: z36.optional(SerializableExact),
4773
+ createdBy: z36.optional(SerializableExact),
4396
4774
  createdByUserType: ExactUserType,
4397
- updatedBy: z35.optional(SerializableExact),
4398
- trackingId: z35.optional(Exact),
4399
- flags: z35.optional(ContainsFlags),
4775
+ updatedBy: z36.optional(SerializableExact),
4776
+ trackingId: z36.optional(Exact),
4777
+ flags: z36.optional(ContainsFlags),
4400
4778
  data: QueryInput
4401
4779
  }).partial();
4402
- var Or2 = z35.object({
4403
- type: z35.literal("or"),
4404
- clauses: z35.array(SerializedQueryExpression)
4780
+ var Or2 = z36.object({
4781
+ type: z36.literal("or"),
4782
+ clauses: z36.array(SerializedQueryExpression)
4405
4783
  });
4406
- var And2 = z35.object({
4407
- type: z35.literal("and"),
4408
- clauses: z35.array(SerializedQueryExpression)
4784
+ var And2 = z36.object({
4785
+ type: z36.literal("and"),
4786
+ clauses: z36.array(SerializedQueryExpression)
4409
4787
  });
4410
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4411
- var CountryConfigQueryInputType = z35.union([
4788
+ var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
4789
+ var CountryConfigQueryInputType = z36.union([
4412
4790
  SerializedQueryExpression,
4413
4791
  And2,
4414
4792
  Or2
4415
4793
  ]);
4416
4794
 
4417
- // ../commons/src/icons.ts
4418
- var z36 = __toESM(require("zod/v4"));
4419
- var AvailableIcons = z36.enum([
4420
- "Archived",
4421
- "Assigned",
4422
- "Briefcase",
4423
- "Certified",
4424
- "Close",
4425
- "Collapse",
4426
- "Draft",
4427
- "DuplicateYellow",
4428
- "Expand",
4429
- "ExternalValidate",
4430
- "FilledCheck",
4431
- "InReview",
4432
- "Offline",
4433
- "Registered",
4434
- "RequiresUpdates",
4435
- "Sent",
4436
- "Validated",
4437
- "WaitingApproval",
4438
- "ChartActivity",
4439
- "Activity",
4440
- "Archive",
4441
- "ArchiveTray",
4442
- "ArrowLeft",
4443
- "ArrowRight",
4444
- "Buildings",
4445
- "Circle",
4446
- "CaretDown",
4447
- "CaretLeft",
4448
- "CaretRight",
4449
- "ChartBar",
4450
- "ChartLine",
4451
- "ChatCircle",
4452
- "CheckSquare",
4453
- "Compass",
4454
- "Check",
4455
- "Copy",
4456
- "Database",
4457
- "DotsThreeVertical",
4458
- "ArrowCounterClockwise",
4459
- "MagnifyingGlassMinus",
4460
- "MagnifyingGlassPlus",
4461
- "Export",
4462
- "Eye",
4463
- "EyeSlash",
4464
- "Envelope",
4465
- "File",
4466
- "FileSearch",
4467
- "FileMinus",
4468
- "FilePlus",
4469
- "FileText",
4470
- "FileX",
4471
- "Handshake",
4472
- "Gear",
4473
- "GitBranch",
4474
- "IdentificationCard",
4475
- "List",
4476
- "ListBullets",
4477
- "Lock",
4478
- "MagnifyingGlass",
4479
- "MapPin",
4480
- "Medal",
4481
- "NotePencil",
4482
- "Paperclip",
4483
- "PaperPlaneTilt",
4484
- "Pen",
4485
- "PenNib",
4486
- "Pencil",
4487
- "PencilSimpleLine",
4488
- "Phone",
4489
- "Plus",
4490
- "Printer",
4491
- "SignOut",
4492
- "Stamp",
4493
- "Star",
4494
- "Target",
4495
- "TextT",
4496
- "Trash",
4497
- "UploadSimple",
4498
- "User",
4499
- "UserPlus",
4500
- "Users",
4501
- "WarningCircle",
4502
- "X",
4503
- "ChatText",
4504
- "CircleWavyCheck",
4505
- "CircleWavyQuestion",
4506
- "ArchiveBox",
4507
- "ArrowCircleDown",
4508
- "FileArrowUp",
4509
- "FileDotted",
4510
- "Files",
4511
- "PencilLine",
4512
- "PencilCircle",
4513
- "UserCircle",
4514
- "Clock",
4515
- "QrCode",
4516
- "Webcam",
4517
- "Sun",
4518
- "DeviceTabletCamera",
4519
- "Globe",
4520
- "Fingerprint",
4521
- "PushPin",
4522
- "Timer"
4523
- ]);
4524
-
4525
4795
  // ../commons/src/events/WorkqueueConfig.ts
4526
4796
  var mandatoryColumns = defineWorkqueuesColumns([
4527
4797
  {
@@ -4652,10 +4922,7 @@ var DeclareActionInput = BaseActionInput.extend(
4652
4922
  );
4653
4923
  var EditActionInput = BaseActionInput.extend(
4654
4924
  z38.object({
4655
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4656
- content: z38.object({
4657
- comment: z38.string().describe("Comment for the edit action.").optional()
4658
- })
4925
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4659
4926
  }).shape
4660
4927
  );
4661
4928
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4694,7 +4961,11 @@ var MarkNotDuplicateActionInput = BaseActionInput.extend(
4694
4961
  var ArchiveActionInput = BaseActionInput.extend(
4695
4962
  z38.object({
4696
4963
  type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4697
- content: ReasonContent
4964
+ /**
4965
+ * Archiving does not collect a reason on its own. Only the
4966
+ * "mark as duplicate" flow archives with a reason attached.
4967
+ */
4968
+ content: ReasonContent.optional()
4698
4969
  }).shape
4699
4970
  );
4700
4971
  var UnarchiveActionInput = BaseActionInput.extend(
@@ -4804,14 +5075,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4804
5075
 
4805
5076
  // ../commons/src/events/EventInput.ts
4806
5077
  var z40 = __toESM(require("zod/v4"));
4807
- var import_uuid10 = require("uuid");
5078
+ var import_uuid11 = require("uuid");
4808
5079
  var EventInput = z40.object({
4809
5080
  transactionId: z40.string(),
4810
5081
  type: z40.string(),
4811
5082
  createdAtLocation: UUID.nullish().describe(
4812
5083
  "Location where the event occurred. Required for system users."
4813
5084
  )
4814
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5085
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4815
5086
 
4816
5087
  // ../commons/src/events/EventDocument.ts
4817
5088
  var z41 = __toESM(require("zod/v4"));
@@ -4828,67 +5099,6 @@ var EventDocument = z41.object({
4828
5099
  )
4829
5100
  }).meta({ id: "EventDocument" });
4830
5101
 
4831
- // ../commons/src/events/state/index.ts
4832
- var import_lodash4 = require("lodash");
4833
-
4834
- // ../commons/src/events/state/utils.ts
4835
- var import_lodash2 = require("lodash");
4836
- var updateActions = ActionTypes.extract([
4837
- ActionType.CREATE,
4838
- ActionType.NOTIFY,
4839
- ActionType.EDIT,
4840
- ActionType.DECLARE,
4841
- ActionType.REGISTER,
4842
- ActionType.REJECT,
4843
- ActionType.ARCHIVE,
4844
- ActionType.UNARCHIVE,
4845
- ActionType.PRINT_CERTIFICATE,
4846
- ActionType.REQUEST_CORRECTION,
4847
- ActionType.APPROVE_CORRECTION,
4848
- ActionType.REJECT_CORRECTION,
4849
- ActionType.CUSTOM
4850
- ]);
4851
-
4852
- // ../commons/src/events/state/flags.ts
4853
- var import_lodash3 = require("lodash");
4854
- var import_date_fns3 = require("date-fns");
4855
- var INHERENT_FLAG_RULES = [
4856
- {
4857
- flag: InherentFlags.CORRECTION_REQUESTED,
4858
- setOn: [ActionType.REQUEST_CORRECTION],
4859
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4860
- },
4861
- {
4862
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4863
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4864
- // are deliberately excluded so the flag freezes across an archive/unarchive
4865
- // round trip and comes back exactly as it was.
4866
- flag: InherentFlags.INCOMPLETE,
4867
- setOn: [ActionType.NOTIFY],
4868
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4869
- },
4870
- {
4871
- flag: InherentFlags.REJECTED,
4872
- setOn: [ActionType.REJECT],
4873
- resetOn: [
4874
- ActionType.NOTIFY,
4875
- ActionType.DECLARE,
4876
- ActionType.EDIT,
4877
- ActionType.REGISTER
4878
- ]
4879
- },
4880
- {
4881
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4882
- setOn: [ActionType.DUPLICATE_DETECTED],
4883
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4884
- },
4885
- {
4886
- flag: InherentFlags.EDIT_IN_PROGRESS,
4887
- setOn: [ActionType.EDIT],
4888
- resetOnAnyOtherAction: true
4889
- }
4890
- ];
4891
-
4892
5102
  // ../commons/src/events/defineConfig.ts
4893
5103
  var IGNORED_EVENT_TYPES = [
4894
5104
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7361,20 +7571,88 @@ var LocationTypeV1 = z43.enum([
7361
7571
  "CRVS_OFFICE",
7362
7572
  "HEALTH_FACILITY"
7363
7573
  ]);
7574
+ var LocationStatus = z43.enum(["active", "inactive"]);
7575
+ var LocationVersion = z43.object({
7576
+ versionId: UUID,
7577
+ effectiveFrom: z43.iso.date(),
7578
+ name: z43.string(),
7579
+ externalId: z43.string().nullish(),
7580
+ status: LocationStatus
7581
+ });
7364
7582
  var AdministrativeArea = z43.object({
7365
7583
  id: UUID,
7366
7584
  name: z43.string(),
7367
7585
  externalId: z43.string().nullish(),
7368
7586
  parentId: UUID.nullable(),
7369
- validUntil: z43.iso.datetime().nullable()
7587
+ status: LocationStatus,
7588
+ versions: z43.array(LocationVersion)
7370
7589
  });
7371
7590
  var Location = z43.object({
7372
7591
  id: UUID,
7373
7592
  name: z43.string(),
7374
7593
  externalId: z43.string().nullish(),
7375
7594
  administrativeAreaId: UUID.nullable(),
7376
- validUntil: z43.iso.datetime().nullable(),
7377
- locationType: z43.string().nullable()
7595
+ locationType: z43.string().nullable(),
7596
+ status: LocationStatus,
7597
+ versions: z43.array(LocationVersion)
7598
+ });
7599
+ var ClientAdministrativeArea = AdministrativeArea.omit({
7600
+ name: true,
7601
+ status: true,
7602
+ externalId: true
7603
+ });
7604
+ var ClientLocation = Location.omit({
7605
+ name: true,
7606
+ status: true,
7607
+ externalId: true
7608
+ });
7609
+ function toClientLocation(location) {
7610
+ return {
7611
+ id: location.id,
7612
+ administrativeAreaId: location.administrativeAreaId,
7613
+ locationType: location.locationType,
7614
+ versions: location.versions
7615
+ };
7616
+ }
7617
+ function toClientAdministrativeArea(area) {
7618
+ return {
7619
+ id: area.id,
7620
+ parentId: area.parentId,
7621
+ versions: area.versions
7622
+ };
7623
+ }
7624
+ function validateAscendingDates(versions, ctx) {
7625
+ const ascending = versions.every(
7626
+ (version, index) => index === 0 || versions[index - 1].effectiveFrom < version.effectiveFrom
7627
+ );
7628
+ if (!ascending) {
7629
+ ctx.addIssue("versions must be strictly ascending by effectiveFrom");
7630
+ }
7631
+ }
7632
+ function validateUniqueIds(versions, ctx) {
7633
+ const versionIds = new Set(versions.map((version) => version.versionId));
7634
+ if (versionIds.size !== versions.length) {
7635
+ ctx.addIssue("versions must not repeat a versionId");
7636
+ }
7637
+ }
7638
+ var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7639
+ validateAscendingDates(versions, ctx);
7640
+ validateUniqueIds(versions, ctx);
7641
+ });
7642
+ var SetLocationPayload = z43.object({
7643
+ id: UUID,
7644
+ name: z43.string(),
7645
+ externalId: z43.string().nullish(),
7646
+ administrativeAreaId: UUID.nullable(),
7647
+ locationType: z43.string().nullable(),
7648
+ versions: SeededLocationVersions.optional()
7649
+ });
7650
+ var SetAdministrativeAreaPayload = z43.object({
7651
+ id: UUID,
7652
+ name: z43.string(),
7653
+ externalId: z43.string().nullish(),
7654
+ parentId: UUID.nullable(),
7655
+ versions: SeededLocationVersions.optional()
7378
7656
  });
7379
7657
 
7380
7658
  // ../commons/src/events/scopes.ts
@@ -7411,8 +7689,7 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7411
7689
  ActionType.READ,
7412
7690
  ActionType.DECLARE,
7413
7691
  ActionType.NOTIFY,
7414
- ActionType.DELETE,
7415
- ActionType.CUSTOM
7692
+ ActionType.DELETE
7416
7693
  ],
7417
7694
  [EventStatus.enum.NOTIFIED]: [
7418
7695
  ActionType.READ,
@@ -7447,20 +7724,20 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7447
7724
  ]
7448
7725
  };
7449
7726
  var ACTION_FILTERS = {
7450
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7451
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7452
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7453
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7454
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7455
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7456
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7457
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7458
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7459
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7460
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7461
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7462
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7463
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7727
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7728
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7729
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7730
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7731
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7732
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7733
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7734
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
7735
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
7736
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7737
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7738
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7739
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
7740
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
7464
7741
  };
7465
7742
  var REJECTED_ACTIONS = [
7466
7743
  ActionType.READ,
@@ -7474,75 +7751,80 @@ var REJECTED_ACTIONS = [
7474
7751
  var import_lodash7 = require("lodash");
7475
7752
 
7476
7753
  // ../commons/src/events/mocks.test.utils.ts
7477
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7754
+ function withVersionFields(entity) {
7755
+ return {
7756
+ ...entity,
7757
+ status: "active",
7758
+ versions: [
7759
+ {
7760
+ versionId: entity.id,
7761
+ effectiveFrom: "0001-01-01",
7762
+ name: entity.name,
7763
+ externalId: entity.externalId ?? null,
7764
+ status: "active"
7765
+ }
7766
+ ]
7767
+ };
7768
+ }
7769
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7478
7770
  {
7479
7771
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7480
7772
  name: "Central",
7481
7773
  parentId: null,
7482
- validUntil: null,
7483
7774
  externalId: "ydyJb1RAy4U1"
7484
7775
  },
7485
7776
  {
7486
7777
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7487
7778
  name: "Sulaka",
7488
7779
  parentId: null,
7489
- validUntil: null,
7490
7780
  externalId: "pQ8nGxWmZ2Q3"
7491
7781
  },
7492
7782
  {
7493
7783
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7494
7784
  name: "Pualula",
7495
7785
  parentId: null,
7496
- validUntil: null,
7497
7786
  externalId: "Aq91DweLmT8k"
7498
7787
  },
7499
7788
  {
7500
7789
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7501
7790
  name: "Chuminga",
7502
7791
  parentId: null,
7503
- validUntil: null,
7504
7792
  externalId: "Rw0fYNh2Xk9a"
7505
7793
  },
7506
7794
  {
7507
7795
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7508
7796
  name: "Ibombo",
7509
7797
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7510
- validUntil: null,
7511
7798
  externalId: "k7DsP4vbN1Qe"
7512
7799
  },
7513
7800
  {
7514
7801
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7515
7802
  name: "Isango",
7516
7803
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7517
- validUntil: null,
7518
7804
  externalId: "Gm3Z9eQpHw4L"
7519
7805
  },
7520
7806
  {
7521
7807
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7522
7808
  name: "Isamba",
7523
7809
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7524
- validUntil: null,
7525
7810
  externalId: "sT0xVu1KqJ7r"
7526
7811
  },
7527
7812
  {
7528
7813
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7529
7814
  name: "Itambo",
7530
7815
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7531
- validUntil: null,
7532
7816
  externalId: "Nq6Bv2HpL9Te"
7533
7817
  },
7534
7818
  {
7535
7819
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7536
7820
  name: "Ezhi",
7537
7821
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7538
- validUntil: null,
7539
7822
  externalId: "xK8cQ0ZRy5Wd"
7540
7823
  },
7541
7824
  {
7542
7825
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7543
7826
  name: "Ilanga",
7544
7827
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7545
- validUntil: null,
7546
7828
  externalId: "Cq4Jm1XvN8Ls"
7547
7829
  },
7548
7830
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7550,49 +7832,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7550
7832
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7551
7833
  name: "Klow",
7552
7834
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7553
- validUntil: null,
7554
7835
  externalId: "IkYcYBUcyY2"
7555
7836
  },
7556
7837
  {
7557
7838
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7558
7839
  name: "Mbondo",
7559
7840
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7560
- validUntil: null,
7561
7841
  externalId: "Qhvv5hvo3mY"
7562
7842
  },
7563
7843
  {
7564
7844
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7565
7845
  name: "Ndara",
7566
7846
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7567
- validUntil: null,
7568
7847
  externalId: "crXh068O9TR"
7569
7848
  },
7570
7849
  {
7571
7850
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7572
7851
  name: "Olani",
7573
7852
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7574
- validUntil: null,
7575
7853
  externalId: "r00It8Tvvp7"
7576
7854
  },
7577
7855
  {
7578
7856
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7579
7857
  name: "Pemba",
7580
7858
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7581
- validUntil: null,
7582
7859
  externalId: "ZnUWsbONIaH"
7583
7860
  },
7584
7861
  {
7585
7862
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7586
7863
  name: "Quanza",
7587
7864
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7588
- validUntil: null,
7589
7865
  externalId: "fDZycvQTa7l"
7590
7866
  },
7591
7867
  {
7592
7868
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7593
7869
  name: "Rivka",
7594
7870
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7595
- validUntil: null,
7596
7871
  externalId: "KqswxCGTELa"
7597
7872
  },
7598
7873
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7600,35 +7875,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7600
7875
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7601
7876
  name: "Mbula",
7602
7877
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7603
- validUntil: null,
7604
7878
  externalId: "osEbKjRc9Kg"
7605
7879
  },
7606
7880
  {
7607
7881
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7608
7882
  name: "Ndoki",
7609
7883
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7610
- validUntil: null,
7611
7884
  externalId: "aq4daBUAGr3"
7612
7885
  },
7613
7886
  {
7614
7887
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7615
7888
  name: "Tsanga",
7616
7889
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7617
- validUntil: null,
7618
7890
  externalId: "cqis6Y8trbJ"
7619
7891
  },
7620
7892
  {
7621
7893
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7622
7894
  name: "Waziri",
7623
7895
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7624
- validUntil: null,
7625
7896
  externalId: "LMijHPyyx6d"
7626
7897
  },
7627
7898
  {
7628
7899
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7629
7900
  name: "Zimbi",
7630
7901
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7631
- validUntil: null,
7632
7902
  externalId: "pcQYbPuKGZ7"
7633
7903
  },
7634
7904
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7636,67 +7906,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7636
7906
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7637
7907
  name: "Felani",
7638
7908
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7639
- validUntil: null,
7640
7909
  externalId: "gSqpoCGdMXp"
7641
7910
  },
7642
7911
  {
7643
7912
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7644
7913
  name: "Goroma",
7645
7914
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7646
- validUntil: null,
7647
7915
  externalId: "KvAAIaNqVrp"
7648
7916
  },
7649
7917
  {
7650
7918
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7651
7919
  name: "Halifu",
7652
7920
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7653
- validUntil: null,
7654
7921
  externalId: "qe4UnEVt1hv"
7655
7922
  },
7656
7923
  {
7657
7924
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7658
7925
  name: "Jabari",
7659
7926
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7660
- validUntil: null,
7661
7927
  externalId: "yHH9Nz4rLOt"
7662
7928
  },
7663
7929
  {
7664
7930
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7665
7931
  name: "Kifani",
7666
7932
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7667
- validUntil: null,
7668
7933
  externalId: "eSWmXIGeu1I"
7669
7934
  },
7670
7935
  {
7671
7936
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7672
7937
  name: "Lumela",
7673
7938
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7674
- validUntil: null,
7675
7939
  externalId: "bh0b3aI1uP3"
7676
7940
  }
7677
7941
  ];
7678
- var V2_DEFAULT_MOCK_LOCATIONS = [
7942
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
7943
+ var MOCK_LOCATIONS_BASE = [
7679
7944
  {
7680
7945
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7681
7946
  name: "Central Provincial Office",
7682
7947
  locationType: "CRVS_OFFICE",
7683
7948
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7684
- validUntil: null,
7685
7949
  externalId: "Xr3Df8WpK6Ys"
7686
7950
  },
7687
7951
  {
7688
7952
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7689
7953
  name: "Central Health Post",
7690
7954
  locationType: "HEALTH_FACILITY",
7691
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7692
- validUntil: null
7955
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7693
7956
  },
7694
7957
  {
7695
7958
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7696
7959
  name: "Ibombo District Office",
7697
7960
  locationType: "CRVS_OFFICE",
7698
7961
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7699
- validUntil: null,
7700
7962
  externalId: "Sm4Nw7GrD2Vy"
7701
7963
  },
7702
7964
  {
@@ -7704,7 +7966,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7704
7966
  name: "Isamba District Office",
7705
7967
  locationType: "CRVS_OFFICE",
7706
7968
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7707
- validUntil: null,
7708
7969
  externalId: "Vg1Bq5XeH9Lt"
7709
7970
  },
7710
7971
  {
@@ -7712,7 +7973,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7712
7973
  name: "Isango District Office",
7713
7974
  locationType: "CRVS_OFFICE",
7714
7975
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7715
- validUntil: null,
7716
7976
  externalId: "Je7Lm2XqN9Vz"
7717
7977
  },
7718
7978
  {
@@ -7720,7 +7980,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7720
7980
  name: "Sulaka Provincial Office",
7721
7981
  locationType: "CRVS_OFFICE",
7722
7982
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7723
- validUntil: null,
7724
7983
  externalId: "Ht2Wp9KcX5Qv"
7725
7984
  },
7726
7985
  {
@@ -7728,7 +7987,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7728
7987
  name: "Ilanga District Office",
7729
7988
  locationType: "CRVS_OFFICE",
7730
7989
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7731
- validUntil: null,
7732
7990
  externalId: "Yp6Ds1WqN3Xz"
7733
7991
  },
7734
7992
  {
@@ -7736,7 +7994,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7736
7994
  name: "Chamakubi Health Post",
7737
7995
  locationType: "HEALTH_FACILITY",
7738
7996
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7739
- validUntil: null,
7740
7997
  externalId: "M1nFr8LbC2Qy"
7741
7998
  },
7742
7999
  {
@@ -7744,7 +8001,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7744
8001
  name: "Ibombo Rural Health Centre",
7745
8002
  locationType: "HEALTH_FACILITY",
7746
8003
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7747
- validUntil: null,
7748
8004
  externalId: "bT7pV6YrW0Xc"
7749
8005
  },
7750
8006
  {
@@ -7752,7 +8008,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7752
8008
  name: "Chikobo Rural Health Centre",
7753
8009
  locationType: "HEALTH_FACILITY",
7754
8010
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7755
- validUntil: null,
7756
8011
  externalId: "zE4qPn2SgJ5d"
7757
8012
  },
7758
8013
  {
@@ -7760,7 +8015,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7760
8015
  name: "Chilochabalenje Health Post",
7761
8016
  locationType: "HEALTH_FACILITY",
7762
8017
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7763
- validUntil: null,
7764
8018
  externalId: "H8vDs1MqR4Uf"
7765
8019
  },
7766
8020
  {
@@ -7768,7 +8022,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7768
8022
  name: "Chipeso Rural Health Centre",
7769
8023
  locationType: "HEALTH_FACILITY",
7770
8024
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7771
- validUntil: null,
7772
8025
  externalId: "Qw3uZ9KfX6Lm"
7773
8026
  },
7774
8027
  {
@@ -7776,7 +8029,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7776
8029
  name: "Chisamba Rural Health Centre",
7777
8030
  locationType: "HEALTH_FACILITY",
7778
8031
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7779
- validUntil: null,
7780
8032
  externalId: "Yr0pCg8LdM2s"
7781
8033
  },
7782
8034
  {
@@ -7784,7 +8036,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7784
8036
  name: "Chitanda Rural Health Centre",
7785
8037
  locationType: "HEALTH_FACILITY",
7786
8038
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7787
- validUntil: null,
7788
8039
  externalId: "tS9gJ4PwB1Qx"
7789
8040
  },
7790
8041
  {
@@ -7792,7 +8043,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7792
8043
  name: "Golden Valley Rural Health Centre",
7793
8044
  locationType: "HEALTH_FACILITY",
7794
8045
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7795
- validUntil: null,
7796
8046
  externalId: "Ld7Qm3XsA8Vr"
7797
8047
  },
7798
8048
  {
@@ -7800,7 +8050,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7800
8050
  name: "Ipongo Rural Health Centre",
7801
8051
  locationType: "HEALTH_FACILITY",
7802
8052
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7803
- validUntil: null,
7804
8053
  externalId: "kF2sW9DmH0Bt"
7805
8054
  },
7806
8055
  {
@@ -7808,7 +8057,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7808
8057
  name: "Itumbwe Health Post",
7809
8058
  locationType: "HEALTH_FACILITY",
7810
8059
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7811
- validUntil: null,
7812
8060
  externalId: "Ue5Xb3VaC7Pq"
7813
8061
  },
7814
8062
  {
@@ -7816,7 +8064,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7816
8064
  name: "Kabangalala Rural Health Centre",
7817
8065
  locationType: "HEALTH_FACILITY",
7818
8066
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7819
- validUntil: null,
7820
8067
  externalId: "Pz8Kc1TqH6Jn"
7821
8068
  },
7822
8069
  // Village offices
@@ -7825,79 +8072,181 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7825
8072
  name: "Klow Village Office",
7826
8073
  locationType: "CRVS_OFFICE",
7827
8074
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7828
- validUntil: null,
7829
8075
  externalId: "PmAyxAJkxiJ"
7830
8076
  }
7831
8077
  ];
8078
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7832
8079
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7833
8080
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7834
8081
  );
7835
8082
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7836
8083
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7837
8084
  );
8085
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
8086
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
8087
+ );
8088
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
8089
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
8090
+ a.id,
8091
+ toClientAdministrativeArea(a)
8092
+ ])
8093
+ );
7838
8094
 
7839
- // ../commons/src/notification/UserNotifications.ts
8095
+ // ../commons/src/events/locationPayloads.ts
7840
8096
  var z44 = __toESM(require("zod/v4"));
8097
+ var CreateLocationPayload = z44.object({
8098
+ id: UUID.optional(),
8099
+ versionId: UUID.optional(),
8100
+ name: z44.string(),
8101
+ externalId: z44.string().nullish(),
8102
+ administrativeAreaId: UUID.nullable(),
8103
+ locationType: z44.string().nullable(),
8104
+ effectiveFrom: z44.iso.date().optional(),
8105
+ status: LocationStatus.default("active")
8106
+ });
8107
+ var UpdateLocationPayload = z44.strictObject({
8108
+ id: UUID,
8109
+ versionId: UUID.optional(),
8110
+ name: z44.string(),
8111
+ externalId: z44.string().nullish(),
8112
+ status: LocationStatus,
8113
+ effectiveFrom: z44.iso.date().optional(),
8114
+ lastVersionId: UUID
8115
+ });
8116
+ var WithdrawLocationVersionPayload = z44.object({
8117
+ id: UUID,
8118
+ versionId: UUID
8119
+ });
8120
+ var CreateAdministrativeAreaPayload = z44.object({
8121
+ id: UUID.optional(),
8122
+ versionId: UUID.optional(),
8123
+ name: z44.string(),
8124
+ externalId: z44.string().nullish(),
8125
+ parentId: UUID.nullable(),
8126
+ effectiveFrom: z44.iso.date().optional(),
8127
+ status: LocationStatus.default("active")
8128
+ });
8129
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
8130
+ id: UUID,
8131
+ versionId: UUID.optional(),
8132
+ name: z44.string(),
8133
+ externalId: z44.string().nullish(),
8134
+ status: LocationStatus,
8135
+ effectiveFrom: z44.iso.date().optional(),
8136
+ lastVersionId: UUID
8137
+ });
8138
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
8139
+ id: UUID,
8140
+ versionId: UUID
8141
+ });
8142
+
8143
+ // ../commons/src/logger.ts
8144
+ var import_pino = __toESM(require("pino"));
8145
+ function filterHealthCheckLogs(args, method) {
8146
+ const logger2 = this;
8147
+ for (const arg of args) {
8148
+ if (typeof arg === "string" && arg.includes("get /ping 200")) {
8149
+ if (logger2.debug) {
8150
+ return logger2.debug(...args);
8151
+ }
8152
+ }
8153
+ }
8154
+ return method.apply(this, args);
8155
+ }
8156
+ var logger = false ? (0, import_pino.default)({
8157
+ level: "info",
8158
+ redact: [
8159
+ "req.headers.authorization",
8160
+ "req.remoteAddress",
8161
+ "req.headers['x-real-ip']"
8162
+ ],
8163
+ hooks: { logMethod: filterHealthCheckLogs }
8164
+ }) : (0, import_pino.default)({
8165
+ level: "debug",
8166
+ transport: {
8167
+ target: "pino-pretty",
8168
+ options: {
8169
+ colorize: true,
8170
+ ignore: "pid,hostname"
8171
+ }
8172
+ },
8173
+ hooks: { logMethod: filterHealthCheckLogs }
8174
+ });
8175
+ var level = false ? "silent" : process.env.LOG_LEVEL;
8176
+ if (level) {
8177
+ logger.level = level;
8178
+ }
8179
+
8180
+ // ../commons/src/notification/UserNotifications.ts
8181
+ var z45 = __toESM(require("zod/v4"));
7841
8182
  var TriggerEvent = {
7842
8183
  USER_CREATED: "user-created",
7843
8184
  USER_UPDATED: "user-updated",
7844
8185
  USERNAME_REMINDER: "username-reminder",
7845
8186
  RESET_PASSWORD: "reset-password",
7846
8187
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8188
+ PASSWORD_RESET_LINK: "password-reset-link",
8189
+ USERNAME_REMINDER_LINK: "username-reminder-link",
7847
8190
  RESEND_INVITE: "resend-invite",
7848
8191
  TWO_FA: "2fa",
7849
8192
  ALL_USER_NOTIFICATION: "all-user-notification",
7850
8193
  CHANGE_PHONE_NUMBER: "change-phone-number",
7851
8194
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7852
8195
  };
7853
- var Recipient = z44.object({
8196
+ var Recipient = z45.object({
7854
8197
  name: NameFieldValue.optional(),
7855
- mobile: z44.string().optional(),
7856
- email: z44.string().optional(),
7857
- bcc: z44.array(z44.string()).optional()
8198
+ mobile: z45.string().optional(),
8199
+ email: z45.string().optional(),
8200
+ bcc: z45.array(z45.string()).optional()
7858
8201
  });
7859
- var BasePayload = z44.object({
8202
+ var BasePayload = z45.object({
7860
8203
  recipient: Recipient
7861
8204
  });
7862
8205
  var TriggerPayload = {
7863
8206
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7864
- username: z44.string(),
7865
- temporaryPassword: z44.string()
8207
+ username: z45.string(),
8208
+ temporaryPassword: z45.string()
7866
8209
  }),
7867
8210
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7868
- oldUsername: z44.string(),
7869
- newUsername: z44.string()
8211
+ oldUsername: z45.string(),
8212
+ newUsername: z45.string()
7870
8213
  }),
7871
8214
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7872
- username: z44.string()
8215
+ username: z45.string()
7873
8216
  }),
7874
8217
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7875
- code: z44.string()
8218
+ code: z45.string()
7876
8219
  }),
7877
8220
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7878
- temporaryPassword: z44.string(),
7879
- admin: z44.object({
7880
- id: z44.string(),
8221
+ temporaryPassword: z45.string(),
8222
+ admin: z45.object({
8223
+ id: z45.string(),
7881
8224
  name: NameFieldValue,
7882
- role: z44.string()
8225
+ role: z45.string()
7883
8226
  })
7884
8227
  }),
8228
+ [TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
8229
+ token: z45.string()
8230
+ }),
8231
+ [TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
8232
+ token: z45.string()
8233
+ }),
7885
8234
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7886
- username: z44.string(),
7887
- temporaryPassword: z44.string()
8235
+ username: z45.string(),
8236
+ temporaryPassword: z45.string()
7888
8237
  }),
7889
8238
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7890
- code: z44.string()
8239
+ code: z45.string()
7891
8240
  }),
7892
8241
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7893
- subject: z44.string(),
7894
- body: z44.string()
8242
+ subject: z45.string(),
8243
+ body: z45.string()
7895
8244
  }),
7896
8245
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7897
- code: z44.string()
8246
+ code: z45.string()
7898
8247
  }),
7899
8248
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7900
- code: z44.string()
8249
+ code: z45.string()
7901
8250
  })
7902
8251
  };
7903
8252
  async function triggerUserEventNotification({
@@ -7906,14 +8255,23 @@ async function triggerUserEventNotification({
7906
8255
  countryConfigUrl,
7907
8256
  authHeader
7908
8257
  }) {
7909
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
7910
- method: "POST",
7911
- body: JSON.stringify(payload),
7912
- headers: {
7913
- "Content-Type": "application/json",
7914
- ...authHeader
8258
+ const response = await fetch(
8259
+ joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8260
+ {
8261
+ method: "POST",
8262
+ body: JSON.stringify(payload),
8263
+ headers: {
8264
+ "Content-Type": "application/json",
8265
+ ...authHeader
8266
+ }
7915
8267
  }
7916
- });
8268
+ );
8269
+ if (!response.ok) {
8270
+ logger.error(
8271
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8272
+ );
8273
+ }
8274
+ return response;
7917
8275
  }
7918
8276
  function parseUserEventTrigger(event2, body) {
7919
8277
  const schema = TriggerPayload[event2];
@@ -7921,4 +8279,4 @@ function parseUserEventTrigger(event2, body) {
7921
8279
  }
7922
8280
 
7923
8281
  // src/notification/index.ts
7924
- z45.globalRegistry.clear();
8282
+ z46.globalRegistry.clear();