@things-factory/shell 4.1.1 → 4.1.12
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-server/pubsub.js +14 -8
- package/dist-server/pubsub.js.map +1 -1
- package/package.json +7 -7
- package/server/pubsub.ts +24 -17
package/dist-server/pubsub.js
CHANGED
@@ -4,7 +4,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
4
|
};
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
6
|
exports.pubsub = void 0;
|
7
|
-
const graphql_kafka_subscriptions_1 = require("graphql-kafka-subscriptions");
|
8
7
|
const graphql_mqtt_subscriptions_1 = require("graphql-mqtt-subscriptions");
|
9
8
|
const graphql_redis_subscriptions_1 = require("graphql-redis-subscriptions");
|
10
9
|
const graphql_subscriptions_1 = require("graphql-subscriptions");
|
@@ -40,10 +39,19 @@ switch (middleware) {
|
|
40
39
|
});
|
41
40
|
break;
|
42
41
|
case 'kafka':
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
42
|
+
try {
|
43
|
+
/*
|
44
|
+
* https://github.com/hatiolab/things-factory/issues/1239
|
45
|
+
*/
|
46
|
+
const { KafkaPubSub } = require('graphql-kafka-subscriptions');
|
47
|
+
exports.pubsub = pubsub = new KafkaPubSub(Object.assign({ topic,
|
48
|
+
host,
|
49
|
+
port }, options));
|
50
|
+
}
|
51
|
+
catch (e) {
|
52
|
+
console.error('graphql-kafka-subscriptions module is not installed, so application can not go further.');
|
53
|
+
throw e;
|
54
|
+
}
|
47
55
|
break;
|
48
56
|
default:
|
49
57
|
exports.pubsub = pubsub = new graphql_subscriptions_1.PubSub();
|
@@ -60,9 +68,7 @@ const exitHandler = async (evt) => {
|
|
60
68
|
console.error(err);
|
61
69
|
}
|
62
70
|
}
|
63
|
-
|
64
|
-
if (evt.exit)
|
65
|
-
process.exit();
|
71
|
+
process.exit();
|
66
72
|
};
|
67
73
|
/*
|
68
74
|
* exit events hint from https://stackoverflow.com/a/14032965/14539284
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"pubsub.js","sourceRoot":"","sources":["../server/pubsub.ts"],"names":[],"mappings":";;;;;;AAAA,
|
1
|
+
{"version":3,"file":"pubsub.js","sourceRoot":"","sources":["../server/pubsub.ts"],"names":[],"mappings":";;;;;;AAAA,2EAAuD;AACvD,6EAAyD;AACzD,iEAA8C;AAC9C,sDAA2B;AAC3B,+BAA8B;AAE9B,6CAA4C;AAE5C,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,YAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;AAElF,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,sBAAsB,CAAC,CAAA;AAEtD,IAAI,MAAW,CAAA;AAuFN,wBAAM;AArFf,QAAQ,UAAU,EAAE;IAClB,KAAK,MAAM;QACT,iBAAA,MAAM,GAAG,IAAI,uCAAU,CAAC;YACtB,MAAM,EAAE,IAAA,cAAO,EAAC,SAAS,GAAG,IAAI,kBAC9B,eAAe,EAAE,IAAI,IAClB,OAAO,EACH;SACV,CAAC,CAAA;QACF,MAAK;IACP,KAAK,OAAO;QACV,MAAM,WAAW,mBACf,IAAI;YACJ,IAAI,EACJ,aAAa,EAAE,KAAK,CAAC,EAAE;gBACrB,kBAAkB;gBAClB,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,EAAE,IAAI,CAAC,CAAA;YACnC,CAAC,IACE,OAAO,CACX,CAAA;QACD,iBAAA,MAAM,GAAG,IAAI,yCAAW,CAAC;YACvB,SAAS,EAAE,IAAI,iBAAK,CAAC,WAAW,CAAC;YACjC,UAAU,EAAE,IAAI,iBAAK,CAAC,WAAW,CAAC;SACnC,CAAC,CAAA;QACF,MAAK;IACP,KAAK,cAAc;QACjB,MAAM,OAAO,GAAG,IAAI,iBA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IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAE5E,oDAAoD;AACpD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC9E,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAE9E,6BAA6B;AAC7B,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,WAAW,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/shell",
|
3
|
-
"version": "4.1.
|
3
|
+
"version": "4.1.12",
|
4
4
|
"description": "Core module for framework",
|
5
5
|
"bin": {
|
6
6
|
"things-factory": "bin/things-factory",
|
@@ -50,10 +50,10 @@
|
|
50
50
|
"@operato/layout": "^0.3.28",
|
51
51
|
"@operato/shell": "^0.3.28",
|
52
52
|
"@operato/utils": "^0.3.28",
|
53
|
-
"@things-factory/ejs-remote": "^4.1.
|
54
|
-
"@things-factory/env": "^4.1.
|
55
|
-
"@things-factory/styles": "^4.1.
|
56
|
-
"@things-factory/utils": "^4.1.
|
53
|
+
"@things-factory/ejs-remote": "^4.1.12",
|
54
|
+
"@things-factory/env": "^4.1.12",
|
55
|
+
"@things-factory/styles": "^4.1.12",
|
56
|
+
"@things-factory/utils": "^4.1.12",
|
57
57
|
"@webcomponents/webcomponentsjs": "^2.6.0",
|
58
58
|
"@webpack-contrib/schema-utils": "^1.0.0-beta.0",
|
59
59
|
"apollo-server-core": "^3.5.0",
|
@@ -71,7 +71,6 @@
|
|
71
71
|
"fs-extra": "^9.0.1",
|
72
72
|
"glob": "^7.1.6",
|
73
73
|
"graphql": "^15.7.2",
|
74
|
-
"graphql-kafka-subscriptions": "^0.4.0",
|
75
74
|
"graphql-mqtt-subscriptions": "^1.2.0",
|
76
75
|
"graphql-redis-subscriptions": "^2.4.2",
|
77
76
|
"graphql-subscriptions": "^2.0.0",
|
@@ -121,6 +120,7 @@
|
|
121
120
|
"optionalDependencies": {
|
122
121
|
"better-sqlite3": "^7.1.2",
|
123
122
|
"mssql": "^6.1.0",
|
123
|
+
"mysql2": "^2.3.3",
|
124
124
|
"oracledb": "^5.1.0",
|
125
125
|
"pg": "^8.3.0",
|
126
126
|
"sqlite3": "^5.0.0"
|
@@ -128,5 +128,5 @@
|
|
128
128
|
"resolutions": {
|
129
129
|
"core-js": "^3.16.0"
|
130
130
|
},
|
131
|
-
"gitHead": "
|
131
|
+
"gitHead": "9055b83aa979f9c2d706b02cf8d73d848522d7dd"
|
132
132
|
}
|
package/server/pubsub.ts
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { KafkaPubSub } from 'graphql-kafka-subscriptions'
|
2
1
|
import { MQTTPubSub } from 'graphql-mqtt-subscriptions'
|
3
2
|
import { RedisPubSub } from 'graphql-redis-subscriptions'
|
4
3
|
import { PubSub } from 'graphql-subscriptions'
|
@@ -45,13 +44,21 @@ switch (middleware) {
|
|
45
44
|
})
|
46
45
|
break
|
47
46
|
case 'kafka':
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
47
|
+
try {
|
48
|
+
/*
|
49
|
+
* https://github.com/hatiolab/things-factory/issues/1239
|
50
|
+
*/
|
51
|
+
const { KafkaPubSub } = require('graphql-kafka-subscriptions')
|
52
|
+
pubsub = new KafkaPubSub({
|
53
|
+
topic,
|
54
|
+
host,
|
55
|
+
port,
|
56
|
+
...options
|
57
|
+
})
|
58
|
+
} catch (e) {
|
59
|
+
console.error('graphql-kafka-subscriptions module is not installed, so application can not go further.')
|
60
|
+
throw e
|
61
|
+
}
|
55
62
|
break
|
56
63
|
default:
|
57
64
|
pubsub = new PubSub()
|
@@ -61,7 +68,7 @@ switch (middleware) {
|
|
61
68
|
debug(middleware || 'default', 'pubsub initialized.')
|
62
69
|
|
63
70
|
// kafka pubsub keeps connection and app port with 'ctrl+c' termination.
|
64
|
-
const exitHandler = async
|
71
|
+
const exitHandler = async evt => {
|
65
72
|
if (pubsub.close) {
|
66
73
|
try {
|
67
74
|
await pubsub.close()
|
@@ -69,25 +76,25 @@ const exitHandler = async (evt) => {
|
|
69
76
|
console.error(err)
|
70
77
|
}
|
71
78
|
}
|
72
|
-
|
73
|
-
|
79
|
+
|
80
|
+
process.exit()
|
74
81
|
}
|
75
82
|
|
76
|
-
/*
|
83
|
+
/*
|
77
84
|
* exit events hint from https://stackoverflow.com/a/14032965/14539284
|
78
85
|
*/
|
79
86
|
|
80
87
|
//do something when app is closing
|
81
|
-
process.on('exit', exitHandler.bind(null, { name: 'exit', exit: true }
|
88
|
+
process.on('exit', exitHandler.bind(null, { name: 'exit', exit: true }))
|
82
89
|
|
83
90
|
//catches ctrl+c event
|
84
|
-
process.on('SIGINT', exitHandler.bind(null, { name: 'SIGINT', exit: true }
|
91
|
+
process.on('SIGINT', exitHandler.bind(null, { name: 'SIGINT', exit: true }))
|
85
92
|
|
86
93
|
// catches "kill pid" (for example: nodemon restart)
|
87
|
-
process.on('SIGUSR1', exitHandler.bind(null, { name: 'SIGUSR1', exit: true }
|
88
|
-
process.on('SIGUSR2', exitHandler.bind(null, { name: 'SIGUSR2', exit: true }
|
94
|
+
process.on('SIGUSR1', exitHandler.bind(null, { name: 'SIGUSR1', exit: true }))
|
95
|
+
process.on('SIGUSR2', exitHandler.bind(null, { name: 'SIGUSR2', exit: true }))
|
89
96
|
|
90
97
|
//catches uncaught exceptions
|
91
|
-
process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }
|
98
|
+
process.on('uncaughtException', exitHandler.bind(null, { name: 'uncaughtException', exit: true }))
|
92
99
|
|
93
100
|
export { pubsub }
|