@message-queue-toolkit/core
Advanced tools
Comparing version 9.0.1 to 9.0.2
@@ -16,4 +16,4 @@ import type { ErrorReporter, ErrorResolver, Either } from '@lokalise/node-core'; | ||
export type Deserializer<MessagePayloadType extends object> = (message: unknown, type: ZodType<MessagePayloadType>, errorProcessor: ErrorResolver) => Either<MessageInvalidFormatError | MessageValidationError, MessagePayloadType>; | ||
export type NewQueueOptionsMultiSchema<MessagePayloadSchemas extends object, CreationConfigType extends object, ExecutionContext, PrehandlerOutput> = NewQueueOptions<CreationConfigType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>; | ||
export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext, PrehandlerOutput> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>; | ||
export type NewQueueOptionsMultiSchema<MessagePayloadSchemas extends object, CreationConfigType extends object, ExecutionContext, PrehandlerOutput = undefined> = NewQueueOptions<CreationConfigType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>; | ||
export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext, PrehandlerOutput = undefined> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>; | ||
export type DeletionConfig = { | ||
@@ -46,3 +46,3 @@ deleteIfExists?: boolean; | ||
}; | ||
export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> = { | ||
export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> = { | ||
handlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[]; | ||
@@ -49,0 +49,0 @@ }; |
@@ -5,3 +5,3 @@ import type { Either } from '@lokalise/node-core'; | ||
import type { RetryMessageLaterError } from '../errors/RetryMessageLaterError'; | ||
export type PrehandlingOutputs<PrehandlerOutput, BarrierOutput> = { | ||
export type PrehandlingOutputs<PrehandlerOutput = undefined, BarrierOutput = undefined> = { | ||
prehandlerOutput: PrehandlerOutput; | ||
@@ -24,3 +24,3 @@ barrierOutput: BarrierOutput; | ||
export declare const defaultLogFormatter: <MessagePayloadSchema>(message: MessagePayloadSchema) => MessagePayloadSchema; | ||
export type HandlerConfigOptions<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput, BarrierOutput> = { | ||
export type HandlerConfigOptions<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = { | ||
messageLogFormatter?: LogFormatter<MessagePayloadSchema>; | ||
@@ -30,3 +30,3 @@ preHandlerBarrier?: BarrierCallbackMultiConsumers<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>; | ||
}; | ||
export declare class MessageHandlerConfig<const MessagePayloadSchema extends object, const ExecutionContext, const PrehandlerOutput = unknown, const BarrierOutput = unknown> { | ||
export declare class MessageHandlerConfig<const MessagePayloadSchema extends object, const ExecutionContext, const PrehandlerOutput = undefined, const BarrierOutput = undefined> { | ||
readonly schema: ZodSchema<MessagePayloadSchema>; | ||
@@ -46,12 +46,12 @@ readonly handler: Handler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>; | ||
export type Handler<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = (message: MessagePayloadSchemas, context: ExecutionContext, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, BarrierOutput>) => Promise<Either<'retryLater', 'success'>>; | ||
export type HandlerContainerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> = { | ||
messageHandlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, unknown>[]; | ||
export type HandlerContainerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = { | ||
messageHandlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutput>[]; | ||
messageTypeField: string; | ||
}; | ||
export declare class HandlerContainer<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> { | ||
export declare class HandlerContainer<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> { | ||
private readonly messageHandlers; | ||
private readonly messageTypeField; | ||
constructor(options: HandlerContainerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>); | ||
resolveHandler<BarrierResult, PrehandlerOutput>(messageType: string): MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierResult>; | ||
resolveHandler<PrehandlerOutput = undefined, BarrierOutput = undefined>(messageType: string): MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutput>; | ||
private resolveHandlerMap; | ||
} |
@@ -50,2 +50,3 @@ "use strict"; | ||
// @ts-ignore | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-return | ||
return handler; | ||
@@ -57,2 +58,3 @@ } | ||
const messageType = entry.schema.shape[this.messageTypeField].value; | ||
// @ts-ignore | ||
acc[messageType] = entry; | ||
@@ -59,0 +61,0 @@ return acc; |
{ | ||
"name": "@message-queue-toolkit/core", | ||
"version": "9.0.1", | ||
"version": "9.0.2", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
57594
813