import type { WerkenTransportOptions } from "../options.js"; import type { DeadLetterStage } from "../dead-letter.js"; /** A message the harness pushed through the transport, with the outcome it reached. */ export interface HarnessRecord { readonly type?: string; readonly id: string; readonly attributes: Readonly>; readonly body: string; } export interface DeadLetteredRecord extends HarnessRecord { readonly reason: string; readonly stage: DeadLetterStage; } export interface EmitOptions { readonly id?: string; readonly source?: string; readonly subject?: string; readonly time?: Date; readonly dataschema?: string; readonly datacontenttype?: string; readonly deliveryAttempt?: number; readonly orderingKey?: string; readonly extensions?: Record; } export interface WerkenTestHarnessOptions { /** The Nest module under test — normally the worker module. */ readonly module: any; /** Provider overrides, so ports can be replaced with fakes. */ readonly overrides?: Array<{ provide: any; useValue: any; }>; /** * Schema handling. `passthrough` — the only mode — sends payloads as plain JSON with no schema * resolution, which is what most consumer tests want. Exercise real Avro decoding against the * emulator instead; see tests/integration/schema.integration.test.ts. */ readonly schemas?: "passthrough"; /** Default `ce-source` for emitted events. */ readonly source?: string; /** * Deterministic clock. Drives `ce-time` and the Pub/Sub publish time on emitted messages, and the * default in-memory idempotency store, so advancing it past `idempotency.ttlMs` lets a test watch * a processed marker expire. * * It does not drive event lateness: that is a telemetry histogram, and the harness deliberately * surfaces no telemetry — assert lateness against a real Telemetry in a unit test instead. */ readonly now?: () => Date; /** Validation policies, so rejection behaviour can be asserted. */ readonly validation?: WerkenTransportOptions["validation"]; /** What to do with an event no handler matches. Default 'ack'. */ readonly onUnhandledPattern?: WerkenTransportOptions["onUnhandledPattern"]; /** Duplicate suppression. Defaults to a fresh in-memory store per harness. */ readonly idempotency?: WerkenTransportOptions["idempotency"]; } export interface WerkenTestHarness { emit(type: string, data: unknown, options?: EmitOptions): Promise; /** * Emits an envelope `emit` cannot express — a missing attribute, an unsupported specversion, a * body that is not JSON. Takes the same delivery options, since how a malformed message behaves * is often exactly what depends on the attempt or the ordering key. */ emitRaw(attributes: Record, body: Buffer | string, options?: EmitOptions): Promise; readonly acked: readonly HarnessRecord[]; readonly nacked: readonly HarnessRecord[]; /** Messages the pipeline sent to the dead-letter topic, with the reason and stage. */ readonly deadLettered: readonly DeadLetteredRecord[]; /** Resolve a provider from the testing module — useful for asserting on fakes. */ get(token: unknown): T; /** Simulate the shutdown drain: stop taking messages and wait for in-flight handlers. */ drain(): Promise; close(): Promise; } export declare function createWerkenTestHarness(options: WerkenTestHarnessOptions): Promise; //# sourceMappingURL=harness.d.ts.map