@opencrvs/toolkit 2.1.0-rc.75e32d8 → 2.1.0-rc.7737766

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 (134) hide show
  1. package/README.md +1 -0
  2. package/build.sh +9 -1
  3. package/create-countryconfig/index.js +412 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +4 -1
  6. package/dist/application-config/index.js +349 -277
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +754 -0
  10. package/dist/cli.js +1782 -113
  11. package/dist/commons/api/router.d.ts +3976 -3374
  12. package/dist/commons/application-config/index.d.ts +6 -6
  13. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +109 -105
  16. package/dist/commons/events/ActionDocument.d.ts +121 -127
  17. package/dist/commons/events/ActionInput.d.ts +4 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +62 -62
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +543 -507
  21. package/dist/commons/events/AuditLog.d.ts +189 -42
  22. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  23. package/dist/commons/events/Conditional.d.ts +3 -3
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  25. package/dist/commons/events/Draft.d.ts +37 -37
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -5
  28. package/dist/commons/events/EventDocument.d.ts +518 -50
  29. package/dist/commons/events/EventIndex.d.ts +49 -72
  30. package/dist/commons/events/EventMetadata.d.ts +39 -49
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +434 -389
  33. package/dist/commons/events/FieldType.d.ts +51 -51
  34. package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
  35. package/dist/commons/events/FieldValue.d.ts +14 -14
  36. package/dist/commons/events/Flag.d.ts +57 -15
  37. package/dist/commons/events/FormConfig.d.ts +6 -0
  38. package/dist/commons/events/PageConfig.d.ts +4 -0
  39. package/dist/commons/events/PlainDate.d.ts +8 -0
  40. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  41. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  42. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  43. package/dist/commons/events/WorkqueueConfig.d.ts +817 -814
  44. package/dist/commons/events/deduplication.d.ts +1 -1
  45. package/dist/commons/events/event.d.ts +14 -2
  46. package/dist/commons/events/field.d.ts +69 -198
  47. package/dist/commons/events/index.d.ts +1 -0
  48. package/dist/commons/events/locationPayloads.d.ts +95 -0
  49. package/dist/commons/events/locations.d.ts +247 -14
  50. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  51. package/dist/commons/events/scopes.d.ts +4 -4
  52. package/dist/commons/events/state/index.d.ts +17 -17
  53. package/dist/commons/events/state/utils.d.ts +7 -7
  54. package/dist/commons/events/test.utils.d.ts +64 -46
  55. package/dist/commons/events/utils.d.ts +129 -114
  56. package/dist/commons/notification/UserNotifications.d.ts +38 -23
  57. package/dist/commons/notification/dispatch.d.ts +10 -0
  58. package/dist/commons/notification/index.d.ts +1 -0
  59. package/dist/conditionals/index.js +334 -60
  60. package/dist/csv.d.ts +25 -0
  61. package/dist/csv.d.ts.map +1 -0
  62. package/dist/csv.js +120 -0
  63. package/dist/environment/derived-variables.d.ts +119 -119
  64. package/dist/environment/derived-variables.d.ts.map +1 -1
  65. package/dist/environment/index.d.ts +1 -0
  66. package/dist/environment/index.d.ts.map +1 -1
  67. package/dist/environment/index.js +10 -0
  68. package/dist/environment/logger.d.ts +6 -3
  69. package/dist/environment/logger.d.ts.map +1 -1
  70. package/dist/environment/manage-users.js +17 -7
  71. package/dist/environment/paths.d.ts +7 -0
  72. package/dist/environment/paths.d.ts.map +1 -0
  73. package/dist/environment/paths.js +72 -0
  74. package/dist/environment/questions.d.ts +75 -74
  75. package/dist/environment/questions.d.ts.map +1 -1
  76. package/dist/environment/questions.js +20 -14
  77. package/dist/environment/setup-environment.js +36 -21
  78. package/dist/environment/swarm-to-k8s.js +17 -7
  79. package/dist/environment/templates.d.ts.map +1 -1
  80. package/dist/environment/templates.js +2 -1
  81. package/dist/environment/update-workflows.d.ts.map +1 -1
  82. package/dist/environment/update-workflows.js +34 -12
  83. package/dist/environment/upgrade.d.ts +2 -0
  84. package/dist/environment/upgrade.d.ts.map +1 -0
  85. package/dist/environment/upgrade.js +82 -0
  86. package/dist/environment/users.js +28 -20
  87. package/dist/environment/utils.d.ts +1 -1
  88. package/dist/environment/utils.js +17 -7
  89. package/dist/events/deduplication.d.ts +1 -1
  90. package/dist/events/index.js +7641 -7128
  91. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  92. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  93. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  94. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  95. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  96. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  97. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  98. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  99. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  100. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  101. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  102. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  103. package/dist/migrations/v2.1/add-translations.js +213 -0
  104. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  105. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  106. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  107. package/dist/migrations/v2.1/index.d.ts.map +1 -1
  108. package/dist/migrations/v2.1/index.js +1058 -0
  109. package/dist/notification/index.js +1870 -1464
  110. package/dist/scopes/index.d.ts +560 -157
  111. package/dist/scopes/index.js +335 -60
  112. package/dist/telemetry/index.d.ts +45 -0
  113. package/dist/telemetry/index.d.ts.map +1 -0
  114. package/dist/telemetry/index.js +39 -0
  115. package/dist/templates/charts-values/dependencies/values.yaml +2 -0
  116. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -3
  117. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  118. package/dist/templates/charts-values/traefik/values.yaml +23 -9
  119. package/dist/templates/inventory/inventory.template.yml +1 -3
  120. package/dist/translations/check.d.ts +21 -0
  121. package/dist/translations/check.d.ts.map +1 -0
  122. package/dist/translations/check.js +132 -0
  123. package/dist/verify/endpoints.d.ts +2 -0
  124. package/dist/verify/endpoints.d.ts.map +1 -0
  125. package/dist/verify/endpoints.js +345 -0
  126. package/opencrvs-toolkit-2.1.0-rc.7737766.tgz +0 -0
  127. package/package.json +12 -7
  128. package/tsconfig.build.json +11 -0
  129. package/tsconfig.build.tsbuildinfo +1 -0
  130. package/tsconfig.json +3 -0
  131. package/dist/templates/inventory/production.example.yml +0 -77
  132. package/dist/templates/inventory/qa.example.yml +0 -48
  133. package/opencrvs-toolkit-2.1.0-rc.75e32d8.tgz +0 -0
  134. package/tsconfig.tsbuildinfo +0 -1
@@ -38,23 +38,17 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z45 = __toESM(require("zod/v4"));
42
-
43
- // ../commons/src/url.ts
44
- function joinUrl(base, path) {
45
- const baseWithSlash = base.endsWith("/") ? base : base + "/";
46
- return new URL(path, baseWithSlash);
47
- }
41
+ var z47 = __toESM(require("zod/v4"));
48
42
 
49
43
  // ../commons/src/events/AuditLog.ts
50
- var z5 = __toESM(require("zod/v4"));
44
+ var z9 = __toESM(require("zod/v4"));
51
45
 
52
46
  // ../commons/src/authentication.ts
53
47
  var import_jwt_decode = __toESM(require("jwt-decode"));
54
- var z3 = __toESM(require("zod/v4"));
48
+ var z8 = __toESM(require("zod/v4"));
55
49
 
56
50
  // ../commons/src/scopes.ts
57
- var z2 = __toESM(require("zod/v4"));
51
+ var z7 = __toESM(require("zod/v4"));
58
52
  var qs = __toESM(require("qs"));
59
53
 
60
54
  // ../commons/src/uuid.ts
@@ -65,12 +59,270 @@ function getUUID() {
65
59
  return (0, import_uuid.v4)();
66
60
  }
67
61
 
62
+ // ../commons/src/events/ActionType.ts
63
+ var z2 = __toESM(require("zod/v4"));
64
+ var ActionType = {
65
+ // Pre-declaration actions
66
+ DELETE: "DELETE",
67
+ CREATE: "CREATE",
68
+ NOTIFY: "NOTIFY",
69
+ // Declaration actions
70
+ DECLARE: "DECLARE",
71
+ REGISTER: "REGISTER",
72
+ EDIT: "EDIT",
73
+ // Declaration system actions. Non-configurable.
74
+ DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
75
+ REJECT: "REJECT",
76
+ // REJECT_DECLARATION
77
+ MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
78
+ MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
79
+ ARCHIVE: "ARCHIVE",
80
+ UNARCHIVE: "UNARCHIVE",
81
+ // Record actions
82
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
83
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
84
+ REJECT_CORRECTION: "REJECT_CORRECTION",
85
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
86
+ // General actions
87
+ READ: "READ",
88
+ ASSIGN: "ASSIGN",
89
+ UNASSIGN: "UNASSIGN",
90
+ // Custom action
91
+ CUSTOM: "CUSTOM"
92
+ };
93
+ var ConfirmableActions = [
94
+ ActionType.NOTIFY,
95
+ ActionType.DECLARE,
96
+ ActionType.EDIT,
97
+ ActionType.REGISTER,
98
+ ActionType.REJECT,
99
+ ActionType.ARCHIVE,
100
+ ActionType.UNARCHIVE,
101
+ ActionType.PRINT_CERTIFICATE,
102
+ ActionType.REQUEST_CORRECTION,
103
+ ActionType.APPROVE_CORRECTION,
104
+ ActionType.REJECT_CORRECTION,
105
+ ActionType.CUSTOM
106
+ ];
107
+ var ActionTypes = z2.enum([
108
+ "DELETE",
109
+ "CREATE",
110
+ "NOTIFY",
111
+ "DECLARE",
112
+ "EDIT",
113
+ "REGISTER",
114
+ "DUPLICATE_DETECTED",
115
+ "REJECT",
116
+ "MARK_AS_DUPLICATE",
117
+ "MARK_AS_NOT_DUPLICATE",
118
+ "ARCHIVE",
119
+ "UNARCHIVE",
120
+ "PRINT_CERTIFICATE",
121
+ "REQUEST_CORRECTION",
122
+ "REJECT_CORRECTION",
123
+ "APPROVE_CORRECTION",
124
+ "READ",
125
+ "ASSIGN",
126
+ "UNASSIGN",
127
+ "CUSTOM"
128
+ ]);
129
+ var ClientSpecificAction = {
130
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
131
+ };
132
+ var declarationActionValues = [
133
+ ActionTypes.enum.DECLARE,
134
+ ActionTypes.enum.EDIT,
135
+ ActionTypes.enum.REGISTER,
136
+ ActionTypes.enum.NOTIFY,
137
+ ActionTypes.enum.DUPLICATE_DETECTED
138
+ ];
139
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
140
+ var declarationUpdateActionValues = [
141
+ ...declarationActionValues,
142
+ ActionTypes.enum.REQUEST_CORRECTION
143
+ ];
144
+ var DeclarationUpdateActions = ActionTypes.extract(
145
+ declarationUpdateActionValues
146
+ );
147
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
148
+ var writeActions = ActionTypes.exclude([
149
+ ActionType.CREATE,
150
+ ActionType.READ,
151
+ ActionType.ASSIGN,
152
+ ActionType.UNASSIGN
153
+ ]);
154
+ var WorkqueueActionType = ActionTypes.extract([
155
+ ActionType.READ,
156
+ ActionType.DELETE,
157
+ ActionType.DECLARE,
158
+ ActionType.REGISTER,
159
+ ActionType.EDIT,
160
+ ActionType.REJECT,
161
+ ActionType.MARK_AS_DUPLICATE,
162
+ ActionType.ARCHIVE,
163
+ ActionType.UNARCHIVE,
164
+ ActionType.PRINT_CERTIFICATE,
165
+ ActionType.REQUEST_CORRECTION
166
+ ]);
167
+ var META_ACTIONS = [
168
+ ActionType.ASSIGN,
169
+ ActionType.UNASSIGN,
170
+ ActionType.READ
171
+ ];
172
+
173
+ // ../commons/src/events/ActionStatus.ts
174
+ var ActionStatus = {
175
+ Requested: "Requested",
176
+ Accepted: "Accepted",
177
+ Rejected: "Rejected"
178
+ };
179
+
180
+ // ../commons/src/events/Flag.ts
181
+ var z5 = __toESM(require("zod/v4"));
182
+
183
+ // ../commons/src/events/TranslationConfig.ts
184
+ var z3 = __toESM(require("zod/v4"));
185
+ var TranslationConfig = z3.object({
186
+ id: z3.string().describe(
187
+ "The identifier of the translation referred in translation CSV files"
188
+ ),
189
+ defaultMessage: z3.string().describe("Default translation message"),
190
+ description: z3.string().describe(
191
+ "Describe the translation for a translator to be able to identify it."
192
+ )
193
+ }).meta({
194
+ description: "Translation configuration",
195
+ id: "TranslationConfig"
196
+ });
197
+
198
+ // ../commons/src/events/Conditional.ts
199
+ var z4 = __toESM(require("zod/v4"));
200
+ var Conditional = z4.any().describe("JSONSchema").meta({
201
+ description: "JSON schema conditional configuration",
202
+ id: "Conditional"
203
+ });
204
+ var ConditionalType = {
205
+ SHOW: "SHOW",
206
+ ENABLE: "ENABLE",
207
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
208
+ };
209
+ var ShowConditional = z4.object({
210
+ type: z4.literal(ConditionalType.SHOW),
211
+ conditional: Conditional
212
+ }).describe(
213
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
214
+ );
215
+ var EnableConditional = z4.object({
216
+ type: z4.literal(ConditionalType.ENABLE),
217
+ conditional: Conditional
218
+ }).describe(
219
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
220
+ );
221
+ var ActionConditional = z4.discriminatedUnion("type", [
222
+ // Action can be shown / hidden
223
+ ShowConditional,
224
+ // Action can be shown to the user in the list but as disabled
225
+ EnableConditional
226
+ ]).meta({
227
+ id: "ActionConditional",
228
+ 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."
229
+ });
230
+ var DisplayOnReviewConditional = z4.object({
231
+ type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
232
+ conditional: Conditional
233
+ }).describe(
234
+ "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."
235
+ );
236
+ var FieldConditional = z4.discriminatedUnion("type", [
237
+ // Field input can be shown / hidden
238
+ ShowConditional,
239
+ // Field input can be shown to the user but as disabled
240
+ EnableConditional,
241
+ // Field output can be shown / hidden on the review page
242
+ DisplayOnReviewConditional
243
+ ]).meta({
244
+ id: "FieldConditional",
245
+ 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."
246
+ });
247
+
248
+ // ../commons/src/events/Flag.ts
249
+ var InherentFlags = {
250
+ INCOMPLETE: "incomplete",
251
+ REJECTED: "rejected",
252
+ CORRECTION_REQUESTED: "correction-requested",
253
+ POTENTIAL_DUPLICATE: "potential-duplicate",
254
+ /**
255
+ * This flag is set by the Edit-action and removed after the declaration or registration.
256
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
257
+ *
258
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
259
+ */
260
+ EDIT_IN_PROGRESS: "edit-in-progress"
261
+ };
262
+ var actionFlagPattern;
263
+ function getActionFlagPattern() {
264
+ actionFlagPattern ??= new RegExp(
265
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
266
+ ActionStatus
267
+ ).join("|").toLowerCase()})$`
268
+ );
269
+ return actionFlagPattern;
270
+ }
271
+ var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
272
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
273
+ });
274
+ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
275
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
276
+ InherentFlags
277
+ ).join(", ")}`
278
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
279
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
280
+ }).describe("Custom flag identifier defined by the country config.");
281
+ var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
282
+ var ContainsFlags = z5.object({
283
+ anyOf: z5.array(Flag).optional(),
284
+ noneOf: z5.array(Flag).optional(),
285
+ allOf: z5.array(Flag).optional()
286
+ }).meta({
287
+ id: "ContainsFlags"
288
+ });
289
+ var FlagConfig = z5.object({
290
+ id: CustomFlag,
291
+ requiresAction: z5.boolean().describe(
292
+ "Indicates if this flag expects an action to be performed to be cleared."
293
+ ),
294
+ label: TranslationConfig.describe("Human readable label of the flag.")
295
+ }).meta({
296
+ id: "FlagConfig",
297
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
298
+ });
299
+ var ActionFlagConfig = z5.object({
300
+ id: Flag,
301
+ operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
302
+ conditional: Conditional.optional().describe(
303
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
304
+ )
305
+ }).meta({
306
+ id: "ActionFlagConfig",
307
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
308
+ });
309
+
310
+ // ../commons/src/events/EventStatus.ts
311
+ var z6 = __toESM(require("zod/v4"));
312
+ var EventStatus = z6.enum([
313
+ "CREATED",
314
+ "NOTIFIED",
315
+ "DECLARED",
316
+ "REGISTERED",
317
+ "ARCHIVED"
318
+ ]);
319
+
68
320
  // ../commons/src/scopes.ts
69
- var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
321
+ var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
70
322
  "Filters based on user jurisdiction relative to their office location in hierarchy."
71
323
  );
72
- var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
73
- var RecordScopeTypeV2 = z2.enum([
324
+ var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
+ var RecordScopeTypeV2 = z7.enum([
74
326
  "record.search",
75
327
  "record.create",
76
328
  "record.read",
@@ -88,14 +340,20 @@ var RecordScopeTypeV2 = z2.enum([
88
340
  "record.unassign-others",
89
341
  "record.custom-action"
90
342
  ]);
91
- var PlainScopeType = z2.enum([
343
+ var PlainScopeType = z7.enum([
92
344
  // Misc. system scopes
93
345
  "bypassratelimit",
94
346
  "record.reindex",
95
347
  "user.data-seeding",
96
348
  "integration.create",
349
+ // Reading an integration's audit log. Deliberately separate from
350
+ // 'integration.create' so read-only oversight can be granted on its own, and
351
+ // deliberately option-less: system clients have no office and no
352
+ // administrative area, so jurisdiction options would have nothing to bind to.
353
+ "integration.audit.read",
97
354
  "record.import",
98
355
  "config.update-all",
356
+ "location.edit",
99
357
  "attachment.upload",
100
358
  "profile.electronic-signature",
101
359
  "user.read-only-my-audit",
@@ -107,72 +365,85 @@ var PlainScopeType = z2.enum([
107
365
  "record.confirm-registration",
108
366
  "record.reject-registration"
109
367
  ]);
110
- var scopeByEvent = z2.preprocess(
368
+ var scopeByEvent = z7.preprocess(
111
369
  (val) => val === void 0 ? void 0 : [val].flat(),
112
- z2.array(z2.string()).optional()
370
+ z7.array(z7.string()).optional()
113
371
  ).describe("Event type, e.g. birth, death");
114
- var userRole = z2.preprocess(
372
+ var scopeByStatus = z7.preprocess(
373
+ (val) => val === void 0 ? void 0 : [val].flat(),
374
+ z7.array(EventStatus).optional()
375
+ ).describe(
376
+ "Restricts the scope to records currently in one of these statuses."
377
+ );
378
+ var userRole = z7.preprocess(
115
379
  (val) => val === void 0 ? void 0 : [val].flat(),
116
- z2.array(z2.string()).optional()
380
+ z7.array(z7.string()).optional()
117
381
  ).describe("User role, e.g. admin, field agent");
118
- var scopeOptionsPlaceEvent = z2.object({
382
+ var scopeOptionsPlaceEvent = z7.object({
119
383
  event: scopeByEvent,
120
- placeOfEvent: JurisdictionFilter.optional()
384
+ placeOfEvent: JurisdictionFilter.optional(),
385
+ createdBy: UserFilter.optional(),
386
+ createdIn: JurisdictionFilter.optional()
121
387
  }).describe("Options applicable to all record scopes.");
122
388
  var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
123
389
  notifiedIn: JurisdictionFilter.optional(),
124
390
  notifiedBy: UserFilter.optional(),
125
391
  declaredIn: JurisdictionFilter.optional(),
126
- declaredBy: UserFilter.optional()
392
+ declaredBy: UserFilter.optional(),
393
+ status: scopeByStatus
127
394
  }).describe("Options applicable to actions that may take place after DECLARE");
128
395
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
129
396
  registeredIn: JurisdictionFilter.optional(),
130
- registeredBy: UserFilter.optional()
397
+ registeredBy: UserFilter.optional(),
398
+ flags: ContainsFlags.optional()
131
399
  }).describe(
132
400
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
133
401
  );
134
402
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
135
- customActionTypes: z2.preprocess(
403
+ customActionTypes: z7.preprocess(
136
404
  (val) => val === void 0 ? void 0 : [val].flat(),
137
- z2.array(z2.string()).optional()
405
+ z7.array(z7.string()).optional()
138
406
  ).describe("Allowed custom action types")
139
407
  });
140
- var AccessLevelOptions = z2.object({
408
+ var AccessLevelOptions = z7.object({
141
409
  accessLevel: JurisdictionFilter.optional()
142
410
  });
143
411
  var AllUserScopeOptions = AccessLevelOptions.extend({
144
412
  role: userRole.optional()
145
413
  });
146
- var WorkqueueOrDashboardOptions = z2.object({
147
- ids: z2.preprocess(
414
+ var WorkqueueOrDashboardOptions = z7.object({
415
+ ids: z7.preprocess(
148
416
  (val) => val === void 0 ? void 0 : [val].flat(),
149
- z2.array(z2.string())
417
+ z7.array(z7.string())
150
418
  ).describe("Must contain a list of workqueue or dashboard ids.")
151
419
  });
152
- var AllScopeOptions = z2.object({
420
+ var AllScopeOptions = z7.object({
153
421
  ...AllRecordScopeOptions.shape,
154
422
  ...AccessLevelOptions.shape,
155
423
  ...AllUserScopeOptions.shape,
156
424
  ...WorkqueueOrDashboardOptions.shape
157
425
  });
158
426
  var ScopeOptionKey = AllScopeOptions.keyof();
159
- var ResolvedScopeOptionsPlaceEvent = z2.object({
427
+ var ResolvedScopeOptionsPlaceEvent = z7.object({
160
428
  event: scopeByEvent,
161
- placeOfEvent: UUID.nullish()
429
+ placeOfEvent: UUID.nullish(),
430
+ createdBy: z7.string().optional(),
431
+ createdIn: UUID.nullish()
162
432
  }).describe(
163
433
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
164
434
  );
165
435
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
166
436
  notifiedIn: UUID.nullish(),
167
- notifiedBy: z2.string().optional(),
437
+ notifiedBy: z7.string().optional(),
168
438
  declaredIn: UUID.nullish(),
169
- declaredBy: z2.string().optional()
439
+ declaredBy: z7.string().optional()
170
440
  }).describe(
171
441
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
172
442
  );
173
443
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
174
444
  registeredIn: UUID.nullish(),
175
- registeredBy: z2.string().optional()
445
+ registeredBy: z7.string().optional(),
446
+ flags: ContainsFlags.optional()
176
447
  }).describe(
177
448
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
178
449
  );
@@ -186,7 +457,6 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
186
457
  "record.reject",
187
458
  "record.archive",
188
459
  "record.unarchive",
189
- "record.review-duplicates",
190
460
  "record.register"
191
461
  ]);
192
462
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -194,41 +464,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
194
464
  "record.read",
195
465
  "record.request-correction",
196
466
  "record.correct",
197
- "record.unassign-others"
467
+ "record.unassign-others",
468
+ "record.review-duplicates"
198
469
  ]);
199
470
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
200
- templates: z2.preprocess(
471
+ templates: z7.preprocess(
201
472
  (val) => val === void 0 ? void 0 : [val].flat(),
202
- z2.array(z2.string()).optional()
473
+ z7.array(z7.string()).optional()
203
474
  ).describe(
204
475
  "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
476
  )
206
477
  });
207
- var RecordScopeV2 = z2.discriminatedUnion("type", [
208
- z2.object({
478
+ var RecordScopeV2 = z7.discriminatedUnion("type", [
479
+ z7.object({
209
480
  type: ScopesWithPlaceEventOptions,
210
481
  options: scopeOptionsPlaceEvent.optional()
211
482
  }),
212
- z2.object({
483
+ z7.object({
213
484
  type: ScopesWithDeclaredOptions,
214
485
  options: scopeOptionsDeclaredOrNotified.optional()
215
486
  }),
216
- z2.object({
487
+ z7.object({
217
488
  type: ScopesWithFullOptions,
218
489
  options: AllRecordScopeOptions.optional()
219
490
  }),
220
- z2.object({
221
- type: z2.literal("record.custom-action"),
491
+ z7.object({
492
+ type: z7.literal("record.custom-action"),
222
493
  options: CustomActionScopeOptions.optional()
223
494
  }),
224
- z2.object({
225
- type: z2.literal("record.print-certified-copies"),
495
+ z7.object({
496
+ type: z7.literal("record.print-certified-copies"),
226
497
  options: ScopeOptionsPrintCertifiedCopies.optional()
227
498
  })
228
499
  ]).describe(
229
500
  "Scopes used to check user's permission to perform actions on a record."
230
501
  );
231
- var SystemScopeType = z2.enum([
502
+ var SystemScopeType = z7.enum([
232
503
  "organisation.read-locations",
233
504
  "user.read",
234
505
  "user.create",
@@ -242,61 +513,61 @@ var UserScopeType = SystemScopeType.extract([
242
513
  "user.search"
243
514
  ]);
244
515
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
245
- var UserScopeV2 = z2.discriminatedUnion("type", [
246
- z2.object({
516
+ var UserScopeV2 = z7.discriminatedUnion("type", [
517
+ z7.object({
247
518
  type: ScopesWithRoleOption,
248
519
  options: AllUserScopeOptions.optional()
249
520
  }),
250
- z2.object({
521
+ z7.object({
251
522
  type: UserScopeType.extract(["user.read", "user.search"]),
252
523
  options: AccessLevelOptions.optional()
253
524
  })
254
525
  ]);
255
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
256
- z2.object({
526
+ var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
527
+ z7.object({
257
528
  type: ScopesWithPlaceEventOptions,
258
529
  options: ResolvedScopeOptionsPlaceEvent.optional()
259
530
  }),
260
- z2.object({
531
+ z7.object({
261
532
  type: ScopesWithDeclaredOptions,
262
533
  options: ResolvedScopeOptionsDeclared.optional()
263
534
  }),
264
- z2.object({
535
+ z7.object({
265
536
  type: ScopesWithFullOptions,
266
537
  options: ResolvedScopeOptionsFull.optional()
267
538
  }),
268
- z2.object({
269
- type: z2.literal("record.print-certified-copies"),
539
+ z7.object({
540
+ type: z7.literal("record.print-certified-copies"),
270
541
  options: ResolvedScopeOptionsFull.extend({
271
- templates: z2.array(z2.string()).optional()
542
+ templates: z7.array(z7.string()).optional()
272
543
  }).optional()
273
544
  })
274
545
  ]).describe("Resolved scope with location/user IDs instead of filters.");
275
- var Scope = z2.discriminatedUnion("type", [
276
- z2.object({ type: PlainScopeType }),
546
+ var Scope = z7.discriminatedUnion("type", [
547
+ z7.object({ type: PlainScopeType }),
277
548
  ...RecordScopeV2.options,
278
549
  ...UserScopeV2.options,
279
- z2.object({
280
- type: z2.literal("organisation.read-locations"),
550
+ z7.object({
551
+ type: z7.literal("organisation.read-locations"),
281
552
  options: AccessLevelOptions.optional()
282
553
  }),
283
- z2.object({
284
- type: z2.literal("workqueue"),
554
+ z7.object({
555
+ type: z7.literal("workqueue"),
285
556
  options: WorkqueueOrDashboardOptions
286
557
  }),
287
- z2.object({
288
- type: z2.literal("dashboard.view"),
558
+ z7.object({
559
+ type: z7.literal("dashboard.view"),
289
560
  options: WorkqueueOrDashboardOptions
290
561
  })
291
562
  ]);
292
- var ScopeType = z2.enum([
563
+ var ScopeType = z7.enum([
293
564
  ...SystemScopeType.options,
294
565
  ...RecordScopeTypeV2.options,
295
566
  ...PlainScopeType.options,
296
567
  "workqueue",
297
568
  "dashboard.view"
298
569
  ]);
299
- var EncodedScope = z2.string().brand("EncodedScope");
570
+ var EncodedScope = z7.string().brand("EncodedScope");
300
571
  var DEFAULT_SCOPE_OPTIONS = {
301
572
  placeOfEvent: JurisdictionFilter.enum.all,
302
573
  accessLevel: JurisdictionFilter.enum.all,
@@ -306,162 +577,51 @@ var DEFAULT_SCOPE_OPTIONS = {
306
577
  };
307
578
 
308
579
  // ../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
- ];
580
+ var TokenUserType = z8.enum(["user", "system"]);
581
+ var TokenWithBearer = z8.string().regex(/^Bearer\s/);
422
582
 
423
583
  // ../commons/src/events/AuditLog.ts
424
- var AuditLogEntryBase = z5.object({
425
- id: z5.string(),
426
- clientId: z5.string(),
584
+ var AuditLogEntryBase = z9.object({
585
+ id: z9.string(),
586
+ clientId: z9.string(),
427
587
  clientType: TokenUserType,
428
- createdAt: z5.string()
588
+ createdAt: z9.string()
429
589
  });
430
590
  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()
591
+ operation: z9.literal("event.create"),
592
+ requestData: z9.object({
593
+ transactionId: z9.string(),
594
+ type: z9.string(),
595
+ createdAtLocation: z9.string().nullable()
436
596
  }),
437
- responseSummary: z5.object({
438
- eventId: z5.string(),
439
- trackingId: z5.string()
597
+ responseSummary: z9.object({
598
+ eventId: z9.string(),
599
+ trackingId: z9.string()
440
600
  })
441
601
  });
442
602
  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()
603
+ operation: z9.literal("event.get"),
604
+ requestData: z9.object({ eventId: z9.string() }),
605
+ responseSummary: z9.object({
606
+ eventType: z9.string(),
607
+ trackingId: z9.string()
448
608
  })
449
609
  });
450
610
  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()
611
+ operation: z9.literal("event.search"),
612
+ clientType: z9.literal("system"),
613
+ requestData: z9.object({
614
+ query: z9.record(z9.string(), z9.unknown()).nullable(),
615
+ limit: z9.number().nullable(),
616
+ offset: z9.number().nullable()
457
617
  }),
458
- responseSummary: z5.object({
459
- total: z5.number(),
460
- eventIds: z5.array(z5.string())
618
+ responseSummary: z9.object({
619
+ total: z9.number(),
620
+ eventIds: z9.array(z9.string())
461
621
  })
462
622
  });
463
623
  var EventActionEntrySchema = AuditLogEntryBase.extend({
464
- operation: z5.enum([
624
+ operation: z9.enum([
465
625
  "event.actions.notify.request",
466
626
  "event.actions.declare.request",
467
627
  "event.actions.register.request",
@@ -481,83 +641,159 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
481
641
  "event.actions.mark_as_duplicate.request",
482
642
  "event.actions.mark_as_not_duplicate.request"
483
643
  ]),
484
- requestData: z5.object({
485
- eventId: z5.string(),
486
- actionType: z5.string(),
487
- eventType: z5.string(),
488
- trackingId: z5.string(),
489
- transactionId: z5.string()
644
+ requestData: z9.object({
645
+ eventId: z9.string(),
646
+ actionType: z9.string(),
647
+ eventType: z9.string(),
648
+ trackingId: z9.string(),
649
+ transactionId: z9.string()
490
650
  })
491
651
  });
492
652
  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()
653
+ operation: z9.literal("event.actions.custom.request"),
654
+ requestData: z9.object({
655
+ eventId: z9.string(),
656
+ actionType: z9.literal(ActionType.CUSTOM),
657
+ customAction: z9.string(),
658
+ eventType: z9.string(),
659
+ trackingId: z9.string(),
660
+ transactionId: z9.string()
501
661
  })
502
662
  });
503
663
  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() })
664
+ operation: z9.literal("integrations.create"),
665
+ requestData: z9.object({ name: z9.string(), scopes: z9.array(z9.string()) }),
666
+ responseSummary: z9.object({ clientId: z9.string() })
507
667
  });
508
668
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
509
- operation: z5.literal("integrations.refreshToken"),
510
- requestData: z5.object({ clientId: z5.string() }),
511
- responseSummary: z5.object({ clientId: z5.string() })
669
+ operation: z9.literal("integrations.refreshToken"),
670
+ requestData: z9.object({ clientId: z9.string() }),
671
+ responseSummary: z9.object({ clientId: z9.string() })
512
672
  });
513
673
  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() })
674
+ operation: z9.literal("integrations.deactivate"),
675
+ requestData: z9.object({ id: z9.string() }),
676
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
517
677
  });
518
678
  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() })
679
+ operation: z9.literal("integrations.activate"),
680
+ requestData: z9.object({ id: z9.string() }),
681
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
522
682
  });
523
683
  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() })
684
+ operation: z9.literal("integrations.delete"),
685
+ requestData: z9.object({ id: z9.string() }),
686
+ responseSummary: z9.object({ id: z9.string(), name: z9.string() })
527
687
  });
528
688
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
529
- operation: z5.literal("integrations.refreshSecret"),
530
- requestData: z5.object({ id: z5.string() }),
531
- responseSummary: z5.object({ clientId: z5.string() })
689
+ operation: z9.literal("integrations.refreshSecret"),
690
+ requestData: z9.object({ id: z9.string() }),
691
+ responseSummary: z9.object({ clientId: z9.string() })
692
+ });
693
+ var createdVersionFields = {
694
+ id: z9.string(),
695
+ versionId: z9.string(),
696
+ name: z9.string(),
697
+ externalId: z9.string().nullish(),
698
+ effectiveFrom: z9.string(),
699
+ status: z9.string()
700
+ };
701
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
702
+ operation: z9.literal("locations.create"),
703
+ requestData: z9.object({
704
+ ...createdVersionFields,
705
+ administrativeAreaId: z9.string().nullish(),
706
+ locationType: z9.string().nullish()
707
+ })
708
+ });
709
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
710
+ operation: z9.literal("administrativeAreas.create"),
711
+ requestData: z9.object({
712
+ ...createdVersionFields,
713
+ parentId: z9.string().nullish()
714
+ })
715
+ });
716
+ var ChangedStringField = z9.object({ from: z9.string(), to: z9.string() });
717
+ var ChangedNullableStringField = z9.object({
718
+ from: z9.string().nullable(),
719
+ to: z9.string().nullable()
720
+ });
721
+ var updatedVersionRequestData = z9.object({
722
+ id: z9.string(),
723
+ versionId: z9.string(),
724
+ name: z9.string(),
725
+ externalId: z9.string().nullish(),
726
+ status: z9.string(),
727
+ effectiveFrom: z9.string(),
728
+ lastVersionId: z9.string()
729
+ });
730
+ var updatedVersionResponseSummary = z9.object({
731
+ previousVersionId: z9.string(),
732
+ versionId: z9.string(),
733
+ changed: z9.object({
734
+ name: ChangedStringField.optional(),
735
+ externalId: ChangedNullableStringField.optional(),
736
+ status: ChangedStringField.optional()
737
+ })
738
+ });
739
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
740
+ operation: z9.literal("locations.update"),
741
+ requestData: updatedVersionRequestData,
742
+ responseSummary: updatedVersionResponseSummary
743
+ });
744
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
745
+ operation: z9.literal("administrativeAreas.update"),
746
+ requestData: updatedVersionRequestData,
747
+ responseSummary: updatedVersionResponseSummary
748
+ });
749
+ var withdrawVersionRequestData = z9.object({
750
+ id: z9.string(),
751
+ versionId: z9.string()
752
+ });
753
+ var withdrawVersionResponseSummary = z9.object({
754
+ effectiveFrom: z9.string(),
755
+ name: z9.string(),
756
+ externalId: z9.string().nullish(),
757
+ status: z9.string()
758
+ });
759
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
760
+ operation: z9.literal("locations.withdrawVersion"),
761
+ requestData: withdrawVersionRequestData,
762
+ responseSummary: withdrawVersionResponseSummary
763
+ });
764
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
765
+ operation: z9.literal("administrativeAreas.withdrawVersion"),
766
+ requestData: withdrawVersionRequestData,
767
+ responseSummary: withdrawVersionResponseSummary
532
768
  });
533
769
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
534
- operation: z5.literal("attachments.upload"),
535
- requestData: z5.object({
536
- transactionId: z5.string(),
537
- path: z5.string().nullable()
770
+ operation: z9.literal("attachments.upload"),
771
+ requestData: z9.object({
772
+ transactionId: z9.string(),
773
+ path: z9.string().nullable()
538
774
  }),
539
- responseSummary: z5.object({ fileUrl: z5.string() })
775
+ responseSummary: z9.object({ fileUrl: z9.string() })
540
776
  });
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()
777
+ var subjectOnly = z9.object({ subjectId: z9.string() });
778
+ var subjectWithReason = z9.object({
779
+ subjectId: z9.string(),
780
+ reason: z9.string(),
781
+ comment: z9.string().optional()
546
782
  });
547
783
  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()
784
+ operation: z9.literal("user.create_user"),
785
+ requestData: z9.object({
786
+ subjectId: z9.string(),
787
+ role: z9.string(),
788
+ primaryOfficeId: z9.string()
553
789
  })
554
790
  });
555
791
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
556
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
792
+ operation: z9.enum(["user.deactivate", "user.reactivate"]),
557
793
  requestData: subjectWithReason
558
794
  });
559
795
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
560
- operation: z5.enum([
796
+ operation: z9.enum([
561
797
  "user.edit_user",
562
798
  "user.logged_in",
563
799
  "user.logged_out",
@@ -571,14 +807,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
571
807
  requestData: subjectOnly
572
808
  });
573
809
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
574
- operation: z5.literal("user.email_address_changed"),
810
+ operation: z9.literal("user.email_address_changed"),
575
811
  requestData: subjectOnly,
576
- responseSummary: z5.object({ email: z5.string() })
812
+ responseSummary: z9.object({ email: z9.string() })
577
813
  });
578
814
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
579
- operation: z5.literal("user.phone_number_changed"),
815
+ operation: z9.literal("user.phone_number_changed"),
580
816
  requestData: subjectOnly,
581
- responseSummary: z5.object({ phoneNumber: z5.string() })
817
+ responseSummary: z9.object({ phoneNumber: z9.string() })
582
818
  });
583
819
  var userBaseOmit = {
584
820
  id: true,
@@ -586,14 +822,14 @@ var userBaseOmit = {
586
822
  clientType: true,
587
823
  createdAt: true
588
824
  };
589
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
825
+ var UserAuditRecordInput = z9.discriminatedUnion("operation", [
590
826
  UserCreateEntrySchema.omit(userBaseOmit),
591
827
  UserReasonEntrySchema.omit(userBaseOmit),
592
828
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
593
829
  UserEmailChangedEntrySchema.omit(userBaseOmit),
594
830
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
595
831
  ]);
596
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
832
+ var AuditLogEntrySchema = z9.discriminatedUnion("operation", [
597
833
  EventCreateEntrySchema,
598
834
  EventGetEntrySchema,
599
835
  EventSearchEntrySchema,
@@ -605,6 +841,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
605
841
  IntegrationActivateEntrySchema,
606
842
  IntegrationDeleteEntrySchema,
607
843
  IntegrationRefreshSecretEntrySchema,
844
+ LocationCreateEntrySchema,
845
+ LocationUpdateEntrySchema,
846
+ AdministrativeAreaUpdateEntrySchema,
847
+ LocationWithdrawEntrySchema,
848
+ AdministrativeAreaWithdrawEntrySchema,
849
+ AdministrativeAreaCreateEntrySchema,
608
850
  AttachmentUploadEntrySchema,
609
851
  UserCreateEntrySchema,
610
852
  UserReasonEntrySchema,
@@ -618,78 +860,13 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
618
860
  var CHILD_ONBOARDING_EVENT = "child-onboarding";
619
861
 
620
862
  // ../commons/src/events/ActionConfig.ts
621
- var z24 = __toESM(require("zod/v4"));
622
-
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
- });
863
+ var z25 = __toESM(require("zod/v4"));
637
864
 
638
865
  // ../commons/src/events/FieldConfig.ts
639
866
  var import_v43 = __toESM(require("zod/v4"));
640
867
 
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
868
  // ../commons/src/events/FieldType.ts
692
- var z8 = __toESM(require("zod/v4"));
869
+ var z10 = __toESM(require("zod/v4"));
693
870
  var FieldType = {
694
871
  NAME: "NAME",
695
872
  PHONE: "PHONE",
@@ -753,7 +930,7 @@ var FieldType = {
753
930
  */
754
931
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
755
932
  };
756
- var FileFieldType = z8.enum([
933
+ var FileFieldType = z10.enum([
757
934
  FieldType.FILE,
758
935
  FieldType.FILE_WITH_OPTIONS,
759
936
  FieldType.SIGNATURE
@@ -789,160 +966,160 @@ var HiddenFieldTypes = [
789
966
  ];
790
967
 
791
968
  // ../commons/src/events/FieldValue.ts
792
- var z12 = __toESM(require("zod/v4"));
969
+ var z14 = __toESM(require("zod/v4"));
793
970
 
794
971
  // ../commons/src/documents.ts
795
- var z9 = __toESM(require("zod/v4"));
796
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
972
+ var z11 = __toESM(require("zod/v4"));
973
+ var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
797
974
  "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
975
  );
799
- var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
976
+ var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
800
977
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
801
978
  );
802
- var DocumentPath = z9.string().brand("DocumentPath").describe(
979
+ var DocumentPath = z11.string().brand("DocumentPath").describe(
803
980
  "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
981
  );
805
982
 
806
983
  // ../commons/src/events/CompositeFieldValue.ts
807
- var z10 = __toESM(require("zod/v4"));
984
+ var z12 = __toESM(require("zod/v4"));
808
985
  var AddressType = {
809
986
  DOMESTIC: "DOMESTIC",
810
987
  INTERNATIONAL: "INTERNATIONAL"
811
988
  };
812
- var FileFieldValue = z10.object({
989
+ var FileFieldValue = z12.object({
813
990
  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(),
991
+ originalFilename: z12.string(),
992
+ type: z12.string()
993
+ });
994
+ var NameFieldValue = z12.object({
995
+ firstname: z12.string(),
996
+ surname: z12.string(),
997
+ middlename: z12.string().optional()
998
+ });
999
+ var NameFieldUpdateValue = z12.object({
1000
+ firstname: z12.string().nullish(),
1001
+ surname: z12.string().nullish(),
1002
+ middlename: z12.string().nullish()
1003
+ }).or(z12.null()).or(z12.undefined());
1004
+ var StreetLevelDetailsValue = z12.record(z12.string(), z12.string()).optional();
1005
+ var StreetLevelDetailsUpdateValue = z12.record(z12.string(), z12.string().nullable()).nullish();
1006
+ var BaseAddressFieldValue = z12.object({
1007
+ country: z12.string(),
831
1008
  streetLevelDetails: StreetLevelDetailsValue
832
1009
  });
833
- var BaseAddressFieldUpdateValue = z10.object({
834
- country: z10.string().nullish(),
1010
+ var BaseAddressFieldUpdateValue = z12.object({
1011
+ country: z12.string().nullish(),
835
1012
  streetLevelDetails: StreetLevelDetailsUpdateValue
836
1013
  });
837
1014
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
838
- addressType: z10.literal(AddressType.DOMESTIC),
839
- administrativeArea: z10.string().uuid()
1015
+ addressType: z12.literal(AddressType.DOMESTIC),
1016
+ administrativeArea: z12.string().uuid()
840
1017
  });
841
1018
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
842
- addressType: z10.literal(AddressType.INTERNATIONAL)
1019
+ addressType: z12.literal(AddressType.INTERNATIONAL)
843
1020
  });
844
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
1021
+ var AddressFieldValue = z12.discriminatedUnion("addressType", [
845
1022
  DomesticAddressFieldValue,
846
1023
  InternationalAddressFieldValue
847
1024
  ]);
848
1025
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
849
- addressType: z10.literal(AddressType.DOMESTIC),
850
- administrativeArea: z10.string().uuid().nullish()
1026
+ addressType: z12.literal(AddressType.DOMESTIC),
1027
+ administrativeArea: z12.string().uuid().nullish()
851
1028
  /* Leaf level admin structure */
852
1029
  });
853
1030
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
854
1031
  {
855
- addressType: z10.literal(AddressType.INTERNATIONAL)
1032
+ addressType: z12.literal(AddressType.INTERNATIONAL)
856
1033
  }
857
1034
  );
858
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
1035
+ var AddressFieldUpdateValue = z12.discriminatedUnion("addressType", [
859
1036
  DomesticAddressUpdateFieldValue,
860
1037
  InternationalAddressUpdateFieldValue
861
1038
  ]).nullish();
862
- var FileFieldValueWithOption = z10.object({
1039
+ var FileFieldValueWithOption = z12.object({
863
1040
  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()
1041
+ originalFilename: z12.string(),
1042
+ type: z12.string(),
1043
+ option: z12.string()
1044
+ });
1045
+ var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
1046
+ var HttpFieldValue = z12.object({
1047
+ loading: z12.boolean(),
1048
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1049
+ data: z12.any()
1050
+ });
1051
+ var HttpFieldUpdateValue = z12.object({
1052
+ loading: z12.boolean().nullish(),
1053
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1054
+ data: z12.any().nullish()
1055
+ }).or(z12.null()).or(z12.undefined());
1056
+ var QueryParamReaderFieldValue = z12.object({
1057
+ data: z12.record(z12.string(), z12.string()),
1058
+ updatedAt: z12.iso.datetime()
882
1059
  }).nullish();
883
- var QueryParamReaderFieldUpdateValue = z10.object({
884
- data: z10.record(z10.string(), z10.string())
1060
+ var QueryParamReaderFieldUpdateValue = z12.object({
1061
+ data: z12.record(z12.string(), z12.string())
885
1062
  });
886
- var ReadDataValue = z10.object({
887
- data: z10.any()
1063
+ var ReadDataValue = z12.object({
1064
+ data: z12.any()
888
1065
  });
889
1066
  var QrReaderFieldValue = ReadDataValue;
890
1067
  var IdReaderFieldValue = ReadDataValue;
891
- var NumberWithUnitFieldValue = z10.object({
892
- numericValue: z10.number(),
893
- unit: z10.string()
1068
+ var NumberWithUnitFieldValue = z12.object({
1069
+ numericValue: z12.number(),
1070
+ unit: z12.string()
894
1071
  });
895
- var NumberWithUnitFieldUpdateValue = z10.object({
896
- numericValue: z10.number().optional(),
897
- unit: z10.string().optional()
1072
+ var NumberWithUnitFieldUpdateValue = z12.object({
1073
+ numericValue: z12.number().optional(),
1074
+ unit: z12.string().optional()
898
1075
  });
899
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1076
+ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
900
1077
 
901
1078
  // ../commons/src/events/PlainDate.ts
902
1079
  var import_zod = require("zod");
903
1080
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
904
1081
 
905
1082
  // ../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()
1083
+ var TextValue = z14.string();
1084
+ var HiddenFieldValue = z14.string();
1085
+ var NonEmptyTextValue = z14.string().trim().min(1);
1086
+ var DateValue = z14.iso.date().describe("Date in the format YYYY-MM-DD");
1087
+ var AgeValue = z14.object({
1088
+ age: z14.number(),
1089
+ asOfDateRef: z14.string()
913
1090
  });
914
1091
  var AgeUpdateValue = AgeValue.optional().nullable();
915
- var AutocompleteValue = z12.object({
916
- label: z12.string(),
917
- value: z12.string()
1092
+ var AutocompleteValue = z14.object({
1093
+ label: z14.string(),
1094
+ value: z14.string()
918
1095
  });
919
1096
  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([
1097
+ var TimeValue = z14.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1098
+ var DatetimeValue = z14.iso.datetime();
1099
+ var SelectDateRangeValue = z14.enum([
923
1100
  "last7Days",
924
1101
  "last30Days",
925
1102
  "last90Days",
926
1103
  "last365Days"
927
1104
  ]);
928
- var DateRangeFieldValue = z12.object({
1105
+ var DateRangeFieldValue = z14.object({
929
1106
  start: PlainDate,
930
1107
  end: PlainDate
931
1108
  }).or(PlainDate).describe(
932
1109
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
933
1110
  );
934
- var EmailValue = z12.email();
935
- var CheckboxFieldValue = z12.boolean();
936
- var NumberFieldValue = z12.number();
1111
+ var EmailValue = z14.email();
1112
+ var CheckboxFieldValue = z14.boolean();
1113
+ var NumberFieldValue = z14.number();
937
1114
  var SignatureFieldValue = FileFieldValue;
938
- var ButtonFieldValue = z12.number();
939
- var VerificationStatusValue = z12.enum([
1115
+ var ButtonFieldValue = z14.number();
1116
+ var VerificationStatusValue = z14.enum([
940
1117
  "verified",
941
1118
  "authenticated",
942
1119
  "failed",
943
1120
  "pending"
944
1121
  ]);
945
- var LeafFieldValues = z12.union([
1122
+ var LeafFieldValues = z14.union([
946
1123
  AddressFieldValue,
947
1124
  TextValue,
948
1125
  PlainDate,
@@ -968,11 +1145,11 @@ var LeafFieldValues = z12.union([
968
1145
  AutocompleteValue,
969
1146
  AutocompleteUpdateValue
970
1147
  ]);
971
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
972
- var DataFieldValue = z12.object({
973
- data: z12.record(z12.string(), LeafFieldValues)
1148
+ var FieldGroupValue = z14.record(z14.string(), LeafFieldValues);
1149
+ var DataFieldValue = z14.object({
1150
+ data: z14.record(z14.string(), LeafFieldValues)
974
1151
  }).nullish();
975
- var FieldValue = z12.union([
1152
+ var FieldValue = z14.union([
976
1153
  LeafFieldValues,
977
1154
  DataFieldValue,
978
1155
  FieldGroupValue
@@ -1006,7 +1183,7 @@ function safeUnion(schemas) {
1006
1183
  const sortedSchemas = [...schemas].sort(
1007
1184
  (a, b) => schemaPriority(a) - schemaPriority(b)
1008
1185
  );
1009
- return z12.any().superRefine((val, ctx) => {
1186
+ return z14.any().superRefine((val, ctx) => {
1010
1187
  for (const schema of sortedSchemas) {
1011
1188
  if (schema.safeParse(val).success) {
1012
1189
  return;
@@ -1045,9 +1222,9 @@ var FieldUpdateValue = safeUnion([
1045
1222
  ]);
1046
1223
 
1047
1224
  // ../commons/src/events/serializers/user/serializer.ts
1048
- var z13 = __toESM(require("zod/v4"));
1049
- var SerializedUserField = z13.object({
1050
- $userField: z13.enum([
1225
+ var z15 = __toESM(require("zod/v4"));
1226
+ var SerializedUserField = z15.object({
1227
+ $userField: z15.enum([
1051
1228
  "id",
1052
1229
  "name",
1053
1230
  "role",
@@ -1061,7 +1238,7 @@ var SerializedUserField = z13.object({
1061
1238
  "primaryOfficeId",
1062
1239
  "administrativeAreaId"
1063
1240
  ]),
1064
- $location: z13.string().optional()
1241
+ $location: z15.string().optional()
1065
1242
  });
1066
1243
  function userSerializer(userField) {
1067
1244
  return {
@@ -1084,30 +1261,25 @@ function userSerializer(userField) {
1084
1261
  var import_v4 = require("zod/v4");
1085
1262
 
1086
1263
  // ../commons/src/events/EventMetadata.ts
1087
- var z16 = __toESM(require("zod/v4"));
1264
+ var z17 = __toESM(require("zod/v4"));
1088
1265
 
1089
1266
  // ../commons/src/events/ActionDocument.ts
1090
- var z14 = __toESM(require("zod/v4"));
1091
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1267
+ var z16 = __toESM(require("zod/v4"));
1268
+ var ActionUpdate = z16.record(z16.string(), FieldUpdateValue).describe(
1092
1269
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1093
1270
  );
1094
- var EventState = z14.record(z14.string(), FieldValue).describe(
1271
+ var EventState = z16.record(z16.string(), FieldValue).describe(
1095
1272
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1096
1273
  );
1097
- var ActionStatus = {
1098
- Requested: "Requested",
1099
- Accepted: "Accepted",
1100
- Rejected: "Rejected"
1101
- };
1102
- var ActionBase = z14.object({
1274
+ var ActionBase = z16.object({
1103
1275
  id: UUID.describe("Unique identifier of the action."),
1104
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1276
+ transactionId: z16.string().describe("Unique identifier of the transaction."),
1105
1277
  createdByUserType: TokenUserType.describe(
1106
1278
  "Indicates whether the action was created by a human-user or by a system-user."
1107
1279
  ),
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."),
1280
+ createdAt: z16.string().datetime().describe("Timestamp indicating when the action was created."),
1281
+ createdBy: z16.string().describe("Identifier of the user who created the action."),
1282
+ createdByRole: z16.string().optional().describe("Role of the user who created the action."),
1111
1283
  createdBySignature: DocumentPath.nullish().describe(
1112
1284
  "Reference to the signature of the user who created the action."
1113
1285
  ),
@@ -1119,7 +1291,7 @@ var ActionBase = z14.object({
1119
1291
  "Declaration data defined by the ActionConfig. Supports partial updates."
1120
1292
  ),
1121
1293
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1122
- status: z14.enum([
1294
+ status: z16.enum([
1123
1295
  ActionStatus.Requested,
1124
1296
  ActionStatus.Accepted,
1125
1297
  ActionStatus.Rejected
@@ -1131,138 +1303,143 @@ var ActionBase = z14.object({
1131
1303
  )
1132
1304
  });
1133
1305
  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.")
1306
+ z16.object({
1307
+ type: z16.literal(ActionType.ASSIGN),
1308
+ assignedTo: z16.string().describe("Identifier of the user to whom the action is assigned.")
1137
1309
  // TODO move into 'content' property
1138
1310
  }).shape
1139
1311
  );
1140
1312
  var UnassignedAction = ActionBase.extend(
1141
- z14.object({
1142
- type: z14.literal(ActionType.UNASSIGN)
1313
+ z16.object({
1314
+ type: z16.literal(ActionType.UNASSIGN)
1143
1315
  }).shape
1144
1316
  );
1145
1317
  var RegisterAction = ActionBase.extend(
1146
- z14.object({
1147
- type: z14.literal(ActionType.REGISTER),
1148
- registrationNumber: z14.string().optional().describe(
1318
+ z16.object({
1319
+ type: z16.literal(ActionType.REGISTER),
1320
+ registrationNumber: z16.string().optional().describe(
1149
1321
  "Registration number of the event. Always present for accepted registrations."
1150
1322
  )
1151
1323
  // TODO move into 'content' property
1152
1324
  }).shape
1153
1325
  );
1154
1326
  var DeclareAction = ActionBase.extend(
1155
- z14.object({
1156
- type: z14.literal(ActionType.DECLARE)
1327
+ z16.object({
1328
+ type: z16.literal(ActionType.DECLARE)
1157
1329
  }).shape
1158
1330
  );
1159
- var ReasonContent = z14.object({
1160
- reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1331
+ var ReasonContent = z16.object({
1332
+ reason: z16.string().min(1, { error: "Message cannot be empty" }).describe(
1161
1333
  "Message describing the reason for rejecting or archiving the event."
1162
1334
  )
1163
1335
  });
1164
1336
  var RejectAction = ActionBase.extend(
1165
- z14.object({
1166
- type: z14.literal(ActionType.REJECT),
1337
+ z16.object({
1338
+ type: z16.literal(ActionType.REJECT),
1167
1339
  content: ReasonContent
1168
1340
  }).shape
1169
1341
  );
1170
- var PotentialDuplicate = z14.object({
1342
+ var PotentialDuplicate = z16.object({
1171
1343
  id: UUID,
1172
- trackingId: z14.string()
1344
+ trackingId: z16.string()
1173
1345
  });
1174
1346
  var DuplicateDetectedAction = ActionBase.extend(
1175
- z14.object({
1176
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1177
- content: z14.object({
1178
- duplicates: z14.array(PotentialDuplicate)
1347
+ z16.object({
1348
+ type: z16.literal(ActionType.DUPLICATE_DETECTED),
1349
+ content: z16.object({
1350
+ duplicates: z16.array(PotentialDuplicate)
1179
1351
  })
1180
1352
  }).shape
1181
1353
  );
1182
1354
  var MarkNotDuplicateAction = ActionBase.extend(
1183
- z14.object({
1184
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1355
+ z16.object({
1356
+ type: z16.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1185
1357
  }).shape
1186
1358
  );
1187
1359
  var MarkAsDuplicateAction = ActionBase.extend(
1188
- z14.object({
1189
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1190
- content: z14.object({
1360
+ z16.object({
1361
+ type: z16.literal(ActionType.MARK_AS_DUPLICATE),
1362
+ content: z16.object({
1191
1363
  duplicateOf: UUID
1192
1364
  }).optional()
1193
1365
  }).shape
1194
1366
  );
1195
1367
  var ArchiveAction = ActionBase.extend(
1196
- z14.object({
1197
- type: z14.literal(ActionType.ARCHIVE),
1198
- content: ReasonContent
1368
+ z16.object({
1369
+ type: z16.literal(ActionType.ARCHIVE),
1370
+ /**
1371
+ * Archiving does not collect a reason on its own. Only the
1372
+ * "mark as duplicate" flow archives with a reason attached.
1373
+ */
1374
+ content: ReasonContent.optional()
1199
1375
  }).shape
1200
1376
  );
1201
1377
  var UnarchiveAction = ActionBase.extend(
1202
- z14.object({
1203
- type: z14.literal(ActionType.UNARCHIVE)
1378
+ z16.object({
1379
+ type: z16.literal(ActionType.UNARCHIVE)
1204
1380
  }).shape
1205
1381
  );
1206
1382
  var CreatedAction = ActionBase.extend(
1207
- z14.object({
1208
- type: z14.literal(ActionType.CREATE)
1383
+ z16.object({
1384
+ type: z16.literal(ActionType.CREATE)
1209
1385
  }).shape
1210
1386
  );
1211
1387
  var NotifiedAction = ActionBase.extend(
1212
- z14.object({
1213
- type: z14.literal(ActionType.NOTIFY)
1388
+ z16.object({
1389
+ type: z16.literal(ActionType.NOTIFY)
1214
1390
  }).shape
1215
1391
  );
1216
1392
  var EditAction = ActionBase.extend(
1217
- z14.object({
1218
- type: z14.literal(ActionType.EDIT),
1219
- content: z14.object({
1220
- comment: z14.string().describe("Comment for the edit action.").optional()
1221
- })
1393
+ z16.object({
1394
+ type: z16.literal(ActionType.EDIT),
1395
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1396
+ content: z16.object({
1397
+ comment: z16.string().describe("Comment for the edit action.").optional()
1398
+ }).optional()
1222
1399
  }).shape
1223
1400
  );
1224
- var PrintContent = z14.object({
1225
- templateId: z14.string().optional()
1401
+ var PrintContent = z16.object({
1402
+ templateId: z16.string().optional()
1226
1403
  });
1227
1404
  var PrintCertificateAction = ActionBase.extend(
1228
- z14.object({
1229
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1405
+ z16.object({
1406
+ type: z16.literal(ActionType.PRINT_CERTIFICATE),
1230
1407
  content: PrintContent.optional().nullable()
1231
1408
  }).shape
1232
1409
  );
1233
1410
  var RequestedCorrectionAction = ActionBase.extend(
1234
- z14.object({
1235
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1411
+ z16.object({
1412
+ type: z16.literal(ActionType.REQUEST_CORRECTION)
1236
1413
  }).shape
1237
1414
  );
1238
1415
  var ApprovedCorrectionAction = ActionBase.extend(
1239
- z14.object({
1240
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1241
- requestId: z14.string(),
1416
+ z16.object({
1417
+ type: z16.literal(ActionType.APPROVE_CORRECTION),
1418
+ requestId: z16.string(),
1242
1419
  // TODO move into 'content' property
1243
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1420
+ content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1244
1421
  }).shape
1245
1422
  );
1246
1423
  var RejectedCorrectionAction = ActionBase.extend(
1247
- z14.object({
1248
- type: z14.literal(ActionType.REJECT_CORRECTION),
1249
- requestId: z14.string(),
1424
+ z16.object({
1425
+ type: z16.literal(ActionType.REJECT_CORRECTION),
1426
+ requestId: z16.string(),
1250
1427
  // TODO move into 'content' property
1251
1428
  content: ReasonContent
1252
1429
  }).shape
1253
1430
  );
1254
1431
  var ReadAction = ActionBase.extend(
1255
- z14.object({
1256
- type: z14.literal(ActionType.READ)
1432
+ z16.object({
1433
+ type: z16.literal(ActionType.READ)
1257
1434
  }).shape
1258
1435
  );
1259
1436
  var CustomAction = ActionBase.merge(
1260
- z14.object({
1261
- type: z14.literal(ActionType.CUSTOM),
1262
- customActionType: z14.string()
1437
+ z16.object({
1438
+ type: z16.literal(ActionType.CUSTOM),
1439
+ customActionType: z16.string()
1263
1440
  })
1264
1441
  );
1265
- var ActionDocument = z14.discriminatedUnion("type", [
1442
+ var ActionDocument = z16.discriminatedUnion("type", [
1266
1443
  CreatedAction.meta({ id: "CreatedAction" }),
1267
1444
  RejectAction.meta({ id: "RejectAction" }),
1268
1445
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1289,109 +1466,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1289
1466
  declaration: true,
1290
1467
  annotation: true
1291
1468
  }).extend(
1292
- z14.object({
1293
- type: z14.enum(ConfirmableActions),
1294
- status: z14.literal(ActionStatus.Rejected)
1469
+ z16.object({
1470
+ type: z16.enum(ConfirmableActions),
1471
+ status: z16.literal(ActionStatus.Rejected)
1295
1472
  }).shape
1296
1473
  );
1297
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1298
-
1299
- // ../commons/src/events/Flag.ts
1300
- var z15 = __toESM(require("zod/v4"));
1301
- var InherentFlags = {
1302
- INCOMPLETE: "incomplete",
1303
- REJECTED: "rejected",
1304
- CORRECTION_REQUESTED: "correction-requested",
1305
- POTENTIAL_DUPLICATE: "potential-duplicate",
1306
- /**
1307
- * This flag is set by the Edit-action and removed after the declaration or registration.
1308
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1309
- *
1310
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1311
- */
1312
- EDIT_IN_PROGRESS: "edit-in-progress"
1313
- };
1314
- var ActionFlag = z15.string().regex(
1315
- new RegExp(
1316
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1317
- ActionStatus
1318
- ).join("|").toLowerCase()})$`
1319
- ),
1320
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1321
- );
1322
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1323
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1324
- InherentFlags
1325
- ).join(", ")}`
1326
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1327
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1328
- }).describe("Custom flag identifier defined by the country config.");
1329
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1330
- var FlagConfig = z15.object({
1331
- id: CustomFlag,
1332
- requiresAction: z15.boolean().describe(
1333
- "Indicates if this flag expects an action to be performed to be cleared."
1334
- ),
1335
- label: TranslationConfig.describe("Human readable label of the flag.")
1336
- }).meta({
1337
- id: "FlagConfig",
1338
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1339
- });
1340
- var ActionFlagConfig = z15.object({
1341
- id: Flag,
1342
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1343
- conditional: Conditional.optional().describe(
1344
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1345
- )
1346
- }).meta({
1347
- id: "ActionFlagConfig",
1348
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1349
- });
1474
+ var Action = z16.union([ActionDocument, AsyncRejectActionDocument]);
1350
1475
 
1351
1476
  // ../commons/src/events/EventMetadata.ts
1352
- var EventStatus = z16.enum([
1353
- "CREATED",
1354
- "NOTIFIED",
1355
- "DECLARED",
1356
- "REGISTERED",
1357
- "ARCHIVED"
1358
- ]);
1359
- var ZodDate = z16.iso.date();
1360
- var ZodDateTime = z16.string().datetime();
1361
- var ActionCreationMetadata = z16.object({
1362
- createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1363
- createdBy: z16.string().describe("ID of the user who created the action request."),
1477
+ var ZodDate = z17.iso.date();
1478
+ var ZodDateTime = z17.string().datetime();
1479
+ var ActionCreationMetadata = z17.object({
1480
+ createdAt: z17.iso.datetime().describe("The timestamp when the action request was created."),
1481
+ createdBy: z17.string().describe("ID of the user who created the action request."),
1364
1482
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1365
1483
  createdAtLocation: UUID.nullish().describe(
1366
1484
  "Location of the user who created the action request."
1367
1485
  ),
1368
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1369
- acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1370
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1486
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1487
+ acceptedAt: z17.iso.datetime().describe("Timestamp when the action request was accepted."),
1488
+ createdByRole: z17.string().optional().describe("Role of the user at the time of action request creation.")
1371
1489
  });
1372
1490
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1373
- registrationNumber: z16.string().describe(
1491
+ registrationNumber: z17.string().describe(
1374
1492
  "Registration number of the event. Always present for accepted registrations."
1375
1493
  )
1376
1494
  });
1377
- var LegalStatuses = z16.object({
1495
+ var LegalStatuses = z17.object({
1378
1496
  [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1379
1497
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1380
1498
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1381
1499
  });
1382
- var EventMetadata = z16.object({
1500
+ var EventMetadata = z17.object({
1383
1501
  id: UUID,
1384
- type: z16.string().describe("The type of event, such as birth, death, or marriage."),
1502
+ type: z17.string().describe("The type of event, such as birth, death, or marriage."),
1385
1503
  status: EventStatus,
1386
1504
  legalStatuses: LegalStatuses.describe(
1387
1505
  "Metadata related to the legal registration of the event, such as who registered it and when."
1388
1506
  ),
1389
- createdAt: z16.iso.datetime().describe("The timestamp when the event was first created and saved."),
1507
+ createdAt: z17.iso.datetime().describe("The timestamp when the event was first created and saved."),
1390
1508
  dateOfEvent: ZodDate.nullish(),
1391
1509
  placeOfEvent: UUID.nullish(),
1392
- createdBy: z16.string().describe("ID of the user who created the event."),
1393
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1394
- updatedByUserRole: z16.string().nullish().describe("Role of the user who last changed the status."),
1510
+ createdBy: z17.string().describe("ID of the user who created the event."),
1511
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1512
+ updatedByUserRole: z17.string().nullish().describe("Role of the user who last changed the status."),
1395
1513
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1396
1514
  createdAtLocation: UUID.nullish().describe(
1397
1515
  "Location of the user who created the event."
@@ -1399,18 +1517,18 @@ var EventMetadata = z16.object({
1399
1517
  updatedAtLocation: UUID.nullish().describe(
1400
1518
  "Location of the user who last changed the status."
1401
1519
  ),
1402
- updatedAt: z16.iso.datetime().describe(
1520
+ updatedAt: z17.iso.datetime().describe(
1403
1521
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1404
1522
  ),
1405
- assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1406
- updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1407
- trackingId: z16.string().describe(
1523
+ assignedTo: z17.string().nullish().describe("ID of the user currently assigned to the event."),
1524
+ updatedBy: z17.string().nullish().describe("ID of the user who last changed the status."),
1525
+ trackingId: z17.string().describe(
1408
1526
  "System-generated tracking ID used by informants or registrars to look up the event."
1409
1527
  ),
1410
- potentialDuplicates: z16.array(PotentialDuplicate).describe(
1528
+ potentialDuplicates: z17.array(PotentialDuplicate).describe(
1411
1529
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1412
1530
  ),
1413
- flags: z16.array(Flag)
1531
+ flags: z17.array(Flag)
1414
1532
  });
1415
1533
  var EventMetadataKeysArray = [
1416
1534
  "id",
@@ -1431,8 +1549,8 @@ var EventMetadataKeysArray = [
1431
1549
  "legalStatuses",
1432
1550
  "flags"
1433
1551
  ];
1434
- var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1435
- var EventMetadataDateFieldIdInput = z16.enum([
1552
+ var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1553
+ var EventMetadataDateFieldIdInput = z17.enum([
1436
1554
  "createdAt",
1437
1555
  "updatedAt",
1438
1556
  "legalStatuses.NOTIFIED.createdAt",
@@ -1442,7 +1560,7 @@ var EventMetadataDateFieldIdInput = z16.enum([
1442
1560
  "legalStatuses.REGISTERED.createdAt",
1443
1561
  "legalStatuses.REGISTERED.acceptedAt"
1444
1562
  ]);
1445
- var EventMetadataDateFieldId = z16.enum([
1563
+ var EventMetadataDateFieldId = z17.enum([
1446
1564
  "event.createdAt",
1447
1565
  "event.updatedAt",
1448
1566
  "event.legalStatuses.NOTIFIED.createdAt",
@@ -1504,13 +1622,6 @@ var Range = import_v4.z.object({
1504
1622
  }).meta({
1505
1623
  id: "Range"
1506
1624
  });
1507
- var ContainsFlags = import_v4.z.object({
1508
- anyOf: import_v4.z.array(Flag).optional(),
1509
- noneOf: import_v4.z.array(Flag).optional(),
1510
- allOf: import_v4.z.array(Flag).optional()
1511
- }).meta({
1512
- id: "ContainsFlags"
1513
- });
1514
1625
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1515
1626
  id: "Within"
1516
1627
  });
@@ -1737,8 +1848,8 @@ var BaseField = import_v43.default.object({
1737
1848
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1738
1849
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1739
1850
  ),
1740
- secured: import_v43.default.boolean().default(false).optional().describe(
1741
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1851
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1852
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
1742
1853
  ),
1743
1854
  placeholder: TranslationConfig.optional(),
1744
1855
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2136,7 +2247,16 @@ var AdministrativeAreaField = BaseField.extend({
2136
2247
  configuration: import_v43.default.object({
2137
2248
  partOf: FieldReference.optional().describe("Parent location"),
2138
2249
  type: AdministrativeAreas,
2139
- allowedLocations: AllowedLocations
2250
+ allowedLocations: AllowedLocations,
2251
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2252
+ "List every historical name a location has had as a separate, selectable option."
2253
+ ),
2254
+ activeOnly: import_v43.default.boolean().optional().describe(
2255
+ "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."
2256
+ ),
2257
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2258
+ "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."
2259
+ )
2140
2260
  }).describe("Administrative area options")
2141
2261
  }).meta({
2142
2262
  description: "Administrative area input field",
@@ -2147,7 +2267,16 @@ var LocationInput = BaseField.extend({
2147
2267
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2148
2268
  configuration: import_v43.default.object({
2149
2269
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2150
- allowedLocations: AllowedLocations
2270
+ allowedLocations: AllowedLocations,
2271
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2272
+ "List every historical name a location has had as a separate, selectable option."
2273
+ ),
2274
+ activeOnly: import_v43.default.boolean().optional().describe(
2275
+ "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."
2276
+ ),
2277
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2278
+ "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."
2279
+ )
2151
2280
  }).optional()
2152
2281
  }).meta({
2153
2282
  description: "A field for selecting a location",
@@ -2173,12 +2302,22 @@ var FileUploadWithOptions = BaseField.extend({
2173
2302
  var Facility = BaseField.extend({
2174
2303
  type: import_v43.default.literal(FieldType.FACILITY),
2175
2304
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2176
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2305
+ configuration: import_v43.default.object({
2306
+ allowedLocations: AllowedLocations,
2307
+ listHistoricalNames: import_v43.default.boolean().optional(),
2308
+ activeOnly: import_v43.default.boolean().optional(),
2309
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2310
+ }).optional()
2177
2311
  }).describe("Input field for a facility");
2178
2312
  var Office = BaseField.extend({
2179
2313
  type: import_v43.default.literal(FieldType.OFFICE),
2180
2314
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2181
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2315
+ configuration: import_v43.default.object({
2316
+ allowedLocations: AllowedLocations,
2317
+ listHistoricalNames: import_v43.default.boolean().optional(),
2318
+ activeOnly: import_v43.default.boolean().optional(),
2319
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2320
+ }).optional()
2182
2321
  }).describe("Input field for an office");
2183
2322
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2184
2323
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2211,7 +2350,16 @@ var Address = BaseField.extend({
2211
2350
  parent: FieldReference.optional()
2212
2351
  })
2213
2352
  ).optional(),
2214
- allowedLocations: AllowedLocations
2353
+ allowedLocations: AllowedLocations,
2354
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2355
+ "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2356
+ ),
2357
+ activeOnly: import_v43.default.boolean().optional().describe(
2358
+ "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."
2359
+ ),
2360
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2361
+ "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."
2362
+ )
2215
2363
  }).optional(),
2216
2364
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2217
2365
  }).meta({
@@ -2512,18 +2660,21 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2512
2660
  ]);
2513
2661
 
2514
2662
  // ../commons/src/events/FormConfig.ts
2515
- var z22 = __toESM(require("zod/v4"));
2663
+ var z23 = __toESM(require("zod/v4"));
2516
2664
 
2517
2665
  // ../commons/src/events/PageConfig.ts
2518
- var z21 = __toESM(require("zod/v4"));
2519
- var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2520
- var PageConfigBase = z21.object({
2521
- id: z21.string().describe("Unique identifier for the page"),
2666
+ var z22 = __toESM(require("zod/v4"));
2667
+ var PageTypes = z22.enum(["FORM", "VERIFICATION"]);
2668
+ var PageConfigBase = z22.object({
2669
+ id: z22.string().describe("Unique identifier for the page"),
2522
2670
  title: TranslationConfig.describe("Header title of the page"),
2523
- requireCompletionToContinue: z21.boolean().default(false).describe(
2671
+ requireCompletionToContinue: z22.boolean().default(false).describe(
2524
2672
  "If true, all required fields must be filled before continuing to the next page"
2525
2673
  ),
2526
- fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2674
+ showClearButton: z22.boolean().optional().describe(
2675
+ 'If true, a "Clear" button is shown at the top of the page allowing the user to reset all fields on the page to their default state'
2676
+ ),
2677
+ fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2527
2678
  conditional: Conditional.optional().describe(
2528
2679
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2529
2680
  )
@@ -2532,13 +2683,13 @@ var PageConfigBase = z21.object({
2532
2683
  id: "FormPageConfig"
2533
2684
  });
2534
2685
  var FormPageConfig = PageConfigBase.extend({
2535
- type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2686
+ type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2536
2687
  });
2537
- var VerificationActionConfig = z21.object({
2538
- verify: z21.object({ label: TranslationConfig }),
2539
- cancel: z21.object({
2688
+ var VerificationActionConfig = z22.object({
2689
+ verify: z22.object({ label: TranslationConfig }),
2690
+ cancel: z22.object({
2540
2691
  label: TranslationConfig,
2541
- confirmation: z21.object({
2692
+ confirmation: z22.object({
2542
2693
  title: TranslationConfig,
2543
2694
  body: TranslationConfig
2544
2695
  })
@@ -2548,34 +2699,34 @@ var VerificationActionConfig = z21.object({
2548
2699
  id: "VerificationActionConfig"
2549
2700
  });
2550
2701
  var VerificationPageConfig = FormPageConfig.extend({
2551
- type: z21.literal(PageTypes.enum.VERIFICATION),
2702
+ type: z22.literal(PageTypes.enum.VERIFICATION),
2552
2703
  actions: VerificationActionConfig
2553
2704
  });
2554
- var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2705
+ var PageConfig = z22.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2555
2706
  id: "PageConfig",
2556
2707
  description: "Configuration for a single page in a form. Either a form page with fields and a continue button, or a verification page with verify/cancel options."
2557
2708
  });
2558
2709
 
2559
2710
  // ../commons/src/events/FormConfig.ts
2560
- var DeclarationFormConfig = z22.object({
2711
+ var DeclarationFormConfig = z23.object({
2561
2712
  label: TranslationConfig.describe("Human readable description of the form"),
2562
- pages: z22.array(FormPageConfig)
2713
+ pages: z23.array(FormPageConfig)
2563
2714
  }).meta({
2564
2715
  id: "DeclarationFormConfig",
2565
2716
  description: "Configuration of the declaration form."
2566
2717
  });
2567
- var ActionFormConfig = z22.object({
2718
+ var ActionFormConfig = z23.object({
2568
2719
  label: TranslationConfig.describe("Human readable description of the form"),
2569
- pages: z22.array(PageConfig)
2720
+ pages: z23.array(PageConfig)
2570
2721
  }).describe(
2571
2722
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
2572
2723
  );
2573
- var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
2724
+ var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2574
2725
 
2575
2726
  // ../commons/src/events/DeduplicationConfig.ts
2576
- var z23 = __toESM(require("zod/v4"));
2577
- var FieldReference2 = z23.string();
2578
- var Matcher = z23.object({
2727
+ var z24 = __toESM(require("zod/v4"));
2728
+ var FieldReference2 = z24.string();
2729
+ var Matcher = z24.object({
2579
2730
  /**
2580
2731
  * Reference to the field used in matching.
2581
2732
  *
@@ -2583,23 +2734,23 @@ var Matcher = z23.object({
2583
2734
  * be used as the origin date to calculate the distance from.
2584
2735
  */
2585
2736
  fieldId: FieldReference2,
2586
- options: z23.object({
2587
- boost: z23.number().optional(),
2737
+ options: z24.object({
2738
+ boost: z24.number().optional(),
2588
2739
  matchAgainst: FieldReference2.optional()
2589
2740
  }).optional().default({
2590
2741
  boost: 1
2591
2742
  })
2592
2743
  });
2593
2744
  var FuzzyMatcher = Matcher.extend({
2594
- type: z23.literal("fuzzy"),
2595
- options: z23.object({
2745
+ type: z24.literal("fuzzy"),
2746
+ options: z24.object({
2596
2747
  /**
2597
2748
  * Names of length 3 or less characters = 0 edits allowed
2598
2749
  * Names of length 4 - 6 characters = 1 edit allowed
2599
2750
  * Names of length >7 characters = 2 edits allowed
2600
2751
  */
2601
- fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2602
- boost: z23.number().optional().default(1),
2752
+ fuzziness: z24.union([z24.string(), z24.number()]).optional().default("AUTO:4,7"),
2753
+ boost: z24.number().optional().default(1),
2603
2754
  matchAgainst: FieldReference2.optional()
2604
2755
  }).optional().default({
2605
2756
  fuzziness: "AUTO:4,7",
@@ -2607,48 +2758,48 @@ var FuzzyMatcher = Matcher.extend({
2607
2758
  })
2608
2759
  });
2609
2760
  var StrictMatcher = Matcher.extend({
2610
- type: z23.literal("strict"),
2611
- options: z23.object({
2612
- boost: z23.number().optional().default(1),
2761
+ type: z24.literal("strict"),
2762
+ options: z24.object({
2763
+ boost: z24.number().optional().default(1),
2613
2764
  /**
2614
2765
  * The constant value to be present in the field for both records
2615
2766
  */
2616
- value: z23.string().optional(),
2767
+ value: z24.string().optional(),
2617
2768
  matchAgainst: FieldReference2.optional()
2618
2769
  }).optional().default({
2619
2770
  boost: 1
2620
2771
  })
2621
2772
  });
2622
2773
  var DateRangeMatcher = Matcher.extend({
2623
- type: z23.literal("dateRange"),
2624
- options: z23.object({
2774
+ type: z24.literal("dateRange"),
2775
+ options: z24.object({
2625
2776
  /**
2626
2777
  * The distance pivot in days. Distance from the origin (the value of
2627
2778
  * fieldId) at which relevance scores receive half of the boost value
2628
2779
  */
2629
- pivot: z23.number().optional(),
2630
- days: z23.number(),
2631
- boost: z23.number().optional().default(1),
2780
+ pivot: z24.number().optional(),
2781
+ days: z24.number(),
2782
+ boost: z24.number().optional().default(1),
2632
2783
  matchAgainst: FieldReference2.optional()
2633
2784
  })
2634
2785
  });
2635
- var Not = z23.object({
2636
- type: z23.literal("not"),
2786
+ var Not = z24.object({
2787
+ type: z24.literal("not"),
2637
2788
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2638
- clause: z23.lazy(() => Clause)
2789
+ clause: z24.lazy(() => Clause)
2639
2790
  });
2640
- var And = z23.object({
2641
- type: z23.literal("and"),
2791
+ var And = z24.object({
2792
+ type: z24.literal("and"),
2642
2793
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2643
- clauses: z23.lazy(() => Clause.array())
2794
+ clauses: z24.lazy(() => Clause.array())
2644
2795
  });
2645
- var Or = z23.object({
2646
- type: z23.literal("or"),
2796
+ var Or = z24.object({
2797
+ type: z24.literal("or"),
2647
2798
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2648
- clauses: z23.lazy(() => Clause.array())
2799
+ clauses: z24.lazy(() => Clause.array())
2649
2800
  });
2650
- var Clause = z23.lazy(
2651
- () => z23.discriminatedUnion("type", [
2801
+ var Clause = z24.lazy(
2802
+ () => z24.discriminatedUnion("type", [
2652
2803
  Not,
2653
2804
  And,
2654
2805
  Or,
@@ -2659,8 +2810,8 @@ var Clause = z23.lazy(
2659
2810
  ).meta({
2660
2811
  id: "Clause"
2661
2812
  });
2662
- var DeduplicationConfig = z23.object({
2663
- id: z23.string(),
2813
+ var DeduplicationConfig = z24.object({
2814
+ id: z24.string(),
2664
2815
  label: TranslationConfig,
2665
2816
  query: Clause
2666
2817
  }).meta({
@@ -2669,15 +2820,15 @@ var DeduplicationConfig = z23.object({
2669
2820
  });
2670
2821
 
2671
2822
  // ../commons/src/events/ActionConfig.ts
2672
- var DeclarationReviewConfig = z24.object({
2823
+ var DeclarationReviewConfig = z25.object({
2673
2824
  title: TranslationConfig.describe("Title of the review page"),
2674
- fields: z24.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2825
+ fields: z25.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2675
2826
  }).describe(
2676
2827
  "Configuration of the declaration review page for collecting event-related metadata."
2677
2828
  );
2678
- var ActionConfigBase = z24.object({
2829
+ var ActionConfigBase = z25.object({
2679
2830
  label: TranslationConfig.describe("Human readable description of the action"),
2680
- flags: z24.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2831
+ flags: z25.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2681
2832
  supportingCopy: TranslationConfig.optional().describe(
2682
2833
  "Text displayed on the confirmation dialog"
2683
2834
  ),
@@ -2688,84 +2839,84 @@ var ActionConfigBase = z24.object({
2688
2839
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
2689
2840
  * for EventConfig.d.ts.
2690
2841
  */
2691
- icon: z24.string().describe("Icon representing the action").optional(),
2692
- conditionals: z24.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2842
+ icon: z25.string().describe("Icon representing the action").optional(),
2843
+ conditionals: z25.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2693
2844
  });
2694
2845
  var DeclarationActionBase = ActionConfigBase.extend({
2695
2846
  deduplication: DeduplicationConfig.optional()
2696
2847
  });
2697
- var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2848
+ var actionConfirmationForm = z25.array(FieldConfig).optional().describe(
2698
2849
  "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2699
2850
  );
2700
2851
  var ReadActionConfig = ActionConfigBase.extend(
2701
- z24.object({
2702
- type: z24.literal(ActionType.READ),
2852
+ z25.object({
2853
+ type: z25.literal(ActionType.READ),
2703
2854
  review: DeclarationReviewConfig.describe(
2704
2855
  "Configuration of the review page for read-only view."
2705
2856
  ),
2706
- conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2857
+ conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2707
2858
  }).shape
2708
2859
  );
2709
2860
  var NotifyConfig = ActionConfigBase.extend(
2710
- z24.object({
2711
- type: z24.literal(ActionType.NOTIFY),
2861
+ z25.object({
2862
+ type: z25.literal(ActionType.NOTIFY),
2712
2863
  form: actionConfirmationForm
2713
2864
  }).shape
2714
2865
  );
2715
2866
  var DuplicateDetectedConfig = ActionConfigBase.extend(
2716
- z24.object({
2717
- type: z24.literal(ActionType.DUPLICATE_DETECTED),
2718
- label: z24.never().optional().describe(
2867
+ z25.object({
2868
+ type: z25.literal(ActionType.DUPLICATE_DETECTED),
2869
+ label: z25.never().optional().describe(
2719
2870
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2720
2871
  ),
2721
- supportingCopy: z24.never().optional(),
2722
- icon: z24.never().optional().describe(
2872
+ supportingCopy: z25.never().optional(),
2873
+ icon: z25.never().optional().describe(
2723
2874
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2724
2875
  ),
2725
- conditionals: z24.never().optional().describe(
2876
+ conditionals: z25.never().optional().describe(
2726
2877
  "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2727
2878
  )
2728
2879
  }).shape
2729
2880
  );
2730
2881
  var MarkAsDuplicateConfig = ActionConfigBase.extend(
2731
- z24.object({
2732
- type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2882
+ z25.object({
2883
+ type: z25.literal(ActionType.MARK_AS_DUPLICATE)
2733
2884
  }).shape
2734
2885
  );
2735
2886
  var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2736
- z24.object({
2737
- type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2887
+ z25.object({
2888
+ type: z25.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2738
2889
  }).shape
2739
2890
  );
2740
2891
  var AssignConfig = ActionConfigBase.extend(
2741
- z24.object({
2742
- type: z24.literal(ActionType.ASSIGN),
2743
- flags: z24.never().optional().describe(
2892
+ z25.object({
2893
+ type: z25.literal(ActionType.ASSIGN),
2894
+ flags: z25.never().optional().describe(
2744
2895
  "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2745
2896
  )
2746
2897
  }).shape
2747
2898
  );
2748
2899
  var UnassignConfig = ActionConfigBase.extend(
2749
- z24.object({
2750
- type: z24.literal(ActionType.UNASSIGN),
2751
- flags: z24.never().optional().describe(
2900
+ z25.object({
2901
+ type: z25.literal(ActionType.UNASSIGN),
2902
+ flags: z25.never().optional().describe(
2752
2903
  "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2753
2904
  )
2754
2905
  }).shape
2755
2906
  );
2756
2907
  var DeleteConfig = ActionConfigBase.extend(
2757
- z24.object({
2758
- type: z24.literal(ActionType.DELETE)
2908
+ z25.object({
2909
+ type: z25.literal(ActionType.DELETE)
2759
2910
  }).shape
2760
2911
  );
2761
2912
  var DeclareConfig = DeclarationActionBase.extend(
2762
- z24.object({
2763
- type: z24.literal(ActionType.DECLARE),
2913
+ z25.object({
2914
+ type: z25.literal(ActionType.DECLARE),
2764
2915
  review: DeclarationReviewConfig.describe(
2765
2916
  "Configuration of the review page fields."
2766
2917
  ),
2767
2918
  form: actionConfirmationForm,
2768
- dialogCopy: z24.object({
2919
+ dialogCopy: z25.object({
2769
2920
  notify: TranslationConfig.describe(
2770
2921
  "Confirmation text for the notify action"
2771
2922
  ),
@@ -2779,20 +2930,20 @@ var DeclareConfig = DeclarationActionBase.extend(
2779
2930
  }).shape
2780
2931
  );
2781
2932
  var ArchiveConfig = ActionConfigBase.extend(
2782
- z24.object({
2783
- type: z24.literal(ActionType.ARCHIVE),
2933
+ z25.object({
2934
+ type: z25.literal(ActionType.ARCHIVE),
2784
2935
  form: actionConfirmationForm
2785
2936
  }).shape
2786
2937
  );
2787
2938
  var UnarchiveConfig = ActionConfigBase.extend(
2788
- z24.object({
2789
- type: z24.literal(ActionType.UNARCHIVE)
2939
+ z25.object({
2940
+ type: z25.literal(ActionType.UNARCHIVE)
2790
2941
  }).shape
2791
2942
  );
2792
2943
  var EditActionConfig = ActionConfigBase.extend(
2793
- z24.object({
2794
- type: z24.literal(ActionType.EDIT),
2795
- dialogCopy: z24.object({
2944
+ z25.object({
2945
+ type: z25.literal(ActionType.EDIT),
2946
+ dialogCopy: z25.object({
2796
2947
  notify: TranslationConfig.describe(
2797
2948
  "Confirmation text for the notify with edits action"
2798
2949
  ),
@@ -2806,45 +2957,45 @@ var EditActionConfig = ActionConfigBase.extend(
2806
2957
  }).shape
2807
2958
  );
2808
2959
  var RejectConfig = ActionConfigBase.extend(
2809
- z24.object({
2810
- type: z24.literal(ActionType.REJECT),
2960
+ z25.object({
2961
+ type: z25.literal(ActionType.REJECT),
2811
2962
  form: actionConfirmationForm
2812
2963
  }).shape
2813
2964
  );
2814
2965
  var RegisterConfig = DeclarationActionBase.extend(
2815
- z24.object({
2816
- type: z24.literal(ActionType.REGISTER),
2966
+ z25.object({
2967
+ type: z25.literal(ActionType.REGISTER),
2817
2968
  form: actionConfirmationForm
2818
2969
  }).shape
2819
2970
  );
2820
2971
  var PrintCertificateActionConfig = ActionConfigBase.extend(
2821
- z24.object({
2822
- type: z24.literal(ActionType.PRINT_CERTIFICATE),
2972
+ z25.object({
2973
+ type: z25.literal(ActionType.PRINT_CERTIFICATE),
2823
2974
  printForm: ActionFormConfig
2824
2975
  }).shape
2825
2976
  );
2826
2977
  var RequestCorrectionConfig = ActionConfigBase.extend(
2827
- z24.object({
2828
- type: z24.literal(ActionType.REQUEST_CORRECTION),
2978
+ z25.object({
2979
+ type: z25.literal(ActionType.REQUEST_CORRECTION),
2829
2980
  correctionForm: ActionFormConfig
2830
2981
  }).shape
2831
2982
  );
2832
2983
  var ApproveCorrectionConfig = ActionConfigBase.extend(
2833
- z24.object({
2834
- type: z24.literal(ActionType.APPROVE_CORRECTION)
2984
+ z25.object({
2985
+ type: z25.literal(ActionType.APPROVE_CORRECTION)
2835
2986
  }).shape
2836
2987
  );
2837
2988
  var RejectCorrectionConfig = ActionConfigBase.extend(
2838
- z24.object({
2839
- type: z24.literal(ActionType.REJECT_CORRECTION)
2989
+ z25.object({
2990
+ type: z25.literal(ActionType.REJECT_CORRECTION)
2840
2991
  }).shape
2841
2992
  );
2842
2993
  var CustomActionConfig = ActionConfigBase.extend(
2843
- z24.object({
2844
- type: z24.literal(ActionType.CUSTOM),
2845
- customActionType: z24.string().describe("Type identifier of the custom action."),
2994
+ z25.object({
2995
+ type: z25.literal(ActionType.CUSTOM),
2996
+ customActionType: z25.string().describe("Type identifier of the custom action."),
2846
2997
  /** Custom action form configuration supports a simple array of field configs, which should be rendered on the action modal. In the future, we might add support for pages etc. */
2847
- form: z24.array(FieldConfig).describe(
2998
+ form: z25.array(FieldConfig).describe(
2848
2999
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
2849
3000
  ),
2850
3001
  auditHistoryLabel: TranslationConfig.describe(
@@ -2852,7 +3003,7 @@ var CustomActionConfig = ActionConfigBase.extend(
2852
3003
  )
2853
3004
  }).shape
2854
3005
  );
2855
- var ActionConfig = z24.discriminatedUnion("type", [
3006
+ var ActionConfig = z25.discriminatedUnion("type", [
2856
3007
  /*
2857
3008
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
2858
3009
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -2939,89 +3090,225 @@ var ActionConfig = z24.discriminatedUnion("type", [
2939
3090
  var actionConfigTypes = new Set(
2940
3091
  ActionConfig.options.map((opt) => opt.shape.type.value)
2941
3092
  );
2942
- var DeclarationActionConfig = z24.discriminatedUnion("type", [
3093
+ var DeclarationActionConfig = z25.discriminatedUnion("type", [
2943
3094
  DeclareConfig,
2944
3095
  RegisterConfig
2945
3096
  ]);
2946
3097
 
2947
3098
  // ../commons/src/events/offline/CertificateConfig.ts
2948
- var z25 = __toESM(require("zod/v4"));
2949
- var FontFamily = z25.object({
2950
- normal: z25.string(),
2951
- bold: z25.string(),
2952
- italics: z25.string(),
2953
- bolditalics: z25.string()
2954
- });
2955
- var CertificateConfig = z25.object({
2956
- id: z25.string(),
2957
- event: z25.string(),
2958
- isV2Template: z25.boolean().optional(),
3099
+ var z26 = __toESM(require("zod/v4"));
3100
+ var FontFamily = z26.object({
3101
+ normal: z26.string(),
3102
+ bold: z26.string(),
3103
+ italics: z26.string(),
3104
+ bolditalics: z26.string()
3105
+ });
3106
+ var CertificateConfig = z26.object({
3107
+ id: z26.string(),
3108
+ event: z26.string(),
3109
+ isV2Template: z26.boolean().optional(),
2959
3110
  label: TranslationConfig,
2960
- isDefault: z25.boolean(),
2961
- fee: z25.object({
2962
- onTime: z25.number(),
2963
- late: z25.number(),
2964
- delayed: z25.number()
3111
+ isDefault: z26.boolean(),
3112
+ fee: z26.object({
3113
+ onTime: z26.number(),
3114
+ late: z26.number(),
3115
+ delayed: z26.number()
2965
3116
  }),
2966
- svgUrl: z25.string(),
2967
- fonts: z25.record(z25.string(), FontFamily).optional(),
2968
- conditionals: z25.array(ShowConditional).optional()
3117
+ svgUrl: z26.string(),
3118
+ fonts: z26.record(z26.string(), FontFamily).optional(),
3119
+ conditionals: z26.array(ShowConditional).optional()
2969
3120
  });
2970
3121
  var CertificateTemplateConfig = CertificateConfig.extend({
2971
- hash: z25.string().optional(),
2972
- svg: z25.string()
3122
+ hash: z26.string().optional(),
3123
+ svg: z26.string()
2973
3124
  });
2974
3125
 
2975
3126
  // ../commons/src/events/offline/LanguageConfig.ts
2976
- var z26 = __toESM(require("zod/v4"));
2977
- var LanguageConfig = z26.object({
2978
- lang: z26.string(),
3127
+ var z27 = __toESM(require("zod/v4"));
3128
+ var LanguageConfig = z27.object({
3129
+ lang: z27.string(),
2979
3130
  /**
2980
3131
  * client.csv contents
2981
3132
  */
2982
- messages: z26.record(z26.string(), z26.string())
3133
+ messages: z27.record(z27.string(), z27.string())
2983
3134
  });
2984
3135
 
2985
3136
  // ../commons/src/events/EventConfig.ts
2986
- var z33 = __toESM(require("zod/v4"));
3137
+ var z35 = __toESM(require("zod/v4"));
2987
3138
 
2988
3139
  // ../commons/src/events/SummaryConfig.ts
2989
- var z27 = __toESM(require("zod/v4"));
2990
- var BaseField2 = z27.object({
3140
+ var z29 = __toESM(require("zod/v4"));
3141
+
3142
+ // ../commons/src/icons.ts
3143
+ var z28 = __toESM(require("zod/v4"));
3144
+ var AvailableIcons = z28.enum([
3145
+ "Archived",
3146
+ "Assigned",
3147
+ "Briefcase",
3148
+ "Certified",
3149
+ "Close",
3150
+ "Collapse",
3151
+ "Draft",
3152
+ "DuplicateYellow",
3153
+ "Expand",
3154
+ "ExternalValidate",
3155
+ "FilledCheck",
3156
+ "InReview",
3157
+ "Offline",
3158
+ "Registered",
3159
+ "RequiresUpdates",
3160
+ "Sent",
3161
+ "Validated",
3162
+ "WaitingApproval",
3163
+ "ChartActivity",
3164
+ "Activity",
3165
+ "Archive",
3166
+ "ArchiveTray",
3167
+ "ArrowLeft",
3168
+ "ArrowRight",
3169
+ "Buildings",
3170
+ "Circle",
3171
+ "CaretDown",
3172
+ "CaretLeft",
3173
+ "CaretRight",
3174
+ "ChartBar",
3175
+ "ChartLine",
3176
+ "ChatCircle",
3177
+ "CheckSquare",
3178
+ "Compass",
3179
+ "Check",
3180
+ "Copy",
3181
+ "Database",
3182
+ "DotsThreeVertical",
3183
+ "ArrowCounterClockwise",
3184
+ "MagnifyingGlassMinus",
3185
+ "MagnifyingGlassPlus",
3186
+ "Export",
3187
+ "Eye",
3188
+ "EyeSlash",
3189
+ "Envelope",
3190
+ "File",
3191
+ "FileLock",
3192
+ "FileSearch",
3193
+ "FileMinus",
3194
+ "FilePlus",
3195
+ "FileText",
3196
+ "FileX",
3197
+ "Handshake",
3198
+ "Gear",
3199
+ "GitBranch",
3200
+ "IdentificationCard",
3201
+ "List",
3202
+ "ListBullets",
3203
+ "Lock",
3204
+ "MagnifyingGlass",
3205
+ "MapPin",
3206
+ "Medal",
3207
+ "NotePencil",
3208
+ "Paperclip",
3209
+ "PaperPlaneTilt",
3210
+ "Pen",
3211
+ "PenNib",
3212
+ "Pencil",
3213
+ "PencilSimpleLine",
3214
+ "Phone",
3215
+ "Plus",
3216
+ "Printer",
3217
+ "SignOut",
3218
+ "Stamp",
3219
+ "Star",
3220
+ "Target",
3221
+ "TextT",
3222
+ "Trash",
3223
+ "UploadSimple",
3224
+ "User",
3225
+ "UserPlus",
3226
+ "Users",
3227
+ "WarningCircle",
3228
+ "X",
3229
+ "ChatText",
3230
+ "CircleWavyCheck",
3231
+ "CircleWavyQuestion",
3232
+ "ArchiveBox",
3233
+ "ArrowCircleDown",
3234
+ "FileArrowUp",
3235
+ "FileDotted",
3236
+ "Files",
3237
+ "PencilLine",
3238
+ "PencilCircle",
3239
+ "UserCircle",
3240
+ "Clock",
3241
+ "QrCode",
3242
+ "Webcam",
3243
+ "Sun",
3244
+ "DeviceTabletCamera",
3245
+ "Globe",
3246
+ "Fingerprint",
3247
+ "PushPin",
3248
+ "Timer"
3249
+ ]);
3250
+
3251
+ // ../commons/src/events/SummaryConfig.ts
3252
+ var InfoBox = z29.object({
3253
+ type: z29.enum(["info", "positive", "warning", "negative"]).describe(
3254
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3255
+ ),
3256
+ background: z29.enum(["tinted", "white"]).default("tinted").optional().describe(
3257
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3258
+ ),
3259
+ icon: AvailableIcons.optional().describe(
3260
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3261
+ ),
3262
+ heading: TranslationConfig.describe(
3263
+ "Primary message. Short, sentence-case."
3264
+ ),
3265
+ description: TranslationConfig.optional().describe(
3266
+ "Secondary copy displayed below the heading, typically a suggested next step."
3267
+ ),
3268
+ conditionals: z29.array(ShowConditional).default([]).optional().describe(
3269
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3270
+ )
3271
+ }).describe(
3272
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3273
+ );
3274
+ var BaseField2 = z29.object({
2991
3275
  emptyValueMessage: TranslationConfig.optional().describe(
2992
3276
  "Default message displayed when the field value is empty."
2993
3277
  ),
2994
- conditionals: z27.array(ShowConditional).default([]).optional()
3278
+ conditionals: z29.array(ShowConditional).default([]).optional()
2995
3279
  });
2996
3280
  var ReferenceField = BaseField2.extend({
2997
- fieldId: z27.string(),
3281
+ fieldId: z29.string(),
2998
3282
  label: TranslationConfig.optional().describe(
2999
3283
  "Overrides the default label from the referenced field when provided."
3000
3284
  )
3001
3285
  }).describe("Field referencing existing event data by field ID.");
3002
3286
  var Field = BaseField2.extend({
3003
- id: z27.string().describe("Identifier of the summary field."),
3287
+ id: z29.string().describe("Identifier of the summary field."),
3004
3288
  value: TranslationConfig.describe(
3005
3289
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3006
3290
  ),
3007
3291
  label: TranslationConfig
3008
3292
  }).describe("Custom field defined for the summary view.");
3009
- var SummaryConfig = z27.object({
3010
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3293
+ var SummaryConfig = z29.object({
3294
+ banners: z29.array(InfoBox).default([]).optional().describe(
3295
+ "Info boxes displayed above the summary fields in the event overview."
3296
+ ),
3297
+ fields: z29.array(z29.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3011
3298
  }).meta({
3012
3299
  id: "SummaryConfig",
3013
3300
  description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3014
3301
  });
3015
3302
 
3016
3303
  // ../commons/src/events/AdvancedSearchConfig.ts
3017
- var z28 = __toESM(require("zod/v4"));
3018
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3019
- var BaseField3 = z28.object({
3020
- config: z28.object({
3304
+ var z30 = __toESM(require("zod/v4"));
3305
+ var MatchType = z30.enum(["fuzzy", "exact", "range", "within"]);
3306
+ var BaseField3 = z30.object({
3307
+ config: z30.object({
3021
3308
  type: MatchType.describe(
3022
3309
  "Determines the search type of field. How to match value."
3023
3310
  ),
3024
- searchFields: z28.array(z28.string()).optional().describe(
3311
+ searchFields: z30.array(z30.string()).optional().describe(
3025
3312
  `
3026
3313
  Defines multiple form fields that should be searched when this field has a value.
3027
3314
  All specified fields will be combined using OR logic.
@@ -3031,7 +3318,7 @@ var BaseField3 = z28.object({
3031
3318
  `
3032
3319
  )
3033
3320
  }),
3034
- type: z28.nativeEnum(FieldType).optional().describe(
3321
+ type: z30.nativeEnum(FieldType).optional().describe(
3035
3322
  `
3036
3323
  Explicitly specify the field type for searchFields.
3037
3324
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -3045,7 +3332,7 @@ var BaseField3 = z28.object({
3045
3332
  This is required when searchFields is defined.
3046
3333
  `
3047
3334
  ),
3048
- options: z28.array(SelectOption).optional(),
3335
+ options: z30.array(SelectOption).optional(),
3049
3336
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3050
3337
  `
3051
3338
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3066,7 +3353,7 @@ var BaseField3 = z28.object({
3066
3353
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3067
3354
  `
3068
3355
  ),
3069
- conditionals: z28.array(FieldConditional).optional().describe(
3356
+ conditionals: z30.array(FieldConditional).optional().describe(
3070
3357
  `
3071
3358
  In advanced search, we sometimes need to override the default field visibility conditionals.
3072
3359
 
@@ -3080,23 +3367,23 @@ var BaseField3 = z28.object({
3080
3367
  are always rendered in the advanced search form.
3081
3368
  `
3082
3369
  ),
3083
- validations: z28.array(ValidationConfig).optional().describe(
3370
+ validations: z30.array(ValidationConfig).optional().describe(
3084
3371
  `Option for overriding the field validations specifically for advanced search form.`
3085
3372
  ),
3086
3373
  allowedLocations: JurisdictionReference.optional().describe(
3087
3374
  `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3088
3375
  )
3089
3376
  });
3090
- var SearchQueryParams = z28.object({
3091
- eventType: z28.string().optional().describe(
3377
+ var SearchQueryParams = z30.object({
3378
+ eventType: z30.string().optional().describe(
3092
3379
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3093
3380
  )
3094
3381
  }).catchall(FieldValue);
3095
3382
  var FieldConfigSchema = BaseField3.extend({
3096
- fieldId: z28.string(),
3097
- fieldType: z28.literal("field")
3383
+ fieldId: z30.string(),
3384
+ fieldType: z30.literal("field")
3098
3385
  });
3099
- var EventFieldIdInput = z28.enum([
3386
+ var EventFieldIdInput = z30.enum([
3100
3387
  "trackingId",
3101
3388
  "status",
3102
3389
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3105,7 +3392,7 @@ var EventFieldIdInput = z28.enum([
3105
3392
  "updatedAt"
3106
3393
  ]);
3107
3394
  var METADATA_FIELD_PREFIX = "event.";
3108
- var EventFieldId = z28.enum([
3395
+ var EventFieldId = z30.enum([
3109
3396
  `${METADATA_FIELD_PREFIX}trackingId`,
3110
3397
  `${METADATA_FIELD_PREFIX}status`,
3111
3398
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3115,195 +3402,60 @@ var EventFieldId = z28.enum([
3115
3402
  ]);
3116
3403
  var EventFieldConfigSchema = BaseField3.extend({
3117
3404
  fieldId: EventFieldId,
3118
- fieldType: z28.literal("event")
3405
+ fieldType: z30.literal("event")
3119
3406
  });
3120
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3407
+ var AdvancedSearchField = z30.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3121
3408
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3122
3409
  if (!data.label) {
3123
3410
  ctx.addIssue({
3124
- code: z28.ZodIssueCode.custom,
3411
+ code: z30.ZodIssueCode.custom,
3125
3412
  message: "label is required when config.searchFields is defined.",
3126
3413
  path: ["label"]
3127
3414
  });
3128
3415
  }
3129
3416
  if (!data.type) {
3130
3417
  ctx.addIssue({
3131
- code: z28.ZodIssueCode.custom,
3418
+ code: z30.ZodIssueCode.custom,
3132
3419
  message: "type is required when config.searchFields is defined.",
3133
3420
  path: ["type"]
3134
3421
  });
3135
3422
  }
3136
3423
  }
3137
- });
3138
- var AdvancedSearchConfig = z28.object({
3139
- title: TranslationConfig.describe("Advanced search tab title"),
3140
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3141
- }).meta({
3142
- id: "AdvancedSearchConfig",
3143
- description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
3144
- });
3145
-
3146
- // ../commons/src/events/utils.ts
3147
- var import_lodash = require("lodash");
3148
-
3149
- // ../commons/src/conditionals/validate.ts
3150
- var import__ = __toESM(require("ajv/dist/2019"));
3151
- var import_ajv_formats = __toESM(require("ajv-formats"));
3152
- var z31 = __toESM(require("zod/v4"));
3153
- var import_date_fns = require("date-fns");
3154
-
3155
- // ../commons/src/events/FieldTypeMapping.ts
3156
- var z30 = __toESM(require("zod/v4"));
3157
-
3158
- // ../commons/src/events/DynamicFieldValue.ts
3159
- var z29 = __toESM(require("zod/v4"));
3160
-
3161
- // ../commons/src/conditionals/validate.ts
3162
- var ajv = new import__.default({
3163
- $data: true,
3164
- allowUnionTypes: true,
3165
- strict: false
3166
- // Allow minContains and other newer features
3167
- });
3168
- var DataContext = z31.object({
3169
- rootData: z31.object({
3170
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3171
- })
3172
- });
3173
- function resolveDataPath(rootData, dataPath, instancePath) {
3174
- const pathParts = dataPath.split("/");
3175
- const levels = parseInt(pathParts[0], 10);
3176
- const referencePath = pathParts.slice(1);
3177
- const instanceParts = instancePath.split("/").filter(Boolean);
3178
- const traversedParts = instanceParts.slice(0, -levels);
3179
- let current = rootData;
3180
- for (const part of traversedParts) {
3181
- if (current === null || current === void 0) {
3182
- return void 0;
3183
- }
3184
- current = current[part];
3185
- }
3186
- for (const part of referencePath) {
3187
- if (current === null || current === void 0) {
3188
- return void 0;
3189
- }
3190
- current = current[part];
3191
- }
3192
- return current;
3193
- }
3194
- function todayISO() {
3195
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3196
- }
3197
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3198
- function compileClientFunction(code) {
3199
- let fn = compiledFunctionCache.get(code);
3200
- if (!fn) {
3201
- fn = new Function(`return (${code})`)();
3202
- compiledFunctionCache.set(code, fn);
3203
- }
3204
- return fn;
3205
- }
3206
- (0, import_ajv_formats.default)(ajv);
3207
- function buildClientFunctionContext(input) {
3208
- return {
3209
- $form: input.form,
3210
- $now: todayISO(),
3211
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3212
- $online: isOnline(),
3213
- $user: input.validatorContext?.user,
3214
- $event: input.validatorContext?.event,
3215
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3216
- user: input.systemVariables?.user,
3217
- $window: input.systemVariables?.$window,
3218
- locations: input.locations,
3219
- adminLevelIds: input.adminLevelIds
3220
- };
3221
- }
3222
- function runClientFunction(code, data, context) {
3223
- return compileClientFunction(code)(data, context);
3224
- }
3225
- ajv.addKeyword({
3226
- keyword: "daysFromDate",
3227
- type: "string",
3228
- schemaType: "object",
3229
- $data: true,
3230
- errors: true,
3231
- validate(schema, data, _2, dataContext) {
3232
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3233
- throw new Error("Validation context must contain $now");
3234
- }
3235
- const { days, clause } = schema;
3236
- if (typeof data !== "string") {
3237
- return false;
3238
- }
3239
- const date = new Date(data);
3240
- if (isNaN(date.getTime())) {
3241
- return false;
3242
- }
3243
- let referenceDate = schema.referenceDate;
3244
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3245
- referenceDate = resolveDataPath(
3246
- dataContext.rootData,
3247
- referenceDate.$data,
3248
- dataContext.instancePath
3249
- );
3250
- }
3251
- if (!referenceDate) {
3252
- referenceDate = dataContext.rootData.$now;
3253
- }
3254
- const baseDate = new Date(referenceDate);
3255
- if (isNaN(baseDate.getTime())) {
3256
- return false;
3257
- }
3258
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3259
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3260
- }
3261
- });
3262
- ajv.addKeyword({
3263
- keyword: "isLeafLevelLocation",
3264
- type: "string",
3265
- schemaType: "boolean",
3266
- $data: true,
3267
- errors: true,
3268
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3269
- validate(_schema, data, _2, dataContext) {
3270
- const locationIdInput = data;
3271
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3272
- return locations.some((location) => location.id === locationIdInput);
3273
- }
3274
- });
3275
- ajv.addKeyword({
3276
- keyword: "customClientValidator",
3277
- schemaType: "object",
3278
- errors: true,
3279
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3280
- // `validate()` callers build root data via `buildClientFunctionContext`,
3281
- // so the cast holds.
3282
- validate(schema, data, _2, dataContext) {
3283
- return Boolean(
3284
- runClientFunction(
3285
- schema.code,
3286
- data,
3287
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3288
- )
3289
- );
3290
- }
3291
- });
3292
- function isOnline() {
3293
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3294
- return navigator.onLine;
3295
- }
3296
- return true;
3297
- }
3424
+ });
3425
+ var AdvancedSearchConfig = z30.object({
3426
+ title: TranslationConfig.describe("Advanced search tab title"),
3427
+ fields: z30.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3428
+ }).meta({
3429
+ id: "AdvancedSearchConfig",
3430
+ 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()`)."
3431
+ });
3298
3432
 
3299
- // ../commons/src/utils.ts
3433
+ // ../commons/src/events/utils.ts
3434
+ var import_lodash4 = require("lodash");
3435
+
3436
+ // ../commons/src/conditionals/validate.ts
3437
+ var import__ = __toESM(require("ajv/dist/2019"));
3438
+ var import_ajv_formats = __toESM(require("ajv-formats"));
3439
+ var z34 = __toESM(require("zod/v4"));
3440
+ var import_date_fns2 = require("date-fns");
3441
+
3442
+ // ../commons/src/events/FieldTypeMapping.ts
3300
3443
  var z32 = __toESM(require("zod/v4"));
3444
+
3445
+ // ../commons/src/events/DynamicFieldValue.ts
3446
+ var z31 = __toESM(require("zod/v4"));
3447
+
3448
+ // ../commons/src/events/state/index.ts
3449
+ var import_lodash3 = require("lodash");
3450
+
3451
+ // ../commons/src/utils.ts
3452
+ var z33 = __toESM(require("zod/v4"));
3301
3453
  var _ = __toESM(require("lodash"));
3302
- var FullNameV1 = z32.array(
3303
- z32.object({
3304
- use: z32.string(),
3305
- family: z32.string(),
3306
- given: z32.array(z32.string())
3454
+ var FullNameV1 = z33.array(
3455
+ z33.object({
3456
+ use: z33.string(),
3457
+ family: z33.string(),
3458
+ given: z33.array(z33.string())
3307
3459
  })
3308
3460
  );
3309
3461
  function omitKeyDeep(obj, keyToRemove) {
@@ -3322,35 +3474,62 @@ function omitKeyDeep(obj, keyToRemove) {
3322
3474
  return newObj;
3323
3475
  }
3324
3476
 
3325
- // ../commons/src/events/utils.ts
3326
- var import_date_fns2 = require("date-fns");
3327
- function getDeclarationFields(configuration) {
3328
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3329
- }
3330
- var getActionAnnotationFields = (actionConfig) => {
3331
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3332
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3333
- }
3334
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3335
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3336
- }
3337
- const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3338
- const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3339
- return [...reviewFields, ...formFields];
3340
- };
3341
- function getAllAnnotationFields(config) {
3342
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3343
- }
3344
- var findAllFields = (config) => {
3345
- return (0, import_lodash.flattenDeep)([
3346
- ...getDeclarationFields(config),
3347
- ...getAllAnnotationFields(config)
3348
- ]);
3349
- };
3350
- var EXCLUDED_ACTIONS = [
3351
- ActionType.REQUEST_CORRECTION,
3477
+ // ../commons/src/events/state/utils.ts
3478
+ var import_lodash = require("lodash");
3479
+ var updateActions = ActionTypes.extract([
3480
+ ActionType.CREATE,
3481
+ ActionType.NOTIFY,
3482
+ ActionType.EDIT,
3483
+ ActionType.DECLARE,
3484
+ ActionType.REGISTER,
3485
+ ActionType.REJECT,
3486
+ ActionType.ARCHIVE,
3487
+ ActionType.UNARCHIVE,
3352
3488
  ActionType.PRINT_CERTIFICATE,
3353
- ActionType.REJECT_CORRECTION
3489
+ ActionType.REQUEST_CORRECTION,
3490
+ ActionType.APPROVE_CORRECTION,
3491
+ ActionType.REJECT_CORRECTION,
3492
+ ActionType.CUSTOM
3493
+ ]);
3494
+
3495
+ // ../commons/src/events/state/flags.ts
3496
+ var import_lodash2 = require("lodash");
3497
+ var import_date_fns = require("date-fns");
3498
+ var INHERENT_FLAG_RULES = [
3499
+ {
3500
+ flag: InherentFlags.CORRECTION_REQUESTED,
3501
+ setOn: [ActionType.REQUEST_CORRECTION],
3502
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3503
+ },
3504
+ {
3505
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3506
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3507
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3508
+ // round trip and comes back exactly as it was.
3509
+ flag: InherentFlags.INCOMPLETE,
3510
+ setOn: [ActionType.NOTIFY],
3511
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3512
+ },
3513
+ {
3514
+ flag: InherentFlags.REJECTED,
3515
+ setOn: [ActionType.REJECT],
3516
+ resetOn: [
3517
+ ActionType.NOTIFY,
3518
+ ActionType.DECLARE,
3519
+ ActionType.EDIT,
3520
+ ActionType.REGISTER
3521
+ ]
3522
+ },
3523
+ {
3524
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3525
+ setOn: [ActionType.DUPLICATE_DETECTED],
3526
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3527
+ },
3528
+ {
3529
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3530
+ setOn: [ActionType.EDIT],
3531
+ resetOnAnyOtherAction: true
3532
+ }
3354
3533
  ];
3355
3534
 
3356
3535
  // ../commons/src/conditionals/conditionals.ts
@@ -3559,6 +3738,33 @@ function defineComparison(field3, value, keyword) {
3559
3738
  required: [field3.$$field]
3560
3739
  });
3561
3740
  }
3741
+ function flag(flagvalue) {
3742
+ return defineConditional({
3743
+ type: "object",
3744
+ properties: {
3745
+ $flags: {
3746
+ type: "array",
3747
+ contains: {
3748
+ type: "string",
3749
+ const: flagvalue
3750
+ }
3751
+ }
3752
+ },
3753
+ required: ["$flags"]
3754
+ });
3755
+ }
3756
+ function status(statusValue) {
3757
+ return defineConditional({
3758
+ type: "object",
3759
+ properties: {
3760
+ $status: {
3761
+ type: "string",
3762
+ const: statusValue
3763
+ }
3764
+ },
3765
+ required: ["$status"]
3766
+ });
3767
+ }
3562
3768
  function createFieldConditionals(fieldId) {
3563
3769
  const getDayRange = (field3, days, clause, referenceDate) => ({
3564
3770
  type: "object",
@@ -3960,6 +4166,176 @@ function createFieldConditionals(fieldId) {
3960
4166
  };
3961
4167
  }
3962
4168
 
4169
+ // ../commons/src/conditionals/validate.ts
4170
+ var ajv = new import__.default({
4171
+ $data: true,
4172
+ allowUnionTypes: true,
4173
+ strict: false
4174
+ // Allow minContains and other newer features
4175
+ });
4176
+ var DataContext = z34.object({
4177
+ rootData: z34.object({
4178
+ $leafAdminStructureLocationIds: z34.array(z34.object({ id: UUID }))
4179
+ })
4180
+ });
4181
+ function resolveDataPath(rootData, dataPath, instancePath) {
4182
+ const pathParts = dataPath.split("/");
4183
+ const levels = parseInt(pathParts[0], 10);
4184
+ const referencePath = pathParts.slice(1);
4185
+ const instanceParts = instancePath.split("/").filter(Boolean);
4186
+ const traversedParts = instanceParts.slice(0, -levels);
4187
+ let current = rootData;
4188
+ for (const part of traversedParts) {
4189
+ if (current === null || current === void 0) {
4190
+ return void 0;
4191
+ }
4192
+ current = current[part];
4193
+ }
4194
+ for (const part of referencePath) {
4195
+ if (current === null || current === void 0) {
4196
+ return void 0;
4197
+ }
4198
+ current = current[part];
4199
+ }
4200
+ return current;
4201
+ }
4202
+ function todayISO() {
4203
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4204
+ }
4205
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4206
+ function compileClientFunction(code) {
4207
+ let fn = compiledFunctionCache.get(code);
4208
+ if (!fn) {
4209
+ fn = new Function(`return (${code})`)();
4210
+ compiledFunctionCache.set(code, fn);
4211
+ }
4212
+ return fn;
4213
+ }
4214
+ (0, import_ajv_formats.default)(ajv);
4215
+ function buildClientFunctionContext(input) {
4216
+ return {
4217
+ $form: input.form,
4218
+ $flags: input.validatorContext?.event?.state.flags ?? [],
4219
+ $now: todayISO(),
4220
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4221
+ $online: isOnline(),
4222
+ $user: input.validatorContext?.user,
4223
+ $event: input.validatorContext?.event?.document,
4224
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4225
+ user: input.systemVariables?.user,
4226
+ $window: input.systemVariables?.$window,
4227
+ locations: input.locations,
4228
+ adminLevelIds: input.adminLevelIds
4229
+ };
4230
+ }
4231
+ function runClientFunction(code, data, context) {
4232
+ return compileClientFunction(code)(data, context);
4233
+ }
4234
+ ajv.addKeyword({
4235
+ keyword: "daysFromDate",
4236
+ type: "string",
4237
+ schemaType: "object",
4238
+ $data: true,
4239
+ errors: true,
4240
+ validate(schema, data, _2, dataContext) {
4241
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4242
+ throw new Error("Validation context must contain $now");
4243
+ }
4244
+ const { days, clause } = schema;
4245
+ if (typeof data !== "string") {
4246
+ return false;
4247
+ }
4248
+ const date = new Date(data);
4249
+ if (isNaN(date.getTime())) {
4250
+ return false;
4251
+ }
4252
+ let referenceDate = schema.referenceDate;
4253
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4254
+ referenceDate = resolveDataPath(
4255
+ dataContext.rootData,
4256
+ referenceDate.$data,
4257
+ dataContext.instancePath
4258
+ );
4259
+ }
4260
+ if (!referenceDate) {
4261
+ referenceDate = dataContext.rootData.$now;
4262
+ }
4263
+ const baseDate = new Date(referenceDate);
4264
+ if (isNaN(baseDate.getTime())) {
4265
+ return false;
4266
+ }
4267
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4268
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4269
+ }
4270
+ });
4271
+ ajv.addKeyword({
4272
+ keyword: "isLeafLevelLocation",
4273
+ type: "string",
4274
+ schemaType: "boolean",
4275
+ $data: true,
4276
+ errors: true,
4277
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4278
+ validate(_schema, data, _2, dataContext) {
4279
+ const locationIdInput = data;
4280
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4281
+ return locations.some((location) => location.id === locationIdInput);
4282
+ }
4283
+ });
4284
+ ajv.addKeyword({
4285
+ keyword: "customClientValidator",
4286
+ schemaType: "object",
4287
+ errors: true,
4288
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4289
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4290
+ // so the cast holds.
4291
+ validate(schema, data, _2, dataContext) {
4292
+ return Boolean(
4293
+ runClientFunction(
4294
+ schema.code,
4295
+ data,
4296
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4297
+ )
4298
+ );
4299
+ }
4300
+ });
4301
+ function isOnline() {
4302
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4303
+ return navigator.onLine;
4304
+ }
4305
+ return true;
4306
+ }
4307
+
4308
+ // ../commons/src/events/utils.ts
4309
+ var import_date_fns3 = require("date-fns");
4310
+ function getDeclarationFields(configuration) {
4311
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4312
+ }
4313
+ var getActionAnnotationFields = (actionConfig) => {
4314
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4315
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4316
+ }
4317
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4318
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4319
+ }
4320
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4321
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4322
+ return [...reviewFields, ...formFields];
4323
+ };
4324
+ function getAllAnnotationFields(config) {
4325
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4326
+ }
4327
+ var findAllFields = (config) => {
4328
+ return (0, import_lodash4.flattenDeep)([
4329
+ ...getDeclarationFields(config),
4330
+ ...getAllAnnotationFields(config)
4331
+ ]);
4332
+ };
4333
+ var EXCLUDED_ACTIONS = [
4334
+ ActionType.REQUEST_CORRECTION,
4335
+ ActionType.PRINT_CERTIFICATE,
4336
+ ActionType.REJECT_CORRECTION
4337
+ ];
4338
+
3963
4339
  // ../commons/src/events/eventConfigValidation.ts
3964
4340
  function validateAdvancedSearchConfig(event2, ctx) {
3965
4341
  const allFields = findAllFields(event2);
@@ -4042,9 +4418,9 @@ function validatePlaceOfEvent(event2, ctx) {
4042
4418
  }
4043
4419
  function validateActionFlags(event2, ctx) {
4044
4420
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4045
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4421
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4046
4422
  const actionFlagIds = event2.actions.flatMap(
4047
- (action) => (action.flags ?? []).map((flag) => flag.id)
4423
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4048
4424
  );
4049
4425
  for (const actionFlagId of actionFlagIds) {
4050
4426
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4080,11 +4456,11 @@ function validateActionOrder(event2, ctx) {
4080
4456
  }
4081
4457
 
4082
4458
  // ../commons/src/events/EventConfig.ts
4083
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4459
+ var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4084
4460
  "Reference to a field defined in the event metadata, using the field id."
4085
4461
  );
4086
- var _EventConfigBase = z33.object({
4087
- id: z33.string().describe(
4462
+ var _EventConfigBase = z35.object({
4463
+ id: z35.string().describe(
4088
4464
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4089
4465
  ),
4090
4466
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4103,23 +4479,26 @@ var _EventConfigBase = z33.object({
4103
4479
  "Summary information displayed in the event overview."
4104
4480
  ),
4105
4481
  label: TranslationConfig.describe("Human-readable label for the event type."),
4106
- actions: z33.array(ActionConfig).describe(
4482
+ actions: z35.array(ActionConfig).describe(
4107
4483
  "Configuration of core and custom actions associated with the event."
4108
4484
  ),
4109
- actionOrder: z33.array(z33.string()).optional().describe(
4485
+ actionOrder: z35.array(z35.string()).optional().describe(
4110
4486
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4111
4487
  ),
4112
4488
  declaration: DeclarationFormConfig.describe(
4113
4489
  "Configuration of the form used to gather event data."
4114
4490
  ),
4115
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4491
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
4116
4492
  "Configuration of fields available in the advanced search feature."
4117
4493
  ),
4118
- flags: z33.array(FlagConfig).optional().default([]).describe(
4494
+ flags: z35.array(FlagConfig).optional().default([]).describe(
4119
4495
  "Configuration of custom flags associated with the actions of this event type."
4120
4496
  ),
4121
- analytics: z33.boolean().optional().default(true).describe(
4497
+ analytics: z35.boolean().optional().default(true).describe(
4122
4498
  "Indicates whether the records of this event type are included in analytics"
4499
+ ),
4500
+ icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
4501
+ 'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
4123
4502
  )
4124
4503
  });
4125
4504
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4139,7 +4518,7 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
4139
4518
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
4140
4519
 
4141
4520
  // ../commons/src/events/WorkqueueConfig.ts
4142
- var z37 = __toESM(require("zod/v4"));
4521
+ var z38 = __toESM(require("zod/v4"));
4143
4522
 
4144
4523
  // ../commons/src/searchConfigs.ts
4145
4524
  function createSearchConfig(baseField) {
@@ -4336,21 +4715,31 @@ var event = Object.assign(eventFn, {
4336
4715
  return {
4337
4716
  $event: field3
4338
4717
  };
4339
- }
4718
+ },
4719
+ /**
4720
+ * Checks if the event currently has the given status.
4721
+ * @param eventStatus - The status to check for.
4722
+ */
4723
+ hasStatus: (eventStatus) => status(eventStatus),
4724
+ /**
4725
+ * Checks if the event currently carries the given flag.
4726
+ * @param flagValue - The flag to check for.
4727
+ */
4728
+ hasFlag: (flagValue) => flag(flagValue)
4340
4729
  });
4341
4730
 
4342
4731
  // ../commons/src/events/WorkqueueColumnConfig.ts
4343
- var z34 = __toESM(require("zod/v4"));
4732
+ var z36 = __toESM(require("zod/v4"));
4344
4733
  var WorkqueueColumnKeysArray = [
4345
4734
  ...EventMetadataKeysArray,
4346
4735
  "title",
4347
4736
  "outbox"
4348
4737
  ];
4349
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4350
- var WorkqueueColumnValue = z34.object({
4738
+ var WorkqueueColumnKeys = z36.enum(WorkqueueColumnKeysArray);
4739
+ var WorkqueueColumnValue = z36.object({
4351
4740
  $event: WorkqueueColumnKeys
4352
4741
  });
4353
- var WorkqueueColumn = z34.object({
4742
+ var WorkqueueColumn = z36.object({
4354
4743
  label: TranslationConfig,
4355
4744
  value: WorkqueueColumnValue
4356
4745
  }).meta({
@@ -4364,164 +4753,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4364
4753
  }
4365
4754
 
4366
4755
  // ../commons/src/events/CountryConfigQueryInput.ts
4367
- var z35 = __toESM(require("zod/v4"));
4368
- var SerializableExact = z35.object({
4369
- type: z35.literal("exact"),
4370
- term: z35.union([z35.string(), SerializedUserField])
4371
- });
4372
- var SerializableWithin = z35.object({
4373
- type: z35.literal("within"),
4374
- location: z35.union([z35.string(), SerializedUserField])
4375
- });
4376
- var SerializedQueryExpression = z35.object({
4377
- eventType: z35.string(),
4378
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4379
- createdAt: z35.optional(DateCondition),
4380
- updatedAt: z35.optional(DateCondition),
4381
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4382
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4383
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4384
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4385
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4386
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4387
- createdAtLocation: z35.optional(
4388
- z35.union([SerializableWithin, SerializableExact])
4756
+ var z37 = __toESM(require("zod/v4"));
4757
+ var SerializableExact = z37.object({
4758
+ type: z37.literal("exact"),
4759
+ term: z37.union([z37.string(), SerializedUserField])
4760
+ });
4761
+ var SerializableWithin = z37.object({
4762
+ type: z37.literal("within"),
4763
+ location: z37.union([z37.string(), SerializedUserField])
4764
+ });
4765
+ var SerializedQueryExpression = z37.object({
4766
+ eventType: z37.string(),
4767
+ status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
4768
+ createdAt: z37.optional(DateCondition),
4769
+ updatedAt: z37.optional(DateCondition),
4770
+ "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
4771
+ "legalStatuses.DECLARED.createdByRole": z37.optional(AnyOf),
4772
+ "legalStatuses.REGISTERED.createdAt": z37.optional(DateCondition),
4773
+ "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
4774
+ "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
4775
+ "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
4776
+ createdAtLocation: z37.optional(
4777
+ z37.union([SerializableWithin, SerializableExact])
4389
4778
  ),
4390
- updatedAtLocation: z35.optional(
4391
- z35.union([SerializableWithin, SerializableExact])
4779
+ updatedAtLocation: z37.optional(
4780
+ z37.union([SerializableWithin, SerializableExact])
4392
4781
  ),
4393
- updatedByUserRole: z35.optional(SerializableExact),
4394
- assignedTo: z35.optional(SerializableExact),
4395
- createdBy: z35.optional(SerializableExact),
4782
+ updatedByUserRole: z37.optional(SerializableExact),
4783
+ assignedTo: z37.optional(SerializableExact),
4784
+ createdBy: z37.optional(SerializableExact),
4396
4785
  createdByUserType: ExactUserType,
4397
- updatedBy: z35.optional(SerializableExact),
4398
- trackingId: z35.optional(Exact),
4399
- flags: z35.optional(ContainsFlags),
4786
+ updatedBy: z37.optional(SerializableExact),
4787
+ trackingId: z37.optional(Exact),
4788
+ flags: z37.optional(ContainsFlags),
4400
4789
  data: QueryInput
4401
4790
  }).partial();
4402
- var Or2 = z35.object({
4403
- type: z35.literal("or"),
4404
- clauses: z35.array(SerializedQueryExpression)
4791
+ var Or2 = z37.object({
4792
+ type: z37.literal("or"),
4793
+ clauses: z37.array(SerializedQueryExpression)
4405
4794
  });
4406
- var And2 = z35.object({
4407
- type: z35.literal("and"),
4408
- clauses: z35.array(SerializedQueryExpression)
4795
+ var And2 = z37.object({
4796
+ type: z37.literal("and"),
4797
+ clauses: z37.array(SerializedQueryExpression)
4409
4798
  });
4410
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4411
- var CountryConfigQueryInputType = z35.union([
4799
+ var CountryConfigQueryType = z37.discriminatedUnion("type", [And2, Or2]);
4800
+ var CountryConfigQueryInputType = z37.union([
4412
4801
  SerializedQueryExpression,
4413
4802
  And2,
4414
4803
  Or2
4415
4804
  ]);
4416
4805
 
4417
- // ../commons/src/icons.ts
4418
- var z36 = __toESM(require("zod/v4"));
4419
- var AvailableIcons = z36.enum([
4420
- "Archived",
4421
- "Assigned",
4422
- "Briefcase",
4423
- "Certified",
4424
- "Close",
4425
- "Collapse",
4426
- "Draft",
4427
- "DuplicateYellow",
4428
- "Expand",
4429
- "ExternalValidate",
4430
- "FilledCheck",
4431
- "InReview",
4432
- "Offline",
4433
- "Registered",
4434
- "RequiresUpdates",
4435
- "Sent",
4436
- "Validated",
4437
- "WaitingApproval",
4438
- "ChartActivity",
4439
- "Activity",
4440
- "Archive",
4441
- "ArchiveTray",
4442
- "ArrowLeft",
4443
- "ArrowRight",
4444
- "Buildings",
4445
- "Circle",
4446
- "CaretDown",
4447
- "CaretLeft",
4448
- "CaretRight",
4449
- "ChartBar",
4450
- "ChartLine",
4451
- "ChatCircle",
4452
- "CheckSquare",
4453
- "Compass",
4454
- "Check",
4455
- "Copy",
4456
- "Database",
4457
- "DotsThreeVertical",
4458
- "ArrowCounterClockwise",
4459
- "MagnifyingGlassMinus",
4460
- "MagnifyingGlassPlus",
4461
- "Export",
4462
- "Eye",
4463
- "EyeSlash",
4464
- "Envelope",
4465
- "File",
4466
- "FileSearch",
4467
- "FileMinus",
4468
- "FilePlus",
4469
- "FileText",
4470
- "FileX",
4471
- "Handshake",
4472
- "Gear",
4473
- "GitBranch",
4474
- "IdentificationCard",
4475
- "List",
4476
- "ListBullets",
4477
- "Lock",
4478
- "MagnifyingGlass",
4479
- "MapPin",
4480
- "Medal",
4481
- "NotePencil",
4482
- "Paperclip",
4483
- "PaperPlaneTilt",
4484
- "Pen",
4485
- "PenNib",
4486
- "Pencil",
4487
- "PencilSimpleLine",
4488
- "Phone",
4489
- "Plus",
4490
- "Printer",
4491
- "SignOut",
4492
- "Stamp",
4493
- "Star",
4494
- "Target",
4495
- "TextT",
4496
- "Trash",
4497
- "UploadSimple",
4498
- "User",
4499
- "UserPlus",
4500
- "Users",
4501
- "WarningCircle",
4502
- "X",
4503
- "ChatText",
4504
- "CircleWavyCheck",
4505
- "CircleWavyQuestion",
4506
- "ArchiveBox",
4507
- "ArrowCircleDown",
4508
- "FileArrowUp",
4509
- "FileDotted",
4510
- "Files",
4511
- "PencilLine",
4512
- "PencilCircle",
4513
- "UserCircle",
4514
- "Clock",
4515
- "QrCode",
4516
- "Webcam",
4517
- "Sun",
4518
- "DeviceTabletCamera",
4519
- "Globe",
4520
- "Fingerprint",
4521
- "PushPin",
4522
- "Timer"
4523
- ]);
4524
-
4525
4806
  // ../commons/src/events/WorkqueueConfig.ts
4526
4807
  var mandatoryColumns = defineWorkqueuesColumns([
4527
4808
  {
@@ -4541,16 +4822,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
4541
4822
  value: event.field("updatedAt")
4542
4823
  }
4543
4824
  ]);
4544
- var WorkqueueConfig = z37.object({
4545
- slug: z37.string().describe("Determines the url of the workqueue."),
4825
+ var WorkqueueConfig = z38.object({
4826
+ slug: z38.string().describe("Determines the url of the workqueue."),
4546
4827
  name: TranslationConfig.describe(
4547
4828
  "Title of the workflow (both in navigation and on the page)"
4548
4829
  ),
4549
4830
  query: CountryConfigQueryType,
4550
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4831
+ action: z38.object({ type: WorkqueueActionType }).optional().describe(
4551
4832
  "Workqueue call-to-action button configuration. This determines the quick action button shown on each event card and the action taken when the button is clicked."
4552
4833
  ),
4553
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4834
+ columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
4554
4835
  icon: AvailableIcons,
4555
4836
  emptyMessage: TranslationConfig.optional()
4556
4837
  }).describe("Configuration for workqueue.");
@@ -4564,10 +4845,10 @@ var WorkqueueConfigInput = WorkqueueConfig.extend({
4564
4845
  id: "WorkqueueConfig",
4565
4846
  description: "Configuration for a single workqueue. Defines the filter applied to the event index, the quick-action button, the columns shown on each row, and the message rendered when the queue is empty."
4566
4847
  });
4567
- var WorkqueueCountInput = z37.array(
4568
- z37.object({ slug: z37.string(), query: QueryType })
4848
+ var WorkqueueCountInput = z38.array(
4849
+ z38.object({ slug: z38.string(), query: QueryType })
4569
4850
  );
4570
- var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
4851
+ var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
4571
4852
 
4572
4853
  // ../commons/src/events/workqueueDefaultColumns.ts
4573
4854
  var defaultWorkqueueColumns = [
@@ -4590,21 +4871,21 @@ var defaultWorkqueueColumns = [
4590
4871
  ];
4591
4872
 
4592
4873
  // ../commons/src/events/Draft.ts
4593
- var z39 = __toESM(require("zod/v4"));
4874
+ var z40 = __toESM(require("zod/v4"));
4594
4875
 
4595
4876
  // ../commons/src/events/ActionInput.ts
4596
- var z38 = __toESM(require("zod/v4"));
4597
- var BaseActionInput = z38.object({
4877
+ var z39 = __toESM(require("zod/v4"));
4878
+ var BaseActionInput = z39.object({
4598
4879
  eventId: UUID,
4599
- transactionId: z38.string(),
4880
+ transactionId: z39.string(),
4600
4881
  declaration: ActionUpdate.default({}),
4601
4882
  annotation: ActionUpdate.optional(),
4602
4883
  originalActionId: UUID.optional(),
4603
4884
  // should not be part of base action.
4604
- keepAssignment: z38.boolean().optional(),
4605
- keepAssignmentIfAccepted: z38.boolean().optional(),
4606
- keepAssignmentIfRejected: z38.boolean().optional(),
4607
- waitFor: z38.boolean().default(true).describe(
4885
+ keepAssignment: z39.boolean().optional(),
4886
+ keepAssignmentIfAccepted: z39.boolean().optional(),
4887
+ keepAssignmentIfRejected: z39.boolean().optional(),
4888
+ waitFor: z39.boolean().default(true).describe(
4608
4889
  "Whether action waits for the indexing before returning. Defaults to true. Setting this to to false completes faster but might lead to stale data in the client if the client tries to read the event immediately after performing the action. Use with care."
4609
4890
  ),
4610
4891
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
@@ -4614,8 +4895,8 @@ var BaseActionInput = z38.object({
4614
4895
  )
4615
4896
  });
4616
4897
  var CreateActionInput = BaseActionInput.extend(
4617
- z38.object({
4618
- type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
4898
+ z39.object({
4899
+ type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
4619
4900
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4620
4901
  createdAtLocation: UUID.nullish().describe(
4621
4902
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -4623,14 +4904,14 @@ var CreateActionInput = BaseActionInput.extend(
4623
4904
  }).shape
4624
4905
  );
4625
4906
  var RegisterActionInput = BaseActionInput.extend(
4626
- z38.strictObject({
4627
- type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4628
- registrationNumber: z38.string().optional()
4907
+ z39.strictObject({
4908
+ type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4909
+ registrationNumber: z39.string().optional()
4629
4910
  }).shape
4630
4911
  );
4631
4912
  var NotifyActionInput = BaseActionInput.extend(
4632
- z38.object({
4633
- type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4913
+ z39.object({
4914
+ type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4634
4915
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4635
4916
  createdAtLocation: UUID.nullish().describe(
4636
4917
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -4646,106 +4927,107 @@ var NotifyActionInput = BaseActionInput.extend(
4646
4927
  }
4647
4928
  });
4648
4929
  var DeclareActionInput = BaseActionInput.extend(
4649
- z38.object({
4650
- type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4930
+ z39.object({
4931
+ type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4651
4932
  }).shape
4652
4933
  );
4653
4934
  var EditActionInput = BaseActionInput.extend(
4654
- z38.object({
4655
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4656
- content: z38.object({
4657
- comment: z38.string().describe("Comment for the edit action.").optional()
4658
- })
4935
+ z39.object({
4936
+ type: z39.literal(ActionType.EDIT).default(ActionType.EDIT)
4659
4937
  }).shape
4660
4938
  );
4661
4939
  var PrintCertificateActionInput = BaseActionInput.extend(
4662
- z38.object({
4663
- type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4940
+ z39.object({
4941
+ type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4664
4942
  content: PrintContent.optional()
4665
4943
  }).shape
4666
4944
  );
4667
4945
  var RejectDeclarationActionInput = BaseActionInput.extend(
4668
- z38.object({
4669
- type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
4946
+ z39.object({
4947
+ type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
4670
4948
  content: ReasonContent
4671
4949
  }).shape
4672
4950
  );
4673
4951
  var DuplicateDetectedActionInput = BaseActionInput.extend(
4674
- z38.object({
4675
- type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4676
- content: z38.object({
4677
- duplicates: z38.array(PotentialDuplicate)
4952
+ z39.object({
4953
+ type: z39.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4954
+ content: z39.object({
4955
+ duplicates: z39.array(PotentialDuplicate)
4678
4956
  })
4679
4957
  }).shape
4680
4958
  );
4681
4959
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
4682
- z38.object({
4683
- type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4684
- content: z38.object({
4960
+ z39.object({
4961
+ type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4962
+ content: z39.object({
4685
4963
  duplicateOf: UUID
4686
4964
  }).optional()
4687
4965
  }).shape
4688
4966
  );
4689
4967
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
4690
- z38.object({
4691
- type: z38.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4968
+ z39.object({
4969
+ type: z39.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4692
4970
  }).shape
4693
4971
  );
4694
4972
  var ArchiveActionInput = BaseActionInput.extend(
4695
- z38.object({
4696
- type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4697
- content: ReasonContent
4973
+ z39.object({
4974
+ type: z39.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4975
+ /**
4976
+ * Archiving does not collect a reason on its own. Only the
4977
+ * "mark as duplicate" flow archives with a reason attached.
4978
+ */
4979
+ content: ReasonContent.optional()
4698
4980
  }).shape
4699
4981
  );
4700
4982
  var UnarchiveActionInput = BaseActionInput.extend(
4701
- z38.object({
4702
- type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4983
+ z39.object({
4984
+ type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4703
4985
  }).shape
4704
4986
  );
4705
4987
  var AssignActionInput = BaseActionInput.extend(
4706
- z38.object({
4707
- type: z38.literal(ActionType.ASSIGN),
4708
- assignedTo: z38.string()
4988
+ z39.object({
4989
+ type: z39.literal(ActionType.ASSIGN),
4990
+ assignedTo: z39.string()
4709
4991
  }).shape
4710
4992
  );
4711
4993
  var UnassignActionInput = BaseActionInput.extend(
4712
- z38.object({
4713
- type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4714
- assignedTo: z38.literal(null).default(null)
4994
+ z39.object({
4995
+ type: z39.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4996
+ assignedTo: z39.literal(null).default(null)
4715
4997
  }).shape
4716
4998
  );
4717
4999
  var RequestCorrectionActionInput = BaseActionInput.extend(
4718
- z38.object({
4719
- type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
5000
+ z39.object({
5001
+ type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4720
5002
  }).shape
4721
5003
  );
4722
5004
  var RejectCorrectionActionInput = BaseActionInput.extend(
4723
- z38.object({
4724
- requestId: z38.string(),
4725
- type: z38.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
5005
+ z39.object({
5006
+ requestId: z39.string(),
5007
+ type: z39.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4726
5008
  content: ReasonContent
4727
5009
  }).shape
4728
5010
  );
4729
5011
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4730
- z38.object({
4731
- requestId: z38.string(),
4732
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4733
- content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
5012
+ z39.object({
5013
+ requestId: z39.string(),
5014
+ type: z39.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5015
+ content: z39.object({ immediateCorrection: z39.boolean().optional() }).optional()
4734
5016
  }).shape
4735
5017
  );
4736
5018
  var ReadActionInput = BaseActionInput.extend(
4737
- z38.object({
4738
- type: z38.literal(ActionType.READ).default(ActionType.READ)
5019
+ z39.object({
5020
+ type: z39.literal(ActionType.READ).default(ActionType.READ)
4739
5021
  }).shape
4740
5022
  );
4741
- var DeleteActionInput = z38.object({ eventId: UUID });
5023
+ var DeleteActionInput = z39.object({ eventId: UUID });
4742
5024
  var CustomActionInput = BaseActionInput.extend(
4743
- z38.object({
4744
- type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
4745
- customActionType: z38.string().describe("Name of the custom action.")
5025
+ z39.object({
5026
+ type: z39.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5027
+ customActionType: z39.string().describe("Name of the custom action.")
4746
5028
  }).shape
4747
5029
  );
4748
- var ActionInput = z38.discriminatedUnion("type", [
5030
+ var ActionInput = z39.discriminatedUnion("type", [
4749
5031
  CreateActionInput.meta({ id: "CreateActionInput" }),
4750
5032
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
4751
5033
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -4782,11 +5064,11 @@ var ActionInput = z38.discriminatedUnion("type", [
4782
5064
  });
4783
5065
 
4784
5066
  // ../commons/src/events/Draft.ts
4785
- var Draft = z39.object({
5067
+ var Draft = z40.object({
4786
5068
  id: UUID,
4787
5069
  eventId: UUID,
4788
- transactionId: z39.string(),
4789
- createdAt: z39.string().datetime(),
5070
+ transactionId: z40.string(),
5071
+ createdAt: z40.string().datetime(),
4790
5072
  action: ActionBase.extend({
4791
5073
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
4792
5074
  }).omit({ id: true, createdAtLocation: true })
@@ -4795,7 +5077,7 @@ var Draft = z39.object({
4795
5077
  );
4796
5078
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4797
5079
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
4798
- status: z39.enum([
5080
+ status: z40.enum([
4799
5081
  ActionStatus.Requested,
4800
5082
  ActionStatus.Accepted,
4801
5083
  ActionStatus.Rejected
@@ -4803,91 +5085,33 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4803
5085
  });
4804
5086
 
4805
5087
  // ../commons/src/events/EventInput.ts
4806
- var z40 = __toESM(require("zod/v4"));
4807
- var import_uuid10 = require("uuid");
4808
- var EventInput = z40.object({
4809
- transactionId: z40.string(),
4810
- type: z40.string(),
5088
+ var z41 = __toESM(require("zod/v4"));
5089
+ var import_uuid11 = require("uuid");
5090
+ var EventInput = z41.object({
5091
+ transactionId: z41.string(),
5092
+ type: z41.string(),
4811
5093
  createdAtLocation: UUID.nullish().describe(
4812
5094
  "Location where the event occurred. Required for system users."
4813
5095
  )
4814
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5096
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4815
5097
 
4816
5098
  // ../commons/src/events/EventDocument.ts
4817
- var z41 = __toESM(require("zod/v4"));
4818
- var EventDocument = z41.object({
5099
+ var z42 = __toESM(require("zod/v4"));
5100
+ var EventDocument = z42.object({
4819
5101
  id: UUID.describe("Unique identifier of the event."),
4820
- type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
4821
- createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
4822
- updatedAt: z41.string().datetime().describe(
5102
+ type: z42.string().describe("Type of the event (e.g. birth, death, marriage)."),
5103
+ createdAt: z42.string().datetime().describe("Timestamp indicating when the event was created."),
5104
+ updatedAt: z42.string().datetime().describe(
4823
5105
  "Timestamp of the last update, excluding changes from actions."
4824
5106
  ),
4825
- actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
4826
- trackingId: z41.string().describe(
5107
+ actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
5108
+ trackingId: z42.string().describe(
4827
5109
  "System-generated tracking identifier used to look up the event."
4828
5110
  )
4829
5111
  }).meta({ id: "EventDocument" });
4830
-
4831
- // ../commons/src/events/state/index.ts
4832
- var import_lodash4 = require("lodash");
4833
-
4834
- // ../commons/src/events/state/utils.ts
4835
- var import_lodash2 = require("lodash");
4836
- var updateActions = ActionTypes.extract([
4837
- ActionType.CREATE,
4838
- ActionType.NOTIFY,
4839
- ActionType.EDIT,
4840
- ActionType.DECLARE,
4841
- ActionType.REGISTER,
4842
- ActionType.REJECT,
4843
- ActionType.ARCHIVE,
4844
- ActionType.UNARCHIVE,
4845
- ActionType.PRINT_CERTIFICATE,
4846
- ActionType.REQUEST_CORRECTION,
4847
- ActionType.APPROVE_CORRECTION,
4848
- ActionType.REJECT_CORRECTION,
4849
- ActionType.CUSTOM
4850
- ]);
4851
-
4852
- // ../commons/src/events/state/flags.ts
4853
- var import_lodash3 = require("lodash");
4854
- var import_date_fns3 = require("date-fns");
4855
- var INHERENT_FLAG_RULES = [
4856
- {
4857
- flag: InherentFlags.CORRECTION_REQUESTED,
4858
- setOn: [ActionType.REQUEST_CORRECTION],
4859
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4860
- },
4861
- {
4862
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4863
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4864
- // are deliberately excluded so the flag freezes across an archive/unarchive
4865
- // round trip and comes back exactly as it was.
4866
- flag: InherentFlags.INCOMPLETE,
4867
- setOn: [ActionType.NOTIFY],
4868
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4869
- },
4870
- {
4871
- flag: InherentFlags.REJECTED,
4872
- setOn: [ActionType.REJECT],
4873
- resetOn: [
4874
- ActionType.NOTIFY,
4875
- ActionType.DECLARE,
4876
- ActionType.EDIT,
4877
- ActionType.REGISTER
4878
- ]
4879
- },
4880
- {
4881
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4882
- setOn: [ActionType.DUPLICATE_DETECTED],
4883
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4884
- },
4885
- {
4886
- flag: InherentFlags.EDIT_IN_PROGRESS,
4887
- setOn: [ActionType.EDIT],
4888
- resetOnAnyOtherAction: true
4889
- }
4890
- ];
5112
+ var EventDocumentOnlyLastAction = EventDocument.extend({
5113
+ actions: z42.array(Action).max(1).describe("Only the last action associated with the event.")
5114
+ }).brand("EventDocumentOnlyLastAction");
4891
5115
 
4892
5116
  // ../commons/src/events/defineConfig.ts
4893
5117
  var IGNORED_EVENT_TYPES = [
@@ -5668,6 +5892,7 @@ var TENNIS_CLUB_DECLARATION_FORM = defineDeclarationForm({
5668
5892
  defaultMessage: "Who is applying for the membership?",
5669
5893
  description: "This is the title of the section"
5670
5894
  },
5895
+ showClearButton: true,
5671
5896
  fields: [
5672
5897
  {
5673
5898
  id: "applicant.name",
@@ -7338,21 +7563,7 @@ var digitalIdentityEvent = defineConfig({
7338
7563
  });
7339
7564
 
7340
7565
  // ../commons/src/events/test.utils.ts
7341
- var z42 = __toESM(require("zod/v4"));
7342
- var TestUserRole = z42.enum([
7343
- "FIELD_AGENT",
7344
- "LOCAL_REGISTRAR",
7345
- "LOCAL_SYSTEM_ADMIN",
7346
- "NATIONAL_REGISTRAR",
7347
- "REGISTRATION_AGENT",
7348
- "NATIONAL_SYSTEM_ADMIN",
7349
- "SOCIAL_WORKER",
7350
- "COMMUNITY_LEADER",
7351
- "PROVINCIAL_REGISTRAR"
7352
- ]);
7353
-
7354
- // ../commons/src/events/scopes.ts
7355
- var import_lodash6 = require("lodash");
7566
+ var z44 = __toESM(require("zod/v4"));
7356
7567
 
7357
7568
  // ../commons/src/events/locations.ts
7358
7569
  var z43 = __toESM(require("zod/v4"));
@@ -7361,188 +7572,165 @@ var LocationTypeV1 = z43.enum([
7361
7572
  "CRVS_OFFICE",
7362
7573
  "HEALTH_FACILITY"
7363
7574
  ]);
7575
+ var LocationStatus = z43.enum(["active", "inactive"]);
7576
+ var LocationVersion = z43.object({
7577
+ versionId: UUID,
7578
+ effectiveFrom: z43.iso.date(),
7579
+ name: z43.string(),
7580
+ externalId: z43.string().nullish(),
7581
+ status: LocationStatus
7582
+ });
7364
7583
  var AdministrativeArea = z43.object({
7365
7584
  id: UUID,
7366
7585
  name: z43.string(),
7367
7586
  externalId: z43.string().nullish(),
7368
- parentId: UUID.nullable(),
7369
- validUntil: z43.iso.datetime().nullable()
7587
+ parentId: UUID.nullable(),
7588
+ status: LocationStatus,
7589
+ versions: z43.array(LocationVersion)
7590
+ });
7591
+ var Location = z43.object({
7592
+ id: UUID,
7593
+ name: z43.string(),
7594
+ externalId: z43.string().nullish(),
7595
+ administrativeAreaId: UUID.nullable(),
7596
+ locationType: z43.string().nullable(),
7597
+ status: LocationStatus,
7598
+ versions: z43.array(LocationVersion)
7599
+ });
7600
+ var ClientAdministrativeArea = AdministrativeArea.omit({
7601
+ name: true,
7602
+ status: true,
7603
+ externalId: true
7604
+ });
7605
+ var ClientLocation = Location.omit({
7606
+ name: true,
7607
+ status: true,
7608
+ externalId: true
7609
+ });
7610
+ function toClientLocation(location) {
7611
+ return {
7612
+ id: location.id,
7613
+ administrativeAreaId: location.administrativeAreaId,
7614
+ locationType: location.locationType,
7615
+ versions: location.versions
7616
+ };
7617
+ }
7618
+ function toClientAdministrativeArea(area) {
7619
+ return {
7620
+ id: area.id,
7621
+ parentId: area.parentId,
7622
+ versions: area.versions
7623
+ };
7624
+ }
7625
+ function validateAscendingDates(versions, ctx) {
7626
+ const ascending = versions.every(
7627
+ (version, index) => index === 0 || versions[index - 1].effectiveFrom < version.effectiveFrom
7628
+ );
7629
+ if (!ascending) {
7630
+ ctx.addIssue("versions must be strictly ascending by effectiveFrom");
7631
+ }
7632
+ }
7633
+ function validateUniqueIds(versions, ctx) {
7634
+ const versionIds = new Set(versions.map((version) => version.versionId));
7635
+ if (versionIds.size !== versions.length) {
7636
+ ctx.addIssue("versions must not repeat a versionId");
7637
+ }
7638
+ }
7639
+ var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7640
+ validateAscendingDates(versions, ctx);
7641
+ validateUniqueIds(versions, ctx);
7642
+ });
7643
+ var SetLocationPayload = z43.object({
7644
+ id: UUID,
7645
+ name: z43.string(),
7646
+ externalId: z43.string().nullish(),
7647
+ administrativeAreaId: UUID.nullable(),
7648
+ locationType: z43.string().nullable(),
7649
+ versions: SeededLocationVersions.optional()
7370
7650
  });
7371
- var Location = z43.object({
7651
+ var SetAdministrativeAreaPayload = z43.object({
7372
7652
  id: UUID,
7373
7653
  name: z43.string(),
7374
7654
  externalId: z43.string().nullish(),
7375
- administrativeAreaId: UUID.nullable(),
7376
- validUntil: z43.iso.datetime().nullable(),
7377
- locationType: z43.string().nullable()
7655
+ parentId: UUID.nullable(),
7656
+ versions: SeededLocationVersions.optional()
7378
7657
  });
7379
7658
 
7380
- // ../commons/src/events/scopes.ts
7381
- var ACTION_SCOPE_MAP = {
7382
- [ActionType.READ]: ["record.read"],
7383
- [ActionType.CREATE]: ["record.create"],
7384
- [ActionType.NOTIFY]: ["record.notify"],
7385
- [ActionType.DECLARE]: ["record.declare", "record.register"],
7386
- [ActionType.EDIT]: ["record.edit"],
7387
- [ActionType.DELETE]: ["record.declare", "record.notify"],
7388
- [ActionType.REGISTER]: ["record.register"],
7389
- [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
7390
- [ActionType.REQUEST_CORRECTION]: [
7391
- "record.request-correction",
7392
- "record.correct"
7393
- ],
7394
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
7395
- [ActionType.REJECT_CORRECTION]: ["record.correct"],
7396
- [ActionType.APPROVE_CORRECTION]: ["record.correct"],
7397
- [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7398
- [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7399
- [ActionType.ARCHIVE]: ["record.archive"],
7400
- [ActionType.UNARCHIVE]: ["record.unarchive"],
7401
- [ActionType.REJECT]: ["record.reject"],
7402
- [ActionType.ASSIGN]: null,
7403
- [ActionType.UNASSIGN]: null,
7404
- [ActionType.DUPLICATE_DETECTED]: [],
7405
- [ActionType.CUSTOM]: []
7406
- };
7407
-
7408
- // ../commons/src/events/state/availableActions.ts
7409
- var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7410
- [EventStatus.enum.CREATED]: [
7411
- ActionType.READ,
7412
- ActionType.DECLARE,
7413
- ActionType.NOTIFY,
7414
- ActionType.DELETE,
7415
- ActionType.CUSTOM
7416
- ],
7417
- [EventStatus.enum.NOTIFIED]: [
7418
- ActionType.READ,
7419
- ActionType.EDIT,
7420
- ActionType.MARK_AS_DUPLICATE,
7421
- ActionType.ARCHIVE,
7422
- ActionType.REJECT,
7423
- ActionType.CUSTOM
7424
- ],
7425
- [EventStatus.enum.DECLARED]: [
7426
- ActionType.READ,
7427
- ActionType.REGISTER,
7428
- ActionType.MARK_AS_DUPLICATE,
7429
- ActionType.ARCHIVE,
7430
- ActionType.REJECT,
7431
- ActionType.CUSTOM,
7432
- ActionType.EDIT
7433
- ],
7434
- [EventStatus.enum.REGISTERED]: [
7435
- ActionType.READ,
7436
- ActionType.PRINT_CERTIFICATE,
7437
- ActionType.REQUEST_CORRECTION,
7438
- ActionType.APPROVE_CORRECTION,
7439
- ActionType.REJECT_CORRECTION,
7440
- ActionType.CUSTOM,
7441
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7442
- ],
7443
- [EventStatus.enum.ARCHIVED]: [
7444
- ActionType.READ,
7445
- ActionType.CUSTOM,
7446
- ActionType.UNARCHIVE
7447
- ]
7448
- };
7449
- var ACTION_FILTERS = {
7450
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7451
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7452
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7453
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7454
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7455
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7456
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7457
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7458
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7459
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7460
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7461
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7462
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7463
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7464
- };
7465
- var REJECTED_ACTIONS = [
7466
- ActionType.READ,
7467
- ActionType.NOTIFY,
7468
- ActionType.CUSTOM,
7469
- ActionType.EDIT,
7470
- ActionType.ARCHIVE
7471
- ];
7472
-
7473
- // ../commons/src/events/FileUtils.ts
7474
- var import_lodash7 = require("lodash");
7475
-
7476
7659
  // ../commons/src/events/mocks.test.utils.ts
7477
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7660
+ function withVersionFields(entity) {
7661
+ return {
7662
+ ...entity,
7663
+ status: "active",
7664
+ versions: [
7665
+ {
7666
+ versionId: entity.id,
7667
+ effectiveFrom: "0001-01-01",
7668
+ name: entity.name,
7669
+ externalId: entity.externalId ?? null,
7670
+ status: "active"
7671
+ }
7672
+ ]
7673
+ };
7674
+ }
7675
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7478
7676
  {
7479
7677
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7480
7678
  name: "Central",
7481
7679
  parentId: null,
7482
- validUntil: null,
7483
7680
  externalId: "ydyJb1RAy4U1"
7484
7681
  },
7485
7682
  {
7486
7683
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7487
7684
  name: "Sulaka",
7488
7685
  parentId: null,
7489
- validUntil: null,
7490
7686
  externalId: "pQ8nGxWmZ2Q3"
7491
7687
  },
7492
7688
  {
7493
7689
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7494
7690
  name: "Pualula",
7495
7691
  parentId: null,
7496
- validUntil: null,
7497
7692
  externalId: "Aq91DweLmT8k"
7498
7693
  },
7499
7694
  {
7500
7695
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7501
7696
  name: "Chuminga",
7502
7697
  parentId: null,
7503
- validUntil: null,
7504
7698
  externalId: "Rw0fYNh2Xk9a"
7505
7699
  },
7506
7700
  {
7507
7701
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7508
7702
  name: "Ibombo",
7509
7703
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7510
- validUntil: null,
7511
7704
  externalId: "k7DsP4vbN1Qe"
7512
7705
  },
7513
7706
  {
7514
7707
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7515
7708
  name: "Isango",
7516
7709
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7517
- validUntil: null,
7518
7710
  externalId: "Gm3Z9eQpHw4L"
7519
7711
  },
7520
7712
  {
7521
7713
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7522
7714
  name: "Isamba",
7523
7715
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7524
- validUntil: null,
7525
7716
  externalId: "sT0xVu1KqJ7r"
7526
7717
  },
7527
7718
  {
7528
7719
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7529
7720
  name: "Itambo",
7530
7721
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7531
- validUntil: null,
7532
7722
  externalId: "Nq6Bv2HpL9Te"
7533
7723
  },
7534
7724
  {
7535
7725
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7536
7726
  name: "Ezhi",
7537
7727
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7538
- validUntil: null,
7539
7728
  externalId: "xK8cQ0ZRy5Wd"
7540
7729
  },
7541
7730
  {
7542
7731
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7543
7732
  name: "Ilanga",
7544
7733
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7545
- validUntil: null,
7546
7734
  externalId: "Cq4Jm1XvN8Ls"
7547
7735
  },
7548
7736
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7550,49 +7738,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7550
7738
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7551
7739
  name: "Klow",
7552
7740
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7553
- validUntil: null,
7554
7741
  externalId: "IkYcYBUcyY2"
7555
7742
  },
7556
7743
  {
7557
7744
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7558
7745
  name: "Mbondo",
7559
7746
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7560
- validUntil: null,
7561
7747
  externalId: "Qhvv5hvo3mY"
7562
7748
  },
7563
7749
  {
7564
7750
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7565
7751
  name: "Ndara",
7566
7752
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7567
- validUntil: null,
7568
7753
  externalId: "crXh068O9TR"
7569
7754
  },
7570
7755
  {
7571
7756
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7572
7757
  name: "Olani",
7573
7758
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7574
- validUntil: null,
7575
7759
  externalId: "r00It8Tvvp7"
7576
7760
  },
7577
7761
  {
7578
7762
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7579
7763
  name: "Pemba",
7580
7764
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7581
- validUntil: null,
7582
7765
  externalId: "ZnUWsbONIaH"
7583
7766
  },
7584
7767
  {
7585
7768
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7586
7769
  name: "Quanza",
7587
7770
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7588
- validUntil: null,
7589
7771
  externalId: "fDZycvQTa7l"
7590
7772
  },
7591
7773
  {
7592
7774
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7593
7775
  name: "Rivka",
7594
7776
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7595
- validUntil: null,
7596
7777
  externalId: "KqswxCGTELa"
7597
7778
  },
7598
7779
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7600,35 +7781,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7600
7781
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7601
7782
  name: "Mbula",
7602
7783
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7603
- validUntil: null,
7604
7784
  externalId: "osEbKjRc9Kg"
7605
7785
  },
7606
7786
  {
7607
7787
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7608
7788
  name: "Ndoki",
7609
7789
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7610
- validUntil: null,
7611
7790
  externalId: "aq4daBUAGr3"
7612
7791
  },
7613
7792
  {
7614
7793
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7615
7794
  name: "Tsanga",
7616
7795
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7617
- validUntil: null,
7618
7796
  externalId: "cqis6Y8trbJ"
7619
7797
  },
7620
7798
  {
7621
7799
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7622
7800
  name: "Waziri",
7623
7801
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7624
- validUntil: null,
7625
7802
  externalId: "LMijHPyyx6d"
7626
7803
  },
7627
7804
  {
7628
7805
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7629
7806
  name: "Zimbi",
7630
7807
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7631
- validUntil: null,
7632
7808
  externalId: "pcQYbPuKGZ7"
7633
7809
  },
7634
7810
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7636,67 +7812,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7636
7812
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7637
7813
  name: "Felani",
7638
7814
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7639
- validUntil: null,
7640
7815
  externalId: "gSqpoCGdMXp"
7641
7816
  },
7642
7817
  {
7643
7818
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7644
7819
  name: "Goroma",
7645
7820
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7646
- validUntil: null,
7647
7821
  externalId: "KvAAIaNqVrp"
7648
7822
  },
7649
7823
  {
7650
7824
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7651
7825
  name: "Halifu",
7652
7826
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7653
- validUntil: null,
7654
7827
  externalId: "qe4UnEVt1hv"
7655
7828
  },
7656
7829
  {
7657
7830
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7658
7831
  name: "Jabari",
7659
7832
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7660
- validUntil: null,
7661
7833
  externalId: "yHH9Nz4rLOt"
7662
7834
  },
7663
7835
  {
7664
7836
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7665
7837
  name: "Kifani",
7666
7838
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7667
- validUntil: null,
7668
7839
  externalId: "eSWmXIGeu1I"
7669
7840
  },
7670
7841
  {
7671
7842
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7672
7843
  name: "Lumela",
7673
7844
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7674
- validUntil: null,
7675
7845
  externalId: "bh0b3aI1uP3"
7676
7846
  }
7677
7847
  ];
7678
- var V2_DEFAULT_MOCK_LOCATIONS = [
7848
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
7849
+ var MOCK_LOCATIONS_BASE = [
7679
7850
  {
7680
7851
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7681
7852
  name: "Central Provincial Office",
7682
7853
  locationType: "CRVS_OFFICE",
7683
7854
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7684
- validUntil: null,
7685
7855
  externalId: "Xr3Df8WpK6Ys"
7686
7856
  },
7687
7857
  {
7688
7858
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7689
7859
  name: "Central Health Post",
7690
7860
  locationType: "HEALTH_FACILITY",
7691
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7692
- validUntil: null
7861
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7693
7862
  },
7694
7863
  {
7695
7864
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7696
7865
  name: "Ibombo District Office",
7697
7866
  locationType: "CRVS_OFFICE",
7698
7867
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7699
- validUntil: null,
7700
7868
  externalId: "Sm4Nw7GrD2Vy"
7701
7869
  },
7702
7870
  {
@@ -7704,7 +7872,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7704
7872
  name: "Isamba District Office",
7705
7873
  locationType: "CRVS_OFFICE",
7706
7874
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7707
- validUntil: null,
7708
7875
  externalId: "Vg1Bq5XeH9Lt"
7709
7876
  },
7710
7877
  {
@@ -7712,7 +7879,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7712
7879
  name: "Isango District Office",
7713
7880
  locationType: "CRVS_OFFICE",
7714
7881
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7715
- validUntil: null,
7716
7882
  externalId: "Je7Lm2XqN9Vz"
7717
7883
  },
7718
7884
  {
@@ -7720,7 +7886,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7720
7886
  name: "Sulaka Provincial Office",
7721
7887
  locationType: "CRVS_OFFICE",
7722
7888
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7723
- validUntil: null,
7724
7889
  externalId: "Ht2Wp9KcX5Qv"
7725
7890
  },
7726
7891
  {
@@ -7728,7 +7893,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7728
7893
  name: "Ilanga District Office",
7729
7894
  locationType: "CRVS_OFFICE",
7730
7895
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7731
- validUntil: null,
7732
7896
  externalId: "Yp6Ds1WqN3Xz"
7733
7897
  },
7734
7898
  {
@@ -7736,7 +7900,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7736
7900
  name: "Chamakubi Health Post",
7737
7901
  locationType: "HEALTH_FACILITY",
7738
7902
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7739
- validUntil: null,
7740
7903
  externalId: "M1nFr8LbC2Qy"
7741
7904
  },
7742
7905
  {
@@ -7744,7 +7907,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7744
7907
  name: "Ibombo Rural Health Centre",
7745
7908
  locationType: "HEALTH_FACILITY",
7746
7909
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7747
- validUntil: null,
7748
7910
  externalId: "bT7pV6YrW0Xc"
7749
7911
  },
7750
7912
  {
@@ -7752,7 +7914,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7752
7914
  name: "Chikobo Rural Health Centre",
7753
7915
  locationType: "HEALTH_FACILITY",
7754
7916
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7755
- validUntil: null,
7756
7917
  externalId: "zE4qPn2SgJ5d"
7757
7918
  },
7758
7919
  {
@@ -7760,7 +7921,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7760
7921
  name: "Chilochabalenje Health Post",
7761
7922
  locationType: "HEALTH_FACILITY",
7762
7923
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7763
- validUntil: null,
7764
7924
  externalId: "H8vDs1MqR4Uf"
7765
7925
  },
7766
7926
  {
@@ -7768,7 +7928,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7768
7928
  name: "Chipeso Rural Health Centre",
7769
7929
  locationType: "HEALTH_FACILITY",
7770
7930
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7771
- validUntil: null,
7772
7931
  externalId: "Qw3uZ9KfX6Lm"
7773
7932
  },
7774
7933
  {
@@ -7776,7 +7935,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7776
7935
  name: "Chisamba Rural Health Centre",
7777
7936
  locationType: "HEALTH_FACILITY",
7778
7937
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7779
- validUntil: null,
7780
7938
  externalId: "Yr0pCg8LdM2s"
7781
7939
  },
7782
7940
  {
@@ -7784,7 +7942,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7784
7942
  name: "Chitanda Rural Health Centre",
7785
7943
  locationType: "HEALTH_FACILITY",
7786
7944
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7787
- validUntil: null,
7788
7945
  externalId: "tS9gJ4PwB1Qx"
7789
7946
  },
7790
7947
  {
@@ -7792,7 +7949,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7792
7949
  name: "Golden Valley Rural Health Centre",
7793
7950
  locationType: "HEALTH_FACILITY",
7794
7951
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7795
- validUntil: null,
7796
7952
  externalId: "Ld7Qm3XsA8Vr"
7797
7953
  },
7798
7954
  {
@@ -7800,7 +7956,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7800
7956
  name: "Ipongo Rural Health Centre",
7801
7957
  locationType: "HEALTH_FACILITY",
7802
7958
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7803
- validUntil: null,
7804
7959
  externalId: "kF2sW9DmH0Bt"
7805
7960
  },
7806
7961
  {
@@ -7808,7 +7963,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7808
7963
  name: "Itumbwe Health Post",
7809
7964
  locationType: "HEALTH_FACILITY",
7810
7965
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7811
- validUntil: null,
7812
7966
  externalId: "Ue5Xb3VaC7Pq"
7813
7967
  },
7814
7968
  {
@@ -7816,7 +7970,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7816
7970
  name: "Kabangalala Rural Health Centre",
7817
7971
  locationType: "HEALTH_FACILITY",
7818
7972
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7819
- validUntil: null,
7820
7973
  externalId: "Pz8Kc1TqH6Jn"
7821
7974
  },
7822
7975
  // Village offices
@@ -7825,100 +7978,353 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7825
7978
  name: "Klow Village Office",
7826
7979
  locationType: "CRVS_OFFICE",
7827
7980
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7828
- validUntil: null,
7829
7981
  externalId: "PmAyxAJkxiJ"
7830
7982
  }
7831
7983
  ];
7984
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7832
7985
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7833
7986
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7834
7987
  );
7835
7988
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7836
7989
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7837
7990
  );
7991
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
7992
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
7993
+ );
7994
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
7995
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
7996
+ a.id,
7997
+ toClientAdministrativeArea(a)
7998
+ ])
7999
+ );
8000
+
8001
+ // ../commons/src/events/test.utils.ts
8002
+ var TestUserRole = z44.enum([
8003
+ "FIELD_AGENT",
8004
+ "LOCAL_REGISTRAR",
8005
+ "LOCAL_SYSTEM_ADMIN",
8006
+ "NATIONAL_REGISTRAR",
8007
+ "REGISTRATION_AGENT",
8008
+ "NATIONAL_SYSTEM_ADMIN",
8009
+ "SOCIAL_WORKER",
8010
+ "COMMUNITY_LEADER",
8011
+ "PROVINCIAL_REGISTRAR"
8012
+ ]);
8013
+
8014
+ // ../commons/src/events/scopes.ts
8015
+ var import_lodash6 = require("lodash");
8016
+ var ACTION_SCOPE_MAP = {
8017
+ [ActionType.READ]: ["record.read"],
8018
+ [ActionType.CREATE]: ["record.create"],
8019
+ [ActionType.NOTIFY]: ["record.notify"],
8020
+ [ActionType.DECLARE]: ["record.declare", "record.register"],
8021
+ [ActionType.EDIT]: ["record.edit"],
8022
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
8023
+ [ActionType.REGISTER]: ["record.register"],
8024
+ [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
8025
+ [ActionType.REQUEST_CORRECTION]: [
8026
+ "record.request-correction",
8027
+ "record.correct"
8028
+ ],
8029
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
8030
+ [ActionType.REJECT_CORRECTION]: ["record.correct"],
8031
+ [ActionType.APPROVE_CORRECTION]: ["record.correct"],
8032
+ [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
8033
+ [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
8034
+ [ActionType.ARCHIVE]: ["record.archive"],
8035
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
8036
+ [ActionType.REJECT]: ["record.reject"],
8037
+ [ActionType.ASSIGN]: null,
8038
+ [ActionType.UNASSIGN]: null,
8039
+ [ActionType.DUPLICATE_DETECTED]: [],
8040
+ [ActionType.CUSTOM]: []
8041
+ };
8042
+
8043
+ // ../commons/src/events/state/availableActions.ts
8044
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
8045
+ [EventStatus.enum.CREATED]: [
8046
+ ActionType.READ,
8047
+ ActionType.DECLARE,
8048
+ ActionType.NOTIFY,
8049
+ ActionType.DELETE
8050
+ ],
8051
+ [EventStatus.enum.NOTIFIED]: [
8052
+ ActionType.READ,
8053
+ ActionType.EDIT,
8054
+ ActionType.MARK_AS_DUPLICATE,
8055
+ ActionType.ARCHIVE,
8056
+ ActionType.REJECT,
8057
+ ActionType.CUSTOM
8058
+ ],
8059
+ [EventStatus.enum.DECLARED]: [
8060
+ ActionType.READ,
8061
+ ActionType.REGISTER,
8062
+ ActionType.MARK_AS_DUPLICATE,
8063
+ ActionType.ARCHIVE,
8064
+ ActionType.REJECT,
8065
+ ActionType.CUSTOM,
8066
+ ActionType.EDIT
8067
+ ],
8068
+ [EventStatus.enum.REGISTERED]: [
8069
+ ActionType.READ,
8070
+ ActionType.PRINT_CERTIFICATE,
8071
+ ActionType.REQUEST_CORRECTION,
8072
+ ActionType.APPROVE_CORRECTION,
8073
+ ActionType.REJECT_CORRECTION,
8074
+ ActionType.CUSTOM,
8075
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST
8076
+ ],
8077
+ [EventStatus.enum.ARCHIVED]: [
8078
+ ActionType.READ,
8079
+ ActionType.CUSTOM,
8080
+ ActionType.UNARCHIVE
8081
+ ]
8082
+ };
8083
+ var ACTION_FILTERS = {
8084
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8085
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8086
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8087
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8088
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8089
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8090
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8091
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8092
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8093
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8094
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8095
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8096
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8097
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
8098
+ };
8099
+ var REJECTED_ACTIONS = [
8100
+ ActionType.READ,
8101
+ ActionType.NOTIFY,
8102
+ ActionType.CUSTOM,
8103
+ ActionType.EDIT,
8104
+ ActionType.ARCHIVE
8105
+ ];
8106
+
8107
+ // ../commons/src/events/FileUtils.ts
8108
+ var import_lodash7 = require("lodash");
8109
+
8110
+ // ../commons/src/events/locationPayloads.ts
8111
+ var z45 = __toESM(require("zod/v4"));
8112
+ var CreateLocationPayload = z45.object({
8113
+ id: UUID.optional(),
8114
+ versionId: UUID.optional(),
8115
+ name: z45.string(),
8116
+ externalId: z45.string().nullish(),
8117
+ administrativeAreaId: UUID.nullable(),
8118
+ locationType: z45.string().nullable(),
8119
+ effectiveFrom: z45.iso.date().optional(),
8120
+ status: LocationStatus.default("active")
8121
+ });
8122
+ var UpdateLocationPayload = z45.strictObject({
8123
+ id: UUID,
8124
+ versionId: UUID.optional(),
8125
+ name: z45.string(),
8126
+ externalId: z45.string().nullish(),
8127
+ status: LocationStatus,
8128
+ effectiveFrom: z45.iso.date().optional(),
8129
+ lastVersionId: UUID
8130
+ });
8131
+ var WithdrawLocationVersionPayload = z45.object({
8132
+ id: UUID,
8133
+ versionId: UUID
8134
+ });
8135
+ var CreateAdministrativeAreaPayload = z45.object({
8136
+ id: UUID.optional(),
8137
+ versionId: UUID.optional(),
8138
+ name: z45.string(),
8139
+ externalId: z45.string().nullish(),
8140
+ parentId: UUID.nullable(),
8141
+ effectiveFrom: z45.iso.date().optional(),
8142
+ status: LocationStatus.default("active")
8143
+ });
8144
+ var UpdateAdministrativeAreaPayload = z45.strictObject({
8145
+ id: UUID,
8146
+ versionId: UUID.optional(),
8147
+ name: z45.string(),
8148
+ externalId: z45.string().nullish(),
8149
+ status: LocationStatus,
8150
+ effectiveFrom: z45.iso.date().optional(),
8151
+ lastVersionId: UUID
8152
+ });
8153
+ var WithdrawAdministrativeAreaVersionPayload = z45.object({
8154
+ id: UUID,
8155
+ versionId: UUID
8156
+ });
7838
8157
 
7839
8158
  // ../commons/src/notification/UserNotifications.ts
7840
- var z44 = __toESM(require("zod/v4"));
8159
+ var z46 = __toESM(require("zod/v4"));
7841
8160
  var TriggerEvent = {
7842
8161
  USER_CREATED: "user-created",
7843
8162
  USER_UPDATED: "user-updated",
7844
8163
  USERNAME_REMINDER: "username-reminder",
7845
8164
  RESET_PASSWORD: "reset-password",
7846
8165
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8166
+ PASSWORD_RESET_LINK: "password-reset-link",
8167
+ USERNAME_REMINDER_LINK: "username-reminder-link",
7847
8168
  RESEND_INVITE: "resend-invite",
7848
8169
  TWO_FA: "2fa",
7849
8170
  ALL_USER_NOTIFICATION: "all-user-notification",
7850
8171
  CHANGE_PHONE_NUMBER: "change-phone-number",
7851
8172
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7852
8173
  };
7853
- var Recipient = z44.object({
8174
+ var Recipient = z46.object({
7854
8175
  name: NameFieldValue.optional(),
7855
- mobile: z44.string().optional(),
7856
- email: z44.string().optional(),
7857
- bcc: z44.array(z44.string()).optional()
8176
+ mobile: z46.string().optional(),
8177
+ email: z46.string().optional(),
8178
+ bcc: z46.array(z46.string()).optional()
7858
8179
  });
7859
- var BasePayload = z44.object({
8180
+ var BasePayload = z46.object({
7860
8181
  recipient: Recipient
7861
8182
  });
7862
8183
  var TriggerPayload = {
7863
8184
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7864
- username: z44.string(),
7865
- temporaryPassword: z44.string()
8185
+ username: z46.string(),
8186
+ temporaryPassword: z46.string()
7866
8187
  }),
7867
8188
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7868
- oldUsername: z44.string(),
7869
- newUsername: z44.string()
8189
+ oldUsername: z46.string(),
8190
+ newUsername: z46.string()
7870
8191
  }),
7871
8192
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7872
- username: z44.string()
8193
+ username: z46.string()
7873
8194
  }),
7874
8195
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7875
- code: z44.string()
8196
+ code: z46.string()
7876
8197
  }),
7877
8198
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7878
- temporaryPassword: z44.string(),
7879
- admin: z44.object({
7880
- id: z44.string(),
8199
+ temporaryPassword: z46.string(),
8200
+ admin: z46.object({
8201
+ id: z46.string(),
7881
8202
  name: NameFieldValue,
7882
- role: z44.string()
8203
+ role: z46.string()
7883
8204
  })
7884
8205
  }),
8206
+ [TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
8207
+ token: z46.string()
8208
+ }),
8209
+ [TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
8210
+ token: z46.string()
8211
+ }),
7885
8212
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7886
- username: z44.string(),
7887
- temporaryPassword: z44.string()
8213
+ username: z46.string(),
8214
+ temporaryPassword: z46.string()
7888
8215
  }),
7889
8216
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7890
- code: z44.string()
8217
+ code: z46.string()
7891
8218
  }),
7892
8219
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7893
- subject: z44.string(),
7894
- body: z44.string()
8220
+ subject: z46.string(),
8221
+ body: z46.string()
7895
8222
  }),
7896
8223
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7897
- code: z44.string()
8224
+ code: z46.string()
7898
8225
  }),
7899
8226
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7900
- code: z44.string()
8227
+ code: z46.string()
7901
8228
  })
7902
8229
  };
8230
+ function parseUserEventTrigger(event2, body) {
8231
+ const schema = TriggerPayload[event2];
8232
+ return schema.parse(body);
8233
+ }
8234
+
8235
+ // ../commons/src/url.ts
8236
+ function joinUrl(base, path) {
8237
+ const baseWithSlash = base.endsWith("/") ? base : base + "/";
8238
+ return new URL(path, baseWithSlash);
8239
+ }
8240
+
8241
+ // ../commons/src/logger.ts
8242
+ var import_pino = __toESM(require("pino"));
8243
+ function normalizeLogArgs(args) {
8244
+ const [first, ...rest] = args;
8245
+ if (typeof first !== "string" || rest.length === 0) {
8246
+ return args;
8247
+ }
8248
+ const mergingObject = {};
8249
+ const primitives = [];
8250
+ for (const arg of rest) {
8251
+ if (arg instanceof Error) {
8252
+ mergingObject.err = import_pino.default.stdSerializers.err(arg);
8253
+ } else if (arg !== null && typeof arg === "object") {
8254
+ Object.assign(mergingObject, arg);
8255
+ } else {
8256
+ primitives.push(arg);
8257
+ }
8258
+ }
8259
+ const message = primitives.length ? `${first} ${primitives.join(" ")}` : first;
8260
+ return Object.keys(mergingObject).length ? [mergingObject, message] : [message];
8261
+ }
8262
+ function filterHealthCheckLogs(args, method) {
8263
+ const logger2 = this;
8264
+ for (const arg of args) {
8265
+ if (typeof arg === "string" && arg.includes("get /ping 200")) {
8266
+ if (logger2.debug) {
8267
+ return logger2.debug(...args);
8268
+ }
8269
+ }
8270
+ }
8271
+ return method.apply(this, normalizeLogArgs(args));
8272
+ }
8273
+ function buildLoggerOptions() {
8274
+ return {
8275
+ serializers: { err: import_pino.default.stdSerializers.err },
8276
+ hooks: { logMethod: filterHealthCheckLogs }
8277
+ };
8278
+ }
8279
+ var logger = false ? (0, import_pino.default)({
8280
+ level: "info",
8281
+ redact: [
8282
+ "req.headers.authorization",
8283
+ "req.remoteAddress",
8284
+ "req.headers['x-real-ip']"
8285
+ ],
8286
+ ...buildLoggerOptions()
8287
+ }) : (0, import_pino.default)({
8288
+ level: "debug",
8289
+ transport: {
8290
+ target: "pino-pretty",
8291
+ options: {
8292
+ colorize: true,
8293
+ ignore: "pid,hostname"
8294
+ }
8295
+ },
8296
+ ...buildLoggerOptions()
8297
+ });
8298
+ var level = false ? "silent" : process.env.LOG_LEVEL;
8299
+ if (level) {
8300
+ logger.level = level;
8301
+ }
8302
+
8303
+ // ../commons/src/notification/dispatch.ts
7903
8304
  async function triggerUserEventNotification({
7904
8305
  event: event2,
7905
8306
  payload,
7906
8307
  countryConfigUrl,
7907
8308
  authHeader
7908
8309
  }) {
7909
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
7910
- method: "POST",
7911
- body: JSON.stringify(payload),
7912
- headers: {
7913
- "Content-Type": "application/json",
7914
- ...authHeader
8310
+ const response = await fetch(
8311
+ joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8312
+ {
8313
+ method: "POST",
8314
+ body: JSON.stringify(payload),
8315
+ headers: {
8316
+ "Content-Type": "application/json",
8317
+ ...authHeader
8318
+ }
7915
8319
  }
7916
- });
7917
- }
7918
- function parseUserEventTrigger(event2, body) {
7919
- const schema = TriggerPayload[event2];
7920
- return schema.parse(body);
8320
+ );
8321
+ if (!response.ok) {
8322
+ logger.error(
8323
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8324
+ );
8325
+ }
8326
+ return response;
7921
8327
  }
7922
8328
 
7923
8329
  // src/notification/index.ts
7924
- z45.globalRegistry.clear();
8330
+ z47.globalRegistry.clear();