@dmptool/types 1.1.2 → 1.2.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 (78) hide show
  1. package/README.md +119 -47
  2. package/dist/answers/__tests__/answers.spec.js +20 -28
  3. package/dist/answers/__tests__/usage.spec.d.ts +1 -0
  4. package/dist/answers/__tests__/usage.spec.js +175 -0
  5. package/dist/answers/answer.d.ts +12 -15
  6. package/dist/answers/answer.js +3 -4
  7. package/dist/answers/dateAnswers.d.ts +30 -30
  8. package/dist/answers/dateAnswers.js +6 -5
  9. package/dist/answers/graphQLAnswers.d.ts +25 -25
  10. package/dist/answers/graphQLAnswers.js +4 -4
  11. package/dist/answers/index.d.ts +860 -1088
  12. package/dist/answers/index.js +2 -2
  13. package/dist/answers/numberAnswers.d.ts +41 -41
  14. package/dist/answers/numberAnswers.js +8 -8
  15. package/dist/answers/optionBasedAnswers.d.ts +55 -55
  16. package/dist/answers/optionBasedAnswers.js +10 -10
  17. package/dist/answers/tableAnswers.d.ts +811 -1772
  18. package/dist/answers/tableAnswers.js +12 -8
  19. package/dist/answers/textAnswers.d.ts +44 -44
  20. package/dist/answers/textAnswers.js +8 -8
  21. package/dist/questions/__tests__/graphQLQuestions.spec.js +6 -4
  22. package/dist/questions/__tests__/optionBasedQuestions.spec.js +4 -12
  23. package/dist/questions/__tests__/usage.spec.d.ts +8 -0
  24. package/dist/questions/__tests__/usage.spec.js +312 -0
  25. package/dist/questions/dateQuestions.d.ts +90 -101
  26. package/dist/questions/dateQuestions.js +15 -34
  27. package/dist/questions/graphQLQuestions.d.ts +176 -182
  28. package/dist/questions/graphQLQuestions.js +44 -45
  29. package/dist/questions/index.d.ts +1791 -2170
  30. package/dist/questions/index.js +2 -2
  31. package/dist/questions/numberQuestions.d.ts +126 -142
  32. package/dist/questions/numberQuestions.js +11 -45
  33. package/dist/questions/optionBasedQuestions.d.ts +197 -225
  34. package/dist/questions/optionBasedQuestions.js +24 -88
  35. package/dist/questions/question.d.ts +24 -56
  36. package/dist/questions/question.js +78 -18
  37. package/dist/questions/tableQuestions.d.ts +2637 -2930
  38. package/dist/questions/tableQuestions.js +9 -21
  39. package/dist/questions/textQuestions.d.ts +125 -145
  40. package/dist/questions/textQuestions.js +16 -57
  41. package/dist/schemas/affiliationSearchAnswer.schema.json +9 -12
  42. package/dist/schemas/affiliationSearchQuestion.schema.json +57 -50
  43. package/dist/schemas/anyAnswer.schema.json +228 -237
  44. package/dist/schemas/anyQuestion.schema.json +349 -517
  45. package/dist/schemas/anyTableColumnAnswer.schema.json +93 -106
  46. package/dist/schemas/anyTableColumnQuestion.schema.json +259 -382
  47. package/dist/schemas/booleanAnswer.schema.json +8 -11
  48. package/dist/schemas/booleanQuestion.schema.json +9 -15
  49. package/dist/schemas/checkboxesAnswer.schema.json +13 -14
  50. package/dist/schemas/checkboxesQuestion.schema.json +18 -24
  51. package/dist/schemas/currencyAnswer.schema.json +8 -11
  52. package/dist/schemas/currencyQuestion.schema.json +13 -17
  53. package/dist/schemas/dateAnswer.schema.json +8 -11
  54. package/dist/schemas/dateQuestion.schema.json +9 -15
  55. package/dist/schemas/dateRangeAnswer.schema.json +16 -21
  56. package/dist/schemas/dateRangeQuestion.schema.json +40 -21
  57. package/dist/schemas/emailAnswer.schema.json +8 -11
  58. package/dist/schemas/emailQuestion.schema.json +11 -16
  59. package/dist/schemas/filteredSearchQuestion.schema.json +0 -3
  60. package/dist/schemas/multiselectBoxAnswer.schema.json +13 -14
  61. package/dist/schemas/multiselectBoxQuestion.schema.json +20 -25
  62. package/dist/schemas/numberAnswer.schema.json +8 -11
  63. package/dist/schemas/numberQuestion.schema.json +11 -16
  64. package/dist/schemas/numberRangeAnswer.schema.json +17 -22
  65. package/dist/schemas/numberRangeQuestion.schema.json +22 -21
  66. package/dist/schemas/radioButtonsAnswer.schema.json +8 -11
  67. package/dist/schemas/radioButtonsQuestion.schema.json +18 -24
  68. package/dist/schemas/selectBoxAnswer.schema.json +8 -11
  69. package/dist/schemas/selectBoxQuestion.schema.json +20 -25
  70. package/dist/schemas/tableAnswer.schema.json +337 -343
  71. package/dist/schemas/tableQuestion.schema.json +279 -416
  72. package/dist/schemas/textAnswer.schema.json +8 -11
  73. package/dist/schemas/textAreaAnswer.schema.json +8 -11
  74. package/dist/schemas/textAreaQuestion.schema.json +13 -17
  75. package/dist/schemas/textQuestion.schema.json +9 -15
  76. package/dist/schemas/urlAnswer.schema.json +8 -11
  77. package/dist/schemas/urlQuestion.schema.json +9 -15
  78. package/package.json +1 -1
@@ -9,7 +9,6 @@ const optionBasedQuestions_1 = require("./optionBasedQuestions");
9
9
  const graphQLQuestions_1 = require("./graphQLQuestions");
10
10
  const question_1 = require("./question");
11
11
  const BaseAttributes = question_1.QuestionSchema.shape.attributes;
12
- const BaseMeta = question_1.QuestionSchema.shape.meta;
13
12
  // Union types for all questions and answers (tables cannot be nested so no TableQuestion here!)
14
13
  exports.AnyTableColumnQuestionSchema = zod_1.z.discriminatedUnion('type', [
15
14
  graphQLQuestions_1.AffiliationSearchQuestionSchema,
@@ -28,29 +27,18 @@ exports.AnyTableColumnQuestionSchema = zod_1.z.discriminatedUnion('type', [
28
27
  textQuestions_1.URLQuestionSchema
29
28
  ]);
30
29
  exports.TableColumn = zod_1.z.object({
31
- heading: zod_1.z.string().optional(), // The heading of the column
32
- content: exports.AnyTableColumnQuestionSchema, // The question for the column
30
+ heading: zod_1.z.string().default('Column A'), // The heading of the column
31
+ content: exports.AnyTableColumnQuestionSchema.default({ type: 'textArea' }), // The question for the column
33
32
  });
34
33
  // Table question and answer
35
- const defaultTableJSON = {
36
- type: 'table',
37
- columns: [],
38
- attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { canAddRows: true, canRemoveRows: true, initialRows: 1, maxRows: undefined, minRows: undefined }),
39
- meta: Object.assign({}, question_1.defaultMeta)
40
- };
41
34
  exports.TableQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
42
- type: zod_1.z.literal('table'), // The type of question
43
- columns: zod_1.z.array(exports.TableColumn), // The columns of the table
44
- attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
45
- canAddRows: zod_1.z.boolean().optional(), // Whether to allow adding rows (default is true)
46
- canRemoveRows: zod_1.z.boolean().optional(), // Whether to allow removing rows (default is true)
47
- initialRows: zod_1.z.number().optional(), // The initial number of rows (default is 1)
35
+ type: zod_1.z.literal('table'),
36
+ columns: zod_1.z.array(exports.TableColumn).default([{}]), // The columns of the table
37
+ attributes: BaseAttributes.merge(zod_1.z.object({
38
+ canAddRows: zod_1.z.boolean().default(true),
39
+ canRemoveRows: zod_1.z.boolean().default(true),
40
+ initialRows: zod_1.z.number().default(1),
48
41
  maxRows: zod_1.z.number().optional(), // The maximum number of rows (no default)
49
42
  minRows: zod_1.z.number().optional() // The minimum number of rows (no default)
50
- })).optional(),
51
- meta: BaseMeta.unwrap().merge(zod_1.z.object({
52
- title: zod_1.z.literal('Table').optional(),
53
- usageDescription: zod_1.z.literal('For questions that require a tabular format.').optional(),
54
- defaultJSON: zod_1.z.literal(JSON.stringify(defaultTableJSON)).optional()
55
- })).optional()
43
+ })).default({})
56
44
  }));
@@ -1,24 +1,38 @@
1
1
  import { z } from "zod";
2
- export declare const EmailQuestionSchema: z.ZodObject<{} & {
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
+ } & {
3
17
  type: z.ZodLiteral<"email">;
4
- attributes: z.ZodOptional<z.ZodObject<{
18
+ attributes: z.ZodDefault<z.ZodObject<{
5
19
  label: z.ZodOptional<z.ZodString>;
6
20
  help: z.ZodOptional<z.ZodString>;
7
21
  labelTranslationKey: z.ZodOptional<z.ZodString>;
8
22
  } & {
9
- maxLength: z.ZodOptional<z.ZodNumber>;
23
+ maxLength: z.ZodDefault<z.ZodNumber>;
10
24
  minLength: z.ZodOptional<z.ZodNumber>;
11
25
  pattern: z.ZodOptional<z.ZodString>;
12
26
  } & {
13
- multiple: z.ZodOptional<z.ZodBoolean>;
27
+ multiple: z.ZodDefault<z.ZodBoolean>;
14
28
  }, "strip", z.ZodTypeAny, {
29
+ maxLength: number;
30
+ multiple: boolean;
15
31
  label?: string | undefined;
16
32
  help?: string | undefined;
17
33
  labelTranslationKey?: string | undefined;
18
- maxLength?: number | undefined;
19
34
  minLength?: number | undefined;
20
35
  pattern?: string | undefined;
21
- multiple?: boolean | undefined;
22
36
  }, {
23
37
  label?: string | undefined;
24
38
  help?: string | undefined;
@@ -28,40 +42,22 @@ export declare const EmailQuestionSchema: z.ZodObject<{} & {
28
42
  pattern?: string | undefined;
29
43
  multiple?: boolean | undefined;
30
44
  }>>;
31
- meta: z.ZodOptional<z.ZodObject<{
32
- schemaVersion: z.ZodLiteral<"1.0">;
33
- } & {
34
- title: z.ZodOptional<z.ZodLiteral<"Email Field">>;
35
- usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require require email address(es).">>;
36
- defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
37
- }, "strip", z.ZodTypeAny, {
38
- schemaVersion: "1.0";
39
- title?: "Email Field" | undefined;
40
- usageDescription?: "For questions that require require email address(es)." | undefined;
41
- defaultJSON?: string | undefined;
42
- }, {
43
- schemaVersion: "1.0";
44
- title?: "Email Field" | undefined;
45
- usageDescription?: "For questions that require require email address(es)." | undefined;
46
- defaultJSON?: string | undefined;
47
- }>>;
48
45
  }, "strip", z.ZodTypeAny, {
49
46
  type: "email";
50
- attributes?: {
47
+ attributes: {
48
+ maxLength: number;
49
+ multiple: boolean;
51
50
  label?: string | undefined;
52
51
  help?: string | undefined;
53
52
  labelTranslationKey?: string | undefined;
54
- maxLength?: number | undefined;
55
53
  minLength?: number | undefined;
56
54
  pattern?: string | undefined;
57
- multiple?: boolean | undefined;
58
- } | undefined;
59
- meta?: {
60
- schemaVersion: "1.0";
61
- title?: "Email Field" | undefined;
62
- usageDescription?: "For questions that require require email address(es)." | undefined;
63
- defaultJSON?: string | undefined;
64
- } | undefined;
55
+ };
56
+ meta: {
57
+ schemaVersion: string;
58
+ title?: string | undefined;
59
+ usageDescription?: string | undefined;
60
+ };
65
61
  }, {
66
62
  type: "email";
67
63
  attributes?: {
@@ -74,33 +70,46 @@ export declare const EmailQuestionSchema: z.ZodObject<{} & {
74
70
  multiple?: boolean | undefined;
75
71
  } | undefined;
76
72
  meta?: {
77
- schemaVersion: "1.0";
78
- title?: "Email Field" | undefined;
79
- usageDescription?: "For questions that require require email address(es)." | undefined;
80
- defaultJSON?: string | undefined;
73
+ schemaVersion?: string | undefined;
74
+ title?: string | undefined;
75
+ usageDescription?: string | undefined;
81
76
  } | undefined;
82
77
  }>;
83
- export declare const TextAreaQuestionSchema: z.ZodObject<{} & {
78
+ 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
+ } & {
84
93
  type: z.ZodLiteral<"textArea">;
85
- attributes: z.ZodOptional<z.ZodObject<{
94
+ attributes: z.ZodDefault<z.ZodObject<{
86
95
  label: z.ZodOptional<z.ZodString>;
87
96
  help: z.ZodOptional<z.ZodString>;
88
97
  labelTranslationKey: z.ZodOptional<z.ZodString>;
89
98
  } & {
90
- cols: z.ZodOptional<z.ZodNumber>;
99
+ cols: z.ZodDefault<z.ZodNumber>;
91
100
  maxLength: z.ZodOptional<z.ZodNumber>;
92
101
  minLength: z.ZodOptional<z.ZodNumber>;
93
- rows: z.ZodOptional<z.ZodNumber>;
94
- asRichText: z.ZodOptional<z.ZodBoolean>;
102
+ rows: z.ZodDefault<z.ZodNumber>;
103
+ asRichText: z.ZodDefault<z.ZodBoolean>;
95
104
  }, "strip", z.ZodTypeAny, {
105
+ cols: number;
106
+ rows: number;
107
+ asRichText: boolean;
96
108
  label?: string | undefined;
97
109
  help?: string | undefined;
98
110
  labelTranslationKey?: string | undefined;
99
111
  maxLength?: number | undefined;
100
112
  minLength?: number | undefined;
101
- cols?: number | undefined;
102
- rows?: number | undefined;
103
- asRichText?: boolean | undefined;
104
113
  }, {
105
114
  label?: string | undefined;
106
115
  help?: string | undefined;
@@ -111,41 +120,23 @@ export declare const TextAreaQuestionSchema: z.ZodObject<{} & {
111
120
  rows?: number | undefined;
112
121
  asRichText?: boolean | undefined;
113
122
  }>>;
114
- meta: z.ZodOptional<z.ZodObject<{
115
- schemaVersion: z.ZodLiteral<"1.0">;
116
- } & {
117
- title: z.ZodOptional<z.ZodLiteral<"Text Area">>;
118
- usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require longer answers, you can select formatting options too.">>;
119
- defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
120
- }, "strip", z.ZodTypeAny, {
121
- schemaVersion: "1.0";
122
- title?: "Text Area" | undefined;
123
- usageDescription?: "For questions that require longer answers, you can select formatting options too." | undefined;
124
- defaultJSON?: string | undefined;
125
- }, {
126
- schemaVersion: "1.0";
127
- title?: "Text Area" | undefined;
128
- usageDescription?: "For questions that require longer answers, you can select formatting options too." | undefined;
129
- defaultJSON?: string | undefined;
130
- }>>;
131
123
  }, "strip", z.ZodTypeAny, {
132
124
  type: "textArea";
133
- attributes?: {
125
+ attributes: {
126
+ cols: number;
127
+ rows: number;
128
+ asRichText: boolean;
134
129
  label?: string | undefined;
135
130
  help?: string | undefined;
136
131
  labelTranslationKey?: string | undefined;
137
132
  maxLength?: number | undefined;
138
133
  minLength?: number | undefined;
139
- cols?: number | undefined;
140
- rows?: number | undefined;
141
- asRichText?: boolean | undefined;
142
- } | undefined;
143
- meta?: {
144
- schemaVersion: "1.0";
145
- title?: "Text Area" | undefined;
146
- usageDescription?: "For questions that require longer answers, you can select formatting options too." | undefined;
147
- defaultJSON?: string | undefined;
148
- } | undefined;
134
+ };
135
+ meta: {
136
+ schemaVersion: string;
137
+ title?: string | undefined;
138
+ usageDescription?: string | undefined;
139
+ };
149
140
  }, {
150
141
  type: "textArea";
151
142
  attributes?: {
@@ -159,27 +150,40 @@ export declare const TextAreaQuestionSchema: z.ZodObject<{} & {
159
150
  asRichText?: boolean | undefined;
160
151
  } | undefined;
161
152
  meta?: {
162
- schemaVersion: "1.0";
163
- title?: "Text Area" | undefined;
164
- usageDescription?: "For questions that require longer answers, you can select formatting options too." | undefined;
165
- defaultJSON?: string | undefined;
153
+ schemaVersion?: string | undefined;
154
+ title?: string | undefined;
155
+ usageDescription?: string | undefined;
166
156
  } | undefined;
167
157
  }>;
168
- export declare const TextQuestionSchema: z.ZodObject<{} & {
158
+ 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
+ } & {
169
173
  type: z.ZodLiteral<"text">;
170
- attributes: z.ZodOptional<z.ZodObject<{
174
+ attributes: z.ZodDefault<z.ZodObject<{
171
175
  label: z.ZodOptional<z.ZodString>;
172
176
  help: z.ZodOptional<z.ZodString>;
173
177
  labelTranslationKey: z.ZodOptional<z.ZodString>;
174
178
  } & {
175
- maxLength: z.ZodOptional<z.ZodNumber>;
179
+ maxLength: z.ZodDefault<z.ZodNumber>;
176
180
  minLength: z.ZodOptional<z.ZodNumber>;
177
181
  pattern: z.ZodOptional<z.ZodString>;
178
182
  }, "strip", z.ZodTypeAny, {
183
+ maxLength: number;
179
184
  label?: string | undefined;
180
185
  help?: string | undefined;
181
186
  labelTranslationKey?: string | undefined;
182
- maxLength?: number | undefined;
183
187
  minLength?: number | undefined;
184
188
  pattern?: string | undefined;
185
189
  }, {
@@ -190,39 +194,21 @@ export declare const TextQuestionSchema: z.ZodObject<{} & {
190
194
  minLength?: number | undefined;
191
195
  pattern?: string | undefined;
192
196
  }>>;
193
- meta: z.ZodOptional<z.ZodObject<{
194
- schemaVersion: z.ZodLiteral<"1.0">;
195
- } & {
196
- title: z.ZodOptional<z.ZodLiteral<"Text Field">>;
197
- usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require short, simple answers.">>;
198
- defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
199
- }, "strip", z.ZodTypeAny, {
200
- schemaVersion: "1.0";
201
- title?: "Text Field" | undefined;
202
- usageDescription?: "For questions that require short, simple answers." | undefined;
203
- defaultJSON?: string | undefined;
204
- }, {
205
- schemaVersion: "1.0";
206
- title?: "Text Field" | undefined;
207
- usageDescription?: "For questions that require short, simple answers." | undefined;
208
- defaultJSON?: string | undefined;
209
- }>>;
210
197
  }, "strip", z.ZodTypeAny, {
211
198
  type: "text";
212
- attributes?: {
199
+ attributes: {
200
+ maxLength: number;
213
201
  label?: string | undefined;
214
202
  help?: string | undefined;
215
203
  labelTranslationKey?: string | undefined;
216
- maxLength?: number | undefined;
217
204
  minLength?: number | undefined;
218
205
  pattern?: string | undefined;
219
- } | undefined;
220
- meta?: {
221
- schemaVersion: "1.0";
222
- title?: "Text Field" | undefined;
223
- usageDescription?: "For questions that require short, simple answers." | undefined;
224
- defaultJSON?: string | undefined;
225
- } | undefined;
206
+ };
207
+ meta: {
208
+ schemaVersion: string;
209
+ title?: string | undefined;
210
+ usageDescription?: string | undefined;
211
+ };
226
212
  }, {
227
213
  type: "text";
228
214
  attributes?: {
@@ -234,27 +220,40 @@ export declare const TextQuestionSchema: z.ZodObject<{} & {
234
220
  pattern?: string | undefined;
235
221
  } | undefined;
236
222
  meta?: {
237
- schemaVersion: "1.0";
238
- title?: "Text Field" | undefined;
239
- usageDescription?: "For questions that require short, simple answers." | undefined;
240
- defaultJSON?: string | undefined;
223
+ schemaVersion?: string | undefined;
224
+ title?: string | undefined;
225
+ usageDescription?: string | undefined;
241
226
  } | undefined;
242
227
  }>;
243
- export declare const URLQuestionSchema: z.ZodObject<{} & {
228
+ 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
+ } & {
244
243
  type: z.ZodLiteral<"url">;
245
- attributes: z.ZodOptional<z.ZodObject<{
244
+ attributes: z.ZodDefault<z.ZodObject<{
246
245
  label: z.ZodOptional<z.ZodString>;
247
246
  help: z.ZodOptional<z.ZodString>;
248
247
  labelTranslationKey: z.ZodOptional<z.ZodString>;
249
248
  } & {
250
- maxLength: z.ZodOptional<z.ZodNumber>;
249
+ maxLength: z.ZodDefault<z.ZodNumber>;
251
250
  minLength: z.ZodOptional<z.ZodNumber>;
252
251
  pattern: z.ZodOptional<z.ZodString>;
253
252
  }, "strip", z.ZodTypeAny, {
253
+ maxLength: number;
254
254
  label?: string | undefined;
255
255
  help?: string | undefined;
256
256
  labelTranslationKey?: string | undefined;
257
- maxLength?: number | undefined;
258
257
  minLength?: number | undefined;
259
258
  pattern?: string | undefined;
260
259
  }, {
@@ -265,39 +264,21 @@ export declare const URLQuestionSchema: z.ZodObject<{} & {
265
264
  minLength?: number | undefined;
266
265
  pattern?: string | undefined;
267
266
  }>>;
268
- meta: z.ZodOptional<z.ZodObject<{
269
- schemaVersion: z.ZodLiteral<"1.0">;
270
- } & {
271
- title: z.ZodOptional<z.ZodLiteral<"URL Field">>;
272
- usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a website, DOI or other URL.">>;
273
- defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
274
- }, "strip", z.ZodTypeAny, {
275
- schemaVersion: "1.0";
276
- title?: "URL Field" | undefined;
277
- usageDescription?: "For questions that require a website, DOI or other URL." | undefined;
278
- defaultJSON?: string | undefined;
279
- }, {
280
- schemaVersion: "1.0";
281
- title?: "URL Field" | undefined;
282
- usageDescription?: "For questions that require a website, DOI or other URL." | undefined;
283
- defaultJSON?: string | undefined;
284
- }>>;
285
267
  }, "strip", z.ZodTypeAny, {
286
268
  type: "url";
287
- attributes?: {
269
+ attributes: {
270
+ maxLength: number;
288
271
  label?: string | undefined;
289
272
  help?: string | undefined;
290
273
  labelTranslationKey?: string | undefined;
291
- maxLength?: number | undefined;
292
274
  minLength?: number | undefined;
293
275
  pattern?: string | undefined;
294
- } | undefined;
295
- meta?: {
296
- schemaVersion: "1.0";
297
- title?: "URL Field" | undefined;
298
- usageDescription?: "For questions that require a website, DOI or other URL." | undefined;
299
- defaultJSON?: string | undefined;
300
- } | undefined;
276
+ };
277
+ meta: {
278
+ schemaVersion: string;
279
+ title?: string | undefined;
280
+ usageDescription?: string | undefined;
281
+ };
301
282
  }, {
302
283
  type: "url";
303
284
  attributes?: {
@@ -309,10 +290,9 @@ export declare const URLQuestionSchema: z.ZodObject<{} & {
309
290
  pattern?: string | undefined;
310
291
  } | undefined;
311
292
  meta?: {
312
- schemaVersion: "1.0";
313
- title?: "URL Field" | undefined;
314
- usageDescription?: "For questions that require a website, DOI or other URL." | undefined;
315
- defaultJSON?: string | undefined;
293
+ schemaVersion?: string | undefined;
294
+ title?: string | undefined;
295
+ usageDescription?: string | undefined;
316
296
  } | undefined;
317
297
  }>;
318
298
  export type EmailQuestionType = z.infer<typeof EmailQuestionSchema>;
@@ -3,78 +3,37 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.URLQuestionSchema = exports.TextQuestionSchema = exports.TextAreaQuestionSchema = exports.EmailQuestionSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const question_1 = require("./question");
6
- const BaseMeta = question_1.QuestionSchema.shape.meta;
7
6
  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)
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()
12
11
  }));
13
12
  // Email question and answer
14
- const defaultEmailJSON = {
15
- type: 'email',
16
- attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { maxLength: 255, minLength: 1, pattern: undefined, multiple: false }),
17
- meta: Object.assign({}, question_1.defaultMeta)
18
- };
19
13
  exports.EmailQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
20
14
  type: zod_1.z.literal('email'),
21
15
  attributes: TextAttributesSchema.merge(zod_1.z.object({
22
- multiple: zod_1.z.boolean().optional(), // Allow multiple emails (default is false; comma separated)
23
- })).optional(),
24
- meta: BaseMeta.unwrap().merge(zod_1.z.object({
25
- title: zod_1.z.literal('Email Field').optional(),
26
- usageDescription: zod_1.z.literal('For questions that require require email address(es).').optional(),
27
- defaultJSON: zod_1.z.literal(JSON.stringify(defaultEmailJSON)).optional(),
28
- })).optional()
16
+ multiple: zod_1.z.boolean().default(false),
17
+ })).default({})
29
18
  }));
30
19
  // Text area question and answer
31
- const defaultTextAreaJSON = {
32
- type: 'textArea',
33
- attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { cols: 20, maxLength: undefined, minLength: undefined, rows: 2, asRichText: true }),
34
- meta: Object.assign({}, question_1.defaultMeta)
35
- };
36
20
  exports.TextAreaQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
37
- type: zod_1.z.literal('textArea'), // The type of question
38
- attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
39
- cols: zod_1.z.number().optional(), // The number of columns (default is 20)
40
- maxLength: zod_1.z.number().optional(), // The maximum length of the text (no default)
41
- minLength: zod_1.z.number().optional(), // The minimum length of the text (no default)
42
- rows: zod_1.z.number().optional(), // The number of rows (default is 2)
43
- asRichText: zod_1.z.boolean().optional() // Whether to use a WYSIWYG editor (default true)
44
- })).optional(),
45
- meta: BaseMeta.unwrap().merge(zod_1.z.object({
46
- title: zod_1.z.literal('Text Area').optional(),
47
- usageDescription: zod_1.z.literal('For questions that require longer answers, you can select formatting options too.').optional(),
48
- defaultJSON: zod_1.z.literal(JSON.stringify(defaultTextAreaJSON)).optional(),
49
- })).optional()
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({})
50
29
  }));
51
30
  // Text question and answer
52
- const defaultTextJSON = {
53
- type: 'text',
54
- attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { maxLength: 255, minLength: undefined, pattern: undefined }),
55
- meta: Object.assign({}, question_1.defaultMeta)
56
- };
57
31
  exports.TextQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
58
32
  type: zod_1.z.literal('text'),
59
- attributes: TextAttributesSchema.optional(),
60
- meta: BaseMeta.unwrap().merge(zod_1.z.object({
61
- title: zod_1.z.literal('Text Field').optional(),
62
- usageDescription: zod_1.z.literal('For questions that require short, simple answers.').optional(),
63
- defaultJSON: zod_1.z.literal(JSON.stringify(defaultTextJSON)).optional(),
64
- })).optional()
33
+ attributes: TextAttributesSchema.default({})
65
34
  }));
66
35
  // URL question and answer
67
- const defaultURLJSON = {
68
- type: 'url',
69
- attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { maxLength: 255, minLength: undefined, pattern: undefined }),
70
- meta: Object.assign({}, question_1.defaultMeta)
71
- };
72
36
  exports.URLQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
73
37
  type: zod_1.z.literal('url'),
74
- attributes: TextAttributesSchema.optional(),
75
- meta: BaseMeta.unwrap().merge(zod_1.z.object({
76
- title: zod_1.z.literal('URL Field').optional(),
77
- usageDescription: zod_1.z.literal('For questions that require a website, DOI or other URL.').optional(),
78
- defaultJSON: zod_1.z.literal(JSON.stringify(defaultURLJSON)).optional(),
79
- })).optional()
38
+ attributes: TextAttributesSchema.default({})
80
39
  }));
@@ -6,29 +6,26 @@
6
6
  "properties": {
7
7
  "type": {
8
8
  "type": "string",
9
- "const": "typeaheadSearch"
10
- },
11
- "answer": {
12
- "type": "string"
9
+ "const": "affiliationSearch"
13
10
  },
14
11
  "meta": {
15
12
  "type": "object",
16
13
  "properties": {
17
14
  "schemaVersion": {
18
15
  "type": "string",
19
- "const": "1.0"
16
+ "default": "1.0"
20
17
  }
21
18
  },
22
- "required": [
23
- "schemaVersion"
24
- ],
25
- "additionalProperties": false
19
+ "additionalProperties": false,
20
+ "default": {}
21
+ },
22
+ "answer": {
23
+ "type": "string",
24
+ "default": ""
26
25
  }
27
26
  },
28
27
  "required": [
29
- "type",
30
- "answer",
31
- "meta"
28
+ "type"
32
29
  ],
33
30
  "additionalProperties": false
34
31
  }