@message-queue-toolkit/core 9.1.0 → 10.0.0
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.
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/queues/AbstractQueueService.d.ts +10 -50
- package/dist/lib/queues/AbstractQueueService.js +11 -0
- package/dist/lib/queues/AbstractQueueService.js.map +1 -1
- package/dist/lib/queues/HandlerContainer.d.ts +3 -3
- package/dist/lib/queues/HandlerSpy.d.ts +1 -1
- package/dist/lib/queues/HandlerSpy.js.map +1 -1
- package/dist/lib/types/queueOptionsTypes.d.ts +45 -0
- package/dist/lib/types/queueOptionsTypes.js +3 -0
- package/dist/lib/types/queueOptionsTypes.js.map +1 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
export type { QueueConsumer, AsyncPublisher, SyncPublisher, TransactionObservabilityManager, Logger, LogFn, SchemaMap, ExtraParams, } from './lib/types/MessageQueueTypes';
|
|
2
|
-
export { AbstractQueueService } from './lib/queues/AbstractQueueService';
|
|
3
|
-
export
|
|
2
|
+
export { AbstractQueueService, Deserializer } from './lib/queues/AbstractQueueService';
|
|
3
|
+
export * from './lib/types/queueOptionsTypes';
|
|
4
4
|
export { isMessageError, MessageValidationError, MessageInvalidFormatError, } from './lib/errors/Errors';
|
|
5
5
|
export { isShallowSubset, objectMatches } from './lib/utils/matchUtils';
|
|
6
6
|
export { RetryMessageLaterError } from './lib/errors/RetryMessageLaterError';
|
|
7
7
|
export { DoNotProcessMessageError } from './lib/errors/DoNotProcessError';
|
|
8
8
|
export { HandlerContainer, MessageHandlerConfig, MessageHandlerConfigBuilder, } from './lib/queues/HandlerContainer';
|
|
9
|
-
export type {
|
|
9
|
+
export type { BarrierCallback, BarrierResult, BarrierResultPositive, BarrierResultNegative, HandlerContainerOptions, Handler, Prehandler, PrehandlingOutputs, } from './lib/queues/HandlerContainer';
|
|
10
10
|
export { HandlerSpy } from './lib/queues/HandlerSpy';
|
|
11
11
|
export type { SpyResult, HandlerSpyParams, PublicHandlerSpy } from './lib/queues/HandlerSpy';
|
|
12
12
|
export { MessageSchemaContainer } from './lib/queues/MessageSchemaContainer';
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isProduction = exports.reloadConfig = exports.parseMessage = exports.waitAndRetry = exports.objectToBuffer = exports.MessageSchemaContainer = exports.HandlerSpy = exports.MessageHandlerConfigBuilder = exports.MessageHandlerConfig = exports.HandlerContainer = exports.DoNotProcessMessageError = exports.RetryMessageLaterError = exports.objectMatches = exports.isShallowSubset = exports.MessageInvalidFormatError = exports.MessageValidationError = exports.isMessageError = exports.AbstractQueueService = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
var AbstractQueueService_1 = require("./lib/queues/AbstractQueueService");
|
|
5
6
|
Object.defineProperty(exports, "AbstractQueueService", { enumerable: true, get: function () { return AbstractQueueService_1.AbstractQueueService; } });
|
|
7
|
+
tslib_1.__exportStar(require("./lib/types/queueOptionsTypes"), exports);
|
|
6
8
|
var Errors_1 = require("./lib/errors/Errors");
|
|
7
9
|
Object.defineProperty(exports, "isMessageError", { enumerable: true, get: function () { return Errors_1.isMessageError; } });
|
|
8
10
|
Object.defineProperty(exports, "MessageValidationError", { enumerable: true, get: function () { return Errors_1.MessageValidationError; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;AAWA,0EAAsF;AAA7E,4HAAA,oBAAoB,OAAA;AAC7B,wEAA6C;AAE7C,8CAI4B;AAH1B,wGAAA,cAAc,OAAA;AACd,gHAAA,sBAAsB,OAAA;AACtB,mHAAA,yBAAyB,OAAA;AAG3B,qDAAuE;AAA9D,6GAAA,eAAe,OAAA;AAAE,2GAAA,aAAa,OAAA;AAEvC,8EAA4E;AAAnE,gIAAA,sBAAsB,OAAA;AAE/B,oEAAyE;AAAhE,6HAAA,wBAAwB,OAAA;AAEjC,kEAIsC;AAHpC,oHAAA,gBAAgB,OAAA;AAChB,wHAAA,oBAAoB,OAAA;AACpB,+HAAA,2BAA2B,OAAA;AAY7B,sDAAoD;AAA3C,wGAAA,UAAU,OAAA;AAGnB,8EAA4E;AAAnE,gIAAA,sBAAsB,OAAA;AAG/B,qDAAuD;AAA9C,4GAAA,cAAc,OAAA;AACvB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA;AACrB,qDAAqD;AAA5C,0GAAA,YAAY,OAAA;AAErB,iDAAiE;AAAxD,wGAAA,YAAY,OAAA;AAAE,wGAAA,YAAY,OAAA"}
|
|
@@ -1,57 +1,15 @@
|
|
|
1
1
|
import type { ErrorReporter, ErrorResolver, Either } from '@lokalise/node-core';
|
|
2
2
|
import type { ZodSchema, ZodType } from 'zod';
|
|
3
3
|
import type { MessageInvalidFormatError, MessageValidationError } from '../errors/Errors';
|
|
4
|
-
import type { Logger,
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
|
|
8
|
-
errorReporter: ErrorReporter;
|
|
9
|
-
logger: Logger;
|
|
10
|
-
};
|
|
11
|
-
export type QueueConsumerDependencies = {
|
|
12
|
-
consumerErrorResolver: ErrorResolver;
|
|
13
|
-
transactionObservabilityManager: TransactionObservabilityManager;
|
|
14
|
-
};
|
|
4
|
+
import type { Logger, MessageProcessingResult } from '../types/MessageQueueTypes';
|
|
5
|
+
import type { DeletionConfig, QueueDependencies, QueueOptions } from '../types/queueOptionsTypes';
|
|
6
|
+
import type { BarrierCallback, BarrierResult, Prehandler, PrehandlerResult, PrehandlingOutputs } from './HandlerContainer';
|
|
7
|
+
import type { HandlerSpy, PublicHandlerSpy } from './HandlerSpy';
|
|
15
8
|
export type Deserializer<MessagePayloadType extends object> = (message: unknown, type: ZodType<MessagePayloadType>, errorProcessor: ErrorResolver) => Either<MessageInvalidFormatError | MessageValidationError, MessagePayloadType>;
|
|
16
|
-
|
|
17
|
-
export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext, PrehandlerOutput = undefined> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>;
|
|
18
|
-
export type DeletionConfig = {
|
|
19
|
-
deleteIfExists?: boolean;
|
|
20
|
-
waitForConfirmation?: boolean;
|
|
21
|
-
forceDeleteInProduction?: boolean;
|
|
22
|
-
};
|
|
23
|
-
export type CommonQueueOptions = {
|
|
24
|
-
messageTypeField: string;
|
|
25
|
-
messageIdField?: string;
|
|
26
|
-
handlerSpy?: HandlerSpy<object> | HandlerSpyParams | boolean;
|
|
27
|
-
logMessages?: boolean;
|
|
28
|
-
};
|
|
29
|
-
export type CommonCreationConfigType = {
|
|
30
|
-
updateAttributesIfExists?: boolean;
|
|
31
|
-
};
|
|
32
|
-
export type NewQueueOptions<CreationConfigType extends CommonCreationConfigType> = {
|
|
33
|
-
locatorConfig?: never;
|
|
34
|
-
deletionConfig?: DeletionConfig;
|
|
35
|
-
creationConfig: CreationConfigType;
|
|
36
|
-
} & CommonQueueOptions;
|
|
37
|
-
export type ExistingQueueOptions<QueueLocatorType extends object> = {
|
|
38
|
-
locatorConfig: QueueLocatorType;
|
|
39
|
-
deletionConfig?: DeletionConfig;
|
|
40
|
-
creationConfig?: never;
|
|
41
|
-
} & CommonQueueOptions;
|
|
42
|
-
export type MultiSchemaPublisherOptions<MessagePayloadSchemas extends object> = {
|
|
43
|
-
messageSchemas: readonly ZodSchema<MessagePayloadSchemas>[];
|
|
44
|
-
};
|
|
45
|
-
export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> = {
|
|
46
|
-
handlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[];
|
|
47
|
-
};
|
|
48
|
-
export type MonoSchemaQueueOptions<MessagePayloadType extends object> = {
|
|
49
|
-
messageSchema: ZodSchema<MessagePayloadType>;
|
|
50
|
-
};
|
|
51
|
-
export type CommonQueueLocator = {
|
|
9
|
+
type CommonQueueLocator = {
|
|
52
10
|
queueName: string;
|
|
53
11
|
};
|
|
54
|
-
export declare abstract class AbstractQueueService<MessagePayloadSchemas extends object, MessageEnvelopeType extends object, DependenciesType extends QueueDependencies, QueueConfiguration extends object, QueueLocatorType extends object = CommonQueueLocator, OptionsType extends
|
|
12
|
+
export declare abstract class AbstractQueueService<MessagePayloadSchemas extends object, MessageEnvelopeType extends object, DependenciesType extends QueueDependencies, QueueConfiguration extends object, QueueLocatorType extends object = CommonQueueLocator, OptionsType extends QueueOptions<QueueConfiguration, QueueLocatorType> = QueueOptions<QueueConfiguration, QueueLocatorType>, ExecutionContext = undefined, PrehandlerOutput = undefined> {
|
|
55
13
|
protected readonly errorReporter: ErrorReporter;
|
|
56
14
|
readonly logger: Logger;
|
|
57
15
|
protected readonly messageTypeField: string;
|
|
@@ -77,10 +35,12 @@ export declare abstract class AbstractQueueService<MessagePayloadSchemas extends
|
|
|
77
35
|
protected handleError(err: unknown, context?: Record<string, unknown>): void;
|
|
78
36
|
protected handleMessageProcessed(message: MessagePayloadSchemas | null, processingResult: MessageProcessingResult, messageId?: string): void;
|
|
79
37
|
protected processPrehandlersInternal(prehandlers: Prehandler<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[], message: MessagePayloadSchemas): Promise<PrehandlerOutput>;
|
|
38
|
+
protected preHandlerBarrierInternal<BarrierOutput>(barrier: BarrierCallback<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput, BarrierOutput> | undefined, message: MessagePayloadSchemas, executionContext: ExecutionContext, prehandlerOutput: PrehandlerOutput): Promise<BarrierResult<BarrierOutput>>;
|
|
80
39
|
protected abstract resolveNextFunction(prehandlers: Prehandler<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[], message: MessagePayloadSchemas, index: number, prehandlerOutput: PrehandlerOutput, resolve: (value: PrehandlerOutput | PromiseLike<PrehandlerOutput>) => void, reject: (err: Error) => void): (prehandlerResult: PrehandlerResult) => void;
|
|
81
40
|
protected resolveNextPreHandlerFunctionInternal(prehandlers: Prehandler<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[], executionContext: ExecutionContext, message: MessagePayloadSchemas, index: number, prehandlerOutput: PrehandlerOutput, resolve: (value: PrehandlerOutput | PromiseLike<PrehandlerOutput>) => void, reject: (err: Error) => void): (prehandlerResult: PrehandlerResult) => void;
|
|
82
41
|
protected abstract processPrehandlers(message: MessagePayloadSchemas, messageType: string): Promise<PrehandlerOutput>;
|
|
83
|
-
protected abstract preHandlerBarrier(message: MessagePayloadSchemas, messageType: string, prehandlerOutput: PrehandlerOutput): Promise<BarrierResult<BarrierOutput>>;
|
|
84
|
-
abstract processMessage(message: MessagePayloadSchemas, messageType: string, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput,
|
|
42
|
+
protected abstract preHandlerBarrier<BarrierOutput>(message: MessagePayloadSchemas, messageType: string, prehandlerOutput: PrehandlerOutput): Promise<BarrierResult<BarrierOutput>>;
|
|
43
|
+
protected abstract processMessage(message: MessagePayloadSchemas, messageType: string, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, any>): Promise<Either<'retryLater', 'success'>>;
|
|
85
44
|
abstract close(): Promise<unknown>;
|
|
86
45
|
}
|
|
46
|
+
export {};
|
|
@@ -92,6 +92,17 @@ class AbstractQueueService {
|
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
async preHandlerBarrierInternal(barrier, message, executionContext, prehandlerOutput) {
|
|
96
|
+
if (!barrier) {
|
|
97
|
+
// @ts-ignore
|
|
98
|
+
return {
|
|
99
|
+
isPassing: true,
|
|
100
|
+
output: undefined,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
// @ts-ignore
|
|
104
|
+
return await barrier(message, executionContext, prehandlerOutput);
|
|
105
|
+
}
|
|
95
106
|
// eslint-disable-next-line max-params
|
|
96
107
|
resolveNextPreHandlerFunctionInternal(prehandlers, executionContext, message, index, prehandlerOutput, resolve, reject) {
|
|
97
108
|
return (prehandlerResult) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractQueueService.js","sourceRoot":"","sources":["../../../lib/queues/AbstractQueueService.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,mDAAiE;
|
|
1
|
+
{"version":3,"file":"AbstractQueueService.js","sourceRoot":"","sources":["../../../lib/queues/AbstractQueueService.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,mDAAiE;AAejE,6CAAgD;AAYhD,MAAsB,oBAAoB;IAarB,aAAa,CAAe;IAC/B,MAAM,CAAQ;IACX,gBAAgB,CAAQ;IACxB,cAAc,CAAQ;IACtB,WAAW,CAAS;IACpB,cAAc,CAAqB;IACnC,aAAa,CAAmB;IAChC,cAAc,CAAiB;IAC/B,WAAW,CAAoC;IAElE,IAAI,UAAU;QACZ,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAED,YAAY,EAAE,aAAa,EAAE,MAAM,EAAoB,EAAE,OAAoB;QAC3E,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QAEpB,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QAChD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,IAAI,IAAI,CAAA;QACpD,IAAI,CAAC,cAAc,GAAG,OAA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E,SAAS;aAClB,CAAA;QACH,CAAC;QAED,aAAa;QACb,OAAO,MAAM,OAAO,CAAC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,CAAC,CAAA;IACnE,CAAC;IAWD,sCAAsC;IAC5B,qCAAqC,CAC7C,WAAoF,EACpF,gBAAkC,EAClC,OAA8B,EAC9B,KAAa,EACb,gBAAkC,EAClC,OAA0E,EAC1E,MAA4B;QAE5B,OAAO,CAAC,gBAAkC,EAAE,EAAE;YAC5C,IAAI,gBAAgB,CAAC,KAAK,EAAE,CAAC;gBAC3B,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YAChC,CAAC;YAED,IAAI,WAAW,CAAC,MAAM,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC;gBACnC,OAAO,CAAC,gBAAgB,CAAC,CAAA;YAC3B,CAAC;iBAAM,CAAC;gBACN,6DAA6D;gBAC7D,WAAW,CAAC,KAAK,CAAC,CAChB,OAAO,EACP,gBAAgB;gBAChB,aAAa;gBACb,gBAAgB,EAChB,IAAI,CAAC,qCAAqC,CACxC,WAAW,EACX,gBAAgB,EAChB,OAAO,EACP,KAAK,GAAG,CAAC,EACT,gBAAgB,EAChB,OAAO,EACP,MAAM,CACP,CACF,CAAA;YACH,CAAC;QACH,CAAC,CAAA;IACH,CAAC;CAqBF;AAvOD,oDAuOC"}
|
|
@@ -17,19 +17,19 @@ export type BarrierResultNegative = {
|
|
|
17
17
|
output?: never;
|
|
18
18
|
};
|
|
19
19
|
export type PrehandlerResult = Either<DoNotProcessMessageError | RetryMessageLaterError, 'success'>;
|
|
20
|
-
export type
|
|
20
|
+
export type BarrierCallback<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
23
|
export type HandlerConfigOptions<MessagePayloadSchema extends object, ExecutionContext, PrehandlerOutput, BarrierOutput> = {
|
|
24
24
|
messageLogFormatter?: LogFormatter<MessagePayloadSchema>;
|
|
25
|
-
preHandlerBarrier?:
|
|
25
|
+
preHandlerBarrier?: BarrierCallback<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
26
26
|
prehandlers?: Prehandler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput>[];
|
|
27
27
|
};
|
|
28
28
|
export declare class MessageHandlerConfig<const MessagePayloadSchema extends object, const ExecutionContext, const PrehandlerOutput = undefined, const BarrierOutput = unknown> {
|
|
29
29
|
readonly schema: ZodSchema<MessagePayloadSchema>;
|
|
30
30
|
readonly handler: Handler<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
31
31
|
readonly messageLogFormatter: LogFormatter<MessagePayloadSchema>;
|
|
32
|
-
readonly preHandlerBarrier?:
|
|
32
|
+
readonly preHandlerBarrier?: BarrierCallback<MessagePayloadSchema, ExecutionContext, PrehandlerOutput, BarrierOutput>;
|
|
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
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MessageProcessingResult } from '../types/MessageQueueTypes';
|
|
2
|
-
import type { CommonQueueOptions } from '
|
|
2
|
+
import type { CommonQueueOptions } from '../types/queueOptionsTypes';
|
|
3
3
|
export type HandlerSpyParams = {
|
|
4
4
|
bufferSize?: number;
|
|
5
5
|
messageIdField?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HandlerSpy.js","sourceRoot":"","sources":["../../../lib/queues/HandlerSpy.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mDAA8C;AAC9C,2CAAiC;
|
|
1
|
+
{"version":3,"file":"HandlerSpy.js","sourceRoot":"","sources":["../../../lib/queues/HandlerSpy.ts"],"names":[],"mappings":";;;AAAA,6CAAwC;AAExC,mDAA8C;AAC9C,2CAAiC;AAIjC,oDAAmD;AAyBnD,SAAgB,YAAY,CAAmB,KAAc;IAC3D,OAAO,CACL,IAAA,oBAAQ,EAAC,KAAK,CAAC;QACf,CAAC,KAAK,YAAY,UAAU,IAAK,KAAuC,CAAC,IAAI,KAAK,YAAY,CAAC,CAChG,CAAA;AACH,CAAC;AALD,oCAKC;AAoBD,MAAa,UAAU;IACd,IAAI,GAAG,YAAY,CAAA;IAC1B,8DAA8D;IAC7C,aAAa,CAAsB;IACnC,cAAc,CAA6B;IAC3C,WAAW,CAA6C;IAEzE,YAAY,SAA2B,EAAE;QACvC,IAAI,CAAC,aAAa,GAAG,IAAI,iBAAI,CAAC,MAAM,CAAC,UAAU,IAAI,GAAG,CAAC,CAAA;QACvD,aAAa;QACb,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,IAAI,CAAA;QACnD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACvB,CAAC;IAEO,oBAAoB,CAC1B,SAA4B,EAC5B,MAA0C,EAC1C,gBAA0C;QAE1C,OAAO;QACL,aAAa;QACb,IAAA,0BAAa,EAAC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC;YACxC,CAAC,CAAC,gBAAgB,IAAI,SAAS,CAAC,gBAAgB,KAAK,gBAAgB,CAAC,CACvE,CAAA;IACH,CAAC;IAED,oBAAoB,CAClB,EAAU,EACV,gBAA0C;QAE1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I,EAAE,CAAC;QACrC,OAAO,IAAI,UAAU,EAA8B,CAAA;IACrD,CAAC;IAED,OAAO,IAAI,UAAU,CAAC,YAAY,CAAC,UAAU,CAA6B,CAAA;AAC5E,CAAC;AAZD,8CAYC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ErrorReporter, ErrorResolver } from '@lokalise/node-core';
|
|
2
|
+
import type { ZodSchema } from 'zod';
|
|
3
|
+
import type { MessageHandlerConfig } from '../queues/HandlerContainer';
|
|
4
|
+
import type { HandlerSpy, HandlerSpyParams } from '../queues/HandlerSpy';
|
|
5
|
+
import type { Logger, TransactionObservabilityManager } from './MessageQueueTypes';
|
|
6
|
+
export type QueueDependencies = {
|
|
7
|
+
errorReporter: ErrorReporter;
|
|
8
|
+
logger: Logger;
|
|
9
|
+
};
|
|
10
|
+
export type QueueConsumerDependencies = {
|
|
11
|
+
consumerErrorResolver: ErrorResolver;
|
|
12
|
+
transactionObservabilityManager: TransactionObservabilityManager;
|
|
13
|
+
};
|
|
14
|
+
export type CommonQueueOptions = {
|
|
15
|
+
messageTypeField: string;
|
|
16
|
+
messageIdField?: string;
|
|
17
|
+
handlerSpy?: HandlerSpy<object> | HandlerSpyParams | boolean;
|
|
18
|
+
logMessages?: boolean;
|
|
19
|
+
};
|
|
20
|
+
type CommonCreationConfigType = {
|
|
21
|
+
updateAttributesIfExists?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type DeletionConfig = {
|
|
24
|
+
deleteIfExists?: boolean;
|
|
25
|
+
waitForConfirmation?: boolean;
|
|
26
|
+
forceDeleteInProduction?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type NewQueueOptions<CreationConfigType extends CommonCreationConfigType> = {
|
|
29
|
+
locatorConfig?: never;
|
|
30
|
+
deletionConfig?: DeletionConfig;
|
|
31
|
+
creationConfig: CreationConfigType;
|
|
32
|
+
} & CommonQueueOptions;
|
|
33
|
+
type ExistingQueueOptions<QueueLocatorType extends object> = {
|
|
34
|
+
locatorConfig: QueueLocatorType;
|
|
35
|
+
deletionConfig?: DeletionConfig;
|
|
36
|
+
creationConfig?: never;
|
|
37
|
+
} & CommonQueueOptions;
|
|
38
|
+
export type QueueOptions<CreationConfigType extends CommonCreationConfigType, QueueLocatorType extends object> = CommonQueueOptions & (NewQueueOptions<CreationConfigType> | ExistingQueueOptions<QueueLocatorType>);
|
|
39
|
+
export type QueuePublisherOptions<CreationConfigType extends CommonCreationConfigType, QueueLocatorType extends object, MessagePayloadSchemas extends object> = QueueOptions<CreationConfigType, QueueLocatorType> & {
|
|
40
|
+
messageSchemas: readonly ZodSchema<MessagePayloadSchemas>[];
|
|
41
|
+
};
|
|
42
|
+
export type QueueConsumerOptions<CreationConfigType extends object, QueueLocatorType extends object, MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput = undefined> = QueueOptions<CreationConfigType, QueueLocatorType> & {
|
|
43
|
+
handlers: MessageHandlerConfig<MessagePayloadSchemas, ExecutionContext, PrehandlerOutput>[];
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queueOptionsTypes.js","sourceRoot":"","sources":["../../../lib/types/queueOptionsTypes.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@message-queue-toolkit/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "10.0.0",
|
|
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",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@types/node": "^20.11.25",
|
|
34
34
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
35
35
|
"@typescript-eslint/parser": "^7.1.1",
|
|
36
|
-
"@vitest/coverage-v8": "^1.
|
|
36
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
37
37
|
"del-cli": "^5.1.0",
|
|
38
38
|
"eslint": "^8.57.0",
|
|
39
39
|
"eslint-config-prettier": "^9.1.0",
|