@dmptool/types 2.2.0 → 2.3.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.
- package/dist/answers/__tests__/answers.spec.js +27 -14
- package/dist/answers/__tests__/defaults.spec.js +2 -0
- package/dist/answers/index.d.ts +102 -0
- package/dist/answers/index.js +1 -0
- package/dist/answers/tableAnswers.d.ts +614 -136
- package/dist/answers/tableAnswers.js +43 -20
- package/dist/dmp/__tests__/commonStandard.spec.js +26 -22
- package/dist/dmp/__tests__/extensions.spec.js +21 -15
- package/dist/dmp/extension.d.ts +385 -92
- package/dist/dmp/extension.js +49 -103
- package/dist/dmp/index.d.ts +515 -2
- package/dist/dmp/index.js +11 -1
- package/dist/questions/__tests__/defaults.spec.js +20 -10
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +17 -12
- package/dist/questions/__tests__/tableQuestion.spec.js +5 -0
- package/dist/questions/index.d.ts +20 -7
- package/dist/questions/optionBasedQuestions.d.ts +8 -6
- package/dist/questions/optionBasedQuestions.js +21 -8
- package/dist/questions/tableQuestions.d.ts +54 -16
- package/dist/questions/tableQuestions.js +56 -19
- package/dist/schemas/anyAnswer.schema.json +514 -0
- package/dist/schemas/anyQuestion.schema.json +60 -35
- package/dist/schemas/anyTableColumnQuestion.schema.json +9 -10
- package/dist/schemas/checkboxesQuestion.schema.json +3 -0
- package/dist/schemas/dmpExtension.schema.json +636 -140
- package/dist/schemas/multiselectBoxQuestion.schema.json +3 -5
- package/dist/schemas/radioButtonsQuestion.schema.json +3 -5
- package/dist/schemas/researchOutputTableAnswer.schema.json +6047 -11983
- package/dist/schemas/selectBoxQuestion.schema.json +3 -5
- package/dist/schemas/tableQuestion.schema.json +9 -10
- package/package.json +1 -1
- package/schemas/anyAnswer.schema.json +514 -0
- package/schemas/anyQuestion.schema.json +60 -35
- package/schemas/anyTableColumnQuestion.schema.json +9 -10
- package/schemas/checkboxesQuestion.schema.json +3 -0
- package/schemas/dmpExtension.schema.json +636 -140
- package/schemas/multiselectBoxQuestion.schema.json +3 -5
- package/schemas/radioButtonsQuestion.schema.json +3 -5
- package/schemas/researchOutputTableAnswer.schema.json +6047 -11983
- package/schemas/selectBoxQuestion.schema.json +3 -5
- package/schemas/tableQuestion.schema.json +9 -10
|
@@ -194,7 +194,7 @@ describe('questions return the expected defaults', () => {
|
|
|
194
194
|
type: "multiselectBox",
|
|
195
195
|
attributes: { multiple: true },
|
|
196
196
|
meta: { schemaVersion: "1.0" },
|
|
197
|
-
options: [{ label: 'Option A',
|
|
197
|
+
options: [{ label: 'Option A', value: 'a' }]
|
|
198
198
|
};
|
|
199
199
|
(0, globals_1.expect)(optionBasedQuestions_1.DefaultMultiselectBoxQuestion).toEqual(expected);
|
|
200
200
|
});
|
|
@@ -231,7 +231,7 @@ describe('questions return the expected defaults', () => {
|
|
|
231
231
|
type: "radioButtons",
|
|
232
232
|
attributes: {},
|
|
233
233
|
meta: { schemaVersion: "1.0" },
|
|
234
|
-
options: [{ label: 'Option A',
|
|
234
|
+
options: [{ label: 'Option A', value: 'a' }]
|
|
235
235
|
};
|
|
236
236
|
(0, globals_1.expect)(optionBasedQuestions_1.DefaultRadioButtonsQuestion).toEqual(expected);
|
|
237
237
|
});
|
|
@@ -247,6 +247,7 @@ describe('questions return the expected defaults', () => {
|
|
|
247
247
|
columns: [
|
|
248
248
|
{
|
|
249
249
|
heading: "Title",
|
|
250
|
+
commonStandardId: 'title',
|
|
250
251
|
help: "Enter the title of this research output",
|
|
251
252
|
required: true,
|
|
252
253
|
enabled: true,
|
|
@@ -258,6 +259,7 @@ describe('questions return the expected defaults', () => {
|
|
|
258
259
|
},
|
|
259
260
|
{
|
|
260
261
|
heading: "Description",
|
|
262
|
+
commonStandardId: 'description',
|
|
261
263
|
help: "Enter a brief description of this research output",
|
|
262
264
|
required: false,
|
|
263
265
|
enabled: false,
|
|
@@ -274,6 +276,7 @@ describe('questions return the expected defaults', () => {
|
|
|
274
276
|
},
|
|
275
277
|
{
|
|
276
278
|
heading: "Type",
|
|
279
|
+
commonStandardId: 'type',
|
|
277
280
|
help: "Select the type of this research output",
|
|
278
281
|
required: true,
|
|
279
282
|
enabled: true,
|
|
@@ -281,15 +284,16 @@ describe('questions return the expected defaults', () => {
|
|
|
281
284
|
type: "selectBox",
|
|
282
285
|
attributes: { multiple: false },
|
|
283
286
|
options: [
|
|
284
|
-
{ label: 'Dataset', value: 'dataset'
|
|
285
|
-
{ label: 'Software', value: 'software'
|
|
286
|
-
{ label: 'Other', value: 'other'
|
|
287
|
+
{ label: 'Dataset', value: 'dataset' },
|
|
288
|
+
{ label: 'Software', value: 'software' },
|
|
289
|
+
{ label: 'Other', value: 'other' }
|
|
287
290
|
],
|
|
288
291
|
meta: { schemaVersion: "1.0" }
|
|
289
292
|
}
|
|
290
293
|
},
|
|
291
294
|
{
|
|
292
295
|
heading: 'Data Flags',
|
|
296
|
+
commonStandardId: 'data_flags',
|
|
293
297
|
help: 'Mark all of the statements that are true about the dataset',
|
|
294
298
|
required: false,
|
|
295
299
|
enabled: false,
|
|
@@ -313,6 +317,7 @@ describe('questions return the expected defaults', () => {
|
|
|
313
317
|
},
|
|
314
318
|
{
|
|
315
319
|
heading: 'Access Level',
|
|
320
|
+
commonStandardId: 'data_access',
|
|
316
321
|
help: 'Select the access level for this research output',
|
|
317
322
|
required: false,
|
|
318
323
|
enabled: false,
|
|
@@ -321,14 +326,15 @@ describe('questions return the expected defaults', () => {
|
|
|
321
326
|
meta: { schemaVersion: "1.0" },
|
|
322
327
|
attributes: {},
|
|
323
328
|
options: [
|
|
324
|
-
{ label: 'Open Access', value: 'open'
|
|
325
|
-
{ label: 'Restricted Access', value: 'restricted'
|
|
326
|
-
{ label: 'Other', value: 'closed'
|
|
329
|
+
{ label: 'Open Access', value: 'open' },
|
|
330
|
+
{ label: 'Restricted Access', value: 'restricted' },
|
|
331
|
+
{ label: 'Other', value: 'closed' },
|
|
327
332
|
]
|
|
328
333
|
}
|
|
329
334
|
},
|
|
330
335
|
{
|
|
331
336
|
heading: "Anticipated Release Date",
|
|
337
|
+
commonStandardId: 'issued',
|
|
332
338
|
help: "The anticipated release date for the research output",
|
|
333
339
|
required: false,
|
|
334
340
|
enabled: false,
|
|
@@ -342,6 +348,7 @@ describe('questions return the expected defaults', () => {
|
|
|
342
348
|
},
|
|
343
349
|
{
|
|
344
350
|
heading: "Byte Size",
|
|
351
|
+
commonStandardId: 'byte_size',
|
|
345
352
|
help: "The size of the research output in bytes",
|
|
346
353
|
required: false,
|
|
347
354
|
enabled: false,
|
|
@@ -352,7 +359,7 @@ describe('questions return the expected defaults', () => {
|
|
|
352
359
|
step: 1,
|
|
353
360
|
context: [
|
|
354
361
|
{ label: 'bytes', value: 'bytes', selected: false },
|
|
355
|
-
{ label: 'KB (kilobytes)', value: 'kb', selected:
|
|
362
|
+
{ label: 'KB (kilobytes)', value: 'kb', selected: false },
|
|
356
363
|
{ label: 'MB (megabytes)', value: 'mb', selected: false },
|
|
357
364
|
{ label: 'GB (gigabytes)', value: 'gb', selected: false },
|
|
358
365
|
{ label: 'TB (terabytes)', value: 'tb', selected: false },
|
|
@@ -366,6 +373,7 @@ describe('questions return the expected defaults', () => {
|
|
|
366
373
|
},
|
|
367
374
|
{
|
|
368
375
|
heading: "Repository(ies)",
|
|
376
|
+
commonStandardId: 'host',
|
|
369
377
|
help: "Select repository(ies) you would prefer users to deposit in",
|
|
370
378
|
required: false,
|
|
371
379
|
enabled: false,
|
|
@@ -435,6 +443,7 @@ describe('questions return the expected defaults', () => {
|
|
|
435
443
|
},
|
|
436
444
|
{
|
|
437
445
|
heading: "Metadata Standard(s)",
|
|
446
|
+
commonStandardId: 'metadata',
|
|
438
447
|
help: "Select metadata standard(s) you would prefer users to use",
|
|
439
448
|
required: false,
|
|
440
449
|
enabled: false,
|
|
@@ -497,6 +506,7 @@ describe('questions return the expected defaults', () => {
|
|
|
497
506
|
},
|
|
498
507
|
{
|
|
499
508
|
heading: "License",
|
|
509
|
+
commonStandardId: 'license_ref',
|
|
500
510
|
help: "Select the license you will apply to the research output",
|
|
501
511
|
required: false,
|
|
502
512
|
enabled: false,
|
|
@@ -630,7 +640,7 @@ describe('questions return the expected defaults', () => {
|
|
|
630
640
|
type: "selectBox",
|
|
631
641
|
attributes: { multiple: false },
|
|
632
642
|
meta: { schemaVersion: "1.0" },
|
|
633
|
-
options: [{ label: 'Option A',
|
|
643
|
+
options: [{ label: 'Option A', value: 'a' }]
|
|
634
644
|
};
|
|
635
645
|
(0, globals_1.expect)(optionBasedQuestions_1.DefaultSelectBoxQuestion).toEqual(expected);
|
|
636
646
|
});
|
|
@@ -101,12 +101,10 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
101
101
|
{
|
|
102
102
|
label: "Male",
|
|
103
103
|
value: "male",
|
|
104
|
-
selected: true,
|
|
105
104
|
},
|
|
106
105
|
{
|
|
107
106
|
label: "Female",
|
|
108
107
|
value: "female",
|
|
109
|
-
selected: true,
|
|
110
108
|
},
|
|
111
109
|
],
|
|
112
110
|
meta: {
|
|
@@ -122,8 +120,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
122
120
|
options: [
|
|
123
121
|
{
|
|
124
122
|
label: "Male",
|
|
125
|
-
value: "male"
|
|
126
|
-
selected: "true", // Invalid type for selected
|
|
123
|
+
value: "male"
|
|
127
124
|
},
|
|
128
125
|
],
|
|
129
126
|
meta: {
|
|
@@ -146,12 +143,10 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
146
143
|
{
|
|
147
144
|
label: "USA",
|
|
148
145
|
value: "us",
|
|
149
|
-
selected: true,
|
|
150
146
|
},
|
|
151
147
|
{
|
|
152
148
|
label: "Canada",
|
|
153
149
|
value: "ca",
|
|
154
|
-
selected: false,
|
|
155
150
|
},
|
|
156
151
|
],
|
|
157
152
|
meta: {
|
|
@@ -168,8 +163,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
168
163
|
options: [
|
|
169
164
|
{
|
|
170
165
|
label: "USA",
|
|
171
|
-
value: "us"
|
|
172
|
-
selected: "true", // Invalid type for selected
|
|
166
|
+
value: "us"
|
|
173
167
|
},
|
|
174
168
|
],
|
|
175
169
|
attributes: {
|
|
@@ -195,12 +189,10 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
195
189
|
{
|
|
196
190
|
label: "USA",
|
|
197
191
|
value: "us",
|
|
198
|
-
selected: true,
|
|
199
192
|
},
|
|
200
193
|
{
|
|
201
194
|
label: "Canada",
|
|
202
195
|
value: "ca",
|
|
203
|
-
selected: false,
|
|
204
196
|
},
|
|
205
197
|
],
|
|
206
198
|
meta: {
|
|
@@ -217,8 +209,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
217
209
|
options: [
|
|
218
210
|
{
|
|
219
211
|
label: "USA",
|
|
220
|
-
value: "us"
|
|
221
|
-
selected: "true", // Invalid type for selected
|
|
212
|
+
value: "us"
|
|
222
213
|
},
|
|
223
214
|
],
|
|
224
215
|
attributes: {
|
|
@@ -231,3 +222,17 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
231
222
|
(0, globals_1.expect)(() => optionBasedQuestions_1.MultiselectBoxQuestionSchema.parse(invalidSelectBoxQuestion)).toThrow();
|
|
232
223
|
});
|
|
233
224
|
});
|
|
225
|
+
(0, globals_1.describe)("Option descriptions", () => {
|
|
226
|
+
(0, globals_1.it)("should accept and preserve an optional description on options", () => {
|
|
227
|
+
const selectWithDescription = {
|
|
228
|
+
type: "selectBox",
|
|
229
|
+
attributes: { multiple: false },
|
|
230
|
+
options: [
|
|
231
|
+
{ label: "Data paper", value: "data-paper", description: "A published description of a dataset" },
|
|
232
|
+
],
|
|
233
|
+
meta: { schemaVersion: "1.0" }
|
|
234
|
+
};
|
|
235
|
+
const parsed = optionBasedQuestions_1.SelectBoxQuestionSchema.parse(selectWithDescription);
|
|
236
|
+
(0, globals_1.expect)(parsed.options[0].description).toBe("A published description of a dataset");
|
|
237
|
+
});
|
|
238
|
+
});
|
|
@@ -78,6 +78,7 @@ describe("ResearchOutputTableQuestionSchema", () => {
|
|
|
78
78
|
columns: [
|
|
79
79
|
{
|
|
80
80
|
heading: "Title",
|
|
81
|
+
commonStandardId: 'title',
|
|
81
82
|
required: true,
|
|
82
83
|
enabled: true,
|
|
83
84
|
content: {
|
|
@@ -88,6 +89,7 @@ describe("ResearchOutputTableQuestionSchema", () => {
|
|
|
88
89
|
},
|
|
89
90
|
{
|
|
90
91
|
heading: "Output Type",
|
|
92
|
+
commonStandardId: 'type',
|
|
91
93
|
required: true,
|
|
92
94
|
enabled: true,
|
|
93
95
|
content: {
|
|
@@ -106,6 +108,7 @@ describe("ResearchOutputTableQuestionSchema", () => {
|
|
|
106
108
|
},
|
|
107
109
|
{
|
|
108
110
|
heading: "Byte Size",
|
|
111
|
+
commonStandardId: 'byte_size',
|
|
109
112
|
required: false,
|
|
110
113
|
enabled: true,
|
|
111
114
|
content: {
|
|
@@ -135,6 +138,7 @@ describe("ResearchOutputTableQuestionSchema", () => {
|
|
|
135
138
|
},
|
|
136
139
|
{
|
|
137
140
|
heading: "Repositories",
|
|
141
|
+
commonStandardId: 'host',
|
|
138
142
|
required: false,
|
|
139
143
|
enabled: true,
|
|
140
144
|
preferences: [
|
|
@@ -202,6 +206,7 @@ describe("ResearchOutputTableQuestionSchema", () => {
|
|
|
202
206
|
columns: [
|
|
203
207
|
{
|
|
204
208
|
heading: "Title",
|
|
209
|
+
commonStandardId: 'title',
|
|
205
210
|
content: {
|
|
206
211
|
type: "invalid",
|
|
207
212
|
meta: {
|
|
@@ -63,6 +63,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
63
63
|
checked: z.ZodDefault<z.ZodBoolean>;
|
|
64
64
|
label: z.ZodDefault<z.ZodString>;
|
|
65
65
|
value: z.ZodDefault<z.ZodString>;
|
|
66
|
+
description: z.ZodOptional<z.ZodString>;
|
|
66
67
|
}, z.core.$strip>>;
|
|
67
68
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
68
69
|
attributes: z.ZodObject<{
|
|
@@ -223,9 +224,9 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
223
224
|
}, z.core.$strip>, z.ZodObject<{
|
|
224
225
|
type: z.ZodLiteral<"multiselectBox">;
|
|
225
226
|
options: z.ZodArray<z.ZodObject<{
|
|
226
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
227
227
|
label: z.ZodDefault<z.ZodString>;
|
|
228
228
|
value: z.ZodDefault<z.ZodString>;
|
|
229
|
+
description: z.ZodOptional<z.ZodString>;
|
|
229
230
|
}, z.core.$strip>>;
|
|
230
231
|
attributes: z.ZodObject<{
|
|
231
232
|
multiple: z.ZodLiteral<true>;
|
|
@@ -289,9 +290,9 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
289
290
|
}, z.core.$strip>, z.ZodObject<{
|
|
290
291
|
type: z.ZodLiteral<"radioButtons">;
|
|
291
292
|
options: z.ZodArray<z.ZodObject<{
|
|
292
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
293
293
|
label: z.ZodDefault<z.ZodString>;
|
|
294
294
|
value: z.ZodDefault<z.ZodString>;
|
|
295
|
+
description: z.ZodOptional<z.ZodString>;
|
|
295
296
|
}, z.core.$strip>>;
|
|
296
297
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
297
298
|
attributes: z.ZodObject<{
|
|
@@ -340,6 +341,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
340
341
|
type: z.ZodLiteral<"researchOutputTable">;
|
|
341
342
|
columns: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
342
343
|
heading: z.ZodDefault<z.ZodString>;
|
|
344
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
343
345
|
help: z.ZodDefault<z.ZodString>;
|
|
344
346
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
345
347
|
content: z.ZodObject<{
|
|
@@ -361,6 +363,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
361
363
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
362
364
|
}, z.core.$strip>, z.ZodObject<{
|
|
363
365
|
heading: z.ZodDefault<z.ZodString>;
|
|
366
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
364
367
|
help: z.ZodDefault<z.ZodString>;
|
|
365
368
|
content: z.ZodObject<{
|
|
366
369
|
type: z.ZodLiteral<"textArea">;
|
|
@@ -385,14 +388,15 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
385
388
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
386
389
|
}, z.core.$strip>, z.ZodObject<{
|
|
387
390
|
heading: z.ZodDefault<z.ZodString>;
|
|
391
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
388
392
|
help: z.ZodDefault<z.ZodString>;
|
|
389
393
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
390
394
|
content: z.ZodObject<{
|
|
391
395
|
type: z.ZodLiteral<"selectBox">;
|
|
392
396
|
options: z.ZodArray<z.ZodObject<{
|
|
393
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
394
397
|
label: z.ZodDefault<z.ZodString>;
|
|
395
398
|
value: z.ZodDefault<z.ZodString>;
|
|
399
|
+
description: z.ZodOptional<z.ZodString>;
|
|
396
400
|
}, z.core.$strip>>;
|
|
397
401
|
attributes: z.ZodObject<{
|
|
398
402
|
multiple: z.ZodLiteral<false>;
|
|
@@ -410,6 +414,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
410
414
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
411
415
|
}, z.core.$strip>, z.ZodObject<{
|
|
412
416
|
heading: z.ZodDefault<z.ZodString>;
|
|
417
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
413
418
|
help: z.ZodDefault<z.ZodString>;
|
|
414
419
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
415
420
|
content: z.ZodObject<{
|
|
@@ -418,6 +423,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
418
423
|
checked: z.ZodDefault<z.ZodBoolean>;
|
|
419
424
|
label: z.ZodDefault<z.ZodString>;
|
|
420
425
|
value: z.ZodDefault<z.ZodString>;
|
|
426
|
+
description: z.ZodOptional<z.ZodString>;
|
|
421
427
|
}, z.core.$strip>>;
|
|
422
428
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
423
429
|
attributes: z.ZodObject<{
|
|
@@ -434,14 +440,15 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
434
440
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
435
441
|
}, z.core.$strip>, z.ZodObject<{
|
|
436
442
|
heading: z.ZodDefault<z.ZodString>;
|
|
443
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
437
444
|
help: z.ZodDefault<z.ZodString>;
|
|
438
445
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
439
446
|
content: z.ZodObject<{
|
|
440
447
|
type: z.ZodLiteral<"radioButtons">;
|
|
441
448
|
options: z.ZodArray<z.ZodObject<{
|
|
442
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
443
449
|
label: z.ZodDefault<z.ZodString>;
|
|
444
450
|
value: z.ZodDefault<z.ZodString>;
|
|
451
|
+
description: z.ZodOptional<z.ZodString>;
|
|
445
452
|
}, z.core.$strip>>;
|
|
446
453
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
447
454
|
attributes: z.ZodObject<{
|
|
@@ -458,6 +465,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
458
465
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
459
466
|
}, z.core.$strip>, z.ZodObject<{
|
|
460
467
|
heading: z.ZodDefault<z.ZodString>;
|
|
468
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
461
469
|
help: z.ZodDefault<z.ZodString>;
|
|
462
470
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
463
471
|
content: z.ZodObject<{
|
|
@@ -480,6 +488,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
480
488
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
481
489
|
}, z.core.$strip>, z.ZodObject<{
|
|
482
490
|
heading: z.ZodDefault<z.ZodString>;
|
|
491
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
483
492
|
help: z.ZodDefault<z.ZodString>;
|
|
484
493
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
485
494
|
content: z.ZodObject<{
|
|
@@ -508,6 +517,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
508
517
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
509
518
|
}, z.core.$strip>, z.ZodObject<{
|
|
510
519
|
heading: z.ZodDefault<z.ZodString>;
|
|
520
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
511
521
|
help: z.ZodDefault<z.ZodString>;
|
|
512
522
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
513
523
|
content: z.ZodObject<{
|
|
@@ -550,6 +560,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
550
560
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
551
561
|
}, z.core.$strip>, z.ZodObject<{
|
|
552
562
|
heading: z.ZodDefault<z.ZodString>;
|
|
563
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
553
564
|
help: z.ZodDefault<z.ZodString>;
|
|
554
565
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
555
566
|
content: z.ZodObject<{
|
|
@@ -592,6 +603,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
592
603
|
required: z.ZodDefault<z.ZodBoolean>;
|
|
593
604
|
}, z.core.$strip>, z.ZodObject<{
|
|
594
605
|
heading: z.ZodDefault<z.ZodString>;
|
|
606
|
+
commonStandardId: z.ZodOptional<z.ZodString>;
|
|
595
607
|
help: z.ZodDefault<z.ZodString>;
|
|
596
608
|
enabled: z.ZodDefault<z.ZodBoolean>;
|
|
597
609
|
content: z.ZodObject<{
|
|
@@ -673,9 +685,9 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
673
685
|
}, z.core.$strip>, z.ZodObject<{
|
|
674
686
|
type: z.ZodLiteral<"selectBox">;
|
|
675
687
|
options: z.ZodArray<z.ZodObject<{
|
|
676
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
677
688
|
label: z.ZodDefault<z.ZodString>;
|
|
678
689
|
value: z.ZodDefault<z.ZodString>;
|
|
690
|
+
description: z.ZodOptional<z.ZodString>;
|
|
679
691
|
}, z.core.$strip>>;
|
|
680
692
|
attributes: z.ZodObject<{
|
|
681
693
|
multiple: z.ZodLiteral<false>;
|
|
@@ -746,6 +758,7 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
746
758
|
checked: z.ZodDefault<z.ZodBoolean>;
|
|
747
759
|
label: z.ZodDefault<z.ZodString>;
|
|
748
760
|
value: z.ZodDefault<z.ZodString>;
|
|
761
|
+
description: z.ZodOptional<z.ZodString>;
|
|
749
762
|
}, z.core.$strip>>;
|
|
750
763
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
751
764
|
attributes: z.ZodObject<{
|
|
@@ -944,9 +957,9 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
944
957
|
}, z.core.$strip>, z.ZodObject<{
|
|
945
958
|
type: z.ZodLiteral<"radioButtons">;
|
|
946
959
|
options: z.ZodArray<z.ZodObject<{
|
|
947
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
948
960
|
label: z.ZodDefault<z.ZodString>;
|
|
949
961
|
value: z.ZodDefault<z.ZodString>;
|
|
962
|
+
description: z.ZodOptional<z.ZodString>;
|
|
950
963
|
}, z.core.$strip>>;
|
|
951
964
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
952
965
|
attributes: z.ZodObject<{
|
|
@@ -994,9 +1007,9 @@ export declare const AnyQuestionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
994
1007
|
}, z.core.$strip>, z.ZodObject<{
|
|
995
1008
|
type: z.ZodLiteral<"selectBox">;
|
|
996
1009
|
options: z.ZodArray<z.ZodObject<{
|
|
997
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
998
1010
|
label: z.ZodDefault<z.ZodString>;
|
|
999
1011
|
value: z.ZodDefault<z.ZodString>;
|
|
1012
|
+
description: z.ZodOptional<z.ZodString>;
|
|
1000
1013
|
}, z.core.$strip>>;
|
|
1001
1014
|
attributes: z.ZodObject<{
|
|
1002
1015
|
multiple: z.ZodLiteral<false>;
|
|
@@ -31,6 +31,7 @@ export declare const CheckboxesQuestionSchema: z.ZodObject<{
|
|
|
31
31
|
checked: z.ZodDefault<z.ZodBoolean>;
|
|
32
32
|
label: z.ZodDefault<z.ZodString>;
|
|
33
33
|
value: z.ZodDefault<z.ZodString>;
|
|
34
|
+
description: z.ZodOptional<z.ZodString>;
|
|
34
35
|
}, z.core.$strip>>;
|
|
35
36
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
36
37
|
attributes: z.ZodObject<{
|
|
@@ -50,6 +51,7 @@ export declare const DefaultCheckboxesQuestion: {
|
|
|
50
51
|
checked: boolean;
|
|
51
52
|
label: string;
|
|
52
53
|
value: string;
|
|
54
|
+
description?: string | undefined;
|
|
53
55
|
}[];
|
|
54
56
|
attributes: {
|
|
55
57
|
label?: string | undefined;
|
|
@@ -66,9 +68,9 @@ export declare const DefaultCheckboxesQuestion: {
|
|
|
66
68
|
export declare const RadioButtonsQuestionSchema: z.ZodObject<{
|
|
67
69
|
type: z.ZodLiteral<"radioButtons">;
|
|
68
70
|
options: z.ZodArray<z.ZodObject<{
|
|
69
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
70
71
|
label: z.ZodDefault<z.ZodString>;
|
|
71
72
|
value: z.ZodDefault<z.ZodString>;
|
|
73
|
+
description: z.ZodOptional<z.ZodString>;
|
|
72
74
|
}, z.core.$strip>>;
|
|
73
75
|
showCommentField: z.ZodOptional<z.ZodBoolean>;
|
|
74
76
|
attributes: z.ZodObject<{
|
|
@@ -85,9 +87,9 @@ export declare const RadioButtonsQuestionSchema: z.ZodObject<{
|
|
|
85
87
|
export declare const DefaultRadioButtonsQuestion: {
|
|
86
88
|
type: "radioButtons";
|
|
87
89
|
options: {
|
|
88
|
-
selected: boolean;
|
|
89
90
|
label: string;
|
|
90
91
|
value: string;
|
|
92
|
+
description?: string | undefined;
|
|
91
93
|
}[];
|
|
92
94
|
attributes: {
|
|
93
95
|
label?: string | undefined;
|
|
@@ -104,9 +106,9 @@ export declare const DefaultRadioButtonsQuestion: {
|
|
|
104
106
|
export declare const SelectBoxQuestionSchema: z.ZodObject<{
|
|
105
107
|
type: z.ZodLiteral<"selectBox">;
|
|
106
108
|
options: z.ZodArray<z.ZodObject<{
|
|
107
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
108
109
|
label: z.ZodDefault<z.ZodString>;
|
|
109
110
|
value: z.ZodDefault<z.ZodString>;
|
|
111
|
+
description: z.ZodOptional<z.ZodString>;
|
|
110
112
|
}, z.core.$strip>>;
|
|
111
113
|
attributes: z.ZodObject<{
|
|
112
114
|
multiple: z.ZodLiteral<false>;
|
|
@@ -124,9 +126,9 @@ export declare const SelectBoxQuestionSchema: z.ZodObject<{
|
|
|
124
126
|
export declare const DefaultSelectBoxQuestion: {
|
|
125
127
|
type: "selectBox";
|
|
126
128
|
options: {
|
|
127
|
-
selected: boolean;
|
|
128
129
|
label: string;
|
|
129
130
|
value: string;
|
|
131
|
+
description?: string | undefined;
|
|
130
132
|
}[];
|
|
131
133
|
attributes: {
|
|
132
134
|
multiple: false;
|
|
@@ -144,9 +146,9 @@ export declare const DefaultSelectBoxQuestion: {
|
|
|
144
146
|
export declare const MultiselectBoxQuestionSchema: z.ZodObject<{
|
|
145
147
|
type: z.ZodLiteral<"multiselectBox">;
|
|
146
148
|
options: z.ZodArray<z.ZodObject<{
|
|
147
|
-
selected: z.ZodDefault<z.ZodBoolean>;
|
|
148
149
|
label: z.ZodDefault<z.ZodString>;
|
|
149
150
|
value: z.ZodDefault<z.ZodString>;
|
|
151
|
+
description: z.ZodOptional<z.ZodString>;
|
|
150
152
|
}, z.core.$strip>>;
|
|
151
153
|
attributes: z.ZodObject<{
|
|
152
154
|
multiple: z.ZodLiteral<true>;
|
|
@@ -164,9 +166,9 @@ export declare const MultiselectBoxQuestionSchema: z.ZodObject<{
|
|
|
164
166
|
export declare const DefaultMultiselectBoxQuestion: {
|
|
165
167
|
type: "multiselectBox";
|
|
166
168
|
options: {
|
|
167
|
-
selected: boolean;
|
|
168
169
|
label: string;
|
|
169
170
|
value: string;
|
|
171
|
+
description?: string | undefined;
|
|
170
172
|
}[];
|
|
171
173
|
attributes: {
|
|
172
174
|
multiple: true;
|
|
@@ -4,14 +4,21 @@ exports.MultiselectBoxQuestionJSONSchema = exports.SelectBoxQuestionJSONSchema =
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
// A select box, radio buttons, or checkboxes option
|
|
7
|
+
// NOTE: Question option shapes are intentionally minimal: they describe the configurable
|
|
8
|
+
// properties of each option (label, value, description). We deliberately do NOT include
|
|
9
|
+
// answer-state flags such as `selected` on question definitions because those represent
|
|
10
|
+
// user response state and belong in answer objects/schemas (not in the question configuration).
|
|
11
|
+
// For checkboxes we include a `checked` default on the question option to allow a configured
|
|
12
|
+
// default checked state. Radio/select/multiselect questions should not contain `selected`;
|
|
13
|
+
// user selections are captured by the answer schemas.
|
|
7
14
|
const OptionSchema = zod_1.z.object({
|
|
8
15
|
label: zod_1.z.string().default('Option A'),
|
|
9
16
|
value: zod_1.z.string().default('a'),
|
|
17
|
+
description: zod_1.z.string().optional(),
|
|
10
18
|
});
|
|
19
|
+
const DefaultOption = OptionSchema.parse({});
|
|
11
20
|
const CheckedOptionSchema = zod_1.z.object(Object.assign(Object.assign({}, OptionSchema.shape), { checked: zod_1.z.boolean().default(false) }));
|
|
12
21
|
const DefaultCheckedOption = CheckedOptionSchema.parse({});
|
|
13
|
-
const SelectedOptionSchema = zod_1.z.object(Object.assign(Object.assign({}, OptionSchema.shape), { selected: zod_1.z.boolean().default(false) }));
|
|
14
|
-
const DefaultSelectedOption = SelectedOptionSchema.parse({});
|
|
15
22
|
const selectBoxAttributes = zod_1.z.object(Object.assign(Object.assign({}, question_1.BaseAttributesSchema.shape), { multiple: zod_1.z.literal(false) }));
|
|
16
23
|
const DefaultSelectBoxAttributes = selectBoxAttributes.parse({
|
|
17
24
|
multiple: false
|
|
@@ -38,32 +45,38 @@ exports.DefaultCheckboxesQuestion = exports.CheckboxesQuestionSchema.parse({
|
|
|
38
45
|
options: [DefaultCheckedOption]
|
|
39
46
|
});
|
|
40
47
|
// Radio buttons question and answer
|
|
41
|
-
exports.RadioButtonsQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('radioButtons'),
|
|
48
|
+
exports.RadioButtonsQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('radioButtons'),
|
|
49
|
+
// Questions should not include the `selected` flag on options
|
|
50
|
+
options: zod_1.z.array(OptionSchema), showCommentField: zod_1.z.boolean().optional() }));
|
|
42
51
|
exports.DefaultRadioButtonsQuestion = exports.RadioButtonsQuestionSchema.parse({
|
|
43
52
|
type: 'radioButtons',
|
|
44
53
|
attributes: DefaultSelectBoxAttributes,
|
|
45
54
|
meta: question_1.DefaultMeta,
|
|
46
|
-
options: [
|
|
55
|
+
options: [DefaultOption]
|
|
47
56
|
});
|
|
48
57
|
// Select box question and answer
|
|
49
|
-
exports.SelectBoxQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('selectBox'),
|
|
58
|
+
exports.SelectBoxQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, question_1.QuestionSchema.shape), { type: zod_1.z.literal('selectBox'),
|
|
59
|
+
// Questions should not include the `selected` flag on options
|
|
60
|
+
options: zod_1.z.array(OptionSchema), attributes: selectBoxAttributes, showCommentField: zod_1.z.boolean().optional() }));
|
|
50
61
|
exports.DefaultSelectBoxQuestion = exports.SelectBoxQuestionSchema.parse({
|
|
51
62
|
type: 'selectBox',
|
|
52
63
|
attributes: DefaultSelectBoxAttributes,
|
|
53
64
|
meta: question_1.DefaultMeta,
|
|
54
|
-
options: [
|
|
65
|
+
options: [DefaultOption]
|
|
55
66
|
});
|
|
56
67
|
const multiselectBoxAttributes = zod_1.z.object(Object.assign(Object.assign({}, selectBoxAttributes.shape), { multiple: zod_1.z.literal(true) }));
|
|
57
68
|
const DefaultMultiselectBoxAttributes = multiselectBoxAttributes.parse({
|
|
58
69
|
multiple: true
|
|
59
70
|
});
|
|
60
71
|
// Multi-select box question and answer
|
|
61
|
-
exports.MultiselectBoxQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, exports.SelectBoxQuestionSchema.shape), { type: zod_1.z.literal('multiselectBox'),
|
|
72
|
+
exports.MultiselectBoxQuestionSchema = zod_1.z.object(Object.assign(Object.assign({}, exports.SelectBoxQuestionSchema.shape), { type: zod_1.z.literal('multiselectBox'),
|
|
73
|
+
// Questions should not include the `selected` flag on options
|
|
74
|
+
options: zod_1.z.array(OptionSchema), attributes: multiselectBoxAttributes, showCommentField: zod_1.z.boolean().optional() }));
|
|
62
75
|
exports.DefaultMultiselectBoxQuestion = exports.MultiselectBoxQuestionSchema.parse({
|
|
63
76
|
type: 'multiselectBox',
|
|
64
77
|
attributes: DefaultMultiselectBoxAttributes,
|
|
65
78
|
meta: question_1.DefaultMeta,
|
|
66
|
-
options: [
|
|
79
|
+
options: [DefaultOption]
|
|
67
80
|
});
|
|
68
81
|
exports.BooleanQuestionJSONSchema = zod_1.z.toJSONSchema(exports.BooleanQuestionSchema);
|
|
69
82
|
exports.CheckboxesQuestionJSONSchema = zod_1.z.toJSONSchema(exports.CheckboxesQuestionSchema);
|