@dmptool/types 1.1.0 → 1.1.1
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/README.md +2 -0
- package/dist/answers/__tests__/answers.spec.js +2 -2
- package/dist/answers/index.d.ts +38 -38
- package/dist/answers/index.js +2 -2
- package/dist/answers/numberAnswers.d.ts +0 -25
- package/dist/answers/numberAnswers.js +1 -5
- package/dist/answers/optionBasedAnswers.d.ts +25 -0
- package/dist/answers/optionBasedAnswers.js +5 -1
- package/dist/answers/tableAnswers.d.ts +72 -72
- package/dist/answers/tableAnswers.js +1 -1
- package/dist/questions/__tests__/numberQuestions.spec.js +0 -48
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +50 -0
- package/dist/questions/index.d.ts +219 -58
- package/dist/questions/index.js +3 -2
- package/dist/questions/numberQuestions.d.ts +0 -51
- package/dist/questions/numberQuestions.js +1 -7
- package/dist/questions/optionBasedQuestions.d.ts +51 -0
- package/dist/questions/optionBasedQuestions.js +7 -1
- package/dist/questions/tableQuestions.d.ts +84 -84
- package/dist/questions/tableQuestions.js +1 -1
- package/dist/schemas/anyQuestion.schema.json +42 -9
- package/dist/schemas/anyTableColumnQuestion.schema.json +2 -1
- package/dist/schemas/booleanQuestion.schema.json +2 -1
- package/dist/schemas/tableQuestion.schema.json +2 -1
- package/package.json +1 -1
|
@@ -2,6 +2,56 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const globals_1 = require("@jest/globals");
|
|
4
4
|
const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
5
|
+
(0, globals_1.describe)("BooleanQuestion", () => {
|
|
6
|
+
(0, globals_1.it)('optional fields should not throw an error if the value is undefined', () => {
|
|
7
|
+
const validBooleanQuestion = {
|
|
8
|
+
type: "boolean",
|
|
9
|
+
meta: {
|
|
10
|
+
schemaVersion: "1.0",
|
|
11
|
+
},
|
|
12
|
+
attributes: {
|
|
13
|
+
checked: undefined, // Valid value
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
17
|
+
});
|
|
18
|
+
(0, globals_1.it)('optional fields should throw an error if the value is null', () => {
|
|
19
|
+
const invalidBooleanQuestion = {
|
|
20
|
+
type: "boolean",
|
|
21
|
+
meta: {
|
|
22
|
+
schemaVersion: "1.0",
|
|
23
|
+
},
|
|
24
|
+
attributes: {
|
|
25
|
+
checked: null, // Invalid value
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
|
|
29
|
+
});
|
|
30
|
+
(0, globals_1.it)("should validate a valid BooleanQuestion", () => {
|
|
31
|
+
const validBooleanQuestion = {
|
|
32
|
+
type: "boolean",
|
|
33
|
+
meta: {
|
|
34
|
+
schemaVersion: "1.0",
|
|
35
|
+
},
|
|
36
|
+
attributes: {
|
|
37
|
+
checked: true,
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
41
|
+
});
|
|
42
|
+
(0, globals_1.it)("should invalidate an invalid BooleanQuestion", () => {
|
|
43
|
+
const invalidBooleanQuestion = {
|
|
44
|
+
type: "boolean",
|
|
45
|
+
meta: {
|
|
46
|
+
schemaVersion: "1.0",
|
|
47
|
+
},
|
|
48
|
+
attributes: {
|
|
49
|
+
checked: "true", // Invalid type
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
5
55
|
(0, globals_1.describe)("CheckboxesQuestion", () => {
|
|
6
56
|
(0, globals_1.it)("should validate a valid CheckboxesQuestion object", () => {
|
|
7
57
|
const validCheckboxesQuestion = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { QuestionTypesEnum } from './question';
|
|
3
|
-
import {
|
|
3
|
+
import { CurrencyQuestionType, NumberQuestionType, NumberRangeQuestionType } from "./numberQuestions";
|
|
4
4
|
import { EmailQuestionType, TextAreaQuestionType, TextQuestionType, URLQuestionType } from "./textQuestions";
|
|
5
5
|
import { DateQuestionType, DateRangeQuestionType } from "./dateQuestions";
|
|
6
|
-
import { CheckboxesQuestionType, RadioButtonsQuestionType, SelectBoxQuestionType } from './optionBasedQuestions';
|
|
6
|
+
import { BooleanQuestionType, CheckboxesQuestionType, RadioButtonsQuestionType, SelectBoxQuestionType } from './optionBasedQuestions';
|
|
7
7
|
import { FilteredSearchQuestionType, TypeaheadSearchQuestionType } from './graphQLQuestions';
|
|
8
8
|
import { TableQuestionType } from './tableQuestions';
|
|
9
9
|
export * from './question';
|
|
@@ -23,7 +23,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
23
23
|
}>>;
|
|
24
24
|
} & {
|
|
25
25
|
type: z.ZodLiteral<"boolean">;
|
|
26
|
-
attributes: z.
|
|
26
|
+
attributes: z.ZodObject<{
|
|
27
27
|
label: z.ZodOptional<z.ZodString>;
|
|
28
28
|
help: z.ZodOptional<z.ZodString>;
|
|
29
29
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -39,26 +39,26 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
39
39
|
help?: string | undefined;
|
|
40
40
|
labelTranslationKey?: string | undefined;
|
|
41
41
|
checked?: boolean | undefined;
|
|
42
|
-
}
|
|
42
|
+
}>;
|
|
43
43
|
}, "strip", z.ZodTypeAny, {
|
|
44
44
|
type: "boolean";
|
|
45
|
-
attributes
|
|
45
|
+
attributes: {
|
|
46
46
|
label?: string | undefined;
|
|
47
47
|
help?: string | undefined;
|
|
48
48
|
labelTranslationKey?: string | undefined;
|
|
49
49
|
checked?: boolean | undefined;
|
|
50
|
-
}
|
|
50
|
+
};
|
|
51
51
|
meta?: {
|
|
52
52
|
schemaVersion: "1.0";
|
|
53
53
|
} | undefined;
|
|
54
54
|
}, {
|
|
55
55
|
type: "boolean";
|
|
56
|
-
attributes
|
|
56
|
+
attributes: {
|
|
57
57
|
label?: string | undefined;
|
|
58
58
|
help?: string | undefined;
|
|
59
59
|
labelTranslationKey?: string | undefined;
|
|
60
60
|
checked?: boolean | undefined;
|
|
61
|
-
}
|
|
61
|
+
};
|
|
62
62
|
meta?: {
|
|
63
63
|
schemaVersion: "1.0";
|
|
64
64
|
} | undefined;
|
|
@@ -718,6 +718,167 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
718
718
|
}, {
|
|
719
719
|
schemaVersion: "1.0";
|
|
720
720
|
}>>;
|
|
721
|
+
} & {
|
|
722
|
+
type: z.ZodLiteral<"numberRange">;
|
|
723
|
+
columns: z.ZodObject<{
|
|
724
|
+
start: z.ZodOptional<z.ZodObject<{
|
|
725
|
+
label: z.ZodOptional<z.ZodString>;
|
|
726
|
+
help: z.ZodOptional<z.ZodString>;
|
|
727
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
728
|
+
} & {
|
|
729
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
730
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
731
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
732
|
+
}, "strip", z.ZodTypeAny, {
|
|
733
|
+
label?: string | undefined;
|
|
734
|
+
help?: string | undefined;
|
|
735
|
+
labelTranslationKey?: string | undefined;
|
|
736
|
+
max?: number | undefined;
|
|
737
|
+
min?: number | undefined;
|
|
738
|
+
step?: number | undefined;
|
|
739
|
+
}, {
|
|
740
|
+
label?: string | undefined;
|
|
741
|
+
help?: string | undefined;
|
|
742
|
+
labelTranslationKey?: string | undefined;
|
|
743
|
+
max?: number | undefined;
|
|
744
|
+
min?: number | undefined;
|
|
745
|
+
step?: number | undefined;
|
|
746
|
+
}>>;
|
|
747
|
+
end: z.ZodOptional<z.ZodObject<{
|
|
748
|
+
label: z.ZodOptional<z.ZodString>;
|
|
749
|
+
help: z.ZodOptional<z.ZodString>;
|
|
750
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
751
|
+
} & {
|
|
752
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
753
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
754
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
755
|
+
}, "strip", z.ZodTypeAny, {
|
|
756
|
+
label?: string | undefined;
|
|
757
|
+
help?: string | undefined;
|
|
758
|
+
labelTranslationKey?: string | undefined;
|
|
759
|
+
max?: number | undefined;
|
|
760
|
+
min?: number | undefined;
|
|
761
|
+
step?: number | undefined;
|
|
762
|
+
}, {
|
|
763
|
+
label?: string | undefined;
|
|
764
|
+
help?: string | undefined;
|
|
765
|
+
labelTranslationKey?: string | undefined;
|
|
766
|
+
max?: number | undefined;
|
|
767
|
+
min?: number | undefined;
|
|
768
|
+
step?: number | undefined;
|
|
769
|
+
}>>;
|
|
770
|
+
}, "strip", z.ZodTypeAny, {
|
|
771
|
+
start?: {
|
|
772
|
+
label?: string | undefined;
|
|
773
|
+
help?: string | undefined;
|
|
774
|
+
labelTranslationKey?: string | undefined;
|
|
775
|
+
max?: number | undefined;
|
|
776
|
+
min?: number | undefined;
|
|
777
|
+
step?: number | undefined;
|
|
778
|
+
} | undefined;
|
|
779
|
+
end?: {
|
|
780
|
+
label?: string | undefined;
|
|
781
|
+
help?: string | undefined;
|
|
782
|
+
labelTranslationKey?: string | undefined;
|
|
783
|
+
max?: number | undefined;
|
|
784
|
+
min?: number | undefined;
|
|
785
|
+
step?: number | undefined;
|
|
786
|
+
} | undefined;
|
|
787
|
+
}, {
|
|
788
|
+
start?: {
|
|
789
|
+
label?: string | undefined;
|
|
790
|
+
help?: string | undefined;
|
|
791
|
+
labelTranslationKey?: string | undefined;
|
|
792
|
+
max?: number | undefined;
|
|
793
|
+
min?: number | undefined;
|
|
794
|
+
step?: number | undefined;
|
|
795
|
+
} | undefined;
|
|
796
|
+
end?: {
|
|
797
|
+
label?: string | undefined;
|
|
798
|
+
help?: string | undefined;
|
|
799
|
+
labelTranslationKey?: string | undefined;
|
|
800
|
+
max?: number | undefined;
|
|
801
|
+
min?: number | undefined;
|
|
802
|
+
step?: number | undefined;
|
|
803
|
+
} | undefined;
|
|
804
|
+
}>;
|
|
805
|
+
}, "strip", z.ZodTypeAny, {
|
|
806
|
+
type: "numberRange";
|
|
807
|
+
columns: {
|
|
808
|
+
start?: {
|
|
809
|
+
label?: string | undefined;
|
|
810
|
+
help?: string | undefined;
|
|
811
|
+
labelTranslationKey?: string | undefined;
|
|
812
|
+
max?: number | undefined;
|
|
813
|
+
min?: number | undefined;
|
|
814
|
+
step?: number | undefined;
|
|
815
|
+
} | undefined;
|
|
816
|
+
end?: {
|
|
817
|
+
label?: string | undefined;
|
|
818
|
+
help?: string | undefined;
|
|
819
|
+
labelTranslationKey?: string | undefined;
|
|
820
|
+
max?: number | undefined;
|
|
821
|
+
min?: number | undefined;
|
|
822
|
+
step?: number | undefined;
|
|
823
|
+
} | undefined;
|
|
824
|
+
};
|
|
825
|
+
attributes?: {
|
|
826
|
+
label?: string | undefined;
|
|
827
|
+
help?: string | undefined;
|
|
828
|
+
labelTranslationKey?: string | undefined;
|
|
829
|
+
} | undefined;
|
|
830
|
+
meta?: {
|
|
831
|
+
schemaVersion: "1.0";
|
|
832
|
+
} | undefined;
|
|
833
|
+
}, {
|
|
834
|
+
type: "numberRange";
|
|
835
|
+
columns: {
|
|
836
|
+
start?: {
|
|
837
|
+
label?: string | undefined;
|
|
838
|
+
help?: string | undefined;
|
|
839
|
+
labelTranslationKey?: string | undefined;
|
|
840
|
+
max?: number | undefined;
|
|
841
|
+
min?: number | undefined;
|
|
842
|
+
step?: number | undefined;
|
|
843
|
+
} | undefined;
|
|
844
|
+
end?: {
|
|
845
|
+
label?: string | undefined;
|
|
846
|
+
help?: string | undefined;
|
|
847
|
+
labelTranslationKey?: string | undefined;
|
|
848
|
+
max?: number | undefined;
|
|
849
|
+
min?: number | undefined;
|
|
850
|
+
step?: number | undefined;
|
|
851
|
+
} | undefined;
|
|
852
|
+
};
|
|
853
|
+
attributes?: {
|
|
854
|
+
label?: string | undefined;
|
|
855
|
+
help?: string | undefined;
|
|
856
|
+
labelTranslationKey?: string | undefined;
|
|
857
|
+
} | undefined;
|
|
858
|
+
meta?: {
|
|
859
|
+
schemaVersion: "1.0";
|
|
860
|
+
} | undefined;
|
|
861
|
+
}>, z.ZodObject<{
|
|
862
|
+
attributes: z.ZodOptional<z.ZodObject<{
|
|
863
|
+
label: z.ZodOptional<z.ZodString>;
|
|
864
|
+
help: z.ZodOptional<z.ZodString>;
|
|
865
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
866
|
+
}, "strip", z.ZodTypeAny, {
|
|
867
|
+
label?: string | undefined;
|
|
868
|
+
help?: string | undefined;
|
|
869
|
+
labelTranslationKey?: string | undefined;
|
|
870
|
+
}, {
|
|
871
|
+
label?: string | undefined;
|
|
872
|
+
help?: string | undefined;
|
|
873
|
+
labelTranslationKey?: string | undefined;
|
|
874
|
+
}>>;
|
|
875
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
876
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
877
|
+
}, "strip", z.ZodTypeAny, {
|
|
878
|
+
schemaVersion: "1.0";
|
|
879
|
+
}, {
|
|
880
|
+
schemaVersion: "1.0";
|
|
881
|
+
}>>;
|
|
721
882
|
} & {
|
|
722
883
|
type: z.ZodLiteral<"radioButtons">;
|
|
723
884
|
options: z.ZodArray<z.ZodObject<{
|
|
@@ -859,7 +1020,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
859
1020
|
}>>;
|
|
860
1021
|
} & {
|
|
861
1022
|
type: z.ZodLiteral<"boolean">;
|
|
862
|
-
attributes: z.
|
|
1023
|
+
attributes: z.ZodObject<{
|
|
863
1024
|
label: z.ZodOptional<z.ZodString>;
|
|
864
1025
|
help: z.ZodOptional<z.ZodString>;
|
|
865
1026
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -875,26 +1036,26 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
875
1036
|
help?: string | undefined;
|
|
876
1037
|
labelTranslationKey?: string | undefined;
|
|
877
1038
|
checked?: boolean | undefined;
|
|
878
|
-
}
|
|
1039
|
+
}>;
|
|
879
1040
|
}, "strip", z.ZodTypeAny, {
|
|
880
1041
|
type: "boolean";
|
|
881
|
-
attributes
|
|
1042
|
+
attributes: {
|
|
882
1043
|
label?: string | undefined;
|
|
883
1044
|
help?: string | undefined;
|
|
884
1045
|
labelTranslationKey?: string | undefined;
|
|
885
1046
|
checked?: boolean | undefined;
|
|
886
|
-
}
|
|
1047
|
+
};
|
|
887
1048
|
meta?: {
|
|
888
1049
|
schemaVersion: "1.0";
|
|
889
1050
|
} | undefined;
|
|
890
1051
|
}, {
|
|
891
1052
|
type: "boolean";
|
|
892
|
-
attributes
|
|
1053
|
+
attributes: {
|
|
893
1054
|
label?: string | undefined;
|
|
894
1055
|
help?: string | undefined;
|
|
895
1056
|
labelTranslationKey?: string | undefined;
|
|
896
1057
|
checked?: boolean | undefined;
|
|
897
|
-
}
|
|
1058
|
+
};
|
|
898
1059
|
meta?: {
|
|
899
1060
|
schemaVersion: "1.0";
|
|
900
1061
|
} | undefined;
|
|
@@ -2016,17 +2177,6 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2016
2177
|
}>]>;
|
|
2017
2178
|
}, "strip", z.ZodTypeAny, {
|
|
2018
2179
|
content: {
|
|
2019
|
-
type: "boolean";
|
|
2020
|
-
attributes?: {
|
|
2021
|
-
label?: string | undefined;
|
|
2022
|
-
help?: string | undefined;
|
|
2023
|
-
labelTranslationKey?: string | undefined;
|
|
2024
|
-
checked?: boolean | undefined;
|
|
2025
|
-
} | undefined;
|
|
2026
|
-
meta?: {
|
|
2027
|
-
schemaVersion: "1.0";
|
|
2028
|
-
} | undefined;
|
|
2029
|
-
} | {
|
|
2030
2180
|
type: "currency";
|
|
2031
2181
|
attributes?: {
|
|
2032
2182
|
label?: string | undefined;
|
|
@@ -2149,6 +2299,17 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2149
2299
|
meta?: {
|
|
2150
2300
|
schemaVersion: "1.0";
|
|
2151
2301
|
} | undefined;
|
|
2302
|
+
} | {
|
|
2303
|
+
type: "boolean";
|
|
2304
|
+
attributes: {
|
|
2305
|
+
label?: string | undefined;
|
|
2306
|
+
help?: string | undefined;
|
|
2307
|
+
labelTranslationKey?: string | undefined;
|
|
2308
|
+
checked?: boolean | undefined;
|
|
2309
|
+
};
|
|
2310
|
+
meta?: {
|
|
2311
|
+
schemaVersion: "1.0";
|
|
2312
|
+
} | undefined;
|
|
2152
2313
|
} | {
|
|
2153
2314
|
options: {
|
|
2154
2315
|
value: string;
|
|
@@ -2256,17 +2417,6 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2256
2417
|
heading?: string | undefined;
|
|
2257
2418
|
}, {
|
|
2258
2419
|
content: {
|
|
2259
|
-
type: "boolean";
|
|
2260
|
-
attributes?: {
|
|
2261
|
-
label?: string | undefined;
|
|
2262
|
-
help?: string | undefined;
|
|
2263
|
-
labelTranslationKey?: string | undefined;
|
|
2264
|
-
checked?: boolean | undefined;
|
|
2265
|
-
} | undefined;
|
|
2266
|
-
meta?: {
|
|
2267
|
-
schemaVersion: "1.0";
|
|
2268
|
-
} | undefined;
|
|
2269
|
-
} | {
|
|
2270
2420
|
type: "currency";
|
|
2271
2421
|
attributes?: {
|
|
2272
2422
|
label?: string | undefined;
|
|
@@ -2389,6 +2539,17 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2389
2539
|
meta?: {
|
|
2390
2540
|
schemaVersion: "1.0";
|
|
2391
2541
|
} | undefined;
|
|
2542
|
+
} | {
|
|
2543
|
+
type: "boolean";
|
|
2544
|
+
attributes: {
|
|
2545
|
+
label?: string | undefined;
|
|
2546
|
+
help?: string | undefined;
|
|
2547
|
+
labelTranslationKey?: string | undefined;
|
|
2548
|
+
checked?: boolean | undefined;
|
|
2549
|
+
};
|
|
2550
|
+
meta?: {
|
|
2551
|
+
schemaVersion: "1.0";
|
|
2552
|
+
} | undefined;
|
|
2392
2553
|
} | {
|
|
2393
2554
|
options: {
|
|
2394
2555
|
value: string;
|
|
@@ -2528,17 +2689,6 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2528
2689
|
type: "table";
|
|
2529
2690
|
columns: {
|
|
2530
2691
|
content: {
|
|
2531
|
-
type: "boolean";
|
|
2532
|
-
attributes?: {
|
|
2533
|
-
label?: string | undefined;
|
|
2534
|
-
help?: string | undefined;
|
|
2535
|
-
labelTranslationKey?: string | undefined;
|
|
2536
|
-
checked?: boolean | undefined;
|
|
2537
|
-
} | undefined;
|
|
2538
|
-
meta?: {
|
|
2539
|
-
schemaVersion: "1.0";
|
|
2540
|
-
} | undefined;
|
|
2541
|
-
} | {
|
|
2542
2692
|
type: "currency";
|
|
2543
2693
|
attributes?: {
|
|
2544
2694
|
label?: string | undefined;
|
|
@@ -2661,6 +2811,17 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2661
2811
|
meta?: {
|
|
2662
2812
|
schemaVersion: "1.0";
|
|
2663
2813
|
} | undefined;
|
|
2814
|
+
} | {
|
|
2815
|
+
type: "boolean";
|
|
2816
|
+
attributes: {
|
|
2817
|
+
label?: string | undefined;
|
|
2818
|
+
help?: string | undefined;
|
|
2819
|
+
labelTranslationKey?: string | undefined;
|
|
2820
|
+
checked?: boolean | undefined;
|
|
2821
|
+
};
|
|
2822
|
+
meta?: {
|
|
2823
|
+
schemaVersion: "1.0";
|
|
2824
|
+
} | undefined;
|
|
2664
2825
|
} | {
|
|
2665
2826
|
options: {
|
|
2666
2827
|
value: string;
|
|
@@ -2784,17 +2945,6 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2784
2945
|
type: "table";
|
|
2785
2946
|
columns: {
|
|
2786
2947
|
content: {
|
|
2787
|
-
type: "boolean";
|
|
2788
|
-
attributes?: {
|
|
2789
|
-
label?: string | undefined;
|
|
2790
|
-
help?: string | undefined;
|
|
2791
|
-
labelTranslationKey?: string | undefined;
|
|
2792
|
-
checked?: boolean | undefined;
|
|
2793
|
-
} | undefined;
|
|
2794
|
-
meta?: {
|
|
2795
|
-
schemaVersion: "1.0";
|
|
2796
|
-
} | undefined;
|
|
2797
|
-
} | {
|
|
2798
2948
|
type: "currency";
|
|
2799
2949
|
attributes?: {
|
|
2800
2950
|
label?: string | undefined;
|
|
@@ -2917,6 +3067,17 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodOb
|
|
|
2917
3067
|
meta?: {
|
|
2918
3068
|
schemaVersion: "1.0";
|
|
2919
3069
|
} | undefined;
|
|
3070
|
+
} | {
|
|
3071
|
+
type: "boolean";
|
|
3072
|
+
attributes: {
|
|
3073
|
+
label?: string | undefined;
|
|
3074
|
+
help?: string | undefined;
|
|
3075
|
+
labelTranslationKey?: string | undefined;
|
|
3076
|
+
checked?: boolean | undefined;
|
|
3077
|
+
};
|
|
3078
|
+
meta?: {
|
|
3079
|
+
schemaVersion: "1.0";
|
|
3080
|
+
} | undefined;
|
|
2920
3081
|
} | {
|
|
2921
3082
|
options: {
|
|
2922
3083
|
value: string;
|
package/dist/questions/index.js
CHANGED
|
@@ -31,7 +31,7 @@ __exportStar(require("./optionBasedQuestions"), exports);
|
|
|
31
31
|
__exportStar(require("./tableQuestions"), exports);
|
|
32
32
|
__exportStar(require("./textQuestions"), exports);
|
|
33
33
|
exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
|
|
34
|
-
|
|
34
|
+
optionBasedQuestions_1.BooleanQuestionSchema,
|
|
35
35
|
optionBasedQuestions_1.CheckboxesQuestionSchema,
|
|
36
36
|
numberQuestions_1.CurrencyQuestionSchema,
|
|
37
37
|
dateQuestions_1.DateQuestionSchema,
|
|
@@ -39,6 +39,7 @@ exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
39
39
|
textQuestions_1.EmailQuestionSchema,
|
|
40
40
|
graphQLQuestions_1.FilteredSearchQuestionSchema,
|
|
41
41
|
numberQuestions_1.NumberQuestionSchema,
|
|
42
|
+
numberQuestions_1.NumberRangeQuestionSchema,
|
|
42
43
|
optionBasedQuestions_1.RadioButtonsQuestionSchema,
|
|
43
44
|
optionBasedQuestions_1.SelectBoxQuestionSchema,
|
|
44
45
|
tableQuestions_1.TableQuestionSchema,
|
|
@@ -49,7 +50,7 @@ exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
49
50
|
]);
|
|
50
51
|
// Export a mapping between Zod Schemas and their corresponding question type label
|
|
51
52
|
exports.QuestionSchemaMap = {
|
|
52
|
-
boolean:
|
|
53
|
+
boolean: optionBasedQuestions_1.BooleanQuestionSchema,
|
|
53
54
|
checkBoxes: optionBasedQuestions_1.CheckboxesQuestionSchema,
|
|
54
55
|
currency: numberQuestions_1.CurrencyQuestionSchema,
|
|
55
56
|
date: dateQuestions_1.DateQuestionSchema,
|
|
@@ -1,54 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const BooleanQuestionSchema: z.ZodObject<{
|
|
3
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
4
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
schemaVersion: "1.0";
|
|
7
|
-
}, {
|
|
8
|
-
schemaVersion: "1.0";
|
|
9
|
-
}>>;
|
|
10
|
-
} & {
|
|
11
|
-
type: z.ZodLiteral<"boolean">;
|
|
12
|
-
attributes: z.ZodOptional<z.ZodObject<{
|
|
13
|
-
label: z.ZodOptional<z.ZodString>;
|
|
14
|
-
help: z.ZodOptional<z.ZodString>;
|
|
15
|
-
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
16
|
-
} & {
|
|
17
|
-
checked: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
-
}, "strip", z.ZodTypeAny, {
|
|
19
|
-
label?: string | undefined;
|
|
20
|
-
help?: string | undefined;
|
|
21
|
-
labelTranslationKey?: string | undefined;
|
|
22
|
-
checked?: boolean | undefined;
|
|
23
|
-
}, {
|
|
24
|
-
label?: string | undefined;
|
|
25
|
-
help?: string | undefined;
|
|
26
|
-
labelTranslationKey?: string | undefined;
|
|
27
|
-
checked?: boolean | undefined;
|
|
28
|
-
}>>;
|
|
29
|
-
}, "strip", z.ZodTypeAny, {
|
|
30
|
-
type: "boolean";
|
|
31
|
-
attributes?: {
|
|
32
|
-
label?: string | undefined;
|
|
33
|
-
help?: string | undefined;
|
|
34
|
-
labelTranslationKey?: string | undefined;
|
|
35
|
-
checked?: boolean | undefined;
|
|
36
|
-
} | undefined;
|
|
37
|
-
meta?: {
|
|
38
|
-
schemaVersion: "1.0";
|
|
39
|
-
} | undefined;
|
|
40
|
-
}, {
|
|
41
|
-
type: "boolean";
|
|
42
|
-
attributes?: {
|
|
43
|
-
label?: string | undefined;
|
|
44
|
-
help?: string | undefined;
|
|
45
|
-
labelTranslationKey?: string | undefined;
|
|
46
|
-
checked?: boolean | undefined;
|
|
47
|
-
} | undefined;
|
|
48
|
-
meta?: {
|
|
49
|
-
schemaVersion: "1.0";
|
|
50
|
-
} | undefined;
|
|
51
|
-
}>;
|
|
52
2
|
export declare const CurrencyQuestionSchema: z.ZodObject<{
|
|
53
3
|
meta: z.ZodOptional<z.ZodObject<{
|
|
54
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
@@ -337,7 +287,6 @@ export declare const NumberRangeQuestionSchema: z.ZodObject<{
|
|
|
337
287
|
schemaVersion: "1.0";
|
|
338
288
|
} | undefined;
|
|
339
289
|
}>;
|
|
340
|
-
export type BooleanQuestionType = z.infer<typeof BooleanQuestionSchema>;
|
|
341
290
|
export type CurrencyQuestionType = z.infer<typeof CurrencyQuestionSchema>;
|
|
342
291
|
export type NumberQuestionType = z.infer<typeof NumberQuestionSchema>;
|
|
343
292
|
export type NumberRangeQuestionType = z.infer<typeof NumberRangeQuestionSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberRangeQuestionSchema = exports.NumberQuestionSchema = exports.CurrencyQuestionSchema =
|
|
3
|
+
exports.NumberRangeQuestionSchema = exports.NumberQuestionSchema = exports.CurrencyQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
const BaseAttributes = question_1.QuestionSchema.shape.attributes;
|
|
@@ -9,12 +9,6 @@ const NumberAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
|
9
9
|
min: zod_1.z.number().optional(), // The lowest amount allowed (default 0)
|
|
10
10
|
step: zod_1.z.number().optional() // The amount to increment. To allow decimals, use 0.01 (default 1)
|
|
11
11
|
}));
|
|
12
|
-
exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
13
|
-
type: zod_1.z.literal('boolean'),
|
|
14
|
-
attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
15
|
-
checked: zod_1.z.boolean().optional(), // Whether it is checked by default
|
|
16
|
-
})).optional(),
|
|
17
|
-
}));
|
|
18
12
|
exports.CurrencyQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
19
13
|
type: zod_1.z.literal('currency'),
|
|
20
14
|
attributes: NumberAttributesSchema.merge(zod_1.z.object({
|
|
@@ -1,4 +1,54 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
+
export declare const BooleanQuestionSchema: z.ZodObject<{
|
|
3
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
4
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
schemaVersion: "1.0";
|
|
7
|
+
}, {
|
|
8
|
+
schemaVersion: "1.0";
|
|
9
|
+
}>>;
|
|
10
|
+
} & {
|
|
11
|
+
type: z.ZodLiteral<"boolean">;
|
|
12
|
+
attributes: z.ZodObject<{
|
|
13
|
+
label: z.ZodOptional<z.ZodString>;
|
|
14
|
+
help: z.ZodOptional<z.ZodString>;
|
|
15
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
16
|
+
} & {
|
|
17
|
+
checked: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
label?: string | undefined;
|
|
20
|
+
help?: string | undefined;
|
|
21
|
+
labelTranslationKey?: string | undefined;
|
|
22
|
+
checked?: boolean | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
label?: string | undefined;
|
|
25
|
+
help?: string | undefined;
|
|
26
|
+
labelTranslationKey?: string | undefined;
|
|
27
|
+
checked?: boolean | undefined;
|
|
28
|
+
}>;
|
|
29
|
+
}, "strip", z.ZodTypeAny, {
|
|
30
|
+
type: "boolean";
|
|
31
|
+
attributes: {
|
|
32
|
+
label?: string | undefined;
|
|
33
|
+
help?: string | undefined;
|
|
34
|
+
labelTranslationKey?: string | undefined;
|
|
35
|
+
checked?: boolean | undefined;
|
|
36
|
+
};
|
|
37
|
+
meta?: {
|
|
38
|
+
schemaVersion: "1.0";
|
|
39
|
+
} | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
type: "boolean";
|
|
42
|
+
attributes: {
|
|
43
|
+
label?: string | undefined;
|
|
44
|
+
help?: string | undefined;
|
|
45
|
+
labelTranslationKey?: string | undefined;
|
|
46
|
+
checked?: boolean | undefined;
|
|
47
|
+
};
|
|
48
|
+
meta?: {
|
|
49
|
+
schemaVersion: "1.0";
|
|
50
|
+
} | undefined;
|
|
51
|
+
}>;
|
|
2
52
|
export declare const CheckboxesQuestionSchema: z.ZodObject<{
|
|
3
53
|
attributes: z.ZodOptional<z.ZodObject<{
|
|
4
54
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -209,6 +259,7 @@ export declare const SelectBoxQuestionSchema: z.ZodObject<{
|
|
|
209
259
|
schemaVersion: "1.0";
|
|
210
260
|
} | undefined;
|
|
211
261
|
}>;
|
|
262
|
+
export type BooleanQuestionType = z.infer<typeof BooleanQuestionSchema>;
|
|
212
263
|
export type CheckboxesQuestionType = z.infer<typeof CheckboxesQuestionSchema>;
|
|
213
264
|
export type RadioButtonsQuestionType = z.infer<typeof RadioButtonsQuestionSchema>;
|
|
214
265
|
export type SelectBoxQuestionType = z.infer<typeof SelectBoxQuestionSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectBoxQuestionSchema = exports.RadioButtonsQuestionSchema = exports.CheckboxesQuestionSchema = void 0;
|
|
3
|
+
exports.SelectBoxQuestionSchema = exports.RadioButtonsQuestionSchema = exports.CheckboxesQuestionSchema = exports.BooleanQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
// A select box, radio buttons, or checkboxes option
|
|
@@ -15,6 +15,12 @@ const CheckedOptionSchema = OptionSchema.merge(zod_1.z.object({
|
|
|
15
15
|
const SelectedOptionSchema = OptionSchema.merge(zod_1.z.object({
|
|
16
16
|
selected: zod_1.z.boolean().optional(),
|
|
17
17
|
}));
|
|
18
|
+
exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
19
|
+
type: zod_1.z.literal('boolean'),
|
|
20
|
+
attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
21
|
+
checked: zod_1.z.boolean().optional(),
|
|
22
|
+
})),
|
|
23
|
+
}));
|
|
18
24
|
// Check boxes question and answer
|
|
19
25
|
exports.CheckboxesQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
20
26
|
type: zod_1.z.literal('checkBoxes'), // The type of question
|