@opencrvs/toolkit 2.0.1-rc.fed4de8 → 2.1.0-beta

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 (169) hide show
  1. package/README.md +16 -0
  2. package/build.sh +14 -5
  3. package/create-countryconfig/index.js +412 -59
  4. package/create-countryconfig/node_modules/.bin/degit +21 -0
  5. package/create-countryconfig/package.json +5 -2
  6. package/dist/application-config/index.js +369 -280
  7. package/dist/authentication/index.d.ts +67 -0
  8. package/dist/authentication/index.d.ts.map +1 -0
  9. package/dist/authentication/index.js +750 -0
  10. package/dist/cli.js +4619 -4737
  11. package/dist/commons/api/router.d.ts +4122 -2944
  12. package/dist/commons/application-config/index.d.ts +6 -6
  13. package/dist/commons/conditionals/conditionals.d.ts +32 -323
  14. package/dist/commons/conditionals/validate.d.ts +16 -5
  15. package/dist/commons/events/ActionConfig.d.ts +302 -67
  16. package/dist/commons/events/ActionDocument.d.ts +159 -121
  17. package/dist/commons/events/ActionInput.d.ts +30 -10
  18. package/dist/commons/events/ActionStatus.d.ts +14 -0
  19. package/dist/commons/events/ActionType.d.ts +63 -58
  20. package/dist/commons/events/AdvancedSearchConfig.d.ts +531 -495
  21. package/dist/commons/events/AuditLog.d.ts +189 -40
  22. package/dist/commons/events/CompositeFieldValue.d.ts +4 -4
  23. package/dist/commons/events/Conditional.d.ts +3 -3
  24. package/dist/commons/events/CountryConfigQueryInput.d.ts +603 -561
  25. package/dist/commons/events/Draft.d.ts +38 -36
  26. package/dist/commons/events/DynamicFieldValue.d.ts +9 -9
  27. package/dist/commons/events/EventConfig.d.ts +8 -3
  28. package/dist/commons/events/EventDocument.d.ts +537 -47
  29. package/dist/commons/events/EventIndex.d.ts +61 -59
  30. package/dist/commons/events/EventMetadata.d.ts +59 -43
  31. package/dist/commons/events/EventStatus.d.ts +19 -0
  32. package/dist/commons/events/FieldConfig.d.ts +424 -379
  33. package/dist/commons/events/FieldType.d.ts +51 -51
  34. package/dist/commons/events/FieldTypeMapping.d.ts +86 -86
  35. package/dist/commons/events/FieldValue.d.ts +14 -14
  36. package/dist/commons/events/Flag.d.ts +57 -15
  37. package/dist/commons/events/PlainDate.d.ts +8 -0
  38. package/dist/commons/events/SummaryConfig.d.ts +249 -0
  39. package/dist/commons/events/TemplateConfig.d.ts +1 -1
  40. package/dist/commons/events/WorkqueueColumnConfig.d.ts +40 -40
  41. package/dist/commons/events/WorkqueueConfig.d.ts +835 -790
  42. package/dist/commons/events/deduplication.d.ts +1 -1
  43. package/dist/commons/events/event.d.ts +14 -2
  44. package/dist/commons/events/field.d.ts +69 -198
  45. package/dist/commons/events/index.d.ts +1 -0
  46. package/dist/commons/events/locationPayloads.d.ts +95 -0
  47. package/dist/commons/events/locations.d.ts +248 -14
  48. package/dist/commons/events/mocks.test.utils.d.ts +48 -4
  49. package/dist/commons/events/scopes.d.ts +5 -4
  50. package/dist/commons/events/state/index.d.ts +23 -15
  51. package/dist/commons/events/state/utils.d.ts +15 -6
  52. package/dist/commons/events/test.utils.d.ts +68 -42
  53. package/dist/commons/events/utils.d.ts +139 -106
  54. package/dist/commons/notification/UserNotifications.d.ts +38 -23
  55. package/dist/commons/notification/dispatch.d.ts +10 -0
  56. package/dist/commons/notification/index.d.ts +1 -0
  57. package/dist/conditionals/index.js +341 -66
  58. package/dist/csv.d.ts +25 -0
  59. package/dist/csv.d.ts.map +1 -0
  60. package/dist/csv.js +120 -0
  61. package/dist/environment/custom-types.d.ts +33 -0
  62. package/dist/environment/custom-types.d.ts.map +1 -0
  63. package/dist/environment/custom-types.js +12 -0
  64. package/dist/environment/derived-variables.d.ts +122 -0
  65. package/dist/environment/derived-variables.d.ts.map +1 -0
  66. package/dist/environment/derived-variables.js +155 -0
  67. package/dist/environment/editor-questions.d.ts +4 -0
  68. package/dist/environment/editor-questions.d.ts.map +1 -0
  69. package/dist/environment/editor-questions.js +67 -0
  70. package/dist/environment/git.d.ts +5 -0
  71. package/dist/environment/git.d.ts.map +1 -0
  72. package/dist/environment/git.js +38 -0
  73. package/dist/environment/github.d.ts +26 -0
  74. package/dist/environment/github.d.ts.map +1 -0
  75. package/dist/environment/github.js +247 -0
  76. package/dist/environment/index.d.ts +6 -0
  77. package/dist/environment/index.d.ts.map +1 -0
  78. package/dist/environment/index.js +81 -0
  79. package/dist/environment/logger.d.ts +18 -0
  80. package/dist/environment/logger.d.ts.map +1 -0
  81. package/dist/environment/logger.js +25 -0
  82. package/dist/environment/manage-users.d.ts +11 -0
  83. package/dist/environment/manage-users.d.ts.map +1 -0
  84. package/dist/environment/manage-users.js +507 -0
  85. package/dist/environment/paths.d.ts +7 -0
  86. package/dist/environment/paths.d.ts.map +1 -0
  87. package/dist/environment/paths.js +72 -0
  88. package/dist/environment/questions-helper.d.ts +15 -0
  89. package/dist/environment/questions-helper.d.ts.map +1 -0
  90. package/dist/environment/questions-helper.js +70 -0
  91. package/dist/environment/questions.d.ts +200 -0
  92. package/dist/environment/questions.d.ts.map +1 -0
  93. package/dist/environment/questions.js +418 -0
  94. package/dist/environment/setup-environment.d.ts +2 -0
  95. package/dist/environment/setup-environment.d.ts.map +1 -0
  96. package/dist/environment/setup-environment.js +795 -0
  97. package/dist/environment/ssh-keygen.d.ts +5 -0
  98. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  99. package/dist/environment/ssh-keygen.js +21 -0
  100. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  101. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  102. package/dist/environment/swarm-to-k8s.js +183 -0
  103. package/dist/environment/templates.d.ts +27 -0
  104. package/dist/environment/templates.d.ts.map +1 -0
  105. package/dist/environment/templates.js +164 -0
  106. package/dist/environment/update-workflows.d.ts +2 -0
  107. package/dist/environment/update-workflows.d.ts.map +1 -0
  108. package/dist/environment/update-workflows.js +191 -0
  109. package/dist/environment/upgrade.d.ts +2 -0
  110. package/dist/environment/upgrade.d.ts.map +1 -0
  111. package/dist/environment/upgrade.js +82 -0
  112. package/dist/environment/users.d.ts +2 -0
  113. package/dist/environment/users.d.ts.map +1 -0
  114. package/dist/environment/users.js +120 -0
  115. package/dist/environment/utils.d.ts +18 -0
  116. package/dist/environment/utils.d.ts.map +1 -0
  117. package/dist/environment/utils.js +110 -0
  118. package/dist/events/deduplication.d.ts +1 -1
  119. package/dist/events/index.js +8106 -7390
  120. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +2 -2
  121. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  122. package/dist/migrations/v2.0/checkout-upstream-files.js +2 -2
  123. package/dist/migrations/v2.0/convert-config-files-to-ts.js +17 -7
  124. package/dist/migrations/v2.0/index.js +88 -5141
  125. package/dist/migrations/v2.0/merge-infrastructure-directory.js +3 -3
  126. package/dist/migrations/v2.0/migrate-application-config-url.js +4 -3
  127. package/dist/migrations/v2.0/remove-hearth-migrations.js +17 -7
  128. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  129. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  130. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  131. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts +3 -0
  132. package/dist/migrations/v2.1/add-recovery-link-notifications.d.ts.map +1 -0
  133. package/dist/migrations/v2.1/add-recovery-link-notifications.js +511 -0
  134. package/dist/migrations/v2.1/add-translations.d.ts +9 -0
  135. package/dist/migrations/v2.1/add-translations.d.ts.map +1 -0
  136. package/dist/migrations/v2.1/add-translations.js +213 -0
  137. package/dist/migrations/v2.1/enable-telemetry.d.ts +3 -0
  138. package/dist/migrations/v2.1/enable-telemetry.d.ts.map +1 -0
  139. package/dist/migrations/v2.1/enable-telemetry.js +438 -0
  140. package/dist/migrations/v2.1/index.d.ts +6 -0
  141. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  142. package/dist/migrations/v2.1/index.js +1276 -0
  143. package/dist/notification/index.js +2011 -1446
  144. package/dist/scopes/index.d.ts +514 -168
  145. package/dist/scopes/index.js +342 -66
  146. package/dist/telemetry/index.d.ts +45 -0
  147. package/dist/telemetry/index.d.ts.map +1 -0
  148. package/dist/telemetry/index.js +39 -0
  149. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  150. package/dist/templates/charts-values/dependencies/values.yaml +82 -0
  151. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  152. package/dist/templates/charts-values/opencrvs-services/values.yaml +78 -0
  153. package/dist/templates/charts-values/opentelemetry/values.yaml +95 -0
  154. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  155. package/dist/templates/charts-values/traefik/values.yaml +129 -0
  156. package/dist/templates/inventory/inventory.template.yml +98 -0
  157. package/dist/translations/check.d.ts +19 -0
  158. package/dist/translations/check.d.ts.map +1 -0
  159. package/dist/translations/check.js +127 -0
  160. package/dist/verify/endpoints.d.ts +2 -0
  161. package/dist/verify/endpoints.d.ts.map +1 -0
  162. package/dist/verify/endpoints.js +345 -0
  163. package/opencrvs-toolkit-2.1.0-beta.tgz +0 -0
  164. package/package.json +25 -6
  165. package/tsconfig.build.json +11 -0
  166. package/tsconfig.build.tsbuildinfo +1 -0
  167. package/tsconfig.json +3 -0
  168. package/opencrvs-toolkit-2.0.1-rc.fed4de8.tgz +0 -0
  169. package/tsconfig.tsbuildinfo +0 -1
@@ -38,23 +38,17 @@ __export(notification_exports, {
38
38
  triggerUserEventNotification: () => triggerUserEventNotification
39
39
  });
40
40
  module.exports = __toCommonJS(notification_exports);
41
- var z45 = __toESM(require("zod/v4"));
42
-
43
- // ../commons/src/url.ts
44
- function joinUrl(base, path) {
45
- const baseWithSlash = base.endsWith("/") ? base : base + "/";
46
- return new URL(path, baseWithSlash);
47
- }
41
+ var z47 = __toESM(require("zod/v4"));
48
42
 
49
43
  // ../commons/src/events/AuditLog.ts
50
- var z5 = __toESM(require("zod/v4"));
44
+ var z9 = __toESM(require("zod/v4"));
51
45
 
52
46
  // ../commons/src/authentication.ts
53
47
  var import_jwt_decode = __toESM(require("jwt-decode"));
54
- var z3 = __toESM(require("zod/v4"));
48
+ var z8 = __toESM(require("zod/v4"));
55
49
 
56
50
  // ../commons/src/scopes.ts
57
- var z2 = __toESM(require("zod/v4"));
51
+ var z7 = __toESM(require("zod/v4"));
58
52
  var qs = __toESM(require("qs"));
59
53
 
60
54
  // ../commons/src/uuid.ts
@@ -65,12 +59,270 @@ function getUUID() {
65
59
  return (0, import_uuid.v4)();
66
60
  }
67
61
 
62
+ // ../commons/src/events/ActionType.ts
63
+ var z2 = __toESM(require("zod/v4"));
64
+ var ActionType = {
65
+ // Pre-declaration actions
66
+ DELETE: "DELETE",
67
+ CREATE: "CREATE",
68
+ NOTIFY: "NOTIFY",
69
+ // Declaration actions
70
+ DECLARE: "DECLARE",
71
+ REGISTER: "REGISTER",
72
+ EDIT: "EDIT",
73
+ // Declaration system actions. Non-configurable.
74
+ DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
75
+ REJECT: "REJECT",
76
+ // REJECT_DECLARATION
77
+ MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
78
+ MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
79
+ ARCHIVE: "ARCHIVE",
80
+ UNARCHIVE: "UNARCHIVE",
81
+ // Record actions
82
+ PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
83
+ REQUEST_CORRECTION: "REQUEST_CORRECTION",
84
+ REJECT_CORRECTION: "REJECT_CORRECTION",
85
+ APPROVE_CORRECTION: "APPROVE_CORRECTION",
86
+ // General actions
87
+ READ: "READ",
88
+ ASSIGN: "ASSIGN",
89
+ UNASSIGN: "UNASSIGN",
90
+ // Custom action
91
+ CUSTOM: "CUSTOM"
92
+ };
93
+ var ConfirmableActions = [
94
+ ActionType.NOTIFY,
95
+ ActionType.DECLARE,
96
+ ActionType.EDIT,
97
+ ActionType.REGISTER,
98
+ ActionType.REJECT,
99
+ ActionType.ARCHIVE,
100
+ ActionType.UNARCHIVE,
101
+ ActionType.PRINT_CERTIFICATE,
102
+ ActionType.REQUEST_CORRECTION,
103
+ ActionType.APPROVE_CORRECTION,
104
+ ActionType.REJECT_CORRECTION,
105
+ ActionType.CUSTOM
106
+ ];
107
+ var ActionTypes = z2.enum([
108
+ "DELETE",
109
+ "CREATE",
110
+ "NOTIFY",
111
+ "DECLARE",
112
+ "EDIT",
113
+ "REGISTER",
114
+ "DUPLICATE_DETECTED",
115
+ "REJECT",
116
+ "MARK_AS_DUPLICATE",
117
+ "MARK_AS_NOT_DUPLICATE",
118
+ "ARCHIVE",
119
+ "UNARCHIVE",
120
+ "PRINT_CERTIFICATE",
121
+ "REQUEST_CORRECTION",
122
+ "REJECT_CORRECTION",
123
+ "APPROVE_CORRECTION",
124
+ "READ",
125
+ "ASSIGN",
126
+ "UNASSIGN",
127
+ "CUSTOM"
128
+ ]);
129
+ var ClientSpecificAction = {
130
+ REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
131
+ };
132
+ var declarationActionValues = [
133
+ ActionTypes.enum.DECLARE,
134
+ ActionTypes.enum.EDIT,
135
+ ActionTypes.enum.REGISTER,
136
+ ActionTypes.enum.NOTIFY,
137
+ ActionTypes.enum.DUPLICATE_DETECTED
138
+ ];
139
+ var DeclarationActions = ActionTypes.extract(declarationActionValues);
140
+ var declarationUpdateActionValues = [
141
+ ...declarationActionValues,
142
+ ActionTypes.enum.REQUEST_CORRECTION
143
+ ];
144
+ var DeclarationUpdateActions = ActionTypes.extract(
145
+ declarationUpdateActionValues
146
+ );
147
+ var annotationActions = ActionTypes.exclude(declarationActionValues);
148
+ var writeActions = ActionTypes.exclude([
149
+ ActionType.CREATE,
150
+ ActionType.READ,
151
+ ActionType.ASSIGN,
152
+ ActionType.UNASSIGN
153
+ ]);
154
+ var WorkqueueActionType = ActionTypes.extract([
155
+ ActionType.READ,
156
+ ActionType.DELETE,
157
+ ActionType.DECLARE,
158
+ ActionType.REGISTER,
159
+ ActionType.EDIT,
160
+ ActionType.REJECT,
161
+ ActionType.MARK_AS_DUPLICATE,
162
+ ActionType.ARCHIVE,
163
+ ActionType.UNARCHIVE,
164
+ ActionType.PRINT_CERTIFICATE,
165
+ ActionType.REQUEST_CORRECTION
166
+ ]);
167
+ var META_ACTIONS = [
168
+ ActionType.ASSIGN,
169
+ ActionType.UNASSIGN,
170
+ ActionType.READ
171
+ ];
172
+
173
+ // ../commons/src/events/ActionStatus.ts
174
+ var ActionStatus = {
175
+ Requested: "Requested",
176
+ Accepted: "Accepted",
177
+ Rejected: "Rejected"
178
+ };
179
+
180
+ // ../commons/src/events/Flag.ts
181
+ var z5 = __toESM(require("zod/v4"));
182
+
183
+ // ../commons/src/events/TranslationConfig.ts
184
+ var z3 = __toESM(require("zod/v4"));
185
+ var TranslationConfig = z3.object({
186
+ id: z3.string().describe(
187
+ "The identifier of the translation referred in translation CSV files"
188
+ ),
189
+ defaultMessage: z3.string().describe("Default translation message"),
190
+ description: z3.string().describe(
191
+ "Describe the translation for a translator to be able to identify it."
192
+ )
193
+ }).meta({
194
+ description: "Translation configuration",
195
+ id: "TranslationConfig"
196
+ });
197
+
198
+ // ../commons/src/events/Conditional.ts
199
+ var z4 = __toESM(require("zod/v4"));
200
+ var Conditional = z4.any().describe("JSONSchema").meta({
201
+ description: "JSON schema conditional configuration",
202
+ id: "Conditional"
203
+ });
204
+ var ConditionalType = {
205
+ SHOW: "SHOW",
206
+ ENABLE: "ENABLE",
207
+ DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
208
+ };
209
+ var ShowConditional = z4.object({
210
+ type: z4.literal(ConditionalType.SHOW),
211
+ conditional: Conditional
212
+ }).describe(
213
+ "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
214
+ );
215
+ var EnableConditional = z4.object({
216
+ type: z4.literal(ConditionalType.ENABLE),
217
+ conditional: Conditional
218
+ }).describe(
219
+ "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
220
+ );
221
+ var ActionConditional = z4.discriminatedUnion("type", [
222
+ // Action can be shown / hidden
223
+ ShowConditional,
224
+ // Action can be shown to the user in the list but as disabled
225
+ EnableConditional
226
+ ]).meta({
227
+ id: "ActionConditional",
228
+ description: "Conditional gating whether an action is shown (SHOW) or enabled (ENABLE). When omitted from an action, the action is shown and enabled for everyone."
229
+ });
230
+ var DisplayOnReviewConditional = z4.object({
231
+ type: z4.literal(ConditionalType.DISPLAY_ON_REVIEW),
232
+ conditional: Conditional
233
+ }).describe(
234
+ "If 'DISPLAY_ON_REVIEW' conditional is defined, the component is shown on the review page only if both the 'DISPLAY_ON_REVIEW' and 'SHOW' conditions are met. This should only be used for fields within declaration forms, as they are the only ones with review pages."
235
+ );
236
+ var FieldConditional = z4.discriminatedUnion("type", [
237
+ // Field input can be shown / hidden
238
+ ShowConditional,
239
+ // Field input can be shown to the user but as disabled
240
+ EnableConditional,
241
+ // Field output can be shown / hidden on the review page
242
+ DisplayOnReviewConditional
243
+ ]).meta({
244
+ id: "FieldConditional",
245
+ description: "Conditional gating whether a form field is shown (SHOW), enabled (ENABLE), or displayed on the review page (DISPLAY_ON_REVIEW). When omitted, the field is shown and enabled for everyone, and is displayed on review whenever it has a value."
246
+ });
247
+
248
+ // ../commons/src/events/Flag.ts
249
+ var InherentFlags = {
250
+ INCOMPLETE: "incomplete",
251
+ REJECTED: "rejected",
252
+ CORRECTION_REQUESTED: "correction-requested",
253
+ POTENTIAL_DUPLICATE: "potential-duplicate",
254
+ /**
255
+ * This flag is set by the Edit-action and removed after the declaration or registration.
256
+ * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
257
+ *
258
+ * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
259
+ */
260
+ EDIT_IN_PROGRESS: "edit-in-progress"
261
+ };
262
+ var actionFlagPattern;
263
+ function getActionFlagPattern() {
264
+ actionFlagPattern ??= new RegExp(
265
+ `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
266
+ ActionStatus
267
+ ).join("|").toLowerCase()})$`
268
+ );
269
+ return actionFlagPattern;
270
+ }
271
+ var ActionFlag = z5.string().refine((value) => getActionFlagPattern().test(value), {
272
+ message: "Flag must be in the format ActionType:ActionStatus (lowerCase)"
273
+ });
274
+ var CustomFlag = z5.string().refine((val) => !Object.values(InherentFlags).includes(val), {
275
+ message: `Custom flag cannot be one of the inherent flags: ${Object.values(
276
+ InherentFlags
277
+ ).join(", ")}`
278
+ }).refine((val) => !ActionFlag.safeParse(val).success, {
279
+ message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
280
+ }).describe("Custom flag identifier defined by the country config.");
281
+ var Flag = ActionFlag.or(z5.enum(InherentFlags)).or(CustomFlag);
282
+ var ContainsFlags = z5.object({
283
+ anyOf: z5.array(Flag).optional(),
284
+ noneOf: z5.array(Flag).optional(),
285
+ allOf: z5.array(Flag).optional()
286
+ }).meta({
287
+ id: "ContainsFlags"
288
+ });
289
+ var FlagConfig = z5.object({
290
+ id: CustomFlag,
291
+ requiresAction: z5.boolean().describe(
292
+ "Indicates if this flag expects an action to be performed to be cleared."
293
+ ),
294
+ label: TranslationConfig.describe("Human readable label of the flag.")
295
+ }).meta({
296
+ id: "FlagConfig",
297
+ description: "Configuration for a custom flag that can be added to or removed from records by event actions."
298
+ });
299
+ var ActionFlagConfig = z5.object({
300
+ id: Flag,
301
+ operation: z5.enum(["add", "remove"]).describe("Operation to perform on the flag."),
302
+ conditional: Conditional.optional().describe(
303
+ "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
304
+ )
305
+ }).meta({
306
+ id: "ActionFlagConfig",
307
+ description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
308
+ });
309
+
310
+ // ../commons/src/events/EventStatus.ts
311
+ var z6 = __toESM(require("zod/v4"));
312
+ var EventStatus = z6.enum([
313
+ "CREATED",
314
+ "NOTIFIED",
315
+ "DECLARED",
316
+ "REGISTERED",
317
+ "ARCHIVED"
318
+ ]);
319
+
68
320
  // ../commons/src/scopes.ts
69
- var JurisdictionFilter = z2.enum(["administrativeArea", "location", "all"]).describe(
321
+ var JurisdictionFilter = z7.enum(["administrativeArea", "location", "all"]).describe(
70
322
  "Filters based on user jurisdiction relative to their office location in hierarchy."
71
323
  );
72
- var UserFilter = z2.enum(["user"]).describe("Filters based on the user. Limits to self.");
73
- var RecordScopeTypeV2 = z2.enum([
324
+ var UserFilter = z7.enum(["user"]).describe("Filters based on the user. Limits to self.");
325
+ var RecordScopeTypeV2 = z7.enum([
74
326
  "record.search",
75
327
  "record.create",
76
328
  "record.read",
@@ -79,6 +331,7 @@ var RecordScopeTypeV2 = z2.enum([
79
331
  "record.edit",
80
332
  "record.reject",
81
333
  "record.archive",
334
+ "record.unarchive",
82
335
  "record.review-duplicates",
83
336
  "record.register",
84
337
  "record.print-certified-copies",
@@ -87,14 +340,20 @@ var RecordScopeTypeV2 = z2.enum([
87
340
  "record.unassign-others",
88
341
  "record.custom-action"
89
342
  ]);
90
- var PlainScopeType = z2.enum([
343
+ var PlainScopeType = z7.enum([
91
344
  // Misc. system scopes
92
345
  "bypassratelimit",
93
346
  "record.reindex",
94
347
  "user.data-seeding",
95
348
  "integration.create",
349
+ // Reading an integration's audit log. Deliberately separate from
350
+ // 'integration.create' so read-only oversight can be granted on its own, and
351
+ // deliberately option-less: system clients have no office and no
352
+ // administrative area, so jurisdiction options would have nothing to bind to.
353
+ "integration.audit.read",
96
354
  "record.import",
97
355
  "config.update-all",
356
+ "location.edit",
98
357
  "attachment.upload",
99
358
  "profile.electronic-signature",
100
359
  "user.read-only-my-audit",
@@ -106,70 +365,81 @@ var PlainScopeType = z2.enum([
106
365
  "record.confirm-registration",
107
366
  "record.reject-registration"
108
367
  ]);
109
- var scopeByEvent = z2.preprocess(
368
+ var scopeByEvent = z7.preprocess(
110
369
  (val) => val === void 0 ? void 0 : [val].flat(),
111
- z2.array(z2.string()).optional()
370
+ z7.array(z7.string()).optional()
112
371
  ).describe("Event type, e.g. birth, death");
113
- var userRole = z2.preprocess(
372
+ var scopeByStatus = z7.preprocess(
373
+ (val) => val === void 0 ? void 0 : [val].flat(),
374
+ z7.array(EventStatus).optional()
375
+ ).describe(
376
+ "Restricts the scope to records currently in one of these statuses."
377
+ );
378
+ var userRole = z7.preprocess(
114
379
  (val) => val === void 0 ? void 0 : [val].flat(),
115
- z2.array(z2.string()).optional()
380
+ z7.array(z7.string()).optional()
116
381
  ).describe("User role, e.g. admin, field agent");
117
- var scopeOptionsPlaceEvent = z2.object({
382
+ var scopeOptionsPlaceEvent = z7.object({
118
383
  event: scopeByEvent,
119
- placeOfEvent: JurisdictionFilter.optional(),
120
- createdBy: UserFilter.optional()
384
+ placeOfEvent: JurisdictionFilter.optional()
121
385
  }).describe("Options applicable to all record scopes.");
122
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
386
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
387
+ notifiedIn: JurisdictionFilter.optional(),
388
+ notifiedBy: UserFilter.optional(),
123
389
  declaredIn: JurisdictionFilter.optional(),
124
- declaredBy: UserFilter.optional()
390
+ declaredBy: UserFilter.optional(),
391
+ status: scopeByStatus
125
392
  }).describe("Options applicable to actions that may take place after DECLARE");
126
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
393
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
127
394
  registeredIn: JurisdictionFilter.optional(),
128
- registeredBy: UserFilter.optional()
395
+ registeredBy: UserFilter.optional(),
396
+ flags: ContainsFlags.optional()
129
397
  }).describe(
130
398
  "Options applicable to actions that may take place after REGISTER, with full filtering capabilities."
131
399
  );
132
400
  var CustomActionScopeOptions = AllRecordScopeOptions.extend({
133
- customActionTypes: z2.preprocess(
401
+ customActionTypes: z7.preprocess(
134
402
  (val) => val === void 0 ? void 0 : [val].flat(),
135
- z2.array(z2.string()).optional()
403
+ z7.array(z7.string()).optional()
136
404
  ).describe("Allowed custom action types")
137
405
  });
138
- var AccessLevelOptions = z2.object({
406
+ var AccessLevelOptions = z7.object({
139
407
  accessLevel: JurisdictionFilter.optional()
140
408
  });
141
409
  var AllUserScopeOptions = AccessLevelOptions.extend({
142
410
  role: userRole.optional()
143
411
  });
144
- var WorkqueueOrDashboardOptions = z2.object({
145
- ids: z2.preprocess(
412
+ var WorkqueueOrDashboardOptions = z7.object({
413
+ ids: z7.preprocess(
146
414
  (val) => val === void 0 ? void 0 : [val].flat(),
147
- z2.array(z2.string())
415
+ z7.array(z7.string())
148
416
  ).describe("Must contain a list of workqueue or dashboard ids.")
149
417
  });
150
- var AllScopeOptions = z2.object({
418
+ var AllScopeOptions = z7.object({
151
419
  ...AllRecordScopeOptions.shape,
152
420
  ...AccessLevelOptions.shape,
153
421
  ...AllUserScopeOptions.shape,
154
422
  ...WorkqueueOrDashboardOptions.shape
155
423
  });
156
424
  var ScopeOptionKey = AllScopeOptions.keyof();
157
- var ResolvedScopeOptionsPlaceEvent = z2.object({
425
+ var ResolvedScopeOptionsPlaceEvent = z7.object({
158
426
  event: scopeByEvent,
159
- placeOfEvent: UUID.nullish(),
160
- createdBy: z2.string().optional()
427
+ placeOfEvent: UUID.nullish()
161
428
  }).describe(
162
429
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
163
430
  );
164
431
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
432
+ notifiedIn: UUID.nullish(),
433
+ notifiedBy: z7.string().optional(),
165
434
  declaredIn: UUID.nullish(),
166
- declaredBy: z2.string().optional()
435
+ declaredBy: z7.string().optional()
167
436
  }).describe(
168
437
  "Resolved options applicable to actions that may take place after DECLARE, with location ID and user ID instead of filters."
169
438
  );
170
439
  var ResolvedScopeOptionsFull = ResolvedScopeOptionsDeclared.extend({
171
440
  registeredIn: UUID.nullish(),
172
- registeredBy: z2.string().optional()
441
+ registeredBy: z7.string().optional(),
442
+ flags: ContainsFlags.optional()
173
443
  }).describe(
174
444
  "Resolved options applicable to actions that may take place after REGISTER, with full filtering capabilities and location/user IDs instead of filters."
175
445
  );
@@ -182,7 +452,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
182
452
  "record.edit",
183
453
  "record.reject",
184
454
  "record.archive",
185
- "record.review-duplicates",
455
+ "record.unarchive",
186
456
  "record.register"
187
457
  ]);
188
458
  var ScopesWithFullOptions = RecordScopeTypeV2.extract([
@@ -190,41 +460,42 @@ var ScopesWithFullOptions = RecordScopeTypeV2.extract([
190
460
  "record.read",
191
461
  "record.request-correction",
192
462
  "record.correct",
193
- "record.unassign-others"
463
+ "record.unassign-others",
464
+ "record.review-duplicates"
194
465
  ]);
195
466
  var ScopeOptionsPrintCertifiedCopies = AllRecordScopeOptions.extend({
196
- templates: z2.preprocess(
467
+ templates: z7.preprocess(
197
468
  (val) => val === void 0 ? void 0 : [val].flat(),
198
- z2.array(z2.string()).optional()
469
+ z7.array(z7.string()).optional()
199
470
  ).describe(
200
471
  "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."
201
472
  )
202
473
  });
203
- var RecordScopeV2 = z2.discriminatedUnion("type", [
204
- z2.object({
474
+ var RecordScopeV2 = z7.discriminatedUnion("type", [
475
+ z7.object({
205
476
  type: ScopesWithPlaceEventOptions,
206
477
  options: scopeOptionsPlaceEvent.optional()
207
478
  }),
208
- z2.object({
479
+ z7.object({
209
480
  type: ScopesWithDeclaredOptions,
210
- options: scopeOptionsDeclared.optional()
481
+ options: scopeOptionsDeclaredOrNotified.optional()
211
482
  }),
212
- z2.object({
483
+ z7.object({
213
484
  type: ScopesWithFullOptions,
214
485
  options: AllRecordScopeOptions.optional()
215
486
  }),
216
- z2.object({
217
- type: z2.literal("record.custom-action"),
487
+ z7.object({
488
+ type: z7.literal("record.custom-action"),
218
489
  options: CustomActionScopeOptions.optional()
219
490
  }),
220
- z2.object({
221
- type: z2.literal("record.print-certified-copies"),
491
+ z7.object({
492
+ type: z7.literal("record.print-certified-copies"),
222
493
  options: ScopeOptionsPrintCertifiedCopies.optional()
223
494
  })
224
495
  ]).describe(
225
496
  "Scopes used to check user's permission to perform actions on a record."
226
497
  );
227
- var SystemScopeType = z2.enum([
498
+ var SystemScopeType = z7.enum([
228
499
  "organisation.read-locations",
229
500
  "user.read",
230
501
  "user.create",
@@ -238,221 +509,115 @@ var UserScopeType = SystemScopeType.extract([
238
509
  "user.search"
239
510
  ]);
240
511
  var ScopesWithRoleOption = UserScopeType.extract(["user.edit", "user.create"]);
241
- var UserScopeV2 = z2.discriminatedUnion("type", [
242
- z2.object({
512
+ var UserScopeV2 = z7.discriminatedUnion("type", [
513
+ z7.object({
243
514
  type: ScopesWithRoleOption,
244
515
  options: AllUserScopeOptions.optional()
245
516
  }),
246
- z2.object({
517
+ z7.object({
247
518
  type: UserScopeType.extract(["user.read", "user.search"]),
248
519
  options: AccessLevelOptions.optional()
249
520
  })
250
521
  ]);
251
- var ResolvedRecordScopeV2 = z2.discriminatedUnion("type", [
252
- z2.object({
522
+ var ResolvedRecordScopeV2 = z7.discriminatedUnion("type", [
523
+ z7.object({
253
524
  type: ScopesWithPlaceEventOptions,
254
525
  options: ResolvedScopeOptionsPlaceEvent.optional()
255
526
  }),
256
- z2.object({
527
+ z7.object({
257
528
  type: ScopesWithDeclaredOptions,
258
529
  options: ResolvedScopeOptionsDeclared.optional()
259
530
  }),
260
- z2.object({
531
+ z7.object({
261
532
  type: ScopesWithFullOptions,
262
533
  options: ResolvedScopeOptionsFull.optional()
263
534
  }),
264
- z2.object({
265
- type: z2.literal("record.print-certified-copies"),
535
+ z7.object({
536
+ type: z7.literal("record.print-certified-copies"),
266
537
  options: ResolvedScopeOptionsFull.extend({
267
- templates: z2.array(z2.string()).optional()
538
+ templates: z7.array(z7.string()).optional()
268
539
  }).optional()
269
540
  })
270
541
  ]).describe("Resolved scope with location/user IDs instead of filters.");
271
- var Scope = z2.discriminatedUnion("type", [
272
- z2.object({ type: PlainScopeType }),
542
+ var Scope = z7.discriminatedUnion("type", [
543
+ z7.object({ type: PlainScopeType }),
273
544
  ...RecordScopeV2.options,
274
545
  ...UserScopeV2.options,
275
- z2.object({
276
- type: z2.literal("organisation.read-locations"),
546
+ z7.object({
547
+ type: z7.literal("organisation.read-locations"),
277
548
  options: AccessLevelOptions.optional()
278
549
  }),
279
- z2.object({
280
- type: z2.literal("workqueue"),
550
+ z7.object({
551
+ type: z7.literal("workqueue"),
281
552
  options: WorkqueueOrDashboardOptions
282
553
  }),
283
- z2.object({
284
- type: z2.literal("dashboard.view"),
554
+ z7.object({
555
+ type: z7.literal("dashboard.view"),
285
556
  options: WorkqueueOrDashboardOptions
286
557
  })
287
558
  ]);
288
- var ScopeType = z2.enum([
559
+ var ScopeType = z7.enum([
289
560
  ...SystemScopeType.options,
290
561
  ...RecordScopeTypeV2.options,
291
562
  ...PlainScopeType.options,
292
563
  "workqueue",
293
564
  "dashboard.view"
294
565
  ]);
295
- var EncodedScope = z2.string().brand("EncodedScope");
566
+ var EncodedScope = z7.string().brand("EncodedScope");
296
567
  var DEFAULT_SCOPE_OPTIONS = {
297
568
  placeOfEvent: JurisdictionFilter.enum.all,
298
569
  accessLevel: JurisdictionFilter.enum.all,
299
- registeredIn: JurisdictionFilter.enum.all,
300
- declaredIn: JurisdictionFilter.enum.all
570
+ notifiedIn: JurisdictionFilter.enum.all,
571
+ declaredIn: JurisdictionFilter.enum.all,
572
+ registeredIn: JurisdictionFilter.enum.all
301
573
  };
302
574
 
303
575
  // ../commons/src/authentication.ts
304
- var TokenUserType = z3.enum(["user", "system"]);
305
- var TokenWithBearer = z3.string().regex(/^Bearer\s/);
306
-
307
- // ../commons/src/events/ActionType.ts
308
- var z4 = __toESM(require("zod/v4"));
309
- var ActionType = {
310
- // Pre-declaration actions
311
- DELETE: "DELETE",
312
- CREATE: "CREATE",
313
- NOTIFY: "NOTIFY",
314
- // Declaration actions
315
- DECLARE: "DECLARE",
316
- REGISTER: "REGISTER",
317
- EDIT: "EDIT",
318
- // Declaration system actions. Non-configurable.
319
- DUPLICATE_DETECTED: "DUPLICATE_DETECTED",
320
- REJECT: "REJECT",
321
- // REJECT_DECLARATION
322
- MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
323
- MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
324
- ARCHIVE: "ARCHIVE",
325
- // Record actions
326
- PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
327
- REQUEST_CORRECTION: "REQUEST_CORRECTION",
328
- REJECT_CORRECTION: "REJECT_CORRECTION",
329
- APPROVE_CORRECTION: "APPROVE_CORRECTION",
330
- // General actions
331
- READ: "READ",
332
- ASSIGN: "ASSIGN",
333
- UNASSIGN: "UNASSIGN",
334
- // Custom action
335
- CUSTOM: "CUSTOM"
336
- };
337
- var ConfirmableActions = [
338
- ActionType.NOTIFY,
339
- ActionType.DECLARE,
340
- ActionType.EDIT,
341
- ActionType.REGISTER,
342
- ActionType.REJECT,
343
- ActionType.ARCHIVE,
344
- ActionType.PRINT_CERTIFICATE,
345
- ActionType.REQUEST_CORRECTION,
346
- ActionType.APPROVE_CORRECTION,
347
- ActionType.REJECT_CORRECTION,
348
- ActionType.CUSTOM
349
- ];
350
- var ActionTypes = z4.enum([
351
- "DELETE",
352
- "CREATE",
353
- "NOTIFY",
354
- "DECLARE",
355
- "EDIT",
356
- "REGISTER",
357
- "DUPLICATE_DETECTED",
358
- "REJECT",
359
- "MARK_AS_DUPLICATE",
360
- "MARK_AS_NOT_DUPLICATE",
361
- "ARCHIVE",
362
- "PRINT_CERTIFICATE",
363
- "REQUEST_CORRECTION",
364
- "REJECT_CORRECTION",
365
- "APPROVE_CORRECTION",
366
- "READ",
367
- "ASSIGN",
368
- "UNASSIGN",
369
- "CUSTOM"
370
- ]);
371
- var ClientSpecificAction = {
372
- REVIEW_CORRECTION_REQUEST: "REVIEW_CORRECTION_REQUEST"
373
- };
374
- var declarationActionValues = [
375
- ActionTypes.enum.DECLARE,
376
- ActionTypes.enum.EDIT,
377
- ActionTypes.enum.REGISTER,
378
- ActionTypes.enum.NOTIFY,
379
- ActionTypes.enum.DUPLICATE_DETECTED
380
- ];
381
- var DeclarationActions = ActionTypes.extract(declarationActionValues);
382
- var declarationUpdateActionValues = [
383
- ...declarationActionValues,
384
- ActionTypes.enum.REQUEST_CORRECTION
385
- ];
386
- var DeclarationUpdateActions = ActionTypes.extract(
387
- declarationUpdateActionValues
388
- );
389
- var annotationActions = ActionTypes.exclude(declarationActionValues);
390
- var writeActions = ActionTypes.exclude([
391
- ActionType.CREATE,
392
- ActionType.READ,
393
- ActionType.ASSIGN,
394
- ActionType.UNASSIGN
395
- ]);
396
- var WorkqueueActionType = ActionTypes.extract([
397
- ActionType.READ,
398
- ActionType.DELETE,
399
- ActionType.DECLARE,
400
- ActionType.REGISTER,
401
- ActionType.EDIT,
402
- ActionType.REJECT,
403
- ActionType.MARK_AS_DUPLICATE,
404
- ActionType.ARCHIVE,
405
- ActionType.PRINT_CERTIFICATE,
406
- ActionType.REQUEST_CORRECTION
407
- ]);
408
- var META_ACTIONS = [
409
- ActionType.ASSIGN,
410
- ActionType.UNASSIGN,
411
- ActionType.READ
412
- ];
576
+ var TokenUserType = z8.enum(["user", "system"]);
577
+ var TokenWithBearer = z8.string().regex(/^Bearer\s/);
413
578
 
414
579
  // ../commons/src/events/AuditLog.ts
415
- var AuditLogEntryBase = z5.object({
416
- id: z5.string(),
417
- clientId: z5.string(),
580
+ var AuditLogEntryBase = z9.object({
581
+ id: z9.string(),
582
+ clientId: z9.string(),
418
583
  clientType: TokenUserType,
419
- createdAt: z5.string()
584
+ createdAt: z9.string()
420
585
  });
421
586
  var EventCreateEntrySchema = AuditLogEntryBase.extend({
422
- operation: z5.literal("event.create"),
423
- requestData: z5.object({
424
- transactionId: z5.string(),
425
- type: z5.string(),
426
- createdAtLocation: z5.string().nullable()
587
+ operation: z9.literal("event.create"),
588
+ requestData: z9.object({
589
+ transactionId: z9.string(),
590
+ type: z9.string(),
591
+ createdAtLocation: z9.string().nullable()
427
592
  }),
428
- responseSummary: z5.object({
429
- eventId: z5.string(),
430
- trackingId: z5.string()
593
+ responseSummary: z9.object({
594
+ eventId: z9.string(),
595
+ trackingId: z9.string()
431
596
  })
432
597
  });
433
598
  var EventGetEntrySchema = AuditLogEntryBase.extend({
434
- operation: z5.literal("event.get"),
435
- requestData: z5.object({ eventId: z5.string() }),
436
- responseSummary: z5.object({
437
- eventType: z5.string(),
438
- trackingId: z5.string()
599
+ operation: z9.literal("event.get"),
600
+ requestData: z9.object({ eventId: z9.string() }),
601
+ responseSummary: z9.object({
602
+ eventType: z9.string(),
603
+ trackingId: z9.string()
439
604
  })
440
605
  });
441
606
  var EventSearchEntrySchema = AuditLogEntryBase.extend({
442
- operation: z5.literal("event.search"),
443
- clientType: z5.literal("system"),
444
- requestData: z5.object({
445
- query: z5.record(z5.string(), z5.unknown()).nullable(),
446
- limit: z5.number().nullable(),
447
- offset: z5.number().nullable()
607
+ operation: z9.literal("event.search"),
608
+ clientType: z9.literal("system"),
609
+ requestData: z9.object({
610
+ query: z9.record(z9.string(), z9.unknown()).nullable(),
611
+ limit: z9.number().nullable(),
612
+ offset: z9.number().nullable()
448
613
  }),
449
- responseSummary: z5.object({
450
- total: z5.number(),
451
- eventIds: z5.array(z5.string())
614
+ responseSummary: z9.object({
615
+ total: z9.number(),
616
+ eventIds: z9.array(z9.string())
452
617
  })
453
618
  });
454
619
  var EventActionEntrySchema = AuditLogEntryBase.extend({
455
- operation: z5.enum([
620
+ operation: z9.enum([
456
621
  "event.actions.notify.request",
457
622
  "event.actions.declare.request",
458
623
  "event.actions.register.request",
@@ -463,6 +628,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
463
628
  "event.actions.unassign.request",
464
629
  "event.actions.read.request",
465
630
  "event.actions.archive.request",
631
+ "event.actions.unarchive.request",
466
632
  "event.actions.reinstate.request",
467
633
  "event.actions.print_certificate.request",
468
634
  "event.actions.correction.request.request",
@@ -471,83 +637,159 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
471
637
  "event.actions.mark_as_duplicate.request",
472
638
  "event.actions.mark_as_not_duplicate.request"
473
639
  ]),
474
- requestData: z5.object({
475
- eventId: z5.string(),
476
- actionType: z5.string(),
477
- eventType: z5.string(),
478
- trackingId: z5.string(),
479
- transactionId: z5.string()
640
+ requestData: z9.object({
641
+ eventId: z9.string(),
642
+ actionType: z9.string(),
643
+ eventType: z9.string(),
644
+ trackingId: z9.string(),
645
+ transactionId: z9.string()
480
646
  })
481
647
  });
482
648
  var EventCustomActionEntrySchema = AuditLogEntryBase.extend({
483
- operation: z5.literal("event.actions.custom.request"),
484
- requestData: z5.object({
485
- eventId: z5.string(),
486
- actionType: z5.literal(ActionType.CUSTOM),
487
- customAction: z5.string(),
488
- eventType: z5.string(),
489
- trackingId: z5.string(),
490
- transactionId: z5.string()
649
+ operation: z9.literal("event.actions.custom.request"),
650
+ requestData: z9.object({
651
+ eventId: z9.string(),
652
+ actionType: z9.literal(ActionType.CUSTOM),
653
+ customAction: z9.string(),
654
+ eventType: z9.string(),
655
+ trackingId: z9.string(),
656
+ transactionId: z9.string()
491
657
  })
492
658
  });
493
659
  var IntegrationCreateEntrySchema = AuditLogEntryBase.extend({
494
- operation: z5.literal("integrations.create"),
495
- requestData: z5.object({ name: z5.string(), scopes: z5.array(z5.string()) }),
496
- responseSummary: z5.object({ clientId: z5.string() })
660
+ operation: z9.literal("integrations.create"),
661
+ requestData: z9.object({ name: z9.string(), scopes: z9.array(z9.string()) }),
662
+ responseSummary: z9.object({ clientId: z9.string() })
497
663
  });
498
664
  var IntegrationRefreshTokenEntrySchema = AuditLogEntryBase.extend({
499
- operation: z5.literal("integrations.refreshToken"),
500
- requestData: z5.object({ clientId: z5.string() }),
501
- responseSummary: z5.object({ clientId: z5.string() })
665
+ operation: z9.literal("integrations.refreshToken"),
666
+ requestData: z9.object({ clientId: z9.string() }),
667
+ responseSummary: z9.object({ clientId: z9.string() })
502
668
  });
503
669
  var IntegrationDeactivateEntrySchema = AuditLogEntryBase.extend({
504
- operation: z5.literal("integrations.deactivate"),
505
- requestData: z5.object({ id: z5.string() }),
506
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
670
+ operation: z9.literal("integrations.deactivate"),
671
+ requestData: z9.object({ id: z9.string() }),
672
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
507
673
  });
508
674
  var IntegrationActivateEntrySchema = AuditLogEntryBase.extend({
509
- operation: z5.literal("integrations.activate"),
510
- requestData: z5.object({ id: z5.string() }),
511
- responseSummary: z5.object({ id: z5.string(), status: z5.string() })
675
+ operation: z9.literal("integrations.activate"),
676
+ requestData: z9.object({ id: z9.string() }),
677
+ responseSummary: z9.object({ id: z9.string(), status: z9.string() })
512
678
  });
513
679
  var IntegrationDeleteEntrySchema = AuditLogEntryBase.extend({
514
- operation: z5.literal("integrations.delete"),
515
- requestData: z5.object({ id: z5.string() }),
516
- responseSummary: z5.object({ id: z5.string(), name: z5.string() })
680
+ operation: z9.literal("integrations.delete"),
681
+ requestData: z9.object({ id: z9.string() }),
682
+ responseSummary: z9.object({ id: z9.string(), name: z9.string() })
517
683
  });
518
684
  var IntegrationRefreshSecretEntrySchema = AuditLogEntryBase.extend({
519
- operation: z5.literal("integrations.refreshSecret"),
520
- requestData: z5.object({ id: z5.string() }),
521
- responseSummary: z5.object({ clientId: z5.string() })
685
+ operation: z9.literal("integrations.refreshSecret"),
686
+ requestData: z9.object({ id: z9.string() }),
687
+ responseSummary: z9.object({ clientId: z9.string() })
688
+ });
689
+ var createdVersionFields = {
690
+ id: z9.string(),
691
+ versionId: z9.string(),
692
+ name: z9.string(),
693
+ externalId: z9.string().nullish(),
694
+ effectiveFrom: z9.string(),
695
+ status: z9.string()
696
+ };
697
+ var LocationCreateEntrySchema = AuditLogEntryBase.extend({
698
+ operation: z9.literal("locations.create"),
699
+ requestData: z9.object({
700
+ ...createdVersionFields,
701
+ administrativeAreaId: z9.string().nullish(),
702
+ locationType: z9.string().nullish()
703
+ })
704
+ });
705
+ var AdministrativeAreaCreateEntrySchema = AuditLogEntryBase.extend({
706
+ operation: z9.literal("administrativeAreas.create"),
707
+ requestData: z9.object({
708
+ ...createdVersionFields,
709
+ parentId: z9.string().nullish()
710
+ })
711
+ });
712
+ var ChangedStringField = z9.object({ from: z9.string(), to: z9.string() });
713
+ var ChangedNullableStringField = z9.object({
714
+ from: z9.string().nullable(),
715
+ to: z9.string().nullable()
716
+ });
717
+ var updatedVersionRequestData = z9.object({
718
+ id: z9.string(),
719
+ versionId: z9.string(),
720
+ name: z9.string(),
721
+ externalId: z9.string().nullish(),
722
+ status: z9.string(),
723
+ effectiveFrom: z9.string(),
724
+ lastVersionId: z9.string()
725
+ });
726
+ var updatedVersionResponseSummary = z9.object({
727
+ previousVersionId: z9.string(),
728
+ versionId: z9.string(),
729
+ changed: z9.object({
730
+ name: ChangedStringField.optional(),
731
+ externalId: ChangedNullableStringField.optional(),
732
+ status: ChangedStringField.optional()
733
+ })
734
+ });
735
+ var LocationUpdateEntrySchema = AuditLogEntryBase.extend({
736
+ operation: z9.literal("locations.update"),
737
+ requestData: updatedVersionRequestData,
738
+ responseSummary: updatedVersionResponseSummary
739
+ });
740
+ var AdministrativeAreaUpdateEntrySchema = AuditLogEntryBase.extend({
741
+ operation: z9.literal("administrativeAreas.update"),
742
+ requestData: updatedVersionRequestData,
743
+ responseSummary: updatedVersionResponseSummary
744
+ });
745
+ var withdrawVersionRequestData = z9.object({
746
+ id: z9.string(),
747
+ versionId: z9.string()
748
+ });
749
+ var withdrawVersionResponseSummary = z9.object({
750
+ effectiveFrom: z9.string(),
751
+ name: z9.string(),
752
+ externalId: z9.string().nullish(),
753
+ status: z9.string()
754
+ });
755
+ var LocationWithdrawEntrySchema = AuditLogEntryBase.extend({
756
+ operation: z9.literal("locations.withdrawVersion"),
757
+ requestData: withdrawVersionRequestData,
758
+ responseSummary: withdrawVersionResponseSummary
759
+ });
760
+ var AdministrativeAreaWithdrawEntrySchema = AuditLogEntryBase.extend({
761
+ operation: z9.literal("administrativeAreas.withdrawVersion"),
762
+ requestData: withdrawVersionRequestData,
763
+ responseSummary: withdrawVersionResponseSummary
522
764
  });
523
765
  var AttachmentUploadEntrySchema = AuditLogEntryBase.extend({
524
- operation: z5.literal("attachments.upload"),
525
- requestData: z5.object({
526
- transactionId: z5.string(),
527
- path: z5.string().nullable()
766
+ operation: z9.literal("attachments.upload"),
767
+ requestData: z9.object({
768
+ transactionId: z9.string(),
769
+ path: z9.string().nullable()
528
770
  }),
529
- responseSummary: z5.object({ fileUrl: z5.string() })
771
+ responseSummary: z9.object({ fileUrl: z9.string() })
530
772
  });
531
- var subjectOnly = z5.object({ subjectId: z5.string() });
532
- var subjectWithReason = z5.object({
533
- subjectId: z5.string(),
534
- reason: z5.string(),
535
- comment: z5.string().optional()
773
+ var subjectOnly = z9.object({ subjectId: z9.string() });
774
+ var subjectWithReason = z9.object({
775
+ subjectId: z9.string(),
776
+ reason: z9.string(),
777
+ comment: z9.string().optional()
536
778
  });
537
779
  var UserCreateEntrySchema = AuditLogEntryBase.extend({
538
- operation: z5.literal("user.create_user"),
539
- requestData: z5.object({
540
- subjectId: z5.string(),
541
- role: z5.string(),
542
- primaryOfficeId: z5.string()
780
+ operation: z9.literal("user.create_user"),
781
+ requestData: z9.object({
782
+ subjectId: z9.string(),
783
+ role: z9.string(),
784
+ primaryOfficeId: z9.string()
543
785
  })
544
786
  });
545
787
  var UserReasonEntrySchema = AuditLogEntryBase.extend({
546
- operation: z5.enum(["user.deactivate", "user.reactivate"]),
788
+ operation: z9.enum(["user.deactivate", "user.reactivate"]),
547
789
  requestData: subjectWithReason
548
790
  });
549
791
  var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
550
- operation: z5.enum([
792
+ operation: z9.enum([
551
793
  "user.edit_user",
552
794
  "user.logged_in",
553
795
  "user.logged_out",
@@ -561,14 +803,14 @@ var UserSubjectOnlyEntrySchema = AuditLogEntryBase.extend({
561
803
  requestData: subjectOnly
562
804
  });
563
805
  var UserEmailChangedEntrySchema = AuditLogEntryBase.extend({
564
- operation: z5.literal("user.email_address_changed"),
806
+ operation: z9.literal("user.email_address_changed"),
565
807
  requestData: subjectOnly,
566
- responseSummary: z5.object({ email: z5.string() })
808
+ responseSummary: z9.object({ email: z9.string() })
567
809
  });
568
810
  var UserPhoneChangedEntrySchema = AuditLogEntryBase.extend({
569
- operation: z5.literal("user.phone_number_changed"),
811
+ operation: z9.literal("user.phone_number_changed"),
570
812
  requestData: subjectOnly,
571
- responseSummary: z5.object({ phoneNumber: z5.string() })
813
+ responseSummary: z9.object({ phoneNumber: z9.string() })
572
814
  });
573
815
  var userBaseOmit = {
574
816
  id: true,
@@ -576,14 +818,14 @@ var userBaseOmit = {
576
818
  clientType: true,
577
819
  createdAt: true
578
820
  };
579
- var UserAuditRecordInput = z5.discriminatedUnion("operation", [
821
+ var UserAuditRecordInput = z9.discriminatedUnion("operation", [
580
822
  UserCreateEntrySchema.omit(userBaseOmit),
581
823
  UserReasonEntrySchema.omit(userBaseOmit),
582
824
  UserSubjectOnlyEntrySchema.omit(userBaseOmit),
583
825
  UserEmailChangedEntrySchema.omit(userBaseOmit),
584
826
  UserPhoneChangedEntrySchema.omit(userBaseOmit)
585
827
  ]);
586
- var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
828
+ var AuditLogEntrySchema = z9.discriminatedUnion("operation", [
587
829
  EventCreateEntrySchema,
588
830
  EventGetEntrySchema,
589
831
  EventSearchEntrySchema,
@@ -595,6 +837,12 @@ var AuditLogEntrySchema = z5.discriminatedUnion("operation", [
595
837
  IntegrationActivateEntrySchema,
596
838
  IntegrationDeleteEntrySchema,
597
839
  IntegrationRefreshSecretEntrySchema,
840
+ LocationCreateEntrySchema,
841
+ LocationUpdateEntrySchema,
842
+ AdministrativeAreaUpdateEntrySchema,
843
+ LocationWithdrawEntrySchema,
844
+ AdministrativeAreaWithdrawEntrySchema,
845
+ AdministrativeAreaCreateEntrySchema,
598
846
  AttachmentUploadEntrySchema,
599
847
  UserCreateEntrySchema,
600
848
  UserReasonEntrySchema,
@@ -608,78 +856,13 @@ var TENNIS_CLUB_MEMBERSHIP = "tennis-club-membership";
608
856
  var CHILD_ONBOARDING_EVENT = "child-onboarding";
609
857
 
610
858
  // ../commons/src/events/ActionConfig.ts
611
- var z24 = __toESM(require("zod/v4"));
612
-
613
- // ../commons/src/events/TranslationConfig.ts
614
- var z6 = __toESM(require("zod/v4"));
615
- var TranslationConfig = z6.object({
616
- id: z6.string().describe(
617
- "The identifier of the translation referred in translation CSV files"
618
- ),
619
- defaultMessage: z6.string().describe("Default translation message"),
620
- description: z6.string().describe(
621
- "Describe the translation for a translator to be able to identify it."
622
- )
623
- }).meta({
624
- description: "Translation configuration",
625
- id: "TranslationConfig"
626
- });
859
+ var z25 = __toESM(require("zod/v4"));
627
860
 
628
861
  // ../commons/src/events/FieldConfig.ts
629
862
  var import_v43 = __toESM(require("zod/v4"));
630
863
 
631
- // ../commons/src/events/Conditional.ts
632
- var z7 = __toESM(require("zod/v4"));
633
- var Conditional = z7.any().describe("JSONSchema").meta({
634
- description: "JSON schema conditional configuration",
635
- id: "Conditional"
636
- });
637
- var ConditionalType = {
638
- SHOW: "SHOW",
639
- ENABLE: "ENABLE",
640
- DISPLAY_ON_REVIEW: "DISPLAY_ON_REVIEW"
641
- };
642
- var ShowConditional = z7.object({
643
- type: z7.literal(ConditionalType.SHOW),
644
- conditional: Conditional
645
- }).describe(
646
- "If 'SHOW' conditional is defined, the component is shown to the user only if the condition is met"
647
- );
648
- var EnableConditional = z7.object({
649
- type: z7.literal(ConditionalType.ENABLE),
650
- conditional: Conditional
651
- }).describe(
652
- "If 'ENABLE' conditional is defined, the component is enabled only if the condition is met"
653
- );
654
- var ActionConditional = z7.discriminatedUnion("type", [
655
- // Action can be shown / hidden
656
- ShowConditional,
657
- // Action can be shown to the user in the list but as disabled
658
- EnableConditional
659
- ]).meta({
660
- id: "ActionConditional",
661
- 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."
662
- });
663
- var DisplayOnReviewConditional = z7.object({
664
- type: z7.literal(ConditionalType.DISPLAY_ON_REVIEW),
665
- conditional: Conditional
666
- }).describe(
667
- "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."
668
- );
669
- var FieldConditional = z7.discriminatedUnion("type", [
670
- // Field input can be shown / hidden
671
- ShowConditional,
672
- // Field input can be shown to the user but as disabled
673
- EnableConditional,
674
- // Field output can be shown / hidden on the review page
675
- DisplayOnReviewConditional
676
- ]).meta({
677
- id: "FieldConditional",
678
- 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."
679
- });
680
-
681
864
  // ../commons/src/events/FieldType.ts
682
- var z8 = __toESM(require("zod/v4"));
865
+ var z10 = __toESM(require("zod/v4"));
683
866
  var FieldType = {
684
867
  NAME: "NAME",
685
868
  PHONE: "PHONE",
@@ -743,7 +926,7 @@ var FieldType = {
743
926
  */
744
927
  _EXPERIMENTAL_CUSTOM: "CUSTOM"
745
928
  };
746
- var FileFieldType = z8.enum([
929
+ var FileFieldType = z10.enum([
747
930
  FieldType.FILE,
748
931
  FieldType.FILE_WITH_OPTIONS,
749
932
  FieldType.SIGNATURE
@@ -779,160 +962,160 @@ var HiddenFieldTypes = [
779
962
  ];
780
963
 
781
964
  // ../commons/src/events/FieldValue.ts
782
- var z12 = __toESM(require("zod/v4"));
965
+ var z14 = __toESM(require("zod/v4"));
783
966
 
784
967
  // ../commons/src/documents.ts
785
- var z9 = __toESM(require("zod/v4"));
786
- var FullDocumentUrl = z9.string().brand("FullDocumentUrl").describe(
968
+ var z11 = __toESM(require("zod/v4"));
969
+ var FullDocumentUrl = z11.string().brand("FullDocumentUrl").describe(
787
970
  "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"
788
971
  );
789
- var FullDocumentPath = z9.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
972
+ var FullDocumentPath = z11.string().overwrite((val) => val.startsWith("/") ? val : `/${val}`).meta({ effectType: "input", type: "string" }).describe(
790
973
  "A full absolute path with bucket name, starting from the root of the S3 server, /bucket-name/document-id.jpg"
791
974
  );
792
- var DocumentPath = z9.string().brand("DocumentPath").describe(
975
+ var DocumentPath = z11.string().brand("DocumentPath").describe(
793
976
  "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."
794
977
  );
795
978
 
796
979
  // ../commons/src/events/CompositeFieldValue.ts
797
- var z10 = __toESM(require("zod/v4"));
980
+ var z12 = __toESM(require("zod/v4"));
798
981
  var AddressType = {
799
982
  DOMESTIC: "DOMESTIC",
800
983
  INTERNATIONAL: "INTERNATIONAL"
801
984
  };
802
- var FileFieldValue = z10.object({
985
+ var FileFieldValue = z12.object({
803
986
  path: DocumentPath,
804
- originalFilename: z10.string(),
805
- type: z10.string()
806
- });
807
- var NameFieldValue = z10.object({
808
- firstname: z10.string(),
809
- surname: z10.string(),
810
- middlename: z10.string().optional()
811
- });
812
- var NameFieldUpdateValue = z10.object({
813
- firstname: z10.string().nullish(),
814
- surname: z10.string().nullish(),
815
- middlename: z10.string().nullish()
816
- }).or(z10.null()).or(z10.undefined());
817
- var StreetLevelDetailsValue = z10.record(z10.string(), z10.string()).optional();
818
- var StreetLevelDetailsUpdateValue = z10.record(z10.string(), z10.string().nullable()).nullish();
819
- var BaseAddressFieldValue = z10.object({
820
- country: z10.string(),
987
+ originalFilename: z12.string(),
988
+ type: z12.string()
989
+ });
990
+ var NameFieldValue = z12.object({
991
+ firstname: z12.string(),
992
+ surname: z12.string(),
993
+ middlename: z12.string().optional()
994
+ });
995
+ var NameFieldUpdateValue = z12.object({
996
+ firstname: z12.string().nullish(),
997
+ surname: z12.string().nullish(),
998
+ middlename: z12.string().nullish()
999
+ }).or(z12.null()).or(z12.undefined());
1000
+ var StreetLevelDetailsValue = z12.record(z12.string(), z12.string()).optional();
1001
+ var StreetLevelDetailsUpdateValue = z12.record(z12.string(), z12.string().nullable()).nullish();
1002
+ var BaseAddressFieldValue = z12.object({
1003
+ country: z12.string(),
821
1004
  streetLevelDetails: StreetLevelDetailsValue
822
1005
  });
823
- var BaseAddressFieldUpdateValue = z10.object({
824
- country: z10.string().nullish(),
1006
+ var BaseAddressFieldUpdateValue = z12.object({
1007
+ country: z12.string().nullish(),
825
1008
  streetLevelDetails: StreetLevelDetailsUpdateValue
826
1009
  });
827
1010
  var DomesticAddressFieldValue = BaseAddressFieldValue.extend({
828
- addressType: z10.literal(AddressType.DOMESTIC),
829
- administrativeArea: z10.string().uuid()
1011
+ addressType: z12.literal(AddressType.DOMESTIC),
1012
+ administrativeArea: z12.string().uuid()
830
1013
  });
831
1014
  var InternationalAddressFieldValue = BaseAddressFieldValue.extend({
832
- addressType: z10.literal(AddressType.INTERNATIONAL)
1015
+ addressType: z12.literal(AddressType.INTERNATIONAL)
833
1016
  });
834
- var AddressFieldValue = z10.discriminatedUnion("addressType", [
1017
+ var AddressFieldValue = z12.discriminatedUnion("addressType", [
835
1018
  DomesticAddressFieldValue,
836
1019
  InternationalAddressFieldValue
837
1020
  ]);
838
1021
  var DomesticAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend({
839
- addressType: z10.literal(AddressType.DOMESTIC),
840
- administrativeArea: z10.string().uuid().nullish()
1022
+ addressType: z12.literal(AddressType.DOMESTIC),
1023
+ administrativeArea: z12.string().uuid().nullish()
841
1024
  /* Leaf level admin structure */
842
1025
  });
843
1026
  var InternationalAddressUpdateFieldValue = BaseAddressFieldUpdateValue.extend(
844
1027
  {
845
- addressType: z10.literal(AddressType.INTERNATIONAL)
1028
+ addressType: z12.literal(AddressType.INTERNATIONAL)
846
1029
  }
847
1030
  );
848
- var AddressFieldUpdateValue = z10.discriminatedUnion("addressType", [
1031
+ var AddressFieldUpdateValue = z12.discriminatedUnion("addressType", [
849
1032
  DomesticAddressUpdateFieldValue,
850
1033
  InternationalAddressUpdateFieldValue
851
1034
  ]).nullish();
852
- var FileFieldValueWithOption = z10.object({
1035
+ var FileFieldValueWithOption = z12.object({
853
1036
  path: DocumentPath,
854
- originalFilename: z10.string(),
855
- type: z10.string(),
856
- option: z10.string()
857
- });
858
- var FileFieldWithOptionValue = z10.array(FileFieldValueWithOption);
859
- var HttpFieldValue = z10.object({
860
- loading: z10.boolean(),
861
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
862
- data: z10.any()
863
- });
864
- var HttpFieldUpdateValue = z10.object({
865
- loading: z10.boolean().nullish(),
866
- error: z10.object({ statusCode: z10.number(), message: z10.string() }).nullish(),
867
- data: z10.any().nullish()
868
- }).or(z10.null()).or(z10.undefined());
869
- var QueryParamReaderFieldValue = z10.object({
870
- data: z10.record(z10.string(), z10.string()),
871
- updatedAt: z10.iso.datetime()
1037
+ originalFilename: z12.string(),
1038
+ type: z12.string(),
1039
+ option: z12.string()
1040
+ });
1041
+ var FileFieldWithOptionValue = z12.array(FileFieldValueWithOption);
1042
+ var HttpFieldValue = z12.object({
1043
+ loading: z12.boolean(),
1044
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1045
+ data: z12.any()
1046
+ });
1047
+ var HttpFieldUpdateValue = z12.object({
1048
+ loading: z12.boolean().nullish(),
1049
+ error: z12.object({ statusCode: z12.number(), message: z12.string() }).nullish(),
1050
+ data: z12.any().nullish()
1051
+ }).or(z12.null()).or(z12.undefined());
1052
+ var QueryParamReaderFieldValue = z12.object({
1053
+ data: z12.record(z12.string(), z12.string()),
1054
+ updatedAt: z12.iso.datetime()
872
1055
  }).nullish();
873
- var QueryParamReaderFieldUpdateValue = z10.object({
874
- data: z10.record(z10.string(), z10.string())
1056
+ var QueryParamReaderFieldUpdateValue = z12.object({
1057
+ data: z12.record(z12.string(), z12.string())
875
1058
  });
876
- var ReadDataValue = z10.object({
877
- data: z10.any()
1059
+ var ReadDataValue = z12.object({
1060
+ data: z12.any()
878
1061
  });
879
1062
  var QrReaderFieldValue = ReadDataValue;
880
1063
  var IdReaderFieldValue = ReadDataValue;
881
- var NumberWithUnitFieldValue = z10.object({
882
- numericValue: z10.number(),
883
- unit: z10.string()
1064
+ var NumberWithUnitFieldValue = z12.object({
1065
+ numericValue: z12.number(),
1066
+ unit: z12.string()
884
1067
  });
885
- var NumberWithUnitFieldUpdateValue = z10.object({
886
- numericValue: z10.number().optional(),
887
- unit: z10.string().optional()
1068
+ var NumberWithUnitFieldUpdateValue = z12.object({
1069
+ numericValue: z12.number().optional(),
1070
+ unit: z12.string().optional()
888
1071
  });
889
- var CustomFieldValue = z10.unknown().brand("CustomFieldValue");
1072
+ var CustomFieldValue = z12.unknown().brand("CustomFieldValue");
890
1073
 
891
1074
  // ../commons/src/events/PlainDate.ts
892
1075
  var import_zod = require("zod");
893
1076
  var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date in the format YYYY-MM-DD");
894
1077
 
895
1078
  // ../commons/src/events/FieldValue.ts
896
- var TextValue = z12.string();
897
- var HiddenFieldValue = z12.string();
898
- var NonEmptyTextValue = z12.string().trim().min(1);
899
- var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
900
- var AgeValue = z12.object({
901
- age: z12.number(),
902
- asOfDateRef: z12.string()
1079
+ var TextValue = z14.string();
1080
+ var HiddenFieldValue = z14.string();
1081
+ var NonEmptyTextValue = z14.string().trim().min(1);
1082
+ var DateValue = z14.iso.date().describe("Date in the format YYYY-MM-DD");
1083
+ var AgeValue = z14.object({
1084
+ age: z14.number(),
1085
+ asOfDateRef: z14.string()
903
1086
  });
904
1087
  var AgeUpdateValue = AgeValue.optional().nullable();
905
- var AutocompleteValue = z12.object({
906
- label: z12.string(),
907
- value: z12.string()
1088
+ var AutocompleteValue = z14.object({
1089
+ label: z14.string(),
1090
+ value: z14.string()
908
1091
  });
909
1092
  var AutocompleteUpdateValue = AutocompleteValue.optional().nullable();
910
- var TimeValue = z12.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
911
- var DatetimeValue = z12.iso.datetime();
912
- var SelectDateRangeValue = z12.enum([
1093
+ var TimeValue = z14.string().regex(/^([01][0-9]|2[0-3]):[0-5][0-9]$/);
1094
+ var DatetimeValue = z14.iso.datetime();
1095
+ var SelectDateRangeValue = z14.enum([
913
1096
  "last7Days",
914
1097
  "last30Days",
915
1098
  "last90Days",
916
1099
  "last365Days"
917
1100
  ]);
918
- var DateRangeFieldValue = z12.object({
1101
+ var DateRangeFieldValue = z14.object({
919
1102
  start: PlainDate,
920
1103
  end: PlainDate
921
1104
  }).or(PlainDate).describe(
922
1105
  "Date range with start and end dates in the format YYYY-MM-DD. Inclusive start, exclusive end."
923
1106
  );
924
- var EmailValue = z12.email();
925
- var CheckboxFieldValue = z12.boolean();
926
- var NumberFieldValue = z12.number();
1107
+ var EmailValue = z14.email();
1108
+ var CheckboxFieldValue = z14.boolean();
1109
+ var NumberFieldValue = z14.number();
927
1110
  var SignatureFieldValue = FileFieldValue;
928
- var ButtonFieldValue = z12.number();
929
- var VerificationStatusValue = z12.enum([
1111
+ var ButtonFieldValue = z14.number();
1112
+ var VerificationStatusValue = z14.enum([
930
1113
  "verified",
931
1114
  "authenticated",
932
1115
  "failed",
933
1116
  "pending"
934
1117
  ]);
935
- var LeafFieldValues = z12.union([
1118
+ var LeafFieldValues = z14.union([
936
1119
  AddressFieldValue,
937
1120
  TextValue,
938
1121
  PlainDate,
@@ -958,11 +1141,11 @@ var LeafFieldValues = z12.union([
958
1141
  AutocompleteValue,
959
1142
  AutocompleteUpdateValue
960
1143
  ]);
961
- var FieldGroupValue = z12.record(z12.string(), LeafFieldValues);
962
- var DataFieldValue = z12.object({
963
- data: z12.record(z12.string(), LeafFieldValues)
1144
+ var FieldGroupValue = z14.record(z14.string(), LeafFieldValues);
1145
+ var DataFieldValue = z14.object({
1146
+ data: z14.record(z14.string(), LeafFieldValues)
964
1147
  }).nullish();
965
- var FieldValue = z12.union([
1148
+ var FieldValue = z14.union([
966
1149
  LeafFieldValues,
967
1150
  DataFieldValue,
968
1151
  FieldGroupValue
@@ -996,7 +1179,7 @@ function safeUnion(schemas) {
996
1179
  const sortedSchemas = [...schemas].sort(
997
1180
  (a, b) => schemaPriority(a) - schemaPriority(b)
998
1181
  );
999
- return z12.any().superRefine((val, ctx) => {
1182
+ return z14.any().superRefine((val, ctx) => {
1000
1183
  for (const schema of sortedSchemas) {
1001
1184
  if (schema.safeParse(val).success) {
1002
1185
  return;
@@ -1035,9 +1218,9 @@ var FieldUpdateValue = safeUnion([
1035
1218
  ]);
1036
1219
 
1037
1220
  // ../commons/src/events/serializers/user/serializer.ts
1038
- var z13 = __toESM(require("zod/v4"));
1039
- var SerializedUserField = z13.object({
1040
- $userField: z13.enum([
1221
+ var z15 = __toESM(require("zod/v4"));
1222
+ var SerializedUserField = z15.object({
1223
+ $userField: z15.enum([
1041
1224
  "id",
1042
1225
  "name",
1043
1226
  "role",
@@ -1051,7 +1234,7 @@ var SerializedUserField = z13.object({
1051
1234
  "primaryOfficeId",
1052
1235
  "administrativeAreaId"
1053
1236
  ]),
1054
- $location: z13.string().optional()
1237
+ $location: z15.string().optional()
1055
1238
  });
1056
1239
  function userSerializer(userField) {
1057
1240
  return {
@@ -1074,30 +1257,25 @@ function userSerializer(userField) {
1074
1257
  var import_v4 = require("zod/v4");
1075
1258
 
1076
1259
  // ../commons/src/events/EventMetadata.ts
1077
- var z16 = __toESM(require("zod/v4"));
1260
+ var z17 = __toESM(require("zod/v4"));
1078
1261
 
1079
1262
  // ../commons/src/events/ActionDocument.ts
1080
- var z14 = __toESM(require("zod/v4"));
1081
- var ActionUpdate = z14.record(z14.string(), FieldUpdateValue).describe(
1263
+ var z16 = __toESM(require("zod/v4"));
1264
+ var ActionUpdate = z16.record(z16.string(), FieldUpdateValue).describe(
1082
1265
  "Record of field-level changes made by an action. Supports partial updates and nullable values."
1083
1266
  );
1084
- var EventState = z14.record(z14.string(), FieldValue).describe(
1267
+ var EventState = z16.record(z16.string(), FieldValue).describe(
1085
1268
  "Aggregate representation of event data after all actions have been applied, with all updates consolidated and null values removed."
1086
1269
  );
1087
- var ActionStatus = {
1088
- Requested: "Requested",
1089
- Accepted: "Accepted",
1090
- Rejected: "Rejected"
1091
- };
1092
- var ActionBase = z14.object({
1270
+ var ActionBase = z16.object({
1093
1271
  id: UUID.describe("Unique identifier of the action."),
1094
- transactionId: z14.string().describe("Unique identifier of the transaction."),
1272
+ transactionId: z16.string().describe("Unique identifier of the transaction."),
1095
1273
  createdByUserType: TokenUserType.describe(
1096
1274
  "Indicates whether the action was created by a human-user or by a system-user."
1097
1275
  ),
1098
- createdAt: z14.string().datetime().describe("Timestamp indicating when the action was created."),
1099
- createdBy: z14.string().describe("Identifier of the user who created the action."),
1100
- createdByRole: z14.string().optional().describe("Role of the user who created the action."),
1276
+ createdAt: z16.string().datetime().describe("Timestamp indicating when the action was created."),
1277
+ createdBy: z16.string().describe("Identifier of the user who created the action."),
1278
+ createdByRole: z16.string().optional().describe("Role of the user who created the action."),
1101
1279
  createdBySignature: DocumentPath.nullish().describe(
1102
1280
  "Reference to the signature of the user who created the action."
1103
1281
  ),
@@ -1109,7 +1287,7 @@ var ActionBase = z14.object({
1109
1287
  "Declaration data defined by the ActionConfig. Supports partial updates."
1110
1288
  ),
1111
1289
  annotation: ActionUpdate.optional().nullable().describe("Action-specific metadata used to annotate the event."),
1112
- status: z14.enum([
1290
+ status: z16.enum([
1113
1291
  ActionStatus.Requested,
1114
1292
  ActionStatus.Accepted,
1115
1293
  ActionStatus.Rejected
@@ -1121,139 +1299,150 @@ var ActionBase = z14.object({
1121
1299
  )
1122
1300
  });
1123
1301
  var AssignedAction = ActionBase.extend(
1124
- z14.object({
1125
- type: z14.literal(ActionType.ASSIGN),
1126
- assignedTo: z14.string().describe("Identifier of the user to whom the action is assigned.")
1302
+ z16.object({
1303
+ type: z16.literal(ActionType.ASSIGN),
1304
+ assignedTo: z16.string().describe("Identifier of the user to whom the action is assigned.")
1127
1305
  // TODO move into 'content' property
1128
1306
  }).shape
1129
1307
  );
1130
1308
  var UnassignedAction = ActionBase.extend(
1131
- z14.object({
1132
- type: z14.literal(ActionType.UNASSIGN)
1309
+ z16.object({
1310
+ type: z16.literal(ActionType.UNASSIGN)
1133
1311
  }).shape
1134
1312
  );
1135
1313
  var RegisterAction = ActionBase.extend(
1136
- z14.object({
1137
- type: z14.literal(ActionType.REGISTER),
1138
- registrationNumber: z14.string().optional().describe(
1314
+ z16.object({
1315
+ type: z16.literal(ActionType.REGISTER),
1316
+ registrationNumber: z16.string().optional().describe(
1139
1317
  "Registration number of the event. Always present for accepted registrations."
1140
1318
  )
1141
1319
  // TODO move into 'content' property
1142
1320
  }).shape
1143
1321
  );
1144
1322
  var DeclareAction = ActionBase.extend(
1145
- z14.object({
1146
- type: z14.literal(ActionType.DECLARE)
1323
+ z16.object({
1324
+ type: z16.literal(ActionType.DECLARE)
1147
1325
  }).shape
1148
1326
  );
1149
- var ReasonContent = z14.object({
1150
- reason: z14.string().min(1, { error: "Message cannot be empty" }).describe(
1327
+ var ReasonContent = z16.object({
1328
+ reason: z16.string().min(1, { error: "Message cannot be empty" }).describe(
1151
1329
  "Message describing the reason for rejecting or archiving the event."
1152
1330
  )
1153
1331
  });
1154
1332
  var RejectAction = ActionBase.extend(
1155
- z14.object({
1156
- type: z14.literal(ActionType.REJECT),
1333
+ z16.object({
1334
+ type: z16.literal(ActionType.REJECT),
1157
1335
  content: ReasonContent
1158
1336
  }).shape
1159
1337
  );
1160
- var PotentialDuplicate = z14.object({
1338
+ var PotentialDuplicate = z16.object({
1161
1339
  id: UUID,
1162
- trackingId: z14.string()
1340
+ trackingId: z16.string()
1163
1341
  });
1164
1342
  var DuplicateDetectedAction = ActionBase.extend(
1165
- z14.object({
1166
- type: z14.literal(ActionType.DUPLICATE_DETECTED),
1167
- content: z14.object({
1168
- duplicates: z14.array(PotentialDuplicate)
1343
+ z16.object({
1344
+ type: z16.literal(ActionType.DUPLICATE_DETECTED),
1345
+ content: z16.object({
1346
+ duplicates: z16.array(PotentialDuplicate)
1169
1347
  })
1170
1348
  }).shape
1171
1349
  );
1172
1350
  var MarkNotDuplicateAction = ActionBase.extend(
1173
- z14.object({
1174
- type: z14.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1351
+ z16.object({
1352
+ type: z16.literal(ActionType.MARK_AS_NOT_DUPLICATE)
1175
1353
  }).shape
1176
1354
  );
1177
1355
  var MarkAsDuplicateAction = ActionBase.extend(
1178
- z14.object({
1179
- type: z14.literal(ActionType.MARK_AS_DUPLICATE),
1180
- content: z14.object({
1356
+ z16.object({
1357
+ type: z16.literal(ActionType.MARK_AS_DUPLICATE),
1358
+ content: z16.object({
1181
1359
  duplicateOf: UUID
1182
1360
  }).optional()
1183
1361
  }).shape
1184
1362
  );
1185
1363
  var ArchiveAction = ActionBase.extend(
1186
- z14.object({
1187
- type: z14.literal(ActionType.ARCHIVE),
1188
- content: ReasonContent
1364
+ z16.object({
1365
+ type: z16.literal(ActionType.ARCHIVE),
1366
+ /**
1367
+ * Archiving does not collect a reason on its own. Only the
1368
+ * "mark as duplicate" flow archives with a reason attached.
1369
+ */
1370
+ content: ReasonContent.optional()
1371
+ }).shape
1372
+ );
1373
+ var UnarchiveAction = ActionBase.extend(
1374
+ z16.object({
1375
+ type: z16.literal(ActionType.UNARCHIVE)
1189
1376
  }).shape
1190
1377
  );
1191
1378
  var CreatedAction = ActionBase.extend(
1192
- z14.object({
1193
- type: z14.literal(ActionType.CREATE)
1379
+ z16.object({
1380
+ type: z16.literal(ActionType.CREATE)
1194
1381
  }).shape
1195
1382
  );
1196
1383
  var NotifiedAction = ActionBase.extend(
1197
- z14.object({
1198
- type: z14.literal(ActionType.NOTIFY)
1384
+ z16.object({
1385
+ type: z16.literal(ActionType.NOTIFY)
1199
1386
  }).shape
1200
1387
  );
1201
1388
  var EditAction = ActionBase.extend(
1202
- z14.object({
1203
- type: z14.literal(ActionType.EDIT),
1204
- content: z14.object({
1205
- comment: z14.string().describe("Comment for the edit action.").optional()
1206
- })
1389
+ z16.object({
1390
+ type: z16.literal(ActionType.EDIT),
1391
+ /** @deprecated New Edit-actions should no longer contain content. This is kept for old 2.0 edits. */
1392
+ content: z16.object({
1393
+ comment: z16.string().describe("Comment for the edit action.").optional()
1394
+ }).optional()
1207
1395
  }).shape
1208
1396
  );
1209
- var PrintContent = z14.object({
1210
- templateId: z14.string().optional()
1397
+ var PrintContent = z16.object({
1398
+ templateId: z16.string().optional()
1211
1399
  });
1212
1400
  var PrintCertificateAction = ActionBase.extend(
1213
- z14.object({
1214
- type: z14.literal(ActionType.PRINT_CERTIFICATE),
1401
+ z16.object({
1402
+ type: z16.literal(ActionType.PRINT_CERTIFICATE),
1215
1403
  content: PrintContent.optional().nullable()
1216
1404
  }).shape
1217
1405
  );
1218
1406
  var RequestedCorrectionAction = ActionBase.extend(
1219
- z14.object({
1220
- type: z14.literal(ActionType.REQUEST_CORRECTION)
1407
+ z16.object({
1408
+ type: z16.literal(ActionType.REQUEST_CORRECTION)
1221
1409
  }).shape
1222
1410
  );
1223
1411
  var ApprovedCorrectionAction = ActionBase.extend(
1224
- z14.object({
1225
- type: z14.literal(ActionType.APPROVE_CORRECTION),
1226
- requestId: z14.string(),
1412
+ z16.object({
1413
+ type: z16.literal(ActionType.APPROVE_CORRECTION),
1414
+ requestId: z16.string(),
1227
1415
  // TODO move into 'content' property
1228
- content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1416
+ content: z16.object({ immediateCorrection: z16.boolean().optional() }).optional()
1229
1417
  }).shape
1230
1418
  );
1231
1419
  var RejectedCorrectionAction = ActionBase.extend(
1232
- z14.object({
1233
- type: z14.literal(ActionType.REJECT_CORRECTION),
1234
- requestId: z14.string(),
1420
+ z16.object({
1421
+ type: z16.literal(ActionType.REJECT_CORRECTION),
1422
+ requestId: z16.string(),
1235
1423
  // TODO move into 'content' property
1236
1424
  content: ReasonContent
1237
1425
  }).shape
1238
1426
  );
1239
1427
  var ReadAction = ActionBase.extend(
1240
- z14.object({
1241
- type: z14.literal(ActionType.READ)
1428
+ z16.object({
1429
+ type: z16.literal(ActionType.READ)
1242
1430
  }).shape
1243
1431
  );
1244
1432
  var CustomAction = ActionBase.merge(
1245
- z14.object({
1246
- type: z14.literal(ActionType.CUSTOM),
1247
- customActionType: z14.string()
1433
+ z16.object({
1434
+ type: z16.literal(ActionType.CUSTOM),
1435
+ customActionType: z16.string()
1248
1436
  })
1249
1437
  );
1250
- var ActionDocument = z14.discriminatedUnion("type", [
1438
+ var ActionDocument = z16.discriminatedUnion("type", [
1251
1439
  CreatedAction.meta({ id: "CreatedAction" }),
1252
1440
  RejectAction.meta({ id: "RejectAction" }),
1253
1441
  DuplicateDetectedAction.meta({ id: "DuplicateDetectedAction" }),
1254
1442
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1255
1443
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1256
1444
  ArchiveAction.meta({ id: "ArchiveAction" }),
1445
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1257
1446
  NotifiedAction.meta({ id: "NotifiedAction" }),
1258
1447
  RegisterAction.meta({ id: "RegisterAction" }),
1259
1448
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1273,108 +1462,50 @@ var AsyncRejectActionDocument = ActionBase.omit({
1273
1462
  declaration: true,
1274
1463
  annotation: true
1275
1464
  }).extend(
1276
- z14.object({
1277
- type: z14.enum(ConfirmableActions),
1278
- status: z14.literal(ActionStatus.Rejected)
1465
+ z16.object({
1466
+ type: z16.enum(ConfirmableActions),
1467
+ status: z16.literal(ActionStatus.Rejected)
1279
1468
  }).shape
1280
1469
  );
1281
- var Action = z14.union([ActionDocument, AsyncRejectActionDocument]);
1282
-
1283
- // ../commons/src/events/Flag.ts
1284
- var z15 = __toESM(require("zod/v4"));
1285
- var InherentFlags = {
1286
- INCOMPLETE: "incomplete",
1287
- REJECTED: "rejected",
1288
- CORRECTION_REQUESTED: "correction-requested",
1289
- POTENTIAL_DUPLICATE: "potential-duplicate",
1290
- /**
1291
- * This flag is set by the Edit-action and removed after the declaration or registration.
1292
- * A record should never stay with the EDIT_IN_PROGRESS flag, since it should always be declared or registered right after.
1293
- *
1294
- * We only use this flag to determine that a NOTIFY, DECLARE or REGISTER action is allowed next.
1295
- */
1296
- EDIT_IN_PROGRESS: "edit-in-progress"
1297
- };
1298
- var ActionFlag = z15.string().regex(
1299
- new RegExp(
1300
- `^(${Object.values(ActionType).join("|").toLowerCase()}):(${Object.values(
1301
- ActionStatus
1302
- ).join("|").toLowerCase()})$`
1303
- ),
1304
- "Flag must be in the format ActionType:ActionStatus (lowerCase)"
1305
- );
1306
- var CustomFlag = z15.string().refine((val) => !Object.values(InherentFlags).includes(val), {
1307
- message: `Custom flag cannot be one of the inherent flags: ${Object.values(
1308
- InherentFlags
1309
- ).join(", ")}`
1310
- }).refine((val) => !ActionFlag.safeParse(val).success, {
1311
- message: "Custom flag cannot match the ActionFlag pattern (ActionType:ActionStatus)."
1312
- }).describe("Custom flag identifier defined by the country config.");
1313
- var Flag = ActionFlag.or(z15.enum(InherentFlags)).or(CustomFlag);
1314
- var FlagConfig = z15.object({
1315
- id: CustomFlag,
1316
- requiresAction: z15.boolean().describe(
1317
- "Indicates if this flag expects an action to be performed to be cleared."
1318
- ),
1319
- label: TranslationConfig.describe("Human readable label of the flag.")
1320
- }).meta({
1321
- id: "FlagConfig",
1322
- description: "Configuration for a custom flag that can be added to or removed from records by event actions."
1323
- });
1324
- var ActionFlagConfig = z15.object({
1325
- id: Flag,
1326
- operation: z15.enum(["add", "remove"]).describe("Operation to perform on the flag."),
1327
- conditional: Conditional.optional().describe(
1328
- "When conditional is met, the operation is performed on the flag. If not provided, the operation is performed unconditionally."
1329
- )
1330
- }).meta({
1331
- id: "ActionFlagConfig",
1332
- description: "Add or remove operation applied to a flag when the parent action is accepted. Optionally gated by a conditional."
1333
- });
1470
+ var Action = z16.union([ActionDocument, AsyncRejectActionDocument]);
1334
1471
 
1335
1472
  // ../commons/src/events/EventMetadata.ts
1336
- var EventStatus = z16.enum([
1337
- "CREATED",
1338
- "NOTIFIED",
1339
- "DECLARED",
1340
- "REGISTERED",
1341
- "ARCHIVED"
1342
- ]);
1343
- var ZodDate = z16.iso.date();
1344
- var ZodDateTime = z16.string().datetime();
1345
- var ActionCreationMetadata = z16.object({
1346
- createdAt: z16.iso.datetime().describe("The timestamp when the action request was created."),
1347
- createdBy: z16.string().describe("ID of the user who created the action request."),
1473
+ var ZodDate = z17.iso.date();
1474
+ var ZodDateTime = z17.string().datetime();
1475
+ var ActionCreationMetadata = z17.object({
1476
+ createdAt: z17.iso.datetime().describe("The timestamp when the action request was created."),
1477
+ createdBy: z17.string().describe("ID of the user who created the action request."),
1348
1478
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1349
1479
  createdAtLocation: UUID.nullish().describe(
1350
1480
  "Location of the user who created the action request."
1351
1481
  ),
1352
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1353
- acceptedAt: z16.iso.datetime().describe("Timestamp when the action request was accepted."),
1354
- createdByRole: z16.string().optional().describe("Role of the user at the time of action request creation.")
1482
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1483
+ acceptedAt: z17.iso.datetime().describe("Timestamp when the action request was accepted."),
1484
+ createdByRole: z17.string().optional().describe("Role of the user at the time of action request creation.")
1355
1485
  });
1356
1486
  var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1357
- registrationNumber: z16.string().describe(
1487
+ registrationNumber: z17.string().describe(
1358
1488
  "Registration number of the event. Always present for accepted registrations."
1359
1489
  )
1360
1490
  });
1361
- var LegalStatuses = z16.object({
1491
+ var LegalStatuses = z17.object({
1492
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1362
1493
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1363
1494
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1364
1495
  });
1365
- var EventMetadata = z16.object({
1496
+ var EventMetadata = z17.object({
1366
1497
  id: UUID,
1367
- type: z16.string().describe("The type of event, such as birth, death, or marriage."),
1498
+ type: z17.string().describe("The type of event, such as birth, death, or marriage."),
1368
1499
  status: EventStatus,
1369
1500
  legalStatuses: LegalStatuses.describe(
1370
1501
  "Metadata related to the legal registration of the event, such as who registered it and when."
1371
1502
  ),
1372
- createdAt: z16.iso.datetime().describe("The timestamp when the event was first created and saved."),
1503
+ createdAt: z17.iso.datetime().describe("The timestamp when the event was first created and saved."),
1373
1504
  dateOfEvent: ZodDate.nullish(),
1374
1505
  placeOfEvent: UUID.nullish(),
1375
- createdBy: z16.string().describe("ID of the user who created the event."),
1376
- createdByUserType: z16.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1377
- updatedByUserRole: z16.string().nullish().describe("Role of the user who last changed the status."),
1506
+ createdBy: z17.string().describe("ID of the user who created the event."),
1507
+ createdByUserType: z17.enum(["user", "system"]).nullish().describe("Whether the user is a normal user or a system."),
1508
+ updatedByUserRole: z17.string().nullish().describe("Role of the user who last changed the status."),
1378
1509
  // @TODO: createdAtLocation should be non-nullable in the future once all action requests have this field populated.
1379
1510
  createdAtLocation: UUID.nullish().describe(
1380
1511
  "Location of the user who created the event."
@@ -1382,18 +1513,18 @@ var EventMetadata = z16.object({
1382
1513
  updatedAtLocation: UUID.nullish().describe(
1383
1514
  "Location of the user who last changed the status."
1384
1515
  ),
1385
- updatedAt: z16.iso.datetime().describe(
1516
+ updatedAt: z17.iso.datetime().describe(
1386
1517
  "Timestamp of the most recent *accepted* status change. Possibly 3rd party update, if action is validation asynchronously."
1387
1518
  ),
1388
- assignedTo: z16.string().nullish().describe("ID of the user currently assigned to the event."),
1389
- updatedBy: z16.string().nullish().describe("ID of the user who last changed the status."),
1390
- trackingId: z16.string().describe(
1519
+ assignedTo: z17.string().nullish().describe("ID of the user currently assigned to the event."),
1520
+ updatedBy: z17.string().nullish().describe("ID of the user who last changed the status."),
1521
+ trackingId: z17.string().describe(
1391
1522
  "System-generated tracking ID used by informants or registrars to look up the event."
1392
1523
  ),
1393
- potentialDuplicates: z16.array(PotentialDuplicate).describe(
1524
+ potentialDuplicates: z17.array(PotentialDuplicate).describe(
1394
1525
  "List of event IDs and their tracking IDs that this event could be a duplicate of."
1395
1526
  ),
1396
- flags: z16.array(Flag)
1527
+ flags: z17.array(Flag)
1397
1528
  });
1398
1529
  var EventMetadataKeysArray = [
1399
1530
  "id",
@@ -1414,18 +1545,22 @@ var EventMetadataKeysArray = [
1414
1545
  "legalStatuses",
1415
1546
  "flags"
1416
1547
  ];
1417
- var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1418
- var EventMetadataDateFieldIdInput = z16.enum([
1548
+ var EventMetadataKeys = z17.enum(EventMetadataKeysArray);
1549
+ var EventMetadataDateFieldIdInput = z17.enum([
1419
1550
  "createdAt",
1420
1551
  "updatedAt",
1552
+ "legalStatuses.NOTIFIED.createdAt",
1553
+ "legalStatuses.NOTIFIED.acceptedAt",
1421
1554
  "legalStatuses.DECLARED.createdAt",
1422
1555
  "legalStatuses.DECLARED.acceptedAt",
1423
1556
  "legalStatuses.REGISTERED.createdAt",
1424
1557
  "legalStatuses.REGISTERED.acceptedAt"
1425
1558
  ]);
1426
- var EventMetadataDateFieldId = z16.enum([
1559
+ var EventMetadataDateFieldId = z17.enum([
1427
1560
  "event.createdAt",
1428
1561
  "event.updatedAt",
1562
+ "event.legalStatuses.NOTIFIED.createdAt",
1563
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1429
1564
  "event.legalStatuses.DECLARED.createdAt",
1430
1565
  "event.legalStatuses.DECLARED.acceptedAt",
1431
1566
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1483,12 +1618,6 @@ var Range = import_v4.z.object({
1483
1618
  }).meta({
1484
1619
  id: "Range"
1485
1620
  });
1486
- var ContainsFlags = import_v4.z.object({
1487
- anyOf: import_v4.z.array(Flag).optional(),
1488
- noneOf: import_v4.z.array(Flag).optional()
1489
- }).meta({
1490
- id: "ContainsFlags"
1491
- });
1492
1621
  var Within = import_v4.z.object({ type: import_v4.z.literal("within"), location: import_v4.z.string() }).meta({
1493
1622
  id: "Within"
1494
1623
  });
@@ -1715,8 +1844,8 @@ var BaseField = import_v43.default.object({
1715
1844
  conditionals: import_v43.default.array(FieldConditional).default([]).optional().describe(
1716
1845
  "Conditions determining when the field is shown or enabled. By default, the field is always shown and enabled."
1717
1846
  ),
1718
- secured: import_v43.default.boolean().default(false).optional().describe(
1719
- "Indicates whether the field is secured. Secured fields are not indexed for search and are only visible when explicitly assigned."
1847
+ secured: import_v43.default.union([import_v43.default.boolean(), Conditional]).default(false).optional().describe(
1848
+ "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."
1720
1849
  ),
1721
1850
  placeholder: TranslationConfig.optional(),
1722
1851
  validation: import_v43.default.array(ValidationConfig).default([]).optional().describe("Additional validation rules applied to the field."),
@@ -2114,7 +2243,16 @@ var AdministrativeAreaField = BaseField.extend({
2114
2243
  configuration: import_v43.default.object({
2115
2244
  partOf: FieldReference.optional().describe("Parent location"),
2116
2245
  type: AdministrativeAreas,
2117
- allowedLocations: AllowedLocations
2246
+ allowedLocations: AllowedLocations,
2247
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2248
+ "List every historical name a location has had as a separate, selectable option."
2249
+ ),
2250
+ activeOnly: import_v43.default.boolean().optional().describe(
2251
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2252
+ ),
2253
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2254
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2255
+ )
2118
2256
  }).describe("Administrative area options")
2119
2257
  }).meta({
2120
2258
  description: "Administrative area input field",
@@ -2125,7 +2263,16 @@ var LocationInput = BaseField.extend({
2125
2263
  defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2126
2264
  configuration: import_v43.default.object({
2127
2265
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2128
- allowedLocations: AllowedLocations
2266
+ allowedLocations: AllowedLocations,
2267
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2268
+ "List every historical name a location has had as a separate, selectable option."
2269
+ ),
2270
+ activeOnly: import_v43.default.boolean().optional().describe(
2271
+ "Offer only locations that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded."
2272
+ ),
2273
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2274
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that."
2275
+ )
2129
2276
  }).optional()
2130
2277
  }).meta({
2131
2278
  description: "A field for selecting a location",
@@ -2151,12 +2298,22 @@ var FileUploadWithOptions = BaseField.extend({
2151
2298
  var Facility = BaseField.extend({
2152
2299
  type: import_v43.default.literal(FieldType.FACILITY),
2153
2300
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2154
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2301
+ configuration: import_v43.default.object({
2302
+ allowedLocations: AllowedLocations,
2303
+ listHistoricalNames: import_v43.default.boolean().optional(),
2304
+ activeOnly: import_v43.default.boolean().optional(),
2305
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2306
+ }).optional()
2155
2307
  }).describe("Input field for a facility");
2156
2308
  var Office = BaseField.extend({
2157
2309
  type: import_v43.default.literal(FieldType.OFFICE),
2158
2310
  defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2159
- configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2311
+ configuration: import_v43.default.object({
2312
+ allowedLocations: AllowedLocations,
2313
+ listHistoricalNames: import_v43.default.boolean().optional(),
2314
+ activeOnly: import_v43.default.boolean().optional(),
2315
+ anchorToDateOfEvent: import_v43.default.boolean().optional()
2316
+ }).optional()
2160
2317
  }).describe("Input field for an office");
2161
2318
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2162
2319
  administrativeArea: import_v43.default.union([UUID, SerializedUserField]).optional()
@@ -2189,7 +2346,16 @@ var Address = BaseField.extend({
2189
2346
  parent: FieldReference.optional()
2190
2347
  })
2191
2348
  ).optional(),
2192
- allowedLocations: AllowedLocations
2349
+ allowedLocations: AllowedLocations,
2350
+ listHistoricalNames: import_v43.default.boolean().optional().describe(
2351
+ "List every historical name a location has had as a separate, selectable option. Propagated to the embedded admin-area selectors."
2352
+ ),
2353
+ activeOnly: import_v43.default.boolean().optional().describe(
2354
+ "Offer only admin areas that are active at the resolved anchor date (today, or the date of event when anchorToDateOfEvent is set); inactive or not-yet-effective versions are excluded. Propagated to the embedded admin-area selectors."
2355
+ ),
2356
+ anchorToDateOfEvent: import_v43.default.boolean().optional().describe(
2357
+ "Resolve selectable/displayed versions against the event's date of event (falling back to the record's creation date when empty) instead of today. Does not by itself exclude inactive versions; combine with activeOnly for that. Propagated to the embedded admin-area selectors."
2358
+ )
2193
2359
  }).optional(),
2194
2360
  defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2195
2361
  }).meta({
@@ -2490,18 +2656,18 @@ var AnyFileField = import_v43.default.discriminatedUnion("type", [
2490
2656
  ]);
2491
2657
 
2492
2658
  // ../commons/src/events/FormConfig.ts
2493
- var z22 = __toESM(require("zod/v4"));
2659
+ var z23 = __toESM(require("zod/v4"));
2494
2660
 
2495
2661
  // ../commons/src/events/PageConfig.ts
2496
- var z21 = __toESM(require("zod/v4"));
2497
- var PageTypes = z21.enum(["FORM", "VERIFICATION"]);
2498
- var PageConfigBase = z21.object({
2499
- id: z21.string().describe("Unique identifier for the page"),
2662
+ var z22 = __toESM(require("zod/v4"));
2663
+ var PageTypes = z22.enum(["FORM", "VERIFICATION"]);
2664
+ var PageConfigBase = z22.object({
2665
+ id: z22.string().describe("Unique identifier for the page"),
2500
2666
  title: TranslationConfig.describe("Header title of the page"),
2501
- requireCompletionToContinue: z21.boolean().default(false).describe(
2667
+ requireCompletionToContinue: z22.boolean().default(false).describe(
2502
2668
  "If true, all required fields must be filled before continuing to the next page"
2503
2669
  ),
2504
- fields: z21.array(FieldConfig).describe("Fields to be rendered on the page"),
2670
+ fields: z22.array(FieldConfig).describe("Fields to be rendered on the page"),
2505
2671
  conditional: Conditional.optional().describe(
2506
2672
  "Page will be shown if condition is met. If conditional is not defined, the page will be always shown."
2507
2673
  )
@@ -2510,13 +2676,13 @@ var PageConfigBase = z21.object({
2510
2676
  id: "FormPageConfig"
2511
2677
  });
2512
2678
  var FormPageConfig = PageConfigBase.extend({
2513
- type: z21.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2679
+ type: z22.literal(PageTypes.enum.FORM).default(PageTypes.enum.FORM)
2514
2680
  });
2515
- var VerificationActionConfig = z21.object({
2516
- verify: z21.object({ label: TranslationConfig }),
2517
- cancel: z21.object({
2681
+ var VerificationActionConfig = z22.object({
2682
+ verify: z22.object({ label: TranslationConfig }),
2683
+ cancel: z22.object({
2518
2684
  label: TranslationConfig,
2519
- confirmation: z21.object({
2685
+ confirmation: z22.object({
2520
2686
  title: TranslationConfig,
2521
2687
  body: TranslationConfig
2522
2688
  })
@@ -2526,34 +2692,34 @@ var VerificationActionConfig = z21.object({
2526
2692
  id: "VerificationActionConfig"
2527
2693
  });
2528
2694
  var VerificationPageConfig = FormPageConfig.extend({
2529
- type: z21.literal(PageTypes.enum.VERIFICATION),
2695
+ type: z22.literal(PageTypes.enum.VERIFICATION),
2530
2696
  actions: VerificationActionConfig
2531
2697
  });
2532
- var PageConfig = z21.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2698
+ var PageConfig = z22.discriminatedUnion("type", [FormPageConfig, VerificationPageConfig]).meta({
2533
2699
  id: "PageConfig",
2534
2700
  description: "Configuration for a single page in a form. Either a form page with fields and a continue button, or a verification page with verify/cancel options."
2535
2701
  });
2536
2702
 
2537
2703
  // ../commons/src/events/FormConfig.ts
2538
- var DeclarationFormConfig = z22.object({
2704
+ var DeclarationFormConfig = z23.object({
2539
2705
  label: TranslationConfig.describe("Human readable description of the form"),
2540
- pages: z22.array(FormPageConfig)
2706
+ pages: z23.array(FormPageConfig)
2541
2707
  }).meta({
2542
2708
  id: "DeclarationFormConfig",
2543
2709
  description: "Configuration of the declaration form."
2544
2710
  });
2545
- var ActionFormConfig = z22.object({
2711
+ var ActionFormConfig = z23.object({
2546
2712
  label: TranslationConfig.describe("Human readable description of the form"),
2547
- pages: z22.array(PageConfig)
2713
+ pages: z23.array(PageConfig)
2548
2714
  }).describe(
2549
2715
  "Configuration of the form used for system actions beyond declaration, supporting a wider range of page types."
2550
2716
  );
2551
- var FormConfig = z22.union([DeclarationFormConfig, ActionFormConfig]);
2717
+ var FormConfig = z23.union([DeclarationFormConfig, ActionFormConfig]);
2552
2718
 
2553
2719
  // ../commons/src/events/DeduplicationConfig.ts
2554
- var z23 = __toESM(require("zod/v4"));
2555
- var FieldReference2 = z23.string();
2556
- var Matcher = z23.object({
2720
+ var z24 = __toESM(require("zod/v4"));
2721
+ var FieldReference2 = z24.string();
2722
+ var Matcher = z24.object({
2557
2723
  /**
2558
2724
  * Reference to the field used in matching.
2559
2725
  *
@@ -2561,23 +2727,23 @@ var Matcher = z23.object({
2561
2727
  * be used as the origin date to calculate the distance from.
2562
2728
  */
2563
2729
  fieldId: FieldReference2,
2564
- options: z23.object({
2565
- boost: z23.number().optional(),
2730
+ options: z24.object({
2731
+ boost: z24.number().optional(),
2566
2732
  matchAgainst: FieldReference2.optional()
2567
2733
  }).optional().default({
2568
2734
  boost: 1
2569
2735
  })
2570
2736
  });
2571
2737
  var FuzzyMatcher = Matcher.extend({
2572
- type: z23.literal("fuzzy"),
2573
- options: z23.object({
2738
+ type: z24.literal("fuzzy"),
2739
+ options: z24.object({
2574
2740
  /**
2575
2741
  * Names of length 3 or less characters = 0 edits allowed
2576
2742
  * Names of length 4 - 6 characters = 1 edit allowed
2577
2743
  * Names of length >7 characters = 2 edits allowed
2578
2744
  */
2579
- fuzziness: z23.union([z23.string(), z23.number()]).optional().default("AUTO:4,7"),
2580
- boost: z23.number().optional().default(1),
2745
+ fuzziness: z24.union([z24.string(), z24.number()]).optional().default("AUTO:4,7"),
2746
+ boost: z24.number().optional().default(1),
2581
2747
  matchAgainst: FieldReference2.optional()
2582
2748
  }).optional().default({
2583
2749
  fuzziness: "AUTO:4,7",
@@ -2585,48 +2751,48 @@ var FuzzyMatcher = Matcher.extend({
2585
2751
  })
2586
2752
  });
2587
2753
  var StrictMatcher = Matcher.extend({
2588
- type: z23.literal("strict"),
2589
- options: z23.object({
2590
- boost: z23.number().optional().default(1),
2754
+ type: z24.literal("strict"),
2755
+ options: z24.object({
2756
+ boost: z24.number().optional().default(1),
2591
2757
  /**
2592
2758
  * The constant value to be present in the field for both records
2593
2759
  */
2594
- value: z23.string().optional(),
2760
+ value: z24.string().optional(),
2595
2761
  matchAgainst: FieldReference2.optional()
2596
2762
  }).optional().default({
2597
2763
  boost: 1
2598
2764
  })
2599
2765
  });
2600
2766
  var DateRangeMatcher = Matcher.extend({
2601
- type: z23.literal("dateRange"),
2602
- options: z23.object({
2767
+ type: z24.literal("dateRange"),
2768
+ options: z24.object({
2603
2769
  /**
2604
2770
  * The distance pivot in days. Distance from the origin (the value of
2605
2771
  * fieldId) at which relevance scores receive half of the boost value
2606
2772
  */
2607
- pivot: z23.number().optional(),
2608
- days: z23.number(),
2609
- boost: z23.number().optional().default(1),
2773
+ pivot: z24.number().optional(),
2774
+ days: z24.number(),
2775
+ boost: z24.number().optional().default(1),
2610
2776
  matchAgainst: FieldReference2.optional()
2611
2777
  })
2612
2778
  });
2613
- var Not = z23.object({
2614
- type: z23.literal("not"),
2779
+ var Not = z24.object({
2780
+ type: z24.literal("not"),
2615
2781
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2616
- clause: z23.lazy(() => Clause)
2782
+ clause: z24.lazy(() => Clause)
2617
2783
  });
2618
- var And = z23.object({
2619
- type: z23.literal("and"),
2784
+ var And = z24.object({
2785
+ type: z24.literal("and"),
2620
2786
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2621
- clauses: z23.lazy(() => Clause.array())
2787
+ clauses: z24.lazy(() => Clause.array())
2622
2788
  });
2623
- var Or = z23.object({
2624
- type: z23.literal("or"),
2789
+ var Or = z24.object({
2790
+ type: z24.literal("or"),
2625
2791
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
2626
- clauses: z23.lazy(() => Clause.array())
2792
+ clauses: z24.lazy(() => Clause.array())
2627
2793
  });
2628
- var Clause = z23.lazy(
2629
- () => z23.discriminatedUnion("type", [
2794
+ var Clause = z24.lazy(
2795
+ () => z24.discriminatedUnion("type", [
2630
2796
  Not,
2631
2797
  And,
2632
2798
  Or,
@@ -2637,8 +2803,8 @@ var Clause = z23.lazy(
2637
2803
  ).meta({
2638
2804
  id: "Clause"
2639
2805
  });
2640
- var DeduplicationConfig = z23.object({
2641
- id: z23.string(),
2806
+ var DeduplicationConfig = z24.object({
2807
+ id: z24.string(),
2642
2808
  label: TranslationConfig,
2643
2809
  query: Clause
2644
2810
  }).meta({
@@ -2647,15 +2813,15 @@ var DeduplicationConfig = z23.object({
2647
2813
  });
2648
2814
 
2649
2815
  // ../commons/src/events/ActionConfig.ts
2650
- var DeclarationReviewConfig = z24.object({
2816
+ var DeclarationReviewConfig = z25.object({
2651
2817
  title: TranslationConfig.describe("Title of the review page"),
2652
- fields: z24.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2818
+ fields: z25.array(FieldConfig).describe("Fields displayed on the review page for annotations.")
2653
2819
  }).describe(
2654
2820
  "Configuration of the declaration review page for collecting event-related metadata."
2655
2821
  );
2656
- var ActionConfigBase = z24.object({
2822
+ var ActionConfigBase = z25.object({
2657
2823
  label: TranslationConfig.describe("Human readable description of the action"),
2658
- flags: z24.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2824
+ flags: z25.array(ActionFlagConfig).optional().default([]).describe("Flag actions which are executed when the action is performed."),
2659
2825
  supportingCopy: TranslationConfig.optional().describe(
2660
2826
  "Text displayed on the confirmation dialog"
2661
2827
  ),
@@ -2666,30 +2832,86 @@ var ActionConfigBase = z24.object({
2666
2832
  * "The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed."
2667
2833
  * for EventConfig.d.ts.
2668
2834
  */
2669
- icon: z24.string().describe("Icon representing the action").optional(),
2670
- conditionals: z24.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2835
+ icon: z25.string().describe("Icon representing the action").optional(),
2836
+ conditionals: z25.array(ActionConditional).optional().describe("Conditionals which can disable or hide actions.")
2671
2837
  });
2672
2838
  var DeclarationActionBase = ActionConfigBase.extend({
2673
2839
  deduplication: DeduplicationConfig.optional()
2674
2840
  });
2841
+ var actionConfirmationForm = z25.array(FieldConfig).optional().describe(
2842
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2843
+ );
2675
2844
  var ReadActionConfig = ActionConfigBase.extend(
2676
- z24.object({
2677
- type: z24.literal(ActionType.READ),
2845
+ z25.object({
2846
+ type: z25.literal(ActionType.READ),
2678
2847
  review: DeclarationReviewConfig.describe(
2679
2848
  "Configuration of the review page for read-only view."
2680
2849
  ),
2681
- conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2850
+ conditionals: z25.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2682
2851
  }).shape
2683
2852
  );
2684
- var DeclareConfig = DeclarationActionBase.extend(
2685
- z24.object({
2686
- type: z24.literal(ActionType.DECLARE),
2687
- review: DeclarationReviewConfig.describe(
2688
- "Configuration of the review page fields."
2853
+ var NotifyConfig = ActionConfigBase.extend(
2854
+ z25.object({
2855
+ type: z25.literal(ActionType.NOTIFY),
2856
+ form: actionConfirmationForm
2857
+ }).shape
2858
+ );
2859
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2860
+ z25.object({
2861
+ type: z25.literal(ActionType.DUPLICATE_DETECTED),
2862
+ label: z25.never().optional().describe(
2863
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2689
2864
  ),
2690
- dialogCopy: z24.object({
2691
- notify: TranslationConfig.describe(
2692
- "Confirmation text for the notify action"
2865
+ supportingCopy: z25.never().optional(),
2866
+ icon: z25.never().optional().describe(
2867
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2868
+ ),
2869
+ conditionals: z25.never().optional().describe(
2870
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2871
+ )
2872
+ }).shape
2873
+ );
2874
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2875
+ z25.object({
2876
+ type: z25.literal(ActionType.MARK_AS_DUPLICATE)
2877
+ }).shape
2878
+ );
2879
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2880
+ z25.object({
2881
+ type: z25.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2882
+ }).shape
2883
+ );
2884
+ var AssignConfig = ActionConfigBase.extend(
2885
+ z25.object({
2886
+ type: z25.literal(ActionType.ASSIGN),
2887
+ flags: z25.never().optional().describe(
2888
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2889
+ )
2890
+ }).shape
2891
+ );
2892
+ var UnassignConfig = ActionConfigBase.extend(
2893
+ z25.object({
2894
+ type: z25.literal(ActionType.UNASSIGN),
2895
+ flags: z25.never().optional().describe(
2896
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2897
+ )
2898
+ }).shape
2899
+ );
2900
+ var DeleteConfig = ActionConfigBase.extend(
2901
+ z25.object({
2902
+ type: z25.literal(ActionType.DELETE)
2903
+ }).shape
2904
+ );
2905
+ var DeclareConfig = DeclarationActionBase.extend(
2906
+ z25.object({
2907
+ type: z25.literal(ActionType.DECLARE),
2908
+ review: DeclarationReviewConfig.describe(
2909
+ "Configuration of the review page fields."
2910
+ ),
2911
+ form: actionConfirmationForm,
2912
+ dialogCopy: z25.object({
2913
+ notify: TranslationConfig.describe(
2914
+ "Confirmation text for the notify action"
2693
2915
  ),
2694
2916
  declare: TranslationConfig.describe(
2695
2917
  "Confirmation text for the declare action"
@@ -2701,14 +2923,20 @@ var DeclareConfig = DeclarationActionBase.extend(
2701
2923
  }).shape
2702
2924
  );
2703
2925
  var ArchiveConfig = ActionConfigBase.extend(
2704
- z24.object({
2705
- type: z24.literal(ActionType.ARCHIVE)
2926
+ z25.object({
2927
+ type: z25.literal(ActionType.ARCHIVE),
2928
+ form: actionConfirmationForm
2929
+ }).shape
2930
+ );
2931
+ var UnarchiveConfig = ActionConfigBase.extend(
2932
+ z25.object({
2933
+ type: z25.literal(ActionType.UNARCHIVE)
2706
2934
  }).shape
2707
2935
  );
2708
2936
  var EditActionConfig = ActionConfigBase.extend(
2709
- z24.object({
2710
- type: z24.literal(ActionType.EDIT),
2711
- dialogCopy: z24.object({
2937
+ z25.object({
2938
+ type: z25.literal(ActionType.EDIT),
2939
+ dialogCopy: z25.object({
2712
2940
  notify: TranslationConfig.describe(
2713
2941
  "Confirmation text for the notify with edits action"
2714
2942
  ),
@@ -2722,41 +2950,53 @@ var EditActionConfig = ActionConfigBase.extend(
2722
2950
  }).shape
2723
2951
  );
2724
2952
  var RejectConfig = ActionConfigBase.extend(
2725
- z24.object({
2726
- type: z24.literal(ActionType.REJECT)
2953
+ z25.object({
2954
+ type: z25.literal(ActionType.REJECT),
2955
+ form: actionConfirmationForm
2727
2956
  }).shape
2728
2957
  );
2729
2958
  var RegisterConfig = DeclarationActionBase.extend(
2730
- z24.object({
2731
- type: z24.literal(ActionType.REGISTER)
2959
+ z25.object({
2960
+ type: z25.literal(ActionType.REGISTER),
2961
+ form: actionConfirmationForm
2732
2962
  }).shape
2733
2963
  );
2734
2964
  var PrintCertificateActionConfig = ActionConfigBase.extend(
2735
- z24.object({
2736
- type: z24.literal(ActionType.PRINT_CERTIFICATE),
2965
+ z25.object({
2966
+ type: z25.literal(ActionType.PRINT_CERTIFICATE),
2737
2967
  printForm: ActionFormConfig
2738
2968
  }).shape
2739
2969
  );
2740
2970
  var RequestCorrectionConfig = ActionConfigBase.extend(
2741
- z24.object({
2742
- type: z24.literal(ActionType.REQUEST_CORRECTION),
2971
+ z25.object({
2972
+ type: z25.literal(ActionType.REQUEST_CORRECTION),
2743
2973
  correctionForm: ActionFormConfig
2744
2974
  }).shape
2745
2975
  );
2746
- var CustomActionConfig = ActionConfigBase.merge(
2747
- z24.object({
2748
- type: z24.literal(ActionType.CUSTOM),
2749
- customActionType: z24.string().describe("Type identifier of the custom action."),
2976
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2977
+ z25.object({
2978
+ type: z25.literal(ActionType.APPROVE_CORRECTION)
2979
+ }).shape
2980
+ );
2981
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2982
+ z25.object({
2983
+ type: z25.literal(ActionType.REJECT_CORRECTION)
2984
+ }).shape
2985
+ );
2986
+ var CustomActionConfig = ActionConfigBase.extend(
2987
+ z25.object({
2988
+ type: z25.literal(ActionType.CUSTOM),
2989
+ customActionType: z25.string().describe("Type identifier of the custom action."),
2750
2990
  /** Custom action form configuration supports a simple array of field configs, which should be rendered on the action modal. In the future, we might add support for pages etc. */
2751
- form: z24.array(FieldConfig).describe(
2991
+ form: z25.array(FieldConfig).describe(
2752
2992
  "Form configuration for the custom action. The form configured here will be used on the custom action confirmation modal."
2753
2993
  ),
2754
2994
  auditHistoryLabel: TranslationConfig.describe(
2755
2995
  'The label to show in audit history for this action. For example "Approved".'
2756
2996
  )
2757
- })
2997
+ }).shape
2758
2998
  );
2759
- var ActionConfig = z24.discriminatedUnion("type", [
2999
+ var ActionConfig = z25.discriminatedUnion("type", [
2760
3000
  /*
2761
3001
  * OpenAPI references are defined here so our generated OpenAPI spec knows to reuse the models
2762
3002
  * and treat them as "models" instead of duplicating the data structure in each endpoint.
@@ -2765,9 +3005,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
2765
3005
  id: "ReadActionConfig",
2766
3006
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2767
3007
  }),
3008
+ AssignConfig.meta({
3009
+ id: "AssignActionConfig",
3010
+ description: "Configuration for assigning a record to the current user."
3011
+ }),
3012
+ UnassignConfig.meta({
3013
+ id: "UnassignActionConfig",
3014
+ description: "Configuration for unassigning a record from its current assignee."
3015
+ }),
3016
+ DeleteConfig.meta({
3017
+ id: "DeleteActionConfig",
3018
+ description: "Configuration for deleting a draft record."
3019
+ }),
3020
+ NotifyConfig.meta({
3021
+ id: "NotifyActionConfig",
3022
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
3023
+ }),
2768
3024
  DeclareConfig.meta({
2769
3025
  id: "DeclareActionConfig",
2770
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
3026
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
3027
+ }),
3028
+ DuplicateDetectedConfig.meta({
3029
+ id: "DuplicateDetectedActionConfig",
3030
+ description: "Configuration for the system-generated duplicate-detection action. Never shown as a button, so it only supports flags \u2014 not label, icon, or conditionals."
3031
+ }),
3032
+ MarkAsDuplicateConfig.meta({
3033
+ id: "MarkAsDuplicateActionConfig",
3034
+ description: "Configuration for marking a record as a duplicate."
3035
+ }),
3036
+ MarkAsNotDuplicateConfig.meta({
3037
+ id: "MarkAsNotDuplicateActionConfig",
3038
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2771
3039
  }),
2772
3040
  RejectConfig.meta({
2773
3041
  id: "RejectActionConfig",
@@ -2785,6 +3053,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2785
3053
  id: "RequestCorrectionActionConfig",
2786
3054
  description: "Configuration for requesting a correction on a registered record."
2787
3055
  }),
3056
+ ApproveCorrectionConfig.meta({
3057
+ id: "ApproveCorrectionActionConfig",
3058
+ description: "Configuration for approving a requested correction."
3059
+ }),
3060
+ RejectCorrectionConfig.meta({
3061
+ id: "RejectCorrectionActionConfig",
3062
+ description: "Configuration for rejecting a requested correction."
3063
+ }),
2788
3064
  EditActionConfig.meta({
2789
3065
  id: "EditActionConfig",
2790
3066
  description: "Configuration for editing a record before registration."
@@ -2793,6 +3069,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2793
3069
  id: "ArchiveActionConfig",
2794
3070
  description: "Configuration for archiving a record."
2795
3071
  }),
3072
+ UnarchiveConfig.meta({
3073
+ id: "UnarchiveActionConfig",
3074
+ description: "Configuration for unarchiving a record."
3075
+ }),
2796
3076
  CustomActionConfig.meta({
2797
3077
  id: "CustomActionConfig",
2798
3078
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -2803,89 +3083,225 @@ var ActionConfig = z24.discriminatedUnion("type", [
2803
3083
  var actionConfigTypes = new Set(
2804
3084
  ActionConfig.options.map((opt) => opt.shape.type.value)
2805
3085
  );
2806
- var DeclarationActionConfig = z24.discriminatedUnion("type", [
3086
+ var DeclarationActionConfig = z25.discriminatedUnion("type", [
2807
3087
  DeclareConfig,
2808
3088
  RegisterConfig
2809
3089
  ]);
2810
3090
 
2811
3091
  // ../commons/src/events/offline/CertificateConfig.ts
2812
- var z25 = __toESM(require("zod/v4"));
2813
- var FontFamily = z25.object({
2814
- normal: z25.string(),
2815
- bold: z25.string(),
2816
- italics: z25.string(),
2817
- bolditalics: z25.string()
2818
- });
2819
- var CertificateConfig = z25.object({
2820
- id: z25.string(),
2821
- event: z25.string(),
2822
- isV2Template: z25.boolean().optional(),
3092
+ var z26 = __toESM(require("zod/v4"));
3093
+ var FontFamily = z26.object({
3094
+ normal: z26.string(),
3095
+ bold: z26.string(),
3096
+ italics: z26.string(),
3097
+ bolditalics: z26.string()
3098
+ });
3099
+ var CertificateConfig = z26.object({
3100
+ id: z26.string(),
3101
+ event: z26.string(),
3102
+ isV2Template: z26.boolean().optional(),
2823
3103
  label: TranslationConfig,
2824
- isDefault: z25.boolean(),
2825
- fee: z25.object({
2826
- onTime: z25.number(),
2827
- late: z25.number(),
2828
- delayed: z25.number()
3104
+ isDefault: z26.boolean(),
3105
+ fee: z26.object({
3106
+ onTime: z26.number(),
3107
+ late: z26.number(),
3108
+ delayed: z26.number()
2829
3109
  }),
2830
- svgUrl: z25.string(),
2831
- fonts: z25.record(z25.string(), FontFamily).optional(),
2832
- conditionals: z25.array(ShowConditional).optional()
3110
+ svgUrl: z26.string(),
3111
+ fonts: z26.record(z26.string(), FontFamily).optional(),
3112
+ conditionals: z26.array(ShowConditional).optional()
2833
3113
  });
2834
3114
  var CertificateTemplateConfig = CertificateConfig.extend({
2835
- hash: z25.string().optional(),
2836
- svg: z25.string()
3115
+ hash: z26.string().optional(),
3116
+ svg: z26.string()
2837
3117
  });
2838
3118
 
2839
3119
  // ../commons/src/events/offline/LanguageConfig.ts
2840
- var z26 = __toESM(require("zod/v4"));
2841
- var LanguageConfig = z26.object({
2842
- lang: z26.string(),
3120
+ var z27 = __toESM(require("zod/v4"));
3121
+ var LanguageConfig = z27.object({
3122
+ lang: z27.string(),
2843
3123
  /**
2844
3124
  * client.csv contents
2845
3125
  */
2846
- messages: z26.record(z26.string(), z26.string())
3126
+ messages: z27.record(z27.string(), z27.string())
2847
3127
  });
2848
3128
 
2849
3129
  // ../commons/src/events/EventConfig.ts
2850
- var z33 = __toESM(require("zod/v4"));
3130
+ var z35 = __toESM(require("zod/v4"));
2851
3131
 
2852
3132
  // ../commons/src/events/SummaryConfig.ts
2853
- var z27 = __toESM(require("zod/v4"));
2854
- var BaseField2 = z27.object({
3133
+ var z29 = __toESM(require("zod/v4"));
3134
+
3135
+ // ../commons/src/icons.ts
3136
+ var z28 = __toESM(require("zod/v4"));
3137
+ var AvailableIcons = z28.enum([
3138
+ "Archived",
3139
+ "Assigned",
3140
+ "Briefcase",
3141
+ "Certified",
3142
+ "Close",
3143
+ "Collapse",
3144
+ "Draft",
3145
+ "DuplicateYellow",
3146
+ "Expand",
3147
+ "ExternalValidate",
3148
+ "FilledCheck",
3149
+ "InReview",
3150
+ "Offline",
3151
+ "Registered",
3152
+ "RequiresUpdates",
3153
+ "Sent",
3154
+ "Validated",
3155
+ "WaitingApproval",
3156
+ "ChartActivity",
3157
+ "Activity",
3158
+ "Archive",
3159
+ "ArchiveTray",
3160
+ "ArrowLeft",
3161
+ "ArrowRight",
3162
+ "Buildings",
3163
+ "Circle",
3164
+ "CaretDown",
3165
+ "CaretLeft",
3166
+ "CaretRight",
3167
+ "ChartBar",
3168
+ "ChartLine",
3169
+ "ChatCircle",
3170
+ "CheckSquare",
3171
+ "Compass",
3172
+ "Check",
3173
+ "Copy",
3174
+ "Database",
3175
+ "DotsThreeVertical",
3176
+ "ArrowCounterClockwise",
3177
+ "MagnifyingGlassMinus",
3178
+ "MagnifyingGlassPlus",
3179
+ "Export",
3180
+ "Eye",
3181
+ "EyeSlash",
3182
+ "Envelope",
3183
+ "File",
3184
+ "FileLock",
3185
+ "FileSearch",
3186
+ "FileMinus",
3187
+ "FilePlus",
3188
+ "FileText",
3189
+ "FileX",
3190
+ "Handshake",
3191
+ "Gear",
3192
+ "GitBranch",
3193
+ "IdentificationCard",
3194
+ "List",
3195
+ "ListBullets",
3196
+ "Lock",
3197
+ "MagnifyingGlass",
3198
+ "MapPin",
3199
+ "Medal",
3200
+ "NotePencil",
3201
+ "Paperclip",
3202
+ "PaperPlaneTilt",
3203
+ "Pen",
3204
+ "PenNib",
3205
+ "Pencil",
3206
+ "PencilSimpleLine",
3207
+ "Phone",
3208
+ "Plus",
3209
+ "Printer",
3210
+ "SignOut",
3211
+ "Stamp",
3212
+ "Star",
3213
+ "Target",
3214
+ "TextT",
3215
+ "Trash",
3216
+ "UploadSimple",
3217
+ "User",
3218
+ "UserPlus",
3219
+ "Users",
3220
+ "WarningCircle",
3221
+ "X",
3222
+ "ChatText",
3223
+ "CircleWavyCheck",
3224
+ "CircleWavyQuestion",
3225
+ "ArchiveBox",
3226
+ "ArrowCircleDown",
3227
+ "FileArrowUp",
3228
+ "FileDotted",
3229
+ "Files",
3230
+ "PencilLine",
3231
+ "PencilCircle",
3232
+ "UserCircle",
3233
+ "Clock",
3234
+ "QrCode",
3235
+ "Webcam",
3236
+ "Sun",
3237
+ "DeviceTabletCamera",
3238
+ "Globe",
3239
+ "Fingerprint",
3240
+ "PushPin",
3241
+ "Timer"
3242
+ ]);
3243
+
3244
+ // ../commons/src/events/SummaryConfig.ts
3245
+ var InfoBox = z29.object({
3246
+ type: z29.enum(["info", "positive", "warning", "negative"]).describe(
3247
+ "Semantic tint of the icon block: info (blue), positive (green), warning (orange), negative (red)."
3248
+ ),
3249
+ background: z29.enum(["tinted", "white"]).default("tinted").optional().describe(
3250
+ "tinted reads as a recessed empty state; white reads as a standalone card."
3251
+ ),
3252
+ icon: AvailableIcons.optional().describe(
3253
+ "Icon displayed inside the icon block. Defaults to FileSearch."
3254
+ ),
3255
+ heading: TranslationConfig.describe(
3256
+ "Primary message. Short, sentence-case."
3257
+ ),
3258
+ description: TranslationConfig.optional().describe(
3259
+ "Secondary copy displayed below the heading, typically a suggested next step."
3260
+ ),
3261
+ conditionals: z29.array(ShowConditional).default([]).optional().describe(
3262
+ "Conditions under which the info box is shown. When omitted, it is always shown."
3263
+ )
3264
+ }).describe(
3265
+ "A compact icon-block + heading + description block displayed above the summary fields in the event overview."
3266
+ );
3267
+ var BaseField2 = z29.object({
2855
3268
  emptyValueMessage: TranslationConfig.optional().describe(
2856
3269
  "Default message displayed when the field value is empty."
2857
3270
  ),
2858
- conditionals: z27.array(ShowConditional).default([]).optional()
3271
+ conditionals: z29.array(ShowConditional).default([]).optional()
2859
3272
  });
2860
3273
  var ReferenceField = BaseField2.extend({
2861
- fieldId: z27.string(),
3274
+ fieldId: z29.string(),
2862
3275
  label: TranslationConfig.optional().describe(
2863
3276
  "Overrides the default label from the referenced field when provided."
2864
3277
  )
2865
3278
  }).describe("Field referencing existing event data by field ID.");
2866
3279
  var Field = BaseField2.extend({
2867
- id: z27.string().describe("Identifier of the summary field."),
3280
+ id: z29.string().describe("Identifier of the summary field."),
2868
3281
  value: TranslationConfig.describe(
2869
3282
  'Field value template supporting variables from configuration and EventMetadata (e.g. "{informant.phoneNo} {informant.email}").'
2870
3283
  ),
2871
3284
  label: TranslationConfig
2872
3285
  }).describe("Custom field defined for the summary view.");
2873
- var SummaryConfig = z27.object({
2874
- fields: z27.array(z27.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
3286
+ var SummaryConfig = z29.object({
3287
+ banners: z29.array(InfoBox).default([]).optional().describe(
3288
+ "Info boxes displayed above the summary fields in the event overview."
3289
+ ),
3290
+ fields: z29.array(z29.union([Field, ReferenceField])).describe("Fields displayed in the event summary view.")
2875
3291
  }).meta({
2876
3292
  id: "SummaryConfig",
2877
3293
  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."
2878
3294
  });
2879
3295
 
2880
3296
  // ../commons/src/events/AdvancedSearchConfig.ts
2881
- var z28 = __toESM(require("zod/v4"));
2882
- var MatchType = z28.enum(["fuzzy", "exact", "range", "within"]);
2883
- var BaseField3 = z28.object({
2884
- config: z28.object({
3297
+ var z30 = __toESM(require("zod/v4"));
3298
+ var MatchType = z30.enum(["fuzzy", "exact", "range", "within"]);
3299
+ var BaseField3 = z30.object({
3300
+ config: z30.object({
2885
3301
  type: MatchType.describe(
2886
3302
  "Determines the search type of field. How to match value."
2887
3303
  ),
2888
- searchFields: z28.array(z28.string()).optional().describe(
3304
+ searchFields: z30.array(z30.string()).optional().describe(
2889
3305
  `
2890
3306
  Defines multiple form fields that should be searched when this field has a value.
2891
3307
  All specified fields will be combined using OR logic.
@@ -2895,7 +3311,7 @@ var BaseField3 = z28.object({
2895
3311
  `
2896
3312
  )
2897
3313
  }),
2898
- type: z28.nativeEnum(FieldType).optional().describe(
3314
+ type: z30.nativeEnum(FieldType).optional().describe(
2899
3315
  `
2900
3316
  Explicitly specify the field type for searchFields.
2901
3317
  This is required when searchFields is defined, to show the correct control in the UI.
@@ -2909,7 +3325,7 @@ var BaseField3 = z28.object({
2909
3325
  This is required when searchFields is defined.
2910
3326
  `
2911
3327
  ),
2912
- options: z28.array(SelectOption).optional(),
3328
+ options: z30.array(SelectOption).optional(),
2913
3329
  searchCriteriaLabelPrefix: TranslationConfig.optional().describe(
2914
3330
  `
2915
3331
  This property determines whether to add a prefix (such as "Child" or "Applicant") before the field label
@@ -2930,7 +3346,7 @@ var BaseField3 = z28.object({
2930
3346
  in the country-config > event.advancedSearch configuration. For example: field("child.dob", { searchCriteriaLabelPrefix: TranslationConfig }).
2931
3347
  `
2932
3348
  ),
2933
- conditionals: z28.array(FieldConditional).optional().describe(
3349
+ conditionals: z30.array(FieldConditional).optional().describe(
2934
3350
  `
2935
3351
  In advanced search, we sometimes need to override the default field visibility conditionals.
2936
3352
 
@@ -2944,23 +3360,23 @@ var BaseField3 = z28.object({
2944
3360
  are always rendered in the advanced search form.
2945
3361
  `
2946
3362
  ),
2947
- validations: z28.array(ValidationConfig).optional().describe(
3363
+ validations: z30.array(ValidationConfig).optional().describe(
2948
3364
  `Option for overriding the field validations specifically for advanced search form.`
2949
3365
  ),
2950
3366
  allowedLocations: JurisdictionReference.optional().describe(
2951
3367
  `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.`
2952
3368
  )
2953
3369
  });
2954
- var SearchQueryParams = z28.object({
2955
- eventType: z28.string().optional().describe(
3370
+ var SearchQueryParams = z30.object({
3371
+ eventType: z30.string().optional().describe(
2956
3372
  "Defines type of event so that when redirecting to Advanced Search page, appropriate tab can be selected"
2957
3373
  )
2958
3374
  }).catchall(FieldValue);
2959
3375
  var FieldConfigSchema = BaseField3.extend({
2960
- fieldId: z28.string(),
2961
- fieldType: z28.literal("field")
3376
+ fieldId: z30.string(),
3377
+ fieldType: z30.literal("field")
2962
3378
  });
2963
- var EventFieldIdInput = z28.enum([
3379
+ var EventFieldIdInput = z30.enum([
2964
3380
  "trackingId",
2965
3381
  "status",
2966
3382
  "legalStatuses.REGISTERED.acceptedAt",
@@ -2969,7 +3385,7 @@ var EventFieldIdInput = z28.enum([
2969
3385
  "updatedAt"
2970
3386
  ]);
2971
3387
  var METADATA_FIELD_PREFIX = "event.";
2972
- var EventFieldId = z28.enum([
3388
+ var EventFieldId = z30.enum([
2973
3389
  `${METADATA_FIELD_PREFIX}trackingId`,
2974
3390
  `${METADATA_FIELD_PREFIX}status`,
2975
3391
  `${METADATA_FIELD_PREFIX}legalStatuses.REGISTERED.acceptedAt`,
@@ -2979,195 +3395,60 @@ var EventFieldId = z28.enum([
2979
3395
  ]);
2980
3396
  var EventFieldConfigSchema = BaseField3.extend({
2981
3397
  fieldId: EventFieldId,
2982
- fieldType: z28.literal("event")
3398
+ fieldType: z30.literal("event")
2983
3399
  });
2984
- var AdvancedSearchField = z28.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
3400
+ var AdvancedSearchField = z30.discriminatedUnion("fieldType", [FieldConfigSchema, EventFieldConfigSchema]).superRefine((data, ctx) => {
2985
3401
  if (data.config.searchFields && data.config.searchFields.length > 0) {
2986
3402
  if (!data.label) {
2987
3403
  ctx.addIssue({
2988
- code: z28.ZodIssueCode.custom,
3404
+ code: z30.ZodIssueCode.custom,
2989
3405
  message: "label is required when config.searchFields is defined.",
2990
3406
  path: ["label"]
2991
- });
2992
- }
2993
- if (!data.type) {
2994
- ctx.addIssue({
2995
- code: z28.ZodIssueCode.custom,
2996
- message: "type is required when config.searchFields is defined.",
2997
- path: ["type"]
2998
- });
2999
- }
3000
- }
3001
- });
3002
- var AdvancedSearchConfig = z28.object({
3003
- title: TranslationConfig.describe("Advanced search tab title"),
3004
- fields: z28.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3005
- }).meta({
3006
- id: "AdvancedSearchConfig",
3007
- 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()`)."
3008
- });
3009
-
3010
- // ../commons/src/events/utils.ts
3011
- var import_lodash = require("lodash");
3012
-
3013
- // ../commons/src/conditionals/validate.ts
3014
- var import__ = __toESM(require("ajv/dist/2019"));
3015
- var import_ajv_formats = __toESM(require("ajv-formats"));
3016
- var z31 = __toESM(require("zod/v4"));
3017
- var import_date_fns = require("date-fns");
3018
-
3019
- // ../commons/src/events/FieldTypeMapping.ts
3020
- var z30 = __toESM(require("zod/v4"));
3021
-
3022
- // ../commons/src/events/DynamicFieldValue.ts
3023
- var z29 = __toESM(require("zod/v4"));
3024
-
3025
- // ../commons/src/conditionals/validate.ts
3026
- var ajv = new import__.default({
3027
- $data: true,
3028
- allowUnionTypes: true,
3029
- strict: false
3030
- // Allow minContains and other newer features
3031
- });
3032
- var DataContext = z31.object({
3033
- rootData: z31.object({
3034
- $leafAdminStructureLocationIds: z31.array(z31.object({ id: UUID }))
3035
- })
3036
- });
3037
- function resolveDataPath(rootData, dataPath, instancePath) {
3038
- const pathParts = dataPath.split("/");
3039
- const levels = parseInt(pathParts[0], 10);
3040
- const referencePath = pathParts.slice(1);
3041
- const instanceParts = instancePath.split("/").filter(Boolean);
3042
- const traversedParts = instanceParts.slice(0, -levels);
3043
- let current = rootData;
3044
- for (const part of traversedParts) {
3045
- if (current === null || current === void 0) {
3046
- return void 0;
3047
- }
3048
- current = current[part];
3049
- }
3050
- for (const part of referencePath) {
3051
- if (current === null || current === void 0) {
3052
- return void 0;
3053
- }
3054
- current = current[part];
3055
- }
3056
- return current;
3057
- }
3058
- function todayISO() {
3059
- return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3060
- }
3061
- var compiledFunctionCache = /* @__PURE__ */ new Map();
3062
- function compileClientFunction(code) {
3063
- let fn = compiledFunctionCache.get(code);
3064
- if (!fn) {
3065
- fn = new Function(`return (${code})`)();
3066
- compiledFunctionCache.set(code, fn);
3067
- }
3068
- return fn;
3069
- }
3070
- (0, import_ajv_formats.default)(ajv);
3071
- function buildClientFunctionContext(input) {
3072
- return {
3073
- $form: input.form,
3074
- $now: todayISO(),
3075
- // eslint-disable-next-line @typescript-eslint/no-use-before-define
3076
- $online: isOnline(),
3077
- $user: input.validatorContext?.user,
3078
- $event: input.validatorContext?.event,
3079
- $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3080
- user: input.systemVariables?.user,
3081
- $window: input.systemVariables?.$window,
3082
- locations: input.locations,
3083
- adminLevelIds: input.adminLevelIds
3084
- };
3085
- }
3086
- function runClientFunction(code, data, context) {
3087
- return compileClientFunction(code)(data, context);
3088
- }
3089
- ajv.addKeyword({
3090
- keyword: "daysFromDate",
3091
- type: "string",
3092
- schemaType: "object",
3093
- $data: true,
3094
- errors: true,
3095
- validate(schema, data, _2, dataContext) {
3096
- if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
3097
- throw new Error("Validation context must contain $now");
3098
- }
3099
- const { days, clause } = schema;
3100
- if (typeof data !== "string") {
3101
- return false;
3102
- }
3103
- const date = new Date(data);
3104
- if (isNaN(date.getTime())) {
3105
- return false;
3106
- }
3107
- let referenceDate = schema.referenceDate;
3108
- if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
3109
- referenceDate = resolveDataPath(
3110
- dataContext.rootData,
3111
- referenceDate.$data,
3112
- dataContext.instancePath
3113
- );
3114
- }
3115
- if (!referenceDate) {
3116
- referenceDate = dataContext.rootData.$now;
3117
- }
3118
- const baseDate = new Date(referenceDate);
3119
- if (isNaN(baseDate.getTime())) {
3120
- return false;
3121
- }
3122
- const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
3123
- return clause === "after" ? (0, import_date_fns.isAfter)(date, offsetDate) : (0, import_date_fns.isBefore)(date, offsetDate);
3124
- }
3125
- });
3126
- ajv.addKeyword({
3127
- keyword: "isLeafLevelLocation",
3128
- type: "string",
3129
- schemaType: "boolean",
3130
- $data: true,
3131
- errors: true,
3132
- // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3133
- validate(_schema, data, _2, dataContext) {
3134
- const locationIdInput = data;
3135
- const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3136
- return locations.some((location) => location.id === locationIdInput);
3137
- }
3138
- });
3139
- ajv.addKeyword({
3140
- keyword: "customClientValidator",
3141
- schemaType: "object",
3142
- errors: true,
3143
- // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3144
- // `validate()` callers build root data via `buildClientFunctionContext`,
3145
- // so the cast holds.
3146
- validate(schema, data, _2, dataContext) {
3147
- return Boolean(
3148
- runClientFunction(
3149
- schema.code,
3150
- data,
3151
- dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3152
- )
3153
- );
3407
+ });
3408
+ }
3409
+ if (!data.type) {
3410
+ ctx.addIssue({
3411
+ code: z30.ZodIssueCode.custom,
3412
+ message: "type is required when config.searchFields is defined.",
3413
+ path: ["type"]
3414
+ });
3415
+ }
3154
3416
  }
3155
3417
  });
3156
- function isOnline() {
3157
- if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3158
- return navigator.onLine;
3159
- }
3160
- return true;
3161
- }
3418
+ var AdvancedSearchConfig = z30.object({
3419
+ title: TranslationConfig.describe("Advanced search tab title"),
3420
+ fields: z30.array(AdvancedSearchField).describe("Advanced search fields within the tab.")
3421
+ }).meta({
3422
+ id: "AdvancedSearchConfig",
3423
+ 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()`)."
3424
+ });
3162
3425
 
3163
- // ../commons/src/utils.ts
3426
+ // ../commons/src/events/utils.ts
3427
+ var import_lodash4 = require("lodash");
3428
+
3429
+ // ../commons/src/conditionals/validate.ts
3430
+ var import__ = __toESM(require("ajv/dist/2019"));
3431
+ var import_ajv_formats = __toESM(require("ajv-formats"));
3432
+ var z34 = __toESM(require("zod/v4"));
3433
+ var import_date_fns2 = require("date-fns");
3434
+
3435
+ // ../commons/src/events/FieldTypeMapping.ts
3164
3436
  var z32 = __toESM(require("zod/v4"));
3437
+
3438
+ // ../commons/src/events/DynamicFieldValue.ts
3439
+ var z31 = __toESM(require("zod/v4"));
3440
+
3441
+ // ../commons/src/events/state/index.ts
3442
+ var import_lodash3 = require("lodash");
3443
+
3444
+ // ../commons/src/utils.ts
3445
+ var z33 = __toESM(require("zod/v4"));
3165
3446
  var _ = __toESM(require("lodash"));
3166
- var FullNameV1 = z32.array(
3167
- z32.object({
3168
- use: z32.string(),
3169
- family: z32.string(),
3170
- given: z32.array(z32.string())
3447
+ var FullNameV1 = z33.array(
3448
+ z33.object({
3449
+ use: z33.string(),
3450
+ family: z33.string(),
3451
+ given: z33.array(z33.string())
3171
3452
  })
3172
3453
  );
3173
3454
  function omitKeyDeep(obj, keyToRemove) {
@@ -3186,39 +3467,62 @@ function omitKeyDeep(obj, keyToRemove) {
3186
3467
  return newObj;
3187
3468
  }
3188
3469
 
3189
- // ../commons/src/events/utils.ts
3190
- var import_date_fns2 = require("date-fns");
3191
- function getDeclarationFields(configuration) {
3192
- return configuration.declaration.pages.flatMap(({ fields }) => fields);
3193
- }
3194
- var getActionAnnotationFields = (actionConfig) => {
3195
- if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
3196
- return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
3197
- }
3198
- if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3199
- return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3200
- }
3201
- if (actionConfig.type === ActionType.CUSTOM) {
3202
- return actionConfig.form;
3203
- }
3204
- if ("review" in actionConfig) {
3205
- return actionConfig.review.fields;
3206
- }
3207
- return [];
3208
- };
3209
- function getAllAnnotationFields(config) {
3210
- return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
3211
- }
3212
- var findAllFields = (config) => {
3213
- return (0, import_lodash.flattenDeep)([
3214
- ...getDeclarationFields(config),
3215
- ...getAllAnnotationFields(config)
3216
- ]);
3217
- };
3218
- var EXCLUDED_ACTIONS = [
3219
- ActionType.REQUEST_CORRECTION,
3470
+ // ../commons/src/events/state/utils.ts
3471
+ var import_lodash = require("lodash");
3472
+ var updateActions = ActionTypes.extract([
3473
+ ActionType.CREATE,
3474
+ ActionType.NOTIFY,
3475
+ ActionType.EDIT,
3476
+ ActionType.DECLARE,
3477
+ ActionType.REGISTER,
3478
+ ActionType.REJECT,
3479
+ ActionType.ARCHIVE,
3480
+ ActionType.UNARCHIVE,
3220
3481
  ActionType.PRINT_CERTIFICATE,
3221
- ActionType.REJECT_CORRECTION
3482
+ ActionType.REQUEST_CORRECTION,
3483
+ ActionType.APPROVE_CORRECTION,
3484
+ ActionType.REJECT_CORRECTION,
3485
+ ActionType.CUSTOM
3486
+ ]);
3487
+
3488
+ // ../commons/src/events/state/flags.ts
3489
+ var import_lodash2 = require("lodash");
3490
+ var import_date_fns = require("date-fns");
3491
+ var INHERENT_FLAG_RULES = [
3492
+ {
3493
+ flag: InherentFlags.CORRECTION_REQUESTED,
3494
+ setOn: [ActionType.REQUEST_CORRECTION],
3495
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
3496
+ },
3497
+ {
3498
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
3499
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
3500
+ // are deliberately excluded so the flag freezes across an archive/unarchive
3501
+ // round trip and comes back exactly as it was.
3502
+ flag: InherentFlags.INCOMPLETE,
3503
+ setOn: [ActionType.NOTIFY],
3504
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
3505
+ },
3506
+ {
3507
+ flag: InherentFlags.REJECTED,
3508
+ setOn: [ActionType.REJECT],
3509
+ resetOn: [
3510
+ ActionType.NOTIFY,
3511
+ ActionType.DECLARE,
3512
+ ActionType.EDIT,
3513
+ ActionType.REGISTER
3514
+ ]
3515
+ },
3516
+ {
3517
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
3518
+ setOn: [ActionType.DUPLICATE_DETECTED],
3519
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
3520
+ },
3521
+ {
3522
+ flag: InherentFlags.EDIT_IN_PROGRESS,
3523
+ setOn: [ActionType.EDIT],
3524
+ resetOnAnyOtherAction: true
3525
+ }
3222
3526
  ];
3223
3527
 
3224
3528
  // ../commons/src/conditionals/conditionals.ts
@@ -3427,6 +3731,33 @@ function defineComparison(field3, value, keyword) {
3427
3731
  required: [field3.$$field]
3428
3732
  });
3429
3733
  }
3734
+ function flag(flagvalue) {
3735
+ return defineConditional({
3736
+ type: "object",
3737
+ properties: {
3738
+ $flags: {
3739
+ type: "array",
3740
+ contains: {
3741
+ type: "string",
3742
+ const: flagvalue
3743
+ }
3744
+ }
3745
+ },
3746
+ required: ["$flags"]
3747
+ });
3748
+ }
3749
+ function status(statusValue) {
3750
+ return defineConditional({
3751
+ type: "object",
3752
+ properties: {
3753
+ $status: {
3754
+ type: "string",
3755
+ const: statusValue
3756
+ }
3757
+ },
3758
+ required: ["$status"]
3759
+ });
3760
+ }
3430
3761
  function createFieldConditionals(fieldId) {
3431
3762
  const getDayRange = (field3, days, clause, referenceDate) => ({
3432
3763
  type: "object",
@@ -3828,6 +4159,176 @@ function createFieldConditionals(fieldId) {
3828
4159
  };
3829
4160
  }
3830
4161
 
4162
+ // ../commons/src/conditionals/validate.ts
4163
+ var ajv = new import__.default({
4164
+ $data: true,
4165
+ allowUnionTypes: true,
4166
+ strict: false
4167
+ // Allow minContains and other newer features
4168
+ });
4169
+ var DataContext = z34.object({
4170
+ rootData: z34.object({
4171
+ $leafAdminStructureLocationIds: z34.array(z34.object({ id: UUID }))
4172
+ })
4173
+ });
4174
+ function resolveDataPath(rootData, dataPath, instancePath) {
4175
+ const pathParts = dataPath.split("/");
4176
+ const levels = parseInt(pathParts[0], 10);
4177
+ const referencePath = pathParts.slice(1);
4178
+ const instanceParts = instancePath.split("/").filter(Boolean);
4179
+ const traversedParts = instanceParts.slice(0, -levels);
4180
+ let current = rootData;
4181
+ for (const part of traversedParts) {
4182
+ if (current === null || current === void 0) {
4183
+ return void 0;
4184
+ }
4185
+ current = current[part];
4186
+ }
4187
+ for (const part of referencePath) {
4188
+ if (current === null || current === void 0) {
4189
+ return void 0;
4190
+ }
4191
+ current = current[part];
4192
+ }
4193
+ return current;
4194
+ }
4195
+ function todayISO() {
4196
+ return (0, import_date_fns2.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
4197
+ }
4198
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
4199
+ function compileClientFunction(code) {
4200
+ let fn = compiledFunctionCache.get(code);
4201
+ if (!fn) {
4202
+ fn = new Function(`return (${code})`)();
4203
+ compiledFunctionCache.set(code, fn);
4204
+ }
4205
+ return fn;
4206
+ }
4207
+ (0, import_ajv_formats.default)(ajv);
4208
+ function buildClientFunctionContext(input) {
4209
+ return {
4210
+ $form: input.form,
4211
+ $flags: input.validatorContext?.event?.state.flags ?? [],
4212
+ $now: todayISO(),
4213
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
4214
+ $online: isOnline(),
4215
+ $user: input.validatorContext?.user,
4216
+ $event: input.validatorContext?.event?.document,
4217
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
4218
+ user: input.systemVariables?.user,
4219
+ $window: input.systemVariables?.$window,
4220
+ locations: input.locations,
4221
+ adminLevelIds: input.adminLevelIds
4222
+ };
4223
+ }
4224
+ function runClientFunction(code, data, context) {
4225
+ return compileClientFunction(code)(data, context);
4226
+ }
4227
+ ajv.addKeyword({
4228
+ keyword: "daysFromDate",
4229
+ type: "string",
4230
+ schemaType: "object",
4231
+ $data: true,
4232
+ errors: true,
4233
+ validate(schema, data, _2, dataContext) {
4234
+ if (!(dataContext && dataContext.rootData && typeof dataContext.rootData === "object" && "$now" in dataContext.rootData && typeof dataContext.rootData.$now === "string")) {
4235
+ throw new Error("Validation context must contain $now");
4236
+ }
4237
+ const { days, clause } = schema;
4238
+ if (typeof data !== "string") {
4239
+ return false;
4240
+ }
4241
+ const date = new Date(data);
4242
+ if (isNaN(date.getTime())) {
4243
+ return false;
4244
+ }
4245
+ let referenceDate = schema.referenceDate;
4246
+ if (referenceDate && typeof referenceDate === "object" && "$data" in referenceDate) {
4247
+ referenceDate = resolveDataPath(
4248
+ dataContext.rootData,
4249
+ referenceDate.$data,
4250
+ dataContext.instancePath
4251
+ );
4252
+ }
4253
+ if (!referenceDate) {
4254
+ referenceDate = dataContext.rootData.$now;
4255
+ }
4256
+ const baseDate = new Date(referenceDate);
4257
+ if (isNaN(baseDate.getTime())) {
4258
+ return false;
4259
+ }
4260
+ const offsetDate = new Date(baseDate.getTime() + days * 24 * 60 * 60 * 1e3);
4261
+ return clause === "after" ? (0, import_date_fns2.isAfter)(date, offsetDate) : (0, import_date_fns2.isBefore)(date, offsetDate);
4262
+ }
4263
+ });
4264
+ ajv.addKeyword({
4265
+ keyword: "isLeafLevelLocation",
4266
+ type: "string",
4267
+ schemaType: "boolean",
4268
+ $data: true,
4269
+ errors: true,
4270
+ // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
4271
+ validate(_schema, data, _2, dataContext) {
4272
+ const locationIdInput = data;
4273
+ const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
4274
+ return locations.some((location) => location.id === locationIdInput);
4275
+ }
4276
+ });
4277
+ ajv.addKeyword({
4278
+ keyword: "customClientValidator",
4279
+ schemaType: "object",
4280
+ errors: true,
4281
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
4282
+ // `validate()` callers build root data via `buildClientFunctionContext`,
4283
+ // so the cast holds.
4284
+ validate(schema, data, _2, dataContext) {
4285
+ return Boolean(
4286
+ runClientFunction(
4287
+ schema.code,
4288
+ data,
4289
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
4290
+ )
4291
+ );
4292
+ }
4293
+ });
4294
+ function isOnline() {
4295
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
4296
+ return navigator.onLine;
4297
+ }
4298
+ return true;
4299
+ }
4300
+
4301
+ // ../commons/src/events/utils.ts
4302
+ var import_date_fns3 = require("date-fns");
4303
+ function getDeclarationFields(configuration) {
4304
+ return configuration.declaration.pages.flatMap(({ fields }) => fields);
4305
+ }
4306
+ var getActionAnnotationFields = (actionConfig) => {
4307
+ if (actionConfig.type === ActionType.REQUEST_CORRECTION) {
4308
+ return actionConfig.correctionForm.pages.flatMap(({ fields }) => fields);
4309
+ }
4310
+ if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
4311
+ return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
4312
+ }
4313
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
4314
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
4315
+ return [...reviewFields, ...formFields];
4316
+ };
4317
+ function getAllAnnotationFields(config) {
4318
+ return (0, import_lodash4.flattenDeep)(config.actions.map(getActionAnnotationFields));
4319
+ }
4320
+ var findAllFields = (config) => {
4321
+ return (0, import_lodash4.flattenDeep)([
4322
+ ...getDeclarationFields(config),
4323
+ ...getAllAnnotationFields(config)
4324
+ ]);
4325
+ };
4326
+ var EXCLUDED_ACTIONS = [
4327
+ ActionType.REQUEST_CORRECTION,
4328
+ ActionType.PRINT_CERTIFICATE,
4329
+ ActionType.REJECT_CORRECTION
4330
+ ];
4331
+
3831
4332
  // ../commons/src/events/eventConfigValidation.ts
3832
4333
  function validateAdvancedSearchConfig(event2, ctx) {
3833
4334
  const allFields = findAllFields(event2);
@@ -3910,9 +4411,9 @@ function validatePlaceOfEvent(event2, ctx) {
3910
4411
  }
3911
4412
  function validateActionFlags(event2, ctx) {
3912
4413
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3913
- const configuredFlagIds = event2.flags.map((flag) => flag.id);
4414
+ const configuredFlagIds = event2.flags.map((flag2) => flag2.id);
3914
4415
  const actionFlagIds = event2.actions.flatMap(
3915
- (action) => action.flags.map((flag) => flag.id)
4416
+ (action) => (action.flags ?? []).map((flag2) => flag2.id)
3916
4417
  );
3917
4418
  for (const actionFlagId of actionFlagIds) {
3918
4419
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -3948,11 +4449,11 @@ function validateActionOrder(event2, ctx) {
3948
4449
  }
3949
4450
 
3950
4451
  // ../commons/src/events/EventConfig.ts
3951
- var EventFieldReference = z33.object({ $$event: EventMetadataDateFieldIdInput }).describe(
4452
+ var EventFieldReference = z35.object({ $$event: EventMetadataDateFieldIdInput }).describe(
3952
4453
  "Reference to a field defined in the event metadata, using the field id."
3953
4454
  );
3954
- var _EventConfigBase = z33.object({
3955
- id: z33.string().describe(
4455
+ var _EventConfigBase = z35.object({
4456
+ id: z35.string().describe(
3956
4457
  'Machine-readable identifier of the event (e.g. "birth", "death").'
3957
4458
  ),
3958
4459
  dateOfEvent: FieldReference.or(EventFieldReference).optional().describe(
@@ -3971,23 +4472,26 @@ var _EventConfigBase = z33.object({
3971
4472
  "Summary information displayed in the event overview."
3972
4473
  ),
3973
4474
  label: TranslationConfig.describe("Human-readable label for the event type."),
3974
- actions: z33.array(ActionConfig).describe(
4475
+ actions: z35.array(ActionConfig).describe(
3975
4476
  "Configuration of core and custom actions associated with the event."
3976
4477
  ),
3977
- actionOrder: z33.array(z33.string()).optional().describe(
4478
+ actionOrder: z35.array(z35.string()).optional().describe(
3978
4479
  "Order of actions in the action menu. Use either the action type for core actions or the customActionType for custom actions."
3979
4480
  ),
3980
4481
  declaration: DeclarationFormConfig.describe(
3981
4482
  "Configuration of the form used to gather event data."
3982
4483
  ),
3983
- advancedSearch: z33.array(AdvancedSearchConfig).optional().default([]).describe(
4484
+ advancedSearch: z35.array(AdvancedSearchConfig).optional().default([]).describe(
3984
4485
  "Configuration of fields available in the advanced search feature."
3985
4486
  ),
3986
- flags: z33.array(FlagConfig).optional().default([]).describe(
4487
+ flags: z35.array(FlagConfig).optional().default([]).describe(
3987
4488
  "Configuration of custom flags associated with the actions of this event type."
3988
4489
  ),
3989
- analytics: z33.boolean().optional().default(true).describe(
4490
+ analytics: z35.boolean().optional().default(true).describe(
3990
4491
  "Indicates whether the records of this event type are included in analytics"
4492
+ ),
4493
+ icon: z35.partialRecord(AvailableIcons, Conditional).optional().describe(
4494
+ '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.'
3991
4495
  )
3992
4496
  });
3993
4497
  var EventConfig = _EventConfigBase.superRefine((event2, ctx) => {
@@ -4007,7 +4511,7 @@ var defineActionForm = (actionForm) => ActionFormConfig.parse(actionForm);
4007
4511
  var defineFormPage = (formPage) => FormPageConfig.parse(formPage);
4008
4512
 
4009
4513
  // ../commons/src/events/WorkqueueConfig.ts
4010
- var z37 = __toESM(require("zod/v4"));
4514
+ var z38 = __toESM(require("zod/v4"));
4011
4515
 
4012
4516
  // ../commons/src/searchConfigs.ts
4013
4517
  function createSearchConfig(baseField) {
@@ -4204,21 +4708,31 @@ var event = Object.assign(eventFn, {
4204
4708
  return {
4205
4709
  $event: field3
4206
4710
  };
4207
- }
4711
+ },
4712
+ /**
4713
+ * Checks if the event currently has the given status.
4714
+ * @param eventStatus - The status to check for.
4715
+ */
4716
+ hasStatus: (eventStatus) => status(eventStatus),
4717
+ /**
4718
+ * Checks if the event currently carries the given flag.
4719
+ * @param flagValue - The flag to check for.
4720
+ */
4721
+ hasFlag: (flagValue) => flag(flagValue)
4208
4722
  });
4209
4723
 
4210
4724
  // ../commons/src/events/WorkqueueColumnConfig.ts
4211
- var z34 = __toESM(require("zod/v4"));
4725
+ var z36 = __toESM(require("zod/v4"));
4212
4726
  var WorkqueueColumnKeysArray = [
4213
4727
  ...EventMetadataKeysArray,
4214
4728
  "title",
4215
4729
  "outbox"
4216
4730
  ];
4217
- var WorkqueueColumnKeys = z34.enum(WorkqueueColumnKeysArray);
4218
- var WorkqueueColumnValue = z34.object({
4731
+ var WorkqueueColumnKeys = z36.enum(WorkqueueColumnKeysArray);
4732
+ var WorkqueueColumnValue = z36.object({
4219
4733
  $event: WorkqueueColumnKeys
4220
4734
  });
4221
- var WorkqueueColumn = z34.object({
4735
+ var WorkqueueColumn = z36.object({
4222
4736
  label: TranslationConfig,
4223
4737
  value: WorkqueueColumnValue
4224
4738
  }).meta({
@@ -4232,164 +4746,56 @@ function defineWorkqueuesColumns(workqueueColumns) {
4232
4746
  }
4233
4747
 
4234
4748
  // ../commons/src/events/CountryConfigQueryInput.ts
4235
- var z35 = __toESM(require("zod/v4"));
4236
- var SerializableExact = z35.object({
4237
- type: z35.literal("exact"),
4238
- term: z35.union([z35.string(), SerializedUserField])
4239
- });
4240
- var SerializableWithin = z35.object({
4241
- type: z35.literal("within"),
4242
- location: z35.union([z35.string(), SerializedUserField])
4243
- });
4244
- var SerializedQueryExpression = z35.object({
4245
- eventType: z35.string(),
4246
- status: z35.optional(z35.union([AnyOfStatus, ExactStatus])),
4247
- createdAt: z35.optional(DateCondition),
4248
- updatedAt: z35.optional(DateCondition),
4249
- "legalStatuses.DECLARED.createdAtLocation": z35.optional(SerializableWithin),
4250
- "legalStatuses.DECLARED.createdByRole": z35.optional(AnyOf),
4251
- "legalStatuses.REGISTERED.createdAt": z35.optional(DateCondition),
4252
- "legalStatuses.REGISTERED.createdAtLocation": z35.optional(SerializableWithin),
4253
- "legalStatuses.REGISTERED.createdByRole": z35.optional(AnyOf),
4254
- "legalStatuses.REGISTERED.registrationNumber": z35.optional(Exact),
4255
- createdAtLocation: z35.optional(
4256
- z35.union([SerializableWithin, SerializableExact])
4749
+ var z37 = __toESM(require("zod/v4"));
4750
+ var SerializableExact = z37.object({
4751
+ type: z37.literal("exact"),
4752
+ term: z37.union([z37.string(), SerializedUserField])
4753
+ });
4754
+ var SerializableWithin = z37.object({
4755
+ type: z37.literal("within"),
4756
+ location: z37.union([z37.string(), SerializedUserField])
4757
+ });
4758
+ var SerializedQueryExpression = z37.object({
4759
+ eventType: z37.string(),
4760
+ status: z37.optional(z37.union([AnyOfStatus, ExactStatus])),
4761
+ createdAt: z37.optional(DateCondition),
4762
+ updatedAt: z37.optional(DateCondition),
4763
+ "legalStatuses.DECLARED.createdAtLocation": z37.optional(SerializableWithin),
4764
+ "legalStatuses.DECLARED.createdByRole": z37.optional(AnyOf),
4765
+ "legalStatuses.REGISTERED.createdAt": z37.optional(DateCondition),
4766
+ "legalStatuses.REGISTERED.createdAtLocation": z37.optional(SerializableWithin),
4767
+ "legalStatuses.REGISTERED.createdByRole": z37.optional(AnyOf),
4768
+ "legalStatuses.REGISTERED.registrationNumber": z37.optional(Exact),
4769
+ createdAtLocation: z37.optional(
4770
+ z37.union([SerializableWithin, SerializableExact])
4257
4771
  ),
4258
- updatedAtLocation: z35.optional(
4259
- z35.union([SerializableWithin, SerializableExact])
4772
+ updatedAtLocation: z37.optional(
4773
+ z37.union([SerializableWithin, SerializableExact])
4260
4774
  ),
4261
- updatedByUserRole: z35.optional(SerializableExact),
4262
- assignedTo: z35.optional(SerializableExact),
4263
- createdBy: z35.optional(SerializableExact),
4775
+ updatedByUserRole: z37.optional(SerializableExact),
4776
+ assignedTo: z37.optional(SerializableExact),
4777
+ createdBy: z37.optional(SerializableExact),
4264
4778
  createdByUserType: ExactUserType,
4265
- updatedBy: z35.optional(SerializableExact),
4266
- trackingId: z35.optional(Exact),
4267
- flags: z35.optional(ContainsFlags),
4779
+ updatedBy: z37.optional(SerializableExact),
4780
+ trackingId: z37.optional(Exact),
4781
+ flags: z37.optional(ContainsFlags),
4268
4782
  data: QueryInput
4269
4783
  }).partial();
4270
- var Or2 = z35.object({
4271
- type: z35.literal("or"),
4272
- clauses: z35.array(SerializedQueryExpression)
4784
+ var Or2 = z37.object({
4785
+ type: z37.literal("or"),
4786
+ clauses: z37.array(SerializedQueryExpression)
4273
4787
  });
4274
- var And2 = z35.object({
4275
- type: z35.literal("and"),
4276
- clauses: z35.array(SerializedQueryExpression)
4788
+ var And2 = z37.object({
4789
+ type: z37.literal("and"),
4790
+ clauses: z37.array(SerializedQueryExpression)
4277
4791
  });
4278
- var CountryConfigQueryType = z35.discriminatedUnion("type", [And2, Or2]);
4279
- var CountryConfigQueryInputType = z35.union([
4792
+ var CountryConfigQueryType = z37.discriminatedUnion("type", [And2, Or2]);
4793
+ var CountryConfigQueryInputType = z37.union([
4280
4794
  SerializedQueryExpression,
4281
4795
  And2,
4282
4796
  Or2
4283
4797
  ]);
4284
4798
 
4285
- // ../commons/src/icons.ts
4286
- var z36 = __toESM(require("zod/v4"));
4287
- var AvailableIcons = z36.enum([
4288
- "Archived",
4289
- "Assigned",
4290
- "Briefcase",
4291
- "Certified",
4292
- "Close",
4293
- "Collapse",
4294
- "Draft",
4295
- "DuplicateYellow",
4296
- "Expand",
4297
- "ExternalValidate",
4298
- "FilledCheck",
4299
- "InReview",
4300
- "Offline",
4301
- "Registered",
4302
- "RequiresUpdates",
4303
- "Sent",
4304
- "Validated",
4305
- "WaitingApproval",
4306
- "ChartActivity",
4307
- "Activity",
4308
- "Archive",
4309
- "ArchiveTray",
4310
- "ArrowLeft",
4311
- "ArrowRight",
4312
- "Buildings",
4313
- "Circle",
4314
- "CaretDown",
4315
- "CaretLeft",
4316
- "CaretRight",
4317
- "ChartBar",
4318
- "ChartLine",
4319
- "ChatCircle",
4320
- "CheckSquare",
4321
- "Compass",
4322
- "Check",
4323
- "Copy",
4324
- "Database",
4325
- "DotsThreeVertical",
4326
- "ArrowCounterClockwise",
4327
- "MagnifyingGlassMinus",
4328
- "MagnifyingGlassPlus",
4329
- "Export",
4330
- "Eye",
4331
- "EyeSlash",
4332
- "Envelope",
4333
- "File",
4334
- "FileSearch",
4335
- "FileMinus",
4336
- "FilePlus",
4337
- "FileText",
4338
- "FileX",
4339
- "Handshake",
4340
- "Gear",
4341
- "GitBranch",
4342
- "IdentificationCard",
4343
- "List",
4344
- "ListBullets",
4345
- "Lock",
4346
- "MagnifyingGlass",
4347
- "MapPin",
4348
- "Medal",
4349
- "NotePencil",
4350
- "Paperclip",
4351
- "PaperPlaneTilt",
4352
- "Pen",
4353
- "PenNib",
4354
- "Pencil",
4355
- "PencilSimpleLine",
4356
- "Phone",
4357
- "Plus",
4358
- "Printer",
4359
- "SignOut",
4360
- "Stamp",
4361
- "Star",
4362
- "Target",
4363
- "TextT",
4364
- "Trash",
4365
- "UploadSimple",
4366
- "User",
4367
- "UserPlus",
4368
- "Users",
4369
- "WarningCircle",
4370
- "X",
4371
- "ChatText",
4372
- "CircleWavyCheck",
4373
- "CircleWavyQuestion",
4374
- "ArchiveBox",
4375
- "ArrowCircleDown",
4376
- "FileArrowUp",
4377
- "FileDotted",
4378
- "Files",
4379
- "PencilLine",
4380
- "PencilCircle",
4381
- "UserCircle",
4382
- "Clock",
4383
- "QrCode",
4384
- "Webcam",
4385
- "Sun",
4386
- "DeviceTabletCamera",
4387
- "Globe",
4388
- "Fingerprint",
4389
- "PushPin",
4390
- "Timer"
4391
- ]);
4392
-
4393
4799
  // ../commons/src/events/WorkqueueConfig.ts
4394
4800
  var mandatoryColumns = defineWorkqueuesColumns([
4395
4801
  {
@@ -4409,16 +4815,16 @@ var mandatoryColumns = defineWorkqueuesColumns([
4409
4815
  value: event.field("updatedAt")
4410
4816
  }
4411
4817
  ]);
4412
- var WorkqueueConfig = z37.object({
4413
- slug: z37.string().describe("Determines the url of the workqueue."),
4818
+ var WorkqueueConfig = z38.object({
4819
+ slug: z38.string().describe("Determines the url of the workqueue."),
4414
4820
  name: TranslationConfig.describe(
4415
4821
  "Title of the workflow (both in navigation and on the page)"
4416
4822
  ),
4417
4823
  query: CountryConfigQueryType,
4418
- action: z37.object({ type: WorkqueueActionType }).optional().describe(
4824
+ action: z38.object({ type: WorkqueueActionType }).optional().describe(
4419
4825
  "Workqueue call-to-action button configuration. This determines the quick action button shown on each event card and the action taken when the button is clicked."
4420
4826
  ),
4421
- columns: z37.array(WorkqueueColumn).default(mandatoryColumns),
4827
+ columns: z38.array(WorkqueueColumn).default(mandatoryColumns),
4422
4828
  icon: AvailableIcons,
4423
4829
  emptyMessage: TranslationConfig.optional()
4424
4830
  }).describe("Configuration for workqueue.");
@@ -4432,10 +4838,10 @@ var WorkqueueConfigInput = WorkqueueConfig.extend({
4432
4838
  id: "WorkqueueConfig",
4433
4839
  description: "Configuration for a single workqueue. Defines the filter applied to the event index, the quick-action button, the columns shown on each row, and the message rendered when the queue is empty."
4434
4840
  });
4435
- var WorkqueueCountInput = z37.array(
4436
- z37.object({ slug: z37.string(), query: QueryType })
4841
+ var WorkqueueCountInput = z38.array(
4842
+ z38.object({ slug: z38.string(), query: QueryType })
4437
4843
  );
4438
- var WorkqueueCountOutput = z37.record(z37.string(), z37.number());
4844
+ var WorkqueueCountOutput = z38.record(z38.string(), z38.number());
4439
4845
 
4440
4846
  // ../commons/src/events/workqueueDefaultColumns.ts
4441
4847
  var defaultWorkqueueColumns = [
@@ -4458,21 +4864,21 @@ var defaultWorkqueueColumns = [
4458
4864
  ];
4459
4865
 
4460
4866
  // ../commons/src/events/Draft.ts
4461
- var z39 = __toESM(require("zod/v4"));
4867
+ var z40 = __toESM(require("zod/v4"));
4462
4868
 
4463
4869
  // ../commons/src/events/ActionInput.ts
4464
- var z38 = __toESM(require("zod/v4"));
4465
- var BaseActionInput = z38.object({
4870
+ var z39 = __toESM(require("zod/v4"));
4871
+ var BaseActionInput = z39.object({
4466
4872
  eventId: UUID,
4467
- transactionId: z38.string(),
4873
+ transactionId: z39.string(),
4468
4874
  declaration: ActionUpdate.default({}),
4469
4875
  annotation: ActionUpdate.optional(),
4470
4876
  originalActionId: UUID.optional(),
4471
4877
  // should not be part of base action.
4472
- keepAssignment: z38.boolean().optional(),
4473
- keepAssignmentIfAccepted: z38.boolean().optional(),
4474
- keepAssignmentIfRejected: z38.boolean().optional(),
4475
- waitFor: z38.boolean().default(true).describe(
4878
+ keepAssignment: z39.boolean().optional(),
4879
+ keepAssignmentIfAccepted: z39.boolean().optional(),
4880
+ keepAssignmentIfRejected: z39.boolean().optional(),
4881
+ waitFor: z39.boolean().default(true).describe(
4476
4882
  "Whether action waits for the indexing before returning. Defaults to true. Setting this to to false completes faster but might lead to stale data in the client if the client tries to read the event immediately after performing the action. Use with care."
4477
4883
  ),
4478
4884
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
@@ -4482,8 +4888,8 @@ var BaseActionInput = z38.object({
4482
4888
  )
4483
4889
  });
4484
4890
  var CreateActionInput = BaseActionInput.extend(
4485
- z38.object({
4486
- type: z38.literal(ActionType.CREATE).default(ActionType.CREATE),
4891
+ z39.object({
4892
+ type: z39.literal(ActionType.CREATE).default(ActionType.CREATE),
4487
4893
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4488
4894
  createdAtLocation: UUID.nullish().describe(
4489
4895
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -4491,14 +4897,14 @@ var CreateActionInput = BaseActionInput.extend(
4491
4897
  }).shape
4492
4898
  );
4493
4899
  var RegisterActionInput = BaseActionInput.extend(
4494
- z38.strictObject({
4495
- type: z38.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4496
- registrationNumber: z38.string().optional()
4900
+ z39.strictObject({
4901
+ type: z39.literal(ActionType.REGISTER).default(ActionType.REGISTER),
4902
+ registrationNumber: z39.string().optional()
4497
4903
  }).shape
4498
4904
  );
4499
4905
  var NotifyActionInput = BaseActionInput.extend(
4500
- z38.object({
4501
- type: z38.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4906
+ z39.object({
4907
+ type: z39.literal(ActionType.NOTIFY).default(ActionType.NOTIFY),
4502
4908
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
4503
4909
  createdAtLocation: UUID.nullish().describe(
4504
4910
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
@@ -4514,101 +4920,107 @@ var NotifyActionInput = BaseActionInput.extend(
4514
4920
  }
4515
4921
  });
4516
4922
  var DeclareActionInput = BaseActionInput.extend(
4517
- z38.object({
4518
- type: z38.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4923
+ z39.object({
4924
+ type: z39.literal(ActionType.DECLARE).default(ActionType.DECLARE)
4519
4925
  }).shape
4520
4926
  );
4521
4927
  var EditActionInput = BaseActionInput.extend(
4522
- z38.object({
4523
- type: z38.literal(ActionType.EDIT).default(ActionType.EDIT),
4524
- content: z38.object({
4525
- comment: z38.string().describe("Comment for the edit action.").optional()
4526
- })
4928
+ z39.object({
4929
+ type: z39.literal(ActionType.EDIT).default(ActionType.EDIT)
4527
4930
  }).shape
4528
4931
  );
4529
4932
  var PrintCertificateActionInput = BaseActionInput.extend(
4530
- z38.object({
4531
- type: z38.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4933
+ z39.object({
4934
+ type: z39.literal(ActionType.PRINT_CERTIFICATE).default(ActionType.PRINT_CERTIFICATE),
4532
4935
  content: PrintContent.optional()
4533
4936
  }).shape
4534
4937
  );
4535
4938
  var RejectDeclarationActionInput = BaseActionInput.extend(
4536
- z38.object({
4537
- type: z38.literal(ActionType.REJECT).default(ActionType.REJECT),
4939
+ z39.object({
4940
+ type: z39.literal(ActionType.REJECT).default(ActionType.REJECT),
4538
4941
  content: ReasonContent
4539
4942
  }).shape
4540
4943
  );
4541
4944
  var DuplicateDetectedActionInput = BaseActionInput.extend(
4542
- z38.object({
4543
- type: z38.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4544
- content: z38.object({
4545
- duplicates: z38.array(PotentialDuplicate)
4945
+ z39.object({
4946
+ type: z39.literal(ActionType.DUPLICATE_DETECTED).default(ActionType.DUPLICATE_DETECTED),
4947
+ content: z39.object({
4948
+ duplicates: z39.array(PotentialDuplicate)
4546
4949
  })
4547
4950
  }).shape
4548
4951
  );
4549
4952
  var MarkAsDuplicateActionInput = BaseActionInput.extend(
4550
- z38.object({
4551
- type: z38.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4552
- content: z38.object({
4953
+ z39.object({
4954
+ type: z39.literal(ActionType.MARK_AS_DUPLICATE).default(ActionType.MARK_AS_DUPLICATE),
4955
+ content: z39.object({
4553
4956
  duplicateOf: UUID
4554
4957
  }).optional()
4555
4958
  }).shape
4556
4959
  );
4557
4960
  var MarkNotDuplicateActionInput = BaseActionInput.extend(
4558
- z38.object({
4559
- type: z38.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4961
+ z39.object({
4962
+ type: z39.literal(ActionType.MARK_AS_NOT_DUPLICATE).default(ActionType.MARK_AS_NOT_DUPLICATE)
4560
4963
  }).shape
4561
4964
  );
4562
4965
  var ArchiveActionInput = BaseActionInput.extend(
4563
- z38.object({
4564
- type: z38.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4565
- content: ReasonContent
4966
+ z39.object({
4967
+ type: z39.literal(ActionType.ARCHIVE).default(ActionType.ARCHIVE),
4968
+ /**
4969
+ * Archiving does not collect a reason on its own. Only the
4970
+ * "mark as duplicate" flow archives with a reason attached.
4971
+ */
4972
+ content: ReasonContent.optional()
4973
+ }).shape
4974
+ );
4975
+ var UnarchiveActionInput = BaseActionInput.extend(
4976
+ z39.object({
4977
+ type: z39.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4566
4978
  }).shape
4567
4979
  );
4568
4980
  var AssignActionInput = BaseActionInput.extend(
4569
- z38.object({
4570
- type: z38.literal(ActionType.ASSIGN),
4571
- assignedTo: z38.string()
4981
+ z39.object({
4982
+ type: z39.literal(ActionType.ASSIGN),
4983
+ assignedTo: z39.string()
4572
4984
  }).shape
4573
4985
  );
4574
4986
  var UnassignActionInput = BaseActionInput.extend(
4575
- z38.object({
4576
- type: z38.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4577
- assignedTo: z38.literal(null).default(null)
4987
+ z39.object({
4988
+ type: z39.literal(ActionType.UNASSIGN).default(ActionType.UNASSIGN),
4989
+ assignedTo: z39.literal(null).default(null)
4578
4990
  }).shape
4579
4991
  );
4580
4992
  var RequestCorrectionActionInput = BaseActionInput.extend(
4581
- z38.object({
4582
- type: z38.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4993
+ z39.object({
4994
+ type: z39.literal(ActionType.REQUEST_CORRECTION).default(ActionType.REQUEST_CORRECTION)
4583
4995
  }).shape
4584
4996
  );
4585
4997
  var RejectCorrectionActionInput = BaseActionInput.extend(
4586
- z38.object({
4587
- requestId: z38.string(),
4588
- type: z38.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4998
+ z39.object({
4999
+ requestId: z39.string(),
5000
+ type: z39.literal(ActionType.REJECT_CORRECTION).default(ActionType.REJECT_CORRECTION),
4589
5001
  content: ReasonContent
4590
5002
  }).shape
4591
5003
  );
4592
5004
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4593
- z38.object({
4594
- requestId: z38.string(),
4595
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4596
- content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
5005
+ z39.object({
5006
+ requestId: z39.string(),
5007
+ type: z39.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
5008
+ content: z39.object({ immediateCorrection: z39.boolean().optional() }).optional()
4597
5009
  }).shape
4598
5010
  );
4599
5011
  var ReadActionInput = BaseActionInput.extend(
4600
- z38.object({
4601
- type: z38.literal(ActionType.READ).default(ActionType.READ)
5012
+ z39.object({
5013
+ type: z39.literal(ActionType.READ).default(ActionType.READ)
4602
5014
  }).shape
4603
5015
  );
4604
- var DeleteActionInput = z38.object({ eventId: UUID });
5016
+ var DeleteActionInput = z39.object({ eventId: UUID });
4605
5017
  var CustomActionInput = BaseActionInput.extend(
4606
- z38.object({
4607
- type: z38.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
4608
- customActionType: z38.string().describe("Name of the custom action.")
5018
+ z39.object({
5019
+ type: z39.literal(ActionType.CUSTOM).default(ActionType.CUSTOM),
5020
+ customActionType: z39.string().describe("Name of the custom action.")
4609
5021
  }).shape
4610
5022
  );
4611
- var ActionInput = z38.discriminatedUnion("type", [
5023
+ var ActionInput = z39.discriminatedUnion("type", [
4612
5024
  CreateActionInput.meta({ id: "CreateActionInput" }),
4613
5025
  RegisterActionInput.meta({ id: "RegisterActionInput" }),
4614
5026
  NotifyActionInput.meta({ id: "NotifyActionInput" }),
@@ -4626,6 +5038,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4626
5038
  id: "MarkNotDuplicateActionInput"
4627
5039
  }),
4628
5040
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
5041
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4629
5042
  AssignActionInput.meta({ id: "AssignActionInput" }),
4630
5043
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4631
5044
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4644,11 +5057,11 @@ var ActionInput = z38.discriminatedUnion("type", [
4644
5057
  });
4645
5058
 
4646
5059
  // ../commons/src/events/Draft.ts
4647
- var Draft = z39.object({
5060
+ var Draft = z40.object({
4648
5061
  id: UUID,
4649
5062
  eventId: UUID,
4650
- transactionId: z39.string(),
4651
- createdAt: z39.string().datetime(),
5063
+ transactionId: z40.string(),
5064
+ createdAt: z40.string().datetime(),
4652
5065
  action: ActionBase.extend({
4653
5066
  type: ActionTypes.exclude([ActionTypes.enum.DELETE])
4654
5067
  }).omit({ id: true, createdAtLocation: true })
@@ -4657,7 +5070,7 @@ var Draft = z39.object({
4657
5070
  );
4658
5071
  var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4659
5072
  type: ActionTypes.exclude([ActionTypes.enum.DELETE]),
4660
- status: z39.enum([
5073
+ status: z40.enum([
4661
5074
  ActionStatus.Requested,
4662
5075
  ActionStatus.Accepted,
4663
5076
  ActionStatus.Rejected
@@ -4665,93 +5078,33 @@ var DraftInput = BaseActionInput.omit({ waitFor: true }).extend({
4665
5078
  });
4666
5079
 
4667
5080
  // ../commons/src/events/EventInput.ts
4668
- var z40 = __toESM(require("zod/v4"));
4669
- var import_uuid10 = require("uuid");
4670
- var EventInput = z40.object({
4671
- transactionId: z40.string(),
4672
- type: z40.string(),
5081
+ var z41 = __toESM(require("zod/v4"));
5082
+ var import_uuid11 = require("uuid");
5083
+ var EventInput = z41.object({
5084
+ transactionId: z41.string(),
5085
+ type: z41.string(),
4673
5086
  createdAtLocation: UUID.nullish().describe(
4674
5087
  "Location where the event occurred. Required for system users."
4675
5088
  )
4676
- }).meta({ default: { transactionId: (0, import_uuid10.v4)(), type: "birth" } });
5089
+ }).meta({ default: { transactionId: (0, import_uuid11.v4)(), type: "birth" } });
4677
5090
 
4678
5091
  // ../commons/src/events/EventDocument.ts
4679
- var z41 = __toESM(require("zod/v4"));
4680
- var EventDocument = z41.object({
5092
+ var z42 = __toESM(require("zod/v4"));
5093
+ var EventDocument = z42.object({
4681
5094
  id: UUID.describe("Unique identifier of the event."),
4682
- type: z41.string().describe("Type of the event (e.g. birth, death, marriage)."),
4683
- createdAt: z41.string().datetime().describe("Timestamp indicating when the event was created."),
4684
- updatedAt: z41.string().datetime().describe(
5095
+ type: z42.string().describe("Type of the event (e.g. birth, death, marriage)."),
5096
+ createdAt: z42.string().datetime().describe("Timestamp indicating when the event was created."),
5097
+ updatedAt: z42.string().datetime().describe(
4685
5098
  "Timestamp of the last update, excluding changes from actions."
4686
5099
  ),
4687
- actions: z41.array(Action).describe("Ordered list of actions associated with the event."),
4688
- trackingId: z41.string().describe(
5100
+ actions: z42.array(Action).describe("Ordered list of actions associated with the event."),
5101
+ trackingId: z42.string().describe(
4689
5102
  "System-generated tracking identifier used to look up the event."
4690
5103
  )
4691
5104
  }).meta({ id: "EventDocument" });
4692
-
4693
- // ../commons/src/events/state/index.ts
4694
- var import_lodash4 = require("lodash");
4695
-
4696
- // ../commons/src/events/state/utils.ts
4697
- var import_lodash2 = require("lodash");
4698
- var updateActions = ActionTypes.extract([
4699
- ActionType.CREATE,
4700
- ActionType.NOTIFY,
4701
- ActionType.EDIT,
4702
- ActionType.DECLARE,
4703
- ActionType.REGISTER,
4704
- ActionType.REJECT,
4705
- ActionType.ARCHIVE,
4706
- ActionType.PRINT_CERTIFICATE,
4707
- ActionType.REQUEST_CORRECTION,
4708
- ActionType.APPROVE_CORRECTION,
4709
- ActionType.REJECT_CORRECTION,
4710
- ActionType.CUSTOM
4711
- ]);
4712
-
4713
- // ../commons/src/events/state/flags.ts
4714
- var import_lodash3 = require("lodash");
4715
- var import_date_fns3 = require("date-fns");
4716
- var INHERENT_FLAG_RULES = [
4717
- {
4718
- flag: InherentFlags.CORRECTION_REQUESTED,
4719
- setOn: [ActionType.REQUEST_CORRECTION],
4720
- resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4721
- },
4722
- {
4723
- // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4724
- // other status-changing action (see getStatusFromActions).
4725
- flag: InherentFlags.INCOMPLETE,
4726
- setOn: [ActionType.NOTIFY],
4727
- resetOn: [
4728
- ActionType.CREATE,
4729
- ActionType.DECLARE,
4730
- ActionType.REGISTER,
4731
- ActionType.ARCHIVE
4732
- ]
4733
- },
4734
- {
4735
- flag: InherentFlags.REJECTED,
4736
- setOn: [ActionType.REJECT],
4737
- resetOn: [
4738
- ActionType.NOTIFY,
4739
- ActionType.DECLARE,
4740
- ActionType.EDIT,
4741
- ActionType.REGISTER
4742
- ]
4743
- },
4744
- {
4745
- flag: InherentFlags.POTENTIAL_DUPLICATE,
4746
- setOn: [ActionType.DUPLICATE_DETECTED],
4747
- resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4748
- },
4749
- {
4750
- flag: InherentFlags.EDIT_IN_PROGRESS,
4751
- setOn: [ActionType.EDIT],
4752
- resetOnAnyOtherAction: true
4753
- }
4754
- ];
5105
+ var EventDocumentOnlyLastAction = EventDocument.extend({
5106
+ actions: z42.array(Action).max(1).describe("Only the last action associated with the event.")
5107
+ }).brand("EventDocumentOnlyLastAction");
4755
5108
 
4756
5109
  // ../commons/src/events/defineConfig.ts
4757
5110
  var IGNORED_EVENT_TYPES = [
@@ -6058,6 +6411,20 @@ var tennisClubMembershipEvent = defineConfig({
6058
6411
  },
6059
6412
  review: TENNIS_CLUB_DECLARATION_REVIEW
6060
6413
  },
6414
+ {
6415
+ type: ActionType.NOTIFY,
6416
+ label: {
6417
+ defaultMessage: "Notify health worker",
6418
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6419
+ id: "event.tennis-club-membership.action.notify.label"
6420
+ },
6421
+ flags: [
6422
+ {
6423
+ id: "health-worker-notified",
6424
+ operation: "add"
6425
+ }
6426
+ ]
6427
+ },
6061
6428
  {
6062
6429
  type: ActionType.REJECT,
6063
6430
  label: {
@@ -6300,6 +6667,17 @@ var tennisClubMembershipEvent = defineConfig({
6300
6667
  }
6301
6668
  }
6302
6669
  ],
6670
+ flags: [
6671
+ {
6672
+ id: "health-worker-notified",
6673
+ requiresAction: false,
6674
+ label: {
6675
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6676
+ defaultMessage: "Health worker notified",
6677
+ description: "Label for the health-worker-notified flag"
6678
+ }
6679
+ }
6680
+ ],
6303
6681
  advancedSearch: [
6304
6682
  {
6305
6683
  title: {
@@ -7177,21 +7555,7 @@ var digitalIdentityEvent = defineConfig({
7177
7555
  });
7178
7556
 
7179
7557
  // ../commons/src/events/test.utils.ts
7180
- var z42 = __toESM(require("zod/v4"));
7181
- var TestUserRole = z42.enum([
7182
- "FIELD_AGENT",
7183
- "LOCAL_REGISTRAR",
7184
- "LOCAL_SYSTEM_ADMIN",
7185
- "NATIONAL_REGISTRAR",
7186
- "REGISTRATION_AGENT",
7187
- "NATIONAL_SYSTEM_ADMIN",
7188
- "SOCIAL_WORKER",
7189
- "COMMUNITY_LEADER",
7190
- "PROVINCIAL_REGISTRAR"
7191
- ]);
7192
-
7193
- // ../commons/src/events/scopes.ts
7194
- var import_lodash6 = require("lodash");
7558
+ var z44 = __toESM(require("zod/v4"));
7195
7559
 
7196
7560
  // ../commons/src/events/locations.ts
7197
7561
  var z43 = __toESM(require("zod/v4"));
@@ -7200,182 +7564,165 @@ var LocationTypeV1 = z43.enum([
7200
7564
  "CRVS_OFFICE",
7201
7565
  "HEALTH_FACILITY"
7202
7566
  ]);
7567
+ var LocationStatus = z43.enum(["active", "inactive"]);
7568
+ var LocationVersion = z43.object({
7569
+ versionId: UUID,
7570
+ effectiveFrom: z43.iso.date(),
7571
+ name: z43.string(),
7572
+ externalId: z43.string().nullish(),
7573
+ status: LocationStatus
7574
+ });
7203
7575
  var AdministrativeArea = z43.object({
7204
7576
  id: UUID,
7205
7577
  name: z43.string(),
7206
7578
  externalId: z43.string().nullish(),
7207
7579
  parentId: UUID.nullable(),
7208
- validUntil: z43.iso.datetime().nullable()
7580
+ status: LocationStatus,
7581
+ versions: z43.array(LocationVersion)
7209
7582
  });
7210
7583
  var Location = z43.object({
7211
7584
  id: UUID,
7212
7585
  name: z43.string(),
7213
7586
  externalId: z43.string().nullish(),
7214
7587
  administrativeAreaId: UUID.nullable(),
7215
- validUntil: z43.iso.datetime().nullable(),
7216
- locationType: z43.string().nullable()
7588
+ locationType: z43.string().nullable(),
7589
+ status: LocationStatus,
7590
+ versions: z43.array(LocationVersion)
7591
+ });
7592
+ var ClientAdministrativeArea = AdministrativeArea.omit({
7593
+ name: true,
7594
+ status: true,
7595
+ externalId: true
7596
+ });
7597
+ var ClientLocation = Location.omit({
7598
+ name: true,
7599
+ status: true,
7600
+ externalId: true
7601
+ });
7602
+ function toClientLocation(location) {
7603
+ return {
7604
+ id: location.id,
7605
+ administrativeAreaId: location.administrativeAreaId,
7606
+ locationType: location.locationType,
7607
+ versions: location.versions
7608
+ };
7609
+ }
7610
+ function toClientAdministrativeArea(area) {
7611
+ return {
7612
+ id: area.id,
7613
+ parentId: area.parentId,
7614
+ versions: area.versions
7615
+ };
7616
+ }
7617
+ function validateAscendingDates(versions, ctx) {
7618
+ const ascending = versions.every(
7619
+ (version, index) => index === 0 || versions[index - 1].effectiveFrom < version.effectiveFrom
7620
+ );
7621
+ if (!ascending) {
7622
+ ctx.addIssue("versions must be strictly ascending by effectiveFrom");
7623
+ }
7624
+ }
7625
+ function validateUniqueIds(versions, ctx) {
7626
+ const versionIds = new Set(versions.map((version) => version.versionId));
7627
+ if (versionIds.size !== versions.length) {
7628
+ ctx.addIssue("versions must not repeat a versionId");
7629
+ }
7630
+ }
7631
+ var SeededLocationVersions = z43.array(LocationVersion).min(1).superRefine((versions, ctx) => {
7632
+ validateAscendingDates(versions, ctx);
7633
+ validateUniqueIds(versions, ctx);
7634
+ });
7635
+ var SetLocationPayload = z43.object({
7636
+ id: UUID,
7637
+ name: z43.string(),
7638
+ externalId: z43.string().nullish(),
7639
+ administrativeAreaId: UUID.nullable(),
7640
+ locationType: z43.string().nullable(),
7641
+ versions: SeededLocationVersions.optional()
7642
+ });
7643
+ var SetAdministrativeAreaPayload = z43.object({
7644
+ id: UUID,
7645
+ name: z43.string(),
7646
+ externalId: z43.string().nullish(),
7647
+ parentId: UUID.nullable(),
7648
+ versions: SeededLocationVersions.optional()
7217
7649
  });
7218
-
7219
- // ../commons/src/events/scopes.ts
7220
- var ACTION_SCOPE_MAP = {
7221
- [ActionType.READ]: ["record.read"],
7222
- [ActionType.CREATE]: ["record.create"],
7223
- [ActionType.NOTIFY]: ["record.notify"],
7224
- [ActionType.DECLARE]: ["record.declare", "record.register"],
7225
- [ActionType.EDIT]: ["record.edit"],
7226
- [ActionType.DELETE]: ["record.declare", "record.notify"],
7227
- [ActionType.REGISTER]: ["record.register"],
7228
- [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
7229
- [ActionType.REQUEST_CORRECTION]: [
7230
- "record.request-correction",
7231
- "record.correct"
7232
- ],
7233
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
7234
- [ActionType.REJECT_CORRECTION]: ["record.correct"],
7235
- [ActionType.APPROVE_CORRECTION]: ["record.correct"],
7236
- [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7237
- [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7238
- [ActionType.ARCHIVE]: ["record.archive"],
7239
- [ActionType.REJECT]: ["record.reject"],
7240
- [ActionType.ASSIGN]: null,
7241
- [ActionType.UNASSIGN]: null,
7242
- [ActionType.DUPLICATE_DETECTED]: [],
7243
- [ActionType.CUSTOM]: []
7244
- };
7245
-
7246
- // ../commons/src/events/state/availableActions.ts
7247
- var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7248
- [EventStatus.enum.CREATED]: [
7249
- ActionType.READ,
7250
- ActionType.DECLARE,
7251
- ActionType.NOTIFY,
7252
- ActionType.DELETE,
7253
- ActionType.CUSTOM
7254
- ],
7255
- [EventStatus.enum.NOTIFIED]: [
7256
- ActionType.READ,
7257
- ActionType.EDIT,
7258
- ActionType.MARK_AS_DUPLICATE,
7259
- ActionType.ARCHIVE,
7260
- ActionType.REJECT,
7261
- ActionType.CUSTOM
7262
- ],
7263
- [EventStatus.enum.DECLARED]: [
7264
- ActionType.READ,
7265
- ActionType.REGISTER,
7266
- ActionType.MARK_AS_DUPLICATE,
7267
- ActionType.ARCHIVE,
7268
- ActionType.REJECT,
7269
- ActionType.CUSTOM,
7270
- ActionType.EDIT
7271
- ],
7272
- [EventStatus.enum.REGISTERED]: [
7273
- ActionType.READ,
7274
- ActionType.PRINT_CERTIFICATE,
7275
- ActionType.REQUEST_CORRECTION,
7276
- ActionType.APPROVE_CORRECTION,
7277
- ActionType.REJECT_CORRECTION,
7278
- ActionType.CUSTOM,
7279
- ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7280
- ],
7281
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7282
- };
7283
- var ACTION_FILTERS = {
7284
- [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7285
- [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7286
- [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7287
- [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7288
- [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
7289
- [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7290
- [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7291
- [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7292
- [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7293
- [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7294
- [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7295
- [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7296
- [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7297
- };
7298
- var REJECTED_ACTIONS = [
7299
- ActionType.READ,
7300
- ActionType.NOTIFY,
7301
- ActionType.CUSTOM,
7302
- ActionType.EDIT,
7303
- ActionType.ARCHIVE
7304
- ];
7305
-
7306
- // ../commons/src/events/FileUtils.ts
7307
- var import_lodash7 = require("lodash");
7308
7650
 
7309
7651
  // ../commons/src/events/mocks.test.utils.ts
7310
- var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7652
+ function withVersionFields(entity) {
7653
+ return {
7654
+ ...entity,
7655
+ status: "active",
7656
+ versions: [
7657
+ {
7658
+ versionId: entity.id,
7659
+ effectiveFrom: "0001-01-01",
7660
+ name: entity.name,
7661
+ externalId: entity.externalId ?? null,
7662
+ status: "active"
7663
+ }
7664
+ ]
7665
+ };
7666
+ }
7667
+ var MOCK_ADMINISTRATIVE_AREAS_BASE = [
7311
7668
  {
7312
7669
  id: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7313
7670
  name: "Central",
7314
7671
  parentId: null,
7315
- validUntil: null,
7316
7672
  externalId: "ydyJb1RAy4U1"
7317
7673
  },
7318
7674
  {
7319
7675
  id: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7320
7676
  name: "Sulaka",
7321
7677
  parentId: null,
7322
- validUntil: null,
7323
7678
  externalId: "pQ8nGxWmZ2Q3"
7324
7679
  },
7325
7680
  {
7326
7681
  id: "7ef2b9c7-5e6d-49f6-ae05-656207d0fc64",
7327
7682
  name: "Pualula",
7328
7683
  parentId: null,
7329
- validUntil: null,
7330
7684
  externalId: "Aq91DweLmT8k"
7331
7685
  },
7332
7686
  {
7333
7687
  id: "6d1a59df-988c-4021-a846-ccbc021931a7",
7334
7688
  name: "Chuminga",
7335
7689
  parentId: null,
7336
- validUntil: null,
7337
7690
  externalId: "Rw0fYNh2Xk9a"
7338
7691
  },
7339
7692
  {
7340
7693
  id: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7341
7694
  name: "Ibombo",
7342
7695
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7343
- validUntil: null,
7344
7696
  externalId: "k7DsP4vbN1Qe"
7345
7697
  },
7346
7698
  {
7347
7699
  id: "27160bbd-32d1-4625-812f-860226bfb92a",
7348
7700
  name: "Isango",
7349
7701
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7350
- validUntil: null,
7351
7702
  externalId: "Gm3Z9eQpHw4L"
7352
7703
  },
7353
7704
  {
7354
7705
  id: "967032fd-3f81-478a-826c-30cb8fe121bd",
7355
7706
  name: "Isamba",
7356
7707
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7357
- validUntil: null,
7358
7708
  externalId: "sT0xVu1KqJ7r"
7359
7709
  },
7360
7710
  {
7361
7711
  id: "89a33893-b17d-481d-a26d-6461e7ac1651",
7362
7712
  name: "Itambo",
7363
7713
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7364
- validUntil: null,
7365
7714
  externalId: "Nq6Bv2HpL9Te"
7366
7715
  },
7367
7716
  {
7368
7717
  id: "d42ab2fe-e7ed-470e-8b31-4fb27f9b8250",
7369
7718
  name: "Ezhi",
7370
7719
  parentId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7371
- validUntil: null,
7372
7720
  externalId: "xK8cQ0ZRy5Wd"
7373
7721
  },
7374
7722
  {
7375
7723
  id: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7376
7724
  name: "Ilanga",
7377
7725
  parentId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7378
- validUntil: null,
7379
7726
  externalId: "Cq4Jm1XvN8Ls"
7380
7727
  },
7381
7728
  // Villages under Ibombo (62a0ccb4-880d-4f30-8882-f256007dfff9)
@@ -7383,49 +7730,42 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7383
7730
  id: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7384
7731
  name: "Klow",
7385
7732
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7386
- validUntil: null,
7387
7733
  externalId: "IkYcYBUcyY2"
7388
7734
  },
7389
7735
  {
7390
7736
  id: "2e5f6a7b-8c9d-4a23-8fab-456789012345",
7391
7737
  name: "Mbondo",
7392
7738
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7393
- validUntil: null,
7394
7739
  externalId: "Qhvv5hvo3mY"
7395
7740
  },
7396
7741
  {
7397
7742
  id: "3f6a7b8c-9d0e-4b34-8abc-567890123456",
7398
7743
  name: "Ndara",
7399
7744
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7400
- validUntil: null,
7401
7745
  externalId: "crXh068O9TR"
7402
7746
  },
7403
7747
  {
7404
7748
  id: "4a7b8c9d-0e1f-4c45-abcd-678901234567",
7405
7749
  name: "Olani",
7406
7750
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7407
- validUntil: null,
7408
7751
  externalId: "r00It8Tvvp7"
7409
7752
  },
7410
7753
  {
7411
7754
  id: "5b8c9d0e-1f2a-4d56-bcde-789012345678",
7412
7755
  name: "Pemba",
7413
7756
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7414
- validUntil: null,
7415
7757
  externalId: "ZnUWsbONIaH"
7416
7758
  },
7417
7759
  {
7418
7760
  id: "6c9d0e1f-2a3b-4e67-8def-890123456789",
7419
7761
  name: "Quanza",
7420
7762
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7421
- validUntil: null,
7422
7763
  externalId: "fDZycvQTa7l"
7423
7764
  },
7424
7765
  {
7425
7766
  id: "7d0e1f2a-3b4c-4f78-8efa-901234567890",
7426
7767
  name: "Rivka",
7427
7768
  parentId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7428
- validUntil: null,
7429
7769
  externalId: "KqswxCGTELa"
7430
7770
  },
7431
7771
  // Villages under Isamba (967032fd-3f81-478a-826c-30cb8fe121bd)
@@ -7433,35 +7773,30 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7433
7773
  id: "8e1f2a3b-4c5d-4089-8fab-012345678901",
7434
7774
  name: "Mbula",
7435
7775
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7436
- validUntil: null,
7437
7776
  externalId: "osEbKjRc9Kg"
7438
7777
  },
7439
7778
  {
7440
7779
  id: "9f2a3b4c-5d6e-4190-8abf-123456789012",
7441
7780
  name: "Ndoki",
7442
7781
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7443
- validUntil: null,
7444
7782
  externalId: "aq4daBUAGr3"
7445
7783
  },
7446
7784
  {
7447
7785
  id: "0a3b4c5d-6e7f-4201-abcd-234567890123",
7448
7786
  name: "Tsanga",
7449
7787
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7450
- validUntil: null,
7451
7788
  externalId: "cqis6Y8trbJ"
7452
7789
  },
7453
7790
  {
7454
7791
  id: "1b4c5d6e-7f8a-4312-bcde-345678901234",
7455
7792
  name: "Waziri",
7456
7793
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7457
- validUntil: null,
7458
7794
  externalId: "LMijHPyyx6d"
7459
7795
  },
7460
7796
  {
7461
7797
  id: "2c5d6e7f-8a9b-4423-8def-456789012345",
7462
7798
  name: "Zimbi",
7463
7799
  parentId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7464
- validUntil: null,
7465
7800
  externalId: "pcQYbPuKGZ7"
7466
7801
  },
7467
7802
  // Villages under Itambo (89a33893-b17d-481d-a26d-6461e7ac1651)
@@ -7469,67 +7804,59 @@ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = [
7469
7804
  id: "3d6e7f8a-9b0c-4534-8efa-567890123456",
7470
7805
  name: "Felani",
7471
7806
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7472
- validUntil: null,
7473
7807
  externalId: "gSqpoCGdMXp"
7474
7808
  },
7475
7809
  {
7476
7810
  id: "4e7f8a9b-0c1d-4645-8fab-678901234567",
7477
7811
  name: "Goroma",
7478
7812
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7479
- validUntil: null,
7480
7813
  externalId: "KvAAIaNqVrp"
7481
7814
  },
7482
7815
  {
7483
7816
  id: "5f8a9b0c-1d2e-4756-8abc-789012345678",
7484
7817
  name: "Halifu",
7485
7818
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7486
- validUntil: null,
7487
7819
  externalId: "qe4UnEVt1hv"
7488
7820
  },
7489
7821
  {
7490
7822
  id: "6a9b0c1d-2e3f-4867-abcd-890123456789",
7491
7823
  name: "Jabari",
7492
7824
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7493
- validUntil: null,
7494
7825
  externalId: "yHH9Nz4rLOt"
7495
7826
  },
7496
7827
  {
7497
7828
  id: "7b0c1d2e-3f4a-4978-bcde-901234567890",
7498
7829
  name: "Kifani",
7499
7830
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7500
- validUntil: null,
7501
7831
  externalId: "eSWmXIGeu1I"
7502
7832
  },
7503
7833
  {
7504
7834
  id: "8c1d2e3f-4a5b-4089-8def-012345678901",
7505
7835
  name: "Lumela",
7506
7836
  parentId: "89a33893-b17d-481d-a26d-6461e7ac1651",
7507
- validUntil: null,
7508
7837
  externalId: "bh0b3aI1uP3"
7509
7838
  }
7510
7839
  ];
7511
- var V2_DEFAULT_MOCK_LOCATIONS = [
7840
+ var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS = MOCK_ADMINISTRATIVE_AREAS_BASE.map(withVersionFields);
7841
+ var MOCK_LOCATIONS_BASE = [
7512
7842
  {
7513
7843
  id: "6f6186ce-cd5f-4a5f-810a-2d99e7c4ba12",
7514
7844
  name: "Central Provincial Office",
7515
7845
  locationType: "CRVS_OFFICE",
7516
7846
  administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7517
- validUntil: null,
7518
7847
  externalId: "Xr3Df8WpK6Ys"
7519
7848
  },
7520
7849
  {
7521
7850
  id: "b1c2d3e4-f5a6-7890-bcde-f12345678901",
7522
7851
  name: "Central Health Post",
7523
7852
  locationType: "HEALTH_FACILITY",
7524
- administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c",
7525
- validUntil: null
7853
+ administrativeAreaId: "a45b982a-5c7b-4bd9-8fd8-a42d0994054c"
7526
7854
  },
7527
7855
  {
7528
7856
  id: "028d2c85-ca31-426d-b5d1-2cef545a4902",
7529
7857
  name: "Ibombo District Office",
7530
7858
  locationType: "CRVS_OFFICE",
7531
7859
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7532
- validUntil: null,
7533
7860
  externalId: "Sm4Nw7GrD2Vy"
7534
7861
  },
7535
7862
  {
@@ -7537,7 +7864,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7537
7864
  name: "Isamba District Office",
7538
7865
  locationType: "CRVS_OFFICE",
7539
7866
  administrativeAreaId: "967032fd-3f81-478a-826c-30cb8fe121bd",
7540
- validUntil: null,
7541
7867
  externalId: "Vg1Bq5XeH9Lt"
7542
7868
  },
7543
7869
  {
@@ -7545,7 +7871,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7545
7871
  name: "Isango District Office",
7546
7872
  locationType: "CRVS_OFFICE",
7547
7873
  administrativeAreaId: "27160bbd-32d1-4625-812f-860226bfb92a",
7548
- validUntil: null,
7549
7874
  externalId: "Je7Lm2XqN9Vz"
7550
7875
  },
7551
7876
  {
@@ -7553,7 +7878,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7553
7878
  name: "Sulaka Provincial Office",
7554
7879
  locationType: "CRVS_OFFICE",
7555
7880
  administrativeAreaId: "c599b691-fd2d-45e1-abf4-d185de727fb5",
7556
- validUntil: null,
7557
7881
  externalId: "Ht2Wp9KcX5Qv"
7558
7882
  },
7559
7883
  {
@@ -7561,7 +7885,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7561
7885
  name: "Ilanga District Office",
7562
7886
  locationType: "CRVS_OFFICE",
7563
7887
  administrativeAreaId: "8fbd09d2-212b-47f4-beb3-5e1694931d9f",
7564
- validUntil: null,
7565
7888
  externalId: "Yp6Ds1WqN3Xz"
7566
7889
  },
7567
7890
  {
@@ -7569,7 +7892,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7569
7892
  name: "Chamakubi Health Post",
7570
7893
  locationType: "HEALTH_FACILITY",
7571
7894
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7572
- validUntil: null,
7573
7895
  externalId: "M1nFr8LbC2Qy"
7574
7896
  },
7575
7897
  {
@@ -7577,7 +7899,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7577
7899
  name: "Ibombo Rural Health Centre",
7578
7900
  locationType: "HEALTH_FACILITY",
7579
7901
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7580
- validUntil: null,
7581
7902
  externalId: "bT7pV6YrW0Xc"
7582
7903
  },
7583
7904
  {
@@ -7585,7 +7906,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7585
7906
  name: "Chikobo Rural Health Centre",
7586
7907
  locationType: "HEALTH_FACILITY",
7587
7908
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7588
- validUntil: null,
7589
7909
  externalId: "zE4qPn2SgJ5d"
7590
7910
  },
7591
7911
  {
@@ -7593,7 +7913,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7593
7913
  name: "Chilochabalenje Health Post",
7594
7914
  locationType: "HEALTH_FACILITY",
7595
7915
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7596
- validUntil: null,
7597
7916
  externalId: "H8vDs1MqR4Uf"
7598
7917
  },
7599
7918
  {
@@ -7601,7 +7920,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7601
7920
  name: "Chipeso Rural Health Centre",
7602
7921
  locationType: "HEALTH_FACILITY",
7603
7922
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7604
- validUntil: null,
7605
7923
  externalId: "Qw3uZ9KfX6Lm"
7606
7924
  },
7607
7925
  {
@@ -7609,7 +7927,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7609
7927
  name: "Chisamba Rural Health Centre",
7610
7928
  locationType: "HEALTH_FACILITY",
7611
7929
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7612
- validUntil: null,
7613
7930
  externalId: "Yr0pCg8LdM2s"
7614
7931
  },
7615
7932
  {
@@ -7617,7 +7934,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7617
7934
  name: "Chitanda Rural Health Centre",
7618
7935
  locationType: "HEALTH_FACILITY",
7619
7936
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7620
- validUntil: null,
7621
7937
  externalId: "tS9gJ4PwB1Qx"
7622
7938
  },
7623
7939
  {
@@ -7625,7 +7941,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7625
7941
  name: "Golden Valley Rural Health Centre",
7626
7942
  locationType: "HEALTH_FACILITY",
7627
7943
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7628
- validUntil: null,
7629
7944
  externalId: "Ld7Qm3XsA8Vr"
7630
7945
  },
7631
7946
  {
@@ -7633,7 +7948,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7633
7948
  name: "Ipongo Rural Health Centre",
7634
7949
  locationType: "HEALTH_FACILITY",
7635
7950
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7636
- validUntil: null,
7637
7951
  externalId: "kF2sW9DmH0Bt"
7638
7952
  },
7639
7953
  {
@@ -7641,7 +7955,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7641
7955
  name: "Itumbwe Health Post",
7642
7956
  locationType: "HEALTH_FACILITY",
7643
7957
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7644
- validUntil: null,
7645
7958
  externalId: "Ue5Xb3VaC7Pq"
7646
7959
  },
7647
7960
  {
@@ -7649,7 +7962,6 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7649
7962
  name: "Kabangalala Rural Health Centre",
7650
7963
  locationType: "HEALTH_FACILITY",
7651
7964
  administrativeAreaId: "62a0ccb4-880d-4f30-8882-f256007dfff9",
7652
- validUntil: null,
7653
7965
  externalId: "Pz8Kc1TqH6Jn"
7654
7966
  },
7655
7967
  // Village offices
@@ -7658,100 +7970,353 @@ var V2_DEFAULT_MOCK_LOCATIONS = [
7658
7970
  name: "Klow Village Office",
7659
7971
  locationType: "CRVS_OFFICE",
7660
7972
  administrativeAreaId: "1d4e5f6a-7b8c-4912-8efa-345678901234",
7661
- validUntil: null,
7662
7973
  externalId: "PmAyxAJkxiJ"
7663
7974
  }
7664
7975
  ];
7976
+ var V2_DEFAULT_MOCK_LOCATIONS = MOCK_LOCATIONS_BASE.map(withVersionFields);
7665
7977
  var V2_DEFAULT_MOCK_LOCATIONS_MAP = new Map(
7666
7978
  V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, l])
7667
7979
  );
7668
7980
  var V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS_MAP = new Map(
7669
7981
  V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [a.id, a])
7670
7982
  );
7983
+ var V2_DEFAULT_MOCK_CLIENT_LOCATIONS_MAP = new Map(
7984
+ V2_DEFAULT_MOCK_LOCATIONS.map((l) => [l.id, toClientLocation(l)])
7985
+ );
7986
+ var V2_DEFAULT_MOCK_CLIENT_ADMINISTRATIVE_AREAS_MAP = new Map(
7987
+ V2_DEFAULT_MOCK_ADMINISTRATIVE_AREAS.map((a) => [
7988
+ a.id,
7989
+ toClientAdministrativeArea(a)
7990
+ ])
7991
+ );
7992
+
7993
+ // ../commons/src/events/test.utils.ts
7994
+ var TestUserRole = z44.enum([
7995
+ "FIELD_AGENT",
7996
+ "LOCAL_REGISTRAR",
7997
+ "LOCAL_SYSTEM_ADMIN",
7998
+ "NATIONAL_REGISTRAR",
7999
+ "REGISTRATION_AGENT",
8000
+ "NATIONAL_SYSTEM_ADMIN",
8001
+ "SOCIAL_WORKER",
8002
+ "COMMUNITY_LEADER",
8003
+ "PROVINCIAL_REGISTRAR"
8004
+ ]);
8005
+
8006
+ // ../commons/src/events/scopes.ts
8007
+ var import_lodash6 = require("lodash");
8008
+ var ACTION_SCOPE_MAP = {
8009
+ [ActionType.READ]: ["record.read"],
8010
+ [ActionType.CREATE]: ["record.create"],
8011
+ [ActionType.NOTIFY]: ["record.notify"],
8012
+ [ActionType.DECLARE]: ["record.declare", "record.register"],
8013
+ [ActionType.EDIT]: ["record.edit"],
8014
+ [ActionType.DELETE]: ["record.declare", "record.notify"],
8015
+ [ActionType.REGISTER]: ["record.register"],
8016
+ [ActionType.PRINT_CERTIFICATE]: ["record.print-certified-copies"],
8017
+ [ActionType.REQUEST_CORRECTION]: [
8018
+ "record.request-correction",
8019
+ "record.correct"
8020
+ ],
8021
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: ["record.correct"],
8022
+ [ActionType.REJECT_CORRECTION]: ["record.correct"],
8023
+ [ActionType.APPROVE_CORRECTION]: ["record.correct"],
8024
+ [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
8025
+ [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
8026
+ [ActionType.ARCHIVE]: ["record.archive"],
8027
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
8028
+ [ActionType.REJECT]: ["record.reject"],
8029
+ [ActionType.ASSIGN]: null,
8030
+ [ActionType.UNASSIGN]: null,
8031
+ [ActionType.DUPLICATE_DETECTED]: [],
8032
+ [ActionType.CUSTOM]: []
8033
+ };
8034
+
8035
+ // ../commons/src/events/state/availableActions.ts
8036
+ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
8037
+ [EventStatus.enum.CREATED]: [
8038
+ ActionType.READ,
8039
+ ActionType.DECLARE,
8040
+ ActionType.NOTIFY,
8041
+ ActionType.DELETE
8042
+ ],
8043
+ [EventStatus.enum.NOTIFIED]: [
8044
+ ActionType.READ,
8045
+ ActionType.EDIT,
8046
+ ActionType.MARK_AS_DUPLICATE,
8047
+ ActionType.ARCHIVE,
8048
+ ActionType.REJECT,
8049
+ ActionType.CUSTOM
8050
+ ],
8051
+ [EventStatus.enum.DECLARED]: [
8052
+ ActionType.READ,
8053
+ ActionType.REGISTER,
8054
+ ActionType.MARK_AS_DUPLICATE,
8055
+ ActionType.ARCHIVE,
8056
+ ActionType.REJECT,
8057
+ ActionType.CUSTOM,
8058
+ ActionType.EDIT
8059
+ ],
8060
+ [EventStatus.enum.REGISTERED]: [
8061
+ ActionType.READ,
8062
+ ActionType.PRINT_CERTIFICATE,
8063
+ ActionType.REQUEST_CORRECTION,
8064
+ ActionType.APPROVE_CORRECTION,
8065
+ ActionType.REJECT_CORRECTION,
8066
+ ActionType.CUSTOM,
8067
+ ClientSpecificAction.REVIEW_CORRECTION_REQUEST
8068
+ ],
8069
+ [EventStatus.enum.ARCHIVED]: [
8070
+ ActionType.READ,
8071
+ ActionType.CUSTOM,
8072
+ ActionType.UNARCHIVE
8073
+ ]
8074
+ };
8075
+ var ACTION_FILTERS = {
8076
+ [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8077
+ [ActionType.REQUEST_CORRECTION]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8078
+ [ClientSpecificAction.REVIEW_CORRECTION_REQUEST]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8079
+ [ActionType.APPROVE_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8080
+ [ActionType.REJECT_CORRECTION]: (flags) => flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8081
+ [ActionType.MARK_AS_DUPLICATE]: (flags) => flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8082
+ [ActionType.EDIT]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8083
+ [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag2) => flag2.endsWith(":requested")),
8084
+ [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag2) => flag2.endsWith(":requested")),
8085
+ [ActionType.ARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8086
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8087
+ [ActionType.ASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8088
+ [ActionType.UNASSIGN]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested")),
8089
+ [ActionType.CUSTOM]: (flags) => !flags.some((flag2) => flag2.endsWith(":requested"))
8090
+ };
8091
+ var REJECTED_ACTIONS = [
8092
+ ActionType.READ,
8093
+ ActionType.NOTIFY,
8094
+ ActionType.CUSTOM,
8095
+ ActionType.EDIT,
8096
+ ActionType.ARCHIVE
8097
+ ];
8098
+
8099
+ // ../commons/src/events/FileUtils.ts
8100
+ var import_lodash7 = require("lodash");
8101
+
8102
+ // ../commons/src/events/locationPayloads.ts
8103
+ var z45 = __toESM(require("zod/v4"));
8104
+ var CreateLocationPayload = z45.object({
8105
+ id: UUID.optional(),
8106
+ versionId: UUID.optional(),
8107
+ name: z45.string(),
8108
+ externalId: z45.string().nullish(),
8109
+ administrativeAreaId: UUID.nullable(),
8110
+ locationType: z45.string().nullable(),
8111
+ effectiveFrom: z45.iso.date().optional(),
8112
+ status: LocationStatus.default("active")
8113
+ });
8114
+ var UpdateLocationPayload = z45.strictObject({
8115
+ id: UUID,
8116
+ versionId: UUID.optional(),
8117
+ name: z45.string(),
8118
+ externalId: z45.string().nullish(),
8119
+ status: LocationStatus,
8120
+ effectiveFrom: z45.iso.date().optional(),
8121
+ lastVersionId: UUID
8122
+ });
8123
+ var WithdrawLocationVersionPayload = z45.object({
8124
+ id: UUID,
8125
+ versionId: UUID
8126
+ });
8127
+ var CreateAdministrativeAreaPayload = z45.object({
8128
+ id: UUID.optional(),
8129
+ versionId: UUID.optional(),
8130
+ name: z45.string(),
8131
+ externalId: z45.string().nullish(),
8132
+ parentId: UUID.nullable(),
8133
+ effectiveFrom: z45.iso.date().optional(),
8134
+ status: LocationStatus.default("active")
8135
+ });
8136
+ var UpdateAdministrativeAreaPayload = z45.strictObject({
8137
+ id: UUID,
8138
+ versionId: UUID.optional(),
8139
+ name: z45.string(),
8140
+ externalId: z45.string().nullish(),
8141
+ status: LocationStatus,
8142
+ effectiveFrom: z45.iso.date().optional(),
8143
+ lastVersionId: UUID
8144
+ });
8145
+ var WithdrawAdministrativeAreaVersionPayload = z45.object({
8146
+ id: UUID,
8147
+ versionId: UUID
8148
+ });
7671
8149
 
7672
8150
  // ../commons/src/notification/UserNotifications.ts
7673
- var z44 = __toESM(require("zod/v4"));
8151
+ var z46 = __toESM(require("zod/v4"));
7674
8152
  var TriggerEvent = {
7675
8153
  USER_CREATED: "user-created",
7676
8154
  USER_UPDATED: "user-updated",
7677
8155
  USERNAME_REMINDER: "username-reminder",
7678
8156
  RESET_PASSWORD: "reset-password",
7679
8157
  RESET_PASSWORD_BY_ADMIN: "reset-password-by-admin",
8158
+ PASSWORD_RESET_LINK: "password-reset-link",
8159
+ USERNAME_REMINDER_LINK: "username-reminder-link",
7680
8160
  RESEND_INVITE: "resend-invite",
7681
8161
  TWO_FA: "2fa",
7682
8162
  ALL_USER_NOTIFICATION: "all-user-notification",
7683
8163
  CHANGE_PHONE_NUMBER: "change-phone-number",
7684
8164
  CHANGE_EMAIL_ADDRESS: "change-email-address"
7685
8165
  };
7686
- var Recipient = z44.object({
8166
+ var Recipient = z46.object({
7687
8167
  name: NameFieldValue.optional(),
7688
- mobile: z44.string().optional(),
7689
- email: z44.string().optional(),
7690
- bcc: z44.array(z44.string()).optional()
8168
+ mobile: z46.string().optional(),
8169
+ email: z46.string().optional(),
8170
+ bcc: z46.array(z46.string()).optional()
7691
8171
  });
7692
- var BasePayload = z44.object({
8172
+ var BasePayload = z46.object({
7693
8173
  recipient: Recipient
7694
8174
  });
7695
8175
  var TriggerPayload = {
7696
8176
  [TriggerEvent.USER_CREATED]: BasePayload.extend({
7697
- username: z44.string(),
7698
- temporaryPassword: z44.string()
8177
+ username: z46.string(),
8178
+ temporaryPassword: z46.string()
7699
8179
  }),
7700
8180
  [TriggerEvent.USER_UPDATED]: BasePayload.extend({
7701
- oldUsername: z44.string(),
7702
- newUsername: z44.string()
8181
+ oldUsername: z46.string(),
8182
+ newUsername: z46.string()
7703
8183
  }),
7704
8184
  [TriggerEvent.USERNAME_REMINDER]: BasePayload.extend({
7705
- username: z44.string()
8185
+ username: z46.string()
7706
8186
  }),
7707
8187
  [TriggerEvent.RESET_PASSWORD]: BasePayload.extend({
7708
- code: z44.string()
8188
+ code: z46.string()
7709
8189
  }),
7710
8190
  [TriggerEvent.RESET_PASSWORD_BY_ADMIN]: BasePayload.extend({
7711
- temporaryPassword: z44.string(),
7712
- admin: z44.object({
7713
- id: z44.string(),
8191
+ temporaryPassword: z46.string(),
8192
+ admin: z46.object({
8193
+ id: z46.string(),
7714
8194
  name: NameFieldValue,
7715
- role: z44.string()
8195
+ role: z46.string()
7716
8196
  })
7717
8197
  }),
8198
+ [TriggerEvent.PASSWORD_RESET_LINK]: BasePayload.extend({
8199
+ token: z46.string()
8200
+ }),
8201
+ [TriggerEvent.USERNAME_REMINDER_LINK]: BasePayload.extend({
8202
+ token: z46.string()
8203
+ }),
7718
8204
  [TriggerEvent.RESEND_INVITE]: BasePayload.extend({
7719
- username: z44.string(),
7720
- temporaryPassword: z44.string()
8205
+ username: z46.string(),
8206
+ temporaryPassword: z46.string()
7721
8207
  }),
7722
8208
  [TriggerEvent.TWO_FA]: BasePayload.extend({
7723
- code: z44.string()
8209
+ code: z46.string()
7724
8210
  }),
7725
8211
  [TriggerEvent.ALL_USER_NOTIFICATION]: BasePayload.extend({
7726
- subject: z44.string(),
7727
- body: z44.string()
8212
+ subject: z46.string(),
8213
+ body: z46.string()
7728
8214
  }),
7729
8215
  [TriggerEvent.CHANGE_PHONE_NUMBER]: BasePayload.extend({
7730
- code: z44.string()
8216
+ code: z46.string()
7731
8217
  }),
7732
8218
  [TriggerEvent.CHANGE_EMAIL_ADDRESS]: BasePayload.extend({
7733
- code: z44.string()
8219
+ code: z46.string()
7734
8220
  })
7735
8221
  };
8222
+ function parseUserEventTrigger(event2, body) {
8223
+ const schema = TriggerPayload[event2];
8224
+ return schema.parse(body);
8225
+ }
8226
+
8227
+ // ../commons/src/url.ts
8228
+ function joinUrl(base, path) {
8229
+ const baseWithSlash = base.endsWith("/") ? base : base + "/";
8230
+ return new URL(path, baseWithSlash);
8231
+ }
8232
+
8233
+ // ../commons/src/logger.ts
8234
+ var import_pino = __toESM(require("pino"));
8235
+ function normalizeLogArgs(args) {
8236
+ const [first, ...rest] = args;
8237
+ if (typeof first !== "string" || rest.length === 0) {
8238
+ return args;
8239
+ }
8240
+ const mergingObject = {};
8241
+ const primitives = [];
8242
+ for (const arg of rest) {
8243
+ if (arg instanceof Error) {
8244
+ mergingObject.err = import_pino.default.stdSerializers.err(arg);
8245
+ } else if (arg !== null && typeof arg === "object") {
8246
+ Object.assign(mergingObject, arg);
8247
+ } else {
8248
+ primitives.push(arg);
8249
+ }
8250
+ }
8251
+ const message = primitives.length ? `${first} ${primitives.join(" ")}` : first;
8252
+ return Object.keys(mergingObject).length ? [mergingObject, message] : [message];
8253
+ }
8254
+ function filterHealthCheckLogs(args, method) {
8255
+ const logger2 = this;
8256
+ for (const arg of args) {
8257
+ if (typeof arg === "string" && arg.includes("get /ping 200")) {
8258
+ if (logger2.debug) {
8259
+ return logger2.debug(...args);
8260
+ }
8261
+ }
8262
+ }
8263
+ return method.apply(this, normalizeLogArgs(args));
8264
+ }
8265
+ function buildLoggerOptions() {
8266
+ return {
8267
+ serializers: { err: import_pino.default.stdSerializers.err },
8268
+ hooks: { logMethod: filterHealthCheckLogs }
8269
+ };
8270
+ }
8271
+ var logger = false ? (0, import_pino.default)({
8272
+ level: "info",
8273
+ redact: [
8274
+ "req.headers.authorization",
8275
+ "req.remoteAddress",
8276
+ "req.headers['x-real-ip']"
8277
+ ],
8278
+ ...buildLoggerOptions()
8279
+ }) : (0, import_pino.default)({
8280
+ level: "debug",
8281
+ transport: {
8282
+ target: "pino-pretty",
8283
+ options: {
8284
+ colorize: true,
8285
+ ignore: "pid,hostname"
8286
+ }
8287
+ },
8288
+ ...buildLoggerOptions()
8289
+ });
8290
+ var level = false ? "silent" : process.env.LOG_LEVEL;
8291
+ if (level) {
8292
+ logger.level = level;
8293
+ }
8294
+
8295
+ // ../commons/src/notification/dispatch.ts
7736
8296
  async function triggerUserEventNotification({
7737
8297
  event: event2,
7738
8298
  payload,
7739
8299
  countryConfigUrl,
7740
8300
  authHeader
7741
8301
  }) {
7742
- return await fetch(joinUrl(countryConfigUrl, `triggers/user/${event2}`), {
7743
- method: "POST",
7744
- body: JSON.stringify(payload),
7745
- headers: {
7746
- "Content-Type": "application/json",
7747
- ...authHeader
8302
+ const response = await fetch(
8303
+ joinUrl(countryConfigUrl, `triggers/user/${event2}`),
8304
+ {
8305
+ method: "POST",
8306
+ body: JSON.stringify(payload),
8307
+ headers: {
8308
+ "Content-Type": "application/json",
8309
+ ...authHeader
8310
+ }
7748
8311
  }
7749
- });
7750
- }
7751
- function parseUserEventTrigger(event2, body) {
7752
- const schema = TriggerPayload[event2];
7753
- return schema.parse(body);
8312
+ );
8313
+ if (!response.ok) {
8314
+ logger.error(
8315
+ `triggerUserEventNotification: dispatch failed for event "${event2}" with status ${response.status}`
8316
+ );
8317
+ }
8318
+ return response;
7754
8319
  }
7755
8320
 
7756
8321
  // src/notification/index.ts
7757
- z45.globalRegistry.clear();
8322
+ z47.globalRegistry.clear();