@toist/spec
v0.10.5
Published
Pure Toist pipeline-format tooling: YAML parsing, discriminator/expression parsing, JSON Schema helpers, and offline validation.
Readme
@toist/spec
Pure Toist pipeline-format tooling: YAML parsing, discriminator/expression parsing, JSON Schema helpers, and offline validation.
import { parseYaml, validateSpec } from "@toist/spec"
const spec = parseYaml(`
apiVersion: "toist.in/v1"
id: hello
nodes:
- id: greet
kind: data.json
params:
value: { message: "hello" }
`)
const result = validateSpec(spec)
if (!result.ok) throw new Error(result.errors.join("; "))
console.log(result.parsed?.id)What it exports
parseYaml/YamlErrorparseExpr,evalExprparseDisc,resolveDiscvalidateSpec- kind-contract types like
NodeKind,ExecContext,PlatformCtx - JSON Schema helpers like
pipelineSchemaandkindToNodeSchema
Validation
validateSpec(input) is pure. It checks pipeline shape, refs, cycles, payload schema, and returns parsed graph data:
const result = validateSpec(spec)
if (result.ok) {
console.log(result.parsed?.parsedNodes)
console.log(result.parsed?.edges)
}If you have a live kind registry, pass kind resolvers through ValidateOptions.
Kind-facing types
Kinds depend on the spec package for their contract:
import type { NodeKind } from "@toist/spec"That keeps pipeline tooling and kind authoring free of runner/server dependencies.
