flowstack-sdk 0.2.2 → 0.2.3

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.mjs CHANGED
@@ -269,7 +269,25 @@ async function executeQueryWithConfig(credentials, query, workspaceId, options,
269
269
  })
270
270
  });
271
271
  if (!response.ok) {
272
- throw new Error(`Query failed: ${response.statusText}`);
272
+ let message = response.statusText || "request failed";
273
+ let code;
274
+ let body;
275
+ try {
276
+ body = await response.clone().json();
277
+ const payload = body && typeof body === "object" && "detail" in body && typeof body.detail === "object" ? body.detail : body;
278
+ if (payload && typeof payload === "object") {
279
+ code = payload.code;
280
+ message = payload.error || payload.message || payload.detail || message;
281
+ } else if (typeof payload === "string") {
282
+ message = payload;
283
+ }
284
+ } catch {
285
+ }
286
+ const err = new Error(`Query failed: ${message}`);
287
+ err.status = response.status;
288
+ err.code = code;
289
+ err.body = body;
290
+ throw err;
273
291
  }
274
292
  return response;
275
293
  }
@@ -7090,7 +7108,7 @@ function useAutomations() {
7090
7108
  return;
7091
7109
  }
7092
7110
  const data = await res.json();
7093
- setAutomations(data.automations ?? []);
7111
+ setAutomations(Array.isArray(data) ? data : data.automations ?? []);
7094
7112
  } catch (e) {
7095
7113
  setError(e.message || "Failed to load automations");
7096
7114
  } finally {
@@ -7189,7 +7207,7 @@ function useAutomations() {
7189
7207
  const res = await fetch(url, { headers: headers() });
7190
7208
  if (!res.ok) return [];
7191
7209
  const data = await res.json();
7192
- return data.runs ?? [];
7210
+ return Array.isArray(data) ? data : data.runs ?? [];
7193
7211
  } catch {
7194
7212
  return [];
7195
7213
  }
@@ -8735,7 +8753,11 @@ function MermaidDiagram({ code }) {
8735
8753
  let cancelled = false;
8736
8754
  async function render() {
8737
8755
  try {
8738
- const mermaid = (await import('mermaid')).default;
8756
+ const mermaidPkg = "mermaid";
8757
+ const mermaid = (await import(
8758
+ /* @vite-ignore */
8759
+ mermaidPkg
8760
+ )).default;
8739
8761
  if (!mermaidInitialized) {
8740
8762
  mermaid.initialize({
8741
8763
  startOnLoad: false,