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