@querypanel/node-sdk 1.2.5 → 1.2.7
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 +39 -0
- package/dist/index.cjs +90 -2
- 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 +90 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -395,6 +395,12 @@ interface ChartListOptions {
|
|
|
395
395
|
updatedTo?: string;
|
|
396
396
|
includeData?: boolean;
|
|
397
397
|
}
|
|
398
|
+
/** Options for bulk chart fetch (`GET /charts/bulk`) — no pagination. */
|
|
399
|
+
type ChartListAllOptions = Omit<ChartListOptions, "pagination">;
|
|
400
|
+
interface ChartBulkGetResponse {
|
|
401
|
+
data: SdkChart[];
|
|
402
|
+
missingIds: string[];
|
|
403
|
+
}
|
|
398
404
|
|
|
399
405
|
interface SdkActiveChart {
|
|
400
406
|
id: string;
|
|
@@ -1412,6 +1418,14 @@ declare class QueryPanelSdkAPI {
|
|
|
1412
1418
|
* ```
|
|
1413
1419
|
*/
|
|
1414
1420
|
listCharts(options?: ChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse$1<SdkChart>>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Lists saved charts via `GET /charts/all` (same query, filters, and pagination as {@link listCharts}).
|
|
1423
|
+
*/
|
|
1424
|
+
listAllCharts(options?: ChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse$1<SdkChart>>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Bulk gets saved charts by chart IDs (`GET /charts/bulk` with `ids` query params).
|
|
1427
|
+
*/
|
|
1428
|
+
getChartsByIds(ids: string[], options?: ChartListAllOptions, signal?: AbortSignal): Promise<ChartBulkGetResponse>;
|
|
1415
1429
|
/**
|
|
1416
1430
|
* Lists query sessions with pagination and filtering.
|
|
1417
1431
|
*
|
|
@@ -1910,4 +1924,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1910
1924
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1911
1925
|
}
|
|
1912
1926
|
|
|
1913
|
-
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults };
|
|
1927
|
+
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults };
|
package/dist/index.d.ts
CHANGED
|
@@ -395,6 +395,12 @@ interface ChartListOptions {
|
|
|
395
395
|
updatedTo?: string;
|
|
396
396
|
includeData?: boolean;
|
|
397
397
|
}
|
|
398
|
+
/** Options for bulk chart fetch (`GET /charts/bulk`) — no pagination. */
|
|
399
|
+
type ChartListAllOptions = Omit<ChartListOptions, "pagination">;
|
|
400
|
+
interface ChartBulkGetResponse {
|
|
401
|
+
data: SdkChart[];
|
|
402
|
+
missingIds: string[];
|
|
403
|
+
}
|
|
398
404
|
|
|
399
405
|
interface SdkActiveChart {
|
|
400
406
|
id: string;
|
|
@@ -1412,6 +1418,14 @@ declare class QueryPanelSdkAPI {
|
|
|
1412
1418
|
* ```
|
|
1413
1419
|
*/
|
|
1414
1420
|
listCharts(options?: ChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse$1<SdkChart>>;
|
|
1421
|
+
/**
|
|
1422
|
+
* Lists saved charts via `GET /charts/all` (same query, filters, and pagination as {@link listCharts}).
|
|
1423
|
+
*/
|
|
1424
|
+
listAllCharts(options?: ChartListOptions, signal?: AbortSignal): Promise<PaginatedResponse$1<SdkChart>>;
|
|
1425
|
+
/**
|
|
1426
|
+
* Bulk gets saved charts by chart IDs (`GET /charts/bulk` with `ids` query params).
|
|
1427
|
+
*/
|
|
1428
|
+
getChartsByIds(ids: string[], options?: ChartListAllOptions, signal?: AbortSignal): Promise<ChartBulkGetResponse>;
|
|
1415
1429
|
/**
|
|
1416
1430
|
* Lists query sessions with pagination and filtering.
|
|
1417
1431
|
*
|
|
@@ -1910,4 +1924,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1910
1924
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1911
1925
|
}
|
|
1912
1926
|
|
|
1913
|
-
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults };
|
|
1927
|
+
export { ALL_VIZ_CHART_TYPES, type ActiveChartBulkGetResponse, type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, BigQueryAdapter, type BigQueryAdapterOptions, type BigQueryClientFn, type BigQueryQueryRequest, type BigQueryQueryResult, CallbackApiClient, type ChartBulkGetResponse, type ChartCreateInput, type ChartEncoding, type ChartEnvelope, type ChartListAllOptions, type ChartListOptions, type ChartModifyInput, type ChartModifyOptions, type ChartModifyResponse, type ChartSpec, type ChartType, type ChartUpdateInput, ClickHouseAdapter, type ClickHouseAdapterOptions, type ClickHouseClientFn, type ContextDocument, type DashboardCreateInput, type DashboardForkInput, type DashboardForkUpdateInput, type DashboardListOptions, type DashboardUpdateInput, type DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IQueryPanelApi, type IngestResponse, type IntentResult, type MetricEncoding, type MetricField, type MetricSpec, type PaginatedResponse$1 as PaginatedResponse, type PaginationInfo$1 as PaginationInfo, type PaginationQuery$1 as PaginationQuery, type ParamRecord, type ParamValue, type PipelineTrace, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, type QueryPanelSdkAPIOptions, QueryPipelineError, type RequestHandler, type RequestHandlerOptions, type RequestHandlerResult, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkDashboard, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type ValueFormat, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecGeneratorInput, type VizSpecKind, type VizSpecResponse, type VizSpecResult, anonymizeResults };
|
package/dist/index.js
CHANGED
|
@@ -338,10 +338,15 @@ var ClickHouseAdapter = class {
|
|
|
338
338
|
return;
|
|
339
339
|
}
|
|
340
340
|
const allowedSet = new Set(this.allowedTables);
|
|
341
|
-
const tablePattern =
|
|
341
|
+
const tablePattern = /\b(FROM|JOIN)\s+(?:FINAL\s+)?(?:(?:[a-zA-Z_][a-zA-Z0-9_]*)\.)?(["'`]?[a-zA-Z_][a-zA-Z0-9_]*["'`]?)/gi;
|
|
342
342
|
const matches = sql.matchAll(tablePattern);
|
|
343
343
|
for (const match of matches) {
|
|
344
|
-
const
|
|
344
|
+
const clause = match[1]?.toUpperCase();
|
|
345
|
+
const matchIndex = match.index ?? -1;
|
|
346
|
+
if (clause === "JOIN" && matchIndex >= 0 && isArrayJoinClause(sql, matchIndex)) {
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
const table = match[2]?.replace(/["'`]/g, "");
|
|
345
350
|
if (table) {
|
|
346
351
|
if (!allowedSet.has(table)) {
|
|
347
352
|
throw new Error(
|
|
@@ -409,6 +414,11 @@ function normalizeTableFilter2(tables) {
|
|
|
409
414
|
}
|
|
410
415
|
return normalized;
|
|
411
416
|
}
|
|
417
|
+
function isArrayJoinClause(sql, joinIndex) {
|
|
418
|
+
const beforeJoin = sql.slice(0, joinIndex);
|
|
419
|
+
const previousToken = beforeJoin.trim().split(/\s+/).pop()?.toUpperCase();
|
|
420
|
+
return previousToken === "ARRAY";
|
|
421
|
+
}
|
|
412
422
|
function transformColumnRow(row) {
|
|
413
423
|
const unwrappedType = unwrapTypeModifiers(row.type);
|
|
414
424
|
const column = {
|
|
@@ -1261,6 +1271,61 @@ async function listCharts(client, queryEngine, options, signal) {
|
|
|
1261
1271
|
}
|
|
1262
1272
|
return response;
|
|
1263
1273
|
}
|
|
1274
|
+
async function listAllCharts(client, queryEngine, options, signal) {
|
|
1275
|
+
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1276
|
+
const params = new URLSearchParams();
|
|
1277
|
+
if (options?.pagination?.page)
|
|
1278
|
+
params.set("page", `${options.pagination.page}`);
|
|
1279
|
+
if (options?.pagination?.limit)
|
|
1280
|
+
params.set("limit", `${options.pagination.limit}`);
|
|
1281
|
+
if (options?.sortBy) params.set("sort_by", options.sortBy);
|
|
1282
|
+
if (options?.sortDir) params.set("sort_dir", options.sortDir);
|
|
1283
|
+
if (options?.title) params.set("title", options.title);
|
|
1284
|
+
if (options?.userFilter) params.set("user_id", options.userFilter);
|
|
1285
|
+
if (options?.createdFrom) params.set("created_from", options.createdFrom);
|
|
1286
|
+
if (options?.createdTo) params.set("created_to", options.createdTo);
|
|
1287
|
+
if (options?.updatedFrom) params.set("updated_from", options.updatedFrom);
|
|
1288
|
+
if (options?.updatedTo) params.set("updated_to", options.updatedTo);
|
|
1289
|
+
const response = await client.get(
|
|
1290
|
+
`/charts/all${params.toString() ? `?${params.toString()}` : ""}`,
|
|
1291
|
+
tenantId,
|
|
1292
|
+
options?.userId,
|
|
1293
|
+
options?.scopes,
|
|
1294
|
+
signal
|
|
1295
|
+
);
|
|
1296
|
+
if (options?.includeData) {
|
|
1297
|
+
response.data = await Promise.all(
|
|
1298
|
+
response.data.map(async (chart) => {
|
|
1299
|
+
const rows = await executeChartQuery(queryEngine, chart, tenantId);
|
|
1300
|
+
return hydrateChartWithData(chart, rows);
|
|
1301
|
+
})
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
return response;
|
|
1305
|
+
}
|
|
1306
|
+
async function getChartsByIds(client, queryEngine, ids, options, signal) {
|
|
1307
|
+
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1308
|
+
const params = new URLSearchParams();
|
|
1309
|
+
for (const id of ids) {
|
|
1310
|
+
params.append("ids", id);
|
|
1311
|
+
}
|
|
1312
|
+
const response = await client.get(
|
|
1313
|
+
`/charts/bulk${params.toString() ? `?${params.toString()}` : ""}`,
|
|
1314
|
+
tenantId,
|
|
1315
|
+
options?.userId,
|
|
1316
|
+
options?.scopes,
|
|
1317
|
+
signal
|
|
1318
|
+
);
|
|
1319
|
+
if (options?.includeData) {
|
|
1320
|
+
response.data = await Promise.all(
|
|
1321
|
+
response.data.map(async (chart) => {
|
|
1322
|
+
const rows = await executeChartQuery(queryEngine, chart, tenantId);
|
|
1323
|
+
return hydrateChartWithData(chart, rows);
|
|
1324
|
+
})
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
return response;
|
|
1328
|
+
}
|
|
1264
1329
|
async function getChart(client, queryEngine, id, options, signal) {
|
|
1265
1330
|
const tenantId = resolveTenantId(client, options?.tenantId);
|
|
1266
1331
|
const chart = await client.get(
|
|
@@ -2728,6 +2793,29 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
|
|
|
2728
2793
|
signal
|
|
2729
2794
|
);
|
|
2730
2795
|
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Lists saved charts via `GET /charts/all` (same query, filters, and pagination as {@link listCharts}).
|
|
2798
|
+
*/
|
|
2799
|
+
async listAllCharts(options, signal) {
|
|
2800
|
+
return await listAllCharts(
|
|
2801
|
+
this.client,
|
|
2802
|
+
this.queryEngine,
|
|
2803
|
+
options,
|
|
2804
|
+
signal
|
|
2805
|
+
);
|
|
2806
|
+
}
|
|
2807
|
+
/**
|
|
2808
|
+
* Bulk gets saved charts by chart IDs (`GET /charts/bulk` with `ids` query params).
|
|
2809
|
+
*/
|
|
2810
|
+
async getChartsByIds(ids, options, signal) {
|
|
2811
|
+
return await getChartsByIds(
|
|
2812
|
+
this.client,
|
|
2813
|
+
this.queryEngine,
|
|
2814
|
+
ids,
|
|
2815
|
+
options,
|
|
2816
|
+
signal
|
|
2817
|
+
);
|
|
2818
|
+
}
|
|
2731
2819
|
// Session history CRUD operations
|
|
2732
2820
|
/**
|
|
2733
2821
|
* Lists query sessions with pagination and filtering.
|