@concepttocloud/saiku-embed 3.19.0 → 3.20.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 CHANGED
@@ -84,6 +84,57 @@ scope. Requires an AI-kind token (see "Minting an AI token" below).
84
84
  ></saiku-embed>
85
85
  ```
86
86
 
87
+ ### A single KPI tile (v3.20, `render="kpi"`)
88
+
89
+ The most common embed shape — one governed figure rendered large. Derives its
90
+ value from the same records response as `render="table"`, so it needs no server
91
+ change. Point it at a saved query whose last measure is the headline number;
92
+ when the query carries a prior measure column, a delta chip is shown.
93
+
94
+ ```html
95
+ <saiku-embed
96
+ server="..."
97
+ token="..."
98
+ path="homes/admin/Examples/NetRevenue.saiku"
99
+ render="kpi"
100
+ height="160px"
101
+ ></saiku-embed>
102
+ ```
103
+
104
+ ### A saved query, sliced at embed time (v3.20, `filter`)
105
+
106
+ Pass slicer overrides as a JSON array. They ride the same validated slicer path
107
+ the dashboard filter tiles use — the saved query's cube binding and axes are
108
+ untouched, so a host can parameterise an embed without re-authoring the query.
109
+
110
+ ```html
111
+ <saiku-embed
112
+ server="..."
113
+ token="..."
114
+ path="homes/admin/Examples/Sales.saiku"
115
+ filter='[{"dimension":"Time","level":"Year","members":["[Time].[2024]"]}]'
116
+ ></saiku-embed>
117
+ ```
118
+
119
+ ### A persona-scoped AI ask (v3.20, `space`)
120
+
121
+ Add a `space` to a `kind="ai"` embed to scope the assistant to an admin-authored
122
+ [Agent Space](../../../docs/AGENT-SPACES-SPEC.md) persona. The persona's system
123
+ prompt, skill filter, and cube allowlist apply server-side. The cube stays
124
+ pinned by the token, so a space can only **narrow** what the guest reaches — if
125
+ the space's allowlist excludes the pinned cube, the ask fails closed.
126
+
127
+ ```html
128
+ <saiku-embed
129
+ server="..."
130
+ token="..."
131
+ kind="ai"
132
+ path="foodmart/FoodMart/FoodMart/Sales"
133
+ space="foodmart-sales-analyst"
134
+ height="240px"
135
+ ></saiku-embed>
136
+ ```
137
+
87
138
  ### A saved dashboard
88
139
 
89
140
  ```html
@@ -117,14 +168,39 @@ If the resource is marked publicly embeddable on the server
117
168
  | `path` | _(required)_| `kind=query`: saved query path (`.saiku`) — `kind=dashboard`: dashboard path (`.saikudash`) — `kind=ai`: cube ref `connection/catalog/schema/cubeName` |
118
169
  | `kind` | `query` | `query`, `dashboard`, or `ai` |
119
170
  | `token` | _(none)_ | Embed token from `POST /saiku/api/embed/tokens`. Omit for public reads |
120
- | `render` | `table` | For `kind=query`: `table`, `matrix`, or `chart` |
171
+ | `render` | `table` | For `kind=query`: `table`, `matrix`, `chart`, or `kpi` (v3.20) |
121
172
  | `mode` | `bar` | For `render=chart`: `bar`, `line`, or `pie` |
122
173
  | `height` | `400px` | CSS height of the rendered surface |
174
+ | `space` | _(none)_ | For `kind=ai`: Agent Space persona id — scopes the ask server-side (v3.20) |
175
+ | `filter` | _(none)_ | For `kind=query`: JSON array of slicer overrides applied at embed time (v3.20) |
176
+ | `theme` | _(light)_ | `light`, `dark`, or `auto` (follow `prefers-color-scheme`) (v3.20) |
123
177
 
124
178
  The component re-renders whenever an attribute changes, so frameworks
125
179
  binding state to attrs (React's JSX, Vue's `:server="..."`, etc.) just
126
180
  work.
127
181
 
182
+ ## Events (v3.20)
183
+
184
+ The element emits namespaced `CustomEvent`s so the host page can react to what
185
+ happens inside the embed. All bubble and are `composed`, so a listener on the
186
+ `<saiku-embed>` element receives them:
187
+
188
+ | Event | `detail` | Fires when |
189
+ |-------------------|-----------------------------------|-----------------------------------------|
190
+ | `saiku:load` | `{ kind, rows }` | a query / matrix / kpi surface loads |
191
+ | `saiku:error` | `{ message }` | a query load fails (friendly message) |
192
+ | `saiku:select` | `{ row }` | a table row is clicked (`render=table`) |
193
+ | `saiku:ai-query` | `{ question, degraded }` | an AI ask resolves (`kind=ai`) |
194
+
195
+ ```js
196
+ const el = document.querySelector("saiku-embed");
197
+ el.addEventListener("saiku:load", (e) => console.log("loaded", e.detail.rows, "rows"));
198
+ el.addEventListener("saiku:select", (e) => showDetail(e.detail.row));
199
+ ```
200
+
201
+ In React (via `@concepttocloud/saiku-embed-react`) the same events are exposed
202
+ as `onLoad` / `onError` / `onSelect` / `onAiQuery` callback props.
203
+
128
204
  ## Server-side: minting a token
129
205
 
130
206
  Authenticated as a user who has GRANT on the saved query / dashboard:
@@ -200,8 +276,14 @@ curl -X DELETE 'https://YOUR-SAIKU/rest/saiku/api/embed/public?kind=query&path=s
200
276
 
201
277
  The embed lives inside an
202
278
  [open shadow root](https://developer.mozilla.org/docs/Web/API/ShadowRoot),
203
- so host page CSS can't leak in and vice versa. To recolour the embed,
204
- set CSS variables on the host page:
279
+ so host page CSS can't leak in and vice versa.
280
+
281
+ For a quick dark surface, set `theme="dark"` (or `theme="auto"` to follow the
282
+ viewer's `prefers-color-scheme`) — it swaps the whole palette without the host
283
+ having to set each variable (v3.20). Leaving `theme` unset keeps the original
284
+ light palette, so existing embeds are unchanged.
285
+
286
+ To fine-tune individual colours, set CSS variables on the host page:
205
287
 
206
288
  ```css
207
289
  saiku-embed {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@concepttocloud/saiku-embed",
3
- "version": "3.19.0",
3
+ "version": "3.20.0",
4
4
  "description": "<saiku-embed> Web Component — drop a saved Saiku query or dashboard into any page.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",