@malloy-publisher/sdk 0.2.7 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +172 -204
- package/dist/ServerProvider-CGnLjzag.cjs.js +1 -0
- package/dist/{ServerProvider-ksC5Su_x.es.js → ServerProvider-DSK9rfSY.es.js} +245 -245
- 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 +4 -2
- package/dist/components/Dashboard/promoteMeasureRow.d.ts +36 -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 +18 -0
- package/dist/components/DocumentStorage/index.d.ts +3 -0
- package/dist/components/Model/index.d.ts +0 -1
- package/dist/components/RenderedResult/RenderedResult.d.ts +12 -0
- package/dist/components/RenderedResult/ResultContainer.d.ts +7 -1
- package/dist/components/RenderedResult/index.d.ts +1 -0
- package/dist/components/RenderedResult/resultSizing.d.ts +183 -0
- package/dist/components/drill/index.d.ts +1 -0
- 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 +2 -3
- package/dist/components/styles.d.ts +3 -3
- 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 +1 -1
- package/dist/hooks/useSuggestOptions.d.ts +28 -12
- package/dist/index.cjs.js +281 -1
- package/dist/index.es.js +45803 -79
- package/dist/sdk.css +1 -1
- package/dist/styles.css +0 -1
- package/package.json +2 -6
- package/src/components/ApiErrorDisplay.tsx +1 -1
- package/src/components/Connections/EditConnectionDialog.tsx +96 -86
- package/src/components/Dashboard/Dashboard.tsx +60 -95
- package/src/components/Dashboard/DashboardTile.tsx +25 -2
- package/src/components/Dashboard/promoteMeasureRow.spec.ts +137 -0
- package/src/components/Dashboard/promoteMeasureRow.ts +129 -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 +46 -0
- package/src/components/DocumentStorage/index.ts +15 -0
- package/src/components/Model/ModelCell.tsx +2 -1
- package/src/components/Model/index.ts +0 -1
- package/src/components/Notebook/Notebook.tsx +10 -76
- package/src/components/Notebook/NotebookCell.tsx +2 -8
- package/src/components/RenderedResult/RenderedResult.tsx +86 -76
- package/src/components/RenderedResult/ResultContainer.tsx +21 -24
- package/src/components/RenderedResult/index.ts +15 -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 +5 -0
- 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/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 +5 -3
- package/src/hooks/index.ts +0 -1
- package/src/hooks/useGivensState.spec.ts +158 -0
- package/src/hooks/useGivensState.ts +114 -23
- package/src/hooks/useSuggestOptions.dom.spec.ts +60 -1
- package/src/hooks/useSuggestOptions.ts +94 -51
- package/vite.config.ts +0 -1
- package/dist/ServerProvider-xXW1HJOJ.cjs.js +0 -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
|
|
|
@@ -51,7 +51,9 @@ import "@malloy-publisher/sdk/styles.css";
|
|
|
51
51
|
function App() {
|
|
52
52
|
return (
|
|
53
53
|
<ServerProvider baseURL="http://localhost:4000/api/v0">
|
|
54
|
-
<Home
|
|
54
|
+
<Home
|
|
55
|
+
onClickEnvironment={(path) => console.log("Navigate to:", path)}
|
|
56
|
+
/>
|
|
55
57
|
</ServerProvider>
|
|
56
58
|
);
|
|
57
59
|
}
|
|
@@ -169,7 +171,6 @@ ServerProvider (required wrapper)
|
|
|
169
171
|
│ └── Package (show models, notebooks, connections)
|
|
170
172
|
│ ├── Model (visual query builder + named queries)
|
|
171
173
|
│ └── Notebook (read-only notebook viewer)
|
|
172
|
-
└── Workbook (interactive analysis workbook)
|
|
173
174
|
```
|
|
174
175
|
|
|
175
176
|
### Navigation Pattern
|
|
@@ -200,7 +201,7 @@ The `ServerProvider` is the required context provider that wraps your applicatio
|
|
|
200
201
|
| ---------------- | ----------------------- | ------------- | -------------------------------------------------------------------- |
|
|
201
202
|
| `baseURL` | `string` | Auto-detected | Base URL of the Publisher API (e.g., `http://localhost:4000/api/v0`) |
|
|
202
203
|
| `getAccessToken` | `() => Promise<string>` | `undefined` | Async function returning auth token |
|
|
203
|
-
| `mutable` | `boolean` | `true` | Enable/disable environment/package management UI
|
|
204
|
+
| `mutable` | `boolean` | `true` | Enable/disable environment/package management UI |
|
|
204
205
|
|
|
205
206
|
### Basic Usage
|
|
206
207
|
|
|
@@ -463,48 +464,6 @@ const resourceUri = encodeResourceUri({
|
|
|
463
464
|
|
|
464
465
|
---
|
|
465
466
|
|
|
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
467
|
## Query & Results Components
|
|
509
468
|
|
|
510
469
|
### QueryResult
|
|
@@ -610,13 +569,13 @@ component does not use this mechanism; see [Notebooks use `given:`](#notebooks-u
|
|
|
610
569
|
|
|
611
570
|
### Filter Types
|
|
612
571
|
|
|
613
|
-
| Type
|
|
614
|
-
|
|
615
|
-
| `Star`
|
|
616
|
-
| `MinMax`
|
|
617
|
-
| `DateMinMax` | Date range picker
|
|
618
|
-
| `Retrieval`
|
|
619
|
-
| `Boolean`
|
|
572
|
+
| Type | UI Component | Use Case |
|
|
573
|
+
| ------------ | --------------------- | ---------------------------------- |
|
|
574
|
+
| `Star` | Multi-select dropdown | String fields with discrete values |
|
|
575
|
+
| `MinMax` | Range slider | Numeric fields |
|
|
576
|
+
| `DateMinMax` | Date range picker | Date/timestamp fields |
|
|
577
|
+
| `Retrieval` | Semantic search input | Free-text semantic search |
|
|
578
|
+
| `Boolean` | Toggle switch | Boolean fields |
|
|
620
579
|
|
|
621
580
|
### Source Declaration Syntax
|
|
622
581
|
|
|
@@ -699,34 +658,52 @@ For custom data apps, use the SDK's React hooks:
|
|
|
699
658
|
|
|
700
659
|
```tsx
|
|
701
660
|
import {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
} from
|
|
661
|
+
useDimensionFiltersFromSpec,
|
|
662
|
+
DimensionFiltersConfig,
|
|
663
|
+
} from "@malloy-publisher/sdk";
|
|
705
664
|
|
|
706
665
|
const config: DimensionFiltersConfig = {
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
666
|
+
environment: "malloy-samples",
|
|
667
|
+
package: "faa",
|
|
668
|
+
indexLimit: 1000,
|
|
669
|
+
dimensionSpecs: [
|
|
670
|
+
{
|
|
671
|
+
dimensionName: "origin_code",
|
|
672
|
+
filterType: "Star",
|
|
673
|
+
source: "flights",
|
|
674
|
+
model: "flights.malloy",
|
|
675
|
+
label: "Origin Airport",
|
|
676
|
+
},
|
|
677
|
+
{
|
|
678
|
+
dimensionName: "distance",
|
|
679
|
+
filterType: "MinMax",
|
|
680
|
+
source: "flights",
|
|
681
|
+
model: "flights.malloy",
|
|
682
|
+
label: "Distance (miles)",
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
dimensionName: "dep_time",
|
|
686
|
+
filterType: "DateMinMax",
|
|
687
|
+
source: "flights",
|
|
688
|
+
model: "flights.malloy",
|
|
689
|
+
label: "Departure Time",
|
|
690
|
+
},
|
|
691
|
+
],
|
|
715
692
|
};
|
|
716
693
|
|
|
717
694
|
function FilteredDashboard() {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
695
|
+
const {
|
|
696
|
+
filterStates, // Current filter values
|
|
697
|
+
updateFilter, // Update a single filter
|
|
698
|
+
clearAllFilters, // Reset all filters
|
|
699
|
+
activeFilters, // Array of active filter selections
|
|
700
|
+
data, // Dimension values for dropdowns/sliders
|
|
701
|
+
isLoading, // Loading state
|
|
702
|
+
executeQuery, // Run query with current filters
|
|
703
|
+
queryString, // Generated Malloy query
|
|
704
|
+
} = useDimensionFiltersFromSpec(config);
|
|
705
|
+
|
|
706
|
+
// Render filter UI and results...
|
|
730
707
|
}
|
|
731
708
|
```
|
|
732
709
|
|
|
@@ -734,14 +711,14 @@ function FilteredDashboard() {
|
|
|
734
711
|
|
|
735
712
|
Filters support different match types depending on the filter type:
|
|
736
713
|
|
|
737
|
-
| Match Type
|
|
738
|
-
|
|
739
|
-
| `Equals`
|
|
740
|
-
| `Contains`
|
|
741
|
-
| `Greater Than` / `Less Than` | Comparison
|
|
742
|
-
| `Between`
|
|
743
|
-
| `After` / `Before`
|
|
744
|
-
| `Semantic Search`
|
|
714
|
+
| Match Type | Description | Applicable To |
|
|
715
|
+
| ---------------------------- | ------------------------------------ | ------------------ |
|
|
716
|
+
| `Equals` | Exact match (multi-select supported) | Star, Retrieval |
|
|
717
|
+
| `Contains` | Substring match | Star |
|
|
718
|
+
| `Greater Than` / `Less Than` | Comparison | MinMax |
|
|
719
|
+
| `Between` | Range (inclusive) | MinMax, DateMinMax |
|
|
720
|
+
| `After` / `Before` | Date comparison | DateMinMax |
|
|
721
|
+
| `Semantic Search` | Semantic similarity | Retrieval |
|
|
745
722
|
|
|
746
723
|
---
|
|
747
724
|
|
|
@@ -829,7 +806,8 @@ import { useMutationWithApiError } from "@malloy-publisher/sdk";
|
|
|
829
806
|
function MyComponent() {
|
|
830
807
|
const mutation = useMutationWithApiError({
|
|
831
808
|
mutationFn: async (newEnvironment) => {
|
|
832
|
-
const response =
|
|
809
|
+
const response =
|
|
810
|
+
await apiClients.environments.createEnvironment(newEnvironment);
|
|
833
811
|
return response.data;
|
|
834
812
|
},
|
|
835
813
|
onSuccess: () => {
|
|
@@ -1003,145 +981,141 @@ type ParsedResource = {
|
|
|
1003
981
|
|
|
1004
982
|
---
|
|
1005
983
|
|
|
1006
|
-
##
|
|
984
|
+
## Document Storage
|
|
1007
985
|
|
|
1008
|
-
|
|
986
|
+
The SDK renders dashboards and notebooks a Publisher server serves out of a package, and it will
|
|
987
|
+
author them too, but it does not decide where an authored document is kept. That is the host's
|
|
988
|
+
choice, made by passing a `DocumentStorage` implementation into `DocumentStorageProvider`. The
|
|
989
|
+
Console keeps documents in this browser's localStorage; a platform keeps them in its own document
|
|
990
|
+
store; a repo-backed host writes them to the package directory.
|
|
1009
991
|
|
|
1010
|
-
###
|
|
992
|
+
### DocumentStorage Interface
|
|
993
|
+
|
|
994
|
+
```tsx
|
|
995
|
+
/** The kinds of document the SDK authors. */
|
|
996
|
+
type DocumentType = "dashboard" | "notebook";
|
|
1011
997
|
|
|
1012
|
-
```typescript
|
|
1013
998
|
interface Workspace {
|
|
1014
999
|
name: string;
|
|
1015
1000
|
writeable: boolean;
|
|
1016
1001
|
description: string;
|
|
1017
1002
|
}
|
|
1018
1003
|
|
|
1019
|
-
interface
|
|
1020
|
-
path: string;
|
|
1004
|
+
interface DocumentLocator {
|
|
1021
1005
|
workspace: string;
|
|
1006
|
+
type: DocumentType;
|
|
1007
|
+
path: string; // as the backend spells it, e.g. "dashboards/overview.malloy"
|
|
1022
1008
|
}
|
|
1023
1009
|
|
|
1024
|
-
interface
|
|
1010
|
+
interface DocumentStorage {
|
|
1025
1011
|
listWorkspaces(writeableOnly: boolean): Promise<Workspace[]>;
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1012
|
+
listDocuments(
|
|
1013
|
+
workspace: Workspace,
|
|
1014
|
+
type?: DocumentType,
|
|
1015
|
+
): Promise<DocumentLocator[]>;
|
|
1016
|
+
getDocument(locator: DocumentLocator): Promise<string>;
|
|
1017
|
+
saveDocument(locator: DocumentLocator, content: string): Promise<void>;
|
|
1018
|
+
deleteDocument(locator: DocumentLocator): Promise<void>;
|
|
1019
|
+
moveDocument(from: DocumentLocator, to: DocumentLocator): Promise<void>;
|
|
1031
1020
|
}
|
|
1032
1021
|
```
|
|
1033
1022
|
|
|
1034
|
-
|
|
1023
|
+
A document is a string; the `type` on its locator says what kind so a backend can keep kinds apart
|
|
1024
|
+
and a listing can ask for one. Every method rejects when the document is not there, so a caller can
|
|
1025
|
+
tell "missing" from "empty".
|
|
1035
1026
|
|
|
1036
|
-
###
|
|
1027
|
+
### BrowserDocumentStorage
|
|
1037
1028
|
|
|
1038
|
-
|
|
1029
|
+
The default: one workspace named `Local`, private to this browser and origin.
|
|
1039
1030
|
|
|
1040
1031
|
```tsx
|
|
1041
1032
|
import {
|
|
1042
|
-
|
|
1043
|
-
|
|
1033
|
+
BrowserDocumentStorage,
|
|
1034
|
+
DocumentStorageProvider,
|
|
1044
1035
|
} from "@malloy-publisher/sdk";
|
|
1045
1036
|
|
|
1046
|
-
const storage = new
|
|
1037
|
+
const storage = new BrowserDocumentStorage();
|
|
1047
1038
|
|
|
1048
|
-
<
|
|
1039
|
+
<DocumentStorageProvider documentStorage={storage}>
|
|
1049
1040
|
<App />
|
|
1050
|
-
</
|
|
1041
|
+
</DocumentStorageProvider>;
|
|
1051
1042
|
```
|
|
1052
1043
|
|
|
1053
|
-
|
|
1044
|
+
### A custom backend
|
|
1054
1045
|
|
|
1055
|
-
|
|
1046
|
+
Implement the interface over whatever you have. For example, over a document API keyed by workspace,
|
|
1047
|
+
type and path:
|
|
1056
1048
|
|
|
1057
1049
|
```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
|
-
}
|
|
1050
|
+
class ApiDocumentStorage implements DocumentStorage {
|
|
1051
|
+
constructor(private client: DocumentsApi) {}
|
|
1066
1052
|
|
|
1067
1053
|
async listWorkspaces(writeableOnly: boolean): Promise<Workspace[]> {
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
name: this.bucket,
|
|
1071
|
-
writeable: true,
|
|
1072
|
-
description: "S3 bucket storage",
|
|
1073
|
-
},
|
|
1074
|
-
];
|
|
1054
|
+
const all = await this.client.listWorkspaces();
|
|
1055
|
+
return writeableOnly ? all.filter((w) => w.writeable) : all;
|
|
1075
1056
|
}
|
|
1076
1057
|
|
|
1077
|
-
async
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
);
|
|
1082
|
-
return
|
|
1083
|
-
path: obj.key,
|
|
1058
|
+
async listDocuments(
|
|
1059
|
+
workspace: Workspace,
|
|
1060
|
+
type?: DocumentType,
|
|
1061
|
+
): Promise<DocumentLocator[]> {
|
|
1062
|
+
const docs = await this.client.listDocuments(workspace.name, type);
|
|
1063
|
+
return docs.map((d) => ({
|
|
1084
1064
|
workspace: workspace.name,
|
|
1065
|
+
type: d.type,
|
|
1066
|
+
path: d.path,
|
|
1085
1067
|
}));
|
|
1086
1068
|
}
|
|
1087
1069
|
|
|
1088
|
-
async
|
|
1089
|
-
|
|
1090
|
-
|
|
1070
|
+
async getDocument(locator: DocumentLocator): Promise<string> {
|
|
1071
|
+
return (await this.client.getDocument(locator.workspace, locator.path))
|
|
1072
|
+
.content;
|
|
1091
1073
|
}
|
|
1092
1074
|
|
|
1093
|
-
async
|
|
1094
|
-
|
|
1075
|
+
async saveDocument(
|
|
1076
|
+
locator: DocumentLocator,
|
|
1077
|
+
content: string,
|
|
1078
|
+
): Promise<void> {
|
|
1079
|
+
await this.client.putDocument(locator.workspace, locator.path, {
|
|
1080
|
+
type: locator.type,
|
|
1081
|
+
content,
|
|
1082
|
+
});
|
|
1095
1083
|
}
|
|
1096
1084
|
|
|
1097
|
-
async
|
|
1098
|
-
await this.
|
|
1085
|
+
async deleteDocument(locator: DocumentLocator): Promise<void> {
|
|
1086
|
+
await this.client.deleteDocument(locator.workspace, locator.path);
|
|
1099
1087
|
}
|
|
1100
1088
|
|
|
1101
|
-
async
|
|
1102
|
-
from:
|
|
1103
|
-
to:
|
|
1089
|
+
async moveDocument(
|
|
1090
|
+
from: DocumentLocator,
|
|
1091
|
+
to: DocumentLocator,
|
|
1104
1092
|
): Promise<void> {
|
|
1105
|
-
const content = await this.
|
|
1106
|
-
await this.
|
|
1107
|
-
await this.
|
|
1093
|
+
const content = await this.getDocument(from);
|
|
1094
|
+
await this.saveDocument(to, content);
|
|
1095
|
+
await this.deleteDocument(from);
|
|
1108
1096
|
}
|
|
1109
1097
|
}
|
|
1110
|
-
|
|
1111
|
-
// Usage
|
|
1112
|
-
const storage = new S3WorkbookStorage(s3Client, "my-workbooks-bucket");
|
|
1113
|
-
|
|
1114
|
-
<WorkbookStorageProvider workbookStorage={storage}>
|
|
1115
|
-
<App />
|
|
1116
|
-
</WorkbookStorageProvider>;
|
|
1117
1098
|
```
|
|
1118
1099
|
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
### WorkbookStorageProvider
|
|
1122
|
-
|
|
1123
|
-
Context provider for workbook storage.
|
|
1100
|
+
### DocumentStorageProvider
|
|
1124
1101
|
|
|
1125
1102
|
```tsx
|
|
1126
1103
|
import {
|
|
1127
|
-
|
|
1128
|
-
|
|
1104
|
+
DocumentStorageProvider,
|
|
1105
|
+
useDocumentStorage,
|
|
1129
1106
|
} from "@malloy-publisher/sdk";
|
|
1130
1107
|
|
|
1131
|
-
|
|
1132
|
-
<WorkbookStorageProvider workbookStorage={myStorage}>
|
|
1108
|
+
<DocumentStorageProvider documentStorage={myStorage}>
|
|
1133
1109
|
<App />
|
|
1134
|
-
</
|
|
1110
|
+
</DocumentStorageProvider>;
|
|
1135
1111
|
|
|
1136
|
-
//
|
|
1112
|
+
// Inside a component:
|
|
1137
1113
|
function MyComponent() {
|
|
1138
|
-
const {
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
description: "",
|
|
1144
|
-
});
|
|
1114
|
+
const { documentStorage } = useDocumentStorage();
|
|
1115
|
+
const dashboards = await documentStorage.listDocuments(
|
|
1116
|
+
{ name: "Local", writeable: true, description: "" },
|
|
1117
|
+
"dashboard",
|
|
1118
|
+
);
|
|
1145
1119
|
}
|
|
1146
1120
|
```
|
|
1147
1121
|
|
|
@@ -1159,9 +1133,6 @@ import "@malloy-publisher/sdk/styles.css";
|
|
|
1159
1133
|
|
|
1160
1134
|
// If using Model/ModelExplorer outside of Publisher
|
|
1161
1135
|
import "@malloy-publisher/sdk/malloy-explorer.css";
|
|
1162
|
-
|
|
1163
|
-
// If using Workbook markdown editor
|
|
1164
|
-
import "@malloy-publisher/sdk/markdown-editor.css";
|
|
1165
1136
|
```
|
|
1166
1137
|
|
|
1167
1138
|
---
|
|
@@ -1449,38 +1420,34 @@ function EnvironmentList() {
|
|
|
1449
1420
|
| Component | Description |
|
|
1450
1421
|
| ------------------------- | ----------------------------------------------- |
|
|
1451
1422
|
| `ServerProvider` | Required context provider for API access |
|
|
1452
|
-
| `Home` | Environment listing landing page
|
|
1453
|
-
| `Environment`
|
|
1423
|
+
| `Home` | Environment listing landing page |
|
|
1424
|
+
| `Environment` | Package listing for an environment |
|
|
1454
1425
|
| `Package` | Package detail (models, notebooks, connections) |
|
|
1455
1426
|
| `Model` | Full model explorer with visual query builder |
|
|
1456
1427
|
| `ModelExplorer` | Lower-level query builder component |
|
|
1457
1428
|
| `ModelExplorerDialog` | Model explorer in a modal dialog |
|
|
1458
1429
|
| `Notebook` | Read-only notebook viewer |
|
|
1459
|
-
| `
|
|
1460
|
-
| `WorkbookList` | List workbooks from storage |
|
|
1461
|
-
| `WorkbookManager` | Workbook state management class |
|
|
1462
|
-
| `WorkbookStorageProvider` | Context for workbook storage |
|
|
1430
|
+
| `DocumentStorageProvider` | Context for document storage |
|
|
1463
1431
|
| `QueryResult` | Execute and display query |
|
|
1464
1432
|
| `RenderedResult` | Render Malloy result JSON |
|
|
1465
1433
|
| `EmbeddedQueryResult` | Render serialized query config |
|
|
1466
1434
|
| `Loading` | Loading spinner with text |
|
|
1467
1435
|
| `ApiErrorDisplay` | Error display component |
|
|
1468
|
-
| `AnalyzePackageButton` | Create/manage workbooks |
|
|
1469
1436
|
| `SourcesExplorer` | Source schema browser |
|
|
1470
1437
|
| `ConnectionExplorer` | Connection management UI |
|
|
1471
1438
|
|
|
1472
1439
|
### Exported Hooks
|
|
1473
1440
|
|
|
1474
|
-
| Hook
|
|
1475
|
-
|
|
|
1476
|
-
| `useServer`
|
|
1477
|
-
| `useQueryWithApiError`
|
|
1478
|
-
| `useMutationWithApiError`
|
|
1479
|
-
| `useModelData`
|
|
1480
|
-
| `useRawQueryData`
|
|
1481
|
-
| `useRouterClickHandler`
|
|
1482
|
-
| `
|
|
1483
|
-
| `useDimensionFiltersFromSpec`
|
|
1441
|
+
| Hook | Description |
|
|
1442
|
+
| ----------------------------- | ----------------------------------- |
|
|
1443
|
+
| `useServer` | Access ServerProvider context |
|
|
1444
|
+
| `useQueryWithApiError` | React Query with error handling |
|
|
1445
|
+
| `useMutationWithApiError` | Mutations with error handling |
|
|
1446
|
+
| `useModelData` | Fetch compiled model |
|
|
1447
|
+
| `useRawQueryData` | Execute query, get raw data |
|
|
1448
|
+
| `useRouterClickHandler` | Smart navigation with modifier keys |
|
|
1449
|
+
| `useDocumentStorage` | Access document storage context |
|
|
1450
|
+
| `useDimensionFiltersFromSpec` | Programmatic dimensional filtering |
|
|
1484
1451
|
|
|
1485
1452
|
### Exported Utilities
|
|
1486
1453
|
|
|
@@ -1489,24 +1456,25 @@ function EnvironmentList() {
|
|
|
1489
1456
|
| `encodeResourceUri` | Create resource URI from components |
|
|
1490
1457
|
| `parseResourceUri` | Parse resource URI to components |
|
|
1491
1458
|
| `createEmbeddedQueryResult` | Serialize query config |
|
|
1492
|
-
| `
|
|
1459
|
+
| `BrowserDocumentStorage` | localStorage-based document storage |
|
|
1493
1460
|
| `globalQueryClient` | Shared React Query client |
|
|
1494
1461
|
|
|
1495
1462
|
### Exported Types
|
|
1496
1463
|
|
|
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
|
-
| `
|
|
1464
|
+
| Type | Description |
|
|
1465
|
+
| ------------------------ | -------------------------------- |
|
|
1466
|
+
| `ParsedResource` | Parsed resource URI components |
|
|
1467
|
+
| `ServerContextValue` | Server context interface |
|
|
1468
|
+
| `ServerProviderProps` | ServerProvider props |
|
|
1469
|
+
| `QueryExplorerResult` | Query builder result |
|
|
1470
|
+
| `SourceAndPath` | Source info with model path |
|
|
1471
|
+
| `DocumentStorage` | Document storage interface |
|
|
1472
|
+
| `DocumentLocator` | Workspace + type + path |
|
|
1473
|
+
| `DocumentType` | `"dashboard"` or `"notebook"` |
|
|
1474
|
+
| `Workspace` | Workspace metadata |
|
|
1475
|
+
| `ApiError` | Standardized API error |
|
|
1476
|
+
| `ModelExplorerProps` | ModelExplorer props |
|
|
1477
|
+
| `DimensionFiltersConfig` | Dimensional filter configuration |
|
|
1510
1478
|
|
|
1511
1479
|
---
|
|
1512
1480
|
|