@luzmo/embed 6.13.5 → 6.13.6

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/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  All notable changes to this project are documented in this file.
4
4
 
5
+ ## [6.13.6] - 2026-07-03
6
+
7
+ ### Added
8
+ - `getDashboardContext()` on `<luzmo-embed-dashboard>`, returning the live dashboard context as the unified `dashboard` aiprompt input (`{ type, value }`, where `value` carries the current screen mode as `value.currentScreenMode`) in both iframe and web-component embed modes.
9
+ - `getVizItemContext()` on `<luzmo-embed-viz-item>`, returning a flex chart's live context (id, type, slots, options, filters and datasetIds).
10
+ - `contextChanged` event on `<luzmo-embed-dashboard>` and `<luzmo-embed-viz-item>`, emitted on any change and carrying the full context.
11
+ - Context-aware IQ chat: `dashboardId`, `contextIds` and `availableDatasets` properties on `<luzmo-iq-embed-chat>` to auto-connect the chat to an embedded dashboard or flex charts on the same page, plus a `connectionStatusChanged` event reporting `standalone` / `connecting` / `connected` / `not-found`.
12
+
5
13
  ## [6.13.5] - 2026-06-09
6
14
 
7
15
  ### Fixed
package/README.md CHANGED
@@ -82,13 +82,14 @@ Below a list of available properties on the viz item web component
82
82
 
83
83
  ### Events luzmo-embed-viz-item
84
84
 
85
- | Name | Description |
86
- |----------------|----------------------------------------|
87
- | changedFilters | Emitted when filters are changed |
88
- | customEvent | Emitted when a custom event is fired |
89
- | exported | Emitted when export completes or fails |
90
- | rendered | Emitted when the item is rendered |
91
- | load | Emitted when viz item is loaded |
85
+ | Name | Description |
86
+ |----------------|-------------------------------------------------------------|
87
+ | changedFilters | Emitted when filters are changed |
88
+ | contextChanged | Emitted on any change, carries the full viz-item context |
89
+ | customEvent | Emitted when a custom event is fired |
90
+ | exported | Emitted when export completes or fails |
91
+ | rendered | Emitted when the item is rendered |
92
+ | load | Emitted when viz item is loaded |
92
93
 
93
94
  <br/>
94
95
 
@@ -101,6 +102,10 @@ getData(): ItemData;
101
102
  // Return an array of active filters on the viz item.
102
103
  getFilters(): FilterGroup[];
103
104
 
105
+ // Return the live context of the viz item: id (contextId/DOM id), type, slots, options, filters and datasetIds.
106
+ // Used to feed a flex chart's context into an IQ chat or an /aiprompt call.
107
+ getVizItemContext(): VizItemContext;
108
+
104
109
  // Refresh the data of the viz item.
105
110
  refreshData(): void;
106
111
 
@@ -196,13 +201,14 @@ Below a list of available properties on the dashboard web component
196
201
 
197
202
  ### Events luzmo-embed-dashboard
198
203
 
199
- | Name | Description | Event Arguments |
200
- | -------------- | -------------------------------------- | --------------------- |
201
- | changedFilters | Emitted when filters are changed | `ChangedFiltersEvent` |
202
- | customEvent | Emitted when a custom event is fired | `CustomEvent` |
203
- | exported | Emitted when export completes or fails | `ExportedEvent` |
204
- | itemsRendered | Emitted when all items are rendered | `ItemsRenderedEvent` |
205
- | load | Emitted when dashboard is loaded | `LoadEvent` |
204
+ | Name | Description | Event Arguments |
205
+ | -------------- | ------------------------------------------------------------ | ---------------------- |
206
+ | changedFilters | Emitted when filters are changed | `ChangedFiltersEvent` |
207
+ | contextChanged | Emitted on any dashboard change, carries the full context | `ContextChangedEvent` |
208
+ | customEvent | Emitted when a custom event is fired | `CustomEvent` |
209
+ | exported | Emitted when export completes or fails | `ExportedEvent` |
210
+ | itemsRendered | Emitted when all items are rendered | `ItemsRenderedEvent` |
211
+ | load | Emitted when dashboard is loaded | `LoadEvent` |
206
212
 
207
213
  <br/>
208
214
 
@@ -218,6 +224,13 @@ getData(itemId: string): Promise<ItemData>;
218
224
  // Returns an array of active filters.
219
225
  getFilters(): Promise<FilterGroup[]>;
220
226
 
227
+ // Returns the live dashboard context (current views, runtime filters and titles) as the
228
+ // unified `dashboard` aiprompt input (`{ type: 'dashboard', value }`, where `value` carries
229
+ // the current screen mode as `value.currentScreenMode`).
230
+ // Works in both iframe and web-component embed modes. Feed it into an IQ chat (via its
231
+ // `dashboardContext` input) or an /aiprompt call.
232
+ getDashboardContext(): Promise<DashboardContext | undefined>;
233
+
221
234
  // Changes the authorization of all or one dashboard. To fetch data based on new authorization parameters, reloadDashboard() or refreshData() needs to be called.
222
235
  setAuthorization(key: string, token: string): Promise<void>;
223
236
 
@@ -354,6 +367,33 @@ All available properties for the IQ chat component can be seen in the table belo
354
367
  | `apiHost` | string | Tenancy of Luzmo API to connect to (Default: 'https://api.luzmo.com/' , for US set apiHost to 'https://api.us.luzmo.com/') |
355
368
  | `options` | IQChatOptions | Specifies the customization options of the IQ chat component that affect its appearance and functionality. |
356
369
  | `initialSuggestionsDatasetId` | string | ID of a dataset that assists the AI service in generating automated, initial prompts based on the provided data. |
370
+ | `availableDatasets` | string[] | Restrict the analyst to these dataset ids. Accepts a JSON array string attribute. |
371
+ | `dashboardContext` | DashboardContext | A `dashboard-context` to answer over (manual API path). Accepts a JSON object string attribute. |
372
+ | `dashboardId` | string | Connect the chat to a dashboard embedded on the same page; it auto-reads live context and refreshes on change. |
373
+ | `contextIds` | string[] | Connect the chat to one or more flex charts by their `context-id`; a synthetic dashboard-context is assembled. JSON array. |
374
+
375
+ <br/>
376
+
377
+ #### Context-aware chat (dashboards & flex charts)
378
+
379
+ The IQ chat can answer using the **live context** of an embedded dashboard or one/more standalone flex charts on the same page. Connection is always explicit:
380
+
381
+ - Set neither `dashboardId` nor `contextIds` → standalone chat (no context).
382
+ - Set `dashboardId` → the chat finds the `luzmo-embed-dashboard` with that id, reads its context via `getDashboardContext()` and refreshes on each `contextChanged`.
383
+ - Set `contextIds` → the chat finds each `luzmo-embed-viz-item` whose `context-id` matches, reads each via `getVizItemContext()` and assembles a synthetic dashboard-context.
384
+ - If an id is not found on the page, the chat does not connect and surfaces a clear message; a `connectionStatusChanged` event reports the status (`standalone` / `connecting` / `connected` / `not-found`).
385
+
386
+ For a customer's own UI you can also skip auto-connect and forward context yourself: listen to the dashboard's `contextChanged` (or call `getDashboardContext()`), then pass the payload into the chat's `dashboardContext` input or into an `/aiprompt` call.
387
+
388
+ ```html
389
+ <!-- Auto-connect to a dashboard on the same page -->
390
+ <luzmo-embed-dashboard dashboardId="<dashboard-id>" authKey="..." authToken="..."></luzmo-embed-dashboard>
391
+ <luzmo-iq-embed-chat dashboardId="<dashboard-id>" authKey="..." authToken="..."></luzmo-iq-embed-chat>
392
+
393
+ <!-- Auto-connect to one or more flex charts -->
394
+ <luzmo-embed-viz-item context-id="sales-by-product" authKey="..." authToken="..."></luzmo-embed-viz-item>
395
+ <luzmo-iq-embed-chat contextIds='["sales-by-product"]' authKey="..." authToken="..."></luzmo-iq-embed-chat>
396
+ ```
357
397
 
358
398
  <br/>
359
399
 
package/index.cjs CHANGED
@@ -65,7 +65,7 @@ var import_decorators = require("lit/decorators.js");
65
65
  var import_style_map = require("lit/directives/style-map.js");
66
66
 
67
67
  // libs/embed-libs/embed/package.json
68
- var version = "6.13.5";
68
+ var version = "6.13.6";
69
69
 
70
70
  // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
71
71
  var SharedLib = __toESM(require("@luzmo/shared-embed"));
@@ -131,6 +131,14 @@ var _setEventHandler = () => {
131
131
  );
132
132
  break;
133
133
  }
134
+ case "dashboardContext": {
135
+ SharedLib.resolvePromise(
136
+ dashboardComponent,
137
+ event.data.requestId,
138
+ event.data.context
139
+ );
140
+ break;
141
+ }
134
142
  case "getAccessibleDashboards": {
135
143
  SharedLib.resolvePromise(
136
144
  dashboardComponent,
@@ -170,6 +178,12 @@ var _setEventHandler = () => {
170
178
  );
171
179
  break;
172
180
  }
181
+ case "contextChanged": {
182
+ dashboardComponent.dispatchEvent(
183
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
184
+ );
185
+ break;
186
+ }
173
187
  case "customEvent": {
174
188
  dashboardComponent.dispatchEvent(
175
189
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -565,6 +579,7 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
565
579
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
566
580
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
567
581
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
582
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
568
583
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
569
584
  if (container) {
570
585
  container.append(el);
@@ -920,6 +935,15 @@ var LuzmoDashboard = class extends import_lit2.LitElement {
920
935
  }
921
936
  return Promise.reject();
922
937
  }
938
+ getDashboardContext() {
939
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
940
+ return this.dashboardReference.getDashboardContext();
941
+ }
942
+ if (!this.isWebComponentViewMode()) {
943
+ return SharedLib2.getDashboardContext(this, this.iframe);
944
+ }
945
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
946
+ }
923
947
  setSelectedData(itemId, filters) {
924
948
  if (this.isWebComponentViewMode() && this.dashboardReference) {
925
949
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -1197,6 +1221,19 @@ var import_lit3 = require("lit");
1197
1221
  var import_decorators2 = require("lit/decorators.js");
1198
1222
  var dashboardContentsVersion = import_dashboard_contents_types.CONTENTS_VERSION;
1199
1223
  var vizItemRemote = "VizItemApp";
1224
+ function collectVizItemDatasetIds(slots) {
1225
+ const ids = /* @__PURE__ */ new Set();
1226
+ for (const slot of slots ?? []) {
1227
+ for (const content of slot?.content ?? []) {
1228
+ const column = content;
1229
+ const datasetId = column.datasetId ?? column.set;
1230
+ if (datasetId) {
1231
+ ids.add(datasetId);
1232
+ }
1233
+ }
1234
+ }
1235
+ return [...ids];
1236
+ }
1200
1237
  var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1201
1238
  constructor() {
1202
1239
  super(...arguments);
@@ -1242,6 +1279,22 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1242
1279
  getFilters() {
1243
1280
  return this.chartElement.getFilters();
1244
1281
  }
1282
+ /**
1283
+ * Snapshot of this flex chart's live context: its definition (type, slots,
1284
+ * options), current filters and the datasets it reads. Used by context-aware
1285
+ * embeds such as the Luzmo IQ chat component.
1286
+ */
1287
+ getVizItemContext() {
1288
+ const slots = this.slots ?? [];
1289
+ return {
1290
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
1291
+ type: this.type,
1292
+ slots,
1293
+ options: this.options,
1294
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
1295
+ datasetIds: collectVizItemDatasetIds(slots)
1296
+ };
1297
+ }
1245
1298
  export(type = "png") {
1246
1299
  return this.chartElement.export(type);
1247
1300
  }
@@ -1294,7 +1347,12 @@ var LuzmoBaseVizItem = class extends import_lit3.LitElement {
1294
1347
  }
1295
1348
  this.dispatchEvent(new CustomEvent("rendered", payload));
1296
1349
  });
1297
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1350
+ this.chartElement.addEventListener("changedFilters", (payload) => {
1351
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
1352
+ this.dispatchEvent(new CustomEvent("contextChanged", {
1353
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
1354
+ }));
1355
+ });
1298
1356
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1299
1357
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1300
1358
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -1417,7 +1475,9 @@ var inputMap = {
1417
1475
  libVersion: "lib-version",
1418
1476
  aydHost: "ayd-host",
1419
1477
  availableDatasets: "available-datasets",
1420
- dashboardContext: "dashboard-context"
1478
+ dashboardContext: "dashboard-context",
1479
+ dashboardId: "dashboard-id",
1480
+ contextIds: "context-ids"
1421
1481
  };
1422
1482
  var embedChatTag = "luzmo-iq-embed-chat";
1423
1483
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -1456,6 +1516,10 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
1456
1516
  if (!this.chartElement) {
1457
1517
  this.chartElement = document.createElement(chatComponentTag);
1458
1518
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1519
+ this.chartElement.addEventListener(
1520
+ "connectionStatusChanged",
1521
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
1522
+ );
1459
1523
  this.updateVizItemProperties();
1460
1524
  this.renderRoot.append(this.chartElement);
1461
1525
  }
@@ -1478,7 +1542,12 @@ var LuzmoIQEmbedChatComponent = class extends import_lit4.LitElement {
1478
1542
  if (this.chartElement) {
1479
1543
  for (const [propertyName] of changedProperties.entries()) {
1480
1544
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1481
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1545
+ const propertyValue = this[propertyName];
1546
+ if (propertyValue == null) {
1547
+ this.chartElement.removeAttribute(mappedAttributeName);
1548
+ continue;
1549
+ }
1550
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
1482
1551
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1483
1552
  }
1484
1553
  } else {
@@ -1548,6 +1617,12 @@ __decorateClass([
1548
1617
  __decorateClass([
1549
1618
  (0, import_decorators3.property)({ type: Object })
1550
1619
  ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
1620
+ __decorateClass([
1621
+ (0, import_decorators3.property)()
1622
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
1623
+ __decorateClass([
1624
+ (0, import_decorators3.property)({ type: Array })
1625
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
1551
1626
  if (!customElements.get(embedChatTag)) {
1552
1627
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
1553
1628
  }
package/index.js CHANGED
@@ -23,7 +23,7 @@ import { property, query, state } from "lit/decorators.js";
23
23
  import { styleMap } from "lit/directives/style-map.js";
24
24
 
25
25
  // libs/embed-libs/embed/package.json
26
- var version = "6.13.5";
26
+ var version = "6.13.6";
27
27
 
28
28
  // libs/embed-libs/embed/src/lib/helper/event-bus-handler.ts
29
29
  import * as SharedLib from "@luzmo/shared-embed";
@@ -89,6 +89,14 @@ var _setEventHandler = () => {
89
89
  );
90
90
  break;
91
91
  }
92
+ case "dashboardContext": {
93
+ SharedLib.resolvePromise(
94
+ dashboardComponent,
95
+ event.data.requestId,
96
+ event.data.context
97
+ );
98
+ break;
99
+ }
92
100
  case "getAccessibleDashboards": {
93
101
  SharedLib.resolvePromise(
94
102
  dashboardComponent,
@@ -128,6 +136,12 @@ var _setEventHandler = () => {
128
136
  );
129
137
  break;
130
138
  }
139
+ case "contextChanged": {
140
+ dashboardComponent.dispatchEvent(
141
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
142
+ );
143
+ break;
144
+ }
131
145
  case "customEvent": {
132
146
  dashboardComponent.dispatchEvent(
133
147
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -523,6 +537,7 @@ var LuzmoDashboard = class extends LitElement {
523
537
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
524
538
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
525
539
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
540
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
526
541
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
527
542
  if (container) {
528
543
  container.append(el);
@@ -878,6 +893,15 @@ var LuzmoDashboard = class extends LitElement {
878
893
  }
879
894
  return Promise.reject();
880
895
  }
896
+ getDashboardContext() {
897
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
898
+ return this.dashboardReference.getDashboardContext();
899
+ }
900
+ if (!this.isWebComponentViewMode()) {
901
+ return SharedLib2.getDashboardContext(this, this.iframe);
902
+ }
903
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
904
+ }
881
905
  setSelectedData(itemId, filters) {
882
906
  if (this.isWebComponentViewMode() && this.dashboardReference) {
883
907
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -1155,6 +1179,19 @@ import { css as css2, html as html2, LitElement as LitElement2 } from "lit";
1155
1179
  import { property as property2 } from "lit/decorators.js";
1156
1180
  var dashboardContentsVersion = CONTENTS_VERSION;
1157
1181
  var vizItemRemote = "VizItemApp";
1182
+ function collectVizItemDatasetIds(slots) {
1183
+ const ids = /* @__PURE__ */ new Set();
1184
+ for (const slot of slots ?? []) {
1185
+ for (const content of slot?.content ?? []) {
1186
+ const column = content;
1187
+ const datasetId = column.datasetId ?? column.set;
1188
+ if (datasetId) {
1189
+ ids.add(datasetId);
1190
+ }
1191
+ }
1192
+ }
1193
+ return [...ids];
1194
+ }
1158
1195
  var LuzmoBaseVizItem = class extends LitElement2 {
1159
1196
  constructor() {
1160
1197
  super(...arguments);
@@ -1200,6 +1237,22 @@ var LuzmoBaseVizItem = class extends LitElement2 {
1200
1237
  getFilters() {
1201
1238
  return this.chartElement.getFilters();
1202
1239
  }
1240
+ /**
1241
+ * Snapshot of this flex chart's live context: its definition (type, slots,
1242
+ * options), current filters and the datasets it reads. Used by context-aware
1243
+ * embeds such as the Luzmo IQ chat component.
1244
+ */
1245
+ getVizItemContext() {
1246
+ const slots = this.slots ?? [];
1247
+ return {
1248
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
1249
+ type: this.type,
1250
+ slots,
1251
+ options: this.options,
1252
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
1253
+ datasetIds: collectVizItemDatasetIds(slots)
1254
+ };
1255
+ }
1203
1256
  export(type = "png") {
1204
1257
  return this.chartElement.export(type);
1205
1258
  }
@@ -1252,7 +1305,12 @@ var LuzmoBaseVizItem = class extends LitElement2 {
1252
1305
  }
1253
1306
  this.dispatchEvent(new CustomEvent("rendered", payload));
1254
1307
  });
1255
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
1308
+ this.chartElement.addEventListener("changedFilters", (payload) => {
1309
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
1310
+ this.dispatchEvent(new CustomEvent("contextChanged", {
1311
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
1312
+ }));
1313
+ });
1256
1314
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
1257
1315
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
1258
1316
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -1375,7 +1433,9 @@ var inputMap = {
1375
1433
  libVersion: "lib-version",
1376
1434
  aydHost: "ayd-host",
1377
1435
  availableDatasets: "available-datasets",
1378
- dashboardContext: "dashboard-context"
1436
+ dashboardContext: "dashboard-context",
1437
+ dashboardId: "dashboard-id",
1438
+ contextIds: "context-ids"
1379
1439
  };
1380
1440
  var embedChatTag = "luzmo-iq-embed-chat";
1381
1441
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -1414,6 +1474,10 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1414
1474
  if (!this.chartElement) {
1415
1475
  this.chartElement = document.createElement(chatComponentTag);
1416
1476
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
1477
+ this.chartElement.addEventListener(
1478
+ "connectionStatusChanged",
1479
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
1480
+ );
1417
1481
  this.updateVizItemProperties();
1418
1482
  this.renderRoot.append(this.chartElement);
1419
1483
  }
@@ -1436,7 +1500,12 @@ var LuzmoIQEmbedChatComponent = class extends LitElement3 {
1436
1500
  if (this.chartElement) {
1437
1501
  for (const [propertyName] of changedProperties.entries()) {
1438
1502
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
1439
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
1503
+ const propertyValue = this[propertyName];
1504
+ if (propertyValue == null) {
1505
+ this.chartElement.removeAttribute(mappedAttributeName);
1506
+ continue;
1507
+ }
1508
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
1440
1509
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
1441
1510
  }
1442
1511
  } else {
@@ -1506,6 +1575,12 @@ __decorateClass([
1506
1575
  __decorateClass([
1507
1576
  property3({ type: Object })
1508
1577
  ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
1578
+ __decorateClass([
1579
+ property3()
1580
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
1581
+ __decorateClass([
1582
+ property3({ type: Array })
1583
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
1509
1584
  if (!customElements.get(embedChatTag)) {
1510
1585
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
1511
1586
  }
@@ -754,6 +754,30 @@ var getAccessibleDashboards = async (dashboardComponent) => {
754
754
  throw new Error("No authKey or authToken found in the luzmo-dashboard component.");
755
755
  };
756
756
 
757
+ // libs/embed-libs/shared-embed/src/lib/methods/get-dashboard-context.ts
758
+ var getDashboardContext = (dashboardComponent, iframe) => {
759
+ if (iframe?.contentWindow) {
760
+ const requestId = uuidv4();
761
+ iframe.contentWindow.postMessage(
762
+ { action: "getDashboardContext", _version: dashboardComponent.libVersion, requestId },
763
+ "*"
764
+ );
765
+ return new Promise((resolve, reject) => {
766
+ dashboardComponent.promises[requestId] = { resolve, reject };
767
+ setTimeout(() => {
768
+ if (dashboardComponent.promises[requestId]) {
769
+ const errorMessage = "getDashboardContext request timed out.";
770
+ dashboardComponent.promises[requestId].reject(
771
+ new Error(errorMessage)
772
+ );
773
+ delete dashboardComponent.promises[requestId];
774
+ }
775
+ }, 2e3);
776
+ });
777
+ }
778
+ return Promise.reject(new Error("Cannot retrieve contentWindow."));
779
+ };
780
+
757
781
  // libs/embed-libs/shared-embed/src/lib/methods/get-data.ts
758
782
  var getData = (dashboardComponent, iframe, itemId) => {
759
783
  if (iframe?.contentWindow) {
@@ -5743,7 +5767,7 @@ var o6 = e6(class extends i5 {
5743
5767
  });
5744
5768
 
5745
5769
  // libs/embed-libs/embed/package.json
5746
- var version = "6.13.5";
5770
+ var version = "6.13.6";
5747
5771
 
5748
5772
  // libs/embed-libs/embed/src/lib/luzmo-service.ts
5749
5773
  var LuzmoDashboardService = class {
@@ -5806,6 +5830,14 @@ var _setEventHandler = () => {
5806
5830
  );
5807
5831
  break;
5808
5832
  }
5833
+ case "dashboardContext": {
5834
+ resolvePromise(
5835
+ dashboardComponent,
5836
+ event.data.requestId,
5837
+ event.data.context
5838
+ );
5839
+ break;
5840
+ }
5809
5841
  case "getAccessibleDashboards": {
5810
5842
  resolvePromise(
5811
5843
  dashboardComponent,
@@ -5845,6 +5877,12 @@ var _setEventHandler = () => {
5845
5877
  );
5846
5878
  break;
5847
5879
  }
5880
+ case "contextChanged": {
5881
+ dashboardComponent.dispatchEvent(
5882
+ new CustomEvent("contextChanged", { detail: { data: event.data } })
5883
+ );
5884
+ break;
5885
+ }
5848
5886
  case "customEvent": {
5849
5887
  dashboardComponent.dispatchEvent(
5850
5888
  new CustomEvent("customEvent", { detail: { data: event.data } })
@@ -6239,6 +6277,7 @@ var LuzmoDashboard = class extends i4 {
6239
6277
  el.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
6240
6278
  el.addEventListener("dashboardAction", (payload) => this.dispatchEvent(new CustomEvent("dashboardAction", payload)));
6241
6279
  el.addEventListener("export", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
6280
+ el.addEventListener("contextChanged", (payload) => this.dispatchEvent(new CustomEvent("contextChanged", payload)));
6242
6281
  const container = this.renderRoot.querySelector("#dashboard-wc-container");
6243
6282
  if (container) {
6244
6283
  container.append(el);
@@ -6594,6 +6633,15 @@ var LuzmoDashboard = class extends i4 {
6594
6633
  }
6595
6634
  return Promise.reject();
6596
6635
  }
6636
+ getDashboardContext() {
6637
+ if (this.isWebComponentViewMode() && this.dashboardReference) {
6638
+ return this.dashboardReference.getDashboardContext();
6639
+ }
6640
+ if (!this.isWebComponentViewMode()) {
6641
+ return getDashboardContext(this, this.iframe);
6642
+ }
6643
+ return Promise.reject(new Error("getDashboardContext is not available: dashboard reference is not ready."));
6644
+ }
6597
6645
  setSelectedData(itemId, filters) {
6598
6646
  if (this.isWebComponentViewMode() && this.dashboardReference) {
6599
6647
  return this.dashboardReference.setSelectedData(itemId, filters);
@@ -6870,6 +6918,19 @@ var CONTENTS_VERSION = "0.1.100";
6870
6918
  // libs/embed-libs/embed/src/lib/viz-item/viz-item.base.ts
6871
6919
  var dashboardContentsVersion = CONTENTS_VERSION;
6872
6920
  var vizItemRemote = "VizItemApp";
6921
+ function collectVizItemDatasetIds(slots) {
6922
+ const ids = /* @__PURE__ */ new Set();
6923
+ for (const slot of slots ?? []) {
6924
+ for (const content of slot?.content ?? []) {
6925
+ const column = content;
6926
+ const datasetId = column.datasetId ?? column.set;
6927
+ if (datasetId) {
6928
+ ids.add(datasetId);
6929
+ }
6930
+ }
6931
+ }
6932
+ return [...ids];
6933
+ }
6873
6934
  var LuzmoBaseVizItem = class extends i4 {
6874
6935
  constructor() {
6875
6936
  super(...arguments);
@@ -6915,6 +6976,22 @@ var LuzmoBaseVizItem = class extends i4 {
6915
6976
  getFilters() {
6916
6977
  return this.chartElement.getFilters();
6917
6978
  }
6979
+ /**
6980
+ * Snapshot of this flex chart's live context: its definition (type, slots,
6981
+ * options), current filters and the datasets it reads. Used by context-aware
6982
+ * embeds such as the Luzmo IQ chat component.
6983
+ */
6984
+ getVizItemContext() {
6985
+ const slots = this.slots ?? [];
6986
+ return {
6987
+ id: this.contextId ?? this.getAttribute("context-id") ?? this.id ?? this.itemId ?? "",
6988
+ type: this.type,
6989
+ slots,
6990
+ options: this.options,
6991
+ filters: typeof this.chartElement?.getFilters === "function" ? this.getFilters() : this.filters ?? [],
6992
+ datasetIds: collectVizItemDatasetIds(slots)
6993
+ };
6994
+ }
6918
6995
  export(type = "png") {
6919
6996
  return this.chartElement.export(type);
6920
6997
  }
@@ -6967,7 +7044,12 @@ var LuzmoBaseVizItem = class extends i4 {
6967
7044
  }
6968
7045
  this.dispatchEvent(new CustomEvent("rendered", payload));
6969
7046
  });
6970
- this.chartElement.addEventListener("changedFilters", (payload) => this.dispatchEvent(new CustomEvent("changedFilters", payload)));
7047
+ this.chartElement.addEventListener("changedFilters", (payload) => {
7048
+ this.dispatchEvent(new CustomEvent("changedFilters", payload));
7049
+ this.dispatchEvent(new CustomEvent("contextChanged", {
7050
+ detail: { data: { type: "contextChanged", context: this.getVizItemContext() } }
7051
+ }));
7052
+ });
6971
7053
  this.chartElement.addEventListener("exported", (payload) => this.dispatchEvent(new CustomEvent("exported", payload)));
6972
7054
  this.chartElement.addEventListener("customEvent", (payload) => this.dispatchEvent(new CustomEvent("customEvent", payload)));
6973
7055
  this.chartElement.addEventListener("authorizationExpired", (payload) => this.dispatchEvent(new CustomEvent("authorizationExpired", payload)));
@@ -7087,7 +7169,9 @@ var inputMap = {
7087
7169
  libVersion: "lib-version",
7088
7170
  aydHost: "ayd-host",
7089
7171
  availableDatasets: "available-datasets",
7090
- dashboardContext: "dashboard-context"
7172
+ dashboardContext: "dashboard-context",
7173
+ dashboardId: "dashboard-id",
7174
+ contextIds: "context-ids"
7091
7175
  };
7092
7176
  var embedChatTag = "luzmo-iq-embed-chat";
7093
7177
  var chatComponentTag = "luzmo-iq-chat-component";
@@ -7126,6 +7210,10 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
7126
7210
  if (!this.chartElement) {
7127
7211
  this.chartElement = document.createElement(chatComponentTag);
7128
7212
  this.chartElement.addEventListener("load", (payload) => this.dispatchEvent(new CustomEvent("load", payload)));
7213
+ this.chartElement.addEventListener(
7214
+ "connectionStatusChanged",
7215
+ (event) => this.dispatchEvent(new CustomEvent("connectionStatusChanged", { detail: event.detail }))
7216
+ );
7129
7217
  this.updateVizItemProperties();
7130
7218
  this.renderRoot.append(this.chartElement);
7131
7219
  }
@@ -7148,7 +7236,12 @@ var LuzmoIQEmbedChatComponent = class extends i4 {
7148
7236
  if (this.chartElement) {
7149
7237
  for (const [propertyName] of changedProperties.entries()) {
7150
7238
  const mappedAttributeName = inputMap[propertyName] ?? propertyName;
7151
- const attributeValue = typeof this[propertyName] === "object" ? JSON.stringify(this[propertyName]) : this[propertyName]?.toString() ?? this[propertyName];
7239
+ const propertyValue = this[propertyName];
7240
+ if (propertyValue == null) {
7241
+ this.chartElement.removeAttribute(mappedAttributeName);
7242
+ continue;
7243
+ }
7244
+ const attributeValue = typeof propertyValue === "object" ? JSON.stringify(propertyValue) : propertyValue.toString();
7152
7245
  this.chartElement.setAttribute(mappedAttributeName, attributeValue);
7153
7246
  }
7154
7247
  } else {
@@ -7218,6 +7311,12 @@ __decorateClass([
7218
7311
  __decorateClass([
7219
7312
  n4({ type: Object })
7220
7313
  ], LuzmoIQEmbedChatComponent.prototype, "dashboardContext", 2);
7314
+ __decorateClass([
7315
+ n4()
7316
+ ], LuzmoIQEmbedChatComponent.prototype, "dashboardId", 2);
7317
+ __decorateClass([
7318
+ n4({ type: Array })
7319
+ ], LuzmoIQEmbedChatComponent.prototype, "contextIds", 2);
7221
7320
  if (!customElements.get(embedChatTag)) {
7222
7321
  customElements.define(embedChatTag, LuzmoIQEmbedChatComponent);
7223
7322
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@luzmo/embed",
3
- "version": "6.13.5",
3
+ "version": "6.13.6",
4
4
  "dependencies": {
5
5
  "lit": "^3.3.1",
6
- "@luzmo/shared-embed": "5.12.2"
6
+ "@luzmo/shared-embed": "5.12.3"
7
7
  },
8
8
  "keywords": [
9
9
  "es6",
@@ -89,6 +89,7 @@ export declare class LuzmoDashboard extends LitElement implements SharedLib.WebC
89
89
  getDashboards(): Promise<LuzmoDashboard[]>;
90
90
  getData(itemId: string): Promise<SharedLib.ItemData>;
91
91
  getFilters(): Promise<FilterGroup[]>;
92
+ getDashboardContext(): Promise<SharedLib.DashboardContext | undefined>;
92
93
  setSelectedData<K extends CombinedSelectedDataInput>(itemId: string, filters: K): Promise<SharedLib.SetSelectedData>;
93
94
  setAuthorization(key: string, token: string): Promise<void>;
94
95
  refreshData(itemId?: string): Promise<void>;
@@ -1,17 +1,14 @@
1
1
  import type { IQChatOptions } from '@luzmo/dashboard-contents-types';
2
+ import { type DashboardContext } from '@luzmo/shared-embed';
2
3
  import { LitElement, PropertyValues } from 'lit';
3
4
  import type { TemplateResult } from 'lit-html';
4
- export interface SerializedDashboardContext {
5
- type: 'dashboard-context';
6
- id: string;
7
- json: unknown;
8
- screen_mode?: string;
9
- meta?: {
10
- title?: string;
11
- description?: string;
12
- };
13
- runtime_filters?: unknown[];
14
- }
5
+ /**
6
+ * Dashboard context accepted by the embedded IQ chat. Alias of the shared embed
7
+ * {@link DashboardContext} so the published contract stays in lockstep with
8
+ * `getDashboardContext()` and the `contextChanged` event (including the typed
9
+ * `runtimeFilters`).
10
+ */
11
+ export type SerializedDashboardContext = DashboardContext;
15
12
  export declare class LuzmoIQEmbedChatComponent extends LitElement {
16
13
  appServer?: string;
17
14
  apiHost?: string;
@@ -26,6 +23,8 @@ export declare class LuzmoIQEmbedChatComponent extends LitElement {
26
23
  aydHost: string;
27
24
  availableDatasets?: string[];
28
25
  dashboardContext?: SerializedDashboardContext;
26
+ dashboardId?: string;
27
+ contextIds?: string[];
29
28
  chartElement: HTMLElement;
30
29
  static styles: import("lit").CSSResult;
31
30
  protected createRenderRoot(): HTMLElement | DocumentFragment;
@@ -26,6 +26,7 @@ interface LuzmoVizItemComponentInterface extends HTMLElement {
26
26
  itemId?: string;
27
27
  aiMessageAssetId?: string;
28
28
  getFilters: () => FilterGroup[];
29
+ getVizItemContext?: () => SharedLib.VizItemContext;
29
30
  export: (type?: VizItemExportType) => Promise<string | void>;
30
31
  refreshData: () => void;
31
32
  getData: () => SharedLib.ItemData;
@@ -59,6 +60,12 @@ export declare class LuzmoBaseVizItem extends LitElement implements LuzmoVizItem
59
60
  protected createRenderRoot(): HTMLElement | DocumentFragment;
60
61
  canInitializeVizItem(): boolean;
61
62
  getFilters(): FilterGroup[];
63
+ /**
64
+ * Snapshot of this flex chart's live context: its definition (type, slots,
65
+ * options), current filters and the datasets it reads. Used by context-aware
66
+ * embeds such as the Luzmo IQ chat component.
67
+ */
68
+ getVizItemContext(): SharedLib.VizItemContext;
62
69
  export(type?: VizItemExportType): Promise<string | void>;
63
70
  getData(): SharedLib.ItemData;
64
71
  refreshData(): void;