/** * `publishCapability` + `publishPlugin` — cross-process publish as a * capability composition. * * import { createApp, publishPlugin } from "@nwire/app"; * * const app = createApp({ appName: "shop" }).with(publishPlugin()); * * // inside a handler: * await ctx.publish(OrderShipped, { orderId, customerId }); * * The capability composes `runtime.emit` (local fan-out to subscribers) * with `runtime.sinkDrain` (outbound chain delivery). For events marked * public via `defineEvent(...).public()` the call fires both; for * private events only local subscribers fire and the sink is skipped. * * ## When to use this vs forge * * Forge ships its own bundled publish path inside `ForgeDispatcher` — * projections fold, actors transition, workflows fire, and the bus * publishes in one atomic sequence with defined order. That sequence * cannot be decomposed without breaking saga ordering guarantees. * * `publishCapability` is the non-forge path: same emit + sink-drain * shape, no projection/actor/workflow integration. Apps that aren't * doing CQRS but still need cross-process broadcast install this; apps * with forge use the forge path. */ import { type Capability } from "@nwire/runtime"; import type { EventDefinition } from "@nwire/messages"; import type { PluginDefinition } from "./runtime/index.js"; /** Ctx shape contributed by `publishCapability`. */ export interface PublishCaps { publish(event: EventDefinition & { readonly name: string; readonly schema: { parse(input: unknown): unknown; }; /** Set by `defineEvent(...).public()`. */ readonly $public?: boolean; }, payload: TPayload): Promise; } /** * The capability. Provides `ctx.publish`; the runtime methods it composes * (`emit`, `sinkDrain`) are already exposed. * * Sink drain fires only when `event.$public === true`. Private events * stay intra-bounded-context — they fan out to local subscribers but * never cross the process membrane. */ export declare const publishCapability: Capability; /** * `app.with(publishPlugin())` installs `publishCapability`. Stateless; * no options. The capability's `__mark` carries `PublishCaps` so the * App's `` learns about `ctx.publish`. */ export declare function publishPlugin(): PluginDefinition;