@epam/ai-dial-visualizer-connector 1.3.0-dev.126 → 1.3.0-dev.130

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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
+ export { ChatVisualizerConnector, type ChatVisualizerEventType, } from './lib/ChatVisualizerConnector';
1
2
  export { VisualizerConnector } from './lib/VisualizerConnector';
2
- export type { VisualizerConnectorLoaderStyles, VisualizerConnectorOptions, VisualizerConnectorRequest, } from './models/visualizer-connector';
3
- export { VisualizerConnectorEvents, VisualizerConnectorRequests, } from './types/visualizer-connector';
3
+ export type { AppsEditorMessage, ChatVisualizerCallbacks, VisualizerAttachmentData, VisualizerGroupedAttachmentItem, VisualizerGroupedAttachmentsData, VisualizerConnectorLoaderStyles, VisualizerConnectorOptions, VisualizerConnectorRequest, } from './models/visualizer-connector';
4
+ export { AppsEditorEvents, AppsEditorMessages, VisualizerConnectorEvents, VisualizerConnectorRequests, } from './types/visualizer-connector';
4
5
  //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EACV,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,KAAK,uBAAuB,GAC7B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,YAAY,EACV,iBAAiB,EACjB,uBAAuB,EACvB,wBAAwB,EACxB,+BAA+B,EAC/B,gCAAgC,EAChC,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,GAC3B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,GAC5B,MAAM,8BAA8B,CAAC"}
package/index.js CHANGED
@@ -3,24 +3,111 @@ var e = /* @__PURE__ */ function(e) {
3
3
  return e.SendVisualizeData = "SEND_VISUALIZE_DATA", e.SendGroupedVisualizeData = "SEND_GROUPED_VISUALIZE_DATA", e.SetVisualizerOptions = "SET_VISUALIZER_OPTIONS", e;
4
4
  }({}), t = /* @__PURE__ */ function(e) {
5
5
  return e.InitReady = "INIT_READY", e.Ready = "READY", e.ReadyToInteract = "READY_TO_INTERACT", e.SendMessage = "SEND_MESSAGE", e.CreatedConversationSuccess = "CREATED_CONVERSATION_SUCCESS", e.UpdatedConversationSuccess = "UPDATED_CONVERSATION_SUCCESS", e.UpdatedApplicationSuccess = "UPDATED_APPLICATION_SUCCESS", e;
6
- }({}), n = 1e4, r = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
6
+ }({}), n = /* @__PURE__ */ function(e) {
7
+ return e.ReadyToInteract = "readyToInteract", e.ReadyToSave = "readyToSave", e.LoggedOut = "loggedOut", e.UpdatedApplicationSuccess = "updatedApplicationSuccess", e;
8
+ }({}), r = /* @__PURE__ */ function(e) {
9
+ return e.TriggerSave = "TRIGGER_SAVE", e.SaveSuccess = "SAVE_SUCCESS", e.SaveError = "SAVE_ERROR", e.ValidityState = "VALIDITY_STATE", e.DirtyState = "DIRTY_STATE", e.RequestToolsetLogin = "REQUEST_TOOLSET_LOGIN", e.ToolsetLoginResult = "TOOLSET_LOGIN_RESULT", e.RequestToolsetLogout = "REQUEST_TOOLSET_LOGOUT", e.ToolsetLogoutResult = "TOOLSET_LOGOUT_RESULT", e.RequestApplicationCredentials = "REQUEST_APPLICATION_CREDENTIALS", e;
10
+ }({}), i = "*", a = new Set(Object.values(r)), o = "/RESPONSE", s = (e) => typeof e == "object" && !!e, c = (e, t) => t.every((t) => Object.prototype.hasOwnProperty.call(e, t)), l = (e) => {
11
+ let t = e.length;
12
+ for (; t > 0 && e[t - 1] === "/";) t--;
13
+ return e.slice(0, t);
14
+ }, u = class {
15
+ dialHosts;
16
+ dialHost;
17
+ appName;
18
+ callbacks;
19
+ constructor(e, t, n) {
20
+ let r = (Array.isArray(e) ? e : [e]).map(l);
21
+ if (!r.length) throw Error("[ChatVisualizerConnector] No dial host(s) provided");
22
+ this.dialHosts = r, this.dialHost = r[0], this.appName = t, this.callbacks = typeof n == "function" ? { onData: n } : n, window.addEventListener("message", this.postMessageListener, !1);
23
+ }
24
+ send({ type: e, payload: t, dialHost: n }) {
25
+ if (!window?.parent) throw Error(`[${this.appName}] There is no parent window to send requests`);
26
+ (n ? [n] : this.dialHosts).forEach((n) => {
27
+ window.parent.postMessage({
28
+ type: `${this.appName}/${e}`,
29
+ payload: t
30
+ }, n);
31
+ });
32
+ }
33
+ sendEditorMessage(e, t) {
34
+ if (!window?.parent) throw Error(`[${this.appName}] There is no parent window to send requests`);
35
+ (t ? [t] : this.dialHosts).forEach((t) => window.parent.postMessage(e, t));
36
+ }
37
+ sendPMResponse({ type: e, requestId: t, payload: n, dialHost: r }) {
38
+ window?.parent.postMessage({
39
+ type: `${e}${o}`,
40
+ requestId: t,
41
+ payload: n
42
+ }, r);
43
+ }
44
+ postMessageListener = (t) => {
45
+ if (t.source === window || !this.isAllowedOrigin(t.origin)) return;
46
+ let { data: n } = t;
47
+ if (!s(n) || typeof n.type != "string") return;
48
+ if (a.has(n.type)) {
49
+ this.callbacks.onEditorMessage?.(n, t.origin);
50
+ return;
51
+ }
52
+ if (!n.type.startsWith(`${this.appName}/`) || n.type.endsWith(o)) return;
53
+ let r = s(n.payload) ? n.payload : null;
54
+ switch (n.type.slice(this.appName.length + 1)) {
55
+ case e.SendVisualizeData:
56
+ r && c(r, ["visualizerData"]) && this.callbacks.onData?.(r);
57
+ break;
58
+ case e.SendGroupedVisualizeData:
59
+ r && c(r, ["attachments", "layout"]) && this.callbacks.onGroupedData?.(r);
60
+ break;
61
+ default: if (n.requestId === void 0) return;
62
+ }
63
+ this.sendPMResponse({
64
+ type: n.type,
65
+ requestId: n.requestId,
66
+ dialHost: t.origin
67
+ });
68
+ };
69
+ sendReady() {
70
+ this.send({ type: t.Ready });
71
+ }
72
+ sendReadyToInteract() {
73
+ this.send({ type: t.ReadyToInteract });
74
+ }
75
+ sendReadyToSave() {
76
+ this.send({ type: n.ReadyToSave });
77
+ }
78
+ sendLoggedOut() {
79
+ this.send({ type: n.LoggedOut });
80
+ }
81
+ async sendMessage(e) {
82
+ this.send({
83
+ type: t.SendMessage,
84
+ payload: { message: e }
85
+ });
86
+ }
87
+ destroy() {
88
+ window.removeEventListener("message", this.postMessageListener);
89
+ }
90
+ isAllowedOrigin(e) {
91
+ return this.dialHosts[0] === i || this.dialHosts.includes(e);
92
+ }
93
+ }, d = 1e4, f = () => typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (e) => {
7
94
  let t = Math.random() * 16 | 0;
8
95
  return (e === "x" ? t : t & 3 | 8).toString(16);
9
- }), i = class {
96
+ }), p = class {
10
97
  type;
11
98
  payload;
12
99
  promise;
13
- requestId = r();
100
+ requestId = f();
14
101
  resolveFn;
15
102
  timeoutHandle;
16
103
  replied = !1;
17
- constructor(e, t, r, i) {
104
+ constructor(e, t, n, r) {
18
105
  this.type = e, this.payload = t;
19
- let a = r || n;
106
+ let i = n || d;
20
107
  this.promise = new Promise((t, n) => {
21
108
  this.resolveFn = t, this.timeoutHandle = setTimeout(() => {
22
- n(`[${i}] Request ${e} failed. Timeout ${a}`);
23
- }, a);
109
+ n(`[${r}] Request ${e} failed. Timeout ${i}`);
110
+ }, i);
24
111
  });
25
112
  }
26
113
  get isReplied() {
@@ -39,12 +126,12 @@ var e = /* @__PURE__ */ function(e) {
39
126
  requestId: this.requestId
40
127
  };
41
128
  }
42
- }, a = (e, t) => {
129
+ }, m = (e, t) => {
43
130
  for (let n of Object.keys(t)) {
44
131
  let r = t[n];
45
132
  r && (e.style[n] = r);
46
133
  }
47
- }, o = class {
134
+ }, h = class {
48
135
  promise;
49
136
  resolveFn;
50
137
  rejectFn;
@@ -63,7 +150,7 @@ var e = /* @__PURE__ */ function(e) {
63
150
  ready() {
64
151
  return this.promise;
65
152
  }
66
- }, s = "VisualizerConnector", c = "Chat Visualizer destroyed", l = [
153
+ }, g = "VisualizerConnector", _ = "Chat Visualizer destroyed", v = [
67
154
  "allow-same-origin",
68
155
  "allow-scripts",
69
156
  "allow-modals",
@@ -71,18 +158,18 @@ var e = /* @__PURE__ */ function(e) {
71
158
  "allow-downloads",
72
159
  "allow-popups",
73
160
  "allow-presentation"
74
- ], u = "clipboard-write *; fullscreen *; accelerometer *; gyroscope *; autoplay *; web-share *; encrypted-media *", d = class {
161
+ ], y = "clipboard-write *; fullscreen *; accelerometer *; gyroscope *; autoplay *; web-share *; encrypted-media *", b = class {
75
162
  root;
76
163
  subscriptions = [];
77
164
  iframe;
78
165
  loader;
79
166
  loaderDisplayCss = "flex";
80
- iframeInteraction = new o();
167
+ iframeInteraction = new h();
81
168
  requests = [];
82
169
  options;
83
170
  isDestroyed = !1;
84
171
  constructor(e, t) {
85
- this.options = t, this.root = this.getRoot(e), this.iframe = this.initIframe(), this.loader = this.initLoader(t.loaderStyles ?? {}, t.loaderClass, t.loaderInnerHTML), this.root.appendChild(this.loader), this.root.appendChild(this.iframe), a(this.root, { position: "relative" }), this.showLoader(), window.addEventListener("message", this.process);
172
+ this.options = t, this.root = this.getRoot(e), this.iframe = this.initIframe(), this.loader = this.initLoader(t.loaderStyles ?? {}, t.loaderClass, t.loaderInnerHTML), this.root.appendChild(this.loader), this.root.appendChild(this.iframe), m(this.root, { position: "relative" }), this.showLoader(), window.addEventListener("message", this.process);
86
173
  }
87
174
  async ready() {
88
175
  return this.iframeInteraction.ready();
@@ -91,13 +178,13 @@ var e = /* @__PURE__ */ function(e) {
91
178
  if (n) try {
92
179
  await this.iframeInteraction.ready();
93
180
  } catch (e) {
94
- if (e === c) return;
181
+ if (e === _) return;
95
182
  throw e;
96
183
  }
97
184
  let r = this.iframe.contentWindow;
98
185
  if (!this.iframe.isConnected || !r) return;
99
- let a = new i(`${this.options.visualizerName}/${e}`, t, this.options.requestTimeout, s);
100
- return this.requests.push(a), r.postMessage(a.toPostMessage(), this.options.domain), a.promise;
186
+ let i = new p(`${this.options.visualizerName}/${e}`, t, this.options.requestTimeout, g);
187
+ return this.requests.push(i), r.postMessage(i.toPostMessage(), this.options.domain), i.promise;
101
188
  }
102
189
  subscribe(e, t) {
103
190
  return this.subscriptions.push({
@@ -111,15 +198,15 @@ var e = /* @__PURE__ */ function(e) {
111
198
  this.options = e;
112
199
  }
113
200
  destroy() {
114
- this.isDestroyed || (this.isDestroyed = !0, window.removeEventListener("message", this.process), this.iframeInteraction.ready().catch(() => void 0), this.iframeInteraction.fail(c), this.iframe.remove(), this.loader.remove());
201
+ this.isDestroyed || (this.isDestroyed = !0, window.removeEventListener("message", this.process), this.iframeInteraction.ready().catch(() => void 0), this.iframeInteraction.fail(_), this.iframe.remove(), this.loader.remove());
115
202
  }
116
203
  initIframe() {
117
204
  let e = document.createElement("iframe");
118
- return e.src = this.options.domain, e.setAttribute("sandbox", l.join(" ")), e.setAttribute("allow", u), e.style.height = "100%", e.style.width = "100%", e.style.border = "none", e.loading = "lazy", e;
205
+ return e.src = this.options.domain, e.setAttribute("sandbox", v.join(" ")), e.setAttribute("allow", y), e.style.height = "100%", e.style.width = "100%", e.style.border = "none", e.loading = "lazy", e;
119
206
  }
120
207
  initLoader(e, t, n) {
121
208
  let r = document.createElement("div");
122
- return r.innerHTML = n ?? "<svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M24 39V46.5\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.4\" d=\"M9 24H1.5\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.5\" d=\"M8.0918 8.0918L13.3994 13.3994\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.6\" d=\"M24 1.5V9\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.7\" d=\"M39.9121 8.08594L37.2607 10.7373L34.6094 13.3887\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.8\" d=\"M46.5 24H39\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.9\" d=\"M34.6055 34.6055L39.9082 39.9082\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.3\" d=\"M13.3936 34.6055L8.08594 39.9131\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<animateTransform attributeName=\"transform\" attributeType=\"XML\" type=\"rotate\" from=\"0 0 0\" to=\"360 0 0\" dur=\"1s\" repeatCount=\"indefinite\" />\n</svg>\n", t && (r.className = t), e.display && (this.loaderDisplayCss = e.display), a(r, {
209
+ return r.innerHTML = n ?? "<svg width=\"48\" height=\"48\" viewBox=\"0 0 48 48\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n<path d=\"M24 39V46.5\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.4\" d=\"M9 24H1.5\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.5\" d=\"M8.0918 8.0918L13.3994 13.3994\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.6\" d=\"M24 1.5V9\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.7\" d=\"M39.9121 8.08594L37.2607 10.7373L34.6094 13.3887\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.8\" d=\"M46.5 24H39\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.9\" d=\"M34.6055 34.6055L39.9082 39.9082\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<path opacity=\"0.3\" d=\"M13.3936 34.6055L8.08594 39.9131\" stroke=\"#7F8792\" stroke-width=\"3\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n<animateTransform attributeName=\"transform\" attributeType=\"XML\" type=\"rotate\" from=\"0 0 0\" to=\"360 0 0\" dur=\"1s\" repeatCount=\"indefinite\" />\n</svg>\n", t && (r.className = t), e.display && (this.loaderDisplayCss = e.display), m(r, {
123
210
  position: "absolute",
124
211
  background: "white",
125
212
  display: this.loaderDisplayCss,
@@ -136,7 +223,7 @@ var e = /* @__PURE__ */ function(e) {
136
223
  getRoot(e) {
137
224
  if (typeof e != "string") return e;
138
225
  let t = document.querySelector(e);
139
- if (!t) throw Error(`[${s}] There is no element with selector ${e} to append iframe`);
226
+ if (!t) throw Error(`[${g}] There is no element with selector ${e} to append iframe`);
140
227
  return t;
141
228
  }
142
229
  process = (e) => {
@@ -158,11 +245,11 @@ var e = /* @__PURE__ */ function(e) {
158
245
  for (let n of this.subscriptions) n.eventType === e && n.callback(t);
159
246
  }
160
247
  showLoader() {
161
- a(this.loader, { display: this.loaderDisplayCss });
248
+ m(this.loader, { display: this.loaderDisplayCss });
162
249
  }
163
250
  hideLoader() {
164
- a(this.loader, { display: "none" });
251
+ m(this.loader, { display: "none" });
165
252
  }
166
253
  };
167
254
  //#endregion
168
- export { d as VisualizerConnector, t as VisualizerConnectorEvents, e as VisualizerConnectorRequests };
255
+ export { n as AppsEditorEvents, r as AppsEditorMessages, u as ChatVisualizerConnector, b as VisualizerConnector, t as VisualizerConnectorEvents, e as VisualizerConnectorRequests };
@@ -0,0 +1,58 @@
1
+ import { ChatVisualizerCallbacks, VisualizerAttachmentData, VisualizerConnectorRequest } from '../models/visualizer-connector';
2
+ import { AppsEditorEvents, AppsEditorMessages, VisualizerConnectorEvents } from '../types/visualizer-connector';
3
+ /** Event types `ChatVisualizerConnector.send()` posts, each prefixed `${appName}/`. */
4
+ export type ChatVisualizerEventType = VisualizerConnectorEvents | AppsEditorEvents;
5
+ /**
6
+ * The iframe half of the visualizer protocol: runs inside a visualizer or application-editor iframe
7
+ * and exchanges namespaced messages with DIAL Chat.
8
+ */
9
+ export declare class ChatVisualizerConnector {
10
+ /** Allowed and target hosts: outgoing messages go to each; incoming ones must come from one. */
11
+ protected dialHosts: string[];
12
+ /** The first of `dialHosts`, kept for callers written against npm `0.49.0`. */
13
+ protected dialHost: string;
14
+ protected appName: string;
15
+ protected callbacks: ChatVisualizerCallbacks;
16
+ /**
17
+ * Starts listening for host messages. It announces nothing: call `sendReady()` and
18
+ * `sendReadyToInteract()` once the iframe can take them.
19
+ *
20
+ * @param dialHost DIAL Chat origin(s); `'*'` as the first entry accepts any origin.
21
+ * @param appName Protocol namespace; must equal the host's visualizer `title` or editor application name.
22
+ * @param callbacks An `onData` callback, or an object with `onData` / `onGroupedData`.
23
+ */
24
+ constructor(dialHost: string | string[], appName: string, callbacks: ((data: VisualizerAttachmentData) => void) | ChatVisualizerCallbacks);
25
+ /** Posts `${appName}/${type}` to every configured host, or only to `dialHost` when given. */
26
+ send({ type, payload, dialHost, }: {
27
+ type: ChatVisualizerEventType;
28
+ payload?: unknown;
29
+ dialHost?: string;
30
+ }): void;
31
+ /**
32
+ * Posts an application-editor message as is — no `${appName}/` prefix — to every configured host,
33
+ * or only to `dialHost` when given. Fields go where the host reads them (see `AppsEditorMessages`).
34
+ */
35
+ sendEditorMessage(message: {
36
+ type: AppsEditorMessages;
37
+ } & Record<string, unknown>, dialHost?: string): void;
38
+ /** Acknowledges a host request: posts `${type}/RESPONSE` with its `requestId` back to `dialHost`. */
39
+ sendPMResponse({ type, requestId, payload, dialHost, }: VisualizerConnectorRequest & {
40
+ dialHost: string;
41
+ }): void;
42
+ /** Handles one inbound `message`; bound, so it can be added and removed as a listener. */
43
+ postMessageListener: (event: MessageEvent<VisualizerConnectorRequest>) => void;
44
+ /** Posts `${appName}/READY`: the iframe has loaded. */
45
+ sendReady(): void;
46
+ /** Posts `${appName}/READY_TO_INTERACT`: the iframe can take data. */
47
+ sendReadyToInteract(): void;
48
+ /** Posts `${appName}/readyToSave`: an application editor's model is loaded and safe to save. */
49
+ sendReadyToSave(): void;
50
+ /** Posts `${appName}/loggedOut`: an application editor's session resolved signed out. */
51
+ sendLoggedOut(): void;
52
+ /** Posts `${appName}/SEND_MESSAGE` with `{ message: content }` into the selected conversations. */
53
+ sendMessage(content: string): Promise<void>;
54
+ /** Stops listening for host messages. A second call is a no-op. */
55
+ destroy(): void;
56
+ private isAllowedOrigin;
57
+ }
58
+ //# sourceMappingURL=ChatVisualizerConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatVisualizerConnector.d.ts","sourceRoot":"","sources":["../../src/lib/ChatVisualizerConnector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,uBAAuB,EACvB,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EAE1B,MAAM,+BAA+B,CAAC;AA0BvC,uFAAuF;AACvF,MAAM,MAAM,uBAAuB,GACjC,yBAAyB,GAAG,gBAAgB,CAAC;AAE/C;;;GAGG;AACH,qBAAa,uBAAuB;IAClC,gGAAgG;IAChG,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAC9B,+EAA+E;IAC/E,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B,SAAS,CAAC,SAAS,EAAE,uBAAuB,CAAC;IAE7C;;;;;;;OAOG;gBAED,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,EAC3B,OAAO,EAAE,MAAM,EACf,SAAS,EACP,CAAC,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC,GAAG,uBAAuB;IAgBxE,6FAA6F;IAC7F,IAAI,CAAC,EACH,IAAI,EACJ,OAAO,EACP,QAAQ,GACT,EAAE;QACD,IAAI,EAAE,uBAAuB,CAAC;QAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,GAAG,IAAI;IAeR;;;OAGG;IACH,iBAAiB,CACf,OAAO,EAAE;QAAE,IAAI,EAAE,kBAAkB,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI;IAUP,qGAAqG;IACrG,cAAc,CAAC,EACb,IAAI,EACJ,SAAS,EACT,OAAO,EACP,QAAQ,GACT,EAAE,0BAA0B,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAO3D,0FAA0F;IAC1F,mBAAmB,GACjB,OAAO,YAAY,CAAC,0BAA0B,CAAC,KAC9C,IAAI,CAsDL;IAEF,uDAAuD;IACvD,SAAS,IAAI,IAAI;IAIjB,sEAAsE;IACtE,mBAAmB,IAAI,IAAI;IAI3B,gGAAgG;IAChG,eAAe,IAAI,IAAI;IAIvB,yFAAyF;IACzF,aAAa,IAAI,IAAI;IAIrB,mGAAmG;IAC7F,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOjD,mEAAmE;IACnE,OAAO,IAAI,IAAI;IAQf,OAAO,CAAC,eAAe;CAKxB"}
@@ -1,3 +1,4 @@
1
+ import { AppsEditorMessages } from '../types/visualizer-connector';
1
2
  /** CSS declarations applied inline to the built-in loader overlay. */
2
3
  export type VisualizerConnectorLoaderStyles = {
3
4
  [property in keyof CSSStyleDeclaration]?: string;
@@ -23,6 +24,45 @@ export interface VisualizerConnectorOptions {
23
24
  /** Milliseconds a `send()` waits for its `/RESPONSE`. Defaults to `10000`. Does not bound `ready()`. */
24
25
  requestTimeout?: number;
25
26
  }
27
+ /** Payload of `SEND_VISUALIZE_DATA`, as `ChatVisualizerConnector` hands it to `onData`. */
28
+ export interface VisualizerAttachmentData {
29
+ /** MIME type of the attachment being visualized. Absent when Chat 0.x's application editor sends only a layout. */
30
+ mimeType?: string;
31
+ /** Presentation layout plus the opaque per-attachment payload. */
32
+ visualizerData: Record<string, unknown>;
33
+ }
34
+ /** One attachment inside a `SEND_GROUPED_VISUALIZE_DATA` payload. */
35
+ export interface VisualizerGroupedAttachmentItem extends VisualizerAttachmentData {
36
+ /** The attachment's own MIME type; always present for a grouped item. */
37
+ mimeType: string;
38
+ /** Absolute URL of the attachment, resolved by the host. */
39
+ url: string;
40
+ }
41
+ /** Payload of `SEND_GROUPED_VISUALIZE_DATA`, as `ChatVisualizerConnector` hands it to `onGroupedData`. */
42
+ export interface VisualizerGroupedAttachmentsData {
43
+ /** One item per attachment the visualizer claims, in message order. */
44
+ attachments: VisualizerGroupedAttachmentItem[];
45
+ /** Presentation layout hints shared by every item. */
46
+ layout: Record<string, unknown>;
47
+ }
48
+ /** An unprefixed application-editor message; the fields beyond `type` depend on it (see `AppsEditorMessages`). */
49
+ export interface AppsEditorMessage {
50
+ /** The message, as posted, with no `${applicationName}/` prefix. */
51
+ type: AppsEditorMessages;
52
+ /** Nested fields, for the messages that carry them there. */
53
+ payload?: unknown;
54
+ /** Top-level fields, for the messages that carry them there. */
55
+ [field: string]: unknown;
56
+ }
57
+ /** Callbacks a `ChatVisualizerConnector` invokes with the data the host sends. */
58
+ export interface ChatVisualizerCallbacks {
59
+ /** Single-attachment data (`CUSTOM_VISUALIZERS`). */
60
+ onData?: (data: VisualizerAttachmentData) => void;
61
+ /** Grouped attachments data (`APPLICATION_VISUALIZERS`). */
62
+ onGroupedData?: (data: VisualizerGroupedAttachmentsData) => void;
63
+ /** An application-editor message from an allowed host, such as `TRIGGER_SAVE`, with the sender's origin. */
64
+ onEditorMessage?: (message: AppsEditorMessage, origin: string) => void;
65
+ }
26
66
  /** Shape of every message exchanged with the visualizer iframe. */
27
67
  export interface VisualizerConnectorRequest {
28
68
  /** `${visualizerName}/${request or event}`, with `/RESPONSE` appended on replies. */
@@ -1 +1 @@
1
- {"version":3,"file":"visualizer-connector.d.ts","sourceRoot":"","sources":["../../src/models/visualizer-connector.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,MAAM,MAAM,+BAA+B,GAAG;KAC3C,QAAQ,IAAI,MAAM,mBAAmB,CAAC,CAAC,EAAE,MAAM;CACjD,CAAC;AAEF,oDAAoD;AACpD,MAAM,WAAW,0BAA0B;IACzC,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,+BAA+B,CAAC;IAC/C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wGAAwG;IACxG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,mEAAmE;AACnE,MAAM,WAAW,0BAA0B;IACzC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
1
+ {"version":3,"file":"visualizer-connector.d.ts","sourceRoot":"","sources":["../../src/models/visualizer-connector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AAExE,sEAAsE;AACtE,MAAM,MAAM,+BAA+B,GAAG;KAC3C,QAAQ,IAAI,MAAM,mBAAmB,CAAC,CAAC,EAAE,MAAM;CACjD,CAAC;AAEF,oDAAoD;AACpD,MAAM,WAAW,0BAA0B;IACzC,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,0FAA0F;IAC1F,cAAc,EAAE,MAAM,CAAC;IACvB,6DAA6D;IAC7D,YAAY,CAAC,EAAE,+BAA+B,CAAC;IAC/C,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wGAAwG;IACxG,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,2FAA2F;AAC3F,MAAM,WAAW,wBAAwB;IACvC,mHAAmH;IACnH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kEAAkE;IAClE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC;AAED,qEAAqE;AACrE,MAAM,WAAW,+BAAgC,SAAQ,wBAAwB;IAC/E,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,GAAG,EAAE,MAAM,CAAC;CACb;AAED,0GAA0G;AAC1G,MAAM,WAAW,gCAAgC;IAC/C,uEAAuE;IACvE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAC/C,sDAAsD;IACtD,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACjC;AAED,kHAAkH;AAClH,MAAM,WAAW,iBAAiB;IAChC,oEAAoE;IACpE,IAAI,EAAE,kBAAkB,CAAC;IACzB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,qDAAqD;IACrD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,wBAAwB,KAAK,IAAI,CAAC;IAClD,4DAA4D;IAC5D,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE,gCAAgC,KAAK,IAAI,CAAC;IACjE,4GAA4G;IAC5G,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACxE;AAED,mEAAmE;AACnE,MAAM,WAAW,0BAA0B;IACzC,qFAAqF;IACrF,IAAI,EAAE,MAAM,CAAC;IACb,yEAAyE;IACzE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wCAAwC;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@epam/ai-dial-visualizer-connector",
3
- "description": "Host-side postMessage connector that mounts a custom visualizer iframe and delivers its data",
4
- "version": "1.3.0-dev.126",
3
+ "description": "Host-side and iframe-side postMessage connectors for DIAL Chat custom visualizers and application editors",
4
+ "version": "1.3.0-dev.130",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./index.js",
@@ -17,4 +17,45 @@ export declare enum VisualizerConnectorEvents {
17
17
  UpdatedConversationSuccess = "UPDATED_CONVERSATION_SUCCESS",
18
18
  UpdatedApplicationSuccess = "UPDATED_APPLICATION_SUCCESS"
19
19
  }
20
+ /**
21
+ * Messages an application-editor iframe posts to DIAL Chat's application editor, as
22
+ * `${applicationName}/${value}`. The camelCase wire values are the ones the editor host matches on;
23
+ * they are not the visualizer events above.
24
+ */
25
+ export declare enum AppsEditorEvents {
26
+ /** The editor's UI has rendered; the host drops its loading overlay. */
27
+ ReadyToInteract = "readyToInteract",
28
+ /** The editor's own model is loaded and valid, so a `TRIGGER_SAVE` saves correctly. May repeat. */
29
+ ReadyToSave = "readyToSave",
30
+ /** The editor's session resolved signed out, so `ReadyToSave` will not arrive. */
31
+ LoggedOut = "loggedOut",
32
+ /** The editor saved the application; the host refreshes its own copy. */
33
+ UpdatedApplicationSuccess = "updatedApplicationSuccess"
34
+ }
35
+ /**
36
+ * The application editor's save and auth messages, posted WITHOUT the `${applicationName}/` prefix.
37
+ * Field placement follows what DIAL Chat's application editor reads (top level unless noted).
38
+ */
39
+ export declare enum AppsEditorMessages {
40
+ /** Host → editor: save now. Carries the General step as `general` when the host owns it. */
41
+ TriggerSave = "TRIGGER_SAVE",
42
+ /** Editor → host: the save landed; `hasChanges: boolean`. */
43
+ SaveSuccess = "SAVE_SUCCESS",
44
+ /** Editor → host: the save failed or was refused; `error: string`. */
45
+ SaveError = "SAVE_ERROR",
46
+ /** Editor → host: the form's validity; `payload.isValid: boolean`. */
47
+ ValidityState = "VALIDITY_STATE",
48
+ /** Editor → host: unsaved edits; `payload.isDirty: boolean` (top-level `isDirty` also read). */
49
+ DirtyState = "DIRTY_STATE",
50
+ /** Editor → host: start a toolset OAuth login; `toolsetId: string`. */
51
+ RequestToolsetLogin = "REQUEST_TOOLSET_LOGIN",
52
+ /** Host → editor: outcome of `RequestToolsetLogin`. */
53
+ ToolsetLoginResult = "TOOLSET_LOGIN_RESULT",
54
+ /** Editor → host: log a toolset out; `toolsetId: string`. */
55
+ RequestToolsetLogout = "REQUEST_TOOLSET_LOGOUT",
56
+ /** Host → editor: outcome of `RequestToolsetLogout`. */
57
+ ToolsetLogoutResult = "TOOLSET_LOGOUT_RESULT",
58
+ /** Editor → host: open the host's credential forms; `appId: string`. No credential crosses the frame. */
59
+ RequestApplicationCredentials = "REQUEST_APPLICATION_CREDENTIALS"
60
+ }
20
61
  //# sourceMappingURL=visualizer-connector.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"visualizer-connector.d.ts","sourceRoot":"","sources":["../../src/types/visualizer-connector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,2BAA2B;IACrC,iBAAiB,wBAAwB;IACzC,wBAAwB,gCAAgC;IACxD,oBAAoB,2BAA2B;CAChD;AAED,qGAAqG;AACrG,oBAAY,yBAAyB;IACnC,SAAS,eAAe;IACxB,KAAK,UAAU;IACf,eAAe,sBAAsB;IACrC,WAAW,iBAAiB;IAC5B,0BAA0B,iCAAiC;IAC3D,0BAA0B,iCAAiC;IAC3D,yBAAyB,gCAAgC;CAC1D"}
1
+ {"version":3,"file":"visualizer-connector.d.ts","sourceRoot":"","sources":["../../src/types/visualizer-connector.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,2BAA2B;IACrC,iBAAiB,wBAAwB;IACzC,wBAAwB,gCAAgC;IACxD,oBAAoB,2BAA2B;CAChD;AAED,qGAAqG;AACrG,oBAAY,yBAAyB;IACnC,SAAS,eAAe;IACxB,KAAK,UAAU;IACf,eAAe,sBAAsB;IACrC,WAAW,iBAAiB;IAC5B,0BAA0B,iCAAiC;IAC3D,0BAA0B,iCAAiC;IAC3D,yBAAyB,gCAAgC;CAC1D;AAED;;;;GAIG;AACH,oBAAY,gBAAgB;IAC1B,wEAAwE;IACxE,eAAe,oBAAoB;IACnC,mGAAmG;IACnG,WAAW,gBAAgB;IAC3B,kFAAkF;IAClF,SAAS,cAAc;IACvB,yEAAyE;IACzE,yBAAyB,8BAA8B;CACxD;AAED;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,4FAA4F;IAC5F,WAAW,iBAAiB;IAC5B,6DAA6D;IAC7D,WAAW,iBAAiB;IAC5B,sEAAsE;IACtE,SAAS,eAAe;IACxB,sEAAsE;IACtE,aAAa,mBAAmB;IAChC,gGAAgG;IAChG,UAAU,gBAAgB;IAC1B,uEAAuE;IACvE,mBAAmB,0BAA0B;IAC7C,uDAAuD;IACvD,kBAAkB,yBAAyB;IAC3C,6DAA6D;IAC7D,oBAAoB,2BAA2B;IAC/C,wDAAwD;IACxD,mBAAmB,0BAA0B;IAC7C,yGAAyG;IACzG,6BAA6B,oCAAoC;CAClE"}