Skip to content

Function: extendSubject()

Makaio Framework


Makaio Framework / bus-core / extendSubject

extendSubject<SD, Ext>(context, subject, extensions): ExtendedSubjectDefinition<SD, Ext>

Defined in: ../../../packages/bus-core/src/extend-subject.ts:87

Extend a registered bus subject’s schema with additional fields.

Called on the bus context directly. Adds new fields to the Zod schema for dev-mode validation and widens the TypeScript payload type. Successive calls accumulate fields — two packages can independently extend the same subject with different field names. If two extensions add the same field name, the later call’s definition wins (Zod .extend() semantics).

The returned value is the same runtime object — only the TypeScript type widens.

SD extends SubjectDefinition

Ext extends RequestSubjectExtension | EventSubjectExtension

MakaioBusContext

Bus context containing the namespace registry

SD

The SubjectDefinition to extend

Ext

Additional Zod fields to add

ExtendedSubjectDefinition<SD, Ext>

The same SubjectDefinition with wider TypeScript types