@malloydata/malloyyo 0.2.48 → 0.2.50

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.
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Dashboard query text → what the server should compile.
3
+ *
4
+ * The three shapes a dashboard may write are the three the MCP `query` tool
5
+ * accepts, and the same text should work in both places:
6
+ *
7
+ * "flights -> by_carrier" a run-expression
8
+ * "run: flights -> by_carrier" a run statement
9
+ * "source: x is flights extend {…}\nrun: x -> …" a document
10
+ *
11
+ * Only the first needs `run:` put in front of it. Prefixing a document made
12
+ * `run: source: …` — a syntax error that surfaced when the page ran rather
13
+ * than when the query was written. Text that carries a statement of its own
14
+ * goes through untouched, so the compiler's own message comes back (a
15
+ * document with nothing to run included).
16
+ *
17
+ * The keywords are matched as WHOLE statements — `run`, `source` and `query`
18
+ * only when a colon follows, `import` only at a word end. Matching the bare
19
+ * prefix instead meant a model with a source named `runs` or `sources` wrote
20
+ * `runs -> { … }`, that read as a statement, no `run:` was added, and the tile
21
+ * failed at view time (which nothing caught at save: inlineQueries looks for a
22
+ * real `run:`).
23
+ *
24
+ * Its own module, free of browser imports, so it can be tested directly.
25
+ */
26
+ const STATEMENT_RE = /(^|\n)[ \t]*(?:(?:run|source|query)[ \t]*:|import\b|##!)/;
27
+
28
+ export const asRunText = (text: string): string => (STATEMENT_RE.test(text) ? text : `run: ${text}`);
@@ -112,8 +112,11 @@ export function runQuery(req, givens) {
112
112
  }));
113
113
  }
114
114
 
115
- // Panel/data query text may come with or without a leading `run:`.
116
- export const asRunText = (text) => (/^\s*run\s*:/.test(text) ? text : `run: ${text}`);
115
+ // Query text → what the server compiles; see ./run-text. IMPORTED, not just
116
+ // re-exported: this module calls it, and `export { x } from "…"` would carry
117
+ // the name to consumers while leaving it undefined in here.
118
+ import { asRunText } from "./run-text";
119
+ export { asRunText };
117
120
 
118
121
  /** Run restricted Malloy text, resolve to the result rows (array of objects). */
119
122
  export function runData(malloy, givens) {
@@ -231,7 +234,12 @@ export function useQuery(req) {
231
234
  runQuery(wire, givens).then((m) => {
232
235
  if (cancelled) return;
233
236
  if (m.ok) setState({ rows: m.rows, result: m.result, loading: false });
234
- else setState({ rows: [], loading: false, error: m.error });
237
+ else {
238
+ // A component that ignores `error` would otherwise render an empty
239
+ // chart with nothing anywhere saying why.
240
+ console.error("dashboard query failed:", m.error, wire);
241
+ setState({ rows: [], loading: false, error: m.error });
242
+ }
235
243
  });
236
244
  return () => {
237
245
  cancelled = true;
package/dist/index.js CHANGED
@@ -2902,7 +2902,7 @@ function clearCreds(url6) {
2902
2902
  }
2903
2903
 
2904
2904
  // package.json
2905
- var version = "0.2.48";
2905
+ var version = "0.2.50";
2906
2906
 
2907
2907
  // src/http.ts
2908
2908
  var USER_AGENT = `malloyyo/${version}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloyyo",
3
- "version": "0.2.48",
3
+ "version": "0.2.50",
4
4
  "description": "Publish Malloy models to a Malloyyo instance",
5
5
  "license": "MIT",
6
6
  "repository": {