@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
package/README.md CHANGED
@@ -18,10 +18,10 @@ The Publisher SDK (`@malloy-publisher/sdk`) is a comprehensive React component l
18
18
  7. [Dimensional Filters](#dimensional-filters)
19
19
  8. [Hooks](#hooks)
20
20
  9. [Utilities](#utilities)
21
- 10. [Workbook Storage](#workbook-storage)
22
- 11. [Styling](#styling)
23
- 12. [Building a Custom Data App](#building-a-custom-data-app)
24
- 13. [API Reference](#api-reference)
21
+ 10. [Document Storage](#document-storage)
22
+ 11. [Styling](#styling)
23
+ 12. [Building a Custom Data App](#building-a-custom-data-app)
24
+ 13. [API Reference](#api-reference)
25
25
 
26
26
  ---
27
27
 
@@ -40,6 +40,14 @@ yarn add @malloy-publisher/sdk
40
40
 
41
41
  ---
42
42
 
43
+ ### Peer dependencies
44
+
45
+ The SDK expects the host to provide React and the Malloy packages it renders
46
+ with, including `@malloydata/malloy`. The Malloy parser is only loaded when the
47
+ dashboard builder opens (it is imported lazily, about 440 KB gzipped), so an
48
+ app that never opens the builder never downloads it — but the package still has
49
+ to be installed, or that one dynamic import fails at open time.
50
+
43
51
  ## Quick Start
44
52
 
45
53
  ### Basic Setup
@@ -51,7 +59,9 @@ import "@malloy-publisher/sdk/styles.css";
51
59
  function App() {
52
60
  return (
53
61
  <ServerProvider baseURL="http://localhost:4000/api/v0">
54
- <Home onClickEnvironment={(path) => console.log("Navigate to:", path)} />
62
+ <Home
63
+ onClickEnvironment={(path) => console.log("Navigate to:", path)}
64
+ />
55
65
  </ServerProvider>
56
66
  );
57
67
  }
@@ -169,7 +179,6 @@ ServerProvider (required wrapper)
169
179
  │ └── Package (show models, notebooks, connections)
170
180
  │ ├── Model (visual query builder + named queries)
171
181
  │ └── Notebook (read-only notebook viewer)
172
- └── Workbook (interactive analysis workbook)
173
182
  ```
174
183
 
175
184
  ### Navigation Pattern
@@ -200,7 +209,7 @@ The `ServerProvider` is the required context provider that wraps your applicatio
200
209
  | ---------------- | ----------------------- | ------------- | -------------------------------------------------------------------- |
201
210
  | `baseURL` | `string` | Auto-detected | Base URL of the Publisher API (e.g., `http://localhost:4000/api/v0`) |
202
211
  | `getAccessToken` | `() => Promise<string>` | `undefined` | Async function returning auth token |
203
- | `mutable` | `boolean` | `true` | Enable/disable environment/package management UI |
212
+ | `mutable` | `boolean` | `true` | Enable/disable environment/package management UI |
204
213
 
205
214
  ### Basic Usage
206
215
 
@@ -463,48 +472,6 @@ const resourceUri = encodeResourceUri({
463
472
 
464
473
  ---
465
474
 
466
- ### Workbook
467
-
468
- Interactive workbook editor for creating and saving custom analyses.
469
-
470
- ```tsx
471
- import {
472
- Workbook,
473
- WorkbookStorageProvider,
474
- BrowserWorkbookStorage,
475
- encodeResourceUri,
476
- } from "@malloy-publisher/sdk";
477
-
478
- interface WorkbookProps {
479
- workbookPath?: WorkbookLocator; // { path: string, workspace: string }
480
- resourceUri: string;
481
- }
482
-
483
- // Usage
484
- const workbookStorage = new BrowserWorkbookStorage();
485
- const resourceUri = encodeResourceUri({
486
- environmentName: "my-environment",
487
- packageName: "analytics",
488
- });
489
-
490
- <WorkbookStorageProvider workbookStorage={workbookStorage}>
491
- <Workbook
492
- workbookPath={{ path: "my-analysis", workspace: "Local" }}
493
- resourceUri={resourceUri}
494
- />
495
- </WorkbookStorageProvider>;
496
- ```
497
-
498
- **Features:**
499
-
500
- - Add/remove Markdown and Malloy cells
501
- - Model picker for source selection
502
- - Auto-save to storage backend
503
- - Export to Malloy format
504
- - Delete workbook
505
-
506
- ---
507
-
508
475
  ## Query & Results Components
509
476
 
510
477
  ### QueryResult
@@ -610,13 +577,13 @@ component does not use this mechanism; see [Notebooks use `given:`](#notebooks-u
610
577
 
611
578
  ### Filter Types
612
579
 
613
- | Type | UI Component | Use Case |
614
- |------|--------------|----------|
615
- | `Star` | Multi-select dropdown | String fields with discrete values |
616
- | `MinMax` | Range slider | Numeric fields |
617
- | `DateMinMax` | Date range picker | Date/timestamp fields |
618
- | `Retrieval` | Semantic search input | Free-text semantic search |
619
- | `Boolean` | Toggle switch | Boolean fields |
580
+ | Type | UI Component | Use Case |
581
+ | ------------ | --------------------- | ---------------------------------- |
582
+ | `Star` | Multi-select dropdown | String fields with discrete values |
583
+ | `MinMax` | Range slider | Numeric fields |
584
+ | `DateMinMax` | Date range picker | Date/timestamp fields |
585
+ | `Retrieval` | Semantic search input | Free-text semantic search |
586
+ | `Boolean` | Toggle switch | Boolean fields |
620
587
 
621
588
  ### Source Declaration Syntax
622
589
 
@@ -699,34 +666,52 @@ For custom data apps, use the SDK's React hooks:
699
666
 
700
667
  ```tsx
701
668
  import {
702
- useDimensionFiltersFromSpec,
703
- DimensionFiltersConfig
704
- } from '@malloy-publisher/sdk';
669
+ useDimensionFiltersFromSpec,
670
+ DimensionFiltersConfig,
671
+ } from "@malloy-publisher/sdk";
705
672
 
706
673
  const config: DimensionFiltersConfig = {
707
- environment: "malloy-samples",
708
- package: "faa",
709
- indexLimit: 1000,
710
- dimensionSpecs: [
711
- { dimensionName: "origin_code", filterType: "Star", source: "flights", model: "flights.malloy", label: "Origin Airport" },
712
- { dimensionName: "distance", filterType: "MinMax", source: "flights", model: "flights.malloy", label: "Distance (miles)" },
713
- { dimensionName: "dep_time", filterType: "DateMinMax", source: "flights", model: "flights.malloy", label: "Departure Time" },
714
- ],
674
+ environment: "malloy-samples",
675
+ package: "faa",
676
+ indexLimit: 1000,
677
+ dimensionSpecs: [
678
+ {
679
+ dimensionName: "origin_code",
680
+ filterType: "Star",
681
+ source: "flights",
682
+ model: "flights.malloy",
683
+ label: "Origin Airport",
684
+ },
685
+ {
686
+ dimensionName: "distance",
687
+ filterType: "MinMax",
688
+ source: "flights",
689
+ model: "flights.malloy",
690
+ label: "Distance (miles)",
691
+ },
692
+ {
693
+ dimensionName: "dep_time",
694
+ filterType: "DateMinMax",
695
+ source: "flights",
696
+ model: "flights.malloy",
697
+ label: "Departure Time",
698
+ },
699
+ ],
715
700
  };
716
701
 
717
702
  function FilteredDashboard() {
718
- const {
719
- filterStates, // Current filter values
720
- updateFilter, // Update a single filter
721
- clearAllFilters, // Reset all filters
722
- activeFilters, // Array of active filter selections
723
- data, // Dimension values for dropdowns/sliders
724
- isLoading, // Loading state
725
- executeQuery, // Run query with current filters
726
- queryString, // Generated Malloy query
727
- } = useDimensionFiltersFromSpec(config);
728
-
729
- // Render filter UI and results...
703
+ const {
704
+ filterStates, // Current filter values
705
+ updateFilter, // Update a single filter
706
+ clearAllFilters, // Reset all filters
707
+ activeFilters, // Array of active filter selections
708
+ data, // Dimension values for dropdowns/sliders
709
+ isLoading, // Loading state
710
+ executeQuery, // Run query with current filters
711
+ queryString, // Generated Malloy query
712
+ } = useDimensionFiltersFromSpec(config);
713
+
714
+ // Render filter UI and results...
730
715
  }
731
716
  ```
732
717
 
@@ -734,14 +719,14 @@ function FilteredDashboard() {
734
719
 
735
720
  Filters support different match types depending on the filter type:
736
721
 
737
- | Match Type | Description | Applicable To |
738
- |------------|-------------|---------------|
739
- | `Equals` | Exact match (multi-select supported) | Star, Retrieval |
740
- | `Contains` | Substring match | Star |
741
- | `Greater Than` / `Less Than` | Comparison | MinMax |
742
- | `Between` | Range (inclusive) | MinMax, DateMinMax |
743
- | `After` / `Before` | Date comparison | DateMinMax |
744
- | `Semantic Search` | Semantic similarity | Retrieval |
722
+ | Match Type | Description | Applicable To |
723
+ | ---------------------------- | ------------------------------------ | ------------------ |
724
+ | `Equals` | Exact match (multi-select supported) | Star, Retrieval |
725
+ | `Contains` | Substring match | Star |
726
+ | `Greater Than` / `Less Than` | Comparison | MinMax |
727
+ | `Between` | Range (inclusive) | MinMax, DateMinMax |
728
+ | `After` / `Before` | Date comparison | DateMinMax |
729
+ | `Semantic Search` | Semantic similarity | Retrieval |
745
730
 
746
731
  ---
747
732
 
@@ -829,7 +814,8 @@ import { useMutationWithApiError } from "@malloy-publisher/sdk";
829
814
  function MyComponent() {
830
815
  const mutation = useMutationWithApiError({
831
816
  mutationFn: async (newEnvironment) => {
832
- const response = await apiClients.environments.createEnvironment(newEnvironment);
817
+ const response =
818
+ await apiClients.environments.createEnvironment(newEnvironment);
833
819
  return response.data;
834
820
  },
835
821
  onSuccess: () => {
@@ -1003,145 +989,141 @@ type ParsedResource = {
1003
989
 
1004
990
  ---
1005
991
 
1006
- ## Workbook Storage
992
+ ## Document Storage
1007
993
 
1008
- Workbooks are interactive analysis documents that can be saved and loaded. The SDK provides a storage abstraction that you can implement for different backends.
994
+ The SDK renders dashboards and notebooks a Publisher server serves out of a package, and it will
995
+ author them too, but it does not decide where an authored document is kept. That is the host's
996
+ choice, made by passing a `DocumentStorage` implementation into `DocumentStorageProvider`. The
997
+ Console keeps documents in this browser's localStorage; a platform keeps them in its own document
998
+ store; a repo-backed host writes them to the package directory.
1009
999
 
1010
- ### WorkbookStorage Interface
1000
+ ### DocumentStorage Interface
1001
+
1002
+ ```tsx
1003
+ /** The kinds of document the SDK authors. */
1004
+ type DocumentType = "dashboard" | "notebook";
1011
1005
 
1012
- ```typescript
1013
1006
  interface Workspace {
1014
1007
  name: string;
1015
1008
  writeable: boolean;
1016
1009
  description: string;
1017
1010
  }
1018
1011
 
1019
- interface WorkbookLocator {
1020
- path: string;
1012
+ interface DocumentLocator {
1021
1013
  workspace: string;
1014
+ type: DocumentType;
1015
+ path: string; // as the backend spells it, e.g. "dashboards/overview.malloy"
1022
1016
  }
1023
1017
 
1024
- interface WorkbookStorage {
1018
+ interface DocumentStorage {
1025
1019
  listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
1026
- listWorkbooks(workspace: Workspace): Promise<WorkbookLocator[]>;
1027
- getWorkbook(path: WorkbookLocator): Promise<string>;
1028
- deleteWorkbook(path: WorkbookLocator): Promise<void>;
1029
- saveWorkbook(path: WorkbookLocator, workbook: string): Promise<void>;
1030
- moveWorkbook(from: WorkbookLocator, to: WorkbookLocator): Promise<void>;
1020
+ listDocuments(
1021
+ workspace: Workspace,
1022
+ type?: DocumentType,
1023
+ ): Promise<DocumentLocator[]>;
1024
+ getDocument(locator: DocumentLocator): Promise<string>;
1025
+ saveDocument(locator: DocumentLocator, content: string): Promise<void>;
1026
+ deleteDocument(locator: DocumentLocator): Promise<void>;
1027
+ moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
1031
1028
  }
1032
1029
  ```
1033
1030
 
1034
- ---
1031
+ A document is a string; the `type` on its locator says what kind so a backend can keep kinds apart
1032
+ and a listing can ask for one. Every method rejects when the document is not there, so a caller can
1033
+ tell "missing" from "empty".
1035
1034
 
1036
- ### BrowserWorkbookStorage
1035
+ ### BrowserDocumentStorage
1037
1036
 
1038
- Built-in implementation using browser localStorage.
1037
+ The default: one workspace named `Local`, private to this browser and origin.
1039
1038
 
1040
1039
  ```tsx
1041
1040
  import {
1042
- BrowserWorkbookStorage,
1043
- WorkbookStorageProvider,
1041
+ BrowserDocumentStorage,
1042
+ DocumentStorageProvider,
1044
1043
  } from "@malloy-publisher/sdk";
1045
1044
 
1046
- const storage = new BrowserWorkbookStorage();
1045
+ const storage = new BrowserDocumentStorage();
1047
1046
 
1048
- <WorkbookStorageProvider workbookStorage={storage}>
1047
+ <DocumentStorageProvider documentStorage={storage}>
1049
1048
  <App />
1050
- </WorkbookStorageProvider>;
1049
+ </DocumentStorageProvider>;
1051
1050
  ```
1052
1051
 
1053
- ---
1052
+ ### A custom backend
1054
1053
 
1055
- ### Custom Storage Implementation
1054
+ Implement the interface over whatever you have. For example, over a document API keyed by workspace,
1055
+ type and path:
1056
1056
 
1057
1057
  ```tsx
1058
- class S3WorkbookStorage implements WorkbookStorage {
1059
- private s3Client: S3Client;
1060
- private bucket: string;
1061
-
1062
- constructor(s3Client: S3Client, bucket: string) {
1063
- this.s3Client = s3Client;
1064
- this.bucket = bucket;
1065
- }
1058
+ class ApiDocumentStorage implements DocumentStorage {
1059
+ constructor(private client: DocumentsApi) {}
1066
1060
 
1067
1061
  async listWorkspaces(writeableOnly: boolean): Promise<Workspace[]> {
1068
- return [
1069
- {
1070
- name: this.bucket,
1071
- writeable: true,
1072
- description: "S3 bucket storage",
1073
- },
1074
- ];
1062
+ const all = await this.client.listWorkspaces();
1063
+ return writeableOnly ? all.filter((w) => w.writeable) : all;
1075
1064
  }
1076
1065
 
1077
- async listWorkbooks(workspace: Workspace): Promise<WorkbookLocator[]> {
1078
- const objects = await this.s3Client.listObjects(
1079
- this.bucket,
1080
- "workbooks/",
1081
- );
1082
- return objects.map((obj) => ({
1083
- path: obj.key,
1066
+ async listDocuments(
1067
+ workspace: Workspace,
1068
+ type?: DocumentType,
1069
+ ): Promise<DocumentLocator[]> {
1070
+ const docs = await this.client.listDocuments(workspace.name, type);
1071
+ return docs.map((d) => ({
1084
1072
  workspace: workspace.name,
1073
+ type: d.type,
1074
+ path: d.path,
1085
1075
  }));
1086
1076
  }
1087
1077
 
1088
- async getWorkbook(path: WorkbookLocator): Promise<string> {
1089
- const data = await this.s3Client.getObject(this.bucket, path.path);
1090
- return data.toString();
1078
+ async getDocument(locator: DocumentLocator): Promise<string> {
1079
+ return (await this.client.getDocument(locator.workspace, locator.path))
1080
+ .content;
1091
1081
  }
1092
1082
 
1093
- async saveWorkbook(path: WorkbookLocator, workbook: string): Promise<void> {
1094
- await this.s3Client.putObject(this.bucket, path.path, workbook);
1083
+ async saveDocument(
1084
+ locator: DocumentLocator,
1085
+ content: string,
1086
+ ): Promise<void> {
1087
+ await this.client.putDocument(locator.workspace, locator.path, {
1088
+ type: locator.type,
1089
+ content,
1090
+ });
1095
1091
  }
1096
1092
 
1097
- async deleteWorkbook(path: WorkbookLocator): Promise<void> {
1098
- await this.s3Client.deleteObject(this.bucket, path.path);
1093
+ async deleteDocument(locator: DocumentLocator): Promise<void> {
1094
+ await this.client.deleteDocument(locator.workspace, locator.path);
1099
1095
  }
1100
1096
 
1101
- async moveWorkbook(
1102
- from: WorkbookLocator,
1103
- to: WorkbookLocator,
1097
+ async moveDocument(
1098
+ from: DocumentLocator,
1099
+ to: DocumentLocator,
1104
1100
  ): Promise<void> {
1105
- const content = await this.getWorkbook(from);
1106
- await this.saveWorkbook(to, content);
1107
- await this.deleteWorkbook(from);
1101
+ const content = await this.getDocument(from);
1102
+ await this.saveDocument(to, content);
1103
+ await this.deleteDocument(from);
1108
1104
  }
1109
1105
  }
1110
-
1111
- // Usage
1112
- const storage = new S3WorkbookStorage(s3Client, "my-workbooks-bucket");
1113
-
1114
- <WorkbookStorageProvider workbookStorage={storage}>
1115
- <App />
1116
- </WorkbookStorageProvider>;
1117
1106
  ```
1118
1107
 
1119
- ---
1120
-
1121
- ### WorkbookStorageProvider
1122
-
1123
- Context provider for workbook storage.
1108
+ ### DocumentStorageProvider
1124
1109
 
1125
1110
  ```tsx
1126
1111
  import {
1127
- WorkbookStorageProvider,
1128
- useWorkbookStorage,
1112
+ DocumentStorageProvider,
1113
+ useDocumentStorage,
1129
1114
  } from "@malloy-publisher/sdk";
1130
1115
 
1131
- // Provider setup
1132
- <WorkbookStorageProvider workbookStorage={myStorage}>
1116
+ <DocumentStorageProvider documentStorage={myStorage}>
1133
1117
  <App />
1134
- </WorkbookStorageProvider>;
1118
+ </DocumentStorageProvider>;
1135
1119
 
1136
- // Access in components
1120
+ // Inside a component:
1137
1121
  function MyComponent() {
1138
- const { workbookStorage } = useWorkbookStorage();
1139
-
1140
- const workbooks = await workbookStorage.listWorkbooks({
1141
- name: "Local",
1142
- writeable: true,
1143
- description: "",
1144
- });
1122
+ const { documentStorage } = useDocumentStorage();
1123
+ const dashboards = await documentStorage.listDocuments(
1124
+ { name: "Local", writeable: true, description: "" },
1125
+ "dashboard",
1126
+ );
1145
1127
  }
1146
1128
  ```
1147
1129
 
@@ -1159,9 +1141,6 @@ import "@malloy-publisher/sdk/styles.css";
1159
1141
 
1160
1142
  // If using Model/ModelExplorer outside of Publisher
1161
1143
  import "@malloy-publisher/sdk/malloy-explorer.css";
1162
-
1163
- // If using Workbook markdown editor
1164
- import "@malloy-publisher/sdk/markdown-editor.css";
1165
1144
  ```
1166
1145
 
1167
1146
  ---
@@ -1449,38 +1428,34 @@ function EnvironmentList() {
1449
1428
  | Component | Description |
1450
1429
  | ------------------------- | ----------------------------------------------- |
1451
1430
  | `ServerProvider` | Required context provider for API access |
1452
- | `Home` | Environment listing landing page |
1453
- | `Environment` | Package listing for an environment |
1431
+ | `Home` | Environment listing landing page |
1432
+ | `Environment` | Package listing for an environment |
1454
1433
  | `Package` | Package detail (models, notebooks, connections) |
1455
1434
  | `Model` | Full model explorer with visual query builder |
1456
1435
  | `ModelExplorer` | Lower-level query builder component |
1457
1436
  | `ModelExplorerDialog` | Model explorer in a modal dialog |
1458
1437
  | `Notebook` | Read-only notebook viewer |
1459
- | `Workbook` | Interactive workbook editor |
1460
- | `WorkbookList` | List workbooks from storage |
1461
- | `WorkbookManager` | Workbook state management class |
1462
- | `WorkbookStorageProvider` | Context for workbook storage |
1438
+ | `DocumentStorageProvider` | Context for document storage |
1463
1439
  | `QueryResult` | Execute and display query |
1464
1440
  | `RenderedResult` | Render Malloy result JSON |
1465
1441
  | `EmbeddedQueryResult` | Render serialized query config |
1466
1442
  | `Loading` | Loading spinner with text |
1467
1443
  | `ApiErrorDisplay` | Error display component |
1468
- | `AnalyzePackageButton` | Create/manage workbooks |
1469
1444
  | `SourcesExplorer` | Source schema browser |
1470
1445
  | `ConnectionExplorer` | Connection management UI |
1471
1446
 
1472
1447
  ### Exported Hooks
1473
1448
 
1474
- | Hook | Description |
1475
- | ------------------------------- | ----------------------------------- |
1476
- | `useServer` | Access ServerProvider context |
1477
- | `useQueryWithApiError` | React Query with error handling |
1478
- | `useMutationWithApiError` | Mutations with error handling |
1479
- | `useModelData` | Fetch compiled model |
1480
- | `useRawQueryData` | Execute query, get raw data |
1481
- | `useRouterClickHandler` | Smart navigation with modifier keys |
1482
- | `useWorkbookStorage` | Access workbook storage context |
1483
- | `useDimensionFiltersFromSpec` | Programmatic dimensional filtering |
1449
+ | Hook | Description |
1450
+ | ----------------------------- | ----------------------------------- |
1451
+ | `useServer` | Access ServerProvider context |
1452
+ | `useQueryWithApiError` | React Query with error handling |
1453
+ | `useMutationWithApiError` | Mutations with error handling |
1454
+ | `useModelData` | Fetch compiled model |
1455
+ | `useRawQueryData` | Execute query, get raw data |
1456
+ | `useRouterClickHandler` | Smart navigation with modifier keys |
1457
+ | `useDocumentStorage` | Access document storage context |
1458
+ | `useDimensionFiltersFromSpec` | Programmatic dimensional filtering |
1484
1459
 
1485
1460
  ### Exported Utilities
1486
1461
 
@@ -1489,24 +1464,25 @@ function EnvironmentList() {
1489
1464
  | `encodeResourceUri` | Create resource URI from components |
1490
1465
  | `parseResourceUri` | Parse resource URI to components |
1491
1466
  | `createEmbeddedQueryResult` | Serialize query config |
1492
- | `BrowserWorkbookStorage` | localStorage-based workbook storage |
1467
+ | `BrowserDocumentStorage` | localStorage-based document storage |
1493
1468
  | `globalQueryClient` | Shared React Query client |
1494
1469
 
1495
1470
  ### Exported Types
1496
1471
 
1497
- | Type | Description |
1498
- | ------------------------ | ------------------------------------ |
1499
- | `ParsedResource` | Parsed resource URI components |
1500
- | `ServerContextValue` | Server context interface |
1501
- | `ServerProviderProps` | ServerProvider props |
1502
- | `QueryExplorerResult` | Query builder result |
1503
- | `SourceAndPath` | Source info with model path |
1504
- | `WorkbookStorage` | Workbook storage interface |
1505
- | `WorkbookLocator` | Workbook path + workspace |
1506
- | `Workspace` | Workspace metadata |
1507
- | `ApiError` | Standardized API error |
1508
- | `ModelExplorerProps` | ModelExplorer props |
1509
- | `DimensionFiltersConfig` | Dimensional filter configuration |
1472
+ | Type | Description |
1473
+ | ------------------------ | -------------------------------- |
1474
+ | `ParsedResource` | Parsed resource URI components |
1475
+ | `ServerContextValue` | Server context interface |
1476
+ | `ServerProviderProps` | ServerProvider props |
1477
+ | `QueryExplorerResult` | Query builder result |
1478
+ | `SourceAndPath` | Source info with model path |
1479
+ | `DocumentStorage` | Document storage interface |
1480
+ | `DocumentLocator` | Workspace + type + path |
1481
+ | `DocumentType` | `"dashboard"` or `"notebook"` |
1482
+ | `Workspace` | Workspace metadata |
1483
+ | `ApiError` | Standardized API error |
1484
+ | `ModelExplorerProps` | ModelExplorer props |
1485
+ | `DimensionFiltersConfig` | Dimensional filter configuration |
1510
1486
 
1511
1487
  ---
1512
1488