@encatch/schema 1.0.1-beta.3 → 1.1.0-beta.10

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
@@ -10,13 +10,15 @@ var translationEntrySchema = z.string().min(1).describe("Translated text content
10
10
  var baseQuestionTranslationFieldsSchema = z.object({
11
11
  title: translationEntrySchema.describe("Question title translation"),
12
12
  description: translationEntrySchema.optional().describe("Question description translation"),
13
- errorMessage: translationEntrySchema.optional().describe("Error message translation")
13
+ errorMessage: translationEntrySchema.optional().describe("Error message translation"),
14
+ nextButtonLabel: translationEntrySchema.max(50).optional().describe("Next button label translation when advancing past this question")
14
15
  });
15
16
  var BASE_QUESTION_TRANSLATION_KEYS = [
16
17
  "type",
17
18
  "title",
18
19
  "description",
19
- "errorMessage"
20
+ "errorMessage",
21
+ "nextButtonLabel"
20
22
  ];
21
23
  var ratingQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
22
24
  type: z.literal("rating").describe("Question type identifier"),
@@ -86,21 +88,17 @@ var annotationQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.ex
86
88
  noAnnotationText: translationEntrySchema.optional().describe("No annotation display text translation")
87
89
  }).describe("Translation schema for annotation questions");
88
90
  var welcomeQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
89
- type: z.literal("welcome").describe("Question type identifier"),
90
- buttonLabel: translationEntrySchema.optional().describe("Translated proceed/start button label")
91
+ type: z.literal("welcome").describe("Question type identifier")
91
92
  }).describe("Translation schema for welcome screen questions");
92
93
  var thankYouQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
93
- type: z.literal("thank_you").describe("Question type identifier"),
94
- buttonLabel: translationEntrySchema.optional().describe(
95
- "Translated dismiss/done button label"
96
- )
94
+ type: z.literal("thank_you").describe("Question type identifier")
97
95
  }).describe("Translation schema for thank you screen questions");
98
96
  var messagePanelQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
99
- type: z.literal("message_panel").describe("Question type identifier"),
100
- buttonLabel: translationEntrySchema.optional().describe(
101
- "Translated continue/button label"
102
- )
97
+ type: z.literal("message_panel").describe("Question type identifier")
103
98
  }).describe("Translation schema for message panel questions");
99
+ var consentQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
100
+ type: z.literal("consent").describe("Question type identifier")
101
+ }).describe("Translation schema for consent questions; description carries the translated checkbox label (markdown supported)");
104
102
  var yesNoQuestionTranslationSchema = baseQuestionTranslationFieldsSchema.extend({
105
103
  type: z.literal("yes_no").describe("Question type identifier"),
106
104
  yesLabel: translationEntrySchema.optional().describe("Translated Yes label"),
@@ -172,11 +170,18 @@ var questionTranslationSchema = z.union([
172
170
  thankYouQuestionTranslationSchema,
173
171
  messagePanelQuestionTranslationSchema,
174
172
  yesNoQuestionTranslationSchema,
173
+ consentQuestionTranslationSchema,
175
174
  ratingMatrixQuestionTranslationSchema,
176
175
  matrixSingleChoiceQuestionTranslationSchema,
177
176
  matrixMultipleChoiceQuestionTranslationSchema
178
177
  ]).describe("Union of all question type translation schemas");
179
178
  var languageCodeSchema = z.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
179
+ var sectionTranslationSchema = z.object({
180
+ title: translationEntrySchema.max(200).describe("Section title translation"),
181
+ description: translationEntrySchema.max(1e3).optional().describe("Section description translation"),
182
+ nextButtonLabel: translationEntrySchema.max(50).optional().describe("Next button label translation for this section")
183
+ }).describe("Translation payload for a section in a single language");
184
+ var sectionTranslationsByLanguageSchema = z.record(languageCodeSchema, sectionTranslationSchema).describe("Section translations keyed by language code");
180
185
  var questionTranslationsByLanguageSchema = z.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
181
186
  var questionCentricTranslationsSchema = z.record(z.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
182
187
  var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
@@ -288,7 +293,8 @@ var questionTypeSchema = z2.enum([
288
293
  "rating_matrix",
289
294
  "matrix_single_choice",
290
295
  "matrix_multiple_choice",
291
- "exit_form"
296
+ "exit_form",
297
+ "consent"
292
298
  ]).describe("Enumeration of all supported question types for form fields");
293
299
  var QuestionTypes = {
294
300
  RATING: "rating",
@@ -306,7 +312,8 @@ var QuestionTypes = {
306
312
  RATING_MATRIX: "rating_matrix",
307
313
  MATRIX_SINGLE_CHOICE: "matrix_single_choice",
308
314
  MATRIX_MULTIPLE_CHOICE: "matrix_multiple_choice",
309
- EXIT_FORM: "exit_form"
315
+ EXIT_FORM: "exit_form",
316
+ CONSENT: "consent"
310
317
  };
311
318
  var validationRuleTypeSchema = z2.enum([
312
319
  "required",
@@ -367,23 +374,12 @@ var visibilityConditionSchema = z2.object({
367
374
  var sectionSchema = z2.object({
368
375
  id: z2.string().describe("Unique identifier for the section"),
369
376
  title: z2.string().min(1).max(200).describe("Display title for the section"),
370
- titleTranslations: z2.record(
371
- languageCodeSchema,
372
- z2.string().min(1).max(200)
373
- ).optional().describe("Localized section titles keyed by language code"),
374
377
  description: z2.string().max(1e3).optional().describe("Optional detailed description or help text for the section"),
375
- descriptionTranslations: z2.record(
376
- languageCodeSchema,
377
- z2.string().min(1).max(1e3)
378
- ).optional().describe("Localized section descriptions keyed by language code"),
379
378
  showTitle: z2.boolean().default(true).describe("Whether to show the section title in the UI"),
380
379
  showDescription: z2.boolean().default(true).describe("Whether to show the section description in the UI"),
381
380
  nextButtonLabel: z2.string().min(1).max(50).optional().describe("Label for the next button when navigating from this section"),
382
- nextButtonLabelTranslations: z2.record(
383
- languageCodeSchema,
384
- z2.string().min(1).max(50)
385
- ).optional().describe(
386
- "Localized next-button labels for this section keyed by language code"
381
+ translations: sectionTranslationsByLanguageSchema.optional().describe(
382
+ "Per-language section copy (title, optional description and nextButtonLabel), keyed by language code"
387
383
  ),
388
384
  inAppSingleQuestion: z2.boolean().default(false).describe(
389
385
  "When true, the native app shows one question at a time within this section"
@@ -466,6 +462,9 @@ var ChoiceOrderOptions = {
466
462
  };
467
463
  var questionSchema = z2.object({
468
464
  id: z2.string().describe("Unique identifier for the question"),
465
+ slug: z2.string().min(1).max(128).optional().describe(
466
+ "Optional stable identifier for the question (e.g. URLs, analytics, or integrations)"
467
+ ),
469
468
  type: questionTypeSchema.describe(
470
469
  "The type of question (rating, single_choice, etc.)"
471
470
  ),
@@ -483,7 +482,12 @@ var questionSchema = z2.object({
483
482
  status: questionStatusSchema.describe(
484
483
  "Current status of the question (Draft, Published, etc.)"
485
484
  ),
486
- textAlign: z2.enum(["left", "center"]).optional().default("left").describe("Text alignment for the question title and description")
485
+ textAlign: z2.enum(["left", "center", "justify"]).optional().default("left").describe(
486
+ "Text alignment for the question title and description; `justify` is intended for consent questions (full-width justified consent body markdown)"
487
+ ),
488
+ nextButtonLabel: z2.string().min(1).max(50).optional().describe(
489
+ "Label for the next button when advancing past this question (overrides section or form defaults when set)"
490
+ )
487
491
  }).describe("Base schema for all question types with common properties");
488
492
  var ratingQuestionSchema = questionSchema.extend({
489
493
  type: z2.literal("rating").describe("Must be exactly 'rating'"),
@@ -506,7 +510,6 @@ var welcomeQuestionSchema = questionSchema.extend({
506
510
  type: z2.literal("welcome").describe("Must be exactly 'welcome'"),
507
511
  title: z2.string().min(1).max(200).describe("The main heading displayed on the welcome screen"),
508
512
  description: z2.string().max(1e3).optional().describe("Optional sub-text body shown below the heading"),
509
- buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the proceed/start button (e.g. 'Get Started', 'Begin')"),
510
513
  imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the welcome screen")
511
514
  }).describe("Schema for a welcome screen displayed at the start or inline within a form");
512
515
  var thankYouQuestionSchema = questionSchema.extend({
@@ -515,7 +518,6 @@ var thankYouQuestionSchema = questionSchema.extend({
515
518
  description: z2.string().max(1e3).optional().describe(
516
519
  "Optional thank you body text; rendered as Markdown where the form supports it"
517
520
  ),
518
- buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the dismiss/done button (e.g. 'Done', 'Close')"),
519
521
  imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the thank you screen")
520
522
  }).describe(
521
523
  "Schema for a thank you screen shown at the end or inline within a form"
@@ -524,7 +526,6 @@ var messagePanelQuestionSchema = questionSchema.extend({
524
526
  type: z2.literal("message_panel").describe("Must be exactly 'message_panel'"),
525
527
  title: z2.string().min(1).max(200).describe("The main heading displayed on the message panel"),
526
528
  description: z2.string().max(1e3).optional().describe("Optional body text shown below the heading"),
527
- buttonLabel: z2.string().min(1).max(50).optional().describe("Label for the continue button (e.g. 'Continue', 'Next')"),
528
529
  imageUrl: z2.string().url().optional().describe("Optional image URL displayed on the message panel")
529
530
  }).describe(
530
531
  "Schema for an inline message panel (informational); distinct from welcome for UI semantics and analytics"
@@ -540,6 +541,11 @@ var yesNoQuestionSchema = questionSchema.extend({
540
541
  noLabel: z2.string().min(1).max(50).optional().describe("Label for the No option (defaults to 'No' in the UI if omitted)"),
541
542
  displayStyle: yesNoDisplayStyleSchema.optional().describe("Layout for the Yes/No controls (horizontal row or vertical stack)")
542
543
  }).describe("Schema for yes/no questions with optional custom labels and layout");
544
+ var consentQuestionSchema = questionSchema.extend({
545
+ type: z2.literal("consent").describe("Must be exactly 'consent'")
546
+ }).describe(
547
+ "Schema for a single-checkbox consent question; use description (rendered as markdown) for the checkbox label text and any policy/terms links; answer is boolean (true = checked)"
548
+ );
543
549
  var ratingMatrixDisplayStyleSchema = z2.enum([
544
550
  "radio",
545
551
  "star",
@@ -838,6 +844,7 @@ var combinedQuestionSchema = z2.discriminatedUnion("type", [
838
844
  messagePanelQuestionSchema,
839
845
  exitFormQuestionSchema,
840
846
  yesNoQuestionSchema,
847
+ consentQuestionSchema,
841
848
  ratingMatrixQuestionSchema,
842
849
  matrixSingleChoiceQuestionSchema,
843
850
  matrixMultipleChoiceQuestionSchema,
@@ -871,6 +878,7 @@ var AnswerItemSchema = z3.object({
871
878
  ),
872
879
  rating: z3.number().optional().describe("Star rating value (e.g., 1-5)"),
873
880
  yesNo: z3.boolean().optional().describe("Yes/no answer for yes_no questions (true = Yes, false = No)"),
881
+ consent: z3.boolean().optional().describe("Consent answer for consent questions (true = checked/agreed, false = unchecked)"),
874
882
  multipleChoiceMultiple: z3.array(z3.string()).optional().describe("Array of selected option IDs for multiple choice questions"),
875
883
  singleChoiceOther: z3.string().optional().describe(
876
884
  'Free-text "other" answer for single choice questions when allowOther is enabled'
@@ -923,13 +931,9 @@ import { z as z8 } from "zod";
923
931
  // src/schemas/fields/other-screen-schema.ts
924
932
  import { z as z5 } from "zod";
925
933
  var OtherFieldsSchema = z5.object({
926
- pagination: z5.boolean().describe("Whether to show pagination for multi-page forms"),
927
934
  questionNumber: z5.boolean().describe("Whether to display question numbers"),
928
- pageTitle: z5.boolean().describe("Whether to show page titles in multi-page forms"),
929
- blockerFeedback: z5.boolean().describe("Whether to show blocker feedback for validation errors"),
930
935
  submitButtonLabel: z5.string().min(1).max(50).describe("Text for the submit button"),
931
936
  previousButtonLabel: z5.string().min(1).max(50).describe("Text for the previous button in pagination"),
932
- nextButtonLabel: z5.string().min(1).max(50).describe("Text for the next button in pagination"),
933
937
  aiEnhancementSuccessMessage: z5.string().min(1).max(100).describe("Message shown when AI enhancement is successful (max 100 characters)"),
934
938
  aiEnhancementCooldownErrorMessage: z5.string().min(1).max(100).describe("Message shown when AI enhancement is on cooldown (max 100 characters)"),
935
939
  aiEnhancementMaxReachedErrorMessage: z5.string().min(1).max(100).describe("Message shown when maximum AI enhancements reached (max 100 characters)")
@@ -942,7 +946,6 @@ var LanguagesSchema = z5.array(LanguageFieldSchema).describe("Schema for array o
942
946
  var OtherFieldsTranslationSchema = z5.object({
943
947
  submitButtonLabel: z5.string().min(1).max(50).describe("Translated text for the submit button"),
944
948
  previousButtonLabel: z5.string().min(1).max(50).describe("Translated text for the previous button in pagination"),
945
- nextButtonLabel: z5.string().min(1).max(50).describe("Translated text for the next button in pagination"),
946
949
  aiEnhancementSuccessMessage: z5.string().min(1).max(100).describe("Translated message shown when AI enhancement is successful (max 100 characters)"),
947
950
  aiEnhancementCooldownErrorMessage: z5.string().min(1).max(100).describe("Translated message shown when AI enhancement is on cooldown (max 100 characters)"),
948
951
  aiEnhancementMaxReachedErrorMessage: z5.string().min(1).max(100).describe("Translated message shown when maximum AI enhancements reached (max 100 characters)")
@@ -986,18 +989,26 @@ var ShareableModes = {
986
989
  SYSTEM: "system"
987
990
  };
988
991
  var previousButtonModeSchema = z6.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto");
992
+ var PreviousButtonModes = {
993
+ NEVER: "never",
994
+ ALWAYS: "always",
995
+ AUTO: "auto"
996
+ };
989
997
  var featureSettingsSchema = z6.object({
990
- darkOverlay: z6.boolean().describe("Whether to show a dark overlay behind the widget"),
991
- closeButton: z6.boolean().describe("Whether to display a close button on the widget"),
992
- progressBar: z6.boolean().describe("Whether to show a progress bar indicating completion status"),
993
- showBranding: z6.boolean().describe("Whether to display branding elements on the widget"),
998
+ darkOverlay: z6.boolean().default(false).describe("Whether to show a dark overlay behind the widget"),
999
+ closeButton: z6.boolean().default(true).describe("Whether to display a close button on the widget"),
1000
+ progressBar: z6.boolean().default(true).describe("Whether to show a progress bar indicating completion status"),
1001
+ showBranding: z6.boolean().default(true).describe("Whether to display branding elements on the widget"),
994
1002
  customPosition: z6.boolean().describe("Whether custom positioning is enabled"),
995
1003
  customCss: z6.string().optional().describe("Custom CSS link to apply for the feedback form"),
996
- shareableMode: shareableModeSchema.optional().describe(
1004
+ shareableMode: shareableModeSchema.optional().default(ShareableModes.LIGHT).describe(
997
1005
  "Display mode for the shareable: light, dark, or system preference"
998
1006
  ),
999
- rtl: z6.boolean().describe("Whether right-to-left text direction is enabled"),
1000
- previousButton: previousButtonModeSchema.describe("Previous button visibility mode: never, always, or auto")
1007
+ enableShareableKeyboardNavigation: z6.boolean().default(false).describe(
1008
+ "Whether keyboard navigation is enabled for the shareable widget experience"
1009
+ ),
1010
+ rtl: z6.boolean().default(false).describe("Whether right-to-left text direction is enabled"),
1011
+ previousButton: previousButtonModeSchema.default(PreviousButtonModes.ALWAYS).describe("Previous button visibility mode: never, always, or auto")
1001
1012
  }).describe("Feature settings controlling widget UI behavior and appearance");
1002
1013
  var themeColorsSchema = z6.object({
1003
1014
  theme: z6.string().optional().describe("Theme for a single mode (shadcn variables JSON)")
@@ -1101,13 +1112,13 @@ var otherConfigurationPropertiesSchema = z8.discriminatedUnion("isEnabled", [
1101
1112
  // When other configuration is disabled
1102
1113
  z8.object({
1103
1114
  isEnabled: z8.literal(false).describe("Whether other configuration properties are enabled"),
1104
- otherFields: OtherFieldsSchema.describe("Other form configuration fields including pagination, buttons, and display options"),
1115
+ otherFields: OtherFieldsSchema.describe("Other form configuration fields including buttons and display options"),
1105
1116
  translations: z8.record(z8.string(), OtherFieldsTranslationSchema).optional().describe("Translations for other configuration field labels and buttons keyed by language code")
1106
1117
  }),
1107
1118
  // When other configuration is enabled
1108
1119
  z8.object({
1109
1120
  isEnabled: z8.literal(true).describe("Whether other configuration properties are enabled"),
1110
- otherFields: OtherFieldsSchema.describe("Other form configuration fields including pagination, buttons, and display options"),
1121
+ otherFields: OtherFieldsSchema.describe("Other form configuration fields including buttons and display options"),
1111
1122
  translations: z8.record(z8.string(), OtherFieldsTranslationSchema).describe("Translations for other configuration field labels and buttons keyed by language code")
1112
1123
  })
1113
1124
  ]).describe("Schema for other configuration properties including fields and translations");
@@ -1256,6 +1267,9 @@ var feedbackConfigurationItemSchema = z12.object({
1256
1267
  customPosition: z12.boolean().describe("Whether custom position is enabled"),
1257
1268
  customIconPosition: z12.boolean().describe("Whether custom icon position is enabled"),
1258
1269
  customCss: z12.string().nullable().optional().describe("Custom CSS link (optional)"),
1270
+ enableShareableKeyboardNavigation: z12.boolean().default(false).describe(
1271
+ "Whether keyboard navigation is enabled for the shareable widget experience"
1272
+ ),
1259
1273
  rtl: z12.boolean().describe("Whether right-to-left text direction is enabled"),
1260
1274
  previousButton: z12.enum(["never", "always", "auto"]).describe("Previous button visibility mode: never, always, or auto")
1261
1275
  }).describe("Feature settings for the feedback form"),
@@ -1285,6 +1299,16 @@ var formConfigurationResponseSchema = z12.object({
1285
1299
  formTitle: z12.string().describe("Title of the feedback form"),
1286
1300
  formDescription: z12.string().describe("Description of the feedback form")
1287
1301
  }).describe("Form configuration response with title and description");
1302
+ var logicJumpRuleSchema = z12.object({
1303
+ jsonLogic: z12.record(z12.string(), z12.unknown()).describe("JSON Logic expression to evaluate"),
1304
+ targetQuestionId: z12.string().describe("Question ID to navigate to when this rule matches")
1305
+ }).describe("A single logic jump rule mapping a condition to a target question");
1306
+ var logicJumpRulesSchema = z12.record(
1307
+ z12.string(),
1308
+ z12.array(logicJumpRuleSchema)
1309
+ ).describe(
1310
+ "Logic jump rules keyed by question ID (or '__workflow_start__'). Each entry is an ordered array of rules evaluated top-down; the first matching rule wins."
1311
+ );
1288
1312
  var questionnaireFieldsResponseSchema = z12.object({
1289
1313
  questions: z12.record(z12.string(), combinedQuestionSchema).describe("Collection of questions keyed by their string identifiers"),
1290
1314
  sections: z12.array(sectionSchema).describe(
@@ -1295,9 +1319,12 @@ var questionnaireFieldsResponseSchema = z12.object({
1295
1319
  ),
1296
1320
  selectedLanguages: LanguagesSchema.describe(
1297
1321
  "Array of languages selected for this questionnaire"
1298
- )
1322
+ ),
1323
+ isLogicJumpsEnabled: z12.boolean().optional().default(false).describe("When true, form navigation follows logicJumpRules instead of linear section order"),
1324
+ logicJumpRules: logicJumpRulesSchema.optional().describe("Conditional navigation rules evaluated per question to determine the next question to show"),
1325
+ contextVariables: z12.array(z12.string()).optional().describe("List of context variable keys expected by the form (informational)")
1299
1326
  }).describe(
1300
- "Questionnaire fields response including questions, sections, translations, and selected languages"
1327
+ "Questionnaire fields response including questions, sections, translations, selected languages, and optional logic jump configuration"
1301
1328
  );
1302
1329
  var fetchFeedbackDetailsResponseSchema = z12.object({
1303
1330
  feedbackConfigurationId: z12.string().uuid().describe("Unique identifier for the feedback configuration"),
@@ -1467,6 +1494,7 @@ export {
1467
1494
  OtherFieldsSchema,
1468
1495
  OtherFieldsTranslationSchema,
1469
1496
  Positions,
1497
+ PreviousButtonModes,
1470
1498
  PublicationStatuses,
1471
1499
  QuestionStatuses,
1472
1500
  QuestionTypes,
@@ -1492,6 +1520,8 @@ export {
1492
1520
  conditionalIfMetadataSchema,
1493
1521
  conditionalIfSchema,
1494
1522
  conditionalWhenSchema,
1523
+ consentQuestionSchema,
1524
+ consentQuestionTranslationSchema,
1495
1525
  createTranslationProvider,
1496
1526
  currentModeSchema,
1497
1527
  customEventFieldOperatorSchema,
@@ -1514,6 +1544,8 @@ export {
1514
1544
  formConfigSchema,
1515
1545
  formConfigurationResponseSchema,
1516
1546
  formPropertiesSchema,
1547
+ logicJumpRuleSchema,
1548
+ logicJumpRulesSchema,
1517
1549
  longAnswerQuestionSchema,
1518
1550
  longAnswerQuestionTranslationSchema,
1519
1551
  masterPropertiesSchema,
@@ -1542,6 +1574,7 @@ export {
1542
1574
  otherConfigurationPropertiesSchema,
1543
1575
  partialFeedbackSchema,
1544
1576
  positionSchema,
1577
+ previousButtonModeSchema,
1545
1578
  publicationStatusSchema,
1546
1579
  queryOutputSchema,
1547
1580
  questionCentricTranslationsSchema,
@@ -1567,6 +1600,8 @@ export {
1567
1600
  refineTextResponseSchema,
1568
1601
  responseSchema,
1569
1602
  sectionSchema,
1603
+ sectionTranslationSchema,
1604
+ sectionTranslationsByLanguageSchema,
1570
1605
  sessionInfoSchema,
1571
1606
  shareableModeSchema,
1572
1607
  shortAnswerQuestionSchema,