@opencrvs/toolkit 2.1.0-rc.ecb508d → 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 (69) 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 +254 -197
  6. package/dist/cli.js +195 -73
  7. package/dist/commons/api/router.d.ts +672 -57
  8. package/dist/commons/conditionals/conditionals.d.ts +6 -6
  9. package/dist/commons/conditionals/validate.d.ts +16 -5
  10. package/dist/commons/events/ActionDocument.d.ts +5 -11
  11. package/dist/commons/events/ActionInput.d.ts +4 -4
  12. package/dist/commons/events/ActionStatus.d.ts +14 -0
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +18 -0
  14. package/dist/commons/events/AuditLog.d.ts +147 -0
  15. package/dist/commons/events/EventConfig.d.ts +3 -0
  16. package/dist/commons/events/EventDocument.d.ts +2 -2
  17. package/dist/commons/events/EventIndex.d.ts +3 -26
  18. package/dist/commons/events/FieldConfig.d.ts +83 -53
  19. package/dist/commons/events/FieldTypeMapping.d.ts +19 -19
  20. package/dist/commons/events/FieldValue.d.ts +2 -2
  21. package/dist/commons/events/Flag.d.ts +42 -0
  22. package/dist/commons/events/PlainDate.d.ts +8 -0
  23. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  24. package/dist/commons/events/WorkqueueConfig.d.ts +17 -14
  25. package/dist/commons/events/event.d.ts +12 -0
  26. package/dist/commons/events/index.d.ts +1 -0
  27. package/dist/commons/events/locationPayloads.d.ts +95 -0
  28. package/dist/commons/events/locations.d.ts +163 -24
  29. package/dist/commons/events/mocks.test.utils.d.ts +30 -0
  30. package/dist/commons/events/test.utils.d.ts +8 -4
  31. package/dist/commons/events/utils.d.ts +2 -2
  32. package/dist/commons/notification/UserNotifications.d.ts +28 -0
  33. package/dist/conditionals/index.js +308 -55
  34. package/dist/environment/index.d.ts +1 -0
  35. package/dist/environment/index.d.ts.map +1 -1
  36. package/dist/environment/index.js +10 -0
  37. package/dist/environment/logger.d.ts +12 -3
  38. package/dist/environment/logger.d.ts.map +1 -1
  39. package/dist/environment/paths.d.ts +7 -0
  40. package/dist/environment/paths.d.ts.map +1 -0
  41. package/dist/environment/paths.js +72 -0
  42. package/dist/environment/questions.d.ts.map +1 -1
  43. package/dist/environment/questions.js +20 -14
  44. package/dist/environment/setup-environment.js +3 -2
  45. package/dist/environment/templates.d.ts.map +1 -1
  46. package/dist/environment/templates.js +2 -1
  47. package/dist/environment/update-workflows.d.ts.map +1 -1
  48. package/dist/environment/update-workflows.js +17 -5
  49. package/dist/environment/upgrade.d.ts +2 -0
  50. package/dist/environment/upgrade.d.ts.map +1 -0
  51. package/dist/environment/upgrade.js +82 -0
  52. package/dist/environment/users.js +11 -13
  53. package/dist/events/index.js +3621 -3243
  54. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  55. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  56. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  57. package/dist/notification/index.js +1400 -1033
  58. package/dist/scopes/index.d.ts +253 -26
  59. package/dist/scopes/index.js +309 -55
  60. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  61. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  62. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  63. package/dist/templates/inventory/inventory.template.yml +1 -3
  64. package/opencrvs-toolkit-2.1.0-rc.f29a266.tgz +0 -0
  65. package/package.json +5 -5
  66. package/tsconfig.tsbuildinfo +1 -1
  67. package/dist/templates/inventory/production.example.yml +0 -77
  68. package/dist/templates/inventory/qa.example.yml +0 -48
  69. package/opencrvs-toolkit-2.1.0-rc.ecb508d.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,139 +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),
1378
+ z15.object({
1379
+ type: z15.literal(ActionType.EDIT),
1219
1380
  /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1220
- content: z14.object({
1221
- comment: z14.string().describe("Comment for the edit action.").optional()
1381
+ content: z15.object({
1382
+ comment: z15.string().describe("Comment for the edit action.").optional()
1222
1383
  }).optional()
1223
1384
  }).shape
1224
1385
  );
1225
- var PrintContent = z14.object({
1226
- templateId: z14.string().optional()
1386
+ var PrintContent = z15.object({
1387
+ templateId: z15.string().optional()
1227
1388
  });
1228
1389
  var PrintCertificateAction = ActionBase.extend(
1229
- z14.object({
1230
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1390
+ z15.object({
1391
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1231
1392
  content: PrintContent.optional().nullable()
1232
1393
  }).shape
1233
1394
  );
1234
1395
  var RequestedCorrectionAction = ActionBase.extend(
1235
- z14.object({
1236
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1396
+ z15.object({
1397
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1237
1398
  }).shape
1238
1399
  );
1239
1400
  var ApprovedCorrectionAction = ActionBase.extend(
1240
- z14.object({
1241
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1242
- requestId: z14.string(),
1401
+ z15.object({
1402
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1403
+ requestId: z15.string(),
1243
1404
  // TODO move into 'content' property
1244
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1405
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1245
1406
  }).shape
1246
1407
  );
1247
1408
  var RejectedCorrectionAction = ActionBase.extend(
1248
- z14.object({
1249
- type: z14.literal(ActionType.REJECT_CORRECTION),
1250
- requestId: z14.string(),
1409
+ z15.object({
1410
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1411
+ requestId: z15.string(),
1251
1412
  // TODO move into 'content' property
1252
1413
  content: ReasonContent
1253
1414
  }).shape
1254
1415
  );
1255
1416
  var ReadAction = ActionBase.extend(
1256
- z14.object({
1257
- type: z14.literal(ActionType.READ)
1417
+ z15.object({
1418
+ type: z15.literal(ActionType.READ)
1258
1419
  }).shape
1259
1420
  );
1260
1421
  var CustomAction = ActionBase.merge(
1261
- z14.object({
1262
- type: z14.literal(ActionType.CUSTOM),
1263
- customActionType: z14.string()
1422
+ z15.object({
1423
+ type: z15.literal(ActionType.CUSTOM),
1424
+ customActionType: z15.string()
1264
1425
  })
1265
1426
  );
1266
- var ActionDocument = z14.discriminatedUnion("type", [
1427
+ var ActionDocument = z15.discriminatedUnion("type", [
1267
1428
  CreatedAction.meta({ id: "CreatedAction" }),
1268
1429
  RejectAction.meta({ id: "RejectAction" }),
1269
1430
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1290,64 +1451,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1290
1451
  declaration: true,
1291
1452
  annotation: true
1292
1453
  }).extend(
1293
- z14.object({
1294
- type: z14.enum(ConfirmableActions),
1295
- status: z14.literal(ActionStatus.Rejected)
1454
+ z15.object({
1455
+ type: z15.enum(ConfirmableActions),
1456
+ status: z15.literal(ActionStatus.Rejected)
1296
1457
  }).shape
1297
1458
  );
1298
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1299
-
1300
- // ../commons/src/events/Flag.ts
1301
- var z15 = __toESM(require("zod/v4"));
1302
- var InherentFlags = {
1303
- INCOMPLETE: "incomplete",
1304
- REJECTED: "rejected",
1305
- CORRECTION_REQUESTED: "correction-requested",
1306
- POTENTIAL_DUPLICATE: "potential-duplicate",
1307
- /**
1308
- * This flag is set by the Edit-action and removed after the declaration or registration.
1309
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1310
- *
1311
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1312
- */
1313
- EDIT_IN_PROGRESS: "edit-in-progress"
1314
- };
1315
- var ActionFlag = z15.string().regex(
1316
- new RegExp(
1317
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1318
- ActionStatus
1319
- ).join("|").toLowerCase()})$`
1320
- ),
1321
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1322
- );
1323
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1324
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1325
- InherentFlags
1326
- ).join(", ")}`
1327
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1328
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1329
- }).describe("Custom flag identifier defined by the country config.");
1330
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1331
- var FlagConfig = z15.object({
1332
- id: CustomFlag,
1333
- requiresAction: z15.boolean().describe(
1334
- "Indicates if this flag expects an action to be performed to be cleared."
1335
- ),
1336
- label: TranslationConfig.describe("Human readable label of the flag.")
1337
- }).meta({
1338
- id: "FlagConfig",
1339
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1340
- });
1341
- var ActionFlagConfig = z15.object({
1342
- id: Flag,
1343
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1344
- conditional: Conditional.optional().describe(
1345
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1346
- )
1347
- }).meta({
1348
- id: "ActionFlagConfig",
1349
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1350
- });
1459
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1351
1460
 
1352
1461
  // ../commons/src/events/EventMetadata.ts
1353
1462
  var EventStatus = z16.enum([
@@ -1505,13 +1614,6 @@ var Range = import_v4.z.object({
1505
1614
  }).meta({
1506
1615
  id: "Range"
1507
1616
  });
1508
- var ContainsFlags = import_v4.z.object({
1509
- anyOf: import_v4.z.array(Flag).optional(),
1510
- noneOf: import_v4.z.array(Flag).optional(),
1511
- allOf: import_v4.z.array(Flag).optional()
1512
- }).meta({
1513
- id: "ContainsFlags"
1514
- });
1515
1617
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1516
1618
  id: "Within"
1517
1619
  });
@@ -1738,8 +1840,8 @@ var BaseField = import_v43.default.object({
1738
1840
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1739
1841
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1740
1842
  ),
1741
- secured: import_v43.default.boolean().default(false).optional().describe(
1742
- "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."
1743
1845
  ),
1744
1846
  placeholder: TranslationConfig.optional(),
1745
1847
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2137,7 +2239,16 @@ var AdministrativeAreaField = BaseField.extend({
2137
2239
  configuration: import_v43.default.object({
2138
2240
  partOf: FieldReference.optional().describe("Parent location"),
2139
2241
  type: AdministrativeAreas,
2140
- 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
+ )
2141
2252
  }).describe("Administrative area options")
2142
2253
  }).meta({
2143
2254
  description: "Administrative area input field",
@@ -2148,7 +2259,16 @@ var LocationInput = BaseField.extend({
2148
2259
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2149
2260
  configuration: import_v43.default.object({
2150
2261
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2151
- 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
+ )
2152
2272
  }).optional()
2153
2273
  }).meta({
2154
2274
  description: "A field for selecting a location",
@@ -2174,12 +2294,22 @@ var FileUploadWithOptions = BaseField.extend({
2174
2294
  var Facility = BaseField.extend({
2175
2295
  type: import_v43.default.literal(FieldType.FACILITY),
2176
2296
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2177
- 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()
2178
2303
  }).describe("Input field for a facility");
2179
2304
  var Office = BaseField.extend({
2180
2305
  type: import_v43.default.literal(FieldType.OFFICE),
2181
2306
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2182
- 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()
2183
2313
  }).describe("Input field for an office");
2184
2314
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2185
2315
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2212,7 +2342,16 @@ var Address = BaseField.extend({
2212
2342
  parent: FieldReference.optional()
2213
2343
  })
2214
2344
  ).optional(),
2215
- 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
+ )
2216
2355
  }).optional(),
2217
2356
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2218
2357
  }).meta({
@@ -2984,45 +3123,181 @@ var LanguageConfig = z26.object({
2984
3123
  });
2985
3124
 
2986
3125
  // ../commons/src/events/EventConfig.ts
2987
- var z33 = __toESM(require("zod/v4"));
3126
+ var z34 = __toESM(require("zod/v4"));
2988
3127
 
2989
3128
  // ../commons/src/events/SummaryConfig.ts
3129
+ var z28 = __toESM(require("zod/v4"));
3130
+
3131
+ // ../commons/src/icons.ts
2990
3132
  var z27 = __toESM(require("zod/v4"));
2991
- 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({
2992
3264
  emptyValueMessage: TranslationConfig.optional().describe(
2993
3265
  "Default message displayed when the field value is empty."
2994
3266
  ),
2995
- conditionals: z27.array(ShowConditional).default([]).optional()
3267
+ conditionals: z28.array(ShowConditional).default([]).optional()
2996
3268
  });
2997
3269
  var ReferenceField = BaseField2.extend({
2998
- fieldId: z27.string(),
3270
+ fieldId: z28.string(),
2999
3271
  label: TranslationConfig.optional().describe(
3000
3272
  "Overrides the default label from the referenced field when provided."
3001
3273
  )
3002
3274
  }).describe("Field referencing existing event data by field ID.");
3003
3275
  var Field = BaseField2.extend({
3004
- id: z27.string().describe("Identifier of the summary field."),
3276
+ id: z28.string().describe("Identifier of the summary field."),
3005
3277
  value: TranslationConfig.describe(
3006
3278
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3007
3279
  ),
3008
3280
  label: TranslationConfig
3009
3281
  }).describe("Custom field defined for the summary view.");
3010
- var SummaryConfig = z27.object({
3011
- 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.")
3012
3287
  }).meta({
3013
3288
  id: "SummaryConfig",
3014
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."
3015
3290
  });
3016
3291
 
3017
3292
  // ../commons/src/events/AdvancedSearchConfig.ts
3018
- var z28 = __toESM(require("zod/v4"));
3019
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3020
- var BaseField3 = z28.object({
3021
- 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({
3022
3297
  type: MatchType.describe(
3023
3298
  "Determines the search type of field. How to match value."
3024
3299
  ),
3025
- searchFields: z28.array(z28.string()).optional().describe(
3300
+ searchFields: z29.array(z29.string()).optional().describe(
3026
3301
  `
3027
3302
  Defines multiple form fields that should be searched when this field has a value.
3028
3303
  All specified fields will be combined using OR logic.
@@ -3032,7 +3307,7 @@ var BaseField3 = z28.object({
3032
3307
  `
3033
3308
  )
3034
3309
  }),
3035
- type: z28.nativeEnum(FieldType).optional().describe(
3310
+ type: z29.nativeEnum(FieldType).optional().describe(
3036
3311
  `
3037
3312
  Explicitly specify the field type for searchFields.
3038
3313
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3046,7 +3321,7 @@ var BaseField3 = z28.object({
3046
3321
  This is required when searchFields is defined.
3047
3322
  `
3048
3323
  ),
3049
- options: z28.array(SelectOption).optional(),
3324
+ options: z29.array(SelectOption).optional(),
3050
3325
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3051
3326
  `
3052
3327
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3067,7 +3342,7 @@ var BaseField3 = z28.object({
3067
3342
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3068
3343
  `
3069
3344
  ),
3070
- conditionals: z28.array(FieldConditional).optional().describe(
3345
+ conditionals: z29.array(FieldConditional).optional().describe(
3071
3346
  `
3072
3347
  In advanced search, we sometimes need to override the default field visibility conditionals.
3073
3348
 
@@ -3081,23 +3356,23 @@ var BaseField3 = z28.object({
3081
3356
  are always rendered in the advanced search form.
3082
3357
  `
3083
3358
  ),
3084
- validations: z28.array(ValidationConfig).optional().describe(
3359
+ validations: z29.array(ValidationConfig).optional().describe(
3085
3360
  `Option for overriding the field validations specifically for advanced search form.`
3086
3361
  ),
3087
3362
  allowedLocations: JurisdictionReference.optional().describe(
3088
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.`
3089
3364
  )
3090
3365
  });
3091
- var SearchQueryParams = z28.object({
3092
- eventType: z28.string().optional().describe(
3366
+ var SearchQueryParams = z29.object({
3367
+ eventType: z29.string().optional().describe(
3093
3368
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3094
3369
  )
3095
3370
  }).catchall(FieldValue);
3096
3371
  var FieldConfigSchema = BaseField3.extend({
3097
- fieldId: z28.string(),
3098
- fieldType: z28.literal("field")
3372
+ fieldId: z29.string(),
3373
+ fieldType: z29.literal("field")
3099
3374
  });
3100
- var EventFieldIdInput = z28.enum([
3375
+ var EventFieldIdInput = z29.enum([
3101
3376
  "trackingId",
3102
3377
  "status",
3103
3378
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3106,7 +3381,7 @@ var EventFieldIdInput = z28.enum([
3106
3381
  "updatedAt"
3107
3382
  ]);
3108
3383
  var METADATA_FIELD_PREFIX = "event.";
3109
- var EventFieldId = z28.enum([
3384
+ var EventFieldId = z29.enum([
3110
3385
  `${METADATA_FIELD_PREFIX}trackingId`,
3111
3386
  `${METADATA_FIELD_PREFIX}status`,
3112
3387
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3116,186 +3391,51 @@ var EventFieldId = z28.enum([
3116
3391
  ]);
3117
3392
  var EventFieldConfigSchema = BaseField3.extend({
3118
3393
  fieldId: EventFieldId,
3119
- fieldType: z28.literal("event")
3394
+ fieldType: z29.literal("event")
3120
3395
  });
3121
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3396
+ var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3122
3397
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3123
3398
  if (!data.label) {
3124
3399
  ctx.addIssue({
3125
- code: z28.ZodIssueCode.custom,
3400
+ code: z29.ZodIssueCode.custom,
3126
3401
  message: "label is required when config.searchFields is defined.",
3127
3402
  path: ["label"]
3128
3403
  });
3129
3404
  }
3130
3405
  if (!data.type) {
3131
3406
  ctx.addIssue({
3132
- code: z28.ZodIssueCode.custom,
3407
+ code: z29.ZodIssueCode.custom,
3133
3408
  message: "type is required when config.searchFields is defined.",
3134
3409
  path: ["type"]
3135
3410
  });
3136
3411
  }
3137
3412
  }
3138
3413
  });
3139
- var AdvancedSearchConfig = z28.object({
3414
+ var AdvancedSearchConfig = z29.object({
3140
3415
  title: TranslationConfig.describe("Advanced search tab title"),
3141
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3416
+ fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3142
3417
  }).meta({
3143
3418
  id: "AdvancedSearchConfig",
3144
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()`)."
3145
3420
  });
3146
3421
 
3147
3422
  // ../commons/src/events/utils.ts
3148
- var import_lodash = require("lodash");
3149
-
3150
- // ../commons/src/conditionals/validate.ts
3151
- var import__ = __toESM(require("ajv/dist/2019"));
3152
- var import_ajv_formats = __toESM(require("ajv-formats"));
3153
- var z31 = __toESM(require("zod/v4"));
3154
- var import_date_fns = require("date-fns");
3155
-
3156
- // ../commons/src/events/FieldTypeMapping.ts
3157
- var z30 = __toESM(require("zod/v4"));
3158
-
3159
- // ../commons/src/events/DynamicFieldValue.ts
3160
- var z29 = __toESM(require("zod/v4"));
3161
-
3162
- // ../commons/src/conditionals/validate.ts
3163
- var ajv = new import__.default({
3164
- $data: true,
3165
- allowUnionTypes: true,
3166
- strict: false
3167
- // Allow minContains and other newer features
3168
- });
3169
- var DataContext = z31.object({
3170
- rootData: z31.object({
3171
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3172
- })
3173
- });
3174
- function resolveDataPath(rootData, dataPath, instancePath) {
3175
- const pathParts = dataPath.split("/");
3176
- const levels = parseInt(pathParts[0], 10);
3177
- const referencePath = pathParts.slice(1);
3178
- const instanceParts = instancePath.split("/").filter(Boolean);
3179
- const traversedParts = instanceParts.slice(0, -levels);
3180
- let current = rootData;
3181
- for (const part of traversedParts) {
3182
- if (current === null || current === void 0) {
3183
- return void 0;
3184
- }
3185
- current = current[part];
3186
- }
3187
- for (const part of referencePath) {
3188
- if (current === null || current === void 0) {
3189
- return void 0;
3190
- }
3191
- current = current[part];
3192
- }
3193
- return current;
3194
- }
3195
- function todayISO() {
3196
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3197
- }
3198
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3199
- function compileClientFunction(code) {
3200
- let fn = compiledFunctionCache.get(code);
3201
- if (!fn) {
3202
- fn = new Function(`return (${code})`)();
3203
- compiledFunctionCache.set(code, fn);
3204
- }
3205
- return fn;
3206
- }
3207
- (0, import_ajv_formats.default)(ajv);
3208
- function buildClientFunctionContext(input) {
3209
- return {
3210
- $form: input.form,
3211
- $now: todayISO(),
3212
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3213
- $online: isOnline(),
3214
- $user: input.validatorContext?.user,
3215
- $event: input.validatorContext?.event,
3216
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3217
- user: input.systemVariables?.user,
3218
- $window: input.systemVariables?.$window,
3219
- locations: input.locations,
3220
- adminLevelIds: input.adminLevelIds
3221
- };
3222
- }
3223
- function runClientFunction(code, data, context) {
3224
- return compileClientFunction(code)(data, context);
3225
- }
3226
- ajv.addKeyword({
3227
- keyword: "daysFromDate",
3228
- type: "string",
3229
- schemaType: "object",
3230
- $data: true,
3231
- errors: true,
3232
- validate(schema, data, _2, dataContext) {
3233
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3234
- throw new Error("Validation context must contain $now");
3235
- }
3236
- const { days, clause } = schema;
3237
- if (typeof data !== "string") {
3238
- return false;
3239
- }
3240
- const date = new Date(data);
3241
- if (isNaN(date.getTime())) {
3242
- return false;
3243
- }
3244
- let referenceDate = schema.referenceDate;
3245
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3246
- referenceDate = resolveDataPath(
3247
- dataContext.rootData,
3248
- referenceDate.$data,
3249
- dataContext.instancePath
3250
- );
3251
- }
3252
- if (!referenceDate) {
3253
- referenceDate = dataContext.rootData.$now;
3254
- }
3255
- const baseDate = new Date(referenceDate);
3256
- if (isNaN(baseDate.getTime())) {
3257
- return false;
3258
- }
3259
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3260
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3261
- }
3262
- });
3263
- ajv.addKeyword({
3264
- keyword: "isLeafLevelLocation",
3265
- type: "string",
3266
- schemaType: "boolean",
3267
- $data: true,
3268
- errors: true,
3269
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3270
- validate(_schema, data, _2, dataContext) {
3271
- const locationIdInput = data;
3272
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3273
- return locations.some((location) => location.id === locationIdInput);
3274
- }
3275
- });
3276
- ajv.addKeyword({
3277
- keyword: "customClientValidator",
3278
- schemaType: "object",
3279
- errors: true,
3280
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3281
- // `validate()` callers build root data via `buildClientFunctionContext`,
3282
- // so the cast holds.
3283
- validate(schema, data, _2, dataContext) {
3284
- return Boolean(
3285
- runClientFunction(
3286
- schema.code,
3287
- data,
3288
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3289
- )
3290
- );
3291
- }
3292
- });
3293
- function isOnline() {
3294
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3295
- return navigator.onLine;
3296
- }
3297
- return true;
3298
- }
3423
+ var import_lodash4 = require("lodash");
3424
+
3425
+ // ../commons/src/conditionals/validate.ts
3426
+ var import__ = __toESM(require("ajv/dist/2019"));
3427
+ var import_ajv_formats = __toESM(require("ajv-formats"));
3428
+ var z33 = __toESM(require("zod/v4"));
3429
+ var import_date_fns2 = require("date-fns");
3430
+
3431
+ // ../commons/src/events/FieldTypeMapping.ts
3432
+ var z31 = __toESM(require("zod/v4"));
3433
+
3434
+ // ../commons/src/events/DynamicFieldValue.ts
3435
+ var z30 = __toESM(require("zod/v4"));
3436
+
3437
+ // ../commons/src/events/state/index.ts
3438
+ var import_lodash3 = require("lodash");
3299
3439
 
3300
3440
  // ../commons/src/utils.ts
3301
3441
  var z32 = __toESM(require("zod/v4"));
@@ -3323,35 +3463,62 @@ function omitKeyDeep(obj, keyToRemove) {
3323
3463
  return newObj;
3324
3464
  }
3325
3465
 
3326
- // ../commons/src/events/utils.ts
3327
- var import_date_fns2 = require("date-fns");
3328
- function getDeclarationFields(configuration) {
3329
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3330
- }
3331
- var getActionAnnotationFields = (actionConfig) => {
3332
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3333
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3334
- }
3335
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3336
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3337
- }
3338
- const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3339
- const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3340
- return [...reviewFields, ...formFields];
3341
- };
3342
- function getAllAnnotationFields(config) {
3343
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3344
- }
3345
- var findAllFields = (config) => {
3346
- return (0, import_lodash.flattenDeep)([
3347
- ...getDeclarationFields(config),
3348
- ...getAllAnnotationFields(config)
3349
- ]);
3350
- };
3351
- var EXCLUDED_ACTIONS = [
3352
- 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,
3353
3477
  ActionType.PRINT_CERTIFICATE,
3354
- 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
+ }
3355
3522
  ];
3356
3523
 
3357
3524
  // ../commons/src/conditionals/conditionals.ts
@@ -3560,6 +3727,33 @@ function defineComparison(field3, value, keyword) {
3560
3727
  required: [field3.$$field]
3561
3728
  });
3562
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
+ }
3563
3757
  function createFieldConditionals(fieldId) {
3564
3758
  const getDayRange = (field3, days, clause, referenceDate) => ({
3565
3759
  type: "object",
@@ -3961,6 +4155,176 @@ function createFieldConditionals(fieldId) {
3961
4155
  };
3962
4156
  }
3963
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
+
3964
4328
  // ../commons/src/events/eventConfigValidation.ts
3965
4329
  function validateAdvancedSearchConfig(event2, ctx) {
3966
4330
  const allFields = findAllFields(event2);
@@ -4043,9 +4407,9 @@ function validatePlaceOfEvent(event2, ctx) {
4043
4407
  }
4044
4408
  function validateActionFlags(event2, ctx) {
4045
4409
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4046
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4410
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4047
4411
  const actionFlagIds = event2.actions.flatMap(
4048
- (action) => (action.flags ?? []).map((flag) => flag.id)
4412
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4049
4413
  );
4050
4414
  for (const actionFlagId of actionFlagIds) {
4051
4415
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4081,11 +4445,11 @@ function validateActionOrder(event2, ctx) {
4081
4445
  }
4082
4446
 
4083
4447
  // ../commons/src/events/EventConfig.ts
4084
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4448
+ var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4085
4449
  "Reference to a field defined in the event metadata, using the field id."
4086
4450
  );
4087
- var _EventConfigBase = z33.object({
4088
- id: z33.string().describe(
4451
+ var _EventConfigBase = z34.object({
4452
+ id: z34.string().describe(
4089
4453
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4090
4454
  ),
4091
4455
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4104,23 +4468,26 @@ var _EventConfigBase = z33.object({
4104
4468
  "Summary information displayed in the event overview."
4105
4469
  ),
4106
4470
  label: TranslationConfig.describe("Human-readable label for the event type."),
4107
- actions: z33.array(ActionConfig).describe(
4471
+ actions: z34.array(ActionConfig).describe(
4108
4472
  "Configuration of core and custom actions associated with the event."
4109
4473
  ),
4110
- actionOrder: z33.array(z33.string()).optional().describe(
4474
+ actionOrder: z34.array(z34.string()).optional().describe(
4111
4475
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4112
4476
  ),
4113
4477
  declaration: DeclarationFormConfig.describe(
4114
4478
  "Configuration of the form used to gather event data."
4115
4479
  ),
4116
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4480
+ advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
4117
4481
  "Configuration of fields available in the advanced search feature."
4118
4482
  ),
4119
- flags: z33.array(FlagConfig).optional().default([]).describe(
4483
+ flags: z34.array(FlagConfig).optional().default([]).describe(
4120
4484
  "Configuration of custom flags associated with the actions of this event type."
4121
4485
  ),
4122
- analytics: z33.boolean().optional().default(true).describe(
4486
+ analytics: z34.boolean().optional().default(true).describe(
4123
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.'
4124
4491
  )
4125
4492
  });
4126
4493
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4337,21 +4704,31 @@ var event = Object.assign(eventFn, {
4337
4704
  return {
4338
4705
  $event: field3
4339
4706
  };
4340
- }
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)
4341
4718
  });
4342
4719
 
4343
4720
  // ../commons/src/events/WorkqueueColumnConfig.ts
4344
- var z34 = __toESM(require("zod/v4"));
4721
+ var z35 = __toESM(require("zod/v4"));
4345
4722
  var WorkqueueColumnKeysArray = [
4346
4723
  ...EventMetadataKeysArray,
4347
4724
  "title",
4348
4725
  "outbox"
4349
4726
  ];
4350
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4351
- var WorkqueueColumnValue = z34.object({
4727
+ var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
4728
+ var WorkqueueColumnValue = z35.object({
4352
4729
  $event: WorkqueueColumnKeys
4353
4730
  });
4354
- var WorkqueueColumn = z34.object({
4731
+ var WorkqueueColumn = z35.object({
4355
4732
  label: TranslationConfig,
4356
4733
  value: WorkqueueColumnValue
4357
4734
  }).meta({
@@ -4365,164 +4742,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4365
4742
  }
4366
4743
 
4367
4744
  // ../commons/src/events/CountryConfigQueryInput.ts
4368
- var z35 = __toESM(require("zod/v4"));
4369
- var SerializableExact = z35.object({
4370
- type: z35.literal("exact"),
4371
- term: z35.union([z35.string(), SerializedUserField])
4372
- });
4373
- var SerializableWithin = z35.object({
4374
- type: z35.literal("within"),
4375
- location: z35.union([z35.string(), SerializedUserField])
4376
- });
4377
- var SerializedQueryExpression = z35.object({
4378
- eventType: z35.string(),
4379
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4380
- createdAt: z35.optional(DateCondition),
4381
- updatedAt: z35.optional(DateCondition),
4382
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4383
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4384
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4385
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4386
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4387
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4388
- createdAtLocation: z35.optional(
4389
- 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])
4390
4767
  ),
4391
- updatedAtLocation: z35.optional(
4392
- z35.union([SerializableWithin, SerializableExact])
4768
+ updatedAtLocation: z36.optional(
4769
+ z36.union([SerializableWithin, SerializableExact])
4393
4770
  ),
4394
- updatedByUserRole: z35.optional(SerializableExact),
4395
- assignedTo: z35.optional(SerializableExact),
4396
- createdBy: z35.optional(SerializableExact),
4771
+ updatedByUserRole: z36.optional(SerializableExact),
4772
+ assignedTo: z36.optional(SerializableExact),
4773
+ createdBy: z36.optional(SerializableExact),
4397
4774
  createdByUserType: ExactUserType,
4398
- updatedBy: z35.optional(SerializableExact),
4399
- trackingId: z35.optional(Exact),
4400
- flags: z35.optional(ContainsFlags),
4775
+ updatedBy: z36.optional(SerializableExact),
4776
+ trackingId: z36.optional(Exact),
4777
+ flags: z36.optional(ContainsFlags),
4401
4778
  data: QueryInput
4402
4779
  }).partial();
4403
- var Or2 = z35.object({
4404
- type: z35.literal("or"),
4405
- clauses: z35.array(SerializedQueryExpression)
4780
+ var Or2 = z36.object({
4781
+ type: z36.literal("or"),
4782
+ clauses: z36.array(SerializedQueryExpression)
4406
4783
  });
4407
- var And2 = z35.object({
4408
- type: z35.literal("and"),
4409
- clauses: z35.array(SerializedQueryExpression)
4784
+ var And2 = z36.object({
4785
+ type: z36.literal("and"),
4786
+ clauses: z36.array(SerializedQueryExpression)
4410
4787
  });
4411
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4412
- var CountryConfigQueryInputType = z35.union([
4788
+ var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
4789
+ var CountryConfigQueryInputType = z36.union([
4413
4790
  SerializedQueryExpression,
4414
4791
  And2,
4415
4792
  Or2
4416
4793
  ]);
4417
4794
 
4418
- // ../commons/src/icons.ts
4419
- var z36 = __toESM(require("zod/v4"));
4420
- var AvailableIcons = z36.enum([
4421
- "Archived",
4422
- "Assigned",
4423
- "Briefcase",
4424
- "Certified",
4425
- "Close",
4426
- "Collapse",
4427
- "Draft",
4428
- "DuplicateYellow",
4429
- "Expand",
4430
- "ExternalValidate",
4431
- "FilledCheck",
4432
- "InReview",
4433
- "Offline",
4434
- "Registered",
4435
- "RequiresUpdates",
4436
- "Sent",
4437
- "Validated",
4438
- "WaitingApproval",
4439
- "ChartActivity",
4440
- "Activity",
4441
- "Archive",
4442
- "ArchiveTray",
4443
- "ArrowLeft",
4444
- "ArrowRight",
4445
- "Buildings",
4446
- "Circle",
4447
- "CaretDown",
4448
- "CaretLeft",
4449
- "CaretRight",
4450
- "ChartBar",
4451
- "ChartLine",
4452
- "ChatCircle",
4453
- "CheckSquare",
4454
- "Compass",
4455
- "Check",
4456
- "Copy",
4457
- "Database",
4458
- "DotsThreeVertical",
4459
- "ArrowCounterClockwise",
4460
- "MagnifyingGlassMinus",
4461
- "MagnifyingGlassPlus",
4462
- "Export",
4463
- "Eye",
4464
- "EyeSlash",
4465
- "Envelope",
4466
- "File",
4467
- "FileSearch",
4468
- "FileMinus",
4469
- "FilePlus",
4470
- "FileText",
4471
- "FileX",
4472
- "Handshake",
4473
- "Gear",
4474
- "GitBranch",
4475
- "IdentificationCard",
4476
- "List",
4477
- "ListBullets",
4478
- "Lock",
4479
- "MagnifyingGlass",
4480
- "MapPin",
4481
- "Medal",
4482
- "NotePencil",
4483
- "Paperclip",
4484
- "PaperPlaneTilt",
4485
- "Pen",
4486
- "PenNib",
4487
- "Pencil",
4488
- "PencilSimpleLine",
4489
- "Phone",
4490
- "Plus",
4491
- "Printer",
4492
- "SignOut",
4493
- "Stamp",
4494
- "Star",
4495
- "Target",
4496
- "TextT",
4497
- "Trash",
4498
- "UploadSimple",
4499
- "User",
4500
- "UserPlus",
4501
- "Users",
4502
- "WarningCircle",
4503
- "X",
4504
- "ChatText",
4505
- "CircleWavyCheck",
4506
- "CircleWavyQuestion",
4507
- "ArchiveBox",
4508
- "ArrowCircleDown",
4509
- "FileArrowUp",
4510
- "FileDotted",
4511
- "Files",
4512
- "PencilLine",
4513
- "PencilCircle",
4514
- "UserCircle",
4515
- "Clock",
4516
- "QrCode",
4517
- "Webcam",
4518
- "Sun",
4519
- "DeviceTabletCamera",
4520
- "Globe",
4521
- "Fingerprint",
4522
- "PushPin",
4523
- "Timer"
4524
- ]);
4525
-
4526
4795
  // ../commons/src/events/WorkqueueConfig.ts
4527
4796
  var mandatoryColumns = defineWorkqueuesColumns([
4528
4797
  {
@@ -4692,7 +4961,11 @@ var MarkNotDuplicateActionInput = BaseActionInput.extend(
4692
4961
  var ArchiveActionInput = BaseActionInput.extend(
4693
4962
  z38.object({
4694
4963
  type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4695
- 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()
4696
4969
  }).shape
4697
4970
  );
4698
4971
  var UnarchiveActionInput = BaseActionInput.extend(
@@ -4802,14 +5075,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4802
5075
 
4803
5076
  // ../commons/src/events/EventInput.ts
4804
5077
  var z40 = __toESM(require("zod/v4"));
4805
- var import_uuid10 = require("uuid");
5078
+ var import_uuid11 = require("uuid");
4806
5079
  var EventInput = z40.object({
4807
5080
  transactionId: z40.string(),
4808
5081
  type: z40.string(),
4809
5082
  createdAtLocation: UUID.nullish().describe(
4810
5083
  "Location where the event occurred. Required for system users."
4811
5084
  )
4812
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5085
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4813
5086
 
4814
5087
  // ../commons/src/events/EventDocument.ts
4815
5088
  var z41 = __toESM(require("zod/v4"));
@@ -4826,67 +5099,6 @@ var EventDocument = z41.object({
4826
5099
  )
4827
5100
  }).meta({ id: "EventDocument" });
4828
5101
 
4829
- // ../commons/src/events/state/index.ts
4830
- var import_lodash4 = require("lodash");
4831
-
4832
- // ../commons/src/events/state/utils.ts
4833
- var import_lodash2 = require("lodash");
4834
- var updateActions = ActionTypes.extract([
4835
- ActionType.CREATE,
4836
- ActionType.NOTIFY,
4837
- ActionType.EDIT,
4838
- ActionType.DECLARE,
4839
- ActionType.REGISTER,
4840
- ActionType.REJECT,
4841
- ActionType.ARCHIVE,
4842
- ActionType.UNARCHIVE,
4843
- ActionType.PRINT_CERTIFICATE,
4844
- ActionType.REQUEST_CORRECTION,
4845
- ActionType.APPROVE_CORRECTION,
4846
- ActionType.REJECT_CORRECTION,
4847
- ActionType.CUSTOM
4848
- ]);
4849
-
4850
- // ../commons/src/events/state/flags.ts
4851
- var import_lodash3 = require("lodash");
4852
- var import_date_fns3 = require("date-fns");
4853
- var INHERENT_FLAG_RULES = [
4854
- {
4855
- flag: InherentFlags.CORRECTION_REQUESTED,
4856
- setOn: [ActionType.REQUEST_CORRECTION],
4857
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4858
- },
4859
- {
4860
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4861
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4862
- // are deliberately excluded so the flag freezes across an archive/unarchive
4863
- // round trip and comes back exactly as it was.
4864
- flag: InherentFlags.INCOMPLETE,
4865
- setOn: [ActionType.NOTIFY],
4866
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4867
- },
4868
- {
4869
- flag: InherentFlags.REJECTED,
4870
- setOn: [ActionType.REJECT],
4871
- resetOn: [
4872
- ActionType.NOTIFY,
4873
- ActionType.DECLARE,
4874
- ActionType.EDIT,
4875
- ActionType.REGISTER
4876
- ]
4877
- },
4878
- {
4879
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4880
- setOn: [ActionType.DUPLICATE_DETECTED],
4881
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4882
- },
4883
- {
4884
- flag: InherentFlags.EDIT_IN_PROGRESS,
4885
- setOn: [ActionType.EDIT],
4886
- resetOnAnyOtherAction: true
4887
- }
4888
- ];
4889
-
4890
5102
  // ../commons/src/events/defineConfig.ts
4891
5103
  var IGNORED_EVENT_TYPES = [
4892
5104
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7384,18 +7596,63 @@ var Location = z43.object({
7384
7596
  status: LocationStatus,
7385
7597
  versions: z43.array(LocationVersion)
7386
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
+ });
7387
7642
  var SetLocationPayload = z43.object({
7388
7643
  id: UUID,
7389
7644
  name: z43.string(),
7390
7645
  externalId: z43.string().nullish(),
7391
7646
  administrativeAreaId: UUID.nullable(),
7392
- locationType: z43.string().nullable()
7647
+ locationType: z43.string().nullable(),
7648
+ versions: SeededLocationVersions.optional()
7393
7649
  });
7394
7650
  var SetAdministrativeAreaPayload = z43.object({
7395
7651
  id: UUID,
7396
7652
  name: z43.string(),
7397
7653
  externalId: z43.string().nullish(),
7398
- parentId: UUID.nullable()
7654
+ parentId: UUID.nullable(),
7655
+ versions: SeededLocationVersions.optional()
7399
7656
  });
7400
7657
 
7401
7658
  // ../commons/src/events/scopes.ts
@@ -7432,8 +7689,7 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7432
7689
  ActionType.READ,
7433
7690
  ActionType.DECLARE,
7434
7691
  ActionType.NOTIFY,
7435
- ActionType.DELETE,
7436
- ActionType.CUSTOM
7692
+ ActionType.DELETE
7437
7693
  ],
7438
7694
  [EventStatus.enum.NOTIFIED]: [
7439
7695
  ActionType.READ,
@@ -7468,20 +7724,20 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7468
7724
  ]
7469
7725
  };
7470
7726
  var ACTION_FILTERS = {
7471
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7472
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7473
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7474
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7475
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7476
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7477
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7478
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7479
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7480
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7481
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7482
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7483
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7484
- [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"))
7485
7741
  };
7486
7742
  var REJECTED_ACTIONS = [
7487
7743
  ActionType.READ,
@@ -7826,69 +8082,171 @@ var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7826
8082
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7827
8083
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7828
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
+ );
7829
8094
 
7830
- // ../commons/src/notification/UserNotifications.ts
8095
+ // ../commons/src/events/locationPayloads.ts
7831
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"));
7832
8182
  var TriggerEvent = {
7833
8183
  USER_CREATED: "user-created",
7834
8184
  USER_UPDATED: "user-updated",
7835
8185
  USERNAME_REMINDER: "username-reminder",
7836
8186
  RESET_PASSWORD: "reset-password",
7837
8187
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8188
+ PASSWORD_RESET_LINK: "password-reset-link",
8189
+ USERNAME_REMINDER_LINK: "username-reminder-link",
7838
8190
  RESEND_INVITE: "resend-invite",
7839
8191
  TWO_FA: "2fa",
7840
8192
  ALL_USER_NOTIFICATION: "all-user-notification",
7841
8193
  CHANGE_PHONE_NUMBER: "change-phone-number",
7842
8194
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7843
8195
  };
7844
- var Recipient = z44.object({
8196
+ var Recipient = z45.object({
7845
8197
  name: NameFieldValue.optional(),
7846
- mobile: z44.string().optional(),
7847
- email: z44.string().optional(),
7848
- bcc: z44.array(z44.string()).optional()
8198
+ mobile: z45.string().optional(),
8199
+ email: z45.string().optional(),
8200
+ bcc: z45.array(z45.string()).optional()
7849
8201
  });
7850
- var BasePayload = z44.object({
8202
+ var BasePayload = z45.object({
7851
8203
  recipient: Recipient
7852
8204
  });
7853
8205
  var TriggerPayload = {
7854
8206
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7855
- username: z44.string(),
7856
- temporaryPassword: z44.string()
8207
+ username: z45.string(),
8208
+ temporaryPassword: z45.string()
7857
8209
  }),
7858
8210
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7859
- oldUsername: z44.string(),
7860
- newUsername: z44.string()
8211
+ oldUsername: z45.string(),
8212
+ newUsername: z45.string()
7861
8213
  }),
7862
8214
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7863
- username: z44.string()
8215
+ username: z45.string()
7864
8216
  }),
7865
8217
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7866
- code: z44.string()
8218
+ code: z45.string()
7867
8219
  }),
7868
8220
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7869
- temporaryPassword: z44.string(),
7870
- admin: z44.object({
7871
- id: z44.string(),
8221
+ temporaryPassword: z45.string(),
8222
+ admin: z45.object({
8223
+ id: z45.string(),
7872
8224
  name: NameFieldValue,
7873
- role: z44.string()
8225
+ role: z45.string()
7874
8226
  })
7875
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
+ }),
7876
8234
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7877
- username: z44.string(),
7878
- temporaryPassword: z44.string()
8235
+ username: z45.string(),
8236
+ temporaryPassword: z45.string()
7879
8237
  }),
7880
8238
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7881
- code: z44.string()
8239
+ code: z45.string()
7882
8240
  }),
7883
8241
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7884
- subject: z44.string(),
7885
- body: z44.string()
8242
+ subject: z45.string(),
8243
+ body: z45.string()
7886
8244
  }),
7887
8245
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7888
- code: z44.string()
8246
+ code: z45.string()
7889
8247
  }),
7890
8248
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7891
- code: z44.string()
8249
+ code: z45.string()
7892
8250
  })
7893
8251
  };
7894
8252
  async function triggerUserEventNotification({
@@ -7897,14 +8255,23 @@ async function triggerUserEventNotification({
7897
8255
  countryConfigUrl,
7898
8256
  authHeader
7899
8257
  }) {
7900
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
7901
- method: "POST",
7902
- body: JSON.stringify(payload),
7903
- headers: {
7904
- "Content-Type": "application/json",
7905
- ...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
+ }
7906
8267
  }
7907
- });
8268
+ );
8269
+ if (!response.ok) {
8270
+ logger.error(
8271
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8272
+ );
8273
+ }
8274
+ return response;
7908
8275
  }
7909
8276
  function parseUserEventTrigger(event2, body) {
7910
8277
  const schema = TriggerPayload[event2];
@@ -7912,4 +8279,4 @@ function parseUserEventTrigger(event2, body) {
7912
8279
  }
7913
8280
 
7914
8281
  // src/notification/index.ts
7915
- z45.globalRegistry.clear();
8282
+ z46.globalRegistry.clear();