@malloy-publisher/sdk 0.0.196-dev → 0.0.196
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 +77 -77
- package/TREE_SHAKING.md +11 -11
- package/dist/{ServerProvider-CvZTC0sJ.es.js → ServerProvider-DDScRRDc.es.js} +1393 -1393
- package/dist/ServerProvider-IhQ4aYBm.cjs.js +1 -0
- package/dist/client/api.d.ts +674 -674
- 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 +53 -53
- 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/ServerProvider.d.ts +4 -4
- package/dist/components/index.d.ts +1 -1
- package/dist/{core-mP4paWtU.cjs.js → core-7-3Jcsb0.cjs.js} +1 -1
- package/dist/{core-BrfQApxh.es.js → core-w79IMXAG.es.js} +1 -1
- 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/{index-ClRkROAM.es.js → index-CN0_kZSF.es.js} +13067 -13033
- package/dist/{index-CW09s4Xx.cjs.js → index-Xo_ADux9.cjs.js} +34 -34
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.es.js +21 -21
- package/dist/utils/formatting.d.ts +1 -1
- package/dist/utils/parsing.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/Connections/DeleteConnectionDialog.tsx +1 -0
- package/src/components/Connections/EditConnectionDialog.tsx +2 -0
- package/src/components/{Project → Environment}/About.tsx +8 -4
- package/src/components/{Project → Environment}/AddPackageDialog.tsx +5 -3
- package/src/components/{Project → Environment}/ConnectionExplorer.tsx +14 -14
- package/src/components/{Project → Environment}/DeletePackageDialog.tsx +2 -2
- package/src/components/{Project → Environment}/EditPackageDialog.tsx +18 -13
- package/src/components/{Project/Project.tsx → Environment/Environment.tsx} +6 -6
- package/src/components/{Project → Environment}/Packages.tsx +6 -5
- package/src/components/Environment/index.ts +2 -0
- package/src/components/Home/{AddProjectDialog.tsx → AddEnvironmentDialog.tsx} +21 -18
- package/src/components/Home/{DeleteProjectDialog.tsx → DeleteEnvironmentDialog.tsx} +14 -13
- package/src/components/Home/{EditProjectDialog.tsx → EditEnvironmentDialog.tsx} +32 -28
- package/src/components/Home/Home.tsx +39 -38
- package/src/components/Model/ModelCell.tsx +2 -2
- package/src/components/Model/SourcesExplorer.tsx +2 -2
- package/src/components/Model/useModelData.ts +3 -3
- package/src/components/Notebook/Notebook.tsx +7 -7
- package/src/components/Package/Config.tsx +4 -4
- package/src/components/Package/Connections.tsx +15 -15
- package/src/components/Package/Databases.tsx +4 -4
- package/src/components/Package/Models.tsx +4 -4
- package/src/components/Package/Notebooks.tsx +4 -4
- package/src/components/QueryResult/QueryResult.tsx +6 -6
- package/src/components/ServerProvider.tsx +5 -5
- package/src/components/Workbook/ModelPicker.tsx +4 -4
- package/src/components/Workbook/Workbook.tsx +4 -4
- package/src/components/index.ts +1 -1
- package/src/hooks/useDimensionFiltersFromSpec.ts +5 -5
- package/src/hooks/useDimensionFiltersQuery.ts +6 -6
- package/src/hooks/useDimensionalFilterRangeData.ts +7 -7
- package/src/hooks/useRawQueryData.ts +3 -3
- package/src/index.ts +1 -1
- package/src/utils/formatting.spec.ts +22 -21
- package/src/utils/formatting.ts +8 -7
- package/src/utils/parsing.spec.ts +23 -19
- package/src/utils/parsing.ts +8 -6
- package/dist/ServerProvider-BMsmCksc.cjs.js +0 -1
- 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/Project/Project.d.ts +0 -6
- package/dist/components/Project/index.d.ts +0 -2
- 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/{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
|
@@ -46,7 +46,7 @@ import "@malloy-publisher/sdk/styles.css";
|
|
|
46
46
|
function App() {
|
|
47
47
|
return (
|
|
48
48
|
<ServerProvider baseURL="http://localhost:4000/api/v0">
|
|
49
|
-
<Home
|
|
49
|
+
<Home onClickEnvironment={(path) => console.log("Navigate to:", path)} />
|
|
50
50
|
</ServerProvider>
|
|
51
51
|
);
|
|
52
52
|
}
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
ServerProvider,
|
|
67
67
|
Home,
|
|
68
|
-
|
|
68
|
+
Environment,
|
|
69
69
|
Package,
|
|
70
70
|
Model,
|
|
71
71
|
Notebook,
|
|
@@ -80,13 +80,13 @@ function App() {
|
|
|
80
80
|
<BrowserRouter>
|
|
81
81
|
<Routes>
|
|
82
82
|
<Route path="/" element={<HomePage />} />
|
|
83
|
-
<Route path="/:
|
|
83
|
+
<Route path="/:environmentName" element={<EnvironmentPage />} />
|
|
84
84
|
<Route
|
|
85
|
-
path="/:
|
|
85
|
+
path="/:environmentName/:packageName"
|
|
86
86
|
element={<PackagePage />}
|
|
87
87
|
/>
|
|
88
88
|
<Route
|
|
89
|
-
path="/:
|
|
89
|
+
path="/:environmentName/:packageName/*"
|
|
90
90
|
element={<ModelPage />}
|
|
91
91
|
/>
|
|
92
92
|
</Routes>
|
|
@@ -97,20 +97,20 @@ function App() {
|
|
|
97
97
|
|
|
98
98
|
function HomePage() {
|
|
99
99
|
const navigate = useRouterClickHandler();
|
|
100
|
-
return <Home
|
|
100
|
+
return <Home onClickEnvironment={navigate} />;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
function
|
|
103
|
+
function EnvironmentPage() {
|
|
104
104
|
const navigate = useRouterClickHandler();
|
|
105
|
-
const {
|
|
106
|
-
const resourceUri = encodeResourceUri({
|
|
107
|
-
return <
|
|
105
|
+
const { environmentName } = useParams();
|
|
106
|
+
const resourceUri = encodeResourceUri({ environmentName });
|
|
107
|
+
return <Environment onSelectPackage={navigate} resourceUri={resourceUri} />;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
function PackagePage() {
|
|
111
111
|
const navigate = useRouterClickHandler();
|
|
112
|
-
const {
|
|
113
|
-
const resourceUri = encodeResourceUri({
|
|
112
|
+
const { environmentName, packageName } = useParams();
|
|
113
|
+
const resourceUri = encodeResourceUri({ environmentName, packageName });
|
|
114
114
|
return <Package onClickPackageFile={navigate} resourceUri={resourceUri} />;
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -118,7 +118,7 @@ function ModelPage() {
|
|
|
118
118
|
const params = useParams();
|
|
119
119
|
const modelPath = params["*"];
|
|
120
120
|
const resourceUri = encodeResourceUri({
|
|
121
|
-
|
|
121
|
+
environmentName: params.environmentName,
|
|
122
122
|
packageName: params.packageName,
|
|
123
123
|
modelPath,
|
|
124
124
|
});
|
|
@@ -142,14 +142,14 @@ function ModelPage() {
|
|
|
142
142
|
The SDK uses a standardized URI format to identify resources:
|
|
143
143
|
|
|
144
144
|
```
|
|
145
|
-
publisher://
|
|
145
|
+
publisher://environments/{environmentName}/packages/{packageName}/models/{modelPath}?versionId={version}
|
|
146
146
|
```
|
|
147
147
|
|
|
148
148
|
Examples:
|
|
149
149
|
|
|
150
|
-
-
|
|
151
|
-
- Package: `publisher://
|
|
152
|
-
- Model: `publisher://
|
|
150
|
+
- Environment: `publisher://environments/my-environment`
|
|
151
|
+
- Package: `publisher://environments/my-environment/packages/analytics`
|
|
152
|
+
- Model: `publisher://environments/my-environment/packages/analytics/models/orders.malloy`
|
|
153
153
|
|
|
154
154
|
Use the `encodeResourceUri()` and `parseResourceUri()` utilities to work with these URIs.
|
|
155
155
|
|
|
@@ -159,8 +159,8 @@ The SDK components follow a natural hierarchy:
|
|
|
159
159
|
|
|
160
160
|
```
|
|
161
161
|
ServerProvider (required wrapper)
|
|
162
|
-
├── Home (list all
|
|
163
|
-
│ └──
|
|
162
|
+
├── Home (list all environments)
|
|
163
|
+
│ └── Environment (show packages in an environment)
|
|
164
164
|
│ └── Package (show models, notebooks, connections)
|
|
165
165
|
│ ├── Model (visual query builder + named queries)
|
|
166
166
|
│ └── Notebook (read-only notebook viewer)
|
|
@@ -174,13 +174,13 @@ Components accept callback functions for navigation rather than handling routing
|
|
|
174
174
|
```tsx
|
|
175
175
|
// With React Router
|
|
176
176
|
const navigate = useRouterClickHandler();
|
|
177
|
-
<Home
|
|
177
|
+
<Home onClickEnvironment={navigate} />
|
|
178
178
|
|
|
179
179
|
// Custom navigation
|
|
180
|
-
<Home
|
|
180
|
+
<Home onClickEnvironment={(path) => window.location.href = path} />
|
|
181
181
|
|
|
182
182
|
// SPA with history
|
|
183
|
-
<Home
|
|
183
|
+
<Home onClickEnvironment={(path) => history.push(path)} />
|
|
184
184
|
```
|
|
185
185
|
|
|
186
186
|
---
|
|
@@ -195,7 +195,7 @@ The `ServerProvider` is the required context provider that wraps your applicatio
|
|
|
195
195
|
| ---------------- | ----------------------- | ------------- | -------------------------------------------------------------------- |
|
|
196
196
|
| `baseURL` | `string` | Auto-detected | Base URL of the Publisher API (e.g., `http://localhost:4000/api/v0`) |
|
|
197
197
|
| `getAccessToken` | `() => Promise<string>` | `undefined` | Async function returning auth token |
|
|
198
|
-
| `mutable` | `boolean` | `true` | Enable/disable
|
|
198
|
+
| `mutable` | `boolean` | `true` | Enable/disable environment/package management UI |
|
|
199
199
|
|
|
200
200
|
### Basic Usage
|
|
201
201
|
|
|
@@ -238,19 +238,19 @@ async function getAccessToken() {
|
|
|
238
238
|
|
|
239
239
|
### Home
|
|
240
240
|
|
|
241
|
-
Displays a landing page with feature cards and a list of all available
|
|
241
|
+
Displays a landing page with feature cards and a list of all available environments.
|
|
242
242
|
|
|
243
243
|
```tsx
|
|
244
244
|
import { Home } from "@malloy-publisher/sdk";
|
|
245
245
|
|
|
246
246
|
interface HomeProps {
|
|
247
|
-
|
|
247
|
+
onClickEnvironment?: (path: string, event?: React.MouseEvent) => void;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// Usage
|
|
251
251
|
<Home
|
|
252
|
-
|
|
253
|
-
// path is like "/my-
|
|
252
|
+
onClickEnvironment={(path, event) => {
|
|
253
|
+
// path is like "/my-environment/"
|
|
254
254
|
navigate(path);
|
|
255
255
|
}}
|
|
256
256
|
/>;
|
|
@@ -260,27 +260,27 @@ interface HomeProps {
|
|
|
260
260
|
|
|
261
261
|
- Hero section with Publisher branding
|
|
262
262
|
- Feature cards (Ad Hoc Analysis, Notebook Dashboards, AI Agents)
|
|
263
|
-
-
|
|
264
|
-
- Add/Edit/Delete
|
|
263
|
+
- Environment listing with descriptions
|
|
264
|
+
- Add/Edit/Delete environment dialogs (when `mutable=true`)
|
|
265
265
|
|
|
266
266
|
---
|
|
267
267
|
|
|
268
|
-
###
|
|
268
|
+
### Environment
|
|
269
269
|
|
|
270
|
-
Shows all packages within
|
|
270
|
+
Shows all packages within an environment.
|
|
271
271
|
|
|
272
272
|
```tsx
|
|
273
|
-
import {
|
|
273
|
+
import { Environment, encodeResourceUri } from "@malloy-publisher/sdk";
|
|
274
274
|
|
|
275
|
-
interface
|
|
275
|
+
interface EnvironmentProps {
|
|
276
276
|
onSelectPackage: (path: string, event?: React.MouseEvent) => void;
|
|
277
277
|
resourceUri: string;
|
|
278
278
|
}
|
|
279
279
|
|
|
280
280
|
// Usage
|
|
281
|
-
const resourceUri = encodeResourceUri({
|
|
281
|
+
const resourceUri = encodeResourceUri({ environmentName: "my-environment" });
|
|
282
282
|
|
|
283
|
-
<
|
|
283
|
+
<Environment
|
|
284
284
|
onSelectPackage={(path) => navigate(path)}
|
|
285
285
|
resourceUri={resourceUri}
|
|
286
286
|
/>;
|
|
@@ -290,7 +290,7 @@ const resourceUri = encodeResourceUri({ projectName: "my-project" });
|
|
|
290
290
|
|
|
291
291
|
- Package listing with version info
|
|
292
292
|
- Add/Edit/Delete package dialogs (when `mutable=true`)
|
|
293
|
-
-
|
|
293
|
+
- Environment README display
|
|
294
294
|
|
|
295
295
|
---
|
|
296
296
|
|
|
@@ -308,7 +308,7 @@ interface PackageProps {
|
|
|
308
308
|
|
|
309
309
|
// Usage
|
|
310
310
|
const resourceUri = encodeResourceUri({
|
|
311
|
-
|
|
311
|
+
environmentName: "my-environment",
|
|
312
312
|
packageName: "analytics",
|
|
313
313
|
});
|
|
314
314
|
|
|
@@ -350,7 +350,7 @@ interface QueryExplorerResult {
|
|
|
350
350
|
|
|
351
351
|
// Usage
|
|
352
352
|
const resourceUri = encodeResourceUri({
|
|
353
|
-
|
|
353
|
+
environmentName: "my-environment",
|
|
354
354
|
packageName: "analytics",
|
|
355
355
|
modelPath: "models/orders.malloy",
|
|
356
356
|
});
|
|
@@ -428,7 +428,7 @@ interface NotebookProps {
|
|
|
428
428
|
|
|
429
429
|
// Usage
|
|
430
430
|
const resourceUri = encodeResourceUri({
|
|
431
|
-
|
|
431
|
+
environmentName: "my-environment",
|
|
432
432
|
packageName: "analytics",
|
|
433
433
|
modelPath: "notebooks/sales-dashboard.malloynb",
|
|
434
434
|
});
|
|
@@ -465,7 +465,7 @@ interface WorkbookProps {
|
|
|
465
465
|
// Usage
|
|
466
466
|
const workbookStorage = new BrowserWorkbookStorage();
|
|
467
467
|
const resourceUri = encodeResourceUri({
|
|
468
|
-
|
|
468
|
+
environmentName: "my-environment",
|
|
469
469
|
packageName: "analytics",
|
|
470
470
|
});
|
|
471
471
|
|
|
@@ -508,7 +508,7 @@ interface QueryResultProps {
|
|
|
508
508
|
sourceName="orders"
|
|
509
509
|
queryName="by_region"
|
|
510
510
|
resourceUri={encodeResourceUri({
|
|
511
|
-
|
|
511
|
+
environmentName: "my-environment",
|
|
512
512
|
packageName: "analytics",
|
|
513
513
|
modelPath: "models/orders.malloy",
|
|
514
514
|
})}
|
|
@@ -518,7 +518,7 @@ interface QueryResultProps {
|
|
|
518
518
|
<QueryResult
|
|
519
519
|
query="run: orders -> { group_by: status; aggregate: order_count }"
|
|
520
520
|
resourceUri={encodeResourceUri({
|
|
521
|
-
|
|
521
|
+
environmentName: "my-environment",
|
|
522
522
|
packageName: "analytics",
|
|
523
523
|
modelPath: "models/orders.malloy",
|
|
524
524
|
})}
|
|
@@ -567,7 +567,7 @@ const embedded = createEmbeddedQueryResult({
|
|
|
567
567
|
queryName: "by_region",
|
|
568
568
|
sourceName: "orders",
|
|
569
569
|
resourceUri: encodeResourceUri({
|
|
570
|
-
|
|
570
|
+
environmentName: "my-environment",
|
|
571
571
|
packageName: "analytics",
|
|
572
572
|
modelPath: "models/orders.malloy",
|
|
573
573
|
}),
|
|
@@ -684,7 +684,7 @@ import {
|
|
|
684
684
|
} from '@malloy-publisher/sdk';
|
|
685
685
|
|
|
686
686
|
const config: DimensionFiltersConfig = {
|
|
687
|
-
|
|
687
|
+
environment: "malloy-samples",
|
|
688
688
|
package: "faa",
|
|
689
689
|
indexLimit: 1000,
|
|
690
690
|
dimensionSpecs: [
|
|
@@ -743,9 +743,9 @@ function MyComponent() {
|
|
|
743
743
|
} = useServer();
|
|
744
744
|
|
|
745
745
|
// Use API clients directly
|
|
746
|
-
const
|
|
746
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
747
747
|
const model = await apiClients.models.getModel(
|
|
748
|
-
|
|
748
|
+
environmentName,
|
|
749
749
|
packageName,
|
|
750
750
|
modelPath,
|
|
751
751
|
versionId,
|
|
@@ -758,7 +758,7 @@ function MyComponent() {
|
|
|
758
758
|
```typescript
|
|
759
759
|
interface ApiClients {
|
|
760
760
|
models: ModelsApi; // Get/execute models
|
|
761
|
-
|
|
761
|
+
environments: EnvironmentsApi; // CRUD environments
|
|
762
762
|
packages: PackagesApi; // CRUD packages
|
|
763
763
|
notebooks: NotebooksApi; // Get/execute notebooks
|
|
764
764
|
connections: ConnectionsApi; // CRUD connections
|
|
@@ -780,7 +780,7 @@ function MyComponent() {
|
|
|
780
780
|
const { data, isLoading, isError, error } = useQueryWithApiError({
|
|
781
781
|
queryKey: ["my-data", someParam],
|
|
782
782
|
queryFn: async () => {
|
|
783
|
-
const response = await apiClients.
|
|
783
|
+
const response = await apiClients.environments.listEnvironments();
|
|
784
784
|
return response.data;
|
|
785
785
|
},
|
|
786
786
|
});
|
|
@@ -808,18 +808,18 @@ import { useMutationWithApiError } from "@malloy-publisher/sdk";
|
|
|
808
808
|
|
|
809
809
|
function MyComponent() {
|
|
810
810
|
const mutation = useMutationWithApiError({
|
|
811
|
-
mutationFn: async (
|
|
812
|
-
const response = await apiClients.
|
|
811
|
+
mutationFn: async (newEnvironment) => {
|
|
812
|
+
const response = await apiClients.environments.createEnvironment(newEnvironment);
|
|
813
813
|
return response.data;
|
|
814
814
|
},
|
|
815
815
|
onSuccess: () => {
|
|
816
|
-
queryClient.invalidateQueries(["
|
|
816
|
+
queryClient.invalidateQueries(["environments"]);
|
|
817
817
|
},
|
|
818
818
|
});
|
|
819
819
|
|
|
820
820
|
return (
|
|
821
|
-
<button onClick={() => mutation.mutate({ name: "new-
|
|
822
|
-
Create
|
|
821
|
+
<button onClick={() => mutation.mutate({ name: "new-environment" })}>
|
|
822
|
+
Create Environment
|
|
823
823
|
</button>
|
|
824
824
|
);
|
|
825
825
|
}
|
|
@@ -897,7 +897,7 @@ function MyComponent() {
|
|
|
897
897
|
const navigate = useRouterClickHandler();
|
|
898
898
|
|
|
899
899
|
return (
|
|
900
|
-
<button onClick={(e) => navigate("/
|
|
900
|
+
<button onClick={(e) => navigate("/environments/analytics", e)}>
|
|
901
901
|
Go to Analytics
|
|
902
902
|
</button>
|
|
903
903
|
);
|
|
@@ -922,27 +922,27 @@ Create a resource URI from components.
|
|
|
922
922
|
```tsx
|
|
923
923
|
import { encodeResourceUri } from "@malloy-publisher/sdk";
|
|
924
924
|
|
|
925
|
-
//
|
|
926
|
-
const
|
|
927
|
-
|
|
925
|
+
// Environment only
|
|
926
|
+
const environmentUri = encodeResourceUri({
|
|
927
|
+
environmentName: "my-environment",
|
|
928
928
|
});
|
|
929
|
-
// Result: "publisher://
|
|
929
|
+
// Result: "publisher://environments/my-environment"
|
|
930
930
|
|
|
931
931
|
// Package
|
|
932
932
|
const packageUri = encodeResourceUri({
|
|
933
|
-
|
|
933
|
+
environmentName: "my-environment",
|
|
934
934
|
packageName: "analytics",
|
|
935
935
|
});
|
|
936
|
-
// Result: "publisher://
|
|
936
|
+
// Result: "publisher://environments/my-environment/packages/analytics"
|
|
937
937
|
|
|
938
938
|
// Model with version
|
|
939
939
|
const modelUri = encodeResourceUri({
|
|
940
|
-
|
|
940
|
+
environmentName: "my-environment",
|
|
941
941
|
packageName: "analytics",
|
|
942
942
|
modelPath: "models/orders.malloy",
|
|
943
943
|
versionId: "abc123",
|
|
944
944
|
});
|
|
945
|
-
// Result: "publisher://
|
|
945
|
+
// Result: "publisher://environments/my-environment/packages/analytics/models/models/orders.malloy?versionId=abc123"
|
|
946
946
|
```
|
|
947
947
|
|
|
948
948
|
---
|
|
@@ -955,12 +955,12 @@ Parse a resource URI back to components.
|
|
|
955
955
|
import { parseResourceUri } from "@malloy-publisher/sdk";
|
|
956
956
|
|
|
957
957
|
const uri =
|
|
958
|
-
"publisher://
|
|
958
|
+
"publisher://environments/my-environment/packages/analytics/models/orders.malloy?versionId=abc123";
|
|
959
959
|
const parsed = parseResourceUri(uri);
|
|
960
960
|
|
|
961
961
|
// Result:
|
|
962
962
|
// {
|
|
963
|
-
//
|
|
963
|
+
// environmentName: "my-environment",
|
|
964
964
|
// packageName: "analytics",
|
|
965
965
|
// modelPath: "orders.malloy",
|
|
966
966
|
// versionId: "abc123"
|
|
@@ -973,7 +973,7 @@ const parsed = parseResourceUri(uri);
|
|
|
973
973
|
|
|
974
974
|
```typescript
|
|
975
975
|
type ParsedResource = {
|
|
976
|
-
|
|
976
|
+
environmentName: string;
|
|
977
977
|
packageName?: string;
|
|
978
978
|
connectionName?: string;
|
|
979
979
|
versionId?: string;
|
|
@@ -1219,7 +1219,7 @@ import { Grid, Typography, Paper } from "@mui/material";
|
|
|
1219
1219
|
|
|
1220
1220
|
function Dashboard() {
|
|
1221
1221
|
const resourceUri = encodeResourceUri({
|
|
1222
|
-
|
|
1222
|
+
environmentName: "my-environment",
|
|
1223
1223
|
packageName: "analytics",
|
|
1224
1224
|
modelPath: "models/sales.malloy",
|
|
1225
1225
|
});
|
|
@@ -1300,7 +1300,7 @@ import { DataGrid } from "@mui/x-data-grid";
|
|
|
1300
1300
|
|
|
1301
1301
|
function DataTable() {
|
|
1302
1302
|
const resourceUri = encodeResourceUri({
|
|
1303
|
-
|
|
1303
|
+
environmentName: "my-environment",
|
|
1304
1304
|
packageName: "analytics",
|
|
1305
1305
|
modelPath: "models/customers.malloy",
|
|
1306
1306
|
});
|
|
@@ -1353,7 +1353,7 @@ function Explorer() {
|
|
|
1353
1353
|
const [selectedQuery, setSelectedQuery] = useState(null);
|
|
1354
1354
|
|
|
1355
1355
|
const resourceUri = encodeResourceUri({
|
|
1356
|
-
|
|
1356
|
+
environmentName: "my-environment",
|
|
1357
1357
|
packageName: "analytics",
|
|
1358
1358
|
modelPath: "models/orders.malloy",
|
|
1359
1359
|
});
|
|
@@ -1395,24 +1395,24 @@ import { ServerProvider, useServer } from "@malloy-publisher/sdk/client";
|
|
|
1395
1395
|
function MyApp() {
|
|
1396
1396
|
return (
|
|
1397
1397
|
<ServerProvider baseURL="http://localhost:4000/api/v0">
|
|
1398
|
-
<
|
|
1398
|
+
<EnvironmentList />
|
|
1399
1399
|
</ServerProvider>
|
|
1400
1400
|
);
|
|
1401
1401
|
}
|
|
1402
1402
|
|
|
1403
|
-
function
|
|
1403
|
+
function EnvironmentList() {
|
|
1404
1404
|
const { apiClients } = useServer();
|
|
1405
|
-
const [
|
|
1405
|
+
const [environments, setEnvironments] = useState([]);
|
|
1406
1406
|
|
|
1407
1407
|
useEffect(() => {
|
|
1408
|
-
apiClients.
|
|
1409
|
-
.
|
|
1410
|
-
.then((response) =>
|
|
1408
|
+
apiClients.environments
|
|
1409
|
+
.listEnvironments()
|
|
1410
|
+
.then((response) => setEnvironments(response.data));
|
|
1411
1411
|
}, []);
|
|
1412
1412
|
|
|
1413
1413
|
return (
|
|
1414
1414
|
<ul>
|
|
1415
|
-
{
|
|
1415
|
+
{environments.map((p) => (
|
|
1416
1416
|
<li key={p.name}>{p.name}</li>
|
|
1417
1417
|
))}
|
|
1418
1418
|
</ul>
|
|
@@ -1429,8 +1429,8 @@ function ProjectList() {
|
|
|
1429
1429
|
| Component | Description |
|
|
1430
1430
|
| ------------------------- | ----------------------------------------------- |
|
|
1431
1431
|
| `ServerProvider` | Required context provider for API access |
|
|
1432
|
-
| `Home` |
|
|
1433
|
-
| `
|
|
1432
|
+
| `Home` | Environment listing landing page |
|
|
1433
|
+
| `Environment` | Package listing for an environment |
|
|
1434
1434
|
| `Package` | Package detail (models, notebooks, connections) |
|
|
1435
1435
|
| `Model` | Full model explorer with visual query builder |
|
|
1436
1436
|
| `ModelExplorer` | Lower-level query builder component |
|
package/TREE_SHAKING.md
CHANGED
|
@@ -29,7 +29,7 @@ function YourComponent() {
|
|
|
29
29
|
const { apiClients } = useServer();
|
|
30
30
|
|
|
31
31
|
// Use API clients for data fetching
|
|
32
|
-
const
|
|
32
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
33
33
|
|
|
34
34
|
return <div>{/* Your custom UI */}</div>;
|
|
35
35
|
}
|
|
@@ -52,7 +52,7 @@ The client entry point (`@malloy-publisher/sdk/client`) is ideal when you:
|
|
|
52
52
|
The client entry exports:
|
|
53
53
|
- `ServerProvider` and `useServer` React components
|
|
54
54
|
- `globalQueryClient` for direct React Query access
|
|
55
|
-
- All OpenAPI-generated client APIs (`ConnectionsApi`, `
|
|
55
|
+
- All OpenAPI-generated client APIs (`ConnectionsApi`, `EnvironmentsApi`, etc.)
|
|
56
56
|
- `Configuration` class for API client setup
|
|
57
57
|
|
|
58
58
|
## Full SDK Usage
|
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
ServerProvider,
|
|
66
66
|
useServer,
|
|
67
67
|
Home,
|
|
68
|
-
|
|
68
|
+
Environment,
|
|
69
69
|
Package,
|
|
70
70
|
Model,
|
|
71
71
|
Notebook
|
|
@@ -89,7 +89,7 @@ import {
|
|
|
89
89
|
ServerProvider,
|
|
90
90
|
useServer,
|
|
91
91
|
Configuration,
|
|
92
|
-
|
|
92
|
+
EnvironmentsApi,
|
|
93
93
|
ConnectionsApi
|
|
94
94
|
} from '@malloy-publisher/sdk/client';
|
|
95
95
|
|
|
@@ -98,15 +98,15 @@ const config = new Configuration({
|
|
|
98
98
|
basePath: 'https://your-publisher-instance.com'
|
|
99
99
|
});
|
|
100
100
|
|
|
101
|
-
const
|
|
101
|
+
const environmentsApi = new EnvironmentsApi(config);
|
|
102
102
|
|
|
103
103
|
function MyComponent() {
|
|
104
104
|
const { apiClients } = useServer();
|
|
105
105
|
|
|
106
106
|
// Use either the context clients or direct instances
|
|
107
|
-
const
|
|
107
|
+
const environments = await apiClients.environments.listEnvironments();
|
|
108
108
|
// OR
|
|
109
|
-
const
|
|
109
|
+
const environments2 = await environmentsApi.listEnvironments();
|
|
110
110
|
|
|
111
111
|
return <div>{/* Your UI */}</div>;
|
|
112
112
|
}
|
|
@@ -117,17 +117,17 @@ function MyComponent() {
|
|
|
117
117
|
```tsx
|
|
118
118
|
// ✅ Types-only import - zero bundle impact
|
|
119
119
|
import type {
|
|
120
|
-
|
|
120
|
+
EnvironmentsApi,
|
|
121
121
|
ModelsApi,
|
|
122
122
|
QueryResult
|
|
123
123
|
} from '@malloy-publisher/sdk/client';
|
|
124
124
|
|
|
125
125
|
// Your API wrapper
|
|
126
126
|
class MyApiWrapper {
|
|
127
|
-
constructor(private
|
|
127
|
+
constructor(private environmentsApi: EnvironmentsApi) {}
|
|
128
128
|
|
|
129
|
-
async
|
|
130
|
-
return this.
|
|
129
|
+
async getEnvironment(name: string): Promise<QueryResult> {
|
|
130
|
+
return this.environmentsApi.getEnvironment(name);
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
```
|