@querypanel/node-sdk 1.3.0-beta.0 → 1.3.0-beta.1
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 +4 -2
- package/dist/index.cjs +15 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -9
- package/dist/index.d.ts +15 -9
- package/dist/index.js +13 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -724,13 +724,14 @@ interface AskOptions {
|
|
|
724
724
|
*/
|
|
725
725
|
querypanelSessionId?: string;
|
|
726
726
|
/**
|
|
727
|
-
* Pipeline version
|
|
728
|
-
*
|
|
729
|
-
* - "v2":
|
|
727
|
+
* Pipeline version for query generation.
|
|
728
|
+
* Defaults to `"v2"` (`POST /v2/query`).
|
|
729
|
+
* - `"v2"` (default): intent planning, hybrid retrieval, schema linking, SQL reflection
|
|
730
|
+
* - `"v1"` (**deprecated**): legacy `POST /query` pipeline — prefer omitting or `"v2"`
|
|
730
731
|
*/
|
|
731
732
|
pipeline?: "v1" | "v2";
|
|
732
733
|
/**
|
|
733
|
-
* Optional model id for
|
|
734
|
+
* Optional model id for SQL generation (e.g. OpenAI or `gemini-*` when the API uses Gemini). Omit for server default.
|
|
734
735
|
*/
|
|
735
736
|
model?: string;
|
|
736
737
|
/**
|
|
@@ -742,7 +743,7 @@ interface AskOptions {
|
|
|
742
743
|
* Use this for tenant-specific policies (e.g. retention windows) that must
|
|
743
744
|
* be enforced on every query.
|
|
744
745
|
*
|
|
745
|
-
*
|
|
746
|
+
* Sent when the resolved pipeline is `"v2"` (the default).
|
|
746
747
|
*/
|
|
747
748
|
systemPrompt?: string;
|
|
748
749
|
/**
|
|
@@ -819,6 +820,10 @@ interface AskResponse {
|
|
|
819
820
|
/** Pipeline execution trace from v2 pipeline. */
|
|
820
821
|
trace?: PipelineTrace;
|
|
821
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Resolve ask/modify pipeline. Defaults to v2; `"v1"` remains available but deprecated.
|
|
825
|
+
*/
|
|
826
|
+
declare function resolveQueryPipeline(pipeline?: "v1" | "v2"): "v1" | "v2";
|
|
822
827
|
declare function anonymizeResults(rows: Array<Record<string, unknown>>): Array<Record<string, string>>;
|
|
823
828
|
|
|
824
829
|
/**
|
|
@@ -962,9 +967,10 @@ interface ChartModifyOptions {
|
|
|
962
967
|
/** Chart generation method: 'vega-lite' or 'vizspec' */
|
|
963
968
|
chartType?: "vega-lite" | "vizspec";
|
|
964
969
|
/**
|
|
965
|
-
* Pipeline version
|
|
966
|
-
*
|
|
967
|
-
* - "v2":
|
|
970
|
+
* Pipeline version for SQL regeneration.
|
|
971
|
+
* Defaults to `"v2"` (`POST /v2/query`).
|
|
972
|
+
* - `"v2"` (default): intent planning, hybrid retrieval, schema linking, SQL reflection
|
|
973
|
+
* - `"v1"` (**deprecated**): legacy `POST /query` pipeline — prefer omitting or `"v2"`
|
|
968
974
|
*/
|
|
969
975
|
pipeline?: "v1" | "v2";
|
|
970
976
|
/**
|
|
@@ -1957,4 +1963,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1957
1963
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1958
1964
|
}
|
|
1959
1965
|
|
|
1960
|
-
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, mapGeneratedParams, normalizeSqlParamsInput };
|
|
1966
|
+
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, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
package/dist/index.d.ts
CHANGED
|
@@ -724,13 +724,14 @@ interface AskOptions {
|
|
|
724
724
|
*/
|
|
725
725
|
querypanelSessionId?: string;
|
|
726
726
|
/**
|
|
727
|
-
* Pipeline version
|
|
728
|
-
*
|
|
729
|
-
* - "v2":
|
|
727
|
+
* Pipeline version for query generation.
|
|
728
|
+
* Defaults to `"v2"` (`POST /v2/query`).
|
|
729
|
+
* - `"v2"` (default): intent planning, hybrid retrieval, schema linking, SQL reflection
|
|
730
|
+
* - `"v1"` (**deprecated**): legacy `POST /query` pipeline — prefer omitting or `"v2"`
|
|
730
731
|
*/
|
|
731
732
|
pipeline?: "v1" | "v2";
|
|
732
733
|
/**
|
|
733
|
-
* Optional model id for
|
|
734
|
+
* Optional model id for SQL generation (e.g. OpenAI or `gemini-*` when the API uses Gemini). Omit for server default.
|
|
734
735
|
*/
|
|
735
736
|
model?: string;
|
|
736
737
|
/**
|
|
@@ -742,7 +743,7 @@ interface AskOptions {
|
|
|
742
743
|
* Use this for tenant-specific policies (e.g. retention windows) that must
|
|
743
744
|
* be enforced on every query.
|
|
744
745
|
*
|
|
745
|
-
*
|
|
746
|
+
* Sent when the resolved pipeline is `"v2"` (the default).
|
|
746
747
|
*/
|
|
747
748
|
systemPrompt?: string;
|
|
748
749
|
/**
|
|
@@ -819,6 +820,10 @@ interface AskResponse {
|
|
|
819
820
|
/** Pipeline execution trace from v2 pipeline. */
|
|
820
821
|
trace?: PipelineTrace;
|
|
821
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Resolve ask/modify pipeline. Defaults to v2; `"v1"` remains available but deprecated.
|
|
825
|
+
*/
|
|
826
|
+
declare function resolveQueryPipeline(pipeline?: "v1" | "v2"): "v1" | "v2";
|
|
822
827
|
declare function anonymizeResults(rows: Array<Record<string, unknown>>): Array<Record<string, string>>;
|
|
823
828
|
|
|
824
829
|
/**
|
|
@@ -962,9 +967,10 @@ interface ChartModifyOptions {
|
|
|
962
967
|
/** Chart generation method: 'vega-lite' or 'vizspec' */
|
|
963
968
|
chartType?: "vega-lite" | "vizspec";
|
|
964
969
|
/**
|
|
965
|
-
* Pipeline version
|
|
966
|
-
*
|
|
967
|
-
* - "v2":
|
|
970
|
+
* Pipeline version for SQL regeneration.
|
|
971
|
+
* Defaults to `"v2"` (`POST /v2/query`).
|
|
972
|
+
* - `"v2"` (default): intent planning, hybrid retrieval, schema linking, SQL reflection
|
|
973
|
+
* - `"v1"` (**deprecated**): legacy `POST /query` pipeline — prefer omitting or `"v2"`
|
|
968
974
|
*/
|
|
969
975
|
pipeline?: "v1" | "v2";
|
|
970
976
|
/**
|
|
@@ -1957,4 +1963,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1957
1963
|
}, signal?: AbortSignal): Promise<SdkDashboard[]>;
|
|
1958
1964
|
}
|
|
1959
1965
|
|
|
1960
|
-
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, mapGeneratedParams, normalizeSqlParamsInput };
|
|
1966
|
+
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, mapGeneratedParams, normalizeSqlParamsInput, resolveQueryPipeline };
|
package/dist/index.js
CHANGED
|
@@ -1936,6 +1936,9 @@ import crypto4 from "crypto";
|
|
|
1936
1936
|
|
|
1937
1937
|
// src/routes/query.ts
|
|
1938
1938
|
import crypto3 from "crypto";
|
|
1939
|
+
function resolveQueryPipeline(pipeline) {
|
|
1940
|
+
return pipeline ?? "v2";
|
|
1941
|
+
}
|
|
1939
1942
|
async function ask(client, queryEngine, question, options, signal) {
|
|
1940
1943
|
const tenantId = resolveTenantId5(client, options.tenantId);
|
|
1941
1944
|
const sessionId = crypto3.randomUUID();
|
|
@@ -1944,7 +1947,8 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1944
1947
|
let attempt = 0;
|
|
1945
1948
|
let lastError = options.lastError;
|
|
1946
1949
|
let previousSql = options.previousSql;
|
|
1947
|
-
const
|
|
1950
|
+
const pipeline = resolveQueryPipeline(options.pipeline);
|
|
1951
|
+
const queryEndpoint = pipeline === "v2" ? "/v2/query" : "/query";
|
|
1948
1952
|
while (attempt <= maxRetry) {
|
|
1949
1953
|
const databaseName = options.database ?? queryEngine.getDefaultDatabase();
|
|
1950
1954
|
const metadata = databaseName ? queryEngine.getDatabaseMetadata(databaseName) : void 0;
|
|
@@ -1968,7 +1972,7 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1968
1972
|
...databaseName ? { database: databaseName } : {},
|
|
1969
1973
|
...metadata?.dialect ? { dialect: metadata.dialect } : {},
|
|
1970
1974
|
...options.model?.trim() ? { model: options.model.trim() } : {},
|
|
1971
|
-
...
|
|
1975
|
+
...pipeline === "v2" && options.systemPrompt?.trim() ? { system_prompt: options.systemPrompt.trim() } : {},
|
|
1972
1976
|
debug: options.debug ?? false
|
|
1973
1977
|
},
|
|
1974
1978
|
tenantId,
|
|
@@ -2283,7 +2287,8 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
2283
2287
|
const hasSqlMods = !!input.sqlModifications;
|
|
2284
2288
|
const hasVizMods = !!input.vizModifications;
|
|
2285
2289
|
const hasCustomSql = !!input.sqlModifications?.customSql;
|
|
2286
|
-
const
|
|
2290
|
+
const pipeline = resolveQueryPipeline(options?.pipeline);
|
|
2291
|
+
const queryEndpoint = pipeline === "v2" ? "/v2/query" : "/query";
|
|
2287
2292
|
let finalSql = input.sql;
|
|
2288
2293
|
let finalParams = input.params ?? {};
|
|
2289
2294
|
let paramMetadata = [];
|
|
@@ -2315,10 +2320,10 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
2315
2320
|
const modifiedQuestion = buildModifiedQuestion(
|
|
2316
2321
|
input.question,
|
|
2317
2322
|
input.sqlModifications,
|
|
2318
|
-
|
|
2323
|
+
pipeline,
|
|
2319
2324
|
hasQuerypanelSessionContext
|
|
2320
2325
|
);
|
|
2321
|
-
if (
|
|
2326
|
+
if (pipeline === "v2") {
|
|
2322
2327
|
finalQuestion = modifiedQuestion;
|
|
2323
2328
|
}
|
|
2324
2329
|
const queryResponse = await client.post(
|
|
@@ -2342,7 +2347,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
2342
2347
|
finalSql = queryResponse.sql;
|
|
2343
2348
|
paramMetadata = Array.isArray(queryResponse.params) ? queryResponse.params : [];
|
|
2344
2349
|
finalParams = queryEngine.mapGeneratedParams(paramMetadata);
|
|
2345
|
-
if (
|
|
2350
|
+
if (pipeline === "v2") {
|
|
2346
2351
|
applyDateRangeOverrides(
|
|
2347
2352
|
input.sqlModifications?.dateRange,
|
|
2348
2353
|
finalParams,
|
|
@@ -3584,6 +3589,7 @@ export {
|
|
|
3584
3589
|
QueryPipelineError,
|
|
3585
3590
|
anonymizeResults,
|
|
3586
3591
|
mapGeneratedParams,
|
|
3587
|
-
normalizeSqlParamsInput
|
|
3592
|
+
normalizeSqlParamsInput,
|
|
3593
|
+
resolveQueryPipeline
|
|
3588
3594
|
};
|
|
3589
3595
|
//# sourceMappingURL=index.js.map
|