@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.
Files changed (62) hide show
  1. package/README.md +127 -29
  2. package/dist/answers/__tests__/answers.spec.d.ts +1 -0
  3. package/dist/answers/__tests__/answers.spec.js +127 -0
  4. package/dist/answers/answer.d.ts +25 -0
  5. package/dist/answers/answer.js +13 -0
  6. package/dist/answers/dateAnswers.d.ts +66 -0
  7. package/dist/answers/dateAnswers.js +16 -0
  8. package/dist/answers/graphQLAnswers.d.ts +51 -0
  9. package/dist/answers/graphQLAnswers.js +14 -0
  10. package/dist/answers/index.d.ts +880 -0
  11. package/dist/answers/index.js +48 -0
  12. package/dist/answers/optionBasedAnswers.d.ts +76 -0
  13. package/dist/answers/optionBasedAnswers.js +18 -0
  14. package/dist/answers/primitiveAnswers.d.ts +176 -0
  15. package/dist/answers/primitiveAnswers.js +34 -0
  16. package/dist/answers/tableAnswers.d.ts +876 -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 +195 -59
  40. package/dist/schemas/anyTableColumnAnswer.schema.json +336 -0
  41. package/dist/schemas/anyTableColumnQuestion.schema.json +637 -0
  42. package/dist/schemas/booleanAnswer.schema.json +15 -1
  43. package/dist/schemas/checkboxesAnswer.schema.json +15 -1
  44. package/dist/schemas/currencyAnswer.schema.json +15 -1
  45. package/dist/schemas/datePickerAnswer.schema.json +15 -1
  46. package/dist/schemas/dateRangeAnswer.schema.json +15 -1
  47. package/dist/schemas/emailAnswer.schema.json +15 -1
  48. package/dist/schemas/filteredSearchAnswer.schema.json +15 -1
  49. package/dist/schemas/numberAnswer.schema.json +15 -1
  50. package/dist/schemas/radioButtonsAnswer.schema.json +15 -1
  51. package/dist/schemas/selectBoxAnswer.schema.json +19 -2
  52. package/dist/schemas/tableAnswer.schema.json +91 -18
  53. package/dist/schemas/textAnswer.schema.json +15 -1
  54. package/dist/schemas/textAreaAnswer.schema.json +15 -1
  55. package/dist/schemas/typeaheadSearchAnswer.schema.json +15 -1
  56. package/dist/schemas/urlAnswer.schema.json +15 -1
  57. package/package.json +8 -1
  58. package/dist/answers.d.ts +0 -558
  59. package/dist/answers.js +0 -87
  60. /package/dist/{dateQuestions.d.ts → questions/dateQuestions.d.ts} +0 -0
  61. /package/dist/{graphQLQuestions.d.ts → questions/graphQLQuestions.d.ts} +0 -0
  62. /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
- ]);
@@ -12,11 +12,25 @@
12
12
  },
13
13
  "answer": {
14
14
  "type": "boolean"
15
+ },
16
+ "meta": {
17
+ "type": "object",
18
+ "properties": {
19
+ "schemaVersion": {
20
+ "type": "string",
21
+ "const": "1.0"
22
+ }
23
+ },
24
+ "required": [
25
+ "schemaVersion"
26
+ ],
27
+ "additionalProperties": false
15
28
  }
16
29
  },
17
30
  "required": [
18
31
  "type",
19
- "answer"
32
+ "answer",
33
+ "meta"
20
34
  ],
21
35
  "additionalProperties": false
22
36
  },
@@ -32,11 +46,15 @@
32
46
  "items": {
33
47
  "type": "string"
34
48
  }
49
+ },
50
+ "meta": {
51
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
35
52
  }
36
53
  },
37
54
  "required": [
38
55
  "type",
39
- "answer"
56
+ "answer",
57
+ "meta"
40
58
  ],
41
59
  "additionalProperties": false
42
60
  },
@@ -49,11 +67,15 @@
49
67
  },
50
68
  "answer": {
51
69
  "type": "number"
70
+ },
71
+ "meta": {
72
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
52
73
  }
53
74
  },
54
75
  "required": [
55
76
  "type",
56
- "answer"
77
+ "answer",
78
+ "meta"
57
79
  ],
58
80
  "additionalProperties": false
59
81
  },
@@ -66,11 +88,15 @@
66
88
  },
67
89
  "answer": {
68
90
  "type": "string"
91
+ },
92
+ "meta": {
93
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
69
94
  }
70
95
  },
71
96
  "required": [
72
97
  "type",
73
- "answer"
98
+ "answer",
99
+ "meta"
74
100
  ],
75
101
  "additionalProperties": false
76
102
  },
@@ -96,11 +122,15 @@
96
122
  "end"
97
123
  ],
98
124
  "additionalProperties": false
125
+ },
126
+ "meta": {
127
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
99
128
  }
100
129
  },
101
130
  "required": [
102
131
  "type",
103
- "answer"
132
+ "answer",
133
+ "meta"
104
134
  ],
105
135
  "additionalProperties": false
106
136
  },
@@ -113,11 +143,15 @@
113
143
  },
114
144
  "answer": {
115
145
  "type": "string"
146
+ },
147
+ "meta": {
148
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
116
149
  }
117
150
  },
118
151
  "required": [
119
152
  "type",
120
- "answer"
153
+ "answer",
154
+ "meta"
121
155
  ],
122
156
  "additionalProperties": false
123
157
  },
@@ -133,11 +167,15 @@
133
167
  "items": {
134
168
  "type": "string"
135
169
  }
170
+ },
171
+ "meta": {
172
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
136
173
  }
137
174
  },
138
175
  "required": [
139
176
  "type",
140
- "answer"
177
+ "answer",
178
+ "meta"
141
179
  ],
142
180
  "additionalProperties": false
143
181
  },
@@ -150,11 +188,15 @@
150
188
  },
151
189
  "answer": {
152
190
  "type": "number"
191
+ },
192
+ "meta": {
193
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
153
194
  }
154
195
  },
155
196
  "required": [
156
197
  "type",
157
- "answer"
198
+ "answer",
199
+ "meta"
158
200
  ],
159
201
  "additionalProperties": false
160
202
  },
@@ -167,11 +209,15 @@
167
209
  },
168
210
  "answer": {
169
211
  "type": "string"
212
+ },
213
+ "meta": {
214
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
170
215
  }
171
216
  },
172
217
  "required": [
173
218
  "type",
174
- "answer"
219
+ "answer",
220
+ "meta"
175
221
  ],
176
222
  "additionalProperties": false
177
223
  },
@@ -183,12 +229,19 @@
183
229
  "const": "selectBox"
184
230
  },
185
231
  "answer": {
186
- "type": "string"
232
+ "type": "array",
233
+ "items": {
234
+ "type": "string"
235
+ }
236
+ },
237
+ "meta": {
238
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
187
239
  }
188
240
  },
189
241
  "required": [
190
242
  "type",
191
- "answer"
243
+ "answer",
244
+ "meta"
192
245
  ],
193
246
  "additionalProperties": false
194
247
  },
@@ -197,68 +250,151 @@
197
250
  "properties": {
198
251
  "type": {
199
252
  "type": "string",
200
- "const": "textArea"
253
+ "const": "table"
201
254
  },
202
255
  "answer": {
203
- "type": "string"
256
+ "type": "array",
257
+ "items": {
258
+ "anyOf": [
259
+ {
260
+ "$ref": "#/definitions/AnyAnswer/anyOf/0"
261
+ },
262
+ {
263
+ "$ref": "#/definitions/AnyAnswer/anyOf/1"
264
+ },
265
+ {
266
+ "$ref": "#/definitions/AnyAnswer/anyOf/2"
267
+ },
268
+ {
269
+ "$ref": "#/definitions/AnyAnswer/anyOf/3"
270
+ },
271
+ {
272
+ "$ref": "#/definitions/AnyAnswer/anyOf/4"
273
+ },
274
+ {
275
+ "$ref": "#/definitions/AnyAnswer/anyOf/5"
276
+ },
277
+ {
278
+ "$ref": "#/definitions/AnyAnswer/anyOf/6"
279
+ },
280
+ {
281
+ "$ref": "#/definitions/AnyAnswer/anyOf/7"
282
+ },
283
+ {
284
+ "$ref": "#/definitions/AnyAnswer/anyOf/8"
285
+ },
286
+ {
287
+ "$ref": "#/definitions/AnyAnswer/anyOf/9"
288
+ },
289
+ {
290
+ "type": "object",
291
+ "properties": {
292
+ "type": {
293
+ "type": "string",
294
+ "const": "text"
295
+ },
296
+ "answer": {
297
+ "type": "string"
298
+ },
299
+ "meta": {
300
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
301
+ }
302
+ },
303
+ "required": [
304
+ "type",
305
+ "answer",
306
+ "meta"
307
+ ],
308
+ "additionalProperties": false
309
+ },
310
+ {
311
+ "type": "object",
312
+ "properties": {
313
+ "type": {
314
+ "type": "string",
315
+ "const": "textArea"
316
+ },
317
+ "answer": {
318
+ "type": "string"
319
+ },
320
+ "meta": {
321
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
322
+ }
323
+ },
324
+ "required": [
325
+ "type",
326
+ "answer",
327
+ "meta"
328
+ ],
329
+ "additionalProperties": false
330
+ },
331
+ {
332
+ "type": "object",
333
+ "properties": {
334
+ "type": {
335
+ "type": "string",
336
+ "const": "typeaheadSearch"
337
+ },
338
+ "answer": {
339
+ "type": "string"
340
+ },
341
+ "meta": {
342
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
343
+ }
344
+ },
345
+ "required": [
346
+ "type",
347
+ "answer",
348
+ "meta"
349
+ ],
350
+ "additionalProperties": false
351
+ },
352
+ {
353
+ "type": "object",
354
+ "properties": {
355
+ "type": {
356
+ "type": "string",
357
+ "const": "url"
358
+ },
359
+ "answer": {
360
+ "type": "string"
361
+ },
362
+ "meta": {
363
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
364
+ }
365
+ },
366
+ "required": [
367
+ "type",
368
+ "answer",
369
+ "meta"
370
+ ],
371
+ "additionalProperties": false
372
+ }
373
+ ]
374
+ }
375
+ },
376
+ "meta": {
377
+ "$ref": "#/definitions/AnyAnswer/anyOf/0/properties/meta"
204
378
  }
205
379
  },
206
380
  "required": [
207
381
  "type",
208
- "answer"
382
+ "answer",
383
+ "meta"
209
384
  ],
210
385
  "additionalProperties": false
211
386
  },
212
387
  {
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
388
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/10"
228
389
  },
229
390
  {
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
391
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/11"
245
392
  },
246
393
  {
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
394
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/12"
395
+ },
396
+ {
397
+ "$ref": "#/definitions/AnyAnswer/anyOf/10/properties/answer/items/anyOf/13"
262
398
  }
263
399
  ]
264
400
  }