PURISTA API / Modules / @purista/core
Module: @purista/core
This is the main package of PURISTA.
A backend framework for building message based domain services.
This framework adapts and combines a wide range of different patters from domain driven design, cqrs, microservice, event sourcing and lambda functions.
It is build from ground up in typescript and highly focuses on schema, and auto generation of types, input-output-validation, OpenApi documentation (swagger).
It contains the builders, classes & types and some helper functions. For easier testing of commands and subscriptions, the package contains different mock creation helper based on sinon
Learn PURIST at purista.dev
Table of contents
Enumerations
Classes
Interfaces
Type Aliases
- AuthCredentials
- BrokerHeaderCommandMsg
- BrokerHeaderCommandResponseMsg
- BrokerHeaderCustomMsg
- Command
- CommandDefinitionList
- CommandDefinitionListResolved
- CommandDefinitionMetadataBase
- Complete
- CompressionMethod
- ConfigStoreCacheMap
- ContentType
- ContextBase
- CorrelationId
- CustomMessage
- DefaultConfigStoreConfig
- DefaultEventBridgeConfig
- DefaultSecretStoreConfig
- DefaultStateStoreConfig
- DefinitionEventBridgeConfig
- EBMessage
- EBMessageAddress
- EBMessageBase
- EBMessageId
- EBMessageSenderAddress
- EmitCustomMessageFunction
- EmitSchemaList
- ErrorResponsePayload
- EventBridgeAdapterEvents
- EventBridgeConfig
- EventBridgeCustomEvents
- EventBridgeEvents
- EventKey
- EventMap
- FromEmitToOtherType
- FromInvokeToOtherType
- HttpClientConfig
- HttpClientRequestOptions
- HttpExposedServiceMeta
- InfoInvokeTimeout
- InfoInvokeTimeoutPayload
- InfoMessage
- InfoMessageType
- InfoServiceBase
- InfoServiceDrain
- InfoServiceFunctionAdded
- InfoServiceInit
- InfoServiceNotReady
- InfoServiceReady
- InfoServiceShutdown
- InfoSubscriptionError
- InstanceId
- InvokeFunction
- LogFnParamType
- LogLevelName
- LoggerOptions
- LoggerStubs
- Newable
- NonEmptyString
- ObjectWithKeysFromStringArray
- PendigInvocation
- Prettify
- PrincipalId
- QueryParameter
- SecretStoreCacheMap
- ServiceEvents
- ServiceInfoType
- ShutdownEntry
- StoreBaseConfig
- SubscriptionDefinitionList
- SubscriptionDefinitionListResolved
- SubscriptionDefinitionMetadataBase
- SubscriptionStorageEntry
- SupportedHttpMethod
- TenantId
- TraceId
- addPrefixToObject
Variables
Functions
- createInvokeFunctionProxy
- extendApi
- generateSchema
- getCommandFunctionWithValidation
- getDefaultEventBridgeConfig
- getDefaultLogLevel
- getNewSubscriptionStorageEntry
- getSubscriptionFunctionWithValidation
- getTimeoutPromise
- initDefaultConfigStore
- initDefaultSecretStore
- initDefaultStateStore
- initLogger
- isCustomMessage
- isHttpExposedServiceMeta
- isInfoMessage
- isInfoServiceFunctionAdded
- isMessageMatchingSubscription
- safeBind
- throwIfNotValidMessage
- validationToSchema
Command
- CommandDefinitionBuilder
- CommandAfterGuardHook
- CommandBeforeGuardHook
- CommandDefinition
- CommandErrorResponse
- CommandFunction
- CommandFunctionContext
- CommandFunctionContextEnhancements
- CommandResponse
- CommandSuccessResponse
- CommandTransformFunctionContext
- CommandTransformInputHook
- CommandTransformOutputHook
- isCommand
- isCommandErrorResponse
- isCommandResponse
- isCommandSuccessResponse
Event bridge
Helper
- convertToCamelCase
- convertToKebabCase
- convertToPascalCase
- convertToSnakeCase
- createErrorResponse
- createInfoMessage
- createSuccessResponse
- deserializeOtp
- getCleanedMessage
- getErrorMessageForCode
- getNewCorrelationId
- getNewEBMessageId
- getNewInstanceId
- getNewTraceId
- getSubscriptionQueueName
- getUniqueId
- gracefulShutdown
- isDevelop
- serializeOtp
Service
Store
- ConfigStoreBaseClass
- DefaultConfigStore
- DefaultSecretStore
- DefaultStateStore
- SecretStoreBaseClass
- StateStoreBaseClass
- ConfigStore
- SecretStore
- StateStore
- ConfigDeleteFunction
- ConfigGetterFunction
- ConfigSetterFunction
- SecretDeleteFunction
- SecretGetterFunction
- SecretSetterFunction
- StateDeleteFunction
- StateGetterFunction
- StateSetterFunction
Subscription
- SubscriptionDefinitionBuilder
- Subscription
- SubscriptionAfterGuardHook
- SubscriptionBeforeGuardHook
- SubscriptionDefinition
- SubscriptionFunction
- SubscriptionFunctionContext
- SubscriptionFunctionContextEnhancements
- SubscriptionTransformFunctionContext
- SubscriptionTransformInputHook
- SubscriptionTransformOutputHook
Unit test helper
- getCommandContextMock
- getCommandErrorMessageMock
- getCommandMessageMock
- getCommandSuccessMessageMock
- getCommandTransformContextMock
- getCustomMessageMessageMock
- getEventBridgeMock
- getLoggerMock
- getSubscriptionContextMock
- getSubscriptionTransformContextMock
Type Aliases
AuthCredentials
Ƭ AuthCredentials: Object
HTTP authentication information
Type declaration
Name | Type | Description |
---|---|---|
basicAuth? | { password : string ; username : string } | Basic-Auth information |
basicAuth.password | string | Basic-Auth password |
basicAuth.username | string | Basic-Auth username |
bearerToken? | string | Bearer token header |
Defined in
HttpClient/types/AuthCredentials.ts:4
BrokerHeaderCommandMsg
Ƭ BrokerHeaderCommandMsg: Prettify
<BrokerHeaderCustomMsg
& { receiverInstanceId?
: InstanceId
; receiverServiceName
: string
; receiverServiceTarget
: string
; receiverServiceVersion
: string
}>
Defined in
core/types/BrokerHeaderCommandMsg.ts:5
BrokerHeaderCommandResponseMsg
Ƭ BrokerHeaderCommandResponseMsg: Prettify
<BrokerHeaderCommandMsg
& { receiverInstanceId
: InstanceId
}>
Defined in
core/types/BrokerHeaderCommandResponseMsg.ts:5
BrokerHeaderCustomMsg
Ƭ BrokerHeaderCustomMsg: Object
Type declaration
Name | Type |
---|---|
eventName? | string |
messageType | EBMessageType |
principalId? | PrincipalId |
senderInstanceId | InstanceId |
senderServiceName | string |
senderServiceTarget | string |
senderServiceVersion | string |
tenantId? | TenantId |
Defined in
core/types/BrokerHeaderCustomMsg.ts:6
Command
Ƭ Command<PayloadType
, ParameterType
>: Prettify
<{ correlationId
: CorrelationId
; messageType
: Command
; payload
: { parameter
: ParameterType
; payload
: PayloadType
} ; receiver
: EBMessageAddress
} & EBMessageBase
>
Command is a event bridge message, which is emitted by sender to event bridge. The event bridge dispatches the event to the receiver. A command expects to get a response message from receiver back to sender.
Also if there are subscriptions which are matching given command, the event bridge also dispatches the command message to the subscriber(s).
BE AWARE: Subscribers should not respond with command responses if they are "silent" subscribers/listeners.
Type parameters
Name | Type |
---|---|
PayloadType | unknown |
ParameterType | unknown |
Defined in
core/types/commandType/Command.ts:18
CommandDefinitionList
Ƭ CommandDefinitionList<ServiceClassType
>: Promise
<CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, any
, any
, any
, any
, any
, any
, any
, any
>>[]
Helper type for creating list of service commands to be passed as input to service class
export const userServiceCommands: CommandDefinitionList<UserService> = [signUp.getDefinition()]
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
Defined in
core/types/commandType/CommandDefinitionList.ts:12
CommandDefinitionListResolved
Ƭ CommandDefinitionListResolved<ServiceClassType
>: CommandDefinition
<ServiceClassType
, CommandDefinitionMetadataBase
, any
, any
, any
, any
, any
, any
, any
, any
>[]
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
Defined in
core/types/commandType/CommandDefinitionList.ts:16
CommandDefinitionMetadataBase
Ƭ CommandDefinitionMetadataBase: Object
Type declaration
Name | Type |
---|---|
expose | { contentEncodingRequest? : string ; contentEncodingResponse? : string ; contentTypeRequest? : ContentType ; contentTypeResponse? : ContentType ; deprecated? : boolean ; inputPayload? : SchemaObject ; outputPayload? : SchemaObject ; parameter? : SchemaObject } |
expose.contentEncodingRequest? | string |
expose.contentEncodingResponse? | string |
expose.contentTypeRequest? | ContentType |
expose.contentTypeResponse? | ContentType |
expose.deprecated? | boolean |
expose.inputPayload? | SchemaObject |
expose.outputPayload? | SchemaObject |
expose.parameter? | SchemaObject |
Defined in
core/types/commandType/CommandDefinitionMetadataBase.ts:5
Complete
Ƭ Complete<T
>: { [P in keyof Required<T>]: Pick<T, P> extends Required<Pick<T, P>> ? T[P] : T[P] | undefined }
A helper which forces to provide all object keys, even if they are optional.
Example
type A = {
one?: string,
two?: number,
three: string
}
// without:
const x:A = { three: 'will work'}
// this will fail
const y:Complete<A> = { three: 'will complain that one and two is missing'}
// needs to be like this:
const z:Complete<A> = { one: undefined, two: undefined, three: 'will work'}
Type parameters
Name |
---|
T |
Defined in
CompressionMethod
Ƭ CompressionMethod: "gzip"
| "deflat"
| "br"
| undefined
Defined in
core/HttpServer/types/CompressionMethod.ts:1
ConfigStoreCacheMap
Ƭ ConfigStoreCacheMap: Map
<string
, { createdAt
: number
; value
: string
}>
Defined in
core/ConfigStore/types/ConfigStoreCacheMap.ts:1
ContentType
Ƭ ContentType: "application/json"
| "application/javascript"
| "text/csv"
| "text/css"
| "text/html"
| "text/javascript"
| "text/markdown"
| "text/plain"
| "text/xml"
| string
List of content types for message payloads. If the content type is other than application/json
, the message payload must be a string. It is up to the implementation to extract the content type from the original message and to convert or transform data.
Defined in
ContextBase
Ƭ ContextBase: Object
The ContextBase provides is a basic type. Each context for command function, subscription function and all Hooks and transformers will have at least the properties of this type.
Type declaration
Name | Type | Description |
---|---|---|
configs | { getConfig : ConfigGetterFunction ; removeConfig : ConfigDeleteFunction ; setConfig : ConfigSetterFunction } | the config store |
configs.getConfig | ConfigGetterFunction | get a config value from the config store |
configs.removeConfig | ConfigDeleteFunction | delete a config value from the config store |
configs.setConfig | ConfigSetterFunction | set a config value in the config store |
logger | Logger | the logger instance |
secrets | { getSecret : SecretGetterFunction ; removeSecret : SecretDeleteFunction ; setSecret : SecretSetterFunction } | the secret store |
secrets.getSecret | SecretGetterFunction | get a secret from the secret store |
secrets.removeSecret | SecretDeleteFunction | delete a secret from the secret store |
secrets.setSecret | SecretSetterFunction | set a secret in the secret store |
startActiveSpan | <F>(name : string , opts : SpanOptions , context : Context | undefined , fn : (span : Span ) => Promise <F >) => Promise <F > | wrap given function in an opentelemetry active span |
states | { getState : StateGetterFunction ; removeState : StateDeleteFunction ; setState : StateSetterFunction } | the state store |
states.getState | StateGetterFunction | get a state value from the state store |
states.removeState | StateDeleteFunction | delete a state value from the state store |
states.setState | StateSetterFunction | set a state value in the state store |
wrapInSpan | <F>(name : string , opts : SpanOptions , fn : (span : Span ) => Promise <F >, context? : Context ) => Promise <F > | wrap given function in an opentelemetry span |
Defined in
CorrelationId
Ƭ CorrelationId: string
the correlation id links the command invocation message with the command response message
Defined in
CustomMessage
Ƭ CustomMessage<Payload
>: Prettify
<{ eventName
: string
; messageType
: CustomMessage
; payload?
: Payload
; receiver?
: EBMessageAddress
} & EBMessageBase
>
A custom message is a message which can be used to pass business information. The producer emits the message without knowledge about any consumer. The producer does not expect a response from a consumer.
Type parameters
Name | Type |
---|---|
Payload | unknown |
Defined in
core/types/CustomMessage.ts:11
DefaultConfigStoreConfig
Ƭ DefaultConfigStoreConfig: Record
<string
, unknown
>
Defined in
DefaultConfigStore/types/DefaultConfigStoreConfig.ts:1
DefaultEventBridgeConfig
Ƭ DefaultEventBridgeConfig: Object
The configuration for the DefaultEventBridge.
Type declaration
Name | Type | Description |
---|---|---|
emitMessagesAsEventBridgeEvents? | boolean | Emit messages which have an event name set as javascript events on the event bridge instance |
logWarnOnMessagesWithoutReceiver? | boolean | Log warnings on messages which are emitted, but could not delivered to at least one receiver |
Defined in
DefaultEventBridge/types/DefaultEventBridgeConfig.ts:4
DefaultSecretStoreConfig
Ƭ DefaultSecretStoreConfig: Record
<string
, unknown
>
Defined in
DefaultSecretStore/types/DefaultSecretStoreConfig.ts:1
DefaultStateStoreConfig
Ƭ DefaultStateStoreConfig: Record
<string
, unknown
>
Defined in
DefaultStateStore/types/DefaultStateStoreConfig.ts:1
DefinitionEventBridgeConfig
Ƭ DefinitionEventBridgeConfig: Object
Settings and advices for the event bridge, which are set in the command or subscription builder. The properties are advices and hints. It depends on the used event bridge implementation and underlaying message broker, if a specific property can be respected.
Type declaration
Name | Type | Description |
---|---|---|
autoacknowledge | boolean | Send the acknowledge to message broker as soon as the message arrives - defaults to true for commands - defaults to false for subscriptions |
durable | boolean | Advise the underlaying message broker to store messages if no consumer is available. Messages will be send as soon as the service is able to consume. |
shared | boolean | If set to true, the event bridge is adviced to deliver one message to at least one consumer instance. True is the default value. If set to false, the event bridge is adviced to deliver one message to all consumer instances. Use case: Receiving Info of message, which need to be passed to all instance to keep information in sync. In serverless environments, this flag should not have any effect Default ts true |
Defined in
core/types/DefinitionEventBridgeConfig.ts:6
EBMessage
Ƭ EBMessage: Command
| CommandResponse
| InfoMessage
| CustomMessage
EBMessage is some message which is handled by the event bridge.
Defined in
EBMessageAddress
Ƭ EBMessageAddress: Object
A event bridge message address describes the sender or receiver of a message.
Type declaration
Name | Type | Description |
---|---|---|
instanceId? | Exclude <InstanceId , "" > | instance id of eventbridge |
serviceName | Exclude <string , "" > | the name of the service |
serviceTarget | Exclude <string , "" > | the name of the command or subscription |
serviceVersion | Exclude <string , "" > | the version of the service |
Defined in
core/types/EBMessageAddress.ts:6
EBMessageBase
Ƭ EBMessageBase: Object
Default fields which are part of any purista message
Type declaration
Name | Type | Description |
---|---|---|
contentEncoding | string | content encoding of message payload |
contentType | ContentType | content type of message payload |
correlationId? | CorrelationId | correlation id to know which command response referrs to which command |
eventName? | string | event name for this message |
id | EBMessageId | global unique id of message |
otp? | string | stringified Opentelemetry parent trace id |
principalId? | PrincipalId | principal id |
sender | EBMessageSenderAddress | - |
tenantId? | TenantId | principal id |
timestamp | number | timestamp of message creation time |
traceId? | TraceId | trace id of message |
Defined in
core/types/EBMessageBase.ts:12
EBMessageId
Ƭ EBMessageId: string
Unique id of the event bridge message
Defined in
EBMessageSenderAddress
Ƭ EBMessageSenderAddress: Prettify
<Omit
<EBMessageAddress
, "instanceId"
> & Required
<Pick
<EBMessageAddress
, "instanceId"
>>>
A event bridge message address describes the sender or receiver of a message.
Defined in
core/types/EBMessageSenderAddress.ts:7
EmitCustomMessageFunction
Ƭ EmitCustomMessageFunction<EmitList
>: <K>(eventName
: K
, payload
: EmitList
[K
], contentType?
: ContentType
, contentEncoding?
: string
) => Promise
<void
>
Emits the given payload as custom message with the given event name.
Example
await emit('my-custom-event-name', { the: 'payload' })
Type parameters
Name |
---|
EmitList |
Type declaration
▸ <K
>(eventName
, payload
, contentType?
, contentEncoding?
): Promise
<void
>
Type parameters
Name | Type |
---|---|
K | extends keyof EmitSchemaList <EmitList > |
Parameters
Name | Type |
---|---|
eventName | K |
payload | EmitList [K ] |
contentType? | ContentType |
contentEncoding? | string |
Returns
Promise
<void
>
Defined in
core/types/EmitCustomMessageFunction.ts:12
EmitSchemaList
Ƭ EmitSchemaList<T
>: { [K in keyof T]: Schema }
Type parameters
Name |
---|
T |
Defined in
core/types/EmitSchemaList.ts:3
ErrorResponsePayload
Ƭ ErrorResponsePayload: Object
Error message payload
Type declaration
Name | Type | Description |
---|---|---|
data? | unknown | addition data |
message | string | a human readable error message |
status | StatusCode | the error status code |
traceId? | TraceId | the trace if of the request |
Defined in
core/types/ErrorResponsePayload.ts:7
EventBridgeAdapterEvents
Ƭ EventBridgeAdapterEvents: Object
Index signature
▪ [key: string
]: unknown
currently not used, but reserved for further events
Group
Events
Defined in
core/EventBridge/types/EventBridgeEvents.ts:42
EventBridgeConfig
Ƭ EventBridgeConfig<CustomConfig
>: Prettify
<{ defaultCommandTimeout?
: number
; instanceId?
: string
; logLevel?
: LogLevelName
; logger?
: Logger
; spanProcessor?
: SpanProcessor
} & CustomConfig
>
The config object for an event bridge. Every event bridge implementation must use this type for configuration.
Type parameters
Name |
---|
CustomConfig |
Defined in
core/EventBridge/types/EventBridgeConfig.ts:10
EventBridgeCustomEvents
Ƭ EventBridgeCustomEvents: Object
Index signature
▪ [key: string
]: unknown
emitted a EBMessage if event name is provided and if it is enabled and supported on the event bridge
Group
Events
Defined in
core/EventBridge/types/EventBridgeEvents.ts:37
EventBridgeEvents
Ƭ EventBridgeEvents: Prettify
<EventBridgeEventsBasic
& addPrefixToObject
<EventBridgeAdapterEvents
, "adapter-"
> & addPrefixToObject
<EventBridgeCustomEvents
, "custom-"
>>
Defined in
core/EventBridge/types/EventBridgeEvents.ts:47
EventKey
Ƭ EventKey<T
>: string
& keyof T
Type parameters
Name | Type |
---|---|
T | extends EventMap |
Defined in
core/types/GenericEventEmitter.ts:5
EventMap
Ƭ EventMap: Record
<string
, any
>
Defined in
core/types/GenericEventEmitter.ts:3
FromEmitToOtherType
Ƭ FromEmitToOtherType<Entry
, NewType
>: { [TKey in keyof Entry]: NewType }
Changes the canEmit proxy type to given type
serviceName.ServiceVersion.FunctionName becomes type of SinonStub
Type parameters
Name |
---|
Entry |
NewType |
Defined in
core/types/FromEmitToOtherType.ts:6
FromInvokeToOtherType
Ƭ FromInvokeToOtherType<Entry
, NewType
>: { [TKey in keyof Entry]: { [TKey2 in keyof Entry[TKey]]: { [TKey3 in keyof Entry[TKey][TKey2]]: NewType } } }
Changes the canInvoke proxy type to given type
serviceName.ServiceVersion.FunctionName becomes type of NewType
Type parameters
Name |
---|
Entry |
NewType |
Defined in
core/types/FromInvokeToOtherType.ts:6
HttpClientConfig
Ƭ HttpClientConfig<CustomConfig
>: Prettify
<{ baseUrl
: string
; basicAuth?
: { password
: string
; username
: string
} ; bearerToken?
: string
; defaultHeaders?
: Record
<string
, string
> ; defaultTimeout?
: number
; enableOpentelemetry?
: boolean
; isKeepAlive?
: boolean
; logLevel?
: LogLevelName
; logger?
: Logger
; name?
: string
; spanProcessor?
: SpanProcessor
; traceId?
: string
} & CustomConfig
>
Tha basic configuration for a HTTPClient Requires as least a baseUrl
Type parameters
Name | Type |
---|---|
CustomConfig | extends Record <string , unknown > |
Defined in
HttpClient/types/HttpClientConfig.ts:9
HttpClientRequestOptions
Ƭ HttpClientRequestOptions: Object
Options for a single request
Type declaration
Name | Type | Description |
---|---|---|
hash? | string | url hash @example: http://example.com/index.html#hash |
headers? | Record <string , string > | additional headers |
query? | Record <string , string > | query/search string parameter |
timeout? | number | Timeout for the request in ms Default ts 30000 |
Defined in
HttpClient/types/HttpClientRequestOptions.ts:4
HttpExposedServiceMeta
Ƭ HttpExposedServiceMeta<ParameterType
>: Prettify
<CommandDefinitionMetadataBase
& { expose
: { http
: { method
: "GET"
| "POST"
| "PATCH"
| "PUT"
| "DELETE"
; openApi?
: { additionalStatusCodes?
: StatusCode
[] ; description
: string
; isSecure
: boolean
; operationId?
: string
; query?
: QueryParameter
<ParameterType
>[] ; summary
: string
; tags?
: string
[] } ; path
: string
} } }>
Type parameters
Name | Type |
---|---|
ParameterType | {} |
Defined in
core/HttpServer/types/HttpExposedServiceMeta.ts:4
InfoInvokeTimeout
Ƭ InfoInvokeTimeout: { messageType
: InfoInvokeTimeout
} & InfoServiceBase
Defined in
core/types/infoType/InfoInvokeTimeout.ts:22
InfoInvokeTimeoutPayload
Ƭ InfoInvokeTimeoutPayload: Object
Type declaration
Name | Type |
---|---|
correlationId | CorrelationId |
receiver | { serviceName : string ; serviceTarget : string ; serviceVersion : string } |
receiver.serviceName | string |
receiver.serviceTarget | string |
receiver.serviceVersion | string |
sender | { serviceName : string ; serviceTarget : string ; serviceVersion : string } |
sender.serviceName | string |
sender.serviceTarget | string |
sender.serviceVersion | string |
timestamp | number |
traceId | TraceId |
Defined in
core/types/infoType/InfoInvokeTimeout.ts:6
InfoMessage
Ƭ InfoMessage: InfoServiceDrain
| InfoServiceFunctionAdded
| InfoServiceInit
| InfoServiceNotReady
| InfoServiceReady
| InfoServiceShutdown
| InfoInvokeTimeout
| InfoSubscriptionError
Defined in
core/types/infoType/InfoMessage.ts:11
InfoMessageType
Ƭ InfoMessageType: InfoServiceDrain
| InfoServiceFunctionAdded
| InfoServiceInit
| InfoServiceNotReady
| InfoServiceReady
| InfoServiceShutdown
| InfoInvokeTimeout
| InfoSubscriptionError
Defined in
core/types/infoType/InfoMessage.ts:21
InfoServiceBase
Ƭ InfoServiceBase: Prettify
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; payload?
: unknown
} & EBMessageBase
>
Defined in
core/types/infoType/InfoServiceBase.ts:4
InfoServiceDrain
Ƭ InfoServiceDrain: Prettify
<{ messageType
: InfoServiceDrain
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceDrain.ts:5
InfoServiceFunctionAdded
Ƭ InfoServiceFunctionAdded: Prettify
<{ messageType
: InfoServiceFunctionAdded
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceFunctionAdded.ts:5
InfoServiceInit
Ƭ InfoServiceInit: Prettify
<{ messageType
: InfoServiceInit
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceInit.ts:5
InfoServiceNotReady
Ƭ InfoServiceNotReady: Prettify
<{ messageType
: InfoServiceNotReady
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceNotReady.ts:5
InfoServiceReady
Ƭ InfoServiceReady: Prettify
<{ messageType
: InfoServiceReady
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceReady.ts:5
InfoServiceShutdown
Ƭ InfoServiceShutdown: Prettify
<{ messageType
: InfoServiceShutdown
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoServiceShutdown.ts:5
InfoSubscriptionError
Ƭ InfoSubscriptionError: Prettify
<{ messageType
: InfoSubscriptionError
} & InfoServiceBase
>
Defined in
core/types/infoType/InfoSubscriptionError.ts:5
InstanceId
Ƭ InstanceId: string
the instance id of the event bridge
Defined in
InvokeFunction
Ƭ InvokeFunction: <InvokeResponseType, PayloadType, ParameterType>(address
: EBMessageAddress
, payload
: PayloadType
, parameter
: ParameterType
) => Promise
<InvokeResponseType
>
Invokes a command and returns the result. It is recommended to validate the result against a schema which only contains the data you actually need.
Example
const address: EBMessageAddress = {
serviceName: 'name-of-service-to-invoke',
serviceVersion: '1',
serviceTarget: 'command-name-to-invoke',
}
const inputPayload = { my: 'input' }
const inputParameter = { search: 'for_me' }
const result = await invoke<MyResultType>(address, inputPayload inputParameter )
Type declaration
▸ <InvokeResponseType
, PayloadType
, ParameterType
>(address
, payload
, parameter
): Promise
<InvokeResponseType
>
Type parameters
Name | Type |
---|---|
InvokeResponseType | unknown |
PayloadType | unknown |
ParameterType | unknown |
Parameters
Name | Type |
---|---|
address | EBMessageAddress |
payload | PayloadType |
parameter | ParameterType |
Returns
Promise
<InvokeResponseType
>
Defined in
core/types/InvokeFunction.ts:22
LogFnParamType
Ƭ LogFnParamType: [unknown
, string?, ...any] | [string
, ...any]
Defined in
LogLevelName
Ƭ LogLevelName: "info"
| "error"
| "warn"
| "debug"
| "trace"
| "fatal"
Defined in
LoggerOptions
Ƭ LoggerOptions: Object
Type declaration
Name | Type |
---|---|
customTraceId? | TraceId |
hostname? | string |
instanceId? | InstanceId |
module? | string |
name? | string |
principalId? | PrincipalId |
puristaVersion? | string |
serviceName? | string |
serviceTarget? | string |
serviceVersion? | string |
tenantId? | TenantId |
Defined in
LoggerStubs
Ƭ LoggerStubs: Object
Type declaration
Name | Type |
---|---|
debug | SinonStub |
error | SinonStub |
info | SinonStub |
trace | SinonStub |
warn | SinonStub |
Defined in
Newable
Ƭ Newable<T
, ConfigType
>: (config
: ServiceConstructorInput
<ConfigType
>) => T
Type parameters
Name |
---|
T |
ConfigType |
Type declaration
• new Newable(config
): T
Parameters
Name | Type |
---|---|
config | ServiceConstructorInput <ConfigType > |
Returns
T
Defined in
ServiceBuilder/ServiceBuilder.impl.ts:30
NonEmptyString
Ƭ NonEmptyString<T
>: ""
extends T
? never
: T
Type parameters
Name | Type |
---|---|
T | extends string |
Defined in
helper/types/NonEmptyString.ts:1
ObjectWithKeysFromStringArray
Ƭ ObjectWithKeysFromStringArray<T
, Value
>: { [K in T extends ReadonlyArray<infer U> ? U : never]: Value }
Type helper which can create a typed record, based on given string array type.
Type parameters
Name | Type |
---|---|
T | extends ReadonlyArray <string > |
Value | unknown | undefined |
Defined in
helper/types/ObjectWithKeysFromStringArray.ts:5
PendigInvocation
Ƭ PendigInvocation: Object
Type declaration
Name | Type |
---|---|
reject | (error : UnhandledError | HandledError ) => void |
resolve | (responsePayload : unknown ) => void |
Defined in
DefaultEventBridge/types/PendingInvocations.ts:3
Prettify
Ƭ Prettify<T
>: { [K in keyof T]: T[K] } & {}
Type parameters
Name |
---|
T |
Defined in
PrincipalId
Ƭ PrincipalId: string
the principal id
Defined in
QueryParameter
Ƭ QueryParameter<ParameterType
>: Object
Type parameters
Name | Type |
---|---|
ParameterType | {} |
Type declaration
Name | Type |
---|---|
name | keyof ParameterType |
required | boolean |
Defined in
core/HttpServer/types/QueryParameter.ts:1
SecretStoreCacheMap
Ƭ SecretStoreCacheMap: Map
<string
, { createdAt
: number
; value
: string
}>
Defined in
core/SecretStore/types/SecretStoreCacheMap.ts:1
ServiceEvents
Ƭ ServiceEvents: ServiceEventsInternal
& addPrefixToObject
<CustomEvents
, "custom-"
> & addPrefixToObject
<CustomEvents
, "misc-"
>
ServiceEvents are plain javascript events sent by the service. There are three types:
- technical events when a services starts, stops, an error occurs and so on are prefixed with
service-
- response messages, which have a event name assigned, are prefixed with
custom-
- additional events, free defined by developer are prefixed with
misc-
Defined in
core/types/ServiceEvents.ts:98
ServiceInfoType
Ƭ ServiceInfoType: Object
General service information
Type declaration
Name | Type |
---|---|
serviceDescription | string |
serviceName | Exclude <string , "" > |
serviceVersion | Exclude <string , "" > |
Defined in
core/types/infoType/ServiceInfoType.ts:4
ShutdownEntry
Ƭ ShutdownEntry: Object
Entry of thing you like to shutdown gracefully
Type declaration
Name | Type | Description |
---|---|---|
destroy | () => Promise <void > | a async function that is called during shutdown |
name | string | the name |
Defined in
helper/types/ShutdownEntry.ts:4
StoreBaseConfig
Ƭ StoreBaseConfig<Config
>: Prettify
<{ cacheTtl?
: number
; enableCache?
: boolean
; enableGet?
: boolean
; enableRemove?
: boolean
; enableSet?
: boolean
; logLevel?
: LogLevelName
; logger?
: Logger
} & Config
>
Basic configuration object which is used by any store
Type parameters
Name | Type |
---|---|
Config | extends Record <string , unknown > |
Defined in
core/types/StoreBaseConfig.ts:8
SubscriptionDefinitionList
Ƭ SubscriptionDefinitionList<ServiceClassType
>: Promise
<SubscriptionDefinition
<ServiceClassType
, any
, any
, any
, any
, any
, any
, any
, any
, any
>>[]
Helper type for creating list of service commands to be passed as input to service class
export const userServiceCommands: SubscriptionDefinitionList<UserService> = [signUp.getDefinition()]
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
Defined in
core/types/subscription/SubscriptionDefinitionList.ts:11
SubscriptionDefinitionListResolved
Ƭ SubscriptionDefinitionListResolved<ServiceClassType
>: SubscriptionDefinition
<ServiceClassType
, any
, any
, any
, any
, any
, any
, any
, any
, any
>[]
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
Defined in
core/types/subscription/SubscriptionDefinitionList.ts:15
SubscriptionDefinitionMetadataBase
Ƭ SubscriptionDefinitionMetadataBase: Object
Type declaration
Name | Type |
---|---|
expose | { contentEncodingRequest? : string ; contentEncodingResponse? : string ; contentTypeRequest? : ContentType ; contentTypeResponse? : ContentType ; inputPayload? : SchemaObject ; outputPayload? : SchemaObject ; parameter? : SchemaObject } |
expose.contentEncodingRequest? | string |
expose.contentEncodingResponse? | string |
expose.contentTypeRequest? | ContentType |
expose.contentTypeResponse? | ContentType |
expose.inputPayload? | SchemaObject |
expose.outputPayload? | SchemaObject |
expose.parameter? | SchemaObject |
Defined in
core/types/subscription/SubscriptionDefinitionMetadataBase.ts:5
SubscriptionStorageEntry
Ƭ SubscriptionStorageEntry: Object
Type declaration
Name | Type |
---|---|
cb | (message : EBMessage ) => Promise <Omit <CustomMessage , "id" | "timestamp" > | undefined > |
emitEventName? | string |
isMatchingEventName | (input? : string ) => boolean |
isMatchingMessageType | (input : EBMessageType ) => boolean |
isMatchingPrincipalId | (input? : string ) => boolean |
isMatchingReceiverInstanceId | (input? : string ) => boolean |
isMatchingReceiverServiceName | (input? : string ) => boolean |
isMatchingReceiverServiceTarget | (input? : string ) => boolean |
isMatchingReceiverServiceVersion | (input? : string ) => boolean |
isMatchingSenderInstanceId | (input? : string ) => boolean |
isMatchingSenderServiceName | (input? : string ) => boolean |
isMatchingSenderServiceTarget | (input? : string ) => boolean |
isMatchingSenderServiceVersion | (input? : string ) => boolean |
isMatchingTenantId | (input? : string ) => boolean |
Defined in
DefaultEventBridge/types/SubscriptionStorageEntry.ts:3
SupportedHttpMethod
Ƭ SupportedHttpMethod: "GET"
| "POST"
| "PATCH"
| "PUT"
| "DELETE"
Supported HTTP-Methods for defining endpoints
Defined in
core/HttpServer/types/SupportedHttpMethod.ts:2
TenantId
Ƭ TenantId: string
the tenant id
Defined in
TraceId
Ƭ TraceId: string
The trace id which will be passed through all commands, invocations and subscriptions
Defined in
addPrefixToObject
Ƭ addPrefixToObject<T
, P
>: { [K in keyof T as K extends string ? `${P}${K}` : never]: T[K] }
Helper for better typescript type. All keys of given object must start with the given prefix. Otherwise Typescript will complain.
#### Type parameters
| Name | Type |
| :------ | :------ |
| `T` | `T` |
| `P` | extends `string` |
#### Defined in
[core/types/addPrefixToObject.ts:7](https://github.com/puristajs/purista/blob/master/packages/core/src/core/types/addPrefixToObject.ts#L7)
## Variables
### MIN\_CONTENT\_SIZE\_FOR\_COMPRESSION
• `Const` **MIN\_CONTENT\_SIZE\_FOR\_COMPRESSION**: ``1024``
#### Defined in
[core/HttpServer/MinContentSizeForCompression.const.ts:1](https://github.com/puristajs/purista/blob/master/packages/core/src/core/HttpServer/MinContentSizeForCompression.const.ts#L1)
___
### ServiceInfoValidator
• `Const` **ServiceInfoValidator**: `Object`
#### Type declaration
| Name | Type |
| :------ | :------ |
| `set` | (`obj`: [`ServiceInfoType`](purista_core.md#serviceinfotype), `prop`: keyof [`ServiceInfoType`](purista_core.md#serviceinfotype), `value`: `string`) => `boolean` |
#### Defined in
[core/Service/ServiceInfoValidator.impl.ts:5](https://github.com/puristajs/purista/blob/master/packages/core/src/core/Service/ServiceInfoValidator.impl.ts#L5)
___
### infoMessageTypes
• `Const` **infoMessageTypes**: [`EBMessageType`](../enums/purista_core.EBMessageType.md)[]
#### Defined in
[core/types/infoType/InfoMessage.ts:30](https://github.com/puristajs/purista/blob/master/packages/core/src/core/types/infoType/InfoMessage.ts#L30)
___
### puristaVersion
• `Const` **puristaVersion**: ``"1.11.0"``
#### Defined in
[version.ts:1](https://github.com/puristajs/purista/blob/master/packages/core/src/version.ts#L1)
## Functions
### createInvokeFunctionProxy
▸ **createInvokeFunctionProxy**\<`TFaux`\>(`invokeOg`, `address?`, `lvl?`): `TFaux`
Creates a proxy which allows to chain the invoke function.
#### Type parameters
| Name |
| :------ |
| `TFaux` |
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `invokeOg` | [`InvokeFunction`](purista_core.md#invokefunction) | `undefined` | the regular invoke function |
| `address?` | [`EBMessageAddress`](purista_core.md#ebmessageaddress) | `undefined` | the receivers EBMessageAddress |
| `lvl` | `number` | `0` | counter for recursive usage |
#### Returns
`TFaux`
a proxy which allows to chain like serviceName.serviceVersion.fnToInvoke(payload,parameter)
#### Defined in
[core/helper/createInvokeFunctionProxy.impl.ts:16](https://github.com/puristajs/purista/blob/master/packages/core/src/core/helper/createInvokeFunctionProxy.impl.ts#L16)
___
### extendApi
▸ **extendApi**\<`T`\>(`schema`, `SchemaObject?`): `T`
#### Type parameters
| Name | Type |
| :------ | :------ |
| `T` | extends [`OpenApiZodAny`](../interfaces/purista_core.OpenApiZodAny.md) |
#### Parameters
| Name | Type |
| :------ | :------ |
| `schema` | `T` |
| `SchemaObject` | `SchemaObject` |
#### Returns
`T`
#### Defined in
[zodOpenApi/zodOpenApi.impl.ts:26](https://github.com/puristajs/purista/blob/master/packages/core/src/zodOpenApi/zodOpenApi.impl.ts#L26)
___
### generateSchema
▸ **generateSchema**(`zodRef`, `useOutput?`): `SchemaObject`
#### Parameters
| Name | Type |
| :------ | :------ |
| `zodRef` | [`OpenApiZodAny`](../interfaces/purista_core.OpenApiZodAny.md) |
| `useOutput?` | `boolean` |
#### Returns
`SchemaObject`
#### Defined in
[zodOpenApi/zodOpenApi.impl.ts:415](https://github.com/puristajs/purista/blob/master/packages/core/src/zodOpenApi/zodOpenApi.impl.ts#L415)
___
### getCommandFunctionWithValidation
▸ **getCommandFunctionWithValidation**\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `MessageResultType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>(`fn`, `inputPayloadSchema`, `inputParameterSchema`, `outputPayloadSchema`, `beforeGuards?`): [`CommandFunction`](purista_core.md#commandfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>
#### Type parameters
| Name | Type |
| :------ | :------ |
| `ServiceClassType` | extends [`ServiceClass`](../interfaces/purista_core.ServiceClass.md)\<`unknown`\> |
| `MessagePayloadType` | `unknown` |
| `MessageParamsType` | `unknown` |
| `MessageResultType` | `unknown` |
| `FunctionPayloadType` | `MessagePayloadType` |
| `FunctionParamsType` | `MessageParamsType` |
| `FunctionResultType` | `MessageResultType` |
| `Invokes` | {} |
| `EmitListType` | {} |
#### Parameters
| Name | Type |
| :------ | :------ |
| `fn` | [`CommandFunction`](purista_core.md#commandfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\> |
| `inputPayloadSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `inputParameterSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `outputPayloadSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `beforeGuards` | `Record`\<`string`, [`CommandBeforeGuardHook`](purista_core.md#commandbeforeguardhook)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `Invokes`, `EmitListType`\>\> |
#### Returns
[`CommandFunction`](purista_core.md#commandfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>
#### Defined in
[CommandDefinitionBuilder/getCommandFunctionWithValidation.impl.ts:8](https://github.com/puristajs/purista/blob/master/packages/core/src/CommandDefinitionBuilder/getCommandFunctionWithValidation.impl.ts#L8)
___
### getDefaultEventBridgeConfig
▸ **getDefaultEventBridgeConfig**(): [`Complete`](purista_core.md#complete)\<[`DefaultEventBridgeConfig`](purista_core.md#defaulteventbridgeconfig)\>
#### Returns
[`Complete`](purista_core.md#complete)\<[`DefaultEventBridgeConfig`](purista_core.md#defaulteventbridgeconfig)\>
#### Defined in
[DefaultEventBridge/getDefaultEventBridgeConfig.impl.ts:4](https://github.com/puristajs/purista/blob/master/packages/core/src/DefaultEventBridge/getDefaultEventBridgeConfig.impl.ts#L4)
___
### getDefaultLogLevel
▸ **getDefaultLogLevel**(): [`LogLevelName`](purista_core.md#loglevelname)
#### Returns
[`LogLevelName`](purista_core.md#loglevelname)
#### Defined in
[DefaultLogger/getDefaultLogLevel.ts:4](https://github.com/puristajs/purista/blob/master/packages/core/src/DefaultLogger/getDefaultLogLevel.ts#L4)
___
### getNewSubscriptionStorageEntry
▸ **getNewSubscriptionStorageEntry**(`subscription`, `cb`): [`SubscriptionStorageEntry`](purista_core.md#subscriptionstorageentry)
#### Parameters
| Name | Type |
| :------ | :------ |
| `subscription` | [`Subscription`](purista_core.md#subscription) |
| `cb` | (`message`: [`EBMessage`](purista_core.md#ebmessage)) => `Promise`\<`undefined` \| `Omit`\<\{ `contentEncoding`: `string` ; `contentType`: `string` ; `correlationId?`: `string` ; `eventName`: `string` ; `id`: `string` ; `messageType`: [`CustomMessage`](../enums/purista_core.EBMessageType.md#custommessage) ; `otp?`: `string` ; `payload?`: `unknown` ; `principalId?`: `string` ; `receiver?`: [`EBMessageAddress`](purista_core.md#ebmessageaddress) ; `sender`: \{ `instanceId`: `string` ; `serviceName`: `string` ; `serviceTarget`: `string` ; `serviceVersion`: `string` } ; `tenantId?`: `string` ; `timestamp`: `number` ; `traceId?`: `string` }, ``"id"`` \| ``"timestamp"``\>\> |
#### Returns
[`SubscriptionStorageEntry`](purista_core.md#subscriptionstorageentry)
#### Defined in
[DefaultEventBridge/getNewSubscriptionStorageEntry.impl.ts:4](https://github.com/puristajs/purista/blob/master/packages/core/src/DefaultEventBridge/getNewSubscriptionStorageEntry.impl.ts#L4)
___
### getSubscriptionFunctionWithValidation
▸ **getSubscriptionFunctionWithValidation**\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `MessageResultType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>(`fn`, `inputPayloadSchema`, `inputParameterSchema`, `outputPayloadSchema`, `beforeGuards?`): [`SubscriptionFunction`](purista_core.md#subscriptionfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>
#### Type parameters
| Name | Type |
| :------ | :------ |
| `ServiceClassType` | extends [`ServiceClass`](../interfaces/purista_core.ServiceClass.md)\<`unknown`\> |
| `MessagePayloadType` | `unknown` |
| `MessageParamsType` | `unknown` |
| `MessageResultType` | `unknown` |
| `FunctionPayloadType` | `MessagePayloadType` |
| `FunctionParamsType` | `MessageParamsType` |
| `FunctionResultType` | `MessageResultType` |
| `Invokes` | {} |
| `EmitListType` | {} |
#### Parameters
| Name | Type |
| :------ | :------ |
| `fn` | [`SubscriptionFunction`](purista_core.md#subscriptionfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\> |
| `inputPayloadSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `inputParameterSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `outputPayloadSchema` | `undefined` \| `Schema`\<`any`, `any`, `any`, ``""``\> \| `ZodType`\<`any`, `ZodTypeDef`, `any`\> |
| `beforeGuards` | `Record`\<`string`, [`SubscriptionBeforeGuardHook`](purista_core.md#subscriptionbeforeguardhook)\<`ServiceClassType`, `FunctionPayloadType`, `FunctionParamsType`, `Invokes`, `EmitListType`\>\> |
#### Returns
[`SubscriptionFunction`](purista_core.md#subscriptionfunction)\<`ServiceClassType`, `MessagePayloadType`, `MessageParamsType`, `FunctionPayloadType`, `FunctionParamsType`, `FunctionResultType`, `Invokes`, `EmitListType`\>
#### Defined in
[SubscriptionDefinitionBuilder/getSubscriptionFunctionWithValidation.impl.ts:8](https://github.com/puristajs/purista/blob/master/packages/core/src/SubscriptionDefinitionBuilder/getSubscriptionFunctionWithValidation.impl.ts#L8)
___
### getTimeoutPromise
▸ **getTimeoutPromise**\<`T`\>(`fn`, `ttl?`): `Promise`\<`T`\>
#### Type parameters
| Name |
| :------ |
| `T` |
#### Parameters
| Name | Type | Default value | Description |
| :------ | :------ | :------ | :------ |
| `fn` | `Promise`\<`T`\> | `undefined` | the promise which should get a timeout |
| `ttl` | `number` | `30000` | the timeout in ms |
#### Returns
`Promise`\<`T`\>
**`Default`**
```ts
30000
Defined in
helper/getTimeoutPromise.impl.ts:9
initDefaultConfigStore
▸ initDefaultConfigStore(options
): DefaultConfigStore
Parameters
Name | Type |
---|---|
options | Object |
options.logger | Logger |
Returns
Defined in
DefaultConfigStore/initDefaultConfigStore.impl.ts:4
initDefaultSecretStore
▸ initDefaultSecretStore(options
): DefaultSecretStore
Parameters
Name | Type |
---|---|
options | Object |
options.logger | Logger |
Returns
Defined in
DefaultSecretStore/initDefaultSecretStore.impl.ts:4
initDefaultStateStore
▸ initDefaultStateStore(options
): DefaultStateStore
Parameters
Name | Type |
---|---|
options | Object |
options.logger | Logger |
Returns
Defined in
DefaultStateStore/initDefaultStateStore.impl.ts:4
initLogger
▸ initLogger(level?
, opt?
): Logger
Create a new logger with the given minimum log level
Parameters
Name | Type |
---|---|
level | LogLevelName |
opt? | LoggerOptions <never > |
Returns
Defined in
DefaultLogger/initLogger.impl.ts:14
isCustomMessage
▸ isCustomMessage(message
): message is Object
Checks if a PURISTA message is type of custom message
Parameters
Name | Type | Description |
---|---|---|
message | EBMessage | any PURISTA message |
Returns
message is Object
true if message is type of custom message
Defined in
core/types/isCustomMessage.impl.ts:10
isHttpExposedServiceMeta
▸ isHttpExposedServiceMeta(input?
): input is Object
Checks if given input is type of HttpExposedServiceMeta
Parameters
Name | Type |
---|---|
input? | any |
Returns
input is Object
boolean - true if input is type of HttpExposedServiceMeta
Defined in
core/HttpServer/types/isHttpExposedServiceMeta.impl.ts:8
isInfoMessage
▸ isInfoMessage(message
): message is InfoMessage
Parameters
Name | Type |
---|---|
message | EBMessage |
Returns
message is InfoMessage
Defined in
core/types/infoType/isInfoMessage.impl.ts:5
isInfoServiceFunctionAdded
▸ isInfoServiceFunctionAdded(message
): message is Object
Parameters
Name | Type |
---|---|
message | EBMessage |
Returns
message is Object
Defined in
core/types/infoType/isInfoServiceFunctionAdded.impl.ts:5
isMessageMatchingSubscription
▸ isMessageMatchingSubscription(_log
, message
, subscription
): boolean
Parameters
Name | Type |
---|---|
_log | Logger |
message | EBMessage |
subscription | SubscriptionStorageEntry |
Returns
boolean
Defined in
DefaultEventBridge/isMessageMatchingSubscription.impl.ts:5
safeBind
▸ safeBind<T
>(fn
, thisArg
): (...args
: Parameters
<T
>) => ReturnType
<T
>
Bind this
argument like regular .bind(thisArg)
, but keeps the typescript types in result
Type parameters
Name | Type |
---|---|
T | extends (...args : any ) => any |
Parameters
Name | Type | Description |
---|---|---|
fn | T | The function |
thisArg | SafeThisParameterType <T > | - |
Returns
fn
▸ (...args
): ReturnType
<T
>
Parameters
Name | Type |
---|---|
...args | Parameters <T > |
Returns
ReturnType
<T
>
Example
const functionWithThisSet = safeBind(fn, thisParam)
Defined in
throwIfNotValidMessage
▸ throwIfNotValidMessage(input
): void
Validates if the given input might be valid event bridge message It only checks for "technically possible"
Parameters
Name | Type |
---|---|
input | unknown |
Returns
void
Defined in
helper/throwIfNotValidMessage.impl.ts:10
validationToSchema
▸ validationToSchema<T
>(schema?
): Promise
<undefined
| SchemaObject
>
Type parameters
Name | Type |
---|---|
T | extends Schema <any , any , any , "" > | ZodType <any , ZodTypeDef , any > |
Parameters
Name | Type |
---|---|
schema? | T |
Returns
Promise
<undefined
| SchemaObject
>
Defined in
zodOpenApi/validationToSchema.ts:9
Command
• CommandDefinitionBuilder<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, PayloadSchema
, ParameterSchema
, ResultSchema
, Invokes
, EmitListType
>: Object
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 | {} |
MessageResultType | void |
PayloadSchema | extends Schema = ZodAny |
ParameterSchema | extends Schema = ZodAny |
ResultSchema | extends Schema = ZodAny |
Invokes | {} |
EmitListType | {} |
Defined in
CommandDefinitionBuilder/CommandDefinitionBuilder.impl.ts:38
CommandAfterGuardHook
Ƭ CommandAfterGuardHook<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionResultType
, FunctionPayloadType
, FunctionParamsType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: CommandFunctionContext
<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>, result
: Readonly
<FunctionResultType
>, input
: Readonly
<FunctionPayloadType
>, parameter
: Readonly
<FunctionParamsType
>) => Promise
<void
>
Definition of after guard hook functions. This guard is called after function successfully returns and after output validation.
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | unknown |
FunctionResultType | unknown |
FunctionPayloadType | unknown |
FunctionParamsType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, result
, input
, parameter
): Promise
<void
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | CommandFunctionContext <MessagePayloadType , MessageParamsType , Invokes , EmitListType > |
result | Readonly <FunctionResultType > |
input | Readonly <FunctionPayloadType > |
parameter | Readonly <FunctionParamsType > |
Returns
Promise
<void
>
Defined in
core/types/commandType/CommandAfterGuardHook.ts:10
CommandBeforeGuardHook
Ƭ CommandBeforeGuardHook<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: CommandFunctionContext
<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>, payload
: Readonly
<FunctionPayloadType
>, parameter
: Readonly
<FunctionParamsType
>) => Promise
<void
>
Guard is called after command function input validation and before executing the command function. The guard is usefull to separate for example auth checks from business logic. It should throw HandledError or return void.
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | unknown |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<void
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | CommandFunctionContext <MessagePayloadType , MessageParamsType , Invokes , EmitListType > |
payload | Readonly <FunctionPayloadType > |
parameter | Readonly <FunctionParamsType > |
Returns
Promise
<void
>
Defined in
core/types/commandType/CommandBeforeGuardHook.ts:11
CommandDefinition
Ƭ CommandDefinition<ServiceClassType
, MetadataType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
, Invokes
, EmitListType
>: Object
The definition for a command provided by some service.
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass = ServiceClass |
MetadataType | CommandDefinitionMetadataBase |
MessagePayloadType | unknown |
MessageParamsType | unknown |
MessageResultType | unknown |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
Name | Type | Description |
---|---|---|
call | CommandFunction <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType , FunctionResultType , Invokes , EmitListType > | the command function |
commandDescription | string | the description of the command |
commandName | string | the name of the command |
emitList | EmitListType | - |
eventBridgeConfig | DefinitionEventBridgeConfig | config information for event bridge |
eventName? | string | the eventName for the command response |
hooks | { afterGuard? : Record <string , CommandAfterGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionResultType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> ; beforeGuard? : Record <string , CommandBeforeGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> ; transformInput? : { transformFunction : CommandTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > ; transformInputSchema : Schema ; transformParameterSchema : Schema } ; transformOutput? : { transformFunction : CommandTransformOutputHook <ServiceClassType , MessagePayloadType , MessageParamsType , MessageResultType , FunctionResultType , FunctionParamsType > ; transformOutputSchema : Schema } } | hooks of command |
hooks.afterGuard? | Record <string , CommandAfterGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionResultType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> | - |
hooks.beforeGuard? | Record <string , CommandBeforeGuardHook <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> | - |
hooks.transformInput? | { transformFunction : CommandTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > ; transformInputSchema : Schema ; transformParameterSchema : Schema } | - |
hooks.transformInput.transformFunction | CommandTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > | - |
hooks.transformInput.transformInputSchema | Schema | - |
hooks.transformInput.transformParameterSchema | Schema | - |
hooks.transformOutput? | { transformFunction : CommandTransformOutputHook <ServiceClassType , MessagePayloadType , MessageParamsType , MessageResultType , FunctionResultType , FunctionParamsType > ; transformOutputSchema : Schema } | - |
hooks.transformOutput.transformFunction | CommandTransformOutputHook <ServiceClassType , MessagePayloadType , MessageParamsType , MessageResultType , FunctionResultType , FunctionParamsType > | - |
hooks.transformOutput.transformOutputSchema | Schema | - |
invokes | FromInvokeToOtherType <Invokes , { outputSchema? : Schema ; parameterSchema? : Schema ; payloadSchema? : Schema }> | - |
metadata | MetadataType | the metadata of the command |
Defined in
core/types/commandType/CommandDefinition.ts:18
CommandErrorResponse
Ƭ CommandErrorResponse: Prettify
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; correlationId
: CorrelationId
; isHandledError
: boolean
; messageType
: CommandErrorResponse
; payload
: { data?
: unknown
; message
: string
; status
: StatusCode
} ; receiver
: EBMessageSenderAddress
} & EBMessageBase
>
CommandErrorResponse is a response to a specific previously received command which indicates some failure.
Defined in
core/types/commandType/CommandErrorResponse.ts:13
CommandFunction
Ƭ CommandFunction<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: CommandFunctionContext
<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>, payload
: Readonly
<FunctionPayloadType
>, parameter
: Readonly
<FunctionParamsType
>) => Promise
<FunctionResultType
>
CommandFunction is a function which will be triggered when a matching event bridge message is received by the service
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | unknown |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<FunctionResultType
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | CommandFunctionContext <MessagePayloadType , MessageParamsType , Invokes , EmitListType > |
payload | Readonly <FunctionPayloadType > |
parameter | Readonly <FunctionParamsType > |
Returns
Promise
<FunctionResultType
>
Defined in
core/types/commandType/CommandFunction.ts:9
CommandFunctionContext
Ƭ CommandFunctionContext<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>: Prettify
<ContextBase
& CommandFunctionContextEnhancements
<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>>
The command function context which will be passed into command function.
Type parameters
Name | Type |
---|---|
MessagePayloadType | unknown |
MessageParamsType | unknown |
Invokes | {} |
EmitListType | {} |
Defined in
core/types/commandType/CommandFunctionContext.ts:72
CommandFunctionContextEnhancements
Ƭ CommandFunctionContextEnhancements<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>: Object
It provides the original command message with types for payload and parameter. Also, the methods:
emit
which allows to emit custom events to the event bridgeinvoke
which allows to call other commands
Type parameters
Name | Type |
---|---|
MessagePayloadType | unknown |
MessageParamsType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
Name | Type | Description |
---|---|---|
emit | EmitCustomMessageFunction <EmitListType > | emit a custom message |
invoke | InvokeFunction | Deprecated Please use service instead and define the invocations with canInvoke in command builder. Invokes a command and returns the result. It is recommended to validate the result against a schema which only contains the data you actually need. Example typescript const address: EBMessageAddress = { serviceName: 'name-of-service-to-invoke', serviceVersion: '1', serviceTarget: 'command-name-to-invoke', } const inputPayload = { my: 'input' } const inputParameter = { search: 'for_me' } const result = await invoke<MyResultType>(address, inputPayload inputParameter ) |
message | Readonly <Command <MessagePayloadType , MessageParamsType >> | the original message |
service | Invokes | Invokes a command and returns the result. It is recommended to validate the result against a schema which only contains the data you actually need. Example typescript // define your invocation in command builder .canInvoke('ServiceA', '1', 'test', responseOutputSchema, payloadSchema, parameterSchema) .setCommandFunction(async function (context, payload, _parameter) { const inputPayload = { my: 'input' } const inputParameter = { search: 'for_me' } const result = await context.service.ServiceA[1].test(inputPayload,inputParameter) }) |
Defined in
core/types/commandType/CommandFunctionContext.ts:16
CommandResponse
Ƭ CommandResponse<T
>: CommandSuccessResponse
<T
> | CommandErrorResponse
CommandResponse is a response to a specific previously received command which can be either a success or failure
Type parameters
Name | Type |
---|---|
T | unknown |
Defined in
core/types/commandType/CommandResponse.ts:9
CommandSuccessResponse
Ƭ CommandSuccessResponse<PayloadType
>: Prettify
<{ correlationId
: CorrelationId
; messageType
: CommandSuccessResponse
; payload
: PayloadType
; receiver
: EBMessageSenderAddress
} & EBMessageBase
>
CommandSuccessResponse is a response to a specific previously received command. It indicates that the command was executed successfully and contains the result payload
Type parameters
Name | Type |
---|---|
PayloadType | unknown |
Defined in
core/types/commandType/CommandSuccessResponse.ts:13
CommandTransformFunctionContext
Ƭ CommandTransformFunctionContext<PayloadType
, ParameterType
>: Prettify
<ContextBase
& { message
: Readonly
<Command
<PayloadType
, ParameterType
>> }>
Type parameters
Name |
---|
PayloadType |
ParameterType |
Defined in
core/types/commandType/CommandTransformFunctionContext.ts:8
CommandTransformInputHook
Ƭ CommandTransformInputHook<ServiceClassType
, FunctionPayloadOutput
, FunctionParamsOutput
, MessagePayloadInput
, MessageParamsInput
>: (this
: ServiceClassType
, context
: CommandTransformFunctionContext
<MessagePayloadInput
, MessageParamsInput
>, payload
: Readonly
<MessagePayloadInput
>, parameter
: Readonly
<MessageParamsInput
>) => Promise
<{ parameter
: Readonly
<FunctionParamsOutput
> ; payload
: Readonly
<FunctionPayloadOutput
> }>
The command transform gets the raw message payload and parameter input, which is validated against the transform input schemas. The command transform function is called before guard hooks and before the actual command function.
It should throw HandledError or return an object with the transformed payload and parameter. The type of returned payload and parameter must match the command function input for payload and parameter
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClassType |
FunctionPayloadOutput | unknown |
FunctionParamsOutput | unknown |
MessagePayloadInput | unknown |
MessageParamsInput | unknown |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<{ parameter
: Readonly
<FunctionParamsOutput
> ; payload
: Readonly
<FunctionPayloadOutput
> }>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | CommandTransformFunctionContext <MessagePayloadInput , MessageParamsInput > |
payload | Readonly <MessagePayloadInput > |
parameter | Readonly <MessageParamsInput > |
Returns
Promise
<{ parameter
: Readonly
<FunctionParamsOutput
> ; payload
: Readonly
<FunctionPayloadOutput
> }>
Defined in
core/types/commandType/CommandTransformInputHook.ts:12
CommandTransformOutputHook
Ƭ CommandTransformOutputHook<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionResultType
, FunctionParamsType
>: (this
: ServiceClassType
, context
: CommandTransformFunctionContext
<MessagePayloadType
, MessageParamsType
>, commandFunctionOutput
: Readonly
<FunctionResultType
>, commandFunctionInputParameter
: Readonly
<FunctionParamsType
>) => Promise
<MessageResultType
>
This transform hook is executed after function output validation and AfterGuardHooks.
Type parameters
Name |
---|
ServiceClassType |
MessagePayloadType |
MessageParamsType |
MessageResultType |
FunctionResultType |
FunctionParamsType |
Type declaration
▸ (this
, context
, commandFunctionOutput
, commandFunctionInputParameter
): Promise
<MessageResultType
>
Parameters
Name | Type | Description |
---|---|---|
this | ServiceClassType | - |
context | CommandTransformFunctionContext <MessagePayloadType , MessageParamsType > | the Context |
commandFunctionOutput | Readonly <FunctionResultType > | The output result output of command function |
commandFunctionInputParameter | Readonly <FunctionParamsType > | The parameter input given to command function |
Returns
Promise
<MessageResultType
>
Defined in
core/types/commandType/CommandTransformOutputHook.ts:13
isCommand
▸ isCommand(message
): message is Object
Checks if given message is type of Command
Parameters
Name | Type |
---|---|
message | EBMessage |
Returns
message is Object
boolean
Defined in
core/types/commandType/isCommand.impl.ts:12
isCommandErrorResponse
▸ isCommandErrorResponse(message
): message is Object
Checks if given message is type of CommandErrorResponse
Parameters
Name | Type |
---|---|
message | unknown |
Returns
message is Object
boolean
Defined in
core/types/commandType/isCommandErrorResponse.impl.ts:12
isCommandResponse
▸ isCommandResponse(message
): message is CommandResponse
Checks if given message is type of CommandResponse (success or error)
Parameters
Name | Type |
---|---|
message | EBMessage |
Returns
message is CommandResponse
boolean
Defined in
core/types/commandType/isCommandResponse.impl.ts:12
isCommandSuccessResponse
▸ isCommandSuccessResponse(message
): message is Object
Checks if given message is type of CommandSuccessResponse
Parameters
Name | Type |
---|---|
message | EBMessage |
Returns
message is Object
boolean
Defined in
core/types/commandType/isCommandSuccessResponse.impl.ts:12
Event bridge
• DefaultEventBridge: Object
Simple implementation of some simple in-memory event bridge. Does not support threads and does not need any external databases.
Example
import { DefaultEventBridge } from '@purista/core'
const eventBridge = new DefaultEventBridge()
await eventBridge.start()
// add your services
Defined in
DefaultEventBridge/DefaultEventBridge.impl.ts:63
• EventBridgeBaseClass<ConfigType
>: Object
The base class to be extended by event bridge implementations
Type parameters
Name |
---|
ConfigType |
Defined in
core/EventBridge/EventBridgeBaseClass.impl.ts:19
• EventBridge: Object
Event bridge interface The event bridge must implement this interface.
Defined in
core/EventBridge/types/EventBridge.ts:19
EventBridgeEventsBasic
Ƭ EventBridgeEventsBasic: Object
Events which can be emitted by a event bridge
Type declaration
Name | Type | Description |
---|---|---|
eventbridge-connected | never | emitted when then connection to event bridge is established |
eventbridge-connection-error | undefined | unknown | Error | emitted when the connection to event bridge can not be established or a connection has issues or gets closed unexpectedly |
eventbridge-disconnected | never | emitted when the connection to event bridge closed |
eventbridge-error | UnhandledError | unknown | emitted on internal event bridge error |
eventbridge-reconnecting | never | emitted on retry to connect to event bridge |
Defined in
core/EventBridge/types/EventBridgeEvents.ts:20
getCommandQueueName
▸ getCommandQueueName(address
): string
Parameters
Name | Type |
---|---|
address | EBMessageAddress |
Returns
string
Defined in
core/helper/getCommandQueueName.impl.ts:10
Helper
convertToCamelCase
▸ convertToCamelCase(str
): string
Converts a string into camelCase
Parameters
Name | Type | Description |
---|---|---|
str | string | string |
Returns
string
string converted to camelCase
Link
https://github.com/30-seconds/30-seconds-of-code
Defined in
helper/string/convertToCamelCase.impl.ts:9
convertToKebabCase
▸ convertToKebabCase(str
): string
Converts a string into kebab-case
Parameters
Name | Type | Description |
---|---|---|
str | string | string |
Returns
string
string converted to kebab-case
Link
https://github.com/30-seconds/30-seconds-of-code
Defined in
helper/string/convertToKebabCase.impl.ts:9
convertToPascalCase
▸ convertToPascalCase(str
): string
Converts a string into PascalCase
Parameters
Name | Type | Description |
---|---|---|
str | string | string |
Returns
string
string converted to PascalCase
Link
https://github.com/30-seconds/30-seconds-of-code
Defined in
helper/string/convertToPascalCase.impl.ts:9
convertToSnakeCase
▸ convertToSnakeCase(str
): string
Converts a string into snake_case
Parameters
Name | Type | Description |
---|---|---|
str | string | string |
Returns
string
string converted to snake_case
Link
https://github.com/30-seconds/30-seconds-of-code
Defined in
helper/string/convertToSnakeCase.impl.ts:9
createErrorResponse
▸ createErrorResponse(instanceId
, originalEBMessage
, statusCode?
, error?
): Readonly
<Omit
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; correlationId
: string
; eventName?
: string
; id
: string
; isHandledError
: boolean
; messageType
: CommandErrorResponse
; otp?
: string
; payload
: { data?
: unknown
; message
: string
; status
: StatusCode
} ; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}, "instanceId"
>>
Creates a error response object based on original command Toggles sender and receiver
Parameters
Name | Type | Default value |
---|---|---|
instanceId | string | undefined |
originalEBMessage | Readonly <{ contentEncoding : string ; contentType : string ; correlationId : string ; eventName? : string ; id : string ; messageType : Command ; otp? : string ; payload : { parameter : unknown ; payload : unknown } ; principalId? : string ; receiver : EBMessageAddress ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> | undefined |
statusCode | StatusCode | StatusCode.InternalServerError |
error? | unknown | undefined |
Returns
Readonly
<Omit
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; correlationId
: string
; eventName?
: string
; id
: string
; isHandledError
: boolean
; messageType
: CommandErrorResponse
; otp?
: string
; payload
: { data?
: unknown
; message
: string
; status
: StatusCode
} ; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}, "instanceId"
>>
CommandErrorResponse message object
Defined in
core/helper/createErrorResponse.impl.ts:19
createInfoMessage
▸ createInfoMessage(messageType
, sender
, additional?
): InfoMessage
Parameters
Name | Type | Description |
---|---|---|
messageType | InfoMessageType | - |
sender | Object | - |
sender.instanceId | string | instance id of eventbridge |
sender.serviceName | string | the name of the service |
sender.serviceTarget | string | the name of the command or subscription |
sender.serviceVersion | string | the version of the service |
additional? | Partial <InfoMessage > | - |
Returns
Defined in
core/helper/createInfoMessage.impl.ts:14
createSuccessResponse
▸ createSuccessResponse<T
>(instanceId
, originalEBMessage
, payload
, eventName?
, contentType?
, contentEncoding?
): Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: CommandSuccessResponse
; otp?
: string
; payload
: T
; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Type parameters
Name |
---|
T |
Parameters
Name | Type | Default value |
---|---|---|
instanceId | string | undefined |
originalEBMessage | Readonly <{ contentEncoding : string ; contentType : string ; correlationId : string ; eventName? : string ; id : string ; messageType : Command ; otp? : string ; payload : { parameter : unknown ; payload : unknown } ; principalId? : string ; receiver : EBMessageAddress ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> | undefined |
payload | T | undefined |
eventName? | string | undefined |
contentType | string | 'application/json' |
contentEncoding | string | 'utf-8' |
Returns
Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: CommandSuccessResponse
; otp?
: string
; payload
: T
; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Defined in
core/helper/createSuccessResponse.impl.ts:16
deserializeOtp
▸ deserializeOtp(logger
, otp?
): undefined
| Context
Parameters
Name | Type |
---|---|
logger | Logger |
otp? | string |
Returns
undefined
| Context
Defined in
core/helper/serializeOtp.impl.ts:26
getCleanedMessage
▸ getCleanedMessage(message
, stripeOutContent?
): Record
<string
, unknown
>
Helper function for logging. Returns a message object, where fields which might contain sensitive data, are overwritten with string values. For command messages, parameter and payload are overwritten with string values.
For command success responses, the response field is overwritten.
Command error responses are not changed.
Parameters
Name | Type | Default value |
---|---|---|
message | Readonly <EBMessage > | undefined |
stripeOutContent | boolean | !isDevelop() |
Returns
Record
<string
, unknown
>
Defined in
core/helper/getCleanedMessage.impl.ts:16
getErrorMessageForCode
▸ getErrorMessageForCode(code
): string
Parameters
Name | Type |
---|---|
code | StatusCode |
Returns
string
Defined in
core/helper/getErrorMessageForCode.impl.ts:10
getNewCorrelationId
▸ getNewCorrelationId(): string
Create a new unique event bridge correlation id
Returns
string
EBMessageId
Defined in
core/helper/getNewCorrelationId.impl.ts:10
getNewEBMessageId
▸ getNewEBMessageId(): string
Create a new unique event bridge message id
Returns
string
EBMessageId
Defined in
core/helper/getNewEBMessageId.impl.ts:11
getNewInstanceId
▸ getNewInstanceId(): string
Returns
string
Defined in
core/helper/getNewInstanceId.impl.ts:9
getNewTraceId
▸ getNewTraceId(): string
Returns
string
Defined in
core/helper/getNewTraceId.impl.ts:9
getSubscriptionQueueName
▸ getSubscriptionQueueName(address
): string
Parameters
Name | Type |
---|---|
address | EBMessageAddress |
Returns
string
Defined in
core/helper/getSubscriptionQueueName.impl.ts:10
getUniqueId
▸ getUniqueId(): string
Returns
string
Defined in
core/helper/getUniqueId.impl.ts:11
gracefulShutdown
▸ gracefulShutdown(logger
, list
, timeoutMs?
): void
Helps to gracefully shut down your application. Provide in list objects. The objects contains a name and a promise function which should be executed.
The execution of array list functions is done sequential.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
logger | Logger | undefined | the logger object |
list | ShutdownEntry [] | undefined | a object containing name and function |
timeoutMs | number | 30000 | in ms to shut |
Returns
void
Example
const shutDownList = [
{
name: `${serviceA.info.serviceName} version ${serviceA.info.serviceVersion}`,
fn: serviceA.destroy
},
{
name: `${serviceB.info.serviceName} version ${serviceB.info.serviceVersion}`,
fn: serviceB.destroy
},
{
name: eventbridge.name,
fn: eventbridge.destroy
}
]
gracefulShutdown(logger, shutDownList)
// will shutdown ServiceA, then ServiceB, then the event bridge
Default
30000 milliseconds
Defined in
helper/gracefulShutdown.impl.ts:37
isDevelop
▸ isDevelop(): boolean
returns true if NODE_ENV is set to value starting with "develop"
Returns
boolean
Defined in
core/helper/isDevelop.impl.ts:6
serializeOtp
▸ serializeOtp(): string
Returns
string
Defined in
core/helper/serializeOtp.impl.ts:11
Service
• ServiceEventsNames: Object
Events which can be emitted by a service. Internal events are prefixed with service-
Defined in
core/types/ServiceEvents.ts:11
• Service<ConfigType
>: Object
Base class for all services. This class provides base functions to work with the event bridge, logging and so on
Every service should extend this class and should not directly access the eventbridge or other service
class MyService extends Service {
async start() {
await super.start()
// your custom implementation
}
async destroy() {
// your custom implementation
await super.destroy()
}
}
Type parameters
Name | Type |
---|---|
ConfigType | unknown |
Defined in
core/Service/Service.impl.ts:81
• ServiceBuilder<ConfigType
, ConfigInputType
, ServiceClassType
>: Object
This class is used to build a service. The ServiceBuilder
class is used to build a service. It has a few methods that are used to add command definitions and subscription definitions to the service. It also has a method that is used to create an instance of the service class.
Type parameters
Name | Type |
---|---|
ConfigType | Record <string , unknown > |
ConfigInputType | Record <string , unknown > |
ServiceClassType | extends ServiceClass = Service <ConfigType > |
Defined in
ServiceBuilder/ServiceBuilder.impl.ts:40
• ServiceClass<ConfigType
>: Object
The ServiceClass interface
Type parameters
Name | Type |
---|---|
ConfigType | unknown | undefined |
Defined in
ServiceConstructorInput
Ƭ ServiceConstructorInput<ConfigType
>: Object
Type parameters
Name |
---|
ConfigType |
Type declaration
Name | Type | Description |
---|---|---|
commandDefinitionList | CommandDefinitionListResolved <any > | The list of command definitions for this service |
config | ConfigType | The service specific config |
configSchema? | Schema | The config validation schema |
configStore? | ConfigStore | The config store instance |
eventBridge | EventBridge | The eventBridge instance |
info | ServiceInfoType | The service info with name, version and description of service |
logger | Logger | A logger instance |
secretStore? | SecretStore | The secret store instance |
spanProcessor? | SpanProcessor | The opentelemetry span processor instance |
stateStore? | StateStore | the state store instance |
subscriptionDefinitionList | SubscriptionDefinitionListResolved <any > | The list of subscription definitions for this service |
Defined in
core/types/ServiceConstructorInput.ts:16
ServiceEventsInternal
Ƭ ServiceEventsInternal: Object
Events which can be emitted by a service. Internal events are prefixed with service-
.
Response messages, which have an event name assigned, are prefixed with custom-
If you like to use your own events, the event name must be prefixed with misc-
.
Type declaration
Name | Type | Description |
---|---|---|
service-available | undefined | emitted when the service is fully initialized and ready Should be emitted by custom service class. It is not emitted by default |
service-drain | undefined | emitted when the service is going to be stopped |
service-handled-command-error | { commandName : string ; error : HandledError ; traceId? : TraceId } | emitted when a command throws a HandledError |
service-handled-command-error.commandName | string | - |
service-handled-command-error.error | HandledError | - |
service-handled-command-error.traceId? | TraceId | - |
service-handled-subscription-error | { error : HandledError ; subscriptionName : string ; traceId? : TraceId } | emitted when a subscription throws a HandledError |
service-handled-subscription-error.error | HandledError | - |
service-handled-subscription-error.subscriptionName | string | - |
service-handled-subscription-error.traceId? | TraceId | - |
service-not-available | undefined | unknown | emitted when the service is not available (for example database connection could not be established) |
service-started | undefined | emitted when the service is started, but not fully initialized and not ready yet |
service-stopped | undefined | emitted when the service has been stopped |
service-unhandled-command-error | { commandName : string ; error : unknown ; traceId? : TraceId } | emitted when a command throws an error other than a HandledError |
service-unhandled-command-error.commandName | string | - |
service-unhandled-command-error.error | unknown | - |
service-unhandled-command-error.traceId? | TraceId | - |
service-unhandled-subscription-error | { error : unknown ; subscriptionName : string ; traceId? : TraceId } | emitted when a subscription throws an error other than a HandledError |
service-unhandled-subscription-error.error | unknown | - |
service-unhandled-subscription-error.subscriptionName | string | - |
service-unhandled-subscription-error.traceId? | TraceId | - |
Defined in
core/types/ServiceEvents.ts:54
Store
• Abstract
ConfigStoreBaseClass<ConfigStoreConfigType
>: Object
Base class for config store adapters. The actual store implementation must overwrite the protected methods:
getConfigImpl
setConfigImpl
removeConfigImpl
DO NOT OVERWRITE: the regular methods getConfig, setConfig or removeConfig
Type parameters
Name | Type |
---|---|
ConfigStoreConfigType | extends Record <string , unknown > = {} |
Defined in
core/ConfigStore/ConfigStoreBaseClass.impl.ts:20
• DefaultConfigStore: Object
The DefaultConfigStore is a placeholder which offers all needed methods. Getters and setters will throw a UnhandledError with status Unauthorized
, when a disabled operation is called.
For development and testing purpose, you can initiate the store with values.
Example
const store = new DefaultConfigStore({
enableGet: true,
enableRemove: true,
enableSet: true,
config: {
initialValue: 'initial',
},
})
console.log(await store.getConfig('initialValue') // outputs: { initialValue: 'initial' }
Defined in
DefaultConfigStore/DefaultConfigStore.impl.ts:28
• DefaultSecretStore: Object
The DefaultSecretStore is a placeholder which offers all needed methods. Getters and setters will throw a UnhandledError with status Unauthorized
, when a disabled operation is called.
For development and testing purpose, you can initiate the store with values.
Example
const store = new DefaultSecretStore({
config: {
secretOne: 'my_secret_one_value',
secretTwo: 'my_secret_two_value',
}
})
console.log(await store.getSecret('secretOne', 'secretTwo) // outputs: { secretOne: my_secret_one_value, secretTwo: 'my_secret_two_value' }
Per default, setting/changing and removal of values are disabled. You can enable it on instance creation:
Example
const store = new DefaultSecretStore({
enableGet: true,
enableRemove: true,
enableSet: true,
})
Defined in
DefaultSecretStore/DefaultSecretStore.impl.ts:37
• DefaultStateStore: Object
The DefaultStateStore is a placeholder which offers all needed methods. Getters and setters will throw a UnhandledError with status Not implemented
Defined in
DefaultStateStore/DefaultStateStore.impl.ts:13
• Abstract
SecretStoreBaseClass<SecretStoreConfigType
>: Object
Base class for secret store adapters The actual store implementation must overwrite the protected methods:
getSecretImpl
setSecretImpl
removeSecretImpl
DO NOT OVERWRITE: the regular methods getSecret, setSecret or removeSecret
Type parameters
Name | Type |
---|---|
SecretStoreConfigType | extends Record <string , unknown > = {} |
Defined in
core/SecretStore/SecretStoreBaseClass.impl.ts:20
• Abstract
StateStoreBaseClass<StateStoreConfigType
>: Object
Base class for config store implementations The actual store implementation must overwrite the protected methods:
getStateImpl
setStateImpl
removeStateImpl
DO NOT OVERWRITE: the regular methods getState, setState or removeState
Type parameters
Name | Type |
---|---|
StateStoreConfigType | extends Record <string , unknown > = {} |
Defined in
core/StateStore/StateStoreBaseClass.impl.ts:18
• ConfigStore: Object
Interface definition for config store adapters
Defined in
core/ConfigStore/types/ConfigStore.ts:10
• SecretStore: Object
Interface definition for a secret store implementation
Defined in
core/SecretStore/types/SecretStore.ts:9
• StateStore: Object
Interface definition for state store implementations
Defined in
core/StateStore/types/StateStore.ts:10
ConfigDeleteFunction
Ƭ ConfigDeleteFunction: (configName
: string
) => Promise
<void
>
delete a config value from the config store
Type declaration
▸ (configName
): Promise
<void
>
Parameters
Name | Type |
---|---|
configName | string |
Returns
Promise
<void
>
Defined in
core/ConfigStore/types/ConfigDeleteFunction.ts:2
ConfigGetterFunction
Ƭ ConfigGetterFunction: <ConfigNames>(...configNames
: ConfigNames
) => Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
get a config value from the config store
Type declaration
▸ <ConfigNames
>(...configNames
): Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
Type parameters
Name | Type |
---|---|
ConfigNames | extends string [] |
Parameters
Name | Type |
---|---|
...configNames | ConfigNames |
Returns
Promise
<ObjectWithKeysFromStringArray
<ConfigNames
>>
Defined in
core/ConfigStore/types/ConfigGetterFunction.ts:4
ConfigSetterFunction
Ƭ ConfigSetterFunction: (configName
: string
, configValue
: unknown
) => Promise
<void
>
set a config value in the config store
Type declaration
▸ (configName
, configValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
configName | string |
configValue | unknown |
Returns
Promise
<void
>
Defined in
core/ConfigStore/types/ConfigSetterFunction.ts:2
SecretDeleteFunction
Ƭ SecretDeleteFunction: (secretName
: string
) => Promise
<void
>
delete a secret from the secret store
Type declaration
▸ (secretName
): Promise
<void
>
Parameters
Name | Type |
---|---|
secretName | string |
Returns
Promise
<void
>
Defined in
core/SecretStore/types/SecretDeleteFunction.ts:2
SecretGetterFunction
Ƭ SecretGetterFunction: <SecretNames>(...secretNames
: SecretNames
) => Promise
<ObjectWithKeysFromStringArray
<SecretNames
, string
| undefined
>>
get a secret from the secret store
Type declaration
▸ <SecretNames
>(...secretNames
): Promise
<ObjectWithKeysFromStringArray
<SecretNames
, string
| undefined
>>
Type parameters
Name | Type |
---|---|
SecretNames | extends string [] |
Parameters
Name | Type |
---|---|
...secretNames | SecretNames |
Returns
Promise
<ObjectWithKeysFromStringArray
<SecretNames
, string
| undefined
>>
Defined in
core/SecretStore/types/SecretGetterFunction.ts:4
SecretSetterFunction
Ƭ SecretSetterFunction: (secretName
: string
, secretValue
: string
) => Promise
<void
>
set a secret in the secret store
Type declaration
▸ (secretName
, secretValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
secretName | string |
secretValue | string |
Returns
Promise
<void
>
Defined in
core/SecretStore/types/SecretSetterFunction.ts:2
StateDeleteFunction
Ƭ StateDeleteFunction: (stateName
: string
) => Promise
<void
>
delete a state value from the state store
Type declaration
▸ (stateName
): Promise
<void
>
Parameters
Name | Type |
---|---|
stateName | string |
Returns
Promise
<void
>
Defined in
core/StateStore/types/StateDeleteFunction.ts:2
StateGetterFunction
Ƭ StateGetterFunction: <StateNames>(...stateNames
: StateNames
) => Promise
<ObjectWithKeysFromStringArray
<StateNames
>>
get a state value from the state store
Type declaration
▸ <StateNames
>(...stateNames
): Promise
<ObjectWithKeysFromStringArray
<StateNames
>>
Type parameters
Name | Type |
---|---|
StateNames | extends string [] |
Parameters
Name | Type |
---|---|
...stateNames | StateNames |
Returns
Promise
<ObjectWithKeysFromStringArray
<StateNames
>>
Defined in
core/StateStore/types/StateGetterFunction.ts:4
StateSetterFunction
Ƭ StateSetterFunction: (stateName
: string
, stateValue
: unknown
) => Promise
<void
>
set a state value in the state store
Type declaration
▸ (stateName
, stateValue
): Promise
<void
>
Parameters
Name | Type |
---|---|
stateName | string |
stateValue | unknown |
Returns
Promise
<void
>
Defined in
core/StateStore/types/StateSetterFunction.ts:2
Subscription
• SubscriptionDefinitionBuilder<ServiceClassType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, PayloadSchema
, ParameterSchema
, ResultSchema
, Invokes
, EmitListType
>: Object
Subscription definition builder is a helper to create and define a subscriptions for a service. It helps to set all needed filters.
A working schema definition needs at least a subscription name, a short description and the subscription implementation.
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass = ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | undefined |
MessageResultType | void |
PayloadSchema | extends Schema = ZodAny |
ParameterSchema | extends Schema = ZodAny |
ResultSchema | extends Schema = ZodAny |
Invokes | {} |
EmitListType | {} |
Defined in
SubscriptionDefinitionBuilder/SubscriptionDefinitionBuilder.impl.ts:39
Subscription
Ƭ Subscription<PayloadType
, ParameterType
>: Object
A subscription managed by the event bridge
Type parameters
Name | Type |
---|---|
PayloadType | unknown |
ParameterType | unknown |
Type declaration
Name | Type | Description |
---|---|---|
emitEventName? | string | the event name to be used for custom message if the subscriptions returns a result |
eventBridgeConfig | DefinitionEventBridgeConfig | config information for event bridge |
eventName? | string | the event name to subscribe for |
messageType? | EBMessageType | the message type |
payload? | { parameter? : ParameterType ; payload? : PayloadType } | the message payload |
payload.parameter? | ParameterType | - |
payload.payload? | PayloadType | - |
principalId? | PrincipalId | the principal id |
receiver? | { instanceId? : InstanceId ; serviceName? : string ; serviceTarget? : string ; serviceVersion? : string } | the consumer address of the message |
receiver.instanceId? | InstanceId | - |
receiver.serviceName? | string | - |
receiver.serviceTarget? | string | - |
receiver.serviceVersion? | string | - |
sender? | { instanceId? : InstanceId ; serviceName? : string ; serviceTarget? : string ; serviceVersion? : string } | the producer address of the message |
sender.instanceId? | InstanceId | - |
sender.serviceName? | string | - |
sender.serviceTarget? | string | - |
sender.serviceVersion? | string | - |
subscriber | EBMessageAddress | the address of the subscription (service name, version and subscription name) |
tenantId? | TenantId | the tenant id |
Defined in
core/types/subscription/Subscription.ts:13
SubscriptionAfterGuardHook
Ƭ SubscriptionAfterGuardHook<ServiceClassType
, FunctionResultType
, FunctionPayloadOutputType
, FunctionParameterType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: SubscriptionFunctionContext
<Invokes
, EmitListType
>, result
: Readonly
<FunctionResultType
>, payload
: Readonly
<FunctionPayloadOutputType
>, parameter
: Readonly
<FunctionParameterType
>) => Promise
<void
>
Definition of after guard hook functions. This guard is called after function successfully returns and after output validation.
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClass |
FunctionResultType | unknown |
FunctionPayloadOutputType | unknown |
FunctionParameterType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, result
, payload
, parameter
): Promise
<void
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | SubscriptionFunctionContext <Invokes , EmitListType > |
result | Readonly <FunctionResultType > |
payload | Readonly <FunctionPayloadOutputType > |
parameter | Readonly <FunctionParameterType > |
Returns
Promise
<void
>
Defined in
core/types/subscription/SubscriptionAfterGuardHook.ts:10
SubscriptionBeforeGuardHook
Ƭ SubscriptionBeforeGuardHook<ServiceClassType
, FunctionPayloadType
, FunctionParamsType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: SubscriptionFunctionContext
<Invokes
, EmitListType
>, payload
: Readonly
<FunctionPayloadType
>, parameter
: Readonly
<FunctionParamsType
>) => Promise
<void
>
Guard is called after command function input validation and before executing the command function. The guard is usefull to separate for example auth checks from business logic. It should throw HandledError or return void.
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClass |
FunctionPayloadType | unknown |
FunctionParamsType | unknown |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<void
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | SubscriptionFunctionContext <Invokes , EmitListType > |
payload | Readonly <FunctionPayloadType > |
parameter | Readonly <FunctionParamsType > |
Returns
Promise
<void
>
Defined in
core/types/subscription/SubscriptionBeforeGuardHook.ts:11
SubscriptionDefinition
Ƭ SubscriptionDefinition<ServiceClassType
, MetadataType
, MessagePayloadType
, MessageParamsType
, MessageResultType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
, Invokes
, EmitListType
>: Object
The definition for a subscription provided by some service.
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass = ServiceClass |
MetadataType | SubscriptionDefinitionMetadataBase |
MessagePayloadType | unknown |
MessageParamsType | unknown |
MessageResultType | unknown |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | MessageResultType |
Invokes | {} |
EmitListType | {} |
Type declaration
Name | Type | Description |
---|---|---|
call | SubscriptionFunction <ServiceClassType , MessagePayloadType , MessageParamsType , FunctionPayloadType , FunctionParamsType , FunctionResultType , Invokes , EmitListType > | the subscription function |
emitEventName? | string | event name to be used for custom message if the subscription functions returns value |
emitList | EmitListType | - |
eventBridgeConfig | DefinitionEventBridgeConfig | config information for event bridge |
eventName? | string | filter forevent name |
hooks | { afterGuard? : Record <string , SubscriptionAfterGuardHook <ServiceClassType , FunctionResultType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> ; beforeGuard? : Record <string , SubscriptionBeforeGuardHook <ServiceClassType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> ; transformInput? : { transformFunction : SubscriptionTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > ; transformInputSchema : Schema ; transformParameterSchema : Schema } ; transformOutput? : { transformFunction : SubscriptionTransformOutputHook <ServiceClassType , FunctionResultType , FunctionParamsType , any > ; transformOutputSchema : Schema } } | hooks of subscription |
hooks.afterGuard? | Record <string , SubscriptionAfterGuardHook <ServiceClassType , FunctionResultType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> | - |
hooks.beforeGuard? | Record <string , SubscriptionBeforeGuardHook <ServiceClassType , FunctionPayloadType , FunctionParamsType , Invokes , EmitListType >> | - |
hooks.transformInput? | { transformFunction : SubscriptionTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > ; transformInputSchema : Schema ; transformParameterSchema : Schema } | - |
hooks.transformInput.transformFunction | SubscriptionTransformInputHook <ServiceClassType , MessagePayloadType , MessageParamsType > | - |
hooks.transformInput.transformInputSchema | Schema | - |
hooks.transformInput.transformParameterSchema | Schema | - |
hooks.transformOutput? | { transformFunction : SubscriptionTransformOutputHook <ServiceClassType , FunctionResultType , FunctionParamsType , any > ; transformOutputSchema : Schema } | - |
hooks.transformOutput.transformFunction | SubscriptionTransformOutputHook <ServiceClassType , FunctionResultType , FunctionParamsType , any > | - |
hooks.transformOutput.transformOutputSchema | Schema | - |
invokes | FromInvokeToOtherType <Invokes , { outputSchema? : Schema ; parameterSchema? : Schema ; payloadSchema? : Schema }> | - |
messageType? | EBMessageType | filter for message type |
metadata | MetadataType | the metadata of the subscription |
principalId? | PrincipalId | filter for principal id |
receiver? | { instanceId? : InstanceId ; serviceName? : string ; serviceTarget? : string ; serviceVersion? : string } | filter for messages consumed by given receiver |
receiver.instanceId? | InstanceId | - |
receiver.serviceName? | string | - |
receiver.serviceTarget? | string | - |
receiver.serviceVersion? | string | - |
sender? | { instanceId? : InstanceId ; serviceName? : string ; serviceTarget? : string ; serviceVersion? : string } | filter for messages produced by given sender |
sender.instanceId? | InstanceId | - |
sender.serviceName? | string | - |
sender.serviceTarget? | string | - |
sender.serviceVersion? | string | - |
subscriptionDescription | string | the description of the subscription |
subscriptionName | string | the name of the subscription |
tenantId? | TenantId | filter for tenant id |
Defined in
core/types/subscription/SubscriptionDefinition.ts:22
SubscriptionFunction
Ƭ SubscriptionFunction<ServiceClassType
, MessagePayloadType
, MessageParamsType
, FunctionPayloadType
, FunctionParamsType
, FunctionResultType
, Invokes
, EmitListType
>: (this
: ServiceClassType
, context
: SubscriptionFunctionContext
<Invokes
, EmitListType
>, payload
: Readonly
<FunctionPayloadType
>, parameter
: Readonly
<FunctionParamsType
>) => Promise
<FunctionResultType
>
CommandFunction is a function which will be triggered when a matching event bridge message is received by the service
Type parameters
Name | Type |
---|---|
ServiceClassType | extends ServiceClass |
MessagePayloadType | unknown |
MessageParamsType | undefined |
FunctionPayloadType | MessagePayloadType |
FunctionParamsType | MessageParamsType |
FunctionResultType | undefined |
Invokes | {} |
EmitListType | {} |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<FunctionResultType
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | SubscriptionFunctionContext <Invokes , EmitListType > |
payload | Readonly <FunctionPayloadType > |
parameter | Readonly <FunctionParamsType > |
Returns
Promise
<FunctionResultType
>
Defined in
core/types/subscription/SubscriptionFunction.ts:8
SubscriptionFunctionContext
Ƭ SubscriptionFunctionContext<Invokes
, EmitListType
>: Prettify
<ContextBase
& SubscriptionFunctionContextEnhancements
<Invokes
, EmitListType
>>
The subscription function context which will be passed into subscription function.
Type parameters
Name | Type |
---|---|
Invokes | {} |
EmitListType | {} |
Defined in
core/types/subscription/SubscriptionFunctionContext.ts:66
SubscriptionFunctionContextEnhancements
Ƭ SubscriptionFunctionContextEnhancements<Invokes
, EmitListType
>: Object
It provides the original command message. Also, the methods:
emit
which allows to emit custom events to the event bridgeinvoke
which allows to call other commands
Type parameters
Name | Type |
---|---|
Invokes | {} |
EmitListType | {} |
Type declaration
Name | Type | Description |
---|---|---|
emit | EmitCustomMessageFunction <EmitListType > | emit a custom message |
invoke | InvokeFunction | Deprecated Please use service instead and define the invocations with canInvoke in subscription builder. Invokes a command and returns the result. It is recommended to validate the result against a schema which only contains the data you actually need. Example typescript const address: EBMessageAddress = { serviceName: 'name-of-service-to-invoke', serviceVersion: '1', serviceTarget: 'command-name-to-invoke', } const inputPayload = { my: 'input' } const inputParameter = { search: 'for_me' } const result = await invoke<MyResultType>(address, inputPayload inputParameter ) |
message | Readonly <EBMessage > | the original message |
service | Invokes | Invokes a command and returns the result. It is recommended to validate the result against a schema which only contains the data you actually need. Example typescript // define your invocation in subscription builder .canInvoke<{ response: string }>('ServiceA', '1', 'test', payloadSchema, parameterSchema) .setCommandFunction(async function (context, payload, _parameter) { const inputPayload = { my: 'input' } const inputParameter = { search: 'for_me' } const result = await context.service.ServiceA[1].test(inputPayload,inputParameter) }) |
Defined in
core/types/subscription/SubscriptionFunctionContext.ts:16
SubscriptionTransformFunctionContext
Ƭ SubscriptionTransformFunctionContext: Prettify
<ContextBase
& { message
: Readonly
<EBMessage
> }>
Defined in
core/types/subscription/SubscriptionTransformFunctionContext.ts:8
SubscriptionTransformInputHook
Ƭ SubscriptionTransformInputHook<ServiceClassType
, PayloadOutput
, ParamsOutput
, PayloadInput
, ParamsInput
>: (this
: ServiceClassType
, context
: SubscriptionTransformFunctionContext
, payload
: Readonly
<PayloadInput
>, parameter
: Readonly
<ParamsInput
>) => Promise
<{ parameter
: Readonly
<ParamsOutput
> ; payload
: Readonly
<PayloadOutput
> }>
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClassType |
PayloadOutput | unknown |
ParamsOutput | unknown |
PayloadInput | unknown |
ParamsInput | unknown |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<{ parameter
: Readonly
<ParamsOutput
> ; payload
: Readonly
<PayloadOutput
> }>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | SubscriptionTransformFunctionContext |
payload | Readonly <PayloadInput > |
parameter | Readonly <ParamsInput > |
Returns
Promise
<{ parameter
: Readonly
<ParamsOutput
> ; payload
: Readonly
<PayloadOutput
> }>
Defined in
core/types/subscription/SubscriptionTransformInputHook.ts:6
SubscriptionTransformOutputHook
Ƭ SubscriptionTransformOutputHook<ServiceClassType
, MessageResultType
, MessageParamsType
, ResponseOutput
>: (this
: ServiceClassType
, context
: SubscriptionTransformFunctionContext
, payload
: Readonly
<MessageResultType
>, parameter
: Readonly
<MessageParamsType
>) => Promise
<ResponseOutput
>
This transform hook is executed after function output validation and AfterGuardHooks.
Type parameters
Name | Type |
---|---|
ServiceClassType | ServiceClassType |
MessageResultType | unknown |
MessageParamsType | unknown |
ResponseOutput | unknown |
Type declaration
▸ (this
, context
, payload
, parameter
): Promise
<ResponseOutput
>
Parameters
Name | Type |
---|---|
this | ServiceClassType |
context | SubscriptionTransformFunctionContext |
payload | Readonly <MessageResultType > |
parameter | Readonly <MessageParamsType > |
Returns
Promise
<ResponseOutput
>
Defined in
core/types/subscription/SubscriptionTransformOutputHook.ts:8
Unit test helper
getCommandContextMock
▸ getCommandContextMock<MessagePayloadType
, MessageParamsType
, Invokes
, EmitListType
>(payload
, parameter
, sandbox?
, _invokes?
, emitList?
): Object
A function that returns a mock object for command function context
Type parameters
Name | Type |
---|---|
MessagePayloadType | unknown |
MessageParamsType | unknown |
Invokes | {} |
EmitListType | {} |
Parameters
Name | Type |
---|---|
payload | MessagePayloadType |
parameter | MessageParamsType |
sandbox? | SinonSandbox |
_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 > }> |
emitList? | EmitListType |
Returns
Object
Name | Type |
---|---|
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.getConfig | ConfigGetterFunction |
mock.configs.removeConfig | ConfigDeleteFunction |
mock.configs.setConfig | ConfigSetterFunction |
mock.emit | EmitCustomMessageFunction <EmitListType > |
mock.invoke | InvokeFunction |
mock.logger | Logger |
mock.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 }> |
mock.secrets | { getSecret : SecretGetterFunction ; removeSecret : SecretDeleteFunction ; setSecret : SecretSetterFunction } |
mock.secrets.getSecret | SecretGetterFunction |
mock.secrets.removeSecret | SecretDeleteFunction |
mock.secrets.setSecret | SecretSetterFunction |
mock.service | Invokes |
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.getState | StateGetterFunction |
mock.states.removeState | StateDeleteFunction |
mock.states.setState | StateSetterFunction |
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.emit | FromEmitToOtherType <EmitListType , SinonStub <any [], any >> |
stubs.getConfig | SinonStub <any [], any > |
stubs.getSecret | SinonStub <any [], any > |
stubs.getState | SinonStub <any [], any > |
stubs.invoke | SinonStub <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.debug | SinonStub <any [], any > |
stubs.logger.error | SinonStub <any [], any > |
stubs.logger.fatal | SinonStub <any [], any > |
stubs.logger.info | SinonStub <any [], any > |
stubs.logger.trace | SinonStub <any [], any > |
stubs.logger.warn | SinonStub <any [], any > |
stubs.removeConfig | SinonStub <any [], any > |
stubs.removeSecret | SinonStub <any [], any > |
stubs.removeState | SinonStub <any [], any > |
stubs.service | FromInvokeToOtherType <Invokes , SinonStub <any [], any >> |
stubs.setConfig | SinonStub <any [], any > |
stubs.setSecret | SinonStub <any [], any > |
stubs.setState | SinonStub <any [], any > |
stubs.startActiveSpan | SinonStub <any [], any > |
stubs.wrapInSpan | SinonStub <any [], any > |
Defined in
mocks/getCommandContext.mock.ts:19
getCommandErrorMessageMock
▸ getCommandErrorMessageMock(error?
, input?
, commandMessage?
): Readonly
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; correlationId
: string
; eventName?
: string
; id
: string
; isHandledError
: boolean
; messageType
: CommandErrorResponse
; otp?
: string
; payload
: { data?
: unknown
; message
: string
; status
: StatusCode
} ; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
A function that returns a mocked command error response message
Parameters
Name | Type | Description |
---|---|---|
error? | UnhandledError | HandledError | - |
input? | Partial <{ contentEncoding : "utf-8" ; contentType : "application/json" ; correlationId : string ; eventName? : string ; id : string ; isHandledError : boolean ; messageType : CommandErrorResponse ; otp? : string ; payload : { data? : unknown ; message : string ; status : StatusCode } ; principalId? : string ; receiver : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> | - |
commandMessage? | Object | - |
commandMessage.contentEncoding | string | content encoding of message payload |
commandMessage.contentType | string | content type of message payload |
commandMessage.correlationId | string | correlation id to know which command response referrs to which command |
commandMessage.eventName? | string | event name for this message |
commandMessage.id | string | global unique id of message |
commandMessage.messageType | Command | - |
commandMessage.otp? | string | stringified Opentelemetry parent trace id |
commandMessage.payload | Object | - |
commandMessage.payload.parameter | unknown | - |
commandMessage.payload.payload | unknown | - |
commandMessage.principalId? | string | principal id |
commandMessage.receiver | EBMessageAddress | - |
commandMessage.sender | Object | - |
commandMessage.sender.instanceId | string | instance id of eventbridge |
commandMessage.sender.serviceName | string | the name of the service |
commandMessage.sender.serviceTarget | string | the name of the command or subscription |
commandMessage.sender.serviceVersion | string | the version of the service |
commandMessage.tenantId? | string | principal id |
commandMessage.timestamp | number | timestamp of message creation time |
commandMessage.traceId? | string | trace id of message |
Returns
Readonly
<{ contentEncoding
: "utf-8"
; contentType
: "application/json"
; correlationId
: string
; eventName?
: string
; id
: string
; isHandledError
: boolean
; messageType
: CommandErrorResponse
; otp?
: string
; payload
: { data?
: unknown
; message
: string
; status
: StatusCode
} ; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Defined in
mocks/messages/getCommandErrorMessage.mock.ts:16
getCommandMessageMock
▸ getCommandMessageMock<Payload
, Parameter
>(input?
): Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: Command
; otp?
: string
; payload
: { parameter
: Parameter
; payload
: Payload
} ; principalId?
: string
; receiver
: EBMessageAddress
; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
A function that returns a mocked command message.
Type parameters
Name | Type |
---|---|
Payload | unknown |
Parameter | unknown |
Parameters
Name | Type |
---|---|
input? | Partial <{ contentEncoding : string ; contentType : string ; correlationId : string ; eventName? : string ; id : string ; messageType : Command ; otp? : string ; payload : { parameter : Parameter ; payload : Payload } ; principalId? : string ; receiver : EBMessageAddress ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> & { payload? : { parameter? : Parameter ; payload? : Payload } } |
Returns
Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: Command
; otp?
: string
; payload
: { parameter
: Parameter
; payload
: Payload
} ; principalId?
: string
; receiver
: EBMessageAddress
; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Defined in
mocks/messages/getCommandMessage.mock.ts:15
getCommandSuccessMessageMock
▸ getCommandSuccessMessageMock<PayloadType
>(payload
, input?
, commandMessage?
): Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: CommandSuccessResponse
; otp?
: string
; payload
: PayloadType
; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
A function that returns a mocked command success response message.
Type parameters
Name |
---|
PayloadType |
Parameters
Name | Type | Description |
---|---|---|
payload | PayloadType | - |
input? | Partial <{ contentEncoding : string ; contentType : string ; correlationId : string ; eventName? : string ; id : string ; messageType : CommandSuccessResponse ; otp? : string ; payload : PayloadType ; principalId? : string ; receiver : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> | - |
commandMessage? | Object | - |
commandMessage.contentEncoding | string | content encoding of message payload |
commandMessage.contentType | string | content type of message payload |
commandMessage.correlationId | string | correlation id to know which command response referrs to which command |
commandMessage.eventName? | string | event name for this message |
commandMessage.id | string | global unique id of message |
commandMessage.messageType | Command | - |
commandMessage.otp? | string | stringified Opentelemetry parent trace id |
commandMessage.payload | Object | - |
commandMessage.payload.parameter | unknown | - |
commandMessage.payload.payload | unknown | - |
commandMessage.principalId? | string | principal id |
commandMessage.receiver | EBMessageAddress | - |
commandMessage.sender | Object | - |
commandMessage.sender.instanceId | string | instance id of eventbridge |
commandMessage.sender.serviceName | string | the name of the service |
commandMessage.sender.serviceTarget | string | the name of the command or subscription |
commandMessage.sender.serviceVersion | string | the version of the service |
commandMessage.tenantId? | string | principal id |
commandMessage.timestamp | number | timestamp of message creation time |
commandMessage.traceId? | string | trace id of message |
Returns
Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId
: string
; eventName?
: string
; id
: string
; messageType
: CommandSuccessResponse
; otp?
: string
; payload
: PayloadType
; principalId?
: string
; receiver
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Defined in
mocks/messages/getCommandSuccessMessage.mock.ts:10
getCommandTransformContextMock
▸ getCommandTransformContextMock<MessagePayloadType
, MessageParamsType
>(payload
, parameter
, sandbox?
): Object
A function that returns a mock object for command transform function context
Type parameters
Name | Type |
---|---|
MessagePayloadType | unknown |
MessageParamsType | unknown |
Parameters
Name | Type |
---|---|
payload | MessagePayloadType |
parameter | MessageParamsType |
sandbox? | SinonSandbox |
Returns
Object
Name | Type |
---|---|
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.getConfig | ConfigGetterFunction |
mock.configs.removeConfig | ConfigDeleteFunction |
mock.configs.setConfig | ConfigSetterFunction |
mock.logger | Logger |
mock.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 }> |
mock.secrets | { getSecret : SecretGetterFunction ; removeSecret : SecretDeleteFunction ; setSecret : SecretSetterFunction } |
mock.secrets.getSecret | SecretGetterFunction |
mock.secrets.removeSecret | SecretDeleteFunction |
mock.secrets.setSecret | SecretSetterFunction |
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.getState | StateGetterFunction |
mock.states.removeState | StateDeleteFunction |
mock.states.setState | StateSetterFunction |
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.getConfig | SinonStub <any [], any > |
stubs.getSecret | SinonStub <any [], any > |
stubs.getState | SinonStub <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.debug | SinonStub <any [], any > |
stubs.logger.error | SinonStub <any [], any > |
stubs.logger.fatal | SinonStub <any [], any > |
stubs.logger.info | SinonStub <any [], any > |
stubs.logger.trace | SinonStub <any [], any > |
stubs.logger.warn | SinonStub <any [], any > |
stubs.removeConfig | SinonStub <any [], any > |
stubs.removeSecret | SinonStub <any [], any > |
stubs.removeState | SinonStub <any [], any > |
stubs.setConfig | SinonStub <any [], any > |
stubs.setSecret | SinonStub <any [], any > |
stubs.setState | SinonStub <any [], any > |
stubs.startActiveSpan | SinonStub <any [], any > |
stubs.wrapInSpan | SinonStub <any [], any > |
Defined in
mocks/getCommandTransformContext.mock.ts:13
getCustomMessageMessageMock
▸ getCustomMessageMessageMock<PayloadType
>(eventName
, payload
, input?
): Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId?
: string
; eventName
: string
; id
: string
; messageType
: CustomMessage
; otp?
: string
; payload?
: PayloadType
; principalId?
: string
; receiver?
: EBMessageAddress
; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
A function that returns a mocked custom message.
Type parameters
Name |
---|
PayloadType |
Parameters
Name | Type |
---|---|
eventName | string |
payload | PayloadType |
input? | Partial <{ contentEncoding : string ; contentType : string ; correlationId? : string ; eventName : string ; id : string ; messageType : CustomMessage ; otp? : string ; payload? : PayloadType ; principalId? : string ; receiver? : EBMessageAddress ; sender : { instanceId : string ; serviceName : string ; serviceTarget : string ; serviceVersion : string } ; tenantId? : string ; timestamp : number ; traceId? : string }> |
Returns
Readonly
<{ contentEncoding
: string
; contentType
: string
; correlationId?
: string
; eventName
: string
; id
: string
; messageType
: CustomMessage
; otp?
: string
; payload?
: PayloadType
; principalId?
: string
; receiver?
: EBMessageAddress
; sender
: { instanceId
: string
; serviceName
: string
; serviceTarget
: string
; serviceVersion
: string
} ; tenantId?
: string
; timestamp
: number
; traceId?
: string
}>
Defined in
mocks/messages/getCustomMessage.mock.ts:15
getEventBridgeMock
▸ getEventBridgeMock(sandbox?
): Object
Mocks the eventBridge and stubs the methods
Parameters
Name | Type |
---|---|
sandbox? | SinonSandbox |
Returns
Object
EventBridge mocked
Name | Type |
---|---|
mock | EventBridge |
stubs | Record <string , SinonStub <any [], any >> |
Defined in
mocks/getEventBridge.mock.ts:11
getLoggerMock
▸ getLoggerMock(sandbox?
): Object
Mocks the logger and methods are stubs
Parameters
Name | Type |
---|---|
sandbox? | SinonSandbox |
Returns
Object
logger mocked
Name | Type |
---|---|
mock | Logger |
stubs | { 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.debug | SinonStub <any [], any > |
stubs.error | SinonStub <any [], any > |
stubs.fatal | SinonStub <any [], any > |
stubs.info | SinonStub <any [], any > |
stubs.trace | SinonStub <any [], any > |
stubs.warn | SinonStub <any [], any > |
Defined in
getSubscriptionContextMock
▸ getSubscriptionContextMock<Invokes
, EmitListType
>(message
, sandbox?
, _invokes?
, emitList?
): Object
A function that returns a mock object for subscription function context
Type parameters
Name | Type |
---|---|
Invokes | {} |
EmitListType | {} |
Parameters
Name | Type |
---|---|
message | EBMessage |
sandbox? | SinonSandbox |
_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 > }> |
emitList? | EmitListType |
Returns
Object
Name | Type |
---|---|
mock | { configs : { getConfig : ConfigGetterFunction ; removeConfig : ConfigDeleteFunction ; setConfig : ConfigSetterFunction } ; emit : EmitCustomMessageFunction <{}> ; invoke : InvokeFunction ; logger : Logger ; message : Readonly <EBMessage > ; 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.getConfig | ConfigGetterFunction |
mock.configs.removeConfig | ConfigDeleteFunction |
mock.configs.setConfig | ConfigSetterFunction |
mock.emit | EmitCustomMessageFunction <{}> |
mock.invoke | InvokeFunction |
mock.logger | Logger |
mock.message | Readonly <EBMessage > |
mock.secrets | { getSecret : SecretGetterFunction ; removeSecret : SecretDeleteFunction ; setSecret : SecretSetterFunction } |
mock.secrets.getSecret | SecretGetterFunction |
mock.secrets.removeSecret | SecretDeleteFunction |
mock.secrets.setSecret | SecretSetterFunction |
mock.service | Invokes |
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.getState | StateGetterFunction |
mock.states.removeState | StateDeleteFunction |
mock.states.setState | StateSetterFunction |
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.emit | FromEmitToOtherType <EmitListType , SinonStub <any [], any >> |
stubs.getConfig | SinonStub <any [], any > |
stubs.getSecret | SinonStub <any [], any > |
stubs.getState | SinonStub <any [], any > |
stubs.invoke | SinonStub <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.debug | SinonStub <any [], any > |
stubs.logger.error | SinonStub <any [], any > |
stubs.logger.fatal | SinonStub <any [], any > |
stubs.logger.info | SinonStub <any [], any > |
stubs.logger.trace | SinonStub <any [], any > |
stubs.logger.warn | SinonStub <any [], any > |
stubs.removeConfig | SinonStub <any [], any > |
stubs.removeSecret | SinonStub <any [], any > |
stubs.removeState | SinonStub <any [], any > |
stubs.service | FromInvokeToOtherType <Invokes , SinonStub <any [], any >> |
stubs.setConfig | SinonStub <any [], any > |
stubs.setSecret | SinonStub <any [], any > |
stubs.setState | SinonStub <any [], any > |
stubs.startActiveSpan | SinonStub <any [], any > |
stubs.wrapInSpan | SinonStub <any [], any > |
Defined in
mocks/getSubscriptionContext.mock.ts:19
getSubscriptionTransformContextMock
▸ getSubscriptionTransformContextMock(message
, sandbox?
): Object
A function that returns a mock object for subscription transform function context
Parameters
Name | Type |
---|---|
message | EBMessage |
sandbox? | SinonSandbox |
Returns
Object
Name | Type |
---|---|
mock | { configs : { getConfig : ConfigGetterFunction ; removeConfig : ConfigDeleteFunction ; setConfig : ConfigSetterFunction } ; logger : Logger ; message : Readonly <EBMessage > ; 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.getConfig | ConfigGetterFunction |
mock.configs.removeConfig | ConfigDeleteFunction |
mock.configs.setConfig | ConfigSetterFunction |
mock.logger | Logger |
mock.message | Readonly <EBMessage > |
mock.secrets | { getSecret : SecretGetterFunction ; removeSecret : SecretDeleteFunction ; setSecret : SecretSetterFunction } |
mock.secrets.getSecret | SecretGetterFunction |
mock.secrets.removeSecret | SecretDeleteFunction |
mock.secrets.setSecret | SecretSetterFunction |
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.getState | StateGetterFunction |
mock.states.removeState | StateDeleteFunction |
mock.states.setState | StateSetterFunction |
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.getConfig | SinonStub <any [], any > |
stubs.getSecret | SinonStub <any [], any > |
stubs.getState | SinonStub <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.debug | SinonStub <any [], any > |
stubs.logger.error | SinonStub <any [], any > |
stubs.logger.fatal | SinonStub <any [], any > |
stubs.logger.info | SinonStub <any [], any > |
stubs.logger.trace | SinonStub <any [], any > |
stubs.logger.warn | SinonStub <any [], any > |
stubs.removeConfig | SinonStub <any [], any > |
stubs.removeSecret | SinonStub <any [], any > |
stubs.removeState | SinonStub <any [], any > |
stubs.setConfig | SinonStub <any [], any > |
stubs.setSecret | SinonStub <any [], any > |
stubs.setState | SinonStub <any [], any > |
stubs.startActiveSpan | SinonStub <any [], any > |
stubs.wrapInSpan | SinonStub <any [], any > |