@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.
Files changed (47) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +41 -0
  3. package/dist/answers.d.ts +558 -0
  4. package/dist/answers.js +87 -0
  5. package/dist/dateQuestions.d.ts +244 -0
  6. package/dist/dateQuestions.js +30 -0
  7. package/dist/graphQLQuestions.d.ts +288 -0
  8. package/dist/graphQLQuestions.js +41 -0
  9. package/dist/optionBasedQuestions.d.ts +236 -0
  10. package/dist/optionBasedQuestions.js +44 -0
  11. package/dist/primitiveQuestions.d.ts +367 -0
  12. package/dist/primitiveQuestions.js +96 -0
  13. package/dist/schemas/anyAnswer.schema.json +267 -0
  14. package/dist/schemas/anyQuestion.schema.json +726 -0
  15. package/dist/schemas/booleanAnswer.schema.json +23 -0
  16. package/dist/schemas/booleanQuestion.schema.json +46 -0
  17. package/dist/schemas/checkboxesAnswer.schema.json +26 -0
  18. package/dist/schemas/checkboxesQuestion.schema.json +73 -0
  19. package/dist/schemas/currencyAnswer.schema.json +23 -0
  20. package/dist/schemas/currencyQuestion.schema.json +45 -0
  21. package/dist/schemas/datePickerAnswer.schema.json +23 -0
  22. package/dist/schemas/datePickerQuestion.schema.json +52 -0
  23. package/dist/schemas/dateRangeAnswer.schema.json +36 -0
  24. package/dist/schemas/dateRangeQuestion.schema.json +106 -0
  25. package/dist/schemas/emailAnswer.schema.json +23 -0
  26. package/dist/schemas/emailQuestion.schema.json +55 -0
  27. package/dist/schemas/filteredSearchAnswer.schema.json +26 -0
  28. package/dist/schemas/filteredSearchQuestion.schema.json +120 -0
  29. package/dist/schemas/numberAnswer.schema.json +23 -0
  30. package/dist/schemas/numberQuestion.schema.json +52 -0
  31. package/dist/schemas/radioButtonsAnswer.schema.json +23 -0
  32. package/dist/schemas/radioButtonsQuestion.schema.json +73 -0
  33. package/dist/schemas/selectBoxAnswer.schema.json +23 -0
  34. package/dist/schemas/selectBoxQuestion.schema.json +83 -0
  35. package/dist/schemas/tableAnswer.schema.json +284 -0
  36. package/dist/schemas/tableQuestion.schema.json +680 -0
  37. package/dist/schemas/textAnswer.schema.json +23 -0
  38. package/dist/schemas/textAreaAnswer.schema.json +23 -0
  39. package/dist/schemas/textAreaQuestion.schema.json +48 -0
  40. package/dist/schemas/textQuestion.schema.json +52 -0
  41. package/dist/schemas/typeaheadSearchAnswer.schema.json +23 -0
  42. package/dist/schemas/typeaheadSearchQuestion.schema.json +110 -0
  43. package/dist/schemas/urlAnswer.schema.json +23 -0
  44. package/dist/schemas/urlQuestion.schema.json +52 -0
  45. package/dist/tableQuestions.d.ts +4195 -0
  46. package/dist/tableQuestions.js +55 -0
  47. package/package.json +41 -0
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.URLQuestion = exports.TextQuestion = exports.TextAreaQuestion = exports.EmailQuestion = exports.CurrencyQuestion = exports.NumberQuestion = exports.BooleanQuestion = 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
+ });
33
+ // A Yes/No True/False question and answer
34
+ exports.BooleanQuestion = exports.Question.merge(zod_1.z.object({
35
+ type: zod_1.z.literal('boolean'), // The type of question
36
+ attributes: zod_1.z.object({
37
+ checked: zod_1.z.boolean().optional() // If it is checked by default when rendered (default is false)
38
+ })
39
+ }));
40
+ // A number question and answer
41
+ exports.NumberQuestion = exports.Question.merge(zod_1.z.object({
42
+ type: zod_1.z.literal('number'), // The type of question
43
+ attributes: zod_1.z.object({
44
+ max: zod_1.z.number().optional(), // The maximum value (no default)
45
+ min: zod_1.z.number().optional(), // The minimum value (default is 0)
46
+ step: zod_1.z.number().optional() // The step value (use 0.01 or similar for float)
47
+ })
48
+ }));
49
+ // Currency question and answer
50
+ exports.CurrencyQuestion = exports.NumberQuestion.merge(zod_1.z.object({
51
+ type: zod_1.z.literal('currency'), // The type of question
52
+ meta: zod_1.z.object({
53
+ denomination: zod_1.z.string().optional() // The currency denomination (default is USD)
54
+ })
55
+ }));
56
+ // Email question and answer
57
+ exports.EmailQuestion = exports.Question.merge(zod_1.z.object({
58
+ type: zod_1.z.literal('email'), // The type of question
59
+ attributes: zod_1.z.object({
60
+ maxLength: zod_1.z.number().optional(), // The maximum length of the email (no default)
61
+ minLength: zod_1.z.number().optional(), // The minimum length of the email (no default)
62
+ multiple: zod_1.z.boolean().optional(), // Allow multiple emails (default is false; comma separated)
63
+ pattern: zod_1.z.string().optional() // The regex pattern to match (no default)
64
+ })
65
+ }));
66
+ // Text area question and answer
67
+ exports.TextAreaQuestion = exports.Question.merge(zod_1.z.object({
68
+ type: zod_1.z.literal('textArea'), // The type of question
69
+ attributes: zod_1.z.object({
70
+ cols: zod_1.z.number().optional(), // The number of columns (default is 20)
71
+ maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
72
+ minLength: zod_1.z.number().optional(), // The minimum length of the text (no default)
73
+ rows: zod_1.z.number().optional() // The number of rows (default is 2)
74
+ }),
75
+ meta: zod_1.z.object({
76
+ asRichText: zod_1.z.boolean().optional() // Whether to use rich text (default is false)
77
+ })
78
+ }));
79
+ // Text question and answer
80
+ exports.TextQuestion = exports.Question.merge(zod_1.z.object({
81
+ type: zod_1.z.literal('text'), // The type of question
82
+ attributes: zod_1.z.object({
83
+ maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
84
+ minLength: zod_1.z.number().optional(), // The minimum length of the text (no default)
85
+ pattern: zod_1.z.string().optional() // The regex pattern to match (no default)
86
+ }),
87
+ }));
88
+ // URL question and answer
89
+ exports.URLQuestion = exports.Question.merge(zod_1.z.object({
90
+ type: zod_1.z.literal('url'), // The type of question
91
+ attributes: zod_1.z.object({
92
+ maxLength: zod_1.z.number().optional(), // The maximum length of the URL (no default)
93
+ minLength: zod_1.z.number().optional(), // The minimum length of the URL (no default)
94
+ pattern: zod_1.z.string().optional() // The regex pattern to match (no default)
95
+ })
96
+ }));
@@ -0,0 +1,267 @@
1
+ {
2
+ "$ref": "#/definitions/AnyAnswer",
3
+ "definitions": {
4
+ "AnyAnswer": {
5
+ "anyOf": [
6
+ {
7
+ "type": "object",
8
+ "properties": {
9
+ "type": {
10
+ "type": "string",
11
+ "const": "boolean"
12
+ },
13
+ "answer": {
14
+ "type": "boolean"
15
+ }
16
+ },
17
+ "required": [
18
+ "type",
19
+ "answer"
20
+ ],
21
+ "additionalProperties": false
22
+ },
23
+ {
24
+ "type": "object",
25
+ "properties": {
26
+ "type": {
27
+ "type": "string",
28
+ "const": "checkBoxes"
29
+ },
30
+ "answer": {
31
+ "type": "array",
32
+ "items": {
33
+ "type": "string"
34
+ }
35
+ }
36
+ },
37
+ "required": [
38
+ "type",
39
+ "answer"
40
+ ],
41
+ "additionalProperties": false
42
+ },
43
+ {
44
+ "type": "object",
45
+ "properties": {
46
+ "type": {
47
+ "type": "string",
48
+ "const": "currency"
49
+ },
50
+ "answer": {
51
+ "type": "number"
52
+ }
53
+ },
54
+ "required": [
55
+ "type",
56
+ "answer"
57
+ ],
58
+ "additionalProperties": false
59
+ },
60
+ {
61
+ "type": "object",
62
+ "properties": {
63
+ "type": {
64
+ "type": "string",
65
+ "const": "datePicker"
66
+ },
67
+ "answer": {
68
+ "type": "string"
69
+ }
70
+ },
71
+ "required": [
72
+ "type",
73
+ "answer"
74
+ ],
75
+ "additionalProperties": false
76
+ },
77
+ {
78
+ "type": "object",
79
+ "properties": {
80
+ "type": {
81
+ "type": "string",
82
+ "const": "dateRange"
83
+ },
84
+ "answer": {
85
+ "type": "object",
86
+ "properties": {
87
+ "start": {
88
+ "type": "string"
89
+ },
90
+ "end": {
91
+ "type": "string"
92
+ }
93
+ },
94
+ "required": [
95
+ "start",
96
+ "end"
97
+ ],
98
+ "additionalProperties": false
99
+ }
100
+ },
101
+ "required": [
102
+ "type",
103
+ "answer"
104
+ ],
105
+ "additionalProperties": false
106
+ },
107
+ {
108
+ "type": "object",
109
+ "properties": {
110
+ "type": {
111
+ "type": "string",
112
+ "const": "email"
113
+ },
114
+ "answer": {
115
+ "type": "string"
116
+ }
117
+ },
118
+ "required": [
119
+ "type",
120
+ "answer"
121
+ ],
122
+ "additionalProperties": false
123
+ },
124
+ {
125
+ "type": "object",
126
+ "properties": {
127
+ "type": {
128
+ "type": "string",
129
+ "const": "filteredSearch"
130
+ },
131
+ "answer": {
132
+ "type": "array",
133
+ "items": {
134
+ "type": "string"
135
+ }
136
+ }
137
+ },
138
+ "required": [
139
+ "type",
140
+ "answer"
141
+ ],
142
+ "additionalProperties": false
143
+ },
144
+ {
145
+ "type": "object",
146
+ "properties": {
147
+ "type": {
148
+ "type": "string",
149
+ "const": "number"
150
+ },
151
+ "answer": {
152
+ "type": "number"
153
+ }
154
+ },
155
+ "required": [
156
+ "type",
157
+ "answer"
158
+ ],
159
+ "additionalProperties": false
160
+ },
161
+ {
162
+ "type": "object",
163
+ "properties": {
164
+ "type": {
165
+ "type": "string",
166
+ "const": "radioButtons"
167
+ },
168
+ "answer": {
169
+ "type": "string"
170
+ }
171
+ },
172
+ "required": [
173
+ "type",
174
+ "answer"
175
+ ],
176
+ "additionalProperties": false
177
+ },
178
+ {
179
+ "type": "object",
180
+ "properties": {
181
+ "type": {
182
+ "type": "string",
183
+ "const": "selectBox"
184
+ },
185
+ "answer": {
186
+ "type": "string"
187
+ }
188
+ },
189
+ "required": [
190
+ "type",
191
+ "answer"
192
+ ],
193
+ "additionalProperties": false
194
+ },
195
+ {
196
+ "type": "object",
197
+ "properties": {
198
+ "type": {
199
+ "type": "string",
200
+ "const": "textArea"
201
+ },
202
+ "answer": {
203
+ "type": "string"
204
+ }
205
+ },
206
+ "required": [
207
+ "type",
208
+ "answer"
209
+ ],
210
+ "additionalProperties": false
211
+ },
212
+ {
213
+ "type": "object",
214
+ "properties": {
215
+ "type": {
216
+ "type": "string",
217
+ "const": "text"
218
+ },
219
+ "answer": {
220
+ "type": "string"
221
+ }
222
+ },
223
+ "required": [
224
+ "type",
225
+ "answer"
226
+ ],
227
+ "additionalProperties": false
228
+ },
229
+ {
230
+ "type": "object",
231
+ "properties": {
232
+ "type": {
233
+ "type": "string",
234
+ "const": "typeaheadSearch"
235
+ },
236
+ "answer": {
237
+ "type": "string"
238
+ }
239
+ },
240
+ "required": [
241
+ "type",
242
+ "answer"
243
+ ],
244
+ "additionalProperties": false
245
+ },
246
+ {
247
+ "type": "object",
248
+ "properties": {
249
+ "type": {
250
+ "type": "string",
251
+ "const": "url"
252
+ },
253
+ "answer": {
254
+ "type": "string"
255
+ }
256
+ },
257
+ "required": [
258
+ "type",
259
+ "answer"
260
+ ],
261
+ "additionalProperties": false
262
+ }
263
+ ]
264
+ }
265
+ },
266
+ "$schema": "http://json-schema.org/draft-07/schema#"
267
+ }