@opencrvs/toolkit 1.9.13-rc.2e6f2fb → 1.9.13-rc.309c8c5

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.
@@ -1488,11 +1488,23 @@ var FieldId = import_zod17.z.string().refine(
1488
1488
  })
1489
1489
  ).describe("Unique identifier for the field");
1490
1490
  var FieldReference = import_zod17.z.object({
1491
- $$field: FieldId,
1491
+ $$field: FieldId.describe(
1492
+ "Field whose value is passed as the first argument to the computation"
1493
+ ),
1492
1494
  $$subfield: import_zod17.z.array(import_zod17.z.string()).optional().default([]).describe(
1493
1495
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1496
+ ),
1497
+ $$code: import_zod17.z.string().optional().describe(
1498
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1499
+ )
1500
+ }).describe(
1501
+ "Reference to a field value, with an optional client-side computation applied."
1502
+ );
1503
+ var ComputedDefaultValue = import_zod17.z.object({
1504
+ $$code: import_zod17.z.string().describe(
1505
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1494
1506
  )
1495
- }).describe("Reference to a field by its ID");
1507
+ }).describe("A context-only computation used as a field default value.");
1496
1508
  var ValidationConfig = import_zod17.z.object({
1497
1509
  validator: Conditional,
1498
1510
  message: TranslationConfig
@@ -1526,7 +1538,7 @@ var BaseField = import_zod17.z.object({
1526
1538
  "Indicates whether the field can be modified during record correction."
1527
1539
  ),
1528
1540
  value: FieldReference.or(import_zod17.z.array(FieldReference)).optional().describe(
1529
- "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."
1541
+ "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."
1530
1542
  ),
1531
1543
  analytics: import_zod17.z.boolean().default(false).optional().describe(
1532
1544
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1537,7 +1549,7 @@ var Divider = BaseField.extend({
1537
1549
  });
1538
1550
  var TextField = BaseField.extend({
1539
1551
  type: import_zod17.z.literal(FieldType.TEXT),
1540
- defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField]).optional(),
1552
+ defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1541
1553
  configuration: import_zod17.z.object({
1542
1554
  maxLength: import_zod17.z.number().optional().describe("Maximum length of the text"),
1543
1555
  type: import_zod17.z.enum(["text", "password"]).optional(),
@@ -1547,7 +1559,7 @@ var TextField = BaseField.extend({
1547
1559
  }).describe("Text input");
1548
1560
  var NumberField = BaseField.extend({
1549
1561
  type: import_zod17.z.literal(FieldType.NUMBER),
1550
- defaultValue: NumberFieldValue.optional(),
1562
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1551
1563
  configuration: import_zod17.z.object({
1552
1564
  min: import_zod17.z.number().optional().describe("Minimum value"),
1553
1565
  max: import_zod17.z.number().optional().describe("Maximum value"),
@@ -1557,7 +1569,7 @@ var NumberField = BaseField.extend({
1557
1569
  }).describe("Number input");
1558
1570
  var TextAreaField = BaseField.extend({
1559
1571
  type: import_zod17.z.literal(FieldType.TEXTAREA),
1560
- defaultValue: NonEmptyTextValue.optional(),
1572
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1561
1573
  configuration: import_zod17.z.object({
1562
1574
  maxLength: import_zod17.z.number().optional().describe("Maximum length of the text"),
1563
1575
  rows: import_zod17.z.number().optional().describe("Number of visible text lines"),
@@ -1588,7 +1600,7 @@ var SignatureField = BaseField.extend({
1588
1600
  signaturePromptLabel: TranslationConfig.describe(
1589
1601
  "Title of the signature modal"
1590
1602
  ),
1591
- defaultValue: SignatureFieldValue.optional(),
1603
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1592
1604
  configuration: import_zod17.z.object({
1593
1605
  maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1594
1606
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1601,11 +1613,11 @@ var EmailField = BaseField.extend({
1601
1613
  configuration: import_zod17.z.object({
1602
1614
  maxLength: import_zod17.z.number().optional().describe("Maximum length of the text")
1603
1615
  }).default({ maxLength: 10 }).optional(),
1604
- defaultValue: NonEmptyTextValue.optional()
1616
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1605
1617
  });
1606
1618
  var DateField = BaseField.extend({
1607
1619
  type: import_zod17.z.literal(FieldType.DATE),
1608
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().openapi({ effectType: "input", type: "string" }).describe("Default date value(yyyy-MM-dd)"),
1620
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().openapi({ effectType: "input", type: "string" }).describe("Default date value(yyyy-MM-dd)"),
1609
1621
  configuration: import_zod17.z.object({
1610
1622
  notice: TranslationConfig.describe(
1611
1623
  "Text to display above the date input"
@@ -1614,7 +1626,7 @@ var DateField = BaseField.extend({
1614
1626
  }).describe("A single date input (yyyy-MM-dd)");
1615
1627
  var AgeField = BaseField.extend({
1616
1628
  type: import_zod17.z.literal(FieldType.AGE),
1617
- defaultValue: NumberFieldValue.optional(),
1629
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1618
1630
  configuration: import_zod17.z.object({
1619
1631
  asOfDate: FieldReference,
1620
1632
  prefix: TranslationConfig.optional(),
@@ -1623,7 +1635,7 @@ var AgeField = BaseField.extend({
1623
1635
  }).describe("An age input field which uses the current date as the asOfDate");
1624
1636
  var TimeField = BaseField.extend({
1625
1637
  type: import_zod17.z.literal(FieldType.TIME),
1626
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
1638
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().openapi({ effectType: "input", type: "object" }).describe("Default time value (HH-mm)"),
1627
1639
  configuration: import_zod17.z.object({
1628
1640
  use12HourFormat: import_zod17.z.boolean().optional().describe("Whether to use 12-hour format"),
1629
1641
  notice: TranslationConfig.describe(
@@ -1633,7 +1645,7 @@ var TimeField = BaseField.extend({
1633
1645
  }).describe("A single date input (HH-mm)");
1634
1646
  var DateRangeField = BaseField.extend({
1635
1647
  type: import_zod17.z.literal(FieldType.DATE_RANGE),
1636
- defaultValue: DateRangeFieldValue.optional(),
1648
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1637
1649
  configuration: import_zod17.z.object({
1638
1650
  notice: TranslationConfig.describe(
1639
1651
  "Text to display above the date input"
@@ -1660,16 +1672,14 @@ var ParagraphConfiguration = import_zod17.z.object({
1660
1672
  }).default({});
1661
1673
  var Paragraph = BaseField.extend({
1662
1674
  type: import_zod17.z.literal(FieldType.PARAGRAPH),
1663
- defaultValue: NonEmptyTextValue.optional(),
1664
1675
  configuration: ParagraphConfiguration
1665
1676
  }).describe("A read-only HTML <p> paragraph");
1666
1677
  var PageHeader = BaseField.extend({
1667
- type: import_zod17.z.literal(FieldType.PAGE_HEADER),
1668
- defaultValue: NonEmptyTextValue.optional()
1678
+ type: import_zod17.z.literal(FieldType.PAGE_HEADER)
1669
1679
  }).describe("A read-only header component for form pages");
1670
1680
  var File = BaseField.extend({
1671
1681
  type: import_zod17.z.literal(FieldType.FILE),
1672
- defaultValue: FileFieldValue.optional(),
1682
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1673
1683
  configuration: import_zod17.z.object({
1674
1684
  maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1675
1685
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1693,7 +1703,7 @@ var SelectOption = import_zod17.z.object({
1693
1703
  });
1694
1704
  var NumberWithUnitField = BaseField.extend({
1695
1705
  type: import_zod17.z.literal(FieldType.NUMBER_WITH_UNIT),
1696
- defaultValue: NumberWithUnitFieldValue.optional(),
1706
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1697
1707
  options: import_zod17.z.array(SelectOption).describe("A list of options for the unit select"),
1698
1708
  configuration: import_zod17.z.object({
1699
1709
  min: import_zod17.z.number().optional().describe("Minimum value of the number field"),
@@ -1705,7 +1715,7 @@ var NumberWithUnitField = BaseField.extend({
1705
1715
  }).describe("Number with unit input");
1706
1716
  var RadioGroup = BaseField.extend({
1707
1717
  type: import_zod17.z.literal(FieldType.RADIO_GROUP),
1708
- defaultValue: TextValue.optional(),
1718
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1709
1719
  options: import_zod17.z.array(SelectOption).describe("A list of options"),
1710
1720
  configuration: import_zod17.z.object({
1711
1721
  styles: import_zod17.z.object({
@@ -1715,7 +1725,6 @@ var RadioGroup = BaseField.extend({
1715
1725
  }).describe("Grouped radio options");
1716
1726
  var BulletList = BaseField.extend({
1717
1727
  type: import_zod17.z.literal(FieldType.BULLET_LIST),
1718
- defaultValue: TextValue.optional(),
1719
1728
  items: import_zod17.z.array(TranslationConfig).describe("A list of items"),
1720
1729
  configuration: import_zod17.z.object({
1721
1730
  styles: import_zod17.z.object({
@@ -1725,7 +1734,7 @@ var BulletList = BaseField.extend({
1725
1734
  }).describe("A list of bullet points");
1726
1735
  var Select = BaseField.extend({
1727
1736
  type: import_zod17.z.literal(FieldType.SELECT),
1728
- defaultValue: TextValue.optional(),
1737
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1729
1738
  options: import_zod17.z.array(SelectOption).describe("A list of options"),
1730
1739
  noOptionsMessage: TranslationConfig.optional().describe(
1731
1740
  `
@@ -1744,7 +1753,7 @@ var SelectDateRangeOption = import_zod17.z.object({
1744
1753
  });
1745
1754
  var SelectDateRangeField = BaseField.extend({
1746
1755
  type: import_zod17.z.literal(FieldType.SELECT_DATE_RANGE),
1747
- defaultValue: SelectDateRangeValue.optional(),
1756
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
1748
1757
  options: import_zod17.z.array(SelectDateRangeOption).describe("A list of options")
1749
1758
  }).describe("Select input with date range options");
1750
1759
  var NameConfig = import_zod17.z.object({
@@ -1758,7 +1767,7 @@ var NameField = BaseField.extend({
1758
1767
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
1759
1768
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
1760
1769
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
1761
- }).optional(),
1770
+ }).or(ComputedDefaultValue).optional(),
1762
1771
  configuration: import_zod17.z.object({
1763
1772
  name: NameConfig.default({
1764
1773
  firstname: { required: true },
@@ -1779,20 +1788,20 @@ var NameField = BaseField.extend({
1779
1788
  }).optional()
1780
1789
  }).describe("Name input field");
1781
1790
  var PhoneField = BaseField.extend({
1782
- defaultValue: NonEmptyTextValue.optional(),
1791
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1783
1792
  type: import_zod17.z.literal(FieldType.PHONE)
1784
1793
  }).describe("Phone input field");
1785
1794
  var IdField = BaseField.extend({
1786
- defaultValue: NonEmptyTextValue.optional(),
1795
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1787
1796
  type: import_zod17.z.literal(FieldType.ID)
1788
1797
  }).describe("ID input field");
1789
1798
  var Checkbox = BaseField.extend({
1790
1799
  type: import_zod17.z.literal(FieldType.CHECKBOX),
1791
- defaultValue: CheckboxFieldValue.default(false)
1800
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
1792
1801
  }).describe("Boolean checkbox field");
1793
1802
  var Country = BaseField.extend({
1794
1803
  type: import_zod17.z.literal(FieldType.COUNTRY),
1795
- defaultValue: NonEmptyTextValue.optional(),
1804
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1796
1805
  optionOverrides: import_zod17.z.array(SelectOption.omit({ label: true })).optional().describe(
1797
1806
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
1798
1807
  )
@@ -1808,12 +1817,12 @@ var AdministrativeAreaConfiguration = import_zod17.z.object({
1808
1817
  }).describe("Administrative area options");
1809
1818
  var AdministrativeArea = BaseField.extend({
1810
1819
  type: import_zod17.z.literal(FieldType.ADMINISTRATIVE_AREA),
1811
- defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField]).optional(),
1820
+ defaultValue: import_zod17.z.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1812
1821
  configuration: AdministrativeAreaConfiguration
1813
1822
  }).describe("Administrative area input field e.g. facility, office");
1814
1823
  var LocationInput = BaseField.extend({
1815
1824
  type: import_zod17.z.literal(FieldType.LOCATION),
1816
- defaultValue: NonEmptyTextValue.optional(),
1825
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1817
1826
  configuration: import_zod17.z.object({
1818
1827
  searchableResource: import_zod17.z.array(import_zod17.z.enum(["locations", "facilities", "offices"]))
1819
1828
  })
@@ -1821,7 +1830,7 @@ var LocationInput = BaseField.extend({
1821
1830
  var FileUploadWithOptions = BaseField.extend({
1822
1831
  type: import_zod17.z.literal(FieldType.FILE_WITH_OPTIONS),
1823
1832
  options: import_zod17.z.array(SelectOption).describe("A list of options"),
1824
- defaultValue: FileFieldWithOptionValue.optional(),
1833
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
1825
1834
  configuration: import_zod17.z.object({
1826
1835
  maxFileSize: import_zod17.z.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1827
1836
  maxImageSize: import_zod17.z.object({
@@ -1834,11 +1843,11 @@ var FileUploadWithOptions = BaseField.extend({
1834
1843
  });
1835
1844
  var Facility = BaseField.extend({
1836
1845
  type: import_zod17.z.literal(FieldType.FACILITY),
1837
- defaultValue: NonEmptyTextValue.optional()
1846
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1838
1847
  }).describe("Input field for a facility");
1839
1848
  var Office = BaseField.extend({
1840
1849
  type: import_zod17.z.literal(FieldType.OFFICE),
1841
- defaultValue: NonEmptyTextValue.optional()
1850
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1842
1851
  }).describe("Input field for an office");
1843
1852
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1844
1853
  administrativeArea: import_zod17.z.union([UUID, SerializedUserField]).optional()
@@ -1872,7 +1881,7 @@ var Address = BaseField.extend({
1872
1881
  })
1873
1882
  ).optional()
1874
1883
  }).optional(),
1875
- defaultValue: DefaultAddressFieldValue.optional()
1884
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1876
1885
  }).describe("Address input field \u2013 a combination of location and text fields");
1877
1886
  var StaticDataEntry = import_zod17.z.object({
1878
1887
  id: import_zod17.z.string().describe("ID for the data entry."),
@@ -1891,7 +1900,7 @@ var DataField = BaseField.extend({
1891
1900
  }).describe("Data field for displaying read-only data");
1892
1901
  var ButtonField = BaseField.extend({
1893
1902
  type: import_zod17.z.literal(FieldType.BUTTON),
1894
- defaultValue: ButtonFieldValue.optional(),
1903
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
1895
1904
  configuration: import_zod17.z.object({
1896
1905
  icon: import_zod17.z.string().optional().describe(
1897
1906
  "Icon for the button. You can find icons from OpenCRVS UI-Kit."
@@ -1916,7 +1925,7 @@ var AlphaPrintButton = BaseField.extend({
1916
1925
  }).describe("Print button field for printing certificates");
1917
1926
  var HttpField = BaseField.extend({
1918
1927
  type: import_zod17.z.literal(FieldType.HTTP),
1919
- defaultValue: HttpFieldValue.optional(),
1928
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
1920
1929
  configuration: import_zod17.z.object({
1921
1930
  trigger: FieldReference,
1922
1931
  url: import_zod17.z.string().describe("URL to send the HTTP request to"),
@@ -1971,7 +1980,7 @@ var LinkButtonField = BaseField.extend({
1971
1980
  }).describe("Button that opens a link");
1972
1981
  var VerificationStatus = BaseField.extend({
1973
1982
  type: import_zod17.z.literal(FieldType.VERIFICATION_STATUS),
1974
- defaultValue: VerificationStatusValue.optional(),
1983
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
1975
1984
  configuration: import_zod17.z.object({
1976
1985
  status: TranslationConfig.describe("Text to display on the status pill."),
1977
1986
  description: TranslationConfig.describe(
@@ -1989,7 +1998,7 @@ var QueryParamReaderField = BaseField.extend({
1989
1998
  );
1990
1999
  var QrReaderField = BaseField.extend({
1991
2000
  type: import_zod17.z.literal(FieldType.QR_READER),
1992
- defaultValue: QrReaderFieldValue.optional(),
2001
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
1993
2002
  configuration: import_zod17.z.object({
1994
2003
  validator: import_zod17.z.custom(
1995
2004
  (val) => typeof val === "object" && val !== null
@@ -1998,7 +2007,7 @@ var QrReaderField = BaseField.extend({
1998
2007
  });
1999
2008
  var IdReaderField = BaseField.extend({
2000
2009
  type: import_zod17.z.literal(FieldType.ID_READER),
2001
- defaultValue: IdReaderFieldValue.optional(),
2010
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2002
2011
  methods: import_zod17.z.array(
2003
2012
  import_zod17.z.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2004
2013
  )
@@ -2559,6 +2568,15 @@ function resolveDataPath(rootData, dataPath, instancePath) {
2559
2568
  }
2560
2569
  return current;
2561
2570
  }
2571
+ var compiledFunctionCache = /* @__PURE__ */ new Map();
2572
+ function compileClientFunction(code) {
2573
+ let fn = compiledFunctionCache.get(code);
2574
+ if (!fn) {
2575
+ fn = new Function(`return (${code})`)();
2576
+ compiledFunctionCache.set(code, fn);
2577
+ }
2578
+ return fn;
2579
+ }
2562
2580
  (0, import_ajv_formats.default)(ajv);
2563
2581
  ajv.addKeyword({
2564
2582
  keyword: "daysFromDate",
@@ -2604,12 +2622,23 @@ ajv.addKeyword({
2604
2622
  $data: true,
2605
2623
  errors: true,
2606
2624
  // @ts-ignore -- Force type. We will move this away from AJV next. Parsing the array will take seconds and is only called by core.
2607
- validate(schema, data, _2, dataContext) {
2625
+ validate(_schema, data, _2, dataContext) {
2608
2626
  const locationIdInput = data;
2609
2627
  const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
2610
2628
  return locations.some((location) => location.id === locationIdInput);
2611
2629
  }
2612
2630
  });
2631
+ ajv.addKeyword({
2632
+ keyword: "customClientValidator",
2633
+ schemaType: "object",
2634
+ errors: true,
2635
+ // @ts-ignore -- DataContext is not typed in AJV's public API
2636
+ validate(schema, data, _2, dataContext) {
2637
+ return Boolean(
2638
+ compileClientFunction(schema.code)(data, dataContext?.rootData)
2639
+ );
2640
+ }
2641
+ });
2613
2642
 
2614
2643
  // ../commons/src/utils.ts
2615
2644
  var z29 = __toESM(require("zod"));
@@ -3232,7 +3261,54 @@ function createFieldConditionals(fieldId) {
3232
3261
  }
3233
3262
  },
3234
3263
  required: [fieldId]
3235
- })
3264
+ }),
3265
+ /**
3266
+ * Custom client-side validator. The provided function is serialised and executed
3267
+ * just-in-time on the client only. External references (e.g. lodash) are not
3268
+ * available inside the function body — all logic must be self-contained.
3269
+ *
3270
+ * @example
3271
+ * field('nid').customClientValidator((value) => {
3272
+ * // LUHN check — all logic must be inline
3273
+ * const digits = String(value).split('').map(Number)
3274
+ * // ...
3275
+ * return isValid
3276
+ * })
3277
+ */
3278
+ customClientValidator(validationFn) {
3279
+ const code = validationFn.toString();
3280
+ return defineFormConditional({
3281
+ type: "object",
3282
+ properties: wrapToPath(
3283
+ { [fieldId]: { customClientValidator: { code } } },
3284
+ this.$$subfield
3285
+ ),
3286
+ required: [fieldId]
3287
+ });
3288
+ },
3289
+ /**
3290
+ * Custom client-side evaluation. Returns a {@link FieldReference} descriptor
3291
+ * that can be used as the `value` property or a DATA component entry.
3292
+ * The function receives the referenced field's value as the first argument and
3293
+ * the full form context as the second; its return value replaces the field reference.
3294
+ * The function is serialised and executed just-in-time on the client only.
3295
+ * External references (e.g. lodash) are not available inside the function body.
3296
+ *
3297
+ * For computing a default value without referencing a specific field, use
3298
+ * `evaluate(fn)` in the `defaultValue` property instead.
3299
+ *
3300
+ * @example
3301
+ * field('a').customClientEvaluation((aValue, ctx) =>
3302
+ * Number(aValue) + Number(ctx.$form.b)
3303
+ * )
3304
+ */
3305
+ customClientEvaluation(computationFn) {
3306
+ return {
3307
+ $$code: computationFn.toString(),
3308
+ $$field: fieldId,
3309
+ $$subfield: this.$$subfield
3310
+ };
3311
+ }
3236
3312
  };
3237
3313
  }
3238
3314
 
@@ -3804,6 +3880,8 @@ var BaseActionInput = import_zod34.z.object({
3804
3880
  originalActionId: UUID.optional(),
3805
3881
  // should not be part of base action.
3806
3882
  keepAssignment: import_zod34.z.boolean().optional(),
3883
+ keepAssignmentIfAccepted: import_zod34.z.boolean().optional(),
3884
+ keepAssignmentIfRejected: import_zod34.z.boolean().optional(),
3807
3885
  // For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
3808
3886
  createdAtLocation: CreatedAtLocation.describe(
3809
3887
  "A valid office location ID. This is required for system users performing actions. The provided location must be a leaf-location, i.e. it must not have any children locations."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.9.13-rc.2e6f2fb",
3
+ "version": "1.9.13-rc.309c8c5",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {
@@ -17,21 +17,21 @@
17
17
  "build:all": "lerna run build --include-dependencies --scope @opencrvs/toolkit && ./build.sh"
18
18
  },
19
19
  "dependencies": {
20
- "uuid": "^9.0.0",
20
+ "@trpc/client": "11.4.3",
21
+ "@trpc/server": "11.4.3",
21
22
  "ajv": "^8.17.1",
22
23
  "ajv-formats": "^3.0.1",
23
24
  "object-hash": "^3.0.0",
24
25
  "superjson": "1.9.0-0",
25
- "@trpc/client": "11.4.3",
26
- "@trpc/server": "11.4.3",
26
+ "uuid": "^9.0.0",
27
27
  "zod-openapi": "^4.2.4"
28
28
  },
29
29
  "devDependencies": {
30
+ "@opencrvs/events": "^1.9.0",
31
+ "@types/object-hash": "^3.0.6",
30
32
  "@types/uuid": "^9.0.3",
31
33
  "esbuild": "^0.24.0",
32
- "typescript": "^5.6.3",
33
- "@opencrvs/events": "^1.9.0",
34
- "@types/object-hash": "^3.0.6"
34
+ "typescript": "^5.6.3"
35
35
  },
36
36
  "moduleNameMapper": {
37
37
  "@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js",