@querypanel/node-sdk 1.2.3 → 1.2.5
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 +31 -0
- package/dist/index.cjs +83 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +83 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -366,6 +366,37 @@ dashboard.data.forEach(item => {
|
|
|
366
366
|
});
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
+
### All active charts (no pagination)
|
|
370
|
+
|
|
371
|
+
`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.
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
const all = await qp.listAllActiveCharts({
|
|
375
|
+
tenantId: "tenant_123",
|
|
376
|
+
withData: true, // optional: same as listActiveCharts — runs SQL per chart via your attached DB
|
|
377
|
+
});
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### Bulk fetch by active-chart IDs
|
|
381
|
+
|
|
382
|
+
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.
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
const { data, missingIds } = await qp.getActiveChartsByIds(
|
|
386
|
+
["550e8400-e29b-41d4-a716-446655440000", "550e8400-e29b-41d4-a716-446655440001"],
|
|
387
|
+
{
|
|
388
|
+
tenantId: "tenant_123",
|
|
389
|
+
withData: true, // optional
|
|
390
|
+
},
|
|
391
|
+
);
|
|
392
|
+
|
|
393
|
+
if (missingIds.length) {
|
|
394
|
+
console.warn("Unknown or inaccessible active charts:", missingIds);
|
|
395
|
+
}
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
The API accepts up to **100** UUIDs per request. Examples: `?ids=a&ids=b` or `?ids=a,b`.
|
|
399
|
+
|
|
369
400
|
## Deno Support
|
|
370
401
|
|
|
371
402
|
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
|
@@ -58,12 +58,6 @@ var BigQueryAdapter = class {
|
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
projectId;
|
|
62
|
-
datasetProjectId;
|
|
63
|
-
defaultDataset;
|
|
64
|
-
databaseName;
|
|
65
|
-
kind;
|
|
66
|
-
allowedTables;
|
|
67
61
|
async execute(sql, params) {
|
|
68
62
|
if (this.allowedTables) {
|
|
69
63
|
this.validateQueryTables(sql);
|
|
@@ -294,10 +288,6 @@ var ClickHouseAdapter = class {
|
|
|
294
288
|
this.allowedTables = normalizeTableFilter2(options.allowedTables);
|
|
295
289
|
}
|
|
296
290
|
}
|
|
297
|
-
databaseName;
|
|
298
|
-
defaultFormat;
|
|
299
|
-
kind;
|
|
300
|
-
allowedTables;
|
|
301
291
|
async execute(sql, params) {
|
|
302
292
|
if (this.allowedTables) {
|
|
303
293
|
this.validateQueryTables(sql);
|
|
@@ -510,10 +500,6 @@ var PostgresAdapter = class {
|
|
|
510
500
|
);
|
|
511
501
|
}
|
|
512
502
|
}
|
|
513
|
-
databaseName;
|
|
514
|
-
defaultSchema;
|
|
515
|
-
kind;
|
|
516
|
-
allowedTables;
|
|
517
503
|
async execute(sql, params) {
|
|
518
504
|
if (this.allowedTables) {
|
|
519
505
|
this.validateQueryTables(sql);
|
|
@@ -754,14 +740,8 @@ function sanitize2(value) {
|
|
|
754
740
|
// src/core/client.ts
|
|
755
741
|
var import_node_crypto = __toESM(require("crypto"), 1);
|
|
756
742
|
var ApiClient = class {
|
|
757
|
-
baseUrl;
|
|
758
|
-
privateKey;
|
|
759
|
-
organizationId;
|
|
760
|
-
defaultTenantId;
|
|
761
|
-
additionalHeaders;
|
|
762
|
-
fetchImpl;
|
|
763
|
-
cryptoKey = null;
|
|
764
743
|
constructor(baseUrl, privateKey, organizationId, options) {
|
|
744
|
+
this.cryptoKey = null;
|
|
765
745
|
if (!baseUrl) {
|
|
766
746
|
throw new Error("Base URL is required");
|
|
767
747
|
}
|
|
@@ -1007,8 +987,6 @@ var ApiClient = class {
|
|
|
1007
987
|
|
|
1008
988
|
// src/core/callback-client.ts
|
|
1009
989
|
var CallbackApiClient = class {
|
|
1010
|
-
requestHandler;
|
|
1011
|
-
defaultTenantId;
|
|
1012
990
|
constructor(requestHandler, options) {
|
|
1013
991
|
this.requestHandler = requestHandler;
|
|
1014
992
|
this.defaultTenantId = options?.defaultTenantId;
|
|
@@ -1112,9 +1090,10 @@ var CallbackApiClient = class {
|
|
|
1112
1090
|
|
|
1113
1091
|
// src/core/query-engine.ts
|
|
1114
1092
|
var QueryEngine = class {
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1093
|
+
constructor() {
|
|
1094
|
+
this.databases = /* @__PURE__ */ new Map();
|
|
1095
|
+
this.databaseMetadata = /* @__PURE__ */ new Map();
|
|
1096
|
+
}
|
|
1118
1097
|
attachDatabase(name, adapter, metadata) {
|
|
1119
1098
|
this.databases.set(name, adapter);
|
|
1120
1099
|
this.databaseMetadata.set(name, metadata);
|
|
@@ -1434,7 +1413,7 @@ async function listActiveCharts(client, queryEngine, options, signal) {
|
|
|
1434
1413
|
params.set("limit", `${options.pagination.limit}`);
|
|
1435
1414
|
if (options?.sortBy) params.set("sort_by", options.sortBy);
|
|
1436
1415
|
if (options?.sortDir) params.set("sort_dir", options.sortDir);
|
|
1437
|
-
if (options?.title) params.set("
|
|
1416
|
+
if (options?.title) params.set("title", options.title);
|
|
1438
1417
|
if (options?.userFilter) params.set("user_id", options.userFilter);
|
|
1439
1418
|
if (options?.createdFrom) params.set("created_from", options.createdFrom);
|
|
1440
1419
|
if (options?.createdTo) params.set("created_to", options.createdTo);
|
|
@@ -1463,6 +1442,60 @@ async function listActiveCharts(client, queryEngine, options, signal) {
|
|
|
1463
1442
|
}
|
|
1464
1443
|
return response;
|
|
1465
1444
|
}
|
|
1445
|
+
async function listAllActiveCharts(client, queryEngine, options, signal) {
|
|
1446
|
+
const tenantId = resolveTenantId2(client, options?.tenantId);
|
|
1447
|
+
const response = await client.get(
|
|
1448
|
+
"/active-charts/all",
|
|
1449
|
+
tenantId,
|
|
1450
|
+
options?.userId,
|
|
1451
|
+
options?.scopes,
|
|
1452
|
+
signal
|
|
1453
|
+
);
|
|
1454
|
+
if (options?.withData) {
|
|
1455
|
+
response.data = await Promise.all(
|
|
1456
|
+
response.data.map(async (active) => ({
|
|
1457
|
+
...active,
|
|
1458
|
+
chart: active.chart ? await getChart(
|
|
1459
|
+
client,
|
|
1460
|
+
queryEngine,
|
|
1461
|
+
active.chart_id,
|
|
1462
|
+
options,
|
|
1463
|
+
signal
|
|
1464
|
+
) : null
|
|
1465
|
+
}))
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
return response.data;
|
|
1469
|
+
}
|
|
1470
|
+
async function getActiveChartsByIds(client, queryEngine, ids, options, signal) {
|
|
1471
|
+
const tenantId = resolveTenantId2(client, options?.tenantId);
|
|
1472
|
+
const params = new URLSearchParams();
|
|
1473
|
+
for (const id of ids) {
|
|
1474
|
+
params.append("ids", id);
|
|
1475
|
+
}
|
|
1476
|
+
const response = await client.get(
|
|
1477
|
+
`/active-charts/bulk${params.toString() ? `?${params.toString()}` : ""}`,
|
|
1478
|
+
tenantId,
|
|
1479
|
+
options?.userId,
|
|
1480
|
+
options?.scopes,
|
|
1481
|
+
signal
|
|
1482
|
+
);
|
|
1483
|
+
if (options?.withData) {
|
|
1484
|
+
response.data = await Promise.all(
|
|
1485
|
+
response.data.map(async (active) => ({
|
|
1486
|
+
...active,
|
|
1487
|
+
chart: active.chart ? await getChart(
|
|
1488
|
+
client,
|
|
1489
|
+
queryEngine,
|
|
1490
|
+
active.chart_id,
|
|
1491
|
+
options,
|
|
1492
|
+
signal
|
|
1493
|
+
) : null
|
|
1494
|
+
}))
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
return response;
|
|
1498
|
+
}
|
|
1466
1499
|
async function getActiveChart(client, queryEngine, id, options, signal) {
|
|
1467
1500
|
const tenantId = resolveTenantId2(client, options?.tenantId);
|
|
1468
1501
|
const active = await client.get(
|
|
@@ -2345,9 +2378,6 @@ var ALL_VIZ_CHART_TYPES = [
|
|
|
2345
2378
|
|
|
2346
2379
|
// src/index.ts
|
|
2347
2380
|
var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
2348
|
-
client;
|
|
2349
|
-
queryEngine;
|
|
2350
|
-
supportedChartTypes;
|
|
2351
2381
|
/**
|
|
2352
2382
|
* @param workspaceId - Workspace UUID (same value as your org in the dashboard). Passed to the API as JWT claim `organizationId`.
|
|
2353
2383
|
*/
|
|
@@ -2957,6 +2987,29 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
|
2957
2987
|
signal
|
|
2958
2988
|
);
|
|
2959
2989
|
}
|
|
2990
|
+
/**
|
|
2991
|
+
* Lists all active charts without pagination.
|
|
2992
|
+
*/
|
|
2993
|
+
async listAllActiveCharts(options, signal) {
|
|
2994
|
+
return await listAllActiveCharts(
|
|
2995
|
+
this.client,
|
|
2996
|
+
this.queryEngine,
|
|
2997
|
+
options,
|
|
2998
|
+
signal
|
|
2999
|
+
);
|
|
3000
|
+
}
|
|
3001
|
+
/**
|
|
3002
|
+
* Bulk gets active charts by IDs.
|
|
3003
|
+
*/
|
|
3004
|
+
async getActiveChartsByIds(ids, options, signal) {
|
|
3005
|
+
return await getActiveChartsByIds(
|
|
3006
|
+
this.client,
|
|
3007
|
+
this.queryEngine,
|
|
3008
|
+
ids,
|
|
3009
|
+
options,
|
|
3010
|
+
signal
|
|
3011
|
+
);
|
|
3012
|
+
}
|
|
2960
3013
|
/**
|
|
2961
3014
|
* Retrieves a single active chart by ID.
|
|
2962
3015
|
*
|