@dmptool/types 1.0.0 → 1.0.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/README.md +127 -29
- package/dist/answers/__tests__/answers.spec.d.ts +1 -0
- package/dist/answers/__tests__/answers.spec.js +127 -0
- package/dist/answers/answer.d.ts +25 -0
- package/dist/answers/answer.js +13 -0
- package/dist/answers/dateAnswers.d.ts +66 -0
- package/dist/answers/dateAnswers.js +16 -0
- package/dist/answers/graphQLAnswers.d.ts +51 -0
- package/dist/answers/graphQLAnswers.js +14 -0
- package/dist/answers/index.d.ts +880 -0
- package/dist/answers/index.js +48 -0
- package/dist/answers/optionBasedAnswers.d.ts +76 -0
- package/dist/answers/optionBasedAnswers.js +18 -0
- package/dist/answers/primitiveAnswers.d.ts +176 -0
- package/dist/answers/primitiveAnswers.js +34 -0
- package/dist/answers/tableAnswers.d.ts +876 -0
- package/dist/answers/tableAnswers.js +31 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +19 -0
- package/dist/questions/__tests__/dateQuestions.spec.d.ts +1 -0
- package/dist/questions/__tests__/dateQuestions.spec.js +149 -0
- package/dist/questions/__tests__/graphQLQuestions.spec.d.ts +1 -0
- package/dist/questions/__tests__/graphQLQuestions.spec.js +87 -0
- package/dist/questions/__tests__/optionBasedQuestions.spec.d.ts +1 -0
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +152 -0
- package/dist/questions/__tests__/primitiveQuestions.spec.d.ts +1 -0
- package/dist/questions/__tests__/primitiveQuestions.spec.js +189 -0
- package/dist/{dateQuestions.js → questions/dateQuestions.js} +3 -3
- package/dist/{graphQLQuestions.js → questions/graphQLQuestions.js} +3 -3
- package/dist/{tableQuestions.d.ts → questions/index.d.ts} +97 -1650
- package/dist/questions/index.js +48 -0
- package/dist/{optionBasedQuestions.js → questions/optionBasedQuestions.js} +4 -4
- package/dist/{primitiveQuestions.d.ts → questions/primitiveQuestions.d.ts} +0 -27
- package/dist/{primitiveQuestions.js → questions/primitiveQuestions.js} +8 -35
- package/dist/questions/question.d.ts +29 -0
- package/dist/questions/question.js +32 -0
- package/dist/questions/tableQuestions.d.ts +2638 -0
- package/dist/{tableQuestions.js → questions/tableQuestions.js} +5 -22
- package/dist/schemas/anyAnswer.schema.json +195 -59
- package/dist/schemas/anyTableColumnAnswer.schema.json +336 -0
- package/dist/schemas/anyTableColumnQuestion.schema.json +637 -0
- package/dist/schemas/booleanAnswer.schema.json +15 -1
- package/dist/schemas/checkboxesAnswer.schema.json +15 -1
- package/dist/schemas/currencyAnswer.schema.json +15 -1
- package/dist/schemas/datePickerAnswer.schema.json +15 -1
- package/dist/schemas/dateRangeAnswer.schema.json +15 -1
- package/dist/schemas/emailAnswer.schema.json +15 -1
- package/dist/schemas/filteredSearchAnswer.schema.json +15 -1
- package/dist/schemas/numberAnswer.schema.json +15 -1
- package/dist/schemas/radioButtonsAnswer.schema.json +15 -1
- package/dist/schemas/selectBoxAnswer.schema.json +19 -2
- package/dist/schemas/tableAnswer.schema.json +91 -18
- package/dist/schemas/textAnswer.schema.json +15 -1
- package/dist/schemas/textAreaAnswer.schema.json +15 -1
- package/dist/schemas/typeaheadSearchAnswer.schema.json +15 -1
- package/dist/schemas/urlAnswer.schema.json +15 -1
- package/package.json +8 -1
- package/dist/answers.d.ts +0 -558
- package/dist/answers.js +0 -87
- /package/dist/{dateQuestions.d.ts → questions/dateQuestions.d.ts} +0 -0
- /package/dist/{graphQLQuestions.d.ts → questions/graphQLQuestions.d.ts} +0 -0
- /package/dist/{optionBasedQuestions.d.ts → questions/optionBasedQuestions.d.ts} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.AnyQuestion = void 0;
|
|
18
|
+
const zod_1 = require("zod");
|
|
19
|
+
const primitiveQuestions_1 = require("./primitiveQuestions");
|
|
20
|
+
const dateQuestions_1 = require("./dateQuestions");
|
|
21
|
+
const optionBasedQuestions_1 = require("./optionBasedQuestions");
|
|
22
|
+
const graphQLQuestions_1 = require("./graphQLQuestions");
|
|
23
|
+
const tableQuestions_1 = require("./tableQuestions");
|
|
24
|
+
// Export all the questions
|
|
25
|
+
__exportStar(require("./question"), exports);
|
|
26
|
+
__exportStar(require("./dateQuestions"), exports);
|
|
27
|
+
__exportStar(require("./graphQLQuestions"), exports);
|
|
28
|
+
__exportStar(require("./optionBasedQuestions"), exports);
|
|
29
|
+
__exportStar(require("./primitiveQuestions"), exports);
|
|
30
|
+
__exportStar(require("./tableQuestions"), exports);
|
|
31
|
+
// All of the possible questions
|
|
32
|
+
exports.AnyQuestion = zod_1.z.discriminatedUnion('type', [
|
|
33
|
+
primitiveQuestions_1.BooleanQuestion,
|
|
34
|
+
optionBasedQuestions_1.CheckboxesQuestion,
|
|
35
|
+
primitiveQuestions_1.CurrencyQuestion,
|
|
36
|
+
dateQuestions_1.DatePickerQuestion,
|
|
37
|
+
dateQuestions_1.DateRangeQuestion,
|
|
38
|
+
primitiveQuestions_1.EmailQuestion,
|
|
39
|
+
graphQLQuestions_1.FilteredSearchQuestion,
|
|
40
|
+
primitiveQuestions_1.NumberQuestion,
|
|
41
|
+
optionBasedQuestions_1.RadioButtonsQuestion,
|
|
42
|
+
optionBasedQuestions_1.SelectBoxQuestion,
|
|
43
|
+
tableQuestions_1.TableQuestion,
|
|
44
|
+
primitiveQuestions_1.TextAreaQuestion,
|
|
45
|
+
primitiveQuestions_1.TextQuestion,
|
|
46
|
+
graphQLQuestions_1.TypeaheadSearchQuestion,
|
|
47
|
+
primitiveQuestions_1.URLQuestion
|
|
48
|
+
]);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SelectBoxQuestion = exports.RadioButtonsQuestion = exports.CheckboxesQuestion = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
const
|
|
5
|
+
const question_1 = require("./question");
|
|
6
6
|
// A select box, radio buttons, or checkboxes option
|
|
7
7
|
const Option = zod_1.z.object({
|
|
8
8
|
type: zod_1.z.literal('option'), // The type of option
|
|
@@ -25,17 +25,17 @@ const SelectedOption = zod_1.z.object({
|
|
|
25
25
|
}),
|
|
26
26
|
});
|
|
27
27
|
// Check boxes question and answer
|
|
28
|
-
exports.CheckboxesQuestion =
|
|
28
|
+
exports.CheckboxesQuestion = question_1.Question.merge(zod_1.z.object({
|
|
29
29
|
type: zod_1.z.literal('checkBoxes'), // The type of question
|
|
30
30
|
options: zod_1.z.array(CheckedOption)
|
|
31
31
|
}));
|
|
32
32
|
// Radio buttons question and answer
|
|
33
|
-
exports.RadioButtonsQuestion =
|
|
33
|
+
exports.RadioButtonsQuestion = question_1.Question.merge(zod_1.z.object({
|
|
34
34
|
type: zod_1.z.literal('radioButtons'), // The type of question
|
|
35
35
|
options: zod_1.z.array(SelectedOption)
|
|
36
36
|
}));
|
|
37
37
|
// Select box question and answer
|
|
38
|
-
exports.SelectBoxQuestion =
|
|
38
|
+
exports.SelectBoxQuestion = question_1.Question.merge(zod_1.z.object({
|
|
39
39
|
type: zod_1.z.literal('selectBox'), // The type of question
|
|
40
40
|
options: zod_1.z.array(SelectedOption),
|
|
41
41
|
attributes: zod_1.z.object({
|
|
@@ -1,31 +1,4 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const CURRENT_SCHEMA_VERSION = "1.0";
|
|
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 Question: z.ZodObject<{
|
|
5
|
-
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "option", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
6
|
-
meta: z.ZodObject<{
|
|
7
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
8
|
-
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
9
|
-
}, "strip", z.ZodTypeAny, {
|
|
10
|
-
schemaVersion: "1.0";
|
|
11
|
-
labelTranslationKey?: string | undefined;
|
|
12
|
-
}, {
|
|
13
|
-
schemaVersion: "1.0";
|
|
14
|
-
labelTranslationKey?: string | undefined;
|
|
15
|
-
}>;
|
|
16
|
-
}, "strip", z.ZodTypeAny, {
|
|
17
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "option" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
18
|
-
meta: {
|
|
19
|
-
schemaVersion: "1.0";
|
|
20
|
-
labelTranslationKey?: string | undefined;
|
|
21
|
-
};
|
|
22
|
-
}, {
|
|
23
|
-
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "option" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
24
|
-
meta: {
|
|
25
|
-
schemaVersion: "1.0";
|
|
26
|
-
labelTranslationKey?: string | undefined;
|
|
27
|
-
};
|
|
28
|
-
}>;
|
|
29
2
|
export declare const BooleanQuestion: z.ZodObject<{
|
|
30
3
|
meta: z.ZodObject<{
|
|
31
4
|
schemaVersion: z.ZodLiteral<"1.0">;
|
|
@@ -1,44 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.URLQuestion = exports.TextQuestion = exports.TextAreaQuestion = exports.EmailQuestion = exports.CurrencyQuestion = exports.NumberQuestion = exports.BooleanQuestion =
|
|
3
|
+
exports.URLQuestion = exports.TextQuestion = exports.TextAreaQuestion = exports.EmailQuestion = exports.CurrencyQuestion = exports.NumberQuestion = exports.BooleanQuestion = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
|
-
|
|
6
|
-
// The type of question
|
|
7
|
-
exports.QuestionTypesEnum = zod_1.z.enum([
|
|
8
|
-
'boolean',
|
|
9
|
-
'checkBoxes',
|
|
10
|
-
'currency',
|
|
11
|
-
'datePicker',
|
|
12
|
-
'dateRange',
|
|
13
|
-
'email',
|
|
14
|
-
'filteredSearch',
|
|
15
|
-
'number',
|
|
16
|
-
'option',
|
|
17
|
-
'radioButtons',
|
|
18
|
-
'selectBox',
|
|
19
|
-
'table',
|
|
20
|
-
'text',
|
|
21
|
-
'textArea',
|
|
22
|
-
'typeaheadSearch',
|
|
23
|
-
'url'
|
|
24
|
-
]);
|
|
25
|
-
// Base abstract type for all questions
|
|
26
|
-
exports.Question = zod_1.z.object({
|
|
27
|
-
type: exports.QuestionTypesEnum, // The type of question
|
|
28
|
-
meta: zod_1.z.object({
|
|
29
|
-
schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
|
|
30
|
-
labelTranslationKey: zod_1.z.string().optional() // The translation key for the label (DMP Tool only)
|
|
31
|
-
}),
|
|
32
|
-
});
|
|
5
|
+
const question_1 = require("./question");
|
|
33
6
|
// A Yes/No True/False question and answer
|
|
34
|
-
exports.BooleanQuestion =
|
|
7
|
+
exports.BooleanQuestion = question_1.Question.merge(zod_1.z.object({
|
|
35
8
|
type: zod_1.z.literal('boolean'), // The type of question
|
|
36
9
|
attributes: zod_1.z.object({
|
|
37
10
|
checked: zod_1.z.boolean().optional() // If it is checked by default when rendered (default is false)
|
|
38
11
|
})
|
|
39
12
|
}));
|
|
40
13
|
// A number question and answer
|
|
41
|
-
exports.NumberQuestion =
|
|
14
|
+
exports.NumberQuestion = question_1.Question.merge(zod_1.z.object({
|
|
42
15
|
type: zod_1.z.literal('number'), // The type of question
|
|
43
16
|
attributes: zod_1.z.object({
|
|
44
17
|
max: zod_1.z.number().optional(), // The maximum value (no default)
|
|
@@ -54,7 +27,7 @@ exports.CurrencyQuestion = exports.NumberQuestion.merge(zod_1.z.object({
|
|
|
54
27
|
})
|
|
55
28
|
}));
|
|
56
29
|
// Email question and answer
|
|
57
|
-
exports.EmailQuestion =
|
|
30
|
+
exports.EmailQuestion = question_1.Question.merge(zod_1.z.object({
|
|
58
31
|
type: zod_1.z.literal('email'), // The type of question
|
|
59
32
|
attributes: zod_1.z.object({
|
|
60
33
|
maxLength: zod_1.z.number().optional(), // The maximum length of the email (no default)
|
|
@@ -64,7 +37,7 @@ exports.EmailQuestion = exports.Question.merge(zod_1.z.object({
|
|
|
64
37
|
})
|
|
65
38
|
}));
|
|
66
39
|
// Text area question and answer
|
|
67
|
-
exports.TextAreaQuestion =
|
|
40
|
+
exports.TextAreaQuestion = question_1.Question.merge(zod_1.z.object({
|
|
68
41
|
type: zod_1.z.literal('textArea'), // The type of question
|
|
69
42
|
attributes: zod_1.z.object({
|
|
70
43
|
cols: zod_1.z.number().optional(), // The number of columns (default is 20)
|
|
@@ -77,7 +50,7 @@ exports.TextAreaQuestion = exports.Question.merge(zod_1.z.object({
|
|
|
77
50
|
})
|
|
78
51
|
}));
|
|
79
52
|
// Text question and answer
|
|
80
|
-
exports.TextQuestion =
|
|
53
|
+
exports.TextQuestion = question_1.Question.merge(zod_1.z.object({
|
|
81
54
|
type: zod_1.z.literal('text'), // The type of question
|
|
82
55
|
attributes: zod_1.z.object({
|
|
83
56
|
maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
|
|
@@ -86,7 +59,7 @@ exports.TextQuestion = exports.Question.merge(zod_1.z.object({
|
|
|
86
59
|
}),
|
|
87
60
|
}));
|
|
88
61
|
// URL question and answer
|
|
89
|
-
exports.URLQuestion =
|
|
62
|
+
exports.URLQuestion = question_1.Question.merge(zod_1.z.object({
|
|
90
63
|
type: zod_1.z.literal('url'), // The type of question
|
|
91
64
|
attributes: zod_1.z.object({
|
|
92
65
|
maxLength: zod_1.z.number().optional(), // The maximum length of the URL (no default)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const CURRENT_SCHEMA_VERSION = "1.0";
|
|
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 Question: z.ZodObject<{
|
|
5
|
+
type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "option", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
|
|
6
|
+
meta: z.ZodObject<{
|
|
7
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
8
|
+
labelTranslationKey: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
schemaVersion: "1.0";
|
|
11
|
+
labelTranslationKey?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
schemaVersion: "1.0";
|
|
14
|
+
labelTranslationKey?: string | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "option" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
18
|
+
meta: {
|
|
19
|
+
schemaVersion: "1.0";
|
|
20
|
+
labelTranslationKey?: string | undefined;
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "option" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
|
|
24
|
+
meta: {
|
|
25
|
+
schemaVersion: "1.0";
|
|
26
|
+
labelTranslationKey?: string | undefined;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
export type QuestionType = z.infer<typeof Question>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Question = exports.QuestionTypesEnum = exports.CURRENT_SCHEMA_VERSION = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.CURRENT_SCHEMA_VERSION = '1.0'; // The current schema version
|
|
6
|
+
// The type of question
|
|
7
|
+
exports.QuestionTypesEnum = zod_1.z.enum([
|
|
8
|
+
'boolean',
|
|
9
|
+
'checkBoxes',
|
|
10
|
+
'currency',
|
|
11
|
+
'datePicker',
|
|
12
|
+
'dateRange',
|
|
13
|
+
'email',
|
|
14
|
+
'filteredSearch',
|
|
15
|
+
'number',
|
|
16
|
+
'option',
|
|
17
|
+
'radioButtons',
|
|
18
|
+
'selectBox',
|
|
19
|
+
'table',
|
|
20
|
+
'text',
|
|
21
|
+
'textArea',
|
|
22
|
+
'typeaheadSearch',
|
|
23
|
+
'url'
|
|
24
|
+
]);
|
|
25
|
+
// Base abstract type for all questions
|
|
26
|
+
exports.Question = zod_1.z.object({
|
|
27
|
+
type: exports.QuestionTypesEnum, // The type of question
|
|
28
|
+
meta: zod_1.z.object({
|
|
29
|
+
schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
|
|
30
|
+
labelTranslationKey: zod_1.z.string().optional() // The translation key for the label (DMP Tool only)
|
|
31
|
+
}),
|
|
32
|
+
});
|