@querypanel/node-sdk 1.0.48 → 1.0.50
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.cjs +15 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +54 -2
- package/dist/index.d.ts +54 -2
- package/dist/index.js +15 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -368,7 +368,8 @@ interface VizSpecBase {
|
|
|
368
368
|
sourceId: string;
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
-
type
|
|
371
|
+
type VizSpecKind = VizSpecBase["kind"];
|
|
372
|
+
type ChartType = 'line' | 'bar' | 'column' | 'area' | 'scatter' | 'pie';
|
|
372
373
|
type StackingMode = 'none' | 'stacked' | 'percent';
|
|
373
374
|
interface ChartEncoding {
|
|
374
375
|
chartType: ChartType;
|
|
@@ -415,6 +416,50 @@ interface MetricSpec extends VizSpecBase {
|
|
|
415
416
|
encoding: MetricEncoding;
|
|
416
417
|
}
|
|
417
418
|
type VizSpec = ChartSpec | TableSpec | MetricSpec;
|
|
419
|
+
/**
|
|
420
|
+
* Encoding hints for vizspec modifications.
|
|
421
|
+
* These hints guide the LLM to generate specific visualization configurations.
|
|
422
|
+
*/
|
|
423
|
+
interface EncodingHints {
|
|
424
|
+
/** Preferred vizspec kind (chart, table, metric) */
|
|
425
|
+
kind?: 'chart' | 'table' | 'metric';
|
|
426
|
+
/** Preferred chart type (bar, line, area, scatter, pie) */
|
|
427
|
+
chartType?: ChartType;
|
|
428
|
+
/** X axis field configuration */
|
|
429
|
+
xAxis?: AxisField;
|
|
430
|
+
/** Y axis field configuration (single or multiple) */
|
|
431
|
+
yAxis?: AxisField | AxisField[];
|
|
432
|
+
/** Series/color field for multi-series charts */
|
|
433
|
+
series?: FieldRef;
|
|
434
|
+
/** Stacking mode for multi-series */
|
|
435
|
+
stacking?: StackingMode;
|
|
436
|
+
/** Maximum rows to display */
|
|
437
|
+
limit?: number;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Input for vizspec generator service
|
|
441
|
+
*/
|
|
442
|
+
interface VizSpecGeneratorInput {
|
|
443
|
+
question: string;
|
|
444
|
+
sql: string;
|
|
445
|
+
rationale?: string;
|
|
446
|
+
fields: string[];
|
|
447
|
+
rows: Array<Record<string, unknown>>;
|
|
448
|
+
maxRetries?: number;
|
|
449
|
+
queryId?: string;
|
|
450
|
+
/**
|
|
451
|
+
* Optional encoding hints for visualization modification.
|
|
452
|
+
* When provided, these guide the LLM to generate specific visualization configurations.
|
|
453
|
+
*/
|
|
454
|
+
encodingHints?: EncodingHints;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Output from vizspec generator service
|
|
458
|
+
*/
|
|
459
|
+
interface VizSpecResult {
|
|
460
|
+
spec: VizSpec;
|
|
461
|
+
notes: string | null;
|
|
462
|
+
}
|
|
418
463
|
|
|
419
464
|
/**
|
|
420
465
|
* Context document returned by the query pipeline.
|
|
@@ -573,6 +618,8 @@ interface SqlModifications {
|
|
|
573
618
|
* These changes only affect how the chart is rendered.
|
|
574
619
|
*/
|
|
575
620
|
interface VizModifications {
|
|
621
|
+
/** Change the VizSpec kind (chart, table, metric). Applies to vizspec only. */
|
|
622
|
+
kind?: VizSpecKind;
|
|
576
623
|
/** Change the chart type (line, bar, area, scatter, pie) */
|
|
577
624
|
chartType?: ChartType;
|
|
578
625
|
/** Configure the X axis field and settings */
|
|
@@ -750,6 +797,11 @@ interface VizSpecGenerateInput {
|
|
|
750
797
|
rows: Array<Record<string, unknown>>;
|
|
751
798
|
max_retries?: number;
|
|
752
799
|
query_id?: string;
|
|
800
|
+
/**
|
|
801
|
+
* Optional encoding hints for visualization modification.
|
|
802
|
+
* When provided, these guide the LLM to generate specific visualization configurations.
|
|
803
|
+
*/
|
|
804
|
+
encoding_hints?: EncodingHints;
|
|
753
805
|
}
|
|
754
806
|
interface VizSpecGenerateOptions {
|
|
755
807
|
tenantId?: string;
|
|
@@ -1231,4 +1283,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1231
1283
|
}, signal?: AbortSignal): Promise<void>;
|
|
1232
1284
|
}
|
|
1233
1285
|
|
|
1234
|
-
export { type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, 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 DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type FieldRef, type FieldRefInput, type FieldType, type IngestResponse, 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, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, QueryPipelineError, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecResponse, anonymizeResults };
|
|
1286
|
+
export { type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, 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 DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IngestResponse, 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, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, QueryPipelineError, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, 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
|
@@ -368,7 +368,8 @@ interface VizSpecBase {
|
|
|
368
368
|
sourceId: string;
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
-
type
|
|
371
|
+
type VizSpecKind = VizSpecBase["kind"];
|
|
372
|
+
type ChartType = 'line' | 'bar' | 'column' | 'area' | 'scatter' | 'pie';
|
|
372
373
|
type StackingMode = 'none' | 'stacked' | 'percent';
|
|
373
374
|
interface ChartEncoding {
|
|
374
375
|
chartType: ChartType;
|
|
@@ -415,6 +416,50 @@ interface MetricSpec extends VizSpecBase {
|
|
|
415
416
|
encoding: MetricEncoding;
|
|
416
417
|
}
|
|
417
418
|
type VizSpec = ChartSpec | TableSpec | MetricSpec;
|
|
419
|
+
/**
|
|
420
|
+
* Encoding hints for vizspec modifications.
|
|
421
|
+
* These hints guide the LLM to generate specific visualization configurations.
|
|
422
|
+
*/
|
|
423
|
+
interface EncodingHints {
|
|
424
|
+
/** Preferred vizspec kind (chart, table, metric) */
|
|
425
|
+
kind?: 'chart' | 'table' | 'metric';
|
|
426
|
+
/** Preferred chart type (bar, line, area, scatter, pie) */
|
|
427
|
+
chartType?: ChartType;
|
|
428
|
+
/** X axis field configuration */
|
|
429
|
+
xAxis?: AxisField;
|
|
430
|
+
/** Y axis field configuration (single or multiple) */
|
|
431
|
+
yAxis?: AxisField | AxisField[];
|
|
432
|
+
/** Series/color field for multi-series charts */
|
|
433
|
+
series?: FieldRef;
|
|
434
|
+
/** Stacking mode for multi-series */
|
|
435
|
+
stacking?: StackingMode;
|
|
436
|
+
/** Maximum rows to display */
|
|
437
|
+
limit?: number;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Input for vizspec generator service
|
|
441
|
+
*/
|
|
442
|
+
interface VizSpecGeneratorInput {
|
|
443
|
+
question: string;
|
|
444
|
+
sql: string;
|
|
445
|
+
rationale?: string;
|
|
446
|
+
fields: string[];
|
|
447
|
+
rows: Array<Record<string, unknown>>;
|
|
448
|
+
maxRetries?: number;
|
|
449
|
+
queryId?: string;
|
|
450
|
+
/**
|
|
451
|
+
* Optional encoding hints for visualization modification.
|
|
452
|
+
* When provided, these guide the LLM to generate specific visualization configurations.
|
|
453
|
+
*/
|
|
454
|
+
encodingHints?: EncodingHints;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Output from vizspec generator service
|
|
458
|
+
*/
|
|
459
|
+
interface VizSpecResult {
|
|
460
|
+
spec: VizSpec;
|
|
461
|
+
notes: string | null;
|
|
462
|
+
}
|
|
418
463
|
|
|
419
464
|
/**
|
|
420
465
|
* Context document returned by the query pipeline.
|
|
@@ -573,6 +618,8 @@ interface SqlModifications {
|
|
|
573
618
|
* These changes only affect how the chart is rendered.
|
|
574
619
|
*/
|
|
575
620
|
interface VizModifications {
|
|
621
|
+
/** Change the VizSpec kind (chart, table, metric). Applies to vizspec only. */
|
|
622
|
+
kind?: VizSpecKind;
|
|
576
623
|
/** Change the chart type (line, bar, area, scatter, pie) */
|
|
577
624
|
chartType?: ChartType;
|
|
578
625
|
/** Configure the X axis field and settings */
|
|
@@ -750,6 +797,11 @@ interface VizSpecGenerateInput {
|
|
|
750
797
|
rows: Array<Record<string, unknown>>;
|
|
751
798
|
max_retries?: number;
|
|
752
799
|
query_id?: string;
|
|
800
|
+
/**
|
|
801
|
+
* Optional encoding hints for visualization modification.
|
|
802
|
+
* When provided, these guide the LLM to generate specific visualization configurations.
|
|
803
|
+
*/
|
|
804
|
+
encoding_hints?: EncodingHints;
|
|
753
805
|
}
|
|
754
806
|
interface VizSpecGenerateOptions {
|
|
755
807
|
tenantId?: string;
|
|
@@ -1231,4 +1283,4 @@ declare class QueryPanelSdkAPI {
|
|
|
1231
1283
|
}, signal?: AbortSignal): Promise<void>;
|
|
1232
1284
|
}
|
|
1233
1285
|
|
|
1234
|
-
export { type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, 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 DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type FieldRef, type FieldRefInput, type FieldType, type IngestResponse, 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, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, QueryPipelineError, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, type SdkSession, type SdkSessionTurn, type SessionGetOptions, type SessionListOptions, type SessionUpdateInput, type SqlModifications, type StackingMode, type TableColumn, type TableEncoding, type TableSpec, type TimeUnit, type VizModifications, type VizSpec, type VizSpecGenerateInput, type VizSpecGenerateOptions, type VizSpecResponse, anonymizeResults };
|
|
1286
|
+
export { type ActiveChartCreateInput, type ActiveChartListOptions, type ActiveChartUpdateInput, type AggregateOp, type AskOptions, type AskResponse, type AxisField, type AxisFieldInput, 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 DatabaseAdapter, type DatabaseDialect, type DateRangeInput, type EncodingHints, type FieldRef, type FieldRefInput, type FieldType, type IngestResponse, 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, PostgresAdapter, type PostgresAdapterOptions, type PostgresClientFn, QueryErrorCode, QueryErrorCode as QueryErrorCodeType, QueryPanelSdkAPI, QueryPipelineError, type SchemaIntrospection, type SchemaSyncOptions, type SdkActiveChart, type SdkChart, 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
|
@@ -1430,6 +1430,9 @@ function buildModifiedQuestion(originalQuestion, modifications) {
|
|
|
1430
1430
|
}
|
|
1431
1431
|
function buildVizHints(modifications) {
|
|
1432
1432
|
const hints = {};
|
|
1433
|
+
if (modifications.kind) {
|
|
1434
|
+
hints.kind = modifications.kind;
|
|
1435
|
+
}
|
|
1433
1436
|
if (modifications.chartType) {
|
|
1434
1437
|
hints.chartType = modifications.chartType;
|
|
1435
1438
|
}
|
|
@@ -1450,6 +1453,13 @@ function buildVizHints(modifications) {
|
|
|
1450
1453
|
}
|
|
1451
1454
|
return hints;
|
|
1452
1455
|
}
|
|
1456
|
+
function stripVizSpecOnlyHints(hints) {
|
|
1457
|
+
if (!("kind" in hints)) {
|
|
1458
|
+
return hints;
|
|
1459
|
+
}
|
|
1460
|
+
const { kind: _kind, ...rest } = hints;
|
|
1461
|
+
return rest;
|
|
1462
|
+
}
|
|
1453
1463
|
function resolveTenantId5(client, tenantId) {
|
|
1454
1464
|
const resolved = tenantId ?? client.getDefaultTenantId();
|
|
1455
1465
|
if (!resolved) {
|
|
@@ -1533,6 +1543,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
1533
1543
|
};
|
|
1534
1544
|
if (rows.length > 0) {
|
|
1535
1545
|
const vizHints = hasVizMods ? buildVizHints(input.vizModifications) : {};
|
|
1546
|
+
const vizHintsForChart = chartType === "vizspec" ? vizHints : stripVizSpecOnlyHints(vizHints);
|
|
1536
1547
|
if (chartType === "vizspec") {
|
|
1537
1548
|
const vizspecResponse = await client.post(
|
|
1538
1549
|
"/vizspec",
|
|
@@ -1545,7 +1556,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
1545
1556
|
max_retries: options?.chartMaxRetries ?? 3,
|
|
1546
1557
|
query_id: queryId,
|
|
1547
1558
|
// Include viz hints for the chart generator
|
|
1548
|
-
...hasVizMods ? { encoding_hints:
|
|
1559
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
|
|
1549
1560
|
},
|
|
1550
1561
|
tenantId,
|
|
1551
1562
|
options?.userId,
|
|
@@ -1570,7 +1581,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
1570
1581
|
max_retries: options?.chartMaxRetries ?? 3,
|
|
1571
1582
|
query_id: queryId,
|
|
1572
1583
|
// Include viz hints for the chart generator
|
|
1573
|
-
...hasVizMods ? { encoding_hints:
|
|
1584
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
|
|
1574
1585
|
},
|
|
1575
1586
|
tenantId,
|
|
1576
1587
|
options?.userId,
|
|
@@ -1690,7 +1701,8 @@ async function generateVizSpec(client, input, options, signal) {
|
|
|
1690
1701
|
fields: input.fields,
|
|
1691
1702
|
rows: input.rows,
|
|
1692
1703
|
max_retries: options?.maxRetries ?? input.max_retries ?? 3,
|
|
1693
|
-
query_id: input.query_id
|
|
1704
|
+
query_id: input.query_id,
|
|
1705
|
+
encoding_hints: input.encoding_hints
|
|
1694
1706
|
},
|
|
1695
1707
|
tenantId,
|
|
1696
1708
|
options?.userId,
|