@opencrvs/toolkit 1.9.12 → 1.9.13-rc.00bb36c
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.
- package/dist/commons/api/router.d.ts +2508 -185
- package/dist/commons/conditionals/conditionals.d.ts +348 -4
- package/dist/commons/conditionals/validate.d.ts +42 -0
- package/dist/commons/events/ActionConfig.d.ts +28 -28
- package/dist/commons/events/ActionInput.d.ts +204 -0
- package/dist/commons/events/AdvancedSearchConfig.d.ts +48 -48
- package/dist/commons/events/CountryConfigQueryInput.d.ts +240 -240
- package/dist/commons/events/DeduplicationConfig.d.ts +2 -2
- package/dist/commons/events/Draft.d.ts +6 -0
- package/dist/commons/events/EventConfig.d.ts +61 -54
- package/dist/commons/events/EventIndex.d.ts +88 -88
- package/dist/commons/events/FieldConfig.d.ts +1619 -227
- package/dist/commons/events/WorkqueueConfig.d.ts +488 -488
- package/dist/commons/events/defineConfig.d.ts +8 -7
- package/dist/commons/events/field.d.ts +47 -1
- package/dist/commons/events/utils.d.ts +10 -178
- package/dist/conditionals/index.js +48 -1
- package/dist/events/index.js +189 -85
- package/dist/notification/index.js +150 -39
- package/package.json +11 -7
|
@@ -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("
|
|
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,7 +2568,37 @@ function resolveDataPath(rootData, dataPath, instancePath) {
|
|
|
2559
2568
|
}
|
|
2560
2569
|
return current;
|
|
2561
2570
|
}
|
|
2571
|
+
function todayISO() {
|
|
2572
|
+
return (0, import_date_fns.formatISO)(/* @__PURE__ */ new Date(), { representation: "date" });
|
|
2573
|
+
}
|
|
2574
|
+
var compiledFunctionCache = /* @__PURE__ */ new Map();
|
|
2575
|
+
function compileClientFunction(code) {
|
|
2576
|
+
let fn = compiledFunctionCache.get(code);
|
|
2577
|
+
if (!fn) {
|
|
2578
|
+
fn = new Function(`return (${code})`)();
|
|
2579
|
+
compiledFunctionCache.set(code, fn);
|
|
2580
|
+
}
|
|
2581
|
+
return fn;
|
|
2582
|
+
}
|
|
2562
2583
|
(0, import_ajv_formats.default)(ajv);
|
|
2584
|
+
function buildClientFunctionContext(input) {
|
|
2585
|
+
return {
|
|
2586
|
+
$form: input.form,
|
|
2587
|
+
$now: todayISO(),
|
|
2588
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
2589
|
+
$online: isOnline(),
|
|
2590
|
+
$user: input.validatorContext?.user,
|
|
2591
|
+
$event: input.validatorContext?.event,
|
|
2592
|
+
$leafAdminStructureLocationIds: input.validatorContext?.leafAdminStructureLocationIds ?? [],
|
|
2593
|
+
user: input.systemVariables?.user,
|
|
2594
|
+
$window: input.systemVariables?.$window,
|
|
2595
|
+
locations: input.locations,
|
|
2596
|
+
adminLevelIds: input.adminLevelIds
|
|
2597
|
+
};
|
|
2598
|
+
}
|
|
2599
|
+
function runClientFunction(code, data, context) {
|
|
2600
|
+
return compileClientFunction(code)(data, context);
|
|
2601
|
+
}
|
|
2563
2602
|
ajv.addKeyword({
|
|
2564
2603
|
keyword: "daysFromDate",
|
|
2565
2604
|
type: "string",
|
|
@@ -2604,12 +2643,35 @@ ajv.addKeyword({
|
|
|
2604
2643
|
$data: true,
|
|
2605
2644
|
errors: true,
|
|
2606
2645
|
// @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(
|
|
2646
|
+
validate(_schema, data, _2, dataContext) {
|
|
2608
2647
|
const locationIdInput = data;
|
|
2609
2648
|
const locations = dataContext?.rootData.$leafAdminStructureLocationIds ?? [];
|
|
2610
2649
|
return locations.some((location) => location.id === locationIdInput);
|
|
2611
2650
|
}
|
|
2612
2651
|
});
|
|
2652
|
+
ajv.addKeyword({
|
|
2653
|
+
keyword: "customClientValidator",
|
|
2654
|
+
schemaType: "object",
|
|
2655
|
+
errors: true,
|
|
2656
|
+
// @ts-expect-error -- AJV's public types don't expose `rootData`. All
|
|
2657
|
+
// `validate()` callers build root data via `buildClientFunctionContext`,
|
|
2658
|
+
// so the cast holds.
|
|
2659
|
+
validate(schema, data, _2, dataContext) {
|
|
2660
|
+
return Boolean(
|
|
2661
|
+
runClientFunction(
|
|
2662
|
+
schema.code,
|
|
2663
|
+
data,
|
|
2664
|
+
dataContext?.rootData ?? buildClientFunctionContext({ form: {} })
|
|
2665
|
+
)
|
|
2666
|
+
);
|
|
2667
|
+
}
|
|
2668
|
+
});
|
|
2669
|
+
function isOnline() {
|
|
2670
|
+
if (typeof window !== "undefined" && typeof navigator !== "undefined") {
|
|
2671
|
+
return navigator.onLine;
|
|
2672
|
+
}
|
|
2673
|
+
return true;
|
|
2674
|
+
}
|
|
2613
2675
|
|
|
2614
2676
|
// ../commons/src/utils.ts
|
|
2615
2677
|
var z29 = __toESM(require("zod"));
|
|
@@ -3232,7 +3294,54 @@ function createFieldConditionals(fieldId) {
|
|
|
3232
3294
|
}
|
|
3233
3295
|
},
|
|
3234
3296
|
required: [fieldId]
|
|
3235
|
-
})
|
|
3297
|
+
}),
|
|
3298
|
+
/**
|
|
3299
|
+
* Custom client-side validator. The provided function is serialised and executed
|
|
3300
|
+
* just-in-time on the client only. External references (e.g. lodash) are not
|
|
3301
|
+
* available inside the function body — all logic must be self-contained.
|
|
3302
|
+
*
|
|
3303
|
+
* @example
|
|
3304
|
+
* field('nid').customClientValidator((value) => {
|
|
3305
|
+
* // LUHN check — all logic must be inline
|
|
3306
|
+
* const digits = String(value).split('').map(Number)
|
|
3307
|
+
* // ...
|
|
3308
|
+
* return isValid
|
|
3309
|
+
* })
|
|
3310
|
+
*/
|
|
3311
|
+
customClientValidator(validationFn) {
|
|
3312
|
+
const code = validationFn.toString();
|
|
3313
|
+
return defineFormConditional({
|
|
3314
|
+
type: "object",
|
|
3315
|
+
properties: wrapToPath(
|
|
3316
|
+
{ [fieldId]: { customClientValidator: { code } } },
|
|
3317
|
+
this.$$subfield
|
|
3318
|
+
),
|
|
3319
|
+
required: [fieldId]
|
|
3320
|
+
});
|
|
3321
|
+
},
|
|
3322
|
+
/**
|
|
3323
|
+
* Custom client-side evaluation. Returns a {@link FieldReference} descriptor
|
|
3324
|
+
* that can be used as the `value` property or a DATA component entry.
|
|
3325
|
+
* The function receives the referenced field's value as the first argument and
|
|
3326
|
+
* the full form context as the second; its return value replaces the field reference.
|
|
3327
|
+
* The function is serialised and executed just-in-time on the client only.
|
|
3328
|
+
* External references (e.g. lodash) are not available inside the function body.
|
|
3329
|
+
*
|
|
3330
|
+
* For computing a default value without referencing a specific field, use
|
|
3331
|
+
* `evaluate(fn)` in the `defaultValue` property instead.
|
|
3332
|
+
*
|
|
3333
|
+
* @example
|
|
3334
|
+
* field('a').customClientEvaluation((aValue, ctx) =>
|
|
3335
|
+
* Number(aValue) + Number(ctx.$form.b)
|
|
3336
|
+
* )
|
|
3337
|
+
*/
|
|
3338
|
+
customClientEvaluation(computationFn) {
|
|
3339
|
+
return {
|
|
3340
|
+
$$code: computationFn.toString(),
|
|
3341
|
+
$$field: fieldId,
|
|
3342
|
+
$$subfield: this.$$subfield
|
|
3343
|
+
};
|
|
3344
|
+
}
|
|
3236
3345
|
};
|
|
3237
3346
|
}
|
|
3238
3347
|
|
|
@@ -3804,6 +3913,8 @@ var BaseActionInput = import_zod34.z.object({
|
|
|
3804
3913
|
originalActionId: UUID.optional(),
|
|
3805
3914
|
// should not be part of base action.
|
|
3806
3915
|
keepAssignment: import_zod34.z.boolean().optional(),
|
|
3916
|
+
keepAssignmentIfAccepted: import_zod34.z.boolean().optional(),
|
|
3917
|
+
keepAssignmentIfRejected: import_zod34.z.boolean().optional(),
|
|
3807
3918
|
// For normal users, the createdAtLocation is resolved on the backend from the user's primaryOfficeId.
|
|
3808
3919
|
createdAtLocation: CreatedAtLocation.describe(
|
|
3809
3920
|
"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.
|
|
3
|
+
"version": "1.9.13-rc.00bb36c",
|
|
4
4
|
"description": "OpenCRVS toolkit for building country configurations",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"exports": {
|
|
@@ -16,22 +16,26 @@
|
|
|
16
16
|
"build": "./build.sh",
|
|
17
17
|
"build:all": "lerna run build --include-dependencies --scope @opencrvs/toolkit && ./build.sh"
|
|
18
18
|
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/opencrvs/opencrvs-core.git"
|
|
22
|
+
},
|
|
19
23
|
"dependencies": {
|
|
20
|
-
"
|
|
24
|
+
"@trpc/client": "11.4.3",
|
|
25
|
+
"@trpc/server": "11.4.3",
|
|
21
26
|
"ajv": "^8.17.1",
|
|
22
27
|
"ajv-formats": "^3.0.1",
|
|
23
28
|
"object-hash": "^3.0.0",
|
|
24
29
|
"superjson": "1.9.0-0",
|
|
25
|
-
"
|
|
26
|
-
"@trpc/server": "11.4.3",
|
|
30
|
+
"uuid": "^9.0.0",
|
|
27
31
|
"zod-openapi": "^4.2.4"
|
|
28
32
|
},
|
|
29
33
|
"devDependencies": {
|
|
34
|
+
"@opencrvs/events": "^1.9.0",
|
|
35
|
+
"@types/object-hash": "^3.0.6",
|
|
30
36
|
"@types/uuid": "^9.0.3",
|
|
31
37
|
"esbuild": "^0.24.0",
|
|
32
|
-
"typescript": "^5.6.3"
|
|
33
|
-
"@opencrvs/events": "^1.9.0",
|
|
34
|
-
"@types/object-hash": "^3.0.6"
|
|
38
|
+
"typescript": "^5.6.3"
|
|
35
39
|
},
|
|
36
40
|
"moduleNameMapper": {
|
|
37
41
|
"@opencrvs/commons/events": "@opencrvs/commons/build/dist/common/events/index.js",
|