@encatch/schema 0.1.19 → 0.1.21
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 +43 -44
- package/dist/esm/index.js.map +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/schemas/api/fetch-feedback-schema.d.ts +0 -8
- package/dist/types/schemas/fields/form-properties-schema.d.ts +53 -60
- package/dist/types/schemas/fields/form-schema.d.ts +3 -12
- package/dist/types/schemas/fields/translations-schema.d.ts +55 -57
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -474,10 +474,10 @@ var AnswerSchema = z2.discriminatedUnion("type", [
|
|
|
474
474
|
|
|
475
475
|
// src/schemas/fields/form-schema.ts
|
|
476
476
|
import { z as z3 } from "zod";
|
|
477
|
-
var surveyTypeSchema = z3.enum(["R", "
|
|
477
|
+
var surveyTypeSchema = z3.enum(["R", "S"]).describe("Enumeration of feedback types: R=Recurring, O=One-time");
|
|
478
478
|
var SurveyTypes = {
|
|
479
479
|
RECURRING: "R",
|
|
480
|
-
ONE_TIME: "
|
|
480
|
+
ONE_TIME: "S"
|
|
481
481
|
};
|
|
482
482
|
var yesNoSchema = z3.enum(["Y", "N"]).describe("Yes/No enumeration using Y/N values");
|
|
483
483
|
var YesNoValues = {
|
|
@@ -509,7 +509,7 @@ var frequencyAndSchedulingPropertiesSchema = z3.object({
|
|
|
509
509
|
).describe("Stop date and time for the feedback in ISO format")
|
|
510
510
|
}).refine(
|
|
511
511
|
(data) => {
|
|
512
|
-
if (data.surveyType === "
|
|
512
|
+
if (data.surveyType === "S" && data.showOnce === "N") {
|
|
513
513
|
return false;
|
|
514
514
|
}
|
|
515
515
|
return true;
|
|
@@ -551,33 +551,34 @@ var PublicationStatuses = {
|
|
|
551
551
|
DRAFT: "D",
|
|
552
552
|
ARCHIVED: "A"
|
|
553
553
|
};
|
|
554
|
-
var durationSchema = z3.object({
|
|
555
|
-
from: z3.string().describe("Start date and time for the duration (ISO format or custom format)"),
|
|
556
|
-
to: z3.string().describe("End date and time for the duration (ISO format or custom format)")
|
|
557
|
-
}).describe("Duration range for when something is active");
|
|
558
554
|
var feedbackConfigurationSchema = z3.object({
|
|
559
555
|
form_title: z3.string().describe("Title of the feedback form"),
|
|
560
556
|
form_description: z3.string().describe("Description of the feedback form"),
|
|
561
|
-
duration: durationSchema
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
557
|
+
// duration: durationSchema
|
|
558
|
+
// .refine(
|
|
559
|
+
// (data) => {
|
|
560
|
+
// // Validate ISO format for this specific use case
|
|
561
|
+
// const isoRegex = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(\+|\-)\d{2}:\d{2}$/;
|
|
562
|
+
// return isoRegex.test(data.from) && isoRegex.test(data.to);
|
|
563
|
+
// },
|
|
564
|
+
// {
|
|
565
|
+
// message: "Duration dates must be in valid ISO format with timezone",
|
|
566
|
+
// path: ["from"],
|
|
567
|
+
// }
|
|
568
|
+
// )
|
|
569
|
+
// .refine(
|
|
570
|
+
// (data) => {
|
|
571
|
+
// // End date should be after start date
|
|
572
|
+
// const start = new Date(data.from);
|
|
573
|
+
// const end = new Date(data.to);
|
|
574
|
+
// return end > start;
|
|
575
|
+
// },
|
|
576
|
+
// {
|
|
577
|
+
// message: "End date must be after start date",
|
|
578
|
+
// path: ["to"],
|
|
579
|
+
// }
|
|
580
|
+
// )
|
|
581
|
+
// .describe("Duration period for the feedback"),
|
|
581
582
|
is_published: publicationStatusSchema.describe("Publication status of the feedback form")
|
|
582
583
|
}).describe("Schema defining feedback configuration properties");
|
|
583
584
|
|
|
@@ -687,23 +688,21 @@ var questionTranslationSchema = z4.union([
|
|
|
687
688
|
var languageCodeSchema = z4.string().min(2).max(10).describe("Language code (e.g., 'en', 'es', 'hi')");
|
|
688
689
|
var questionTranslationsByLanguageSchema = z4.record(languageCodeSchema, questionTranslationSchema).describe("Question translations keyed by language code");
|
|
689
690
|
var questionCentricTranslationsSchema = z4.record(z4.string().uuid(), questionTranslationsByLanguageSchema).describe("Question-centric translations keyed by question ID, then by language code");
|
|
690
|
-
var translationsSchema =
|
|
691
|
-
defaultLanguage: z4.string().describe("Default/fallback language code"),
|
|
692
|
-
questions: questionCentricTranslationsSchema.describe("Question-centric translations")
|
|
693
|
-
}).describe("Complete question-centric translation schema");
|
|
691
|
+
var translationsSchema = questionCentricTranslationsSchema.describe("Question-centric translations at root level");
|
|
694
692
|
var _TranslationProvider = class _TranslationProvider {
|
|
695
|
-
constructor(translations) {
|
|
693
|
+
constructor(translations, defaultLanguage = "en") {
|
|
696
694
|
this.translations = translations;
|
|
695
|
+
this.defaultLanguage = defaultLanguage;
|
|
697
696
|
}
|
|
698
697
|
/**
|
|
699
698
|
* Get translations for a specific question in a specific language
|
|
700
699
|
*/
|
|
701
700
|
getQuestionTranslations(questionId, languageCode) {
|
|
702
|
-
const questionTranslations = this.translations
|
|
701
|
+
const questionTranslations = this.translations[questionId];
|
|
703
702
|
if (!questionTranslations) return null;
|
|
704
703
|
let translation = questionTranslations[languageCode];
|
|
705
704
|
if (!translation) {
|
|
706
|
-
translation = questionTranslations[this.
|
|
705
|
+
translation = questionTranslations[this.defaultLanguage];
|
|
707
706
|
}
|
|
708
707
|
return translation || null;
|
|
709
708
|
}
|
|
@@ -723,7 +722,7 @@ var _TranslationProvider = class _TranslationProvider {
|
|
|
723
722
|
* Get all available languages for a specific question
|
|
724
723
|
*/
|
|
725
724
|
getQuestionLanguages(questionId) {
|
|
726
|
-
const questionTranslations = this.translations
|
|
725
|
+
const questionTranslations = this.translations[questionId];
|
|
727
726
|
if (!questionTranslations) return [];
|
|
728
727
|
return Object.keys(questionTranslations);
|
|
729
728
|
}
|
|
@@ -732,7 +731,7 @@ var _TranslationProvider = class _TranslationProvider {
|
|
|
732
731
|
*/
|
|
733
732
|
getAvailableLanguages() {
|
|
734
733
|
const allLanguages = /* @__PURE__ */ new Set();
|
|
735
|
-
Object.values(this.translations
|
|
734
|
+
Object.values(this.translations).forEach((questionTranslations) => {
|
|
736
735
|
Object.keys(questionTranslations).forEach((langCode) => {
|
|
737
736
|
allLanguages.add(langCode);
|
|
738
737
|
});
|
|
@@ -743,7 +742,7 @@ var _TranslationProvider = class _TranslationProvider {
|
|
|
743
742
|
* Check if a language is supported for a specific question
|
|
744
743
|
*/
|
|
745
744
|
isLanguageSupportedForQuestion(questionId, languageCode) {
|
|
746
|
-
const questionTranslations = this.translations
|
|
745
|
+
const questionTranslations = this.translations[questionId];
|
|
747
746
|
if (!questionTranslations) return false;
|
|
748
747
|
return languageCode in questionTranslations;
|
|
749
748
|
}
|
|
@@ -757,27 +756,27 @@ var _TranslationProvider = class _TranslationProvider {
|
|
|
757
756
|
* Get the default language
|
|
758
757
|
*/
|
|
759
758
|
getDefaultLanguage() {
|
|
760
|
-
return this.
|
|
759
|
+
return this.defaultLanguage;
|
|
761
760
|
}
|
|
762
761
|
/**
|
|
763
762
|
* Get all questions that have translations
|
|
764
763
|
*/
|
|
765
764
|
getQuestionIds() {
|
|
766
|
-
return Object.keys(this.translations
|
|
765
|
+
return Object.keys(this.translations);
|
|
767
766
|
}
|
|
768
767
|
/**
|
|
769
768
|
* Get question type for a specific question
|
|
770
769
|
*/
|
|
771
770
|
getQuestionType(questionId, languageCode) {
|
|
772
|
-
const langCode = languageCode || this.
|
|
771
|
+
const langCode = languageCode || this.defaultLanguage;
|
|
773
772
|
const translation = this.getQuestionTranslations(questionId, langCode);
|
|
774
773
|
return translation?.type || null;
|
|
775
774
|
}
|
|
776
775
|
};
|
|
777
776
|
__name(_TranslationProvider, "TranslationProvider");
|
|
778
777
|
var TranslationProvider = _TranslationProvider;
|
|
779
|
-
function createTranslationProvider(translations) {
|
|
780
|
-
return new TranslationProvider(translations);
|
|
778
|
+
function createTranslationProvider(translations, defaultLanguage = "en") {
|
|
779
|
+
return new TranslationProvider(translations, defaultLanguage);
|
|
781
780
|
}
|
|
782
781
|
__name(createTranslationProvider, "createTranslationProvider");
|
|
783
782
|
|
|
@@ -1130,7 +1129,8 @@ import { z as z12 } from "zod";
|
|
|
1130
1129
|
var feedbackConfigurationItemSchema = z12.object({
|
|
1131
1130
|
feedbackConfigurationId: z12.string().uuid().describe("Unique identifier for the feedback configuration"),
|
|
1132
1131
|
feedbackTitle: z12.string().describe("Title of the feedback configuration"),
|
|
1133
|
-
duration: durationSchema
|
|
1132
|
+
// duration: durationSchema
|
|
1133
|
+
// .describe("Active duration for this feedback configuration"),
|
|
1134
1134
|
triggerProperties: audienceTriggerPropertiesSchema.describe("Trigger properties including auto/manual settings and audience segments"),
|
|
1135
1135
|
appearanceProperties: z12.object({
|
|
1136
1136
|
themes: z12.object({
|
|
@@ -1256,7 +1256,6 @@ export {
|
|
|
1256
1256
|
deviceSessionInfoSchema,
|
|
1257
1257
|
deviceThemeSchema,
|
|
1258
1258
|
dismissBehaviorSchema,
|
|
1259
|
-
durationSchema,
|
|
1260
1259
|
endScreenPropertiesSchema,
|
|
1261
1260
|
externalPublishingPropertiesSchema,
|
|
1262
1261
|
featureSettingsSchema,
|