@dmptool/types 1.0.2 → 1.0.4
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 +5 -5
- 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 +4 -2
- package/dist/answers/index.js +35 -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 +4 -2
- package/dist/questions/index.js +35 -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 +6 -6
- package/dist/questions/question.js +2 -3
- package/dist/questions/tableQuestions.d.ts +4 -4
- package/dist/questions/tableQuestions.js +18 -18
- package/package.json +1 -1
|
@@ -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,8 +1,8 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
export declare const CURRENT_SCHEMA_VERSION = "1.0";
|
|
3
|
-
export declare const QuestionTypesEnum: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "
|
|
4
|
-
export declare const
|
|
5
|
-
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "
|
|
3
|
+
export declare const QuestionTypesEnum: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
4
|
+
export declare const QuestionSchema: z.ZodObject<{
|
|
5
|
+
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
6
6
|
meta: z.ZodObject<{
|
|
7
7
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
8
8
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -14,16 +14,16 @@ export declare const Question: z.ZodObject<{
|
|
|
14
14
|
labelTranslationKey?: string | undefined;
|
|
15
15
|
}>;
|
|
16
16
|
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "
|
|
17
|
+
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
18
18
|
meta: {
|
|
19
19
|
schemaVersion: "1.0";
|
|
20
20
|
labelTranslationKey?: string | undefined;
|
|
21
21
|
};
|
|
22
22
|
}, {
|
|
23
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "
|
|
23
|
+
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
24
24
|
meta: {
|
|
25
25
|
schemaVersion: "1.0";
|
|
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
|
|
@@ -13,7 +13,6 @@ exports.QuestionTypesEnum = zod_1.z.enum([
|
|
|
13
13
|
'email',
|
|
14
14
|
'filteredSearch',
|
|
15
15
|
'number',
|
|
16
|
-
'option',
|
|
17
16
|
'radioButtons',
|
|
18
17
|
'selectBox',
|
|
19
18
|
'table',
|
|
@@ -23,7 +22,7 @@ exports.QuestionTypesEnum = zod_1.z.enum([
|
|
|
23
22
|
'url'
|
|
24
23
|
]);
|
|
25
24
|
// Base abstract type for all questions
|
|
26
|
-
exports.
|
|
25
|
+
exports.QuestionSchema = zod_1.z.object({
|
|
27
26
|
type: exports.QuestionTypesEnum, // The type of question
|
|
28
27
|
meta: zod_1.z.object({
|
|
29
28
|
schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const AnyTableColumnQuestionSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
|
|
3
3
|
meta: z.ZodObject<{
|
|
4
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
5
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -1076,7 +1076,7 @@ export declare const AnyTableColumnQuestion: z.ZodDiscriminatedUnion<"type", [z.
|
|
|
1076
1076
|
pattern?: string | undefined;
|
|
1077
1077
|
};
|
|
1078
1078
|
}>]>;
|
|
1079
|
-
export declare const
|
|
1079
|
+
export declare const TableQuestionSchema: z.ZodObject<{
|
|
1080
1080
|
meta: z.ZodObject<{
|
|
1081
1081
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
1082
1082
|
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
@@ -2634,5 +2634,5 @@ export declare const TableQuestion: z.ZodObject<{
|
|
|
2634
2634
|
};
|
|
2635
2635
|
})[];
|
|
2636
2636
|
}>;
|
|
2637
|
-
export type TableQuestionType = z.infer<typeof
|
|
2638
|
-
export type AnyTableColumnQuestionType = z.infer<typeof
|
|
2637
|
+
export type TableQuestionType = z.infer<typeof TableQuestionSchema>;
|
|
2638
|
+
export type AnyTableColumnQuestionType = z.infer<typeof AnyTableColumnQuestionSchema>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.TableQuestionSchema = exports.AnyTableColumnQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const primitiveQuestions_1 = require("./primitiveQuestions");
|
|
6
6
|
const dateQuestions_1 = require("./dateQuestions");
|
|
@@ -8,26 +8,26 @@ const optionBasedQuestions_1 = require("./optionBasedQuestions");
|
|
|
8
8
|
const graphQLQuestions_1 = require("./graphQLQuestions");
|
|
9
9
|
const question_1 = require("./question");
|
|
10
10
|
// Union types for all questions and answers (tables cannot be nested so no TableQuestion here!)
|
|
11
|
-
exports.
|
|
12
|
-
primitiveQuestions_1.
|
|
13
|
-
optionBasedQuestions_1.
|
|
14
|
-
primitiveQuestions_1.
|
|
15
|
-
dateQuestions_1.
|
|
16
|
-
dateQuestions_1.
|
|
17
|
-
primitiveQuestions_1.
|
|
18
|
-
graphQLQuestions_1.
|
|
19
|
-
primitiveQuestions_1.
|
|
20
|
-
optionBasedQuestions_1.
|
|
21
|
-
optionBasedQuestions_1.
|
|
22
|
-
primitiveQuestions_1.
|
|
23
|
-
primitiveQuestions_1.
|
|
24
|
-
graphQLQuestions_1.
|
|
25
|
-
primitiveQuestions_1.
|
|
11
|
+
exports.AnyTableColumnQuestionSchema = zod_1.z.discriminatedUnion('type', [
|
|
12
|
+
primitiveQuestions_1.BooleanQuestionSchema,
|
|
13
|
+
optionBasedQuestions_1.CheckboxesQuestionSchema,
|
|
14
|
+
primitiveQuestions_1.CurrencyQuestionSchema,
|
|
15
|
+
dateQuestions_1.DatePickerQuestionSchema,
|
|
16
|
+
dateQuestions_1.DateRangeQuestionSchema,
|
|
17
|
+
primitiveQuestions_1.EmailQuestionSchema,
|
|
18
|
+
graphQLQuestions_1.FilteredSearchQuestionSchema,
|
|
19
|
+
primitiveQuestions_1.NumberQuestionSchema,
|
|
20
|
+
optionBasedQuestions_1.RadioButtonsQuestionSchema,
|
|
21
|
+
optionBasedQuestions_1.SelectBoxQuestionSchema,
|
|
22
|
+
primitiveQuestions_1.TextAreaQuestionSchema,
|
|
23
|
+
primitiveQuestions_1.TextQuestionSchema,
|
|
24
|
+
graphQLQuestions_1.TypeaheadSearchQuestionSchema,
|
|
25
|
+
primitiveQuestions_1.URLQuestionSchema
|
|
26
26
|
]);
|
|
27
27
|
// Table question and answer
|
|
28
|
-
exports.
|
|
28
|
+
exports.TableQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
29
29
|
type: zod_1.z.literal('table'), // The type of question
|
|
30
|
-
columns: zod_1.z.array(exports.
|
|
30
|
+
columns: zod_1.z.array(exports.AnyTableColumnQuestionSchema), // The columns of the table (note: tables cannot be nested)
|
|
31
31
|
attributes: zod_1.z.object({
|
|
32
32
|
canAddRows: zod_1.z.boolean().optional(), // Whether to allow adding rows (default is true)
|
|
33
33
|
canRemoveRows: zod_1.z.boolean().optional(), // Whether to allow removing rows (default is true)
|