@dmptool/types 1.0.6 → 1.0.8

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 (43) hide show
  1. package/README.md +5 -4
  2. package/dist/answers/__tests__/answers.spec.js +59 -7
  3. package/dist/answers/answer.d.ts +3 -3
  4. package/dist/answers/dateAnswers.d.ts +5 -5
  5. package/dist/answers/dateAnswers.js +3 -3
  6. package/dist/answers/index.d.ts +892 -513
  7. package/dist/answers/index.js +3 -2
  8. package/dist/answers/primitiveAnswers.d.ts +40 -0
  9. package/dist/answers/primitiveAnswers.js +8 -1
  10. package/dist/answers/tableAnswers.d.ts +1639 -32
  11. package/dist/answers/tableAnswers.js +10 -3
  12. package/dist/questions/__tests__/dateQuestions.spec.js +20 -20
  13. package/dist/questions/__tests__/primitiveQuestions.spec.js +92 -0
  14. package/dist/questions/__tests__/tableQuestion.spec.d.ts +1 -0
  15. package/dist/questions/__tests__/tableQuestion.spec.js +73 -0
  16. package/dist/questions/dateQuestions.d.ts +19 -19
  17. package/dist/questions/dateQuestions.js +8 -8
  18. package/dist/questions/graphQLQuestions.d.ts +20 -20
  19. package/dist/questions/graphQLQuestions.js +1 -1
  20. package/dist/questions/index.d.ts +1856 -1413
  21. package/dist/questions/index.js +3 -2
  22. package/dist/questions/optionBasedQuestions.js +1 -1
  23. package/dist/questions/primitiveQuestions.d.ts +193 -0
  24. package/dist/questions/primitiveQuestions.js +17 -1
  25. package/dist/questions/question.d.ts +4 -4
  26. package/dist/questions/question.js +2 -1
  27. package/dist/questions/tableQuestions.d.ts +2124 -145
  28. package/dist/questions/tableQuestions.js +7 -3
  29. package/dist/schemas/anyAnswer.schema.json +144 -119
  30. package/dist/schemas/anyQuestion.schema.json +148 -137
  31. package/dist/schemas/anyTableColumnAnswer.schema.json +1 -1
  32. package/dist/schemas/anyTableColumnQuestion.schema.json +2 -3
  33. package/dist/schemas/dateAnswer.schema.json +37 -0
  34. package/dist/schemas/datePickerAnswer.schema.json +4 -4
  35. package/dist/schemas/datePickerQuestion.schema.json +6 -5
  36. package/dist/schemas/dateQuestion.schema.json +51 -0
  37. package/dist/schemas/dateRangeQuestion.schema.json +1 -1
  38. package/dist/schemas/filteredSearchQuestion.schema.json +1 -2
  39. package/dist/schemas/numberRangeAnswer.schema.json +50 -0
  40. package/dist/schemas/numberRangeQuestion.schema.json +106 -0
  41. package/dist/schemas/tableAnswer.schema.json +349 -324
  42. package/dist/schemas/tableQuestion.schema.json +491 -480
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -22,11 +22,12 @@ The available question schemas/types are:
22
22
  - `BooleanQuestion` A Yes/No True/False question.
23
23
  - `CheckboxesQuestion` A question type that supports an array of `option` objects. The user may "check" multiple options.
24
24
  - `CurrencyQuestion` A number field that supports the defintiion of a `denomination`.
25
- - `DatePickerQuestion` A date field. Supports `YYYY-MM-DD` format.
26
- - `DateRangeQuestion` A series of 2 date picker fields. Meant to capture "From" and "To" or "Start" and "End" dates.
25
+ - `DateQuestion` A date field. Supports `YYYY-MM-DD` format.
26
+ - `DateRangeQuestion` A series of 2 date fields. Meant to capture "From" and "To" or "Start" and "End" dates.
27
27
  - `EmailQuestion` An email address. Supports multiple emails that are comma separated.
28
28
  - `FilteredSearchQuestion` A complex field that allows the user to enter a search term and filters. The field fires a graphQL query and allows the user to potentially select multiple results.
29
29
  - `NumberQuestion` A numeric field. Supports both integers and floats.
30
+ - `NumberRangeQuestion` A series of 2 number fields. Meant to capture "From" and "To" or "Min" and "Max" numbers.
30
31
  - `RadioButtonsQuestion` A question type that supports an array of `option` objects. The user may "select" a single option.
31
32
  - `SelectBoxQuestion` A drop down select box that supports an array of `option` objects. A `multiple` flag can be set to allow multi-select.
32
33
  - `TableQuestion` A table question type. Each column in the table can be any one of the `AnyTableColumnQuestion` types.
@@ -45,8 +46,8 @@ The available answer schemas/types are:
45
46
  - `BooleanAnswer` A Yes/No True/False answer.
46
47
  - `CheckboxesAnswer` A answer type that supports an array of `option` objects. The user may "check" multiple options.
47
48
  - `CurrencyAnswer` A number field that supports the defintiion of a `denomination`.
48
- - `DatePickerAnswer` A date field. Supports `YYYY-MM-DD` format.
49
- - `DateRangeAnswer` A series of 2 date picker fields. Meant to capture "From" and "To" or "Start" and "End" dates.
49
+ - `DateAnswer` A date field. Supports `YYYY-MM-DD` format.
50
+ - `DateRangeAnswer` A series of 2 date fields. Meant to capture "From" and "To" or "Start" and "End" dates.
50
51
  - `EmailAnswer` An email address. Supports multiple emails that are comma separated.
51
52
  - `FilteredSearchAnswer` A complex field that allows the user to enter a search term and filters. The field fires a graphQL query and allows the user to potentially select multiple results.
52
53
  - `NumberAnswer` A numeric field. Supports both integers and floats.
@@ -27,11 +27,11 @@ const questions_1 = require("../../questions");
27
27
  const invalidData = { type: 'currency', answer: '100.5', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
28
28
  (0, globals_1.expect)(() => primitiveAnswers_1.CurrencyAnswerSchema.parse(invalidData)).toThrow();
29
29
  });
30
- (0, globals_1.it)('should validate DatePickerAnswer', () => {
31
- const validData = { type: 'datePicker', answer: '2023-10-01', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
32
- (0, globals_1.expect)(() => dateAnswers_1.DatePickerAnswerSchema.parse(validData)).not.toThrow();
33
- const invalidData = { type: 'datePicker', answer: 12345, meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
34
- (0, globals_1.expect)(() => dateAnswers_1.DatePickerAnswerSchema.parse(invalidData)).toThrow();
30
+ (0, globals_1.it)('should validate DateAnswer', () => {
31
+ const validData = { type: 'date', answer: '2023-10-01', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
32
+ (0, globals_1.expect)(() => dateAnswers_1.DateAnswerSchema.parse(validData)).not.toThrow();
33
+ const invalidData = { type: 'date', answer: 12345, meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
34
+ (0, globals_1.expect)(() => dateAnswers_1.DateAnswerSchema.parse(invalidData)).toThrow();
35
35
  });
36
36
  (0, globals_1.it)('should validate DateRangeAnswer', () => {
37
37
  const validData = {
@@ -65,6 +65,20 @@ const questions_1 = require("../../questions");
65
65
  const invalidData = { type: 'number', answer: '42', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
66
66
  (0, globals_1.expect)(() => primitiveAnswers_1.NumberAnswerSchema.parse(invalidData)).toThrow();
67
67
  });
68
+ (0, globals_1.it)('should validate NumberRangeAnswer', () => {
69
+ const validData = {
70
+ type: 'numberRange',
71
+ answer: { start: 1, end: 10 },
72
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
73
+ };
74
+ (0, globals_1.expect)(() => primitiveAnswers_1.NumberRangeAnswerSchema.parse(validData)).not.toThrow();
75
+ const invalidData = {
76
+ type: 'numberRange',
77
+ answer: { start: '1', end: 10 },
78
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
79
+ };
80
+ (0, globals_1.expect)(() => primitiveAnswers_1.NumberRangeAnswerSchema.parse(invalidData)).toThrow();
81
+ });
68
82
  (0, globals_1.it)('should validate RadioButtonsAnswer', () => {
69
83
  const validData = { type: 'radioButtons', answer: 'option1', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } };
70
84
  (0, globals_1.expect)(() => optionBasedAnswers_1.RadioButtonsAnswerSchema.parse(validData)).not.toThrow();
@@ -105,8 +119,46 @@ const questions_1 = require("../../questions");
105
119
  const validData = {
106
120
  type: 'table',
107
121
  answer: [
108
- { type: 'text', answer: 'Row 1', meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } },
109
- { type: 'number', answer: 42, meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION } },
122
+ {
123
+ columns: [
124
+ {
125
+ heading: "Name",
126
+ content: {
127
+ type: 'text',
128
+ answer: 'Leia Organa',
129
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
130
+ }
131
+ },
132
+ {
133
+ heading: "Age",
134
+ content: {
135
+ type: 'number',
136
+ answer: 28,
137
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
138
+ }
139
+ }
140
+ ]
141
+ },
142
+ {
143
+ columns: [
144
+ {
145
+ heading: "Name",
146
+ content: {
147
+ type: 'text',
148
+ answer: 'Han Solo',
149
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
150
+ }
151
+ },
152
+ {
153
+ heading: "Age",
154
+ content: {
155
+ type: 'number',
156
+ answer: 35,
157
+ meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
158
+ }
159
+ }
160
+ ]
161
+ }
110
162
  ],
111
163
  meta: { schemaVersion: questions_1.CURRENT_SCHEMA_VERSION }
112
164
  };
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const AnswerSchema: z.ZodObject<{
3
- type: z.ZodEnum<["boolean", "checkBoxes", "currency", "datePicker", "dateRange", "email", "filteredSearch", "number", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
3
+ type: z.ZodEnum<["boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "typeaheadSearch", "url"]>;
4
4
  answer: z.ZodString;
5
5
  meta: z.ZodObject<{
6
6
  schemaVersion: z.ZodLiteral<"1.0">;
@@ -10,13 +10,13 @@ export declare const AnswerSchema: z.ZodObject<{
10
10
  schemaVersion: "1.0";
11
11
  }>;
12
12
  }, "strip", z.ZodTypeAny, {
13
- type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
13
+ type: "number" | "boolean" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
14
14
  meta: {
15
15
  schemaVersion: "1.0";
16
16
  };
17
17
  answer: string;
18
18
  }, {
19
- type: "number" | "boolean" | "checkBoxes" | "currency" | "datePicker" | "dateRange" | "email" | "filteredSearch" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
19
+ type: "number" | "boolean" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "typeaheadSearch" | "url";
20
20
  meta: {
21
21
  schemaVersion: "1.0";
22
22
  };
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- export declare const DatePickerAnswerSchema: z.ZodObject<{
2
+ export declare const DateAnswerSchema: z.ZodObject<{
3
3
  answer: z.ZodString;
4
4
  meta: z.ZodObject<{
5
5
  schemaVersion: z.ZodLiteral<"1.0">;
@@ -9,15 +9,15 @@ export declare const DatePickerAnswerSchema: z.ZodObject<{
9
9
  schemaVersion: "1.0";
10
10
  }>;
11
11
  } & {
12
- type: z.ZodLiteral<"datePicker">;
12
+ type: z.ZodLiteral<"date">;
13
13
  }, "strip", z.ZodTypeAny, {
14
- type: "datePicker";
14
+ type: "date";
15
15
  meta: {
16
16
  schemaVersion: "1.0";
17
17
  };
18
18
  answer: string;
19
19
  }, {
20
- type: "datePicker";
20
+ type: "date";
21
21
  meta: {
22
22
  schemaVersion: "1.0";
23
23
  };
@@ -62,5 +62,5 @@ export declare const DateRangeAnswerSchema: z.ZodObject<{
62
62
  end: string;
63
63
  };
64
64
  }>;
65
- export type DatePickerAnswerType = z.infer<typeof DatePickerAnswerSchema>;
65
+ export type DateAnswerType = z.infer<typeof DateAnswerSchema>;
66
66
  export type DateRangeAnswerType = z.infer<typeof DateRangeAnswerSchema>;
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DateRangeAnswerSchema = exports.DatePickerAnswerSchema = void 0;
3
+ exports.DateRangeAnswerSchema = exports.DateAnswerSchema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const answer_1 = require("./answer");
6
6
  // Answers to Date Question Types
7
- exports.DatePickerAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
8
- type: zod_1.z.literal('datePicker'), // The type of question
7
+ exports.DateAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
8
+ type: zod_1.z.literal('date'), // The type of question
9
9
  }));
10
10
  exports.DateRangeAnswerSchema = answer_1.AnswerSchema.merge(zod_1.z.object({
11
11
  type: zod_1.z.literal('dateRange'), // The type of answer