effx
API reference@effx/compilergenerate

emit

API reference for @effx/compiler/generate/emit

emit.ts overview


Exports Grouped by Category


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
}

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) => string

reserve (method)

Reserve authored declarations and lexical locals before adding schema imports.

Signature

declare const reserve: (...names: ReadonlyArray<string>) => void

occupied (method)

Signature

declare const occupied: (local: string) => boolean

addAliased (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) => string

addTypeAliased (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) => string

render (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) => void

bindRef

Registers reference once (first occurrence wins) and returns its collision-free local.

Signature

declare const bindRef: (imports: Imports, names: Map<string, string>, reference: RefLike) => string

bindRefs

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) => void

errorsBuilt

Signature

declare const errorsBuilt: (errors: ReadonlyArray<SchemaRef>) => ErrorSchemaBuilt

errorsExpr

Schema.Never for none, the schema itself for one, Schema.Union([...]) for several.

Signature

declare const errorsExpr: (imports: Imports, errors: ReadonlyArray<SchemaRef>) => string

exposed

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) => GeneratedFile

handlerCall

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) => string

header

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) => string

indent

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>) => NameOf

operationName

Operation name as it appears in operation:<name>.

Signature

declare const operationName: (operation: OperationNode) => string

pathParams

/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) => Term

render

Joins header, imports and body into file contents; body empty → export {}.

Signature

declare const render: (headerLines: ReadonlyArray<string>, imports: Imports, body: ReadonlyArray<string>) => string

schemaExpr

Preserve the original symbol and static-member suffix while resolving a collision-free local import.

Signature

declare const schemaExpr: (imports: Imports, reference: SchemaRef) => string

schemaName

The stable declared symbol name, including static members, independent of import aliases.

Signature

declare const schemaName: (ref: SchemaRef) => string

On this page