本页还没有译文
本页 19 段还没译成Español,下面显示的是英文原文。selectWorkflowVersion
还没翻译译自英文(tanstack.com)本页 19 段都还没译
Function: selectWorkflowVersion()
function selectWorkflowVersion<T>(
versions,
runId,
runStore): Promise<T | undefined>;Defined in: packages/workflow-core/src/registry/select-version.ts:28
Pick the workflow version that a persisted run was started under.
Hosts running multiple versions of the same workflow side-by-side
use this to route resume calls to the right code path. Each
WorkflowDefinition should carry a version field
(createWorkflow({ version: 'v1', ... })); the helper compares
that against the workflowVersion field on the run's persisted
state.
Resolution order:
- Exact match by
workflowIdANDworkflowVersion. - If no
workflowVersionis persisted (e.g., older runs from before the version field existed), fall back to the FIRST definition whoseidmatches and which does NOT declareversion(the "unversioned default"). - Otherwise undefined — the host decides whether to reject or use a latest-version fallback.
const v1 = createWorkflow({ id: 'pipeline', version: 'v1' }).handler(...)
const v2 = createWorkflow({ id: 'pipeline', version: 'v2' }).handler(...)
const wf = await selectWorkflowVersion([v1, v2], runId, store)
?? v2 // default to latest for fresh starts / unrouted runs
runWorkflow({ workflow: wf, runId, ... })
Type Parameters
T
T extends AnyWorkflowDefinition
Parameters
versions
readonly T[]
runId
string
runStore
Returns
Promise<T | undefined>
AI 翻译查看英文原文