@conduitplatform/grpc-sdk 0.16.0-alpha.9 → 0.16.0-rc.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.
- package/dist/classes/ConduitAuthorizedResource.js +5 -6
- package/dist/classes/ConduitAuthorizedResource.js.map +1 -1
- package/dist/classes/ConduitModule.js +59 -162
- package/dist/classes/ConduitModule.js.map +1 -1
- package/dist/classes/ConduitSchema.js +3 -4
- package/dist/classes/ConduitSchema.js.map +1 -1
- package/dist/classes/Error.js +17 -40
- package/dist/classes/Error.js.map +1 -1
- package/dist/classes/HealthCheck.js +28 -96
- package/dist/classes/HealthCheck.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +300 -462
- package/dist/index.js.map +1 -1
- package/dist/interceptors/grpcSignedToken.d.ts +1 -1
- package/dist/interceptors/grpcSignedToken.js +7 -79
- package/dist/interceptors/grpcSignedToken.js.map +1 -1
- package/dist/interceptors/moduleName.d.ts +1 -1
- package/dist/interceptors/moduleName.js +7 -79
- package/dist/interceptors/moduleName.js.map +1 -1
- package/dist/interfaces/ConduitRouteReturn.js +9 -18
- package/dist/interfaces/ConduitRouteReturn.js.map +1 -1
- package/dist/interfaces/GrpcCallback.d.ts +1 -1
- package/dist/interfaces/Indexable.d.ts +7 -7
- package/dist/interfaces/Model.d.ts +19 -16
- package/dist/interfaces/Params.d.ts +3 -3
- package/dist/interfaces/RawQuery.d.ts +2 -2
- package/dist/interfaces/Route.d.ts +12 -9
- package/dist/interfaces/Route.js.map +1 -1
- package/dist/interfaces/Socket.d.ts +1 -1
- package/dist/interfaces/UntypedArray.d.ts +1 -1
- package/dist/interfaces/types.d.ts +6 -6
- package/dist/module.proto +58 -0
- package/dist/modules/admin/index.d.ts +2 -3
- package/dist/modules/admin/index.js +13 -39
- package/dist/modules/admin/index.js.map +1 -1
- package/dist/modules/authentication/index.d.ts +6 -2
- package/dist/modules/authentication/index.js +33 -40
- package/dist/modules/authentication/index.js.map +1 -1
- package/dist/modules/authorization/index.d.ts +4 -1
- package/dist/modules/authorization/index.js +38 -47
- package/dist/modules/authorization/index.js.map +1 -1
- package/dist/modules/chat/index.js +16 -34
- package/dist/modules/chat/index.js.map +1 -1
- package/dist/modules/config/index.d.ts +10 -1
- package/dist/modules/config/index.js +82 -177
- package/dist/modules/config/index.js.map +1 -1
- package/dist/modules/core/index.js +8 -26
- package/dist/modules/core/index.js.map +1 -1
- package/dist/modules/database/index.d.ts +19 -10
- package/dist/modules/database/index.js +184 -125
- package/dist/modules/database/index.js.map +1 -1
- package/dist/modules/email/index.js +15 -33
- package/dist/modules/email/index.js.map +1 -1
- package/dist/modules/pushNotifications/index.d.ts +4 -4
- package/dist/modules/pushNotifications/index.js +38 -60
- package/dist/modules/pushNotifications/index.js.map +1 -1
- package/dist/modules/router/index.d.ts +2 -3
- package/dist/modules/router/index.js +15 -41
- package/dist/modules/router/index.js.map +1 -1
- package/dist/modules/sms/index.js +17 -35
- package/dist/modules/sms/index.js.map +1 -1
- package/dist/modules/storage/index.d.ts +7 -7
- package/dist/modules/storage/index.js +64 -55
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/protoUtils/authentication.d.ts +200 -4
- package/dist/protoUtils/authentication.js +789 -194
- package/dist/protoUtils/authentication.js.map +1 -1
- package/dist/protoUtils/authorization.d.ts +155 -5
- package/dist/protoUtils/authorization.js +860 -447
- package/dist/protoUtils/authorization.js.map +1 -1
- package/dist/protoUtils/chat.d.ts +18 -7
- package/dist/protoUtils/chat.js +210 -227
- package/dist/protoUtils/chat.js.map +1 -1
- package/dist/protoUtils/core.d.ts +55 -50
- package/dist/protoUtils/core.js +1018 -902
- package/dist/protoUtils/core.js.map +1 -1
- package/dist/protoUtils/database.d.ts +262 -16
- package/dist/protoUtils/database.js +1489 -832
- package/dist/protoUtils/database.js.map +1 -1
- package/dist/protoUtils/email.d.ts +13 -4
- package/dist/protoUtils/email.js +242 -253
- package/dist/protoUtils/email.js.map +1 -1
- package/dist/protoUtils/google/protobuf/empty.d.ts +4 -3
- package/dist/protoUtils/google/protobuf/empty.js +21 -38
- package/dist/protoUtils/google/protobuf/empty.js.map +1 -1
- package/dist/protoUtils/grpc_health_check.d.ts +10 -4
- package/dist/protoUtils/grpc_health_check.js +72 -83
- package/dist/protoUtils/grpc_health_check.js.map +1 -1
- package/dist/protoUtils/module.d.ts +202 -4
- package/dist/protoUtils/module.js +810 -72
- package/dist/protoUtils/module.js.map +1 -1
- package/dist/protoUtils/push-notifications.d.ts +26 -6
- package/dist/protoUtils/push-notifications.js +381 -317
- package/dist/protoUtils/push-notifications.js.map +1 -1
- package/dist/protoUtils/router.d.ts +18 -48
- package/dist/protoUtils/router.js +502 -560
- package/dist/protoUtils/router.js.map +1 -1
- package/dist/protoUtils/sms.d.ts +16 -4
- package/dist/protoUtils/sms.js +199 -175
- package/dist/protoUtils/sms.js.map +1 -1
- package/dist/protoUtils/storage.d.ts +37 -4
- package/dist/protoUtils/storage.js +639 -318
- package/dist/protoUtils/storage.js.map +1 -1
- package/dist/types/db.d.ts +13 -11
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +6 -24
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/EventBus.d.ts +3 -1
- package/dist/utilities/EventBus.js +38 -17
- package/dist/utilities/EventBus.js.map +1 -1
- package/dist/utilities/RedisManager.js +11 -21
- package/dist/utilities/RedisManager.js.map +1 -1
- package/dist/utilities/StateManager.d.ts +9 -0
- package/dist/utilities/StateManager.js +58 -15
- package/dist/utilities/StateManager.js.map +1 -1
- package/dist/utilities/env.js +4 -4
- package/dist/utilities/env.js.map +1 -1
- package/dist/utilities/sleep.js +1 -1
- package/dist/utilities/sleep.js.map +1 -1
- package/package.json +26 -19
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConduitAuthorizedResource = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ConduitAuthorizedResource {
|
|
5
|
+
constructor(name, relations, permissions) {
|
|
6
6
|
this.relations = [];
|
|
7
7
|
this.permissions = [];
|
|
8
8
|
this.name = name;
|
|
9
|
-
this.relations = Object.keys(relations).map(
|
|
9
|
+
this.relations = Object.keys(relations).map(relation => {
|
|
10
10
|
return {
|
|
11
11
|
name: relation,
|
|
12
12
|
resourceType: Array.isArray(relations[relation])
|
|
@@ -14,7 +14,7 @@ var ConduitAuthorizedResource = /** @class */ (function () {
|
|
|
14
14
|
: [relations[relation]],
|
|
15
15
|
};
|
|
16
16
|
});
|
|
17
|
-
this.permissions = Object.keys(permissions).map(
|
|
17
|
+
this.permissions = Object.keys(permissions).map(permission => {
|
|
18
18
|
return {
|
|
19
19
|
name: permission,
|
|
20
20
|
roles: Array.isArray(permissions[permission])
|
|
@@ -23,7 +23,6 @@ var ConduitAuthorizedResource = /** @class */ (function () {
|
|
|
23
23
|
};
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
|
|
27
|
-
}());
|
|
26
|
+
}
|
|
28
27
|
exports.ConduitAuthorizedResource = ConduitAuthorizedResource;
|
|
29
28
|
//# sourceMappingURL=ConduitAuthorizedResource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitAuthorizedResource.js","sourceRoot":"","sources":["../../src/classes/ConduitAuthorizedResource.ts"],"names":[],"mappings":";;;AAEA;
|
|
1
|
+
{"version":3,"file":"ConduitAuthorizedResource.js","sourceRoot":"","sources":["../../src/classes/ConduitAuthorizedResource.ts"],"names":[],"mappings":";;;AAEA,MAAa,yBAAyB;IAKpC,YACE,IAAY,EACZ,SAAiD,EACjD,WAAoD;QAN7C,cAAS,GAAwB,EAAE,CAAC;QACpC,gBAAW,GAA0B,EAAE,CAAC;QAO/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACrD,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;oBAC9C,CAAC,CAAE,SAAS,CAAC,QAAQ,CAAc;oBACnC,CAAC,CAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAc;aACxC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE;YAC3D,OAAO;gBACL,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;oBAC3C,CAAC,CAAE,WAAW,CAAC,UAAU,CAAc;oBACvC,CAAC,CAAE,CAAC,WAAW,CAAC,UAAU,CAAC,CAAc;aAC5C,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA5BD,8DA4BC"}
|
|
@@ -1,111 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
39
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
40
|
-
var m = o[Symbol.asyncIterator], i;
|
|
41
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
42
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
43
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
44
|
-
};
|
|
45
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
3
|
exports.ConduitModule = void 0;
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
4
|
+
const interceptors_1 = require("../interceptors");
|
|
5
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
6
|
+
const nice_grpc_client_middleware_retry_1 = require("nice-grpc-client-middleware-retry");
|
|
7
|
+
const grpc_health_check_1 = require("../protoUtils/grpc_health_check");
|
|
8
|
+
const events_1 = require("events");
|
|
9
|
+
const protoUtils_1 = require("../protoUtils");
|
|
10
|
+
class ConduitModule {
|
|
11
|
+
constructor(_clientName, _serviceName, _serviceUrl, _grpcToken) {
|
|
55
12
|
this._clientName = _clientName;
|
|
56
13
|
this._serviceName = _serviceName;
|
|
57
14
|
this._serviceUrl = _serviceUrl;
|
|
58
15
|
this._grpcToken = _grpcToken;
|
|
59
16
|
this.healthCheckEmitter = new events_1.EventEmitter();
|
|
60
17
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
});
|
|
82
|
-
Object.defineProperty(ConduitModule.prototype, "active", {
|
|
83
|
-
get: function () {
|
|
84
|
-
if (!this.channel) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
var connectivityState = this.channel.getConnectivityState(true);
|
|
88
|
-
return connectivityState === 2 || connectivityState === 1 || connectivityState === 0;
|
|
89
|
-
},
|
|
90
|
-
enumerable: false,
|
|
91
|
-
configurable: true
|
|
92
|
-
});
|
|
93
|
-
Object.defineProperty(ConduitModule.prototype, "healthCheckWatcher", {
|
|
94
|
-
get: function () {
|
|
95
|
-
return this.healthCheckEmitter;
|
|
96
|
-
},
|
|
97
|
-
enumerable: false,
|
|
98
|
-
configurable: true
|
|
99
|
-
});
|
|
100
|
-
ConduitModule.prototype.initializeClient = function (type) {
|
|
18
|
+
get client() {
|
|
19
|
+
return this._client;
|
|
20
|
+
}
|
|
21
|
+
get healthClient() {
|
|
22
|
+
return this._healthClient;
|
|
23
|
+
}
|
|
24
|
+
get moduleClient() {
|
|
25
|
+
return this._moduleClient;
|
|
26
|
+
}
|
|
27
|
+
get active() {
|
|
28
|
+
if (!this.channel) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const connectivityState = this.channel.getConnectivityState(true);
|
|
32
|
+
return connectivityState === 2 || connectivityState === 1 || connectivityState === 0;
|
|
33
|
+
}
|
|
34
|
+
get healthCheckWatcher() {
|
|
35
|
+
return this.healthCheckEmitter;
|
|
36
|
+
}
|
|
37
|
+
initializeClient(type) {
|
|
101
38
|
if (this._client)
|
|
102
39
|
return this._client;
|
|
103
40
|
this.type = type;
|
|
104
41
|
this.openConnection();
|
|
105
42
|
return this._client;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var _this = this;
|
|
43
|
+
}
|
|
44
|
+
openConnection() {
|
|
109
45
|
if (this.channel)
|
|
110
46
|
return;
|
|
111
47
|
// ConduitGrpcSdk.Logger.log(`Opening connection for ${this._serviceName}`);
|
|
@@ -113,7 +49,7 @@ var ConduitModule = /** @class */ (function () {
|
|
|
113
49
|
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
114
50
|
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
115
51
|
});
|
|
116
|
-
|
|
52
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)()
|
|
117
53
|
.use(this._grpcToken
|
|
118
54
|
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(this._grpcToken)
|
|
119
55
|
: (0, interceptors_1.getModuleNameInterceptor)(this._clientName))
|
|
@@ -129,85 +65,46 @@ var ConduitModule = /** @class */ (function () {
|
|
|
129
65
|
});
|
|
130
66
|
this._healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, this.channel);
|
|
131
67
|
this._moduleClient = clientFactory.create(protoUtils_1.ConduitModuleDefinition, this.channel);
|
|
132
|
-
|
|
133
|
-
if (!
|
|
68
|
+
const monitorChannel = () => {
|
|
69
|
+
if (!this.channel)
|
|
134
70
|
return;
|
|
135
71
|
try {
|
|
136
|
-
|
|
137
|
-
|
|
72
|
+
const state = this.channel.getConnectivityState(true);
|
|
73
|
+
this.channel.watchConnectivityState(state, Infinity, monitorChannel);
|
|
138
74
|
}
|
|
139
75
|
catch (e) { }
|
|
140
76
|
};
|
|
141
77
|
monitorChannel();
|
|
142
|
-
}
|
|
143
|
-
|
|
78
|
+
}
|
|
79
|
+
closeConnection() {
|
|
144
80
|
if (!this.channel)
|
|
145
81
|
return;
|
|
146
82
|
// ConduitGrpcSdk.Logger.warn(`Closing connection for ${this._serviceName}`);
|
|
147
83
|
this.channel.close();
|
|
148
84
|
this.channel = undefined;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
return this.healthClient.check({ service: service }).then(function (res) {
|
|
85
|
+
}
|
|
86
|
+
check(service = '') {
|
|
87
|
+
return this.healthClient.check({ service }).then((res) => {
|
|
153
88
|
return res.status;
|
|
154
89
|
});
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
_c.trys.push([2, 7, 8, 13]);
|
|
175
|
-
call_1 = __asyncValues(call);
|
|
176
|
-
_c.label = 3;
|
|
177
|
-
case 3: return [4 /*yield*/, call_1.next()];
|
|
178
|
-
case 4:
|
|
179
|
-
if (!(call_1_1 = _c.sent(), !call_1_1.done)) return [3 /*break*/, 6];
|
|
180
|
-
data = call_1_1.value;
|
|
181
|
-
self.healthCheckEmitter.emit("grpc-health-change:".concat(serviceName), data.status);
|
|
182
|
-
_c.label = 5;
|
|
183
|
-
case 5: return [3 /*break*/, 3];
|
|
184
|
-
case 6: return [3 /*break*/, 13];
|
|
185
|
-
case 7:
|
|
186
|
-
e_1_1 = _c.sent();
|
|
187
|
-
e_1 = { error: e_1_1 };
|
|
188
|
-
return [3 /*break*/, 13];
|
|
189
|
-
case 8:
|
|
190
|
-
_c.trys.push([8, , 11, 12]);
|
|
191
|
-
if (!(call_1_1 && !call_1_1.done && (_a = call_1.return))) return [3 /*break*/, 10];
|
|
192
|
-
return [4 /*yield*/, _a.call(call_1)];
|
|
193
|
-
case 9:
|
|
194
|
-
_c.sent();
|
|
195
|
-
_c.label = 10;
|
|
196
|
-
case 10: return [3 /*break*/, 12];
|
|
197
|
-
case 11:
|
|
198
|
-
if (e_1) throw e_1.error;
|
|
199
|
-
return [7 /*endfinally*/];
|
|
200
|
-
case 12: return [7 /*endfinally*/];
|
|
201
|
-
case 13: return [3 /*break*/, 15];
|
|
202
|
-
case 14:
|
|
203
|
-
error_1 = _c.sent();
|
|
204
|
-
return [3 /*break*/, 15];
|
|
205
|
-
case 15: return [2 /*return*/];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
};
|
|
210
|
-
return ConduitModule;
|
|
211
|
-
}());
|
|
90
|
+
}
|
|
91
|
+
async watch(service = '') {
|
|
92
|
+
var _a;
|
|
93
|
+
const self = this;
|
|
94
|
+
const serviceName = (_a = this.type) === null || _a === void 0 ? void 0 : _a.name;
|
|
95
|
+
this.healthCheckEmitter.setMaxListeners(150);
|
|
96
|
+
try {
|
|
97
|
+
const call = this.healthClient.watch({ service });
|
|
98
|
+
for await (const data of call) {
|
|
99
|
+
self.healthCheckEmitter.emit(`grpc-health-change:${serviceName}`, data.status);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// uncomment for debug when needed
|
|
104
|
+
// currently is misleading if left on
|
|
105
|
+
// ConduitGrpcSdk.Logger.warn('Connection to gRPC server closed');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
212
109
|
exports.ConduitModule = ConduitModule;
|
|
213
110
|
//# sourceMappingURL=ConduitModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitModule.js","sourceRoot":"","sources":["../../src/classes/ConduitModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConduitModule.js","sourceRoot":"","sources":["../../src/classes/ConduitModule.ts"],"names":[],"mappings":";;;AAAA,kDAA0F;AAE1F,yCAAgF;AAChF,yFAAoE;AACpE,uEAAwF;AACxF,mCAAsC;AACtC,8CAAwD;AAExD,MAAa,aAAa;IAMxB,YACW,WAAmB,EACX,YAAoB,EACpB,WAAmB,EACnB,UAAmB;QAH3B,gBAAW,GAAX,WAAW,CAAQ;QACX,iBAAY,GAAZ,YAAY,CAAQ;QACpB,gBAAW,GAAX,WAAW,CAAQ;QACnB,eAAU,GAAV,UAAU,CAAS;QANnB,uBAAkB,GAAG,IAAI,qBAAY,EAAE,CAAC;IAOxD,CAAC;IAIJ,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAID,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAID,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAClE,OAAO,iBAAiB,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,IAAO;QACtB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,OAAQ,CAAC;IACvB,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,4EAA4E;QAC5E,IAAI,CAAC,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE;YACxD,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;YACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;SAClD,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,+BAAmB,GAAE;aACxC,GAAG,CACF,IAAI,CAAC,UAAU;YACb,CAAC,CAAC,IAAA,4CAA6B,EAAC,IAAI,CAAC,UAAU,CAAC;YAChD,CAAC,CAAC,IAAA,uCAAwB,EAAC,IAAI,CAAC,WAAW,CAAC,CAC/C;aACA,GAAG,CAAC,mDAAe,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,OAAO,EAAE;YAC5D,GAAG,EAAE;gBACH,2DAA2D;gBAC3D,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;gBAC9B,gBAAgB,EAAE,GAAG;gBACrB,gBAAgB,EAAE,CAAC;gBACnB,KAAK,EAAE,IAAI;aACZ;SACF,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjF,MAAM,cAAc,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,OAAO;gBAAE,OAAO;YAC1B,IAAI;gBACF,MAAM,KAAK,GAAG,IAAI,CAAC,OAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;gBACvD,IAAI,CAAC,OAAQ,CAAC,sBAAsB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;aACvE;YAAC,OAAO,CAAC,EAAE,GAAE;QAChB,CAAC,CAAC;QACF,cAAc,EAAE,CAAC;IACnB,CAAC;IAED,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,6EAA6E;QAC7E,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,UAAkB,EAAE;QACxB,OAAO,IAAI,CAAC,YAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAwB,EAAE,EAAE;YAC7E,OAAO,GAAG,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,UAAkB,EAAE;;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI;YACF,MAAM,IAAI,GAAG,IAAI,CAAC,YAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YACnD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,EAAE;gBAC7B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,sBAAsB,WAAW,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;aAChF;SACF;QAAC,OAAO,KAAK,EAAE;YACd,kCAAkC;YAClC,qCAAqC;YACrC,kEAAkE;SACnE;IACH,CAAC;CACF;AAjHD,sCAiHC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConduitSchema = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ConduitSchema {
|
|
5
|
+
constructor(name, fields, modelOptions, collectionName) {
|
|
6
6
|
this.ownerModule = 'unknown';
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.fields = fields;
|
|
9
9
|
this.modelOptions = modelOptions !== null && modelOptions !== void 0 ? modelOptions : {};
|
|
10
10
|
this.collectionName = collectionName && collectionName !== '' ? collectionName : '';
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
}());
|
|
12
|
+
}
|
|
14
13
|
exports.ConduitSchema = ConduitSchema;
|
|
15
14
|
//# sourceMappingURL=ConduitSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitSchema.ts"],"names":[],"mappings":";;;AAEA;
|
|
1
|
+
{"version":3,"file":"ConduitSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitSchema.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAQxB,YACE,IAAY,EACZ,MAAoB,EACpB,YAAmC,EACnC,cAAuB;QAPzB,gBAAW,GAAW,SAAS,CAAC;QAS9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,cAAc,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,CAAC;CACF;AAnBD,sCAmBC"}
|
package/dist/classes/Error.js
CHANGED
|
@@ -1,51 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ConduitError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.status = status;
|
|
26
|
-
return _this;
|
|
4
|
+
class ConduitError extends Error {
|
|
5
|
+
constructor(name, status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.status = status;
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
if (message === void 0) { message = 'Unauthorized'; }
|
|
11
|
+
static unauthorized(message = 'Unauthorized') {
|
|
30
12
|
return new ConduitError('UNAUTHORIZED', 401, message);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (message === void 0) { message = 'Resource not found'; }
|
|
13
|
+
}
|
|
14
|
+
static notFound(message = 'Resource not found') {
|
|
34
15
|
return new ConduitError('NOT_FOUND', 404, message);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (message === void 0) { message = 'Forbidden'; }
|
|
16
|
+
}
|
|
17
|
+
static forbidden(message = 'Forbidden') {
|
|
38
18
|
return new ConduitError('FORBIDDEN', 403, message);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (message === void 0) { message = 'Request data are invalid'; }
|
|
19
|
+
}
|
|
20
|
+
static userInput(message = 'Request data are invalid') {
|
|
42
21
|
return new ConduitError('USER_INPUT_ERROR', 400, message);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (message === void 0) { message = 'Something went wrong'; }
|
|
22
|
+
}
|
|
23
|
+
static internalServerError(message = 'Something went wrong') {
|
|
46
24
|
throw new ConduitError('INTERNAL_SERVER_ERROR', 500, message);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}(Error));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
50
27
|
exports.ConduitError = ConduitError;
|
|
51
28
|
//# sourceMappingURL=Error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../src/classes/Error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../src/classes/Error.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IAKrC,YAAY,IAAY,EAAE,MAAc,EAAE,OAAe;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,UAAkB,cAAc;QAClD,OAAO,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,UAAkB,oBAAoB;QACpD,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,UAAkB,WAAW;QAC5C,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,UAAkB,0BAA0B;QAC3D,OAAO,IAAI,YAAY,CAAC,kBAAkB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,OAAO,GAAG,sBAAsB;QACzD,MAAM,IAAI,YAAY,CAAC,uBAAuB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF;AA/BD,oCA+BC"}
|
|
@@ -1,106 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __values = (this && this.__values) || function(o) {
|
|
39
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
-
if (m) return m.call(o);
|
|
41
|
-
if (o && typeof o.length === "number") return {
|
|
42
|
-
next: function () {
|
|
43
|
-
if (o && i >= o.length) o = void 0;
|
|
44
|
-
return { value: o && o[i++], done: !o };
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
-
};
|
|
49
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
4
|
};
|
|
52
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
6
|
exports.checkModuleHealth = void 0;
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
function checkModuleHealth(clientName, serviceUrl, service, grpcToken) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
var e_1, _c;
|
|
63
|
-
return __generator(this, function (_d) {
|
|
64
|
-
switch (_d.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
channel = (0, nice_grpc_1.createChannel)(serviceUrl, undefined, {
|
|
67
|
-
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
68
|
-
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
69
|
-
});
|
|
70
|
-
clientFactory = (0, nice_grpc_1.createClientFactory)();
|
|
71
|
-
try {
|
|
72
|
-
for (_a = __values(index_1.default.interceptors), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
73
|
-
interceptor = _b.value;
|
|
74
|
-
clientFactory.use(interceptor);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
78
|
-
finally {
|
|
79
|
-
try {
|
|
80
|
-
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
81
|
-
}
|
|
82
|
-
finally { if (e_1) throw e_1.error; }
|
|
83
|
-
}
|
|
84
|
-
clientFactory.use(grpcToken
|
|
85
|
-
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(grpcToken)
|
|
86
|
-
: (0, interceptors_1.getModuleNameInterceptor)(clientName));
|
|
87
|
-
_healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, channel);
|
|
88
|
-
return [4 /*yield*/, _healthClient
|
|
89
|
-
.check({ service: service })
|
|
90
|
-
.then(function (res) {
|
|
91
|
-
return res.status;
|
|
92
|
-
})
|
|
93
|
-
.catch(function (err) { return (error = err); })];
|
|
94
|
-
case 1:
|
|
95
|
-
status = _d.sent();
|
|
96
|
-
channel.close();
|
|
97
|
-
if (!error) {
|
|
98
|
-
return [2 /*return*/, status];
|
|
99
|
-
}
|
|
100
|
-
throw error;
|
|
101
|
-
}
|
|
102
|
-
});
|
|
7
|
+
const interceptors_1 = require("../interceptors");
|
|
8
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
9
|
+
const grpc_health_check_1 = require("../protoUtils/grpc_health_check");
|
|
10
|
+
const index_1 = __importDefault(require("../index"));
|
|
11
|
+
async function checkModuleHealth(clientName, serviceUrl, service = '', grpcToken) {
|
|
12
|
+
const channel = (0, nice_grpc_1.createChannel)(serviceUrl, undefined, {
|
|
13
|
+
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
14
|
+
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
103
15
|
});
|
|
16
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)();
|
|
17
|
+
for (const interceptor of index_1.default.interceptors) {
|
|
18
|
+
clientFactory.use(interceptor);
|
|
19
|
+
}
|
|
20
|
+
clientFactory.use(grpcToken
|
|
21
|
+
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(grpcToken)
|
|
22
|
+
: (0, interceptors_1.getModuleNameInterceptor)(clientName));
|
|
23
|
+
const _healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, channel);
|
|
24
|
+
let error;
|
|
25
|
+
const status = await _healthClient
|
|
26
|
+
.check({ service })
|
|
27
|
+
.then((res) => {
|
|
28
|
+
return res.status;
|
|
29
|
+
})
|
|
30
|
+
.catch(err => (error = err));
|
|
31
|
+
channel.close();
|
|
32
|
+
if (!error) {
|
|
33
|
+
return status;
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
104
36
|
}
|
|
105
37
|
exports.checkModuleHealth = checkModuleHealth;
|
|
106
38
|
//# sourceMappingURL=HealthCheck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HealthCheck.js","sourceRoot":"","sources":["../../src/classes/HealthCheck.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HealthCheck.js","sourceRoot":"","sources":["../../src/classes/HealthCheck.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0F;AAC1F,yCAA+D;AAC/D,uEAAwF;AACxF,qDAAsC;AAE/B,KAAK,UAAU,iBAAiB,CACrC,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAAE,EACpB,SAAkB;IAElB,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,UAAU,EAAE,SAAS,EAAE;QACnD,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;QACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;KAClD,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,IAAA,+BAAmB,GAAE,CAAC;IAC5C,KAAK,MAAM,WAAW,IAAI,eAAc,CAAC,YAAY,EAAE;QACrD,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KAChC;IACD,aAAa,CAAC,GAAG,CACf,SAAS;QACP,CAAC,CAAC,IAAA,4CAA6B,EAAC,SAAS,CAAC;QAC1C,CAAC,CAAC,IAAA,uCAAwB,EAAC,UAAU,CAAC,CACzC,CAAC;IACF,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAgB,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAI,KAAK,CAAC;IACV,MAAM,MAAM,GAAG,MAAM,aAAa;SAC/B,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;SAClB,IAAI,CAAC,CAAC,GAAwB,EAAE,EAAE;QACjC,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,MAAM,CAAC;KACf;IACD,MAAM,KAAK,CAAC;AACd,CAAC;AAjCD,8CAiCC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export default class ConduitGrpcSdk {
|
|
|
70
70
|
* This will only work on known modules, since the primary usage for the sdk is internal
|
|
71
71
|
*/
|
|
72
72
|
initializeModules(): Promise<string | void>;
|
|
73
|
+
updateModuleHealth(moduleName: string, serving: boolean): void;
|
|
73
74
|
createModuleClient(moduleName: string, moduleUrl: string): void;
|
|
74
75
|
isModuleUp(moduleName: string, moduleUrl: string, service?: string): Promise<any>;
|
|
75
76
|
moduleClient(name: string, type: CompatServiceDefinition): void;
|
|
@@ -78,7 +79,7 @@ export default class ConduitGrpcSdk {
|
|
|
78
79
|
getModuleClient(name: string): Client<ConduitModuleDefinition> | undefined;
|
|
79
80
|
getHealthClient<T extends CompatServiceDefinition>(name: string): Client<typeof HealthDefinition> | undefined;
|
|
80
81
|
isAvailable(moduleName: string): boolean;
|
|
81
|
-
waitForExistence(moduleName: string): Promise<
|
|
82
|
+
waitForExistence(moduleName: string, onlyIfServing?: boolean): Promise<unknown>;
|
|
82
83
|
onceModuleUp(moduleName: string, callback: () => void): void;
|
|
83
84
|
onceModuleDown(moduleName: string, callback: () => void): void;
|
|
84
85
|
/**
|