@opencrvs/toolkit 2.0.1 → 2.1.0-beta.2

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 (167) hide show
  1. package/README.md +18 -12
  2. package/build.sh +14 -5
  3. package/create-countryconfig/index.js +313 -129
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +5 -2
  6. package/dist/application-config/index.js +367 -278
  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 +4320 -4790
  11. package/dist/commons/api/router.d.ts +4120 -2982
  12. package/dist/commons/application-config/index.d.ts +6 -6
  13. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +302 -67
  16. package/dist/commons/events/ActionDocument.d.ts +159 -121
  17. package/dist/commons/events/ActionInput.d.ts +30 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +63 -58
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +537 -495
  21. package/dist/commons/events/AuditLog.d.ts +189 -40
  22. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  23. package/dist/commons/events/Conditional.d.ts +3 -3
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
  25. package/dist/commons/events/Draft.d.ts +38 -36
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -3
  28. package/dist/commons/events/EventDocument.d.ts +537 -47
  29. package/dist/commons/events/EventIndex.d.ts +61 -59
  30. package/dist/commons/events/EventMetadata.d.ts +59 -43
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +431 -380
  33. package/dist/commons/events/FieldType.d.ts +51 -51
  34. package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
  35. package/dist/commons/events/FieldValue.d.ts +14 -14
  36. package/dist/commons/events/Flag.d.ts +57 -15
  37. package/dist/commons/events/PlainDate.d.ts +8 -0
  38. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  39. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  40. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  41. package/dist/commons/events/WorkqueueConfig.d.ts +835 -790
  42. package/dist/commons/events/deduplication.d.ts +1 -1
  43. package/dist/commons/events/event.d.ts +14 -2
  44. package/dist/commons/events/field.d.ts +69 -198
  45. package/dist/commons/events/index.d.ts +1 -0
  46. package/dist/commons/events/locationPayloads.d.ts +95 -0
  47. package/dist/commons/events/locations.d.ts +248 -14
  48. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  49. package/dist/commons/events/scopes.d.ts +5 -4
  50. package/dist/commons/events/state/index.d.ts +23 -15
  51. package/dist/commons/events/state/utils.d.ts +15 -6
  52. package/dist/commons/events/test.utils.d.ts +68 -42
  53. package/dist/commons/events/utils.d.ts +143 -110
  54. package/dist/commons/notification/UserNotifications.d.ts +38 -18
  55. package/dist/commons/notification/dispatch.d.ts +10 -0
  56. package/dist/commons/notification/index.d.ts +1 -0
  57. package/dist/conditionals/index.js +340 -63
  58. package/dist/csv.d.ts +25 -0
  59. package/dist/csv.d.ts.map +1 -0
  60. package/dist/csv.js +120 -0
  61. package/dist/environment/custom-types.d.ts +33 -0
  62. package/dist/environment/custom-types.d.ts.map +1 -0
  63. package/dist/environment/custom-types.js +12 -0
  64. package/dist/environment/derived-variables.d.ts +122 -0
  65. package/dist/environment/derived-variables.d.ts.map +1 -0
  66. package/dist/environment/derived-variables.js +155 -0
  67. package/dist/environment/editor-questions.d.ts +4 -0
  68. package/dist/environment/editor-questions.d.ts.map +1 -0
  69. package/dist/environment/editor-questions.js +67 -0
  70. package/dist/environment/git.d.ts +5 -0
  71. package/dist/environment/git.d.ts.map +1 -0
  72. package/dist/environment/git.js +38 -0
  73. package/dist/environment/github.d.ts +26 -0
  74. package/dist/environment/github.d.ts.map +1 -0
  75. package/dist/environment/github.js +247 -0
  76. package/dist/environment/index.d.ts +6 -0
  77. package/dist/environment/index.d.ts.map +1 -0
  78. package/dist/environment/index.js +81 -0
  79. package/dist/environment/logger.d.ts +18 -0
  80. package/dist/environment/logger.d.ts.map +1 -0
  81. package/dist/environment/logger.js +25 -0
  82. package/dist/environment/manage-users.d.ts +11 -0
  83. package/dist/environment/manage-users.d.ts.map +1 -0
  84. package/dist/environment/manage-users.js +507 -0
  85. package/dist/environment/paths.d.ts +7 -0
  86. package/dist/environment/paths.d.ts.map +1 -0
  87. package/dist/environment/paths.js +72 -0
  88. package/dist/environment/questions-helper.d.ts +15 -0
  89. package/dist/environment/questions-helper.d.ts.map +1 -0
  90. package/dist/environment/questions-helper.js +70 -0
  91. package/dist/environment/questions.d.ts +200 -0
  92. package/dist/environment/questions.d.ts.map +1 -0
  93. package/dist/environment/questions.js +418 -0
  94. package/dist/environment/setup-environment.d.ts +2 -0
  95. package/dist/environment/setup-environment.d.ts.map +1 -0
  96. package/dist/environment/setup-environment.js +793 -0
  97. package/dist/environment/ssh-keygen.d.ts +5 -0
  98. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  99. package/dist/environment/ssh-keygen.js +21 -0
  100. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  101. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  102. package/dist/environment/swarm-to-k8s.js +183 -0
  103. package/dist/environment/templates.d.ts +26 -0
  104. package/dist/environment/templates.d.ts.map +1 -0
  105. package/dist/environment/templates.js +159 -0
  106. package/dist/environment/update-workflows.d.ts +2 -0
  107. package/dist/environment/update-workflows.d.ts.map +1 -0
  108. package/dist/environment/update-workflows.js +195 -0
  109. package/dist/environment/upgrade.d.ts +2 -0
  110. package/dist/environment/upgrade.d.ts.map +1 -0
  111. package/dist/environment/upgrade.js +82 -0
  112. package/dist/environment/users.d.ts +2 -0
  113. package/dist/environment/users.d.ts.map +1 -0
  114. package/dist/environment/users.js +120 -0
  115. package/dist/environment/utils.d.ts +6 -0
  116. package/dist/environment/utils.d.ts.map +1 -0
  117. package/dist/environment/utils.js +83 -0
  118. package/dist/events/deduplication.d.ts +1 -1
  119. package/dist/events/index.js +8107 -7388
  120. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  121. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  122. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  123. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  124. package/dist/migrations/v2.0/index.js +88 -5143
  125. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  126. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  127. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  128. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  129. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  130. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  131. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  132. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  133. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  134. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  135. package/dist/migrations/v2.1/add-translations.js +213 -0
  136. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  137. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  138. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  139. package/dist/migrations/v2.1/index.d.ts +6 -0
  140. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  141. package/dist/migrations/v2.1/index.js +1276 -0
  142. package/dist/notification/index.js +2011 -1446
  143. package/dist/scopes/index.d.ts +550 -161
  144. package/dist/scopes/index.js +341 -63
  145. package/dist/telemetry/index.d.ts +45 -0
  146. package/dist/telemetry/index.d.ts.map +1 -0
  147. package/dist/telemetry/index.js +39 -0
  148. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  149. package/dist/templates/charts-values/dependencies/values.yaml +82 -0
  150. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  151. package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
  152. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  153. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  154. package/dist/templates/charts-values/traefik/values.yaml +129 -0
  155. package/dist/templates/inventory/inventory.template.yml +98 -0
  156. package/dist/translations/check.d.ts +21 -0
  157. package/dist/translations/check.d.ts.map +1 -0
  158. package/dist/translations/check.js +132 -0
  159. package/dist/verify/endpoints.d.ts.map +1 -1
  160. package/dist/verify/endpoints.js +26 -26
  161. package/opencrvs-toolkit-2.1.0-beta.2.tgz +0 -0
  162. package/package.json +25 -6
  163. package/tsconfig.build.json +11 -0
  164. package/tsconfig.build.tsbuildinfo +1 -0
  165. package/tsconfig.json +3 -0
  166. package/opencrvs-toolkit-2.0.1.tgz +0 -0
  167. 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",
@@ -79,6 +331,7 @@ var RecordScopeTypeV2 = z2.enum([
79
331
  "record.edit",
80
332
  "record.reject",
81
333
  "record.archive",
334
+ "record.unarchive",
82
335
  "record.review-duplicates",
83
336
  "record.register",
84
337
  "record.print-certified-copies",
@@ -87,14 +340,20 @@ var RecordScopeTypeV2 = z2.enum([
87
340
  "record.unassign-others",
88
341
  "record.custom-action"
89
342
  ]);
90
- var PlainScopeType = z2.enum([
343
+ var PlainScopeType = z7.enum([
91
344
  // Misc. system scopes
92
345
  "bypassratelimit",
93
346
  "record.reindex",
94
347
  "user.data-seeding",
95
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",
96
354
  "record.import",
97
355
  "config.update-all",
356
+ "location.edit",
98
357
  "attachment.upload",
99
358
  "profile.electronic-signature",
100
359
  "user.read-only-my-audit",
@@ -106,72 +365,85 @@ var PlainScopeType = z2.enum([
106
365
  "record.confirm-registration",
107
366
  "record.reject-registration"
108
367
  ]);
109
- var scopeByEvent = z2.preprocess(
368
+ var scopeByEvent = z7.preprocess(
110
369
  (val) => val === void 0 ? void 0 : [val].flat(),
111
- z2.array(z2.string()).optional()
370
+ z7.array(z7.string()).optional()
112
371
  ).describe("Event type, e.g. birth, death");
113
- 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(
114
379
  (val) => val === void 0 ? void 0 : [val].flat(),
115
- z2.array(z2.string()).optional()
380
+ z7.array(z7.string()).optional()
116
381
  ).describe("User role, e.g. admin, field agent");
117
- var scopeOptionsPlaceEvent = z2.object({
382
+ var scopeOptionsPlaceEvent = z7.object({
118
383
  event: scopeByEvent,
119
384
  placeOfEvent: JurisdictionFilter.optional(),
120
385
  createdBy: UserFilter.optional(),
121
386
  createdIn: JurisdictionFilter.optional()
122
387
  }).describe("Options applicable to all record scopes.");
123
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
388
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
389
+ notifiedIn: JurisdictionFilter.optional(),
390
+ notifiedBy: UserFilter.optional(),
124
391
  declaredIn: JurisdictionFilter.optional(),
125
- declaredBy: UserFilter.optional()
392
+ declaredBy: UserFilter.optional(),
393
+ status: scopeByStatus
126
394
  }).describe("Options applicable to actions that may take place after DECLARE");
127
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
395
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
128
396
  registeredIn: JurisdictionFilter.optional(),
129
- registeredBy: UserFilter.optional()
397
+ registeredBy: UserFilter.optional(),
398
+ flags: ContainsFlags.optional()
130
399
  }).describe(
131
400
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
132
401
  );
133
402
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
134
- customActionTypes: z2.preprocess(
403
+ customActionTypes: z7.preprocess(
135
404
  (val) => val === void 0 ? void 0 : [val].flat(),
136
- z2.array(z2.string()).optional()
405
+ z7.array(z7.string()).optional()
137
406
  ).describe("Allowed custom action types")
138
407
  });
139
- var AccessLevelOptions = z2.object({
408
+ var AccessLevelOptions = z7.object({
140
409
  accessLevel: JurisdictionFilter.optional()
141
410
  });
142
411
  var AllUserScopeOptions = AccessLevelOptions.extend({
143
412
  role: userRole.optional()
144
413
  });
145
- var WorkqueueOrDashboardOptions = z2.object({
146
- ids: z2.preprocess(
414
+ var WorkqueueOrDashboardOptions = z7.object({
415
+ ids: z7.preprocess(
147
416
  (val) => val === void 0 ? void 0 : [val].flat(),
148
- z2.array(z2.string())
417
+ z7.array(z7.string())
149
418
  ).describe("Must contain a list of workqueue or dashboard ids.")
150
419
  });
151
- var AllScopeOptions = z2.object({
420
+ var AllScopeOptions = z7.object({
152
421
  ...AllRecordScopeOptions.shape,
153
422
  ...AccessLevelOptions.shape,
154
423
  ...AllUserScopeOptions.shape,
155
424
  ...WorkqueueOrDashboardOptions.shape
156
425
  });
157
426
  var ScopeOptionKey = AllScopeOptions.keyof();
158
- var ResolvedScopeOptionsPlaceEvent = z2.object({
427
+ var ResolvedScopeOptionsPlaceEvent = z7.object({
159
428
  event: scopeByEvent,
160
429
  placeOfEvent: UUID.nullish(),
161
- createdBy: z2.string().optional(),
430
+ createdBy: z7.string().optional(),
162
431
  createdIn: UUID.nullish()
163
432
  }).describe(
164
433
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
165
434
  );
166
435
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
436
+ notifiedIn: UUID.nullish(),
437
+ notifiedBy: z7.string().optional(),
167
438
  declaredIn: UUID.nullish(),
168
- declaredBy: z2.string().optional()
439
+ declaredBy: z7.string().optional()
169
440
  }).describe(
170
441
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
171
442
  );
172
443
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
173
444
  registeredIn: UUID.nullish(),
174
- registeredBy: z2.string().optional()
445
+ registeredBy: z7.string().optional(),
446
+ flags: ContainsFlags.optional()
175
447
  }).describe(
176
448
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
177
449
  );
@@ -184,7 +456,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
184
456
  "record.edit",
185
457
  "record.reject",
186
458
  "record.archive",
187
- "record.review-duplicates",
459
+ "record.unarchive",
188
460
  "record.register"
189
461
  ]);
190
462
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -192,41 +464,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
192
464
  "record.read",
193
465
  "record.request-correction",
194
466
  "record.correct",
195
- "record.unassign-others"
467
+ "record.unassign-others",
468
+ "record.review-duplicates"
196
469
  ]);
197
470
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
198
- templates: z2.preprocess(
471
+ templates: z7.preprocess(
199
472
  (val) => val === void 0 ? void 0 : [val].flat(),
200
- z2.array(z2.string()).optional()
473
+ z7.array(z7.string()).optional()
201
474
  ).describe(
202
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."
203
476
  )
204
477
  });
205
- var RecordScopeV2 = z2.discriminatedUnion("type", [
206
- z2.object({
478
+ var RecordScopeV2 = z7.discriminatedUnion("type", [
479
+ z7.object({
207
480
  type: ScopesWithPlaceEventOptions,
208
481
  options: scopeOptionsPlaceEvent.optional()
209
482
  }),
210
- z2.object({
483
+ z7.object({
211
484
  type: ScopesWithDeclaredOptions,
212
- options: scopeOptionsDeclared.optional()
485
+ options: scopeOptionsDeclaredOrNotified.optional()
213
486
  }),
214
- z2.object({
487
+ z7.object({
215
488
  type: ScopesWithFullOptions,
216
489
  options: AllRecordScopeOptions.optional()
217
490
  }),
218
- z2.object({
219
- type: z2.literal("record.custom-action"),
491
+ z7.object({
492
+ type: z7.literal("record.custom-action"),
220
493
  options: CustomActionScopeOptions.optional()
221
494
  }),
222
- z2.object({
223
- type: z2.literal("record.print-certified-copies"),
495
+ z7.object({
496
+ type: z7.literal("record.print-certified-copies"),
224
497
  options: ScopeOptionsPrintCertifiedCopies.optional()
225
498
  })
226
499
  ]).describe(
227
500
  "Scopes used to check user's permission to perform actions on a record."
228
501
  );
229
- var SystemScopeType = z2.enum([
502
+ var SystemScopeType = z7.enum([
230
503
  "organisation.read-locations",
231
504
  "user.read",
232
505
  "user.create",
@@ -240,221 +513,115 @@ var UserScopeType = SystemScopeType.extract([
240
513
  "user.search"
241
514
  ]);
242
515
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
243
- var UserScopeV2 = z2.discriminatedUnion("type", [
244
- z2.object({
516
+ var UserScopeV2 = z7.discriminatedUnion("type", [
517
+ z7.object({
245
518
  type: ScopesWithRoleOption,
246
519
  options: AllUserScopeOptions.optional()
247
520
  }),
248
- z2.object({
521
+ z7.object({
249
522
  type: UserScopeType.extract(["user.read", "user.search"]),
250
523
  options: AccessLevelOptions.optional()
251
524
  })
252
525
  ]);
253
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
254
- z2.object({
526
+ var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
527
+ z7.object({
255
528
  type: ScopesWithPlaceEventOptions,
256
529
  options: ResolvedScopeOptionsPlaceEvent.optional()
257
530
  }),
258
- z2.object({
531
+ z7.object({
259
532
  type: ScopesWithDeclaredOptions,
260
533
  options: ResolvedScopeOptionsDeclared.optional()
261
534
  }),
262
- z2.object({
535
+ z7.object({
263
536
  type: ScopesWithFullOptions,
264
537
  options: ResolvedScopeOptionsFull.optional()
265
538
  }),
266
- z2.object({
267
- type: z2.literal("record.print-certified-copies"),
539
+ z7.object({
540
+ type: z7.literal("record.print-certified-copies"),
268
541
  options: ResolvedScopeOptionsFull.extend({
269
- templates: z2.array(z2.string()).optional()
542
+ templates: z7.array(z7.string()).optional()
270
543
  }).optional()
271
544
  })
272
545
  ]).describe("Resolved scope with location/user IDs instead of filters.");
273
- var Scope = z2.discriminatedUnion("type", [
274
- z2.object({ type: PlainScopeType }),
546
+ var Scope = z7.discriminatedUnion("type", [
547
+ z7.object({ type: PlainScopeType }),
275
548
  ...RecordScopeV2.options,
276
549
  ...UserScopeV2.options,
277
- z2.object({
278
- type: z2.literal("organisation.read-locations"),
550
+ z7.object({
551
+ type: z7.literal("organisation.read-locations"),
279
552
  options: AccessLevelOptions.optional()
280
553
  }),
281
- z2.object({
282
- type: z2.literal("workqueue"),
554
+ z7.object({
555
+ type: z7.literal("workqueue"),
283
556
  options: WorkqueueOrDashboardOptions
284
557
  }),
285
- z2.object({
286
- type: z2.literal("dashboard.view"),
558
+ z7.object({
559
+ type: z7.literal("dashboard.view"),
287
560
  options: WorkqueueOrDashboardOptions
288
561
  })
289
562
  ]);
290
- var ScopeType = z2.enum([
563
+ var ScopeType = z7.enum([
291
564
  ...SystemScopeType.options,
292
565
  ...RecordScopeTypeV2.options,
293
566
  ...PlainScopeType.options,
294
567
  "workqueue",
295
568
  "dashboard.view"
296
569
  ]);
297
- var EncodedScope = z2.string().brand("EncodedScope");
570
+ var EncodedScope = z7.string().brand("EncodedScope");
298
571
  var DEFAULT_SCOPE_OPTIONS = {
299
572
  placeOfEvent: JurisdictionFilter.enum.all,
300
573
  accessLevel: JurisdictionFilter.enum.all,
301
- registeredIn: JurisdictionFilter.enum.all,
302
- declaredIn: JurisdictionFilter.enum.all
574
+ notifiedIn: JurisdictionFilter.enum.all,
575
+ declaredIn: JurisdictionFilter.enum.all,
576
+ registeredIn: JurisdictionFilter.enum.all
303
577
  };
304
578
 
305
579
  // ../commons/src/authentication.ts
306
- var TokenUserType = z3.enum(["user", "system"]);
307
- var TokenWithBearer = z3.string().regex(/^Bearer\s/);
308
-
309
- // ../commons/src/events/ActionType.ts
310
- var z4 = __toESM(require("zod/v4"));
311
- var ActionType = {
312
- // Pre-declaration actions
313
- DELETE: "DELETE",
314
- CREATE: "CREATE",
315
- NOTIFY: "NOTIFY",
316
- // Declaration actions
317
- DECLARE: "DECLARE",
318
- REGISTER: "REGISTER",
319
- EDIT: "EDIT",
320
- // Declaration system actions. Non-configurable.
321
- DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
322
- REJECT: "REJECT",
323
- // REJECT_DECLARATION
324
- MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
325
- MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
326
- ARCHIVE: "ARCHIVE",
327
- // Record actions
328
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
329
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
330
- REJECT_CORRECTION: "REJECT_CORRECTION",
331
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
332
- // General actions
333
- READ: "READ",
334
- ASSIGN: "ASSIGN",
335
- UNASSIGN: "UNASSIGN",
336
- // Custom action
337
- CUSTOM: "CUSTOM"
338
- };
339
- var ConfirmableActions = [
340
- ActionType.NOTIFY,
341
- ActionType.DECLARE,
342
- ActionType.EDIT,
343
- ActionType.REGISTER,
344
- ActionType.REJECT,
345
- ActionType.ARCHIVE,
346
- ActionType.PRINT_CERTIFICATE,
347
- ActionType.REQUEST_CORRECTION,
348
- ActionType.APPROVE_CORRECTION,
349
- ActionType.REJECT_CORRECTION,
350
- ActionType.CUSTOM
351
- ];
352
- var ActionTypes = z4.enum([
353
- "DELETE",
354
- "CREATE",
355
- "NOTIFY",
356
- "DECLARE",
357
- "EDIT",
358
- "REGISTER",
359
- "DUPLICATE_DETECTED",
360
- "REJECT",
361
- "MARK_AS_DUPLICATE",
362
- "MARK_AS_NOT_DUPLICATE",
363
- "ARCHIVE",
364
- "PRINT_CERTIFICATE",
365
- "REQUEST_CORRECTION",
366
- "REJECT_CORRECTION",
367
- "APPROVE_CORRECTION",
368
- "READ",
369
- "ASSIGN",
370
- "UNASSIGN",
371
- "CUSTOM"
372
- ]);
373
- var ClientSpecificAction = {
374
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
375
- };
376
- var declarationActionValues = [
377
- ActionTypes.enum.DECLARE,
378
- ActionTypes.enum.EDIT,
379
- ActionTypes.enum.REGISTER,
380
- ActionTypes.enum.NOTIFY,
381
- ActionTypes.enum.DUPLICATE_DETECTED
382
- ];
383
- var DeclarationActions = ActionTypes.extract(declarationActionValues);
384
- var declarationUpdateActionValues = [
385
- ...declarationActionValues,
386
- ActionTypes.enum.REQUEST_CORRECTION
387
- ];
388
- var DeclarationUpdateActions = ActionTypes.extract(
389
- declarationUpdateActionValues
390
- );
391
- var annotationActions = ActionTypes.exclude(declarationActionValues);
392
- var writeActions = ActionTypes.exclude([
393
- ActionType.CREATE,
394
- ActionType.READ,
395
- ActionType.ASSIGN,
396
- ActionType.UNASSIGN
397
- ]);
398
- var WorkqueueActionType = ActionTypes.extract([
399
- ActionType.READ,
400
- ActionType.DELETE,
401
- ActionType.DECLARE,
402
- ActionType.REGISTER,
403
- ActionType.EDIT,
404
- ActionType.REJECT,
405
- ActionType.MARK_AS_DUPLICATE,
406
- ActionType.ARCHIVE,
407
- ActionType.PRINT_CERTIFICATE,
408
- ActionType.REQUEST_CORRECTION
409
- ]);
410
- var META_ACTIONS = [
411
- ActionType.ASSIGN,
412
- ActionType.UNASSIGN,
413
- ActionType.READ
414
- ];
580
+ var TokenUserType = z8.enum(["user", "system"]);
581
+ var TokenWithBearer = z8.string().regex(/^Bearer\s/);
415
582
 
416
583
  // ../commons/src/events/AuditLog.ts
417
- var AuditLogEntryBase = z5.object({
418
- id: z5.string(),
419
- clientId: z5.string(),
584
+ var AuditLogEntryBase = z9.object({
585
+ id: z9.string(),
586
+ clientId: z9.string(),
420
587
  clientType: TokenUserType,
421
- createdAt: z5.string()
588
+ createdAt: z9.string()
422
589
  });
423
590
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
424
- operation: z5.literal("event.create"),
425
- requestData: z5.object({
426
- transactionId: z5.string(),
427
- type: z5.string(),
428
- 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()
429
596
  }),
430
- responseSummary: z5.object({
431
- eventId: z5.string(),
432
- trackingId: z5.string()
597
+ responseSummary: z9.object({
598
+ eventId: z9.string(),
599
+ trackingId: z9.string()
433
600
  })
434
601
  });
435
602
  var EventGetEntrySchema = AuditLogEntryBase.extend({
436
- operation: z5.literal("event.get"),
437
- requestData: z5.object({ eventId: z5.string() }),
438
- responseSummary: z5.object({
439
- eventType: z5.string(),
440
- 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()
441
608
  })
442
609
  });
443
610
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
444
- operation: z5.literal("event.search"),
445
- clientType: z5.literal("system"),
446
- requestData: z5.object({
447
- query: z5.record(z5.string(), z5.unknown()).nullable(),
448
- limit: z5.number().nullable(),
449
- 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()
450
617
  }),
451
- responseSummary: z5.object({
452
- total: z5.number(),
453
- eventIds: z5.array(z5.string())
618
+ responseSummary: z9.object({
619
+ total: z9.number(),
620
+ eventIds: z9.array(z9.string())
454
621
  })
455
622
  });
456
623
  var EventActionEntrySchema = AuditLogEntryBase.extend({
457
- operation: z5.enum([
624
+ operation: z9.enum([
458
625
  "event.actions.notify.request",
459
626
  "event.actions.declare.request",
460
627
  "event.actions.register.request",
@@ -465,6 +632,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
465
632
  "event.actions.unassign.request",
466
633
  "event.actions.read.request",
467
634
  "event.actions.archive.request",
635
+ "event.actions.unarchive.request",
468
636
  "event.actions.reinstate.request",
469
637
  "event.actions.print_certificate.request",
470
638
  "event.actions.correction.request.request",
@@ -473,83 +641,159 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
473
641
  "event.actions.mark_as_duplicate.request",
474
642
  "event.actions.mark_as_not_duplicate.request"
475
643
  ]),
476
- requestData: z5.object({
477
- eventId: z5.string(),
478
- actionType: z5.string(),
479
- eventType: z5.string(),
480
- trackingId: z5.string(),
481
- 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()
482
650
  })
483
651
  });
484
652
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
485
- operation: z5.literal("event.actions.custom.request"),
486
- requestData: z5.object({
487
- eventId: z5.string(),
488
- actionType: z5.literal(ActionType.CUSTOM),
489
- customAction: z5.string(),
490
- eventType: z5.string(),
491
- trackingId: z5.string(),
492
- 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()
493
661
  })
494
662
  });
495
663
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
496
- operation: z5.literal("integrations.create"),
497
- requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
498
- 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() })
499
667
  });
500
668
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
501
- operation: z5.literal("integrations.refreshToken"),
502
- requestData: z5.object({ clientId: z5.string() }),
503
- 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() })
504
672
  });
505
673
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
506
- operation: z5.literal("integrations.deactivate"),
507
- requestData: z5.object({ id: z5.string() }),
508
- 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() })
509
677
  });
510
678
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
511
- operation: z5.literal("integrations.activate"),
512
- requestData: z5.object({ id: z5.string() }),
513
- 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() })
514
682
  });
515
683
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
516
- operation: z5.literal("integrations.delete"),
517
- requestData: z5.object({ id: z5.string() }),
518
- 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() })
519
687
  });
520
688
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
521
- operation: z5.literal("integrations.refreshSecret"),
522
- requestData: z5.object({ id: z5.string() }),
523
- 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
524
768
  });
525
769
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
526
- operation: z5.literal("attachments.upload"),
527
- requestData: z5.object({
528
- transactionId: z5.string(),
529
- path: z5.string().nullable()
770
+ operation: z9.literal("attachments.upload"),
771
+ requestData: z9.object({
772
+ transactionId: z9.string(),
773
+ path: z9.string().nullable()
530
774
  }),
531
- responseSummary: z5.object({ fileUrl: z5.string() })
775
+ responseSummary: z9.object({ fileUrl: z9.string() })
532
776
  });
533
- var subjectOnly = z5.object({ subjectId: z5.string() });
534
- var subjectWithReason = z5.object({
535
- subjectId: z5.string(),
536
- reason: z5.string(),
537
- 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()
538
782
  });
539
783
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
540
- operation: z5.literal("user.create_user"),
541
- requestData: z5.object({
542
- subjectId: z5.string(),
543
- role: z5.string(),
544
- 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()
545
789
  })
546
790
  });
547
791
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
548
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
792
+ operation: z9.enum(["user.deactivate", "user.reactivate"]),
549
793
  requestData: subjectWithReason
550
794
  });
551
795
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
552
- operation: z5.enum([
796
+ operation: z9.enum([
553
797
  "user.edit_user",
554
798
  "user.logged_in",
555
799
  "user.logged_out",
@@ -563,14 +807,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
563
807
  requestData: subjectOnly
564
808
  });
565
809
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
566
- operation: z5.literal("user.email_address_changed"),
810
+ operation: z9.literal("user.email_address_changed"),
567
811
  requestData: subjectOnly,
568
- responseSummary: z5.object({ email: z5.string() })
812
+ responseSummary: z9.object({ email: z9.string() })
569
813
  });
570
814
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
571
- operation: z5.literal("user.phone_number_changed"),
815
+ operation: z9.literal("user.phone_number_changed"),
572
816
  requestData: subjectOnly,
573
- responseSummary: z5.object({ phoneNumber: z5.string() })
817
+ responseSummary: z9.object({ phoneNumber: z9.string() })
574
818
  });
575
819
  var userBaseOmit = {
576
820
  id: true,
@@ -578,14 +822,14 @@ var userBaseOmit = {
578
822
  clientType: true,
579
823
  createdAt: true
580
824
  };
581
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
825
+ var UserAuditRecordInput = z9.discriminatedUnion("operation", [
582
826
  UserCreateEntrySchema.omit(userBaseOmit),
583
827
  UserReasonEntrySchema.omit(userBaseOmit),
584
828
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
585
829
  UserEmailChangedEntrySchema.omit(userBaseOmit),
586
830
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
587
831
  ]);
588
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
832
+ var AuditLogEntrySchema = z9.discriminatedUnion("operation", [
589
833
  EventCreateEntrySchema,
590
834
  EventGetEntrySchema,
591
835
  EventSearchEntrySchema,
@@ -597,6 +841,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
597
841
  IntegrationActivateEntrySchema,
598
842
  IntegrationDeleteEntrySchema,
599
843
  IntegrationRefreshSecretEntrySchema,
844
+ LocationCreateEntrySchema,
845
+ LocationUpdateEntrySchema,
846
+ AdministrativeAreaUpdateEntrySchema,
847
+ LocationWithdrawEntrySchema,
848
+ AdministrativeAreaWithdrawEntrySchema,
849
+ AdministrativeAreaCreateEntrySchema,
600
850
  AttachmentUploadEntrySchema,
601
851
  UserCreateEntrySchema,
602
852
  UserReasonEntrySchema,
@@ -610,78 +860,13 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
610
860
  var CHILD_ONBOARDING_EVENT = "child-onboarding";
611
861
 
612
862
  // ../commons/src/events/ActionConfig.ts
613
- var z24 = __toESM(require("zod/v4"));
614
-
615
- // ../commons/src/events/TranslationConfig.ts
616
- var z6 = __toESM(require("zod/v4"));
617
- var TranslationConfig = z6.object({
618
- id: z6.string().describe(
619
- "The identifier of the translation referred in translation CSV files"
620
- ),
621
- defaultMessage: z6.string().describe("Default translation message"),
622
- description: z6.string().describe(
623
- "Describe the translation for a translator to be able to identify it."
624
- )
625
- }).meta({
626
- description: "Translation configuration",
627
- id: "TranslationConfig"
628
- });
863
+ var z25 = __toESM(require("zod/v4"));
629
864
 
630
865
  // ../commons/src/events/FieldConfig.ts
631
866
  var import_v43 = __toESM(require("zod/v4"));
632
867
 
633
- // ../commons/src/events/Conditional.ts
634
- var z7 = __toESM(require("zod/v4"));
635
- var Conditional = z7.any().describe("JSONSchema").meta({
636
- description: "JSON schema conditional configuration",
637
- id: "Conditional"
638
- });
639
- var ConditionalType = {
640
- SHOW: "SHOW",
641
- ENABLE: "ENABLE",
642
- DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
643
- };
644
- var ShowConditional = z7.object({
645
- type: z7.literal(ConditionalType.SHOW),
646
- conditional: Conditional
647
- }).describe(
648
- "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
649
- );
650
- var EnableConditional = z7.object({
651
- type: z7.literal(ConditionalType.ENABLE),
652
- conditional: Conditional
653
- }).describe(
654
- "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
655
- );
656
- var ActionConditional = z7.discriminatedUnion("type", [
657
- // Action can be shown / hidden
658
- ShowConditional,
659
- // Action can be shown to the user in the list but as disabled
660
- EnableConditional
661
- ]).meta({
662
- id: "ActionConditional",
663
- 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."
664
- });
665
- var DisplayOnReviewConditional = z7.object({
666
- type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
667
- conditional: Conditional
668
- }).describe(
669
- "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."
670
- );
671
- var FieldConditional = z7.discriminatedUnion("type", [
672
- // Field input can be shown / hidden
673
- ShowConditional,
674
- // Field input can be shown to the user but as disabled
675
- EnableConditional,
676
- // Field output can be shown / hidden on the review page
677
- DisplayOnReviewConditional
678
- ]).meta({
679
- id: "FieldConditional",
680
- 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."
681
- });
682
-
683
868
  // ../commons/src/events/FieldType.ts
684
- var z8 = __toESM(require("zod/v4"));
869
+ var z10 = __toESM(require("zod/v4"));
685
870
  var FieldType = {
686
871
  NAME: "NAME",
687
872
  PHONE: "PHONE",
@@ -745,7 +930,7 @@ var FieldType = {
745
930
  */
746
931
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
747
932
  };
748
- var FileFieldType = z8.enum([
933
+ var FileFieldType = z10.enum([
749
934
  FieldType.FILE,
750
935
  FieldType.FILE_WITH_OPTIONS,
751
936
  FieldType.SIGNATURE
@@ -781,160 +966,160 @@ var HiddenFieldTypes = [
781
966
  ];
782
967
 
783
968
  // ../commons/src/events/FieldValue.ts
784
- var z12 = __toESM(require("zod/v4"));
969
+ var z14 = __toESM(require("zod/v4"));
785
970
 
786
971
  // ../commons/src/documents.ts
787
- var z9 = __toESM(require("zod/v4"));
788
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
972
+ var z11 = __toESM(require("zod/v4"));
973
+ var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
789
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"
790
975
  );
791
- 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(
792
977
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
793
978
  );
794
- var DocumentPath = z9.string().brand("DocumentPath").describe(
979
+ var DocumentPath = z11.string().brand("DocumentPath").describe(
795
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."
796
981
  );
797
982
 
798
983
  // ../commons/src/events/CompositeFieldValue.ts
799
- var z10 = __toESM(require("zod/v4"));
984
+ var z12 = __toESM(require("zod/v4"));
800
985
  var AddressType = {
801
986
  DOMESTIC: "DOMESTIC",
802
987
  INTERNATIONAL: "INTERNATIONAL"
803
988
  };
804
- var FileFieldValue = z10.object({
989
+ var FileFieldValue = z12.object({
805
990
  path: DocumentPath,
806
- originalFilename: z10.string(),
807
- type: z10.string()
808
- });
809
- var NameFieldValue = z10.object({
810
- firstname: z10.string(),
811
- surname: z10.string(),
812
- middlename: z10.string().optional()
813
- });
814
- var NameFieldUpdateValue = z10.object({
815
- firstname: z10.string().nullish(),
816
- surname: z10.string().nullish(),
817
- middlename: z10.string().nullish()
818
- }).or(z10.null()).or(z10.undefined());
819
- var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
820
- var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
821
- var BaseAddressFieldValue = z10.object({
822
- 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(),
823
1008
  streetLevelDetails: StreetLevelDetailsValue
824
1009
  });
825
- var BaseAddressFieldUpdateValue = z10.object({
826
- country: z10.string().nullish(),
1010
+ var BaseAddressFieldUpdateValue = z12.object({
1011
+ country: z12.string().nullish(),
827
1012
  streetLevelDetails: StreetLevelDetailsUpdateValue
828
1013
  });
829
1014
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
830
- addressType: z10.literal(AddressType.DOMESTIC),
831
- administrativeArea: z10.string().uuid()
1015
+ addressType: z12.literal(AddressType.DOMESTIC),
1016
+ administrativeArea: z12.string().uuid()
832
1017
  });
833
1018
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
834
- addressType: z10.literal(AddressType.INTERNATIONAL)
1019
+ addressType: z12.literal(AddressType.INTERNATIONAL)
835
1020
  });
836
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
1021
+ var AddressFieldValue = z12.discriminatedUnion("addressType", [
837
1022
  DomesticAddressFieldValue,
838
1023
  InternationalAddressFieldValue
839
1024
  ]);
840
1025
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
841
- addressType: z10.literal(AddressType.DOMESTIC),
842
- administrativeArea: z10.string().uuid().nullish()
1026
+ addressType: z12.literal(AddressType.DOMESTIC),
1027
+ administrativeArea: z12.string().uuid().nullish()
843
1028
  /* Leaf level admin structure */
844
1029
  });
845
1030
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
846
1031
  {
847
- addressType: z10.literal(AddressType.INTERNATIONAL)
1032
+ addressType: z12.literal(AddressType.INTERNATIONAL)
848
1033
  }
849
1034
  );
850
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
1035
+ var AddressFieldUpdateValue = z12.discriminatedUnion("addressType", [
851
1036
  DomesticAddressUpdateFieldValue,
852
1037
  InternationalAddressUpdateFieldValue
853
1038
  ]).nullish();
854
- var FileFieldValueWithOption = z10.object({
1039
+ var FileFieldValueWithOption = z12.object({
855
1040
  path: DocumentPath,
856
- originalFilename: z10.string(),
857
- type: z10.string(),
858
- option: z10.string()
859
- });
860
- var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
861
- var HttpFieldValue = z10.object({
862
- loading: z10.boolean(),
863
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
864
- data: z10.any()
865
- });
866
- var HttpFieldUpdateValue = z10.object({
867
- loading: z10.boolean().nullish(),
868
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
869
- data: z10.any().nullish()
870
- }).or(z10.null()).or(z10.undefined());
871
- var QueryParamReaderFieldValue = z10.object({
872
- data: z10.record(z10.string(), z10.string()),
873
- 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()
874
1059
  }).nullish();
875
- var QueryParamReaderFieldUpdateValue = z10.object({
876
- data: z10.record(z10.string(), z10.string())
1060
+ var QueryParamReaderFieldUpdateValue = z12.object({
1061
+ data: z12.record(z12.string(), z12.string())
877
1062
  });
878
- var ReadDataValue = z10.object({
879
- data: z10.any()
1063
+ var ReadDataValue = z12.object({
1064
+ data: z12.any()
880
1065
  });
881
1066
  var QrReaderFieldValue = ReadDataValue;
882
1067
  var IdReaderFieldValue = ReadDataValue;
883
- var NumberWithUnitFieldValue = z10.object({
884
- numericValue: z10.number(),
885
- unit: z10.string()
1068
+ var NumberWithUnitFieldValue = z12.object({
1069
+ numericValue: z12.number(),
1070
+ unit: z12.string()
886
1071
  });
887
- var NumberWithUnitFieldUpdateValue = z10.object({
888
- numericValue: z10.number().optional(),
889
- unit: z10.string().optional()
1072
+ var NumberWithUnitFieldUpdateValue = z12.object({
1073
+ numericValue: z12.number().optional(),
1074
+ unit: z12.string().optional()
890
1075
  });
891
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1076
+ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
892
1077
 
893
1078
  // ../commons/src/events/PlainDate.ts
894
1079
  var import_zod = require("zod");
895
1080
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
896
1081
 
897
1082
  // ../commons/src/events/FieldValue.ts
898
- var TextValue = z12.string();
899
- var HiddenFieldValue = z12.string();
900
- var NonEmptyTextValue = z12.string().trim().min(1);
901
- var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
902
- var AgeValue = z12.object({
903
- age: z12.number(),
904
- 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()
905
1090
  });
906
1091
  var AgeUpdateValue = AgeValue.optional().nullable();
907
- var AutocompleteValue = z12.object({
908
- label: z12.string(),
909
- value: z12.string()
1092
+ var AutocompleteValue = z14.object({
1093
+ label: z14.string(),
1094
+ value: z14.string()
910
1095
  });
911
1096
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
912
- var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
913
- var DatetimeValue = z12.iso.datetime();
914
- 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([
915
1100
  "last7Days",
916
1101
  "last30Days",
917
1102
  "last90Days",
918
1103
  "last365Days"
919
1104
  ]);
920
- var DateRangeFieldValue = z12.object({
1105
+ var DateRangeFieldValue = z14.object({
921
1106
  start: PlainDate,
922
1107
  end: PlainDate
923
1108
  }).or(PlainDate).describe(
924
1109
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
925
1110
  );
926
- var EmailValue = z12.email();
927
- var CheckboxFieldValue = z12.boolean();
928
- var NumberFieldValue = z12.number();
1111
+ var EmailValue = z14.email();
1112
+ var CheckboxFieldValue = z14.boolean();
1113
+ var NumberFieldValue = z14.number();
929
1114
  var SignatureFieldValue = FileFieldValue;
930
- var ButtonFieldValue = z12.number();
931
- var VerificationStatusValue = z12.enum([
1115
+ var ButtonFieldValue = z14.number();
1116
+ var VerificationStatusValue = z14.enum([
932
1117
  "verified",
933
1118
  "authenticated",
934
1119
  "failed",
935
1120
  "pending"
936
1121
  ]);
937
- var LeafFieldValues = z12.union([
1122
+ var LeafFieldValues = z14.union([
938
1123
  AddressFieldValue,
939
1124
  TextValue,
940
1125
  PlainDate,
@@ -960,11 +1145,11 @@ var LeafFieldValues = z12.union([
960
1145
  AutocompleteValue,
961
1146
  AutocompleteUpdateValue
962
1147
  ]);
963
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
964
- var DataFieldValue = z12.object({
965
- 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)
966
1151
  }).nullish();
967
- var FieldValue = z12.union([
1152
+ var FieldValue = z14.union([
968
1153
  LeafFieldValues,
969
1154
  DataFieldValue,
970
1155
  FieldGroupValue
@@ -998,7 +1183,7 @@ function safeUnion(schemas) {
998
1183
  const sortedSchemas = [...schemas].sort(
999
1184
  (a, b) => schemaPriority(a) - schemaPriority(b)
1000
1185
  );
1001
- return z12.any().superRefine((val, ctx) => {
1186
+ return z14.any().superRefine((val, ctx) => {
1002
1187
  for (const schema of sortedSchemas) {
1003
1188
  if (schema.safeParse(val).success) {
1004
1189
  return;
@@ -1037,9 +1222,9 @@ var FieldUpdateValue = safeUnion([
1037
1222
  ]);
1038
1223
 
1039
1224
  // ../commons/src/events/serializers/user/serializer.ts
1040
- var z13 = __toESM(require("zod/v4"));
1041
- var SerializedUserField = z13.object({
1042
- $userField: z13.enum([
1225
+ var z15 = __toESM(require("zod/v4"));
1226
+ var SerializedUserField = z15.object({
1227
+ $userField: z15.enum([
1043
1228
  "id",
1044
1229
  "name",
1045
1230
  "role",
@@ -1053,7 +1238,7 @@ var SerializedUserField = z13.object({
1053
1238
  "primaryOfficeId",
1054
1239
  "administrativeAreaId"
1055
1240
  ]),
1056
- $location: z13.string().optional()
1241
+ $location: z15.string().optional()
1057
1242
  });
1058
1243
  function userSerializer(userField) {
1059
1244
  return {
@@ -1076,30 +1261,25 @@ function userSerializer(userField) {
1076
1261
  var import_v4 = require("zod/v4");
1077
1262
 
1078
1263
  // ../commons/src/events/EventMetadata.ts
1079
- var z16 = __toESM(require("zod/v4"));
1264
+ var z17 = __toESM(require("zod/v4"));
1080
1265
 
1081
1266
  // ../commons/src/events/ActionDocument.ts
1082
- var z14 = __toESM(require("zod/v4"));
1083
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1267
+ var z16 = __toESM(require("zod/v4"));
1268
+ var ActionUpdate = z16.record(z16.string(), FieldUpdateValue).describe(
1084
1269
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1085
1270
  );
1086
- var EventState = z14.record(z14.string(), FieldValue).describe(
1271
+ var EventState = z16.record(z16.string(), FieldValue).describe(
1087
1272
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1088
1273
  );
1089
- var ActionStatus = {
1090
- Requested: "Requested",
1091
- Accepted: "Accepted",
1092
- Rejected: "Rejected"
1093
- };
1094
- var ActionBase = z14.object({
1274
+ var ActionBase = z16.object({
1095
1275
  id: UUID.describe("Unique identifier of the action."),
1096
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1276
+ transactionId: z16.string().describe("Unique identifier of the transaction."),
1097
1277
  createdByUserType: TokenUserType.describe(
1098
1278
  "Indicates whether the action was created by a human-user or by a system-user."
1099
1279
  ),
1100
- createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1101
- createdBy: z14.string().describe("Identifier of the user who created the action."),
1102
- 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."),
1103
1283
  createdBySignature: DocumentPath.nullish().describe(
1104
1284
  "Reference to the signature of the user who created the action."
1105
1285
  ),
@@ -1111,7 +1291,7 @@ var ActionBase = z14.object({
1111
1291
  "Declaration data defined by the ActionConfig. Supports partial updates."
1112
1292
  ),
1113
1293
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1114
- status: z14.enum([
1294
+ status: z16.enum([
1115
1295
  ActionStatus.Requested,
1116
1296
  ActionStatus.Accepted,
1117
1297
  ActionStatus.Rejected
@@ -1123,139 +1303,150 @@ var ActionBase = z14.object({
1123
1303
  )
1124
1304
  });
1125
1305
  var AssignedAction = ActionBase.extend(
1126
- z14.object({
1127
- type: z14.literal(ActionType.ASSIGN),
1128
- 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.")
1129
1309
  // TODO move into 'content' property
1130
1310
  }).shape
1131
1311
  );
1132
1312
  var UnassignedAction = ActionBase.extend(
1133
- z14.object({
1134
- type: z14.literal(ActionType.UNASSIGN)
1313
+ z16.object({
1314
+ type: z16.literal(ActionType.UNASSIGN)
1135
1315
  }).shape
1136
1316
  );
1137
1317
  var RegisterAction = ActionBase.extend(
1138
- z14.object({
1139
- type: z14.literal(ActionType.REGISTER),
1140
- registrationNumber: z14.string().optional().describe(
1318
+ z16.object({
1319
+ type: z16.literal(ActionType.REGISTER),
1320
+ registrationNumber: z16.string().optional().describe(
1141
1321
  "Registration number of the event. Always present for accepted registrations."
1142
1322
  )
1143
1323
  // TODO move into 'content' property
1144
1324
  }).shape
1145
1325
  );
1146
1326
  var DeclareAction = ActionBase.extend(
1147
- z14.object({
1148
- type: z14.literal(ActionType.DECLARE)
1327
+ z16.object({
1328
+ type: z16.literal(ActionType.DECLARE)
1149
1329
  }).shape
1150
1330
  );
1151
- var ReasonContent = z14.object({
1152
- 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(
1153
1333
  "Message describing the reason for rejecting or archiving the event."
1154
1334
  )
1155
1335
  });
1156
1336
  var RejectAction = ActionBase.extend(
1157
- z14.object({
1158
- type: z14.literal(ActionType.REJECT),
1337
+ z16.object({
1338
+ type: z16.literal(ActionType.REJECT),
1159
1339
  content: ReasonContent
1160
1340
  }).shape
1161
1341
  );
1162
- var PotentialDuplicate = z14.object({
1342
+ var PotentialDuplicate = z16.object({
1163
1343
  id: UUID,
1164
- trackingId: z14.string()
1344
+ trackingId: z16.string()
1165
1345
  });
1166
1346
  var DuplicateDetectedAction = ActionBase.extend(
1167
- z14.object({
1168
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1169
- content: z14.object({
1170
- duplicates: z14.array(PotentialDuplicate)
1347
+ z16.object({
1348
+ type: z16.literal(ActionType.DUPLICATE_DETECTED),
1349
+ content: z16.object({
1350
+ duplicates: z16.array(PotentialDuplicate)
1171
1351
  })
1172
1352
  }).shape
1173
1353
  );
1174
1354
  var MarkNotDuplicateAction = ActionBase.extend(
1175
- z14.object({
1176
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1355
+ z16.object({
1356
+ type: z16.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1177
1357
  }).shape
1178
1358
  );
1179
1359
  var MarkAsDuplicateAction = ActionBase.extend(
1180
- z14.object({
1181
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1182
- content: z14.object({
1360
+ z16.object({
1361
+ type: z16.literal(ActionType.MARK_AS_DUPLICATE),
1362
+ content: z16.object({
1183
1363
  duplicateOf: UUID
1184
1364
  }).optional()
1185
1365
  }).shape
1186
1366
  );
1187
1367
  var ArchiveAction = ActionBase.extend(
1188
- z14.object({
1189
- type: z14.literal(ActionType.ARCHIVE),
1190
- 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()
1375
+ }).shape
1376
+ );
1377
+ var UnarchiveAction = ActionBase.extend(
1378
+ z16.object({
1379
+ type: z16.literal(ActionType.UNARCHIVE)
1191
1380
  }).shape
1192
1381
  );
1193
1382
  var CreatedAction = ActionBase.extend(
1194
- z14.object({
1195
- type: z14.literal(ActionType.CREATE)
1383
+ z16.object({
1384
+ type: z16.literal(ActionType.CREATE)
1196
1385
  }).shape
1197
1386
  );
1198
1387
  var NotifiedAction = ActionBase.extend(
1199
- z14.object({
1200
- type: z14.literal(ActionType.NOTIFY)
1388
+ z16.object({
1389
+ type: z16.literal(ActionType.NOTIFY)
1201
1390
  }).shape
1202
1391
  );
1203
1392
  var EditAction = ActionBase.extend(
1204
- z14.object({
1205
- type: z14.literal(ActionType.EDIT),
1206
- content: z14.object({
1207
- comment: z14.string().describe("Comment for the edit action.").optional()
1208
- })
1393
+ z16.object({
1394
+ type: z16.literal(ActionType.EDIT),
1395
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1396
+ content: z16.object({
1397
+ comment: z16.string().describe("Comment for the edit action.").optional()
1398
+ }).optional()
1209
1399
  }).shape
1210
1400
  );
1211
- var PrintContent = z14.object({
1212
- templateId: z14.string().optional()
1401
+ var PrintContent = z16.object({
1402
+ templateId: z16.string().optional()
1213
1403
  });
1214
1404
  var PrintCertificateAction = ActionBase.extend(
1215
- z14.object({
1216
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1405
+ z16.object({
1406
+ type: z16.literal(ActionType.PRINT_CERTIFICATE),
1217
1407
  content: PrintContent.optional().nullable()
1218
1408
  }).shape
1219
1409
  );
1220
1410
  var RequestedCorrectionAction = ActionBase.extend(
1221
- z14.object({
1222
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1411
+ z16.object({
1412
+ type: z16.literal(ActionType.REQUEST_CORRECTION)
1223
1413
  }).shape
1224
1414
  );
1225
1415
  var ApprovedCorrectionAction = ActionBase.extend(
1226
- z14.object({
1227
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1228
- requestId: z14.string(),
1416
+ z16.object({
1417
+ type: z16.literal(ActionType.APPROVE_CORRECTION),
1418
+ requestId: z16.string(),
1229
1419
  // TODO move into 'content' property
1230
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1420
+ content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1231
1421
  }).shape
1232
1422
  );
1233
1423
  var RejectedCorrectionAction = ActionBase.extend(
1234
- z14.object({
1235
- type: z14.literal(ActionType.REJECT_CORRECTION),
1236
- requestId: z14.string(),
1424
+ z16.object({
1425
+ type: z16.literal(ActionType.REJECT_CORRECTION),
1426
+ requestId: z16.string(),
1237
1427
  // TODO move into 'content' property
1238
1428
  content: ReasonContent
1239
1429
  }).shape
1240
1430
  );
1241
1431
  var ReadAction = ActionBase.extend(
1242
- z14.object({
1243
- type: z14.literal(ActionType.READ)
1432
+ z16.object({
1433
+ type: z16.literal(ActionType.READ)
1244
1434
  }).shape
1245
1435
  );
1246
1436
  var CustomAction = ActionBase.merge(
1247
- z14.object({
1248
- type: z14.literal(ActionType.CUSTOM),
1249
- customActionType: z14.string()
1437
+ z16.object({
1438
+ type: z16.literal(ActionType.CUSTOM),
1439
+ customActionType: z16.string()
1250
1440
  })
1251
1441
  );
1252
- var ActionDocument = z14.discriminatedUnion("type", [
1442
+ var ActionDocument = z16.discriminatedUnion("type", [
1253
1443
  CreatedAction.meta({ id: "CreatedAction" }),
1254
1444
  RejectAction.meta({ id: "RejectAction" }),
1255
1445
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1256
1446
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1257
1447
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1258
1448
  ArchiveAction.meta({ id: "ArchiveAction" }),
1449
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1259
1450
  NotifiedAction.meta({ id: "NotifiedAction" }),
1260
1451
  RegisterAction.meta({ id: "RegisterAction" }),
1261
1452
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1275,108 +1466,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1275
1466
  declaration: true,
1276
1467
  annotation: true
1277
1468
  }).extend(
1278
- z14.object({
1279
- type: z14.enum(ConfirmableActions),
1280
- status: z14.literal(ActionStatus.Rejected)
1469
+ z16.object({
1470
+ type: z16.enum(ConfirmableActions),
1471
+ status: z16.literal(ActionStatus.Rejected)
1281
1472
  }).shape
1282
1473
  );
1283
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1284
-
1285
- // ../commons/src/events/Flag.ts
1286
- var z15 = __toESM(require("zod/v4"));
1287
- var InherentFlags = {
1288
- INCOMPLETE: "incomplete",
1289
- REJECTED: "rejected",
1290
- CORRECTION_REQUESTED: "correction-requested",
1291
- POTENTIAL_DUPLICATE: "potential-duplicate",
1292
- /**
1293
- * This flag is set by the Edit-action and removed after the declaration or registration.
1294
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1295
- *
1296
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1297
- */
1298
- EDIT_IN_PROGRESS: "edit-in-progress"
1299
- };
1300
- var ActionFlag = z15.string().regex(
1301
- new RegExp(
1302
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1303
- ActionStatus
1304
- ).join("|").toLowerCase()})$`
1305
- ),
1306
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1307
- );
1308
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1309
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1310
- InherentFlags
1311
- ).join(", ")}`
1312
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1313
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1314
- }).describe("Custom flag identifier defined by the country config.");
1315
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1316
- var FlagConfig = z15.object({
1317
- id: CustomFlag,
1318
- requiresAction: z15.boolean().describe(
1319
- "Indicates if this flag expects an action to be performed to be cleared."
1320
- ),
1321
- label: TranslationConfig.describe("Human readable label of the flag.")
1322
- }).meta({
1323
- id: "FlagConfig",
1324
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1325
- });
1326
- var ActionFlagConfig = z15.object({
1327
- id: Flag,
1328
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1329
- conditional: Conditional.optional().describe(
1330
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1331
- )
1332
- }).meta({
1333
- id: "ActionFlagConfig",
1334
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1335
- });
1474
+ var Action = z16.union([ActionDocument, AsyncRejectActionDocument]);
1336
1475
 
1337
1476
  // ../commons/src/events/EventMetadata.ts
1338
- var EventStatus = z16.enum([
1339
- "CREATED",
1340
- "NOTIFIED",
1341
- "DECLARED",
1342
- "REGISTERED",
1343
- "ARCHIVED"
1344
- ]);
1345
- var ZodDate = z16.iso.date();
1346
- var ZodDateTime = z16.string().datetime();
1347
- var ActionCreationMetadata = z16.object({
1348
- createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1349
- 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."),
1350
1482
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1351
1483
  createdAtLocation: UUID.nullish().describe(
1352
1484
  "Location of the user who created the action request."
1353
1485
  ),
1354
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1355
- acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1356
- 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.")
1357
1489
  });
1358
1490
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1359
- registrationNumber: z16.string().describe(
1491
+ registrationNumber: z17.string().describe(
1360
1492
  "Registration number of the event. Always present for accepted registrations."
1361
1493
  )
1362
1494
  });
1363
- var LegalStatuses = z16.object({
1495
+ var LegalStatuses = z17.object({
1496
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1364
1497
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1365
1498
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1366
1499
  });
1367
- var EventMetadata = z16.object({
1500
+ var EventMetadata = z17.object({
1368
1501
  id: UUID,
1369
- 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."),
1370
1503
  status: EventStatus,
1371
1504
  legalStatuses: LegalStatuses.describe(
1372
1505
  "Metadata related to the legal registration of the event, such as who registered it and when."
1373
1506
  ),
1374
- 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."),
1375
1508
  dateOfEvent: ZodDate.nullish(),
1376
1509
  placeOfEvent: UUID.nullish(),
1377
- createdBy: z16.string().describe("ID of the user who created the event."),
1378
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1379
- 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."),
1380
1513
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1381
1514
  createdAtLocation: UUID.nullish().describe(
1382
1515
  "Location of the user who created the event."
@@ -1384,18 +1517,18 @@ var EventMetadata = z16.object({
1384
1517
  updatedAtLocation: UUID.nullish().describe(
1385
1518
  "Location of the user who last changed the status."
1386
1519
  ),
1387
- updatedAt: z16.iso.datetime().describe(
1520
+ updatedAt: z17.iso.datetime().describe(
1388
1521
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1389
1522
  ),
1390
- assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1391
- updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1392
- 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(
1393
1526
  "System-generated tracking ID used by informants or registrars to look up the event."
1394
1527
  ),
1395
- potentialDuplicates: z16.array(PotentialDuplicate).describe(
1528
+ potentialDuplicates: z17.array(PotentialDuplicate).describe(
1396
1529
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1397
1530
  ),
1398
- flags: z16.array(Flag)
1531
+ flags: z17.array(Flag)
1399
1532
  });
1400
1533
  var EventMetadataKeysArray = [
1401
1534
  "id",
@@ -1416,18 +1549,22 @@ var EventMetadataKeysArray = [
1416
1549
  "legalStatuses",
1417
1550
  "flags"
1418
1551
  ];
1419
- var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1420
- var EventMetadataDateFieldIdInput = z16.enum([
1552
+ var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1553
+ var EventMetadataDateFieldIdInput = z17.enum([
1421
1554
  "createdAt",
1422
1555
  "updatedAt",
1556
+ "legalStatuses.NOTIFIED.createdAt",
1557
+ "legalStatuses.NOTIFIED.acceptedAt",
1423
1558
  "legalStatuses.DECLARED.createdAt",
1424
1559
  "legalStatuses.DECLARED.acceptedAt",
1425
1560
  "legalStatuses.REGISTERED.createdAt",
1426
1561
  "legalStatuses.REGISTERED.acceptedAt"
1427
1562
  ]);
1428
- var EventMetadataDateFieldId = z16.enum([
1563
+ var EventMetadataDateFieldId = z17.enum([
1429
1564
  "event.createdAt",
1430
1565
  "event.updatedAt",
1566
+ "event.legalStatuses.NOTIFIED.createdAt",
1567
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1431
1568
  "event.legalStatuses.DECLARED.createdAt",
1432
1569
  "event.legalStatuses.DECLARED.acceptedAt",
1433
1570
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1485,12 +1622,6 @@ var Range = import_v4.z.object({
1485
1622
  }).meta({
1486
1623
  id: "Range"
1487
1624
  });
1488
- var ContainsFlags = import_v4.z.object({
1489
- anyOf: import_v4.z.array(Flag).optional(),
1490
- noneOf: import_v4.z.array(Flag).optional()
1491
- }).meta({
1492
- id: "ContainsFlags"
1493
- });
1494
1625
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1495
1626
  id: "Within"
1496
1627
  });
@@ -1717,8 +1848,8 @@ var BaseField = import_v43.default.object({
1717
1848
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1718
1849
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1719
1850
  ),
1720
- secured: import_v43.default.boolean().default(false).optional().describe(
1721
- "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."
1722
1853
  ),
1723
1854
  placeholder: TranslationConfig.optional(),
1724
1855
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2116,7 +2247,13 @@ var AdministrativeAreaField = BaseField.extend({
2116
2247
  configuration: import_v43.default.object({
2117
2248
  partOf: FieldReference.optional().describe("Parent location"),
2118
2249
  type: AdministrativeAreas,
2119
- 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
+ )
2120
2257
  }).describe("Administrative area options")
2121
2258
  }).meta({
2122
2259
  description: "Administrative area input field",
@@ -2127,7 +2264,13 @@ var LocationInput = BaseField.extend({
2127
2264
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2128
2265
  configuration: import_v43.default.object({
2129
2266
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2130
- 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
+ )
2131
2274
  }).optional()
2132
2275
  }).meta({
2133
2276
  description: "A field for selecting a location",
@@ -2153,12 +2296,20 @@ var FileUploadWithOptions = BaseField.extend({
2153
2296
  var Facility = BaseField.extend({
2154
2297
  type: import_v43.default.literal(FieldType.FACILITY),
2155
2298
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2156
- 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()
2157
2304
  }).describe("Input field for a facility");
2158
2305
  var Office = BaseField.extend({
2159
2306
  type: import_v43.default.literal(FieldType.OFFICE),
2160
2307
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2161
- 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()
2162
2313
  }).describe("Input field for an office");
2163
2314
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2164
2315
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2191,7 +2342,13 @@ var Address = BaseField.extend({
2191
2342
  parent: FieldReference.optional()
2192
2343
  })
2193
2344
  ).optional(),
2194
- 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
+ )
2195
2352
  }).optional(),
2196
2353
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2197
2354
  }).meta({
@@ -2246,10 +2403,19 @@ var ButtonField = BaseField.extend({
2246
2403
  description: "A generic button that can be used to trigger an action",
2247
2404
  id: "ButtonField"
2248
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
+ });
2249
2414
  var FieldGroup = BaseField.extend({
2250
2415
  type: import_v43.default.literal(FieldType.FIELD_GROUP),
2251
2416
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2252
- 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()
2253
2419
  }).meta({
2254
2420
  description: "A group of fields that are displayed together",
2255
2421
  id: "FieldGroup"
@@ -2492,21 +2658,21 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2492
2658
  ]);
2493
2659
 
2494
2660
  // ../commons/src/events/FormConfig.ts
2495
- var z22 = __toESM(require("zod/v4"));
2661
+ var z23 = __toESM(require("zod/v4"));
2496
2662
 
2497
2663
  // ../commons/src/events/PageConfig.ts
2498
- var z21 = __toESM(require("zod/v4"));
2499
- var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2500
- var PageConfigBase = z21.object({
2501
- 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"),
2502
2668
  title: TranslationConfig.describe("Header title of the page"),
2503
- requireCompletionToContinue: z21.boolean().default(false).describe(
2669
+ requireCompletionToContinue: z22.boolean().default(false).describe(
2504
2670
  "If true, all required fields must be filled before continuing to the next page"
2505
2671
  ),
2506
- showClearButton: z21.boolean().optional().describe(
2672
+ showClearButton: z22.boolean().optional().describe(
2507
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'
2508
2674
  ),
2509
- fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2675
+ fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2510
2676
  conditional: Conditional.optional().describe(
2511
2677
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2512
2678
  )
@@ -2515,13 +2681,13 @@ var PageConfigBase = z21.object({
2515
2681
  id: "FormPageConfig"
2516
2682
  });
2517
2683
  var FormPageConfig = PageConfigBase.extend({
2518
- type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2684
+ type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2519
2685
  });
2520
- var VerificationActionConfig = z21.object({
2521
- verify: z21.object({ label: TranslationConfig }),
2522
- cancel: z21.object({
2686
+ var VerificationActionConfig = z22.object({
2687
+ verify: z22.object({ label: TranslationConfig }),
2688
+ cancel: z22.object({
2523
2689
  label: TranslationConfig,
2524
- confirmation: z21.object({
2690
+ confirmation: z22.object({
2525
2691
  title: TranslationConfig,
2526
2692
  body: TranslationConfig
2527
2693
  })
@@ -2531,34 +2697,34 @@ var VerificationActionConfig = z21.object({
2531
2697
  id: "VerificationActionConfig"
2532
2698
  });
2533
2699
  var VerificationPageConfig = FormPageConfig.extend({
2534
- type: z21.literal(PageTypes.enum.VERIFICATION),
2700
+ type: z22.literal(PageTypes.enum.VERIFICATION),
2535
2701
  actions: VerificationActionConfig
2536
2702
  });
2537
- var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2703
+ var PageConfig = z22.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2538
2704
  id: "PageConfig",
2539
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."
2540
2706
  });
2541
2707
 
2542
2708
  // ../commons/src/events/FormConfig.ts
2543
- var DeclarationFormConfig = z22.object({
2709
+ var DeclarationFormConfig = z23.object({
2544
2710
  label: TranslationConfig.describe("Human readable description of the form"),
2545
- pages: z22.array(FormPageConfig)
2711
+ pages: z23.array(FormPageConfig)
2546
2712
  }).meta({
2547
2713
  id: "DeclarationFormConfig",
2548
2714
  description: "Configuration of the declaration form."
2549
2715
  });
2550
- var ActionFormConfig = z22.object({
2716
+ var ActionFormConfig = z23.object({
2551
2717
  label: TranslationConfig.describe("Human readable description of the form"),
2552
- pages: z22.array(PageConfig)
2718
+ pages: z23.array(PageConfig)
2553
2719
  }).describe(
2554
2720
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
2555
2721
  );
2556
- var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
2722
+ var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2557
2723
 
2558
2724
  // ../commons/src/events/DeduplicationConfig.ts
2559
- var z23 = __toESM(require("zod/v4"));
2560
- var FieldReference2 = z23.string();
2561
- var Matcher = z23.object({
2725
+ var z24 = __toESM(require("zod/v4"));
2726
+ var FieldReference2 = z24.string();
2727
+ var Matcher = z24.object({
2562
2728
  /**
2563
2729
  * Reference to the field used in matching.
2564
2730
  *
@@ -2566,23 +2732,23 @@ var Matcher = z23.object({
2566
2732
  * be used as the origin date to calculate the distance from.
2567
2733
  */
2568
2734
  fieldId: FieldReference2,
2569
- options: z23.object({
2570
- boost: z23.number().optional(),
2735
+ options: z24.object({
2736
+ boost: z24.number().optional(),
2571
2737
  matchAgainst: FieldReference2.optional()
2572
2738
  }).optional().default({
2573
2739
  boost: 1
2574
2740
  })
2575
2741
  });
2576
2742
  var FuzzyMatcher = Matcher.extend({
2577
- type: z23.literal("fuzzy"),
2578
- options: z23.object({
2743
+ type: z24.literal("fuzzy"),
2744
+ options: z24.object({
2579
2745
  /**
2580
2746
  * Names of length 3 or less characters = 0 edits allowed
2581
2747
  * Names of length 4 - 6 characters = 1 edit allowed
2582
2748
  * Names of length >7 characters = 2 edits allowed
2583
2749
  */
2584
- fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2585
- 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),
2586
2752
  matchAgainst: FieldReference2.optional()
2587
2753
  }).optional().default({
2588
2754
  fuzziness: "AUTO:4,7",
@@ -2590,48 +2756,48 @@ var FuzzyMatcher = Matcher.extend({
2590
2756
  })
2591
2757
  });
2592
2758
  var StrictMatcher = Matcher.extend({
2593
- type: z23.literal("strict"),
2594
- options: z23.object({
2595
- boost: z23.number().optional().default(1),
2759
+ type: z24.literal("strict"),
2760
+ options: z24.object({
2761
+ boost: z24.number().optional().default(1),
2596
2762
  /**
2597
2763
  * The constant value to be present in the field for both records
2598
2764
  */
2599
- value: z23.string().optional(),
2765
+ value: z24.string().optional(),
2600
2766
  matchAgainst: FieldReference2.optional()
2601
2767
  }).optional().default({
2602
2768
  boost: 1
2603
2769
  })
2604
2770
  });
2605
2771
  var DateRangeMatcher = Matcher.extend({
2606
- type: z23.literal("dateRange"),
2607
- options: z23.object({
2772
+ type: z24.literal("dateRange"),
2773
+ options: z24.object({
2608
2774
  /**
2609
2775
  * The distance pivot in days. Distance from the origin (the value of
2610
2776
  * fieldId) at which relevance scores receive half of the boost value
2611
2777
  */
2612
- pivot: z23.number().optional(),
2613
- days: z23.number(),
2614
- boost: z23.number().optional().default(1),
2778
+ pivot: z24.number().optional(),
2779
+ days: z24.number(),
2780
+ boost: z24.number().optional().default(1),
2615
2781
  matchAgainst: FieldReference2.optional()
2616
2782
  })
2617
2783
  });
2618
- var Not = z23.object({
2619
- type: z23.literal("not"),
2784
+ var Not = z24.object({
2785
+ type: z24.literal("not"),
2620
2786
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2621
- clause: z23.lazy(() => Clause)
2787
+ clause: z24.lazy(() => Clause)
2622
2788
  });
2623
- var And = z23.object({
2624
- type: z23.literal("and"),
2789
+ var And = z24.object({
2790
+ type: z24.literal("and"),
2625
2791
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2626
- clauses: z23.lazy(() => Clause.array())
2792
+ clauses: z24.lazy(() => Clause.array())
2627
2793
  });
2628
- var Or = z23.object({
2629
- type: z23.literal("or"),
2794
+ var Or = z24.object({
2795
+ type: z24.literal("or"),
2630
2796
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2631
- clauses: z23.lazy(() => Clause.array())
2797
+ clauses: z24.lazy(() => Clause.array())
2632
2798
  });
2633
- var Clause = z23.lazy(
2634
- () => z23.discriminatedUnion("type", [
2799
+ var Clause = z24.lazy(
2800
+ () => z24.discriminatedUnion("type", [
2635
2801
  Not,
2636
2802
  And,
2637
2803
  Or,
@@ -2642,8 +2808,8 @@ var Clause = z23.lazy(
2642
2808
  ).meta({
2643
2809
  id: "Clause"
2644
2810
  });
2645
- var DeduplicationConfig = z23.object({
2646
- id: z23.string(),
2811
+ var DeduplicationConfig = z24.object({
2812
+ id: z24.string(),
2647
2813
  label: TranslationConfig,
2648
2814
  query: Clause
2649
2815
  }).meta({
@@ -2652,15 +2818,15 @@ var DeduplicationConfig = z23.object({
2652
2818
  });
2653
2819
 
2654
2820
  // ../commons/src/events/ActionConfig.ts
2655
- var DeclarationReviewConfig = z24.object({
2821
+ var DeclarationReviewConfig = z25.object({
2656
2822
  title: TranslationConfig.describe("Title of the review page"),
2657
- 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.")
2658
2824
  }).describe(
2659
2825
  "Configuration of the declaration review page for collecting event-related metadata."
2660
2826
  );
2661
- var ActionConfigBase = z24.object({
2827
+ var ActionConfigBase = z25.object({
2662
2828
  label: TranslationConfig.describe("Human readable description of the action"),
2663
- 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."),
2664
2830
  supportingCopy: TranslationConfig.optional().describe(
2665
2831
  "Text displayed on the confirmation dialog"
2666
2832
  ),
@@ -2671,31 +2837,87 @@ var ActionConfigBase = z24.object({
2671
2837
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
2672
2838
  * for EventConfig.d.ts.
2673
2839
  */
2674
- icon: z24.string().describe("Icon representing the action").optional(),
2675
- 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.")
2676
2842
  });
2677
2843
  var DeclarationActionBase = ActionConfigBase.extend({
2678
2844
  deduplication: DeduplicationConfig.optional()
2679
2845
  });
2846
+ var actionConfirmationForm = z25.array(FieldConfig).optional().describe(
2847
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2848
+ );
2680
2849
  var ReadActionConfig = ActionConfigBase.extend(
2681
- z24.object({
2682
- type: z24.literal(ActionType.READ),
2850
+ z25.object({
2851
+ type: z25.literal(ActionType.READ),
2683
2852
  review: DeclarationReviewConfig.describe(
2684
2853
  "Configuration of the review page for read-only view."
2685
2854
  ),
2686
- 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.")
2687
2856
  }).shape
2688
2857
  );
2689
- var DeclareConfig = DeclarationActionBase.extend(
2690
- z24.object({
2691
- type: z24.literal(ActionType.DECLARE),
2692
- review: DeclarationReviewConfig.describe(
2693
- "Configuration of the review page fields."
2858
+ var NotifyConfig = ActionConfigBase.extend(
2859
+ z25.object({
2860
+ type: z25.literal(ActionType.NOTIFY),
2861
+ form: actionConfirmationForm
2862
+ }).shape
2863
+ );
2864
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2865
+ z25.object({
2866
+ type: z25.literal(ActionType.DUPLICATE_DETECTED),
2867
+ label: z25.never().optional().describe(
2868
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2694
2869
  ),
2695
- dialogCopy: z24.object({
2696
- notify: TranslationConfig.describe(
2697
- "Confirmation text for the notify action"
2698
- ),
2870
+ supportingCopy: z25.never().optional(),
2871
+ icon: z25.never().optional().describe(
2872
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2873
+ ),
2874
+ conditionals: z25.never().optional().describe(
2875
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2876
+ )
2877
+ }).shape
2878
+ );
2879
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2880
+ z25.object({
2881
+ type: z25.literal(ActionType.MARK_AS_DUPLICATE)
2882
+ }).shape
2883
+ );
2884
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2885
+ z25.object({
2886
+ type: z25.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2887
+ }).shape
2888
+ );
2889
+ var AssignConfig = ActionConfigBase.extend(
2890
+ z25.object({
2891
+ type: z25.literal(ActionType.ASSIGN),
2892
+ flags: z25.never().optional().describe(
2893
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2894
+ )
2895
+ }).shape
2896
+ );
2897
+ var UnassignConfig = ActionConfigBase.extend(
2898
+ z25.object({
2899
+ type: z25.literal(ActionType.UNASSIGN),
2900
+ flags: z25.never().optional().describe(
2901
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2902
+ )
2903
+ }).shape
2904
+ );
2905
+ var DeleteConfig = ActionConfigBase.extend(
2906
+ z25.object({
2907
+ type: z25.literal(ActionType.DELETE)
2908
+ }).shape
2909
+ );
2910
+ var DeclareConfig = DeclarationActionBase.extend(
2911
+ z25.object({
2912
+ type: z25.literal(ActionType.DECLARE),
2913
+ review: DeclarationReviewConfig.describe(
2914
+ "Configuration of the review page fields."
2915
+ ),
2916
+ form: actionConfirmationForm,
2917
+ dialogCopy: z25.object({
2918
+ notify: TranslationConfig.describe(
2919
+ "Confirmation text for the notify action"
2920
+ ),
2699
2921
  declare: TranslationConfig.describe(
2700
2922
  "Confirmation text for the declare action"
2701
2923
  ),
@@ -2706,14 +2928,20 @@ var DeclareConfig = DeclarationActionBase.extend(
2706
2928
  }).shape
2707
2929
  );
2708
2930
  var ArchiveConfig = ActionConfigBase.extend(
2709
- z24.object({
2710
- type: z24.literal(ActionType.ARCHIVE)
2931
+ z25.object({
2932
+ type: z25.literal(ActionType.ARCHIVE),
2933
+ form: actionConfirmationForm
2934
+ }).shape
2935
+ );
2936
+ var UnarchiveConfig = ActionConfigBase.extend(
2937
+ z25.object({
2938
+ type: z25.literal(ActionType.UNARCHIVE)
2711
2939
  }).shape
2712
2940
  );
2713
2941
  var EditActionConfig = ActionConfigBase.extend(
2714
- z24.object({
2715
- type: z24.literal(ActionType.EDIT),
2716
- dialogCopy: z24.object({
2942
+ z25.object({
2943
+ type: z25.literal(ActionType.EDIT),
2944
+ dialogCopy: z25.object({
2717
2945
  notify: TranslationConfig.describe(
2718
2946
  "Confirmation text for the notify with edits action"
2719
2947
  ),
@@ -2727,41 +2955,53 @@ var EditActionConfig = ActionConfigBase.extend(
2727
2955
  }).shape
2728
2956
  );
2729
2957
  var RejectConfig = ActionConfigBase.extend(
2730
- z24.object({
2731
- type: z24.literal(ActionType.REJECT)
2958
+ z25.object({
2959
+ type: z25.literal(ActionType.REJECT),
2960
+ form: actionConfirmationForm
2732
2961
  }).shape
2733
2962
  );
2734
2963
  var RegisterConfig = DeclarationActionBase.extend(
2735
- z24.object({
2736
- type: z24.literal(ActionType.REGISTER)
2964
+ z25.object({
2965
+ type: z25.literal(ActionType.REGISTER),
2966
+ form: actionConfirmationForm
2737
2967
  }).shape
2738
2968
  );
2739
2969
  var PrintCertificateActionConfig = ActionConfigBase.extend(
2740
- z24.object({
2741
- type: z24.literal(ActionType.PRINT_CERTIFICATE),
2970
+ z25.object({
2971
+ type: z25.literal(ActionType.PRINT_CERTIFICATE),
2742
2972
  printForm: ActionFormConfig
2743
2973
  }).shape
2744
2974
  );
2745
2975
  var RequestCorrectionConfig = ActionConfigBase.extend(
2746
- z24.object({
2747
- type: z24.literal(ActionType.REQUEST_CORRECTION),
2976
+ z25.object({
2977
+ type: z25.literal(ActionType.REQUEST_CORRECTION),
2748
2978
  correctionForm: ActionFormConfig
2749
2979
  }).shape
2750
2980
  );
2751
- var CustomActionConfig = ActionConfigBase.merge(
2752
- z24.object({
2753
- type: z24.literal(ActionType.CUSTOM),
2754
- customActionType: z24.string().describe("Type identifier of the custom action."),
2981
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2982
+ z25.object({
2983
+ type: z25.literal(ActionType.APPROVE_CORRECTION)
2984
+ }).shape
2985
+ );
2986
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2987
+ z25.object({
2988
+ type: z25.literal(ActionType.REJECT_CORRECTION)
2989
+ }).shape
2990
+ );
2991
+ var CustomActionConfig = ActionConfigBase.extend(
2992
+ z25.object({
2993
+ type: z25.literal(ActionType.CUSTOM),
2994
+ customActionType: z25.string().describe("Type identifier of the custom action."),
2755
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. */
2756
- form: z24.array(FieldConfig).describe(
2996
+ form: z25.array(FieldConfig).describe(
2757
2997
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
2758
2998
  ),
2759
2999
  auditHistoryLabel: TranslationConfig.describe(
2760
3000
  'The label to show in audit history for this action. For example "Approved".'
2761
3001
  )
2762
- })
3002
+ }).shape
2763
3003
  );
2764
- var ActionConfig = z24.discriminatedUnion("type", [
3004
+ var ActionConfig = z25.discriminatedUnion("type", [
2765
3005
  /*
2766
3006
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
2767
3007
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -2770,9 +3010,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
2770
3010
  id: "ReadActionConfig",
2771
3011
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2772
3012
  }),
3013
+ AssignConfig.meta({
3014
+ id: "AssignActionConfig",
3015
+ description: "Configuration for assigning a record to the current user."
3016
+ }),
3017
+ UnassignConfig.meta({
3018
+ id: "UnassignActionConfig",
3019
+ description: "Configuration for unassigning a record from its current assignee."
3020
+ }),
3021
+ DeleteConfig.meta({
3022
+ id: "DeleteActionConfig",
3023
+ description: "Configuration for deleting a draft record."
3024
+ }),
3025
+ NotifyConfig.meta({
3026
+ id: "NotifyActionConfig",
3027
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3028
+ }),
2773
3029
  DeclareConfig.meta({
2774
3030
  id: "DeclareActionConfig",
2775
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
3031
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3032
+ }),
3033
+ DuplicateDetectedConfig.meta({
3034
+ id: "DuplicateDetectedActionConfig",
3035
+ description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3036
+ }),
3037
+ MarkAsDuplicateConfig.meta({
3038
+ id: "MarkAsDuplicateActionConfig",
3039
+ description: "Configuration for marking a record as a duplicate."
3040
+ }),
3041
+ MarkAsNotDuplicateConfig.meta({
3042
+ id: "MarkAsNotDuplicateActionConfig",
3043
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2776
3044
  }),
2777
3045
  RejectConfig.meta({
2778
3046
  id: "RejectActionConfig",
@@ -2790,6 +3058,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2790
3058
  id: "RequestCorrectionActionConfig",
2791
3059
  description: "Configuration for requesting a correction on a registered record."
2792
3060
  }),
3061
+ ApproveCorrectionConfig.meta({
3062
+ id: "ApproveCorrectionActionConfig",
3063
+ description: "Configuration for approving a requested correction."
3064
+ }),
3065
+ RejectCorrectionConfig.meta({
3066
+ id: "RejectCorrectionActionConfig",
3067
+ description: "Configuration for rejecting a requested correction."
3068
+ }),
2793
3069
  EditActionConfig.meta({
2794
3070
  id: "EditActionConfig",
2795
3071
  description: "Configuration for editing a record before registration."
@@ -2798,6 +3074,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2798
3074
  id: "ArchiveActionConfig",
2799
3075
  description: "Configuration for archiving a record."
2800
3076
  }),
3077
+ UnarchiveConfig.meta({
3078
+ id: "UnarchiveActionConfig",
3079
+ description: "Configuration for unarchiving a record."
3080
+ }),
2801
3081
  CustomActionConfig.meta({
2802
3082
  id: "CustomActionConfig",
2803
3083
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -2808,89 +3088,225 @@ var ActionConfig = z24.discriminatedUnion("type", [
2808
3088
  var actionConfigTypes = new Set(
2809
3089
  ActionConfig.options.map((opt) => opt.shape.type.value)
2810
3090
  );
2811
- var DeclarationActionConfig = z24.discriminatedUnion("type", [
3091
+ var DeclarationActionConfig = z25.discriminatedUnion("type", [
2812
3092
  DeclareConfig,
2813
3093
  RegisterConfig
2814
3094
  ]);
2815
3095
 
2816
3096
  // ../commons/src/events/offline/CertificateConfig.ts
2817
- var z25 = __toESM(require("zod/v4"));
2818
- var FontFamily = z25.object({
2819
- normal: z25.string(),
2820
- bold: z25.string(),
2821
- italics: z25.string(),
2822
- bolditalics: z25.string()
2823
- });
2824
- var CertificateConfig = z25.object({
2825
- id: z25.string(),
2826
- event: z25.string(),
2827
- 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(),
2828
3108
  label: TranslationConfig,
2829
- isDefault: z25.boolean(),
2830
- fee: z25.object({
2831
- onTime: z25.number(),
2832
- late: z25.number(),
2833
- delayed: z25.number()
3109
+ isDefault: z26.boolean(),
3110
+ fee: z26.object({
3111
+ onTime: z26.number(),
3112
+ late: z26.number(),
3113
+ delayed: z26.number()
2834
3114
  }),
2835
- svgUrl: z25.string(),
2836
- fonts: z25.record(z25.string(), FontFamily).optional(),
2837
- conditionals: z25.array(ShowConditional).optional()
3115
+ svgUrl: z26.string(),
3116
+ fonts: z26.record(z26.string(), FontFamily).optional(),
3117
+ conditionals: z26.array(ShowConditional).optional()
2838
3118
  });
2839
3119
  var CertificateTemplateConfig = CertificateConfig.extend({
2840
- hash: z25.string().optional(),
2841
- svg: z25.string()
3120
+ hash: z26.string().optional(),
3121
+ svg: z26.string()
2842
3122
  });
2843
3123
 
2844
3124
  // ../commons/src/events/offline/LanguageConfig.ts
2845
- var z26 = __toESM(require("zod/v4"));
2846
- var LanguageConfig = z26.object({
2847
- lang: z26.string(),
3125
+ var z27 = __toESM(require("zod/v4"));
3126
+ var LanguageConfig = z27.object({
3127
+ lang: z27.string(),
2848
3128
  /**
2849
3129
  * client.csv contents
2850
3130
  */
2851
- messages: z26.record(z26.string(), z26.string())
3131
+ messages: z27.record(z27.string(), z27.string())
2852
3132
  });
2853
3133
 
2854
3134
  // ../commons/src/events/EventConfig.ts
2855
- var z33 = __toESM(require("zod/v4"));
3135
+ var z35 = __toESM(require("zod/v4"));
2856
3136
 
2857
3137
  // ../commons/src/events/SummaryConfig.ts
2858
- var z27 = __toESM(require("zod/v4"));
2859
- 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({
2860
3273
  emptyValueMessage: TranslationConfig.optional().describe(
2861
3274
  "Default message displayed when the field value is empty."
2862
3275
  ),
2863
- conditionals: z27.array(ShowConditional).default([]).optional()
3276
+ conditionals: z29.array(ShowConditional).default([]).optional()
2864
3277
  });
2865
3278
  var ReferenceField = BaseField2.extend({
2866
- fieldId: z27.string(),
3279
+ fieldId: z29.string(),
2867
3280
  label: TranslationConfig.optional().describe(
2868
3281
  "Overrides the default label from the referenced field when provided."
2869
3282
  )
2870
3283
  }).describe("Field referencing existing event data by field ID.");
2871
3284
  var Field = BaseField2.extend({
2872
- id: z27.string().describe("Identifier of the summary field."),
3285
+ id: z29.string().describe("Identifier of the summary field."),
2873
3286
  value: TranslationConfig.describe(
2874
3287
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
2875
3288
  ),
2876
3289
  label: TranslationConfig
2877
3290
  }).describe("Custom field defined for the summary view.");
2878
- var SummaryConfig = z27.object({
2879
- 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.")
2880
3296
  }).meta({
2881
3297
  id: "SummaryConfig",
2882
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."
2883
3299
  });
2884
3300
 
2885
3301
  // ../commons/src/events/AdvancedSearchConfig.ts
2886
- var z28 = __toESM(require("zod/v4"));
2887
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
2888
- var BaseField3 = z28.object({
2889
- 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({
2890
3306
  type: MatchType.describe(
2891
3307
  "Determines the search type of field. How to match value."
2892
3308
  ),
2893
- searchFields: z28.array(z28.string()).optional().describe(
3309
+ searchFields: z30.array(z30.string()).optional().describe(
2894
3310
  `
2895
3311
  Defines multiple form fields that should be searched when this field has a value.
2896
3312
  All specified fields will be combined using OR logic.
@@ -2900,7 +3316,7 @@ var BaseField3 = z28.object({
2900
3316
  `
2901
3317
  )
2902
3318
  }),
2903
- type: z28.nativeEnum(FieldType).optional().describe(
3319
+ type: z30.nativeEnum(FieldType).optional().describe(
2904
3320
  `
2905
3321
  Explicitly specify the field type for searchFields.
2906
3322
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -2914,7 +3330,7 @@ var BaseField3 = z28.object({
2914
3330
  This is required when searchFields is defined.
2915
3331
  `
2916
3332
  ),
2917
- options: z28.array(SelectOption).optional(),
3333
+ options: z30.array(SelectOption).optional(),
2918
3334
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
2919
3335
  `
2920
3336
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -2935,7 +3351,7 @@ var BaseField3 = z28.object({
2935
3351
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
2936
3352
  `
2937
3353
  ),
2938
- conditionals: z28.array(FieldConditional).optional().describe(
3354
+ conditionals: z30.array(FieldConditional).optional().describe(
2939
3355
  `
2940
3356
  In advanced search, we sometimes need to override the default field visibility conditionals.
2941
3357
 
@@ -2949,23 +3365,23 @@ var BaseField3 = z28.object({
2949
3365
  are always rendered in the advanced search form.
2950
3366
  `
2951
3367
  ),
2952
- validations: z28.array(ValidationConfig).optional().describe(
3368
+ validations: z30.array(ValidationConfig).optional().describe(
2953
3369
  `Option for overriding the field validations specifically for advanced search form.`
2954
3370
  ),
2955
3371
  allowedLocations: JurisdictionReference.optional().describe(
2956
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.`
2957
3373
  )
2958
3374
  });
2959
- var SearchQueryParams = z28.object({
2960
- eventType: z28.string().optional().describe(
3375
+ var SearchQueryParams = z30.object({
3376
+ eventType: z30.string().optional().describe(
2961
3377
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
2962
3378
  )
2963
3379
  }).catchall(FieldValue);
2964
3380
  var FieldConfigSchema = BaseField3.extend({
2965
- fieldId: z28.string(),
2966
- fieldType: z28.literal("field")
3381
+ fieldId: z30.string(),
3382
+ fieldType: z30.literal("field")
2967
3383
  });
2968
- var EventFieldIdInput = z28.enum([
3384
+ var EventFieldIdInput = z30.enum([
2969
3385
  "trackingId",
2970
3386
  "status",
2971
3387
  "legalStatuses.REGISTERED.acceptedAt",
@@ -2974,7 +3390,7 @@ var EventFieldIdInput = z28.enum([
2974
3390
  "updatedAt"
2975
3391
  ]);
2976
3392
  var METADATA_FIELD_PREFIX = "event.";
2977
- var EventFieldId = z28.enum([
3393
+ var EventFieldId = z30.enum([
2978
3394
  `${METADATA_FIELD_PREFIX}trackingId`,
2979
3395
  `${METADATA_FIELD_PREFIX}status`,
2980
3396
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -2984,195 +3400,60 @@ var EventFieldId = z28.enum([
2984
3400
  ]);
2985
3401
  var EventFieldConfigSchema = BaseField3.extend({
2986
3402
  fieldId: EventFieldId,
2987
- fieldType: z28.literal("event")
3403
+ fieldType: z30.literal("event")
2988
3404
  });
2989
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3405
+ var AdvancedSearchField = z30.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
2990
3406
  if (data.config.searchFields && data.config.searchFields.length > 0) {
2991
3407
  if (!data.label) {
2992
3408
  ctx.addIssue({
2993
- code: z28.ZodIssueCode.custom,
3409
+ code: z30.ZodIssueCode.custom,
2994
3410
  message: "label is required when config.searchFields is defined.",
2995
3411
  path: ["label"]
2996
- });
2997
- }
2998
- if (!data.type) {
2999
- ctx.addIssue({
3000
- code: z28.ZodIssueCode.custom,
3001
- message: "type is required when config.searchFields is defined.",
3002
- path: ["type"]
3003
- });
3004
- }
3005
- }
3006
- });
3007
- var AdvancedSearchConfig = z28.object({
3008
- title: TranslationConfig.describe("Advanced search tab title"),
3009
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3010
- }).meta({
3011
- id: "AdvancedSearchConfig",
3012
- 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()`)."
3013
- });
3014
-
3015
- // ../commons/src/events/utils.ts
3016
- var import_lodash = require("lodash");
3017
-
3018
- // ../commons/src/conditionals/validate.ts
3019
- var import__ = __toESM(require("ajv/dist/2019"));
3020
- var import_ajv_formats = __toESM(require("ajv-formats"));
3021
- var z31 = __toESM(require("zod/v4"));
3022
- var import_date_fns = require("date-fns");
3023
-
3024
- // ../commons/src/events/FieldTypeMapping.ts
3025
- var z30 = __toESM(require("zod/v4"));
3026
-
3027
- // ../commons/src/events/DynamicFieldValue.ts
3028
- var z29 = __toESM(require("zod/v4"));
3029
-
3030
- // ../commons/src/conditionals/validate.ts
3031
- var ajv = new import__.default({
3032
- $data: true,
3033
- allowUnionTypes: true,
3034
- strict: false
3035
- // Allow minContains and other newer features
3036
- });
3037
- var DataContext = z31.object({
3038
- rootData: z31.object({
3039
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3040
- })
3041
- });
3042
- function resolveDataPath(rootData, dataPath, instancePath) {
3043
- const pathParts = dataPath.split("/");
3044
- const levels = parseInt(pathParts[0], 10);
3045
- const referencePath = pathParts.slice(1);
3046
- const instanceParts = instancePath.split("/").filter(Boolean);
3047
- const traversedParts = instanceParts.slice(0, -levels);
3048
- let current = rootData;
3049
- for (const part of traversedParts) {
3050
- if (current === null || current === void 0) {
3051
- return void 0;
3052
- }
3053
- current = current[part];
3054
- }
3055
- for (const part of referencePath) {
3056
- if (current === null || current === void 0) {
3057
- return void 0;
3058
- }
3059
- current = current[part];
3060
- }
3061
- return current;
3062
- }
3063
- function todayISO() {
3064
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3065
- }
3066
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3067
- function compileClientFunction(code) {
3068
- let fn = compiledFunctionCache.get(code);
3069
- if (!fn) {
3070
- fn = new Function(`return (${code})`)();
3071
- compiledFunctionCache.set(code, fn);
3072
- }
3073
- return fn;
3074
- }
3075
- (0, import_ajv_formats.default)(ajv);
3076
- function buildClientFunctionContext(input) {
3077
- return {
3078
- $form: input.form,
3079
- $now: todayISO(),
3080
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3081
- $online: isOnline(),
3082
- $user: input.validatorContext?.user,
3083
- $event: input.validatorContext?.event,
3084
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3085
- user: input.systemVariables?.user,
3086
- $window: input.systemVariables?.$window,
3087
- locations: input.locations,
3088
- adminLevelIds: input.adminLevelIds
3089
- };
3090
- }
3091
- function runClientFunction(code, data, context) {
3092
- return compileClientFunction(code)(data, context);
3093
- }
3094
- ajv.addKeyword({
3095
- keyword: "daysFromDate",
3096
- type: "string",
3097
- schemaType: "object",
3098
- $data: true,
3099
- errors: true,
3100
- validate(schema, data, _2, dataContext) {
3101
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3102
- throw new Error("Validation context must contain $now");
3103
- }
3104
- const { days, clause } = schema;
3105
- if (typeof data !== "string") {
3106
- return false;
3107
- }
3108
- const date = new Date(data);
3109
- if (isNaN(date.getTime())) {
3110
- return false;
3111
- }
3112
- let referenceDate = schema.referenceDate;
3113
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3114
- referenceDate = resolveDataPath(
3115
- dataContext.rootData,
3116
- referenceDate.$data,
3117
- dataContext.instancePath
3118
- );
3119
- }
3120
- if (!referenceDate) {
3121
- referenceDate = dataContext.rootData.$now;
3122
- }
3123
- const baseDate = new Date(referenceDate);
3124
- if (isNaN(baseDate.getTime())) {
3125
- return false;
3126
- }
3127
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3128
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3129
- }
3130
- });
3131
- ajv.addKeyword({
3132
- keyword: "isLeafLevelLocation",
3133
- type: "string",
3134
- schemaType: "boolean",
3135
- $data: true,
3136
- errors: true,
3137
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3138
- validate(_schema, data, _2, dataContext) {
3139
- const locationIdInput = data;
3140
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3141
- return locations.some((location) => location.id === locationIdInput);
3142
- }
3143
- });
3144
- ajv.addKeyword({
3145
- keyword: "customClientValidator",
3146
- schemaType: "object",
3147
- errors: true,
3148
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3149
- // `validate()` callers build root data via `buildClientFunctionContext`,
3150
- // so the cast holds.
3151
- validate(schema, data, _2, dataContext) {
3152
- return Boolean(
3153
- runClientFunction(
3154
- schema.code,
3155
- data,
3156
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3157
- )
3158
- );
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
+ }
3159
3421
  }
3160
3422
  });
3161
- function isOnline() {
3162
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3163
- return navigator.onLine;
3164
- }
3165
- return true;
3166
- }
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
+ });
3167
3430
 
3168
- // ../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
3169
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"));
3170
3451
  var _ = __toESM(require("lodash"));
3171
- var FullNameV1 = z32.array(
3172
- z32.object({
3173
- use: z32.string(),
3174
- family: z32.string(),
3175
- 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())
3176
3457
  })
3177
3458
  );
3178
3459
  function omitKeyDeep(obj, keyToRemove) {
@@ -3191,39 +3472,62 @@ function omitKeyDeep(obj, keyToRemove) {
3191
3472
  return newObj;
3192
3473
  }
3193
3474
 
3194
- // ../commons/src/events/utils.ts
3195
- var import_date_fns2 = require("date-fns");
3196
- function getDeclarationFields(configuration) {
3197
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3198
- }
3199
- var getActionAnnotationFields = (actionConfig) => {
3200
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3201
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3202
- }
3203
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3204
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3205
- }
3206
- if (actionConfig.type === ActionType.CUSTOM) {
3207
- return actionConfig.form;
3208
- }
3209
- if ("review" in actionConfig) {
3210
- return actionConfig.review.fields;
3211
- }
3212
- return [];
3213
- };
3214
- function getAllAnnotationFields(config) {
3215
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3216
- }
3217
- var findAllFields = (config) => {
3218
- return (0, import_lodash.flattenDeep)([
3219
- ...getDeclarationFields(config),
3220
- ...getAllAnnotationFields(config)
3221
- ]);
3222
- };
3223
- var EXCLUDED_ACTIONS = [
3224
- 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,
3225
3486
  ActionType.PRINT_CERTIFICATE,
3226
- 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
+ }
3227
3531
  ];
3228
3532
 
3229
3533
  // ../commons/src/conditionals/conditionals.ts
@@ -3432,6 +3736,33 @@ function defineComparison(field3, value, keyword) {
3432
3736
  required: [field3.$$field]
3433
3737
  });
3434
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
+ }
3435
3766
  function createFieldConditionals(fieldId) {
3436
3767
  const getDayRange = (field3, days, clause, referenceDate) => ({
3437
3768
  type: "object",
@@ -3833,6 +4164,176 @@ function createFieldConditionals(fieldId) {
3833
4164
  };
3834
4165
  }
3835
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
+
3836
4337
  // ../commons/src/events/eventConfigValidation.ts
3837
4338
  function validateAdvancedSearchConfig(event2, ctx) {
3838
4339
  const allFields = findAllFields(event2);
@@ -3915,9 +4416,9 @@ function validatePlaceOfEvent(event2, ctx) {
3915
4416
  }
3916
4417
  function validateActionFlags(event2, ctx) {
3917
4418
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3918
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4419
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
3919
4420
  const actionFlagIds = event2.actions.flatMap(
3920
- (action) => action.flags.map((flag) => flag.id)
4421
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
3921
4422
  );
3922
4423
  for (const actionFlagId of actionFlagIds) {
3923
4424
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -3953,11 +4454,11 @@ function validateActionOrder(event2, ctx) {
3953
4454
  }
3954
4455
 
3955
4456
  // ../commons/src/events/EventConfig.ts
3956
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4457
+ var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
3957
4458
  "Reference to a field defined in the event metadata, using the field id."
3958
4459
  );
3959
- var _EventConfigBase = z33.object({
3960
- id: z33.string().describe(
4460
+ var _EventConfigBase = z35.object({
4461
+ id: z35.string().describe(
3961
4462
  'Machine-readable identifier of the event (e.g. "birth", "death").'
3962
4463
  ),
3963
4464
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -3976,23 +4477,26 @@ var _EventConfigBase = z33.object({
3976
4477
  "Summary information displayed in the event overview."
3977
4478
  ),
3978
4479
  label: TranslationConfig.describe("Human-readable label for the event type."),
3979
- actions: z33.array(ActionConfig).describe(
4480
+ actions: z35.array(ActionConfig).describe(
3980
4481
  "Configuration of core and custom actions associated with the event."
3981
4482
  ),
3982
- actionOrder: z33.array(z33.string()).optional().describe(
4483
+ actionOrder: z35.array(z35.string()).optional().describe(
3983
4484
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
3984
4485
  ),
3985
4486
  declaration: DeclarationFormConfig.describe(
3986
4487
  "Configuration of the form used to gather event data."
3987
4488
  ),
3988
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4489
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
3989
4490
  "Configuration of fields available in the advanced search feature."
3990
4491
  ),
3991
- flags: z33.array(FlagConfig).optional().default([]).describe(
4492
+ flags: z35.array(FlagConfig).optional().default([]).describe(
3992
4493
  "Configuration of custom flags associated with the actions of this event type."
3993
4494
  ),
3994
- analytics: z33.boolean().optional().default(true).describe(
4495
+ analytics: z35.boolean().optional().default(true).describe(
3995
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.'
3996
4500
  )
3997
4501
  });
3998
4502
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4012,7 +4516,7 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
4012
4516
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
4013
4517
 
4014
4518
  // ../commons/src/events/WorkqueueConfig.ts
4015
- var z37 = __toESM(require("zod/v4"));
4519
+ var z38 = __toESM(require("zod/v4"));
4016
4520
 
4017
4521
  // ../commons/src/searchConfigs.ts
4018
4522
  function createSearchConfig(baseField) {
@@ -4209,21 +4713,31 @@ var event = Object.assign(eventFn, {
4209
4713
  return {
4210
4714
  $event: field3
4211
4715
  };
4212
- }
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)
4213
4727
  });
4214
4728
 
4215
4729
  // ../commons/src/events/WorkqueueColumnConfig.ts
4216
- var z34 = __toESM(require("zod/v4"));
4730
+ var z36 = __toESM(require("zod/v4"));
4217
4731
  var WorkqueueColumnKeysArray = [
4218
4732
  ...EventMetadataKeysArray,
4219
4733
  "title",
4220
4734
  "outbox"
4221
4735
  ];
4222
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4223
- var WorkqueueColumnValue = z34.object({
4736
+ var WorkqueueColumnKeys = z36.enum(WorkqueueColumnKeysArray);
4737
+ var WorkqueueColumnValue = z36.object({
4224
4738
  $event: WorkqueueColumnKeys
4225
4739
  });
4226
- var WorkqueueColumn = z34.object({
4740
+ var WorkqueueColumn = z36.object({
4227
4741
  label: TranslationConfig,
4228
4742
  value: WorkqueueColumnValue
4229
4743
  }).meta({
@@ -4237,164 +4751,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4237
4751
  }
4238
4752
 
4239
4753
  // ../commons/src/events/CountryConfigQueryInput.ts
4240
- var z35 = __toESM(require("zod/v4"));
4241
- var SerializableExact = z35.object({
4242
- type: z35.literal("exact"),
4243
- term: z35.union([z35.string(), SerializedUserField])
4244
- });
4245
- var SerializableWithin = z35.object({
4246
- type: z35.literal("within"),
4247
- location: z35.union([z35.string(), SerializedUserField])
4248
- });
4249
- var SerializedQueryExpression = z35.object({
4250
- eventType: z35.string(),
4251
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4252
- createdAt: z35.optional(DateCondition),
4253
- updatedAt: z35.optional(DateCondition),
4254
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4255
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4256
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4257
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4258
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4259
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4260
- createdAtLocation: z35.optional(
4261
- 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])
4262
4776
  ),
4263
- updatedAtLocation: z35.optional(
4264
- z35.union([SerializableWithin, SerializableExact])
4777
+ updatedAtLocation: z37.optional(
4778
+ z37.union([SerializableWithin, SerializableExact])
4265
4779
  ),
4266
- updatedByUserRole: z35.optional(SerializableExact),
4267
- assignedTo: z35.optional(SerializableExact),
4268
- createdBy: z35.optional(SerializableExact),
4780
+ updatedByUserRole: z37.optional(SerializableExact),
4781
+ assignedTo: z37.optional(SerializableExact),
4782
+ createdBy: z37.optional(SerializableExact),
4269
4783
  createdByUserType: ExactUserType,
4270
- updatedBy: z35.optional(SerializableExact),
4271
- trackingId: z35.optional(Exact),
4272
- flags: z35.optional(ContainsFlags),
4784
+ updatedBy: z37.optional(SerializableExact),
4785
+ trackingId: z37.optional(Exact),
4786
+ flags: z37.optional(ContainsFlags),
4273
4787
  data: QueryInput
4274
4788
  }).partial();
4275
- var Or2 = z35.object({
4276
- type: z35.literal("or"),
4277
- clauses: z35.array(SerializedQueryExpression)
4789
+ var Or2 = z37.object({
4790
+ type: z37.literal("or"),
4791
+ clauses: z37.array(SerializedQueryExpression)
4278
4792
  });
4279
- var And2 = z35.object({
4280
- type: z35.literal("and"),
4281
- clauses: z35.array(SerializedQueryExpression)
4793
+ var And2 = z37.object({
4794
+ type: z37.literal("and"),
4795
+ clauses: z37.array(SerializedQueryExpression)
4282
4796
  });
4283
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4284
- var CountryConfigQueryInputType = z35.union([
4797
+ var CountryConfigQueryType = z37.discriminatedUnion("type", [And2, Or2]);
4798
+ var CountryConfigQueryInputType = z37.union([
4285
4799
  SerializedQueryExpression,
4286
4800
  And2,
4287
4801
  Or2
4288
4802
  ]);
4289
4803
 
4290
- // ../commons/src/icons.ts
4291
- var z36 = __toESM(require("zod/v4"));
4292
- var AvailableIcons = z36.enum([
4293
- "Archived",
4294
- "Assigned",
4295
- "Briefcase",
4296
- "Certified",
4297
- "Close",
4298
- "Collapse",
4299
- "Draft",
4300
- "DuplicateYellow",
4301
- "Expand",
4302
- "ExternalValidate",
4303
- "FilledCheck",
4304
- "InReview",
4305
- "Offline",
4306
- "Registered",
4307
- "RequiresUpdates",
4308
- "Sent",
4309
- "Validated",
4310
- "WaitingApproval",
4311
- "ChartActivity",
4312
- "Activity",
4313
- "Archive",
4314
- "ArchiveTray",
4315
- "ArrowLeft",
4316
- "ArrowRight",
4317
- "Buildings",
4318
- "Circle",
4319
- "CaretDown",
4320
- "CaretLeft",
4321
- "CaretRight",
4322
- "ChartBar",
4323
- "ChartLine",
4324
- "ChatCircle",
4325
- "CheckSquare",
4326
- "Compass",
4327
- "Check",
4328
- "Copy",
4329
- "Database",
4330
- "DotsThreeVertical",
4331
- "ArrowCounterClockwise",
4332
- "MagnifyingGlassMinus",
4333
- "MagnifyingGlassPlus",
4334
- "Export",
4335
- "Eye",
4336
- "EyeSlash",
4337
- "Envelope",
4338
- "File",
4339
- "FileSearch",
4340
- "FileMinus",
4341
- "FilePlus",
4342
- "FileText",
4343
- "FileX",
4344
- "Handshake",
4345
- "Gear",
4346
- "GitBranch",
4347
- "IdentificationCard",
4348
- "List",
4349
- "ListBullets",
4350
- "Lock",
4351
- "MagnifyingGlass",
4352
- "MapPin",
4353
- "Medal",
4354
- "NotePencil",
4355
- "Paperclip",
4356
- "PaperPlaneTilt",
4357
- "Pen",
4358
- "PenNib",
4359
- "Pencil",
4360
- "PencilSimpleLine",
4361
- "Phone",
4362
- "Plus",
4363
- "Printer",
4364
- "SignOut",
4365
- "Stamp",
4366
- "Star",
4367
- "Target",
4368
- "TextT",
4369
- "Trash",
4370
- "UploadSimple",
4371
- "User",
4372
- "UserPlus",
4373
- "Users",
4374
- "WarningCircle",
4375
- "X",
4376
- "ChatText",
4377
- "CircleWavyCheck",
4378
- "CircleWavyQuestion",
4379
- "ArchiveBox",
4380
- "ArrowCircleDown",
4381
- "FileArrowUp",
4382
- "FileDotted",
4383
- "Files",
4384
- "PencilLine",
4385
- "PencilCircle",
4386
- "UserCircle",
4387
- "Clock",
4388
- "QrCode",
4389
- "Webcam",
4390
- "Sun",
4391
- "DeviceTabletCamera",
4392
- "Globe",
4393
- "Fingerprint",
4394
- "PushPin",
4395
- "Timer"
4396
- ]);
4397
-
4398
4804
  // ../commons/src/events/WorkqueueConfig.ts
4399
4805
  var mandatoryColumns = defineWorkqueuesColumns([
4400
4806
  {
@@ -4414,16 +4820,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
4414
4820
  value: event.field("updatedAt")
4415
4821
  }
4416
4822
  ]);
4417
- var WorkqueueConfig = z37.object({
4418
- 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."),
4419
4825
  name: TranslationConfig.describe(
4420
4826
  "Title of the workflow (both in navigation and on the page)"
4421
4827
  ),
4422
4828
  query: CountryConfigQueryType,
4423
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4829
+ action: z38.object({ type: WorkqueueActionType }).optional().describe(
4424
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."
4425
4831
  ),
4426
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4832
+ columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
4427
4833
  icon: AvailableIcons,
4428
4834
  emptyMessage: TranslationConfig.optional()
4429
4835
  }).describe("Configuration for workqueue.");
@@ -4437,10 +4843,10 @@ var WorkqueueConfigInput = WorkqueueConfig.extend({
4437
4843
  id: "WorkqueueConfig",
4438
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."
4439
4845
  });
4440
- var WorkqueueCountInput = z37.array(
4441
- z37.object({ slug: z37.string(), query: QueryType })
4846
+ var WorkqueueCountInput = z38.array(
4847
+ z38.object({ slug: z38.string(), query: QueryType })
4442
4848
  );
4443
- var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
4849
+ var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
4444
4850
 
4445
4851
  // ../commons/src/events/workqueueDefaultColumns.ts
4446
4852
  var defaultWorkqueueColumns = [
@@ -4463,21 +4869,21 @@ var defaultWorkqueueColumns = [
4463
4869
  ];
4464
4870
 
4465
4871
  // ../commons/src/events/Draft.ts
4466
- var z39 = __toESM(require("zod/v4"));
4872
+ var z40 = __toESM(require("zod/v4"));
4467
4873
 
4468
4874
  // ../commons/src/events/ActionInput.ts
4469
- var z38 = __toESM(require("zod/v4"));
4470
- var BaseActionInput = z38.object({
4875
+ var z39 = __toESM(require("zod/v4"));
4876
+ var BaseActionInput = z39.object({
4471
4877
  eventId: UUID,
4472
- transactionId: z38.string(),
4878
+ transactionId: z39.string(),
4473
4879
  declaration: ActionUpdate.default({}),
4474
4880
  annotation: ActionUpdate.optional(),
4475
4881
  originalActionId: UUID.optional(),
4476
4882
  // should not be part of base action.
4477
- keepAssignment: z38.boolean().optional(),
4478
- keepAssignmentIfAccepted: z38.boolean().optional(),
4479
- keepAssignmentIfRejected: z38.boolean().optional(),
4480
- 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(
4481
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."
4482
4888
  ),
4483
4889
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
@@ -4487,8 +4893,8 @@ var BaseActionInput = z38.object({
4487
4893
  )
4488
4894
  });
4489
4895
  var CreateActionInput = BaseActionInput.extend(
4490
- z38.object({
4491
- type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
4896
+ z39.object({
4897
+ type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
4492
4898
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4493
4899
  createdAtLocation: UUID.nullish().describe(
4494
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."
@@ -4496,14 +4902,14 @@ var CreateActionInput = BaseActionInput.extend(
4496
4902
  }).shape
4497
4903
  );
4498
4904
  var RegisterActionInput = BaseActionInput.extend(
4499
- z38.strictObject({
4500
- type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4501
- registrationNumber: z38.string().optional()
4905
+ z39.strictObject({
4906
+ type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4907
+ registrationNumber: z39.string().optional()
4502
4908
  }).shape
4503
4909
  );
4504
4910
  var NotifyActionInput = BaseActionInput.extend(
4505
- z38.object({
4506
- type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4911
+ z39.object({
4912
+ type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4507
4913
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4508
4914
  createdAtLocation: UUID.nullish().describe(
4509
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."
@@ -4519,101 +4925,107 @@ var NotifyActionInput = BaseActionInput.extend(
4519
4925
  }
4520
4926
  });
4521
4927
  var DeclareActionInput = BaseActionInput.extend(
4522
- z38.object({
4523
- type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4928
+ z39.object({
4929
+ type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4524
4930
  }).shape
4525
4931
  );
4526
4932
  var EditActionInput = BaseActionInput.extend(
4527
- z38.object({
4528
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4529
- content: z38.object({
4530
- comment: z38.string().describe("Comment for the edit action.").optional()
4531
- })
4933
+ z39.object({
4934
+ type: z39.literal(ActionType.EDIT).default(ActionType.EDIT)
4532
4935
  }).shape
4533
4936
  );
4534
4937
  var PrintCertificateActionInput = BaseActionInput.extend(
4535
- z38.object({
4536
- type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4938
+ z39.object({
4939
+ type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4537
4940
  content: PrintContent.optional()
4538
4941
  }).shape
4539
4942
  );
4540
4943
  var RejectDeclarationActionInput = BaseActionInput.extend(
4541
- z38.object({
4542
- type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
4944
+ z39.object({
4945
+ type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
4543
4946
  content: ReasonContent
4544
4947
  }).shape
4545
4948
  );
4546
4949
  var DuplicateDetectedActionInput = BaseActionInput.extend(
4547
- z38.object({
4548
- type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4549
- content: z38.object({
4550
- 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)
4551
4954
  })
4552
4955
  }).shape
4553
4956
  );
4554
4957
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
4555
- z38.object({
4556
- type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4557
- content: z38.object({
4958
+ z39.object({
4959
+ type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4960
+ content: z39.object({
4558
4961
  duplicateOf: UUID
4559
4962
  }).optional()
4560
4963
  }).shape
4561
4964
  );
4562
4965
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
4563
- z38.object({
4564
- 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)
4565
4968
  }).shape
4566
4969
  );
4567
4970
  var ArchiveActionInput = BaseActionInput.extend(
4568
- z38.object({
4569
- type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4570
- 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()
4978
+ }).shape
4979
+ );
4980
+ var UnarchiveActionInput = BaseActionInput.extend(
4981
+ z39.object({
4982
+ type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4571
4983
  }).shape
4572
4984
  );
4573
4985
  var AssignActionInput = BaseActionInput.extend(
4574
- z38.object({
4575
- type: z38.literal(ActionType.ASSIGN),
4576
- assignedTo: z38.string()
4986
+ z39.object({
4987
+ type: z39.literal(ActionType.ASSIGN),
4988
+ assignedTo: z39.string()
4577
4989
  }).shape
4578
4990
  );
4579
4991
  var UnassignActionInput = BaseActionInput.extend(
4580
- z38.object({
4581
- type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4582
- 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)
4583
4995
  }).shape
4584
4996
  );
4585
4997
  var RequestCorrectionActionInput = BaseActionInput.extend(
4586
- z38.object({
4587
- type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4998
+ z39.object({
4999
+ type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4588
5000
  }).shape
4589
5001
  );
4590
5002
  var RejectCorrectionActionInput = BaseActionInput.extend(
4591
- z38.object({
4592
- requestId: z38.string(),
4593
- 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),
4594
5006
  content: ReasonContent
4595
5007
  }).shape
4596
5008
  );
4597
5009
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4598
- z38.object({
4599
- requestId: z38.string(),
4600
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4601
- 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()
4602
5014
  }).shape
4603
5015
  );
4604
5016
  var ReadActionInput = BaseActionInput.extend(
4605
- z38.object({
4606
- type: z38.literal(ActionType.READ).default(ActionType.READ)
5017
+ z39.object({
5018
+ type: z39.literal(ActionType.READ).default(ActionType.READ)
4607
5019
  }).shape
4608
5020
  );
4609
- var DeleteActionInput = z38.object({ eventId: UUID });
5021
+ var DeleteActionInput = z39.object({ eventId: UUID });
4610
5022
  var CustomActionInput = BaseActionInput.extend(
4611
- z38.object({
4612
- type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
4613
- 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.")
4614
5026
  }).shape
4615
5027
  );
4616
- var ActionInput = z38.discriminatedUnion("type", [
5028
+ var ActionInput = z39.discriminatedUnion("type", [
4617
5029
  CreateActionInput.meta({ id: "CreateActionInput" }),
4618
5030
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
4619
5031
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -4631,6 +5043,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4631
5043
  id: "MarkNotDuplicateActionInput"
4632
5044
  }),
4633
5045
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
5046
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4634
5047
  AssignActionInput.meta({ id: "AssignActionInput" }),
4635
5048
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4636
5049
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4649,11 +5062,11 @@ var ActionInput = z38.discriminatedUnion("type", [
4649
5062
  });
4650
5063
 
4651
5064
  // ../commons/src/events/Draft.ts
4652
- var Draft = z39.object({
5065
+ var Draft = z40.object({
4653
5066
  id: UUID,
4654
5067
  eventId: UUID,
4655
- transactionId: z39.string(),
4656
- createdAt: z39.string().datetime(),
5068
+ transactionId: z40.string(),
5069
+ createdAt: z40.string().datetime(),
4657
5070
  action: ActionBase.extend({
4658
5071
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
4659
5072
  }).omit({ id: true, createdAtLocation: true })
@@ -4662,7 +5075,7 @@ var Draft = z39.object({
4662
5075
  );
4663
5076
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4664
5077
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
4665
- status: z39.enum([
5078
+ status: z40.enum([
4666
5079
  ActionStatus.Requested,
4667
5080
  ActionStatus.Accepted,
4668
5081
  ActionStatus.Rejected
@@ -4670,93 +5083,33 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4670
5083
  });
4671
5084
 
4672
5085
  // ../commons/src/events/EventInput.ts
4673
- var z40 = __toESM(require("zod/v4"));
4674
- var import_uuid10 = require("uuid");
4675
- var EventInput = z40.object({
4676
- transactionId: z40.string(),
4677
- 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(),
4678
5091
  createdAtLocation: UUID.nullish().describe(
4679
5092
  "Location where the event occurred. Required for system users."
4680
5093
  )
4681
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5094
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4682
5095
 
4683
5096
  // ../commons/src/events/EventDocument.ts
4684
- var z41 = __toESM(require("zod/v4"));
4685
- var EventDocument = z41.object({
5097
+ var z42 = __toESM(require("zod/v4"));
5098
+ var EventDocument = z42.object({
4686
5099
  id: UUID.describe("Unique identifier of the event."),
4687
- type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
4688
- createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
4689
- 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(
4690
5103
  "Timestamp of the last update, excluding changes from actions."
4691
5104
  ),
4692
- actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
4693
- trackingId: z41.string().describe(
5105
+ actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
5106
+ trackingId: z42.string().describe(
4694
5107
  "System-generated tracking identifier used to look up the event."
4695
5108
  )
4696
5109
  }).meta({ id: "EventDocument" });
4697
-
4698
- // ../commons/src/events/state/index.ts
4699
- var import_lodash4 = require("lodash");
4700
-
4701
- // ../commons/src/events/state/utils.ts
4702
- var import_lodash2 = require("lodash");
4703
- var updateActions = ActionTypes.extract([
4704
- ActionType.CREATE,
4705
- ActionType.NOTIFY,
4706
- ActionType.EDIT,
4707
- ActionType.DECLARE,
4708
- ActionType.REGISTER,
4709
- ActionType.REJECT,
4710
- ActionType.ARCHIVE,
4711
- ActionType.PRINT_CERTIFICATE,
4712
- ActionType.REQUEST_CORRECTION,
4713
- ActionType.APPROVE_CORRECTION,
4714
- ActionType.REJECT_CORRECTION,
4715
- ActionType.CUSTOM
4716
- ]);
4717
-
4718
- // ../commons/src/events/state/flags.ts
4719
- var import_lodash3 = require("lodash");
4720
- var import_date_fns3 = require("date-fns");
4721
- var INHERENT_FLAG_RULES = [
4722
- {
4723
- flag: InherentFlags.CORRECTION_REQUESTED,
4724
- setOn: [ActionType.REQUEST_CORRECTION],
4725
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4726
- },
4727
- {
4728
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4729
- // other status-changing action (see getStatusFromActions).
4730
- flag: InherentFlags.INCOMPLETE,
4731
- setOn: [ActionType.NOTIFY],
4732
- resetOn: [
4733
- ActionType.CREATE,
4734
- ActionType.DECLARE,
4735
- ActionType.REGISTER,
4736
- ActionType.ARCHIVE
4737
- ]
4738
- },
4739
- {
4740
- flag: InherentFlags.REJECTED,
4741
- setOn: [ActionType.REJECT],
4742
- resetOn: [
4743
- ActionType.NOTIFY,
4744
- ActionType.DECLARE,
4745
- ActionType.EDIT,
4746
- ActionType.REGISTER
4747
- ]
4748
- },
4749
- {
4750
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4751
- setOn: [ActionType.DUPLICATE_DETECTED],
4752
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4753
- },
4754
- {
4755
- flag: InherentFlags.EDIT_IN_PROGRESS,
4756
- setOn: [ActionType.EDIT],
4757
- resetOnAnyOtherAction: true
4758
- }
4759
- ];
5110
+ var EventDocumentOnlyLastAction = EventDocument.extend({
5111
+ actions: z42.array(Action).max(1).describe("Only the last action associated with the event.")
5112
+ }).brand("EventDocumentOnlyLastAction");
4760
5113
 
4761
5114
  // ../commons/src/events/defineConfig.ts
4762
5115
  var IGNORED_EVENT_TYPES = [
@@ -6064,6 +6417,20 @@ var tennisClubMembershipEvent = defineConfig({
6064
6417
  },
6065
6418
  review: TENNIS_CLUB_DECLARATION_REVIEW
6066
6419
  },
6420
+ {
6421
+ type: ActionType.NOTIFY,
6422
+ label: {
6423
+ defaultMessage: "Notify health worker",
6424
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6425
+ id: "event.tennis-club-membership.action.notify.label"
6426
+ },
6427
+ flags: [
6428
+ {
6429
+ id: "health-worker-notified",
6430
+ operation: "add"
6431
+ }
6432
+ ]
6433
+ },
6067
6434
  {
6068
6435
  type: ActionType.REJECT,
6069
6436
  label: {
@@ -6306,6 +6673,17 @@ var tennisClubMembershipEvent = defineConfig({
6306
6673
  }
6307
6674
  }
6308
6675
  ],
6676
+ flags: [
6677
+ {
6678
+ id: "health-worker-notified",
6679
+ requiresAction: false,
6680
+ label: {
6681
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6682
+ defaultMessage: "Health worker notified",
6683
+ description: "Label for the health-worker-notified flag"
6684
+ }
6685
+ }
6686
+ ],
6309
6687
  advancedSearch: [
6310
6688
  {
6311
6689
  title: {
@@ -7183,21 +7561,7 @@ var digitalIdentityEvent = defineConfig({
7183
7561
  });
7184
7562
 
7185
7563
  // ../commons/src/events/test.utils.ts
7186
- var z42 = __toESM(require("zod/v4"));
7187
- var TestUserRole = z42.enum([
7188
- "FIELD_AGENT",
7189
- "LOCAL_REGISTRAR",
7190
- "LOCAL_SYSTEM_ADMIN",
7191
- "NATIONAL_REGISTRAR",
7192
- "REGISTRATION_AGENT",
7193
- "NATIONAL_SYSTEM_ADMIN",
7194
- "SOCIAL_WORKER",
7195
- "COMMUNITY_LEADER",
7196
- "PROVINCIAL_REGISTRAR"
7197
- ]);
7198
-
7199
- // ../commons/src/events/scopes.ts
7200
- var import_lodash6 = require("lodash");
7564
+ var z44 = __toESM(require("zod/v4"));
7201
7565
 
7202
7566
  // ../commons/src/events/locations.ts
7203
7567
  var z43 = __toESM(require("zod/v4"));
@@ -7206,182 +7570,165 @@ var LocationTypeV1 = z43.enum([
7206
7570
  "CRVS_OFFICE",
7207
7571
  "HEALTH_FACILITY"
7208
7572
  ]);
7573
+ var LocationStatus = z43.enum(["active", "inactive"]);
7574
+ var LocationVersion = z43.object({
7575
+ versionId: UUID,
7576
+ effectiveFrom: z43.iso.date(),
7577
+ name: z43.string(),
7578
+ externalId: z43.string().nullish(),
7579
+ status: LocationStatus
7580
+ });
7209
7581
  var AdministrativeArea = z43.object({
7210
7582
  id: UUID,
7211
7583
  name: z43.string(),
7212
7584
  externalId: z43.string().nullish(),
7213
7585
  parentId: UUID.nullable(),
7214
- validUntil: z43.iso.datetime().nullable()
7586
+ status: LocationStatus,
7587
+ versions: z43.array(LocationVersion)
7215
7588
  });
7216
7589
  var Location = z43.object({
7217
7590
  id: UUID,
7218
7591
  name: z43.string(),
7219
7592
  externalId: z43.string().nullish(),
7220
7593
  administrativeAreaId: UUID.nullable(),
7221
- validUntil: z43.iso.datetime().nullable(),
7222
- locationType: z43.string().nullable()
7594
+ locationType: z43.string().nullable(),
7595
+ status: LocationStatus,
7596
+ versions: z43.array(LocationVersion)
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
+ });
7641
+ var SetLocationPayload = z43.object({
7642
+ id: UUID,
7643
+ name: z43.string(),
7644
+ externalId: z43.string().nullish(),
7645
+ administrativeAreaId: UUID.nullable(),
7646
+ locationType: z43.string().nullable(),
7647
+ versions: SeededLocationVersions.optional()
7648
+ });
7649
+ var SetAdministrativeAreaPayload = z43.object({
7650
+ id: UUID,
7651
+ name: z43.string(),
7652
+ externalId: z43.string().nullish(),
7653
+ parentId: UUID.nullable(),
7654
+ versions: SeededLocationVersions.optional()
7223
7655
  });
7224
-
7225
- // ../commons/src/events/scopes.ts
7226
- var ACTION_SCOPE_MAP = {
7227
- [ActionType.READ]: ["record.read"],
7228
- [ActionType.CREATE]: ["record.create"],
7229
- [ActionType.NOTIFY]: ["record.notify"],
7230
- [ActionType.DECLARE]: ["record.declare", "record.register"],
7231
- [ActionType.EDIT]: ["record.edit"],
7232
- [ActionType.DELETE]: ["record.declare", "record.notify"],
7233
- [ActionType.REGISTER]: ["record.register"],
7234
- [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
7235
- [ActionType.REQUEST_CORRECTION]: [
7236
- "record.request-correction",
7237
- "record.correct"
7238
- ],
7239
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
7240
- [ActionType.REJECT_CORRECTION]: ["record.correct"],
7241
- [ActionType.APPROVE_CORRECTION]: ["record.correct"],
7242
- [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7243
- [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7244
- [ActionType.ARCHIVE]: ["record.archive"],
7245
- [ActionType.REJECT]: ["record.reject"],
7246
- [ActionType.ASSIGN]: null,
7247
- [ActionType.UNASSIGN]: null,
7248
- [ActionType.DUPLICATE_DETECTED]: [],
7249
- [ActionType.CUSTOM]: []
7250
- };
7251
-
7252
- // ../commons/src/events/state/availableActions.ts
7253
- var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7254
- [EventStatus.enum.CREATED]: [
7255
- ActionType.READ,
7256
- ActionType.DECLARE,
7257
- ActionType.NOTIFY,
7258
- ActionType.DELETE,
7259
- ActionType.CUSTOM
7260
- ],
7261
- [EventStatus.enum.NOTIFIED]: [
7262
- ActionType.READ,
7263
- ActionType.EDIT,
7264
- ActionType.MARK_AS_DUPLICATE,
7265
- ActionType.ARCHIVE,
7266
- ActionType.REJECT,
7267
- ActionType.CUSTOM
7268
- ],
7269
- [EventStatus.enum.DECLARED]: [
7270
- ActionType.READ,
7271
- ActionType.REGISTER,
7272
- ActionType.MARK_AS_DUPLICATE,
7273
- ActionType.ARCHIVE,
7274
- ActionType.REJECT,
7275
- ActionType.CUSTOM,
7276
- ActionType.EDIT
7277
- ],
7278
- [EventStatus.enum.REGISTERED]: [
7279
- ActionType.READ,
7280
- ActionType.PRINT_CERTIFICATE,
7281
- ActionType.REQUEST_CORRECTION,
7282
- ActionType.APPROVE_CORRECTION,
7283
- ActionType.REJECT_CORRECTION,
7284
- ActionType.CUSTOM,
7285
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7286
- ],
7287
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7288
- };
7289
- var ACTION_FILTERS = {
7290
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7291
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7292
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7293
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7294
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7295
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7296
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7297
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7298
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7299
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7300
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7301
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7302
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7303
- };
7304
- var REJECTED_ACTIONS = [
7305
- ActionType.READ,
7306
- ActionType.NOTIFY,
7307
- ActionType.CUSTOM,
7308
- ActionType.EDIT,
7309
- ActionType.ARCHIVE
7310
- ];
7311
-
7312
- // ../commons/src/events/FileUtils.ts
7313
- var import_lodash7 = require("lodash");
7314
7656
 
7315
7657
  // ../commons/src/events/mocks.test.utils.ts
7316
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7658
+ function withVersionFields(entity) {
7659
+ return {
7660
+ ...entity,
7661
+ status: "active",
7662
+ versions: [
7663
+ {
7664
+ versionId: entity.id,
7665
+ effectiveFrom: "0001-01-01",
7666
+ name: entity.name,
7667
+ externalId: entity.externalId ?? null,
7668
+ status: "active"
7669
+ }
7670
+ ]
7671
+ };
7672
+ }
7673
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7317
7674
  {
7318
7675
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7319
7676
  name: "Central",
7320
7677
  parentId: null,
7321
- validUntil: null,
7322
7678
  externalId: "ydyJb1RAy4U1"
7323
7679
  },
7324
7680
  {
7325
7681
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7326
7682
  name: "Sulaka",
7327
7683
  parentId: null,
7328
- validUntil: null,
7329
7684
  externalId: "pQ8nGxWmZ2Q3"
7330
7685
  },
7331
7686
  {
7332
7687
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7333
7688
  name: "Pualula",
7334
7689
  parentId: null,
7335
- validUntil: null,
7336
7690
  externalId: "Aq91DweLmT8k"
7337
7691
  },
7338
7692
  {
7339
7693
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7340
7694
  name: "Chuminga",
7341
7695
  parentId: null,
7342
- validUntil: null,
7343
7696
  externalId: "Rw0fYNh2Xk9a"
7344
7697
  },
7345
7698
  {
7346
7699
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7347
7700
  name: "Ibombo",
7348
7701
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7349
- validUntil: null,
7350
7702
  externalId: "k7DsP4vbN1Qe"
7351
7703
  },
7352
7704
  {
7353
7705
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7354
7706
  name: "Isango",
7355
7707
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7356
- validUntil: null,
7357
7708
  externalId: "Gm3Z9eQpHw4L"
7358
7709
  },
7359
7710
  {
7360
7711
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7361
7712
  name: "Isamba",
7362
7713
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7363
- validUntil: null,
7364
7714
  externalId: "sT0xVu1KqJ7r"
7365
7715
  },
7366
7716
  {
7367
7717
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7368
7718
  name: "Itambo",
7369
7719
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7370
- validUntil: null,
7371
7720
  externalId: "Nq6Bv2HpL9Te"
7372
7721
  },
7373
7722
  {
7374
7723
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7375
7724
  name: "Ezhi",
7376
7725
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7377
- validUntil: null,
7378
7726
  externalId: "xK8cQ0ZRy5Wd"
7379
7727
  },
7380
7728
  {
7381
7729
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7382
7730
  name: "Ilanga",
7383
7731
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7384
- validUntil: null,
7385
7732
  externalId: "Cq4Jm1XvN8Ls"
7386
7733
  },
7387
7734
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7389,49 +7736,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7389
7736
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7390
7737
  name: "Klow",
7391
7738
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7392
- validUntil: null,
7393
7739
  externalId: "IkYcYBUcyY2"
7394
7740
  },
7395
7741
  {
7396
7742
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7397
7743
  name: "Mbondo",
7398
7744
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7399
- validUntil: null,
7400
7745
  externalId: "Qhvv5hvo3mY"
7401
7746
  },
7402
7747
  {
7403
7748
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7404
7749
  name: "Ndara",
7405
7750
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7406
- validUntil: null,
7407
7751
  externalId: "crXh068O9TR"
7408
7752
  },
7409
7753
  {
7410
7754
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7411
7755
  name: "Olani",
7412
7756
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7413
- validUntil: null,
7414
7757
  externalId: "r00It8Tvvp7"
7415
7758
  },
7416
7759
  {
7417
7760
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7418
7761
  name: "Pemba",
7419
7762
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7420
- validUntil: null,
7421
7763
  externalId: "ZnUWsbONIaH"
7422
7764
  },
7423
7765
  {
7424
7766
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7425
7767
  name: "Quanza",
7426
7768
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7427
- validUntil: null,
7428
7769
  externalId: "fDZycvQTa7l"
7429
7770
  },
7430
7771
  {
7431
7772
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7432
7773
  name: "Rivka",
7433
7774
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7434
- validUntil: null,
7435
7775
  externalId: "KqswxCGTELa"
7436
7776
  },
7437
7777
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7439,35 +7779,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7439
7779
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7440
7780
  name: "Mbula",
7441
7781
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7442
- validUntil: null,
7443
7782
  externalId: "osEbKjRc9Kg"
7444
7783
  },
7445
7784
  {
7446
7785
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7447
7786
  name: "Ndoki",
7448
7787
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7449
- validUntil: null,
7450
7788
  externalId: "aq4daBUAGr3"
7451
7789
  },
7452
7790
  {
7453
7791
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7454
7792
  name: "Tsanga",
7455
7793
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7456
- validUntil: null,
7457
7794
  externalId: "cqis6Y8trbJ"
7458
7795
  },
7459
7796
  {
7460
7797
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7461
7798
  name: "Waziri",
7462
7799
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7463
- validUntil: null,
7464
7800
  externalId: "LMijHPyyx6d"
7465
7801
  },
7466
7802
  {
7467
7803
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7468
7804
  name: "Zimbi",
7469
7805
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7470
- validUntil: null,
7471
7806
  externalId: "pcQYbPuKGZ7"
7472
7807
  },
7473
7808
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7475,67 +7810,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7475
7810
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7476
7811
  name: "Felani",
7477
7812
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7478
- validUntil: null,
7479
7813
  externalId: "gSqpoCGdMXp"
7480
7814
  },
7481
7815
  {
7482
7816
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7483
7817
  name: "Goroma",
7484
7818
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7485
- validUntil: null,
7486
7819
  externalId: "KvAAIaNqVrp"
7487
7820
  },
7488
7821
  {
7489
7822
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7490
7823
  name: "Halifu",
7491
7824
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7492
- validUntil: null,
7493
7825
  externalId: "qe4UnEVt1hv"
7494
7826
  },
7495
7827
  {
7496
7828
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7497
7829
  name: "Jabari",
7498
7830
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7499
- validUntil: null,
7500
7831
  externalId: "yHH9Nz4rLOt"
7501
7832
  },
7502
7833
  {
7503
7834
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7504
7835
  name: "Kifani",
7505
7836
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7506
- validUntil: null,
7507
7837
  externalId: "eSWmXIGeu1I"
7508
7838
  },
7509
7839
  {
7510
7840
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7511
7841
  name: "Lumela",
7512
7842
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7513
- validUntil: null,
7514
7843
  externalId: "bh0b3aI1uP3"
7515
7844
  }
7516
7845
  ];
7517
- var V2_DEFAULT_MOCK_LOCATIONS = [
7846
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
7847
+ var MOCK_LOCATIONS_BASE = [
7518
7848
  {
7519
7849
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7520
7850
  name: "Central Provincial Office",
7521
7851
  locationType: "CRVS_OFFICE",
7522
7852
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7523
- validUntil: null,
7524
7853
  externalId: "Xr3Df8WpK6Ys"
7525
7854
  },
7526
7855
  {
7527
7856
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7528
7857
  name: "Central Health Post",
7529
7858
  locationType: "HEALTH_FACILITY",
7530
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7531
- validUntil: null
7859
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7532
7860
  },
7533
7861
  {
7534
7862
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7535
7863
  name: "Ibombo District Office",
7536
7864
  locationType: "CRVS_OFFICE",
7537
7865
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7538
- validUntil: null,
7539
7866
  externalId: "Sm4Nw7GrD2Vy"
7540
7867
  },
7541
7868
  {
@@ -7543,7 +7870,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7543
7870
  name: "Isamba District Office",
7544
7871
  locationType: "CRVS_OFFICE",
7545
7872
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7546
- validUntil: null,
7547
7873
  externalId: "Vg1Bq5XeH9Lt"
7548
7874
  },
7549
7875
  {
@@ -7551,7 +7877,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7551
7877
  name: "Isango District Office",
7552
7878
  locationType: "CRVS_OFFICE",
7553
7879
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7554
- validUntil: null,
7555
7880
  externalId: "Je7Lm2XqN9Vz"
7556
7881
  },
7557
7882
  {
@@ -7559,7 +7884,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7559
7884
  name: "Sulaka Provincial Office",
7560
7885
  locationType: "CRVS_OFFICE",
7561
7886
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7562
- validUntil: null,
7563
7887
  externalId: "Ht2Wp9KcX5Qv"
7564
7888
  },
7565
7889
  {
@@ -7567,7 +7891,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7567
7891
  name: "Ilanga District Office",
7568
7892
  locationType: "CRVS_OFFICE",
7569
7893
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7570
- validUntil: null,
7571
7894
  externalId: "Yp6Ds1WqN3Xz"
7572
7895
  },
7573
7896
  {
@@ -7575,7 +7898,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7575
7898
  name: "Chamakubi Health Post",
7576
7899
  locationType: "HEALTH_FACILITY",
7577
7900
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7578
- validUntil: null,
7579
7901
  externalId: "M1nFr8LbC2Qy"
7580
7902
  },
7581
7903
  {
@@ -7583,7 +7905,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7583
7905
  name: "Ibombo Rural Health Centre",
7584
7906
  locationType: "HEALTH_FACILITY",
7585
7907
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7586
- validUntil: null,
7587
7908
  externalId: "bT7pV6YrW0Xc"
7588
7909
  },
7589
7910
  {
@@ -7591,7 +7912,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7591
7912
  name: "Chikobo Rural Health Centre",
7592
7913
  locationType: "HEALTH_FACILITY",
7593
7914
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7594
- validUntil: null,
7595
7915
  externalId: "zE4qPn2SgJ5d"
7596
7916
  },
7597
7917
  {
@@ -7599,7 +7919,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7599
7919
  name: "Chilochabalenje Health Post",
7600
7920
  locationType: "HEALTH_FACILITY",
7601
7921
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7602
- validUntil: null,
7603
7922
  externalId: "H8vDs1MqR4Uf"
7604
7923
  },
7605
7924
  {
@@ -7607,7 +7926,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7607
7926
  name: "Chipeso Rural Health Centre",
7608
7927
  locationType: "HEALTH_FACILITY",
7609
7928
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7610
- validUntil: null,
7611
7929
  externalId: "Qw3uZ9KfX6Lm"
7612
7930
  },
7613
7931
  {
@@ -7615,7 +7933,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7615
7933
  name: "Chisamba Rural Health Centre",
7616
7934
  locationType: "HEALTH_FACILITY",
7617
7935
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7618
- validUntil: null,
7619
7936
  externalId: "Yr0pCg8LdM2s"
7620
7937
  },
7621
7938
  {
@@ -7623,7 +7940,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7623
7940
  name: "Chitanda Rural Health Centre",
7624
7941
  locationType: "HEALTH_FACILITY",
7625
7942
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7626
- validUntil: null,
7627
7943
  externalId: "tS9gJ4PwB1Qx"
7628
7944
  },
7629
7945
  {
@@ -7631,7 +7947,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7631
7947
  name: "Golden Valley Rural Health Centre",
7632
7948
  locationType: "HEALTH_FACILITY",
7633
7949
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7634
- validUntil: null,
7635
7950
  externalId: "Ld7Qm3XsA8Vr"
7636
7951
  },
7637
7952
  {
@@ -7639,7 +7954,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7639
7954
  name: "Ipongo Rural Health Centre",
7640
7955
  locationType: "HEALTH_FACILITY",
7641
7956
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7642
- validUntil: null,
7643
7957
  externalId: "kF2sW9DmH0Bt"
7644
7958
  },
7645
7959
  {
@@ -7647,7 +7961,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7647
7961
  name: "Itumbwe Health Post",
7648
7962
  locationType: "HEALTH_FACILITY",
7649
7963
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7650
- validUntil: null,
7651
7964
  externalId: "Ue5Xb3VaC7Pq"
7652
7965
  },
7653
7966
  {
@@ -7655,7 +7968,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7655
7968
  name: "Kabangalala Rural Health Centre",
7656
7969
  locationType: "HEALTH_FACILITY",
7657
7970
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7658
- validUntil: null,
7659
7971
  externalId: "Pz8Kc1TqH6Jn"
7660
7972
  },
7661
7973
  // Village offices
@@ -7664,100 +7976,353 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7664
7976
  name: "Klow Village Office",
7665
7977
  locationType: "CRVS_OFFICE",
7666
7978
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7667
- validUntil: null,
7668
7979
  externalId: "PmAyxAJkxiJ"
7669
7980
  }
7670
7981
  ];
7982
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7671
7983
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7672
7984
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7673
7985
  );
7674
7986
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7675
7987
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7676
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
+ });
7677
8155
 
7678
8156
  // ../commons/src/notification/UserNotifications.ts
7679
- var z44 = __toESM(require("zod/v4"));
8157
+ var z46 = __toESM(require("zod/v4"));
7680
8158
  var TriggerEvent = {
7681
8159
  USER_CREATED: "user-created",
7682
8160
  USER_UPDATED: "user-updated",
7683
8161
  USERNAME_REMINDER: "username-reminder",
7684
8162
  RESET_PASSWORD: "reset-password",
7685
8163
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8164
+ PASSWORD_RESET_LINK: "password-reset-link",
8165
+ USERNAME_REMINDER_LINK: "username-reminder-link",
7686
8166
  RESEND_INVITE: "resend-invite",
7687
8167
  TWO_FA: "2fa",
7688
8168
  ALL_USER_NOTIFICATION: "all-user-notification",
7689
8169
  CHANGE_PHONE_NUMBER: "change-phone-number",
7690
8170
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7691
8171
  };
7692
- var Recipient = z44.object({
8172
+ var Recipient = z46.object({
7693
8173
  name: NameFieldValue.optional(),
7694
- mobile: z44.string().optional(),
7695
- email: z44.string().optional(),
7696
- bcc: z44.array(z44.string()).optional()
8174
+ mobile: z46.string().optional(),
8175
+ email: z46.string().optional(),
8176
+ bcc: z46.array(z46.string()).optional()
7697
8177
  });
7698
- var BasePayload = z44.object({
8178
+ var BasePayload = z46.object({
7699
8179
  recipient: Recipient
7700
8180
  });
7701
8181
  var TriggerPayload = {
7702
8182
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7703
- username: z44.string(),
7704
- temporaryPassword: z44.string()
8183
+ username: z46.string(),
8184
+ temporaryPassword: z46.string()
7705
8185
  }),
7706
8186
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7707
- oldUsername: z44.string(),
7708
- newUsername: z44.string()
8187
+ oldUsername: z46.string(),
8188
+ newUsername: z46.string()
7709
8189
  }),
7710
8190
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7711
- username: z44.string()
8191
+ username: z46.string()
7712
8192
  }),
7713
8193
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7714
- code: z44.string()
8194
+ code: z46.string()
7715
8195
  }),
7716
8196
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7717
- temporaryPassword: z44.string(),
7718
- admin: z44.object({
7719
- id: z44.string(),
8197
+ temporaryPassword: z46.string(),
8198
+ admin: z46.object({
8199
+ id: z46.string(),
7720
8200
  name: NameFieldValue,
7721
- role: z44.string()
8201
+ role: z46.string()
7722
8202
  })
7723
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
+ }),
7724
8210
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7725
- username: z44.string(),
7726
- temporaryPassword: z44.string()
8211
+ username: z46.string(),
8212
+ temporaryPassword: z46.string()
7727
8213
  }),
7728
8214
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7729
- code: z44.string()
8215
+ code: z46.string()
7730
8216
  }),
7731
8217
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7732
- subject: z44.string(),
7733
- body: z44.string()
8218
+ subject: z46.string(),
8219
+ body: z46.string()
7734
8220
  }),
7735
8221
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7736
- code: z44.string()
8222
+ code: z46.string()
7737
8223
  }),
7738
8224
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7739
- code: z44.string()
8225
+ code: z46.string()
7740
8226
  })
7741
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 = false ? (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 = false ? "silent" : process.env.LOG_LEVEL;
8297
+ if (level) {
8298
+ logger.level = level;
8299
+ }
8300
+
8301
+ // ../commons/src/notification/dispatch.ts
7742
8302
  async function triggerUserEventNotification({
7743
8303
  event: event2,
7744
8304
  payload,
7745
8305
  countryConfigUrl,
7746
8306
  authHeader
7747
8307
  }) {
7748
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
7749
- method: "POST",
7750
- body: JSON.stringify(payload),
7751
- headers: {
7752
- "Content-Type": "application/json",
7753
- ...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
+ }
7754
8317
  }
7755
- });
7756
- }
7757
- function parseUserEventTrigger(event2, body) {
7758
- const schema = TriggerPayload[event2];
7759
- 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;
7760
8325
  }
7761
8326
 
7762
8327
  // src/notification/index.ts
7763
- z45.globalRegistry.clear();
8328
+ z47.globalRegistry.clear();