Class: CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, FunctionPayloadType, FunctionParamsType, FunctionResultType>
PURISTA API / Modules / @purista/core / CommandDefinitionBuilder
Class: CommandDefinitionBuilder<ServiceClassType, MessagePayloadType, MessageParamsType, MessageResultType, FunctionPayloadType, FunctionParamsType, FunctionResultType>
@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
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | undefined |
MessageResultType | void |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | MessageResultType |
Table of contents
Constructors
Properties
- autoacknowledge
- commandDescription
- commandName
- deprecated
- durable
- errorStatusCodes
- eventName
- fn
- hooks
- httpMetadata
- inputContentEncoding
- inputContentType
- inputSchema
- isSecure
- operationId
- outputContentEncoding
- outputContentType
- outputSchema
- parameterSchema
- queryParameter
- summary
- tags
Methods
- addOpenApiErrorStatusCodes
- addOpenApiTags
- addOutputSchema
- addParameterSchema
- addPayloadSchema
- addQueryParameters
- adviceAutoacknowledgeMessages
- disableHttpSecurity
- enableHttpSecurity
- exposeAsHttpEndpoint
- extendWithHttpMetadata
- getCommandFunction
- getDefinition
- getTransformInputFunction
- getTransformOutputFunction
- markAsDeprecated
- setAfterGuardHooks
- setBeforeGuardHooks
- setCommandFunction
- setOpenApiOperationId
- setOpenApiSummary
- setSuccessEventName
- setTransformInput
- setTransformOutput
Constructors
constructor
• new CommandDefinitionBuilder<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>(commandName
, commandDescription
, eventName?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass <unknown > |
MessagePayloadType | unknown |
MessageParamsType | undefined |
MessageResultType | void |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | MessageResultType |
Parameters
Name | Type |
---|---|
commandName | string |
commandDescription | string |
eventName? | string |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:113
Properties
autoacknowledge
• Private
autoacknowledge: boolean
= true
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:63
commandDescription
• Private
commandDescription: string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:115
commandName
• Private
commandName: string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:114
deprecated
• Private
deprecated: boolean
= false
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:52
durable
• Private
durable: boolean
= false
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:62
errorStatusCodes
• Private
errorStatusCodes: StatusCode
[] = []
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:56
eventName
• Private
Optional
eventName: string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:116
fn
• Private
Optional
fn: CommandFunction
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:103
hooks
• Private
hooks: Object
Type declaration
Name | Type |
---|---|
afterGuard | Record <string , CommandAfterGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionResultType , FunctionPayloadType , FunctionParamsType >> |
beforeGuard | Record <string , CommandBeforeGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType >> |
transformInput? | { transformFunction : CommandTransformInputHook <ServiceClassType , any , any , any , any > ; transformInputSchema : ZodType <any , ZodTypeDef , any > ; transformParameterSchema : ZodType <any , ZodTypeDef , any > } |
transformInput.transformFunction | CommandTransformInputHook <ServiceClassType , any , any , any , any > |
transformInput.transformInputSchema | ZodType <any , ZodTypeDef , any > |
transformInput.transformParameterSchema | ZodType <any , ZodTypeDef , any > |
transformOutput? | { transformFunction : CommandTransformOutputHook <ServiceClassType , any , any , FunctionParamsType , any > ; transformOutputSchema : ZodType <any , ZodTypeDef , any > } |
transformOutput.transformFunction | CommandTransformOutputHook <ServiceClassType , any , any , FunctionParamsType , any > |
transformOutput.transformOutputSchema | ZodType <any , ZodTypeDef , any > |
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:65
httpMetadata
• Private
Optional
httpMetadata: Object
Type declaration
Name | Type |
---|---|
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 <FunctionParamsType >[] ; summary : string ; tags? : string [] } ; path : string } } |
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:40
inputContentEncoding
• Private
inputContentEncoding: undefined
| string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:43
inputContentType
• Private
inputContentType: undefined
| string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:42
inputSchema
• Private
Optional
inputSchema: ZodType
<any
, ZodTypeDef
, any
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:41
isSecure
• Private
isSecure: boolean
= true
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:58
operationId
• Private
Optional
operationId: string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:60
outputContentEncoding
• Private
outputContentEncoding: undefined
| string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:46
outputContentType
• Private
outputContentType: undefined
| string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:45
outputSchema
• Private
Optional
outputSchema: ZodType
<any
, ZodTypeDef
, any
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:44
parameterSchema
• Private
Optional
parameterSchema: ZodType
<any
, ZodTypeDef
, any
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:47
queryParameter
• Private
queryParameter: QueryParameter
<FunctionParamsType
>[] = []
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:48
summary
• Private
Optional
summary: string
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:54
tags
• Private
tags: string
[] = []
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:50
Methods
addOpenApiErrorStatusCodes
▸ addOpenApiErrorStatusCodes(...codes
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type | Description |
---|---|---|
...codes | StatusCode [] | List of status codes |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Example
addErrorStatusCodes(StatusCode.PaymentRequired, StatusCode.Conflict)
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:269
addOpenApiTags
▸ addOpenApiTags(...tags
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Add tags for openApi definition for given function. It is recommended to use some enum for tags to avoid typo issues.
Parameters
Name | Type | Description |
---|---|---|
...tags | string [] | List of tag strings |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Example
addTags('User','Public')
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:251
addOutputSchema
▸ addOutputSchema<I
, D
, O
>(outputSchema
, outputContentType?
, outputContentEncoding?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, O
, FunctionPayloadType
, FunctionParamsType
, I
>
Add a schema for output payload validation. Types for payload of message and function payload output are generated from given schema.
Type parameters
Name | Type |
---|---|
I | I |
D | extends ZodTypeDef |
O | O |
Parameters
Name | Type | Description |
---|---|---|
outputSchema | ZodType <O , D , I > | The schema validation for output payload |
outputContentType? | string | optional the content type of payload |
outputContentEncoding? | string | optional the content encoding |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, O
, FunctionPayloadType
, FunctionParamsType
, I
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:165
addParameterSchema
▸ addParameterSchema<I
, D
, O
>(parameterSchema
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, I
, MessageResultType
, FunctionPayloadType
, O
, FunctionResultType
>
Add a schema for output parameter validation. Types for parameter of message and function parameter output are generated from given schema.
Type parameters
Name | Type |
---|---|
I | I |
D | extends ZodTypeDef |
O | O |
Parameters
Name | Type | Description |
---|---|---|
parameterSchema | ZodType <O , D , I > | The schema validation for output parameter |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, I
, MessageResultType
, FunctionPayloadType
, O
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:199
addPayloadSchema
▸ addPayloadSchema<I
, D
, O
>(inputSchema
, inputContentType?
, inputContentEncoding?
): CommandDefinitionBuilder
<ServiceClassType
, I
, MessageParamsType
, MessageResultType
, O
, FunctionParamsType
, FunctionResultType
>
Add a schema for input payload validation. Types for payload of message and function payload input are generated from given schema.
Type parameters
Name | Type |
---|---|
I | unknown |
D | extends ZodTypeDef = ZodTypeDef |
O | unknown |
Parameters
Name | Type | Description |
---|---|---|
inputSchema | ZodType <O , D , I > | The schema validation for input payload |
inputContentType? | string | optional the content type of payload |
inputContentEncoding? | string | optional the content encoding |
Returns
CommandDefinitionBuilder
<ServiceClassType
, I
, MessageParamsType
, MessageResultType
, O
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:138
addQueryParameters
▸ addQueryParameters(...queryParams
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type | Description |
---|---|---|
...queryParams | QueryParameter <FunctionParamsType >[] | Add one or more query parameter definitions |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Example
.addQueryParameters(
{
required: false,
name: 'search',
},
{
required: false,
name: 'limit',
},
)
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:234
adviceAutoacknowledgeMessages
▸ adviceAutoacknowledgeMessages(acknowledge?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type | Default value | Description |
---|---|---|---|
acknowledge | boolean | true | Enable (true) and disable (false) |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinition
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:593
disableHttpSecurity
▸ disableHttpSecurity(disabled?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
enable or disable security for this endpoint
Parameters
Name | Type | Default value |
---|---|---|
disabled | boolean | true |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:497
enableHttpSecurity
▸ enableHttpSecurity(enabled?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
enable or disable security for this endpoint
Parameters
Name | Type | Default value | Description |
---|---|---|---|
enabled | boolean | true | Defaults to true if not set means "enable security" |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:487
exposeAsHttpEndpoint
▸ exposeAsHttpEndpoint(method
, path
, contentTypeRequest?
, contentEncodingRequest?
, contentTypeResponse?
, contentEncodingResponse?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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/login
as path
Parameters
Name | Type | Description |
---|---|---|
method | SupportedHttpMethod | Http method POST, PUT, PATCH, GET, DELETE |
path | string | The url path |
contentTypeRequest? | string | input content type defaults to application/json |
contentEncodingRequest? | string | input content encoding defaults to utf-8 |
contentTypeResponse? | string | input content type defaults to application/json |
contentEncodingResponse? | string | input content encoding defaults to utf-8 |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:459
extendWithHttpMetadata
▸ extendWithHttpMetadata(definition
): Complete
<CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>>
Parameters
Name | Type |
---|---|
definition | Complete <CommandDefinition <ServiceClassType , CommandDefinitionMetadataBase , MessagePayloadType , MessageParamsType , MessageResultType , FunctionPayloadType , FunctionParamsType , FunctionResultType >> |
Returns
Complete
<CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:528
getCommandFunction
▸ getCommandFunction(): CommandFunction
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Get the function implementation
Returns
CommandFunction
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
the function
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:735
getDefinition
▸ getDefinition(): CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Creates and returns the CommandDefinition used as input for the service.
Returns
CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinition
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:602
getTransformInputFunction
▸ getTransformInputFunction(): undefined
| CommandTransformInputHook
<ServiceClassType
, FunctionPayloadType
, FunctionParamsType
, MessagePayloadType
, MessageParamsType
>
Return the transform input function
Returns
undefined
| CommandTransformInputHook
<ServiceClassType
, FunctionPayloadType
, FunctionParamsType
, MessagePayloadType
, MessageParamsType
>
the input transform function if defined
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:328
getTransformOutputFunction
▸ getTransformOutputFunction(): undefined
| CommandTransformOutputHook
<ServiceClassType
, MessagePayloadType
, FunctionResultType
, FunctionParamsType
, MessageResultType
>
Return the transform output function
Returns
undefined
| CommandTransformOutputHook
<ServiceClassType
, MessagePayloadType
, FunctionResultType
, FunctionParamsType
, MessageResultType
>
the transform output function if defined
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:385
markAsDeprecated
▸ markAsDeprecated(): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Mark this endpoint/command as deprecated
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:188
setAfterGuardHooks
▸ setAfterGuardHooks(afterGuards
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Set one or more after guard hook(s). If there are multiple after guard hooks, they are executed in parallel
Parameters
Name | Type |
---|---|
afterGuards | Record <string , CommandAfterGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionResultType , FunctionPayloadType , FunctionParamsType >> |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:427
setBeforeGuardHooks
▸ setBeforeGuardHooks(beforeGuards
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Set one or more before guard hook(s). If there are multiple before guard hooks, they are executed in parallel
Parameters
Name | Type | Description |
---|---|---|
beforeGuards | Record <string , CommandBeforeGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType >> | Object of key = name of guard, value = function |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:405
setCommandFunction
▸ setCommandFunction(fn
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type | Description |
---|---|---|
fn | CommandFunction <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType , FunctionResultType > | the function implementation |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Example
async function (context, payload, parameter) {
return `the result output payload`
}
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:693
setOpenApiOperationId
▸ setOpenApiOperationId(operationId
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Set the operationId for openApi documentation
Parameters
Name | Type |
---|---|
operationId | string |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:523
setOpenApiSummary
▸ setOpenApiSummary(summary
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Set the function summary text used for example in openApi documentation
Parameters
Name | Type | Description |
---|---|---|
summary | string | Summary text |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Example
setSummary('Some function summary')
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:513
setSuccessEventName
▸ setSuccessEventName(eventName
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Parameters
Name | Type |
---|---|
eventName | string |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:125
setTransformInput
▸ setTransformInput<PayloadIn
, ParamsIn
, PayloadOut
, ParamsOut
, PayloadD
, ParamsD
>(transformInputSchema
, transformParameterSchema
, transformFunction
, inputContentType?
, inputContentEncoding?
): CommandDefinitionBuilder
<ServiceClassType
, PayloadIn
, ParamsIn
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type |
---|---|
PayloadIn | MessagePayloadType |
ParamsIn | MessageParamsType |
PayloadOut | MessagePayloadType |
ParamsOut | MessageParamsType |
PayloadD | extends ZodTypeDef = ZodTypeDef |
ParamsD | extends ZodTypeDef = ZodTypeDef |
Parameters
Name | Type | Description |
---|---|---|
transformInputSchema | ZodType <PayloadOut , PayloadD , PayloadIn > | Input payload validation schema |
transformParameterSchema | ZodType <ParamsOut , ParamsD , ParamsIn > | Input parameter validation schema |
transformFunction | CommandTransformInputHook <ServiceClassType , FunctionPayloadType , FunctionParamsType , PayloadIn , ParamsIn > | Transform input function |
inputContentType? | string | optional the content type of payload |
inputContentEncoding? | string | optional the content encoding |
Returns
CommandDefinitionBuilder
<ServiceClassType
, PayloadIn
, ParamsIn
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:285
setTransformOutput
▸ setTransformOutput<PayloadOut
, PayloadD
, PayloadIn
>(transformOutputSchema
, transformFunction
, outputContentType?
, outputContentEncoding?
): CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, PayloadOut
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
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
Name | Type |
---|---|
PayloadOut | PayloadOut |
PayloadD | extends ZodTypeDef |
PayloadIn | PayloadIn |
Parameters
Name | Type | Description |
---|---|---|
transformOutputSchema | ZodType <PayloadOut , PayloadD , PayloadIn > | The output validation schema |
transformFunction | CommandTransformOutputHook <ServiceClassType , MessagePayloadType , FunctionResultType , FunctionParamsType , PayloadIn > | Transform output function |
outputContentType? | string | optional the content type of payload |
outputContentEncoding? | string | optional the content encoding |
Returns
CommandDefinitionBuilder
<ServiceClassType
, MessagePayloadType
, MessageParamsType
, PayloadOut
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
>
CommandDefinitionBuilder
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:352