@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
@@ -1,281 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const primitiveQuestions_1 = require("../primitiveQuestions");
4
- describe("Primitive Questions Zod Schemas", () => {
5
- it('optional fields should not throw an error if the value is undefined', () => {
6
- const validBooleanQuestion = {
7
- type: "boolean",
8
- meta: {
9
- schemaVersion: "1.0",
10
- },
11
- attributes: {
12
- checked: undefined, // Valid value
13
- },
14
- };
15
- expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
16
- });
17
- it('optional fields should throw an error if the value is null', () => {
18
- const invalidBooleanQuestion = {
19
- type: "boolean",
20
- meta: {
21
- schemaVersion: "1.0",
22
- },
23
- attributes: {
24
- checked: null, // Invalid value
25
- },
26
- };
27
- expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
28
- });
29
- it("should validate a valid BooleanQuestion", () => {
30
- const validBooleanQuestion = {
31
- type: "boolean",
32
- meta: {
33
- schemaVersion: "1.0",
34
- },
35
- attributes: {
36
- checked: true,
37
- },
38
- };
39
- expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
40
- });
41
- it("should invalidate an invalid BooleanQuestion", () => {
42
- const invalidBooleanQuestion = {
43
- type: "boolean",
44
- meta: {
45
- schemaVersion: "1.0",
46
- },
47
- attributes: {
48
- checked: "true", // Invalid type
49
- },
50
- };
51
- expect(() => primitiveQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
52
- });
53
- it("should validate a valid CurrencyQuestion", () => {
54
- const validCurrencyQuestion = {
55
- type: "currency",
56
- meta: {
57
- schemaVersion: "1.0",
58
- denomination: "USD",
59
- },
60
- attributes: {
61
- max: 100,
62
- min: 1,
63
- step: 0.01,
64
- },
65
- };
66
- expect(() => primitiveQuestions_1.CurrencyQuestionSchema.parse(validCurrencyQuestion)).not.toThrow();
67
- });
68
- it("should invalidate an invalid CurrencyQuestion", () => {
69
- const invalidCurrencyQuestion = {
70
- type: "currency",
71
- meta: {
72
- schemaVersion: "1.0",
73
- },
74
- attributes: {
75
- max: "100", // Invalid type
76
- },
77
- };
78
- expect(() => primitiveQuestions_1.CurrencyQuestionSchema.parse(invalidCurrencyQuestion)).toThrow();
79
- });
80
- it("should validate a valid EmailQuestion", () => {
81
- const validEmailQuestion = {
82
- type: "email",
83
- meta: {
84
- schemaVersion: "1.0",
85
- },
86
- attributes: {
87
- maxLength: 50,
88
- minLength: 5,
89
- multiple: true,
90
- pattern: "^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$",
91
- },
92
- };
93
- expect(() => primitiveQuestions_1.EmailQuestionSchema.parse(validEmailQuestion)).not.toThrow();
94
- });
95
- it("should invalidate an invalid EmailQuestion", () => {
96
- const invalidEmailQuestion = {
97
- type: "email",
98
- meta: {
99
- schemaVersion: "1.0",
100
- },
101
- attributes: {
102
- maxLength: "50", // Invalid type
103
- },
104
- };
105
- expect(() => primitiveQuestions_1.EmailQuestionSchema.parse(invalidEmailQuestion)).toThrow();
106
- });
107
- it("should validate a valid NumberQuestion", () => {
108
- const validNumberQuestion = {
109
- type: "number",
110
- meta: {
111
- schemaVersion: "1.0",
112
- },
113
- attributes: {
114
- max: 100,
115
- min: 0,
116
- step: 1,
117
- },
118
- };
119
- expect(() => primitiveQuestions_1.NumberQuestionSchema.parse(validNumberQuestion)).not.toThrow();
120
- });
121
- it("should invalidate an invalid NumberQuestion", () => {
122
- const invalidNumberQuestion = {
123
- type: "number",
124
- meta: {
125
- schemaVersion: "1.0",
126
- },
127
- attributes: {
128
- step: "1", // Invalid type
129
- },
130
- };
131
- expect(() => primitiveQuestions_1.NumberQuestionSchema.parse(invalidNumberQuestion)).toThrow();
132
- });
133
- it("should validate a valid NumberRangeQuestion", () => {
134
- const validNumberRangeQuestion = {
135
- type: "numberRange",
136
- meta: {
137
- schemaVersion: "1.0",
138
- },
139
- columns: {
140
- start: {
141
- type: "number",
142
- attributes: {
143
- label: "Start",
144
- min: 0,
145
- max: 50,
146
- step: 1,
147
- },
148
- meta: {
149
- schemaVersion: "1.0",
150
- },
151
- },
152
- end: {
153
- type: "number",
154
- attributes: {
155
- label: "End",
156
- min: 50,
157
- max: 100,
158
- step: 1,
159
- },
160
- meta: {
161
- schemaVersion: "1.0",
162
- },
163
- },
164
- },
165
- };
166
- expect(() => primitiveQuestions_1.NumberRangeQuestionSchema.parse(validNumberRangeQuestion)).not.toThrow();
167
- });
168
- it("should invalidate an invalid NumberRangeQuestion", () => {
169
- const invalidNumberRangeQuestion = {
170
- type: "numberRange",
171
- meta: {
172
- schemaVersion: "1.0",
173
- },
174
- columns: {
175
- start: {
176
- type: "number",
177
- attributes: {
178
- min: 0,
179
- max: 50,
180
- },
181
- meta: {
182
- schemaVersion: "1.0",
183
- },
184
- },
185
- end: {
186
- type: "number",
187
- attributes: {
188
- label: "End",
189
- min: 50,
190
- max: 100,
191
- step: 1,
192
- },
193
- meta: {
194
- schemaVersion: "1.0",
195
- },
196
- },
197
- },
198
- };
199
- expect(() => primitiveQuestions_1.NumberRangeQuestionSchema.parse(invalidNumberRangeQuestion)).toThrow();
200
- });
201
- it("should validate a valid TextAreaQuestion", () => {
202
- const validTextAreaQuestion = {
203
- type: "textArea",
204
- meta: {
205
- schemaVersion: "1.0",
206
- asRichText: true,
207
- },
208
- attributes: {
209
- cols: 30,
210
- rows: 5,
211
- maxLength: 500,
212
- minLength: 10,
213
- },
214
- };
215
- expect(() => primitiveQuestions_1.TextAreaQuestionSchema.parse(validTextAreaQuestion)).not.toThrow();
216
- });
217
- it("should invalidate an invalid TextAreaQuestion", () => {
218
- const invalidTextAreaQuestion = {
219
- type: "textArea",
220
- meta: {
221
- schemaVersion: "1.0",
222
- },
223
- attributes: {
224
- cols: "30", // Invalid type
225
- },
226
- };
227
- expect(() => primitiveQuestions_1.TextAreaQuestionSchema.parse(invalidTextAreaQuestion)).toThrow();
228
- });
229
- it("should validate a valid TextQuestion", () => {
230
- const validTextQuestion = {
231
- type: "text",
232
- meta: {
233
- schemaVersion: "1.0",
234
- },
235
- attributes: {
236
- maxLength: 100,
237
- minLength: 1,
238
- pattern: "^[a-zA-Z]+$",
239
- },
240
- };
241
- expect(() => primitiveQuestions_1.TextQuestionSchema.parse(validTextQuestion)).not.toThrow();
242
- });
243
- it("should invalidate an invalid TextQuestion", () => {
244
- const invalidTextQuestion = {
245
- type: "text",
246
- meta: {
247
- schemaVersion: "1.0",
248
- },
249
- attributes: {
250
- maxLength: "100", // Invalid type
251
- },
252
- };
253
- expect(() => primitiveQuestions_1.TextQuestionSchema.parse(invalidTextQuestion)).toThrow();
254
- });
255
- it("should validate a valid URLQuestion", () => {
256
- const validURLQuestion = {
257
- type: "url",
258
- meta: {
259
- schemaVersion: "1.0",
260
- },
261
- attributes: {
262
- maxLength: 200,
263
- minLength: 10,
264
- pattern: "https?://.+",
265
- },
266
- };
267
- expect(() => primitiveQuestions_1.URLQuestionSchema.parse(validURLQuestion)).not.toThrow();
268
- });
269
- it("should invalidate an invalid URLQuestion", () => {
270
- const invalidURLQuestion = {
271
- type: "url",
272
- meta: {
273
- schemaVersion: "1.0",
274
- },
275
- attributes: {
276
- maxLength: "200", // Invalid type
277
- },
278
- };
279
- expect(() => primitiveQuestions_1.URLQuestionSchema.parse(invalidURLQuestion)).toThrow();
280
- });
281
- });