@encatch/schema 0.0.1 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/esm/index.js +891 -12
- package/dist/esm/index.js.map +7 -1
- package/package.json +43 -7
- package/dist/cjs/index.js +0 -30
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/schemas/fields/answer-schema.js +0 -103
- package/dist/cjs/schemas/fields/answer-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/auto-trigger-schema.js +0 -49
- package/dist/cjs/schemas/fields/auto-trigger-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/field-schema.js +0 -678
- package/dist/cjs/schemas/fields/field-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/form-properties-schema.js +0 -136
- package/dist/cjs/schemas/fields/form-properties-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/form-schema.js +0 -123
- package/dist/cjs/schemas/fields/form-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/other-screen-schema.js +0 -169
- package/dist/cjs/schemas/fields/other-screen-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/theme-schema.js +0 -85
- package/dist/cjs/schemas/fields/theme-schema.js.map +0 -1
- package/dist/cjs/schemas/fields/translations-example.js +0 -187
- package/dist/cjs/schemas/fields/translations-example.js.map +0 -1
- package/dist/cjs/schemas/fields/translations-schema.js +0 -198
- package/dist/cjs/schemas/fields/translations-schema.js.map +0 -1
- package/dist/esm/schemas/fields/answer-schema.js +0 -100
- package/dist/esm/schemas/fields/answer-schema.js.map +0 -1
- package/dist/esm/schemas/fields/auto-trigger-schema.js +0 -46
- package/dist/esm/schemas/fields/auto-trigger-schema.js.map +0 -1
- package/dist/esm/schemas/fields/field-schema.js +0 -675
- package/dist/esm/schemas/fields/field-schema.js.map +0 -1
- package/dist/esm/schemas/fields/form-properties-schema.js +0 -133
- package/dist/esm/schemas/fields/form-properties-schema.js.map +0 -1
- package/dist/esm/schemas/fields/form-schema.js +0 -120
- package/dist/esm/schemas/fields/form-schema.js.map +0 -1
- package/dist/esm/schemas/fields/other-screen-schema.js +0 -166
- package/dist/esm/schemas/fields/other-screen-schema.js.map +0 -1
- package/dist/esm/schemas/fields/theme-schema.js +0 -82
- package/dist/esm/schemas/fields/theme-schema.js.map +0 -1
- package/dist/esm/schemas/fields/translations-example.js +0 -181
- package/dist/esm/schemas/fields/translations-example.js.map +0 -1
- package/dist/esm/schemas/fields/translations-schema.js +0 -193
- package/dist/esm/schemas/fields/translations-schema.js.map +0 -1
package/dist/esm/index.js
CHANGED
|
@@ -1,12 +1,891 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/schemas/fields/field-schema.ts
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
var questionTypeSchema = z.enum([
|
|
7
|
+
"rating",
|
|
8
|
+
"single_choice",
|
|
9
|
+
"nps",
|
|
10
|
+
"nested_selection",
|
|
11
|
+
"multiple_choice_multiple",
|
|
12
|
+
"short_answer",
|
|
13
|
+
"long_text",
|
|
14
|
+
"annotation"
|
|
15
|
+
]).describe("Enumeration of all supported question types for form fields");
|
|
16
|
+
var validationRuleSchema = z.object({
|
|
17
|
+
type: z.enum([
|
|
18
|
+
"required",
|
|
19
|
+
"min",
|
|
20
|
+
"max",
|
|
21
|
+
"minLength",
|
|
22
|
+
"maxLength",
|
|
23
|
+
"pattern",
|
|
24
|
+
"email",
|
|
25
|
+
"url",
|
|
26
|
+
"custom"
|
|
27
|
+
]).describe("Type of validation rule to apply"),
|
|
28
|
+
value: z.union([z.string(), z.number(), z.boolean()]).optional().describe("Value for the validation rule (string, number, or boolean)"),
|
|
29
|
+
message: z.string().optional().describe("Custom error message when validation fails"),
|
|
30
|
+
describe: z.string().max(500).optional().describe("LLM tool call description for this validation rule")
|
|
31
|
+
}).describe("Schema defining validation rules for question responses");
|
|
32
|
+
var visibilityConditionSchema = z.object({
|
|
33
|
+
field: z.string().describe("ID of the field to check against"),
|
|
34
|
+
operator: z.enum([
|
|
35
|
+
"equals",
|
|
36
|
+
"not_equals",
|
|
37
|
+
"contains",
|
|
38
|
+
"not_contains",
|
|
39
|
+
"greater_than",
|
|
40
|
+
"less_than",
|
|
41
|
+
"is_empty",
|
|
42
|
+
"is_not_empty"
|
|
43
|
+
]).describe("Comparison operator for the condition"),
|
|
44
|
+
value: z.union([z.string(), z.number(), z.boolean()]).optional().describe("Value to compare against (string, number, or boolean)"),
|
|
45
|
+
describe: z.string().max(500).optional().describe("LLM tool call description for this visibility condition")
|
|
46
|
+
}).describe(
|
|
47
|
+
"Schema defining conditions that control when questions are visible"
|
|
48
|
+
);
|
|
49
|
+
var sectionSchema = z.object({
|
|
50
|
+
id: z.uuid().describe("Unique identifier for the section"),
|
|
51
|
+
title: z.string().min(1).max(200).describe("Display title for the section"),
|
|
52
|
+
question_ids: z.array(z.uuid()).min(1).describe("Array of question IDs that belong to this section")
|
|
53
|
+
}).describe("Schema defining sections that organize questions into logical groups");
|
|
54
|
+
var questionStatusSchema = z.enum(["D", "P", "A", "S"]);
|
|
55
|
+
var ratingDisplayStyleSchema = z.enum([
|
|
56
|
+
"star",
|
|
57
|
+
"heart",
|
|
58
|
+
"thumbs-up",
|
|
59
|
+
"diamond",
|
|
60
|
+
"emoji",
|
|
61
|
+
"emoji-exp"
|
|
62
|
+
]);
|
|
63
|
+
var ratingRepresentationSizeSchema = z.enum([
|
|
64
|
+
"small",
|
|
65
|
+
"medium",
|
|
66
|
+
"large"
|
|
67
|
+
]);
|
|
68
|
+
var multipleChoiceDisplayStyleSchema = z.enum([
|
|
69
|
+
"radio",
|
|
70
|
+
"list",
|
|
71
|
+
"chip",
|
|
72
|
+
"dropdown"
|
|
73
|
+
]);
|
|
74
|
+
var multipleChoiceMultipleDisplayStyleSchema = z.enum([
|
|
75
|
+
"checkbox",
|
|
76
|
+
"list",
|
|
77
|
+
"chip"
|
|
78
|
+
]);
|
|
79
|
+
var choiceOrderOptionSchema = z.enum([
|
|
80
|
+
"randomize",
|
|
81
|
+
"flip",
|
|
82
|
+
"rotate",
|
|
83
|
+
"ascending",
|
|
84
|
+
"none"
|
|
85
|
+
]);
|
|
86
|
+
var questionSchema = z.object({
|
|
87
|
+
id: z.uuid().describe("Unique identifier for the question"),
|
|
88
|
+
type: questionTypeSchema.describe(
|
|
89
|
+
"The type of question (rating, single_choice, etc.)"
|
|
90
|
+
),
|
|
91
|
+
title: z.string().min(1).max(200).describe("The main title/question text displayed to users"),
|
|
92
|
+
description: z.string().max(1e3).optional().describe("Optional detailed description or help text"),
|
|
93
|
+
describe: z.string().max(2e3).optional().describe(
|
|
94
|
+
"LLM tool call description for better AI understanding and context"
|
|
95
|
+
),
|
|
96
|
+
required: z.boolean().default(false).describe("Whether this question must be answered"),
|
|
97
|
+
errorMessage: z.string().max(500).optional().describe("Custom error message when validation fails"),
|
|
98
|
+
validations: z.array(validationRuleSchema).optional().default([]).describe("Array of validation rules to apply"),
|
|
99
|
+
visibility: z.array(visibilityConditionSchema).optional().default([]).describe("Conditions that control when this question is shown"),
|
|
100
|
+
isFixed: z.boolean().describe("Whether this question position is fixed or can be reordered"),
|
|
101
|
+
sectionId: z.string().uuid().optional().describe("ID of the section this question belongs to"),
|
|
102
|
+
status: questionStatusSchema.describe(
|
|
103
|
+
"Current status of the question (Draft, Published, etc.)"
|
|
104
|
+
)
|
|
105
|
+
}).describe("Base schema for all question types with common properties");
|
|
106
|
+
var ratingQuestionSchema = questionSchema.extend({
|
|
107
|
+
type: z.literal(questionTypeSchema.enum.rating).describe("Must be exactly 'rating'"),
|
|
108
|
+
showLabels: z.boolean().optional().describe("Whether to show min/max labels"),
|
|
109
|
+
minLabel: z.string().max(100).optional().describe("Label for the minimum rating value"),
|
|
110
|
+
maxLabel: z.string().max(100).optional().describe("Label for the maximum rating value"),
|
|
111
|
+
displayStyle: ratingDisplayStyleSchema.optional().describe("Visual style for rating display"),
|
|
112
|
+
numberOfRatings: z.number().int().min(1).max(10).describe("Number of rating options (1-10)"),
|
|
113
|
+
representationSize: ratingRepresentationSizeSchema.optional().describe("Size of rating visual elements"),
|
|
114
|
+
color: z.string().regex(/^#[0-9A-F]{6}$/i, "Must be a valid hex color").optional().describe("Hex color for rating elements")
|
|
115
|
+
}).describe("Schema for rating questions with customizable display options");
|
|
116
|
+
var annotationQuestionSchema = questionSchema.extend({
|
|
117
|
+
type: z.literal(questionTypeSchema.enum.annotation).describe("Must be exactly 'annotation'"),
|
|
118
|
+
annotationText: z.string().max(1e3).optional().describe("Text to display when annotation is provided"),
|
|
119
|
+
noAnnotationText: z.string().max(500).optional().describe("Text to display when no annotation is provided")
|
|
120
|
+
}).describe(
|
|
121
|
+
"Schema for annotation questions that provide additional context or instructions"
|
|
122
|
+
);
|
|
123
|
+
var questionOptionSchema = z.object({
|
|
124
|
+
id: z.uuid().describe("Unique identifier for this option"),
|
|
125
|
+
value: z.string().min(1).max(100).describe("The internal value used for this option"),
|
|
126
|
+
label: z.string().min(1).max(200).describe("The display text shown to users for this option"),
|
|
127
|
+
describe: z.string().max(500).optional().describe(
|
|
128
|
+
"LLM tool call description providing context about this option"
|
|
129
|
+
),
|
|
130
|
+
imageUrl: z.string().url().optional().describe("Optional image URL to display with this option")
|
|
131
|
+
}).describe("Schema for individual options in choice-based questions");
|
|
132
|
+
var nestedOptionSchema = z.lazy(
|
|
133
|
+
() => z.object({
|
|
134
|
+
id: z.string().uuid().describe("Unique identifier for this nested option"),
|
|
135
|
+
value: z.string().min(1).max(100).describe("The internal value used for this nested option"),
|
|
136
|
+
label: z.string().min(1).max(200).describe("The display text shown for this nested option"),
|
|
137
|
+
describe: z.string().max(500).optional().describe("LLM tool call description for this nested option context"),
|
|
138
|
+
imageUrl: z.string().url().optional().describe("Optional image URL for this nested option"),
|
|
139
|
+
hint: z.string().max(500).optional().describe(
|
|
140
|
+
"Optional hint text to help users understand this nested option"
|
|
141
|
+
),
|
|
142
|
+
children: z.array(nestedOptionSchema).optional().default([]).describe("Array of child options for hierarchical structure")
|
|
143
|
+
}).describe("Schema for nested options with hierarchical structure support")
|
|
144
|
+
);
|
|
145
|
+
var multipleChoiceSingleQuestionSchema = questionSchema.extend({
|
|
146
|
+
type: z.literal(questionTypeSchema.enum.single_choice).describe("Must be exactly 'single_choice'"),
|
|
147
|
+
displayStyle: multipleChoiceDisplayStyleSchema.optional().describe("Visual style for displaying options"),
|
|
148
|
+
randomizeOptions: z.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
149
|
+
options: z.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
150
|
+
}).describe("Schema for single-choice multiple selection questions");
|
|
151
|
+
var multipleChoiceMultipleQuestionSchema = questionSchema.extend({
|
|
152
|
+
type: z.literal(questionTypeSchema.enum.multiple_choice_multiple).describe("Must be exactly 'multiple_choice_multiple'"),
|
|
153
|
+
displayStyle: multipleChoiceMultipleDisplayStyleSchema.optional().describe("Visual style for displaying multiple options"),
|
|
154
|
+
minSelections: z.number().int().min(0).optional().describe("Minimum number of options that must be selected"),
|
|
155
|
+
maxSelections: z.number().int().min(1).optional().describe("Maximum number of options that can be selected"),
|
|
156
|
+
randomizeOptions: z.boolean().optional().default(false).describe("Whether to randomize the order of options"),
|
|
157
|
+
options: z.array(questionOptionSchema).min(1).max(50).describe("Array of options for user selection (1-50 options)")
|
|
158
|
+
}).refine(
|
|
159
|
+
(data) => {
|
|
160
|
+
if (data.minSelections !== void 0 && data.maxSelections !== void 0) {
|
|
161
|
+
return data.minSelections <= data.maxSelections;
|
|
162
|
+
}
|
|
163
|
+
return true;
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
message: "minSelections cannot be greater than maxSelections",
|
|
167
|
+
path: ["minSelections"]
|
|
168
|
+
// Point to minSelections field for the error
|
|
169
|
+
}
|
|
170
|
+
).describe(
|
|
171
|
+
"Schema for multiple-choice questions allowing multiple selections"
|
|
172
|
+
);
|
|
173
|
+
var npsQuestionSchema = questionSchema.extend({
|
|
174
|
+
type: z.literal(questionTypeSchema.enum.nps).describe("Must be exactly 'nps'"),
|
|
175
|
+
min: z.literal(0).describe("NPS always starts at 0"),
|
|
176
|
+
max: z.literal(10).describe("NPS always ends at 10"),
|
|
177
|
+
minLabel: z.string().max(100).optional().describe("Label for the minimum NPS value (0)"),
|
|
178
|
+
maxLabel: z.string().max(100).optional().describe("Label for the maximum NPS value (10)"),
|
|
179
|
+
scaleLabels: z.record(z.string().regex(/^\d+$/).transform(Number).refine((val) => val >= 0 && val <= 10), z.string().max(50)).optional().describe("Custom labels for specific NPS values (0-10)"),
|
|
180
|
+
prepopulatedValue: z.number().int().min(0).max(10).optional().describe("Default value to pre-select (0-10)")
|
|
181
|
+
}).refine(
|
|
182
|
+
(data) => {
|
|
183
|
+
if (data.scaleLabels) {
|
|
184
|
+
const keys = Object.keys(data.scaleLabels).map(Number);
|
|
185
|
+
return keys.every((key) => key >= 0 && key <= 10);
|
|
186
|
+
}
|
|
187
|
+
return true;
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
message: "scaleLabels keys must be between 0 and 10 (inclusive)",
|
|
191
|
+
path: ["scaleLabels"]
|
|
192
|
+
}
|
|
193
|
+
).describe("Schema for Net Promoter Score questions with 0-10 scale");
|
|
194
|
+
var shortAnswerQuestionSchema = questionSchema.extend({
|
|
195
|
+
type: z.literal(questionTypeSchema.enum.short_answer).describe("Must be exactly 'short_answer'"),
|
|
196
|
+
maxCharacters: z.number().int().min(1).max(1e4).optional().describe("Maximum number of characters allowed"),
|
|
197
|
+
minCharacters: z.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
198
|
+
placeholder: z.string().max(200).optional().describe("Placeholder text shown in the input field"),
|
|
199
|
+
enableRegexValidation: z.boolean().optional().default(false).describe("Whether to enable regex pattern validation"),
|
|
200
|
+
regexPattern: z.string().optional().describe("Regular expression pattern for validation"),
|
|
201
|
+
enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
202
|
+
promptTemplate: z.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
203
|
+
cooldownSeconds: z.number().int().min(0).max(3600).optional().describe("Cooldown period between AI enhancements (0-3600 seconds)"),
|
|
204
|
+
maxEnhancements: z.number().int().min(1).max(10).optional().describe("Maximum number of AI enhancements allowed"),
|
|
205
|
+
maxTokenAllowed: z.number().int().min(1).max(1e4).optional().describe("Maximum tokens allowed for AI processing"),
|
|
206
|
+
minCharactersToEnhance: z.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
|
|
207
|
+
}).refine(
|
|
208
|
+
(data) => {
|
|
209
|
+
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
210
|
+
return data.minCharacters <= data.maxCharacters;
|
|
211
|
+
}
|
|
212
|
+
return true;
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
message: "minCharacters cannot be greater than maxCharacters",
|
|
216
|
+
path: ["minCharacters"]
|
|
217
|
+
}
|
|
218
|
+
).refine(
|
|
219
|
+
(data) => {
|
|
220
|
+
if (data.enableRegexValidation && !data.regexPattern) {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
return true;
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
message: "regexPattern is required when enableRegexValidation is true",
|
|
227
|
+
path: ["regexPattern"]
|
|
228
|
+
}
|
|
229
|
+
).refine(
|
|
230
|
+
(data) => {
|
|
231
|
+
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
return true;
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
238
|
+
path: ["promptTemplate"]
|
|
239
|
+
}
|
|
240
|
+
).describe("Schema for short answer questions with optional AI enhancement");
|
|
241
|
+
var longAnswerQuestionSchema = questionSchema.extend({
|
|
242
|
+
type: z.literal(questionTypeSchema.enum.long_text).describe("Must be exactly 'long_text'"),
|
|
243
|
+
maxCharacters: z.number().int().min(1).max(5e4).optional().describe(
|
|
244
|
+
"Maximum number of characters allowed (higher limit for long text)"
|
|
245
|
+
),
|
|
246
|
+
minCharacters: z.number().int().min(0).optional().describe("Minimum number of characters required"),
|
|
247
|
+
rows: z.number().int().min(1).max(20).optional().describe("Number of textarea rows to display (1-20)"),
|
|
248
|
+
placeholder: z.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
|
|
249
|
+
enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
|
|
250
|
+
promptTemplate: z.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
|
|
251
|
+
cooldownSeconds: z.number().int().min(0).max(3600).optional().describe("Cooldown period between AI enhancements (0-3600 seconds)"),
|
|
252
|
+
maxEnhancements: z.number().int().min(1).max(10).optional().describe("Maximum number of AI enhancements allowed"),
|
|
253
|
+
maxTokenAllowed: z.number().int().min(1).max(25e3).optional().describe(
|
|
254
|
+
"Maximum tokens allowed for AI processing (higher for long text)"
|
|
255
|
+
)
|
|
256
|
+
}).refine(
|
|
257
|
+
(data) => {
|
|
258
|
+
if (data.minCharacters !== void 0 && data.maxCharacters !== void 0) {
|
|
259
|
+
return data.minCharacters <= data.maxCharacters;
|
|
260
|
+
}
|
|
261
|
+
return true;
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
message: "minCharacters cannot be greater than maxCharacters",
|
|
265
|
+
path: ["minCharacters"]
|
|
266
|
+
}
|
|
267
|
+
).refine(
|
|
268
|
+
(data) => {
|
|
269
|
+
if (data.enableEnhanceWithAi && !data.promptTemplate) {
|
|
270
|
+
return false;
|
|
271
|
+
}
|
|
272
|
+
return true;
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
message: "promptTemplate is required when enableEnhanceWithAi is true",
|
|
276
|
+
path: ["promptTemplate"]
|
|
277
|
+
}
|
|
278
|
+
).describe(
|
|
279
|
+
"Schema for long answer questions with rich text support and AI enhancement"
|
|
280
|
+
);
|
|
281
|
+
var nestedDropdownQuestionSchema = questionSchema.extend({
|
|
282
|
+
type: z.literal(questionTypeSchema.enum.nested_selection).describe("Must be exactly 'nested_selection'"),
|
|
283
|
+
placeholder: z.string().max(200).optional().describe("Placeholder text for the nested dropdown"),
|
|
284
|
+
options: z.array(nestedOptionSchema).min(1).max(100).describe(
|
|
285
|
+
"Array of nested options for hierarchical selection (1-100 options)"
|
|
286
|
+
),
|
|
287
|
+
displayStyle: z.literal("list").describe("Fixed display style for nested dropdowns"),
|
|
288
|
+
choiceOrderOption: choiceOrderOptionSchema.optional().default("none").describe("How to order the nested choices"),
|
|
289
|
+
preserveLastChoices: z.number().int().min(0).max(10).optional().describe("Number of choice levels to preserve (0-10)"),
|
|
290
|
+
prepopulatedValue: z.string().max(1e3).optional().describe("Default value to pre-populate"),
|
|
291
|
+
allowOther: z.boolean().optional().default(false).describe('Whether to allow custom "other" options'),
|
|
292
|
+
otherColumnName: z.string().max(100).optional().describe('Column name for storing custom "other" values'),
|
|
293
|
+
maxDepth: z.number().int().min(1).max(10).optional().describe("Maximum nesting depth allowed (1-10)"),
|
|
294
|
+
cascadeLabels: z.boolean().optional().default(false).describe("Whether to cascade labels from parent options")
|
|
295
|
+
}).refine(
|
|
296
|
+
(data) => {
|
|
297
|
+
if (data.allowOther && !data.otherColumnName) {
|
|
298
|
+
return false;
|
|
299
|
+
}
|
|
300
|
+
return true;
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
message: "otherColumnName is required when allowOther is true",
|
|
304
|
+
path: ["otherColumnName"]
|
|
305
|
+
}
|
|
306
|
+
).describe(
|
|
307
|
+
"Schema for nested dropdown questions with hierarchical option structure"
|
|
308
|
+
);
|
|
309
|
+
var combinedQuestionSchema = z.discriminatedUnion("type", [
|
|
310
|
+
ratingQuestionSchema,
|
|
311
|
+
annotationQuestionSchema,
|
|
312
|
+
multipleChoiceSingleQuestionSchema,
|
|
313
|
+
multipleChoiceMultipleQuestionSchema,
|
|
314
|
+
npsQuestionSchema,
|
|
315
|
+
shortAnswerQuestionSchema,
|
|
316
|
+
longAnswerQuestionSchema,
|
|
317
|
+
nestedDropdownQuestionSchema
|
|
318
|
+
]);
|
|
319
|
+
|
|
320
|
+
// src/schemas/fields/answer-schema.ts
|
|
321
|
+
import { z as z2 } from "zod";
|
|
322
|
+
var SimpleAnswerSchema = z2.object({
|
|
323
|
+
type: z2.literal("simple").describe("Indicates this is a simple answer with a single value"),
|
|
324
|
+
value: z2.union([z2.string(), z2.number(), z2.boolean()]).describe("The answer value - can be text, number, or boolean")
|
|
325
|
+
}).describe(
|
|
326
|
+
"A simple answer containing a single value like text, number, or boolean"
|
|
327
|
+
);
|
|
328
|
+
var ChoiceAnswerSchema = z2.object({
|
|
329
|
+
type: z2.literal("choice").describe("Indicates this is a single-choice answer"),
|
|
330
|
+
selectedOptionId: z2.string().describe("The ID of the selected option from the available choices")
|
|
331
|
+
}).describe(
|
|
332
|
+
"A single-choice answer where the user selects one option from a list"
|
|
333
|
+
);
|
|
334
|
+
var MultipleChoiceAnswerSchema = z2.object({
|
|
335
|
+
type: z2.literal("multiple_choice").describe("Indicates this is a multiple-choice answer"),
|
|
336
|
+
selectedOptionIds: z2.array(z2.string()).describe(
|
|
337
|
+
"Array of IDs for all selected options from the available choices"
|
|
338
|
+
)
|
|
339
|
+
}).describe(
|
|
340
|
+
"A multiple-choice answer where the user can select multiple options from a list"
|
|
341
|
+
);
|
|
342
|
+
var ScaleAnswerSchema = z2.object({
|
|
343
|
+
type: z2.literal("scale").describe("Indicates this is a scale/rating answer"),
|
|
344
|
+
value: z2.number().describe(
|
|
345
|
+
"The numerical value representing the position on the scale (e.g., 1-5, 1-10)"
|
|
346
|
+
)
|
|
347
|
+
}).describe(
|
|
348
|
+
"A scale answer where the user selects a numerical value on a scale"
|
|
349
|
+
);
|
|
350
|
+
var ContinuousSumAnswerSchema = z2.object({
|
|
351
|
+
type: z2.literal("continuous_sum").describe("Indicates this is a continuous sum answer"),
|
|
352
|
+
values: z2.array(
|
|
353
|
+
z2.object({
|
|
354
|
+
optionId: z2.string().describe("The ID of the option being rated"),
|
|
355
|
+
value: z2.number().describe("The numerical value assigned to this option")
|
|
356
|
+
})
|
|
357
|
+
).describe(
|
|
358
|
+
"Array of option-value pairs where the sum of all values represents a total allocation"
|
|
359
|
+
)
|
|
360
|
+
}).describe(
|
|
361
|
+
"A continuous sum answer where users distribute values across multiple options that add up to a total"
|
|
362
|
+
);
|
|
363
|
+
var RankingAnswerSchema = z2.object({
|
|
364
|
+
type: z2.literal("ranking").describe("Indicates this is a ranking answer"),
|
|
365
|
+
ranks: z2.array(
|
|
366
|
+
z2.object({
|
|
367
|
+
optionId: z2.string().describe("The ID of the option being ranked"),
|
|
368
|
+
rank: z2.number().describe(
|
|
369
|
+
"The rank position of this option (lower numbers indicate higher preference)"
|
|
370
|
+
)
|
|
371
|
+
})
|
|
372
|
+
).describe(
|
|
373
|
+
"Array of option-rank pairs showing the user's preference ordering"
|
|
374
|
+
)
|
|
375
|
+
}).describe(
|
|
376
|
+
"A ranking answer where users order options by preference or priority"
|
|
377
|
+
);
|
|
378
|
+
var TextAnswerSchema = z2.object({
|
|
379
|
+
type: z2.literal("text").describe("Indicates this is a text-based answer"),
|
|
380
|
+
values: z2.array(
|
|
381
|
+
z2.object({
|
|
382
|
+
fieldId: z2.string().describe("The ID of the text field"),
|
|
383
|
+
text: z2.string().describe("The text content entered by the user")
|
|
384
|
+
})
|
|
385
|
+
).describe("Array of field-text pairs for multiple text input fields")
|
|
386
|
+
}).describe(
|
|
387
|
+
"A text answer containing responses to one or more text input fields"
|
|
388
|
+
);
|
|
389
|
+
var AnswerSchema = z2.discriminatedUnion("type", [
|
|
390
|
+
SimpleAnswerSchema,
|
|
391
|
+
ChoiceAnswerSchema,
|
|
392
|
+
MultipleChoiceAnswerSchema,
|
|
393
|
+
ScaleAnswerSchema,
|
|
394
|
+
ContinuousSumAnswerSchema,
|
|
395
|
+
RankingAnswerSchema,
|
|
396
|
+
TextAnswerSchema
|
|
397
|
+
]).describe(
|
|
398
|
+
"A union of all possible answer types discriminated by the 'type' field"
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
// src/schemas/fields/form-schema.ts
|
|
402
|
+
import { z as z3 } from "zod";
|
|
403
|
+
var surveyTypeSchema = z3.enum(["R", "O"]).describe("Enumeration of feedback types: R=Recurring, O=One-time");
|
|
404
|
+
var yesNoSchema = z3.enum(["Y", "N"]).describe("Yes/No enumeration using Y/N values");
|
|
405
|
+
var recurringUnitSchema = z3.enum(["minutes", "hours", "days", "weeks", "months", "years"]).describe("Time units for recurring feedback schedules");
|
|
406
|
+
var frequencyAndSchedulingPropertiesSchema = z3.object({
|
|
407
|
+
surveyType: surveyTypeSchema.describe("Type of feedback: R for recurring, O for one-time"),
|
|
408
|
+
showOnce: yesNoSchema.describe("Whether the feedback should be shown only once per user"),
|
|
409
|
+
stopWhenResponsesCount: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Stop feedback when this number of responses is reached (as string)"),
|
|
410
|
+
recurringValue: z3.string().regex(/^\d+$/, "Must be a valid number string").describe("Value for recurring schedule (e.g., every 15 days)"),
|
|
411
|
+
recurringUnit: recurringUnitSchema.describe("Time unit for recurring schedule"),
|
|
412
|
+
startDate: z3.string().regex(
|
|
413
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
414
|
+
"Must be a valid ISO date string with timezone"
|
|
415
|
+
).describe("Start date and time for the feedback in ISO format"),
|
|
416
|
+
stopDate: z3.string().regex(
|
|
417
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
418
|
+
"Must be a valid ISO date string with timezone"
|
|
419
|
+
).describe("Stop date and time for the feedback in ISO format")
|
|
420
|
+
}).refine(
|
|
421
|
+
(data) => {
|
|
422
|
+
if (data.surveyType === "O" && data.showOnce === "N") {
|
|
423
|
+
return false;
|
|
424
|
+
}
|
|
425
|
+
return true;
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
message: "One-time feedback must have showOnce set to 'Y'",
|
|
429
|
+
path: ["showOnce"]
|
|
430
|
+
}
|
|
431
|
+
).refine(
|
|
432
|
+
(data) => {
|
|
433
|
+
if (data.surveyType === "R") {
|
|
434
|
+
const value = parseInt(data.recurringValue);
|
|
435
|
+
return value > 0;
|
|
436
|
+
}
|
|
437
|
+
return true;
|
|
438
|
+
},
|
|
439
|
+
{
|
|
440
|
+
message: "Recurring feedback must have a positive recurring value",
|
|
441
|
+
path: ["recurringValue"]
|
|
442
|
+
}
|
|
443
|
+
).refine(
|
|
444
|
+
(data) => {
|
|
445
|
+
const start = new Date(data.startDate);
|
|
446
|
+
const stop = new Date(data.stopDate);
|
|
447
|
+
return stop > start;
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
message: "Stop date must be after start date",
|
|
451
|
+
path: ["stopDate"]
|
|
452
|
+
}
|
|
453
|
+
).describe("Schema defining frequency and scheduling properties for feedback");
|
|
454
|
+
var externalPublishingPropertiesSchema = z3.object({
|
|
455
|
+
isShareable: z3.boolean().describe("Whether the feedback results can be shared externally"),
|
|
456
|
+
isEmailShareable: z3.boolean().describe("Whether the feedback can be shared via email")
|
|
457
|
+
}).describe("Schema defining external publishing and sharing properties for feedback");
|
|
458
|
+
var publicationStatusSchema = z3.enum(["P", "D", "A"]).describe("Publication status: P=Published, D=Draft, A=Archived");
|
|
459
|
+
var feedbackConfigurationSchema = z3.object({
|
|
460
|
+
form_title: z3.string().describe("Title of the feedback form"),
|
|
461
|
+
form_description: z3.string().describe("Description of the feedback form"),
|
|
462
|
+
duration: z3.object({
|
|
463
|
+
from: z3.string().regex(
|
|
464
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
465
|
+
"Must be a valid ISO date string with timezone"
|
|
466
|
+
).describe("Start date and time for the feedback duration"),
|
|
467
|
+
to: z3.string().regex(
|
|
468
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/,
|
|
469
|
+
"Must be a valid ISO date string with timezone"
|
|
470
|
+
).describe("End date and time for the feedback duration")
|
|
471
|
+
}).describe("Duration period for the feedback"),
|
|
472
|
+
is_published: publicationStatusSchema.describe("Publication status of the feedback form")
|
|
473
|
+
}).refine(
|
|
474
|
+
(data) => {
|
|
475
|
+
const start = new Date(data.duration.from);
|
|
476
|
+
const end = new Date(data.duration.to);
|
|
477
|
+
return end > start;
|
|
478
|
+
},
|
|
479
|
+
{
|
|
480
|
+
message: "End date must be after start date",
|
|
481
|
+
path: ["duration", "to"]
|
|
482
|
+
}
|
|
483
|
+
).describe("Schema defining feedback configuration properties");
|
|
484
|
+
|
|
485
|
+
// src/schemas/fields/form-properties-schema.ts
|
|
486
|
+
import { z as z8 } from "zod";
|
|
487
|
+
|
|
488
|
+
// src/schemas/fields/translations-schema.ts
|
|
489
|
+
import { z as z4 } from "zod";
|
|
490
|
+
var translationEntrySchema = z4.object({
|
|
491
|
+
text: z4.string().min(1).describe("Translated text content"),
|
|
492
|
+
context: z4.string().optional().describe("Optional context for translators")
|
|
493
|
+
}).describe("Translation entry with translated text");
|
|
494
|
+
var ratingTranslationsSchema = z4.object({
|
|
495
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
496
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
497
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
498
|
+
minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
|
|
499
|
+
maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
|
|
500
|
+
}).describe("Translation schema for rating questions");
|
|
501
|
+
var singleChoiceTranslationsSchema = z4.object({
|
|
502
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
503
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
504
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
505
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation"),
|
|
506
|
+
options: z4.record(z4.string(), z4.object({
|
|
507
|
+
label: translationEntrySchema.describe("Option label translation"),
|
|
508
|
+
hint: translationEntrySchema.optional().describe("Option hint translation")
|
|
509
|
+
})).describe("Option translations keyed by option ID")
|
|
510
|
+
}).describe("Translation schema for single choice questions");
|
|
511
|
+
var multipleChoiceTranslationsSchema = z4.object({
|
|
512
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
513
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
514
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
515
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation"),
|
|
516
|
+
options: z4.record(z4.string(), z4.object({
|
|
517
|
+
label: translationEntrySchema.describe("Option label translation"),
|
|
518
|
+
hint: translationEntrySchema.optional().describe("Option hint translation")
|
|
519
|
+
})).describe("Option translations keyed by option ID")
|
|
520
|
+
}).describe("Translation schema for multiple choice questions");
|
|
521
|
+
var npsTranslationsSchema = z4.object({
|
|
522
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
523
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
524
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
525
|
+
minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
|
|
526
|
+
maxLabel: translationEntrySchema.optional().describe("Maximum NPS label (10) translation"),
|
|
527
|
+
scaleLabels: z4.record(z4.number().int().min(0).max(10), translationEntrySchema).optional().describe("Scale label translations for specific NPS values (0-10)")
|
|
528
|
+
}).describe("Translation schema for NPS questions");
|
|
529
|
+
var shortAnswerTranslationsSchema = z4.object({
|
|
530
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
531
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
532
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
533
|
+
placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
|
|
534
|
+
}).describe("Translation schema for short answer questions");
|
|
535
|
+
var longAnswerTranslationsSchema = z4.object({
|
|
536
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
537
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
538
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
539
|
+
placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
|
|
540
|
+
}).describe("Translation schema for long answer questions");
|
|
541
|
+
var nestedSelectionTranslationsSchema = z4.object({
|
|
542
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
543
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
544
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
545
|
+
placeholder: translationEntrySchema.optional().describe("Dropdown placeholder translation"),
|
|
546
|
+
nestedOptions: z4.record(z4.string(), z4.object({
|
|
547
|
+
label: translationEntrySchema.describe("Nested option label translation"),
|
|
548
|
+
hint: translationEntrySchema.optional().describe("Nested option hint translation")
|
|
549
|
+
})).describe("Nested option translations keyed by option ID")
|
|
550
|
+
}).describe("Translation schema for nested selection questions");
|
|
551
|
+
var annotationTranslationsSchema = z4.object({
|
|
552
|
+
title: translationEntrySchema.describe("Question title translation"),
|
|
553
|
+
description: translationEntrySchema.optional().describe("Question description translation"),
|
|
554
|
+
errorMessage: translationEntrySchema.optional().describe("Error message translation"),
|
|
555
|
+
annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
|
|
556
|
+
noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
|
|
557
|
+
}).describe("Translation schema for annotation questions");
|
|
558
|
+
var questionTranslationsSchema = z4.discriminatedUnion("type", [
|
|
559
|
+
z4.object({ type: z4.literal("rating"), translations: ratingTranslationsSchema }),
|
|
560
|
+
z4.object({ type: z4.literal("single_choice"), translations: singleChoiceTranslationsSchema }),
|
|
561
|
+
z4.object({ type: z4.literal("multiple_choice_multiple"), translations: multipleChoiceTranslationsSchema }),
|
|
562
|
+
z4.object({ type: z4.literal("nps"), translations: npsTranslationsSchema }),
|
|
563
|
+
z4.object({ type: z4.literal("short_answer"), translations: shortAnswerTranslationsSchema }),
|
|
564
|
+
z4.object({ type: z4.literal("long_text"), translations: longAnswerTranslationsSchema }),
|
|
565
|
+
z4.object({ type: z4.literal("nested_selection"), translations: nestedSelectionTranslationsSchema }),
|
|
566
|
+
z4.object({ type: z4.literal("annotation"), translations: annotationTranslationsSchema })
|
|
567
|
+
]).describe("Discriminated union of all question type translation schemas");
|
|
568
|
+
var languageTranslationsSchema = z4.object({
|
|
569
|
+
languageCode: z4.string().describe("Language code matching LanguagesSchema values"),
|
|
570
|
+
questions: z4.record(z4.string(), questionTranslationsSchema).describe("Question translations keyed by question ID")
|
|
571
|
+
}).describe("Language-specific translation set keyed by question IDs");
|
|
572
|
+
var translationsSchema = z4.object({
|
|
573
|
+
defaultLanguage: z4.string().describe("Default/fallback language code"),
|
|
574
|
+
languages: z4.array(languageTranslationsSchema).min(1).describe("Available language translations"),
|
|
575
|
+
version: z4.string().optional().describe("Translation version for cache management")
|
|
576
|
+
}).describe("Complete translation schema keyed by question IDs");
|
|
577
|
+
var _TranslationProvider = class _TranslationProvider {
|
|
578
|
+
constructor(translations) {
|
|
579
|
+
this.translations = translations;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* Get translations for a specific question in a specific language
|
|
583
|
+
*/
|
|
584
|
+
getQuestionTranslations(questionId, languageCode) {
|
|
585
|
+
const languageData = this.translations.languages.find(
|
|
586
|
+
(lang) => lang.languageCode === languageCode
|
|
587
|
+
);
|
|
588
|
+
if (!languageData) {
|
|
589
|
+
const defaultLang = this.translations.languages.find(
|
|
590
|
+
(lang) => lang.languageCode === this.translations.defaultLanguage
|
|
591
|
+
);
|
|
592
|
+
if (!defaultLang) return null;
|
|
593
|
+
return defaultLang.questions[questionId] || null;
|
|
594
|
+
}
|
|
595
|
+
return languageData.questions[questionId] || null;
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Get a specific translation text
|
|
599
|
+
*/
|
|
600
|
+
getTranslationText(questionId, languageCode, path) {
|
|
601
|
+
const questionTranslations = this.getQuestionTranslations(questionId, languageCode);
|
|
602
|
+
if (!questionTranslations) return null;
|
|
603
|
+
let current = questionTranslations.translations;
|
|
604
|
+
for (const key of path) {
|
|
605
|
+
if (current && typeof current === "object" && key in current) {
|
|
606
|
+
current = current[key];
|
|
607
|
+
} else {
|
|
608
|
+
return null;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
if (current && typeof current === "object" && "text" in current) {
|
|
612
|
+
return current.text;
|
|
613
|
+
}
|
|
614
|
+
return null;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Get all available languages
|
|
618
|
+
*/
|
|
619
|
+
getAvailableLanguages() {
|
|
620
|
+
return this.translations.languages.map((lang) => lang.languageCode);
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Check if a language is supported
|
|
624
|
+
*/
|
|
625
|
+
isLanguageSupported(languageCode) {
|
|
626
|
+
return this.translations.languages.some((lang) => lang.languageCode === languageCode);
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Get the default language
|
|
630
|
+
*/
|
|
631
|
+
getDefaultLanguage() {
|
|
632
|
+
return this.translations.defaultLanguage;
|
|
633
|
+
}
|
|
634
|
+
};
|
|
635
|
+
__name(_TranslationProvider, "TranslationProvider");
|
|
636
|
+
var TranslationProvider = _TranslationProvider;
|
|
637
|
+
function createTranslationProvider(translations) {
|
|
638
|
+
return new TranslationProvider(translations);
|
|
639
|
+
}
|
|
640
|
+
__name(createTranslationProvider, "createTranslationProvider");
|
|
641
|
+
|
|
642
|
+
// src/schemas/fields/other-screen-schema.ts
|
|
643
|
+
import { z as z5 } from "zod";
|
|
644
|
+
var WelcomeScreenFieldsSchema = z5.object({
|
|
645
|
+
title: z5.string().min(1).max(200).describe("The main title displayed on the welcome screen"),
|
|
646
|
+
description: z5.string().min(1).max(1e3).describe("Description text shown on the welcome screen"),
|
|
647
|
+
buttonLabel: z5.string().min(1).max(50).describe("Text displayed on the welcome screen button")
|
|
648
|
+
}).describe("Schema for welcome screen configuration fields");
|
|
649
|
+
var EndScreenFieldsSchema = z5.object({
|
|
650
|
+
title: z5.string().min(1).max(200).describe("The main title displayed on the end screen"),
|
|
651
|
+
message: z5.string().min(1).max(1e3).describe("Message text shown on the end screen"),
|
|
652
|
+
buttonLabel: z5.string().min(1).max(50).describe("Text displayed on the end screen button"),
|
|
653
|
+
dismissBehavior: z5.enum(["fade", "manual"]).describe("How the end screen should be dismissed (fade out or manual dismissal)"),
|
|
654
|
+
fadeDuration: z5.number().int().min(0).max(1e4).describe("Duration in milliseconds for fade dismissal (0-10000)")
|
|
655
|
+
}).describe("Schema for end screen configuration fields");
|
|
656
|
+
var WelcomeFieldsTranslationSchema = z5.object({
|
|
657
|
+
title: z5.string().min(1).max(200).describe("Translated title text for welcome screen"),
|
|
658
|
+
description: z5.string().min(1).max(1e3).describe("Translated description text for welcome screen"),
|
|
659
|
+
buttonLabel: z5.string().min(1).max(50).describe("Translated text for the welcome button label")
|
|
660
|
+
}).describe("Schema for welcome screen translation fields");
|
|
661
|
+
var EndFieldsTranslationSchema = z5.object({
|
|
662
|
+
buttonLabel: z5.string().min(1).max(50).describe("Translated text for the end button label"),
|
|
663
|
+
title: z5.string().min(1).max(200).describe("Translated title text for end screen"),
|
|
664
|
+
message: z5.string().min(1).max(1e3).describe("Translated message text for end screen")
|
|
665
|
+
}).describe("Schema for end screen translation fields");
|
|
666
|
+
var OtherFieldsSchema = z5.object({
|
|
667
|
+
pagination: z5.boolean().describe("Whether to show pagination for multi-page forms"),
|
|
668
|
+
questionNumber: z5.boolean().describe("Whether to display question numbers"),
|
|
669
|
+
pageTitle: z5.boolean().describe("Whether to show page titles in multi-page forms"),
|
|
670
|
+
blockerFeedback: z5.boolean().describe("Whether to show blocker feedback for validation errors"),
|
|
671
|
+
submitButtonLabel: z5.string().min(1).max(50).describe("Text for the submit button"),
|
|
672
|
+
previousButtonLabel: z5.string().min(1).max(50).describe("Text for the previous button in pagination"),
|
|
673
|
+
nextButtonLabel: z5.string().min(1).max(50).describe("Text for the next button in pagination")
|
|
674
|
+
}).describe("Schema for other form configuration fields");
|
|
675
|
+
var LanguageFieldSchema = z5.object({
|
|
676
|
+
value: z5.string().min(1).max(10).describe("Language code (e.g., 'en', 'es', 'fr')"),
|
|
677
|
+
label: z5.string().min(1).max(50).describe("Display name for the language (e.g., 'English', 'Spanish', 'French')"),
|
|
678
|
+
isFixed: z5.boolean().default(false).describe("Whether this language is fixed and cannot be deleted by users")
|
|
679
|
+
}).describe("Schema for individual language field with value, label, and fixed status");
|
|
680
|
+
var LanguagesSchema = z5.array(LanguageFieldSchema).describe("Schema for array of available languages");
|
|
681
|
+
var OtherFieldsTranslationSchema = z5.object({
|
|
682
|
+
submitButtonLabel: z5.string().min(1).max(50).describe("Translated text for the submit button"),
|
|
683
|
+
previousButtonLabel: z5.string().min(1).max(50).describe("Translated text for the previous button in pagination"),
|
|
684
|
+
nextButtonLabel: z5.string().min(1).max(50).describe("Translated text for the next button in pagination")
|
|
685
|
+
}).describe("Schema for other form configuration field translations");
|
|
686
|
+
|
|
687
|
+
// src/schemas/fields/theme-schema.ts
|
|
688
|
+
import { z as z6 } from "zod";
|
|
689
|
+
var positionSchema = z6.enum([
|
|
690
|
+
"top-left",
|
|
691
|
+
"top-center",
|
|
692
|
+
"top-right",
|
|
693
|
+
"middle-left",
|
|
694
|
+
"middle-center",
|
|
695
|
+
"middle-right",
|
|
696
|
+
"bottom-left",
|
|
697
|
+
"bottom-center",
|
|
698
|
+
"bottom-right"
|
|
699
|
+
]).describe("Available positions for widget placement");
|
|
700
|
+
var featureSettingsSchema = z6.object({
|
|
701
|
+
darkOverlay: z6.boolean().describe("Whether to show a dark overlay behind the widget"),
|
|
702
|
+
closeButton: z6.boolean().describe("Whether to display a close button on the widget"),
|
|
703
|
+
progressBar: z6.boolean().describe("Whether to show a progress bar indicating completion status"),
|
|
704
|
+
showBranding: z6.boolean().describe("Whether to display branding elements on the widget"),
|
|
705
|
+
customPosition: z6.boolean().describe("Whether custom positioning is enabled"),
|
|
706
|
+
customIconPosition: z6.boolean().describe("Whether custom icon positioning is enabled")
|
|
707
|
+
}).describe("Feature settings controlling widget UI behavior and appearance");
|
|
708
|
+
var themeColorsSchema = z6.object({
|
|
709
|
+
brandColor: z6.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, "Must be a valid hex color (e.g., #3366CC)").describe("Primary brand color in hex format"),
|
|
710
|
+
overlayColor: z6.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, "Must be a valid hex color (e.g., #FFFFFF)").describe("Overlay background color in hex format"),
|
|
711
|
+
textColor: z6.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, "Must be a valid hex color (e.g., #333333)").describe("Primary text color in hex format"),
|
|
712
|
+
backgroundColor: z6.union([
|
|
713
|
+
z6.string().regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i),
|
|
714
|
+
z6.string().regex(/^rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+\s*(?:,\s*[01](?:\.\d+)?)?\s*\)$/i)
|
|
715
|
+
]).describe("Background color in hex format or rgba format (e.g., #1A1A1A or rgba(255,255,255, 1))")
|
|
716
|
+
}).describe("Color scheme for a single theme");
|
|
717
|
+
var themesSchema = z6.object({
|
|
718
|
+
light: themeColorsSchema,
|
|
719
|
+
dark: themeColorsSchema
|
|
720
|
+
}).describe("Complete theme configuration with light and dark variants");
|
|
721
|
+
var themeConfigurationSchema = z6.object({
|
|
722
|
+
themes: themesSchema.describe("Color themes for light and dark modes"),
|
|
723
|
+
featureSettings: featureSettingsSchema.describe("UI feature settings controlling widget behavior"),
|
|
724
|
+
selectedPosition: positionSchema.describe("Selected position for the main widget"),
|
|
725
|
+
selectedIconPosition: positionSchema.describe("Selected position for the widget icon")
|
|
726
|
+
}).describe("Complete theme and UI configuration including colors, features, and positioning");
|
|
727
|
+
|
|
728
|
+
// src/schemas/fields/auto-trigger-schema.ts
|
|
729
|
+
import { z as z7 } from "zod";
|
|
730
|
+
var audienceSegmentSchema = z7.object({
|
|
731
|
+
id: z7.string().describe("Unique identifier for the audience segment"),
|
|
732
|
+
name: z7.string().min(1).max(200).describe("Display name for the audience segment"),
|
|
733
|
+
isImportant: z7.boolean().describe("Whether this segment is marked as important for targeting"),
|
|
734
|
+
when: z7.string().describe("Timing condition for when to trigger the audience segment"),
|
|
735
|
+
who: z7.string().describe("User criteria or conditions defining who belongs to this segment")
|
|
736
|
+
}).describe("Schema defining an audience segment for targeting");
|
|
737
|
+
var audienceTriggerPropertiesSchema = z7.object({
|
|
738
|
+
isAuto: z7.boolean().describe("Whether automatic triggering is enabled for this audience"),
|
|
739
|
+
isManual: z7.boolean().describe("Whether manual triggering is enabled for this audience"),
|
|
740
|
+
segments: z7.array(audienceSegmentSchema).min(0).describe("Array of audience segments for targeting conditions")
|
|
741
|
+
}).refine(
|
|
742
|
+
(data) => {
|
|
743
|
+
return data.isAuto || data.isManual;
|
|
744
|
+
},
|
|
745
|
+
{
|
|
746
|
+
message: "At least one of isAuto or isManual must be true",
|
|
747
|
+
path: ["isAuto"]
|
|
748
|
+
}
|
|
749
|
+
).describe("Schema defining audience trigger properties for form targeting");
|
|
750
|
+
|
|
751
|
+
// src/schemas/fields/form-properties-schema.ts
|
|
752
|
+
var otherConfigurationPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
753
|
+
// When other configuration is disabled
|
|
754
|
+
z8.object({
|
|
755
|
+
isEnabled: z8.literal(false).describe("Whether other configuration properties are enabled"),
|
|
756
|
+
otherFields: OtherFieldsSchema.optional().describe("Other form configuration fields including pagination, buttons, and display options"),
|
|
757
|
+
translations: OtherFieldsTranslationSchema.optional().describe("Translations for other configuration field labels and buttons")
|
|
758
|
+
}),
|
|
759
|
+
// When other configuration is enabled
|
|
760
|
+
z8.object({
|
|
761
|
+
isEnabled: z8.literal(true).describe("Whether other configuration properties are enabled"),
|
|
762
|
+
otherFields: OtherFieldsSchema.describe("Other form configuration fields including pagination, buttons, and display options"),
|
|
763
|
+
translations: OtherFieldsTranslationSchema.describe("Translations for other configuration field labels and buttons")
|
|
764
|
+
})
|
|
765
|
+
]).describe("Schema for other configuration properties including fields and translations");
|
|
766
|
+
var welcomeScreenPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
767
|
+
// When welcome screen is disabled
|
|
768
|
+
z8.object({
|
|
769
|
+
isEnabled: z8.literal(false).describe("Whether welcome screen is enabled"),
|
|
770
|
+
welcomeFields: WelcomeScreenFieldsSchema.optional().describe("Welcome screen configuration fields including title, description, and button label"),
|
|
771
|
+
translations: WelcomeFieldsTranslationSchema.optional().describe("Translations for welcome screen content")
|
|
772
|
+
}),
|
|
773
|
+
// When welcome screen is enabled
|
|
774
|
+
z8.object({
|
|
775
|
+
isEnabled: z8.literal(true).describe("Whether welcome screen is enabled"),
|
|
776
|
+
welcomeFields: WelcomeScreenFieldsSchema.describe("Welcome screen configuration fields including title, description, and button label"),
|
|
777
|
+
translations: WelcomeFieldsTranslationSchema.describe("Translations for welcome screen content")
|
|
778
|
+
})
|
|
779
|
+
]).describe("Schema for welcome screen properties including fields and translations");
|
|
780
|
+
var endScreenPropertiesSchema = z8.discriminatedUnion("isEnabled", [
|
|
781
|
+
// When end screen is disabled
|
|
782
|
+
z8.object({
|
|
783
|
+
isEnabled: z8.literal(false).describe("Whether end screen is enabled"),
|
|
784
|
+
endFields: EndScreenFieldsSchema.optional().describe("End screen configuration fields including title, message, button label, and dismissal behavior"),
|
|
785
|
+
translations: EndFieldsTranslationSchema.optional().describe("Translations for end screen content")
|
|
786
|
+
}),
|
|
787
|
+
// When end screen is enabled
|
|
788
|
+
z8.object({
|
|
789
|
+
isEnabled: z8.literal(true).describe("Whether end screen is enabled"),
|
|
790
|
+
endFields: EndScreenFieldsSchema.describe("End screen configuration fields including title, message, button label, and dismissal behavior"),
|
|
791
|
+
translations: EndFieldsTranslationSchema.describe("Translations for end screen content")
|
|
792
|
+
})
|
|
793
|
+
]).describe("Schema for end screen properties including fields and translations");
|
|
794
|
+
var appearancePropertiesSchema = z8.object({
|
|
795
|
+
themeConfiguration: themeConfigurationSchema.describe("Theme configuration including colors, features, and positioning")
|
|
796
|
+
}).describe("Schema for appearance properties including theme configuration");
|
|
797
|
+
var formPropertiesSchema = z8.object({
|
|
798
|
+
feedback_configuration_id: z8.uuid().describe("Unique identifier for the feedback configuration"),
|
|
799
|
+
feedback_configuration: feedbackConfigurationSchema.describe("Configuration properties for the feedback form"),
|
|
800
|
+
questionnaire_fields: z8.object({
|
|
801
|
+
questions: z8.record(z8.uuid(), combinedQuestionSchema).describe("Collection of questions keyed by their UUID identifiers"),
|
|
802
|
+
sections: z8.array(sectionSchema).describe("Array of sections that organize questions into logical groups"),
|
|
803
|
+
selected_languages: LanguagesSchema.describe("Array of languages selected for this questionnaire"),
|
|
804
|
+
translations: translationsSchema.describe("Multi-language translations for questions and form content")
|
|
805
|
+
}).describe("Fields defining the questionnaire structure, questions, sections, selected languages, and translations"),
|
|
806
|
+
frequency_and_scheduling_properties: frequencyAndSchedulingPropertiesSchema.describe("Properties controlling when and how often the feedback is shown"),
|
|
807
|
+
external_publishing_properties: externalPublishingPropertiesSchema.describe("Properties controlling external sharing and publishing of feedback results"),
|
|
808
|
+
audience_trigger_properties: audienceTriggerPropertiesSchema.describe("Properties defining audience targeting and trigger conditions for the feedback form"),
|
|
809
|
+
other_configuration_properties: otherConfigurationPropertiesSchema.describe("Additional configuration properties including form display options and translations"),
|
|
810
|
+
welcome_screen_properties: welcomeScreenPropertiesSchema.describe("Welcome screen configuration including content and translations"),
|
|
811
|
+
end_screen_properties: endScreenPropertiesSchema.describe("End screen configuration including content, dismissal behavior, and translations"),
|
|
812
|
+
appearance_properties: appearancePropertiesSchema.describe("Appearance configuration including themes, colors, and UI feature settings")
|
|
813
|
+
}).describe("Complete schema for all feedback-level properties including scheduling, publishing, audience targeting, configuration, screens, and appearance");
|
|
814
|
+
|
|
815
|
+
// src/index.ts
|
|
816
|
+
import { z as z9 } from "zod";
|
|
817
|
+
export {
|
|
818
|
+
AnswerSchema,
|
|
819
|
+
ChoiceAnswerSchema,
|
|
820
|
+
ContinuousSumAnswerSchema,
|
|
821
|
+
EndFieldsTranslationSchema,
|
|
822
|
+
EndScreenFieldsSchema,
|
|
823
|
+
LanguageFieldSchema,
|
|
824
|
+
LanguagesSchema,
|
|
825
|
+
MultipleChoiceAnswerSchema,
|
|
826
|
+
OtherFieldsSchema,
|
|
827
|
+
OtherFieldsTranslationSchema,
|
|
828
|
+
RankingAnswerSchema,
|
|
829
|
+
ScaleAnswerSchema,
|
|
830
|
+
SimpleAnswerSchema,
|
|
831
|
+
TextAnswerSchema,
|
|
832
|
+
TranslationProvider,
|
|
833
|
+
WelcomeFieldsTranslationSchema,
|
|
834
|
+
WelcomeScreenFieldsSchema,
|
|
835
|
+
annotationQuestionSchema,
|
|
836
|
+
annotationTranslationsSchema,
|
|
837
|
+
appearancePropertiesSchema,
|
|
838
|
+
audienceSegmentSchema,
|
|
839
|
+
audienceTriggerPropertiesSchema,
|
|
840
|
+
choiceOrderOptionSchema,
|
|
841
|
+
combinedQuestionSchema,
|
|
842
|
+
createTranslationProvider,
|
|
843
|
+
endScreenPropertiesSchema,
|
|
844
|
+
externalPublishingPropertiesSchema,
|
|
845
|
+
featureSettingsSchema,
|
|
846
|
+
feedbackConfigurationSchema,
|
|
847
|
+
formPropertiesSchema,
|
|
848
|
+
frequencyAndSchedulingPropertiesSchema,
|
|
849
|
+
languageTranslationsSchema,
|
|
850
|
+
longAnswerQuestionSchema,
|
|
851
|
+
longAnswerTranslationsSchema,
|
|
852
|
+
multipleChoiceDisplayStyleSchema,
|
|
853
|
+
multipleChoiceMultipleDisplayStyleSchema,
|
|
854
|
+
multipleChoiceMultipleQuestionSchema,
|
|
855
|
+
multipleChoiceSingleQuestionSchema,
|
|
856
|
+
multipleChoiceTranslationsSchema,
|
|
857
|
+
nestedDropdownQuestionSchema,
|
|
858
|
+
nestedOptionSchema,
|
|
859
|
+
nestedSelectionTranslationsSchema,
|
|
860
|
+
npsQuestionSchema,
|
|
861
|
+
npsTranslationsSchema,
|
|
862
|
+
otherConfigurationPropertiesSchema,
|
|
863
|
+
positionSchema,
|
|
864
|
+
publicationStatusSchema,
|
|
865
|
+
questionOptionSchema,
|
|
866
|
+
questionSchema,
|
|
867
|
+
questionStatusSchema,
|
|
868
|
+
questionTranslationsSchema,
|
|
869
|
+
questionTypeSchema,
|
|
870
|
+
ratingDisplayStyleSchema,
|
|
871
|
+
ratingQuestionSchema,
|
|
872
|
+
ratingRepresentationSizeSchema,
|
|
873
|
+
ratingTranslationsSchema,
|
|
874
|
+
recurringUnitSchema,
|
|
875
|
+
sectionSchema,
|
|
876
|
+
shortAnswerQuestionSchema,
|
|
877
|
+
shortAnswerTranslationsSchema,
|
|
878
|
+
singleChoiceTranslationsSchema,
|
|
879
|
+
surveyTypeSchema,
|
|
880
|
+
themeColorsSchema,
|
|
881
|
+
themeConfigurationSchema,
|
|
882
|
+
themesSchema,
|
|
883
|
+
translationEntrySchema,
|
|
884
|
+
translationsSchema,
|
|
885
|
+
validationRuleSchema,
|
|
886
|
+
visibilityConditionSchema,
|
|
887
|
+
welcomeScreenPropertiesSchema,
|
|
888
|
+
yesNoSchema,
|
|
889
|
+
z9 as z
|
|
890
|
+
};
|
|
891
|
+
//# sourceMappingURL=index.js.map
|