@encatch/schema 0.0.1 → 0.1.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 +6 -0
- package/dist/cjs/index.js +910 -28
- package/dist/cjs/index.js.map +7 -1
- package/dist/esm/index.js +891 -12
- package/dist/esm/index.js.map +7 -1
- package/package.json +1 -1
- package/dist/cjs/schemas/fields/answer-schema.js +0 -103
- package/dist/cjs/schemas/fields/answer-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/auto-trigger-schema.js +0 -49
- package/dist/cjs/schemas/fields/auto-trigger-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/field-schema.js +0 -678
- package/dist/cjs/schemas/fields/field-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/form-properties-schema.js +0 -136
- package/dist/cjs/schemas/fields/form-properties-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/form-schema.js +0 -123
- package/dist/cjs/schemas/fields/form-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/other-screen-schema.js +0 -169
- package/dist/cjs/schemas/fields/other-screen-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/theme-schema.js +0 -85
- package/dist/cjs/schemas/fields/theme-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/translations-example.js +0 -187
- package/dist/cjs/schemas/fields/translations-example.js.map +0 -1
- package/dist/cjs/schemas/fields/translations-schema.js +0 -198
- package/dist/cjs/schemas/fields/translations-schema.js.map +0 -1
- package/dist/esm/schemas/fields/answer-schema.js +0 -100
- package/dist/esm/schemas/fields/answer-schema.js.map +0 -1
- package/dist/esm/schemas/fields/auto-trigger-schema.js +0 -46
- package/dist/esm/schemas/fields/auto-trigger-schema.js.map +0 -1
- package/dist/esm/schemas/fields/field-schema.js +0 -675
- package/dist/esm/schemas/fields/field-schema.js.map +0 -1
- package/dist/esm/schemas/fields/form-properties-schema.js +0 -133
- package/dist/esm/schemas/fields/form-properties-schema.js.map +0 -1
- package/dist/esm/schemas/fields/form-schema.js +0 -120
- package/dist/esm/schemas/fields/form-schema.js.map +0 -1
- package/dist/esm/schemas/fields/other-screen-schema.js +0 -166
- package/dist/esm/schemas/fields/other-screen-schema.js.map +0 -1
- package/dist/esm/schemas/fields/theme-schema.js +0 -82
- package/dist/esm/schemas/fields/theme-schema.js.map +0 -1
- package/dist/esm/schemas/fields/translations-example.js +0 -181
- package/dist/esm/schemas/fields/translations-example.js.map +0 -1
- package/dist/esm/schemas/fields/translations-schema.js +0 -193
- package/dist/esm/schemas/fields/translations-schema.js.map +0 -1
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.translationProvider = exports.availableLanguages = exports.exampleTranslations = void 0;
|
|
4
|
-
exports.getLanguageDisplayName = getLanguageDisplayName;
|
|
5
|
-
exports.getSupportedLanguages = getSupportedLanguages;
|
|
6
|
-
exports.demonstrateUsage = demonstrateUsage;
|
|
7
|
-
const translations_schema_1 = require("./translations-schema");
|
|
8
|
-
// Example translation data following the structure:
|
|
9
|
-
// {
|
|
10
|
-
// "languageCode": {
|
|
11
|
-
// "question_id": {
|
|
12
|
-
// translated schema
|
|
13
|
-
// }
|
|
14
|
-
// }
|
|
15
|
-
// }
|
|
16
|
-
exports.exampleTranslations = {
|
|
17
|
-
defaultLanguage: "en",
|
|
18
|
-
version: "1.0.0",
|
|
19
|
-
languages: [
|
|
20
|
-
{
|
|
21
|
-
languageCode: "en",
|
|
22
|
-
questions: {
|
|
23
|
-
"rating-q1": {
|
|
24
|
-
type: "rating",
|
|
25
|
-
translations: {
|
|
26
|
-
title: { text: "How satisfied are you?" },
|
|
27
|
-
description: { text: "Please rate your experience on a scale of 1-5" },
|
|
28
|
-
minLabel: { text: "Not satisfied" },
|
|
29
|
-
maxLabel: { text: "Very satisfied" }
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"choice-q2": {
|
|
33
|
-
type: "single_choice",
|
|
34
|
-
translations: {
|
|
35
|
-
title: { text: "What is your favorite color?" },
|
|
36
|
-
description: { text: "Choose one option from the list below" },
|
|
37
|
-
options: {
|
|
38
|
-
"opt-red": { label: { text: "Red" } },
|
|
39
|
-
"opt-blue": { label: { text: "Blue" } },
|
|
40
|
-
"opt-green": { label: { text: "Green" } }
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
"nps-q3": {
|
|
45
|
-
type: "nps",
|
|
46
|
-
translations: {
|
|
47
|
-
title: { text: "How likely are you to recommend us?" },
|
|
48
|
-
description: { text: "Rate from 0 to 10" },
|
|
49
|
-
minLabel: { text: "Not at all likely" },
|
|
50
|
-
maxLabel: { text: "Extremely likely" },
|
|
51
|
-
scaleLabels: {
|
|
52
|
-
0: { text: "Not at all likely" },
|
|
53
|
-
5: { text: "Neutral" },
|
|
54
|
-
10: { text: "Extremely likely" }
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
"text-q4": {
|
|
59
|
-
type: "short_answer",
|
|
60
|
-
translations: {
|
|
61
|
-
title: { text: "What improvements would you suggest?" },
|
|
62
|
-
placeholder: { text: "Enter your suggestions here..." }
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
"nested-q5": {
|
|
66
|
-
type: "nested_selection",
|
|
67
|
-
translations: {
|
|
68
|
-
title: { text: "Select your location" },
|
|
69
|
-
placeholder: { text: "Choose a country first..." },
|
|
70
|
-
nestedOptions: {
|
|
71
|
-
"country-us": { label: { text: "United States" } },
|
|
72
|
-
"country-in": { label: { text: "India" } },
|
|
73
|
-
"state-ca": { label: { text: "California" } },
|
|
74
|
-
"state-ny": { label: { text: "New York" } }
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
languageCode: "hi", // Hindi
|
|
82
|
-
questions: {
|
|
83
|
-
"rating-q1": {
|
|
84
|
-
type: "rating",
|
|
85
|
-
translations: {
|
|
86
|
-
title: { text: "आप कितने संतुष्ट हैं?" },
|
|
87
|
-
description: { text: "कृपया 1-5 स्केल पर अपनी संतुष्टि दर करें" },
|
|
88
|
-
minLabel: { text: "असंतुष्ट" },
|
|
89
|
-
maxLabel: { text: "बहुत संतुष्ट" }
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
"choice-q2": {
|
|
93
|
-
type: "single_choice",
|
|
94
|
-
translations: {
|
|
95
|
-
title: { text: "आपका पसंदीदा रंग क्या है?" },
|
|
96
|
-
options: {
|
|
97
|
-
"opt-red": { label: { text: "लाल" } },
|
|
98
|
-
"opt-blue": { label: { text: "नीला" } },
|
|
99
|
-
"opt-green": { label: { text: "हरा" } }
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
languageCode: "es", // Spanish
|
|
107
|
-
questions: {
|
|
108
|
-
"rating-q1": {
|
|
109
|
-
type: "rating",
|
|
110
|
-
translations: {
|
|
111
|
-
title: { text: "¿Qué tan satisfecho estás?" },
|
|
112
|
-
minLabel: { text: "No satisfecho" },
|
|
113
|
-
maxLabel: { text: "Muy satisfecho" }
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
"choice-q2": {
|
|
117
|
-
type: "single_choice",
|
|
118
|
-
translations: {
|
|
119
|
-
title: { text: "¿Cuál es tu color favorito?" },
|
|
120
|
-
options: {
|
|
121
|
-
"opt-red": { label: { text: "Rojo" } },
|
|
122
|
-
"opt-blue": { label: { text: "Azul" } },
|
|
123
|
-
"opt-green": { label: { text: "Verde" } }
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
};
|
|
131
|
-
// Define available languages using your existing schema
|
|
132
|
-
exports.availableLanguages = [
|
|
133
|
-
{
|
|
134
|
-
value: "en",
|
|
135
|
-
label: "English",
|
|
136
|
-
isFixed: true
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
value: "hi",
|
|
140
|
-
label: "हिन्दी",
|
|
141
|
-
isFixed: false
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
value: "es",
|
|
145
|
-
label: "Español",
|
|
146
|
-
isFixed: false
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
value: "fr",
|
|
150
|
-
label: "Français",
|
|
151
|
-
isFixed: false
|
|
152
|
-
}
|
|
153
|
-
];
|
|
154
|
-
// Create translation provider
|
|
155
|
-
exports.translationProvider = (0, translations_schema_1.createTranslationProvider)(exports.exampleTranslations);
|
|
156
|
-
// Helper function to get language display name
|
|
157
|
-
function getLanguageDisplayName(languageCode) {
|
|
158
|
-
const language = exports.availableLanguages.find(lang => lang.value === languageCode);
|
|
159
|
-
return language?.label || languageCode;
|
|
160
|
-
}
|
|
161
|
-
// Helper function to get supported languages
|
|
162
|
-
function getSupportedLanguages() {
|
|
163
|
-
return exports.availableLanguages.filter(lang => exports.exampleTranslations.languages.some(t => t.languageCode === lang.value));
|
|
164
|
-
}
|
|
165
|
-
// Usage examples
|
|
166
|
-
function demonstrateUsage() {
|
|
167
|
-
console.log("=== Translation System with Language Integration ===\n");
|
|
168
|
-
// Get translations for a specific question
|
|
169
|
-
const ratingTranslations = exports.translationProvider.getQuestionTranslations("rating-q1", "hi");
|
|
170
|
-
console.log("Hindi rating title:", ratingTranslations?.translations.title.text);
|
|
171
|
-
// Get specific translation text
|
|
172
|
-
const titleText = exports.translationProvider.getTranslationText("choice-q2", "es", ["title"]);
|
|
173
|
-
console.log("Spanish choice title:", titleText);
|
|
174
|
-
// Get option translation
|
|
175
|
-
const optionText = exports.translationProvider.getTranslationText("choice-q2", "hi", ["options", "opt-red", "label"]);
|
|
176
|
-
console.log("Hindi red option:", optionText);
|
|
177
|
-
// Language integration examples
|
|
178
|
-
console.log("\n=== Language Integration ===");
|
|
179
|
-
console.log("Available languages:", exports.translationProvider.getAvailableLanguages());
|
|
180
|
-
console.log("Supported languages with display names:");
|
|
181
|
-
getSupportedLanguages().forEach(lang => {
|
|
182
|
-
console.log(` ${lang.value}: ${lang.label}`);
|
|
183
|
-
});
|
|
184
|
-
console.log("\nDefault language:", exports.translationProvider.getDefaultLanguage());
|
|
185
|
-
console.log("Is French supported?", exports.translationProvider.isLanguageSupported("fr"));
|
|
186
|
-
}
|
|
187
|
-
//# sourceMappingURL=translations-example.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translations-example.js","sourceRoot":"","sources":["../../../../src/schemas/fields/translations-example.ts"],"names":[],"mappings":";;;AA2JA,wDAGC;AAGD,sDAIC;AAGD,4CAyBC;AAjMD,+DAAgF;AAGhF,oDAAoD;AACpD,IAAI;AACJ,sBAAsB;AACtB,uBAAuB;AACvB,0BAA0B;AAC1B,QAAQ;AACR,MAAM;AACN,IAAI;AACS,QAAA,mBAAmB,GAAiB;IAC/C,eAAe,EAAE,IAAI;IACrB,OAAO,EAAE,OAAO;IAChB,SAAS,EAAE;QACT;YACE,YAAY,EAAE,IAAI;YAClB,SAAS,EAAE;gBACT,WAAW,EAAE;oBACX,IAAI,EAAE,QAAQ;oBACd,YAAY,EAAE;wBACZ,KAAK,EAAE,EAAE,IAAI,EAAE,wBAAwB,EAAE;wBACzC,WAAW,EAAE,EAAE,IAAI,EAAE,+CAA+C,EAAE;wBACtE,QAAQ,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;wBACnC,QAAQ,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE;qBACrC;iBACF;gBACD,WAAW,EAAE;oBACX,IAAI,EAAE,eAAe;oBACrB,YAAY,EAAE;wBACZ,KAAK,EAAE,EAAE,IAAI,EAAE,8BAA8B,EAAE;wBAC/C,WAAW,EAAE,EAAE,IAAI,EAAE,uCAAuC,EAAE;wBAC9D,OAAO,EAAE;4BACP,SAAS,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,KA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
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TranslationProvider = exports.translationsSchema = exports.languageTranslationsSchema = exports.questionTranslationsSchema = exports.annotationTranslationsSchema = exports.nestedSelectionTranslationsSchema = exports.longAnswerTranslationsSchema = exports.shortAnswerTranslationsSchema = exports.npsTranslationsSchema = exports.multipleChoiceTranslationsSchema = exports.singleChoiceTranslationsSchema = exports.ratingTranslationsSchema = exports.translationEntrySchema = void 0;
|
|
4
|
-
exports.createTranslationProvider = createTranslationProvider;
|
|
5
|
-
const zod_1 = require("zod");
|
|
6
|
-
// Base translation entry
|
|
7
|
-
exports.translationEntrySchema = zod_1.z
|
|
8
|
-
.object({
|
|
9
|
-
text: zod_1.z.string().min(1).describe("Translated text content"),
|
|
10
|
-
context: zod_1.z.string().optional().describe("Optional context for translators"),
|
|
11
|
-
})
|
|
12
|
-
.describe("Translation entry with translated text");
|
|
13
|
-
// Rating question translations
|
|
14
|
-
exports.ratingTranslationsSchema = zod_1.z
|
|
15
|
-
.object({
|
|
16
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
17
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
18
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
19
|
-
minLabel: exports.translationEntrySchema.optional().describe("Minimum rating label translation"),
|
|
20
|
-
maxLabel: exports.translationEntrySchema.optional().describe("Maximum rating label translation"),
|
|
21
|
-
})
|
|
22
|
-
.describe("Translation schema for rating questions");
|
|
23
|
-
// Single choice question translations
|
|
24
|
-
exports.singleChoiceTranslationsSchema = zod_1.z
|
|
25
|
-
.object({
|
|
26
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
27
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
28
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
29
|
-
placeholder: exports.translationEntrySchema.optional().describe("Input placeholder translation"),
|
|
30
|
-
options: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
|
|
31
|
-
label: exports.translationEntrySchema.describe("Option label translation"),
|
|
32
|
-
hint: exports.translationEntrySchema.optional().describe("Option hint translation"),
|
|
33
|
-
})).describe("Option translations keyed by option ID"),
|
|
34
|
-
})
|
|
35
|
-
.describe("Translation schema for single choice questions");
|
|
36
|
-
// Multiple choice question translations
|
|
37
|
-
exports.multipleChoiceTranslationsSchema = zod_1.z
|
|
38
|
-
.object({
|
|
39
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
40
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
41
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
42
|
-
placeholder: exports.translationEntrySchema.optional().describe("Input placeholder translation"),
|
|
43
|
-
options: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
|
|
44
|
-
label: exports.translationEntrySchema.describe("Option label translation"),
|
|
45
|
-
hint: exports.translationEntrySchema.optional().describe("Option hint translation"),
|
|
46
|
-
})).describe("Option translations keyed by option ID"),
|
|
47
|
-
})
|
|
48
|
-
.describe("Translation schema for multiple choice questions");
|
|
49
|
-
// NPS question translations
|
|
50
|
-
exports.npsTranslationsSchema = zod_1.z
|
|
51
|
-
.object({
|
|
52
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
53
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
54
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
55
|
-
minLabel: exports.translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
|
|
56
|
-
maxLabel: exports.translationEntrySchema.optional().describe("Maximum NPS label (10) translation"),
|
|
57
|
-
scaleLabels: zod_1.z.record(zod_1.z.number().int().min(0).max(10), exports.translationEntrySchema)
|
|
58
|
-
.optional()
|
|
59
|
-
.describe("Scale label translations for specific NPS values (0-10)"),
|
|
60
|
-
})
|
|
61
|
-
.describe("Translation schema for NPS questions");
|
|
62
|
-
// Short answer question translations
|
|
63
|
-
exports.shortAnswerTranslationsSchema = zod_1.z
|
|
64
|
-
.object({
|
|
65
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
66
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
67
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
68
|
-
placeholder: exports.translationEntrySchema.optional().describe("Input placeholder translation"),
|
|
69
|
-
})
|
|
70
|
-
.describe("Translation schema for short answer questions");
|
|
71
|
-
// Long answer question translations
|
|
72
|
-
exports.longAnswerTranslationsSchema = zod_1.z
|
|
73
|
-
.object({
|
|
74
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
75
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
76
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
77
|
-
placeholder: exports.translationEntrySchema.optional().describe("Textarea placeholder translation"),
|
|
78
|
-
})
|
|
79
|
-
.describe("Translation schema for long answer questions");
|
|
80
|
-
// Nested selection question translations
|
|
81
|
-
exports.nestedSelectionTranslationsSchema = zod_1.z
|
|
82
|
-
.object({
|
|
83
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
84
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
85
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
86
|
-
placeholder: exports.translationEntrySchema.optional().describe("Dropdown placeholder translation"),
|
|
87
|
-
nestedOptions: zod_1.z.record(zod_1.z.string(), zod_1.z.object({
|
|
88
|
-
label: exports.translationEntrySchema.describe("Nested option label translation"),
|
|
89
|
-
hint: exports.translationEntrySchema.optional().describe("Nested option hint translation"),
|
|
90
|
-
})).describe("Nested option translations keyed by option ID"),
|
|
91
|
-
})
|
|
92
|
-
.describe("Translation schema for nested selection questions");
|
|
93
|
-
// Annotation question translations
|
|
94
|
-
exports.annotationTranslationsSchema = zod_1.z
|
|
95
|
-
.object({
|
|
96
|
-
title: exports.translationEntrySchema.describe("Question title translation"),
|
|
97
|
-
description: exports.translationEntrySchema.optional().describe("Question description translation"),
|
|
98
|
-
errorMessage: exports.translationEntrySchema.optional().describe("Error message translation"),
|
|
99
|
-
annotationText: exports.translationEntrySchema.optional().describe("Annotation display text translation"),
|
|
100
|
-
noAnnotationText: exports.translationEntrySchema.optional().describe("No annotation display text translation"),
|
|
101
|
-
})
|
|
102
|
-
.describe("Translation schema for annotation questions");
|
|
103
|
-
// Discriminated union of all translation types
|
|
104
|
-
exports.questionTranslationsSchema = zod_1.z
|
|
105
|
-
.discriminatedUnion("type", [
|
|
106
|
-
zod_1.z.object({ type: zod_1.z.literal("rating"), translations: exports.ratingTranslationsSchema }),
|
|
107
|
-
zod_1.z.object({ type: zod_1.z.literal("single_choice"), translations: exports.singleChoiceTranslationsSchema }),
|
|
108
|
-
zod_1.z.object({ type: zod_1.z.literal("multiple_choice_multiple"), translations: exports.multipleChoiceTranslationsSchema }),
|
|
109
|
-
zod_1.z.object({ type: zod_1.z.literal("nps"), translations: exports.npsTranslationsSchema }),
|
|
110
|
-
zod_1.z.object({ type: zod_1.z.literal("short_answer"), translations: exports.shortAnswerTranslationsSchema }),
|
|
111
|
-
zod_1.z.object({ type: zod_1.z.literal("long_text"), translations: exports.longAnswerTranslationsSchema }),
|
|
112
|
-
zod_1.z.object({ type: zod_1.z.literal("nested_selection"), translations: exports.nestedSelectionTranslationsSchema }),
|
|
113
|
-
zod_1.z.object({ type: zod_1.z.literal("annotation"), translations: exports.annotationTranslationsSchema }),
|
|
114
|
-
])
|
|
115
|
-
.describe("Discriminated union of all question type translation schemas");
|
|
116
|
-
// Language-specific translations keyed by question ID
|
|
117
|
-
exports.languageTranslationsSchema = zod_1.z
|
|
118
|
-
.object({
|
|
119
|
-
languageCode: zod_1.z.string().describe("Language code matching LanguagesSchema values"),
|
|
120
|
-
questions: zod_1.z.record(zod_1.z.string(), exports.questionTranslationsSchema)
|
|
121
|
-
.describe("Question translations keyed by question ID"),
|
|
122
|
-
})
|
|
123
|
-
.describe("Language-specific translation set keyed by question IDs");
|
|
124
|
-
// Complete translation schema
|
|
125
|
-
exports.translationsSchema = zod_1.z
|
|
126
|
-
.object({
|
|
127
|
-
defaultLanguage: zod_1.z.string().describe("Default/fallback language code"),
|
|
128
|
-
languages: zod_1.z.array(exports.languageTranslationsSchema).min(1)
|
|
129
|
-
.describe("Available language translations"),
|
|
130
|
-
version: zod_1.z.string().optional().describe("Translation version for cache management"),
|
|
131
|
-
})
|
|
132
|
-
.describe("Complete translation schema keyed by question IDs");
|
|
133
|
-
// Translation helper class
|
|
134
|
-
class TranslationProvider {
|
|
135
|
-
constructor(translations) {
|
|
136
|
-
this.translations = translations;
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Get translations for a specific question in a specific language
|
|
140
|
-
*/
|
|
141
|
-
getQuestionTranslations(questionId, languageCode) {
|
|
142
|
-
const languageData = this.translations.languages.find(lang => lang.languageCode === languageCode);
|
|
143
|
-
if (!languageData) {
|
|
144
|
-
// Fallback to default language
|
|
145
|
-
const defaultLang = this.translations.languages.find(lang => lang.languageCode === this.translations.defaultLanguage);
|
|
146
|
-
if (!defaultLang)
|
|
147
|
-
return null;
|
|
148
|
-
return defaultLang.questions[questionId] || null;
|
|
149
|
-
}
|
|
150
|
-
return languageData.questions[questionId] || null;
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Get a specific translation text
|
|
154
|
-
*/
|
|
155
|
-
getTranslationText(questionId, languageCode, path) {
|
|
156
|
-
const questionTranslations = this.getQuestionTranslations(questionId, languageCode);
|
|
157
|
-
if (!questionTranslations)
|
|
158
|
-
return null;
|
|
159
|
-
let current = questionTranslations.translations;
|
|
160
|
-
for (const key of path) {
|
|
161
|
-
if (current && typeof current === 'object' && key in current) {
|
|
162
|
-
current = current[key];
|
|
163
|
-
}
|
|
164
|
-
else {
|
|
165
|
-
return null;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
// Handle nested structures like options
|
|
169
|
-
if (current && typeof current === 'object' && 'text' in current) {
|
|
170
|
-
return current.text;
|
|
171
|
-
}
|
|
172
|
-
return null;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Get all available languages
|
|
176
|
-
*/
|
|
177
|
-
getAvailableLanguages() {
|
|
178
|
-
return this.translations.languages.map(lang => lang.languageCode);
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* Check if a language is supported
|
|
182
|
-
*/
|
|
183
|
-
isLanguageSupported(languageCode) {
|
|
184
|
-
return this.translations.languages.some(lang => lang.languageCode === languageCode);
|
|
185
|
-
}
|
|
186
|
-
/**
|
|
187
|
-
* Get the default language
|
|
188
|
-
*/
|
|
189
|
-
getDefaultLanguage() {
|
|
190
|
-
return this.translations.defaultLanguage;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
exports.TranslationProvider = TranslationProvider;
|
|
194
|
-
// Factory function to create translation provider
|
|
195
|
-
function createTranslationProvider(translations) {
|
|
196
|
-
return new TranslationProvider(translations);
|
|
197
|
-
}
|
|
198
|
-
//# sourceMappingURL=translations-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translations-schema.js","sourceRoot":"","sources":["../../../../src/schemas/fields/translations-schema.ts"],"names":[],"mappings":";;;AAgPA,8DAEC;AAlPD,6BAAwB;AAGxB,yBAAyB;AACZ,QAAA,sBAAsB,GAAG,OAAC;KACpC,MAAM,CAAC;IACN,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,yBAAyB,CAAC;IAC3D,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kCAAkC,CAAC;CAC5E,CAAC;KACD,QAAQ,CAAC,wCAAwC,CAAC,CAAC;AAEtD,+BAA+B;AAClB,Q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O,IAAI,CAAC;QAEvC,IAAI,OAAO,GAAQ,oBAAoB,CAAC,YAAY,CAAC;QAErD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;YACvB,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,GAAG,IAAI,OAAO,EAAE,CAAC;gBAC7D,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QAED,wCAAwC;QACxC,IAAI,OAAO,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,EAAE,CAAC;YAChE,OAAO,OAAO,CAAC,IAAI,CAAC;QACtB,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,qBAAqB;QACnB,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACpE,CAAC;IAED;;OAEG;IACH,mBAAmB,CAAC,YAAoB;QACtC,OAAO,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,YAAY,KAAK,YAAY,CAAC,CAAC;IACtF,CAAC;IAED;;OAEG;IACH,kBAAkB;QAChB,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,CAAC;IAC3C,CAAC;CACF;AAhFD,kDAgFC;AAED,kDAAkD;AAClD,SAAgB,yBAAyB,CAAC,YAA0B;IAClE,OAAO,IAAI,mBAAmB,CAAC,YAAY,CAAC,CAAC;AAC/C,CAAC"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// Simple answer schema
|
|
3
|
-
export const SimpleAnswerSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
type: z
|
|
6
|
-
.literal("simple")
|
|
7
|
-
.describe("Indicates this is a simple answer with a single value"),
|
|
8
|
-
value: z
|
|
9
|
-
.union([z.string(), z.number(), z.boolean()])
|
|
10
|
-
.describe("The answer value - can be text, number, or boolean"),
|
|
11
|
-
})
|
|
12
|
-
.describe("A simple answer containing a single value like text, number, or boolean");
|
|
13
|
-
// Choice answer schema
|
|
14
|
-
export const ChoiceAnswerSchema = z
|
|
15
|
-
.object({
|
|
16
|
-
type: z
|
|
17
|
-
.literal("choice")
|
|
18
|
-
.describe("Indicates this is a single-choice answer"),
|
|
19
|
-
selectedOptionId: z
|
|
20
|
-
.string()
|
|
21
|
-
.describe("The ID of the selected option from the available choices"),
|
|
22
|
-
})
|
|
23
|
-
.describe("A single-choice answer where the user selects one option from a list");
|
|
24
|
-
// Multiple choice answer schema
|
|
25
|
-
export const MultipleChoiceAnswerSchema = z
|
|
26
|
-
.object({
|
|
27
|
-
type: z
|
|
28
|
-
.literal("multiple_choice")
|
|
29
|
-
.describe("Indicates this is a multiple-choice answer"),
|
|
30
|
-
selectedOptionIds: z
|
|
31
|
-
.array(z.string())
|
|
32
|
-
.describe("Array of IDs for all selected options from the available choices"),
|
|
33
|
-
})
|
|
34
|
-
.describe("A multiple-choice answer where the user can select multiple options from a list");
|
|
35
|
-
// Scale answer schema
|
|
36
|
-
export const ScaleAnswerSchema = z
|
|
37
|
-
.object({
|
|
38
|
-
type: z
|
|
39
|
-
.literal("scale")
|
|
40
|
-
.describe("Indicates this is a scale/rating answer"),
|
|
41
|
-
value: z
|
|
42
|
-
.number()
|
|
43
|
-
.describe("The numerical value representing the position on the scale (e.g., 1-5, 1-10)"),
|
|
44
|
-
})
|
|
45
|
-
.describe("A scale answer where the user selects a numerical value on a scale");
|
|
46
|
-
// Continuous sum answer schema
|
|
47
|
-
export const ContinuousSumAnswerSchema = z
|
|
48
|
-
.object({
|
|
49
|
-
type: z
|
|
50
|
-
.literal("continuous_sum")
|
|
51
|
-
.describe("Indicates this is a continuous sum answer"),
|
|
52
|
-
values: z
|
|
53
|
-
.array(z.object({
|
|
54
|
-
optionId: z.string().describe("The ID of the option being rated"),
|
|
55
|
-
value: z
|
|
56
|
-
.number()
|
|
57
|
-
.describe("The numerical value assigned to this option"),
|
|
58
|
-
}))
|
|
59
|
-
.describe("Array of option-value pairs where the sum of all values represents a total allocation"),
|
|
60
|
-
})
|
|
61
|
-
.describe("A continuous sum answer where users distribute values across multiple options that add up to a total");
|
|
62
|
-
// Ranking answer schema
|
|
63
|
-
export const RankingAnswerSchema = z
|
|
64
|
-
.object({
|
|
65
|
-
type: z.literal("ranking").describe("Indicates this is a ranking answer"),
|
|
66
|
-
ranks: z
|
|
67
|
-
.array(z.object({
|
|
68
|
-
optionId: z.string().describe("The ID of the option being ranked"),
|
|
69
|
-
rank: z
|
|
70
|
-
.number()
|
|
71
|
-
.describe("The rank position of this option (lower numbers indicate higher preference)"),
|
|
72
|
-
}))
|
|
73
|
-
.describe("Array of option-rank pairs showing the user's preference ordering"),
|
|
74
|
-
})
|
|
75
|
-
.describe("A ranking answer where users order options by preference or priority");
|
|
76
|
-
// Text answer schema
|
|
77
|
-
export const TextAnswerSchema = z
|
|
78
|
-
.object({
|
|
79
|
-
type: z.literal("text").describe("Indicates this is a text-based answer"),
|
|
80
|
-
values: z
|
|
81
|
-
.array(z.object({
|
|
82
|
-
fieldId: z.string().describe("The ID of the text field"),
|
|
83
|
-
text: z.string().describe("The text content entered by the user"),
|
|
84
|
-
}))
|
|
85
|
-
.describe("Array of field-text pairs for multiple text input fields"),
|
|
86
|
-
})
|
|
87
|
-
.describe("A text answer containing responses to one or more text input fields");
|
|
88
|
-
// Union schema for all answer types
|
|
89
|
-
export const AnswerSchema = z
|
|
90
|
-
.discriminatedUnion("type", [
|
|
91
|
-
SimpleAnswerSchema,
|
|
92
|
-
ChoiceAnswerSchema,
|
|
93
|
-
MultipleChoiceAnswerSchema,
|
|
94
|
-
ScaleAnswerSchema,
|
|
95
|
-
ContinuousSumAnswerSchema,
|
|
96
|
-
RankingAnswerSchema,
|
|
97
|
-
TextAnswerSchema,
|
|
98
|
-
])
|
|
99
|
-
.describe("A union of all possible answer types discriminated by the 'type' field");
|
|
100
|
-
//# sourceMappingURL=answer-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"answer-schema.js","sourceRoot":"","sources":["../../../../src/schemas/fields/answer-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,CAAC,uDAAuD,CAAC;IACpE,KAAK,EAAE,CAAC;SACL,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;SAC5C,QAAQ,CAAC,oDAAoD,CAAC;CAClE,CAAC;KACD,QAAQ,CACP,yEAAyE,CAC1E,CAAC;AAEJ,uBAAuB;AACvB,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC;KAChC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,QAAQ,CAAC,0CAA0C,CAAC;IACvD,gBAAgB,EAAE,CAAC;SAChB,MAAM,EAAE;SACR,QAAQ,CAAC,0DAA0D,CAAC;CACxE,CAAC;KACD,QAAQ,CACP,sEAAsE,CACvE,CAAC;AAEJ,gCAAgC;AAChC,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC;KACxC,MAAM,CAAC;IACN,IAAI,EAAE,CAAC;SACJ,OAAO,CAAC,iBAAiB,CAAC;SAC1B,QAAQ,CAAC,4CAA4C,CAAC;IACzD,iBAAiB,EAAE,CAAC;SACjB,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;SACjB,QAAQ,CACP,kEAAkE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Q,CACP,mEAAmE,CACpE;CACJ,CAAC;KACD,QAAQ,CACP,sEAAsE,CACvE,CAAC;AAEJ,qBAAqB;AACrB,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC;KAC9B,MAAM,CAAC;IACN,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IACzE,MAAM,EAAE,CAAC;SACN,KAAK,CACJ,CAAC,CAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;QACxD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;KAClE,CAAC,CACH;SACA,QAAQ,CAAC,0DAA0D,CAAC;CACxE,CAAC;KACD,QAAQ,CACP,qEAAqE,CACtE,CAAC;AAEJ,oCAAoC;AACpC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC;KAC1B,kBAAkB,CAAC,MAAM,EAAE;IAC1B,kBAAkB;IAClB,kBAAkB;IAClB,0BAA0B;IAC1B,iBAAiB;IACjB,yBAAyB;IACzB,mBAAmB;IACnB,gBAAgB;CACjB,CAAC;KACD,QAAQ,CACP,wEAAwE,CACzE,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
// Audience segment schema for targeting specific user groups
|
|
3
|
-
export const audienceSegmentSchema = z
|
|
4
|
-
.object({
|
|
5
|
-
id: z
|
|
6
|
-
.string()
|
|
7
|
-
.describe("Unique identifier for the audience segment"),
|
|
8
|
-
name: z
|
|
9
|
-
.string()
|
|
10
|
-
.min(1)
|
|
11
|
-
.max(200)
|
|
12
|
-
.describe("Display name for the audience segment"),
|
|
13
|
-
isImportant: z
|
|
14
|
-
.boolean()
|
|
15
|
-
.describe("Whether this segment is marked as important for targeting"),
|
|
16
|
-
when: z
|
|
17
|
-
.string()
|
|
18
|
-
.describe("Timing condition for when to trigger the audience segment"),
|
|
19
|
-
who: z
|
|
20
|
-
.string()
|
|
21
|
-
.describe("User criteria or conditions defining who belongs to this segment"),
|
|
22
|
-
})
|
|
23
|
-
.describe("Schema defining an audience segment for targeting");
|
|
24
|
-
// Audience trigger properties schema
|
|
25
|
-
export const audienceTriggerPropertiesSchema = z
|
|
26
|
-
.object({
|
|
27
|
-
isAuto: z
|
|
28
|
-
.boolean()
|
|
29
|
-
.describe("Whether automatic triggering is enabled for this audience"),
|
|
30
|
-
isManual: z
|
|
31
|
-
.boolean()
|
|
32
|
-
.describe("Whether manual triggering is enabled for this audience"),
|
|
33
|
-
segments: z
|
|
34
|
-
.array(audienceSegmentSchema)
|
|
35
|
-
.min(0)
|
|
36
|
-
.describe("Array of audience segments for targeting conditions"),
|
|
37
|
-
})
|
|
38
|
-
.refine((data) => {
|
|
39
|
-
// Ensure at least one of isAuto or isManual is true
|
|
40
|
-
return data.isAuto || data.isManual;
|
|
41
|
-
}, {
|
|
42
|
-
message: "At least one of isAuto or isManual must be true",
|
|
43
|
-
path: ["isAuto"],
|
|
44
|
-
})
|
|
45
|
-
.describe("Schema defining audience trigger properties for form targeting");
|
|
46
|
-
//# sourceMappingURL=auto-trigger-schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auto-trigger-schema.js","sourceRoot":"","sources":["../../../../src/schemas/fields/auto-trigger-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6DAA6D;AAC7D,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC;KACnC,MAAM,CAAC;IACN,EAAE,EAAE,CAAC;SACF,MAAM,EAAE;SACR,QAAQ,CAAC,4CAA4C,CAAC;IACzD,IAAI,EAAE,CAAC;SACJ,MAAM,EAAE;SACR,GAAG,CAAC,CAAC,CAAC;SACN,GAAG,CAAC,GAAG,CAAC;SACR,QAAQ,CAAC,uCAAuC,CAAC;IACpD,WA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