@message-queue-toolkit/core 3.0.0 → 3.1.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, SchemaMap, } from './lib/types/MessageQueueTypes';
2
2
  export { AbstractQueueService } from './lib/queues/AbstractQueueService';
3
- export type { NewQueueOptions, ExistingQueueOptions, NewQueueOptionsMultiSchema, ExistingQueueOptionsMultiSchema, MonoSchemaQueueOptions, MultiSchemaConsumerOptions, QueueDependencies, QueueConsumerDependencies, Deserializer, CommonQueueLocator, } from './lib/queues/AbstractQueueService';
3
+ export type { NewQueueOptions, ExistingQueueOptions, NewQueueOptionsMultiSchema, ExistingQueueOptionsMultiSchema, MonoSchemaQueueOptions, MultiSchemaConsumerOptions, QueueDependencies, QueueConsumerDependencies, Deserializer, CommonQueueLocator, DeletionConfig, } from './lib/queues/AbstractQueueService';
4
4
  export { isMessageError, MessageValidationError, MessageInvalidFormatError, } from './lib/errors/Errors';
5
5
  export { HandlerContainer, MessageHandlerConfig, MessageHandlerConfigBuilder, } from './lib/queues/HandlerContainer';
6
6
  export type { HandlerContainerOptions, Handler } from './lib/queues/HandlerContainer';
@@ -9,3 +9,4 @@ export type { MessageSchemaContainerOptions } from './lib/queues/MessageSchemaCo
9
9
  export { objectToBuffer } from './lib/utils/queueUtils';
10
10
  export { waitAndRetry } from './lib/utils/waitUtils';
11
11
  export { parseMessage } from './lib/utils/parseUtils';
12
+ export { reloadConfig, isProduction } from './lib/utils/envUtils';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMessage = exports.waitAndRetry = exports.objectToBuffer = exports.MessageSchemaContainer = exports.MessageHandlerConfigBuilder = exports.MessageHandlerConfig = exports.HandlerContainer = exports.MessageInvalidFormatError = exports.MessageValidationError = exports.isMessageError = exports.AbstractQueueService = void 0;
3
+ exports.isProduction = exports.reloadConfig = exports.parseMessage = exports.waitAndRetry = exports.objectToBuffer = exports.MessageSchemaContainer = exports.MessageHandlerConfigBuilder = exports.MessageHandlerConfig = exports.HandlerContainer = exports.MessageInvalidFormatError = exports.MessageValidationError = exports.isMessageError = exports.AbstractQueueService = void 0;
4
4
  var AbstractQueueService_1 = require("./lib/queues/AbstractQueueService");
5
5
  Object.defineProperty(exports, "AbstractQueueService", { enumerable: true, get: function () { return AbstractQueueService_1.AbstractQueueService; } });
6
6
  var Errors_1 = require("./lib/errors/Errors");
@@ -19,4 +19,7 @@ var waitUtils_1 = require("./lib/utils/waitUtils");
19
19
  Object.defineProperty(exports, "waitAndRetry", { enumerable: true, get: function () { return waitUtils_1.waitAndRetry; } });
20
20
  var parseUtils_1 = require("./lib/utils/parseUtils");
21
21
  Object.defineProperty(exports, "parseMessage", { enumerable: true, get: function () { return parseUtils_1.parseMessage; } });
22
+ var envUtils_1 = require("./lib/utils/envUtils");
23
+ Object.defineProperty(exports, "reloadConfig", { enumerable: true, get: function () { return envUtils_1.reloadConfig; } });
24
+ Object.defineProperty(exports, "isProduction", { enumerable: true, get: function () { return envUtils_1.isProduction; } });
22
25
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AASA,0EAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAc7B,8CAI4B;AAH1B,wGAAA,cAAc,OAAA;AACd,gHAAA,sBAAsB,OAAA;AACtB,mHAAA,yBAAyB,OAAA;AAG3B,kEAIsC;AAHpC,oHAAA,gBAAgB,OAAA;AAChB,wHAAA,oBAAoB,OAAA;AACpB,+HAAA,2BAA2B,OAAA;AAI7B,8EAA4E;AAAnE,gIAAA,sBAAsB,OAAA;AAG/B,qDAAuD;AAA9C,4GAAA,cAAc,OAAA;AACvB,mDAAoD;AAA3C,yGAAA,YAAY,OAAA;AACrB,qDAAqD;AAA5C,0GAAA,YAAY,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AASA,0EAAwE;AAA/D,4HAAA,oBAAoB,OAAA;AAe7B,8CAI4B;AAH1B,wGAAA,cAAc,OAAA;AACd,gHAAA,sBAAsB,OAAA;AACtB,mHAAA,yBAAyB,OAAA;AAG3B,kEAIsC;AAHpC,oHAAA,gBAAgB,OAAA;AAChB,wHAAA,oBAAoB,OAAA;AACpB,+HAAA,2BAA2B,OAAA;AAI7B,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"}
@@ -14,14 +14,20 @@ export type QueueConsumerDependencies = {
14
14
  export type Deserializer<MessagePayloadType extends object> = (message: unknown, type: ZodType<MessagePayloadType>, errorProcessor: ErrorResolver) => Either<MessageInvalidFormatError | MessageValidationError, MessagePayloadType>;
15
15
  export type NewQueueOptionsMultiSchema<MessagePayloadSchemas extends object, CreationConfigType extends object, ExecutionContext> = NewQueueOptions<CreationConfigType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext>;
16
16
  export type ExistingQueueOptionsMultiSchema<MessagePayloadSchemas extends object, QueueLocatorType extends object, ExecutionContext> = ExistingQueueOptions<QueueLocatorType> & MultiSchemaConsumerOptions<MessagePayloadSchemas, ExecutionContext>;
17
+ export type DeletionConfig = {
18
+ deleteIfExists?: boolean;
19
+ forceDeleteInProduction?: boolean;
20
+ };
17
21
  export type NewQueueOptions<CreationConfigType extends object> = {
18
22
  messageTypeField: string;
19
23
  locatorConfig?: never;
24
+ deletionConfig?: DeletionConfig;
20
25
  creationConfig: CreationConfigType;
21
26
  };
22
27
  export type ExistingQueueOptions<QueueLocatorType extends object> = {
23
28
  messageTypeField: string;
24
29
  locatorConfig: QueueLocatorType;
30
+ deletionConfig?: DeletionConfig;
25
31
  creationConfig?: never;
26
32
  };
27
33
  export type MultiSchemaConsumerOptions<MessagePayloadSchemas extends object, ExecutionContext> = {
@@ -39,7 +45,8 @@ export declare abstract class AbstractQueueService<MessagePayloadSchemas extends
39
45
  protected readonly messageTypeField: string;
40
46
  protected readonly creationConfig?: QueueConfiguration;
41
47
  protected readonly locatorConfig?: QueueLocatorType;
42
- constructor({ errorReporter, logger }: DependenciesType, { messageTypeField, creationConfig, locatorConfig }: OptionsType);
48
+ protected readonly deletionConfig?: DeletionConfig;
49
+ constructor({ errorReporter, logger }: DependenciesType, options: OptionsType);
43
50
  protected abstract resolveSchema(message: MessagePayloadSchemas): Either<Error, ZodSchema<MessagePayloadSchemas>>;
44
51
  protected abstract resolveMessage(message: MessageEnvelopeType): Either<MessageInvalidFormatError | MessageValidationError, unknown>;
45
52
  protected handleError(err: unknown): void;
@@ -9,12 +9,14 @@ class AbstractQueueService {
9
9
  messageTypeField;
10
10
  creationConfig;
11
11
  locatorConfig;
12
- constructor({ errorReporter, logger }, { messageTypeField, creationConfig, locatorConfig }) {
12
+ deletionConfig;
13
+ constructor({ errorReporter, logger }, options) {
13
14
  this.errorReporter = errorReporter;
14
15
  this.logger = logger;
15
- this.messageTypeField = messageTypeField;
16
- this.creationConfig = creationConfig;
17
- this.locatorConfig = locatorConfig;
16
+ this.messageTypeField = options.messageTypeField;
17
+ this.creationConfig = options.creationConfig;
18
+ this.locatorConfig = options.locatorConfig;
19
+ this.deletionConfig = options.deletionConfig;
18
20
  }
19
21
  handleError(err) {
20
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":";;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AAgB,GAAG,OAAO,CAAC,gBAAgB,CAAA;QAChD,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;QAC5C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,aAAa,CAAA;QAC1C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAA;IAC9C,CAAC;IASS,WAAW,CAAC,GAAY;QAChC,MAAM,SAAS,GAAG,IAAA,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;AA7CD,oDA6CC"}
@@ -0,0 +1,2 @@
1
+ export declare function reloadConfig(): void;
2
+ export declare function isProduction(): boolean;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isProduction = exports.reloadConfig = void 0;
4
+ const node_core_1 = require("@lokalise/node-core");
5
+ const configScope = new node_core_1.ConfigScope();
6
+ function reloadConfig() {
7
+ configScope.updateEnv();
8
+ }
9
+ exports.reloadConfig = reloadConfig;
10
+ function isProduction() {
11
+ return configScope.isProduction();
12
+ }
13
+ exports.isProduction = isProduction;
14
+ //# sourceMappingURL=envUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"envUtils.js","sourceRoot":"","sources":["../../../lib/utils/envUtils.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD,MAAM,WAAW,GAAG,IAAI,uBAAW,EAAE,CAAA;AAErC,SAAgB,YAAY;IAC1B,WAAW,CAAC,SAAS,EAAE,CAAA;AACzB,CAAC;AAFD,oCAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,WAAW,CAAC,YAAY,EAAE,CAAA;AACnC,CAAC;AAFD,oCAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@message-queue-toolkit/core",
3
- "version": "3.0.0",
3
+ "version": "3.1.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",