@message-queue-toolkit/sqs 3.7.0 → 4.0.1

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.
@@ -1,5 +1,5 @@
1
1
  import type { Either, ErrorResolver } from '@lokalise/node-core';
2
- import type { QueueConsumer as QueueConsumer, NewQueueOptions, ExistingQueueOptions } from '@message-queue-toolkit/core';
2
+ import type { QueueConsumer as QueueConsumer, NewQueueOptions, ExistingQueueOptions, BarrierResult } from '@message-queue-toolkit/core';
3
3
  import { Consumer } from 'sqs-consumer';
4
4
  import type { ConsumerOptions } from 'sqs-consumer/src/types';
5
5
  import type { SQSMessage } from '../types/MessageTypes';
@@ -17,15 +17,15 @@ export type NewSQSConsumerOptions<CreationConfigType extends SQSCreationConfig>
17
17
  export type ExistingSQSConsumerOptions<QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType> = ExistingQueueOptions<QueueLocatorType> & {
18
18
  consumerOverrides?: Partial<ConsumerOptions>;
19
19
  };
20
- 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>> extends AbstractSqsService<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, SQSConsumerDependencies> implements QueueConsumer {
20
+ 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>, BarrierOutput = unknown> extends AbstractSqsService<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, SQSConsumerDependencies> implements QueueConsumer {
21
21
  private readonly transactionObservabilityManager?;
22
22
  protected readonly errorResolver: ErrorResolver;
23
23
  protected consumer: Consumer;
24
24
  private readonly consumerOptionsOverride;
25
25
  protected constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType);
26
26
  private internalProcessMessage;
27
- protected abstract preHandlerBarrier(message: MessagePayloadType, messageType: string): Promise<boolean>;
28
- abstract processMessage(message: MessagePayloadType, messageType: string): Promise<Either<'retryLater', 'success'>>;
27
+ protected abstract preHandlerBarrier(message: MessagePayloadType, messageType: string): Promise<BarrierResult<BarrierOutput>>;
28
+ abstract processMessage(message: MessagePayloadType, messageType: string, barrierOutput: BarrierOutput): Promise<Either<'retryLater', 'success'>>;
29
29
  private deserializeMessage;
30
30
  private failProcessing;
31
31
  start(): Promise<void>;
@@ -21,9 +21,9 @@ class AbstractSqsConsumer extends AbstractSqsService_1.AbstractSqsService {
21
21
  this.consumerOptionsOverride = options.consumerOverrides ?? {};
22
22
  }
23
23
  async internalProcessMessage(message, messageType) {
24
- const barrierPassed = await this.preHandlerBarrier(message, messageType);
25
- if (barrierPassed) {
26
- return this.processMessage(message, messageType);
24
+ const barrierResult = await this.preHandlerBarrier(message, messageType);
25
+ if (barrierResult.isPassing) {
26
+ return this.processMessage(message, messageType, barrierResult.output);
27
27
  }
28
28
  return { error: 'retryLater' };
29
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSqsConsumer.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumer.ts"],"names":[],"mappings":";;;AAOA,sDAA0E;AAC1E,+CAAuC;AAIvC,gEAA0D;AAO1D,6DAAyD;AAEzD,MAAM,kBAAkB,GAA2B;IACjD,KAAK,EAAE,OAAO;CACf,CAAA;AAqBD,MAAsB,mBAUpB,SAAQ,uCAMP;IAGgB,+BAA+B,CAAkC;IAC/D,aAAa,CAAe;IAC/C,aAAa;IACH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AC,CAAC;qBACD,OAAO,CAAC,GAAG,EAAE;oBACZ,IAAI,CAAC,+BAA+B,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;gBAC/D,CAAC,CAAC,CAAA;gBAEJ,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;YACzD,CAAC;YACD,GAAG,EAAE,IAAI,CAAC,SAAS;YACnB,GAAG,IAAI,CAAC,uBAAuB;SAChC,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YAChC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QACvB,CAAC,CAAC,CAAA;QAEF,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAA;IACvB,CAAC;IAEkB,cAAc,CAAC,OAAmB;QACnD,OAAO,IAAA,iCAAc,EAAC,OAAO,EAAE,IAAI,CAAC,aAAa,CAAC,CAAA;IACpD,CAAC;IAEe,KAAK,CAAC,KAAK,CAAC,KAAe;QACzC,MAAM,KAAK,CAAC,KAAK,EAAE,CAAA;QACnB,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC;YAClB,KAAK,EAAE,KAAK,IAAI,KAAK;SACtB,CAAC,CAAA;IACJ,CAAC;CACF;AA5KD,kDA4KC"}
@@ -1,18 +1,19 @@
1
1
  import type { Either } from '@lokalise/node-core';
2
- import type { MonoSchemaQueueOptions, QueueConsumer as QueueConsumer } from '@message-queue-toolkit/core';
2
+ import type { MonoSchemaQueueOptions, QueueConsumer as QueueConsumer, BarrierResult } from '@message-queue-toolkit/core';
3
3
  import type { ZodSchema } from 'zod';
4
4
  import type { ExistingSQSConsumerOptions, NewSQSConsumerOptions, SQSCreationConfig } from './AbstractSqsConsumer';
5
5
  import { AbstractSqsConsumer } from './AbstractSqsConsumer';
6
6
  import type { SQSConsumerDependencies, SQSQueueLocatorType } from './AbstractSqsService';
7
7
  export type NewSQSConsumerOptionsMono<MessagePayloadType extends object, CreationConfigType extends SQSCreationConfig> = NewSQSConsumerOptions<CreationConfigType> & MonoSchemaQueueOptions<MessagePayloadType>;
8
8
  export type ExistingSQSConsumerOptionsMono<MessagePayloadType extends object, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType> = ExistingSQSConsumerOptions<QueueLocatorType> & MonoSchemaQueueOptions<MessagePayloadType>;
9
- export declare abstract class AbstractSqsConsumerMonoSchema<MessagePayloadType extends object, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, ConsumerOptionsType extends NewSQSConsumerOptionsMono<MessagePayloadType, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, QueueLocatorType> = NewSQSConsumerOptionsMono<MessagePayloadType, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, QueueLocatorType>> extends AbstractSqsConsumer<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType> implements QueueConsumer {
9
+ export declare abstract class AbstractSqsConsumerMonoSchema<MessagePayloadType extends object, BarrierOutput = undefined, QueueLocatorType extends SQSQueueLocatorType = SQSQueueLocatorType, CreationConfigType extends SQSCreationConfig = SQSCreationConfig, ConsumerOptionsType extends NewSQSConsumerOptionsMono<MessagePayloadType, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, QueueLocatorType> = NewSQSConsumerOptionsMono<MessagePayloadType, CreationConfigType> | ExistingSQSConsumerOptionsMono<MessagePayloadType, QueueLocatorType>> extends AbstractSqsConsumer<MessagePayloadType, QueueLocatorType, CreationConfigType, ConsumerOptionsType, BarrierOutput> implements QueueConsumer {
10
10
  private readonly messageSchema;
11
11
  private readonly schemaEither;
12
12
  protected constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType);
13
13
  /**
14
14
  * Override to implement barrier pattern
15
15
  */
16
- protected preHandlerBarrier(_message: MessagePayloadType, _messageType: string): Promise<boolean>;
16
+ protected preHandlerBarrier(_message: MessagePayloadType, _messageType: string): Promise<BarrierResult<BarrierOutput>>;
17
+ abstract processMessage(message: MessagePayloadType, messageType: string, barrierOutput: BarrierOutput): Promise<Either<'retryLater', 'success'>>;
17
18
  protected resolveSchema(): Either<Error, ZodSchema<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
18
19
  }
@@ -2,6 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractSqsConsumerMonoSchema = void 0;
4
4
  const AbstractSqsConsumer_1 = require("./AbstractSqsConsumer");
5
+ const DEFAULT_BARRIER_RESULT = {
6
+ isPassing: true,
7
+ output: undefined,
8
+ };
5
9
  class AbstractSqsConsumerMonoSchema extends AbstractSqsConsumer_1.AbstractSqsConsumer {
6
10
  messageSchema;
7
11
  schemaEither;
@@ -15,8 +19,10 @@ class AbstractSqsConsumerMonoSchema extends AbstractSqsConsumer_1.AbstractSqsCon
15
19
  /**
16
20
  * Override to implement barrier pattern
17
21
  */
22
+ /* c8 ignore start */
18
23
  preHandlerBarrier(_message, _messageType) {
19
- return Promise.resolve(true);
24
+ // @ts-ignore
25
+ return Promise.resolve(DEFAULT_BARRIER_RESULT);
20
26
  }
21
27
  resolveSchema() {
22
28
  return this.schemaEither;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSqsConsumerMonoSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumerMonoSchema.ts"],"names":[],"mappings":";;;AAYA,+DAA2D;AAa3D,MAAsB,6BAUpB,SAAQ,yCAKP;IAGgB,aAAa,CAA+B;IAC5C,YAAY,CAA8C;IAE3E,YAAsB,YAAqC,EAAE,OAA4B;QACvF,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAE5B,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;IACgB,iBAAiB,CAClC,QAA4B,EAC5B,YAAoB;QAEpB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC9B,CAAC;IAES,aAAa;QACrB,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CACF;AA3CD,sEA2CC"}
1
+ {"version":3,"file":"AbstractSqsConsumerMonoSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumerMonoSchema.ts"],"names":[],"mappings":";;;AAaA,+DAA2D;AAG3D,MAAM,sBAAsB,GAAG;IAC7B,SAAS,EAAE,IAAI;IACf,MAAM,EAAE,SAAS;CACT,CAAA;AAYV,MAAsB,6BAWpB,SAAQ,yCAMP;IAGgB,aAAa,CAA+B;IAC5C,YAAY,CAA8C;IAE3E,YAAsB,YAAqC,EAAE,OAA4B;QACvF,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAA;QAE5B,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;IASS,aAAa;QACrB,OAAO,IAAI,CAAC,YAAY,CAAA;IAC1B,CAAC;CACF;AAnDD,sEAmDC"}
@@ -1,6 +1,6 @@
1
1
  import type { Either } from '@lokalise/node-core';
2
- import type { ExistingQueueOptionsMultiSchema, NewQueueOptionsMultiSchema } from '@message-queue-toolkit/core';
3
2
  import { HandlerContainer, MessageSchemaContainer } from '@message-queue-toolkit/core';
3
+ import type { ExistingQueueOptionsMultiSchema, NewQueueOptionsMultiSchema, BarrierResult } from '@message-queue-toolkit/core';
4
4
  import type { ConsumerOptions } from 'sqs-consumer/src/types';
5
5
  import type { SQSCreationConfig } from './AbstractSqsConsumer';
6
6
  import { AbstractSqsConsumer } from './AbstractSqsConsumer';
@@ -16,7 +16,7 @@ export declare abstract class AbstractSqsConsumerMultiSchema<MessagePayloadType
16
16
  handlerContainer: HandlerContainer<MessagePayloadType, ExecutionContext>;
17
17
  constructor(dependencies: SQSConsumerDependencies, options: ConsumerOptionsType);
18
18
  protected resolveSchema(message: MessagePayloadType): Either<Error, import("zod").ZodType<MessagePayloadType, import("zod").ZodTypeDef, MessagePayloadType>>;
19
- processMessage(message: MessagePayloadType, messageType: string): Promise<Either<'retryLater', 'success'>>;
19
+ processMessage(message: MessagePayloadType, messageType: string, barrierOutput: unknown): Promise<Either<'retryLater', 'success'>>;
20
20
  protected resolveMessageLog(message: MessagePayloadType, messageType: string): unknown;
21
- protected preHandlerBarrier(message: MessagePayloadType, messageType: string): Promise<boolean>;
21
+ protected preHandlerBarrier<BarrierOutput>(message: MessagePayloadType, messageType: string): Promise<BarrierResult<BarrierOutput>>;
22
22
  }
@@ -21,10 +21,10 @@ class AbstractSqsConsumerMultiSchema extends AbstractSqsConsumer_1.AbstractSqsCo
21
21
  resolveSchema(message) {
22
22
  return this.messageSchemaContainer.resolveSchema(message);
23
23
  }
24
- async processMessage(message, messageType) {
24
+ async processMessage(message, messageType, barrierOutput) {
25
25
  const handler = this.handlerContainer.resolveHandler(messageType);
26
26
  // @ts-ignore
27
- return handler.handler(message, this);
27
+ return handler.handler(message, this, barrierOutput);
28
28
  }
29
29
  resolveMessageLog(message, messageType) {
30
30
  const handler = this.handlerContainer.resolveHandler(messageType);
@@ -33,7 +33,13 @@ class AbstractSqsConsumerMultiSchema extends AbstractSqsConsumer_1.AbstractSqsCo
33
33
  async preHandlerBarrier(message, messageType) {
34
34
  const handler = this.handlerContainer.resolveHandler(messageType);
35
35
  // @ts-ignore
36
- return handler.preHandlerBarrier ? await handler.preHandlerBarrier(message, this) : true;
36
+ return handler.preHandlerBarrier
37
+ ? // @ts-ignore
38
+ await handler.preHandlerBarrier(message, this)
39
+ : {
40
+ isPassing: true,
41
+ output: undefined,
42
+ };
37
43
  }
38
44
  }
39
45
  exports.AbstractSqsConsumerMultiSchema = AbstractSqsConsumerMultiSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractSqsConsumerMultiSchema.js","sourceRoot":"","sources":["../../../lib/sqs/AbstractSqsConsumerMultiSchema.ts"],"names":[],"mappings":";;;AAKA,sDAAsF;AAItF,+DAA2D;AAmB3D,MAAsB,8BAcpB,SAAQ,yCAKT;IACC,sBAAsB,CAA4C;IAClE,gBAAgB,CAAwD;IAExE,YAAY,YAAqC,EAAE,OAA4B;QAC7E,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,CAAuC;YACjF,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,eAAe,EAAE,OAAO,CAAC,QAAQ;SAClC,CAAC,CAAA;IACJ,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;QAEnB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QACjE,aAAa;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAA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;IACJ,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,EACnB,aAAsB;QAEtB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QACjE,aAAa;QACb,OAAO,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,CAAC,CAAA;IACtD,CAAC;IAEkB,iBAAiB,CAAC,OAA2B,EAAE,WAAmB;QACnF,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAC,WAAW,CAAC,CAAA;QACjE,OAAO,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;IAC7C,CAAC;IAEkB,KAAK,CAAC,iBAAiB,CACxC,OAA2B,EAC3B,WAAmB;QAEnB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,cAAc,CAAgB,WAAW,CAAC,CAAA;QAChF,aAAa;QACb,OAAO,OAAO,CAAC,iBAAiB;YAC9B,CAAC,CAAC,aAAa;gBACb,MAAM,OAAO,CAAC,iBAAiB,CAAC,OAAO,EAAE,IAAI,CAAC;YAChD,CAAC,CAAC;gBACE,SAAS,EAAE,IAAI;gBACf,MAAM,EAAE,SAAS;aAClB,CAAA;IACP,CAAC;CACF;AAvED,wEAuEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@message-queue-toolkit/sqs",
3
- "version": "3.7.0",
3
+ "version": "4.0.1",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "SQS adapter for message-queue-toolkit",
@@ -26,23 +26,23 @@
26
26
  "prepublishOnly": "npm run build:release"
27
27
  },
28
28
  "dependencies": {
29
- "@lokalise/node-core": "^6.0.0",
29
+ "@lokalise/node-core": "^6.4.0",
30
30
  "sqs-consumer": "^7.2.2",
31
- "zod": "^3.21.4"
31
+ "zod": "^3.22.4"
32
32
  },
33
33
  "peerDependencies": {
34
34
  "@aws-sdk/client-sqs": "^3.385.0",
35
- "@message-queue-toolkit/core": "^3.6.0"
35
+ "@message-queue-toolkit/core": "^4.0.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@aws-sdk/client-sqs": "^3.385.0",
39
39
  "@message-queue-toolkit/core": "*",
40
- "@types/node": "^20.5.0",
41
- "@typescript-eslint/eslint-plugin": "^6.4.0",
42
- "@typescript-eslint/parser": "^6.4.0",
43
- "@vitest/coverage-v8": "^0.34.1",
40
+ "@types/node": "^20.7.0",
41
+ "@typescript-eslint/eslint-plugin": "^6.7.3",
42
+ "@typescript-eslint/parser": "^6.7.3",
43
+ "@vitest/coverage-v8": "^0.34.5",
44
44
  "awilix": "^8.0.1",
45
- "awilix-manager": "^2.0.0",
45
+ "awilix-manager": "^3.2.0",
46
46
  "del-cli": "^5.0.0",
47
47
  "eslint": "^8.47.0",
48
48
  "eslint-config-prettier": "^9.0.0",
@@ -50,8 +50,8 @@
50
50
  "eslint-plugin-prettier": "^5.0.0",
51
51
  "eslint-plugin-vitest": "^0.2.6",
52
52
  "prettier": "^3.0.0",
53
- "typescript": "^5.1.6",
54
- "vitest": "^0.34.1"
53
+ "typescript": "^5.2.2",
54
+ "vitest": "^0.34.5"
55
55
  },
56
56
  "homepage": "https://github.com/kibertoad/message-queue-toolkit",
57
57
  "repository": {