Skip to content

defineDomain

defineDomain<TDomain, TEvents, TCommands, TRpc>(domainName, definition): DomainDefinition<TDomain, TEvents, TCommands, TRpc>

Defined in: packages/hoppity/src/contracts/defineDomain.ts:50

Defines a domain and returns typed contract objects for all its operations.

The returned contracts are pure data — they carry metadata and derived topology properties (exchange, routingKey) but have no knowledge of RabbitMQ or rascal. Topology generation happens later in ServiceBuilder.

Accepts both bare Zod schemas and extended { schema, …options } objects for each operation, enabling future per-operation options (e.g. partitionBy) without a breaking API change.

TDomain extends string

TEvents extends EventsDefinition

TCommands extends CommandsDefinition

TRpc extends RpcDefinition

TDomain

The domain identifier. Used as a namespace for all generated topology artifact names. Must be non-empty.

DomainDefinitionInput<TEvents, TCommands, TRpc>

The event, command, and RPC operation schemas for this domain.

DomainDefinition<TDomain, TEvents, TCommands, TRpc>

A DomainDefinition with typed contract objects for each operation.