@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AnyTableColumnAnswerJSONSchema = exports.ResearchOutputTableAnswerJSONSchema = exports.TableAnswerJSONSchema = exports.DefaultResearchOutputTableAnswer = exports.ResearchOutputTableAnswerSchema = exports.DefaultTableAnswer = exports.TableAnswerSchema = exports.AnyTableColumnAnswerSchema = void 0;
|
|
3
|
+
exports.AnyTableColumnAnswerJSONSchema = exports.ResearchOutputTableRowAnswerJSONSchema = exports.TableRowAnswerJSONSchema = exports.ResearchOutputTableAnswerJSONSchema = exports.TableAnswerJSONSchema = exports.DefaultResearchOutputTableAnswer = exports.ResearchOutputTableAnswerSchema = exports.DefaultTableAnswer = exports.TableAnswerSchema = exports.DefaultResearchOutputTableRowAnswer = exports.ResearchOutputTableRowAnswerSchema = exports.DefaultTableRowAnswer = exports.TableRowAnswerSchema = exports.AnyResearchOutputTableColumnAnswerSchema = exports.AnyTableColumnAnswerSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const answer_1 = require("./answer");
|
|
6
6
|
const optionBasedAnswers_1 = require("./optionBasedAnswers");
|
|
@@ -30,40 +30,63 @@ exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
30
30
|
textAnswers_1.TextAreaAnswerSchema,
|
|
31
31
|
textAnswers_1.URLAnswerSchema
|
|
32
32
|
]);
|
|
33
|
-
|
|
33
|
+
// A subset of AnyTableColumnAnswerSchema that includes the commonStandardId field.
|
|
34
|
+
// This is used to map answers in the Research Output table to elements of the
|
|
35
|
+
// RDA Common Standard.
|
|
36
|
+
const roCheckBoxesAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, optionBasedAnswers_1.CheckboxesAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
37
|
+
const roDateAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, dateAnswers_1.DateAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
38
|
+
const roLicenseSearchAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, graphQLAnswers_1.LicenseSearchAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
39
|
+
const roMetadataStandardSearchAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, graphQLAnswers_1.MetadataStandardSearchAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
40
|
+
const roNumberWithContextAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, numberAnswers_1.NumberWithContextAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
41
|
+
const roRadioButtonsAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, optionBasedAnswers_1.RadioButtonsAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
42
|
+
const roRepositorySearchAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, graphQLAnswers_1.RepositorySearchAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
43
|
+
const roSelectBoxAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, optionBasedAnswers_1.SelectBoxAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
44
|
+
const roTextAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, textAnswers_1.TextAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
45
|
+
const roTextAreaAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, textAnswers_1.TextAreaAnswerSchema.shape), { commonStandardId: zod_1.z.string().optional() }));
|
|
46
|
+
exports.AnyResearchOutputTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
47
|
+
roCheckBoxesAnswerSchema,
|
|
48
|
+
roDateAnswerSchema,
|
|
49
|
+
roLicenseSearchAnswerSchema,
|
|
50
|
+
roMetadataStandardSearchAnswerSchema,
|
|
51
|
+
roNumberWithContextAnswerSchema,
|
|
52
|
+
roRadioButtonsAnswerSchema,
|
|
53
|
+
roRepositorySearchAnswerSchema,
|
|
54
|
+
roSelectBoxAnswerSchema,
|
|
55
|
+
roTextAnswerSchema,
|
|
56
|
+
roTextAreaAnswerSchema
|
|
57
|
+
]);
|
|
58
|
+
exports.TableRowAnswerSchema = zod_1.z.object({
|
|
34
59
|
columns: zod_1.z.array(exports.AnyTableColumnAnswerSchema) // The answers for each column in the row
|
|
35
60
|
});
|
|
36
|
-
|
|
61
|
+
exports.DefaultTableRowAnswer = exports.TableRowAnswerSchema.parse({
|
|
37
62
|
columns: [textAnswers_1.DefaultTextAreaAnswer]
|
|
38
63
|
});
|
|
64
|
+
exports.ResearchOutputTableRowAnswerSchema = zod_1.z.object({
|
|
65
|
+
columns: zod_1.z.array(exports.AnyResearchOutputTableColumnAnswerSchema)
|
|
66
|
+
});
|
|
67
|
+
exports.DefaultResearchOutputTableRowAnswer = exports.ResearchOutputTableRowAnswerSchema.parse({
|
|
68
|
+
columns: [
|
|
69
|
+
Object.assign(Object.assign({}, textAnswers_1.DefaultTextAnswer), { commonStandardId: 'title' }),
|
|
70
|
+
Object.assign(Object.assign({}, optionBasedAnswers_1.DefaultSelectBoxAnswer), { commonStandardId: 'type' }),
|
|
71
|
+
]
|
|
72
|
+
});
|
|
39
73
|
// Answers to Table Question Types
|
|
40
|
-
exports.TableAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, answer_1.AnswerSchema.shape), { type: zod_1.z.literal('table'), columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Column A']), answer: zod_1.z.array(TableRowAnswerSchema) }));
|
|
74
|
+
exports.TableAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, answer_1.AnswerSchema.shape), { type: zod_1.z.literal('table'), columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Column A']), answer: zod_1.z.array(exports.TableRowAnswerSchema) }));
|
|
41
75
|
exports.DefaultTableAnswer = exports.TableAnswerSchema.parse({
|
|
42
76
|
type: 'table',
|
|
43
77
|
columnHeadings: ['Column A'],
|
|
44
|
-
answer: [DefaultTableRowAnswer],
|
|
78
|
+
answer: [exports.DefaultTableRowAnswer],
|
|
45
79
|
meta: questions_1.DefaultMeta
|
|
46
80
|
});
|
|
47
|
-
exports.ResearchOutputTableAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, exports.TableAnswerSchema.shape), { type: zod_1.z.literal('researchOutputTable'), columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Title', 'Type']) }));
|
|
81
|
+
exports.ResearchOutputTableAnswerSchema = zod_1.z.object(Object.assign(Object.assign({}, exports.TableAnswerSchema.shape), { type: zod_1.z.literal('researchOutputTable'), columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Title', 'Type']), answer: zod_1.z.array(exports.ResearchOutputTableRowAnswerSchema) }));
|
|
48
82
|
exports.DefaultResearchOutputTableAnswer = exports.ResearchOutputTableAnswerSchema.parse({
|
|
49
83
|
type: 'researchOutputTable',
|
|
50
84
|
columnHeadings: ['Title', 'Type'],
|
|
51
|
-
answer: [
|
|
52
|
-
columns: [
|
|
53
|
-
{
|
|
54
|
-
type: 'text',
|
|
55
|
-
answer: '',
|
|
56
|
-
meta: questions_1.DefaultMeta
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
type: 'selectBox',
|
|
60
|
-
answer: '',
|
|
61
|
-
meta: questions_1.DefaultMeta
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}],
|
|
85
|
+
answer: [exports.DefaultResearchOutputTableRowAnswer],
|
|
65
86
|
meta: questions_1.DefaultMeta
|
|
66
87
|
});
|
|
67
88
|
exports.TableAnswerJSONSchema = zod_1.z.toJSONSchema(exports.TableAnswerSchema);
|
|
68
89
|
exports.ResearchOutputTableAnswerJSONSchema = zod_1.z.toJSONSchema(exports.ResearchOutputTableAnswerSchema);
|
|
90
|
+
exports.TableRowAnswerJSONSchema = zod_1.z.toJSONSchema(exports.TableRowAnswerSchema);
|
|
91
|
+
exports.ResearchOutputTableRowAnswerJSONSchema = zod_1.z.toJSONSchema(exports.ResearchOutputTableRowAnswerSchema);
|
|
69
92
|
exports.AnyTableColumnAnswerJSONSchema = zod_1.z.toJSONSchema(exports.AnyTableColumnAnswerSchema);
|
|
@@ -24,10 +24,10 @@ describe('validate the RDA common standard', () => {
|
|
|
24
24
|
contact: {
|
|
25
25
|
name: 'Test Contact',
|
|
26
26
|
mbox: 'tester@example.com',
|
|
27
|
-
contact_id: {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
contact_id: [{
|
|
28
|
+
identifier: '123456789',
|
|
29
|
+
type: 'other'
|
|
30
|
+
}]
|
|
31
31
|
},
|
|
32
32
|
dataset: [{
|
|
33
33
|
title: 'Test Dataset',
|
|
@@ -66,10 +66,10 @@ describe('validate the RDA common standard', () => {
|
|
|
66
66
|
contact: {
|
|
67
67
|
name: 'Test Contact',
|
|
68
68
|
mbox: 'tester@example.com',
|
|
69
|
-
contact_id: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
contact_id: [{
|
|
70
|
+
identifier: 'https://orcid.org/0000-0000-0000-0000',
|
|
71
|
+
type: 'orcid'
|
|
72
|
+
}],
|
|
73
73
|
affiliation: [{
|
|
74
74
|
name: 'Test University',
|
|
75
75
|
affiliation_id: {
|
|
@@ -80,10 +80,10 @@ describe('validate the RDA common standard', () => {
|
|
|
80
80
|
},
|
|
81
81
|
contributor: [{
|
|
82
82
|
name: 'Test Contact',
|
|
83
|
-
contributor_id: {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
contributor_id: [{
|
|
84
|
+
identifier: 'https://orcid.org/0000-0000-0000-0000',
|
|
85
|
+
type: 'orcid'
|
|
86
|
+
}],
|
|
87
87
|
affiliation: [{
|
|
88
88
|
name: 'Test University',
|
|
89
89
|
affiliation_id: {
|
|
@@ -117,10 +117,10 @@ describe('validate the RDA common standard', () => {
|
|
|
117
117
|
metadata: [{
|
|
118
118
|
description: 'Description of metadata',
|
|
119
119
|
language: 'eng',
|
|
120
|
-
metadata_standard_id: {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
120
|
+
metadata_standard_id: [{
|
|
121
|
+
identifier: 'https://example.com/metadata-standards/123',
|
|
122
|
+
type: 'url'
|
|
123
|
+
}]
|
|
124
124
|
}],
|
|
125
125
|
preservation_statement: 'Statement about preservation',
|
|
126
126
|
security_and_privacy: [{
|
|
@@ -185,19 +185,23 @@ describe('validate the RDA common standard', () => {
|
|
|
185
185
|
project: [{
|
|
186
186
|
title: 'Test Project',
|
|
187
187
|
description: 'This is a test project',
|
|
188
|
-
project_id: {
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
188
|
+
project_id: [{
|
|
189
|
+
identifier: '123456789',
|
|
190
|
+
type: 'other'
|
|
191
|
+
}],
|
|
192
192
|
start: '2025-01-01',
|
|
193
193
|
end: '2028-01-31',
|
|
194
194
|
funding: [{
|
|
195
195
|
name: 'Funder Organization',
|
|
196
|
-
funding_status: '
|
|
196
|
+
funding_status: 'granted',
|
|
197
197
|
funder_id: {
|
|
198
198
|
identifier: 'https://ror.org/0987654321',
|
|
199
199
|
type: 'ror'
|
|
200
|
-
}
|
|
200
|
+
},
|
|
201
|
+
grant_id: [{
|
|
202
|
+
identifier: '123456789',
|
|
203
|
+
type: 'other'
|
|
204
|
+
}]
|
|
201
205
|
}]
|
|
202
206
|
}]
|
|
203
207
|
};
|
|
@@ -5,7 +5,9 @@ const extension_1 = require("../extension");
|
|
|
5
5
|
describe('extensions', () => {
|
|
6
6
|
it('validates a minimal DMP Tool extension', () => {
|
|
7
7
|
const expected = {
|
|
8
|
+
rda_schema_version: "1.2",
|
|
8
9
|
provenance: 'your-application',
|
|
10
|
+
status: 'draft',
|
|
9
11
|
privacy: 'private',
|
|
10
12
|
featured: 'no',
|
|
11
13
|
};
|
|
@@ -13,7 +15,9 @@ describe('extensions', () => {
|
|
|
13
15
|
});
|
|
14
16
|
it('validates a full DMP Tool extension', () => {
|
|
15
17
|
const validData = {
|
|
18
|
+
rda_schema_version: "1.2",
|
|
16
19
|
provenance: 'your-application',
|
|
20
|
+
status: 'complete',
|
|
17
21
|
privacy: 'private',
|
|
18
22
|
featured: 'no',
|
|
19
23
|
registered: '2026-01-01T10:32:45Z',
|
|
@@ -24,12 +28,6 @@ describe('extensions', () => {
|
|
|
24
28
|
type: 'url'
|
|
25
29
|
}
|
|
26
30
|
},
|
|
27
|
-
related_identifier: [{
|
|
28
|
-
identifier: 'https://doi.org/10.1234/dmp.123456789',
|
|
29
|
-
descriptor: 'cites',
|
|
30
|
-
work_type: 'dataset',
|
|
31
|
-
type: 'doi'
|
|
32
|
-
}],
|
|
33
31
|
research_facility: [{
|
|
34
32
|
name: 'Super telescope',
|
|
35
33
|
type: 'observatory',
|
|
@@ -52,18 +50,26 @@ describe('extensions', () => {
|
|
|
52
50
|
type: 'url'
|
|
53
51
|
}
|
|
54
52
|
}],
|
|
53
|
+
funding_project: [{
|
|
54
|
+
project_id: {
|
|
55
|
+
identifier: '123456789',
|
|
56
|
+
type: 'other'
|
|
57
|
+
},
|
|
58
|
+
funder_id: {
|
|
59
|
+
identifier: 'https://ror.org/0987654321',
|
|
60
|
+
type: 'ror'
|
|
61
|
+
},
|
|
62
|
+
project_identifier: {
|
|
63
|
+
identifier: 'https://example.com/erbgierg',
|
|
64
|
+
type: 'url'
|
|
65
|
+
}
|
|
66
|
+
}],
|
|
55
67
|
version: [{
|
|
56
|
-
access_url: 'https://example.com/
|
|
57
|
-
|
|
68
|
+
access_url: 'https://example.com/dmps/123456789?version=2026-01-01T10:32:45Z',
|
|
69
|
+
version: '2026-01-01T10:32:45Z',
|
|
58
70
|
}],
|
|
59
71
|
narrative: {
|
|
60
|
-
|
|
61
|
-
csv: 'https://example.com/dmp/123456789/narrative.csv',
|
|
62
|
-
docx: 'https://example.com/dmp/123456789/narrative.docx',
|
|
63
|
-
html: 'https://example.com/dmp/123456789/narrative.html',
|
|
64
|
-
pdf: 'https://example.com/dmp/123456789/narrative.pdf',
|
|
65
|
-
txt: 'https://example.com/dmp/123456789/narrative.txt',
|
|
66
|
-
},
|
|
72
|
+
download_url: 'https://example.com/dmps/123456789/narrative',
|
|
67
73
|
template: {
|
|
68
74
|
id: 1234567,
|
|
69
75
|
title: 'Narrative Template',
|