@opencrvs/toolkit 2.0.0-rc.9954a7c → 2.0.0-rc.99921a2

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 (113) hide show
  1. package/README.md +15 -0
  2. package/build.sh +5 -4
  3. package/dist/application-config/index.js +82 -40
  4. package/dist/cli.js +3186 -4915
  5. package/dist/commons/api/router.d.ts +700 -22
  6. package/dist/commons/application-config/index.d.ts +1 -0
  7. package/dist/commons/conditionals/conditionals.d.ts +354 -10
  8. package/dist/commons/conditionals/validate.d.ts +51 -2
  9. package/dist/commons/events/ActionConfig.d.ts +230 -2
  10. package/dist/commons/events/ActionDocument.d.ts +50 -0
  11. package/dist/commons/events/ActionInput.d.ts +32 -0
  12. package/dist/commons/events/ActionType.d.ts +6 -1
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +360 -0
  14. package/dist/commons/events/AuditLog.d.ts +2 -0
  15. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  16. package/dist/commons/events/Draft.d.ts +2 -0
  17. package/dist/commons/events/EventConfig.d.ts +2 -0
  18. package/dist/commons/events/EventDocument.d.ts +25 -0
  19. package/dist/commons/events/EventIndex.d.ts +25 -0
  20. package/dist/commons/events/EventMetadata.d.ts +26 -0
  21. package/dist/commons/events/FieldConfig.d.ts +393 -50
  22. package/dist/commons/events/FieldType.d.ts +1 -0
  23. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  24. package/dist/commons/events/FieldValue.d.ts +6 -0
  25. package/dist/commons/events/WorkqueueConfig.d.ts +44 -2
  26. package/dist/commons/events/field.d.ts +53 -1
  27. package/dist/commons/events/index.d.ts +1 -0
  28. package/dist/commons/events/locations.d.ts +1 -0
  29. package/dist/commons/events/scopes.d.ts +1 -0
  30. package/dist/commons/events/state/flags.d.ts +14 -0
  31. package/dist/commons/events/state/index.d.ts +8 -0
  32. package/dist/commons/events/state/utils.d.ts +21 -287
  33. package/dist/commons/events/test.utils.d.ts +9 -1
  34. package/dist/commons/events/utils.d.ts +27 -2
  35. package/dist/conditionals/index.js +60 -6
  36. package/dist/environment/custom-types.d.ts +33 -0
  37. package/dist/environment/custom-types.d.ts.map +1 -0
  38. package/dist/environment/custom-types.js +12 -0
  39. package/dist/environment/derived-variables.d.ts +134 -0
  40. package/dist/environment/derived-variables.d.ts.map +1 -0
  41. package/dist/environment/derived-variables.js +169 -0
  42. package/dist/environment/editor-questions.d.ts +4 -0
  43. package/dist/environment/editor-questions.d.ts.map +1 -0
  44. package/dist/environment/editor-questions.js +67 -0
  45. package/dist/environment/git.d.ts +5 -0
  46. package/dist/environment/git.d.ts.map +1 -0
  47. package/dist/environment/git.js +38 -0
  48. package/dist/environment/github.d.ts +26 -0
  49. package/dist/environment/github.d.ts.map +1 -0
  50. package/dist/environment/github.js +247 -0
  51. package/dist/environment/index.d.ts +5 -0
  52. package/dist/environment/index.d.ts.map +1 -0
  53. package/dist/environment/index.js +71 -0
  54. package/dist/environment/logger.d.ts +15 -0
  55. package/dist/environment/logger.d.ts.map +1 -0
  56. package/dist/environment/logger.js +25 -0
  57. package/dist/environment/manage-users.d.ts +11 -0
  58. package/dist/environment/manage-users.d.ts.map +1 -0
  59. package/dist/environment/manage-users.js +497 -0
  60. package/dist/environment/questions-helper.d.ts +15 -0
  61. package/dist/environment/questions-helper.d.ts.map +1 -0
  62. package/dist/environment/questions-helper.js +70 -0
  63. package/dist/environment/questions.d.ts +199 -0
  64. package/dist/environment/questions.d.ts.map +1 -0
  65. package/dist/environment/questions.js +412 -0
  66. package/dist/environment/setup-environment.d.ts +2 -0
  67. package/dist/environment/setup-environment.d.ts.map +1 -0
  68. package/dist/environment/setup-environment.js +794 -0
  69. package/dist/environment/ssh-keygen.d.ts +5 -0
  70. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  71. package/dist/environment/ssh-keygen.js +21 -0
  72. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  73. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  74. package/dist/environment/swarm-to-k8s.js +173 -0
  75. package/dist/environment/templates.d.ts +27 -0
  76. package/dist/environment/templates.d.ts.map +1 -0
  77. package/dist/environment/templates.js +163 -0
  78. package/dist/environment/update-workflows.d.ts +2 -0
  79. package/dist/environment/update-workflows.d.ts.map +1 -0
  80. package/dist/environment/update-workflows.js +169 -0
  81. package/dist/environment/users.d.ts +2 -0
  82. package/dist/environment/users.d.ts.map +1 -0
  83. package/dist/environment/users.js +112 -0
  84. package/dist/environment/utils.d.ts +18 -0
  85. package/dist/environment/utils.d.ts.map +1 -0
  86. package/dist/environment/utils.js +100 -0
  87. package/dist/events/index.js +600 -158
  88. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  89. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  90. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  91. package/dist/migrations/v2.0/index.js +88 -5133
  92. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  93. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  94. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  95. package/dist/migrations/v2.1/index.d.ts +6 -0
  96. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  97. package/dist/migrations/v2.1/index.js +218 -0
  98. package/dist/notification/index.js +389 -49
  99. package/dist/scopes/index.d.ts +100 -8
  100. package/dist/scopes/index.js +21 -8
  101. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  102. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  103. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  104. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  105. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  106. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  107. package/dist/templates/inventory/inventory.template.yml +100 -0
  108. package/dist/templates/inventory/production.example.yml +77 -0
  109. package/dist/templates/inventory/qa.example.yml +48 -0
  110. package/opencrvs-toolkit-2.0.0-rc.99921a2.tgz +0 -0
  111. package/package.json +15 -1
  112. package/tsconfig.tsbuildinfo +1 -1
  113. package/opencrvs-toolkit-2.0.0-rc.9954a7c.tgz +0 -0
@@ -79,6 +79,7 @@ var RecordScopeTypeV2 = z2.enum([
79
79
  "record.edit",
80
80
  "record.reject",
81
81
  "record.archive",
82
+ "record.unarchive",
82
83
  "record.review-duplicates",
83
84
  "record.register",
84
85
  "record.print-certified-copies",
@@ -118,11 +119,13 @@ var scopeOptionsPlaceEvent = z2.object({
118
119
  event: scopeByEvent,
119
120
  placeOfEvent: JurisdictionFilter.optional()
120
121
  }).describe("Options applicable to all record scopes.");
121
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
122
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
123
+ notifiedIn: JurisdictionFilter.optional(),
124
+ notifiedBy: UserFilter.optional(),
122
125
  declaredIn: JurisdictionFilter.optional(),
123
126
  declaredBy: UserFilter.optional()
124
127
  }).describe("Options applicable to actions that may take place after DECLARE");
125
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
128
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
126
129
  registeredIn: JurisdictionFilter.optional(),
127
130
  registeredBy: UserFilter.optional()
128
131
  }).describe(
@@ -160,6 +163,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
160
163
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
161
164
  );
162
165
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
166
+ notifiedIn: UUID.nullish(),
167
+ notifiedBy: z2.string().optional(),
163
168
  declaredIn: UUID.nullish(),
164
169
  declaredBy: z2.string().optional()
165
170
  }).describe(
@@ -180,6 +185,7 @@ var ScopesWithDeclaredOptions = RecordScopeTypeV2.extract([
180
185
  "record.edit",
181
186
  "record.reject",
182
187
  "record.archive",
188
+ "record.unarchive",
183
189
  "record.review-duplicates",
184
190
  "record.register"
185
191
  ]);
@@ -205,7 +211,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
205
211
  }),
206
212
  z2.object({
207
213
  type: ScopesWithDeclaredOptions,
208
- options: scopeOptionsDeclared.optional()
214
+ options: scopeOptionsDeclaredOrNotified.optional()
209
215
  }),
210
216
  z2.object({
211
217
  type: ScopesWithFullOptions,
@@ -294,8 +300,9 @@ var EncodedScope = z2.string().brand("EncodedScope");
294
300
  var DEFAULT_SCOPE_OPTIONS = {
295
301
  placeOfEvent: JurisdictionFilter.enum.all,
296
302
  accessLevel: JurisdictionFilter.enum.all,
297
- registeredIn: JurisdictionFilter.enum.all,
298
- declaredIn: JurisdictionFilter.enum.all
303
+ notifiedIn: JurisdictionFilter.enum.all,
304
+ declaredIn: JurisdictionFilter.enum.all,
305
+ registeredIn: JurisdictionFilter.enum.all
299
306
  };
300
307
 
301
308
  // ../commons/src/authentication.ts
@@ -320,6 +327,7 @@ var ActionType = {
320
327
  MARK_AS_DUPLICATE: "MARK_AS_DUPLICATE",
321
328
  MARK_AS_NOT_DUPLICATE: "MARK_AS_NOT_DUPLICATE",
322
329
  ARCHIVE: "ARCHIVE",
330
+ UNARCHIVE: "UNARCHIVE",
323
331
  // Record actions
324
332
  PRINT_CERTIFICATE: "PRINT_CERTIFICATE",
325
333
  REQUEST_CORRECTION: "REQUEST_CORRECTION",
@@ -339,6 +347,7 @@ var ConfirmableActions = [
339
347
  ActionType.REGISTER,
340
348
  ActionType.REJECT,
341
349
  ActionType.ARCHIVE,
350
+ ActionType.UNARCHIVE,
342
351
  ActionType.PRINT_CERTIFICATE,
343
352
  ActionType.REQUEST_CORRECTION,
344
353
  ActionType.APPROVE_CORRECTION,
@@ -357,6 +366,7 @@ var ActionTypes = z4.enum([
357
366
  "MARK_AS_DUPLICATE",
358
367
  "MARK_AS_NOT_DUPLICATE",
359
368
  "ARCHIVE",
369
+ "UNARCHIVE",
360
370
  "PRINT_CERTIFICATE",
361
371
  "REQUEST_CORRECTION",
362
372
  "REJECT_CORRECTION",
@@ -400,6 +410,7 @@ var WorkqueueActionType = ActionTypes.extract([
400
410
  ActionType.REJECT,
401
411
  ActionType.MARK_AS_DUPLICATE,
402
412
  ActionType.ARCHIVE,
413
+ ActionType.UNARCHIVE,
403
414
  ActionType.PRINT_CERTIFICATE,
404
415
  ActionType.REQUEST_CORRECTION
405
416
  ]);
@@ -461,6 +472,7 @@ var EventActionEntrySchema = AuditLogEntryBase.extend({
461
472
  "event.actions.unassign.request",
462
473
  "event.actions.read.request",
463
474
  "event.actions.archive.request",
475
+ "event.actions.unarchive.request",
464
476
  "event.actions.reinstate.request",
465
477
  "event.actions.print_certificate.request",
466
478
  "event.actions.correction.request.request",
@@ -770,6 +782,11 @@ var FieldTypesToHideInReview = [
770
782
  FieldType.ALPHA_PRINT_BUTTON,
771
783
  FieldType.ALPHA_HIDDEN
772
784
  ];
785
+ var HiddenFieldTypes = [
786
+ FieldType.HTTP,
787
+ FieldType.QUERY_PARAM_READER,
788
+ FieldType.ALPHA_HIDDEN
789
+ ];
773
790
 
774
791
  // ../commons/src/events/FieldValue.ts
775
792
  var z12 = __toESM(require("zod/v4"));
@@ -888,7 +905,7 @@ var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date i
888
905
  // ../commons/src/events/FieldValue.ts
889
906
  var TextValue = z12.string();
890
907
  var HiddenFieldValue = z12.string();
891
- var NonEmptyTextValue = TextValue.min(1);
908
+ var NonEmptyTextValue = z12.string().trim().min(1);
892
909
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
893
910
  var AgeValue = z12.object({
894
911
  age: z12.number(),
@@ -917,6 +934,7 @@ var DateRangeFieldValue = z12.object({
917
934
  var EmailValue = z12.email();
918
935
  var CheckboxFieldValue = z12.boolean();
919
936
  var NumberFieldValue = z12.number();
937
+ var SignatureFieldValue = FileFieldValue;
920
938
  var ButtonFieldValue = z12.number();
921
939
  var VerificationStatusValue = z12.enum([
922
940
  "verified",
@@ -1180,6 +1198,11 @@ var ArchiveAction = ActionBase.extend(
1180
1198
  content: ReasonContent
1181
1199
  }).shape
1182
1200
  );
1201
+ var UnarchiveAction = ActionBase.extend(
1202
+ z14.object({
1203
+ type: z14.literal(ActionType.UNARCHIVE)
1204
+ }).shape
1205
+ );
1183
1206
  var CreatedAction = ActionBase.extend(
1184
1207
  z14.object({
1185
1208
  type: z14.literal(ActionType.CREATE)
@@ -1215,8 +1238,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1215
1238
  var ApprovedCorrectionAction = ActionBase.extend(
1216
1239
  z14.object({
1217
1240
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1218
- requestId: z14.string()
1241
+ requestId: z14.string(),
1219
1242
  // TODO move into 'content' property
1243
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1220
1244
  }).shape
1221
1245
  );
1222
1246
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1245,6 +1269,7 @@ var ActionDocument = z14.discriminatedUnion("type", [
1245
1269
  MarkNotDuplicateAction.meta({ id: "MarkNotDuplicateAction" }),
1246
1270
  MarkAsDuplicateAction.meta({ id: "MarkAsDuplicateAction" }),
1247
1271
  ArchiveAction.meta({ id: "ArchiveAction" }),
1272
+ UnarchiveAction.meta({ id: "UnarchiveAction" }),
1248
1273
  NotifiedAction.meta({ id: "NotifiedAction" }),
1249
1274
  RegisterAction.meta({ id: "RegisterAction" }),
1250
1275
  DeclareAction.meta({ id: "DeclareAction" }),
@@ -1350,6 +1375,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1350
1375
  )
1351
1376
  });
1352
1377
  var LegalStatuses = z16.object({
1378
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1353
1379
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1354
1380
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1355
1381
  });
@@ -1409,6 +1435,8 @@ var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1409
1435
  var EventMetadataDateFieldIdInput = z16.enum([
1410
1436
  "createdAt",
1411
1437
  "updatedAt",
1438
+ "legalStatuses.NOTIFIED.createdAt",
1439
+ "legalStatuses.NOTIFIED.acceptedAt",
1412
1440
  "legalStatuses.DECLARED.createdAt",
1413
1441
  "legalStatuses.DECLARED.acceptedAt",
1414
1442
  "legalStatuses.REGISTERED.createdAt",
@@ -1417,6 +1445,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1417
1445
  var EventMetadataDateFieldId = z16.enum([
1418
1446
  "event.createdAt",
1419
1447
  "event.updatedAt",
1448
+ "event.legalStatuses.NOTIFIED.createdAt",
1449
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1420
1450
  "event.legalStatuses.DECLARED.createdAt",
1421
1451
  "event.legalStatuses.DECLARED.acceptedAt",
1422
1452
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1476,7 +1506,8 @@ var Range = import_v4.z.object({
1476
1506
  });
1477
1507
  var ContainsFlags = import_v4.z.object({
1478
1508
  anyOf: import_v4.z.array(Flag).optional(),
1479
- noneOf: import_v4.z.array(Flag).optional()
1509
+ noneOf: import_v4.z.array(Flag).optional(),
1510
+ allOf: import_v4.z.array(Flag).optional()
1480
1511
  }).meta({
1481
1512
  id: "ContainsFlags"
1482
1513
  });
@@ -1665,8 +1696,18 @@ var FieldReference = import_v43.default.object({
1665
1696
  $$field: FieldId.describe("Id of the field to reference"),
1666
1697
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1667
1698
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1699
+ ),
1700
+ $$code: import_v43.default.string().optional().describe(
1701
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1668
1702
  )
1669
- }).describe("Reference to a field by its ID");
1703
+ }).describe(
1704
+ "Reference to a field value, with an optional client-side computation applied."
1705
+ );
1706
+ var ComputedDefaultValue = import_v43.default.object({
1707
+ $$code: import_v43.default.string().describe(
1708
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1709
+ )
1710
+ }).describe("A context-only computation used as a field default value.");
1670
1711
  var ValidationConfig = import_v43.default.object({
1671
1712
  validator: Conditional.describe(
1672
1713
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1707,7 +1748,7 @@ var BaseField = import_v43.default.object({
1707
1748
  "Indicates whether the field can be modified during record correction."
1708
1749
  ),
1709
1750
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
1710
- "Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used."
1751
+ "Reference to the source field or fields. When a value is defined, it is copied from the parent field when changed. If multiple references are provided, the first truthy value is used. A FieldReference with $$code computes the value via a custom client-side function."
1711
1752
  ),
1712
1753
  analytics: import_v43.default.boolean().default(false).optional().describe(
1713
1754
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1721,7 +1762,7 @@ var Divider = BaseField.extend({
1721
1762
  });
1722
1763
  var TextField = BaseField.extend({
1723
1764
  type: import_v43.default.literal(FieldType.TEXT),
1724
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1765
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1725
1766
  configuration: import_v43.default.object({
1726
1767
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1727
1768
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1734,10 +1775,11 @@ var TextField = BaseField.extend({
1734
1775
  });
1735
1776
  var NumberField = BaseField.extend({
1736
1777
  type: import_v43.default.literal(FieldType.NUMBER),
1737
- defaultValue: NumberFieldValue.optional(),
1778
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1738
1779
  configuration: import_v43.default.object({
1739
1780
  min: import_v43.default.number().optional().describe("Minimum value"),
1740
1781
  max: import_v43.default.number().optional().describe("Maximum value"),
1782
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
1741
1783
  prefix: TranslationConfig.optional(),
1742
1784
  postfix: TranslationConfig.optional()
1743
1785
  }).optional()
@@ -1747,7 +1789,7 @@ var NumberField = BaseField.extend({
1747
1789
  });
1748
1790
  var TextAreaField = BaseField.extend({
1749
1791
  type: import_v43.default.literal(FieldType.TEXTAREA),
1750
- defaultValue: NonEmptyTextValue.optional(),
1792
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1751
1793
  configuration: import_v43.default.object({
1752
1794
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1753
1795
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1781,7 +1823,7 @@ var SignatureField = BaseField.extend({
1781
1823
  signaturePromptLabel: TranslationConfig.describe(
1782
1824
  "Title of the signature modal"
1783
1825
  ),
1784
- defaultValue: FieldValue.optional(),
1826
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1785
1827
  configuration: import_v43.default.object({
1786
1828
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1787
1829
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1797,14 +1839,14 @@ var EmailField = BaseField.extend({
1797
1839
  configuration: import_v43.default.object({
1798
1840
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1799
1841
  }).default({ maxLength: 255 }).optional(),
1800
- defaultValue: NonEmptyTextValue.optional()
1842
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1801
1843
  }).meta({
1802
1844
  description: "An email input field",
1803
1845
  id: "EmailField"
1804
1846
  });
1805
1847
  var DateField = BaseField.extend({
1806
1848
  type: import_v43.default.literal(FieldType.DATE),
1807
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1849
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1808
1850
  configuration: import_v43.default.object({
1809
1851
  notice: TranslationConfig.describe(
1810
1852
  "Text to display above the date input"
@@ -1816,7 +1858,7 @@ var DateField = BaseField.extend({
1816
1858
  });
1817
1859
  var AgeField = BaseField.extend({
1818
1860
  type: import_v43.default.literal(FieldType.AGE),
1819
- defaultValue: NumberFieldValue.optional(),
1861
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1820
1862
  configuration: import_v43.default.object({
1821
1863
  asOfDate: FieldReference,
1822
1864
  prefix: TranslationConfig.optional(),
@@ -1828,7 +1870,7 @@ var AgeField = BaseField.extend({
1828
1870
  });
1829
1871
  var TimeField = BaseField.extend({
1830
1872
  type: import_v43.default.literal(FieldType.TIME),
1831
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1873
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1832
1874
  configuration: import_v43.default.object({
1833
1875
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1834
1876
  notice: TranslationConfig.describe(
@@ -1841,7 +1883,7 @@ var TimeField = BaseField.extend({
1841
1883
  });
1842
1884
  var DateRangeField = BaseField.extend({
1843
1885
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1844
- defaultValue: DateRangeFieldValue.optional(),
1886
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1845
1887
  configuration: import_v43.default.object({
1846
1888
  notice: TranslationConfig.describe(
1847
1889
  "Text to display above the date input"
@@ -1920,7 +1962,7 @@ var PageHeader = BaseField.extend({
1920
1962
  });
1921
1963
  var File = BaseField.extend({
1922
1964
  type: import_v43.default.literal(FieldType.FILE),
1923
- defaultValue: FileFieldValue.optional(),
1965
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1924
1966
  configuration: import_v43.default.object({
1925
1967
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1926
1968
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1947,7 +1989,7 @@ var SelectOption = import_v43.default.object({
1947
1989
  });
1948
1990
  var NumberWithUnitField = BaseField.extend({
1949
1991
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1950
- defaultValue: NumberWithUnitFieldValue.optional(),
1992
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1951
1993
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1952
1994
  configuration: import_v43.default.object({
1953
1995
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1962,7 +2004,7 @@ var NumberWithUnitField = BaseField.extend({
1962
2004
  });
1963
2005
  var RadioGroup = BaseField.extend({
1964
2006
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1965
- defaultValue: TextValue.optional(),
2007
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1966
2008
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1967
2009
  configuration: import_v43.default.object({
1968
2010
  styles: import_v43.default.object({
@@ -1987,7 +2029,7 @@ var BulletList = BaseField.extend({
1987
2029
  });
1988
2030
  var Select = BaseField.extend({
1989
2031
  type: import_v43.default.literal(FieldType.SELECT),
1990
- defaultValue: TextValue.optional(),
2032
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1991
2033
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1992
2034
  noOptionsMessage: TranslationConfig.optional().describe(
1993
2035
  `
@@ -2009,7 +2051,7 @@ var SelectDateRangeOption = import_v43.default.object({
2009
2051
  });
2010
2052
  var SelectDateRangeField = BaseField.extend({
2011
2053
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2012
- defaultValue: SelectDateRangeValue.optional(),
2054
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2013
2055
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2014
2056
  }).meta({
2015
2057
  description: "A date range selection field",
@@ -2026,7 +2068,7 @@ var NameField = BaseField.extend({
2026
2068
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2027
2069
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2028
2070
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2029
- }).optional(),
2071
+ }).or(ComputedDefaultValue).optional(),
2030
2072
  configuration: import_v43.default.object({
2031
2073
  name: NameConfig.default({
2032
2074
  firstname: { required: true },
@@ -2050,14 +2092,14 @@ var NameField = BaseField.extend({
2050
2092
  id: "NameField"
2051
2093
  });
2052
2094
  var PhoneField = BaseField.extend({
2053
- defaultValue: NonEmptyTextValue.optional(),
2095
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2054
2096
  type: import_v43.default.literal(FieldType.PHONE)
2055
2097
  }).meta({
2056
2098
  description: "A field for entering a phone number",
2057
2099
  id: "PhoneField"
2058
2100
  });
2059
2101
  var IdField = BaseField.extend({
2060
- defaultValue: NonEmptyTextValue.optional(),
2102
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2061
2103
  type: import_v43.default.literal(FieldType.ID)
2062
2104
  }).meta({
2063
2105
  description: "A field for entering an ID",
@@ -2065,14 +2107,14 @@ var IdField = BaseField.extend({
2065
2107
  });
2066
2108
  var Checkbox = BaseField.extend({
2067
2109
  type: import_v43.default.literal(FieldType.CHECKBOX),
2068
- defaultValue: CheckboxFieldValue.default(false)
2110
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2069
2111
  }).meta({
2070
2112
  description: "A boolean checkbox field",
2071
2113
  id: "Checkbox"
2072
2114
  });
2073
2115
  var Country = BaseField.extend({
2074
2116
  type: import_v43.default.literal(FieldType.COUNTRY),
2075
- defaultValue: NonEmptyTextValue.optional(),
2117
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2076
2118
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2077
2119
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2078
2120
  )
@@ -2090,7 +2132,7 @@ var AdministrativeAreas = import_v43.default.enum([
2090
2132
  ]);
2091
2133
  var AdministrativeAreaField = BaseField.extend({
2092
2134
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2093
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2135
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2094
2136
  configuration: import_v43.default.object({
2095
2137
  partOf: FieldReference.optional().describe("Parent location"),
2096
2138
  type: AdministrativeAreas,
@@ -2102,7 +2144,7 @@ var AdministrativeAreaField = BaseField.extend({
2102
2144
  });
2103
2145
  var LocationInput = BaseField.extend({
2104
2146
  type: import_v43.default.literal(FieldType.LOCATION),
2105
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2147
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2106
2148
  configuration: import_v43.default.object({
2107
2149
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2108
2150
  allowedLocations: AllowedLocations
@@ -2114,7 +2156,7 @@ var LocationInput = BaseField.extend({
2114
2156
  var FileUploadWithOptions = BaseField.extend({
2115
2157
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2116
2158
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2117
- defaultValue: FileFieldWithOptionValue.optional(),
2159
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2118
2160
  configuration: import_v43.default.object({
2119
2161
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2120
2162
  maxImageSize: import_v43.default.object({
@@ -2130,12 +2172,12 @@ var FileUploadWithOptions = BaseField.extend({
2130
2172
  });
2131
2173
  var Facility = BaseField.extend({
2132
2174
  type: import_v43.default.literal(FieldType.FACILITY),
2133
- defaultValue: NonEmptyTextValue.optional(),
2175
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2134
2176
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2135
2177
  }).describe("Input field for a facility");
2136
2178
  var Office = BaseField.extend({
2137
2179
  type: import_v43.default.literal(FieldType.OFFICE),
2138
- defaultValue: NonEmptyTextValue.optional(),
2180
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2139
2181
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2140
2182
  }).describe("Input field for an office");
2141
2183
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2171,7 +2213,7 @@ var Address = BaseField.extend({
2171
2213
  ).optional(),
2172
2214
  allowedLocations: AllowedLocations
2173
2215
  }).optional(),
2174
- defaultValue: DefaultAddressFieldValue.optional()
2216
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2175
2217
  }).meta({
2176
2218
  description: "Address input field \u2013 a combination of location and text fields",
2177
2219
  id: "Address"
@@ -2218,7 +2260,7 @@ var ButtonConfiguration = import_v43.default.object({
2218
2260
  });
2219
2261
  var ButtonField = BaseField.extend({
2220
2262
  type: import_v43.default.literal(FieldType.BUTTON),
2221
- defaultValue: ButtonFieldValue.optional(),
2263
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2222
2264
  configuration: ButtonConfiguration
2223
2265
  }).meta({
2224
2266
  description: "A generic button that can be used to trigger an action",
@@ -2246,7 +2288,7 @@ var AlphaPrintButton = BaseField.extend({
2246
2288
  });
2247
2289
  var HttpField = BaseField.extend({
2248
2290
  type: import_v43.default.literal(FieldType.HTTP),
2249
- defaultValue: HttpFieldValue.optional(),
2291
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2250
2292
  configuration: import_v43.default.object({
2251
2293
  trigger: FieldReference.optional().describe(
2252
2294
  "Reference to the field that triggers the HTTP request when its value changes. If not provided, the HTTP request is triggered once on component mount."
@@ -2332,7 +2374,7 @@ var LinkButtonField = BaseField.extend({
2332
2374
  });
2333
2375
  var VerificationStatus = BaseField.extend({
2334
2376
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2335
- defaultValue: VerificationStatusValue.optional(),
2377
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2336
2378
  configuration: import_v43.default.object({
2337
2379
  status: TranslationConfig.describe("Text to display on the status pill."),
2338
2380
  description: TranslationConfig.describe(
@@ -2354,7 +2396,7 @@ var QueryParamReaderField = BaseField.extend({
2354
2396
  });
2355
2397
  var QrReaderField = BaseField.extend({
2356
2398
  type: import_v43.default.literal(FieldType.QR_READER),
2357
- defaultValue: QrReaderFieldValue.optional(),
2399
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2358
2400
  configuration: import_v43.default.object({
2359
2401
  validator: import_v43.default.any().meta({
2360
2402
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2367,7 +2409,7 @@ var QrReaderField = BaseField.extend({
2367
2409
  });
2368
2410
  var IdReaderField = BaseField.extend({
2369
2411
  type: import_v43.default.literal(FieldType.ID_READER),
2370
- defaultValue: IdReaderFieldValue.optional(),
2412
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2371
2413
  methods: import_v43.default.array(
2372
2414
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2373
2415
  )
@@ -2661,6 +2703,57 @@ var ReadActionConfig = ActionConfigBase.extend(
2661
2703
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2662
2704
  }).shape
2663
2705
  );
2706
+ var NotifyConfig = ActionConfigBase.extend(
2707
+ z24.object({
2708
+ type: z24.literal(ActionType.NOTIFY)
2709
+ }).shape
2710
+ );
2711
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2712
+ z24.object({
2713
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
2714
+ label: z24.never().optional().describe(
2715
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2716
+ ),
2717
+ supportingCopy: z24.never().optional(),
2718
+ icon: z24.never().optional().describe(
2719
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2720
+ ),
2721
+ conditionals: z24.never().optional().describe(
2722
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2723
+ )
2724
+ }).shape
2725
+ );
2726
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2727
+ z24.object({
2728
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2729
+ }).shape
2730
+ );
2731
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2732
+ z24.object({
2733
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2734
+ }).shape
2735
+ );
2736
+ var AssignConfig = ActionConfigBase.extend(
2737
+ z24.object({
2738
+ type: z24.literal(ActionType.ASSIGN),
2739
+ flags: z24.never().optional().describe(
2740
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2741
+ )
2742
+ }).shape
2743
+ );
2744
+ var UnassignConfig = ActionConfigBase.extend(
2745
+ z24.object({
2746
+ type: z24.literal(ActionType.UNASSIGN),
2747
+ flags: z24.never().optional().describe(
2748
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2749
+ )
2750
+ }).shape
2751
+ );
2752
+ var DeleteConfig = ActionConfigBase.extend(
2753
+ z24.object({
2754
+ type: z24.literal(ActionType.DELETE)
2755
+ }).shape
2756
+ );
2664
2757
  var DeclareConfig = DeclarationActionBase.extend(
2665
2758
  z24.object({
2666
2759
  type: z24.literal(ActionType.DECLARE),
@@ -2685,6 +2778,11 @@ var ArchiveConfig = ActionConfigBase.extend(
2685
2778
  type: z24.literal(ActionType.ARCHIVE)
2686
2779
  }).shape
2687
2780
  );
2781
+ var UnarchiveConfig = ActionConfigBase.extend(
2782
+ z24.object({
2783
+ type: z24.literal(ActionType.UNARCHIVE)
2784
+ }).shape
2785
+ );
2688
2786
  var EditActionConfig = ActionConfigBase.extend(
2689
2787
  z24.object({
2690
2788
  type: z24.literal(ActionType.EDIT),
@@ -2723,7 +2821,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2723
2821
  correctionForm: ActionFormConfig
2724
2822
  }).shape
2725
2823
  );
2726
- var CustomActionConfig = ActionConfigBase.merge(
2824
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2825
+ z24.object({
2826
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
2827
+ }).shape
2828
+ );
2829
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2830
+ z24.object({
2831
+ type: z24.literal(ActionType.REJECT_CORRECTION)
2832
+ }).shape
2833
+ );
2834
+ var CustomActionConfig = ActionConfigBase.extend(
2727
2835
  z24.object({
2728
2836
  type: z24.literal(ActionType.CUSTOM),
2729
2837
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2734,7 +2842,7 @@ var CustomActionConfig = ActionConfigBase.merge(
2734
2842
  auditHistoryLabel: TranslationConfig.describe(
2735
2843
  'The label to show in audit history for this action. For example "Approved".'
2736
2844
  )
2737
- })
2845
+ }).shape
2738
2846
  );
2739
2847
  var ActionConfig = z24.discriminatedUnion("type", [
2740
2848
  /*
@@ -2745,9 +2853,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
2745
2853
  id: "ReadActionConfig",
2746
2854
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2747
2855
  }),
2856
+ AssignConfig.meta({
2857
+ id: "AssignActionConfig",
2858
+ description: "Configuration for assigning a record to the current user."
2859
+ }),
2860
+ UnassignConfig.meta({
2861
+ id: "UnassignActionConfig",
2862
+ description: "Configuration for unassigning a record from its current assignee."
2863
+ }),
2864
+ DeleteConfig.meta({
2865
+ id: "DeleteActionConfig",
2866
+ description: "Configuration for deleting a draft record."
2867
+ }),
2868
+ NotifyConfig.meta({
2869
+ id: "NotifyActionConfig",
2870
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
2871
+ }),
2748
2872
  DeclareConfig.meta({
2749
2873
  id: "DeclareActionConfig",
2750
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
2874
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2875
+ }),
2876
+ DuplicateDetectedConfig.meta({
2877
+ id: "DuplicateDetectedActionConfig",
2878
+ 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."
2879
+ }),
2880
+ MarkAsDuplicateConfig.meta({
2881
+ id: "MarkAsDuplicateActionConfig",
2882
+ description: "Configuration for marking a record as a duplicate."
2883
+ }),
2884
+ MarkAsNotDuplicateConfig.meta({
2885
+ id: "MarkAsNotDuplicateActionConfig",
2886
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2751
2887
  }),
2752
2888
  RejectConfig.meta({
2753
2889
  id: "RejectActionConfig",
@@ -2765,6 +2901,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2765
2901
  id: "RequestCorrectionActionConfig",
2766
2902
  description: "Configuration for requesting a correction on a registered record."
2767
2903
  }),
2904
+ ApproveCorrectionConfig.meta({
2905
+ id: "ApproveCorrectionActionConfig",
2906
+ description: "Configuration for approving a requested correction."
2907
+ }),
2908
+ RejectCorrectionConfig.meta({
2909
+ id: "RejectCorrectionActionConfig",
2910
+ description: "Configuration for rejecting a requested correction."
2911
+ }),
2768
2912
  EditActionConfig.meta({
2769
2913
  id: "EditActionConfig",
2770
2914
  description: "Configuration for editing a record before registration."
@@ -2773,6 +2917,10 @@ var ActionConfig = z24.discriminatedUnion("type", [
2773
2917
  id: "ArchiveActionConfig",
2774
2918
  description: "Configuration for archiving a record."
2775
2919
  }),
2920
+ UnarchiveConfig.meta({
2921
+ id: "UnarchiveActionConfig",
2922
+ description: "Configuration for unarchiving a record."
2923
+ }),
2776
2924
  CustomActionConfig.meta({
2777
2925
  id: "CustomActionConfig",
2778
2926
  description: "Configuration for a country-defined custom action. An event may include any number of these."
@@ -2926,6 +3074,9 @@ var BaseField3 = z28.object({
2926
3074
  ),
2927
3075
  validations: z28.array(ValidationConfig).optional().describe(
2928
3076
  `Option for overriding the field validations specifically for advanced search form.`
3077
+ ),
3078
+ allowedLocations: JurisdictionReference.optional().describe(
3079
+ `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.`
2929
3080
  )
2930
3081
  });
2931
3082
  var SearchQueryParams = z28.object({
@@ -3032,7 +3183,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3032
3183
  }
3033
3184
  return current;
3034
3185
  }
3186
+ function todayISO() {
3187
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3188
+ }
3189
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3190
+ function compileClientFunction(code) {
3191
+ let fn = compiledFunctionCache.get(code);
3192
+ if (!fn) {
3193
+ fn = new Function(`return (${code})`)();
3194
+ compiledFunctionCache.set(code, fn);
3195
+ }
3196
+ return fn;
3197
+ }
3035
3198
  (0, import_ajv_formats.default)(ajv);
3199
+ function buildClientFunctionContext(input) {
3200
+ return {
3201
+ $form: input.form,
3202
+ $now: todayISO(),
3203
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
3204
+ $online: isOnline(),
3205
+ $user: input.validatorContext?.user,
3206
+ $event: input.validatorContext?.event,
3207
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3208
+ user: input.systemVariables?.user,
3209
+ $window: input.systemVariables?.$window,
3210
+ locations: input.locations,
3211
+ adminLevelIds: input.adminLevelIds
3212
+ };
3213
+ }
3214
+ function runClientFunction(code, data, context) {
3215
+ return compileClientFunction(code)(data, context);
3216
+ }
3036
3217
  ajv.addKeyword({
3037
3218
  keyword: "daysFromDate",
3038
3219
  type: "string",
@@ -3077,12 +3258,35 @@ ajv.addKeyword({
3077
3258
  $data: true,
3078
3259
  errors: true,
3079
3260
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3080
- validate(schema, data, _2, dataContext) {
3261
+ validate(_schema, data, _2, dataContext) {
3081
3262
  const locationIdInput = data;
3082
3263
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3083
3264
  return locations.some((location) => location.id === locationIdInput);
3084
3265
  }
3085
3266
  });
3267
+ ajv.addKeyword({
3268
+ keyword: "customClientValidator",
3269
+ schemaType: "object",
3270
+ errors: true,
3271
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3272
+ // `validate()` callers build root data via `buildClientFunctionContext`,
3273
+ // so the cast holds.
3274
+ validate(schema, data, _2, dataContext) {
3275
+ return Boolean(
3276
+ runClientFunction(
3277
+ schema.code,
3278
+ data,
3279
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3280
+ )
3281
+ );
3282
+ }
3283
+ });
3284
+ function isOnline() {
3285
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3286
+ return navigator.onLine;
3287
+ }
3288
+ return true;
3289
+ }
3086
3290
 
3087
3291
  // ../commons/src/utils.ts
3088
3292
  var z32 = __toESM(require("zod/v4"));
@@ -3125,7 +3329,7 @@ var getActionAnnotationFields = (actionConfig) => {
3125
3329
  if (actionConfig.type === ActionType.CUSTOM) {
3126
3330
  return actionConfig.form;
3127
3331
  }
3128
- if ("review" in actionConfig) {
3332
+ if ("review" in actionConfig && actionConfig.review != null) {
3129
3333
  return actionConfig.review.fields;
3130
3334
  }
3131
3335
  return [];
@@ -3701,7 +3905,54 @@ function createFieldConditionals(fieldId) {
3701
3905
  }
3702
3906
  },
3703
3907
  required: [fieldId]
3704
- })
3908
+ }),
3909
+ /**
3910
+ * Custom client-side validator. The provided function is serialised and executed
3911
+ * just-in-time on the client only. External references (e.g. lodash) are not
3912
+ * available inside the function body — all logic must be self-contained.
3913
+ *
3914
+ * @example
3915
+ * field('nid').customClientValidator((value) => {
3916
+ * // LUHN check — all logic must be inline
3917
+ * const digits = String(value).split('').map(Number)
3918
+ * // ...
3919
+ * return isValid
3920
+ * })
3921
+ */
3922
+ customClientValidator(validationFn) {
3923
+ const code = validationFn.toString();
3924
+ return defineFormConditional({
3925
+ type: "object",
3926
+ properties: wrapToPath(
3927
+ { [fieldId]: { customClientValidator: { code } } },
3928
+ this.$$subfield
3929
+ ),
3930
+ required: [fieldId]
3931
+ });
3932
+ },
3933
+ /**
3934
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3935
+ * that can be used as the `value` property or a DATA component entry.
3936
+ * The function receives the referenced field's value as the first argument and
3937
+ * the full form context as the second; its return value replaces the field reference.
3938
+ * The function is serialised and executed just-in-time on the client only.
3939
+ * External references (e.g. lodash) are not available inside the function body.
3940
+ *
3941
+ * For computing a default value without referencing a specific field, use
3942
+ * `evaluate(fn)` in the `defaultValue` property instead.
3943
+ *
3944
+ * @example
3945
+ * field('a').customClientEvaluation((aValue, ctx) =>
3946
+ * Number(aValue) + Number(ctx.$form.b)
3947
+ * )
3948
+ */
3949
+ customClientEvaluation(computationFn) {
3950
+ return {
3951
+ $$code: computationFn.toString(),
3952
+ $$field: fieldId,
3953
+ $$subfield: this.$$subfield
3954
+ };
3955
+ }
3705
3956
  };
3706
3957
  }
3707
3958
 
@@ -3789,7 +4040,7 @@ function validateActionFlags(event2, ctx) {
3789
4040
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3790
4041
  const configuredFlagIds = event2.flags.map((flag) => flag.id);
3791
4042
  const actionFlagIds = event2.actions.flatMap(
3792
- (action) => action.flags.map((flag) => flag.id)
4043
+ (action) => (action.flags ?? []).map((flag) => flag.id)
3793
4044
  );
3794
4045
  for (const actionFlagId of actionFlagIds) {
3795
4046
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4442,6 +4693,11 @@ var ArchiveActionInput = BaseActionInput.extend(
4442
4693
  content: ReasonContent
4443
4694
  }).shape
4444
4695
  );
4696
+ var UnarchiveActionInput = BaseActionInput.extend(
4697
+ z38.object({
4698
+ type: z38.literal(ActionType.UNARCHIVE).default(ActionType.UNARCHIVE)
4699
+ }).shape
4700
+ );
4445
4701
  var AssignActionInput = BaseActionInput.extend(
4446
4702
  z38.object({
4447
4703
  type: z38.literal(ActionType.ASSIGN),
@@ -4469,7 +4725,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
4469
4725
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4470
4726
  z38.object({
4471
4727
  requestId: z38.string(),
4472
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
4728
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4729
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
4473
4730
  }).shape
4474
4731
  );
4475
4732
  var ReadActionInput = BaseActionInput.extend(
@@ -4502,6 +4759,7 @@ var ActionInput = z38.discriminatedUnion("type", [
4502
4759
  id: "MarkNotDuplicateActionInput"
4503
4760
  }),
4504
4761
  ArchiveActionInput.meta({ id: "ArchiveActionInput" }),
4762
+ UnarchiveActionInput.meta({ id: "UnarchiveActionInput" }),
4505
4763
  AssignActionInput.meta({ id: "AssignActionInput" }),
4506
4764
  UnassignActionInput.meta({ id: "UnassignActionInput" }),
4507
4765
  PrintCertificateActionInput.meta({ id: "PrintCertificateActionInput" }),
@@ -4579,14 +4837,53 @@ var updateActions = ActionTypes.extract([
4579
4837
  ActionType.REGISTER,
4580
4838
  ActionType.REJECT,
4581
4839
  ActionType.ARCHIVE,
4840
+ ActionType.UNARCHIVE,
4582
4841
  ActionType.PRINT_CERTIFICATE,
4583
4842
  ActionType.REQUEST_CORRECTION,
4843
+ ActionType.APPROVE_CORRECTION,
4844
+ ActionType.REJECT_CORRECTION,
4584
4845
  ActionType.CUSTOM
4585
4846
  ]);
4586
4847
 
4587
4848
  // ../commons/src/events/state/flags.ts
4588
4849
  var import_lodash3 = require("lodash");
4589
4850
  var import_date_fns3 = require("date-fns");
4851
+ var INHERENT_FLAG_RULES = [
4852
+ {
4853
+ flag: InherentFlags.CORRECTION_REQUESTED,
4854
+ setOn: [ActionType.REQUEST_CORRECTION],
4855
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4856
+ },
4857
+ {
4858
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4859
+ // other status-changing action (see getStatusFromActions). ARCHIVE/UNARCHIVE
4860
+ // are deliberately excluded so the flag freezes across an archive/unarchive
4861
+ // round trip and comes back exactly as it was.
4862
+ flag: InherentFlags.INCOMPLETE,
4863
+ setOn: [ActionType.NOTIFY],
4864
+ resetOn: [ActionType.CREATE, ActionType.DECLARE, ActionType.REGISTER]
4865
+ },
4866
+ {
4867
+ flag: InherentFlags.REJECTED,
4868
+ setOn: [ActionType.REJECT],
4869
+ resetOn: [
4870
+ ActionType.NOTIFY,
4871
+ ActionType.DECLARE,
4872
+ ActionType.EDIT,
4873
+ ActionType.REGISTER
4874
+ ]
4875
+ },
4876
+ {
4877
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4878
+ setOn: [ActionType.DUPLICATE_DETECTED],
4879
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4880
+ },
4881
+ {
4882
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4883
+ setOn: [ActionType.EDIT],
4884
+ resetOnAnyOtherAction: true
4885
+ }
4886
+ ];
4590
4887
 
4591
4888
  // ../commons/src/events/defineConfig.ts
4592
4889
  var IGNORED_EVENT_TYPES = [
@@ -5332,6 +5629,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5332
5629
  id: "signature.upload.modal.title",
5333
5630
  defaultMessage: "Draw signature",
5334
5631
  description: "Title for the modal to draw signature"
5632
+ },
5633
+ // Zod applies the schema default at parse time, but this fixture bypasses
5634
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5635
+ configuration: {
5636
+ maxFileSize: 5 * 1024 * 1024
5335
5637
  }
5336
5638
  }
5337
5639
  ]
@@ -5888,6 +6190,20 @@ var tennisClubMembershipEvent = defineConfig({
5888
6190
  },
5889
6191
  review: TENNIS_CLUB_DECLARATION_REVIEW
5890
6192
  },
6193
+ {
6194
+ type: ActionType.NOTIFY,
6195
+ label: {
6196
+ defaultMessage: "Notify health worker",
6197
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6198
+ id: "event.tennis-club-membership.action.notify.label"
6199
+ },
6200
+ flags: [
6201
+ {
6202
+ id: "health-worker-notified",
6203
+ operation: "add"
6204
+ }
6205
+ ]
6206
+ },
5891
6207
  {
5892
6208
  type: ActionType.REJECT,
5893
6209
  label: {
@@ -6130,6 +6446,17 @@ var tennisClubMembershipEvent = defineConfig({
6130
6446
  }
6131
6447
  }
6132
6448
  ],
6449
+ flags: [
6450
+ {
6451
+ id: "health-worker-notified",
6452
+ requiresAction: false,
6453
+ label: {
6454
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6455
+ defaultMessage: "Health worker notified",
6456
+ description: "Label for the health-worker-notified flag"
6457
+ }
6458
+ }
6459
+ ],
6133
6460
  advancedSearch: [
6134
6461
  {
6135
6462
  title: {
@@ -7066,6 +7393,7 @@ var ACTION_SCOPE_MAP = {
7066
7393
  [ActionType.MARK_AS_DUPLICATE]: ["record.review-duplicates"],
7067
7394
  [ActionType.MARK_AS_NOT_DUPLICATE]: ["record.review-duplicates"],
7068
7395
  [ActionType.ARCHIVE]: ["record.archive"],
7396
+ [ActionType.UNARCHIVE]: ["record.unarchive"],
7069
7397
  [ActionType.REJECT]: ["record.reject"],
7070
7398
  [ActionType.ASSIGN]: null,
7071
7399
  [ActionType.UNASSIGN]: null,
@@ -7108,7 +7436,11 @@ var AVAILABLE_ACTIONS_BY_EVENT_STATUS = {
7108
7436
  ActionType.CUSTOM,
7109
7437
  ClientSpecificAction.REVIEW_CORRECTION_REQUEST
7110
7438
  ],
7111
- [EventStatus.enum.ARCHIVED]: [ActionType.READ, ActionType.CUSTOM]
7439
+ [EventStatus.enum.ARCHIVED]: [
7440
+ ActionType.READ,
7441
+ ActionType.CUSTOM,
7442
+ ActionType.UNARCHIVE
7443
+ ]
7112
7444
  };
7113
7445
  var ACTION_FILTERS = {
7114
7446
  [ActionType.PRINT_CERTIFICATE]: (flags) => !flags.includes(InherentFlags.CORRECTION_REQUESTED) && !flags.some((flag) => flag.endsWith(":requested")),
@@ -7121,10 +7453,18 @@ var ACTION_FILTERS = {
7121
7453
  [ActionType.REGISTER]: (flags) => !flags.includes(InherentFlags.POTENTIAL_DUPLICATE) && !flags.some((flag) => flag.endsWith(":requested")),
7122
7454
  [ActionType.REJECT]: (flags) => !flags.includes(InherentFlags.REJECTED) && !flags.some((flag) => flag.endsWith(":requested")),
7123
7455
  [ActionType.ARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7456
+ [ActionType.UNARCHIVE]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7124
7457
  [ActionType.ASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7125
7458
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7126
7459
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7127
7460
  };
7461
+ var REJECTED_ACTIONS = [
7462
+ ActionType.READ,
7463
+ ActionType.NOTIFY,
7464
+ ActionType.CUSTOM,
7465
+ ActionType.EDIT,
7466
+ ActionType.ARCHIVE
7467
+ ];
7128
7468
 
7129
7469
  // ../commons/src/events/FileUtils.ts
7130
7470
  var import_lodash7 = require("lodash");