@opencrvs/toolkit 2.0.0-rc.fd34e69 → 2.0.0-rc.fd79e2e

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 (33) hide show
  1. package/dist/application-config/index.js +55 -35
  2. package/dist/cli.js +10 -4
  3. package/dist/commons/api/router.d.ts +94 -17
  4. package/dist/commons/application-config/index.d.ts +1 -0
  5. package/dist/commons/conditionals/conditionals.d.ts +348 -4
  6. package/dist/commons/conditionals/validate.d.ts +51 -2
  7. package/dist/commons/events/ActionConfig.d.ts +230 -2
  8. package/dist/commons/events/ActionDocument.d.ts +6 -0
  9. package/dist/commons/events/ActionInput.d.ts +6 -0
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +342 -0
  11. package/dist/commons/events/CountryConfigQueryInput.d.ts +42 -0
  12. package/dist/commons/events/EventDocument.d.ts +3 -0
  13. package/dist/commons/events/EventIndex.d.ts +14 -0
  14. package/dist/commons/events/FieldConfig.d.ts +378 -50
  15. package/dist/commons/events/FieldType.d.ts +1 -0
  16. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  17. package/dist/commons/events/FieldValue.d.ts +6 -0
  18. package/dist/commons/events/WorkqueueConfig.d.ts +39 -0
  19. package/dist/commons/events/field.d.ts +53 -1
  20. package/dist/commons/events/state/utils.d.ts +12 -287
  21. package/dist/commons/events/utils.d.ts +12 -1
  22. package/dist/conditionals/index.js +48 -1
  23. package/dist/events/index.js +464 -153
  24. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  25. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  26. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  27. package/dist/migrations/v2.0/index.js +10 -4
  28. package/dist/notification/index.js +334 -42
  29. package/dist/scopes/index.d.ts +4 -6
  30. package/dist/scopes/index.js +9 -3
  31. package/opencrvs-toolkit-2.0.0-rc.fd79e2e.tgz +0 -0
  32. package/package.json +1 -1
  33. package/opencrvs-toolkit-2.0.0-rc.fd34e69.tgz +0 -0
@@ -770,6 +770,11 @@ var FieldTypesToHideInReview = [
770
770
  FieldType.ALPHA_PRINT_BUTTON,
771
771
  FieldType.ALPHA_HIDDEN
772
772
  ];
773
+ var HiddenFieldTypes = [
774
+ FieldType.HTTP,
775
+ FieldType.QUERY_PARAM_READER,
776
+ FieldType.ALPHA_HIDDEN
777
+ ];
773
778
 
774
779
  // ../commons/src/events/FieldValue.ts
775
780
  var z12 = __toESM(require("zod/v4"));
@@ -888,7 +893,7 @@ var PlainDate = import_zod.z.string().date().brand("PlainDate").describe("Date i
888
893
  // ../commons/src/events/FieldValue.ts
889
894
  var TextValue = z12.string();
890
895
  var HiddenFieldValue = z12.string();
891
- var NonEmptyTextValue = TextValue.min(1);
896
+ var NonEmptyTextValue = z12.string().trim().min(1);
892
897
  var DateValue = z12.iso.date().describe("Date in the format YYYY-MM-DD");
893
898
  var AgeValue = z12.object({
894
899
  age: z12.number(),
@@ -917,6 +922,7 @@ var DateRangeFieldValue = z12.object({
917
922
  var EmailValue = z12.email();
918
923
  var CheckboxFieldValue = z12.boolean();
919
924
  var NumberFieldValue = z12.number();
925
+ var SignatureFieldValue = FileFieldValue;
920
926
  var ButtonFieldValue = z12.number();
921
927
  var VerificationStatusValue = z12.enum([
922
928
  "verified",
@@ -1215,8 +1221,9 @@ var RequestedCorrectionAction = ActionBase.extend(
1215
1221
  var ApprovedCorrectionAction = ActionBase.extend(
1216
1222
  z14.object({
1217
1223
  type: z14.literal(ActionType.APPROVE_CORRECTION),
1218
- requestId: z14.string()
1224
+ requestId: z14.string(),
1219
1225
  // TODO move into 'content' property
1226
+ content: z14.object({ immediateCorrection: z14.boolean().optional() }).optional()
1220
1227
  }).shape
1221
1228
  );
1222
1229
  var RejectedCorrectionAction = ActionBase.extend(
@@ -1476,7 +1483,8 @@ var Range = import_v4.z.object({
1476
1483
  });
1477
1484
  var ContainsFlags = import_v4.z.object({
1478
1485
  anyOf: import_v4.z.array(Flag).optional(),
1479
- noneOf: import_v4.z.array(Flag).optional()
1486
+ noneOf: import_v4.z.array(Flag).optional(),
1487
+ allOf: import_v4.z.array(Flag).optional()
1480
1488
  }).meta({
1481
1489
  id: "ContainsFlags"
1482
1490
  });
@@ -1665,8 +1673,18 @@ var FieldReference = import_v43.default.object({
1665
1673
  $$field: FieldId.describe("Id of the field to reference"),
1666
1674
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1667
1675
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1676
+ ),
1677
+ $$code: import_v43.default.string().optional().describe(
1678
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1679
+ )
1680
+ }).describe(
1681
+ "Reference to a field value, with an optional client-side computation applied."
1682
+ );
1683
+ var ComputedDefaultValue = import_v43.default.object({
1684
+ $$code: import_v43.default.string().describe(
1685
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1668
1686
  )
1669
- }).describe("Reference to a field by its ID");
1687
+ }).describe("A context-only computation used as a field default value.");
1670
1688
  var ValidationConfig = import_v43.default.object({
1671
1689
  validator: Conditional.describe(
1672
1690
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1707,7 +1725,7 @@ var BaseField = import_v43.default.object({
1707
1725
  "Indicates whether the field can be modified during record correction."
1708
1726
  ),
1709
1727
  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."
1728
+ "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
1729
  ),
1712
1730
  analytics: import_v43.default.boolean().default(false).optional().describe(
1713
1731
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1721,7 +1739,7 @@ var Divider = BaseField.extend({
1721
1739
  });
1722
1740
  var TextField = BaseField.extend({
1723
1741
  type: import_v43.default.literal(FieldType.TEXT),
1724
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1742
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1725
1743
  configuration: import_v43.default.object({
1726
1744
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1727
1745
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1734,10 +1752,11 @@ var TextField = BaseField.extend({
1734
1752
  });
1735
1753
  var NumberField = BaseField.extend({
1736
1754
  type: import_v43.default.literal(FieldType.NUMBER),
1737
- defaultValue: NumberFieldValue.optional(),
1755
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1738
1756
  configuration: import_v43.default.object({
1739
1757
  min: import_v43.default.number().optional().describe("Minimum value"),
1740
1758
  max: import_v43.default.number().optional().describe("Maximum value"),
1759
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
1741
1760
  prefix: TranslationConfig.optional(),
1742
1761
  postfix: TranslationConfig.optional()
1743
1762
  }).optional()
@@ -1747,7 +1766,7 @@ var NumberField = BaseField.extend({
1747
1766
  });
1748
1767
  var TextAreaField = BaseField.extend({
1749
1768
  type: import_v43.default.literal(FieldType.TEXTAREA),
1750
- defaultValue: NonEmptyTextValue.optional(),
1769
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1751
1770
  configuration: import_v43.default.object({
1752
1771
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1753
1772
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1781,7 +1800,7 @@ var SignatureField = BaseField.extend({
1781
1800
  signaturePromptLabel: TranslationConfig.describe(
1782
1801
  "Title of the signature modal"
1783
1802
  ),
1784
- defaultValue: FieldValue.optional(),
1803
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1785
1804
  configuration: import_v43.default.object({
1786
1805
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1787
1806
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1797,14 +1816,14 @@ var EmailField = BaseField.extend({
1797
1816
  configuration: import_v43.default.object({
1798
1817
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1799
1818
  }).default({ maxLength: 255 }).optional(),
1800
- defaultValue: NonEmptyTextValue.optional()
1819
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1801
1820
  }).meta({
1802
1821
  description: "An email input field",
1803
1822
  id: "EmailField"
1804
1823
  });
1805
1824
  var DateField = BaseField.extend({
1806
1825
  type: import_v43.default.literal(FieldType.DATE),
1807
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1826
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1808
1827
  configuration: import_v43.default.object({
1809
1828
  notice: TranslationConfig.describe(
1810
1829
  "Text to display above the date input"
@@ -1816,7 +1835,7 @@ var DateField = BaseField.extend({
1816
1835
  });
1817
1836
  var AgeField = BaseField.extend({
1818
1837
  type: import_v43.default.literal(FieldType.AGE),
1819
- defaultValue: NumberFieldValue.optional(),
1838
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1820
1839
  configuration: import_v43.default.object({
1821
1840
  asOfDate: FieldReference,
1822
1841
  prefix: TranslationConfig.optional(),
@@ -1828,7 +1847,7 @@ var AgeField = BaseField.extend({
1828
1847
  });
1829
1848
  var TimeField = BaseField.extend({
1830
1849
  type: import_v43.default.literal(FieldType.TIME),
1831
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1850
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1832
1851
  configuration: import_v43.default.object({
1833
1852
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1834
1853
  notice: TranslationConfig.describe(
@@ -1841,7 +1860,7 @@ var TimeField = BaseField.extend({
1841
1860
  });
1842
1861
  var DateRangeField = BaseField.extend({
1843
1862
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1844
- defaultValue: DateRangeFieldValue.optional(),
1863
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1845
1864
  configuration: import_v43.default.object({
1846
1865
  notice: TranslationConfig.describe(
1847
1866
  "Text to display above the date input"
@@ -1920,7 +1939,7 @@ var PageHeader = BaseField.extend({
1920
1939
  });
1921
1940
  var File = BaseField.extend({
1922
1941
  type: import_v43.default.literal(FieldType.FILE),
1923
- defaultValue: FileFieldValue.optional(),
1942
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1924
1943
  configuration: import_v43.default.object({
1925
1944
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1926
1945
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1947,7 +1966,7 @@ var SelectOption = import_v43.default.object({
1947
1966
  });
1948
1967
  var NumberWithUnitField = BaseField.extend({
1949
1968
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1950
- defaultValue: NumberWithUnitFieldValue.optional(),
1969
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1951
1970
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1952
1971
  configuration: import_v43.default.object({
1953
1972
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1962,7 +1981,7 @@ var NumberWithUnitField = BaseField.extend({
1962
1981
  });
1963
1982
  var RadioGroup = BaseField.extend({
1964
1983
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1965
- defaultValue: TextValue.optional(),
1984
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1966
1985
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1967
1986
  configuration: import_v43.default.object({
1968
1987
  styles: import_v43.default.object({
@@ -1987,7 +2006,7 @@ var BulletList = BaseField.extend({
1987
2006
  });
1988
2007
  var Select = BaseField.extend({
1989
2008
  type: import_v43.default.literal(FieldType.SELECT),
1990
- defaultValue: TextValue.optional(),
2009
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1991
2010
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1992
2011
  noOptionsMessage: TranslationConfig.optional().describe(
1993
2012
  `
@@ -2009,7 +2028,7 @@ var SelectDateRangeOption = import_v43.default.object({
2009
2028
  });
2010
2029
  var SelectDateRangeField = BaseField.extend({
2011
2030
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2012
- defaultValue: SelectDateRangeValue.optional(),
2031
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2013
2032
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2014
2033
  }).meta({
2015
2034
  description: "A date range selection field",
@@ -2026,7 +2045,7 @@ var NameField = BaseField.extend({
2026
2045
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2027
2046
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2028
2047
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2029
- }).optional(),
2048
+ }).or(ComputedDefaultValue).optional(),
2030
2049
  configuration: import_v43.default.object({
2031
2050
  name: NameConfig.default({
2032
2051
  firstname: { required: true },
@@ -2050,14 +2069,14 @@ var NameField = BaseField.extend({
2050
2069
  id: "NameField"
2051
2070
  });
2052
2071
  var PhoneField = BaseField.extend({
2053
- defaultValue: NonEmptyTextValue.optional(),
2072
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2054
2073
  type: import_v43.default.literal(FieldType.PHONE)
2055
2074
  }).meta({
2056
2075
  description: "A field for entering a phone number",
2057
2076
  id: "PhoneField"
2058
2077
  });
2059
2078
  var IdField = BaseField.extend({
2060
- defaultValue: NonEmptyTextValue.optional(),
2079
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2061
2080
  type: import_v43.default.literal(FieldType.ID)
2062
2081
  }).meta({
2063
2082
  description: "A field for entering an ID",
@@ -2065,14 +2084,14 @@ var IdField = BaseField.extend({
2065
2084
  });
2066
2085
  var Checkbox = BaseField.extend({
2067
2086
  type: import_v43.default.literal(FieldType.CHECKBOX),
2068
- defaultValue: CheckboxFieldValue.default(false)
2087
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2069
2088
  }).meta({
2070
2089
  description: "A boolean checkbox field",
2071
2090
  id: "Checkbox"
2072
2091
  });
2073
2092
  var Country = BaseField.extend({
2074
2093
  type: import_v43.default.literal(FieldType.COUNTRY),
2075
- defaultValue: NonEmptyTextValue.optional(),
2094
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2076
2095
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2077
2096
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2078
2097
  )
@@ -2090,7 +2109,7 @@ var AdministrativeAreas = import_v43.default.enum([
2090
2109
  ]);
2091
2110
  var AdministrativeAreaField = BaseField.extend({
2092
2111
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2093
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2112
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2094
2113
  configuration: import_v43.default.object({
2095
2114
  partOf: FieldReference.optional().describe("Parent location"),
2096
2115
  type: AdministrativeAreas,
@@ -2102,7 +2121,7 @@ var AdministrativeAreaField = BaseField.extend({
2102
2121
  });
2103
2122
  var LocationInput = BaseField.extend({
2104
2123
  type: import_v43.default.literal(FieldType.LOCATION),
2105
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2124
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2106
2125
  configuration: import_v43.default.object({
2107
2126
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2108
2127
  allowedLocations: AllowedLocations
@@ -2114,7 +2133,7 @@ var LocationInput = BaseField.extend({
2114
2133
  var FileUploadWithOptions = BaseField.extend({
2115
2134
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2116
2135
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2117
- defaultValue: FileFieldWithOptionValue.optional(),
2136
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2118
2137
  configuration: import_v43.default.object({
2119
2138
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2120
2139
  maxImageSize: import_v43.default.object({
@@ -2130,12 +2149,12 @@ var FileUploadWithOptions = BaseField.extend({
2130
2149
  });
2131
2150
  var Facility = BaseField.extend({
2132
2151
  type: import_v43.default.literal(FieldType.FACILITY),
2133
- defaultValue: NonEmptyTextValue.optional(),
2152
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2134
2153
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2135
2154
  }).describe("Input field for a facility");
2136
2155
  var Office = BaseField.extend({
2137
2156
  type: import_v43.default.literal(FieldType.OFFICE),
2138
- defaultValue: NonEmptyTextValue.optional(),
2157
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2139
2158
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2140
2159
  }).describe("Input field for an office");
2141
2160
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2171,7 +2190,7 @@ var Address = BaseField.extend({
2171
2190
  ).optional(),
2172
2191
  allowedLocations: AllowedLocations
2173
2192
  }).optional(),
2174
- defaultValue: DefaultAddressFieldValue.optional()
2193
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2175
2194
  }).meta({
2176
2195
  description: "Address input field \u2013 a combination of location and text fields",
2177
2196
  id: "Address"
@@ -2218,7 +2237,7 @@ var ButtonConfiguration = import_v43.default.object({
2218
2237
  });
2219
2238
  var ButtonField = BaseField.extend({
2220
2239
  type: import_v43.default.literal(FieldType.BUTTON),
2221
- defaultValue: ButtonFieldValue.optional(),
2240
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2222
2241
  configuration: ButtonConfiguration
2223
2242
  }).meta({
2224
2243
  description: "A generic button that can be used to trigger an action",
@@ -2246,7 +2265,7 @@ var AlphaPrintButton = BaseField.extend({
2246
2265
  });
2247
2266
  var HttpField = BaseField.extend({
2248
2267
  type: import_v43.default.literal(FieldType.HTTP),
2249
- defaultValue: HttpFieldValue.optional(),
2268
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2250
2269
  configuration: import_v43.default.object({
2251
2270
  trigger: FieldReference.optional().describe(
2252
2271
  "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 +2351,7 @@ var LinkButtonField = BaseField.extend({
2332
2351
  });
2333
2352
  var VerificationStatus = BaseField.extend({
2334
2353
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2335
- defaultValue: VerificationStatusValue.optional(),
2354
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2336
2355
  configuration: import_v43.default.object({
2337
2356
  status: TranslationConfig.describe("Text to display on the status pill."),
2338
2357
  description: TranslationConfig.describe(
@@ -2354,7 +2373,7 @@ var QueryParamReaderField = BaseField.extend({
2354
2373
  });
2355
2374
  var QrReaderField = BaseField.extend({
2356
2375
  type: import_v43.default.literal(FieldType.QR_READER),
2357
- defaultValue: QrReaderFieldValue.optional(),
2376
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2358
2377
  configuration: import_v43.default.object({
2359
2378
  validator: import_v43.default.any().meta({
2360
2379
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2367,7 +2386,7 @@ var QrReaderField = BaseField.extend({
2367
2386
  });
2368
2387
  var IdReaderField = BaseField.extend({
2369
2388
  type: import_v43.default.literal(FieldType.ID_READER),
2370
- defaultValue: IdReaderFieldValue.optional(),
2389
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2371
2390
  methods: import_v43.default.array(
2372
2391
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2373
2392
  )
@@ -2661,6 +2680,51 @@ var ReadActionConfig = ActionConfigBase.extend(
2661
2680
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2662
2681
  }).shape
2663
2682
  );
2683
+ var NotifyConfig = ActionConfigBase.extend(
2684
+ z24.object({
2685
+ type: z24.literal(ActionType.NOTIFY)
2686
+ }).shape
2687
+ );
2688
+ var DuplicateDetectedConfig = ActionConfigBase.extend(
2689
+ z24.object({
2690
+ type: z24.literal(ActionType.DUPLICATE_DETECTED),
2691
+ label: z24.never().optional().describe(
2692
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no label."
2693
+ ),
2694
+ supportingCopy: z24.never().optional(),
2695
+ icon: z24.never().optional().describe(
2696
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it has no icon."
2697
+ ),
2698
+ conditionals: z24.never().optional().describe(
2699
+ "DUPLICATE_DETECTED is system-generated and never shown as a button, so it cannot be disabled or hidden with conditionals."
2700
+ )
2701
+ }).shape
2702
+ );
2703
+ var MarkAsDuplicateConfig = ActionConfigBase.extend(
2704
+ z24.object({
2705
+ type: z24.literal(ActionType.MARK_AS_DUPLICATE)
2706
+ }).shape
2707
+ );
2708
+ var MarkAsNotDuplicateConfig = ActionConfigBase.extend(
2709
+ z24.object({
2710
+ type: z24.literal(ActionType.MARK_AS_NOT_DUPLICATE)
2711
+ }).shape
2712
+ );
2713
+ var AssignConfig = ActionConfigBase.extend(
2714
+ z24.object({
2715
+ type: z24.literal(ActionType.ASSIGN)
2716
+ }).shape
2717
+ );
2718
+ var UnassignConfig = ActionConfigBase.extend(
2719
+ z24.object({
2720
+ type: z24.literal(ActionType.UNASSIGN)
2721
+ }).shape
2722
+ );
2723
+ var DeleteConfig = ActionConfigBase.extend(
2724
+ z24.object({
2725
+ type: z24.literal(ActionType.DELETE)
2726
+ }).shape
2727
+ );
2664
2728
  var DeclareConfig = DeclarationActionBase.extend(
2665
2729
  z24.object({
2666
2730
  type: z24.literal(ActionType.DECLARE),
@@ -2723,7 +2787,17 @@ var RequestCorrectionConfig = ActionConfigBase.extend(
2723
2787
  correctionForm: ActionFormConfig
2724
2788
  }).shape
2725
2789
  );
2726
- var CustomActionConfig = ActionConfigBase.merge(
2790
+ var ApproveCorrectionConfig = ActionConfigBase.extend(
2791
+ z24.object({
2792
+ type: z24.literal(ActionType.APPROVE_CORRECTION)
2793
+ }).shape
2794
+ );
2795
+ var RejectCorrectionConfig = ActionConfigBase.extend(
2796
+ z24.object({
2797
+ type: z24.literal(ActionType.REJECT_CORRECTION)
2798
+ }).shape
2799
+ );
2800
+ var CustomActionConfig = ActionConfigBase.extend(
2727
2801
  z24.object({
2728
2802
  type: z24.literal(ActionType.CUSTOM),
2729
2803
  customActionType: z24.string().describe("Type identifier of the custom action."),
@@ -2734,7 +2808,7 @@ var CustomActionConfig = ActionConfigBase.merge(
2734
2808
  auditHistoryLabel: TranslationConfig.describe(
2735
2809
  'The label to show in audit history for this action. For example "Approved".'
2736
2810
  )
2737
- })
2811
+ }).shape
2738
2812
  );
2739
2813
  var ActionConfig = z24.discriminatedUnion("type", [
2740
2814
  /*
@@ -2745,9 +2819,37 @@ var ActionConfig = z24.discriminatedUnion("type", [
2745
2819
  id: "ReadActionConfig",
2746
2820
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2747
2821
  }),
2822
+ AssignConfig.meta({
2823
+ id: "AssignActionConfig",
2824
+ description: "Configuration for assigning a record to the current user."
2825
+ }),
2826
+ UnassignConfig.meta({
2827
+ id: "UnassignActionConfig",
2828
+ description: "Configuration for unassigning a record from its current assignee."
2829
+ }),
2830
+ DeleteConfig.meta({
2831
+ id: "DeleteActionConfig",
2832
+ description: "Configuration for deleting a draft record."
2833
+ }),
2834
+ NotifyConfig.meta({
2835
+ id: "NotifyActionConfig",
2836
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
2837
+ }),
2748
2838
  DeclareConfig.meta({
2749
2839
  id: "DeclareActionConfig",
2750
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
2840
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2841
+ }),
2842
+ DuplicateDetectedConfig.meta({
2843
+ id: "DuplicateDetectedActionConfig",
2844
+ 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."
2845
+ }),
2846
+ MarkAsDuplicateConfig.meta({
2847
+ id: "MarkAsDuplicateActionConfig",
2848
+ description: "Configuration for marking a record as a duplicate."
2849
+ }),
2850
+ MarkAsNotDuplicateConfig.meta({
2851
+ id: "MarkAsNotDuplicateActionConfig",
2852
+ description: "Configuration for marking a record as not a duplicate, after it was previously flagged as one."
2751
2853
  }),
2752
2854
  RejectConfig.meta({
2753
2855
  id: "RejectActionConfig",
@@ -2765,6 +2867,14 @@ var ActionConfig = z24.discriminatedUnion("type", [
2765
2867
  id: "RequestCorrectionActionConfig",
2766
2868
  description: "Configuration for requesting a correction on a registered record."
2767
2869
  }),
2870
+ ApproveCorrectionConfig.meta({
2871
+ id: "ApproveCorrectionActionConfig",
2872
+ description: "Configuration for approving a requested correction."
2873
+ }),
2874
+ RejectCorrectionConfig.meta({
2875
+ id: "RejectCorrectionActionConfig",
2876
+ description: "Configuration for rejecting a requested correction."
2877
+ }),
2768
2878
  EditActionConfig.meta({
2769
2879
  id: "EditActionConfig",
2770
2880
  description: "Configuration for editing a record before registration."
@@ -2926,6 +3036,9 @@ var BaseField3 = z28.object({
2926
3036
  ),
2927
3037
  validations: z28.array(ValidationConfig).optional().describe(
2928
3038
  `Option for overriding the field validations specifically for advanced search form.`
3039
+ ),
3040
+ allowedLocations: JurisdictionReference.optional().describe(
3041
+ `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
3042
  )
2930
3043
  });
2931
3044
  var SearchQueryParams = z28.object({
@@ -3032,7 +3145,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3032
3145
  }
3033
3146
  return current;
3034
3147
  }
3148
+ function todayISO() {
3149
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3150
+ }
3151
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3152
+ function compileClientFunction(code) {
3153
+ let fn = compiledFunctionCache.get(code);
3154
+ if (!fn) {
3155
+ fn = new Function(`return (${code})`)();
3156
+ compiledFunctionCache.set(code, fn);
3157
+ }
3158
+ return fn;
3159
+ }
3035
3160
  (0, import_ajv_formats.default)(ajv);
3161
+ function buildClientFunctionContext(input) {
3162
+ return {
3163
+ $form: input.form,
3164
+ $now: todayISO(),
3165
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
3166
+ $online: isOnline(),
3167
+ $user: input.validatorContext?.user,
3168
+ $event: input.validatorContext?.event,
3169
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3170
+ user: input.systemVariables?.user,
3171
+ $window: input.systemVariables?.$window,
3172
+ locations: input.locations,
3173
+ adminLevelIds: input.adminLevelIds
3174
+ };
3175
+ }
3176
+ function runClientFunction(code, data, context) {
3177
+ return compileClientFunction(code)(data, context);
3178
+ }
3036
3179
  ajv.addKeyword({
3037
3180
  keyword: "daysFromDate",
3038
3181
  type: "string",
@@ -3077,12 +3220,35 @@ ajv.addKeyword({
3077
3220
  $data: true,
3078
3221
  errors: true,
3079
3222
  // @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) {
3223
+ validate(_schema, data, _2, dataContext) {
3081
3224
  const locationIdInput = data;
3082
3225
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3083
3226
  return locations.some((location) => location.id === locationIdInput);
3084
3227
  }
3085
3228
  });
3229
+ ajv.addKeyword({
3230
+ keyword: "customClientValidator",
3231
+ schemaType: "object",
3232
+ errors: true,
3233
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3234
+ // `validate()` callers build root data via `buildClientFunctionContext`,
3235
+ // so the cast holds.
3236
+ validate(schema, data, _2, dataContext) {
3237
+ return Boolean(
3238
+ runClientFunction(
3239
+ schema.code,
3240
+ data,
3241
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3242
+ )
3243
+ );
3244
+ }
3245
+ });
3246
+ function isOnline() {
3247
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3248
+ return navigator.onLine;
3249
+ }
3250
+ return true;
3251
+ }
3086
3252
 
3087
3253
  // ../commons/src/utils.ts
3088
3254
  var z32 = __toESM(require("zod/v4"));
@@ -3125,7 +3291,7 @@ var getActionAnnotationFields = (actionConfig) => {
3125
3291
  if (actionConfig.type === ActionType.CUSTOM) {
3126
3292
  return actionConfig.form;
3127
3293
  }
3128
- if ("review" in actionConfig) {
3294
+ if ("review" in actionConfig && actionConfig.review != null) {
3129
3295
  return actionConfig.review.fields;
3130
3296
  }
3131
3297
  return [];
@@ -3701,7 +3867,54 @@ function createFieldConditionals(fieldId) {
3701
3867
  }
3702
3868
  },
3703
3869
  required: [fieldId]
3704
- })
3870
+ }),
3871
+ /**
3872
+ * Custom client-side validator. The provided function is serialised and executed
3873
+ * just-in-time on the client only. External references (e.g. lodash) are not
3874
+ * available inside the function body — all logic must be self-contained.
3875
+ *
3876
+ * @example
3877
+ * field('nid').customClientValidator((value) => {
3878
+ * // LUHN check — all logic must be inline
3879
+ * const digits = String(value).split('').map(Number)
3880
+ * // ...
3881
+ * return isValid
3882
+ * })
3883
+ */
3884
+ customClientValidator(validationFn) {
3885
+ const code = validationFn.toString();
3886
+ return defineFormConditional({
3887
+ type: "object",
3888
+ properties: wrapToPath(
3889
+ { [fieldId]: { customClientValidator: { code } } },
3890
+ this.$$subfield
3891
+ ),
3892
+ required: [fieldId]
3893
+ });
3894
+ },
3895
+ /**
3896
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3897
+ * that can be used as the `value` property or a DATA component entry.
3898
+ * The function receives the referenced field's value as the first argument and
3899
+ * the full form context as the second; its return value replaces the field reference.
3900
+ * The function is serialised and executed just-in-time on the client only.
3901
+ * External references (e.g. lodash) are not available inside the function body.
3902
+ *
3903
+ * For computing a default value without referencing a specific field, use
3904
+ * `evaluate(fn)` in the `defaultValue` property instead.
3905
+ *
3906
+ * @example
3907
+ * field('a').customClientEvaluation((aValue, ctx) =>
3908
+ * Number(aValue) + Number(ctx.$form.b)
3909
+ * )
3910
+ */
3911
+ customClientEvaluation(computationFn) {
3912
+ return {
3913
+ $$code: computationFn.toString(),
3914
+ $$field: fieldId,
3915
+ $$subfield: this.$$subfield
3916
+ };
3917
+ }
3705
3918
  };
3706
3919
  }
3707
3920
 
@@ -4469,7 +4682,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
4469
4682
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4470
4683
  z38.object({
4471
4684
  requestId: z38.string(),
4472
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
4685
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4686
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
4473
4687
  }).shape
4474
4688
  );
4475
4689
  var ReadActionInput = BaseActionInput.extend(
@@ -4581,12 +4795,53 @@ var updateActions = ActionTypes.extract([
4581
4795
  ActionType.ARCHIVE,
4582
4796
  ActionType.PRINT_CERTIFICATE,
4583
4797
  ActionType.REQUEST_CORRECTION,
4798
+ ActionType.APPROVE_CORRECTION,
4799
+ ActionType.REJECT_CORRECTION,
4584
4800
  ActionType.CUSTOM
4585
4801
  ]);
4586
4802
 
4587
4803
  // ../commons/src/events/state/flags.ts
4588
4804
  var import_lodash3 = require("lodash");
4589
4805
  var import_date_fns3 = require("date-fns");
4806
+ var INHERENT_FLAG_RULES = [
4807
+ {
4808
+ flag: InherentFlags.CORRECTION_REQUESTED,
4809
+ setOn: [ActionType.REQUEST_CORRECTION],
4810
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4811
+ },
4812
+ {
4813
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4814
+ // other status-changing action (see getStatusFromActions).
4815
+ flag: InherentFlags.INCOMPLETE,
4816
+ setOn: [ActionType.NOTIFY],
4817
+ resetOn: [
4818
+ ActionType.CREATE,
4819
+ ActionType.DECLARE,
4820
+ ActionType.REGISTER,
4821
+ ActionType.ARCHIVE
4822
+ ]
4823
+ },
4824
+ {
4825
+ flag: InherentFlags.REJECTED,
4826
+ setOn: [ActionType.REJECT],
4827
+ resetOn: [
4828
+ ActionType.NOTIFY,
4829
+ ActionType.DECLARE,
4830
+ ActionType.EDIT,
4831
+ ActionType.REGISTER
4832
+ ]
4833
+ },
4834
+ {
4835
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4836
+ setOn: [ActionType.DUPLICATE_DETECTED],
4837
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4838
+ },
4839
+ {
4840
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4841
+ setOn: [ActionType.EDIT],
4842
+ resetOnAnyOtherAction: true
4843
+ }
4844
+ ];
4590
4845
 
4591
4846
  // ../commons/src/events/defineConfig.ts
4592
4847
  var IGNORED_EVENT_TYPES = [
@@ -5332,6 +5587,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5332
5587
  id: "signature.upload.modal.title",
5333
5588
  defaultMessage: "Draw signature",
5334
5589
  description: "Title for the modal to draw signature"
5590
+ },
5591
+ // Zod applies the schema default at parse time, but this fixture bypasses
5592
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5593
+ configuration: {
5594
+ maxFileSize: 5 * 1024 * 1024
5335
5595
  }
5336
5596
  }
5337
5597
  ]
@@ -5888,6 +6148,20 @@ var tennisClubMembershipEvent = defineConfig({
5888
6148
  },
5889
6149
  review: TENNIS_CLUB_DECLARATION_REVIEW
5890
6150
  },
6151
+ {
6152
+ type: ActionType.NOTIFY,
6153
+ label: {
6154
+ defaultMessage: "Notify health worker",
6155
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6156
+ id: "event.tennis-club-membership.action.notify.label"
6157
+ },
6158
+ flags: [
6159
+ {
6160
+ id: "health-worker-notified",
6161
+ operation: "add"
6162
+ }
6163
+ ]
6164
+ },
5891
6165
  {
5892
6166
  type: ActionType.REJECT,
5893
6167
  label: {
@@ -6130,6 +6404,17 @@ var tennisClubMembershipEvent = defineConfig({
6130
6404
  }
6131
6405
  }
6132
6406
  ],
6407
+ flags: [
6408
+ {
6409
+ id: "health-worker-notified",
6410
+ requiresAction: false,
6411
+ label: {
6412
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6413
+ defaultMessage: "Health worker notified",
6414
+ description: "Label for the health-worker-notified flag"
6415
+ }
6416
+ }
6417
+ ],
6133
6418
  advancedSearch: [
6134
6419
  {
6135
6420
  title: {
@@ -7125,6 +7410,13 @@ var ACTION_FILTERS = {
7125
7410
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7126
7411
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7127
7412
  };
7413
+ var REJECTED_ACTIONS = [
7414
+ ActionType.READ,
7415
+ ActionType.NOTIFY,
7416
+ ActionType.CUSTOM,
7417
+ ActionType.EDIT,
7418
+ ActionType.ARCHIVE
7419
+ ];
7128
7420
 
7129
7421
  // ../commons/src/events/FileUtils.ts
7130
7422
  var import_lodash7 = require("lodash");