@opencrvs/toolkit 2.0.0-rc.57eca4e → 2.0.0-rc.57fff6f

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 (37) hide show
  1. package/dist/application-config/index.js +65 -36
  2. package/dist/cli.js +17 -6
  3. package/dist/commons/api/router.d.ts +100 -17
  4. package/dist/commons/application-config/index.d.ts +1 -0
  5. package/dist/commons/conditionals/conditionals.d.ts +351 -7
  6. package/dist/commons/conditionals/validate.d.ts +51 -2
  7. package/dist/commons/events/ActionConfig.d.ts +28 -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 +354 -0
  11. package/dist/commons/events/EventConfig.d.ts +2 -0
  12. package/dist/commons/events/EventDocument.d.ts +3 -0
  13. package/dist/commons/events/EventIndex.d.ts +11 -0
  14. package/dist/commons/events/EventMetadata.d.ts +26 -0
  15. package/dist/commons/events/FieldConfig.d.ts +388 -50
  16. package/dist/commons/events/FieldType.d.ts +1 -0
  17. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  18. package/dist/commons/events/FieldValue.d.ts +6 -0
  19. package/dist/commons/events/field.d.ts +53 -1
  20. package/dist/commons/events/index.d.ts +1 -0
  21. package/dist/commons/events/locations.d.ts +1 -0
  22. package/dist/commons/events/state/flags.d.ts +1 -0
  23. package/dist/commons/events/state/index.d.ts +8 -0
  24. package/dist/commons/events/state/utils.d.ts +21 -287
  25. package/dist/commons/events/utils.d.ts +12 -1
  26. package/dist/conditionals/index.js +55 -3
  27. package/dist/events/index.js +417 -149
  28. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  29. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  30. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  31. package/dist/migrations/v2.0/index.js +17 -6
  32. package/dist/notification/index.js +260 -41
  33. package/dist/scopes/index.d.ts +92 -6
  34. package/dist/scopes/index.js +16 -5
  35. package/opencrvs-toolkit-2.0.0-rc.57fff6f.tgz +0 -0
  36. package/package.json +1 -1
  37. package/opencrvs-toolkit-2.0.0-rc.57eca4e.tgz +0 -0
@@ -119,6 +119,8 @@ var scopeOptionsPlaceEvent = z2.object({
119
119
  placeOfEvent: JurisdictionFilter.optional()
120
120
  }).describe("Options applicable to all record scopes.");
121
121
  var scopeOptionsDeclared = 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");
@@ -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(
@@ -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",
@@ -1665,8 +1682,18 @@ var FieldReference = import_v43.default.object({
1665
1682
  $$field: FieldId.describe("Id of the field to reference"),
1666
1683
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1667
1684
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1685
+ ),
1686
+ $$code: import_v43.default.string().optional().describe(
1687
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1668
1688
  )
1669
- }).describe("Reference to a field by its ID");
1689
+ }).describe(
1690
+ "Reference to a field value, with an optional client-side computation applied."
1691
+ );
1692
+ var ComputedDefaultValue = import_v43.default.object({
1693
+ $$code: import_v43.default.string().describe(
1694
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1695
+ )
1696
+ }).describe("A context-only computation used as a field default value.");
1670
1697
  var ValidationConfig = import_v43.default.object({
1671
1698
  validator: Conditional.describe(
1672
1699
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1707,7 +1734,7 @@ var BaseField = import_v43.default.object({
1707
1734
  "Indicates whether the field can be modified during record correction."
1708
1735
  ),
1709
1736
  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."
1737
+ "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
1738
  ),
1712
1739
  analytics: import_v43.default.boolean().default(false).optional().describe(
1713
1740
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1721,7 +1748,7 @@ var Divider = BaseField.extend({
1721
1748
  });
1722
1749
  var TextField = BaseField.extend({
1723
1750
  type: import_v43.default.literal(FieldType.TEXT),
1724
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1751
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1725
1752
  configuration: import_v43.default.object({
1726
1753
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1727
1754
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1734,10 +1761,11 @@ var TextField = BaseField.extend({
1734
1761
  });
1735
1762
  var NumberField = BaseField.extend({
1736
1763
  type: import_v43.default.literal(FieldType.NUMBER),
1737
- defaultValue: NumberFieldValue.optional(),
1764
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1738
1765
  configuration: import_v43.default.object({
1739
1766
  min: import_v43.default.number().optional().describe("Minimum value"),
1740
1767
  max: import_v43.default.number().optional().describe("Maximum value"),
1768
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
1741
1769
  prefix: TranslationConfig.optional(),
1742
1770
  postfix: TranslationConfig.optional()
1743
1771
  }).optional()
@@ -1747,7 +1775,7 @@ var NumberField = BaseField.extend({
1747
1775
  });
1748
1776
  var TextAreaField = BaseField.extend({
1749
1777
  type: import_v43.default.literal(FieldType.TEXTAREA),
1750
- defaultValue: NonEmptyTextValue.optional(),
1778
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1751
1779
  configuration: import_v43.default.object({
1752
1780
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1753
1781
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1781,7 +1809,7 @@ var SignatureField = BaseField.extend({
1781
1809
  signaturePromptLabel: TranslationConfig.describe(
1782
1810
  "Title of the signature modal"
1783
1811
  ),
1784
- defaultValue: FieldValue.optional(),
1812
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1785
1813
  configuration: import_v43.default.object({
1786
1814
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1787
1815
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1797,14 +1825,14 @@ var EmailField = BaseField.extend({
1797
1825
  configuration: import_v43.default.object({
1798
1826
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1799
1827
  }).default({ maxLength: 255 }).optional(),
1800
- defaultValue: NonEmptyTextValue.optional()
1828
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1801
1829
  }).meta({
1802
1830
  description: "An email input field",
1803
1831
  id: "EmailField"
1804
1832
  });
1805
1833
  var DateField = BaseField.extend({
1806
1834
  type: import_v43.default.literal(FieldType.DATE),
1807
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1835
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1808
1836
  configuration: import_v43.default.object({
1809
1837
  notice: TranslationConfig.describe(
1810
1838
  "Text to display above the date input"
@@ -1816,7 +1844,7 @@ var DateField = BaseField.extend({
1816
1844
  });
1817
1845
  var AgeField = BaseField.extend({
1818
1846
  type: import_v43.default.literal(FieldType.AGE),
1819
- defaultValue: NumberFieldValue.optional(),
1847
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1820
1848
  configuration: import_v43.default.object({
1821
1849
  asOfDate: FieldReference,
1822
1850
  prefix: TranslationConfig.optional(),
@@ -1828,7 +1856,7 @@ var AgeField = BaseField.extend({
1828
1856
  });
1829
1857
  var TimeField = BaseField.extend({
1830
1858
  type: import_v43.default.literal(FieldType.TIME),
1831
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1859
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1832
1860
  configuration: import_v43.default.object({
1833
1861
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1834
1862
  notice: TranslationConfig.describe(
@@ -1841,7 +1869,7 @@ var TimeField = BaseField.extend({
1841
1869
  });
1842
1870
  var DateRangeField = BaseField.extend({
1843
1871
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1844
- defaultValue: DateRangeFieldValue.optional(),
1872
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1845
1873
  configuration: import_v43.default.object({
1846
1874
  notice: TranslationConfig.describe(
1847
1875
  "Text to display above the date input"
@@ -1920,7 +1948,7 @@ var PageHeader = BaseField.extend({
1920
1948
  });
1921
1949
  var File = BaseField.extend({
1922
1950
  type: import_v43.default.literal(FieldType.FILE),
1923
- defaultValue: FileFieldValue.optional(),
1951
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1924
1952
  configuration: import_v43.default.object({
1925
1953
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1926
1954
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1947,7 +1975,7 @@ var SelectOption = import_v43.default.object({
1947
1975
  });
1948
1976
  var NumberWithUnitField = BaseField.extend({
1949
1977
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1950
- defaultValue: NumberWithUnitFieldValue.optional(),
1978
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1951
1979
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1952
1980
  configuration: import_v43.default.object({
1953
1981
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1962,7 +1990,7 @@ var NumberWithUnitField = BaseField.extend({
1962
1990
  });
1963
1991
  var RadioGroup = BaseField.extend({
1964
1992
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1965
- defaultValue: TextValue.optional(),
1993
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1966
1994
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1967
1995
  configuration: import_v43.default.object({
1968
1996
  styles: import_v43.default.object({
@@ -1987,7 +2015,7 @@ var BulletList = BaseField.extend({
1987
2015
  });
1988
2016
  var Select = BaseField.extend({
1989
2017
  type: import_v43.default.literal(FieldType.SELECT),
1990
- defaultValue: TextValue.optional(),
2018
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1991
2019
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1992
2020
  noOptionsMessage: TranslationConfig.optional().describe(
1993
2021
  `
@@ -2009,7 +2037,7 @@ var SelectDateRangeOption = import_v43.default.object({
2009
2037
  });
2010
2038
  var SelectDateRangeField = BaseField.extend({
2011
2039
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2012
- defaultValue: SelectDateRangeValue.optional(),
2040
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2013
2041
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2014
2042
  }).meta({
2015
2043
  description: "A date range selection field",
@@ -2026,7 +2054,7 @@ var NameField = BaseField.extend({
2026
2054
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2027
2055
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2028
2056
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2029
- }).optional(),
2057
+ }).or(ComputedDefaultValue).optional(),
2030
2058
  configuration: import_v43.default.object({
2031
2059
  name: NameConfig.default({
2032
2060
  firstname: { required: true },
@@ -2050,14 +2078,14 @@ var NameField = BaseField.extend({
2050
2078
  id: "NameField"
2051
2079
  });
2052
2080
  var PhoneField = BaseField.extend({
2053
- defaultValue: NonEmptyTextValue.optional(),
2081
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2054
2082
  type: import_v43.default.literal(FieldType.PHONE)
2055
2083
  }).meta({
2056
2084
  description: "A field for entering a phone number",
2057
2085
  id: "PhoneField"
2058
2086
  });
2059
2087
  var IdField = BaseField.extend({
2060
- defaultValue: NonEmptyTextValue.optional(),
2088
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2061
2089
  type: import_v43.default.literal(FieldType.ID)
2062
2090
  }).meta({
2063
2091
  description: "A field for entering an ID",
@@ -2065,14 +2093,14 @@ var IdField = BaseField.extend({
2065
2093
  });
2066
2094
  var Checkbox = BaseField.extend({
2067
2095
  type: import_v43.default.literal(FieldType.CHECKBOX),
2068
- defaultValue: CheckboxFieldValue.default(false)
2096
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2069
2097
  }).meta({
2070
2098
  description: "A boolean checkbox field",
2071
2099
  id: "Checkbox"
2072
2100
  });
2073
2101
  var Country = BaseField.extend({
2074
2102
  type: import_v43.default.literal(FieldType.COUNTRY),
2075
- defaultValue: NonEmptyTextValue.optional(),
2103
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2076
2104
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2077
2105
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2078
2106
  )
@@ -2090,7 +2118,7 @@ var AdministrativeAreas = import_v43.default.enum([
2090
2118
  ]);
2091
2119
  var AdministrativeAreaField = BaseField.extend({
2092
2120
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2093
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2121
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2094
2122
  configuration: import_v43.default.object({
2095
2123
  partOf: FieldReference.optional().describe("Parent location"),
2096
2124
  type: AdministrativeAreas,
@@ -2102,7 +2130,7 @@ var AdministrativeAreaField = BaseField.extend({
2102
2130
  });
2103
2131
  var LocationInput = BaseField.extend({
2104
2132
  type: import_v43.default.literal(FieldType.LOCATION),
2105
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2133
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2106
2134
  configuration: import_v43.default.object({
2107
2135
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2108
2136
  allowedLocations: AllowedLocations
@@ -2114,7 +2142,7 @@ var LocationInput = BaseField.extend({
2114
2142
  var FileUploadWithOptions = BaseField.extend({
2115
2143
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2116
2144
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2117
- defaultValue: FileFieldWithOptionValue.optional(),
2145
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2118
2146
  configuration: import_v43.default.object({
2119
2147
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2120
2148
  maxImageSize: import_v43.default.object({
@@ -2130,12 +2158,12 @@ var FileUploadWithOptions = BaseField.extend({
2130
2158
  });
2131
2159
  var Facility = BaseField.extend({
2132
2160
  type: import_v43.default.literal(FieldType.FACILITY),
2133
- defaultValue: NonEmptyTextValue.optional(),
2161
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2134
2162
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2135
2163
  }).describe("Input field for a facility");
2136
2164
  var Office = BaseField.extend({
2137
2165
  type: import_v43.default.literal(FieldType.OFFICE),
2138
- defaultValue: NonEmptyTextValue.optional(),
2166
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2139
2167
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2140
2168
  }).describe("Input field for an office");
2141
2169
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2171,7 +2199,7 @@ var Address = BaseField.extend({
2171
2199
  ).optional(),
2172
2200
  allowedLocations: AllowedLocations
2173
2201
  }).optional(),
2174
- defaultValue: DefaultAddressFieldValue.optional()
2202
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2175
2203
  }).meta({
2176
2204
  description: "Address input field \u2013 a combination of location and text fields",
2177
2205
  id: "Address"
@@ -2218,7 +2246,7 @@ var ButtonConfiguration = import_v43.default.object({
2218
2246
  });
2219
2247
  var ButtonField = BaseField.extend({
2220
2248
  type: import_v43.default.literal(FieldType.BUTTON),
2221
- defaultValue: ButtonFieldValue.optional(),
2249
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2222
2250
  configuration: ButtonConfiguration
2223
2251
  }).meta({
2224
2252
  description: "A generic button that can be used to trigger an action",
@@ -2246,7 +2274,7 @@ var AlphaPrintButton = BaseField.extend({
2246
2274
  });
2247
2275
  var HttpField = BaseField.extend({
2248
2276
  type: import_v43.default.literal(FieldType.HTTP),
2249
- defaultValue: HttpFieldValue.optional(),
2277
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2250
2278
  configuration: import_v43.default.object({
2251
2279
  trigger: FieldReference.optional().describe(
2252
2280
  "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 +2360,7 @@ var LinkButtonField = BaseField.extend({
2332
2360
  });
2333
2361
  var VerificationStatus = BaseField.extend({
2334
2362
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2335
- defaultValue: VerificationStatusValue.optional(),
2363
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2336
2364
  configuration: import_v43.default.object({
2337
2365
  status: TranslationConfig.describe("Text to display on the status pill."),
2338
2366
  description: TranslationConfig.describe(
@@ -2354,7 +2382,7 @@ var QueryParamReaderField = BaseField.extend({
2354
2382
  });
2355
2383
  var QrReaderField = BaseField.extend({
2356
2384
  type: import_v43.default.literal(FieldType.QR_READER),
2357
- defaultValue: QrReaderFieldValue.optional(),
2385
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2358
2386
  configuration: import_v43.default.object({
2359
2387
  validator: import_v43.default.any().meta({
2360
2388
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2367,7 +2395,7 @@ var QrReaderField = BaseField.extend({
2367
2395
  });
2368
2396
  var IdReaderField = BaseField.extend({
2369
2397
  type: import_v43.default.literal(FieldType.ID_READER),
2370
- defaultValue: IdReaderFieldValue.optional(),
2398
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2371
2399
  methods: import_v43.default.array(
2372
2400
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2373
2401
  )
@@ -2661,6 +2689,11 @@ var ReadActionConfig = ActionConfigBase.extend(
2661
2689
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2662
2690
  }).shape
2663
2691
  );
2692
+ var NotifyConfig = ActionConfigBase.extend(
2693
+ z24.object({
2694
+ type: z24.literal(ActionType.NOTIFY)
2695
+ }).shape
2696
+ );
2664
2697
  var DeclareConfig = DeclarationActionBase.extend(
2665
2698
  z24.object({
2666
2699
  type: z24.literal(ActionType.DECLARE),
@@ -2745,9 +2778,13 @@ var ActionConfig = z24.discriminatedUnion("type", [
2745
2778
  id: "ReadActionConfig",
2746
2779
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2747
2780
  }),
2781
+ NotifyConfig.meta({
2782
+ id: "NotifyActionConfig",
2783
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
2784
+ }),
2748
2785
  DeclareConfig.meta({
2749
2786
  id: "DeclareActionConfig",
2750
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
2787
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2751
2788
  }),
2752
2789
  RejectConfig.meta({
2753
2790
  id: "RejectActionConfig",
@@ -2926,6 +2963,9 @@ var BaseField3 = z28.object({
2926
2963
  ),
2927
2964
  validations: z28.array(ValidationConfig).optional().describe(
2928
2965
  `Option for overriding the field validations specifically for advanced search form.`
2966
+ ),
2967
+ allowedLocations: JurisdictionReference.optional().describe(
2968
+ `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
2969
  )
2930
2970
  });
2931
2971
  var SearchQueryParams = z28.object({
@@ -3032,7 +3072,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3032
3072
  }
3033
3073
  return current;
3034
3074
  }
3075
+ function todayISO() {
3076
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3077
+ }
3078
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3079
+ function compileClientFunction(code) {
3080
+ let fn = compiledFunctionCache.get(code);
3081
+ if (!fn) {
3082
+ fn = new Function(`return (${code})`)();
3083
+ compiledFunctionCache.set(code, fn);
3084
+ }
3085
+ return fn;
3086
+ }
3035
3087
  (0, import_ajv_formats.default)(ajv);
3088
+ function buildClientFunctionContext(input) {
3089
+ return {
3090
+ $form: input.form,
3091
+ $now: todayISO(),
3092
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
3093
+ $online: isOnline(),
3094
+ $user: input.validatorContext?.user,
3095
+ $event: input.validatorContext?.event,
3096
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3097
+ user: input.systemVariables?.user,
3098
+ $window: input.systemVariables?.$window,
3099
+ locations: input.locations,
3100
+ adminLevelIds: input.adminLevelIds
3101
+ };
3102
+ }
3103
+ function runClientFunction(code, data, context) {
3104
+ return compileClientFunction(code)(data, context);
3105
+ }
3036
3106
  ajv.addKeyword({
3037
3107
  keyword: "daysFromDate",
3038
3108
  type: "string",
@@ -3077,12 +3147,35 @@ ajv.addKeyword({
3077
3147
  $data: true,
3078
3148
  errors: true,
3079
3149
  // @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) {
3150
+ validate(_schema, data, _2, dataContext) {
3081
3151
  const locationIdInput = data;
3082
3152
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3083
3153
  return locations.some((location) => location.id === locationIdInput);
3084
3154
  }
3085
3155
  });
3156
+ ajv.addKeyword({
3157
+ keyword: "customClientValidator",
3158
+ schemaType: "object",
3159
+ errors: true,
3160
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3161
+ // `validate()` callers build root data via `buildClientFunctionContext`,
3162
+ // so the cast holds.
3163
+ validate(schema, data, _2, dataContext) {
3164
+ return Boolean(
3165
+ runClientFunction(
3166
+ schema.code,
3167
+ data,
3168
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3169
+ )
3170
+ );
3171
+ }
3172
+ });
3173
+ function isOnline() {
3174
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3175
+ return navigator.onLine;
3176
+ }
3177
+ return true;
3178
+ }
3086
3179
 
3087
3180
  // ../commons/src/utils.ts
3088
3181
  var z32 = __toESM(require("zod/v4"));
@@ -3125,7 +3218,7 @@ var getActionAnnotationFields = (actionConfig) => {
3125
3218
  if (actionConfig.type === ActionType.CUSTOM) {
3126
3219
  return actionConfig.form;
3127
3220
  }
3128
- if ("review" in actionConfig) {
3221
+ if ("review" in actionConfig && actionConfig.review != null) {
3129
3222
  return actionConfig.review.fields;
3130
3223
  }
3131
3224
  return [];
@@ -3701,7 +3794,54 @@ function createFieldConditionals(fieldId) {
3701
3794
  }
3702
3795
  },
3703
3796
  required: [fieldId]
3704
- })
3797
+ }),
3798
+ /**
3799
+ * Custom client-side validator. The provided function is serialised and executed
3800
+ * just-in-time on the client only. External references (e.g. lodash) are not
3801
+ * available inside the function body — all logic must be self-contained.
3802
+ *
3803
+ * @example
3804
+ * field('nid').customClientValidator((value) => {
3805
+ * // LUHN check — all logic must be inline
3806
+ * const digits = String(value).split('').map(Number)
3807
+ * // ...
3808
+ * return isValid
3809
+ * })
3810
+ */
3811
+ customClientValidator(validationFn) {
3812
+ const code = validationFn.toString();
3813
+ return defineFormConditional({
3814
+ type: "object",
3815
+ properties: wrapToPath(
3816
+ { [fieldId]: { customClientValidator: { code } } },
3817
+ this.$$subfield
3818
+ ),
3819
+ required: [fieldId]
3820
+ });
3821
+ },
3822
+ /**
3823
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3824
+ * that can be used as the `value` property or a DATA component entry.
3825
+ * The function receives the referenced field's value as the first argument and
3826
+ * the full form context as the second; its return value replaces the field reference.
3827
+ * The function is serialised and executed just-in-time on the client only.
3828
+ * External references (e.g. lodash) are not available inside the function body.
3829
+ *
3830
+ * For computing a default value without referencing a specific field, use
3831
+ * `evaluate(fn)` in the `defaultValue` property instead.
3832
+ *
3833
+ * @example
3834
+ * field('a').customClientEvaluation((aValue, ctx) =>
3835
+ * Number(aValue) + Number(ctx.$form.b)
3836
+ * )
3837
+ */
3838
+ customClientEvaluation(computationFn) {
3839
+ return {
3840
+ $$code: computationFn.toString(),
3841
+ $$field: fieldId,
3842
+ $$subfield: this.$$subfield
3843
+ };
3844
+ }
3705
3845
  };
3706
3846
  }
3707
3847
 
@@ -4469,7 +4609,8 @@ var RejectCorrectionActionInput = BaseActionInput.extend(
4469
4609
  var ApproveCorrectionActionInput = BaseActionInput.extend(
4470
4610
  z38.object({
4471
4611
  requestId: z38.string(),
4472
- type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION)
4612
+ type: z38.literal(ActionType.APPROVE_CORRECTION).default(ActionType.APPROVE_CORRECTION),
4613
+ content: z38.object({ immediateCorrection: z38.boolean().optional() }).optional()
4473
4614
  }).shape
4474
4615
  );
4475
4616
  var ReadActionInput = BaseActionInput.extend(
@@ -4581,12 +4722,53 @@ var updateActions = ActionTypes.extract([
4581
4722
  ActionType.ARCHIVE,
4582
4723
  ActionType.PRINT_CERTIFICATE,
4583
4724
  ActionType.REQUEST_CORRECTION,
4725
+ ActionType.APPROVE_CORRECTION,
4726
+ ActionType.REJECT_CORRECTION,
4584
4727
  ActionType.CUSTOM
4585
4728
  ]);
4586
4729
 
4587
4730
  // ../commons/src/events/state/flags.ts
4588
4731
  var import_lodash3 = require("lodash");
4589
4732
  var import_date_fns3 = require("date-fns");
4733
+ var INHERENT_FLAG_RULES = [
4734
+ {
4735
+ flag: InherentFlags.CORRECTION_REQUESTED,
4736
+ setOn: [ActionType.REQUEST_CORRECTION],
4737
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4738
+ },
4739
+ {
4740
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4741
+ // other status-changing action (see getStatusFromActions).
4742
+ flag: InherentFlags.INCOMPLETE,
4743
+ setOn: [ActionType.NOTIFY],
4744
+ resetOn: [
4745
+ ActionType.CREATE,
4746
+ ActionType.DECLARE,
4747
+ ActionType.REGISTER,
4748
+ ActionType.ARCHIVE
4749
+ ]
4750
+ },
4751
+ {
4752
+ flag: InherentFlags.REJECTED,
4753
+ setOn: [ActionType.REJECT],
4754
+ resetOn: [
4755
+ ActionType.NOTIFY,
4756
+ ActionType.DECLARE,
4757
+ ActionType.EDIT,
4758
+ ActionType.REGISTER
4759
+ ]
4760
+ },
4761
+ {
4762
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4763
+ setOn: [ActionType.DUPLICATE_DETECTED],
4764
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4765
+ },
4766
+ {
4767
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4768
+ setOn: [ActionType.EDIT],
4769
+ resetOnAnyOtherAction: true
4770
+ }
4771
+ ];
4590
4772
 
4591
4773
  // ../commons/src/events/defineConfig.ts
4592
4774
  var IGNORED_EVENT_TYPES = [
@@ -5332,6 +5514,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5332
5514
  id: "signature.upload.modal.title",
5333
5515
  defaultMessage: "Draw signature",
5334
5516
  description: "Title for the modal to draw signature"
5517
+ },
5518
+ // Zod applies the schema default at parse time, but this fixture bypasses
5519
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5520
+ configuration: {
5521
+ maxFileSize: 5 * 1024 * 1024
5335
5522
  }
5336
5523
  }
5337
5524
  ]
@@ -5888,6 +6075,20 @@ var tennisClubMembershipEvent = defineConfig({
5888
6075
  },
5889
6076
  review: TENNIS_CLUB_DECLARATION_REVIEW
5890
6077
  },
6078
+ {
6079
+ type: ActionType.NOTIFY,
6080
+ label: {
6081
+ defaultMessage: "Notify health worker",
6082
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6083
+ id: "event.tennis-club-membership.action.notify.label"
6084
+ },
6085
+ flags: [
6086
+ {
6087
+ id: "health-worker-notified",
6088
+ operation: "add"
6089
+ }
6090
+ ]
6091
+ },
5891
6092
  {
5892
6093
  type: ActionType.REJECT,
5893
6094
  label: {
@@ -6130,6 +6331,17 @@ var tennisClubMembershipEvent = defineConfig({
6130
6331
  }
6131
6332
  }
6132
6333
  ],
6334
+ flags: [
6335
+ {
6336
+ id: "health-worker-notified",
6337
+ requiresAction: false,
6338
+ label: {
6339
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6340
+ defaultMessage: "Health worker notified",
6341
+ description: "Label for the health-worker-notified flag"
6342
+ }
6343
+ }
6344
+ ],
6133
6345
  advancedSearch: [
6134
6346
  {
6135
6347
  title: {
@@ -7125,6 +7337,13 @@ var ACTION_FILTERS = {
7125
7337
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7126
7338
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7127
7339
  };
7340
+ var REJECTED_ACTIONS = [
7341
+ ActionType.READ,
7342
+ ActionType.NOTIFY,
7343
+ ActionType.CUSTOM,
7344
+ ActionType.EDIT,
7345
+ ActionType.ARCHIVE
7346
+ ];
7128
7347
 
7129
7348
  // ../commons/src/events/FileUtils.ts
7130
7349
  var import_lodash7 = require("lodash");