@querypanel/node-sdk 1.0.54 → 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,6 +1490,9 @@ function buildModifiedQuestion(originalQuestion, modifications, pipeline) {
1489
1490
  if (hints.length === 0) {
1490
1491
  return originalQuestion;
1491
1492
  }
1493
+ if (pipeline === "v2" && hasSessionContext) {
1494
+ return hints.join(", ");
1495
+ }
1492
1496
  return `${originalQuestion} (${hints.join(", ")})`;
1493
1497
  }
1494
1498
  var START_PARAM_KEY_REGEX = /(^|_)(start|from)(_|$)/i;
@@ -1597,6 +1601,7 @@ async function modifyChart(client, queryEngine, input, options, signal) {
1597
1601
  const tenantId = resolveTenantId5(client, options?.tenantId);
1598
1602
  const sessionId = import_node_crypto4.default.randomUUID();
1599
1603
  const querypanelSessionId = options?.querypanelSessionId ?? sessionId;
1604
+ const hasQuerypanelSessionContext = !!options?.querypanelSessionId;
1600
1605
  const chartType = options?.chartType ?? "vega-lite";
1601
1606
  const hasSqlMods = !!input.sqlModifications;
1602
1607
  const hasVizMods = !!input.vizModifications;
@@ -1633,7 +1638,8 @@ async function modifyChart(client, queryEngine, input, options, signal) {
1633
1638
  const modifiedQuestion = buildModifiedQuestion(
1634
1639
  input.question,
1635
1640
  input.sqlModifications,
1636
- options?.pipeline
1641
+ options?.pipeline,
1642
+ hasQuerypanelSessionContext
1637
1643
  );
1638
1644
  if (options?.pipeline === "v2") {
1639
1645
  finalQuestion = modifiedQuestion;