@dmptool/types 1.2.6 → 2.1.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/README.md +1 -1
- package/dist/answers/__tests__/defaults.spec.js +216 -0
- package/dist/answers/answer.d.ts +29 -14
- package/dist/answers/answer.js +11 -5
- package/dist/answers/dateAnswers.d.ts +20 -47
- package/dist/answers/dateAnswers.js +20 -10
- package/dist/answers/graphQLAnswers.d.ts +48 -120
- package/dist/answers/graphQLAnswers.js +46 -21
- package/dist/answers/index.d.ts +155 -1439
- package/dist/answers/index.js +26 -1
- package/dist/answers/numberAnswers.d.ts +38 -92
- package/dist/answers/numberAnswers.js +38 -19
- package/dist/answers/optionBasedAnswers.d.ts +42 -87
- package/dist/answers/optionBasedAnswers.js +37 -21
- package/dist/answers/tableAnswers.d.ts +348 -3032
- package/dist/answers/tableAnswers.js +25 -61
- package/dist/answers/textAnswers.d.ts +32 -68
- package/dist/answers/textAnswers.js +30 -17
- package/dist/dmp/__tests__/commonStandard.spec.d.ts +1 -0
- package/dist/dmp/__tests__/commonStandard.spec.js +210 -0
- package/dist/dmp/__tests__/extensions.spec.d.ts +1 -0
- package/dist/dmp/__tests__/extensions.spec.js +99 -0
- package/dist/dmp/extension.d.ts +1006 -0
- package/dist/dmp/extension.js +234 -0
- package/dist/dmp/index.d.ts +9 -0
- package/dist/dmp/index.js +23 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/questions/__tests__/dateQuestions.spec.js +3 -0
- package/dist/questions/__tests__/defaults.spec.d.ts +1 -0
- package/dist/questions/__tests__/defaults.spec.js +668 -0
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +3 -2
- package/dist/questions/__tests__/tableQuestion.spec.js +22 -23
- package/dist/questions/__tests__/textQuestions.spec.js +32 -0
- package/dist/questions/dateQuestions.d.ts +45 -191
- package/dist/questions/dateQuestions.js +26 -23
- package/dist/questions/graphQLQuestions.d.ts +262 -556
- package/dist/questions/graphQLQuestions.js +225 -223
- package/dist/questions/index.d.ts +670 -7441
- package/dist/questions/index.js +26 -1
- package/dist/questions/numberQuestions.d.ts +85 -331
- package/dist/questions/numberQuestions.js +50 -36
- package/dist/questions/optionBasedQuestions.d.ts +83 -290
- package/dist/questions/optionBasedQuestions.js +58 -41
- package/dist/questions/question.d.ts +72 -35
- package/dist/questions/question.js +14 -5
- package/dist/questions/tableQuestions.d.ts +2228 -9599
- package/dist/questions/tableQuestions.js +185 -192
- package/dist/questions/textQuestions.d.ts +70 -226
- package/dist/questions/textQuestions.js +31 -31
- package/dist/schemas/affiliationSearchAnswer.schema.json +35 -33
- package/dist/schemas/affiliationSearchQuestion.schema.json +124 -122
- package/dist/schemas/anyAnswer.schema.json +1229 -408
- package/dist/schemas/anyQuestion.schema.json +4312 -2023
- package/dist/schemas/anyTableColumnAnswer.schema.json +535 -314
- package/dist/schemas/anyTableColumnQuestion.schema.json +1309 -874
- package/dist/schemas/booleanAnswer.schema.json +22 -23
- package/dist/schemas/booleanQuestion.schema.json +39 -43
- package/dist/schemas/checkboxesAnswer.schema.json +27 -28
- package/dist/schemas/checkboxesQuestion.schema.json +63 -62
- package/dist/schemas/currencyAnswer.schema.json +22 -23
- package/dist/schemas/currencyQuestion.schema.json +57 -54
- package/dist/schemas/dateAnswer.schema.json +22 -23
- package/dist/schemas/dateQuestion.schema.json +50 -49
- package/dist/schemas/dateRangeAnswer.schema.json +35 -33
- package/dist/schemas/dateRangeQuestion.schema.json +87 -78
- package/dist/schemas/dmp.schema.json +2070 -0
- package/dist/schemas/dmpExtension.schema.json +1874 -0
- package/dist/schemas/emailAnswer.schema.json +22 -23
- package/dist/schemas/emailQuestion.schema.json +55 -53
- package/dist/schemas/licenseSearchAnswer.schema.json +40 -38
- package/dist/schemas/licenseSearchQuestion.schema.json +122 -146
- package/dist/schemas/metadataStandardSearchAnswer.schema.json +40 -38
- package/dist/schemas/metadataStandardSearchQuestion.schema.json +123 -156
- package/dist/schemas/multiselectBoxAnswer.schema.json +27 -28
- package/dist/schemas/multiselectBoxQuestion.schema.json +70 -71
- package/dist/schemas/numberAnswer.schema.json +22 -23
- package/dist/schemas/numberQuestion.schema.json +52 -50
- package/dist/schemas/numberRangeAnswer.schema.json +35 -33
- package/dist/schemas/numberRangeQuestion.schema.json +91 -60
- package/dist/schemas/numberWithContextAnswer.schema.json +35 -33
- package/dist/schemas/numberWithContextQuestion.schema.json +81 -70
- package/dist/schemas/radioButtonsAnswer.schema.json +22 -23
- package/dist/schemas/radioButtonsQuestion.schema.json +63 -62
- package/dist/schemas/repositorySearchAnswer.schema.json +40 -38
- package/dist/schemas/repositorySearchQuestion.schema.json +122 -162
- package/dist/schemas/researchOutputTableAnswer.schema.json +16622 -411
- package/dist/schemas/researchOutputTableQuestion.schema.json +114 -1157
- package/dist/schemas/selectBoxAnswer.schema.json +22 -23
- package/dist/schemas/selectBoxQuestion.schema.json +70 -71
- package/dist/schemas/tableAnswer.schema.json +581 -360
- package/dist/schemas/tableQuestion.schema.json +1388 -942
- package/dist/schemas/textAnswer.schema.json +22 -23
- package/dist/schemas/textAreaAnswer.schema.json +22 -23
- package/dist/schemas/textAreaQuestion.schema.json +65 -57
- package/dist/schemas/textQuestion.schema.json +50 -49
- package/dist/schemas/urlAnswer.schema.json +22 -23
- package/dist/schemas/urlQuestion.schema.json +50 -49
- package/package.json +6 -4
- package/dist/answers/__tests__/usage.spec.js +0 -178
- package/dist/questions/__tests__/usage.spec.d.ts +0 -8
- package/dist/questions/__tests__/usage.spec.js +0 -473
- /package/dist/answers/__tests__/{usage.spec.d.ts → defaults.spec.d.ts} +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DefaultExtensionSchema = exports.ExtensionSchema = exports.DefaultNarrative = void 0;
|
|
4
|
+
// DMP Tool extensions to the RDA Common Standard
|
|
5
|
+
// See: https://github.com/RDA-DMP-Common/RDA-DMP-Common-Standard
|
|
6
|
+
//
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
const answers_1 = require("../answers");
|
|
9
|
+
// the DMP visibility setting (should be used to check authorization)
|
|
10
|
+
const visibilityTypes = [
|
|
11
|
+
'public',
|
|
12
|
+
'private',
|
|
13
|
+
'embargoed',
|
|
14
|
+
];
|
|
15
|
+
// The types of research facilities
|
|
16
|
+
const researchFacilityTypes = [
|
|
17
|
+
'data_center',
|
|
18
|
+
'field_station',
|
|
19
|
+
'laboratory',
|
|
20
|
+
'observatory',
|
|
21
|
+
'other',
|
|
22
|
+
];
|
|
23
|
+
// Relation types are derived from the DataCite schema
|
|
24
|
+
const relationTypes = [
|
|
25
|
+
"is_cited_by",
|
|
26
|
+
"cites",
|
|
27
|
+
"is_supplement_to",
|
|
28
|
+
"is_supplemented_by",
|
|
29
|
+
"is_continued_by",
|
|
30
|
+
"continues",
|
|
31
|
+
"is_described_by",
|
|
32
|
+
"describes",
|
|
33
|
+
"has_metadata",
|
|
34
|
+
"is_metadata_for",
|
|
35
|
+
"has_version",
|
|
36
|
+
"is_version_of",
|
|
37
|
+
"is_new_version_of",
|
|
38
|
+
"is_previous_version_of",
|
|
39
|
+
"is_part_of",
|
|
40
|
+
"has_part",
|
|
41
|
+
"is_published_in",
|
|
42
|
+
"is_referenced_by",
|
|
43
|
+
"references",
|
|
44
|
+
"is_documented_by",
|
|
45
|
+
"documents",
|
|
46
|
+
"is_compiled_by",
|
|
47
|
+
"compiles",
|
|
48
|
+
"is_variant_form_of",
|
|
49
|
+
"is_original_form_of",
|
|
50
|
+
"is_identical_to",
|
|
51
|
+
"is_reviewed_by",
|
|
52
|
+
"reviews",
|
|
53
|
+
"is_derived_from",
|
|
54
|
+
"is_source_of",
|
|
55
|
+
"is_required_by",
|
|
56
|
+
"requires",
|
|
57
|
+
"obsoletes",
|
|
58
|
+
"is_obsoleted_by",
|
|
59
|
+
"is_collected_by",
|
|
60
|
+
"collects",
|
|
61
|
+
"is_translation_of",
|
|
62
|
+
"has_translation"
|
|
63
|
+
];
|
|
64
|
+
// Work types are derived from the DataCite schema
|
|
65
|
+
const workTypes = [
|
|
66
|
+
"audiovisual",
|
|
67
|
+
"book",
|
|
68
|
+
"book_chapter",
|
|
69
|
+
"collection",
|
|
70
|
+
"computational_notebook",
|
|
71
|
+
"conference_paper",
|
|
72
|
+
"conference_proceeding",
|
|
73
|
+
"data_paper",
|
|
74
|
+
"dataset",
|
|
75
|
+
"dissertation",
|
|
76
|
+
"event",
|
|
77
|
+
"image",
|
|
78
|
+
"instrument",
|
|
79
|
+
"interactive_resource",
|
|
80
|
+
"journal",
|
|
81
|
+
"journal_article",
|
|
82
|
+
"model",
|
|
83
|
+
"output_management_plan",
|
|
84
|
+
"peer_review",
|
|
85
|
+
"physical_object",
|
|
86
|
+
"preprint",
|
|
87
|
+
"project",
|
|
88
|
+
"report",
|
|
89
|
+
"service",
|
|
90
|
+
"software",
|
|
91
|
+
"sound",
|
|
92
|
+
"standard",
|
|
93
|
+
"study_registration",
|
|
94
|
+
"text",
|
|
95
|
+
"workflow",
|
|
96
|
+
"other"
|
|
97
|
+
];
|
|
98
|
+
const ResearchDomainSchema = zod_1.z.object({
|
|
99
|
+
// The human-readable name for the research domain
|
|
100
|
+
name: zod_1.z.string(),
|
|
101
|
+
// The identifier for the research domain
|
|
102
|
+
research_domain_identifier: zod_1.z.object({
|
|
103
|
+
identifier: zod_1.z.string().optional(),
|
|
104
|
+
type: zod_1.z.enum(['ark', 'doi', 'handle', 'url', 'other']).default('url')
|
|
105
|
+
}),
|
|
106
|
+
});
|
|
107
|
+
const RelatedIdentifierSchema = zod_1.z.object({
|
|
108
|
+
// The description of how the DMP is related to the work (e.g. the DMP "cites" the work)
|
|
109
|
+
descriptor: zod_1.z.enum(relationTypes).default('cites'),
|
|
110
|
+
// The identifier of the work
|
|
111
|
+
identifier: zod_1.z.string(),
|
|
112
|
+
// The type of identifier
|
|
113
|
+
type: zod_1.z.enum(['ark', 'doi', 'handle', 'url']).default('url'),
|
|
114
|
+
// The type of the work
|
|
115
|
+
work_type: zod_1.z.enum(workTypes).default('dataset'),
|
|
116
|
+
});
|
|
117
|
+
const ResearchFacilitySchema = zod_1.z.object({
|
|
118
|
+
// The human-readable name of the research facility
|
|
119
|
+
name: zod_1.z.string(),
|
|
120
|
+
// The facility type
|
|
121
|
+
type: zod_1.z.enum(researchFacilityTypes).default('other'),
|
|
122
|
+
// The identifier for the research facility
|
|
123
|
+
research_facility_identifier: zod_1.z.object({
|
|
124
|
+
identifier: zod_1.z.string(),
|
|
125
|
+
type: zod_1.z.enum(['ark', 'doi', 'handle', 'url', 'other']).default('url')
|
|
126
|
+
}),
|
|
127
|
+
});
|
|
128
|
+
const FundingOpportunitySchema = zod_1.z.object({
|
|
129
|
+
// The id of the project this opportunity maps to
|
|
130
|
+
project_id: zod_1.z.object({
|
|
131
|
+
identifier: zod_1.z.string(),
|
|
132
|
+
type: zod_1.z.enum(['ark', 'doi', 'handle', 'url', 'other']).default('other')
|
|
133
|
+
}),
|
|
134
|
+
// The id of the funding this opportunity maps to within the project
|
|
135
|
+
funder_id: zod_1.z.object({
|
|
136
|
+
identifier: zod_1.z.string(),
|
|
137
|
+
type: zod_1.z.enum(['ror', 'url', 'other']).default('ror')
|
|
138
|
+
}),
|
|
139
|
+
// The opportunity id
|
|
140
|
+
opportunity_identifier: zod_1.z.object({
|
|
141
|
+
identifier: zod_1.z.string(),
|
|
142
|
+
type: zod_1.z.enum(['ark', 'doi', 'handle', 'url', 'other']).default('url')
|
|
143
|
+
})
|
|
144
|
+
});
|
|
145
|
+
const VersionSchema = zod_1.z.object({
|
|
146
|
+
// URL to fetch the historical version of the DMP
|
|
147
|
+
access_url: zod_1.z.string(),
|
|
148
|
+
// The date of the version
|
|
149
|
+
version_date: zod_1.z.iso.datetime(),
|
|
150
|
+
});
|
|
151
|
+
const NarrativeAnswerSchema = zod_1.z.object({
|
|
152
|
+
id: zod_1.z.number(),
|
|
153
|
+
json: answers_1.AnyAnswerSchema,
|
|
154
|
+
});
|
|
155
|
+
const DefaultAnswer = NarrativeAnswerSchema.parse({
|
|
156
|
+
id: 0,
|
|
157
|
+
json: answers_1.DefaultTextAreaAnswer
|
|
158
|
+
});
|
|
159
|
+
const NarrativeQuestionSchema = zod_1.z.object({
|
|
160
|
+
id: zod_1.z.number(),
|
|
161
|
+
order: zod_1.z.number(),
|
|
162
|
+
text: zod_1.z.string(),
|
|
163
|
+
answer: NarrativeAnswerSchema.optional(),
|
|
164
|
+
});
|
|
165
|
+
const DefaultQuestion = NarrativeQuestionSchema.parse({
|
|
166
|
+
id: 0,
|
|
167
|
+
order: 0,
|
|
168
|
+
text: 'Undefined question text',
|
|
169
|
+
answer: DefaultAnswer
|
|
170
|
+
});
|
|
171
|
+
const NarrativeSectionSchema = zod_1.z.object({
|
|
172
|
+
id: zod_1.z.number(),
|
|
173
|
+
order: zod_1.z.number(),
|
|
174
|
+
title: zod_1.z.string(),
|
|
175
|
+
description: zod_1.z.string().optional(),
|
|
176
|
+
question: zod_1.z.array(NarrativeQuestionSchema)
|
|
177
|
+
});
|
|
178
|
+
const DefaultSection = NarrativeSectionSchema.parse({
|
|
179
|
+
id: 0,
|
|
180
|
+
order: 0,
|
|
181
|
+
title: 'Undefined section',
|
|
182
|
+
question: [DefaultQuestion]
|
|
183
|
+
});
|
|
184
|
+
const NarrativeTemplateSchema = zod_1.z.object({
|
|
185
|
+
id: zod_1.z.number(),
|
|
186
|
+
title: zod_1.z.string(),
|
|
187
|
+
description: zod_1.z.string().optional(),
|
|
188
|
+
version: zod_1.z.string().optional(),
|
|
189
|
+
section: zod_1.z.array(NarrativeSectionSchema)
|
|
190
|
+
});
|
|
191
|
+
const DefaultNarrativeTemplate = NarrativeTemplateSchema.parse({
|
|
192
|
+
id: 0,
|
|
193
|
+
title: 'Undefined template',
|
|
194
|
+
section: [DefaultSection]
|
|
195
|
+
});
|
|
196
|
+
// URLs to fetch the narrative as a document other than JSON
|
|
197
|
+
const NarrativeURLsSchema = zod_1.z.object({
|
|
198
|
+
csv: zod_1.z.string().optional(),
|
|
199
|
+
docx: zod_1.z.string().optional(),
|
|
200
|
+
html: zod_1.z.string().optional(),
|
|
201
|
+
pdf: zod_1.z.string().optional(),
|
|
202
|
+
});
|
|
203
|
+
const NarrativeSchema = zod_1.z.object({
|
|
204
|
+
download_urls: NarrativeURLsSchema.optional(),
|
|
205
|
+
template: NarrativeTemplateSchema.optional(),
|
|
206
|
+
});
|
|
207
|
+
exports.DefaultNarrative = NarrativeSchema.parse({
|
|
208
|
+
template: DefaultNarrativeTemplate
|
|
209
|
+
});
|
|
210
|
+
exports.ExtensionSchema = zod_1.z.object({
|
|
211
|
+
// The name of the system that owns this record
|
|
212
|
+
provenance: zod_1.z.string(),
|
|
213
|
+
// The visibility setting for the DMP
|
|
214
|
+
privacy: zod_1.z.enum(visibilityTypes).default('private'),
|
|
215
|
+
// Whether the DMP is featured on the public plans page of the DMP Tool website
|
|
216
|
+
featured: zod_1.z.enum(['yes', 'no']).default('no'),
|
|
217
|
+
// The date the DMP Id was registered as a DOI with EZID/DataCite
|
|
218
|
+
registered: zod_1.z.iso.datetime().optional(),
|
|
219
|
+
// The narrative content of the DMP expressed as a JSON object
|
|
220
|
+
narrative: NarrativeSchema.optional(),
|
|
221
|
+
// The research domain of the project/DMP
|
|
222
|
+
research_domain: ResearchDomainSchema.optional(),
|
|
223
|
+
// Other works related to the DMP
|
|
224
|
+
related_identifier: zod_1.z.array(RelatedIdentifierSchema).optional(),
|
|
225
|
+
// Research facilities used to collect or process data
|
|
226
|
+
research_facility: zod_1.z.array(ResearchFacilitySchema).optional(),
|
|
227
|
+
// Historical versions of the DMP
|
|
228
|
+
version: zod_1.z.array(VersionSchema).optional(),
|
|
229
|
+
// Funding opportunity / call for grant submissions related to the funding
|
|
230
|
+
funding_opportunity: zod_1.z.array(FundingOpportunitySchema).optional(),
|
|
231
|
+
});
|
|
232
|
+
exports.DefaultExtensionSchema = exports.ExtensionSchema.parse({
|
|
233
|
+
provenance: 'your-application',
|
|
234
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { FromSchema } from "json-schema-to-ts";
|
|
3
|
+
import { ExtensionType } from "./extension";
|
|
4
|
+
declare const jsonSchema: any;
|
|
5
|
+
export declare const RDACommonStandardDMPJSONSchema: any;
|
|
6
|
+
export type RDACommonStandardDMPType = FromSchema<typeof jsonSchema>;
|
|
7
|
+
export type DMPToolDMPType = RDACommonStandardDMPType & ExtensionType;
|
|
8
|
+
export declare const ExtensionJSONSchema: z.core.JSONSchema.JSONSchema;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ExtensionJSONSchema = exports.RDACommonStandardDMPJSONSchema = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const extension_1 = require("./extension");
|
|
10
|
+
// The RDA Common Standard for DMPs JSON schema is automatically downloaded by
|
|
11
|
+
// scripts/importRDACommonStandard.ts script. This file fetches the specified
|
|
12
|
+
// version of the schema and places it into the schemas/ directory.
|
|
13
|
+
//
|
|
14
|
+
// At this time, there is a PR to add support for converting a JSON Schema into
|
|
15
|
+
// a Zod schema, but it is not there yet.
|
|
16
|
+
//
|
|
17
|
+
// Convert the downloaded JSON schema into types
|
|
18
|
+
const RDA_COMMON_STANDARD_JSON_FILE = './schemas/dmp.schema.json';
|
|
19
|
+
// Ignoring ESLint here because it doesn't like that we're only using jsonSchema as a Type
|
|
20
|
+
// but that's exactly what we want to do.
|
|
21
|
+
const jsonSchema = JSON.parse(fs_1.default.readFileSync(RDA_COMMON_STANDARD_JSON_FILE, 'utf8'));
|
|
22
|
+
exports.RDACommonStandardDMPJSONSchema = jsonSchema;
|
|
23
|
+
exports.ExtensionJSONSchema = zod_1.z.toJSONSchema(extension_1.ExtensionSchema);
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
// Export All the Zod schemas and types
|
|
18
18
|
__exportStar(require("./answers"), exports);
|
|
19
|
+
__exportStar(require("./dmp"), exports);
|
|
19
20
|
__exportStar(require("./questions"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|