@malloy-publisher/sdk 0.4.1 → 0.5.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 (59) hide show
  1. package/dist/{DocumentStorage-BiFqO15i.es.js → DocumentStorage-DkwqA8SA.es.js} +2284 -2319
  2. package/dist/{DocumentStorage-CMyLifsz.cjs.js → DocumentStorage-mMn5SZ1c.cjs.js} +29 -29
  3. package/dist/{RenderedResult-CvrmYyr5.es.js → RenderedResult-CTD2Ej2S.es.js} +100 -80
  4. package/dist/{RenderedResult-CZzE8wv-.cjs.js → RenderedResult-GukOadCi.cjs.js} +27 -7
  5. package/dist/ServerProvider-CC9ein5-.cjs.js +1 -0
  6. package/dist/{ServerProvider-BWOEKg0O.es.js → ServerProvider-IzXlqSVe.es.js} +572 -553
  7. package/dist/builder/index.cjs.js +54 -49
  8. package/dist/builder/index.es.js +4124 -3521
  9. package/dist/client/api.d.ts +54 -2
  10. package/dist/client/index.cjs.js +1 -1
  11. package/dist/client/index.es.js +1 -1
  12. package/dist/components/Dashboard/TileCard.d.ts +7 -3
  13. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +15 -4
  14. package/dist/components/DashboardBuilder/controls.d.ts +8 -6
  15. package/dist/components/DashboardBuilder/document.d.ts +19 -5
  16. package/dist/components/DashboardBuilder/malloyText.d.ts +0 -30
  17. package/dist/components/DashboardBuilder/malloyTree.d.ts +232 -0
  18. package/dist/components/DashboardBuilder/preview.d.ts +17 -0
  19. package/dist/components/DashboardBuilder/readDocument.d.ts +23 -28
  20. package/dist/components/DashboardBuilder/spliceDocument.d.ts +12 -0
  21. package/dist/index.cjs.js +1 -1
  22. package/dist/index.es.js +5 -5
  23. package/dist/theme/resolveTheme.d.ts +1 -1
  24. package/dist/theme/types.d.ts +12 -2
  25. package/package.json +1 -1
  26. package/src/components/Dashboard/TileCard.tsx +8 -4
  27. package/src/components/DashboardBuilder/BuilderToolbar.tsx +4 -5
  28. package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +356 -0
  29. package/src/components/DashboardBuilder/DashboardEditor.tsx +116 -25
  30. package/src/components/DashboardBuilder/FilterDialog.tsx +19 -6
  31. package/src/components/DashboardBuilder/TileFrame.tsx +11 -2
  32. package/src/components/DashboardBuilder/TileMenu.tsx +6 -0
  33. package/src/components/DashboardBuilder/__test__/inventory.ts +367 -0
  34. package/src/components/DashboardBuilder/controls.spec.ts +53 -3
  35. package/src/components/DashboardBuilder/controls.ts +9 -7
  36. package/src/components/DashboardBuilder/document.ts +17 -5
  37. package/src/components/DashboardBuilder/invariants.spec.ts +297 -0
  38. package/src/components/DashboardBuilder/malloyText.spec.ts +27 -66
  39. package/src/components/DashboardBuilder/malloyText.ts +4 -109
  40. package/src/components/DashboardBuilder/malloyTree.spec.ts +362 -0
  41. package/src/components/DashboardBuilder/malloyTree.ts +954 -0
  42. package/src/components/DashboardBuilder/preview.spec.ts +18 -0
  43. package/src/components/DashboardBuilder/preview.ts +24 -6
  44. package/src/components/DashboardBuilder/readDocument.spec.ts +312 -21
  45. package/src/components/DashboardBuilder/readDocument.ts +144 -165
  46. package/src/components/DashboardBuilder/scannerShapes.spec.ts +550 -0
  47. package/src/components/DashboardBuilder/spliceDocument.spec.ts +955 -21
  48. package/src/components/DashboardBuilder/spliceDocument.ts +509 -119
  49. package/src/components/DashboardBuilder/statementExtent.spec.ts +606 -0
  50. package/src/components/RenderedResult/RenderedResult.tsx +21 -1
  51. package/src/components/given/GivensPanel.tsx +15 -3
  52. package/src/theme/buildTableCssVars.spec.ts +3 -0
  53. package/src/theme/buildTableCssVars.ts +6 -0
  54. package/src/theme/defaults.ts +16 -12
  55. package/src/theme/resolveTheme.spec.ts +14 -7
  56. package/src/theme/resolveTheme.ts +14 -8
  57. package/src/theme/types.ts +12 -2
  58. package/tsconfig.spec.json +5 -1
  59. package/dist/ServerProvider-Cc489A3f.cjs.js +0 -1
@@ -1,4 +1,5 @@
1
1
  import { DashboardDocument, LocalGiven } from './document';
2
+ import { ParsedMalloy } from './malloyTree';
2
3
  /**
3
4
  * Read a `dashboards/*.malloy` file into a {@link DashboardDocument}.
4
5
  *
@@ -7,10 +8,10 @@ import { DashboardDocument, LocalGiven } from './document';
7
8
  * in the browser and in a unit test alike, which is what lets the suite open
8
9
  * every dashboard in the repository as a regression gate.
9
10
  *
10
- * Structure comes from the parser's symbol tree, which covers imports (including
11
- * the items of a named list), sources, views and dimensions, each with a source
12
- * RANGE. Content comes from the text inside those ranges, and tags from
13
- * `parseAnnotation` over the block above each declaration.
11
+ * Structure comes from Malloy's own parse tree, through `malloyTree`: imports,
12
+ * sources, views, dimensions, givens and every `where:` clause, each with an
13
+ * exact span. Tags come from `parseAnnotation` over the `#` block above a
14
+ * declaration, which is `malloy-tag`'s grammar rather than Malloy's.
14
15
  *
15
16
  * Reading tags from the text rather than from the server, which serves them
16
17
  * already attached, is deliberate. The splice writer has to LOCATE a tag in
@@ -43,7 +44,7 @@ export type ReadResult = {
43
44
  * does not typecheck, in a codebase where most code never notices.
44
45
  */
45
46
  export declare const readFailed: (result: ReadResult) => result is ReadFailure;
46
- /** A `#`/`//` block above a declaration, and where it sits. */
47
+ /** A `#`/comment block above a declaration, and where it sits. */
47
48
  export interface Block {
48
49
  /** 0-based line of the first line in the block. */
49
50
  start: number;
@@ -57,23 +58,22 @@ export interface Block {
57
58
  }>;
58
59
  }
59
60
  /**
60
- * The comment-and-tag block immediately above `declLine`.
61
+ * The comment-and-tag block immediately above `declLine`, up to the blank line
62
+ * that is the author's own separator. Validated against the bundled dashboard,
63
+ * where it collects `revenue_trend`'s three tags and the fourteen-line comment
64
+ * explaining its colspan, then stops at the blank line above — which is the
65
+ * right unit to carry when that tile moves.
61
66
  *
62
- * Scans upward while lines are `#` tags or `//` comments and STOPS AT A BLANK
63
- * LINE. Validated against the bundled dashboard, where it collects
64
- * `revenue_trend`'s three tags and the fourteen-line comment explaining its
65
- * colspan, then stops at the blank line above — which is the right unit to carry
66
- * when that tile moves.
67
- *
68
- * A blank line is the author's own separator, which is why it is the boundary
69
- * rather than a count or a heuristic about comment content.
70
- */
71
- export declare function blockAbove(lines: string[], declLine: number): Block;
72
- /**
73
- * One `where: <field> <op> $<GIVEN>` clause. Exported for the writer, which
74
- * has to find the same clauses in order to replace them and nothing else.
67
+ * WHERE the block starts comes from `parsed`, which takes its comments from the
68
+ * lexer, and not from a scan for `//` here. Malloy spells a comment three ways
69
+ * — `//`, `--` and `/* … *\/` — and this walked upward looking only for the
70
+ * first. The other two stopped it early while the parser read straight past
71
+ * them, so a `#` tag above one was visible to the reader and invisible to the
72
+ * writer, which then wrote a SECOND copy of the tag below the comment. The
73
+ * reader picks the lower one up and the read-back gate is satisfied, so the
74
+ * file quietly ends up carrying two.
75
75
  */
76
- export declare const BINDING_CLAUSE: RegExp;
76
+ export declare function blockAbove(parsed: ParsedMalloy, lines: string[], declLine: number): Block;
77
77
  /**
78
78
  * A tag object, as `parseAnnotation` returns it. Only the reads this file makes.
79
79
  */
@@ -86,10 +86,7 @@ type ParseTags = (lines: string[]) => {
86
86
  tag?: TagLike | null;
87
87
  };
88
88
  /**
89
- * `given:` declarations, which the parser's symbol tree does not cover at all —
90
- * its types are query, unnamed_query, explore, field, join, import and
91
- * import_item. So these are read as text, in BOTH spellings Malloy accepts and
92
- * this repository uses:
89
+ * `given:` declarations, in BOTH spellings Malloy accepts:
93
90
  *
94
91
  * given: CATEGORY :: filter<string> is f'' // one per line
95
92
  *
@@ -97,10 +94,8 @@ type ParseTags = (lines: string[]) => {
97
94
  * CATEGORY :: filter<string> is f''
98
95
  * SINCE :: date is @2023-01-01
99
96
  *
100
- * The one-line form is what `givens.malloy` and the docs write and what the
101
- * builder emits; the block form is read so a file written the other way still
102
- * opens. Either way the tags above a declaration are its control contract.
97
+ * Either way the `#` tags above a declaration are its control contract.
103
98
  */
104
- export declare function localGivens(lines: string[], parse: ParseTags): LocalGiven[] | undefined;
99
+ export declare function localGivens(parsed: ParsedMalloy, lines: string[], parse: ParseTags): LocalGiven[] | undefined;
105
100
  export declare function readDashboardDocument(sourceText: string): Promise<ReadResult>;
106
101
  export {};
@@ -1,4 +1,16 @@
1
1
  import { DashboardDocument, DashboardTile } from './document';
2
+ /**
3
+ * The syntax errors Malloy's own parser reports for `text`, as a multiset of
4
+ * messages.
5
+ *
6
+ * The first `translate()` is enough and is all we want: a document with
7
+ * imports comes back NOT final, asking for the urls it needs, and by then the
8
+ * parse has already happened while nothing has been resolved. So this sees
9
+ * every syntax error and none of the semantic ones, which are not this
10
+ * writer's business -- a dashboard referring to a source in a file we decline
11
+ * to hand over is not damage we caused.
12
+ */
13
+ export declare function syntaxErrors(text: string): Promise<string[]>;
2
14
  /**
3
15
  * Write a change back into a `dashboards/*.malloy` file by PATCHING it.
4
16
  *