@querypanel/node-sdk 1.2.7 → 1.2.8

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.d.cts CHANGED
@@ -737,6 +737,11 @@ interface AskOptions {
737
737
  * Sent to `POST /vizspec` as `supported_chart_types`. Omitted allows all standard types.
738
738
  */
739
739
  supportedChartTypes?: ChartType[];
740
+ /**
741
+ * When true, rationale includes engineer-style schema detail (tables, columns).
742
+ * When false (default), rationale is client-safe for end users.
743
+ */
744
+ debug?: boolean;
740
745
  }
741
746
  /**
742
747
  * Intent analysis result from the v2 pipeline.
@@ -961,6 +966,11 @@ interface ChartModifyOptions {
961
966
  * Restrict VizSpec chart types for this call (merged with SDK default from constructor when omitted).
962
967
  */
963
968
  supportedChartTypes?: ChartType[];
969
+ /**
970
+ * When true, rationale includes engineer-style schema detail (tables, columns).
971
+ * When false (default), rationale is client-safe for end users.
972
+ */
973
+ debug?: boolean;
964
974
  }
965
975
  /**
966
976
  * Response from modifyChart(), extending AskResponse with modification metadata.
@@ -1233,7 +1243,7 @@ declare class QueryPanelSdkAPI {
1233
1243
  * It handles the complete flow: SQL generation → validation → execution → chart generation.
1234
1244
  *
1235
1245
  * @param question - Natural language question (e.g., "Show revenue by country")
1236
- * @param options - Query options including tenantId, database, and retry settings
1246
+ * @param options - Query options including tenantId, database, retry settings, and optional `debug` for engineer-style rationale
1237
1247
  * @param signal - Optional AbortSignal for cancellation
1238
1248
  * @returns Response with SQL, executed data rows, and generated chart
1239
1249
  * @throws {Error} When SQL generation or execution fails after all retries
package/dist/index.d.ts CHANGED
@@ -737,6 +737,11 @@ interface AskOptions {
737
737
  * Sent to `POST /vizspec` as `supported_chart_types`. Omitted allows all standard types.
738
738
  */
739
739
  supportedChartTypes?: ChartType[];
740
+ /**
741
+ * When true, rationale includes engineer-style schema detail (tables, columns).
742
+ * When false (default), rationale is client-safe for end users.
743
+ */
744
+ debug?: boolean;
740
745
  }
741
746
  /**
742
747
  * Intent analysis result from the v2 pipeline.
@@ -961,6 +966,11 @@ interface ChartModifyOptions {
961
966
  * Restrict VizSpec chart types for this call (merged with SDK default from constructor when omitted).
962
967
  */
963
968
  supportedChartTypes?: ChartType[];
969
+ /**
970
+ * When true, rationale includes engineer-style schema detail (tables, columns).
971
+ * When false (default), rationale is client-safe for end users.
972
+ */
973
+ debug?: boolean;
964
974
  }
965
975
  /**
966
976
  * Response from modifyChart(), extending AskResponse with modification metadata.
@@ -1233,7 +1243,7 @@ declare class QueryPanelSdkAPI {
1233
1243
  * It handles the complete flow: SQL generation → validation → execution → chart generation.
1234
1244
  *
1235
1245
  * @param question - Natural language question (e.g., "Show revenue by country")
1236
- * @param options - Query options including tenantId, database, and retry settings
1246
+ * @param options - Query options including tenantId, database, retry settings, and optional `debug` for engineer-style rationale
1237
1247
  * @param signal - Optional AbortSignal for cancellation
1238
1248
  * @returns Response with SQL, executed data rows, and generated chart
1239
1249
  * @throws {Error} When SQL generation or execution fails after all retries
package/dist/index.js CHANGED
@@ -1798,7 +1798,6 @@ async function ask(client, queryEngine, question, options, signal) {
1798
1798
  let previousSql = options.previousSql;
1799
1799
  const queryEndpoint = options.pipeline === "v2" ? "/v2/query" : "/query";
1800
1800
  while (attempt <= maxRetry) {
1801
- console.log({ lastError, previousSql });
1802
1801
  const databaseName = options.database ?? queryEngine.getDefaultDatabase();
1803
1802
  const metadata = databaseName ? queryEngine.getDatabaseMetadata(databaseName) : void 0;
1804
1803
  let tenantSettings;
@@ -1821,7 +1820,8 @@ async function ask(client, queryEngine, question, options, signal) {
1821
1820
  ...databaseName ? { database: databaseName } : {},
1822
1821
  ...metadata?.dialect ? { dialect: metadata.dialect } : {},
1823
1822
  ...options.model?.trim() ? { model: options.model.trim() } : {},
1824
- ...options.pipeline === "v2" && options.systemPrompt?.trim() ? { system_prompt: options.systemPrompt.trim() } : {}
1823
+ ...options.pipeline === "v2" && options.systemPrompt?.trim() ? { system_prompt: options.systemPrompt.trim() } : {},
1824
+ debug: options.debug ?? false
1825
1825
  },
1826
1826
  tenantId,
1827
1827
  options.userId,
@@ -1942,9 +1942,14 @@ async function ask(client, queryEngine, question, options, signal) {
1942
1942
  }
1943
1943
  lastError = error instanceof Error ? error.message : String(error);
1944
1944
  previousSql = queryResponse.data.sql ?? previousSql;
1945
- console.warn(
1946
- `SQL execution failed (attempt ${attempt}/${maxRetry + 1}): ${lastError}. Retrying...`
1947
- );
1945
+ console.warn("SQL execution failed, retrying query generation", {
1946
+ attempt,
1947
+ maxAttempts: maxRetry + 1,
1948
+ error: lastError,
1949
+ sql: queryResponse.data.sql ?? null,
1950
+ paramMetadata,
1951
+ params: paramValues
1952
+ });
1948
1953
  }
1949
1954
  }
1950
1955
  throw new Error("Unexpected error in ask retry loop");
@@ -2170,7 +2175,8 @@ async function modifyChart(client, queryEngine, input, options, signal) {
2170
2175
  ...options?.maxRetry ? { max_retry: options.maxRetry } : {},
2171
2176
  ...tenantSettings ? { tenant_settings: tenantSettings } : {},
2172
2177
  ...databaseName ? { database: databaseName } : {},
2173
- ...metadata?.dialect ? { dialect: metadata.dialect } : {}
2178
+ ...metadata?.dialect ? { dialect: metadata.dialect } : {},
2179
+ debug: options?.debug ?? false
2174
2180
  },
2175
2181
  tenantId,
2176
2182
  options?.userId,
@@ -2551,7 +2557,7 @@ var QueryPanelSdkAPI = class _QueryPanelSdkAPI {
2551
2557
  * It handles the complete flow: SQL generation → validation → execution → chart generation.
2552
2558
  *
2553
2559
  * @param question - Natural language question (e.g., "Show revenue by country")
2554
- * @param options - Query options including tenantId, database, and retry settings
2560
+ * @param options - Query options including tenantId, database, retry settings, and optional `debug` for engineer-style rationale
2555
2561
  * @param signal - Optional AbortSignal for cancellation
2556
2562
  * @returns Response with SQL, executed data rows, and generated chart
2557
2563
  * @throws {Error} When SQL generation or execution fails after all retries