@malloy-publisher/sdk 0.2.7 → 0.3.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 (221) hide show
  1. package/README.md +180 -204
  2. package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
  3. package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
  4. package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
  5. package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
  6. package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
  7. package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
  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 +9561 -0
  11. package/dist/builder-entry.d.ts +8 -0
  12. package/dist/client/api.d.ts +13 -1
  13. package/dist/client/index.cjs.js +1 -1
  14. package/dist/client/index.es.js +1 -1
  15. package/dist/components/ApiErrorDisplay.d.ts +1 -2
  16. package/dist/components/Dashboard/Dashboard.d.ts +23 -16
  17. package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
  18. package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
  19. package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
  20. package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
  21. package/dist/components/Dashboard/TileCard.d.ts +44 -0
  22. package/dist/components/Dashboard/index.d.ts +2 -0
  23. package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
  24. package/dist/components/Dashboard/telemetry.d.ts +43 -0
  25. package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
  26. package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
  27. package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
  28. package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
  29. package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
  30. package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
  31. package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
  32. package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
  33. package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
  34. package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
  35. package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
  36. package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
  37. package/dist/components/DashboardBuilder/controls.d.ts +157 -0
  38. package/dist/components/DashboardBuilder/diff.d.ts +35 -0
  39. package/dist/components/DashboardBuilder/document.d.ts +218 -0
  40. package/dist/components/DashboardBuilder/layout.d.ts +71 -0
  41. package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
  42. package/dist/components/DashboardBuilder/preview.d.ts +60 -0
  43. package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
  44. package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
  45. package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
  46. package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
  47. package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
  48. package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
  49. package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
  50. package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
  51. package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
  52. package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
  53. package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
  54. package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
  55. package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
  56. package/dist/components/DocumentStorage/index.d.ts +3 -0
  57. package/dist/components/FloatingIconButton.d.ts +16 -0
  58. package/dist/components/Model/index.d.ts +0 -1
  59. package/dist/components/Prose.d.ts +46 -0
  60. package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
  61. package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
  62. package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
  63. package/dist/components/RenderedResult/index.d.ts +2 -0
  64. package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
  65. package/dist/components/drill/index.d.ts +2 -1
  66. package/dist/components/drill/resolveDrill.d.ts +22 -0
  67. package/dist/components/drill/useDrill.d.ts +11 -2
  68. package/dist/components/drill/useDrillSelf.d.ts +46 -0
  69. package/dist/components/given/filterValue.d.ts +63 -0
  70. package/dist/components/given/index.d.ts +1 -0
  71. package/dist/components/given/useGivenUrlParams.d.ts +39 -0
  72. package/dist/components/index.d.ts +3 -3
  73. package/dist/components/styles.d.ts +3 -7
  74. package/dist/core-8NVBCLZh.cjs.js +148 -0
  75. package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
  76. package/dist/hooks/index.d.ts +3 -1
  77. package/dist/hooks/useDocumentControls.d.ts +70 -0
  78. package/dist/hooks/useQueryResult.d.ts +40 -0
  79. package/dist/hooks/useSuggestOptions.d.ts +28 -12
  80. package/dist/index.cjs.js +34 -1
  81. package/dist/index.es.js +21487 -79
  82. package/dist/sdk.css +1 -1
  83. package/dist/styles.css +0 -1
  84. package/dist/utils/malloyLiteral.d.ts +11 -0
  85. package/package.json +25 -14
  86. package/src/builder-entry.ts +55 -0
  87. package/src/components/ApiErrorDisplay.tsx +1 -1
  88. package/src/components/Connections/EditConnectionDialog.tsx +96 -86
  89. package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
  90. package/src/components/Dashboard/Dashboard.tsx +184 -229
  91. package/src/components/Dashboard/DashboardGrid.tsx +124 -0
  92. package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
  93. package/src/components/Dashboard/DashboardTile.tsx +67 -101
  94. package/src/components/Dashboard/ExploreDialog.tsx +84 -0
  95. package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
  96. package/src/components/Dashboard/RowsDialog.tsx +234 -0
  97. package/src/components/Dashboard/TileCard.tsx +120 -0
  98. package/src/components/Dashboard/index.ts +2 -0
  99. package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
  100. package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
  101. package/src/components/Dashboard/telemetry.ts +44 -0
  102. package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
  103. package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
  104. package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
  105. package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
  106. package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
  107. package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
  108. package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
  109. package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
  110. package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
  111. package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
  112. package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
  113. package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
  114. package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
  115. package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
  116. package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
  117. package/src/components/DashboardBuilder/catalog.ts +225 -0
  118. package/src/components/DashboardBuilder/controls.spec.ts +243 -0
  119. package/src/components/DashboardBuilder/controls.ts +398 -0
  120. package/src/components/DashboardBuilder/diff.spec.ts +44 -0
  121. package/src/components/DashboardBuilder/diff.ts +93 -0
  122. package/src/components/DashboardBuilder/document.ts +209 -0
  123. package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
  124. package/src/components/DashboardBuilder/layout.ts +143 -0
  125. package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
  126. package/src/components/DashboardBuilder/malloyText.ts +151 -0
  127. package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
  128. package/src/components/DashboardBuilder/preview.spec.ts +149 -0
  129. package/src/components/DashboardBuilder/preview.ts +172 -0
  130. package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
  131. package/src/components/DashboardBuilder/readDocument.ts +467 -0
  132. package/src/components/DashboardBuilder/sortable.tsx +151 -0
  133. package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
  134. package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
  135. package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
  136. package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
  137. package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
  138. package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
  139. package/src/components/DashboardBuilder/useDraft.ts +43 -0
  140. package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
  141. package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
  142. package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
  143. package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
  144. package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
  145. package/src/components/DashboardBuilder/useTileResize.ts +110 -0
  146. package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
  147. package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
  148. package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
  149. package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
  150. package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
  151. package/src/components/DocumentStorage/index.ts +16 -0
  152. package/src/components/Environment/About.tsx +4 -36
  153. package/src/components/FloatingIconButton.tsx +41 -0
  154. package/src/components/Model/Model.tsx +6 -23
  155. package/src/components/Model/ModelCell.tsx +34 -72
  156. package/src/components/Model/index.ts +0 -1
  157. package/src/components/Notebook/Notebook.tsx +27 -156
  158. package/src/components/Notebook/NotebookCell.tsx +37 -191
  159. package/src/components/Prose.spec.tsx +85 -0
  160. package/src/components/Prose.tsx +179 -0
  161. package/src/components/QueryResult/QueryResult.tsx +15 -43
  162. package/src/components/RenderedResult/RenderedResult.tsx +86 -76
  163. package/src/components/RenderedResult/ResultContainer.tsx +25 -36
  164. package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
  165. package/src/components/RenderedResult/ResultPanel.tsx +73 -0
  166. package/src/components/RenderedResult/index.ts +16 -0
  167. package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
  168. package/src/components/RenderedResult/resultSizing.ts +308 -0
  169. package/src/components/ResultsDialog.tsx +2 -1
  170. package/src/components/drill/index.ts +6 -0
  171. package/src/components/drill/resolveDrill.ts +22 -1
  172. package/src/components/drill/useDrill.spec.tsx +94 -0
  173. package/src/components/drill/useDrill.tsx +52 -12
  174. package/src/components/drill/useDrillSelf.spec.tsx +64 -0
  175. package/src/components/drill/useDrillSelf.ts +110 -0
  176. package/src/components/given/GivenInput.spec.tsx +196 -2
  177. package/src/components/given/GivenInput.tsx +300 -25
  178. package/src/components/given/GivensPanel.tsx +1 -1
  179. package/src/components/given/filterValue.spec.ts +112 -0
  180. package/src/components/given/filterValue.ts +188 -0
  181. package/src/components/given/index.ts +4 -0
  182. package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
  183. package/src/components/given/useGivenUrlParams.ts +87 -0
  184. package/src/components/index.ts +11 -3
  185. package/src/components/styles.ts +0 -37
  186. package/src/hooks/index.ts +13 -1
  187. package/src/hooks/useDocumentControls.ts +170 -0
  188. package/src/hooks/useGivensState.spec.ts +158 -0
  189. package/src/hooks/useGivensState.ts +114 -23
  190. package/src/hooks/useQueryResult.ts +82 -0
  191. package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
  192. package/src/hooks/useSuggestOptions.ts +94 -51
  193. package/src/utils/malloyLiteral.spec.ts +43 -0
  194. package/src/utils/malloyLiteral.ts +76 -0
  195. package/vite.config.ts +5 -1
  196. package/dist/components/AnalyzePackageButton.d.ts +0 -6
  197. package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
  198. package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
  199. package/dist/components/Workbook/ModelPicker.d.ts +0 -11
  200. package/dist/components/Workbook/MutableCell.d.ts +0 -17
  201. package/dist/components/Workbook/Workbook.d.ts +0 -7
  202. package/dist/components/Workbook/WorkbookList.d.ts +0 -7
  203. package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
  204. package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
  205. package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
  206. package/dist/components/Workbook/index.d.ts +0 -7
  207. package/dist/core-CWKmWEg2.cjs.js +0 -148
  208. package/dist/index-B0WyZAUA.es.js +0 -66412
  209. package/dist/index-kxVD1RjY.cjs.js +0 -356
  210. package/dist/markdown-editor.css +0 -341
  211. package/src/components/AnalyzePackageButton.tsx +0 -319
  212. package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
  213. package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
  214. package/src/components/Workbook/ModelPicker.tsx +0 -134
  215. package/src/components/Workbook/MutableCell.tsx +0 -458
  216. package/src/components/Workbook/Workbook.tsx +0 -501
  217. package/src/components/Workbook/WorkbookList.tsx +0 -110
  218. package/src/components/Workbook/WorkbookManager.ts +0 -214
  219. package/src/components/Workbook/WorkbookStorage.ts +0 -35
  220. package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
  221. package/src/components/Workbook/index.ts +0 -10
@@ -0,0 +1,32 @@
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 is through the host's {@link DocumentStorage}, not to the package.
9
+ * The package dashboard is a read-only origin: editing works on a copy, the
10
+ * copy is saved where the host keeps documents (the Console's default is this
11
+ * browser), and "Export" hands the file back so it can be put in the package.
12
+ * That is the plan's copy-and-export model, and it needs no server write path.
13
+ * A host with no storage still gets the editor, without Save.
14
+ *
15
+ * What that costs is stated in the toolbar: a control added here is live in the
16
+ * editor (its value is written into each tile's query) but reaches the package
17
+ * only when the exported file does.
18
+ */
19
+ export interface DashboardEditorProps {
20
+ environmentName: string;
21
+ packageName: string;
22
+ /** The dashboard's slug: `overview`, not `dashboards/overview.malloy`. */
23
+ dashboardName: string;
24
+ /** Leave the editor: the host's "Done". Absent, no Done button. */
25
+ onExit?: () => void;
26
+ /**
27
+ * What the editor does — opened, saved, exported, refused — for the host
28
+ * to log or count; see `DashboardEvent`.
29
+ */
30
+ onEvent?: DashboardEventHandler;
31
+ }
32
+ 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;
@@ -0,0 +1,157 @@
1
+ import { DashboardDocument, DashboardTile, LocalGiven } from './document';
2
+ /**
3
+ * The builder's view of the dashboard's filter controls, and the pure edits it
4
+ * makes to them. Kept out of the component so every rule here has a test that
5
+ * needs no DOM.
6
+ *
7
+ * A control is a GIVEN some tile binds. It comes from one of two places, and
8
+ * the difference decides what the builder may do with it:
9
+ *
10
+ * - `dashboard` — declared in this file ({@link LocalGiven}). The builder owns
11
+ * it outright: add, retag, remove, and bind on any tile.
12
+ * - `model` — declared in the model and reaching this file through an import.
13
+ * The builder may bind it on tiles, because a binding is a refinement in this
14
+ * file, but it cannot change or remove the declaration, because the builder
15
+ * never edits imports or model files.
16
+ *
17
+ * Declaring in the dashboard is the convention; see {@link LocalGiven}.
18
+ */
19
+ export type ControlOrigin = "dashboard" | "model";
20
+ /** A given the builder can bind a tile to, from either origin. */
21
+ export interface BuilderGiven {
22
+ /** The given's name, as written after `$` in a `where:`. */
23
+ name: string;
24
+ label?: string;
25
+ /** The declared type, which decides how a binding compares; see {@link defaultOperator}. */
26
+ type?: string;
27
+ /**
28
+ * The field to compare against, used as the default when this given is
29
+ * bound to a tile. The dimension its control suggests over is the right
30
+ * guess — a `CATEGORY` control that suggests over `category` is almost
31
+ * always filtering `category` — and it is only a default: the binding is
32
+ * editable afterwards, because the tile's source may spell it differently.
33
+ */
34
+ field?: string;
35
+ }
36
+ export interface BuilderControl extends BuilderGiven {
37
+ origin: ControlOrigin;
38
+ /** The declaration, for a control this dashboard owns. */
39
+ local?: LocalGiven;
40
+ /** How many tiles bind it. Zero means declared but not yet a control. */
41
+ boundTiles: number;
42
+ }
43
+ /**
44
+ * Every control the builder can offer: the dashboard's own first, in file
45
+ * order, then the model's that the caller knows about. A model given that
46
+ * shares a name with a local one is the same control as far as any `where:` is
47
+ * concerned, and the local declaration is the one that binds — so it is not
48
+ * listed twice.
49
+ */
50
+ export declare function controlsOf(document: DashboardDocument, modelGivens?: readonly BuilderGiven[]): BuilderControl[];
51
+ /**
52
+ * How a binding to a given of this type compares.
53
+ *
54
+ * A `filter<…>` given is a filter EXPRESSION and binds with `~`, which is the
55
+ * common case and is left implicit on the binding. A plain-typed given is a
56
+ * VALUE: a `date` is "since", a `number` is "at least", a `string` is "equals".
57
+ * Measured: `created_at ~ $SINCE` does not compile against a `date` given.
58
+ */
59
+ export declare function defaultOperator(type: string | undefined): string | undefined;
60
+ /**
61
+ * Whether a given of `givenType` can compare a field of `fieldType` (the
62
+ * catalog's spelling: `string_type`, `number_type`, `date_type`, …).
63
+ *
64
+ * A `filter<string>` over a number field compiles nowhere and a `date` over a
65
+ * string field compares nothing, so the picker offers only the fields a control
66
+ * can take, and a binding to one it cannot is marked. Dates and timestamps
67
+ * compare with each other. Unknown on EITHER side is accepted: the catalog may
68
+ * carry no type, and a given of a type this does not know is not refused on
69
+ * that account.
70
+ */
71
+ export declare function acceptsField(givenType: string | undefined, fieldType: string | undefined): boolean;
72
+ /** `number_type` -> "a number", as a message would say it. */
73
+ export declare function typeLabel(type: string | undefined): string;
74
+ /**
75
+ * The control a field of this type naturally gets: a number range for a
76
+ * number, a date picker for a date, a pick-list for anything else. What the
77
+ * window switches a new control to when the field picked does not fit the kind
78
+ * it started with.
79
+ */
80
+ export declare function kindForFieldType(fieldType: string | undefined): ControlKind;
81
+ /** The comparisons a binding can use, with how a reader would say them. */
82
+ export declare const OPERATORS: ReadonlyArray<{
83
+ op: string;
84
+ label: string;
85
+ }>;
86
+ /**
87
+ * A given name from a field: `products.category` -> `CATEGORY`, and kept
88
+ * distinct from any name already taken.
89
+ */
90
+ export declare function givenNameFor(field: string, taken: Iterable<string>): string;
91
+ /** What kind of control a new filter is, in a reader's terms. */
92
+ export type ControlKind = "select" | "multiselect" | "text" | "number" | "date";
93
+ export declare const CONTROL_KINDS: ReadonlyArray<{
94
+ kind: ControlKind;
95
+ label: string;
96
+ hint: string;
97
+ }>;
98
+ /**
99
+ * A new control's declaration, from what the dialog asked.
100
+ *
101
+ * The picker's options come from the source the field lives on — the base of
102
+ * the tile's own extension — which the file necessarily already imports, so a
103
+ * `suggest` here always resolves and the builder never has to add an import.
104
+ */
105
+ export declare function newLocalGiven(spec: {
106
+ name: string;
107
+ label: string;
108
+ kind: ControlKind;
109
+ field: string;
110
+ /** The source to suggest over, for `select` and `multiselect`. */
111
+ source?: string;
112
+ /** A date's default, `YYYY-MM-DD`; a number range's bounds. */
113
+ dateDefault?: string;
114
+ range?: {
115
+ min: number;
116
+ max: number;
117
+ };
118
+ }): LocalGiven;
119
+ /** One tile's row in a control's mapping: whether it binds, and how. */
120
+ export interface MappingRow {
121
+ include: boolean;
122
+ field: string;
123
+ /** Absent means `~`; see {@link defaultOperator}. */
124
+ op?: string;
125
+ }
126
+ /**
127
+ * Which tiles can take a binding, and why the others cannot.
128
+ *
129
+ * A binding is a `+ { where: … }` refinement on the tile's declaration, so the
130
+ * tile has to BE a declaration this file owns that the reader will read back.
131
+ * That is the `reference` form only: an `inherited` tile is declared on the
132
+ * model's source, and an `inline` tile's body is a query, not a reference, so a
133
+ * refinement written onto it would not come back and the round-trip gate would
134
+ * refuse the whole save. Better to refuse the tick.
135
+ */
136
+ export declare const canBind: (tile: DashboardTile) => boolean;
137
+ /** The mapping a control has NOW, one row per tile, for the dialog to open on. */
138
+ export declare function mappingOf(document: DashboardDocument, control: {
139
+ name: string;
140
+ field?: string;
141
+ type?: string;
142
+ }): MappingRow[];
143
+ /**
144
+ * Apply a mapping: a DIFF against what each tile carries now — added where
145
+ * newly ticked, dropped where unticked, rewritten where only the field or the
146
+ * comparison changed. Mutates the draft; the caller makes it one history entry.
147
+ */
148
+ export declare function applyMapping(draft: DashboardDocument, given: string, rows: readonly MappingRow[]): void;
149
+ /** Declare a control in this dashboard, or replace its declaration by name. */
150
+ export declare function declareControl(draft: DashboardDocument, given: LocalGiven): void;
151
+ /**
152
+ * Take a control off the dashboard: every binding to it, and — when this file
153
+ * declares it — the declaration too. A model given keeps its declaration, which
154
+ * is not ours; it simply stops being a control here, because a control is a
155
+ * given some tile binds.
156
+ */
157
+ export declare function removeControl(draft: DashboardDocument, name: string): void;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * A line diff, for showing an author what a structural save will do to the
3
+ * file before it does it.
4
+ *
5
+ * Adding or removing a tile moves a declaration and the comment block above
6
+ * it, and the file cannot say whether that comment belonged to the tile, the
7
+ * row, or the page. The writer makes a defensible choice (a tile's `#` tags
8
+ * go with it; `//` comments stay), and this is what turns that choice from a
9
+ * silent one into one the author sees and approves.
10
+ *
11
+ * Longest-common-subsequence over lines: exact, and a dashboard file is a few
12
+ * hundred lines, so the quadratic table is small. Past `LIMIT` lines a side,
13
+ * the diff degrades to "everything changed" rather than stalling the page.
14
+ */
15
+ export type DiffLine = {
16
+ kind: "same";
17
+ text: string;
18
+ } | {
19
+ kind: "add";
20
+ text: string;
21
+ } | {
22
+ kind: "del";
23
+ text: string;
24
+ };
25
+ export declare function lineDiff(before: string, after: string): DiffLine[];
26
+ /**
27
+ * The diff with unchanged stretches folded, keeping `context` lines around
28
+ * every change — what a review tool shows, and all a reader needs to judge a
29
+ * save. A fold is one entry saying how many lines it hides.
30
+ */
31
+ export type DiffHunkLine = DiffLine | {
32
+ kind: "fold";
33
+ count: number;
34
+ };
35
+ export declare function foldUnchanged(lines: DiffLine[], context?: number): DiffHunkLine[];