@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 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 (rows.length > 0) {
1911
- if (chartType === "vizspec") {
1912
- const vizspecResponse = await client.post(
1913
- "/vizspec",
1914
- {
1915
- question,
1916
- sql,
1917
- rationale: queryResponse.data.rationale,
1918
- fields: execution.fields,
1919
- rows: anonymizeResults(rows),
1920
- max_retries: options.chartMaxRetries ?? 3,
1921
- query_id: queryResponse.data.queryId,
1922
- ...options.supportedChartTypes?.length ? {
1923
- supported_chart_types: options.supportedChartTypes
1924
- } : {}
1925
- },
1926
- tenantId,
1927
- options.userId,
1928
- options.scopes,
1929
- signal,
1930
- sessionId
1931
- );
1932
- chart = {
1933
- vizSpec: vizspecResponse.spec,
1934
- specType: "vizspec",
1935
- notes: vizspecResponse.notes
1936
- };
1937
- } else {
1938
- const chartResponse = await client.post(
1939
- "/chart",
1940
- {
1941
- question,
1942
- sql,
1943
- rationale: queryResponse.data.rationale,
1944
- fields: execution.fields,
1945
- rows: anonymizeResults(rows),
1946
- max_retries: options.chartMaxRetries ?? 3,
1947
- query_id: queryResponse.data.queryId
1948
- },
1949
- tenantId,
1950
- options.userId,
1951
- options.scopes,
1952
- signal,
1953
- sessionId
1954
- );
1955
- chart = {
1956
- vegaLiteSpec: chartResponse.chart ? {
1957
- ...chartResponse.chart,
1958
- data: { values: rows }
1959
- } : null,
1960
- specType: "vega-lite",
1961
- notes: chartResponse.notes
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
- if (rows.length > 0) {
2257
- const vizHints = hasVizMods ? buildVizHints(input.vizModifications) : {};
2258
- const vizHintsForChart = chartType === "vizspec" ? vizHints : stripVizSpecOnlyHints(vizHints);
2259
- if (chartType === "vizspec") {
2260
- const vizspecResponse = await client.post(
2261
- "/vizspec",
2262
- {
2263
- question: finalQuestion,
2264
- sql: finalSql,
2265
- rationale,
2266
- fields: execution.fields,
2267
- rows: anonymizeResults(rows),
2268
- max_retries: options?.chartMaxRetries ?? 3,
2269
- query_id: queryId,
2270
- // Include viz hints for the chart generator
2271
- ...hasVizMods ? { encoding_hints: vizHintsForChart } : {},
2272
- ...options?.supportedChartTypes?.length ? { supported_chart_types: options.supportedChartTypes } : {}
2273
- },
2274
- tenantId,
2275
- options?.userId,
2276
- options?.scopes,
2277
- signal,
2278
- sessionId
2279
- );
2280
- chart = {
2281
- vizSpec: vizspecResponse.spec,
2282
- specType: "vizspec",
2283
- notes: vizspecResponse.notes
2284
- };
2285
- } else {
2286
- const chartResponse = await client.post(
2287
- "/chart",
2288
- {
2289
- question: finalQuestion,
2290
- sql: finalSql,
2291
- rationale,
2292
- fields: execution.fields,
2293
- rows: anonymizeResults(rows),
2294
- max_retries: options?.chartMaxRetries ?? 3,
2295
- query_id: queryId,
2296
- // Include viz hints for the chart generator
2297
- ...hasVizMods ? { encoding_hints: vizHintsForChart } : {}
2298
- },
2299
- tenantId,
2300
- options?.userId,
2301
- options?.scopes,
2302
- signal,
2303
- sessionId
2304
- );
2305
- chart = {
2306
- vegaLiteSpec: chartResponse.chart ? {
2307
- ...chartResponse.chart,
2308
- data: { values: rows }
2309
- } : null,
2310
- specType: "vega-lite",
2311
- notes: chartResponse.notes
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,