@opencrvs/toolkit 2.0.0-rc.1237a55 → 2.0.0-rc.1239696

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 (109) hide show
  1. package/README.md +15 -0
  2. package/build.sh +5 -4
  3. package/create-countryconfig/index.js +50 -20
  4. package/dist/application-config/index.js +70 -40
  5. package/dist/cli.js +3186 -4915
  6. package/dist/commons/api/router.d.ts +102 -17
  7. package/dist/commons/application-config/index.d.ts +1 -0
  8. package/dist/commons/conditionals/conditionals.d.ts +357 -7
  9. package/dist/commons/conditionals/validate.d.ts +51 -2
  10. package/dist/commons/events/ActionConfig.d.ts +211 -2
  11. package/dist/commons/events/ActionDocument.d.ts +6 -0
  12. package/dist/commons/events/ActionInput.d.ts +6 -0
  13. package/dist/commons/events/AdvancedSearchConfig.d.ts +354 -0
  14. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  15. package/dist/commons/events/EventConfig.d.ts +2 -0
  16. package/dist/commons/events/EventDocument.d.ts +3 -0
  17. package/dist/commons/events/EventIndex.d.ts +25 -0
  18. package/dist/commons/events/EventMetadata.d.ts +26 -0
  19. package/dist/commons/events/FieldConfig.d.ts +388 -50
  20. package/dist/commons/events/FieldType.d.ts +1 -0
  21. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  22. package/dist/commons/events/FieldValue.d.ts +6 -0
  23. package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
  24. package/dist/commons/events/field.d.ts +53 -1
  25. package/dist/commons/events/index.d.ts +1 -0
  26. package/dist/commons/events/locations.d.ts +1 -0
  27. package/dist/commons/events/state/flags.d.ts +16 -0
  28. package/dist/commons/events/state/index.d.ts +8 -0
  29. package/dist/commons/events/state/utils.d.ts +21 -287
  30. package/dist/commons/events/utils.d.ts +20 -1
  31. package/dist/conditionals/index.js +62 -6
  32. package/dist/environment/custom-types.d.ts +33 -0
  33. package/dist/environment/custom-types.d.ts.map +1 -0
  34. package/dist/environment/custom-types.js +12 -0
  35. package/dist/environment/derived-variables.d.ts +134 -0
  36. package/dist/environment/derived-variables.d.ts.map +1 -0
  37. package/dist/environment/derived-variables.js +169 -0
  38. package/dist/environment/editor-questions.d.ts +4 -0
  39. package/dist/environment/editor-questions.d.ts.map +1 -0
  40. package/dist/environment/editor-questions.js +67 -0
  41. package/dist/environment/git.d.ts +5 -0
  42. package/dist/environment/git.d.ts.map +1 -0
  43. package/dist/environment/git.js +38 -0
  44. package/dist/environment/github.d.ts +26 -0
  45. package/dist/environment/github.d.ts.map +1 -0
  46. package/dist/environment/github.js +247 -0
  47. package/dist/environment/index.d.ts +5 -0
  48. package/dist/environment/index.d.ts.map +1 -0
  49. package/dist/environment/index.js +71 -0
  50. package/dist/environment/logger.d.ts +15 -0
  51. package/dist/environment/logger.d.ts.map +1 -0
  52. package/dist/environment/logger.js +25 -0
  53. package/dist/environment/manage-users.d.ts +11 -0
  54. package/dist/environment/manage-users.d.ts.map +1 -0
  55. package/dist/environment/manage-users.js +497 -0
  56. package/dist/environment/questions-helper.d.ts +15 -0
  57. package/dist/environment/questions-helper.d.ts.map +1 -0
  58. package/dist/environment/questions-helper.js +70 -0
  59. package/dist/environment/questions.d.ts +199 -0
  60. package/dist/environment/questions.d.ts.map +1 -0
  61. package/dist/environment/questions.js +412 -0
  62. package/dist/environment/setup-environment.d.ts +2 -0
  63. package/dist/environment/setup-environment.d.ts.map +1 -0
  64. package/dist/environment/setup-environment.js +794 -0
  65. package/dist/environment/ssh-keygen.d.ts +5 -0
  66. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  67. package/dist/environment/ssh-keygen.js +21 -0
  68. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  69. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  70. package/dist/environment/swarm-to-k8s.js +173 -0
  71. package/dist/environment/templates.d.ts +27 -0
  72. package/dist/environment/templates.d.ts.map +1 -0
  73. package/dist/environment/templates.js +163 -0
  74. package/dist/environment/update-workflows.d.ts +2 -0
  75. package/dist/environment/update-workflows.d.ts.map +1 -0
  76. package/dist/environment/update-workflows.js +169 -0
  77. package/dist/environment/users.d.ts +2 -0
  78. package/dist/environment/users.d.ts.map +1 -0
  79. package/dist/environment/users.js +112 -0
  80. package/dist/environment/utils.d.ts +18 -0
  81. package/dist/environment/utils.d.ts.map +1 -0
  82. package/dist/environment/utils.js +100 -0
  83. package/dist/events/index.js +569 -164
  84. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  85. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  86. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  87. package/dist/migrations/v2.0/index.js +88 -5133
  88. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts +3 -0
  89. package/dist/migrations/v2.1/add-explicit-correction-flags.d.ts.map +1 -0
  90. package/dist/migrations/v2.1/add-explicit-correction-flags.js +234 -0
  91. package/dist/migrations/v2.1/index.d.ts +6 -0
  92. package/dist/migrations/v2.1/index.d.ts.map +1 -0
  93. package/dist/migrations/v2.1/index.js +218 -0
  94. package/dist/notification/index.js +369 -57
  95. package/dist/scopes/index.d.ts +93 -7
  96. package/dist/scopes/index.js +19 -8
  97. package/dist/templates/charts-values/dependencies/values.override.yaml +4 -0
  98. package/dist/templates/charts-values/dependencies/values.yaml +83 -0
  99. package/dist/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  100. package/dist/templates/charts-values/opencrvs-services/values.yaml +81 -0
  101. package/dist/templates/charts-values/traefik/values.override.yaml +4 -0
  102. package/dist/templates/charts-values/traefik/values.yaml +115 -0
  103. package/dist/templates/inventory/inventory.template.yml +100 -0
  104. package/dist/templates/inventory/production.example.yml +77 -0
  105. package/dist/templates/inventory/qa.example.yml +48 -0
  106. package/opencrvs-toolkit-2.0.0-rc.1239696.tgz +0 -0
  107. package/package.json +16 -2
  108. package/tsconfig.tsbuildinfo +1 -1
  109. package/opencrvs-toolkit-2.0.0-rc.1237a55.tgz +0 -0
@@ -118,11 +118,13 @@ var scopeOptionsPlaceEvent = z2.object({
118
118
  event: scopeByEvent,
119
119
  placeOfEvent: JurisdictionFilter.optional()
120
120
  }).describe("Options applicable to all record scopes.");
121
- var scopeOptionsDeclared = scopeOptionsPlaceEvent.extend({
121
+ var scopeOptionsDeclaredOrNotified = scopeOptionsPlaceEvent.extend({
122
+ notifiedIn: JurisdictionFilter.optional(),
123
+ notifiedBy: UserFilter.optional(),
122
124
  declaredIn: JurisdictionFilter.optional(),
123
125
  declaredBy: UserFilter.optional()
124
126
  }).describe("Options applicable to actions that may take place after DECLARE");
125
- var AllRecordScopeOptions = scopeOptionsDeclared.extend({
127
+ var AllRecordScopeOptions = scopeOptionsDeclaredOrNotified.extend({
126
128
  registeredIn: JurisdictionFilter.optional(),
127
129
  registeredBy: UserFilter.optional()
128
130
  }).describe(
@@ -160,6 +162,8 @@ var ResolvedScopeOptionsPlaceEvent = z2.object({
160
162
  "Resolved options applicable to all record scopes, with location ID instead of jurisdiction filter."
161
163
  );
162
164
  var ResolvedScopeOptionsDeclared = ResolvedScopeOptionsPlaceEvent.extend({
165
+ notifiedIn: UUID.nullish(),
166
+ notifiedBy: z2.string().optional(),
163
167
  declaredIn: UUID.nullish(),
164
168
  declaredBy: z2.string().optional()
165
169
  }).describe(
@@ -205,7 +209,7 @@ var RecordScopeV2 = z2.discriminatedUnion("type", [
205
209
  }),
206
210
  z2.object({
207
211
  type: ScopesWithDeclaredOptions,
208
- options: scopeOptionsDeclared.optional()
212
+ options: scopeOptionsDeclaredOrNotified.optional()
209
213
  }),
210
214
  z2.object({
211
215
  type: ScopesWithFullOptions,
@@ -294,8 +298,9 @@ var EncodedScope = z2.string().brand("EncodedScope");
294
298
  var DEFAULT_SCOPE_OPTIONS = {
295
299
  placeOfEvent: JurisdictionFilter.enum.all,
296
300
  accessLevel: JurisdictionFilter.enum.all,
297
- registeredIn: JurisdictionFilter.enum.all,
298
- declaredIn: JurisdictionFilter.enum.all
301
+ notifiedIn: JurisdictionFilter.enum.all,
302
+ declaredIn: JurisdictionFilter.enum.all,
303
+ registeredIn: JurisdictionFilter.enum.all
299
304
  };
300
305
 
301
306
  // ../commons/src/authentication.ts
@@ -770,6 +775,11 @@ var FieldTypesToHideInReview = [
770
775
  FieldType.ALPHA_PRINT_BUTTON,
771
776
  FieldType.ALPHA_HIDDEN
772
777
  ];
778
+ var HiddenFieldTypes = [
779
+ FieldType.HTTP,
780
+ FieldType.QUERY_PARAM_READER,
781
+ FieldType.ALPHA_HIDDEN
782
+ ];
773
783
 
774
784
  // ../commons/src/events/FieldValue.ts
775
785
  var z12 = __toESM(require("zod/v4"));
@@ -888,7 +898,7 @@ var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date i
888
898
  // ../commons/src/events/FieldValue.ts
889
899
  var TextValue = z12.string();
890
900
  var HiddenFieldValue = z12.string();
891
- var NonEmptyTextValue = TextValue.min(1);
901
+ var NonEmptyTextValue = z12.string().trim().min(1);
892
902
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
893
903
  var AgeValue = z12.object({
894
904
  age: z12.number(),
@@ -917,6 +927,7 @@ var DateRangeFieldValue = z12.object({
917
927
  var EmailValue = z12.email();
918
928
  var CheckboxFieldValue = z12.boolean();
919
929
  var NumberFieldValue = z12.number();
930
+ var SignatureFieldValue = FileFieldValue;
920
931
  var ButtonFieldValue = z12.number();
921
932
  var VerificationStatusValue = z12.enum([
922
933
  "verified",
@@ -1215,8 +1226,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1215
1226
  var ApprovedCorrectionAction = ActionBase.extend(
1216
1227
  z14.object({
1217
1228
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1218
- requestId: z14.string()
1229
+ requestId: z14.string(),
1219
1230
  // TODO move into 'content' property
1231
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1220
1232
  }).shape
1221
1233
  );
1222
1234
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1350,6 +1362,7 @@ var RegistrationCreationMetadata = ActionCreationMetadata.extend({
1350
1362
  )
1351
1363
  });
1352
1364
  var LegalStatuses = z16.object({
1365
+ [EventStatus.enum.NOTIFIED]: ActionCreationMetadata.nullish(),
1353
1366
  [EventStatus.enum.DECLARED]: ActionCreationMetadata.nullish(),
1354
1367
  [EventStatus.enum.REGISTERED]: RegistrationCreationMetadata.nullish()
1355
1368
  });
@@ -1409,6 +1422,8 @@ var EventMetadataKeys = z16.enum(EventMetadataKeysArray);
1409
1422
  var EventMetadataDateFieldIdInput = z16.enum([
1410
1423
  "createdAt",
1411
1424
  "updatedAt",
1425
+ "legalStatuses.NOTIFIED.createdAt",
1426
+ "legalStatuses.NOTIFIED.acceptedAt",
1412
1427
  "legalStatuses.DECLARED.createdAt",
1413
1428
  "legalStatuses.DECLARED.acceptedAt",
1414
1429
  "legalStatuses.REGISTERED.createdAt",
@@ -1417,6 +1432,8 @@ var EventMetadataDateFieldIdInput = z16.enum([
1417
1432
  var EventMetadataDateFieldId = z16.enum([
1418
1433
  "event.createdAt",
1419
1434
  "event.updatedAt",
1435
+ "event.legalStatuses.NOTIFIED.createdAt",
1436
+ "event.legalStatuses.NOTIFIED.acceptedAt",
1420
1437
  "event.legalStatuses.DECLARED.createdAt",
1421
1438
  "event.legalStatuses.DECLARED.acceptedAt",
1422
1439
  "event.legalStatuses.REGISTERED.createdAt",
@@ -1476,7 +1493,8 @@ var Range = import_v4.z.object({
1476
1493
  });
1477
1494
  var ContainsFlags = import_v4.z.object({
1478
1495
  anyOf: import_v4.z.array(Flag).optional(),
1479
- noneOf: import_v4.z.array(Flag).optional()
1496
+ noneOf: import_v4.z.array(Flag).optional(),
1497
+ allOf: import_v4.z.array(Flag).optional()
1480
1498
  }).meta({
1481
1499
  id: "ContainsFlags"
1482
1500
  });
@@ -1665,8 +1683,18 @@ var FieldReference = import_v43.default.object({
1665
1683
  $$field: FieldId.describe("Id of the field to reference"),
1666
1684
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1667
1685
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1686
+ ),
1687
+ $$code: import_v43.default.string().optional().describe(
1688
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1689
+ )
1690
+ }).describe(
1691
+ "Reference to a field value, with an optional client-side computation applied."
1692
+ );
1693
+ var ComputedDefaultValue = import_v43.default.object({
1694
+ $$code: import_v43.default.string().describe(
1695
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1668
1696
  )
1669
- }).describe("Reference to a field by its ID");
1697
+ }).describe("A context-only computation used as a field default value.");
1670
1698
  var ValidationConfig = import_v43.default.object({
1671
1699
  validator: Conditional.describe(
1672
1700
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1707,7 +1735,7 @@ var BaseField = import_v43.default.object({
1707
1735
  "Indicates whether the field can be modified during record correction."
1708
1736
  ),
1709
1737
  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."
1738
+ "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
1739
  ),
1712
1740
  analytics: import_v43.default.boolean().default(false).optional().describe(
1713
1741
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1721,7 +1749,7 @@ var Divider = BaseField.extend({
1721
1749
  });
1722
1750
  var TextField = BaseField.extend({
1723
1751
  type: import_v43.default.literal(FieldType.TEXT),
1724
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1752
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1725
1753
  configuration: import_v43.default.object({
1726
1754
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1727
1755
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1734,10 +1762,11 @@ var TextField = BaseField.extend({
1734
1762
  });
1735
1763
  var NumberField = BaseField.extend({
1736
1764
  type: import_v43.default.literal(FieldType.NUMBER),
1737
- defaultValue: NumberFieldValue.optional(),
1765
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1738
1766
  configuration: import_v43.default.object({
1739
1767
  min: import_v43.default.number().optional().describe("Minimum value"),
1740
1768
  max: import_v43.default.number().optional().describe("Maximum value"),
1769
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
1741
1770
  prefix: TranslationConfig.optional(),
1742
1771
  postfix: TranslationConfig.optional()
1743
1772
  }).optional()
@@ -1747,7 +1776,7 @@ var NumberField = BaseField.extend({
1747
1776
  });
1748
1777
  var TextAreaField = BaseField.extend({
1749
1778
  type: import_v43.default.literal(FieldType.TEXTAREA),
1750
- defaultValue: NonEmptyTextValue.optional(),
1779
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1751
1780
  configuration: import_v43.default.object({
1752
1781
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1753
1782
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1781,7 +1810,7 @@ var SignatureField = BaseField.extend({
1781
1810
  signaturePromptLabel: TranslationConfig.describe(
1782
1811
  "Title of the signature modal"
1783
1812
  ),
1784
- defaultValue: FieldValue.optional(),
1813
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1785
1814
  configuration: import_v43.default.object({
1786
1815
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1787
1816
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1797,14 +1826,14 @@ var EmailField = BaseField.extend({
1797
1826
  configuration: import_v43.default.object({
1798
1827
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1799
1828
  }).default({ maxLength: 255 }).optional(),
1800
- defaultValue: NonEmptyTextValue.optional()
1829
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1801
1830
  }).meta({
1802
1831
  description: "An email input field",
1803
1832
  id: "EmailField"
1804
1833
  });
1805
1834
  var DateField = BaseField.extend({
1806
1835
  type: import_v43.default.literal(FieldType.DATE),
1807
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1836
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1808
1837
  configuration: import_v43.default.object({
1809
1838
  notice: TranslationConfig.describe(
1810
1839
  "Text to display above the date input"
@@ -1816,7 +1845,7 @@ var DateField = BaseField.extend({
1816
1845
  });
1817
1846
  var AgeField = BaseField.extend({
1818
1847
  type: import_v43.default.literal(FieldType.AGE),
1819
- defaultValue: NumberFieldValue.optional(),
1848
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1820
1849
  configuration: import_v43.default.object({
1821
1850
  asOfDate: FieldReference,
1822
1851
  prefix: TranslationConfig.optional(),
@@ -1828,7 +1857,7 @@ var AgeField = BaseField.extend({
1828
1857
  });
1829
1858
  var TimeField = BaseField.extend({
1830
1859
  type: import_v43.default.literal(FieldType.TIME),
1831
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1860
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1832
1861
  configuration: import_v43.default.object({
1833
1862
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1834
1863
  notice: TranslationConfig.describe(
@@ -1841,7 +1870,7 @@ var TimeField = BaseField.extend({
1841
1870
  });
1842
1871
  var DateRangeField = BaseField.extend({
1843
1872
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1844
- defaultValue: DateRangeFieldValue.optional(),
1873
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1845
1874
  configuration: import_v43.default.object({
1846
1875
  notice: TranslationConfig.describe(
1847
1876
  "Text to display above the date input"
@@ -1920,7 +1949,7 @@ var PageHeader = BaseField.extend({
1920
1949
  });
1921
1950
  var File = BaseField.extend({
1922
1951
  type: import_v43.default.literal(FieldType.FILE),
1923
- defaultValue: FileFieldValue.optional(),
1952
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1924
1953
  configuration: import_v43.default.object({
1925
1954
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1926
1955
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1947,7 +1976,7 @@ var SelectOption = import_v43.default.object({
1947
1976
  });
1948
1977
  var NumberWithUnitField = BaseField.extend({
1949
1978
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1950
- defaultValue: NumberWithUnitFieldValue.optional(),
1979
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1951
1980
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1952
1981
  configuration: import_v43.default.object({
1953
1982
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1962,7 +1991,7 @@ var NumberWithUnitField = BaseField.extend({
1962
1991
  });
1963
1992
  var RadioGroup = BaseField.extend({
1964
1993
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1965
- defaultValue: TextValue.optional(),
1994
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1966
1995
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1967
1996
  configuration: import_v43.default.object({
1968
1997
  styles: import_v43.default.object({
@@ -1987,7 +2016,7 @@ var BulletList = BaseField.extend({
1987
2016
  });
1988
2017
  var Select = BaseField.extend({
1989
2018
  type: import_v43.default.literal(FieldType.SELECT),
1990
- defaultValue: TextValue.optional(),
2019
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1991
2020
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1992
2021
  noOptionsMessage: TranslationConfig.optional().describe(
1993
2022
  `
@@ -2009,7 +2038,7 @@ var SelectDateRangeOption = import_v43.default.object({
2009
2038
  });
2010
2039
  var SelectDateRangeField = BaseField.extend({
2011
2040
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2012
- defaultValue: SelectDateRangeValue.optional(),
2041
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2013
2042
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2014
2043
  }).meta({
2015
2044
  description: "A date range selection field",
@@ -2026,7 +2055,7 @@ var NameField = BaseField.extend({
2026
2055
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2027
2056
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2028
2057
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2029
- }).optional(),
2058
+ }).or(ComputedDefaultValue).optional(),
2030
2059
  configuration: import_v43.default.object({
2031
2060
  name: NameConfig.default({
2032
2061
  firstname: { required: true },
@@ -2050,14 +2079,14 @@ var NameField = BaseField.extend({
2050
2079
  id: "NameField"
2051
2080
  });
2052
2081
  var PhoneField = BaseField.extend({
2053
- defaultValue: NonEmptyTextValue.optional(),
2082
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2054
2083
  type: import_v43.default.literal(FieldType.PHONE)
2055
2084
  }).meta({
2056
2085
  description: "A field for entering a phone number",
2057
2086
  id: "PhoneField"
2058
2087
  });
2059
2088
  var IdField = BaseField.extend({
2060
- defaultValue: NonEmptyTextValue.optional(),
2089
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2061
2090
  type: import_v43.default.literal(FieldType.ID)
2062
2091
  }).meta({
2063
2092
  description: "A field for entering an ID",
@@ -2065,14 +2094,14 @@ var IdField = BaseField.extend({
2065
2094
  });
2066
2095
  var Checkbox = BaseField.extend({
2067
2096
  type: import_v43.default.literal(FieldType.CHECKBOX),
2068
- defaultValue: CheckboxFieldValue.default(false)
2097
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2069
2098
  }).meta({
2070
2099
  description: "A boolean checkbox field",
2071
2100
  id: "Checkbox"
2072
2101
  });
2073
2102
  var Country = BaseField.extend({
2074
2103
  type: import_v43.default.literal(FieldType.COUNTRY),
2075
- defaultValue: NonEmptyTextValue.optional(),
2104
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2076
2105
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2077
2106
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2078
2107
  )
@@ -2090,7 +2119,7 @@ var AdministrativeAreas = import_v43.default.enum([
2090
2119
  ]);
2091
2120
  var AdministrativeAreaField = BaseField.extend({
2092
2121
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2093
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2122
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2094
2123
  configuration: import_v43.default.object({
2095
2124
  partOf: FieldReference.optional().describe("Parent location"),
2096
2125
  type: AdministrativeAreas,
@@ -2102,7 +2131,7 @@ var AdministrativeAreaField = BaseField.extend({
2102
2131
  });
2103
2132
  var LocationInput = BaseField.extend({
2104
2133
  type: import_v43.default.literal(FieldType.LOCATION),
2105
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2134
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2106
2135
  configuration: import_v43.default.object({
2107
2136
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2108
2137
  allowedLocations: AllowedLocations
@@ -2114,7 +2143,7 @@ var LocationInput = BaseField.extend({
2114
2143
  var FileUploadWithOptions = BaseField.extend({
2115
2144
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2116
2145
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2117
- defaultValue: FileFieldWithOptionValue.optional(),
2146
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2118
2147
  configuration: import_v43.default.object({
2119
2148
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2120
2149
  maxImageSize: import_v43.default.object({
@@ -2130,12 +2159,12 @@ var FileUploadWithOptions = BaseField.extend({
2130
2159
  });
2131
2160
  var Facility = BaseField.extend({
2132
2161
  type: import_v43.default.literal(FieldType.FACILITY),
2133
- defaultValue: NonEmptyTextValue.optional(),
2162
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2134
2163
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2135
2164
  }).describe("Input field for a facility");
2136
2165
  var Office = BaseField.extend({
2137
2166
  type: import_v43.default.literal(FieldType.OFFICE),
2138
- defaultValue: NonEmptyTextValue.optional(),
2167
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2139
2168
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2140
2169
  }).describe("Input field for an office");
2141
2170
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2171,7 +2200,7 @@ var Address = BaseField.extend({
2171
2200
  ).optional(),
2172
2201
  allowedLocations: AllowedLocations
2173
2202
  }).optional(),
2174
- defaultValue: DefaultAddressFieldValue.optional()
2203
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2175
2204
  }).meta({
2176
2205
  description: "Address input field \u2013 a combination of location and text fields",
2177
2206
  id: "Address"
@@ -2218,7 +2247,7 @@ var ButtonConfiguration = import_v43.default.object({
2218
2247
  });
2219
2248
  var ButtonField = BaseField.extend({
2220
2249
  type: import_v43.default.literal(FieldType.BUTTON),
2221
- defaultValue: ButtonFieldValue.optional(),
2250
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2222
2251
  configuration: ButtonConfiguration
2223
2252
  }).meta({
2224
2253
  description: "A generic button that can be used to trigger an action",
@@ -2246,7 +2275,7 @@ var AlphaPrintButton = BaseField.extend({
2246
2275
  });
2247
2276
  var HttpField = BaseField.extend({
2248
2277
  type: import_v43.default.literal(FieldType.HTTP),
2249
- defaultValue: HttpFieldValue.optional(),
2278
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2250
2279
  configuration: import_v43.default.object({
2251
2280
  trigger: FieldReference.optional().describe(
2252
2281
  "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 +2361,7 @@ var LinkButtonField = BaseField.extend({
2332
2361
  });
2333
2362
  var VerificationStatus = BaseField.extend({
2334
2363
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2335
- defaultValue: VerificationStatusValue.optional(),
2364
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2336
2365
  configuration: import_v43.default.object({
2337
2366
  status: TranslationConfig.describe("Text to display on the status pill."),
2338
2367
  description: TranslationConfig.describe(
@@ -2354,7 +2383,7 @@ var QueryParamReaderField = BaseField.extend({
2354
2383
  });
2355
2384
  var QrReaderField = BaseField.extend({
2356
2385
  type: import_v43.default.literal(FieldType.QR_READER),
2357
- defaultValue: QrReaderFieldValue.optional(),
2386
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2358
2387
  configuration: import_v43.default.object({
2359
2388
  validator: import_v43.default.any().meta({
2360
2389
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2367,7 +2396,7 @@ var QrReaderField = BaseField.extend({
2367
2396
  });
2368
2397
  var IdReaderField = BaseField.extend({
2369
2398
  type: import_v43.default.literal(FieldType.ID_READER),
2370
- defaultValue: IdReaderFieldValue.optional(),
2399
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2371
2400
  methods: import_v43.default.array(
2372
2401
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2373
2402
  )
@@ -2652,6 +2681,9 @@ var ActionConfigBase = z24.object({
2652
2681
  var DeclarationActionBase = ActionConfigBase.extend({
2653
2682
  deduplication: DeduplicationConfig.optional()
2654
2683
  });
2684
+ var actionConfirmationForm = z24.array(FieldConfig).optional().describe(
2685
+ "Fields rendered on the action confirmation dialog. Submitted values are stored in the action annotation and shown in the audit history."
2686
+ );
2655
2687
  var ReadActionConfig = ActionConfigBase.extend(
2656
2688
  z24.object({
2657
2689
  type: z24.literal(ActionType.READ),
@@ -2661,12 +2693,65 @@ var ReadActionConfig = ActionConfigBase.extend(
2661
2693
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2662
2694
  }).shape
2663
2695
  );
2696
+ var NotifyConfig = ActionConfigBase.extend(
2697
+ z24.object({
2698
+ type: z24.literal(ActionType.NOTIFY),
2699
+ form: actionConfirmationForm
2700
+ }).shape
2701
+ );
2702
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2703
+ z24.object({
2704
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
2705
+ label: z24.never().optional().describe(
2706
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2707
+ ),
2708
+ supportingCopy: z24.never().optional(),
2709
+ icon: z24.never().optional().describe(
2710
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2711
+ ),
2712
+ conditionals: z24.never().optional().describe(
2713
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2714
+ )
2715
+ }).shape
2716
+ );
2717
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2718
+ z24.object({
2719
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2720
+ }).shape
2721
+ );
2722
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2723
+ z24.object({
2724
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2725
+ }).shape
2726
+ );
2727
+ var AssignConfig = ActionConfigBase.extend(
2728
+ z24.object({
2729
+ type: z24.literal(ActionType.ASSIGN),
2730
+ flags: z24.never().optional().describe(
2731
+ "ASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2732
+ )
2733
+ }).shape
2734
+ );
2735
+ var UnassignConfig = ActionConfigBase.extend(
2736
+ z24.object({
2737
+ type: z24.literal(ActionType.UNASSIGN),
2738
+ flags: z24.never().optional().describe(
2739
+ "UNASSIGN is a meta action excluded from flag resolution, so flags configured here would never apply."
2740
+ )
2741
+ }).shape
2742
+ );
2743
+ var DeleteConfig = ActionConfigBase.extend(
2744
+ z24.object({
2745
+ type: z24.literal(ActionType.DELETE)
2746
+ }).shape
2747
+ );
2664
2748
  var DeclareConfig = DeclarationActionBase.extend(
2665
2749
  z24.object({
2666
2750
  type: z24.literal(ActionType.DECLARE),
2667
2751
  review: DeclarationReviewConfig.describe(
2668
2752
  "Configuration of the review page fields."
2669
2753
  ),
2754
+ form: actionConfirmationForm,
2670
2755
  dialogCopy: z24.object({
2671
2756
  notify: TranslationConfig.describe(
2672
2757
  "Confirmation text for the notify action"
@@ -2682,7 +2767,8 @@ var DeclareConfig = DeclarationActionBase.extend(
2682
2767
  );
2683
2768
  var ArchiveConfig = ActionConfigBase.extend(
2684
2769
  z24.object({
2685
- type: z24.literal(ActionType.ARCHIVE)
2770
+ type: z24.literal(ActionType.ARCHIVE),
2771
+ form: actionConfirmationForm
2686
2772
  }).shape
2687
2773
  );
2688
2774
  var EditActionConfig = ActionConfigBase.extend(
@@ -2703,12 +2789,14 @@ var EditActionConfig = ActionConfigBase.extend(
2703
2789
  );
2704
2790
  var RejectConfig = ActionConfigBase.extend(
2705
2791
  z24.object({
2706
- type: z24.literal(ActionType.REJECT)
2792
+ type: z24.literal(ActionType.REJECT),
2793
+ form: actionConfirmationForm
2707
2794
  }).shape
2708
2795
  );
2709
2796
  var RegisterConfig = DeclarationActionBase.extend(
2710
2797
  z24.object({
2711
- type: z24.literal(ActionType.REGISTER)
2798
+ type: z24.literal(ActionType.REGISTER),
2799
+ form: actionConfirmationForm
2712
2800
  }).shape
2713
2801
  );
2714
2802
  var PrintCertificateActionConfig = ActionConfigBase.extend(
@@ -2723,7 +2811,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2723
2811
  correctionForm: ActionFormConfig
2724
2812
  }).shape
2725
2813
  );
2726
- var CustomActionConfig = ActionConfigBase.merge(
2814
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2815
+ z24.object({
2816
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
2817
+ }).shape
2818
+ );
2819
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2820
+ z24.object({
2821
+ type: z24.literal(ActionType.REJECT_CORRECTION)
2822
+ }).shape
2823
+ );
2824
+ var CustomActionConfig = ActionConfigBase.extend(
2727
2825
  z24.object({
2728
2826
  type: z24.literal(ActionType.CUSTOM),
2729
2827
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2734,7 +2832,7 @@ var CustomActionConfig = ActionConfigBase.merge(
2734
2832
  auditHistoryLabel: TranslationConfig.describe(
2735
2833
  'The label to show in audit history for this action. For example "Approved".'
2736
2834
  )
2737
- })
2835
+ }).shape
2738
2836
  );
2739
2837
  var ActionConfig = z24.discriminatedUnion("type", [
2740
2838
  /*
@@ -2745,9 +2843,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
2745
2843
  id: "ReadActionConfig",
2746
2844
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2747
2845
  }),
2846
+ AssignConfig.meta({
2847
+ id: "AssignActionConfig",
2848
+ description: "Configuration for assigning a record to the current user."
2849
+ }),
2850
+ UnassignConfig.meta({
2851
+ id: "UnassignActionConfig",
2852
+ description: "Configuration for unassigning a record from its current assignee."
2853
+ }),
2854
+ DeleteConfig.meta({
2855
+ id: "DeleteActionConfig",
2856
+ description: "Configuration for deleting a draft record."
2857
+ }),
2858
+ NotifyConfig.meta({
2859
+ id: "NotifyActionConfig",
2860
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
2861
+ }),
2748
2862
  DeclareConfig.meta({
2749
2863
  id: "DeclareActionConfig",
2750
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
2864
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2865
+ }),
2866
+ DuplicateDetectedConfig.meta({
2867
+ id: "DuplicateDetectedActionConfig",
2868
+ 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."
2869
+ }),
2870
+ MarkAsDuplicateConfig.meta({
2871
+ id: "MarkAsDuplicateActionConfig",
2872
+ description: "Configuration for marking a record as a duplicate."
2873
+ }),
2874
+ MarkAsNotDuplicateConfig.meta({
2875
+ id: "MarkAsNotDuplicateActionConfig",
2876
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2751
2877
  }),
2752
2878
  RejectConfig.meta({
2753
2879
  id: "RejectActionConfig",
@@ -2765,6 +2891,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2765
2891
  id: "RequestCorrectionActionConfig",
2766
2892
  description: "Configuration for requesting a correction on a registered record."
2767
2893
  }),
2894
+ ApproveCorrectionConfig.meta({
2895
+ id: "ApproveCorrectionActionConfig",
2896
+ description: "Configuration for approving a requested correction."
2897
+ }),
2898
+ RejectCorrectionConfig.meta({
2899
+ id: "RejectCorrectionActionConfig",
2900
+ description: "Configuration for rejecting a requested correction."
2901
+ }),
2768
2902
  EditActionConfig.meta({
2769
2903
  id: "EditActionConfig",
2770
2904
  description: "Configuration for editing a record before registration."
@@ -2926,6 +3060,9 @@ var BaseField3 = z28.object({
2926
3060
  ),
2927
3061
  validations: z28.array(ValidationConfig).optional().describe(
2928
3062
  `Option for overriding the field validations specifically for advanced search form.`
3063
+ ),
3064
+ allowedLocations: JurisdictionReference.optional().describe(
3065
+ `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
3066
  )
2930
3067
  });
2931
3068
  var SearchQueryParams = z28.object({
@@ -3032,7 +3169,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3032
3169
  }
3033
3170
  return current;
3034
3171
  }
3172
+ function todayISO() {
3173
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3174
+ }
3175
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3176
+ function compileClientFunction(code) {
3177
+ let fn = compiledFunctionCache.get(code);
3178
+ if (!fn) {
3179
+ fn = new Function(`return (${code})`)();
3180
+ compiledFunctionCache.set(code, fn);
3181
+ }
3182
+ return fn;
3183
+ }
3035
3184
  (0, import_ajv_formats.default)(ajv);
3185
+ function buildClientFunctionContext(input) {
3186
+ return {
3187
+ $form: input.form,
3188
+ $now: todayISO(),
3189
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
3190
+ $online: isOnline(),
3191
+ $user: input.validatorContext?.user,
3192
+ $event: input.validatorContext?.event,
3193
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3194
+ user: input.systemVariables?.user,
3195
+ $window: input.systemVariables?.$window,
3196
+ locations: input.locations,
3197
+ adminLevelIds: input.adminLevelIds
3198
+ };
3199
+ }
3200
+ function runClientFunction(code, data, context) {
3201
+ return compileClientFunction(code)(data, context);
3202
+ }
3036
3203
  ajv.addKeyword({
3037
3204
  keyword: "daysFromDate",
3038
3205
  type: "string",
@@ -3077,12 +3244,35 @@ ajv.addKeyword({
3077
3244
  $data: true,
3078
3245
  errors: true,
3079
3246
  // @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) {
3247
+ validate(_schema, data, _2, dataContext) {
3081
3248
  const locationIdInput = data;
3082
3249
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3083
3250
  return locations.some((location) => location.id === locationIdInput);
3084
3251
  }
3085
3252
  });
3253
+ ajv.addKeyword({
3254
+ keyword: "customClientValidator",
3255
+ schemaType: "object",
3256
+ errors: true,
3257
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3258
+ // `validate()` callers build root data via `buildClientFunctionContext`,
3259
+ // so the cast holds.
3260
+ validate(schema, data, _2, dataContext) {
3261
+ return Boolean(
3262
+ runClientFunction(
3263
+ schema.code,
3264
+ data,
3265
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3266
+ )
3267
+ );
3268
+ }
3269
+ });
3270
+ function isOnline() {
3271
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3272
+ return navigator.onLine;
3273
+ }
3274
+ return true;
3275
+ }
3086
3276
 
3087
3277
  // ../commons/src/utils.ts
3088
3278
  var z32 = __toESM(require("zod/v4"));
@@ -3122,13 +3312,9 @@ var getActionAnnotationFields = (actionConfig) => {
3122
3312
  if (actionConfig.type === ActionType.PRINT_CERTIFICATE) {
3123
3313
  return actionConfig.printForm.pages.flatMap(({ fields }) => fields);
3124
3314
  }
3125
- if (actionConfig.type === ActionType.CUSTOM) {
3126
- return actionConfig.form;
3127
- }
3128
- if ("review" in actionConfig) {
3129
- return actionConfig.review.fields;
3130
- }
3131
- return [];
3315
+ const reviewFields = "review" in actionConfig && actionConfig.review != null ? actionConfig.review.fields : [];
3316
+ const formFields = "form" in actionConfig && actionConfig.form != null ? actionConfig.form : [];
3317
+ return [...reviewFields, ...formFields];
3132
3318
  };
3133
3319
  function getAllAnnotationFields(config) {
3134
3320
  return (0, import_lodash.flattenDeep)(config.actions.map(getActionAnnotationFields));
@@ -3701,7 +3887,54 @@ function createFieldConditionals(fieldId) {
3701
3887
  }
3702
3888
  },
3703
3889
  required: [fieldId]
3704
- })
3890
+ }),
3891
+ /**
3892
+ * Custom client-side validator. The provided function is serialised and executed
3893
+ * just-in-time on the client only. External references (e.g. lodash) are not
3894
+ * available inside the function body — all logic must be self-contained.
3895
+ *
3896
+ * @example
3897
+ * field('nid').customClientValidator((value) => {
3898
+ * // LUHN check — all logic must be inline
3899
+ * const digits = String(value).split('').map(Number)
3900
+ * // ...
3901
+ * return isValid
3902
+ * })
3903
+ */
3904
+ customClientValidator(validationFn) {
3905
+ const code = validationFn.toString();
3906
+ return defineFormConditional({
3907
+ type: "object",
3908
+ properties: wrapToPath(
3909
+ { [fieldId]: { customClientValidator: { code } } },
3910
+ this.$$subfield
3911
+ ),
3912
+ required: [fieldId]
3913
+ });
3914
+ },
3915
+ /**
3916
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3917
+ * that can be used as the `value` property or a DATA component entry.
3918
+ * The function receives the referenced field's value as the first argument and
3919
+ * the full form context as the second; its return value replaces the field reference.
3920
+ * The function is serialised and executed just-in-time on the client only.
3921
+ * External references (e.g. lodash) are not available inside the function body.
3922
+ *
3923
+ * For computing a default value without referencing a specific field, use
3924
+ * `evaluate(fn)` in the `defaultValue` property instead.
3925
+ *
3926
+ * @example
3927
+ * field('a').customClientEvaluation((aValue, ctx) =>
3928
+ * Number(aValue) + Number(ctx.$form.b)
3929
+ * )
3930
+ */
3931
+ customClientEvaluation(computationFn) {
3932
+ return {
3933
+ $$code: computationFn.toString(),
3934
+ $$field: fieldId,
3935
+ $$subfield: this.$$subfield
3936
+ };
3937
+ }
3705
3938
  };
3706
3939
  }
3707
3940
 
@@ -3789,7 +4022,7 @@ function validateActionFlags(event2, ctx) {
3789
4022
  const isInherentFlag = (value) => Object.values(InherentFlags).includes(value);
3790
4023
  const configuredFlagIds = event2.flags.map((flag) => flag.id);
3791
4024
  const actionFlagIds = event2.actions.flatMap(
3792
- (action) => action.flags.map((flag) => flag.id)
4025
+ (action) => (action.flags ?? []).map((flag) => flag.id)
3793
4026
  );
3794
4027
  for (const actionFlagId of actionFlagIds) {
3795
4028
  const isConfigured = configuredFlagIds.includes(actionFlagId);
@@ -4469,7 +4702,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
4469
4702
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4470
4703
  z38.object({
4471
4704
  requestId: z38.string(),
4472
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
4705
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4706
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
4473
4707
  }).shape
4474
4708
  );
4475
4709
  var ReadActionInput = BaseActionInput.extend(
@@ -4581,12 +4815,53 @@ var updateActions = ActionTypes.extract([
4581
4815
  ActionType.ARCHIVE,
4582
4816
  ActionType.PRINT_CERTIFICATE,
4583
4817
  ActionType.REQUEST_CORRECTION,
4818
+ ActionType.APPROVE_CORRECTION,
4819
+ ActionType.REJECT_CORRECTION,
4584
4820
  ActionType.CUSTOM
4585
4821
  ]);
4586
4822
 
4587
4823
  // ../commons/src/events/state/flags.ts
4588
4824
  var import_lodash3 = require("lodash");
4589
4825
  var import_date_fns3 = require("date-fns");
4826
+ var INHERENT_FLAG_RULES = [
4827
+ {
4828
+ flag: InherentFlags.CORRECTION_REQUESTED,
4829
+ setOn: [ActionType.REQUEST_CORRECTION],
4830
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4831
+ },
4832
+ {
4833
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4834
+ // other status-changing action (see getStatusFromActions).
4835
+ flag: InherentFlags.INCOMPLETE,
4836
+ setOn: [ActionType.NOTIFY],
4837
+ resetOn: [
4838
+ ActionType.CREATE,
4839
+ ActionType.DECLARE,
4840
+ ActionType.REGISTER,
4841
+ ActionType.ARCHIVE
4842
+ ]
4843
+ },
4844
+ {
4845
+ flag: InherentFlags.REJECTED,
4846
+ setOn: [ActionType.REJECT],
4847
+ resetOn: [
4848
+ ActionType.NOTIFY,
4849
+ ActionType.DECLARE,
4850
+ ActionType.EDIT,
4851
+ ActionType.REGISTER
4852
+ ]
4853
+ },
4854
+ {
4855
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4856
+ setOn: [ActionType.DUPLICATE_DETECTED],
4857
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4858
+ },
4859
+ {
4860
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4861
+ setOn: [ActionType.EDIT],
4862
+ resetOnAnyOtherAction: true
4863
+ }
4864
+ ];
4590
4865
 
4591
4866
  // ../commons/src/events/defineConfig.ts
4592
4867
  var IGNORED_EVENT_TYPES = [
@@ -5332,6 +5607,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5332
5607
  id: "signature.upload.modal.title",
5333
5608
  defaultMessage: "Draw signature",
5334
5609
  description: "Title for the modal to draw signature"
5610
+ },
5611
+ // Zod applies the schema default at parse time, but this fixture bypasses
5612
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5613
+ configuration: {
5614
+ maxFileSize: 5 * 1024 * 1024
5335
5615
  }
5336
5616
  }
5337
5617
  ]
@@ -5888,6 +6168,20 @@ var tennisClubMembershipEvent = defineConfig({
5888
6168
  },
5889
6169
  review: TENNIS_CLUB_DECLARATION_REVIEW
5890
6170
  },
6171
+ {
6172
+ type: ActionType.NOTIFY,
6173
+ label: {
6174
+ defaultMessage: "Notify health worker",
6175
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6176
+ id: "event.tennis-club-membership.action.notify.label"
6177
+ },
6178
+ flags: [
6179
+ {
6180
+ id: "health-worker-notified",
6181
+ operation: "add"
6182
+ }
6183
+ ]
6184
+ },
5891
6185
  {
5892
6186
  type: ActionType.REJECT,
5893
6187
  label: {
@@ -6130,6 +6424,17 @@ var tennisClubMembershipEvent = defineConfig({
6130
6424
  }
6131
6425
  }
6132
6426
  ],
6427
+ flags: [
6428
+ {
6429
+ id: "health-worker-notified",
6430
+ requiresAction: false,
6431
+ label: {
6432
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6433
+ defaultMessage: "Health worker notified",
6434
+ description: "Label for the health-worker-notified flag"
6435
+ }
6436
+ }
6437
+ ],
6133
6438
  advancedSearch: [
6134
6439
  {
6135
6440
  title: {
@@ -7125,6 +7430,13 @@ var ACTION_FILTERS = {
7125
7430
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7126
7431
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7127
7432
  };
7433
+ var REJECTED_ACTIONS = [
7434
+ ActionType.READ,
7435
+ ActionType.NOTIFY,
7436
+ ActionType.CUSTOM,
7437
+ ActionType.EDIT,
7438
+ ActionType.ARCHIVE
7439
+ ];
7128
7440
 
7129
7441
  // ../commons/src/events/FileUtils.ts
7130
7442
  var import_lodash7 = require("lodash");