@querypanel/node-sdk 1.2.8 → 1.2.9
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 +108 -112
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +108 -112
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1907,60 +1907,58 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1907
1907
|
specType: chartType,
|
|
1908
1908
|
notes: rows.length === 0 ? "Query returned no rows." : null
|
|
1909
1909
|
};
|
|
1910
|
-
if (
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
chart
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
};
|
|
1963
|
-
}
|
|
1910
|
+
if (chartType === "vizspec") {
|
|
1911
|
+
const vizspecResponse = await client.post(
|
|
1912
|
+
"/vizspec",
|
|
1913
|
+
{
|
|
1914
|
+
question,
|
|
1915
|
+
sql,
|
|
1916
|
+
rationale: queryResponse.data.rationale,
|
|
1917
|
+
fields: execution.fields,
|
|
1918
|
+
rows: anonymizeResults(rows),
|
|
1919
|
+
max_retries: options.chartMaxRetries ?? 3,
|
|
1920
|
+
query_id: queryResponse.data.queryId,
|
|
1921
|
+
...options.supportedChartTypes?.length ? {
|
|
1922
|
+
supported_chart_types: options.supportedChartTypes
|
|
1923
|
+
} : {}
|
|
1924
|
+
},
|
|
1925
|
+
tenantId,
|
|
1926
|
+
options.userId,
|
|
1927
|
+
options.scopes,
|
|
1928
|
+
signal,
|
|
1929
|
+
sessionId
|
|
1930
|
+
);
|
|
1931
|
+
chart = {
|
|
1932
|
+
vizSpec: vizspecResponse.spec,
|
|
1933
|
+
specType: "vizspec",
|
|
1934
|
+
notes: rows.length === 0 ? vizspecResponse.notes ?? "Query returned no rows." : vizspecResponse.notes
|
|
1935
|
+
};
|
|
1936
|
+
} else {
|
|
1937
|
+
const chartResponse = await client.post(
|
|
1938
|
+
"/chart",
|
|
1939
|
+
{
|
|
1940
|
+
question,
|
|
1941
|
+
sql,
|
|
1942
|
+
rationale: queryResponse.data.rationale,
|
|
1943
|
+
fields: execution.fields,
|
|
1944
|
+
rows: anonymizeResults(rows),
|
|
1945
|
+
max_retries: options.chartMaxRetries ?? 3,
|
|
1946
|
+
query_id: queryResponse.data.queryId
|
|
1947
|
+
},
|
|
1948
|
+
tenantId,
|
|
1949
|
+
options.userId,
|
|
1950
|
+
options.scopes,
|
|
1951
|
+
signal,
|
|
1952
|
+
sessionId
|
|
1953
|
+
);
|
|
1954
|
+
chart = {
|
|
1955
|
+
vegaLiteSpec: chartResponse.chart ? {
|
|
1956
|
+
...chartResponse.chart,
|
|
1957
|
+
data: { values: rows }
|
|
1958
|
+
} : null,
|
|
1959
|
+
specType: "vega-lite",
|
|
1960
|
+
notes: rows.length === 0 ? chartResponse.notes ?? "Query returned no rows." : chartResponse.notes
|
|
1961
|
+
};
|
|
1964
1962
|
}
|
|
1965
1963
|
return {
|
|
1966
1964
|
sql,
|
|
@@ -2253,64 +2251,62 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
2253
2251
|
specType: chartType,
|
|
2254
2252
|
notes: rows.length === 0 ? "Query returned no rows." : null
|
|
2255
2253
|
};
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
chart
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
};
|
|
2313
|
-
}
|
|
2254
|
+
const vizHints = hasVizMods ? buildVizHints(input.vizModifications) : {};
|
|
2255
|
+
const vizHintsForChart = chartType === "vizspec" ? vizHints : stripVizSpecOnlyHints(vizHints);
|
|
2256
|
+
if (chartType === "vizspec") {
|
|
2257
|
+
const vizspecResponse = await client.post(
|
|
2258
|
+
"/vizspec",
|
|
2259
|
+
{
|
|
2260
|
+
question: finalQuestion,
|
|
2261
|
+
sql: finalSql,
|
|
2262
|
+
rationale,
|
|
2263
|
+
fields: execution.fields,
|
|
2264
|
+
rows: anonymizeResults(rows),
|
|
2265
|
+
max_retries: options?.chartMaxRetries ?? 3,
|
|
2266
|
+
query_id: queryId,
|
|
2267
|
+
// Include viz hints for the chart generator
|
|
2268
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {},
|
|
2269
|
+
...options?.supportedChartTypes?.length ? { supported_chart_types: options.supportedChartTypes } : {}
|
|
2270
|
+
},
|
|
2271
|
+
tenantId,
|
|
2272
|
+
options?.userId,
|
|
2273
|
+
options?.scopes,
|
|
2274
|
+
signal,
|
|
2275
|
+
sessionId
|
|
2276
|
+
);
|
|
2277
|
+
chart = {
|
|
2278
|
+
vizSpec: vizspecResponse.spec,
|
|
2279
|
+
specType: "vizspec",
|
|
2280
|
+
notes: rows.length === 0 ? vizspecResponse.notes ?? "Query returned no rows." : vizspecResponse.notes
|
|
2281
|
+
};
|
|
2282
|
+
} else {
|
|
2283
|
+
const chartResponse = await client.post(
|
|
2284
|
+
"/chart",
|
|
2285
|
+
{
|
|
2286
|
+
question: finalQuestion,
|
|
2287
|
+
sql: finalSql,
|
|
2288
|
+
rationale,
|
|
2289
|
+
fields: execution.fields,
|
|
2290
|
+
rows: anonymizeResults(rows),
|
|
2291
|
+
max_retries: options?.chartMaxRetries ?? 3,
|
|
2292
|
+
query_id: queryId,
|
|
2293
|
+
// Include viz hints for the chart generator
|
|
2294
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
|
|
2295
|
+
},
|
|
2296
|
+
tenantId,
|
|
2297
|
+
options?.userId,
|
|
2298
|
+
options?.scopes,
|
|
2299
|
+
signal,
|
|
2300
|
+
sessionId
|
|
2301
|
+
);
|
|
2302
|
+
chart = {
|
|
2303
|
+
vegaLiteSpec: chartResponse.chart ? {
|
|
2304
|
+
...chartResponse.chart,
|
|
2305
|
+
data: { values: rows }
|
|
2306
|
+
} : null,
|
|
2307
|
+
specType: "vega-lite",
|
|
2308
|
+
notes: rows.length === 0 ? chartResponse.notes ?? "Query returned no rows." : chartResponse.notes
|
|
2309
|
+
};
|
|
2314
2310
|
}
|
|
2315
2311
|
return {
|
|
2316
2312
|
sql: finalSql,
|