@opencrvs/toolkit 1.9.12-rc.fd4afc3 → 1.9.13-rc.04ec9c3

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.
@@ -176,6 +176,13 @@ export declare const defineConfig: (config: EventConfigInput) => {
176
176
  options?: {
177
177
  value: string;
178
178
  label: string | import("./TranslationConfig").TranslationConfig;
179
+ conditionals?: ({
180
+ type: "SHOW";
181
+ conditional: import(".").JSONSchema;
182
+ } | {
183
+ type: "ENABLE";
184
+ conditional: import(".").JSONSchema;
185
+ })[] | undefined;
179
186
  }[] | undefined;
180
187
  label?: import("./TranslationConfig").TranslationConfig | undefined;
181
188
  conditionals?: ({
@@ -204,6 +211,13 @@ export declare const defineConfig: (config: EventConfigInput) => {
204
211
  options?: {
205
212
  value: string;
206
213
  label: string | import("./TranslationConfig").TranslationConfig;
214
+ conditionals?: ({
215
+ type: "SHOW";
216
+ conditional: import(".").JSONSchema;
217
+ } | {
218
+ type: "ENABLE";
219
+ conditional: import(".").JSONSchema;
220
+ })[] | undefined;
207
221
  }[] | undefined;
208
222
  label?: import("./TranslationConfig").TranslationConfig | undefined;
209
223
  conditionals?: ({
@@ -554,6 +554,13 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
554
554
  options?: {
555
555
  value: string;
556
556
  label: string | import("./TranslationConfig").TranslationConfig;
557
+ conditionals?: ({
558
+ type: "SHOW";
559
+ conditional: import(".").JSONSchema;
560
+ } | {
561
+ type: "ENABLE";
562
+ conditional: import(".").JSONSchema;
563
+ })[] | undefined;
557
564
  }[] | undefined;
558
565
  label?: import("./TranslationConfig").TranslationConfig | undefined;
559
566
  conditionals?: ({
@@ -582,6 +589,13 @@ export declare function getEventConfigById(eventConfigs: EventConfig[], id: stri
582
589
  options?: {
583
590
  value: string;
584
591
  label: string | import("./TranslationConfig").TranslationConfig;
592
+ conditionals?: ({
593
+ type: "SHOW";
594
+ conditional: import(".").JSONSchema;
595
+ } | {
596
+ type: "ENABLE";
597
+ conditional: import(".").JSONSchema;
598
+ })[] | undefined;
585
599
  }[] | undefined;
586
600
  label?: import("./TranslationConfig").TranslationConfig | undefined;
587
601
  conditionals?: ({
@@ -2182,7 +2182,8 @@ var File = BaseField.extend({
2182
2182
  }).describe("File upload");
2183
2183
  var SelectOption = import_zod17.z.object({
2184
2184
  value: import_zod17.z.string().describe("The value of the option"),
2185
- label: import_zod17.z.union([import_zod17.z.string(), TranslationConfig]).describe("The label of the option")
2185
+ label: import_zod17.z.union([import_zod17.z.string(), TranslationConfig]).describe("The label of the option"),
2186
+ conditionals: import_zod17.z.array(ActionConditional).default([]).optional()
2186
2187
  });
2187
2188
  var NumberWithUnitField = BaseField.extend({
2188
2189
  type: import_zod17.z.literal(FieldType.NUMBER_WITH_UNIT),
@@ -2285,7 +2286,10 @@ var Checkbox = BaseField.extend({
2285
2286
  }).describe("Boolean checkbox field");
2286
2287
  var Country = BaseField.extend({
2287
2288
  type: import_zod17.z.literal(FieldType.COUNTRY),
2288
- defaultValue: NonEmptyTextValue.optional()
2289
+ defaultValue: NonEmptyTextValue.optional(),
2290
+ optionOverrides: import_zod17.z.array(SelectOption.omit({ label: true })).optional().describe(
2291
+ "Conditionals for specific countries. Countries not listed are always shown and enabled."
2292
+ )
2289
2293
  }).describe("Country select field");
2290
2294
  var AdministrativeAreas = import_zod17.z.enum([
2291
2295
  "ADMIN_STRUCTURE",
@@ -2333,28 +2337,19 @@ var Office = BaseField.extend({
2333
2337
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
2334
2338
  administrativeArea: import_zod17.z.union([UUID, SerializedUserField]).optional()
2335
2339
  });
2336
- var DomesticAddressField = import_zod17.z.string().or(
2337
- BaseField.pick({
2338
- id: true,
2339
- required: true,
2340
- conditionals: true
2341
- }).extend({
2342
- type: import_zod17.z.union([
2343
- import_zod17.z.literal(FieldType.ADMINISTRATIVE_AREA),
2344
- import_zod17.z.literal(FieldType.COUNTRY)
2345
- ])
2346
- })
2347
- ).transform((val) => {
2348
- if (typeof val === "string") {
2349
- return {
2350
- id: val,
2351
- type: val === "country" ? FieldType.COUNTRY : FieldType.ADMINISTRATIVE_AREA,
2352
- required: true,
2353
- conditionals: []
2354
- };
2355
- }
2356
- return val;
2357
- }).openapi({ effectType: "input", type: "string" });
2340
+ var commonDomesticFieldProps = {
2341
+ id: true,
2342
+ type: true,
2343
+ label: true,
2344
+ conditionals: true,
2345
+ required: true
2346
+ };
2347
+ var DomesticAddressField = Country.partial().pick({
2348
+ ...commonDomesticFieldProps,
2349
+ optionOverrides: true
2350
+ }).required({ id: true, type: true }).or(
2351
+ AdministrativeArea.partial().pick(commonDomesticFieldProps).required({ id: true, type: true })
2352
+ );
2358
2353
  var Address = BaseField.extend({
2359
2354
  type: import_zod17.z.literal(FieldType.ADDRESS),
2360
2355
  configuration: import_zod17.z.object({
@@ -1688,7 +1688,8 @@ var File = BaseField.extend({
1688
1688
  }).describe("File upload");
1689
1689
  var SelectOption = import_zod17.z.object({
1690
1690
  value: import_zod17.z.string().describe("The value of the option"),
1691
- label: import_zod17.z.union([import_zod17.z.string(), TranslationConfig]).describe("The label of the option")
1691
+ label: import_zod17.z.union([import_zod17.z.string(), TranslationConfig]).describe("The label of the option"),
1692
+ conditionals: import_zod17.z.array(ActionConditional).default([]).optional()
1692
1693
  });
1693
1694
  var NumberWithUnitField = BaseField.extend({
1694
1695
  type: import_zod17.z.literal(FieldType.NUMBER_WITH_UNIT),
@@ -1791,7 +1792,10 @@ var Checkbox = BaseField.extend({
1791
1792
  }).describe("Boolean checkbox field");
1792
1793
  var Country = BaseField.extend({
1793
1794
  type: import_zod17.z.literal(FieldType.COUNTRY),
1794
- defaultValue: NonEmptyTextValue.optional()
1795
+ defaultValue: NonEmptyTextValue.optional(),
1796
+ optionOverrides: import_zod17.z.array(SelectOption.omit({ label: true })).optional().describe(
1797
+ "Conditionals for specific countries. Countries not listed are always shown and enabled."
1798
+ )
1795
1799
  }).describe("Country select field");
1796
1800
  var AdministrativeAreas = import_zod17.z.enum([
1797
1801
  "ADMIN_STRUCTURE",
@@ -1839,28 +1843,19 @@ var Office = BaseField.extend({
1839
1843
  var DefaultAddressFieldValue = DomesticAddressFieldValue.extend({
1840
1844
  administrativeArea: import_zod17.z.union([UUID, SerializedUserField]).optional()
1841
1845
  });
1842
- var DomesticAddressField = import_zod17.z.string().or(
1843
- BaseField.pick({
1844
- id: true,
1845
- required: true,
1846
- conditionals: true
1847
- }).extend({
1848
- type: import_zod17.z.union([
1849
- import_zod17.z.literal(FieldType.ADMINISTRATIVE_AREA),
1850
- import_zod17.z.literal(FieldType.COUNTRY)
1851
- ])
1852
- })
1853
- ).transform((val) => {
1854
- if (typeof val === "string") {
1855
- return {
1856
- id: val,
1857
- type: val === "country" ? FieldType.COUNTRY : FieldType.ADMINISTRATIVE_AREA,
1858
- required: true,
1859
- conditionals: []
1860
- };
1861
- }
1862
- return val;
1863
- }).openapi({ effectType: "input", type: "string" });
1846
+ var commonDomesticFieldProps = {
1847
+ id: true,
1848
+ type: true,
1849
+ label: true,
1850
+ conditionals: true,
1851
+ required: true
1852
+ };
1853
+ var DomesticAddressField = Country.partial().pick({
1854
+ ...commonDomesticFieldProps,
1855
+ optionOverrides: true
1856
+ }).required({ id: true, type: true }).or(
1857
+ AdministrativeArea.partial().pick(commonDomesticFieldProps).required({ id: true, type: true })
1858
+ );
1864
1859
  var Address = BaseField.extend({
1865
1860
  type: import_zod17.z.literal(FieldType.ADDRESS),
1866
1861
  configuration: import_zod17.z.object({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrvs/toolkit",
3
- "version": "1.9.12-rc.fd4afc3",
3
+ "version": "1.9.13-rc.04ec9c3",
4
4
  "description": "OpenCRVS toolkit for building country configurations",
5
5
  "license": "MPL-2.0",
6
6
  "exports": {