@prismiq/react 0.2.0 → 0.2.1

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.
Files changed (39) hide show
  1. package/dist/{ChatBubble-ARocmvZD.d.cts → ChatBubble-3mFpV7yX.d.ts} +4 -2
  2. package/dist/{ChatBubble-BN_CjIpk.d.ts → ChatBubble-CMkEupzn.d.cts} +4 -2
  3. package/dist/{DashboardDialog-Z-HypxmG.d.cts → DashboardDialog-DMmZ3bnf.d.cts} +1 -1
  4. package/dist/{DashboardDialog-UhUGXx2h.d.ts → DashboardDialog-RlcPkdMt.d.ts} +1 -1
  5. package/dist/charts/index.d.cts +2 -2
  6. package/dist/charts/index.d.ts +2 -2
  7. package/dist/{chunk-JBJ5LEAG.js → chunk-F6QYNQEW.js} +12 -4
  8. package/dist/chunk-F6QYNQEW.js.map +1 -0
  9. package/dist/{chunk-FKXCINUF.cjs → chunk-N6I3QOHG.cjs} +201 -193
  10. package/dist/chunk-N6I3QOHG.cjs.map +1 -0
  11. package/dist/{chunk-PG7QBH3G.cjs → chunk-NXXKG4GN.cjs} +50 -15
  12. package/dist/chunk-NXXKG4GN.cjs.map +1 -0
  13. package/dist/{chunk-GELI7MDZ.js → chunk-VEFYFB5H.js} +50 -15
  14. package/dist/chunk-VEFYFB5H.js.map +1 -0
  15. package/dist/components/index.cjs +56 -56
  16. package/dist/components/index.d.cts +2 -2
  17. package/dist/components/index.d.ts +2 -2
  18. package/dist/components/index.js +1 -1
  19. package/dist/dashboard/index.cjs +34 -34
  20. package/dist/dashboard/index.d.cts +3 -3
  21. package/dist/dashboard/index.d.ts +3 -3
  22. package/dist/dashboard/index.js +2 -2
  23. package/dist/export/index.d.cts +1 -1
  24. package/dist/export/index.d.ts +1 -1
  25. package/dist/{index-B8DelfpL.d.cts → index-BA2VUhgN.d.cts} +1 -1
  26. package/dist/{index-RbfYPQD_.d.ts → index-BPo89ZAj.d.ts} +1 -1
  27. package/dist/index.cjs +100 -100
  28. package/dist/index.d.cts +11 -8
  29. package/dist/index.d.ts +11 -8
  30. package/dist/index.js +4 -4
  31. package/dist/{types-ccB9Ps3k.d.cts → types-BaI6sSAG.d.cts} +20 -2
  32. package/dist/{types-ccB9Ps3k.d.ts → types-BaI6sSAG.d.ts} +20 -2
  33. package/dist/utils/index.d.cts +1 -1
  34. package/dist/utils/index.d.ts +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-FKXCINUF.cjs.map +0 -1
  37. package/dist/chunk-GELI7MDZ.js.map +0 -1
  38. package/dist/chunk-JBJ5LEAG.js.map +0 -1
  39. package/dist/chunk-PG7QBH3G.cjs.map +0 -1
@@ -2861,9 +2861,10 @@ var PrismiqClient = class {
2861
2861
  * @param history - Previous conversation messages.
2862
2862
  * @param currentSql - Current SQL in the editor (for context).
2863
2863
  * @param signal - Optional AbortSignal for cancellation.
2864
+ * @param widgetContext - Optional widget context for targeted SQL generation.
2864
2865
  * @yields StreamChunk objects as the response is generated.
2865
2866
  */
2866
- async *streamChat(message, history, currentSql, signal) {
2867
+ async *streamChat(message, history, currentSql, signal, widgetContext) {
2867
2868
  const url = `${this.endpoint}/llm/chat`;
2868
2869
  const headers = {
2869
2870
  "Content-Type": "application/json",
@@ -2876,14 +2877,18 @@ var PrismiqClient = class {
2876
2877
  const token = await this.getToken();
2877
2878
  headers["Authorization"] = `Bearer ${token}`;
2878
2879
  }
2880
+ const body = {
2881
+ message,
2882
+ history,
2883
+ current_sql: currentSql
2884
+ };
2885
+ if (widgetContext) {
2886
+ body.widget_context = widgetContext;
2887
+ }
2879
2888
  const response = await fetch(url, {
2880
2889
  method: "POST",
2881
2890
  headers,
2882
- body: JSON.stringify({
2883
- message,
2884
- history,
2885
- current_sql: currentSql
2886
- }),
2891
+ body: JSON.stringify(body),
2887
2892
  signal
2888
2893
  });
2889
2894
  if (!response.ok) {
@@ -4022,12 +4027,13 @@ function useLLMChat() {
4022
4027
  const [streamingContent, setStreamingContent] = react.useState("");
4023
4028
  const [suggestedSql, setSuggestedSql] = react.useState(null);
4024
4029
  const [error, setError] = react.useState(null);
4030
+ const [statusMessage, setStatusMessage] = react.useState(null);
4025
4031
  const abortRef = react.useRef(null);
4026
4032
  const isStreamingRef = react.useRef(false);
4027
4033
  const messagesRef = react.useRef([]);
4028
4034
  messagesRef.current = messages;
4029
4035
  const sendMessage = react.useCallback(
4030
- async (message, currentSql) => {
4036
+ async (message, currentSql, widgetContext) => {
4031
4037
  if (!client || isStreamingRef.current) return;
4032
4038
  abortRef.current?.abort();
4033
4039
  const controller = new AbortController();
@@ -4039,6 +4045,7 @@ function useLLMChat() {
4039
4045
  setStreamingContent("");
4040
4046
  setSuggestedSql(null);
4041
4047
  setError(null);
4048
+ setStatusMessage(null);
4042
4049
  let accumulatedText = "";
4043
4050
  let lastSql = null;
4044
4051
  try {
@@ -4050,22 +4057,28 @@ function useLLMChat() {
4050
4057
  message,
4051
4058
  history,
4052
4059
  currentSql,
4053
- controller.signal
4060
+ controller.signal,
4061
+ widgetContext
4054
4062
  )) {
4055
4063
  if (controller.signal.aborted) break;
4056
4064
  switch (chunk.type) {
4057
4065
  case "text":
4058
4066
  accumulatedText += chunk.content ?? "";
4059
4067
  setStreamingContent(accumulatedText);
4068
+ setStatusMessage(null);
4060
4069
  break;
4061
4070
  case "sql":
4062
4071
  lastSql = chunk.content ?? null;
4063
4072
  setSuggestedSql(lastSql);
4064
4073
  break;
4074
+ case "status":
4075
+ setStatusMessage(chunk.content ?? null);
4076
+ break;
4065
4077
  case "error":
4066
4078
  setError(chunk.content ?? "Unknown error");
4067
4079
  break;
4068
4080
  case "done":
4081
+ setStatusMessage(null);
4069
4082
  break;
4070
4083
  }
4071
4084
  }
@@ -4076,6 +4089,7 @@ function useLLMChat() {
4076
4089
  } finally {
4077
4090
  isStreamingRef.current = false;
4078
4091
  setIsStreaming(false);
4092
+ setStatusMessage(null);
4079
4093
  if (accumulatedText) {
4080
4094
  const assistantMsg = {
4081
4095
  role: "assistant",
@@ -4100,6 +4114,7 @@ function useLLMChat() {
4100
4114
  setSuggestedSql(null);
4101
4115
  setError(null);
4102
4116
  setIsStreaming(false);
4117
+ setStatusMessage(null);
4103
4118
  }, []);
4104
4119
  return {
4105
4120
  messages,
@@ -4108,7 +4123,8 @@ function useLLMChat() {
4108
4123
  suggestedSql,
4109
4124
  sendMessage,
4110
4125
  clearHistory,
4111
- error
4126
+ error,
4127
+ statusMessage
4112
4128
  };
4113
4129
  }
4114
4130
  var nodeStyles = {
@@ -9459,7 +9475,7 @@ function ChatBubble({ message, onApplySql }) {
9459
9475
  return /* @__PURE__ */ jsxRuntime.jsx("span", { children: part.value }, i);
9460
9476
  }) });
9461
9477
  }
9462
- function ChatPanel({ currentSql, onApplySql }) {
9478
+ function ChatPanel({ currentSql, onApplySql, widgetContext }) {
9463
9479
  const { theme } = chunkLMTG3LRC_cjs.useTheme();
9464
9480
  const {
9465
9481
  messages,
@@ -9468,7 +9484,8 @@ function ChatPanel({ currentSql, onApplySql }) {
9468
9484
  suggestedSql,
9469
9485
  sendMessage,
9470
9486
  clearHistory,
9471
- error
9487
+ error,
9488
+ statusMessage
9472
9489
  } = useLLMChat();
9473
9490
  const [input, setInput] = react.useState("");
9474
9491
  const messagesEndRef = react.useRef(null);
@@ -9479,8 +9496,8 @@ function ChatPanel({ currentSql, onApplySql }) {
9479
9496
  const trimmed = input.trim();
9480
9497
  if (!trimmed) return;
9481
9498
  setInput("");
9482
- void sendMessage(trimmed, currentSql);
9483
- }, [input, currentSql, sendMessage]);
9499
+ void sendMessage(trimmed, currentSql, widgetContext);
9500
+ }, [input, currentSql, widgetContext, sendMessage]);
9484
9501
  const handleKeyDown = react.useCallback(
9485
9502
  (e) => {
9486
9503
  if (e.key === "Enter" && !e.shiftKey) {
@@ -9601,6 +9618,24 @@ function ChatPanel({ currentSql, onApplySql }) {
9601
9618
  "\u258D"
9602
9619
  ] }),
9603
9620
  isStreaming && !streamingContent && /* @__PURE__ */ jsxRuntime.jsx("div", { style: streamingStyle, "data-testid": "chat-streaming", children: "Thinking..." }),
9621
+ isStreaming && statusMessage && /* @__PURE__ */ jsxRuntime.jsxs(
9622
+ "div",
9623
+ {
9624
+ style: {
9625
+ display: "flex",
9626
+ alignItems: "center",
9627
+ gap: theme.spacing.xs,
9628
+ fontSize: theme.fontSizes.xs,
9629
+ color: theme.colors.textMuted,
9630
+ padding: `${theme.spacing.xs} 0`
9631
+ },
9632
+ "data-testid": "chat-status",
9633
+ children: [
9634
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { name: "sync", size: 12 }),
9635
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: statusMessage })
9636
+ ]
9637
+ }
9638
+ ),
9604
9639
  /* @__PURE__ */ jsxRuntime.jsx("div", { ref: messagesEndRef })
9605
9640
  ] }),
9606
9641
  error && /* @__PURE__ */ jsxRuntime.jsx("div", { style: errorStyle, "data-testid": "chat-error", children: error }),
@@ -9712,5 +9747,5 @@ exports.usePinnedDashboards = usePinnedDashboards;
9712
9747
  exports.useQuery = useQuery;
9713
9748
  exports.useSavedQueries = useSavedQueries;
9714
9749
  exports.useSchema = useSchema;
9715
- //# sourceMappingURL=chunk-PG7QBH3G.cjs.map
9716
- //# sourceMappingURL=chunk-PG7QBH3G.cjs.map
9750
+ //# sourceMappingURL=chunk-NXXKG4GN.cjs.map
9751
+ //# sourceMappingURL=chunk-NXXKG4GN.cjs.map