@malloy-publisher/sdk 0.0.382-dev → 0.2.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 +115 -95
- package/TREE_SHAKING.md +16 -11
- package/bunfig.toml +7 -0
- package/dist/ServerProvider-Cn_LhKda.cjs.js +1 -0
- package/dist/ServerProvider-sfabtriY.es.js +4076 -0
- package/dist/client/api.d.ts +3773 -1515
- package/dist/client/configuration.d.ts +1 -1
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.es.js +86 -59
- package/dist/components/Connections/EditConnectionDialog.d.ts +2 -1
- package/dist/components/Connections/common.d.ts +8 -2
- package/dist/components/Dashboard/Dashboard.d.ts +62 -0
- package/dist/components/Dashboard/DashboardTile.d.ts +57 -0
- package/dist/components/Dashboard/index.d.ts +2 -0
- package/dist/components/DataAppViewer/DataAppViewer.d.ts +23 -0
- package/dist/components/DataAppViewer/index.d.ts +1 -0
- package/dist/components/Environment/Environment.d.ts +6 -0
- package/dist/components/Environment/index.d.ts +2 -0
- package/dist/components/Home/AddEnvironmentDialog.d.ts +1 -0
- package/dist/components/Home/DeleteEnvironmentDialog.d.ts +5 -0
- package/dist/components/Home/EditEnvironmentDialog.d.ts +7 -0
- package/dist/components/Home/Home.d.ts +2 -2
- package/dist/components/Materializations/CreateEnvMaterializationDialog.d.ts +14 -0
- package/dist/components/Materializations/CreateMaterializationDialog.d.ts +10 -0
- package/dist/components/Materializations/DeleteMaterializationDialog.d.ts +7 -0
- package/dist/components/Materializations/EnvironmentMaterializations.d.ts +7 -0
- package/dist/components/Materializations/ManifestView.d.ts +13 -0
- package/dist/components/Materializations/MaterializationDetailDialog.d.ts +9 -0
- package/dist/components/Materializations/MaterializationRunsList.d.ts +15 -0
- package/dist/components/Materializations/Materializations.d.ts +7 -0
- package/dist/components/Materializations/ScheduleCard.d.ts +20 -0
- package/dist/components/Materializations/SectionLabel.d.ts +10 -0
- package/dist/components/Materializations/SetScheduleDialog.d.ts +11 -0
- package/dist/components/Materializations/TriggerChip.d.ts +10 -0
- package/dist/components/Materializations/cron.d.ts +23 -0
- package/dist/components/Materializations/index.d.ts +2 -0
- package/dist/components/Materializations/utils.d.ts +46 -0
- package/dist/components/Notebook/Notebook.d.ts +47 -4
- package/dist/components/Notebook/NotebookCell.d.ts +37 -1
- package/dist/components/Notebook/runPlan.d.ts +29 -0
- package/dist/components/Notebook/types.d.ts +10 -0
- package/dist/components/Package/ContentTypeIcon.d.ts +31 -0
- package/dist/components/Package/Package.d.ts +1 -4
- package/dist/components/RenderedResult/RenderedResult.d.ts +7 -1
- package/dist/components/RenderedResult/ResultContainer.d.ts +5 -1
- package/dist/components/RenderedResult/renderLogs.d.ts +6 -0
- package/dist/components/ResultsDialog.d.ts +6 -1
- package/dist/components/ServerProvider.d.ts +28 -4
- package/dist/components/click_helper.d.ts +10 -1
- package/dist/components/drill/index.d.ts +3 -0
- package/dist/components/drill/markDrillableCells.d.ts +55 -0
- package/dist/components/drill/resolveDrill.d.ts +139 -0
- package/dist/components/drill/useDrill.d.ts +63 -0
- package/dist/components/given/GivenInput.d.ts +52 -0
- package/dist/components/given/GivensPanel.d.ts +47 -0
- package/dist/components/given/filterValue.d.ts +97 -0
- package/dist/components/given/index.d.ts +2 -0
- package/dist/components/given/paramCodec.d.ts +60 -0
- package/dist/components/given/utils.d.ts +17 -0
- package/dist/components/highlighter.d.ts +6 -1
- package/dist/components/index.d.ts +7 -2
- package/dist/components/styles.d.ts +47 -0
- package/dist/constants/docLinks.d.ts +12 -0
- package/dist/{core-YNpOLuB1.cjs.js → core-CqRKhtoy.cjs.js} +1 -1
- package/dist/{core-CjeTkq8O.es.js → core-DyU47reh.es.js} +1 -1
- package/dist/github-dark-BKL9xNgN.cjs.js +1 -0
- package/dist/github-dark-DenFmJkN.es.js +4 -0
- package/dist/hooks/givenValue.d.ts +10 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/useDimensionFiltersFromSpec.d.ts +3 -3
- package/dist/hooks/useDimensionFiltersQuery.d.ts +3 -3
- package/dist/hooks/useDimensionalFilterRangeData.d.ts +4 -4
- package/dist/hooks/useGivensState.d.ts +64 -0
- package/dist/hooks/useModelGivens.d.ts +10 -0
- package/dist/hooks/useSuggestOptions.d.ts +78 -0
- package/dist/{index-DRDu9kIV.es.js → index-CAkFE4Ol.es.js} +41278 -28504
- package/dist/index-DD4b_bt0.cjs.js +356 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.es.js +79 -48
- package/dist/malloy-explorer.css +12 -1
- package/dist/sdk.css +1 -1
- package/dist/theme/ThemeContext.d.ts +45 -0
- package/dist/theme/buildMalloyExplicitTheme.d.ts +34 -0
- package/dist/theme/buildTableCssVars.d.ts +41 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +16 -0
- package/dist/theme/defaults.d.ts +7 -0
- package/dist/theme/index.d.ts +8 -0
- package/dist/theme/keys.d.ts +20 -0
- package/dist/theme/readChartAnnotations.d.ts +23 -0
- package/dist/theme/resolveTheme.d.ts +22 -0
- package/dist/theme/types.d.ts +70 -0
- package/dist/utils/dataAppEmbed.d.ts +44 -0
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/malloyString.d.ts +7 -0
- package/dist/utils/parsing.d.ts +2 -2
- package/dist/utils/queryClient.d.ts +5 -0
- package/package.json +19 -8
- package/src/client-entry.ts +3 -0
- package/src/components/AnalyzePackageButton.tsx +9 -3
- package/src/components/ApiErrorDisplay.tsx +3 -0
- package/src/components/Connections/AddConnectionDialog.tsx +132 -25
- package/src/components/Connections/DeleteConnectionDialog.tsx +14 -3
- package/src/components/Connections/EditConnectionDialog.tsx +167 -37
- package/src/components/Connections/common.ts +94 -3
- package/src/components/DOMElement/DOMElement.tsx +3 -0
- package/src/components/DOMElement/index.ts +3 -0
- package/src/components/Dashboard/Dashboard.spec.tsx +216 -0
- package/src/components/Dashboard/Dashboard.tsx +458 -0
- package/src/components/Dashboard/DashboardTile.spec.tsx +81 -0
- package/src/components/Dashboard/DashboardTile.tsx +199 -0
- package/src/components/Dashboard/index.ts +5 -0
- package/src/components/Dashboard/tileGridColumn.spec.ts +35 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +214 -0
- package/src/components/DataAppViewer/index.ts +4 -0
- package/src/components/{Project → Environment}/About.tsx +11 -4
- package/src/components/Environment/AddPackageDialog.tsx +202 -0
- package/src/components/{Project → Environment}/ConnectionExplorer.tsx +17 -14
- package/src/components/Environment/Connections.tsx +391 -0
- package/src/components/{Project → Environment}/DeletePackageDialog.tsx +8 -4
- package/src/components/{Project → Environment}/EditPackageDialog.tsx +21 -13
- package/src/components/Environment/Environment.tsx +89 -0
- package/src/components/Environment/Packages.tsx +206 -0
- package/src/components/Environment/index.ts +5 -0
- package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +25 -19
- package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +20 -15
- package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +35 -28
- package/src/components/Home/Home.tsx +386 -408
- package/src/components/Home/index.ts +3 -0
- package/src/components/Loading.tsx +3 -0
- package/src/components/Materializations/CreateEnvMaterializationDialog.tsx +179 -0
- package/src/components/Materializations/CreateMaterializationDialog.tsx +112 -0
- package/src/components/Materializations/DeleteMaterializationDialog.tsx +109 -0
- package/src/components/Materializations/EnvironmentMaterializations.tsx +267 -0
- package/src/components/Materializations/ManifestView.tsx +87 -0
- package/src/components/Materializations/MaterializationDetailDialog.tsx +259 -0
- package/src/components/Materializations/MaterializationRunsList.tsx +256 -0
- package/src/components/Materializations/Materializations.tsx +355 -0
- package/src/components/Materializations/ScheduleCard.tsx +231 -0
- package/src/components/Materializations/SectionLabel.tsx +30 -0
- package/src/components/Materializations/SetScheduleDialog.tsx +162 -0
- package/src/components/Materializations/TriggerChip.tsx +44 -0
- package/src/components/Materializations/cron.ts +124 -0
- package/src/components/Materializations/index.ts +5 -0
- package/src/components/Materializations/utils.ts +145 -0
- package/src/components/Model/Model.tsx +44 -2
- package/src/components/Model/ModelCell.tsx +14 -5
- package/src/components/Model/ModelExplorer.tsx +3 -0
- package/src/components/Model/ModelExplorerDialog.tsx +4 -1
- package/src/components/Model/SourcesExplorer.tsx +9 -6
- package/src/components/Model/index.ts +3 -0
- package/src/components/Model/useModelData.ts +6 -3
- package/src/components/Notebook/Notebook.spec.tsx +88 -0
- package/src/components/Notebook/Notebook.tsx +476 -339
- package/src/components/Notebook/NotebookCell.tsx +264 -25
- package/src/components/Notebook/index.ts +3 -0
- package/src/components/Notebook/runPlan.spec.ts +155 -0
- package/src/components/Notebook/runPlan.ts +67 -0
- package/src/components/Notebook/types.ts +14 -0
- package/src/components/Package/ContentTypeIcon.spec.ts +91 -0
- package/src/components/Package/ContentTypeIcon.tsx +177 -0
- package/src/components/Package/FileTreeView.tsx +3 -0
- package/src/components/Package/Models.tsx +7 -4
- package/src/components/Package/Package.spec.tsx +113 -0
- package/src/components/Package/Package.tsx +692 -59
- package/src/components/Package/index.ts +3 -0
- package/src/components/QueryResult/QueryResult.tsx +17 -8
- package/src/components/QueryResult/index.ts +3 -0
- package/src/components/RenderedResult/RenderedResult.tsx +725 -67
- package/src/components/RenderedResult/ResultContainer.tsx +71 -2
- package/src/components/RenderedResult/index.ts +3 -0
- package/src/components/RenderedResult/renderLogs.spec.ts +58 -0
- package/src/components/RenderedResult/renderLogs.ts +43 -0
- package/src/components/ResultsDialog.tsx +13 -1
- package/src/components/ServerProvider.tsx +175 -51
- package/src/components/Workbook/BrowserWorkbookStorage.ts +3 -0
- package/src/components/Workbook/EditableMalloyCell.tsx +3 -0
- package/src/components/Workbook/ModelPicker.tsx +7 -4
- package/src/components/Workbook/MutableCell.tsx +10 -5
- package/src/components/Workbook/Workbook.tsx +8 -5
- package/src/components/Workbook/WorkbookList.tsx +3 -0
- package/src/components/Workbook/WorkbookManager.ts +3 -0
- package/src/components/Workbook/WorkbookStorage.ts +3 -0
- package/src/components/Workbook/WorkbookStorageProvider.tsx +3 -0
- package/src/components/Workbook/index.ts +3 -0
- package/src/components/click_helper.ts +17 -1
- package/src/components/drill/index.ts +28 -0
- package/src/components/drill/markDrillableCells.dom.spec.ts +313 -0
- package/src/components/drill/markDrillableCells.spec.ts +109 -0
- package/src/components/drill/markDrillableCells.ts +314 -0
- package/src/components/drill/resolveDrill.spec.ts +449 -0
- package/src/components/drill/resolveDrill.ts +375 -0
- package/src/components/drill/useDrill.tsx +203 -0
- package/src/components/filter/DimensionFilter.tsx +3 -0
- package/src/components/filter/index.ts +3 -0
- package/src/components/filter/utils.ts +16 -5
- package/src/components/given/GivenInput.spec.tsx +689 -0
- package/src/components/given/GivenInput.tsx +801 -0
- package/src/components/given/GivensPanel.spec.tsx +175 -0
- package/src/components/given/GivensPanel.tsx +195 -0
- package/src/components/given/filterValue.spec.ts +364 -0
- package/src/components/given/filterValue.ts +207 -0
- package/src/components/given/index.ts +9 -0
- package/src/components/given/paramCodec.spec.ts +857 -0
- package/src/components/given/paramCodec.ts +483 -0
- package/src/components/given/utils.spec.ts +60 -0
- package/src/components/given/utils.ts +79 -0
- package/src/components/highlighter.ts +22 -5
- package/src/components/index.ts +10 -2
- package/src/components/styles.ts +82 -33
- package/src/constants/docLinks.spec.ts +54 -0
- package/src/constants/docLinks.ts +46 -0
- package/src/hooks/givenValue.ts +13 -0
- package/src/hooks/index.ts +13 -0
- package/src/hooks/useDimensionFilters.ts +4 -7
- package/src/hooks/useDimensionFiltersFromSpec.ts +8 -5
- package/src/hooks/useDimensionFiltersQuery.ts +10 -13
- package/src/hooks/useDimensionalFilterRangeData.ts +11 -14
- package/src/hooks/useGivensState.spec.ts +449 -0
- package/src/hooks/useGivensState.ts +340 -0
- package/src/hooks/useModelGivens.ts +29 -0
- package/src/hooks/useQueryWithApiError.ts +3 -0
- package/src/hooks/useRawQueryData.ts +6 -3
- package/src/hooks/useSuggestOptions.dom.spec.ts +91 -0
- package/src/hooks/useSuggestOptions.spec.ts +112 -0
- package/src/hooks/useSuggestOptions.ts +268 -0
- package/src/index.ts +10 -1
- package/src/react-app-env.d.ts +3 -0
- package/src/theme/ThemeContext.tsx +86 -0
- package/src/theme/buildMalloyExplicitTheme.ts +61 -0
- package/src/theme/buildTableCssVars.spec.ts +86 -0
- package/src/theme/buildTableCssVars.ts +98 -0
- package/src/theme/buildVegaThemeOverride.spec.ts +56 -0
- package/src/theme/buildVegaThemeOverride.ts +47 -0
- package/src/theme/defaults.ts +78 -0
- package/src/theme/index.ts +11 -0
- package/src/theme/keys.ts +32 -0
- package/src/theme/readChartAnnotations.spec.ts +58 -0
- package/src/theme/readChartAnnotations.ts +69 -0
- package/src/theme/resolveTheme.spec.ts +160 -0
- package/src/theme/resolveTheme.ts +121 -0
- package/src/theme/types.ts +79 -0
- package/src/utils/dataAppEmbed.spec.ts +63 -0
- package/src/utils/dataAppEmbed.ts +84 -0
- package/src/utils/formatting.spec.ts +25 -21
- package/src/utils/formatting.ts +11 -7
- package/src/utils/malloyString.spec.ts +24 -0
- package/src/utils/malloyString.ts +12 -0
- package/src/utils/parsing.spec.ts +26 -19
- package/src/utils/parsing.ts +11 -6
- package/src/utils/queryClient.ts +17 -0
- package/test/README.md +185 -0
- package/test/serverProvider.tsx +72 -0
- package/test/setup.ts +29 -0
- package/tsconfig.json +12 -1
- package/tsconfig.spec.json +22 -0
- package/vite.config.ts +3 -0
- package/dist/ServerProvider-lOQXDlqB.cjs.js +0 -1
- package/dist/ServerProvider-on-8FH5Z.es.js +0 -3060
- package/dist/components/Home/AddProjectDialog.d.ts +0 -1
- package/dist/components/Home/DeleteProjectDialog.d.ts +0 -5
- package/dist/components/Home/EditProjectDialog.d.ts +0 -7
- package/dist/components/Package/Config.d.ts +0 -5
- package/dist/components/Package/Databases.d.ts +0 -5
- package/dist/components/Package/Notebooks.d.ts +0 -6
- package/dist/components/Project/Project.d.ts +0 -6
- package/dist/components/Project/index.d.ts +0 -2
- package/dist/index-BOLBP6_i.cjs.js +0 -233
- package/src/components/Package/Config.tsx +0 -97
- package/src/components/Package/Connections.tsx +0 -373
- package/src/components/Package/Databases.tsx +0 -228
- package/src/components/Package/Notebooks.tsx +0 -77
- package/src/components/Project/AddPackageDialog.tsx +0 -159
- package/src/components/Project/Packages.tsx +0 -191
- package/src/components/Project/Project.tsx +0 -52
- package/src/components/Project/index.ts +0 -2
- /package/dist/components/{Project → Environment}/About.d.ts +0 -0
- /package/dist/components/{Project → Environment}/AddPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/ConnectionExplorer.d.ts +0 -0
- /package/dist/components/{Package → Environment}/Connections.d.ts +0 -0
- /package/dist/components/{Project → Environment}/DeletePackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/EditPackageDialog.d.ts +0 -0
- /package/dist/components/{Project → Environment}/Packages.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) Credible Data Inc.
|
|
3
|
+
SPDX-License-Identifier: MIT
|
|
4
|
+
-->
|
|
5
|
+
|
|
1
6
|
# Malloy Publisher SDK
|
|
2
7
|
|
|
3
8
|
The Publisher SDK (`@malloy-publisher/sdk`) is a comprehensive React component library for building data applications that interact with Publisher's REST API. It provides everything you need to browse semantic models, execute queries, visualize results, and build interactive data experiences.
|
|
@@ -46,7 +51,7 @@ import "@malloy-publisher/sdk/styles.css";
|
|
|
46
51
|
function App() {
|
|
47
52
|
return (
|
|
48
53
|
<ServerProvider baseURL="http://localhost:4000/api/v0">
|
|
49
|
-
<Home
|
|
54
|
+
<Home onClickEnvironment={(path) => console.log("Navigate to:", path)} />
|
|
50
55
|
</ServerProvider>
|
|
51
56
|
);
|
|
52
57
|
}
|
|
@@ -65,7 +70,7 @@ import {
|
|
|
65
70
|
import {
|
|
66
71
|
ServerProvider,
|
|
67
72
|
Home,
|
|
68
|
-
|
|
73
|
+
Environment,
|
|
69
74
|
Package,
|
|
70
75
|
Model,
|
|
71
76
|
Notebook,
|
|
@@ -80,13 +85,13 @@ function App() {
|
|
|
80
85
|
<BrowserRouter>
|
|
81
86
|
<Routes>
|
|
82
87
|
<Route path="/" element={<HomePage />} />
|
|
83
|
-
<Route path="/:
|
|
88
|
+
<Route path="/:environmentName" element={<EnvironmentPage />} />
|
|
84
89
|
<Route
|
|
85
|
-
path="/:
|
|
90
|
+
path="/:environmentName/:packageName"
|
|
86
91
|
element={<PackagePage />}
|
|
87
92
|
/>
|
|
88
93
|
<Route
|
|
89
|
-
path="/:
|
|
94
|
+
path="/:environmentName/:packageName/*"
|
|
90
95
|
element={<ModelPage />}
|
|
91
96
|
/>
|
|
92
97
|
</Routes>
|
|
@@ -97,20 +102,20 @@ function App() {
|
|
|
97
102
|
|
|
98
103
|
function HomePage() {
|
|
99
104
|
const navigate = useRouterClickHandler();
|
|
100
|
-
return <Home
|
|
105
|
+
return <Home onClickEnvironment={navigate} />;
|
|
101
106
|
}
|
|
102
107
|
|
|
103
|
-
function
|
|
108
|
+
function EnvironmentPage() {
|
|
104
109
|
const navigate = useRouterClickHandler();
|
|
105
|
-
const {
|
|
106
|
-
const resourceUri = encodeResourceUri({
|
|
107
|
-
return <
|
|
110
|
+
const { environmentName } = useParams();
|
|
111
|
+
const resourceUri = encodeResourceUri({ environmentName });
|
|
112
|
+
return <Environment onSelectPackage={navigate} resourceUri={resourceUri} />;
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
function PackagePage() {
|
|
111
116
|
const navigate = useRouterClickHandler();
|
|
112
|
-
const {
|
|
113
|
-
const resourceUri = encodeResourceUri({
|
|
117
|
+
const { environmentName, packageName } = useParams();
|
|
118
|
+
const resourceUri = encodeResourceUri({ environmentName, packageName });
|
|
114
119
|
return <Package onClickPackageFile={navigate} resourceUri={resourceUri} />;
|
|
115
120
|
}
|
|
116
121
|
|
|
@@ -118,7 +123,7 @@ function ModelPage() {
|
|
|
118
123
|
const params = useParams();
|
|
119
124
|
const modelPath = params["*"];
|
|
120
125
|
const resourceUri = encodeResourceUri({
|
|
121
|
-
|
|
126
|
+
environmentName: params.environmentName,
|
|
122
127
|
packageName: params.packageName,
|
|
123
128
|
modelPath,
|
|
124
129
|
});
|
|
@@ -142,14 +147,14 @@ function ModelPage() {
|
|
|
142
147
|
The SDK uses a standardized URI format to identify resources:
|
|
143
148
|
|
|
144
149
|
```
|
|
145
|
-
publisher://
|
|
150
|
+
publisher://environments/{environmentName}/packages/{packageName}/models/{modelPath}?versionId={version}
|
|
146
151
|
```
|
|
147
152
|
|
|
148
153
|
Examples:
|
|
149
154
|
|
|
150
|
-
-
|
|
151
|
-
- Package: `publisher://
|
|
152
|
-
- Model: `publisher://
|
|
155
|
+
- Environment: `publisher://environments/my-environment`
|
|
156
|
+
- Package: `publisher://environments/my-environment/packages/analytics`
|
|
157
|
+
- Model: `publisher://environments/my-environment/packages/analytics/models/orders.malloy`
|
|
153
158
|
|
|
154
159
|
Use the `encodeResourceUri()` and `parseResourceUri()` utilities to work with these URIs.
|
|
155
160
|
|
|
@@ -159,8 +164,8 @@ The SDK components follow a natural hierarchy:
|
|
|
159
164
|
|
|
160
165
|
```
|
|
161
166
|
ServerProvider (required wrapper)
|
|
162
|
-
├── Home (list all
|
|
163
|
-
│ └──
|
|
167
|
+
├── Home (list all environments)
|
|
168
|
+
│ └── Environment (show packages in an environment)
|
|
164
169
|
│ └── Package (show models, notebooks, connections)
|
|
165
170
|
│ ├── Model (visual query builder + named queries)
|
|
166
171
|
│ └── Notebook (read-only notebook viewer)
|
|
@@ -174,13 +179,13 @@ Components accept callback functions for navigation rather than handling routing
|
|
|
174
179
|
```tsx
|
|
175
180
|
// With React Router
|
|
176
181
|
const navigate = useRouterClickHandler();
|
|
177
|
-
<Home
|
|
182
|
+
<Home onClickEnvironment={navigate} />
|
|
178
183
|
|
|
179
184
|
// Custom navigation
|
|
180
|
-
<Home
|
|
185
|
+
<Home onClickEnvironment={(path) => window.location.href = path} />
|
|
181
186
|
|
|
182
187
|
// SPA with history
|
|
183
|
-
<Home
|
|
188
|
+
<Home onClickEnvironment={(path) => history.push(path)} />
|
|
184
189
|
```
|
|
185
190
|
|
|
186
191
|
---
|
|
@@ -195,7 +200,7 @@ The `ServerProvider` is the required context provider that wraps your applicatio
|
|
|
195
200
|
| ---------------- | ----------------------- | ------------- | -------------------------------------------------------------------- |
|
|
196
201
|
| `baseURL` | `string` | Auto-detected | Base URL of the Publisher API (e.g., `http://localhost:4000/api/v0`) |
|
|
197
202
|
| `getAccessToken` | `() => Promise<string>` | `undefined` | Async function returning auth token |
|
|
198
|
-
| `mutable` | `boolean` | `true` | Enable/disable
|
|
203
|
+
| `mutable` | `boolean` | `true` | Enable/disable environment/package management UI |
|
|
199
204
|
|
|
200
205
|
### Basic Usage
|
|
201
206
|
|
|
@@ -238,19 +243,19 @@ async function getAccessToken() {
|
|
|
238
243
|
|
|
239
244
|
### Home
|
|
240
245
|
|
|
241
|
-
Displays a landing page with feature cards and a list of all available
|
|
246
|
+
Displays a landing page with feature cards and a list of all available environments.
|
|
242
247
|
|
|
243
248
|
```tsx
|
|
244
249
|
import { Home } from "@malloy-publisher/sdk";
|
|
245
250
|
|
|
246
251
|
interface HomeProps {
|
|
247
|
-
|
|
252
|
+
onClickEnvironment?: (path: string, event?: React.MouseEvent) => void;
|
|
248
253
|
}
|
|
249
254
|
|
|
250
255
|
// Usage
|
|
251
256
|
<Home
|
|
252
|
-
|
|
253
|
-
// path is like "/my-
|
|
257
|
+
onClickEnvironment={(path, event) => {
|
|
258
|
+
// path is like "/my-environment/"
|
|
254
259
|
navigate(path);
|
|
255
260
|
}}
|
|
256
261
|
/>;
|
|
@@ -260,27 +265,27 @@ interface HomeProps {
|
|
|
260
265
|
|
|
261
266
|
- Hero section with Publisher branding
|
|
262
267
|
- Feature cards (Ad Hoc Analysis, Notebook Dashboards, AI Agents)
|
|
263
|
-
-
|
|
264
|
-
- Add/Edit/Delete
|
|
268
|
+
- Environment listing with descriptions
|
|
269
|
+
- Add/Edit/Delete environment dialogs (when `mutable=true`)
|
|
265
270
|
|
|
266
271
|
---
|
|
267
272
|
|
|
268
|
-
###
|
|
273
|
+
### Environment
|
|
269
274
|
|
|
270
|
-
Shows all packages within
|
|
275
|
+
Shows all packages within an environment.
|
|
271
276
|
|
|
272
277
|
```tsx
|
|
273
|
-
import {
|
|
278
|
+
import { Environment, encodeResourceUri } from "@malloy-publisher/sdk";
|
|
274
279
|
|
|
275
|
-
interface
|
|
280
|
+
interface EnvironmentProps {
|
|
276
281
|
onSelectPackage: (path: string, event?: React.MouseEvent) => void;
|
|
277
282
|
resourceUri: string;
|
|
278
283
|
}
|
|
279
284
|
|
|
280
285
|
// Usage
|
|
281
|
-
const resourceUri = encodeResourceUri({
|
|
286
|
+
const resourceUri = encodeResourceUri({ environmentName: "my-environment" });
|
|
282
287
|
|
|
283
|
-
<
|
|
288
|
+
<Environment
|
|
284
289
|
onSelectPackage={(path) => navigate(path)}
|
|
285
290
|
resourceUri={resourceUri}
|
|
286
291
|
/>;
|
|
@@ -290,7 +295,7 @@ const resourceUri = encodeResourceUri({ projectName: "my-project" });
|
|
|
290
295
|
|
|
291
296
|
- Package listing with version info
|
|
292
297
|
- Add/Edit/Delete package dialogs (when `mutable=true`)
|
|
293
|
-
-
|
|
298
|
+
- Environment README display
|
|
294
299
|
|
|
295
300
|
---
|
|
296
301
|
|
|
@@ -308,7 +313,7 @@ interface PackageProps {
|
|
|
308
313
|
|
|
309
314
|
// Usage
|
|
310
315
|
const resourceUri = encodeResourceUri({
|
|
311
|
-
|
|
316
|
+
environmentName: "my-environment",
|
|
312
317
|
packageName: "analytics",
|
|
313
318
|
});
|
|
314
319
|
|
|
@@ -322,7 +327,7 @@ const resourceUri = encodeResourceUri({
|
|
|
322
327
|
|
|
323
328
|
- Models list (`.malloy` files)
|
|
324
329
|
- Notebooks list (`.malloynb` files)
|
|
325
|
-
- Embedded databases (`.parquet` files)
|
|
330
|
+
- Embedded databases (`.parquet`, `.csv`, and `.xlsx` files)
|
|
326
331
|
- Connection configuration
|
|
327
332
|
- Package README
|
|
328
333
|
|
|
@@ -350,7 +355,7 @@ interface QueryExplorerResult {
|
|
|
350
355
|
|
|
351
356
|
// Usage
|
|
352
357
|
const resourceUri = encodeResourceUri({
|
|
353
|
-
|
|
358
|
+
environmentName: "my-environment",
|
|
354
359
|
packageName: "analytics",
|
|
355
360
|
modelPath: "models/orders.malloy",
|
|
356
361
|
});
|
|
@@ -424,11 +429,24 @@ import { Notebook, encodeResourceUri } from "@malloy-publisher/sdk";
|
|
|
424
429
|
interface NotebookProps {
|
|
425
430
|
resourceUri: string;
|
|
426
431
|
maxResultSize?: number; // Default: 0 (no limit)
|
|
432
|
+
// The notebook's `given:` parameters. Pass the ones you hold (from the URL,
|
|
433
|
+
// say) and the notebook runs every cell with them.
|
|
434
|
+
givens?: Record<string, string>;
|
|
435
|
+
// Called when a parameter changes, with the new values and the names the
|
|
436
|
+
// notebook manages, so a host can put them in the URL. `managed` is what to
|
|
437
|
+
// clear when a value goes away; anything else in your URL is left alone.
|
|
438
|
+
onGivensChange?: (
|
|
439
|
+
givens: Record<string, string>,
|
|
440
|
+
managed: readonly string[],
|
|
441
|
+
) => void;
|
|
442
|
+
// Where a `# drill` click wants to go. Given no handler, a drill onto the
|
|
443
|
+
// notebook's own parameters still works; only navigation away is dropped.
|
|
444
|
+
onNavigate?: (to: string, event?: NavigationClick) => void;
|
|
427
445
|
}
|
|
428
446
|
|
|
429
447
|
// Usage
|
|
430
448
|
const resourceUri = encodeResourceUri({
|
|
431
|
-
|
|
449
|
+
environmentName: "my-environment",
|
|
432
450
|
packageName: "analytics",
|
|
433
451
|
modelPath: "notebooks/sales-dashboard.malloynb",
|
|
434
452
|
});
|
|
@@ -465,7 +483,7 @@ interface WorkbookProps {
|
|
|
465
483
|
// Usage
|
|
466
484
|
const workbookStorage = new BrowserWorkbookStorage();
|
|
467
485
|
const resourceUri = encodeResourceUri({
|
|
468
|
-
|
|
486
|
+
environmentName: "my-environment",
|
|
469
487
|
packageName: "analytics",
|
|
470
488
|
});
|
|
471
489
|
|
|
@@ -508,7 +526,7 @@ interface QueryResultProps {
|
|
|
508
526
|
sourceName="orders"
|
|
509
527
|
queryName="by_region"
|
|
510
528
|
resourceUri={encodeResourceUri({
|
|
511
|
-
|
|
529
|
+
environmentName: "my-environment",
|
|
512
530
|
packageName: "analytics",
|
|
513
531
|
modelPath: "models/orders.malloy",
|
|
514
532
|
})}
|
|
@@ -518,7 +536,7 @@ interface QueryResultProps {
|
|
|
518
536
|
<QueryResult
|
|
519
537
|
query="run: orders -> { group_by: status; aggregate: order_count }"
|
|
520
538
|
resourceUri={encodeResourceUri({
|
|
521
|
-
|
|
539
|
+
environmentName: "my-environment",
|
|
522
540
|
packageName: "analytics",
|
|
523
541
|
modelPath: "models/orders.malloy",
|
|
524
542
|
})}
|
|
@@ -538,14 +556,19 @@ interface RenderedResultProps {
|
|
|
538
556
|
result: string; // JSON result string
|
|
539
557
|
height?: number; // Fixed height in pixels
|
|
540
558
|
onSizeChange?: (height: number) => void; // Callback when size changes
|
|
541
|
-
|
|
559
|
+
drill?: DrillBinding; // `# drill` click handling and its affordance
|
|
542
560
|
}
|
|
543
561
|
|
|
544
562
|
// Usage (result is the JSON string from query execution)
|
|
545
563
|
<RenderedResult
|
|
546
564
|
result={queryResultJson}
|
|
547
|
-
|
|
548
|
-
|
|
565
|
+
drill={{
|
|
566
|
+
onClick: (payload) => {
|
|
567
|
+
console.log("Clicked:", payload.field?.name, payload.value);
|
|
568
|
+
},
|
|
569
|
+
// Which fields' cells should read as clickable. Build the whole binding
|
|
570
|
+
// with `useDrill` to get destination handling and the menu for free.
|
|
571
|
+
canDrill: () => false,
|
|
549
572
|
}}
|
|
550
573
|
/>;
|
|
551
574
|
```
|
|
@@ -567,7 +590,7 @@ const embedded = createEmbeddedQueryResult({
|
|
|
567
590
|
queryName: "by_region",
|
|
568
591
|
sourceName: "orders",
|
|
569
592
|
resourceUri: encodeResourceUri({
|
|
570
|
-
|
|
593
|
+
environmentName: "my-environment",
|
|
571
594
|
packageName: "analytics",
|
|
572
595
|
modelPath: "models/orders.malloy",
|
|
573
596
|
}),
|
|
@@ -581,7 +604,9 @@ const embedded = createEmbeddedQueryResult({
|
|
|
581
604
|
|
|
582
605
|
## Dimensional Filters
|
|
583
606
|
|
|
584
|
-
The SDK supports interactive dimensional filtering for
|
|
607
|
+
The SDK supports interactive dimensional filtering for hand-built data apps.
|
|
608
|
+
Filters are configured through annotations in Malloy source files. The `Notebook`
|
|
609
|
+
component does not use this mechanism; see [Notebooks use `given:`](#notebooks-use-given-not-these-annotations) below.
|
|
585
610
|
|
|
586
611
|
### Filter Types
|
|
587
612
|
|
|
@@ -657,21 +682,16 @@ source: recalls is duckdb.table('data/recalls.csv') extend {
|
|
|
657
682
|
|
|
658
683
|
The `# label="..."` annotation can be placed before or after the `#(filter)` annotation. When present, the label value will be displayed in the filter UI instead of the raw field name.
|
|
659
684
|
|
|
660
|
-
###
|
|
661
|
-
|
|
662
|
-
Enable filters in a notebook by adding a `##(filters)` annotation in a Malloy code cell. This annotation specifies which dimensions should appear as filters using `source.dimension` format:
|
|
663
|
-
|
|
664
|
-
**Simple array format:**
|
|
665
|
-
```malloy
|
|
666
|
-
##(filters) ["flights.origin_code", "carriers.name", "flights.flight_departure"]
|
|
667
|
-
import {flights, carriers} from 'flights.malloy'
|
|
668
|
-
```
|
|
685
|
+
### Notebooks use `given:`, not these annotations
|
|
669
686
|
|
|
670
|
-
The
|
|
687
|
+
The `Notebook` component no longer renders a filter panel from a `##(filters)`
|
|
688
|
+
annotation, and its `retrievalFn` prop is gone with it. A notebook's controls now
|
|
689
|
+
come from the `given:` parameters its model declares, which is the mechanism
|
|
690
|
+
described in [docs/givens.md](../../docs/givens.md). A `##(filters)` annotation in
|
|
691
|
+
a notebook cell is inert.
|
|
671
692
|
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
If no search function is supplied, the filter is ignored.
|
|
693
|
+
The `#(filter)` source annotations above still work, and so do the hooks below.
|
|
694
|
+
They are what a hand-built data app uses; only the notebook's own panel changed.
|
|
675
695
|
|
|
676
696
|
### React Hooks for Programmatic Filtering
|
|
677
697
|
|
|
@@ -684,7 +704,7 @@ import {
|
|
|
684
704
|
} from '@malloy-publisher/sdk';
|
|
685
705
|
|
|
686
706
|
const config: DimensionFiltersConfig = {
|
|
687
|
-
|
|
707
|
+
environment: "malloy-samples",
|
|
688
708
|
package: "faa",
|
|
689
709
|
indexLimit: 1000,
|
|
690
710
|
dimensionSpecs: [
|
|
@@ -743,9 +763,9 @@ function MyComponent() {
|
|
|
743
763
|
} = useServer();
|
|
744
764
|
|
|
745
765
|
// Use API clients directly
|
|
746
|
-
const
|
|
766
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
747
767
|
const model = await apiClients.models.getModel(
|
|
748
|
-
|
|
768
|
+
environmentName,
|
|
749
769
|
packageName,
|
|
750
770
|
modelPath,
|
|
751
771
|
versionId,
|
|
@@ -758,7 +778,7 @@ function MyComponent() {
|
|
|
758
778
|
```typescript
|
|
759
779
|
interface ApiClients {
|
|
760
780
|
models: ModelsApi; // Get/execute models
|
|
761
|
-
|
|
781
|
+
environments: EnvironmentsApi; // CRUD environments
|
|
762
782
|
packages: PackagesApi; // CRUD packages
|
|
763
783
|
notebooks: NotebooksApi; // Get/execute notebooks
|
|
764
784
|
connections: ConnectionsApi; // CRUD connections
|
|
@@ -780,7 +800,7 @@ function MyComponent() {
|
|
|
780
800
|
const { data, isLoading, isError, error } = useQueryWithApiError({
|
|
781
801
|
queryKey: ["my-data", someParam],
|
|
782
802
|
queryFn: async () => {
|
|
783
|
-
const response = await apiClients.
|
|
803
|
+
const response = await apiClients.environments.listEnvironments();
|
|
784
804
|
return response.data;
|
|
785
805
|
},
|
|
786
806
|
});
|
|
@@ -808,18 +828,18 @@ import { useMutationWithApiError } from "@malloy-publisher/sdk";
|
|
|
808
828
|
|
|
809
829
|
function MyComponent() {
|
|
810
830
|
const mutation = useMutationWithApiError({
|
|
811
|
-
mutationFn: async (
|
|
812
|
-
const response = await apiClients.
|
|
831
|
+
mutationFn: async (newEnvironment) => {
|
|
832
|
+
const response = await apiClients.environments.createEnvironment(newEnvironment);
|
|
813
833
|
return response.data;
|
|
814
834
|
},
|
|
815
835
|
onSuccess: () => {
|
|
816
|
-
queryClient.invalidateQueries(["
|
|
836
|
+
queryClient.invalidateQueries(["environments"]);
|
|
817
837
|
},
|
|
818
838
|
});
|
|
819
839
|
|
|
820
840
|
return (
|
|
821
|
-
<button onClick={() => mutation.mutate({ name: "new-
|
|
822
|
-
Create
|
|
841
|
+
<button onClick={() => mutation.mutate({ name: "new-environment" })}>
|
|
842
|
+
Create Environment
|
|
823
843
|
</button>
|
|
824
844
|
);
|
|
825
845
|
}
|
|
@@ -897,7 +917,7 @@ function MyComponent() {
|
|
|
897
917
|
const navigate = useRouterClickHandler();
|
|
898
918
|
|
|
899
919
|
return (
|
|
900
|
-
<button onClick={(e) => navigate("/
|
|
920
|
+
<button onClick={(e) => navigate("/environments/analytics", e)}>
|
|
901
921
|
Go to Analytics
|
|
902
922
|
</button>
|
|
903
923
|
);
|
|
@@ -922,27 +942,27 @@ Create a resource URI from components.
|
|
|
922
942
|
```tsx
|
|
923
943
|
import { encodeResourceUri } from "@malloy-publisher/sdk";
|
|
924
944
|
|
|
925
|
-
//
|
|
926
|
-
const
|
|
927
|
-
|
|
945
|
+
// Environment only
|
|
946
|
+
const environmentUri = encodeResourceUri({
|
|
947
|
+
environmentName: "my-environment",
|
|
928
948
|
});
|
|
929
|
-
// Result: "publisher://
|
|
949
|
+
// Result: "publisher://environments/my-environment"
|
|
930
950
|
|
|
931
951
|
// Package
|
|
932
952
|
const packageUri = encodeResourceUri({
|
|
933
|
-
|
|
953
|
+
environmentName: "my-environment",
|
|
934
954
|
packageName: "analytics",
|
|
935
955
|
});
|
|
936
|
-
// Result: "publisher://
|
|
956
|
+
// Result: "publisher://environments/my-environment/packages/analytics"
|
|
937
957
|
|
|
938
958
|
// Model with version
|
|
939
959
|
const modelUri = encodeResourceUri({
|
|
940
|
-
|
|
960
|
+
environmentName: "my-environment",
|
|
941
961
|
packageName: "analytics",
|
|
942
962
|
modelPath: "models/orders.malloy",
|
|
943
963
|
versionId: "abc123",
|
|
944
964
|
});
|
|
945
|
-
// Result: "publisher://
|
|
965
|
+
// Result: "publisher://environments/my-environment/packages/analytics/models/models/orders.malloy?versionId=abc123"
|
|
946
966
|
```
|
|
947
967
|
|
|
948
968
|
---
|
|
@@ -955,12 +975,12 @@ Parse a resource URI back to components.
|
|
|
955
975
|
import { parseResourceUri } from "@malloy-publisher/sdk";
|
|
956
976
|
|
|
957
977
|
const uri =
|
|
958
|
-
"publisher://
|
|
978
|
+
"publisher://environments/my-environment/packages/analytics/models/orders.malloy?versionId=abc123";
|
|
959
979
|
const parsed = parseResourceUri(uri);
|
|
960
980
|
|
|
961
981
|
// Result:
|
|
962
982
|
// {
|
|
963
|
-
//
|
|
983
|
+
// environmentName: "my-environment",
|
|
964
984
|
// packageName: "analytics",
|
|
965
985
|
// modelPath: "orders.malloy",
|
|
966
986
|
// versionId: "abc123"
|
|
@@ -973,7 +993,7 @@ const parsed = parseResourceUri(uri);
|
|
|
973
993
|
|
|
974
994
|
```typescript
|
|
975
995
|
type ParsedResource = {
|
|
976
|
-
|
|
996
|
+
environmentName: string;
|
|
977
997
|
packageName?: string;
|
|
978
998
|
connectionName?: string;
|
|
979
999
|
versionId?: string;
|
|
@@ -1219,7 +1239,7 @@ import { Grid, Typography, Paper } from "@mui/material";
|
|
|
1219
1239
|
|
|
1220
1240
|
function Dashboard() {
|
|
1221
1241
|
const resourceUri = encodeResourceUri({
|
|
1222
|
-
|
|
1242
|
+
environmentName: "my-environment",
|
|
1223
1243
|
packageName: "analytics",
|
|
1224
1244
|
modelPath: "models/sales.malloy",
|
|
1225
1245
|
});
|
|
@@ -1300,7 +1320,7 @@ import { DataGrid } from "@mui/x-data-grid";
|
|
|
1300
1320
|
|
|
1301
1321
|
function DataTable() {
|
|
1302
1322
|
const resourceUri = encodeResourceUri({
|
|
1303
|
-
|
|
1323
|
+
environmentName: "my-environment",
|
|
1304
1324
|
packageName: "analytics",
|
|
1305
1325
|
modelPath: "models/customers.malloy",
|
|
1306
1326
|
});
|
|
@@ -1353,7 +1373,7 @@ function Explorer() {
|
|
|
1353
1373
|
const [selectedQuery, setSelectedQuery] = useState(null);
|
|
1354
1374
|
|
|
1355
1375
|
const resourceUri = encodeResourceUri({
|
|
1356
|
-
|
|
1376
|
+
environmentName: "my-environment",
|
|
1357
1377
|
packageName: "analytics",
|
|
1358
1378
|
modelPath: "models/orders.malloy",
|
|
1359
1379
|
});
|
|
@@ -1395,24 +1415,24 @@ import { ServerProvider, useServer } from "@malloy-publisher/sdk/client";
|
|
|
1395
1415
|
function MyApp() {
|
|
1396
1416
|
return (
|
|
1397
1417
|
<ServerProvider baseURL="http://localhost:4000/api/v0">
|
|
1398
|
-
<
|
|
1418
|
+
<EnvironmentList />
|
|
1399
1419
|
</ServerProvider>
|
|
1400
1420
|
);
|
|
1401
1421
|
}
|
|
1402
1422
|
|
|
1403
|
-
function
|
|
1423
|
+
function EnvironmentList() {
|
|
1404
1424
|
const { apiClients } = useServer();
|
|
1405
|
-
const [
|
|
1425
|
+
const [environments, setEnvironments] = useState([]);
|
|
1406
1426
|
|
|
1407
1427
|
useEffect(() => {
|
|
1408
|
-
apiClients.
|
|
1409
|
-
.
|
|
1410
|
-
.then((response) =>
|
|
1428
|
+
apiClients.environments
|
|
1429
|
+
.listEnvironments()
|
|
1430
|
+
.then((response) => setEnvironments(response.data));
|
|
1411
1431
|
}, []);
|
|
1412
1432
|
|
|
1413
1433
|
return (
|
|
1414
1434
|
<ul>
|
|
1415
|
-
{
|
|
1435
|
+
{environments.map((p) => (
|
|
1416
1436
|
<li key={p.name}>{p.name}</li>
|
|
1417
1437
|
))}
|
|
1418
1438
|
</ul>
|
|
@@ -1429,8 +1449,8 @@ function ProjectList() {
|
|
|
1429
1449
|
| Component | Description |
|
|
1430
1450
|
| ------------------------- | ----------------------------------------------- |
|
|
1431
1451
|
| `ServerProvider` | Required context provider for API access |
|
|
1432
|
-
| `Home` |
|
|
1433
|
-
| `
|
|
1452
|
+
| `Home` | Environment listing landing page |
|
|
1453
|
+
| `Environment` | Package listing for an environment |
|
|
1434
1454
|
| `Package` | Package detail (models, notebooks, connections) |
|
|
1435
1455
|
| `Model` | Full model explorer with visual query builder |
|
|
1436
1456
|
| `ModelExplorer` | Lower-level query builder component |
|
package/TREE_SHAKING.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) Credible Data Inc.
|
|
3
|
+
SPDX-License-Identifier: MIT
|
|
4
|
+
-->
|
|
5
|
+
|
|
1
6
|
# SDK Tree-Shaking and Code Splitting Guide
|
|
2
7
|
|
|
3
8
|
This document explains how to use the Malloy Publisher SDK's optimized packaging for better tree-shaking and code splitting.
|
|
@@ -29,7 +34,7 @@ function YourComponent() {
|
|
|
29
34
|
const { apiClients } = useServer();
|
|
30
35
|
|
|
31
36
|
// Use API clients for data fetching
|
|
32
|
-
const
|
|
37
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
33
38
|
|
|
34
39
|
return <div>{/* Your custom UI */}</div>;
|
|
35
40
|
}
|
|
@@ -52,7 +57,7 @@ The client entry point (`@malloy-publisher/sdk/client`) is ideal when you:
|
|
|
52
57
|
The client entry exports:
|
|
53
58
|
- `ServerProvider` and `useServer` React components
|
|
54
59
|
- `globalQueryClient` for direct React Query access
|
|
55
|
-
- All OpenAPI-generated client APIs (`ConnectionsApi`, `
|
|
60
|
+
- All OpenAPI-generated client APIs (`ConnectionsApi`, `EnvironmentsApi`, etc.)
|
|
56
61
|
- `Configuration` class for API client setup
|
|
57
62
|
|
|
58
63
|
## Full SDK Usage
|
|
@@ -65,7 +70,7 @@ import {
|
|
|
65
70
|
ServerProvider,
|
|
66
71
|
useServer,
|
|
67
72
|
Home,
|
|
68
|
-
|
|
73
|
+
Environment,
|
|
69
74
|
Package,
|
|
70
75
|
Model,
|
|
71
76
|
Notebook
|
|
@@ -89,7 +94,7 @@ import {
|
|
|
89
94
|
ServerProvider,
|
|
90
95
|
useServer,
|
|
91
96
|
Configuration,
|
|
92
|
-
|
|
97
|
+
EnvironmentsApi,
|
|
93
98
|
ConnectionsApi
|
|
94
99
|
} from '@malloy-publisher/sdk/client';
|
|
95
100
|
|
|
@@ -98,15 +103,15 @@ const config = new Configuration({
|
|
|
98
103
|
basePath: 'https://your-publisher-instance.com'
|
|
99
104
|
});
|
|
100
105
|
|
|
101
|
-
const
|
|
106
|
+
const environmentsApi = new EnvironmentsApi(config);
|
|
102
107
|
|
|
103
108
|
function MyComponent() {
|
|
104
109
|
const { apiClients } = useServer();
|
|
105
110
|
|
|
106
111
|
// Use either the context clients or direct instances
|
|
107
|
-
const
|
|
112
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
108
113
|
// OR
|
|
109
|
-
const
|
|
114
|
+
const environments2 = await environmentsApi.listEnvironments();
|
|
110
115
|
|
|
111
116
|
return <div>{/* Your UI */}</div>;
|
|
112
117
|
}
|
|
@@ -117,17 +122,17 @@ function MyComponent() {
|
|
|
117
122
|
```tsx
|
|
118
123
|
// ✅ Types-only import - zero bundle impact
|
|
119
124
|
import type {
|
|
120
|
-
|
|
125
|
+
EnvironmentsApi,
|
|
121
126
|
ModelsApi,
|
|
122
127
|
QueryResult
|
|
123
128
|
} from '@malloy-publisher/sdk/client';
|
|
124
129
|
|
|
125
130
|
// Your API wrapper
|
|
126
131
|
class MyApiWrapper {
|
|
127
|
-
constructor(private
|
|
132
|
+
constructor(private environmentsApi: EnvironmentsApi) {}
|
|
128
133
|
|
|
129
|
-
async
|
|
130
|
-
return this.
|
|
134
|
+
async getEnvironment(name: string): Promise<QueryResult> {
|
|
135
|
+
return this.environmentsApi.getEnvironment(name);
|
|
131
136
|
}
|
|
132
137
|
}
|
|
133
138
|
```
|
package/bunfig.toml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Copyright (c) Credible Data Inc.
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
[test]
|
|
5
|
+
# Installs a DOM onto globalThis before any spec runs, so React components and
|
|
6
|
+
# hooks in this package can be rendered under `bun test`. See test/setup.ts.
|
|
7
|
+
preload = ["./test/setup.ts"]
|