Skip to content

PURISTA API / Modules / @purista/core / CommandDefinitionBuilder

Class: CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

@purista/core.CommandDefinitionBuilder

Command definition builder is a helper to create and define a command for a service. It helps to set all needed information like schemas and hooks. With these information, the types are automatically set and extended.

A working schema definition needs at least a command name, a short description and the function implementation.

Type parameters

NameType
ServiceClassTypeextends ServiceClass
MessagePayloadTypeunknown
MessageParamsType{}
MessageResultTypevoid
PayloadSchemaextends Schema = ZodAny
ParameterSchemaextends Schema = ZodAny
ResultSchemaextends Schema = ZodAny
Invokes{}
EmitListType{}

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>(commandName, commandDescription, eventName?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Type parameters

NameType
ServiceClassTypeextends ServiceClass<unknown>
MessagePayloadTypeunknown
MessageParamsType{}
MessageResultTypevoid
PayloadSchemaextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> = ZodAny
ParameterSchemaextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> = ZodAny
ResultSchemaextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> = ZodAny
Invokes{}
EmitListType{}

Parameters

NameType
commandNamestring
commandDescriptionstring
eventName?string

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:135

Properties

autoacknowledge

Private autoacknowledge: boolean = true

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:72


commandDescription

Private commandDescription: string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:137


commandName

Private commandName: string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:136


deprecated

Private deprecated: boolean = false

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:61


durable

Private durable: boolean = false

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:71


emitList

Private emitList: EmitListType

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:79


errorStatusCodes

Private errorStatusCodes: StatusCode[] = []

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:65


eventName

Private Optional eventName: string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:138


fn

Private Optional fn: CommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? input<ResultSchema> : never> : never>>, Invokes, EmitListType>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:123


hooks

Private hooks: Object

Type declaration

NameType
afterGuardRecord<string, CommandAfterGuardHook<ServiceClassType, MessagePayloadType, MessageParamsType, Infer<ResultSchema>, Infer<PayloadSchema>, Infer<ParameterSchema>, Invokes, EmitListType>>
beforeGuardRecord<string, CommandBeforeGuardHook<ServiceClassType, MessagePayloadType, MessageParamsType, Infer<PayloadSchema>, Infer<ParameterSchema>, Invokes, EmitListType>>
transformInput?{ transformFunction: CommandTransformInputHook<ServiceClassType, any, any, any, any> ; transformInputSchema: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> ; transformParameterSchema: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> }
transformInput.transformFunctionCommandTransformInputHook<ServiceClassType, any, any, any, any>
transformInput.transformInputSchemaSchema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
transformInput.transformParameterSchemaSchema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
transformOutput?{ transformFunction: CommandTransformOutputHook<ServiceClassType, any, any, any, any, any> ; transformOutputSchema: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> }
transformOutput.transformFunctionCommandTransformOutputHook<ServiceClassType, any, any, any, any, any>
transformOutput.transformOutputSchemaSchema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:81


httpMetadata

Private Optional httpMetadata: Object

Type declaration

NameType
expose{ contentEncodingRequest?: string ; contentEncodingResponse?: string ; contentTypeRequest?: string ; contentTypeResponse?: string ; deprecated?: boolean ; inputPayload?: SchemaObject ; outputPayload?: SchemaObject ; parameter?: SchemaObject } & { http: { method: "GET" | "POST" | "PATCH" | "PUT" | "DELETE" ; openApi?: { additionalStatusCodes?: StatusCode[] ; description: string ; isSecure: boolean ; operationId?: string ; query?: QueryParameter<UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>[] ; summary: string ; tags?: string[] } ; path: string } }

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:49


inputContentEncoding

Private inputContentEncoding: undefined | string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:52


inputContentType

Private inputContentType: undefined | string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:51


inputSchema

Private Optional inputSchema: PayloadSchema

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:50


invokes

Private invokes: FromInvokeToOtherType<Invokes, { outputSchema?: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> ; parameterSchema?: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> ; payloadSchema?: Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any> }>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:74


isSecure

Private isSecure: boolean = true

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:67


operationId

Private Optional operationId: string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:69


outputContentEncoding

Private outputContentEncoding: undefined | string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:55


outputContentType

Private outputContentType: undefined | string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:54


outputSchema

Private Optional outputSchema: ResultSchema

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:53


parameterSchema

Private Optional parameterSchema: ParameterSchema

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:56


queryParameter

Private queryParameter: QueryParameter<UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>[] = []

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:57


summary

Private Optional summary: string

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:63


tags

Private tags: string[] = []

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:59

Methods

addOpenApiErrorStatusCodes

addOpenApiErrorStatusCodes(...codes): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

If a function can return other status codes, than the default ones, you should add them to openApi definition. Per default, 200, 204, 400, 401 and 500 can be autogenerated in most cases. Special cases or different status codes should be added with this function.

Parameters

NameTypeDescription
...codesStatusCode[]List of status codes

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Example

ts
addErrorStatusCodes(StatusCode.PaymentRequired, StatusCode.Conflict)

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:394


addOpenApiTags

addOpenApiTags(...tags): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Add tags for openApi definition for given function. It is recommended to use some enum for tags to avoid typo issues.

Parameters

NameTypeDescription
...tagsstring[]List of tag strings

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Example

ts
addTags('User','Public')

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:376


addOutputSchema

addOutputSchema<T>(outputSchema, outputContentType?, outputContentEncoding?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? output<T> : never> : never>>, PayloadSchema, ParameterSchema, T, Invokes, EmitListType>

Add a schema for output payload validation. Types for payload of message and function payload output are generated from given schema.

Type parameters

NameType
Textends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
outputSchemaTThe schema validation for output payload
outputContentType?stringoptional the content type of payload
outputContentEncoding?stringoptional the content encoding

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? output<T> : never> : never>>, PayloadSchema, ParameterSchema, T, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:290


addParameterSchema

addParameterSchema<T>(parameterSchema): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>, MessageResultType, PayloadSchema, T, ResultSchema, Invokes, EmitListType>

Add a schema for output parameter validation. Types for parameter of message and function parameter output are generated from given schema.

Type parameters

NameType
Textends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
parameterSchemaTThe schema validation for output parameter

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>, MessageResultType, PayloadSchema, T, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:322


addPayloadSchema

addPayloadSchema<T>(inputSchema, inputContentType?, inputContentEncoding?): CommandDefinitionBuilder<ServiceClassType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>, MessageParamsType, MessageResultType, T, ParameterSchema, ResultSchema, Invokes, EmitListType>

Add a schema for input payload validation. Types for payload of message and function payload input are generated from given schema.

Type parameters

NameType
Textends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
inputSchemaTThe schema validation for input payload
inputContentType?stringoptional the content type of payload
inputContentEncoding?stringoptional the content encoding

Returns

CommandDefinitionBuilder<ServiceClassType, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>, MessageParamsType, MessageResultType, T, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:265


addQueryParameters

addQueryParameters(...queryParams): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Define query parameters if you expose the function as http endpoint. Query parameters are add to openApi definition. Query parameters are add to input parameters.

Parameters

NameTypeDescription
...queryParamsQueryParameter<UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>[]Add one or more query parameter definitions

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Example

ts
.addQueryParameters(
  {
    required: false,
    name: 'search',
  },
  {
    required: false,
    name: 'limit',
  },
)

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:359


adviceAutoacknowledgeMessages

adviceAutoacknowledgeMessages(acknowledge?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Instruct the event bridge message broker to autoacknowledge commands as soon as they arrive. This means, a message will not be resent, if the command execution fails unexpected.

If set to false, the command message will be resent from message broker to eventbridge, if:

  • the underlaying message broker supports it
  • if the command execution fails unexpected
  • if sending of command response failed

Parameters

NameTypeDefault valueDescription
acknowledgebooleantrueEnable (true) and disable (false)

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinition

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:726


canEmit

canEmit<EventName, T>(eventName, schema): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType & Record<EventName, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>>>

Define which custom events the command can emit.

Type parameters

NameType
EventNameextends string
Textends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
eventNameEventNameThe custom event name
schemaTthe payload schema

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType & Record<EventName, UnknownIfNever<IfDefined<T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends never ? never : never | T extends Schema<any, any, any, ""> ? IfDefined<T extends Schema<any, any, any, ""> ? InferType<T> : never> : never | T extends ZodType<any, ZodTypeDef, any> ? IfDefined<T extends ZodType<any, ZodTypeDef, any> ? input<T> : never> : never>>>>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:226


canInvoke

canInvoke<Output, Payload, Parameter, SName, Version, Fname>(serviceName, serviceVersion, serviceTarget, outputSchema?, payloadSchema?, parameterSchema?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes & Record<SName, Record<Version, Record<Fname, (payload: UnknownIfNever<IfDefined<Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends Schema<any, any, any, ""> ? IfDefined<Payload extends Schema<any, any, any, ""> ? InferType<Payload> : never> : never | Payload extends ZodType<any, ZodTypeDef, any> ? IfDefined<Payload extends ZodType<any, ZodTypeDef, any> ? input<Payload> : never> : never>>, parameter: UnknownIfNever<IfDefined<Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends Schema<any, any, any, ""> ? IfDefined<Parameter extends Schema<any, any, any, ""> ? InferType<Parameter> : never> : never | Parameter extends ZodType<any, ZodTypeDef, any> ? IfDefined<Parameter extends ZodType<any, ZodTypeDef, any> ? input<Parameter> : never> : never>>) => Promise<UnknownIfNever<IfDefined<Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends Schema<any, any, any, ""> ? IfDefined<Output extends Schema<any, any, any, ""> ? InferType<Output> : never> : never | Output extends ZodType<any, ZodTypeDef, any> ? IfDefined<Output extends ZodType<any, ZodTypeDef, any> ? output<Output> : never> : never>>>>>>, EmitListType>

Define a command which can be invoked by the current command

Type parameters

NameType
Outputextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
Payloadextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
Parameterextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
SNameextends string = string
Versionextends string = string
Fnameextends string = string

Parameters

NameType
serviceNameSName
serviceVersionVersion
serviceTargetFname
outputSchema?Output
payloadSchema?Payload
parameterSchema?Parameter

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes & Record<SName, Record<Version, Record<Fname, (payload: UnknownIfNever<IfDefined<Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends never ? never : never | Payload extends Schema<any, any, any, ""> ? IfDefined<Payload extends Schema<any, any, any, ""> ? InferType<Payload> : never> : never | Payload extends ZodType<any, ZodTypeDef, any> ? IfDefined<Payload extends ZodType<any, ZodTypeDef, any> ? input<Payload> : never> : never>>, parameter: UnknownIfNever<IfDefined<Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends never ? never : never | Parameter extends Schema<any, any, any, ""> ? IfDefined<Parameter extends Schema<any, any, any, ""> ? InferType<Parameter> : never> : never | Parameter extends ZodType<any, ZodTypeDef, any> ? IfDefined<Parameter extends ZodType<any, ZodTypeDef, any> ? input<Parameter> : never> : never>>) => Promise<UnknownIfNever<IfDefined<Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends Schema<any, any, any, ""> ? IfDefined<Output extends Schema<any, any, any, ""> ? InferType<Output> : never> : never | Output extends ZodType<any, ZodTypeDef, any> ? IfDefined<Output extends ZodType<any, ZodTypeDef, any> ? output<Output> : never> : never>>>>>>, EmitListType>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:151


disableHttpSecurity

disableHttpSecurity(disabled?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

enable or disable security for this endpoint

Parameters

NameTypeDefault value
disabledbooleantrue

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:626


enableHttpSecurity

enableHttpSecurity(enabled?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

enable or disable security for this endpoint

Parameters

NameTypeDefault valueDescription
enabledbooleantrueDefaults to true if not set means "enable security"

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:616


exposeAsHttpEndpoint

exposeAsHttpEndpoint(method, path, contentTypeRequest?, contentEncodingRequest?, contentTypeResponse?, contentEncodingResponse?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Mark the function to be exposed as http endpoint.

Api url prefix and service version are prepended automatically

For exposing a url like: /api/V1/user/login simply provide user/loginas path

Parameters

NameTypeDescription
methodSupportedHttpMethodHttp method POST, PUT, PATCH, GET, DELETE
pathstringThe url path
contentTypeRequest?stringinput content type defaults to application/json
contentEncodingRequest?stringinput content encoding defaults to utf-8
contentTypeResponse?stringinput content type defaults to application/json
contentEncodingResponse?stringinput content encoding defaults to utf-8

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:588


extendWithHttpMetadata

extendWithHttpMetadata(definition): Complete<CommandDefinition<ServiceClassType, CommandDefinitionMetadataBase, MessagePayloadType, MessageParamsType, MessageResultType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, Invokes, EmitListType>>

Parameters

NameType
definitionComplete<CommandDefinition<ServiceClassType, CommandDefinitionMetadataBase, MessagePayloadType, MessageParamsType, MessageResultType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, Invokes, EmitListType>>

Returns

Complete<CommandDefinition<ServiceClassType, CommandDefinitionMetadataBase, MessagePayloadType, MessageParamsType, MessageResultType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, Invokes, EmitListType>>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:657


getCommandContextMock

getCommandContextMock(payload, parameter, sandbox?): Object

Returns a mocked command function context, which can be used in unit tests.

Parameters

NameTypeDescription
payloadMessagePayloadType-
parameterMessageParamsType-
sandbox?SinonSandboxSinon sandbox

Returns

Object

a mocked command function context

NameType
mock{ configs: { getConfig: ConfigGetterFunction ; removeConfig: ConfigDeleteFunction ; setConfig: ConfigSetterFunction } ; emit: EmitCustomMessageFunction<EmitListType> ; invoke: InvokeFunction ; logger: Logger ; message: Readonly<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: MessageParamsType ; payload: MessagePayloadType } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }> ; secrets: { getSecret: SecretGetterFunction ; removeSecret: SecretDeleteFunction ; setSecret: SecretSetterFunction } ; service: Invokes ; startActiveSpan: <F>(name: string, opts: SpanOptions, context: undefined | Context, fn: (span: Span) => Promise<F>) => Promise<F> ; states: { getState: StateGetterFunction ; removeState: StateDeleteFunction ; setState: StateSetterFunction } ; wrapInSpan: <F>(name: string, opts: SpanOptions, fn: (span: Span) => Promise<F>, context?: Context) => Promise<F> }
mock.configs{ getConfig: ConfigGetterFunction ; removeConfig: ConfigDeleteFunction ; setConfig: ConfigSetterFunction }
mock.configs.getConfigConfigGetterFunction
mock.configs.removeConfigConfigDeleteFunction
mock.configs.setConfigConfigSetterFunction
mock.emitEmitCustomMessageFunction<EmitListType>
mock.invokeInvokeFunction
mock.loggerLogger
mock.messageReadonly<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: MessageParamsType ; payload: MessagePayloadType } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }>
mock.secrets{ getSecret: SecretGetterFunction ; removeSecret: SecretDeleteFunction ; setSecret: SecretSetterFunction }
mock.secrets.getSecretSecretGetterFunction
mock.secrets.removeSecretSecretDeleteFunction
mock.secrets.setSecretSecretSetterFunction
mock.serviceInvokes
mock.startActiveSpan<F>(name: string, opts: SpanOptions, context: undefined | Context, fn: (span: Span) => Promise<F>) => Promise<F>
mock.states{ getState: StateGetterFunction ; removeState: StateDeleteFunction ; setState: StateSetterFunction }
mock.states.getStateStateGetterFunction
mock.states.removeStateStateDeleteFunction
mock.states.setStateStateSetterFunction
mock.wrapInSpan<F>(name: string, opts: SpanOptions, fn: (span: Span) => Promise<F>, context?: Context) => Promise<F>
stubs{ emit: FromEmitToOtherType<EmitListType, SinonStub<any[], any>> = eventList; getConfig: SinonStub<any[], any> ; getSecret: SinonStub<any[], any> ; getState: SinonStub<any[], any> ; invoke: SinonStub<any[], any> ; logger: { debug: SinonStub<any[], any> ; error: SinonStub<any[], any> ; fatal: SinonStub<any[], any> ; info: SinonStub<any[], any> ; trace: SinonStub<any[], any> ; warn: SinonStub<any[], any> } = logger.stubs; removeConfig: SinonStub<any[], any> ; removeSecret: SinonStub<any[], any> ; removeState: SinonStub<any[], any> ; service: FromInvokeToOtherType<Invokes, SinonStub<any[], any>> ; setConfig: SinonStub<any[], any> ; setSecret: SinonStub<any[], any> ; setState: SinonStub<any[], any> ; startActiveSpan: SinonStub<any[], any> ; wrapInSpan: SinonStub<any[], any> }
stubs.emitFromEmitToOtherType<EmitListType, SinonStub<any[], any>>
stubs.getConfigSinonStub<any[], any>
stubs.getSecretSinonStub<any[], any>
stubs.getStateSinonStub<any[], any>
stubs.invokeSinonStub<any[], any>
stubs.logger{ debug: SinonStub<any[], any> ; error: SinonStub<any[], any> ; fatal: SinonStub<any[], any> ; info: SinonStub<any[], any> ; trace: SinonStub<any[], any> ; warn: SinonStub<any[], any> }
stubs.logger.debugSinonStub<any[], any>
stubs.logger.errorSinonStub<any[], any>
stubs.logger.fatalSinonStub<any[], any>
stubs.logger.infoSinonStub<any[], any>
stubs.logger.traceSinonStub<any[], any>
stubs.logger.warnSinonStub<any[], any>
stubs.removeConfigSinonStub<any[], any>
stubs.removeSecretSinonStub<any[], any>
stubs.removeStateSinonStub<any[], any>
stubs.serviceFromInvokeToOtherType<Invokes, SinonStub<any[], any>>
stubs.setConfigSinonStub<any[], any>
stubs.setSecretSinonStub<any[], any>
stubs.setStateSinonStub<any[], any>
stubs.startActiveSpanSinonStub<any[], any>
stubs.wrapInSpanSinonStub<any[], any>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:940


getCommandFunction

getCommandFunction(): CommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, Invokes, EmitListType>

Get the function implementation including input and output validation. Also, before and after hooks are triggered during execution.

Returns

CommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, Invokes, EmitListType>

the function

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:880


getCommandFunctionPlain

getCommandFunctionPlain(): CommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, Infer<PayloadSchema>, Infer<ParameterSchema>, InferIn<ResultSchema>, Invokes, EmitListType>

Get the function implementation without input and output validation. No hooks are triggered during execution.

Returns

CommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, Infer<PayloadSchema>, Infer<ParameterSchema>, InferIn<ResultSchema>, Invokes, EmitListType>

the function

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:913


getCommandTransformContextMock

getCommandTransformContextMock(payload, parameter, sandbox?): Object

Returns a mocked transform function context, which can be used in unit tests.

Parameters

NameTypeDescription
payloadMessagePayloadType-
parameterMessageParamsType-
sandbox?SinonSandboxSinon sandbox

Returns

Object

a mocked transform function context

NameType
mock{ configs: { getConfig: ConfigGetterFunction ; removeConfig: ConfigDeleteFunction ; setConfig: ConfigSetterFunction } ; logger: Logger ; message: Readonly<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: MessageParamsType ; payload: MessagePayloadType } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }> ; secrets: { getSecret: SecretGetterFunction ; removeSecret: SecretDeleteFunction ; setSecret: SecretSetterFunction } ; startActiveSpan: <F>(name: string, opts: SpanOptions, context: undefined | Context, fn: (span: Span) => Promise<F>) => Promise<F> ; states: { getState: StateGetterFunction ; removeState: StateDeleteFunction ; setState: StateSetterFunction } ; wrapInSpan: <F>(name: string, opts: SpanOptions, fn: (span: Span) => Promise<F>, context?: Context) => Promise<F> }
mock.configs{ getConfig: ConfigGetterFunction ; removeConfig: ConfigDeleteFunction ; setConfig: ConfigSetterFunction }
mock.configs.getConfigConfigGetterFunction
mock.configs.removeConfigConfigDeleteFunction
mock.configs.setConfigConfigSetterFunction
mock.loggerLogger
mock.messageReadonly<{ contentEncoding: string ; contentType: string ; correlationId: string ; eventName?: string ; id: string ; messageType: Command ; otp?: string ; payload: { parameter: MessageParamsType ; payload: MessagePayloadType } ; principalId?: string ; receiver: EBMessageAddress ; sender: { instanceId: string ; serviceName: string ; serviceTarget: string ; serviceVersion: string } ; tenantId?: string ; timestamp: number ; traceId?: string }>
mock.secrets{ getSecret: SecretGetterFunction ; removeSecret: SecretDeleteFunction ; setSecret: SecretSetterFunction }
mock.secrets.getSecretSecretGetterFunction
mock.secrets.removeSecretSecretDeleteFunction
mock.secrets.setSecretSecretSetterFunction
mock.startActiveSpan<F>(name: string, opts: SpanOptions, context: undefined | Context, fn: (span: Span) => Promise<F>) => Promise<F>
mock.states{ getState: StateGetterFunction ; removeState: StateDeleteFunction ; setState: StateSetterFunction }
mock.states.getStateStateGetterFunction
mock.states.removeStateStateDeleteFunction
mock.states.setStateStateSetterFunction
mock.wrapInSpan<F>(name: string, opts: SpanOptions, fn: (span: Span) => Promise<F>, context?: Context) => Promise<F>
stubs{ getConfig: SinonStub<any[], any> ; getSecret: SinonStub<any[], any> ; getState: SinonStub<any[], any> ; logger: { debug: SinonStub<any[], any> ; error: SinonStub<any[], any> ; fatal: SinonStub<any[], any> ; info: SinonStub<any[], any> ; trace: SinonStub<any[], any> ; warn: SinonStub<any[], any> } = logger.stubs; removeConfig: SinonStub<any[], any> ; removeSecret: SinonStub<any[], any> ; removeState: SinonStub<any[], any> ; setConfig: SinonStub<any[], any> ; setSecret: SinonStub<any[], any> ; setState: SinonStub<any[], any> ; startActiveSpan: SinonStub<any[], any> ; wrapInSpan: SinonStub<any[], any> }
stubs.getConfigSinonStub<any[], any>
stubs.getSecretSinonStub<any[], any>
stubs.getStateSinonStub<any[], any>
stubs.logger{ debug: SinonStub<any[], any> ; error: SinonStub<any[], any> ; fatal: SinonStub<any[], any> ; info: SinonStub<any[], any> ; trace: SinonStub<any[], any> ; warn: SinonStub<any[], any> }
stubs.logger.debugSinonStub<any[], any>
stubs.logger.errorSinonStub<any[], any>
stubs.logger.fatalSinonStub<any[], any>
stubs.logger.infoSinonStub<any[], any>
stubs.logger.traceSinonStub<any[], any>
stubs.logger.warnSinonStub<any[], any>
stubs.removeConfigSinonStub<any[], any>
stubs.removeSecretSinonStub<any[], any>
stubs.removeStateSinonStub<any[], any>
stubs.setConfigSinonStub<any[], any>
stubs.setSecretSinonStub<any[], any>
stubs.setStateSinonStub<any[], any>
stubs.startActiveSpanSinonStub<any[], any>
stubs.wrapInSpanSinonStub<any[], any>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:957


getDefinition

getDefinition(): Promise<CommandDefinition<ServiceClassType, CommandDefinitionMetadataBase, MessagePayloadType, MessageParamsType, MessageResultType, Infer<PayloadSchema>, Infer<ParameterSchema>, Infer<ResultSchema>, Invokes, EmitListType>>

Creates and returns the CommandDefinition used as input for the service.

Returns

Promise<CommandDefinition<ServiceClassType, CommandDefinitionMetadataBase, MessagePayloadType, MessageParamsType, MessageResultType, Infer<PayloadSchema>, Infer<ParameterSchema>, Infer<ResultSchema>, Invokes, EmitListType>>

CommandDefinition

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:735


getTransformInputFunction

getTransformInputFunction(): undefined | CommandTransformInputHook<ServiceClassType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<ParameterSchema> : never> : never>>, MessagePayloadType, MessageParamsType>

Return the transform input function

Returns

undefined | CommandTransformInputHook<ServiceClassType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<ParameterSchema> : never> : never>>, MessagePayloadType, MessageParamsType>

the input transform function if defined

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:448


getTransformOutputFunction

getTransformOutputFunction(): undefined | CommandTransformOutputHook<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>

Return the transform output function

Returns

undefined | CommandTransformOutputHook<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>

the transform output function if defined

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:509


markAsDeprecated

markAsDeprecated(): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Mark this endpoint/command as deprecated

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:311


setAfterGuardHooks

setAfterGuardHooks(afterGuards): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set one or more after guard hook(s). If there are multiple after guard hooks, they are executed in parallel

Parameters

NameType
afterGuardsRecord<string, CommandAfterGuardHook<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, Invokes, EmitListType>>

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:554


setBeforeGuardHooks

setBeforeGuardHooks(beforeGuards): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set one or more before guard hook(s). If there are multiple before guard hooks, they are executed in parallel

Parameters

NameTypeDescription
beforeGuardsRecord<string, CommandBeforeGuardHook<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>, Invokes, EmitListType>>Object of key = name of guard, value = function

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:530


setCommandFunction

setCommandFunction(fn): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Required: Set the function implementation. The types should be automatically set as soon as schemas previously defined. As the function will be a a function of a service class you need to implement as function declaration. Anonymous functions do not have access to the this scope.

Parameters

NameTypeDescription
fnCommandFunction<ServiceClassType, MessagePayloadType, MessageParamsType, Infer<PayloadSchema>, Infer<ParameterSchema>, InferIn<ResultSchema>, Invokes, EmitListType>the function implementation

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Example

ts
async function (context, payload, parameter) {

   return `the result output payload`
}

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:828


setOpenApiOperationId

setOpenApiOperationId(operationId): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set the operationId for openApi documentation

Parameters

NameType
operationIdstring

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:652


setOpenApiSummary

setOpenApiSummary(summary): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set the function summary text used for example in openApi documentation

Parameters

NameTypeDescription
summarystringSummary text

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Example

ts
setSummary('Some function summary')

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:642


setSuccessEventName

setSuccessEventName<N>(eventName): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Type parameters

NameType
Nextends string

Parameters

NameType
eventNameNonEmptyString<N>

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:252


setTransformInput

setTransformInput<TransFormPayloadSchema, TransFormParameterSchema>(transformInputSchema, transformParameterSchema, transformFunction, inputContentType?, inputContentEncoding?): CommandDefinitionBuilder<ServiceClassType, UnknownIfNever<IfDefined<TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormPayloadSchema extends Schema<any, any, any, ""> ? InferType<TransFormPayloadSchema> : never> : never | TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<TransFormPayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormParameterSchema extends Schema<any, any, any, ""> ? InferType<TransFormParameterSchema> : never> : never | TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<TransFormParameterSchema> : never> : never>>, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set a transform input hook which will encode or transform the input payload and parameters. Will be executed as first step before input validation, before guard and the function itself. This will change the type of input message payload and input message parameter.

Type parameters

NameType
TransFormPayloadSchemaextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>
TransFormParameterSchemaextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
transformInputSchemaTransFormPayloadSchemaInput payload validation schema
transformParameterSchemaTransFormParameterSchemaInput parameter validation schema
transformFunctionCommandTransformInputHook<ServiceClassType, UnknownIfNever<IfDefined<PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends never ? never : never | PayloadSchema extends Schema<any, any, any, ""> ? IfDefined<PayloadSchema extends Schema<any, any, any, ""> ? InferType<PayloadSchema> : never> : never | PayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<PayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<PayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<ParameterSchema> : never> : never>>, UnknownIfNever<IfDefined<TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormPayloadSchema extends Schema<any, any, any, ""> ? InferType<TransFormPayloadSchema> : never> : never | TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? output<TransFormPayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormParameterSchema extends Schema<any, any, any, ""> ? InferType<TransFormParameterSchema> : never> : never | TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<TransFormParameterSchema> : never> : never>>>Transform input function
inputContentType?stringoptional the content type of payload
inputContentEncoding?stringoptional the content encoding

Returns

CommandDefinitionBuilder<ServiceClassType, UnknownIfNever<IfDefined<TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends never ? never : never | TransFormPayloadSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormPayloadSchema extends Schema<any, any, any, ""> ? InferType<TransFormPayloadSchema> : never> : never | TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormPayloadSchema extends ZodType<any, ZodTypeDef, any> ? input<TransFormPayloadSchema> : never> : never>>, UnknownIfNever<IfDefined<TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends never ? never : never | TransFormParameterSchema extends Schema<any, any, any, ""> ? IfDefined<TransFormParameterSchema extends Schema<any, any, any, ""> ? InferType<TransFormParameterSchema> : never> : never | TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<TransFormParameterSchema extends ZodType<any, ZodTypeDef, any> ? input<TransFormParameterSchema> : never> : never>>, MessageResultType, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:410


setTransformOutput

setTransformOutput<Output>(transformOutputSchema, transformFunction, outputContentType?, outputContentEncoding?): CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends Schema<any, any, any, ""> ? IfDefined<Output extends Schema<any, any, any, ""> ? InferType<Output> : never> : never | Output extends ZodType<any, ZodTypeDef, any> ? IfDefined<Output extends ZodType<any, ZodTypeDef, any> ? output<Output> : never> : never>>, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

Set a transform output hook which will encode or transform the response payload. Will be executed at very last step after function execution, output validation and after guard hooks. This will change the type of output message payload.

Type parameters

NameType
Outputextends Schema<any, any, any, ""> | ZodType<any, ZodTypeDef, any>

Parameters

NameTypeDescription
transformOutputSchemaOutputThe output validation schema
transformFunctionCommandTransformOutputHook<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends Schema<any, any, any, ""> ? IfDefined<Output extends Schema<any, any, any, ""> ? InferType<Output> : never> : never | Output extends ZodType<any, ZodTypeDef, any> ? IfDefined<Output extends ZodType<any, ZodTypeDef, any> ? input<Output> : never> : never>>, UnknownIfNever<IfDefined<ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends never ? never : never | ResultSchema extends Schema<any, any, any, ""> ? IfDefined<ResultSchema extends Schema<any, any, any, ""> ? InferType<ResultSchema> : never> : never | ResultSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ResultSchema extends ZodType<any, ZodTypeDef, any> ? output<ResultSchema> : never> : never>>, UnknownIfNever<IfDefined<ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends never ? never : never | ParameterSchema extends Schema<any, any, any, ""> ? IfDefined<ParameterSchema extends Schema<any, any, any, ""> ? InferType<ParameterSchema> : never> : never | ParameterSchema extends ZodType<any, ZodTypeDef, any> ? IfDefined<ParameterSchema extends ZodType<any, ZodTypeDef, any> ? output<ParameterSchema> : never> : never>>>Transform output function
outputContentType?stringoptional the content type of payload
outputContentEncoding?stringoptional the content encoding

Returns

CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, UnknownIfNever<IfDefined<Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends never ? never : never | Output extends Schema<any, any, any, ""> ? IfDefined<Output extends Schema<any, any, any, ""> ? InferType<Output> : never> : never | Output extends ZodType<any, ZodTypeDef, any> ? IfDefined<Output extends ZodType<any, ZodTypeDef, any> ? output<Output> : never> : never>>, PayloadSchema, ParameterSchema, ResultSchema, Invokes, EmitListType>

CommandDefinitionBuilder

Defined in

CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:472