@dmptool/types 1.0.2 → 1.0.3
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/answers/__tests__/answers.spec.js +32 -32
- package/dist/answers/answer.d.ts +2 -2
- package/dist/answers/answer.js +2 -2
- package/dist/answers/dateAnswers.d.ts +4 -4
- package/dist/answers/dateAnswers.js +3 -3
- package/dist/answers/graphQLAnswers.d.ts +4 -4
- package/dist/answers/graphQLAnswers.js +3 -3
- package/dist/answers/index.d.ts +2 -2
- package/dist/answers/index.js +17 -17
- package/dist/answers/optionBasedAnswers.d.ts +6 -6
- package/dist/answers/optionBasedAnswers.js +4 -4
- package/dist/answers/primitiveAnswers.d.ts +14 -14
- package/dist/answers/primitiveAnswers.js +8 -8
- package/dist/answers/tableAnswers.d.ts +4 -4
- package/dist/answers/tableAnswers.js +18 -18
- package/dist/questions/__tests__/dateQuestions.spec.js +6 -6
- package/dist/questions/__tests__/graphQLQuestions.spec.js +4 -4
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +6 -6
- package/dist/questions/__tests__/primitiveQuestions.spec.js +14 -14
- package/dist/questions/dateQuestions.d.ts +4 -4
- package/dist/questions/dateQuestions.js +5 -5
- package/dist/questions/graphQLQuestions.d.ts +4 -4
- package/dist/questions/graphQLQuestions.js +3 -3
- package/dist/questions/index.d.ts +2 -2
- package/dist/questions/index.js +17 -17
- package/dist/questions/optionBasedQuestions.d.ts +6 -6
- package/dist/questions/optionBasedQuestions.js +11 -11
- package/dist/questions/primitiveQuestions.d.ts +14 -14
- package/dist/questions/primitiveQuestions.js +8 -8
- package/dist/questions/question.d.ts +2 -2
- package/dist/questions/question.js +2 -2
- package/dist/questions/tableQuestions.d.ts +4 -4
- package/dist/questions/tableQuestions.js +18 -18
- package/package.json +1 -1
|
@@ -25,7 +25,7 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
|
25
25
|
schemaVersion: "1.0"
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
28
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.FilteredSearchQuestionSchema.parse(validData)).not.toThrow();
|
|
29
29
|
});
|
|
30
30
|
(0, globals_1.it)("should throw an error for an invalid FilteredSearchQuestion object", () => {
|
|
31
31
|
const invalidData = {
|
|
@@ -46,7 +46,7 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
|
46
46
|
schemaVersion: "1.0"
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
49
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.FilteredSearchQuestionSchema.parse(invalidData)).toThrow();
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
(0, globals_1.describe)("TypeaheadSearchQuestion schema", () => {
|
|
@@ -67,7 +67,7 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
|
67
67
|
schemaVersion: "1.0"
|
|
68
68
|
}
|
|
69
69
|
};
|
|
70
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
70
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.TypeaheadSearchQuestionSchema.parse(validData)).not.toThrow();
|
|
71
71
|
});
|
|
72
72
|
(0, globals_1.it)("should throw an error for an invalid TypeaheadSearchQuestion object", () => {
|
|
73
73
|
const invalidData = {
|
|
@@ -82,6 +82,6 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
|
82
82
|
],
|
|
83
83
|
},
|
|
84
84
|
};
|
|
85
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
85
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.TypeaheadSearchQuestionSchema.parse(invalidData)).toThrow();
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -27,7 +27,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
27
27
|
schemaVersion: "1.0"
|
|
28
28
|
}
|
|
29
29
|
};
|
|
30
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
30
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.CheckboxesQuestionSchema.parse(validCheckboxesQuestion)).not.toThrow();
|
|
31
31
|
});
|
|
32
32
|
(0, globals_1.it)("should throw an error for an invalid CheckboxesQuestion object", () => {
|
|
33
33
|
const invalidCheckboxesQuestion = {
|
|
@@ -46,7 +46,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
46
46
|
schemaVersion: "1.0"
|
|
47
47
|
}
|
|
48
48
|
};
|
|
49
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
49
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.CheckboxesQuestionSchema.parse(invalidCheckboxesQuestion)).toThrow();
|
|
50
50
|
});
|
|
51
51
|
});
|
|
52
52
|
(0, globals_1.describe)("RadioButtonsQuestion", () => {
|
|
@@ -74,7 +74,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
74
74
|
schemaVersion: "1.0"
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
77
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.RadioButtonsQuestionSchema.parse(validRadioButtonsQuestion)).not.toThrow();
|
|
78
78
|
});
|
|
79
79
|
(0, globals_1.it)("should throw an error for an invalid RadioButtonsQuestion object", () => {
|
|
80
80
|
const invalidRadioButtonsQuestion = {
|
|
@@ -93,7 +93,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
93
93
|
schemaVersion: "1.0"
|
|
94
94
|
}
|
|
95
95
|
};
|
|
96
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
96
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.RadioButtonsQuestionSchema.parse(invalidRadioButtonsQuestion)).toThrow();
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
(0, globals_1.describe)("SelectBoxQuestion", () => {
|
|
@@ -124,7 +124,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
124
124
|
schemaVersion: "1.0"
|
|
125
125
|
}
|
|
126
126
|
};
|
|
127
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
127
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.SelectBoxQuestionSchema.parse(validSelectBoxQuestion)).not.toThrow();
|
|
128
128
|
});
|
|
129
129
|
(0, globals_1.it)("should throw an error for an invalid SelectBoxQuestion object", () => {
|
|
130
130
|
const invalidSelectBoxQuestion = {
|
|
@@ -147,6 +147,6 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
147
147
|
schemaVersion: "1.0"
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
|
-
(0, globals_1.expect)(() => optionBasedQuestions_1.
|
|
150
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.SelectBoxQuestionSchema.parse(invalidSelectBoxQuestion)).toThrow();
|
|
151
151
|
});
|
|
152
152
|
});
|
|
@@ -12,7 +12,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
12
12
|
checked: true,
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
|
-
expect(() => primitiveQuestions_1.
|
|
15
|
+
expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
|
|
16
16
|
});
|
|
17
17
|
it("should invalidate an invalid BooleanQuestion", () => {
|
|
18
18
|
const invalidBooleanQuestion = {
|
|
@@ -24,7 +24,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
24
24
|
checked: "true", // Invalid type
|
|
25
25
|
},
|
|
26
26
|
};
|
|
27
|
-
expect(() => primitiveQuestions_1.
|
|
27
|
+
expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
|
|
28
28
|
});
|
|
29
29
|
it("should validate a valid CurrencyQuestion", () => {
|
|
30
30
|
const validCurrencyQuestion = {
|
|
@@ -39,7 +39,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
39
39
|
step: 0.01,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
|
-
expect(() => primitiveQuestions_1.
|
|
42
|
+
expect(() => primitiveQuestions_1.CurrencyQuestionSchema.parse(validCurrencyQuestion)).not.toThrow();
|
|
43
43
|
});
|
|
44
44
|
it("should invalidate an invalid CurrencyQuestion", () => {
|
|
45
45
|
const invalidCurrencyQuestion = {
|
|
@@ -51,7 +51,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
51
51
|
max: "100", // Invalid type
|
|
52
52
|
},
|
|
53
53
|
};
|
|
54
|
-
expect(() => primitiveQuestions_1.
|
|
54
|
+
expect(() => primitiveQuestions_1.CurrencyQuestionSchema.parse(invalidCurrencyQuestion)).toThrow();
|
|
55
55
|
});
|
|
56
56
|
it("should validate a valid EmailQuestion", () => {
|
|
57
57
|
const validEmailQuestion = {
|
|
@@ -66,7 +66,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
66
66
|
pattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
|
|
67
67
|
},
|
|
68
68
|
};
|
|
69
|
-
expect(() => primitiveQuestions_1.
|
|
69
|
+
expect(() => primitiveQuestions_1.EmailQuestionSchema.parse(validEmailQuestion)).not.toThrow();
|
|
70
70
|
});
|
|
71
71
|
it("should invalidate an invalid EmailQuestion", () => {
|
|
72
72
|
const invalidEmailQuestion = {
|
|
@@ -78,7 +78,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
78
78
|
maxLength: "50", // Invalid type
|
|
79
79
|
},
|
|
80
80
|
};
|
|
81
|
-
expect(() => primitiveQuestions_1.
|
|
81
|
+
expect(() => primitiveQuestions_1.EmailQuestionSchema.parse(invalidEmailQuestion)).toThrow();
|
|
82
82
|
});
|
|
83
83
|
it("should validate a valid NumberQuestion", () => {
|
|
84
84
|
const validNumberQuestion = {
|
|
@@ -92,7 +92,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
92
92
|
step: 1,
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
|
-
expect(() => primitiveQuestions_1.
|
|
95
|
+
expect(() => primitiveQuestions_1.NumberQuestionSchema.parse(validNumberQuestion)).not.toThrow();
|
|
96
96
|
});
|
|
97
97
|
it("should invalidate an invalid NumberQuestion", () => {
|
|
98
98
|
const invalidNumberQuestion = {
|
|
@@ -104,7 +104,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
104
104
|
step: "1", // Invalid type
|
|
105
105
|
},
|
|
106
106
|
};
|
|
107
|
-
expect(() => primitiveQuestions_1.
|
|
107
|
+
expect(() => primitiveQuestions_1.NumberQuestionSchema.parse(invalidNumberQuestion)).toThrow();
|
|
108
108
|
});
|
|
109
109
|
it("should validate a valid TextAreaQuestion", () => {
|
|
110
110
|
const validTextAreaQuestion = {
|
|
@@ -120,7 +120,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
120
120
|
minLength: 10,
|
|
121
121
|
},
|
|
122
122
|
};
|
|
123
|
-
expect(() => primitiveQuestions_1.
|
|
123
|
+
expect(() => primitiveQuestions_1.TextAreaQuestionSchema.parse(validTextAreaQuestion)).not.toThrow();
|
|
124
124
|
});
|
|
125
125
|
it("should invalidate an invalid TextAreaQuestion", () => {
|
|
126
126
|
const invalidTextAreaQuestion = {
|
|
@@ -132,7 +132,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
132
132
|
cols: "30", // Invalid type
|
|
133
133
|
},
|
|
134
134
|
};
|
|
135
|
-
expect(() => primitiveQuestions_1.
|
|
135
|
+
expect(() => primitiveQuestions_1.TextAreaQuestionSchema.parse(invalidTextAreaQuestion)).toThrow();
|
|
136
136
|
});
|
|
137
137
|
it("should validate a valid TextQuestion", () => {
|
|
138
138
|
const validTextQuestion = {
|
|
@@ -146,7 +146,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
146
146
|
pattern: "^[a-zA-Z]+$",
|
|
147
147
|
},
|
|
148
148
|
};
|
|
149
|
-
expect(() => primitiveQuestions_1.
|
|
149
|
+
expect(() => primitiveQuestions_1.TextQuestionSchema.parse(validTextQuestion)).not.toThrow();
|
|
150
150
|
});
|
|
151
151
|
it("should invalidate an invalid TextQuestion", () => {
|
|
152
152
|
const invalidTextQuestion = {
|
|
@@ -158,7 +158,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
158
158
|
maxLength: "100", // Invalid type
|
|
159
159
|
},
|
|
160
160
|
};
|
|
161
|
-
expect(() => primitiveQuestions_1.
|
|
161
|
+
expect(() => primitiveQuestions_1.TextQuestionSchema.parse(invalidTextQuestion)).toThrow();
|
|
162
162
|
});
|
|
163
163
|
it("should validate a valid URLQuestion", () => {
|
|
164
164
|
const validURLQuestion = {
|
|
@@ -172,7 +172,7 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
172
172
|
pattern: "https?://.+",
|
|
173
173
|
},
|
|
174
174
|
};
|
|
175
|
-
expect(() => primitiveQuestions_1.
|
|
175
|
+
expect(() => primitiveQuestions_1.URLQuestionSchema.parse(validURLQuestion)).not.toThrow();
|
|
176
176
|
});
|
|
177
177
|
it("should invalidate an invalid URLQuestion", () => {
|
|
178
178
|
const invalidURLQuestion = {
|
|
@@ -184,6 +184,6 @@ describe("Primitive Questions Zod Schemas", () => {
|
|
|
184
184
|
maxLength: "200", // Invalid type
|
|
185
185
|
},
|
|
186
186
|
};
|
|
187
|
-
expect(() => primitiveQuestions_1.
|
|
187
|
+
expect(() => primitiveQuestions_1.URLQuestionSchema.parse(invalidURLQuestion)).toThrow();
|
|
188
188
|
});
|
|
189
189
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const DatePickerQuestionSchema: z.ZodObject<{
|
|
3
3
|
meta: z.ZodObject<{
|
|
4
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
5
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -48,7 +48,7 @@ export declare const DatePickerQuestion: z.ZodObject<{
|
|
|
48
48
|
step?: number | undefined;
|
|
49
49
|
};
|
|
50
50
|
}>;
|
|
51
|
-
export declare const
|
|
51
|
+
export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
52
52
|
meta: z.ZodObject<{
|
|
53
53
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
54
54
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -240,5 +240,5 @@ export declare const DateRangeQuestion: z.ZodObject<{
|
|
|
240
240
|
};
|
|
241
241
|
};
|
|
242
242
|
}>;
|
|
243
|
-
export type DatePickerQuestionType = z.infer<typeof
|
|
244
|
-
export type DateRangeQuestionType = z.infer<typeof
|
|
243
|
+
export type DatePickerQuestionType = z.infer<typeof DatePickerQuestionSchema>;
|
|
244
|
+
export type DateRangeQuestionType = z.infer<typeof DateRangeQuestionSchema>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.DateRangeQuestionSchema = exports.DatePickerQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
// Date picker question and answer
|
|
7
|
-
exports.
|
|
7
|
+
exports.DatePickerQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
8
8
|
type: zod_1.z.literal('datePicker'), // The type of question
|
|
9
9
|
attributes: zod_1.z.object({
|
|
10
10
|
max: zod_1.z.string().optional(), // The maximum date (no default)
|
|
@@ -13,15 +13,15 @@ exports.DatePickerQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
13
13
|
})
|
|
14
14
|
}));
|
|
15
15
|
// Date range question and answer
|
|
16
|
-
exports.
|
|
16
|
+
exports.DateRangeQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
17
17
|
type: zod_1.z.literal('dateRange'), // The type of question
|
|
18
18
|
columns: zod_1.z.object({
|
|
19
|
-
start: exports.
|
|
19
|
+
start: exports.DatePickerQuestionSchema.merge(zod_1.z.object({
|
|
20
20
|
attributes: zod_1.z.object({
|
|
21
21
|
label: zod_1.z.string() // The label for the start date picker
|
|
22
22
|
})
|
|
23
23
|
})),
|
|
24
|
-
end: exports.
|
|
24
|
+
end: exports.DatePickerQuestionSchema.merge(zod_1.z.object({
|
|
25
25
|
attributes: zod_1.z.object({
|
|
26
26
|
label: zod_1.z.string() // The label for the end date picker
|
|
27
27
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const FilteredSearchQuestionSchema: z.ZodObject<{
|
|
3
3
|
meta: z.ZodObject<{
|
|
4
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
5
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -148,7 +148,7 @@ export declare const FilteredSearchQuestion: z.ZodObject<{
|
|
|
148
148
|
query?: string | undefined;
|
|
149
149
|
};
|
|
150
150
|
}>;
|
|
151
|
-
export declare const
|
|
151
|
+
export declare const TypeaheadSearchQuestionSchema: z.ZodObject<{
|
|
152
152
|
meta: z.ZodObject<{
|
|
153
153
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
154
154
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -284,5 +284,5 @@ export declare const TypeaheadSearchQuestion: z.ZodObject<{
|
|
|
284
284
|
query?: string | undefined;
|
|
285
285
|
};
|
|
286
286
|
}>;
|
|
287
|
-
export type FilteredSearchQuestionType = z.infer<typeof
|
|
288
|
-
export type TypeaheadSearchQuestionType = z.infer<typeof
|
|
287
|
+
export type FilteredSearchQuestionType = z.infer<typeof FilteredSearchQuestionSchema>;
|
|
288
|
+
export type TypeaheadSearchQuestionType = z.infer<typeof TypeaheadSearchQuestionSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TypeaheadSearchQuestionSchema = exports.FilteredSearchQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
// An input variable for a GraphQL query
|
|
@@ -27,7 +27,7 @@ const GraphQLQuery = zod_1.z.object({
|
|
|
27
27
|
variables: zod_1.z.array(GraphQLVariable) // The variables for the query
|
|
28
28
|
});
|
|
29
29
|
// Filtered search question and answer
|
|
30
|
-
exports.
|
|
30
|
+
exports.FilteredSearchQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
31
31
|
type: zod_1.z.literal('filteredSearch'), // The type of question
|
|
32
32
|
graphQL: GraphQLQuery, // The GraphQL query options for the filtered search
|
|
33
33
|
attributes: zod_1.z.object({
|
|
@@ -35,7 +35,7 @@ exports.FilteredSearchQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
35
35
|
})
|
|
36
36
|
}));
|
|
37
37
|
// Typeahead search question and answer
|
|
38
|
-
exports.
|
|
38
|
+
exports.TypeaheadSearchQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
39
39
|
type: zod_1.z.literal('typeaheadSearch'), // The type of question
|
|
40
40
|
graphQL: GraphQLQuery, // The GraphQL query options for the typeahead search
|
|
41
41
|
}));
|
|
@@ -5,7 +5,7 @@ export * from './graphQLQuestions';
|
|
|
5
5
|
export * from './optionBasedQuestions';
|
|
6
6
|
export * from './primitiveQuestions';
|
|
7
7
|
export * from './tableQuestions';
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
9
9
|
meta: z.ZodObject<{
|
|
10
10
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
11
11
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -2639,4 +2639,4 @@ export declare const AnyQuestion: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
|
2639
2639
|
pattern?: string | undefined;
|
|
2640
2640
|
};
|
|
2641
2641
|
}>]>;
|
|
2642
|
-
export type AnyQuestionType = z.infer<typeof
|
|
2642
|
+
export type AnyQuestionType = z.infer<typeof AnyQuestionSchema>;
|
package/dist/questions/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.AnyQuestionSchema = void 0;
|
|
18
18
|
const zod_1 = require("zod");
|
|
19
19
|
const primitiveQuestions_1 = require("./primitiveQuestions");
|
|
20
20
|
const dateQuestions_1 = require("./dateQuestions");
|
|
@@ -29,20 +29,20 @@ __exportStar(require("./optionBasedQuestions"), exports);
|
|
|
29
29
|
__exportStar(require("./primitiveQuestions"), exports);
|
|
30
30
|
__exportStar(require("./tableQuestions"), exports);
|
|
31
31
|
// All of the possible questions
|
|
32
|
-
exports.
|
|
33
|
-
primitiveQuestions_1.
|
|
34
|
-
optionBasedQuestions_1.
|
|
35
|
-
primitiveQuestions_1.
|
|
36
|
-
dateQuestions_1.
|
|
37
|
-
dateQuestions_1.
|
|
38
|
-
primitiveQuestions_1.
|
|
39
|
-
graphQLQuestions_1.
|
|
40
|
-
primitiveQuestions_1.
|
|
41
|
-
optionBasedQuestions_1.
|
|
42
|
-
optionBasedQuestions_1.
|
|
43
|
-
tableQuestions_1.
|
|
44
|
-
primitiveQuestions_1.
|
|
45
|
-
primitiveQuestions_1.
|
|
46
|
-
graphQLQuestions_1.
|
|
47
|
-
primitiveQuestions_1.
|
|
32
|
+
exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
|
|
33
|
+
primitiveQuestions_1.BooleanQuestionSchema,
|
|
34
|
+
optionBasedQuestions_1.CheckboxesQuestionSchema,
|
|
35
|
+
primitiveQuestions_1.CurrencyQuestionSchema,
|
|
36
|
+
dateQuestions_1.DatePickerQuestionSchema,
|
|
37
|
+
dateQuestions_1.DateRangeQuestionSchema,
|
|
38
|
+
primitiveQuestions_1.EmailQuestionSchema,
|
|
39
|
+
graphQLQuestions_1.FilteredSearchQuestionSchema,
|
|
40
|
+
primitiveQuestions_1.NumberQuestionSchema,
|
|
41
|
+
optionBasedQuestions_1.RadioButtonsQuestionSchema,
|
|
42
|
+
optionBasedQuestions_1.SelectBoxQuestionSchema,
|
|
43
|
+
tableQuestions_1.TableQuestionSchema,
|
|
44
|
+
primitiveQuestions_1.TextAreaQuestionSchema,
|
|
45
|
+
primitiveQuestions_1.TextQuestionSchema,
|
|
46
|
+
graphQLQuestions_1.TypeaheadSearchQuestionSchema,
|
|
47
|
+
primitiveQuestions_1.URLQuestionSchema
|
|
48
48
|
]);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const CheckboxesQuestionSchema: z.ZodObject<{
|
|
3
3
|
meta: z.ZodObject<{
|
|
4
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
5
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -72,7 +72,7 @@ export declare const CheckboxesQuestion: z.ZodObject<{
|
|
|
72
72
|
labelTranslationKey?: string | undefined;
|
|
73
73
|
};
|
|
74
74
|
}>;
|
|
75
|
-
export declare const
|
|
75
|
+
export declare const RadioButtonsQuestionSchema: z.ZodObject<{
|
|
76
76
|
meta: z.ZodObject<{
|
|
77
77
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
78
78
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -145,7 +145,7 @@ export declare const RadioButtonsQuestion: z.ZodObject<{
|
|
|
145
145
|
labelTranslationKey?: string | undefined;
|
|
146
146
|
};
|
|
147
147
|
}>;
|
|
148
|
-
export declare const
|
|
148
|
+
export declare const SelectBoxQuestionSchema: z.ZodObject<{
|
|
149
149
|
meta: z.ZodObject<{
|
|
150
150
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
151
151
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -231,6 +231,6 @@ export declare const SelectBoxQuestion: z.ZodObject<{
|
|
|
231
231
|
multiple?: boolean | undefined;
|
|
232
232
|
};
|
|
233
233
|
}>;
|
|
234
|
-
export type CheckboxesQuestionType = z.infer<typeof
|
|
235
|
-
export type RadioButtonsQuestionType = z.infer<typeof
|
|
236
|
-
export type SelectBoxQuestionType = z.infer<typeof
|
|
234
|
+
export type CheckboxesQuestionType = z.infer<typeof CheckboxesQuestionSchema>;
|
|
235
|
+
export type RadioButtonsQuestionType = z.infer<typeof RadioButtonsQuestionSchema>;
|
|
236
|
+
export type SelectBoxQuestionType = z.infer<typeof SelectBoxQuestionSchema>;
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.SelectBoxQuestionSchema = exports.RadioButtonsQuestionSchema = exports.CheckboxesQuestionSchema = 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
|
|
7
|
-
const
|
|
7
|
+
const OptionSchema = zod_1.z.object({
|
|
8
8
|
type: zod_1.z.literal('option'), // The type of option
|
|
9
9
|
attributes: zod_1.z.object({
|
|
10
10
|
label: zod_1.z.string(), // The label of the option
|
|
11
11
|
value: zod_1.z.string(), // The value of the option
|
|
12
12
|
}),
|
|
13
13
|
});
|
|
14
|
-
const BaseOptionAttributes =
|
|
15
|
-
const
|
|
14
|
+
const BaseOptionAttributes = OptionSchema.shape.attributes;
|
|
15
|
+
const CheckedOptionSchema = zod_1.z.object({
|
|
16
16
|
type: zod_1.z.literal('option'),
|
|
17
17
|
attributes: BaseOptionAttributes.extend({
|
|
18
18
|
checked: zod_1.z.boolean().optional(),
|
|
19
19
|
}),
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const SelectedOptionSchema = zod_1.z.object({
|
|
22
22
|
type: zod_1.z.literal('option'),
|
|
23
23
|
attributes: BaseOptionAttributes.extend({
|
|
24
24
|
selected: zod_1.z.boolean().optional(),
|
|
25
25
|
}),
|
|
26
26
|
});
|
|
27
27
|
// Check boxes question and answer
|
|
28
|
-
exports.
|
|
28
|
+
exports.CheckboxesQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
29
29
|
type: zod_1.z.literal('checkBoxes'), // The type of question
|
|
30
|
-
options: zod_1.z.array(
|
|
30
|
+
options: zod_1.z.array(CheckedOptionSchema)
|
|
31
31
|
}));
|
|
32
32
|
// Radio buttons question and answer
|
|
33
|
-
exports.
|
|
33
|
+
exports.RadioButtonsQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
34
34
|
type: zod_1.z.literal('radioButtons'), // The type of question
|
|
35
|
-
options: zod_1.z.array(
|
|
35
|
+
options: zod_1.z.array(SelectedOptionSchema)
|
|
36
36
|
}));
|
|
37
37
|
// Select box question and answer
|
|
38
|
-
exports.
|
|
38
|
+
exports.SelectBoxQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
39
39
|
type: zod_1.z.literal('selectBox'), // The type of question
|
|
40
|
-
options: zod_1.z.array(
|
|
40
|
+
options: zod_1.z.array(SelectedOptionSchema),
|
|
41
41
|
attributes: zod_1.z.object({
|
|
42
42
|
multiple: zod_1.z.boolean().optional() // Whether to allow multiple selections (default is false)
|
|
43
43
|
})
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const BooleanQuestionSchema: z.ZodObject<{
|
|
3
3
|
meta: z.ZodObject<{
|
|
4
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
5
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -38,7 +38,7 @@ export declare const BooleanQuestion: z.ZodObject<{
|
|
|
38
38
|
checked?: boolean | undefined;
|
|
39
39
|
};
|
|
40
40
|
}>;
|
|
41
|
-
export declare const
|
|
41
|
+
export declare const NumberQuestionSchema: z.ZodObject<{
|
|
42
42
|
meta: z.ZodObject<{
|
|
43
43
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
44
44
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -87,7 +87,7 @@ export declare const NumberQuestion: z.ZodObject<{
|
|
|
87
87
|
step?: number | undefined;
|
|
88
88
|
};
|
|
89
89
|
}>;
|
|
90
|
-
export declare const
|
|
90
|
+
export declare const CurrencyQuestionSchema: z.ZodObject<{
|
|
91
91
|
attributes: z.ZodObject<{
|
|
92
92
|
max: z.ZodOptional<z.ZodNumber>;
|
|
93
93
|
min: z.ZodOptional<z.ZodNumber>;
|
|
@@ -131,7 +131,7 @@ export declare const CurrencyQuestion: z.ZodObject<{
|
|
|
131
131
|
step?: number | undefined;
|
|
132
132
|
};
|
|
133
133
|
}>;
|
|
134
|
-
export declare const
|
|
134
|
+
export declare const EmailQuestionSchema: z.ZodObject<{
|
|
135
135
|
meta: z.ZodObject<{
|
|
136
136
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
137
137
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -185,7 +185,7 @@ export declare const EmailQuestion: z.ZodObject<{
|
|
|
185
185
|
pattern?: string | undefined;
|
|
186
186
|
};
|
|
187
187
|
}>;
|
|
188
|
-
export declare const
|
|
188
|
+
export declare const TextAreaQuestionSchema: z.ZodObject<{} & {
|
|
189
189
|
type: z.ZodLiteral<"textArea">;
|
|
190
190
|
attributes: z.ZodObject<{
|
|
191
191
|
cols: z.ZodOptional<z.ZodNumber>;
|
|
@@ -233,7 +233,7 @@ export declare const TextAreaQuestion: z.ZodObject<{} & {
|
|
|
233
233
|
rows?: number | undefined;
|
|
234
234
|
};
|
|
235
235
|
}>;
|
|
236
|
-
export declare const
|
|
236
|
+
export declare const TextQuestionSchema: z.ZodObject<{
|
|
237
237
|
meta: z.ZodObject<{
|
|
238
238
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
239
239
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -282,7 +282,7 @@ export declare const TextQuestion: z.ZodObject<{
|
|
|
282
282
|
pattern?: string | undefined;
|
|
283
283
|
};
|
|
284
284
|
}>;
|
|
285
|
-
export declare const
|
|
285
|
+
export declare const URLQuestionSchema: z.ZodObject<{
|
|
286
286
|
meta: z.ZodObject<{
|
|
287
287
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
288
288
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -331,10 +331,10 @@ export declare const URLQuestion: z.ZodObject<{
|
|
|
331
331
|
pattern?: string | undefined;
|
|
332
332
|
};
|
|
333
333
|
}>;
|
|
334
|
-
export type BooleanQuestionType = z.infer<typeof
|
|
335
|
-
export type CurrencyQuestionType = z.infer<typeof
|
|
336
|
-
export type EmailQuestionType = z.infer<typeof
|
|
337
|
-
export type NumberQuestionType = z.infer<typeof
|
|
338
|
-
export type TextAreaQuestionType = z.infer<typeof
|
|
339
|
-
export type TextQuestionType = z.infer<typeof
|
|
340
|
-
export type URLQuestionType = z.infer<typeof
|
|
334
|
+
export type BooleanQuestionType = z.infer<typeof BooleanQuestionSchema>;
|
|
335
|
+
export type CurrencyQuestionType = z.infer<typeof CurrencyQuestionSchema>;
|
|
336
|
+
export type EmailQuestionType = z.infer<typeof EmailQuestionSchema>;
|
|
337
|
+
export type NumberQuestionType = z.infer<typeof NumberQuestionSchema>;
|
|
338
|
+
export type TextAreaQuestionType = z.infer<typeof TextAreaQuestionSchema>;
|
|
339
|
+
export type TextQuestionType = z.infer<typeof TextQuestionSchema>;
|
|
340
|
+
export type URLQuestionType = z.infer<typeof URLQuestionSchema>;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.URLQuestionSchema = exports.TextQuestionSchema = exports.TextAreaQuestionSchema = exports.EmailQuestionSchema = exports.CurrencyQuestionSchema = exports.NumberQuestionSchema = exports.BooleanQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
// A Yes/No True/False question and answer
|
|
7
|
-
exports.
|
|
7
|
+
exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
8
8
|
type: zod_1.z.literal('boolean'), // The type of question
|
|
9
9
|
attributes: zod_1.z.object({
|
|
10
10
|
checked: zod_1.z.boolean().optional() // If it is checked by default when rendered (default is false)
|
|
11
11
|
})
|
|
12
12
|
}));
|
|
13
13
|
// A number question and answer
|
|
14
|
-
exports.
|
|
14
|
+
exports.NumberQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
15
15
|
type: zod_1.z.literal('number'), // The type of question
|
|
16
16
|
attributes: zod_1.z.object({
|
|
17
17
|
max: zod_1.z.number().optional(), // The maximum value (no default)
|
|
@@ -20,14 +20,14 @@ exports.NumberQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
20
20
|
})
|
|
21
21
|
}));
|
|
22
22
|
// Currency question and answer
|
|
23
|
-
exports.
|
|
23
|
+
exports.CurrencyQuestionSchema = exports.NumberQuestionSchema.merge(zod_1.z.object({
|
|
24
24
|
type: zod_1.z.literal('currency'), // The type of question
|
|
25
25
|
meta: zod_1.z.object({
|
|
26
26
|
denomination: zod_1.z.string().optional() // The currency denomination (default is USD)
|
|
27
27
|
})
|
|
28
28
|
}));
|
|
29
29
|
// Email question and answer
|
|
30
|
-
exports.
|
|
30
|
+
exports.EmailQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
31
31
|
type: zod_1.z.literal('email'), // The type of question
|
|
32
32
|
attributes: zod_1.z.object({
|
|
33
33
|
maxLength: zod_1.z.number().optional(), // The maximum length of the email (no default)
|
|
@@ -37,7 +37,7 @@ exports.EmailQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
37
37
|
})
|
|
38
38
|
}));
|
|
39
39
|
// Text area question and answer
|
|
40
|
-
exports.
|
|
40
|
+
exports.TextAreaQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
41
41
|
type: zod_1.z.literal('textArea'), // The type of question
|
|
42
42
|
attributes: zod_1.z.object({
|
|
43
43
|
cols: zod_1.z.number().optional(), // The number of columns (default is 20)
|
|
@@ -50,7 +50,7 @@ exports.TextAreaQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
50
50
|
})
|
|
51
51
|
}));
|
|
52
52
|
// Text question and answer
|
|
53
|
-
exports.
|
|
53
|
+
exports.TextQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
54
54
|
type: zod_1.z.literal('text'), // The type of question
|
|
55
55
|
attributes: zod_1.z.object({
|
|
56
56
|
maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
|
|
@@ -59,7 +59,7 @@ exports.TextQuestion = question_1.Question.merge(zod_1.z.object({
|
|
|
59
59
|
}),
|
|
60
60
|
}));
|
|
61
61
|
// URL question and answer
|
|
62
|
-
exports.
|
|
62
|
+
exports.URLQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
63
63
|
type: zod_1.z.literal('url'), // The type of question
|
|
64
64
|
attributes: zod_1.z.object({
|
|
65
65
|
maxLength: zod_1.z.number().optional(), // The maximum length of the URL (no default)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const CURRENT_SCHEMA_VERSION = "1.0";
|
|
3
3
|
export declare const QuestionTypesEnum: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "option", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const QuestionSchema: z.ZodObject<{
|
|
5
5
|
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "option", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
6
6
|
meta: z.ZodObject<{
|
|
7
7
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
@@ -26,4 +26,4 @@ export declare const Question: z.ZodObject<{
|
|
|
26
26
|
labelTranslationKey?: string | undefined;
|
|
27
27
|
};
|
|
28
28
|
}>;
|
|
29
|
-
export type QuestionType = z.infer<typeof
|
|
29
|
+
export type QuestionType = z.infer<typeof QuestionSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.QuestionSchema = exports.QuestionTypesEnum = exports.CURRENT_SCHEMA_VERSION = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.CURRENT_SCHEMA_VERSION = '1.0'; // The current schema version
|
|
6
6
|
// The type of question
|
|
@@ -23,7 +23,7 @@ exports.QuestionTypesEnum = zod_1.z.enum([
|
|
|
23
23
|
'url'
|
|
24
24
|
]);
|
|
25
25
|
// Base abstract type for all questions
|
|
26
|
-
exports.
|
|
26
|
+
exports.QuestionSchema = zod_1.z.object({
|
|
27
27
|
type: exports.QuestionTypesEnum, // The type of question
|
|
28
28
|
meta: zod_1.z.object({
|
|
29
29
|
schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
|