@querypanel/node-sdk 1.0.48 → 1.0.49
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 +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -368,6 +368,7 @@ interface VizSpecBase {
|
|
|
368
368
|
sourceId: string;
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
+
type VizSpecKind = VizSpecBase["kind"];
|
|
371
372
|
type ChartType = 'line' | 'bar' | 'area' | 'scatter' | 'pie';
|
|
372
373
|
type StackingMode = 'none' | 'stacked' | 'percent';
|
|
373
374
|
interface ChartEncoding {
|
|
@@ -573,6 +574,8 @@ interface SqlModifications {
|
|
|
573
574
|
* These changes only affect how the chart is rendered.
|
|
574
575
|
*/
|
|
575
576
|
interface VizModifications {
|
|
577
|
+
/** Change the VizSpec kind (chart, table, metric). Applies to vizspec only. */
|
|
578
|
+
kind?: VizSpecKind;
|
|
576
579
|
/** Change the chart type (line, bar, area, scatter, pie) */
|
|
577
580
|
chartType?: ChartType;
|
|
578
581
|
/** Configure the X axis field and settings */
|
package/dist/index.d.ts
CHANGED
|
@@ -368,6 +368,7 @@ interface VizSpecBase {
|
|
|
368
368
|
sourceId: string;
|
|
369
369
|
};
|
|
370
370
|
}
|
|
371
|
+
type VizSpecKind = VizSpecBase["kind"];
|
|
371
372
|
type ChartType = 'line' | 'bar' | 'area' | 'scatter' | 'pie';
|
|
372
373
|
type StackingMode = 'none' | 'stacked' | 'percent';
|
|
373
374
|
interface ChartEncoding {
|
|
@@ -573,6 +574,8 @@ interface SqlModifications {
|
|
|
573
574
|
* These changes only affect how the chart is rendered.
|
|
574
575
|
*/
|
|
575
576
|
interface VizModifications {
|
|
577
|
+
/** Change the VizSpec kind (chart, table, metric). Applies to vizspec only. */
|
|
578
|
+
kind?: VizSpecKind;
|
|
576
579
|
/** Change the chart type (line, bar, area, scatter, pie) */
|
|
577
580
|
chartType?: ChartType;
|
|
578
581
|
/** Configure the X axis field and settings */
|
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,
|