@rxdi/graphql-pubsub 0.7.239 → 0.7.240
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/config.tokens.d.ts
CHANGED
|
@@ -3,6 +3,11 @@ import { AmqpPubSub } from '@rxdi/graphql-rabbitmq-subscriptions';
|
|
|
3
3
|
import { PubSub } from 'graphql-subscriptions';
|
|
4
4
|
import { Server } from 'http';
|
|
5
5
|
import { ServerOptions } from 'subscriptions-transport-ws';
|
|
6
|
+
export declare enum PubSubProtocol {
|
|
7
|
+
DEFAULT = "DEFAULT",
|
|
8
|
+
NATS = "NATS",
|
|
9
|
+
RABBITMQ = "RABBITMQ"
|
|
10
|
+
}
|
|
6
11
|
export interface GRAPHQL_PUBSUB_SERVER_OPTIONS {
|
|
7
12
|
server?: Server;
|
|
8
13
|
path?: string;
|
|
@@ -32,6 +37,7 @@ export declare class GRAPHQL_PUB_SUB_DI_CONFIG {
|
|
|
32
37
|
authentication?: string;
|
|
33
38
|
log?: boolean;
|
|
34
39
|
activateRabbitMQ?: boolean;
|
|
40
|
+
protocol?: PubSubProtocol;
|
|
35
41
|
logger?: any;
|
|
36
42
|
subscriptionServerOptions?: GRAPHQL_PUBSUB_SERVER_OPTIONS;
|
|
37
43
|
}
|
package/dist/config.tokens.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRAPHQL_PUB_SUB_CONFIG = exports.GRAPHQL_PUB_SUB_DI_CONFIG = void 0;
|
|
3
|
+
exports.GRAPHQL_PUB_SUB_CONFIG = exports.GRAPHQL_PUB_SUB_DI_CONFIG = exports.PubSubProtocol = void 0;
|
|
4
4
|
const core_1 = require("@rxdi/core");
|
|
5
|
+
var PubSubProtocol;
|
|
6
|
+
(function (PubSubProtocol) {
|
|
7
|
+
PubSubProtocol["DEFAULT"] = "DEFAULT";
|
|
8
|
+
PubSubProtocol["NATS"] = "NATS";
|
|
9
|
+
PubSubProtocol["RABBITMQ"] = "RABBITMQ";
|
|
10
|
+
})(PubSubProtocol || (exports.PubSubProtocol = PubSubProtocol = {}));
|
|
5
11
|
class GRAPHQL_PUB_SUB_DI_CONFIG {
|
|
6
12
|
}
|
|
7
13
|
exports.GRAPHQL_PUB_SUB_DI_CONFIG = GRAPHQL_PUB_SUB_DI_CONFIG;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import { PubSub } from
|
|
2
|
-
import { AmqpPubSub } from
|
|
3
|
-
import { GRAPHQL_PUB_SUB_DI_CONFIG } from
|
|
4
|
-
import { PubSubLogger } from
|
|
5
|
-
export declare let pubsub: PubSub | AmqpPubSub;
|
|
1
|
+
import { PubSub } from 'graphql-subscriptions';
|
|
2
|
+
import { AmqpPubSub } from '@rxdi/graphql-rabbitmq-subscriptions';
|
|
3
|
+
import { GRAPHQL_PUB_SUB_DI_CONFIG } from '../config.tokens';
|
|
4
|
+
import { PubSubLogger } from './logger.service';
|
|
5
|
+
export declare let pubsub: PubSub | AmqpPubSub | any;
|
|
6
6
|
export declare class PubSubService {
|
|
7
7
|
private config;
|
|
8
8
|
private logger;
|
|
9
9
|
sub: AmqpPubSub & PubSub;
|
|
10
10
|
constructor(config: GRAPHQL_PUB_SUB_DI_CONFIG, logger: PubSubLogger);
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
private createNatsPubSub;
|
|
12
|
+
asyncIterator(event: any, options?: any): AsyncIterator<any>;
|
|
13
|
+
asyncIterableIterator(event: any, options?: any): AsyncIterator<any>;
|
|
13
14
|
publish(signal: string, data: any): Promise<void>;
|
|
14
15
|
}
|
|
@@ -19,15 +19,19 @@ const core_1 = require("@rxdi/core");
|
|
|
19
19
|
const config_tokens_1 = require("../config.tokens");
|
|
20
20
|
const logger_service_1 = require("./logger.service");
|
|
21
21
|
let PubSubService = class PubSubService {
|
|
22
|
+
;
|
|
22
23
|
constructor(config, logger) {
|
|
23
24
|
this.config = config;
|
|
24
25
|
this.logger = logger;
|
|
25
26
|
if (this.config.pubsub) {
|
|
26
27
|
this.sub = this.config.pubsub;
|
|
27
28
|
}
|
|
29
|
+
else if (this.config.protocol === config_tokens_1.PubSubProtocol.NATS) {
|
|
30
|
+
this.sub = this.createNatsPubSub();
|
|
31
|
+
}
|
|
28
32
|
else if (this.config.activateRabbitMQ) {
|
|
29
33
|
this.sub = new graphql_rabbitmq_subscriptions_1.AmqpPubSub({
|
|
30
|
-
config: `amqp://${this.config.user || process.env.AMQP_USER ||
|
|
34
|
+
config: `amqp://${this.config.user || process.env.AMQP_USER || 'guest'}:${this.config.pass || 'guest'}@${this.config.host || process.env.AMQP_HOST || 'localhost'}:${this.config.port || process.env.AMQP_PORT || '5672'}`,
|
|
31
35
|
logger: this.config.logger || this.logger,
|
|
32
36
|
});
|
|
33
37
|
}
|
|
@@ -35,11 +39,23 @@ let PubSubService = class PubSubService {
|
|
|
35
39
|
this.sub = new graphql_subscriptions_1.PubSub();
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
|
-
|
|
42
|
+
createNatsPubSub() {
|
|
43
|
+
var _a;
|
|
44
|
+
try {
|
|
45
|
+
const { NatsClientService, NatsPubSub } = require('@rxdi/nats');
|
|
46
|
+
const natsClient = core_1.Container.get(NatsClientService);
|
|
47
|
+
if ((_a = natsClient === null || natsClient === void 0 ? void 0 : natsClient.isReady) === null || _a === void 0 ? void 0 : _a.call(natsClient)) {
|
|
48
|
+
return new NatsPubSub(natsClient);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
catch (e) {
|
|
52
|
+
console.warn('NATS PubSub not available, falling back to default PubSub');
|
|
53
|
+
}
|
|
54
|
+
return new graphql_subscriptions_1.PubSub();
|
|
55
|
+
}
|
|
39
56
|
asyncIterator(event, options) {
|
|
40
57
|
return this.sub.asyncIterableIterator(event, options);
|
|
41
58
|
}
|
|
42
|
-
/* New version of graphql-subscriptions async iterator */
|
|
43
59
|
asyncIterableIterator(event, options) {
|
|
44
60
|
return this.sub.asyncIterableIterator(event, options);
|
|
45
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rxdi/graphql-pubsub",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.240",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rxdi/graphql-pubsub"
|
|
@@ -10,10 +10,9 @@
|
|
|
10
10
|
"module": "./dist/index.js",
|
|
11
11
|
"typings": "./dist/index.d.ts",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"test": "jest
|
|
13
|
+
"test": "jest",
|
|
14
14
|
"build": "tsc",
|
|
15
|
-
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'"
|
|
16
|
-
"pretest": "npm run lint"
|
|
15
|
+
"lint": "tslint -c tslint.json 'src/**/*.{ts,tsx}'"
|
|
17
16
|
},
|
|
18
17
|
"author": {
|
|
19
18
|
"name": "Kristian Tachev(Stradivario)",
|
|
@@ -30,21 +29,17 @@
|
|
|
30
29
|
},
|
|
31
30
|
"homepage": "https://github.com/rxdi/graphql-pubsub#readme",
|
|
32
31
|
"dependencies": {
|
|
33
|
-
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.
|
|
34
|
-
"@rxdi/rabbitmq-pubsub": "^0.7.
|
|
32
|
+
"@rxdi/graphql-rabbitmq-subscriptions": "^0.7.239",
|
|
33
|
+
"@rxdi/rabbitmq-pubsub": "^0.7.239",
|
|
35
34
|
"subscriptions-transport-ws": "^0.9.19"
|
|
36
35
|
},
|
|
37
36
|
"devDependencies": {
|
|
38
|
-
"@rxdi/core": "^0.7.
|
|
39
|
-
"@rxdi/graphql": "^0.7.
|
|
40
|
-
"@rxdi/hapi": "^0.7.
|
|
37
|
+
"@rxdi/core": "^0.7.239",
|
|
38
|
+
"@rxdi/graphql": "^0.7.239",
|
|
39
|
+
"@rxdi/hapi": "^0.7.239",
|
|
41
40
|
"@types/graphql": "^14.5.0",
|
|
42
41
|
"@types/hapi": "^18.0.4",
|
|
43
|
-
"@types/jest": "^24.0.22",
|
|
44
42
|
"@types/node": "^25.0.3",
|
|
45
|
-
"jest": "^24.8.0",
|
|
46
|
-
"jest-cli": "^24.8.1",
|
|
47
|
-
"ts-jest": "^24.0.2",
|
|
48
43
|
"tslint": "^5.20.1",
|
|
49
44
|
"tslint-language-service": "^0.9.9",
|
|
50
45
|
"typescript": "^5.9.3"
|
|
@@ -54,23 +49,19 @@
|
|
|
54
49
|
"testPathIgnorePatterns": [
|
|
55
50
|
"/node_modules/"
|
|
56
51
|
],
|
|
57
|
-
"coverageReporters": [
|
|
58
|
-
"lcov",
|
|
59
|
-
"html"
|
|
60
|
-
],
|
|
61
52
|
"rootDir": "./",
|
|
62
|
-
"moduleFileExtensions": [
|
|
63
|
-
"ts",
|
|
64
|
-
"tsx",
|
|
65
|
-
"js",
|
|
66
|
-
"json",
|
|
67
|
-
"node"
|
|
68
|
-
],
|
|
69
53
|
"transform": {
|
|
70
|
-
"
|
|
54
|
+
"^.+\\.tsx?$": [
|
|
55
|
+
"ts-jest",
|
|
56
|
+
{
|
|
57
|
+
"useESM": true,
|
|
58
|
+
"diagnostics": false
|
|
59
|
+
}
|
|
60
|
+
]
|
|
71
61
|
},
|
|
72
|
-
"testRegex": "/src/.*\\.spec
|
|
73
|
-
"
|
|
74
|
-
|
|
62
|
+
"testRegex": "/src/.*\\.spec\\.(ts|tsx|js)$",
|
|
63
|
+
"moduleNameMapper": {
|
|
64
|
+
"^(\\.{1,2}/.*)\\.js$": "$1"
|
|
65
|
+
}
|
|
75
66
|
}
|
|
76
67
|
}
|