@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
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@ const questions_1 = require("../../questions");
|
|
|
12
12
|
(0, globals_1.describe)('Answer Type Validations', () => {
|
|
13
13
|
(0, globals_1.it)('should validate BooleanAnswer', () => {
|
|
14
14
|
const validData = { type: 'boolean', answer: true, meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
|
|
15
|
-
(0, globals_1.expect)(() =>
|
|
15
|
+
(0, globals_1.expect)(() => optionBasedAnswers_1.BooleanAnswerSchema.parse(validData)).not.toThrow();
|
|
16
16
|
const invalidData = { type: 'boolean', answer: 'true' };
|
|
17
|
-
(0, globals_1.expect)(() =>
|
|
17
|
+
(0, globals_1.expect)(() => optionBasedAnswers_1.BooleanAnswerSchema.parse(invalidData)).toThrow();
|
|
18
18
|
});
|
|
19
19
|
(0, globals_1.it)('should validate CheckboxesAnswer', () => {
|
|
20
20
|
const validData = { type: 'checkBoxes', answer: ['option1', 'option2'], meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
|
package/dist/answers/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { DateAnswerType, DateRangeAnswerType } from './dateAnswers';
|
|
3
3
|
import { FilteredSearchAnswerType, TypeaheadSearchAnswerType } from './graphQLAnswers';
|
|
4
|
-
import { CheckboxesAnswerType, RadioButtonsAnswerType, SelectBoxAnswerType } from './optionBasedAnswers';
|
|
5
|
-
import {
|
|
4
|
+
import { BooleanAnswerType, CheckboxesAnswerType, RadioButtonsAnswerType, SelectBoxAnswerType } from './optionBasedAnswers';
|
|
5
|
+
import { CurrencyAnswerType, NumberAnswerType, NumberRangeAnswerType } from './numberAnswers';
|
|
6
6
|
import { TableAnswerType } from './tableAnswers';
|
|
7
7
|
import { EmailAnswerType, TextAnswerType, TextAreaAnswerType, URLAnswerType } from './textAnswers';
|
|
8
8
|
import { QuestionTypesEnum } from '../questions';
|
|
@@ -638,6 +638,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
638
638
|
schemaVersion: "1.0";
|
|
639
639
|
};
|
|
640
640
|
answer: string;
|
|
641
|
+
} | {
|
|
642
|
+
type: "boolean";
|
|
643
|
+
meta: {
|
|
644
|
+
schemaVersion: "1.0";
|
|
645
|
+
};
|
|
646
|
+
answer: boolean;
|
|
641
647
|
} | {
|
|
642
648
|
type: "checkBoxes";
|
|
643
649
|
meta: {
|
|
@@ -656,12 +662,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
656
662
|
schemaVersion: "1.0";
|
|
657
663
|
};
|
|
658
664
|
answer: string[];
|
|
659
|
-
} | {
|
|
660
|
-
type: "boolean";
|
|
661
|
-
meta: {
|
|
662
|
-
schemaVersion: "1.0";
|
|
663
|
-
};
|
|
664
|
-
answer: boolean;
|
|
665
665
|
} | {
|
|
666
666
|
type: "currency";
|
|
667
667
|
meta: {
|
|
@@ -728,6 +728,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
728
728
|
schemaVersion: "1.0";
|
|
729
729
|
};
|
|
730
730
|
answer: string;
|
|
731
|
+
} | {
|
|
732
|
+
type: "boolean";
|
|
733
|
+
meta: {
|
|
734
|
+
schemaVersion: "1.0";
|
|
735
|
+
};
|
|
736
|
+
answer: boolean;
|
|
731
737
|
} | {
|
|
732
738
|
type: "checkBoxes";
|
|
733
739
|
meta: {
|
|
@@ -746,12 +752,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
746
752
|
schemaVersion: "1.0";
|
|
747
753
|
};
|
|
748
754
|
answer: string[];
|
|
749
|
-
} | {
|
|
750
|
-
type: "boolean";
|
|
751
|
-
meta: {
|
|
752
|
-
schemaVersion: "1.0";
|
|
753
|
-
};
|
|
754
|
-
answer: boolean;
|
|
755
755
|
} | {
|
|
756
756
|
type: "currency";
|
|
757
757
|
meta: {
|
|
@@ -820,6 +820,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
820
820
|
schemaVersion: "1.0";
|
|
821
821
|
};
|
|
822
822
|
answer: string;
|
|
823
|
+
} | {
|
|
824
|
+
type: "boolean";
|
|
825
|
+
meta: {
|
|
826
|
+
schemaVersion: "1.0";
|
|
827
|
+
};
|
|
828
|
+
answer: boolean;
|
|
823
829
|
} | {
|
|
824
830
|
type: "checkBoxes";
|
|
825
831
|
meta: {
|
|
@@ -838,12 +844,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
838
844
|
schemaVersion: "1.0";
|
|
839
845
|
};
|
|
840
846
|
answer: string[];
|
|
841
|
-
} | {
|
|
842
|
-
type: "boolean";
|
|
843
|
-
meta: {
|
|
844
|
-
schemaVersion: "1.0";
|
|
845
|
-
};
|
|
846
|
-
answer: boolean;
|
|
847
847
|
} | {
|
|
848
848
|
type: "currency";
|
|
849
849
|
meta: {
|
|
@@ -912,6 +912,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
912
912
|
schemaVersion: "1.0";
|
|
913
913
|
};
|
|
914
914
|
answer: string;
|
|
915
|
+
} | {
|
|
916
|
+
type: "boolean";
|
|
917
|
+
meta: {
|
|
918
|
+
schemaVersion: "1.0";
|
|
919
|
+
};
|
|
920
|
+
answer: boolean;
|
|
915
921
|
} | {
|
|
916
922
|
type: "checkBoxes";
|
|
917
923
|
meta: {
|
|
@@ -930,12 +936,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
930
936
|
schemaVersion: "1.0";
|
|
931
937
|
};
|
|
932
938
|
answer: string[];
|
|
933
|
-
} | {
|
|
934
|
-
type: "boolean";
|
|
935
|
-
meta: {
|
|
936
|
-
schemaVersion: "1.0";
|
|
937
|
-
};
|
|
938
|
-
answer: boolean;
|
|
939
939
|
} | {
|
|
940
940
|
type: "currency";
|
|
941
941
|
meta: {
|
|
@@ -1010,6 +1010,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1010
1010
|
schemaVersion: "1.0";
|
|
1011
1011
|
};
|
|
1012
1012
|
answer: string;
|
|
1013
|
+
} | {
|
|
1014
|
+
type: "boolean";
|
|
1015
|
+
meta: {
|
|
1016
|
+
schemaVersion: "1.0";
|
|
1017
|
+
};
|
|
1018
|
+
answer: boolean;
|
|
1013
1019
|
} | {
|
|
1014
1020
|
type: "checkBoxes";
|
|
1015
1021
|
meta: {
|
|
@@ -1028,12 +1034,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1028
1034
|
schemaVersion: "1.0";
|
|
1029
1035
|
};
|
|
1030
1036
|
answer: string[];
|
|
1031
|
-
} | {
|
|
1032
|
-
type: "boolean";
|
|
1033
|
-
meta: {
|
|
1034
|
-
schemaVersion: "1.0";
|
|
1035
|
-
};
|
|
1036
|
-
answer: boolean;
|
|
1037
1037
|
} | {
|
|
1038
1038
|
type: "currency";
|
|
1039
1039
|
meta: {
|
|
@@ -1108,6 +1108,12 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1108
1108
|
schemaVersion: "1.0";
|
|
1109
1109
|
};
|
|
1110
1110
|
answer: string;
|
|
1111
|
+
} | {
|
|
1112
|
+
type: "boolean";
|
|
1113
|
+
meta: {
|
|
1114
|
+
schemaVersion: "1.0";
|
|
1115
|
+
};
|
|
1116
|
+
answer: boolean;
|
|
1111
1117
|
} | {
|
|
1112
1118
|
type: "checkBoxes";
|
|
1113
1119
|
meta: {
|
|
@@ -1126,12 +1132,6 @@ export declare const AnyAnswerSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
|
|
|
1126
1132
|
schemaVersion: "1.0";
|
|
1127
1133
|
};
|
|
1128
1134
|
answer: string[];
|
|
1129
|
-
} | {
|
|
1130
|
-
type: "boolean";
|
|
1131
|
-
meta: {
|
|
1132
|
-
schemaVersion: "1.0";
|
|
1133
|
-
};
|
|
1134
|
-
answer: boolean;
|
|
1135
1135
|
} | {
|
|
1136
1136
|
type: "currency";
|
|
1137
1137
|
meta: {
|
package/dist/answers/index.js
CHANGED
|
@@ -32,7 +32,7 @@ __exportStar(require("./tableAnswers"), exports);
|
|
|
32
32
|
__exportStar(require("./textAnswers"), exports);
|
|
33
33
|
// Union of all possible answers
|
|
34
34
|
exports.AnyAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
35
|
-
|
|
35
|
+
optionBasedAnswers_1.BooleanAnswerSchema,
|
|
36
36
|
optionBasedAnswers_1.CheckboxesAnswerSchema,
|
|
37
37
|
numberAnswers_1.CurrencyAnswerSchema,
|
|
38
38
|
dateAnswers_1.DateAnswerSchema,
|
|
@@ -50,7 +50,7 @@ exports.AnyAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
50
50
|
]);
|
|
51
51
|
// Export a mapping between question types and their corresponding answer schemas
|
|
52
52
|
exports.AnswerSchemaMap = {
|
|
53
|
-
boolean:
|
|
53
|
+
boolean: optionBasedAnswers_1.BooleanAnswerSchema,
|
|
54
54
|
checkBoxes: optionBasedAnswers_1.CheckboxesAnswerSchema,
|
|
55
55
|
currency: numberAnswers_1.CurrencyAnswerSchema,
|
|
56
56
|
date: dateAnswers_1.DateAnswerSchema,
|
|
@@ -1,28 +1,4 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const BooleanAnswerSchema: z.ZodObject<{
|
|
3
|
-
meta: 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
|
-
answer: z.ZodBoolean;
|
|
13
|
-
}, "strip", z.ZodTypeAny, {
|
|
14
|
-
type: "boolean";
|
|
15
|
-
meta: {
|
|
16
|
-
schemaVersion: "1.0";
|
|
17
|
-
};
|
|
18
|
-
answer: boolean;
|
|
19
|
-
}, {
|
|
20
|
-
type: "boolean";
|
|
21
|
-
meta: {
|
|
22
|
-
schemaVersion: "1.0";
|
|
23
|
-
};
|
|
24
|
-
answer: boolean;
|
|
25
|
-
}>;
|
|
26
2
|
export declare const CurrencyAnswerSchema: z.ZodObject<{
|
|
27
3
|
meta: z.ZodObject<{
|
|
28
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
@@ -110,7 +86,6 @@ export declare const NumberRangeAnswerSchema: z.ZodObject<{
|
|
|
110
86
|
end: number;
|
|
111
87
|
};
|
|
112
88
|
}>;
|
|
113
|
-
export type BooleanAnswerType = z.infer<typeof BooleanAnswerSchema>;
|
|
114
89
|
export type CurrencyAnswerType = z.infer<typeof CurrencyAnswerSchema>;
|
|
115
90
|
export type NumberAnswerType = z.infer<typeof NumberAnswerSchema>;
|
|
116
91
|
export type NumberRangeAnswerType = z.infer<typeof NumberRangeAnswerSchema>;
|
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NumberRangeAnswerSchema = exports.NumberAnswerSchema = exports.CurrencyAnswerSchema =
|
|
3
|
+
exports.NumberRangeAnswerSchema = exports.NumberAnswerSchema = exports.CurrencyAnswerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const answer_1 = require("./answer");
|
|
6
6
|
// Answers to Number Question Types
|
|
7
|
-
exports.BooleanAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
8
|
-
type: zod_1.z.literal('boolean'), // The type of answer
|
|
9
|
-
answer: zod_1.z.boolean() // The answer to the question (true/false)
|
|
10
|
-
}));
|
|
11
7
|
exports.CurrencyAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
12
8
|
type: zod_1.z.literal('currency'), // The type of answer
|
|
13
9
|
answer: zod_1.z.number() // The answer to the question (number)
|
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
export declare const BooleanAnswerSchema: z.ZodObject<{
|
|
3
|
+
meta: 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
|
+
answer: z.ZodBoolean;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
type: "boolean";
|
|
15
|
+
meta: {
|
|
16
|
+
schemaVersion: "1.0";
|
|
17
|
+
};
|
|
18
|
+
answer: boolean;
|
|
19
|
+
}, {
|
|
20
|
+
type: "boolean";
|
|
21
|
+
meta: {
|
|
22
|
+
schemaVersion: "1.0";
|
|
23
|
+
};
|
|
24
|
+
answer: boolean;
|
|
25
|
+
}>;
|
|
2
26
|
export declare const CheckboxesAnswerSchema: z.ZodObject<{
|
|
3
27
|
meta: z.ZodObject<{
|
|
4
28
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
@@ -71,6 +95,7 @@ export declare const SelectBoxAnswerSchema: z.ZodObject<{
|
|
|
71
95
|
};
|
|
72
96
|
answer: string[];
|
|
73
97
|
}>;
|
|
98
|
+
export type BooleanAnswerType = z.infer<typeof BooleanAnswerSchema>;
|
|
74
99
|
export type CheckboxesAnswerType = z.infer<typeof CheckboxesAnswerSchema>;
|
|
75
100
|
export type RadioButtonsAnswerType = z.infer<typeof RadioButtonsAnswerSchema>;
|
|
76
101
|
export type SelectBoxAnswerType = z.infer<typeof SelectBoxAnswerSchema>;
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectBoxAnswerSchema = exports.RadioButtonsAnswerSchema = exports.CheckboxesAnswerSchema = void 0;
|
|
3
|
+
exports.SelectBoxAnswerSchema = exports.RadioButtonsAnswerSchema = exports.CheckboxesAnswerSchema = exports.BooleanAnswerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const answer_1 = require("./answer");
|
|
6
6
|
// Answers to Option Based Question Types
|
|
7
|
+
exports.BooleanAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
8
|
+
type: zod_1.z.literal('boolean'), // The type of answer
|
|
9
|
+
answer: zod_1.z.boolean() // The answer to the question (true/false)
|
|
10
|
+
}));
|
|
7
11
|
exports.CheckboxesAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
8
12
|
type: zod_1.z.literal('checkBoxes'), // The type of answer
|
|
9
13
|
answer: zod_1.z.array(zod_1.z.string()) // The answer to the question (array of strings)
|
|
@@ -706,6 +706,12 @@ export declare const TableColumnAnswerSchema: z.ZodObject<{
|
|
|
706
706
|
schemaVersion: "1.0";
|
|
707
707
|
};
|
|
708
708
|
answer: string;
|
|
709
|
+
} | {
|
|
710
|
+
type: "boolean";
|
|
711
|
+
meta: {
|
|
712
|
+
schemaVersion: "1.0";
|
|
713
|
+
};
|
|
714
|
+
answer: boolean;
|
|
709
715
|
} | {
|
|
710
716
|
type: "checkBoxes";
|
|
711
717
|
meta: {
|
|
@@ -724,12 +730,6 @@ export declare const TableColumnAnswerSchema: z.ZodObject<{
|
|
|
724
730
|
schemaVersion: "1.0";
|
|
725
731
|
};
|
|
726
732
|
answer: string[];
|
|
727
|
-
} | {
|
|
728
|
-
type: "boolean";
|
|
729
|
-
meta: {
|
|
730
|
-
schemaVersion: "1.0";
|
|
731
|
-
};
|
|
732
|
-
answer: boolean;
|
|
733
733
|
} | {
|
|
734
734
|
type: "currency";
|
|
735
735
|
meta: {
|
|
@@ -796,6 +796,12 @@ export declare const TableColumnAnswerSchema: z.ZodObject<{
|
|
|
796
796
|
schemaVersion: "1.0";
|
|
797
797
|
};
|
|
798
798
|
answer: string;
|
|
799
|
+
} | {
|
|
800
|
+
type: "boolean";
|
|
801
|
+
meta: {
|
|
802
|
+
schemaVersion: "1.0";
|
|
803
|
+
};
|
|
804
|
+
answer: boolean;
|
|
799
805
|
} | {
|
|
800
806
|
type: "checkBoxes";
|
|
801
807
|
meta: {
|
|
@@ -814,12 +820,6 @@ export declare const TableColumnAnswerSchema: z.ZodObject<{
|
|
|
814
820
|
schemaVersion: "1.0";
|
|
815
821
|
};
|
|
816
822
|
answer: string[];
|
|
817
|
-
} | {
|
|
818
|
-
type: "boolean";
|
|
819
|
-
meta: {
|
|
820
|
-
schemaVersion: "1.0";
|
|
821
|
-
};
|
|
822
|
-
answer: boolean;
|
|
823
823
|
} | {
|
|
824
824
|
type: "currency";
|
|
825
825
|
meta: {
|
|
@@ -1228,6 +1228,12 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1228
1228
|
schemaVersion: "1.0";
|
|
1229
1229
|
};
|
|
1230
1230
|
answer: string;
|
|
1231
|
+
} | {
|
|
1232
|
+
type: "boolean";
|
|
1233
|
+
meta: {
|
|
1234
|
+
schemaVersion: "1.0";
|
|
1235
|
+
};
|
|
1236
|
+
answer: boolean;
|
|
1231
1237
|
} | {
|
|
1232
1238
|
type: "checkBoxes";
|
|
1233
1239
|
meta: {
|
|
@@ -1246,12 +1252,6 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1246
1252
|
schemaVersion: "1.0";
|
|
1247
1253
|
};
|
|
1248
1254
|
answer: string[];
|
|
1249
|
-
} | {
|
|
1250
|
-
type: "boolean";
|
|
1251
|
-
meta: {
|
|
1252
|
-
schemaVersion: "1.0";
|
|
1253
|
-
};
|
|
1254
|
-
answer: boolean;
|
|
1255
1255
|
} | {
|
|
1256
1256
|
type: "currency";
|
|
1257
1257
|
meta: {
|
|
@@ -1318,6 +1318,12 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1318
1318
|
schemaVersion: "1.0";
|
|
1319
1319
|
};
|
|
1320
1320
|
answer: string;
|
|
1321
|
+
} | {
|
|
1322
|
+
type: "boolean";
|
|
1323
|
+
meta: {
|
|
1324
|
+
schemaVersion: "1.0";
|
|
1325
|
+
};
|
|
1326
|
+
answer: boolean;
|
|
1321
1327
|
} | {
|
|
1322
1328
|
type: "checkBoxes";
|
|
1323
1329
|
meta: {
|
|
@@ -1336,12 +1342,6 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1336
1342
|
schemaVersion: "1.0";
|
|
1337
1343
|
};
|
|
1338
1344
|
answer: string[];
|
|
1339
|
-
} | {
|
|
1340
|
-
type: "boolean";
|
|
1341
|
-
meta: {
|
|
1342
|
-
schemaVersion: "1.0";
|
|
1343
|
-
};
|
|
1344
|
-
answer: boolean;
|
|
1345
1345
|
} | {
|
|
1346
1346
|
type: "currency";
|
|
1347
1347
|
meta: {
|
|
@@ -1410,6 +1410,12 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1410
1410
|
schemaVersion: "1.0";
|
|
1411
1411
|
};
|
|
1412
1412
|
answer: string;
|
|
1413
|
+
} | {
|
|
1414
|
+
type: "boolean";
|
|
1415
|
+
meta: {
|
|
1416
|
+
schemaVersion: "1.0";
|
|
1417
|
+
};
|
|
1418
|
+
answer: boolean;
|
|
1413
1419
|
} | {
|
|
1414
1420
|
type: "checkBoxes";
|
|
1415
1421
|
meta: {
|
|
@@ -1428,12 +1434,6 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1428
1434
|
schemaVersion: "1.0";
|
|
1429
1435
|
};
|
|
1430
1436
|
answer: string[];
|
|
1431
|
-
} | {
|
|
1432
|
-
type: "boolean";
|
|
1433
|
-
meta: {
|
|
1434
|
-
schemaVersion: "1.0";
|
|
1435
|
-
};
|
|
1436
|
-
answer: boolean;
|
|
1437
1437
|
} | {
|
|
1438
1438
|
type: "currency";
|
|
1439
1439
|
meta: {
|
|
@@ -1502,6 +1502,12 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1502
1502
|
schemaVersion: "1.0";
|
|
1503
1503
|
};
|
|
1504
1504
|
answer: string;
|
|
1505
|
+
} | {
|
|
1506
|
+
type: "boolean";
|
|
1507
|
+
meta: {
|
|
1508
|
+
schemaVersion: "1.0";
|
|
1509
|
+
};
|
|
1510
|
+
answer: boolean;
|
|
1505
1511
|
} | {
|
|
1506
1512
|
type: "checkBoxes";
|
|
1507
1513
|
meta: {
|
|
@@ -1520,12 +1526,6 @@ export declare const TableRowAnswerSchema: z.ZodObject<{
|
|
|
1520
1526
|
schemaVersion: "1.0";
|
|
1521
1527
|
};
|
|
1522
1528
|
answer: string[];
|
|
1523
|
-
} | {
|
|
1524
|
-
type: "boolean";
|
|
1525
|
-
meta: {
|
|
1526
|
-
schemaVersion: "1.0";
|
|
1527
|
-
};
|
|
1528
|
-
answer: boolean;
|
|
1529
1529
|
} | {
|
|
1530
1530
|
type: "currency";
|
|
1531
1531
|
meta: {
|
|
@@ -1945,6 +1945,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
1945
1945
|
schemaVersion: "1.0";
|
|
1946
1946
|
};
|
|
1947
1947
|
answer: string;
|
|
1948
|
+
} | {
|
|
1949
|
+
type: "boolean";
|
|
1950
|
+
meta: {
|
|
1951
|
+
schemaVersion: "1.0";
|
|
1952
|
+
};
|
|
1953
|
+
answer: boolean;
|
|
1948
1954
|
} | {
|
|
1949
1955
|
type: "checkBoxes";
|
|
1950
1956
|
meta: {
|
|
@@ -1963,12 +1969,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
1963
1969
|
schemaVersion: "1.0";
|
|
1964
1970
|
};
|
|
1965
1971
|
answer: string[];
|
|
1966
|
-
} | {
|
|
1967
|
-
type: "boolean";
|
|
1968
|
-
meta: {
|
|
1969
|
-
schemaVersion: "1.0";
|
|
1970
|
-
};
|
|
1971
|
-
answer: boolean;
|
|
1972
1972
|
} | {
|
|
1973
1973
|
type: "currency";
|
|
1974
1974
|
meta: {
|
|
@@ -2035,6 +2035,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2035
2035
|
schemaVersion: "1.0";
|
|
2036
2036
|
};
|
|
2037
2037
|
answer: string;
|
|
2038
|
+
} | {
|
|
2039
|
+
type: "boolean";
|
|
2040
|
+
meta: {
|
|
2041
|
+
schemaVersion: "1.0";
|
|
2042
|
+
};
|
|
2043
|
+
answer: boolean;
|
|
2038
2044
|
} | {
|
|
2039
2045
|
type: "checkBoxes";
|
|
2040
2046
|
meta: {
|
|
@@ -2053,12 +2059,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2053
2059
|
schemaVersion: "1.0";
|
|
2054
2060
|
};
|
|
2055
2061
|
answer: string[];
|
|
2056
|
-
} | {
|
|
2057
|
-
type: "boolean";
|
|
2058
|
-
meta: {
|
|
2059
|
-
schemaVersion: "1.0";
|
|
2060
|
-
};
|
|
2061
|
-
answer: boolean;
|
|
2062
2062
|
} | {
|
|
2063
2063
|
type: "currency";
|
|
2064
2064
|
meta: {
|
|
@@ -2127,6 +2127,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2127
2127
|
schemaVersion: "1.0";
|
|
2128
2128
|
};
|
|
2129
2129
|
answer: string;
|
|
2130
|
+
} | {
|
|
2131
|
+
type: "boolean";
|
|
2132
|
+
meta: {
|
|
2133
|
+
schemaVersion: "1.0";
|
|
2134
|
+
};
|
|
2135
|
+
answer: boolean;
|
|
2130
2136
|
} | {
|
|
2131
2137
|
type: "checkBoxes";
|
|
2132
2138
|
meta: {
|
|
@@ -2145,12 +2151,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2145
2151
|
schemaVersion: "1.0";
|
|
2146
2152
|
};
|
|
2147
2153
|
answer: string[];
|
|
2148
|
-
} | {
|
|
2149
|
-
type: "boolean";
|
|
2150
|
-
meta: {
|
|
2151
|
-
schemaVersion: "1.0";
|
|
2152
|
-
};
|
|
2153
|
-
answer: boolean;
|
|
2154
2154
|
} | {
|
|
2155
2155
|
type: "currency";
|
|
2156
2156
|
meta: {
|
|
@@ -2219,6 +2219,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2219
2219
|
schemaVersion: "1.0";
|
|
2220
2220
|
};
|
|
2221
2221
|
answer: string;
|
|
2222
|
+
} | {
|
|
2223
|
+
type: "boolean";
|
|
2224
|
+
meta: {
|
|
2225
|
+
schemaVersion: "1.0";
|
|
2226
|
+
};
|
|
2227
|
+
answer: boolean;
|
|
2222
2228
|
} | {
|
|
2223
2229
|
type: "checkBoxes";
|
|
2224
2230
|
meta: {
|
|
@@ -2237,12 +2243,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2237
2243
|
schemaVersion: "1.0";
|
|
2238
2244
|
};
|
|
2239
2245
|
answer: string[];
|
|
2240
|
-
} | {
|
|
2241
|
-
type: "boolean";
|
|
2242
|
-
meta: {
|
|
2243
|
-
schemaVersion: "1.0";
|
|
2244
|
-
};
|
|
2245
|
-
answer: boolean;
|
|
2246
2246
|
} | {
|
|
2247
2247
|
type: "currency";
|
|
2248
2248
|
meta: {
|
|
@@ -2317,6 +2317,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2317
2317
|
schemaVersion: "1.0";
|
|
2318
2318
|
};
|
|
2319
2319
|
answer: string;
|
|
2320
|
+
} | {
|
|
2321
|
+
type: "boolean";
|
|
2322
|
+
meta: {
|
|
2323
|
+
schemaVersion: "1.0";
|
|
2324
|
+
};
|
|
2325
|
+
answer: boolean;
|
|
2320
2326
|
} | {
|
|
2321
2327
|
type: "checkBoxes";
|
|
2322
2328
|
meta: {
|
|
@@ -2335,12 +2341,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2335
2341
|
schemaVersion: "1.0";
|
|
2336
2342
|
};
|
|
2337
2343
|
answer: string[];
|
|
2338
|
-
} | {
|
|
2339
|
-
type: "boolean";
|
|
2340
|
-
meta: {
|
|
2341
|
-
schemaVersion: "1.0";
|
|
2342
|
-
};
|
|
2343
|
-
answer: boolean;
|
|
2344
2344
|
} | {
|
|
2345
2345
|
type: "currency";
|
|
2346
2346
|
meta: {
|
|
@@ -2415,6 +2415,12 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2415
2415
|
schemaVersion: "1.0";
|
|
2416
2416
|
};
|
|
2417
2417
|
answer: string;
|
|
2418
|
+
} | {
|
|
2419
|
+
type: "boolean";
|
|
2420
|
+
meta: {
|
|
2421
|
+
schemaVersion: "1.0";
|
|
2422
|
+
};
|
|
2423
|
+
answer: boolean;
|
|
2418
2424
|
} | {
|
|
2419
2425
|
type: "checkBoxes";
|
|
2420
2426
|
meta: {
|
|
@@ -2433,12 +2439,6 @@ export declare const TableAnswerSchema: z.ZodObject<{
|
|
|
2433
2439
|
schemaVersion: "1.0";
|
|
2434
2440
|
};
|
|
2435
2441
|
answer: string[];
|
|
2436
|
-
} | {
|
|
2437
|
-
type: "boolean";
|
|
2438
|
-
meta: {
|
|
2439
|
-
schemaVersion: "1.0";
|
|
2440
|
-
};
|
|
2441
|
-
answer: boolean;
|
|
2442
2442
|
} | {
|
|
2443
2443
|
type: "currency";
|
|
2444
2444
|
meta: {
|
|
@@ -10,7 +10,7 @@ const numberAnswers_1 = require("./numberAnswers");
|
|
|
10
10
|
const textAnswers_1 = require("./textAnswers");
|
|
11
11
|
// Answers to Table Column Question Types (note that TableAnswer is not included here because we don't allow nested tables)
|
|
12
12
|
exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
13
|
-
|
|
13
|
+
optionBasedAnswers_1.BooleanAnswerSchema,
|
|
14
14
|
optionBasedAnswers_1.CheckboxesAnswerSchema,
|
|
15
15
|
numberAnswers_1.CurrencyAnswerSchema,
|
|
16
16
|
dateAnswers_1.DateAnswerSchema,
|
|
@@ -2,54 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const numberQuestions_1 = require("../numberQuestions");
|
|
4
4
|
describe("Number Questions Zod Schemas", () => {
|
|
5
|
-
it('optional fields should not throw an error if the value is undefined', () => {
|
|
6
|
-
const validBooleanQuestion = {
|
|
7
|
-
type: "boolean",
|
|
8
|
-
meta: {
|
|
9
|
-
schemaVersion: "1.0",
|
|
10
|
-
},
|
|
11
|
-
attributes: {
|
|
12
|
-
checked: undefined, // Valid value
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
expect(() => numberQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
16
|
-
});
|
|
17
|
-
it('optional fields should throw an error if the value is null', () => {
|
|
18
|
-
const invalidBooleanQuestion = {
|
|
19
|
-
type: "boolean",
|
|
20
|
-
meta: {
|
|
21
|
-
schemaVersion: "1.0",
|
|
22
|
-
},
|
|
23
|
-
attributes: {
|
|
24
|
-
checked: null, // Invalid value
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
expect(() => numberQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
|
|
28
|
-
});
|
|
29
|
-
it("should validate a valid BooleanQuestion", () => {
|
|
30
|
-
const validBooleanQuestion = {
|
|
31
|
-
type: "boolean",
|
|
32
|
-
meta: {
|
|
33
|
-
schemaVersion: "1.0",
|
|
34
|
-
},
|
|
35
|
-
attributes: {
|
|
36
|
-
checked: true,
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
expect(() => numberQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
40
|
-
});
|
|
41
|
-
it("should invalidate an invalid BooleanQuestion", () => {
|
|
42
|
-
const invalidBooleanQuestion = {
|
|
43
|
-
type: "boolean",
|
|
44
|
-
meta: {
|
|
45
|
-
schemaVersion: "1.0",
|
|
46
|
-
},
|
|
47
|
-
attributes: {
|
|
48
|
-
checked: "true", // Invalid type
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
expect(() => numberQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
|
|
52
|
-
});
|
|
53
5
|
it("should validate a valid CurrencyQuestion", () => {
|
|
54
6
|
const validCurrencyQuestion = {
|
|
55
7
|
type: "currency",
|