@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.
- package/README.md +180 -204
- package/dist/DocumentStorageProvider-BeBD0uWc.cjs.js +134 -0
- package/dist/DocumentStorageProvider-tGvodI8f.es.js +24268 -0
- package/dist/RenderedResult-CPi6uQWq.cjs.js +115 -0
- package/dist/RenderedResult-mDE-4u8S.es.js +542 -0
- package/dist/{ServerProvider-xXW1HJOJ.cjs.js → ServerProvider-CH71GsoL.cjs.js} +1 -1
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-X2Ma0HRs.es.js} +324 -359
- package/dist/builder/index.cjs.js +105 -0
- package/dist/builder/index.d.ts +2 -0
- package/dist/builder/index.es.js +9561 -0
- package/dist/builder-entry.d.ts +8 -0
- package/dist/client/api.d.ts +13 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +1 -1
- package/dist/components/ApiErrorDisplay.d.ts +1 -2
- package/dist/components/Dashboard/Dashboard.d.ts +23 -16
- package/dist/components/Dashboard/DashboardGrid.d.ts +67 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +6 -1
- package/dist/components/Dashboard/ExploreDialog.d.ts +18 -0
- package/dist/components/Dashboard/RowsDialog.d.ts +47 -0
- package/dist/components/Dashboard/TileCard.d.ts +44 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +40 -0
- package/dist/components/Dashboard/telemetry.d.ts +43 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +35 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +29 -0
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +112 -0
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +32 -0
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/DrillDialog.d.ts +15 -0
- package/dist/components/DashboardBuilder/FilterDialog.d.ts +54 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +17 -0
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +20 -0
- package/dist/components/DashboardBuilder/TileFrame.d.ts +42 -0
- package/dist/components/DashboardBuilder/TileMenu.d.ts +24 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +62 -0
- package/dist/components/DashboardBuilder/controls.d.ts +157 -0
- package/dist/components/DashboardBuilder/diff.d.ts +35 -0
- package/dist/components/DashboardBuilder/document.d.ts +218 -0
- package/dist/components/DashboardBuilder/layout.d.ts +71 -0
- package/dist/components/DashboardBuilder/malloyText.d.ts +45 -0
- package/dist/components/DashboardBuilder/preview.d.ts +60 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +106 -0
- package/dist/components/DashboardBuilder/sortable.d.ts +51 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +44 -0
- package/dist/components/DashboardBuilder/testing/fixtures.d.ts +10 -0
- package/dist/components/DashboardBuilder/useBuilderShortcuts.d.ts +22 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +63 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +13 -0
- package/dist/components/DashboardBuilder/useFilterForm.d.ts +65 -0
- package/dist/components/DashboardBuilder/useTileReorder.d.ts +22 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +29 -0
- package/dist/components/DocumentStorage/BrowserDocumentStorage.d.ts +14 -0
- package/dist/components/DocumentStorage/DocumentStorage.d.ts +58 -0
- package/dist/components/DocumentStorage/DocumentStorageProvider.d.ts +25 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/FloatingIconButton.d.ts +16 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/Prose.d.ts +46 -0
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/ResultPanel.d.ts +30 -0
- package/dist/components/RenderedResult/index.d.ts +2 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +2 -1
- package/dist/components/drill/resolveDrill.d.ts +22 -0
- package/dist/components/drill/useDrill.d.ts +11 -2
- package/dist/components/drill/useDrillSelf.d.ts +46 -0
- package/dist/components/given/filterValue.d.ts +63 -0
- package/dist/components/given/index.d.ts +1 -0
- package/dist/components/given/useGivenUrlParams.d.ts +39 -0
- package/dist/components/index.d.ts +3 -3
- package/dist/components/styles.d.ts +3 -7
- package/dist/core-8NVBCLZh.cjs.js +148 -0
- package/dist/{core-BY7vB5gN.es.js → core-B8oMW4sm.es.js} +3540 -2335
- package/dist/hooks/index.d.ts +3 -1
- package/dist/hooks/useDocumentControls.d.ts +70 -0
- package/dist/hooks/useQueryResult.d.ts +40 -0
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +34 -1
- package/dist/index.es.js +21487 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/dist/utils/malloyLiteral.d.ts +11 -0
- package/package.json +25 -14
- package/src/builder-entry.ts +55 -0
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.spec.tsx +7 -10
- package/src/components/Dashboard/Dashboard.tsx +184 -229
- package/src/components/Dashboard/DashboardGrid.tsx +124 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +30 -6
- package/src/components/Dashboard/DashboardTile.tsx +67 -101
- package/src/components/Dashboard/ExploreDialog.tsx +84 -0
- package/src/components/Dashboard/RowsDialog.spec.ts +42 -0
- package/src/components/Dashboard/RowsDialog.tsx +234 -0
- package/src/components/Dashboard/TileCard.tsx +120 -0
- package/src/components/Dashboard/index.ts +2 -0
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +207 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +160 -0
- package/src/components/Dashboard/telemetry.ts +44 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +1 -1
- package/src/components/DashboardBuilder/AddTileDialog.tsx +249 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +270 -0
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +858 -0
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +653 -0
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +211 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +493 -0
- package/src/components/DashboardBuilder/DiffDialog.tsx +129 -0
- package/src/components/DashboardBuilder/DrillDialog.tsx +281 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +581 -0
- package/src/components/DashboardBuilder/FilterStrip.tsx +125 -0
- package/src/components/DashboardBuilder/SettingsPopover.tsx +168 -0
- package/src/components/DashboardBuilder/TileFrame.tsx +380 -0
- package/src/components/DashboardBuilder/TileMenu.tsx +188 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +215 -0
- package/src/components/DashboardBuilder/catalog.ts +225 -0
- package/src/components/DashboardBuilder/controls.spec.ts +243 -0
- package/src/components/DashboardBuilder/controls.ts +398 -0
- package/src/components/DashboardBuilder/diff.spec.ts +44 -0
- package/src/components/DashboardBuilder/diff.ts +93 -0
- package/src/components/DashboardBuilder/document.ts +209 -0
- package/src/components/DashboardBuilder/keepRowStructure.spec.ts +84 -0
- package/src/components/DashboardBuilder/layout.ts +143 -0
- package/src/components/DashboardBuilder/malloyText.spec.ts +84 -0
- package/src/components/DashboardBuilder/malloyText.ts +151 -0
- package/src/components/DashboardBuilder/moveIntoGap.spec.ts +90 -0
- package/src/components/DashboardBuilder/preview.spec.ts +149 -0
- package/src/components/DashboardBuilder/preview.ts +172 -0
- package/src/components/DashboardBuilder/readDocument.spec.ts +375 -0
- package/src/components/DashboardBuilder/readDocument.ts +467 -0
- package/src/components/DashboardBuilder/sortable.tsx +151 -0
- package/src/components/DashboardBuilder/spliceDocument.spec.ts +1108 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +1098 -0
- package/src/components/DashboardBuilder/testing/fixtures.ts +48 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +88 -0
- package/src/components/DashboardBuilder/useDashboardEditor.spec.ts +255 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +193 -0
- package/src/components/DashboardBuilder/useDraft.ts +43 -0
- package/src/components/DashboardBuilder/useFilterForm.spec.tsx +144 -0
- package/src/components/DashboardBuilder/useFilterForm.ts +352 -0
- package/src/components/DashboardBuilder/useTileReorder.spec.tsx +97 -0
- package/src/components/DashboardBuilder/useTileReorder.ts +115 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +121 -0
- package/src/components/DashboardBuilder/useTileResize.ts +110 -0
- package/src/components/DashboardBuilder/withGaps.spec.ts +96 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.spec.ts +81 -0
- package/src/components/DocumentStorage/BrowserDocumentStorage.ts +105 -0
- package/src/components/DocumentStorage/DocumentStorage.ts +73 -0
- package/src/components/DocumentStorage/DocumentStorageProvider.tsx +58 -0
- package/src/components/DocumentStorage/index.ts +16 -0
- package/src/components/Environment/About.tsx +4 -36
- package/src/components/FloatingIconButton.tsx +41 -0
- package/src/components/Model/Model.tsx +6 -23
- package/src/components/Model/ModelCell.tsx +34 -72
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +27 -156
- package/src/components/Notebook/NotebookCell.tsx +37 -191
- package/src/components/Prose.spec.tsx +85 -0
- package/src/components/Prose.tsx +179 -0
- package/src/components/QueryResult/QueryResult.tsx +15 -43
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +25 -36
- package/src/components/RenderedResult/ResultPanel.spec.tsx +49 -0
- package/src/components/RenderedResult/ResultPanel.tsx +73 -0
- package/src/components/RenderedResult/index.ts +16 -0
- package/src/components/RenderedResult/resultSizing.spec.ts +249 -0
- package/src/components/RenderedResult/resultSizing.ts +308 -0
- package/src/components/ResultsDialog.tsx +2 -1
- package/src/components/drill/index.ts +6 -0
- package/src/components/drill/resolveDrill.ts +22 -1
- package/src/components/drill/useDrill.spec.tsx +94 -0
- package/src/components/drill/useDrill.tsx +52 -12
- package/src/components/drill/useDrillSelf.spec.tsx +64 -0
- package/src/components/drill/useDrillSelf.ts +110 -0
- package/src/components/given/GivenInput.spec.tsx +196 -2
- package/src/components/given/GivenInput.tsx +300 -25
- package/src/components/given/GivensPanel.tsx +1 -1
- package/src/components/given/filterValue.spec.ts +112 -0
- package/src/components/given/filterValue.ts +188 -0
- package/src/components/given/index.ts +4 -0
- package/src/components/given/useGivenUrlParams.spec.tsx +74 -0
- package/src/components/given/useGivenUrlParams.ts +87 -0
- package/src/components/index.ts +11 -3
- package/src/components/styles.ts +0 -37
- package/src/hooks/index.ts +13 -1
- package/src/hooks/useDocumentControls.ts +170 -0
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useQueryResult.ts +82 -0
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/src/utils/malloyLiteral.spec.ts +43 -0
- package/src/utils/malloyLiteral.ts +76 -0
- package/vite.config.ts +5 -1
- package/dist/components/AnalyzePackageButton.d.ts +0 -6
- package/dist/components/Workbook/BrowserWorkbookStorage.d.ts +0 -9
- package/dist/components/Workbook/EditableMalloyCell.d.ts +0 -11
- package/dist/components/Workbook/ModelPicker.d.ts +0 -11
- package/dist/components/Workbook/MutableCell.d.ts +0 -17
- package/dist/components/Workbook/Workbook.d.ts +0 -7
- package/dist/components/Workbook/WorkbookList.d.ts +0 -7
- package/dist/components/Workbook/WorkbookManager.d.ts +0 -84
- package/dist/components/Workbook/WorkbookStorage.d.ts +0 -17
- package/dist/components/Workbook/WorkbookStorageProvider.d.ts +0 -12
- package/dist/components/Workbook/index.d.ts +0 -7
- package/dist/core-CWKmWEg2.cjs.js +0 -148
- package/dist/index-B0WyZAUA.es.js +0 -66412
- package/dist/index-kxVD1RjY.cjs.js +0 -356
- package/dist/markdown-editor.css +0 -341
- package/src/components/AnalyzePackageButton.tsx +0 -319
- package/src/components/Workbook/BrowserWorkbookStorage.ts +0 -64
- package/src/components/Workbook/EditableMalloyCell.tsx +0 -49
- package/src/components/Workbook/ModelPicker.tsx +0 -134
- package/src/components/Workbook/MutableCell.tsx +0 -458
- package/src/components/Workbook/Workbook.tsx +0 -501
- package/src/components/Workbook/WorkbookList.tsx +0 -110
- package/src/components/Workbook/WorkbookManager.ts +0 -214
- package/src/components/Workbook/WorkbookStorage.ts +0 -35
- package/src/components/Workbook/WorkbookStorageProvider.tsx +0 -40
- 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.
|
|
22
|
-
11.
|
|
23
|
-
12.
|
|
24
|
-
13.
|
|
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
|
|
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
|
|
614
|
-
|
|
615
|
-
| `Star`
|
|
616
|
-
| `MinMax`
|
|
617
|
-
| `DateMinMax` | Date range picker
|
|
618
|
-
| `Retrieval`
|
|
619
|
-
| `Boolean`
|
|
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
|
-
|
|
703
|
-
|
|
704
|
-
} from
|
|
669
|
+
useDimensionFiltersFromSpec,
|
|
670
|
+
DimensionFiltersConfig,
|
|
671
|
+
} from "@malloy-publisher/sdk";
|
|
705
672
|
|
|
706
673
|
const config: DimensionFiltersConfig = {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
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
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
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
|
|
738
|
-
|
|
739
|
-
| `Equals`
|
|
740
|
-
| `Contains`
|
|
741
|
-
| `Greater Than` / `Less Than` | Comparison
|
|
742
|
-
| `Between`
|
|
743
|
-
| `After` / `Before`
|
|
744
|
-
| `Semantic Search`
|
|
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 =
|
|
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
|
-
##
|
|
992
|
+
## Document Storage
|
|
1007
993
|
|
|
1008
|
-
|
|
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
|
-
###
|
|
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
|
|
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
|
|
1018
|
+
interface DocumentStorage {
|
|
1025
1019
|
listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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
|
-
###
|
|
1035
|
+
### BrowserDocumentStorage
|
|
1037
1036
|
|
|
1038
|
-
|
|
1037
|
+
The default: one workspace named `Local`, private to this browser and origin.
|
|
1039
1038
|
|
|
1040
1039
|
```tsx
|
|
1041
1040
|
import {
|
|
1042
|
-
|
|
1043
|
-
|
|
1041
|
+
BrowserDocumentStorage,
|
|
1042
|
+
DocumentStorageProvider,
|
|
1044
1043
|
} from "@malloy-publisher/sdk";
|
|
1045
1044
|
|
|
1046
|
-
const storage = new
|
|
1045
|
+
const storage = new BrowserDocumentStorage();
|
|
1047
1046
|
|
|
1048
|
-
<
|
|
1047
|
+
<DocumentStorageProvider documentStorage={storage}>
|
|
1049
1048
|
<App />
|
|
1050
|
-
</
|
|
1049
|
+
</DocumentStorageProvider>;
|
|
1051
1050
|
```
|
|
1052
1051
|
|
|
1053
|
-
|
|
1052
|
+
### A custom backend
|
|
1054
1053
|
|
|
1055
|
-
|
|
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
|
|
1059
|
-
private
|
|
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
|
-
|
|
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
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
);
|
|
1082
|
-
return
|
|
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
|
|
1089
|
-
|
|
1090
|
-
|
|
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
|
|
1094
|
-
|
|
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
|
|
1098
|
-
await this.
|
|
1093
|
+
async deleteDocument(locator: DocumentLocator): Promise<void> {
|
|
1094
|
+
await this.client.deleteDocument(locator.workspace, locator.path);
|
|
1099
1095
|
}
|
|
1100
1096
|
|
|
1101
|
-
async
|
|
1102
|
-
from:
|
|
1103
|
-
to:
|
|
1097
|
+
async moveDocument(
|
|
1098
|
+
from: DocumentLocator,
|
|
1099
|
+
to: DocumentLocator,
|
|
1104
1100
|
): Promise<void> {
|
|
1105
|
-
const content = await this.
|
|
1106
|
-
await this.
|
|
1107
|
-
await this.
|
|
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
|
-
|
|
1128
|
-
|
|
1112
|
+
DocumentStorageProvider,
|
|
1113
|
+
useDocumentStorage,
|
|
1129
1114
|
} from "@malloy-publisher/sdk";
|
|
1130
1115
|
|
|
1131
|
-
|
|
1132
|
-
<WorkbookStorageProvider workbookStorage={myStorage}>
|
|
1116
|
+
<DocumentStorageProvider documentStorage={myStorage}>
|
|
1133
1117
|
<App />
|
|
1134
|
-
</
|
|
1118
|
+
</DocumentStorageProvider>;
|
|
1135
1119
|
|
|
1136
|
-
//
|
|
1120
|
+
// Inside a component:
|
|
1137
1121
|
function MyComponent() {
|
|
1138
|
-
const {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
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`
|
|
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
|
-
| `
|
|
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
|
|
1475
|
-
|
|
|
1476
|
-
| `useServer`
|
|
1477
|
-
| `useQueryWithApiError`
|
|
1478
|
-
| `useMutationWithApiError`
|
|
1479
|
-
| `useModelData`
|
|
1480
|
-
| `useRawQueryData`
|
|
1481
|
-
| `useRouterClickHandler`
|
|
1482
|
-
| `
|
|
1483
|
-
| `useDimensionFiltersFromSpec`
|
|
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
|
-
| `
|
|
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
|
-
| `
|
|
1505
|
-
| `
|
|
1506
|
-
| `
|
|
1507
|
-
| `
|
|
1508
|
-
| `
|
|
1509
|
-
| `
|
|
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
|
|