@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
@@ -2,27 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TableQuestionSchema = exports.TableColumn = exports.AnyTableColumnQuestionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const primitiveQuestions_1 = require("./primitiveQuestions");
5
+ const numberQuestions_1 = require("./numberQuestions");
6
+ const textQuestions_1 = require("./textQuestions");
6
7
  const dateQuestions_1 = require("./dateQuestions");
7
8
  const optionBasedQuestions_1 = require("./optionBasedQuestions");
8
9
  const graphQLQuestions_1 = require("./graphQLQuestions");
9
10
  const question_1 = require("./question");
11
+ const BaseAttributes = question_1.QuestionSchema.shape.attributes;
10
12
  // Union types for all questions and answers (tables cannot be nested so no TableQuestion here!)
11
13
  exports.AnyTableColumnQuestionSchema = zod_1.z.discriminatedUnion('type', [
12
- primitiveQuestions_1.BooleanQuestionSchema,
14
+ optionBasedQuestions_1.BooleanQuestionSchema,
13
15
  optionBasedQuestions_1.CheckboxesQuestionSchema,
14
- primitiveQuestions_1.CurrencyQuestionSchema,
16
+ numberQuestions_1.CurrencyQuestionSchema,
15
17
  dateQuestions_1.DateQuestionSchema,
16
18
  dateQuestions_1.DateRangeQuestionSchema,
17
- primitiveQuestions_1.EmailQuestionSchema,
19
+ textQuestions_1.EmailQuestionSchema,
18
20
  graphQLQuestions_1.FilteredSearchQuestionSchema,
19
- primitiveQuestions_1.NumberQuestionSchema,
21
+ numberQuestions_1.NumberQuestionSchema,
20
22
  optionBasedQuestions_1.RadioButtonsQuestionSchema,
21
23
  optionBasedQuestions_1.SelectBoxQuestionSchema,
22
- primitiveQuestions_1.TextAreaQuestionSchema,
23
- primitiveQuestions_1.TextQuestionSchema,
24
+ textQuestions_1.TextAreaQuestionSchema,
25
+ textQuestions_1.TextQuestionSchema,
24
26
  graphQLQuestions_1.TypeaheadSearchQuestionSchema,
25
- primitiveQuestions_1.URLQuestionSchema
27
+ textQuestions_1.URLQuestionSchema
26
28
  ]);
27
29
  exports.TableColumn = zod_1.z.object({
28
30
  heading: zod_1.z.string().optional(), // The heading of the column
@@ -32,11 +34,11 @@ exports.TableColumn = zod_1.z.object({
32
34
  exports.TableQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
33
35
  type: zod_1.z.literal('table'), // The type of question
34
36
  columns: zod_1.z.array(exports.TableColumn), // The columns of the table
35
- attributes: zod_1.z.object({
37
+ attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
36
38
  canAddRows: zod_1.z.boolean().optional(), // Whether to allow adding rows (default is true)
37
39
  canRemoveRows: zod_1.z.boolean().optional(), // Whether to allow removing rows (default is true)
38
40
  initialRows: zod_1.z.number().optional(), // The initial number of rows (default is 1)
39
41
  maxRows: zod_1.z.number().optional(), // The maximum number of rows (no default)
40
42
  minRows: zod_1.z.number().optional() // The minimum number of rows (no default)
41
- }).optional(),
43
+ })).optional(),
42
44
  }));
@@ -0,0 +1,261 @@
1
+ import { z } from "zod";
2
+ export declare const EmailQuestionSchema: 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<"email">;
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
+ maxLength: z.ZodOptional<z.ZodNumber>;
18
+ minLength: z.ZodOptional<z.ZodNumber>;
19
+ pattern: z.ZodOptional<z.ZodString>;
20
+ } & {
21
+ multiple: z.ZodOptional<z.ZodBoolean>;
22
+ }, "strip", z.ZodTypeAny, {
23
+ label?: string | undefined;
24
+ help?: string | undefined;
25
+ labelTranslationKey?: string | undefined;
26
+ maxLength?: number | undefined;
27
+ minLength?: number | undefined;
28
+ pattern?: string | undefined;
29
+ multiple?: boolean | undefined;
30
+ }, {
31
+ label?: string | undefined;
32
+ help?: string | undefined;
33
+ labelTranslationKey?: string | undefined;
34
+ maxLength?: number | undefined;
35
+ minLength?: number | undefined;
36
+ pattern?: string | undefined;
37
+ multiple?: boolean | undefined;
38
+ }>>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ type: "email";
41
+ attributes?: {
42
+ label?: string | undefined;
43
+ help?: string | undefined;
44
+ labelTranslationKey?: string | undefined;
45
+ maxLength?: number | undefined;
46
+ minLength?: number | undefined;
47
+ pattern?: string | undefined;
48
+ multiple?: boolean | undefined;
49
+ } | undefined;
50
+ meta?: {
51
+ schemaVersion: "1.0";
52
+ } | undefined;
53
+ }, {
54
+ type: "email";
55
+ attributes?: {
56
+ label?: string | undefined;
57
+ help?: string | undefined;
58
+ labelTranslationKey?: string | undefined;
59
+ maxLength?: number | undefined;
60
+ minLength?: number | undefined;
61
+ pattern?: string | undefined;
62
+ multiple?: boolean | undefined;
63
+ } | undefined;
64
+ meta?: {
65
+ schemaVersion: "1.0";
66
+ } | undefined;
67
+ }>;
68
+ export declare const TextAreaQuestionSchema: z.ZodObject<{} & {
69
+ type: z.ZodLiteral<"textArea">;
70
+ attributes: z.ZodOptional<z.ZodObject<{
71
+ label: z.ZodOptional<z.ZodString>;
72
+ help: z.ZodOptional<z.ZodString>;
73
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
74
+ } & {
75
+ cols: z.ZodOptional<z.ZodNumber>;
76
+ maxLength: z.ZodOptional<z.ZodNumber>;
77
+ minLength: z.ZodOptional<z.ZodNumber>;
78
+ rows: z.ZodOptional<z.ZodNumber>;
79
+ }, "strip", z.ZodTypeAny, {
80
+ label?: string | undefined;
81
+ help?: string | undefined;
82
+ labelTranslationKey?: string | undefined;
83
+ maxLength?: number | undefined;
84
+ minLength?: number | undefined;
85
+ cols?: number | undefined;
86
+ rows?: number | undefined;
87
+ }, {
88
+ label?: string | undefined;
89
+ help?: string | undefined;
90
+ labelTranslationKey?: string | undefined;
91
+ maxLength?: number | undefined;
92
+ minLength?: number | undefined;
93
+ cols?: number | undefined;
94
+ rows?: number | undefined;
95
+ }>>;
96
+ meta: z.ZodObject<{
97
+ schemaVersion: z.ZodLiteral<"1.0">;
98
+ } & {
99
+ asRichText: z.ZodOptional<z.ZodBoolean>;
100
+ }, "strip", z.ZodTypeAny, {
101
+ schemaVersion: "1.0";
102
+ asRichText?: boolean | undefined;
103
+ }, {
104
+ schemaVersion: "1.0";
105
+ asRichText?: boolean | undefined;
106
+ }>;
107
+ }, "strip", z.ZodTypeAny, {
108
+ type: "textArea";
109
+ meta: {
110
+ schemaVersion: "1.0";
111
+ asRichText?: boolean | undefined;
112
+ };
113
+ attributes?: {
114
+ label?: string | undefined;
115
+ help?: string | undefined;
116
+ labelTranslationKey?: string | undefined;
117
+ maxLength?: number | undefined;
118
+ minLength?: number | undefined;
119
+ cols?: number | undefined;
120
+ rows?: number | undefined;
121
+ } | undefined;
122
+ }, {
123
+ type: "textArea";
124
+ meta: {
125
+ schemaVersion: "1.0";
126
+ asRichText?: boolean | undefined;
127
+ };
128
+ attributes?: {
129
+ label?: string | undefined;
130
+ help?: string | undefined;
131
+ labelTranslationKey?: string | undefined;
132
+ maxLength?: number | undefined;
133
+ minLength?: number | undefined;
134
+ cols?: number | undefined;
135
+ rows?: number | undefined;
136
+ } | undefined;
137
+ }>;
138
+ export declare const TextQuestionSchema: z.ZodObject<{
139
+ meta: z.ZodOptional<z.ZodObject<{
140
+ schemaVersion: z.ZodLiteral<"1.0">;
141
+ }, "strip", z.ZodTypeAny, {
142
+ schemaVersion: "1.0";
143
+ }, {
144
+ schemaVersion: "1.0";
145
+ }>>;
146
+ } & {
147
+ type: z.ZodLiteral<"text">;
148
+ attributes: z.ZodOptional<z.ZodObject<{
149
+ label: z.ZodOptional<z.ZodString>;
150
+ help: z.ZodOptional<z.ZodString>;
151
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
152
+ } & {
153
+ maxLength: z.ZodOptional<z.ZodNumber>;
154
+ minLength: z.ZodOptional<z.ZodNumber>;
155
+ pattern: z.ZodOptional<z.ZodString>;
156
+ }, "strip", z.ZodTypeAny, {
157
+ label?: string | undefined;
158
+ help?: string | undefined;
159
+ labelTranslationKey?: string | undefined;
160
+ maxLength?: number | undefined;
161
+ minLength?: number | undefined;
162
+ pattern?: string | undefined;
163
+ }, {
164
+ label?: string | undefined;
165
+ help?: string | undefined;
166
+ labelTranslationKey?: string | undefined;
167
+ maxLength?: number | undefined;
168
+ minLength?: number | undefined;
169
+ pattern?: string | undefined;
170
+ }>>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ type: "text";
173
+ attributes?: {
174
+ label?: string | undefined;
175
+ help?: string | undefined;
176
+ labelTranslationKey?: string | undefined;
177
+ maxLength?: number | undefined;
178
+ minLength?: number | undefined;
179
+ pattern?: string | undefined;
180
+ } | undefined;
181
+ meta?: {
182
+ schemaVersion: "1.0";
183
+ } | undefined;
184
+ }, {
185
+ type: "text";
186
+ attributes?: {
187
+ label?: string | undefined;
188
+ help?: string | undefined;
189
+ labelTranslationKey?: string | undefined;
190
+ maxLength?: number | undefined;
191
+ minLength?: number | undefined;
192
+ pattern?: string | undefined;
193
+ } | undefined;
194
+ meta?: {
195
+ schemaVersion: "1.0";
196
+ } | undefined;
197
+ }>;
198
+ export declare const URLQuestionSchema: z.ZodObject<{
199
+ meta: z.ZodOptional<z.ZodObject<{
200
+ schemaVersion: z.ZodLiteral<"1.0">;
201
+ }, "strip", z.ZodTypeAny, {
202
+ schemaVersion: "1.0";
203
+ }, {
204
+ schemaVersion: "1.0";
205
+ }>>;
206
+ } & {
207
+ type: z.ZodLiteral<"url">;
208
+ attributes: z.ZodOptional<z.ZodObject<{
209
+ label: z.ZodOptional<z.ZodString>;
210
+ help: z.ZodOptional<z.ZodString>;
211
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
212
+ } & {
213
+ maxLength: z.ZodOptional<z.ZodNumber>;
214
+ minLength: z.ZodOptional<z.ZodNumber>;
215
+ pattern: z.ZodOptional<z.ZodString>;
216
+ }, "strip", z.ZodTypeAny, {
217
+ label?: string | undefined;
218
+ help?: string | undefined;
219
+ labelTranslationKey?: string | undefined;
220
+ maxLength?: number | undefined;
221
+ minLength?: number | undefined;
222
+ pattern?: string | undefined;
223
+ }, {
224
+ label?: string | undefined;
225
+ help?: string | undefined;
226
+ labelTranslationKey?: string | undefined;
227
+ maxLength?: number | undefined;
228
+ minLength?: number | undefined;
229
+ pattern?: string | undefined;
230
+ }>>;
231
+ }, "strip", z.ZodTypeAny, {
232
+ type: "url";
233
+ attributes?: {
234
+ label?: string | undefined;
235
+ help?: string | undefined;
236
+ labelTranslationKey?: string | undefined;
237
+ maxLength?: number | undefined;
238
+ minLength?: number | undefined;
239
+ pattern?: string | undefined;
240
+ } | undefined;
241
+ meta?: {
242
+ schemaVersion: "1.0";
243
+ } | undefined;
244
+ }, {
245
+ type: "url";
246
+ attributes?: {
247
+ label?: string | undefined;
248
+ help?: string | undefined;
249
+ labelTranslationKey?: string | undefined;
250
+ maxLength?: number | undefined;
251
+ minLength?: number | undefined;
252
+ pattern?: string | undefined;
253
+ } | undefined;
254
+ meta?: {
255
+ schemaVersion: "1.0";
256
+ } | undefined;
257
+ }>;
258
+ export type EmailQuestionType = z.infer<typeof EmailQuestionSchema>;
259
+ export type TextAreaQuestionType = z.infer<typeof TextAreaQuestionSchema>;
260
+ export type TextQuestionType = z.infer<typeof TextQuestionSchema>;
261
+ export type URLQuestionType = z.infer<typeof URLQuestionSchema>;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.URLQuestionSchema = exports.TextQuestionSchema = exports.TextAreaQuestionSchema = exports.EmailQuestionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const question_1 = require("./question");
6
+ const BaseMeta = question_1.QuestionSchema.shape.meta;
7
+ const BaseAttributes = question_1.QuestionSchema.shape.attributes;
8
+ const TextAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
9
+ maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
10
+ minLength: zod_1.z.number().optional(), // The minimum length of the text (no default)
11
+ pattern: zod_1.z.string().optional() // The regex pattern to match (no default)
12
+ }));
13
+ // Email question and answer
14
+ exports.EmailQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
15
+ type: zod_1.z.literal('email'), // The type of question
16
+ attributes: TextAttributesSchema.merge(zod_1.z.object({
17
+ multiple: zod_1.z.boolean().optional(), // Allow multiple emails (default is false; comma separated)
18
+ })).optional(),
19
+ }));
20
+ // Text area question and answer
21
+ exports.TextAreaQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
22
+ type: zod_1.z.literal('textArea'), // The type of question
23
+ attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
24
+ cols: zod_1.z.number().optional(), // The number of columns (default is 20)
25
+ maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
26
+ minLength: zod_1.z.number().optional(), // The minimum length of the text (no default)
27
+ rows: zod_1.z.number().optional() // The number of rows (default is 2)
28
+ })).optional(),
29
+ meta: BaseMeta.unwrap().extend({
30
+ asRichText: zod_1.z.boolean().optional() // Whether to use rich text (default is false)
31
+ })
32
+ }));
33
+ // Text question and answer
34
+ exports.TextQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
35
+ type: zod_1.z.literal('text'), // The type of question
36
+ attributes: TextAttributesSchema.optional(),
37
+ }));
38
+ // URL question and answer
39
+ exports.URLQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
40
+ type: zod_1.z.literal('url'), // The type of question
41
+ attributes: TextAttributesSchema.optional(),
42
+ }));