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