@encatch/schema 1.0.0-beta.1 → 1.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -160,6 +160,7 @@ var questionSchema = z.object({
160
160
  ),
161
161
  title: z.string().min(1).max(200).describe("The main title/question text displayed to users"),
162
162
  description: z.string().max(1e3).optional().describe("Optional detailed description or help text"),
163
+ descriptionMarkdown: z.string().max(5e3).optional().describe("Optional description in Markdown format"),
163
164
  describe: z.string().max(2e3).optional().describe(
164
165
  "LLM tool call description for better AI understanding and context"
165
166
  ),
@@ -285,8 +286,6 @@ var shortAnswerQuestionSchema = questionSchema.extend({
285
286
  regexPattern: z.string().optional().describe("Regular expression pattern for validation"),
286
287
  enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
287
288
  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
289
  maxTokenAllowed: z.number().int().min(1).max(1e4).optional().describe("Maximum tokens allowed for AI processing"),
291
290
  minCharactersToEnhance: z.number().int().min(1).optional().describe("Minimum characters needed to trigger AI enhancement")
292
291
  }).refine(
@@ -333,8 +332,6 @@ var longAnswerQuestionSchema = questionSchema.extend({
333
332
  placeholder: z.string().max(500).optional().describe("Placeholder text for the textarea (longer for long text)"),
334
333
  enableEnhanceWithAi: z.boolean().optional().default(false).describe("Whether to enable AI enhancement features"),
335
334
  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
335
  maxTokenAllowed: z.number().int().min(1).max(25e3).optional().describe(
339
336
  "Maximum tokens allowed for AI processing (higher for long text)"
340
337
  ),
@@ -559,90 +556,83 @@ import { z as z8 } from "zod";
559
556
  // src/schemas/fields/translations-schema.ts
560
557
  import { z as z4 } from "zod";
561
558
  var translationEntrySchema = z4.string().min(1).describe("Translated text content");
562
- var ratingQuestionTranslationSchema = z4.object({
563
- type: z4.literal("rating").describe("Question type identifier"),
559
+ var baseQuestionTranslationFieldsSchema = z4.object({
564
560
  title: translationEntrySchema.describe("Question title translation"),
565
561
  description: translationEntrySchema.optional().describe("Question description translation"),
566
- errorMessage: translationEntrySchema.optional().describe("Error message translation"),
562
+ descriptionMarkdown: translationEntrySchema.optional().describe("Question description Markdown translation"),
563
+ errorMessage: translationEntrySchema.optional().describe("Error message translation")
564
+ });
565
+ var BASE_QUESTION_TRANSLATION_KEYS = [
566
+ "type",
567
+ "title",
568
+ "description",
569
+ "descriptionMarkdown",
570
+ "errorMessage"
571
+ ];
572
+ var ratingQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
573
+ type: z4.literal("rating").describe("Question type identifier"),
567
574
  minLabel: translationEntrySchema.optional().describe("Minimum rating label translation"),
568
575
  maxLabel: translationEntrySchema.optional().describe("Maximum rating label translation")
569
576
  }).describe("Translation schema for rating questions");
570
- var singleChoiceQuestionTranslationSchema = z4.object({
577
+ var singleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
571
578
  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
579
  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({
580
+ }).catchall(translationEntrySchema).refine(
581
+ (data) => {
582
+ const additionalKeys = Object.keys(data).filter(
583
+ (key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
584
+ );
585
+ return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
586
+ },
587
+ { message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
588
+ ).describe("Translation schema for single choice questions");
589
+ var multipleChoiceQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
585
590
  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
591
  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({
592
+ }).catchall(translationEntrySchema).refine(
593
+ (data) => {
594
+ const additionalKeys = Object.keys(data).filter(
595
+ (key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
596
+ );
597
+ return additionalKeys.every((key) => /^option\..+\.(label|value)$/.test(key));
598
+ },
599
+ { message: "Additional keys must follow the pattern 'option.{id}.{label|value}'" }
600
+ ).describe("Translation schema for multiple choice questions");
601
+ var npsQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
599
602
  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
603
  minLabel: translationEntrySchema.optional().describe("Minimum NPS label (0) translation"),
604
604
  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({
605
+ }).catchall(translationEntrySchema).refine(
606
+ (data) => {
607
+ const additionalKeys = Object.keys(data).filter(
608
+ (key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "minLabel", "maxLabel"].includes(key)
609
+ );
610
+ return additionalKeys.every((key) => /^scaleLabel\.\d+$/.test(key));
611
+ },
612
+ { message: "Additional keys must follow the pattern 'scaleLabel.{number}'" }
613
+ ).describe("Translation schema for NPS questions");
614
+ var shortAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
614
615
  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
616
  placeholder: translationEntrySchema.optional().describe("Input placeholder translation")
619
617
  }).describe("Translation schema for short answer questions");
620
- var longAnswerQuestionTranslationSchema = z4.object({
618
+ var longAnswerQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
621
619
  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
620
  placeholder: translationEntrySchema.optional().describe("Textarea placeholder translation")
626
621
  }).describe("Translation schema for long answer questions");
627
- var nestedSelectionQuestionTranslationSchema = z4.object({
622
+ var nestedSelectionQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
628
623
  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
624
  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({
625
+ }).catchall(translationEntrySchema).refine(
626
+ (data) => {
627
+ const additionalKeys = Object.keys(data).filter(
628
+ (key) => ![...BASE_QUESTION_TRANSLATION_KEYS, "placeholder"].includes(key)
629
+ );
630
+ return additionalKeys.every((key) => /^nestedOption\..+\.(label|hint)$/.test(key));
631
+ },
632
+ { message: "Additional keys must follow the pattern 'nestedOption.{id}.{label|hint}'" }
633
+ ).describe("Translation schema for nested selection questions");
634
+ var annotationQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
642
635
  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
636
  annotationText: translationEntrySchema.optional().describe("Annotation display text translation"),
647
637
  noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
648
638
  }).describe("Translation schema for annotation questions");
@@ -1221,22 +1211,20 @@ var fetchConfigurationListResponseSchema = z12.object({
1221
1211
  import { z as z13 } from "zod";
1222
1212
  var refineTextParamsSchema = z13.object({
1223
1213
  questionId: z13.string().describe("Unique identifier for the question"),
1224
- identifier: z13.string().uuid().describe("Unique identifier for the feedback instance"),
1225
1214
  feedbackConfigurationId: z13.string().uuid().describe("Unique identifier for the feedback configuration"),
1226
1215
  userText: z13.string().describe("Original text input from the user")
1227
1216
  }).strict().describe("Request schema for refining user text input");
1217
+ var refineTextResponseSchema = z13.object({
1218
+ message: z13.string().optional().describe("Human-readable message"),
1219
+ refinedText: z13.string().optional().describe("Refined/improved version of the user text (success only)"),
1220
+ status: z13.number().optional().describe("HTTP status code (error responses)"),
1221
+ error: z13.string().optional().describe("Error type (error responses)"),
1222
+ code: z13.string().optional().describe("Error code for display mapping")
1223
+ }).describe("Response schema for refine text API operation");
1228
1224
  var refineTextDataSchema = z13.object({
1229
1225
  userText: z13.string().describe("Original text input from the user"),
1230
1226
  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");
1227
+ }).describe("Data containing original and refined text (legacy nested format)");
1240
1228
 
1241
1229
  // src/helpers/case-convert-helper.ts
1242
1230
  function convertObject(obj, keyConverter) {