@opencrvs/toolkit 2.1.0-rc.e2f2b3d → 2.1.0-rc.e58bb01

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 +201 -191
  2. package/dist/cli.js +48 -0
  3. package/dist/commons/api/router.d.ts +1644 -1627
  4. package/dist/commons/application-config/index.d.ts +6 -6
  5. package/dist/commons/conditionals/conditionals.d.ts +323 -32
  6. package/dist/commons/conditionals/validate.d.ts +2 -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 +6 -0
  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 +5 -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 +342 -337
  24. package/dist/commons/events/FieldType.d.ts +51 -51
  25. package/dist/commons/events/FieldTypeMapping.d.ts +100 -100
  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 +835 -820
  31. package/dist/commons/events/deduplication.d.ts +1 -1
  32. package/dist/commons/events/event.d.ts +2 -2
  33. package/dist/commons/events/field.d.ts +198 -69
  34. package/dist/commons/events/locations.d.ts +6 -96
  35. package/dist/commons/events/mocks.test.utils.d.ts +4 -18
  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 +43 -40
  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 +131 -119
  44. package/dist/environment/derived-variables.d.ts.map +1 -1
  45. package/dist/environment/derived-variables.js +14 -0
  46. package/dist/environment/logger.d.ts +12 -3
  47. package/dist/environment/logger.d.ts.map +1 -1
  48. package/dist/environment/manage-users.js +7 -17
  49. package/dist/environment/questions.d.ts +74 -75
  50. package/dist/environment/questions.d.ts.map +1 -1
  51. package/dist/environment/setup-environment.js +28 -8
  52. package/dist/environment/swarm-to-k8s.js +7 -17
  53. package/dist/environment/update-workflows.js +7 -17
  54. package/dist/environment/users.js +7 -17
  55. package/dist/environment/utils.d.ts +1 -1
  56. package/dist/environment/utils.js +7 -17
  57. package/dist/events/deduplication.d.ts +1 -1
  58. package/dist/events/index.js +3274 -3238
  59. package/dist/migrations/v2.0/convert-config-files-to-ts.js +7 -17
  60. package/dist/migrations/v2.0/migrate-application-config-url.js +3 -4
  61. package/dist/migrations/v2.0/remove-hearth-migrations.js +7 -17
  62. package/dist/notification/index.js +1482 -910
  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 +3 -0
  66. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -0
  67. package/opencrvs-toolkit-2.1.0-rc.e58bb01.tgz +0 -0
  68. package/package.json +5 -5
  69. package/tsconfig.tsbuildinfo +1 -1
  70. package/opencrvs-toolkit-2.1.0-rc.e2f2b3d.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,139 +1208,138 @@ 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
- /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1220
- content: z14.object({
1221
- comment: z14.string().describe("Comment for the edit action.").optional()
1222
- }).optional()
1294
+ z15.object({
1295
+ type: z15.literal(ActionType.EDIT),
1296
+ content: z15.object({
1297
+ comment: z15.string().describe("Comment for the edit action.").optional()
1298
+ })
1223
1299
  }).shape
1224
1300
  );
1225
- var PrintContent = z14.object({
1226
- templateId: z14.string().optional()
1301
+ var PrintContent = z15.object({
1302
+ templateId: z15.string().optional()
1227
1303
  });
1228
1304
  var PrintCertificateAction = ActionBase.extend(
1229
- z14.object({
1230
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1305
+ z15.object({
1306
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1231
1307
  content: PrintContent.optional().nullable()
1232
1308
  }).shape
1233
1309
  );
1234
1310
  var RequestedCorrectionAction = ActionBase.extend(
1235
- z14.object({
1236
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1311
+ z15.object({
1312
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1237
1313
  }).shape
1238
1314
  );
1239
1315
  var ApprovedCorrectionAction = ActionBase.extend(
1240
- z14.object({
1241
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1242
- requestId: z14.string(),
1316
+ z15.object({
1317
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1318
+ requestId: z15.string(),
1243
1319
  // TODO move into 'content' property
1244
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1320
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1245
1321
  }).shape
1246
1322
  );
1247
1323
  var RejectedCorrectionAction = ActionBase.extend(
1248
- z14.object({
1249
- type: z14.literal(ActionType.REJECT_CORRECTION),
1250
- requestId: z14.string(),
1324
+ z15.object({
1325
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1326
+ requestId: z15.string(),
1251
1327
  // TODO move into 'content' property
1252
1328
  content: ReasonContent
1253
1329
  }).shape
1254
1330
  );
1255
1331
  var ReadAction = ActionBase.extend(
1256
- z14.object({
1257
- type: z14.literal(ActionType.READ)
1332
+ z15.object({
1333
+ type: z15.literal(ActionType.READ)
1258
1334
  }).shape
1259
1335
  );
1260
1336
  var CustomAction = ActionBase.merge(
1261
- z14.object({
1262
- type: z14.literal(ActionType.CUSTOM),
1263
- customActionType: z14.string()
1337
+ z15.object({
1338
+ type: z15.literal(ActionType.CUSTOM),
1339
+ customActionType: z15.string()
1264
1340
  })
1265
1341
  );
1266
- var ActionDocument = z14.discriminatedUnion("type", [
1342
+ var ActionDocument = z15.discriminatedUnion("type", [
1267
1343
  CreatedAction.meta({ id: "CreatedAction" }),
1268
1344
  RejectAction.meta({ id: "RejectAction" }),
1269
1345
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1283,71 +1359,19 @@ var ActionDocument = z14.discriminatedUnion("type", [
1283
1359
  ReadAction.meta({ id: "ReadAction" }),
1284
1360
  EditAction.meta({ id: "EditAction" }),
1285
1361
  CustomAction.meta({ id: "CustomAction" })
1286
- ]).meta({
1287
- id: "ActionDocument"
1288
- });
1289
- var AsyncRejectActionDocument = ActionBase.omit({
1290
- declaration: true,
1291
- annotation: true
1292
- }).extend(
1293
- z14.object({
1294
- type: z14.enum(ConfirmableActions),
1295
- status: z14.literal(ActionStatus.Rejected)
1296
- }).shape
1297
- );
1298
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1299
-
1300
- // ../commons/src/events/Flag.ts
1301
- var z15 = __toESM(require("zod/v4"));
1302
- var InherentFlags = {
1303
- INCOMPLETE: "incomplete",
1304
- REJECTED: "rejected",
1305
- CORRECTION_REQUESTED: "correction-requested",
1306
- POTENTIAL_DUPLICATE: "potential-duplicate",
1307
- /**
1308
- * This flag is set by the Edit-action and removed after the declaration or registration.
1309
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1310
- *
1311
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1312
- */
1313
- EDIT_IN_PROGRESS: "edit-in-progress"
1314
- };
1315
- var ActionFlag = z15.string().regex(
1316
- new RegExp(
1317
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1318
- ActionStatus
1319
- ).join("|").toLowerCase()})$`
1320
- ),
1321
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1322
- );
1323
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1324
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1325
- InherentFlags
1326
- ).join(", ")}`
1327
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1328
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1329
- }).describe("Custom flag identifier defined by the country config.");
1330
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1331
- var FlagConfig = z15.object({
1332
- id: CustomFlag,
1333
- requiresAction: z15.boolean().describe(
1334
- "Indicates if this flag expects an action to be performed to be cleared."
1335
- ),
1336
- label: TranslationConfig.describe("Human readable label of the flag.")
1337
- }).meta({
1338
- id: "FlagConfig",
1339
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1340
- });
1341
- var ActionFlagConfig = z15.object({
1342
- id: Flag,
1343
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1344
- conditional: Conditional.optional().describe(
1345
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1346
- )
1347
- }).meta({
1348
- id: "ActionFlagConfig",
1349
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1362
+ ]).meta({
1363
+ id: "ActionDocument"
1350
1364
  });
1365
+ var AsyncRejectActionDocument = ActionBase.omit({
1366
+ declaration: true,
1367
+ annotation: true
1368
+ }).extend(
1369
+ z15.object({
1370
+ type: z15.enum(ConfirmableActions),
1371
+ status: z15.literal(ActionStatus.Rejected)
1372
+ }).shape
1373
+ );
1374
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1351
1375
 
1352
1376
  // ../commons/src/events/EventMetadata.ts
1353
1377
  var EventStatus = z16.enum([
@@ -1505,13 +1529,6 @@ var Range = import_v4.z.object({
1505
1529
  }).meta({
1506
1530
  id: "Range"
1507
1531
  });
1508
- var ContainsFlags = import_v4.z.object({
1509
- anyOf: import_v4.z.array(Flag).optional(),
1510
- noneOf: import_v4.z.array(Flag).optional(),
1511
- allOf: import_v4.z.array(Flag).optional()
1512
- }).meta({
1513
- id: "ContainsFlags"
1514
- });
1515
1532
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1516
1533
  id: "Within"
1517
1534
  });
@@ -3145,13 +3162,13 @@ var AdvancedSearchConfig = z28.object({
3145
3162
  });
3146
3163
 
3147
3164
  // ../commons/src/events/utils.ts
3148
- var import_lodash = require("lodash");
3165
+ var import_lodash4 = require("lodash");
3149
3166
 
3150
3167
  // ../commons/src/conditionals/validate.ts
3151
3168
  var import__ = __toESM(require("ajv/dist/2019"));
3152
3169
  var import_ajv_formats = __toESM(require("ajv-formats"));
3153
- var z31 = __toESM(require("zod/v4"));
3154
- var import_date_fns = require("date-fns");
3170
+ var z32 = __toESM(require("zod/v4"));
3171
+ var import_date_fns2 = require("date-fns");
3155
3172
 
3156
3173
  // ../commons/src/events/FieldTypeMapping.ts
3157
3174
  var z30 = __toESM(require("zod/v4"));
@@ -3159,200 +3176,300 @@ var z30 = __toESM(require("zod/v4"));
3159
3176
  // ../commons/src/events/DynamicFieldValue.ts
3160
3177
  var z29 = __toESM(require("zod/v4"));
3161
3178
 
3162
- // ../commons/src/conditionals/validate.ts
3163
- var ajv = new import__.default({
3164
- $data: true,
3165
- allowUnionTypes: true,
3166
- strict: false
3167
- // Allow minContains and other newer features
3168
- });
3169
- var DataContext = z31.object({
3170
- rootData: z31.object({
3171
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3179
+ // ../commons/src/events/state/index.ts
3180
+ var import_lodash3 = require("lodash");
3181
+
3182
+ // ../commons/src/utils.ts
3183
+ var z31 = __toESM(require("zod/v4"));
3184
+ var _ = __toESM(require("lodash"));
3185
+ function getOrThrow(x, message) {
3186
+ if (x === void 0 || x === null) {
3187
+ throw new Error(message);
3188
+ }
3189
+ return x;
3190
+ }
3191
+ function joinValues(values, separator = " ") {
3192
+ return values.filter((value) => !!value).join(separator).trim();
3193
+ }
3194
+ var FullNameV1 = z31.array(
3195
+ z31.object({
3196
+ use: z31.string(),
3197
+ family: z31.string(),
3198
+ given: z31.array(z31.string())
3172
3199
  })
3173
- });
3174
- function resolveDataPath(rootData, dataPath, instancePath) {
3175
- const pathParts = dataPath.split("/");
3176
- const levels = parseInt(pathParts[0], 10);
3177
- const referencePath = pathParts.slice(1);
3178
- const instanceParts = instancePath.split("/").filter(Boolean);
3179
- const traversedParts = instanceParts.slice(0, -levels);
3180
- let current = rootData;
3181
- for (const part of traversedParts) {
3182
- if (current === null || current === void 0) {
3183
- return void 0;
3184
- }
3185
- current = current[part];
3200
+ );
3201
+ function omitKeyDeep(obj, keyToRemove) {
3202
+ if (Array.isArray(obj)) {
3203
+ return obj.map((item) => omitKeyDeep(item, keyToRemove));
3186
3204
  }
3187
- for (const part of referencePath) {
3188
- if (current === null || current === void 0) {
3189
- return void 0;
3205
+ if (obj === null || typeof obj !== "object") {
3206
+ return obj;
3207
+ }
3208
+ const newObj = {};
3209
+ for (const key of Object.keys(obj)) {
3210
+ if (key !== keyToRemove) {
3211
+ newObj[key] = omitKeyDeep(obj[key], keyToRemove);
3190
3212
  }
3191
- current = current[part];
3192
3213
  }
3193
- return current;
3214
+ return newObj;
3194
3215
  }
3195
- function todayISO() {
3196
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3216
+
3217
+ // ../commons/src/events/state/utils.ts
3218
+ var import_lodash = require("lodash");
3219
+ function getActionRequests(actionType, actions) {
3220
+ const filtered = actions.filter((action) => action.type === actionType).reverse();
3221
+ const accept = filtered.find(
3222
+ (action) => action.status === ActionStatus.Accepted
3223
+ );
3224
+ const request = filtered.find(
3225
+ (action) => action.status === ActionStatus.Requested
3226
+ );
3227
+ const reject = filtered.find(
3228
+ (action) => action.status === ActionStatus.Rejected
3229
+ );
3230
+ return {
3231
+ reject,
3232
+ accept,
3233
+ request
3234
+ };
3197
3235
  }
3198
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3199
- function compileClientFunction(code) {
3200
- let fn = compiledFunctionCache.get(code);
3201
- if (!fn) {
3202
- fn = new Function(`return (${code})`)();
3203
- compiledFunctionCache.set(code, fn);
3236
+ function getDeclarationActionCreationMetadata(actionType, actions) {
3237
+ const { accept: acceptAction, request: requestAction } = getActionRequests(
3238
+ actionType,
3239
+ actions
3240
+ );
3241
+ if (!acceptAction) {
3242
+ return null;
3204
3243
  }
3205
- return fn;
3244
+ const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3245
+ return {
3246
+ // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3247
+ createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3248
+ createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3249
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3250
+ createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3251
+ acceptedAt: acceptAction.createdAt,
3252
+ createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3253
+ registrationNumber
3254
+ };
3206
3255
  }
3207
- (0, import_ajv_formats.default)(ajv);
3208
- function buildClientFunctionContext(input) {
3256
+ var updateActions = ActionTypes.extract([
3257
+ ActionType.CREATE,
3258
+ ActionType.NOTIFY,
3259
+ ActionType.EDIT,
3260
+ ActionType.DECLARE,
3261
+ ActionType.REGISTER,
3262
+ ActionType.REJECT,
3263
+ ActionType.ARCHIVE,
3264
+ ActionType.UNARCHIVE,
3265
+ ActionType.PRINT_CERTIFICATE,
3266
+ ActionType.REQUEST_CORRECTION,
3267
+ ActionType.APPROVE_CORRECTION,
3268
+ ActionType.REJECT_CORRECTION,
3269
+ ActionType.CUSTOM
3270
+ ]);
3271
+ function getActionUpdateMetadata(actions) {
3272
+ const createAction = getOrThrow(
3273
+ actions.find((action) => action.type === ActionType.CREATE),
3274
+ `Event has no ${ActionType.CREATE} action`
3275
+ );
3276
+ const metadataFields = [
3277
+ "createdAt",
3278
+ "createdBy",
3279
+ "createdByUserType",
3280
+ "createdAtLocation",
3281
+ "createdByRole"
3282
+ ];
3283
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3284
+ (_2, action) => {
3285
+ if (action.originalActionId) {
3286
+ const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3287
+ return (0, import_lodash.pick)(originalAction, metadataFields);
3288
+ }
3289
+ return (0, import_lodash.pick)(action, metadataFields);
3290
+ },
3291
+ (0, import_lodash.pick)(createAction, metadataFields)
3292
+ );
3293
+ }
3294
+ function getLegalStatuses(actions) {
3209
3295
  return {
3210
- $form: input.form,
3211
- $now: todayISO(),
3212
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3213
- $online: isOnline(),
3214
- $user: input.validatorContext?.user,
3215
- $event: input.validatorContext?.event,
3216
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3217
- user: input.systemVariables?.user,
3218
- $window: input.systemVariables?.$window,
3219
- locations: input.locations,
3220
- adminLevelIds: input.adminLevelIds
3296
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3297
+ ActionType.NOTIFY,
3298
+ actions
3299
+ ),
3300
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3301
+ ActionType.DECLARE,
3302
+ actions
3303
+ ),
3304
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3305
+ ActionType.REGISTER,
3306
+ actions
3307
+ )
3221
3308
  };
3222
3309
  }
3223
- function runClientFunction(code, data, context) {
3224
- return compileClientFunction(code)(data, context);
3310
+
3311
+ // ../commons/src/events/state/flags.ts
3312
+ var import_lodash2 = require("lodash");
3313
+ var import_date_fns = require("date-fns");
3314
+ function isFlagConditionMet(conditional, form, action) {
3315
+ 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" });
3316
+ return validate(conditional, {
3317
+ $form: form,
3318
+ $now: now2,
3319
+ $online: true,
3320
+ $user: {
3321
+ sub: "",
3322
+ exp: "",
3323
+ role: action.createdByRole,
3324
+ algorithm: "",
3325
+ scope: [],
3326
+ userType: action.createdByUserType
3327
+ }
3328
+ });
3225
3329
  }
3226
- ajv.addKeyword({
3227
- keyword: "daysFromDate",
3228
- type: "string",
3229
- schemaType: "object",
3230
- $data: true,
3231
- errors: true,
3232
- validate(schema, data, _2, dataContext) {
3233
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3234
- throw new Error("Validation context must contain $now");
3330
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3331
+ if (!isActionConfigType(action.type)) {
3332
+ return false;
3333
+ }
3334
+ const actionConfig = getActionConfig({
3335
+ eventConfiguration,
3336
+ actionType: action.type,
3337
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3338
+ });
3339
+ const removeOperations = (actionConfig?.flags ?? []).filter(
3340
+ ({ id, operation }) => id === flagId && operation === "remove"
3341
+ );
3342
+ if (removeOperations.length === 0) {
3343
+ return false;
3344
+ }
3345
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3346
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3347
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3348
+ const form = { ...declaration, ...annotation };
3349
+ return removeOperations.some(
3350
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3351
+ );
3352
+ }
3353
+ var INHERENT_FLAG_RULES = [
3354
+ {
3355
+ flag: InherentFlags.CORRECTION_REQUESTED,
3356
+ setOn: [ActionType.REQUEST_CORRECTION],
3357
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3358
+ },
3359
+ {
3360
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3361
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3362
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3363
+ // round trip and comes back exactly as it was.
3364
+ flag: InherentFlags.INCOMPLETE,
3365
+ setOn: [ActionType.NOTIFY],
3366
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3367
+ },
3368
+ {
3369
+ flag: InherentFlags.REJECTED,
3370
+ setOn: [ActionType.REJECT],
3371
+ resetOn: [
3372
+ ActionType.NOTIFY,
3373
+ ActionType.DECLARE,
3374
+ ActionType.EDIT,
3375
+ ActionType.REGISTER
3376
+ ]
3377
+ },
3378
+ {
3379
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3380
+ setOn: [ActionType.DUPLICATE_DETECTED],
3381
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3382
+ },
3383
+ {
3384
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3385
+ setOn: [ActionType.EDIT],
3386
+ resetOnAnyOtherAction: true
3387
+ }
3388
+ ];
3389
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3390
+ return acceptedActions.reduce((present, action, idx) => {
3391
+ if (rule.setOn.includes(action.type)) {
3392
+ return true;
3235
3393
  }
3236
- const { days, clause } = schema;
3237
- if (typeof data !== "string") {
3394
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3238
3395
  return false;
3239
3396
  }
3240
- const date = new Date(data);
3241
- if (isNaN(date.getTime())) {
3397
+ if (actionConfigRemovesFlag(
3398
+ action,
3399
+ rule.flag,
3400
+ acceptedActions.slice(0, idx + 1),
3401
+ event2,
3402
+ eventConfiguration
3403
+ )) {
3242
3404
  return false;
3243
3405
  }
3244
- let referenceDate = schema.referenceDate;
3245
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3246
- referenceDate = resolveDataPath(
3247
- dataContext.rootData,
3248
- referenceDate.$data,
3249
- dataContext.instancePath
3250
- );
3251
- }
3252
- if (!referenceDate) {
3253
- referenceDate = dataContext.rootData.$now;
3406
+ return present;
3407
+ }, false);
3408
+ }
3409
+ function resolveEventCustomFlags(event2, eventConfiguration) {
3410
+ const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3411
+ return actions.reduce((acc, action, idx) => {
3412
+ let actionConfig;
3413
+ if (isActionConfigType(action.type)) {
3414
+ actionConfig = getActionConfig({
3415
+ eventConfiguration,
3416
+ actionType: action.type,
3417
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3418
+ });
3254
3419
  }
3255
- const baseDate = new Date(referenceDate);
3256
- if (isNaN(baseDate.getTime())) {
3257
- return false;
3420
+ if (!actionConfig) {
3421
+ return acc;
3258
3422
  }
3259
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3260
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3261
- }
3262
- });
3263
- ajv.addKeyword({
3264
- keyword: "isLeafLevelLocation",
3265
- type: "string",
3266
- schemaType: "boolean",
3267
- $data: true,
3268
- errors: true,
3269
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3270
- validate(_schema, data, _2, dataContext) {
3271
- const locationIdInput = data;
3272
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3273
- return locations.some((location) => location.id === locationIdInput);
3274
- }
3275
- });
3276
- ajv.addKeyword({
3277
- keyword: "customClientValidator",
3278
- schemaType: "object",
3279
- errors: true,
3280
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3281
- // `validate()` callers build root data via `buildClientFunctionContext`,
3282
- // so the cast holds.
3283
- validate(schema, data, _2, dataContext) {
3284
- return Boolean(
3285
- runClientFunction(
3286
- schema.code,
3287
- data,
3288
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3423
+ const eventUpToThisAction = {
3424
+ ...event2,
3425
+ actions: actions.slice(0, idx + 1)
3426
+ };
3427
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3428
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3429
+ const form = { ...declaration, ...annotation };
3430
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3431
+ ({ conditional }) => (
3432
+ // If conditional is not provided, the flag is resolved
3433
+ conditional ? isFlagConditionMet(conditional, form, action) : true
3289
3434
  )
3290
3435
  );
3291
- }
3292
- });
3293
- function isOnline() {
3294
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3295
- return navigator.onLine;
3296
- }
3297
- return true;
3298
- }
3299
-
3300
- // ../commons/src/utils.ts
3301
- var z32 = __toESM(require("zod/v4"));
3302
- var _ = __toESM(require("lodash"));
3303
- var FullNameV1 = z32.array(
3304
- z32.object({
3305
- use: z32.string(),
3306
- family: z32.string(),
3307
- given: z32.array(z32.string())
3308
- })
3309
- );
3310
- function omitKeyDeep(obj, keyToRemove) {
3311
- if (Array.isArray(obj)) {
3312
- return obj.map((item) => omitKeyDeep(item, keyToRemove));
3313
- }
3314
- if (obj === null || typeof obj !== "object") {
3315
- return obj;
3316
- }
3317
- const newObj = {};
3318
- for (const key of Object.keys(obj)) {
3319
- if (key !== keyToRemove) {
3320
- newObj[key] = omitKeyDeep(obj[key], keyToRemove);
3321
- }
3322
- }
3323
- return newObj;
3436
+ const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3437
+ const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3438
+ const flags = [...acc, ...addedFlags].filter(
3439
+ (flagId) => !removedFlags.includes(flagId)
3440
+ );
3441
+ return (0, import_lodash2.uniq)(flags);
3442
+ }, []);
3324
3443
  }
3325
-
3326
- // ../commons/src/events/utils.ts
3327
- var import_date_fns2 = require("date-fns");
3328
- function getDeclarationFields(configuration) {
3329
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3444
+ function getActionStatusFlags(sortedActions) {
3445
+ const actionStatus = sortedActions.reduce(
3446
+ (actionStatuses, { type, status }) => ({
3447
+ ...actionStatuses,
3448
+ [type]: status
3449
+ }),
3450
+ {}
3451
+ );
3452
+ return Object.entries(actionStatus).filter(([, status]) => status !== ActionStatus.Accepted).map(([type, status]) => {
3453
+ const flag = joinValues([type, status], ":").toLowerCase();
3454
+ return flag;
3455
+ });
3330
3456
  }
3331
- var getActionAnnotationFields = (actionConfig) => {
3332
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3333
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3334
- }
3335
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3336
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3337
- }
3338
- const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3339
- const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3340
- return [...reviewFields, ...formFields];
3341
- };
3342
- function getAllAnnotationFields(config) {
3343
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3457
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
3458
+ const acceptedActions = sortedActions.filter(
3459
+ ({ status }) => status === ActionStatus.Accepted
3460
+ );
3461
+ return INHERENT_FLAG_RULES.filter(
3462
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3463
+ ).map(({ flag }) => flag);
3464
+ }
3465
+ function getEventFlags(event2, config) {
3466
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3467
+ return [
3468
+ ...getActionStatusFlags(sortedActions),
3469
+ ...getInherentFlags(sortedActions, event2, config),
3470
+ ...resolveEventCustomFlags(event2, config)
3471
+ ];
3344
3472
  }
3345
- var findAllFields = (config) => {
3346
- return (0, import_lodash.flattenDeep)([
3347
- ...getDeclarationFields(config),
3348
- ...getAllAnnotationFields(config)
3349
- ]);
3350
- };
3351
- var EXCLUDED_ACTIONS = [
3352
- ActionType.REQUEST_CORRECTION,
3353
- ActionType.PRINT_CERTIFICATE,
3354
- ActionType.REJECT_CORRECTION
3355
- ];
3356
3473
 
3357
3474
  // ../commons/src/conditionals/conditionals.ts
3358
3475
  var objectHash = __toESM(require("object-hash"));
@@ -3881,84 +3998,590 @@ function createFieldConditionals(fieldId) {
3881
3998
  },
3882
3999
  this.$$subfield
3883
4000
  )
3884
- },
3885
- required: [fieldId]
3886
- });
3887
- },
3888
- getId: () => ({ fieldId }),
3889
- /**
3890
- * @deprecated
3891
- * use field(fieldId).get(nestedProperty) instead
3892
- * with 'and' combinator e.g.
3893
- * and(
3894
- * field('child.name').get('firstname').isEqualTo('John'),
3895
- * field('child.name').get('surname').isEqualTo('Doe')
3896
- * )
3897
- */
3898
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
3899
- object: (options) => defineFormConditional({
3900
- type: "object",
3901
- properties: {
3902
- [fieldId]: {
3903
- type: "object",
3904
- properties: Object.fromEntries(
3905
- Object.entries(options).map(([key, value]) => {
3906
- return [key, value.properties.$form.properties[key]];
3907
- })
3908
- ),
3909
- required: Object.keys(options)
4001
+ },
4002
+ required: [fieldId]
4003
+ });
4004
+ },
4005
+ getId: () => ({ fieldId }),
4006
+ /**
4007
+ * @deprecated
4008
+ * use field(fieldId).get(nestedProperty) instead
4009
+ * with 'and' combinator e.g.
4010
+ * and(
4011
+ * field('child.name').get('firstname').isEqualTo('John'),
4012
+ * field('child.name').get('surname').isEqualTo('Doe')
4013
+ * )
4014
+ */
4015
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
4016
+ object: (options) => defineFormConditional({
4017
+ type: "object",
4018
+ properties: {
4019
+ [fieldId]: {
4020
+ type: "object",
4021
+ properties: Object.fromEntries(
4022
+ Object.entries(options).map(([key, value]) => {
4023
+ return [key, value.properties.$form.properties[key]];
4024
+ })
4025
+ ),
4026
+ required: Object.keys(options)
4027
+ }
4028
+ },
4029
+ required: [fieldId]
4030
+ }),
4031
+ /**
4032
+ * Custom client-side validator. The provided function is serialised and executed
4033
+ * just-in-time on the client only. External references (e.g. lodash) are not
4034
+ * available inside the function body — all logic must be self-contained.
4035
+ *
4036
+ * @example
4037
+ * field('nid').customClientValidator((value) => {
4038
+ * // LUHN check — all logic must be inline
4039
+ * const digits = String(value).split('').map(Number)
4040
+ * // ...
4041
+ * return isValid
4042
+ * })
4043
+ */
4044
+ customClientValidator(validationFn) {
4045
+ const code = validationFn.toString();
4046
+ return defineFormConditional({
4047
+ type: "object",
4048
+ properties: wrapToPath(
4049
+ { [fieldId]: { customClientValidator: { code } } },
4050
+ this.$$subfield
4051
+ ),
4052
+ required: [fieldId]
4053
+ });
4054
+ },
4055
+ /**
4056
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
4057
+ * that can be used as the `value` property or a DATA component entry.
4058
+ * The function receives the referenced field's value as the first argument and
4059
+ * the full form context as the second; its return value replaces the field reference.
4060
+ * The function is serialised and executed just-in-time on the client only.
4061
+ * External references (e.g. lodash) are not available inside the function body.
4062
+ *
4063
+ * For computing a default value without referencing a specific field, use
4064
+ * `evaluate(fn)` in the `defaultValue` property instead.
4065
+ *
4066
+ * @example
4067
+ * field('a').customClientEvaluation((aValue, ctx) =>
4068
+ * Number(aValue) + Number(ctx.$form.b)
4069
+ * )
4070
+ */
4071
+ customClientEvaluation(computationFn) {
4072
+ return {
4073
+ $$code: computationFn.toString(),
4074
+ $$field: fieldId,
4075
+ $$subfield: this.$$subfield
4076
+ };
4077
+ }
4078
+ };
4079
+ }
4080
+
4081
+ // ../commons/src/events/state/index.ts
4082
+ function getStatusFromActions(actions) {
4083
+ const acceptedActions = actions.filter(
4084
+ ({ status }) => status === ActionStatus.Accepted
4085
+ );
4086
+ const isCurrentlyArchived = acceptedActions.reduce(
4087
+ (archived, action) => {
4088
+ if (action.type === ActionType.ARCHIVE) {
4089
+ return true;
4090
+ }
4091
+ if (action.type === ActionType.UNARCHIVE) {
4092
+ return false;
4093
+ }
4094
+ return archived;
4095
+ },
4096
+ false
4097
+ );
4098
+ if (isCurrentlyArchived) {
4099
+ return EventStatus.enum.ARCHIVED;
4100
+ }
4101
+ return acceptedActions.filter(
4102
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4103
+ ).reduce((status, action) => {
4104
+ switch (action.type) {
4105
+ case ActionType.CREATE:
4106
+ return EventStatus.enum.CREATED;
4107
+ case ActionType.DECLARE:
4108
+ return EventStatus.enum.DECLARED;
4109
+ case ActionType.REGISTER:
4110
+ return EventStatus.enum.REGISTERED;
4111
+ case ActionType.NOTIFY:
4112
+ return EventStatus.enum.NOTIFIED;
4113
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
4114
+ case ActionType.ARCHIVE:
4115
+ case ActionType.UNARCHIVE:
4116
+ case ActionType.CUSTOM:
4117
+ case ActionType.PRINT_CERTIFICATE:
4118
+ case ActionType.ASSIGN:
4119
+ case ActionType.UNASSIGN:
4120
+ case ActionType.REJECT:
4121
+ case ActionType.REQUEST_CORRECTION:
4122
+ case ActionType.APPROVE_CORRECTION:
4123
+ case ActionType.DUPLICATE_DETECTED:
4124
+ case ActionType.MARK_AS_NOT_DUPLICATE:
4125
+ case ActionType.MARK_AS_DUPLICATE:
4126
+ case ActionType.REJECT_CORRECTION:
4127
+ case ActionType.READ:
4128
+ case ActionType.EDIT:
4129
+ default:
4130
+ return status;
4131
+ }
4132
+ }, EventStatus.enum.CREATED);
4133
+ }
4134
+ function getAssignedUserFromActions(actions) {
4135
+ return actions.reduce((user2, action) => {
4136
+ if (action.type === ActionType.ASSIGN) {
4137
+ return action.assignedTo;
4138
+ }
4139
+ if (action.type === ActionType.UNASSIGN) {
4140
+ return null;
4141
+ }
4142
+ return user2;
4143
+ }, null);
4144
+ }
4145
+ function deepDropNulls(obj) {
4146
+ if (Array.isArray(obj)) {
4147
+ return obj.map(deepDropNulls);
4148
+ }
4149
+ if (obj !== null && typeof obj === "object") {
4150
+ return Object.entries(obj).reduce((acc, [key, value]) => {
4151
+ const cleanedValue = deepDropNulls(value);
4152
+ if (cleanedValue !== null) {
4153
+ ;
4154
+ acc[key] = cleanedValue;
4155
+ }
4156
+ return acc;
4157
+ }, {});
4158
+ }
4159
+ return obj;
4160
+ }
4161
+ var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4162
+ function extractDateString(dateTime) {
4163
+ return dateTime.split("T")[0];
4164
+ }
4165
+ function resolveDateOfEvent(eventIndex, declaration, config) {
4166
+ if (!config.dateOfEvent) {
4167
+ return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4168
+ }
4169
+ const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4170
+ getMixedPath(eventIndex, config.dateOfEvent.$$event)
4171
+ );
4172
+ return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4173
+ }
4174
+ var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4175
+ function getParsedUUID(value, oldValue) {
4176
+ const parsed = UUID.safeParse(value);
4177
+ return parsed.success ? parsed.data : oldValue;
4178
+ }
4179
+ function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4180
+ let placeOfEvent = getParsedUUID(
4181
+ eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4182
+ );
4183
+ if (config.placeOfEvent) {
4184
+ const addressFieldValue = AddressFieldValue.safeParse(
4185
+ declaration[config.placeOfEvent.$$field]
4186
+ );
4187
+ if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4188
+ placeOfEvent = getParsedUUID(
4189
+ addressFieldValue.data.administrativeArea,
4190
+ placeOfEvent
4191
+ );
4192
+ } else {
4193
+ placeOfEvent = getParsedUUID(
4194
+ declaration[config.placeOfEvent.$$field],
4195
+ placeOfEvent
4196
+ );
4197
+ }
4198
+ }
4199
+ return placeOfEvent;
4200
+ }
4201
+ function extractPotentialDuplicatesFromActions(actions) {
4202
+ return actions.reduce((duplicates, action) => {
4203
+ if (action.type === ActionType.DUPLICATE_DETECTED) {
4204
+ duplicates = action.content.duplicates;
4205
+ }
4206
+ if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4207
+ duplicates = [];
4208
+ }
4209
+ return duplicates;
4210
+ }, []);
4211
+ }
4212
+ function getCurrentEventState(event2, config) {
4213
+ const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4214
+ const creationAction = sortedActions.find(
4215
+ (action) => action.type === ActionType.CREATE
4216
+ );
4217
+ if (!creationAction) {
4218
+ throw new Error(`Event ${event2.id} has no creation action`);
4219
+ }
4220
+ const acceptedActions = getAcceptedActions(event2).sort(
4221
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
4222
+ );
4223
+ const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4224
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4225
+ const declaration = aggregateActionDeclarations(event2);
4226
+ const status = getStatusFromActions(sortedActions);
4227
+ const legalStatuses = getLegalStatuses(sortedActions);
4228
+ const base = deepDropNulls({
4229
+ id: event2.id,
4230
+ type: event2.type,
4231
+ status,
4232
+ legalStatuses,
4233
+ createdAt: creationAction.createdAt,
4234
+ createdBy: creationAction.createdBy,
4235
+ createdByUserType: creationAction.createdByUserType,
4236
+ createdAtLocation: creationAction.createdAtLocation,
4237
+ updatedAt: acceptedActionMetadata.createdAt,
4238
+ assignedTo: getAssignedUserFromActions(acceptedActions),
4239
+ updatedBy: requestActionMetadata.createdBy,
4240
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
4241
+ declaration,
4242
+ trackingId: event2.trackingId,
4243
+ updatedByUserRole: requestActionMetadata.createdByRole,
4244
+ placeOfEvent: resolvePlaceOfEvent(
4245
+ { createdAtLocation: creationAction.createdAtLocation },
4246
+ declaration,
4247
+ config
4248
+ ),
4249
+ potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4250
+ flags: getEventFlags(event2, config)
4251
+ });
4252
+ return deepDropNulls({
4253
+ ...base,
4254
+ dateOfEvent: resolveDateOfEvent(base, declaration, config)
4255
+ });
4256
+ }
4257
+
4258
+ // ../commons/src/conditionals/validate.ts
4259
+ var ajv = new import__.default({
4260
+ $data: true,
4261
+ allowUnionTypes: true,
4262
+ strict: false
4263
+ // Allow minContains and other newer features
4264
+ });
4265
+ var DataContext = z32.object({
4266
+ rootData: z32.object({
4267
+ $leafAdminStructureLocationIds: z32.array(z32.object({ id: UUID }))
4268
+ })
4269
+ });
4270
+ function resolveDataPath(rootData, dataPath, instancePath) {
4271
+ const pathParts = dataPath.split("/");
4272
+ const levels = parseInt(pathParts[0], 10);
4273
+ const referencePath = pathParts.slice(1);
4274
+ const instanceParts = instancePath.split("/").filter(Boolean);
4275
+ const traversedParts = instanceParts.slice(0, -levels);
4276
+ let current = rootData;
4277
+ for (const part of traversedParts) {
4278
+ if (current === null || current === void 0) {
4279
+ return void 0;
4280
+ }
4281
+ current = current[part];
4282
+ }
4283
+ for (const part of referencePath) {
4284
+ if (current === null || current === void 0) {
4285
+ return void 0;
4286
+ }
4287
+ current = current[part];
4288
+ }
4289
+ return current;
4290
+ }
4291
+ function todayISO() {
4292
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4293
+ }
4294
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4295
+ function compileClientFunction(code) {
4296
+ let fn = compiledFunctionCache.get(code);
4297
+ if (!fn) {
4298
+ fn = new Function(`return (${code})`)();
4299
+ compiledFunctionCache.set(code, fn);
4300
+ }
4301
+ return fn;
4302
+ }
4303
+ (0, import_ajv_formats.default)(ajv);
4304
+ function buildClientFunctionContext(input) {
4305
+ const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getCurrentEventState(
4306
+ input.validatorContext?.event,
4307
+ input.validatorContext?.eventConfig
4308
+ )?.flags : [];
4309
+ return {
4310
+ $form: input.form,
4311
+ $flags: flags,
4312
+ $now: todayISO(),
4313
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4314
+ $online: isOnline(),
4315
+ $user: input.validatorContext?.user,
4316
+ $event: input.validatorContext?.event,
4317
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4318
+ user: input.systemVariables?.user,
4319
+ $window: input.systemVariables?.$window,
4320
+ locations: input.locations,
4321
+ adminLevelIds: input.adminLevelIds
4322
+ };
4323
+ }
4324
+ function runClientFunction(code, data, context) {
4325
+ return compileClientFunction(code)(data, context);
4326
+ }
4327
+ ajv.addKeyword({
4328
+ keyword: "daysFromDate",
4329
+ type: "string",
4330
+ schemaType: "object",
4331
+ $data: true,
4332
+ errors: true,
4333
+ validate(schema, data, _2, dataContext) {
4334
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4335
+ throw new Error("Validation context must contain $now");
4336
+ }
4337
+ const { days, clause } = schema;
4338
+ if (typeof data !== "string") {
4339
+ return false;
4340
+ }
4341
+ const date = new Date(data);
4342
+ if (isNaN(date.getTime())) {
4343
+ return false;
4344
+ }
4345
+ let referenceDate = schema.referenceDate;
4346
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4347
+ referenceDate = resolveDataPath(
4348
+ dataContext.rootData,
4349
+ referenceDate.$data,
4350
+ dataContext.instancePath
4351
+ );
4352
+ }
4353
+ if (!referenceDate) {
4354
+ referenceDate = dataContext.rootData.$now;
4355
+ }
4356
+ const baseDate = new Date(referenceDate);
4357
+ if (isNaN(baseDate.getTime())) {
4358
+ return false;
4359
+ }
4360
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4361
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4362
+ }
4363
+ });
4364
+ ajv.addKeyword({
4365
+ keyword: "isLeafLevelLocation",
4366
+ type: "string",
4367
+ schemaType: "boolean",
4368
+ $data: true,
4369
+ errors: true,
4370
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4371
+ validate(_schema, data, _2, dataContext) {
4372
+ const locationIdInput = data;
4373
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4374
+ return locations.some((location) => location.id === locationIdInput);
4375
+ }
4376
+ });
4377
+ function isAgeValue(value) {
4378
+ return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4379
+ }
4380
+ ajv.addKeyword({
4381
+ keyword: "customClientValidator",
4382
+ schemaType: "object",
4383
+ errors: true,
4384
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4385
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4386
+ // so the cast holds.
4387
+ validate(schema, data, _2, dataContext) {
4388
+ return Boolean(
4389
+ runClientFunction(
4390
+ schema.code,
4391
+ data,
4392
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4393
+ )
4394
+ );
4395
+ }
4396
+ });
4397
+ function validate(schema, data) {
4398
+ const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4399
+ if ("$form" in data) {
4400
+ const entries = Object.entries(data.$form).map(([key, value]) => {
4401
+ if (!isAgeValue(value)) {
4402
+ return [key, value];
4403
+ }
4404
+ const age = value.age;
4405
+ const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4406
+ return [
4407
+ key,
4408
+ {
4409
+ age,
4410
+ dob: ageToDate(
4411
+ age,
4412
+ maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4413
+ )
3910
4414
  }
3911
- },
3912
- required: [fieldId]
3913
- }),
3914
- /**
3915
- * Custom client-side validator. The provided function is serialised and executed
3916
- * just-in-time on the client only. External references (e.g. lodash) are not
3917
- * available inside the function body — all logic must be self-contained.
3918
- *
3919
- * @example
3920
- * field('nid').customClientValidator((value) => {
3921
- * // LUHN check — all logic must be inline
3922
- * const digits = String(value).split('').map(Number)
3923
- * // ...
3924
- * return isValid
3925
- * })
3926
- */
3927
- customClientValidator(validationFn) {
3928
- const code = validationFn.toString();
3929
- return defineFormConditional({
3930
- type: "object",
3931
- properties: wrapToPath(
3932
- { [fieldId]: { customClientValidator: { code } } },
3933
- this.$$subfield
3934
- ),
3935
- required: [fieldId]
3936
- });
3937
- },
3938
- /**
3939
- * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3940
- * that can be used as the `value` property or a DATA component entry.
3941
- * The function receives the referenced field's value as the first argument and
3942
- * the full form context as the second; its return value replaces the field reference.
3943
- * The function is serialised and executed just-in-time on the client only.
3944
- * External references (e.g. lodash) are not available inside the function body.
3945
- *
3946
- * For computing a default value without referencing a specific field, use
3947
- * `evaluate(fn)` in the `defaultValue` property instead.
3948
- *
3949
- * @example
3950
- * field('a').customClientEvaluation((aValue, ctx) =>
3951
- * Number(aValue) + Number(ctx.$form.b)
3952
- * )
3953
- */
3954
- customClientEvaluation(computationFn) {
3955
- return {
3956
- $$code: computationFn.toString(),
3957
- $$field: fieldId,
3958
- $$subfield: this.$$subfield
3959
- };
4415
+ ];
4416
+ });
4417
+ data.$form = Object.fromEntries(entries);
4418
+ }
4419
+ const result = validator(data);
4420
+ return result;
4421
+ }
4422
+ function isOnline() {
4423
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4424
+ return navigator.onLine;
4425
+ }
4426
+ return true;
4427
+ }
4428
+
4429
+ // ../commons/src/events/utils.ts
4430
+ var import_date_fns3 = require("date-fns");
4431
+ function ageToDate(age, asOfDate) {
4432
+ const date = plainDateToLocalDate(asOfDate);
4433
+ return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4434
+ }
4435
+ function getDeclarationFields(configuration) {
4436
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4437
+ }
4438
+ function isActionConfigType(type) {
4439
+ return actionConfigTypes.has(type);
4440
+ }
4441
+ function getActionConfig({
4442
+ eventConfiguration,
4443
+ actionType,
4444
+ customActionType
4445
+ }) {
4446
+ if (actionType === ActionType.NOTIFY) {
4447
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4448
+ }
4449
+ return eventConfiguration.actions.find((a) => {
4450
+ if (a.type === ActionType.CUSTOM && customActionType) {
4451
+ return a.customActionType === customActionType;
4452
+ }
4453
+ return a.type === actionType;
4454
+ });
4455
+ }
4456
+ var getActionAnnotationFields = (actionConfig) => {
4457
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4458
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4459
+ }
4460
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4461
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4462
+ }
4463
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4464
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4465
+ return [...reviewFields, ...formFields];
4466
+ };
4467
+ function getAllAnnotationFields(config) {
4468
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4469
+ }
4470
+ function deepMerge(currentDocument, actionDocument) {
4471
+ const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4472
+ return (0, import_lodash4.mergeWith)(
4473
+ (0, import_lodash4.cloneDeep)(currentDocumentClone),
4474
+ actionDocument,
4475
+ (previousValue, incomingValue) => {
4476
+ if (incomingValue === void 0) {
4477
+ return previousValue;
4478
+ }
4479
+ if ((0, import_lodash4.isArray)(incomingValue)) {
4480
+ return incomingValue;
4481
+ }
4482
+ if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4483
+ return void 0;
4484
+ }
4485
+ return incomingValue;
4486
+ }
4487
+ );
4488
+ }
4489
+ var findAllFields = (config) => {
4490
+ return (0, import_lodash4.flattenDeep)([
4491
+ ...getDeclarationFields(config),
4492
+ ...getAllAnnotationFields(config)
4493
+ ]);
4494
+ };
4495
+ function getMixedPath(obj, path, defaultValue) {
4496
+ const parts = path.split(".");
4497
+ const resolve = (current, segments) => {
4498
+ if (current == null || segments.length === 0) {
4499
+ return current;
3960
4500
  }
4501
+ for (let i = segments.length; i > 0; i--) {
4502
+ const compoundKey = segments.slice(0, i).join(".");
4503
+ if ((0, import_lodash4.has)(current, compoundKey)) {
4504
+ const next = (0, import_lodash4.get)(current, compoundKey);
4505
+ return resolve(next, segments.slice(i));
4506
+ }
4507
+ }
4508
+ return void 0;
3961
4509
  };
4510
+ const result = resolve(obj, parts);
4511
+ return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4512
+ }
4513
+ function isAcceptedAction(a) {
4514
+ return a.status === ActionStatus.Accepted;
4515
+ }
4516
+ function getCompleteActionAnnotation(event2, action) {
4517
+ if (action.originalActionId) {
4518
+ const originalAction = event2.actions.find(
4519
+ ({ id }) => id === action.originalActionId
4520
+ );
4521
+ if (originalAction?.status === ActionStatus.Requested) {
4522
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4523
+ }
4524
+ }
4525
+ return action.annotation ?? {};
4526
+ }
4527
+ function getCompleteActionDeclaration(declaration, event2, action) {
4528
+ if (action.originalActionId) {
4529
+ const originalAction = event2.actions.find(
4530
+ ({ id }) => id === action.originalActionId
4531
+ );
4532
+ if (originalAction?.status === ActionStatus.Requested) {
4533
+ return deepMerge(
4534
+ deepMerge(declaration, originalAction.declaration),
4535
+ action.declaration
4536
+ );
4537
+ }
4538
+ }
4539
+ return deepMerge(declaration, action.declaration);
4540
+ }
4541
+ function getAcceptedActions(event2) {
4542
+ return event2.actions.filter(isAcceptedAction).map((action) => ({
4543
+ ...action,
4544
+ declaration: getCompleteActionDeclaration({}, event2, action),
4545
+ annotation: getCompleteActionAnnotation(event2, action)
4546
+ }));
4547
+ }
4548
+ var EXCLUDED_ACTIONS = [
4549
+ ActionType.REQUEST_CORRECTION,
4550
+ ActionType.PRINT_CERTIFICATE,
4551
+ ActionType.REJECT_CORRECTION
4552
+ ];
4553
+ function aggregateActionDeclarations(event2) {
4554
+ const allAcceptedActions = getAcceptedActions(event2);
4555
+ const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4556
+ return aggregatedActions.reduce((declaration, action) => {
4557
+ if (action.type === ActionType.APPROVE_CORRECTION) {
4558
+ const requestAction = allAcceptedActions.find(
4559
+ ({ id }) => id === action.requestId
4560
+ );
4561
+ if (!requestAction) {
4562
+ return declaration;
4563
+ }
4564
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4565
+ declaration,
4566
+ event2,
4567
+ requestAction
4568
+ );
4569
+ return getCompleteActionDeclaration(
4570
+ declarationWithApprovedCorrection,
4571
+ event2,
4572
+ action
4573
+ );
4574
+ }
4575
+ return getCompleteActionDeclaration(declaration, event2, action);
4576
+ }, {});
4577
+ }
4578
+ function aggregateActionAnnotations(event2) {
4579
+ return event2.actions.reduce((ann, sortedAction) => {
4580
+ if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4581
+ return ann;
4582
+ }
4583
+ return deepMerge(ann, sortedAction.annotation);
4584
+ }, {});
3962
4585
  }
3963
4586
 
3964
4587
  // ../commons/src/events/eventConfigValidation.ts
@@ -4653,7 +5276,10 @@ var DeclareActionInput = BaseActionInput.extend(
4653
5276
  );
4654
5277
  var EditActionInput = BaseActionInput.extend(
4655
5278
  z38.object({
4656
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
5279
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
5280
+ content: z38.object({
5281
+ comment: z38.string().describe("Comment for the edit action.").optional()
5282
+ })
4657
5283
  }).shape
4658
5284
  );
4659
5285
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4802,14 +5428,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4802
5428
 
4803
5429
  // ../commons/src/events/EventInput.ts
4804
5430
  var z40 = __toESM(require("zod/v4"));
4805
- var import_uuid10 = require("uuid");
5431
+ var import_uuid11 = require("uuid");
4806
5432
  var EventInput = z40.object({
4807
5433
  transactionId: z40.string(),
4808
5434
  type: z40.string(),
4809
5435
  createdAtLocation: UUID.nullish().describe(
4810
5436
  "Location where the event occurred. Required for system users."
4811
5437
  )
4812
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5438
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4813
5439
 
4814
5440
  // ../commons/src/events/EventDocument.ts
4815
5441
  var z41 = __toESM(require("zod/v4"));
@@ -4826,67 +5452,6 @@ var EventDocument = z41.object({
4826
5452
  )
4827
5453
  }).meta({ id: "EventDocument" });
4828
5454
 
4829
- // ../commons/src/events/state/index.ts
4830
- var import_lodash4 = require("lodash");
4831
-
4832
- // ../commons/src/events/state/utils.ts
4833
- var import_lodash2 = require("lodash");
4834
- var updateActions = ActionTypes.extract([
4835
- ActionType.CREATE,
4836
- ActionType.NOTIFY,
4837
- ActionType.EDIT,
4838
- ActionType.DECLARE,
4839
- ActionType.REGISTER,
4840
- ActionType.REJECT,
4841
- ActionType.ARCHIVE,
4842
- ActionType.UNARCHIVE,
4843
- ActionType.PRINT_CERTIFICATE,
4844
- ActionType.REQUEST_CORRECTION,
4845
- ActionType.APPROVE_CORRECTION,
4846
- ActionType.REJECT_CORRECTION,
4847
- ActionType.CUSTOM
4848
- ]);
4849
-
4850
- // ../commons/src/events/state/flags.ts
4851
- var import_lodash3 = require("lodash");
4852
- var import_date_fns3 = require("date-fns");
4853
- var INHERENT_FLAG_RULES = [
4854
- {
4855
- flag: InherentFlags.CORRECTION_REQUESTED,
4856
- setOn: [ActionType.REQUEST_CORRECTION],
4857
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4858
- },
4859
- {
4860
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4861
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4862
- // are deliberately excluded so the flag freezes across an archive/unarchive
4863
- // round trip and comes back exactly as it was.
4864
- flag: InherentFlags.INCOMPLETE,
4865
- setOn: [ActionType.NOTIFY],
4866
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4867
- },
4868
- {
4869
- flag: InherentFlags.REJECTED,
4870
- setOn: [ActionType.REJECT],
4871
- resetOn: [
4872
- ActionType.NOTIFY,
4873
- ActionType.DECLARE,
4874
- ActionType.EDIT,
4875
- ActionType.REGISTER
4876
- ]
4877
- },
4878
- {
4879
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4880
- setOn: [ActionType.DUPLICATE_DETECTED],
4881
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4882
- },
4883
- {
4884
- flag: InherentFlags.EDIT_IN_PROGRESS,
4885
- setOn: [ActionType.EDIT],
4886
- resetOnAnyOtherAction: true
4887
- }
4888
- ];
4889
-
4890
5455
  // ../commons/src/events/defineConfig.ts
4891
5456
  var IGNORED_EVENT_TYPES = [
4892
5457
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7359,44 +7924,21 @@ var LocationTypeV1 = z43.enum([
7359
7924
  "CRVS_OFFICE",
7360
7925
  "HEALTH_FACILITY"
7361
7926
  ]);
7362
- var LocationStatus = z43.enum(["active", "inactive"]);
7363
- var LocationVersion = z43.object({
7364
- versionId: UUID,
7365
- effectiveFrom: z43.iso.date(),
7366
- name: z43.string(),
7367
- externalId: z43.string().nullish(),
7368
- status: LocationStatus
7369
- });
7370
7927
  var AdministrativeArea = z43.object({
7371
7928
  id: UUID,
7372
7929
  name: z43.string(),
7373
7930
  externalId: z43.string().nullish(),
7374
7931
  parentId: UUID.nullable(),
7375
- status: LocationStatus,
7376
- versions: z43.array(LocationVersion)
7932
+ validUntil: z43.iso.datetime().nullable()
7377
7933
  });
7378
7934
  var Location = z43.object({
7379
7935
  id: UUID,
7380
7936
  name: z43.string(),
7381
7937
  externalId: z43.string().nullish(),
7382
7938
  administrativeAreaId: UUID.nullable(),
7383
- locationType: z43.string().nullable(),
7384
- status: LocationStatus,
7385
- versions: z43.array(LocationVersion)
7386
- });
7387
- var SetLocationPayload = z43.object({
7388
- id: UUID,
7389
- name: z43.string(),
7390
- externalId: z43.string().nullish(),
7391
- administrativeAreaId: UUID.nullable(),
7939
+ validUntil: z43.iso.datetime().nullable(),
7392
7940
  locationType: z43.string().nullable()
7393
7941
  });
7394
- var SetAdministrativeAreaPayload = z43.object({
7395
- id: UUID,
7396
- name: z43.string(),
7397
- externalId: z43.string().nullish(),
7398
- parentId: UUID.nullable()
7399
- });
7400
7942
 
7401
7943
  // ../commons/src/events/scopes.ts
7402
7944
  var ACTION_SCOPE_MAP = {
@@ -7495,80 +8037,75 @@ var REJECTED_ACTIONS = [
7495
8037
  var import_lodash7 = require("lodash");
7496
8038
 
7497
8039
  // ../commons/src/events/mocks.test.utils.ts
7498
- function withVersionFields(entity) {
7499
- return {
7500
- ...entity,
7501
- status: "active",
7502
- versions: [
7503
- {
7504
- versionId: entity.id,
7505
- effectiveFrom: "0001-01-01",
7506
- name: entity.name,
7507
- externalId: entity.externalId ?? null,
7508
- status: "active"
7509
- }
7510
- ]
7511
- };
7512
- }
7513
- var MOCK_ADMINISTRATIVE_AREAS_BASE = [
8040
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7514
8041
  {
7515
8042
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7516
8043
  name: "Central",
7517
8044
  parentId: null,
8045
+ validUntil: null,
7518
8046
  externalId: "ydyJb1RAy4U1"
7519
8047
  },
7520
8048
  {
7521
8049
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7522
8050
  name: "Sulaka",
7523
8051
  parentId: null,
8052
+ validUntil: null,
7524
8053
  externalId: "pQ8nGxWmZ2Q3"
7525
8054
  },
7526
8055
  {
7527
8056
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7528
8057
  name: "Pualula",
7529
8058
  parentId: null,
8059
+ validUntil: null,
7530
8060
  externalId: "Aq91DweLmT8k"
7531
8061
  },
7532
8062
  {
7533
8063
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7534
8064
  name: "Chuminga",
7535
8065
  parentId: null,
8066
+ validUntil: null,
7536
8067
  externalId: "Rw0fYNh2Xk9a"
7537
8068
  },
7538
8069
  {
7539
8070
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7540
8071
  name: "Ibombo",
7541
8072
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8073
+ validUntil: null,
7542
8074
  externalId: "k7DsP4vbN1Qe"
7543
8075
  },
7544
8076
  {
7545
8077
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7546
8078
  name: "Isango",
7547
8079
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8080
+ validUntil: null,
7548
8081
  externalId: "Gm3Z9eQpHw4L"
7549
8082
  },
7550
8083
  {
7551
8084
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7552
8085
  name: "Isamba",
7553
8086
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8087
+ validUntil: null,
7554
8088
  externalId: "sT0xVu1KqJ7r"
7555
8089
  },
7556
8090
  {
7557
8091
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7558
8092
  name: "Itambo",
7559
8093
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8094
+ validUntil: null,
7560
8095
  externalId: "Nq6Bv2HpL9Te"
7561
8096
  },
7562
8097
  {
7563
8098
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7564
8099
  name: "Ezhi",
7565
8100
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8101
+ validUntil: null,
7566
8102
  externalId: "xK8cQ0ZRy5Wd"
7567
8103
  },
7568
8104
  {
7569
8105
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7570
8106
  name: "Ilanga",
7571
8107
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
8108
+ validUntil: null,
7572
8109
  externalId: "Cq4Jm1XvN8Ls"
7573
8110
  },
7574
8111
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7576,42 +8113,49 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7576
8113
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7577
8114
  name: "Klow",
7578
8115
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8116
+ validUntil: null,
7579
8117
  externalId: "IkYcYBUcyY2"
7580
8118
  },
7581
8119
  {
7582
8120
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7583
8121
  name: "Mbondo",
7584
8122
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8123
+ validUntil: null,
7585
8124
  externalId: "Qhvv5hvo3mY"
7586
8125
  },
7587
8126
  {
7588
8127
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7589
8128
  name: "Ndara",
7590
8129
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8130
+ validUntil: null,
7591
8131
  externalId: "crXh068O9TR"
7592
8132
  },
7593
8133
  {
7594
8134
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7595
8135
  name: "Olani",
7596
8136
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8137
+ validUntil: null,
7597
8138
  externalId: "r00It8Tvvp7"
7598
8139
  },
7599
8140
  {
7600
8141
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7601
8142
  name: "Pemba",
7602
8143
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8144
+ validUntil: null,
7603
8145
  externalId: "ZnUWsbONIaH"
7604
8146
  },
7605
8147
  {
7606
8148
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7607
8149
  name: "Quanza",
7608
8150
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8151
+ validUntil: null,
7609
8152
  externalId: "fDZycvQTa7l"
7610
8153
  },
7611
8154
  {
7612
8155
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7613
8156
  name: "Rivka",
7614
8157
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8158
+ validUntil: null,
7615
8159
  externalId: "KqswxCGTELa"
7616
8160
  },
7617
8161
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7619,30 +8163,35 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7619
8163
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7620
8164
  name: "Mbula",
7621
8165
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8166
+ validUntil: null,
7622
8167
  externalId: "osEbKjRc9Kg"
7623
8168
  },
7624
8169
  {
7625
8170
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7626
8171
  name: "Ndoki",
7627
8172
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8173
+ validUntil: null,
7628
8174
  externalId: "aq4daBUAGr3"
7629
8175
  },
7630
8176
  {
7631
8177
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7632
8178
  name: "Tsanga",
7633
8179
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8180
+ validUntil: null,
7634
8181
  externalId: "cqis6Y8trbJ"
7635
8182
  },
7636
8183
  {
7637
8184
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7638
8185
  name: "Waziri",
7639
8186
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8187
+ validUntil: null,
7640
8188
  externalId: "LMijHPyyx6d"
7641
8189
  },
7642
8190
  {
7643
8191
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7644
8192
  name: "Zimbi",
7645
8193
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8194
+ validUntil: null,
7646
8195
  externalId: "pcQYbPuKGZ7"
7647
8196
  },
7648
8197
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7650,59 +8199,67 @@ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7650
8199
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7651
8200
  name: "Felani",
7652
8201
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8202
+ validUntil: null,
7653
8203
  externalId: "gSqpoCGdMXp"
7654
8204
  },
7655
8205
  {
7656
8206
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7657
8207
  name: "Goroma",
7658
8208
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8209
+ validUntil: null,
7659
8210
  externalId: "KvAAIaNqVrp"
7660
8211
  },
7661
8212
  {
7662
8213
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7663
8214
  name: "Halifu",
7664
8215
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8216
+ validUntil: null,
7665
8217
  externalId: "qe4UnEVt1hv"
7666
8218
  },
7667
8219
  {
7668
8220
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7669
8221
  name: "Jabari",
7670
8222
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8223
+ validUntil: null,
7671
8224
  externalId: "yHH9Nz4rLOt"
7672
8225
  },
7673
8226
  {
7674
8227
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7675
8228
  name: "Kifani",
7676
8229
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8230
+ validUntil: null,
7677
8231
  externalId: "eSWmXIGeu1I"
7678
8232
  },
7679
8233
  {
7680
8234
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7681
8235
  name: "Lumela",
7682
8236
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
8237
+ validUntil: null,
7683
8238
  externalId: "bh0b3aI1uP3"
7684
8239
  }
7685
8240
  ];
7686
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
7687
- var MOCK_LOCATIONS_BASE = [
8241
+ var V2_DEFAULT_MOCK_LOCATIONS = [
7688
8242
  {
7689
8243
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7690
8244
  name: "Central Provincial Office",
7691
8245
  locationType: "CRVS_OFFICE",
7692
8246
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8247
+ validUntil: null,
7693
8248
  externalId: "Xr3Df8WpK6Ys"
7694
8249
  },
7695
8250
  {
7696
8251
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7697
8252
  name: "Central Health Post",
7698
8253
  locationType: "HEALTH_FACILITY",
7699
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
8254
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
8255
+ validUntil: null
7700
8256
  },
7701
8257
  {
7702
8258
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7703
8259
  name: "Ibombo District Office",
7704
8260
  locationType: "CRVS_OFFICE",
7705
8261
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8262
+ validUntil: null,
7706
8263
  externalId: "Sm4Nw7GrD2Vy"
7707
8264
  },
7708
8265
  {
@@ -7710,6 +8267,7 @@ var MOCK_LOCATIONS_BASE = [
7710
8267
  name: "Isamba District Office",
7711
8268
  locationType: "CRVS_OFFICE",
7712
8269
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
8270
+ validUntil: null,
7713
8271
  externalId: "Vg1Bq5XeH9Lt"
7714
8272
  },
7715
8273
  {
@@ -7717,6 +8275,7 @@ var MOCK_LOCATIONS_BASE = [
7717
8275
  name: "Isango District Office",
7718
8276
  locationType: "CRVS_OFFICE",
7719
8277
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
8278
+ validUntil: null,
7720
8279
  externalId: "Je7Lm2XqN9Vz"
7721
8280
  },
7722
8281
  {
@@ -7724,6 +8283,7 @@ var MOCK_LOCATIONS_BASE = [
7724
8283
  name: "Sulaka Provincial Office",
7725
8284
  locationType: "CRVS_OFFICE",
7726
8285
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
8286
+ validUntil: null,
7727
8287
  externalId: "Ht2Wp9KcX5Qv"
7728
8288
  },
7729
8289
  {
@@ -7731,6 +8291,7 @@ var MOCK_LOCATIONS_BASE = [
7731
8291
  name: "Ilanga District Office",
7732
8292
  locationType: "CRVS_OFFICE",
7733
8293
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
8294
+ validUntil: null,
7734
8295
  externalId: "Yp6Ds1WqN3Xz"
7735
8296
  },
7736
8297
  {
@@ -7738,6 +8299,7 @@ var MOCK_LOCATIONS_BASE = [
7738
8299
  name: "Chamakubi Health Post",
7739
8300
  locationType: "HEALTH_FACILITY",
7740
8301
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8302
+ validUntil: null,
7741
8303
  externalId: "M1nFr8LbC2Qy"
7742
8304
  },
7743
8305
  {
@@ -7745,6 +8307,7 @@ var MOCK_LOCATIONS_BASE = [
7745
8307
  name: "Ibombo Rural Health Centre",
7746
8308
  locationType: "HEALTH_FACILITY",
7747
8309
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8310
+ validUntil: null,
7748
8311
  externalId: "bT7pV6YrW0Xc"
7749
8312
  },
7750
8313
  {
@@ -7752,6 +8315,7 @@ var MOCK_LOCATIONS_BASE = [
7752
8315
  name: "Chikobo Rural Health Centre",
7753
8316
  locationType: "HEALTH_FACILITY",
7754
8317
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8318
+ validUntil: null,
7755
8319
  externalId: "zE4qPn2SgJ5d"
7756
8320
  },
7757
8321
  {
@@ -7759,6 +8323,7 @@ var MOCK_LOCATIONS_BASE = [
7759
8323
  name: "Chilochabalenje Health Post",
7760
8324
  locationType: "HEALTH_FACILITY",
7761
8325
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8326
+ validUntil: null,
7762
8327
  externalId: "H8vDs1MqR4Uf"
7763
8328
  },
7764
8329
  {
@@ -7766,6 +8331,7 @@ var MOCK_LOCATIONS_BASE = [
7766
8331
  name: "Chipeso Rural Health Centre",
7767
8332
  locationType: "HEALTH_FACILITY",
7768
8333
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8334
+ validUntil: null,
7769
8335
  externalId: "Qw3uZ9KfX6Lm"
7770
8336
  },
7771
8337
  {
@@ -7773,6 +8339,7 @@ var MOCK_LOCATIONS_BASE = [
7773
8339
  name: "Chisamba Rural Health Centre",
7774
8340
  locationType: "HEALTH_FACILITY",
7775
8341
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8342
+ validUntil: null,
7776
8343
  externalId: "Yr0pCg8LdM2s"
7777
8344
  },
7778
8345
  {
@@ -7780,6 +8347,7 @@ var MOCK_LOCATIONS_BASE = [
7780
8347
  name: "Chitanda Rural Health Centre",
7781
8348
  locationType: "HEALTH_FACILITY",
7782
8349
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8350
+ validUntil: null,
7783
8351
  externalId: "tS9gJ4PwB1Qx"
7784
8352
  },
7785
8353
  {
@@ -7787,6 +8355,7 @@ var MOCK_LOCATIONS_BASE = [
7787
8355
  name: "Golden Valley Rural Health Centre",
7788
8356
  locationType: "HEALTH_FACILITY",
7789
8357
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8358
+ validUntil: null,
7790
8359
  externalId: "Ld7Qm3XsA8Vr"
7791
8360
  },
7792
8361
  {
@@ -7794,6 +8363,7 @@ var MOCK_LOCATIONS_BASE = [
7794
8363
  name: "Ipongo Rural Health Centre",
7795
8364
  locationType: "HEALTH_FACILITY",
7796
8365
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8366
+ validUntil: null,
7797
8367
  externalId: "kF2sW9DmH0Bt"
7798
8368
  },
7799
8369
  {
@@ -7801,6 +8371,7 @@ var MOCK_LOCATIONS_BASE = [
7801
8371
  name: "Itumbwe Health Post",
7802
8372
  locationType: "HEALTH_FACILITY",
7803
8373
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8374
+ validUntil: null,
7804
8375
  externalId: "Ue5Xb3VaC7Pq"
7805
8376
  },
7806
8377
  {
@@ -7808,6 +8379,7 @@ var MOCK_LOCATIONS_BASE = [
7808
8379
  name: "Kabangalala Rural Health Centre",
7809
8380
  locationType: "HEALTH_FACILITY",
7810
8381
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
8382
+ validUntil: null,
7811
8383
  externalId: "Pz8Kc1TqH6Jn"
7812
8384
  },
7813
8385
  // Village offices
@@ -7816,10 +8388,10 @@ var MOCK_LOCATIONS_BASE = [
7816
8388
  name: "Klow Village Office",
7817
8389
  locationType: "CRVS_OFFICE",
7818
8390
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
8391
+ validUntil: null,
7819
8392
  externalId: "PmAyxAJkxiJ"
7820
8393
  }
7821
8394
  ];
7822
- var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7823
8395
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7824
8396
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7825
8397
  );