@message-queue-toolkit/core 1.1.0 → 2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  export type { QueueConsumer, AsyncPublisher, SyncPublisher, TransactionObservabilityManager, Logger, } from './lib/types/MessageQueueTypes';
2
2
  export { AbstractQueueService } from './lib/queues/AbstractQueueService';
3
- export type { QueueOptions, QueueDependencies, QueueConsumerDependencies, Deserializer, } from './lib/queues/AbstractQueueService';
3
+ export type { NewQueueOptions, ExistingQueueOptions, QueueDependencies, QueueConsumerDependencies, Deserializer, CommonQueueLocator, } from './lib/queues/AbstractQueueService';
4
4
  export { isMessageError, MessageValidationError, MessageInvalidFormatError, } from './lib/errors/Errors';
5
5
  export { objectToBuffer } from './lib/utils/queueUtils';
6
6
  export { waitAndRetry } from './lib/utils/waitUtils';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAQA,0EAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAQ7B,8CAI4B;AAH1B,wGAAA,cAAc,OAAA;AACd,gHAAA,sBAAsB,OAAA;AACtB,mHAAA,yBAAyB,OAAA;AAG3B,qDAAuD;AAA9C,4GAAA,cAAc,OAAA;AACvB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAQA,0EAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAU7B,8CAI4B;AAH1B,wGAAA,cAAc,OAAA;AACd,gHAAA,sBAAsB,OAAA;AACtB,mHAAA,yBAAyB,OAAA;AAG3B,qDAAuD;AAA9C,4GAAA,cAAc,OAAA;AACvB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA"}
@@ -11,20 +11,29 @@ export type QueueConsumerDependencies = {
11
11
  transactionObservabilityManager: TransactionObservabilityManager;
12
12
  };
13
13
  export type Deserializer<MessagePayloadType extends object, QueueEngineMessageType extends object> = (message: QueueEngineMessageType, type: ZodType<MessagePayloadType>, errorProcessor: ErrorResolver) => Either<MessageInvalidFormatError | MessageValidationError, MessagePayloadType>;
14
- export type QueueOptions<MessagePayloadType extends object, QueueConfiguration extends object> = {
14
+ export type NewQueueOptions<MessagePayloadType extends object, CreationConfigType extends object> = {
15
15
  messageSchema: ZodSchema<MessagePayloadType>;
16
16
  messageTypeField: string;
17
+ locatorConfig?: never;
18
+ creationConfig: CreationConfigType;
19
+ };
20
+ export type ExistingQueueOptions<MessagePayloadType extends object, QueueLocatorType extends object> = {
21
+ messageSchema: ZodSchema<MessagePayloadType>;
22
+ messageTypeField: string;
23
+ locatorConfig: QueueLocatorType;
24
+ creationConfig?: never;
25
+ };
26
+ export type CommonQueueLocator = {
17
27
  queueName: string;
18
- queueConfiguration: QueueConfiguration;
19
28
  };
20
- export declare abstract class AbstractQueueService<MessagePayloadType extends object, DependenciesType extends QueueDependencies, QueueConfiguration extends object, OptionsType extends QueueOptions<MessagePayloadType, QueueConfiguration> = QueueOptions<MessagePayloadType, QueueConfiguration>> {
21
- protected readonly queueName: string;
29
+ export declare abstract class AbstractQueueService<MessagePayloadType extends object, DependenciesType extends QueueDependencies, QueueConfiguration extends object, QueueLocatorType extends object = CommonQueueLocator, OptionsType extends NewQueueOptions<MessagePayloadType, QueueConfiguration> | ExistingQueueOptions<MessagePayloadType, QueueLocatorType> = NewQueueOptions<MessagePayloadType, QueueConfiguration> | ExistingQueueOptions<MessagePayloadType, QueueLocatorType>> {
22
30
  protected readonly errorReporter: ErrorReporter;
23
31
  protected readonly messageSchema: ZodSchema<MessagePayloadType>;
24
32
  protected readonly logger: Logger;
25
33
  protected readonly messageTypeField: string;
26
- protected readonly queueConfiguration: QueueConfiguration;
27
- constructor({ errorReporter, logger }: DependenciesType, { messageSchema, messageTypeField, queueName, queueConfiguration }: OptionsType);
34
+ protected readonly creationConfig?: QueueConfiguration;
35
+ protected readonly locatorConfig?: QueueLocatorType;
36
+ constructor({ errorReporter, logger }: DependenciesType, { messageSchema, messageTypeField, creationConfig, locatorConfig }: OptionsType);
28
37
  protected handleError(err: unknown): void;
29
38
  abstract close(): Promise<unknown>;
30
39
  }
@@ -4,19 +4,19 @@ exports.AbstractQueueService = void 0;
4
4
  const node_util_1 = require("node:util");
5
5
  const node_core_1 = require("@lokalise/node-core");
6
6
  class AbstractQueueService {
7
- queueName;
8
7
  errorReporter;
9
8
  messageSchema;
10
9
  logger;
11
10
  messageTypeField;
12
- queueConfiguration;
13
- constructor({ errorReporter, logger }, { messageSchema, messageTypeField, queueName, queueConfiguration }) {
11
+ creationConfig;
12
+ locatorConfig;
13
+ constructor({ errorReporter, logger }, { messageSchema, messageTypeField, creationConfig, locatorConfig }) {
14
14
  this.errorReporter = errorReporter;
15
15
  this.logger = logger;
16
- this.queueName = queueName;
17
16
  this.messageSchema = messageSchema;
18
17
  this.messageTypeField = messageTypeField;
19
- this.queueConfiguration = queueConfiguration;
18
+ this.creationConfig = creationConfig;
19
+ this.locatorConfig = locatorConfig;
20
20
  }
21
21
  handleError(err) {
22
22
  const logObject = (0, node_core_1.resolveGlobalErrorLogObject)(err);
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractQueueService.js","sourceRoot":"","sources":["../../../lib/queues/AbstractQueueService.ts"],"names":[],"mappings":";;;AAAA,yCAAiC;AAGjC,mDAAiE;AAgCjE,MAAsB,oBAAoB;IASrB,SAAS,CAAQ;IACjB,aAAa,CAAe;IAC5B,aAAa,CAA+B;IAC5C,MAAM,CAAQ;IACd,gBAAgB,CAAQ;IACxB,kBAAkB,CAAoB;IAEzD,YACE,EAAE,aAAa,EAAE,MAAM,EAAoB,EAC3C,EAAE,aAAa,EAAE,gBAAgB,EAAE,SAAS,EAAE,kBAAkB,EAAe;QAE/E,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,MAAM,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A,uCAA2B,EAAC,GAAG,CAAC,CAAA;QAClD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAA;QAC5B,IAAI,iBAAK,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE;YAC5B,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAA;SAC1C;IACH,CAAC;CAGF;AAxCD,oDAwCC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@message-queue-toolkit/core",
3
- "version": "1.1.0",
3
+ "version": "2.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",
@@ -26,16 +26,16 @@
26
26
  },
27
27
  "dependencies": {},
28
28
  "devDependencies": {
29
- "@types/node": "^20.3.1",
30
- "@typescript-eslint/eslint-plugin": "^5.60.0",
31
- "@typescript-eslint/parser": "^5.60.0",
29
+ "@types/node": "^20.4.1",
30
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
31
+ "@typescript-eslint/parser": "^5.62.0",
32
32
  "del-cli": "^5.0.0",
33
- "eslint": "^8.43.0",
33
+ "eslint": "^8.44.0",
34
34
  "eslint-config-prettier": "^8.8.0",
35
35
  "eslint-plugin-import": "^2.27.5",
36
- "eslint-plugin-prettier": "^4.2.1",
37
- "prettier": "^2.8.8",
38
- "typescript": "^5.1.3"
36
+ "eslint-plugin-prettier": "^5.0.0",
37
+ "prettier": "^3.0.0",
38
+ "typescript": "^5.1.6"
39
39
  },
40
40
  "homepage": "https://github.com/kibertoad/message-queue-toolkit",
41
41
  "repository": {