@malloy-publisher/sdk 0.3.0 → 0.4.0

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 (244) hide show
  1. package/README.md +22 -9
  2. package/dist/DocumentStorageProvider-CyOJ0hqf.es.js +24443 -0
  3. package/dist/DocumentStorageProvider-DGPQEd_l.cjs.js +134 -0
  4. package/dist/RenderedResult-BnPzJ9Jf.es.js +549 -0
  5. package/dist/RenderedResult-Dp22kZsQ.cjs.js +115 -0
  6. package/dist/{ServerProvider-DSK9rfSY.es.js → ServerProvider-BWOEKg0O.es.js} +1256 -1318
  7. package/dist/ServerProvider-Cc489A3f.cjs.js +1 -0
  8. package/dist/builder/index.cjs.js +105 -0
  9. package/dist/builder/index.d.ts +2 -0
  10. package/dist/builder/index.es.js +9482 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/api.d.ts +100 -42
  13. package/dist/client/index.cjs.js +1 -1
  14. package/dist/client/index.es.js +1 -1
  15. package/dist/components/AppDialog.d.ts +30 -0
  16. package/dist/components/BackLink.d.ts +32 -0
  17. package/dist/components/Dashboard/Dashboard.d.ts +19 -14
  18. package/dist/components/Dashboard/DashboardBar.d.ts +21 -0
  19. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  20. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  21. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  22. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  23. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  24. package/dist/components/Dashboard/index.d.ts +2 -0
  25. package/dist/components/Dashboard/promoteMeasureRow.d.ts +7 -3
  26. package/dist/components/Dashboard/telemetry.d.ts +48 -0
  27. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  28. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +31 -0
  29. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +118 -0
  30. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +30 -0
  31. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  32. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  33. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  34. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  35. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  36. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  37. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  38. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  39. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  40. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  41. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  42. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  43. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  44. package/dist/components/DashboardBuilder/newDashboard.d.ts +17 -0
  45. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  46. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  47. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  48. package/dist/components/DashboardBuilder/spliceDocument.d.ts +53 -0
  49. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  50. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  51. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  52. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  53. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  54. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  55. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  56. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +7 -0
  57. package/dist/components/DocumentStorage/index.d.ts +1 -1
  58. package/dist/components/FloatingIconButton.d.ts +16 -0
  59. package/dist/components/ItemRow.d.ts +38 -0
  60. package/dist/components/Materializations/MaterializationDetailDialog.d.ts +1 -2
  61. package/dist/components/Materializations/MaterializationRunsList.d.ts +1 -5
  62. package/dist/components/Materializations/Materializations.d.ts +7 -3
  63. package/dist/components/Materializations/ScopeButton.d.ts +18 -0
  64. package/dist/components/Materializations/SectionLabel.d.ts +7 -4
  65. package/dist/components/Materializations/TriggerLabel.d.ts +14 -0
  66. package/dist/components/Materializations/index.d.ts +0 -1
  67. package/dist/components/Package/ContentTypeIcon.d.ts +3 -5
  68. package/dist/components/Package/NewDashboardDialog.d.ts +18 -0
  69. package/dist/components/Package/index.d.ts +0 -1
  70. package/dist/components/PackageSection.d.ts +23 -0
  71. package/dist/components/Prose.d.ts +46 -0
  72. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  73. package/dist/components/RenderedResult/index.d.ts +1 -0
  74. package/dist/components/buttons.d.ts +53 -0
  75. package/dist/components/drill/index.d.ts +1 -1
  76. package/dist/components/drill/resolveDrill.d.ts +22 -0
  77. package/dist/components/drill/useDrill.d.ts +11 -2
  78. package/dist/components/index.d.ts +6 -0
  79. package/dist/components/styles.d.ts +49 -44
  80. package/dist/hooks/index.d.ts +2 -0
  81. package/dist/hooks/useCrudMutation.d.ts +42 -0
  82. package/dist/hooks/useDocumentControls.d.ts +70 -0
  83. package/dist/hooks/useQueryResult.d.ts +40 -0
  84. package/dist/index.cjs.js +22 -273
  85. package/dist/index.d.ts +1 -0
  86. package/dist/index.es.js +16888 -44451
  87. package/dist/telemetry/consoleEvents.d.ts +60 -0
  88. package/dist/utils/malloyLiteral.d.ts +11 -0
  89. package/dist/utils/sha256.d.ts +2 -0
  90. package/package.json +24 -9
  91. package/src/builder-entry.ts +55 -0
  92. package/src/components/AppDialog.tsx +115 -0
  93. package/src/components/BackLink.tsx +83 -0
  94. package/src/components/Connections/AddConnectionDialog.tsx +50 -70
  95. package/src/components/Connections/DeleteConnectionDialog.tsx +23 -50
  96. package/src/components/Connections/EditConnectionDialog.tsx +54 -73
  97. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  98. package/src/components/Dashboard/Dashboard.tsx +165 -175
  99. package/src/components/Dashboard/DashboardBar.tsx +88 -0
  100. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  101. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  102. package/src/components/Dashboard/DashboardTile.tsx +66 -123
  103. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  104. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  105. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  106. package/src/components/Dashboard/TileCard.tsx +120 -0
  107. package/src/components/Dashboard/index.ts +2 -0
  108. package/src/components/Dashboard/promoteMeasureRow.spec.ts +70 -0
  109. package/src/components/Dashboard/promoteMeasureRow.ts +33 -2
  110. package/src/components/Dashboard/telemetry.ts +51 -0
  111. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  112. package/src/components/DashboardBuilder/AddTileDialog.tsx +247 -0
  113. package/src/components/DashboardBuilder/BuilderToolbar.tsx +162 -0
  114. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +852 -0
  115. package/src/components/DashboardBuilder/DashboardBuilder.tsx +666 -0
  116. package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +163 -0
  117. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +188 -0
  118. package/src/components/DashboardBuilder/DashboardEditor.tsx +567 -0
  119. package/src/components/DashboardBuilder/DiffDialog.tsx +122 -0
  120. package/src/components/DashboardBuilder/DrillDialog.tsx +269 -0
  121. package/src/components/DashboardBuilder/FilterDialog.tsx +562 -0
  122. package/src/components/DashboardBuilder/FilterStrip.tsx +126 -0
  123. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  124. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  125. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  126. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  127. package/src/components/DashboardBuilder/catalog.ts +225 -0
  128. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  129. package/src/components/DashboardBuilder/controls.ts +398 -0
  130. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  131. package/src/components/DashboardBuilder/diff.ts +93 -0
  132. package/src/components/DashboardBuilder/document.ts +209 -0
  133. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  134. package/src/components/DashboardBuilder/layout.ts +143 -0
  135. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  136. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  137. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  138. package/src/components/DashboardBuilder/newDashboard.spec.ts +40 -0
  139. package/src/components/DashboardBuilder/newDashboard.ts +48 -0
  140. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  141. package/src/components/DashboardBuilder/preview.ts +172 -0
  142. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  143. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  144. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  145. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1161 -0
  146. package/src/components/DashboardBuilder/spliceDocument.ts +1135 -0
  147. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  148. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  149. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +311 -0
  150. package/src/components/DashboardBuilder/useDashboardEditor.ts +201 -0
  151. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  152. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  153. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  154. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  155. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  156. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  157. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  158. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  159. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +12 -0
  160. package/src/components/DocumentStorage/index.ts +1 -0
  161. package/src/components/Environment/About.tsx +16 -62
  162. package/src/components/Environment/AddPackageDialog.tsx +85 -154
  163. package/src/components/Environment/Connections.tsx +125 -205
  164. package/src/components/Environment/DeletePackageDialog.tsx +32 -77
  165. package/src/components/Environment/EditPackageDialog.tsx +46 -58
  166. package/src/components/Environment/Environment.tsx +34 -36
  167. package/src/components/Environment/Packages.tsx +63 -128
  168. package/src/components/FloatingIconButton.tsx +41 -0
  169. package/src/components/Home/AddEnvironmentDialog.tsx +47 -70
  170. package/src/components/Home/DeleteEnvironmentDialog.tsx +32 -77
  171. package/src/components/Home/EditEnvironmentDialog.tsx +47 -61
  172. package/src/components/Home/Home.tsx +101 -214
  173. package/src/components/ItemRow.tsx +165 -0
  174. package/src/components/Materializations/CreateMaterializationDialog.tsx +34 -51
  175. package/src/components/Materializations/DeleteMaterializationDialog.tsx +31 -53
  176. package/src/components/Materializations/MaterializationDetailDialog.tsx +60 -69
  177. package/src/components/Materializations/MaterializationRunsList.tsx +29 -42
  178. package/src/components/Materializations/Materializations.tsx +137 -140
  179. package/src/components/Materializations/ScopeButton.tsx +85 -0
  180. package/src/components/Materializations/SectionLabel.tsx +7 -4
  181. package/src/components/Materializations/SetScheduleDialog.tsx +48 -89
  182. package/src/components/Materializations/TriggerLabel.tsx +36 -0
  183. package/src/components/Materializations/cron.spec.ts +113 -0
  184. package/src/components/Materializations/index.ts +0 -1
  185. package/src/components/Materializations/utils.spec.ts +182 -0
  186. package/src/components/Model/Model.tsx +6 -23
  187. package/src/components/Model/ModelCell.tsx +33 -72
  188. package/src/components/Notebook/Notebook.tsx +25 -88
  189. package/src/components/Notebook/NotebookCell.tsx +35 -183
  190. package/src/components/Package/ContentTypeIcon.spec.ts +22 -37
  191. package/src/components/Package/ContentTypeIcon.tsx +10 -12
  192. package/src/components/Package/NewDashboardDialog.spec.tsx +129 -0
  193. package/src/components/Package/NewDashboardDialog.tsx +265 -0
  194. package/src/components/Package/Package.tsx +179 -238
  195. package/src/components/Package/index.ts +0 -1
  196. package/src/components/PackageSection.tsx +85 -0
  197. package/src/components/Prose.spec.tsx +85 -0
  198. package/src/components/Prose.tsx +179 -0
  199. package/src/components/QueryResult/QueryResult.tsx +15 -43
  200. package/src/components/RenderedResult/RenderedResult.lifecycle.spec.tsx +198 -0
  201. package/src/components/RenderedResult/RenderedResult.tsx +22 -8
  202. package/src/components/RenderedResult/ResultContainer.tsx +4 -12
  203. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  204. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  205. package/src/components/RenderedResult/index.ts +1 -0
  206. package/src/components/ResultsDialog.tsx +8 -32
  207. package/src/components/buttons.tsx +114 -0
  208. package/src/components/designSystem.spec.tsx +316 -0
  209. package/src/components/drill/index.ts +1 -0
  210. package/src/components/drill/resolveDrill.ts +22 -1
  211. package/src/components/drill/useDrill.spec.tsx +94 -0
  212. package/src/components/drill/useDrill.tsx +52 -12
  213. package/src/components/given/GivensPanel.tsx +1 -1
  214. package/src/components/given/paramCodec.spec.ts +1 -1
  215. package/src/components/index.ts +16 -0
  216. package/src/components/styles.ts +49 -122
  217. package/src/hooks/index.ts +13 -0
  218. package/src/hooks/useCrudMutation.spec.tsx +119 -0
  219. package/src/hooks/useCrudMutation.tsx +85 -0
  220. package/src/hooks/useDocumentControls.ts +170 -0
  221. package/src/hooks/useQueryResult.ts +82 -0
  222. package/src/index.ts +9 -0
  223. package/src/telemetry/consoleEvents.spec.ts +130 -0
  224. package/src/telemetry/consoleEvents.ts +124 -0
  225. package/src/theme/defaults.ts +34 -23
  226. package/src/theme/resolveTheme.spec.ts +9 -4
  227. package/src/theme/resolveTheme.ts +12 -8
  228. package/src/utils/malloyLiteral.spec.ts +43 -0
  229. package/src/utils/malloyLiteral.ts +76 -0
  230. package/src/utils/sha256.ts +13 -0
  231. package/test/README.md +1 -1
  232. package/test/serverProvider.tsx +5 -2
  233. package/vite.config.ts +5 -0
  234. package/dist/ServerProvider-CGnLjzag.cjs.js +0 -1
  235. package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +0 -14
  236. package/dist/components/Materializations/EnvironmentMaterializations.d.ts +0 -7
  237. package/dist/components/Materializations/ScheduleCard.d.ts +0 -20
  238. package/dist/components/Materializations/TriggerChip.d.ts +0 -10
  239. package/dist/components/Package/Models.d.ts +0 -6
  240. package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +0 -179
  241. package/src/components/Materializations/EnvironmentMaterializations.tsx +0 -267
  242. package/src/components/Materializations/ScheduleCard.tsx +0 -231
  243. package/src/components/Materializations/TriggerChip.tsx +0 -44
  244. package/src/components/Package/Models.tsx +0 -71
@@ -0,0 +1,106 @@
1
+ import { DashboardDocument, LocalGiven } from './document';
2
+ /**
3
+ * Read a `dashboards/*.malloy` file into a {@link DashboardDocument}.
4
+ *
5
+ * PURE: source text in, document out. No server, no schema, no connection.
6
+ * `Malloy.parse` needs none of those — only `Malloy.compile` does — so this runs
7
+ * in the browser and in a unit test alike, which is what lets the suite open
8
+ * every dashboard in the repository as a regression gate.
9
+ *
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.
14
+ *
15
+ * Reading tags from the text rather than from the server, which serves them
16
+ * already attached, is deliberate. The splice writer has to LOCATE a tag in
17
+ * order to edit it, so the scan exists either way; taking the values from the
18
+ * same scan keeps one source of truth for them and keeps this function pure.
19
+ *
20
+ * ALL-OR-NOTHING: a file this cannot fully represent is refused rather than
21
+ * half-opened. The bar is lower than it sounds because the document is an
22
+ * editing projection — unmodelled Malloy survives a splice untouched, so it only
23
+ * blocks when it would make an edit unsafe.
24
+ */
25
+ /** Why a file could not be opened, in terms its author can act on. */
26
+ export interface ReadFailure {
27
+ ok: false;
28
+ reason: string;
29
+ /** 1-based, for a message that can point at the line. */
30
+ line?: number;
31
+ }
32
+ export type ReadResult = {
33
+ ok: true;
34
+ document: DashboardDocument;
35
+ } | ReadFailure;
36
+ /**
37
+ * Narrow a result to its failure arm.
38
+ *
39
+ * A guard rather than `if (!result.ok)`, because this package compiles with
40
+ * `strict: false` — the tsconfig says why, and it is not ours to change — and
41
+ * without `strictNullChecks` TypeScript does not narrow a discriminated union
42
+ * through a negated discriminant. The failure is quiet: `result.reason` simply
43
+ * does not typecheck, in a codebase where most code never notices.
44
+ */
45
+ export declare const readFailed: (result: ReadResult) => result is ReadFailure;
46
+ /** A `#`/`//` block above a declaration, and where it sits. */
47
+ export interface Block {
48
+ /** 0-based line of the first line in the block. */
49
+ start: number;
50
+ /**
51
+ * The `#`-prefixed lines only, in order, WITH their line numbers. The writer
52
+ * needs the numbers to patch a tag in place; the reader only needs the text.
53
+ */
54
+ tags: Array<{
55
+ line: number;
56
+ text: string;
57
+ }>;
58
+ }
59
+ /**
60
+ * The comment-and-tag block immediately above `declLine`.
61
+ *
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.
75
+ */
76
+ export declare const BINDING_CLAUSE: RegExp;
77
+ /**
78
+ * A tag object, as `parseAnnotation` returns it. Only the reads this file makes.
79
+ */
80
+ type TagLike = {
81
+ text: (key: string) => string | undefined;
82
+ numeric: (key: string) => number | undefined;
83
+ tag: (key: string) => TagLike | undefined;
84
+ };
85
+ type ParseTags = (lines: string[]) => {
86
+ tag?: TagLike | null;
87
+ };
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:
93
+ *
94
+ * given: CATEGORY :: filter<string> is f'' // one per line
95
+ *
96
+ * given: // a block
97
+ * CATEGORY :: filter<string> is f''
98
+ * SINCE :: date is @2023-01-01
99
+ *
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.
103
+ */
104
+ export declare function localGivens(lines: string[], parse: ParseTags): LocalGiven[] | undefined;
105
+ export declare function readDashboardDocument(sourceText: string): Promise<ReadResult>;
106
+ export {};
@@ -0,0 +1,51 @@
1
+ import { KeyboardSensor, PointerSensor, PointerSensorOptions } from '@dnd-kit/dom';
2
+ import { ReactNode } from 'react';
3
+ import { PluginDescriptor, Plugin } from '@dnd-kit/abstract';
4
+ /** The type of a gap: the empty end of a row, offered as a drop target. */
5
+ export declare const GAP_TYPE = "gap";
6
+ export declare const builderSensors: ( PluginDescriptor<any, Plugin<any, PointerSensorOptions>, typeof PointerSensor> | typeof KeyboardSensor)[];
7
+ interface TileSortableHandles {
8
+ /** The tile's element: what is dragged, and what a drop lands on. */
9
+ ref: (element: Element | null) => void;
10
+ /** The grip: keyboard focus and screen-reader instructions live here. */
11
+ handleRef: (element: Element | null) => void;
12
+ /** This tile is the one being dragged. */
13
+ isDragSource: boolean;
14
+ }
15
+ /**
16
+ * A tile as a sortable item. A component rather than a hook call in the
17
+ * builder's render, because the grid renders tiles through a callback and a
18
+ * hook cannot be called from one.
19
+ *
20
+ * `index` is the tile's place in the PREVIEWED order, which is what lets the
21
+ * library animate a tile to its new slot when that order changes under it.
22
+ */
23
+ export declare function TileSortable({ id, index, children, }: {
24
+ id: string;
25
+ index: number;
26
+ children: (handles: TileSortableHandles) => ReactNode;
27
+ }): import("react/jsx-runtime").JSX.Element;
28
+ /** What a gap drop target carries: the key of the tile the gap follows. */
29
+ export interface GapData {
30
+ after: string;
31
+ }
32
+ /**
33
+ * The empty end of a row, as a drop target.
34
+ *
35
+ * A flow grid has no element where a row runs out; the space is simply not
36
+ * painted. So while a drag is live the builder lays one of these into each
37
+ * such space, spanning exactly the columns left over, and the library can
38
+ * report the pointer over it like any other target. `pointerIntersection`
39
+ * rather than the default shape overlap: the dragged copy is tile-sized and
40
+ * would overlap a neighbouring tile more than a narrow gap; the pointer is
41
+ * where the reader means.
42
+ */
43
+ export declare function GapDroppable({ id, after, children, }: {
44
+ id: string;
45
+ after: string;
46
+ children: (handles: {
47
+ ref: (element: Element | null) => void;
48
+ isDropTarget: boolean;
49
+ }) => ReactNode;
50
+ }): import("react/jsx-runtime").JSX.Element;
51
+ export {};
@@ -0,0 +1,53 @@
1
+ import { DashboardDocument, DashboardTile } from './document';
2
+ /**
3
+ * Write a change back into a `dashboards/*.malloy` file by PATCHING it.
4
+ *
5
+ * The builder does not regenerate the file. It rewrites the bytes it owns and
6
+ * leaves every other byte exactly where it was, which is what lets it edit a
7
+ * dashboard somebody else wrote: comments, formatting, declaration order and
8
+ * unmodelled Malloy all survive an edit because nothing rewrites them.
9
+ *
10
+ * The safety property is a SEMANTIC round-trip, not a byte one. After splicing,
11
+ * the result is read back and compared against the document that was asked for;
12
+ * a mismatch refuses the write. Byte-identity with a regenerated file would be
13
+ * a weaker thing to know, and would make every commented file read-only.
14
+ *
15
+ * A refused write NEVER discards the edit. The caller keeps its document and is
16
+ * told the writer produced something it could not read back — that is a defect
17
+ * in this module, not a mistake by the person editing.
18
+ *
19
+ * SCOPE, deliberately: a tile's presentation, its filter bindings, the order of
20
+ * tiles, and the dashboard's OWN givens — added, removed or retagged. Never an
21
+ * import, and never a model file: a filter the builder adds is a declaration in
22
+ * this file, which is the convention {@link LocalGiven} describes. And tiles
23
+ * ADDED or REMOVED: a new `view:` inside the extension of the source it reads
24
+ * (or a new extension, when the file imports that source by name), a removed
25
+ * one deleted with its `#` tags. Those moves are the one place the file cannot
26
+ * say who owns the comment beside a declaration, so the builder shows the diff
27
+ * before a structural save and the `//` comments are left where they were.
28
+ *
29
+ * A given is different from a tile in exactly the way that matters there: the
30
+ * `#` tags above its declaration are its control contract and have no other
31
+ * owner, so removing the declaration can take them with it, and a `//` comment
32
+ * in the same block is left where it is.
33
+ */
34
+ export interface SpliceFailure {
35
+ ok: false;
36
+ reason: string;
37
+ }
38
+ export type SpliceResult = {
39
+ ok: true;
40
+ source: string;
41
+ } | SpliceFailure;
42
+ /** Narrow to the failure arm; see {@link readFailed} for why a guard. */
43
+ export declare const spliceFailed: (result: SpliceResult) => result is SpliceFailure;
44
+ /**
45
+ * One tile's identity TO THE FILE, ignoring presentation and position — but
46
+ * not its declaration: a tile redeclared from another view is a different tile
47
+ * to the file, removed and added, which `document.tileKey` does not say.
48
+ * `document.tileKey` is the grid's identity, which a drag names and React keys
49
+ * on; this one decides what gets written. Anything asking "will this save
50
+ * rewrite declarations?" wants THIS key.
51
+ */
52
+ export declare const tileFileKey: (t: DashboardTile) => string;
53
+ export declare function spliceDashboardDocument(sourceText: string, next: DashboardDocument): Promise<SpliceResult>;
@@ -0,0 +1,10 @@
1
+ import { DashboardDocument } from '../document';
2
+ import { SpliceResult } from '../spliceDocument';
3
+ /** The document a file produces, or a thrown reason: what a spec starts from. */
4
+ export declare function openDocument(source: string): Promise<DashboardDocument>;
5
+ /** Open, edit a copy, and hand back what the writer says. */
6
+ export declare function splice(source: string, edit: (document: DashboardDocument) => void): Promise<SpliceResult>;
7
+ /** `splice`, for an edit the writer is expected to accept. */
8
+ export declare function spliced(source: string, edit: (document: DashboardDocument) => void): Promise<string>;
9
+ /** `splice`, for an edit the writer is expected to refuse; its reason. */
10
+ export declare function refused(source: string, edit: (document: DashboardDocument) => void): Promise<string>;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The keyboard an editor is expected to have.
3
+ *
4
+ * Undo and redo on the platform's usual keys, save on ⌘S / Ctrl+S (which the
5
+ * browser would otherwise take), Escape to drop the selection, and the arrow
6
+ * keys to nudge the selected tile's width a column at a time — the one layout
7
+ * edit that is otherwise drag-only.
8
+ *
9
+ * Nothing but Escape fires while a text field has focus, so typing into a
10
+ * title never undoes a layout.
11
+ */
12
+ export interface BuilderShortcutHandlers {
13
+ undo: () => void;
14
+ redo: () => void;
15
+ save?: () => void;
16
+ escape: () => void;
17
+ /** Nudge the selected tile's width by ±1 column. */
18
+ nudge: (delta: 1 | -1) => void;
19
+ }
20
+ /** The modifier's glyph for a tooltip. */
21
+ export declare const MOD: string;
22
+ export declare function useBuilderShortcuts(handlers: BuilderShortcutHandlers): void;
@@ -0,0 +1,63 @@
1
+ import { DashboardDocument } from './document';
2
+ /**
3
+ * The editor's state: the document being edited, its history, and saving.
4
+ *
5
+ * Deliberately holds the DOCUMENT and nothing else. Given VALUES — what the
6
+ * preview is running with — are editor state rather than document state and
7
+ * live outside this hook, which is what keeps them out of the undo stack. Undo
8
+ * should take back a layout change; it should not rewind the filter someone was
9
+ * previewing under.
10
+ */
11
+ export interface DashboardEditor {
12
+ document: DashboardDocument;
13
+ /** The file as it currently stands, which is what a save patches. */
14
+ source: string;
15
+ canUndo: boolean;
16
+ canRedo: boolean;
17
+ /** Whether the document has changes the file does not have yet. */
18
+ dirty: boolean;
19
+ /**
20
+ * Why the last save did not happen. The document is untouched when this is
21
+ * set: a refused write keeps the reader's work and reports a defect in the
22
+ * writer, rather than discarding an edit because a tool could not read back
23
+ * what it produced.
24
+ */
25
+ error?: string;
26
+ /** Apply a change. Receives a copy; mutate it freely. */
27
+ update: (change: (draft: DashboardDocument) => void) => void;
28
+ undo: () => void;
29
+ redo: () => void;
30
+ /** Splice the change into the file, or say why it was refused. */
31
+ save: () => Promise<SaveOutcome>;
32
+ /**
33
+ * The file a save would write, without writing it: what a diff preview
34
+ * shows. The failure arm is the writer's refusal, worded for the author.
35
+ */
36
+ preview: () => Promise<{
37
+ ok: true;
38
+ source: string;
39
+ } | {
40
+ ok: false;
41
+ reason: string;
42
+ }>;
43
+ /**
44
+ * Whether the unsaved change adds or removes a tile. Those moves touch
45
+ * declarations and the comments beside them, which is when a save is worth
46
+ * showing as a diff first; a property edit never is.
47
+ */
48
+ structural: boolean;
49
+ }
50
+ export type SaveOutcome = {
51
+ ok: true;
52
+ } | {
53
+ ok: false;
54
+ reason: string;
55
+ };
56
+ export declare function useDashboardEditor(options: {
57
+ /** The file as read from storage. */
58
+ source: string;
59
+ /** The document that file produced. */
60
+ document: DashboardDocument;
61
+ /** Persist the patched file. Rejecting leaves the editor dirty. */
62
+ onSave?: (source: string) => Promise<void> | void;
63
+ }): DashboardEditor;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A copy of `value` to edit while a window is open, committed ONCE when it
3
+ * closes, and only if something changed.
4
+ *
5
+ * Per-keystroke commits would put a document in the undo stack for every
6
+ * letter typed into a title, and undo would then walk back through the word.
7
+ */
8
+ export declare function useDraft<T>(value: T | undefined, open: boolean, onCommit: (next: T) => void, onClose: () => void): {
9
+ draft: T;
10
+ patch: (change: (draft: T) => void) => void;
11
+ close: () => void;
12
+ discard: () => void;
13
+ };
@@ -0,0 +1,65 @@
1
+ import { CatalogField } from './catalog';
2
+ import { BuilderControl, ControlKind, MappingRow } from './controls';
3
+ import { DashboardDocument, DashboardTile, LocalGiven } from './document';
4
+ import { Dispatch, SetStateAction } from 'react';
5
+ type Source = {
6
+ kind: "existing";
7
+ name: string;
8
+ } | {
9
+ kind: "new";
10
+ };
11
+ /** `STATUS` → `Status`: the label a new control gets when none is typed. */
12
+ export declare const titleCase: (name: string) => string;
13
+ /**
14
+ * The filter window's state and every derivation it renders from: what the
15
+ * control is (new here, or one the model offers), which tiles it binds and on
16
+ * which field, what stands in the way of applying, and the payload an Apply
17
+ * hands back. No MUI in here, so it can be exercised without a dialog.
18
+ */
19
+ export declare function useFilterForm({ open, document, control, available, fieldsFor, onApply, }: {
20
+ open: boolean;
21
+ document: DashboardDocument;
22
+ control: BuilderControl | undefined;
23
+ available: readonly BuilderControl[];
24
+ fieldsFor?: (tile: DashboardTile) => readonly CatalogField[] | undefined;
25
+ onApply: (given: string, rows: MappingRow[], declare?: LocalGiven) => void;
26
+ }): {
27
+ editing: boolean;
28
+ shown: BuilderControl;
29
+ fromModel: boolean;
30
+ source: Source;
31
+ setSource: Dispatch<SetStateAction<Source>>;
32
+ label: string;
33
+ setLabel: Dispatch<SetStateAction<string>>;
34
+ kind: ControlKind;
35
+ dateDefault: string;
36
+ setDateDefault: Dispatch<SetStateAction<string>>;
37
+ field: string;
38
+ rows: MappingRow[];
39
+ setRows: Dispatch<SetStateAction<MappingRow[]>>;
40
+ perTile: boolean;
41
+ setPerTile: Dispatch<SetStateAction<boolean>>;
42
+ newName: string;
43
+ target: {
44
+ name: string;
45
+ type?: string;
46
+ };
47
+ valueTyped: boolean;
48
+ commonOp: string;
49
+ setRow: (index: number, patch: Partial<MappingRow>) => void;
50
+ setCommonOp: (next: string) => void;
51
+ pickExisting: (given: BuilderControl) => void;
52
+ pickKind: (next: ControlKind) => void;
53
+ bindable: boolean[];
54
+ bindableCount: number;
55
+ included: number;
56
+ commonFields: CatalogField[];
57
+ setAll: (include: boolean) => void;
58
+ accepts: (candidate: CatalogField) => boolean;
59
+ pickField: (next: string) => void;
60
+ rowProblems: string[];
61
+ commonProblem: string;
62
+ canApply: boolean;
63
+ apply: () => void;
64
+ };
65
+ export {};
@@ -0,0 +1,22 @@
1
+ import { DragEndEvent, DragOverEvent } from '@dnd-kit/react';
2
+ import { DashboardTile } from './document';
3
+ /**
4
+ * Dragging a tile to reorder it. The gesture is `@dnd-kit/react`'s (see
5
+ * `sortable.tsx`); what is decided here is what a drop means for the file,
6
+ * through `keepRowStructure` for a drop onto a tile and `moveIntoGap` for a
7
+ * drop into the empty end of a row. The preview is rebuilt on each report and
8
+ * written ONCE, on release: one history entry for the whole drag.
9
+ */
10
+ export declare function useTileReorder({ tiles, commit, onLanded, }: {
11
+ tiles: DashboardTile[];
12
+ /** The order to write when the drag ends somewhere new. */
13
+ commit: (next: DashboardTile[]) => void;
14
+ /** Where the dragged tile came to rest, which the caller selects. */
15
+ onLanded: (index: number) => void;
16
+ }): {
17
+ dragging: boolean;
18
+ preview: DashboardTile[];
19
+ onDragStart: () => void;
20
+ onDragOver: (event: DragOverEvent) => void;
21
+ onDragEnd: (event: DragEndEvent) => void;
22
+ };
@@ -0,0 +1,29 @@
1
+ import { DashboardTile } from './document';
2
+ import { RefObject } from 'react';
3
+ /** A resize in flight: the tile, the width it WOULD be, and the geometry. */
4
+ export interface ResizeState {
5
+ index: number;
6
+ span: number;
7
+ left: number;
8
+ track: number;
9
+ }
10
+ /**
11
+ * Dragging a tile's right edge to set its `colspan`. The width is previewed
12
+ * by the caller from `resize.span` and written ONCE, on release: writing on
13
+ * every pointer move would put a dozen documents in the history for one
14
+ * gesture, and undo would walk back through the drag a column at a time.
15
+ */
16
+ export declare function useTileResize({ tiles, columns, onStart, commit, }: {
17
+ tiles: readonly DashboardTile[];
18
+ columns: number;
19
+ /** The tile a resize begins on, which the caller selects. */
20
+ onStart: (index: number) => void;
21
+ /** The width to write when the drag ends. */
22
+ commit: (index: number, span: number) => void;
23
+ }): {
24
+ resize: ResizeState;
25
+ gridBox: RefObject<HTMLDivElement>;
26
+ startResize: (event: React.PointerEvent<HTMLDivElement>, index: number) => void;
27
+ onResize: (event: React.PointerEvent<HTMLDivElement>) => void;
28
+ endResize: (event: React.PointerEvent<HTMLDivElement>) => void;
29
+ };
@@ -15,4 +15,11 @@ interface DocumentStorageContextValue {
15
15
  export declare function DocumentStorageProvider({ children, documentStorage, }: DocumentStorageProviderProps): import("react/jsx-runtime").JSX.Element;
16
16
  /** The host's storage, or a thrown error outside a provider: there is no default. */
17
17
  export declare function useDocumentStorage(): DocumentStorageContextValue;
18
+ /**
19
+ * The host's storage, or undefined outside a provider. For a component that
20
+ * can do without one — the dashboard editor still edits and exports with no
21
+ * place to save — rather than the throwing form, which is for components that
22
+ * cannot.
23
+ */
24
+ export declare function useOptionalDocumentStorage(): DocumentStorageContextValue | undefined;
18
25
  export {};
@@ -1,3 +1,3 @@
1
1
  export type { DocumentLocator, DocumentStorage, DocumentType, Workspace, } from './DocumentStorage';
2
- export { DocumentStorageProvider, useDocumentStorage, type DocumentStorageProviderProps, } from './DocumentStorageProvider';
2
+ export { DocumentStorageProvider, useDocumentStorage, useOptionalDocumentStorage, type DocumentStorageProviderProps, } from './DocumentStorageProvider';
3
3
  export { BrowserDocumentStorage } from './BrowserDocumentStorage';
@@ -0,0 +1,16 @@
1
+ import { IconButtonProps } from '@mui/material';
2
+ /**
3
+ * A small round button that sits OVER content — a rendered result, an
4
+ * explorer, a chart — to open something about it: the code, the full result,
5
+ * a render warning.
6
+ *
7
+ * On the instance theme's tile colour, with its border, so it reads as a chip
8
+ * of the same card it floats on in both modes. Six of these were drawn by hand
9
+ * before, every one on a hardcoded white plate with a hardcoded dark icon,
10
+ * and the notebook's comment said why that was the only way: a white plate
11
+ * needs a dark icon whatever the mode. The plate follows the theme now, so
12
+ * the icon can too.
13
+ *
14
+ * Positioning is the caller's: it passes `sx` for where the button floats.
15
+ */
16
+ export declare function FloatingIconButton({ sx, ...props }: IconButtonProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,38 @@
1
+ import * as React from "react";
2
+ /**
3
+ * One thing in a list, anywhere in the Console: a colored icon plate, the
4
+ * thing's name, what it is, and whatever acts on it at the right edge. One per
5
+ * row.
6
+ *
7
+ * The rule is that a list is a list: everything a reader scans down is drawn
8
+ * this way, so the same reading task looks the same on every page. A grid of
9
+ * cards says "these are tiles to arrange", which is not what any of these
10
+ * lists are; a row also lets the description be a description rather than two
11
+ * clamped lines.
12
+ *
13
+ * The color is passed rather than derived here: the package page keys it off
14
+ * content type (see `CONTENT_TINT`), and the environment-scoped lists off what
15
+ * kind of thing the list holds (see `SURFACE_TINT`). Both are exhaustive maps,
16
+ * so the color stays a property of the kind and not of the call site.
17
+ */
18
+ export declare function ItemRow({ icon, tint, label, mono, description, rightLabel, trailingAction, onClick, ariaLabel, }: {
19
+ /** The glyph, drawn white on the tinted plate. */
20
+ icon: React.ReactNode;
21
+ tint: string;
22
+ label: string;
23
+ /** Monospace label, for a name that is a file path. */
24
+ mono?: boolean;
25
+ /** What this one is, in the author's words. One line, then ellipsis. */
26
+ description?: string;
27
+ /** A fact about the row, right-aligned before any action: "1.0 K rows". */
28
+ rightLabel?: string;
29
+ /**
30
+ * Rendered at the end of the row: a menu, an open-in-new-tab button. Clicks
31
+ * on it should `event.stopPropagation()` so the row's own click does not
32
+ * also fire.
33
+ */
34
+ trailingAction?: React.ReactNode;
35
+ onClick?: (event: React.MouseEvent) => void;
36
+ /** Overrides the accessible name, which is otherwise the label. */
37
+ ariaLabel?: string;
38
+ }): import("react/jsx-runtime").JSX.Element;
@@ -2,8 +2,7 @@ import { BuildPlan, Materialization } from '../../client';
2
2
  type MaterializationDetailDialogProps = {
3
3
  materialization: Materialization | null;
4
4
  buildPlan: BuildPlan | null;
5
- showBuildPlan?: boolean;
6
5
  onClose: () => void;
7
6
  };
8
- export default function MaterializationDetailDialog({ materialization, buildPlan, showBuildPlan, onClose, }: MaterializationDetailDialogProps): import("react/jsx-runtime").JSX.Element;
7
+ export default function MaterializationDetailDialog({ materialization, buildPlan, onClose, }: MaterializationDetailDialogProps): import("react/jsx-runtime").JSX.Element;
9
8
  export {};
@@ -3,13 +3,9 @@ type MaterializationRunsListProps = {
3
3
  materializations: Materialization[];
4
4
  mutable: boolean;
5
5
  isMutating: boolean;
6
- /** Show a Package column — for the environment-scoped view spanning packages. */
7
- showPackage?: boolean;
8
- /** Navigate to a package (used by the Package column links). */
9
- onClickPackage?: (packageName: string) => void;
10
6
  onStop: (materialization: Materialization) => void;
11
7
  onDelete: (materialization: Materialization, dropTables: boolean) => void;
12
8
  onViewDetails: (materialization: Materialization) => void;
13
9
  };
14
- export default function MaterializationRunsList({ materializations, mutable, isMutating, showPackage, onClickPackage, onStop, onDelete, onViewDetails, }: MaterializationRunsListProps): import("react/jsx-runtime").JSX.Element;
10
+ export default function MaterializationRunsList({ materializations, mutable, isMutating, onStop, onDelete, onViewDetails, }: MaterializationRunsListProps): import("react/jsx-runtime").JSX.Element;
15
11
  export {};
@@ -1,7 +1,11 @@
1
- import { default as React } from 'react';
2
1
  interface MaterializationsProps {
3
2
  resourceUri: string;
4
- onClickPackageFile?: (to: string, event?: React.MouseEvent) => void;
5
3
  }
6
- export default function Materializations({ resourceUri, onClickPackageFile, }: MaterializationsProps): import("react/jsx-runtime").JSX.Element;
4
+ /**
5
+ * The package's materializations, as a section of its page: what has been
6
+ * built, and the three controls that change it — scope, schedule, and a new
7
+ * build. The runs are the package's own history, so they sit beside its
8
+ * dashboards and models rather than one click away on a page of their own.
9
+ */
10
+ export default function Materializations({ resourceUri, }: MaterializationsProps): import("react/jsx-runtime").JSX.Element;
7
11
  export {};
@@ -0,0 +1,18 @@
1
+ export type Scope = "package" | "version";
2
+ /**
3
+ * The package's persist scope, as one button.
4
+ *
5
+ * It is a menu rather than a pair of toggles because the two values are a
6
+ * choice, not a filter, and because the choice is usually made once and then
7
+ * left alone — the section's heading row is not the place for a permanent
8
+ * two-button control. What each value means is in the menu, where it is read at
9
+ * the moment of choosing rather than sitting on the page forever.
10
+ */
11
+ export default function ScopeButton({ scope, disabled, disabledReason, isSubmitting, onChange, }: {
12
+ scope: Scope;
13
+ disabled?: boolean;
14
+ /** Why the control is disabled, shown on hover. */
15
+ disabledReason?: string;
16
+ isSubmitting?: boolean;
17
+ onChange: (scope: Scope) => Promise<unknown>;
18
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,12 @@
1
1
  import { ReactNode } from 'react';
2
2
  /**
3
- * Small uppercase section heading for consistent hierarchy across the
4
- * materialization views (detail dialog, manifest view). One source of truth for
5
- * the style so the headings can't drift. Renders as an <h6> so it is a real
6
- * heading (role="heading") — the caption styling is purely visual.
3
+ * A sub-heading INSIDE a materialization view — the detail dialog and the
4
+ * manifest view — where `PackageSection` does not apply: those are sections of
5
+ * a dialog, not of a page. Small and uppercase to sit a level under the
6
+ * dialog's own title.
7
+ *
8
+ * Renders as an `<h6>`, so it is a real heading to anything navigating by
9
+ * them; the caption styling is purely visual.
7
10
  */
8
11
  export default function SectionLabel({ children }: {
9
12
  children: ReactNode;
@@ -0,0 +1,14 @@
1
+ import { MaterializationMetadata } from './utils';
2
+ /**
3
+ * How a run was initiated — Scheduled (the standalone scheduler fired the
4
+ * package's cron) or Manual (an API or UI create) — with the tooltip that says
5
+ * which. One source of truth for the label, so the runs list and the detail
6
+ * dialog cannot drift.
7
+ *
8
+ * A word, like every other cell in the row. A two-value distinction needs no
9
+ * pictogram, and a bordered pill here made a value look like something to
10
+ * click.
11
+ */
12
+ export default function TriggerLabel({ meta, }: {
13
+ meta: MaterializationMetadata;
14
+ }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1 @@
1
1
  export { default as Materializations } from './Materializations';
2
- export { default as EnvironmentMaterializations } from './EnvironmentMaterializations';
@@ -5,11 +5,9 @@ export type ContentType = "report" | "model" | "data" | "materialization" | "dat
5
5
  * a page that lists all six, a shared color reads as a shared kind, and the
6
6
  * glyphs are small enough that color does most of the telling apart.
7
7
  *
8
- * The logo's three go to the three artifacts a reader opens to look at data,
9
- * dashboards and notebooks and the models under them, and the accents to the
10
- * rest, so the brand leads on the things the page is mostly for. Not a
11
- * seniority ranking: dashboards are the newest thing a package can hold, and
12
- * Package Data is among the oldest and takes an accent.
8
+ * Six hues from `PALETTE`, spaced far enough apart to survive being 18px of
9
+ * white on a 32px plate, and disjoint from the three `SURFACE_TINT` uses so a
10
+ * colour means one kind of thing everywhere in the Console.
13
11
  *
14
12
  * Exhaustive by type rather than by a default, so adding a `ContentType` is a
15
13
  * compile error here instead of a row that silently paints itself the same as