本页还没有译文
本页 17 段还没译成Português (BR),下面显示的是英文原文。createWorkflow
还没翻译译自英文(tanstack.com)本页 17 段都还没译
Function: createWorkflow()
function createWorkflow<TInputSchema, TOutputSchema, TStateSchema>(config): WorkflowBuilder<TInputSchema, TOutputSchema, TStateSchema>;Defined in: packages/workflow-core/src/define/define-workflow.ts:198
Define a workflow. Returns a builder chain:
export const onboard = createWorkflow({
id: 'onboard',
input: z.object({ userId: z.string() }),
})
.middleware([requireUser, traced])
.handler(async (ctx) => {
const profile = await ctx.step('load', () => loadProfile(ctx.user.id))
await ctx.sleep(60_000)
const decision = await ctx.approve({ title: 'Continue?' })
return { ok: decision.approved }
})
The handler's ctx argument carries everything: input, state,
durable primitives (step, sleep, waitForEvent, ...), and
any fields added by registered middleware. Helpers should accept
a typed Ctx<...> argument to compose cleanly.
Type Parameters
TInputSchema
TInputSchema extends SchemaInput | undefined = undefined
TOutputSchema
TOutputSchema extends SchemaInput | undefined = undefined
TStateSchema
TStateSchema extends SchemaInput | undefined = undefined
Parameters
config
CreateWorkflowConfig<TInputSchema, TOutputSchema, TStateSchema>
Returns
WorkflowBuilder<TInputSchema, TOutputSchema, TStateSchema>
AI 翻译查看英文原文