@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.
- package/README.md +119 -47
- package/dist/answers/__tests__/answers.spec.js +20 -28
- package/dist/answers/__tests__/usage.spec.d.ts +1 -0
- package/dist/answers/__tests__/usage.spec.js +175 -0
- package/dist/answers/answer.d.ts +12 -15
- package/dist/answers/answer.js +3 -4
- package/dist/answers/dateAnswers.d.ts +30 -30
- package/dist/answers/dateAnswers.js +6 -5
- package/dist/answers/graphQLAnswers.d.ts +25 -25
- package/dist/answers/graphQLAnswers.js +4 -4
- package/dist/answers/index.d.ts +860 -1088
- package/dist/answers/index.js +2 -2
- package/dist/answers/numberAnswers.d.ts +41 -41
- package/dist/answers/numberAnswers.js +8 -8
- package/dist/answers/optionBasedAnswers.d.ts +55 -55
- package/dist/answers/optionBasedAnswers.js +10 -10
- package/dist/answers/tableAnswers.d.ts +811 -1772
- package/dist/answers/tableAnswers.js +12 -8
- package/dist/answers/textAnswers.d.ts +44 -44
- package/dist/answers/textAnswers.js +8 -8
- package/dist/questions/__tests__/graphQLQuestions.spec.js +1 -1
- package/dist/questions/__tests__/usage.spec.d.ts +8 -0
- package/dist/questions/__tests__/usage.spec.js +312 -0
- package/dist/questions/dateQuestions.d.ts +81 -82
- package/dist/questions/dateQuestions.js +12 -16
- package/dist/questions/graphQLQuestions.d.ts +142 -142
- package/dist/questions/graphQLQuestions.js +35 -30
- package/dist/questions/index.d.ts +1494 -1674
- package/dist/questions/index.js +2 -2
- package/dist/questions/numberQuestions.d.ts +97 -98
- package/dist/questions/numberQuestions.js +7 -19
- package/dist/questions/optionBasedQuestions.d.ts +163 -166
- package/dist/questions/optionBasedQuestions.js +20 -36
- package/dist/questions/question.d.ts +24 -48
- package/dist/questions/question.js +78 -17
- package/dist/questions/tableQuestions.d.ts +2219 -2231
- package/dist/questions/tableQuestions.js +6 -11
- package/dist/questions/textQuestions.d.ts +104 -104
- package/dist/questions/textQuestions.js +6 -23
- package/dist/schemas/affiliationSearchAnswer.schema.json +9 -12
- package/dist/schemas/affiliationSearchQuestion.schema.json +30 -36
- package/dist/schemas/anyAnswer.schema.json +228 -237
- package/dist/schemas/anyQuestion.schema.json +292 -493
- package/dist/schemas/anyTableColumnAnswer.schema.json +93 -106
- package/dist/schemas/anyTableColumnQuestion.schema.json +164 -325
- package/dist/schemas/booleanAnswer.schema.json +8 -11
- package/dist/schemas/booleanQuestion.schema.json +7 -10
- package/dist/schemas/checkboxesAnswer.schema.json +13 -14
- package/dist/schemas/checkboxesQuestion.schema.json +12 -13
- package/dist/schemas/currencyAnswer.schema.json +8 -11
- package/dist/schemas/currencyQuestion.schema.json +7 -10
- package/dist/schemas/dateAnswer.schema.json +8 -11
- package/dist/schemas/dateQuestion.schema.json +7 -10
- package/dist/schemas/dateRangeAnswer.schema.json +16 -21
- package/dist/schemas/dateRangeQuestion.schema.json +38 -20
- package/dist/schemas/emailAnswer.schema.json +8 -11
- package/dist/schemas/emailQuestion.schema.json +7 -10
- package/dist/schemas/multiselectBoxAnswer.schema.json +13 -14
- package/dist/schemas/multiselectBoxQuestion.schema.json +14 -14
- package/dist/schemas/numberAnswer.schema.json +8 -11
- package/dist/schemas/numberQuestion.schema.json +7 -10
- package/dist/schemas/numberRangeAnswer.schema.json +17 -22
- package/dist/schemas/numberRangeQuestion.schema.json +18 -19
- package/dist/schemas/radioButtonsAnswer.schema.json +8 -11
- package/dist/schemas/radioButtonsQuestion.schema.json +12 -13
- package/dist/schemas/selectBoxAnswer.schema.json +8 -11
- package/dist/schemas/selectBoxQuestion.schema.json +18 -15
- package/dist/schemas/tableAnswer.schema.json +337 -343
- package/dist/schemas/tableQuestion.schema.json +178 -352
- package/dist/schemas/textAnswer.schema.json +8 -11
- package/dist/schemas/textAreaAnswer.schema.json +8 -11
- package/dist/schemas/textAreaQuestion.schema.json +7 -10
- package/dist/schemas/textQuestion.schema.json +7 -10
- package/dist/schemas/urlAnswer.schema.json +8 -11
- package/dist/schemas/urlQuestion.schema.json +7 -10
- 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
|
|
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", "
|
|
34
|
-
attributes: z.
|
|
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.
|
|
48
|
-
schemaVersion: z.
|
|
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:
|
|
24
|
+
schemaVersion: string;
|
|
53
25
|
title?: string | undefined;
|
|
54
26
|
usageDescription?: string | undefined;
|
|
55
27
|
}, {
|
|
56
|
-
schemaVersion
|
|
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" | "
|
|
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
|
-
}
|
|
67
|
-
meta
|
|
68
|
-
schemaVersion:
|
|
38
|
+
};
|
|
39
|
+
meta: {
|
|
40
|
+
schemaVersion: string;
|
|
69
41
|
title?: string | undefined;
|
|
70
42
|
usageDescription?: string | undefined;
|
|
71
|
-
}
|
|
43
|
+
};
|
|
72
44
|
}, {
|
|
73
|
-
type: "number" | "boolean" | "affiliationSearch" | "checkBoxes" | "currency" | "date" | "dateRange" | "email" | "
|
|
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
|
-
}
|
|
50
|
+
};
|
|
79
51
|
meta?: {
|
|
80
|
-
schemaVersion
|
|
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
|
|
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.
|
|
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
|
|
7
|
-
exports.
|
|
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.
|
|
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
|
|
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.
|
|
47
|
-
attributes: DefaultAttributesSchema
|
|
48
|
-
meta: DefaultMetaSchema.
|
|
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
|
+
};
|