From 732f23376abf8cfc7dc0ba43ae971e66e6e07ff0 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sat, 29 Nov 2025 16:03:58 +0000 Subject: [PATCH] runBg -> backend II --- cli/deps.ts | 2 +- cli/src/commands/app/dev.ts | 36 +++++++++---------- cli/src/commands/app/wmillTsDev.ts | 12 +++---- .../sharedUtils/vite.sharedUtils.config.js | 2 +- frontend/src/lib/components/raw_apps/utils.ts | 1 - 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/cli/deps.ts b/cli/deps.ts index d86629b653..adc49d62c6 100644 --- a/cli/deps.ts +++ b/cli/deps.ts @@ -57,7 +57,7 @@ export { WebSocketServer, WebSocket } from "npm:ws"; export * as getPort from "npm:get-port@7.1.0"; export * as open from "npm:open"; export * as esMain from "npm:es-main"; -export * as windmillUtils from "jsr:@windmill-labs/shared-utils@1.0.9"; +export * as windmillUtils from "jsr:@windmill-labs/shared-utils@1.0.10"; import { OpenAPI } from "./gen/index.ts"; diff --git a/cli/src/commands/app/dev.ts b/cli/src/commands/app/dev.ts index d34905935d..b4c24bffc9 100644 --- a/cli/src/commands/app/dev.ts +++ b/cli/src/commands/app/dev.ts @@ -407,23 +407,23 @@ async function dev(opts: DevOptions) { runnableId, args ); - log.info(colors.gray(`[runBg] Job started: ${uuid}`)); + log.info(colors.gray(`[backend] Job started: ${uuid}`)); const result = await waitForJob(workspaceId, uuid); return { uuid, result }; }; switch (type) { - case "runBg": { + case "backend": { // Run a runnable synchronously and wait for result - log.info(colors.blue(`[runBg] Running runnable: ${runnable_id}`)); + log.info(colors.blue(`[backend] Running runnable: ${runnable_id}`)); try { const { result } = await runAndWaitForResult(runnable_id, v); - respond("runBgRes", result, false); + respond("backendRes", result, false); } catch (error: any) { - log.error(colors.red(`[runBg] Error: ${error.message}`)); + log.error(colors.red(`[backend] Error: ${error.message}`)); respond( - "runBgRes", + "backendRes", { message: error.message, stack: error.stack }, true ); @@ -431,10 +431,10 @@ async function dev(opts: DevOptions) { break; } - case "runBgAsync": { + case "backendAsync": { // Run a runnable asynchronously and return job ID immediately log.info( - colors.blue(`[runBgAsync] Running runnable async: ${runnable_id}`) + colors.blue(`[backendAsync] Running runnable async: ${runnable_id}`) ); try { const runnables = await loadRunnables(); @@ -451,27 +451,27 @@ async function dev(opts: DevOptions) { runnable_id, v ); - log.info(colors.gray(`[runBgAsync] Job started: ${uuid}`)); + log.info(colors.gray(`[backendAsync] Job started: ${uuid}`)); // Return job ID immediately - respond("runBgAsyncRes", uuid, false); + respond("backendAsyncRes", uuid, false); // Wait for result in the background and send it when done waitForJob(workspaceId, uuid) .then((result) => { - respond("runBgRes", result, false); + respond("backendRes", result, false); }) .catch((error: any) => { respond( - "runBgRes", + "backendRes", { message: error.message, stack: error.stack }, true ); }); } catch (error: any) { - log.error(colors.red(`[runBgAsync] Error: ${error.message}`)); + log.error(colors.red(`[backendAsync] Error: ${error.message}`)); respond( - "runBgAsyncRes", + "backendAsyncRes", { message: error.message, stack: error.stack }, true ); @@ -484,11 +484,11 @@ async function dev(opts: DevOptions) { log.info(colors.blue(`[waitJob] Waiting for job: ${jobId}`)); try { const result = await waitForJob(workspaceId, jobId); - respond("runBgRes", result, false); + respond("backendRes", result, false); } catch (error: any) { log.error(colors.red(`[waitJob] Error: ${error.message}`)); respond( - "runBgRes", + "backendRes", { message: error.message, stack: error.stack }, true ); @@ -501,11 +501,11 @@ async function dev(opts: DevOptions) { log.info(colors.blue(`[getJob] Getting job status: ${jobId}`)); try { const result = await getJobStatus(workspaceId, jobId); - respond("runBgRes", result, false); + respond("backendRes", result, false); } catch (error: any) { log.error(colors.red(`[getJob] Error: ${error.message}`)); respond( - "runBgRes", + "backendRes", { message: error.message, stack: error.stack }, true ); diff --git a/cli/src/commands/app/wmillTsDev.ts b/cli/src/commands/app/wmillTsDev.ts index ca9db42004..256dd89fe6 100644 --- a/cli/src/commands/app/wmillTsDev.ts +++ b/cli/src/commands/app/wmillTsDev.ts @@ -19,8 +19,8 @@ function initWebSocket() { ws.onmessage = (event) => { const data = JSON.parse(event.data) - if (data.type === 'runBgRes' || data.type === 'runBgAsyncRes') { - console.log('Message from WebSocket runBg', data) + if (data.type === 'backendRes' || data.type === 'backendAsyncRes') { + console.log('Message from WebSocket backend', data) const job = reqs[data.reqId] if (job) { const result = data.result @@ -57,22 +57,22 @@ async 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 }) } } }) diff --git a/frontend/sharedUtils/vite.sharedUtils.config.js b/frontend/sharedUtils/vite.sharedUtils.config.js index d20cfa893f..5bf4bcd688 100644 --- a/frontend/sharedUtils/vite.sharedUtils.config.js +++ b/frontend/sharedUtils/vite.sharedUtils.config.js @@ -5,7 +5,7 @@ import { exec } from 'child_process' import { promisify } from 'util' const execAsync = promisify(exec) -const VERSION = '1.0.9' +const VERSION = '1.0.10' export default defineConfig({ build: { diff --git a/frontend/src/lib/components/raw_apps/utils.ts b/frontend/src/lib/components/raw_apps/utils.ts index 46db7c8ba3..a5bede8f2b 100644 --- a/frontend/src/lib/components/raw_apps/utils.ts +++ b/frontend/src/lib/components/raw_apps/utils.ts @@ -1,7 +1,6 @@ import type { ScriptLang } from '../../gen/types.gen' import type { Schema } from '../../common' import { schemaToTsType } from '../../schema' -import { capitalize } from '../../sharedUtils' import { isRunnableByName, isRunnableByPath, type RunnableWithFields } from '../apps/inputType' import type { InlineScript } from '../apps/sharedTypes'