@sagentic-ai/sagentic-af / when
when() ​
ts
when<S, T>(rule, schema): <This, Args, Return>(target, context) => (this, ...args) => Return
Decorator for defining reactions to structured messages.
Type parameters ​
• S
• T extends ZodRawShape
Parameters ​
• rule: string
• schema: ZodObject
<T
, UnknownKeysParam
, ZodTypeAny
, { [k in string | number | symbol]: addQuestionMarks<baseObjectOutputType<T>, requiredKeys<baseObjectOutputType<T>>>[k] }
, { [k in string | number | symbol]: baseObjectInputType<T>[k] }
>
Returns ​
Function
Type parameters ​
• This
• Args extends [
S
,{ [k in string | number | symbol]: addQuestionMarks<baseObjectOutputType<T>, requiredKeys<baseObjectOutputType<T>>>[k] }
]• Return
Parameters ​
• target
• context:
ClassMethodDecoratorContext
<This
, (this
, ...args
) =>Return
>Returns ​
Function
Parameters ​
• this:
This
• ...args:
Args
Returns ​
Return