@dmptool/types 1.1.2 → 1.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.
Files changed (78) hide show
  1. package/README.md +119 -47
  2. package/dist/answers/__tests__/answers.spec.js +20 -28
  3. package/dist/answers/__tests__/usage.spec.d.ts +1 -0
  4. package/dist/answers/__tests__/usage.spec.js +175 -0
  5. package/dist/answers/answer.d.ts +12 -15
  6. package/dist/answers/answer.js +3 -4
  7. package/dist/answers/dateAnswers.d.ts +30 -30
  8. package/dist/answers/dateAnswers.js +6 -5
  9. package/dist/answers/graphQLAnswers.d.ts +25 -25
  10. package/dist/answers/graphQLAnswers.js +4 -4
  11. package/dist/answers/index.d.ts +860 -1088
  12. package/dist/answers/index.js +2 -2
  13. package/dist/answers/numberAnswers.d.ts +41 -41
  14. package/dist/answers/numberAnswers.js +8 -8
  15. package/dist/answers/optionBasedAnswers.d.ts +55 -55
  16. package/dist/answers/optionBasedAnswers.js +10 -10
  17. package/dist/answers/tableAnswers.d.ts +811 -1772
  18. package/dist/answers/tableAnswers.js +12 -8
  19. package/dist/answers/textAnswers.d.ts +44 -44
  20. package/dist/answers/textAnswers.js +8 -8
  21. package/dist/questions/__tests__/graphQLQuestions.spec.js +6 -4
  22. package/dist/questions/__tests__/optionBasedQuestions.spec.js +4 -12
  23. package/dist/questions/__tests__/usage.spec.d.ts +8 -0
  24. package/dist/questions/__tests__/usage.spec.js +312 -0
  25. package/dist/questions/dateQuestions.d.ts +90 -101
  26. package/dist/questions/dateQuestions.js +15 -34
  27. package/dist/questions/graphQLQuestions.d.ts +176 -182
  28. package/dist/questions/graphQLQuestions.js +44 -45
  29. package/dist/questions/index.d.ts +1791 -2170
  30. package/dist/questions/index.js +2 -2
  31. package/dist/questions/numberQuestions.d.ts +126 -142
  32. package/dist/questions/numberQuestions.js +11 -45
  33. package/dist/questions/optionBasedQuestions.d.ts +197 -225
  34. package/dist/questions/optionBasedQuestions.js +24 -88
  35. package/dist/questions/question.d.ts +24 -56
  36. package/dist/questions/question.js +78 -18
  37. package/dist/questions/tableQuestions.d.ts +2637 -2930
  38. package/dist/questions/tableQuestions.js +9 -21
  39. package/dist/questions/textQuestions.d.ts +125 -145
  40. package/dist/questions/textQuestions.js +16 -57
  41. package/dist/schemas/affiliationSearchAnswer.schema.json +9 -12
  42. package/dist/schemas/affiliationSearchQuestion.schema.json +57 -50
  43. package/dist/schemas/anyAnswer.schema.json +228 -237
  44. package/dist/schemas/anyQuestion.schema.json +349 -517
  45. package/dist/schemas/anyTableColumnAnswer.schema.json +93 -106
  46. package/dist/schemas/anyTableColumnQuestion.schema.json +259 -382
  47. package/dist/schemas/booleanAnswer.schema.json +8 -11
  48. package/dist/schemas/booleanQuestion.schema.json +9 -15
  49. package/dist/schemas/checkboxesAnswer.schema.json +13 -14
  50. package/dist/schemas/checkboxesQuestion.schema.json +18 -24
  51. package/dist/schemas/currencyAnswer.schema.json +8 -11
  52. package/dist/schemas/currencyQuestion.schema.json +13 -17
  53. package/dist/schemas/dateAnswer.schema.json +8 -11
  54. package/dist/schemas/dateQuestion.schema.json +9 -15
  55. package/dist/schemas/dateRangeAnswer.schema.json +16 -21
  56. package/dist/schemas/dateRangeQuestion.schema.json +40 -21
  57. package/dist/schemas/emailAnswer.schema.json +8 -11
  58. package/dist/schemas/emailQuestion.schema.json +11 -16
  59. package/dist/schemas/filteredSearchQuestion.schema.json +0 -3
  60. package/dist/schemas/multiselectBoxAnswer.schema.json +13 -14
  61. package/dist/schemas/multiselectBoxQuestion.schema.json +20 -25
  62. package/dist/schemas/numberAnswer.schema.json +8 -11
  63. package/dist/schemas/numberQuestion.schema.json +11 -16
  64. package/dist/schemas/numberRangeAnswer.schema.json +17 -22
  65. package/dist/schemas/numberRangeQuestion.schema.json +22 -21
  66. package/dist/schemas/radioButtonsAnswer.schema.json +8 -11
  67. package/dist/schemas/radioButtonsQuestion.schema.json +18 -24
  68. package/dist/schemas/selectBoxAnswer.schema.json +8 -11
  69. package/dist/schemas/selectBoxQuestion.schema.json +20 -25
  70. package/dist/schemas/tableAnswer.schema.json +337 -343
  71. package/dist/schemas/tableQuestion.schema.json +279 -416
  72. package/dist/schemas/textAnswer.schema.json +8 -11
  73. package/dist/schemas/textAreaAnswer.schema.json +8 -11
  74. package/dist/schemas/textAreaQuestion.schema.json +13 -17
  75. package/dist/schemas/textQuestion.schema.json +9 -15
  76. package/dist/schemas/urlAnswer.schema.json +8 -11
  77. package/dist/schemas/urlQuestion.schema.json +9 -15
  78. package/package.json +1 -1
@@ -1,21 +1,35 @@
1
1
  import { z } from "zod";
2
- export declare const DateQuestionSchema: z.ZodObject<{} & {
2
+ export declare const DateQuestionSchema: z.ZodObject<{
3
+ meta: z.ZodDefault<z.ZodObject<{
4
+ schemaVersion: z.ZodDefault<z.ZodString>;
5
+ title: z.ZodOptional<z.ZodString>;
6
+ usageDescription: z.ZodOptional<z.ZodString>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ schemaVersion: string;
9
+ title?: string | undefined;
10
+ usageDescription?: string | undefined;
11
+ }, {
12
+ schemaVersion?: string | undefined;
13
+ title?: string | undefined;
14
+ usageDescription?: string | undefined;
15
+ }>>;
16
+ } & {
3
17
  type: z.ZodLiteral<"date">;
4
- attributes: z.ZodOptional<z.ZodObject<{
18
+ attributes: z.ZodDefault<z.ZodObject<{
5
19
  label: z.ZodOptional<z.ZodString>;
6
20
  help: z.ZodOptional<z.ZodString>;
7
21
  labelTranslationKey: z.ZodOptional<z.ZodString>;
8
22
  } & {
9
23
  max: z.ZodOptional<z.ZodString>;
10
24
  min: z.ZodOptional<z.ZodString>;
11
- step: z.ZodOptional<z.ZodNumber>;
25
+ step: z.ZodDefault<z.ZodNumber>;
12
26
  }, "strip", z.ZodTypeAny, {
27
+ step: number;
13
28
  label?: string | undefined;
14
29
  help?: string | undefined;
15
30
  labelTranslationKey?: string | undefined;
16
31
  max?: string | undefined;
17
32
  min?: string | undefined;
18
- step?: number | undefined;
19
33
  }, {
20
34
  label?: string | undefined;
21
35
  help?: string | undefined;
@@ -24,39 +38,21 @@ export declare const DateQuestionSchema: z.ZodObject<{} & {
24
38
  min?: string | undefined;
25
39
  step?: number | undefined;
26
40
  }>>;
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
- }>>;
44
41
  }, "strip", z.ZodTypeAny, {
45
42
  type: "date";
46
- attributes?: {
43
+ attributes: {
44
+ step: number;
47
45
  label?: string | undefined;
48
46
  help?: string | undefined;
49
47
  labelTranslationKey?: string | undefined;
50
48
  max?: string | undefined;
51
49
  min?: string | undefined;
52
- step?: number | undefined;
53
- } | undefined;
54
- meta?: {
55
- schemaVersion: "1.0";
56
- title?: "Date Field" | undefined;
57
- usageDescription?: "For questions that require a date." | undefined;
58
- defaultJSON?: string | undefined;
59
- } | undefined;
50
+ };
51
+ meta: {
52
+ schemaVersion: string;
53
+ title?: string | undefined;
54
+ usageDescription?: string | undefined;
55
+ };
60
56
  }, {
61
57
  type: "date";
62
58
  attributes?: {
@@ -68,14 +64,28 @@ export declare const DateQuestionSchema: z.ZodObject<{} & {
68
64
  step?: number | undefined;
69
65
  } | undefined;
70
66
  meta?: {
71
- schemaVersion: "1.0";
72
- title?: "Date Field" | undefined;
73
- usageDescription?: "For questions that require a date." | undefined;
74
- defaultJSON?: string | undefined;
67
+ schemaVersion?: string | undefined;
68
+ title?: string | undefined;
69
+ usageDescription?: string | undefined;
75
70
  } | undefined;
76
71
  }>;
77
72
  export declare const DateRangeQuestionSchema: z.ZodObject<{
78
- attributes: z.ZodOptional<z.ZodObject<{
73
+ meta: z.ZodDefault<z.ZodObject<{
74
+ schemaVersion: z.ZodDefault<z.ZodString>;
75
+ title: z.ZodOptional<z.ZodString>;
76
+ usageDescription: z.ZodOptional<z.ZodString>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ schemaVersion: string;
79
+ title?: string | undefined;
80
+ usageDescription?: string | undefined;
81
+ }, {
82
+ schemaVersion?: string | undefined;
83
+ title?: string | undefined;
84
+ usageDescription?: string | undefined;
85
+ }>>;
86
+ } & {
87
+ type: z.ZodLiteral<"dateRange">;
88
+ attributes: z.ZodDefault<z.ZodObject<{
79
89
  label: z.ZodOptional<z.ZodString>;
80
90
  help: z.ZodOptional<z.ZodString>;
81
91
  labelTranslationKey: z.ZodOptional<z.ZodString>;
@@ -88,24 +98,22 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
88
98
  help?: string | undefined;
89
99
  labelTranslationKey?: string | undefined;
90
100
  }>>;
91
- } & {
92
- type: z.ZodLiteral<"dateRange">;
93
- columns: z.ZodObject<{
94
- start: z.ZodOptional<z.ZodObject<{
95
- label: z.ZodOptional<z.ZodString>;
101
+ columns: z.ZodDefault<z.ZodObject<{
102
+ start: z.ZodDefault<z.ZodObject<{
96
103
  help: z.ZodOptional<z.ZodString>;
97
104
  labelTranslationKey: z.ZodOptional<z.ZodString>;
98
- } & {
99
105
  max: z.ZodOptional<z.ZodString>;
100
106
  min: z.ZodOptional<z.ZodString>;
101
- step: z.ZodOptional<z.ZodNumber>;
107
+ step: z.ZodDefault<z.ZodNumber>;
108
+ } & {
109
+ label: z.ZodDefault<z.ZodString>;
102
110
  }, "strip", z.ZodTypeAny, {
103
- label?: string | undefined;
111
+ label: string;
112
+ step: number;
104
113
  help?: string | undefined;
105
114
  labelTranslationKey?: string | undefined;
106
115
  max?: string | undefined;
107
116
  min?: string | undefined;
108
- step?: number | undefined;
109
117
  }, {
110
118
  label?: string | undefined;
111
119
  help?: string | undefined;
@@ -114,21 +122,21 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
114
122
  min?: string | undefined;
115
123
  step?: number | undefined;
116
124
  }>>;
117
- end: z.ZodOptional<z.ZodObject<{
118
- label: z.ZodOptional<z.ZodString>;
125
+ end: z.ZodDefault<z.ZodObject<{
119
126
  help: z.ZodOptional<z.ZodString>;
120
127
  labelTranslationKey: z.ZodOptional<z.ZodString>;
121
- } & {
122
128
  max: z.ZodOptional<z.ZodString>;
123
129
  min: z.ZodOptional<z.ZodString>;
124
- step: z.ZodOptional<z.ZodNumber>;
130
+ step: z.ZodDefault<z.ZodNumber>;
131
+ } & {
132
+ label: z.ZodDefault<z.ZodString>;
125
133
  }, "strip", z.ZodTypeAny, {
126
- label?: string | undefined;
134
+ label: string;
135
+ step: number;
127
136
  help?: string | undefined;
128
137
  labelTranslationKey?: string | undefined;
129
138
  max?: string | undefined;
130
139
  min?: string | undefined;
131
- step?: number | undefined;
132
140
  }, {
133
141
  label?: string | undefined;
134
142
  help?: string | undefined;
@@ -138,22 +146,22 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
138
146
  step?: number | undefined;
139
147
  }>>;
140
148
  }, "strip", z.ZodTypeAny, {
141
- start?: {
142
- label?: string | undefined;
149
+ start: {
150
+ label: string;
151
+ step: number;
143
152
  help?: string | undefined;
144
153
  labelTranslationKey?: string | undefined;
145
154
  max?: string | undefined;
146
155
  min?: string | undefined;
147
- step?: number | undefined;
148
- } | undefined;
149
- end?: {
150
- label?: string | undefined;
156
+ };
157
+ end: {
158
+ label: string;
159
+ step: number;
151
160
  help?: string | undefined;
152
161
  labelTranslationKey?: string | undefined;
153
162
  max?: string | undefined;
154
163
  min?: string | undefined;
155
- step?: number | undefined;
156
- } | undefined;
164
+ };
157
165
  }, {
158
166
  start?: {
159
167
  label?: string | undefined;
@@ -171,58 +179,50 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
171
179
  min?: string | undefined;
172
180
  step?: number | undefined;
173
181
  } | undefined;
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
182
  }>>;
192
183
  }, "strip", z.ZodTypeAny, {
193
184
  type: "dateRange";
185
+ attributes: {
186
+ label?: string | undefined;
187
+ help?: string | undefined;
188
+ labelTranslationKey?: string | undefined;
189
+ };
190
+ meta: {
191
+ schemaVersion: string;
192
+ title?: string | undefined;
193
+ usageDescription?: string | undefined;
194
+ };
194
195
  columns: {
195
- start?: {
196
- label?: string | undefined;
196
+ start: {
197
+ label: string;
198
+ step: number;
197
199
  help?: string | undefined;
198
200
  labelTranslationKey?: string | undefined;
199
201
  max?: string | undefined;
200
202
  min?: string | undefined;
201
- step?: number | undefined;
202
- } | undefined;
203
- end?: {
204
- label?: string | undefined;
203
+ };
204
+ end: {
205
+ label: string;
206
+ step: number;
205
207
  help?: string | undefined;
206
208
  labelTranslationKey?: string | undefined;
207
209
  max?: string | undefined;
208
210
  min?: string | undefined;
209
- step?: number | undefined;
210
- } | undefined;
211
+ };
211
212
  };
213
+ }, {
214
+ type: "dateRange";
212
215
  attributes?: {
213
216
  label?: string | undefined;
214
217
  help?: string | undefined;
215
218
  labelTranslationKey?: string | undefined;
216
219
  } | undefined;
217
220
  meta?: {
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;
221
+ schemaVersion?: string | undefined;
222
+ title?: string | undefined;
223
+ usageDescription?: string | undefined;
222
224
  } | undefined;
223
- }, {
224
- type: "dateRange";
225
- columns: {
225
+ columns?: {
226
226
  start?: {
227
227
  label?: string | undefined;
228
228
  help?: string | undefined;
@@ -239,17 +239,6 @@ export declare const DateRangeQuestionSchema: z.ZodObject<{
239
239
  min?: string | undefined;
240
240
  step?: number | undefined;
241
241
  } | undefined;
242
- };
243
- attributes?: {
244
- label?: string | undefined;
245
- help?: string | undefined;
246
- labelTranslationKey?: string | undefined;
247
- } | undefined;
248
- meta?: {
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;
253
242
  } | undefined;
254
243
  }>;
255
244
  export type DateQuestionType = z.infer<typeof DateQuestionSchema>;
@@ -4,45 +4,26 @@ 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;
8
- const DateAttributesSchema = BaseAttributes.unwrap().merge(zod_1.z.object({
9
- max: zod_1.z.string().optional(), // The maximum date (no default)
10
- min: zod_1.z.string().optional(), // The minimum date (no default)
11
- step: zod_1.z.number().optional() // The step value (default is 1 day)
7
+ const DateAttributesSchema = BaseAttributes.merge(zod_1.z.object({
8
+ max: zod_1.z.string().optional(),
9
+ min: zod_1.z.string().optional(),
10
+ step: zod_1.z.number().default(1),
12
11
  }));
13
12
  // 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
- };
19
13
  exports.DateQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
20
- type: zod_1.z.literal('date'), // The type of question
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(),
14
+ type: zod_1.z.literal('date'),
15
+ attributes: DateAttributesSchema.default({})
27
16
  }));
28
17
  // 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
- };
37
18
  exports.DateRangeQuestionSchema = question_1.QuestionSchema.merge(zod_1.z.object({
38
- type: zod_1.z.literal('dateRange'), // The type of question
19
+ type: zod_1.z.literal('dateRange'),
20
+ attributes: BaseAttributes.default({}),
39
21
  columns: zod_1.z.object({
40
- start: DateAttributesSchema.optional(),
41
- end: DateAttributesSchema.optional()
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(),
22
+ start: DateAttributesSchema.merge(zod_1.z.object({
23
+ label: zod_1.z.string().default('From')
24
+ })).default({}),
25
+ end: DateAttributesSchema.merge(zod_1.z.object({
26
+ label: zod_1.z.string().default('To')
27
+ })).default({}),
28
+ }).default({})
48
29
  }));