@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
@@ -31,31 +31,35 @@ __exportStar(require("./optionBasedQuestions"), exports);
31
31
  __exportStar(require("./tableQuestions"), exports);
32
32
  __exportStar(require("./textQuestions"), exports);
33
33
  exports.AnyQuestionSchema = zod_1.z.discriminatedUnion('type', [
34
- numberQuestions_1.BooleanQuestionSchema,
34
+ graphQLQuestions_1.AffiliationSearchQuestionSchema,
35
+ optionBasedQuestions_1.BooleanQuestionSchema,
35
36
  optionBasedQuestions_1.CheckboxesQuestionSchema,
36
37
  numberQuestions_1.CurrencyQuestionSchema,
37
38
  dateQuestions_1.DateQuestionSchema,
38
39
  dateQuestions_1.DateRangeQuestionSchema,
39
40
  textQuestions_1.EmailQuestionSchema,
40
41
  graphQLQuestions_1.FilteredSearchQuestionSchema,
42
+ optionBasedQuestions_1.MultiselectBoxQuestionSchema,
41
43
  numberQuestions_1.NumberQuestionSchema,
44
+ numberQuestions_1.NumberRangeQuestionSchema,
42
45
  optionBasedQuestions_1.RadioButtonsQuestionSchema,
43
46
  optionBasedQuestions_1.SelectBoxQuestionSchema,
44
47
  tableQuestions_1.TableQuestionSchema,
45
48
  textQuestions_1.TextAreaQuestionSchema,
46
49
  textQuestions_1.TextQuestionSchema,
47
- graphQLQuestions_1.TypeaheadSearchQuestionSchema,
48
50
  textQuestions_1.URLQuestionSchema
49
51
  ]);
50
52
  // Export a mapping between Zod Schemas and their corresponding question type label
51
53
  exports.QuestionSchemaMap = {
52
- boolean: numberQuestions_1.BooleanQuestionSchema,
54
+ affiliationSearch: graphQLQuestions_1.AffiliationSearchQuestionSchema,
55
+ boolean: optionBasedQuestions_1.BooleanQuestionSchema,
53
56
  checkBoxes: optionBasedQuestions_1.CheckboxesQuestionSchema,
54
57
  currency: numberQuestions_1.CurrencyQuestionSchema,
55
58
  date: dateQuestions_1.DateQuestionSchema,
56
59
  dateRange: dateQuestions_1.DateRangeQuestionSchema,
57
60
  email: textQuestions_1.EmailQuestionSchema,
58
61
  filteredSearch: graphQLQuestions_1.FilteredSearchQuestionSchema,
62
+ multiselectBox: optionBasedQuestions_1.MultiselectBoxQuestionSchema,
59
63
  number: numberQuestions_1.NumberQuestionSchema,
60
64
  numberRange: numberQuestions_1.NumberRangeQuestionSchema,
61
65
  radioButtons: optionBasedQuestions_1.RadioButtonsQuestionSchema,
@@ -63,7 +67,6 @@ exports.QuestionSchemaMap = {
63
67
  table: tableQuestions_1.TableQuestionSchema,
64
68
  text: textQuestions_1.TextQuestionSchema,
65
69
  textArea: textQuestions_1.TextAreaQuestionSchema,
66
- typeaheadSearch: graphQLQuestions_1.TypeaheadSearchQuestionSchema,
67
70
  url: textQuestions_1.URLQuestionSchema
68
71
  };
69
72
  ;
@@ -1,63 +1,5 @@
1
1
  import { z } from "zod";
2
- export declare const BooleanQuestionSchema: 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
- } & {
11
- type: z.ZodLiteral<"boolean">;
12
- attributes: z.ZodOptional<z.ZodObject<{
13
- label: z.ZodOptional<z.ZodString>;
14
- help: z.ZodOptional<z.ZodString>;
15
- labelTranslationKey: z.ZodOptional<z.ZodString>;
16
- } & {
17
- checked: z.ZodOptional<z.ZodBoolean>;
18
- }, "strip", z.ZodTypeAny, {
19
- label?: string | undefined;
20
- help?: string | undefined;
21
- labelTranslationKey?: string | undefined;
22
- checked?: boolean | undefined;
23
- }, {
24
- label?: string | undefined;
25
- help?: string | undefined;
26
- labelTranslationKey?: string | undefined;
27
- checked?: boolean | undefined;
28
- }>>;
29
- }, "strip", z.ZodTypeAny, {
30
- type: "boolean";
31
- attributes?: {
32
- label?: string | undefined;
33
- help?: string | undefined;
34
- labelTranslationKey?: string | undefined;
35
- checked?: boolean | undefined;
36
- } | undefined;
37
- meta?: {
38
- schemaVersion: "1.0";
39
- } | undefined;
40
- }, {
41
- type: "boolean";
42
- attributes?: {
43
- label?: string | undefined;
44
- help?: string | undefined;
45
- labelTranslationKey?: string | undefined;
46
- checked?: boolean | undefined;
47
- } | undefined;
48
- meta?: {
49
- schemaVersion: "1.0";
50
- } | undefined;
51
- }>;
52
- export declare const CurrencyQuestionSchema: z.ZodObject<{
53
- meta: z.ZodOptional<z.ZodObject<{
54
- schemaVersion: z.ZodLiteral<"1.0">;
55
- }, "strip", z.ZodTypeAny, {
56
- schemaVersion: "1.0";
57
- }, {
58
- schemaVersion: "1.0";
59
- }>>;
60
- } & {
2
+ export declare const CurrencyQuestionSchema: z.ZodObject<{} & {
61
3
  type: z.ZodLiteral<"currency">;
62
4
  attributes: z.ZodOptional<z.ZodObject<{
63
5
  label: z.ZodOptional<z.ZodString>;
@@ -86,6 +28,23 @@ export declare const CurrencyQuestionSchema: z.ZodObject<{
86
28
  step?: number | undefined;
87
29
  denomination?: string | undefined;
88
30
  }>>;
31
+ meta: z.ZodOptional<z.ZodObject<{
32
+ schemaVersion: z.ZodLiteral<"1.0">;
33
+ } & {
34
+ title: z.ZodOptional<z.ZodLiteral<"Currency Field">>;
35
+ usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a monetary amount (e.g. Cost or Budget).">>;
36
+ defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
37
+ }, "strip", z.ZodTypeAny, {
38
+ schemaVersion: "1.0";
39
+ title?: "Currency Field" | undefined;
40
+ usageDescription?: "For questions that require a monetary amount (e.g. Cost or Budget)." | undefined;
41
+ defaultJSON?: string | undefined;
42
+ }, {
43
+ schemaVersion: "1.0";
44
+ title?: "Currency Field" | undefined;
45
+ usageDescription?: "For questions that require a monetary amount (e.g. Cost or Budget)." | undefined;
46
+ defaultJSON?: string | undefined;
47
+ }>>;
89
48
  }, "strip", z.ZodTypeAny, {
90
49
  type: "currency";
91
50
  attributes?: {
@@ -99,6 +58,9 @@ export declare const CurrencyQuestionSchema: z.ZodObject<{
99
58
  } | undefined;
100
59
  meta?: {
101
60
  schemaVersion: "1.0";
61
+ title?: "Currency Field" | undefined;
62
+ usageDescription?: "For questions that require a monetary amount (e.g. Cost or Budget)." | undefined;
63
+ defaultJSON?: string | undefined;
102
64
  } | undefined;
103
65
  }, {
104
66
  type: "currency";
@@ -113,17 +75,12 @@ export declare const CurrencyQuestionSchema: z.ZodObject<{
113
75
  } | undefined;
114
76
  meta?: {
115
77
  schemaVersion: "1.0";
78
+ title?: "Currency Field" | undefined;
79
+ usageDescription?: "For questions that require a monetary amount (e.g. Cost or Budget)." | undefined;
80
+ defaultJSON?: string | undefined;
116
81
  } | undefined;
117
82
  }>;
118
- export declare const NumberQuestionSchema: z.ZodObject<{
119
- meta: z.ZodOptional<z.ZodObject<{
120
- schemaVersion: z.ZodLiteral<"1.0">;
121
- }, "strip", z.ZodTypeAny, {
122
- schemaVersion: "1.0";
123
- }, {
124
- schemaVersion: "1.0";
125
- }>>;
126
- } & {
83
+ export declare const NumberQuestionSchema: z.ZodObject<{} & {
127
84
  type: z.ZodLiteral<"number">;
128
85
  attributes: z.ZodOptional<z.ZodObject<{
129
86
  label: z.ZodOptional<z.ZodString>;
@@ -148,6 +105,23 @@ export declare const NumberQuestionSchema: z.ZodObject<{
148
105
  min?: number | undefined;
149
106
  step?: number | undefined;
150
107
  }>>;
108
+ meta: z.ZodOptional<z.ZodObject<{
109
+ schemaVersion: z.ZodLiteral<"1.0">;
110
+ } & {
111
+ title: z.ZodOptional<z.ZodLiteral<"Number Field">>;
112
+ usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a single numeric value.">>;
113
+ defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
114
+ }, "strip", z.ZodTypeAny, {
115
+ schemaVersion: "1.0";
116
+ title?: "Number Field" | undefined;
117
+ usageDescription?: "For questions that require a single numeric value." | undefined;
118
+ defaultJSON?: string | undefined;
119
+ }, {
120
+ schemaVersion: "1.0";
121
+ title?: "Number Field" | undefined;
122
+ usageDescription?: "For questions that require a single numeric value." | undefined;
123
+ defaultJSON?: string | undefined;
124
+ }>>;
151
125
  }, "strip", z.ZodTypeAny, {
152
126
  type: "number";
153
127
  attributes?: {
@@ -160,6 +134,9 @@ export declare const NumberQuestionSchema: z.ZodObject<{
160
134
  } | undefined;
161
135
  meta?: {
162
136
  schemaVersion: "1.0";
137
+ title?: "Number Field" | undefined;
138
+ usageDescription?: "For questions that require a single numeric value." | undefined;
139
+ defaultJSON?: string | undefined;
163
140
  } | undefined;
164
141
  }, {
165
142
  type: "number";
@@ -173,6 +150,9 @@ export declare const NumberQuestionSchema: z.ZodObject<{
173
150
  } | undefined;
174
151
  meta?: {
175
152
  schemaVersion: "1.0";
153
+ title?: "Number Field" | undefined;
154
+ usageDescription?: "For questions that require a single numeric value." | undefined;
155
+ defaultJSON?: string | undefined;
176
156
  } | undefined;
177
157
  }>;
178
158
  export declare const NumberRangeQuestionSchema: z.ZodObject<{
@@ -189,13 +169,6 @@ export declare const NumberRangeQuestionSchema: z.ZodObject<{
189
169
  help?: string | undefined;
190
170
  labelTranslationKey?: string | undefined;
191
171
  }>>;
192
- meta: z.ZodOptional<z.ZodObject<{
193
- schemaVersion: z.ZodLiteral<"1.0">;
194
- }, "strip", z.ZodTypeAny, {
195
- schemaVersion: "1.0";
196
- }, {
197
- schemaVersion: "1.0";
198
- }>>;
199
172
  } & {
200
173
  type: z.ZodLiteral<"numberRange">;
201
174
  columns: z.ZodObject<{
@@ -280,6 +253,23 @@ export declare const NumberRangeQuestionSchema: z.ZodObject<{
280
253
  step?: number | undefined;
281
254
  } | undefined;
282
255
  }>;
256
+ meta: z.ZodOptional<z.ZodObject<{
257
+ schemaVersion: z.ZodLiteral<"1.0">;
258
+ } & {
259
+ title: z.ZodOptional<z.ZodLiteral<"Number Range">>;
260
+ usageDescription: z.ZodOptional<z.ZodLiteral<"For questions that require a numerical range (e.g. From/To, Min/Max).">>;
261
+ defaultJSON: z.ZodOptional<z.ZodLiteral<string>>;
262
+ }, "strip", z.ZodTypeAny, {
263
+ schemaVersion: "1.0";
264
+ title?: "Number Range" | undefined;
265
+ usageDescription?: "For questions that require a numerical range (e.g. From/To, Min/Max)." | undefined;
266
+ defaultJSON?: string | undefined;
267
+ }, {
268
+ schemaVersion: "1.0";
269
+ title?: "Number Range" | undefined;
270
+ usageDescription?: "For questions that require a numerical range (e.g. From/To, Min/Max)." | undefined;
271
+ defaultJSON?: string | undefined;
272
+ }>>;
283
273
  }, "strip", z.ZodTypeAny, {
284
274
  type: "numberRange";
285
275
  columns: {
@@ -307,6 +297,9 @@ export declare const NumberRangeQuestionSchema: z.ZodObject<{
307
297
  } | undefined;
308
298
  meta?: {
309
299
  schemaVersion: "1.0";
300
+ title?: "Number Range" | undefined;
301
+ usageDescription?: "For questions that require a numerical range (e.g. From/To, Min/Max)." | undefined;
302
+ defaultJSON?: string | undefined;
310
303
  } | undefined;
311
304
  }, {
312
305
  type: "numberRange";
@@ -335,9 +328,11 @@ export declare const NumberRangeQuestionSchema: z.ZodObject<{
335
328
  } | undefined;
336
329
  meta?: {
337
330
  schemaVersion: "1.0";
331
+ title?: "Number Range" | undefined;
332
+ usageDescription?: "For questions that require a numerical range (e.g. From/To, Min/Max)." | undefined;
333
+ defaultJSON?: string | undefined;
338
334
  } | undefined;
339
335
  }>;
340
- export type BooleanQuestionType = z.infer<typeof BooleanQuestionSchema>;
341
336
  export type CurrencyQuestionType = z.infer<typeof CurrencyQuestionSchema>;
342
337
  export type NumberQuestionType = z.infer<typeof NumberQuestionSchema>;
343
338
  export type NumberRangeQuestionType = z.infer<typeof NumberRangeQuestionSchema>;
@@ -1,34 +1,63 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NumberRangeQuestionSchema = exports.NumberQuestionSchema = exports.CurrencyQuestionSchema = exports.BooleanQuestionSchema = void 0;
3
+ exports.NumberRangeQuestionSchema = exports.NumberQuestionSchema = exports.CurrencyQuestionSchema = 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 NumberAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
8
9
  max: zod_1.z.number().optional(), // The highest value allowed (default no max)
9
10
  min: zod_1.z.number().optional(), // The lowest amount allowed (default 0)
10
11
  step: zod_1.z.number().optional() // The amount to increment. To allow decimals, use 0.01 (default 1)
11
12
  }));
12
- exports.BooleanQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
13
- type: zod_1.z.literal('boolean'),
14
- attributes: BaseAttributes.unwrap().merge(zod_1.z.object({
15
- checked: zod_1.z.boolean().optional(), // Whether it is checked by default
16
- })).optional(),
17
- }));
13
+ const defaultCurrencyJSON = {
14
+ type: 'currency',
15
+ attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { denomination: 'USD', max: undefined, min: 0, step: 1 }),
16
+ meta: Object.assign({}, question_1.defaultMeta)
17
+ };
18
18
  exports.CurrencyQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
19
19
  type: zod_1.z.literal('currency'),
20
20
  attributes: NumberAttributesSchema.merge(zod_1.z.object({
21
21
  denomination: zod_1.z.string().optional(), // The currency type (default is "USD")
22
22
  })).optional(),
23
+ meta: BaseMeta.unwrap().merge(zod_1.z.object({
24
+ title: zod_1.z.literal('Currency Field').optional(),
25
+ usageDescription: zod_1.z.literal('For questions that require a monetary amount (e.g. Cost or Budget).').optional(),
26
+ defaultJSON: zod_1.z.literal(JSON.stringify(defaultCurrencyJSON, null, 2)).optional(),
27
+ })).optional()
23
28
  }));
29
+ const defaultNumberJSON = {
30
+ type: 'number',
31
+ attributes: Object.assign(Object.assign({}, question_1.defaultAttributes), { max: undefined, min: 0, step: 1 }),
32
+ meta: Object.assign({}, question_1.defaultMeta)
33
+ };
24
34
  exports.NumberQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
25
35
  type: zod_1.z.literal('number'),
26
36
  attributes: NumberAttributesSchema.optional(),
37
+ meta: BaseMeta.unwrap().merge(zod_1.z.object({
38
+ title: zod_1.z.literal('Number Field').optional(),
39
+ usageDescription: zod_1.z.literal('For questions that require a single numeric value.').optional(),
40
+ defaultJSON: zod_1.z.literal(JSON.stringify(defaultNumberJSON, null, 2)).optional(),
41
+ })).optional()
27
42
  }));
43
+ const defaultNumberRangeJSON = {
44
+ type: 'numberRange',
45
+ attributes: Object.assign({}, question_1.defaultAttributes),
46
+ columns: {
47
+ start: Object.assign(Object.assign({}, question_1.defaultAttributes), { label: 'From', max: undefined, min: 0, step: 1 }),
48
+ end: Object.assign(Object.assign({}, question_1.defaultAttributes), { label: 'To', max: undefined, min: 0, step: 1 })
49
+ },
50
+ meta: Object.assign({}, question_1.defaultMeta)
51
+ };
28
52
  exports.NumberRangeQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
29
53
  type: zod_1.z.literal('numberRange'),
30
54
  columns: zod_1.z.object({
31
55
  start: NumberAttributesSchema.optional(),
32
56
  end: NumberAttributesSchema.optional()
33
- })
57
+ }),
58
+ meta: BaseMeta.unwrap().merge(zod_1.z.object({
59
+ title: zod_1.z.literal('Number Range').optional(),
60
+ usageDescription: zod_1.z.literal('For questions that require a numerical range (e.g. From/To, Min/Max).').optional(),
61
+ defaultJSON: zod_1.z.literal(JSON.stringify(defaultNumberRangeJSON, null, 2)).optional(),
62
+ })).optional()
34
63
  }));