@querypanel/node-sdk 1.0.55 → 1.0.56

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/README.md CHANGED
@@ -212,7 +212,10 @@ const monthly = await qp.modifyChart({
212
212
  timeGranularity: "month",
213
213
  dateRange: { from: "2024-01-01", to: "2024-12-31" },
214
214
  },
215
- }, { tenantId: "tenant_123" });
215
+ }, {
216
+ tenantId: "tenant_123",
217
+ querypanelSessionId: response.querypanelSessionId, // preserve follow-up context
218
+ });
216
219
 
217
220
  console.log(monthly.sql); // New SQL with monthly GROUP BY
218
221
  console.log(monthly.modified.sqlChanged); // true
@@ -275,6 +278,11 @@ const combined = await qp.modifyChart({
275
278
 
276
279
  Load a saved chart and modify it:
277
280
 
281
+ If you do not have a previous `querypanelSessionId` (common for persisted charts),
282
+ the SDK starts a new QueryPanel session and sends the full original question with
283
+ your modification hints. If you have one from an earlier `ask()` call, pass it to
284
+ keep follow-up context.
285
+
278
286
  ```ts
279
287
  // Load a saved chart
280
288
  const savedChart = await qp.getChart("chart_id_123", {
package/dist/index.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1454,7 +1455,7 @@ function anonymizeResults(rows) {
1454
1455
  }
1455
1456
 
1456
1457
  // src/routes/modify.ts
1457
- function buildModifiedQuestion(originalQuestion, modifications, pipeline) {
1458
+ function buildModifiedQuestion(originalQuestion, modifications, pipeline, hasSessionContext = false) {
1458
1459
  const hints = [];
1459
1460
  if (modifications.timeGranularity) {
1460
1461
  hints.push(`group results by ${modifications.timeGranularity}`);
@@ -1489,7 +1490,7 @@ function buildModifiedQuestion(originalQuestion, modifications, pipeline) {
1489
1490
  if (hints.length === 0) {
1490
1491
  return originalQuestion;
1491
1492
  }
1492
- if (pipeline === "v2") {
1493
+ if (pipeline === "v2" && hasSessionContext) {
1493
1494
  return hints.join(", ");
1494
1495
  }
1495
1496
  return `${originalQuestion} (${hints.join(", ")})`;
@@ -1600,6 +1601,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
1600
1601
  const tenantId = resolveTenantId5(client, options?.tenantId);
1601
1602
  const sessionId = import_node_crypto4.default.randomUUID();
1602
1603
  const querypanelSessionId = options?.querypanelSessionId ?? sessionId;
1604
+ const hasQuerypanelSessionContext = !!options?.querypanelSessionId;
1603
1605
  const chartType = options?.chartType ?? "vega-lite";
1604
1606
  const hasSqlMods = !!input.sqlModifications;
1605
1607
  const hasVizMods = !!input.vizModifications;
@@ -1636,7 +1638,8 @@ async function modifyChart(client, queryEngine, input, options, signal) {
1636
1638
  const modifiedQuestion = buildModifiedQuestion(
1637
1639
  input.question,
1638
1640
  input.sqlModifications,
1639
- options?.pipeline
1641
+ options?.pipeline,
1642
+ hasQuerypanelSessionContext
1640
1643
  );
1641
1644
  if (options?.pipeline === "v2") {
1642
1645
  finalQuestion = modifiedQuestion;