amqp-extension 1.1.1 → 2.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.
package/.eslintrc CHANGED
@@ -3,7 +3,7 @@
3
3
  "@tada5hi/eslint-config-typescript"
4
4
  ],
5
5
  "parserOptions": {
6
- "project": "./tsconfig.json"
6
+ "project": "./tsconfig.eslint.json"
7
7
  },
8
8
  "ignorePatterns": ["**/dist/*", "**/*.d.ts", "**/test/*"],
9
9
  "globals": {
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## [2.0.1](https://github.com/Tada5hi/amqp-extension/compare/v2.0.0...v2.0.1) (2023-11-05)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * bump (dev-) dependencies & resolved linting issues ([25b74ce](https://github.com/Tada5hi/amqp-extension/commit/25b74ceb3b83581b1f67bc7b09c6c68029e87252))
7
+
8
+ # [2.0.0](https://github.com/Tada5hi/amqp-extension/compare/v1.1.1...v2.0.0) (2023-02-03)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * add generic type to publish option ([6f67912](https://github.com/Tada5hi/amqp-extension/commit/6f679129b4e295757b728e0df625ce276d708fe4))
14
+ * **deps:** bump @types/amqplib ([de1316b](https://github.com/Tada5hi/amqp-extension/commit/de1316bd33885387ca88b761d03962692ba01d7f))
15
+
16
+
17
+ ### BREAKING CHANGES
18
+
19
+ * bump version
20
+
1
21
  ## [1.1.1](https://github.com/Tada5hi/amqp-extension/compare/v1.1.0...v1.1.1) (2023-02-03)
2
22
 
3
23
 
package/README.MD CHANGED
@@ -56,7 +56,7 @@ setConfig({
56
56
 
57
57
  (async () => {
58
58
  await publish({
59
- data: {
59
+ content: {
60
60
  type: 'resourceCreated',
61
61
  name: 'foo'
62
62
  }
@@ -148,7 +148,7 @@ setConfig({
148
148
  await publish({
149
149
  routingKey: '<routing-key>',
150
150
  alias: 'foo', // <--- use another connection :)
151
- data: {
151
+ content: {
152
152
  foo: 'bar'
153
153
  }
154
154
  });
@@ -315,7 +315,7 @@ import {
315
315
 
316
316
  (async () => {
317
317
  await publish({
318
- data: {
318
+ content: {
319
319
  type: 'resourceCreated'
320
320
  }
321
321
  });
@@ -6,5 +6,5 @@
6
6
  */
7
7
 
8
8
  module.exports = {
9
- extends: ['@commitlint/config-angular'],
9
+ extends: ['@tada5hi/commitlint-config'],
10
10
  };
@@ -1,4 +1,4 @@
1
- import { Config, ConfigInput } from './type';
1
+ import type { Config, ConfigInput } from './type';
2
2
  export declare function setConfig(key: string | ConfigInput, value?: ConfigInput): Config;
3
3
  export declare function hasConfig(key?: string): boolean;
4
4
  export declare function getConfig(key?: string | ConfigInput): Config;
@@ -1,6 +1,6 @@
1
- import { Options } from 'amqplib';
2
- import { ExchangeOptions } from '../exchange';
3
- import { ConsumeOptions, PublishOptions } from '../type';
1
+ import type { Options } from 'amqplib';
2
+ import type { ExchangeOptions } from '../exchange';
3
+ import type { ConsumeOptions, PublishOptions } from '../type';
4
4
  export type Config = {
5
5
  alias: string;
6
6
  connection: Options.Connect | string;
@@ -1,3 +1,3 @@
1
- import { Config, ConfigInput } from './type';
1
+ import type { Config, ConfigInput } from './type';
2
2
  export declare function getConfigKey(alias?: string): string;
3
3
  export declare function extendConfig(input: ConfigInput): Config;
@@ -1,7 +1,7 @@
1
- import RabbitMQ, { Connection, Options } from 'amqplib';
2
- import { ConfigInput } from '../config';
1
+ import type { Connection, Options } from 'amqplib';
2
+ import type { ConfigInput } from '../config';
3
3
  export declare function clearConnections(): Promise<void>;
4
4
  export declare function hasConnection(key?: string): boolean;
5
5
  export declare function getConnections(): Record<string, Connection>;
6
6
  export declare function useConnection(key: string | ConfigInput): Promise<Connection>;
7
- export declare function createConnection(config: Options.Connect | string): Promise<RabbitMQ.Connection>;
7
+ export declare function createConnection(config: Options.Connect | string): Promise<Connection>;
@@ -1,3 +1,3 @@
1
- import { ConsumeOptions } from '../type';
2
- import { ConsumeHandlers } from './type';
1
+ import type { ConsumeOptions } from '../type';
2
+ import type { ConsumeHandlers } from './type';
3
3
  export declare function consume(options: ConsumeOptions, handlers: ConsumeHandlers): Promise<void>;
@@ -1,5 +1,5 @@
1
1
  import type { Channel, ConsumeMessage } from 'amqplib';
2
- import { ConsumeHandlerAnyKey } from './static';
2
+ import type { ConsumeHandlerAnyKey } from './static';
3
3
  export { ConsumeMessage, };
4
4
  export type ConsumeMessageHandler = (message: ConsumeMessage, channel: Channel) => Promise<void>;
5
5
  export type ConsumeHandlerAnyKeyType = typeof ConsumeHandlerAnyKey;
@@ -1,3 +1,3 @@
1
- import { Options } from 'amqplib';
2
- import { ConsumeOptions } from '../type';
1
+ import type { Options } from 'amqplib';
2
+ import type { ConsumeOptions } from '../type';
3
3
  export declare function buildDriverConsumeOptions(options: ConsumeOptions): Options.Consume;
@@ -8,4 +8,4 @@ var ExchangeType;
8
8
  ExchangeType["DIRECT"] = "direct";
9
9
  ExchangeType["TOPIC"] = "topic";
10
10
  ExchangeType["MATCH"] = "match";
11
- })(ExchangeType = exports.ExchangeType || (exports.ExchangeType = {}));
11
+ })(ExchangeType || (exports.ExchangeType = ExchangeType = {}));
@@ -1,5 +1,5 @@
1
- import { Options } from 'amqplib';
2
- import { ExchangeType } from './constants';
1
+ import type { Options } from 'amqplib';
2
+ import type { ExchangeType } from './constants';
3
3
  export type ExchangeOptions = {
4
4
  name: string;
5
5
  type: `${ExchangeType}`;
@@ -1,5 +1,5 @@
1
- import { Options } from 'amqplib';
1
+ import type { Options } from 'amqplib';
2
2
  import { ExchangeType } from './constants';
3
- import { ExchangeOptions } from './type';
3
+ import type { ExchangeOptions } from './type';
4
4
  export declare function isDefaultExchange(exchange?: `${ExchangeType}`): boolean;
5
5
  export declare function buildDriverExchangeOptions(options: ExchangeOptions): Options.AssertExchange;
@@ -1,2 +1,2 @@
1
- import { PublishOptionsExtended } from './type';
1
+ import type { PublishOptionsExtended } from './type';
2
2
  export declare function publish(options: PublishOptionsExtended): Promise<void>;
@@ -17,14 +17,14 @@ const utils_1 = require("./utils");
17
17
  /* istanbul ignore next */
18
18
  async function publish(options) {
19
19
  let buffer;
20
- if (Buffer.isBuffer(options.data)) {
21
- buffer = options.data;
20
+ if (Buffer.isBuffer(options.content)) {
21
+ buffer = options.content;
22
22
  }
23
- else if (typeof options.data === 'string') {
24
- buffer = Buffer.from(options.data, 'utf-8');
23
+ else if (typeof options.content === 'string') {
24
+ buffer = Buffer.from(options.content, 'utf-8');
25
25
  }
26
26
  else {
27
- buffer = Buffer.from(JSON.stringify(options.data), 'utf-8');
27
+ buffer = Buffer.from(JSON.stringify(options.content), 'utf-8');
28
28
  }
29
29
  const config = (0, config_1.getConfig)(options.alias);
30
30
  const connection = await (0, connection_1.useConnection)(config.alias);
@@ -1,5 +1,5 @@
1
- import { PublishOptions } from '../type';
2
- export type PublishOptionsExtended = {
1
+ import type { PublishOptions } from '../type';
2
+ export type PublishOptionsExtended<T = any> = {
3
3
  /**
4
4
  * Alias for: messageId
5
5
  *
@@ -9,5 +9,5 @@ export type PublishOptionsExtended = {
9
9
  /**
10
10
  * The message data.
11
11
  */
12
- data: any;
12
+ content: T;
13
13
  } & PublishOptions;
@@ -1,3 +1,3 @@
1
- import { Options } from 'amqplib';
2
- import { PublishOptionsExtended } from './type';
1
+ import type { Options } from 'amqplib';
2
+ import type { PublishOptionsExtended } from './type';
3
3
  export declare function buildDriverPublishOptions(options: PublishOptionsExtended): Options.Publish;
@@ -7,7 +7,7 @@ function buildDriverPublishOptions(options) {
7
7
  'alias',
8
8
  'exchange',
9
9
  'queueName',
10
- 'data',
10
+ 'content',
11
11
  'id',
12
12
  ]);
13
13
  }
package/dist/type.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Options } from 'amqplib';
2
- import { ConfigInput } from './config';
3
- import { ExchangeOptions } from './exchange';
1
+ import type { Options } from 'amqplib';
2
+ import type { ConfigInput } from './config';
3
+ import type { ExchangeOptions } from './exchange';
4
4
  type CommonOptions = {
5
5
  /**
6
6
  * Config key or object.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amqp-extension",
3
- "version": "1.1.1",
3
+ "version": "2.0.1",
4
4
  "description": "An amqp extension with functions and utility functions to consume and publish queue messages.",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -35,37 +35,25 @@
35
35
  },
36
36
  "homepage": "https://github.com/Tada5hi/amqp-extension#readme",
37
37
  "dependencies": {
38
- "@types/amqplib": "^0.10.0",
38
+ "@types/amqplib": "^0.10.3",
39
39
  "amqplib": "^0.10.3",
40
- "smob": "^0.1.0",
41
- "uuid": "^9.0.0"
40
+ "smob": "^1.4.1",
41
+ "uuid": "^9.0.1"
42
42
  },
43
43
  "devDependencies": {
44
- "@commitlint/cli": "^17.4.2",
45
- "@commitlint/config-angular": "^17.4.2",
46
- "@commitlint/config-conventional": "^17.4.2",
47
- "@commitlint/cz-commitlint": "^17.4.2",
48
- "@semantic-release/changelog": "^6.0.1",
49
- "@semantic-release/git": "^10.0.1",
50
- "@semantic-release/release-notes-generator": "^10.0.3",
51
- "@tada5hi/eslint-config-typescript": "^1.1.1",
52
- "@tada5hi/tsconfig": "^0.4.0",
53
- "@types/jest": "^27.4.1",
54
- "@types/node": "^18.11.9",
44
+ "@tada5hi/commitlint-config": "^1.1.3",
45
+ "@tada5hi/eslint-config-typescript": "^1.2.6",
46
+ "@tada5hi/semantic-release": "^0.3.0",
47
+ "@tada5hi/tsconfig": "^0.5.0",
48
+ "@types/jest": "^29.5.7",
49
+ "@types/node": "^20.8.10",
55
50
  "@types/uuid": "^8.3.4",
56
- "codecov": "^3.8.3",
57
- "coveralls": "^3.1.0",
58
51
  "cross-env": "^7.0.3",
59
- "eslint": "^8.33.0",
60
- "husky": "^8.0.2",
61
- "jest": "^27.5.1",
62
- "semantic-release": "^19.0.5",
63
- "ts-jest": "^27.1.4",
64
- "typescript": "^4.9.5"
65
- },
66
- "config": {
67
- "commitizen": {
68
- "path": "@commitlint/cz-commitlint"
69
- }
52
+ "eslint": "^8.53.0",
53
+ "husky": "^8.0.3",
54
+ "jest": "^29.7.0",
55
+ "semantic-release": "^22.0.7",
56
+ "ts-jest": "^29.1.1",
57
+ "typescript": "^5.2.2"
70
58
  }
71
59
  }
package/release.config.js CHANGED
@@ -1,10 +1,3 @@
1
1
  module.exports = {
2
- "plugins": [
3
- "@semantic-release/commit-analyzer",
4
- "@semantic-release/release-notes-generator",
5
- "@semantic-release/changelog",
6
- "@semantic-release/npm",
7
- "@semantic-release/git",
8
- "@semantic-release/github"
9
- ]
2
+ "extends": "@tada5hi/semantic-release"
10
3
  }
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": ["./tsconfig.json"],
3
+ "include": [
4
+ "src/**/*.ts",
5
+ "release.config.js",
6
+ "commitlint.config.js"
7
+ ],
8
+ "exclude": [
9
+ "node_modules/**/*"
10
+ ]
11
+ }