@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,48 @@
1
+ /**
2
+ * What a dashboard surface reports about itself, for the host to log or
3
+ * count: the operations that matter (open, save, the rows behind a value,
4
+ * exploring a tile), each with its outcome and how long it took.
5
+ *
6
+ * Context-free on purpose — the host that mounted the surface knows which
7
+ * environment, package and dashboard it is, and adds that when it logs.
8
+ */
9
+ export type DashboardEvent = {
10
+ type: "dashboard.opened";
11
+ /** The package file, or a draft the host had saved. */
12
+ from: "package" | "draft";
13
+ tiles: number;
14
+ durationMs: number;
15
+ } | {
16
+ type: "dashboard.open_refused";
17
+ reason: string;
18
+ } | {
19
+ type: "dashboard.saved";
20
+ tiles: number;
21
+ /** Whether a tile was added or removed, which moves declarations. */
22
+ structural: boolean;
23
+ /**
24
+ * Where it went. A save into the package is a change every reader of
25
+ * that server sees; a browser save is one person's copy on one
26
+ * machine. Counting them together makes "dashboards are being edited"
27
+ * unreadable, because a read-only server reports exactly as much
28
+ * saving as a writable one.
29
+ */
30
+ where: "package" | "browser";
31
+ durationMs: number;
32
+ } | {
33
+ type: "dashboard.save_refused";
34
+ reason: string;
35
+ } | {
36
+ type: "dashboard.rows_shown";
37
+ source: string;
38
+ view: string;
39
+ field: string;
40
+ ok: boolean;
41
+ durationMs: number;
42
+ } | {
43
+ type: "dashboard.explored";
44
+ tile: string;
45
+ };
46
+ export type DashboardEventHandler = (event: DashboardEvent) => void;
47
+ /** A monotonic clock in milliseconds, for durations. */
48
+ export declare const now: () => number;
@@ -0,0 +1,35 @@
1
+ import { PackageCatalog } from './catalog';
2
+ import { DashboardDocument } from './document';
3
+ /**
4
+ * What a new tile is: a view, picked from the package, on a source this file
5
+ * can reach.
6
+ *
7
+ * The picker is what makes a tile expression correct BY CONSTRUCTION. Every
8
+ * `source -> view` it offers came from the catalog, so the builder never emits
9
+ * a tile that does not resolve — which is why saving needs no compile step
10
+ * beyond the reader's own round-trip.
11
+ *
12
+ * "Can reach" is the rule the writer enforces and the reason some sources are
13
+ * not offered: a tile's view is declared in an extension of a model source, and
14
+ * that source has to be in this file's scope. The builder never adds an
15
+ * import, so a model source is offered only when the file already extends it,
16
+ * or imports it BY NAME. A bare `import "../m.malloy"` may well bring it in,
17
+ * but the file cannot say so, and a guess here fails the whole package load.
18
+ */
19
+ export interface NewTile {
20
+ /** The model source the view lives on. */
21
+ base: string;
22
+ /** The view, as the catalog names it. */
23
+ view: string;
24
+ label?: string;
25
+ colspan: number;
26
+ }
27
+ export interface AddTileDialogProps {
28
+ open: boolean;
29
+ document: DashboardDocument;
30
+ catalog: PackageCatalog | undefined;
31
+ columns: number;
32
+ onClose: () => void;
33
+ onAdd: (tile: NewTile) => void;
34
+ }
35
+ export declare function AddTileDialog({ open, document, catalog, columns, onClose, onAdd, }: AddTileDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,31 @@
1
+ import { ReactNode } from 'react';
2
+ /**
3
+ * The edit bar across the top of the builder: that you are editing on the
4
+ * left, what you can do about it on the right, in the same {@link DashboardBar}
5
+ * the reader's view uses, so switching modes swaps the contents of one bar
6
+ * rather than replacing one bar with a different one.
7
+ *
8
+ * The right-hand controls are grouped by what they do, separated rather than
9
+ * run together: change the page (a tile, its settings), take a change back or
10
+ * put it down (undo, redo, save), and leave (Done, where the reader's view has
11
+ * Edit). Sticky, so undo and save stay in reach on a long dashboard; the
12
+ * reader's own header (title and description) stays in the page below it
13
+ * rather than being repeated here.
14
+ */
15
+ export interface BuilderToolbarProps {
16
+ canUndo: boolean;
17
+ canRedo: boolean;
18
+ onUndo: () => void;
19
+ onRedo: () => void;
20
+ dirty: boolean;
21
+ saving: boolean;
22
+ /** Absent when the builder has nowhere to save: no Save, no unsaved marker. */
23
+ onSave?: () => void;
24
+ /** The host's way out of editing: Done, at the right edge. */
25
+ actions?: ReactNode;
26
+ /** Open the add-tile picker. Absent when the host passed no catalog to pick from. */
27
+ onAddTile?: () => void;
28
+ /** Open the page's settings, anchored to the button that asked. */
29
+ onSettings: (anchor: HTMLElement) => void;
30
+ }
31
+ export declare function BuilderToolbar({ canUndo, canRedo, onUndo, onRedo, dirty, saving, onSave, actions, onAddTile, onSettings, }: BuilderToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,118 @@
1
+ import { ReactNode } from 'react';
2
+ import { DashboardEventHandler } from '../Dashboard/telemetry';
3
+ import { BuilderGiven } from './controls';
4
+ import { PackageCatalog } from './catalog';
5
+ import { DashboardDocument, DashboardTile } from './document';
6
+ export type { BuilderGiven } from './controls';
7
+ /**
8
+ * The dashboard builder's editing surface.
9
+ *
10
+ * Lays the tiles out on the SAME grid the dashboard renders on — literally the
11
+ * same component, `DashboardGrid`, rather than a grid restated here to match.
12
+ * What you arrange is what a reader will see, and the two cannot drift.
13
+ *
14
+ * The TILE ITSELF is the caller's business, through `renderTile`. A tile's
15
+ * result comes from running a query, and where that query runs differs between
16
+ * a saved package dashboard and an unsaved draft; keeping it out here means the
17
+ * editing surface can be mounted, tested and reviewed without a server.
18
+ *
19
+ * `renderTile` replaces the tile rather than filling it, because `DashboardTile`
20
+ * draws its own card AND its own heading. Nesting one inside a card of ours
21
+ * would show a card in a card under two titles — which is precisely not what a
22
+ * reader sees. So every affordance is drawn AROUND whatever the caller renders:
23
+ * an outline for selection, a grip and a menu in the corners, a handle at the
24
+ * edge.
25
+ *
26
+ * **Everything here is on the thing it changes.** Drag a tile's right edge to
27
+ * set its width, and the tile itself to reorder — into the empty end of a row
28
+ * to change which row it is in. The tile's own menu holds its title and
29
+ * subtitle. FILTERS are configured in exactly one place, the strip under the
30
+ * header: each chip opens the tiles-to-update window for that control,
31
+ * which is where a tile is bound or unbound, and "Add filter" declares a new
32
+ * one in this file — the convention {@link LocalGiven} describes — or binds one
33
+ * the model offers. Nothing about filters is on the tiles themselves: a second
34
+ * place to edit the same binding is a second place for it to be wrong.
35
+ *
36
+ * Tiles are added from the package's catalog and removed from their menu; a
37
+ * save that adds or removes one shows the file's diff first, because those
38
+ * moves relocate declarations and the comments beside them.
39
+ */
40
+ export interface DashboardBuilderProps {
41
+ /** The file being edited. */
42
+ source: string;
43
+ /** The document that file produced. */
44
+ document: DashboardDocument;
45
+ /** Persist the patched file. Left out, the builder edits without saving. */
46
+ onSave?: (source: string) => Promise<void> | void;
47
+ /**
48
+ * The document as it stands, on every edit — including the first render.
49
+ *
50
+ * For the host's LIVE VIEW. A tile's result and the control row are the
51
+ * host's to render (`renderTile`, `controls`), and both have to follow the
52
+ * document rather than the saved file, or an edit looks like it did
53
+ * nothing: unbinding a tile left it filtering, removing a control left it
54
+ * in the row. `preview.ts` turns the document handed here into what a reader
55
+ * would see.
56
+ */
57
+ onChange?: (document: DashboardDocument) => void;
58
+ /**
59
+ * Renders a tile, card and heading included — this is where a real
60
+ * `DashboardTile` goes. Without it, tiles show what they will run.
61
+ */
62
+ renderTile?: (tile: DashboardTile) => ReactNode;
63
+ /**
64
+ * The control row, in the slot the reader puts it — this is where a real
65
+ * `GivensPanel` goes.
66
+ *
67
+ * A seam for the same reason as `renderTile`, and not an oversight: a
68
+ * control's SPEC (its type, its control tag, its suggestions) is resolved by
69
+ * the server across the model and everything it imports, and a
70
+ * `DashboardDocument` holds only what this one file declares. The storefront
71
+ * dashboard is the ordinary case — it imports every given from
72
+ * `../givens.malloy` — so a bar built from the document alone would come up
73
+ * empty and claim the dashboard has no filters. Better to let a caller that
74
+ * has the manifest hand over the real one.
75
+ *
76
+ * It matters to LAYOUT, not just to fidelity: the bar takes vertical space
77
+ * above the grid, so an author arranging tiles without it is arranging
78
+ * against a page the reader never sees.
79
+ */
80
+ controls?: ReactNode;
81
+ /**
82
+ * Givens a tile can be bound to, for the palette above the grid.
83
+ *
84
+ * A prop for the same reason as `controls`: which givens exist is resolved
85
+ * by the server across the model and its imports, and a `DashboardDocument`
86
+ * knows only what its own file declares.
87
+ */
88
+ givens?: BuilderGiven[];
89
+ /**
90
+ * What the package offers, for the filter window to SEARCH a field rather
91
+ * than take one on trust: the dimensions of the source the tiles read are
92
+ * offered, an unknown name is marked where it stands, and a binding to a
93
+ * field the source does not have cannot be applied. Absent, any name is
94
+ * accepted — a binding to a missing field then fails at package load, which
95
+ * is the worst place for it.
96
+ */
97
+ catalog?: PackageCatalog;
98
+ /**
99
+ * The other dashboards in the package, by slug — where a clicked cell can
100
+ * go. Absent, a drill can only filter this dashboard.
101
+ */
102
+ dashboards?: string[];
103
+ /** Saves and refusals, for the host to log; see `DashboardEvent`. */
104
+ onEvent?: DashboardEventHandler;
105
+ /**
106
+ * Where `onSave` puts the file, for the event it reports. The builder
107
+ * cannot tell — it is handed a function — and a save into the package and a
108
+ * save into this browser are not the same event.
109
+ */
110
+ savesTo?: "package" | "browser";
111
+ /**
112
+ * The host's own actions for the edit bar — Done — rendered beside
113
+ * undo, redo and save. The builder owns the edits; where the file goes
114
+ * afterwards is the host's, so its buttons sit in the host's slot.
115
+ */
116
+ toolbar?: ReactNode;
117
+ }
118
+ export declare function DashboardBuilder({ source, document, onSave, onChange, renderTile, controls, givens, catalog, toolbar, dashboards, onEvent, savesTo, }: DashboardBuilderProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import { DashboardEventHandler } from '../Dashboard/telemetry';
2
+ /**
3
+ * The builder, opened on a package dashboard, with everything a host has to
4
+ * supply already wired: the file's text and manifest from the server, a live
5
+ * control row and live tiles that follow the document, a catalog for the
6
+ * filter window's field search, and saving.
7
+ *
8
+ * SAVING goes to the package on a server that takes writes, and otherwise to
9
+ * the host's {@link DocumentStorage} — the Console's default is this browser,
10
+ * where the copy is offered back on the next visit. A host with neither still
11
+ * gets the editor, without Save.
12
+ *
13
+ * What that costs is stated in the toolbar: a control added here is live in the
14
+ * editor (its value is written into each tile's query) but reaches the package
15
+ * only when the file is saved into it.
16
+ */
17
+ export interface DashboardEditorProps {
18
+ environmentName: string;
19
+ packageName: string;
20
+ /** The dashboard's slug: `overview`, not `dashboards/overview.malloy`. */
21
+ dashboardName: string;
22
+ /** Leave the editor: the host's "Done editing". Absent, no such button. */
23
+ onExit?: () => void;
24
+ /**
25
+ * What the editor does — opened, saved, refused — for the host to log or
26
+ * count; see `DashboardEvent`.
27
+ */
28
+ onEvent?: DashboardEventHandler;
29
+ }
30
+ export declare function DashboardEditor({ environmentName, packageName, dashboardName, onExit, onEvent, }: DashboardEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * What a save will do to the file, before it does it.
3
+ *
4
+ * Shown for a STRUCTURAL save — a tile added or removed — because those move
5
+ * declarations and the comments beside them, and the file is git-native: a
6
+ * diff is the idiom its authors already read. A property edit never needs
7
+ * this; it changes one tag on one line.
8
+ */
9
+ export declare function DiffDialog({ open, before, after, onConfirm, onClose, }: {
10
+ open: boolean;
11
+ before: string;
12
+ after: string;
13
+ onConfirm: () => void;
14
+ onClose: () => void;
15
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { DashboardDocument, DashboardDrill, DashboardSource } from './document';
2
+ export interface DrillDialogProps {
3
+ open: boolean;
4
+ document: DashboardDocument;
5
+ /** The tile's source: the extension whose dimensions are offered. */
6
+ source: DashboardSource | undefined;
7
+ /** The controls a click can write into: the dashboard's and the model's. */
8
+ givenNames: string[];
9
+ /** Other dashboards in the package, by slug, as `to=` destinations. */
10
+ dashboards: string[];
11
+ onClose: () => void;
12
+ /** Every drill on `source`, replacing what the document had for it. */
13
+ onApply: (drills: DashboardDrill[]) => void;
14
+ }
15
+ export declare function DrillDialog({ open, document, source, givenNames, dashboards, onClose, onApply, }: DrillDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,54 @@
1
+ import { CatalogField } from './catalog';
2
+ import { BuilderControl, MappingRow } from './controls';
3
+ import { DashboardDocument, DashboardTile, LocalGiven } from './document';
4
+ /**
5
+ * A filter control: what it is, and which tiles it drives.
6
+ *
7
+ * Two questions, asked in that order and nothing else. WHAT: its label, and
8
+ * the field it filters on — one field, because a control almost always filters
9
+ * the same field on every tile, and the case where it does not is one click
10
+ * away ("Adjust per tile"), not five text boxes on every open. WHICH: a list
11
+ * of the dashboard's tiles with a checkbox each, and one checkbox over them
12
+ * all. A tile that cannot take a filter says why in place.
13
+ *
14
+ * The field is SEARCHED, not typed blind, when the host has handed over the
15
+ * source's fields: the picker offers the dimensions the tiles' source has,
16
+ * an unknown name is marked as such where it stands, and Apply waits until
17
+ * every ticked tile's field resolves. A binding to a field that does not exist
18
+ * fails at package load, which is the worst place for it to fail; here it
19
+ * cannot be written.
20
+ *
21
+ * The same window adds, edits and removes. It opens on the mapping the control
22
+ * has NOW, so unticking a tile unbinds it, and a control this dashboard
23
+ * declares can be taken off the page from here.
24
+ *
25
+ * What it writes is the convention {@link LocalGiven} describes: a new control
26
+ * is a `given:` declared in this file, bound on each ticked tile as a
27
+ * `+ { where: field ~ $GIVEN }` refinement. A control the model declares can be
28
+ * bound here but not changed, since the builder never edits model files.
29
+ */
30
+ export interface FilterDialogProps {
31
+ open: boolean;
32
+ document: DashboardDocument;
33
+ /** The control being edited, or undefined to add one. */
34
+ control?: BuilderControl;
35
+ /** Model givens not yet bound anywhere, offered as "from the model". */
36
+ available: readonly BuilderControl[];
37
+ /**
38
+ * The fields a binding on THIS tile may name: the dimensions of the source
39
+ * it reads. Per tile, because a composite dashboard exists to span sources,
40
+ * and a field one source has another may not. Undefined for a tile whose
41
+ * source the host has no catalog for, in which case any name is accepted
42
+ * for it and nothing is searched.
43
+ */
44
+ fieldsFor?: (tile: DashboardTile) => readonly CatalogField[] | undefined;
45
+ onClose: () => void;
46
+ /**
47
+ * Bind a control. `declare` is set when the control is new to this file, or
48
+ * when its declaration changed, and is the declaration to write.
49
+ */
50
+ onApply: (given: string, rows: MappingRow[], declare?: LocalGiven) => void;
51
+ /** Take a control off the dashboard; offered for one this file declares. */
52
+ onRemove: (given: string) => void;
53
+ }
54
+ export declare function FilterDialog({ open, document, control, available, fieldsFor, onClose, onApply, onRemove, }: FilterDialogProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { ReactNode } from 'react';
2
+ import { BuilderControl } from './controls';
3
+ /**
4
+ * The strip under the header where the dashboard's controls are configured —
5
+ * the ONE place: a chip per control opens its window, and "Add filter"
6
+ * declares a new one. The live control row the host renders sits under it.
7
+ */
8
+ export declare function FilterStrip({ controls: controlList, tileCount, unknownFieldsOf, onEdit, onAdd, children, }: {
9
+ controls: BuilderControl[];
10
+ tileCount: number;
11
+ /** Bindings a control has that its tiles' sources cannot take. */
12
+ unknownFieldsOf: (name: string, type: string | undefined) => string[];
13
+ onEdit: (control: BuilderControl) => void;
14
+ onAdd: () => void;
15
+ /** The host's live control row. */
16
+ children?: ReactNode;
17
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import { DashboardDocument } from './document';
2
+ /**
3
+ * The page's own settings, off the edit bar: its title, the markdown
4
+ * description under it, the grid's width, and whether controls run as they
5
+ * change or behind an Apply button. Edits commit on close (`useDraft`).
6
+ */
7
+ export interface PageSettings {
8
+ title: string;
9
+ description?: string;
10
+ columns?: number;
11
+ autorun?: boolean;
12
+ }
13
+ export declare const settingsOf: (document: DashboardDocument) => PageSettings;
14
+ export declare function SettingsPopover({ anchor, settings, onClose, onCommit, }: {
15
+ anchor: HTMLElement | null;
16
+ settings: PageSettings;
17
+ onClose: () => void;
18
+ /** Called once, on close, only when something changed. */
19
+ onCommit: (next: PageSettings) => void;
20
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { PointerEvent, ReactNode } from 'react';
2
+ import { DashboardTile } from './document';
3
+ /**
4
+ * Everything the builder draws AROUND a tile: the selection outline, the grip,
5
+ * the menu button, the resize badge and the handle at the right edge. The tile
6
+ * itself is `children` — the host's real `DashboardTile`, or a placeholder
7
+ * saying what the tile will run.
8
+ */
9
+ export declare function TileFrame({ tile, index, selected, menuOpen, resizeSpan, columns, onSelect, onOpenMenu, onResizeStart, onResizeMove, onResizeEnd, children, }: {
10
+ tile: DashboardTile;
11
+ index: number;
12
+ selected: boolean;
13
+ /** Whether this tile's menu is open, which keeps its button showing. */
14
+ menuOpen: boolean;
15
+ /** The width being previewed while THIS tile is resized. */
16
+ resizeSpan: number | undefined;
17
+ columns: number;
18
+ onSelect: () => void;
19
+ onOpenMenu: (anchor: HTMLElement) => void;
20
+ onResizeStart: (event: PointerEvent<HTMLDivElement>) => void;
21
+ onResizeMove: (event: PointerEvent<HTMLDivElement>) => void;
22
+ onResizeEnd: (event: PointerEvent<HTMLDivElement>) => void;
23
+ children: ReactNode;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ /**
26
+ * No host-supplied tile: say what this one will run, so the surface is still
27
+ * legible without a server.
28
+ */
29
+ export declare function TilePlaceholder({ tile }: {
30
+ tile: DashboardTile;
31
+ }): import("react/jsx-runtime").JSX.Element;
32
+ /** The empty end of a row, made a drop target while a drag is live. */
33
+ export declare function GapTarget({ after }: {
34
+ after: string;
35
+ }): import("react/jsx-runtime").JSX.Element;
36
+ /**
37
+ * Column guides, drawn only during a gesture: a flow grid is invisible until
38
+ * you are trying to land on it.
39
+ */
40
+ export declare function GridGuides({ columns }: {
41
+ columns: number;
42
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { DashboardTile } from './document';
2
+ /**
3
+ * A tile's own settings, on the tile: a popover off its menu button, so
4
+ * editing it never means scrolling away from it. Its title, subtitle, width
5
+ * presets, clickable cells and removal. Its row is set by dragging it — a drop
6
+ * into the empty end of a row is what "start a new row" means — and its card
7
+ * is the reader's to decide, so neither is a toggle here. Which controls it
8
+ * answers to is not here either: filters are configured in one place, the
9
+ * strip under the header. Edits commit on close (`useDraft`).
10
+ */
11
+ export interface TileMenuProps {
12
+ anchor: HTMLElement | null;
13
+ tile: DashboardTile | undefined;
14
+ onClose: () => void;
15
+ /** Apply the edited tile. Called once, on close, only when something changed. */
16
+ onCommit: (next: DashboardTile) => void;
17
+ /** Take the tile off the dashboard. Offered on every tile: order is this file's. */
18
+ onRemove: () => void;
19
+ /** The grid's width, which the width presets are fractions of. */
20
+ columns: number;
21
+ /** Open the clickable-cells window for this tile's source. */
22
+ onDrills: () => void;
23
+ }
24
+ export declare function TileMenu({ anchor, tile, onClose, onCommit, onRemove, columns, onDrills, }: TileMenuProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,62 @@
1
+ import { CompiledModel } from '../../client';
2
+ /**
3
+ * What a package offers a dashboard: the sources, the views on them, and the
4
+ * fields a drill can be declared on.
5
+ *
6
+ * This is what makes a tile expression correct BY CONSTRUCTION. The builder only
7
+ * ever offers `source -> view` pairs that came from here, so it cannot emit a
8
+ * tile that does not resolve — which is the reason validation needs nothing more
9
+ * than the existing compile endpoint.
10
+ *
11
+ * Shaped from the models endpoint as it is, rather than from a new one. The cost
12
+ * is that annotations arrive RAW — `'# bar_chart\n'`, `'#(doc) Revenue by
13
+ * category\n'` — so the small amount of reading below happens here instead of on
14
+ * the server.
15
+ */
16
+ export interface CatalogField {
17
+ name: string;
18
+ kind: "dimension" | "measure";
19
+ type?: string;
20
+ }
21
+ export interface CatalogView {
22
+ name: string;
23
+ /** From a `#(doc)` annotation, which is what a picker should show. */
24
+ description?: string;
25
+ /** `bar_chart`, `line_chart`, `shape_map`, … if the view declares one. */
26
+ chart?: string;
27
+ }
28
+ export interface CatalogSource {
29
+ name: string;
30
+ /** The model that declares it, which is what a preview runs against. */
31
+ modelPath: string;
32
+ description?: string;
33
+ views: CatalogView[];
34
+ /**
35
+ * The givens this source is scoped by, which is also the control row a tile
36
+ * reading it will show — measured equal to the manifest's per-tile
37
+ * `givenNames` for the `source -> view` form.
38
+ */
39
+ givens: string[];
40
+ /** For declaring a `# drill` dimension. */
41
+ fields: CatalogField[];
42
+ }
43
+ export interface PackageCatalog {
44
+ sources: CatalogSource[];
45
+ }
46
+ /** `#(doc) Revenue by product category\n` -> `Revenue by product category`. */
47
+ export declare function docOf(annotations: string[] | undefined): string | undefined;
48
+ /** `# bar_chart\n` -> `bar_chart`. Only the renderer's own chart tags count. */
49
+ export declare function chartOf(annotations: string[] | undefined): string | undefined;
50
+ /**
51
+ * The fields a filter on `source` may name: its dimensions, joins included as
52
+ * paths. Measures are not filterable with `where:` and are left out. Undefined
53
+ * when the catalog has no such source, which a picker reads as "no list".
54
+ */
55
+ export declare function filterableFields(catalog: PackageCatalog | undefined, source: string | undefined): CatalogField[] | undefined;
56
+ /**
57
+ * A dashboard file is itself a model, so the endpoint lists it alongside the
58
+ * real ones. Offering a dashboard's own tile views as things to put on a
59
+ * dashboard would be circular, so they are left out.
60
+ */
61
+ export declare const isDashboardModel: (path: string | undefined) => boolean;
62
+ export declare function buildCatalog(models: CompiledModel[]): PackageCatalog;