Skip to content

Commit 87ac03f

Browse files
committed
fix: schema fixes & removed validation schema
1 parent c34b041 commit 87ac03f

File tree

10 files changed

+43
-19
lines changed

10 files changed

+43
-19
lines changed

packages/common/src/utils/collection-flow/schemas/elements/common/http-params.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const CommonHttpParamsSchema = z.object({
44
url: z.string(),
55
method: z.union([z.literal('GET'), z.literal('POST'), z.literal('PUT'), z.literal('DELETE')]),
66
resultPath: z.string(),
7-
headers: z.record(z.string(), z.string()),
7+
headers: z.record(z.string(), z.string()).optional(),
88
timeout: z.number().optional(),
9-
params: z.record(z.string(), z.any()),
9+
params: z.record(z.string(), z.any()).optional(),
1010
});

packages/common/src/utils/collection-flow/schemas/elements/common/option.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { z } from 'zod';
22

33
export const CommonOptionSchema = z.object({
44
label: z.string(),
5-
value: z.string(),
5+
value: z.string().optional(),
66
});
77

88
export type TCommonOption = z.infer<typeof CommonOptionSchema>;

packages/common/src/utils/collection-flow/schemas/elements/element.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ import {
5353
StatePickerFieldParamsSchema,
5454
TagsFieldElementType,
5555
TagsFieldParamsSchema,
56+
TaxIdPickerFieldElementType,
57+
TaxIdPickerFieldParamsSchema,
5658
TextFieldElementType,
5759
TextFieldParamsSchema,
5860
} from './fields';
@@ -74,13 +76,11 @@ export const BaseUIElementSchema = z.discriminatedUnion('element', [
7476
// UI Elements start
7577
BaseUIElement.extend({
7678
element: ColumnElementType,
77-
params: ColumnElementParamsSchema,
78-
children: z.array(BaseUIElement),
79+
params: ColumnElementParamsSchema.optional(),
7980
}),
8081
BaseUIElement.extend({
8182
element: RowElementType,
82-
params: RowElementParamsSchema,
83-
children: z.array(BaseUIElement),
83+
params: RowElementParamsSchema.optional(),
8484
}),
8585
BaseUIElement.extend({
8686
element: DescriptionElementType,
@@ -185,6 +185,10 @@ export const BaseUIElementSchema = z.discriminatedUnion('element', [
185185
element: StatePickerFieldElementType,
186186
params: StatePickerFieldParamsSchema,
187187
}),
188+
BaseUIElement.extend({
189+
element: TaxIdPickerFieldElementType,
190+
params: TaxIdPickerFieldParamsSchema,
191+
}),
188192
BaseUIElement.extend({
189193
element: SubmitButtonElementType,
190194
params: SubmitParamsSchema,
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { z } from 'zod';
2-
import { SelectFieldParamsSchema } from './selectfield';
2+
import { FieldSchema } from '../common';
3+
4+
export const CountryPickerFieldParamsSchema = FieldSchema.extend({
5+
optionNotFoundText: z.string().optional(),
6+
});
37

48
export const COUNTRY_PICKER_FIELD_ELEMENT_TYPE = 'countrypickerfield' as const;
59
export const CountryPickerFieldElementType = z.literal(COUNTRY_PICKER_FIELD_ELEMENT_TYPE);
610

7-
export const CountryPickerFieldParamsSchema = SelectFieldParamsSchema;
8-
911
export type TCountryPickerFieldParams = z.infer<typeof CountryPickerFieldParamsSchema>;

packages/common/src/utils/collection-flow/schemas/elements/fields/entityfieldgroup.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export const EntityFieldGroupParamsSchema = FieldListParamsSchema.extend({
2121
httpParams: CommonHttpParamsSchema,
2222
transform: z.string().optional(),
2323
}),
24-
uploadDocument: CommonHttpParamsSchema,
2524
deleteEntity: CommonHttpParamsSchema,
26-
deleteDocument: CommonHttpParamsSchema,
25+
uploadDocument: CommonHttpParamsSchema.optional(),
26+
deleteDocument: CommonHttpParamsSchema.optional(),
2727
}),
2828
});
2929

packages/common/src/utils/collection-flow/schemas/elements/fields/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ export * from './localepicker';
1818
export * from './mccpicker';
1919
export * from './nationalitypicker';
2020
export * from './statepicker';
21+
export * from './taxidpickerfield';
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { z } from 'zod';
2-
import { SelectFieldParamsSchema } from './selectfield';
2+
import { FieldSchema } from '../common';
33

44
export const MCC_PICKER_FIELD_ELEMENT_TYPE = 'mccpickerfield' as const;
55
export const MCCPickerFieldElementType = z.literal(MCC_PICKER_FIELD_ELEMENT_TYPE);
66

7-
export const MCCPickerFieldParamsSchema = SelectFieldParamsSchema;
7+
export const MCCPickerFieldParamsSchema = FieldSchema.extend({
8+
optionNotFoundText: z.string().optional(),
9+
});
810

911
export type TMCCPickerFieldParams = z.infer<typeof MCCPickerFieldParamsSchema>;
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { z } from 'zod';
2-
import { SelectFieldParamsSchema } from './selectfield';
2+
import { FieldSchema } from '../common';
33

44
export const NATIONALITY_PICKER_FIELD_ELEMENT_TYPE = 'nationalitypickerfield' as const;
55
export const NationalityPickerFieldElementType = z.literal(NATIONALITY_PICKER_FIELD_ELEMENT_TYPE);
66

7-
export const NationalityPickerFieldParamsSchema = SelectFieldParamsSchema;
7+
export const NationalityPickerFieldParamsSchema = FieldSchema.extend({
8+
optionNotFoundText: z.string().optional(),
9+
});
810

911
export type TNationalityPickerFieldParams = z.infer<typeof NationalityPickerFieldParamsSchema>;
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { z } from 'zod';
2-
import { SelectFieldParamsSchema } from './selectfield';
2+
import { FieldSchema } from '../common';
33

44
export const STATE_PICKER_FIELD_ELEMENT_TYPE = 'statepickerfield' as const;
55
export const StatePickerFieldElementType = z.literal(STATE_PICKER_FIELD_ELEMENT_TYPE);
66

7-
export const StatePickerFieldParamsSchema = SelectFieldParamsSchema.extend({
8-
countryCodePath: z.string().optional(),
7+
export const StatePickerFieldParamsSchema = FieldSchema.extend({
8+
countryCodePath: z.string(),
9+
optionNotFoundText: z.string().optional(),
910
});
1011

1112
export type TStatePickerFieldParams = z.infer<typeof StatePickerFieldParamsSchema>;
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { z } from 'zod';
2+
import { FieldSchema } from '../common';
3+
4+
export const TAX_ID_PICKER_FIELD_ELEMENT_TYPE = 'taxidpickerfield' as const;
5+
export const TaxIdPickerFieldElementType = z.literal(TAX_ID_PICKER_FIELD_ELEMENT_TYPE);
6+
7+
export const TaxIdPickerFieldParamsSchema = FieldSchema.extend({
8+
countryCodePath: z.string(),
9+
optionNotFoundText: z.string().optional(),
10+
});
11+
12+
export type TTaxIdPickerFieldParams = z.infer<typeof TaxIdPickerFieldParamsSchema>;

0 commit comments

Comments
 (0)