mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-09 08:03:50 +00:00
runBg -> backend
This commit is contained in:
@@ -20,7 +20,7 @@ console.log('Running postinstall for root project');
|
||||
|
||||
import { x } from 'tar'
|
||||
|
||||
const tarUrl = 'https://pub-06154ed168a24e73a86ab84db6bf15d8.r2.dev/ui_builder-00e139d.tar.gz'
|
||||
const tarUrl = 'https://pub-06154ed168a24e73a86ab84db6bf15d8.r2.dev/ui_builder-ad9e747.tar.gz'
|
||||
const outputTarPath = path.join(process.cwd(), 'ui_builder.tar.gz')
|
||||
const extractTo = path.join(process.cwd(), 'static/ui_builder/')
|
||||
|
||||
|
||||
@@ -42,12 +42,12 @@
|
||||
result = e
|
||||
}
|
||||
|
||||
if (event.data.type == 'runBg') {
|
||||
if (event.data.type == 'backend') {
|
||||
respond({ result, error })
|
||||
}
|
||||
return result
|
||||
}
|
||||
if (event.data.type == 'runBg' || event.data.type == 'runBgAsync') {
|
||||
if (event.data.type == 'backend' || event.data.type == 'backendAsync') {
|
||||
const runnable_id = data.runnable_id
|
||||
let runnable = runnables[runnable_id]
|
||||
if (runnable) {
|
||||
@@ -80,7 +80,7 @@
|
||||
undefined
|
||||
)
|
||||
let job: JobById = { component: runnable_id, created_at: Date.now(), job: uuid }
|
||||
if (event.data.type == 'runBgAsync') {
|
||||
if (event.data.type == 'backendAsync') {
|
||||
let result = uuid
|
||||
respond({ result })
|
||||
}
|
||||
|
||||
@@ -68,13 +68,13 @@ export function genWmillTs(runnables: Record<string, Runnable>) {
|
||||
return `// THIS FILE IS READ-ONLY
|
||||
// AND GENERATED AUTOMATICALLY FROM YOUR RUNNABLES
|
||||
|
||||
export declare const runBg: {
|
||||
export declare const backend: {
|
||||
${Object.entries(runnables)
|
||||
.map(([k, v]) => ` ${k}: (args: ${hiddenRunnableToTsType(v)}) => Promise<any>;`)
|
||||
.join('\n')}
|
||||
};
|
||||
|
||||
export declare const runBgAsync: {
|
||||
export declare const backendAsync: {
|
||||
${Object.entries(runnables)
|
||||
.map(([k, v]) => ` ${k}: (args: ${hiddenRunnableToTsType(v)}) => Promise<string>;`)
|
||||
.join('\n')}
|
||||
|
||||
@@ -8,22 +8,22 @@ function doRequest(type: string, o: object) {
|
||||
})
|
||||
}
|
||||
|
||||
export const runBg = new Proxy(
|
||||
export const backend = new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, runnable_id: string) {
|
||||
return (v: any) => {
|
||||
return doRequest('runBg', { runnable_id, v })
|
||||
return doRequest('backend', { runnable_id, v })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
export const runBgAsync = new Proxy(
|
||||
export const backendAsync = new Proxy(
|
||||
{},
|
||||
{
|
||||
get(_, runnable_id: string) {
|
||||
return (v: any) => {
|
||||
return doRequest('runBgAsync', { runnable_id, v })
|
||||
return doRequest('backendAsync', { runnable_id, v })
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -39,7 +39,7 @@ export function getJob(jobId: string) {
|
||||
|
||||
window.addEventListener('message', (e) => {
|
||||
if (e.data.type == 'runBgRes' || e.data.type == 'runBgAsyncRes') {
|
||||
console.log('Message from parent runBg', e.data)
|
||||
console.log('Message from parent backend', e.data)
|
||||
let job = reqs[e.data.reqId]
|
||||
if (job) {
|
||||
const result = e.data.result
|
||||
|
||||
@@ -8,7 +8,7 @@ const root = createRoot(document.getElementById('root')!);
|
||||
root.render(<App/>);
|
||||
`
|
||||
const appTsx = `import React, { useState } from 'react'
|
||||
import { runBg } from './wmill'
|
||||
import { backend } from './wmill'
|
||||
import './index.css'
|
||||
|
||||
const App = () => {
|
||||
@@ -18,7 +18,7 @@ const App = () => {
|
||||
async function runA() {
|
||||
setLoading(true)
|
||||
try {
|
||||
setValue(await runBg.a({ x: 42 }))
|
||||
setValue(await backend.a({ x: 42 }))
|
||||
} catch (e) {
|
||||
console.error()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user