@opencrvs/toolkit 2.1.0-rc.bb6887b → 2.1.0-rc.bed50b3

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