@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/test/README.md
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
Copyright (c) Credible Data Inc.
|
|
3
|
+
SPDX-License-Identifier: MIT
|
|
4
|
+
-->
|
|
5
|
+
|
|
6
|
+
# Testing React components and hooks in the SDK
|
|
7
|
+
|
|
8
|
+
`bun test` in this package runs with a DOM, so components and hooks can be
|
|
9
|
+
rendered and asserted on. Before this existed every SDK spec was a pure
|
|
10
|
+
function, and anything touching React was untestable.
|
|
11
|
+
|
|
12
|
+
Run them the usual way:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
cd packages/sdk && bun test # whole package
|
|
16
|
+
cd packages/sdk && bun test src/components/given # one directory
|
|
17
|
+
cd packages/sdk && bun test -t "explicit false" # one test by name
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Run them from this package, not from the repo root. Bun reads `bunfig.toml`
|
|
21
|
+
from the working directory, so a spec invoked from the root gets no preload and
|
|
22
|
+
fails with `ReferenceError: document is not defined`. `bun run test:sdk` at the
|
|
23
|
+
root is fine; it changes directory first, and so does CI.
|
|
24
|
+
|
|
25
|
+
## How the DOM gets there
|
|
26
|
+
|
|
27
|
+
`bunfig.toml` preloads `test/setup.ts`, which registers happy-dom onto
|
|
28
|
+
`globalThis` and installs Testing Library's `cleanup` in an `afterEach`. There
|
|
29
|
+
is no per-file setup: write a spec and it has a document.
|
|
30
|
+
|
|
31
|
+
Two details in that file are load-bearing. Testing Library is imported
|
|
32
|
+
dynamically, after the registrator runs, because it binds to `document` at
|
|
33
|
+
module scope and a static import would hoist above the line that creates one.
|
|
34
|
+
And the setup file lives outside `src/` because `vite-plugin-dts` generates
|
|
35
|
+
declarations for everything under `src/`, so a setup file in there would ship a
|
|
36
|
+
stray `.d.ts` in `dist/`.
|
|
37
|
+
|
|
38
|
+
happy-dom rather than jsdom because `@happy-dom/global-registrator` is designed
|
|
39
|
+
to install into an existing runtime, which is exactly what a Bun preload can do.
|
|
40
|
+
jsdom expects to own the test environment and offers no equivalent hook, so
|
|
41
|
+
using it would have meant bringing in a second test runner alongside `bun test`.
|
|
42
|
+
|
|
43
|
+
## Testing a component
|
|
44
|
+
|
|
45
|
+
```tsx
|
|
46
|
+
import { describe, expect, it, mock } from "bun:test";
|
|
47
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
48
|
+
import type { GivenValue } from "../../hooks/givenValue";
|
|
49
|
+
import { GivenInput } from "./GivenInput";
|
|
50
|
+
|
|
51
|
+
it("reverts rather than blanking the field", () => {
|
|
52
|
+
const onChange = mock((_next: GivenValue) => {});
|
|
53
|
+
render(<GivenInput given={{ name: "region" }} value="CA" onChange={onChange} />);
|
|
54
|
+
|
|
55
|
+
fireEvent.click(screen.getByLabelText("clear value"));
|
|
56
|
+
|
|
57
|
+
expect(onChange.mock.calls[0][0]).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Type the mock's parameter. `mock(() => {})` is a zero-argument mock, so
|
|
62
|
+
`mock.calls` is an array of empty tuples: reading `[0][0]` does not compile,
|
|
63
|
+
and nothing constrains what the component actually passes you.
|
|
64
|
+
|
|
65
|
+
Query by what a user can perceive (`getByLabelText`, `getByRole`,
|
|
66
|
+
`getByText`) rather than by class name or component internals, so a test
|
|
67
|
+
survives a restyle. Use `queryAllBy*` when asserting something is absent;
|
|
68
|
+
`getBy*` throws instead of returning empty.
|
|
69
|
+
|
|
70
|
+
`src/components/given/GivenInput.spec.tsx` is the worked example.
|
|
71
|
+
|
|
72
|
+
## Testing a hook
|
|
73
|
+
|
|
74
|
+
No JSX is needed, so a hook spec is a plain `.spec.ts`.
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
import { act, renderHook } from "@testing-library/react";
|
|
78
|
+
|
|
79
|
+
const { result, rerender } = renderHook(
|
|
80
|
+
({ types }) => useGivensState({ declaredTypes: types, autorun: true }),
|
|
81
|
+
{ initialProps: { types: new Map([["REGION", "filter<string>"]]) } },
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
act(() => result.current.setGiven("REGION", "West"));
|
|
85
|
+
expect(result.current.applied.get("REGION")).toBe("West");
|
|
86
|
+
|
|
87
|
+
rerender({ types: new Map() }); // props change, effects flush
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
`result.current` is re-read after every update, so hold onto the object rather
|
|
91
|
+
than destructuring off it. Wrap anything that sets state in `act()`.
|
|
92
|
+
|
|
93
|
+
`src/hooks/useGivensState.spec.ts` is the worked example, and two things in it
|
|
94
|
+
are worth copying. The test named "settles when its inputs are fresh objects on
|
|
95
|
+
every render" passes deliberately unmemoized arguments to prove the hook settles
|
|
96
|
+
instead of re-rendering forever; that is a real defect class here, and it is
|
|
97
|
+
invisible to a test that only ever passes stable inputs. Named rather than
|
|
98
|
+
pointed at by position, because "its last test" stopped being that one the first
|
|
99
|
+
time a test was appended. And its `renderWithUrlHost` helper feeds the hook's own output back in
|
|
100
|
+
as props, the way the page hosts do through the URL. Several defects in that
|
|
101
|
+
hook only appear on the second half of that loop, so a spec that treats the
|
|
102
|
+
props as constant cannot see them.
|
|
103
|
+
|
|
104
|
+
## Testing something that talks to the server
|
|
105
|
+
|
|
106
|
+
Anything that calls `useServer()` needs `ServerProvider` replaced, because the
|
|
107
|
+
real one builds axios clients against `window.location`. `test/serverProvider.tsx`
|
|
108
|
+
is the one way to do it:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { cacheKeys, clearCache, mockServerProvider, pending, serverWrapper }
|
|
112
|
+
from "../../../test/serverProvider";
|
|
113
|
+
|
|
114
|
+
const getDashboard = mock(() => pending());
|
|
115
|
+
mockServerProvider({ dashboards: { getDashboard } });
|
|
116
|
+
|
|
117
|
+
// AFTER the line above, never a static import: it would hoist past the stub.
|
|
118
|
+
const { default: Dashboard } = await import("./Dashboard");
|
|
119
|
+
|
|
120
|
+
render(<Dashboard resourceUri={URI} dashboard="ops" />, { wrapper: serverWrapper });
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Three things that file exists to get right.
|
|
124
|
+
|
|
125
|
+
`mock.module` is **process-global and cannot be undone**. `bun test` runs every
|
|
126
|
+
spec in one process, so a stub registered here is the `ServerProvider` every
|
|
127
|
+
later spec sees, in file order. Nothing in Bun scopes it to a file. That is
|
|
128
|
+
survivable only while every spec registers the same shape, which is why the
|
|
129
|
+
stub lives in one place rather than being hand-rolled per file: a spec that
|
|
130
|
+
inherits someone else's stub still gets `{ server, apiClients }`, and fails on
|
|
131
|
+
a missing client rather than on a missing property of `undefined`. If you ever
|
|
132
|
+
need a spec to see the REAL `ServerProvider`, it cannot share a process with
|
|
133
|
+
these — that would need its own `bun test` invocation.
|
|
134
|
+
|
|
135
|
+
`serverWrapper` provides `globalQueryClient`, the same instance `ServerProvider`
|
|
136
|
+
provides in production. It is not decoration: `useQueryWithApiError` passes that
|
|
137
|
+
client to `useQuery` explicitly while `useQueries` resolves one from context, so
|
|
138
|
+
a spec that supplies a fresh client sees only half its component's queries.
|
|
139
|
+
Sharing one client is also why `clearCache()` belongs in `beforeEach` — the
|
|
140
|
+
cache outlives the test that filled it.
|
|
141
|
+
|
|
142
|
+
`cacheKeys(prefix)` reads the query keys back out as strings. Assert on the
|
|
143
|
+
whole key, not just on the value you added: a key is the only thing standing
|
|
144
|
+
between two requests that differ, so "the version is in there somewhere" passes
|
|
145
|
+
for a key that also grew a slot it should not have. Note the two key shapes —
|
|
146
|
+
`useQueryWithApiError` appends the server URL, plain `useQueries` does not.
|
|
147
|
+
|
|
148
|
+
## Where specs live, and what not to break
|
|
149
|
+
|
|
150
|
+
Co-locate a spec with what it tests, matching the existing `*.spec.ts` files.
|
|
151
|
+
|
|
152
|
+
`tsconfig.json` excludes test files, because that config drives the declaration
|
|
153
|
+
build and anything left in it emits a stray `.d.ts` into `dist/`, which ships.
|
|
154
|
+
`bun test` discovers four name patterns, and both configs list all four with
|
|
155
|
+
the extension left open, so `.tsx`/`.mts`/`.cts` cannot slip past:
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
*.spec.* *.test.* *_spec.* *_test.*
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Excluded is not unchecked. `tsconfig.spec.json` includes the same four plus
|
|
162
|
+
everything in `test/`, and the root `typecheck:sdk` runs it, so a type error in
|
|
163
|
+
a spec fails the gate. Without it there would be no gate at all: `bun test`
|
|
164
|
+
strips types without checking them, and eslint in this package is not
|
|
165
|
+
type-aware.
|
|
166
|
+
|
|
167
|
+
Keep the two lists in step, and if you add a pattern, put it in both and check
|
|
168
|
+
`dist/` afterwards.
|
|
169
|
+
|
|
170
|
+
## One thing happy-dom will let you get wrong
|
|
171
|
+
|
|
172
|
+
happy-dom does not implement the HTML value-sanitization algorithm. Set
|
|
173
|
+
`"12abc"` on a raw `<input type="number">` and happy-dom keeps it, where a real
|
|
174
|
+
browser discards it and leaves the field empty (checked against Chromium). So a
|
|
175
|
+
test that hands a number input a non-numeric value and asserts on what it
|
|
176
|
+
displays can pass here and be false in production.
|
|
177
|
+
|
|
178
|
+
Note where that does *not* bite: it only fires if your code passes the bad
|
|
179
|
+
value through to the DOM. `GivenInput` substitutes `""` first, so both engines
|
|
180
|
+
agree there, and its non-numeric test asserts on the revert affordance rather
|
|
181
|
+
than the displayed value.
|
|
182
|
+
|
|
183
|
+
The general form of that trap: happy-dom is a fast approximation, not a
|
|
184
|
+
browser. Behaviour that depends on layout, real CSS, or the finer points of
|
|
185
|
+
form-control semantics belongs in the Playwright suite in `packages/app`.
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Mount a component that calls `useServer()` without a real server.
|
|
6
|
+
*
|
|
7
|
+
* `mock.module` is process-global and there is no way to undo it, so every
|
|
8
|
+
* spec that stubs `ServerProvider` stubs it for the whole `bun test` run. One
|
|
9
|
+
* shared stub is what keeps that survivable: the shape a later spec inherits
|
|
10
|
+
* is this one, whatever it registered. See test/README.md.
|
|
11
|
+
*/
|
|
12
|
+
import { QueryClientProvider } from "@tanstack/react-query";
|
|
13
|
+
import { mock } from "bun:test";
|
|
14
|
+
import type { ReactNode } from "react";
|
|
15
|
+
import { globalQueryClient } from "../src/utils/queryClient";
|
|
16
|
+
|
|
17
|
+
/** Stands in for the base URL `useQueryWithApiError` appends to every key. */
|
|
18
|
+
export const TEST_SERVER = "http://localhost/api/v0";
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Replace `ServerProvider` with a stub serving `apiClients`.
|
|
22
|
+
*
|
|
23
|
+
* Call it at the top of a spec, BEFORE importing whatever is under test:
|
|
24
|
+
* a static import of the component would hoist above this and bind the real
|
|
25
|
+
* module. `ServerProvider` itself is stubbed alongside `useServer` because
|
|
26
|
+
* `components/index.ts` re-exports both, and the barrel is in the graph.
|
|
27
|
+
*/
|
|
28
|
+
export function mockServerProvider(apiClients: unknown) {
|
|
29
|
+
mock.module("../src/components/ServerProvider", () => ({
|
|
30
|
+
ServerProvider: () => null,
|
|
31
|
+
useServer: () => ({ server: TEST_SERVER, apiClients }),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The client `ServerProvider` hands down in production, which is also the one
|
|
37
|
+
* `useQueryWithApiError` reaches for directly. Passing the same instance means
|
|
38
|
+
* a spec can read every query out of {@link cacheKeys}, whether the code under
|
|
39
|
+
* test went through the hook or through plain `useQueries`.
|
|
40
|
+
*/
|
|
41
|
+
export const serverWrapper = ({ children }: { children: ReactNode }) => (
|
|
42
|
+
<QueryClientProvider client={globalQueryClient}>
|
|
43
|
+
{children}
|
|
44
|
+
</QueryClientProvider>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Every query key in the cache as a string, so a spec can assert on one slot.
|
|
49
|
+
*
|
|
50
|
+
* Stringified rather than compared structurally because the interesting
|
|
51
|
+
* assertion is almost always "is this value in the key at all": a key that
|
|
52
|
+
* carries a version in the wrong slot is still a key that cannot collide.
|
|
53
|
+
*/
|
|
54
|
+
export function cacheKeys(prefix?: string): string[] {
|
|
55
|
+
const keys = globalQueryClient
|
|
56
|
+
.getQueryCache()
|
|
57
|
+
.getAll()
|
|
58
|
+
.map((query) => JSON.stringify(query.queryKey));
|
|
59
|
+
return prefix === undefined
|
|
60
|
+
? keys
|
|
61
|
+
: keys.filter((key) => key.startsWith(`["${prefix}"`));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Between tests: a key left behind is a key the next test can mistake. */
|
|
65
|
+
export function clearCache() {
|
|
66
|
+
globalQueryClient.clear();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** A request that never settles, so nothing renders past its loading state. */
|
|
70
|
+
export function pending<T = never>(): Promise<T> {
|
|
71
|
+
return new Promise<T>(() => {});
|
|
72
|
+
}
|
package/test/setup.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// Copyright (c) Credible Data Inc.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* DOM environment for `bun test` in this package.
|
|
6
|
+
*
|
|
7
|
+
* Registered via `preload` in bunfig.toml, so it runs once before any spec and
|
|
8
|
+
* every spec in the package gets the same globals. Lives outside `src/` on
|
|
9
|
+
* purpose: `vite-plugin-dts` emits declarations for everything under `src/`, so
|
|
10
|
+
* a setup file in there would ship a stray `.d.ts` into `dist/`.
|
|
11
|
+
*
|
|
12
|
+
* happy-dom rather than jsdom because `@happy-dom/global-registrator` installs
|
|
13
|
+
* onto globalThis, which is what a Bun preload can do; jsdom expects to own the
|
|
14
|
+
* test runner's environment and has no equivalent hook. See test/README.md.
|
|
15
|
+
*/
|
|
16
|
+
import { GlobalRegistrator } from "@happy-dom/global-registrator";
|
|
17
|
+
import { afterEach } from "bun:test";
|
|
18
|
+
|
|
19
|
+
GlobalRegistrator.register();
|
|
20
|
+
|
|
21
|
+
// Imported dynamically, AFTER register(). Testing Library binds to `document`
|
|
22
|
+
// at module scope, so a static import would be hoisted above the line that
|
|
23
|
+
// creates it and every query would resolve against an undefined document.
|
|
24
|
+
const { cleanup } = await import("@testing-library/react");
|
|
25
|
+
|
|
26
|
+
// Unmount between tests. Without this each render appends to the same <body>,
|
|
27
|
+
// so `getByLabelText` starts throwing "found multiple elements" on the second
|
|
28
|
+
// test that renders the same widget.
|
|
29
|
+
afterEach(cleanup);
|
package/tsconfig.json
CHANGED
|
@@ -27,5 +27,16 @@
|
|
|
27
27
|
"forceConsistentCasingInFileNames": true
|
|
28
28
|
},
|
|
29
29
|
"include": ["src", "k6-tests"], // Specifies the directory to include when searching for TypeScript files.
|
|
30
|
-
|
|
30
|
+
// Keep test files out of the build; anything left in emits a stray .d.ts.
|
|
31
|
+
// These are the four name patterns `bun test` discovers, each left open on
|
|
32
|
+
// the extension so .tsx/.mts/.cts cannot slip past. tsconfig.spec.json
|
|
33
|
+
// includes the same four, so excluded does not mean unchecked.
|
|
34
|
+
"exclude": [
|
|
35
|
+
"src/**/__docs__",
|
|
36
|
+
"src/**/__test__",
|
|
37
|
+
"**/*.spec.*",
|
|
38
|
+
"**/*.test.*",
|
|
39
|
+
"**/*_spec.*",
|
|
40
|
+
"**/*_test.*"
|
|
41
|
+
]
|
|
31
42
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Typechecks the test files tsconfig.json excludes from the build.
|
|
2
|
+
//
|
|
3
|
+
// They must be excluded there, because that config drives the declaration
|
|
4
|
+
// build. But excluded also meant unchecked: `bun test` strips types without
|
|
5
|
+
// checking them and eslint here is not type-aware, so a type error in a spec
|
|
6
|
+
// reached no gate. The root `typecheck:sdk` runs this config as its second
|
|
7
|
+
// half. Keep the four patterns in step with the exclude list next door.
|
|
8
|
+
{
|
|
9
|
+
"extends": "./tsconfig.json",
|
|
10
|
+
"compilerOptions": {
|
|
11
|
+
"noEmit": true,
|
|
12
|
+
"declaration": false
|
|
13
|
+
},
|
|
14
|
+
"include": [
|
|
15
|
+
"src/**/*.spec.*",
|
|
16
|
+
"src/**/*.test.*",
|
|
17
|
+
"src/**/*_spec.*",
|
|
18
|
+
"src/**/*_test.*",
|
|
19
|
+
"test/**/*"
|
|
20
|
+
],
|
|
21
|
+
"exclude": []
|
|
22
|
+
}
|
package/vite.config.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const q=require("react/jsx-runtime"),$=require("@tanstack/react-query"),u=require("axios"),R=require("react"),m="http://localhost/api/v0".replace(/\/+$/,"");class y{constructor(r,e=m,a=u){this.basePath=e,this.axios=a,r&&(this.configuration=r,this.basePath=r.basePath??e)}configuration}class pe extends Error{constructor(r,e){super(e),this.field=r,this.name="RequiredError"}}const P={},V="https://example.com",d=function(l,r,e){if(e==null)throw new pe(r,`Required parameter ${r} was null or undefined when calling ${l}.`)};function Q(l,r,e=""){r!=null&&(typeof r=="object"?Array.isArray(r)?r.forEach(a=>Q(l,a,e)):Object.keys(r).forEach(a=>Q(l,r[a],`${e}${e!==""?".":""}${a}`)):l.has(e)?l.append(e,r):l.set(e,r))}const O=function(l,...r){const e=new URLSearchParams(l.search);Q(e,r),l.search=e.toString()},C=function(l,r,e){const a=typeof l!="string";return(a&&e&&e.isJsonMime?e.isJsonMime(r.headers["Content-Type"]):a)?JSON.stringify(l!==void 0?l:{}):l||""},b=function(l){return l.pathname+l.search+l.hash},g=function(l,r,e,a){return(t=r,o=e)=>{const s={...l.options,url:(t.defaults.baseURL?"":a?.basePath??o)+l.url};return t.request(s)}},de={Bigquery:"bigquery",Snowflake:"snowflake",Postgres:"postgres",Gcs:"gcs",S3:"s3",Azure:"azure"},he={ServicePrincipal:"service_principal",SasToken:"sas_token"},ue={Error:"error",Warn:"warn",Debug:"debug"},me={Success:"success",Error:"error"},Pe={Postgres:"postgres",Bigquery:"bigquery",Snowflake:"snowflake",Trino:"trino",Mysql:"mysql",Duckdb:"duckdb",Motherduck:"motherduck",Ducklake:"ducklake"},Ve={Ok:"ok",Failed:"failed"},Oe={Embedded:"embedded",Materialized:"materialized"},be={Equal:"equal",In:"in",Like:"like",GreaterThan:"greater_than",LessThan:"less_than"},ge={Debug:"debug",Info:"info",Warn:"warn",Error:"error"},Ae={Pending:"PENDING",Running:"RUNNING",Success:"SUCCESS",Failed:"FAILED",Cancelled:"CANCELLED"},Se={Markdown:"markdown",Code:"code"},Ce={Markdown:"markdown",Code:"code"},ye={Initializing:"initializing",Serving:"serving",Draining:"draining"},f=function(l){return{createConnection:async(r,e,a,t={})=>{d("createConnection","projectName",r),d("createConnection","connectionName",e),d("createConnection","connection",a);const o="/projects/{projectName}/connections/{connectionName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}},deleteConnection:async(r,e,a={})=>{d("deleteConnection","projectName",r),d("deleteConnection","connectionName",e);const t="/projects/{projectName}/connections/{connectionName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"DELETE",...s,...a},c={};O(o,{});let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},getConnection:async(r,e,a={})=>{d("getConnection","projectName",r),d("getConnection","connectionName",e);const t="/projects/{projectName}/connections/{connectionName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"GET",...s,...a},c={};O(o,{});let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},getQuerydata:async(r,e,a,t,o={})=>{d("getQuerydata","projectName",r),d("getQuerydata","connectionName",e);const s="/projects/{projectName}/connections/{connectionName}/queryData".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};a!==void 0&&(h.sqlStatement=a),t!==void 0&&(h.options=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},getSqlsource:async(r,e,a,t={})=>{d("getSqlsource","projectName",r),d("getSqlsource","connectionName",e);const o="/projects/{projectName}/connections/{connectionName}/sqlSource".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={},p={};a!==void 0&&(p.sqlStatement=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}},getTable:async(r,e,a,t,o={})=>{d("getTable","projectName",r),d("getTable","connectionName",e),d("getTable","schemaName",a),d("getTable","tablePath",t);const s="/projects/{projectName}/connections/{connectionName}/schemas/{schemaName}/tables/{tablePath}".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))).replace("{schemaName}",encodeURIComponent(String(a))).replace("{tablePath}",encodeURIComponent(String(t))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={};O(n,{});let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},getTemporarytable:async(r,e,a,t={})=>{d("getTemporarytable","projectName",r),d("getTemporarytable","connectionName",e);const o="/projects/{projectName}/connections/{connectionName}/temporaryTable".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={},p={};a!==void 0&&(p.sqlStatement=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}},listConnections:async(r,e={})=>{d("listConnections","projectName",r);const a="/projects/{projectName}/connections".replace("{projectName}",encodeURIComponent(String(r))),t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"GET",...o,...e},n={};O(t,{});let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},{url:b(t),options:s}},listSchemas:async(r,e,a={})=>{d("listSchemas","projectName",r),d("listSchemas","connectionName",e);const t="/projects/{projectName}/connections/{connectionName}/schemas".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"GET",...s,...a},c={};O(o,{});let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},listTables:async(r,e,a,t,o={})=>{d("listTables","projectName",r),d("listTables","connectionName",e),d("listTables","schemaName",a);const s="/projects/{projectName}/connections/{connectionName}/schemas/{schemaName}/tables".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))).replace("{schemaName}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};t&&(h.tableNames=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},postQuerydata:async(r,e,a,t={})=>{d("postQuerydata","projectName",r),d("postQuerydata","connectionName",e),d("postQuerydata","postQuerydataRequest",a);const o="/projects/{projectName}/connections/{connectionName}/sqlQuery".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}},postSqlsource:async(r,e,a,t={})=>{d("postSqlsource","projectName",r),d("postSqlsource","connectionName",e),d("postSqlsource","postSqlsourceRequest",a);const o="/projects/{projectName}/connections/{connectionName}/sqlSource".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}},postTemporarytable:async(r,e,a,t={})=>{d("postTemporarytable","projectName",r),d("postTemporarytable","connectionName",e),d("postTemporarytable","postSqlsourceRequest",a);const o="/projects/{projectName}/connections/{connectionName}/sqlTemporaryTable".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}},updateConnection:async(r,e,a,t={})=>{d("updateConnection","projectName",r),d("updateConnection","connectionName",e),d("updateConnection","updateConnectionRequest",a);const o="/projects/{projectName}/connections/{connectionName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{connectionName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"PATCH",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}}}},S=function(l){const r=f(l);return{async createConnection(e,a,t,o){const s=await r.createConnection(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.createConnection"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async deleteConnection(e,a,t){const o=await r.deleteConnection(e,a,t),s=l?.serverIndex??0,n=P["ConnectionsApi.deleteConnection"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async getConnection(e,a,t){const o=await r.getConnection(e,a,t),s=l?.serverIndex??0,n=P["ConnectionsApi.getConnection"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async getQuerydata(e,a,t,o,s){const n=await r.getQuerydata(e,a,t,o,s),c=l?.serverIndex??0,i=P["ConnectionsApi.getQuerydata"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async getSqlsource(e,a,t,o){const s=await r.getSqlsource(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.getSqlsource"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async getTable(e,a,t,o,s){const n=await r.getTable(e,a,t,o,s),c=l?.serverIndex??0,i=P["ConnectionsApi.getTable"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async getTemporarytable(e,a,t,o){const s=await r.getTemporarytable(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.getTemporarytable"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async listConnections(e,a){const t=await r.listConnections(e,a),o=l?.serverIndex??0,s=P["ConnectionsApi.listConnections"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)},async listSchemas(e,a,t){const o=await r.listSchemas(e,a,t),s=l?.serverIndex??0,n=P["ConnectionsApi.listSchemas"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async listTables(e,a,t,o,s){const n=await r.listTables(e,a,t,o,s),c=l?.serverIndex??0,i=P["ConnectionsApi.listTables"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async postQuerydata(e,a,t,o){const s=await r.postQuerydata(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.postQuerydata"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async postSqlsource(e,a,t,o){const s=await r.postSqlsource(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.postSqlsource"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async postTemporarytable(e,a,t,o){const s=await r.postTemporarytable(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.postTemporarytable"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async updateConnection(e,a,t,o){const s=await r.updateConnection(e,a,t,o),n=l?.serverIndex??0,c=P["ConnectionsApi.updateConnection"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},je=function(l,r,e){const a=S(l);return{createConnection(t,o,s,n){return a.createConnection(t,o,s,n).then(c=>c(e,r))},deleteConnection(t,o,s){return a.deleteConnection(t,o,s).then(n=>n(e,r))},getConnection(t,o,s){return a.getConnection(t,o,s).then(n=>n(e,r))},getQuerydata(t,o,s,n,c){return a.getQuerydata(t,o,s,n,c).then(i=>i(e,r))},getSqlsource(t,o,s,n){return a.getSqlsource(t,o,s,n).then(c=>c(e,r))},getTable(t,o,s,n,c){return a.getTable(t,o,s,n,c).then(i=>i(e,r))},getTemporarytable(t,o,s,n){return a.getTemporarytable(t,o,s,n).then(c=>c(e,r))},listConnections(t,o){return a.listConnections(t,o).then(s=>s(e,r))},listSchemas(t,o,s){return a.listSchemas(t,o,s).then(n=>n(e,r))},listTables(t,o,s,n,c){return a.listTables(t,o,s,n,c).then(i=>i(e,r))},postQuerydata(t,o,s,n){return a.postQuerydata(t,o,s,n).then(c=>c(e,r))},postSqlsource(t,o,s,n){return a.postSqlsource(t,o,s,n).then(c=>c(e,r))},postTemporarytable(t,o,s,n){return a.postTemporarytable(t,o,s,n).then(c=>c(e,r))},updateConnection(t,o,s,n){return a.updateConnection(t,o,s,n).then(c=>c(e,r))}}};class L extends y{createConnection(r,e,a,t){return S(this.configuration).createConnection(r,e,a,t).then(o=>o(this.axios,this.basePath))}deleteConnection(r,e,a){return S(this.configuration).deleteConnection(r,e,a).then(t=>t(this.axios,this.basePath))}getConnection(r,e,a){return S(this.configuration).getConnection(r,e,a).then(t=>t(this.axios,this.basePath))}getQuerydata(r,e,a,t,o){return S(this.configuration).getQuerydata(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}getSqlsource(r,e,a,t){return S(this.configuration).getSqlsource(r,e,a,t).then(o=>o(this.axios,this.basePath))}getTable(r,e,a,t,o){return S(this.configuration).getTable(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}getTemporarytable(r,e,a,t){return S(this.configuration).getTemporarytable(r,e,a,t).then(o=>o(this.axios,this.basePath))}listConnections(r,e){return S(this.configuration).listConnections(r,e).then(a=>a(this.axios,this.basePath))}listSchemas(r,e,a){return S(this.configuration).listSchemas(r,e,a).then(t=>t(this.axios,this.basePath))}listTables(r,e,a,t,o){return S(this.configuration).listTables(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}postQuerydata(r,e,a,t){return S(this.configuration).postQuerydata(r,e,a,t).then(o=>o(this.axios,this.basePath))}postSqlsource(r,e,a,t){return S(this.configuration).postSqlsource(r,e,a,t).then(o=>o(this.axios,this.basePath))}postTemporarytable(r,e,a,t){return S(this.configuration).postTemporarytable(r,e,a,t).then(o=>o(this.axios,this.basePath))}updateConnection(r,e,a,t){return S(this.configuration).updateConnection(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const H=function(l){return{testConnectionConfiguration:async(r,e={})=>{d("testConnectionConfiguration","connection",r);const a="/connections/test",t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"POST",...o,...e},n={},c={};n["Content-Type"]="application/json",O(t,c);let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},s.data=C(r,s,l),{url:b(t),options:s}}}},z=function(l){const r=H(l);return{async testConnectionConfiguration(e,a){const t=await r.testConnectionConfiguration(e,a),o=l?.serverIndex??0,s=P["ConnectionsTestApi.testConnectionConfiguration"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)}}},xe=function(l,r,e){const a=z(l);return{testConnectionConfiguration(t,o){return a.testConnectionConfiguration(t,o).then(s=>s(e,r))}}};class Ne extends y{testConnectionConfiguration(r,e){return z(this.configuration).testConnectionConfiguration(r,e).then(a=>a(this.axios,this.basePath))}}const D=function(l){return{listDatabases:async(r,e,a,t={})=>{d("listDatabases","projectName",r),d("listDatabases","packageName",e);const o="/projects/{projectName}/packages/{packageName}/databases".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={},p={};a!==void 0&&(p.versionId=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}}}},B=function(l){const r=D(l);return{async listDatabases(e,a,t,o){const s=await r.listDatabases(e,a,t,o),n=l?.serverIndex??0,c=P["DatabasesApi.listDatabases"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},ke=function(l,r,e){const a=B(l);return{listDatabases(t,o,s,n){return a.listDatabases(t,o,s,n).then(c=>c(e,r))}}};class W extends y{listDatabases(r,e,a,t){return B(this.configuration).listDatabases(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const G=function(l){return{getManifest:async(r,e,a={})=>{d("getManifest","projectName",r),d("getManifest","packageName",e);const t="/projects/{projectName}/packages/{packageName}/manifest".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"GET",...s,...a},c={};O(o,{});let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},manifestAction:async(r,e,a,t={})=>{d("manifestAction","projectName",r),d("manifestAction","packageName",e),d("manifestAction","action",a);const o="/projects/{projectName}/packages/{packageName}/manifest".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};a!==void 0&&(p.action=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}}}},T=function(l){const r=G(l);return{async getManifest(e,a,t){const o=await r.getManifest(e,a,t),s=l?.serverIndex??0,n=P["ManifestsApi.getManifest"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async manifestAction(e,a,t,o){const s=await r.manifestAction(e,a,t,o),n=l?.serverIndex??0,c=P["ManifestsApi.manifestAction"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},Ie=function(l,r,e){const a=T(l);return{getManifest(t,o,s){return a.getManifest(t,o,s).then(n=>n(e,r))},manifestAction(t,o,s,n){return a.manifestAction(t,o,s,n).then(c=>c(e,r))}}};class Re extends y{getManifest(r,e,a){return T(this.configuration).getManifest(r,e,a).then(t=>t(this.axios,this.basePath))}manifestAction(r,e,a,t){return T(this.configuration).manifestAction(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const ve={Reload:"reload"},_=function(l){return{createMaterialization:async(r,e,a,t={})=>{d("createMaterialization","projectName",r),d("createMaterialization","packageName",e);const o="/projects/{projectName}/packages/{packageName}/materializations".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}},deleteMaterialization:async(r,e,a,t={})=>{d("deleteMaterialization","projectName",r),d("deleteMaterialization","packageName",e),d("deleteMaterialization","materializationId",a);const o="/projects/{projectName}/packages/{packageName}/materializations/{materializationId}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{materializationId}",encodeURIComponent(String(a))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"DELETE",...n,...t},i={};O(s,{});let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}},getMaterialization:async(r,e,a,t={})=>{d("getMaterialization","projectName",r),d("getMaterialization","packageName",e),d("getMaterialization","materializationId",a);const o="/projects/{projectName}/packages/{packageName}/materializations/{materializationId}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{materializationId}",encodeURIComponent(String(a))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={};O(s,{});let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}},listMaterializations:async(r,e,a,t,o={})=>{d("listMaterializations","projectName",r),d("listMaterializations","packageName",e);const s="/projects/{projectName}/packages/{packageName}/materializations".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};a!==void 0&&(h.limit=a),t!==void 0&&(h.offset=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},materializationAction:async(r,e,a,t,o={})=>{d("materializationAction","projectName",r),d("materializationAction","packageName",e),d("materializationAction","materializationId",a),d("materializationAction","action",t);const s="/projects/{projectName}/packages/{packageName}/materializations/{materializationId}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{materializationId}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"POST",...c,...o},p={},h={};t!==void 0&&(h.action=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}}}},N=function(l){const r=_(l);return{async createMaterialization(e,a,t,o){const s=await r.createMaterialization(e,a,t,o),n=l?.serverIndex??0,c=P["MaterializationsApi.createMaterialization"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async deleteMaterialization(e,a,t,o){const s=await r.deleteMaterialization(e,a,t,o),n=l?.serverIndex??0,c=P["MaterializationsApi.deleteMaterialization"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async getMaterialization(e,a,t,o){const s=await r.getMaterialization(e,a,t,o),n=l?.serverIndex??0,c=P["MaterializationsApi.getMaterialization"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async listMaterializations(e,a,t,o,s){const n=await r.listMaterializations(e,a,t,o,s),c=l?.serverIndex??0,i=P["MaterializationsApi.listMaterializations"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async materializationAction(e,a,t,o,s){const n=await r.materializationAction(e,a,t,o,s),c=l?.serverIndex??0,i=P["MaterializationsApi.materializationAction"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)}}},Ue=function(l,r,e){const a=N(l);return{createMaterialization(t,o,s,n){return a.createMaterialization(t,o,s,n).then(c=>c(e,r))},deleteMaterialization(t,o,s,n){return a.deleteMaterialization(t,o,s,n).then(c=>c(e,r))},getMaterialization(t,o,s,n){return a.getMaterialization(t,o,s,n).then(c=>c(e,r))},listMaterializations(t,o,s,n,c){return a.listMaterializations(t,o,s,n,c).then(i=>i(e,r))},materializationAction(t,o,s,n,c){return a.materializationAction(t,o,s,n,c).then(i=>i(e,r))}}};class Me extends y{createMaterialization(r,e,a,t){return N(this.configuration).createMaterialization(r,e,a,t).then(o=>o(this.axios,this.basePath))}deleteMaterialization(r,e,a,t){return N(this.configuration).deleteMaterialization(r,e,a,t).then(o=>o(this.axios,this.basePath))}getMaterialization(r,e,a,t){return N(this.configuration).getMaterialization(r,e,a,t).then(o=>o(this.axios,this.basePath))}listMaterializations(r,e,a,t,o){return N(this.configuration).listMaterializations(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}materializationAction(r,e,a,t,o){return N(this.configuration).materializationAction(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}}const we={Start:"start",Stop:"stop"},J=function(l){return{compileModelSource:async(r,e,a,t,o={})=>{d("compileModelSource","projectName",r),d("compileModelSource","packageName",e),d("compileModelSource","path",a),d("compileModelSource","compileRequest",t);const s="/projects/{projectName}/packages/{packageName}/models/{path}/compile".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{path}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"POST",...c,...o},p={},h={};p["Content-Type"]="application/json",O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},i.data=C(t,i,l),{url:b(n),options:i}},executeQueryModel:async(r,e,a,t,o={})=>{d("executeQueryModel","projectName",r),d("executeQueryModel","packageName",e),d("executeQueryModel","path",a),d("executeQueryModel","queryRequest",t);const s="/projects/{projectName}/packages/{packageName}/models/{path}/query".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{path}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"POST",...c,...o},p={},h={};p["Content-Type"]="application/json",O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},i.data=C(t,i,l),{url:b(n),options:i}},getModel:async(r,e,a,t,o={})=>{d("getModel","projectName",r),d("getModel","packageName",e),d("getModel","path",a);const s="/projects/{projectName}/packages/{packageName}/models/{path}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{path}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};t!==void 0&&(h.versionId=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},listModels:async(r,e,a,t={})=>{d("listModels","projectName",r),d("listModels","packageName",e);const o="/projects/{projectName}/packages/{packageName}/models".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={},p={};a!==void 0&&(p.versionId=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}}}},v=function(l){const r=J(l);return{async compileModelSource(e,a,t,o,s){const n=await r.compileModelSource(e,a,t,o,s),c=l?.serverIndex??0,i=P["ModelsApi.compileModelSource"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async executeQueryModel(e,a,t,o,s){const n=await r.executeQueryModel(e,a,t,o,s),c=l?.serverIndex??0,i=P["ModelsApi.executeQueryModel"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async getModel(e,a,t,o,s){const n=await r.getModel(e,a,t,o,s),c=l?.serverIndex??0,i=P["ModelsApi.getModel"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async listModels(e,a,t,o){const s=await r.listModels(e,a,t,o),n=l?.serverIndex??0,c=P["ModelsApi.listModels"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},Te=function(l,r,e){const a=v(l);return{compileModelSource(t,o,s,n,c){return a.compileModelSource(t,o,s,n,c).then(i=>i(e,r))},executeQueryModel(t,o,s,n,c){return a.executeQueryModel(t,o,s,n,c).then(i=>i(e,r))},getModel(t,o,s,n,c){return a.getModel(t,o,s,n,c).then(i=>i(e,r))},listModels(t,o,s,n){return a.listModels(t,o,s,n).then(c=>c(e,r))}}};class K extends y{compileModelSource(r,e,a,t,o){return v(this.configuration).compileModelSource(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}executeQueryModel(r,e,a,t,o){return v(this.configuration).executeQueryModel(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}getModel(r,e,a,t,o){return v(this.configuration).getModel(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}listModels(r,e,a,t){return v(this.configuration).listModels(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const Y=function(l){return{executeNotebookCell:async(r,e,a,t,o,s,n,c={})=>{d("executeNotebookCell","projectName",r),d("executeNotebookCell","packageName",e),d("executeNotebookCell","path",a),d("executeNotebookCell","cellIndex",t);const i="/projects/{projectName}/packages/{packageName}/notebooks/{path}/cells/{cellIndex}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{path}",encodeURIComponent(String(a))).replace("{cellIndex}",encodeURIComponent(String(t))),p=new URL(i,V);let h;l&&(h=l.baseOptions);const A={method:"GET",...h,...c},j={},x={};o!==void 0&&(x.versionId=o),s!==void 0&&(x.filter_params=s),n!==void 0&&(x.bypass_filters=n),O(p,x);let F=h&&h.headers?h.headers:{};return A.headers={...j,...F,...c.headers},{url:b(p),options:A}},getNotebook:async(r,e,a,t,o={})=>{d("getNotebook","projectName",r),d("getNotebook","packageName",e),d("getNotebook","path",a);const s="/projects/{projectName}/packages/{packageName}/notebooks/{path}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))).replace("{path}",encodeURIComponent(String(a))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};t!==void 0&&(h.versionId=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},listNotebooks:async(r,e,a,t={})=>{d("listNotebooks","projectName",r),d("listNotebooks","packageName",e);const o="/projects/{projectName}/packages/{packageName}/notebooks".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"GET",...n,...t},i={},p={};a!==void 0&&(p.versionId=a),O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},{url:b(s),options:c}}}},U=function(l){const r=Y(l);return{async executeNotebookCell(e,a,t,o,s,n,c,i){const p=await r.executeNotebookCell(e,a,t,o,s,n,c,i),h=l?.serverIndex??0,A=P["NotebooksApi.executeNotebookCell"]?.[h]?.url;return(j,x)=>g(p,u,m,l)(j,A||x)},async getNotebook(e,a,t,o,s){const n=await r.getNotebook(e,a,t,o,s),c=l?.serverIndex??0,i=P["NotebooksApi.getNotebook"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async listNotebooks(e,a,t,o){const s=await r.listNotebooks(e,a,t,o),n=l?.serverIndex??0,c=P["NotebooksApi.listNotebooks"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},Fe=function(l,r,e){const a=U(l);return{executeNotebookCell(t,o,s,n,c,i,p,h){return a.executeNotebookCell(t,o,s,n,c,i,p,h).then(A=>A(e,r))},getNotebook(t,o,s,n,c){return a.getNotebook(t,o,s,n,c).then(i=>i(e,r))},listNotebooks(t,o,s,n){return a.listNotebooks(t,o,s,n).then(c=>c(e,r))}}};class X extends y{executeNotebookCell(r,e,a,t,o,s,n,c){return U(this.configuration).executeNotebookCell(r,e,a,t,o,s,n,c).then(i=>i(this.axios,this.basePath))}getNotebook(r,e,a,t,o){return U(this.configuration).getNotebook(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}listNotebooks(r,e,a,t){return U(this.configuration).listNotebooks(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const Qe={True:"true",False:"false"},Z=function(l){return{createPackage:async(r,e,a,t={})=>{d("createPackage","projectName",r),d("createPackage","_package",e);const o="/projects/{projectName}/packages".replace("{projectName}",encodeURIComponent(String(r))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"POST",...n,...t},i={},p={};a!==void 0&&(p.autoLoadManifest=a),i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(e,c,l),{url:b(s),options:c}},deletePackage:async(r,e,a={})=>{d("deletePackage","projectName",r),d("deletePackage","packageName",e);const t="/projects/{projectName}/packages/{packageName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"DELETE",...s,...a},c={};O(o,{});let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},getPackage:async(r,e,a,t,o={})=>{d("getPackage","projectName",r),d("getPackage","packageName",e);const s="/projects/{projectName}/packages/{packageName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),n=new URL(s,V);let c;l&&(c=l.baseOptions);const i={method:"GET",...c,...o},p={},h={};a!==void 0&&(h.versionId=a),t!==void 0&&(h.reload=t),O(n,h);let A=c&&c.headers?c.headers:{};return i.headers={...p,...A,...o.headers},{url:b(n),options:i}},listPackages:async(r,e={})=>{d("listPackages","projectName",r);const a="/projects/{projectName}/packages".replace("{projectName}",encodeURIComponent(String(r))),t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"GET",...o,...e},n={};O(t,{});let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},{url:b(t),options:s}},updatePackage:async(r,e,a,t={})=>{d("updatePackage","projectName",r),d("updatePackage","packageName",e),d("updatePackage","_package",a);const o="/projects/{projectName}/packages/{packageName}".replace("{projectName}",encodeURIComponent(String(r))).replace("{packageName}",encodeURIComponent(String(e))),s=new URL(o,V);let n;l&&(n=l.baseOptions);const c={method:"PATCH",...n,...t},i={},p={};i["Content-Type"]="application/json",O(s,p);let h=n&&n.headers?n.headers:{};return c.headers={...i,...h,...t.headers},c.data=C(a,c,l),{url:b(s),options:c}}}},k=function(l){const r=Z(l);return{async createPackage(e,a,t,o){const s=await r.createPackage(e,a,t,o),n=l?.serverIndex??0,c=P["PackagesApi.createPackage"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)},async deletePackage(e,a,t){const o=await r.deletePackage(e,a,t),s=l?.serverIndex??0,n=P["PackagesApi.deletePackage"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async getPackage(e,a,t,o,s){const n=await r.getPackage(e,a,t,o,s),c=l?.serverIndex??0,i=P["PackagesApi.getPackage"]?.[c]?.url;return(p,h)=>g(n,u,m,l)(p,i||h)},async listPackages(e,a){const t=await r.listPackages(e,a),o=l?.serverIndex??0,s=P["PackagesApi.listPackages"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)},async updatePackage(e,a,t,o){const s=await r.updatePackage(e,a,t,o),n=l?.serverIndex??0,c=P["PackagesApi.updatePackage"]?.[n]?.url;return(i,p)=>g(s,u,m,l)(i,c||p)}}},ze=function(l,r,e){const a=k(l);return{createPackage(t,o,s,n){return a.createPackage(t,o,s,n).then(c=>c(e,r))},deletePackage(t,o,s){return a.deletePackage(t,o,s).then(n=>n(e,r))},getPackage(t,o,s,n,c){return a.getPackage(t,o,s,n,c).then(i=>i(e,r))},listPackages(t,o){return a.listPackages(t,o).then(s=>s(e,r))},updatePackage(t,o,s,n){return a.updatePackage(t,o,s,n).then(c=>c(e,r))}}};class ee extends y{createPackage(r,e,a,t){return k(this.configuration).createPackage(r,e,a,t).then(o=>o(this.axios,this.basePath))}deletePackage(r,e,a){return k(this.configuration).deletePackage(r,e,a).then(t=>t(this.axios,this.basePath))}getPackage(r,e,a,t,o){return k(this.configuration).getPackage(r,e,a,t,o).then(s=>s(this.axios,this.basePath))}listPackages(r,e){return k(this.configuration).listPackages(r,e).then(a=>a(this.axios,this.basePath))}updatePackage(r,e,a,t){return k(this.configuration).updatePackage(r,e,a,t).then(o=>o(this.axios,this.basePath))}}const te=function(l){return{createProject:async(r,e={})=>{d("createProject","project",r);const a="/projects",t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"POST",...o,...e},n={},c={};n["Content-Type"]="application/json",O(t,c);let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},s.data=C(r,s,l),{url:b(t),options:s}},deleteProject:async(r,e={})=>{d("deleteProject","projectName",r);const a="/projects/{projectName}".replace("{projectName}",encodeURIComponent(String(r))),t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"DELETE",...o,...e},n={};O(t,{});let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},{url:b(t),options:s}},getProject:async(r,e,a={})=>{d("getProject","projectName",r);const t="/projects/{projectName}".replace("{projectName}",encodeURIComponent(String(r))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"GET",...s,...a},c={},i={};e!==void 0&&(i.reload=e),O(o,i);let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},{url:b(o),options:n}},listProjects:async(r={})=>{const e="/projects",a=new URL(e,V);let t;l&&(t=l.baseOptions);const o={method:"GET",...t,...r},s={};O(a,{});let c=t&&t.headers?t.headers:{};return o.headers={...s,...c,...r.headers},{url:b(a),options:o}},updateProject:async(r,e,a={})=>{d("updateProject","projectName",r),d("updateProject","project",e);const t="/projects/{projectName}".replace("{projectName}",encodeURIComponent(String(r))),o=new URL(t,V);let s;l&&(s=l.baseOptions);const n={method:"PATCH",...s,...a},c={},i={};c["Content-Type"]="application/json",O(o,i);let p=s&&s.headers?s.headers:{};return n.headers={...c,...p,...a.headers},n.data=C(e,n,l),{url:b(o),options:n}}}},I=function(l){const r=te(l);return{async createProject(e,a){const t=await r.createProject(e,a),o=l?.serverIndex??0,s=P["ProjectsApi.createProject"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)},async deleteProject(e,a){const t=await r.deleteProject(e,a),o=l?.serverIndex??0,s=P["ProjectsApi.deleteProject"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)},async getProject(e,a,t){const o=await r.getProject(e,a,t),s=l?.serverIndex??0,n=P["ProjectsApi.getProject"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)},async listProjects(e){const a=await r.listProjects(e),t=l?.serverIndex??0,o=P["ProjectsApi.listProjects"]?.[t]?.url;return(s,n)=>g(a,u,m,l)(s,o||n)},async updateProject(e,a,t){const o=await r.updateProject(e,a,t),s=l?.serverIndex??0,n=P["ProjectsApi.updateProject"]?.[s]?.url;return(c,i)=>g(o,u,m,l)(c,n||i)}}},Be=function(l,r,e){const a=I(l);return{createProject(t,o){return a.createProject(t,o).then(s=>s(e,r))},deleteProject(t,o){return a.deleteProject(t,o).then(s=>s(e,r))},getProject(t,o,s){return a.getProject(t,o,s).then(n=>n(e,r))},listProjects(t){return a.listProjects(t).then(o=>o(e,r))},updateProject(t,o,s){return a.updateProject(t,o,s).then(n=>n(e,r))}}};class ae extends y{createProject(r,e){return I(this.configuration).createProject(r,e).then(a=>a(this.axios,this.basePath))}deleteProject(r,e){return I(this.configuration).deleteProject(r,e).then(a=>a(this.axios,this.basePath))}getProject(r,e,a){return I(this.configuration).getProject(r,e,a).then(t=>t(this.axios,this.basePath))}listProjects(r){return I(this.configuration).listProjects(r).then(e=>e(this.axios,this.basePath))}updateProject(r,e,a){return I(this.configuration).updateProject(r,e,a).then(t=>t(this.axios,this.basePath))}}const re=function(l){return{getStatus:async(r={})=>{const e="/status",a=new URL(e,V);let t;l&&(t=l.baseOptions);const o={method:"GET",...t,...r},s={};O(a,{});let c=t&&t.headers?t.headers:{};return o.headers={...s,...c,...r.headers},{url:b(a),options:o}}}},E=function(l){const r=re(l);return{async getStatus(e){const a=await r.getStatus(e),t=l?.serverIndex??0,o=P["PublisherApi.getStatus"]?.[t]?.url;return(s,n)=>g(a,u,m,l)(s,o||n)}}},Ee=function(l,r,e){const a=E(l);return{getStatus(t){return a.getStatus(t).then(o=>o(e,r))}}};class oe extends y{getStatus(r){return E(this.configuration).getStatus(r).then(e=>e(this.axios,this.basePath))}}const se=function(l){return{getWatchStatus:async(r={})=>{const e="/watch-mode/status",a=new URL(e,V);let t;l&&(t=l.baseOptions);const o={method:"GET",...t,...r},s={};O(a,{});let c=t&&t.headers?t.headers:{};return o.headers={...s,...c,...r.headers},{url:b(a),options:o}},startWatching:async(r,e={})=>{d("startWatching","startWatchRequest",r);const a="/watch-mode/start",t=new URL(a,V);let o;l&&(o=l.baseOptions);const s={method:"POST",...o,...e},n={},c={};n["Content-Type"]="application/json",O(t,c);let i=o&&o.headers?o.headers:{};return s.headers={...n,...i,...e.headers},s.data=C(r,s,l),{url:b(t),options:s}},stopWatching:async(r={})=>{const e="/watch-mode/stop",a=new URL(e,V);let t;l&&(t=l.baseOptions);const o={method:"POST",...t,...r},s={};O(a,{});let c=t&&t.headers?t.headers:{};return o.headers={...s,...c,...r.headers},{url:b(a),options:o}}}},M=function(l){const r=se(l);return{async getWatchStatus(e){const a=await r.getWatchStatus(e),t=l?.serverIndex??0,o=P["WatchModeApi.getWatchStatus"]?.[t]?.url;return(s,n)=>g(a,u,m,l)(s,o||n)},async startWatching(e,a){const t=await r.startWatching(e,a),o=l?.serverIndex??0,s=P["WatchModeApi.startWatching"]?.[o]?.url;return(n,c)=>g(t,u,m,l)(n,s||c)},async stopWatching(e){const a=await r.stopWatching(e),t=l?.serverIndex??0,o=P["WatchModeApi.stopWatching"]?.[t]?.url;return(s,n)=>g(a,u,m,l)(s,o||n)}}},qe=function(l,r,e){const a=M(l);return{getWatchStatus(t){return a.getWatchStatus(t).then(o=>o(e,r))},startWatching(t,o){return a.startWatching(t,o).then(s=>s(e,r))},stopWatching(t){return a.stopWatching(t).then(o=>o(e,r))}}};class ne extends y{getWatchStatus(r){return M(this.configuration).getWatchStatus(r).then(e=>e(this.axios,this.basePath))}startWatching(r,e){return M(this.configuration).startWatching(r,e).then(a=>a(this.axios,this.basePath))}stopWatching(r){return M(this.configuration).stopWatching(r).then(e=>e(this.axios,this.basePath))}}class ce{apiKey;username;password;accessToken;basePath;serverIndex;baseOptions;formDataCtor;constructor(r={}){this.apiKey=r.apiKey,this.username=r.username,this.password=r.password,this.accessToken=r.accessToken,this.basePath=r.basePath,this.serverIndex=r.serverIndex,this.baseOptions={...r.baseOptions,headers:{...r.baseOptions?.headers}},this.formDataCtor=r.formDataCtor}isJsonMime(r){const e=new RegExp("^(application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(;.*)?$","i");return r!==null&&(e.test(r)||r.toLowerCase()==="application/json-patch+json")}}const le=new $.QueryClient({defaultOptions:{queries:{retry:!1,throwOnError:!1},mutations:{retry:!1,throwOnError:!1}}});u.defaults.baseURL||(u.defaults.baseURL="IfYouAreSeeingThis_baseURL_IsNotSet");const ie=R.createContext(void 0),$e=(l,r)=>{const e=`${window.location.protocol}//${window.location.host}/api/v0`,a=u.create({baseURL:l||e,withCredentials:!0,timeout:6e5});a.interceptors.request.use(async o=>{const s=await r?.();return o.headers.Authorization=s||"",o});const t=new ce({basePath:e});return{models:new K(t,e,a),publisher:new oe(t,e,a),projects:new ae(t,e,a),packages:new ee(t,e,a),notebooks:new X(t,e,a),connections:new L(t,e,a),databases:new W(t,e,a),watchMode:new ne(t,e,a)}},fe=({children:l,getAccessToken:r,baseURL:e,mutable:a})=>{const t=R.useMemo(()=>$e(e,r),[e,r]),o=e||`${window.location.protocol}//${window.location.host}/api/v0`,[s,n]=R.useState(a),[c,i]=R.useState(!0);R.useEffect(()=>{let h=!0;return(async()=>{try{const j=await t.publisher.getStatus();if(h){const F=j.data?.frozenConfig;let w;F?w=!1:a===void 0?w=!0:w=a,n(w),i(!1)}}catch(j){console.error("Failed to fetch publisher status:",j),h&&(n(a),i(!1))}})(),()=>{h=!1}},[t,a]);const p={server:o,getAccessToken:r,apiClients:t,mutable:s,isLoadingStatus:c};return q.jsx($.QueryClientProvider,{client:le,children:q.jsx(ie.Provider,{value:p,children:l})})},Le=()=>{const l=R.useContext(ie);if(l===void 0)throw new Error("useServer must be used within a ServerProvider");return l};exports.AttachedDatabaseTypeEnum=de;exports.AzureConnectionAuthTypeEnum=he;exports.CompileProblemSeverityEnum=ue;exports.CompileResultStatusEnum=me;exports.Configuration=ce;exports.ConnectionStatusStatusEnum=Ve;exports.ConnectionTypeEnum=Pe;exports.ConnectionsApi=L;exports.ConnectionsApiAxiosParamCreator=f;exports.ConnectionsApiFactory=je;exports.ConnectionsApiFp=S;exports.ConnectionsTestApi=Ne;exports.ConnectionsTestApiAxiosParamCreator=H;exports.ConnectionsTestApiFactory=xe;exports.ConnectionsTestApiFp=z;exports.DatabaseTypeEnum=Oe;exports.DatabasesApi=W;exports.DatabasesApiAxiosParamCreator=D;exports.DatabasesApiFactory=ke;exports.DatabasesApiFp=B;exports.ExecuteNotebookCellBypassFiltersEnum=Qe;exports.FilterTypeEnum=be;exports.LogMessageSeverityEnum=ge;exports.ManifestActionActionEnum=ve;exports.ManifestsApi=Re;exports.ManifestsApiAxiosParamCreator=G;exports.ManifestsApiFactory=Ie;exports.ManifestsApiFp=T;exports.MaterializationActionActionEnum=we;exports.MaterializationStatusEnum=Ae;exports.MaterializationsApi=Me;exports.MaterializationsApiAxiosParamCreator=_;exports.MaterializationsApiFactory=Ue;exports.MaterializationsApiFp=N;exports.ModelsApi=K;exports.ModelsApiAxiosParamCreator=J;exports.ModelsApiFactory=Te;exports.ModelsApiFp=v;exports.NotebookCellResultTypeEnum=Ce;exports.NotebookCellTypeEnum=Se;exports.NotebooksApi=X;exports.NotebooksApiAxiosParamCreator=Y;exports.NotebooksApiFactory=Fe;exports.NotebooksApiFp=U;exports.PackagesApi=ee;exports.PackagesApiAxiosParamCreator=Z;exports.PackagesApiFactory=ze;exports.PackagesApiFp=k;exports.ProjectsApi=ae;exports.ProjectsApiAxiosParamCreator=te;exports.ProjectsApiFactory=Be;exports.ProjectsApiFp=I;exports.PublisherApi=oe;exports.PublisherApiAxiosParamCreator=re;exports.PublisherApiFactory=Ee;exports.PublisherApiFp=E;exports.ServerProvider=fe;exports.ServerStatusOperationalStateEnum=ye;exports.WatchModeApi=ne;exports.WatchModeApiAxiosParamCreator=se;exports.WatchModeApiFactory=qe;exports.WatchModeApiFp=M;exports.globalQueryClient=le;exports.useServer=Le;
|