@dmptool/types 2.1.0 → 2.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.
- package/README.md +70 -1
- package/dist/answers/__tests__/defaults.spec.js +80 -21
- package/dist/answers/answer.d.ts +2 -0
- package/dist/answers/answer.js +4 -2
- package/dist/answers/dateAnswers.d.ts +4 -0
- package/dist/answers/graphQLAnswers.d.ts +8 -0
- package/dist/answers/index.d.ts +37 -0
- package/dist/answers/numberAnswers.d.ts +8 -0
- package/dist/answers/optionBasedAnswers.d.ts +10 -0
- package/dist/answers/tableAnswers.d.ts +94 -0
- package/dist/answers/textAnswers.d.ts +8 -0
- package/dist/dmp/extension.d.ts +111 -0
- package/dist/dmp/index.js +48 -2
- package/dist/questions/__tests__/defaults.spec.js +2 -2
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +8 -4
- package/dist/questions/dateQuestions.d.ts +4 -0
- package/dist/questions/dateQuestions.js +2 -2
- package/dist/questions/index.d.ts +28 -0
- package/dist/questions/numberQuestions.d.ts +8 -0
- package/dist/questions/numberQuestions.js +4 -4
- package/dist/questions/optionBasedQuestions.d.ts +10 -0
- package/dist/questions/optionBasedQuestions.js +5 -5
- package/dist/questions/tableQuestions.d.ts +70 -0
- package/dist/questions/textQuestions.d.ts +4 -0
- package/dist/questions/textQuestions.js +2 -2
- package/dist/schemas/affiliationSearchAnswer.schema.json +3 -0
- package/dist/schemas/anyAnswer.schema.json +111 -0
- package/dist/schemas/anyQuestion.schema.json +84 -0
- package/dist/schemas/anyTableColumnAnswer.schema.json +54 -0
- package/dist/schemas/anyTableColumnQuestion.schema.json +33 -0
- package/dist/schemas/booleanAnswer.schema.json +3 -0
- package/dist/schemas/booleanQuestion.schema.json +3 -0
- package/dist/schemas/checkboxesAnswer.schema.json +3 -0
- package/dist/schemas/checkboxesQuestion.schema.json +3 -0
- package/dist/schemas/currencyAnswer.schema.json +3 -0
- package/dist/schemas/currencyQuestion.schema.json +3 -0
- package/dist/schemas/dateAnswer.schema.json +3 -0
- package/dist/schemas/dateQuestion.schema.json +3 -0
- package/dist/schemas/dateRangeAnswer.schema.json +3 -0
- package/dist/schemas/dateRangeQuestion.schema.json +3 -0
- package/dist/schemas/dmpExtension.schema.json +111 -0
- package/dist/schemas/emailAnswer.schema.json +3 -0
- package/dist/schemas/emailQuestion.schema.json +3 -0
- package/dist/schemas/licenseSearchAnswer.schema.json +3 -0
- package/dist/schemas/metadataStandardSearchAnswer.schema.json +3 -0
- package/dist/schemas/multiselectBoxAnswer.schema.json +3 -0
- package/dist/schemas/multiselectBoxQuestion.schema.json +3 -0
- package/dist/schemas/numberAnswer.schema.json +3 -0
- package/dist/schemas/numberQuestion.schema.json +3 -0
- package/dist/schemas/numberRangeAnswer.schema.json +3 -0
- package/dist/schemas/numberRangeQuestion.schema.json +3 -0
- package/dist/schemas/numberWithContextAnswer.schema.json +3 -0
- package/dist/schemas/numberWithContextQuestion.schema.json +3 -0
- package/dist/schemas/radioButtonsAnswer.schema.json +3 -0
- package/dist/schemas/radioButtonsQuestion.schema.json +3 -0
- package/dist/schemas/repositorySearchAnswer.schema.json +3 -0
- package/dist/schemas/researchOutputTableAnswer.schema.json +3344 -9
- package/dist/schemas/selectBoxAnswer.schema.json +3 -0
- package/dist/schemas/selectBoxQuestion.schema.json +3 -0
- package/dist/schemas/tableAnswer.schema.json +57 -0
- package/dist/schemas/tableQuestion.schema.json +33 -0
- package/dist/schemas/textAnswer.schema.json +3 -0
- package/dist/schemas/textAreaAnswer.schema.json +3 -0
- package/dist/schemas/urlAnswer.schema.json +3 -0
- package/dist/schemas/urlQuestion.schema.json +3 -0
- package/package.json +9 -4
- package/schemas/.placeholder +0 -0
- package/schemas/affiliationSearchAnswer.schema.json +50 -0
- package/schemas/affiliationSearchQuestion.schema.json +142 -0
- package/schemas/anyAnswer.schema.json +1537 -0
- package/schemas/anyQuestion.schema.json +4828 -0
- package/schemas/anyTableColumnAnswer.schema.json +741 -0
- package/schemas/anyTableColumnQuestion.schema.json +1560 -0
- package/schemas/booleanAnswer.schema.json +36 -0
- package/schemas/booleanQuestion.schema.json +55 -0
- package/schemas/checkboxesAnswer.schema.json +41 -0
- package/schemas/checkboxesQuestion.schema.json +80 -0
- package/schemas/currencyAnswer.schema.json +36 -0
- package/schemas/currencyQuestion.schema.json +73 -0
- package/schemas/dateAnswer.schema.json +36 -0
- package/schemas/datePickerAnswer.schema.json +37 -0
- package/schemas/datePickerQuestion.schema.json +52 -0
- package/schemas/dateQuestion.schema.json +66 -0
- package/schemas/dateRangeAnswer.schema.json +50 -0
- package/schemas/dateRangeQuestion.schema.json +124 -0
- package/schemas/dmp.schema.json +2070 -0
- package/schemas/dmpExtension.schema.json +1985 -0
- package/schemas/emailAnswer.schema.json +36 -0
- package/schemas/emailQuestion.schema.json +71 -0
- package/schemas/filteredSearchAnswer.schema.json +40 -0
- package/schemas/filteredSearchQuestion.schema.json +130 -0
- package/schemas/licenseSearchAnswer.schema.json +54 -0
- package/schemas/licenseSearchQuestion.schema.json +140 -0
- package/schemas/metadataStandardSearchAnswer.schema.json +54 -0
- package/schemas/metadataStandardSearchQuestion.schema.json +141 -0
- package/schemas/multiselectBoxAnswer.schema.json +41 -0
- package/schemas/multiselectBoxQuestion.schema.json +87 -0
- package/schemas/numberAnswer.schema.json +36 -0
- package/schemas/numberQuestion.schema.json +68 -0
- package/schemas/numberRangeAnswer.schema.json +50 -0
- package/schemas/numberRangeQuestion.schema.json +128 -0
- package/schemas/numberWithContextAnswer.schema.json +50 -0
- package/schemas/numberWithContextQuestion.schema.json +98 -0
- package/schemas/radioButtonsAnswer.schema.json +36 -0
- package/schemas/radioButtonsQuestion.schema.json +80 -0
- package/schemas/repositorySearchAnswer.schema.json +54 -0
- package/schemas/repositorySearchQuestion.schema.json +140 -0
- package/schemas/researchOutputTableAnswer.schema.json +20065 -0
- package/schemas/researchOutputTableQuestion.schema.json +140 -0
- package/schemas/selectBoxAnswer.schema.json +36 -0
- package/schemas/selectBoxQuestion.schema.json +87 -0
- package/schemas/tableAnswer.schema.json +797 -0
- package/schemas/tableQuestion.schema.json +1662 -0
- package/schemas/textAnswer.schema.json +36 -0
- package/schemas/textAreaAnswer.schema.json +36 -0
- package/schemas/textAreaQuestion.schema.json +78 -0
- package/schemas/textQuestion.schema.json +63 -0
- package/schemas/typeaheadSearchAnswer.schema.json +37 -0
- package/schemas/typeaheadSearchQuestion.schema.json +120 -0
- package/schemas/urlAnswer.schema.json +36 -0
- package/schemas/urlQuestion.schema.json +66 -0
package/README.md
CHANGED
|
@@ -215,7 +215,73 @@ To just generate JSON schemas from the Zod schemas: `npm run generate`
|
|
|
215
215
|
|
|
216
216
|
To build the Types, Zod schemas and JSON schemas all at once: `npm run build`
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
### Pre-testing changes from dmptool-types in the backend or frontend
|
|
219
|
+
|
|
220
|
+
It's possible to test changes so you don't have to publish the new version
|
|
221
|
+
of `@dmptool/types` to npm until you know the changes are working as expected. You
|
|
222
|
+
may also fix tests or make other changes to the backend or frontend to use the new types
|
|
223
|
+
schema if it causes breaking changes.
|
|
224
|
+
|
|
225
|
+
in the existing package.json it looks like the following (most of the file omitted):
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"dependencies": {
|
|
230
|
+
"@dmptool/types": "2.0.0",
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
To test frontend or backed locally with new types, change the version to point to the
|
|
236
|
+
GitHub repo instead. You should have committed and pushed your changes to a branch in
|
|
237
|
+
the dmptool-types repo before doing this.
|
|
238
|
+
|
|
239
|
+
While you can put a branch name after the `#` here, it's better to use a specific
|
|
240
|
+
commit hash since it makes it more clear for caching algorithms that code has changed
|
|
241
|
+
(while a branch name may stay the same, even with changes to the branch). You can
|
|
242
|
+
see the latest commit hash by doing `git log -1` in the dmptool-types repo
|
|
243
|
+
(be sure that commit is on github!).
|
|
244
|
+
|
|
245
|
+
Example (most of the file omitted):
|
|
246
|
+
|
|
247
|
+
```json
|
|
248
|
+
{
|
|
249
|
+
"dependencies": {
|
|
250
|
+
"@dmptool/types": "github:CDLUC3/dmptool-types#3804909b252dcf3af4487438ed9321d6a06decd1",
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
After changing you need to run `npm install` again to update the dependency and probably need
|
|
256
|
+
to stop docker and do `docker compose up` again (if you're using docker for local development).
|
|
257
|
+
|
|
258
|
+
This may also help you decide how to set SEMVER version number as a MAJOR, MINOR or PATCH change
|
|
259
|
+
when you go to publish the types package to NPM depending on if breaking existing code.
|
|
260
|
+
|
|
261
|
+
After you've tested your changes and are happy with them, be sure to change the package.json
|
|
262
|
+
`@dmptool/types` back to the previous npm repository and version. After you've published
|
|
263
|
+
the types to NPM (see section below), you can then update the backend and frontend package.json files
|
|
264
|
+
to use the new version from NPM.
|
|
265
|
+
|
|
266
|
+
It's tricky to manage these changes since they potentially may require changes to
|
|
267
|
+
three different repositories in parallel since likely the types changes will at
|
|
268
|
+
least require version number changes to be published to NPM and then the frontend
|
|
269
|
+
and backend will need to update their dependencies to use the new version of the
|
|
270
|
+
types package, also.
|
|
271
|
+
|
|
272
|
+
Be careful with testing locally since if other people are working in parallel with
|
|
273
|
+
types or other backend/frontend changes then the compatibility may change if you're pulling
|
|
274
|
+
latest changes in only some of the repos from upstream, but not others.
|
|
275
|
+
|
|
276
|
+
Problems may not be obvious or easy to figure out when things get out of sync and
|
|
277
|
+
you can waste a lot of time trying to figure out why something isn't working.
|
|
278
|
+
One way to keep things in sync is to create parallel feature branches on all three
|
|
279
|
+
repos when starting the work,so the changes stay the same and can be tested together
|
|
280
|
+
and act like an atomic unit rather than some parts drifting out of sync. If you pull
|
|
281
|
+
in latest changes from upstream on one repo, be sure to do it on all three repos.
|
|
282
|
+
|
|
283
|
+
|
|
284
|
+
### To publish changes:
|
|
219
285
|
- Increment the `version` in `package.json`
|
|
220
286
|
- Run `npm login` and login to you npm account
|
|
221
287
|
- Run `npm publish --access public`
|
|
@@ -242,3 +308,6 @@ latest: 1.0.0
|
|
|
242
308
|
|
|
243
309
|
published 6 minutes ago by npm-user-name <email-address>
|
|
244
310
|
```
|
|
311
|
+
|
|
312
|
+
After publishing changes you'll need to update the `@dmptool/types` dependency in both the
|
|
313
|
+
backend and frontend repos to use the new version number and run `npm install` again.
|
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const questions_1 = require("../../questions");
|
|
4
4
|
const index_1 = require("../index");
|
|
5
|
+
// Helper to only assert `comment` when both actual and expected include it anywhere in the structure.
|
|
6
|
+
function normalizeForCommentCheck(actualInput, expectedInput) {
|
|
7
|
+
const actual = JSON.parse(JSON.stringify(actualInput));
|
|
8
|
+
const expected = JSON.parse(JSON.stringify(expectedInput));
|
|
9
|
+
const isPlainObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
10
|
+
function prune(a, e) {
|
|
11
|
+
if (Array.isArray(e) && Array.isArray(a)) {
|
|
12
|
+
const aArr = a;
|
|
13
|
+
const eArr = e;
|
|
14
|
+
const len = Math.min(aArr.length, eArr.length);
|
|
15
|
+
for (let i = 0; i < len; i++)
|
|
16
|
+
prune(aArr[i], eArr[i]);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (isPlainObject(e) && isPlainObject(a)) {
|
|
20
|
+
const aObj = a;
|
|
21
|
+
const eObj = e;
|
|
22
|
+
// For keys in expected: if it's 'comment' but actual doesn't have it, remove from expected
|
|
23
|
+
for (const key of Object.keys(eObj)) {
|
|
24
|
+
if (key === 'comment') {
|
|
25
|
+
if (!Object.prototype.hasOwnProperty.call(aObj, 'comment'))
|
|
26
|
+
delete eObj['comment'];
|
|
27
|
+
}
|
|
28
|
+
else if (Object.prototype.hasOwnProperty.call(aObj, key)) {
|
|
29
|
+
prune(aObj[key], eObj[key]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// For keys only in actual: if it's 'comment' but expected doesn't have it, remove from actual
|
|
33
|
+
for (const key of Object.keys(aObj)) {
|
|
34
|
+
if (key === 'comment' && !Object.prototype.hasOwnProperty.call(eObj, 'comment')) {
|
|
35
|
+
delete aObj['comment'];
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
prune(actual, expected);
|
|
41
|
+
return { actual, expected };
|
|
42
|
+
}
|
|
5
43
|
describe('Get question answer defaultJSON', () => {
|
|
6
44
|
it('returns the expected default affiliationSearch', () => {
|
|
7
45
|
const expected = {
|
|
@@ -12,7 +50,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
12
50
|
},
|
|
13
51
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
14
52
|
};
|
|
15
|
-
|
|
53
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultAffiliationSearchAnswer, expected);
|
|
54
|
+
expect(actual).toEqual(exp);
|
|
16
55
|
});
|
|
17
56
|
it('returns the expected default boolean', () => {
|
|
18
57
|
const expected = {
|
|
@@ -20,7 +59,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
20
59
|
answer: false,
|
|
21
60
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
22
61
|
};
|
|
23
|
-
|
|
62
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultBooleanAnswer, expected);
|
|
63
|
+
expect(actual).toEqual(exp);
|
|
24
64
|
});
|
|
25
65
|
it('returns the expected default checkBoxes', () => {
|
|
26
66
|
const expected = {
|
|
@@ -28,7 +68,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
28
68
|
answer: [],
|
|
29
69
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
30
70
|
};
|
|
31
|
-
|
|
71
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultCheckboxesAnswer, expected);
|
|
72
|
+
expect(actual).toEqual(exp);
|
|
32
73
|
});
|
|
33
74
|
it('returns the expected default currency', () => {
|
|
34
75
|
const expected = {
|
|
@@ -36,7 +77,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
36
77
|
answer: 0,
|
|
37
78
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
38
79
|
};
|
|
39
|
-
|
|
80
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultCurrencyAnswer, expected);
|
|
81
|
+
expect(actual).toEqual(exp);
|
|
40
82
|
});
|
|
41
83
|
it('returns the expected default date', () => {
|
|
42
84
|
const expected = {
|
|
@@ -44,7 +86,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
44
86
|
answer: "",
|
|
45
87
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
46
88
|
};
|
|
47
|
-
|
|
89
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultDateAnswer, expected);
|
|
90
|
+
expect(actual).toEqual(exp);
|
|
48
91
|
});
|
|
49
92
|
it('returns the expected default dateRange', () => {
|
|
50
93
|
const expected = {
|
|
@@ -55,7 +98,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
55
98
|
},
|
|
56
99
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
57
100
|
};
|
|
58
|
-
|
|
101
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultDateRangeAnswer, expected);
|
|
102
|
+
expect(actual).toEqual(exp);
|
|
59
103
|
});
|
|
60
104
|
it('returns the expected default email', () => {
|
|
61
105
|
const expected = {
|
|
@@ -63,7 +107,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
63
107
|
answer: "",
|
|
64
108
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
65
109
|
};
|
|
66
|
-
|
|
110
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultEmailAnswer, expected);
|
|
111
|
+
expect(actual).toEqual(exp);
|
|
67
112
|
});
|
|
68
113
|
it('returns the expected default licenseSearch', () => {
|
|
69
114
|
const expected = {
|
|
@@ -74,7 +119,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
74
119
|
}],
|
|
75
120
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
76
121
|
};
|
|
77
|
-
|
|
122
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultLicenseSearchAnswer, expected);
|
|
123
|
+
expect(actual).toEqual(exp);
|
|
78
124
|
});
|
|
79
125
|
it('returns the expected default metadataStandardSearch', () => {
|
|
80
126
|
const expected = {
|
|
@@ -85,7 +131,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
85
131
|
}],
|
|
86
132
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
87
133
|
};
|
|
88
|
-
|
|
134
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultMetadataStandardSearchAnswer, expected);
|
|
135
|
+
expect(actual).toEqual(exp);
|
|
89
136
|
});
|
|
90
137
|
it('returns the expected default multiselectBox', () => {
|
|
91
138
|
const expected = {
|
|
@@ -93,7 +140,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
93
140
|
answer: [],
|
|
94
141
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
95
142
|
};
|
|
96
|
-
|
|
143
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultMultiselectBoxAnswer, expected);
|
|
144
|
+
expect(actual).toEqual(exp);
|
|
97
145
|
});
|
|
98
146
|
it('returns the expected default number', () => {
|
|
99
147
|
const expected = {
|
|
@@ -101,7 +149,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
101
149
|
answer: 0,
|
|
102
150
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
103
151
|
};
|
|
104
|
-
|
|
152
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultNumberAnswer, expected);
|
|
153
|
+
expect(actual).toEqual(exp);
|
|
105
154
|
});
|
|
106
155
|
it('returns the expected default numberRange', () => {
|
|
107
156
|
const expected = {
|
|
@@ -112,7 +161,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
112
161
|
},
|
|
113
162
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
114
163
|
};
|
|
115
|
-
|
|
164
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultNumberRangeAnswer, expected);
|
|
165
|
+
expect(actual).toEqual(exp);
|
|
116
166
|
});
|
|
117
167
|
it('returns the expected default numberWithContext', () => {
|
|
118
168
|
const expected = {
|
|
@@ -123,7 +173,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
123
173
|
},
|
|
124
174
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
125
175
|
};
|
|
126
|
-
|
|
176
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultNumberWithContextAnswer, expected);
|
|
177
|
+
expect(actual).toEqual(exp);
|
|
127
178
|
});
|
|
128
179
|
it('returns the expected default radioButtons', () => {
|
|
129
180
|
const expected = {
|
|
@@ -131,7 +182,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
131
182
|
answer: "",
|
|
132
183
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
133
184
|
};
|
|
134
|
-
|
|
185
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultRadioButtonsAnswer, expected);
|
|
186
|
+
expect(actual).toEqual(exp);
|
|
135
187
|
});
|
|
136
188
|
it('returns the expected default repositorySearch', () => {
|
|
137
189
|
const expected = {
|
|
@@ -142,7 +194,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
142
194
|
}],
|
|
143
195
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
144
196
|
};
|
|
145
|
-
|
|
197
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultRepositorySearchAnswer, expected);
|
|
198
|
+
expect(actual).toEqual(exp);
|
|
146
199
|
});
|
|
147
200
|
it('returns the expected default researchOutputTable', () => {
|
|
148
201
|
const expected = {
|
|
@@ -164,7 +217,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
164
217
|
}],
|
|
165
218
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
166
219
|
};
|
|
167
|
-
|
|
220
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultResearchOutputTableAnswer, expected);
|
|
221
|
+
expect(actual).toEqual(exp);
|
|
168
222
|
});
|
|
169
223
|
it('returns the expected default selectBox', () => {
|
|
170
224
|
const expected = {
|
|
@@ -172,7 +226,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
172
226
|
answer: "",
|
|
173
227
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
174
228
|
};
|
|
175
|
-
|
|
229
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultSelectBoxAnswer, expected);
|
|
230
|
+
expect(actual).toEqual(exp);
|
|
176
231
|
});
|
|
177
232
|
it('returns the expected default table', () => {
|
|
178
233
|
const expected = {
|
|
@@ -187,7 +242,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
187
242
|
}],
|
|
188
243
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
189
244
|
};
|
|
190
|
-
|
|
245
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultTableAnswer, expected);
|
|
246
|
+
expect(actual).toEqual(exp);
|
|
191
247
|
});
|
|
192
248
|
it('returns the expected default text', () => {
|
|
193
249
|
const expected = {
|
|
@@ -195,7 +251,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
195
251
|
answer: "",
|
|
196
252
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
197
253
|
};
|
|
198
|
-
|
|
254
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultTextAnswer, expected);
|
|
255
|
+
expect(actual).toEqual(exp);
|
|
199
256
|
});
|
|
200
257
|
it('returns the expected default textArea', () => {
|
|
201
258
|
const expected = {
|
|
@@ -203,7 +260,8 @@ describe('Get question answer defaultJSON', () => {
|
|
|
203
260
|
answer: "",
|
|
204
261
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
205
262
|
};
|
|
206
|
-
|
|
263
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultTextAreaAnswer, expected);
|
|
264
|
+
expect(actual).toEqual(exp);
|
|
207
265
|
});
|
|
208
266
|
it('returns the expected default url', () => {
|
|
209
267
|
const expected = {
|
|
@@ -211,6 +269,7 @@ describe('Get question answer defaultJSON', () => {
|
|
|
211
269
|
answer: "",
|
|
212
270
|
meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION },
|
|
213
271
|
};
|
|
214
|
-
|
|
272
|
+
const { actual, expected: exp } = normalizeForCommentCheck(index_1.DefaultURLAnswer, expected);
|
|
273
|
+
expect(actual).toEqual(exp);
|
|
215
274
|
});
|
|
216
275
|
});
|
package/dist/answers/answer.d.ts
CHANGED
|
@@ -26,12 +26,14 @@ export declare const AnswerSchema: z.ZodObject<{
|
|
|
26
26
|
meta: z.ZodObject<{
|
|
27
27
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
29
30
|
}, z.core.$strip>;
|
|
30
31
|
export declare const DefaultAnswer: {
|
|
31
32
|
type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "licenseSearch" | "metadataStandardSearch" | "multiselectBox" | "numberRange" | "numberWithContext" | "radioButtons" | "repositorySearch" | "researchOutputTable" | "selectBox" | "table" | "text" | "textArea" | "url";
|
|
32
33
|
meta: {
|
|
33
34
|
schemaVersion: string;
|
|
34
35
|
};
|
|
36
|
+
comment?: string | undefined;
|
|
35
37
|
};
|
|
36
38
|
export type AnswerType = z.infer<typeof AnswerSchema>;
|
|
37
39
|
export declare const AnswerJSONSchema: z.core.JSONSchema.JSONSchema;
|
package/dist/answers/answer.js
CHANGED
|
@@ -8,11 +8,13 @@ exports.AnswerSchema = zod_1.z.object({
|
|
|
8
8
|
type: questions_1.QuestionFormatsEnum, // The type of answer
|
|
9
9
|
meta: zod_1.z.object({
|
|
10
10
|
schemaVersion: zod_1.z.string().default(questions_1.CURRENT_SCHEMA_VERSION), // The schema version of the answer
|
|
11
|
-
})
|
|
11
|
+
}),
|
|
12
|
+
comment: zod_1.z.string().optional() // Optional comment associated with the answer
|
|
12
13
|
});
|
|
13
14
|
exports.DefaultAnswer = exports.AnswerSchema.parse({
|
|
14
15
|
type: 'textArea',
|
|
15
16
|
answer: "",
|
|
16
|
-
meta: questions_1.DefaultMeta
|
|
17
|
+
meta: questions_1.DefaultMeta,
|
|
18
|
+
comment: ""
|
|
17
19
|
});
|
|
18
20
|
exports.AnswerJSONSchema = zod_1.z.toJSONSchema(exports.AnswerSchema);
|
|
@@ -5,6 +5,7 @@ export declare const DateAnswerSchema: z.ZodObject<{
|
|
|
5
5
|
meta: z.ZodObject<{
|
|
6
6
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
7
7
|
}, z.core.$strip>;
|
|
8
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
8
9
|
}, z.core.$strip>;
|
|
9
10
|
export declare const DefaultDateAnswer: {
|
|
10
11
|
type: "date";
|
|
@@ -12,6 +13,7 @@ export declare const DefaultDateAnswer: {
|
|
|
12
13
|
meta: {
|
|
13
14
|
schemaVersion: string;
|
|
14
15
|
};
|
|
16
|
+
comment?: string | undefined;
|
|
15
17
|
};
|
|
16
18
|
export declare const DateRangeAnswerSchema: z.ZodObject<{
|
|
17
19
|
type: z.ZodLiteral<"dateRange">;
|
|
@@ -22,6 +24,7 @@ export declare const DateRangeAnswerSchema: z.ZodObject<{
|
|
|
22
24
|
meta: z.ZodObject<{
|
|
23
25
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
24
26
|
}, z.core.$strip>;
|
|
27
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
25
28
|
}, z.core.$strip>;
|
|
26
29
|
export declare const DefaultDateRangeAnswer: {
|
|
27
30
|
type: "dateRange";
|
|
@@ -32,6 +35,7 @@ export declare const DefaultDateRangeAnswer: {
|
|
|
32
35
|
meta: {
|
|
33
36
|
schemaVersion: string;
|
|
34
37
|
};
|
|
38
|
+
comment?: string | undefined;
|
|
35
39
|
};
|
|
36
40
|
export type DateAnswerType = z.infer<typeof DateAnswerSchema>;
|
|
37
41
|
export type DateRangeAnswerType = z.infer<typeof DateRangeAnswerSchema>;
|
|
@@ -8,6 +8,7 @@ export declare const AffiliationSearchAnswerSchema: z.ZodObject<{
|
|
|
8
8
|
meta: z.ZodObject<{
|
|
9
9
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
10
10
|
}, z.core.$strip>;
|
|
11
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
11
12
|
}, z.core.$strip>;
|
|
12
13
|
export declare const DefaultAffiliationSearchAnswer: {
|
|
13
14
|
type: "affiliationSearch";
|
|
@@ -18,6 +19,7 @@ export declare const DefaultAffiliationSearchAnswer: {
|
|
|
18
19
|
meta: {
|
|
19
20
|
schemaVersion: string;
|
|
20
21
|
};
|
|
22
|
+
comment?: string | undefined;
|
|
21
23
|
};
|
|
22
24
|
export declare const LicenseSearchAnswerSchema: z.ZodObject<{
|
|
23
25
|
type: z.ZodLiteral<"licenseSearch">;
|
|
@@ -28,6 +30,7 @@ export declare const LicenseSearchAnswerSchema: z.ZodObject<{
|
|
|
28
30
|
meta: z.ZodObject<{
|
|
29
31
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
30
32
|
}, z.core.$strip>;
|
|
33
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
31
34
|
}, z.core.$strip>;
|
|
32
35
|
export declare const DefaultLicenseSearchAnswer: {
|
|
33
36
|
type: "licenseSearch";
|
|
@@ -38,6 +41,7 @@ export declare const DefaultLicenseSearchAnswer: {
|
|
|
38
41
|
meta: {
|
|
39
42
|
schemaVersion: string;
|
|
40
43
|
};
|
|
44
|
+
comment?: string | undefined;
|
|
41
45
|
};
|
|
42
46
|
export declare const MetadataStandardSearchAnswerSchema: z.ZodObject<{
|
|
43
47
|
type: z.ZodLiteral<"metadataStandardSearch">;
|
|
@@ -48,6 +52,7 @@ export declare const MetadataStandardSearchAnswerSchema: z.ZodObject<{
|
|
|
48
52
|
meta: z.ZodObject<{
|
|
49
53
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
50
54
|
}, z.core.$strip>;
|
|
55
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
51
56
|
}, z.core.$strip>;
|
|
52
57
|
export declare const DefaultMetadataStandardSearchAnswer: {
|
|
53
58
|
type: "metadataStandardSearch";
|
|
@@ -58,6 +63,7 @@ export declare const DefaultMetadataStandardSearchAnswer: {
|
|
|
58
63
|
meta: {
|
|
59
64
|
schemaVersion: string;
|
|
60
65
|
};
|
|
66
|
+
comment?: string | undefined;
|
|
61
67
|
};
|
|
62
68
|
export declare const RepositorySearchAnswerSchema: z.ZodObject<{
|
|
63
69
|
type: z.ZodLiteral<"repositorySearch">;
|
|
@@ -68,6 +74,7 @@ export declare const RepositorySearchAnswerSchema: z.ZodObject<{
|
|
|
68
74
|
meta: z.ZodObject<{
|
|
69
75
|
schemaVersion: z.ZodDefault<z.ZodString>;
|
|
70
76
|
}, z.core.$strip>;
|
|
77
|
+
comment: z.ZodOptional<z.ZodString>;
|
|
71
78
|
}, z.core.$strip>;
|
|
72
79
|
export declare const DefaultRepositorySearchAnswer: {
|
|
73
80
|
type: "repositorySearch";
|
|
@@ -78,6 +85,7 @@ export declare const DefaultRepositorySearchAnswer: {
|
|
|
78
85
|
meta: {
|
|
79
86
|
schemaVersion: string;
|
|
80
87
|
};
|
|
88
|
+
comment?: string | undefined;
|
|
81
89
|
};
|
|
82
90
|
export type AffiliationSearchAnswerType = z.infer<typeof AffiliationSearchAnswerSchema>;
|
|
83
91
|
export type LicenseSearchAnswerType = z.infer<typeof LicenseSearchAnswerSchema>;
|