@opencrvs/toolkit 2.0.0-rc.bdffe06 → 2.0.0-rc.bee0e60

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 (90) hide show
  1. package/README.md +14 -0
  2. package/build.sh +1 -0
  3. package/dist/application-config/index.js +51 -33
  4. package/dist/cli.js +3164 -45
  5. package/dist/commons/api/router.d.ts +26 -17
  6. package/dist/commons/application-config/index.d.ts +1 -0
  7. package/dist/commons/conditionals/conditionals.d.ts +348 -4
  8. package/dist/commons/conditionals/validate.d.ts +51 -2
  9. package/dist/commons/events/ActionConfig.d.ts +28 -2
  10. package/dist/commons/events/AdvancedSearchConfig.d.ts +342 -0
  11. package/dist/commons/events/FieldConfig.d.ts +378 -50
  12. package/dist/commons/events/FieldType.d.ts +1 -0
  13. package/dist/commons/events/FieldTypeMapping.d.ts +1 -1
  14. package/dist/commons/events/FieldValue.d.ts +6 -0
  15. package/dist/commons/events/field.d.ts +53 -1
  16. package/dist/commons/events/state/utils.d.ts +12 -290
  17. package/dist/commons/events/utils.d.ts +1 -1
  18. package/dist/conditionals/index.js +48 -1
  19. package/dist/environment/custom-types.d.ts +33 -0
  20. package/dist/environment/custom-types.d.ts.map +1 -0
  21. package/dist/environment/custom-types.js +12 -0
  22. package/dist/environment/derived-variables.d.ts +134 -0
  23. package/dist/environment/derived-variables.d.ts.map +1 -0
  24. package/dist/environment/derived-variables.js +169 -0
  25. package/dist/environment/editor-questions.d.ts +4 -0
  26. package/dist/environment/editor-questions.d.ts.map +1 -0
  27. package/dist/environment/editor-questions.js +65 -0
  28. package/dist/environment/git.d.ts +5 -0
  29. package/dist/environment/git.d.ts.map +1 -0
  30. package/dist/environment/git.js +38 -0
  31. package/dist/environment/github.d.ts +26 -0
  32. package/dist/environment/github.d.ts.map +1 -0
  33. package/dist/environment/github.js +244 -0
  34. package/dist/environment/index.d.ts +5 -0
  35. package/dist/environment/index.d.ts.map +1 -0
  36. package/dist/environment/index.js +71 -0
  37. package/dist/environment/logger.d.ts +15 -0
  38. package/dist/environment/logger.d.ts.map +1 -0
  39. package/dist/environment/logger.js +25 -0
  40. package/dist/environment/manage-users.d.ts +11 -0
  41. package/dist/environment/manage-users.d.ts.map +1 -0
  42. package/dist/environment/manage-users.js +494 -0
  43. package/dist/environment/questions-helper.d.ts +15 -0
  44. package/dist/environment/questions-helper.d.ts.map +1 -0
  45. package/dist/environment/questions-helper.js +70 -0
  46. package/dist/environment/questions.d.ts +199 -0
  47. package/dist/environment/questions.d.ts.map +1 -0
  48. package/dist/environment/questions.js +412 -0
  49. package/dist/environment/setup-environment.d.ts +2 -0
  50. package/dist/environment/setup-environment.d.ts.map +1 -0
  51. package/dist/environment/setup-environment.js +773 -0
  52. package/dist/environment/ssh-keygen.d.ts +5 -0
  53. package/dist/environment/ssh-keygen.d.ts.map +1 -0
  54. package/dist/environment/ssh-keygen.js +18 -0
  55. package/dist/environment/swarm-to-k8s.d.ts +2 -0
  56. package/dist/environment/swarm-to-k8s.d.ts.map +1 -0
  57. package/dist/environment/swarm-to-k8s.js +172 -0
  58. package/dist/environment/templates/charts-values/dependencies/values.override.yaml +4 -0
  59. package/dist/environment/templates/charts-values/dependencies/values.yaml +82 -0
  60. package/dist/environment/templates/charts-values/opencrvs-services/values.override.yaml +4 -0
  61. package/dist/environment/templates/charts-values/opencrvs-services/values.yaml +79 -0
  62. package/dist/environment/templates/charts-values/traefik/values.override.yaml +4 -0
  63. package/dist/environment/templates/charts-values/traefik/values.yaml +116 -0
  64. package/dist/environment/templates/inventory/inventory.template.yml +100 -0
  65. package/dist/environment/templates/inventory/production.example.yml +77 -0
  66. package/dist/environment/templates/inventory/qa.example.yml +48 -0
  67. package/dist/environment/templates.d.ts +27 -0
  68. package/dist/environment/templates.d.ts.map +1 -0
  69. package/dist/environment/templates.js +159 -0
  70. package/dist/environment/update-workflows.d.ts +2 -0
  71. package/dist/environment/update-workflows.d.ts.map +1 -0
  72. package/dist/environment/update-workflows.js +168 -0
  73. package/dist/environment/users.d.ts +2 -0
  74. package/dist/environment/users.d.ts.map +1 -0
  75. package/dist/environment/users.js +108 -0
  76. package/dist/environment/utils.d.ts +18 -0
  77. package/dist/environment/utils.d.ts.map +1 -0
  78. package/dist/environment/utils.js +100 -0
  79. package/dist/events/index.js +357 -145
  80. package/dist/migrations/v2.0/checkout-upstream-files.d.ts +1 -1
  81. package/dist/migrations/v2.0/checkout-upstream-files.d.ts.map +1 -1
  82. package/dist/migrations/v2.0/checkout-upstream-files.js +1 -1
  83. package/dist/migrations/v2.0/index.js +10 -4
  84. package/dist/notification/index.js +244 -37
  85. package/dist/scopes/index.d.ts +4 -6
  86. package/dist/scopes/index.js +9 -3
  87. package/opencrvs-toolkit-2.0.0-rc.bee0e60.tgz +0 -0
  88. package/package.json +15 -1
  89. package/tsconfig.tsbuildinfo +1 -1
  90. package/opencrvs-toolkit-2.0.0-rc.bdffe06.tgz +0 -0
@@ -1,5 +1,5 @@
1
1
  export declare const UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
2
- export declare const UPSTREAM_BRANCH = "release-v2.0.0";
2
+ export declare const UPSTREAM_BRANCH = "release/2.0.0";
3
3
  /**
4
4
  * Runs a git command in the country config working directory.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,mBAAmB,CAAA;AAc/C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
1
+ {"version":3,"file":"checkout-upstream-files.d.ts","sourceRoot":"","sources":["../../../src/migrations/v2.0/checkout-upstream-files.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,2DACiC,CAAA;AAE1D,eAAO,MAAM,eAAe,kBAAkB,CAAA;AAc9C;;;;;;GAMG;AACH,wBAAgB,MAAM,CACpB,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,MAAc,EAAE,GAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAO,GAC5C,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAO9C;AAED,wBAAgB,eAAe,IAAI,IAAI,CAMtC;AAID,iBAAe,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAuDnC;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -59,7 +59,7 @@ exports.main = main;
59
59
  */
60
60
  const child_process_1 = require("child_process");
61
61
  exports.UPSTREAM_URL = 'https://github.com/opencrvs/opencrvs-countryconfig.git';
62
- exports.UPSTREAM_BRANCH = 'release-v2.0.0';
62
+ exports.UPSTREAM_BRANCH = 'release/2.0.0';
63
63
  // Remote name used only for the duration of this codemod. Prefixed to avoid
64
64
  // clashing with remotes the user may have (origin, upstream, etc.).
65
65
  const TEMP_REMOTE = 'opencrvs-upgrade-v19-v20-codemod';
@@ -2394,14 +2394,20 @@ var encodeScope = (scope) => {
2394
2394
  encode: false
2395
2395
  });
2396
2396
  };
2397
- var decodeScope = (query) => {
2398
- const scope = qs.parse(query, {
2397
+ var decodedScopeCache = /* @__PURE__ */ new Map();
2398
+ var decodeScope = (encodedScope) => {
2399
+ if (decodedScopeCache.has(encodedScope)) {
2400
+ return decodedScopeCache.get(encodedScope);
2401
+ }
2402
+ const scope = qs.parse(encodedScope, {
2399
2403
  ignoreQueryPrefix: true,
2400
2404
  comma: true,
2401
2405
  allowDots: true
2402
2406
  });
2403
2407
  const unflattenedScope = unflattenScope(scope);
2404
- return Scope2.safeParse(unflattenedScope)?.data;
2408
+ const result = Scope2.safeParse(unflattenedScope)?.data;
2409
+ decodedScopeCache.set(encodedScope, result);
2410
+ return result;
2405
2411
  };
2406
2412
  var DEFAULT_SCOPE_OPTIONS = {
2407
2413
  placeOfEvent: JurisdictionFilter.enum.all,
@@ -4306,7 +4312,7 @@ Saved ${handlerRelPath}.`);
4306
4312
  // src/migrations/v2.0/checkout-upstream-files.ts
4307
4313
  var import_child_process = require("child_process");
4308
4314
  var UPSTREAM_URL = "https://github.com/opencrvs/opencrvs-countryconfig.git";
4309
- var UPSTREAM_BRANCH = "release-v2.0.0";
4315
+ var UPSTREAM_BRANCH = "release/2.0.0";
4310
4316
  var TEMP_REMOTE = "opencrvs-upgrade-v19-v20-codemod";
4311
4317
  var FILES_TO_CHECKOUT = [
4312
4318
  "src/analytics/analytics.ts",
@@ -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",
@@ -1666,8 +1672,18 @@ var FieldReference = import_v43.default.object({
1666
1672
  $$field: FieldId.describe("Id of the field to reference"),
1667
1673
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1668
1674
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1675
+ ),
1676
+ $$code: import_v43.default.string().optional().describe(
1677
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1678
+ )
1679
+ }).describe(
1680
+ "Reference to a field value, with an optional client-side computation applied."
1681
+ );
1682
+ var ComputedDefaultValue = import_v43.default.object({
1683
+ $$code: import_v43.default.string().describe(
1684
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1669
1685
  )
1670
- }).describe("Reference to a field by its ID");
1686
+ }).describe("A context-only computation used as a field default value.");
1671
1687
  var ValidationConfig = import_v43.default.object({
1672
1688
  validator: Conditional.describe(
1673
1689
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1708,7 +1724,7 @@ var BaseField = import_v43.default.object({
1708
1724
  "Indicates whether the field can be modified during record correction."
1709
1725
  ),
1710
1726
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
1711
- "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."
1727
+ "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."
1712
1728
  ),
1713
1729
  analytics: import_v43.default.boolean().default(false).optional().describe(
1714
1730
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1722,7 +1738,7 @@ var Divider = BaseField.extend({
1722
1738
  });
1723
1739
  var TextField = BaseField.extend({
1724
1740
  type: import_v43.default.literal(FieldType.TEXT),
1725
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1741
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1726
1742
  configuration: import_v43.default.object({
1727
1743
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1728
1744
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1735,10 +1751,11 @@ var TextField = BaseField.extend({
1735
1751
  });
1736
1752
  var NumberField = BaseField.extend({
1737
1753
  type: import_v43.default.literal(FieldType.NUMBER),
1738
- defaultValue: NumberFieldValue.optional(),
1754
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1739
1755
  configuration: import_v43.default.object({
1740
1756
  min: import_v43.default.number().optional().describe("Minimum value"),
1741
1757
  max: import_v43.default.number().optional().describe("Maximum value"),
1758
+ integer: import_v43.default.boolean().optional().describe("When true, only whole numbers are allowed"),
1742
1759
  prefix: TranslationConfig.optional(),
1743
1760
  postfix: TranslationConfig.optional()
1744
1761
  }).optional()
@@ -1748,7 +1765,7 @@ var NumberField = BaseField.extend({
1748
1765
  });
1749
1766
  var TextAreaField = BaseField.extend({
1750
1767
  type: import_v43.default.literal(FieldType.TEXTAREA),
1751
- defaultValue: NonEmptyTextValue.optional(),
1768
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1752
1769
  configuration: import_v43.default.object({
1753
1770
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1754
1771
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1782,7 +1799,7 @@ var SignatureField = BaseField.extend({
1782
1799
  signaturePromptLabel: TranslationConfig.describe(
1783
1800
  "Title of the signature modal"
1784
1801
  ),
1785
- defaultValue: FieldValue.optional(),
1802
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1786
1803
  configuration: import_v43.default.object({
1787
1804
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1788
1805
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1798,14 +1815,14 @@ var EmailField = BaseField.extend({
1798
1815
  configuration: import_v43.default.object({
1799
1816
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1800
1817
  }).default({ maxLength: 255 }).optional(),
1801
- defaultValue: NonEmptyTextValue.optional()
1818
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1802
1819
  }).meta({
1803
1820
  description: "An email input field",
1804
1821
  id: "EmailField"
1805
1822
  });
1806
1823
  var DateField = BaseField.extend({
1807
1824
  type: import_v43.default.literal(FieldType.DATE),
1808
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1825
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1809
1826
  configuration: import_v43.default.object({
1810
1827
  notice: TranslationConfig.describe(
1811
1828
  "Text to display above the date input"
@@ -1817,7 +1834,7 @@ var DateField = BaseField.extend({
1817
1834
  });
1818
1835
  var AgeField = BaseField.extend({
1819
1836
  type: import_v43.default.literal(FieldType.AGE),
1820
- defaultValue: NumberFieldValue.optional(),
1837
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1821
1838
  configuration: import_v43.default.object({
1822
1839
  asOfDate: FieldReference,
1823
1840
  prefix: TranslationConfig.optional(),
@@ -1829,7 +1846,7 @@ var AgeField = BaseField.extend({
1829
1846
  });
1830
1847
  var TimeField = BaseField.extend({
1831
1848
  type: import_v43.default.literal(FieldType.TIME),
1832
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1849
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1833
1850
  configuration: import_v43.default.object({
1834
1851
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1835
1852
  notice: TranslationConfig.describe(
@@ -1842,7 +1859,7 @@ var TimeField = BaseField.extend({
1842
1859
  });
1843
1860
  var DateRangeField = BaseField.extend({
1844
1861
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1845
- defaultValue: DateRangeFieldValue.optional(),
1862
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1846
1863
  configuration: import_v43.default.object({
1847
1864
  notice: TranslationConfig.describe(
1848
1865
  "Text to display above the date input"
@@ -1921,7 +1938,7 @@ var PageHeader = BaseField.extend({
1921
1938
  });
1922
1939
  var File = BaseField.extend({
1923
1940
  type: import_v43.default.literal(FieldType.FILE),
1924
- defaultValue: FileFieldValue.optional(),
1941
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1925
1942
  configuration: import_v43.default.object({
1926
1943
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1927
1944
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1948,7 +1965,7 @@ var SelectOption = import_v43.default.object({
1948
1965
  });
1949
1966
  var NumberWithUnitField = BaseField.extend({
1950
1967
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1951
- defaultValue: NumberWithUnitFieldValue.optional(),
1968
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1952
1969
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1953
1970
  configuration: import_v43.default.object({
1954
1971
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1963,7 +1980,7 @@ var NumberWithUnitField = BaseField.extend({
1963
1980
  });
1964
1981
  var RadioGroup = BaseField.extend({
1965
1982
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1966
- defaultValue: TextValue.optional(),
1983
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1967
1984
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1968
1985
  configuration: import_v43.default.object({
1969
1986
  styles: import_v43.default.object({
@@ -1988,7 +2005,7 @@ var BulletList = BaseField.extend({
1988
2005
  });
1989
2006
  var Select = BaseField.extend({
1990
2007
  type: import_v43.default.literal(FieldType.SELECT),
1991
- defaultValue: TextValue.optional(),
2008
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1992
2009
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1993
2010
  noOptionsMessage: TranslationConfig.optional().describe(
1994
2011
  `
@@ -2010,7 +2027,7 @@ var SelectDateRangeOption = import_v43.default.object({
2010
2027
  });
2011
2028
  var SelectDateRangeField = BaseField.extend({
2012
2029
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
2013
- defaultValue: SelectDateRangeValue.optional(),
2030
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
2014
2031
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
2015
2032
  }).meta({
2016
2033
  description: "A date range selection field",
@@ -2027,7 +2044,7 @@ var NameField = BaseField.extend({
2027
2044
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
2028
2045
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
2029
2046
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
2030
- }).optional(),
2047
+ }).or(ComputedDefaultValue).optional(),
2031
2048
  configuration: import_v43.default.object({
2032
2049
  name: NameConfig.default({
2033
2050
  firstname: { required: true },
@@ -2051,14 +2068,14 @@ var NameField = BaseField.extend({
2051
2068
  id: "NameField"
2052
2069
  });
2053
2070
  var PhoneField = BaseField.extend({
2054
- defaultValue: NonEmptyTextValue.optional(),
2071
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2055
2072
  type: import_v43.default.literal(FieldType.PHONE)
2056
2073
  }).meta({
2057
2074
  description: "A field for entering a phone number",
2058
2075
  id: "PhoneField"
2059
2076
  });
2060
2077
  var IdField = BaseField.extend({
2061
- defaultValue: NonEmptyTextValue.optional(),
2078
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2062
2079
  type: import_v43.default.literal(FieldType.ID)
2063
2080
  }).meta({
2064
2081
  description: "A field for entering an ID",
@@ -2066,14 +2083,14 @@ var IdField = BaseField.extend({
2066
2083
  });
2067
2084
  var Checkbox = BaseField.extend({
2068
2085
  type: import_v43.default.literal(FieldType.CHECKBOX),
2069
- defaultValue: CheckboxFieldValue.default(false)
2086
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
2070
2087
  }).meta({
2071
2088
  description: "A boolean checkbox field",
2072
2089
  id: "Checkbox"
2073
2090
  });
2074
2091
  var Country = BaseField.extend({
2075
2092
  type: import_v43.default.literal(FieldType.COUNTRY),
2076
- defaultValue: NonEmptyTextValue.optional(),
2093
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2077
2094
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
2078
2095
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
2079
2096
  )
@@ -2091,7 +2108,7 @@ var AdministrativeAreas = import_v43.default.enum([
2091
2108
  ]);
2092
2109
  var AdministrativeAreaField = BaseField.extend({
2093
2110
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
2094
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2111
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2095
2112
  configuration: import_v43.default.object({
2096
2113
  partOf: FieldReference.optional().describe("Parent location"),
2097
2114
  type: AdministrativeAreas,
@@ -2103,7 +2120,7 @@ var AdministrativeAreaField = BaseField.extend({
2103
2120
  });
2104
2121
  var LocationInput = BaseField.extend({
2105
2122
  type: import_v43.default.literal(FieldType.LOCATION),
2106
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
2123
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
2107
2124
  configuration: import_v43.default.object({
2108
2125
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
2109
2126
  allowedLocations: AllowedLocations
@@ -2115,7 +2132,7 @@ var LocationInput = BaseField.extend({
2115
2132
  var FileUploadWithOptions = BaseField.extend({
2116
2133
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
2117
2134
  options: import_v43.default.array(SelectOption).describe("A list of options"),
2118
- defaultValue: FileFieldWithOptionValue.optional(),
2135
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
2119
2136
  configuration: import_v43.default.object({
2120
2137
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
2121
2138
  maxImageSize: import_v43.default.object({
@@ -2131,12 +2148,12 @@ var FileUploadWithOptions = BaseField.extend({
2131
2148
  });
2132
2149
  var Facility = BaseField.extend({
2133
2150
  type: import_v43.default.literal(FieldType.FACILITY),
2134
- defaultValue: NonEmptyTextValue.optional(),
2151
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2135
2152
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2136
2153
  }).describe("Input field for a facility");
2137
2154
  var Office = BaseField.extend({
2138
2155
  type: import_v43.default.literal(FieldType.OFFICE),
2139
- defaultValue: NonEmptyTextValue.optional(),
2156
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
2140
2157
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
2141
2158
  }).describe("Input field for an office");
2142
2159
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -2172,7 +2189,7 @@ var Address = BaseField.extend({
2172
2189
  ).optional(),
2173
2190
  allowedLocations: AllowedLocations
2174
2191
  }).optional(),
2175
- defaultValue: DefaultAddressFieldValue.optional()
2192
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
2176
2193
  }).meta({
2177
2194
  description: "Address input field \u2013 a combination of location and text fields",
2178
2195
  id: "Address"
@@ -2219,7 +2236,7 @@ var ButtonConfiguration = import_v43.default.object({
2219
2236
  });
2220
2237
  var ButtonField = BaseField.extend({
2221
2238
  type: import_v43.default.literal(FieldType.BUTTON),
2222
- defaultValue: ButtonFieldValue.optional(),
2239
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
2223
2240
  configuration: ButtonConfiguration
2224
2241
  }).meta({
2225
2242
  description: "A generic button that can be used to trigger an action",
@@ -2247,7 +2264,7 @@ var AlphaPrintButton = BaseField.extend({
2247
2264
  });
2248
2265
  var HttpField = BaseField.extend({
2249
2266
  type: import_v43.default.literal(FieldType.HTTP),
2250
- defaultValue: HttpFieldValue.optional(),
2267
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
2251
2268
  configuration: import_v43.default.object({
2252
2269
  trigger: FieldReference.optional().describe(
2253
2270
  "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."
@@ -2333,7 +2350,7 @@ var LinkButtonField = BaseField.extend({
2333
2350
  });
2334
2351
  var VerificationStatus = BaseField.extend({
2335
2352
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2336
- defaultValue: VerificationStatusValue.optional(),
2353
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2337
2354
  configuration: import_v43.default.object({
2338
2355
  status: TranslationConfig.describe("Text to display on the status pill."),
2339
2356
  description: TranslationConfig.describe(
@@ -2355,7 +2372,7 @@ var QueryParamReaderField = BaseField.extend({
2355
2372
  });
2356
2373
  var QrReaderField = BaseField.extend({
2357
2374
  type: import_v43.default.literal(FieldType.QR_READER),
2358
- defaultValue: QrReaderFieldValue.optional(),
2375
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2359
2376
  configuration: import_v43.default.object({
2360
2377
  validator: import_v43.default.any().meta({
2361
2378
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2368,7 +2385,7 @@ var QrReaderField = BaseField.extend({
2368
2385
  });
2369
2386
  var IdReaderField = BaseField.extend({
2370
2387
  type: import_v43.default.literal(FieldType.ID_READER),
2371
- defaultValue: IdReaderFieldValue.optional(),
2388
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2372
2389
  methods: import_v43.default.array(
2373
2390
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2374
2391
  )
@@ -2662,6 +2679,11 @@ var ReadActionConfig = ActionConfigBase.extend(
2662
2679
  conditionals: z24.never().optional().describe("Read-action can not be disabled or hidden with conditionals.")
2663
2680
  }).shape
2664
2681
  );
2682
+ var NotifyConfig = ActionConfigBase.extend(
2683
+ z24.object({
2684
+ type: z24.literal(ActionType.NOTIFY)
2685
+ }).shape
2686
+ );
2665
2687
  var DeclareConfig = DeclarationActionBase.extend(
2666
2688
  z24.object({
2667
2689
  type: z24.literal(ActionType.DECLARE),
@@ -2746,9 +2768,13 @@ var ActionConfig = z24.discriminatedUnion("type", [
2746
2768
  id: "ReadActionConfig",
2747
2769
  description: "Configuration for the read action \u2014 defines the record-tab content displayed on the event overview page."
2748
2770
  }),
2771
+ NotifyConfig.meta({
2772
+ id: "NotifyActionConfig",
2773
+ description: "Configuration for the notify action. When present, NOTIFY uses this config independently from DECLARE. When absent, NOTIFY falls back to the DeclareActionConfig."
2774
+ }),
2749
2775
  DeclareConfig.meta({
2750
2776
  id: "DeclareActionConfig",
2751
- description: "Configuration for the declare action. Includes review-page fields. Shared with the notify action (ActionType.NOTIFY)."
2777
+ description: "Configuration for the declare action. Includes review-page fields. NOTIFY falls back to this config when no dedicated NotifyActionConfig is provided."
2752
2778
  }),
2753
2779
  RejectConfig.meta({
2754
2780
  id: "RejectActionConfig",
@@ -2927,6 +2953,9 @@ var BaseField3 = z28.object({
2927
2953
  ),
2928
2954
  validations: z28.array(ValidationConfig).optional().describe(
2929
2955
  `Option for overriding the field validations specifically for advanced search form.`
2956
+ ),
2957
+ allowedLocations: JurisdictionReference.optional().describe(
2958
+ `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.`
2930
2959
  )
2931
2960
  });
2932
2961
  var SearchQueryParams = z28.object({
@@ -3033,7 +3062,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
3033
3062
  }
3034
3063
  return current;
3035
3064
  }
3065
+ function todayISO() {
3066
+ return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
3067
+ }
3068
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
3069
+ function compileClientFunction(code) {
3070
+ let fn = compiledFunctionCache.get(code);
3071
+ if (!fn) {
3072
+ fn = new Function(`return (${code})`)();
3073
+ compiledFunctionCache.set(code, fn);
3074
+ }
3075
+ return fn;
3076
+ }
3036
3077
  (0, import_ajv_formats.default)(ajv);
3078
+ function buildClientFunctionContext(input) {
3079
+ return {
3080
+ $form: input.form,
3081
+ $now: todayISO(),
3082
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
3083
+ $online: isOnline(),
3084
+ $user: input.validatorContext?.user,
3085
+ $event: input.validatorContext?.event,
3086
+ $leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
3087
+ user: input.systemVariables?.user,
3088
+ $window: input.systemVariables?.$window,
3089
+ locations: input.locations,
3090
+ adminLevelIds: input.adminLevelIds
3091
+ };
3092
+ }
3093
+ function runClientFunction(code, data, context) {
3094
+ return compileClientFunction(code)(data, context);
3095
+ }
3037
3096
  ajv.addKeyword({
3038
3097
  keyword: "daysFromDate",
3039
3098
  type: "string",
@@ -3078,12 +3137,35 @@ ajv.addKeyword({
3078
3137
  $data: true,
3079
3138
  errors: true,
3080
3139
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
3081
- validate(schema, data, _2, dataContext) {
3140
+ validate(_schema, data, _2, dataContext) {
3082
3141
  const locationIdInput = data;
3083
3142
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
3084
3143
  return locations.some((location) => location.id === locationIdInput);
3085
3144
  }
3086
3145
  });
3146
+ ajv.addKeyword({
3147
+ keyword: "customClientValidator",
3148
+ schemaType: "object",
3149
+ errors: true,
3150
+ // @ts-expect-error -- AJV's public types don't expose `rootData`. All
3151
+ // `validate()` callers build root data via `buildClientFunctionContext`,
3152
+ // so the cast holds.
3153
+ validate(schema, data, _2, dataContext) {
3154
+ return Boolean(
3155
+ runClientFunction(
3156
+ schema.code,
3157
+ data,
3158
+ dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
3159
+ )
3160
+ );
3161
+ }
3162
+ });
3163
+ function isOnline() {
3164
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
3165
+ return navigator.onLine;
3166
+ }
3167
+ return true;
3168
+ }
3087
3169
 
3088
3170
  // ../commons/src/utils.ts
3089
3171
  var z32 = __toESM(require("zod/v4"));
@@ -3126,7 +3208,7 @@ var getActionAnnotationFields = (actionConfig) => {
3126
3208
  if (actionConfig.type === ActionType.CUSTOM) {
3127
3209
  return actionConfig.form;
3128
3210
  }
3129
- if ("review" in actionConfig) {
3211
+ if ("review" in actionConfig && actionConfig.review != null) {
3130
3212
  return actionConfig.review.fields;
3131
3213
  }
3132
3214
  return [];
@@ -3702,7 +3784,54 @@ function createFieldConditionals(fieldId) {
3702
3784
  }
3703
3785
  },
3704
3786
  required: [fieldId]
3705
- })
3787
+ }),
3788
+ /**
3789
+ * Custom client-side validator. The provided function is serialised and executed
3790
+ * just-in-time on the client only. External references (e.g. lodash) are not
3791
+ * available inside the function body — all logic must be self-contained.
3792
+ *
3793
+ * @example
3794
+ * field('nid').customClientValidator((value) => {
3795
+ * // LUHN check — all logic must be inline
3796
+ * const digits = String(value).split('').map(Number)
3797
+ * // ...
3798
+ * return isValid
3799
+ * })
3800
+ */
3801
+ customClientValidator(validationFn) {
3802
+ const code = validationFn.toString();
3803
+ return defineFormConditional({
3804
+ type: "object",
3805
+ properties: wrapToPath(
3806
+ { [fieldId]: { customClientValidator: { code } } },
3807
+ this.$$subfield
3808
+ ),
3809
+ required: [fieldId]
3810
+ });
3811
+ },
3812
+ /**
3813
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3814
+ * that can be used as the `value` property or a DATA component entry.
3815
+ * The function receives the referenced field's value as the first argument and
3816
+ * the full form context as the second; its return value replaces the field reference.
3817
+ * The function is serialised and executed just-in-time on the client only.
3818
+ * External references (e.g. lodash) are not available inside the function body.
3819
+ *
3820
+ * For computing a default value without referencing a specific field, use
3821
+ * `evaluate(fn)` in the `defaultValue` property instead.
3822
+ *
3823
+ * @example
3824
+ * field('a').customClientEvaluation((aValue, ctx) =>
3825
+ * Number(aValue) + Number(ctx.$form.b)
3826
+ * )
3827
+ */
3828
+ customClientEvaluation(computationFn) {
3829
+ return {
3830
+ $$code: computationFn.toString(),
3831
+ $$field: fieldId,
3832
+ $$subfield: this.$$subfield
3833
+ };
3834
+ }
3706
3835
  };
3707
3836
  }
3708
3837
 
@@ -4583,12 +4712,53 @@ var updateActions = ActionTypes.extract([
4583
4712
  ActionType.ARCHIVE,
4584
4713
  ActionType.PRINT_CERTIFICATE,
4585
4714
  ActionType.REQUEST_CORRECTION,
4715
+ ActionType.APPROVE_CORRECTION,
4716
+ ActionType.REJECT_CORRECTION,
4586
4717
  ActionType.CUSTOM
4587
4718
  ]);
4588
4719
 
4589
4720
  // ../commons/src/events/state/flags.ts
4590
4721
  var import_lodash3 = require("lodash");
4591
4722
  var import_date_fns3 = require("date-fns");
4723
+ var INHERENT_FLAG_RULES = [
4724
+ {
4725
+ flag: InherentFlags.CORRECTION_REQUESTED,
4726
+ setOn: [ActionType.REQUEST_CORRECTION],
4727
+ resetOn: [ActionType.APPROVE_CORRECTION, ActionType.REJECT_CORRECTION]
4728
+ },
4729
+ {
4730
+ // INCOMPLETE mirrors the NOTIFIED status: set by NOTIFY, cleared by any
4731
+ // other status-changing action (see getStatusFromActions).
4732
+ flag: InherentFlags.INCOMPLETE,
4733
+ setOn: [ActionType.NOTIFY],
4734
+ resetOn: [
4735
+ ActionType.CREATE,
4736
+ ActionType.DECLARE,
4737
+ ActionType.REGISTER,
4738
+ ActionType.ARCHIVE
4739
+ ]
4740
+ },
4741
+ {
4742
+ flag: InherentFlags.REJECTED,
4743
+ setOn: [ActionType.REJECT],
4744
+ resetOn: [
4745
+ ActionType.NOTIFY,
4746
+ ActionType.DECLARE,
4747
+ ActionType.EDIT,
4748
+ ActionType.REGISTER
4749
+ ]
4750
+ },
4751
+ {
4752
+ flag: InherentFlags.POTENTIAL_DUPLICATE,
4753
+ setOn: [ActionType.DUPLICATE_DETECTED],
4754
+ resetOn: [ActionType.MARK_AS_DUPLICATE, ActionType.MARK_AS_NOT_DUPLICATE]
4755
+ },
4756
+ {
4757
+ flag: InherentFlags.EDIT_IN_PROGRESS,
4758
+ setOn: [ActionType.EDIT],
4759
+ resetOnAnyOtherAction: true
4760
+ }
4761
+ ];
4592
4762
 
4593
4763
  // ../commons/src/events/defineConfig.ts
4594
4764
  var IGNORED_EVENT_TYPES = [
@@ -5334,6 +5504,11 @@ var TENNIS_CLUB_DECLARATION_REVIEW = {
5334
5504
  id: "signature.upload.modal.title",
5335
5505
  defaultMessage: "Draw signature",
5336
5506
  description: "Title for the modal to draw signature"
5507
+ },
5508
+ // Zod applies the schema default at parse time, but this fixture bypasses
5509
+ // parsing — GeneratedInputField accesses configuration.maxFileSize directly.
5510
+ configuration: {
5511
+ maxFileSize: 5 * 1024 * 1024
5337
5512
  }
5338
5513
  }
5339
5514
  ]
@@ -5890,6 +6065,20 @@ var tennisClubMembershipEvent = defineConfig({
5890
6065
  },
5891
6066
  review: TENNIS_CLUB_DECLARATION_REVIEW
5892
6067
  },
6068
+ {
6069
+ type: ActionType.NOTIFY,
6070
+ label: {
6071
+ defaultMessage: "Notify health worker",
6072
+ description: "This is shown as the action name anywhere the user can trigger the action from",
6073
+ id: "event.tennis-club-membership.action.notify.label"
6074
+ },
6075
+ flags: [
6076
+ {
6077
+ id: "health-worker-notified",
6078
+ operation: "add"
6079
+ }
6080
+ ]
6081
+ },
5893
6082
  {
5894
6083
  type: ActionType.REJECT,
5895
6084
  label: {
@@ -6132,6 +6321,17 @@ var tennisClubMembershipEvent = defineConfig({
6132
6321
  }
6133
6322
  }
6134
6323
  ],
6324
+ flags: [
6325
+ {
6326
+ id: "health-worker-notified",
6327
+ requiresAction: false,
6328
+ label: {
6329
+ id: "event.tennis-club-membership.flag.health-worker-notified.label",
6330
+ defaultMessage: "Health worker notified",
6331
+ description: "Label for the health-worker-notified flag"
6332
+ }
6333
+ }
6334
+ ],
6135
6335
  advancedSearch: [
6136
6336
  {
6137
6337
  title: {
@@ -7127,6 +7327,13 @@ var ACTION_FILTERS = {
7127
7327
  [ActionType.UNASSIGN]: (flags) => !flags.some((flag) => flag.endsWith(":requested")),
7128
7328
  [ActionType.CUSTOM]: (flags) => !flags.some((flag) => flag.endsWith(":requested"))
7129
7329
  };
7330
+ var REJECTED_ACTIONS = [
7331
+ ActionType.READ,
7332
+ ActionType.NOTIFY,
7333
+ ActionType.CUSTOM,
7334
+ ActionType.EDIT,
7335
+ ActionType.ARCHIVE
7336
+ ];
7130
7337
 
7131
7338
  // ../commons/src/events/FileUtils.ts
7132
7339
  var import_lodash7 = require("lodash");