@opencrvs/toolkit 2.1.0-rc.69ab488 → 2.1.0-rc.6bae709

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 (93) hide show
  1. package/README.md +1 -0
  2. package/create-countryconfig/index.js +114 -66
  3. package/create-countryconfig/node_modules/.bin/degit +21 -0
  4. package/create-countryconfig/package.json +4 -1
  5. package/dist/application-config/index.js +230 -197
  6. package/dist/cli.js +174 -106
  7. package/dist/commons/api/router.d.ts +3608 -3367
  8. package/dist/commons/application-config/index.d.ts +6 -6
  9. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  10. package/dist/commons/conditionals/validate.d.ts +11 -4
  11. package/dist/commons/events/ActionConfig.d.ts +112 -105
  12. package/dist/commons/events/ActionDocument.d.ts +117 -123
  13. package/dist/commons/events/ActionInput.d.ts +0 -6
  14. package/dist/commons/events/ActionStatus.d.ts +14 -0
  15. package/dist/commons/events/ActionType.d.ts +62 -62
  16. package/dist/commons/events/AdvancedSearchConfig.d.ts +519 -507
  17. package/dist/commons/events/AuditLog.d.ts +189 -42
  18. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  19. package/dist/commons/events/Conditional.d.ts +3 -3
  20. package/dist/commons/events/CountryConfigQueryInput.d.ts +590 -590
  21. package/dist/commons/events/Draft.d.ts +37 -37
  22. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  23. package/dist/commons/events/EventConfig.d.ts +8 -5
  24. package/dist/commons/events/EventDocument.d.ts +48 -48
  25. package/dist/commons/events/EventIndex.d.ts +49 -72
  26. package/dist/commons/events/EventMetadata.d.ts +40 -40
  27. package/dist/commons/events/FieldConfig.d.ts +406 -389
  28. package/dist/commons/events/FieldType.d.ts +51 -51
  29. package/dist/commons/events/FieldTypeMapping.d.ts +90 -90
  30. package/dist/commons/events/FieldValue.d.ts +14 -14
  31. package/dist/commons/events/Flag.d.ts +57 -15
  32. package/dist/commons/events/PlainDate.d.ts +8 -0
  33. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  34. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  35. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  36. package/dist/commons/events/WorkqueueConfig.d.ts +817 -814
  37. package/dist/commons/events/deduplication.d.ts +1 -1
  38. package/dist/commons/events/event.d.ts +14 -2
  39. package/dist/commons/events/field.d.ts +69 -198
  40. package/dist/commons/events/index.d.ts +1 -0
  41. package/dist/commons/events/locationPayloads.d.ts +95 -0
  42. package/dist/commons/events/locations.d.ts +192 -12
  43. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  44. package/dist/commons/events/scopes.d.ts +4 -4
  45. package/dist/commons/events/state/index.d.ts +17 -17
  46. package/dist/commons/events/state/utils.d.ts +7 -7
  47. package/dist/commons/events/test.utils.d.ts +40 -43
  48. package/dist/commons/events/utils.d.ts +122 -114
  49. package/dist/commons/notification/UserNotifications.d.ts +10 -10
  50. package/dist/conditionals/index.js +303 -55
  51. package/dist/environment/derived-variables.d.ts +119 -131
  52. package/dist/environment/derived-variables.d.ts.map +1 -1
  53. package/dist/environment/derived-variables.js +0 -14
  54. package/dist/environment/index.d.ts +1 -0
  55. package/dist/environment/index.d.ts.map +1 -1
  56. package/dist/environment/index.js +10 -0
  57. package/dist/environment/logger.d.ts +3 -3
  58. package/dist/environment/manage-users.js +17 -7
  59. package/dist/environment/paths.d.ts +7 -0
  60. package/dist/environment/paths.d.ts.map +1 -0
  61. package/dist/environment/paths.js +72 -0
  62. package/dist/environment/questions.d.ts +75 -74
  63. package/dist/environment/questions.d.ts.map +1 -1
  64. package/dist/environment/setup-environment.js +10 -29
  65. package/dist/environment/swarm-to-k8s.js +17 -7
  66. package/dist/environment/templates.d.ts.map +1 -1
  67. package/dist/environment/templates.js +2 -1
  68. package/dist/environment/update-workflows.d.ts.map +1 -1
  69. package/dist/environment/update-workflows.js +34 -12
  70. package/dist/environment/upgrade.d.ts +2 -0
  71. package/dist/environment/upgrade.d.ts.map +1 -0
  72. package/dist/environment/upgrade.js +82 -0
  73. package/dist/environment/users.js +28 -20
  74. package/dist/environment/utils.d.ts +1 -1
  75. package/dist/environment/utils.js +17 -7
  76. package/dist/events/deduplication.d.ts +1 -1
  77. package/dist/events/index.js +3914 -3562
  78. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  79. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  80. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  81. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  82. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  83. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  84. package/dist/notification/index.js +1937 -1112
  85. package/dist/scopes/index.d.ts +394 -169
  86. package/dist/scopes/index.js +304 -55
  87. package/dist/templates/charts-values/dependencies/values.yaml +0 -3
  88. package/dist/templates/charts-values/opencrvs-services/values.yaml +4 -7
  89. package/dist/templates/charts-values/opentelemetry/values.yaml +73 -0
  90. package/opencrvs-toolkit-2.1.0-rc.6bae709.tgz +0 -0
  91. package/package.json +7 -7
  92. package/tsconfig.tsbuildinfo +1 -1
  93. package/opencrvs-toolkit-2.1.0-rc.69ab488.tgz +0 -0
@@ -38,7 +38,7 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z45 = __toESM(require("zod/v4"));
41
+ var z46 = __toESM(require("zod/v4"));
42
42
 
43
43
  // ../commons/src/url.ts
44
44
  function joinUrl(base, path) {
@@ -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,263 @@ 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
+ };
271
+ var actionFlagPattern;
272
+ function getActionFlagPattern() {
273
+ actionFlagPattern ??= new RegExp(
274
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
275
+ ActionStatus
276
+ ).join("|").toLowerCase()})$`
277
+ );
278
+ return actionFlagPattern;
279
+ }
280
+ var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
281
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
282
+ });
283
+ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
284
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
285
+ InherentFlags
286
+ ).join(", ")}`
287
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
288
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
289
+ }).describe("Custom flag identifier defined by the country config.");
290
+ var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
291
+ var ContainsFlags = z5.object({
292
+ anyOf: z5.array(Flag).optional(),
293
+ noneOf: z5.array(Flag).optional(),
294
+ allOf: z5.array(Flag).optional()
295
+ }).meta({
296
+ id: "ContainsFlags"
297
+ });
298
+ var FlagConfig = z5.object({
299
+ id: CustomFlag,
300
+ requiresAction: z5.boolean().describe(
301
+ "Indicates if this flag expects an action to be performed to be cleared."
302
+ ),
303
+ label: TranslationConfig.describe("Human readable label of the flag.")
304
+ }).meta({
305
+ id: "FlagConfig",
306
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
307
+ });
308
+ var ActionFlagConfig = z5.object({
309
+ id: Flag,
310
+ operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
311
+ conditional: Conditional.optional().describe(
312
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
313
+ )
314
+ }).meta({
315
+ id: "ActionFlagConfig",
316
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
317
+ });
318
+
68
319
  // ../commons/src/scopes.ts
69
- var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
320
+ var JurisdictionFilter = z6.enum(["administrativeArea", "location", "all"]).describe(
70
321
  "Filters based on user jurisdiction relative to their office location in hierarchy."
71
322
  );
72
- var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
73
- var RecordScopeTypeV2 = z2.enum([
323
+ var UserFilter = z6.enum(["user"]).describe("Filters based on the user. Limits to self.");
324
+ var RecordScopeTypeV2 = z6.enum([
74
325
  "record.search",
75
326
  "record.create",
76
327
  "record.read",
@@ -88,7 +339,7 @@ var RecordScopeTypeV2 = z2.enum([
88
339
  "record.unassign-others",
89
340
  "record.custom-action"
90
341
  ]);
91
- var PlainScopeType = z2.enum([
342
+ var PlainScopeType = z6.enum([
92
343
  // Misc. system scopes
93
344
  "bypassratelimit",
94
345
  "record.reindex",
@@ -96,6 +347,7 @@ var PlainScopeType = z2.enum([
96
347
  "integration.create",
97
348
  "record.import",
98
349
  "config.update-all",
350
+ "location.edit",
99
351
  "attachment.upload",
100
352
  "profile.electronic-signature",
101
353
  "user.read-only-my-audit",
@@ -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,159 @@ 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() })
675
+ });
676
+ var createdVersionFields = {
677
+ id: z8.string(),
678
+ versionId: z8.string(),
679
+ name: z8.string(),
680
+ externalId: z8.string().nullish(),
681
+ effectiveFrom: z8.string(),
682
+ status: z8.string()
683
+ };
684
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
685
+ operation: z8.literal("locations.create"),
686
+ requestData: z8.object({
687
+ ...createdVersionFields,
688
+ administrativeAreaId: z8.string().nullish(),
689
+ locationType: z8.string().nullish()
690
+ })
691
+ });
692
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
693
+ operation: z8.literal("administrativeAreas.create"),
694
+ requestData: z8.object({
695
+ ...createdVersionFields,
696
+ parentId: z8.string().nullish()
697
+ })
698
+ });
699
+ var ChangedStringField = z8.object({ from: z8.string(), to: z8.string() });
700
+ var ChangedNullableStringField = z8.object({
701
+ from: z8.string().nullable(),
702
+ to: z8.string().nullable()
703
+ });
704
+ var updatedVersionRequestData = z8.object({
705
+ id: z8.string(),
706
+ versionId: z8.string(),
707
+ name: z8.string(),
708
+ externalId: z8.string().nullish(),
709
+ status: z8.string(),
710
+ effectiveFrom: z8.string(),
711
+ lastVersionId: z8.string()
712
+ });
713
+ var updatedVersionResponseSummary = z8.object({
714
+ previousVersionId: z8.string(),
715
+ versionId: z8.string(),
716
+ changed: z8.object({
717
+ name: ChangedStringField.optional(),
718
+ externalId: ChangedNullableStringField.optional(),
719
+ status: ChangedStringField.optional()
720
+ })
721
+ });
722
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
723
+ operation: z8.literal("locations.update"),
724
+ requestData: updatedVersionRequestData,
725
+ responseSummary: updatedVersionResponseSummary
726
+ });
727
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
728
+ operation: z8.literal("administrativeAreas.update"),
729
+ requestData: updatedVersionRequestData,
730
+ responseSummary: updatedVersionResponseSummary
731
+ });
732
+ var withdrawVersionRequestData = z8.object({
733
+ id: z8.string(),
734
+ versionId: z8.string()
735
+ });
736
+ var withdrawVersionResponseSummary = z8.object({
737
+ effectiveFrom: z8.string(),
738
+ name: z8.string(),
739
+ externalId: z8.string().nullish(),
740
+ status: z8.string()
741
+ });
742
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
743
+ operation: z8.literal("locations.withdrawVersion"),
744
+ requestData: withdrawVersionRequestData,
745
+ responseSummary: withdrawVersionResponseSummary
746
+ });
747
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
748
+ operation: z8.literal("administrativeAreas.withdrawVersion"),
749
+ requestData: withdrawVersionRequestData,
750
+ responseSummary: withdrawVersionResponseSummary
532
751
  });
533
752
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
534
- operation: z5.literal("attachments.upload"),
535
- requestData: z5.object({
536
- transactionId: z5.string(),
537
- path: z5.string().nullable()
753
+ operation: z8.literal("attachments.upload"),
754
+ requestData: z8.object({
755
+ transactionId: z8.string(),
756
+ path: z8.string().nullable()
538
757
  }),
539
- responseSummary: z5.object({ fileUrl: z5.string() })
758
+ responseSummary: z8.object({ fileUrl: z8.string() })
540
759
  });
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()
760
+ var subjectOnly = z8.object({ subjectId: z8.string() });
761
+ var subjectWithReason = z8.object({
762
+ subjectId: z8.string(),
763
+ reason: z8.string(),
764
+ comment: z8.string().optional()
546
765
  });
547
766
  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()
767
+ operation: z8.literal("user.create_user"),
768
+ requestData: z8.object({
769
+ subjectId: z8.string(),
770
+ role: z8.string(),
771
+ primaryOfficeId: z8.string()
553
772
  })
554
773
  });
555
774
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
556
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
775
+ operation: z8.enum(["user.deactivate", "user.reactivate"]),
557
776
  requestData: subjectWithReason
558
777
  });
559
778
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
560
- operation: z5.enum([
779
+ operation: z8.enum([
561
780
  "user.edit_user",
562
781
  "user.logged_in",
563
782
  "user.logged_out",
@@ -571,14 +790,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
571
790
  requestData: subjectOnly
572
791
  });
573
792
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
574
- operation: z5.literal("user.email_address_changed"),
793
+ operation: z8.literal("user.email_address_changed"),
575
794
  requestData: subjectOnly,
576
- responseSummary: z5.object({ email: z5.string() })
795
+ responseSummary: z8.object({ email: z8.string() })
577
796
  });
578
797
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
579
- operation: z5.literal("user.phone_number_changed"),
798
+ operation: z8.literal("user.phone_number_changed"),
580
799
  requestData: subjectOnly,
581
- responseSummary: z5.object({ phoneNumber: z5.string() })
800
+ responseSummary: z8.object({ phoneNumber: z8.string() })
582
801
  });
583
802
  var userBaseOmit = {
584
803
  id: true,
@@ -586,14 +805,14 @@ var userBaseOmit = {
586
805
  clientType: true,
587
806
  createdAt: true
588
807
  };
589
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
808
+ var UserAuditRecordInput = z8.discriminatedUnion("operation", [
590
809
  UserCreateEntrySchema.omit(userBaseOmit),
591
810
  UserReasonEntrySchema.omit(userBaseOmit),
592
811
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
593
812
  UserEmailChangedEntrySchema.omit(userBaseOmit),
594
813
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
595
814
  ]);
596
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
815
+ var AuditLogEntrySchema = z8.discriminatedUnion("operation", [
597
816
  EventCreateEntrySchema,
598
817
  EventGetEntrySchema,
599
818
  EventSearchEntrySchema,
@@ -605,6 +824,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
605
824
  IntegrationActivateEntrySchema,
606
825
  IntegrationDeleteEntrySchema,
607
826
  IntegrationRefreshSecretEntrySchema,
827
+ LocationCreateEntrySchema,
828
+ LocationUpdateEntrySchema,
829
+ AdministrativeAreaUpdateEntrySchema,
830
+ LocationWithdrawEntrySchema,
831
+ AdministrativeAreaWithdrawEntrySchema,
832
+ AdministrativeAreaCreateEntrySchema,
608
833
  AttachmentUploadEntrySchema,
609
834
  UserCreateEntrySchema,
610
835
  UserReasonEntrySchema,
@@ -620,76 +845,11 @@ var CHILD_ONBOARDING_EVENT = "child-onboarding";
620
845
  // ../commons/src/events/ActionConfig.ts
621
846
  var z24 = __toESM(require("zod/v4"));
622
847
 
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
848
  // ../commons/src/events/FieldConfig.ts
639
849
  var import_v43 = __toESM(require("zod/v4"));
640
850
 
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
851
  // ../commons/src/events/FieldType.ts
692
- var z8 = __toESM(require("zod/v4"));
852
+ var z9 = __toESM(require("zod/v4"));
693
853
  var FieldType = {
694
854
  NAME: "NAME",
695
855
  PHONE: "PHONE",
@@ -753,7 +913,7 @@ var FieldType = {
753
913
  */
754
914
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
755
915
  };
756
- var FileFieldType = z8.enum([
916
+ var FileFieldType = z9.enum([
757
917
  FieldType.FILE,
758
918
  FieldType.FILE_WITH_OPTIONS,
759
919
  FieldType.SIGNATURE
@@ -789,160 +949,164 @@ var HiddenFieldTypes = [
789
949
  ];
790
950
 
791
951
  // ../commons/src/events/FieldValue.ts
792
- var z12 = __toESM(require("zod/v4"));
952
+ var z13 = __toESM(require("zod/v4"));
793
953
 
794
954
  // ../commons/src/documents.ts
795
- var z9 = __toESM(require("zod/v4"));
796
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
955
+ var z10 = __toESM(require("zod/v4"));
956
+ var FullDocumentUrl = z10.string().brand("FullDocumentUrl").describe(
797
957
  "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
958
  );
799
- var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
959
+ var FullDocumentPath = z10.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
800
960
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
801
961
  );
802
- var DocumentPath = z9.string().brand("DocumentPath").describe(
962
+ var DocumentPath = z10.string().brand("DocumentPath").describe(
803
963
  "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
964
  );
805
965
 
806
966
  // ../commons/src/events/CompositeFieldValue.ts
807
- var z10 = __toESM(require("zod/v4"));
967
+ var z11 = __toESM(require("zod/v4"));
808
968
  var AddressType = {
809
969
  DOMESTIC: "DOMESTIC",
810
970
  INTERNATIONAL: "INTERNATIONAL"
811
971
  };
812
- var FileFieldValue = z10.object({
972
+ var FileFieldValue = z11.object({
813
973
  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(),
974
+ originalFilename: z11.string(),
975
+ type: z11.string()
976
+ });
977
+ var NameFieldValue = z11.object({
978
+ firstname: z11.string(),
979
+ surname: z11.string(),
980
+ middlename: z11.string().optional()
981
+ });
982
+ var NameFieldUpdateValue = z11.object({
983
+ firstname: z11.string().nullish(),
984
+ surname: z11.string().nullish(),
985
+ middlename: z11.string().nullish()
986
+ }).or(z11.null()).or(z11.undefined());
987
+ var StreetLevelDetailsValue = z11.record(z11.string(), z11.string()).optional();
988
+ var StreetLevelDetailsUpdateValue = z11.record(z11.string(), z11.string().nullable()).nullish();
989
+ var BaseAddressFieldValue = z11.object({
990
+ country: z11.string(),
831
991
  streetLevelDetails: StreetLevelDetailsValue
832
992
  });
833
- var BaseAddressFieldUpdateValue = z10.object({
834
- country: z10.string().nullish(),
993
+ var BaseAddressFieldUpdateValue = z11.object({
994
+ country: z11.string().nullish(),
835
995
  streetLevelDetails: StreetLevelDetailsUpdateValue
836
996
  });
837
997
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
838
- addressType: z10.literal(AddressType.DOMESTIC),
839
- administrativeArea: z10.string().uuid()
998
+ addressType: z11.literal(AddressType.DOMESTIC),
999
+ administrativeArea: z11.string().uuid()
840
1000
  });
841
1001
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
842
- addressType: z10.literal(AddressType.INTERNATIONAL)
1002
+ addressType: z11.literal(AddressType.INTERNATIONAL)
843
1003
  });
844
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
1004
+ var AddressFieldValue = z11.discriminatedUnion("addressType", [
845
1005
  DomesticAddressFieldValue,
846
1006
  InternationalAddressFieldValue
847
1007
  ]);
848
1008
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
849
- addressType: z10.literal(AddressType.DOMESTIC),
850
- administrativeArea: z10.string().uuid().nullish()
1009
+ addressType: z11.literal(AddressType.DOMESTIC),
1010
+ administrativeArea: z11.string().uuid().nullish()
851
1011
  /* Leaf level admin structure */
852
1012
  });
853
1013
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
854
1014
  {
855
- addressType: z10.literal(AddressType.INTERNATIONAL)
1015
+ addressType: z11.literal(AddressType.INTERNATIONAL)
856
1016
  }
857
1017
  );
858
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
1018
+ var AddressFieldUpdateValue = z11.discriminatedUnion("addressType", [
859
1019
  DomesticAddressUpdateFieldValue,
860
1020
  InternationalAddressUpdateFieldValue
861
1021
  ]).nullish();
862
- var FileFieldValueWithOption = z10.object({
1022
+ var FileFieldValueWithOption = z11.object({
863
1023
  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()
1024
+ originalFilename: z11.string(),
1025
+ type: z11.string(),
1026
+ option: z11.string()
1027
+ });
1028
+ var FileFieldWithOptionValue = z11.array(FileFieldValueWithOption);
1029
+ var HttpFieldValue = z11.object({
1030
+ loading: z11.boolean(),
1031
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1032
+ data: z11.any()
1033
+ });
1034
+ var HttpFieldUpdateValue = z11.object({
1035
+ loading: z11.boolean().nullish(),
1036
+ error: z11.object({ statusCode: z11.number(), message: z11.string() }).nullish(),
1037
+ data: z11.any().nullish()
1038
+ }).or(z11.null()).or(z11.undefined());
1039
+ var QueryParamReaderFieldValue = z11.object({
1040
+ data: z11.record(z11.string(), z11.string()),
1041
+ updatedAt: z11.iso.datetime()
882
1042
  }).nullish();
883
- var QueryParamReaderFieldUpdateValue = z10.object({
884
- data: z10.record(z10.string(), z10.string())
1043
+ var QueryParamReaderFieldUpdateValue = z11.object({
1044
+ data: z11.record(z11.string(), z11.string())
885
1045
  });
886
- var ReadDataValue = z10.object({
887
- data: z10.any()
1046
+ var ReadDataValue = z11.object({
1047
+ data: z11.any()
888
1048
  });
889
1049
  var QrReaderFieldValue = ReadDataValue;
890
1050
  var IdReaderFieldValue = ReadDataValue;
891
- var NumberWithUnitFieldValue = z10.object({
892
- numericValue: z10.number(),
893
- unit: z10.string()
1051
+ var NumberWithUnitFieldValue = z11.object({
1052
+ numericValue: z11.number(),
1053
+ unit: z11.string()
894
1054
  });
895
- var NumberWithUnitFieldUpdateValue = z10.object({
896
- numericValue: z10.number().optional(),
897
- unit: z10.string().optional()
1055
+ var NumberWithUnitFieldUpdateValue = z11.object({
1056
+ numericValue: z11.number().optional(),
1057
+ unit: z11.string().optional()
898
1058
  });
899
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1059
+ var CustomFieldValue = z11.unknown().brand("CustomFieldValue");
900
1060
 
901
1061
  // ../commons/src/events/PlainDate.ts
902
1062
  var import_zod = require("zod");
903
1063
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
1064
+ function plainDateToLocalDate(date) {
1065
+ const [year, month, day] = date.split("-").map(Number);
1066
+ return new Date(year, month - 1, day);
1067
+ }
904
1068
 
905
1069
  // ../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()
1070
+ var TextValue = z13.string();
1071
+ var HiddenFieldValue = z13.string();
1072
+ var NonEmptyTextValue = z13.string().trim().min(1);
1073
+ var DateValue = z13.iso.date().describe("Date in the format YYYY-MM-DD");
1074
+ var AgeValue = z13.object({
1075
+ age: z13.number(),
1076
+ asOfDateRef: z13.string()
913
1077
  });
914
1078
  var AgeUpdateValue = AgeValue.optional().nullable();
915
- var AutocompleteValue = z12.object({
916
- label: z12.string(),
917
- value: z12.string()
1079
+ var AutocompleteValue = z13.object({
1080
+ label: z13.string(),
1081
+ value: z13.string()
918
1082
  });
919
1083
  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([
1084
+ var TimeValue = z13.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1085
+ var DatetimeValue = z13.iso.datetime();
1086
+ var SelectDateRangeValue = z13.enum([
923
1087
  "last7Days",
924
1088
  "last30Days",
925
1089
  "last90Days",
926
1090
  "last365Days"
927
1091
  ]);
928
- var DateRangeFieldValue = z12.object({
1092
+ var DateRangeFieldValue = z13.object({
929
1093
  start: PlainDate,
930
1094
  end: PlainDate
931
1095
  }).or(PlainDate).describe(
932
1096
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
933
1097
  );
934
- var EmailValue = z12.email();
935
- var CheckboxFieldValue = z12.boolean();
936
- var NumberFieldValue = z12.number();
1098
+ var EmailValue = z13.email();
1099
+ var CheckboxFieldValue = z13.boolean();
1100
+ var NumberFieldValue = z13.number();
937
1101
  var SignatureFieldValue = FileFieldValue;
938
- var ButtonFieldValue = z12.number();
939
- var VerificationStatusValue = z12.enum([
1102
+ var ButtonFieldValue = z13.number();
1103
+ var VerificationStatusValue = z13.enum([
940
1104
  "verified",
941
1105
  "authenticated",
942
1106
  "failed",
943
1107
  "pending"
944
1108
  ]);
945
- var LeafFieldValues = z12.union([
1109
+ var LeafFieldValues = z13.union([
946
1110
  AddressFieldValue,
947
1111
  TextValue,
948
1112
  PlainDate,
@@ -968,11 +1132,11 @@ var LeafFieldValues = z12.union([
968
1132
  AutocompleteValue,
969
1133
  AutocompleteUpdateValue
970
1134
  ]);
971
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
972
- var DataFieldValue = z12.object({
973
- data: z12.record(z12.string(), LeafFieldValues)
1135
+ var FieldGroupValue = z13.record(z13.string(), LeafFieldValues);
1136
+ var DataFieldValue = z13.object({
1137
+ data: z13.record(z13.string(), LeafFieldValues)
974
1138
  }).nullish();
975
- var FieldValue = z12.union([
1139
+ var FieldValue = z13.union([
976
1140
  LeafFieldValues,
977
1141
  DataFieldValue,
978
1142
  FieldGroupValue
@@ -1006,7 +1170,7 @@ function safeUnion(schemas) {
1006
1170
  const sortedSchemas = [...schemas].sort(
1007
1171
  (a, b) => schemaPriority(a) - schemaPriority(b)
1008
1172
  );
1009
- return z12.any().superRefine((val, ctx) => {
1173
+ return z13.any().superRefine((val, ctx) => {
1010
1174
  for (const schema of sortedSchemas) {
1011
1175
  if (schema.safeParse(val).success) {
1012
1176
  return;
@@ -1045,9 +1209,9 @@ var FieldUpdateValue = safeUnion([
1045
1209
  ]);
1046
1210
 
1047
1211
  // ../commons/src/events/serializers/user/serializer.ts
1048
- var z13 = __toESM(require("zod/v4"));
1049
- var SerializedUserField = z13.object({
1050
- $userField: z13.enum([
1212
+ var z14 = __toESM(require("zod/v4"));
1213
+ var SerializedUserField = z14.object({
1214
+ $userField: z14.enum([
1051
1215
  "id",
1052
1216
  "name",
1053
1217
  "role",
@@ -1061,7 +1225,7 @@ var SerializedUserField = z13.object({
1061
1225
  "primaryOfficeId",
1062
1226
  "administrativeAreaId"
1063
1227
  ]),
1064
- $location: z13.string().optional()
1228
+ $location: z14.string().optional()
1065
1229
  });
1066
1230
  function userSerializer(userField) {
1067
1231
  return {
@@ -1087,27 +1251,22 @@ var import_v4 = require("zod/v4");
1087
1251
  var z16 = __toESM(require("zod/v4"));
1088
1252
 
1089
1253
  // ../commons/src/events/ActionDocument.ts
1090
- var z14 = __toESM(require("zod/v4"));
1091
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1254
+ var z15 = __toESM(require("zod/v4"));
1255
+ var ActionUpdate = z15.record(z15.string(), FieldUpdateValue).describe(
1092
1256
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1093
1257
  );
1094
- var EventState = z14.record(z14.string(), FieldValue).describe(
1258
+ var EventState = z15.record(z15.string(), FieldValue).describe(
1095
1259
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1096
1260
  );
1097
- var ActionStatus = {
1098
- Requested: "Requested",
1099
- Accepted: "Accepted",
1100
- Rejected: "Rejected"
1101
- };
1102
- var ActionBase = z14.object({
1261
+ var ActionBase = z15.object({
1103
1262
  id: UUID.describe("Unique identifier of the action."),
1104
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1263
+ transactionId: z15.string().describe("Unique identifier of the transaction."),
1105
1264
  createdByUserType: TokenUserType.describe(
1106
1265
  "Indicates whether the action was created by a human-user or by a system-user."
1107
1266
  ),
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."),
1267
+ createdAt: z15.string().datetime().describe("Timestamp indicating when the action was created."),
1268
+ createdBy: z15.string().describe("Identifier of the user who created the action."),
1269
+ createdByRole: z15.string().optional().describe("Role of the user who created the action."),
1111
1270
  createdBySignature: DocumentPath.nullish().describe(
1112
1271
  "Reference to the signature of the user who created the action."
1113
1272
  ),
@@ -1119,7 +1278,7 @@ var ActionBase = z14.object({
1119
1278
  "Declaration data defined by the ActionConfig. Supports partial updates."
1120
1279
  ),
1121
1280
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1122
- status: z14.enum([
1281
+ status: z15.enum([
1123
1282
  ActionStatus.Requested,
1124
1283
  ActionStatus.Accepted,
1125
1284
  ActionStatus.Rejected
@@ -1131,138 +1290,139 @@ var ActionBase = z14.object({
1131
1290
  )
1132
1291
  });
1133
1292
  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.")
1293
+ z15.object({
1294
+ type: z15.literal(ActionType.ASSIGN),
1295
+ assignedTo: z15.string().describe("Identifier of the user to whom the action is assigned.")
1137
1296
  // TODO move into 'content' property
1138
1297
  }).shape
1139
1298
  );
1140
1299
  var UnassignedAction = ActionBase.extend(
1141
- z14.object({
1142
- type: z14.literal(ActionType.UNASSIGN)
1300
+ z15.object({
1301
+ type: z15.literal(ActionType.UNASSIGN)
1143
1302
  }).shape
1144
1303
  );
1145
1304
  var RegisterAction = ActionBase.extend(
1146
- z14.object({
1147
- type: z14.literal(ActionType.REGISTER),
1148
- registrationNumber: z14.string().optional().describe(
1305
+ z15.object({
1306
+ type: z15.literal(ActionType.REGISTER),
1307
+ registrationNumber: z15.string().optional().describe(
1149
1308
  "Registration number of the event. Always present for accepted registrations."
1150
1309
  )
1151
1310
  // TODO move into 'content' property
1152
1311
  }).shape
1153
1312
  );
1154
1313
  var DeclareAction = ActionBase.extend(
1155
- z14.object({
1156
- type: z14.literal(ActionType.DECLARE)
1314
+ z15.object({
1315
+ type: z15.literal(ActionType.DECLARE)
1157
1316
  }).shape
1158
1317
  );
1159
- var ReasonContent = z14.object({
1160
- reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1318
+ var ReasonContent = z15.object({
1319
+ reason: z15.string().min(1, { error: "Message cannot be empty" }).describe(
1161
1320
  "Message describing the reason for rejecting or archiving the event."
1162
1321
  )
1163
1322
  });
1164
1323
  var RejectAction = ActionBase.extend(
1165
- z14.object({
1166
- type: z14.literal(ActionType.REJECT),
1324
+ z15.object({
1325
+ type: z15.literal(ActionType.REJECT),
1167
1326
  content: ReasonContent
1168
1327
  }).shape
1169
1328
  );
1170
- var PotentialDuplicate = z14.object({
1329
+ var PotentialDuplicate = z15.object({
1171
1330
  id: UUID,
1172
- trackingId: z14.string()
1331
+ trackingId: z15.string()
1173
1332
  });
1174
1333
  var DuplicateDetectedAction = ActionBase.extend(
1175
- z14.object({
1176
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1177
- content: z14.object({
1178
- duplicates: z14.array(PotentialDuplicate)
1334
+ z15.object({
1335
+ type: z15.literal(ActionType.DUPLICATE_DETECTED),
1336
+ content: z15.object({
1337
+ duplicates: z15.array(PotentialDuplicate)
1179
1338
  })
1180
1339
  }).shape
1181
1340
  );
1182
1341
  var MarkNotDuplicateAction = ActionBase.extend(
1183
- z14.object({
1184
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1342
+ z15.object({
1343
+ type: z15.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1185
1344
  }).shape
1186
1345
  );
1187
1346
  var MarkAsDuplicateAction = ActionBase.extend(
1188
- z14.object({
1189
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1190
- content: z14.object({
1347
+ z15.object({
1348
+ type: z15.literal(ActionType.MARK_AS_DUPLICATE),
1349
+ content: z15.object({
1191
1350
  duplicateOf: UUID
1192
1351
  }).optional()
1193
1352
  }).shape
1194
1353
  );
1195
1354
  var ArchiveAction = ActionBase.extend(
1196
- z14.object({
1197
- type: z14.literal(ActionType.ARCHIVE),
1355
+ z15.object({
1356
+ type: z15.literal(ActionType.ARCHIVE),
1198
1357
  content: ReasonContent
1199
1358
  }).shape
1200
1359
  );
1201
1360
  var UnarchiveAction = ActionBase.extend(
1202
- z14.object({
1203
- type: z14.literal(ActionType.UNARCHIVE)
1361
+ z15.object({
1362
+ type: z15.literal(ActionType.UNARCHIVE)
1204
1363
  }).shape
1205
1364
  );
1206
1365
  var CreatedAction = ActionBase.extend(
1207
- z14.object({
1208
- type: z14.literal(ActionType.CREATE)
1366
+ z15.object({
1367
+ type: z15.literal(ActionType.CREATE)
1209
1368
  }).shape
1210
1369
  );
1211
1370
  var NotifiedAction = ActionBase.extend(
1212
- z14.object({
1213
- type: z14.literal(ActionType.NOTIFY)
1371
+ z15.object({
1372
+ type: z15.literal(ActionType.NOTIFY)
1214
1373
  }).shape
1215
1374
  );
1216
1375
  var EditAction = ActionBase.extend(
1217
- z14.object({
1218
- type: z14.literal(ActionType.EDIT),
1219
- content: z14.object({
1220
- comment: z14.string().describe("Comment for the edit action.").optional()
1221
- })
1376
+ z15.object({
1377
+ type: z15.literal(ActionType.EDIT),
1378
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1379
+ content: z15.object({
1380
+ comment: z15.string().describe("Comment for the edit action.").optional()
1381
+ }).optional()
1222
1382
  }).shape
1223
1383
  );
1224
- var PrintContent = z14.object({
1225
- templateId: z14.string().optional()
1384
+ var PrintContent = z15.object({
1385
+ templateId: z15.string().optional()
1226
1386
  });
1227
1387
  var PrintCertificateAction = ActionBase.extend(
1228
- z14.object({
1229
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1388
+ z15.object({
1389
+ type: z15.literal(ActionType.PRINT_CERTIFICATE),
1230
1390
  content: PrintContent.optional().nullable()
1231
1391
  }).shape
1232
1392
  );
1233
1393
  var RequestedCorrectionAction = ActionBase.extend(
1234
- z14.object({
1235
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1394
+ z15.object({
1395
+ type: z15.literal(ActionType.REQUEST_CORRECTION)
1236
1396
  }).shape
1237
1397
  );
1238
1398
  var ApprovedCorrectionAction = ActionBase.extend(
1239
- z14.object({
1240
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1241
- requestId: z14.string(),
1399
+ z15.object({
1400
+ type: z15.literal(ActionType.APPROVE_CORRECTION),
1401
+ requestId: z15.string(),
1242
1402
  // TODO move into 'content' property
1243
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1403
+ content: z15.object({ immediateCorrection: z15.boolean().optional() }).optional()
1244
1404
  }).shape
1245
1405
  );
1246
1406
  var RejectedCorrectionAction = ActionBase.extend(
1247
- z14.object({
1248
- type: z14.literal(ActionType.REJECT_CORRECTION),
1249
- requestId: z14.string(),
1407
+ z15.object({
1408
+ type: z15.literal(ActionType.REJECT_CORRECTION),
1409
+ requestId: z15.string(),
1250
1410
  // TODO move into 'content' property
1251
1411
  content: ReasonContent
1252
1412
  }).shape
1253
1413
  );
1254
1414
  var ReadAction = ActionBase.extend(
1255
- z14.object({
1256
- type: z14.literal(ActionType.READ)
1415
+ z15.object({
1416
+ type: z15.literal(ActionType.READ)
1257
1417
  }).shape
1258
1418
  );
1259
1419
  var CustomAction = ActionBase.merge(
1260
- z14.object({
1261
- type: z14.literal(ActionType.CUSTOM),
1262
- customActionType: z14.string()
1420
+ z15.object({
1421
+ type: z15.literal(ActionType.CUSTOM),
1422
+ customActionType: z15.string()
1263
1423
  })
1264
1424
  );
1265
- var ActionDocument = z14.discriminatedUnion("type", [
1425
+ var ActionDocument = z15.discriminatedUnion("type", [
1266
1426
  CreatedAction.meta({ id: "CreatedAction" }),
1267
1427
  RejectAction.meta({ id: "RejectAction" }),
1268
1428
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
@@ -1289,64 +1449,12 @@ var AsyncRejectActionDocument = ActionBase.omit({
1289
1449
  declaration: true,
1290
1450
  annotation: true
1291
1451
  }).extend(
1292
- z14.object({
1293
- type: z14.enum(ConfirmableActions),
1294
- status: z14.literal(ActionStatus.Rejected)
1452
+ z15.object({
1453
+ type: z15.enum(ConfirmableActions),
1454
+ status: z15.literal(ActionStatus.Rejected)
1295
1455
  }).shape
1296
1456
  );
1297
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1298
-
1299
- // ../commons/src/events/Flag.ts
1300
- var z15 = __toESM(require("zod/v4"));
1301
- var InherentFlags = {
1302
- INCOMPLETE: "incomplete",
1303
- REJECTED: "rejected",
1304
- CORRECTION_REQUESTED: "correction-requested",
1305
- POTENTIAL_DUPLICATE: "potential-duplicate",
1306
- /**
1307
- * This flag is set by the Edit-action and removed after the declaration or registration.
1308
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1309
- *
1310
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1311
- */
1312
- EDIT_IN_PROGRESS: "edit-in-progress"
1313
- };
1314
- var ActionFlag = z15.string().regex(
1315
- new RegExp(
1316
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1317
- ActionStatus
1318
- ).join("|").toLowerCase()})$`
1319
- ),
1320
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1321
- );
1322
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1323
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1324
- InherentFlags
1325
- ).join(", ")}`
1326
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1327
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1328
- }).describe("Custom flag identifier defined by the country config.");
1329
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1330
- var FlagConfig = z15.object({
1331
- id: CustomFlag,
1332
- requiresAction: z15.boolean().describe(
1333
- "Indicates if this flag expects an action to be performed to be cleared."
1334
- ),
1335
- label: TranslationConfig.describe("Human readable label of the flag.")
1336
- }).meta({
1337
- id: "FlagConfig",
1338
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1339
- });
1340
- var ActionFlagConfig = z15.object({
1341
- id: Flag,
1342
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1343
- conditional: Conditional.optional().describe(
1344
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1345
- )
1346
- }).meta({
1347
- id: "ActionFlagConfig",
1348
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1349
- });
1457
+ var Action = z15.union([ActionDocument, AsyncRejectActionDocument]);
1350
1458
 
1351
1459
  // ../commons/src/events/EventMetadata.ts
1352
1460
  var EventStatus = z16.enum([
@@ -1504,13 +1612,6 @@ var Range = import_v4.z.object({
1504
1612
  }).meta({
1505
1613
  id: "Range"
1506
1614
  });
1507
- var ContainsFlags = import_v4.z.object({
1508
- anyOf: import_v4.z.array(Flag).optional(),
1509
- noneOf: import_v4.z.array(Flag).optional(),
1510
- allOf: import_v4.z.array(Flag).optional()
1511
- }).meta({
1512
- id: "ContainsFlags"
1513
- });
1514
1615
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1515
1616
  id: "Within"
1516
1617
  });
@@ -1737,8 +1838,8 @@ var BaseField = import_v43.default.object({
1737
1838
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1738
1839
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1739
1840
  ),
1740
- secured: import_v43.default.boolean().default(false).optional().describe(
1741
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1841
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1842
+ "Indicates whether the field is secured, either always (boolean) or conditionally, evaluated against the event (a JSONSchema conditional, e.g. flag('sealed')). Secured fields are not indexed for search and are only visible when explicitly assigned."
1742
1843
  ),
1743
1844
  placeholder: TranslationConfig.optional(),
1744
1845
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2136,7 +2237,13 @@ var AdministrativeAreaField = BaseField.extend({
2136
2237
  configuration: import_v43.default.object({
2137
2238
  partOf: FieldReference.optional().describe("Parent location"),
2138
2239
  type: AdministrativeAreas,
2139
- allowedLocations: AllowedLocations
2240
+ allowedLocations: AllowedLocations,
2241
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2242
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
2243
+ ),
2244
+ activeOnly: import_v43.default.boolean().optional().describe(
2245
+ "Advanced search: offer only currently-active locations; inactivated ones are excluded."
2246
+ )
2140
2247
  }).describe("Administrative area options")
2141
2248
  }).meta({
2142
2249
  description: "Administrative area input field",
@@ -2147,7 +2254,10 @@ var LocationInput = BaseField.extend({
2147
2254
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2148
2255
  configuration: import_v43.default.object({
2149
2256
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2150
- allowedLocations: AllowedLocations
2257
+ allowedLocations: AllowedLocations,
2258
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2259
+ "Advanced search: list every historical name a location has had as a separate, selectable option."
2260
+ )
2151
2261
  }).optional()
2152
2262
  }).meta({
2153
2263
  description: "A field for selecting a location",
@@ -2173,12 +2283,18 @@ var FileUploadWithOptions = BaseField.extend({
2173
2283
  var Facility = BaseField.extend({
2174
2284
  type: import_v43.default.literal(FieldType.FACILITY),
2175
2285
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2176
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2286
+ configuration: import_v43.default.object({
2287
+ allowedLocations: AllowedLocations,
2288
+ listHistoricalNames: import_v43.default.boolean().optional()
2289
+ }).optional()
2177
2290
  }).describe("Input field for a facility");
2178
2291
  var Office = BaseField.extend({
2179
2292
  type: import_v43.default.literal(FieldType.OFFICE),
2180
2293
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2181
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2294
+ configuration: import_v43.default.object({
2295
+ allowedLocations: AllowedLocations,
2296
+ listHistoricalNames: import_v43.default.boolean().optional()
2297
+ }).optional()
2182
2298
  }).describe("Input field for an office");
2183
2299
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2184
2300
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2211,7 +2327,13 @@ var Address = BaseField.extend({
2211
2327
  parent: FieldReference.optional()
2212
2328
  })
2213
2329
  ).optional(),
2214
- allowedLocations: AllowedLocations
2330
+ allowedLocations: AllowedLocations,
2331
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2332
+ "Advanced search: list every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2333
+ ),
2334
+ activeOnly: import_v43.default.boolean().optional().describe(
2335
+ "Advanced search: offer only currently-active admin areas; inactivated ones are excluded. Propagated to the embedded admin-area selectors."
2336
+ )
2215
2337
  }).optional(),
2216
2338
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2217
2339
  }).meta({
@@ -2694,6 +2816,9 @@ var ActionConfigBase = z24.object({
2694
2816
  var DeclarationActionBase = ActionConfigBase.extend({
2695
2817
  deduplication: DeduplicationConfig.optional()
2696
2818
  });
2819
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2820
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2821
+ );
2697
2822
  var ReadActionConfig = ActionConfigBase.extend(
2698
2823
  z24.object({
2699
2824
  type: z24.literal(ActionType.READ),
@@ -2705,7 +2830,8 @@ var ReadActionConfig = ActionConfigBase.extend(
2705
2830
  );
2706
2831
  var NotifyConfig = ActionConfigBase.extend(
2707
2832
  z24.object({
2708
- type: z24.literal(ActionType.NOTIFY)
2833
+ type: z24.literal(ActionType.NOTIFY),
2834
+ form: actionConfirmationForm
2709
2835
  }).shape
2710
2836
  );
2711
2837
  var DuplicateDetectedConfig = ActionConfigBase.extend(
@@ -2760,6 +2886,7 @@ var DeclareConfig = DeclarationActionBase.extend(
2760
2886
  review: DeclarationReviewConfig.describe(
2761
2887
  "Configuration of the review page fields."
2762
2888
  ),
2889
+ form: actionConfirmationForm,
2763
2890
  dialogCopy: z24.object({
2764
2891
  notify: TranslationConfig.describe(
2765
2892
  "Confirmation text for the notify action"
@@ -2775,7 +2902,8 @@ var DeclareConfig = DeclarationActionBase.extend(
2775
2902
  );
2776
2903
  var ArchiveConfig = ActionConfigBase.extend(
2777
2904
  z24.object({
2778
- type: z24.literal(ActionType.ARCHIVE)
2905
+ type: z24.literal(ActionType.ARCHIVE),
2906
+ form: actionConfirmationForm
2779
2907
  }).shape
2780
2908
  );
2781
2909
  var UnarchiveConfig = ActionConfigBase.extend(
@@ -2801,12 +2929,14 @@ var EditActionConfig = ActionConfigBase.extend(
2801
2929
  );
2802
2930
  var RejectConfig = ActionConfigBase.extend(
2803
2931
  z24.object({
2804
- type: z24.literal(ActionType.REJECT)
2932
+ type: z24.literal(ActionType.REJECT),
2933
+ form: actionConfirmationForm
2805
2934
  }).shape
2806
2935
  );
2807
2936
  var RegisterConfig = DeclarationActionBase.extend(
2808
2937
  z24.object({
2809
- type: z24.literal(ActionType.REGISTER)
2938
+ type: z24.literal(ActionType.REGISTER),
2939
+ form: actionConfirmationForm
2810
2940
  }).shape
2811
2941
  );
2812
2942
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -2975,59 +3105,195 @@ var LanguageConfig = z26.object({
2975
3105
  });
2976
3106
 
2977
3107
  // ../commons/src/events/EventConfig.ts
2978
- var z33 = __toESM(require("zod/v4"));
3108
+ var z34 = __toESM(require("zod/v4"));
2979
3109
 
2980
3110
  // ../commons/src/events/SummaryConfig.ts
2981
- var z27 = __toESM(require("zod/v4"));
2982
- var BaseField2 = z27.object({
2983
- emptyValueMessage: TranslationConfig.optional().describe(
2984
- "Default message displayed when the field value is empty."
2985
- ),
2986
- conditionals: z27.array(ShowConditional).default([]).optional()
2987
- });
2988
- var ReferenceField = BaseField2.extend({
2989
- fieldId: z27.string(),
2990
- label: TranslationConfig.optional().describe(
2991
- "Overrides the default label from the referenced field when provided."
2992
- )
2993
- }).describe("Field referencing existing event data by field ID.");
2994
- var Field = BaseField2.extend({
2995
- id: z27.string().describe("Identifier of the summary field."),
2996
- value: TranslationConfig.describe(
2997
- 'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
2998
- ),
2999
- label: TranslationConfig
3000
- }).describe("Custom field defined for the summary view.");
3001
- var SummaryConfig = z27.object({
3002
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3003
- }).meta({
3004
- id: "SummaryConfig",
3005
- description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3006
- });
3007
-
3008
- // ../commons/src/events/AdvancedSearchConfig.ts
3009
3111
  var z28 = __toESM(require("zod/v4"));
3010
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
3011
- var BaseField3 = z28.object({
3012
- config: z28.object({
3013
- type: MatchType.describe(
3014
- "Determines the search type of field. How to match value."
3015
- ),
3016
- searchFields: z28.array(z28.string()).optional().describe(
3017
- `
3018
- Defines multiple form fields that should be searched when this field has a value.
3019
- All specified fields will be combined using OR logic.
3020
3112
 
3021
- Example: { searchFields: ['mother.name', 'father.name', 'informant.name'] }
3022
- Will search all fields and return a record if any of the fields match the search value.
3023
- `
3024
- )
3025
- }),
3026
- type: z28.nativeEnum(FieldType).optional().describe(
3027
- `
3028
- Explicitly specify the field type for searchFields.
3029
- This is required when searchFields is defined, to show the correct control in the UI.
3030
-
3113
+ // ../commons/src/icons.ts
3114
+ var z27 = __toESM(require("zod/v4"));
3115
+ var AvailableIcons = z27.enum([
3116
+ "Archived",
3117
+ "Assigned",
3118
+ "Briefcase",
3119
+ "Certified",
3120
+ "Close",
3121
+ "Collapse",
3122
+ "Draft",
3123
+ "DuplicateYellow",
3124
+ "Expand",
3125
+ "ExternalValidate",
3126
+ "FilledCheck",
3127
+ "InReview",
3128
+ "Offline",
3129
+ "Registered",
3130
+ "RequiresUpdates",
3131
+ "Sent",
3132
+ "Validated",
3133
+ "WaitingApproval",
3134
+ "ChartActivity",
3135
+ "Activity",
3136
+ "Archive",
3137
+ "ArchiveTray",
3138
+ "ArrowLeft",
3139
+ "ArrowRight",
3140
+ "Buildings",
3141
+ "Circle",
3142
+ "CaretDown",
3143
+ "CaretLeft",
3144
+ "CaretRight",
3145
+ "ChartBar",
3146
+ "ChartLine",
3147
+ "ChatCircle",
3148
+ "CheckSquare",
3149
+ "Compass",
3150
+ "Check",
3151
+ "Copy",
3152
+ "Database",
3153
+ "DotsThreeVertical",
3154
+ "ArrowCounterClockwise",
3155
+ "MagnifyingGlassMinus",
3156
+ "MagnifyingGlassPlus",
3157
+ "Export",
3158
+ "Eye",
3159
+ "EyeSlash",
3160
+ "Envelope",
3161
+ "File",
3162
+ "FileLock",
3163
+ "FileSearch",
3164
+ "FileMinus",
3165
+ "FilePlus",
3166
+ "FileText",
3167
+ "FileX",
3168
+ "Handshake",
3169
+ "Gear",
3170
+ "GitBranch",
3171
+ "IdentificationCard",
3172
+ "List",
3173
+ "ListBullets",
3174
+ "Lock",
3175
+ "MagnifyingGlass",
3176
+ "MapPin",
3177
+ "Medal",
3178
+ "NotePencil",
3179
+ "Paperclip",
3180
+ "PaperPlaneTilt",
3181
+ "Pen",
3182
+ "PenNib",
3183
+ "Pencil",
3184
+ "PencilSimpleLine",
3185
+ "Phone",
3186
+ "Plus",
3187
+ "Printer",
3188
+ "SignOut",
3189
+ "Stamp",
3190
+ "Star",
3191
+ "Target",
3192
+ "TextT",
3193
+ "Trash",
3194
+ "UploadSimple",
3195
+ "User",
3196
+ "UserPlus",
3197
+ "Users",
3198
+ "WarningCircle",
3199
+ "X",
3200
+ "ChatText",
3201
+ "CircleWavyCheck",
3202
+ "CircleWavyQuestion",
3203
+ "ArchiveBox",
3204
+ "ArrowCircleDown",
3205
+ "FileArrowUp",
3206
+ "FileDotted",
3207
+ "Files",
3208
+ "PencilLine",
3209
+ "PencilCircle",
3210
+ "UserCircle",
3211
+ "Clock",
3212
+ "QrCode",
3213
+ "Webcam",
3214
+ "Sun",
3215
+ "DeviceTabletCamera",
3216
+ "Globe",
3217
+ "Fingerprint",
3218
+ "PushPin",
3219
+ "Timer"
3220
+ ]);
3221
+
3222
+ // ../commons/src/events/SummaryConfig.ts
3223
+ var InfoBox = z28.object({
3224
+ type: z28.enum(["info", "positive", "warning", "negative"]).describe(
3225
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3226
+ ),
3227
+ background: z28.enum(["tinted", "white"]).default("tinted").optional().describe(
3228
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3229
+ ),
3230
+ icon: AvailableIcons.optional().describe(
3231
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3232
+ ),
3233
+ heading: TranslationConfig.describe(
3234
+ "Primary message. Short, sentence-case."
3235
+ ),
3236
+ description: TranslationConfig.optional().describe(
3237
+ "Secondary copy displayed below the heading, typically a suggested next step."
3238
+ ),
3239
+ conditionals: z28.array(ShowConditional).default([]).optional().describe(
3240
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3241
+ )
3242
+ }).describe(
3243
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3244
+ );
3245
+ var BaseField2 = z28.object({
3246
+ emptyValueMessage: TranslationConfig.optional().describe(
3247
+ "Default message displayed when the field value is empty."
3248
+ ),
3249
+ conditionals: z28.array(ShowConditional).default([]).optional()
3250
+ });
3251
+ var ReferenceField = BaseField2.extend({
3252
+ fieldId: z28.string(),
3253
+ label: TranslationConfig.optional().describe(
3254
+ "Overrides the default label from the referenced field when provided."
3255
+ )
3256
+ }).describe("Field referencing existing event data by field ID.");
3257
+ var Field = BaseField2.extend({
3258
+ id: z28.string().describe("Identifier of the summary field."),
3259
+ value: TranslationConfig.describe(
3260
+ 'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
3261
+ ),
3262
+ label: TranslationConfig
3263
+ }).describe("Custom field defined for the summary view.");
3264
+ var SummaryConfig = z28.object({
3265
+ banners: z28.array(InfoBox).default([]).optional().describe(
3266
+ "Info boxes displayed above the summary fields in the event overview."
3267
+ ),
3268
+ fields: z28.array(z28.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3269
+ }).meta({
3270
+ id: "SummaryConfig",
3271
+ description: "Configuration of the event overview page. Defines which declaration fields appear in the record summary, optionally with custom labels, empty-value messages, and templated values."
3272
+ });
3273
+
3274
+ // ../commons/src/events/AdvancedSearchConfig.ts
3275
+ var z29 = __toESM(require("zod/v4"));
3276
+ var MatchType = z29.enum(["fuzzy", "exact", "range", "within"]);
3277
+ var BaseField3 = z29.object({
3278
+ config: z29.object({
3279
+ type: MatchType.describe(
3280
+ "Determines the search type of field. How to match value."
3281
+ ),
3282
+ searchFields: z29.array(z29.string()).optional().describe(
3283
+ `
3284
+ Defines multiple form fields that should be searched when this field has a value.
3285
+ All specified fields will be combined using OR logic.
3286
+
3287
+ Example: { searchFields: ['mother.name', 'father.name', 'informant.name'] }
3288
+ Will search all fields and return a record if any of the fields match the search value.
3289
+ `
3290
+ )
3291
+ }),
3292
+ type: z29.nativeEnum(FieldType).optional().describe(
3293
+ `
3294
+ Explicitly specify the field type for searchFields.
3295
+ This is required when searchFields is defined, to show the correct control in the UI.
3296
+
3031
3297
  Example: FieldType.NAME for name fields, FieldType.TEXT for text fields, FieldType.DATE for date fields, etc.
3032
3298
  `
3033
3299
  ),
@@ -3037,7 +3303,7 @@ var BaseField3 = z28.object({
3037
3303
  This is required when searchFields is defined.
3038
3304
  `
3039
3305
  ),
3040
- options: z28.array(SelectOption).optional(),
3306
+ options: z29.array(SelectOption).optional(),
3041
3307
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
3042
3308
  `
3043
3309
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -3058,7 +3324,7 @@ var BaseField3 = z28.object({
3058
3324
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
3059
3325
  `
3060
3326
  ),
3061
- conditionals: z28.array(FieldConditional).optional().describe(
3327
+ conditionals: z29.array(FieldConditional).optional().describe(
3062
3328
  `
3063
3329
  In advanced search, we sometimes need to override the default field visibility conditionals.
3064
3330
 
@@ -3072,23 +3338,23 @@ var BaseField3 = z28.object({
3072
3338
  are always rendered in the advanced search form.
3073
3339
  `
3074
3340
  ),
3075
- validations: z28.array(ValidationConfig).optional().describe(
3341
+ validations: z29.array(ValidationConfig).optional().describe(
3076
3342
  `Option for overriding the field validations specifically for advanced search form.`
3077
3343
  ),
3078
3344
  allowedLocations: JurisdictionReference.optional().describe(
3079
3345
  `Override the allowedLocations for a location field in advanced search. Use this when the declaration form's allowedLocations references a scope (e.g. record.create) that search-only users don't have \u2014 specify record.search scope instead.`
3080
3346
  )
3081
3347
  });
3082
- var SearchQueryParams = z28.object({
3083
- eventType: z28.string().optional().describe(
3348
+ var SearchQueryParams = z29.object({
3349
+ eventType: z29.string().optional().describe(
3084
3350
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
3085
3351
  )
3086
3352
  }).catchall(FieldValue);
3087
3353
  var FieldConfigSchema = BaseField3.extend({
3088
- fieldId: z28.string(),
3089
- fieldType: z28.literal("field")
3354
+ fieldId: z29.string(),
3355
+ fieldType: z29.literal("field")
3090
3356
  });
3091
- var EventFieldIdInput = z28.enum([
3357
+ var EventFieldIdInput = z29.enum([
3092
3358
  "trackingId",
3093
3359
  "status",
3094
3360
  "legalStatuses.REGISTERED.acceptedAt",
@@ -3097,7 +3363,7 @@ var EventFieldIdInput = z28.enum([
3097
3363
  "updatedAt"
3098
3364
  ]);
3099
3365
  var METADATA_FIELD_PREFIX = "event.";
3100
- var EventFieldId = z28.enum([
3366
+ var EventFieldId = z29.enum([
3101
3367
  `${METADATA_FIELD_PREFIX}trackingId`,
3102
3368
  `${METADATA_FIELD_PREFIX}status`,
3103
3369
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -3107,190 +3373,64 @@ var EventFieldId = z28.enum([
3107
3373
  ]);
3108
3374
  var EventFieldConfigSchema = BaseField3.extend({
3109
3375
  fieldId: EventFieldId,
3110
- fieldType: z28.literal("event")
3376
+ fieldType: z29.literal("event")
3111
3377
  });
3112
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3378
+ var AdvancedSearchField = z29.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3113
3379
  if (data.config.searchFields && data.config.searchFields.length > 0) {
3114
3380
  if (!data.label) {
3115
3381
  ctx.addIssue({
3116
- code: z28.ZodIssueCode.custom,
3382
+ code: z29.ZodIssueCode.custom,
3117
3383
  message: "label is required when config.searchFields is defined.",
3118
3384
  path: ["label"]
3119
3385
  });
3120
3386
  }
3121
3387
  if (!data.type) {
3122
3388
  ctx.addIssue({
3123
- code: z28.ZodIssueCode.custom,
3389
+ code: z29.ZodIssueCode.custom,
3124
3390
  message: "type is required when config.searchFields is defined.",
3125
3391
  path: ["type"]
3126
3392
  });
3127
3393
  }
3128
3394
  }
3129
3395
  });
3130
- var AdvancedSearchConfig = z28.object({
3396
+ var AdvancedSearchConfig = z29.object({
3131
3397
  title: TranslationConfig.describe("Advanced search tab title"),
3132
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3398
+ fields: z29.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3133
3399
  }).meta({
3134
3400
  id: "AdvancedSearchConfig",
3135
3401
  description: "Configuration of one advanced search tab. Each tab has a title and a list of searchable fields \u2014 either declaration fields (via `field()`) or event metadata (via `event()`)."
3136
3402
  });
3137
3403
 
3138
3404
  // ../commons/src/events/utils.ts
3139
- var import_lodash = require("lodash");
3405
+ var import_lodash4 = require("lodash");
3140
3406
 
3141
3407
  // ../commons/src/conditionals/validate.ts
3142
3408
  var import__ = __toESM(require("ajv/dist/2019"));
3143
3409
  var import_ajv_formats = __toESM(require("ajv-formats"));
3144
- var z31 = __toESM(require("zod/v4"));
3145
- var import_date_fns = require("date-fns");
3410
+ var z33 = __toESM(require("zod/v4"));
3411
+ var import_date_fns2 = require("date-fns");
3146
3412
 
3147
3413
  // ../commons/src/events/FieldTypeMapping.ts
3148
- var z30 = __toESM(require("zod/v4"));
3414
+ var z31 = __toESM(require("zod/v4"));
3149
3415
 
3150
3416
  // ../commons/src/events/DynamicFieldValue.ts
3151
- var z29 = __toESM(require("zod/v4"));
3417
+ var z30 = __toESM(require("zod/v4"));
3152
3418
 
3153
- // ../commons/src/conditionals/validate.ts
3154
- var ajv = new import__.default({
3155
- $data: true,
3156
- allowUnionTypes: true,
3157
- strict: false
3158
- // Allow minContains and other newer features
3159
- });
3160
- var DataContext = z31.object({
3161
- rootData: z31.object({
3162
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3163
- })
3164
- });
3165
- function resolveDataPath(rootData, dataPath, instancePath) {
3166
- const pathParts = dataPath.split("/");
3167
- const levels = parseInt(pathParts[0], 10);
3168
- const referencePath = pathParts.slice(1);
3169
- const instanceParts = instancePath.split("/").filter(Boolean);
3170
- const traversedParts = instanceParts.slice(0, -levels);
3171
- let current = rootData;
3172
- for (const part of traversedParts) {
3173
- if (current === null || current === void 0) {
3174
- return void 0;
3175
- }
3176
- current = current[part];
3177
- }
3178
- for (const part of referencePath) {
3179
- if (current === null || current === void 0) {
3180
- return void 0;
3181
- }
3182
- current = current[part];
3183
- }
3184
- return current;
3185
- }
3186
- function todayISO() {
3187
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3188
- }
3189
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3190
- function compileClientFunction(code) {
3191
- let fn = compiledFunctionCache.get(code);
3192
- if (!fn) {
3193
- fn = new Function(`return (${code})`)();
3194
- compiledFunctionCache.set(code, fn);
3195
- }
3196
- return fn;
3197
- }
3198
- (0, import_ajv_formats.default)(ajv);
3199
- function buildClientFunctionContext(input) {
3200
- return {
3201
- $form: input.form,
3202
- $now: todayISO(),
3203
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3204
- $online: isOnline(),
3205
- $user: input.validatorContext?.user,
3206
- $event: input.validatorContext?.event,
3207
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3208
- user: input.systemVariables?.user,
3209
- $window: input.systemVariables?.$window,
3210
- locations: input.locations,
3211
- adminLevelIds: input.adminLevelIds
3212
- };
3213
- }
3214
- function runClientFunction(code, data, context) {
3215
- return compileClientFunction(code)(data, context);
3216
- }
3217
- ajv.addKeyword({
3218
- keyword: "daysFromDate",
3219
- type: "string",
3220
- schemaType: "object",
3221
- $data: true,
3222
- errors: true,
3223
- validate(schema, data, _2, dataContext) {
3224
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3225
- throw new Error("Validation context must contain $now");
3226
- }
3227
- const { days, clause } = schema;
3228
- if (typeof data !== "string") {
3229
- return false;
3230
- }
3231
- const date = new Date(data);
3232
- if (isNaN(date.getTime())) {
3233
- return false;
3234
- }
3235
- let referenceDate = schema.referenceDate;
3236
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3237
- referenceDate = resolveDataPath(
3238
- dataContext.rootData,
3239
- referenceDate.$data,
3240
- dataContext.instancePath
3241
- );
3242
- }
3243
- if (!referenceDate) {
3244
- referenceDate = dataContext.rootData.$now;
3245
- }
3246
- const baseDate = new Date(referenceDate);
3247
- if (isNaN(baseDate.getTime())) {
3248
- return false;
3249
- }
3250
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3251
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3252
- }
3253
- });
3254
- ajv.addKeyword({
3255
- keyword: "isLeafLevelLocation",
3256
- type: "string",
3257
- schemaType: "boolean",
3258
- $data: true,
3259
- errors: true,
3260
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3261
- validate(_schema, data, _2, dataContext) {
3262
- const locationIdInput = data;
3263
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3264
- return locations.some((location) => location.id === locationIdInput);
3265
- }
3266
- });
3267
- ajv.addKeyword({
3268
- keyword: "customClientValidator",
3269
- schemaType: "object",
3270
- errors: true,
3271
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3272
- // `validate()` callers build root data via `buildClientFunctionContext`,
3273
- // so the cast holds.
3274
- validate(schema, data, _2, dataContext) {
3275
- return Boolean(
3276
- runClientFunction(
3277
- schema.code,
3278
- data,
3279
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3280
- )
3281
- );
3282
- }
3283
- });
3284
- function isOnline() {
3285
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3286
- return navigator.onLine;
3287
- }
3288
- return true;
3289
- }
3419
+ // ../commons/src/events/state/index.ts
3420
+ var import_lodash3 = require("lodash");
3290
3421
 
3291
3422
  // ../commons/src/utils.ts
3292
3423
  var z32 = __toESM(require("zod/v4"));
3293
3424
  var _ = __toESM(require("lodash"));
3425
+ function getOrThrow(x, message) {
3426
+ if (x === void 0 || x === null) {
3427
+ throw new Error(message);
3428
+ }
3429
+ return x;
3430
+ }
3431
+ function joinValues(values, separator = " ") {
3432
+ return values.filter((value) => !!value).join(separator).trim();
3433
+ }
3294
3434
  var FullNameV1 = z32.array(
3295
3435
  z32.object({
3296
3436
  use: z32.string(),
@@ -3314,40 +3454,262 @@ function omitKeyDeep(obj, keyToRemove) {
3314
3454
  return newObj;
3315
3455
  }
3316
3456
 
3317
- // ../commons/src/events/utils.ts
3318
- var import_date_fns2 = require("date-fns");
3319
- function getDeclarationFields(configuration) {
3320
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3457
+ // ../commons/src/events/state/utils.ts
3458
+ var import_lodash = require("lodash");
3459
+ function getActionRequests(actionType, actions) {
3460
+ const filtered = actions.filter((action) => action.type === actionType).reverse();
3461
+ const accept = filtered.find(
3462
+ (action) => action.status === ActionStatus.Accepted
3463
+ );
3464
+ const request = filtered.find(
3465
+ (action) => action.status === ActionStatus.Requested
3466
+ );
3467
+ const reject = filtered.find(
3468
+ (action) => action.status === ActionStatus.Rejected
3469
+ );
3470
+ return {
3471
+ reject,
3472
+ accept,
3473
+ request
3474
+ };
3475
+ }
3476
+ function getDeclarationActionCreationMetadata(actionType, actions) {
3477
+ const { accept: acceptAction, request: requestAction } = getActionRequests(
3478
+ actionType,
3479
+ actions
3480
+ );
3481
+ if (!acceptAction) {
3482
+ return null;
3483
+ }
3484
+ const registrationNumber = acceptAction.type === ActionType.REGISTER ? acceptAction.registrationNumber : null;
3485
+ return {
3486
+ // When 3rd party API returns 200 OK, we assume that the request was accepted, and persist single 'accepted' action.
3487
+ createdAt: requestAction?.createdAt ?? acceptAction.createdAt,
3488
+ createdBy: requestAction?.createdBy ?? acceptAction.createdBy,
3489
+ createdByUserType: requestAction?.createdByUserType ?? acceptAction.createdByUserType,
3490
+ createdAtLocation: requestAction?.createdAtLocation ?? acceptAction.createdAtLocation,
3491
+ acceptedAt: acceptAction.createdAt,
3492
+ createdByRole: requestAction?.createdByRole ?? acceptAction.createdByRole,
3493
+ registrationNumber
3494
+ };
3495
+ }
3496
+ var updateActions = ActionTypes.extract([
3497
+ ActionType.CREATE,
3498
+ ActionType.NOTIFY,
3499
+ ActionType.EDIT,
3500
+ ActionType.DECLARE,
3501
+ ActionType.REGISTER,
3502
+ ActionType.REJECT,
3503
+ ActionType.ARCHIVE,
3504
+ ActionType.UNARCHIVE,
3505
+ ActionType.PRINT_CERTIFICATE,
3506
+ ActionType.REQUEST_CORRECTION,
3507
+ ActionType.APPROVE_CORRECTION,
3508
+ ActionType.REJECT_CORRECTION,
3509
+ ActionType.CUSTOM
3510
+ ]);
3511
+ function getActionUpdateMetadata(actions) {
3512
+ const createAction = getOrThrow(
3513
+ actions.find((action) => action.type === ActionType.CREATE),
3514
+ `Event has no ${ActionType.CREATE} action`
3515
+ );
3516
+ const metadataFields = [
3517
+ "createdAt",
3518
+ "createdBy",
3519
+ "createdByUserType",
3520
+ "createdAtLocation",
3521
+ "createdByRole"
3522
+ ];
3523
+ return actions.filter(({ type }) => updateActions.safeParse(type).success).reduce(
3524
+ (_2, action) => {
3525
+ if (action.originalActionId) {
3526
+ const originalAction = actions.find(({ id }) => id === action.originalActionId) ?? action;
3527
+ return (0, import_lodash.pick)(originalAction, metadataFields);
3528
+ }
3529
+ return (0, import_lodash.pick)(action, metadataFields);
3530
+ },
3531
+ (0, import_lodash.pick)(createAction, metadataFields)
3532
+ );
3533
+ }
3534
+ function getLegalStatuses(actions) {
3535
+ return {
3536
+ [EventStatus.enum.NOTIFIED]: getDeclarationActionCreationMetadata(
3537
+ ActionType.NOTIFY,
3538
+ actions
3539
+ ),
3540
+ [EventStatus.enum.DECLARED]: getDeclarationActionCreationMetadata(
3541
+ ActionType.DECLARE,
3542
+ actions
3543
+ ),
3544
+ [EventStatus.enum.REGISTERED]: getDeclarationActionCreationMetadata(
3545
+ ActionType.REGISTER,
3546
+ actions
3547
+ )
3548
+ };
3549
+ }
3550
+
3551
+ // ../commons/src/events/state/flags.ts
3552
+ var import_lodash2 = require("lodash");
3553
+ var import_date_fns = require("date-fns");
3554
+ function isFlagConditionMet(conditional, form, action) {
3555
+ 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" });
3556
+ return validate(conditional, {
3557
+ $form: form,
3558
+ $now: now2,
3559
+ $online: true,
3560
+ $user: {
3561
+ sub: "",
3562
+ exp: "",
3563
+ role: action.createdByRole,
3564
+ algorithm: "",
3565
+ scope: [],
3566
+ userType: action.createdByUserType
3567
+ }
3568
+ });
3569
+ }
3570
+ function actionConfigRemovesFlag(action, flagId, actionsUpToAndIncluding, event2, eventConfiguration) {
3571
+ if (!isActionConfigType(action.type)) {
3572
+ return false;
3573
+ }
3574
+ const actionConfig = getActionConfig({
3575
+ eventConfiguration,
3576
+ actionType: action.type,
3577
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3578
+ });
3579
+ const removeOperations = (actionConfig?.flags ?? []).filter(
3580
+ ({ id, operation }) => id === flagId && operation === "remove"
3581
+ );
3582
+ if (removeOperations.length === 0) {
3583
+ return false;
3584
+ }
3585
+ const eventUpToThisAction = { ...event2, actions: actionsUpToAndIncluding };
3586
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3587
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3588
+ const form = { ...declaration, ...annotation };
3589
+ return removeOperations.some(
3590
+ ({ conditional }) => conditional ? isFlagConditionMet(conditional, form, action) : true
3591
+ );
3592
+ }
3593
+ var INHERENT_FLAG_RULES = [
3594
+ {
3595
+ flag: InherentFlags.CORRECTION_REQUESTED,
3596
+ setOn: [ActionType.REQUEST_CORRECTION],
3597
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3598
+ },
3599
+ {
3600
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3601
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3602
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3603
+ // round trip and comes back exactly as it was.
3604
+ flag: InherentFlags.INCOMPLETE,
3605
+ setOn: [ActionType.NOTIFY],
3606
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3607
+ },
3608
+ {
3609
+ flag: InherentFlags.REJECTED,
3610
+ setOn: [ActionType.REJECT],
3611
+ resetOn: [
3612
+ ActionType.NOTIFY,
3613
+ ActionType.DECLARE,
3614
+ ActionType.EDIT,
3615
+ ActionType.REGISTER
3616
+ ]
3617
+ },
3618
+ {
3619
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3620
+ setOn: [ActionType.DUPLICATE_DETECTED],
3621
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3622
+ },
3623
+ {
3624
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3625
+ setOn: [ActionType.EDIT],
3626
+ resetOnAnyOtherAction: true
3627
+ }
3628
+ ];
3629
+ function resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration) {
3630
+ return acceptedActions.reduce((present, action, idx) => {
3631
+ if (rule.setOn.includes(action.type)) {
3632
+ return true;
3633
+ }
3634
+ if (rule.resetOnAnyOtherAction || (rule.resetOn ?? []).includes(action.type)) {
3635
+ return false;
3636
+ }
3637
+ if (actionConfigRemovesFlag(
3638
+ action,
3639
+ rule.flag,
3640
+ acceptedActions.slice(0, idx + 1),
3641
+ event2,
3642
+ eventConfiguration
3643
+ )) {
3644
+ return false;
3645
+ }
3646
+ return present;
3647
+ }, false);
3648
+ }
3649
+ function resolveEventCustomFlags(event2, eventConfiguration) {
3650
+ const actions = getAcceptedActions(event2).filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3651
+ return actions.reduce((acc, action, idx) => {
3652
+ let actionConfig;
3653
+ if (isActionConfigType(action.type)) {
3654
+ actionConfig = getActionConfig({
3655
+ eventConfiguration,
3656
+ actionType: action.type,
3657
+ customActionType: "customActionType" in action ? action.customActionType : void 0
3658
+ });
3659
+ }
3660
+ if (!actionConfig) {
3661
+ return acc;
3662
+ }
3663
+ const eventUpToThisAction = {
3664
+ ...event2,
3665
+ actions: actions.slice(0, idx + 1)
3666
+ };
3667
+ const declaration = aggregateActionDeclarations(eventUpToThisAction);
3668
+ const annotation = aggregateActionAnnotations(eventUpToThisAction);
3669
+ const form = { ...declaration, ...annotation };
3670
+ const flagsWithMetConditions = (actionConfig.flags ?? []).filter(
3671
+ ({ conditional }) => (
3672
+ // If conditional is not provided, the flag is resolved
3673
+ conditional ? isFlagConditionMet(conditional, form, action) : true
3674
+ )
3675
+ );
3676
+ const addedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "add").map(({ id }) => id);
3677
+ const removedFlags = flagsWithMetConditions.filter(({ operation }) => operation === "remove").map(({ id }) => id);
3678
+ const flags = [...acc, ...addedFlags].filter(
3679
+ (flagId) => !removedFlags.includes(flagId)
3680
+ );
3681
+ return (0, import_lodash2.uniq)(flags);
3682
+ }, []);
3683
+ }
3684
+ function getActionStatusFlags(sortedActions) {
3685
+ const actionStatus = sortedActions.reduce(
3686
+ (actionStatuses, { type, status: status2 }) => ({
3687
+ ...actionStatuses,
3688
+ [type]: status2
3689
+ }),
3690
+ {}
3691
+ );
3692
+ return Object.entries(actionStatus).filter(([, status2]) => status2 !== ActionStatus.Accepted).map(([type, status2]) => {
3693
+ const flag2 = joinValues([type, status2], ":").toLowerCase();
3694
+ return flag2;
3695
+ });
3321
3696
  }
3322
- var getActionAnnotationFields = (actionConfig) => {
3323
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3324
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3325
- }
3326
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3327
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3328
- }
3329
- if (actionConfig.type === ActionType.CUSTOM) {
3330
- return actionConfig.form;
3331
- }
3332
- if ("review" in actionConfig && actionConfig.review != null) {
3333
- return actionConfig.review.fields;
3334
- }
3335
- return [];
3336
- };
3337
- function getAllAnnotationFields(config) {
3338
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3697
+ function getInherentFlags(sortedActions, event2, eventConfiguration) {
3698
+ const acceptedActions = sortedActions.filter(
3699
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
3700
+ );
3701
+ return INHERENT_FLAG_RULES.filter(
3702
+ (rule) => resolveInherentFlag(rule, acceptedActions, event2, eventConfiguration)
3703
+ ).map(({ flag: flag2 }) => flag2);
3704
+ }
3705
+ function getEventFlags(event2, config) {
3706
+ const sortedActions = event2.actions.filter(({ type }) => !isMetaAction(type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
3707
+ return [
3708
+ ...getActionStatusFlags(sortedActions),
3709
+ ...getInherentFlags(sortedActions, event2, config),
3710
+ ...resolveEventCustomFlags(event2, config)
3711
+ ];
3339
3712
  }
3340
- var findAllFields = (config) => {
3341
- return (0, import_lodash.flattenDeep)([
3342
- ...getDeclarationFields(config),
3343
- ...getAllAnnotationFields(config)
3344
- ]);
3345
- };
3346
- var EXCLUDED_ACTIONS = [
3347
- ActionType.REQUEST_CORRECTION,
3348
- ActionType.PRINT_CERTIFICATE,
3349
- ActionType.REJECT_CORRECTION
3350
- ];
3351
3713
 
3352
3714
  // ../commons/src/conditionals/conditionals.ts
3353
3715
  var objectHash = __toESM(require("object-hash"));
@@ -3555,6 +3917,33 @@ function defineComparison(field3, value, keyword) {
3555
3917
  required: [field3.$$field]
3556
3918
  });
3557
3919
  }
3920
+ function flag(flagvalue) {
3921
+ return defineConditional({
3922
+ type: "object",
3923
+ properties: {
3924
+ $flags: {
3925
+ type: "array",
3926
+ contains: {
3927
+ type: "string",
3928
+ const: flagvalue
3929
+ }
3930
+ }
3931
+ },
3932
+ required: ["$flags"]
3933
+ });
3934
+ }
3935
+ function status(statusValue) {
3936
+ return defineConditional({
3937
+ type: "object",
3938
+ properties: {
3939
+ $status: {
3940
+ type: "string",
3941
+ const: statusValue
3942
+ }
3943
+ },
3944
+ required: ["$status"]
3945
+ });
3946
+ }
3558
3947
  function createFieldConditionals(fieldId) {
3559
3948
  const getDayRange = (field3, days, clause, referenceDate) => ({
3560
3949
  type: "object",
@@ -3956,6 +4345,526 @@ function createFieldConditionals(fieldId) {
3956
4345
  };
3957
4346
  }
3958
4347
 
4348
+ // ../commons/src/events/state/index.ts
4349
+ function getStatusFromActions(actions) {
4350
+ const acceptedActions = actions.filter(
4351
+ ({ status: status2 }) => status2 === ActionStatus.Accepted
4352
+ );
4353
+ const isCurrentlyArchived = acceptedActions.reduce(
4354
+ (archived, action) => {
4355
+ if (action.type === ActionType.ARCHIVE) {
4356
+ return true;
4357
+ }
4358
+ if (action.type === ActionType.UNARCHIVE) {
4359
+ return false;
4360
+ }
4361
+ return archived;
4362
+ },
4363
+ false
4364
+ );
4365
+ if (isCurrentlyArchived) {
4366
+ return EventStatus.enum.ARCHIVED;
4367
+ }
4368
+ return acceptedActions.filter(
4369
+ ({ type }) => type !== ActionType.ARCHIVE && type !== ActionType.UNARCHIVE
4370
+ ).reduce((status2, action) => {
4371
+ switch (action.type) {
4372
+ case ActionType.CREATE:
4373
+ return EventStatus.enum.CREATED;
4374
+ case ActionType.DECLARE:
4375
+ return EventStatus.enum.DECLARED;
4376
+ case ActionType.REGISTER:
4377
+ return EventStatus.enum.REGISTERED;
4378
+ case ActionType.NOTIFY:
4379
+ return EventStatus.enum.NOTIFIED;
4380
+ // Already filtered out above; listed here only to satisfy exhaustiveness.
4381
+ case ActionType.ARCHIVE:
4382
+ case ActionType.UNARCHIVE:
4383
+ case ActionType.CUSTOM:
4384
+ case ActionType.PRINT_CERTIFICATE:
4385
+ case ActionType.ASSIGN:
4386
+ case ActionType.UNASSIGN:
4387
+ case ActionType.REJECT:
4388
+ case ActionType.REQUEST_CORRECTION:
4389
+ case ActionType.APPROVE_CORRECTION:
4390
+ case ActionType.DUPLICATE_DETECTED:
4391
+ case ActionType.MARK_AS_NOT_DUPLICATE:
4392
+ case ActionType.MARK_AS_DUPLICATE:
4393
+ case ActionType.REJECT_CORRECTION:
4394
+ case ActionType.READ:
4395
+ case ActionType.EDIT:
4396
+ default:
4397
+ return status2;
4398
+ }
4399
+ }, EventStatus.enum.CREATED);
4400
+ }
4401
+ function getAssignedUserFromActions(actions) {
4402
+ return actions.reduce((user2, action) => {
4403
+ if (action.type === ActionType.ASSIGN) {
4404
+ return action.assignedTo;
4405
+ }
4406
+ if (action.type === ActionType.UNASSIGN) {
4407
+ return null;
4408
+ }
4409
+ return user2;
4410
+ }, null);
4411
+ }
4412
+ function deepDropNulls(obj) {
4413
+ if (Array.isArray(obj)) {
4414
+ return obj.map(deepDropNulls);
4415
+ }
4416
+ if (obj !== null && typeof obj === "object") {
4417
+ return Object.entries(obj).reduce((acc, [key, value]) => {
4418
+ const cleanedValue = deepDropNulls(value);
4419
+ if (cleanedValue !== null) {
4420
+ ;
4421
+ acc[key] = cleanedValue;
4422
+ }
4423
+ return acc;
4424
+ }, {});
4425
+ }
4426
+ return obj;
4427
+ }
4428
+ var DEFAULT_DATE_OF_EVENT_PROPERTY = "createdAt";
4429
+ function extractDateString(dateTime) {
4430
+ return dateTime.split("T")[0];
4431
+ }
4432
+ function resolveDateOfEvent(eventIndex, declaration, config) {
4433
+ if (!config.dateOfEvent) {
4434
+ return extractDateString(eventIndex[DEFAULT_DATE_OF_EVENT_PROPERTY]);
4435
+ }
4436
+ const parsedDate = isFieldReference(config.dateOfEvent) ? ZodDate.safeParse(declaration[config.dateOfEvent.$$field]) : ZodDateTime.safeParse(
4437
+ getMixedPath(eventIndex, config.dateOfEvent.$$event)
4438
+ );
4439
+ return parsedDate.success ? extractDateString(parsedDate.data) : void 0;
4440
+ }
4441
+ var DEFAULT_PLACE_OF_EVENT_PROPERTY = "createdAtLocation";
4442
+ function getParsedUUID(value, oldValue) {
4443
+ const parsed = UUID.safeParse(value);
4444
+ return parsed.success ? parsed.data : oldValue;
4445
+ }
4446
+ function resolvePlaceOfEvent(eventMetadata, declaration, config) {
4447
+ let placeOfEvent = getParsedUUID(
4448
+ eventMetadata[DEFAULT_PLACE_OF_EVENT_PROPERTY]
4449
+ );
4450
+ if (config.placeOfEvent) {
4451
+ const addressFieldValue = AddressFieldValue.safeParse(
4452
+ declaration[config.placeOfEvent.$$field]
4453
+ );
4454
+ if (addressFieldValue.success && addressFieldValue.data.addressType === AddressType.DOMESTIC && addressFieldValue.data.administrativeArea) {
4455
+ placeOfEvent = getParsedUUID(
4456
+ addressFieldValue.data.administrativeArea,
4457
+ placeOfEvent
4458
+ );
4459
+ } else {
4460
+ placeOfEvent = getParsedUUID(
4461
+ declaration[config.placeOfEvent.$$field],
4462
+ placeOfEvent
4463
+ );
4464
+ }
4465
+ }
4466
+ return placeOfEvent;
4467
+ }
4468
+ function extractPotentialDuplicatesFromActions(actions) {
4469
+ return actions.reduce((duplicates, action) => {
4470
+ if (action.type === ActionType.DUPLICATE_DETECTED) {
4471
+ duplicates = action.content.duplicates;
4472
+ }
4473
+ if (action.type === ActionType.MARK_AS_NOT_DUPLICATE || action.type === ActionType.MARK_AS_DUPLICATE) {
4474
+ duplicates = [];
4475
+ }
4476
+ return duplicates;
4477
+ }, []);
4478
+ }
4479
+ function getCurrentEventState(event2, config) {
4480
+ const sortedActions = event2.actions.slice().sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4481
+ const creationAction = sortedActions.find(
4482
+ (action) => action.type === ActionType.CREATE
4483
+ );
4484
+ if (!creationAction) {
4485
+ throw new Error(`Event ${event2.id} has no creation action`);
4486
+ }
4487
+ const acceptedActions = getAcceptedActions(event2).sort(
4488
+ (a, b) => a.createdAt.localeCompare(b.createdAt)
4489
+ );
4490
+ const requestActionMetadata = getActionUpdateMetadata(sortedActions);
4491
+ const acceptedActionMetadata = getActionUpdateMetadata(acceptedActions);
4492
+ const declaration = aggregateActionDeclarations(event2);
4493
+ const status2 = getStatusFromActions(sortedActions);
4494
+ const legalStatuses = getLegalStatuses(sortedActions);
4495
+ const base = deepDropNulls({
4496
+ id: event2.id,
4497
+ type: event2.type,
4498
+ status: status2,
4499
+ legalStatuses,
4500
+ createdAt: creationAction.createdAt,
4501
+ createdBy: creationAction.createdBy,
4502
+ createdByUserType: creationAction.createdByUserType,
4503
+ createdAtLocation: creationAction.createdAtLocation,
4504
+ updatedAt: acceptedActionMetadata.createdAt,
4505
+ assignedTo: getAssignedUserFromActions(acceptedActions),
4506
+ updatedBy: requestActionMetadata.createdBy,
4507
+ updatedAtLocation: requestActionMetadata.createdAtLocation,
4508
+ declaration,
4509
+ trackingId: event2.trackingId,
4510
+ updatedByUserRole: requestActionMetadata.createdByRole,
4511
+ placeOfEvent: resolvePlaceOfEvent(
4512
+ { createdAtLocation: creationAction.createdAtLocation },
4513
+ declaration,
4514
+ config
4515
+ ),
4516
+ potentialDuplicates: extractPotentialDuplicatesFromActions(sortedActions),
4517
+ flags: getEventFlags(event2, config)
4518
+ });
4519
+ return deepDropNulls({
4520
+ ...base,
4521
+ dateOfEvent: resolveDateOfEvent(base, declaration, config)
4522
+ });
4523
+ }
4524
+
4525
+ // ../commons/src/conditionals/validate.ts
4526
+ var ajv = new import__.default({
4527
+ $data: true,
4528
+ allowUnionTypes: true,
4529
+ strict: false
4530
+ // Allow minContains and other newer features
4531
+ });
4532
+ var DataContext = z33.object({
4533
+ rootData: z33.object({
4534
+ $leafAdminStructureLocationIds: z33.array(z33.object({ id: UUID }))
4535
+ })
4536
+ });
4537
+ function resolveDataPath(rootData, dataPath, instancePath) {
4538
+ const pathParts = dataPath.split("/");
4539
+ const levels = parseInt(pathParts[0], 10);
4540
+ const referencePath = pathParts.slice(1);
4541
+ const instanceParts = instancePath.split("/").filter(Boolean);
4542
+ const traversedParts = instanceParts.slice(0, -levels);
4543
+ let current = rootData;
4544
+ for (const part of traversedParts) {
4545
+ if (current === null || current === void 0) {
4546
+ return void 0;
4547
+ }
4548
+ current = current[part];
4549
+ }
4550
+ for (const part of referencePath) {
4551
+ if (current === null || current === void 0) {
4552
+ return void 0;
4553
+ }
4554
+ current = current[part];
4555
+ }
4556
+ return current;
4557
+ }
4558
+ function todayISO() {
4559
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4560
+ }
4561
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4562
+ function compileClientFunction(code) {
4563
+ let fn = compiledFunctionCache.get(code);
4564
+ if (!fn) {
4565
+ fn = new Function(`return (${code})`)();
4566
+ compiledFunctionCache.set(code, fn);
4567
+ }
4568
+ return fn;
4569
+ }
4570
+ (0, import_ajv_formats.default)(ajv);
4571
+ var inMemoryEventStateCache = /* @__PURE__ */ new WeakMap();
4572
+ function getInMemoryEventState(event2, config) {
4573
+ let stateByConfig = inMemoryEventStateCache.get(event2);
4574
+ if (!stateByConfig) {
4575
+ stateByConfig = /* @__PURE__ */ new WeakMap();
4576
+ inMemoryEventStateCache.set(event2, stateByConfig);
4577
+ }
4578
+ let state = stateByConfig.get(config);
4579
+ if (!state) {
4580
+ state = getCurrentEventState(event2, config);
4581
+ stateByConfig.set(config, state);
4582
+ }
4583
+ return state;
4584
+ }
4585
+ function buildClientFunctionContext(input) {
4586
+ const flags = input.validatorContext?.event && input.validatorContext?.eventConfig ? getInMemoryEventState(
4587
+ input.validatorContext?.event,
4588
+ input.validatorContext?.eventConfig
4589
+ )?.flags : [];
4590
+ return {
4591
+ $form: input.form,
4592
+ $flags: flags,
4593
+ $now: todayISO(),
4594
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4595
+ $online: isOnline(),
4596
+ $user: input.validatorContext?.user,
4597
+ $event: input.validatorContext?.event,
4598
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4599
+ user: input.systemVariables?.user,
4600
+ $window: input.systemVariables?.$window,
4601
+ locations: input.locations,
4602
+ adminLevelIds: input.adminLevelIds
4603
+ };
4604
+ }
4605
+ function runClientFunction(code, data, context) {
4606
+ return compileClientFunction(code)(data, context);
4607
+ }
4608
+ ajv.addKeyword({
4609
+ keyword: "daysFromDate",
4610
+ type: "string",
4611
+ schemaType: "object",
4612
+ $data: true,
4613
+ errors: true,
4614
+ validate(schema, data, _2, dataContext) {
4615
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4616
+ throw new Error("Validation context must contain $now");
4617
+ }
4618
+ const { days, clause } = schema;
4619
+ if (typeof data !== "string") {
4620
+ return false;
4621
+ }
4622
+ const date = new Date(data);
4623
+ if (isNaN(date.getTime())) {
4624
+ return false;
4625
+ }
4626
+ let referenceDate = schema.referenceDate;
4627
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4628
+ referenceDate = resolveDataPath(
4629
+ dataContext.rootData,
4630
+ referenceDate.$data,
4631
+ dataContext.instancePath
4632
+ );
4633
+ }
4634
+ if (!referenceDate) {
4635
+ referenceDate = dataContext.rootData.$now;
4636
+ }
4637
+ const baseDate = new Date(referenceDate);
4638
+ if (isNaN(baseDate.getTime())) {
4639
+ return false;
4640
+ }
4641
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4642
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4643
+ }
4644
+ });
4645
+ ajv.addKeyword({
4646
+ keyword: "isLeafLevelLocation",
4647
+ type: "string",
4648
+ schemaType: "boolean",
4649
+ $data: true,
4650
+ errors: true,
4651
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4652
+ validate(_schema, data, _2, dataContext) {
4653
+ const locationIdInput = data;
4654
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4655
+ return locations.some((location) => location.id === locationIdInput);
4656
+ }
4657
+ });
4658
+ function isAgeValue(value) {
4659
+ return typeof value === "object" && value !== null && "age" in value && typeof value.age === "number";
4660
+ }
4661
+ ajv.addKeyword({
4662
+ keyword: "customClientValidator",
4663
+ schemaType: "object",
4664
+ errors: true,
4665
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4666
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4667
+ // so the cast holds.
4668
+ validate(schema, data, _2, dataContext) {
4669
+ return Boolean(
4670
+ runClientFunction(
4671
+ schema.code,
4672
+ data,
4673
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4674
+ )
4675
+ );
4676
+ }
4677
+ });
4678
+ function validate(schema, data) {
4679
+ const validator = ajv.getSchema(schema.$id) || ajv.compile(schema);
4680
+ if ("$form" in data) {
4681
+ const entries = Object.entries(data.$form).map(([key, value]) => {
4682
+ if (!isAgeValue(value)) {
4683
+ return [key, value];
4684
+ }
4685
+ const age = value.age;
4686
+ const maybeAsOfDate = PlainDate.safeParse(data.$form[value.asOfDateRef]);
4687
+ return [
4688
+ key,
4689
+ {
4690
+ age,
4691
+ dob: ageToDate(
4692
+ age,
4693
+ maybeAsOfDate.success ? maybeAsOfDate.data : PlainDate.parse(data.$now)
4694
+ )
4695
+ }
4696
+ ];
4697
+ });
4698
+ data.$form = Object.fromEntries(entries);
4699
+ }
4700
+ const result = validator(data);
4701
+ return result;
4702
+ }
4703
+ function isOnline() {
4704
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4705
+ return navigator.onLine;
4706
+ }
4707
+ return true;
4708
+ }
4709
+
4710
+ // ../commons/src/events/utils.ts
4711
+ var import_date_fns3 = require("date-fns");
4712
+ function ageToDate(age, asOfDate) {
4713
+ const date = plainDateToLocalDate(asOfDate);
4714
+ return PlainDate.parse((0, import_date_fns3.format)((0, import_date_fns3.subYears)(date, age), "yyyy-MM-dd"));
4715
+ }
4716
+ function getDeclarationFields(configuration) {
4717
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4718
+ }
4719
+ function isActionConfigType(type) {
4720
+ return actionConfigTypes.has(type);
4721
+ }
4722
+ function getActionConfig({
4723
+ eventConfiguration,
4724
+ actionType,
4725
+ customActionType
4726
+ }) {
4727
+ if (actionType === ActionType.NOTIFY) {
4728
+ return eventConfiguration.actions.find((a) => a.type === ActionType.NOTIFY) ?? eventConfiguration.actions.find((a) => a.type === ActionType.DECLARE);
4729
+ }
4730
+ return eventConfiguration.actions.find((a) => {
4731
+ if (a.type === ActionType.CUSTOM && customActionType) {
4732
+ return a.customActionType === customActionType;
4733
+ }
4734
+ return a.type === actionType;
4735
+ });
4736
+ }
4737
+ var getActionAnnotationFields = (actionConfig) => {
4738
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4739
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4740
+ }
4741
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4742
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4743
+ }
4744
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4745
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4746
+ return [...reviewFields, ...formFields];
4747
+ };
4748
+ function getAllAnnotationFields(config) {
4749
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4750
+ }
4751
+ function deepMerge(currentDocument, actionDocument) {
4752
+ const currentDocumentClone = (0, import_lodash4.cloneDeep)(currentDocument);
4753
+ return (0, import_lodash4.mergeWith)(
4754
+ (0, import_lodash4.cloneDeep)(currentDocumentClone),
4755
+ actionDocument,
4756
+ (previousValue, incomingValue) => {
4757
+ if (incomingValue === void 0) {
4758
+ return previousValue;
4759
+ }
4760
+ if ((0, import_lodash4.isArray)(incomingValue)) {
4761
+ return incomingValue;
4762
+ }
4763
+ if ((0, import_lodash4.isObject)(previousValue) && (0, import_lodash4.isObject)(incomingValue)) {
4764
+ return void 0;
4765
+ }
4766
+ return incomingValue;
4767
+ }
4768
+ );
4769
+ }
4770
+ var findAllFields = (config) => {
4771
+ return (0, import_lodash4.flattenDeep)([
4772
+ ...getDeclarationFields(config),
4773
+ ...getAllAnnotationFields(config)
4774
+ ]);
4775
+ };
4776
+ function getMixedPath(obj, path, defaultValue) {
4777
+ const parts = path.split(".");
4778
+ const resolve = (current, segments) => {
4779
+ if (current == null || segments.length === 0) {
4780
+ return current;
4781
+ }
4782
+ for (let i = segments.length; i > 0; i--) {
4783
+ const compoundKey = segments.slice(0, i).join(".");
4784
+ if ((0, import_lodash4.has)(current, compoundKey)) {
4785
+ const next = (0, import_lodash4.get)(current, compoundKey);
4786
+ return resolve(next, segments.slice(i));
4787
+ }
4788
+ }
4789
+ return void 0;
4790
+ };
4791
+ const result = resolve(obj, parts);
4792
+ return (0, import_lodash4.isNil)(result) ? defaultValue : result;
4793
+ }
4794
+ function isAcceptedAction(a) {
4795
+ return a.status === ActionStatus.Accepted;
4796
+ }
4797
+ function getCompleteActionAnnotation(event2, action) {
4798
+ if (action.originalActionId) {
4799
+ const originalAction = event2.actions.find(
4800
+ ({ id }) => id === action.originalActionId
4801
+ );
4802
+ if (originalAction?.status === ActionStatus.Requested) {
4803
+ return deepMerge(originalAction.annotation ?? {}, action.annotation ?? {});
4804
+ }
4805
+ }
4806
+ return action.annotation ?? {};
4807
+ }
4808
+ function getCompleteActionDeclaration(declaration, event2, action) {
4809
+ if (action.originalActionId) {
4810
+ const originalAction = event2.actions.find(
4811
+ ({ id }) => id === action.originalActionId
4812
+ );
4813
+ if (originalAction?.status === ActionStatus.Requested) {
4814
+ return deepMerge(
4815
+ deepMerge(declaration, originalAction.declaration),
4816
+ action.declaration
4817
+ );
4818
+ }
4819
+ }
4820
+ return deepMerge(declaration, action.declaration);
4821
+ }
4822
+ function getAcceptedActions(event2) {
4823
+ return event2.actions.filter(isAcceptedAction).map((action) => ({
4824
+ ...action,
4825
+ declaration: getCompleteActionDeclaration({}, event2, action),
4826
+ annotation: getCompleteActionAnnotation(event2, action)
4827
+ }));
4828
+ }
4829
+ var EXCLUDED_ACTIONS = [
4830
+ ActionType.REQUEST_CORRECTION,
4831
+ ActionType.PRINT_CERTIFICATE,
4832
+ ActionType.REJECT_CORRECTION
4833
+ ];
4834
+ function aggregateActionDeclarations(event2) {
4835
+ const allAcceptedActions = getAcceptedActions(event2);
4836
+ const aggregatedActions = allAcceptedActions.filter((a) => !EXCLUDED_ACTIONS.some((type) => type === a.type)).sort((a, b) => a.createdAt.localeCompare(b.createdAt));
4837
+ return aggregatedActions.reduce((declaration, action) => {
4838
+ if (action.type === ActionType.APPROVE_CORRECTION) {
4839
+ const requestAction = allAcceptedActions.find(
4840
+ ({ id }) => id === action.requestId
4841
+ );
4842
+ if (!requestAction) {
4843
+ return declaration;
4844
+ }
4845
+ const declarationWithApprovedCorrection = getCompleteActionDeclaration(
4846
+ declaration,
4847
+ event2,
4848
+ requestAction
4849
+ );
4850
+ return getCompleteActionDeclaration(
4851
+ declarationWithApprovedCorrection,
4852
+ event2,
4853
+ action
4854
+ );
4855
+ }
4856
+ return getCompleteActionDeclaration(declaration, event2, action);
4857
+ }, {});
4858
+ }
4859
+ function aggregateActionAnnotations(event2) {
4860
+ return event2.actions.reduce((ann, sortedAction) => {
4861
+ if (!("annotation" in sortedAction) || !sortedAction.annotation) {
4862
+ return ann;
4863
+ }
4864
+ return deepMerge(ann, sortedAction.annotation);
4865
+ }, {});
4866
+ }
4867
+
3959
4868
  // ../commons/src/events/eventConfigValidation.ts
3960
4869
  function validateAdvancedSearchConfig(event2, ctx) {
3961
4870
  const allFields = findAllFields(event2);
@@ -4038,9 +4947,9 @@ function validatePlaceOfEvent(event2, ctx) {
4038
4947
  }
4039
4948
  function validateActionFlags(event2, ctx) {
4040
4949
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
4041
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4950
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
4042
4951
  const actionFlagIds = event2.actions.flatMap(
4043
- (action) => (action.flags ?? []).map((flag) => flag.id)
4952
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
4044
4953
  );
4045
4954
  for (const actionFlagId of actionFlagIds) {
4046
4955
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4076,11 +4985,11 @@ function validateActionOrder(event2, ctx) {
4076
4985
  }
4077
4986
 
4078
4987
  // ../commons/src/events/EventConfig.ts
4079
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4988
+ var EventFieldReference = z34.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4080
4989
  "Reference to a field defined in the event metadata, using the field id."
4081
4990
  );
4082
- var _EventConfigBase = z33.object({
4083
- id: z33.string().describe(
4991
+ var _EventConfigBase = z34.object({
4992
+ id: z34.string().describe(
4084
4993
  'Machine-readable identifier of the event (e.g. "birth", "death").'
4085
4994
  ),
4086
4995
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -4099,23 +5008,26 @@ var _EventConfigBase = z33.object({
4099
5008
  "Summary information displayed in the event overview."
4100
5009
  ),
4101
5010
  label: TranslationConfig.describe("Human-readable label for the event type."),
4102
- actions: z33.array(ActionConfig).describe(
5011
+ actions: z34.array(ActionConfig).describe(
4103
5012
  "Configuration of core and custom actions associated with the event."
4104
5013
  ),
4105
- actionOrder: z33.array(z33.string()).optional().describe(
5014
+ actionOrder: z34.array(z34.string()).optional().describe(
4106
5015
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
4107
5016
  ),
4108
5017
  declaration: DeclarationFormConfig.describe(
4109
5018
  "Configuration of the form used to gather event data."
4110
5019
  ),
4111
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
5020
+ advancedSearch: z34.array(AdvancedSearchConfig).optional().default([]).describe(
4112
5021
  "Configuration of fields available in the advanced search feature."
4113
5022
  ),
4114
- flags: z33.array(FlagConfig).optional().default([]).describe(
5023
+ flags: z34.array(FlagConfig).optional().default([]).describe(
4115
5024
  "Configuration of custom flags associated with the actions of this event type."
4116
5025
  ),
4117
- analytics: z33.boolean().optional().default(true).describe(
5026
+ analytics: z34.boolean().optional().default(true).describe(
4118
5027
  "Indicates whether the records of this event type are included in analytics"
5028
+ ),
5029
+ icon: z34.partialRecord(AvailableIcons, Conditional).optional().describe(
5030
+ 'Maps an icon name to a conditional. The icon of the first entry (in definition order) whose conditional matches the event is used when rendering it (e.g. in the "iconWithName"/"iconWithNameEvent" workqueue columns). Falls back to the default status-based icon when unset or when no conditional matches.'
4119
5031
  )
4120
5032
  });
4121
5033
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4332,21 +5244,31 @@ var event = Object.assign(eventFn, {
4332
5244
  return {
4333
5245
  $event: field3
4334
5246
  };
4335
- }
5247
+ },
5248
+ /**
5249
+ * Checks if the event currently has the given status.
5250
+ * @param eventStatus - The status to check for.
5251
+ */
5252
+ hasStatus: (eventStatus) => status(eventStatus),
5253
+ /**
5254
+ * Checks if the event currently carries the given flag.
5255
+ * @param flagValue - The flag to check for.
5256
+ */
5257
+ hasFlag: (flagValue) => flag(flagValue)
4336
5258
  });
4337
5259
 
4338
5260
  // ../commons/src/events/WorkqueueColumnConfig.ts
4339
- var z34 = __toESM(require("zod/v4"));
5261
+ var z35 = __toESM(require("zod/v4"));
4340
5262
  var WorkqueueColumnKeysArray = [
4341
5263
  ...EventMetadataKeysArray,
4342
5264
  "title",
4343
5265
  "outbox"
4344
5266
  ];
4345
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4346
- var WorkqueueColumnValue = z34.object({
5267
+ var WorkqueueColumnKeys = z35.enum(WorkqueueColumnKeysArray);
5268
+ var WorkqueueColumnValue = z35.object({
4347
5269
  $event: WorkqueueColumnKeys
4348
5270
  });
4349
- var WorkqueueColumn = z34.object({
5271
+ var WorkqueueColumn = z35.object({
4350
5272
  label: TranslationConfig,
4351
5273
  value: WorkqueueColumnValue
4352
5274
  }).meta({
@@ -4360,164 +5282,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4360
5282
  }
4361
5283
 
4362
5284
  // ../commons/src/events/CountryConfigQueryInput.ts
4363
- var z35 = __toESM(require("zod/v4"));
4364
- var SerializableExact = z35.object({
4365
- type: z35.literal("exact"),
4366
- term: z35.union([z35.string(), SerializedUserField])
4367
- });
4368
- var SerializableWithin = z35.object({
4369
- type: z35.literal("within"),
4370
- location: z35.union([z35.string(), SerializedUserField])
4371
- });
4372
- var SerializedQueryExpression = z35.object({
4373
- eventType: z35.string(),
4374
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4375
- createdAt: z35.optional(DateCondition),
4376
- updatedAt: z35.optional(DateCondition),
4377
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4378
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4379
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4380
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4381
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4382
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4383
- createdAtLocation: z35.optional(
4384
- z35.union([SerializableWithin, SerializableExact])
5285
+ var z36 = __toESM(require("zod/v4"));
5286
+ var SerializableExact = z36.object({
5287
+ type: z36.literal("exact"),
5288
+ term: z36.union([z36.string(), SerializedUserField])
5289
+ });
5290
+ var SerializableWithin = z36.object({
5291
+ type: z36.literal("within"),
5292
+ location: z36.union([z36.string(), SerializedUserField])
5293
+ });
5294
+ var SerializedQueryExpression = z36.object({
5295
+ eventType: z36.string(),
5296
+ status: z36.optional(z36.union([AnyOfStatus, ExactStatus])),
5297
+ createdAt: z36.optional(DateCondition),
5298
+ updatedAt: z36.optional(DateCondition),
5299
+ "legalStatuses.DECLARED.createdAtLocation": z36.optional(SerializableWithin),
5300
+ "legalStatuses.DECLARED.createdByRole": z36.optional(AnyOf),
5301
+ "legalStatuses.REGISTERED.createdAt": z36.optional(DateCondition),
5302
+ "legalStatuses.REGISTERED.createdAtLocation": z36.optional(SerializableWithin),
5303
+ "legalStatuses.REGISTERED.createdByRole": z36.optional(AnyOf),
5304
+ "legalStatuses.REGISTERED.registrationNumber": z36.optional(Exact),
5305
+ createdAtLocation: z36.optional(
5306
+ z36.union([SerializableWithin, SerializableExact])
4385
5307
  ),
4386
- updatedAtLocation: z35.optional(
4387
- z35.union([SerializableWithin, SerializableExact])
5308
+ updatedAtLocation: z36.optional(
5309
+ z36.union([SerializableWithin, SerializableExact])
4388
5310
  ),
4389
- updatedByUserRole: z35.optional(SerializableExact),
4390
- assignedTo: z35.optional(SerializableExact),
4391
- createdBy: z35.optional(SerializableExact),
5311
+ updatedByUserRole: z36.optional(SerializableExact),
5312
+ assignedTo: z36.optional(SerializableExact),
5313
+ createdBy: z36.optional(SerializableExact),
4392
5314
  createdByUserType: ExactUserType,
4393
- updatedBy: z35.optional(SerializableExact),
4394
- trackingId: z35.optional(Exact),
4395
- flags: z35.optional(ContainsFlags),
5315
+ updatedBy: z36.optional(SerializableExact),
5316
+ trackingId: z36.optional(Exact),
5317
+ flags: z36.optional(ContainsFlags),
4396
5318
  data: QueryInput
4397
5319
  }).partial();
4398
- var Or2 = z35.object({
4399
- type: z35.literal("or"),
4400
- clauses: z35.array(SerializedQueryExpression)
5320
+ var Or2 = z36.object({
5321
+ type: z36.literal("or"),
5322
+ clauses: z36.array(SerializedQueryExpression)
4401
5323
  });
4402
- var And2 = z35.object({
4403
- type: z35.literal("and"),
4404
- clauses: z35.array(SerializedQueryExpression)
5324
+ var And2 = z36.object({
5325
+ type: z36.literal("and"),
5326
+ clauses: z36.array(SerializedQueryExpression)
4405
5327
  });
4406
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4407
- var CountryConfigQueryInputType = z35.union([
5328
+ var CountryConfigQueryType = z36.discriminatedUnion("type", [And2, Or2]);
5329
+ var CountryConfigQueryInputType = z36.union([
4408
5330
  SerializedQueryExpression,
4409
5331
  And2,
4410
5332
  Or2
4411
5333
  ]);
4412
5334
 
4413
- // ../commons/src/icons.ts
4414
- var z36 = __toESM(require("zod/v4"));
4415
- var AvailableIcons = z36.enum([
4416
- "Archived",
4417
- "Assigned",
4418
- "Briefcase",
4419
- "Certified",
4420
- "Close",
4421
- "Collapse",
4422
- "Draft",
4423
- "DuplicateYellow",
4424
- "Expand",
4425
- "ExternalValidate",
4426
- "FilledCheck",
4427
- "InReview",
4428
- "Offline",
4429
- "Registered",
4430
- "RequiresUpdates",
4431
- "Sent",
4432
- "Validated",
4433
- "WaitingApproval",
4434
- "ChartActivity",
4435
- "Activity",
4436
- "Archive",
4437
- "ArchiveTray",
4438
- "ArrowLeft",
4439
- "ArrowRight",
4440
- "Buildings",
4441
- "Circle",
4442
- "CaretDown",
4443
- "CaretLeft",
4444
- "CaretRight",
4445
- "ChartBar",
4446
- "ChartLine",
4447
- "ChatCircle",
4448
- "CheckSquare",
4449
- "Compass",
4450
- "Check",
4451
- "Copy",
4452
- "Database",
4453
- "DotsThreeVertical",
4454
- "ArrowCounterClockwise",
4455
- "MagnifyingGlassMinus",
4456
- "MagnifyingGlassPlus",
4457
- "Export",
4458
- "Eye",
4459
- "EyeSlash",
4460
- "Envelope",
4461
- "File",
4462
- "FileSearch",
4463
- "FileMinus",
4464
- "FilePlus",
4465
- "FileText",
4466
- "FileX",
4467
- "Handshake",
4468
- "Gear",
4469
- "GitBranch",
4470
- "IdentificationCard",
4471
- "List",
4472
- "ListBullets",
4473
- "Lock",
4474
- "MagnifyingGlass",
4475
- "MapPin",
4476
- "Medal",
4477
- "NotePencil",
4478
- "Paperclip",
4479
- "PaperPlaneTilt",
4480
- "Pen",
4481
- "PenNib",
4482
- "Pencil",
4483
- "PencilSimpleLine",
4484
- "Phone",
4485
- "Plus",
4486
- "Printer",
4487
- "SignOut",
4488
- "Stamp",
4489
- "Star",
4490
- "Target",
4491
- "TextT",
4492
- "Trash",
4493
- "UploadSimple",
4494
- "User",
4495
- "UserPlus",
4496
- "Users",
4497
- "WarningCircle",
4498
- "X",
4499
- "ChatText",
4500
- "CircleWavyCheck",
4501
- "CircleWavyQuestion",
4502
- "ArchiveBox",
4503
- "ArrowCircleDown",
4504
- "FileArrowUp",
4505
- "FileDotted",
4506
- "Files",
4507
- "PencilLine",
4508
- "PencilCircle",
4509
- "UserCircle",
4510
- "Clock",
4511
- "QrCode",
4512
- "Webcam",
4513
- "Sun",
4514
- "DeviceTabletCamera",
4515
- "Globe",
4516
- "Fingerprint",
4517
- "PushPin",
4518
- "Timer"
4519
- ]);
4520
-
4521
5335
  // ../commons/src/events/WorkqueueConfig.ts
4522
5336
  var mandatoryColumns = defineWorkqueuesColumns([
4523
5337
  {
@@ -4648,10 +5462,7 @@ var DeclareActionInput = BaseActionInput.extend(
4648
5462
  );
4649
5463
  var EditActionInput = BaseActionInput.extend(
4650
5464
  z38.object({
4651
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4652
- content: z38.object({
4653
- comment: z38.string().describe("Comment for the edit action.").optional()
4654
- })
5465
+ type: z38.literal(ActionType.EDIT).default(ActionType.EDIT)
4655
5466
  }).shape
4656
5467
  );
4657
5468
  var PrintCertificateActionInput = BaseActionInput.extend(
@@ -4800,14 +5611,14 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4800
5611
 
4801
5612
  // ../commons/src/events/EventInput.ts
4802
5613
  var z40 = __toESM(require("zod/v4"));
4803
- var import_uuid10 = require("uuid");
5614
+ var import_uuid11 = require("uuid");
4804
5615
  var EventInput = z40.object({
4805
5616
  transactionId: z40.string(),
4806
5617
  type: z40.string(),
4807
5618
  createdAtLocation: UUID.nullish().describe(
4808
5619
  "Location where the event occurred. Required for system users."
4809
5620
  )
4810
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5621
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4811
5622
 
4812
5623
  // ../commons/src/events/EventDocument.ts
4813
5624
  var z41 = __toESM(require("zod/v4"));
@@ -4824,67 +5635,6 @@ var EventDocument = z41.object({
4824
5635
  )
4825
5636
  }).meta({ id: "EventDocument" });
4826
5637
 
4827
- // ../commons/src/events/state/index.ts
4828
- var import_lodash4 = require("lodash");
4829
-
4830
- // ../commons/src/events/state/utils.ts
4831
- var import_lodash2 = require("lodash");
4832
- var updateActions = ActionTypes.extract([
4833
- ActionType.CREATE,
4834
- ActionType.NOTIFY,
4835
- ActionType.EDIT,
4836
- ActionType.DECLARE,
4837
- ActionType.REGISTER,
4838
- ActionType.REJECT,
4839
- ActionType.ARCHIVE,
4840
- ActionType.UNARCHIVE,
4841
- ActionType.PRINT_CERTIFICATE,
4842
- ActionType.REQUEST_CORRECTION,
4843
- ActionType.APPROVE_CORRECTION,
4844
- ActionType.REJECT_CORRECTION,
4845
- ActionType.CUSTOM
4846
- ]);
4847
-
4848
- // ../commons/src/events/state/flags.ts
4849
- var import_lodash3 = require("lodash");
4850
- var import_date_fns3 = require("date-fns");
4851
- var INHERENT_FLAG_RULES = [
4852
- {
4853
- flag: InherentFlags.CORRECTION_REQUESTED,
4854
- setOn: [ActionType.REQUEST_CORRECTION],
4855
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4856
- },
4857
- {
4858
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4859
- // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4860
- // are deliberately excluded so the flag freezes across an archive/unarchive
4861
- // round trip and comes back exactly as it was.
4862
- flag: InherentFlags.INCOMPLETE,
4863
- setOn: [ActionType.NOTIFY],
4864
- resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4865
- },
4866
- {
4867
- flag: InherentFlags.REJECTED,
4868
- setOn: [ActionType.REJECT],
4869
- resetOn: [
4870
- ActionType.NOTIFY,
4871
- ActionType.DECLARE,
4872
- ActionType.EDIT,
4873
- ActionType.REGISTER
4874
- ]
4875
- },
4876
- {
4877
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4878
- setOn: [ActionType.DUPLICATE_DETECTED],
4879
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4880
- },
4881
- {
4882
- flag: InherentFlags.EDIT_IN_PROGRESS,
4883
- setOn: [ActionType.EDIT],
4884
- resetOnAnyOtherAction: true
4885
- }
4886
- ];
4887
-
4888
5638
  // ../commons/src/events/defineConfig.ts
4889
5639
  var IGNORED_EVENT_TYPES = [
4890
5640
  "FOOTBALL_CLUB_MEMBERSHIP",
@@ -7357,21 +8107,69 @@ var LocationTypeV1 = z43.enum([
7357
8107
  "CRVS_OFFICE",
7358
8108
  "HEALTH_FACILITY"
7359
8109
  ]);
8110
+ var LocationStatus = z43.enum(["active", "inactive"]);
8111
+ var LocationVersion = z43.object({
8112
+ versionId: UUID,
8113
+ effectiveFrom: z43.iso.date(),
8114
+ name: z43.string(),
8115
+ externalId: z43.string().nullish(),
8116
+ status: LocationStatus
8117
+ });
7360
8118
  var AdministrativeArea = z43.object({
7361
8119
  id: UUID,
7362
8120
  name: z43.string(),
7363
8121
  externalId: z43.string().nullish(),
7364
8122
  parentId: UUID.nullable(),
7365
- validUntil: z43.iso.datetime().nullable()
8123
+ status: LocationStatus,
8124
+ versions: z43.array(LocationVersion)
7366
8125
  });
7367
8126
  var Location = z43.object({
7368
8127
  id: UUID,
7369
8128
  name: z43.string(),
7370
8129
  externalId: z43.string().nullish(),
7371
8130
  administrativeAreaId: UUID.nullable(),
7372
- validUntil: z43.iso.datetime().nullable(),
8131
+ locationType: z43.string().nullable(),
8132
+ status: LocationStatus,
8133
+ versions: z43.array(LocationVersion)
8134
+ });
8135
+ var ClientAdministrativeArea = AdministrativeArea.omit({
8136
+ name: true,
8137
+ status: true,
8138
+ externalId: true
8139
+ });
8140
+ var ClientLocation = Location.omit({
8141
+ name: true,
8142
+ status: true,
8143
+ externalId: true
8144
+ });
8145
+ function toClientLocation(location) {
8146
+ return {
8147
+ id: location.id,
8148
+ administrativeAreaId: location.administrativeAreaId,
8149
+ locationType: location.locationType,
8150
+ versions: location.versions
8151
+ };
8152
+ }
8153
+ function toClientAdministrativeArea(area) {
8154
+ return {
8155
+ id: area.id,
8156
+ parentId: area.parentId,
8157
+ versions: area.versions
8158
+ };
8159
+ }
8160
+ var SetLocationPayload = z43.object({
8161
+ id: UUID,
8162
+ name: z43.string(),
8163
+ externalId: z43.string().nullish(),
8164
+ administrativeAreaId: UUID.nullable(),
7373
8165
  locationType: z43.string().nullable()
7374
8166
  });
8167
+ var SetAdministrativeAreaPayload = z43.object({
8168
+ id: UUID,
8169
+ name: z43.string(),
8170
+ externalId: z43.string().nullish(),
8171
+ parentId: UUID.nullable()
8172
+ });
7375
8173
 
7376
8174
  // ../commons/src/events/scopes.ts
7377
8175
  var ACTION_SCOPE_MAP = {
@@ -7443,20 +8241,20 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7443
8241
  ]
7444
8242
  };
7445
8243
  var ACTION_FILTERS = {
7446
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7447
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7448
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7449
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7450
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7451
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7452
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7453
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7454
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7455
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7456
- [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7457
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7458
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7459
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
8244
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8245
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8246
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8247
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8248
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8249
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8250
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8251
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8252
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8253
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8254
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8255
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8256
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8257
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
7460
8258
  };
7461
8259
  var REJECTED_ACTIONS = [
7462
8260
  ActionType.READ,
@@ -7470,75 +8268,80 @@ var REJECTED_ACTIONS = [
7470
8268
  var import_lodash7 = require("lodash");
7471
8269
 
7472
8270
  // ../commons/src/events/mocks.test.utils.ts
7473
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
8271
+ function withVersionFields(entity) {
8272
+ return {
8273
+ ...entity,
8274
+ status: "active",
8275
+ versions: [
8276
+ {
8277
+ versionId: entity.id,
8278
+ effectiveFrom: "0001-01-01",
8279
+ name: entity.name,
8280
+ externalId: entity.externalId ?? null,
8281
+ status: "active"
8282
+ }
8283
+ ]
8284
+ };
8285
+ }
8286
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7474
8287
  {
7475
8288
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7476
8289
  name: "Central",
7477
8290
  parentId: null,
7478
- validUntil: null,
7479
8291
  externalId: "ydyJb1RAy4U1"
7480
8292
  },
7481
8293
  {
7482
8294
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7483
8295
  name: "Sulaka",
7484
8296
  parentId: null,
7485
- validUntil: null,
7486
8297
  externalId: "pQ8nGxWmZ2Q3"
7487
8298
  },
7488
8299
  {
7489
8300
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7490
8301
  name: "Pualula",
7491
8302
  parentId: null,
7492
- validUntil: null,
7493
8303
  externalId: "Aq91DweLmT8k"
7494
8304
  },
7495
8305
  {
7496
8306
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7497
8307
  name: "Chuminga",
7498
8308
  parentId: null,
7499
- validUntil: null,
7500
8309
  externalId: "Rw0fYNh2Xk9a"
7501
8310
  },
7502
8311
  {
7503
8312
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7504
8313
  name: "Ibombo",
7505
8314
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7506
- validUntil: null,
7507
8315
  externalId: "k7DsP4vbN1Qe"
7508
8316
  },
7509
8317
  {
7510
8318
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7511
8319
  name: "Isango",
7512
8320
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7513
- validUntil: null,
7514
8321
  externalId: "Gm3Z9eQpHw4L"
7515
8322
  },
7516
8323
  {
7517
8324
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7518
8325
  name: "Isamba",
7519
8326
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7520
- validUntil: null,
7521
8327
  externalId: "sT0xVu1KqJ7r"
7522
8328
  },
7523
8329
  {
7524
8330
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7525
8331
  name: "Itambo",
7526
8332
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7527
- validUntil: null,
7528
8333
  externalId: "Nq6Bv2HpL9Te"
7529
8334
  },
7530
8335
  {
7531
8336
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7532
8337
  name: "Ezhi",
7533
8338
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7534
- validUntil: null,
7535
8339
  externalId: "xK8cQ0ZRy5Wd"
7536
8340
  },
7537
8341
  {
7538
8342
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7539
8343
  name: "Ilanga",
7540
8344
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7541
- validUntil: null,
7542
8345
  externalId: "Cq4Jm1XvN8Ls"
7543
8346
  },
7544
8347
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7546,49 +8349,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7546
8349
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7547
8350
  name: "Klow",
7548
8351
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7549
- validUntil: null,
7550
8352
  externalId: "IkYcYBUcyY2"
7551
8353
  },
7552
8354
  {
7553
8355
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7554
8356
  name: "Mbondo",
7555
8357
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7556
- validUntil: null,
7557
8358
  externalId: "Qhvv5hvo3mY"
7558
8359
  },
7559
8360
  {
7560
8361
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7561
8362
  name: "Ndara",
7562
8363
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7563
- validUntil: null,
7564
8364
  externalId: "crXh068O9TR"
7565
8365
  },
7566
8366
  {
7567
8367
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7568
8368
  name: "Olani",
7569
8369
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7570
- validUntil: null,
7571
8370
  externalId: "r00It8Tvvp7"
7572
8371
  },
7573
8372
  {
7574
8373
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7575
8374
  name: "Pemba",
7576
8375
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7577
- validUntil: null,
7578
8376
  externalId: "ZnUWsbONIaH"
7579
8377
  },
7580
8378
  {
7581
8379
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7582
8380
  name: "Quanza",
7583
8381
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7584
- validUntil: null,
7585
8382
  externalId: "fDZycvQTa7l"
7586
8383
  },
7587
8384
  {
7588
8385
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7589
8386
  name: "Rivka",
7590
8387
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7591
- validUntil: null,
7592
8388
  externalId: "KqswxCGTELa"
7593
8389
  },
7594
8390
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7596,35 +8392,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7596
8392
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7597
8393
  name: "Mbula",
7598
8394
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7599
- validUntil: null,
7600
8395
  externalId: "osEbKjRc9Kg"
7601
8396
  },
7602
8397
  {
7603
8398
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7604
8399
  name: "Ndoki",
7605
8400
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7606
- validUntil: null,
7607
8401
  externalId: "aq4daBUAGr3"
7608
8402
  },
7609
8403
  {
7610
8404
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7611
8405
  name: "Tsanga",
7612
8406
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7613
- validUntil: null,
7614
8407
  externalId: "cqis6Y8trbJ"
7615
8408
  },
7616
8409
  {
7617
8410
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7618
8411
  name: "Waziri",
7619
8412
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7620
- validUntil: null,
7621
8413
  externalId: "LMijHPyyx6d"
7622
8414
  },
7623
8415
  {
7624
8416
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7625
8417
  name: "Zimbi",
7626
8418
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7627
- validUntil: null,
7628
8419
  externalId: "pcQYbPuKGZ7"
7629
8420
  },
7630
8421
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7632,67 +8423,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7632
8423
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7633
8424
  name: "Felani",
7634
8425
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7635
- validUntil: null,
7636
8426
  externalId: "gSqpoCGdMXp"
7637
8427
  },
7638
8428
  {
7639
8429
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7640
8430
  name: "Goroma",
7641
8431
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7642
- validUntil: null,
7643
8432
  externalId: "KvAAIaNqVrp"
7644
8433
  },
7645
8434
  {
7646
8435
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7647
8436
  name: "Halifu",
7648
8437
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7649
- validUntil: null,
7650
8438
  externalId: "qe4UnEVt1hv"
7651
8439
  },
7652
8440
  {
7653
8441
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7654
8442
  name: "Jabari",
7655
8443
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7656
- validUntil: null,
7657
8444
  externalId: "yHH9Nz4rLOt"
7658
8445
  },
7659
8446
  {
7660
8447
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7661
8448
  name: "Kifani",
7662
8449
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7663
- validUntil: null,
7664
8450
  externalId: "eSWmXIGeu1I"
7665
8451
  },
7666
8452
  {
7667
8453
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7668
8454
  name: "Lumela",
7669
8455
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7670
- validUntil: null,
7671
8456
  externalId: "bh0b3aI1uP3"
7672
8457
  }
7673
8458
  ];
7674
- var V2_DEFAULT_MOCK_LOCATIONS = [
8459
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
8460
+ var MOCK_LOCATIONS_BASE = [
7675
8461
  {
7676
8462
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7677
8463
  name: "Central Provincial Office",
7678
8464
  locationType: "CRVS_OFFICE",
7679
8465
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7680
- validUntil: null,
7681
8466
  externalId: "Xr3Df8WpK6Ys"
7682
8467
  },
7683
8468
  {
7684
8469
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7685
8470
  name: "Central Health Post",
7686
8471
  locationType: "HEALTH_FACILITY",
7687
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7688
- validUntil: null
8472
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7689
8473
  },
7690
8474
  {
7691
8475
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7692
8476
  name: "Ibombo District Office",
7693
8477
  locationType: "CRVS_OFFICE",
7694
8478
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7695
- validUntil: null,
7696
8479
  externalId: "Sm4Nw7GrD2Vy"
7697
8480
  },
7698
8481
  {
@@ -7700,7 +8483,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7700
8483
  name: "Isamba District Office",
7701
8484
  locationType: "CRVS_OFFICE",
7702
8485
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7703
- validUntil: null,
7704
8486
  externalId: "Vg1Bq5XeH9Lt"
7705
8487
  },
7706
8488
  {
@@ -7708,7 +8490,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7708
8490
  name: "Isango District Office",
7709
8491
  locationType: "CRVS_OFFICE",
7710
8492
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7711
- validUntil: null,
7712
8493
  externalId: "Je7Lm2XqN9Vz"
7713
8494
  },
7714
8495
  {
@@ -7716,7 +8497,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7716
8497
  name: "Sulaka Provincial Office",
7717
8498
  locationType: "CRVS_OFFICE",
7718
8499
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7719
- validUntil: null,
7720
8500
  externalId: "Ht2Wp9KcX5Qv"
7721
8501
  },
7722
8502
  {
@@ -7724,7 +8504,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7724
8504
  name: "Ilanga District Office",
7725
8505
  locationType: "CRVS_OFFICE",
7726
8506
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7727
- validUntil: null,
7728
8507
  externalId: "Yp6Ds1WqN3Xz"
7729
8508
  },
7730
8509
  {
@@ -7732,7 +8511,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7732
8511
  name: "Chamakubi Health Post",
7733
8512
  locationType: "HEALTH_FACILITY",
7734
8513
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7735
- validUntil: null,
7736
8514
  externalId: "M1nFr8LbC2Qy"
7737
8515
  },
7738
8516
  {
@@ -7740,7 +8518,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7740
8518
  name: "Ibombo Rural Health Centre",
7741
8519
  locationType: "HEALTH_FACILITY",
7742
8520
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7743
- validUntil: null,
7744
8521
  externalId: "bT7pV6YrW0Xc"
7745
8522
  },
7746
8523
  {
@@ -7748,7 +8525,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7748
8525
  name: "Chikobo Rural Health Centre",
7749
8526
  locationType: "HEALTH_FACILITY",
7750
8527
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7751
- validUntil: null,
7752
8528
  externalId: "zE4qPn2SgJ5d"
7753
8529
  },
7754
8530
  {
@@ -7756,7 +8532,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7756
8532
  name: "Chilochabalenje Health Post",
7757
8533
  locationType: "HEALTH_FACILITY",
7758
8534
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7759
- validUntil: null,
7760
8535
  externalId: "H8vDs1MqR4Uf"
7761
8536
  },
7762
8537
  {
@@ -7764,7 +8539,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7764
8539
  name: "Chipeso Rural Health Centre",
7765
8540
  locationType: "HEALTH_FACILITY",
7766
8541
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7767
- validUntil: null,
7768
8542
  externalId: "Qw3uZ9KfX6Lm"
7769
8543
  },
7770
8544
  {
@@ -7772,7 +8546,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7772
8546
  name: "Chisamba Rural Health Centre",
7773
8547
  locationType: "HEALTH_FACILITY",
7774
8548
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7775
- validUntil: null,
7776
8549
  externalId: "Yr0pCg8LdM2s"
7777
8550
  },
7778
8551
  {
@@ -7780,7 +8553,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7780
8553
  name: "Chitanda Rural Health Centre",
7781
8554
  locationType: "HEALTH_FACILITY",
7782
8555
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7783
- validUntil: null,
7784
8556
  externalId: "tS9gJ4PwB1Qx"
7785
8557
  },
7786
8558
  {
@@ -7788,7 +8560,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7788
8560
  name: "Golden Valley Rural Health Centre",
7789
8561
  locationType: "HEALTH_FACILITY",
7790
8562
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7791
- validUntil: null,
7792
8563
  externalId: "Ld7Qm3XsA8Vr"
7793
8564
  },
7794
8565
  {
@@ -7796,7 +8567,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7796
8567
  name: "Ipongo Rural Health Centre",
7797
8568
  locationType: "HEALTH_FACILITY",
7798
8569
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7799
- validUntil: null,
7800
8570
  externalId: "kF2sW9DmH0Bt"
7801
8571
  },
7802
8572
  {
@@ -7804,7 +8574,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7804
8574
  name: "Itumbwe Health Post",
7805
8575
  locationType: "HEALTH_FACILITY",
7806
8576
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7807
- validUntil: null,
7808
8577
  externalId: "Ue5Xb3VaC7Pq"
7809
8578
  },
7810
8579
  {
@@ -7812,7 +8581,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7812
8581
  name: "Kabangalala Rural Health Centre",
7813
8582
  locationType: "HEALTH_FACILITY",
7814
8583
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7815
- validUntil: null,
7816
8584
  externalId: "Pz8Kc1TqH6Jn"
7817
8585
  },
7818
8586
  // Village offices
@@ -7821,19 +8589,76 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7821
8589
  name: "Klow Village Office",
7822
8590
  locationType: "CRVS_OFFICE",
7823
8591
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7824
- validUntil: null,
7825
8592
  externalId: "PmAyxAJkxiJ"
7826
8593
  }
7827
8594
  ];
8595
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7828
8596
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7829
8597
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7830
8598
  );
7831
8599
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7832
8600
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7833
8601
  );
8602
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
8603
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
8604
+ );
8605
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
8606
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
8607
+ a.id,
8608
+ toClientAdministrativeArea(a)
8609
+ ])
8610
+ );
7834
8611
 
7835
- // ../commons/src/notification/UserNotifications.ts
8612
+ // ../commons/src/events/locationPayloads.ts
7836
8613
  var z44 = __toESM(require("zod/v4"));
8614
+ var CreateLocationPayload = z44.object({
8615
+ id: UUID.optional(),
8616
+ versionId: UUID.optional(),
8617
+ name: z44.string(),
8618
+ externalId: z44.string().nullish(),
8619
+ administrativeAreaId: UUID.nullable(),
8620
+ locationType: z44.string().nullable(),
8621
+ effectiveFrom: z44.iso.date().optional(),
8622
+ status: LocationStatus.default("active")
8623
+ });
8624
+ var UpdateLocationPayload = z44.strictObject({
8625
+ id: UUID,
8626
+ versionId: UUID.optional(),
8627
+ name: z44.string(),
8628
+ externalId: z44.string().nullish(),
8629
+ status: LocationStatus,
8630
+ effectiveFrom: z44.iso.date().optional(),
8631
+ lastVersionId: UUID
8632
+ });
8633
+ var WithdrawLocationVersionPayload = z44.object({
8634
+ id: UUID,
8635
+ versionId: UUID
8636
+ });
8637
+ var CreateAdministrativeAreaPayload = z44.object({
8638
+ id: UUID.optional(),
8639
+ versionId: UUID.optional(),
8640
+ name: z44.string(),
8641
+ externalId: z44.string().nullish(),
8642
+ parentId: UUID.nullable(),
8643
+ effectiveFrom: z44.iso.date().optional(),
8644
+ status: LocationStatus.default("active")
8645
+ });
8646
+ var UpdateAdministrativeAreaPayload = z44.strictObject({
8647
+ id: UUID,
8648
+ versionId: UUID.optional(),
8649
+ name: z44.string(),
8650
+ externalId: z44.string().nullish(),
8651
+ status: LocationStatus,
8652
+ effectiveFrom: z44.iso.date().optional(),
8653
+ lastVersionId: UUID
8654
+ });
8655
+ var WithdrawAdministrativeAreaVersionPayload = z44.object({
8656
+ id: UUID,
8657
+ versionId: UUID
8658
+ });
8659
+
8660
+ // ../commons/src/notification/UserNotifications.ts
8661
+ var z45 = __toESM(require("zod/v4"));
7837
8662
  var TriggerEvent = {
7838
8663
  USER_CREATED: "user-created",
7839
8664
  USER_UPDATED: "user-updated",
@@ -7846,54 +8671,54 @@ var TriggerEvent = {
7846
8671
  CHANGE_PHONE_NUMBER: "change-phone-number",
7847
8672
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7848
8673
  };
7849
- var Recipient = z44.object({
8674
+ var Recipient = z45.object({
7850
8675
  name: NameFieldValue.optional(),
7851
- mobile: z44.string().optional(),
7852
- email: z44.string().optional(),
7853
- bcc: z44.array(z44.string()).optional()
8676
+ mobile: z45.string().optional(),
8677
+ email: z45.string().optional(),
8678
+ bcc: z45.array(z45.string()).optional()
7854
8679
  });
7855
- var BasePayload = z44.object({
8680
+ var BasePayload = z45.object({
7856
8681
  recipient: Recipient
7857
8682
  });
7858
8683
  var TriggerPayload = {
7859
8684
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7860
- username: z44.string(),
7861
- temporaryPassword: z44.string()
8685
+ username: z45.string(),
8686
+ temporaryPassword: z45.string()
7862
8687
  }),
7863
8688
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7864
- oldUsername: z44.string(),
7865
- newUsername: z44.string()
8689
+ oldUsername: z45.string(),
8690
+ newUsername: z45.string()
7866
8691
  }),
7867
8692
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7868
- username: z44.string()
8693
+ username: z45.string()
7869
8694
  }),
7870
8695
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7871
- code: z44.string()
8696
+ code: z45.string()
7872
8697
  }),
7873
8698
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7874
- temporaryPassword: z44.string(),
7875
- admin: z44.object({
7876
- id: z44.string(),
8699
+ temporaryPassword: z45.string(),
8700
+ admin: z45.object({
8701
+ id: z45.string(),
7877
8702
  name: NameFieldValue,
7878
- role: z44.string()
8703
+ role: z45.string()
7879
8704
  })
7880
8705
  }),
7881
8706
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7882
- username: z44.string(),
7883
- temporaryPassword: z44.string()
8707
+ username: z45.string(),
8708
+ temporaryPassword: z45.string()
7884
8709
  }),
7885
8710
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7886
- code: z44.string()
8711
+ code: z45.string()
7887
8712
  }),
7888
8713
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7889
- subject: z44.string(),
7890
- body: z44.string()
8714
+ subject: z45.string(),
8715
+ body: z45.string()
7891
8716
  }),
7892
8717
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7893
- code: z44.string()
8718
+ code: z45.string()
7894
8719
  }),
7895
8720
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7896
- code: z44.string()
8721
+ code: z45.string()
7897
8722
  })
7898
8723
  };
7899
8724
  async function triggerUserEventNotification({
@@ -7917,4 +8742,4 @@ function parseUserEventTrigger(event2, body) {
7917
8742
  }
7918
8743
 
7919
8744
  // src/notification/index.ts
7920
- z45.globalRegistry.clear();
8745
+ z46.globalRegistry.clear();