@opencrvs/toolkit 2.1.0-rc.fa9aecf → 2.1.0-rc.fc582d7

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 (70) hide show
  1. package/dist/application-config/index.js +202 -190
  2. package/dist/cli.js +0 -48
  3. package/dist/commons/api/router.d.ts +3342 -3359
  4. package/dist/commons/application-config/index.d.ts +6 -6
  5. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  6. package/dist/commons/conditionals/validate.d.ts +10 -1
  7. package/dist/commons/events/ActionConfig.d.ts +126 -105
  8. package/dist/commons/events/ActionDocument.d.ts +117 -123
  9. package/dist/commons/events/ActionInput.d.ts +0 -6
  10. package/dist/commons/events/ActionStatus.d.ts +14 -0
  11. package/dist/commons/events/ActionType.d.ts +62 -62
  12. package/dist/commons/events/AdvancedSearchConfig.d.ts +513 -507
  13. package/dist/commons/events/AuditLog.d.ts +43 -43
  14. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  15. package/dist/commons/events/Conditional.d.ts +3 -3
  16. package/dist/commons/events/CountryConfigQueryInput.d.ts +608 -590
  17. package/dist/commons/events/Draft.d.ts +37 -37
  18. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  19. package/dist/commons/events/EventConfig.d.ts +8 -5
  20. package/dist/commons/events/EventDocument.d.ts +48 -48
  21. package/dist/commons/events/EventIndex.d.ts +52 -71
  22. package/dist/commons/events/EventMetadata.d.ts +41 -40
  23. package/dist/commons/events/FieldConfig.d.ts +341 -336
  24. package/dist/commons/events/FieldType.d.ts +51 -51
  25. package/dist/commons/events/FieldTypeMapping.d.ts +91 -91
  26. package/dist/commons/events/FieldValue.d.ts +12 -12
  27. package/dist/commons/events/Flag.d.ts +63 -15
  28. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  29. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  30. package/dist/commons/events/WorkqueueConfig.d.ts +832 -814
  31. package/dist/commons/events/deduplication.d.ts +1 -1
  32. package/dist/commons/events/event.d.ts +14 -2
  33. package/dist/commons/events/field.d.ts +69 -198
  34. package/dist/commons/events/locations.d.ts +96 -6
  35. package/dist/commons/events/mocks.test.utils.d.ts +18 -4
  36. package/dist/commons/events/scopes.d.ts +4 -4
  37. package/dist/commons/events/state/index.d.ts +17 -17
  38. package/dist/commons/events/state/utils.d.ts +7 -7
  39. package/dist/commons/events/test.utils.d.ts +40 -43
  40. package/dist/commons/events/utils.d.ts +114 -114
  41. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  42. package/dist/conditionals/index.js +303 -55
  43. package/dist/environment/derived-variables.d.ts +119 -131
  44. package/dist/environment/derived-variables.d.ts.map +1 -1
  45. package/dist/environment/derived-variables.js +0 -14
  46. package/dist/environment/logger.d.ts +3 -12
  47. package/dist/environment/logger.d.ts.map +1 -1
  48. package/dist/environment/manage-users.js +17 -7
  49. package/dist/environment/questions.d.ts +75 -74
  50. package/dist/environment/questions.d.ts.map +1 -1
  51. package/dist/environment/setup-environment.js +8 -28
  52. package/dist/environment/swarm-to-k8s.js +17 -7
  53. package/dist/environment/update-workflows.js +17 -7
  54. package/dist/environment/users.js +17 -7
  55. package/dist/environment/utils.d.ts +1 -1
  56. package/dist/environment/utils.js +17 -7
  57. package/dist/events/deduplication.d.ts +1 -1
  58. package/dist/events/index.js +3355 -3279
  59. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  60. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  61. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  62. package/dist/notification/index.js +1615 -1020
  63. package/dist/scopes/index.d.ts +396 -146
  64. package/dist/scopes/index.js +304 -55
  65. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  66. package/dist/templates/charts-values/opencrvs-services/values.yaml +0 -4
  67. package/opencrvs-toolkit-2.1.0-rc.fc582d7.tgz +0 -0
  68. package/package.json +5 -5
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/opencrvs-toolkit-2.1.0-rc.fa9aecf.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",
@@ -88,7 +340,7 @@ var RecordScopeTypeV2 = z2.enum([
88
340
  "record.unassign-others",
89
341
  "record.custom-action"
90
342
  ]);
91
- var PlainScopeType = z2.enum([
343
+ var PlainScopeType = z6.enum([
92
344
  // Misc. system scopes
93
345
  "bypassratelimit",
94
346
  "record.reindex",
@@ -107,15 +359,15 @@ var PlainScopeType = z2.enum([
107
359
  "record.confirm-registration",
108
360
  "record.reject-registration"
109
361
  ]);
110
- var scopeByEvent = z2.preprocess(
362
+ var scopeByEvent = z6.preprocess(
111
363
  (val) => val === void 0 ? void 0 : [val].flat(),
112
- z2.array(z2.string()).optional()
364
+ z6.array(z6.string()).optional()
113
365
  ).describe("Event type, e.g. birth, death");
114
- var userRole = z2.preprocess(
366
+ var userRole = z6.preprocess(
115
367
  (val) => val === void 0 ? void 0 : [val].flat(),
116
- z2.array(z2.string()).optional()
368
+ z6.array(z6.string()).optional()
117
369
  ).describe("User role, e.g. admin, field agent");
118
- var scopeOptionsPlaceEvent = z2.object({
370
+ var scopeOptionsPlaceEvent = z6.object({
119
371
  event: scopeByEvent,
120
372
  placeOfEvent: JurisdictionFilter.optional()
121
373
  }).describe("Options applicable to all record scopes.");
@@ -127,36 +379,37 @@ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
127
379
  }).describe("Options applicable to actions that may take place after DECLARE");
128
380
  var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
129
381
  registeredIn: JurisdictionFilter.optional(),
130
- registeredBy: UserFilter.optional()
382
+ registeredBy: UserFilter.optional(),
383
+ flags: ContainsFlags.optional()
131
384
  }).describe(
132
385
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
133
386
  );
134
387
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
135
- customActionTypes: z2.preprocess(
388
+ customActionTypes: z6.preprocess(
136
389
  (val) => val === void 0 ? void 0 : [val].flat(),
137
- z2.array(z2.string()).optional()
390
+ z6.array(z6.string()).optional()
138
391
  ).describe("Allowed custom action types")
139
392
  });
140
- var AccessLevelOptions = z2.object({
393
+ var AccessLevelOptions = z6.object({
141
394
  accessLevel: JurisdictionFilter.optional()
142
395
  });
143
396
  var AllUserScopeOptions = AccessLevelOptions.extend({
144
397
  role: userRole.optional()
145
398
  });
146
- var WorkqueueOrDashboardOptions = z2.object({
147
- ids: z2.preprocess(
399
+ var WorkqueueOrDashboardOptions = z6.object({
400
+ ids: z6.preprocess(
148
401
  (val) => val === void 0 ? void 0 : [val].flat(),
149
- z2.array(z2.string())
402
+ z6.array(z6.string())
150
403
  ).describe("Must contain a list of workqueue or dashboard ids.")
151
404
  });
152
- var AllScopeOptions = z2.object({
405
+ var AllScopeOptions = z6.object({
153
406
  ...AllRecordScopeOptions.shape,
154
407
  ...AccessLevelOptions.shape,
155
408
  ...AllUserScopeOptions.shape,
156
409
  ...WorkqueueOrDashboardOptions.shape
157
410
  });
158
411
  var ScopeOptionKey = AllScopeOptions.keyof();
159
- var ResolvedScopeOptionsPlaceEvent = z2.object({
412
+ var ResolvedScopeOptionsPlaceEvent = z6.object({
160
413
  event: scopeByEvent,
161
414
  placeOfEvent: UUID.nullish()
162
415
  }).describe(
@@ -164,15 +417,16 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
164
417
  );
165
418
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
166
419
  notifiedIn: UUID.nullish(),
167
- notifiedBy: z2.string().optional(),
420
+ notifiedBy: z6.string().optional(),
168
421
  declaredIn: UUID.nullish(),
169
- declaredBy: z2.string().optional()
422
+ declaredBy: z6.string().optional()
170
423
  }).describe(
171
424
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
172
425
  );
173
426
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
174
427
  registeredIn: UUID.nullish(),
175
- registeredBy: z2.string().optional()
428
+ registeredBy: z6.string().optional(),
429
+ flags: ContainsFlags.optional()
176
430
  }).describe(
177
431
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
178
432
  );
@@ -197,38 +451,38 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
197
451
  "record.unassign-others"
198
452
  ]);
199
453
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
200
- templates: z2.preprocess(
454
+ templates: z6.preprocess(
201
455
  (val) => val === void 0 ? void 0 : [val].flat(),
202
- z2.array(z2.string()).optional()
456
+ z6.array(z6.string()).optional()
203
457
  ).describe(
204
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."
205
459
  )
206
460
  });
207
- var RecordScopeV2 = z2.discriminatedUnion("type", [
208
- z2.object({
461
+ var RecordScopeV2 = z6.discriminatedUnion("type", [
462
+ z6.object({
209
463
  type: ScopesWithPlaceEventOptions,
210
464
  options: scopeOptionsPlaceEvent.optional()
211
465
  }),
212
- z2.object({
466
+ z6.object({
213
467
  type: ScopesWithDeclaredOptions,
214
468
  options: scopeOptionsDeclaredOrNotified.optional()
215
469
  }),
216
- z2.object({
470
+ z6.object({
217
471
  type: ScopesWithFullOptions,
218
472
  options: AllRecordScopeOptions.optional()
219
473
  }),
220
- z2.object({
221
- type: z2.literal("record.custom-action"),
474
+ z6.object({
475
+ type: z6.literal("record.custom-action"),
222
476
  options: CustomActionScopeOptions.optional()
223
477
  }),
224
- z2.object({
225
- type: z2.literal("record.print-certified-copies"),
478
+ z6.object({
479
+ type: z6.literal("record.print-certified-copies"),
226
480
  options: ScopeOptionsPrintCertifiedCopies.optional()
227
481
  })
228
482
  ]).describe(
229
483
  "Scopes used to check user's permission to perform actions on a record."
230
484
  );
231
- var SystemScopeType = z2.enum([
485
+ var SystemScopeType = z6.enum([
232
486
  "organisation.read-locations",
233
487
  "user.read",
234
488
  "user.create",
@@ -242,61 +496,61 @@ var UserScopeType = SystemScopeType.extract([
242
496
  "user.search"
243
497
  ]);
244
498
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
245
- var UserScopeV2 = z2.discriminatedUnion("type", [
246
- z2.object({
499
+ var UserScopeV2 = z6.discriminatedUnion("type", [
500
+ z6.object({
247
501
  type: ScopesWithRoleOption,
248
502
  options: AllUserScopeOptions.optional()
249
503
  }),
250
- z2.object({
504
+ z6.object({
251
505
  type: UserScopeType.extract(["user.read", "user.search"]),
252
506
  options: AccessLevelOptions.optional()
253
507
  })
254
508
  ]);
255
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
256
- z2.object({
509
+ var ResolvedRecordScopeV2 = z6.discriminatedUnion("type", [
510
+ z6.object({
257
511
  type: ScopesWithPlaceEventOptions,
258
512
  options: ResolvedScopeOptionsPlaceEvent.optional()
259
513
  }),
260
- z2.object({
514
+ z6.object({
261
515
  type: ScopesWithDeclaredOptions,
262
516
  options: ResolvedScopeOptionsDeclared.optional()
263
517
  }),
264
- z2.object({
518
+ z6.object({
265
519
  type: ScopesWithFullOptions,
266
520
  options: ResolvedScopeOptionsFull.optional()
267
521
  }),
268
- z2.object({
269
- type: z2.literal("record.print-certified-copies"),
522
+ z6.object({
523
+ type: z6.literal("record.print-certified-copies"),
270
524
  options: ResolvedScopeOptionsFull.extend({
271
- templates: z2.array(z2.string()).optional()
525
+ templates: z6.array(z6.string()).optional()
272
526
  }).optional()
273
527
  })
274
528
  ]).describe("Resolved scope with location/user IDs instead of filters.");
275
- var Scope = z2.discriminatedUnion("type", [
276
- z2.object({ type: PlainScopeType }),
529
+ var Scope = z6.discriminatedUnion("type", [
530
+ z6.object({ type: PlainScopeType }),
277
531
  ...RecordScopeV2.options,
278
532
  ...UserScopeV2.options,
279
- z2.object({
280
- type: z2.literal("organisation.read-locations"),
533
+ z6.object({
534
+ type: z6.literal("organisation.read-locations"),
281
535
  options: AccessLevelOptions.optional()
282
536
  }),
283
- z2.object({
284
- type: z2.literal("workqueue"),
537
+ z6.object({
538
+ type: z6.literal("workqueue"),
285
539
  options: WorkqueueOrDashboardOptions
286
540
  }),
287
- z2.object({
288
- type: z2.literal("dashboard.view"),
541
+ z6.object({
542
+ type: z6.literal("dashboard.view"),
289
543
  options: WorkqueueOrDashboardOptions
290
544
  })
291
545
  ]);
292
- var ScopeType = z2.enum([
546
+ var ScopeType = z6.enum([
293
547
  ...SystemScopeType.options,
294
548
  ...RecordScopeTypeV2.options,
295
549
  ...PlainScopeType.options,
296
550
  "workqueue",
297
551
  "dashboard.view"
298
552
  ]);
299
- var EncodedScope = z2.string().brand("EncodedScope");
553
+ var EncodedScope = z6.string().brand("EncodedScope");
300
554
  var DEFAULT_SCOPE_OPTIONS = {
301
555
  placeOfEvent: JurisdictionFilter.enum.all,
302
556
  accessLevel: JurisdictionFilter.enum.all,
@@ -306,162 +560,51 @@ var DEFAULT_SCOPE_OPTIONS = {
306
560
  };
307
561
 
308
562
  // ../commons/src/authentication.ts
309
- var TokenUserType = z3.enum(["user", "system"]);
310
- var TokenWithBearer = z3.string().regex(/^Bearer\s/);
311
-
312
- // ../commons/src/events/ActionType.ts
313
- var z4 = __toESM(require("zod/v4"));
314
- var ActionType = {
315
- // Pre-declaration actions
316
- DELETE: "DELETE",
317
- CREATE: "CREATE",
318
- NOTIFY: "NOTIFY",
319
- // Declaration actions
320
- DECLARE: "DECLARE",
321
- REGISTER: "REGISTER",
322
- EDIT: "EDIT",
323
- // Declaration system actions. Non-configurable.
324
- DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
325
- REJECT: "REJECT",
326
- // REJECT_DECLARATION
327
- MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
328
- MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
329
- ARCHIVE: "ARCHIVE",
330
- UNARCHIVE: "UNARCHIVE",
331
- // Record actions
332
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
333
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
334
- REJECT_CORRECTION: "REJECT_CORRECTION",
335
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
336
- // General actions
337
- READ: "READ",
338
- ASSIGN: "ASSIGN",
339
- UNASSIGN: "UNASSIGN",
340
- // Custom action
341
- CUSTOM: "CUSTOM"
342
- };
343
- var ConfirmableActions = [
344
- ActionType.NOTIFY,
345
- ActionType.DECLARE,
346
- ActionType.EDIT,
347
- ActionType.REGISTER,
348
- ActionType.REJECT,
349
- ActionType.ARCHIVE,
350
- ActionType.UNARCHIVE,
351
- ActionType.PRINT_CERTIFICATE,
352
- ActionType.REQUEST_CORRECTION,
353
- ActionType.APPROVE_CORRECTION,
354
- ActionType.REJECT_CORRECTION,
355
- ActionType.CUSTOM
356
- ];
357
- var ActionTypes = z4.enum([
358
- "DELETE",
359
- "CREATE",
360
- "NOTIFY",
361
- "DECLARE",
362
- "EDIT",
363
- "REGISTER",
364
- "DUPLICATE_DETECTED",
365
- "REJECT",
366
- "MARK_AS_DUPLICATE",
367
- "MARK_AS_NOT_DUPLICATE",
368
- "ARCHIVE",
369
- "UNARCHIVE",
370
- "PRINT_CERTIFICATE",
371
- "REQUEST_CORRECTION",
372
- "REJECT_CORRECTION",
373
- "APPROVE_CORRECTION",
374
- "READ",
375
- "ASSIGN",
376
- "UNASSIGN",
377
- "CUSTOM"
378
- ]);
379
- var ClientSpecificAction = {
380
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
381
- };
382
- var declarationActionValues = [
383
- ActionTypes.enum.DECLARE,
384
- ActionTypes.enum.EDIT,
385
- ActionTypes.enum.REGISTER,
386
- ActionTypes.enum.NOTIFY,
387
- ActionTypes.enum.DUPLICATE_DETECTED
388
- ];
389
- var DeclarationActions = ActionTypes.extract(declarationActionValues);
390
- var declarationUpdateActionValues = [
391
- ...declarationActionValues,
392
- ActionTypes.enum.REQUEST_CORRECTION
393
- ];
394
- var DeclarationUpdateActions = ActionTypes.extract(
395
- declarationUpdateActionValues
396
- );
397
- var annotationActions = ActionTypes.exclude(declarationActionValues);
398
- var writeActions = ActionTypes.exclude([
399
- ActionType.CREATE,
400
- ActionType.READ,
401
- ActionType.ASSIGN,
402
- ActionType.UNASSIGN
403
- ]);
404
- var WorkqueueActionType = ActionTypes.extract([
405
- ActionType.READ,
406
- ActionType.DELETE,
407
- ActionType.DECLARE,
408
- ActionType.REGISTER,
409
- ActionType.EDIT,
410
- ActionType.REJECT,
411
- ActionType.MARK_AS_DUPLICATE,
412
- ActionType.ARCHIVE,
413
- ActionType.UNARCHIVE,
414
- ActionType.PRINT_CERTIFICATE,
415
- ActionType.REQUEST_CORRECTION
416
- ]);
417
- var META_ACTIONS = [
418
- ActionType.ASSIGN,
419
- ActionType.UNASSIGN,
420
- ActionType.READ
421
- ];
563
+ var TokenUserType = z7.enum(["user", "system"]);
564
+ var TokenWithBearer = z7.string().regex(/^Bearer\s/);
422
565
 
423
566
  // ../commons/src/events/AuditLog.ts
424
- var AuditLogEntryBase = z5.object({
425
- id: z5.string(),
426
- clientId: z5.string(),
567
+ var AuditLogEntryBase = z8.object({
568
+ id: z8.string(),
569
+ clientId: z8.string(),
427
570
  clientType: TokenUserType,
428
- createdAt: z5.string()
571
+ createdAt: z8.string()
429
572
  });
430
573
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
431
- operation: z5.literal("event.create"),
432
- requestData: z5.object({
433
- transactionId: z5.string(),
434
- type: z5.string(),
435
- createdAtLocation: z5.string().nullable()
574
+ operation: z8.literal("event.create"),
575
+ requestData: z8.object({
576
+ transactionId: z8.string(),
577
+ type: z8.string(),
578
+ createdAtLocation: z8.string().nullable()
436
579
  }),
437
- responseSummary: z5.object({
438
- eventId: z5.string(),
439
- trackingId: z5.string()
580
+ responseSummary: z8.object({
581
+ eventId: z8.string(),
582
+ trackingId: z8.string()
440
583
  })
441
584
  });
442
585
  var EventGetEntrySchema = AuditLogEntryBase.extend({
443
- operation: z5.literal("event.get"),
444
- requestData: z5.object({ eventId: z5.string() }),
445
- responseSummary: z5.object({
446
- eventType: z5.string(),
447
- trackingId: z5.string()
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()
448
591
  })
449
592
  });
450
593
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
451
- operation: z5.literal("event.search"),
452
- clientType: z5.literal("system"),
453
- requestData: z5.object({
454
- query: z5.record(z5.string(), z5.unknown()).nullable(),
455
- limit: z5.number().nullable(),
456
- offset: z5.number().nullable()
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()
457
600
  }),
458
- responseSummary: z5.object({
459
- total: z5.number(),
460
- eventIds: z5.array(z5.string())
601
+ responseSummary: z8.object({
602
+ total: z8.number(),
603
+ eventIds: z8.array(z8.string())
461
604
  })
462
605
  });
463
606
  var EventActionEntrySchema = AuditLogEntryBase.extend({
464
- operation: z5.enum([
607
+ operation: z8.enum([
465
608
  "event.actions.notify.request",
466
609
  "event.actions.declare.request",
467
610
  "event.actions.register.request",
@@ -481,83 +624,83 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
481
624
  "event.actions.mark_as_duplicate.request",
482
625
  "event.actions.mark_as_not_duplicate.request"
483
626
  ]),
484
- requestData: z5.object({
485
- eventId: z5.string(),
486
- actionType: z5.string(),
487
- eventType: z5.string(),
488
- trackingId: z5.string(),
489
- 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()
490
633
  })
491
634
  });
492
635
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
493
- operation: z5.literal("event.actions.custom.request"),
494
- requestData: z5.object({
495
- eventId: z5.string(),
496
- actionType: z5.literal(ActionType.CUSTOM),
497
- customAction: z5.string(),
498
- eventType: z5.string(),
499
- trackingId: z5.string(),
500
- transactionId: z5.string()
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()
501
644
  })
502
645
  });
503
646
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
504
- operation: z5.literal("integrations.create"),
505
- requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
506
- responseSummary: z5.object({ clientId: z5.string() })
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() })
507
650
  });
508
651
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
509
- operation: z5.literal("integrations.refreshToken"),
510
- requestData: z5.object({ clientId: z5.string() }),
511
- 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() })
512
655
  });
513
656
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
514
- operation: z5.literal("integrations.deactivate"),
515
- requestData: z5.object({ id: z5.string() }),
516
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
657
+ operation: z8.literal("integrations.deactivate"),
658
+ requestData: z8.object({ id: z8.string() }),
659
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
517
660
  });
518
661
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
519
- operation: z5.literal("integrations.activate"),
520
- requestData: z5.object({ id: z5.string() }),
521
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
662
+ operation: z8.literal("integrations.activate"),
663
+ requestData: z8.object({ id: z8.string() }),
664
+ responseSummary: z8.object({ id: z8.string(), status: z8.string() })
522
665
  });
523
666
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
524
- operation: z5.literal("integrations.delete"),
525
- requestData: z5.object({ id: z5.string() }),
526
- responseSummary: z5.object({ id: z5.string(), name: z5.string() })
667
+ operation: z8.literal("integrations.delete"),
668
+ requestData: z8.object({ id: z8.string() }),
669
+ responseSummary: z8.object({ id: z8.string(), name: z8.string() })
527
670
  });
528
671
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
529
- operation: z5.literal("integrations.refreshSecret"),
530
- requestData: z5.object({ id: z5.string() }),
531
- 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() })
532
675
  });
533
676
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
534
- operation: z5.literal("attachments.upload"),
535
- requestData: z5.object({
536
- transactionId: z5.string(),
537
- path: z5.string().nullable()
677
+ operation: z8.literal("attachments.upload"),
678
+ requestData: z8.object({
679
+ transactionId: z8.string(),
680
+ path: z8.string().nullable()
538
681
  }),
539
- responseSummary: z5.object({ fileUrl: z5.string() })
682
+ responseSummary: z8.object({ fileUrl: z8.string() })
540
683
  });
541
- var subjectOnly = z5.object({ subjectId: z5.string() });
542
- var subjectWithReason = z5.object({
543
- subjectId: z5.string(),
544
- reason: z5.string(),
545
- comment: z5.string().optional()
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()
546
689
  });
547
690
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
548
- operation: z5.literal("user.create_user"),
549
- requestData: z5.object({
550
- subjectId: z5.string(),
551
- role: z5.string(),
552
- primaryOfficeId: z5.string()
691
+ operation: z8.literal("user.create_user"),
692
+ requestData: z8.object({
693
+ subjectId: z8.string(),
694
+ role: z8.string(),
695
+ primaryOfficeId: z8.string()
553
696
  })
554
697
  });
555
698
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
556
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
699
+ operation: z8.enum(["user.deactivate", "user.reactivate"]),
557
700
  requestData: subjectWithReason
558
701
  });
559
702
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
560
- operation: z5.enum([
703
+ operation: z8.enum([
561
704
  "user.edit_user",
562
705
  "user.logged_in",
563
706
  "user.logged_out",
@@ -571,14 +714,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
571
714
  requestData: subjectOnly
572
715
  });
573
716
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
574
- operation: z5.literal("user.email_address_changed"),
717
+ operation: z8.literal("user.email_address_changed"),
575
718
  requestData: subjectOnly,
576
- responseSummary: z5.object({ email: z5.string() })
719
+ responseSummary: z8.object({ email: z8.string() })
577
720
  });
578
721
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
579
- operation: z5.literal("user.phone_number_changed"),
722
+ operation: z8.literal("user.phone_number_changed"),
580
723
  requestData: subjectOnly,
581
- responseSummary: z5.object({ phoneNumber: z5.string() })
724
+ responseSummary: z8.object({ phoneNumber: z8.string() })
582
725
  });
583
726
  var userBaseOmit = {
584
727
  id: true,
@@ -586,14 +729,14 @@ var userBaseOmit = {
586
729
  clientType: true,
587
730
  createdAt: true
588
731
  };
589
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
732
+ var UserAuditRecordInput = z8.discriminatedUnion("operation", [
590
733
  UserCreateEntrySchema.omit(userBaseOmit),
591
734
  UserReasonEntrySchema.omit(userBaseOmit),
592
735
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
593
736
  UserEmailChangedEntrySchema.omit(userBaseOmit),
594
737
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
595
738
  ]);
596
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
739
+ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
597
740
  EventCreateEntrySchema,
598
741
  EventGetEntrySchema,
599
742
  EventSearchEntrySchema,
@@ -620,76 +763,11 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
620
763
  // ../commons/src/events/ActionConfig.ts
621
764
  var z24 = __toESM(require("zod/v4"));
622
765
 
623
- // ../commons/src/events/TranslationConfig.ts
624
- var z6 = __toESM(require("zod/v4"));
625
- var TranslationConfig = z6.object({
626
- id: z6.string().describe(
627
- "The identifier of the translation referred in translation CSV files"
628
- ),
629
- defaultMessage: z6.string().describe("Default translation message"),
630
- description: z6.string().describe(
631
- "Describe the translation for a translator to be able to identify it."
632
- )
633
- }).meta({
634
- description: "Translation configuration",
635
- id: "TranslationConfig"
636
- });
637
-
638
766
  // ../commons/src/events/FieldConfig.ts
639
767
  var import_v43 = __toESM(require("zod/v4"));
640
768
 
641
- // ../commons/src/events/Conditional.ts
642
- var z7 = __toESM(require("zod/v4"));
643
- var Conditional = z7.any().describe("JSONSchema").meta({
644
- description: "JSON schema conditional configuration",
645
- id: "Conditional"
646
- });
647
- var ConditionalType = {
648
- SHOW: "SHOW",
649
- ENABLE: "ENABLE",
650
- DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
651
- };
652
- var ShowConditional = z7.object({
653
- type: z7.literal(ConditionalType.SHOW),
654
- conditional: Conditional
655
- }).describe(
656
- "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
657
- );
658
- var EnableConditional = z7.object({
659
- type: z7.literal(ConditionalType.ENABLE),
660
- conditional: Conditional
661
- }).describe(
662
- "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
663
- );
664
- var ActionConditional = z7.discriminatedUnion("type", [
665
- // Action can be shown / hidden
666
- ShowConditional,
667
- // Action can be shown to the user in the list but as disabled
668
- EnableConditional
669
- ]).meta({
670
- id: "ActionConditional",
671
- description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
672
- });
673
- var DisplayOnReviewConditional = z7.object({
674
- type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
675
- conditional: Conditional
676
- }).describe(
677
- "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
678
- );
679
- var FieldConditional = z7.discriminatedUnion("type", [
680
- // Field input can be shown / hidden
681
- ShowConditional,
682
- // Field input can be shown to the user but as disabled
683
- EnableConditional,
684
- // Field output can be shown / hidden on the review page
685
- DisplayOnReviewConditional
686
- ]).meta({
687
- id: "FieldConditional",
688
- description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
689
- });
690
-
691
769
  // ../commons/src/events/FieldType.ts
692
- var z8 = __toESM(require("zod/v4"));
770
+ var z9 = __toESM(require("zod/v4"));
693
771
  var FieldType = {
694
772
  NAME: "NAME",
695
773
  PHONE: "PHONE",
@@ -753,7 +831,7 @@ var FieldType = {
753
831
  */
754
832
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
755
833
  };
756
- var FileFieldType = z8.enum([
834
+ var FileFieldType = z9.enum([
757
835
  FieldType.FILE,
758
836
  FieldType.FILE_WITH_OPTIONS,
759
837
  FieldType.SIGNATURE
@@ -789,160 +867,164 @@ var HiddenFieldTypes = [
789
867
  ];
790
868
 
791
869
  // ../commons/src/events/FieldValue.ts
792
- var z12 = __toESM(require("zod/v4"));
870
+ var z13 = __toESM(require("zod/v4"));
793
871
 
794
872
  // ../commons/src/documents.ts
795
- var z9 = __toESM(require("zod/v4"));
796
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
873
+ var z10 = __toESM(require("zod/v4"));
874
+ var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
797
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"
798
876
  );
799
- 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(
800
878
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
801
879
  );
802
- var DocumentPath = z9.string().brand("DocumentPath").describe(
880
+ var DocumentPath = z10.string().brand("DocumentPath").describe(
803
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."
804
882
  );
805
883
 
806
884
  // ../commons/src/events/CompositeFieldValue.ts
807
- var z10 = __toESM(require("zod/v4"));
885
+ var z11 = __toESM(require("zod/v4"));
808
886
  var AddressType = {
809
887
  DOMESTIC: "DOMESTIC",
810
888
  INTERNATIONAL: "INTERNATIONAL"
811
889
  };
812
- var FileFieldValue = z10.object({
890
+ var FileFieldValue = z11.object({
813
891
  path: DocumentPath,
814
- originalFilename: z10.string(),
815
- type: z10.string()
816
- });
817
- var NameFieldValue = z10.object({
818
- firstname: z10.string(),
819
- surname: z10.string(),
820
- middlename: z10.string().optional()
821
- });
822
- var NameFieldUpdateValue = z10.object({
823
- firstname: z10.string().nullish(),
824
- surname: z10.string().nullish(),
825
- middlename: z10.string().nullish()
826
- }).or(z10.null()).or(z10.undefined());
827
- var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
828
- var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
829
- var BaseAddressFieldValue = z10.object({
830
- country: z10.string(),
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(),
831
909
  streetLevelDetails: StreetLevelDetailsValue
832
910
  });
833
- var BaseAddressFieldUpdateValue = z10.object({
834
- country: z10.string().nullish(),
911
+ var BaseAddressFieldUpdateValue = z11.object({
912
+ country: z11.string().nullish(),
835
913
  streetLevelDetails: StreetLevelDetailsUpdateValue
836
914
  });
837
915
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
838
- addressType: z10.literal(AddressType.DOMESTIC),
839
- administrativeArea: z10.string().uuid()
916
+ addressType: z11.literal(AddressType.DOMESTIC),
917
+ administrativeArea: z11.string().uuid()
840
918
  });
841
919
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
842
- addressType: z10.literal(AddressType.INTERNATIONAL)
920
+ addressType: z11.literal(AddressType.INTERNATIONAL)
843
921
  });
844
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
922
+ var AddressFieldValue = z11.discriminatedUnion("addressType", [
845
923
  DomesticAddressFieldValue,
846
924
  InternationalAddressFieldValue
847
925
  ]);
848
926
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
849
- addressType: z10.literal(AddressType.DOMESTIC),
850
- administrativeArea: z10.string().uuid().nullish()
927
+ addressType: z11.literal(AddressType.DOMESTIC),
928
+ administrativeArea: z11.string().uuid().nullish()
851
929
  /* Leaf level admin structure */
852
930
  });
853
931
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
854
932
  {
855
- addressType: z10.literal(AddressType.INTERNATIONAL)
933
+ addressType: z11.literal(AddressType.INTERNATIONAL)
856
934
  }
857
935
  );
858
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
936
+ var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
859
937
  DomesticAddressUpdateFieldValue,
860
938
  InternationalAddressUpdateFieldValue
861
939
  ]).nullish();
862
- var FileFieldValueWithOption = z10.object({
940
+ var FileFieldValueWithOption = z11.object({
863
941
  path: DocumentPath,
864
- originalFilename: z10.string(),
865
- type: z10.string(),
866
- option: z10.string()
867
- });
868
- var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
869
- var HttpFieldValue = z10.object({
870
- loading: z10.boolean(),
871
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
872
- data: z10.any()
873
- });
874
- var HttpFieldUpdateValue = z10.object({
875
- loading: z10.boolean().nullish(),
876
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
877
- data: z10.any().nullish()
878
- }).or(z10.null()).or(z10.undefined());
879
- var QueryParamReaderFieldValue = z10.object({
880
- data: z10.record(z10.string(), z10.string()),
881
- updatedAt: z10.iso.datetime()
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()
882
960
  }).nullish();
883
- var QueryParamReaderFieldUpdateValue = z10.object({
884
- data: z10.record(z10.string(), z10.string())
961
+ var QueryParamReaderFieldUpdateValue = z11.object({
962
+ data: z11.record(z11.string(), z11.string())
885
963
  });
886
- var ReadDataValue = z10.object({
887
- data: z10.any()
964
+ var ReadDataValue = z11.object({
965
+ data: z11.any()
888
966
  });
889
967
  var QrReaderFieldValue = ReadDataValue;
890
968
  var IdReaderFieldValue = ReadDataValue;
891
- var NumberWithUnitFieldValue = z10.object({
892
- numericValue: z10.number(),
893
- unit: z10.string()
969
+ var NumberWithUnitFieldValue = z11.object({
970
+ numericValue: z11.number(),
971
+ unit: z11.string()
894
972
  });
895
- var NumberWithUnitFieldUpdateValue = z10.object({
896
- numericValue: z10.number().optional(),
897
- unit: z10.string().optional()
973
+ var NumberWithUnitFieldUpdateValue = z11.object({
974
+ numericValue: z11.number().optional(),
975
+ unit: z11.string().optional()
898
976
  });
899
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
977
+ var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
900
978
 
901
979
  // ../commons/src/events/PlainDate.ts
902
980
  var import_zod = require("zod");
903
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
+ }
904
986
 
905
987
  // ../commons/src/events/FieldValue.ts
906
- var TextValue = z12.string();
907
- var HiddenFieldValue = z12.string();
908
- var NonEmptyTextValue = z12.string().trim().min(1);
909
- var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
910
- var AgeValue = z12.object({
911
- age: z12.number(),
912
- asOfDateRef: z12.string()
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()
913
995
  });
914
996
  var AgeUpdateValue = AgeValue.optional().nullable();
915
- var AutocompleteValue = z12.object({
916
- label: z12.string(),
917
- value: z12.string()
997
+ var AutocompleteValue = z13.object({
998
+ label: z13.string(),
999
+ value: z13.string()
918
1000
  });
919
1001
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
920
- var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
921
- var DatetimeValue = z12.iso.datetime();
922
- var SelectDateRangeValue = z12.enum([
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([
923
1005
  "last7Days",
924
1006
  "last30Days",
925
1007
  "last90Days",
926
1008
  "last365Days"
927
1009
  ]);
928
- var DateRangeFieldValue = z12.object({
1010
+ var DateRangeFieldValue = z13.object({
929
1011
  start: PlainDate,
930
1012
  end: PlainDate
931
1013
  }).or(PlainDate).describe(
932
1014
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
933
1015
  );
934
- var EmailValue = z12.email();
935
- var CheckboxFieldValue = z12.boolean();
936
- var NumberFieldValue = z12.number();
1016
+ var EmailValue = z13.email();
1017
+ var CheckboxFieldValue = z13.boolean();
1018
+ var NumberFieldValue = z13.number();
937
1019
  var SignatureFieldValue = FileFieldValue;
938
- var ButtonFieldValue = z12.number();
939
- var VerificationStatusValue = z12.enum([
1020
+ var ButtonFieldValue = z13.number();
1021
+ var VerificationStatusValue = z13.enum([
940
1022
  "verified",
941
1023
  "authenticated",
942
1024
  "failed",
943
1025
  "pending"
944
1026
  ]);
945
- var LeafFieldValues = z12.union([
1027
+ var LeafFieldValues = z13.union([
946
1028
  AddressFieldValue,
947
1029
  TextValue,
948
1030
  PlainDate,
@@ -968,11 +1050,11 @@ var LeafFieldValues = z12.union([
968
1050
  AutocompleteValue,
969
1051
  AutocompleteUpdateValue
970
1052
  ]);
971
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
972
- var DataFieldValue = z12.object({
973
- 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)
974
1056
  }).nullish();
975
- var FieldValue = z12.union([
1057
+ var FieldValue = z13.union([
976
1058
  LeafFieldValues,
977
1059
  DataFieldValue,
978
1060
  FieldGroupValue
@@ -1006,7 +1088,7 @@ function safeUnion(schemas) {
1006
1088
  const sortedSchemas = [...schemas].sort(
1007
1089
  (a, b) => schemaPriority(a) - schemaPriority(b)
1008
1090
  );
1009
- return z12.any().superRefine((val, ctx) => {
1091
+ return z13.any().superRefine((val, ctx) => {
1010
1092
  for (const schema of sortedSchemas) {
1011
1093
  if (schema.safeParse(val).success) {
1012
1094
  return;
@@ -1045,9 +1127,9 @@ var FieldUpdateValue = safeUnion([
1045
1127
  ]);
1046
1128
 
1047
1129
  // ../commons/src/events/serializers/user/serializer.ts
1048
- var z13 = __toESM(require("zod/v4"));
1049
- var SerializedUserField = z13.object({
1050
- $userField: z13.enum([
1130
+ var z14 = __toESM(require("zod/v4"));
1131
+ var SerializedUserField = z14.object({
1132
+ $userField: z14.enum([
1051
1133
  "id",
1052
1134
  "name",
1053
1135
  "role",
@@ -1061,7 +1143,7 @@ var SerializedUserField = z13.object({
1061
1143
  "primaryOfficeId",
1062
1144
  "administrativeAreaId"
1063
1145
  ]),
1064
- $location: z13.string().optional()
1146
+ $location: z14.string().optional()
1065
1147
  });
1066
1148
  function userSerializer(userField) {
1067
1149
  return {
@@ -1087,27 +1169,22 @@ var import_v4 = require("zod/v4");
1087
1169
  var z16 = __toESM(require("zod/v4"));
1088
1170
 
1089
1171
  // ../commons/src/events/ActionDocument.ts
1090
- var z14 = __toESM(require("zod/v4"));
1091
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1172
+ var z15 = __toESM(require("zod/v4"));
1173
+ var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1092
1174
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1093
1175
  );
1094
- var EventState = z14.record(z14.string(), FieldValue).describe(
1176
+ var EventState = z15.record(z15.string(), FieldValue).describe(
1095
1177
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1096
1178
  );
1097
- var ActionStatus = {
1098
- Requested: "Requested",
1099
- Accepted: "Accepted",
1100
- Rejected: "Rejected"
1101
- };
1102
- var ActionBase = z14.object({
1179
+ var ActionBase = z15.object({
1103
1180
  id: UUID.describe("Unique identifier of the action."),
1104
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1181
+ transactionId: z15.string().describe("Unique identifier of the transaction."),
1105
1182
  createdByUserType: TokenUserType.describe(
1106
1183
  "Indicates whether the action was created by a human-user or by a system-user."
1107
1184
  ),
1108
- createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1109
- createdBy: z14.string().describe("Identifier of the user who created the action."),
1110
- createdByRole: z14.string().optional().describe("Role of the user who created the action."),
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."),
1111
1188
  createdBySignature: DocumentPath.nullish().describe(
1112
1189
  "Reference to the signature of the user who created the action."
1113
1190
  ),
@@ -1119,7 +1196,7 @@ var ActionBase = z14.object({
1119
1196
  "Declaration data defined by the ActionConfig. Supports partial updates."
1120
1197
  ),
1121
1198
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1122
- status: z14.enum([
1199
+ status: z15.enum([
1123
1200
  ActionStatus.Requested,
1124
1201
  ActionStatus.Accepted,
1125
1202
  ActionStatus.Rejected
@@ -1131,138 +1208,139 @@ var ActionBase = z14.object({
1131
1208
  )
1132
1209
  });
1133
1210
  var AssignedAction = ActionBase.extend(
1134
- z14.object({
1135
- type: z14.literal(ActionType.ASSIGN),
1136
- assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
1211
+ z15.object({
1212
+ type: z15.literal(ActionType.ASSIGN),
1213
+ assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1137
1214
  // TODO move into 'content' property
1138
1215
  }).shape
1139
1216
  );
1140
1217
  var UnassignedAction = ActionBase.extend(
1141
- z14.object({
1142
- type: z14.literal(ActionType.UNASSIGN)
1218
+ z15.object({
1219
+ type: z15.literal(ActionType.UNASSIGN)
1143
1220
  }).shape
1144
1221
  );
1145
1222
  var RegisterAction = ActionBase.extend(
1146
- z14.object({
1147
- type: z14.literal(ActionType.REGISTER),
1148
- registrationNumber: z14.string().optional().describe(
1223
+ z15.object({
1224
+ type: z15.literal(ActionType.REGISTER),
1225
+ registrationNumber: z15.string().optional().describe(
1149
1226
  "Registration number of the event. Always present for accepted registrations."
1150
1227
  )
1151
1228
  // TODO move into 'content' property
1152
1229
  }).shape
1153
1230
  );
1154
1231
  var DeclareAction = ActionBase.extend(
1155
- z14.object({
1156
- type: z14.literal(ActionType.DECLARE)
1232
+ z15.object({
1233
+ type: z15.literal(ActionType.DECLARE)
1157
1234
  }).shape
1158
1235
  );
1159
- var ReasonContent = z14.object({
1160
- 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(
1161
1238
  "Message describing the reason for rejecting or archiving the event."
1162
1239
  )
1163
1240
  });
1164
1241
  var RejectAction = ActionBase.extend(
1165
- z14.object({
1166
- type: z14.literal(ActionType.REJECT),
1242
+ z15.object({
1243
+ type: z15.literal(ActionType.REJECT),
1167
1244
  content: ReasonContent
1168
1245
  }).shape
1169
1246
  );
1170
- var PotentialDuplicate = z14.object({
1247
+ var PotentialDuplicate = z15.object({
1171
1248
  id: UUID,
1172
- trackingId: z14.string()
1249
+ trackingId: z15.string()
1173
1250
  });
1174
1251
  var DuplicateDetectedAction = ActionBase.extend(
1175
- z14.object({
1176
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1177
- content: z14.object({
1178
- duplicates: z14.array(PotentialDuplicate)
1252
+ z15.object({
1253
+ type: z15.literal(ActionType.DUPLICATE_DETECTED),
1254
+ content: z15.object({
1255
+ duplicates: z15.array(PotentialDuplicate)
1179
1256
  })
1180
1257
  }).shape
1181
1258
  );
1182
1259
  var MarkNotDuplicateAction = ActionBase.extend(
1183
- z14.object({
1184
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1260
+ z15.object({
1261
+ type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1185
1262
  }).shape
1186
1263
  );
1187
1264
  var MarkAsDuplicateAction = ActionBase.extend(
1188
- z14.object({
1189
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1190
- content: z14.object({
1265
+ z15.object({
1266
+ type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1267
+ content: z15.object({
1191
1268
  duplicateOf: UUID
1192
1269
  }).optional()
1193
1270
  }).shape
1194
1271
  );
1195
1272
  var ArchiveAction = ActionBase.extend(
1196
- z14.object({
1197
- type: z14.literal(ActionType.ARCHIVE),
1273
+ z15.object({
1274
+ type: z15.literal(ActionType.ARCHIVE),
1198
1275
  content: ReasonContent
1199
1276
  }).shape
1200
1277
  );
1201
1278
  var UnarchiveAction = ActionBase.extend(
1202
- z14.object({
1203
- type: z14.literal(ActionType.UNARCHIVE)
1279
+ z15.object({
1280
+ type: z15.literal(ActionType.UNARCHIVE)
1204
1281
  }).shape
1205
1282
  );
1206
1283
  var CreatedAction = ActionBase.extend(
1207
- z14.object({
1208
- type: z14.literal(ActionType.CREATE)
1284
+ z15.object({
1285
+ type: z15.literal(ActionType.CREATE)
1209
1286
  }).shape
1210
1287
  );
1211
1288
  var NotifiedAction = ActionBase.extend(
1212
- z14.object({
1213
- type: z14.literal(ActionType.NOTIFY)
1289
+ z15.object({
1290
+ type: z15.literal(ActionType.NOTIFY)
1214
1291
  }).shape
1215
1292
  );
1216
1293
  var EditAction = ActionBase.extend(
1217
- z14.object({
1218
- type: z14.literal(ActionType.EDIT),
1219
- content: z14.object({
1220
- comment: z14.string().describe("Comment for the edit action.").optional()
1221
- })
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()
1222
1300
  }).shape
1223
1301
  );
1224
- var PrintContent = z14.object({
1225
- templateId: z14.string().optional()
1302
+ var PrintContent = z15.object({
1303
+ templateId: z15.string().optional()
1226
1304
  });
1227
1305
  var PrintCertificateAction = ActionBase.extend(
1228
- z14.object({
1229
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1306
+ z15.object({
1307
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1230
1308
  content: PrintContent.optional().nullable()
1231
1309
  }).shape
1232
1310
  );
1233
1311
  var RequestedCorrectionAction = ActionBase.extend(
1234
- z14.object({
1235
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1312
+ z15.object({
1313
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1236
1314
  }).shape
1237
1315
  );
1238
1316
  var ApprovedCorrectionAction = ActionBase.extend(
1239
- z14.object({
1240
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1241
- requestId: z14.string(),
1317
+ z15.object({
1318
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1319
+ requestId: z15.string(),
1242
1320
  // TODO move into 'content' property
1243
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1321
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1244
1322
  }).shape
1245
1323
  );
1246
1324
  var RejectedCorrectionAction = ActionBase.extend(
1247
- z14.object({
1248
- type: z14.literal(ActionType.REJECT_CORRECTION),
1249
- requestId: z14.string(),
1325
+ z15.object({
1326
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1327
+ requestId: z15.string(),
1250
1328
  // TODO move into 'content' property
1251
1329
  content: ReasonContent
1252
1330
  }).shape
1253
1331
  );
1254
1332
  var ReadAction = ActionBase.extend(
1255
- z14.object({
1256
- type: z14.literal(ActionType.READ)
1333
+ z15.object({
1334
+ type: z15.literal(ActionType.READ)
1257
1335
  }).shape
1258
1336
  );
1259
1337
  var CustomAction = ActionBase.merge(
1260
- z14.object({
1261
- type: z14.literal(ActionType.CUSTOM),
1262
- customActionType: z14.string()
1338
+ z15.object({
1339
+ type: z15.literal(ActionType.CUSTOM),
1340
+ customActionType: z15.string()
1263
1341
  })
1264
1342
  );
1265
- var ActionDocument = z14.discriminatedUnion("type", [
1343
+ var ActionDocument = z15.discriminatedUnion("type", [
1266
1344
  CreatedAction.meta({ id: "CreatedAction" }),
1267
1345
  RejectAction.meta({ id: "RejectAction" }),
1268
1346
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1289,64 +1367,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1289
1367
  declaration: true,
1290
1368
  annotation: true
1291
1369
  }).extend(
1292
- z14.object({
1293
- type: z14.enum(ConfirmableActions),
1294
- status: z14.literal(ActionStatus.Rejected)
1370
+ z15.object({
1371
+ type: z15.enum(ConfirmableActions),
1372
+ status: z15.literal(ActionStatus.Rejected)
1295
1373
  }).shape
1296
1374
  );
1297
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1298
-
1299
- // ../commons/src/events/Flag.ts
1300
- var z15 = __toESM(require("zod/v4"));
1301
- var InherentFlags = {
1302
- INCOMPLETE: "incomplete",
1303
- REJECTED: "rejected",
1304
- CORRECTION_REQUESTED: "correction-requested",
1305
- POTENTIAL_DUPLICATE: "potential-duplicate",
1306
- /**
1307
- * This flag is set by the Edit-action and removed after the declaration or registration.
1308
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1309
- *
1310
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1311
- */
1312
- EDIT_IN_PROGRESS: "edit-in-progress"
1313
- };
1314
- var ActionFlag = z15.string().regex(
1315
- new RegExp(
1316
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1317
- ActionStatus
1318
- ).join("|").toLowerCase()})$`
1319
- ),
1320
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1321
- );
1322
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1323
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1324
- InherentFlags
1325
- ).join(", ")}`
1326
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1327
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1328
- }).describe("Custom flag identifier defined by the country config.");
1329
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1330
- var FlagConfig = z15.object({
1331
- id: CustomFlag,
1332
- requiresAction: z15.boolean().describe(
1333
- "Indicates if this flag expects an action to be performed to be cleared."
1334
- ),
1335
- label: TranslationConfig.describe("Human readable label of the flag.")
1336
- }).meta({
1337
- id: "FlagConfig",
1338
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1339
- });
1340
- var ActionFlagConfig = z15.object({
1341
- id: Flag,
1342
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1343
- conditional: Conditional.optional().describe(
1344
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1345
- )
1346
- }).meta({
1347
- id: "ActionFlagConfig",
1348
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1349
- });
1375
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1350
1376
 
1351
1377
  // ../commons/src/events/EventMetadata.ts
1352
1378
  var EventStatus = z16.enum([
@@ -1504,13 +1530,6 @@ var Range = import_v4.z.object({
1504
1530
  }).meta({
1505
1531
  id: "Range"
1506
1532
  });
1507
- var ContainsFlags = import_v4.z.object({
1508
- anyOf: import_v4.z.array(Flag).optional(),
1509
- noneOf: import_v4.z.array(Flag).optional(),
1510
- allOf: import_v4.z.array(Flag).optional()
1511
- }).meta({
1512
- id: "ContainsFlags"
1513
- });
1514
1533
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1515
1534
  id: "Within"
1516
1535
  });
@@ -2983,7 +3002,7 @@ var LanguageConfig = z26.object({
2983
3002
  });
2984
3003
 
2985
3004
  // ../commons/src/events/EventConfig.ts
2986
- var z33 = __toESM(require("zod/v4"));
3005
+ var z34 = __toESM(require("zod/v4"));
2987
3006
 
2988
3007
  // ../commons/src/events/SummaryConfig.ts
2989
3008
  var z27 = __toESM(require("zod/v4"));
@@ -3143,162 +3162,145 @@ var AdvancedSearchConfig = z28.object({
3143
3162
  description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
3144
3163
  });
3145
3164
 
3146
- // ../commons/src/events/utils.ts
3147
- var import_lodash = require("lodash");
3148
-
3149
- // ../commons/src/conditionals/validate.ts
3150
- var import__ = __toESM(require("ajv/dist/2019"));
3151
- var import_ajv_formats = __toESM(require("ajv-formats"));
3152
- var z31 = __toESM(require("zod/v4"));
3153
- var import_date_fns = require("date-fns");
3154
-
3155
- // ../commons/src/events/FieldTypeMapping.ts
3156
- var z30 = __toESM(require("zod/v4"));
3157
-
3158
- // ../commons/src/events/DynamicFieldValue.ts
3165
+ // ../commons/src/icons.ts
3159
3166
  var z29 = __toESM(require("zod/v4"));
3160
-
3161
- // ../commons/src/conditionals/validate.ts
3162
- var ajv = new import__.default({
3163
- $data: true,
3164
- allowUnionTypes: true,
3165
- strict: false
3166
- // Allow minContains and other newer features
3167
- });
3168
- var DataContext = z31.object({
3169
- rootData: z31.object({
3170
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3171
- })
3172
- });
3173
- function resolveDataPath(rootData, dataPath, instancePath) {
3174
- const pathParts = dataPath.split("/");
3175
- const levels = parseInt(pathParts[0], 10);
3176
- const referencePath = pathParts.slice(1);
3177
- const instanceParts = instancePath.split("/").filter(Boolean);
3178
- const traversedParts = instanceParts.slice(0, -levels);
3179
- let current = rootData;
3180
- for (const part of traversedParts) {
3181
- if (current === null || current === void 0) {
3182
- return void 0;
3183
- }
3184
- current = current[part];
3185
- }
3186
- for (const part of referencePath) {
3187
- if (current === null || current === void 0) {
3188
- return void 0;
3189
- }
3190
- current = current[part];
3191
- }
3192
- return current;
3193
- }
3194
- function todayISO() {
3195
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3196
- }
3197
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3198
- function compileClientFunction(code) {
3199
- let fn = compiledFunctionCache.get(code);
3200
- if (!fn) {
3201
- fn = new Function(`return (${code})`)();
3202
- compiledFunctionCache.set(code, fn);
3203
- }
3204
- return fn;
3205
- }
3206
- (0, import_ajv_formats.default)(ajv);
3207
- function buildClientFunctionContext(input) {
3208
- return {
3209
- $form: input.form,
3210
- $now: todayISO(),
3211
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3212
- $online: isOnline(),
3213
- $user: input.validatorContext?.user,
3214
- $event: input.validatorContext?.event,
3215
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3216
- user: input.systemVariables?.user,
3217
- $window: input.systemVariables?.$window,
3218
- locations: input.locations,
3219
- adminLevelIds: input.adminLevelIds
3220
- };
3221
- }
3222
- function runClientFunction(code, data, context) {
3223
- return compileClientFunction(code)(data, context);
3224
- }
3225
- ajv.addKeyword({
3226
- keyword: "daysFromDate",
3227
- type: "string",
3228
- schemaType: "object",
3229
- $data: true,
3230
- errors: true,
3231
- validate(schema, data, _2, dataContext) {
3232
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3233
- throw new Error("Validation context must contain $now");
3234
- }
3235
- const { days, clause } = schema;
3236
- if (typeof data !== "string") {
3237
- return false;
3238
- }
3239
- const date = new Date(data);
3240
- if (isNaN(date.getTime())) {
3241
- return false;
3242
- }
3243
- let referenceDate = schema.referenceDate;
3244
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3245
- referenceDate = resolveDataPath(
3246
- dataContext.rootData,
3247
- referenceDate.$data,
3248
- dataContext.instancePath
3249
- );
3250
- }
3251
- if (!referenceDate) {
3252
- referenceDate = dataContext.rootData.$now;
3253
- }
3254
- const baseDate = new Date(referenceDate);
3255
- if (isNaN(baseDate.getTime())) {
3256
- return false;
3257
- }
3258
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3259
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3260
- }
3261
- });
3262
- ajv.addKeyword({
3263
- keyword: "isLeafLevelLocation",
3264
- type: "string",
3265
- schemaType: "boolean",
3266
- $data: true,
3267
- errors: true,
3268
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3269
- validate(_schema, data, _2, dataContext) {
3270
- const locationIdInput = data;
3271
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3272
- return locations.some((location) => location.id === locationIdInput);
3273
- }
3274
- });
3275
- ajv.addKeyword({
3276
- keyword: "customClientValidator",
3277
- schemaType: "object",
3278
- errors: true,
3279
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3280
- // `validate()` callers build root data via `buildClientFunctionContext`,
3281
- // so the cast holds.
3282
- validate(schema, data, _2, dataContext) {
3283
- return Boolean(
3284
- runClientFunction(
3285
- schema.code,
3286
- data,
3287
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3288
- )
3289
- );
3290
- }
3291
- });
3292
- function isOnline() {
3293
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3294
- return navigator.onLine;
3295
- }
3296
- return true;
3297
- }
3167
+ var AvailableIcons = z29.enum([
3168
+ "Archived",
3169
+ "Assigned",
3170
+ "Briefcase",
3171
+ "Certified",
3172
+ "Close",
3173
+ "Collapse",
3174
+ "Draft",
3175
+ "DuplicateYellow",
3176
+ "Expand",
3177
+ "ExternalValidate",
3178
+ "FilledCheck",
3179
+ "InReview",
3180
+ "Offline",
3181
+ "Registered",
3182
+ "RequiresUpdates",
3183
+ "Sent",
3184
+ "Validated",
3185
+ "WaitingApproval",
3186
+ "ChartActivity",
3187
+ "Activity",
3188
+ "Archive",
3189
+ "ArchiveTray",
3190
+ "ArrowLeft",
3191
+ "ArrowRight",
3192
+ "Buildings",
3193
+ "Circle",
3194
+ "CaretDown",
3195
+ "CaretLeft",
3196
+ "CaretRight",
3197
+ "ChartBar",
3198
+ "ChartLine",
3199
+ "ChatCircle",
3200
+ "CheckSquare",
3201
+ "Compass",
3202
+ "Check",
3203
+ "Copy",
3204
+ "Database",
3205
+ "DotsThreeVertical",
3206
+ "ArrowCounterClockwise",
3207
+ "MagnifyingGlassMinus",
3208
+ "MagnifyingGlassPlus",
3209
+ "Export",
3210
+ "Eye",
3211
+ "EyeSlash",
3212
+ "Envelope",
3213
+ "File",
3214
+ "FileLock",
3215
+ "FileSearch",
3216
+ "FileMinus",
3217
+ "FilePlus",
3218
+ "FileText",
3219
+ "FileX",
3220
+ "Handshake",
3221
+ "Gear",
3222
+ "GitBranch",
3223
+ "IdentificationCard",
3224
+ "List",
3225
+ "ListBullets",
3226
+ "Lock",
3227
+ "MagnifyingGlass",
3228
+ "MapPin",
3229
+ "Medal",
3230
+ "NotePencil",
3231
+ "Paperclip",
3232
+ "PaperPlaneTilt",
3233
+ "Pen",
3234
+ "PenNib",
3235
+ "Pencil",
3236
+ "PencilSimpleLine",
3237
+ "Phone",
3238
+ "Plus",
3239
+ "Printer",
3240
+ "SignOut",
3241
+ "Stamp",
3242
+ "Star",
3243
+ "Target",
3244
+ "TextT",
3245
+ "Trash",
3246
+ "UploadSimple",
3247
+ "User",
3248
+ "UserPlus",
3249
+ "Users",
3250
+ "WarningCircle",
3251
+ "X",
3252
+ "ChatText",
3253
+ "CircleWavyCheck",
3254
+ "CircleWavyQuestion",
3255
+ "ArchiveBox",
3256
+ "ArrowCircleDown",
3257
+ "FileArrowUp",
3258
+ "FileDotted",
3259
+ "Files",
3260
+ "PencilLine",
3261
+ "PencilCircle",
3262
+ "UserCircle",
3263
+ "Clock",
3264
+ "QrCode",
3265
+ "Webcam",
3266
+ "Sun",
3267
+ "DeviceTabletCamera",
3268
+ "Globe",
3269
+ "Fingerprint",
3270
+ "PushPin",
3271
+ "Timer"
3272
+ ]);
3273
+
3274
+ // ../commons/src/events/utils.ts
3275
+ var import_lodash4 = require("lodash");
3276
+
3277
+ // ../commons/src/conditionals/validate.ts
3278
+ var import__ = __toESM(require("ajv/dist/2019"));
3279
+ var import_ajv_formats = __toESM(require("ajv-formats"));
3280
+ var z33 = __toESM(require("zod/v4"));
3281
+ var import_date_fns2 = require("date-fns");
3282
+
3283
+ // ../commons/src/events/FieldTypeMapping.ts
3284
+ var z31 = __toESM(require("zod/v4"));
3285
+
3286
+ // ../commons/src/events/DynamicFieldValue.ts
3287
+ var z30 = __toESM(require("zod/v4"));
3288
+
3289
+ // ../commons/src/events/state/index.ts
3290
+ var import_lodash3 = require("lodash");
3298
3291
 
3299
3292
  // ../commons/src/utils.ts
3300
3293
  var z32 = __toESM(require("zod/v4"));
3301
3294
  var _ = __toESM(require("lodash"));
3295
+ function getOrThrow(x, message) {
3296
+ if (x === void 0 || x === null) {
3297
+ throw new Error(message);
3298
+ }
3299
+ return x;
3300
+ }
3301
+ function joinValues(values, separator = " ") {
3302
+ return values.filter((value) => !!value).join(separator).trim();
3303
+ }
3302
3304
  var FullNameV1 = z32.array(
3303
3305
  z32.object({
3304
3306
  use: z32.string(),
@@ -3319,39 +3321,265 @@ function omitKeyDeep(obj, keyToRemove) {
3319
3321
  newObj[key] = omitKeyDeep(obj[key], keyToRemove);
3320
3322
  }
3321
3323
  }
3322
- return newObj;
3324
+ return newObj;
3325
+ }
3326
+
3327
+ // ../commons/src/events/state/utils.ts
3328
+ var import_lodash = require("lodash");
3329
+ function getActionRequests(actionType, actions) {
3330
+ const filtered = actions.filter((action) => action.type === actionType).reverse();
3331
+ const accept = filtered.find(
3332
+ (action) => action.status === ActionStatus.Accepted
3333
+ );
3334
+ const request = filtered.find(
3335
+ (action) => action.status === ActionStatus.Requested
3336
+ );
3337
+ const reject = filtered.find(
3338
+ (action) => action.status === ActionStatus.Rejected
3339
+ );
3340
+ return {
3341
+ reject,
3342
+ accept,
3343
+ request
3344
+ };
3345
+ }
3346
+ function getDeclarationActionCreationMetadata(actionType, actions) {
3347
+ const { accept: acceptAction, request: requestAction } = getActionRequests(
3348
+ actionType,
3349
+ actions
3350
+ );
3351
+ if (!acceptAction) {
3352
+ return null;
3353
+ }
3354
+ const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3355
+ return {
3356
+ // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3357
+ createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3358
+ createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3359
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3360
+ createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3361
+ acceptedAt: acceptAction.createdAt,
3362
+ createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3363
+ registrationNumber
3364
+ };
3365
+ }
3366
+ var updateActions = ActionTypes.extract([
3367
+ ActionType.CREATE,
3368
+ ActionType.NOTIFY,
3369
+ ActionType.EDIT,
3370
+ ActionType.DECLARE,
3371
+ ActionType.REGISTER,
3372
+ ActionType.REJECT,
3373
+ ActionType.ARCHIVE,
3374
+ ActionType.UNARCHIVE,
3375
+ ActionType.PRINT_CERTIFICATE,
3376
+ ActionType.REQUEST_CORRECTION,
3377
+ ActionType.APPROVE_CORRECTION,
3378
+ ActionType.REJECT_CORRECTION,
3379
+ ActionType.CUSTOM
3380
+ ]);
3381
+ function getActionUpdateMetadata(actions) {
3382
+ const createAction = getOrThrow(
3383
+ actions.find((action) => action.type === ActionType.CREATE),
3384
+ `Event has no ${ActionType.CREATE} action`
3385
+ );
3386
+ const metadataFields = [
3387
+ "createdAt",
3388
+ "createdBy",
3389
+ "createdByUserType",
3390
+ "createdAtLocation",
3391
+ "createdByRole"
3392
+ ];
3393
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3394
+ (_2, action) => {
3395
+ if (action.originalActionId) {
3396
+ const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3397
+ return (0, import_lodash.pick)(originalAction, metadataFields);
3398
+ }
3399
+ return (0, import_lodash.pick)(action, metadataFields);
3400
+ },
3401
+ (0, import_lodash.pick)(createAction, metadataFields)
3402
+ );
3403
+ }
3404
+ function getLegalStatuses(actions) {
3405
+ return {
3406
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3407
+ ActionType.NOTIFY,
3408
+ actions
3409
+ ),
3410
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3411
+ ActionType.DECLARE,
3412
+ actions
3413
+ ),
3414
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3415
+ ActionType.REGISTER,
3416
+ actions
3417
+ )
3418
+ };
3419
+ }
3420
+
3421
+ // ../commons/src/events/state/flags.ts
3422
+ var import_lodash2 = require("lodash");
3423
+ var import_date_fns = require("date-fns");
3424
+ function isFlagConditionMet(conditional, form, action) {
3425
+ 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" });
3426
+ return validate(conditional, {
3427
+ $form: form,
3428
+ $now: now2,
3429
+ $online: true,
3430
+ $user: {
3431
+ sub: "",
3432
+ exp: "",
3433
+ role: action.createdByRole,
3434
+ algorithm: "",
3435
+ scope: [],
3436
+ userType: action.createdByUserType
3437
+ }
3438
+ });
3439
+ }
3440
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3441
+ if (!isActionConfigType(action.type)) {
3442
+ return false;
3443
+ }
3444
+ const actionConfig = getActionConfig({
3445
+ eventConfiguration,
3446
+ actionType: action.type,
3447
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3448
+ });
3449
+ const removeOperations = (actionConfig?.flags ?? []).filter(
3450
+ ({ id, operation }) => id === flagId && operation === "remove"
3451
+ );
3452
+ if (removeOperations.length === 0) {
3453
+ return false;
3454
+ }
3455
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3456
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3457
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3458
+ const form = { ...declaration, ...annotation };
3459
+ return removeOperations.some(
3460
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3461
+ );
3462
+ }
3463
+ var INHERENT_FLAG_RULES = [
3464
+ {
3465
+ flag: InherentFlags.CORRECTION_REQUESTED,
3466
+ setOn: [ActionType.REQUEST_CORRECTION],
3467
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3468
+ },
3469
+ {
3470
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3471
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3472
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3473
+ // round trip and comes back exactly as it was.
3474
+ flag: InherentFlags.INCOMPLETE,
3475
+ setOn: [ActionType.NOTIFY],
3476
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3477
+ },
3478
+ {
3479
+ flag: InherentFlags.REJECTED,
3480
+ setOn: [ActionType.REJECT],
3481
+ resetOn: [
3482
+ ActionType.NOTIFY,
3483
+ ActionType.DECLARE,
3484
+ ActionType.EDIT,
3485
+ ActionType.REGISTER
3486
+ ]
3487
+ },
3488
+ {
3489
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3490
+ setOn: [ActionType.DUPLICATE_DETECTED],
3491
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3492
+ },
3493
+ {
3494
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3495
+ setOn: [ActionType.EDIT],
3496
+ resetOnAnyOtherAction: true
3497
+ }
3498
+ ];
3499
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3500
+ return acceptedActions.reduce((present, action, idx) => {
3501
+ if (rule.setOn.includes(action.type)) {
3502
+ return true;
3503
+ }
3504
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3505
+ return false;
3506
+ }
3507
+ if (actionConfigRemovesFlag(
3508
+ action,
3509
+ rule.flag,
3510
+ acceptedActions.slice(0, idx + 1),
3511
+ event2,
3512
+ eventConfiguration
3513
+ )) {
3514
+ return false;
3515
+ }
3516
+ return present;
3517
+ }, false);
3323
3518
  }
3324
-
3325
- // ../commons/src/events/utils.ts
3326
- var import_date_fns2 = require("date-fns");
3327
- function getDeclarationFields(configuration) {
3328
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3519
+ function resolveEventCustomFlags(event2, eventConfiguration) {
3520
+ const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3521
+ return actions.reduce((acc, action, idx) => {
3522
+ let actionConfig;
3523
+ if (isActionConfigType(action.type)) {
3524
+ actionConfig = getActionConfig({
3525
+ eventConfiguration,
3526
+ actionType: action.type,
3527
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3528
+ });
3529
+ }
3530
+ if (!actionConfig) {
3531
+ return acc;
3532
+ }
3533
+ const eventUpToThisAction = {
3534
+ ...event2,
3535
+ actions: actions.slice(0, idx + 1)
3536
+ };
3537
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3538
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3539
+ const form = { ...declaration, ...annotation };
3540
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3541
+ ({ conditional }) => (
3542
+ // If conditional is not provided, the flag is resolved
3543
+ conditional ? isFlagConditionMet(conditional, form, action) : true
3544
+ )
3545
+ );
3546
+ const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3547
+ const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3548
+ const flags = [...acc, ...addedFlags].filter(
3549
+ (flagId) => !removedFlags.includes(flagId)
3550
+ );
3551
+ return (0, import_lodash2.uniq)(flags);
3552
+ }, []);
3329
3553
  }
3330
- var getActionAnnotationFields = (actionConfig) => {
3331
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3332
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3333
- }
3334
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3335
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3336
- }
3337
- const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3338
- const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3339
- return [...reviewFields, ...formFields];
3340
- };
3341
- function getAllAnnotationFields(config) {
3342
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3554
+ function getActionStatusFlags(sortedActions) {
3555
+ const actionStatus = sortedActions.reduce(
3556
+ (actionStatuses, { type, status: status2 }) => ({
3557
+ ...actionStatuses,
3558
+ [type]: status2
3559
+ }),
3560
+ {}
3561
+ );
3562
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
3563
+ const flag2 = joinValues([type, status2], ":").toLowerCase();
3564
+ return flag2;
3565
+ });
3566
+ }
3567
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
3568
+ const acceptedActions = sortedActions.filter(
3569
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
3570
+ );
3571
+ return INHERENT_FLAG_RULES.filter(
3572
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3573
+ ).map(({ flag: flag2 }) => flag2);
3574
+ }
3575
+ function getEventFlags(event2, config) {
3576
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3577
+ return [
3578
+ ...getActionStatusFlags(sortedActions),
3579
+ ...getInherentFlags(sortedActions, event2, config),
3580
+ ...resolveEventCustomFlags(event2, config)
3581
+ ];
3343
3582
  }
3344
- var findAllFields = (config) => {
3345
- return (0, import_lodash.flattenDeep)([
3346
- ...getDeclarationFields(config),
3347
- ...getAllAnnotationFields(config)
3348
- ]);
3349
- };
3350
- var EXCLUDED_ACTIONS = [
3351
- ActionType.REQUEST_CORRECTION,
3352
- ActionType.PRINT_CERTIFICATE,
3353
- ActionType.REJECT_CORRECTION
3354
- ];
3355
3583
 
3356
3584
  // ../commons/src/conditionals/conditionals.ts
3357
3585
  var objectHash = __toESM(require("object-hash"));
@@ -3559,6 +3787,33 @@ function defineComparison(field3, value, keyword) {
3559
3787
  required: [field3.$$field]
3560
3788
  });
3561
3789
  }
3790
+ function flag(flagvalue) {
3791
+ return defineConditional({
3792
+ type: "object",
3793
+ properties: {
3794
+ $flags: {
3795
+ type: "array",
3796
+ contains: {
3797
+ type: "string",
3798
+ const: flagvalue
3799
+ }
3800
+ }
3801
+ },
3802
+ required: ["$flags"]
3803
+ });
3804
+ }
3805
+ function status(statusValue) {
3806
+ return defineConditional({
3807
+ type: "object",
3808
+ properties: {
3809
+ $status: {
3810
+ type: "string",
3811
+ const: statusValue
3812
+ }
3813
+ },
3814
+ required: ["$status"]
3815
+ });
3816
+ }
3562
3817
  function createFieldConditionals(fieldId) {
3563
3818
  const getDayRange = (field3, days, clause, referenceDate) => ({
3564
3819
  type: "object",
@@ -3960,6 +4215,512 @@ function createFieldConditionals(fieldId) {
3960
4215
  };
3961
4216
  }
3962
4217
 
4218
+ // ../commons/src/events/state/index.ts
4219
+ function getStatusFromActions(actions) {
4220
+ const acceptedActions = actions.filter(
4221
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
4222
+ );
4223
+ const isCurrentlyArchived = acceptedActions.reduce(
4224
+ (archived, action) => {
4225
+ if (action.type === ActionType.ARCHIVE) {
4226
+ return true;
4227
+ }
4228
+ if (action.type === ActionType.UNARCHIVE) {
4229
+ return false;
4230
+ }
4231
+ return archived;
4232
+ },
4233
+ false
4234
+ );
4235
+ if (isCurrentlyArchived) {
4236
+ return EventStatus.enum.ARCHIVED;
4237
+ }
4238
+ return acceptedActions.filter(
4239
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4240
+ ).reduce((status2, action) => {
4241
+ switch (action.type) {
4242
+ case ActionType.CREATE:
4243
+ return EventStatus.enum.CREATED;
4244
+ case ActionType.DECLARE:
4245
+ return EventStatus.enum.DECLARED;
4246
+ case ActionType.REGISTER:
4247
+ return EventStatus.enum.REGISTERED;
4248
+ case ActionType.NOTIFY:
4249
+ return EventStatus.enum.NOTIFIED;
4250
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
4251
+ case ActionType.ARCHIVE:
4252
+ case ActionType.UNARCHIVE:
4253
+ case ActionType.CUSTOM:
4254
+ case ActionType.PRINT_CERTIFICATE:
4255
+ case ActionType.ASSIGN:
4256
+ case ActionType.UNASSIGN:
4257
+ case ActionType.REJECT:
4258
+ case ActionType.REQUEST_CORRECTION:
4259
+ case ActionType.APPROVE_CORRECTION:
4260
+ case ActionType.DUPLICATE_DETECTED:
4261
+ case ActionType.MARK_AS_NOT_DUPLICATE:
4262
+ case ActionType.MARK_AS_DUPLICATE:
4263
+ case ActionType.REJECT_CORRECTION:
4264
+ case ActionType.READ:
4265
+ case ActionType.EDIT:
4266
+ default:
4267
+ return status2;
4268
+ }
4269
+ }, EventStatus.enum.CREATED);
4270
+ }
4271
+ function getAssignedUserFromActions(actions) {
4272
+ return actions.reduce((user2, action) => {
4273
+ if (action.type === ActionType.ASSIGN) {
4274
+ return action.assignedTo;
4275
+ }
4276
+ if (action.type === ActionType.UNASSIGN) {
4277
+ return null;
4278
+ }
4279
+ return user2;
4280
+ }, null);
4281
+ }
4282
+ function deepDropNulls(obj) {
4283
+ if (Array.isArray(obj)) {
4284
+ return obj.map(deepDropNulls);
4285
+ }
4286
+ if (obj !== null && typeof obj === "object") {
4287
+ return Object.entries(obj).reduce((acc, [key, value]) => {
4288
+ const cleanedValue = deepDropNulls(value);
4289
+ if (cleanedValue !== null) {
4290
+ ;
4291
+ acc[key] = cleanedValue;
4292
+ }
4293
+ return acc;
4294
+ }, {});
4295
+ }
4296
+ return obj;
4297
+ }
4298
+ var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4299
+ function extractDateString(dateTime) {
4300
+ return dateTime.split("T")[0];
4301
+ }
4302
+ function resolveDateOfEvent(eventIndex, declaration, config) {
4303
+ if (!config.dateOfEvent) {
4304
+ return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4305
+ }
4306
+ const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4307
+ getMixedPath(eventIndex, config.dateOfEvent.$$event)
4308
+ );
4309
+ return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4310
+ }
4311
+ var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4312
+ function getParsedUUID(value, oldValue) {
4313
+ const parsed = UUID.safeParse(value);
4314
+ return parsed.success ? parsed.data : oldValue;
4315
+ }
4316
+ function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4317
+ let placeOfEvent = getParsedUUID(
4318
+ eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4319
+ );
4320
+ if (config.placeOfEvent) {
4321
+ const addressFieldValue = AddressFieldValue.safeParse(
4322
+ declaration[config.placeOfEvent.$$field]
4323
+ );
4324
+ if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4325
+ placeOfEvent = getParsedUUID(
4326
+ addressFieldValue.data.administrativeArea,
4327
+ placeOfEvent
4328
+ );
4329
+ } else {
4330
+ placeOfEvent = getParsedUUID(
4331
+ declaration[config.placeOfEvent.$$field],
4332
+ placeOfEvent
4333
+ );
4334
+ }
4335
+ }
4336
+ return placeOfEvent;
4337
+ }
4338
+ function extractPotentialDuplicatesFromActions(actions) {
4339
+ return actions.reduce((duplicates, action) => {
4340
+ if (action.type === ActionType.DUPLICATE_DETECTED) {
4341
+ duplicates = action.content.duplicates;
4342
+ }
4343
+ if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4344
+ duplicates = [];
4345
+ }
4346
+ return duplicates;
4347
+ }, []);
4348
+ }
4349
+ function getCurrentEventState(event2, config) {
4350
+ const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4351
+ const creationAction = sortedActions.find(
4352
+ (action) => action.type === ActionType.CREATE
4353
+ );
4354
+ if (!creationAction) {
4355
+ throw new Error(`Event ${event2.id} has no creation action`);
4356
+ }
4357
+ const acceptedActions = getAcceptedActions(event2).sort(
4358
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
4359
+ );
4360
+ const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4361
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4362
+ const declaration = aggregateActionDeclarations(event2);
4363
+ const status2 = getStatusFromActions(sortedActions);
4364
+ const legalStatuses = getLegalStatuses(sortedActions);
4365
+ const base = deepDropNulls({
4366
+ id: event2.id,
4367
+ type: event2.type,
4368
+ status: status2,
4369
+ legalStatuses,
4370
+ createdAt: creationAction.createdAt,
4371
+ createdBy: creationAction.createdBy,
4372
+ createdByUserType: creationAction.createdByUserType,
4373
+ createdAtLocation: creationAction.createdAtLocation,
4374
+ updatedAt: acceptedActionMetadata.createdAt,
4375
+ assignedTo: getAssignedUserFromActions(acceptedActions),
4376
+ updatedBy: requestActionMetadata.createdBy,
4377
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
4378
+ declaration,
4379
+ trackingId: event2.trackingId,
4380
+ updatedByUserRole: requestActionMetadata.createdByRole,
4381
+ placeOfEvent: resolvePlaceOfEvent(
4382
+ { createdAtLocation: creationAction.createdAtLocation },
4383
+ declaration,
4384
+ config
4385
+ ),
4386
+ potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4387
+ flags: getEventFlags(event2, config)
4388
+ });
4389
+ return deepDropNulls({
4390
+ ...base,
4391
+ dateOfEvent: resolveDateOfEvent(base, declaration, config)
4392
+ });
4393
+ }
4394
+
4395
+ // ../commons/src/conditionals/validate.ts
4396
+ var ajv = new import__.default({
4397
+ $data: true,
4398
+ allowUnionTypes: true,
4399
+ strict: false
4400
+ // Allow minContains and other newer features
4401
+ });
4402
+ var DataContext = z33.object({
4403
+ rootData: z33.object({
4404
+ $leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
4405
+ })
4406
+ });
4407
+ function resolveDataPath(rootData, dataPath, instancePath) {
4408
+ const pathParts = dataPath.split("/");
4409
+ const levels = parseInt(pathParts[0], 10);
4410
+ const referencePath = pathParts.slice(1);
4411
+ const instanceParts = instancePath.split("/").filter(Boolean);
4412
+ const traversedParts = instanceParts.slice(0, -levels);
4413
+ let current = rootData;
4414
+ for (const part of traversedParts) {
4415
+ if (current === null || current === void 0) {
4416
+ return void 0;
4417
+ }
4418
+ current = current[part];
4419
+ }
4420
+ for (const part of referencePath) {
4421
+ if (current === null || current === void 0) {
4422
+ return void 0;
4423
+ }
4424
+ current = current[part];
4425
+ }
4426
+ return current;
4427
+ }
4428
+ function todayISO() {
4429
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4430
+ }
4431
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4432
+ function compileClientFunction(code) {
4433
+ let fn = compiledFunctionCache.get(code);
4434
+ if (!fn) {
4435
+ fn = new Function(`return (${code})`)();
4436
+ compiledFunctionCache.set(code, fn);
4437
+ }
4438
+ return fn;
4439
+ }
4440
+ (0, import_ajv_formats.default)(ajv);
4441
+ function buildClientFunctionContext(input) {
4442
+ const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
4443
+ input.validatorContext?.event,
4444
+ input.validatorContext?.eventConfig
4445
+ )?.flags : [];
4446
+ return {
4447
+ $form: input.form,
4448
+ $flags: flags,
4449
+ $now: todayISO(),
4450
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4451
+ $online: isOnline(),
4452
+ $user: input.validatorContext?.user,
4453
+ $event: input.validatorContext?.event,
4454
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4455
+ user: input.systemVariables?.user,
4456
+ $window: input.systemVariables?.$window,
4457
+ locations: input.locations,
4458
+ adminLevelIds: input.adminLevelIds
4459
+ };
4460
+ }
4461
+ function runClientFunction(code, data, context) {
4462
+ return compileClientFunction(code)(data, context);
4463
+ }
4464
+ ajv.addKeyword({
4465
+ keyword: "daysFromDate",
4466
+ type: "string",
4467
+ schemaType: "object",
4468
+ $data: true,
4469
+ errors: true,
4470
+ validate(schema, data, _2, dataContext) {
4471
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4472
+ throw new Error("Validation context must contain $now");
4473
+ }
4474
+ const { days, clause } = schema;
4475
+ if (typeof data !== "string") {
4476
+ return false;
4477
+ }
4478
+ const date = new Date(data);
4479
+ if (isNaN(date.getTime())) {
4480
+ return false;
4481
+ }
4482
+ let referenceDate = schema.referenceDate;
4483
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4484
+ referenceDate = resolveDataPath(
4485
+ dataContext.rootData,
4486
+ referenceDate.$data,
4487
+ dataContext.instancePath
4488
+ );
4489
+ }
4490
+ if (!referenceDate) {
4491
+ referenceDate = dataContext.rootData.$now;
4492
+ }
4493
+ const baseDate = new Date(referenceDate);
4494
+ if (isNaN(baseDate.getTime())) {
4495
+ return false;
4496
+ }
4497
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4498
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4499
+ }
4500
+ });
4501
+ ajv.addKeyword({
4502
+ keyword: "isLeafLevelLocation",
4503
+ type: "string",
4504
+ schemaType: "boolean",
4505
+ $data: true,
4506
+ errors: true,
4507
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4508
+ validate(_schema, data, _2, dataContext) {
4509
+ const locationIdInput = data;
4510
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4511
+ return locations.some((location) => location.id === locationIdInput);
4512
+ }
4513
+ });
4514
+ function isAgeValue(value) {
4515
+ return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4516
+ }
4517
+ ajv.addKeyword({
4518
+ keyword: "customClientValidator",
4519
+ schemaType: "object",
4520
+ errors: true,
4521
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4522
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4523
+ // so the cast holds.
4524
+ validate(schema, data, _2, dataContext) {
4525
+ return Boolean(
4526
+ runClientFunction(
4527
+ schema.code,
4528
+ data,
4529
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4530
+ )
4531
+ );
4532
+ }
4533
+ });
4534
+ function validate(schema, data) {
4535
+ const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4536
+ if ("$form" in data) {
4537
+ const entries = Object.entries(data.$form).map(([key, value]) => {
4538
+ if (!isAgeValue(value)) {
4539
+ return [key, value];
4540
+ }
4541
+ const age = value.age;
4542
+ const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4543
+ return [
4544
+ key,
4545
+ {
4546
+ age,
4547
+ dob: ageToDate(
4548
+ age,
4549
+ maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4550
+ )
4551
+ }
4552
+ ];
4553
+ });
4554
+ data.$form = Object.fromEntries(entries);
4555
+ }
4556
+ const result = validator(data);
4557
+ return result;
4558
+ }
4559
+ function isOnline() {
4560
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4561
+ return navigator.onLine;
4562
+ }
4563
+ return true;
4564
+ }
4565
+
4566
+ // ../commons/src/events/utils.ts
4567
+ var import_date_fns3 = require("date-fns");
4568
+ function ageToDate(age, asOfDate) {
4569
+ const date = plainDateToLocalDate(asOfDate);
4570
+ return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4571
+ }
4572
+ function getDeclarationFields(configuration) {
4573
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4574
+ }
4575
+ function isActionConfigType(type) {
4576
+ return actionConfigTypes.has(type);
4577
+ }
4578
+ function getActionConfig({
4579
+ eventConfiguration,
4580
+ actionType,
4581
+ customActionType
4582
+ }) {
4583
+ if (actionType === ActionType.NOTIFY) {
4584
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4585
+ }
4586
+ return eventConfiguration.actions.find((a) => {
4587
+ if (a.type === ActionType.CUSTOM && customActionType) {
4588
+ return a.customActionType === customActionType;
4589
+ }
4590
+ return a.type === actionType;
4591
+ });
4592
+ }
4593
+ var getActionAnnotationFields = (actionConfig) => {
4594
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4595
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4596
+ }
4597
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4598
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4599
+ }
4600
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4601
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4602
+ return [...reviewFields, ...formFields];
4603
+ };
4604
+ function getAllAnnotationFields(config) {
4605
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4606
+ }
4607
+ function deepMerge(currentDocument, actionDocument) {
4608
+ const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4609
+ return (0, import_lodash4.mergeWith)(
4610
+ (0, import_lodash4.cloneDeep)(currentDocumentClone),
4611
+ actionDocument,
4612
+ (previousValue, incomingValue) => {
4613
+ if (incomingValue === void 0) {
4614
+ return previousValue;
4615
+ }
4616
+ if ((0, import_lodash4.isArray)(incomingValue)) {
4617
+ return incomingValue;
4618
+ }
4619
+ if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4620
+ return void 0;
4621
+ }
4622
+ return incomingValue;
4623
+ }
4624
+ );
4625
+ }
4626
+ var findAllFields = (config) => {
4627
+ return (0, import_lodash4.flattenDeep)([
4628
+ ...getDeclarationFields(config),
4629
+ ...getAllAnnotationFields(config)
4630
+ ]);
4631
+ };
4632
+ function getMixedPath(obj, path, defaultValue) {
4633
+ const parts = path.split(".");
4634
+ const resolve = (current, segments) => {
4635
+ if (current == null || segments.length === 0) {
4636
+ return current;
4637
+ }
4638
+ for (let i = segments.length; i > 0; i--) {
4639
+ const compoundKey = segments.slice(0, i).join(".");
4640
+ if ((0, import_lodash4.has)(current, compoundKey)) {
4641
+ const next = (0, import_lodash4.get)(current, compoundKey);
4642
+ return resolve(next, segments.slice(i));
4643
+ }
4644
+ }
4645
+ return void 0;
4646
+ };
4647
+ const result = resolve(obj, parts);
4648
+ return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4649
+ }
4650
+ function isAcceptedAction(a) {
4651
+ return a.status === ActionStatus.Accepted;
4652
+ }
4653
+ function getCompleteActionAnnotation(event2, action) {
4654
+ if (action.originalActionId) {
4655
+ const originalAction = event2.actions.find(
4656
+ ({ id }) => id === action.originalActionId
4657
+ );
4658
+ if (originalAction?.status === ActionStatus.Requested) {
4659
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4660
+ }
4661
+ }
4662
+ return action.annotation ?? {};
4663
+ }
4664
+ function getCompleteActionDeclaration(declaration, event2, action) {
4665
+ if (action.originalActionId) {
4666
+ const originalAction = event2.actions.find(
4667
+ ({ id }) => id === action.originalActionId
4668
+ );
4669
+ if (originalAction?.status === ActionStatus.Requested) {
4670
+ return deepMerge(
4671
+ deepMerge(declaration, originalAction.declaration),
4672
+ action.declaration
4673
+ );
4674
+ }
4675
+ }
4676
+ return deepMerge(declaration, action.declaration);
4677
+ }
4678
+ function getAcceptedActions(event2) {
4679
+ return event2.actions.filter(isAcceptedAction).map((action) => ({
4680
+ ...action,
4681
+ declaration: getCompleteActionDeclaration({}, event2, action),
4682
+ annotation: getCompleteActionAnnotation(event2, action)
4683
+ }));
4684
+ }
4685
+ var EXCLUDED_ACTIONS = [
4686
+ ActionType.REQUEST_CORRECTION,
4687
+ ActionType.PRINT_CERTIFICATE,
4688
+ ActionType.REJECT_CORRECTION
4689
+ ];
4690
+ function aggregateActionDeclarations(event2) {
4691
+ const allAcceptedActions = getAcceptedActions(event2);
4692
+ const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4693
+ return aggregatedActions.reduce((declaration, action) => {
4694
+ if (action.type === ActionType.APPROVE_CORRECTION) {
4695
+ const requestAction = allAcceptedActions.find(
4696
+ ({ id }) => id === action.requestId
4697
+ );
4698
+ if (!requestAction) {
4699
+ return declaration;
4700
+ }
4701
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4702
+ declaration,
4703
+ event2,
4704
+ requestAction
4705
+ );
4706
+ return getCompleteActionDeclaration(
4707
+ declarationWithApprovedCorrection,
4708
+ event2,
4709
+ action
4710
+ );
4711
+ }
4712
+ return getCompleteActionDeclaration(declaration, event2, action);
4713
+ }, {});
4714
+ }
4715
+ function aggregateActionAnnotations(event2) {
4716
+ return event2.actions.reduce((ann, sortedAction) => {
4717
+ if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4718
+ return ann;
4719
+ }
4720
+ return deepMerge(ann, sortedAction.annotation);
4721
+ }, {});
4722
+ }
4723
+
3963
4724
  // ../commons/src/events/eventConfigValidation.ts
3964
4725
  function validateAdvancedSearchConfig(event2, ctx) {
3965
4726
  const allFields = findAllFields(event2);
@@ -4042,9 +4803,9 @@ function validatePlaceOfEvent(event2, ctx) {
4042
4803
  }
4043
4804
  function validateActionFlags(event2, ctx) {
4044
4805
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4045
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4806
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4046
4807
  const actionFlagIds = event2.actions.flatMap(
4047
- (action) => (action.flags ?? []).map((flag) => flag.id)
4808
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4048
4809
  );
4049
4810
  for (const actionFlagId of actionFlagIds) {
4050
4811
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4080,11 +4841,11 @@ function validateActionOrder(event2, ctx) {
4080
4841
  }
4081
4842
 
4082
4843
  // ../commons/src/events/EventConfig.ts
4083
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4844
+ var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4084
4845
  "Reference to a field defined in the event metadata, using the field id."
4085
4846
  );
4086
- var _EventConfigBase = z33.object({
4087
- id: z33.string().describe(
4847
+ var _EventConfigBase = z34.object({
4848
+ id: z34.string().describe(
4088
4849
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4089
4850
  ),
4090
4851
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4103,23 +4864,26 @@ var _EventConfigBase = z33.object({
4103
4864
  "Summary information displayed in the event overview."
4104
4865
  ),
4105
4866
  label: TranslationConfig.describe("Human-readable label for the event type."),
4106
- actions: z33.array(ActionConfig).describe(
4867
+ actions: z34.array(ActionConfig).describe(
4107
4868
  "Configuration of core and custom actions associated with the event."
4108
4869
  ),
4109
- actionOrder: z33.array(z33.string()).optional().describe(
4870
+ actionOrder: z34.array(z34.string()).optional().describe(
4110
4871
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4111
4872
  ),
4112
4873
  declaration: DeclarationFormConfig.describe(
4113
4874
  "Configuration of the form used to gather event data."
4114
4875
  ),
4115
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4876
+ advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
4116
4877
  "Configuration of fields available in the advanced search feature."
4117
4878
  ),
4118
- flags: z33.array(FlagConfig).optional().default([]).describe(
4879
+ flags: z34.array(FlagConfig).optional().default([]).describe(
4119
4880
  "Configuration of custom flags associated with the actions of this event type."
4120
4881
  ),
4121
- analytics: z33.boolean().optional().default(true).describe(
4882
+ analytics: z34.boolean().optional().default(true).describe(
4122
4883
  "Indicates whether the records of this event type are included in analytics"
4884
+ ),
4885
+ icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
4886
+ 'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
4123
4887
  )
4124
4888
  });
4125
4889
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4336,21 +5100,31 @@ var event = Object.assign(eventFn, {
4336
5100
  return {
4337
5101
  $event: field3
4338
5102
  };
4339
- }
5103
+ },
5104
+ /**
5105
+ * Checks if the event currently has the given status.
5106
+ * @param eventStatus - The status to check for.
5107
+ */
5108
+ hasStatus: (eventStatus) => status(eventStatus),
5109
+ /**
5110
+ * Checks if the event currently carries the given flag.
5111
+ * @param flagValue - The flag to check for.
5112
+ */
5113
+ hasFlag: (flagValue) => flag(flagValue)
4340
5114
  });
4341
5115
 
4342
5116
  // ../commons/src/events/WorkqueueColumnConfig.ts
4343
- var z34 = __toESM(require("zod/v4"));
5117
+ var z35 = __toESM(require("zod/v4"));
4344
5118
  var WorkqueueColumnKeysArray = [
4345
5119
  ...EventMetadataKeysArray,
4346
5120
  "title",
4347
5121
  "outbox"
4348
5122
  ];
4349
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4350
- var WorkqueueColumnValue = z34.object({
5123
+ var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
5124
+ var WorkqueueColumnValue = z35.object({
4351
5125
  $event: WorkqueueColumnKeys
4352
5126
  });
4353
- var WorkqueueColumn = z34.object({
5127
+ var WorkqueueColumn = z35.object({
4354
5128
  label: TranslationConfig,
4355
5129
  value: WorkqueueColumnValue
4356
5130
  }).meta({
@@ -4364,164 +5138,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4364
5138
  }
4365
5139
 
4366
5140
  // ../commons/src/events/CountryConfigQueryInput.ts
4367
- var z35 = __toESM(require("zod/v4"));
4368
- var SerializableExact = z35.object({
4369
- type: z35.literal("exact"),
4370
- term: z35.union([z35.string(), SerializedUserField])
4371
- });
4372
- var SerializableWithin = z35.object({
4373
- type: z35.literal("within"),
4374
- location: z35.union([z35.string(), SerializedUserField])
4375
- });
4376
- var SerializedQueryExpression = z35.object({
4377
- eventType: z35.string(),
4378
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4379
- createdAt: z35.optional(DateCondition),
4380
- updatedAt: z35.optional(DateCondition),
4381
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4382
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4383
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4384
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4385
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4386
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4387
- createdAtLocation: z35.optional(
4388
- z35.union([SerializableWithin, SerializableExact])
5141
+ var z36 = __toESM(require("zod/v4"));
5142
+ var SerializableExact = z36.object({
5143
+ type: z36.literal("exact"),
5144
+ term: z36.union([z36.string(), SerializedUserField])
5145
+ });
5146
+ var SerializableWithin = z36.object({
5147
+ type: z36.literal("within"),
5148
+ location: z36.union([z36.string(), SerializedUserField])
5149
+ });
5150
+ var SerializedQueryExpression = z36.object({
5151
+ eventType: z36.string(),
5152
+ status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
5153
+ createdAt: z36.optional(DateCondition),
5154
+ updatedAt: z36.optional(DateCondition),
5155
+ "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
5156
+ "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
5157
+ "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
5158
+ "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
5159
+ "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
5160
+ "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
5161
+ createdAtLocation: z36.optional(
5162
+ z36.union([SerializableWithin, SerializableExact])
4389
5163
  ),
4390
- updatedAtLocation: z35.optional(
4391
- z35.union([SerializableWithin, SerializableExact])
5164
+ updatedAtLocation: z36.optional(
5165
+ z36.union([SerializableWithin, SerializableExact])
4392
5166
  ),
4393
- updatedByUserRole: z35.optional(SerializableExact),
4394
- assignedTo: z35.optional(SerializableExact),
4395
- createdBy: z35.optional(SerializableExact),
5167
+ updatedByUserRole: z36.optional(SerializableExact),
5168
+ assignedTo: z36.optional(SerializableExact),
5169
+ createdBy: z36.optional(SerializableExact),
4396
5170
  createdByUserType: ExactUserType,
4397
- updatedBy: z35.optional(SerializableExact),
4398
- trackingId: z35.optional(Exact),
4399
- flags: z35.optional(ContainsFlags),
5171
+ updatedBy: z36.optional(SerializableExact),
5172
+ trackingId: z36.optional(Exact),
5173
+ flags: z36.optional(ContainsFlags),
4400
5174
  data: QueryInput
4401
5175
  }).partial();
4402
- var Or2 = z35.object({
4403
- type: z35.literal("or"),
4404
- clauses: z35.array(SerializedQueryExpression)
5176
+ var Or2 = z36.object({
5177
+ type: z36.literal("or"),
5178
+ clauses: z36.array(SerializedQueryExpression)
4405
5179
  });
4406
- var And2 = z35.object({
4407
- type: z35.literal("and"),
4408
- clauses: z35.array(SerializedQueryExpression)
5180
+ var And2 = z36.object({
5181
+ type: z36.literal("and"),
5182
+ clauses: z36.array(SerializedQueryExpression)
4409
5183
  });
4410
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4411
- var CountryConfigQueryInputType = z35.union([
5184
+ var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
5185
+ var CountryConfigQueryInputType = z36.union([
4412
5186
  SerializedQueryExpression,
4413
5187
  And2,
4414
5188
  Or2
4415
5189
  ]);
4416
5190
 
4417
- // ../commons/src/icons.ts
4418
- var z36 = __toESM(require("zod/v4"));
4419
- var AvailableIcons = z36.enum([
4420
- "Archived",
4421
- "Assigned",
4422
- "Briefcase",
4423
- "Certified",
4424
- "Close",
4425
- "Collapse",
4426
- "Draft",
4427
- "DuplicateYellow",
4428
- "Expand",
4429
- "ExternalValidate",
4430
- "FilledCheck",
4431
- "InReview",
4432
- "Offline",
4433
- "Registered",
4434
- "RequiresUpdates",
4435
- "Sent",
4436
- "Validated",
4437
- "WaitingApproval",
4438
- "ChartActivity",
4439
- "Activity",
4440
- "Archive",
4441
- "ArchiveTray",
4442
- "ArrowLeft",
4443
- "ArrowRight",
4444
- "Buildings",
4445
- "Circle",
4446
- "CaretDown",
4447
- "CaretLeft",
4448
- "CaretRight",
4449
- "ChartBar",
4450
- "ChartLine",
4451
- "ChatCircle",
4452
- "CheckSquare",
4453
- "Compass",
4454
- "Check",
4455
- "Copy",
4456
- "Database",
4457
- "DotsThreeVertical",
4458
- "ArrowCounterClockwise",
4459
- "MagnifyingGlassMinus",
4460
- "MagnifyingGlassPlus",
4461
- "Export",
4462
- "Eye",
4463
- "EyeSlash",
4464
- "Envelope",
4465
- "File",
4466
- "FileSearch",
4467
- "FileMinus",
4468
- "FilePlus",
4469
- "FileText",
4470
- "FileX",
4471
- "Handshake",
4472
- "Gear",
4473
- "GitBranch",
4474
- "IdentificationCard",
4475
- "List",
4476
- "ListBullets",
4477
- "Lock",
4478
- "MagnifyingGlass",
4479
- "MapPin",
4480
- "Medal",
4481
- "NotePencil",
4482
- "Paperclip",
4483
- "PaperPlaneTilt",
4484
- "Pen",
4485
- "PenNib",
4486
- "Pencil",
4487
- "PencilSimpleLine",
4488
- "Phone",
4489
- "Plus",
4490
- "Printer",
4491
- "SignOut",
4492
- "Stamp",
4493
- "Star",
4494
- "Target",
4495
- "TextT",
4496
- "Trash",
4497
- "UploadSimple",
4498
- "User",
4499
- "UserPlus",
4500
- "Users",
4501
- "WarningCircle",
4502
- "X",
4503
- "ChatText",
4504
- "CircleWavyCheck",
4505
- "CircleWavyQuestion",
4506
- "ArchiveBox",
4507
- "ArrowCircleDown",
4508
- "FileArrowUp",
4509
- "FileDotted",
4510
- "Files",
4511
- "PencilLine",
4512
- "PencilCircle",
4513
- "UserCircle",
4514
- "Clock",
4515
- "QrCode",
4516
- "Webcam",
4517
- "Sun",
4518
- "DeviceTabletCamera",
4519
- "Globe",
4520
- "Fingerprint",
4521
- "PushPin",
4522
- "Timer"
4523
- ]);
4524
-
4525
5191
  // ../commons/src/events/WorkqueueConfig.ts
4526
5192
  var mandatoryColumns = defineWorkqueuesColumns([
4527
5193
  {
@@ -4652,10 +5318,7 @@ var DeclareActionInput = BaseActionInput.extend(
4652
5318
  );
4653
5319
  var EditActionInput = BaseActionInput.extend(
4654
5320
  z38.object({
4655
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4656
- content: z38.object({
4657
- comment: z38.string().describe("Comment for the edit action.").optional()
4658
- })
5321
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4659
5322
  }).shape
4660
5323
  );
4661
5324
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4804,14 +5467,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4804
5467
 
4805
5468
  // ../commons/src/events/EventInput.ts
4806
5469
  var z40 = __toESM(require("zod/v4"));
4807
- var import_uuid10 = require("uuid");
5470
+ var import_uuid11 = require("uuid");
4808
5471
  var EventInput = z40.object({
4809
5472
  transactionId: z40.string(),
4810
5473
  type: z40.string(),
4811
5474
  createdAtLocation: UUID.nullish().describe(
4812
5475
  "Location where the event occurred. Required for system users."
4813
5476
  )
4814
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5477
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4815
5478
 
4816
5479
  // ../commons/src/events/EventDocument.ts
4817
5480
  var z41 = __toESM(require("zod/v4"));
@@ -4828,67 +5491,6 @@ var EventDocument = z41.object({
4828
5491
  )
4829
5492
  }).meta({ id: "EventDocument" });
4830
5493
 
4831
- // ../commons/src/events/state/index.ts
4832
- var import_lodash4 = require("lodash");
4833
-
4834
- // ../commons/src/events/state/utils.ts
4835
- var import_lodash2 = require("lodash");
4836
- var updateActions = ActionTypes.extract([
4837
- ActionType.CREATE,
4838
- ActionType.NOTIFY,
4839
- ActionType.EDIT,
4840
- ActionType.DECLARE,
4841
- ActionType.REGISTER,
4842
- ActionType.REJECT,
4843
- ActionType.ARCHIVE,
4844
- ActionType.UNARCHIVE,
4845
- ActionType.PRINT_CERTIFICATE,
4846
- ActionType.REQUEST_CORRECTION,
4847
- ActionType.APPROVE_CORRECTION,
4848
- ActionType.REJECT_CORRECTION,
4849
- ActionType.CUSTOM
4850
- ]);
4851
-
4852
- // ../commons/src/events/state/flags.ts
4853
- var import_lodash3 = require("lodash");
4854
- var import_date_fns3 = require("date-fns");
4855
- var INHERENT_FLAG_RULES = [
4856
- {
4857
- flag: InherentFlags.CORRECTION_REQUESTED,
4858
- setOn: [ActionType.REQUEST_CORRECTION],
4859
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4860
- },
4861
- {
4862
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4863
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4864
- // are deliberately excluded so the flag freezes across an archive/unarchive
4865
- // round trip and comes back exactly as it was.
4866
- flag: InherentFlags.INCOMPLETE,
4867
- setOn: [ActionType.NOTIFY],
4868
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4869
- },
4870
- {
4871
- flag: InherentFlags.REJECTED,
4872
- setOn: [ActionType.REJECT],
4873
- resetOn: [
4874
- ActionType.NOTIFY,
4875
- ActionType.DECLARE,
4876
- ActionType.EDIT,
4877
- ActionType.REGISTER
4878
- ]
4879
- },
4880
- {
4881
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4882
- setOn: [ActionType.DUPLICATE_DETECTED],
4883
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4884
- },
4885
- {
4886
- flag: InherentFlags.EDIT_IN_PROGRESS,
4887
- setOn: [ActionType.EDIT],
4888
- resetOnAnyOtherAction: true
4889
- }
4890
- ];
4891
-
4892
5494
  // ../commons/src/events/defineConfig.ts
4893
5495
  var IGNORED_EVENT_TYPES = [
4894
5496
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7361,21 +7963,44 @@ var LocationTypeV1 = z43.enum([
7361
7963
  "CRVS_OFFICE",
7362
7964
  "HEALTH_FACILITY"
7363
7965
  ]);
7966
+ var LocationStatus = z43.enum(["active", "inactive"]);
7967
+ var LocationVersion = z43.object({
7968
+ versionId: UUID,
7969
+ effectiveFrom: z43.iso.date(),
7970
+ name: z43.string(),
7971
+ externalId: z43.string().nullish(),
7972
+ status: LocationStatus
7973
+ });
7364
7974
  var AdministrativeArea = z43.object({
7365
7975
  id: UUID,
7366
7976
  name: z43.string(),
7367
7977
  externalId: z43.string().nullish(),
7368
7978
  parentId: UUID.nullable(),
7369
- validUntil: z43.iso.datetime().nullable()
7979
+ status: LocationStatus,
7980
+ versions: z43.array(LocationVersion)
7370
7981
  });
7371
7982
  var Location = z43.object({
7372
7983
  id: UUID,
7373
7984
  name: z43.string(),
7374
7985
  externalId: z43.string().nullish(),
7375
7986
  administrativeAreaId: UUID.nullable(),
7376
- validUntil: z43.iso.datetime().nullable(),
7987
+ locationType: z43.string().nullable(),
7988
+ status: LocationStatus,
7989
+ versions: z43.array(LocationVersion)
7990
+ });
7991
+ var SetLocationPayload = z43.object({
7992
+ id: UUID,
7993
+ name: z43.string(),
7994
+ externalId: z43.string().nullish(),
7995
+ administrativeAreaId: UUID.nullable(),
7377
7996
  locationType: z43.string().nullable()
7378
7997
  });
7998
+ var SetAdministrativeAreaPayload = z43.object({
7999
+ id: UUID,
8000
+ name: z43.string(),
8001
+ externalId: z43.string().nullish(),
8002
+ parentId: UUID.nullable()
8003
+ });
7379
8004
 
7380
8005
  // ../commons/src/events/scopes.ts
7381
8006
  var ACTION_SCOPE_MAP = {
@@ -7447,20 +8072,20 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7447
8072
  ]
7448
8073
  };
7449
8074
  var ACTION_FILTERS = {
7450
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7451
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7452
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7453
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7454
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7455
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7456
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7457
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7458
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7459
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7460
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7461
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7462
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7463
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
8075
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8076
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8077
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8078
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8079
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8080
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8081
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8082
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8083
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8084
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8085
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8086
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8087
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8088
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
7464
8089
  };
7465
8090
  var REJECTED_ACTIONS = [
7466
8091
  ActionType.READ,
@@ -7474,75 +8099,80 @@ var REJECTED_ACTIONS = [
7474
8099
  var import_lodash7 = require("lodash");
7475
8100
 
7476
8101
  // ../commons/src/events/mocks.test.utils.ts
7477
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
8102
+ function withVersionFields(entity) {
8103
+ return {
8104
+ ...entity,
8105
+ status: "active",
8106
+ versions: [
8107
+ {
8108
+ versionId: entity.id,
8109
+ effectiveFrom: "0001-01-01",
8110
+ name: entity.name,
8111
+ externalId: entity.externalId ?? null,
8112
+ status: "active"
8113
+ }
8114
+ ]
8115
+ };
8116
+ }
8117
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7478
8118
  {
7479
8119
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7480
8120
  name: "Central",
7481
8121
  parentId: null,
7482
- validUntil: null,
7483
8122
  externalId: "ydyJb1RAy4U1"
7484
8123
  },
7485
8124
  {
7486
8125
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7487
8126
  name: "Sulaka",
7488
8127
  parentId: null,
7489
- validUntil: null,
7490
8128
  externalId: "pQ8nGxWmZ2Q3"
7491
8129
  },
7492
8130
  {
7493
8131
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7494
8132
  name: "Pualula",
7495
8133
  parentId: null,
7496
- validUntil: null,
7497
8134
  externalId: "Aq91DweLmT8k"
7498
8135
  },
7499
8136
  {
7500
8137
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7501
8138
  name: "Chuminga",
7502
8139
  parentId: null,
7503
- validUntil: null,
7504
8140
  externalId: "Rw0fYNh2Xk9a"
7505
8141
  },
7506
8142
  {
7507
8143
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7508
8144
  name: "Ibombo",
7509
8145
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7510
- validUntil: null,
7511
8146
  externalId: "k7DsP4vbN1Qe"
7512
8147
  },
7513
8148
  {
7514
8149
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7515
8150
  name: "Isango",
7516
8151
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7517
- validUntil: null,
7518
8152
  externalId: "Gm3Z9eQpHw4L"
7519
8153
  },
7520
8154
  {
7521
8155
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7522
8156
  name: "Isamba",
7523
8157
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7524
- validUntil: null,
7525
8158
  externalId: "sT0xVu1KqJ7r"
7526
8159
  },
7527
8160
  {
7528
8161
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7529
8162
  name: "Itambo",
7530
8163
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7531
- validUntil: null,
7532
8164
  externalId: "Nq6Bv2HpL9Te"
7533
8165
  },
7534
8166
  {
7535
8167
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7536
8168
  name: "Ezhi",
7537
8169
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7538
- validUntil: null,
7539
8170
  externalId: "xK8cQ0ZRy5Wd"
7540
8171
  },
7541
8172
  {
7542
8173
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7543
8174
  name: "Ilanga",
7544
8175
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7545
- validUntil: null,
7546
8176
  externalId: "Cq4Jm1XvN8Ls"
7547
8177
  },
7548
8178
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7550,49 +8180,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7550
8180
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7551
8181
  name: "Klow",
7552
8182
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7553
- validUntil: null,
7554
8183
  externalId: "IkYcYBUcyY2"
7555
8184
  },
7556
8185
  {
7557
8186
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7558
8187
  name: "Mbondo",
7559
8188
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7560
- validUntil: null,
7561
8189
  externalId: "Qhvv5hvo3mY"
7562
8190
  },
7563
8191
  {
7564
8192
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7565
8193
  name: "Ndara",
7566
8194
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7567
- validUntil: null,
7568
8195
  externalId: "crXh068O9TR"
7569
8196
  },
7570
8197
  {
7571
8198
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7572
8199
  name: "Olani",
7573
8200
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7574
- validUntil: null,
7575
8201
  externalId: "r00It8Tvvp7"
7576
8202
  },
7577
8203
  {
7578
8204
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7579
8205
  name: "Pemba",
7580
8206
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7581
- validUntil: null,
7582
8207
  externalId: "ZnUWsbONIaH"
7583
8208
  },
7584
8209
  {
7585
8210
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7586
8211
  name: "Quanza",
7587
8212
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7588
- validUntil: null,
7589
8213
  externalId: "fDZycvQTa7l"
7590
8214
  },
7591
8215
  {
7592
8216
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7593
8217
  name: "Rivka",
7594
8218
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7595
- validUntil: null,
7596
8219
  externalId: "KqswxCGTELa"
7597
8220
  },
7598
8221
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7600,35 +8223,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7600
8223
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7601
8224
  name: "Mbula",
7602
8225
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7603
- validUntil: null,
7604
8226
  externalId: "osEbKjRc9Kg"
7605
8227
  },
7606
8228
  {
7607
8229
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7608
8230
  name: "Ndoki",
7609
8231
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7610
- validUntil: null,
7611
8232
  externalId: "aq4daBUAGr3"
7612
8233
  },
7613
8234
  {
7614
8235
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7615
8236
  name: "Tsanga",
7616
8237
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7617
- validUntil: null,
7618
8238
  externalId: "cqis6Y8trbJ"
7619
8239
  },
7620
8240
  {
7621
8241
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7622
8242
  name: "Waziri",
7623
8243
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7624
- validUntil: null,
7625
8244
  externalId: "LMijHPyyx6d"
7626
8245
  },
7627
8246
  {
7628
8247
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7629
8248
  name: "Zimbi",
7630
8249
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7631
- validUntil: null,
7632
8250
  externalId: "pcQYbPuKGZ7"
7633
8251
  },
7634
8252
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7636,67 +8254,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7636
8254
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7637
8255
  name: "Felani",
7638
8256
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7639
- validUntil: null,
7640
8257
  externalId: "gSqpoCGdMXp"
7641
8258
  },
7642
8259
  {
7643
8260
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7644
8261
  name: "Goroma",
7645
8262
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7646
- validUntil: null,
7647
8263
  externalId: "KvAAIaNqVrp"
7648
8264
  },
7649
8265
  {
7650
8266
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7651
8267
  name: "Halifu",
7652
8268
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7653
- validUntil: null,
7654
8269
  externalId: "qe4UnEVt1hv"
7655
8270
  },
7656
8271
  {
7657
8272
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7658
8273
  name: "Jabari",
7659
8274
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7660
- validUntil: null,
7661
8275
  externalId: "yHH9Nz4rLOt"
7662
8276
  },
7663
8277
  {
7664
8278
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7665
8279
  name: "Kifani",
7666
8280
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7667
- validUntil: null,
7668
8281
  externalId: "eSWmXIGeu1I"
7669
8282
  },
7670
8283
  {
7671
8284
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7672
8285
  name: "Lumela",
7673
8286
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7674
- validUntil: null,
7675
8287
  externalId: "bh0b3aI1uP3"
7676
8288
  }
7677
8289
  ];
7678
- var V2_DEFAULT_MOCK_LOCATIONS = [
8290
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
8291
+ var MOCK_LOCATIONS_BASE = [
7679
8292
  {
7680
8293
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7681
8294
  name: "Central Provincial Office",
7682
8295
  locationType: "CRVS_OFFICE",
7683
8296
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7684
- validUntil: null,
7685
8297
  externalId: "Xr3Df8WpK6Ys"
7686
8298
  },
7687
8299
  {
7688
8300
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7689
8301
  name: "Central Health Post",
7690
8302
  locationType: "HEALTH_FACILITY",
7691
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7692
- validUntil: null
8303
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7693
8304
  },
7694
8305
  {
7695
8306
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7696
8307
  name: "Ibombo District Office",
7697
8308
  locationType: "CRVS_OFFICE",
7698
8309
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7699
- validUntil: null,
7700
8310
  externalId: "Sm4Nw7GrD2Vy"
7701
8311
  },
7702
8312
  {
@@ -7704,7 +8314,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7704
8314
  name: "Isamba District Office",
7705
8315
  locationType: "CRVS_OFFICE",
7706
8316
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7707
- validUntil: null,
7708
8317
  externalId: "Vg1Bq5XeH9Lt"
7709
8318
  },
7710
8319
  {
@@ -7712,7 +8321,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7712
8321
  name: "Isango District Office",
7713
8322
  locationType: "CRVS_OFFICE",
7714
8323
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7715
- validUntil: null,
7716
8324
  externalId: "Je7Lm2XqN9Vz"
7717
8325
  },
7718
8326
  {
@@ -7720,7 +8328,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7720
8328
  name: "Sulaka Provincial Office",
7721
8329
  locationType: "CRVS_OFFICE",
7722
8330
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7723
- validUntil: null,
7724
8331
  externalId: "Ht2Wp9KcX5Qv"
7725
8332
  },
7726
8333
  {
@@ -7728,7 +8335,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7728
8335
  name: "Ilanga District Office",
7729
8336
  locationType: "CRVS_OFFICE",
7730
8337
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7731
- validUntil: null,
7732
8338
  externalId: "Yp6Ds1WqN3Xz"
7733
8339
  },
7734
8340
  {
@@ -7736,7 +8342,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7736
8342
  name: "Chamakubi Health Post",
7737
8343
  locationType: "HEALTH_FACILITY",
7738
8344
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7739
- validUntil: null,
7740
8345
  externalId: "M1nFr8LbC2Qy"
7741
8346
  },
7742
8347
  {
@@ -7744,7 +8349,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7744
8349
  name: "Ibombo Rural Health Centre",
7745
8350
  locationType: "HEALTH_FACILITY",
7746
8351
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7747
- validUntil: null,
7748
8352
  externalId: "bT7pV6YrW0Xc"
7749
8353
  },
7750
8354
  {
@@ -7752,7 +8356,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7752
8356
  name: "Chikobo Rural Health Centre",
7753
8357
  locationType: "HEALTH_FACILITY",
7754
8358
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7755
- validUntil: null,
7756
8359
  externalId: "zE4qPn2SgJ5d"
7757
8360
  },
7758
8361
  {
@@ -7760,7 +8363,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7760
8363
  name: "Chilochabalenje Health Post",
7761
8364
  locationType: "HEALTH_FACILITY",
7762
8365
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7763
- validUntil: null,
7764
8366
  externalId: "H8vDs1MqR4Uf"
7765
8367
  },
7766
8368
  {
@@ -7768,7 +8370,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7768
8370
  name: "Chipeso Rural Health Centre",
7769
8371
  locationType: "HEALTH_FACILITY",
7770
8372
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7771
- validUntil: null,
7772
8373
  externalId: "Qw3uZ9KfX6Lm"
7773
8374
  },
7774
8375
  {
@@ -7776,7 +8377,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7776
8377
  name: "Chisamba Rural Health Centre",
7777
8378
  locationType: "HEALTH_FACILITY",
7778
8379
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7779
- validUntil: null,
7780
8380
  externalId: "Yr0pCg8LdM2s"
7781
8381
  },
7782
8382
  {
@@ -7784,7 +8384,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7784
8384
  name: "Chitanda Rural Health Centre",
7785
8385
  locationType: "HEALTH_FACILITY",
7786
8386
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7787
- validUntil: null,
7788
8387
  externalId: "tS9gJ4PwB1Qx"
7789
8388
  },
7790
8389
  {
@@ -7792,7 +8391,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7792
8391
  name: "Golden Valley Rural Health Centre",
7793
8392
  locationType: "HEALTH_FACILITY",
7794
8393
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7795
- validUntil: null,
7796
8394
  externalId: "Ld7Qm3XsA8Vr"
7797
8395
  },
7798
8396
  {
@@ -7800,7 +8398,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7800
8398
  name: "Ipongo Rural Health Centre",
7801
8399
  locationType: "HEALTH_FACILITY",
7802
8400
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7803
- validUntil: null,
7804
8401
  externalId: "kF2sW9DmH0Bt"
7805
8402
  },
7806
8403
  {
@@ -7808,7 +8405,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7808
8405
  name: "Itumbwe Health Post",
7809
8406
  locationType: "HEALTH_FACILITY",
7810
8407
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7811
- validUntil: null,
7812
8408
  externalId: "Ue5Xb3VaC7Pq"
7813
8409
  },
7814
8410
  {
@@ -7816,7 +8412,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7816
8412
  name: "Kabangalala Rural Health Centre",
7817
8413
  locationType: "HEALTH_FACILITY",
7818
8414
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7819
- validUntil: null,
7820
8415
  externalId: "Pz8Kc1TqH6Jn"
7821
8416
  },
7822
8417
  // Village offices
@@ -7825,10 +8420,10 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7825
8420
  name: "Klow Village Office",
7826
8421
  locationType: "CRVS_OFFICE",
7827
8422
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7828
- validUntil: null,
7829
8423
  externalId: "PmAyxAJkxiJ"
7830
8424
  }
7831
8425
  ];
8426
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7832
8427
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7833
8428
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7834
8429
  );