@dmptool/types 1.1.1 → 1.1.2
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 +11 -5
- package/dist/answers/answer.d.ts +3 -3
- package/dist/answers/graphQLAnswers.d.ts +2 -2
- package/dist/answers/graphQLAnswers.js +2 -2
- package/dist/answers/index.d.ts +92 -55
- package/dist/answers/index.js +2 -2
- package/dist/answers/optionBasedAnswers.d.ts +27 -2
- package/dist/answers/optionBasedAnswers.js +5 -1
- package/dist/answers/tableAnswers.d.ts +268 -104
- package/dist/answers/tableAnswers.js +2 -1
- package/dist/questions/__tests__/graphQLQuestions.spec.js +7 -7
- package/dist/questions/__tests__/optionBasedQuestions.spec.js +48 -1
- package/dist/questions/dateQuestions.d.ts +47 -16
- package/dist/questions/dateQuestions.js +25 -1
- package/dist/questions/graphQLQuestions.d.ts +59 -28
- package/dist/questions/graphQLQuestions.js +40 -3
- package/dist/questions/index.d.ts +1363 -646
- package/dist/questions/index.js +4 -2
- package/dist/questions/numberQuestions.d.ts +71 -25
- package/dist/questions/numberQuestions.js +36 -1
- package/dist/questions/optionBasedQuestions.d.ts +197 -44
- package/dist/questions/optionBasedQuestions.js +84 -6
- package/dist/questions/question.d.ts +51 -4
- package/dist/questions/question.js +14 -2
- package/dist/questions/tableQuestions.d.ts +1841 -932
- package/dist/questions/tableQuestions.js +13 -1
- package/dist/questions/textQuestions.d.ts +100 -40
- package/dist/questions/textQuestions.js +45 -7
- package/dist/schemas/affiliationSearchAnswer.schema.json +37 -0
- package/dist/schemas/affiliationSearchQuestion.schema.json +133 -0
- package/dist/schemas/anyAnswer.schema.json +41 -23
- package/dist/schemas/anyQuestion.schema.json +533 -149
- package/dist/schemas/anyTableColumnAnswer.schema.json +35 -14
- package/dist/schemas/anyTableColumnQuestion.schema.json +397 -119
- package/dist/schemas/booleanQuestion.schema.json +13 -2
- package/dist/schemas/checkboxesQuestion.schema.json +12 -0
- package/dist/schemas/currencyQuestion.schema.json +12 -0
- package/dist/schemas/dateQuestion.schema.json +12 -0
- package/dist/schemas/dateRangeQuestion.schema.json +12 -0
- package/dist/schemas/emailQuestion.schema.json +12 -0
- package/dist/schemas/filteredSearchQuestion.schema.json +10 -0
- package/dist/schemas/multiselectBoxAnswer.schema.json +40 -0
- package/dist/schemas/multiselectBoxQuestion.schema.json +90 -0
- package/dist/schemas/numberQuestion.schema.json +12 -0
- package/dist/schemas/numberRangeQuestion.schema.json +12 -0
- package/dist/schemas/radioButtonsQuestion.schema.json +12 -0
- package/dist/schemas/selectBoxAnswer.schema.json +1 -4
- package/dist/schemas/selectBoxQuestion.schema.json +18 -1
- package/dist/schemas/tableAnswer.schema.json +35 -14
- package/dist/schemas/tableQuestion.schema.json +419 -120
- package/dist/schemas/textAreaQuestion.schema.json +15 -4
- package/dist/schemas/textQuestion.schema.json +12 -0
- package/dist/schemas/urlQuestion.schema.json +12 -0
- package/package.json +1 -1
|
@@ -147,7 +147,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
147
147
|
attributes: {
|
|
148
148
|
label: "Fruits",
|
|
149
149
|
help: "Select all fruits you like",
|
|
150
|
-
multiple:
|
|
150
|
+
multiple: false,
|
|
151
151
|
},
|
|
152
152
|
options: [
|
|
153
153
|
{
|
|
@@ -187,3 +187,50 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
|
|
|
187
187
|
(0, globals_1.expect)(() => optionBasedQuestions_1.SelectBoxQuestionSchema.parse(invalidSelectBoxQuestion)).toThrow();
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
|
+
(0, globals_1.describe)("MultiselectBoxQuestion", () => {
|
|
191
|
+
(0, globals_1.it)("should validate a valid MultiselectBoxQuestion object", () => {
|
|
192
|
+
const validSelectBoxQuestion = {
|
|
193
|
+
type: "multiselectBox",
|
|
194
|
+
attributes: {
|
|
195
|
+
label: "Fruits",
|
|
196
|
+
help: "Select all fruits you like",
|
|
197
|
+
multiple: true,
|
|
198
|
+
},
|
|
199
|
+
options: [
|
|
200
|
+
{
|
|
201
|
+
label: "USA",
|
|
202
|
+
value: "us",
|
|
203
|
+
selected: true,
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
label: "Canada",
|
|
207
|
+
value: "ca",
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
meta: {
|
|
211
|
+
schemaVersion: "1.0"
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.MultiselectBoxQuestionSchema.parse(validSelectBoxQuestion)).not.toThrow();
|
|
215
|
+
});
|
|
216
|
+
(0, globals_1.it)("should throw an error for an invalid MultiselectBoxQuestion object", () => {
|
|
217
|
+
const invalidSelectBoxQuestion = {
|
|
218
|
+
type: "multiselectBox",
|
|
219
|
+
questionText: "Select your country",
|
|
220
|
+
options: [
|
|
221
|
+
{
|
|
222
|
+
label: "USA",
|
|
223
|
+
value: "us",
|
|
224
|
+
selected: "true", // Invalid type for selected
|
|
225
|
+
},
|
|
226
|
+
],
|
|
227
|
+
attributes: {
|
|
228
|
+
multiple: "true", // Invalid type for multiple
|
|
229
|
+
},
|
|
230
|
+
meta: {
|
|
231
|
+
schemaVersion: "1.0"
|
|
232
|
+
}
|
|
233
|
+
};
|
|
234
|
+
(0, globals_1.expect)(() => optionBasedQuestions_1.MultiselectBoxQuestionSchema.parse(invalidSelectBoxQuestion)).toThrow();
|
|
235
|
+
});
|
|
236
|
+
});
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const DateQuestionSchema: z.ZodObject<{
|
|
3
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
4
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
schemaVersion: "1.0";
|
|
7
|
-
}, {
|
|
8
|
-
schemaVersion: "1.0";
|
|
9
|
-
}>>;
|
|
10
|
-
} & {
|
|
2
|
+
export declare const DateQuestionSchema: z.ZodObject<{} & {
|
|
11
3
|
type: z.ZodLiteral<"date">;
|
|
12
4
|
attributes: z.ZodOptional<z.ZodObject<{
|
|
13
5
|
label: z.ZodOptional<z.ZodString>;
|
|
@@ -32,6 +24,23 @@ export declare const DateQuestionSchema: z.ZodObject<{
|
|
|
32
24
|
min?: string | undefined;
|
|
33
25
|
step?: number | undefined;
|
|
34
26
|
}>>;
|
|
27
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
28
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
29
|
+
} & {
|
|
30
|
+
title: z.ZodOptional<z.ZodLiteral<"Date Field">>;
|
|
31
|
+
usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a date.">>;
|
|
32
|
+
defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
schemaVersion: "1.0";
|
|
35
|
+
title?: "Date Field" | undefined;
|
|
36
|
+
usageDescription?: "For questions that require a date." | undefined;
|
|
37
|
+
defaultJSON?: string | undefined;
|
|
38
|
+
}, {
|
|
39
|
+
schemaVersion: "1.0";
|
|
40
|
+
title?: "Date Field" | undefined;
|
|
41
|
+
usageDescription?: "For questions that require a date." | undefined;
|
|
42
|
+
defaultJSON?: string | undefined;
|
|
43
|
+
}>>;
|
|
35
44
|
}, "strip", z.ZodTypeAny, {
|
|
36
45
|
type: "date";
|
|
37
46
|
attributes?: {
|
|
@@ -44,6 +53,9 @@ export declare const DateQuestionSchema: z.ZodObject<{
|
|
|
44
53
|
} | undefined;
|
|
45
54
|
meta?: {
|
|
46
55
|
schemaVersion: "1.0";
|
|
56
|
+
title?: "Date Field" | undefined;
|
|
57
|
+
usageDescription?: "For questions that require a date." | undefined;
|
|
58
|
+
defaultJSON?: string | undefined;
|
|
47
59
|
} | undefined;
|
|
48
60
|
}, {
|
|
49
61
|
type: "date";
|
|
@@ -57,6 +69,9 @@ export declare const DateQuestionSchema: z.ZodObject<{
|
|
|
57
69
|
} | undefined;
|
|
58
70
|
meta?: {
|
|
59
71
|
schemaVersion: "1.0";
|
|
72
|
+
title?: "Date Field" | undefined;
|
|
73
|
+
usageDescription?: "For questions that require a date." | undefined;
|
|
74
|
+
defaultJSON?: string | undefined;
|
|
60
75
|
} | undefined;
|
|
61
76
|
}>;
|
|
62
77
|
export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
@@ -73,13 +88,6 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
|
73
88
|
help?: string | undefined;
|
|
74
89
|
labelTranslationKey?: string | undefined;
|
|
75
90
|
}>>;
|
|
76
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
78
|
-
}, "strip", z.ZodTypeAny, {
|
|
79
|
-
schemaVersion: "1.0";
|
|
80
|
-
}, {
|
|
81
|
-
schemaVersion: "1.0";
|
|
82
|
-
}>>;
|
|
83
91
|
} & {
|
|
84
92
|
type: z.ZodLiteral<"dateRange">;
|
|
85
93
|
columns: z.ZodObject<{
|
|
@@ -164,6 +172,23 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
|
164
172
|
step?: number | undefined;
|
|
165
173
|
} | undefined;
|
|
166
174
|
}>;
|
|
175
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
176
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
177
|
+
} & {
|
|
178
|
+
title: z.ZodOptional<z.ZodLiteral<"Date Range">>;
|
|
179
|
+
usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a date range (e.g. From/To, Start/End)">>;
|
|
180
|
+
defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
|
|
181
|
+
}, "strip", z.ZodTypeAny, {
|
|
182
|
+
schemaVersion: "1.0";
|
|
183
|
+
title?: "Date Range" | undefined;
|
|
184
|
+
usageDescription?: "For questions that require a date range (e.g. From/To, Start/End)" | undefined;
|
|
185
|
+
defaultJSON?: string | undefined;
|
|
186
|
+
}, {
|
|
187
|
+
schemaVersion: "1.0";
|
|
188
|
+
title?: "Date Range" | undefined;
|
|
189
|
+
usageDescription?: "For questions that require a date range (e.g. From/To, Start/End)" | undefined;
|
|
190
|
+
defaultJSON?: string | undefined;
|
|
191
|
+
}>>;
|
|
167
192
|
}, "strip", z.ZodTypeAny, {
|
|
168
193
|
type: "dateRange";
|
|
169
194
|
columns: {
|
|
@@ -191,6 +216,9 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
|
191
216
|
} | undefined;
|
|
192
217
|
meta?: {
|
|
193
218
|
schemaVersion: "1.0";
|
|
219
|
+
title?: "Date Range" | undefined;
|
|
220
|
+
usageDescription?: "For questions that require a date range (e.g. From/To, Start/End)" | undefined;
|
|
221
|
+
defaultJSON?: string | undefined;
|
|
194
222
|
} | undefined;
|
|
195
223
|
}, {
|
|
196
224
|
type: "dateRange";
|
|
@@ -219,6 +247,9 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
|
|
|
219
247
|
} | undefined;
|
|
220
248
|
meta?: {
|
|
221
249
|
schemaVersion: "1.0";
|
|
250
|
+
title?: "Date Range" | undefined;
|
|
251
|
+
usageDescription?: "For questions that require a date range (e.g. From/To, Start/End)" | undefined;
|
|
252
|
+
defaultJSON?: string | undefined;
|
|
222
253
|
} | undefined;
|
|
223
254
|
}>;
|
|
224
255
|
export type DateQuestionType = z.infer<typeof DateQuestionSchema>;
|
|
@@ -4,21 +4,45 @@ exports.DateRangeQuestionSchema = exports.DateQuestionSchema = void 0;
|
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
const BaseAttributes = question_1.QuestionSchema.shape.attributes;
|
|
7
|
+
const BaseMeta = question_1.QuestionSchema.shape.meta;
|
|
7
8
|
const DateAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
8
9
|
max: zod_1.z.string().optional(), // The maximum date (no default)
|
|
9
10
|
min: zod_1.z.string().optional(), // The minimum date (no default)
|
|
10
11
|
step: zod_1.z.number().optional() // The step value (default is 1 day)
|
|
11
12
|
}));
|
|
12
13
|
// Date question and answer
|
|
14
|
+
const defaultDateJSON = {
|
|
15
|
+
type: 'date',
|
|
16
|
+
attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { max: undefined, min: undefined, step: 1 }),
|
|
17
|
+
meta: Object.assign({}, question_1.defaultMeta)
|
|
18
|
+
};
|
|
13
19
|
exports.DateQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
14
20
|
type: zod_1.z.literal('date'), // The type of question
|
|
15
21
|
attributes: DateAttributesSchema.optional(),
|
|
22
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
23
|
+
title: zod_1.z.literal('Date Field').optional(),
|
|
24
|
+
usageDescription: zod_1.z.literal('For questions that require a date.').optional(),
|
|
25
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultDateJSON)).optional(),
|
|
26
|
+
})).optional(),
|
|
16
27
|
}));
|
|
17
28
|
// Date range question and answer
|
|
29
|
+
const defaultDateRangeJSON = {
|
|
30
|
+
type: 'dateRange',
|
|
31
|
+
attributes: Object.assign({}, question_1.defaultAttributes),
|
|
32
|
+
columns: {
|
|
33
|
+
start: Object.assign(Object.assign({}, question_1.defaultAttributes), { label: 'Start', max: undefined, min: undefined, step: 1 }),
|
|
34
|
+
end: Object.assign(Object.assign({}, question_1.defaultAttributes), { label: 'End', max: undefined, min: undefined, step: 1 })
|
|
35
|
+
}
|
|
36
|
+
};
|
|
18
37
|
exports.DateRangeQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
19
38
|
type: zod_1.z.literal('dateRange'), // The type of question
|
|
20
39
|
columns: zod_1.z.object({
|
|
21
40
|
start: DateAttributesSchema.optional(),
|
|
22
41
|
end: DateAttributesSchema.optional()
|
|
23
|
-
})
|
|
42
|
+
}),
|
|
43
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
44
|
+
title: zod_1.z.literal('Date Range').optional(),
|
|
45
|
+
usageDescription: zod_1.z.literal('For questions that require a date range (e.g. From/To, Start/End)').optional(),
|
|
46
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultDateRangeJSON)).optional(),
|
|
47
|
+
})).optional(),
|
|
24
48
|
}));
|
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const FilteredSearchQuestionSchema: z.ZodObject<{
|
|
3
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
4
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
5
|
-
}, "strip", z.ZodTypeAny, {
|
|
6
|
-
schemaVersion: "1.0";
|
|
7
|
-
}, {
|
|
8
|
-
schemaVersion: "1.0";
|
|
9
|
-
}>>;
|
|
10
|
-
} & {
|
|
2
|
+
export declare const FilteredSearchQuestionSchema: z.ZodObject<{} & {
|
|
11
3
|
type: z.ZodLiteral<"filteredSearch">;
|
|
12
4
|
graphQL: z.ZodObject<{
|
|
13
5
|
displayFields: z.ZodArray<z.ZodObject<{
|
|
@@ -100,6 +92,23 @@ export declare const FilteredSearchQuestionSchema: z.ZodObject<{
|
|
|
100
92
|
labelTranslationKey?: string | undefined;
|
|
101
93
|
multiple?: boolean | undefined;
|
|
102
94
|
}>>;
|
|
95
|
+
meta: z.ZodOptional<z.ZodObject<{
|
|
96
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
97
|
+
usageDescription: z.ZodOptional<z.ZodString>;
|
|
98
|
+
defaultJSON: z.ZodOptional<z.ZodString>;
|
|
99
|
+
} & {
|
|
100
|
+
title: z.ZodOptional<z.ZodLiteral<"Not yet implemented">>;
|
|
101
|
+
}, "strip", z.ZodTypeAny, {
|
|
102
|
+
schemaVersion: "1.0";
|
|
103
|
+
title?: "Not yet implemented" | undefined;
|
|
104
|
+
usageDescription?: string | undefined;
|
|
105
|
+
defaultJSON?: string | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
schemaVersion: "1.0";
|
|
108
|
+
title?: "Not yet implemented" | undefined;
|
|
109
|
+
usageDescription?: string | undefined;
|
|
110
|
+
defaultJSON?: string | undefined;
|
|
111
|
+
}>>;
|
|
103
112
|
}, "strip", z.ZodTypeAny, {
|
|
104
113
|
type: "filteredSearch";
|
|
105
114
|
graphQL: {
|
|
@@ -128,6 +137,9 @@ export declare const FilteredSearchQuestionSchema: z.ZodObject<{
|
|
|
128
137
|
} | undefined;
|
|
129
138
|
meta?: {
|
|
130
139
|
schemaVersion: "1.0";
|
|
140
|
+
title?: "Not yet implemented" | undefined;
|
|
141
|
+
usageDescription?: string | undefined;
|
|
142
|
+
defaultJSON?: string | undefined;
|
|
131
143
|
} | undefined;
|
|
132
144
|
}, {
|
|
133
145
|
type: "filteredSearch";
|
|
@@ -157,9 +169,12 @@ export declare const FilteredSearchQuestionSchema: z.ZodObject<{
|
|
|
157
169
|
} | undefined;
|
|
158
170
|
meta?: {
|
|
159
171
|
schemaVersion: "1.0";
|
|
172
|
+
title?: "Not yet implemented" | undefined;
|
|
173
|
+
usageDescription?: string | undefined;
|
|
174
|
+
defaultJSON?: string | undefined;
|
|
160
175
|
} | undefined;
|
|
161
176
|
}>;
|
|
162
|
-
export declare const
|
|
177
|
+
export declare const AffiliationSearchQuestionSchema: z.ZodObject<{
|
|
163
178
|
attributes: z.ZodOptional<z.ZodObject<{
|
|
164
179
|
label: z.ZodOptional<z.ZodString>;
|
|
165
180
|
help: z.ZodOptional<z.ZodString>;
|
|
@@ -173,15 +188,6 @@ export declare const TypeaheadSearchQuestionSchema: z.ZodObject<{
|
|
|
173
188
|
help?: string | undefined;
|
|
174
189
|
labelTranslationKey?: string | undefined;
|
|
175
190
|
}>>;
|
|
176
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
177
|
-
schemaVersion: z.ZodLiteral<"1.0">;
|
|
178
|
-
}, "strip", z.ZodTypeAny, {
|
|
179
|
-
schemaVersion: "1.0";
|
|
180
|
-
}, {
|
|
181
|
-
schemaVersion: "1.0";
|
|
182
|
-
}>>;
|
|
183
|
-
} & {
|
|
184
|
-
type: z.ZodLiteral<"typeaheadSearch">;
|
|
185
191
|
graphQL: z.ZodObject<{
|
|
186
192
|
displayFields: z.ZodArray<z.ZodObject<{
|
|
187
193
|
propertyName: z.ZodString;
|
|
@@ -256,8 +262,33 @@ export declare const TypeaheadSearchQuestionSchema: z.ZodObject<{
|
|
|
256
262
|
defaultValue?: string | undefined;
|
|
257
263
|
}[] | undefined;
|
|
258
264
|
}>;
|
|
265
|
+
} & {
|
|
266
|
+
type: z.ZodLiteral<"affiliationSearch">;
|
|
267
|
+
meta: z.ZodObject<{
|
|
268
|
+
schemaVersion: z.ZodLiteral<"1.0">;
|
|
269
|
+
} & {
|
|
270
|
+
title: z.ZodOptional<z.ZodLiteral<"Affiliation Search">>;
|
|
271
|
+
usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require the user to select from a controlled list of institutions.">>;
|
|
272
|
+
defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
schemaVersion: "1.0";
|
|
275
|
+
title?: "Affiliation Search" | undefined;
|
|
276
|
+
usageDescription?: "For questions that require the user to select from a controlled list of institutions." | undefined;
|
|
277
|
+
defaultJSON?: string | undefined;
|
|
278
|
+
}, {
|
|
279
|
+
schemaVersion: "1.0";
|
|
280
|
+
title?: "Affiliation Search" | undefined;
|
|
281
|
+
usageDescription?: "For questions that require the user to select from a controlled list of institutions." | undefined;
|
|
282
|
+
defaultJSON?: string | undefined;
|
|
283
|
+
}>;
|
|
259
284
|
}, "strip", z.ZodTypeAny, {
|
|
260
|
-
type: "
|
|
285
|
+
type: "affiliationSearch";
|
|
286
|
+
meta: {
|
|
287
|
+
schemaVersion: "1.0";
|
|
288
|
+
title?: "Affiliation Search" | undefined;
|
|
289
|
+
usageDescription?: "For questions that require the user to select from a controlled list of institutions." | undefined;
|
|
290
|
+
defaultJSON?: string | undefined;
|
|
291
|
+
};
|
|
261
292
|
graphQL: {
|
|
262
293
|
displayFields: {
|
|
263
294
|
label: string;
|
|
@@ -281,11 +312,14 @@ export declare const TypeaheadSearchQuestionSchema: z.ZodObject<{
|
|
|
281
312
|
help?: string | undefined;
|
|
282
313
|
labelTranslationKey?: string | undefined;
|
|
283
314
|
} | undefined;
|
|
284
|
-
meta?: {
|
|
285
|
-
schemaVersion: "1.0";
|
|
286
|
-
} | undefined;
|
|
287
315
|
}, {
|
|
288
|
-
type: "
|
|
316
|
+
type: "affiliationSearch";
|
|
317
|
+
meta: {
|
|
318
|
+
schemaVersion: "1.0";
|
|
319
|
+
title?: "Affiliation Search" | undefined;
|
|
320
|
+
usageDescription?: "For questions that require the user to select from a controlled list of institutions." | undefined;
|
|
321
|
+
defaultJSON?: string | undefined;
|
|
322
|
+
};
|
|
289
323
|
graphQL: {
|
|
290
324
|
displayFields: {
|
|
291
325
|
label: string;
|
|
@@ -309,9 +343,6 @@ export declare const TypeaheadSearchQuestionSchema: z.ZodObject<{
|
|
|
309
343
|
help?: string | undefined;
|
|
310
344
|
labelTranslationKey?: string | undefined;
|
|
311
345
|
} | undefined;
|
|
312
|
-
meta?: {
|
|
313
|
-
schemaVersion: "1.0";
|
|
314
|
-
} | undefined;
|
|
315
346
|
}>;
|
|
316
347
|
export type FilteredSearchQuestionType = z.infer<typeof FilteredSearchQuestionSchema>;
|
|
317
|
-
export type
|
|
348
|
+
export type AffiliationSearchQuestionType = z.infer<typeof AffiliationSearchQuestionSchema>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.AffiliationSearchQuestionSchema = exports.FilteredSearchQuestionSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const question_1 = require("./question");
|
|
6
6
|
const BaseAttributes = question_1.QuestionSchema.shape.attributes;
|
|
7
|
+
const BaseMeta = question_1.QuestionSchema.shape.meta;
|
|
7
8
|
// An input variable for a GraphQL query
|
|
8
9
|
const GraphQLVariable = zod_1.z.object({
|
|
9
10
|
minLength: zod_1.z.number().optional(), // A min length for the variable before executing the query
|
|
@@ -28,15 +29,51 @@ const GraphQLQuery = zod_1.z.object({
|
|
|
28
29
|
variables: zod_1.z.array(GraphQLVariable).optional() // The variables for the query
|
|
29
30
|
});
|
|
30
31
|
// Filtered search question and answer
|
|
32
|
+
// TODO: This one is for future use to help build out the components of the
|
|
33
|
+
// Research Outputs Question Type (e.g. License selector, Repository selector, etc.)
|
|
31
34
|
exports.FilteredSearchQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
32
35
|
type: zod_1.z.literal('filteredSearch'), // The type of question
|
|
33
36
|
graphQL: GraphQLQuery, // The GraphQL query options for the filtered search
|
|
34
37
|
attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
|
|
35
38
|
multiple: zod_1.z.boolean().optional() // Whether to allow multiple selections (default is true)
|
|
36
|
-
})).optional()
|
|
39
|
+
})).optional(),
|
|
40
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
41
|
+
title: zod_1.z.literal('Not yet implemented').optional(),
|
|
42
|
+
})).optional(),
|
|
37
43
|
}));
|
|
38
44
|
// Typeahead search question and answer
|
|
39
|
-
|
|
45
|
+
const TypeaheadSearchQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
|
|
40
46
|
type: zod_1.z.literal('typeaheadSearch'), // The type of question
|
|
41
47
|
graphQL: GraphQLQuery, // The GraphQL query options for the typeahead search
|
|
42
48
|
}));
|
|
49
|
+
const defaultAffiliationSearchJSON = {
|
|
50
|
+
type: 'affiliationSearch',
|
|
51
|
+
attributes: Object.assign({}, question_1.defaultAttributes),
|
|
52
|
+
meta: Object.assign({}, question_1.defaultMeta),
|
|
53
|
+
graphQL: {
|
|
54
|
+
query: "query Affiliations($name: String!){affiliations(name: $name) { totalCount nextCursor items {id displayName uri}}}",
|
|
55
|
+
queryId: "useAffiliationsQuery",
|
|
56
|
+
variables: [{
|
|
57
|
+
name: "term",
|
|
58
|
+
type: "string",
|
|
59
|
+
label: "Search for your institution",
|
|
60
|
+
minLength: 3,
|
|
61
|
+
labelTranslationKey: "SignupPage.institutionHelp"
|
|
62
|
+
}],
|
|
63
|
+
answerField: "uri",
|
|
64
|
+
displayFields: [{
|
|
65
|
+
label: "Institution",
|
|
66
|
+
propertyName: "displayName",
|
|
67
|
+
labelTranslationKey: "SignupPage.institution"
|
|
68
|
+
}],
|
|
69
|
+
responseField: "affiliations.items"
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
exports.AffiliationSearchQuestionSchema = TypeaheadSearchQuestionSchema.merge(zod_1.z.object({
|
|
73
|
+
type: zod_1.z.literal('affiliationSearch'),
|
|
74
|
+
meta: BaseMeta.unwrap().merge(zod_1.z.object({
|
|
75
|
+
title: zod_1.z.literal('Affiliation Search').optional(),
|
|
76
|
+
usageDescription: zod_1.z.literal('For questions that require the user to select from a controlled list of institutions.').optional(),
|
|
77
|
+
defaultJSON: zod_1.z.literal(JSON.stringify(defaultAffiliationSearchJSON)).optional(),
|
|
78
|
+
}))
|
|
79
|
+
}));
|