@bircleai/widget-protocol 0.6.0 → 0.6.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/index.cjs CHANGED
@@ -160,8 +160,28 @@ function sanitizeServerTheme(raw) {
160
160
  if (locale !== null) out.locale = locale;
161
161
  const texts = sanitizeThemeTexts(o.texts);
162
162
  if (texts !== null) out.texts = texts;
163
+ const faqs = sanitizeThemeFaqs(o.faqs);
164
+ if (faqs !== null) out.faqs = faqs;
163
165
  return out;
164
166
  }
167
+ function sanitizeThemeFaqs(raw) {
168
+ if (!Array.isArray(raw)) return null;
169
+ const out = [];
170
+ for (const item of raw) {
171
+ if (out.length >= 6) break;
172
+ if (typeof item !== "object" || item === null) continue;
173
+ const v = item;
174
+ const label = typeof v.label === "string" ? v.label.trim() : "";
175
+ if (label === "" || label.length > 60) continue;
176
+ const entry = { label };
177
+ if (typeof v.message === "string") {
178
+ const message = v.message.trim();
179
+ if (message !== "" && message.length <= 500) entry.message = message;
180
+ }
181
+ out.push(entry);
182
+ }
183
+ return out.length > 0 ? out : null;
184
+ }
165
185
  function safeThemeLocale(value) {
166
186
  if (typeof value !== "string") return null;
167
187
  const v = value.trim();
package/dist/index.js CHANGED
@@ -112,8 +112,28 @@ function sanitizeServerTheme(raw) {
112
112
  if (locale !== null) out.locale = locale;
113
113
  const texts = sanitizeThemeTexts(o.texts);
114
114
  if (texts !== null) out.texts = texts;
115
+ const faqs = sanitizeThemeFaqs(o.faqs);
116
+ if (faqs !== null) out.faqs = faqs;
115
117
  return out;
116
118
  }
119
+ function sanitizeThemeFaqs(raw) {
120
+ if (!Array.isArray(raw)) return null;
121
+ const out = [];
122
+ for (const item of raw) {
123
+ if (out.length >= 6) break;
124
+ if (typeof item !== "object" || item === null) continue;
125
+ const v = item;
126
+ const label = typeof v.label === "string" ? v.label.trim() : "";
127
+ if (label === "" || label.length > 60) continue;
128
+ const entry = { label };
129
+ if (typeof v.message === "string") {
130
+ const message = v.message.trim();
131
+ if (message !== "" && message.length <= 500) entry.message = message;
132
+ }
133
+ out.push(entry);
134
+ }
135
+ return out.length > 0 ? out : null;
136
+ }
117
137
  function safeThemeLocale(value) {
118
138
  if (typeof value !== "string") return null;
119
139
  const v = value.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bircleai/widget-protocol",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Contrato compartido del Chat Gateway de BircleAI (tipos + helpers de parseo).",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "type": "module",