Skip to content

uni-flow 公开 API(中文注解)


uni-flow 公开 API(中文注解) / validateWorkflowYamlSource

Function: validateWorkflowYamlSource()

validateWorkflowYamlSource(source): WorkflowYamlDocument

Defined in: yaml/validate.ts:111

解析 YAML 字符串并按 Workflow schema 校验,返回类型化文档。 CLI uniflow validatecreateEngineFromYaml 均走此路径。

Parameters

source

string

Workflow YAML 文本(不是文件路径)

Returns

WorkflowYamlDocument

通过校验的 WorkflowYamlDocument

Throws

语法或 schema 校验失败时

Example

ts
import { validateWorkflowYamlSource } from 'uni-flow';

const doc = validateWorkflowYamlSource(`
apiVersion: uniflow/v1
kind: Workflow
metadata:
  id: demo
spec:
  units:
    - id: a
      uses: demo.echo
  flow:
    type: sequential
    order: [a]
`);
console.log(doc.metadata.id); // "demo"

MIT Licensed