@ada-cx/messaging-sdk 1.0.0-setup.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.
Files changed (61) hide show
  1. package/README.md +211 -0
  2. package/dist/client/ada-settings-reader.d.ts +10 -0
  3. package/dist/client/client-channel-handlers.d.ts +92 -0
  4. package/dist/client/client-errors.d.ts +7 -0
  5. package/dist/client/client-frame-constants.d.ts +41 -0
  6. package/dist/client/client-frame-runtime.d.ts +54 -0
  7. package/dist/client/client-host-runtime.d.ts +73 -0
  8. package/dist/client/client-types.d.ts +231 -0
  9. package/dist/client/client.d.ts +843 -0
  10. package/dist/client/config-helpers.d.ts +157 -0
  11. package/dist/client/constants.d.ts +61 -0
  12. package/dist/client/core-channel-test-harness.d.ts +47 -0
  13. package/dist/client/embed-interface.d.ts +172 -0
  14. package/dist/client/embed-lifecycle.d.ts +12 -0
  15. package/dist/client/fallback-html.d.ts +1 -0
  16. package/dist/client/frame-manager.d.ts +64 -0
  17. package/dist/client/frame-styles.d.ts +164 -0
  18. package/dist/client/frame-visibility.d.ts +53 -0
  19. package/dist/client/integration-manager.d.ts +73 -0
  20. package/dist/client/legacy-callback-adapter.d.ts +22 -0
  21. package/dist/client/mask-element.d.ts +19 -0
  22. package/dist/client/proactive/index.d.ts +5 -0
  23. package/dist/client/proactive/proactive-channel.d.ts +33 -0
  24. package/dist/client/proactive/proactive-runtime.d.ts +65 -0
  25. package/dist/client/proactive/proactive-utils.d.ts +51 -0
  26. package/dist/client/sdk-error-reporter.d.ts +22 -0
  27. package/dist/client/sdk-event-bus.d.ts +116 -0
  28. package/dist/client/service-worker-notifications.d.ts +1 -0
  29. package/dist/client/url-business-events.d.ts +19 -0
  30. package/dist/frame-channel/frame-channel.d.ts +64 -0
  31. package/dist/frame-channel/frame-child.d.ts +45 -0
  32. package/dist/frame-channel/index.d.ts +3 -0
  33. package/dist/frame-channel/types.d.ts +736 -0
  34. package/dist/helpers/rollout.d.ts +18 -0
  35. package/dist/host-telemetry.d.ts +15 -0
  36. package/dist/index.d.ts +8 -0
  37. package/dist/logger.d.ts +59 -0
  38. package/dist/mobile-webview-runtime.d.ts +122 -0
  39. package/dist/npm/build-info.d.cts +17 -0
  40. package/dist/npm/build-info.d.ts +17 -0
  41. package/dist/npm/index.cjs +276 -0
  42. package/dist/npm/index.cjs.map +1 -0
  43. package/dist/npm/index.d.cts +15 -0
  44. package/dist/npm/index.d.ts +9 -0
  45. package/dist/npm/index.js +270 -0
  46. package/dist/npm/index.js.map +1 -0
  47. package/dist/npm/loader.d.cts +120 -0
  48. package/dist/npm/loader.d.ts +120 -0
  49. package/dist/npm/testing.cjs +155 -0
  50. package/dist/npm/testing.cjs.map +1 -0
  51. package/dist/npm/testing.d.cts +39 -0
  52. package/dist/npm/testing.d.ts +39 -0
  53. package/dist/npm/testing.js +154 -0
  54. package/dist/npm/testing.js.map +1 -0
  55. package/dist/sdk-module-loader.d.ts +1 -0
  56. package/dist/shared-utils/clusters.d.ts +5 -0
  57. package/dist/shared-utils/csat.d.ts +116 -0
  58. package/dist/shared-utils/host-telemetry.d.ts +35 -0
  59. package/dist/shared-utils/index.d.ts +3 -0
  60. package/dist/voice/voice-manager.d.ts +120 -0
  61. package/package.json +77 -0
@@ -0,0 +1,231 @@
1
+ export type MetaFieldValue = string | number | boolean | null;
2
+ export interface AdaSdkEventContext {
3
+ eventKey: string;
4
+ }
5
+ export type AdaSdkEventCallback = (event: unknown, context: AdaSdkEventContext) => void;
6
+ export type BeforeSend = (message: {
7
+ text: string;
8
+ }) => {
9
+ text: string;
10
+ } | false | Promise<{
11
+ text: string;
12
+ } | false>;
13
+ export interface Delegate {
14
+ beforeSend?: BeforeSend;
15
+ }
16
+ export interface PublicAgentInfo {
17
+ id: string;
18
+ name: string;
19
+ avatarUrl?: string;
20
+ }
21
+ export interface AdaReadyCallbackParams {
22
+ isRolledOut: boolean;
23
+ }
24
+ export interface AdaMessagingSettings {
25
+ /** Full base URL for the Ada API; overrides all default derivation. */
26
+ endpoint?: string;
27
+ /**
28
+ * Ada base-domain segment (e.g. "ada", "ada-dev2"), combined with `handle`
29
+ * and any regional `cluster` into the API host
30
+ * `https://<handle>.[<cluster>.]<domain>.support`. For a full URL override,
31
+ * use `endpoint` instead.
32
+ */
33
+ domain?: string;
34
+ /**
35
+ * Ada cluster: either a full base domain (e.g. "ada-dev2.support",
36
+ * "eu.ada.support", "localhost") used as-is, or a regional segment (e.g.
37
+ * "eu") combined with `domain`.
38
+ */
39
+ cluster?: string | null;
40
+ /** Language code (e.g. "en", "fr") */
41
+ language?: string;
42
+ /** Answer response id to trigger as the initial greeting (legacy CDN parity). */
43
+ greeting?: string;
44
+ /** Short-lived identity token returned by the Platform API auth-token endpoint. */
45
+ identityToken?: string;
46
+ /**
47
+ * URL of a customer-hosted app frame to mount in place of Ada's default
48
+ * conversation UI. Must be an absolute `https:` URL (or `http:` on a
49
+ * loopback host for local development); any other value is
50
+ * ignored with a warning. Ada enables custom apps per handle by
51
+ * allowlisting your app's origin server-side — ask your Ada team to add
52
+ * it; a URL whose origin is not allowlisted is dropped with a console
53
+ * warning and Ada's default app mounts instead. The custom frame keeps its
54
+ * own origin (sandboxed with `allow-same-origin`) and receives
55
+ * conversation state through `@ada-cx/messaging-bridge`, never through URL
56
+ * query params. When the custom frame fails to load or complete its bridge
57
+ * handshake, Messaging falls back to Ada's default app unless
58
+ * `appUrlFallback` is `false`.
59
+ */
60
+ appUrl?: string;
61
+ /**
62
+ * When `false`, a failing custom `appUrl` frame is NOT replaced with Ada's
63
+ * default app; activation fails instead. Defaults to true. Only meaningful
64
+ * together with `appUrl`.
65
+ */
66
+ appUrlFallback?: boolean;
67
+ /** Metafield key/value pairs passed to the bot */
68
+ metaFields?: Record<string, MetaFieldValue>;
69
+ /**
70
+ * When true, `reset({ metaFields })` may apply caller-supplied metaFields.
71
+ * Defaults to false so an end user cannot inject or override metaFields by
72
+ * calling `reset()` (e.g. from the browser console). The value is locked on
73
+ * the first config and cannot be changed at runtime. (MES-542)
74
+ */
75
+ allowMetaFieldsInReset?: boolean;
76
+ /**
77
+ * When true, unlocks the programmatic-control surface — `sendMessage()`,
78
+ * `setComposerText()`, `setDelegate()`, `getMessages()`, `getConversation()`,
79
+ * and the `ada:message:sent` / `ada:message:received` events. Defaults to
80
+ * false for security; the value is locked on the first config and cannot be
81
+ * changed at runtime. (MES-981)
82
+ */
83
+ enableProgrammaticControl?: boolean;
84
+ /** Custom style overrides (tintColor, surfaceColor, etc.) */
85
+ styles?: Record<string, string>;
86
+ /** Button and chat drawer alignment: "right" (default), "left", or "auto" */
87
+ align?: "right" | "left" | "auto";
88
+ /** Defer SDK initialization until start() is explicitly called */
89
+ lazy?: boolean;
90
+ /**
91
+ * Where to mount the chat when the floating drawer is not desired.
92
+ * Accepts an `HTMLElement` or an element id string.
93
+ */
94
+ parentElement?: string | HTMLElement;
95
+ /**
96
+ * Hide the widget's built-in ChatHeader, for hosts that render their own
97
+ * header chrome around the widget. Defaults to false, so parentElement
98
+ * consumers (mobile webview, React Native) keep their header.
99
+ *
100
+ * Currently unused and undocumented — no caller sets it. Removing it spans
101
+ * core/bridge/sdk/app, so it is left in place as its own cleanup.
102
+ */
103
+ hideDefaultHeader?: boolean;
104
+ /** Prevent cross-session history from being loaded */
105
+ privateMode?: boolean;
106
+ /** Mark chatter as a test user (not counted in analytics) */
107
+ testMode?: boolean;
108
+ /** Hide the overlay mask behind the chat drawer */
109
+ hideMask?: boolean;
110
+ /**
111
+ * Run the SDK without rendering the default launcher button, intro popup, or
112
+ * chat drawer. Intended for hosts that render their own UI and drive the
113
+ * conversation through the programmatic API.
114
+ */
115
+ headless?: boolean;
116
+ /**
117
+ * When true (default), show a self-contained fallback document in the chat
118
+ * frame if chat activation exceeds the timeout budget and no
119
+ * `ada:chat_frame_timeout` subscriber has taken over handling.
120
+ */
121
+ showFallbackOnTimeout?: boolean;
122
+ /** Sensitive metafield key/value pairs passed through secure storage transport. */
123
+ sensitiveMetaFields?: Record<string, MetaFieldValue>;
124
+ /** Event callbacks to eagerly register before the first startup event fires */
125
+ eventCallbacks?: Record<string, AdaSdkEventCallback>;
126
+ /**
127
+ * Override the rollout fraction for this session (0–1).
128
+ * For testing and QA purposes only.
129
+ */
130
+ rolloutOverride?: number;
131
+ /** Persist eligible live-chat window state across refreshes and tabs. Defaults to true. */
132
+ crossWindowPersistence?: boolean;
133
+ /**
134
+ * Color scheme for the chat widget: `"light"`, `"dark"`, or `"auto"`.
135
+ * When set to `"auto"` (default), the widget follows the user's OS preference
136
+ * via `prefers-color-scheme`. This overrides the server-configured theme.
137
+ */
138
+ theme?: "light" | "dark" | "auto";
139
+ /** Legacy callback fired when chat has finished setting up. */
140
+ adaReadyCallback?: (params: AdaReadyCallbackParams) => void;
141
+ /** Legacy callback fired when a chatter token becomes available. */
142
+ chatterTokenCallback?: (chatterToken: string) => void;
143
+ /** Legacy callback fired when the conversation ends. */
144
+ conversationEndCallback?: (event?: Record<string, unknown>) => void;
145
+ /** Legacy callback fired when the drawer opens or closes. */
146
+ toggleCallback?: (isDrawerOpen: boolean) => void;
147
+ /**
148
+ * Called once the public embed interface is ready to be used.
149
+ * Useful for early event subscriptions.
150
+ */
151
+ onAdaEmbedLoaded?: () => void;
152
+ /** Legacy Zendesk chat auth callback. */
153
+ zdChatterAuthCallback?: (callback: (token: string) => void) => void;
154
+ }
155
+ /** Parameters for resetting the session with optional new config */
156
+ export interface ResetParams {
157
+ /** Legacy Answer response id to trigger after reset. */
158
+ greeting?: string | null;
159
+ /** Response id to trigger after reset */
160
+ greetingResponseId?: string | null;
161
+ /** Language code to apply after reset */
162
+ language?: string;
163
+ /** Metafield key/value pairs to apply after reset */
164
+ metaFields?: Record<string, MetaFieldValue>;
165
+ /** Sensitive metafield key/value pairs to apply after reset */
166
+ sensitiveMetaFields?: Record<string, MetaFieldValue>;
167
+ /** Short-lived identity token to exchange before the next boot sequence. */
168
+ identityToken?: string;
169
+ /** When false, preserve conversation history on reset */
170
+ resetChatHistory?: boolean;
171
+ }
172
+ /** Current client state returned by getInfo() */
173
+ export interface WindowInfo {
174
+ /** Whether chat is currently visible to the user */
175
+ isChatOpen: boolean;
176
+ /** Whether the drawer UI is currently open (always false in parentElement mode) */
177
+ isDrawerOpen: boolean;
178
+ /** Whether an active chatter exists in the current session */
179
+ hasActiveChatter: boolean;
180
+ /** Whether the chatter has previously closed a chat */
181
+ hasClosedChat: boolean;
182
+ }
183
+ /** Conversation + live-agent handoff state returned by getConversation(). */
184
+ export interface ConversationInfo {
185
+ /** The active conversation id, or null if none has started. */
186
+ id: string | null;
187
+ handoff: {
188
+ /** Whether the conversation is currently in a live-agent handoff. */
189
+ inLiveChat: boolean;
190
+ /** Basic connected-agent identity when Messaging has it. */
191
+ agent?: PublicAgentInfo;
192
+ };
193
+ }
194
+ /**
195
+ * A single message in the transcript returned by getMessages(). The base shape
196
+ * matches legacy Embed2; Messaging may include safe type-specific data when
197
+ * that data is already visible in the rendered conversation.
198
+ */
199
+ export interface PublicMessage {
200
+ id: string;
201
+ /** The message author. */
202
+ role: "user" | "bot" | "agent";
203
+ /** The message kind (e.g. "text", "quick_replies", "picture"). */
204
+ type: string;
205
+ /** The message body text, when the message type has a text body. */
206
+ body?: string;
207
+ /** Unix-epoch seconds when the message was created. */
208
+ createdAt: number;
209
+ /** Present whenever the transport message carries agent identity (legacy parity). */
210
+ agent?: PublicAgentInfo;
211
+ data?: Record<string, unknown>;
212
+ /** "programmatic" for SDK-originated sends; absent otherwise (legacy parity). */
213
+ origin?: "programmatic";
214
+ }
215
+ /** Result returned by sendMessage() once Messaging accepts the user message. */
216
+ export interface SendMessageResult {
217
+ id: string;
218
+ }
219
+ /**
220
+ * Event keys for subscribeEvent().
221
+ * Extends string so custom keys are also accepted.
222
+ */
223
+ export type AdaSdkEventKey = "ada:ready" | "ada:campaigns:shown" | "ada:campaigns:opened" | "ada:campaigns:engaged" | "ada:campaigns:dismissed" | "ada:end_conversation" | "ada:agent:joined" | "ada:agent:left" | "ada:typing:start" | "ada:typing:stop" | "ada:connection:change" | "ada:conversation:change" | "ada:minimize_chat" | "ada:close_chat" | "ada:csat_submitted" | "ada:conversation:message" | "ada:message:sent" | "ada:message:received" | "ada:chat_frame_timeout" | "ada:chatter_token" | "ada:identity_token:error" | "ada:identity_token:expired" | "ada:analytics" | "ada:toggle" | "ada:embed_loaded" | "ada:web_notification:click" | string;
224
+ export interface AdaMessagingClientConfig extends AdaMessagingSettings {
225
+ /** Bot handle identifier */
226
+ handle: string;
227
+ }
228
+ export interface AdaMessagingStartOptions extends AdaMessagingSettings {
229
+ /** Bot handle identifier. Required unless it was already provided elsewhere. */
230
+ handle?: string;
231
+ }