@encatch/schema 1.0.1-beta.1 → 1.0.1-beta.3
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 +643 -793
- package/dist/esm/index.js.map +3 -3
- package/dist/types/index.d.ts +4 -4
- package/dist/types/schemas/api/fetch-feedback-schema.d.ts +350 -236
- package/dist/types/schemas/fields/app-props-schema.d.ts +175 -142
- package/dist/types/schemas/fields/field-schema.d.ts +377 -144
- package/dist/types/schemas/fields/form-properties-schema.d.ts +176 -244
- package/dist/types/schemas/fields/form-schema.d.ts +0 -58
- package/dist/types/schemas/fields/other-screen-schema.d.ts +0 -39
- package/dist/types/schemas/fields/theme-schema.d.ts +0 -4
- package/dist/types/schemas/fields/translations-schema.d.ts +1 -77
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -2,8 +2,277 @@ 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 questionTranslationsByLanguageSchema = z.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
|
|
181
|
+
var questionCentricTranslationsSchema = z.record(z.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
|
|
182
|
+
var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
|
|
183
|
+
var _TranslationProvider = class _TranslationProvider {
|
|
184
|
+
constructor(translations, defaultLanguage = "en") {
|
|
185
|
+
this.translations = translations;
|
|
186
|
+
this.defaultLanguage = defaultLanguage;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get translations for a specific question in a specific language
|
|
190
|
+
*/
|
|
191
|
+
getQuestionTranslations(questionId, languageCode) {
|
|
192
|
+
const questionTranslations = this.translations[questionId];
|
|
193
|
+
if (!questionTranslations) return null;
|
|
194
|
+
let translation = questionTranslations[languageCode];
|
|
195
|
+
if (!translation) {
|
|
196
|
+
translation = questionTranslations[this.defaultLanguage];
|
|
197
|
+
}
|
|
198
|
+
return translation || null;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Get a specific translation text by field path
|
|
202
|
+
*/
|
|
203
|
+
getTranslationText(questionId, languageCode, fieldPath) {
|
|
204
|
+
const questionTranslation = this.getQuestionTranslations(questionId, languageCode);
|
|
205
|
+
if (!questionTranslation) return null;
|
|
206
|
+
if (fieldPath in questionTranslation) {
|
|
207
|
+
const value = questionTranslation[fieldPath];
|
|
208
|
+
return typeof value === "string" ? value : null;
|
|
209
|
+
}
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Get all available languages for a specific question
|
|
214
|
+
*/
|
|
215
|
+
getQuestionLanguages(questionId) {
|
|
216
|
+
const questionTranslations = this.translations[questionId];
|
|
217
|
+
if (!questionTranslations) return [];
|
|
218
|
+
return Object.keys(questionTranslations);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get all available languages across all questions
|
|
222
|
+
*/
|
|
223
|
+
getAvailableLanguages() {
|
|
224
|
+
const allLanguages = /* @__PURE__ */ new Set();
|
|
225
|
+
Object.values(this.translations).forEach((questionTranslations) => {
|
|
226
|
+
Object.keys(questionTranslations).forEach((langCode) => {
|
|
227
|
+
allLanguages.add(langCode);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
return Array.from(allLanguages);
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Check if a language is supported for a specific question
|
|
234
|
+
*/
|
|
235
|
+
isLanguageSupportedForQuestion(questionId, languageCode) {
|
|
236
|
+
const questionTranslations = this.translations[questionId];
|
|
237
|
+
if (!questionTranslations) return false;
|
|
238
|
+
return languageCode in questionTranslations;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Check if a language is supported across all questions
|
|
242
|
+
*/
|
|
243
|
+
isLanguageSupported(languageCode) {
|
|
244
|
+
return this.getAvailableLanguages().includes(languageCode);
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Get the default language
|
|
248
|
+
*/
|
|
249
|
+
getDefaultLanguage() {
|
|
250
|
+
return this.defaultLanguage;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Get all questions that have translations
|
|
254
|
+
*/
|
|
255
|
+
getQuestionIds() {
|
|
256
|
+
return Object.keys(this.translations);
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Get question type for a specific question
|
|
260
|
+
*/
|
|
261
|
+
getQuestionType(questionId, languageCode) {
|
|
262
|
+
const langCode = languageCode || this.defaultLanguage;
|
|
263
|
+
const translation = this.getQuestionTranslations(questionId, langCode);
|
|
264
|
+
return translation?.type || null;
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
__name(_TranslationProvider, "TranslationProvider");
|
|
268
|
+
var TranslationProvider = _TranslationProvider;
|
|
269
|
+
function createTranslationProvider(translations, defaultLanguage = "en") {
|
|
270
|
+
return new TranslationProvider(translations, defaultLanguage);
|
|
271
|
+
}
|
|
272
|
+
__name(createTranslationProvider, "createTranslationProvider");
|
|
273
|
+
|
|
274
|
+
// src/schemas/fields/field-schema.ts
|
|
275
|
+
var questionTypeSchema = z2.enum([
|
|
7
276
|
"rating",
|
|
8
277
|
"single_choice",
|
|
9
278
|
"nps",
|
|
@@ -18,7 +287,8 @@ var questionTypeSchema = z.enum([
|
|
|
18
287
|
"yes_no",
|
|
19
288
|
"rating_matrix",
|
|
20
289
|
"matrix_single_choice",
|
|
21
|
-
"matrix_multiple_choice"
|
|
290
|
+
"matrix_multiple_choice",
|
|
291
|
+
"exit_form"
|
|
22
292
|
]).describe("Enumeration of all supported question types for form fields");
|
|
23
293
|
var QuestionTypes = {
|
|
24
294
|
RATING: "rating",
|
|
@@ -35,9 +305,10 @@ var QuestionTypes = {
|
|
|
35
305
|
YES_NO: "yes_no",
|
|
36
306
|
RATING_MATRIX: "rating_matrix",
|
|
37
307
|
MATRIX_SINGLE_CHOICE: "matrix_single_choice",
|
|
38
|
-
MATRIX_MULTIPLE_CHOICE: "matrix_multiple_choice"
|
|
308
|
+
MATRIX_MULTIPLE_CHOICE: "matrix_multiple_choice",
|
|
309
|
+
EXIT_FORM: "exit_form"
|
|
39
310
|
};
|
|
40
|
-
var validationRuleTypeSchema =
|
|
311
|
+
var validationRuleTypeSchema = z2.enum([
|
|
41
312
|
"required",
|
|
42
313
|
"min",
|
|
43
314
|
"max",
|
|
@@ -59,13 +330,13 @@ var ValidationRuleTypes = {
|
|
|
59
330
|
URL: "url",
|
|
60
331
|
CUSTOM: "custom"
|
|
61
332
|
};
|
|
62
|
-
var validationRuleSchema =
|
|
333
|
+
var validationRuleSchema = z2.object({
|
|
63
334
|
type: validationRuleTypeSchema.describe("Type of validation rule to apply"),
|
|
64
|
-
value:
|
|
65
|
-
message:
|
|
66
|
-
describe:
|
|
335
|
+
value: z2.union([z2.string(), z2.number(), z2.boolean()]).optional().describe("Value for the validation rule (string, number, or boolean)"),
|
|
336
|
+
message: z2.string().optional().describe("Custom error message when validation fails"),
|
|
337
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this validation rule")
|
|
67
338
|
}).describe("Schema defining validation rules for question responses");
|
|
68
|
-
var visibilityConditionOperatorSchema =
|
|
339
|
+
var visibilityConditionOperatorSchema = z2.enum([
|
|
69
340
|
"equals",
|
|
70
341
|
"not_equals",
|
|
71
342
|
"contains",
|
|
@@ -85,27 +356,48 @@ var VisibilityConditionOperators = {
|
|
|
85
356
|
IS_EMPTY: "is_empty",
|
|
86
357
|
IS_NOT_EMPTY: "is_not_empty"
|
|
87
358
|
};
|
|
88
|
-
var visibilityConditionSchema =
|
|
89
|
-
field:
|
|
359
|
+
var visibilityConditionSchema = z2.object({
|
|
360
|
+
field: z2.string().describe("ID of the field to check against"),
|
|
90
361
|
operator: visibilityConditionOperatorSchema.describe("Comparison operator for the condition"),
|
|
91
|
-
value:
|
|
92
|
-
describe:
|
|
362
|
+
value: z2.union([z2.string(), z2.number(), z2.boolean()]).optional().describe("Value to compare against (string, number, or boolean)"),
|
|
363
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this visibility condition")
|
|
93
364
|
}).describe(
|
|
94
365
|
"Schema defining conditions that control when questions are visible"
|
|
95
366
|
);
|
|
96
|
-
var sectionSchema =
|
|
97
|
-
id:
|
|
98
|
-
title:
|
|
99
|
-
|
|
367
|
+
var sectionSchema = z2.object({
|
|
368
|
+
id: z2.string().describe("Unique identifier for the section"),
|
|
369
|
+
title: z2.string().min(1).max(200).describe("Display title for the section"),
|
|
370
|
+
titleTranslations: z2.record(
|
|
371
|
+
languageCodeSchema,
|
|
372
|
+
z2.string().min(1).max(200)
|
|
373
|
+
).optional().describe("Localized section titles keyed by language code"),
|
|
374
|
+
description: z2.string().max(1e3).optional().describe("Optional detailed description or help text for the section"),
|
|
375
|
+
descriptionTranslations: z2.record(
|
|
376
|
+
languageCodeSchema,
|
|
377
|
+
z2.string().min(1).max(1e3)
|
|
378
|
+
).optional().describe("Localized section descriptions keyed by language code"),
|
|
379
|
+
showTitle: z2.boolean().default(true).describe("Whether to show the section title in the UI"),
|
|
380
|
+
showDescription: z2.boolean().default(true).describe("Whether to show the section description in the UI"),
|
|
381
|
+
nextButtonLabel: z2.string().min(1).max(50).optional().describe("Label for the next button when navigating from this section"),
|
|
382
|
+
nextButtonLabelTranslations: z2.record(
|
|
383
|
+
languageCodeSchema,
|
|
384
|
+
z2.string().min(1).max(50)
|
|
385
|
+
).optional().describe(
|
|
386
|
+
"Localized next-button labels for this section keyed by language code"
|
|
387
|
+
),
|
|
388
|
+
inAppSingleQuestion: z2.boolean().default(false).describe(
|
|
389
|
+
"When true, the native app shows one question at a time within this section"
|
|
390
|
+
),
|
|
391
|
+
questionIds: z2.array(z2.string()).min(1).describe("Array of question IDs that belong to this section")
|
|
100
392
|
}).describe("Schema defining sections that organize questions into logical groups");
|
|
101
|
-
var questionStatusSchema =
|
|
393
|
+
var questionStatusSchema = z2.enum(["D", "P", "A", "S"]);
|
|
102
394
|
var QuestionStatuses = {
|
|
103
395
|
DRAFT: "D",
|
|
104
396
|
PUBLISHED: "P",
|
|
105
397
|
ARCHIVED: "A",
|
|
106
398
|
SUSPENDED: "S"
|
|
107
399
|
};
|
|
108
|
-
var ratingDisplayStyleSchema =
|
|
400
|
+
var ratingDisplayStyleSchema = z2.enum([
|
|
109
401
|
"star",
|
|
110
402
|
"heart",
|
|
111
403
|
"thumbs-up",
|
|
@@ -121,7 +413,7 @@ var RatingDisplayStyles = {
|
|
|
121
413
|
EMOJI: "emoji",
|
|
122
414
|
EMOJI_EXP: "emoji_exp"
|
|
123
415
|
};
|
|
124
|
-
var ratingRepresentationSizeSchema =
|
|
416
|
+
var ratingRepresentationSizeSchema = z2.enum([
|
|
125
417
|
"small",
|
|
126
418
|
"medium",
|
|
127
419
|
"large"
|
|
@@ -131,7 +423,7 @@ var RatingRepresentationSizes = {
|
|
|
131
423
|
MEDIUM: "medium",
|
|
132
424
|
LARGE: "large"
|
|
133
425
|
};
|
|
134
|
-
var multipleChoiceDisplayStyleSchema =
|
|
426
|
+
var multipleChoiceDisplayStyleSchema = z2.enum([
|
|
135
427
|
"radio",
|
|
136
428
|
"list",
|
|
137
429
|
"chip",
|
|
@@ -143,7 +435,7 @@ var MultipleChoiceDisplayStyles = {
|
|
|
143
435
|
CHIP: "chip",
|
|
144
436
|
DROPDOWN: "dropdown"
|
|
145
437
|
};
|
|
146
|
-
var multipleChoiceMultipleDisplayStyleSchema =
|
|
438
|
+
var multipleChoiceMultipleDisplayStyleSchema = z2.enum([
|
|
147
439
|
"checkbox",
|
|
148
440
|
"list",
|
|
149
441
|
"chip"
|
|
@@ -153,12 +445,12 @@ var MultipleChoiceMultipleDisplayStyles = {
|
|
|
153
445
|
LIST: "list",
|
|
154
446
|
CHIP: "chip"
|
|
155
447
|
};
|
|
156
|
-
var yesNoDisplayStyleSchema =
|
|
448
|
+
var yesNoDisplayStyleSchema = z2.enum(["horizontal", "vertical"]);
|
|
157
449
|
var YesNoDisplayStyles = {
|
|
158
450
|
HORIZONTAL: "horizontal",
|
|
159
451
|
VERTICAL: "vertical"
|
|
160
452
|
};
|
|
161
|
-
var choiceOrderOptionSchema =
|
|
453
|
+
var choiceOrderOptionSchema = z2.enum([
|
|
162
454
|
"randomize",
|
|
163
455
|
"flip",
|
|
164
456
|
"rotate",
|
|
@@ -172,78 +464,83 @@ var ChoiceOrderOptions = {
|
|
|
172
464
|
ASCENDING: "ascending",
|
|
173
465
|
NONE: "none"
|
|
174
466
|
};
|
|
175
|
-
var questionSchema =
|
|
176
|
-
id:
|
|
467
|
+
var questionSchema = z2.object({
|
|
468
|
+
id: z2.string().describe("Unique identifier for the question"),
|
|
177
469
|
type: questionTypeSchema.describe(
|
|
178
470
|
"The type of question (rating, single_choice, etc.)"
|
|
179
471
|
),
|
|
180
|
-
title:
|
|
181
|
-
description:
|
|
182
|
-
|
|
183
|
-
describe: z.string().max(2e3).optional().describe(
|
|
472
|
+
title: z2.string().min(1).max(200).describe("The main title/question text displayed to users"),
|
|
473
|
+
description: z2.string().max(1e3).optional().describe("Optional detailed description or help text"),
|
|
474
|
+
describe: z2.string().max(2e3).optional().describe(
|
|
184
475
|
"LLM tool call description for better AI understanding and context"
|
|
185
476
|
),
|
|
186
|
-
required:
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
sectionId:
|
|
477
|
+
required: z2.boolean().default(false).describe("Whether this question must be answered"),
|
|
478
|
+
isHidden: z2.boolean().default(false).describe("When true, the question is hidden from the form UI"),
|
|
479
|
+
errorMessage: z2.string().max(500).optional().describe("Custom error message when validation fails"),
|
|
480
|
+
validations: z2.array(validationRuleSchema).optional().default([]).describe("Array of validation rules to apply"),
|
|
481
|
+
visibility: z2.array(visibilityConditionSchema).optional().default([]).describe("Conditions that control when this question is shown"),
|
|
482
|
+
sectionId: z2.string().optional().describe("ID of the section this question belongs to"),
|
|
192
483
|
status: questionStatusSchema.describe(
|
|
193
484
|
"Current status of the question (Draft, Published, etc.)"
|
|
194
|
-
)
|
|
485
|
+
),
|
|
486
|
+
textAlign: z2.enum(["left", "center"]).optional().default("left").describe("Text alignment for the question title and description")
|
|
195
487
|
}).describe("Base schema for all question types with common properties");
|
|
196
488
|
var ratingQuestionSchema = questionSchema.extend({
|
|
197
|
-
type:
|
|
198
|
-
showLabels:
|
|
199
|
-
minLabel:
|
|
200
|
-
maxLabel:
|
|
489
|
+
type: z2.literal("rating").describe("Must be exactly 'rating'"),
|
|
490
|
+
showLabels: z2.boolean().optional().describe("Whether to show min/max labels"),
|
|
491
|
+
minLabel: z2.string().max(100).optional().describe("Label for the minimum rating value"),
|
|
492
|
+
maxLabel: z2.string().max(100).optional().describe("Label for the maximum rating value"),
|
|
201
493
|
displayStyle: ratingDisplayStyleSchema.optional().describe("Visual style for rating display"),
|
|
202
|
-
numberOfRatings:
|
|
494
|
+
numberOfRatings: z2.number().int().min(1).max(10).describe("Number of rating options (1-10)"),
|
|
203
495
|
representationSize: ratingRepresentationSizeSchema.optional().describe("Size of rating visual elements"),
|
|
204
|
-
color:
|
|
496
|
+
color: z2.string().regex(/^#[0-9A-F]{6}$/i, "Must be a valid hex color").optional().describe("Hex color for rating elements")
|
|
205
497
|
}).describe("Schema for rating questions with customizable display options");
|
|
206
498
|
var annotationQuestionSchema = questionSchema.extend({
|
|
207
|
-
type:
|
|
208
|
-
annotationText:
|
|
209
|
-
noAnnotationText:
|
|
499
|
+
type: z2.literal("annotation").describe("Must be exactly 'annotation'"),
|
|
500
|
+
annotationText: z2.string().max(1e3).optional().describe("Text to display when annotation is provided"),
|
|
501
|
+
noAnnotationText: z2.string().max(500).optional().describe("Text to display when no annotation is provided")
|
|
210
502
|
}).describe(
|
|
211
503
|
"Schema for annotation questions that provide additional context or instructions"
|
|
212
504
|
);
|
|
213
505
|
var welcomeQuestionSchema = questionSchema.extend({
|
|
214
|
-
type:
|
|
215
|
-
title:
|
|
216
|
-
description:
|
|
217
|
-
buttonLabel:
|
|
218
|
-
imageUrl:
|
|
506
|
+
type: z2.literal("welcome").describe("Must be exactly 'welcome'"),
|
|
507
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the welcome screen"),
|
|
508
|
+
description: z2.string().max(1e3).optional().describe("Optional sub-text body shown below the heading"),
|
|
509
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the proceed/start button (e.g. 'Get Started', 'Begin')"),
|
|
510
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the welcome screen")
|
|
219
511
|
}).describe("Schema for a welcome screen displayed at the start or inline within a form");
|
|
220
512
|
var thankYouQuestionSchema = questionSchema.extend({
|
|
221
|
-
type:
|
|
222
|
-
title:
|
|
223
|
-
description:
|
|
224
|
-
"Optional thank you body text
|
|
513
|
+
type: z2.literal("thank_you").describe("Must be exactly 'thank_you'"),
|
|
514
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the thank you screen"),
|
|
515
|
+
description: z2.string().max(1e3).optional().describe(
|
|
516
|
+
"Optional thank you body text; rendered as Markdown where the form supports it"
|
|
225
517
|
),
|
|
226
|
-
buttonLabel:
|
|
227
|
-
imageUrl:
|
|
518
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the dismiss/done button (e.g. 'Done', 'Close')"),
|
|
519
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the thank you screen")
|
|
228
520
|
}).describe(
|
|
229
|
-
"Schema for a thank you screen shown at the end or inline within a form
|
|
521
|
+
"Schema for a thank you screen shown at the end or inline within a form"
|
|
230
522
|
);
|
|
231
523
|
var messagePanelQuestionSchema = questionSchema.extend({
|
|
232
|
-
type:
|
|
233
|
-
title:
|
|
234
|
-
description:
|
|
235
|
-
buttonLabel:
|
|
236
|
-
imageUrl:
|
|
524
|
+
type: z2.literal("message_panel").describe("Must be exactly 'message_panel'"),
|
|
525
|
+
title: z2.string().min(1).max(200).describe("The main heading displayed on the message panel"),
|
|
526
|
+
description: z2.string().max(1e3).optional().describe("Optional body text shown below the heading"),
|
|
527
|
+
buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the continue button (e.g. 'Continue', 'Next')"),
|
|
528
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the message panel")
|
|
237
529
|
}).describe(
|
|
238
530
|
"Schema for an inline message panel (informational); distinct from welcome for UI semantics and analytics"
|
|
239
531
|
);
|
|
532
|
+
var exitFormQuestionSchema = questionSchema.extend({
|
|
533
|
+
type: z2.literal("exit_form").describe("Must be exactly 'exit_form'")
|
|
534
|
+
}).describe(
|
|
535
|
+
"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"
|
|
536
|
+
);
|
|
240
537
|
var yesNoQuestionSchema = questionSchema.extend({
|
|
241
|
-
type:
|
|
242
|
-
yesLabel:
|
|
243
|
-
noLabel:
|
|
538
|
+
type: z2.literal("yes_no").describe("Must be exactly 'yes_no'"),
|
|
539
|
+
yesLabel: z2.string().min(1).max(50).optional().describe("Label for the Yes option (defaults to 'Yes' in the UI if omitted)"),
|
|
540
|
+
noLabel: z2.string().min(1).max(50).optional().describe("Label for the No option (defaults to 'No' in the UI if omitted)"),
|
|
244
541
|
displayStyle: yesNoDisplayStyleSchema.optional().describe("Layout for the Yes/No controls (horizontal row or vertical stack)")
|
|
245
542
|
}).describe("Schema for yes/no questions with optional custom labels and layout");
|
|
246
|
-
var ratingMatrixDisplayStyleSchema =
|
|
543
|
+
var ratingMatrixDisplayStyleSchema = z2.enum([
|
|
247
544
|
"radio",
|
|
248
545
|
"star",
|
|
249
546
|
"emoji",
|
|
@@ -255,74 +552,72 @@ var RatingMatrixDisplayStyles = {
|
|
|
255
552
|
EMOJI: "emoji",
|
|
256
553
|
BUTTON: "button"
|
|
257
554
|
};
|
|
258
|
-
var ratingMatrixStatementSchema =
|
|
259
|
-
id:
|
|
260
|
-
value:
|
|
261
|
-
label:
|
|
262
|
-
describe:
|
|
555
|
+
var ratingMatrixStatementSchema = z2.object({
|
|
556
|
+
id: z2.string().describe("Unique identifier for this statement (system time milliseconds)"),
|
|
557
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this statement"),
|
|
558
|
+
label: z2.string().min(1).max(200).describe("Display text shown to users for this statement"),
|
|
559
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this statement")
|
|
263
560
|
}).describe("Schema for an individual statement (row) in a rating matrix");
|
|
264
|
-
var ratingMatrixScalePointSchema =
|
|
265
|
-
id:
|
|
266
|
-
value:
|
|
267
|
-
label:
|
|
268
|
-
describe:
|
|
561
|
+
var ratingMatrixScalePointSchema = z2.object({
|
|
562
|
+
id: z2.string().describe("Unique identifier for this scale point"),
|
|
563
|
+
value: z2.union([z2.number(), z2.string()]).describe("Stored response value for this scale point (number or string)"),
|
|
564
|
+
label: z2.string().min(1).max(200).describe("Display label shown for this scale point"),
|
|
565
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this scale point")
|
|
269
566
|
}).describe("Schema for a single point on a custom rating scale");
|
|
270
|
-
var ratingMatrixScaleSchema =
|
|
271
|
-
// Likert: symmetric ordinal scale -2…+2,
|
|
272
|
-
|
|
273
|
-
kind:
|
|
274
|
-
|
|
275
|
-
maxLabel: z.string().max(100).optional().describe("Optional label for the positive end of the Likert scale")
|
|
567
|
+
var ratingMatrixScaleSchema = z2.discriminatedUnion("kind", [
|
|
568
|
+
// Likert: symmetric ordinal scale -2…+2, explicit scale points with labels
|
|
569
|
+
z2.object({
|
|
570
|
+
kind: z2.literal("likert").describe("Symmetric ordinal scale (-2 to +2)"),
|
|
571
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column")
|
|
276
572
|
}),
|
|
277
|
-
// Numerical: 1…N points where N is 2, 3, 4, or 5
|
|
278
|
-
|
|
279
|
-
kind:
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
maxLabel: z.string().max(100).optional().describe("Optional label for the highest numerical value")
|
|
573
|
+
// Numerical: 1…N points where N is 2, 3, 4, or 5, explicit scale points with labels
|
|
574
|
+
z2.object({
|
|
575
|
+
kind: z2.literal("numerical").describe("Numerical scale from 1 to N"),
|
|
576
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column"),
|
|
577
|
+
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)")
|
|
283
578
|
}),
|
|
284
579
|
// Custom: consumer defines each point's value and label
|
|
285
|
-
|
|
286
|
-
kind:
|
|
287
|
-
scalePoints:
|
|
580
|
+
z2.object({
|
|
581
|
+
kind: z2.literal("custom").describe("Custom scale with user-defined points and values"),
|
|
582
|
+
scalePoints: z2.array(ratingMatrixScalePointSchema).min(2).max(10).describe("Scale points with display labels for each column")
|
|
288
583
|
})
|
|
289
584
|
]).describe("Scale configuration for rating matrix questions");
|
|
290
585
|
var ratingMatrixQuestionSchema = questionSchema.extend({
|
|
291
|
-
type:
|
|
292
|
-
statements:
|
|
586
|
+
type: z2.literal("rating_matrix").describe("Must be exactly 'rating_matrix'"),
|
|
587
|
+
statements: z2.array(ratingMatrixStatementSchema).min(1).max(10).describe("Statements (rows) users will rate on the shared scale (1-10)"),
|
|
293
588
|
scale: ratingMatrixScaleSchema.describe("Scale configuration shared across all statement rows"),
|
|
294
589
|
displayStyle: ratingMatrixDisplayStyleSchema.optional().describe(
|
|
295
590
|
"Visual representation of scale points per row (radio buttons, stars, emoji, or buttons)"
|
|
296
591
|
),
|
|
297
|
-
randomizeStatements:
|
|
592
|
+
randomizeStatements: z2.boolean().optional().default(false).describe("Whether to randomize the order of statements")
|
|
298
593
|
}).describe("Schema for rating matrix questions with multiple statements on a shared scale");
|
|
299
|
-
var matrixRowSchema =
|
|
300
|
-
id:
|
|
301
|
-
value:
|
|
302
|
-
label:
|
|
303
|
-
describe:
|
|
594
|
+
var matrixRowSchema = z2.object({
|
|
595
|
+
id: z2.string().describe("Unique identifier for this row (system time milliseconds)"),
|
|
596
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this row"),
|
|
597
|
+
label: z2.string().min(1).max(200).describe("Display text shown to users for this row"),
|
|
598
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this row")
|
|
304
599
|
}).describe("Schema for an individual row in a matrix choice question");
|
|
305
|
-
var matrixColumnSchema =
|
|
306
|
-
id:
|
|
307
|
-
value:
|
|
308
|
-
label:
|
|
309
|
-
describe:
|
|
600
|
+
var matrixColumnSchema = z2.object({
|
|
601
|
+
id: z2.string().describe("Unique identifier for this column (system time milliseconds)"),
|
|
602
|
+
value: z2.string().min(1).max(100).describe("Internal value / export key for this column"),
|
|
603
|
+
label: z2.string().min(1).max(200).describe("Display label shown for this column"),
|
|
604
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this column")
|
|
310
605
|
}).describe("Schema for an individual column in a matrix choice question");
|
|
311
606
|
var matrixSingleChoiceQuestionSchema = questionSchema.extend({
|
|
312
|
-
type:
|
|
313
|
-
rows:
|
|
314
|
-
columns:
|
|
315
|
-
randomizeRows:
|
|
316
|
-
randomizeColumns:
|
|
607
|
+
type: z2.literal("matrix_single_choice").describe("Must be exactly 'matrix_single_choice'"),
|
|
608
|
+
rows: z2.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
|
|
609
|
+
columns: z2.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
|
|
610
|
+
randomizeRows: z2.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
|
|
611
|
+
randomizeColumns: z2.boolean().optional().default(false).describe("Whether to randomize the order of columns")
|
|
317
612
|
}).describe("Schema for matrix single-choice questions where one column is selected per row");
|
|
318
613
|
var matrixMultipleChoiceQuestionSchema = questionSchema.extend({
|
|
319
|
-
type:
|
|
320
|
-
rows:
|
|
321
|
-
columns:
|
|
322
|
-
minSelectionsPerRow:
|
|
323
|
-
maxSelectionsPerRow:
|
|
324
|
-
randomizeRows:
|
|
325
|
-
randomizeColumns:
|
|
614
|
+
type: z2.literal("matrix_multiple_choice").describe("Must be exactly 'matrix_multiple_choice'"),
|
|
615
|
+
rows: z2.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
|
|
616
|
+
columns: z2.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
|
|
617
|
+
minSelectionsPerRow: z2.number().int().min(0).optional().describe("Minimum number of columns a user must select per row"),
|
|
618
|
+
maxSelectionsPerRow: z2.number().int().min(1).optional().describe("Maximum number of columns a user can select per row"),
|
|
619
|
+
randomizeRows: z2.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
|
|
620
|
+
randomizeColumns: z2.boolean().optional().default(false).describe("Whether to randomize the order of columns")
|
|
326
621
|
}).refine(
|
|
327
622
|
(data) => {
|
|
328
623
|
if (data.minSelectionsPerRow !== void 0 && data.maxSelectionsPerRow !== void 0) {
|
|
@@ -337,53 +632,53 @@ var matrixMultipleChoiceQuestionSchema = questionSchema.extend({
|
|
|
337
632
|
).describe(
|
|
338
633
|
"Schema for matrix multiple-choice questions where one or more columns can be selected per row"
|
|
339
634
|
);
|
|
340
|
-
var questionOptionSchema =
|
|
341
|
-
id:
|
|
342
|
-
value:
|
|
343
|
-
label:
|
|
344
|
-
describe:
|
|
635
|
+
var questionOptionSchema = z2.object({
|
|
636
|
+
id: z2.string().describe("Unique identifier for this option (system time milliseconds)"),
|
|
637
|
+
value: z2.string().min(1).max(100).describe("The internal value used for this option"),
|
|
638
|
+
label: z2.string().min(1).max(200).describe("The display text shown to users for this option"),
|
|
639
|
+
describe: z2.string().max(500).optional().describe(
|
|
345
640
|
"LLM tool call description providing context about this option"
|
|
346
641
|
),
|
|
347
|
-
imageUrl:
|
|
642
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL to display with this option")
|
|
348
643
|
}).describe("Schema for individual options in choice-based questions");
|
|
349
|
-
var nestedOptionSchema =
|
|
350
|
-
() =>
|
|
351
|
-
id:
|
|
352
|
-
value:
|
|
353
|
-
label:
|
|
354
|
-
describe:
|
|
355
|
-
imageUrl:
|
|
356
|
-
hint:
|
|
644
|
+
var nestedOptionSchema = z2.lazy(
|
|
645
|
+
() => z2.object({
|
|
646
|
+
id: z2.string().describe("Unique identifier for this nested option (system time milliseconds)"),
|
|
647
|
+
value: z2.string().min(1).max(100).describe("The internal value used for this nested option"),
|
|
648
|
+
label: z2.string().min(1).max(200).describe("The display text shown for this nested option"),
|
|
649
|
+
describe: z2.string().max(500).optional().describe("LLM tool call description for this nested option context"),
|
|
650
|
+
imageUrl: z2.string().url().optional().describe("Optional image URL for this nested option"),
|
|
651
|
+
hint: z2.string().max(500).optional().describe(
|
|
357
652
|
"Optional hint text to help users understand this nested option"
|
|
358
653
|
),
|
|
359
|
-
children:
|
|
654
|
+
children: z2.array(nestedOptionSchema).optional().default([]).describe("Array of child options for hierarchical structure")
|
|
360
655
|
}).describe("Schema for nested options with hierarchical structure support")
|
|
361
656
|
);
|
|
362
657
|
var multipleChoiceSingleQuestionSchema = questionSchema.extend({
|
|
363
|
-
type:
|
|
658
|
+
type: z2.literal("single_choice").describe("Must be exactly 'single_choice'"),
|
|
364
659
|
displayStyle: multipleChoiceDisplayStyleSchema.optional().describe("Visual style for displaying options"),
|
|
365
|
-
allowOther:
|
|
366
|
-
otherTextConfig:
|
|
367
|
-
minChars:
|
|
368
|
-
maxChars:
|
|
369
|
-
placeholder:
|
|
660
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow a custom "other" option'),
|
|
661
|
+
otherTextConfig: z2.object({
|
|
662
|
+
minChars: z2.number().int().min(0).optional().describe("Minimum number of characters required for the other text"),
|
|
663
|
+
maxChars: z2.number().int().min(1).optional().describe("Maximum number of characters allowed for the other text"),
|
|
664
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the other text input")
|
|
370
665
|
}).optional().describe('Configuration for the custom "other" text input'),
|
|
371
|
-
randomizeOptions:
|
|
372
|
-
options:
|
|
666
|
+
randomizeOptions: z2.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
667
|
+
options: z2.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
373
668
|
}).describe("Schema for single-choice multiple selection questions");
|
|
374
669
|
var multipleChoiceMultipleQuestionSchema = questionSchema.extend({
|
|
375
|
-
type:
|
|
670
|
+
type: z2.literal("multiple_choice_multiple").describe("Must be exactly 'multiple_choice_multiple'"),
|
|
376
671
|
displayStyle: multipleChoiceMultipleDisplayStyleSchema.optional().describe("Visual style for displaying multiple options"),
|
|
377
|
-
allowOther:
|
|
378
|
-
otherTextConfig:
|
|
379
|
-
minChars:
|
|
380
|
-
maxChars:
|
|
381
|
-
placeholder:
|
|
672
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow a custom "other" option'),
|
|
673
|
+
otherTextConfig: z2.object({
|
|
674
|
+
minChars: z2.number().int().min(0).optional().describe("Minimum number of characters required for the other text"),
|
|
675
|
+
maxChars: z2.number().int().min(1).optional().describe("Maximum number of characters allowed for the other text"),
|
|
676
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the other text input")
|
|
382
677
|
}).optional().describe('Configuration for the custom "other" text input'),
|
|
383
|
-
minSelections:
|
|
384
|
-
maxSelections:
|
|
385
|
-
randomizeOptions:
|
|
386
|
-
options:
|
|
678
|
+
minSelections: z2.number().int().min(0).optional().describe("Minimum number of options that must be selected"),
|
|
679
|
+
maxSelections: z2.number().int().min(1).optional().describe("Maximum number of options that can be selected"),
|
|
680
|
+
randomizeOptions: z2.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
681
|
+
options: z2.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
387
682
|
}).refine(
|
|
388
683
|
(data) => {
|
|
389
684
|
if (data.minSelections !== void 0 && data.maxSelections !== void 0) {
|
|
@@ -400,13 +695,13 @@ var multipleChoiceMultipleQuestionSchema = questionSchema.extend({
|
|
|
400
695
|
"Schema for multiple-choice questions allowing multiple selections"
|
|
401
696
|
);
|
|
402
697
|
var npsQuestionSchema = questionSchema.extend({
|
|
403
|
-
type:
|
|
404
|
-
min:
|
|
405
|
-
max:
|
|
406
|
-
minLabel:
|
|
407
|
-
maxLabel:
|
|
408
|
-
scaleLabels:
|
|
409
|
-
prepopulatedValue:
|
|
698
|
+
type: z2.literal("nps").describe("Must be exactly 'nps'"),
|
|
699
|
+
min: z2.literal(0).describe("NPS always starts at 0"),
|
|
700
|
+
max: z2.literal(10).describe("NPS always ends at 10"),
|
|
701
|
+
minLabel: z2.string().max(100).optional().describe("Label for the minimum NPS value (0)"),
|
|
702
|
+
maxLabel: z2.string().max(100).optional().describe("Label for the maximum NPS value (10)"),
|
|
703
|
+
scaleLabels: z2.record(z2.string().regex(/^\d+$/), z2.string().max(50)).optional().describe("Custom labels for specific NPS values (0-10)"),
|
|
704
|
+
prepopulatedValue: z2.number().int().min(0).max(10).optional().describe("Default value to pre-select (0-10)")
|
|
410
705
|
}).refine(
|
|
411
706
|
(data) => {
|
|
412
707
|
if (data.scaleLabels) {
|
|
@@ -421,599 +716,212 @@ var npsQuestionSchema = questionSchema.extend({
|
|
|
421
716
|
{
|
|
422
717
|
message: "scaleLabels keys must be between 0 and 10 (inclusive)",
|
|
423
718
|
path: ["scaleLabels"]
|
|
424
|
-
}
|
|
425
|
-
).describe("Schema for Net Promoter Score questions with 0-10 scale");
|
|
426
|
-
var shortAnswerQuestionSchema = questionSchema.extend({
|
|
427
|
-
type:
|
|
428
|
-
maxCharacters:
|
|
429
|
-
minCharacters:
|
|
430
|
-
placeholder:
|
|
431
|
-
enableRegexValidation:
|
|
432
|
-
regexPattern:
|
|
433
|
-
enableEnhanceWithAi:
|
|
434
|
-
promptTemplate:
|
|
435
|
-
maxTokenAllowed:
|
|
436
|
-
minCharactersToEnhance:
|
|
437
|
-
}).refine(
|
|
438
|
-
(data) => {
|
|
439
|
-
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
440
|
-
return data.minCharacters <= data.maxCharacters;
|
|
441
|
-
}
|
|
442
|
-
return true;
|
|
443
|
-
},
|
|
444
|
-
{
|
|
445
|
-
message: "minCharacters cannot be greater than maxCharacters",
|
|
446
|
-
path: ["minCharacters"]
|
|
447
|
-
}
|
|
448
|
-
).refine(
|
|
449
|
-
(data) => {
|
|
450
|
-
if (data.enableRegexValidation && !data.regexPattern) {
|
|
451
|
-
return false;
|
|
452
|
-
}
|
|
453
|
-
return true;
|
|
454
|
-
},
|
|
455
|
-
{
|
|
456
|
-
message: "regexPattern is required when enableRegexValidation is true",
|
|
457
|
-
path: ["regexPattern"]
|
|
458
|
-
}
|
|
459
|
-
).refine(
|
|
460
|
-
(data) => {
|
|
461
|
-
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
462
|
-
return false;
|
|
463
|
-
}
|
|
464
|
-
return true;
|
|
465
|
-
},
|
|
466
|
-
{
|
|
467
|
-
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
468
|
-
path: ["promptTemplate"]
|
|
469
|
-
}
|
|
470
|
-
).describe("Schema for short answer questions with optional AI enhancement");
|
|
471
|
-
var longAnswerQuestionSchema = questionSchema.extend({
|
|
472
|
-
type: z.literal("long_text").describe("Must be exactly 'long_text'"),
|
|
473
|
-
maxCharacters: z.number().int().min(1).max(5e4).optional().describe(
|
|
474
|
-
"Maximum number of characters allowed (higher limit for long text)"
|
|
475
|
-
),
|
|
476
|
-
minCharacters: z.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
477
|
-
rows: z.number().int().min(1).max(20).optional().describe("Number of textarea rows to display (1-20)"),
|
|
478
|
-
placeholder: z.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
|
|
479
|
-
enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
480
|
-
promptTemplate: z.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
481
|
-
maxTokenAllowed: z.number().int().min(1).max(25e3).optional().describe(
|
|
482
|
-
"Maximum tokens allowed for AI processing (higher for long text)"
|
|
483
|
-
),
|
|
484
|
-
minCharactersToEnhance: z.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
485
|
-
}).refine(
|
|
486
|
-
(data) => {
|
|
487
|
-
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
488
|
-
return data.minCharacters <= data.maxCharacters;
|
|
489
|
-
}
|
|
490
|
-
return true;
|
|
491
|
-
},
|
|
492
|
-
{
|
|
493
|
-
message: "minCharacters cannot be greater than maxCharacters",
|
|
494
|
-
path: ["minCharacters"]
|
|
495
|
-
}
|
|
496
|
-
).refine(
|
|
497
|
-
(data) => {
|
|
498
|
-
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
499
|
-
return false;
|
|
500
|
-
}
|
|
501
|
-
return true;
|
|
502
|
-
},
|
|
503
|
-
{
|
|
504
|
-
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
505
|
-
path: ["promptTemplate"]
|
|
506
|
-
}
|
|
507
|
-
).describe(
|
|
508
|
-
"Schema for long answer questions with rich text support and AI enhancement"
|
|
509
|
-
);
|
|
510
|
-
var nestedDropdownQuestionSchema = questionSchema.extend({
|
|
511
|
-
type: z.literal("nested_selection").describe("Must be exactly 'nested_selection'"),
|
|
512
|
-
placeholder: z.string().max(200).optional().describe("Placeholder text for the nested dropdown"),
|
|
513
|
-
options: z.array(nestedOptionSchema).min(1).max(100).describe(
|
|
514
|
-
"Array of nested options for hierarchical selection (1-100 options)"
|
|
515
|
-
),
|
|
516
|
-
displayStyle: z.literal("list").describe("Fixed display style for nested dropdowns"),
|
|
517
|
-
choiceOrderOption: choiceOrderOptionSchema.optional().default("none").describe("How to order the nested choices"),
|
|
518
|
-
preserveLastChoices: z.number().int().min(0).max(10).optional().describe("Number of choice levels to preserve (0-10)"),
|
|
519
|
-
prepopulatedValue: z.string().max(1e3).optional().describe("Default value to pre-populate"),
|
|
520
|
-
allowOther: z.boolean().optional().default(false).describe('Whether to allow custom "other" options'),
|
|
521
|
-
otherColumnName: z.string().max(100).optional().describe('Column name for storing custom "other" values'),
|
|
522
|
-
maxDepth: z.number().int().min(1).max(10).optional().describe("Maximum nesting depth allowed (1-10)"),
|
|
523
|
-
cascadeLabels: z.boolean().optional().default(false).describe("Whether to cascade labels from parent options")
|
|
524
|
-
}).refine(
|
|
525
|
-
(data) => {
|
|
526
|
-
if (data.allowOther && !data.otherColumnName) {
|
|
527
|
-
return false;
|
|
528
|
-
}
|
|
529
|
-
return true;
|
|
530
|
-
},
|
|
531
|
-
{
|
|
532
|
-
message: "otherColumnName is required when allowOther is true",
|
|
533
|
-
path: ["otherColumnName"]
|
|
534
|
-
}
|
|
535
|
-
).describe(
|
|
536
|
-
"Schema for nested dropdown questions with hierarchical option structure"
|
|
537
|
-
);
|
|
538
|
-
var combinedQuestionSchema = z.discriminatedUnion("type", [
|
|
539
|
-
ratingQuestionSchema,
|
|
540
|
-
annotationQuestionSchema,
|
|
541
|
-
welcomeQuestionSchema,
|
|
542
|
-
thankYouQuestionSchema,
|
|
543
|
-
messagePanelQuestionSchema,
|
|
544
|
-
yesNoQuestionSchema,
|
|
545
|
-
ratingMatrixQuestionSchema,
|
|
546
|
-
matrixSingleChoiceQuestionSchema,
|
|
547
|
-
matrixMultipleChoiceQuestionSchema,
|
|
548
|
-
multipleChoiceSingleQuestionSchema,
|
|
549
|
-
multipleChoiceMultipleQuestionSchema,
|
|
550
|
-
npsQuestionSchema,
|
|
551
|
-
shortAnswerQuestionSchema,
|
|
552
|
-
longAnswerQuestionSchema,
|
|
553
|
-
nestedDropdownQuestionSchema
|
|
554
|
-
]);
|
|
555
|
-
|
|
556
|
-
// src/schemas/fields/answer-schema.ts
|
|
557
|
-
import { z as z2 } from "zod";
|
|
558
|
-
var AnnotationMarkerSchema = z2.object({
|
|
559
|
-
markerNo: z2.string(),
|
|
560
|
-
timeline: z2.string(),
|
|
561
|
-
comment: z2.string()
|
|
562
|
-
});
|
|
563
|
-
var AnnotationSchema = z2.object({
|
|
564
|
-
fileType: z2.string(),
|
|
565
|
-
fileName: z2.string(),
|
|
566
|
-
markers: z2.array(AnnotationMarkerSchema)
|
|
567
|
-
});
|
|
568
|
-
var AnswerItemSchema = z2.object({
|
|
569
|
-
nps: z2.number().optional().describe("Net Promoter Score value (e.g., 0-10)"),
|
|
570
|
-
nestedSelection: z2.array(z2.string()).optional().describe("Array of selected nested option IDs"),
|
|
571
|
-
longText: z2.string().optional().describe("Long text answer, e.g., paragraph or essay"),
|
|
572
|
-
shortAnswer: z2.string().optional().describe("Short text answer, e.g., single sentence or word"),
|
|
573
|
-
singleChoice: z2.string().optional().describe(
|
|
574
|
-
"single selected option ID (for single choice questions)"
|
|
575
|
-
),
|
|
576
|
-
rating: z2.number().optional().describe("Star rating value (e.g., 1-5)"),
|
|
577
|
-
yesNo: z2.boolean().optional().describe("Yes/no answer for yes_no questions (true = Yes, false = No)"),
|
|
578
|
-
multipleChoiceMultiple: z2.array(z2.string()).optional().describe("Array of selected option IDs for multiple choice questions"),
|
|
579
|
-
singleChoiceOther: z2.string().optional().describe(
|
|
580
|
-
'Free-text "other" answer for single choice questions when allowOther is enabled'
|
|
581
|
-
),
|
|
582
|
-
multipleChoiceOther: z2.string().optional().describe(
|
|
583
|
-
'Free-text "other" answer for multiple choice questions when allowOther is enabled'
|
|
584
|
-
),
|
|
585
|
-
annotation: AnnotationSchema.optional().describe(
|
|
586
|
-
"Annotation object containing file and marker details"
|
|
587
|
-
),
|
|
588
|
-
ratingMatrix: z2.record(z2.string(), z2.union([z2.number(), z2.string()])).optional().describe(
|
|
589
|
-
"Rating matrix answers keyed by statement id, value is the selected scale value (number for likert/numerical, string for custom)"
|
|
590
|
-
),
|
|
591
|
-
matrixSingleChoice: z2.record(z2.string(), z2.string()).optional().describe(
|
|
592
|
-
"Matrix single-choice answers keyed by row id, value is the selected column option id"
|
|
593
|
-
),
|
|
594
|
-
matrixMultipleChoice: z2.record(z2.string(), z2.array(z2.string())).optional().describe(
|
|
595
|
-
"Matrix multiple-choice answers keyed by row id, value is array of selected column option ids"
|
|
596
|
-
),
|
|
597
|
-
others: z2.string().optional().describe(
|
|
598
|
-
"For multiple choice questions and single choice questions, this is the value of the other option"
|
|
599
|
-
)
|
|
600
|
-
}).describe(
|
|
601
|
-
"Flexible answer item supporting various question types and custom fields"
|
|
602
|
-
);
|
|
603
|
-
var AnswerSchema = AnswerItemSchema;
|
|
604
|
-
|
|
605
|
-
// src/schemas/fields/form-schema.ts
|
|
606
|
-
import { z as z3 } from "zod";
|
|
607
|
-
var surveyTypeSchema = z3.enum(["R", "S"]).describe("Enumeration of feedback types: R=Recurring, O=One-time");
|
|
608
|
-
var SurveyTypes = {
|
|
609
|
-
RECURRING: "R",
|
|
610
|
-
ONE_TIME: "S"
|
|
611
|
-
};
|
|
612
|
-
var yesNoSchema = z3.enum(["Y", "N"]).describe("Yes/No enumeration using Y/N values");
|
|
613
|
-
var YesNoValues = {
|
|
614
|
-
YES: "Y",
|
|
615
|
-
NO: "N"
|
|
616
|
-
};
|
|
617
|
-
var recurringUnitSchema = z3.enum(["minutes", "hours", "days", "weeks", "months", "years"]).describe("Time units for recurring feedback schedules");
|
|
618
|
-
var RecurringUnits = {
|
|
619
|
-
MINUTES: "minutes",
|
|
620
|
-
HOURS: "hours",
|
|
621
|
-
DAYS: "days",
|
|
622
|
-
WEEKS: "weeks",
|
|
623
|
-
MONTHS: "months",
|
|
624
|
-
YEARS: "years"
|
|
625
|
-
};
|
|
626
|
-
var frequencyAndSchedulingPropertiesSchema = z3.object({
|
|
627
|
-
surveyType: surveyTypeSchema.describe("Type of feedback: R for recurring, O for one-time"),
|
|
628
|
-
showOnce: yesNoSchema.describe("Whether the feedback should be shown only once per user"),
|
|
629
|
-
stopWhenResponsesCount: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Stop feedback when this number of responses is reached (as string)"),
|
|
630
|
-
recurringValue: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Value for recurring schedule (e.g., every 15 days)"),
|
|
631
|
-
recurringUnit: recurringUnitSchema.describe("Time unit for recurring schedule"),
|
|
632
|
-
startDate: z3.string().regex(
|
|
633
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
634
|
-
"Must be a valid ISO date string with timezone"
|
|
635
|
-
).describe("Start date and time for the feedback in ISO format"),
|
|
636
|
-
stopDate: z3.string().regex(
|
|
637
|
-
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
638
|
-
"Must be a valid ISO date string with timezone"
|
|
639
|
-
).describe("Stop date and time for the feedback in ISO format")
|
|
640
|
-
}).refine(
|
|
641
|
-
(data) => {
|
|
642
|
-
if (data.surveyType === "S" && data.showOnce === "N") {
|
|
643
|
-
return false;
|
|
644
|
-
}
|
|
645
|
-
return true;
|
|
646
|
-
},
|
|
647
|
-
{
|
|
648
|
-
message: "One-time feedback must have showOnce set to 'Y'",
|
|
649
|
-
path: ["showOnce"]
|
|
650
|
-
}
|
|
651
|
-
).refine(
|
|
652
|
-
(data) => {
|
|
653
|
-
if (data.surveyType === "R") {
|
|
654
|
-
const value = parseInt(data.recurringValue);
|
|
655
|
-
return value > 0;
|
|
656
|
-
}
|
|
657
|
-
return true;
|
|
658
|
-
},
|
|
659
|
-
{
|
|
660
|
-
message: "Recurring feedback must have a positive recurring value",
|
|
661
|
-
path: ["recurringValue"]
|
|
662
|
-
}
|
|
663
|
-
).refine(
|
|
664
|
-
(data) => {
|
|
665
|
-
const start = new Date(data.startDate);
|
|
666
|
-
const stop = new Date(data.stopDate);
|
|
667
|
-
return stop > start;
|
|
668
|
-
},
|
|
669
|
-
{
|
|
670
|
-
message: "Stop date must be after start date",
|
|
671
|
-
path: ["stopDate"]
|
|
672
|
-
}
|
|
673
|
-
).describe("Schema defining frequency and scheduling properties for feedback");
|
|
674
|
-
var externalPublishingPropertiesSchema = z3.object({
|
|
675
|
-
isShareable: z3.boolean().describe("Whether the feedback results can be shared externally"),
|
|
676
|
-
isEmailShareable: z3.boolean().describe("Whether the feedback can be shared via email")
|
|
677
|
-
}).describe("Schema defining external publishing and sharing properties for feedback");
|
|
678
|
-
var publicationStatusSchema = z3.enum(["P", "D", "A", "S"]).describe("Publication status: P=Published, D=Draft, A=Archived, S=Stopped");
|
|
679
|
-
var PublicationStatuses = {
|
|
680
|
-
PUBLISHED: "P",
|
|
681
|
-
DRAFT: "D",
|
|
682
|
-
ARCHIVED: "A",
|
|
683
|
-
STOPPED: "S"
|
|
684
|
-
};
|
|
685
|
-
var feedbackConfigurationSchema = z3.object({
|
|
686
|
-
formTitle: z3.string().describe("Title of the feedback form"),
|
|
687
|
-
formDescription: z3.string().describe("Description of the feedback form"),
|
|
688
|
-
// duration: durationSchema
|
|
689
|
-
// .refine(
|
|
690
|
-
// (data) => {
|
|
691
|
-
// // Validate ISO format for this specific use case
|
|
692
|
-
// const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/;
|
|
693
|
-
// return isoRegex.test(data.from) && isoRegex.test(data.to);
|
|
694
|
-
// },
|
|
695
|
-
// {
|
|
696
|
-
// message: "Duration dates must be in valid ISO format with timezone",
|
|
697
|
-
// path: ["from"],
|
|
698
|
-
// }
|
|
699
|
-
// )
|
|
700
|
-
// .refine(
|
|
701
|
-
// (data) => {
|
|
702
|
-
// // End date should be after start date
|
|
703
|
-
// const start = new Date(data.from);
|
|
704
|
-
// const end = new Date(data.to);
|
|
705
|
-
// return end > start;
|
|
706
|
-
// },
|
|
707
|
-
// {
|
|
708
|
-
// message: "End date must be after start date",
|
|
709
|
-
// path: ["to"],
|
|
710
|
-
// }
|
|
711
|
-
// )
|
|
712
|
-
// .describe("Duration period for the feedback"),
|
|
713
|
-
isPublished: publicationStatusSchema.describe("Publication status of the feedback form")
|
|
714
|
-
}).describe("Schema defining feedback configuration properties");
|
|
715
|
-
|
|
716
|
-
// src/schemas/fields/form-properties-schema.ts
|
|
717
|
-
import { z as z8 } from "zod";
|
|
718
|
-
|
|
719
|
-
// src/schemas/fields/translations-schema.ts
|
|
720
|
-
import { z as z4 } from "zod";
|
|
721
|
-
var translationEntrySchema = z4.string().min(1).describe("Translated text content");
|
|
722
|
-
var baseQuestionTranslationFieldsSchema = z4.object({
|
|
723
|
-
title: translationEntrySchema.describe("Question title translation"),
|
|
724
|
-
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
725
|
-
descriptionMarkdown: translationEntrySchema.optional().describe("Question description Markdown translation"),
|
|
726
|
-
errorMessage: translationEntrySchema.optional().describe("Error message translation")
|
|
727
|
-
});
|
|
728
|
-
var BASE_QUESTION_TRANSLATION_KEYS = [
|
|
729
|
-
"type",
|
|
730
|
-
"title",
|
|
731
|
-
"description",
|
|
732
|
-
"descriptionMarkdown",
|
|
733
|
-
"errorMessage"
|
|
734
|
-
];
|
|
735
|
-
var ratingQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
736
|
-
type: z4.literal("rating").describe("Question type identifier"),
|
|
737
|
-
minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
|
|
738
|
-
maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
|
|
739
|
-
}).describe("Translation schema for rating questions");
|
|
740
|
-
var singleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
741
|
-
type: z4.literal("single_choice").describe("Question type identifier"),
|
|
742
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
743
|
-
}).catchall(translationEntrySchema).refine(
|
|
744
|
-
(data) => {
|
|
745
|
-
const additionalKeys = Object.keys(data).filter(
|
|
746
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
747
|
-
);
|
|
748
|
-
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
749
|
-
},
|
|
750
|
-
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
751
|
-
).describe("Translation schema for single choice questions");
|
|
752
|
-
var multipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
753
|
-
type: z4.literal("multiple_choice_multiple").describe("Question type identifier"),
|
|
754
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
755
|
-
}).catchall(translationEntrySchema).refine(
|
|
756
|
-
(data) => {
|
|
757
|
-
const additionalKeys = Object.keys(data).filter(
|
|
758
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
759
|
-
);
|
|
760
|
-
return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
|
|
761
|
-
},
|
|
762
|
-
{ message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
|
|
763
|
-
).describe("Translation schema for multiple choice questions");
|
|
764
|
-
var npsQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
765
|
-
type: z4.literal("nps").describe("Question type identifier"),
|
|
766
|
-
minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
|
|
767
|
-
maxLabel: translationEntrySchema.optional().describe("Maximum NPS label (10) translation")
|
|
768
|
-
}).catchall(translationEntrySchema).refine(
|
|
769
|
-
(data) => {
|
|
770
|
-
const additionalKeys = Object.keys(data).filter(
|
|
771
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(key)
|
|
772
|
-
);
|
|
773
|
-
return additionalKeys.every((key) => /^scaleLabel\.\d+$/.test(key));
|
|
774
|
-
},
|
|
775
|
-
{ message: "Additional keys must follow the pattern 'scaleLabel.{number}'" }
|
|
776
|
-
).describe("Translation schema for NPS questions");
|
|
777
|
-
var shortAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
778
|
-
type: z4.literal("short_answer").describe("Question type identifier"),
|
|
779
|
-
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
780
|
-
}).describe("Translation schema for short answer questions");
|
|
781
|
-
var longAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
782
|
-
type: z4.literal("long_text").describe("Question type identifier"),
|
|
783
|
-
placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
|
|
784
|
-
}).describe("Translation schema for long answer questions");
|
|
785
|
-
var nestedSelectionQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
786
|
-
type: z4.literal("nested_selection").describe("Question type identifier"),
|
|
787
|
-
placeholder: translationEntrySchema.optional().describe("Dropdown placeholder translation")
|
|
788
|
-
}).catchall(translationEntrySchema).refine(
|
|
789
|
-
(data) => {
|
|
790
|
-
const additionalKeys = Object.keys(data).filter(
|
|
791
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
|
|
792
|
-
);
|
|
793
|
-
return additionalKeys.every((key) => /^nestedOption\..+\.(label|hint)$/.test(key));
|
|
794
|
-
},
|
|
795
|
-
{ message: "Additional keys must follow the pattern 'nestedOption.{id}.{label|hint}'" }
|
|
796
|
-
).describe("Translation schema for nested selection questions");
|
|
797
|
-
var annotationQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
798
|
-
type: z4.literal("annotation").describe("Question type identifier"),
|
|
799
|
-
annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
|
|
800
|
-
noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
|
|
801
|
-
}).describe("Translation schema for annotation questions");
|
|
802
|
-
var welcomeQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
803
|
-
type: z4.literal("welcome").describe("Question type identifier"),
|
|
804
|
-
buttonLabel: translationEntrySchema.optional().describe("Translated proceed/start button label")
|
|
805
|
-
}).describe("Translation schema for welcome screen questions");
|
|
806
|
-
var thankYouQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
807
|
-
type: z4.literal("thank_you").describe("Question type identifier"),
|
|
808
|
-
buttonLabel: translationEntrySchema.optional().describe(
|
|
809
|
-
"Translated dismiss/done button label"
|
|
810
|
-
)
|
|
811
|
-
}).describe("Translation schema for thank you screen questions");
|
|
812
|
-
var messagePanelQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
813
|
-
type: z4.literal("message_panel").describe("Question type identifier"),
|
|
814
|
-
buttonLabel: translationEntrySchema.optional().describe(
|
|
815
|
-
"Translated continue/button label"
|
|
816
|
-
)
|
|
817
|
-
}).describe("Translation schema for message panel questions");
|
|
818
|
-
var yesNoQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
819
|
-
type: z4.literal("yes_no").describe("Question type identifier"),
|
|
820
|
-
yesLabel: translationEntrySchema.optional().describe("Translated Yes label"),
|
|
821
|
-
noLabel: translationEntrySchema.optional().describe("Translated No label")
|
|
822
|
-
}).describe("Translation schema for yes/no questions");
|
|
823
|
-
var ratingMatrixQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
824
|
-
type: z4.literal("rating_matrix").describe("Question type identifier"),
|
|
825
|
-
minLabel: translationEntrySchema.optional().describe(
|
|
826
|
-
"Translated scale minimum end label (for likert and numerical kinds)"
|
|
827
|
-
),
|
|
828
|
-
maxLabel: translationEntrySchema.optional().describe(
|
|
829
|
-
"Translated scale maximum end label (for likert and numerical kinds)"
|
|
830
|
-
)
|
|
831
|
-
}).catchall(translationEntrySchema).refine(
|
|
832
|
-
(data) => {
|
|
833
|
-
const additionalKeys = Object.keys(data).filter(
|
|
834
|
-
(key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(
|
|
835
|
-
key
|
|
836
|
-
)
|
|
837
|
-
);
|
|
838
|
-
return additionalKeys.every(
|
|
839
|
-
(key) => /^statement\..+\.label$/.test(key) || /^scalePoint\..+\.label$/.test(key)
|
|
840
|
-
);
|
|
719
|
+
}
|
|
720
|
+
).describe("Schema for Net Promoter Score questions with 0-10 scale");
|
|
721
|
+
var shortAnswerQuestionSchema = questionSchema.extend({
|
|
722
|
+
type: z2.literal("short_answer").describe("Must be exactly 'short_answer'"),
|
|
723
|
+
maxCharacters: z2.number().int().min(1).max(1e4).optional().describe("Maximum number of characters allowed"),
|
|
724
|
+
minCharacters: z2.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
725
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text shown in the input field"),
|
|
726
|
+
enableRegexValidation: z2.boolean().optional().default(false).describe("Whether to enable regex pattern validation"),
|
|
727
|
+
regexPattern: z2.string().optional().describe("Regular expression pattern for validation"),
|
|
728
|
+
enableEnhanceWithAi: z2.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
729
|
+
promptTemplate: z2.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
730
|
+
maxTokenAllowed: z2.number().int().min(1).max(1e4).optional().describe("Maximum tokens allowed for AI processing"),
|
|
731
|
+
minCharactersToEnhance: z2.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
732
|
+
}).refine(
|
|
733
|
+
(data) => {
|
|
734
|
+
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
735
|
+
return data.minCharacters <= data.maxCharacters;
|
|
736
|
+
}
|
|
737
|
+
return true;
|
|
841
738
|
},
|
|
842
739
|
{
|
|
843
|
-
message: "
|
|
740
|
+
message: "minCharacters cannot be greater than maxCharacters",
|
|
741
|
+
path: ["minCharacters"]
|
|
844
742
|
}
|
|
845
|
-
).
|
|
846
|
-
var matrixSingleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
847
|
-
type: z4.literal("matrix_single_choice").describe("Question type identifier")
|
|
848
|
-
}).catchall(translationEntrySchema).refine(
|
|
743
|
+
).refine(
|
|
849
744
|
(data) => {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
return
|
|
854
|
-
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
855
|
-
);
|
|
745
|
+
if (data.enableRegexValidation && !data.regexPattern) {
|
|
746
|
+
return false;
|
|
747
|
+
}
|
|
748
|
+
return true;
|
|
856
749
|
},
|
|
857
750
|
{
|
|
858
|
-
message: "
|
|
751
|
+
message: "regexPattern is required when enableRegexValidation is true",
|
|
752
|
+
path: ["regexPattern"]
|
|
859
753
|
}
|
|
860
|
-
).
|
|
861
|
-
var matrixMultipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
|
|
862
|
-
type: z4.literal("matrix_multiple_choice").describe("Question type identifier")
|
|
863
|
-
}).catchall(translationEntrySchema).refine(
|
|
754
|
+
).refine(
|
|
864
755
|
(data) => {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
return
|
|
869
|
-
(key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
|
|
870
|
-
);
|
|
756
|
+
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
757
|
+
return false;
|
|
758
|
+
}
|
|
759
|
+
return true;
|
|
871
760
|
},
|
|
872
761
|
{
|
|
873
|
-
message: "
|
|
874
|
-
|
|
875
|
-
).describe("Translation schema for matrix multiple-choice questions");
|
|
876
|
-
var questionTranslationSchema = z4.union([
|
|
877
|
-
ratingQuestionTranslationSchema,
|
|
878
|
-
singleChoiceQuestionTranslationSchema,
|
|
879
|
-
multipleChoiceQuestionTranslationSchema,
|
|
880
|
-
npsQuestionTranslationSchema,
|
|
881
|
-
shortAnswerQuestionTranslationSchema,
|
|
882
|
-
longAnswerQuestionTranslationSchema,
|
|
883
|
-
nestedSelectionQuestionTranslationSchema,
|
|
884
|
-
annotationQuestionTranslationSchema,
|
|
885
|
-
welcomeQuestionTranslationSchema,
|
|
886
|
-
thankYouQuestionTranslationSchema,
|
|
887
|
-
messagePanelQuestionTranslationSchema,
|
|
888
|
-
yesNoQuestionTranslationSchema,
|
|
889
|
-
ratingMatrixQuestionTranslationSchema,
|
|
890
|
-
matrixSingleChoiceQuestionTranslationSchema,
|
|
891
|
-
matrixMultipleChoiceQuestionTranslationSchema
|
|
892
|
-
]).describe("Union of all question type translation schemas");
|
|
893
|
-
var languageCodeSchema = z4.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
|
|
894
|
-
var questionTranslationsByLanguageSchema = z4.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
|
|
895
|
-
var questionCentricTranslationsSchema = z4.record(z4.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
|
|
896
|
-
var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
|
|
897
|
-
var _TranslationProvider = class _TranslationProvider {
|
|
898
|
-
constructor(translations, defaultLanguage = "en") {
|
|
899
|
-
this.translations = translations;
|
|
900
|
-
this.defaultLanguage = defaultLanguage;
|
|
762
|
+
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
763
|
+
path: ["promptTemplate"]
|
|
901
764
|
}
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
765
|
+
).describe("Schema for short answer questions with optional AI enhancement");
|
|
766
|
+
var longAnswerQuestionSchema = questionSchema.extend({
|
|
767
|
+
type: z2.literal("long_text").describe("Must be exactly 'long_text'"),
|
|
768
|
+
maxCharacters: z2.number().int().min(1).max(5e4).optional().describe(
|
|
769
|
+
"Maximum number of characters allowed (higher limit for long text)"
|
|
770
|
+
),
|
|
771
|
+
minCharacters: z2.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
772
|
+
rows: z2.number().int().min(1).max(20).optional().describe("Number of textarea rows to display (1-20)"),
|
|
773
|
+
placeholder: z2.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
|
|
774
|
+
enableEnhanceWithAi: z2.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
775
|
+
promptTemplate: z2.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
776
|
+
maxTokenAllowed: z2.number().int().min(1).max(25e3).optional().describe(
|
|
777
|
+
"Maximum tokens allowed for AI processing (higher for long text)"
|
|
778
|
+
),
|
|
779
|
+
minCharactersToEnhance: z2.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
780
|
+
}).refine(
|
|
781
|
+
(data) => {
|
|
782
|
+
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
783
|
+
return data.minCharacters <= data.maxCharacters;
|
|
911
784
|
}
|
|
912
|
-
return
|
|
785
|
+
return true;
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
message: "minCharacters cannot be greater than maxCharacters",
|
|
789
|
+
path: ["minCharacters"]
|
|
913
790
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
const questionTranslation = this.getQuestionTranslations(questionId, languageCode);
|
|
919
|
-
if (!questionTranslation) return null;
|
|
920
|
-
if (fieldPath in questionTranslation) {
|
|
921
|
-
const value = questionTranslation[fieldPath];
|
|
922
|
-
return typeof value === "string" ? value : null;
|
|
791
|
+
).refine(
|
|
792
|
+
(data) => {
|
|
793
|
+
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
794
|
+
return false;
|
|
923
795
|
}
|
|
924
|
-
return
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
getQuestionLanguages(questionId) {
|
|
930
|
-
const questionTranslations = this.translations[questionId];
|
|
931
|
-
if (!questionTranslations) return [];
|
|
932
|
-
return Object.keys(questionTranslations);
|
|
933
|
-
}
|
|
934
|
-
/**
|
|
935
|
-
* Get all available languages across all questions
|
|
936
|
-
*/
|
|
937
|
-
getAvailableLanguages() {
|
|
938
|
-
const allLanguages = /* @__PURE__ */ new Set();
|
|
939
|
-
Object.values(this.translations).forEach((questionTranslations) => {
|
|
940
|
-
Object.keys(questionTranslations).forEach((langCode) => {
|
|
941
|
-
allLanguages.add(langCode);
|
|
942
|
-
});
|
|
943
|
-
});
|
|
944
|
-
return Array.from(allLanguages);
|
|
945
|
-
}
|
|
946
|
-
/**
|
|
947
|
-
* Check if a language is supported for a specific question
|
|
948
|
-
*/
|
|
949
|
-
isLanguageSupportedForQuestion(questionId, languageCode) {
|
|
950
|
-
const questionTranslations = this.translations[questionId];
|
|
951
|
-
if (!questionTranslations) return false;
|
|
952
|
-
return languageCode in questionTranslations;
|
|
953
|
-
}
|
|
954
|
-
/**
|
|
955
|
-
* Check if a language is supported across all questions
|
|
956
|
-
*/
|
|
957
|
-
isLanguageSupported(languageCode) {
|
|
958
|
-
return this.getAvailableLanguages().includes(languageCode);
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* Get the default language
|
|
962
|
-
*/
|
|
963
|
-
getDefaultLanguage() {
|
|
964
|
-
return this.defaultLanguage;
|
|
965
|
-
}
|
|
966
|
-
/**
|
|
967
|
-
* Get all questions that have translations
|
|
968
|
-
*/
|
|
969
|
-
getQuestionIds() {
|
|
970
|
-
return Object.keys(this.translations);
|
|
796
|
+
return true;
|
|
797
|
+
},
|
|
798
|
+
{
|
|
799
|
+
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
800
|
+
path: ["promptTemplate"]
|
|
971
801
|
}
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
802
|
+
).describe(
|
|
803
|
+
"Schema for long answer questions with rich text support and AI enhancement"
|
|
804
|
+
);
|
|
805
|
+
var nestedDropdownQuestionSchema = questionSchema.extend({
|
|
806
|
+
type: z2.literal("nested_selection").describe("Must be exactly 'nested_selection'"),
|
|
807
|
+
placeholder: z2.string().max(200).optional().describe("Placeholder text for the nested dropdown"),
|
|
808
|
+
options: z2.array(nestedOptionSchema).min(1).max(100).describe(
|
|
809
|
+
"Array of nested options for hierarchical selection (1-100 options)"
|
|
810
|
+
),
|
|
811
|
+
displayStyle: z2.literal("list").describe("Fixed display style for nested dropdowns"),
|
|
812
|
+
choiceOrderOption: choiceOrderOptionSchema.optional().default("none").describe("How to order the nested choices"),
|
|
813
|
+
preserveLastChoices: z2.number().int().min(0).max(10).optional().describe("Number of choice levels to preserve (0-10)"),
|
|
814
|
+
prepopulatedValue: z2.string().max(1e3).optional().describe("Default value to pre-populate"),
|
|
815
|
+
allowOther: z2.boolean().optional().default(false).describe('Whether to allow custom "other" options'),
|
|
816
|
+
otherColumnName: z2.string().max(100).optional().describe('Column name for storing custom "other" values'),
|
|
817
|
+
maxDepth: z2.number().int().min(1).max(10).optional().describe("Maximum nesting depth allowed (1-10)"),
|
|
818
|
+
cascadeLabels: z2.boolean().optional().default(false).describe("Whether to cascade labels from parent options")
|
|
819
|
+
}).refine(
|
|
820
|
+
(data) => {
|
|
821
|
+
if (data.allowOther && !data.otherColumnName) {
|
|
822
|
+
return false;
|
|
823
|
+
}
|
|
824
|
+
return true;
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
message: "otherColumnName is required when allowOther is true",
|
|
828
|
+
path: ["otherColumnName"]
|
|
979
829
|
}
|
|
830
|
+
).describe(
|
|
831
|
+
"Schema for nested dropdown questions with hierarchical option structure"
|
|
832
|
+
);
|
|
833
|
+
var combinedQuestionSchema = z2.discriminatedUnion("type", [
|
|
834
|
+
ratingQuestionSchema,
|
|
835
|
+
annotationQuestionSchema,
|
|
836
|
+
welcomeQuestionSchema,
|
|
837
|
+
thankYouQuestionSchema,
|
|
838
|
+
messagePanelQuestionSchema,
|
|
839
|
+
exitFormQuestionSchema,
|
|
840
|
+
yesNoQuestionSchema,
|
|
841
|
+
ratingMatrixQuestionSchema,
|
|
842
|
+
matrixSingleChoiceQuestionSchema,
|
|
843
|
+
matrixMultipleChoiceQuestionSchema,
|
|
844
|
+
multipleChoiceSingleQuestionSchema,
|
|
845
|
+
multipleChoiceMultipleQuestionSchema,
|
|
846
|
+
npsQuestionSchema,
|
|
847
|
+
shortAnswerQuestionSchema,
|
|
848
|
+
longAnswerQuestionSchema,
|
|
849
|
+
nestedDropdownQuestionSchema
|
|
850
|
+
]);
|
|
851
|
+
|
|
852
|
+
// src/schemas/fields/answer-schema.ts
|
|
853
|
+
import { z as z3 } from "zod";
|
|
854
|
+
var AnnotationMarkerSchema = z3.object({
|
|
855
|
+
markerNo: z3.string(),
|
|
856
|
+
timeline: z3.string(),
|
|
857
|
+
comment: z3.string()
|
|
858
|
+
});
|
|
859
|
+
var AnnotationSchema = z3.object({
|
|
860
|
+
fileType: z3.string(),
|
|
861
|
+
fileName: z3.string(),
|
|
862
|
+
markers: z3.array(AnnotationMarkerSchema)
|
|
863
|
+
});
|
|
864
|
+
var AnswerItemSchema = z3.object({
|
|
865
|
+
nps: z3.number().optional().describe("Net Promoter Score value (e.g., 0-10)"),
|
|
866
|
+
nestedSelection: z3.array(z3.string()).optional().describe("Array of selected nested option IDs"),
|
|
867
|
+
longText: z3.string().optional().describe("Long text answer, e.g., paragraph or essay"),
|
|
868
|
+
shortAnswer: z3.string().optional().describe("Short text answer, e.g., single sentence or word"),
|
|
869
|
+
singleChoice: z3.string().optional().describe(
|
|
870
|
+
"single selected option ID (for single choice questions)"
|
|
871
|
+
),
|
|
872
|
+
rating: z3.number().optional().describe("Star rating value (e.g., 1-5)"),
|
|
873
|
+
yesNo: z3.boolean().optional().describe("Yes/no answer for yes_no questions (true = Yes, false = No)"),
|
|
874
|
+
multipleChoiceMultiple: z3.array(z3.string()).optional().describe("Array of selected option IDs for multiple choice questions"),
|
|
875
|
+
singleChoiceOther: z3.string().optional().describe(
|
|
876
|
+
'Free-text "other" answer for single choice questions when allowOther is enabled'
|
|
877
|
+
),
|
|
878
|
+
multipleChoiceOther: z3.string().optional().describe(
|
|
879
|
+
'Free-text "other" answer for multiple choice questions when allowOther is enabled'
|
|
880
|
+
),
|
|
881
|
+
annotation: AnnotationSchema.optional().describe(
|
|
882
|
+
"Annotation object containing file and marker details"
|
|
883
|
+
),
|
|
884
|
+
ratingMatrix: z3.record(z3.string(), z3.union([z3.number(), z3.string()])).optional().describe(
|
|
885
|
+
"Rating matrix answers keyed by statement value (export key), value is the selected scale value (number for likert/numerical, string for custom)"
|
|
886
|
+
),
|
|
887
|
+
matrixSingleChoice: z3.record(z3.string(), z3.string()).optional().describe(
|
|
888
|
+
"Matrix single-choice answers keyed by row value (export key), map value is the selected column option value"
|
|
889
|
+
),
|
|
890
|
+
matrixMultipleChoice: z3.record(z3.string(), z3.array(z3.string())).optional().describe(
|
|
891
|
+
"Matrix multiple-choice answers keyed by row value (export key), map value is array of selected column option values"
|
|
892
|
+
),
|
|
893
|
+
others: z3.string().optional().describe(
|
|
894
|
+
"For multiple choice questions and single choice questions, this is the value of the other option"
|
|
895
|
+
)
|
|
896
|
+
}).describe(
|
|
897
|
+
"Flexible answer item supporting various question types and custom fields"
|
|
898
|
+
);
|
|
899
|
+
var AnswerSchema = AnswerItemSchema;
|
|
900
|
+
|
|
901
|
+
// src/schemas/fields/form-schema.ts
|
|
902
|
+
import { z as z4 } from "zod";
|
|
903
|
+
var externalPublishingPropertiesSchema = z4.object({
|
|
904
|
+
isShareable: z4.boolean().describe("Whether the feedback results can be shared externally"),
|
|
905
|
+
isEmailShareable: z4.boolean().describe("Whether the feedback can be shared via email")
|
|
906
|
+
}).describe("Schema defining external publishing and sharing properties for feedback");
|
|
907
|
+
var publicationStatusSchema = z4.enum(["P", "D", "A", "S"]).describe("Publication status: P=Published, D=Draft, A=Archived, S=Stopped");
|
|
908
|
+
var PublicationStatuses = {
|
|
909
|
+
PUBLISHED: "P",
|
|
910
|
+
DRAFT: "D",
|
|
911
|
+
ARCHIVED: "A",
|
|
912
|
+
STOPPED: "S"
|
|
980
913
|
};
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
|
|
914
|
+
var feedbackConfigurationSchema = z4.object({
|
|
915
|
+
formTitle: z4.string().describe("Title of the feedback form"),
|
|
916
|
+
formDescription: z4.string().describe("Description of the feedback form"),
|
|
917
|
+
isPublished: publicationStatusSchema.describe("Publication status of the feedback form")
|
|
918
|
+
}).describe("Schema defining feedback configuration properties");
|
|
919
|
+
|
|
920
|
+
// src/schemas/fields/form-properties-schema.ts
|
|
921
|
+
import { z as z8 } from "zod";
|
|
987
922
|
|
|
988
923
|
// src/schemas/fields/other-screen-schema.ts
|
|
989
924
|
import { z as z5 } from "zod";
|
|
990
|
-
var dismissBehaviorSchema = z5.enum(["fade", "manual"]).describe("How the end screen should be dismissed (fade out or manual dismissal)");
|
|
991
|
-
var DismissBehaviors = {
|
|
992
|
-
FADE: "fade",
|
|
993
|
-
MANUAL: "manual"
|
|
994
|
-
};
|
|
995
|
-
var WelcomeScreenFieldsSchema = z5.object({
|
|
996
|
-
title: z5.string().min(1).max(200).describe("The main title displayed on the welcome screen"),
|
|
997
|
-
description: z5.string().min(1).max(1e3).describe("Description text shown on the welcome screen"),
|
|
998
|
-
buttonLabel: z5.string().min(1).max(50).describe("Text displayed on the welcome screen button")
|
|
999
|
-
}).describe("Schema for welcome screen configuration fields");
|
|
1000
|
-
var EndScreenFieldsSchema = z5.object({
|
|
1001
|
-
title: z5.string().min(1).max(200).describe("The main title displayed on the end screen"),
|
|
1002
|
-
message: z5.string().min(1).max(1e3).describe("Message text shown on the end screen"),
|
|
1003
|
-
buttonLabel: z5.string().min(1).max(50).describe("Text displayed on the end screen button"),
|
|
1004
|
-
dismissBehavior: dismissBehaviorSchema.describe("How the end screen should be dismissed (fade out or manual dismissal)"),
|
|
1005
|
-
fadeDuration: z5.number().int().min(0).max(1e4).describe("Duration in milliseconds for fade dismissal (0-10000)")
|
|
1006
|
-
}).describe("Schema for end screen configuration fields");
|
|
1007
|
-
var WelcomeFieldsTranslationSchema = z5.object({
|
|
1008
|
-
title: z5.string().min(1).max(200).describe("Translated title text for welcome screen"),
|
|
1009
|
-
description: z5.string().min(1).max(1e3).describe("Translated description text for welcome screen"),
|
|
1010
|
-
buttonLabel: z5.string().min(1).max(50).describe("Translated text for the welcome button label")
|
|
1011
|
-
}).describe("Schema for welcome screen translation fields");
|
|
1012
|
-
var EndFieldsTranslationSchema = z5.object({
|
|
1013
|
-
buttonLabel: z5.string().min(1).max(50).describe("Translated text for the end button label"),
|
|
1014
|
-
title: z5.string().min(1).max(200).describe("Translated title text for end screen"),
|
|
1015
|
-
message: z5.string().min(1).max(1e3).describe("Translated message text for end screen")
|
|
1016
|
-
}).describe("Schema for end screen translation fields");
|
|
1017
925
|
var OtherFieldsSchema = z5.object({
|
|
1018
926
|
pagination: z5.boolean().describe("Whether to show pagination for multi-page forms"),
|
|
1019
927
|
questionNumber: z5.boolean().describe("Whether to display question numbers"),
|
|
@@ -1028,9 +936,8 @@ var OtherFieldsSchema = z5.object({
|
|
|
1028
936
|
}).describe("Schema for other form configuration fields");
|
|
1029
937
|
var LanguageFieldSchema = z5.object({
|
|
1030
938
|
value: z5.string().min(1).max(10).describe("Language code (e.g., 'en', 'es', 'fr')"),
|
|
1031
|
-
label: z5.string().min(1).max(50).describe("Display name for the language (e.g., 'English', 'Spanish', 'French')")
|
|
1032
|
-
|
|
1033
|
-
}).describe("Schema for individual language field with value, label, and fixed status");
|
|
939
|
+
label: z5.string().min(1).max(50).describe("Display name for the language (e.g., 'English', 'Spanish', 'French')")
|
|
940
|
+
}).describe("Schema for individual language field with value and label");
|
|
1034
941
|
var LanguagesSchema = z5.array(LanguageFieldSchema).describe("Schema for array of available languages");
|
|
1035
942
|
var OtherFieldsTranslationSchema = z5.object({
|
|
1036
943
|
submitButtonLabel: z5.string().min(1).max(50).describe("Translated text for the submit button"),
|
|
@@ -1085,12 +992,10 @@ var featureSettingsSchema = z6.object({
|
|
|
1085
992
|
progressBar: z6.boolean().describe("Whether to show a progress bar indicating completion status"),
|
|
1086
993
|
showBranding: z6.boolean().describe("Whether to display branding elements on the widget"),
|
|
1087
994
|
customPosition: z6.boolean().describe("Whether custom positioning is enabled"),
|
|
1088
|
-
customIconPosition: z6.boolean().describe("Whether custom icon positioning is enabled"),
|
|
1089
995
|
customCss: z6.string().optional().describe("Custom CSS link to apply for the feedback form"),
|
|
1090
996
|
shareableMode: shareableModeSchema.optional().describe(
|
|
1091
997
|
"Display mode for the shareable: light, dark, or system preference"
|
|
1092
998
|
),
|
|
1093
|
-
allowMultipleQuestionsPerSection: z6.boolean().describe("Whether to allow multiple questions per section"),
|
|
1094
999
|
rtl: z6.boolean().describe("Whether right-to-left text direction is enabled"),
|
|
1095
1000
|
previousButton: previousButtonModeSchema.describe("Previous button visibility mode: never, always, or auto")
|
|
1096
1001
|
}).describe("Feature settings controlling widget UI behavior and appearance");
|
|
@@ -1206,34 +1111,6 @@ var otherConfigurationPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
|
1206
1111
|
translations: z8.record(z8.string(), OtherFieldsTranslationSchema).describe("Translations for other configuration field labels and buttons keyed by language code")
|
|
1207
1112
|
})
|
|
1208
1113
|
]).describe("Schema for other configuration properties including fields and translations");
|
|
1209
|
-
var welcomeScreenPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
1210
|
-
// When welcome screen is disabled
|
|
1211
|
-
z8.object({
|
|
1212
|
-
isEnabled: z8.literal(false).describe("Whether welcome screen is enabled"),
|
|
1213
|
-
welcomeFields: WelcomeScreenFieldsSchema.optional().describe("Welcome screen configuration fields including title, description, and button label"),
|
|
1214
|
-
translations: z8.record(z8.string(), WelcomeFieldsTranslationSchema).optional().describe("Translations for welcome screen content keyed by language code")
|
|
1215
|
-
}),
|
|
1216
|
-
// When welcome screen is enabled
|
|
1217
|
-
z8.object({
|
|
1218
|
-
isEnabled: z8.literal(true).describe("Whether welcome screen is enabled"),
|
|
1219
|
-
welcomeFields: WelcomeScreenFieldsSchema.describe("Welcome screen configuration fields including title, description, and button label"),
|
|
1220
|
-
translations: z8.record(z8.string(), WelcomeFieldsTranslationSchema).describe("Translations for welcome screen content keyed by language code")
|
|
1221
|
-
})
|
|
1222
|
-
]).describe("Schema for welcome screen properties including fields and translations");
|
|
1223
|
-
var endScreenPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
1224
|
-
// When end screen is disabled
|
|
1225
|
-
z8.object({
|
|
1226
|
-
isEnabled: z8.literal(false).describe("Whether end screen is enabled"),
|
|
1227
|
-
endFields: EndScreenFieldsSchema.optional().describe("End screen configuration fields including title, message, button label, and dismissal behavior"),
|
|
1228
|
-
translations: z8.record(z8.string(), EndFieldsTranslationSchema).optional().describe("Translations for end screen content keyed by language code")
|
|
1229
|
-
}),
|
|
1230
|
-
// When end screen is enabled
|
|
1231
|
-
z8.object({
|
|
1232
|
-
isEnabled: z8.literal(true).describe("Whether end screen is enabled"),
|
|
1233
|
-
endFields: EndScreenFieldsSchema.describe("End screen configuration fields including title, message, button label, and dismissal behavior"),
|
|
1234
|
-
translations: z8.record(z8.string(), EndFieldsTranslationSchema).describe("Translations for end screen content keyed by language code")
|
|
1235
|
-
})
|
|
1236
|
-
]).describe("Schema for end screen properties including fields and translations");
|
|
1237
1114
|
var appearancePropertiesSchema = z8.object({
|
|
1238
1115
|
themeConfiguration: themeConfigurationSchema.describe("Theme configuration including colors, features, and positioning")
|
|
1239
1116
|
}).describe("Schema for appearance properties including theme configuration");
|
|
@@ -1246,14 +1123,11 @@ var formPropertiesSchema = z8.object({
|
|
|
1246
1123
|
selectedLanguages: LanguagesSchema.describe("Array of languages selected for this questionnaire"),
|
|
1247
1124
|
translations: translationsSchema.describe("Multi-language translations for questions and form content")
|
|
1248
1125
|
}).describe("Fields defining the questionnaire structure, questions, sections, selected languages, and translations"),
|
|
1249
|
-
frequencyAndSchedulingProperties: frequencyAndSchedulingPropertiesSchema.describe("Properties controlling when and how often the feedback is shown"),
|
|
1250
1126
|
externalPublishingProperties: externalPublishingPropertiesSchema.describe("Properties controlling external sharing and publishing of feedback results"),
|
|
1251
1127
|
audienceTriggerProperties: audienceTriggerPropertiesSchema.describe("Properties defining audience targeting and trigger conditions for the feedback form"),
|
|
1252
1128
|
otherConfigurationProperties: otherConfigurationPropertiesSchema.describe("Additional configuration properties including form display options and translations"),
|
|
1253
|
-
welcomeScreenProperties: welcomeScreenPropertiesSchema.describe("Welcome screen configuration including content and translations"),
|
|
1254
|
-
endScreenProperties: endScreenPropertiesSchema.describe("End screen configuration including content, dismissal behavior, and translations"),
|
|
1255
1129
|
appearanceProperties: appearancePropertiesSchema.describe("Appearance configuration including themes, colors, and UI feature settings")
|
|
1256
|
-
}).describe("Complete schema for all feedback-level properties including
|
|
1130
|
+
}).describe("Complete schema for all feedback-level properties including publishing, audience targeting, configuration, and appearance");
|
|
1257
1131
|
|
|
1258
1132
|
// src/schemas/fields/other-properties-schema.ts
|
|
1259
1133
|
import { z as z9 } from "zod";
|
|
@@ -1382,14 +1256,12 @@ var feedbackConfigurationItemSchema = z12.object({
|
|
|
1382
1256
|
customPosition: z12.boolean().describe("Whether custom position is enabled"),
|
|
1383
1257
|
customIconPosition: z12.boolean().describe("Whether custom icon position is enabled"),
|
|
1384
1258
|
customCss: z12.string().nullable().optional().describe("Custom CSS link (optional)"),
|
|
1385
|
-
allowMultipleQuestionsPerSection: z12.boolean().describe("Whether to allow multiple questions per section"),
|
|
1386
1259
|
rtl: z12.boolean().describe("Whether right-to-left text direction is enabled"),
|
|
1387
1260
|
previousButton: z12.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto")
|
|
1388
1261
|
}).describe("Feature settings for the feedback form"),
|
|
1389
1262
|
selectedIconPosition: z12.string().describe("Selected position for the feedback icon"),
|
|
1390
1263
|
selectedPosition: z12.string().describe("Selected position for the feedback form")
|
|
1391
|
-
}).describe("Appearance properties for the feedback form")
|
|
1392
|
-
frequencyAndScheduling: frequencyAndSchedulingPropertiesSchema.optional().describe("Frequency and scheduling properties for the feedback (optional)")
|
|
1264
|
+
}).describe("Appearance properties for the feedback form")
|
|
1393
1265
|
}).describe("Individual feedback configuration item in the list");
|
|
1394
1266
|
var fetchFormConfigSchema = z12.object({
|
|
1395
1267
|
feedbackConfigurationId: z12.string().uuid().describe("Unique identifier for the feedback configuration"),
|
|
@@ -1439,12 +1311,6 @@ var fetchFeedbackDetailsResponseSchema = z12.object({
|
|
|
1439
1311
|
otherConfigurationProperties: otherConfigurationPropertiesSchema.describe(
|
|
1440
1312
|
"Other configuration properties using existing schema"
|
|
1441
1313
|
),
|
|
1442
|
-
welcomeScreenProperties: welcomeScreenPropertiesSchema.describe(
|
|
1443
|
-
"Welcome screen properties using existing schema"
|
|
1444
|
-
),
|
|
1445
|
-
endScreenProperties: endScreenPropertiesSchema.describe(
|
|
1446
|
-
"End screen properties using existing schema"
|
|
1447
|
-
),
|
|
1448
1314
|
appearanceProperties: appearancePropertiesSchema.describe(
|
|
1449
1315
|
"Appearance properties including theme configuration"
|
|
1450
1316
|
)
|
|
@@ -1563,8 +1429,6 @@ var appPropsSchema = z14.object({
|
|
|
1563
1429
|
otherConfigurationProperties: otherConfigurationPropertiesSchema.describe(
|
|
1564
1430
|
"Other configuration properties including form display options and translations"
|
|
1565
1431
|
),
|
|
1566
|
-
welcomeScreenProperties: welcomeScreenPropertiesSchema.optional().describe("Welcome screen configuration (optional)"),
|
|
1567
|
-
endScreenProperties: endScreenPropertiesSchema.optional().describe("End screen configuration (optional)"),
|
|
1568
1432
|
translations: translationsSchema.optional().describe(
|
|
1569
1433
|
"Multi-language translations for questions and form content (optional)"
|
|
1570
1434
|
),
|
|
@@ -1596,9 +1460,6 @@ export {
|
|
|
1596
1460
|
ChoiceOrderOptions,
|
|
1597
1461
|
CurrentModes,
|
|
1598
1462
|
DeviceThemes,
|
|
1599
|
-
DismissBehaviors,
|
|
1600
|
-
EndFieldsTranslationSchema,
|
|
1601
|
-
EndScreenFieldsSchema,
|
|
1602
1463
|
LanguageFieldSchema,
|
|
1603
1464
|
LanguagesSchema,
|
|
1604
1465
|
MultipleChoiceDisplayStyles,
|
|
@@ -1612,17 +1473,12 @@ export {
|
|
|
1612
1473
|
RatingDisplayStyles,
|
|
1613
1474
|
RatingMatrixDisplayStyles,
|
|
1614
1475
|
RatingRepresentationSizes,
|
|
1615
|
-
RecurringUnits,
|
|
1616
1476
|
ShareableModes,
|
|
1617
|
-
SurveyTypes,
|
|
1618
1477
|
ThemeModes,
|
|
1619
1478
|
TranslationProvider,
|
|
1620
1479
|
ValidationRuleTypes,
|
|
1621
1480
|
VisibilityConditionOperators,
|
|
1622
|
-
WelcomeFieldsTranslationSchema,
|
|
1623
|
-
WelcomeScreenFieldsSchema,
|
|
1624
1481
|
YesNoDisplayStyles,
|
|
1625
|
-
YesNoValues,
|
|
1626
1482
|
annotationQuestionSchema,
|
|
1627
1483
|
annotationQuestionTranslationSchema,
|
|
1628
1484
|
appPropsSchema,
|
|
@@ -1643,8 +1499,7 @@ export {
|
|
|
1643
1499
|
deviceInfoSchema,
|
|
1644
1500
|
deviceSessionInfoSchema,
|
|
1645
1501
|
deviceThemeSchema,
|
|
1646
|
-
|
|
1647
|
-
endScreenPropertiesSchema,
|
|
1502
|
+
exitFormQuestionSchema,
|
|
1648
1503
|
externalPublishingPropertiesSchema,
|
|
1649
1504
|
featureSettingsSchema,
|
|
1650
1505
|
feedbackConfigurationItemSchema,
|
|
@@ -1659,7 +1514,6 @@ export {
|
|
|
1659
1514
|
formConfigSchema,
|
|
1660
1515
|
formConfigurationResponseSchema,
|
|
1661
1516
|
formPropertiesSchema,
|
|
1662
|
-
frequencyAndSchedulingPropertiesSchema,
|
|
1663
1517
|
longAnswerQuestionSchema,
|
|
1664
1518
|
longAnswerQuestionTranslationSchema,
|
|
1665
1519
|
masterPropertiesSchema,
|
|
@@ -1708,7 +1562,6 @@ export {
|
|
|
1708
1562
|
ratingQuestionSchema,
|
|
1709
1563
|
ratingQuestionTranslationSchema,
|
|
1710
1564
|
ratingRepresentationSizeSchema,
|
|
1711
|
-
recurringUnitSchema,
|
|
1712
1565
|
refineTextDataSchema,
|
|
1713
1566
|
refineTextParamsSchema,
|
|
1714
1567
|
refineTextResponseSchema,
|
|
@@ -1720,7 +1573,6 @@ export {
|
|
|
1720
1573
|
shortAnswerQuestionTranslationSchema,
|
|
1721
1574
|
singleChoiceQuestionTranslationSchema,
|
|
1722
1575
|
submitFeedbackSchema,
|
|
1723
|
-
surveyTypeSchema,
|
|
1724
1576
|
thankYouQuestionSchema,
|
|
1725
1577
|
thankYouQuestionTranslationSchema,
|
|
1726
1578
|
themeColorsSchema,
|
|
@@ -1740,12 +1592,10 @@ export {
|
|
|
1740
1592
|
visibilityConditionSchema,
|
|
1741
1593
|
welcomeQuestionSchema,
|
|
1742
1594
|
welcomeQuestionTranslationSchema,
|
|
1743
|
-
welcomeScreenPropertiesSchema,
|
|
1744
1595
|
whoSchema,
|
|
1745
1596
|
yesNoDisplayStyleSchema,
|
|
1746
1597
|
yesNoQuestionSchema,
|
|
1747
1598
|
yesNoQuestionTranslationSchema,
|
|
1748
|
-
yesNoSchema,
|
|
1749
1599
|
z15 as z
|
|
1750
1600
|
};
|
|
1751
1601
|
//# sourceMappingURL=index.js.map
|