refactor(monorepo): decouple api and webui into workspaces packages

This commit is contained in:
yiling
2026-06-01 23:35:00 +08:00
parent e3f4fa219e
commit 1f341c15d0
288 changed files with 18024 additions and 21178 deletions
@@ -0,0 +1,50 @@
import { bundleWorkflowCode } from '@temporalio/worker'
import type { BunPlugin } from 'bun'
import { resolve } from 'node:path'
export interface TemporalWorkflowPluginOptions {
/** Query param identifier. Default: 'workflow' */
identifier?: string
/** Forwarded to bundleWorkflowCode (minus workflowsPath) */
bundleOptions?: Omit<Parameters<typeof bundleWorkflowCode>[0], 'workflowsPath'>
}
export function temporalWorkflow(options: TemporalWorkflowPluginOptions = {}): BunPlugin {
return {
name: 'temporal-workflow',
setup(build) {
// Resolve imports with the workflow query parameter
build.onResolve({ filter: /:::workflow$/ }, (args) => {
console.log(args)
const cleanPath = args.path.split(':::')[0]!
const resolveDir = args.importer
? args.importer.replace(/[/\\\\][^/\\\\]*$/, '')
: (args.resolveDir ?? process.cwd())
const resolved = resolve(resolveDir, cleanPath)
return {
path: resolved,
namespace: 'temporal-workflow',
}
})
// Load and bundle workflow code
build.onLoad({ filter: /.*/, namespace: 'temporal-workflow' }, async (args) => {
const workflowsPath = args.path
const bundle = await bundleWorkflowCode({
workflowsPath,
...options.bundleOptions,
})
return {
contents: `export default { code: ${JSON.stringify(bundle.code)}, sourceMap: ${JSON.stringify(bundle.sourceMap ?? '')} };`,
loader: 'js',
}
})
},
}
}
export default temporalWorkflow
+1 -1
View File
@@ -2,7 +2,7 @@ import { prisma } from '@shumai/db'
import { WorkflowTask, WorkflowTaskStatus, WorkflowTaskType } from '@shumai/db'
import { Executor } from './executor'
import * as taskActivities from './activities/task'
import { logger } from '@/logger'
import { logger } from '@shumai/core/src/logger'
type WorkflowFn = (task: WorkflowTask) => Promise<void>