@opencrvs/toolkit 2.0.0-rc.a4cf9f6 → 2.0.0-rc.a541c60

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