@svatah/yam-steps
defineStep API and the Tier 0 matcher
- Source:
packages/steps· README:packages/steps/README.md - Install:
npm install @svatah/yam-steps - Version 0.1.0 · Apache-2.0
Exports
| Export | Kind | Signature | |
|---|---|---|---|
CompiledTemplate | interface | export interface CompiledTemplate | |
compileTemplate | function | export function compileTemplate(template: string): CompiledTemplate | Compile a template into a matcher. |
CUSTOM_STEP | variable | CUSTOM_STEP = Symbol.for("yam.customStep") | Discriminates a CustomStep from anything else a module might export. |
customDiagnostic | function | export function customDiagnostic( | |
CustomStep | interface | export interface CustomStep<A extends StepArgs = StepArgs> | What defineStep returns, and what a steps/*.ts file exports. |
DefinedStep | interface | export interface DefinedStep<A extends StepArgs = StepArgs> extends CustomStep<A> | A defined step, plus the compiled template the matcher uses. |
defineStep | function | export function defineStep<A extends StepArgs = StepArgs>( | |
Diagnostic | interface | export interface Diagnostic | The diagnostics Tier 0 produces. |
emitCustom | function | export function emitCustom( | Split a match's captures into params and targets. |
EmitOptions | interface | export interface EmitOptions | |
EmittedCustom | interface | export interface EmittedCustom | |
isCustomStep | function | export function isCustomStep(value: unknown): value is CustomStep | |
LoadResult | interface | export interface LoadResult | |
loadSteps | function | export async function loadSteps(root: string, dir = "steps"): Promise<LoadResult> | Load steps/ into a registry. |
matchTemplate | function | export function matchTemplate( | Match a sentence against a compiled template. |
Placeholder | interface | export interface Placeholder | |
PLACEHOLDER_TYPES | variable | PLACEHOLDER_TYPES = ["string", "number", "boolean", "target", "value"] as const | The placeholder types a template may declare (LLD §5). |
PlaceholderType | typealias | export type PlaceholderType = (typeof PLACEHOLDER_TYPES)[number]; | |
RegistryMatch | interface | export interface RegistryMatch | |
StepArgs | typealias | export type StepArgs = Readonly<Record<string, unknown>>; | The arguments a handler receives. |
StepContext | interface | export interface StepContext<A extends StepArgs = StepArgs> | What a handler can do. |
StepHandler | typealias | export type StepHandler<A extends StepArgs = StepArgs> = ( | |
StepMeta | interface | export interface StepMeta | What defineStep's second argument may say. |
StepRegistry | class | export class StepRegistry | |
StepScope | interface | export interface StepScope | The slice of the run's scope a custom step may touch (LLD §8.5). |
t | variable | t | t — the placeholder types, named, for anyone writing a template in code |
TargetResolver | typealias | export type TargetResolver = (phrase: string) => TargetRef; | How a target placeholder's phrase becomes a TargetRef. Supplied by the compiler. |
TemplateError | class | export class TemplateError extends Error {} | |
TemplateMatch | interface | export interface TemplateMatch | |
ValueParser | typealias | export type ValueParser = (raw: string) => ValueRef; | How a value placeholder's text becomes a ValueRef. Supplied by the compiler. |