@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.js
CHANGED
|
@@ -1863,60 +1863,58 @@ async function ask(client, queryEngine, question, options, signal) {
|
|
|
1863
1863
|
specType: chartType,
|
|
1864
1864
|
notes: rows.length === 0 ? "Query returned no rows." : null
|
|
1865
1865
|
};
|
|
1866
|
-
if (
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
chart
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
};
|
|
1919
|
-
}
|
|
1866
|
+
if (chartType === "vizspec") {
|
|
1867
|
+
const vizspecResponse = await client.post(
|
|
1868
|
+
"/vizspec",
|
|
1869
|
+
{
|
|
1870
|
+
question,
|
|
1871
|
+
sql,
|
|
1872
|
+
rationale: queryResponse.data.rationale,
|
|
1873
|
+
fields: execution.fields,
|
|
1874
|
+
rows: anonymizeResults(rows),
|
|
1875
|
+
max_retries: options.chartMaxRetries ?? 3,
|
|
1876
|
+
query_id: queryResponse.data.queryId,
|
|
1877
|
+
...options.supportedChartTypes?.length ? {
|
|
1878
|
+
supported_chart_types: options.supportedChartTypes
|
|
1879
|
+
} : {}
|
|
1880
|
+
},
|
|
1881
|
+
tenantId,
|
|
1882
|
+
options.userId,
|
|
1883
|
+
options.scopes,
|
|
1884
|
+
signal,
|
|
1885
|
+
sessionId
|
|
1886
|
+
);
|
|
1887
|
+
chart = {
|
|
1888
|
+
vizSpec: vizspecResponse.spec,
|
|
1889
|
+
specType: "vizspec",
|
|
1890
|
+
notes: rows.length === 0 ? vizspecResponse.notes ?? "Query returned no rows." : vizspecResponse.notes
|
|
1891
|
+
};
|
|
1892
|
+
} else {
|
|
1893
|
+
const chartResponse = await client.post(
|
|
1894
|
+
"/chart",
|
|
1895
|
+
{
|
|
1896
|
+
question,
|
|
1897
|
+
sql,
|
|
1898
|
+
rationale: queryResponse.data.rationale,
|
|
1899
|
+
fields: execution.fields,
|
|
1900
|
+
rows: anonymizeResults(rows),
|
|
1901
|
+
max_retries: options.chartMaxRetries ?? 3,
|
|
1902
|
+
query_id: queryResponse.data.queryId
|
|
1903
|
+
},
|
|
1904
|
+
tenantId,
|
|
1905
|
+
options.userId,
|
|
1906
|
+
options.scopes,
|
|
1907
|
+
signal,
|
|
1908
|
+
sessionId
|
|
1909
|
+
);
|
|
1910
|
+
chart = {
|
|
1911
|
+
vegaLiteSpec: chartResponse.chart ? {
|
|
1912
|
+
...chartResponse.chart,
|
|
1913
|
+
data: { values: rows }
|
|
1914
|
+
} : null,
|
|
1915
|
+
specType: "vega-lite",
|
|
1916
|
+
notes: rows.length === 0 ? chartResponse.notes ?? "Query returned no rows." : chartResponse.notes
|
|
1917
|
+
};
|
|
1920
1918
|
}
|
|
1921
1919
|
return {
|
|
1922
1920
|
sql,
|
|
@@ -2209,64 +2207,62 @@ async function modifyChart(client, queryEngine, input, options, signal) {
|
|
|
2209
2207
|
specType: chartType,
|
|
2210
2208
|
notes: rows.length === 0 ? "Query returned no rows." : null
|
|
2211
2209
|
};
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
chart
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
};
|
|
2269
|
-
}
|
|
2210
|
+
const vizHints = hasVizMods ? buildVizHints(input.vizModifications) : {};
|
|
2211
|
+
const vizHintsForChart = chartType === "vizspec" ? vizHints : stripVizSpecOnlyHints(vizHints);
|
|
2212
|
+
if (chartType === "vizspec") {
|
|
2213
|
+
const vizspecResponse = await client.post(
|
|
2214
|
+
"/vizspec",
|
|
2215
|
+
{
|
|
2216
|
+
question: finalQuestion,
|
|
2217
|
+
sql: finalSql,
|
|
2218
|
+
rationale,
|
|
2219
|
+
fields: execution.fields,
|
|
2220
|
+
rows: anonymizeResults(rows),
|
|
2221
|
+
max_retries: options?.chartMaxRetries ?? 3,
|
|
2222
|
+
query_id: queryId,
|
|
2223
|
+
// Include viz hints for the chart generator
|
|
2224
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {},
|
|
2225
|
+
...options?.supportedChartTypes?.length ? { supported_chart_types: options.supportedChartTypes } : {}
|
|
2226
|
+
},
|
|
2227
|
+
tenantId,
|
|
2228
|
+
options?.userId,
|
|
2229
|
+
options?.scopes,
|
|
2230
|
+
signal,
|
|
2231
|
+
sessionId
|
|
2232
|
+
);
|
|
2233
|
+
chart = {
|
|
2234
|
+
vizSpec: vizspecResponse.spec,
|
|
2235
|
+
specType: "vizspec",
|
|
2236
|
+
notes: rows.length === 0 ? vizspecResponse.notes ?? "Query returned no rows." : vizspecResponse.notes
|
|
2237
|
+
};
|
|
2238
|
+
} else {
|
|
2239
|
+
const chartResponse = await client.post(
|
|
2240
|
+
"/chart",
|
|
2241
|
+
{
|
|
2242
|
+
question: finalQuestion,
|
|
2243
|
+
sql: finalSql,
|
|
2244
|
+
rationale,
|
|
2245
|
+
fields: execution.fields,
|
|
2246
|
+
rows: anonymizeResults(rows),
|
|
2247
|
+
max_retries: options?.chartMaxRetries ?? 3,
|
|
2248
|
+
query_id: queryId,
|
|
2249
|
+
// Include viz hints for the chart generator
|
|
2250
|
+
...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
|
|
2251
|
+
},
|
|
2252
|
+
tenantId,
|
|
2253
|
+
options?.userId,
|
|
2254
|
+
options?.scopes,
|
|
2255
|
+
signal,
|
|
2256
|
+
sessionId
|
|
2257
|
+
);
|
|
2258
|
+
chart = {
|
|
2259
|
+
vegaLiteSpec: chartResponse.chart ? {
|
|
2260
|
+
...chartResponse.chart,
|
|
2261
|
+
data: { values: rows }
|
|
2262
|
+
} : null,
|
|
2263
|
+
specType: "vega-lite",
|
|
2264
|
+
notes: rows.length === 0 ? chartResponse.notes ?? "Query returned no rows." : chartResponse.notes
|
|
2265
|
+
};
|
|
2270
2266
|
}
|
|
2271
2267
|
return {
|
|
2272
2268
|
sql: finalSql,
|