@querypanel/node-sdk 1.2.2 → 1.2.3

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/dist/index.d.cts CHANGED
@@ -554,6 +554,8 @@ interface VizSpecBase {
554
554
  }
555
555
  type VizSpecKind = VizSpecBase["kind"];
556
556
  type ChartType = 'line' | 'bar' | 'column' | 'area' | 'scatter' | 'pie';
557
+ /** Full VizSpec chart catalog; use when building a custom `supportedChartTypes` list. */
558
+ declare const ALL_VIZ_CHART_TYPES: readonly ChartType[];
557
559
  type StackingMode = 'none' | 'stacked' | 'percent';
558
560
  interface ChartEncoding {
559
561
  chartType: ChartType;
@@ -720,6 +722,11 @@ interface AskOptions {
720
722
  * Only sent when `pipeline: "v2"`.
721
723
  */
722
724
  systemPrompt?: string;
725
+ /**
726
+ * Restrict VizSpec `chartType` values when `chartType` is `"vizspec"`.
727
+ * Sent to `POST /vizspec` as `supported_chart_types`. Omitted allows all standard types.
728
+ */
729
+ supportedChartTypes?: ChartType[];
723
730
  }
724
731
  /**
725
732
  * Intent analysis result from the v2 pipeline.
@@ -940,6 +947,10 @@ interface ChartModifyOptions {
940
947
  * the original question with modification hints.
941
948
  */
942
949
  querypanelSessionId?: string;
950
+ /**
951
+ * Restrict VizSpec chart types for this call (merged with SDK default from constructor when omitted).
952
+ */
953
+ supportedChartTypes?: ChartType[];
943
954
  }
944
955
  /**
945
956
  * Response from modifyChart(), extending AskResponse with modification metadata.
@@ -1054,6 +1065,8 @@ interface VizSpecGenerateInput {
1054
1065
  * When provided, these guide the LLM to generate specific visualization configurations.
1055
1066
  */
1056
1067
  encoding_hints?: EncodingHints;
1068
+ /** When set, VizSpec kind "chart" may only use these chart types (API: supported_chart_types). */
1069
+ supported_chart_types?: ChartType[];
1057
1070
  }
1058
1071
  interface VizSpecGenerateOptions {
1059
1072
  tenantId?: string;
@@ -1100,6 +1113,12 @@ interface QueryPanelSdkAPIOptions {
1100
1113
  * use this when calling the SDK from within your own API to avoid recursion.
1101
1114
  */
1102
1115
  api?: IQueryPanelApi;
1116
+ /**
1117
+ * Restrict VizSpec chart kinds (when using `chartType: "vizspec"`).
1118
+ * Omitted means all types: line, bar, column, area, scatter, pie.
1119
+ * Per-request `supportedChartTypes` on `ask` / `modifyChart` overrides this default.
1120
+ */
1121
+ supportedChartTypes?: ChartType[];
1103
1122
  }
1104
1123
  /**
1105
1124
  * Main SDK class - Thin orchestrator
@@ -1109,6 +1128,7 @@ interface QueryPanelSdkAPIOptions {
1109
1128
  declare class QueryPanelSdkAPI {
1110
1129
  private readonly client;
1111
1130
  private readonly queryEngine;
1131
+ private readonly supportedChartTypes?;
1112
1132
  /**
1113
1133
  * @param workspaceId - Workspace UUID (same value as your org in the dashboard). Passed to the API as JWT claim `organizationId`.
1114
1134
  */
@@ -1146,6 +1166,7 @@ declare class QueryPanelSdkAPI {
1146
1166
  */
1147
1167
  static withCallbacks(workspaceId: string, requestHandler: RequestHandler, options?: {
1148
1168
  defaultTenantId?: string;
1169
+ supportedChartTypes?: ChartType[];
1149
1170
  }): QueryPanelSdkAPI;
1150
1171
  attachClickhouse(name: string, clientFn: ClickHouseClientFn, options?: ClickHouseAdapterOptions & {
1151
1172
  description?: string;
@@ -1877,4 +1898,4 @@ declare class QueryPanelSdkAPI {
1877
1898
  }, signal?: AbortSignal): Promise<SdkDashboard[]>;
1878
1899
  }
1879
1900
 
1880
- export { 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 };
1901
+ export { ALL_VIZ_CHART_TYPES, 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 };
package/dist/index.d.ts CHANGED
@@ -554,6 +554,8 @@ interface VizSpecBase {
554
554
  }
555
555
  type VizSpecKind = VizSpecBase["kind"];
556
556
  type ChartType = 'line' | 'bar' | 'column' | 'area' | 'scatter' | 'pie';
557
+ /** Full VizSpec chart catalog; use when building a custom `supportedChartTypes` list. */
558
+ declare const ALL_VIZ_CHART_TYPES: readonly ChartType[];
557
559
  type StackingMode = 'none' | 'stacked' | 'percent';
558
560
  interface ChartEncoding {
559
561
  chartType: ChartType;
@@ -720,6 +722,11 @@ interface AskOptions {
720
722
  * Only sent when `pipeline: "v2"`.
721
723
  */
722
724
  systemPrompt?: string;
725
+ /**
726
+ * Restrict VizSpec `chartType` values when `chartType` is `"vizspec"`.
727
+ * Sent to `POST /vizspec` as `supported_chart_types`. Omitted allows all standard types.
728
+ */
729
+ supportedChartTypes?: ChartType[];
723
730
  }
724
731
  /**
725
732
  * Intent analysis result from the v2 pipeline.
@@ -940,6 +947,10 @@ interface ChartModifyOptions {
940
947
  * the original question with modification hints.
941
948
  */
942
949
  querypanelSessionId?: string;
950
+ /**
951
+ * Restrict VizSpec chart types for this call (merged with SDK default from constructor when omitted).
952
+ */
953
+ supportedChartTypes?: ChartType[];
943
954
  }
944
955
  /**
945
956
  * Response from modifyChart(), extending AskResponse with modification metadata.
@@ -1054,6 +1065,8 @@ interface VizSpecGenerateInput {
1054
1065
  * When provided, these guide the LLM to generate specific visualization configurations.
1055
1066
  */
1056
1067
  encoding_hints?: EncodingHints;
1068
+ /** When set, VizSpec kind "chart" may only use these chart types (API: supported_chart_types). */
1069
+ supported_chart_types?: ChartType[];
1057
1070
  }
1058
1071
  interface VizSpecGenerateOptions {
1059
1072
  tenantId?: string;
@@ -1100,6 +1113,12 @@ interface QueryPanelSdkAPIOptions {
1100
1113
  * use this when calling the SDK from within your own API to avoid recursion.
1101
1114
  */
1102
1115
  api?: IQueryPanelApi;
1116
+ /**
1117
+ * Restrict VizSpec chart kinds (when using `chartType: "vizspec"`).
1118
+ * Omitted means all types: line, bar, column, area, scatter, pie.
1119
+ * Per-request `supportedChartTypes` on `ask` / `modifyChart` overrides this default.
1120
+ */
1121
+ supportedChartTypes?: ChartType[];
1103
1122
  }
1104
1123
  /**
1105
1124
  * Main SDK class - Thin orchestrator
@@ -1109,6 +1128,7 @@ interface QueryPanelSdkAPIOptions {
1109
1128
  declare class QueryPanelSdkAPI {
1110
1129
  private readonly client;
1111
1130
  private readonly queryEngine;
1131
+ private readonly supportedChartTypes?;
1112
1132
  /**
1113
1133
  * @param workspaceId - Workspace UUID (same value as your org in the dashboard). Passed to the API as JWT claim `organizationId`.
1114
1134
  */
@@ -1146,6 +1166,7 @@ declare class QueryPanelSdkAPI {
1146
1166
  */
1147
1167
  static withCallbacks(workspaceId: string, requestHandler: RequestHandler, options?: {
1148
1168
  defaultTenantId?: string;
1169
+ supportedChartTypes?: ChartType[];
1149
1170
  }): QueryPanelSdkAPI;
1150
1171
  attachClickhouse(name: string, clientFn: ClickHouseClientFn, options?: ClickHouseAdapterOptions & {
1151
1172
  description?: string;
@@ -1877,4 +1898,4 @@ declare class QueryPanelSdkAPI {
1877
1898
  }, signal?: AbortSignal): Promise<SdkDashboard[]>;
1878
1899
  }
1879
1900
 
1880
- export { 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 };
1901
+ export { ALL_VIZ_CHART_TYPES, 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 };
package/dist/index.js CHANGED
@@ -1776,7 +1776,10 @@ async function ask(client, queryEngine, question, options, signal) {
1776
1776
  fields: execution.fields,
1777
1777
  rows: anonymizeResults(rows),
1778
1778
  max_retries: options.chartMaxRetries ?? 3,
1779
- query_id: queryResponse.data.queryId
1779
+ query_id: queryResponse.data.queryId,
1780
+ ...options.supportedChartTypes?.length ? {
1781
+ supported_chart_types: options.supportedChartTypes
1782
+ } : {}
1780
1783
  },
1781
1784
  tenantId,
1782
1785
  options.userId,
@@ -2117,7 +2120,8 @@ async function modifyChart(client, queryEngine, input, options, signal) {
2117
2120
  max_retries: options?.chartMaxRetries ?? 3,
2118
2121
  query_id: queryId,
2119
2122
  // Include viz hints for the chart generator
2120
- ...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
2123
+ ...hasVizMods ? { encoding_hints: vizHintsForChart } : {},
2124
+ ...options?.supportedChartTypes?.length ? { supported_chart_types: options.supportedChartTypes } : {}
2121
2125
  },
2122
2126
  tenantId,
2123
2127
  options?.userId,
@@ -2264,7 +2268,8 @@ async function generateVizSpec(client, input, options, signal) {
2264
2268
  rows: input.rows,
2265
2269
  max_retries: options?.maxRetries ?? input.max_retries ?? 3,
2266
2270
  query_id: input.query_id,
2267
- encoding_hints: input.encoding_hints
2271
+ encoding_hints: input.encoding_hints,
2272
+ ...input.supported_chart_types?.length ? { supported_chart_types: input.supported_chart_types } : {}
2268
2273
  },
2269
2274
  tenantId,
2270
2275
  options?.userId,
@@ -2284,10 +2289,21 @@ function resolveTenantId8(client, tenantId) {
2284
2289
  return resolved;
2285
2290
  }
2286
2291
 
2292
+ // src/types/vizspec.ts
2293
+ var ALL_VIZ_CHART_TYPES = [
2294
+ "line",
2295
+ "bar",
2296
+ "column",
2297
+ "area",
2298
+ "scatter",
2299
+ "pie"
2300
+ ];
2301
+
2287
2302
  // src/index.ts
2288
2303
  var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2289
2304
  client;
2290
2305
  queryEngine;
2306
+ supportedChartTypes;
2291
2307
  /**
2292
2308
  * @param workspaceId - Workspace UUID (same value as your org in the dashboard). Passed to the API as JWT claim `organizationId`.
2293
2309
  */
@@ -2305,6 +2321,7 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2305
2321
  });
2306
2322
  }
2307
2323
  this.queryEngine = new QueryEngine();
2324
+ this.supportedChartTypes = options?.supportedChartTypes;
2308
2325
  }
2309
2326
  /**
2310
2327
  * Create an SDK instance that uses a request callback instead of HTTP.
@@ -2341,7 +2358,10 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2341
2358
  const api = new CallbackApiClient(requestHandler, {
2342
2359
  defaultTenantId: options?.defaultTenantId
2343
2360
  });
2344
- return new _QueryPanelSdkAPI("", "", workspaceId, { api });
2361
+ return new _QueryPanelSdkAPI("", "", workspaceId, {
2362
+ api,
2363
+ supportedChartTypes: options?.supportedChartTypes
2364
+ });
2345
2365
  }
2346
2366
  // Database attachment methods
2347
2367
  attachClickhouse(name, clientFn, options) {
@@ -2465,7 +2485,10 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2465
2485
  this.client,
2466
2486
  this.queryEngine,
2467
2487
  question,
2468
- options,
2488
+ {
2489
+ ...options,
2490
+ supportedChartTypes: options.supportedChartTypes ?? this.supportedChartTypes
2491
+ },
2469
2492
  signal
2470
2493
  );
2471
2494
  }
@@ -2537,7 +2560,10 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2537
2560
  async generateVizSpec(input, options, signal) {
2538
2561
  return await generateVizSpec(
2539
2562
  this.client,
2540
- input,
2563
+ {
2564
+ ...input,
2565
+ supported_chart_types: input.supported_chart_types ?? this.supportedChartTypes
2566
+ },
2541
2567
  options,
2542
2568
  signal
2543
2569
  );
@@ -2605,7 +2631,10 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2605
2631
  this.client,
2606
2632
  this.queryEngine,
2607
2633
  input,
2608
- options,
2634
+ options ? {
2635
+ ...options,
2636
+ supportedChartTypes: options.supportedChartTypes ?? this.supportedChartTypes
2637
+ } : this.supportedChartTypes ? { supportedChartTypes: this.supportedChartTypes } : void 0,
2609
2638
  signal
2610
2639
  );
2611
2640
  }
@@ -3243,6 +3272,7 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
3243
3272
  }
3244
3273
  };
3245
3274
  export {
3275
+ ALL_VIZ_CHART_TYPES,
3246
3276
  BigQueryAdapter,
3247
3277
  CallbackApiClient,
3248
3278
  ClickHouseAdapter,