@dmptool/types 1.0.0 → 1.0.1

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/README.md +33 -2
  2. package/dist/answers/__tests__/answers.spec.d.ts +1 -0
  3. package/dist/answers/__tests__/answers.spec.js +122 -0
  4. package/dist/answers/answer.d.ts +12 -0
  5. package/dist/answers/answer.js +10 -0
  6. package/dist/answers/dateAnswers.d.ts +39 -0
  7. package/dist/answers/dateAnswers.js +16 -0
  8. package/dist/answers/graphQLAnswers.d.ts +23 -0
  9. package/dist/answers/graphQLAnswers.js +14 -0
  10. package/dist/{answers.d.ts → answers/index.d.ts} +102 -268
  11. package/dist/answers/index.js +48 -0
  12. package/dist/answers/optionBasedAnswers.d.ts +34 -0
  13. package/dist/answers/optionBasedAnswers.js +18 -0
  14. package/dist/answers/primitiveAnswers.d.ts +78 -0
  15. package/dist/answers/primitiveAnswers.js +34 -0
  16. package/dist/answers/tableAnswers.d.ts +388 -0
  17. package/dist/answers/tableAnswers.js +31 -0
  18. package/dist/index.d.ts +2 -0
  19. package/dist/index.js +19 -0
  20. package/dist/questions/__tests__/dateQuestions.spec.d.ts +1 -0
  21. package/dist/questions/__tests__/dateQuestions.spec.js +149 -0
  22. package/dist/questions/__tests__/graphQLQuestions.spec.d.ts +1 -0
  23. package/dist/questions/__tests__/graphQLQuestions.spec.js +87 -0
  24. package/dist/questions/__tests__/optionBasedQuestions.spec.d.ts +1 -0
  25. package/dist/questions/__tests__/optionBasedQuestions.spec.js +152 -0
  26. package/dist/questions/__tests__/primitiveQuestions.spec.d.ts +1 -0
  27. package/dist/questions/__tests__/primitiveQuestions.spec.js +189 -0
  28. package/dist/{dateQuestions.js → questions/dateQuestions.js} +3 -3
  29. package/dist/{graphQLQuestions.js → questions/graphQLQuestions.js} +3 -3
  30. package/dist/{tableQuestions.d.ts → questions/index.d.ts} +97 -1650
  31. package/dist/questions/index.js +48 -0
  32. package/dist/{optionBasedQuestions.js → questions/optionBasedQuestions.js} +4 -4
  33. package/dist/{primitiveQuestions.d.ts → questions/primitiveQuestions.d.ts} +0 -27
  34. package/dist/{primitiveQuestions.js → questions/primitiveQuestions.js} +8 -35
  35. package/dist/questions/question.d.ts +29 -0
  36. package/dist/questions/question.js +32 -0
  37. package/dist/questions/tableQuestions.d.ts +2638 -0
  38. package/dist/{tableQuestions.js → questions/tableQuestions.js} +5 -22
  39. package/dist/schemas/anyAnswer.schema.json +110 -47
  40. package/dist/schemas/anyTableColumnAnswer.schema.json +267 -0
  41. package/dist/schemas/anyTableColumnQuestion.schema.json +637 -0
  42. package/dist/schemas/tableAnswer.schema.json +2 -2
  43. package/package.json +8 -1
  44. package/dist/answers.js +0 -87
  45. /package/dist/{dateQuestions.d.ts → questions/dateQuestions.d.ts} +0 -0
  46. /package/dist/{graphQLQuestions.d.ts → questions/graphQLQuestions.d.ts} +0 -0
  47. /package/dist/{optionBasedQuestions.d.ts → questions/optionBasedQuestions.d.ts} +0 -0
@@ -1,13 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AnyQuestion = exports.TableQuestion = void 0;
3
+ exports.TableQuestion = exports.AnyTableColumnQuestion = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const primitiveQuestions_1 = require("./primitiveQuestions");
6
6
  const dateQuestions_1 = require("./dateQuestions");
7
7
  const optionBasedQuestions_1 = require("./optionBasedQuestions");
8
8
  const graphQLQuestions_1 = require("./graphQLQuestions");
9
+ const question_1 = require("./question");
9
10
  // Union types for all questions and answers (tables cannot be nested so no TableQuestion here!)
10
- const ColumnQuestions = zod_1.z.discriminatedUnion('type', [
11
+ exports.AnyTableColumnQuestion = zod_1.z.discriminatedUnion('type', [
11
12
  primitiveQuestions_1.BooleanQuestion,
12
13
  optionBasedQuestions_1.CheckboxesQuestion,
13
14
  primitiveQuestions_1.CurrencyQuestion,
@@ -24,9 +25,9 @@ const ColumnQuestions = zod_1.z.discriminatedUnion('type', [
24
25
  primitiveQuestions_1.URLQuestion
25
26
  ]);
26
27
  // Table question and answer
27
- exports.TableQuestion = primitiveQuestions_1.Question.merge(zod_1.z.object({
28
+ exports.TableQuestion = question_1.Question.merge(zod_1.z.object({
28
29
  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
+ columns: zod_1.z.array(exports.AnyTableColumnQuestion), // The columns of the table (note: tables cannot be nested)
30
31
  attributes: zod_1.z.object({
31
32
  canAddRows: zod_1.z.boolean().optional(), // Whether to allow adding rows (default is true)
32
33
  canRemoveRows: zod_1.z.boolean().optional(), // Whether to allow removing rows (default is true)
@@ -35,21 +36,3 @@ exports.TableQuestion = primitiveQuestions_1.Question.merge(zod_1.z.object({
35
36
  minRows: zod_1.z.number().optional() // The minimum number of rows (no default)
36
37
  })
37
38
  }));
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
- ]);
@@ -197,10 +197,112 @@
197
197
  "properties": {
198
198
  "type": {
199
199
  "type": "string",
200
- "const": "textArea"
200
+ "const": "table"
201
201
  },
202
202
  "answer": {
203
- "type": "string"
203
+ "type": "array",
204
+ "items": {
205
+ "anyOf": [
206
+ {
207
+ "$ref": "#/definitions/AnyAnswer/anyOf/0"
208
+ },
209
+ {
210
+ "$ref": "#/definitions/AnyAnswer/anyOf/1"
211
+ },
212
+ {
213
+ "$ref": "#/definitions/AnyAnswer/anyOf/2"
214
+ },
215
+ {
216
+ "$ref": "#/definitions/AnyAnswer/anyOf/3"
217
+ },
218
+ {
219
+ "$ref": "#/definitions/AnyAnswer/anyOf/4"
220
+ },
221
+ {
222
+ "$ref": "#/definitions/AnyAnswer/anyOf/5"
223
+ },
224
+ {
225
+ "$ref": "#/definitions/AnyAnswer/anyOf/6"
226
+ },
227
+ {
228
+ "$ref": "#/definitions/AnyAnswer/anyOf/7"
229
+ },
230
+ {
231
+ "$ref": "#/definitions/AnyAnswer/anyOf/8"
232
+ },
233
+ {
234
+ "$ref": "#/definitions/AnyAnswer/anyOf/9"
235
+ },
236
+ {
237
+ "type": "object",
238
+ "properties": {
239
+ "type": {
240
+ "type": "string",
241
+ "const": "text"
242
+ },
243
+ "answer": {
244
+ "type": "string"
245
+ }
246
+ },
247
+ "required": [
248
+ "type",
249
+ "answer"
250
+ ],
251
+ "additionalProperties": false
252
+ },
253
+ {
254
+ "type": "object",
255
+ "properties": {
256
+ "type": {
257
+ "type": "string",
258
+ "const": "textArea"
259
+ },
260
+ "answer": {
261
+ "type": "string"
262
+ }
263
+ },
264
+ "required": [
265
+ "type",
266
+ "answer"
267
+ ],
268
+ "additionalProperties": false
269
+ },
270
+ {
271
+ "type": "object",
272
+ "properties": {
273
+ "type": {
274
+ "type": "string",
275
+ "const": "typeaheadSearch"
276
+ },
277
+ "answer": {
278
+ "type": "string"
279
+ }
280
+ },
281
+ "required": [
282
+ "type",
283
+ "answer"
284
+ ],
285
+ "additionalProperties": false
286
+ },
287
+ {
288
+ "type": "object",
289
+ "properties": {
290
+ "type": {
291
+ "type": "string",
292
+ "const": "url"
293
+ },
294
+ "answer": {
295
+ "type": "string"
296
+ }
297
+ },
298
+ "required": [
299
+ "type",
300
+ "answer"
301
+ ],
302
+ "additionalProperties": false
303
+ }
304
+ ]
305
+ }
204
306
  }
205
307
  },
206
308
  "required": [
@@ -210,55 +312,16 @@
210
312
  "additionalProperties": false
211
313
  },
212
314
  {
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
315
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/10"
228
316
  },
229
317
  {
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
318
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/11"
245
319
  },
246
320
  {
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
321
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/12"
322
+ },
323
+ {
324
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/13"
262
325
  }
263
326
  ]
264
327
  }
@@ -0,0 +1,267 @@
1
+ {
2
+ "$ref": "#/definitions/AnyTableColumnAnswer",
3
+ "definitions": {
4
+ "AnyTableColumnAnswer": {
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": "text"
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": "textArea"
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
+ }