amqp-extension 4.0.0 → 5.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.
Files changed (46) hide show
  1. package/README.MD +284 -40
  2. package/dist/index.d.mts +287 -0
  3. package/dist/index.mjs +502 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/package.json +53 -39
  6. package/.editorconfig +0 -13
  7. package/.eslintrc +0 -27
  8. package/.husky/commit-msg +0 -4
  9. package/CHANGELOG.md +0 -149
  10. package/commitlint.config.js +0 -10
  11. package/dist/config/index.d.ts +0 -3
  12. package/dist/config/index.js +0 -25
  13. package/dist/config/module.d.ts +0 -2
  14. package/dist/config/module.js +0 -23
  15. package/dist/config/type.d.ts +0 -13
  16. package/dist/config/type.js +0 -8
  17. package/dist/consume/constants.d.ts +0 -1
  18. package/dist/consume/constants.js +0 -10
  19. package/dist/consume/index.d.ts +0 -3
  20. package/dist/consume/index.js +0 -25
  21. package/dist/consume/type.d.ts +0 -24
  22. package/dist/consume/type.js +0 -8
  23. package/dist/consume/utils.d.ts +0 -2
  24. package/dist/consume/utils.js +0 -16
  25. package/dist/exchange/constants.d.ts +0 -6
  26. package/dist/exchange/constants.js +0 -10
  27. package/dist/exchange/index.d.ts +0 -3
  28. package/dist/exchange/index.js +0 -19
  29. package/dist/exchange/type.d.ts +0 -8
  30. package/dist/exchange/type.js +0 -2
  31. package/dist/exchange/utils.d.ts +0 -4
  32. package/dist/exchange/utils.js +0 -13
  33. package/dist/index.d.ts +0 -6
  34. package/dist/index.js +0 -28
  35. package/dist/module.d.ts +0 -18
  36. package/dist/module.js +0 -187
  37. package/dist/publish/index.d.ts +0 -1
  38. package/dist/publish/index.js +0 -23
  39. package/dist/publish/type.d.ts +0 -7
  40. package/dist/publish/type.js +0 -8
  41. package/dist/type.d.ts +0 -14
  42. package/dist/type.js +0 -2
  43. package/dist/utils.d.ts +0 -2
  44. package/dist/utils.js +0 -23
  45. package/release.config.js +0 -3
  46. package/tsconfig.eslint.json +0 -12
package/package.json CHANGED
@@ -1,31 +1,13 @@
1
1
  {
2
2
  "name": "amqp-extension",
3
- "version": "4.0.0",
3
+ "version": "5.0.0",
4
+ "type": "module",
4
5
  "description": "An amqp extension with functions and utility functions to consume and publish queue messages.",
5
- "main": "./dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "scripts": {
8
- "build": "rm -rf ./dist && tsc",
9
- "test": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --detectOpenHandles",
10
- "test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage",
11
- "lint": "eslint --ext .js,.vue,.ts ./src",
12
- "lint:fix": "npm run lint -- --fix",
13
- "prepublishOnly": "npm run build"
14
- },
15
6
  "author": {
16
7
  "name": "Peter Placzek",
17
8
  "email": "contact@tada5hi.net",
18
9
  "url": "https://github.com/tada5hi"
19
10
  },
20
- "license": "MIT",
21
- "keywords": [
22
- "amqp",
23
- "amqplib",
24
- "consumeQueue",
25
- "publishMessage",
26
- "typescript",
27
- "amqplib"
28
- ],
29
11
  "repository": {
30
12
  "type": "git",
31
13
  "url": "git+https://github.com/Tada5hi/amqp-extension.git"
@@ -34,28 +16,60 @@
34
16
  "url": "https://github.com/Tada5hi/amqp-extension/issues"
35
17
  },
36
18
  "homepage": "https://github.com/Tada5hi/amqp-extension#readme",
19
+ "main": "dist/index.mjs",
20
+ "types": "dist/index.d.mts",
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "types": "./dist/index.d.mts",
25
+ "import": "./dist/index.mjs"
26
+ }
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "engines": {
32
+ "node": ">=22.0.0"
33
+ },
34
+ "scripts": {
35
+ "build": "tsdown",
36
+ "test": "vitest --config test/vitest.config.ts --run",
37
+ "test:coverage": "vitest --config test/vitest.config.ts --run --coverage",
38
+ "lint": "eslint",
39
+ "lint:fix": "npm run lint -- --fix",
40
+ "prepare": "husky"
41
+ },
42
+ "keywords": [
43
+ "amqp",
44
+ "amqplib",
45
+ "rabbitmq",
46
+ "consume",
47
+ "publish",
48
+ "typescript"
49
+ ],
50
+ "publishConfig": {
51
+ "access": "public"
52
+ },
53
+ "license": "MIT",
37
54
  "dependencies": {
38
- "@types/amqplib": "^0.10.7",
39
- "amqp-connection-manager": "^4.1.14",
40
- "amqplib": "^0.10.7",
41
- "smob": "^1.5.0",
42
- "uuid": "^11.1.0"
55
+ "@ebec/core": "^1.3.2",
56
+ "amqp-connection-manager": "^5.0.0",
57
+ "amqplib": "^2.2.0",
58
+ "smob": "^1.6.2"
43
59
  },
44
60
  "devDependencies": {
45
- "@tada5hi/commitlint-config": "^1.2.4",
46
- "@tada5hi/eslint-config-typescript": "^1.2.15",
47
- "@tada5hi/semantic-release": "^0.3.2",
48
- "@tada5hi/tsconfig": "^0.6.0",
49
- "@types/jest": "^29.5.14",
50
- "@types/node": "^22.13.14",
51
- "cross-env": "^7.0.3",
52
- "envix": "^1.5.0",
53
- "eslint": "^8.57.0",
61
+ "@commitlint/cli": "^21.2.3",
62
+ "@tada5hi/commitlint-config": "^1.3.2",
63
+ "@tada5hi/eslint-config": "^2.4.0",
64
+ "@tada5hi/tsconfig": "^0.7.2",
65
+ "@types/node": "^26.6.5",
66
+ "@vitest/coverage-v8": "^5.0.4",
67
+ "eslint": "^10.12.0",
54
68
  "husky": "^9.1.7",
55
- "jest": "^29.7.0",
56
- "semantic-release": "^24.2.3",
57
- "testcontainers": "^10.23.0",
58
- "ts-jest": "^29.3.0",
59
- "typescript": "^5.8.2"
69
+ "testcontainers": "^12.2.1",
70
+ "tsdown": "^0.23.1",
71
+ "typescript": "^6.0.3",
72
+ "typescript-eslint": "^8.71.2",
73
+ "vitest": "^5.0.4"
60
74
  }
61
75
  }
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # editorconfig.org
2
- root = true
3
-
4
- [*]
5
- indent_style = space
6
- indent_size = 4
7
- end_of_line = lf
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- insert_final_newline = true
11
-
12
- [*.md]
13
- trim_trailing_whitespace = false
package/.eslintrc DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "extends": [
3
- "@tada5hi/eslint-config-typescript"
4
- ],
5
- "parserOptions": {
6
- "project": "./tsconfig.eslint.json"
7
- },
8
- "ignorePatterns": ["**/dist/*", "**/*.d.ts"],
9
- "globals": {
10
- "NodeJS": true
11
- },
12
- "rules": {
13
- "class-methods-use-this": "off",
14
- "import/no-cycle": [2, {
15
- "maxDepth": 1,
16
- }],
17
-
18
- "no-underscore-dangle": "off",
19
- "no-continue": "off",
20
- "no-use-before-define": "off",
21
- "no-nested-ternary": "off",
22
- "no-shadow": "off",
23
-
24
- "@typescript-eslint/no-unused-vars": "off",
25
- "@typescript-eslint/no-use-before-define": "off"
26
- }
27
- }
package/.husky/commit-msg DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env sh
2
- . "$(dirname -- "$0")/_/husky.sh"
3
-
4
- npx --no -- commitlint --edit
package/CHANGELOG.md DELETED
@@ -1,149 +0,0 @@
1
- # [4.0.0](https://github.com/Tada5hi/amqp-extension/compare/v3.3.0...v4.0.0) (2025-03-31)
2
-
3
-
4
- ### Bug Fixes
5
-
6
- * **deps:** bump amqplib from 0.10.3 to 0.10.4 ([#368](https://github.com/Tada5hi/amqp-extension/issues/368)) ([dae6c84](https://github.com/Tada5hi/amqp-extension/commit/dae6c840ad69e74a6c5dc37ea7f0fbb6c8ea1bae))
7
- * **deps:** bump smob from 1.4.1 to 1.5.0 ([#334](https://github.com/Tada5hi/amqp-extension/issues/334)) ([0b2935a](https://github.com/Tada5hi/amqp-extension/commit/0b2935af145d4844510c19b6d3f9d23ac0e3386a))
8
- * **deps:** bump the minorandpatch group with 10 updates ([#428](https://github.com/Tada5hi/amqp-extension/issues/428)) ([3ffb425](https://github.com/Tada5hi/amqp-extension/commit/3ffb425c3ff7e987791d80172fe4166a3b9f7dc5))
9
- * **deps:** bump uuid from 9.0.1 to 11.1.0 in the majorprod group ([#426](https://github.com/Tada5hi/amqp-extension/issues/426)) ([2c6bdc0](https://github.com/Tada5hi/amqp-extension/commit/2c6bdc095aeb6760467d0eed678fe2b4cd421f70))
10
- * ensure (n)ack is send on same channel ([ab7026f](https://github.com/Tada5hi/amqp-extension/commit/ab7026f4e65f9cff33cb509dc25a77b72ddc25f1))
11
- * only ack message if noAck option is false ([d6102e3](https://github.com/Tada5hi/amqp-extension/commit/d6102e3df431c6710257b5bdf59c8e99672e7df6))
12
-
13
-
14
- ### Features
15
-
16
- * adjusted test suite ([a5cc771](https://github.com/Tada5hi/amqp-extension/commit/a5cc7714a141d671d1e97ed67216df0ffc53af49))
17
- * change publish/consume signature ([ff316ec](https://github.com/Tada5hi/amqp-extension/commit/ff316ec27ac1077c7a6949ea5e5adf6ad1e5e5f5))
18
- * initial refactoring of config, consume- &p publish-behaviour ([1102aa8](https://github.com/Tada5hi/amqp-extension/commit/1102aa8a8b000336312d89c92434d8c77e7a0424))
19
-
20
-
21
- ### BREAKING CHANGES
22
-
23
- * public api changed
24
-
25
- # [4.0.0-beta.3](https://github.com/Tada5hi/amqp-extension/compare/v4.0.0-beta.2...v4.0.0-beta.3) (2024-06-12)
26
-
27
-
28
- ### Bug Fixes
29
-
30
- * only ack message if noAck option is false ([d6102e3](https://github.com/Tada5hi/amqp-extension/commit/d6102e3df431c6710257b5bdf59c8e99672e7df6))
31
-
32
- # [4.0.0-beta.2](https://github.com/Tada5hi/amqp-extension/compare/v4.0.0-beta.1...v4.0.0-beta.2) (2024-06-11)
33
-
34
-
35
- ### Bug Fixes
36
-
37
- * ensure (n)ack is send on same channel ([ab7026f](https://github.com/Tada5hi/amqp-extension/commit/ab7026f4e65f9cff33cb509dc25a77b72ddc25f1))
38
-
39
- # [4.0.0-beta.1](https://github.com/Tada5hi/amqp-extension/compare/v3.3.0...v4.0.0-beta.1) (2024-06-06)
40
-
41
-
42
- ### Bug Fixes
43
-
44
- * **deps:** bump amqplib from 0.10.3 to 0.10.4 ([#368](https://github.com/Tada5hi/amqp-extension/issues/368)) ([dae6c84](https://github.com/Tada5hi/amqp-extension/commit/dae6c840ad69e74a6c5dc37ea7f0fbb6c8ea1bae))
45
- * **deps:** bump smob from 1.4.1 to 1.5.0 ([#334](https://github.com/Tada5hi/amqp-extension/issues/334)) ([0b2935a](https://github.com/Tada5hi/amqp-extension/commit/0b2935af145d4844510c19b6d3f9d23ac0e3386a))
46
-
47
-
48
- ### Features
49
-
50
- * adjusted test suite ([a5cc771](https://github.com/Tada5hi/amqp-extension/commit/a5cc7714a141d671d1e97ed67216df0ffc53af49))
51
- * change publish/consume signature ([ff316ec](https://github.com/Tada5hi/amqp-extension/commit/ff316ec27ac1077c7a6949ea5e5adf6ad1e5e5f5))
52
- * initial refactoring of config, consume- &p publish-behaviour ([1102aa8](https://github.com/Tada5hi/amqp-extension/commit/1102aa8a8b000336312d89c92434d8c77e7a0424))
53
-
54
-
55
- ### BREAKING CHANGES
56
-
57
- * public api changed
58
-
59
- # [3.3.0](https://github.com/Tada5hi/amqp-extension/compare/v3.2.0...v3.3.0) (2024-03-20)
60
-
61
-
62
- ### Features
63
-
64
- * use amqp-connection-manager for connection/reconnect buisness ([#331](https://github.com/Tada5hi/amqp-extension/issues/331)) ([aa6a21e](https://github.com/Tada5hi/amqp-extension/commit/aa6a21e391ad2c07aa645ec2241e47b177e825e9))
65
-
66
- # [3.2.0](https://github.com/Tada5hi/amqp-extension/compare/v3.1.1...v3.2.0) (2024-03-11)
67
-
68
-
69
- ### Bug Fixes
70
-
71
- * remove unnecessary alias option ([8027d0a](https://github.com/Tada5hi/amqp-extension/commit/8027d0afb2063e5d0387dacf26cd77444dc933e4))
72
-
73
-
74
- ### Features
75
-
76
- * allways close channel after publishing ([a9b300f](https://github.com/Tada5hi/amqp-extension/commit/a9b300f6ab64d176a656cf9fc485f31a36168a7f))
77
-
78
- ## [3.1.1](https://github.com/Tada5hi/amqp-extension/compare/v3.1.0...v3.1.1) (2024-03-07)
79
-
80
-
81
- ### Bug Fixes
82
-
83
- * don't register consumer multiple times ([b45defa](https://github.com/Tada5hi/amqp-extension/commit/b45defa4dbd5a7abf6d2568586e2ff5bf2e62d16))
84
-
85
- # [3.1.0](https://github.com/Tada5hi/amqp-extension/compare/v3.0.0...v3.1.0) (2024-03-06)
86
-
87
-
88
- ### Features
89
-
90
- * reconnect strategy ([#320](https://github.com/Tada5hi/amqp-extension/issues/320)) ([4c31551](https://github.com/Tada5hi/amqp-extension/commit/4c31551029916dcaf055f78d53a8af7c626c393d))
91
- * reconnect strategy ([#320](https://github.com/Tada5hi/amqp-extension/issues/320)) ([17b141f](https://github.com/Tada5hi/amqp-extension/commit/17b141f6bd6256172e8c03a1006bfc1cab6225eb))
92
-
93
- # [3.0.0](https://github.com/Tada5hi/amqp-extension/compare/v2.0.2...v3.0.0) (2024-02-28)
94
-
95
-
96
- ### Bug Fixes
97
-
98
- * **deps:** bump @types/amqplib from 0.10.4 to 0.10.5 ([#310](https://github.com/Tada5hi/amqp-extension/issues/310)) ([984294e](https://github.com/Tada5hi/amqp-extension/commit/984294e7ac9dd04853ebd75e70b09841340b3239))
99
-
100
-
101
- ### Features
102
-
103
- * bind consume & publish to client class & remove singleton patterns ([9160408](https://github.com/Tada5hi/amqp-extension/commit/9160408038b1d48210735c843674817bb0ac45c6))
104
-
105
-
106
- ### BREAKING CHANGES
107
-
108
- * refactor public api
109
-
110
- ## [2.0.2](https://github.com/Tada5hi/amqp-extension/compare/v2.0.1...v2.0.2) (2024-02-28)
111
-
112
-
113
- ### Bug Fixes
114
-
115
- * **deps:** bump @types/amqplib from 0.10.3 to 0.10.4 ([#264](https://github.com/Tada5hi/amqp-extension/issues/264)) ([fb85e39](https://github.com/Tada5hi/amqp-extension/commit/fb85e39317d9b1bc2e08452f70bde7ea48957bef))
116
-
117
- ## [2.0.1](https://github.com/Tada5hi/amqp-extension/compare/v2.0.0...v2.0.1) (2023-11-05)
118
-
119
-
120
- ### Bug Fixes
121
-
122
- * bump (dev-) dependencies & resolved linting issues ([25b74ce](https://github.com/Tada5hi/amqp-extension/commit/25b74ceb3b83581b1f67bc7b09c6c68029e87252))
123
-
124
- # [2.0.0](https://github.com/Tada5hi/amqp-extension/compare/v1.1.1...v2.0.0) (2023-02-03)
125
-
126
-
127
- ### Bug Fixes
128
-
129
- * add generic type to publish option ([6f67912](https://github.com/Tada5hi/amqp-extension/commit/6f679129b4e295757b728e0df625ce276d708fe4))
130
- * **deps:** bump @types/amqplib ([de1316b](https://github.com/Tada5hi/amqp-extension/commit/de1316bd33885387ca88b761d03962692ba01d7f))
131
-
132
-
133
- ### BREAKING CHANGES
134
-
135
- * bump version
136
-
137
- ## [1.1.1](https://github.com/Tada5hi/amqp-extension/compare/v1.1.0...v1.1.1) (2023-02-03)
138
-
139
-
140
- ### Bug Fixes
141
-
142
- * expose amqplib types \n\n BREAKING CHANGE: bump to v2 ([5156649](https://github.com/Tada5hi/amqp-extension/commit/515664904e54c0767fb495bf7c6993101b0f169f))
143
-
144
- # [1.1.0](https://github.com/Tada5hi/amqp-extension/compare/v1.0.5...v1.1.0) (2023-02-03)
145
-
146
-
147
- ### Features
148
-
149
- * refactored and enhance publish & subscribe pattern \n\n BREAKING CHANGE: api rewritten ([#224](https://github.com/Tada5hi/amqp-extension/issues/224)) ([5bc43c2](https://github.com/Tada5hi/amqp-extension/commit/5bc43c235113ec8d604ad259434ad94fb7bb09f8))
@@ -1,10 +0,0 @@
1
- /*
2
- * Copyright (c) 2022.
3
- * Author Peter Placzek (tada5hi)
4
- * For the full copyright and license information,
5
- * view the LICENSE file that was distributed with this source code.
6
- */
7
-
8
- module.exports = {
9
- extends: ['@tada5hi/commitlint-config'],
10
- };
@@ -1,3 +0,0 @@
1
- export * from './type';
2
- export * from './module';
3
- export * from './module';
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./type"), exports);
24
- __exportStar(require("./module"), exports);
25
- __exportStar(require("./module"), exports);
@@ -1,2 +0,0 @@
1
- import type { Config, ConfigInput } from './type';
2
- export declare function buildConfig(input: ConfigInput): Config;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022-2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.buildConfig = buildConfig;
10
- const exchange_1 = require("../exchange");
11
- function buildConfig(input) {
12
- return {
13
- reconnectAttempts: 10,
14
- reconnectTimeout: 1000,
15
- connection: input.connection,
16
- publish: input.publish || {},
17
- consume: input.consume || {},
18
- exchange: input.exchange || {
19
- name: '',
20
- type: exchange_1.ExchangeType.DIRECT,
21
- },
22
- };
23
- }
@@ -1,13 +0,0 @@
1
- import type { Options } from 'amqplib';
2
- import type { ConsumeOptions } from '../consume';
3
- import type { Exchange } from '../exchange';
4
- import type { PublishOptions } from '../publish';
5
- export type Config = {
6
- reconnectAttempts: number;
7
- reconnectTimeout: number;
8
- connection: Options.Connect | string;
9
- exchange: Exchange;
10
- publish: PublishOptions;
11
- consume: ConsumeOptions;
12
- };
13
- export type ConfigInput = Partial<Exclude<Config, 'connection'>> & Pick<Config, 'connection'>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export declare const ConsumeHandlerAnyKey = "$any";
@@ -1,10 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ConsumeHandlerAnyKey = void 0;
10
- exports.ConsumeHandlerAnyKey = '$any';
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './type';
3
- export * from './utils';
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./constants"), exports);
24
- __exportStar(require("./type"), exports);
25
- __exportStar(require("./utils"), exports);
@@ -1,24 +0,0 @@
1
- import type { Channel, ConsumeMessage, Options } from 'amqplib';
2
- import type { ConsumeHandlerAnyKey } from './constants';
3
- export { ConsumeMessage, };
4
- export type ConsumeMessageHandler = (message: ConsumeMessage, channel: Channel) => Promise<void> | void;
5
- export type ConsumeHandlers = {
6
- [ConsumeHandlerAnyKey]?: ConsumeMessageHandler;
7
- } & {
8
- [key: string]: ConsumeMessageHandler;
9
- };
10
- export type ConsumeOptions = Options.Consume & {
11
- /**
12
- * Default: false
13
- */
14
- requeueOnFailure?: boolean;
15
- /**
16
- * Default: undefined
17
- */
18
- prefetchCount?: number;
19
- };
20
- export type ConsumeContext = {
21
- from: string;
22
- options?: ConsumeOptions;
23
- handlers: ConsumeHandlers;
24
- };
@@ -1,8 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- import type { ConsumeHandlers } from './type';
2
- export declare function isConsumeHandlers(input: unknown): input is ConsumeHandlers;
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isConsumeHandlers = isConsumeHandlers;
4
- const smob_1 = require("smob");
5
- function isConsumeHandlers(input) {
6
- if (!(0, smob_1.isObject)(input)) {
7
- return false;
8
- }
9
- const keys = Object.keys(input);
10
- for (let i = 0; i < keys.length; i++) {
11
- if (typeof input[keys[i]] !== 'function') {
12
- return false;
13
- }
14
- }
15
- return true;
16
- }
@@ -1,6 +0,0 @@
1
- export declare enum ExchangeType {
2
- FANOUT = "fanout",
3
- DIRECT = "direct",
4
- TOPIC = "topic",
5
- MATCH = "match"
6
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExchangeType = void 0;
4
- var ExchangeType;
5
- (function (ExchangeType) {
6
- ExchangeType["FANOUT"] = "fanout";
7
- ExchangeType["DIRECT"] = "direct";
8
- ExchangeType["TOPIC"] = "topic";
9
- ExchangeType["MATCH"] = "match";
10
- })(ExchangeType || (exports.ExchangeType = ExchangeType = {}));
@@ -1,3 +0,0 @@
1
- export * from './constants';
2
- export * from './type';
3
- export * from './utils';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./constants"), exports);
18
- __exportStar(require("./type"), exports);
19
- __exportStar(require("./utils"), exports);
@@ -1,8 +0,0 @@
1
- import type { Options } from 'amqplib';
2
- import type { ExchangeType } from './constants';
3
- export type ExchangeOptions = Options.AssertExchange;
4
- export type Exchange = {
5
- type: `${ExchangeType}`;
6
- name?: string;
7
- options?: ExchangeOptions;
8
- };
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +0,0 @@
1
- import { ExchangeType } from './constants';
2
- import type { Exchange } from './type';
3
- export declare function isDefaultExchange(input?: `${ExchangeType}`): input is ExchangeType.DIRECT;
4
- export declare function isExchange(input: unknown): input is Exchange;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isDefaultExchange = isDefaultExchange;
4
- exports.isExchange = isExchange;
5
- const smob_1 = require("smob");
6
- const constants_1 = require("./constants");
7
- function isDefaultExchange(input) {
8
- return typeof input === 'undefined' || input === constants_1.ExchangeType.DIRECT;
9
- }
10
- function isExchange(input) {
11
- return (0, smob_1.isObject)(input) &&
12
- typeof input.type === 'string';
13
- }
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export * from './config';
2
- export * from './consume';
3
- export * from './exchange';
4
- export * from './module';
5
- export * from './publish';
6
- export * from './type';
package/dist/index.js DELETED
@@ -1,28 +0,0 @@
1
- "use strict";
2
- /*
3
- * Copyright (c) 2022.
4
- * Author Peter Placzek (tada5hi)
5
- * For the full copyright and license information,
6
- * view the LICENSE file that was distributed with this source code.
7
- */
8
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
- if (k2 === undefined) k2 = k;
10
- var desc = Object.getOwnPropertyDescriptor(m, k);
11
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
- desc = { enumerable: true, get: function() { return m[k]; } };
13
- }
14
- Object.defineProperty(o, k2, desc);
15
- }) : (function(o, m, k, k2) {
16
- if (k2 === undefined) k2 = k;
17
- o[k2] = m[k];
18
- }));
19
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
- };
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./config"), exports);
24
- __exportStar(require("./consume"), exports);
25
- __exportStar(require("./exchange"), exports);
26
- __exportStar(require("./module"), exports);
27
- __exportStar(require("./publish"), exports);
28
- __exportStar(require("./type"), exports);
package/dist/module.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { PublishContext, PublishOptions } from './publish';
2
- import type { ClientContext, Connection } from './type';
3
- import type { ConsumeContext, ConsumeHandlers, ConsumeOptions } from './consume';
4
- import type { Exchange } from './exchange';
5
- export declare class Client {
6
- readonly connection: Connection;
7
- protected publishOptions: PublishOptions;
8
- protected consumeOptions: ConsumeOptions;
9
- protected exchange: Exchange;
10
- constructor(ctx: ClientContext);
11
- of(exchange: Exchange): Client;
12
- consume(ctx: ConsumeContext): Promise<void>;
13
- consume(from: string, handlers: ConsumeHandlers): Promise<void>;
14
- consume(from: string, options: ConsumeOptions, handlers: ConsumeHandlers): Promise<void>;
15
- publish(ctx: PublishContext): Promise<boolean>;
16
- publish(to: string, data: any): Promise<boolean>;
17
- publish(to: string, data: any, options: PublishOptions): Promise<boolean>;
18
- }