@opencrvs/toolkit 2.1.0-rc.c3b24ba → 2.1.0-rc.c500a81

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