@accurix/centrinfo-widget 1.0.1 → 1.1.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/README.md +53 -3
- package/dist/cdn/centrinfo-widget.js +278 -53
- package/dist/cdn/manifest.json +6 -6
- package/dist/config-BfVMFkZ4.cjs +36 -0
- package/dist/config-CHvO9tW1.mjs +30 -0
- package/dist/index.cjs +257 -33
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +257 -33
- package/dist/runtime.cjs +1 -1
- package/dist/runtime.d.cts +11 -7
- package/dist/runtime.d.mts +11 -7
- package/dist/runtime.mjs +1 -1
- package/dist/{types-DQWp12Cg.d.mts → types-BwixZ4yh.d.mts} +59 -5
- package/dist/{types-rfkc-TtX.d.cts → types-CiW6Ilds.d.cts} +59 -5
- package/package.json +5 -4
- package/dist/config-CCkOySUT.mjs +0 -29
- package/dist/config-CzrfVSPp.cjs +0 -35
package/dist/runtime.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require(`./config-
|
|
1
|
+
const e=require(`./config-BfVMFkZ4.cjs`),t=t=>t.demo?new e.v:t.preview?new e._(new e.y(t.apiBaseUrl,t.token,t.gifApiKey,t.analyticsContextToken,{agentName:t.agentName,agentAvatarUrl:t.agentAvatarUrl},t.identityToken,t.getIdentityToken,t.chatSurface),t.strings):new e.y(t.apiBaseUrl,t.token,t.gifApiKey,t.analyticsContextToken,{agentName:t.agentName,agentAvatarUrl:t.agentAvatarUrl},t.identityToken,t.getIdentityToken,t.chatSurface);exports.ResultTable=e.u,exports.WidgetAnalyticsChart=e.p,exports.buildWidgetAnalyticsChartModel=e.m,exports.createChatTransport=t,exports.formatResultCell=e.d,exports.renderRich=e.a,exports.resolveConfig=e.t,exports.serializeResultCsv=e.f,exports.useChat=e.n;
|
package/dist/runtime.d.cts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as Visitor, c as
|
|
1
|
+
import { a as Visitor, c as WidgetThemeTokens, d as ActionType, f as AnalyticsVisualization, g as WidgetStrings, h as Transport, i as Source, l as WidgetUser, m as GifResult, n as ChatMessage, o as WidgetConfig, p as DemoSlotsResult, r as FeaturedLink, t as BootstrapInfo, u as ActionResult } from "./types-CiW6Ilds.cjs";
|
|
2
2
|
import * as preact0 from "preact";
|
|
3
3
|
import { JSX } from "preact";
|
|
4
4
|
|
|
5
5
|
//#region src/config.d.ts
|
|
6
|
-
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'gifApiKey' | 'labels' | 'user' | 'analyticsContextToken' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onAction' | 'onHandoff'>> {
|
|
6
|
+
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'themeTokens' | 'gifApiKey' | 'labels' | 'user' | 'analyticsContextToken' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onAction' | 'onHandoff'>> {
|
|
7
7
|
accentColor?: string;
|
|
8
8
|
agentName?: string;
|
|
9
9
|
agentAvatarUrl?: string;
|
|
10
10
|
launcherIcon?: string;
|
|
11
|
+
themeTokens?: WidgetConfig['themeTokens'];
|
|
11
12
|
gifApiKey?: string;
|
|
12
13
|
/** Resolved string table (English defaults + host `labels` overrides). */
|
|
13
14
|
strings: WidgetStrings;
|
|
@@ -58,7 +59,7 @@ interface AnalyticsVisualizationRecommendation {
|
|
|
58
59
|
interface AnalyticsVisualization$1 {
|
|
59
60
|
version?: number;
|
|
60
61
|
presentation?: 'kpi' | 'chart' | 'table';
|
|
61
|
-
type: 'kpi' | 'table' | 'bar' | 'line' | 'stacked_bar';
|
|
62
|
+
type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
|
|
62
63
|
title?: string;
|
|
63
64
|
label?: string;
|
|
64
65
|
value?: string;
|
|
@@ -81,6 +82,8 @@ interface AnalyticsVisualization$1 {
|
|
|
81
82
|
interface ResultColumn {
|
|
82
83
|
key: string;
|
|
83
84
|
label?: string;
|
|
85
|
+
dataType?: AnalyticsVisualizationColumn['dataType'];
|
|
86
|
+
currencyCode?: string;
|
|
84
87
|
}
|
|
85
88
|
interface ResultTableClassNames {
|
|
86
89
|
wrap?: string;
|
|
@@ -95,8 +98,9 @@ type WidgetAnalyticsSeries = {
|
|
|
95
98
|
values: Array<number | null>;
|
|
96
99
|
valueColumn?: AnalyticsVisualizationColumn;
|
|
97
100
|
};
|
|
101
|
+
type WidgetAnalyticsChartType = 'line' | 'bar' | 'stacked_bar';
|
|
98
102
|
type WidgetAnalyticsChartModel = {
|
|
99
|
-
type:
|
|
103
|
+
type: WidgetAnalyticsChartType;
|
|
100
104
|
title: string;
|
|
101
105
|
xAxisTitle: string;
|
|
102
106
|
yAxisTitle: string;
|
|
@@ -105,7 +109,7 @@ type WidgetAnalyticsChartModel = {
|
|
|
105
109
|
summary: string;
|
|
106
110
|
omittedSeriesCount: number;
|
|
107
111
|
};
|
|
108
|
-
declare const buildWidgetAnalyticsChartModel: (visualization: AnalyticsVisualization$1) => WidgetAnalyticsChartModel | null;
|
|
112
|
+
declare const buildWidgetAnalyticsChartModel: (visualization: AnalyticsVisualization$1, overrideType?: WidgetAnalyticsChartType) => WidgetAnalyticsChartModel | null;
|
|
109
113
|
declare const WidgetAnalyticsChart: ({
|
|
110
114
|
model,
|
|
111
115
|
expanded
|
|
@@ -115,7 +119,7 @@ declare const WidgetAnalyticsChart: ({
|
|
|
115
119
|
}) => preact0.JSX.Element;
|
|
116
120
|
//#endregion
|
|
117
121
|
//#region ../centrinfo-results/src/result.d.ts
|
|
118
|
-
declare const formatResultCell: (value: unknown, locale?: string) => string;
|
|
122
|
+
declare const formatResultCell: (value: unknown, locale?: string, column?: ResultColumn) => string;
|
|
119
123
|
declare const serializeResultCsv: (rows: Array<Record<string, unknown>>, columns?: Array<string | ResultColumn>) => string;
|
|
120
124
|
//#endregion
|
|
121
125
|
//#region ../centrinfo-results/src/table.d.ts
|
|
@@ -242,4 +246,4 @@ declare const useChat: (transport: Transport, config: ResolvedConfig, active?: b
|
|
|
242
246
|
//#region src/runtime.d.ts
|
|
243
247
|
declare const createChatTransport: (config: ResolvedConfig) => Transport;
|
|
244
248
|
//#endregion
|
|
245
|
-
export { type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatMessage, type HistoryEntry, type ResolvedConfig, ResultTable, type Source, type Transport, WidgetAnalyticsChart, type WidgetConfig, type WidgetUser, buildWidgetAnalyticsChartModel, createChatTransport, formatResultCell, renderRich, resolveConfig, serializeResultCsv, useChat };
|
|
249
|
+
export { type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatMessage, type HistoryEntry, type ResolvedConfig, ResultTable, type Source, type Transport, WidgetAnalyticsChart, type WidgetConfig, type WidgetThemeTokens, type WidgetUser, buildWidgetAnalyticsChartModel, createChatTransport, formatResultCell, renderRich, resolveConfig, serializeResultCsv, useChat };
|
package/dist/runtime.d.mts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import { a as Visitor, c as
|
|
1
|
+
import { a as Visitor, c as WidgetThemeTokens, d as ActionType, f as AnalyticsVisualization, g as WidgetStrings, h as Transport, i as Source, l as WidgetUser, m as GifResult, n as ChatMessage, o as WidgetConfig, p as DemoSlotsResult, r as FeaturedLink, t as BootstrapInfo, u as ActionResult } from "./types-BwixZ4yh.mjs";
|
|
2
2
|
import * as preact0 from "preact";
|
|
3
3
|
import { JSX } from "preact";
|
|
4
4
|
|
|
5
5
|
//#region src/config.d.ts
|
|
6
|
-
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'gifApiKey' | 'labels' | 'user' | 'analyticsContextToken' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onAction' | 'onHandoff'>> {
|
|
6
|
+
interface ResolvedConfig extends Required<Omit<WidgetConfig, 'accentColor' | 'agentName' | 'agentAvatarUrl' | 'launcherIcon' | 'themeTokens' | 'gifApiKey' | 'labels' | 'user' | 'analyticsContextToken' | 'identityToken' | 'getIdentityToken' | 'customLauncherSelector' | 'proactiveMessage' | 'proactiveOnPaths' | 'onOpen' | 'onClose' | 'onShow' | 'onHide' | 'onUnreadChange' | 'onMessage' | 'onAction' | 'onHandoff'>> {
|
|
7
7
|
accentColor?: string;
|
|
8
8
|
agentName?: string;
|
|
9
9
|
agentAvatarUrl?: string;
|
|
10
10
|
launcherIcon?: string;
|
|
11
|
+
themeTokens?: WidgetConfig['themeTokens'];
|
|
11
12
|
gifApiKey?: string;
|
|
12
13
|
/** Resolved string table (English defaults + host `labels` overrides). */
|
|
13
14
|
strings: WidgetStrings;
|
|
@@ -58,7 +59,7 @@ interface AnalyticsVisualizationRecommendation {
|
|
|
58
59
|
interface AnalyticsVisualization$1 {
|
|
59
60
|
version?: number;
|
|
60
61
|
presentation?: 'kpi' | 'chart' | 'table';
|
|
61
|
-
type: 'kpi' | 'table' | 'bar' | 'line' | 'stacked_bar';
|
|
62
|
+
type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
|
|
62
63
|
title?: string;
|
|
63
64
|
label?: string;
|
|
64
65
|
value?: string;
|
|
@@ -81,6 +82,8 @@ interface AnalyticsVisualization$1 {
|
|
|
81
82
|
interface ResultColumn {
|
|
82
83
|
key: string;
|
|
83
84
|
label?: string;
|
|
85
|
+
dataType?: AnalyticsVisualizationColumn['dataType'];
|
|
86
|
+
currencyCode?: string;
|
|
84
87
|
}
|
|
85
88
|
interface ResultTableClassNames {
|
|
86
89
|
wrap?: string;
|
|
@@ -95,8 +98,9 @@ type WidgetAnalyticsSeries = {
|
|
|
95
98
|
values: Array<number | null>;
|
|
96
99
|
valueColumn?: AnalyticsVisualizationColumn;
|
|
97
100
|
};
|
|
101
|
+
type WidgetAnalyticsChartType = 'line' | 'bar' | 'stacked_bar';
|
|
98
102
|
type WidgetAnalyticsChartModel = {
|
|
99
|
-
type:
|
|
103
|
+
type: WidgetAnalyticsChartType;
|
|
100
104
|
title: string;
|
|
101
105
|
xAxisTitle: string;
|
|
102
106
|
yAxisTitle: string;
|
|
@@ -105,7 +109,7 @@ type WidgetAnalyticsChartModel = {
|
|
|
105
109
|
summary: string;
|
|
106
110
|
omittedSeriesCount: number;
|
|
107
111
|
};
|
|
108
|
-
declare const buildWidgetAnalyticsChartModel: (visualization: AnalyticsVisualization$1) => WidgetAnalyticsChartModel | null;
|
|
112
|
+
declare const buildWidgetAnalyticsChartModel: (visualization: AnalyticsVisualization$1, overrideType?: WidgetAnalyticsChartType) => WidgetAnalyticsChartModel | null;
|
|
109
113
|
declare const WidgetAnalyticsChart: ({
|
|
110
114
|
model,
|
|
111
115
|
expanded
|
|
@@ -115,7 +119,7 @@ declare const WidgetAnalyticsChart: ({
|
|
|
115
119
|
}) => preact0.JSX.Element;
|
|
116
120
|
//#endregion
|
|
117
121
|
//#region ../centrinfo-results/src/result.d.ts
|
|
118
|
-
declare const formatResultCell: (value: unknown, locale?: string) => string;
|
|
122
|
+
declare const formatResultCell: (value: unknown, locale?: string, column?: ResultColumn) => string;
|
|
119
123
|
declare const serializeResultCsv: (rows: Array<Record<string, unknown>>, columns?: Array<string | ResultColumn>) => string;
|
|
120
124
|
//#endregion
|
|
121
125
|
//#region ../centrinfo-results/src/table.d.ts
|
|
@@ -242,4 +246,4 @@ declare const useChat: (transport: Transport, config: ResolvedConfig, active?: b
|
|
|
242
246
|
//#region src/runtime.d.ts
|
|
243
247
|
declare const createChatTransport: (config: ResolvedConfig) => Transport;
|
|
244
248
|
//#endregion
|
|
245
|
-
export { type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatMessage, type HistoryEntry, type ResolvedConfig, ResultTable, type Source, type Transport, WidgetAnalyticsChart, type WidgetConfig, type WidgetUser, buildWidgetAnalyticsChartModel, createChatTransport, formatResultCell, renderRich, resolveConfig, serializeResultCsv, useChat };
|
|
249
|
+
export { type AnalyticsVisualization, type BootstrapInfo, type ChatApi, type ChatMessage, type HistoryEntry, type ResolvedConfig, ResultTable, type Source, type Transport, WidgetAnalyticsChart, type WidgetConfig, type WidgetThemeTokens, type WidgetUser, buildWidgetAnalyticsChartModel, createChatTransport, formatResultCell, renderRich, resolveConfig, serializeResultCsv, useChat };
|
package/dist/runtime.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,a as t,d as n,f as r,
|
|
1
|
+
import{_ as e,a as t,d as n,f as r,m as i,n as a,p as o,t as s,u as c,v as l,y as u}from"./config-CHvO9tW1.mjs";const d=t=>t.demo?new l:t.preview?new e(new u(t.apiBaseUrl,t.token,t.gifApiKey,t.analyticsContextToken,{agentName:t.agentName,agentAvatarUrl:t.agentAvatarUrl},t.identityToken,t.getIdentityToken,t.chatSurface),t.strings):new u(t.apiBaseUrl,t.token,t.gifApiKey,t.analyticsContextToken,{agentName:t.agentName,agentAvatarUrl:t.agentAvatarUrl},t.identityToken,t.getIdentityToken,t.chatSurface);export{c as ResultTable,o as WidgetAnalyticsChart,i as buildWidgetAnalyticsChartModel,d as createChatTransport,n as formatResultCell,t as renderRich,s as resolveConfig,r as serializeResultCsv,a as useChat};
|
|
@@ -170,7 +170,7 @@ interface AnalyticsVisualizationExplanation {
|
|
|
170
170
|
interface AnalyticsVisualization {
|
|
171
171
|
version?: number;
|
|
172
172
|
presentation?: 'kpi' | 'chart' | 'table';
|
|
173
|
-
type: 'kpi' | 'table' | 'bar' | 'line' | 'stacked_bar';
|
|
173
|
+
type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
|
|
174
174
|
title?: string;
|
|
175
175
|
label?: string;
|
|
176
176
|
value?: string;
|
|
@@ -241,6 +241,30 @@ interface LiveEventsResult {
|
|
|
241
241
|
conversationEnded?: boolean;
|
|
242
242
|
events: LiveEvent[];
|
|
243
243
|
}
|
|
244
|
+
interface AuthenticatedHistoryMessage {
|
|
245
|
+
id: string;
|
|
246
|
+
role: 'user' | 'assistant' | 'system';
|
|
247
|
+
content: string;
|
|
248
|
+
authorName?: string;
|
|
249
|
+
messageType?: string;
|
|
250
|
+
sources?: Array<{
|
|
251
|
+
title?: string;
|
|
252
|
+
url?: string;
|
|
253
|
+
}>;
|
|
254
|
+
visualization?: AnalyticsVisualization;
|
|
255
|
+
createdAt: string;
|
|
256
|
+
}
|
|
257
|
+
interface AuthenticatedHistoryConversation {
|
|
258
|
+
sessionId: string;
|
|
259
|
+
title: string;
|
|
260
|
+
ended: boolean;
|
|
261
|
+
lastSeenAt: string;
|
|
262
|
+
messages: AuthenticatedHistoryMessage[];
|
|
263
|
+
}
|
|
264
|
+
interface AuthenticatedHistoryResult {
|
|
265
|
+
activeSessionId?: string;
|
|
266
|
+
conversations: AuthenticatedHistoryConversation[];
|
|
267
|
+
}
|
|
244
268
|
interface StreamCallbacks {
|
|
245
269
|
/** Called with each incremental text chunk. */
|
|
246
270
|
onChunk: (text: string) => void;
|
|
@@ -304,6 +328,8 @@ interface GifResult {
|
|
|
304
328
|
*/
|
|
305
329
|
interface Transport {
|
|
306
330
|
bootstrap(): Promise<BootstrapInfo>;
|
|
331
|
+
/** Server-backed history for the verified SDK customer. Anonymous returns empty. */
|
|
332
|
+
history(): Promise<AuthenticatedHistoryResult>;
|
|
307
333
|
/** Stream a turn; resolves with final metadata once `done`. */
|
|
308
334
|
stream(question: string, sessionId: string, cb: StreamCallbacks): Promise<TurnResult>;
|
|
309
335
|
/** Poll for staff/system events after a timestamp during live handoff. */
|
|
@@ -345,10 +371,13 @@ interface Transport {
|
|
|
345
371
|
}
|
|
346
372
|
//#endregion
|
|
347
373
|
//#region src/types.d.ts
|
|
374
|
+
type ChatSurface = 'floating' | 'full-page';
|
|
348
375
|
/** Public configuration surface passed to `Centrinfo.init()` / <CentrinfoWidget>. */
|
|
349
376
|
interface WidgetConfig {
|
|
350
377
|
/** The org's public chat token (`pub_*`). Required. It IS the org identity. */
|
|
351
378
|
token: string;
|
|
379
|
+
/** Conversation namespace. Set by the SDK surface mounting the chat. */
|
|
380
|
+
chatSurface?: ChatSurface;
|
|
352
381
|
/** Short-lived server-signed context token for governed customer analytics. */
|
|
353
382
|
analyticsContextToken?: string;
|
|
354
383
|
/** Short-lived SDK customer identity JWT for authenticated chat access. */
|
|
@@ -359,6 +388,11 @@ interface WidgetConfig {
|
|
|
359
388
|
apiBaseUrl?: string;
|
|
360
389
|
/** Brand accent (any CSS color). Overrides the persona/default green. */
|
|
361
390
|
accentColor?: string;
|
|
391
|
+
/**
|
|
392
|
+
* Full brand token map for SDK-rendered chat surfaces. `accentColor` remains
|
|
393
|
+
* a shorthand for `themeTokens.accent` and wins when both are supplied.
|
|
394
|
+
*/
|
|
395
|
+
themeTokens?: WidgetThemeTokens;
|
|
362
396
|
/** Optional display-name override. Normally loaded from the token bootstrap. */
|
|
363
397
|
agentName?: string;
|
|
364
398
|
/** Optional header avatar URL override. Normally loaded from the token bootstrap. */
|
|
@@ -391,8 +425,9 @@ interface WidgetConfig {
|
|
|
391
425
|
* - `session` — `sessionStorage`, cleared when the tab closes (better on
|
|
392
426
|
* shared / kiosk machines so the next visitor can't read prior chats).
|
|
393
427
|
* - `none` — never persisted; the transcript lives only in memory.
|
|
394
|
-
*
|
|
395
|
-
*
|
|
428
|
+
* Authenticated SDK users also restore retained conversations from the
|
|
429
|
+
* backend on a new browser or device. This setting controls the local cache
|
|
430
|
+
* and remains the only persistence layer for anonymous visitors.
|
|
396
431
|
*/
|
|
397
432
|
persistence?: 'local' | 'session' | 'none';
|
|
398
433
|
/**
|
|
@@ -440,7 +475,7 @@ interface WidgetConfig {
|
|
|
440
475
|
/** CSS selector for host-page element(s) that open the widget on click
|
|
441
476
|
* (your own launcher). Listeners are (re)bound automatically. */
|
|
442
477
|
customLauncherSelector?: string;
|
|
443
|
-
/** Auto-logout (wipe local
|
|
478
|
+
/** Auto-logout (wipe local cache) after this many minutes of inactivity.
|
|
444
479
|
* 0 / omitted = never. Use on shared / kiosk devices. */
|
|
445
480
|
sessionDurationMinutes?: number;
|
|
446
481
|
/**
|
|
@@ -476,6 +511,25 @@ interface WidgetConfig {
|
|
|
476
511
|
onAction?: (action: string) => void;
|
|
477
512
|
onHandoff?: () => void;
|
|
478
513
|
}
|
|
514
|
+
/** Shared theme tokens consumed by the floating widget and full-page chat app. */
|
|
515
|
+
interface WidgetThemeTokens {
|
|
516
|
+
accent?: string;
|
|
517
|
+
accentStrong?: string;
|
|
518
|
+
accentSoft?: string;
|
|
519
|
+
accentText?: string;
|
|
520
|
+
background?: string;
|
|
521
|
+
surface?: string;
|
|
522
|
+
surfaceMuted?: string;
|
|
523
|
+
text?: string;
|
|
524
|
+
mutedText?: string;
|
|
525
|
+
border?: string;
|
|
526
|
+
shadow?: string;
|
|
527
|
+
radius?: string;
|
|
528
|
+
fontFamily?: string;
|
|
529
|
+
success?: string;
|
|
530
|
+
warning?: string;
|
|
531
|
+
danger?: string;
|
|
532
|
+
}
|
|
479
533
|
/** A B2B company / account the visitor belongs to (Intercom "Company object").
|
|
480
534
|
* Folded into the session metadata for the staff inbox. */
|
|
481
535
|
interface WidgetCompany {
|
|
@@ -658,4 +712,4 @@ interface SchedulerInfo {
|
|
|
658
712
|
bookingLink?: string;
|
|
659
713
|
}
|
|
660
714
|
//#endregion
|
|
661
|
-
export { Visitor as a,
|
|
715
|
+
export { Visitor as a, WidgetThemeTokens as c, ActionType as d, AnalyticsVisualization as f, WidgetStrings as g, Transport as h, Source as i, WidgetUser as l, GifResult as m, ChatMessage as n, WidgetConfig as o, DemoSlotsResult as p, FeaturedLink as r, WidgetHandle as s, BootstrapInfo as t, ActionResult as u };
|
|
@@ -167,7 +167,7 @@ interface AnalyticsVisualizationExplanation {
|
|
|
167
167
|
interface AnalyticsVisualization {
|
|
168
168
|
version?: number;
|
|
169
169
|
presentation?: 'kpi' | 'chart' | 'table';
|
|
170
|
-
type: 'kpi' | 'table' | 'bar' | 'line' | 'stacked_bar';
|
|
170
|
+
type: 'kpi' | 'table' | 'bar' | 'line' | 'area' | 'stacked_bar' | 'pie' | 'scatter' | 'funnel';
|
|
171
171
|
title?: string;
|
|
172
172
|
label?: string;
|
|
173
173
|
value?: string;
|
|
@@ -238,6 +238,30 @@ interface LiveEventsResult {
|
|
|
238
238
|
conversationEnded?: boolean;
|
|
239
239
|
events: LiveEvent[];
|
|
240
240
|
}
|
|
241
|
+
interface AuthenticatedHistoryMessage {
|
|
242
|
+
id: string;
|
|
243
|
+
role: 'user' | 'assistant' | 'system';
|
|
244
|
+
content: string;
|
|
245
|
+
authorName?: string;
|
|
246
|
+
messageType?: string;
|
|
247
|
+
sources?: Array<{
|
|
248
|
+
title?: string;
|
|
249
|
+
url?: string;
|
|
250
|
+
}>;
|
|
251
|
+
visualization?: AnalyticsVisualization;
|
|
252
|
+
createdAt: string;
|
|
253
|
+
}
|
|
254
|
+
interface AuthenticatedHistoryConversation {
|
|
255
|
+
sessionId: string;
|
|
256
|
+
title: string;
|
|
257
|
+
ended: boolean;
|
|
258
|
+
lastSeenAt: string;
|
|
259
|
+
messages: AuthenticatedHistoryMessage[];
|
|
260
|
+
}
|
|
261
|
+
interface AuthenticatedHistoryResult {
|
|
262
|
+
activeSessionId?: string;
|
|
263
|
+
conversations: AuthenticatedHistoryConversation[];
|
|
264
|
+
}
|
|
241
265
|
interface StreamCallbacks {
|
|
242
266
|
/** Called with each incremental text chunk. */
|
|
243
267
|
onChunk: (text: string) => void;
|
|
@@ -301,6 +325,8 @@ interface GifResult {
|
|
|
301
325
|
*/
|
|
302
326
|
interface Transport {
|
|
303
327
|
bootstrap(): Promise<BootstrapInfo>;
|
|
328
|
+
/** Server-backed history for the verified SDK customer. Anonymous returns empty. */
|
|
329
|
+
history(): Promise<AuthenticatedHistoryResult>;
|
|
304
330
|
/** Stream a turn; resolves with final metadata once `done`. */
|
|
305
331
|
stream(question: string, sessionId: string, cb: StreamCallbacks): Promise<TurnResult>;
|
|
306
332
|
/** Poll for staff/system events after a timestamp during live handoff. */
|
|
@@ -342,10 +368,13 @@ interface Transport {
|
|
|
342
368
|
}
|
|
343
369
|
//#endregion
|
|
344
370
|
//#region src/types.d.ts
|
|
371
|
+
type ChatSurface = 'floating' | 'full-page';
|
|
345
372
|
/** Public configuration surface passed to `Centrinfo.init()` / <CentrinfoWidget>. */
|
|
346
373
|
interface WidgetConfig {
|
|
347
374
|
/** The org's public chat token (`pub_*`). Required. It IS the org identity. */
|
|
348
375
|
token: string;
|
|
376
|
+
/** Conversation namespace. Set by the SDK surface mounting the chat. */
|
|
377
|
+
chatSurface?: ChatSurface;
|
|
349
378
|
/** Short-lived server-signed context token for governed customer analytics. */
|
|
350
379
|
analyticsContextToken?: string;
|
|
351
380
|
/** Short-lived SDK customer identity JWT for authenticated chat access. */
|
|
@@ -356,6 +385,11 @@ interface WidgetConfig {
|
|
|
356
385
|
apiBaseUrl?: string;
|
|
357
386
|
/** Brand accent (any CSS color). Overrides the persona/default green. */
|
|
358
387
|
accentColor?: string;
|
|
388
|
+
/**
|
|
389
|
+
* Full brand token map for SDK-rendered chat surfaces. `accentColor` remains
|
|
390
|
+
* a shorthand for `themeTokens.accent` and wins when both are supplied.
|
|
391
|
+
*/
|
|
392
|
+
themeTokens?: WidgetThemeTokens;
|
|
359
393
|
/** Optional display-name override. Normally loaded from the token bootstrap. */
|
|
360
394
|
agentName?: string;
|
|
361
395
|
/** Optional header avatar URL override. Normally loaded from the token bootstrap. */
|
|
@@ -388,8 +422,9 @@ interface WidgetConfig {
|
|
|
388
422
|
* - `session` — `sessionStorage`, cleared when the tab closes (better on
|
|
389
423
|
* shared / kiosk machines so the next visitor can't read prior chats).
|
|
390
424
|
* - `none` — never persisted; the transcript lives only in memory.
|
|
391
|
-
*
|
|
392
|
-
*
|
|
425
|
+
* Authenticated SDK users also restore retained conversations from the
|
|
426
|
+
* backend on a new browser or device. This setting controls the local cache
|
|
427
|
+
* and remains the only persistence layer for anonymous visitors.
|
|
393
428
|
*/
|
|
394
429
|
persistence?: 'local' | 'session' | 'none';
|
|
395
430
|
/**
|
|
@@ -437,7 +472,7 @@ interface WidgetConfig {
|
|
|
437
472
|
/** CSS selector for host-page element(s) that open the widget on click
|
|
438
473
|
* (your own launcher). Listeners are (re)bound automatically. */
|
|
439
474
|
customLauncherSelector?: string;
|
|
440
|
-
/** Auto-logout (wipe local
|
|
475
|
+
/** Auto-logout (wipe local cache) after this many minutes of inactivity.
|
|
441
476
|
* 0 / omitted = never. Use on shared / kiosk devices. */
|
|
442
477
|
sessionDurationMinutes?: number;
|
|
443
478
|
/**
|
|
@@ -473,6 +508,25 @@ interface WidgetConfig {
|
|
|
473
508
|
onAction?: (action: string) => void;
|
|
474
509
|
onHandoff?: () => void;
|
|
475
510
|
}
|
|
511
|
+
/** Shared theme tokens consumed by the floating widget and full-page chat app. */
|
|
512
|
+
interface WidgetThemeTokens {
|
|
513
|
+
accent?: string;
|
|
514
|
+
accentStrong?: string;
|
|
515
|
+
accentSoft?: string;
|
|
516
|
+
accentText?: string;
|
|
517
|
+
background?: string;
|
|
518
|
+
surface?: string;
|
|
519
|
+
surfaceMuted?: string;
|
|
520
|
+
text?: string;
|
|
521
|
+
mutedText?: string;
|
|
522
|
+
border?: string;
|
|
523
|
+
shadow?: string;
|
|
524
|
+
radius?: string;
|
|
525
|
+
fontFamily?: string;
|
|
526
|
+
success?: string;
|
|
527
|
+
warning?: string;
|
|
528
|
+
danger?: string;
|
|
529
|
+
}
|
|
476
530
|
/** A B2B company / account the visitor belongs to (Intercom "Company object").
|
|
477
531
|
* Folded into the session metadata for the staff inbox. */
|
|
478
532
|
interface WidgetCompany {
|
|
@@ -655,4 +709,4 @@ interface SchedulerInfo {
|
|
|
655
709
|
bookingLink?: string;
|
|
656
710
|
}
|
|
657
711
|
//#endregion
|
|
658
|
-
export { Visitor as a,
|
|
712
|
+
export { Visitor as a, WidgetThemeTokens as c, ActionType as d, AnalyticsVisualization as f, WidgetStrings as g, Transport as h, Source as i, WidgetUser as l, GifResult as m, ChatMessage as n, WidgetConfig as o, DemoSlotsResult as p, FeaturedLink as r, WidgetHandle as s, BootstrapInfo as t, ActionResult as u };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@accurix/centrinfo-widget",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -43,9 +43,6 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"preact": "^10.27.0"
|
|
45
45
|
},
|
|
46
|
-
"peerDependencies": {
|
|
47
|
-
"@accurix/centrinfo": "^0.1.1"
|
|
48
|
-
},
|
|
49
46
|
"devDependencies": {
|
|
50
47
|
"@playwright/test": "^1.50.0",
|
|
51
48
|
"@types/node": "^22.0.0",
|
|
@@ -56,10 +53,14 @@
|
|
|
56
53
|
"typescript": "^5.8.0",
|
|
57
54
|
"vite": "^7.0.0",
|
|
58
55
|
"vitest": "^3.2.0",
|
|
56
|
+
"wrangler": "^4.91.0",
|
|
59
57
|
"@accurix/centrinfo-results": "^0.1.0",
|
|
60
58
|
"@accurix/web-config-eslint": "^0.0.0"
|
|
61
59
|
},
|
|
62
60
|
"module": "./dist/index.mjs",
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@accurix/centrinfo": "^0.1.2"
|
|
63
|
+
},
|
|
63
64
|
"publishConfig": {
|
|
64
65
|
"access": "public",
|
|
65
66
|
"registry": "https://registry.npmjs.org/"
|