@dmptool/types 1.1.1 → 1.1.2
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 +11 -5
- package/dist/answers/answer.d.ts +3 -3
- package/dist/answers/graphQLAnswers.d.ts +2 -2
- package/dist/answers/graphQLAnswers.js +2 -2
- package/dist/answers/index.d.ts +92 -55
- package/dist/answers/index.js +2 -2
- package/dist/answers/optionBasedAnswers.d.ts +27 -2
- package/dist/answers/optionBasedAnswers.js +5 -1
- package/dist/answers/tableAnswers.d.ts +268 -104
- package/dist/answers/tableAnswers.js +2 -1
- package/dist/questions/__tests__/graphQLQuestions.spec.js +7 -7
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +48 -1
- package/dist/questions/dateQuestions.d.ts +47 -16
- package/dist/questions/dateQuestions.js +25 -1
- package/dist/questions/graphQLQuestions.d.ts +59 -28
- package/dist/questions/graphQLQuestions.js +40 -3
- package/dist/questions/index.d.ts +1363 -646
- package/dist/questions/index.js +4 -2
- package/dist/questions/numberQuestions.d.ts +71 -25
- package/dist/questions/numberQuestions.js +36 -1
- package/dist/questions/optionBasedQuestions.d.ts +197 -44
- package/dist/questions/optionBasedQuestions.js +84 -6
- package/dist/questions/question.d.ts +51 -4
- package/dist/questions/question.js +14 -2
- package/dist/questions/tableQuestions.d.ts +1841 -932
- package/dist/questions/tableQuestions.js +13 -1
- package/dist/questions/textQuestions.d.ts +100 -40
- package/dist/questions/textQuestions.js +45 -7
- package/dist/schemas/affiliationSearchAnswer.schema.json +37 -0
- package/dist/schemas/affiliationSearchQuestion.schema.json +133 -0
- package/dist/schemas/anyAnswer.schema.json +41 -23
- package/dist/schemas/anyQuestion.schema.json +533 -149
- package/dist/schemas/anyTableColumnAnswer.schema.json +35 -14
- package/dist/schemas/anyTableColumnQuestion.schema.json +397 -119
- package/dist/schemas/booleanQuestion.schema.json +13 -2
- package/dist/schemas/checkboxesQuestion.schema.json +12 -0
- package/dist/schemas/currencyQuestion.schema.json +12 -0
- package/dist/schemas/dateQuestion.schema.json +12 -0
- package/dist/schemas/dateRangeQuestion.schema.json +12 -0
- package/dist/schemas/emailQuestion.schema.json +12 -0
- package/dist/schemas/filteredSearchQuestion.schema.json +10 -0
- package/dist/schemas/multiselectBoxAnswer.schema.json +40 -0
- package/dist/schemas/multiselectBoxQuestion.schema.json +90 -0
- package/dist/schemas/numberQuestion.schema.json +12 -0
- package/dist/schemas/numberRangeQuestion.schema.json +12 -0
- package/dist/schemas/radioButtonsQuestion.schema.json +12 -0
- package/dist/schemas/selectBoxAnswer.schema.json +1 -4
- package/dist/schemas/selectBoxQuestion.schema.json +18 -1
- package/dist/schemas/tableAnswer.schema.json +35 -14
- package/dist/schemas/tableQuestion.schema.json +419 -120
- package/dist/schemas/textAreaQuestion.schema.json +15 -4
- package/dist/schemas/textQuestion.schema.json +12 -0
- package/dist/schemas/urlQuestion.schema.json +12 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SelectBoxQuestionSchema = exports.RadioButtonsQuestionSchema = exports.CheckboxesQuestionSchema = exports.BooleanQuestionSchema = void 0;
|
|
3
|
+
exports.MultiselectBoxQuestionSchema = 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
|
|
@@ -9,33 +9,111 @@ const OptionSchema = zod_1.z.object({
|
|
|
9
9
|
value: zod_1.z.string(), // The value of the option
|
|
10
10
|
});
|
|
11
11
|
const BaseAttributes = question_1.QuestionSchema.shape.attributes;
|
|
12
|
+
const BaseMeta = question_1.QuestionSchema.shape.meta;
|
|
12
13
|
const CheckedOptionSchema = OptionSchema.merge(zod_1.z.object({
|
|
13
14
|
checked: zod_1.z.boolean().optional(),
|
|
14
15
|
}));
|
|
15
16
|
const SelectedOptionSchema = OptionSchema.merge(zod_1.z.object({
|
|
16
17
|
selected: zod_1.z.boolean().optional(),
|
|
17
18
|
}));
|
|
19
|
+
// Yes/No (boolean) question
|
|
20
|
+
const defaultBooleanJSON = {
|
|
21
|
+
attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { checked: false }),
|
|
22
|
+
meta: Object.assign({}, question_1.defaultMeta)
|
|
23
|
+
};
|
|
18
24
|
exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
19
25
|
type: zod_1.z.literal('boolean'),
|
|
20
26
|
attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
21
27
|
checked: zod_1.z.boolean().optional(),
|
|
22
|
-
})),
|
|
28
|
+
})).optional(),
|
|
29
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
30
|
+
title: zod_1.z.literal('Yes/No Field').optional(),
|
|
31
|
+
usageDescription: zod_1.z.literal('For questions that require a simple Yes/No response.').optional(),
|
|
32
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultBooleanJSON, null, 2)).optional(),
|
|
33
|
+
})).optional()
|
|
23
34
|
}));
|
|
24
35
|
// Check boxes question and answer
|
|
36
|
+
const defaultCheckboxesJSON = {
|
|
37
|
+
type: 'checkBoxes',
|
|
38
|
+
attributes: Object.assign({}, question_1.defaultAttributes),
|
|
39
|
+
options: [
|
|
40
|
+
{
|
|
41
|
+
label: 'Option 1',
|
|
42
|
+
value: '1',
|
|
43
|
+
checked: false
|
|
44
|
+
}
|
|
45
|
+
],
|
|
46
|
+
meta: Object.assign({}, question_1.defaultMeta)
|
|
47
|
+
};
|
|
25
48
|
exports.CheckboxesQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
26
49
|
type: zod_1.z.literal('checkBoxes'), // The type of question
|
|
27
|
-
options: zod_1.z.array(CheckedOptionSchema)
|
|
50
|
+
options: zod_1.z.array(CheckedOptionSchema),
|
|
51
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
52
|
+
title: zod_1.z.literal('Check Boxes').optional(),
|
|
53
|
+
usageDescription: zod_1.z.literal('For multiple choice questions where users can select multiple options.').optional(),
|
|
54
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultCheckboxesJSON, null, 2)).optional(),
|
|
55
|
+
})).optional()
|
|
28
56
|
}));
|
|
29
57
|
// Radio buttons question and answer
|
|
58
|
+
const defaultRadioButtonsJSON = {
|
|
59
|
+
type: 'radioButtons',
|
|
60
|
+
attributes: Object.assign({}, question_1.defaultAttributes),
|
|
61
|
+
options: [
|
|
62
|
+
{
|
|
63
|
+
label: 'Option 1',
|
|
64
|
+
value: 'option1',
|
|
65
|
+
selected: false
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
meta: Object.assign({}, question_1.defaultMeta)
|
|
69
|
+
};
|
|
30
70
|
exports.RadioButtonsQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
31
71
|
type: zod_1.z.literal('radioButtons'), // The type of question
|
|
32
|
-
options: zod_1.z.array(SelectedOptionSchema)
|
|
72
|
+
options: zod_1.z.array(SelectedOptionSchema),
|
|
73
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
74
|
+
title: zod_1.z.literal('Radio Buttons').optional(),
|
|
75
|
+
usageDescription: zod_1.z.literal('For multiple choice questions where users select just one option.').optional(),
|
|
76
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultRadioButtonsJSON, null, 2)).optional(),
|
|
77
|
+
})).optional()
|
|
33
78
|
}));
|
|
34
79
|
// Select box question and answer
|
|
80
|
+
const selectBoxAttributes = BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
81
|
+
multiple: zod_1.z.boolean()
|
|
82
|
+
}));
|
|
83
|
+
const defaultSelectBoxJSON = {
|
|
84
|
+
type: 'selectBox',
|
|
85
|
+
attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { multiple: false }),
|
|
86
|
+
options: [
|
|
87
|
+
{
|
|
88
|
+
label: 'Option 1',
|
|
89
|
+
value: 'option1',
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
meta: Object.assign({}, question_1.defaultMeta)
|
|
93
|
+
};
|
|
35
94
|
exports.SelectBoxQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
36
95
|
type: zod_1.z.literal('selectBox'), // The type of question
|
|
37
96
|
options: zod_1.z.array(SelectedOptionSchema),
|
|
38
|
-
attributes:
|
|
39
|
-
multiple: zod_1.z.
|
|
97
|
+
attributes: selectBoxAttributes.merge(zod_1.z.object({
|
|
98
|
+
multiple: zod_1.z.literal(false) // Whether to allow multiple selections (default is false)
|
|
99
|
+
})),
|
|
100
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
101
|
+
title: zod_1.z.literal('Select Box').optional(),
|
|
102
|
+
usageDescription: zod_1.z.literal('For questions where users select one option from a list.').optional(),
|
|
103
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultSelectBoxJSON, null, 2)).optional(),
|
|
40
104
|
})).optional()
|
|
41
105
|
}));
|
|
106
|
+
// Multi-select box question and answer
|
|
107
|
+
const defaultMultiselectBoxJSON = defaultSelectBoxJSON;
|
|
108
|
+
defaultMultiselectBoxJSON.attributes.multiple = true;
|
|
109
|
+
exports.MultiselectBoxQuestionSchema = exports.SelectBoxQuestionSchema.merge(zod_1.z.object({
|
|
110
|
+
type: zod_1.z.literal('multiselectBox'),
|
|
111
|
+
attributes: selectBoxAttributes.merge(zod_1.z.object({
|
|
112
|
+
multiple: zod_1.z.literal(true) // Whether to allow multiple selections (default is false)
|
|
113
|
+
})),
|
|
114
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
115
|
+
title: zod_1.z.literal('Multi-select Box').optional(),
|
|
116
|
+
usageDescription: zod_1.z.literal('For questions where multiple answers are valid. Allows users to select several options from a predefined list, providing flexibility in responses.').optional(),
|
|
117
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultMultiselectBoxJSON, null, 2)).optional(),
|
|
118
|
+
})).optional(),
|
|
119
|
+
}));
|
|
@@ -1,8 +1,39 @@
|
|
|
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", "date", "dateRange", "email", "filteredSearch", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "
|
|
3
|
+
export declare const QuestionTypesEnum: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
|
|
4
|
+
export declare const defaultMeta: z.infer<typeof DefaultMetaSchema>;
|
|
5
|
+
export declare const defaultAttributes: z.infer<typeof DefaultAttributesSchema>;
|
|
6
|
+
declare const DefaultMetaSchema: z.ZodObject<{
|
|
7
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
8
|
+
title: z.ZodOptional<z.ZodString>;
|
|
9
|
+
usageDescription: z.ZodOptional<z.ZodString>;
|
|
10
|
+
defaultJSON: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
schemaVersion: "1.0";
|
|
13
|
+
title?: string | undefined;
|
|
14
|
+
usageDescription?: string | undefined;
|
|
15
|
+
defaultJSON?: string | undefined;
|
|
16
|
+
}, {
|
|
17
|
+
schemaVersion: "1.0";
|
|
18
|
+
title?: string | undefined;
|
|
19
|
+
usageDescription?: string | undefined;
|
|
20
|
+
defaultJSON?: string | undefined;
|
|
21
|
+
}>;
|
|
22
|
+
declare const DefaultAttributesSchema: z.ZodObject<{
|
|
23
|
+
label: z.ZodOptional<z.ZodString>;
|
|
24
|
+
help: z.ZodOptional<z.ZodString>;
|
|
25
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
label?: string | undefined;
|
|
28
|
+
help?: string | undefined;
|
|
29
|
+
labelTranslationKey?: string | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
label?: string | undefined;
|
|
32
|
+
help?: string | undefined;
|
|
33
|
+
labelTranslationKey?: string | undefined;
|
|
34
|
+
}>;
|
|
4
35
|
export declare const QuestionSchema: z.ZodObject<{
|
|
5
|
-
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "
|
|
36
|
+
type: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
|
|
6
37
|
attributes: z.ZodOptional<z.ZodObject<{
|
|
7
38
|
label: z.ZodOptional<z.ZodString>;
|
|
8
39
|
help: z.ZodOptional<z.ZodString>;
|
|
@@ -18,13 +49,22 @@ export declare const QuestionSchema: z.ZodObject<{
|
|
|
18
49
|
}>>;
|
|
19
50
|
meta: z.ZodOptional<z.ZodObject<{
|
|
20
51
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
52
|
+
title: z.ZodOptional<z.ZodString>;
|
|
53
|
+
usageDescription: z.ZodOptional<z.ZodString>;
|
|
54
|
+
defaultJSON: z.ZodOptional<z.ZodString>;
|
|
21
55
|
}, "strip", z.ZodTypeAny, {
|
|
22
56
|
schemaVersion: "1.0";
|
|
57
|
+
title?: string | undefined;
|
|
58
|
+
usageDescription?: string | undefined;
|
|
59
|
+
defaultJSON?: string | undefined;
|
|
23
60
|
}, {
|
|
24
61
|
schemaVersion: "1.0";
|
|
62
|
+
title?: string | undefined;
|
|
63
|
+
usageDescription?: string | undefined;
|
|
64
|
+
defaultJSON?: string | undefined;
|
|
25
65
|
}>>;
|
|
26
66
|
}, "strip", z.ZodTypeAny, {
|
|
27
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "
|
|
67
|
+
type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
|
|
28
68
|
attributes?: {
|
|
29
69
|
label?: string | undefined;
|
|
30
70
|
help?: string | undefined;
|
|
@@ -32,9 +72,12 @@ export declare const QuestionSchema: z.ZodObject<{
|
|
|
32
72
|
} | undefined;
|
|
33
73
|
meta?: {
|
|
34
74
|
schemaVersion: "1.0";
|
|
75
|
+
title?: string | undefined;
|
|
76
|
+
usageDescription?: string | undefined;
|
|
77
|
+
defaultJSON?: string | undefined;
|
|
35
78
|
} | undefined;
|
|
36
79
|
}, {
|
|
37
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "
|
|
80
|
+
type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
|
|
38
81
|
attributes?: {
|
|
39
82
|
label?: string | undefined;
|
|
40
83
|
help?: string | undefined;
|
|
@@ -42,6 +85,10 @@ export declare const QuestionSchema: z.ZodObject<{
|
|
|
42
85
|
} | undefined;
|
|
43
86
|
meta?: {
|
|
44
87
|
schemaVersion: "1.0";
|
|
88
|
+
title?: string | undefined;
|
|
89
|
+
usageDescription?: string | undefined;
|
|
90
|
+
defaultJSON?: string | undefined;
|
|
45
91
|
} | undefined;
|
|
46
92
|
}>;
|
|
47
93
|
export type QuestionType = z.infer<typeof QuestionSchema>;
|
|
94
|
+
export {};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QuestionSchema = exports.QuestionTypesEnum = exports.CURRENT_SCHEMA_VERSION = void 0;
|
|
3
|
+
exports.QuestionSchema = exports.defaultAttributes = exports.defaultMeta = 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
|
|
7
7
|
exports.QuestionTypesEnum = zod_1.z.enum([
|
|
8
|
+
'affiliationSearch',
|
|
8
9
|
'boolean',
|
|
9
10
|
'checkBoxes',
|
|
10
11
|
'currency',
|
|
@@ -12,6 +13,7 @@ exports.QuestionTypesEnum = zod_1.z.enum([
|
|
|
12
13
|
'dateRange',
|
|
13
14
|
'email',
|
|
14
15
|
'filteredSearch',
|
|
16
|
+
'multiselectBox',
|
|
15
17
|
'number',
|
|
16
18
|
'numberRange',
|
|
17
19
|
'radioButtons',
|
|
@@ -19,11 +21,21 @@ exports.QuestionTypesEnum = zod_1.z.enum([
|
|
|
19
21
|
'table',
|
|
20
22
|
'text',
|
|
21
23
|
'textArea',
|
|
22
|
-
'typeaheadSearch',
|
|
23
24
|
'url'
|
|
24
25
|
]);
|
|
26
|
+
exports.defaultMeta = {
|
|
27
|
+
schemaVersion: exports.CURRENT_SCHEMA_VERSION,
|
|
28
|
+
};
|
|
29
|
+
exports.defaultAttributes = {
|
|
30
|
+
label: undefined,
|
|
31
|
+
help: undefined,
|
|
32
|
+
labelTranslationKey: undefined,
|
|
33
|
+
};
|
|
25
34
|
const DefaultMetaSchema = zod_1.z.object({
|
|
26
35
|
schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
|
|
36
|
+
title: zod_1.z.string().optional(), // The title of the question type
|
|
37
|
+
usageDescription: zod_1.z.string().optional(), // A description of when to use the question type
|
|
38
|
+
defaultJSON: zod_1.z.string().optional(), // A default version of the question
|
|
27
39
|
});
|
|
28
40
|
const DefaultAttributesSchema = zod_1.z.object({
|
|
29
41
|
label: zod_1.z.string().optional(), // UI label for the field
|