@encatch/schema 1.0.1-beta.2 → 1.1.0-beta.4
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/dist/esm/index.js +500 -584
- package/dist/esm/index.js.map +3 -3
- package/dist/types/index.d.ts +2 -2
- package/dist/types/schemas/api/fetch-feedback-schema.d.ts +84 -112
- package/dist/types/schemas/fields/app-props-schema.d.ts +42 -34
- package/dist/types/schemas/fields/field-schema.d.ts +84 -74
- package/dist/types/schemas/fields/form-properties-schema.d.ts +42 -58
- package/dist/types/schemas/fields/form-schema.d.ts +0 -58
- package/dist/types/schemas/fields/theme-schema.d.ts +0 -4
- package/dist/types/schemas/fields/translations-schema.d.ts +12 -0
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,283 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/schemas/fields/field-schema.ts
|
|
5
|
+
import { z as z2 } from "zod";
|
|
6
|
+
|
|
7
|
+
// src/schemas/fields/translations-schema.ts
|
|
5
8
|
import { z } from "zod";
|
|
6
|
-
var
|
|
9
|
+
var translationEntrySchema = z.string().min(1).describe("Translated text content");
|
|
10
|
+
var baseQuestionTranslationFieldsSchema = z.object({
|
|
11
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
12
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
13
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation")
|
|
14
|
+
});
|
|
15
|
+
var BASE_QUESTION_TRANSLATION_KEYS = [
|
|
16
|
+
"type",
|
|
17
|
+
"title",
|
|
18
|
+
"description",
|
|
19
|
+
"errorMessage"
|
|
20
|
+
];
|
|
21
|
+
var ratingQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
22
|
+
type: z.literal("rating").describe("Question type identifier"),
|
|
23
|
+
minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
|
|
24
|
+
maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
|
|
25
|
+
}).describe("Translation schema for rating questions");
|
|
26
|
+
var singleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
27
|
+
type: z.literal("single_choice").describe("Question type identifier"),
|
|
28
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
29
|
+
}).catchall(translationEntrySchema).refine(
|
|
30
|
+
(data) => {
|
|
31
|
+
const additionalKeys = Object.keys(data).filter(
|
|
32
|
+
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
33
|
+
);
|
|
34
|
+
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
35
|
+
},
|
|
36
|
+
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
37
|
+
).describe("Translation schema for single choice questions");
|
|
38
|
+
var multipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
39
|
+
type: z.literal("multiple_choice_multiple").describe("Question type identifier"),
|
|
40
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
41
|
+
}).catchall(translationEntrySchema).refine(
|
|
42
|
+
(data) => {
|
|
43
|
+
const additionalKeys = Object.keys(data).filter(
|
|
44
|
+
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
45
|
+
);
|
|
46
|
+
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
47
|
+
},
|
|
48
|
+
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
49
|
+
).describe("Translation schema for multiple choice questions");
|
|
50
|
+
var npsQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
51
|
+
type: z.literal("nps").describe("Question type identifier"),
|
|
52
|
+
minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
|
|
53
|
+
maxLabel: translationEntrySchema.optional().describe("Maximum NPS label (10) translation")
|
|
54
|
+
}).catchall(translationEntrySchema).refine(
|
|
55
|
+
(data) => {
|
|
56
|
+
const additionalKeys = Object.keys(data).filter(
|
|
57
|
+
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(key)
|
|
58
|
+
);
|
|
59
|
+
return additionalKeys.every((key) => /^scaleLabel\.\d+$/.test(key));
|
|
60
|
+
},
|
|
61
|
+
{ message: "Additional keys must follow the pattern 'scaleLabel.{number}'" }
|
|
62
|
+
).describe("Translation schema for NPS questions");
|
|
63
|
+
var shortAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
64
|
+
type: z.literal("short_answer").describe("Question type identifier"),
|
|
65
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
66
|
+
}).describe("Translation schema for short answer questions");
|
|
67
|
+
var longAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
68
|
+
type: z.literal("long_text").describe("Question type identifier"),
|
|
69
|
+
placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
|
|
70
|
+
}).describe("Translation schema for long answer questions");
|
|
71
|
+
var nestedSelectionQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
72
|
+
type: z.literal("nested_selection").describe("Question type identifier"),
|
|
73
|
+
placeholder: translationEntrySchema.optional().describe("Dropdown placeholder translation")
|
|
74
|
+
}).catchall(translationEntrySchema).refine(
|
|
75
|
+
(data) => {
|
|
76
|
+
const additionalKeys = Object.keys(data).filter(
|
|
77
|
+
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
78
|
+
);
|
|
79
|
+
return additionalKeys.every((key) => /^nestedOption\..+\.(label|hint)$/.test(key));
|
|
80
|
+
},
|
|
81
|
+
{ message: "Additional keys must follow the pattern 'nestedOption.{id}.{label|hint}'" }
|
|
82
|
+
).describe("Translation schema for nested selection questions");
|
|
83
|
+
var annotationQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
84
|
+
type: z.literal("annotation").describe("Question type identifier"),
|
|
85
|
+
annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
|
|
86
|
+
noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
|
|
87
|
+
}).describe("Translation schema for annotation questions");
|
|
88
|
+
var welcomeQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
89
|
+
type: z.literal("welcome").describe("Question type identifier"),
|
|
90
|
+
buttonLabel: translationEntrySchema.optional().describe("Translated proceed/start button label")
|
|
91
|
+
}).describe("Translation schema for welcome screen questions");
|
|
92
|
+
var thankYouQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
93
|
+
type: z.literal("thank_you").describe("Question type identifier"),
|
|
94
|
+
buttonLabel: translationEntrySchema.optional().describe(
|
|
95
|
+
"Translated dismiss/done button label"
|
|
96
|
+
)
|
|
97
|
+
}).describe("Translation schema for thank you screen questions");
|
|
98
|
+
var messagePanelQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
99
|
+
type: z.literal("message_panel").describe("Question type identifier"),
|
|
100
|
+
buttonLabel: translationEntrySchema.optional().describe(
|
|
101
|
+
"Translated continue/button label"
|
|
102
|
+
)
|
|
103
|
+
}).describe("Translation schema for message panel questions");
|
|
104
|
+
var yesNoQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
105
|
+
type: z.literal("yes_no").describe("Question type identifier"),
|
|
106
|
+
yesLabel: translationEntrySchema.optional().describe("Translated Yes label"),
|
|
107
|
+
noLabel: translationEntrySchema.optional().describe("Translated No label")
|
|
108
|
+
}).describe("Translation schema for yes/no questions");
|
|
109
|
+
var ratingMatrixQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
110
|
+
type: z.literal("rating_matrix").describe("Question type identifier"),
|
|
111
|
+
minLabel: translationEntrySchema.optional().describe(
|
|
112
|
+
"Translated scale minimum end label (for likert and numerical kinds)"
|
|
113
|
+
),
|
|
114
|
+
maxLabel: translationEntrySchema.optional().describe(
|
|
115
|
+
"Translated scale maximum end label (for likert and numerical kinds)"
|
|
116
|
+
)
|
|
117
|
+
}).catchall(translationEntrySchema).refine(
|
|
118
|
+
(data) => {
|
|
119
|
+
const additionalKeys = Object.keys(data).filter(
|
|
120
|
+
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(
|
|
121
|
+
key
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
return additionalKeys.every(
|
|
125
|
+
(key) => /^statement\..+\.label$/.test(key) || /^scalePoint\..+\.label$/.test(key)
|
|
126
|
+
);
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
message: "Additional keys must follow 'statement.{id}.label' or 'scalePoint.{id}.label'"
|
|
130
|
+
}
|
|
131
|
+
).describe("Translation schema for rating matrix questions");
|
|
132
|
+
var matrixSingleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
133
|
+
type: z.literal("matrix_single_choice").describe("Question type identifier")
|
|
134
|
+
}).catchall(translationEntrySchema).refine(
|
|
135
|
+
(data) => {
|
|
136
|
+
const additionalKeys = Object.keys(data).filter(
|
|
137
|
+
(key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
|
|
138
|
+
);
|
|
139
|
+
return additionalKeys.every(
|
|
140
|
+
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
141
|
+
);
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
|
|
145
|
+
}
|
|
146
|
+
).describe("Translation schema for matrix single-choice questions");
|
|
147
|
+
var matrixMultipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
148
|
+
type: z.literal("matrix_multiple_choice").describe("Question type identifier")
|
|
149
|
+
}).catchall(translationEntrySchema).refine(
|
|
150
|
+
(data) => {
|
|
151
|
+
const additionalKeys = Object.keys(data).filter(
|
|
152
|
+
(key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
|
|
153
|
+
);
|
|
154
|
+
return additionalKeys.every(
|
|
155
|
+
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
156
|
+
);
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
|
|
160
|
+
}
|
|
161
|
+
).describe("Translation schema for matrix multiple-choice questions");
|
|
162
|
+
var questionTranslationSchema = z.union([
|
|
163
|
+
ratingQuestionTranslationSchema,
|
|
164
|
+
singleChoiceQuestionTranslationSchema,
|
|
165
|
+
multipleChoiceQuestionTranslationSchema,
|
|
166
|
+
npsQuestionTranslationSchema,
|
|
167
|
+
shortAnswerQuestionTranslationSchema,
|
|
168
|
+
longAnswerQuestionTranslationSchema,
|
|
169
|
+
nestedSelectionQuestionTranslationSchema,
|
|
170
|
+
annotationQuestionTranslationSchema,
|
|
171
|
+
welcomeQuestionTranslationSchema,
|
|
172
|
+
thankYouQuestionTranslationSchema,
|
|
173
|
+
messagePanelQuestionTranslationSchema,
|
|
174
|
+
yesNoQuestionTranslationSchema,
|
|
175
|
+
ratingMatrixQuestionTranslationSchema,
|
|
176
|
+
matrixSingleChoiceQuestionTranslationSchema,
|
|
177
|
+
matrixMultipleChoiceQuestionTranslationSchema
|
|
178
|
+
]).describe("Union of all question type translation schemas");
|
|
179
|
+
var languageCodeSchema = z.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
|
|
180
|
+
var sectionTranslationSchema = z.object({
|
|
181
|
+
title: translationEntrySchema.max(200).describe("Section title translation"),
|
|
182
|
+
description: translationEntrySchema.max(1e3).optional().describe("Section description translation"),
|
|
183
|
+
nextButtonLabel: translationEntrySchema.max(50).optional().describe("Next button label translation for this section")
|
|
184
|
+
}).describe("Translation payload for a section in a single language");
|
|
185
|
+
var sectionTranslationsByLanguageSchema = z.record(languageCodeSchema, sectionTranslationSchema).describe("Section translations keyed by language code");
|
|
186
|
+
var questionTranslationsByLanguageSchema = z.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
|
|
187
|
+
var questionCentricTranslationsSchema = z.record(z.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
|
|
188
|
+
var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
|
|
189
|
+
var _TranslationProvider = class _TranslationProvider {
|
|
190
|
+
constructor(translations, defaultLanguage = "en") {
|
|
191
|
+
this.translations = translations;
|
|
192
|
+
this.defaultLanguage = defaultLanguage;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get translations for a specific question in a specific language
|
|
196
|
+
*/
|
|
197
|
+
getQuestionTranslations(questionId, languageCode) {
|
|
198
|
+
const questionTranslations = this.translations[questionId];
|
|
199
|
+
if (!questionTranslations) return null;
|
|
200
|
+
let translation = questionTranslations[languageCode];
|
|
201
|
+
if (!translation) {
|
|
202
|
+
translation = questionTranslations[this.defaultLanguage];
|
|
203
|
+
}
|
|
204
|
+
return translation || null;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get a specific translation text by field path
|
|
208
|
+
*/
|
|
209
|
+
getTranslationText(questionId, languageCode, fieldPath) {
|
|
210
|
+
const questionTranslation = this.getQuestionTranslations(questionId, languageCode);
|
|
211
|
+
if (!questionTranslation) return null;
|
|
212
|
+
if (fieldPath in questionTranslation) {
|
|
213
|
+
const value = questionTranslation[fieldPath];
|
|
214
|
+
return typeof value === "string" ? value : null;
|
|
215
|
+
}
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Get all available languages for a specific question
|
|
220
|
+
*/
|
|
221
|
+
getQuestionLanguages(questionId) {
|
|
222
|
+
const questionTranslations = this.translations[questionId];
|
|
223
|
+
if (!questionTranslations) return [];
|
|
224
|
+
return Object.keys(questionTranslations);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Get all available languages across all questions
|
|
228
|
+
*/
|
|
229
|
+
getAvailableLanguages() {
|
|
230
|
+
const allLanguages = /* @__PURE__ */ new Set();
|
|
231
|
+
Object.values(this.translations).forEach((questionTranslations) => {
|
|
232
|
+
Object.keys(questionTranslations).forEach((langCode) => {
|
|
233
|
+
allLanguages.add(langCode);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
return Array.from(allLanguages);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Check if a language is supported for a specific question
|
|
240
|
+
*/
|
|
241
|
+
isLanguageSupportedForQuestion(questionId, languageCode) {
|
|
242
|
+
const questionTranslations = this.translations[questionId];
|
|
243
|
+
if (!questionTranslations) return false;
|
|
244
|
+
return languageCode in questionTranslations;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Check if a language is supported across all questions
|
|
248
|
+
*/
|
|
249
|
+
isLanguageSupported(languageCode) {
|
|
250
|
+
return this.getAvailableLanguages().includes(languageCode);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get the default language
|
|
254
|
+
*/
|
|
255
|
+
getDefaultLanguage() {
|
|
256
|
+
return this.defaultLanguage;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get all questions that have translations
|
|
260
|
+
*/
|
|
261
|
+
getQuestionIds() {
|
|
262
|
+
return Object.keys(this.translations);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Get question type for a specific question
|
|
266
|
+
*/
|
|
267
|
+
getQuestionType(questionId, languageCode) {
|
|
268
|
+
const langCode = languageCode || this.defaultLanguage;
|
|
269
|
+
const translation = this.getQuestionTranslations(questionId, langCode);
|
|
270
|
+
return translation?.type || null;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
__name(_TranslationProvider, "TranslationProvider");
|
|
274
|
+
var TranslationProvider = _TranslationProvider;
|
|
275
|
+
function createTranslationProvider(translations, defaultLanguage = "en") {
|
|
276
|
+
return new TranslationProvider(translations, defaultLanguage);
|
|
277
|
+
}
|
|
278
|
+
__name(createTranslationProvider, "createTranslationProvider");
|
|
279
|
+
|
|
280
|
+
// src/schemas/fields/field-schema.ts
|
|
281
|
+
var questionTypeSchema = z2.enum([
|
|
7
282
|
"rating",
|
|
8
283
|
"single_choice",
|
|
9
284
|
"nps",
|
|
@@ -39,7 +314,7 @@ var QuestionTypes = {
|
|
|
39
314
|
MATRIX_MULTIPLE_CHOICE: "matrix_multiple_choice",
|
|
40
315
|
EXIT_FORM: "exit_form"
|
|
41
316
|
};
|
|
42
|
-
var validationRuleTypeSchema =
|
|
317
|
+
var validationRuleTypeSchema = z2.enum([
|
|
43
318
|
"required",
|
|
44
319
|
"min",
|
|
45
320
|
"max",
|
|
@@ -61,13 +336,13 @@ var ValidationRuleTypes = {
|
|
|
61
336
|
URL: "url",
|
|
62
337
|
CUSTOM: "custom"
|
|
63
338
|
};
|
|
64
|
-
var validationRuleSchema =
|
|
339
|
+
var validationRuleSchema = z2.object({
|
|
65
340
|
type: validationRuleTypeSchema.describe("Type of validation rule to apply"),
|
|
66
|
-
value:
|
|
67
|
-
message:
|
|
68
|
-
describe:
|
|
341
|
+
value: z2.union([z2.string(), z2.number(), z2.boolean()]).optional().describe("Value for the validation rule (string, number, or boolean)"),
|
|
342
|
+
message: z2.string().optional().describe("Custom error message when validation fails"),
|
|
343
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this validation rule")
|
|
69
344
|
}).describe("Schema defining validation rules for question responses");
|
|
70
|
-
var visibilityConditionOperatorSchema =
|
|
345
|
+
var visibilityConditionOperatorSchema = z2.enum([
|
|
71
346
|
"equals",
|
|
72
347
|
"not_equals",
|
|
73
348
|
"contains",
|
|
@@ -87,27 +362,37 @@ var VisibilityConditionOperators = {
|
|
|
87
362
|
IS_EMPTY: "is_empty",
|
|
88
363
|
IS_NOT_EMPTY: "is_not_empty"
|
|
89
364
|
};
|
|
90
|
-
var visibilityConditionSchema =
|
|
91
|
-
field:
|
|
365
|
+
var visibilityConditionSchema = z2.object({
|
|
366
|
+
field: z2.string().describe("ID of the field to check against"),
|
|
92
367
|
operator: visibilityConditionOperatorSchema.describe("Comparison operator for the condition"),
|
|
93
|
-
value:
|
|
94
|
-
describe:
|
|
368
|
+
value: z2.union([z2.string(), z2.number(), z2.boolean()]).optional().describe("Value to compare against (string, number, or boolean)"),
|
|
369
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this visibility condition")
|
|
95
370
|
}).describe(
|
|
96
371
|
"Schema defining conditions that control when questions are visible"
|
|
97
372
|
);
|
|
98
|
-
var sectionSchema =
|
|
99
|
-
id:
|
|
100
|
-
title:
|
|
101
|
-
|
|
373
|
+
var sectionSchema = z2.object({
|
|
374
|
+
id: z2.string().describe("Unique identifier for the section"),
|
|
375
|
+
title: z2.string().min(1).max(200).describe("Display title for the section"),
|
|
376
|
+
description: z2.string().max(1e3).optional().describe("Optional detailed description or help text for the section"),
|
|
377
|
+
showTitle: z2.boolean().default(true).describe("Whether to show the section title in the UI"),
|
|
378
|
+
showDescription: z2.boolean().default(true).describe("Whether to show the section description in the UI"),
|
|
379
|
+
nextButtonLabel: z2.string().min(1).max(50).optional().describe("Label for the next button when navigating from this section"),
|
|
380
|
+
translations: sectionTranslationsByLanguageSchema.optional().describe(
|
|
381
|
+
"Per-language section copy (title, optional description and nextButtonLabel), keyed by language code"
|
|
382
|
+
),
|
|
383
|
+
inAppSingleQuestion: z2.boolean().default(false).describe(
|
|
384
|
+
"When true, the native app shows one question at a time within this section"
|
|
385
|
+
),
|
|
386
|
+
questionIds: z2.array(z2.string()).min(1).describe("Array of question IDs that belong to this section")
|
|
102
387
|
}).describe("Schema defining sections that organize questions into logical groups");
|
|
103
|
-
var questionStatusSchema =
|
|
388
|
+
var questionStatusSchema = z2.enum(["D", "P", "A", "S"]);
|
|
104
389
|
var QuestionStatuses = {
|
|
105
390
|
DRAFT: "D",
|
|
106
391
|
PUBLISHED: "P",
|
|
107
392
|
ARCHIVED: "A",
|
|
108
393
|
SUSPENDED: "S"
|
|
109
394
|
};
|
|
110
|
-
var ratingDisplayStyleSchema =
|
|
395
|
+
var ratingDisplayStyleSchema = z2.enum([
|
|
111
396
|
"star",
|
|
112
397
|
"heart",
|
|
113
398
|
"thumbs-up",
|
|
@@ -123,7 +408,7 @@ var RatingDisplayStyles = {
|
|
|
123
408
|
EMOJI: "emoji",
|
|
124
409
|
EMOJI_EXP: "emoji_exp"
|
|
125
410
|
};
|
|
126
|
-
var ratingRepresentationSizeSchema =
|
|
411
|
+
var ratingRepresentationSizeSchema = z2.enum([
|
|
127
412
|
"small",
|
|
128
413
|
"medium",
|
|
129
414
|
"large"
|
|
@@ -133,7 +418,7 @@ var RatingRepresentationSizes = {
|
|
|
133
418
|
MEDIUM: "medium",
|
|
134
419
|
LARGE: "large"
|
|
135
420
|
};
|
|
136
|
-
var multipleChoiceDisplayStyleSchema =
|
|
421
|
+
var multipleChoiceDisplayStyleSchema = z2.enum([
|
|
137
422
|
"radio",
|
|
138
423
|
"list",
|
|
139
424
|
"chip",
|
|
@@ -145,7 +430,7 @@ var MultipleChoiceDisplayStyles = {
|
|
|
145
430
|
CHIP: "chip",
|
|
146
431
|
DROPDOWN: "dropdown"
|
|
147
432
|
};
|
|
148
|
-
var multipleChoiceMultipleDisplayStyleSchema =
|
|
433
|
+
var multipleChoiceMultipleDisplayStyleSchema = z2.enum([
|
|
149
434
|
"checkbox",
|
|
150
435
|
"list",
|
|
151
436
|
"chip"
|
|
@@ -155,12 +440,12 @@ var MultipleChoiceMultipleDisplayStyles = {
|
|
|
155
440
|
LIST: "list",
|
|
156
441
|
CHIP: "chip"
|
|
157
442
|
};
|
|
158
|
-
var yesNoDisplayStyleSchema =
|
|
443
|
+
var yesNoDisplayStyleSchema = z2.enum(["horizontal", "vertical"]);
|
|
159
444
|
var YesNoDisplayStyles = {
|
|
160
445
|
HORIZONTAL: "horizontal",
|
|
161
446
|
VERTICAL: "vertical"
|
|
162
447
|
};
|
|
163
|
-
var choiceOrderOptionSchema =
|
|
448
|
+
var choiceOrderOptionSchema = z2.enum([
|
|
164
449
|
"randomize",
|
|
165
450
|
"flip",
|
|
166
451
|
"rotate",
|
|
@@ -174,83 +459,83 @@ var ChoiceOrderOptions = {
|
|
|
174
459
|
ASCENDING: "ascending",
|
|
175
460
|
NONE: "none"
|
|
176
461
|
};
|
|
177
|
-
var questionSchema =
|
|
178
|
-
id:
|
|
462
|
+
var questionSchema = z2.object({
|
|
463
|
+
id: z2.string().describe("Unique identifier for the question"),
|
|
179
464
|
type: questionTypeSchema.describe(
|
|
180
465
|
"The type of question (rating, single_choice, etc.)"
|
|
181
466
|
),
|
|
182
|
-
title:
|
|
183
|
-
description:
|
|
184
|
-
describe:
|
|
467
|
+
title: z2.string().min(1).max(200).describe("The main title/question text displayed to users"),
|
|
468
|
+
description: z2.string().max(1e3).optional().describe("Optional detailed description or help text"),
|
|
469
|
+
describe: z2.string().max(2e3).optional().describe(
|
|
185
470
|
"LLM tool call description for better AI understanding and context"
|
|
186
471
|
),
|
|
187
|
-
required:
|
|
188
|
-
isHidden:
|
|
189
|
-
errorMessage:
|
|
190
|
-
validations:
|
|
191
|
-
visibility:
|
|
192
|
-
sectionId:
|
|
472
|
+
required: z2.boolean().default(false).describe("Whether this question must be answered"),
|
|
473
|
+
isHidden: z2.boolean().default(false).describe("When true, the question is hidden from the form UI"),
|
|
474
|
+
errorMessage: z2.string().max(500).optional().describe("Custom error message when validation fails"),
|
|
475
|
+
validations: z2.array(validationRuleSchema).optional().default([]).describe("Array of validation rules to apply"),
|
|
476
|
+
visibility: z2.array(visibilityConditionSchema).optional().default([]).describe("Conditions that control when this question is shown"),
|
|
477
|
+
sectionId: z2.string().optional().describe("ID of the section this question belongs to"),
|
|
193
478
|
status: questionStatusSchema.describe(
|
|
194
479
|
"Current status of the question (Draft, Published, etc.)"
|
|
195
480
|
),
|
|
196
|
-
textAlign:
|
|
481
|
+
textAlign: z2.enum(["left", "center"]).optional().default("left").describe("Text alignment for the question title and description")
|
|
197
482
|
}).describe("Base schema for all question types with common properties");
|
|
198
483
|
var ratingQuestionSchema = questionSchema.extend({
|
|
199
|
-
type:
|
|
200
|
-
showLabels:
|
|
201
|
-
minLabel:
|
|
202
|
-
maxLabel:
|
|
484
|
+
type: z2.literal("rating").describe("Must be exactly 'rating'"),
|
|
485
|
+
showLabels: z2.boolean().optional().describe("Whether to show min/max labels"),
|
|
486
|
+
minLabel: z2.string().max(100).optional().describe("Label for the minimum rating value"),
|
|
487
|
+
maxLabel: z2.string().max(100).optional().describe("Label for the maximum rating value"),
|
|
203
488
|
displayStyle: ratingDisplayStyleSchema.optional().describe("Visual style for rating display"),
|
|
204
|
-
numberOfRatings:
|
|
489
|
+
numberOfRatings: z2.number().int().min(1).max(10).describe("Number of rating options (1-10)"),
|
|
205
490
|
representationSize: ratingRepresentationSizeSchema.optional().describe("Size of rating visual elements"),
|
|
206
|
-
color:
|
|
491
|
+
color: z2.string().regex(/^#[0-9A-F]{6}$/i, "Must be a valid hex color").optional().describe("Hex color for rating elements")
|
|
207
492
|
}).describe("Schema for rating questions with customizable display options");
|
|
208
493
|
var annotationQuestionSchema = questionSchema.extend({
|
|
209
|
-
type:
|
|
210
|
-
annotationText:
|
|
211
|
-
noAnnotationText:
|
|
494
|
+
type: z2.literal("annotation").describe("Must be exactly 'annotation'"),
|
|
495
|
+
annotationText: z2.string().max(1e3).optional().describe("Text to display when annotation is provided"),
|
|
496
|
+
noAnnotationText: z2.string().max(500).optional().describe("Text to display when no annotation is provided")
|
|
212
497
|
}).describe(
|
|
213
498
|
"Schema for annotation questions that provide additional context or instructions"
|
|
214
499
|
);
|
|
215
500
|
var welcomeQuestionSchema = questionSchema.extend({
|
|
216
|
-
type:
|
|
217
|
-
title:
|
|
218
|
-
description:
|
|
219
|
-
buttonLabel:
|
|
220
|
-
imageUrl:
|
|
501
|
+
type: z2.literal("welcome").describe("Must be exactly 'welcome'"),
|
|
502
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the welcome screen"),
|
|
503
|
+
description: z2.string().max(1e3).optional().describe("Optional sub-text body shown below the heading"),
|
|
504
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the proceed/start button (e.g. 'Get Started', 'Begin')"),
|
|
505
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the welcome screen")
|
|
221
506
|
}).describe("Schema for a welcome screen displayed at the start or inline within a form");
|
|
222
507
|
var thankYouQuestionSchema = questionSchema.extend({
|
|
223
|
-
type:
|
|
224
|
-
title:
|
|
225
|
-
description:
|
|
508
|
+
type: z2.literal("thank_you").describe("Must be exactly 'thank_you'"),
|
|
509
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the thank you screen"),
|
|
510
|
+
description: z2.string().max(1e3).optional().describe(
|
|
226
511
|
"Optional thank you body text; rendered as Markdown where the form supports it"
|
|
227
512
|
),
|
|
228
|
-
buttonLabel:
|
|
229
|
-
imageUrl:
|
|
513
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the dismiss/done button (e.g. 'Done', 'Close')"),
|
|
514
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the thank you screen")
|
|
230
515
|
}).describe(
|
|
231
516
|
"Schema for a thank you screen shown at the end or inline within a form"
|
|
232
517
|
);
|
|
233
518
|
var messagePanelQuestionSchema = questionSchema.extend({
|
|
234
|
-
type:
|
|
235
|
-
title:
|
|
236
|
-
description:
|
|
237
|
-
buttonLabel:
|
|
238
|
-
imageUrl:
|
|
519
|
+
type: z2.literal("message_panel").describe("Must be exactly 'message_panel'"),
|
|
520
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the message panel"),
|
|
521
|
+
description: z2.string().max(1e3).optional().describe("Optional body text shown below the heading"),
|
|
522
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the continue button (e.g. 'Continue', 'Next')"),
|
|
523
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the message panel")
|
|
239
524
|
}).describe(
|
|
240
525
|
"Schema for an inline message panel (informational); distinct from welcome for UI semantics and analytics"
|
|
241
526
|
);
|
|
242
527
|
var exitFormQuestionSchema = questionSchema.extend({
|
|
243
|
-
type:
|
|
528
|
+
type: z2.literal("exit_form").describe("Must be exactly 'exit_form'")
|
|
244
529
|
}).describe(
|
|
245
530
|
"Schema for an exit marker that silently ends the survey; carries no UI and captures no answer \u2014 intended for branch logic paths that should terminate without showing a thank-you screen"
|
|
246
531
|
);
|
|
247
532
|
var yesNoQuestionSchema = questionSchema.extend({
|
|
248
|
-
type:
|
|
249
|
-
yesLabel:
|
|
250
|
-
noLabel:
|
|
533
|
+
type: z2.literal("yes_no").describe("Must be exactly 'yes_no'"),
|
|
534
|
+
yesLabel: z2.string().min(1).max(50).optional().describe("Label for the Yes option (defaults to 'Yes' in the UI if omitted)"),
|
|
535
|
+
noLabel: z2.string().min(1).max(50).optional().describe("Label for the No option (defaults to 'No' in the UI if omitted)"),
|
|
251
536
|
displayStyle: yesNoDisplayStyleSchema.optional().describe("Layout for the Yes/No controls (horizontal row or vertical stack)")
|
|
252
537
|
}).describe("Schema for yes/no questions with optional custom labels and layout");
|
|
253
|
-
var ratingMatrixDisplayStyleSchema =
|
|
538
|
+
var ratingMatrixDisplayStyleSchema = z2.enum([
|
|
254
539
|
"radio",
|
|
255
540
|
"star",
|
|
256
541
|
"emoji",
|
|
@@ -262,72 +547,72 @@ var RatingMatrixDisplayStyles = {
|
|
|
262
547
|
EMOJI: "emoji",
|
|
263
548
|
BUTTON: "button"
|
|
264
549
|
};
|
|
265
|
-
var ratingMatrixStatementSchema =
|
|
266
|
-
id:
|
|
267
|
-
value:
|
|
268
|
-
label:
|
|
269
|
-
describe:
|
|
550
|
+
var ratingMatrixStatementSchema = z2.object({
|
|
551
|
+
id: z2.string().describe("Unique identifier for this statement (system time milliseconds)"),
|
|
552
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this statement"),
|
|
553
|
+
label: z2.string().min(1).max(200).describe("Display text shown to users for this statement"),
|
|
554
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this statement")
|
|
270
555
|
}).describe("Schema for an individual statement (row) in a rating matrix");
|
|
271
|
-
var ratingMatrixScalePointSchema =
|
|
272
|
-
id:
|
|
273
|
-
value:
|
|
274
|
-
label:
|
|
275
|
-
describe:
|
|
556
|
+
var ratingMatrixScalePointSchema = z2.object({
|
|
557
|
+
id: z2.string().describe("Unique identifier for this scale point"),
|
|
558
|
+
value: z2.union([z2.number(), z2.string()]).describe("Stored response value for this scale point (number or string)"),
|
|
559
|
+
label: z2.string().min(1).max(200).describe("Display label shown for this scale point"),
|
|
560
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this scale point")
|
|
276
561
|
}).describe("Schema for a single point on a custom rating scale");
|
|
277
|
-
var ratingMatrixScaleSchema =
|
|
562
|
+
var ratingMatrixScaleSchema = z2.discriminatedUnion("kind", [
|
|
278
563
|
// Likert: symmetric ordinal scale -2…+2, explicit scale points with labels
|
|
279
|
-
|
|
280
|
-
kind:
|
|
281
|
-
scalePoints:
|
|
564
|
+
z2.object({
|
|
565
|
+
kind: z2.literal("likert").describe("Symmetric ordinal scale (-2 to +2)"),
|
|
566
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column")
|
|
282
567
|
}),
|
|
283
568
|
// Numerical: 1…N points where N is 2, 3, 4, or 5, explicit scale points with labels
|
|
284
|
-
|
|
285
|
-
kind:
|
|
286
|
-
scalePoints:
|
|
287
|
-
pointCount:
|
|
569
|
+
z2.object({
|
|
570
|
+
kind: z2.literal("numerical").describe("Numerical scale from 1 to N"),
|
|
571
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column"),
|
|
572
|
+
pointCount: z2.union([z2.literal(2), z2.literal(3), z2.literal(4), z2.literal(5)]).describe("Number of scale points (2, 3, 4, or 5)")
|
|
288
573
|
}),
|
|
289
574
|
// Custom: consumer defines each point's value and label
|
|
290
|
-
|
|
291
|
-
kind:
|
|
292
|
-
scalePoints:
|
|
575
|
+
z2.object({
|
|
576
|
+
kind: z2.literal("custom").describe("Custom scale with user-defined points and values"),
|
|
577
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column")
|
|
293
578
|
})
|
|
294
579
|
]).describe("Scale configuration for rating matrix questions");
|
|
295
580
|
var ratingMatrixQuestionSchema = questionSchema.extend({
|
|
296
|
-
type:
|
|
297
|
-
statements:
|
|
581
|
+
type: z2.literal("rating_matrix").describe("Must be exactly 'rating_matrix'"),
|
|
582
|
+
statements: z2.array(ratingMatrixStatementSchema).min(1).max(10).describe("Statements (rows) users will rate on the shared scale (1-10)"),
|
|
298
583
|
scale: ratingMatrixScaleSchema.describe("Scale configuration shared across all statement rows"),
|
|
299
584
|
displayStyle: ratingMatrixDisplayStyleSchema.optional().describe(
|
|
300
585
|
"Visual representation of scale points per row (radio buttons, stars, emoji, or buttons)"
|
|
301
586
|
),
|
|
302
|
-
randomizeStatements:
|
|
587
|
+
randomizeStatements: z2.boolean().optional().default(false).describe("Whether to randomize the order of statements")
|
|
303
588
|
}).describe("Schema for rating matrix questions with multiple statements on a shared scale");
|
|
304
|
-
var matrixRowSchema =
|
|
305
|
-
id:
|
|
306
|
-
value:
|
|
307
|
-
label:
|
|
308
|
-
describe:
|
|
589
|
+
var matrixRowSchema = z2.object({
|
|
590
|
+
id: z2.string().describe("Unique identifier for this row (system time milliseconds)"),
|
|
591
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this row"),
|
|
592
|
+
label: z2.string().min(1).max(200).describe("Display text shown to users for this row"),
|
|
593
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this row")
|
|
309
594
|
}).describe("Schema for an individual row in a matrix choice question");
|
|
310
|
-
var matrixColumnSchema =
|
|
311
|
-
id:
|
|
312
|
-
value:
|
|
313
|
-
label:
|
|
314
|
-
describe:
|
|
595
|
+
var matrixColumnSchema = z2.object({
|
|
596
|
+
id: z2.string().describe("Unique identifier for this column (system time milliseconds)"),
|
|
597
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this column"),
|
|
598
|
+
label: z2.string().min(1).max(200).describe("Display label shown for this column"),
|
|
599
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this column")
|
|
315
600
|
}).describe("Schema for an individual column in a matrix choice question");
|
|
316
601
|
var matrixSingleChoiceQuestionSchema = questionSchema.extend({
|
|
317
|
-
type:
|
|
318
|
-
rows:
|
|
319
|
-
columns:
|
|
320
|
-
randomizeRows:
|
|
321
|
-
randomizeColumns:
|
|
602
|
+
type: z2.literal("matrix_single_choice").describe("Must be exactly 'matrix_single_choice'"),
|
|
603
|
+
rows: z2.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
|
|
604
|
+
columns: z2.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
|
|
605
|
+
randomizeRows: z2.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
|
|
606
|
+
randomizeColumns: z2.boolean().optional().default(false).describe("Whether to randomize the order of columns")
|
|
322
607
|
}).describe("Schema for matrix single-choice questions where one column is selected per row");
|
|
323
608
|
var matrixMultipleChoiceQuestionSchema = questionSchema.extend({
|
|
324
|
-
type:
|
|
325
|
-
rows:
|
|
326
|
-
columns:
|
|
327
|
-
minSelectionsPerRow:
|
|
328
|
-
maxSelectionsPerRow:
|
|
329
|
-
randomizeRows:
|
|
330
|
-
randomizeColumns:
|
|
609
|
+
type: z2.literal("matrix_multiple_choice").describe("Must be exactly 'matrix_multiple_choice'"),
|
|
610
|
+
rows: z2.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
|
|
611
|
+
columns: z2.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
|
|
612
|
+
minSelectionsPerRow: z2.number().int().min(0).optional().describe("Minimum number of columns a user must select per row"),
|
|
613
|
+
maxSelectionsPerRow: z2.number().int().min(1).optional().describe("Maximum number of columns a user can select per row"),
|
|
614
|
+
randomizeRows: z2.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
|
|
615
|
+
randomizeColumns: z2.boolean().optional().default(false).describe("Whether to randomize the order of columns")
|
|
331
616
|
}).refine(
|
|
332
617
|
(data) => {
|
|
333
618
|
if (data.minSelectionsPerRow !== void 0 && data.maxSelectionsPerRow !== void 0) {
|
|
@@ -342,53 +627,53 @@ var matrixMultipleChoiceQuestionSchema = questionSchema.extend({
|
|
|
342
627
|
).describe(
|
|
343
628
|
"Schema for matrix multiple-choice questions where one or more columns can be selected per row"
|
|
344
629
|
);
|
|
345
|
-
var questionOptionSchema =
|
|
346
|
-
id:
|
|
347
|
-
value:
|
|
348
|
-
label:
|
|
349
|
-
describe:
|
|
630
|
+
var questionOptionSchema = z2.object({
|
|
631
|
+
id: z2.string().describe("Unique identifier for this option (system time milliseconds)"),
|
|
632
|
+
value: z2.string().min(1).max(100).describe("The internal value used for this option"),
|
|
633
|
+
label: z2.string().min(1).max(200).describe("The display text shown to users for this option"),
|
|
634
|
+
describe: z2.string().max(500).optional().describe(
|
|
350
635
|
"LLM tool call description providing context about this option"
|
|
351
636
|
),
|
|
352
|
-
imageUrl:
|
|
637
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL to display with this option")
|
|
353
638
|
}).describe("Schema for individual options in choice-based questions");
|
|
354
|
-
var nestedOptionSchema =
|
|
355
|
-
() =>
|
|
356
|
-
id:
|
|
357
|
-
value:
|
|
358
|
-
label:
|
|
359
|
-
describe:
|
|
360
|
-
imageUrl:
|
|
361
|
-
hint:
|
|
639
|
+
var nestedOptionSchema = z2.lazy(
|
|
640
|
+
() => z2.object({
|
|
641
|
+
id: z2.string().describe("Unique identifier for this nested option (system time milliseconds)"),
|
|
642
|
+
value: z2.string().min(1).max(100).describe("The internal value used for this nested option"),
|
|
643
|
+
label: z2.string().min(1).max(200).describe("The display text shown for this nested option"),
|
|
644
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this nested option context"),
|
|
645
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL for this nested option"),
|
|
646
|
+
hint: z2.string().max(500).optional().describe(
|
|
362
647
|
"Optional hint text to help users understand this nested option"
|
|
363
648
|
),
|
|
364
|
-
children:
|
|
649
|
+
children: z2.array(nestedOptionSchema).optional().default([]).describe("Array of child options for hierarchical structure")
|
|
365
650
|
}).describe("Schema for nested options with hierarchical structure support")
|
|
366
651
|
);
|
|
367
652
|
var multipleChoiceSingleQuestionSchema = questionSchema.extend({
|
|
368
|
-
type:
|
|
653
|
+
type: z2.literal("single_choice").describe("Must be exactly 'single_choice'"),
|
|
369
654
|
displayStyle: multipleChoiceDisplayStyleSchema.optional().describe("Visual style for displaying options"),
|
|
370
|
-
allowOther:
|
|
371
|
-
otherTextConfig:
|
|
372
|
-
minChars:
|
|
373
|
-
maxChars:
|
|
374
|
-
placeholder:
|
|
655
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow a custom "other" option'),
|
|
656
|
+
otherTextConfig: z2.object({
|
|
657
|
+
minChars: z2.number().int().min(0).optional().describe("Minimum number of characters required for the other text"),
|
|
658
|
+
maxChars: z2.number().int().min(1).optional().describe("Maximum number of characters allowed for the other text"),
|
|
659
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the other text input")
|
|
375
660
|
}).optional().describe('Configuration for the custom "other" text input'),
|
|
376
|
-
randomizeOptions:
|
|
377
|
-
options:
|
|
661
|
+
randomizeOptions: z2.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
662
|
+
options: z2.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
378
663
|
}).describe("Schema for single-choice multiple selection questions");
|
|
379
664
|
var multipleChoiceMultipleQuestionSchema = questionSchema.extend({
|
|
380
|
-
type:
|
|
665
|
+
type: z2.literal("multiple_choice_multiple").describe("Must be exactly 'multiple_choice_multiple'"),
|
|
381
666
|
displayStyle: multipleChoiceMultipleDisplayStyleSchema.optional().describe("Visual style for displaying multiple options"),
|
|
382
|
-
allowOther:
|
|
383
|
-
otherTextConfig:
|
|
384
|
-
minChars:
|
|
385
|
-
maxChars:
|
|
386
|
-
placeholder:
|
|
667
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow a custom "other" option'),
|
|
668
|
+
otherTextConfig: z2.object({
|
|
669
|
+
minChars: z2.number().int().min(0).optional().describe("Minimum number of characters required for the other text"),
|
|
670
|
+
maxChars: z2.number().int().min(1).optional().describe("Maximum number of characters allowed for the other text"),
|
|
671
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the other text input")
|
|
387
672
|
}).optional().describe('Configuration for the custom "other" text input'),
|
|
388
|
-
minSelections:
|
|
389
|
-
maxSelections:
|
|
390
|
-
randomizeOptions:
|
|
391
|
-
options:
|
|
673
|
+
minSelections: z2.number().int().min(0).optional().describe("Minimum number of options that must be selected"),
|
|
674
|
+
maxSelections: z2.number().int().min(1).optional().describe("Maximum number of options that can be selected"),
|
|
675
|
+
randomizeOptions: z2.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
676
|
+
options: z2.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
392
677
|
}).refine(
|
|
393
678
|
(data) => {
|
|
394
679
|
if (data.minSelections !== void 0 && data.maxSelections !== void 0) {
|
|
@@ -405,13 +690,13 @@ var multipleChoiceMultipleQuestionSchema = questionSchema.extend({
|
|
|
405
690
|
"Schema for multiple-choice questions allowing multiple selections"
|
|
406
691
|
);
|
|
407
692
|
var npsQuestionSchema = questionSchema.extend({
|
|
408
|
-
type:
|
|
409
|
-
min:
|
|
410
|
-
max:
|
|
411
|
-
minLabel:
|
|
412
|
-
maxLabel:
|
|
413
|
-
scaleLabels:
|
|
414
|
-
prepopulatedValue:
|
|
693
|
+
type: z2.literal("nps").describe("Must be exactly 'nps'"),
|
|
694
|
+
min: z2.literal(0).describe("NPS always starts at 0"),
|
|
695
|
+
max: z2.literal(10).describe("NPS always ends at 10"),
|
|
696
|
+
minLabel: z2.string().max(100).optional().describe("Label for the minimum NPS value (0)"),
|
|
697
|
+
maxLabel: z2.string().max(100).optional().describe("Label for the maximum NPS value (10)"),
|
|
698
|
+
scaleLabels: z2.record(z2.string().regex(/^\d+$/), z2.string().max(50)).optional().describe("Custom labels for specific NPS values (0-10)"),
|
|
699
|
+
prepopulatedValue: z2.number().int().min(0).max(10).optional().describe("Default value to pre-select (0-10)")
|
|
415
700
|
}).refine(
|
|
416
701
|
(data) => {
|
|
417
702
|
if (data.scaleLabels) {
|
|
@@ -429,16 +714,16 @@ var npsQuestionSchema = questionSchema.extend({
|
|
|
429
714
|
}
|
|
430
715
|
).describe("Schema for Net Promoter Score questions with 0-10 scale");
|
|
431
716
|
var shortAnswerQuestionSchema = questionSchema.extend({
|
|
432
|
-
type:
|
|
433
|
-
maxCharacters:
|
|
434
|
-
minCharacters:
|
|
435
|
-
placeholder:
|
|
436
|
-
enableRegexValidation:
|
|
437
|
-
regexPattern:
|
|
438
|
-
enableEnhanceWithAi:
|
|
439
|
-
promptTemplate:
|
|
440
|
-
maxTokenAllowed:
|
|
441
|
-
minCharactersToEnhance:
|
|
717
|
+
type: z2.literal("short_answer").describe("Must be exactly 'short_answer'"),
|
|
718
|
+
maxCharacters: z2.number().int().min(1).max(1e4).optional().describe("Maximum number of characters allowed"),
|
|
719
|
+
minCharacters: z2.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
720
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text shown in the input field"),
|
|
721
|
+
enableRegexValidation: z2.boolean().optional().default(false).describe("Whether to enable regex pattern validation"),
|
|
722
|
+
regexPattern: z2.string().optional().describe("Regular expression pattern for validation"),
|
|
723
|
+
enableEnhanceWithAi: z2.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
724
|
+
promptTemplate: z2.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
725
|
+
maxTokenAllowed: z2.number().int().min(1).max(1e4).optional().describe("Maximum tokens allowed for AI processing"),
|
|
726
|
+
minCharactersToEnhance: z2.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
442
727
|
}).refine(
|
|
443
728
|
(data) => {
|
|
444
729
|
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
@@ -474,19 +759,19 @@ var shortAnswerQuestionSchema = questionSchema.extend({
|
|
|
474
759
|
}
|
|
475
760
|
).describe("Schema for short answer questions with optional AI enhancement");
|
|
476
761
|
var longAnswerQuestionSchema = questionSchema.extend({
|
|
477
|
-
type:
|
|
478
|
-
maxCharacters:
|
|
762
|
+
type: z2.literal("long_text").describe("Must be exactly 'long_text'"),
|
|
763
|
+
maxCharacters: z2.number().int().min(1).max(5e4).optional().describe(
|
|
479
764
|
"Maximum number of characters allowed (higher limit for long text)"
|
|
480
765
|
),
|
|
481
|
-
minCharacters:
|
|
482
|
-
rows:
|
|
483
|
-
placeholder:
|
|
484
|
-
enableEnhanceWithAi:
|
|
485
|
-
promptTemplate:
|
|
486
|
-
maxTokenAllowed:
|
|
766
|
+
minCharacters: z2.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
767
|
+
rows: z2.number().int().min(1).max(20).optional().describe("Number of textarea rows to display (1-20)"),
|
|
768
|
+
placeholder: z2.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
|
|
769
|
+
enableEnhanceWithAi: z2.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
770
|
+
promptTemplate: z2.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
771
|
+
maxTokenAllowed: z2.number().int().min(1).max(25e3).optional().describe(
|
|
487
772
|
"Maximum tokens allowed for AI processing (higher for long text)"
|
|
488
773
|
),
|
|
489
|
-
minCharactersToEnhance:
|
|
774
|
+
minCharactersToEnhance: z2.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
490
775
|
}).refine(
|
|
491
776
|
(data) => {
|
|
492
777
|
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
@@ -513,19 +798,19 @@ var longAnswerQuestionSchema = questionSchema.extend({
|
|
|
513
798
|
"Schema for long answer questions with rich text support and AI enhancement"
|
|
514
799
|
);
|
|
515
800
|
var nestedDropdownQuestionSchema = questionSchema.extend({
|
|
516
|
-
type:
|
|
517
|
-
placeholder:
|
|
518
|
-
options:
|
|
801
|
+
type: z2.literal("nested_selection").describe("Must be exactly 'nested_selection'"),
|
|
802
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the nested dropdown"),
|
|
803
|
+
options: z2.array(nestedOptionSchema).min(1).max(100).describe(
|
|
519
804
|
"Array of nested options for hierarchical selection (1-100 options)"
|
|
520
805
|
),
|
|
521
|
-
displayStyle:
|
|
806
|
+
displayStyle: z2.literal("list").describe("Fixed display style for nested dropdowns"),
|
|
522
807
|
choiceOrderOption: choiceOrderOptionSchema.optional().default("none").describe("How to order the nested choices"),
|
|
523
|
-
preserveLastChoices:
|
|
524
|
-
prepopulatedValue:
|
|
525
|
-
allowOther:
|
|
526
|
-
otherColumnName:
|
|
527
|
-
maxDepth:
|
|
528
|
-
cascadeLabels:
|
|
808
|
+
preserveLastChoices: z2.number().int().min(0).max(10).optional().describe("Number of choice levels to preserve (0-10)"),
|
|
809
|
+
prepopulatedValue: z2.string().max(1e3).optional().describe("Default value to pre-populate"),
|
|
810
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow custom "other" options'),
|
|
811
|
+
otherColumnName: z2.string().max(100).optional().describe('Column name for storing custom "other" values'),
|
|
812
|
+
maxDepth: z2.number().int().min(1).max(10).optional().describe("Maximum nesting depth allowed (1-10)"),
|
|
813
|
+
cascadeLabels: z2.boolean().optional().default(false).describe("Whether to cascade labels from parent options")
|
|
529
814
|
}).refine(
|
|
530
815
|
(data) => {
|
|
531
816
|
if (data.allowOther && !data.otherColumnName) {
|
|
@@ -540,7 +825,7 @@ var nestedDropdownQuestionSchema = questionSchema.extend({
|
|
|
540
825
|
).describe(
|
|
541
826
|
"Schema for nested dropdown questions with hierarchical option structure"
|
|
542
827
|
);
|
|
543
|
-
var combinedQuestionSchema =
|
|
828
|
+
var combinedQuestionSchema = z2.discriminatedUnion("type", [
|
|
544
829
|
ratingQuestionSchema,
|
|
545
830
|
annotationQuestionSchema,
|
|
546
831
|
welcomeQuestionSchema,
|
|
@@ -560,47 +845,47 @@ var combinedQuestionSchema = z.discriminatedUnion("type", [
|
|
|
560
845
|
]);
|
|
561
846
|
|
|
562
847
|
// src/schemas/fields/answer-schema.ts
|
|
563
|
-
import { z as
|
|
564
|
-
var AnnotationMarkerSchema =
|
|
565
|
-
markerNo:
|
|
566
|
-
timeline:
|
|
567
|
-
comment:
|
|
848
|
+
import { z as z3 } from "zod";
|
|
849
|
+
var AnnotationMarkerSchema = z3.object({
|
|
850
|
+
markerNo: z3.string(),
|
|
851
|
+
timeline: z3.string(),
|
|
852
|
+
comment: z3.string()
|
|
568
853
|
});
|
|
569
|
-
var AnnotationSchema =
|
|
570
|
-
fileType:
|
|
571
|
-
fileName:
|
|
572
|
-
markers:
|
|
854
|
+
var AnnotationSchema = z3.object({
|
|
855
|
+
fileType: z3.string(),
|
|
856
|
+
fileName: z3.string(),
|
|
857
|
+
markers: z3.array(AnnotationMarkerSchema)
|
|
573
858
|
});
|
|
574
|
-
var AnswerItemSchema =
|
|
575
|
-
nps:
|
|
576
|
-
nestedSelection:
|
|
577
|
-
longText:
|
|
578
|
-
shortAnswer:
|
|
579
|
-
singleChoice:
|
|
859
|
+
var AnswerItemSchema = z3.object({
|
|
860
|
+
nps: z3.number().optional().describe("Net Promoter Score value (e.g., 0-10)"),
|
|
861
|
+
nestedSelection: z3.array(z3.string()).optional().describe("Array of selected nested option IDs"),
|
|
862
|
+
longText: z3.string().optional().describe("Long text answer, e.g., paragraph or essay"),
|
|
863
|
+
shortAnswer: z3.string().optional().describe("Short text answer, e.g., single sentence or word"),
|
|
864
|
+
singleChoice: z3.string().optional().describe(
|
|
580
865
|
"single selected option ID (for single choice questions)"
|
|
581
866
|
),
|
|
582
|
-
rating:
|
|
583
|
-
yesNo:
|
|
584
|
-
multipleChoiceMultiple:
|
|
585
|
-
singleChoiceOther:
|
|
867
|
+
rating: z3.number().optional().describe("Star rating value (e.g., 1-5)"),
|
|
868
|
+
yesNo: z3.boolean().optional().describe("Yes/no answer for yes_no questions (true = Yes, false = No)"),
|
|
869
|
+
multipleChoiceMultiple: z3.array(z3.string()).optional().describe("Array of selected option IDs for multiple choice questions"),
|
|
870
|
+
singleChoiceOther: z3.string().optional().describe(
|
|
586
871
|
'Free-text "other" answer for single choice questions when allowOther is enabled'
|
|
587
872
|
),
|
|
588
|
-
multipleChoiceOther:
|
|
873
|
+
multipleChoiceOther: z3.string().optional().describe(
|
|
589
874
|
'Free-text "other" answer for multiple choice questions when allowOther is enabled'
|
|
590
875
|
),
|
|
591
876
|
annotation: AnnotationSchema.optional().describe(
|
|
592
877
|
"Annotation object containing file and marker details"
|
|
593
878
|
),
|
|
594
|
-
ratingMatrix:
|
|
879
|
+
ratingMatrix: z3.record(z3.string(), z3.union([z3.number(), z3.string()])).optional().describe(
|
|
595
880
|
"Rating matrix answers keyed by statement value (export key), value is the selected scale value (number for likert/numerical, string for custom)"
|
|
596
881
|
),
|
|
597
|
-
matrixSingleChoice:
|
|
882
|
+
matrixSingleChoice: z3.record(z3.string(), z3.string()).optional().describe(
|
|
598
883
|
"Matrix single-choice answers keyed by row value (export key), map value is the selected column option value"
|
|
599
884
|
),
|
|
600
|
-
matrixMultipleChoice:
|
|
885
|
+
matrixMultipleChoice: z3.record(z3.string(), z3.array(z3.string())).optional().describe(
|
|
601
886
|
"Matrix multiple-choice answers keyed by row value (export key), map value is array of selected column option values"
|
|
602
887
|
),
|
|
603
|
-
others:
|
|
888
|
+
others: z3.string().optional().describe(
|
|
604
889
|
"For multiple choice questions and single choice questions, this is the value of the other option"
|
|
605
890
|
)
|
|
606
891
|
}).describe(
|
|
@@ -609,386 +894,27 @@ var AnswerItemSchema = z2.object({
|
|
|
609
894
|
var AnswerSchema = AnswerItemSchema;
|
|
610
895
|
|
|
611
896
|
// src/schemas/fields/form-schema.ts
|
|
612
|
-
import { z as
|
|
613
|
-
var
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
ONE_TIME: "S"
|
|
617
|
-
};
|
|
618
|
-
var yesNoSchema = z3.enum(["Y", "N"]).describe("Yes/No enumeration using Y/N values");
|
|
619
|
-
var YesNoValues = {
|
|
620
|
-
YES: "Y",
|
|
621
|
-
NO: "N"
|
|
622
|
-
};
|
|
623
|
-
var recurringUnitSchema = z3.enum(["minutes", "hours", "days", "weeks", "months", "years"]).describe("Time units for recurring feedback schedules");
|
|
624
|
-
var RecurringUnits = {
|
|
625
|
-
MINUTES: "minutes",
|
|
626
|
-
HOURS: "hours",
|
|
627
|
-
DAYS: "days",
|
|
628
|
-
WEEKS: "weeks",
|
|
629
|
-
MONTHS: "months",
|
|
630
|
-
YEARS: "years"
|
|
631
|
-
};
|
|
632
|
-
var frequencyAndSchedulingPropertiesSchema = z3.object({
|
|
633
|
-
surveyType: surveyTypeSchema.describe("Type of feedback: R for recurring, O for one-time"),
|
|
634
|
-
showOnce: yesNoSchema.describe("Whether the feedback should be shown only once per user"),
|
|
635
|
-
stopWhenResponsesCount: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Stop feedback when this number of responses is reached (as string)"),
|
|
636
|
-
recurringValue: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Value for recurring schedule (e.g., every 15 days)"),
|
|
637
|
-
recurringUnit: recurringUnitSchema.describe("Time unit for recurring schedule"),
|
|
638
|
-
startDate: z3.string().regex(
|
|
639
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
640
|
-
"Must be a valid ISO date string with timezone"
|
|
641
|
-
).describe("Start date and time for the feedback in ISO format"),
|
|
642
|
-
stopDate: z3.string().regex(
|
|
643
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
644
|
-
"Must be a valid ISO date string with timezone"
|
|
645
|
-
).describe("Stop date and time for the feedback in ISO format")
|
|
646
|
-
}).refine(
|
|
647
|
-
(data) => {
|
|
648
|
-
if (data.surveyType === "S" && data.showOnce === "N") {
|
|
649
|
-
return false;
|
|
650
|
-
}
|
|
651
|
-
return true;
|
|
652
|
-
},
|
|
653
|
-
{
|
|
654
|
-
message: "One-time feedback must have showOnce set to 'Y'",
|
|
655
|
-
path: ["showOnce"]
|
|
656
|
-
}
|
|
657
|
-
).refine(
|
|
658
|
-
(data) => {
|
|
659
|
-
if (data.surveyType === "R") {
|
|
660
|
-
const value = parseInt(data.recurringValue);
|
|
661
|
-
return value > 0;
|
|
662
|
-
}
|
|
663
|
-
return true;
|
|
664
|
-
},
|
|
665
|
-
{
|
|
666
|
-
message: "Recurring feedback must have a positive recurring value",
|
|
667
|
-
path: ["recurringValue"]
|
|
668
|
-
}
|
|
669
|
-
).refine(
|
|
670
|
-
(data) => {
|
|
671
|
-
const start = new Date(data.startDate);
|
|
672
|
-
const stop = new Date(data.stopDate);
|
|
673
|
-
return stop > start;
|
|
674
|
-
},
|
|
675
|
-
{
|
|
676
|
-
message: "Stop date must be after start date",
|
|
677
|
-
path: ["stopDate"]
|
|
678
|
-
}
|
|
679
|
-
).describe("Schema defining frequency and scheduling properties for feedback");
|
|
680
|
-
var externalPublishingPropertiesSchema = z3.object({
|
|
681
|
-
isShareable: z3.boolean().describe("Whether the feedback results can be shared externally"),
|
|
682
|
-
isEmailShareable: z3.boolean().describe("Whether the feedback can be shared via email")
|
|
897
|
+
import { z as z4 } from "zod";
|
|
898
|
+
var externalPublishingPropertiesSchema = z4.object({
|
|
899
|
+
isShareable: z4.boolean().describe("Whether the feedback results can be shared externally"),
|
|
900
|
+
isEmailShareable: z4.boolean().describe("Whether the feedback can be shared via email")
|
|
683
901
|
}).describe("Schema defining external publishing and sharing properties for feedback");
|
|
684
|
-
var publicationStatusSchema =
|
|
902
|
+
var publicationStatusSchema = z4.enum(["P", "D", "A", "S"]).describe("Publication status: P=Published, D=Draft, A=Archived, S=Stopped");
|
|
685
903
|
var PublicationStatuses = {
|
|
686
904
|
PUBLISHED: "P",
|
|
687
905
|
DRAFT: "D",
|
|
688
906
|
ARCHIVED: "A",
|
|
689
907
|
STOPPED: "S"
|
|
690
908
|
};
|
|
691
|
-
var feedbackConfigurationSchema =
|
|
692
|
-
formTitle:
|
|
693
|
-
formDescription:
|
|
694
|
-
// duration: durationSchema
|
|
695
|
-
// .refine(
|
|
696
|
-
// (data) => {
|
|
697
|
-
// // Validate ISO format for this specific use case
|
|
698
|
-
// const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/;
|
|
699
|
-
// return isoRegex.test(data.from) && isoRegex.test(data.to);
|
|
700
|
-
// },
|
|
701
|
-
// {
|
|
702
|
-
// message: "Duration dates must be in valid ISO format with timezone",
|
|
703
|
-
// path: ["from"],
|
|
704
|
-
// }
|
|
705
|
-
// )
|
|
706
|
-
// .refine(
|
|
707
|
-
// (data) => {
|
|
708
|
-
// // End date should be after start date
|
|
709
|
-
// const start = new Date(data.from);
|
|
710
|
-
// const end = new Date(data.to);
|
|
711
|
-
// return end > start;
|
|
712
|
-
// },
|
|
713
|
-
// {
|
|
714
|
-
// message: "End date must be after start date",
|
|
715
|
-
// path: ["to"],
|
|
716
|
-
// }
|
|
717
|
-
// )
|
|
718
|
-
// .describe("Duration period for the feedback"),
|
|
909
|
+
var feedbackConfigurationSchema = z4.object({
|
|
910
|
+
formTitle: z4.string().describe("Title of the feedback form"),
|
|
911
|
+
formDescription: z4.string().describe("Description of the feedback form"),
|
|
719
912
|
isPublished: publicationStatusSchema.describe("Publication status of the feedback form")
|
|
720
913
|
}).describe("Schema defining feedback configuration properties");
|
|
721
914
|
|
|
722
915
|
// src/schemas/fields/form-properties-schema.ts
|
|
723
916
|
import { z as z8 } from "zod";
|
|
724
917
|
|
|
725
|
-
// src/schemas/fields/translations-schema.ts
|
|
726
|
-
import { z as z4 } from "zod";
|
|
727
|
-
var translationEntrySchema = z4.string().min(1).describe("Translated text content");
|
|
728
|
-
var baseQuestionTranslationFieldsSchema = z4.object({
|
|
729
|
-
title: translationEntrySchema.describe("Question title translation"),
|
|
730
|
-
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
731
|
-
errorMessage: translationEntrySchema.optional().describe("Error message translation")
|
|
732
|
-
});
|
|
733
|
-
var BASE_QUESTION_TRANSLATION_KEYS = [
|
|
734
|
-
"type",
|
|
735
|
-
"title",
|
|
736
|
-
"description",
|
|
737
|
-
"errorMessage"
|
|
738
|
-
];
|
|
739
|
-
var ratingQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
740
|
-
type: z4.literal("rating").describe("Question type identifier"),
|
|
741
|
-
minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
|
|
742
|
-
maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
|
|
743
|
-
}).describe("Translation schema for rating questions");
|
|
744
|
-
var singleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
745
|
-
type: z4.literal("single_choice").describe("Question type identifier"),
|
|
746
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
747
|
-
}).catchall(translationEntrySchema).refine(
|
|
748
|
-
(data) => {
|
|
749
|
-
const additionalKeys = Object.keys(data).filter(
|
|
750
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
751
|
-
);
|
|
752
|
-
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
753
|
-
},
|
|
754
|
-
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
755
|
-
).describe("Translation schema for single choice questions");
|
|
756
|
-
var multipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
757
|
-
type: z4.literal("multiple_choice_multiple").describe("Question type identifier"),
|
|
758
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
759
|
-
}).catchall(translationEntrySchema).refine(
|
|
760
|
-
(data) => {
|
|
761
|
-
const additionalKeys = Object.keys(data).filter(
|
|
762
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
763
|
-
);
|
|
764
|
-
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
765
|
-
},
|
|
766
|
-
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
767
|
-
).describe("Translation schema for multiple choice questions");
|
|
768
|
-
var npsQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
769
|
-
type: z4.literal("nps").describe("Question type identifier"),
|
|
770
|
-
minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
|
|
771
|
-
maxLabel: translationEntrySchema.optional().describe("Maximum NPS label (10) translation")
|
|
772
|
-
}).catchall(translationEntrySchema).refine(
|
|
773
|
-
(data) => {
|
|
774
|
-
const additionalKeys = Object.keys(data).filter(
|
|
775
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(key)
|
|
776
|
-
);
|
|
777
|
-
return additionalKeys.every((key) => /^scaleLabel\.\d+$/.test(key));
|
|
778
|
-
},
|
|
779
|
-
{ message: "Additional keys must follow the pattern 'scaleLabel.{number}'" }
|
|
780
|
-
).describe("Translation schema for NPS questions");
|
|
781
|
-
var shortAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
782
|
-
type: z4.literal("short_answer").describe("Question type identifier"),
|
|
783
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
784
|
-
}).describe("Translation schema for short answer questions");
|
|
785
|
-
var longAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
786
|
-
type: z4.literal("long_text").describe("Question type identifier"),
|
|
787
|
-
placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
|
|
788
|
-
}).describe("Translation schema for long answer questions");
|
|
789
|
-
var nestedSelectionQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
790
|
-
type: z4.literal("nested_selection").describe("Question type identifier"),
|
|
791
|
-
placeholder: translationEntrySchema.optional().describe("Dropdown placeholder translation")
|
|
792
|
-
}).catchall(translationEntrySchema).refine(
|
|
793
|
-
(data) => {
|
|
794
|
-
const additionalKeys = Object.keys(data).filter(
|
|
795
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
796
|
-
);
|
|
797
|
-
return additionalKeys.every((key) => /^nestedOption\..+\.(label|hint)$/.test(key));
|
|
798
|
-
},
|
|
799
|
-
{ message: "Additional keys must follow the pattern 'nestedOption.{id}.{label|hint}'" }
|
|
800
|
-
).describe("Translation schema for nested selection questions");
|
|
801
|
-
var annotationQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
802
|
-
type: z4.literal("annotation").describe("Question type identifier"),
|
|
803
|
-
annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
|
|
804
|
-
noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
|
|
805
|
-
}).describe("Translation schema for annotation questions");
|
|
806
|
-
var welcomeQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
807
|
-
type: z4.literal("welcome").describe("Question type identifier"),
|
|
808
|
-
buttonLabel: translationEntrySchema.optional().describe("Translated proceed/start button label")
|
|
809
|
-
}).describe("Translation schema for welcome screen questions");
|
|
810
|
-
var thankYouQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
811
|
-
type: z4.literal("thank_you").describe("Question type identifier"),
|
|
812
|
-
buttonLabel: translationEntrySchema.optional().describe(
|
|
813
|
-
"Translated dismiss/done button label"
|
|
814
|
-
)
|
|
815
|
-
}).describe("Translation schema for thank you screen questions");
|
|
816
|
-
var messagePanelQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
817
|
-
type: z4.literal("message_panel").describe("Question type identifier"),
|
|
818
|
-
buttonLabel: translationEntrySchema.optional().describe(
|
|
819
|
-
"Translated continue/button label"
|
|
820
|
-
)
|
|
821
|
-
}).describe("Translation schema for message panel questions");
|
|
822
|
-
var yesNoQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
823
|
-
type: z4.literal("yes_no").describe("Question type identifier"),
|
|
824
|
-
yesLabel: translationEntrySchema.optional().describe("Translated Yes label"),
|
|
825
|
-
noLabel: translationEntrySchema.optional().describe("Translated No label")
|
|
826
|
-
}).describe("Translation schema for yes/no questions");
|
|
827
|
-
var ratingMatrixQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
828
|
-
type: z4.literal("rating_matrix").describe("Question type identifier"),
|
|
829
|
-
minLabel: translationEntrySchema.optional().describe(
|
|
830
|
-
"Translated scale minimum end label (for likert and numerical kinds)"
|
|
831
|
-
),
|
|
832
|
-
maxLabel: translationEntrySchema.optional().describe(
|
|
833
|
-
"Translated scale maximum end label (for likert and numerical kinds)"
|
|
834
|
-
)
|
|
835
|
-
}).catchall(translationEntrySchema).refine(
|
|
836
|
-
(data) => {
|
|
837
|
-
const additionalKeys = Object.keys(data).filter(
|
|
838
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(
|
|
839
|
-
key
|
|
840
|
-
)
|
|
841
|
-
);
|
|
842
|
-
return additionalKeys.every(
|
|
843
|
-
(key) => /^statement\..+\.label$/.test(key) || /^scalePoint\..+\.label$/.test(key)
|
|
844
|
-
);
|
|
845
|
-
},
|
|
846
|
-
{
|
|
847
|
-
message: "Additional keys must follow 'statement.{id}.label' or 'scalePoint.{id}.label'"
|
|
848
|
-
}
|
|
849
|
-
).describe("Translation schema for rating matrix questions");
|
|
850
|
-
var matrixSingleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
851
|
-
type: z4.literal("matrix_single_choice").describe("Question type identifier")
|
|
852
|
-
}).catchall(translationEntrySchema).refine(
|
|
853
|
-
(data) => {
|
|
854
|
-
const additionalKeys = Object.keys(data).filter(
|
|
855
|
-
(key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
|
|
856
|
-
);
|
|
857
|
-
return additionalKeys.every(
|
|
858
|
-
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
859
|
-
);
|
|
860
|
-
},
|
|
861
|
-
{
|
|
862
|
-
message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
|
|
863
|
-
}
|
|
864
|
-
).describe("Translation schema for matrix single-choice questions");
|
|
865
|
-
var matrixMultipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
866
|
-
type: z4.literal("matrix_multiple_choice").describe("Question type identifier")
|
|
867
|
-
}).catchall(translationEntrySchema).refine(
|
|
868
|
-
(data) => {
|
|
869
|
-
const additionalKeys = Object.keys(data).filter(
|
|
870
|
-
(key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
|
|
871
|
-
);
|
|
872
|
-
return additionalKeys.every(
|
|
873
|
-
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
874
|
-
);
|
|
875
|
-
},
|
|
876
|
-
{
|
|
877
|
-
message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
|
|
878
|
-
}
|
|
879
|
-
).describe("Translation schema for matrix multiple-choice questions");
|
|
880
|
-
var questionTranslationSchema = z4.union([
|
|
881
|
-
ratingQuestionTranslationSchema,
|
|
882
|
-
singleChoiceQuestionTranslationSchema,
|
|
883
|
-
multipleChoiceQuestionTranslationSchema,
|
|
884
|
-
npsQuestionTranslationSchema,
|
|
885
|
-
shortAnswerQuestionTranslationSchema,
|
|
886
|
-
longAnswerQuestionTranslationSchema,
|
|
887
|
-
nestedSelectionQuestionTranslationSchema,
|
|
888
|
-
annotationQuestionTranslationSchema,
|
|
889
|
-
welcomeQuestionTranslationSchema,
|
|
890
|
-
thankYouQuestionTranslationSchema,
|
|
891
|
-
messagePanelQuestionTranslationSchema,
|
|
892
|
-
yesNoQuestionTranslationSchema,
|
|
893
|
-
ratingMatrixQuestionTranslationSchema,
|
|
894
|
-
matrixSingleChoiceQuestionTranslationSchema,
|
|
895
|
-
matrixMultipleChoiceQuestionTranslationSchema
|
|
896
|
-
]).describe("Union of all question type translation schemas");
|
|
897
|
-
var languageCodeSchema = z4.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
|
|
898
|
-
var questionTranslationsByLanguageSchema = z4.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
|
|
899
|
-
var questionCentricTranslationsSchema = z4.record(z4.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
|
|
900
|
-
var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
|
|
901
|
-
var _TranslationProvider = class _TranslationProvider {
|
|
902
|
-
constructor(translations, defaultLanguage = "en") {
|
|
903
|
-
this.translations = translations;
|
|
904
|
-
this.defaultLanguage = defaultLanguage;
|
|
905
|
-
}
|
|
906
|
-
/**
|
|
907
|
-
* Get translations for a specific question in a specific language
|
|
908
|
-
*/
|
|
909
|
-
getQuestionTranslations(questionId, languageCode) {
|
|
910
|
-
const questionTranslations = this.translations[questionId];
|
|
911
|
-
if (!questionTranslations) return null;
|
|
912
|
-
let translation = questionTranslations[languageCode];
|
|
913
|
-
if (!translation) {
|
|
914
|
-
translation = questionTranslations[this.defaultLanguage];
|
|
915
|
-
}
|
|
916
|
-
return translation || null;
|
|
917
|
-
}
|
|
918
|
-
/**
|
|
919
|
-
* Get a specific translation text by field path
|
|
920
|
-
*/
|
|
921
|
-
getTranslationText(questionId, languageCode, fieldPath) {
|
|
922
|
-
const questionTranslation = this.getQuestionTranslations(questionId, languageCode);
|
|
923
|
-
if (!questionTranslation) return null;
|
|
924
|
-
if (fieldPath in questionTranslation) {
|
|
925
|
-
const value = questionTranslation[fieldPath];
|
|
926
|
-
return typeof value === "string" ? value : null;
|
|
927
|
-
}
|
|
928
|
-
return null;
|
|
929
|
-
}
|
|
930
|
-
/**
|
|
931
|
-
* Get all available languages for a specific question
|
|
932
|
-
*/
|
|
933
|
-
getQuestionLanguages(questionId) {
|
|
934
|
-
const questionTranslations = this.translations[questionId];
|
|
935
|
-
if (!questionTranslations) return [];
|
|
936
|
-
return Object.keys(questionTranslations);
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* Get all available languages across all questions
|
|
940
|
-
*/
|
|
941
|
-
getAvailableLanguages() {
|
|
942
|
-
const allLanguages = /* @__PURE__ */ new Set();
|
|
943
|
-
Object.values(this.translations).forEach((questionTranslations) => {
|
|
944
|
-
Object.keys(questionTranslations).forEach((langCode) => {
|
|
945
|
-
allLanguages.add(langCode);
|
|
946
|
-
});
|
|
947
|
-
});
|
|
948
|
-
return Array.from(allLanguages);
|
|
949
|
-
}
|
|
950
|
-
/**
|
|
951
|
-
* Check if a language is supported for a specific question
|
|
952
|
-
*/
|
|
953
|
-
isLanguageSupportedForQuestion(questionId, languageCode) {
|
|
954
|
-
const questionTranslations = this.translations[questionId];
|
|
955
|
-
if (!questionTranslations) return false;
|
|
956
|
-
return languageCode in questionTranslations;
|
|
957
|
-
}
|
|
958
|
-
/**
|
|
959
|
-
* Check if a language is supported across all questions
|
|
960
|
-
*/
|
|
961
|
-
isLanguageSupported(languageCode) {
|
|
962
|
-
return this.getAvailableLanguages().includes(languageCode);
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Get the default language
|
|
966
|
-
*/
|
|
967
|
-
getDefaultLanguage() {
|
|
968
|
-
return this.defaultLanguage;
|
|
969
|
-
}
|
|
970
|
-
/**
|
|
971
|
-
* Get all questions that have translations
|
|
972
|
-
*/
|
|
973
|
-
getQuestionIds() {
|
|
974
|
-
return Object.keys(this.translations);
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Get question type for a specific question
|
|
978
|
-
*/
|
|
979
|
-
getQuestionType(questionId, languageCode) {
|
|
980
|
-
const langCode = languageCode || this.defaultLanguage;
|
|
981
|
-
const translation = this.getQuestionTranslations(questionId, langCode);
|
|
982
|
-
return translation?.type || null;
|
|
983
|
-
}
|
|
984
|
-
};
|
|
985
|
-
__name(_TranslationProvider, "TranslationProvider");
|
|
986
|
-
var TranslationProvider = _TranslationProvider;
|
|
987
|
-
function createTranslationProvider(translations, defaultLanguage = "en") {
|
|
988
|
-
return new TranslationProvider(translations, defaultLanguage);
|
|
989
|
-
}
|
|
990
|
-
__name(createTranslationProvider, "createTranslationProvider");
|
|
991
|
-
|
|
992
918
|
// src/schemas/fields/other-screen-schema.ts
|
|
993
919
|
import { z as z5 } from "zod";
|
|
994
920
|
var OtherFieldsSchema = z5.object({
|
|
@@ -1061,12 +987,10 @@ var featureSettingsSchema = z6.object({
|
|
|
1061
987
|
progressBar: z6.boolean().describe("Whether to show a progress bar indicating completion status"),
|
|
1062
988
|
showBranding: z6.boolean().describe("Whether to display branding elements on the widget"),
|
|
1063
989
|
customPosition: z6.boolean().describe("Whether custom positioning is enabled"),
|
|
1064
|
-
customIconPosition: z6.boolean().describe("Whether custom icon positioning is enabled"),
|
|
1065
990
|
customCss: z6.string().optional().describe("Custom CSS link to apply for the feedback form"),
|
|
1066
991
|
shareableMode: shareableModeSchema.optional().describe(
|
|
1067
992
|
"Display mode for the shareable: light, dark, or system preference"
|
|
1068
993
|
),
|
|
1069
|
-
allowMultipleQuestionsPerSection: z6.boolean().describe("Whether to allow multiple questions per section"),
|
|
1070
994
|
rtl: z6.boolean().describe("Whether right-to-left text direction is enabled"),
|
|
1071
995
|
previousButton: previousButtonModeSchema.describe("Previous button visibility mode: never, always, or auto")
|
|
1072
996
|
}).describe("Feature settings controlling widget UI behavior and appearance");
|
|
@@ -1194,12 +1118,11 @@ var formPropertiesSchema = z8.object({
|
|
|
1194
1118
|
selectedLanguages: LanguagesSchema.describe("Array of languages selected for this questionnaire"),
|
|
1195
1119
|
translations: translationsSchema.describe("Multi-language translations for questions and form content")
|
|
1196
1120
|
}).describe("Fields defining the questionnaire structure, questions, sections, selected languages, and translations"),
|
|
1197
|
-
frequencyAndSchedulingProperties: frequencyAndSchedulingPropertiesSchema.describe("Properties controlling when and how often the feedback is shown"),
|
|
1198
1121
|
externalPublishingProperties: externalPublishingPropertiesSchema.describe("Properties controlling external sharing and publishing of feedback results"),
|
|
1199
1122
|
audienceTriggerProperties: audienceTriggerPropertiesSchema.describe("Properties defining audience targeting and trigger conditions for the feedback form"),
|
|
1200
1123
|
otherConfigurationProperties: otherConfigurationPropertiesSchema.describe("Additional configuration properties including form display options and translations"),
|
|
1201
1124
|
appearanceProperties: appearancePropertiesSchema.describe("Appearance configuration including themes, colors, and UI feature settings")
|
|
1202
|
-
}).describe("Complete schema for all feedback-level properties including
|
|
1125
|
+
}).describe("Complete schema for all feedback-level properties including publishing, audience targeting, configuration, and appearance");
|
|
1203
1126
|
|
|
1204
1127
|
// src/schemas/fields/other-properties-schema.ts
|
|
1205
1128
|
import { z as z9 } from "zod";
|
|
@@ -1328,14 +1251,12 @@ var feedbackConfigurationItemSchema = z12.object({
|
|
|
1328
1251
|
customPosition: z12.boolean().describe("Whether custom position is enabled"),
|
|
1329
1252
|
customIconPosition: z12.boolean().describe("Whether custom icon position is enabled"),
|
|
1330
1253
|
customCss: z12.string().nullable().optional().describe("Custom CSS link (optional)"),
|
|
1331
|
-
allowMultipleQuestionsPerSection: z12.boolean().describe("Whether to allow multiple questions per section"),
|
|
1332
1254
|
rtl: z12.boolean().describe("Whether right-to-left text direction is enabled"),
|
|
1333
1255
|
previousButton: z12.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto")
|
|
1334
1256
|
}).describe("Feature settings for the feedback form"),
|
|
1335
1257
|
selectedIconPosition: z12.string().describe("Selected position for the feedback icon"),
|
|
1336
1258
|
selectedPosition: z12.string().describe("Selected position for the feedback form")
|
|
1337
|
-
}).describe("Appearance properties for the feedback form")
|
|
1338
|
-
frequencyAndScheduling: frequencyAndSchedulingPropertiesSchema.optional().describe("Frequency and scheduling properties for the feedback (optional)")
|
|
1259
|
+
}).describe("Appearance properties for the feedback form")
|
|
1339
1260
|
}).describe("Individual feedback configuration item in the list");
|
|
1340
1261
|
var fetchFormConfigSchema = z12.object({
|
|
1341
1262
|
feedbackConfigurationId: z12.string().uuid().describe("Unique identifier for the feedback configuration"),
|
|
@@ -1547,15 +1468,12 @@ export {
|
|
|
1547
1468
|
RatingDisplayStyles,
|
|
1548
1469
|
RatingMatrixDisplayStyles,
|
|
1549
1470
|
RatingRepresentationSizes,
|
|
1550
|
-
RecurringUnits,
|
|
1551
1471
|
ShareableModes,
|
|
1552
|
-
SurveyTypes,
|
|
1553
1472
|
ThemeModes,
|
|
1554
1473
|
TranslationProvider,
|
|
1555
1474
|
ValidationRuleTypes,
|
|
1556
1475
|
VisibilityConditionOperators,
|
|
1557
1476
|
YesNoDisplayStyles,
|
|
1558
|
-
YesNoValues,
|
|
1559
1477
|
annotationQuestionSchema,
|
|
1560
1478
|
annotationQuestionTranslationSchema,
|
|
1561
1479
|
appPropsSchema,
|
|
@@ -1591,7 +1509,6 @@ export {
|
|
|
1591
1509
|
formConfigSchema,
|
|
1592
1510
|
formConfigurationResponseSchema,
|
|
1593
1511
|
formPropertiesSchema,
|
|
1594
|
-
frequencyAndSchedulingPropertiesSchema,
|
|
1595
1512
|
longAnswerQuestionSchema,
|
|
1596
1513
|
longAnswerQuestionTranslationSchema,
|
|
1597
1514
|
masterPropertiesSchema,
|
|
@@ -1640,19 +1557,19 @@ export {
|
|
|
1640
1557
|
ratingQuestionSchema,
|
|
1641
1558
|
ratingQuestionTranslationSchema,
|
|
1642
1559
|
ratingRepresentationSizeSchema,
|
|
1643
|
-
recurringUnitSchema,
|
|
1644
1560
|
refineTextDataSchema,
|
|
1645
1561
|
refineTextParamsSchema,
|
|
1646
1562
|
refineTextResponseSchema,
|
|
1647
1563
|
responseSchema,
|
|
1648
1564
|
sectionSchema,
|
|
1565
|
+
sectionTranslationSchema,
|
|
1566
|
+
sectionTranslationsByLanguageSchema,
|
|
1649
1567
|
sessionInfoSchema,
|
|
1650
1568
|
shareableModeSchema,
|
|
1651
1569
|
shortAnswerQuestionSchema,
|
|
1652
1570
|
shortAnswerQuestionTranslationSchema,
|
|
1653
1571
|
singleChoiceQuestionTranslationSchema,
|
|
1654
1572
|
submitFeedbackSchema,
|
|
1655
|
-
surveyTypeSchema,
|
|
1656
1573
|
thankYouQuestionSchema,
|
|
1657
1574
|
thankYouQuestionTranslationSchema,
|
|
1658
1575
|
themeColorsSchema,
|
|
@@ -1676,7 +1593,6 @@ export {
|
|
|
1676
1593
|
yesNoDisplayStyleSchema,
|
|
1677
1594
|
yesNoQuestionSchema,
|
|
1678
1595
|
yesNoQuestionTranslationSchema,
|
|
1679
|
-
yesNoSchema,
|
|
1680
1596
|
z15 as z
|
|
1681
1597
|
};
|
|
1682
1598
|
//# sourceMappingURL=index.js.map
|