@bircleai/widget-protocol 0.5.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 +22 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +22 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -90,7 +90,8 @@ var SERVER_PROVIDED_THEME_FIELDS = [
|
|
|
90
90
|
"colorScheme",
|
|
91
91
|
"poweredBy",
|
|
92
92
|
"locale",
|
|
93
|
-
"texts"
|
|
93
|
+
"texts",
|
|
94
|
+
"faqs"
|
|
94
95
|
];
|
|
95
96
|
var MAX_THEME_LABEL = 40;
|
|
96
97
|
var MAX_THEME_TAGLINE = 80;
|
|
@@ -159,8 +160,28 @@ function sanitizeServerTheme(raw) {
|
|
|
159
160
|
if (locale !== null) out.locale = locale;
|
|
160
161
|
const texts = sanitizeThemeTexts(o.texts);
|
|
161
162
|
if (texts !== null) out.texts = texts;
|
|
163
|
+
const faqs = sanitizeThemeFaqs(o.faqs);
|
|
164
|
+
if (faqs !== null) out.faqs = faqs;
|
|
162
165
|
return out;
|
|
163
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
|
+
}
|
|
164
185
|
function safeThemeLocale(value) {
|
|
165
186
|
if (typeof value !== "string") return null;
|
|
166
187
|
const v = value.trim();
|
package/dist/index.d.cts
CHANGED
|
@@ -357,6 +357,21 @@ interface ThemeResponse {
|
|
|
357
357
|
launcherLabel?: string;
|
|
358
358
|
/** `false` oculta el footer "Powered by BircleAI". Cualquier otro valor lo muestra. */
|
|
359
359
|
poweredBy?: boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Preguntas frecuentes del chat: chips que se muestran sobre el composer
|
|
362
|
+
* mientras la conversación está vacía (después colapsan a un botón que las
|
|
363
|
+
* re-despliega). Tocar una envía su `message` (o el `label` si no hay) como
|
|
364
|
+
* mensaje del usuario, por el camino normal — el agente la responde como
|
|
365
|
+
* cualquier consulta.
|
|
366
|
+
*
|
|
367
|
+
* Configurables desde la pestaña Apariencia del Dashboard, por embed key.
|
|
368
|
+
* Tope 6; `label` <= 60 chars (lo que se ve), `message` <= 500 (lo que se
|
|
369
|
+
* envía). Ambos se renderizan como `textContent`, nunca como markup.
|
|
370
|
+
*/
|
|
371
|
+
faqs?: Array<{
|
|
372
|
+
label: string;
|
|
373
|
+
message?: string;
|
|
374
|
+
}>;
|
|
360
375
|
/**
|
|
361
376
|
* Hosts https permitidos para renderizar media rica (allow-list; lo consume la
|
|
362
377
|
* UI, no el core).
|
|
@@ -410,7 +425,7 @@ interface ThemeResponse {
|
|
|
410
425
|
* blancas (el `toUiView` del Gateway y la del widget web) — son defensa en
|
|
411
426
|
* profundidad a propósito, no una duplicación accidental.
|
|
412
427
|
*/
|
|
413
|
-
declare const SERVER_PROVIDED_THEME_FIELDS: readonly ["primaryColor", "accentColor", "launcherIcon", "launcherLabel", "position", "headerLogo", "assistantName", "assistantTagline", "assistantAvatar", "fontFamily", "colorScheme", "poweredBy", "locale", "texts"];
|
|
428
|
+
declare const SERVER_PROVIDED_THEME_FIELDS: readonly ["primaryColor", "accentColor", "launcherIcon", "launcherLabel", "position", "headerLogo", "assistantName", "assistantTagline", "assistantAvatar", "fontFamily", "colorScheme", "poweredBy", "locale", "texts", "faqs"];
|
|
414
429
|
/** Subconjunto de `ThemeResponse` que el server realmente puede mandar (ver `SERVER_PROVIDED_THEME_FIELDS`). */
|
|
415
430
|
type ServerThemeResponse = Pick<ThemeResponse, (typeof SERVER_PROVIDED_THEME_FIELDS)[number]>;
|
|
416
431
|
/** Tope de `assistantName` y `launcherLabel`. Más que esto no entra en un header de teléfono. */
|
package/dist/index.d.ts
CHANGED
|
@@ -357,6 +357,21 @@ interface ThemeResponse {
|
|
|
357
357
|
launcherLabel?: string;
|
|
358
358
|
/** `false` oculta el footer "Powered by BircleAI". Cualquier otro valor lo muestra. */
|
|
359
359
|
poweredBy?: boolean;
|
|
360
|
+
/**
|
|
361
|
+
* Preguntas frecuentes del chat: chips que se muestran sobre el composer
|
|
362
|
+
* mientras la conversación está vacía (después colapsan a un botón que las
|
|
363
|
+
* re-despliega). Tocar una envía su `message` (o el `label` si no hay) como
|
|
364
|
+
* mensaje del usuario, por el camino normal — el agente la responde como
|
|
365
|
+
* cualquier consulta.
|
|
366
|
+
*
|
|
367
|
+
* Configurables desde la pestaña Apariencia del Dashboard, por embed key.
|
|
368
|
+
* Tope 6; `label` <= 60 chars (lo que se ve), `message` <= 500 (lo que se
|
|
369
|
+
* envía). Ambos se renderizan como `textContent`, nunca como markup.
|
|
370
|
+
*/
|
|
371
|
+
faqs?: Array<{
|
|
372
|
+
label: string;
|
|
373
|
+
message?: string;
|
|
374
|
+
}>;
|
|
360
375
|
/**
|
|
361
376
|
* Hosts https permitidos para renderizar media rica (allow-list; lo consume la
|
|
362
377
|
* UI, no el core).
|
|
@@ -410,7 +425,7 @@ interface ThemeResponse {
|
|
|
410
425
|
* blancas (el `toUiView` del Gateway y la del widget web) — son defensa en
|
|
411
426
|
* profundidad a propósito, no una duplicación accidental.
|
|
412
427
|
*/
|
|
413
|
-
declare const SERVER_PROVIDED_THEME_FIELDS: readonly ["primaryColor", "accentColor", "launcherIcon", "launcherLabel", "position", "headerLogo", "assistantName", "assistantTagline", "assistantAvatar", "fontFamily", "colorScheme", "poweredBy", "locale", "texts"];
|
|
428
|
+
declare const SERVER_PROVIDED_THEME_FIELDS: readonly ["primaryColor", "accentColor", "launcherIcon", "launcherLabel", "position", "headerLogo", "assistantName", "assistantTagline", "assistantAvatar", "fontFamily", "colorScheme", "poweredBy", "locale", "texts", "faqs"];
|
|
414
429
|
/** Subconjunto de `ThemeResponse` que el server realmente puede mandar (ver `SERVER_PROVIDED_THEME_FIELDS`). */
|
|
415
430
|
type ServerThemeResponse = Pick<ThemeResponse, (typeof SERVER_PROVIDED_THEME_FIELDS)[number]>;
|
|
416
431
|
/** Tope de `assistantName` y `launcherLabel`. Más que esto no entra en un header de teléfono. */
|
package/dist/index.js
CHANGED
|
@@ -42,7 +42,8 @@ var SERVER_PROVIDED_THEME_FIELDS = [
|
|
|
42
42
|
"colorScheme",
|
|
43
43
|
"poweredBy",
|
|
44
44
|
"locale",
|
|
45
|
-
"texts"
|
|
45
|
+
"texts",
|
|
46
|
+
"faqs"
|
|
46
47
|
];
|
|
47
48
|
var MAX_THEME_LABEL = 40;
|
|
48
49
|
var MAX_THEME_TAGLINE = 80;
|
|
@@ -111,8 +112,28 @@ function sanitizeServerTheme(raw) {
|
|
|
111
112
|
if (locale !== null) out.locale = locale;
|
|
112
113
|
const texts = sanitizeThemeTexts(o.texts);
|
|
113
114
|
if (texts !== null) out.texts = texts;
|
|
115
|
+
const faqs = sanitizeThemeFaqs(o.faqs);
|
|
116
|
+
if (faqs !== null) out.faqs = faqs;
|
|
114
117
|
return out;
|
|
115
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
|
+
}
|
|
116
137
|
function safeThemeLocale(value) {
|
|
117
138
|
if (typeof value !== "string") return null;
|
|
118
139
|
const v = value.trim();
|
package/package.json
CHANGED