@opencrvs/toolkit 2.0.0-rc.c07ca60 → 2.0.0-rc.c0adb49

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.
@@ -353,6 +353,7 @@ var DateRangeFieldValue = z7.object({
353
353
  var EmailValue = z7.email();
354
354
  var CheckboxFieldValue = z7.boolean();
355
355
  var NumberFieldValue = z7.number();
356
+ var SignatureFieldValue = FileFieldValue;
356
357
  var ButtonFieldValue = z7.number();
357
358
  var VerificationStatusValue = z7.enum([
358
359
  "verified",
@@ -1410,8 +1411,18 @@ var FieldReference = import_v43.default.object({
1410
1411
  $$field: FieldId.describe("Id of the field to reference"),
1411
1412
  $$subfield: import_v43.default.array(import_v43.default.string()).optional().default([]).describe(
1412
1413
  'If the FieldValue is an object, subfield can be used to refer to e.g. `["foo", "bar"]` in `{ foo: { bar: 3 } }`'
1414
+ ),
1415
+ $$code: import_v43.default.string().optional().describe(
1416
+ "Serialised client-side function body. When present the expression is evaluated rather than dereferenced."
1417
+ )
1418
+ }).describe(
1419
+ "Reference to a field value, with an optional client-side computation applied."
1420
+ );
1421
+ var ComputedDefaultValue = import_v43.default.object({
1422
+ $$code: import_v43.default.string().describe(
1423
+ "Serialised client-side function body. Receives (undefined, context) where context includes $now, $online, and system variables."
1413
1424
  )
1414
- }).describe("Reference to a field by its ID");
1425
+ }).describe("A context-only computation used as a field default value.");
1415
1426
  var ValidationConfig = import_v43.default.object({
1416
1427
  validator: Conditional.describe(
1417
1428
  "Conditional expression that must hold for the field value to be considered valid."
@@ -1452,7 +1463,7 @@ var BaseField = import_v43.default.object({
1452
1463
  "Indicates whether the field can be modified during record correction."
1453
1464
  ),
1454
1465
  value: FieldReference.or(import_v43.default.array(FieldReference)).optional().describe(
1455
- "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."
1466
+ "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."
1456
1467
  ),
1457
1468
  analytics: import_v43.default.boolean().default(false).optional().describe(
1458
1469
  "Indicates whether the field is included in analytics. When enabled, its value becomes available in the analytics dashboard."
@@ -1466,7 +1477,7 @@ var Divider = BaseField.extend({
1466
1477
  });
1467
1478
  var TextField = BaseField.extend({
1468
1479
  type: import_v43.default.literal(FieldType.TEXT),
1469
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1480
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1470
1481
  configuration: import_v43.default.object({
1471
1482
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1472
1483
  type: import_v43.default.enum(["text", "password"]).optional(),
@@ -1479,7 +1490,7 @@ var TextField = BaseField.extend({
1479
1490
  });
1480
1491
  var NumberField = BaseField.extend({
1481
1492
  type: import_v43.default.literal(FieldType.NUMBER),
1482
- defaultValue: NumberFieldValue.optional(),
1493
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1483
1494
  configuration: import_v43.default.object({
1484
1495
  min: import_v43.default.number().optional().describe("Minimum value"),
1485
1496
  max: import_v43.default.number().optional().describe("Maximum value"),
@@ -1492,7 +1503,7 @@ var NumberField = BaseField.extend({
1492
1503
  });
1493
1504
  var TextAreaField = BaseField.extend({
1494
1505
  type: import_v43.default.literal(FieldType.TEXTAREA),
1495
- defaultValue: NonEmptyTextValue.optional(),
1506
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1496
1507
  configuration: import_v43.default.object({
1497
1508
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text"),
1498
1509
  rows: import_v43.default.number().optional().describe("Number of visible text lines"),
@@ -1526,7 +1537,7 @@ var SignatureField = BaseField.extend({
1526
1537
  signaturePromptLabel: TranslationConfig.describe(
1527
1538
  "Title of the signature modal"
1528
1539
  ),
1529
- defaultValue: FieldValue.optional(),
1540
+ defaultValue: SignatureFieldValue.or(ComputedDefaultValue).optional(),
1530
1541
  configuration: import_v43.default.object({
1531
1542
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1532
1543
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature")
@@ -1542,14 +1553,14 @@ var EmailField = BaseField.extend({
1542
1553
  configuration: import_v43.default.object({
1543
1554
  maxLength: import_v43.default.number().optional().describe("Maximum length of the text")
1544
1555
  }).default({ maxLength: 255 }).optional(),
1545
- defaultValue: NonEmptyTextValue.optional()
1556
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional()
1546
1557
  }).meta({
1547
1558
  description: "An email input field",
1548
1559
  id: "EmailField"
1549
1560
  });
1550
1561
  var DateField = BaseField.extend({
1551
1562
  type: import_v43.default.literal(FieldType.DATE),
1552
- defaultValue: SerializedNowDateTime.or(PlainDate).optional().describe("Default date value(yyyy-MM-dd)"),
1563
+ defaultValue: SerializedNowDateTime.or(PlainDate).or(ComputedDefaultValue).optional().describe("Default date value(yyyy-MM-dd)"),
1553
1564
  configuration: import_v43.default.object({
1554
1565
  notice: TranslationConfig.describe(
1555
1566
  "Text to display above the date input"
@@ -1561,7 +1572,7 @@ var DateField = BaseField.extend({
1561
1572
  });
1562
1573
  var AgeField = BaseField.extend({
1563
1574
  type: import_v43.default.literal(FieldType.AGE),
1564
- defaultValue: NumberFieldValue.optional(),
1575
+ defaultValue: NumberFieldValue.or(ComputedDefaultValue).optional(),
1565
1576
  configuration: import_v43.default.object({
1566
1577
  asOfDate: FieldReference,
1567
1578
  prefix: TranslationConfig.optional(),
@@ -1573,7 +1584,7 @@ var AgeField = BaseField.extend({
1573
1584
  });
1574
1585
  var TimeField = BaseField.extend({
1575
1586
  type: import_v43.default.literal(FieldType.TIME),
1576
- defaultValue: SerializedNowDateTime.or(TimeValue).optional().describe("Default time value (HH-mm)"),
1587
+ defaultValue: SerializedNowDateTime.or(TimeValue).or(ComputedDefaultValue).optional().describe("Default time value (HH-mm)"),
1577
1588
  configuration: import_v43.default.object({
1578
1589
  use12HourFormat: import_v43.default.boolean().optional().describe("Whether to use 12-hour format"),
1579
1590
  notice: TranslationConfig.describe(
@@ -1586,7 +1597,7 @@ var TimeField = BaseField.extend({
1586
1597
  });
1587
1598
  var DateRangeField = BaseField.extend({
1588
1599
  type: import_v43.default.literal(FieldType.DATE_RANGE),
1589
- defaultValue: DateRangeFieldValue.optional(),
1600
+ defaultValue: DateRangeFieldValue.or(ComputedDefaultValue).optional(),
1590
1601
  configuration: import_v43.default.object({
1591
1602
  notice: TranslationConfig.describe(
1592
1603
  "Text to display above the date input"
@@ -1665,7 +1676,7 @@ var PageHeader = BaseField.extend({
1665
1676
  });
1666
1677
  var File = BaseField.extend({
1667
1678
  type: import_v43.default.literal(FieldType.FILE),
1668
- defaultValue: FileFieldValue.optional(),
1679
+ defaultValue: FileFieldValue.or(ComputedDefaultValue).optional(),
1669
1680
  configuration: import_v43.default.object({
1670
1681
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1671
1682
  acceptedFileTypes: MimeType.array().optional().describe("List of allowed file formats for the signature"),
@@ -1692,7 +1703,7 @@ var SelectOption = import_v43.default.object({
1692
1703
  });
1693
1704
  var NumberWithUnitField = BaseField.extend({
1694
1705
  type: import_v43.default.literal(FieldType.NUMBER_WITH_UNIT),
1695
- defaultValue: NumberWithUnitFieldValue.optional(),
1706
+ defaultValue: NumberWithUnitFieldValue.or(ComputedDefaultValue).optional(),
1696
1707
  options: import_v43.default.array(SelectOption).describe("A list of options for the unit select"),
1697
1708
  configuration: import_v43.default.object({
1698
1709
  min: import_v43.default.number().optional().describe("Minimum value of the number field"),
@@ -1707,7 +1718,7 @@ var NumberWithUnitField = BaseField.extend({
1707
1718
  });
1708
1719
  var RadioGroup = BaseField.extend({
1709
1720
  type: import_v43.default.literal(FieldType.RADIO_GROUP),
1710
- defaultValue: TextValue.optional(),
1721
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1711
1722
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1712
1723
  configuration: import_v43.default.object({
1713
1724
  styles: import_v43.default.object({
@@ -1732,7 +1743,7 @@ var BulletList = BaseField.extend({
1732
1743
  });
1733
1744
  var Select = BaseField.extend({
1734
1745
  type: import_v43.default.literal(FieldType.SELECT),
1735
- defaultValue: TextValue.optional(),
1746
+ defaultValue: TextValue.or(ComputedDefaultValue).optional(),
1736
1747
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1737
1748
  noOptionsMessage: TranslationConfig.optional().describe(
1738
1749
  `
@@ -1754,7 +1765,7 @@ var SelectDateRangeOption = import_v43.default.object({
1754
1765
  });
1755
1766
  var SelectDateRangeField = BaseField.extend({
1756
1767
  type: import_v43.default.literal(FieldType.SELECT_DATE_RANGE),
1757
- defaultValue: SelectDateRangeValue.optional(),
1768
+ defaultValue: SelectDateRangeValue.or(ComputedDefaultValue).optional(),
1758
1769
  options: import_v43.default.array(SelectDateRangeOption).describe("A list of options")
1759
1770
  }).meta({
1760
1771
  description: "A date range selection field",
@@ -1771,7 +1782,7 @@ var NameField = BaseField.extend({
1771
1782
  firstname: SerializedUserField.or(NonEmptyTextValue).optional(),
1772
1783
  middlename: SerializedUserField.or(NonEmptyTextValue).optional(),
1773
1784
  surname: SerializedUserField.or(NonEmptyTextValue).optional()
1774
- }).optional(),
1785
+ }).or(ComputedDefaultValue).optional(),
1775
1786
  configuration: import_v43.default.object({
1776
1787
  name: NameConfig.default({
1777
1788
  firstname: { required: true },
@@ -1795,14 +1806,14 @@ var NameField = BaseField.extend({
1795
1806
  id: "NameField"
1796
1807
  });
1797
1808
  var PhoneField = BaseField.extend({
1798
- defaultValue: NonEmptyTextValue.optional(),
1809
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1799
1810
  type: import_v43.default.literal(FieldType.PHONE)
1800
1811
  }).meta({
1801
1812
  description: "A field for entering a phone number",
1802
1813
  id: "PhoneField"
1803
1814
  });
1804
1815
  var IdField = BaseField.extend({
1805
- defaultValue: NonEmptyTextValue.optional(),
1816
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1806
1817
  type: import_v43.default.literal(FieldType.ID)
1807
1818
  }).meta({
1808
1819
  description: "A field for entering an ID",
@@ -1810,14 +1821,14 @@ var IdField = BaseField.extend({
1810
1821
  });
1811
1822
  var Checkbox = BaseField.extend({
1812
1823
  type: import_v43.default.literal(FieldType.CHECKBOX),
1813
- defaultValue: CheckboxFieldValue.default(false)
1824
+ defaultValue: CheckboxFieldValue.or(ComputedDefaultValue).default(false)
1814
1825
  }).meta({
1815
1826
  description: "A boolean checkbox field",
1816
1827
  id: "Checkbox"
1817
1828
  });
1818
1829
  var Country = BaseField.extend({
1819
1830
  type: import_v43.default.literal(FieldType.COUNTRY),
1820
- defaultValue: NonEmptyTextValue.optional(),
1831
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1821
1832
  optionOverrides: import_v43.default.array(SelectOption.omit({ label: true })).optional().describe(
1822
1833
  "Conditionals for specific countries. Countries not listed are always shown and enabled."
1823
1834
  )
@@ -1835,7 +1846,7 @@ var AdministrativeAreas = import_v43.default.enum([
1835
1846
  ]);
1836
1847
  var AdministrativeAreaField = BaseField.extend({
1837
1848
  type: import_v43.default.literal(FieldType.ADMINISTRATIVE_AREA),
1838
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1849
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1839
1850
  configuration: import_v43.default.object({
1840
1851
  partOf: FieldReference.optional().describe("Parent location"),
1841
1852
  type: AdministrativeAreas,
@@ -1847,7 +1858,7 @@ var AdministrativeAreaField = BaseField.extend({
1847
1858
  });
1848
1859
  var LocationInput = BaseField.extend({
1849
1860
  type: import_v43.default.literal(FieldType.LOCATION),
1850
- defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField]).optional(),
1861
+ defaultValue: import_v43.default.union([NonEmptyTextValue, SerializedUserField, ComputedDefaultValue]).optional(),
1851
1862
  configuration: import_v43.default.object({
1852
1863
  locationTypes: import_v43.default.array(import_v43.default.string()).optional().describe("Types of the locations that are available for selection."),
1853
1864
  allowedLocations: AllowedLocations
@@ -1859,7 +1870,7 @@ var LocationInput = BaseField.extend({
1859
1870
  var FileUploadWithOptions = BaseField.extend({
1860
1871
  type: import_v43.default.literal(FieldType.FILE_WITH_OPTIONS),
1861
1872
  options: import_v43.default.array(SelectOption).describe("A list of options"),
1862
- defaultValue: FileFieldWithOptionValue.optional(),
1873
+ defaultValue: FileFieldWithOptionValue.or(ComputedDefaultValue).optional(),
1863
1874
  configuration: import_v43.default.object({
1864
1875
  maxFileSize: import_v43.default.number().describe("Maximum file size in bytes").default(DEFAULT_MAX_FILE_SIZE_BYTES),
1865
1876
  maxImageSize: import_v43.default.object({
@@ -1875,12 +1886,12 @@ var FileUploadWithOptions = BaseField.extend({
1875
1886
  });
1876
1887
  var Facility = BaseField.extend({
1877
1888
  type: import_v43.default.literal(FieldType.FACILITY),
1878
- defaultValue: NonEmptyTextValue.optional(),
1889
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1879
1890
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1880
1891
  }).describe("Input field for a facility");
1881
1892
  var Office = BaseField.extend({
1882
1893
  type: import_v43.default.literal(FieldType.OFFICE),
1883
- defaultValue: NonEmptyTextValue.optional(),
1894
+ defaultValue: NonEmptyTextValue.or(ComputedDefaultValue).optional(),
1884
1895
  configuration: import_v43.default.object({ allowedLocations: AllowedLocations }).optional()
1885
1896
  }).describe("Input field for an office");
1886
1897
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
@@ -1916,7 +1927,7 @@ var Address = BaseField.extend({
1916
1927
  ).optional(),
1917
1928
  allowedLocations: AllowedLocations
1918
1929
  }).optional(),
1919
- defaultValue: DefaultAddressFieldValue.optional()
1930
+ defaultValue: DefaultAddressFieldValue.or(ComputedDefaultValue).optional()
1920
1931
  }).meta({
1921
1932
  description: "Address input field \u2013 a combination of location and text fields",
1922
1933
  id: "Address"
@@ -1963,7 +1974,7 @@ var ButtonConfiguration = import_v43.default.object({
1963
1974
  });
1964
1975
  var ButtonField = BaseField.extend({
1965
1976
  type: import_v43.default.literal(FieldType.BUTTON),
1966
- defaultValue: ButtonFieldValue.optional(),
1977
+ defaultValue: ButtonFieldValue.or(ComputedDefaultValue).optional(),
1967
1978
  configuration: ButtonConfiguration
1968
1979
  }).meta({
1969
1980
  description: "A generic button that can be used to trigger an action",
@@ -1991,7 +2002,7 @@ var AlphaPrintButton = BaseField.extend({
1991
2002
  });
1992
2003
  var HttpField = BaseField.extend({
1993
2004
  type: import_v43.default.literal(FieldType.HTTP),
1994
- defaultValue: HttpFieldValue.optional(),
2005
+ defaultValue: HttpFieldValue.or(ComputedDefaultValue).optional(),
1995
2006
  configuration: import_v43.default.object({
1996
2007
  trigger: FieldReference.optional().describe(
1997
2008
  "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."
@@ -2077,7 +2088,7 @@ var LinkButtonField = BaseField.extend({
2077
2088
  });
2078
2089
  var VerificationStatus = BaseField.extend({
2079
2090
  type: import_v43.default.literal(FieldType.VERIFICATION_STATUS),
2080
- defaultValue: VerificationStatusValue.optional(),
2091
+ defaultValue: VerificationStatusValue.or(ComputedDefaultValue).optional(),
2081
2092
  configuration: import_v43.default.object({
2082
2093
  status: TranslationConfig.describe("Text to display on the status pill."),
2083
2094
  description: TranslationConfig.describe(
@@ -2099,7 +2110,7 @@ var QueryParamReaderField = BaseField.extend({
2099
2110
  });
2100
2111
  var QrReaderField = BaseField.extend({
2101
2112
  type: import_v43.default.literal(FieldType.QR_READER),
2102
- defaultValue: QrReaderFieldValue.optional(),
2113
+ defaultValue: QrReaderFieldValue.or(ComputedDefaultValue).optional(),
2103
2114
  configuration: import_v43.default.object({
2104
2115
  validator: import_v43.default.any().meta({
2105
2116
  description: "JSON Schema to validate the scanned QR code data against before populating the form fields.",
@@ -2112,7 +2123,7 @@ var QrReaderField = BaseField.extend({
2112
2123
  });
2113
2124
  var IdReaderField = BaseField.extend({
2114
2125
  type: import_v43.default.literal(FieldType.ID_READER),
2115
- defaultValue: IdReaderFieldValue.optional(),
2126
+ defaultValue: IdReaderFieldValue.or(ComputedDefaultValue).optional(),
2116
2127
  methods: import_v43.default.array(
2117
2128
  import_v43.default.union([QrReaderField, LinkButtonField]).describe("Methods for reading an ID")
2118
2129
  )
@@ -2273,6 +2284,8 @@ var ClientConfig = z20.object({
2273
2284
  COUNTRY: z20.string(),
2274
2285
  LANGUAGES: z20.array(z20.string()),
2275
2286
  SENTRY: z20.string().optional(),
2287
+ LOGIN_URL: z20.string().optional(),
2288
+ MINIO_BASE_URL: z20.string(),
2276
2289
  REGISTER_BACKGROUND: BackgroundConfig,
2277
2290
  DASHBOARDS: z20.array(
2278
2291
  z20.object({
@@ -74,6 +74,8 @@ export declare const ClientConfig: z.ZodObject<{
74
74
  COUNTRY: z.ZodString;
75
75
  LANGUAGES: z.ZodArray<z.ZodString>;
76
76
  SENTRY: z.ZodOptional<z.ZodString>;
77
+ LOGIN_URL: z.ZodOptional<z.ZodString>;
78
+ MINIO_BASE_URL: z.ZodString;
77
79
  REGISTER_BACKGROUND: z.ZodObject<{
78
80
  backgroundColor: z.ZodOptional<z.ZodString>;
79
81
  backgroundImage: z.ZodOptional<z.ZodString>;