@message-queue-toolkit/sqs 11.1.0 → 12.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 +4 -10
- package/dist/index.js +5 -11
- package/dist/index.js.map +1 -1
- package/dist/lib/errors/SqsConsumerErrorResolver.js +2 -0
- package/dist/lib/errors/SqsConsumerErrorResolver.js.map +1 -1
- package/dist/lib/fakes/FakeConsumerErrorResolver.d.ts +2 -2
- package/dist/lib/fakes/FakeConsumerErrorResolver.js +7 -7
- package/dist/lib/fakes/FakeConsumerErrorResolver.js.map +1 -1
- package/dist/lib/sqs/AbstractSqsConsumer.d.ts +22 -15
- package/dist/lib/sqs/AbstractSqsConsumer.js +110 -76
- package/dist/lib/sqs/AbstractSqsConsumer.js.map +1 -1
- package/dist/lib/sqs/{AbstractSqsPublisherMultiSchema.d.ts → AbstractSqsPublisher.d.ts} +6 -4
- package/dist/lib/sqs/AbstractSqsPublisher.js +77 -0
- package/dist/lib/sqs/AbstractSqsPublisher.js.map +1 -0
- package/dist/lib/sqs/AbstractSqsService.d.ts +6 -12
- package/dist/lib/sqs/AbstractSqsService.js +5 -41
- package/dist/lib/sqs/AbstractSqsService.js.map +1 -1
- package/dist/lib/utils/sqsInitter.js +2 -10
- package/dist/lib/utils/sqsInitter.js.map +1 -1
- package/package.json +3 -3
- package/dist/lib/sqs/AbstractSqsConsumerMonoSchema.d.ts +0 -25
- package/dist/lib/sqs/AbstractSqsConsumerMonoSchema.js +0 -41
- package/dist/lib/sqs/AbstractSqsConsumerMonoSchema.js.map +0 -1
- package/dist/lib/sqs/AbstractSqsConsumerMultiSchema.d.ts +0 -25
- package/dist/lib/sqs/AbstractSqsConsumerMultiSchema.js +0 -57
- package/dist/lib/sqs/AbstractSqsConsumerMultiSchema.js.map +0 -1
- package/dist/lib/sqs/AbstractSqsPublisherMonoSchema.d.ts +0 -19
- package/dist/lib/sqs/AbstractSqsPublisherMonoSchema.js +0 -39
- package/dist/lib/sqs/AbstractSqsPublisherMonoSchema.js.map +0 -1
- package/dist/lib/sqs/AbstractSqsPublisherMultiSchema.js +0 -45
- package/dist/lib/sqs/AbstractSqsPublisherMultiSchema.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export
|
|
3
|
-
export type { SQSCreationConfig, ExtraSQSCreationParams } from './lib/sqs/AbstractSqsConsumer';
|
|
4
|
-
export { AbstractSqsConsumerMultiSchema } from './lib/sqs/AbstractSqsConsumerMultiSchema';
|
|
5
|
-
export { AbstractSqsConsumerMonoSchema } from './lib/sqs/AbstractSqsConsumerMonoSchema';
|
|
6
|
-
export type { CommonSQSConsumerOptionsMono } from './lib/sqs/AbstractSqsConsumerMonoSchema';
|
|
7
|
-
export type { NewSQSConsumerOptions, ExistingSQSConsumerOptions, } from './lib/sqs/AbstractSqsConsumer';
|
|
1
|
+
export type { SQSConsumerDependencies, SQSQueueLocatorType, SQSDependencies, } from './lib/sqs/AbstractSqsService';
|
|
2
|
+
export * from './lib/sqs/AbstractSqsConsumer';
|
|
8
3
|
export { SqsConsumerErrorResolver } from './lib/errors/SqsConsumerErrorResolver';
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
11
|
-
export type { SQSMessageOptions } from './lib/sqs/AbstractSqsPublisherMultiSchema';
|
|
4
|
+
export { AbstractSqsPublisher } from './lib/sqs/AbstractSqsPublisher';
|
|
5
|
+
export type { SQSMessageOptions } from './lib/sqs/AbstractSqsPublisher';
|
|
12
6
|
export { assertQueue, deleteQueue, getQueueAttributes, getQueueUrl } from './lib/utils/sqsUtils';
|
|
13
7
|
export { deleteSqs, updateQueueAttributes } from './lib/utils/sqsInitter';
|
|
14
8
|
export { deserializeSQSMessage } from './lib/utils/sqsMessageDeserializer';
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.FakeConsumerErrorResolver = exports.generateWildcardSnsArn = exports.generateWildcardSqsArn = exports.generateQueuePublishForTopicPolicy = exports.deserializeSQSMessage = exports.updateQueueAttributes = exports.deleteSqs = exports.getQueueUrl = exports.getQueueAttributes = exports.deleteQueue = exports.assertQueue = exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var AbstractSqsConsumerMultiSchema_1 = require("./lib/sqs/AbstractSqsConsumerMultiSchema");
|
|
7
|
-
Object.defineProperty(exports, "AbstractSqsConsumerMultiSchema", { enumerable: true, get: function () { return AbstractSqsConsumerMultiSchema_1.AbstractSqsConsumerMultiSchema; } });
|
|
8
|
-
var AbstractSqsConsumerMonoSchema_1 = require("./lib/sqs/AbstractSqsConsumerMonoSchema");
|
|
9
|
-
Object.defineProperty(exports, "AbstractSqsConsumerMonoSchema", { enumerable: true, get: function () { return AbstractSqsConsumerMonoSchema_1.AbstractSqsConsumerMonoSchema; } });
|
|
3
|
+
exports.FakeConsumerErrorResolver = exports.generateWildcardSnsArn = exports.generateWildcardSqsArn = exports.generateQueuePublishForTopicPolicy = exports.deserializeSQSMessage = exports.updateQueueAttributes = exports.deleteSqs = exports.getQueueUrl = exports.getQueueAttributes = exports.deleteQueue = exports.assertQueue = exports.AbstractSqsPublisher = exports.SqsConsumerErrorResolver = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./lib/sqs/AbstractSqsConsumer"), exports);
|
|
10
6
|
var SqsConsumerErrorResolver_1 = require("./lib/errors/SqsConsumerErrorResolver");
|
|
11
7
|
Object.defineProperty(exports, "SqsConsumerErrorResolver", { enumerable: true, get: function () { return SqsConsumerErrorResolver_1.SqsConsumerErrorResolver; } });
|
|
12
|
-
var
|
|
13
|
-
Object.defineProperty(exports, "
|
|
14
|
-
var AbstractSqsPublisherMultiSchema_1 = require("./lib/sqs/AbstractSqsPublisherMultiSchema");
|
|
15
|
-
Object.defineProperty(exports, "AbstractSqsPublisherMultiSchema", { enumerable: true, get: function () { return AbstractSqsPublisherMultiSchema_1.AbstractSqsPublisherMultiSchema; } });
|
|
8
|
+
var AbstractSqsPublisher_1 = require("./lib/sqs/AbstractSqsPublisher");
|
|
9
|
+
Object.defineProperty(exports, "AbstractSqsPublisher", { enumerable: true, get: function () { return AbstractSqsPublisher_1.AbstractSqsPublisher; } });
|
|
16
10
|
var sqsUtils_1 = require("./lib/utils/sqsUtils");
|
|
17
11
|
Object.defineProperty(exports, "assertQueue", { enumerable: true, get: function () { return sqsUtils_1.assertQueue; } });
|
|
18
12
|
Object.defineProperty(exports, "deleteQueue", { enumerable: true, get: function () { return sqsUtils_1.deleteQueue; } });
|
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":";;;;AAMA,wEAA6C;AAC7C,kFAAgF;AAAvE,oIAAA,wBAAwB,OAAA;AAEjC,uEAAqE;AAA5D,4HAAA,oBAAoB,OAAA;AAG7B,iDAAgG;AAAvF,uGAAA,WAAW,OAAA;AAAE,uGAAA,WAAW,OAAA;AAAE,8GAAA,kBAAkB,OAAA;AAAE,uGAAA,WAAW,OAAA;AAClE,qDAAyE;AAAhE,uGAAA,SAAS,OAAA;AAAE,mHAAA,qBAAqB,OAAA;AACzC,6EAA0E;AAAjE,+HAAA,qBAAqB,OAAA;AAC9B,mEAIsC;AAHpC,uIAAA,kCAAkC,OAAA;AAClC,2HAAA,sBAAsB,OAAA;AACtB,2HAAA,sBAAsB,OAAA;AAIxB,mFAAiF;AAAxE,sIAAA,yBAAyB,OAAA"}
|
|
@@ -26,10 +26,12 @@ class SqsConsumerErrorResolver {
|
|
|
26
26
|
errorCode: error.code,
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
+
/* c8 ignore start */
|
|
29
30
|
return new node_core_1.InternalError({
|
|
30
31
|
message: 'Error processing message',
|
|
31
32
|
errorCode: 'INTERNAL_ERROR',
|
|
32
33
|
});
|
|
34
|
+
/* c8 ignore stop */
|
|
33
35
|
}
|
|
34
36
|
}
|
|
35
37
|
exports.SqsConsumerErrorResolver = SqsConsumerErrorResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqsConsumerErrorResolver.js","sourceRoot":"","sources":["../../../lib/errors/SqsConsumerErrorResolver.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,mDAAwE;AACxE,sDAA+F;AAC/F,6BAA8B;AAE9B,MAAa,wBAAwB;IAC5B,YAAY,CAAC,KAAc;QAChC,IAAI,iBAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,aAAa,EAAE,CAAC;YAChE,OAAO,IAAI,gCAAyB,CAAC;gBACnC,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,KAAK,YAAY,cAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,6BAAsB,CAAC;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE;oBACP,KAAK,EAAE,KAAK,CAAC,MAAM;iBACpB;aACF,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,IAAA,+BAAmB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,yBAAa,CAAC;gBACvB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,SAAS,EAAE,KAAK,CAAC,IAAI;aACtB,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,IAAI,yBAAa,CAAC;YACvB,OAAO,EAAE,0BAA0B;YACnC,SAAS,EAAE,gBAAgB;SAC5B,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"SqsConsumerErrorResolver.js","sourceRoot":"","sources":["../../../lib/errors/SqsConsumerErrorResolver.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,mDAAwE;AACxE,sDAA+F;AAC/F,6BAA8B;AAE9B,MAAa,wBAAwB;IAC5B,YAAY,CAAC,KAAc;QAChC,IAAI,iBAAK,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,EAAE,IAAI,KAAK,aAAa,EAAE,CAAC;YAChE,OAAO,IAAI,gCAAyB,CAAC;gBACnC,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,KAAK,YAAY,cAAQ,EAAE,CAAC;YAC9B,OAAO,IAAI,6BAAsB,CAAC;gBAChC,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,OAAO,EAAE;oBACP,KAAK,EAAE,KAAK,CAAC,MAAM;iBACpB;aACF,CAAC,CAAA;QACJ,CAAC;QACD,IAAI,IAAA,+BAAmB,EAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,IAAI,yBAAa,CAAC;gBACvB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,SAAS,EAAE,KAAK,CAAC,IAAI;aACtB,CAAC,CAAA;QACJ,CAAC;QACD,qBAAqB;QACrB,OAAO,IAAI,yBAAa,CAAC;YACvB,OAAO,EAAE,0BAA0B;YACnC,SAAS,EAAE,gBAAgB;SAC5B,CAAC,CAAA;QACF,oBAAoB;IACtB,CAAC;CACF;AA5BD,4DA4BC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SqsConsumerErrorResolver } from '../errors/SqsConsumerErrorResolver';
|
|
2
2
|
export declare class FakeConsumerErrorResolver extends SqsConsumerErrorResolver {
|
|
3
|
-
|
|
4
|
-
get handleErrorCallsCount(): number;
|
|
3
|
+
private _errors;
|
|
5
4
|
constructor();
|
|
6
5
|
processError(error: unknown): import("@lokalise/node-core").InternalError<import("@lokalise/node-core").ErrorDetails>;
|
|
6
|
+
get errors(): unknown[];
|
|
7
7
|
clear(): void;
|
|
8
8
|
}
|
|
@@ -3,20 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.FakeConsumerErrorResolver = void 0;
|
|
4
4
|
const SqsConsumerErrorResolver_1 = require("../errors/SqsConsumerErrorResolver");
|
|
5
5
|
class FakeConsumerErrorResolver extends SqsConsumerErrorResolver_1.SqsConsumerErrorResolver {
|
|
6
|
-
|
|
7
|
-
get handleErrorCallsCount() {
|
|
8
|
-
return this.errors.length;
|
|
9
|
-
}
|
|
6
|
+
_errors;
|
|
10
7
|
constructor() {
|
|
11
8
|
super();
|
|
12
|
-
this.
|
|
9
|
+
this._errors = [];
|
|
13
10
|
}
|
|
14
11
|
processError(error) {
|
|
15
|
-
this.
|
|
12
|
+
this._errors.push(error);
|
|
16
13
|
return super.processError(error);
|
|
17
14
|
}
|
|
15
|
+
get errors() {
|
|
16
|
+
return this._errors;
|
|
17
|
+
}
|
|
18
18
|
clear() {
|
|
19
|
-
this.
|
|
19
|
+
this._errors = [];
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
exports.FakeConsumerErrorResolver = FakeConsumerErrorResolver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FakeConsumerErrorResolver.js","sourceRoot":"","sources":["../../../lib/fakes/FakeConsumerErrorResolver.ts"],"names":[],"mappings":";;;AAAA,iFAA6E;AAE7E,MAAa,yBAA0B,SAAQ,mDAAwB;
|
|
1
|
+
{"version":3,"file":"FakeConsumerErrorResolver.js","sourceRoot":"","sources":["../../../lib/fakes/FakeConsumerErrorResolver.ts"],"names":[],"mappings":";;;AAAA,iFAA6E;AAE7E,MAAa,yBAA0B,SAAQ,mDAAwB;IAC7D,OAAO,CAAW;IAE1B;QACE,KAAK,EAAE,CAAA;QACP,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;IAEe,YAAY,CAAC,KAAc;QACzC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxB,OAAO,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAClC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAA;IACrB,CAAC;IACM,KAAK;QACV,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;IACnB,CAAC;CACF;AAnBD,8DAmBC"}
|
|
@@ -1,35 +1,42 @@
|
|
|
1
|
+
import type { CreateQueueRequest } from '@aws-sdk/client-sqs';
|
|
1
2
|
import type { Either, ErrorResolver } from '@lokalise/node-core';
|
|
2
|
-
import type { QueueConsumer as QueueConsumer,
|
|
3
|
-
import {
|
|
3
|
+
import type { QueueConsumer as QueueConsumer, QueueConsumerOptions, PrehandlingOutputs, Prehandler, BarrierResult } from '@message-queue-toolkit/core';
|
|
4
|
+
import { MessageSchemaContainer } from '@message-queue-toolkit/core';
|
|
4
5
|
import type { ConsumerOptions } from 'sqs-consumer/src/types';
|
|
5
6
|
import type { SQSMessage } from '../types/MessageTypes';
|
|
6
|
-
import type { SQSConsumerDependencies,
|
|
7
|
+
import type { SQSConsumerDependencies, SQSQueueLocatorType } from './AbstractSqsService';
|
|
7
8
|
import { AbstractSqsService } from './AbstractSqsService';
|
|
8
9
|
export type ExtraSQSCreationParams = {
|
|
9
10
|
topicArnsWithPublishPermissionsPrefix?: string;
|
|
10
11
|
updateAttributesIfExists?: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type SQSCreationConfig = {
|
|
13
|
-
queue:
|
|
14
|
+
queue: CreateQueueRequest;
|
|
14
15
|
updateAttributesIfExists?: boolean;
|
|
15
16
|
} & ExtraSQSCreationParams;
|
|
16
|
-
export type
|
|
17
|
+
export type SQSConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType> = QueueConsumerOptions<CreationConfigType, QueueLocatorType, MessagePayloadSchemas, ExecutionContext, PrehandlerOutput> & {
|
|
17
18
|
consumerOverrides?: Partial<ConsumerOptions>;
|
|
18
19
|
};
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
};
|
|
22
|
-
export declare abstract class AbstractSqsConsumer<MessagePayloadType extends object, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, ConsumerOptionsType extends NewSQSConsumerOptions<CreationConfigType> | ExistingSQSConsumerOptions<QueueLocatorType> = NewSQSConsumerOptions<CreationConfigType> | ExistingSQSConsumerOptions<QueueLocatorType>, ExecutionContext = unknown, PrehandlerOutput = unknown, BarrierOutput = unknown> extends AbstractSqsService<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, SQSConsumerDependencies, ExecutionContext, PrehandlerOutput, BarrierOutput> implements QueueConsumer {
|
|
20
|
+
export declare abstract class AbstractSqsConsumer<MessagePayloadType extends object, ExecutionContext, PrehandlerOutput = undefined, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, ConsumerOptionsType extends SQSConsumerOptions<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType, QueueLocatorType> = SQSConsumerOptions<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType, QueueLocatorType>> extends AbstractSqsService<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, SQSConsumerDependencies, ExecutionContext, PrehandlerOutput> implements QueueConsumer {
|
|
21
|
+
private consumer?;
|
|
23
22
|
private readonly transactionObservabilityManager?;
|
|
24
|
-
protected readonly errorResolver: ErrorResolver;
|
|
25
|
-
protected consumer: Consumer;
|
|
26
23
|
private readonly consumerOptionsOverride;
|
|
27
|
-
|
|
24
|
+
private readonly handlerContainer;
|
|
25
|
+
protected readonly errorResolver: ErrorResolver;
|
|
26
|
+
protected readonly messageSchemaContainer: MessageSchemaContainer<MessagePayloadType>;
|
|
27
|
+
protected readonly executionContext: ExecutionContext;
|
|
28
|
+
protected constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType, executionContext: ExecutionContext);
|
|
29
|
+
start(): Promise<void>;
|
|
30
|
+
close(abort?: boolean): Promise<void>;
|
|
28
31
|
private internalProcessMessage;
|
|
32
|
+
protected processMessage(message: MessagePayloadType, messageType: string, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, any>): Promise<Either<'retryLater', 'success'>>;
|
|
33
|
+
protected processPrehandlers(message: MessagePayloadType, messageType: string): Promise<PrehandlerOutput>;
|
|
34
|
+
protected preHandlerBarrier<BarrierOutput>(message: MessagePayloadType, messageType: string, prehandlerOutput: PrehandlerOutput): Promise<BarrierResult<BarrierOutput>>;
|
|
35
|
+
protected resolveSchema(message: MessagePayloadType): Either<Error, import("zod").ZodType<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
|
|
36
|
+
protected resolveNextFunction(prehandlers: Prehandler<MessagePayloadType, ExecutionContext, unknown>[], message: MessagePayloadType, index: number, prehandlerOutput: PrehandlerOutput, resolve: (value: PrehandlerOutput | PromiseLike<PrehandlerOutput>) => void, reject: (err: Error) => void): (prehandlerResult: import("@message-queue-toolkit/core/dist/lib/queues/HandlerContainer").PrehandlerResult) => void;
|
|
37
|
+
protected resolveMessageLog(message: MessagePayloadType, messageType: string): unknown;
|
|
38
|
+
protected resolveMessage(message: SQSMessage): Either<import("@message-queue-toolkit/core").MessageInvalidFormatError | import("@message-queue-toolkit/core").MessageValidationError, unknown>;
|
|
29
39
|
private tryToExtractId;
|
|
30
40
|
private deserializeMessage;
|
|
31
41
|
private failProcessing;
|
|
32
|
-
start(): Promise<void>;
|
|
33
|
-
protected resolveMessage(message: SQSMessage): Either<import("@message-queue-toolkit/core").MessageInvalidFormatError | import("@message-queue-toolkit/core").MessageValidationError, unknown>;
|
|
34
|
-
close(abort?: boolean): Promise<void>;
|
|
35
42
|
}
|
|
@@ -9,83 +9,28 @@ const ABORT_EARLY_EITHER = {
|
|
|
9
9
|
error: 'abort',
|
|
10
10
|
};
|
|
11
11
|
class AbstractSqsConsumer extends AbstractSqsService_1.AbstractSqsService {
|
|
12
|
-
transactionObservabilityManager;
|
|
13
|
-
errorResolver;
|
|
14
|
-
// @ts-ignore
|
|
15
12
|
consumer;
|
|
13
|
+
transactionObservabilityManager;
|
|
16
14
|
consumerOptionsOverride;
|
|
17
|
-
|
|
15
|
+
handlerContainer;
|
|
16
|
+
errorResolver;
|
|
17
|
+
messageSchemaContainer;
|
|
18
|
+
executionContext;
|
|
19
|
+
constructor(dependencies, options, executionContext) {
|
|
18
20
|
super(dependencies, options);
|
|
19
21
|
this.transactionObservabilityManager = dependencies.transactionObservabilityManager;
|
|
20
22
|
this.errorResolver = dependencies.consumerErrorResolver;
|
|
21
23
|
this.consumerOptionsOverride = options.consumerOverrides ?? {};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return { error: 'retryLater' };
|
|
33
|
-
}
|
|
34
|
-
tryToExtractId(message) {
|
|
35
|
-
if (message === null) {
|
|
36
|
-
return ABORT_EARLY_EITHER;
|
|
37
|
-
}
|
|
38
|
-
const resolveMessageResult = this.resolveMessage(message);
|
|
39
|
-
if ((0, core_1.isMessageError)(resolveMessageResult.error)) {
|
|
40
|
-
this.handleError(resolveMessageResult.error);
|
|
41
|
-
return ABORT_EARLY_EITHER;
|
|
42
|
-
}
|
|
43
|
-
// Empty content for whatever reason
|
|
44
|
-
if (!resolveMessageResult.result) {
|
|
45
|
-
return ABORT_EARLY_EITHER;
|
|
46
|
-
}
|
|
47
|
-
// @ts-ignore
|
|
48
|
-
if (this.messageIdField in resolveMessageResult.result) {
|
|
49
|
-
return {
|
|
50
|
-
// @ts-ignore
|
|
51
|
-
result: resolveMessageResult.result[this.messageIdField],
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return ABORT_EARLY_EITHER;
|
|
55
|
-
}
|
|
56
|
-
deserializeMessage(message) {
|
|
57
|
-
if (message === null) {
|
|
58
|
-
return ABORT_EARLY_EITHER;
|
|
59
|
-
}
|
|
60
|
-
const resolveMessageResult = this.resolveMessage(message);
|
|
61
|
-
if ((0, core_1.isMessageError)(resolveMessageResult.error)) {
|
|
62
|
-
this.handleError(resolveMessageResult.error);
|
|
63
|
-
return ABORT_EARLY_EITHER;
|
|
64
|
-
}
|
|
65
|
-
// Empty content for whatever reason
|
|
66
|
-
if (!resolveMessageResult.result) {
|
|
67
|
-
return ABORT_EARLY_EITHER;
|
|
68
|
-
}
|
|
69
|
-
const resolveSchemaResult = this.resolveSchema(resolveMessageResult.result);
|
|
70
|
-
if (resolveSchemaResult.error) {
|
|
71
|
-
this.handleError(resolveSchemaResult.error);
|
|
72
|
-
return ABORT_EARLY_EITHER;
|
|
73
|
-
}
|
|
74
|
-
const deserializationResult = (0, core_1.parseMessage)(resolveMessageResult.result, resolveSchemaResult.result, this.errorResolver);
|
|
75
|
-
if ((0, core_1.isMessageError)(deserializationResult.error)) {
|
|
76
|
-
this.handleError(deserializationResult.error);
|
|
77
|
-
return ABORT_EARLY_EITHER;
|
|
78
|
-
}
|
|
79
|
-
// Empty content for whatever reason
|
|
80
|
-
if (!deserializationResult.result) {
|
|
81
|
-
return ABORT_EARLY_EITHER;
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
result: deserializationResult.result,
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
async failProcessing(_message) {
|
|
88
|
-
// Not implemented yet - needs dead letter queue
|
|
24
|
+
const messageSchemas = options.handlers.map((entry) => entry.schema);
|
|
25
|
+
this.messageSchemaContainer = new core_1.MessageSchemaContainer({
|
|
26
|
+
messageSchemas,
|
|
27
|
+
messageTypeField: options.messageTypeField,
|
|
28
|
+
});
|
|
29
|
+
this.handlerContainer = new core_1.HandlerContainer({
|
|
30
|
+
messageTypeField: this.messageTypeField,
|
|
31
|
+
messageHandlers: options.handlers,
|
|
32
|
+
});
|
|
33
|
+
this.executionContext = executionContext;
|
|
89
34
|
}
|
|
90
35
|
async start() {
|
|
91
36
|
await this.init();
|
|
@@ -95,9 +40,9 @@ class AbstractSqsConsumer extends AbstractSqsService_1.AbstractSqsService {
|
|
|
95
40
|
this.consumer = sqs_consumer_1.Consumer.create({
|
|
96
41
|
queueUrl: this.queueUrl,
|
|
97
42
|
handleMessage: async (message) => {
|
|
98
|
-
|
|
43
|
+
/* c8 ignore next */
|
|
44
|
+
if (message === null)
|
|
99
45
|
return;
|
|
100
|
-
}
|
|
101
46
|
const deserializedMessage = this.deserializeMessage(message);
|
|
102
47
|
if (deserializedMessage.error === 'abort') {
|
|
103
48
|
await this.failProcessing(message);
|
|
@@ -146,15 +91,104 @@ class AbstractSqsConsumer extends AbstractSqsService_1.AbstractSqsService {
|
|
|
146
91
|
});
|
|
147
92
|
this.consumer.start();
|
|
148
93
|
}
|
|
149
|
-
resolveMessage(message) {
|
|
150
|
-
return (0, sqsMessageReader_1.readSqsMessage)(message, this.errorResolver);
|
|
151
|
-
}
|
|
152
94
|
async close(abort) {
|
|
153
95
|
await super.close();
|
|
154
96
|
this.consumer?.stop({
|
|
155
97
|
abort: abort ?? false,
|
|
156
98
|
});
|
|
157
99
|
}
|
|
100
|
+
async internalProcessMessage(message, messageType) {
|
|
101
|
+
const prehandlerOutput = await this.processPrehandlers(message, messageType);
|
|
102
|
+
const barrierResult = await this.preHandlerBarrier(message, messageType, prehandlerOutput);
|
|
103
|
+
if (barrierResult.isPassing) {
|
|
104
|
+
return this.processMessage(message, messageType, {
|
|
105
|
+
prehandlerOutput,
|
|
106
|
+
barrierOutput: barrierResult.output,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return { error: 'retryLater' };
|
|
110
|
+
}
|
|
111
|
+
async processMessage(message, messageType,
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
prehandlingOutputs) {
|
|
114
|
+
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
115
|
+
return handler.handler(message, this.executionContext, prehandlingOutputs);
|
|
116
|
+
}
|
|
117
|
+
processPrehandlers(message, messageType) {
|
|
118
|
+
const handlerConfig = this.handlerContainer.resolveHandler(messageType);
|
|
119
|
+
return this.processPrehandlersInternal(handlerConfig.prehandlers, message);
|
|
120
|
+
}
|
|
121
|
+
async preHandlerBarrier(message, messageType, prehandlerOutput) {
|
|
122
|
+
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
123
|
+
return this.preHandlerBarrierInternal(handler.preHandlerBarrier, message, this.executionContext, prehandlerOutput);
|
|
124
|
+
}
|
|
125
|
+
resolveSchema(message) {
|
|
126
|
+
return this.messageSchemaContainer.resolveSchema(message);
|
|
127
|
+
}
|
|
128
|
+
// eslint-disable-next-line max-params
|
|
129
|
+
resolveNextFunction(prehandlers, message, index, prehandlerOutput, resolve, reject) {
|
|
130
|
+
return this.resolveNextPreHandlerFunctionInternal(prehandlers, this.executionContext, message, index, prehandlerOutput, resolve, reject);
|
|
131
|
+
}
|
|
132
|
+
resolveMessageLog(message, messageType) {
|
|
133
|
+
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
134
|
+
return handler.messageLogFormatter(message);
|
|
135
|
+
}
|
|
136
|
+
resolveMessage(message) {
|
|
137
|
+
return (0, sqsMessageReader_1.readSqsMessage)(message, this.errorResolver);
|
|
138
|
+
}
|
|
139
|
+
tryToExtractId(message) {
|
|
140
|
+
const resolveMessageResult = this.resolveMessage(message);
|
|
141
|
+
if ((0, core_1.isMessageError)(resolveMessageResult.error)) {
|
|
142
|
+
this.handleError(resolveMessageResult.error);
|
|
143
|
+
return ABORT_EARLY_EITHER;
|
|
144
|
+
}
|
|
145
|
+
// Empty content for whatever reason
|
|
146
|
+
/* c8 ignore next */
|
|
147
|
+
if (!resolveMessageResult.result)
|
|
148
|
+
return ABORT_EARLY_EITHER;
|
|
149
|
+
// @ts-ignore
|
|
150
|
+
if (this.messageIdField in resolveMessageResult.result) {
|
|
151
|
+
return {
|
|
152
|
+
// @ts-ignore
|
|
153
|
+
result: resolveMessageResult.result[this.messageIdField],
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
return ABORT_EARLY_EITHER;
|
|
157
|
+
}
|
|
158
|
+
deserializeMessage(message) {
|
|
159
|
+
if (message === null) {
|
|
160
|
+
return ABORT_EARLY_EITHER;
|
|
161
|
+
}
|
|
162
|
+
const resolveMessageResult = this.resolveMessage(message);
|
|
163
|
+
if ((0, core_1.isMessageError)(resolveMessageResult.error)) {
|
|
164
|
+
this.handleError(resolveMessageResult.error);
|
|
165
|
+
return ABORT_EARLY_EITHER;
|
|
166
|
+
}
|
|
167
|
+
// Empty content for whatever reason
|
|
168
|
+
if (!resolveMessageResult.result) {
|
|
169
|
+
return ABORT_EARLY_EITHER;
|
|
170
|
+
}
|
|
171
|
+
const resolveSchemaResult = this.resolveSchema(resolveMessageResult.result);
|
|
172
|
+
if (resolveSchemaResult.error) {
|
|
173
|
+
this.handleError(resolveSchemaResult.error);
|
|
174
|
+
return ABORT_EARLY_EITHER;
|
|
175
|
+
}
|
|
176
|
+
const deserializationResult = (0, core_1.parseMessage)(resolveMessageResult.result, resolveSchemaResult.result, this.errorResolver);
|
|
177
|
+
if ((0, core_1.isMessageError)(deserializationResult.error)) {
|
|
178
|
+
this.handleError(deserializationResult.error);
|
|
179
|
+
return ABORT_EARLY_EITHER;
|
|
180
|
+
}
|
|
181
|
+
// Empty content for whatever reason
|
|
182
|
+
if (!deserializationResult.result) {
|
|
183
|
+
return ABORT_EARLY_EITHER;
|
|
184
|
+
}
|
|
185
|
+
return {
|
|
186
|
+
result: deserializationResult.result,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
async failProcessing(_message) {
|
|
190
|
+
// Not implemented yet - needs dead letter queue
|
|
191
|
+
}
|
|
158
192
|
}
|
|
159
193
|
exports.AbstractSqsConsumer = AbstractSqsConsumer;
|
|
160
194
|
//# sourceMappingURL=AbstractSqsConsumer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsConsumer.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumer.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AbstractSqsConsumer.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumer.ts"],"names":[],"mappings":";;;AAUA,sDAKoC;AACpC,+CAAuC;AAIvC,gEAA0D;AAG1D,6DAAyD;AAEzD,MAAM,kBAAkB,GAA2B;IACjD,KAAK,EAAE,OAAO;CACf,CAAA;AA2BD,MAAsB,mBAoBpB,SAAQ,uCAQP;IAGO,QAAQ,CAAW;IACV,+BAA+B,CAAkC;IAEjE,uBAAuB,CAA0B;IACjD,gBAAgB,CAIhC;IAEkB,aAAa,CAAe;IAC5B,sBAAsB,CAA4C;IAClE,gBAAgB,CAAkB;IAErD,YACE,YAAqC,EACrC,OAA4B,EAC5B,gBAAkC;QAElC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5B,IAAI,CAAC,+BAA+B,GAAG,YAAY,CAAC,+BAA+B,CAAA;QACnF,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC,qBAAqB,CAAA;QAEvD,IAAI,CAAC,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,IAAI,EAAE,CAAA;QAC9D,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEpE,IAAI,CAAC,sBAAsB,GAAG,IAAI,6BAAsB,CAAqB;YAC3E,cAAc;YACd,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C,CAAC,CAAA;QACF,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAgB,CAI1C;YACA,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,eAAe,EAAE,OAAO,CAAC,QAAQ;SAClC,CAAC,CAAA;QACF,IAAI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QAC3B,CAAC;QAED,oCAAoC;QACpC,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,CAAC;YAClC,OAAO,kBAAkB,CAAA;QAC3B,CAAC;QAED,OAAO;YACL,MAAM,EAAE,qBAAqB,CAAC,MAAM;SACrC,CAAA;IACH,CAAC;IAEO,KAAK,CAAC,cAAc,CAAC,QAAoB;QAC/C,gDAAgD;IAClD,CAAC;CACF;AA/SD,kDA+SC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Either } from '@lokalise/node-core';
|
|
2
|
-
import type { AsyncPublisher, MessageInvalidFormatError, MessageValidationError,
|
|
2
|
+
import type { AsyncPublisher, MessageInvalidFormatError, MessageValidationError, BarrierResult, QueuePublisherOptions } from '@message-queue-toolkit/core';
|
|
3
3
|
import type { ZodSchema } from 'zod';
|
|
4
4
|
import type { SQSMessage } from '../types/MessageTypes';
|
|
5
5
|
import type { SQSCreationConfig } from './AbstractSqsConsumer';
|
|
@@ -9,14 +9,16 @@ export type SQSMessageOptions = {
|
|
|
9
9
|
MessageGroupId?: string;
|
|
10
10
|
MessageDeduplicationId?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare abstract class
|
|
12
|
+
export declare abstract class AbstractSqsPublisher<MessagePayloadType extends object> extends AbstractSqsService<MessagePayloadType> implements AsyncPublisher<MessagePayloadType, SQSMessageOptions> {
|
|
13
13
|
private readonly messageSchemaContainer;
|
|
14
|
-
|
|
14
|
+
private isInitted;
|
|
15
|
+
private initPromise?;
|
|
16
|
+
constructor(dependencies: SQSDependencies, options: QueuePublisherOptions<SQSCreationConfig, SQSQueueLocatorType, MessagePayloadType>);
|
|
15
17
|
publish(message: MessagePayloadType, options?: SQSMessageOptions): Promise<void>;
|
|
16
18
|
protected resolveNextFunction(): () => void;
|
|
17
19
|
protected resolveMessage(_message: SQSMessage): Either<MessageInvalidFormatError | MessageValidationError, unknown>;
|
|
18
20
|
protected processPrehandlers(): Promise<unknown>;
|
|
19
|
-
protected preHandlerBarrier(): Promise<BarrierResult<
|
|
21
|
+
protected preHandlerBarrier<BarrierOutput>(): Promise<BarrierResult<BarrierOutput>>;
|
|
20
22
|
processMessage(): Promise<Either<'retryLater', 'success'>>;
|
|
21
23
|
protected resolveSchema(message: MessagePayloadType): Either<Error, ZodSchema<MessagePayloadType>>;
|
|
22
24
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSqsPublisher = void 0;
|
|
4
|
+
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
|
+
const core_1 = require("@message-queue-toolkit/core");
|
|
6
|
+
const AbstractSqsService_1 = require("./AbstractSqsService");
|
|
7
|
+
class AbstractSqsPublisher extends AbstractSqsService_1.AbstractSqsService {
|
|
8
|
+
messageSchemaContainer;
|
|
9
|
+
isInitted;
|
|
10
|
+
initPromise;
|
|
11
|
+
constructor(dependencies, options) {
|
|
12
|
+
super(dependencies, options);
|
|
13
|
+
const messageSchemas = options.messageSchemas;
|
|
14
|
+
this.messageSchemaContainer = new core_1.MessageSchemaContainer({
|
|
15
|
+
messageSchemas,
|
|
16
|
+
messageTypeField: options.messageTypeField,
|
|
17
|
+
});
|
|
18
|
+
this.isInitted = false;
|
|
19
|
+
}
|
|
20
|
+
async publish(message, options = {}) {
|
|
21
|
+
const messageSchemaResult = this.resolveSchema(message);
|
|
22
|
+
if (messageSchemaResult.error) {
|
|
23
|
+
throw messageSchemaResult.error;
|
|
24
|
+
}
|
|
25
|
+
// If it's not initted yet, do the lazy init
|
|
26
|
+
if (!this.isInitted) {
|
|
27
|
+
// avoid multiple concurrent inits
|
|
28
|
+
if (!this.initPromise) {
|
|
29
|
+
this.initPromise = this.init();
|
|
30
|
+
}
|
|
31
|
+
await this.initPromise;
|
|
32
|
+
}
|
|
33
|
+
try {
|
|
34
|
+
messageSchemaResult.result.parse(message);
|
|
35
|
+
if (this.logMessages) {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
const resolvedLogMessage = this.resolveMessageLog(message, message[this.messageTypeField]);
|
|
38
|
+
this.logMessage(resolvedLogMessage);
|
|
39
|
+
}
|
|
40
|
+
const input = {
|
|
41
|
+
// SendMessageRequest
|
|
42
|
+
QueueUrl: this.queueUrl,
|
|
43
|
+
MessageBody: JSON.stringify(message),
|
|
44
|
+
...options,
|
|
45
|
+
};
|
|
46
|
+
const command = new client_sqs_1.SendMessageCommand(input);
|
|
47
|
+
await this.sqsClient.send(command);
|
|
48
|
+
this.handleMessageProcessed(message, 'published');
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
this.handleError(error);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/* c8 ignore start */
|
|
56
|
+
resolveNextFunction() {
|
|
57
|
+
throw new Error('Not implemented for publisher');
|
|
58
|
+
}
|
|
59
|
+
resolveMessage(_message) {
|
|
60
|
+
throw new Error('Not implemented for publisher');
|
|
61
|
+
}
|
|
62
|
+
processPrehandlers() {
|
|
63
|
+
throw new Error('Not implemented for publisher');
|
|
64
|
+
}
|
|
65
|
+
preHandlerBarrier() {
|
|
66
|
+
throw new Error('Not implemented for publisher');
|
|
67
|
+
}
|
|
68
|
+
processMessage() {
|
|
69
|
+
throw new Error('Not implemented for publisher');
|
|
70
|
+
}
|
|
71
|
+
/* c8 ignore stop */
|
|
72
|
+
resolveSchema(message) {
|
|
73
|
+
return this.messageSchemaContainer.resolveSchema(message);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
exports.AbstractSqsPublisher = AbstractSqsPublisher;
|
|
77
|
+
//# sourceMappingURL=AbstractSqsPublisher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractSqsPublisher.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsPublisher.ts"],"names":[],"mappings":";;;AACA,oDAAwD;AASxD,sDAAoE;AAMpE,6DAAyD;AA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rB,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;gBACpC,GAAG,OAAO;aACuB,CAAA;YACnC,MAAM,OAAO,GAAG,IAAI,+BAAkB,CAAC,KAAK,CAAC,CAAA;YAC7C,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;YAClC,IAAI,CAAC,sBAAsB,CAAC,OAAO,EAAE,WAAW,CAAC,CAAA;QACnD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;YACvB,MAAM,KAAK,CAAA;QACb,CAAC;IACH,CAAC;IAED,qBAAqB;IACF,mBAAmB;QACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAES,cAAc,CACtB,QAAoB;QAEpB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,kBAAkB;QACnC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,iBAAiB;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEQ,cAAc;QACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IACD,oBAAoB;IAED,aAAa,CAC9B,OAA2B;QAE3B,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC3D,CAAC;CACF;AA1FD,oDA0FC"}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
import type { SQSClient
|
|
2
|
-
import type { QueueConsumerDependencies, QueueDependencies,
|
|
1
|
+
import type { SQSClient } from '@aws-sdk/client-sqs';
|
|
2
|
+
import type { QueueConsumerDependencies, QueueDependencies, QueueOptions } from '@message-queue-toolkit/core';
|
|
3
3
|
import { AbstractQueueService } from '@message-queue-toolkit/core';
|
|
4
|
-
import type { ZodSchema } from 'zod';
|
|
5
4
|
import type { SQSMessage } from '../types/MessageTypes';
|
|
6
5
|
import type { SQSCreationConfig } from './AbstractSqsConsumer';
|
|
7
|
-
import type { SQSMessageOptions } from './AbstractSqsPublisherMultiSchema';
|
|
8
6
|
export type SQSDependencies = QueueDependencies & {
|
|
9
7
|
sqsClient: SQSClient;
|
|
10
8
|
};
|
|
11
9
|
export type SQSConsumerDependencies = SQSDependencies & QueueConsumerDependencies;
|
|
12
|
-
export type SQSQueueConfig = CreateQueueRequest;
|
|
13
10
|
export type SQSQueueLocatorType = {
|
|
14
11
|
queueUrl: string;
|
|
15
12
|
};
|
|
16
|
-
export declare abstract class AbstractSqsService<MessagePayloadType extends object, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, SQSOptionsType extends
|
|
13
|
+
export declare abstract class AbstractSqsService<MessagePayloadType extends object, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, SQSOptionsType extends QueueOptions<CreationConfigType, QueueLocatorType> = QueueOptions<CreationConfigType, QueueLocatorType>, DependenciesType extends SQSDependencies = SQSDependencies, PrehandlerOutput = unknown, ExecutionContext = unknown> extends AbstractQueueService<MessagePayloadType, SQSMessage, DependenciesType, CreationConfigType, QueueLocatorType, SQSOptionsType, PrehandlerOutput, ExecutionContext> {
|
|
17
14
|
protected readonly sqsClient: SQSClient;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
queueArn: string;
|
|
21
|
-
private isInitted;
|
|
22
|
-
private initPromise?;
|
|
15
|
+
protected queueName: string;
|
|
16
|
+
protected queueUrl: string;
|
|
17
|
+
protected queueArn: string;
|
|
23
18
|
constructor(dependencies: DependenciesType, options: SQSOptionsType);
|
|
24
19
|
init(): Promise<void>;
|
|
25
|
-
protected internalPublish(message: MessagePayloadType, messageSchema: ZodSchema<MessagePayloadType>, options?: SQSMessageOptions): Promise<void>;
|
|
26
20
|
close(): Promise<void>;
|
|
27
21
|
}
|
|
@@ -1,64 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AbstractSqsService = void 0;
|
|
4
|
-
const client_sqs_1 = require("@aws-sdk/client-sqs");
|
|
5
4
|
const core_1 = require("@message-queue-toolkit/core");
|
|
6
5
|
const sqsInitter_1 = require("../utils/sqsInitter");
|
|
7
6
|
class AbstractSqsService extends core_1.AbstractQueueService {
|
|
8
7
|
sqsClient;
|
|
9
8
|
// @ts-ignore
|
|
10
|
-
queueUrl;
|
|
11
|
-
// @ts-ignore
|
|
12
9
|
queueName;
|
|
13
10
|
// @ts-ignore
|
|
11
|
+
queueUrl;
|
|
12
|
+
// @ts-ignore
|
|
14
13
|
queueArn;
|
|
15
|
-
isInitted;
|
|
16
|
-
initPromise;
|
|
17
14
|
constructor(dependencies, options) {
|
|
18
15
|
super(dependencies, options);
|
|
19
|
-
this.isInitted = false;
|
|
20
16
|
this.sqsClient = dependencies.sqsClient;
|
|
21
17
|
}
|
|
22
18
|
async init() {
|
|
23
19
|
if (this.deletionConfig && this.creationConfig) {
|
|
24
20
|
await (0, sqsInitter_1.deleteSqs)(this.sqsClient, this.deletionConfig, this.creationConfig);
|
|
25
21
|
}
|
|
26
|
-
const {
|
|
27
|
-
this.queueArn = queueArn;
|
|
28
|
-
this.queueUrl = queueUrl;
|
|
22
|
+
const { queueName, queueUrl, queueArn } = await (0, sqsInitter_1.initSqs)(this.sqsClient, this.locatorConfig, this.creationConfig);
|
|
29
23
|
this.queueName = queueName;
|
|
30
|
-
this.
|
|
31
|
-
|
|
32
|
-
async internalPublish(message, messageSchema, options = {}) {
|
|
33
|
-
// If it's not initted yet, do the lazy init
|
|
34
|
-
if (!this.isInitted) {
|
|
35
|
-
// avoid multiple concurrent inits
|
|
36
|
-
if (!this.initPromise) {
|
|
37
|
-
this.initPromise = this.init();
|
|
38
|
-
}
|
|
39
|
-
await this.initPromise;
|
|
40
|
-
}
|
|
41
|
-
try {
|
|
42
|
-
messageSchema.parse(message);
|
|
43
|
-
if (this.logMessages) {
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
const resolvedLogMessage = this.resolveMessageLog(message, message[this.messageTypeField]);
|
|
46
|
-
this.logMessage(resolvedLogMessage);
|
|
47
|
-
}
|
|
48
|
-
const input = {
|
|
49
|
-
// SendMessageRequest
|
|
50
|
-
QueueUrl: this.queueUrl,
|
|
51
|
-
MessageBody: JSON.stringify(message),
|
|
52
|
-
...options,
|
|
53
|
-
};
|
|
54
|
-
const command = new client_sqs_1.SendMessageCommand(input);
|
|
55
|
-
await this.sqsClient.send(command);
|
|
56
|
-
this.handleMessageProcessed(message, 'published');
|
|
57
|
-
}
|
|
58
|
-
catch (error) {
|
|
59
|
-
this.handleError(error);
|
|
60
|
-
throw error;
|
|
61
|
-
}
|
|
24
|
+
this.queueUrl = queueUrl;
|
|
25
|
+
this.queueArn = queueArn;
|
|
62
26
|
}
|
|
63
27
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
64
28
|
async close() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsService.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AbstractSqsService.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsService.ts"],"names":[],"mappings":";;;AAMA,sDAAkE;AAGlE,oDAAwD;AAcxD,MAAsB,kBAWpB,SAAQ,2BAST;IACoB,SAAS,CAAW;IAEvC,aAAa;IACH,SAAS,CAAQ;IAC3B,aAAa;IACH,QAAQ,CAAQ;IAC1B,aAAa;IACH,QAAQ,CAAQ;IAE1B,YAAY,YAA8B,EAAE,OAAuB;QACjE,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5B,IAAI,CAAC,SAAS,GAAG,YAAY,CAAC,SAAS,CAAA;IACzC,CAAC;IAEM,KAAK,CAAC,IAAI;QACf,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YAC/C,MAAM,IAAA,sBAAS,EAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;QAC3E,CAAC;QACD,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,oBAAO,EACrD,IAAI,CAAC,SAAS,EACd,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,cAAc,CACpB,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAED,4DAA4D;IAC5C,KAAK,CAAC,KAAK,KAAmB,CAAC;CAChD;AAnDD,gDAmDC"}
|
|
@@ -39,11 +39,7 @@ async function initSqs(sqsClient, locatorConfig, creationConfig) {
|
|
|
39
39
|
const queueUrl = locatorConfig.queueUrl;
|
|
40
40
|
const splitUrl = queueUrl.split('/');
|
|
41
41
|
const queueName = splitUrl[splitUrl.length - 1];
|
|
42
|
-
return {
|
|
43
|
-
queueArn,
|
|
44
|
-
queueUrl,
|
|
45
|
-
queueName,
|
|
46
|
-
};
|
|
42
|
+
return { queueArn, queueUrl, queueName };
|
|
47
43
|
}
|
|
48
44
|
// create new queue if does not exist
|
|
49
45
|
if (!creationConfig?.queue.QueueName) {
|
|
@@ -55,11 +51,7 @@ async function initSqs(sqsClient, locatorConfig, creationConfig) {
|
|
|
55
51
|
updateAttributesIfExists: creationConfig.updateAttributesIfExists,
|
|
56
52
|
});
|
|
57
53
|
const queueName = creationConfig.queue.QueueName;
|
|
58
|
-
return {
|
|
59
|
-
queueUrl,
|
|
60
|
-
queueArn,
|
|
61
|
-
queueName,
|
|
62
|
-
};
|
|
54
|
+
return { queueUrl, queueArn, queueName };
|
|
63
55
|
}
|
|
64
56
|
exports.initSqs = initSqs;
|
|
65
57
|
//# sourceMappingURL=sqsInitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sqsInitter.js","sourceRoot":"","sources":["../../../lib/utils/sqsInitter.ts"],"names":[],"mappings":";;;AAAA,oDAA+D;AAG/D,sDAA0D;AAK1D,yCAAyE;AAElE,KAAK,UAAU,SAAS,CAC7B,SAAoB,EACpB,cAA8B,EAC9B,cAAiC;IAEjC,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,CAAC;QACnC,OAAM;IACR,CAAC;IAED,IAAI,IAAA,mBAAY,GAAE,IAAI,CAAC,cAAc,CAAC,uBAAuB,EAAE,CAAC;QAC9D,MAAM,IAAI,KAAK,CACb,wMAAwM,CACzM,CAAA;IACH,CAAC;IAED,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IAED,MAAM,IAAA,sBAAW,EACf,SAAS,EACT,cAAc,CAAC,KAAK,CAAC,SAAS,EAC9B,cAAc,CAAC,mBAAmB,KAAK,KAAK,CAC7C,CAAA;AACH,CAAC;AAxBD,8BAwBC;AAEM,KAAK,UAAU,qBAAqB,CACzC,SAAoB,EACpB,QAAgB,EAChB,aAA0D,EAAE;IAE5D,MAAM,OAAO,GAAG,IAAI,sCAAyB,CAAC;QAC5C,QAAQ,EAAE,QAAQ;QAClB,UAAU,EAAE,UAAU;KACvB,CAAC,CAAA;IACF,MAAM,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AAC/B,CAAC;AAVD,sDAUC;AAEM,KAAK,UAAU,OAAO,CAC3B,SAAoB,EACpB,aAAmC,EACnC,cAAkC;IAElC,4BAA4B;IAC5B,IAAI,aAAa,EAAE,CAAC;QAClB,MAAM,WAAW,G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,KAAK,CAAC,iEAAiE,CAAC,CAAA;IACpF,CAAC;IAED,mBAAmB;IACnB,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,MAAM,IAAA,sBAAW,EAAC,SAAS,EAAE,cAAc,CAAC,KAAK,EAAE;QAChF,qCAAqC,EAAE,cAAc,CAAC,qCAAqC;QAC3F,wBAAwB,EAAE,cAAc,CAAC,wBAAwB;KAClE,CAAC,CAAA;IACF,MAAM,SAAS,GAAG,cAAc,CAAC,KAAK,CAAC,SAAS,CAAA;IAEhD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAA;AAC1C,CAAC;AArCD,0BAqCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@message-queue-toolkit/sqs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"description": "SQS adapter for message-queue-toolkit",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@lokalise/node-core": "^9.10.1",
|
|
29
|
-
"sqs-consumer": "^
|
|
29
|
+
"sqs-consumer": "^9.1.0",
|
|
30
30
|
"zod": "^3.22.4"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@types/node": "^20.11.25",
|
|
40
40
|
"@typescript-eslint/eslint-plugin": "^7.1.1",
|
|
41
41
|
"@typescript-eslint/parser": "^7.1.1",
|
|
42
|
-
"@vitest/coverage-v8": "^1.
|
|
42
|
+
"@vitest/coverage-v8": "^1.4.0",
|
|
43
43
|
"awilix": "^10.0.1",
|
|
44
44
|
"awilix-manager": "^5.1.0",
|
|
45
45
|
"del-cli": "^5.1.0",
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Either } from '@lokalise/node-core';
|
|
2
|
-
import type { MonoSchemaQueueOptions, QueueConsumer as QueueConsumer, BarrierResult, Prehandler, PrehandlingOutputs } from '@message-queue-toolkit/core';
|
|
3
|
-
import type { ZodSchema } from 'zod';
|
|
4
|
-
import type { ExistingSQSConsumerOptions, NewSQSConsumerOptions, SQSCreationConfig } from './AbstractSqsConsumer';
|
|
5
|
-
import { AbstractSqsConsumer } from './AbstractSqsConsumer';
|
|
6
|
-
import type { SQSConsumerDependencies, SQSQueueLocatorType } from './AbstractSqsService';
|
|
7
|
-
export type CommonSQSConsumerOptionsMono<MessagePayloadType extends object, ExecutionContext, PrehandlerOutput = undefined> = {
|
|
8
|
-
prehandlers?: Prehandler<MessagePayloadType, ExecutionContext, PrehandlerOutput>[];
|
|
9
|
-
};
|
|
10
|
-
export type NewSQSConsumerOptionsMono<MessagePayloadType extends object, ExecutionContext, PrehandlerOutput = undefined, CreationConfigType extends SQSCreationConfig = SQSCreationConfig> = NewSQSConsumerOptions<CreationConfigType> & MonoSchemaQueueOptions<MessagePayloadType> & CommonSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput>;
|
|
11
|
-
export type ExistingSQSConsumerOptionsMono<MessagePayloadType extends object, ExecutionContext, PrehandlerOutput = undefined, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType> = ExistingSQSConsumerOptions<QueueLocatorType> & MonoSchemaQueueOptions<MessagePayloadType> & CommonSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput>;
|
|
12
|
-
export declare abstract class AbstractSqsConsumerMonoSchema<MessagePayloadType extends object, PrehandlerOutput = undefined, ExecutionContext = undefined, BarrierOutput = undefined, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, ConsumerOptionsType extends NewSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput, QueueLocatorType> = NewSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, ExecutionContext, PrehandlerOutput, QueueLocatorType>> extends AbstractSqsConsumer<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, ExecutionContext, PrehandlerOutput, BarrierOutput> implements QueueConsumer {
|
|
13
|
-
private readonly messageSchema;
|
|
14
|
-
private readonly schemaEither;
|
|
15
|
-
private readonly prehandlers;
|
|
16
|
-
protected constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType);
|
|
17
|
-
/**
|
|
18
|
-
* Override to implement barrier pattern
|
|
19
|
-
*/
|
|
20
|
-
protected preHandlerBarrier(_message: MessagePayloadType, _messageType: string): Promise<BarrierResult<BarrierOutput>>;
|
|
21
|
-
abstract processMessage(message: MessagePayloadType, messageType: string, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, BarrierOutput>): Promise<Either<'retryLater', 'success'>>;
|
|
22
|
-
protected processPrehandlers(message: MessagePayloadType, _messageType: string): Promise<PrehandlerOutput>;
|
|
23
|
-
protected resolveNextFunction(prehandlers: Prehandler<MessagePayloadType, ExecutionContext, PrehandlerOutput>[], message: MessagePayloadType, index: number, prehandlerOutput: PrehandlerOutput, resolve: (value: PrehandlerOutput | PromiseLike<PrehandlerOutput>) => void, reject: (err: Error) => void): (prehandlerResult: import("@message-queue-toolkit/core/dist/lib/queues/HandlerContainer").PrehandlerResult) => void;
|
|
24
|
-
protected resolveSchema(): Either<Error, ZodSchema<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
|
|
25
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractSqsConsumerMonoSchema = void 0;
|
|
4
|
-
const AbstractSqsConsumer_1 = require("./AbstractSqsConsumer");
|
|
5
|
-
const DEFAULT_BARRIER_RESULT = {
|
|
6
|
-
isPassing: true,
|
|
7
|
-
output: undefined,
|
|
8
|
-
};
|
|
9
|
-
class AbstractSqsConsumerMonoSchema extends AbstractSqsConsumer_1.AbstractSqsConsumer {
|
|
10
|
-
messageSchema;
|
|
11
|
-
schemaEither;
|
|
12
|
-
prehandlers;
|
|
13
|
-
constructor(dependencies, options) {
|
|
14
|
-
super(dependencies, options);
|
|
15
|
-
this.prehandlers = options.prehandlers ?? [];
|
|
16
|
-
this.messageSchema = options.messageSchema;
|
|
17
|
-
this.schemaEither = {
|
|
18
|
-
result: this.messageSchema,
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Override to implement barrier pattern
|
|
23
|
-
*/
|
|
24
|
-
/* c8 ignore start */
|
|
25
|
-
preHandlerBarrier(_message, _messageType) {
|
|
26
|
-
// @ts-ignore
|
|
27
|
-
return Promise.resolve(DEFAULT_BARRIER_RESULT);
|
|
28
|
-
}
|
|
29
|
-
processPrehandlers(message, _messageType) {
|
|
30
|
-
return this.processPrehandlersInternal(this.prehandlers, message);
|
|
31
|
-
}
|
|
32
|
-
// eslint-disable-next-line max-params
|
|
33
|
-
resolveNextFunction(prehandlers, message, index, prehandlerOutput, resolve, reject) {
|
|
34
|
-
return this.resolveNextPreHandlerFunctionInternal(prehandlers, this, message, index, prehandlerOutput, resolve, reject);
|
|
35
|
-
}
|
|
36
|
-
resolveSchema() {
|
|
37
|
-
return this.schemaEither;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.AbstractSqsConsumerMonoSchema = AbstractSqsConsumerMonoSchema;
|
|
41
|
-
//# sourceMappingURL=AbstractSqsConsumerMonoSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsConsumerMonoSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumerMonoSchema.ts"],"names":[],"mappings":";;;AAeA,+DAA2D;AAG3D,MAAM,sBAAsB,GAAG;IAC7B,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,SAAS;CACT,CAAA;AA4BV,MAAsB,6BAiCpB,SAAQ,yCAQP;IAGgB,aAAa,CAA+B;IAC5C,YAAY,CAA8C;IAC1D,WAAW,CAAsE;IAElG,YAAsB,YAAqC,EAAE,OAA4B;QACvF,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAE5B,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAA;QAC5C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAC1C,IAAI,CAAC,YAAY,GAAG;YAClB,MAAM,EAAE,IAAI,CAAC,aAAa;SAC3B,CAAA;IACH,CAAC;IAED;;OAEG;IACH,qBAAqB;IACF,iBAAiB,CAAC,QAA4B,EAAE,YAAoB;QACrF,aAAa;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,sBAAsD,CAAC,CAAA;IAChF,CAAC;IASkB,kBAAkB,CAAC,OAA2B,EAAE,YAAoB;QACrF,OAAO,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,WAAW,EAAE,OAAO,CAAC,CAAA;IACnE,CAAC;IAED,sCAAsC;IACnB,mBAAmB,CACpC,WAAiF,EACjF,OAA2B,EAC3B,KAAa,EACb,gBAAkC,EAClC,OAA0E,EAC1E,MAA4B;QAE5B,OAAO,IAAI,CAAC,qCAAqC,CAC/C,WAAW,EACX,IAAmC,EACnC,OAAO,EACP,KAAK,EACL,gBAAgB,EAChB,OAAO,EACP,MAAM,CACP,CAAA;IACH,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CACF;AArGD,sEAqGC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Either } from '@lokalise/node-core';
|
|
2
|
-
import { HandlerContainer, MessageSchemaContainer } from '@message-queue-toolkit/core';
|
|
3
|
-
import type { ExistingQueueOptionsMultiSchema, NewQueueOptionsMultiSchema, BarrierResult, Prehandler, PrehandlingOutputs } from '@message-queue-toolkit/core';
|
|
4
|
-
import type { ConsumerOptions } from 'sqs-consumer/src/types';
|
|
5
|
-
import type { SQSCreationConfig } from './AbstractSqsConsumer';
|
|
6
|
-
import { AbstractSqsConsumer } from './AbstractSqsConsumer';
|
|
7
|
-
import type { SQSConsumerDependencies, SQSQueueLocatorType } from './AbstractSqsService';
|
|
8
|
-
export type NewSQSConsumerOptionsMultiSchema<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput, CreationConfigType extends SQSCreationConfig> = NewQueueOptionsMultiSchema<MessagePayloadSchemas, CreationConfigType, ExecutionContext, PrehandlerOutput> & {
|
|
9
|
-
consumerOverrides?: Partial<ConsumerOptions>;
|
|
10
|
-
};
|
|
11
|
-
export type ExistingSQSConsumerOptionsMultiSchema<MessagePayloadSchemas extends object, ExecutionContext, PrehandlerOutput, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType> = ExistingQueueOptionsMultiSchema<MessagePayloadSchemas, QueueLocatorType, ExecutionContext, PrehandlerOutput> & {
|
|
12
|
-
consumerOverrides?: Partial<ConsumerOptions>;
|
|
13
|
-
};
|
|
14
|
-
export declare abstract class AbstractSqsConsumerMultiSchema<MessagePayloadType extends object, ExecutionContext, PrehandlerOutput = undefined, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, ConsumerOptionsType extends NewSQSConsumerOptionsMultiSchema<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType> = NewSQSConsumerOptionsMultiSchema<MessagePayloadType, ExecutionContext, PrehandlerOutput, CreationConfigType>> extends AbstractSqsConsumer<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, ExecutionContext, PrehandlerOutput> {
|
|
15
|
-
messageSchemaContainer: MessageSchemaContainer<MessagePayloadType>;
|
|
16
|
-
handlerContainer: HandlerContainer<MessagePayloadType, ExecutionContext, PrehandlerOutput>;
|
|
17
|
-
protected readonly executionContext: ExecutionContext;
|
|
18
|
-
constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType, executionContext: ExecutionContext);
|
|
19
|
-
protected resolveSchema(message: MessagePayloadType): Either<Error, import("zod").ZodType<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
|
|
20
|
-
processMessage(message: MessagePayloadType, messageType: string, prehandlingOutputs: PrehandlingOutputs<PrehandlerOutput, any>): Promise<Either<'retryLater', 'success'>>;
|
|
21
|
-
protected processPrehandlers(message: MessagePayloadType, messageType: string): Promise<PrehandlerOutput>;
|
|
22
|
-
protected resolveNextFunction(prehandlers: Prehandler<MessagePayloadType, ExecutionContext, unknown>[], message: MessagePayloadType, index: number, prehandlerOutput: PrehandlerOutput, resolve: (value: PrehandlerOutput | PromiseLike<PrehandlerOutput>) => void, reject: (err: Error) => void): (prehandlerResult: import("@message-queue-toolkit/core/dist/lib/queues/HandlerContainer").PrehandlerResult) => void;
|
|
23
|
-
protected resolveMessageLog(message: MessagePayloadType, messageType: string): unknown;
|
|
24
|
-
protected preHandlerBarrier<BarrierOutput>(message: MessagePayloadType, messageType: string, prehandlerOutput: PrehandlerOutput): Promise<BarrierResult<BarrierOutput>>;
|
|
25
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractSqsConsumerMultiSchema = void 0;
|
|
4
|
-
const core_1 = require("@message-queue-toolkit/core");
|
|
5
|
-
const AbstractSqsConsumer_1 = require("./AbstractSqsConsumer");
|
|
6
|
-
class AbstractSqsConsumerMultiSchema extends AbstractSqsConsumer_1.AbstractSqsConsumer {
|
|
7
|
-
messageSchemaContainer;
|
|
8
|
-
handlerContainer;
|
|
9
|
-
executionContext;
|
|
10
|
-
constructor(dependencies, options, executionContext) {
|
|
11
|
-
super(dependencies, options);
|
|
12
|
-
const messageSchemas = options.handlers.map((entry) => entry.schema);
|
|
13
|
-
this.messageSchemaContainer = new core_1.MessageSchemaContainer({
|
|
14
|
-
messageSchemas,
|
|
15
|
-
messageTypeField: options.messageTypeField,
|
|
16
|
-
});
|
|
17
|
-
this.handlerContainer = new core_1.HandlerContainer({
|
|
18
|
-
messageTypeField: this.messageTypeField,
|
|
19
|
-
messageHandlers: options.handlers,
|
|
20
|
-
});
|
|
21
|
-
this.executionContext = executionContext;
|
|
22
|
-
}
|
|
23
|
-
resolveSchema(message) {
|
|
24
|
-
return this.messageSchemaContainer.resolveSchema(message);
|
|
25
|
-
}
|
|
26
|
-
async processMessage(message, messageType,
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
28
|
-
prehandlingOutputs) {
|
|
29
|
-
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
30
|
-
return handler.handler(message, this.executionContext, prehandlingOutputs);
|
|
31
|
-
}
|
|
32
|
-
processPrehandlers(message, messageType) {
|
|
33
|
-
const handlerConfig = this.handlerContainer.resolveHandler(messageType);
|
|
34
|
-
return this.processPrehandlersInternal(handlerConfig.prehandlers, message);
|
|
35
|
-
}
|
|
36
|
-
// eslint-disable-next-line max-params
|
|
37
|
-
resolveNextFunction(prehandlers, message, index, prehandlerOutput, resolve, reject) {
|
|
38
|
-
return this.resolveNextPreHandlerFunctionInternal(prehandlers, this.executionContext, message, index, prehandlerOutput, resolve, reject);
|
|
39
|
-
}
|
|
40
|
-
resolveMessageLog(message, messageType) {
|
|
41
|
-
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
42
|
-
return handler.messageLogFormatter(message);
|
|
43
|
-
}
|
|
44
|
-
async preHandlerBarrier(message, messageType, prehandlerOutput) {
|
|
45
|
-
const handler = this.handlerContainer.resolveHandler(messageType);
|
|
46
|
-
// @ts-ignore
|
|
47
|
-
return handler.preHandlerBarrier
|
|
48
|
-
? // @ts-ignore
|
|
49
|
-
await handler.preHandlerBarrier(message, this.executionContext, prehandlerOutput)
|
|
50
|
-
: {
|
|
51
|
-
isPassing: true,
|
|
52
|
-
output: undefined,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.AbstractSqsConsumerMultiSchema = AbstractSqsConsumerMultiSchema;
|
|
57
|
-
//# sourceMappingURL=AbstractSqsConsumerMultiSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsConsumerMultiSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumerMultiSchema.ts"],"names":[],"mappings":";;;AACA,sDAAsF;AAWtF,+DAA2D;AA+B3D,MAAsB,8BAiBpB,SAAQ,yCAOT;IACC,sBAAsB,CAA4C;IAClE,gBAAgB,CAA0E;IACvE,gBAAgB,CAAkB;IAErD,YACE,YAAqC,EACrC,OAA4B,EAC5B,gBAAkC;QAElC,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAE5B,MAAM,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAEpE,IAAI,CAAC,sBAAsB,GAAG,IAAI,6BAAsB,CAAqB;YAC3E,cAAc;YACd,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C,CAAC,CAAA;QACF,IAAI,CAAC,gBAAgB,GAAG,IAAI,uBAAgB,CAI1C;YACA,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,eAAe,EAAE,OAAO,CAAC,QAAQ;SAClC,CAAC,CAAA;QACF,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;IAC1C,CAAC;IAEkB,aAAa,CAAC,OAA2B;QAC1D,OAAO,IAAI,CAAC,sBAAsB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC3D,CAAC;IAEe,KAAK,CAAC,cAAc,CAClC,OAA2B,EAC3B,WAAmB;IACnB,8DAA8D;IAC9D,kBAA6D;QAE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AAS;aAClB,CAAA;IACP,CAAC;CACF;AApHD,wEAoHC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { Either } from '@lokalise/node-core';
|
|
2
|
-
import type { AsyncPublisher, MessageInvalidFormatError, MessageValidationError, ExistingQueueOptions, MonoSchemaQueueOptions, NewQueueOptions, BarrierResult } from '@message-queue-toolkit/core';
|
|
3
|
-
import type { ZodSchema } from 'zod';
|
|
4
|
-
import type { SQSCreationConfig } from './AbstractSqsConsumer';
|
|
5
|
-
import type { SQSMessageOptions } from './AbstractSqsPublisherMultiSchema';
|
|
6
|
-
import type { SQSDependencies, SQSQueueLocatorType } from './AbstractSqsService';
|
|
7
|
-
import { AbstractSqsService } from './AbstractSqsService';
|
|
8
|
-
export declare abstract class AbstractSqsPublisherMonoSchema<MessagePayloadType extends object> extends AbstractSqsService<MessagePayloadType> implements AsyncPublisher<MessagePayloadType, SQSMessageOptions> {
|
|
9
|
-
private readonly messageSchema;
|
|
10
|
-
private readonly schemaEither;
|
|
11
|
-
constructor(dependencies: SQSDependencies, options: (NewQueueOptions<SQSCreationConfig> | ExistingQueueOptions<SQSQueueLocatorType>) & MonoSchemaQueueOptions<MessagePayloadType>);
|
|
12
|
-
publish(message: MessagePayloadType, options?: SQSMessageOptions): Promise<void>;
|
|
13
|
-
protected resolveNextFunction(): () => void;
|
|
14
|
-
protected resolveMessage(): Either<MessageInvalidFormatError | MessageValidationError, unknown>;
|
|
15
|
-
protected processPrehandlers(): Promise<unknown>;
|
|
16
|
-
protected preHandlerBarrier(): Promise<BarrierResult<unknown>>;
|
|
17
|
-
processMessage(): Promise<Either<'retryLater', 'success'>>;
|
|
18
|
-
protected resolveSchema(): Either<Error, ZodSchema<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
|
|
19
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractSqsPublisherMonoSchema = void 0;
|
|
4
|
-
const AbstractSqsService_1 = require("./AbstractSqsService");
|
|
5
|
-
class AbstractSqsPublisherMonoSchema extends AbstractSqsService_1.AbstractSqsService {
|
|
6
|
-
messageSchema;
|
|
7
|
-
schemaEither;
|
|
8
|
-
constructor(dependencies, options) {
|
|
9
|
-
super(dependencies, options);
|
|
10
|
-
this.messageSchema = options.messageSchema;
|
|
11
|
-
this.schemaEither = {
|
|
12
|
-
result: this.messageSchema,
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
async publish(message, options = {}) {
|
|
16
|
-
return this.internalPublish(message, this.messageSchema, options);
|
|
17
|
-
}
|
|
18
|
-
/* c8 ignore start */
|
|
19
|
-
resolveNextFunction() {
|
|
20
|
-
throw new Error('Not implemented for publisher');
|
|
21
|
-
}
|
|
22
|
-
resolveMessage() {
|
|
23
|
-
throw new Error('Not implemented for publisher');
|
|
24
|
-
}
|
|
25
|
-
processPrehandlers() {
|
|
26
|
-
throw new Error('Not implemented for publisher');
|
|
27
|
-
}
|
|
28
|
-
preHandlerBarrier() {
|
|
29
|
-
throw new Error('Not implemented for publisher');
|
|
30
|
-
}
|
|
31
|
-
processMessage() {
|
|
32
|
-
throw new Error('Not implemented for publisher');
|
|
33
|
-
}
|
|
34
|
-
resolveSchema() {
|
|
35
|
-
return this.schemaEither;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.AbstractSqsPublisherMonoSchema = AbstractSqsPublisherMonoSchema;
|
|
39
|
-
//# sourceMappingURL=AbstractSqsPublisherMonoSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsPublisherMonoSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsPublisherMonoSchema.ts"],"names":[],"mappings":";;;AAeA,6DAAyD;AAEzD,MAAsB,8BACpB,SAAQ,uCAAsC;IAG7B,aAAa,CAA+B;IAC5C,YAAY,CAA8C;IAE3E,YACE,YAA6B,EAC7B,OAC4C;QAE5C,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAC5B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAE1C,IAAI,CAAC,YAAY,GAAG;YAClB,MAAM,EAAE,IAAI,CAAC,aAAa;SAC3B,CAAA;IACH,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAA2B,EAAE,UAA6B,EAAE;QACxE,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAA;IACnE,CAAC;IAED,qBAAqB;IACF,mBAAmB;QACpC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,cAAc;QAI/B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,kBAAkB;QACnC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,iBAAiB;QAClC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEQ,cAAc;QACrB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;IAClD,CAAC;IAEkB,aAAa;QAC9B,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CAEF;AApDD,wEAoDC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AbstractSqsPublisherMultiSchema = void 0;
|
|
4
|
-
const core_1 = require("@message-queue-toolkit/core");
|
|
5
|
-
const AbstractSqsService_1 = require("./AbstractSqsService");
|
|
6
|
-
class AbstractSqsPublisherMultiSchema extends AbstractSqsService_1.AbstractSqsService {
|
|
7
|
-
messageSchemaContainer;
|
|
8
|
-
constructor(dependencies, options) {
|
|
9
|
-
super(dependencies, options);
|
|
10
|
-
const messageSchemas = options.messageSchemas;
|
|
11
|
-
this.messageSchemaContainer = new core_1.MessageSchemaContainer({
|
|
12
|
-
messageSchemas,
|
|
13
|
-
messageTypeField: options.messageTypeField,
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
async publish(message, options = {}) {
|
|
17
|
-
const messageSchemaResult = this.resolveSchema(message);
|
|
18
|
-
if (messageSchemaResult.error) {
|
|
19
|
-
throw messageSchemaResult.error;
|
|
20
|
-
}
|
|
21
|
-
return this.internalPublish(message, messageSchemaResult.result, options);
|
|
22
|
-
}
|
|
23
|
-
/* c8 ignore start */
|
|
24
|
-
resolveNextFunction() {
|
|
25
|
-
throw new Error('Not implemented for publisher');
|
|
26
|
-
}
|
|
27
|
-
resolveMessage(_message) {
|
|
28
|
-
throw new Error('Not implemented for publisher');
|
|
29
|
-
}
|
|
30
|
-
processPrehandlers() {
|
|
31
|
-
throw new Error('Not implemented for publisher');
|
|
32
|
-
}
|
|
33
|
-
preHandlerBarrier() {
|
|
34
|
-
throw new Error('Not implemented for publisher');
|
|
35
|
-
}
|
|
36
|
-
processMessage() {
|
|
37
|
-
throw new Error('Not implemented for publisher');
|
|
38
|
-
}
|
|
39
|
-
/* c8 ignore stop */
|
|
40
|
-
resolveSchema(message) {
|
|
41
|
-
return this.messageSchemaContainer.resolveSchema(message);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.AbstractSqsPublisherMultiSchema = AbstractSqsPublisherMultiSchema;
|
|
45
|
-
//# sourceMappingURL=AbstractSqsPublisherMultiSchema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AbstractSqsPublisherMultiSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsPublisherMultiSchema.ts"],"names":[],"mappings":";;;AAUA,sDAAoE;AAMpE,6DAAyD;AAQzD,MAAsB,+BACpB,SAAQ,uCAAsC;IAG7B,sBAAsB,CAA4C;IAEnF,YACE,YAA6B,EAC7B,OACiD;QAEjD,KAAK,CAAC,YAAY,EAA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