@autofleet/rabbit 4.0.0-beta.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.
Files changed (55) hide show
  1. package/dist/index.d.ts +24 -17
  2. package/dist/index.js +303 -180
  3. package/dist/index.js.map +1 -0
  4. package/dist/lib/celery.js +1 -0
  5. package/dist/lib/celery.js.map +1 -0
  6. package/dist/lib/consts.d.ts +0 -2
  7. package/dist/lib/consts.js +2 -3
  8. package/dist/lib/consts.js.map +1 -0
  9. package/dist/lib/rabbitError.js +1 -0
  10. package/dist/lib/rabbitError.js.map +1 -0
  11. package/dist/lib/redis.js +1 -0
  12. package/dist/lib/redis.js.map +1 -0
  13. package/dist/lib/types.d.ts +8 -0
  14. package/dist/lib/types.js +1 -0
  15. package/dist/lib/types.js.map +1 -0
  16. package/dist/lib/utils.js +1 -0
  17. package/dist/lib/utils.js.map +1 -0
  18. package/dist/logger.js +1 -0
  19. package/dist/logger.js.map +1 -0
  20. package/dist/{mock.d.ts → mock/index.d.ts} +1 -1
  21. package/dist/{mock.js → mock/index.js} +2 -1
  22. package/dist/mock/index.js.map +1 -0
  23. package/dist/mock/vitest.d.ts +13 -0
  24. package/dist/mock/vitest.js +18 -0
  25. package/dist/mock/vitest.js.map +1 -0
  26. package/package.json +22 -16
  27. package/src/index.ts +360 -203
  28. package/src/lib/consts.ts +0 -2
  29. package/src/lib/types.ts +10 -0
  30. package/src/{mock.ts → mock/index.ts} +2 -2
  31. package/src/mock/vitest.ts +24 -0
  32. package/tsconfig.build.json +5 -0
  33. package/tsconfig.json +2 -2
  34. package/vitest.config.ts +17 -0
  35. package/coverage/clover.xml +0 -669
  36. package/coverage/coverage-final.json +0 -9
  37. package/coverage/lcov-report/base.css +0 -224
  38. package/coverage/lcov-report/block-navigation.js +0 -87
  39. package/coverage/lcov-report/favicon.png +0 -0
  40. package/coverage/lcov-report/index.html +0 -131
  41. package/coverage/lcov-report/prettify.css +0 -1
  42. package/coverage/lcov-report/prettify.js +0 -2
  43. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  44. package/coverage/lcov-report/sorter.js +0 -196
  45. package/coverage/lcov-report/src/index.html +0 -131
  46. package/coverage/lcov-report/src/index.ts.html +0 -3826
  47. package/coverage/lcov-report/src/lib/celery.ts.html +0 -352
  48. package/coverage/lcov-report/src/lib/consts.ts.html +0 -142
  49. package/coverage/lcov-report/src/lib/index.html +0 -191
  50. package/coverage/lcov-report/src/lib/rabbitError.ts.html +0 -103
  51. package/coverage/lcov-report/src/lib/redis.ts.html +0 -133
  52. package/coverage/lcov-report/src/lib/types.ts.html +0 -268
  53. package/coverage/lcov-report/src/lib/utils.ts.html +0 -142
  54. package/coverage/lcov-report/src/logger.ts.html +0 -100
  55. package/coverage/lcov.info +0 -1076
package/src/lib/consts.ts CHANGED
@@ -6,8 +6,6 @@ export const USER_TRACING_HEADER = 'x-af-user-id';
6
6
  export const AUTOMATION_ID_HEADER = 'x-af-automation-id';
7
7
  export const USER_OBJECT = 'userObject';
8
8
  export const DEFAULT_USE_CONSUME_WITH_LOCK = false;
9
- export const CONNECTION_CREATED_CONST = 'connectionCreated';
10
- export const CONNECTION_FAILED_CONST = 'connectionFailed';
11
9
  export const DEFAULT_OPTIONS = {
12
10
  limit: 1,
13
11
  retries: 1,
package/src/lib/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AmqpConnectionManager } from 'amqp-connection-manager';
1
2
  import { ConsumeMessage, Options, Replies } from 'amqplib';
2
3
 
3
4
  export interface ExchangesCache {
@@ -31,6 +32,7 @@ export interface ConsumeOptions {
31
32
  useConsumeWithLock?: boolean;
32
33
  auditContext?: any;
33
34
  enableRabbitTrace?: boolean;
35
+ // TODO: [QUORUM-PHASE-3] Redundant because all the queues are quorum queues
34
36
  isQuorumQueue?: boolean;
35
37
  }
36
38
 
@@ -60,3 +62,11 @@ export const CONSUMER_DEFAULT_OPTIONS: Options.Consume = {
60
62
  [HA_PROMOTE_ON_SHUTDOWN]: 'always',
61
63
  },
62
64
  };
65
+
66
+ export type ConnectionData = {
67
+ amqpConnection: AmqpConnectionManager | null;
68
+ creatingConnection: boolean;
69
+ connectionCreatedEventName: string;
70
+ connectionFailedEventName: string;
71
+ blockReconnect: boolean;
72
+ };
@@ -1,6 +1,6 @@
1
- // eslint-disable-next-line import/no-extraneous-dependencies
1
+ // eslint-disable-next-line import/no-unresolved
2
2
  import 'jest';
3
- import { IAfRabbitMq } from './index';
3
+ import type { IAfRabbitMq } from '../index';
4
4
 
5
5
  class RabbitMq implements IAfRabbitMq {
6
6
  ack: any = jest.fn();
@@ -0,0 +1,24 @@
1
+ import { vi } from 'vitest';
2
+ import { IAfRabbitMq } from '../index';
3
+
4
+ class RabbitMq implements IAfRabbitMq {
5
+ ack = vi.fn();
6
+
7
+ nack = vi.fn();
8
+
9
+ assertChannel = vi.fn();
10
+
11
+ assertExchange = vi.fn();
12
+
13
+ assertQueue = vi.fn();
14
+
15
+ consume = vi.fn();
16
+
17
+ consumeFromExchange = vi.fn();
18
+
19
+ publish = vi.fn();
20
+
21
+ sendToQueue = vi.fn();
22
+ }
23
+
24
+ export default RabbitMq;
@@ -0,0 +1,5 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src"],
4
+ "exclude": ["node_modules", "dist", "src/example.ts", "**/*.test.ts"],
5
+ }
package/tsconfig.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "experimentalDecorators": true,
10
10
  "emitDecoratorMetadata": true,
11
11
  "skipLibCheck": true,
12
- "types": ["@types/jest"]
12
+ "sourceMap": true,
13
13
  },
14
14
  "exclude": ["node_modules"],
15
- "include": ["src/**/*.ts"]
15
+ "include": ["src/", "vitest.config.ts"],
16
16
  }
@@ -0,0 +1,17 @@
1
+ // eslint-disable-next-line import/no-unresolved
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ coverage: {
7
+ provider: 'v8',
8
+ include: ['src/**/*.ts'],
9
+ exclude: ['src/example.ts', 'src/mock/*.ts'],
10
+ reporter: 'text',
11
+ thresholds: {
12
+ // TO DO: Increase the coverage threshold back to 75 in phase 3
13
+ lines: 65,
14
+ },
15
+ },
16
+ },
17
+ });