@encatch/schema 1.0.0 → 1.0.1-beta.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/dist/esm/index.js CHANGED
@@ -11,7 +11,14 @@ var questionTypeSchema = z.enum([
11
11
  "multiple_choice_multiple",
12
12
  "short_answer",
13
13
  "long_text",
14
- "annotation"
14
+ "annotation",
15
+ "welcome",
16
+ "thank_you",
17
+ "message_panel",
18
+ "yes_no",
19
+ "rating_matrix",
20
+ "matrix_single_choice",
21
+ "matrix_multiple_choice"
15
22
  ]).describe("Enumeration of all supported question types for form fields");
16
23
  var QuestionTypes = {
17
24
  RATING: "rating",
@@ -21,7 +28,14 @@ var QuestionTypes = {
21
28
  MULTIPLE_CHOICE_MULTIPLE: "multiple_choice_multiple",
22
29
  SHORT_ANSWER: "short_answer",
23
30
  LONG_TEXT: "long_text",
24
- ANNOTATION: "annotation"
31
+ ANNOTATION: "annotation",
32
+ WELCOME: "welcome",
33
+ THANK_YOU: "thank_you",
34
+ MESSAGE_PANEL: "message_panel",
35
+ YES_NO: "yes_no",
36
+ RATING_MATRIX: "rating_matrix",
37
+ MATRIX_SINGLE_CHOICE: "matrix_single_choice",
38
+ MATRIX_MULTIPLE_CHOICE: "matrix_multiple_choice"
25
39
  };
26
40
  var validationRuleTypeSchema = z.enum([
27
41
  "required",
@@ -139,6 +153,11 @@ var MultipleChoiceMultipleDisplayStyles = {
139
153
  LIST: "list",
140
154
  CHIP: "chip"
141
155
  };
156
+ var yesNoDisplayStyleSchema = z.enum(["horizontal", "vertical"]);
157
+ var YesNoDisplayStyles = {
158
+ HORIZONTAL: "horizontal",
159
+ VERTICAL: "vertical"
160
+ };
142
161
  var choiceOrderOptionSchema = z.enum([
143
162
  "randomize",
144
163
  "flip",
@@ -160,6 +179,7 @@ var questionSchema = z.object({
160
179
  ),
161
180
  title: z.string().min(1).max(200).describe("The main title/question text displayed to users"),
162
181
  description: z.string().max(1e3).optional().describe("Optional detailed description or help text"),
182
+ descriptionMarkdown: z.string().max(5e3).optional().describe("Optional description in Markdown format"),
163
183
  describe: z.string().max(2e3).optional().describe(
164
184
  "LLM tool call description for better AI understanding and context"
165
185
  ),
@@ -190,6 +210,133 @@ var annotationQuestionSchema = questionSchema.extend({
190
210
  }).describe(
191
211
  "Schema for annotation questions that provide additional context or instructions"
192
212
  );
213
+ var welcomeQuestionSchema = questionSchema.extend({
214
+ type: z.literal("welcome").describe("Must be exactly 'welcome'"),
215
+ title: z.string().min(1).max(200).describe("The main heading displayed on the welcome screen"),
216
+ description: z.string().max(1e3).optional().describe("Optional sub-text body shown below the heading"),
217
+ buttonLabel: z.string().min(1).max(50).optional().describe("Label for the proceed/start button (e.g. 'Get Started', 'Begin')"),
218
+ imageUrl: z.string().url().optional().describe("Optional image URL displayed on the welcome screen")
219
+ }).describe("Schema for a welcome screen displayed at the start or inline within a form");
220
+ var thankYouQuestionSchema = questionSchema.extend({
221
+ type: z.literal("thank_you").describe("Must be exactly 'thank_you'"),
222
+ title: z.string().min(1).max(200).describe("The main heading displayed on the thank you screen"),
223
+ description: z.string().max(1e3).optional().describe(
224
+ "Optional thank you body text (plain); use descriptionMarkdown for rich content"
225
+ ),
226
+ buttonLabel: z.string().min(1).max(50).optional().describe("Label for the dismiss/done button (e.g. 'Done', 'Close')"),
227
+ imageUrl: z.string().url().optional().describe("Optional image URL displayed on the thank you screen")
228
+ }).describe(
229
+ "Schema for a thank you screen shown at the end or inline within a form; use descriptionMarkdown from the base question for rich copy"
230
+ );
231
+ var messagePanelQuestionSchema = questionSchema.extend({
232
+ type: z.literal("message_panel").describe("Must be exactly 'message_panel'"),
233
+ title: z.string().min(1).max(200).describe("The main heading displayed on the message panel"),
234
+ description: z.string().max(1e3).optional().describe("Optional body text shown below the heading"),
235
+ buttonLabel: z.string().min(1).max(50).optional().describe("Label for the continue button (e.g. 'Continue', 'Next')"),
236
+ imageUrl: z.string().url().optional().describe("Optional image URL displayed on the message panel")
237
+ }).describe(
238
+ "Schema for an inline message panel (informational); distinct from welcome for UI semantics and analytics"
239
+ );
240
+ var yesNoQuestionSchema = questionSchema.extend({
241
+ type: z.literal("yes_no").describe("Must be exactly 'yes_no'"),
242
+ yesLabel: z.string().min(1).max(50).optional().describe("Label for the Yes option (defaults to 'Yes' in the UI if omitted)"),
243
+ noLabel: z.string().min(1).max(50).optional().describe("Label for the No option (defaults to 'No' in the UI if omitted)"),
244
+ displayStyle: yesNoDisplayStyleSchema.optional().describe("Layout for the Yes/No controls (horizontal row or vertical stack)")
245
+ }).describe("Schema for yes/no questions with optional custom labels and layout");
246
+ var ratingMatrixDisplayStyleSchema = z.enum([
247
+ "radio",
248
+ "star",
249
+ "emoji",
250
+ "button"
251
+ ]);
252
+ var RatingMatrixDisplayStyles = {
253
+ RADIO: "radio",
254
+ STAR: "star",
255
+ EMOJI: "emoji",
256
+ BUTTON: "button"
257
+ };
258
+ var ratingMatrixStatementSchema = z.object({
259
+ id: z.string().describe("Unique identifier for this statement (system time milliseconds)"),
260
+ value: z.string().min(1).max(100).describe("Internal value / export key for this statement"),
261
+ label: z.string().min(1).max(200).describe("Display text shown to users for this statement"),
262
+ describe: z.string().max(500).optional().describe("LLM tool call description for this statement")
263
+ }).describe("Schema for an individual statement (row) in a rating matrix");
264
+ var ratingMatrixScalePointSchema = z.object({
265
+ id: z.string().describe("Unique identifier for this scale point"),
266
+ value: z.union([z.number(), z.string()]).describe("Stored response value for this scale point (number or string)"),
267
+ label: z.string().min(1).max(200).describe("Display label shown for this scale point"),
268
+ describe: z.string().max(500).optional().describe("LLM tool call description for this scale point")
269
+ }).describe("Schema for a single point on a custom rating scale");
270
+ var ratingMatrixScaleSchema = z.discriminatedUnion("kind", [
271
+ // Likert: symmetric ordinal scale -2…+2, implicit 5 points
272
+ z.object({
273
+ kind: z.literal("likert").describe("Symmetric ordinal scale (-2 to +2)"),
274
+ minLabel: z.string().max(100).optional().describe("Optional label for the negative end of the Likert scale"),
275
+ maxLabel: z.string().max(100).optional().describe("Optional label for the positive end of the Likert scale")
276
+ }),
277
+ // Numerical: 1…N points where N is 2, 3, 4, or 5
278
+ z.object({
279
+ kind: z.literal("numerical").describe("Numerical scale from 1 to N (N = 2-5)"),
280
+ pointCount: z.union([z.literal(2), z.literal(3), z.literal(4), z.literal(5)]).describe("Number of scale points (2, 3, 4, or 5)"),
281
+ minLabel: z.string().max(100).optional().describe("Optional label for the lowest numerical value"),
282
+ maxLabel: z.string().max(100).optional().describe("Optional label for the highest numerical value")
283
+ }),
284
+ // Custom: consumer defines each point's value and label
285
+ z.object({
286
+ kind: z.literal("custom").describe("Custom scale with user-defined points and values"),
287
+ scalePoints: z.array(ratingMatrixScalePointSchema).min(2).max(5).describe("User-defined scale points (2-5 points)")
288
+ })
289
+ ]).describe("Scale configuration for rating matrix questions");
290
+ var ratingMatrixQuestionSchema = questionSchema.extend({
291
+ type: z.literal("rating_matrix").describe("Must be exactly 'rating_matrix'"),
292
+ statements: z.array(ratingMatrixStatementSchema).min(1).max(10).describe("Statements (rows) users will rate on the shared scale (1-10)"),
293
+ scale: ratingMatrixScaleSchema.describe("Scale configuration shared across all statement rows"),
294
+ displayStyle: ratingMatrixDisplayStyleSchema.optional().describe(
295
+ "Visual representation of scale points per row (radio buttons, stars, emoji, or buttons)"
296
+ ),
297
+ randomizeStatements: z.boolean().optional().default(false).describe("Whether to randomize the order of statements")
298
+ }).describe("Schema for rating matrix questions with multiple statements on a shared scale");
299
+ var matrixRowSchema = z.object({
300
+ id: z.string().describe("Unique identifier for this row (system time milliseconds)"),
301
+ value: z.string().min(1).max(100).describe("Internal value / export key for this row"),
302
+ label: z.string().min(1).max(200).describe("Display text shown to users for this row"),
303
+ describe: z.string().max(500).optional().describe("LLM tool call description for this row")
304
+ }).describe("Schema for an individual row in a matrix choice question");
305
+ var matrixColumnSchema = z.object({
306
+ id: z.string().describe("Unique identifier for this column (system time milliseconds)"),
307
+ value: z.string().min(1).max(100).describe("Internal value / export key for this column"),
308
+ label: z.string().min(1).max(200).describe("Display label shown for this column"),
309
+ describe: z.string().max(500).optional().describe("LLM tool call description for this column")
310
+ }).describe("Schema for an individual column in a matrix choice question");
311
+ var matrixSingleChoiceQuestionSchema = questionSchema.extend({
312
+ type: z.literal("matrix_single_choice").describe("Must be exactly 'matrix_single_choice'"),
313
+ rows: z.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
314
+ columns: z.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
315
+ randomizeRows: z.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
316
+ randomizeColumns: z.boolean().optional().default(false).describe("Whether to randomize the order of columns")
317
+ }).describe("Schema for matrix single-choice questions where one column is selected per row");
318
+ var matrixMultipleChoiceQuestionSchema = questionSchema.extend({
319
+ type: z.literal("matrix_multiple_choice").describe("Must be exactly 'matrix_multiple_choice'"),
320
+ rows: z.array(matrixRowSchema).min(1).max(20).describe("Row items (1-20 rows)"),
321
+ columns: z.array(matrixColumnSchema).min(2).max(10).describe("Column options shared across all rows (2-10 columns)"),
322
+ minSelectionsPerRow: z.number().int().min(0).optional().describe("Minimum number of columns a user must select per row"),
323
+ maxSelectionsPerRow: z.number().int().min(1).optional().describe("Maximum number of columns a user can select per row"),
324
+ randomizeRows: z.boolean().optional().default(false).describe("Whether to randomize the order of rows"),
325
+ randomizeColumns: z.boolean().optional().default(false).describe("Whether to randomize the order of columns")
326
+ }).refine(
327
+ (data) => {
328
+ if (data.minSelectionsPerRow !== void 0 && data.maxSelectionsPerRow !== void 0) {
329
+ return data.minSelectionsPerRow <= data.maxSelectionsPerRow;
330
+ }
331
+ return true;
332
+ },
333
+ {
334
+ message: "minSelectionsPerRow cannot be greater than maxSelectionsPerRow",
335
+ path: ["minSelectionsPerRow"]
336
+ }
337
+ ).describe(
338
+ "Schema for matrix multiple-choice questions where one or more columns can be selected per row"
339
+ );
193
340
  var questionOptionSchema = z.object({
194
341
  id: z.string().describe("Unique identifier for this option (system time milliseconds)"),
195
342
  value: z.string().min(1).max(100).describe("The internal value used for this option"),
@@ -285,8 +432,6 @@ var shortAnswerQuestionSchema = questionSchema.extend({
285
432
  regexPattern: z.string().optional().describe("Regular expression pattern for validation"),
286
433
  enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
287
434
  promptTemplate: z.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
288
- cooldownSeconds: z.number().int().min(0).max(3600).optional().describe("Cooldown period between AI enhancements (0-3600 seconds)"),
289
- maxEnhancements: z.number().int().min(1).max(10).optional().describe("Maximum number of AI enhancements allowed"),
290
435
  maxTokenAllowed: z.number().int().min(1).max(1e4).optional().describe("Maximum tokens allowed for AI processing"),
291
436
  minCharactersToEnhance: z.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
292
437
  }).refine(
@@ -333,8 +478,6 @@ var longAnswerQuestionSchema = questionSchema.extend({
333
478
  placeholder: z.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
334
479
  enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
335
480
  promptTemplate: z.string().max(2e3).optional().describe("Template for AI enhancement prompts"),
336
- cooldownSeconds: z.number().int().min(0).max(3600).optional().describe("Cooldown period between AI enhancements (0-3600 seconds)"),
337
- maxEnhancements: z.number().int().min(1).max(10).optional().describe("Maximum number of AI enhancements allowed"),
338
481
  maxTokenAllowed: z.number().int().min(1).max(25e3).optional().describe(
339
482
  "Maximum tokens allowed for AI processing (higher for long text)"
340
483
  ),
@@ -395,6 +538,13 @@ var nestedDropdownQuestionSchema = questionSchema.extend({
395
538
  var combinedQuestionSchema = z.discriminatedUnion("type", [
396
539
  ratingQuestionSchema,
397
540
  annotationQuestionSchema,
541
+ welcomeQuestionSchema,
542
+ thankYouQuestionSchema,
543
+ messagePanelQuestionSchema,
544
+ yesNoQuestionSchema,
545
+ ratingMatrixQuestionSchema,
546
+ matrixSingleChoiceQuestionSchema,
547
+ matrixMultipleChoiceQuestionSchema,
398
548
  multipleChoiceSingleQuestionSchema,
399
549
  multipleChoiceMultipleQuestionSchema,
400
550
  npsQuestionSchema,
@@ -424,6 +574,7 @@ var AnswerItemSchema = z2.object({
424
574
  "single selected option ID (for single choice questions)"
425
575
  ),
426
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)"),
427
578
  multipleChoiceMultiple: z2.array(z2.string()).optional().describe("Array of selected option IDs for multiple choice questions"),
428
579
  singleChoiceOther: z2.string().optional().describe(
429
580
  'Free-text "other" answer for single choice questions when allowOther is enabled'
@@ -434,6 +585,15 @@ var AnswerItemSchema = z2.object({
434
585
  annotation: AnnotationSchema.optional().describe(
435
586
  "Annotation object containing file and marker details"
436
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
+ ),
437
597
  others: z2.string().optional().describe(
438
598
  "For multiple choice questions and single choice questions, this is the value of the other option"
439
599
  )
@@ -559,93 +719,160 @@ import { z as z8 } from "zod";
559
719
  // src/schemas/fields/translations-schema.ts
560
720
  import { z as z4 } from "zod";
561
721
  var translationEntrySchema = z4.string().min(1).describe("Translated text content");
562
- var ratingQuestionTranslationSchema = z4.object({
563
- type: z4.literal("rating").describe("Question type identifier"),
722
+ var baseQuestionTranslationFieldsSchema = z4.object({
564
723
  title: translationEntrySchema.describe("Question title translation"),
565
724
  description: translationEntrySchema.optional().describe("Question description translation"),
566
- errorMessage: translationEntrySchema.optional().describe("Error message 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"),
567
737
  minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
568
738
  maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
569
739
  }).describe("Translation schema for rating questions");
570
- var singleChoiceQuestionTranslationSchema = z4.object({
740
+ var singleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
571
741
  type: z4.literal("single_choice").describe("Question type identifier"),
572
- title: translationEntrySchema.describe("Question title translation"),
573
- description: translationEntrySchema.optional().describe("Question description translation"),
574
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
575
742
  placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
576
- }).catchall(translationEntrySchema).refine((data) => {
577
- const additionalKeys = Object.keys(data).filter(
578
- (key) => !["type", "title", "description", "errorMessage", "placeholder"].includes(key)
579
- );
580
- return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
581
- }, {
582
- message: "Additional keys must follow the pattern 'option.{id}.{label|value}'"
583
- }).describe("Translation schema for single choice questions");
584
- var multipleChoiceQuestionTranslationSchema = z4.object({
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({
585
753
  type: z4.literal("multiple_choice_multiple").describe("Question type identifier"),
586
- title: translationEntrySchema.describe("Question title translation"),
587
- description: translationEntrySchema.optional().describe("Question description translation"),
588
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
589
754
  placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
590
- }).catchall(translationEntrySchema).refine((data) => {
591
- const additionalKeys = Object.keys(data).filter(
592
- (key) => !["type", "title", "description", "errorMessage", "placeholder"].includes(key)
593
- );
594
- return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
595
- }, {
596
- message: "Additional keys must follow the pattern 'option.{id}.{label|value}'"
597
- }).describe("Translation schema for multiple choice questions");
598
- var npsQuestionTranslationSchema = z4.object({
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({
599
765
  type: z4.literal("nps").describe("Question type identifier"),
600
- title: translationEntrySchema.describe("Question title translation"),
601
- description: translationEntrySchema.optional().describe("Question description translation"),
602
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
603
766
  minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
604
767
  maxLabel: translationEntrySchema.optional().describe("Maximum NPS label (10) translation")
605
- }).catchall(translationEntrySchema).refine((data) => {
606
- const additionalKeys = Object.keys(data).filter(
607
- (key) => !["type", "title", "description", "errorMessage", "minLabel", "maxLabel"].includes(key)
608
- );
609
- return additionalKeys.every((key) => /^scaleLabel\.\d+$/.test(key));
610
- }, {
611
- message: "Additional keys must follow the pattern 'scaleLabel.{number}'"
612
- }).describe("Translation schema for NPS questions");
613
- var shortAnswerQuestionTranslationSchema = z4.object({
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({
614
778
  type: z4.literal("short_answer").describe("Question type identifier"),
615
- title: translationEntrySchema.describe("Question title translation"),
616
- description: translationEntrySchema.optional().describe("Question description translation"),
617
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
618
779
  placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
619
780
  }).describe("Translation schema for short answer questions");
620
- var longAnswerQuestionTranslationSchema = z4.object({
781
+ var longAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
621
782
  type: z4.literal("long_text").describe("Question type identifier"),
622
- title: translationEntrySchema.describe("Question title translation"),
623
- description: translationEntrySchema.optional().describe("Question description translation"),
624
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
625
783
  placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
626
784
  }).describe("Translation schema for long answer questions");
627
- var nestedSelectionQuestionTranslationSchema = z4.object({
785
+ var nestedSelectionQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
628
786
  type: z4.literal("nested_selection").describe("Question type identifier"),
629
- title: translationEntrySchema.describe("Question title translation"),
630
- description: translationEntrySchema.optional().describe("Question description translation"),
631
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
632
787
  placeholder: translationEntrySchema.optional().describe("Dropdown placeholder translation")
633
- }).catchall(translationEntrySchema).refine((data) => {
634
- const additionalKeys = Object.keys(data).filter(
635
- (key) => !["type", "title", "description", "errorMessage", "placeholder"].includes(key)
636
- );
637
- return additionalKeys.every((key) => /^nestedOption\..+\.(label|hint)$/.test(key));
638
- }, {
639
- message: "Additional keys must follow the pattern 'nestedOption.{id}.{label|hint}'"
640
- }).describe("Translation schema for nested selection questions");
641
- var annotationQuestionTranslationSchema = z4.object({
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({
642
798
  type: z4.literal("annotation").describe("Question type identifier"),
643
- title: translationEntrySchema.describe("Question title translation"),
644
- description: translationEntrySchema.optional().describe("Question description translation"),
645
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
646
799
  annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
647
800
  noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
648
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
+ );
841
+ },
842
+ {
843
+ message: "Additional keys must follow 'statement.{id}.label' or 'scalePoint.{id}.label'"
844
+ }
845
+ ).describe("Translation schema for rating matrix questions");
846
+ var matrixSingleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
847
+ type: z4.literal("matrix_single_choice").describe("Question type identifier")
848
+ }).catchall(translationEntrySchema).refine(
849
+ (data) => {
850
+ const additionalKeys = Object.keys(data).filter(
851
+ (key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
852
+ );
853
+ return additionalKeys.every(
854
+ (key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
855
+ );
856
+ },
857
+ {
858
+ message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
859
+ }
860
+ ).describe("Translation schema for matrix single-choice questions");
861
+ var matrixMultipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
862
+ type: z4.literal("matrix_multiple_choice").describe("Question type identifier")
863
+ }).catchall(translationEntrySchema).refine(
864
+ (data) => {
865
+ const additionalKeys = Object.keys(data).filter(
866
+ (key) => !BASE_QUESTION_TRANSLATION_KEYS.includes(key)
867
+ );
868
+ return additionalKeys.every(
869
+ (key) => /^row\..+\.label$/.test(key) || /^column\..+\.label$/.test(key)
870
+ );
871
+ },
872
+ {
873
+ message: "Additional keys must follow 'row.{id}.label' or 'column.{id}.label'"
874
+ }
875
+ ).describe("Translation schema for matrix multiple-choice questions");
649
876
  var questionTranslationSchema = z4.union([
650
877
  ratingQuestionTranslationSchema,
651
878
  singleChoiceQuestionTranslationSchema,
@@ -654,7 +881,14 @@ var questionTranslationSchema = z4.union([
654
881
  shortAnswerQuestionTranslationSchema,
655
882
  longAnswerQuestionTranslationSchema,
656
883
  nestedSelectionQuestionTranslationSchema,
657
- annotationQuestionTranslationSchema
884
+ annotationQuestionTranslationSchema,
885
+ welcomeQuestionTranslationSchema,
886
+ thankYouQuestionTranslationSchema,
887
+ messagePanelQuestionTranslationSchema,
888
+ yesNoQuestionTranslationSchema,
889
+ ratingMatrixQuestionTranslationSchema,
890
+ matrixSingleChoiceQuestionTranslationSchema,
891
+ matrixMultipleChoiceQuestionTranslationSchema
658
892
  ]).describe("Union of all question type translation schemas");
659
893
  var languageCodeSchema = z4.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
660
894
  var questionTranslationsByLanguageSchema = z4.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
@@ -844,6 +1078,7 @@ var ShareableModes = {
844
1078
  DARK: "dark",
845
1079
  SYSTEM: "system"
846
1080
  };
1081
+ var previousButtonModeSchema = z6.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto");
847
1082
  var featureSettingsSchema = z6.object({
848
1083
  darkOverlay: z6.boolean().describe("Whether to show a dark overlay behind the widget"),
849
1084
  closeButton: z6.boolean().describe("Whether to display a close button on the widget"),
@@ -854,7 +1089,10 @@ var featureSettingsSchema = z6.object({
854
1089
  customCss: z6.string().optional().describe("Custom CSS link to apply for the feedback form"),
855
1090
  shareableMode: shareableModeSchema.optional().describe(
856
1091
  "Display mode for the shareable: light, dark, or system preference"
857
- )
1092
+ ),
1093
+ allowMultipleQuestionsPerSection: z6.boolean().describe("Whether to allow multiple questions per section"),
1094
+ rtl: z6.boolean().describe("Whether right-to-left text direction is enabled"),
1095
+ previousButton: previousButtonModeSchema.describe("Previous button visibility mode: never, always, or auto")
858
1096
  }).describe("Feature settings controlling widget UI behavior and appearance");
859
1097
  var themeColorsSchema = z6.object({
860
1098
  theme: z6.string().optional().describe("Theme for a single mode (shadcn variables JSON)")
@@ -1143,7 +1381,10 @@ var feedbackConfigurationItemSchema = z12.object({
1143
1381
  showBranding: z12.boolean().describe("Whether to show branding"),
1144
1382
  customPosition: z12.boolean().describe("Whether custom position is enabled"),
1145
1383
  customIconPosition: z12.boolean().describe("Whether custom icon position is enabled"),
1146
- customCss: z12.string().nullable().optional().describe("Custom CSS link (optional)")
1384
+ customCss: z12.string().nullable().optional().describe("Custom CSS link (optional)"),
1385
+ allowMultipleQuestionsPerSection: z12.boolean().describe("Whether to allow multiple questions per section"),
1386
+ rtl: z12.boolean().describe("Whether right-to-left text direction is enabled"),
1387
+ previousButton: z12.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto")
1147
1388
  }).describe("Feature settings for the feedback form"),
1148
1389
  selectedIconPosition: z12.string().describe("Selected position for the feedback icon"),
1149
1390
  selectedPosition: z12.string().describe("Selected position for the feedback form")
@@ -1221,22 +1462,20 @@ var fetchConfigurationListResponseSchema = z12.object({
1221
1462
  import { z as z13 } from "zod";
1222
1463
  var refineTextParamsSchema = z13.object({
1223
1464
  questionId: z13.string().describe("Unique identifier for the question"),
1224
- identifier: z13.string().uuid().describe("Unique identifier for the feedback instance"),
1225
1465
  feedbackConfigurationId: z13.string().uuid().describe("Unique identifier for the feedback configuration"),
1226
1466
  userText: z13.string().describe("Original text input from the user")
1227
1467
  }).strict().describe("Request schema for refining user text input");
1468
+ var refineTextResponseSchema = z13.object({
1469
+ message: z13.string().optional().describe("Human-readable message"),
1470
+ refinedText: z13.string().optional().describe("Refined/improved version of the user text (success only)"),
1471
+ status: z13.number().optional().describe("HTTP status code (error responses)"),
1472
+ error: z13.string().optional().describe("Error type (error responses)"),
1473
+ code: z13.string().optional().describe("Error code for display mapping")
1474
+ }).describe("Response schema for refine text API operation");
1228
1475
  var refineTextDataSchema = z13.object({
1229
1476
  userText: z13.string().describe("Original text input from the user"),
1230
1477
  refinedText: z13.string().describe("Refined/improved version of the user text")
1231
- }).describe("Data containing original and refined text");
1232
- var refineTextResponseSchema = z13.object({
1233
- success: z13.boolean().describe("Indicates whether the operation was successful"),
1234
- code: z13.string().describe("Response code indicating the status"),
1235
- message: z13.string().describe("Human-readable message describing the result"),
1236
- messageId: z13.string().describe("Unique identifier for the response message"),
1237
- data: refineTextDataSchema.describe("Response data containing original and refined text"),
1238
- error: z13.string().optional().describe("Error message if the operation failed (optional)")
1239
- }).strict().describe("Response schema for refine text API operation");
1478
+ }).describe("Data containing original and refined text (legacy nested format)");
1240
1479
 
1241
1480
  // src/helpers/case-convert-helper.ts
1242
1481
  function convertObject(obj, keyConverter) {
@@ -1371,6 +1610,7 @@ export {
1371
1610
  QuestionStatuses,
1372
1611
  QuestionTypes,
1373
1612
  RatingDisplayStyles,
1613
+ RatingMatrixDisplayStyles,
1374
1614
  RatingRepresentationSizes,
1375
1615
  RecurringUnits,
1376
1616
  ShareableModes,
@@ -1381,6 +1621,7 @@ export {
1381
1621
  VisibilityConditionOperators,
1382
1622
  WelcomeFieldsTranslationSchema,
1383
1623
  WelcomeScreenFieldsSchema,
1624
+ YesNoDisplayStyles,
1384
1625
  YesNoValues,
1385
1626
  annotationQuestionSchema,
1386
1627
  annotationQuestionTranslationSchema,
@@ -1423,6 +1664,14 @@ export {
1423
1664
  longAnswerQuestionTranslationSchema,
1424
1665
  masterPropertiesSchema,
1425
1666
  matchedTriggerPropertiesSchema,
1667
+ matrixColumnSchema,
1668
+ matrixMultipleChoiceQuestionSchema,
1669
+ matrixMultipleChoiceQuestionTranslationSchema,
1670
+ matrixRowSchema,
1671
+ matrixSingleChoiceQuestionSchema,
1672
+ matrixSingleChoiceQuestionTranslationSchema,
1673
+ messagePanelQuestionSchema,
1674
+ messagePanelQuestionTranslationSchema,
1426
1675
  multipleChoiceDisplayStyleSchema,
1427
1676
  multipleChoiceMultipleDisplayStyleSchema,
1428
1677
  multipleChoiceMultipleQuestionSchema,
@@ -1450,6 +1699,12 @@ export {
1450
1699
  questionTypeSchema,
1451
1700
  questionnaireFieldsResponseSchema,
1452
1701
  ratingDisplayStyleSchema,
1702
+ ratingMatrixDisplayStyleSchema,
1703
+ ratingMatrixQuestionSchema,
1704
+ ratingMatrixQuestionTranslationSchema,
1705
+ ratingMatrixScalePointSchema,
1706
+ ratingMatrixScaleSchema,
1707
+ ratingMatrixStatementSchema,
1453
1708
  ratingQuestionSchema,
1454
1709
  ratingQuestionTranslationSchema,
1455
1710
  ratingRepresentationSizeSchema,
@@ -1466,6 +1721,8 @@ export {
1466
1721
  singleChoiceQuestionTranslationSchema,
1467
1722
  submitFeedbackSchema,
1468
1723
  surveyTypeSchema,
1724
+ thankYouQuestionSchema,
1725
+ thankYouQuestionTranslationSchema,
1469
1726
  themeColorsSchema,
1470
1727
  themeConfigurationSchema,
1471
1728
  themeModeSchema,
@@ -1481,8 +1738,13 @@ export {
1481
1738
  validationRuleSchema,
1482
1739
  validationRuleTypeSchema,
1483
1740
  visibilityConditionSchema,
1741
+ welcomeQuestionSchema,
1742
+ welcomeQuestionTranslationSchema,
1484
1743
  welcomeScreenPropertiesSchema,
1485
1744
  whoSchema,
1745
+ yesNoDisplayStyleSchema,
1746
+ yesNoQuestionSchema,
1747
+ yesNoQuestionTranslationSchema,
1486
1748
  yesNoSchema,
1487
1749
  z15 as z
1488
1750
  };