term
API reference for @effx/compiler/generate/term
term.ts overview
Exports Grouped by Category
utils
MethodCall (interface)
One method-call suffix (.<name>(<args>)), e.g. .annotate(K, v) appended to a generated expression.
Signature
export interface MethodCall {
readonly name: string
readonly args: ReadonlyArray<Term>
}NameOf (type alias)
Resolves a reference to its printed name (collision-free local plus static-member suffix). Pure.
Signature
type NameOf = (ref: RefLike) => stringObjEntry (interface)
One key: value entry of an object literal. key is the exact key text (already quoted if it must be).
Signature
export interface ObjEntry {
readonly key: string
readonly value: Term
}ObjLayout (type alias)
How an object literal prints. "inline" is the generator's { ${join} } template, which pads an empty
object to { }; "compact" is the Arg printer's form, which collapses an empty object to {}; "block"
writes one entry per line at two-space indent with a trailing comma (the endpoint options object).
Signature
type ObjLayout = "inline" | "compact" | "block"RefLike (type alias)
A reference a term names; the term keeps the identity, the printer resolves it to an import local.
Signature
type RefLike = SchemaRef | SymbolRefTerm (type alias)
A generated TypeScript expression, structurally. Call.callee is itself a term, so higher-order calls
(HttpApiSchema.status(200)(success)) and chains (SchemaAST.resolve(s.ast)?.httpApiStatus) are exact.
Signature
type Term =
| { readonly _tag: "Lit"; readonly json: Schema.Json }
| { readonly _tag: "Ref"; readonly ref: RefLike }
| { readonly _tag: "Call"; readonly callee: Term; readonly args: ReadonlyArray<Term> }
| { readonly _tag: "Chain"; readonly head: Term; readonly calls: ReadonlyArray<MethodCall> }
| { readonly _tag: "Member"; readonly term: Term; readonly member: string }
| { readonly _tag: "OptionalMember"; readonly term: Term; readonly member: string }
| { readonly _tag: "Nullish"; readonly head: Term; readonly tail: ReadonlyArray<Term> }
| { readonly _tag: "StrictEqual"; readonly left: Term; readonly right: Term }
| {
readonly _tag: "Cond"
readonly test: Term
readonly consequent: Term
readonly alternate: Term
}
| { readonly _tag: "Paren"; readonly term: Term }
| { readonly _tag: "Obj"; readonly entries: ReadonlyArray<ObjEntry>; readonly layout: ObjLayout }
| { readonly _tag: "Arr"; readonly items: ReadonlyArray<Term> }arr
Signature
declare const arr: (items: ReadonlyArray<Term>) => Termcall
Signature
declare const call: (callee: Term, args: ReadonlyArray<Term>) => Termchain
Signature
declare const chain: (head: Term, calls: ReadonlyArray<MethodCall>) => Termcond
Signature
declare const cond: (test: Term, consequent: Term, alternate: Term) => Termlit
Signature
declare const lit: (json: Schema.Json) => Termmember
Signature
declare const member: (term: Term, name: string) => TermmethodCall
Signature
declare const methodCall: (name: string, args: ReadonlyArray<Term>) => MethodCallnullish
Signature
declare const nullish: (head: Term, tail: ReadonlyArray<Term>) => Termobj
Signature
declare const obj: (entries: ReadonlyArray<ObjEntry>, layout?: ObjLayout) => TermoptionalMember
Signature
declare const optionalMember: (term: Term, name: string) => Termparen
Signature
declare const paren: (term: Term) => TermprintMethodCall
Prints a receiverless method-call suffix: .name(arg, …).
Signature
declare const printMethodCall: (names: NameOf, call_: MethodCall) => stringprintTerm
Prints a term exactly as the generator wrote it; names resolves references and nothing else. Pure.
Signature
declare const printTerm: (names: NameOf, term: Term) => stringref
Signature
declare const ref: (reference: RefLike) => TermrefKey
The import-binding key of a reference: one binding per module/export, independent of any member.
Signature
declare const refKey: (ref: RefLike) => stringstrictEqual
Signature
declare const strictEqual: (left: Term, right: Term) => Term