Skip to main content

@svatah/yam-steps

defineStep API and the Tier 0 matcher

Exports

ExportKindSignature
CompiledTemplateinterfaceexport interface CompiledTemplate
compileTemplatefunctionexport function compileTemplate(template: string): CompiledTemplateCompile a template into a matcher.
CUSTOM_STEPvariableCUSTOM_STEP = Symbol.for("yam.customStep")Discriminates a CustomStep from anything else a module might export.
customDiagnosticfunctionexport function customDiagnostic(
CustomStepinterfaceexport interface CustomStep<A extends StepArgs = StepArgs>What defineStep returns, and what a steps/*.ts file exports.
DefinedStepinterfaceexport interface DefinedStep<A extends StepArgs = StepArgs> extends CustomStep<A>A defined step, plus the compiled template the matcher uses.
defineStepfunctionexport function defineStep<A extends StepArgs = StepArgs>(
Diagnosticinterfaceexport interface DiagnosticThe diagnostics Tier 0 produces.
emitCustomfunctionexport function emitCustom(Split a match's captures into params and targets.
EmitOptionsinterfaceexport interface EmitOptions
EmittedCustominterfaceexport interface EmittedCustom
isCustomStepfunctionexport function isCustomStep(value: unknown): value is CustomStep
LoadResultinterfaceexport interface LoadResult
loadStepsfunctionexport async function loadSteps(root: string, dir = "steps"): Promise<LoadResult>Load steps/ into a registry.
matchTemplatefunctionexport function matchTemplate(Match a sentence against a compiled template.
Placeholderinterfaceexport interface Placeholder
PLACEHOLDER_TYPESvariablePLACEHOLDER_TYPES = ["string", "number", "boolean", "target", "value"] as constThe placeholder types a template may declare (LLD §5).
PlaceholderTypetypealiasexport type PlaceholderType = (typeof PLACEHOLDER_TYPES)[number];
RegistryMatchinterfaceexport interface RegistryMatch
StepArgstypealiasexport type StepArgs = Readonly<Record<string, unknown>>;The arguments a handler receives.
StepContextinterfaceexport interface StepContext<A extends StepArgs = StepArgs>What a handler can do.
StepHandlertypealiasexport type StepHandler<A extends StepArgs = StepArgs> = (
StepMetainterfaceexport interface StepMetaWhat defineStep's second argument may say.
StepRegistryclassexport class StepRegistry
StepScopeinterfaceexport interface StepScopeThe slice of the run's scope a custom step may touch (LLD §8.5).
tvariablet t — the placeholder types, named, for anyone writing a template in code
TargetResolvertypealiasexport type TargetResolver = (phrase: string) => TargetRef;How a target placeholder's phrase becomes a TargetRef. Supplied by the compiler.
TemplateErrorclassexport class TemplateError extends Error {}
TemplateMatchinterfaceexport interface TemplateMatch
ValueParsertypealiasexport type ValueParser = (raw: string) => ValueRef;How a value placeholder's text becomes a ValueRef. Supplied by the compiler.