@dmptool/types 1.2.6 → 2.0.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 (97) hide show
  1. package/README.md +1 -1
  2. package/dist/answers/__tests__/defaults.spec.js +216 -0
  3. package/dist/answers/answer.d.ts +29 -14
  4. package/dist/answers/answer.js +11 -5
  5. package/dist/answers/dateAnswers.d.ts +20 -47
  6. package/dist/answers/dateAnswers.js +20 -10
  7. package/dist/answers/graphQLAnswers.d.ts +48 -120
  8. package/dist/answers/graphQLAnswers.js +46 -21
  9. package/dist/answers/index.d.ts +155 -1439
  10. package/dist/answers/index.js +26 -1
  11. package/dist/answers/numberAnswers.d.ts +38 -92
  12. package/dist/answers/numberAnswers.js +38 -19
  13. package/dist/answers/optionBasedAnswers.d.ts +42 -87
  14. package/dist/answers/optionBasedAnswers.js +37 -21
  15. package/dist/answers/tableAnswers.d.ts +348 -3032
  16. package/dist/answers/tableAnswers.js +25 -61
  17. package/dist/answers/textAnswers.d.ts +32 -68
  18. package/dist/answers/textAnswers.js +30 -17
  19. package/dist/questions/__tests__/dateQuestions.spec.js +3 -0
  20. package/dist/questions/__tests__/defaults.spec.d.ts +1 -0
  21. package/dist/questions/__tests__/defaults.spec.js +668 -0
  22. package/dist/questions/__tests__/optionBasedQuestions.spec.js +3 -2
  23. package/dist/questions/__tests__/tableQuestion.spec.js +22 -23
  24. package/dist/questions/__tests__/textQuestions.spec.js +32 -0
  25. package/dist/questions/dateQuestions.d.ts +45 -191
  26. package/dist/questions/dateQuestions.js +26 -23
  27. package/dist/questions/graphQLQuestions.d.ts +262 -556
  28. package/dist/questions/graphQLQuestions.js +225 -223
  29. package/dist/questions/index.d.ts +689 -7440
  30. package/dist/questions/index.js +26 -1
  31. package/dist/questions/numberQuestions.d.ts +85 -331
  32. package/dist/questions/numberQuestions.js +50 -36
  33. package/dist/questions/optionBasedQuestions.d.ts +83 -290
  34. package/dist/questions/optionBasedQuestions.js +58 -41
  35. package/dist/questions/question.d.ts +72 -35
  36. package/dist/questions/question.js +14 -5
  37. package/dist/questions/tableQuestions.d.ts +1977 -9646
  38. package/dist/questions/tableQuestions.js +184 -192
  39. package/dist/questions/textQuestions.d.ts +70 -226
  40. package/dist/questions/textQuestions.js +31 -31
  41. package/package.json +4 -5
  42. package/dist/answers/__tests__/usage.spec.js +0 -178
  43. package/dist/questions/__tests__/usage.spec.d.ts +0 -8
  44. package/dist/questions/__tests__/usage.spec.js +0 -473
  45. package/dist/schemas/affiliationSearchAnswer.schema.json +0 -45
  46. package/dist/schemas/affiliationSearchQuestion.schema.json +0 -140
  47. package/dist/schemas/anyAnswer.schema.json +0 -605
  48. package/dist/schemas/anyQuestion.schema.json +0 -2455
  49. package/dist/schemas/anyTableColumnAnswer.schema.json +0 -466
  50. package/dist/schemas/anyTableColumnQuestion.schema.json +0 -1092
  51. package/dist/schemas/booleanAnswer.schema.json +0 -34
  52. package/dist/schemas/booleanQuestion.schema.json +0 -56
  53. package/dist/schemas/checkboxesAnswer.schema.json +0 -39
  54. package/dist/schemas/checkboxesQuestion.schema.json +0 -76
  55. package/dist/schemas/currencyAnswer.schema.json +0 -34
  56. package/dist/schemas/currencyQuestion.schema.json +0 -67
  57. package/dist/schemas/dateAnswer.schema.json +0 -34
  58. package/dist/schemas/datePickerAnswer.schema.json +0 -37
  59. package/dist/schemas/datePickerQuestion.schema.json +0 -52
  60. package/dist/schemas/dateQuestion.schema.json +0 -62
  61. package/dist/schemas/dateRangeAnswer.schema.json +0 -45
  62. package/dist/schemas/dateRangeQuestion.schema.json +0 -112
  63. package/dist/schemas/emailAnswer.schema.json +0 -34
  64. package/dist/schemas/emailQuestion.schema.json +0 -66
  65. package/dist/schemas/filteredSearchAnswer.schema.json +0 -40
  66. package/dist/schemas/filteredSearchQuestion.schema.json +0 -130
  67. package/dist/schemas/licenseSearchAnswer.schema.json +0 -49
  68. package/dist/schemas/licenseSearchQuestion.schema.json +0 -164
  69. package/dist/schemas/metadataStandardSearchAnswer.schema.json +0 -49
  70. package/dist/schemas/metadataStandardSearchQuestion.schema.json +0 -174
  71. package/dist/schemas/multiselectBoxAnswer.schema.json +0 -39
  72. package/dist/schemas/multiselectBoxQuestion.schema.json +0 -85
  73. package/dist/schemas/numberAnswer.schema.json +0 -34
  74. package/dist/schemas/numberQuestion.schema.json +0 -63
  75. package/dist/schemas/numberRangeAnswer.schema.json +0 -45
  76. package/dist/schemas/numberRangeQuestion.schema.json +0 -94
  77. package/dist/schemas/numberWithContextAnswer.schema.json +0 -45
  78. package/dist/schemas/numberWithContextQuestion.schema.json +0 -84
  79. package/dist/schemas/radioButtonsAnswer.schema.json +0 -34
  80. package/dist/schemas/radioButtonsQuestion.schema.json +0 -76
  81. package/dist/schemas/repositorySearchAnswer.schema.json +0 -49
  82. package/dist/schemas/repositorySearchQuestion.schema.json +0 -180
  83. package/dist/schemas/researchOutputTableAnswer.schema.json +0 -519
  84. package/dist/schemas/researchOutputTableQuestion.schema.json +0 -1183
  85. package/dist/schemas/selectBoxAnswer.schema.json +0 -34
  86. package/dist/schemas/selectBoxQuestion.schema.json +0 -85
  87. package/dist/schemas/tableAnswer.schema.json +0 -519
  88. package/dist/schemas/tableQuestion.schema.json +0 -1183
  89. package/dist/schemas/textAnswer.schema.json +0 -34
  90. package/dist/schemas/textAreaAnswer.schema.json +0 -34
  91. package/dist/schemas/textAreaQuestion.schema.json +0 -70
  92. package/dist/schemas/textQuestion.schema.json +0 -62
  93. package/dist/schemas/typeaheadSearchAnswer.schema.json +0 -37
  94. package/dist/schemas/typeaheadSearchQuestion.schema.json +0 -120
  95. package/dist/schemas/urlAnswer.schema.json +0 -34
  96. package/dist/schemas/urlQuestion.schema.json +0 -62
  97. /package/dist/answers/__tests__/{usage.spec.d.ts → defaults.spec.d.ts} +0 -0
@@ -1,301 +1,145 @@
1
1
  import { z } from "zod";
2
2
  export declare const EmailQuestionSchema: z.ZodObject<{
3
- meta: z.ZodDefault<z.ZodObject<{
4
- schemaVersion: z.ZodDefault<z.ZodString>;
5
- title: z.ZodOptional<z.ZodString>;
6
- usageDescription: z.ZodOptional<z.ZodString>;
7
- }, "strip", z.ZodTypeAny, {
8
- schemaVersion: string;
9
- title?: string | undefined;
10
- usageDescription?: string | undefined;
11
- }, {
12
- schemaVersion?: string | undefined;
13
- title?: string | undefined;
14
- usageDescription?: string | undefined;
15
- }>>;
16
- } & {
17
3
  type: z.ZodLiteral<"email">;
18
- attributes: z.ZodDefault<z.ZodObject<{
19
- label: z.ZodOptional<z.ZodString>;
20
- help: z.ZodOptional<z.ZodString>;
21
- labelTranslationKey: z.ZodOptional<z.ZodString>;
22
- } & {
4
+ attributes: z.ZodObject<{
5
+ multiple: z.ZodDefault<z.ZodBoolean>;
23
6
  maxLength: z.ZodDefault<z.ZodNumber>;
24
7
  minLength: z.ZodOptional<z.ZodNumber>;
25
8
  pattern: z.ZodOptional<z.ZodString>;
26
- } & {
27
- multiple: z.ZodDefault<z.ZodBoolean>;
28
- }, "strip", z.ZodTypeAny, {
29
- maxLength: number;
30
- multiple: boolean;
31
- label?: string | undefined;
32
- help?: string | undefined;
33
- labelTranslationKey?: string | undefined;
34
- minLength?: number | undefined;
35
- pattern?: string | undefined;
36
- }, {
37
- label?: string | undefined;
38
- help?: string | undefined;
39
- labelTranslationKey?: string | undefined;
40
- maxLength?: number | undefined;
41
- minLength?: number | undefined;
42
- pattern?: string | undefined;
43
- multiple?: boolean | undefined;
44
- }>>;
45
- }, "strip", z.ZodTypeAny, {
9
+ label: z.ZodOptional<z.ZodString>;
10
+ help: z.ZodOptional<z.ZodString>;
11
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ meta: z.ZodObject<{
14
+ schemaVersion: z.ZodDefault<z.ZodString>;
15
+ title: z.ZodOptional<z.ZodString>;
16
+ usageDescription: z.ZodOptional<z.ZodString>;
17
+ }, z.core.$strip>;
18
+ }, z.core.$strip>;
19
+ export declare const DefaultEmailQuestion: {
46
20
  type: "email";
47
21
  attributes: {
48
- maxLength: number;
49
22
  multiple: boolean;
23
+ maxLength: number;
24
+ minLength?: number | undefined;
25
+ pattern?: string | undefined;
50
26
  label?: string | undefined;
51
27
  help?: string | undefined;
52
28
  labelTranslationKey?: string | undefined;
53
- minLength?: number | undefined;
54
- pattern?: string | undefined;
55
29
  };
56
30
  meta: {
57
31
  schemaVersion: string;
58
32
  title?: string | undefined;
59
33
  usageDescription?: string | undefined;
60
34
  };
61
- }, {
62
- type: "email";
63
- attributes?: {
64
- label?: string | undefined;
65
- help?: string | undefined;
66
- labelTranslationKey?: string | undefined;
67
- maxLength?: number | undefined;
68
- minLength?: number | undefined;
69
- pattern?: string | undefined;
70
- multiple?: boolean | undefined;
71
- } | undefined;
72
- meta?: {
73
- schemaVersion?: string | undefined;
74
- title?: string | undefined;
75
- usageDescription?: string | undefined;
76
- } | undefined;
77
- }>;
35
+ };
78
36
  export declare const TextAreaQuestionSchema: z.ZodObject<{
79
- meta: z.ZodDefault<z.ZodObject<{
80
- schemaVersion: z.ZodDefault<z.ZodString>;
81
- title: z.ZodOptional<z.ZodString>;
82
- usageDescription: z.ZodOptional<z.ZodString>;
83
- }, "strip", z.ZodTypeAny, {
84
- schemaVersion: string;
85
- title?: string | undefined;
86
- usageDescription?: string | undefined;
87
- }, {
88
- schemaVersion?: string | undefined;
89
- title?: string | undefined;
90
- usageDescription?: string | undefined;
91
- }>>;
92
- } & {
93
37
  type: z.ZodLiteral<"textArea">;
94
- attributes: z.ZodDefault<z.ZodObject<{
95
- label: z.ZodOptional<z.ZodString>;
96
- help: z.ZodOptional<z.ZodString>;
97
- labelTranslationKey: z.ZodOptional<z.ZodString>;
98
- } & {
38
+ attributes: z.ZodObject<{
99
39
  cols: z.ZodDefault<z.ZodNumber>;
100
- maxLength: z.ZodOptional<z.ZodNumber>;
101
- minLength: z.ZodOptional<z.ZodNumber>;
102
40
  rows: z.ZodDefault<z.ZodNumber>;
103
41
  asRichText: z.ZodDefault<z.ZodBoolean>;
104
- }, "strip", z.ZodTypeAny, {
105
- cols: number;
106
- rows: number;
107
- asRichText: boolean;
108
- label?: string | undefined;
109
- help?: string | undefined;
110
- labelTranslationKey?: string | undefined;
111
- maxLength?: number | undefined;
112
- minLength?: number | undefined;
113
- }, {
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
- asRichText?: boolean | undefined;
122
- }>>;
123
- }, "strip", z.ZodTypeAny, {
42
+ maxLength: z.ZodDefault<z.ZodNumber>;
43
+ minLength: z.ZodOptional<z.ZodNumber>;
44
+ pattern: z.ZodOptional<z.ZodString>;
45
+ label: z.ZodOptional<z.ZodString>;
46
+ help: z.ZodOptional<z.ZodString>;
47
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
48
+ }, z.core.$strip>;
49
+ meta: z.ZodObject<{
50
+ schemaVersion: z.ZodDefault<z.ZodString>;
51
+ title: z.ZodOptional<z.ZodString>;
52
+ usageDescription: z.ZodOptional<z.ZodString>;
53
+ }, z.core.$strip>;
54
+ }, z.core.$strip>;
55
+ export declare const DefaultTextAreaQuestion: {
124
56
  type: "textArea";
125
57
  attributes: {
126
58
  cols: number;
127
59
  rows: number;
128
60
  asRichText: boolean;
61
+ maxLength: number;
62
+ minLength?: number | undefined;
63
+ pattern?: string | undefined;
129
64
  label?: string | undefined;
130
65
  help?: string | undefined;
131
66
  labelTranslationKey?: string | undefined;
132
- maxLength?: number | undefined;
133
- minLength?: number | undefined;
134
67
  };
135
68
  meta: {
136
69
  schemaVersion: string;
137
70
  title?: string | undefined;
138
71
  usageDescription?: string | undefined;
139
72
  };
140
- }, {
141
- type: "textArea";
142
- attributes?: {
143
- label?: string | undefined;
144
- help?: string | undefined;
145
- labelTranslationKey?: string | undefined;
146
- maxLength?: number | undefined;
147
- minLength?: number | undefined;
148
- cols?: number | undefined;
149
- rows?: number | undefined;
150
- asRichText?: boolean | undefined;
151
- } | undefined;
152
- meta?: {
153
- schemaVersion?: string | undefined;
154
- title?: string | undefined;
155
- usageDescription?: string | undefined;
156
- } | undefined;
157
- }>;
73
+ };
158
74
  export declare const TextQuestionSchema: z.ZodObject<{
159
- meta: z.ZodDefault<z.ZodObject<{
160
- schemaVersion: z.ZodDefault<z.ZodString>;
161
- title: z.ZodOptional<z.ZodString>;
162
- usageDescription: z.ZodOptional<z.ZodString>;
163
- }, "strip", z.ZodTypeAny, {
164
- schemaVersion: string;
165
- title?: string | undefined;
166
- usageDescription?: string | undefined;
167
- }, {
168
- schemaVersion?: string | undefined;
169
- title?: string | undefined;
170
- usageDescription?: string | undefined;
171
- }>>;
172
- } & {
173
75
  type: z.ZodLiteral<"text">;
174
- attributes: z.ZodDefault<z.ZodObject<{
175
- label: z.ZodOptional<z.ZodString>;
176
- help: z.ZodOptional<z.ZodString>;
177
- labelTranslationKey: z.ZodOptional<z.ZodString>;
178
- } & {
76
+ attributes: z.ZodObject<{
179
77
  maxLength: z.ZodDefault<z.ZodNumber>;
180
78
  minLength: z.ZodOptional<z.ZodNumber>;
181
79
  pattern: z.ZodOptional<z.ZodString>;
182
- }, "strip", z.ZodTypeAny, {
183
- maxLength: number;
184
- label?: string | undefined;
185
- help?: string | undefined;
186
- labelTranslationKey?: string | undefined;
187
- minLength?: number | undefined;
188
- pattern?: string | undefined;
189
- }, {
190
- label?: string | undefined;
191
- help?: string | undefined;
192
- labelTranslationKey?: string | undefined;
193
- maxLength?: number | undefined;
194
- minLength?: number | undefined;
195
- pattern?: string | undefined;
196
- }>>;
197
- }, "strip", z.ZodTypeAny, {
80
+ label: z.ZodOptional<z.ZodString>;
81
+ help: z.ZodOptional<z.ZodString>;
82
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
83
+ }, z.core.$strip>;
84
+ meta: z.ZodObject<{
85
+ schemaVersion: z.ZodDefault<z.ZodString>;
86
+ title: z.ZodOptional<z.ZodString>;
87
+ usageDescription: z.ZodOptional<z.ZodString>;
88
+ }, z.core.$strip>;
89
+ }, z.core.$strip>;
90
+ export declare const DefaultTextQuestion: {
198
91
  type: "text";
199
92
  attributes: {
200
93
  maxLength: number;
94
+ minLength?: number | undefined;
95
+ pattern?: string | undefined;
201
96
  label?: string | undefined;
202
97
  help?: string | undefined;
203
98
  labelTranslationKey?: string | undefined;
204
- minLength?: number | undefined;
205
- pattern?: string | undefined;
206
99
  };
207
100
  meta: {
208
101
  schemaVersion: string;
209
102
  title?: string | undefined;
210
103
  usageDescription?: string | undefined;
211
104
  };
212
- }, {
213
- type: "text";
214
- attributes?: {
215
- label?: string | undefined;
216
- help?: string | undefined;
217
- labelTranslationKey?: string | undefined;
218
- maxLength?: number | undefined;
219
- minLength?: number | undefined;
220
- pattern?: string | undefined;
221
- } | undefined;
222
- meta?: {
223
- schemaVersion?: string | undefined;
224
- title?: string | undefined;
225
- usageDescription?: string | undefined;
226
- } | undefined;
227
- }>;
105
+ };
228
106
  export declare const URLQuestionSchema: z.ZodObject<{
229
- meta: z.ZodDefault<z.ZodObject<{
230
- schemaVersion: z.ZodDefault<z.ZodString>;
231
- title: z.ZodOptional<z.ZodString>;
232
- usageDescription: z.ZodOptional<z.ZodString>;
233
- }, "strip", z.ZodTypeAny, {
234
- schemaVersion: string;
235
- title?: string | undefined;
236
- usageDescription?: string | undefined;
237
- }, {
238
- schemaVersion?: string | undefined;
239
- title?: string | undefined;
240
- usageDescription?: string | undefined;
241
- }>>;
242
- } & {
243
107
  type: z.ZodLiteral<"url">;
244
- attributes: z.ZodDefault<z.ZodObject<{
245
- label: z.ZodOptional<z.ZodString>;
246
- help: z.ZodOptional<z.ZodString>;
247
- labelTranslationKey: z.ZodOptional<z.ZodString>;
248
- } & {
108
+ attributes: z.ZodObject<{
249
109
  maxLength: z.ZodDefault<z.ZodNumber>;
250
110
  minLength: z.ZodOptional<z.ZodNumber>;
251
111
  pattern: z.ZodOptional<z.ZodString>;
252
- }, "strip", z.ZodTypeAny, {
253
- maxLength: number;
254
- label?: string | undefined;
255
- help?: string | undefined;
256
- labelTranslationKey?: string | undefined;
257
- minLength?: number | undefined;
258
- pattern?: string | undefined;
259
- }, {
260
- label?: string | undefined;
261
- help?: string | undefined;
262
- labelTranslationKey?: string | undefined;
263
- maxLength?: number | undefined;
264
- minLength?: number | undefined;
265
- pattern?: string | undefined;
266
- }>>;
267
- }, "strip", z.ZodTypeAny, {
112
+ label: z.ZodOptional<z.ZodString>;
113
+ help: z.ZodOptional<z.ZodString>;
114
+ labelTranslationKey: z.ZodOptional<z.ZodString>;
115
+ }, z.core.$strip>;
116
+ meta: z.ZodObject<{
117
+ schemaVersion: z.ZodDefault<z.ZodString>;
118
+ title: z.ZodOptional<z.ZodString>;
119
+ usageDescription: z.ZodOptional<z.ZodString>;
120
+ }, z.core.$strip>;
121
+ }, z.core.$strip>;
122
+ export declare const DefaultURLQuestion: {
268
123
  type: "url";
269
124
  attributes: {
270
125
  maxLength: number;
126
+ minLength?: number | undefined;
127
+ pattern?: string | undefined;
271
128
  label?: string | undefined;
272
129
  help?: string | undefined;
273
130
  labelTranslationKey?: string | undefined;
274
- minLength?: number | undefined;
275
- pattern?: string | undefined;
276
131
  };
277
132
  meta: {
278
133
  schemaVersion: string;
279
134
  title?: string | undefined;
280
135
  usageDescription?: string | undefined;
281
136
  };
282
- }, {
283
- type: "url";
284
- attributes?: {
285
- label?: string | undefined;
286
- help?: string | undefined;
287
- labelTranslationKey?: string | undefined;
288
- maxLength?: number | undefined;
289
- minLength?: number | undefined;
290
- pattern?: string | undefined;
291
- } | undefined;
292
- meta?: {
293
- schemaVersion?: string | undefined;
294
- title?: string | undefined;
295
- usageDescription?: string | undefined;
296
- } | undefined;
297
- }>;
137
+ };
298
138
  export type EmailQuestionType = z.infer<typeof EmailQuestionSchema>;
299
139
  export type TextAreaQuestionType = z.infer<typeof TextAreaQuestionSchema>;
300
140
  export type TextQuestionType = z.infer<typeof TextQuestionSchema>;
301
141
  export type URLQuestionType = z.infer<typeof URLQuestionSchema>;
142
+ export declare const EmailQuestionJSONSchema: z.core.JSONSchema.JSONSchema;
143
+ export declare const TextAreaQuestionJSONSchema: z.core.JSONSchema.JSONSchema;
144
+ export declare const TextQuestionJSONSchema: z.core.JSONSchema.JSONSchema;
145
+ export declare const URLQuestionJSONSchema: z.core.JSONSchema.JSONSchema;
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.URLQuestionSchema = exports.TextQuestionSchema = exports.TextAreaQuestionSchema = exports.EmailQuestionSchema = void 0;
3
+ exports.URLQuestionJSONSchema = exports.TextQuestionJSONSchema = exports.TextAreaQuestionJSONSchema = exports.EmailQuestionJSONSchema = exports.DefaultURLQuestion = exports.URLQuestionSchema = exports.DefaultTextQuestion = exports.TextQuestionSchema = exports.DefaultTextAreaQuestion = exports.TextAreaQuestionSchema = exports.DefaultEmailQuestion = exports.EmailQuestionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const question_1 = require("./question");
6
- const BaseAttributes = question_1.QuestionSchema.shape.attributes;
7
- const TextAttributesSchema = BaseAttributes.merge(zod_1.z.object({
8
- maxLength: zod_1.z.number().default(255),
9
- minLength: zod_1.z.number().optional(),
10
- pattern: zod_1.z.string().optional()
11
- }));
6
+ const TextAttributesSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.BaseAttributesSchema.shape), { maxLength: zod_1.z.number().default(255), minLength: zod_1.z.number().optional(), pattern: zod_1.z.string().optional() }));
7
+ const DefaultTextAttributes = TextAttributesSchema.parse({});
12
8
  // Email question and answer
13
- exports.EmailQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
14
- type: zod_1.z.literal('email'),
15
- attributes: TextAttributesSchema.merge(zod_1.z.object({
16
- multiple: zod_1.z.boolean().default(false),
17
- })).default({})
18
- }));
9
+ exports.EmailQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('email'), attributes: zod_1.z.object(Object.assign(Object.assign({}, TextAttributesSchema.shape), { multiple: zod_1.z.boolean().default(false) })) }));
10
+ exports.DefaultEmailQuestion = exports.EmailQuestionSchema.parse({
11
+ type: 'email',
12
+ attributes: exports.EmailQuestionSchema.shape.attributes,
13
+ meta: question_1.DefaultMeta
14
+ });
19
15
  // Text area question and answer
20
- exports.TextAreaQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
21
- type: zod_1.z.literal('textArea'),
22
- attributes: BaseAttributes.merge(zod_1.z.object({
23
- cols: zod_1.z.number().default(20),
24
- maxLength: zod_1.z.number().optional(),
25
- minLength: zod_1.z.number().optional(),
26
- rows: zod_1.z.number().default(2),
27
- asRichText: zod_1.z.boolean().default(true),
28
- })).default({})
29
- }));
16
+ exports.TextAreaQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('textArea'), attributes: zod_1.z.object(Object.assign(Object.assign({}, TextAttributesSchema.shape), { cols: zod_1.z.number().default(20), rows: zod_1.z.number().default(2), asRichText: zod_1.z.boolean().default(true), maxLength: zod_1.z.number().default(10000) })) }));
17
+ exports.DefaultTextAreaQuestion = exports.TextAreaQuestionSchema.parse({
18
+ type: 'textArea',
19
+ attributes: exports.TextAreaQuestionSchema.shape.attributes,
20
+ meta: question_1.DefaultMeta
21
+ });
30
22
  // Text question and answer
31
- exports.TextQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
32
- type: zod_1.z.literal('text'),
33
- attributes: TextAttributesSchema.default({})
34
- }));
23
+ exports.TextQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('text'), attributes: TextAttributesSchema }));
24
+ exports.DefaultTextQuestion = exports.TextQuestionSchema.parse({
25
+ type: 'text',
26
+ attributes: DefaultTextAttributes,
27
+ meta: question_1.DefaultMeta
28
+ });
35
29
  // URL question and answer
36
- exports.URLQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
37
- type: zod_1.z.literal('url'),
38
- attributes: TextAttributesSchema.default({})
39
- }));
30
+ exports.URLQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('url'), attributes: TextAttributesSchema }));
31
+ exports.DefaultURLQuestion = exports.URLQuestionSchema.parse({
32
+ type: 'url',
33
+ attributes: DefaultTextAttributes,
34
+ meta: question_1.DefaultMeta
35
+ });
36
+ exports.EmailQuestionJSONSchema = zod_1.z.toJSONSchema(exports.EmailQuestionSchema);
37
+ exports.TextAreaQuestionJSONSchema = zod_1.z.toJSONSchema(exports.TextAreaQuestionSchema);
38
+ exports.TextQuestionJSONSchema = zod_1.z.toJSONSchema(exports.TextQuestionSchema);
39
+ exports.URLQuestionJSONSchema = zod_1.z.toJSONSchema(exports.URLQuestionSchema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dmptool/types",
3
- "version": "1.2.6",
3
+ "version": "2.0.0",
4
4
  "description": "TypeScript types for DMPTool",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "access": "public"
20
20
  },
21
21
  "scripts": {
22
- "build": "npm run clean && npm run generate && tsc && npm run copy:schemas",
22
+ "build": "npm run clean && tsc",
23
23
  "clean": "rm -rf dist",
24
24
  "copy:schemas": "node scripts/copySchemas.mjs",
25
25
  "generate": "ts-node scripts/generateSchemas.ts",
@@ -32,8 +32,7 @@
32
32
  "trivy-med": "./scripts/trivy-med.sh"
33
33
  },
34
34
  "dependencies": {
35
- "zod": "3.24.4",
36
- "zod-to-json-schema": "3.24.5"
35
+ "zod": "4.1.13"
37
36
  },
38
37
  "devDependencies": {
39
38
  "@eslint/js": "^9.26.0",
@@ -49,4 +48,4 @@
49
48
  "typescript": "^5.2.2",
50
49
  "typescript-eslint": "^8.32.1"
51
50
  }
52
- }
51
+ }
@@ -1,178 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const questions_1 = require("../../questions");
4
- const index_1 = require("../index");
5
- // Parse the Zod schema with no input to generate the default JSON schemas
6
- function defaultJSON(name) {
7
- if (name in index_1.AnswerSchemaMap) {
8
- const schema = index_1.AnswerSchemaMap[name];
9
- return schema.parse({ type: name });
10
- }
11
- else {
12
- return null;
13
- }
14
- }
15
- describe('Get question answer defaultJSON', () => {
16
- it('for affiliationSearch question format', () => {
17
- const json = defaultJSON('affiliationSearch');
18
- const expectedJSON = {
19
- type: 'affiliationSearch',
20
- answer: {
21
- affiliationId: '',
22
- affiliationName: '',
23
- },
24
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
25
- };
26
- expect(json).toEqual(expectedJSON);
27
- });
28
- it('for boolean question format', () => {
29
- const json = defaultJSON('boolean');
30
- const expectedJSON = {
31
- type: 'boolean',
32
- answer: false,
33
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
34
- };
35
- expect(json).toEqual(expectedJSON);
36
- });
37
- it('for checkBoxes question format', () => {
38
- const json = defaultJSON('checkBoxes');
39
- const expectedJSON = {
40
- type: 'checkBoxes',
41
- answer: [''],
42
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
43
- };
44
- expect(json).toEqual(expectedJSON);
45
- });
46
- it('for currency question format', () => {
47
- const json = defaultJSON('currency');
48
- const expectedJSON = {
49
- type: 'currency',
50
- answer: 0,
51
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
52
- };
53
- expect(json).toEqual(expectedJSON);
54
- });
55
- });
56
- it('for date question format', () => {
57
- const json = defaultJSON('date');
58
- const expectedJSON = {
59
- type: 'date',
60
- answer: '',
61
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
62
- };
63
- expect(json).toEqual(expectedJSON);
64
- });
65
- it('for dateRange question format', () => {
66
- const json = defaultJSON('dateRange');
67
- const expectedJSON = {
68
- type: 'dateRange',
69
- answer: {
70
- start: '',
71
- end: '',
72
- },
73
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
74
- };
75
- expect(json).toEqual(expectedJSON);
76
- });
77
- it('for email question format', () => {
78
- const json = defaultJSON('email');
79
- const expectedJSON = {
80
- type: 'email',
81
- answer: '',
82
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
83
- };
84
- expect(json).toEqual(expectedJSON);
85
- });
86
- it('for multiselectBox question format', () => {
87
- const json = defaultJSON('multiselectBox');
88
- const expectedJSON = {
89
- type: 'multiselectBox',
90
- answer: [''],
91
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
92
- };
93
- expect(json).toEqual(expectedJSON);
94
- });
95
- it('for number question format', () => {
96
- const json = defaultJSON('number');
97
- const expectedJSON = {
98
- type: 'number',
99
- answer: 0,
100
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
101
- };
102
- expect(json).toEqual(expectedJSON);
103
- });
104
- it('for numberRange format', () => {
105
- const json = defaultJSON('numberRange');
106
- const expectedJSON = {
107
- type: 'numberRange',
108
- answer: {
109
- start: 0,
110
- end: 0,
111
- },
112
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
113
- };
114
- expect(json).toEqual(expectedJSON);
115
- });
116
- it('for radioButtons question format', () => {
117
- const json = defaultJSON('radioButtons');
118
- const expectedJSON = {
119
- type: 'radioButtons',
120
- answer: '',
121
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
122
- };
123
- expect(json).toEqual(expectedJSON);
124
- });
125
- it('for selectBox question format', () => {
126
- const json = defaultJSON('selectBox');
127
- const expectedJSON = {
128
- type: 'selectBox',
129
- answer: '',
130
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
131
- };
132
- expect(json).toEqual(expectedJSON);
133
- });
134
- it('for table question format', () => {
135
- const json = defaultJSON('table');
136
- const expectedJSON = {
137
- type: 'table',
138
- columnHeadings: [
139
- 'Column A',
140
- ],
141
- answer: [{
142
- columns: [{
143
- type: 'textArea',
144
- answer: '',
145
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
146
- }],
147
- }],
148
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
149
- };
150
- expect(json).toEqual(expectedJSON);
151
- });
152
- it('for text question format', () => {
153
- const json = defaultJSON('text');
154
- const expectedJSON = {
155
- type: 'text',
156
- answer: '',
157
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
158
- };
159
- expect(json).toEqual(expectedJSON);
160
- });
161
- it('for textArea question format', () => {
162
- const json = defaultJSON('textArea');
163
- const expectedJSON = {
164
- type: 'textArea',
165
- answer: '',
166
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
167
- };
168
- expect(json).toEqual(expectedJSON);
169
- });
170
- it('for url question format', () => {
171
- const json = defaultJSON('url');
172
- const expectedJSON = {
173
- type: 'url',
174
- answer: '',
175
- meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
176
- };
177
- expect(json).toEqual(expectedJSON);
178
- });
@@ -1,8 +0,0 @@
1
- import { AnyQuestionType } from "../index";
2
- export interface QuestionFormatInterface {
3
- type?: string;
4
- title?: string;
5
- usageDescription?: string;
6
- defaultJSON?: AnyQuestionType;
7
- schemaVersion?: string;
8
- }