emit
API reference for @effx/compiler/generate/emit
emit.ts overview
Exports Grouped by Category
- utils
- CliTransport (type alias)
- ErrorSchemaBuilt (interface)
- Exposed (interface)
- HEADER
- HttpTransport (type alias)
- Imports (class)
- RpcTransport (type alias)
- bindCallRefs
- bindRef
- bindRefs
- bindTermRefs
- errorsBuilt
- errorsExpr
- exposed
- generated
- handlerCall
- header
- identifier
- indent
- nameOf
- operationName
- pathParams
- refTerm
- render
- schemaExpr
- schemaName
utils
CliTransport (type alias)
Signature
type CliTransport = Extract<Transport, { readonly _tag: "cli" }>ErrorSchemaBuilt (interface)
The error: schema expression plus the references its string form registers, in that exact order: the
several-schema case registers the member schemas before Schema, as the historical builder did.
Signature
export interface ErrorSchemaBuilt {
readonly term: Term
readonly references: ReadonlyArray<RefLike>
}Exposed (interface)
An Exposure joined with the Operation it exposes. T narrows the transport.
Signature
export interface Exposed<T extends Transport = Transport> {
readonly exposure: ExposureNode
readonly transport: T
readonly operation: OperationNode
}HEADER
Signature
declare const HEADER: "// Generated by effx. Do not edit."HttpTransport (type alias)
Signature
type HttpTransport = Extract<Transport, { readonly _tag: "http" }>Imports (class)
Signature
declare class Imports { constructor(private readonly context: GenerationContext = defaultGenerationContext) }add (method)
Registers an import and returns its collision-free local; unoccupied names keep their original bytes.
Signature
declare const add: (module: string, name: string) => stringreserve (method)
Reserve authored declarations and lexical locals before adding schema imports.
Signature
declare const reserve: (...names: ReadonlyArray<string>) => voidoccupied (method)
Signature
declare const occupied: (local: string) => booleanaddAliased (method)
Reserve a collision-free local for an imported root without changing its exported name.
Signature
declare const addAliased: (module: string, exported: string, preferredLocal: string) => stringaddTypeAliased (method)
Reserve a collision-free type-only local; the projected source prints this name in a type.
Signature
declare const addTypeAliased: (module: string, exported: string, preferredLocal: string) => stringrender (method)
effect first, then effect/*, then everything else; modules and names alphabetical.
Signature
declare const render: () => ReadonlyArray<string>RpcTransport (type alias)
Signature
type RpcTransport = Extract<Transport, { readonly _tag: "rpc" }>bindCallRefs
Registers every reference a method-call suffix prints, in print order.
Signature
declare const bindCallRefs: (imports: Imports, names: Map<string, string>, suffix: MethodCall) => voidbindRef
Registers reference once (first occurrence wins) and returns its collision-free local.
Signature
declare const bindRef: (imports: Imports, names: Map<string, string>, reference: RefLike) => stringbindRefs
The local-name table for a reference list, in first-occurrence order.
Signature
declare const bindRefs: (imports: Imports, references: ReadonlyArray<RefLike>) => ReadonlyMap<string, string>bindTermRefs
Registers every reference a term prints, in print order (deduplicated by bindRef).
Signature
declare const bindTermRefs: (imports: Imports, names: Map<string, string>, term: Term) => voiderrorsBuilt
Signature
declare const errorsBuilt: (errors: ReadonlyArray<SchemaRef>) => ErrorSchemaBuilterrorsExpr
Schema.Never for none, the schema itself for one, Schema.Union([...]) for several.
Signature
declare const errorsExpr: (imports: Imports, errors: ReadonlyArray<SchemaRef>) => stringexposed
Every exposure of the IR, sorted by StableId, each resolved to its operation. An exposure whose
operation is missing or not an Operation node is an invariant breach (analysis blocks it), hence a fault.
Signature
declare const exposed: (ir: ApplicationIR, index: GraphIndex) => Effect.Effect<ReadonlyArray<Exposed>, CompilerFault>generated
Signature
declare const generated: (path: string, contents: string) => GeneratedFilehandlerCall
Calls a handler by SymbolRef; a supplied guard thunk stays lazy until the handler calls it.
Signature
declare const handlerCall: (imports: Imports, handler: SymbolRef, args: string, guard?: string) => stringheader
The three header lines ADR 0008 requires: marker, handler sources, operation ids.
Signature
declare const header: (items: ReadonlyArray<Exposed>) => ReadonlyArray<string>identifier
User.Get → UserGet; anything that is not an identifier character is dropped.
Signature
declare const identifier: (name: string) => stringindent
Signature
declare const indent: (lines: ReadonlyArray<string>, level?: number) => ReadonlyArray<string>nameOf
The pure name resolver a printer receives: the registered import local for a reference.
Signature
declare const nameOf: (names: ReadonlyMap<string, string>) => NameOfoperationName
Operation name as it appears in operation:<name>.
Signature
declare const operationName: (operation: OperationNode) => stringpathParams
/users/:id/email → ["id"]; duplicates collapse, order preserved.
Signature
declare const pathParams: (path: string) => ReadonlyArray<string>refTerm
A reference as a term: the imported symbol plus its member path as structural access.
Signature
declare const refTerm: (reference: RefLike) => Termrender
Joins header, imports and body into file contents; body empty → export {}.
Signature
declare const render: (headerLines: ReadonlyArray<string>, imports: Imports, body: ReadonlyArray<string>) => stringschemaExpr
Preserve the original symbol and static-member suffix while resolving a collision-free local import.
Signature
declare const schemaExpr: (imports: Imports, reference: SchemaRef) => stringschemaName
The stable declared symbol name, including static members, independent of import aliases.
Signature
declare const schemaName: (ref: SchemaRef) => string