Skip to content

Commit cb9e2f0

Browse files
committed
temp
1 parent 40f20c4 commit cb9e2f0

9 files changed

Lines changed: 180 additions & 206 deletions

File tree

vscode/extension/README.md

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
<<<<<<< HEAD
21
# SQLMesh VSCode Extension
32

43
## Functionality
@@ -26,77 +25,3 @@ The extension allows you to:
2625
### Linting
2726

2827
The extension allows you to see linting errors and warnings inline.
29-
30-
=======
31-
# vscode README
32-
33-
This is the README for your extension "vscode". After writing up a brief description, we recommend including the following sections.
34-
35-
## Features
36-
37-
Describe specific features of your extension including screenshots of your extension in action. Image paths are relative to this README file.
38-
39-
For example if there is an image subfolder under your extension project workspace:
40-
41-
\!\[feature X\]\(images/feature-x.png\)
42-
43-
> Tip: Many popular extensions utilize animations. This is an excellent way to show off your extension! We recommend short, focused animations that are easy to follow.
44-
45-
## Requirements
46-
47-
If you have any requirements or dependencies, add a section describing those and how to install and configure them.
48-
49-
## Extension Settings
50-
51-
Include if your extension adds any VS Code settings through the `contributes.configuration` extension point.
52-
53-
For example:
54-
55-
This extension contributes the following settings:
56-
57-
* `myExtension.enable`: Enable/disable this extension.
58-
* `myExtension.thing`: Set to `blah` to do something.
59-
60-
## Known Issues
61-
62-
Calling out known issues can help limit users opening duplicate issues against your extension.
63-
64-
## Release Notes
65-
66-
Users appreciate release notes as you update your extension.
67-
68-
### 1.0.0
69-
70-
Initial release of ...
71-
72-
### 1.0.1
73-
74-
Fixed issue #.
75-
76-
### 1.1.0
77-
78-
Added features X, Y, and Z.
79-
80-
---
81-
82-
## Following extension guidelines
83-
84-
Ensure that you've read through the extensions guidelines and follow the best practices for creating your extension.
85-
86-
* [Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines)
87-
88-
## Working with Markdown
89-
90-
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
91-
92-
* Split the editor (`Cmd+\` on macOS or `Ctrl+\` on Windows and Linux).
93-
* Toggle preview (`Shift+Cmd+V` on macOS or `Shift+Ctrl+V` on Windows and Linux).
94-
* Press `Ctrl+Space` (Windows, Linux, macOS) to see a list of Markdown snippets.
95-
96-
## For more information
97-
98-
* [Visual Studio Code's Markdown Support](http://code.visualstudio.com/docs/languages/markdown)
99-
* [Markdown Syntax Reference](https://help.github.com/articles/markdown-basics/)
100-
101-
**Enjoy!**
102-
>>>>>>> c5ee2535 (progress)

vscode/extension/esbuild.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ const production = process.argv.includes('--production');
44
const watch = process.argv.includes('--watch');
55

66
async function main() {
7+
const IS_PRODUCTION = production;
8+
79
const ctx = await esbuild.context({
810
entryPoints: ['src/extension.ts'],
911
bundle: true,
@@ -15,6 +17,9 @@ async function main() {
1517
outfile: 'dist/extension.js',
1618
external: ['vscode'],
1719
logLevel: 'warning',
20+
define: {
21+
'process.env.NODE_ENV': IS_PRODUCTION ? '"production"' : '"development"'
22+
},
1823
plugins: [
1924
/* add to the end of plugins array */
2025
esbuildProblemMatcherPlugin

vscode/extension/openapi.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

vscode/extension/src/extension.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import { AuthenticationProviderTobikoCloud } from "./auth/auth"
1717
import { signOut } from "./commands/signout"
1818
import { signIn } from "./commands/signin"
1919
import { signInSpecifyFlow } from "./commands/signinSpecifyFlow"
20-
import { isErr, Result } from "./utilities/functional/result"
21-
import { ErrorType, handleNotSginedInError } from "./utilities/errors"
20+
import { isErr } from "./utilities/functional/result"
21+
import { handleNotSginedInError } from "./utilities/errors"
2222
import { startWebServer, WebServer } from "./web-server/server"
2323
import { LineagePanel } from "./webviews/lineagePanel"
2424

vscode/extension/src/utilities/isDev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
* Determines if the extension is running in production mode.
33
*/
44
export function isProduction(): boolean {
5+
console.log('NODE_ENV', process.env.NODE_ENV)
56
return process.env.NODE_ENV === 'production'
67
}

vscode/extension/src/webviews/lineagePanel.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
CancellationToken,
44
Disposable,
55
Uri,
6+
Webview,
67
WebviewView,
78
WebviewViewProvider,
89
WebviewViewResolveContext,
@@ -95,7 +96,7 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
9596
[]
9697
);
9798
const { externalUrl, externalAuthority } = this.externalUrlAndAutority();
98-
webviewView.webview.html = this.getHtml(externalUrl, externalAuthority);
99+
webviewView.webview.html = isProduction() ? this.getProductionHTML(webviewView.webview) : this.getHtml(externalUrl, externalAuthority);
99100
}
100101

101102
externalUrlAndAutority(): { externalUrl: string; externalAuthority: string } {
@@ -156,6 +157,38 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
156157
</html> `;
157158
}
158159

160+
private getProductionHTML(panel: Webview) {
161+
const cssUri = panel.asWebviewUri(Uri.joinPath(this._extensionUri, "src_react", "assets", "index.css"));
162+
const jsUri = panel.asWebviewUri(Uri.joinPath(this._extensionUri, "src_react", "assets", "index.js"));
163+
const faviconUri = panel.asWebviewUri(Uri.joinPath(this._extensionUri, "src_react", "favicon.ico"));
164+
const manifestUri = panel.asWebviewUri(Uri.joinPath(this._extensionUri, "src_react", "manifest.json"));
165+
const logoUri = panel.asWebviewUri(Uri.joinPath(this._extensionUri, "src_react", "logo192.png"));
166+
167+
return `
168+
<!DOCTYPE html>
169+
<html lang="en">
170+
<head>
171+
<meta charset="UTF-8" />
172+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
173+
<link rel="icon" href="${faviconUri}" />
174+
<meta name="theme-color" content="#000000" />
175+
<meta
176+
name="description"
177+
content="Web site created using create-tsrouter-app"
178+
/>
179+
<link rel="apple-touch-icon" href="${logoUri}" />
180+
<link rel="manifest" href="${manifestUri}" />
181+
<title>Create TanStack App - react</title>
182+
<script type="module" crossorigin src="${jsUri}"></script>
183+
<link rel="stylesheet" crossorigin href="${cssUri}">
184+
</head>
185+
<body>
186+
<div id="app"></div>
187+
</body>
188+
</html>
189+
`
190+
}
191+
159192
dispose() {
160193
// WebviewView doesn't have a dispose method
161194
// We can clear references

vscode/react/src/pages/lineage.tsx

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
import '../App.css'
2+
import {
3+
QueryCache,
4+
QueryClient,
5+
QueryClientProvider,
6+
} from '@tanstack/react-query'
7+
import { useApiModelLineage, useApiModels } from '@/api'
8+
import LineageFlowProvider from '@/components/graph/context'
9+
import { ModelLineage } from '@/components/graph/ModelLineage'
10+
import { useVSCode } from '@/hooks/vscode'
11+
import React from 'react'
12+
13+
export function LineagePage() {
14+
// Handle messages from VSCode extension
15+
React.useEffect(() => {
16+
const handleMessage = (event: MessageEvent) => {
17+
// Ensure the message is from VSCode
18+
if (event.data && event.data.key === 'vscode_send') {
19+
const payload = event.data.payload
20+
switch (payload.key) {
21+
case 'changeFocusOnFile':
22+
console.log('Changing focus to file:', payload.payload.path)
23+
// Implement your focus change logic here
24+
break
25+
default:
26+
console.log('Unhandled message type:', payload.key)
27+
}
28+
}
29+
}
30+
window.addEventListener('message', handleMessage)
31+
return () => {
32+
window.removeEventListener('message', handleMessage)
33+
}
34+
}, [])
35+
36+
const client = new QueryClient({
37+
queryCache: new QueryCache({
38+
onError(error, query) {
39+
console.error(error, query)
40+
},
41+
onSuccess(data, query) {
42+
console.log('success', data, query)
43+
},
44+
}),
45+
defaultOptions: {
46+
queries: {
47+
networkMode: 'always',
48+
refetchOnWindowFocus: false,
49+
retry: false,
50+
staleTime: Infinity,
51+
},
52+
},
53+
})
54+
55+
return (
56+
<QueryClientProvider client={client}>
57+
<Lineage />
58+
</QueryClientProvider>
59+
)
60+
}
61+
62+
function Lineage() {
63+
const selectedModel = 'sushi.customers'
64+
65+
const { data, isLoading } = useApiModelLineage(selectedModel)
66+
const { data: models, isLoading: isLoadingModels } = useApiModels()
67+
if (isLoading) {
68+
return <div>Loading...</div>
69+
}
70+
if (isLoadingModels) {
71+
return <div>Loading models...</div>
72+
}
73+
console.log('models', models)
74+
console.log('data', data)
75+
const modelsRecord = models?.reduce((acc, model) => {
76+
acc[model.name] = model
77+
return acc
78+
}, {} as Record<string, Model>)
79+
80+
return (
81+
<LineageComponentFromWeb
82+
selectedModel={selectedModel}
83+
models={modelsRecord}
84+
/>
85+
)
86+
}
87+
88+
export function LineageComponentFromWeb({
89+
selectedModel,
90+
models,
91+
}: {
92+
selectedModel: string,
93+
models: Record<string, Model>;
94+
}): JSX.Element {
95+
const vscode = useVSCode()
96+
function handleClickModel(id: string): void {
97+
const decodedId = decodeURIComponent(id);
98+
const model = Object.values(models).find((m: Model) => m.fqn === decodedId);
99+
if (!model) {
100+
throw new Error('Model not found');
101+
}
102+
vscode('openFile', { path: model.path });
103+
}
104+
105+
function handleError(error: any): void {
106+
console.log(error)
107+
}
108+
109+
console.log('models inside', models)
110+
const model = models[selectedModel]
111+
112+
return (
113+
<div className="h-[100vh] w-[100vw]">
114+
<LineageFlowProvider
115+
showColumns={true}
116+
handleClickModel={handleClickModel}
117+
handleError={handleError}
118+
models={models}
119+
showControls={false}
120+
>
121+
<ModelLineage model={model} />
122+
</LineageFlowProvider>
123+
</div>
124+
)
125+
}

vscode/react/src/routes/__root.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
import { Outlet, createRootRoute } from '@tanstack/react-router'
22
import { TanStackRouterDevtools } from '@tanstack/react-router-devtools'
3+
import '../App.css'
4+
import { LineagePage } from '@/pages/lineage'
35

46
export const Route = createRootRoute({
5-
component: () => (
7+
component: () => {
8+
console.log('root route')
9+
return (
610
<>
711
<Outlet />
812
<TanStackRouterDevtools />
913
</>
10-
),
14+
)
15+
},
16+
notFoundComponent: () => {
17+
console.log('not found route')
18+
return <LineagePage />
19+
}
1120
})

0 commit comments

Comments
 (0)