Function: extendSubject()
Makaio Framework / bus-core / extendSubject
Function: extendSubject()
Section titled “Function: 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.
Type Parameters
Section titled “Type Parameters”SD extends SubjectDefinition
Ext extends RequestSubjectExtension | EventSubjectExtension
Parameters
Section titled “Parameters”context
Section titled “context”Bus context containing the namespace registry
subject
Section titled “subject”SD
The SubjectDefinition to extend
extensions
Section titled “extensions”Ext
Additional Zod fields to add
Returns
Section titled “Returns”ExtendedSubjectDefinition<SD, Ext>
The same SubjectDefinition with wider TypeScript types