@dmptool/types 1.1.0 → 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.
Files changed (58) hide show
  1. package/README.md +2 -0
  2. package/dist/answers/__tests__/answers.spec.js +13 -7
  3. package/dist/answers/answer.d.ts +3 -3
  4. package/dist/answers/graphQLAnswers.d.ts +2 -2
  5. package/dist/answers/graphQLAnswers.js +2 -2
  6. package/dist/answers/index.d.ts +111 -74
  7. package/dist/answers/index.js +4 -4
  8. package/dist/answers/numberAnswers.d.ts +0 -25
  9. package/dist/answers/numberAnswers.js +1 -5
  10. package/dist/answers/optionBasedAnswers.d.ts +52 -2
  11. package/dist/answers/optionBasedAnswers.js +9 -1
  12. package/dist/answers/tableAnswers.d.ts +304 -140
  13. package/dist/answers/tableAnswers.js +3 -2
  14. package/dist/questions/__tests__/graphQLQuestions.spec.js +7 -7
  15. package/dist/questions/__tests__/numberQuestions.spec.js +0 -48
  16. package/dist/questions/__tests__/optionBasedQuestions.spec.js +98 -1
  17. package/dist/questions/dateQuestions.d.ts +47 -16
  18. package/dist/questions/dateQuestions.js +25 -1
  19. package/dist/questions/graphQLQuestions.d.ts +59 -28
  20. package/dist/questions/graphQLQuestions.js +40 -3
  21. package/dist/questions/index.d.ts +1567 -689
  22. package/dist/questions/index.js +7 -4
  23. package/dist/questions/numberQuestions.d.ts +71 -76
  24. package/dist/questions/numberQuestions.js +37 -8
  25. package/dist/questions/optionBasedQuestions.d.ts +227 -23
  26. package/dist/questions/optionBasedQuestions.js +89 -5
  27. package/dist/questions/question.d.ts +51 -4
  28. package/dist/questions/question.js +14 -2
  29. package/dist/questions/tableQuestions.d.ts +1965 -1056
  30. package/dist/questions/tableQuestions.js +14 -2
  31. package/dist/questions/textQuestions.d.ts +100 -40
  32. package/dist/questions/textQuestions.js +45 -7
  33. package/dist/schemas/affiliationSearchAnswer.schema.json +37 -0
  34. package/dist/schemas/affiliationSearchQuestion.schema.json +133 -0
  35. package/dist/schemas/anyAnswer.schema.json +41 -23
  36. package/dist/schemas/anyQuestion.schema.json +563 -146
  37. package/dist/schemas/anyTableColumnAnswer.schema.json +35 -14
  38. package/dist/schemas/anyTableColumnQuestion.schema.json +398 -119
  39. package/dist/schemas/booleanQuestion.schema.json +12 -0
  40. package/dist/schemas/checkboxesQuestion.schema.json +12 -0
  41. package/dist/schemas/currencyQuestion.schema.json +12 -0
  42. package/dist/schemas/dateQuestion.schema.json +12 -0
  43. package/dist/schemas/dateRangeQuestion.schema.json +12 -0
  44. package/dist/schemas/emailQuestion.schema.json +12 -0
  45. package/dist/schemas/filteredSearchQuestion.schema.json +10 -0
  46. package/dist/schemas/multiselectBoxAnswer.schema.json +40 -0
  47. package/dist/schemas/multiselectBoxQuestion.schema.json +90 -0
  48. package/dist/schemas/numberQuestion.schema.json +12 -0
  49. package/dist/schemas/numberRangeQuestion.schema.json +12 -0
  50. package/dist/schemas/radioButtonsQuestion.schema.json +12 -0
  51. package/dist/schemas/selectBoxAnswer.schema.json +1 -4
  52. package/dist/schemas/selectBoxQuestion.schema.json +18 -1
  53. package/dist/schemas/tableAnswer.schema.json +35 -14
  54. package/dist/schemas/tableQuestion.schema.json +420 -120
  55. package/dist/schemas/textAreaQuestion.schema.json +15 -4
  56. package/dist/schemas/textQuestion.schema.json +12 -0
  57. package/dist/schemas/urlQuestion.schema.json +12 -0
  58. package/package.json +1 -1
@@ -10,19 +10,20 @@ const numberAnswers_1 = require("./numberAnswers");
10
10
  const textAnswers_1 = require("./textAnswers");
11
11
  // Answers to Table Column Question Types (note that TableAnswer is not included here because we don't allow nested tables)
12
12
  exports.AnyTableColumnAnswerSchema = zod_1.z.discriminatedUnion('type', [
13
- numberAnswers_1.BooleanAnswerSchema,
13
+ graphQLAnswers_1.AffiliationSearchAnswerSchema,
14
+ optionBasedAnswers_1.BooleanAnswerSchema,
14
15
  optionBasedAnswers_1.CheckboxesAnswerSchema,
15
16
  numberAnswers_1.CurrencyAnswerSchema,
16
17
  dateAnswers_1.DateAnswerSchema,
17
18
  dateAnswers_1.DateRangeAnswerSchema,
18
19
  textAnswers_1.EmailAnswerSchema,
19
20
  graphQLAnswers_1.FilteredSearchAnswerSchema,
21
+ optionBasedAnswers_1.MultiselectBoxAnswerSchema,
20
22
  numberAnswers_1.NumberAnswerSchema,
21
23
  optionBasedAnswers_1.RadioButtonsAnswerSchema,
22
24
  optionBasedAnswers_1.SelectBoxAnswerSchema,
23
25
  textAnswers_1.TextAnswerSchema,
24
26
  textAnswers_1.TextAreaAnswerSchema,
25
- graphQLAnswers_1.TypeaheadSearchAnswerSchema,
26
27
  textAnswers_1.URLAnswerSchema
27
28
  ]);
28
29
  exports.TableColumnAnswerSchema = zod_1.z.object({
@@ -51,10 +51,10 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
51
51
  (0, globals_1.expect)(() => graphQLQuestions_1.FilteredSearchQuestionSchema.parse(invalidData)).toThrow();
52
52
  });
53
53
  });
54
- (0, globals_1.describe)("TypeaheadSearchQuestion schema", () => {
55
- (0, globals_1.it)("should validate a correct TypeaheadSearchQuestion object", () => {
54
+ (0, globals_1.describe)("AffiliationSearchQuestion schema", () => {
55
+ (0, globals_1.it)("should validate a correct AffiliationSearchQuestion object", () => {
56
56
  const validData = {
57
- type: "typeaheadSearch",
57
+ type: "affiliationSearch",
58
58
  attributes: {
59
59
  label: "Search",
60
60
  help: "Search for a user",
@@ -73,11 +73,11 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
73
73
  schemaVersion: "1.0"
74
74
  }
75
75
  };
76
- (0, globals_1.expect)(() => graphQLQuestions_1.TypeaheadSearchQuestionSchema.parse(validData)).not.toThrow();
76
+ (0, globals_1.expect)(() => graphQLQuestions_1.AffiliationSearchQuestionSchema.parse(validData)).not.toThrow();
77
77
  });
78
- (0, globals_1.it)("should throw an error for an invalid TypeaheadSearchQuestion object", () => {
78
+ (0, globals_1.it)("should throw an error for an invalid AffiliationSearchQuestion object", () => {
79
79
  const invalidData = {
80
- type: "typeaheadSearch",
80
+ type: "affiliationSearch",
81
81
  graphQL: {
82
82
  displayFields: [
83
83
  { propertyName: "title", label: "Title" },
@@ -88,6 +88,6 @@ const graphQLQuestions_1 = require("../graphQLQuestions");
88
88
  ],
89
89
  },
90
90
  };
91
- (0, globals_1.expect)(() => graphQLQuestions_1.TypeaheadSearchQuestionSchema.parse(invalidData)).toThrow();
91
+ (0, globals_1.expect)(() => graphQLQuestions_1.AffiliationSearchQuestionSchema.parse(invalidData)).toThrow();
92
92
  });
93
93
  });
@@ -2,54 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const numberQuestions_1 = require("../numberQuestions");
4
4
  describe("Number Questions Zod Schemas", () => {
5
- it('optional fields should not throw an error if the value is undefined', () => {
6
- const validBooleanQuestion = {
7
- type: "boolean",
8
- meta: {
9
- schemaVersion: "1.0",
10
- },
11
- attributes: {
12
- checked: undefined, // Valid value
13
- },
14
- };
15
- expect(() => numberQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
16
- });
17
- it('optional fields should throw an error if the value is null', () => {
18
- const invalidBooleanQuestion = {
19
- type: "boolean",
20
- meta: {
21
- schemaVersion: "1.0",
22
- },
23
- attributes: {
24
- checked: null, // Invalid value
25
- },
26
- };
27
- expect(() => numberQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
28
- });
29
- it("should validate a valid BooleanQuestion", () => {
30
- const validBooleanQuestion = {
31
- type: "boolean",
32
- meta: {
33
- schemaVersion: "1.0",
34
- },
35
- attributes: {
36
- checked: true,
37
- },
38
- };
39
- expect(() => numberQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
40
- });
41
- it("should invalidate an invalid BooleanQuestion", () => {
42
- const invalidBooleanQuestion = {
43
- type: "boolean",
44
- meta: {
45
- schemaVersion: "1.0",
46
- },
47
- attributes: {
48
- checked: "true", // Invalid type
49
- },
50
- };
51
- expect(() => numberQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
52
- });
53
5
  it("should validate a valid CurrencyQuestion", () => {
54
6
  const validCurrencyQuestion = {
55
7
  type: "currency",
@@ -2,6 +2,56 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const globals_1 = require("@jest/globals");
4
4
  const optionBasedQuestions_1 = require("../optionBasedQuestions");
5
+ (0, globals_1.describe)("BooleanQuestion", () => {
6
+ (0, globals_1.it)('optional fields should not throw an error if the value is undefined', () => {
7
+ const validBooleanQuestion = {
8
+ type: "boolean",
9
+ meta: {
10
+ schemaVersion: "1.0",
11
+ },
12
+ attributes: {
13
+ checked: undefined, // Valid value
14
+ },
15
+ };
16
+ (0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
17
+ });
18
+ (0, globals_1.it)('optional fields should throw an error if the value is null', () => {
19
+ const invalidBooleanQuestion = {
20
+ type: "boolean",
21
+ meta: {
22
+ schemaVersion: "1.0",
23
+ },
24
+ attributes: {
25
+ checked: null, // Invalid value
26
+ },
27
+ };
28
+ (0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
29
+ });
30
+ (0, globals_1.it)("should validate a valid BooleanQuestion", () => {
31
+ const validBooleanQuestion = {
32
+ type: "boolean",
33
+ meta: {
34
+ schemaVersion: "1.0",
35
+ },
36
+ attributes: {
37
+ checked: true,
38
+ },
39
+ };
40
+ (0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(validBooleanQuestion)).not.toThrow();
41
+ });
42
+ (0, globals_1.it)("should invalidate an invalid BooleanQuestion", () => {
43
+ const invalidBooleanQuestion = {
44
+ type: "boolean",
45
+ meta: {
46
+ schemaVersion: "1.0",
47
+ },
48
+ attributes: {
49
+ checked: "true", // Invalid type
50
+ },
51
+ };
52
+ (0, globals_1.expect)(() => optionBasedQuestions_1.BooleanQuestionSchema.parse(invalidBooleanQuestion)).toThrow();
53
+ });
54
+ });
5
55
  (0, globals_1.describe)("CheckboxesQuestion", () => {
6
56
  (0, globals_1.it)("should validate a valid CheckboxesQuestion object", () => {
7
57
  const validCheckboxesQuestion = {
@@ -97,7 +147,7 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
97
147
  attributes: {
98
148
  label: "Fruits",
99
149
  help: "Select all fruits you like",
100
- multiple: true,
150
+ multiple: false,
101
151
  },
102
152
  options: [
103
153
  {
@@ -137,3 +187,50 @@ const optionBasedQuestions_1 = require("../optionBasedQuestions");
137
187
  (0, globals_1.expect)(() => optionBasedQuestions_1.SelectBoxQuestionSchema.parse(invalidSelectBoxQuestion)).toThrow();
138
188
  });
139
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 TypeaheadSearchQuestionSchema: z.ZodObject<{
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: "typeaheadSearch";
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: "typeaheadSearch";
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 TypeaheadSearchQuestionType = z.infer<typeof TypeaheadSearchQuestionSchema>;
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.TypeaheadSearchQuestionSchema = exports.FilteredSearchQuestionSchema = void 0;
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
- exports.TypeaheadSearchQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
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
+ }));