@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,37 +1,9 @@
1
1
  import { z } from "zod";
2
2
  export declare const CURRENT_SCHEMA_VERSION = "1.0";
3
- export declare const QuestionTypesEnum: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
4
- export declare const defaultMeta: z.infer<typeof DefaultMetaSchema>;
5
- export declare const defaultAttributes: z.infer<typeof DefaultAttributesSchema>;
6
- declare const DefaultMetaSchema: z.ZodObject<{
7
- schemaVersion: z.ZodLiteral<"1.0">;
8
- title: z.ZodOptional<z.ZodString>;
9
- usageDescription: z.ZodOptional<z.ZodString>;
10
- }, "strip", z.ZodTypeAny, {
11
- schemaVersion: "1.0";
12
- title?: string | undefined;
13
- usageDescription?: string | undefined;
14
- }, {
15
- schemaVersion: "1.0";
16
- title?: string | undefined;
17
- usageDescription?: string | undefined;
18
- }>;
19
- declare const DefaultAttributesSchema: z.ZodObject<{
20
- label: z.ZodOptional<z.ZodString>;
21
- help: z.ZodOptional<z.ZodString>;
22
- labelTranslationKey: z.ZodOptional<z.ZodString>;
23
- }, "strip", z.ZodTypeAny, {
24
- label?: string | undefined;
25
- help?: string | undefined;
26
- labelTranslationKey?: string | undefined;
27
- }, {
28
- label?: string | undefined;
29
- help?: string | undefined;
30
- labelTranslationKey?: string | undefined;
31
- }>;
3
+ export declare const QuestionFormatsEnum: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
32
4
  export declare const QuestionSchema: z.ZodObject<{
33
- type: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "filteredSearch", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
34
- attributes: z.ZodOptional<z.ZodObject<{
5
+ type: z.ZodEnum<["affiliationSearch", "boolean", "checkBoxes", "currency", "date", "dateRange", "email", "multiselectBox", "number", "numberRange", "radioButtons", "selectBox", "table", "text", "textArea", "url"]>;
6
+ attributes: z.ZodObject<{
35
7
  label: z.ZodOptional<z.ZodString>;
36
8
  help: z.ZodOptional<z.ZodString>;
37
9
  labelTranslationKey: z.ZodOptional<z.ZodString>;
@@ -43,44 +15,48 @@ export declare const QuestionSchema: z.ZodObject<{
43
15
  label?: string | undefined;
44
16
  help?: string | undefined;
45
17
  labelTranslationKey?: string | undefined;
46
- }>>;
47
- meta: z.ZodOptional<z.ZodObject<{
48
- schemaVersion: z.ZodLiteral<"1.0">;
18
+ }>;
19
+ meta: z.ZodDefault<z.ZodObject<{
20
+ schemaVersion: z.ZodDefault<z.ZodString>;
49
21
  title: z.ZodOptional<z.ZodString>;
50
22
  usageDescription: z.ZodOptional<z.ZodString>;
51
23
  }, "strip", z.ZodTypeAny, {
52
- schemaVersion: "1.0";
24
+ schemaVersion: string;
53
25
  title?: string | undefined;
54
26
  usageDescription?: string | undefined;
55
27
  }, {
56
- schemaVersion: "1.0";
28
+ schemaVersion?: string | undefined;
57
29
  title?: string | undefined;
58
30
  usageDescription?: string | undefined;
59
31
  }>>;
60
32
  }, "strip", z.ZodTypeAny, {
61
- type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
62
- attributes?: {
33
+ type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
34
+ attributes: {
63
35
  label?: string | undefined;
64
36
  help?: string | undefined;
65
37
  labelTranslationKey?: string | undefined;
66
- } | undefined;
67
- meta?: {
68
- schemaVersion: "1.0";
38
+ };
39
+ meta: {
40
+ schemaVersion: string;
69
41
  title?: string | undefined;
70
42
  usageDescription?: string | undefined;
71
- } | undefined;
43
+ };
72
44
  }, {
73
- type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "filteredSearch" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
74
- attributes?: {
45
+ type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "multiselectBox" | "numberRange" | "radioButtons" | "selectBox" | "table" | "text" | "textArea" | "url";
46
+ attributes: {
75
47
  label?: string | undefined;
76
48
  help?: string | undefined;
77
49
  labelTranslationKey?: string | undefined;
78
- } | undefined;
50
+ };
79
51
  meta?: {
80
- schemaVersion: "1.0";
52
+ schemaVersion?: string | undefined;
81
53
  title?: string | undefined;
82
54
  usageDescription?: string | undefined;
83
55
  } | undefined;
84
56
  }>;
85
- export type QuestionType = z.infer<typeof QuestionSchema>;
86
- export {};
57
+ export type QuestionType = z.infer<typeof QuestionFormatsEnum>;
58
+ export interface QuestionFormatsUsageInterface {
59
+ title: string;
60
+ usageDescription: string;
61
+ }
62
+ export declare const QuestionFormatsUsage: Record<QuestionType, QuestionFormatsUsageInterface>;
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QuestionSchema = exports.defaultAttributes = exports.defaultMeta = exports.QuestionTypesEnum = exports.CURRENT_SCHEMA_VERSION = void 0;
3
+ exports.QuestionFormatsUsage = exports.QuestionSchema = exports.QuestionFormatsEnum = exports.CURRENT_SCHEMA_VERSION = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.CURRENT_SCHEMA_VERSION = '1.0'; // The current schema version
6
- // The type of question
7
- exports.QuestionTypesEnum = zod_1.z.enum([
6
+ // The available question formats
7
+ exports.QuestionFormatsEnum = zod_1.z.enum([
8
8
  'affiliationSearch',
9
9
  'boolean',
10
10
  'checkBoxes',
@@ -12,7 +12,7 @@ exports.QuestionTypesEnum = zod_1.z.enum([
12
12
  'date',
13
13
  'dateRange',
14
14
  'email',
15
- 'filteredSearch',
15
+ // 'filteredSearch',
16
16
  'multiselectBox',
17
17
  'number',
18
18
  'numberRange',
@@ -23,27 +23,88 @@ exports.QuestionTypesEnum = zod_1.z.enum([
23
23
  'textArea',
24
24
  'url'
25
25
  ]);
26
- exports.defaultMeta = {
27
- schemaVersion: exports.CURRENT_SCHEMA_VERSION,
28
- };
29
- exports.defaultAttributes = {
30
- label: undefined,
31
- help: undefined,
32
- labelTranslationKey: undefined,
33
- };
34
26
  const DefaultMetaSchema = zod_1.z.object({
35
- schemaVersion: zod_1.z.literal(exports.CURRENT_SCHEMA_VERSION), // The schema version (default is CURRENT_SCHEMA_VERSION)
27
+ schemaVersion: zod_1.z.string().default(exports.CURRENT_SCHEMA_VERSION), // The schema version
36
28
  title: zod_1.z.string().optional(), // The title of the question type
37
29
  usageDescription: zod_1.z.string().optional(), // A description of when to use the question type
38
30
  });
39
31
  const DefaultAttributesSchema = zod_1.z.object({
40
32
  label: zod_1.z.string().optional(), // UI label for the field
41
33
  help: zod_1.z.string().optional(), // Help/tooltip text for the field
42
- labelTranslationKey: zod_1.z.string().optional() // The translation key for the label (DMP Tool only)
34
+ labelTranslationKey: zod_1.z.string().optional() // The local translation key for the label
43
35
  });
44
36
  // Base abstract type for all questions
45
37
  exports.QuestionSchema = zod_1.z.object({
46
- type: exports.QuestionTypesEnum, // The type of question
47
- attributes: DefaultAttributesSchema.optional(), // Field attributes
48
- meta: DefaultMetaSchema.optional(), // Meta information for the field
38
+ type: exports.QuestionFormatsEnum, // The type of question
39
+ attributes: DefaultAttributesSchema, // Field attributes
40
+ meta: DefaultMetaSchema.default({}), // Meta information for the field
49
41
  });
42
+ exports.QuestionFormatsUsage = {
43
+ affiliationSearch: {
44
+ title: 'Affiliation Search',
45
+ usageDescription: 'For questions that require the user to select from a controlled list of institutions.',
46
+ },
47
+ boolean: {
48
+ title: 'Yes/No Field',
49
+ usageDescription: 'For questions that require a simple Yes/No response.',
50
+ },
51
+ checkBoxes: {
52
+ title: 'Check Boxes',
53
+ usageDescription: 'For multiple choice questions where users can select multiple options.',
54
+ },
55
+ currency: {
56
+ title: 'Currency Field',
57
+ usageDescription: 'For questions that require a monetary amount (e.g. Cost or Budget).',
58
+ },
59
+ date: {
60
+ title: 'Date Field',
61
+ usageDescription: 'For questions that require a date.',
62
+ },
63
+ dateRange: {
64
+ title: 'Date Range',
65
+ usageDescription: 'For questions that require a date range (e.g. From/To, Start/End)',
66
+ },
67
+ email: {
68
+ title: 'Email Field',
69
+ usageDescription: 'For questions that require require email address(es).',
70
+ },
71
+ // filteredSearch: {
72
+ // title: 'Not yet implemented',
73
+ // },
74
+ multiselectBox: {
75
+ title: 'Multi-select Box',
76
+ usageDescription: 'For questions where multiple answers are valid. Allows users to select several options from a predefined list, providing flexibility in responses.',
77
+ },
78
+ number: {
79
+ title: 'Number Field',
80
+ usageDescription: 'For questions that require a single numeric value.',
81
+ },
82
+ numberRange: {
83
+ title: 'Number Range',
84
+ usageDescription: 'For questions that require a numerical range (e.g. From/To, Min/Max).',
85
+ },
86
+ radioButtons: {
87
+ title: 'Radio Buttons',
88
+ usageDescription: 'For multiple choice questions where users select just one option.',
89
+ },
90
+ selectBox: {
91
+ title: 'Select Box',
92
+ usageDescription: 'For questions where users select one option from a list.',
93
+ },
94
+ table: {
95
+ title: 'Table',
96
+ usageDescription: 'For questions that require a tabular format.',
97
+ },
98
+ text: {
99
+ title: 'Text Field',
100
+ usageDescription: 'For questions that require short, simple answers.',
101
+ },
102
+ textArea: {
103
+ title: 'Text Area',
104
+ usageDescription: 'For questions that require longer answers, you can select formatting options too.',
105
+ },
106
+ url: {
107
+ title: 'URL Field',
108
+ usageDescription: 'For questions that require a website, DOI or other URL.',
109
+ }
110
+ };