@autofleet/rabbit 3.2.23-beta.0.0 → 3.2.23

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
@@ -3,7 +3,6 @@ import { EventEmitter } from 'events';
3
3
  import { AmqpConnectionManager, ChannelWrapper, CreateChannelOpts } from 'amqp-connection-manager';
4
4
  import { ConfirmChannel, ConsumeMessage, Options, Replies } from 'amqplib';
5
5
  import { RedisConfig } from './lib/redis';
6
- import { sendCeleryTaskViaHttp } from './lib/celery';
7
6
  import { CallbackFunction, ConsumeMessageOrNull, ConsumeOptions, CustomMessageHeaders, QueuesCache, RedisLockType, ExchangesCache, QueueSetupPromisesDictionary, AssertExchangePromisesDictionary } from './lib/types';
8
7
  export interface IAfRabbitMq {
9
8
  ack: any;
@@ -100,4 +99,4 @@ declare class RabbitMq implements IAfRabbitMq {
100
99
  gracefulShutdown(signal: string): Promise<void>;
101
100
  }
102
101
  export default RabbitMq;
103
- export { sendCeleryTaskViaHttp, };
102
+ export { sendCeleryTaskViaHttp, } from './lib/celery';
package/dist/index.js CHANGED
@@ -16,8 +16,6 @@ const logger_1 = __importDefault(require("./logger"));
16
16
  const rabbitError_1 = __importDefault(require("./lib/rabbitError"));
17
17
  const redis_1 = __importDefault(require("./lib/redis"));
18
18
  const utils_1 = require("./lib/utils");
19
- const celery_1 = require("./lib/celery");
20
- Object.defineProperty(exports, "sendCeleryTaskViaHttp", { enumerable: true, get: function () { return celery_1.sendCeleryTaskViaHttp; } });
21
19
  const consts_1 = require("./lib/consts");
22
20
  const types_1 = require("./lib/types");
23
21
  // const debug = nodeDebug('af-rabbitmq')
@@ -571,3 +569,5 @@ class RabbitMq {
571
569
  }
572
570
  }
573
571
  exports.default = RabbitMq;
572
+ var celery_1 = require("./lib/celery");
573
+ Object.defineProperty(exports, "sendCeleryTaskViaHttp", { enumerable: true, get: function () { return celery_1.sendCeleryTaskViaHttp; } });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "3.2.23-beta.0.0",
3
+ "version": "3.2.23",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "engines": {
7
- "node": ">=15.0.0"
7
+ "node": ">=16.7.0"
8
8
  },
9
9
  "scripts": {
10
10
  "postinstall": "echo '\\033[0;31m\nWARNING: in case of migrating to new version of @autofleet/rabbit \nyou might have to delete existing queues or the deployment will fail.\\033[0m\n'",
package/src/index.ts CHANGED
@@ -18,7 +18,6 @@ import logger from './logger';
18
18
  import RabbitError from './lib/rabbitError';
19
19
  import getRedisInstance, { RedisConfig } from './lib/redis';
20
20
  import { assertExchangeFanout, rand, wrapSetImmediate } from './lib/utils';
21
- import { sendCeleryTaskViaHttp } from './lib/celery';
22
21
  import {
23
22
  AUTOMATION_ID_HEADER,
24
23
  CONNECTION_CREATED_CONST,
@@ -769,4 +768,4 @@ export default RabbitMq;
769
768
 
770
769
  export {
771
770
  sendCeleryTaskViaHttp,
772
- };
771
+ } from './lib/celery';
package/src/lib/celery.ts CHANGED
@@ -2,9 +2,9 @@ import { randomUUID } from 'node:crypto';
2
2
  import logger from '../logger';
3
3
  // Environment configuration
4
4
  const config = {
5
- host: process.env.RABBITMQ_SERVICE_HOST || 'localhost',
6
- username: process.env.RABBITMQ_USERNAME || 'guest',
7
- password: process.env.RABBITMQ_PASSWORD || 'guest',
5
+ host: process.env.RABBITMQ_SERVICE_HOST || 'localhost',
6
+ username: process.env.RABBITMQ_USERNAME || 'guest',
7
+ password: process.env.RABBITMQ_PASSWORD || 'guest',
8
8
  } as const;
9
9
 
10
10
  // Type definitions
@@ -42,48 +42,48 @@ interface SendTaskOptions {
42
42
  }
43
43
 
44
44
  async function sendCeleryTaskViaHttp(
45
- data: TaskData,
46
- { taskName, queueName }: SendTaskOptions,
45
+ data: TaskData,
46
+ { taskName, queueName }: SendTaskOptions,
47
47
  ): Promise<void> {
48
- const apiUrl = `http://${config.host}:15672/api/exchanges/%2f/amq.default/publish`;
48
+ const apiUrl = `http://${config.host}:15672/api/exchanges/%2f/amq.default/publish`;
49
49
 
50
- const message: TaskMessage = {
51
- task: taskName,
52
- id: randomUUID(),
53
- args: [data],
54
- };
50
+ const message: TaskMessage = {
51
+ task: taskName,
52
+ id: randomUUID(),
53
+ args: [data],
54
+ };
55
55
 
56
- const payload: PublishPayload = {
57
- properties: {
58
- delivery_mode: 2,
59
- content_type: 'application/json',
60
- },
61
- routing_key: queueName,
62
- payload: JSON.stringify(message),
63
- payload_encoding: 'string',
64
- };
56
+ const payload: PublishPayload = {
57
+ properties: {
58
+ delivery_mode: 2,
59
+ content_type: 'application/json',
60
+ },
61
+ routing_key: queueName,
62
+ payload: JSON.stringify(message),
63
+ payload_encoding: 'string',
64
+ };
65
65
 
66
- try {
67
- const response = await fetch(apiUrl, {
68
- method: 'POST',
69
- headers: {
70
- 'Content-Type': 'application/json',
71
- Authorization: `Basic ${Buffer.from(`${config.username}:${config.password}`).toString('base64')}`,
72
- },
73
- body: JSON.stringify(payload),
74
- });
66
+ try {
67
+ const response = await fetch(apiUrl, {
68
+ method: 'POST',
69
+ headers: {
70
+ 'Content-Type': 'application/json',
71
+ Authorization: `Basic ${Buffer.from(`${config.username}:${config.password}`).toString('base64')}`,
72
+ },
73
+ body: JSON.stringify(payload),
74
+ });
75
75
 
76
- if (response.ok) {
77
- const result: PublishResponse = await response.json();
78
- logger.info('Successfully published message:', result);
79
- } else {
80
- logger.error(`Failed to publish message. Status code: ${response.status}`);
81
- logger.error(`Response: ${await response.text()}`);
82
- }
83
- } catch (error) {
84
- logger.error('Error sending request:', error instanceof Error ? error.message : String(error));
85
- throw error;
76
+ if (response.ok) {
77
+ const result: PublishResponse = await response.json();
78
+ logger.info('Successfully published message:', result);
79
+ } else {
80
+ logger.error(`Failed to publish message. Status code: ${response.status}`);
81
+ logger.error(`Response: ${await response.text()}`);
86
82
  }
83
+ } catch (error) {
84
+ logger.error('Error sending request:', error instanceof Error ? error.message : String(error));
85
+ throw error;
86
+ }
87
87
  }
88
88
 
89
89
  export { sendCeleryTaskViaHttp, TaskData, SendTaskOptions };