@querypanel/node-sdk 1.2.4 → 1.2.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/README.md +70 -0
- package/dist/index.cjs +78 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -201,6 +201,45 @@ if (response.chart.vegaLiteSpec) {
|
|
|
201
201
|
const charts = await qp.listCharts({ tenantId: "tenant_123" });
|
|
202
202
|
```
|
|
203
203
|
|
|
204
|
+
### Saved charts via `/charts/all`
|
|
205
|
+
|
|
206
|
+
`listAllCharts()` calls **`GET /charts/all`**. It accepts the **same options as `listCharts()`** (including **`pagination`** with `page` and `limit`, filters, and sort).
|
|
207
|
+
|
|
208
|
+
**Breaking change:** Older SDK versions returned a **plain array** of charts from `listAllCharts()`. Current versions return **`{ data, pagination }`**, the same **`PaginatedResponse`** shape as **`listCharts()`**. Update callers from `const charts = await qp.listAllCharts(...)` to **`const { data: charts, pagination } = await qp.listAllCharts(...)`** (or use **`result.data`** only).
|
|
209
|
+
|
|
210
|
+
```ts
|
|
211
|
+
const { data, pagination } = await qp.listAllCharts({
|
|
212
|
+
tenantId: "tenant_123",
|
|
213
|
+
pagination: { page: 1, limit: 50 },
|
|
214
|
+
includeData: true,
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
// Walk every page (same pattern as listCharts)
|
|
218
|
+
let page = 1;
|
|
219
|
+
const limit = 50;
|
|
220
|
+
let allCharts: typeof data = [];
|
|
221
|
+
for (;;) {
|
|
222
|
+
const res = await qp.listAllCharts({
|
|
223
|
+
tenantId: "tenant_123",
|
|
224
|
+
pagination: { page, limit },
|
|
225
|
+
});
|
|
226
|
+
allCharts = allCharts.concat(res.data);
|
|
227
|
+
if (!res.pagination.hasNext) break;
|
|
228
|
+
page += 1;
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
### Bulk fetch saved charts by ID
|
|
233
|
+
|
|
234
|
+
To load specific saved charts by their **chart UUIDs** (from `createChart` or list responses), use `getChartsByIds()`. It calls **`GET /charts/bulk`** with `ids` as repeated or comma-separated query params. The API returns **`{ data, missingIds }`**. Up to **100** UUIDs per request.
|
|
235
|
+
|
|
236
|
+
```ts
|
|
237
|
+
const { data, missingIds } = await qp.getChartsByIds(
|
|
238
|
+
["550e8400-e29b-41d4-a716-446655440000"],
|
|
239
|
+
{ tenantId: "tenant_123", includeData: true },
|
|
240
|
+
);
|
|
241
|
+
```
|
|
242
|
+
|
|
204
243
|
Saved charts now include the original `prompt` so you can show the question
|
|
205
244
|
alongside chart history or reuse it in follow-up workflows.
|
|
206
245
|
|
|
@@ -366,6 +405,37 @@ dashboard.data.forEach(item => {
|
|
|
366
405
|
});
|
|
367
406
|
```
|
|
368
407
|
|
|
408
|
+
### All active charts (no pagination)
|
|
409
|
+
|
|
410
|
+
`listActiveCharts()` is **paginated** (default page size is small). To load every pinned chart for a tenant in one round trip, use `listAllActiveCharts()`, which calls **`GET /active-charts/all`** and returns `{ data }` from the API as a plain array.
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
const all = await qp.listAllActiveCharts({
|
|
414
|
+
tenantId: "tenant_123",
|
|
415
|
+
withData: true, // optional: same as listActiveCharts — runs SQL per chart via your attached DB
|
|
416
|
+
});
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### Bulk fetch by active-chart IDs
|
|
420
|
+
|
|
421
|
+
To load only specific dashboard tiles by their **active chart row IDs** (UUIDs from `createActiveChart` / `listActiveCharts`), use `getActiveChartsByIds()`. It calls **`GET /active-charts/bulk`** with query params `ids` (repeat or comma-separated). The API returns **`{ data, missingIds }`**: rows you are allowed to see, plus any requested IDs that were not found or not in scope.
|
|
422
|
+
|
|
423
|
+
```ts
|
|
424
|
+
const { data, missingIds } = await qp.getActiveChartsByIds(
|
|
425
|
+
["550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001"],
|
|
426
|
+
{
|
|
427
|
+
tenantId: "tenant_123",
|
|
428
|
+
withData: true, // optional
|
|
429
|
+
},
|
|
430
|
+
);
|
|
431
|
+
|
|
432
|
+
if (missingIds.length) {
|
|
433
|
+
console.warn("Unknown or inaccessible active charts:", missingIds);
|
|
434
|
+
}
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
The API accepts up to **100** UUIDs per request. Examples: `?ids=a&ids=b` or `?ids=a,b`.
|
|
438
|
+
|
|
369
439
|
## Deno Support
|
|
370
440
|
|
|
371
441
|
The SDK is fully compatible with Deno (including Supabase Edge Functions) thanks to its use of Web Crypto API for JWT signing. No additional configuration needed:
|
package/dist/index.cjs
CHANGED
|
@@ -1305,6 +1305,61 @@ async function listCharts(client, queryEngine, options, signal) {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
return response;
|
|
1307
1307
|
}
|
|
1308
|
+
async function listAllCharts(client, queryEngine, options, signal) {
|
|
1309
|
+
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1310
|
+
const params = new URLSearchParams();
|
|
1311
|
+
if (options?.pagination?.page)
|
|
1312
|
+
params.set("page", `${options.pagination.page}`);
|
|
1313
|
+
if (options?.pagination?.limit)
|
|
1314
|
+
params.set("limit", `${options.pagination.limit}`);
|
|
1315
|
+
if (options?.sortBy) params.set("sort_by", options.sortBy);
|
|
1316
|
+
if (options?.sortDir) params.set("sort_dir", options.sortDir);
|
|
1317
|
+
if (options?.title) params.set("title", options.title);
|
|
1318
|
+
if (options?.userFilter) params.set("user_id", options.userFilter);
|
|
1319
|
+
if (options?.createdFrom) params.set("created_from", options.createdFrom);
|
|
1320
|
+
if (options?.createdTo) params.set("created_to", options.createdTo);
|
|
1321
|
+
if (options?.updatedFrom) params.set("updated_from", options.updatedFrom);
|
|
1322
|
+
if (options?.updatedTo) params.set("updated_to", options.updatedTo);
|
|
1323
|
+
const response = await client.get(
|
|
1324
|
+
`/charts/all${params.toString() ? `?${params.toString()}` : ""}`,
|
|
1325
|
+
tenantId,
|
|
1326
|
+
options?.userId,
|
|
1327
|
+
options?.scopes,
|
|
1328
|
+
signal
|
|
1329
|
+
);
|
|
1330
|
+
if (options?.includeData) {
|
|
1331
|
+
response.data = await Promise.all(
|
|
1332
|
+
response.data.map(async (chart) => {
|
|
1333
|
+
const rows = await executeChartQuery(queryEngine, chart, tenantId);
|
|
1334
|
+
return hydrateChartWithData(chart, rows);
|
|
1335
|
+
})
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
return response;
|
|
1339
|
+
}
|
|
1340
|
+
async function getChartsByIds(client, queryEngine, ids, options, signal) {
|
|
1341
|
+
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1342
|
+
const params = new URLSearchParams();
|
|
1343
|
+
for (const id of ids) {
|
|
1344
|
+
params.append("ids", id);
|
|
1345
|
+
}
|
|
1346
|
+
const response = await client.get(
|
|
1347
|
+
`/charts/bulk${params.toString() ? `?${params.toString()}` : ""}`,
|
|
1348
|
+
tenantId,
|
|
1349
|
+
options?.userId,
|
|
1350
|
+
options?.scopes,
|
|
1351
|
+
signal
|
|
1352
|
+
);
|
|
1353
|
+
if (options?.includeData) {
|
|
1354
|
+
response.data = await Promise.all(
|
|
1355
|
+
response.data.map(async (chart) => {
|
|
1356
|
+
const rows = await executeChartQuery(queryEngine, chart, tenantId);
|
|
1357
|
+
return hydrateChartWithData(chart, rows);
|
|
1358
|
+
})
|
|
1359
|
+
);
|
|
1360
|
+
}
|
|
1361
|
+
return response;
|
|
1362
|
+
}
|
|
1308
1363
|
async function getChart(client, queryEngine, id, options, signal) {
|
|
1309
1364
|
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1310
1365
|
const chart = await client.get(
|
|
@@ -2772,6 +2827,29 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
|
2772
2827
|
signal
|
|
2773
2828
|
);
|
|
2774
2829
|
}
|
|
2830
|
+
/**
|
|
2831
|
+
* Lists saved charts via `GET /charts/all` (same query, filters, and pagination as {@link listCharts}).
|
|
2832
|
+
*/
|
|
2833
|
+
async listAllCharts(options, signal) {
|
|
2834
|
+
return await listAllCharts(
|
|
2835
|
+
this.client,
|
|
2836
|
+
this.queryEngine,
|
|
2837
|
+
options,
|
|
2838
|
+
signal
|
|
2839
|
+
);
|
|
2840
|
+
}
|
|
2841
|
+
/**
|
|
2842
|
+
* Bulk gets saved charts by chart IDs (`GET /charts/bulk` with `ids` query params).
|
|
2843
|
+
*/
|
|
2844
|
+
async getChartsByIds(ids, options, signal) {
|
|
2845
|
+
return await getChartsByIds(
|
|
2846
|
+
this.client,
|
|
2847
|
+
this.queryEngine,
|
|
2848
|
+
ids,
|
|
2849
|
+
options,
|
|
2850
|
+
signal
|
|
2851
|
+
);
|
|
2852
|
+
}
|
|
2775
2853
|
// Session history CRUD operations
|
|
2776
2854
|
/**
|
|
2777
2855
|
* Lists query sessions with pagination and filtering.
|