@dmptool/types 1.0.0
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/LICENSE +21 -0
- package/README.md +41 -0
- package/dist/answers.d.ts +558 -0
- package/dist/answers.js +87 -0
- package/dist/dateQuestions.d.ts +244 -0
- package/dist/dateQuestions.js +30 -0
- package/dist/graphQLQuestions.d.ts +288 -0
- package/dist/graphQLQuestions.js +41 -0
- package/dist/optionBasedQuestions.d.ts +236 -0
- package/dist/optionBasedQuestions.js +44 -0
- package/dist/primitiveQuestions.d.ts +367 -0
- package/dist/primitiveQuestions.js +96 -0
- package/dist/schemas/anyAnswer.schema.json +267 -0
- package/dist/schemas/anyQuestion.schema.json +726 -0
- package/dist/schemas/booleanAnswer.schema.json +23 -0
- package/dist/schemas/booleanQuestion.schema.json +46 -0
- package/dist/schemas/checkboxesAnswer.schema.json +26 -0
- package/dist/schemas/checkboxesQuestion.schema.json +73 -0
- package/dist/schemas/currencyAnswer.schema.json +23 -0
- package/dist/schemas/currencyQuestion.schema.json +45 -0
- package/dist/schemas/datePickerAnswer.schema.json +23 -0
- package/dist/schemas/datePickerQuestion.schema.json +52 -0
- package/dist/schemas/dateRangeAnswer.schema.json +36 -0
- package/dist/schemas/dateRangeQuestion.schema.json +106 -0
- package/dist/schemas/emailAnswer.schema.json +23 -0
- package/dist/schemas/emailQuestion.schema.json +55 -0
- package/dist/schemas/filteredSearchAnswer.schema.json +26 -0
- package/dist/schemas/filteredSearchQuestion.schema.json +120 -0
- package/dist/schemas/numberAnswer.schema.json +23 -0
- package/dist/schemas/numberQuestion.schema.json +52 -0
- package/dist/schemas/radioButtonsAnswer.schema.json +23 -0
- package/dist/schemas/radioButtonsQuestion.schema.json +73 -0
- package/dist/schemas/selectBoxAnswer.schema.json +23 -0
- package/dist/schemas/selectBoxQuestion.schema.json +83 -0
- package/dist/schemas/tableAnswer.schema.json +284 -0
- package/dist/schemas/tableQuestion.schema.json +680 -0
- package/dist/schemas/textAnswer.schema.json +23 -0
- package/dist/schemas/textAreaAnswer.schema.json +23 -0
- package/dist/schemas/textAreaQuestion.schema.json +48 -0
- package/dist/schemas/textQuestion.schema.json +52 -0
- package/dist/schemas/typeaheadSearchAnswer.schema.json +23 -0
- package/dist/schemas/typeaheadSearchQuestion.schema.json +110 -0
- package/dist/schemas/urlAnswer.schema.json +23 -0
- package/dist/schemas/urlQuestion.schema.json +52 -0
- package/dist/tableQuestions.d.ts +4195 -0
- package/dist/tableQuestions.js +55 -0
- package/package.json +41 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AnyQuestion = exports.TableQuestion = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const primitiveQuestions_1 = require("./primitiveQuestions");
|
|
6
|
+
const dateQuestions_1 = require("./dateQuestions");
|
|
7
|
+
const optionBasedQuestions_1 = require("./optionBasedQuestions");
|
|
8
|
+
const graphQLQuestions_1 = require("./graphQLQuestions");
|
|
9
|
+
// Union types for all questions and answers (tables cannot be nested so no TableQuestion here!)
|
|
10
|
+
const ColumnQuestions = zod_1.z.discriminatedUnion('type', [
|
|
11
|
+
primitiveQuestions_1.BooleanQuestion,
|
|
12
|
+
optionBasedQuestions_1.CheckboxesQuestion,
|
|
13
|
+
primitiveQuestions_1.CurrencyQuestion,
|
|
14
|
+
dateQuestions_1.DatePickerQuestion,
|
|
15
|
+
dateQuestions_1.DateRangeQuestion,
|
|
16
|
+
primitiveQuestions_1.EmailQuestion,
|
|
17
|
+
graphQLQuestions_1.FilteredSearchQuestion,
|
|
18
|
+
primitiveQuestions_1.NumberQuestion,
|
|
19
|
+
optionBasedQuestions_1.RadioButtonsQuestion,
|
|
20
|
+
optionBasedQuestions_1.SelectBoxQuestion,
|
|
21
|
+
primitiveQuestions_1.TextAreaQuestion,
|
|
22
|
+
primitiveQuestions_1.TextQuestion,
|
|
23
|
+
graphQLQuestions_1.TypeaheadSearchQuestion,
|
|
24
|
+
primitiveQuestions_1.URLQuestion
|
|
25
|
+
]);
|
|
26
|
+
// Table question and answer
|
|
27
|
+
exports.TableQuestion = primitiveQuestions_1.Question.merge(zod_1.z.object({
|
|
28
|
+
type: zod_1.z.literal('table'), // The type of question
|
|
29
|
+
columns: zod_1.z.array(ColumnQuestions), // The columns of the table (note: tables cannot be nested)
|
|
30
|
+
attributes: zod_1.z.object({
|
|
31
|
+
canAddRows: zod_1.z.boolean().optional(), // Whether to allow adding rows (default is true)
|
|
32
|
+
canRemoveRows: zod_1.z.boolean().optional(), // Whether to allow removing rows (default is true)
|
|
33
|
+
initialRows: zod_1.z.number().optional(), // The initial number of rows (default is 1)
|
|
34
|
+
maxRows: zod_1.z.number().optional(), // The maximum number of rows (no default)
|
|
35
|
+
minRows: zod_1.z.number().optional() // The minimum number of rows (no default)
|
|
36
|
+
})
|
|
37
|
+
}));
|
|
38
|
+
// All of the possible questions
|
|
39
|
+
exports.AnyQuestion = zod_1.z.discriminatedUnion('type', [
|
|
40
|
+
primitiveQuestions_1.BooleanQuestion,
|
|
41
|
+
optionBasedQuestions_1.CheckboxesQuestion,
|
|
42
|
+
primitiveQuestions_1.CurrencyQuestion,
|
|
43
|
+
dateQuestions_1.DatePickerQuestion,
|
|
44
|
+
dateQuestions_1.DateRangeQuestion,
|
|
45
|
+
primitiveQuestions_1.EmailQuestion,
|
|
46
|
+
graphQLQuestions_1.FilteredSearchQuestion,
|
|
47
|
+
primitiveQuestions_1.NumberQuestion,
|
|
48
|
+
optionBasedQuestions_1.RadioButtonsQuestion,
|
|
49
|
+
optionBasedQuestions_1.SelectBoxQuestion,
|
|
50
|
+
exports.TableQuestion,
|
|
51
|
+
primitiveQuestions_1.TextAreaQuestion,
|
|
52
|
+
primitiveQuestions_1.TextQuestion,
|
|
53
|
+
graphQLQuestions_1.TypeaheadSearchQuestion,
|
|
54
|
+
primitiveQuestions_1.URLQuestion
|
|
55
|
+
]);
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dmptool/types",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript types for DMPTool",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "npm run clean && npm run generate && tsc && npm run copy:schemas",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"copy:schemas": "node scripts/copySchemas.mjs",
|
|
18
|
+
"generate": "ts-node scripts/generateSchemas.ts",
|
|
19
|
+
"lint": "eslint . --ignore-pattern dist/ --ignore-pattern node_modules/",
|
|
20
|
+
"prepublishOnly": "npm run build",
|
|
21
|
+
"test": "jest --config jest.config.ts"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"fs": "^0.0.1-security",
|
|
25
|
+
"zod": "^3.24.4",
|
|
26
|
+
"zod-to-json-schema": "^3.24.5"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@eslint/js": "^9.26.0",
|
|
30
|
+
"@types/jest": "^29.5.14",
|
|
31
|
+
"@types/node": "^20.4.3",
|
|
32
|
+
"cpy": "^11.1.0",
|
|
33
|
+
"eslint": "^9.26.0",
|
|
34
|
+
"jest": "^29.7.0",
|
|
35
|
+
"ts-jest": "^29.3.3",
|
|
36
|
+
"ts-node": "^10.9.2",
|
|
37
|
+
"ts-node-dev": "^2.0.0",
|
|
38
|
+
"typescript": "^5.2.2",
|
|
39
|
+
"typescript-eslint": "^8.32.1"
|
|
40
|
+
}
|
|
41
|
+
}
|