@querypanel/node-sdk 1.2.5 → 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 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
 
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.