@message-queue-toolkit/core 9.0.1 → 9.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,8 +13,8 @@ export type QueueConsumerDependencies = {
|
|
|
13
13
|
transactionObservabilityManager: TransactionObservabilityManager;
|
|
14
14
|
};
|
|
15
15
|
export type Deserializer<MessagePayloadType extends object> = (message: unknown, type: ZodType<MessagePayloadType>, errorProcessor: ErrorResolver) => Either<MessageInvalidFormatError | MessageValidationError, MessagePayloadType>;
|
|
16
|
-
export type NewQueueOptionsMultiSchema<MessagePayloadSchemas extends object, CreationConfigType extends object, ExecutionContext, PrehandlerOutput> = NewQueueOptions<CreationConfigType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>;
|
|
17
|
-
export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext, PrehandlerOutput> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>;
|
|
16
|
+
export type NewQueueOptionsMultiSchema<MessagePayloadSchemas extends object, CreationConfigType extends object, ExecutionContext, PrehandlerOutput = undefined> = NewQueueOptions<CreationConfigType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>;
|
|
17
|
+
export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext, PrehandlerOutput = undefined> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>;
|
|
18
18
|
export type DeletionConfig = {
|
|
19
19
|
deleteIfExists?: boolean;
|
|
20
20
|
waitForConfirmation?: boolean;
|
|
@@ -42,7 +42,7 @@ export type ExistingQueueOptions<QueueLocatorType extends object> = {
|
|
|
42
42
|
export type MultiSchemaPublisherOptions<MessagePayloadSchemas extends object> = {
|
|
43
43
|
messageSchemas: readonly ZodSchema<MessagePayloadSchemas>[];
|
|
44
44
|
};
|
|
45
|
-
export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> = {
|
|
45
|
+
export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> = {
|
|
46
46
|
handlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[];
|
|
47
47
|
};
|
|
48
48
|
export type MonoSchemaQueueOptions<MessagePayloadType extends object> = {
|
|
@@ -2,7 +2,7 @@ import type { Either } from '@lokalise/node-core';
|
|
|
2
2
|
import type { ZodSchema } from 'zod';
|
|
3
3
|
import type { DoNotProcessMessageError } from '../errors/DoNotProcessError';
|
|
4
4
|
import type { RetryMessageLaterError } from '../errors/RetryMessageLaterError';
|
|
5
|
-
export type PrehandlingOutputs<PrehandlerOutput, BarrierOutput> = {
|
|
5
|
+
export type PrehandlingOutputs<PrehandlerOutput = undefined, BarrierOutput = undefined> = {
|
|
6
6
|
prehandlerOutput: PrehandlerOutput;
|
|
7
7
|
barrierOutput: BarrierOutput;
|
|
8
8
|
};
|
|
@@ -20,12 +20,12 @@ export type PrehandlerResult = Either<DoNotProcessMessageError | RetryMessageLat
|
|
|
20
20
|
export type BarrierCallbackMultiConsumers<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput, BarrierOutput> = (message: MessagePayloadSchema, context: ExecutionContext, prehandlerOutput: PrehandlerOutput) => Promise<BarrierResult<BarrierOutput>>;
|
|
21
21
|
export type Prehandler<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput> = (message: MessagePayloadSchema, context: ExecutionContext, prehandlerOutput: Partial<PrehandlerOutput>, next: (result: PrehandlerResult) => void) => void;
|
|
22
22
|
export declare const defaultLogFormatter: <MessagePayloadSchema>(message: MessagePayloadSchema) => MessagePayloadSchema;
|
|
23
|
-
export type HandlerConfigOptions<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput, BarrierOutput> = {
|
|
23
|
+
export type HandlerConfigOptions<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = {
|
|
24
24
|
messageLogFormatter?: LogFormatter<MessagePayloadSchema>;
|
|
25
25
|
preHandlerBarrier?: BarrierCallbackMultiConsumers<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
26
26
|
prehandlers?: Prehandler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput>[];
|
|
27
27
|
};
|
|
28
|
-
export declare class MessageHandlerConfig<const MessagePayloadSchema extends object, const ExecutionContext, const PrehandlerOutput =
|
|
28
|
+
export declare class MessageHandlerConfig<const MessagePayloadSchema extends object, const ExecutionContext, const PrehandlerOutput = undefined, const BarrierOutput = undefined> {
|
|
29
29
|
readonly schema: ZodSchema<MessagePayloadSchema>;
|
|
30
30
|
readonly handler: Handler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
31
31
|
readonly messageLogFormatter: LogFormatter<MessagePayloadSchema>;
|
|
@@ -33,21 +33,21 @@ export declare class MessageHandlerConfig<const MessagePayloadSchema extends obj
|
|
|
33
33
|
readonly prehandlers?: Prehandler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput>[];
|
|
34
34
|
constructor(schema: ZodSchema<MessagePayloadSchema>, handler: Handler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>, options?: HandlerConfigOptions<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>);
|
|
35
35
|
}
|
|
36
|
-
export declare class MessageHandlerConfigBuilder<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> {
|
|
36
|
+
export declare class MessageHandlerConfigBuilder<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutputs = undefined> {
|
|
37
37
|
private readonly configs;
|
|
38
38
|
constructor();
|
|
39
39
|
addConfig<MessagePayloadSchema extends MessagePayloadSchemas, const BarrierOutput>(schema: ZodSchema<MessagePayloadSchema>, handler: Handler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>, options?: HandlerConfigOptions<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>): this;
|
|
40
|
-
build(): MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput,
|
|
40
|
+
build(): MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutputs>[];
|
|
41
41
|
}
|
|
42
42
|
export type Handler<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = (message: MessagePayloadSchemas, context: ExecutionContext, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, BarrierOutput>) => Promise<Either<'retryLater', 'success'>>;
|
|
43
|
-
export type HandlerContainerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> = {
|
|
44
|
-
messageHandlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput,
|
|
43
|
+
export type HandlerContainerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutput = undefined> = {
|
|
44
|
+
messageHandlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutput>[];
|
|
45
45
|
messageTypeField: string;
|
|
46
46
|
};
|
|
47
|
-
export declare class HandlerContainer<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput> {
|
|
47
|
+
export declare class HandlerContainer<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined, BarrierOutputs = undefined> {
|
|
48
48
|
private readonly messageHandlers;
|
|
49
49
|
private readonly messageTypeField;
|
|
50
50
|
constructor(options: HandlerContainerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>);
|
|
51
|
-
resolveHandler<
|
|
51
|
+
resolveHandler<PrehandlerOutput = undefined, BarrierOutput = undefined>(messageType: string): MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
52
52
|
private resolveHandlerMap;
|
|
53
53
|
}
|
|
@@ -24,7 +24,9 @@ class MessageHandlerConfigBuilder {
|
|
|
24
24
|
this.configs = [];
|
|
25
25
|
}
|
|
26
26
|
addConfig(schema, handler, options) {
|
|
27
|
-
this.configs.push(
|
|
27
|
+
this.configs.push(
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
new MessageHandlerConfig(schema,
|
|
28
30
|
// @ts-ignore
|
|
29
31
|
handler, options));
|
|
30
32
|
return this;
|
|
@@ -47,12 +49,14 @@ class HandlerContainer {
|
|
|
47
49
|
throw new Error(`Unsupported message type: ${messageType}`);
|
|
48
50
|
}
|
|
49
51
|
// @ts-ignore
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
50
53
|
return handler;
|
|
51
54
|
}
|
|
52
55
|
resolveHandlerMap(supportedHandlers) {
|
|
53
56
|
return supportedHandlers.reduce((acc, entry) => {
|
|
54
57
|
// @ts-ignore
|
|
55
58
|
const messageType = entry.schema.shape[this.messageTypeField].value;
|
|
59
|
+
// @ts-ignore
|
|
56
60
|
acc[messageType] = entry;
|
|
57
61
|
return acc;
|
|
58
62
|
}, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandlerContainer.js","sourceRoot":"","sources":["../../../lib/queues/HandlerContainer.ts"],"names":[],"mappings":";;;AA+CO,MAAM,mBAAmB,GAAG,CAAuB,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAA;AAAtF,QAAA,mBAAmB,uBAAmE;AAkBnG,MAAa,oBAAoB;IAMf,MAAM,CAAiC;IACvC,OAAO,CAKtB;IACe,mBAAmB,CAAoC;IACvD,iBAAiB,CAKhC;IACe,WAAW,CAIxB;IAEH,YACE,MAAuC,EACvC,OAAyF,EACzF,OAKC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,mBAAmB,GAAG,OAAO,EAAE,mBAAmB,IAAI,2BAAmB,CAAA;QAC9E,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,CAAA;IACzC,CAAC;CACF;AA1CD,oDA0CC;AAED,MAAa,2BAA2B;
|
|
1
|
+
{"version":3,"file":"HandlerContainer.js","sourceRoot":"","sources":["../../../lib/queues/HandlerContainer.ts"],"names":[],"mappings":";;;AA+CO,MAAM,mBAAmB,GAAG,CAAuB,OAA6B,EAAE,EAAE,CAAC,OAAO,CAAA;AAAtF,QAAA,mBAAmB,uBAAmE;AAkBnG,MAAa,oBAAoB;IAMf,MAAM,CAAiC;IACvC,OAAO,CAKtB;IACe,mBAAmB,CAAoC;IACvD,iBAAiB,CAKhC;IACe,WAAW,CAIxB;IAEH,YACE,MAAuC,EACvC,OAAyF,EACzF,OAKC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,mBAAmB,GAAG,OAAO,EAAE,mBAAmB,IAAI,2BAAmB,CAAA;QAC9E,IAAI,CAAC,iBAAiB,GAAG,OAAO,EAAE,iBAAiB,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,CAAA;IACzC,CAAC;CACF;AA1CD,oDA0CC;AAED,MAAa,2BAA2B;IAMrB,OAAO,CAKrB;IAEH;QACE,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;IAED,SAAS,CACP,MAAuC,EACvC,OAAyF,EACzF,OAKC;QAED,IAAI,CAAC,OAAO,CAAC,IAAI;QACf,aAAa;QACb,IAAI,oBAAoB,CAMtB,MAAM;QACN,aAAa;QACb,OAAO,EACP,OAAO,CACR,CACF,CAAA;QACD,OAAO,IAAI,CAAA;IACb,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;CACF;AA/CD,kEA+CC;AA4BD,MAAa,gBAAgB;IAMV,eAAe,CAG/B;IACgB,gBAAgB,CAAQ;IAEzC,YACE,OAA2F;QAE3F,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QAChD,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAC,eAAe,CAAC,CAAA;IACxE,CAAC;IAEM,cAAc,CACnB,WAAmB;QAOnB,MAAM,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC,CAAA;QACjD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,6BAA6B,WAAW,EAAE,CAAC,CAAA;QAC7D,CAAC;QACD,aAAa;QACb,+DAA+D;QAC/D,OAAO,OAAO,CAAA;IAChB,CAAC;IAEO,iBAAiB,CACvB,iBAIG;QAKH,OAAO,iBAAiB,CAAC,MAAM,CAC7B,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;YACb,aAAa;YACb,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAA;YACnE,aAAa;YACb,GAAG,CAAC,WAAW,CAAC,GAAG,KAAK,CAAA;YACxB,OAAO,GAAG,CAAA;QACZ,CAAC,EACD,EAQC,CACF,CAAA;IACH,CAAC;CACF;AAjED,4CAiEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@message-queue-toolkit/core",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.3",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "Useful utilities, interfaces and base classes for message queue handling. Supports AMQP and SQS with a common abstraction on top currently",
|