@opencrvs/toolkit 2.1.0-rc.b0003b1 → 2.1.0-rc.b061691

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 (57) hide show
  1. package/build.sh +2 -2
  2. package/dist/application-config/index.js +212 -188
  3. package/dist/cli.js +165 -5154
  4. package/dist/commons/api/router.d.ts +758 -201
  5. package/dist/commons/conditionals/conditionals.d.ts +1592 -40
  6. package/dist/commons/conditionals/validate.d.ts +2 -1
  7. package/dist/commons/events/ActionConfig.d.ts +230 -0
  8. package/dist/commons/events/ActionDocument.d.ts +51 -13
  9. package/dist/commons/events/ActionInput.d.ts +26 -6
  10. package/dist/commons/events/ActionStatus.d.ts +14 -0
  11. package/dist/commons/events/ActionType.d.ts +6 -1
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +12 -0
  13. package/dist/commons/events/AuditLog.d.ts +2 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +18 -0
  15. package/dist/commons/events/Draft.d.ts +2 -0
  16. package/dist/commons/events/EventDocument.d.ts +24 -2
  17. package/dist/commons/events/EventIndex.d.ts +5 -24
  18. package/dist/commons/events/EventMetadata.d.ts +2 -1
  19. package/dist/commons/events/FieldConfig.d.ts +10 -0
  20. package/dist/commons/events/Flag.d.ts +48 -0
  21. package/dist/commons/events/WorkqueueColumnConfig.d.ts +4 -4
  22. package/dist/commons/events/WorkqueueConfig.d.ts +25 -7
  23. package/dist/commons/events/field.d.ts +722 -34
  24. package/dist/commons/events/scopes.d.ts +1 -0
  25. package/dist/commons/events/test.utils.d.ts +9 -4
  26. package/dist/commons/events/utils.d.ts +26 -4
  27. package/dist/conditionals/index.js +305 -55
  28. package/dist/environment/derived-variables.d.ts +0 -12
  29. package/dist/environment/derived-variables.d.ts.map +1 -1
  30. package/dist/environment/derived-variables.js +0 -14
  31. package/dist/environment/logger.d.ts +3 -12
  32. package/dist/environment/logger.d.ts.map +1 -1
  33. package/dist/environment/manage-users.js +17 -7
  34. package/dist/environment/setup-environment.js +0 -14
  35. package/dist/environment/swarm-to-k8s.js +17 -7
  36. package/dist/environment/update-workflows.js +17 -7
  37. package/dist/environment/users.js +17 -7
  38. package/dist/environment/utils.js +17 -7
  39. package/dist/events/index.js +3330 -3128
  40. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  41. package/dist/migrations/v2.0/index.js +88 -5144
  42. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  43. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  44. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  45. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  46. package/dist/migrations/v2.1/index.d.ts +6 -0
  47. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  48. package/dist/migrations/v2.1/index.js +218 -0
  49. package/dist/notification/index.js +1557 -872
  50. package/dist/scopes/index.d.ts +257 -1
  51. package/dist/scopes/index.js +306 -55
  52. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  53. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  54. package/opencrvs-toolkit-2.1.0-rc.b061691.tgz +0 -0
  55. package/package.json +3 -3
  56. package/tsconfig.tsbuildinfo +1 -1
  57. package/opencrvs-toolkit-2.1.0-rc.b0003b1.tgz +0 -0
@@ -47,14 +47,14 @@ function joinUrl(base, path) {
47
47
  }
48
48
 
49
49
  // ../commons/src/events/AuditLog.ts
50
- var z5 = __toESM(require("zod/v4"));
50
+ var z8 = __toESM(require("zod/v4"));
51
51
 
52
52
  // ../commons/src/authentication.ts
53
53
  var import_jwt_decode = __toESM(require("jwt-decode"));
54
- var z3 = __toESM(require("zod/v4"));
54
+ var z7 = __toESM(require("zod/v4"));
55
55
 
56
56
  // ../commons/src/scopes.ts
57
- var z2 = __toESM(require("zod/v4"));
57
+ var z6 = __toESM(require("zod/v4"));
58
58
  var qs = __toESM(require("qs"));
59
59
 
60
60
  // ../commons/src/uuid.ts
@@ -65,12 +65,264 @@ function getUUID() {
65
65
  return (0, import_uuid.v4)();
66
66
  }
67
67
 
68
+ // ../commons/src/events/ActionType.ts
69
+ var z2 = __toESM(require("zod/v4"));
70
+ var ActionType = {
71
+ // Pre-declaration actions
72
+ DELETE: "DELETE",
73
+ CREATE: "CREATE",
74
+ NOTIFY: "NOTIFY",
75
+ // Declaration actions
76
+ DECLARE: "DECLARE",
77
+ REGISTER: "REGISTER",
78
+ EDIT: "EDIT",
79
+ // Declaration system actions. Non-configurable.
80
+ DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
81
+ REJECT: "REJECT",
82
+ // REJECT_DECLARATION
83
+ MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
84
+ MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
85
+ ARCHIVE: "ARCHIVE",
86
+ UNARCHIVE: "UNARCHIVE",
87
+ // Record actions
88
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
89
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
90
+ REJECT_CORRECTION: "REJECT_CORRECTION",
91
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
92
+ // General actions
93
+ READ: "READ",
94
+ ASSIGN: "ASSIGN",
95
+ UNASSIGN: "UNASSIGN",
96
+ // Custom action
97
+ CUSTOM: "CUSTOM"
98
+ };
99
+ var ConfirmableActions = [
100
+ ActionType.NOTIFY,
101
+ ActionType.DECLARE,
102
+ ActionType.EDIT,
103
+ ActionType.REGISTER,
104
+ ActionType.REJECT,
105
+ ActionType.ARCHIVE,
106
+ ActionType.UNARCHIVE,
107
+ ActionType.PRINT_CERTIFICATE,
108
+ ActionType.REQUEST_CORRECTION,
109
+ ActionType.APPROVE_CORRECTION,
110
+ ActionType.REJECT_CORRECTION,
111
+ ActionType.CUSTOM
112
+ ];
113
+ var ActionTypes = z2.enum([
114
+ "DELETE",
115
+ "CREATE",
116
+ "NOTIFY",
117
+ "DECLARE",
118
+ "EDIT",
119
+ "REGISTER",
120
+ "DUPLICATE_DETECTED",
121
+ "REJECT",
122
+ "MARK_AS_DUPLICATE",
123
+ "MARK_AS_NOT_DUPLICATE",
124
+ "ARCHIVE",
125
+ "UNARCHIVE",
126
+ "PRINT_CERTIFICATE",
127
+ "REQUEST_CORRECTION",
128
+ "REJECT_CORRECTION",
129
+ "APPROVE_CORRECTION",
130
+ "READ",
131
+ "ASSIGN",
132
+ "UNASSIGN",
133
+ "CUSTOM"
134
+ ]);
135
+ var ClientSpecificAction = {
136
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
137
+ };
138
+ var declarationActionValues = [
139
+ ActionTypes.enum.DECLARE,
140
+ ActionTypes.enum.EDIT,
141
+ ActionTypes.enum.REGISTER,
142
+ ActionTypes.enum.NOTIFY,
143
+ ActionTypes.enum.DUPLICATE_DETECTED
144
+ ];
145
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
146
+ var declarationUpdateActionValues = [
147
+ ...declarationActionValues,
148
+ ActionTypes.enum.REQUEST_CORRECTION
149
+ ];
150
+ var DeclarationUpdateActions = ActionTypes.extract(
151
+ declarationUpdateActionValues
152
+ );
153
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
154
+ var writeActions = ActionTypes.exclude([
155
+ ActionType.CREATE,
156
+ ActionType.READ,
157
+ ActionType.ASSIGN,
158
+ ActionType.UNASSIGN
159
+ ]);
160
+ var WorkqueueActionType = ActionTypes.extract([
161
+ ActionType.READ,
162
+ ActionType.DELETE,
163
+ ActionType.DECLARE,
164
+ ActionType.REGISTER,
165
+ ActionType.EDIT,
166
+ ActionType.REJECT,
167
+ ActionType.MARK_AS_DUPLICATE,
168
+ ActionType.ARCHIVE,
169
+ ActionType.UNARCHIVE,
170
+ ActionType.PRINT_CERTIFICATE,
171
+ ActionType.REQUEST_CORRECTION
172
+ ]);
173
+ var META_ACTIONS = [
174
+ ActionType.ASSIGN,
175
+ ActionType.UNASSIGN,
176
+ ActionType.READ
177
+ ];
178
+ function isMetaAction(actionType) {
179
+ return META_ACTIONS.includes(actionType);
180
+ }
181
+
182
+ // ../commons/src/events/ActionStatus.ts
183
+ var ActionStatus = {
184
+ Requested: "Requested",
185
+ Accepted: "Accepted",
186
+ Rejected: "Rejected"
187
+ };
188
+
189
+ // ../commons/src/events/Flag.ts
190
+ var z5 = __toESM(require("zod/v4"));
191
+
192
+ // ../commons/src/events/TranslationConfig.ts
193
+ var z3 = __toESM(require("zod/v4"));
194
+ var TranslationConfig = z3.object({
195
+ id: z3.string().describe(
196
+ "The identifier of the translation referred in translation CSV files"
197
+ ),
198
+ defaultMessage: z3.string().describe("Default translation message"),
199
+ description: z3.string().describe(
200
+ "Describe the translation for a translator to be able to identify it."
201
+ )
202
+ }).meta({
203
+ description: "Translation configuration",
204
+ id: "TranslationConfig"
205
+ });
206
+
207
+ // ../commons/src/events/Conditional.ts
208
+ var z4 = __toESM(require("zod/v4"));
209
+ var Conditional = z4.any().describe("JSONSchema").meta({
210
+ description: "JSON schema conditional configuration",
211
+ id: "Conditional"
212
+ });
213
+ var ConditionalType = {
214
+ SHOW: "SHOW",
215
+ ENABLE: "ENABLE",
216
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
217
+ };
218
+ var ShowConditional = z4.object({
219
+ type: z4.literal(ConditionalType.SHOW),
220
+ conditional: Conditional
221
+ }).describe(
222
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
223
+ );
224
+ var EnableConditional = z4.object({
225
+ type: z4.literal(ConditionalType.ENABLE),
226
+ conditional: Conditional
227
+ }).describe(
228
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
229
+ );
230
+ var ActionConditional = z4.discriminatedUnion("type", [
231
+ // Action can be shown / hidden
232
+ ShowConditional,
233
+ // Action can be shown to the user in the list but as disabled
234
+ EnableConditional
235
+ ]).meta({
236
+ id: "ActionConditional",
237
+ 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."
238
+ });
239
+ var DisplayOnReviewConditional = z4.object({
240
+ type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
241
+ conditional: Conditional
242
+ }).describe(
243
+ "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."
244
+ );
245
+ var FieldConditional = z4.discriminatedUnion("type", [
246
+ // Field input can be shown / hidden
247
+ ShowConditional,
248
+ // Field input can be shown to the user but as disabled
249
+ EnableConditional,
250
+ // Field output can be shown / hidden on the review page
251
+ DisplayOnReviewConditional
252
+ ]).meta({
253
+ id: "FieldConditional",
254
+ 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."
255
+ });
256
+
257
+ // ../commons/src/events/Flag.ts
258
+ var InherentFlags = {
259
+ INCOMPLETE: "incomplete",
260
+ REJECTED: "rejected",
261
+ CORRECTION_REQUESTED: "correction-requested",
262
+ POTENTIAL_DUPLICATE: "potential-duplicate",
263
+ /**
264
+ * This flag is set by the Edit-action and removed after the declaration or registration.
265
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
266
+ *
267
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
268
+ */
269
+ EDIT_IN_PROGRESS: "edit-in-progress",
270
+ SEALED: "sealed"
271
+ };
272
+ var actionFlagPattern;
273
+ function getActionFlagPattern() {
274
+ actionFlagPattern ??= new RegExp(
275
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
276
+ ActionStatus
277
+ ).join("|").toLowerCase()})$`
278
+ );
279
+ return actionFlagPattern;
280
+ }
281
+ var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
282
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
283
+ });
284
+ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
285
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
286
+ InherentFlags
287
+ ).join(", ")}`
288
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
289
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
290
+ }).describe("Custom flag identifier defined by the country config.");
291
+ var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
292
+ var ContainsFlags = z5.object({
293
+ anyOf: z5.array(Flag).optional(),
294
+ noneOf: z5.array(Flag).optional(),
295
+ allOf: z5.array(Flag).optional()
296
+ }).meta({
297
+ id: "ContainsFlags"
298
+ });
299
+ var FlagConfig = z5.object({
300
+ id: CustomFlag,
301
+ requiresAction: z5.boolean().describe(
302
+ "Indicates if this flag expects an action to be performed to be cleared."
303
+ ),
304
+ label: TranslationConfig.describe("Human readable label of the flag.")
305
+ }).meta({
306
+ id: "FlagConfig",
307
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
308
+ });
309
+ var ActionFlagConfig = z5.object({
310
+ id: Flag,
311
+ operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
312
+ conditional: Conditional.optional().describe(
313
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
314
+ )
315
+ }).meta({
316
+ id: "ActionFlagConfig",
317
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
318
+ });
319
+
68
320
  // ../commons/src/scopes.ts
69
- var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
321
+ var JurisdictionFilter = z6.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 = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
+ var RecordScopeTypeV2 = z6.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,7 +340,7 @@ var RecordScopeTypeV2 = z2.enum([
87
340
  "record.unassign-others",
88
341
  "record.custom-action"
89
342
  ]);
90
- var PlainScopeType = z2.enum([
343
+ var PlainScopeType = z6.enum([
91
344
  // Misc. system scopes
92
345
  "bypassratelimit",
93
346
  "record.reindex",
@@ -106,15 +359,15 @@ var PlainScopeType = z2.enum([
106
359
  "record.confirm-registration",
107
360
  "record.reject-registration"
108
361
  ]);
109
- var scopeByEvent = z2.preprocess(
362
+ var scopeByEvent = z6.preprocess(
110
363
  (val) => val === void 0 ? void 0 : [val].flat(),
111
- z2.array(z2.string()).optional()
364
+ z6.array(z6.string()).optional()
112
365
  ).describe("Event type, e.g. birth, death");
113
- var userRole = z2.preprocess(
366
+ var userRole = z6.preprocess(
114
367
  (val) => val === void 0 ? void 0 : [val].flat(),
115
- z2.array(z2.string()).optional()
368
+ z6.array(z6.string()).optional()
116
369
  ).describe("User role, e.g. admin, field agent");
117
- var scopeOptionsPlaceEvent = z2.object({
370
+ var scopeOptionsPlaceEvent = z6.object({
118
371
  event: scopeByEvent,
119
372
  placeOfEvent: JurisdictionFilter.optional()
120
373
  }).describe("Options applicable to all record scopes.");
@@ -126,36 +379,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
126
379
  }).describe("Options applicable to actions that may take place after DECLARE");
127
380
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
128
381
  registeredIn: JurisdictionFilter.optional(),
129
- registeredBy: UserFilter.optional()
382
+ registeredBy: UserFilter.optional(),
383
+ flags: ContainsFlags.optional()
130
384
  }).describe(
131
385
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
132
386
  );
133
387
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
134
- customActionTypes: z2.preprocess(
388
+ customActionTypes: z6.preprocess(
135
389
  (val) => val === void 0 ? void 0 : [val].flat(),
136
- z2.array(z2.string()).optional()
390
+ z6.array(z6.string()).optional()
137
391
  ).describe("Allowed custom action types")
138
392
  });
139
- var AccessLevelOptions = z2.object({
393
+ var AccessLevelOptions = z6.object({
140
394
  accessLevel: JurisdictionFilter.optional()
141
395
  });
142
396
  var AllUserScopeOptions = AccessLevelOptions.extend({
143
397
  role: userRole.optional()
144
398
  });
145
- var WorkqueueOrDashboardOptions = z2.object({
146
- ids: z2.preprocess(
399
+ var WorkqueueOrDashboardOptions = z6.object({
400
+ ids: z6.preprocess(
147
401
  (val) => val === void 0 ? void 0 : [val].flat(),
148
- z2.array(z2.string())
402
+ z6.array(z6.string())
149
403
  ).describe("Must contain a list of workqueue or dashboard ids.")
150
404
  });
151
- var AllScopeOptions = z2.object({
405
+ var AllScopeOptions = z6.object({
152
406
  ...AllRecordScopeOptions.shape,
153
407
  ...AccessLevelOptions.shape,
154
408
  ...AllUserScopeOptions.shape,
155
409
  ...WorkqueueOrDashboardOptions.shape
156
410
  });
157
411
  var ScopeOptionKey = AllScopeOptions.keyof();
158
- var ResolvedScopeOptionsPlaceEvent = z2.object({
412
+ var ResolvedScopeOptionsPlaceEvent = z6.object({
159
413
  event: scopeByEvent,
160
414
  placeOfEvent: UUID.nullish()
161
415
  }).describe(
@@ -163,15 +417,16 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
163
417
  );
164
418
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
165
419
  notifiedIn: UUID.nullish(),
166
- notifiedBy: z2.string().optional(),
420
+ notifiedBy: z6.string().optional(),
167
421
  declaredIn: UUID.nullish(),
168
- declaredBy: z2.string().optional()
422
+ declaredBy: z6.string().optional()
169
423
  }).describe(
170
424
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
171
425
  );
172
426
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
173
427
  registeredIn: UUID.nullish(),
174
- registeredBy: z2.string().optional()
428
+ registeredBy: z6.string().optional(),
429
+ flags: ContainsFlags.optional()
175
430
  }).describe(
176
431
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
177
432
  );
@@ -184,6 +439,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
184
439
  "record.edit",
185
440
  "record.reject",
186
441
  "record.archive",
442
+ "record.unarchive",
187
443
  "record.review-duplicates",
188
444
  "record.register"
189
445
  ]);
@@ -195,38 +451,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
195
451
  "record.unassign-others"
196
452
  ]);
197
453
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
198
- templates: z2.preprocess(
454
+ templates: z6.preprocess(
199
455
  (val) => val === void 0 ? void 0 : [val].flat(),
200
- z2.array(z2.string()).optional()
456
+ z6.array(z6.string()).optional()
201
457
  ).describe(
202
458
  "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
459
  )
204
460
  });
205
- var RecordScopeV2 = z2.discriminatedUnion("type", [
206
- z2.object({
461
+ var RecordScopeV2 = z6.discriminatedUnion("type", [
462
+ z6.object({
207
463
  type: ScopesWithPlaceEventOptions,
208
464
  options: scopeOptionsPlaceEvent.optional()
209
465
  }),
210
- z2.object({
466
+ z6.object({
211
467
  type: ScopesWithDeclaredOptions,
212
468
  options: scopeOptionsDeclaredOrNotified.optional()
213
469
  }),
214
- z2.object({
470
+ z6.object({
215
471
  type: ScopesWithFullOptions,
216
472
  options: AllRecordScopeOptions.optional()
217
473
  }),
218
- z2.object({
219
- type: z2.literal("record.custom-action"),
474
+ z6.object({
475
+ type: z6.literal("record.custom-action"),
220
476
  options: CustomActionScopeOptions.optional()
221
477
  }),
222
- z2.object({
223
- type: z2.literal("record.print-certified-copies"),
478
+ z6.object({
479
+ type: z6.literal("record.print-certified-copies"),
224
480
  options: ScopeOptionsPrintCertifiedCopies.optional()
225
481
  })
226
482
  ]).describe(
227
483
  "Scopes used to check user's permission to perform actions on a record."
228
484
  );
229
- var SystemScopeType = z2.enum([
485
+ var SystemScopeType = z6.enum([
230
486
  "organisation.read-locations",
231
487
  "user.read",
232
488
  "user.create",
@@ -240,61 +496,61 @@ var UserScopeType = SystemScopeType.extract([
240
496
  "user.search"
241
497
  ]);
242
498
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
243
- var UserScopeV2 = z2.discriminatedUnion("type", [
244
- z2.object({
499
+ var UserScopeV2 = z6.discriminatedUnion("type", [
500
+ z6.object({
245
501
  type: ScopesWithRoleOption,
246
502
  options: AllUserScopeOptions.optional()
247
503
  }),
248
- z2.object({
504
+ z6.object({
249
505
  type: UserScopeType.extract(["user.read", "user.search"]),
250
506
  options: AccessLevelOptions.optional()
251
507
  })
252
508
  ]);
253
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
254
- z2.object({
509
+ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
510
+ z6.object({
255
511
  type: ScopesWithPlaceEventOptions,
256
512
  options: ResolvedScopeOptionsPlaceEvent.optional()
257
513
  }),
258
- z2.object({
514
+ z6.object({
259
515
  type: ScopesWithDeclaredOptions,
260
516
  options: ResolvedScopeOptionsDeclared.optional()
261
517
  }),
262
- z2.object({
518
+ z6.object({
263
519
  type: ScopesWithFullOptions,
264
520
  options: ResolvedScopeOptionsFull.optional()
265
521
  }),
266
- z2.object({
267
- type: z2.literal("record.print-certified-copies"),
522
+ z6.object({
523
+ type: z6.literal("record.print-certified-copies"),
268
524
  options: ResolvedScopeOptionsFull.extend({
269
- templates: z2.array(z2.string()).optional()
525
+ templates: z6.array(z6.string()).optional()
270
526
  }).optional()
271
527
  })
272
528
  ]).describe("Resolved scope with location/user IDs instead of filters.");
273
- var Scope = z2.discriminatedUnion("type", [
274
- z2.object({ type: PlainScopeType }),
529
+ var Scope = z6.discriminatedUnion("type", [
530
+ z6.object({ type: PlainScopeType }),
275
531
  ...RecordScopeV2.options,
276
532
  ...UserScopeV2.options,
277
- z2.object({
278
- type: z2.literal("organisation.read-locations"),
533
+ z6.object({
534
+ type: z6.literal("organisation.read-locations"),
279
535
  options: AccessLevelOptions.optional()
280
536
  }),
281
- z2.object({
282
- type: z2.literal("workqueue"),
537
+ z6.object({
538
+ type: z6.literal("workqueue"),
283
539
  options: WorkqueueOrDashboardOptions
284
540
  }),
285
- z2.object({
286
- type: z2.literal("dashboard.view"),
541
+ z6.object({
542
+ type: z6.literal("dashboard.view"),
287
543
  options: WorkqueueOrDashboardOptions
288
544
  })
289
545
  ]);
290
- var ScopeType = z2.enum([
546
+ var ScopeType = z6.enum([
291
547
  ...SystemScopeType.options,
292
548
  ...RecordScopeTypeV2.options,
293
549
  ...PlainScopeType.options,
294
550
  "workqueue",
295
551
  "dashboard.view"
296
552
  ]);
297
- var EncodedScope = z2.string().brand("EncodedScope");
553
+ var EncodedScope = z6.string().brand("EncodedScope");
298
554
  var DEFAULT_SCOPE_OPTIONS = {
299
555
  placeOfEvent: JurisdictionFilter.enum.all,
300
556
  accessLevel: JurisdictionFilter.enum.all,
@@ -304,158 +560,51 @@ var DEFAULT_SCOPE_OPTIONS = {
304
560
  };
305
561
 
306
562
  // ../commons/src/authentication.ts
307
- var TokenUserType = z3.enum(["user", "system"]);
308
- var TokenWithBearer = z3.string().regex(/^Bearer\s/);
309
-
310
- // ../commons/src/events/ActionType.ts
311
- var z4 = __toESM(require("zod/v4"));
312
- var ActionType = {
313
- // Pre-declaration actions
314
- DELETE: "DELETE",
315
- CREATE: "CREATE",
316
- NOTIFY: "NOTIFY",
317
- // Declaration actions
318
- DECLARE: "DECLARE",
319
- REGISTER: "REGISTER",
320
- EDIT: "EDIT",
321
- // Declaration system actions. Non-configurable.
322
- DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
323
- REJECT: "REJECT",
324
- // REJECT_DECLARATION
325
- MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
326
- MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
327
- ARCHIVE: "ARCHIVE",
328
- // Record actions
329
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
330
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
331
- REJECT_CORRECTION: "REJECT_CORRECTION",
332
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
333
- // General actions
334
- READ: "READ",
335
- ASSIGN: "ASSIGN",
336
- UNASSIGN: "UNASSIGN",
337
- // Custom action
338
- CUSTOM: "CUSTOM"
339
- };
340
- var ConfirmableActions = [
341
- ActionType.NOTIFY,
342
- ActionType.DECLARE,
343
- ActionType.EDIT,
344
- ActionType.REGISTER,
345
- ActionType.REJECT,
346
- ActionType.ARCHIVE,
347
- ActionType.PRINT_CERTIFICATE,
348
- ActionType.REQUEST_CORRECTION,
349
- ActionType.APPROVE_CORRECTION,
350
- ActionType.REJECT_CORRECTION,
351
- ActionType.CUSTOM
352
- ];
353
- var ActionTypes = z4.enum([
354
- "DELETE",
355
- "CREATE",
356
- "NOTIFY",
357
- "DECLARE",
358
- "EDIT",
359
- "REGISTER",
360
- "DUPLICATE_DETECTED",
361
- "REJECT",
362
- "MARK_AS_DUPLICATE",
363
- "MARK_AS_NOT_DUPLICATE",
364
- "ARCHIVE",
365
- "PRINT_CERTIFICATE",
366
- "REQUEST_CORRECTION",
367
- "REJECT_CORRECTION",
368
- "APPROVE_CORRECTION",
369
- "READ",
370
- "ASSIGN",
371
- "UNASSIGN",
372
- "CUSTOM"
373
- ]);
374
- var ClientSpecificAction = {
375
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
376
- };
377
- var declarationActionValues = [
378
- ActionTypes.enum.DECLARE,
379
- ActionTypes.enum.EDIT,
380
- ActionTypes.enum.REGISTER,
381
- ActionTypes.enum.NOTIFY,
382
- ActionTypes.enum.DUPLICATE_DETECTED
383
- ];
384
- var DeclarationActions = ActionTypes.extract(declarationActionValues);
385
- var declarationUpdateActionValues = [
386
- ...declarationActionValues,
387
- ActionTypes.enum.REQUEST_CORRECTION
388
- ];
389
- var DeclarationUpdateActions = ActionTypes.extract(
390
- declarationUpdateActionValues
391
- );
392
- var annotationActions = ActionTypes.exclude(declarationActionValues);
393
- var writeActions = ActionTypes.exclude([
394
- ActionType.CREATE,
395
- ActionType.READ,
396
- ActionType.ASSIGN,
397
- ActionType.UNASSIGN
398
- ]);
399
- var WorkqueueActionType = ActionTypes.extract([
400
- ActionType.READ,
401
- ActionType.DELETE,
402
- ActionType.DECLARE,
403
- ActionType.REGISTER,
404
- ActionType.EDIT,
405
- ActionType.REJECT,
406
- ActionType.MARK_AS_DUPLICATE,
407
- ActionType.ARCHIVE,
408
- ActionType.PRINT_CERTIFICATE,
409
- ActionType.REQUEST_CORRECTION
410
- ]);
411
- var META_ACTIONS = [
412
- ActionType.ASSIGN,
413
- ActionType.UNASSIGN,
414
- ActionType.READ
415
- ];
563
+ var TokenUserType = z7.enum(["user", "system"]);
564
+ var TokenWithBearer = z7.string().regex(/^Bearer\s/);
416
565
 
417
566
  // ../commons/src/events/AuditLog.ts
418
- var AuditLogEntryBase = z5.object({
419
- id: z5.string(),
420
- clientId: z5.string(),
567
+ var AuditLogEntryBase = z8.object({
568
+ id: z8.string(),
569
+ clientId: z8.string(),
421
570
  clientType: TokenUserType,
422
- createdAt: z5.string()
571
+ createdAt: z8.string()
423
572
  });
424
573
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
425
- operation: z5.literal("event.create"),
426
- requestData: z5.object({
427
- transactionId: z5.string(),
428
- type: z5.string(),
429
- createdAtLocation: z5.string().nullable()
574
+ operation: z8.literal("event.create"),
575
+ requestData: z8.object({
576
+ transactionId: z8.string(),
577
+ type: z8.string(),
578
+ createdAtLocation: z8.string().nullable()
430
579
  }),
431
- responseSummary: z5.object({
432
- eventId: z5.string(),
433
- trackingId: z5.string()
580
+ responseSummary: z8.object({
581
+ eventId: z8.string(),
582
+ trackingId: z8.string()
434
583
  })
435
584
  });
436
585
  var EventGetEntrySchema = AuditLogEntryBase.extend({
437
- operation: z5.literal("event.get"),
438
- requestData: z5.object({ eventId: z5.string() }),
439
- responseSummary: z5.object({
440
- eventType: z5.string(),
441
- trackingId: z5.string()
586
+ operation: z8.literal("event.get"),
587
+ requestData: z8.object({ eventId: z8.string() }),
588
+ responseSummary: z8.object({
589
+ eventType: z8.string(),
590
+ trackingId: z8.string()
442
591
  })
443
592
  });
444
593
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
445
- operation: z5.literal("event.search"),
446
- clientType: z5.literal("system"),
447
- requestData: z5.object({
448
- query: z5.record(z5.string(), z5.unknown()).nullable(),
449
- limit: z5.number().nullable(),
450
- offset: z5.number().nullable()
594
+ operation: z8.literal("event.search"),
595
+ clientType: z8.literal("system"),
596
+ requestData: z8.object({
597
+ query: z8.record(z8.string(), z8.unknown()).nullable(),
598
+ limit: z8.number().nullable(),
599
+ offset: z8.number().nullable()
451
600
  }),
452
- responseSummary: z5.object({
453
- total: z5.number(),
454
- eventIds: z5.array(z5.string())
601
+ responseSummary: z8.object({
602
+ total: z8.number(),
603
+ eventIds: z8.array(z8.string())
455
604
  })
456
605
  });
457
606
  var EventActionEntrySchema = AuditLogEntryBase.extend({
458
- operation: z5.enum([
607
+ operation: z8.enum([
459
608
  "event.actions.notify.request",
460
609
  "event.actions.declare.request",
461
610
  "event.actions.register.request",
@@ -466,6 +615,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
466
615
  "event.actions.unassign.request",
467
616
  "event.actions.read.request",
468
617
  "event.actions.archive.request",
618
+ "event.actions.unarchive.request",
469
619
  "event.actions.reinstate.request",
470
620
  "event.actions.print_certificate.request",
471
621
  "event.actions.correction.request.request",
@@ -474,83 +624,83 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
474
624
  "event.actions.mark_as_duplicate.request",
475
625
  "event.actions.mark_as_not_duplicate.request"
476
626
  ]),
477
- requestData: z5.object({
478
- eventId: z5.string(),
479
- actionType: z5.string(),
480
- eventType: z5.string(),
481
- trackingId: z5.string(),
482
- transactionId: z5.string()
627
+ requestData: z8.object({
628
+ eventId: z8.string(),
629
+ actionType: z8.string(),
630
+ eventType: z8.string(),
631
+ trackingId: z8.string(),
632
+ transactionId: z8.string()
483
633
  })
484
634
  });
485
635
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
486
- operation: z5.literal("event.actions.custom.request"),
487
- requestData: z5.object({
488
- eventId: z5.string(),
489
- actionType: z5.literal(ActionType.CUSTOM),
490
- customAction: z5.string(),
491
- eventType: z5.string(),
492
- trackingId: z5.string(),
493
- transactionId: z5.string()
636
+ operation: z8.literal("event.actions.custom.request"),
637
+ requestData: z8.object({
638
+ eventId: z8.string(),
639
+ actionType: z8.literal(ActionType.CUSTOM),
640
+ customAction: z8.string(),
641
+ eventType: z8.string(),
642
+ trackingId: z8.string(),
643
+ transactionId: z8.string()
494
644
  })
495
645
  });
496
646
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
497
- operation: z5.literal("integrations.create"),
498
- requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
499
- responseSummary: z5.object({ clientId: z5.string() })
647
+ operation: z8.literal("integrations.create"),
648
+ requestData: z8.object({ name: z8.string(), scopes: z8.array(z8.string()) }),
649
+ responseSummary: z8.object({ clientId: z8.string() })
500
650
  });
501
651
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
502
- operation: z5.literal("integrations.refreshToken"),
503
- requestData: z5.object({ clientId: z5.string() }),
504
- responseSummary: z5.object({ clientId: z5.string() })
652
+ operation: z8.literal("integrations.refreshToken"),
653
+ requestData: z8.object({ clientId: z8.string() }),
654
+ responseSummary: z8.object({ clientId: z8.string() })
505
655
  });
506
656
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
507
- operation: z5.literal("integrations.deactivate"),
508
- requestData: z5.object({ id: z5.string() }),
509
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
657
+ operation: z8.literal("integrations.deactivate"),
658
+ requestData: z8.object({ id: z8.string() }),
659
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
510
660
  });
511
661
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
512
- operation: z5.literal("integrations.activate"),
513
- requestData: z5.object({ id: z5.string() }),
514
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
662
+ operation: z8.literal("integrations.activate"),
663
+ requestData: z8.object({ id: z8.string() }),
664
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
515
665
  });
516
666
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
517
- operation: z5.literal("integrations.delete"),
518
- requestData: z5.object({ id: z5.string() }),
519
- responseSummary: z5.object({ id: z5.string(), name: z5.string() })
667
+ operation: z8.literal("integrations.delete"),
668
+ requestData: z8.object({ id: z8.string() }),
669
+ responseSummary: z8.object({ id: z8.string(), name: z8.string() })
520
670
  });
521
671
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
522
- operation: z5.literal("integrations.refreshSecret"),
523
- requestData: z5.object({ id: z5.string() }),
524
- responseSummary: z5.object({ clientId: z5.string() })
672
+ operation: z8.literal("integrations.refreshSecret"),
673
+ requestData: z8.object({ id: z8.string() }),
674
+ responseSummary: z8.object({ clientId: z8.string() })
525
675
  });
526
676
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
527
- operation: z5.literal("attachments.upload"),
528
- requestData: z5.object({
529
- transactionId: z5.string(),
530
- path: z5.string().nullable()
677
+ operation: z8.literal("attachments.upload"),
678
+ requestData: z8.object({
679
+ transactionId: z8.string(),
680
+ path: z8.string().nullable()
531
681
  }),
532
- responseSummary: z5.object({ fileUrl: z5.string() })
682
+ responseSummary: z8.object({ fileUrl: z8.string() })
533
683
  });
534
- var subjectOnly = z5.object({ subjectId: z5.string() });
535
- var subjectWithReason = z5.object({
536
- subjectId: z5.string(),
537
- reason: z5.string(),
538
- comment: z5.string().optional()
684
+ var subjectOnly = z8.object({ subjectId: z8.string() });
685
+ var subjectWithReason = z8.object({
686
+ subjectId: z8.string(),
687
+ reason: z8.string(),
688
+ comment: z8.string().optional()
539
689
  });
540
690
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
541
- operation: z5.literal("user.create_user"),
542
- requestData: z5.object({
543
- subjectId: z5.string(),
544
- role: z5.string(),
545
- primaryOfficeId: z5.string()
691
+ operation: z8.literal("user.create_user"),
692
+ requestData: z8.object({
693
+ subjectId: z8.string(),
694
+ role: z8.string(),
695
+ primaryOfficeId: z8.string()
546
696
  })
547
697
  });
548
698
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
549
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
699
+ operation: z8.enum(["user.deactivate", "user.reactivate"]),
550
700
  requestData: subjectWithReason
551
701
  });
552
702
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
553
- operation: z5.enum([
703
+ operation: z8.enum([
554
704
  "user.edit_user",
555
705
  "user.logged_in",
556
706
  "user.logged_out",
@@ -564,14 +714,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
564
714
  requestData: subjectOnly
565
715
  });
566
716
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
567
- operation: z5.literal("user.email_address_changed"),
717
+ operation: z8.literal("user.email_address_changed"),
568
718
  requestData: subjectOnly,
569
- responseSummary: z5.object({ email: z5.string() })
719
+ responseSummary: z8.object({ email: z8.string() })
570
720
  });
571
721
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
572
- operation: z5.literal("user.phone_number_changed"),
722
+ operation: z8.literal("user.phone_number_changed"),
573
723
  requestData: subjectOnly,
574
- responseSummary: z5.object({ phoneNumber: z5.string() })
724
+ responseSummary: z8.object({ phoneNumber: z8.string() })
575
725
  });
576
726
  var userBaseOmit = {
577
727
  id: true,
@@ -579,14 +729,14 @@ var userBaseOmit = {
579
729
  clientType: true,
580
730
  createdAt: true
581
731
  };
582
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
732
+ var UserAuditRecordInput = z8.discriminatedUnion("operation", [
583
733
  UserCreateEntrySchema.omit(userBaseOmit),
584
734
  UserReasonEntrySchema.omit(userBaseOmit),
585
735
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
586
736
  UserEmailChangedEntrySchema.omit(userBaseOmit),
587
737
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
588
738
  ]);
589
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
739
+ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
590
740
  EventCreateEntrySchema,
591
741
  EventGetEntrySchema,
592
742
  EventSearchEntrySchema,
@@ -613,76 +763,11 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
613
763
  // ../commons/src/events/ActionConfig.ts
614
764
  var z24 = __toESM(require("zod/v4"));
615
765
 
616
- // ../commons/src/events/TranslationConfig.ts
617
- var z6 = __toESM(require("zod/v4"));
618
- var TranslationConfig = z6.object({
619
- id: z6.string().describe(
620
- "The identifier of the translation referred in translation CSV files"
621
- ),
622
- defaultMessage: z6.string().describe("Default translation message"),
623
- description: z6.string().describe(
624
- "Describe the translation for a translator to be able to identify it."
625
- )
626
- }).meta({
627
- description: "Translation configuration",
628
- id: "TranslationConfig"
629
- });
630
-
631
766
  // ../commons/src/events/FieldConfig.ts
632
767
  var import_v43 = __toESM(require("zod/v4"));
633
768
 
634
- // ../commons/src/events/Conditional.ts
635
- var z7 = __toESM(require("zod/v4"));
636
- var Conditional = z7.any().describe("JSONSchema").meta({
637
- description: "JSON schema conditional configuration",
638
- id: "Conditional"
639
- });
640
- var ConditionalType = {
641
- SHOW: "SHOW",
642
- ENABLE: "ENABLE",
643
- DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
644
- };
645
- var ShowConditional = z7.object({
646
- type: z7.literal(ConditionalType.SHOW),
647
- conditional: Conditional
648
- }).describe(
649
- "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
650
- );
651
- var EnableConditional = z7.object({
652
- type: z7.literal(ConditionalType.ENABLE),
653
- conditional: Conditional
654
- }).describe(
655
- "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
656
- );
657
- var ActionConditional = z7.discriminatedUnion("type", [
658
- // Action can be shown / hidden
659
- ShowConditional,
660
- // Action can be shown to the user in the list but as disabled
661
- EnableConditional
662
- ]).meta({
663
- id: "ActionConditional",
664
- 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."
665
- });
666
- var DisplayOnReviewConditional = z7.object({
667
- type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
668
- conditional: Conditional
669
- }).describe(
670
- "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."
671
- );
672
- var FieldConditional = z7.discriminatedUnion("type", [
673
- // Field input can be shown / hidden
674
- ShowConditional,
675
- // Field input can be shown to the user but as disabled
676
- EnableConditional,
677
- // Field output can be shown / hidden on the review page
678
- DisplayOnReviewConditional
679
- ]).meta({
680
- id: "FieldConditional",
681
- 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."
682
- });
683
-
684
769
  // ../commons/src/events/FieldType.ts
685
- var z8 = __toESM(require("zod/v4"));
770
+ var z9 = __toESM(require("zod/v4"));
686
771
  var FieldType = {
687
772
  NAME: "NAME",
688
773
  PHONE: "PHONE",
@@ -746,7 +831,7 @@ var FieldType = {
746
831
  */
747
832
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
748
833
  };
749
- var FileFieldType = z8.enum([
834
+ var FileFieldType = z9.enum([
750
835
  FieldType.FILE,
751
836
  FieldType.FILE_WITH_OPTIONS,
752
837
  FieldType.SIGNATURE
@@ -782,160 +867,164 @@ var HiddenFieldTypes = [
782
867
  ];
783
868
 
784
869
  // ../commons/src/events/FieldValue.ts
785
- var z12 = __toESM(require("zod/v4"));
870
+ var z13 = __toESM(require("zod/v4"));
786
871
 
787
872
  // ../commons/src/documents.ts
788
- var z9 = __toESM(require("zod/v4"));
789
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
873
+ var z10 = __toESM(require("zod/v4"));
874
+ var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
790
875
  "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"
791
876
  );
792
- var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
877
+ var FullDocumentPath = z10.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
793
878
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
794
879
  );
795
- var DocumentPath = z9.string().brand("DocumentPath").describe(
880
+ var DocumentPath = z10.string().brand("DocumentPath").describe(
796
881
  "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."
797
882
  );
798
883
 
799
884
  // ../commons/src/events/CompositeFieldValue.ts
800
- var z10 = __toESM(require("zod/v4"));
885
+ var z11 = __toESM(require("zod/v4"));
801
886
  var AddressType = {
802
887
  DOMESTIC: "DOMESTIC",
803
888
  INTERNATIONAL: "INTERNATIONAL"
804
889
  };
805
- var FileFieldValue = z10.object({
890
+ var FileFieldValue = z11.object({
806
891
  path: DocumentPath,
807
- originalFilename: z10.string(),
808
- type: z10.string()
809
- });
810
- var NameFieldValue = z10.object({
811
- firstname: z10.string(),
812
- surname: z10.string(),
813
- middlename: z10.string().optional()
814
- });
815
- var NameFieldUpdateValue = z10.object({
816
- firstname: z10.string().nullish(),
817
- surname: z10.string().nullish(),
818
- middlename: z10.string().nullish()
819
- }).or(z10.null()).or(z10.undefined());
820
- var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
821
- var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
822
- var BaseAddressFieldValue = z10.object({
823
- country: z10.string(),
892
+ originalFilename: z11.string(),
893
+ type: z11.string()
894
+ });
895
+ var NameFieldValue = z11.object({
896
+ firstname: z11.string(),
897
+ surname: z11.string(),
898
+ middlename: z11.string().optional()
899
+ });
900
+ var NameFieldUpdateValue = z11.object({
901
+ firstname: z11.string().nullish(),
902
+ surname: z11.string().nullish(),
903
+ middlename: z11.string().nullish()
904
+ }).or(z11.null()).or(z11.undefined());
905
+ var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
906
+ var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
907
+ var BaseAddressFieldValue = z11.object({
908
+ country: z11.string(),
824
909
  streetLevelDetails: StreetLevelDetailsValue
825
910
  });
826
- var BaseAddressFieldUpdateValue = z10.object({
827
- country: z10.string().nullish(),
911
+ var BaseAddressFieldUpdateValue = z11.object({
912
+ country: z11.string().nullish(),
828
913
  streetLevelDetails: StreetLevelDetailsUpdateValue
829
914
  });
830
915
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
831
- addressType: z10.literal(AddressType.DOMESTIC),
832
- administrativeArea: z10.string().uuid()
916
+ addressType: z11.literal(AddressType.DOMESTIC),
917
+ administrativeArea: z11.string().uuid()
833
918
  });
834
919
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
835
- addressType: z10.literal(AddressType.INTERNATIONAL)
920
+ addressType: z11.literal(AddressType.INTERNATIONAL)
836
921
  });
837
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
922
+ var AddressFieldValue = z11.discriminatedUnion("addressType", [
838
923
  DomesticAddressFieldValue,
839
924
  InternationalAddressFieldValue
840
925
  ]);
841
926
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
842
- addressType: z10.literal(AddressType.DOMESTIC),
843
- administrativeArea: z10.string().uuid().nullish()
927
+ addressType: z11.literal(AddressType.DOMESTIC),
928
+ administrativeArea: z11.string().uuid().nullish()
844
929
  /* Leaf level admin structure */
845
930
  });
846
931
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
847
932
  {
848
- addressType: z10.literal(AddressType.INTERNATIONAL)
933
+ addressType: z11.literal(AddressType.INTERNATIONAL)
849
934
  }
850
935
  );
851
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
936
+ var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
852
937
  DomesticAddressUpdateFieldValue,
853
938
  InternationalAddressUpdateFieldValue
854
939
  ]).nullish();
855
- var FileFieldValueWithOption = z10.object({
940
+ var FileFieldValueWithOption = z11.object({
856
941
  path: DocumentPath,
857
- originalFilename: z10.string(),
858
- type: z10.string(),
859
- option: z10.string()
860
- });
861
- var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
862
- var HttpFieldValue = z10.object({
863
- loading: z10.boolean(),
864
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
865
- data: z10.any()
866
- });
867
- var HttpFieldUpdateValue = z10.object({
868
- loading: z10.boolean().nullish(),
869
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
870
- data: z10.any().nullish()
871
- }).or(z10.null()).or(z10.undefined());
872
- var QueryParamReaderFieldValue = z10.object({
873
- data: z10.record(z10.string(), z10.string()),
874
- updatedAt: z10.iso.datetime()
942
+ originalFilename: z11.string(),
943
+ type: z11.string(),
944
+ option: z11.string()
945
+ });
946
+ var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
947
+ var HttpFieldValue = z11.object({
948
+ loading: z11.boolean(),
949
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
950
+ data: z11.any()
951
+ });
952
+ var HttpFieldUpdateValue = z11.object({
953
+ loading: z11.boolean().nullish(),
954
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
955
+ data: z11.any().nullish()
956
+ }).or(z11.null()).or(z11.undefined());
957
+ var QueryParamReaderFieldValue = z11.object({
958
+ data: z11.record(z11.string(), z11.string()),
959
+ updatedAt: z11.iso.datetime()
875
960
  }).nullish();
876
- var QueryParamReaderFieldUpdateValue = z10.object({
877
- data: z10.record(z10.string(), z10.string())
961
+ var QueryParamReaderFieldUpdateValue = z11.object({
962
+ data: z11.record(z11.string(), z11.string())
878
963
  });
879
- var ReadDataValue = z10.object({
880
- data: z10.any()
964
+ var ReadDataValue = z11.object({
965
+ data: z11.any()
881
966
  });
882
967
  var QrReaderFieldValue = ReadDataValue;
883
968
  var IdReaderFieldValue = ReadDataValue;
884
- var NumberWithUnitFieldValue = z10.object({
885
- numericValue: z10.number(),
886
- unit: z10.string()
969
+ var NumberWithUnitFieldValue = z11.object({
970
+ numericValue: z11.number(),
971
+ unit: z11.string()
887
972
  });
888
- var NumberWithUnitFieldUpdateValue = z10.object({
889
- numericValue: z10.number().optional(),
890
- unit: z10.string().optional()
973
+ var NumberWithUnitFieldUpdateValue = z11.object({
974
+ numericValue: z11.number().optional(),
975
+ unit: z11.string().optional()
891
976
  });
892
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
977
+ var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
893
978
 
894
979
  // ../commons/src/events/PlainDate.ts
895
980
  var import_zod = require("zod");
896
981
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
982
+ function plainDateToLocalDate(date) {
983
+ const [year, month, day] = date.split("-").map(Number);
984
+ return new Date(year, month - 1, day);
985
+ }
897
986
 
898
987
  // ../commons/src/events/FieldValue.ts
899
- var TextValue = z12.string();
900
- var HiddenFieldValue = z12.string();
901
- var NonEmptyTextValue = z12.string().trim().min(1);
902
- var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
903
- var AgeValue = z12.object({
904
- age: z12.number(),
905
- asOfDateRef: z12.string()
988
+ var TextValue = z13.string();
989
+ var HiddenFieldValue = z13.string();
990
+ var NonEmptyTextValue = z13.string().trim().min(1);
991
+ var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
992
+ var AgeValue = z13.object({
993
+ age: z13.number(),
994
+ asOfDateRef: z13.string()
906
995
  });
907
996
  var AgeUpdateValue = AgeValue.optional().nullable();
908
- var AutocompleteValue = z12.object({
909
- label: z12.string(),
910
- value: z12.string()
997
+ var AutocompleteValue = z13.object({
998
+ label: z13.string(),
999
+ value: z13.string()
911
1000
  });
912
1001
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
913
- var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
914
- var DatetimeValue = z12.iso.datetime();
915
- var SelectDateRangeValue = z12.enum([
1002
+ var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1003
+ var DatetimeValue = z13.iso.datetime();
1004
+ var SelectDateRangeValue = z13.enum([
916
1005
  "last7Days",
917
1006
  "last30Days",
918
1007
  "last90Days",
919
1008
  "last365Days"
920
1009
  ]);
921
- var DateRangeFieldValue = z12.object({
1010
+ var DateRangeFieldValue = z13.object({
922
1011
  start: PlainDate,
923
1012
  end: PlainDate
924
1013
  }).or(PlainDate).describe(
925
1014
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
926
1015
  );
927
- var EmailValue = z12.email();
928
- var CheckboxFieldValue = z12.boolean();
929
- var NumberFieldValue = z12.number();
1016
+ var EmailValue = z13.email();
1017
+ var CheckboxFieldValue = z13.boolean();
1018
+ var NumberFieldValue = z13.number();
930
1019
  var SignatureFieldValue = FileFieldValue;
931
- var ButtonFieldValue = z12.number();
932
- var VerificationStatusValue = z12.enum([
1020
+ var ButtonFieldValue = z13.number();
1021
+ var VerificationStatusValue = z13.enum([
933
1022
  "verified",
934
1023
  "authenticated",
935
1024
  "failed",
936
1025
  "pending"
937
1026
  ]);
938
- var LeafFieldValues = z12.union([
1027
+ var LeafFieldValues = z13.union([
939
1028
  AddressFieldValue,
940
1029
  TextValue,
941
1030
  PlainDate,
@@ -961,11 +1050,11 @@ var LeafFieldValues = z12.union([
961
1050
  AutocompleteValue,
962
1051
  AutocompleteUpdateValue
963
1052
  ]);
964
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
965
- var DataFieldValue = z12.object({
966
- data: z12.record(z12.string(), LeafFieldValues)
1053
+ var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
1054
+ var DataFieldValue = z13.object({
1055
+ data: z13.record(z13.string(), LeafFieldValues)
967
1056
  }).nullish();
968
- var FieldValue = z12.union([
1057
+ var FieldValue = z13.union([
969
1058
  LeafFieldValues,
970
1059
  DataFieldValue,
971
1060
  FieldGroupValue
@@ -999,7 +1088,7 @@ function safeUnion(schemas) {
999
1088
  const sortedSchemas = [...schemas].sort(
1000
1089
  (a, b) => schemaPriority(a) - schemaPriority(b)
1001
1090
  );
1002
- return z12.any().superRefine((val, ctx) => {
1091
+ return z13.any().superRefine((val, ctx) => {
1003
1092
  for (const schema of sortedSchemas) {
1004
1093
  if (schema.safeParse(val).success) {
1005
1094
  return;
@@ -1038,9 +1127,9 @@ var FieldUpdateValue = safeUnion([
1038
1127
  ]);
1039
1128
 
1040
1129
  // ../commons/src/events/serializers/user/serializer.ts
1041
- var z13 = __toESM(require("zod/v4"));
1042
- var SerializedUserField = z13.object({
1043
- $userField: z13.enum([
1130
+ var z14 = __toESM(require("zod/v4"));
1131
+ var SerializedUserField = z14.object({
1132
+ $userField: z14.enum([
1044
1133
  "id",
1045
1134
  "name",
1046
1135
  "role",
@@ -1054,7 +1143,7 @@ var SerializedUserField = z13.object({
1054
1143
  "primaryOfficeId",
1055
1144
  "administrativeAreaId"
1056
1145
  ]),
1057
- $location: z13.string().optional()
1146
+ $location: z14.string().optional()
1058
1147
  });
1059
1148
  function userSerializer(userField) {
1060
1149
  return {
@@ -1080,27 +1169,22 @@ var import_v4 = require("zod/v4");
1080
1169
  var z16 = __toESM(require("zod/v4"));
1081
1170
 
1082
1171
  // ../commons/src/events/ActionDocument.ts
1083
- var z14 = __toESM(require("zod/v4"));
1084
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1172
+ var z15 = __toESM(require("zod/v4"));
1173
+ var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1085
1174
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1086
1175
  );
1087
- var EventState = z14.record(z14.string(), FieldValue).describe(
1176
+ var EventState = z15.record(z15.string(), FieldValue).describe(
1088
1177
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1089
1178
  );
1090
- var ActionStatus = {
1091
- Requested: "Requested",
1092
- Accepted: "Accepted",
1093
- Rejected: "Rejected"
1094
- };
1095
- var ActionBase = z14.object({
1179
+ var ActionBase = z15.object({
1096
1180
  id: UUID.describe("Unique identifier of the action."),
1097
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1181
+ transactionId: z15.string().describe("Unique identifier of the transaction."),
1098
1182
  createdByUserType: TokenUserType.describe(
1099
1183
  "Indicates whether the action was created by a human-user or by a system-user."
1100
1184
  ),
1101
- createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1102
- createdBy: z14.string().describe("Identifier of the user who created the action."),
1103
- createdByRole: z14.string().optional().describe("Role of the user who created the action."),
1185
+ createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1186
+ createdBy: z15.string().describe("Identifier of the user who created the action."),
1187
+ createdByRole: z15.string().optional().describe("Role of the user who created the action."),
1104
1188
  createdBySignature: DocumentPath.nullish().describe(
1105
1189
  "Reference to the signature of the user who created the action."
1106
1190
  ),
@@ -1112,7 +1196,7 @@ var ActionBase = z14.object({
1112
1196
  "Declaration data defined by the ActionConfig. Supports partial updates."
1113
1197
  ),
1114
1198
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1115
- status: z14.enum([
1199
+ status: z15.enum([
1116
1200
  ActionStatus.Requested,
1117
1201
  ActionStatus.Accepted,
1118
1202
  ActionStatus.Rejected
@@ -1124,139 +1208,146 @@ var ActionBase = z14.object({
1124
1208
  )
1125
1209
  });
1126
1210
  var AssignedAction = ActionBase.extend(
1127
- z14.object({
1128
- type: z14.literal(ActionType.ASSIGN),
1129
- assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
1211
+ z15.object({
1212
+ type: z15.literal(ActionType.ASSIGN),
1213
+ assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1130
1214
  // TODO move into 'content' property
1131
1215
  }).shape
1132
1216
  );
1133
1217
  var UnassignedAction = ActionBase.extend(
1134
- z14.object({
1135
- type: z14.literal(ActionType.UNASSIGN)
1218
+ z15.object({
1219
+ type: z15.literal(ActionType.UNASSIGN)
1136
1220
  }).shape
1137
1221
  );
1138
1222
  var RegisterAction = ActionBase.extend(
1139
- z14.object({
1140
- type: z14.literal(ActionType.REGISTER),
1141
- registrationNumber: z14.string().optional().describe(
1223
+ z15.object({
1224
+ type: z15.literal(ActionType.REGISTER),
1225
+ registrationNumber: z15.string().optional().describe(
1142
1226
  "Registration number of the event. Always present for accepted registrations."
1143
1227
  )
1144
1228
  // TODO move into 'content' property
1145
1229
  }).shape
1146
1230
  );
1147
1231
  var DeclareAction = ActionBase.extend(
1148
- z14.object({
1149
- type: z14.literal(ActionType.DECLARE)
1232
+ z15.object({
1233
+ type: z15.literal(ActionType.DECLARE)
1150
1234
  }).shape
1151
1235
  );
1152
- var ReasonContent = z14.object({
1153
- reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1236
+ var ReasonContent = z15.object({
1237
+ reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
1154
1238
  "Message describing the reason for rejecting or archiving the event."
1155
1239
  )
1156
1240
  });
1157
1241
  var RejectAction = ActionBase.extend(
1158
- z14.object({
1159
- type: z14.literal(ActionType.REJECT),
1242
+ z15.object({
1243
+ type: z15.literal(ActionType.REJECT),
1160
1244
  content: ReasonContent
1161
1245
  }).shape
1162
1246
  );
1163
- var PotentialDuplicate = z14.object({
1247
+ var PotentialDuplicate = z15.object({
1164
1248
  id: UUID,
1165
- trackingId: z14.string()
1249
+ trackingId: z15.string()
1166
1250
  });
1167
1251
  var DuplicateDetectedAction = ActionBase.extend(
1168
- z14.object({
1169
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1170
- content: z14.object({
1171
- duplicates: z14.array(PotentialDuplicate)
1252
+ z15.object({
1253
+ type: z15.literal(ActionType.DUPLICATE_DETECTED),
1254
+ content: z15.object({
1255
+ duplicates: z15.array(PotentialDuplicate)
1172
1256
  })
1173
1257
  }).shape
1174
1258
  );
1175
1259
  var MarkNotDuplicateAction = ActionBase.extend(
1176
- z14.object({
1177
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1260
+ z15.object({
1261
+ type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1178
1262
  }).shape
1179
1263
  );
1180
1264
  var MarkAsDuplicateAction = ActionBase.extend(
1181
- z14.object({
1182
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1183
- content: z14.object({
1265
+ z15.object({
1266
+ type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1267
+ content: z15.object({
1184
1268
  duplicateOf: UUID
1185
1269
  }).optional()
1186
1270
  }).shape
1187
1271
  );
1188
1272
  var ArchiveAction = ActionBase.extend(
1189
- z14.object({
1190
- type: z14.literal(ActionType.ARCHIVE),
1273
+ z15.object({
1274
+ type: z15.literal(ActionType.ARCHIVE),
1191
1275
  content: ReasonContent
1192
1276
  }).shape
1193
1277
  );
1278
+ var UnarchiveAction = ActionBase.extend(
1279
+ z15.object({
1280
+ type: z15.literal(ActionType.UNARCHIVE)
1281
+ }).shape
1282
+ );
1194
1283
  var CreatedAction = ActionBase.extend(
1195
- z14.object({
1196
- type: z14.literal(ActionType.CREATE)
1284
+ z15.object({
1285
+ type: z15.literal(ActionType.CREATE)
1197
1286
  }).shape
1198
1287
  );
1199
1288
  var NotifiedAction = ActionBase.extend(
1200
- z14.object({
1201
- type: z14.literal(ActionType.NOTIFY)
1289
+ z15.object({
1290
+ type: z15.literal(ActionType.NOTIFY)
1202
1291
  }).shape
1203
1292
  );
1204
1293
  var EditAction = ActionBase.extend(
1205
- z14.object({
1206
- type: z14.literal(ActionType.EDIT),
1207
- content: z14.object({
1208
- comment: z14.string().describe("Comment for the edit action.").optional()
1209
- })
1294
+ z15.object({
1295
+ type: z15.literal(ActionType.EDIT),
1296
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1297
+ content: z15.object({
1298
+ comment: z15.string().describe("Comment for the edit action.").optional()
1299
+ }).optional()
1210
1300
  }).shape
1211
1301
  );
1212
- var PrintContent = z14.object({
1213
- templateId: z14.string().optional()
1302
+ var PrintContent = z15.object({
1303
+ templateId: z15.string().optional()
1214
1304
  });
1215
1305
  var PrintCertificateAction = ActionBase.extend(
1216
- z14.object({
1217
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1306
+ z15.object({
1307
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1218
1308
  content: PrintContent.optional().nullable()
1219
1309
  }).shape
1220
1310
  );
1221
1311
  var RequestedCorrectionAction = ActionBase.extend(
1222
- z14.object({
1223
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1312
+ z15.object({
1313
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1224
1314
  }).shape
1225
1315
  );
1226
1316
  var ApprovedCorrectionAction = ActionBase.extend(
1227
- z14.object({
1228
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1229
- requestId: z14.string(),
1317
+ z15.object({
1318
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1319
+ requestId: z15.string(),
1230
1320
  // TODO move into 'content' property
1231
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1321
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1232
1322
  }).shape
1233
1323
  );
1234
1324
  var RejectedCorrectionAction = ActionBase.extend(
1235
- z14.object({
1236
- type: z14.literal(ActionType.REJECT_CORRECTION),
1237
- requestId: z14.string(),
1325
+ z15.object({
1326
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1327
+ requestId: z15.string(),
1238
1328
  // TODO move into 'content' property
1239
1329
  content: ReasonContent
1240
1330
  }).shape
1241
1331
  );
1242
1332
  var ReadAction = ActionBase.extend(
1243
- z14.object({
1244
- type: z14.literal(ActionType.READ)
1333
+ z15.object({
1334
+ type: z15.literal(ActionType.READ)
1245
1335
  }).shape
1246
1336
  );
1247
1337
  var CustomAction = ActionBase.merge(
1248
- z14.object({
1249
- type: z14.literal(ActionType.CUSTOM),
1250
- customActionType: z14.string()
1338
+ z15.object({
1339
+ type: z15.literal(ActionType.CUSTOM),
1340
+ customActionType: z15.string()
1251
1341
  })
1252
1342
  );
1253
- var ActionDocument = z14.discriminatedUnion("type", [
1343
+ var ActionDocument = z15.discriminatedUnion("type", [
1254
1344
  CreatedAction.meta({ id: "CreatedAction" }),
1255
1345
  RejectAction.meta({ id: "RejectAction" }),
1256
1346
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1257
1347
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1258
1348
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1259
1349
  ArchiveAction.meta({ id: "ArchiveAction" }),
1350
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1260
1351
  NotifiedAction.meta({ id: "NotifiedAction" }),
1261
1352
  RegisterAction.meta({ id: "RegisterAction" }),
1262
1353
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1276,64 +1367,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1276
1367
  declaration: true,
1277
1368
  annotation: true
1278
1369
  }).extend(
1279
- z14.object({
1280
- type: z14.enum(ConfirmableActions),
1281
- status: z14.literal(ActionStatus.Rejected)
1370
+ z15.object({
1371
+ type: z15.enum(ConfirmableActions),
1372
+ status: z15.literal(ActionStatus.Rejected)
1282
1373
  }).shape
1283
1374
  );
1284
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1285
-
1286
- // ../commons/src/events/Flag.ts
1287
- var z15 = __toESM(require("zod/v4"));
1288
- var InherentFlags = {
1289
- INCOMPLETE: "incomplete",
1290
- REJECTED: "rejected",
1291
- CORRECTION_REQUESTED: "correction-requested",
1292
- POTENTIAL_DUPLICATE: "potential-duplicate",
1293
- /**
1294
- * This flag is set by the Edit-action and removed after the declaration or registration.
1295
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1296
- *
1297
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1298
- */
1299
- EDIT_IN_PROGRESS: "edit-in-progress"
1300
- };
1301
- var ActionFlag = z15.string().regex(
1302
- new RegExp(
1303
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1304
- ActionStatus
1305
- ).join("|").toLowerCase()})$`
1306
- ),
1307
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1308
- );
1309
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1310
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1311
- InherentFlags
1312
- ).join(", ")}`
1313
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1314
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1315
- }).describe("Custom flag identifier defined by the country config.");
1316
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1317
- var FlagConfig = z15.object({
1318
- id: CustomFlag,
1319
- requiresAction: z15.boolean().describe(
1320
- "Indicates if this flag expects an action to be performed to be cleared."
1321
- ),
1322
- label: TranslationConfig.describe("Human readable label of the flag.")
1323
- }).meta({
1324
- id: "FlagConfig",
1325
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1326
- });
1327
- var ActionFlagConfig = z15.object({
1328
- id: Flag,
1329
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1330
- conditional: Conditional.optional().describe(
1331
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1332
- )
1333
- }).meta({
1334
- id: "ActionFlagConfig",
1335
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1336
- });
1375
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1337
1376
 
1338
1377
  // ../commons/src/events/EventMetadata.ts
1339
1378
  var EventStatus = z16.enum([
@@ -1491,13 +1530,6 @@ var Range = import_v4.z.object({
1491
1530
  }).meta({
1492
1531
  id: "Range"
1493
1532
  });
1494
- var ContainsFlags = import_v4.z.object({
1495
- anyOf: import_v4.z.array(Flag).optional(),
1496
- noneOf: import_v4.z.array(Flag).optional(),
1497
- allOf: import_v4.z.array(Flag).optional()
1498
- }).meta({
1499
- id: "ContainsFlags"
1500
- });
1501
1533
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1502
1534
  id: "Within"
1503
1535
  });
@@ -2681,6 +2713,9 @@ var ActionConfigBase = z24.object({
2681
2713
  var DeclarationActionBase = ActionConfigBase.extend({
2682
2714
  deduplication: DeduplicationConfig.optional()
2683
2715
  });
2716
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2717
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2718
+ );
2684
2719
  var ReadActionConfig = ActionConfigBase.extend(
2685
2720
  z24.object({
2686
2721
  type: z24.literal(ActionType.READ),
@@ -2690,9 +2725,56 @@ var ReadActionConfig = ActionConfigBase.extend(
2690
2725
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2691
2726
  }).shape
2692
2727
  );
2693
- var NotifyConfig = ActionConfigBase.extend(
2728
+ var NotifyConfig = ActionConfigBase.extend(
2729
+ z24.object({
2730
+ type: z24.literal(ActionType.NOTIFY),
2731
+ form: actionConfirmationForm
2732
+ }).shape
2733
+ );
2734
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2735
+ z24.object({
2736
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
2737
+ label: z24.never().optional().describe(
2738
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2739
+ ),
2740
+ supportingCopy: z24.never().optional(),
2741
+ icon: z24.never().optional().describe(
2742
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2743
+ ),
2744
+ conditionals: z24.never().optional().describe(
2745
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2746
+ )
2747
+ }).shape
2748
+ );
2749
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2750
+ z24.object({
2751
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2752
+ }).shape
2753
+ );
2754
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2755
+ z24.object({
2756
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2757
+ }).shape
2758
+ );
2759
+ var AssignConfig = ActionConfigBase.extend(
2760
+ z24.object({
2761
+ type: z24.literal(ActionType.ASSIGN),
2762
+ flags: z24.never().optional().describe(
2763
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2764
+ )
2765
+ }).shape
2766
+ );
2767
+ var UnassignConfig = ActionConfigBase.extend(
2768
+ z24.object({
2769
+ type: z24.literal(ActionType.UNASSIGN),
2770
+ flags: z24.never().optional().describe(
2771
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2772
+ )
2773
+ }).shape
2774
+ );
2775
+ var DeleteConfig = ActionConfigBase.extend(
2694
2776
  z24.object({
2695
- type: z24.literal(ActionType.NOTIFY)
2777
+ type: z24.literal(ActionType.DELETE)
2696
2778
  }).shape
2697
2779
  );
2698
2780
  var DeclareConfig = DeclarationActionBase.extend(
@@ -2701,6 +2783,7 @@ var DeclareConfig = DeclarationActionBase.extend(
2701
2783
  review: DeclarationReviewConfig.describe(
2702
2784
  "Configuration of the review page fields."
2703
2785
  ),
2786
+ form: actionConfirmationForm,
2704
2787
  dialogCopy: z24.object({
2705
2788
  notify: TranslationConfig.describe(
2706
2789
  "Confirmation text for the notify action"
@@ -2716,7 +2799,13 @@ var DeclareConfig = DeclarationActionBase.extend(
2716
2799
  );
2717
2800
  var ArchiveConfig = ActionConfigBase.extend(
2718
2801
  z24.object({
2719
- type: z24.literal(ActionType.ARCHIVE)
2802
+ type: z24.literal(ActionType.ARCHIVE),
2803
+ form: actionConfirmationForm
2804
+ }).shape
2805
+ );
2806
+ var UnarchiveConfig = ActionConfigBase.extend(
2807
+ z24.object({
2808
+ type: z24.literal(ActionType.UNARCHIVE)
2720
2809
  }).shape
2721
2810
  );
2722
2811
  var EditActionConfig = ActionConfigBase.extend(
@@ -2737,12 +2826,14 @@ var EditActionConfig = ActionConfigBase.extend(
2737
2826
  );
2738
2827
  var RejectConfig = ActionConfigBase.extend(
2739
2828
  z24.object({
2740
- type: z24.literal(ActionType.REJECT)
2829
+ type: z24.literal(ActionType.REJECT),
2830
+ form: actionConfirmationForm
2741
2831
  }).shape
2742
2832
  );
2743
2833
  var RegisterConfig = DeclarationActionBase.extend(
2744
2834
  z24.object({
2745
- type: z24.literal(ActionType.REGISTER)
2835
+ type: z24.literal(ActionType.REGISTER),
2836
+ form: actionConfirmationForm
2746
2837
  }).shape
2747
2838
  );
2748
2839
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -2757,7 +2848,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2757
2848
  correctionForm: ActionFormConfig
2758
2849
  }).shape
2759
2850
  );
2760
- var CustomActionConfig = ActionConfigBase.merge(
2851
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2852
+ z24.object({
2853
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
2854
+ }).shape
2855
+ );
2856
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2857
+ z24.object({
2858
+ type: z24.literal(ActionType.REJECT_CORRECTION)
2859
+ }).shape
2860
+ );
2861
+ var CustomActionConfig = ActionConfigBase.extend(
2761
2862
  z24.object({
2762
2863
  type: z24.literal(ActionType.CUSTOM),
2763
2864
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2768,7 +2869,7 @@ var CustomActionConfig = ActionConfigBase.merge(
2768
2869
  auditHistoryLabel: TranslationConfig.describe(
2769
2870
  'The label to show in audit history for this action. For example "Approved".'
2770
2871
  )
2771
- })
2872
+ }).shape
2772
2873
  );
2773
2874
  var ActionConfig = z24.discriminatedUnion("type", [
2774
2875
  /*
@@ -2779,6 +2880,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
2779
2880
  id: "ReadActionConfig",
2780
2881
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2781
2882
  }),
2883
+ AssignConfig.meta({
2884
+ id: "AssignActionConfig",
2885
+ description: "Configuration for assigning a record to the current user."
2886
+ }),
2887
+ UnassignConfig.meta({
2888
+ id: "UnassignActionConfig",
2889
+ description: "Configuration for unassigning a record from its current assignee."
2890
+ }),
2891
+ DeleteConfig.meta({
2892
+ id: "DeleteActionConfig",
2893
+ description: "Configuration for deleting a draft record."
2894
+ }),
2782
2895
  NotifyConfig.meta({
2783
2896
  id: "NotifyActionConfig",
2784
2897
  description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
@@ -2787,6 +2900,18 @@ var ActionConfig = z24.discriminatedUnion("type", [
2787
2900
  id: "DeclareActionConfig",
2788
2901
  description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2789
2902
  }),
2903
+ DuplicateDetectedConfig.meta({
2904
+ id: "DuplicateDetectedActionConfig",
2905
+ 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."
2906
+ }),
2907
+ MarkAsDuplicateConfig.meta({
2908
+ id: "MarkAsDuplicateActionConfig",
2909
+ description: "Configuration for marking a record as a duplicate."
2910
+ }),
2911
+ MarkAsNotDuplicateConfig.meta({
2912
+ id: "MarkAsNotDuplicateActionConfig",
2913
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2914
+ }),
2790
2915
  RejectConfig.meta({
2791
2916
  id: "RejectActionConfig",
2792
2917
  description: "Configuration for rejecting a record before registration."
@@ -2803,6 +2928,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2803
2928
  id: "RequestCorrectionActionConfig",
2804
2929
  description: "Configuration for requesting a correction on a registered record."
2805
2930
  }),
2931
+ ApproveCorrectionConfig.meta({
2932
+ id: "ApproveCorrectionActionConfig",
2933
+ description: "Configuration for approving a requested correction."
2934
+ }),
2935
+ RejectCorrectionConfig.meta({
2936
+ id: "RejectCorrectionActionConfig",
2937
+ description: "Configuration for rejecting a requested correction."
2938
+ }),
2806
2939
  EditActionConfig.meta({
2807
2940
  id: "EditActionConfig",
2808
2941
  description: "Configuration for editing a record before registration."
@@ -2811,6 +2944,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2811
2944
  id: "ArchiveActionConfig",
2812
2945
  description: "Configuration for archiving a record."
2813
2946
  }),
2947
+ UnarchiveConfig.meta({
2948
+ id: "UnarchiveActionConfig",
2949
+ description: "Configuration for unarchiving a record."
2950
+ }),
2814
2951
  CustomActionConfig.meta({
2815
2952
  id: "CustomActionConfig",
2816
2953
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -3026,13 +3163,13 @@ var AdvancedSearchConfig = z28.object({
3026
3163
  });
3027
3164
 
3028
3165
  // ../commons/src/events/utils.ts
3029
- var import_lodash = require("lodash");
3166
+ var import_lodash4 = require("lodash");
3030
3167
 
3031
3168
  // ../commons/src/conditionals/validate.ts
3032
3169
  var import__ = __toESM(require("ajv/dist/2019"));
3033
3170
  var import_ajv_formats = __toESM(require("ajv-formats"));
3034
- var z31 = __toESM(require("zod/v4"));
3035
- var import_date_fns = require("date-fns");
3171
+ var z32 = __toESM(require("zod/v4"));
3172
+ var import_date_fns2 = require("date-fns");
3036
3173
 
3037
3174
  // ../commons/src/events/FieldTypeMapping.ts
3038
3175
  var z30 = __toESM(require("zod/v4"));
@@ -3040,204 +3177,300 @@ var z30 = __toESM(require("zod/v4"));
3040
3177
  // ../commons/src/events/DynamicFieldValue.ts
3041
3178
  var z29 = __toESM(require("zod/v4"));
3042
3179
 
3043
- // ../commons/src/conditionals/validate.ts
3044
- var ajv = new import__.default({
3045
- $data: true,
3046
- allowUnionTypes: true,
3047
- strict: false
3048
- // Allow minContains and other newer features
3049
- });
3050
- var DataContext = z31.object({
3051
- rootData: z31.object({
3052
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3180
+ // ../commons/src/events/state/index.ts
3181
+ var import_lodash3 = require("lodash");
3182
+
3183
+ // ../commons/src/utils.ts
3184
+ var z31 = __toESM(require("zod/v4"));
3185
+ var _ = __toESM(require("lodash"));
3186
+ function getOrThrow(x, message) {
3187
+ if (x === void 0 || x === null) {
3188
+ throw new Error(message);
3189
+ }
3190
+ return x;
3191
+ }
3192
+ function joinValues(values, separator = " ") {
3193
+ return values.filter((value) => !!value).join(separator).trim();
3194
+ }
3195
+ var FullNameV1 = z31.array(
3196
+ z31.object({
3197
+ use: z31.string(),
3198
+ family: z31.string(),
3199
+ given: z31.array(z31.string())
3053
3200
  })
3054
- });
3055
- function resolveDataPath(rootData, dataPath, instancePath) {
3056
- const pathParts = dataPath.split("/");
3057
- const levels = parseInt(pathParts[0], 10);
3058
- const referencePath = pathParts.slice(1);
3059
- const instanceParts = instancePath.split("/").filter(Boolean);
3060
- const traversedParts = instanceParts.slice(0, -levels);
3061
- let current = rootData;
3062
- for (const part of traversedParts) {
3063
- if (current === null || current === void 0) {
3064
- return void 0;
3065
- }
3066
- current = current[part];
3201
+ );
3202
+ function omitKeyDeep(obj, keyToRemove) {
3203
+ if (Array.isArray(obj)) {
3204
+ return obj.map((item) => omitKeyDeep(item, keyToRemove));
3067
3205
  }
3068
- for (const part of referencePath) {
3069
- if (current === null || current === void 0) {
3070
- return void 0;
3206
+ if (obj === null || typeof obj !== "object") {
3207
+ return obj;
3208
+ }
3209
+ const newObj = {};
3210
+ for (const key of Object.keys(obj)) {
3211
+ if (key !== keyToRemove) {
3212
+ newObj[key] = omitKeyDeep(obj[key], keyToRemove);
3071
3213
  }
3072
- current = current[part];
3073
3214
  }
3074
- return current;
3215
+ return newObj;
3075
3216
  }
3076
- function todayISO() {
3077
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3217
+
3218
+ // ../commons/src/events/state/utils.ts
3219
+ var import_lodash = require("lodash");
3220
+ function getActionRequests(actionType, actions) {
3221
+ const filtered = actions.filter((action) => action.type === actionType).reverse();
3222
+ const accept = filtered.find(
3223
+ (action) => action.status === ActionStatus.Accepted
3224
+ );
3225
+ const request = filtered.find(
3226
+ (action) => action.status === ActionStatus.Requested
3227
+ );
3228
+ const reject = filtered.find(
3229
+ (action) => action.status === ActionStatus.Rejected
3230
+ );
3231
+ return {
3232
+ reject,
3233
+ accept,
3234
+ request
3235
+ };
3078
3236
  }
3079
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3080
- function compileClientFunction(code) {
3081
- let fn = compiledFunctionCache.get(code);
3082
- if (!fn) {
3083
- fn = new Function(`return (${code})`)();
3084
- compiledFunctionCache.set(code, fn);
3237
+ function getDeclarationActionCreationMetadata(actionType, actions) {
3238
+ const { accept: acceptAction, request: requestAction } = getActionRequests(
3239
+ actionType,
3240
+ actions
3241
+ );
3242
+ if (!acceptAction) {
3243
+ return null;
3085
3244
  }
3086
- return fn;
3087
- }
3088
- (0, import_ajv_formats.default)(ajv);
3089
- function buildClientFunctionContext(input) {
3245
+ const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3090
3246
  return {
3091
- $form: input.form,
3092
- $now: todayISO(),
3093
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3094
- $online: isOnline(),
3095
- $user: input.validatorContext?.user,
3096
- $event: input.validatorContext?.event,
3097
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3098
- user: input.systemVariables?.user,
3099
- $window: input.systemVariables?.$window,
3100
- locations: input.locations,
3101
- adminLevelIds: input.adminLevelIds
3247
+ // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3248
+ createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3249
+ createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3250
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3251
+ createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3252
+ acceptedAt: acceptAction.createdAt,
3253
+ createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3254
+ registrationNumber
3102
3255
  };
3103
3256
  }
3104
- function runClientFunction(code, data, context) {
3105
- return compileClientFunction(code)(data, context);
3257
+ var updateActions = ActionTypes.extract([
3258
+ ActionType.CREATE,
3259
+ ActionType.NOTIFY,
3260
+ ActionType.EDIT,
3261
+ ActionType.DECLARE,
3262
+ ActionType.REGISTER,
3263
+ ActionType.REJECT,
3264
+ ActionType.ARCHIVE,
3265
+ ActionType.UNARCHIVE,
3266
+ ActionType.PRINT_CERTIFICATE,
3267
+ ActionType.REQUEST_CORRECTION,
3268
+ ActionType.APPROVE_CORRECTION,
3269
+ ActionType.REJECT_CORRECTION,
3270
+ ActionType.CUSTOM
3271
+ ]);
3272
+ function getActionUpdateMetadata(actions) {
3273
+ const createAction = getOrThrow(
3274
+ actions.find((action) => action.type === ActionType.CREATE),
3275
+ `Event has no ${ActionType.CREATE} action`
3276
+ );
3277
+ const metadataFields = [
3278
+ "createdAt",
3279
+ "createdBy",
3280
+ "createdByUserType",
3281
+ "createdAtLocation",
3282
+ "createdByRole"
3283
+ ];
3284
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3285
+ (_2, action) => {
3286
+ if (action.originalActionId) {
3287
+ const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3288
+ return (0, import_lodash.pick)(originalAction, metadataFields);
3289
+ }
3290
+ return (0, import_lodash.pick)(action, metadataFields);
3291
+ },
3292
+ (0, import_lodash.pick)(createAction, metadataFields)
3293
+ );
3106
3294
  }
3107
- ajv.addKeyword({
3108
- keyword: "daysFromDate",
3109
- type: "string",
3110
- schemaType: "object",
3111
- $data: true,
3112
- errors: true,
3113
- validate(schema, data, _2, dataContext) {
3114
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3115
- throw new Error("Validation context must contain $now");
3116
- }
3117
- const { days, clause } = schema;
3118
- if (typeof data !== "string") {
3119
- return false;
3120
- }
3121
- const date = new Date(data);
3122
- if (isNaN(date.getTime())) {
3123
- return false;
3124
- }
3125
- let referenceDate = schema.referenceDate;
3126
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3127
- referenceDate = resolveDataPath(
3128
- dataContext.rootData,
3129
- referenceDate.$data,
3130
- dataContext.instancePath
3131
- );
3132
- }
3133
- if (!referenceDate) {
3134
- referenceDate = dataContext.rootData.$now;
3135
- }
3136
- const baseDate = new Date(referenceDate);
3137
- if (isNaN(baseDate.getTime())) {
3138
- return false;
3295
+ function getLegalStatuses(actions) {
3296
+ return {
3297
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3298
+ ActionType.NOTIFY,
3299
+ actions
3300
+ ),
3301
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3302
+ ActionType.DECLARE,
3303
+ actions
3304
+ ),
3305
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3306
+ ActionType.REGISTER,
3307
+ actions
3308
+ )
3309
+ };
3310
+ }
3311
+
3312
+ // ../commons/src/events/state/flags.ts
3313
+ var import_lodash2 = require("lodash");
3314
+ var import_date_fns = require("date-fns");
3315
+ function isFlagConditionMet(conditional, form, action) {
3316
+ const now2 = (0, import_date_fns.isValid)((0, import_date_fns.parseISO)(action.createdAt)) ? (0, import_date_fns.formatISO)((0, import_date_fns.parseISO)(action.createdAt), { representation: "date" }) : (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3317
+ return validate(conditional, {
3318
+ $form: form,
3319
+ $now: now2,
3320
+ $online: true,
3321
+ $user: {
3322
+ sub: "",
3323
+ exp: "",
3324
+ role: action.createdByRole,
3325
+ algorithm: "",
3326
+ scope: [],
3327
+ userType: action.createdByUserType
3139
3328
  }
3140
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3141
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3142
- }
3143
- });
3144
- ajv.addKeyword({
3145
- keyword: "isLeafLevelLocation",
3146
- type: "string",
3147
- schemaType: "boolean",
3148
- $data: true,
3149
- errors: true,
3150
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3151
- validate(_schema, data, _2, dataContext) {
3152
- const locationIdInput = data;
3153
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3154
- return locations.some((location) => location.id === locationIdInput);
3155
- }
3156
- });
3157
- ajv.addKeyword({
3158
- keyword: "customClientValidator",
3159
- schemaType: "object",
3160
- errors: true,
3161
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3162
- // `validate()` callers build root data via `buildClientFunctionContext`,
3163
- // so the cast holds.
3164
- validate(schema, data, _2, dataContext) {
3165
- return Boolean(
3166
- runClientFunction(
3167
- schema.code,
3168
- data,
3169
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3170
- )
3171
- );
3329
+ });
3330
+ }
3331
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3332
+ if (!isActionConfigType(action.type)) {
3333
+ return false;
3172
3334
  }
3173
- });
3174
- function isOnline() {
3175
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3176
- return navigator.onLine;
3335
+ const actionConfig = getActionConfig({
3336
+ eventConfiguration,
3337
+ actionType: action.type,
3338
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3339
+ });
3340
+ const removeOperations = (actionConfig?.flags ?? []).filter(
3341
+ ({ id, operation }) => id === flagId && operation === "remove"
3342
+ );
3343
+ if (removeOperations.length === 0) {
3344
+ return false;
3177
3345
  }
3178
- return true;
3346
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3347
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3348
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3349
+ const form = { ...declaration, ...annotation };
3350
+ return removeOperations.some(
3351
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3352
+ );
3179
3353
  }
3180
-
3181
- // ../commons/src/utils.ts
3182
- var z32 = __toESM(require("zod/v4"));
3183
- var _ = __toESM(require("lodash"));
3184
- var FullNameV1 = z32.array(
3185
- z32.object({
3186
- use: z32.string(),
3187
- family: z32.string(),
3188
- given: z32.array(z32.string())
3189
- })
3190
- );
3191
- function omitKeyDeep(obj, keyToRemove) {
3192
- if (Array.isArray(obj)) {
3193
- return obj.map((item) => omitKeyDeep(item, keyToRemove));
3194
- }
3195
- if (obj === null || typeof obj !== "object") {
3196
- return obj;
3354
+ var INHERENT_FLAG_RULES = [
3355
+ {
3356
+ flag: InherentFlags.CORRECTION_REQUESTED,
3357
+ setOn: [ActionType.REQUEST_CORRECTION],
3358
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3359
+ },
3360
+ {
3361
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3362
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3363
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3364
+ // round trip and comes back exactly as it was.
3365
+ flag: InherentFlags.INCOMPLETE,
3366
+ setOn: [ActionType.NOTIFY],
3367
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3368
+ },
3369
+ {
3370
+ flag: InherentFlags.REJECTED,
3371
+ setOn: [ActionType.REJECT],
3372
+ resetOn: [
3373
+ ActionType.NOTIFY,
3374
+ ActionType.DECLARE,
3375
+ ActionType.EDIT,
3376
+ ActionType.REGISTER
3377
+ ]
3378
+ },
3379
+ {
3380
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3381
+ setOn: [ActionType.DUPLICATE_DETECTED],
3382
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3383
+ },
3384
+ {
3385
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3386
+ setOn: [ActionType.EDIT],
3387
+ resetOnAnyOtherAction: true
3197
3388
  }
3198
- const newObj = {};
3199
- for (const key of Object.keys(obj)) {
3200
- if (key !== keyToRemove) {
3201
- newObj[key] = omitKeyDeep(obj[key], keyToRemove);
3389
+ ];
3390
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3391
+ return acceptedActions.reduce((present, action, idx) => {
3392
+ if (rule.setOn.includes(action.type)) {
3393
+ return true;
3202
3394
  }
3203
- }
3204
- return newObj;
3395
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3396
+ return false;
3397
+ }
3398
+ if (actionConfigRemovesFlag(
3399
+ action,
3400
+ rule.flag,
3401
+ acceptedActions.slice(0, idx + 1),
3402
+ event2,
3403
+ eventConfiguration
3404
+ )) {
3405
+ return false;
3406
+ }
3407
+ return present;
3408
+ }, false);
3205
3409
  }
3206
-
3207
- // ../commons/src/events/utils.ts
3208
- var import_date_fns2 = require("date-fns");
3209
- function getDeclarationFields(configuration) {
3210
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3410
+ function resolveEventCustomFlags(event2, eventConfiguration) {
3411
+ const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3412
+ return actions.reduce((acc, action, idx) => {
3413
+ let actionConfig;
3414
+ if (isActionConfigType(action.type)) {
3415
+ actionConfig = getActionConfig({
3416
+ eventConfiguration,
3417
+ actionType: action.type,
3418
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3419
+ });
3420
+ }
3421
+ if (!actionConfig) {
3422
+ return acc;
3423
+ }
3424
+ const eventUpToThisAction = {
3425
+ ...event2,
3426
+ actions: actions.slice(0, idx + 1)
3427
+ };
3428
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3429
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3430
+ const form = { ...declaration, ...annotation };
3431
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3432
+ ({ conditional }) => (
3433
+ // If conditional is not provided, the flag is resolved
3434
+ conditional ? isFlagConditionMet(conditional, form, action) : true
3435
+ )
3436
+ );
3437
+ const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3438
+ const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3439
+ const flags = [...acc, ...addedFlags].filter(
3440
+ (flagId) => !removedFlags.includes(flagId)
3441
+ );
3442
+ return (0, import_lodash2.uniq)(flags);
3443
+ }, []);
3211
3444
  }
3212
- var getActionAnnotationFields = (actionConfig) => {
3213
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3214
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3215
- }
3216
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3217
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3218
- }
3219
- if (actionConfig.type === ActionType.CUSTOM) {
3220
- return actionConfig.form;
3221
- }
3222
- if ("review" in actionConfig && actionConfig.review != null) {
3223
- return actionConfig.review.fields;
3224
- }
3225
- return [];
3226
- };
3227
- function getAllAnnotationFields(config) {
3228
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3445
+ function getActionStatusFlags(sortedActions) {
3446
+ const actionStatus = sortedActions.reduce(
3447
+ (actionStatuses, { type, status }) => ({
3448
+ ...actionStatuses,
3449
+ [type]: status
3450
+ }),
3451
+ {}
3452
+ );
3453
+ return Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
3454
+ const flag = joinValues([type, status], ":").toLowerCase();
3455
+ return flag;
3456
+ });
3457
+ }
3458
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
3459
+ const acceptedActions = sortedActions.filter(
3460
+ ({ status }) => status === ActionStatus.Accepted
3461
+ );
3462
+ return INHERENT_FLAG_RULES.filter(
3463
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3464
+ ).map(({ flag }) => flag);
3465
+ }
3466
+ function getEventFlags(event2, config) {
3467
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3468
+ return [
3469
+ ...getActionStatusFlags(sortedActions),
3470
+ ...getInherentFlags(sortedActions, event2, config),
3471
+ ...resolveEventCustomFlags(event2, config)
3472
+ ];
3229
3473
  }
3230
- var findAllFields = (config) => {
3231
- return (0, import_lodash.flattenDeep)([
3232
- ...getDeclarationFields(config),
3233
- ...getAllAnnotationFields(config)
3234
- ]);
3235
- };
3236
- var EXCLUDED_ACTIONS = [
3237
- ActionType.REQUEST_CORRECTION,
3238
- ActionType.PRINT_CERTIFICATE,
3239
- ActionType.REJECT_CORRECTION
3240
- ];
3241
3474
 
3242
3475
  // ../commons/src/conditionals/conditionals.ts
3243
3476
  var objectHash = __toESM(require("object-hash"));
@@ -3766,84 +3999,590 @@ function createFieldConditionals(fieldId) {
3766
3999
  },
3767
4000
  this.$$subfield
3768
4001
  )
3769
- },
3770
- required: [fieldId]
3771
- });
3772
- },
3773
- getId: () => ({ fieldId }),
3774
- /**
3775
- * @deprecated
3776
- * use field(fieldId).get(nestedProperty) instead
3777
- * with 'and' combinator e.g.
3778
- * and(
3779
- * field('child.name').get('firstname').isEqualTo('John'),
3780
- * field('child.name').get('surname').isEqualTo('Doe')
3781
- * )
3782
- */
3783
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3784
- object: (options) => defineFormConditional({
3785
- type: "object",
3786
- properties: {
3787
- [fieldId]: {
3788
- type: "object",
3789
- properties: Object.fromEntries(
3790
- Object.entries(options).map(([key, value]) => {
3791
- return [key, value.properties.$form.properties[key]];
3792
- })
3793
- ),
3794
- required: Object.keys(options)
4002
+ },
4003
+ required: [fieldId]
4004
+ });
4005
+ },
4006
+ getId: () => ({ fieldId }),
4007
+ /**
4008
+ * @deprecated
4009
+ * use field(fieldId).get(nestedProperty) instead
4010
+ * with 'and' combinator e.g.
4011
+ * and(
4012
+ * field('child.name').get('firstname').isEqualTo('John'),
4013
+ * field('child.name').get('surname').isEqualTo('Doe')
4014
+ * )
4015
+ */
4016
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4017
+ object: (options) => defineFormConditional({
4018
+ type: "object",
4019
+ properties: {
4020
+ [fieldId]: {
4021
+ type: "object",
4022
+ properties: Object.fromEntries(
4023
+ Object.entries(options).map(([key, value]) => {
4024
+ return [key, value.properties.$form.properties[key]];
4025
+ })
4026
+ ),
4027
+ required: Object.keys(options)
4028
+ }
4029
+ },
4030
+ required: [fieldId]
4031
+ }),
4032
+ /**
4033
+ * Custom client-side validator. The provided function is serialised and executed
4034
+ * just-in-time on the client only. External references (e.g. lodash) are not
4035
+ * available inside the function body — all logic must be self-contained.
4036
+ *
4037
+ * @example
4038
+ * field('nid').customClientValidator((value) => {
4039
+ * // LUHN check — all logic must be inline
4040
+ * const digits = String(value).split('').map(Number)
4041
+ * // ...
4042
+ * return isValid
4043
+ * })
4044
+ */
4045
+ customClientValidator(validationFn) {
4046
+ const code = validationFn.toString();
4047
+ return defineFormConditional({
4048
+ type: "object",
4049
+ properties: wrapToPath(
4050
+ { [fieldId]: { customClientValidator: { code } } },
4051
+ this.$$subfield
4052
+ ),
4053
+ required: [fieldId]
4054
+ });
4055
+ },
4056
+ /**
4057
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
4058
+ * that can be used as the `value` property or a DATA component entry.
4059
+ * The function receives the referenced field's value as the first argument and
4060
+ * the full form context as the second; its return value replaces the field reference.
4061
+ * The function is serialised and executed just-in-time on the client only.
4062
+ * External references (e.g. lodash) are not available inside the function body.
4063
+ *
4064
+ * For computing a default value without referencing a specific field, use
4065
+ * `evaluate(fn)` in the `defaultValue` property instead.
4066
+ *
4067
+ * @example
4068
+ * field('a').customClientEvaluation((aValue, ctx) =>
4069
+ * Number(aValue) + Number(ctx.$form.b)
4070
+ * )
4071
+ */
4072
+ customClientEvaluation(computationFn) {
4073
+ return {
4074
+ $$code: computationFn.toString(),
4075
+ $$field: fieldId,
4076
+ $$subfield: this.$$subfield
4077
+ };
4078
+ }
4079
+ };
4080
+ }
4081
+
4082
+ // ../commons/src/events/state/index.ts
4083
+ function getStatusFromActions(actions) {
4084
+ const acceptedActions = actions.filter(
4085
+ ({ status }) => status === ActionStatus.Accepted
4086
+ );
4087
+ const isCurrentlyArchived = acceptedActions.reduce(
4088
+ (archived, action) => {
4089
+ if (action.type === ActionType.ARCHIVE) {
4090
+ return true;
4091
+ }
4092
+ if (action.type === ActionType.UNARCHIVE) {
4093
+ return false;
4094
+ }
4095
+ return archived;
4096
+ },
4097
+ false
4098
+ );
4099
+ if (isCurrentlyArchived) {
4100
+ return EventStatus.enum.ARCHIVED;
4101
+ }
4102
+ return acceptedActions.filter(
4103
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4104
+ ).reduce((status, action) => {
4105
+ switch (action.type) {
4106
+ case ActionType.CREATE:
4107
+ return EventStatus.enum.CREATED;
4108
+ case ActionType.DECLARE:
4109
+ return EventStatus.enum.DECLARED;
4110
+ case ActionType.REGISTER:
4111
+ return EventStatus.enum.REGISTERED;
4112
+ case ActionType.NOTIFY:
4113
+ return EventStatus.enum.NOTIFIED;
4114
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
4115
+ case ActionType.ARCHIVE:
4116
+ case ActionType.UNARCHIVE:
4117
+ case ActionType.CUSTOM:
4118
+ case ActionType.PRINT_CERTIFICATE:
4119
+ case ActionType.ASSIGN:
4120
+ case ActionType.UNASSIGN:
4121
+ case ActionType.REJECT:
4122
+ case ActionType.REQUEST_CORRECTION:
4123
+ case ActionType.APPROVE_CORRECTION:
4124
+ case ActionType.DUPLICATE_DETECTED:
4125
+ case ActionType.MARK_AS_NOT_DUPLICATE:
4126
+ case ActionType.MARK_AS_DUPLICATE:
4127
+ case ActionType.REJECT_CORRECTION:
4128
+ case ActionType.READ:
4129
+ case ActionType.EDIT:
4130
+ default:
4131
+ return status;
4132
+ }
4133
+ }, EventStatus.enum.CREATED);
4134
+ }
4135
+ function getAssignedUserFromActions(actions) {
4136
+ return actions.reduce((user2, action) => {
4137
+ if (action.type === ActionType.ASSIGN) {
4138
+ return action.assignedTo;
4139
+ }
4140
+ if (action.type === ActionType.UNASSIGN) {
4141
+ return null;
4142
+ }
4143
+ return user2;
4144
+ }, null);
4145
+ }
4146
+ function deepDropNulls(obj) {
4147
+ if (Array.isArray(obj)) {
4148
+ return obj.map(deepDropNulls);
4149
+ }
4150
+ if (obj !== null && typeof obj === "object") {
4151
+ return Object.entries(obj).reduce((acc, [key, value]) => {
4152
+ const cleanedValue = deepDropNulls(value);
4153
+ if (cleanedValue !== null) {
4154
+ ;
4155
+ acc[key] = cleanedValue;
4156
+ }
4157
+ return acc;
4158
+ }, {});
4159
+ }
4160
+ return obj;
4161
+ }
4162
+ var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4163
+ function extractDateString(dateTime) {
4164
+ return dateTime.split("T")[0];
4165
+ }
4166
+ function resolveDateOfEvent(eventIndex, declaration, config) {
4167
+ if (!config.dateOfEvent) {
4168
+ return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4169
+ }
4170
+ const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4171
+ getMixedPath(eventIndex, config.dateOfEvent.$$event)
4172
+ );
4173
+ return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4174
+ }
4175
+ var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4176
+ function getParsedUUID(value, oldValue) {
4177
+ const parsed = UUID.safeParse(value);
4178
+ return parsed.success ? parsed.data : oldValue;
4179
+ }
4180
+ function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4181
+ let placeOfEvent = getParsedUUID(
4182
+ eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4183
+ );
4184
+ if (config.placeOfEvent) {
4185
+ const addressFieldValue = AddressFieldValue.safeParse(
4186
+ declaration[config.placeOfEvent.$$field]
4187
+ );
4188
+ if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4189
+ placeOfEvent = getParsedUUID(
4190
+ addressFieldValue.data.administrativeArea,
4191
+ placeOfEvent
4192
+ );
4193
+ } else {
4194
+ placeOfEvent = getParsedUUID(
4195
+ declaration[config.placeOfEvent.$$field],
4196
+ placeOfEvent
4197
+ );
4198
+ }
4199
+ }
4200
+ return placeOfEvent;
4201
+ }
4202
+ function extractPotentialDuplicatesFromActions(actions) {
4203
+ return actions.reduce((duplicates, action) => {
4204
+ if (action.type === ActionType.DUPLICATE_DETECTED) {
4205
+ duplicates = action.content.duplicates;
4206
+ }
4207
+ if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4208
+ duplicates = [];
4209
+ }
4210
+ return duplicates;
4211
+ }, []);
4212
+ }
4213
+ function getCurrentEventState(event2, config) {
4214
+ const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4215
+ const creationAction = sortedActions.find(
4216
+ (action) => action.type === ActionType.CREATE
4217
+ );
4218
+ if (!creationAction) {
4219
+ throw new Error(`Event ${event2.id} has no creation action`);
4220
+ }
4221
+ const acceptedActions = getAcceptedActions(event2).sort(
4222
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
4223
+ );
4224
+ const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4225
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4226
+ const declaration = aggregateActionDeclarations(event2);
4227
+ const status = getStatusFromActions(sortedActions);
4228
+ const legalStatuses = getLegalStatuses(sortedActions);
4229
+ const base = deepDropNulls({
4230
+ id: event2.id,
4231
+ type: event2.type,
4232
+ status,
4233
+ legalStatuses,
4234
+ createdAt: creationAction.createdAt,
4235
+ createdBy: creationAction.createdBy,
4236
+ createdByUserType: creationAction.createdByUserType,
4237
+ createdAtLocation: creationAction.createdAtLocation,
4238
+ updatedAt: acceptedActionMetadata.createdAt,
4239
+ assignedTo: getAssignedUserFromActions(acceptedActions),
4240
+ updatedBy: requestActionMetadata.createdBy,
4241
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
4242
+ declaration,
4243
+ trackingId: event2.trackingId,
4244
+ updatedByUserRole: requestActionMetadata.createdByRole,
4245
+ placeOfEvent: resolvePlaceOfEvent(
4246
+ { createdAtLocation: creationAction.createdAtLocation },
4247
+ declaration,
4248
+ config
4249
+ ),
4250
+ potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4251
+ flags: getEventFlags(event2, config)
4252
+ });
4253
+ return deepDropNulls({
4254
+ ...base,
4255
+ dateOfEvent: resolveDateOfEvent(base, declaration, config)
4256
+ });
4257
+ }
4258
+
4259
+ // ../commons/src/conditionals/validate.ts
4260
+ var ajv = new import__.default({
4261
+ $data: true,
4262
+ allowUnionTypes: true,
4263
+ strict: false
4264
+ // Allow minContains and other newer features
4265
+ });
4266
+ var DataContext = z32.object({
4267
+ rootData: z32.object({
4268
+ $leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
4269
+ })
4270
+ });
4271
+ function resolveDataPath(rootData, dataPath, instancePath) {
4272
+ const pathParts = dataPath.split("/");
4273
+ const levels = parseInt(pathParts[0], 10);
4274
+ const referencePath = pathParts.slice(1);
4275
+ const instanceParts = instancePath.split("/").filter(Boolean);
4276
+ const traversedParts = instanceParts.slice(0, -levels);
4277
+ let current = rootData;
4278
+ for (const part of traversedParts) {
4279
+ if (current === null || current === void 0) {
4280
+ return void 0;
4281
+ }
4282
+ current = current[part];
4283
+ }
4284
+ for (const part of referencePath) {
4285
+ if (current === null || current === void 0) {
4286
+ return void 0;
4287
+ }
4288
+ current = current[part];
4289
+ }
4290
+ return current;
4291
+ }
4292
+ function todayISO() {
4293
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4294
+ }
4295
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4296
+ function compileClientFunction(code) {
4297
+ let fn = compiledFunctionCache.get(code);
4298
+ if (!fn) {
4299
+ fn = new Function(`return (${code})`)();
4300
+ compiledFunctionCache.set(code, fn);
4301
+ }
4302
+ return fn;
4303
+ }
4304
+ (0, import_ajv_formats.default)(ajv);
4305
+ function buildClientFunctionContext(input) {
4306
+ const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
4307
+ input.validatorContext?.event,
4308
+ input.validatorContext?.eventConfig
4309
+ )?.flags : [];
4310
+ return {
4311
+ $form: input.form,
4312
+ $flags: flags,
4313
+ $now: todayISO(),
4314
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4315
+ $online: isOnline(),
4316
+ $user: input.validatorContext?.user,
4317
+ $event: input.validatorContext?.event,
4318
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4319
+ user: input.systemVariables?.user,
4320
+ $window: input.systemVariables?.$window,
4321
+ locations: input.locations,
4322
+ adminLevelIds: input.adminLevelIds
4323
+ };
4324
+ }
4325
+ function runClientFunction(code, data, context) {
4326
+ return compileClientFunction(code)(data, context);
4327
+ }
4328
+ ajv.addKeyword({
4329
+ keyword: "daysFromDate",
4330
+ type: "string",
4331
+ schemaType: "object",
4332
+ $data: true,
4333
+ errors: true,
4334
+ validate(schema, data, _2, dataContext) {
4335
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4336
+ throw new Error("Validation context must contain $now");
4337
+ }
4338
+ const { days, clause } = schema;
4339
+ if (typeof data !== "string") {
4340
+ return false;
4341
+ }
4342
+ const date = new Date(data);
4343
+ if (isNaN(date.getTime())) {
4344
+ return false;
4345
+ }
4346
+ let referenceDate = schema.referenceDate;
4347
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4348
+ referenceDate = resolveDataPath(
4349
+ dataContext.rootData,
4350
+ referenceDate.$data,
4351
+ dataContext.instancePath
4352
+ );
4353
+ }
4354
+ if (!referenceDate) {
4355
+ referenceDate = dataContext.rootData.$now;
4356
+ }
4357
+ const baseDate = new Date(referenceDate);
4358
+ if (isNaN(baseDate.getTime())) {
4359
+ return false;
4360
+ }
4361
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4362
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4363
+ }
4364
+ });
4365
+ ajv.addKeyword({
4366
+ keyword: "isLeafLevelLocation",
4367
+ type: "string",
4368
+ schemaType: "boolean",
4369
+ $data: true,
4370
+ errors: true,
4371
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4372
+ validate(_schema, data, _2, dataContext) {
4373
+ const locationIdInput = data;
4374
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4375
+ return locations.some((location) => location.id === locationIdInput);
4376
+ }
4377
+ });
4378
+ function isAgeValue(value) {
4379
+ return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4380
+ }
4381
+ ajv.addKeyword({
4382
+ keyword: "customClientValidator",
4383
+ schemaType: "object",
4384
+ errors: true,
4385
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4386
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4387
+ // so the cast holds.
4388
+ validate(schema, data, _2, dataContext) {
4389
+ return Boolean(
4390
+ runClientFunction(
4391
+ schema.code,
4392
+ data,
4393
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4394
+ )
4395
+ );
4396
+ }
4397
+ });
4398
+ function validate(schema, data) {
4399
+ const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4400
+ if ("$form" in data) {
4401
+ const entries = Object.entries(data.$form).map(([key, value]) => {
4402
+ if (!isAgeValue(value)) {
4403
+ return [key, value];
4404
+ }
4405
+ const age = value.age;
4406
+ const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4407
+ return [
4408
+ key,
4409
+ {
4410
+ age,
4411
+ dob: ageToDate(
4412
+ age,
4413
+ maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4414
+ )
3795
4415
  }
3796
- },
3797
- required: [fieldId]
3798
- }),
3799
- /**
3800
- * Custom client-side validator. The provided function is serialised and executed
3801
- * just-in-time on the client only. External references (e.g. lodash) are not
3802
- * available inside the function body — all logic must be self-contained.
3803
- *
3804
- * @example
3805
- * field('nid').customClientValidator((value) => {
3806
- * // LUHN check — all logic must be inline
3807
- * const digits = String(value).split('').map(Number)
3808
- * // ...
3809
- * return isValid
3810
- * })
3811
- */
3812
- customClientValidator(validationFn) {
3813
- const code = validationFn.toString();
3814
- return defineFormConditional({
3815
- type: "object",
3816
- properties: wrapToPath(
3817
- { [fieldId]: { customClientValidator: { code } } },
3818
- this.$$subfield
3819
- ),
3820
- required: [fieldId]
3821
- });
3822
- },
3823
- /**
3824
- * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3825
- * that can be used as the `value` property or a DATA component entry.
3826
- * The function receives the referenced field's value as the first argument and
3827
- * the full form context as the second; its return value replaces the field reference.
3828
- * The function is serialised and executed just-in-time on the client only.
3829
- * External references (e.g. lodash) are not available inside the function body.
3830
- *
3831
- * For computing a default value without referencing a specific field, use
3832
- * `evaluate(fn)` in the `defaultValue` property instead.
3833
- *
3834
- * @example
3835
- * field('a').customClientEvaluation((aValue, ctx) =>
3836
- * Number(aValue) + Number(ctx.$form.b)
3837
- * )
3838
- */
3839
- customClientEvaluation(computationFn) {
3840
- return {
3841
- $$code: computationFn.toString(),
3842
- $$field: fieldId,
3843
- $$subfield: this.$$subfield
3844
- };
4416
+ ];
4417
+ });
4418
+ data.$form = Object.fromEntries(entries);
4419
+ }
4420
+ const result = validator(data);
4421
+ return result;
4422
+ }
4423
+ function isOnline() {
4424
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4425
+ return navigator.onLine;
4426
+ }
4427
+ return true;
4428
+ }
4429
+
4430
+ // ../commons/src/events/utils.ts
4431
+ var import_date_fns3 = require("date-fns");
4432
+ function ageToDate(age, asOfDate) {
4433
+ const date = plainDateToLocalDate(asOfDate);
4434
+ return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4435
+ }
4436
+ function getDeclarationFields(configuration) {
4437
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4438
+ }
4439
+ function isActionConfigType(type) {
4440
+ return actionConfigTypes.has(type);
4441
+ }
4442
+ function getActionConfig({
4443
+ eventConfiguration,
4444
+ actionType,
4445
+ customActionType
4446
+ }) {
4447
+ if (actionType === ActionType.NOTIFY) {
4448
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4449
+ }
4450
+ return eventConfiguration.actions.find((a) => {
4451
+ if (a.type === ActionType.CUSTOM && customActionType) {
4452
+ return a.customActionType === customActionType;
4453
+ }
4454
+ return a.type === actionType;
4455
+ });
4456
+ }
4457
+ var getActionAnnotationFields = (actionConfig) => {
4458
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4459
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4460
+ }
4461
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4462
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4463
+ }
4464
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4465
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4466
+ return [...reviewFields, ...formFields];
4467
+ };
4468
+ function getAllAnnotationFields(config) {
4469
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4470
+ }
4471
+ function deepMerge(currentDocument, actionDocument) {
4472
+ const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4473
+ return (0, import_lodash4.mergeWith)(
4474
+ (0, import_lodash4.cloneDeep)(currentDocumentClone),
4475
+ actionDocument,
4476
+ (previousValue, incomingValue) => {
4477
+ if (incomingValue === void 0) {
4478
+ return previousValue;
4479
+ }
4480
+ if ((0, import_lodash4.isArray)(incomingValue)) {
4481
+ return incomingValue;
4482
+ }
4483
+ if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4484
+ return void 0;
4485
+ }
4486
+ return incomingValue;
4487
+ }
4488
+ );
4489
+ }
4490
+ var findAllFields = (config) => {
4491
+ return (0, import_lodash4.flattenDeep)([
4492
+ ...getDeclarationFields(config),
4493
+ ...getAllAnnotationFields(config)
4494
+ ]);
4495
+ };
4496
+ function getMixedPath(obj, path, defaultValue) {
4497
+ const parts = path.split(".");
4498
+ const resolve = (current, segments) => {
4499
+ if (current == null || segments.length === 0) {
4500
+ return current;
4501
+ }
4502
+ for (let i = segments.length; i > 0; i--) {
4503
+ const compoundKey = segments.slice(0, i).join(".");
4504
+ if ((0, import_lodash4.has)(current, compoundKey)) {
4505
+ const next = (0, import_lodash4.get)(current, compoundKey);
4506
+ return resolve(next, segments.slice(i));
4507
+ }
3845
4508
  }
4509
+ return void 0;
3846
4510
  };
4511
+ const result = resolve(obj, parts);
4512
+ return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4513
+ }
4514
+ function isAcceptedAction(a) {
4515
+ return a.status === ActionStatus.Accepted;
4516
+ }
4517
+ function getCompleteActionAnnotation(event2, action) {
4518
+ if (action.originalActionId) {
4519
+ const originalAction = event2.actions.find(
4520
+ ({ id }) => id === action.originalActionId
4521
+ );
4522
+ if (originalAction?.status === ActionStatus.Requested) {
4523
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4524
+ }
4525
+ }
4526
+ return action.annotation ?? {};
4527
+ }
4528
+ function getCompleteActionDeclaration(declaration, event2, action) {
4529
+ if (action.originalActionId) {
4530
+ const originalAction = event2.actions.find(
4531
+ ({ id }) => id === action.originalActionId
4532
+ );
4533
+ if (originalAction?.status === ActionStatus.Requested) {
4534
+ return deepMerge(
4535
+ deepMerge(declaration, originalAction.declaration),
4536
+ action.declaration
4537
+ );
4538
+ }
4539
+ }
4540
+ return deepMerge(declaration, action.declaration);
4541
+ }
4542
+ function getAcceptedActions(event2) {
4543
+ return event2.actions.filter(isAcceptedAction).map((action) => ({
4544
+ ...action,
4545
+ declaration: getCompleteActionDeclaration({}, event2, action),
4546
+ annotation: getCompleteActionAnnotation(event2, action)
4547
+ }));
4548
+ }
4549
+ var EXCLUDED_ACTIONS = [
4550
+ ActionType.REQUEST_CORRECTION,
4551
+ ActionType.PRINT_CERTIFICATE,
4552
+ ActionType.REJECT_CORRECTION
4553
+ ];
4554
+ function aggregateActionDeclarations(event2) {
4555
+ const allAcceptedActions = getAcceptedActions(event2);
4556
+ const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4557
+ return aggregatedActions.reduce((declaration, action) => {
4558
+ if (action.type === ActionType.APPROVE_CORRECTION) {
4559
+ const requestAction = allAcceptedActions.find(
4560
+ ({ id }) => id === action.requestId
4561
+ );
4562
+ if (!requestAction) {
4563
+ return declaration;
4564
+ }
4565
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4566
+ declaration,
4567
+ event2,
4568
+ requestAction
4569
+ );
4570
+ return getCompleteActionDeclaration(
4571
+ declarationWithApprovedCorrection,
4572
+ event2,
4573
+ action
4574
+ );
4575
+ }
4576
+ return getCompleteActionDeclaration(declaration, event2, action);
4577
+ }, {});
4578
+ }
4579
+ function aggregateActionAnnotations(event2) {
4580
+ return event2.actions.reduce((ann, sortedAction) => {
4581
+ if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4582
+ return ann;
4583
+ }
4584
+ return deepMerge(ann, sortedAction.annotation);
4585
+ }, {});
3847
4586
  }
3848
4587
 
3849
4588
  // ../commons/src/events/eventConfigValidation.ts
@@ -3930,7 +4669,7 @@ function validateActionFlags(event2, ctx) {
3930
4669
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3931
4670
  const configuredFlagIds = event2.flags.map((flag) => flag.id);
3932
4671
  const actionFlagIds = event2.actions.flatMap(
3933
- (action) => action.flags.map((flag) => flag.id)
4672
+ (action) => (action.flags ?? []).map((flag) => flag.id)
3934
4673
  );
3935
4674
  for (const actionFlagId of actionFlagIds) {
3936
4675
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4538,10 +5277,7 @@ var DeclareActionInput = BaseActionInput.extend(
4538
5277
  );
4539
5278
  var EditActionInput = BaseActionInput.extend(
4540
5279
  z38.object({
4541
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4542
- content: z38.object({
4543
- comment: z38.string().describe("Comment for the edit action.").optional()
4544
- })
5280
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4545
5281
  }).shape
4546
5282
  );
4547
5283
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4583,6 +5319,11 @@ var ArchiveActionInput = BaseActionInput.extend(
4583
5319
  content: ReasonContent
4584
5320
  }).shape
4585
5321
  );
5322
+ var UnarchiveActionInput = BaseActionInput.extend(
5323
+ z38.object({
5324
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
5325
+ }).shape
5326
+ );
4586
5327
  var AssignActionInput = BaseActionInput.extend(
4587
5328
  z38.object({
4588
5329
  type: z38.literal(ActionType.ASSIGN),
@@ -4644,6 +5385,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4644
5385
  id: "MarkNotDuplicateActionInput"
4645
5386
  }),
4646
5387
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
5388
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4647
5389
  AssignActionInput.meta({ id: "AssignActionInput" }),
4648
5390
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4649
5391
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4684,14 +5426,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4684
5426
 
4685
5427
  // ../commons/src/events/EventInput.ts
4686
5428
  var z40 = __toESM(require("zod/v4"));
4687
- var import_uuid10 = require("uuid");
5429
+ var import_uuid11 = require("uuid");
4688
5430
  var EventInput = z40.object({
4689
5431
  transactionId: z40.string(),
4690
5432
  type: z40.string(),
4691
5433
  createdAtLocation: UUID.nullish().describe(
4692
5434
  "Location where the event occurred. Required for system users."
4693
5435
  )
4694
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5436
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4695
5437
 
4696
5438
  // ../commons/src/events/EventDocument.ts
4697
5439
  var z41 = __toESM(require("zod/v4"));
@@ -4708,69 +5450,6 @@ var EventDocument = z41.object({
4708
5450
  )
4709
5451
  }).meta({ id: "EventDocument" });
4710
5452
 
4711
- // ../commons/src/events/state/index.ts
4712
- var import_lodash4 = require("lodash");
4713
-
4714
- // ../commons/src/events/state/utils.ts
4715
- var import_lodash2 = require("lodash");
4716
- var updateActions = ActionTypes.extract([
4717
- ActionType.CREATE,
4718
- ActionType.NOTIFY,
4719
- ActionType.EDIT,
4720
- ActionType.DECLARE,
4721
- ActionType.REGISTER,
4722
- ActionType.REJECT,
4723
- ActionType.ARCHIVE,
4724
- ActionType.PRINT_CERTIFICATE,
4725
- ActionType.REQUEST_CORRECTION,
4726
- ActionType.APPROVE_CORRECTION,
4727
- ActionType.REJECT_CORRECTION,
4728
- ActionType.CUSTOM
4729
- ]);
4730
-
4731
- // ../commons/src/events/state/flags.ts
4732
- var import_lodash3 = require("lodash");
4733
- var import_date_fns3 = require("date-fns");
4734
- var INHERENT_FLAG_RULES = [
4735
- {
4736
- flag: InherentFlags.CORRECTION_REQUESTED,
4737
- setOn: [ActionType.REQUEST_CORRECTION],
4738
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4739
- },
4740
- {
4741
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4742
- // other status-changing action (see getStatusFromActions).
4743
- flag: InherentFlags.INCOMPLETE,
4744
- setOn: [ActionType.NOTIFY],
4745
- resetOn: [
4746
- ActionType.CREATE,
4747
- ActionType.DECLARE,
4748
- ActionType.REGISTER,
4749
- ActionType.ARCHIVE
4750
- ]
4751
- },
4752
- {
4753
- flag: InherentFlags.REJECTED,
4754
- setOn: [ActionType.REJECT],
4755
- resetOn: [
4756
- ActionType.NOTIFY,
4757
- ActionType.DECLARE,
4758
- ActionType.EDIT,
4759
- ActionType.REGISTER
4760
- ]
4761
- },
4762
- {
4763
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4764
- setOn: [ActionType.DUPLICATE_DETECTED],
4765
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4766
- },
4767
- {
4768
- flag: InherentFlags.EDIT_IN_PROGRESS,
4769
- setOn: [ActionType.EDIT],
4770
- resetOnAnyOtherAction: true
4771
- }
4772
- ];
4773
-
4774
5453
  // ../commons/src/events/defineConfig.ts
4775
5454
  var IGNORED_EVENT_TYPES = [
4776
5455
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7279,6 +7958,7 @@ var ACTION_SCOPE_MAP = {
7279
7958
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7280
7959
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7281
7960
  [ActionType.ARCHIVE]: ["record.archive"],
7961
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
7282
7962
  [ActionType.REJECT]: ["record.reject"],
7283
7963
  [ActionType.ASSIGN]: null,
7284
7964
  [ActionType.UNASSIGN]: null,
@@ -7321,7 +8001,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7321
8001
  ActionType.CUSTOM,
7322
8002
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7323
8003
  ],
7324
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
8004
+ [EventStatus.enum.ARCHIVED]: [
8005
+ ActionType.READ,
8006
+ ActionType.CUSTOM,
8007
+ ActionType.UNARCHIVE
8008
+ ]
7325
8009
  };
7326
8010
  var ACTION_FILTERS = {
7327
8011
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
@@ -7334,6 +8018,7 @@ var ACTION_FILTERS = {
7334
8018
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7335
8019
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7336
8020
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
8021
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7337
8022
  [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7338
8023
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7339
8024
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))