@nex-ai-ch/widget-sdk 0.7.0 → 0.8.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.
@@ -2,4 +2,4 @@
2
2
  * The core version this package was built from. Bumped by the release commit
3
3
  * together with widget/package.json (core-version.test.ts fails otherwise).
4
4
  */
5
- export declare const CORE_VERSION = "0.7.0";
5
+ export declare const CORE_VERSION = "0.8.0";
@@ -2,4 +2,4 @@
2
2
  * The core version this package was built from. Bumped by the release commit
3
3
  * together with widget/package.json (core-version.test.ts fails otherwise).
4
4
  */
5
- export const CORE_VERSION = '0.7.0';
5
+ export const CORE_VERSION = '0.8.0';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { NexWidgetError } from './nex-widget.js';
2
- export type { EntryPointOrigin, ErrorCode, HistoryLayout, InitConfig, Lang, MountMode, NexWidgetError, PageContext, PageContextInput, Position, RouteNode, ThemeOverride, WidgetEvents, WidgetHandle, WidgetMode, } from './nex-widget.js';
2
+ export type { EntryPointOrigin, ErrorCode, HistoryLayout, InitConfig, Lang, MountMode, NexWidgetError, PageContext, PageContextInput, Position, RouteNode, ThemeOverride, UserSettings, WidgetEvents, WidgetHandle, WidgetMode, } from './nex-widget.js';
3
3
  export type { LoaderConfig } from './loader.js';
4
4
  /** The core version this package was built from. */
5
5
  export declare const coreVersion: string;
@@ -53,15 +53,31 @@ export type ErrorCode =
53
53
  * tree is dropped with it. Reported once per widget, and never before
54
54
  * `init()` resolved. */
55
55
  | 'page_context_too_large'
56
+ /** `/chat` refused the account id (403 `account_unknown`): the signed-in
57
+ * person does not have it. The question stays in the composer: no retry,
58
+ * no session reset. */
59
+ | 'account_unknown'
60
+ /** The page reports an account id but the box got no valid token (401
61
+ * `auth_missing`). The widget has pulled `getAuthToken` once more and
62
+ * retried the same question once; this event means that failed too, or the
63
+ * host has no token callback. The question stays in the composer. Do not
64
+ * sign the visitor out on this alone; set `currentMemberId` to `null` once
65
+ * the person is signed out. */
66
+ | 'auth_missing'
67
+ /** The box cut `pageContext.routeActions` (it was over its limits).
68
+ * Informational: reported once per tree hash, never rejects `init()`. */
69
+ | 'route_actions_truncated'
56
70
 
57
71
  /**
58
72
  * One page of the host application and the pages below it. The keys of
59
73
  * `routes` are names, not paths. `path` starts with `/` and uses only
60
74
  * `[A-Za-z0-9/_.:-]`; the server keeps at most 100 pages, 10 actions per page,
61
- * 200 characters per text and 4 levels.
75
+ * 400 characters per text, 80 per label and 4 levels.
62
76
  */
63
77
  export interface RouteNode {
64
78
  path: string
79
+ /** Short name of the page, at most 80 characters. */
80
+ label?: string
65
81
  description?: string
66
82
  actions?: Array<{ action: string }>
67
83
  routes?: Record<string, RouteNode>
@@ -84,6 +100,14 @@ export interface PageContext {
84
100
  * Kept by the SDK until a new one is handed over — once at `init()` is
85
101
  * enough. Not sent above 64 KB serialised (`page_context_too_large`). */
86
102
  routeActions?: RouteNode
103
+ /**
104
+ * The account the host is working in right now (0.8.0): an id from the
105
+ * customer system's list of the person's accounts. Wire rule: the key
106
+ * present means "take it" (`null` = explicitly no account, no fallback to
107
+ * the deprecated top-level `currentMemberId`); the key absent keeps the
108
+ * previous value. A hint: the box uses it only when the id is on the list.
109
+ */
110
+ currentMemberId?: string | null
87
111
  }
88
112
 
89
113
  /**
@@ -113,6 +137,12 @@ export interface ThemeOverride {
113
137
  scheme?: 'light' | 'dark'
114
138
  }
115
139
 
140
+ /** Widget settings a host page may set for its visitors. */
141
+ export interface UserSettings {
142
+ /** Hide the language picker; the widget keeps the language it was given. */
143
+ hideLanguageSelection?: boolean
144
+ }
145
+
116
146
  export interface InitConfig {
117
147
  /** Profile key from the tenant configuration, e.g. 'website' or 'support'. */
118
148
  profile: string
@@ -124,8 +154,11 @@ export interface InitConfig {
124
154
  authToken?: string
125
155
  /** The account the visitor is working in right now: an id from the customer
126
156
  * system's list of the person's accounts. A hint — the box uses it only
127
- * when the id is on that list. Change it later with `setCurrentMember()`. */
157
+ * when the id is on that list. Change it later with `setCurrentMember()`.
158
+ * @deprecated Removed in the release after 0.8.0; use `pageContext.currentMemberId`. */
128
159
  currentMemberId?: string
160
+ /** Per-visitor widget settings the host decides. */
161
+ userSettings?: UserSettings
129
162
  /** `path` and `title` default to the host page's own `location.pathname`
130
163
  * and `document.title`; either still wins when given explicitly. The
131
164
  * absolute `url` is derived from `path` by the SDK. */
@@ -206,7 +239,8 @@ export interface WidgetHandle {
206
239
  setAuthToken(token: string): void
207
240
  updatePageContext(context: PageContextInput): void
208
241
  /** The account the visitor is working in now; `null` for none. Takes effect
209
- * with the next message and never starts a new conversation. */
242
+ * with the next message and never starts a new conversation.
243
+ * @deprecated Removed in the release after 0.8.0; use `pageContext.currentMemberId`. */
210
244
  setCurrentMember(id: string | null): void
211
245
  /** Removes the iframe and every listener. Irreversible — see hide(). */
212
246
  destroy(): void
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nex-ai-ch/widget-sdk",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Typings and loader for the NEX Widget SDK. The widget itself is served by your own box.",
5
5
  "type": "module",
6
6
  "sideEffects": false,