@dmptool/types 1.2.3 → 1.2.5
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 +8 -0
- package/dist/answers/__tests__/answers.spec.js +122 -6
- package/dist/answers/answer.d.ts +3 -3
- package/dist/answers/graphQLAnswers.d.ts +120 -25
- package/dist/answers/graphQLAnswers.js +22 -5
- package/dist/answers/index.d.ts +399 -31
- package/dist/answers/index.js +8 -2
- package/dist/answers/numberAnswers.d.ts +40 -0
- package/dist/answers/numberAnswers.js +8 -1
- package/dist/answers/tableAnswers.d.ts +1688 -75
- package/dist/answers/tableAnswers.js +63 -2
- package/dist/questions/__tests__/graphQLQuestions.spec.js +177 -39
- package/dist/questions/__tests__/numberQuestions.spec.js +36 -0
- package/dist/questions/__tests__/tableQuestion.spec.js +145 -0
- package/dist/questions/__tests__/usage.spec.js +162 -1
- package/dist/questions/graphQLQuestions.d.ts +420 -60
- package/dist/questions/graphQLQuestions.js +257 -11
- package/dist/questions/index.d.ts +4849 -189
- package/dist/questions/index.js +9 -2
- package/dist/questions/numberQuestions.d.ts +105 -0
- package/dist/questions/numberQuestions.js +12 -1
- package/dist/questions/question.d.ts +4 -4
- package/dist/questions/question.js +25 -4
- package/dist/questions/tableQuestions.d.ts +5930 -679
- package/dist/questions/tableQuestions.js +188 -3
- package/dist/schemas/anyAnswer.schema.json +137 -17
- package/dist/schemas/anyQuestion.schema.json +847 -101
- package/dist/schemas/anyTableColumnAnswer.schema.json +116 -5
- package/dist/schemas/anyTableColumnQuestion.schema.json +326 -24
- package/dist/schemas/licenseSearchAnswer.schema.json +49 -0
- package/dist/schemas/licenseSearchQuestion.schema.json +164 -0
- package/dist/schemas/metadataStandardSearchAnswer.schema.json +49 -0
- package/dist/schemas/metadataStandardSearchQuestion.schema.json +174 -0
- package/dist/schemas/numberWithContextAnswer.schema.json +45 -0
- package/dist/schemas/numberWithContextQuestion.schema.json +84 -0
- package/dist/schemas/repositorySearchAnswer.schema.json +49 -0
- package/dist/schemas/repositorySearchQuestion.schema.json +180 -0
- package/dist/schemas/researchOutputTableAnswer.schema.json +519 -0
- package/dist/schemas/researchOutputTableQuestion.schema.json +1183 -0
- package/dist/schemas/tableAnswer.schema.json +116 -5
- package/dist/schemas/tableQuestion.schema.json +348 -24
- package/package.json +9 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TableAnswerSchema = exports.TableRowAnswerSchema = exports.AnyTableColumnAnswerSchema = void 0;
|
|
3
|
+
exports.ResearchOutputTableAnswerSchema = exports.TableAnswerSchema = exports.TableRowAnswerSchema = 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");
|
|
@@ -18,10 +18,13 @@ exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
|
|
|
18
18
|
dateAnswers_1.DateAnswerSchema,
|
|
19
19
|
dateAnswers_1.DateRangeAnswerSchema,
|
|
20
20
|
textAnswers_1.EmailAnswerSchema,
|
|
21
|
-
graphQLAnswers_1.
|
|
21
|
+
graphQLAnswers_1.LicenseSearchAnswerSchema,
|
|
22
|
+
graphQLAnswers_1.MetadataStandardSearchAnswerSchema,
|
|
22
23
|
optionBasedAnswers_1.MultiselectBoxAnswerSchema,
|
|
23
24
|
numberAnswers_1.NumberAnswerSchema,
|
|
25
|
+
numberAnswers_1.NumberWithContextAnswerSchema,
|
|
24
26
|
optionBasedAnswers_1.RadioButtonsAnswerSchema,
|
|
27
|
+
graphQLAnswers_1.RepositorySearchAnswerSchema,
|
|
25
28
|
optionBasedAnswers_1.SelectBoxAnswerSchema,
|
|
26
29
|
textAnswers_1.TextAnswerSchema,
|
|
27
30
|
textAnswers_1.TextAreaAnswerSchema,
|
|
@@ -42,3 +45,61 @@ exports.TableAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
|
|
|
42
45
|
}]
|
|
43
46
|
}])
|
|
44
47
|
}));
|
|
48
|
+
exports.ResearchOutputTableAnswerSchema = exports.TableAnswerSchema.merge(zod_1.z.object({
|
|
49
|
+
type: zod_1.z.literal('researchOutputTable'),
|
|
50
|
+
columnHeadings: zod_1.z.array(zod_1.z.string()).default(['Title', 'Output Type']),
|
|
51
|
+
answer: zod_1.z.array(exports.TableRowAnswerSchema).default([{
|
|
52
|
+
columns: [
|
|
53
|
+
{
|
|
54
|
+
type: 'text',
|
|
55
|
+
answer: '',
|
|
56
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'textArea',
|
|
60
|
+
answer: '',
|
|
61
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'selectBox',
|
|
65
|
+
answer: '',
|
|
66
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type: 'checkBoxes',
|
|
70
|
+
answer: [],
|
|
71
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
type: 'selectBox',
|
|
75
|
+
answer: '',
|
|
76
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'date',
|
|
80
|
+
answer: '',
|
|
81
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
type: 'numberWithContext',
|
|
85
|
+
answer: { value: undefined, context: '' },
|
|
86
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'repositorySearch',
|
|
90
|
+
answer: [],
|
|
91
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
type: 'metadataStandardSearch',
|
|
95
|
+
answer: [],
|
|
96
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
type: 'licenseSearch',
|
|
100
|
+
answer: [],
|
|
101
|
+
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}])
|
|
105
|
+
}));
|
|
@@ -2,94 +2,232 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const globals_1 = require("@jest/globals");
|
|
4
4
|
const graphQLQuestions_1 = require("../graphQLQuestions");
|
|
5
|
-
(0, globals_1.describe)("
|
|
6
|
-
(0, globals_1.it)("should validate a correct
|
|
5
|
+
(0, globals_1.describe)("AffiliationSearchQuestion schema", () => {
|
|
6
|
+
(0, globals_1.it)("should validate a correct AffiliationSearchQuestion object", () => {
|
|
7
7
|
const validData = {
|
|
8
|
-
type: "
|
|
8
|
+
type: "affiliationSearch",
|
|
9
|
+
attributes: {
|
|
10
|
+
label: "Search",
|
|
11
|
+
help: "Search for a institution",
|
|
12
|
+
},
|
|
9
13
|
graphQL: {
|
|
14
|
+
query: graphQLQuestions_1.affiliationQuery,
|
|
10
15
|
displayFields: [
|
|
11
|
-
{ propertyName: "
|
|
12
|
-
{ propertyName: "age", label: "Age", labelTranslationKey: "age_key" },
|
|
16
|
+
{ propertyName: "displayName", label: "Name" },
|
|
13
17
|
],
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
localQueryId: "12345",
|
|
19
|
+
answerField: "uri",
|
|
20
|
+
responseField: "affiliations.items",
|
|
16
21
|
variables: [
|
|
17
|
-
{
|
|
18
|
-
{ name: "minAge", type: "number", minLength: 1 },
|
|
22
|
+
{ type: "string", name: "name", label: "Term", minLength: 3 },
|
|
19
23
|
],
|
|
20
24
|
},
|
|
21
|
-
attributes: {
|
|
22
|
-
label: "Search",
|
|
23
|
-
help: "Search for a user",
|
|
24
|
-
multiple: true,
|
|
25
|
-
},
|
|
26
25
|
meta: {
|
|
27
26
|
schemaVersion: "1.0"
|
|
28
27
|
}
|
|
29
28
|
};
|
|
30
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
29
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.AffiliationSearchQuestionSchema.parse(validData)).not.toThrow();
|
|
31
30
|
});
|
|
32
|
-
(0, globals_1.it)("should throw an error for an invalid
|
|
31
|
+
(0, globals_1.it)("should throw an error for an invalid AffiliationSearchQuestion object", () => {
|
|
33
32
|
const invalidData = {
|
|
34
|
-
type: "
|
|
33
|
+
type: "affiliationSearch",
|
|
35
34
|
graphQL: {
|
|
36
35
|
displayFields: [
|
|
37
|
-
{ propertyName: "
|
|
36
|
+
{ propertyName: "title", label: "Title" },
|
|
38
37
|
],
|
|
39
|
-
responseField: "
|
|
38
|
+
responseField: "results",
|
|
40
39
|
variables: [
|
|
41
|
-
{ name: "
|
|
40
|
+
{ name: "query", type: 123 }, // Invalid type
|
|
42
41
|
],
|
|
43
42
|
},
|
|
43
|
+
};
|
|
44
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.AffiliationSearchQuestionSchema.parse(invalidData)).toThrow();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
(0, globals_1.describe)("LicenseSearchQuestion schema", () => {
|
|
48
|
+
(0, globals_1.it)("should validate a correct LicenseSearchQuestion object", () => {
|
|
49
|
+
const validData = {
|
|
50
|
+
type: "licenseSearch",
|
|
44
51
|
attributes: {
|
|
45
|
-
|
|
52
|
+
label: "License Search",
|
|
53
|
+
help: "Search for a license",
|
|
54
|
+
},
|
|
55
|
+
graphQL: {
|
|
56
|
+
query: "query Licenses($term: String, $paginationOptions: PaginationOptions){ license(term: $term, paginationOptions: $paginationOptions) { totalCount currentOffset limit hasNextPage hasPreviousPage availableSortFields items { id name uri description } } }",
|
|
57
|
+
displayFields: [
|
|
58
|
+
{
|
|
59
|
+
propertyName: "name",
|
|
60
|
+
label: "Name"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
propertyName: "description",
|
|
64
|
+
label: "Description"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
propertyName: "recommended",
|
|
68
|
+
label: "Recommended"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
answerField: "uri",
|
|
72
|
+
responseField: "licenses.items",
|
|
73
|
+
variables: [
|
|
74
|
+
{
|
|
75
|
+
type: "string",
|
|
76
|
+
name: "term",
|
|
77
|
+
label: "Search term",
|
|
78
|
+
minLength: 2
|
|
79
|
+
},
|
|
80
|
+
],
|
|
46
81
|
},
|
|
47
82
|
meta: {
|
|
48
83
|
schemaVersion: "1.0"
|
|
49
84
|
}
|
|
50
85
|
};
|
|
51
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
86
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.LicenseSearchQuestionSchema.parse(validData)).not.toThrow();
|
|
87
|
+
});
|
|
88
|
+
(0, globals_1.it)("should throw an error for an invalid LicenseSearchQuestion object", () => {
|
|
89
|
+
const invalidData = {
|
|
90
|
+
type: "licenseSearch",
|
|
91
|
+
graphQL: {
|
|
92
|
+
displayFields: [],
|
|
93
|
+
query: 'myInvalidQuery { licenses { id name } }',
|
|
94
|
+
variables: [
|
|
95
|
+
{
|
|
96
|
+
name: "term",
|
|
97
|
+
type: "invalid"
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.LicenseSearchQuestionSchema.parse(invalidData)).toThrow();
|
|
52
103
|
});
|
|
53
104
|
});
|
|
54
|
-
(0, globals_1.describe)("
|
|
55
|
-
(0, globals_1.it)("should validate a correct
|
|
105
|
+
(0, globals_1.describe)("MetadataStandardSearchQuestion schema", () => {
|
|
106
|
+
(0, globals_1.it)("should validate a correct MetadataStandardSearchQuestion object", () => {
|
|
56
107
|
const validData = {
|
|
57
|
-
type: "
|
|
108
|
+
type: "metadataStandardSearch",
|
|
58
109
|
attributes: {
|
|
59
|
-
label: "Search",
|
|
60
|
-
help: "Search for a
|
|
110
|
+
label: "Metadata Standard Search",
|
|
111
|
+
help: "Search for a metadata standard",
|
|
61
112
|
},
|
|
62
113
|
graphQL: {
|
|
63
|
-
query:
|
|
114
|
+
query: "query MetadataStandards($term: String, $keywords: [String!], $paginationOptions: PaginationOptions){ metadataStandards(term: $term, keywords: $keywords, paginationOptions: $paginationOptions) { totalCount currentOffset limit hasNextPage hasPreviousPage availableSortFields items { id name uri description keywords } } }",
|
|
64
115
|
displayFields: [
|
|
65
|
-
{
|
|
116
|
+
{
|
|
117
|
+
propertyName: "name",
|
|
118
|
+
label: "Name"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
propertyName: "description",
|
|
122
|
+
label: "Description"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
propertyName: "website",
|
|
126
|
+
label: "Website"
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
propertyName: "keywords",
|
|
130
|
+
label: "Subject Areas"
|
|
131
|
+
}
|
|
66
132
|
],
|
|
67
|
-
localQueryId: "12345",
|
|
68
133
|
answerField: "uri",
|
|
69
|
-
responseField: "
|
|
134
|
+
responseField: "metadataStandards.items",
|
|
70
135
|
variables: [
|
|
71
|
-
{
|
|
136
|
+
{
|
|
137
|
+
type: "string",
|
|
138
|
+
name: "term",
|
|
139
|
+
label: "Search term",
|
|
140
|
+
minLength: 2
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: "string",
|
|
144
|
+
name: "keywords",
|
|
145
|
+
label: "Subject Areas"
|
|
146
|
+
}
|
|
72
147
|
],
|
|
73
148
|
},
|
|
74
149
|
meta: {
|
|
75
150
|
schemaVersion: "1.0"
|
|
76
151
|
}
|
|
77
152
|
};
|
|
78
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
153
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.MetadataStandardSearchQuestionSchema.parse(validData)).not.toThrow();
|
|
79
154
|
});
|
|
80
|
-
(0, globals_1.it)("should throw an error for an invalid
|
|
155
|
+
(0, globals_1.it)("should throw an error for an invalid MetadataStandardSearchQuestion object", () => {
|
|
81
156
|
const invalidData = {
|
|
82
|
-
type: "
|
|
157
|
+
type: "metadataStandardSearch",
|
|
158
|
+
graphQL: {
|
|
159
|
+
query: 123,
|
|
160
|
+
variables: [],
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.MetadataStandardSearchQuestionSchema.parse(invalidData)).toThrow();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
(0, globals_1.describe)("RepositorySearchQuestion schema", () => {
|
|
167
|
+
(0, globals_1.it)("should validate a correct RepositorySearchQuestion object", () => {
|
|
168
|
+
const validData = {
|
|
169
|
+
type: "repositorySearch",
|
|
170
|
+
attributes: {
|
|
171
|
+
label: "Repository Search",
|
|
172
|
+
help: "Search for a repository",
|
|
173
|
+
},
|
|
83
174
|
graphQL: {
|
|
175
|
+
query: "query Repositories($term: String, $keywords: [String!], $repositoryType: String, $paginationOptions: PaginationOptions){ repositories(term: $term, keywords: $keywords, repositoryType: $repositoryType, paginationOptions: $paginationOptions) { totalCount currentOffset limit hasNextPage hasPreviousPage availableSortFields items { id name uri description website keywords repositoryTypes } } }",
|
|
84
176
|
displayFields: [
|
|
85
|
-
{
|
|
177
|
+
{
|
|
178
|
+
propertyName: "name",
|
|
179
|
+
label: "Name"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
propertyName: "description",
|
|
183
|
+
label: "Description"
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
propertyName: "website",
|
|
187
|
+
label: "Website"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
propertyName: "keywords",
|
|
191
|
+
label: "Subject Areas"
|
|
192
|
+
}
|
|
86
193
|
],
|
|
87
|
-
|
|
194
|
+
answerField: "uri",
|
|
195
|
+
responseField: "repositories.items",
|
|
88
196
|
variables: [
|
|
89
|
-
{
|
|
197
|
+
{
|
|
198
|
+
type: "string",
|
|
199
|
+
name: "term",
|
|
200
|
+
label: "Search term",
|
|
201
|
+
minLength: 2
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
type: "string",
|
|
205
|
+
name: "repositoryType",
|
|
206
|
+
label: "Repository Type"
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: "string",
|
|
210
|
+
name: "keywords",
|
|
211
|
+
label: "Subject Areas"
|
|
212
|
+
}
|
|
90
213
|
],
|
|
91
214
|
},
|
|
215
|
+
meta: {
|
|
216
|
+
schemaVersion: "1.0"
|
|
217
|
+
}
|
|
92
218
|
};
|
|
93
|
-
(0, globals_1.expect)(() => graphQLQuestions_1.
|
|
219
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.RepositorySearchQuestionSchema.parse(validData)).not.toThrow();
|
|
220
|
+
});
|
|
221
|
+
(0, globals_1.it)("should throw an error for an invalid RepositorySearchQuestion object", () => {
|
|
222
|
+
const invalidData = {
|
|
223
|
+
type: "repositorySearch",
|
|
224
|
+
graphQL: {
|
|
225
|
+
responseField: 123,
|
|
226
|
+
variables: [
|
|
227
|
+
{ type: "unknown" },
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
(0, globals_1.expect)(() => graphQLQuestions_1.RepositorySearchQuestionSchema.parse(invalidData)).toThrow();
|
|
94
232
|
});
|
|
95
233
|
});
|
|
@@ -105,4 +105,40 @@ describe("Number Questions Zod Schemas", () => {
|
|
|
105
105
|
};
|
|
106
106
|
expect(() => numberQuestions_1.NumberRangeQuestionSchema.parse(invalidNumberRangeQuestion)).toThrow();
|
|
107
107
|
});
|
|
108
|
+
it("should validate a valid NumberWithContext", () => {
|
|
109
|
+
const validNumberQuestion = {
|
|
110
|
+
type: "numberWithContext",
|
|
111
|
+
meta: {
|
|
112
|
+
schemaVersion: "1.0",
|
|
113
|
+
},
|
|
114
|
+
attributes: {
|
|
115
|
+
max: 100,
|
|
116
|
+
min: 0,
|
|
117
|
+
step: 1,
|
|
118
|
+
context: [
|
|
119
|
+
{
|
|
120
|
+
label: "MB (megabytes)",
|
|
121
|
+
value: "mb",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
label: "GB (gigabytes)",
|
|
125
|
+
value: "gb",
|
|
126
|
+
},
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
expect(() => numberQuestions_1.NumberWithContextQuestionSchema.parse(validNumberQuestion)).not.toThrow();
|
|
131
|
+
});
|
|
132
|
+
it("should invalidate an invalid NumberWithContext", () => {
|
|
133
|
+
const invalidNumberQuestion = {
|
|
134
|
+
type: "numberWithContext",
|
|
135
|
+
meta: {
|
|
136
|
+
schemaVersion: "1.0",
|
|
137
|
+
},
|
|
138
|
+
attributes: {
|
|
139
|
+
step: "1", // Invalid type
|
|
140
|
+
},
|
|
141
|
+
};
|
|
142
|
+
expect(() => numberQuestions_1.NumberWithContextQuestionSchema.parse(invalidNumberQuestion)).toThrow();
|
|
143
|
+
});
|
|
108
144
|
});
|
|
@@ -73,3 +73,148 @@ describe("TableQuestionSchema", () => {
|
|
|
73
73
|
expect(() => tableQuestions_1.TableQuestionSchema.parse(invalidTableQuestion)).toThrow();
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
|
+
describe("ResearchOutputTableQuestionSchema", () => {
|
|
77
|
+
it("should validate a valid ResearchOutputTableQuestion object", () => {
|
|
78
|
+
const validResearchOutputTableQuestion = {
|
|
79
|
+
type: "researchOutputTable",
|
|
80
|
+
columns: [
|
|
81
|
+
{
|
|
82
|
+
heading: "Title",
|
|
83
|
+
required: true,
|
|
84
|
+
enabled: true,
|
|
85
|
+
content: {
|
|
86
|
+
type: "text",
|
|
87
|
+
meta: {
|
|
88
|
+
schemaVersion: "1.0"
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
heading: "Output Type",
|
|
94
|
+
required: true,
|
|
95
|
+
enabled: true,
|
|
96
|
+
content: {
|
|
97
|
+
type: "selectBox",
|
|
98
|
+
attributes: {
|
|
99
|
+
multiple: false
|
|
100
|
+
},
|
|
101
|
+
options: [
|
|
102
|
+
{ label: "Foo", value: "foo" },
|
|
103
|
+
{ label: "Bar", value: "bar" }
|
|
104
|
+
],
|
|
105
|
+
meta: {
|
|
106
|
+
schemaVersion: "1.0"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
heading: "Byte Size",
|
|
112
|
+
required: false,
|
|
113
|
+
enabled: true,
|
|
114
|
+
content: {
|
|
115
|
+
type: "numberWithContext",
|
|
116
|
+
attributes: {
|
|
117
|
+
min: 0,
|
|
118
|
+
step: 1,
|
|
119
|
+
context: [
|
|
120
|
+
{ label: 'bytes', value: 'bytes' },
|
|
121
|
+
{ label: 'KB (kilobytes)', value: 'kb' },
|
|
122
|
+
{ label: 'MB (megabytes)', value: 'mb' },
|
|
123
|
+
{ label: 'GB (gigabytes)', value: 'gb' },
|
|
124
|
+
{ label: 'TB (terabytes)', value: 'tb' },
|
|
125
|
+
{ label: 'PB (petabytes)', value: 'pb' }
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
meta: {
|
|
129
|
+
schemaVersion: "1.0"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
heading: "Repositories",
|
|
135
|
+
required: false,
|
|
136
|
+
enabled: true,
|
|
137
|
+
preferences: [
|
|
138
|
+
{ label: "Repository 1", value: "https://repo.example.com/1" },
|
|
139
|
+
{ label: "Repository 2", value: "https://repo.example.com/2" }
|
|
140
|
+
],
|
|
141
|
+
content: {
|
|
142
|
+
type: "repositorySearch",
|
|
143
|
+
attributes: {
|
|
144
|
+
label: "Repository Search",
|
|
145
|
+
help: "Search for a repository",
|
|
146
|
+
},
|
|
147
|
+
graphQL: {
|
|
148
|
+
query: "query Repositories($term: String, $keywords: [String!], $repositoryType: String, $paginationOptions: PaginationOptions){ repositories(term: $term, keywords: $keywords, repositoryType: $repositoryType, paginationOptions: $paginationOptions) { totalCount currentOffset limit hasNextPage hasPreviousPage availableSortFields items { id name uri description website keywords repositoryTypes } } }",
|
|
149
|
+
displayFields: [
|
|
150
|
+
{
|
|
151
|
+
propertyName: "name",
|
|
152
|
+
label: "Name"
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
propertyName: "description",
|
|
156
|
+
label: "Description"
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
propertyName: "website",
|
|
160
|
+
label: "Website"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
propertyName: "keywords",
|
|
164
|
+
label: "Subject Areas"
|
|
165
|
+
}
|
|
166
|
+
],
|
|
167
|
+
answerField: "uri",
|
|
168
|
+
responseField: "repositories.items",
|
|
169
|
+
variables: [
|
|
170
|
+
{
|
|
171
|
+
type: "string",
|
|
172
|
+
name: "term",
|
|
173
|
+
label: "Search term",
|
|
174
|
+
minLength: 2
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
type: "string",
|
|
178
|
+
name: "repositoryType",
|
|
179
|
+
label: "Repository Type"
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
type: "string",
|
|
183
|
+
name: "keywords",
|
|
184
|
+
label: "Subject Areas"
|
|
185
|
+
}
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
meta: {
|
|
189
|
+
schemaVersion: "1.0"
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
],
|
|
194
|
+
meta: {
|
|
195
|
+
schemaVersion: "1.0"
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
expect(() => tableQuestions_1.ResearchOutputTableQuestionSchema.parse(validResearchOutputTableQuestion)).not.toThrow();
|
|
199
|
+
});
|
|
200
|
+
it("should throw an error for an invalid ResearchOutputTableQuestion object", () => {
|
|
201
|
+
const invalidResearchOutputTableQuestion = {
|
|
202
|
+
type: "researchOutputTable",
|
|
203
|
+
columns: [
|
|
204
|
+
{
|
|
205
|
+
heading: "Title",
|
|
206
|
+
content: {
|
|
207
|
+
type: "invalid",
|
|
208
|
+
meta: {
|
|
209
|
+
schemaVersion: "1.0"
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
meta: {
|
|
215
|
+
schemaVersion: "1.0"
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
expect(() => tableQuestions_1.ResearchOutputTableQuestionSchema.parse(invalidResearchOutputTableQuestion)).toThrow();
|
|
219
|
+
});
|
|
220
|
+
});
|