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