import type { AsyncApiModel, ExtractionIssue } from '@amritk/asyncapi'; import type { OutputWriter } from './create-output-writer.js'; /** Subdirectory of the output root the contract modules land in. */ export declare const CONTRACTS_DIR = "contracts"; /** The package the generated modules import `defineMessages` from. */ export declare const CONTRACTS_PEER = "@amritk/api"; export type EmitMessageContractsOptions = { readonly model: AsyncApiModel; readonly writer: OutputWriter; /** Fallback discriminator for channels that do not declare one (`--discriminator`). */ readonly discriminator?: string; /** Header comment prepended to each file, when `--banner` asked for one. */ readonly bannerPrefix?: string; }; export type EmitMessageContractsResult = { /** Paths staged on the writer, relative to its root, in the order they were staged. */ readonly files: readonly string[]; /** Everything a channel could not project, for the caller to warn about. */ readonly issues: readonly ExtractionIssue[]; /** How many messages made it into a contract, across every channel. */ readonly messageCount: number; /** How many channels got a contract module (the barrel is not one of them). */ readonly channelCount: number; }; /** * Projects every channel of an AsyncAPI document onto a `defineMessages` * contract and stages one module per channel under `contracts/`, plus a barrel. * * These are *runtime values*, not types — which is why the flag that asks for * them refuses `--types-only`, and why the generated files import * `@amritk/api`. That import is the consumer's dependency to satisfy: the CLI * needs the package to have been written, not to be installed where the output * lands, and pinning it as a hard dependency of generated code would drag a * server framework into projects that only wanted the schemas. * * A channel that projects to nothing (every message skipped, or a channel with * no messages at all) is not written: an exported contract with no messages * accepts no frame in either direction, which is a trap rather than a document. * The reasons come back in {@link EmitMessageContractsResult.issues}. * * Only payloads are projected. A message's `headers` schema is generated as its * own tree by the parser run, but has no slot in a messages contract — the * contract describes WebSocket frames, and headers are the broker's layer. Each * module says so in its header when the channel declares any, rather than * leaving the omission to be discovered. * * The barrel's specifiers are always `.ts`, ignoring `--import-ext`: these * modules are the one part of the output `--build` leaves uncompiled (they * import the `@amritk/api` peer, and handing tsc an import the output's project * has not installed would fail the parsers' compilation too). A `.js` specifier * would then name a file this run never wrote. */ export declare const emitMessageContracts: (options: EmitMessageContractsOptions) => Promise;