@dmptool/types 1.0.7 → 1.1.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 (56) hide show
  1. package/dist/answers/__tests__/answers.spec.js +18 -17
  2. package/dist/answers/index.d.ts +50 -25
  3. package/dist/answers/index.js +19 -17
  4. package/dist/answers/{primitiveAnswers.d.ts → numberAnswers.d.ts} +1 -100
  5. package/dist/answers/numberAnswers.js +25 -0
  6. package/dist/answers/tableAnswers.d.ts +48 -48
  7. package/dist/answers/tableAnswers.js +9 -8
  8. package/dist/answers/textAnswers.d.ts +101 -0
  9. package/dist/answers/textAnswers.js +22 -0
  10. package/dist/questions/__tests__/dateQuestions.spec.js +20 -74
  11. package/dist/questions/__tests__/graphQLQuestions.spec.js +6 -0
  12. package/dist/questions/__tests__/numberQuestions.spec.js +156 -0
  13. package/dist/questions/__tests__/optionBasedQuestions.spec.js +41 -54
  14. package/dist/questions/__tests__/tableQuestion.spec.js +2 -0
  15. package/dist/questions/__tests__/textQuestions.spec.d.ts +1 -0
  16. package/dist/questions/__tests__/textQuestions.spec.js +120 -0
  17. package/dist/questions/dateQuestions.d.ts +159 -178
  18. package/dist/questions/dateQuestions.js +9 -15
  19. package/dist/questions/graphQLQuestions.d.ts +67 -38
  20. package/dist/questions/graphQLQuestions.js +3 -2
  21. package/dist/questions/index.d.ts +1616 -1356
  22. package/dist/questions/index.js +21 -19
  23. package/dist/questions/numberQuestions.d.ts +343 -0
  24. package/dist/questions/numberQuestions.js +34 -0
  25. package/dist/questions/optionBasedQuestions.d.ts +136 -158
  26. package/dist/questions/optionBasedQuestions.js +11 -20
  27. package/dist/questions/question.d.ts +29 -11
  28. package/dist/questions/question.js +10 -4
  29. package/dist/questions/tableQuestions.d.ts +2377 -2030
  30. package/dist/questions/tableQuestions.js +12 -10
  31. package/dist/questions/textQuestions.d.ts +261 -0
  32. package/dist/questions/textQuestions.js +42 -0
  33. package/dist/schemas/anyQuestion.schema.json +237 -239
  34. package/dist/schemas/anyTableColumnQuestion.schema.json +207 -217
  35. package/dist/schemas/booleanQuestion.schema.json +17 -12
  36. package/dist/schemas/checkboxesQuestion.schema.json +24 -27
  37. package/dist/schemas/currencyQuestion.schema.json +23 -18
  38. package/dist/schemas/dateQuestion.schema.json +21 -16
  39. package/dist/schemas/dateRangeQuestion.schema.json +31 -56
  40. package/dist/schemas/emailQuestion.schema.json +24 -19
  41. package/dist/schemas/filteredSearchQuestion.schema.json +18 -13
  42. package/dist/schemas/numberQuestion.schema.json +21 -16
  43. package/dist/schemas/numberRangeQuestion.schema.json +31 -56
  44. package/dist/schemas/radioButtonsQuestion.schema.json +24 -27
  45. package/dist/schemas/selectBoxQuestion.schema.json +27 -36
  46. package/dist/schemas/tableQuestion.schema.json +233 -235
  47. package/dist/schemas/textAreaQuestion.schema.json +22 -16
  48. package/dist/schemas/textQuestion.schema.json +21 -16
  49. package/dist/schemas/typeaheadSearchQuestion.schema.json +15 -4
  50. package/dist/schemas/urlQuestion.schema.json +21 -16
  51. package/package.json +1 -1
  52. package/dist/answers/primitiveAnswers.js +0 -41
  53. package/dist/questions/__tests__/primitiveQuestions.spec.js +0 -281
  54. package/dist/questions/primitiveQuestions.d.ts +0 -554
  55. package/dist/questions/primitiveQuestions.js +0 -86
  56. /package/dist/questions/__tests__/{primitiveQuestions.spec.d.ts → numberQuestions.spec.d.ts} +0 -0
@@ -16,7 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.QuestionSchemaMap = exports.AnyQuestionSchema = void 0;
18
18
  const zod_1 = require("zod");
19
- const primitiveQuestions_1 = require("./primitiveQuestions");
19
+ const numberQuestions_1 = require("./numberQuestions");
20
+ const textQuestions_1 = require("./textQuestions");
20
21
  const dateQuestions_1 = require("./dateQuestions");
21
22
  const optionBasedQuestions_1 = require("./optionBasedQuestions");
22
23
  const graphQLQuestions_1 = require("./graphQLQuestions");
@@ -25,43 +26,44 @@ const tableQuestions_1 = require("./tableQuestions");
25
26
  __exportStar(require("./question"), exports);
26
27
  __exportStar(require("./dateQuestions"), exports);
27
28
  __exportStar(require("./graphQLQuestions"), exports);
29
+ __exportStar(require("./numberQuestions"), exports);
28
30
  __exportStar(require("./optionBasedQuestions"), exports);
29
- __exportStar(require("./primitiveQuestions"), exports);
30
31
  __exportStar(require("./tableQuestions"), exports);
31
- // All of the possible questions
32
+ __exportStar(require("./textQuestions"), exports);
32
33
  exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
33
- primitiveQuestions_1.BooleanQuestionSchema,
34
+ numberQuestions_1.BooleanQuestionSchema,
34
35
  optionBasedQuestions_1.CheckboxesQuestionSchema,
35
- primitiveQuestions_1.CurrencyQuestionSchema,
36
+ numberQuestions_1.CurrencyQuestionSchema,
36
37
  dateQuestions_1.DateQuestionSchema,
37
38
  dateQuestions_1.DateRangeQuestionSchema,
38
- primitiveQuestions_1.EmailQuestionSchema,
39
+ textQuestions_1.EmailQuestionSchema,
39
40
  graphQLQuestions_1.FilteredSearchQuestionSchema,
40
- primitiveQuestions_1.NumberQuestionSchema,
41
+ numberQuestions_1.NumberQuestionSchema,
41
42
  optionBasedQuestions_1.RadioButtonsQuestionSchema,
42
43
  optionBasedQuestions_1.SelectBoxQuestionSchema,
43
44
  tableQuestions_1.TableQuestionSchema,
44
- primitiveQuestions_1.TextAreaQuestionSchema,
45
- primitiveQuestions_1.TextQuestionSchema,
45
+ textQuestions_1.TextAreaQuestionSchema,
46
+ textQuestions_1.TextQuestionSchema,
46
47
  graphQLQuestions_1.TypeaheadSearchQuestionSchema,
47
- primitiveQuestions_1.URLQuestionSchema
48
+ textQuestions_1.URLQuestionSchema
48
49
  ]);
49
- // Export a mapping between question types and their corresponding question schemas
50
+ // Export a mapping between Zod Schemas and their corresponding question type label
50
51
  exports.QuestionSchemaMap = {
51
- boolean: primitiveQuestions_1.BooleanQuestionSchema,
52
+ boolean: numberQuestions_1.BooleanQuestionSchema,
52
53
  checkBoxes: optionBasedQuestions_1.CheckboxesQuestionSchema,
53
- currency: primitiveQuestions_1.CurrencyQuestionSchema,
54
+ currency: numberQuestions_1.CurrencyQuestionSchema,
54
55
  date: dateQuestions_1.DateQuestionSchema,
55
56
  dateRange: dateQuestions_1.DateRangeQuestionSchema,
56
- email: primitiveQuestions_1.EmailQuestionSchema,
57
+ email: textQuestions_1.EmailQuestionSchema,
57
58
  filteredSearch: graphQLQuestions_1.FilteredSearchQuestionSchema,
58
- number: primitiveQuestions_1.NumberQuestionSchema,
59
- numberRange: primitiveQuestions_1.NumberRangeQuestionSchema,
59
+ number: numberQuestions_1.NumberQuestionSchema,
60
+ numberRange: numberQuestions_1.NumberRangeQuestionSchema,
60
61
  radioButtons: optionBasedQuestions_1.RadioButtonsQuestionSchema,
61
62
  selectBox: optionBasedQuestions_1.SelectBoxQuestionSchema,
62
63
  table: tableQuestions_1.TableQuestionSchema,
63
- text: primitiveQuestions_1.TextQuestionSchema,
64
- textArea: primitiveQuestions_1.TextAreaQuestionSchema,
64
+ text: textQuestions_1.TextQuestionSchema,
65
+ textArea: textQuestions_1.TextAreaQuestionSchema,
65
66
  typeaheadSearch: graphQLQuestions_1.TypeaheadSearchQuestionSchema,
66
- url: primitiveQuestions_1.URLQuestionSchema
67
+ url: textQuestions_1.URLQuestionSchema
67
68
  };
69
+ ;
@@ -0,0 +1,343 @@
1
+ import { z } from "zod";
2
+ export declare const BooleanQuestionSchema: z.ZodObject<{
3
+ meta: z.ZodOptional<z.ZodObject<{
4
+ schemaVersion: z.ZodLiteral<"1.0">;
5
+ }, "strip", z.ZodTypeAny, {
6
+ schemaVersion: "1.0";
7
+ }, {
8
+ schemaVersion: "1.0";
9
+ }>>;
10
+ } & {
11
+ type: z.ZodLiteral<"boolean">;
12
+ attributes: z.ZodOptional<z.ZodObject<{
13
+ label: z.ZodOptional<z.ZodString>;
14
+ help: z.ZodOptional<z.ZodString>;
15
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
16
+ } & {
17
+ checked: z.ZodOptional<z.ZodBoolean>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ label?: string | undefined;
20
+ help?: string | undefined;
21
+ labelTranslationKey?: string | undefined;
22
+ checked?: boolean | undefined;
23
+ }, {
24
+ label?: string | undefined;
25
+ help?: string | undefined;
26
+ labelTranslationKey?: string | undefined;
27
+ checked?: boolean | undefined;
28
+ }>>;
29
+ }, "strip", z.ZodTypeAny, {
30
+ type: "boolean";
31
+ attributes?: {
32
+ label?: string | undefined;
33
+ help?: string | undefined;
34
+ labelTranslationKey?: string | undefined;
35
+ checked?: boolean | undefined;
36
+ } | undefined;
37
+ meta?: {
38
+ schemaVersion: "1.0";
39
+ } | undefined;
40
+ }, {
41
+ type: "boolean";
42
+ attributes?: {
43
+ label?: string | undefined;
44
+ help?: string | undefined;
45
+ labelTranslationKey?: string | undefined;
46
+ checked?: boolean | undefined;
47
+ } | undefined;
48
+ meta?: {
49
+ schemaVersion: "1.0";
50
+ } | undefined;
51
+ }>;
52
+ export declare const CurrencyQuestionSchema: z.ZodObject<{
53
+ meta: z.ZodOptional<z.ZodObject<{
54
+ schemaVersion: z.ZodLiteral<"1.0">;
55
+ }, "strip", z.ZodTypeAny, {
56
+ schemaVersion: "1.0";
57
+ }, {
58
+ schemaVersion: "1.0";
59
+ }>>;
60
+ } & {
61
+ type: z.ZodLiteral<"currency">;
62
+ attributes: z.ZodOptional<z.ZodObject<{
63
+ label: z.ZodOptional<z.ZodString>;
64
+ help: z.ZodOptional<z.ZodString>;
65
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
66
+ } & {
67
+ max: z.ZodOptional<z.ZodNumber>;
68
+ min: z.ZodOptional<z.ZodNumber>;
69
+ step: z.ZodOptional<z.ZodNumber>;
70
+ } & {
71
+ denomination: z.ZodOptional<z.ZodString>;
72
+ }, "strip", z.ZodTypeAny, {
73
+ label?: string | undefined;
74
+ help?: string | undefined;
75
+ labelTranslationKey?: string | undefined;
76
+ max?: number | undefined;
77
+ min?: number | undefined;
78
+ step?: number | undefined;
79
+ denomination?: string | undefined;
80
+ }, {
81
+ label?: string | undefined;
82
+ help?: string | undefined;
83
+ labelTranslationKey?: string | undefined;
84
+ max?: number | undefined;
85
+ min?: number | undefined;
86
+ step?: number | undefined;
87
+ denomination?: string | undefined;
88
+ }>>;
89
+ }, "strip", z.ZodTypeAny, {
90
+ type: "currency";
91
+ attributes?: {
92
+ label?: string | undefined;
93
+ help?: string | undefined;
94
+ labelTranslationKey?: string | undefined;
95
+ max?: number | undefined;
96
+ min?: number | undefined;
97
+ step?: number | undefined;
98
+ denomination?: string | undefined;
99
+ } | undefined;
100
+ meta?: {
101
+ schemaVersion: "1.0";
102
+ } | undefined;
103
+ }, {
104
+ type: "currency";
105
+ attributes?: {
106
+ label?: string | undefined;
107
+ help?: string | undefined;
108
+ labelTranslationKey?: string | undefined;
109
+ max?: number | undefined;
110
+ min?: number | undefined;
111
+ step?: number | undefined;
112
+ denomination?: string | undefined;
113
+ } | undefined;
114
+ meta?: {
115
+ schemaVersion: "1.0";
116
+ } | undefined;
117
+ }>;
118
+ export declare const NumberQuestionSchema: z.ZodObject<{
119
+ meta: z.ZodOptional<z.ZodObject<{
120
+ schemaVersion: z.ZodLiteral<"1.0">;
121
+ }, "strip", z.ZodTypeAny, {
122
+ schemaVersion: "1.0";
123
+ }, {
124
+ schemaVersion: "1.0";
125
+ }>>;
126
+ } & {
127
+ type: z.ZodLiteral<"number">;
128
+ attributes: z.ZodOptional<z.ZodObject<{
129
+ label: z.ZodOptional<z.ZodString>;
130
+ help: z.ZodOptional<z.ZodString>;
131
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
132
+ } & {
133
+ max: z.ZodOptional<z.ZodNumber>;
134
+ min: z.ZodOptional<z.ZodNumber>;
135
+ step: z.ZodOptional<z.ZodNumber>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ label?: string | undefined;
138
+ help?: string | undefined;
139
+ labelTranslationKey?: string | undefined;
140
+ max?: number | undefined;
141
+ min?: number | undefined;
142
+ step?: number | undefined;
143
+ }, {
144
+ label?: string | undefined;
145
+ help?: string | undefined;
146
+ labelTranslationKey?: string | undefined;
147
+ max?: number | undefined;
148
+ min?: number | undefined;
149
+ step?: number | undefined;
150
+ }>>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ type: "number";
153
+ attributes?: {
154
+ label?: string | undefined;
155
+ help?: string | undefined;
156
+ labelTranslationKey?: string | undefined;
157
+ max?: number | undefined;
158
+ min?: number | undefined;
159
+ step?: number | undefined;
160
+ } | undefined;
161
+ meta?: {
162
+ schemaVersion: "1.0";
163
+ } | undefined;
164
+ }, {
165
+ type: "number";
166
+ attributes?: {
167
+ label?: string | undefined;
168
+ help?: string | undefined;
169
+ labelTranslationKey?: string | undefined;
170
+ max?: number | undefined;
171
+ min?: number | undefined;
172
+ step?: number | undefined;
173
+ } | undefined;
174
+ meta?: {
175
+ schemaVersion: "1.0";
176
+ } | undefined;
177
+ }>;
178
+ export declare const NumberRangeQuestionSchema: z.ZodObject<{
179
+ attributes: z.ZodOptional<z.ZodObject<{
180
+ label: z.ZodOptional<z.ZodString>;
181
+ help: z.ZodOptional<z.ZodString>;
182
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
183
+ }, "strip", z.ZodTypeAny, {
184
+ label?: string | undefined;
185
+ help?: string | undefined;
186
+ labelTranslationKey?: string | undefined;
187
+ }, {
188
+ label?: string | undefined;
189
+ help?: string | undefined;
190
+ labelTranslationKey?: string | undefined;
191
+ }>>;
192
+ meta: z.ZodOptional<z.ZodObject<{
193
+ schemaVersion: z.ZodLiteral<"1.0">;
194
+ }, "strip", z.ZodTypeAny, {
195
+ schemaVersion: "1.0";
196
+ }, {
197
+ schemaVersion: "1.0";
198
+ }>>;
199
+ } & {
200
+ type: z.ZodLiteral<"numberRange">;
201
+ columns: z.ZodObject<{
202
+ start: z.ZodOptional<z.ZodObject<{
203
+ label: z.ZodOptional<z.ZodString>;
204
+ help: z.ZodOptional<z.ZodString>;
205
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
206
+ } & {
207
+ max: z.ZodOptional<z.ZodNumber>;
208
+ min: z.ZodOptional<z.ZodNumber>;
209
+ step: z.ZodOptional<z.ZodNumber>;
210
+ }, "strip", z.ZodTypeAny, {
211
+ label?: string | undefined;
212
+ help?: string | undefined;
213
+ labelTranslationKey?: string | undefined;
214
+ max?: number | undefined;
215
+ min?: number | undefined;
216
+ step?: number | undefined;
217
+ }, {
218
+ label?: string | undefined;
219
+ help?: string | undefined;
220
+ labelTranslationKey?: string | undefined;
221
+ max?: number | undefined;
222
+ min?: number | undefined;
223
+ step?: number | undefined;
224
+ }>>;
225
+ end: z.ZodOptional<z.ZodObject<{
226
+ label: z.ZodOptional<z.ZodString>;
227
+ help: z.ZodOptional<z.ZodString>;
228
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
229
+ } & {
230
+ max: z.ZodOptional<z.ZodNumber>;
231
+ min: z.ZodOptional<z.ZodNumber>;
232
+ step: z.ZodOptional<z.ZodNumber>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ label?: string | undefined;
235
+ help?: string | undefined;
236
+ labelTranslationKey?: string | undefined;
237
+ max?: number | undefined;
238
+ min?: number | undefined;
239
+ step?: number | undefined;
240
+ }, {
241
+ label?: string | undefined;
242
+ help?: string | undefined;
243
+ labelTranslationKey?: string | undefined;
244
+ max?: number | undefined;
245
+ min?: number | undefined;
246
+ step?: number | undefined;
247
+ }>>;
248
+ }, "strip", z.ZodTypeAny, {
249
+ start?: {
250
+ label?: string | undefined;
251
+ help?: string | undefined;
252
+ labelTranslationKey?: string | undefined;
253
+ max?: number | undefined;
254
+ min?: number | undefined;
255
+ step?: number | undefined;
256
+ } | undefined;
257
+ end?: {
258
+ label?: string | undefined;
259
+ help?: string | undefined;
260
+ labelTranslationKey?: string | undefined;
261
+ max?: number | undefined;
262
+ min?: number | undefined;
263
+ step?: number | undefined;
264
+ } | undefined;
265
+ }, {
266
+ start?: {
267
+ label?: string | undefined;
268
+ help?: string | undefined;
269
+ labelTranslationKey?: string | undefined;
270
+ max?: number | undefined;
271
+ min?: number | undefined;
272
+ step?: number | undefined;
273
+ } | undefined;
274
+ end?: {
275
+ label?: string | undefined;
276
+ help?: string | undefined;
277
+ labelTranslationKey?: string | undefined;
278
+ max?: number | undefined;
279
+ min?: number | undefined;
280
+ step?: number | undefined;
281
+ } | undefined;
282
+ }>;
283
+ }, "strip", z.ZodTypeAny, {
284
+ type: "numberRange";
285
+ columns: {
286
+ start?: {
287
+ label?: string | undefined;
288
+ help?: string | undefined;
289
+ labelTranslationKey?: string | undefined;
290
+ max?: number | undefined;
291
+ min?: number | undefined;
292
+ step?: number | undefined;
293
+ } | undefined;
294
+ end?: {
295
+ label?: string | undefined;
296
+ help?: string | undefined;
297
+ labelTranslationKey?: string | undefined;
298
+ max?: number | undefined;
299
+ min?: number | undefined;
300
+ step?: number | undefined;
301
+ } | undefined;
302
+ };
303
+ attributes?: {
304
+ label?: string | undefined;
305
+ help?: string | undefined;
306
+ labelTranslationKey?: string | undefined;
307
+ } | undefined;
308
+ meta?: {
309
+ schemaVersion: "1.0";
310
+ } | undefined;
311
+ }, {
312
+ type: "numberRange";
313
+ columns: {
314
+ start?: {
315
+ label?: string | undefined;
316
+ help?: string | undefined;
317
+ labelTranslationKey?: string | undefined;
318
+ max?: number | undefined;
319
+ min?: number | undefined;
320
+ step?: number | undefined;
321
+ } | undefined;
322
+ end?: {
323
+ label?: string | undefined;
324
+ help?: string | undefined;
325
+ labelTranslationKey?: string | undefined;
326
+ max?: number | undefined;
327
+ min?: number | undefined;
328
+ step?: number | undefined;
329
+ } | undefined;
330
+ };
331
+ attributes?: {
332
+ label?: string | undefined;
333
+ help?: string | undefined;
334
+ labelTranslationKey?: string | undefined;
335
+ } | undefined;
336
+ meta?: {
337
+ schemaVersion: "1.0";
338
+ } | undefined;
339
+ }>;
340
+ export type BooleanQuestionType = z.infer<typeof BooleanQuestionSchema>;
341
+ export type CurrencyQuestionType = z.infer<typeof CurrencyQuestionSchema>;
342
+ export type NumberQuestionType = z.infer<typeof NumberQuestionSchema>;
343
+ export type NumberRangeQuestionType = z.infer<typeof NumberRangeQuestionSchema>;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NumberRangeQuestionSchema = exports.NumberQuestionSchema = exports.CurrencyQuestionSchema = exports.BooleanQuestionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const question_1 = require("./question");
6
+ const BaseAttributes = question_1.QuestionSchema.shape.attributes;
7
+ const NumberAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
8
+ max: zod_1.z.number().optional(), // The highest value allowed (default no max)
9
+ min: zod_1.z.number().optional(), // The lowest amount allowed (default 0)
10
+ step: zod_1.z.number().optional() // The amount to increment. To allow decimals, use 0.01 (default 1)
11
+ }));
12
+ exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
13
+ type: zod_1.z.literal('boolean'),
14
+ attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
15
+ checked: zod_1.z.boolean().optional(), // Whether it is checked by default
16
+ })).optional(),
17
+ }));
18
+ exports.CurrencyQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
19
+ type: zod_1.z.literal('currency'),
20
+ attributes: NumberAttributesSchema.merge(zod_1.z.object({
21
+ denomination: zod_1.z.string().optional(), // The currency type (default is "USD")
22
+ })).optional(),
23
+ }));
24
+ exports.NumberQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
25
+ type: zod_1.z.literal('number'),
26
+ attributes: NumberAttributesSchema.optional(),
27
+ }));
28
+ exports.NumberRangeQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
29
+ type: zod_1.z.literal('numberRange'),
30
+ columns: zod_1.z.object({
31
+ start: NumberAttributesSchema.optional(),
32
+ end: NumberAttributesSchema.optional()
33
+ })
34
+ }));