@conduitplatform/grpc-sdk 0.15.17 → 0.15.19
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/ConduitActiveSchema.js +25 -43
- package/dist/classes/ConduitActiveSchema.js.map +1 -1
- package/dist/classes/ConduitAuthorizedResource.js +5 -6
- package/dist/classes/ConduitAuthorizedResource.js.map +1 -1
- package/dist/classes/ConduitModule.js +44 -138
- 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/ConduitServiceModule.js +39 -98
- package/dist/classes/ConduitServiceModule.js.map +1 -1
- package/dist/classes/ConfigController.js +10 -17
- package/dist/classes/ConfigController.js.map +1 -1
- package/dist/classes/Error.js +17 -40
- package/dist/classes/Error.js.map +1 -1
- package/dist/classes/GrpcServer.js +88 -172
- package/dist/classes/GrpcServer.js.map +1 -1
- package/dist/classes/HealthCheck.js +26 -72
- package/dist/classes/HealthCheck.js.map +1 -1
- package/dist/classes/ManagedModule.js +93 -245
- package/dist/classes/ManagedModule.js.map +1 -1
- package/dist/classes/ModuleManager.js +51 -149
- package/dist/classes/ModuleManager.js.map +1 -1
- package/dist/helpers/GrpcHelper.js +11 -11
- package/dist/helpers/GrpcHelper.js.map +1 -1
- package/dist/helpers/TypeHelpers.js +57 -119
- package/dist/helpers/TypeHelpers.js.map +1 -1
- package/dist/helpers/wrapGrpcFunctions.js +14 -15
- package/dist/helpers/wrapGrpcFunctions.js.map +1 -1
- package/dist/index.js +299 -467
- package/dist/index.js.map +1 -1
- package/dist/interceptors/grpcSignedToken.js +7 -79
- package/dist/interceptors/grpcSignedToken.js.map +1 -1
- package/dist/interceptors/moduleName.js +7 -79
- package/dist/interceptors/moduleName.js.map +1 -1
- package/dist/metrics/MetricsServer.js +25 -70
- package/dist/metrics/MetricsServer.js.map +1 -1
- package/dist/metrics/clientMiddleware.js +76 -217
- package/dist/metrics/clientMiddleware.js.map +1 -1
- package/dist/metrics/config/defaults.js +1 -1
- package/dist/metrics/config/defaults.js.map +1 -1
- package/dist/metrics/index.js +53 -89
- package/dist/metrics/index.js.map +1 -1
- package/dist/modules/admin/index.js +16 -34
- package/dist/modules/admin/index.js.map +1 -1
- package/dist/modules/authentication/index.js +20 -39
- package/dist/modules/authentication/index.js.map +1 -1
- package/dist/modules/authorization/index.js +29 -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.js +70 -175
- 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.js +80 -122
- 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/forms/index.js +8 -26
- package/dist/modules/forms/index.js.map +1 -1
- package/dist/modules/functions/index.js +8 -26
- package/dist/modules/functions/index.js.map +1 -1
- package/dist/modules/pushNotifications/index.js +38 -56
- package/dist/modules/pushNotifications/index.js.map +1 -1
- package/dist/modules/router/index.js +18 -36
- 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.js +17 -36
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/protoUtils/authentication.d.ts +1 -1
- package/dist/protoUtils/authentication.js +188 -169
- package/dist/protoUtils/authentication.js.map +1 -1
- package/dist/protoUtils/authorization.d.ts +1 -1
- package/dist/protoUtils/authorization.js +332 -391
- package/dist/protoUtils/authorization.js.map +1 -1
- package/dist/protoUtils/chat.d.ts +1 -1
- package/dist/protoUtils/chat.js +176 -212
- package/dist/protoUtils/chat.js.map +1 -1
- package/dist/protoUtils/core.d.ts +1 -1
- package/dist/protoUtils/core.js +643 -605
- package/dist/protoUtils/core.js.map +1 -1
- package/dist/protoUtils/database.d.ts +1 -1
- package/dist/protoUtils/database.js +563 -554
- package/dist/protoUtils/database.js.map +1 -1
- package/dist/protoUtils/email.d.ts +1 -1
- package/dist/protoUtils/email.js +180 -208
- package/dist/protoUtils/email.js.map +1 -1
- package/dist/protoUtils/forms.d.ts +1 -1
- package/dist/protoUtils/forms.js +37 -35
- package/dist/protoUtils/forms.js.map +1 -1
- package/dist/protoUtils/functions.d.ts +1 -1
- package/dist/protoUtils/functions.js +37 -35
- package/dist/protoUtils/functions.js.map +1 -1
- package/dist/protoUtils/grpc_health_check.d.ts +1 -1
- package/dist/protoUtils/grpc_health_check.js +36 -34
- package/dist/protoUtils/grpc_health_check.js.map +1 -1
- package/dist/protoUtils/push-notifications.d.ts +1 -1
- package/dist/protoUtils/push-notifications.js +252 -272
- package/dist/protoUtils/push-notifications.js.map +1 -1
- package/dist/protoUtils/router.d.ts +1 -1
- package/dist/protoUtils/router.js +381 -387
- package/dist/protoUtils/router.js.map +1 -1
- package/dist/protoUtils/sms.d.ts +1 -1
- package/dist/protoUtils/sms.js +155 -143
- package/dist/protoUtils/sms.js.map +1 -1
- package/dist/protoUtils/storage.d.ts +1 -1
- package/dist/protoUtils/storage.js +190 -164
- package/dist/protoUtils/storage.js.map +1 -1
- package/dist/routing/ConduitRouteReturn.js +9 -18
- package/dist/routing/ConduitRouteReturn.js.map +1 -1
- package/dist/routing/ProxyRouteBuilder.js +21 -24
- package/dist/routing/ProxyRouteBuilder.js.map +1 -1
- package/dist/routing/RouteBuilder.js +31 -34
- package/dist/routing/RouteBuilder.js.map +1 -1
- package/dist/routing/RoutingManager.js +65 -115
- package/dist/routing/RoutingManager.js.map +1 -1
- package/dist/routing/RoutingUtilities.js +3 -3
- package/dist/routing/RoutingUtilities.js.map +1 -1
- package/dist/routing/wrapRouterFunctions.js +25 -34
- package/dist/routing/wrapRouterFunctions.js.map +1 -1
- package/dist/types/index.js +6 -24
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/EventBus.js +16 -17
- package/dist/utilities/EventBus.js.map +1 -1
- package/dist/utilities/Logger.js +80 -180
- package/dist/utilities/Logger.js.map +1 -1
- package/dist/utilities/RedisManager.js +11 -21
- package/dist/utilities/RedisManager.js.map +1 -1
- package/dist/utilities/StateManager.js +13 -14
- package/dist/utilities/StateManager.js.map +1 -1
- package/dist/utilities/linearBackoffTimeout.js +28 -92
- package/dist/utilities/linearBackoffTimeout.js.map +1 -1
- package/dist/utilities/merge.js +2 -2
- package/dist/utilities/merge.js.map +1 -1
- package/dist/utilities/sleep.js +1 -1
- package/dist/utilities/sleep.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -24,67 +13,29 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
24
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
25
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
26
15
|
};
|
|
27
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
28
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
29
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
30
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
31
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
32
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
37
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
38
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
39
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
40
|
-
function step(op) {
|
|
41
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
42
|
-
while (_) try {
|
|
43
|
-
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;
|
|
44
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
45
|
-
switch (op[0]) {
|
|
46
|
-
case 0: case 1: t = op; break;
|
|
47
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
48
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
49
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
50
|
-
default:
|
|
51
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
52
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
53
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
54
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
55
|
-
if (t[2]) _.ops.pop();
|
|
56
|
-
_.trys.pop(); continue;
|
|
57
|
-
}
|
|
58
|
-
op = body.call(thisArg, _);
|
|
59
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
60
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
16
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
64
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
65
18
|
};
|
|
66
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (serviceHealthStatusGetter === void 0) { serviceHealthStatusGetter = function () { return types_1.HealthCheckStatus.SERVING; }; }
|
|
87
|
-
if (watchModules === void 0) { watchModules = true; }
|
|
20
|
+
const modules_1 = require("./modules");
|
|
21
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
22
|
+
const EventBus_1 = require("./utilities/EventBus");
|
|
23
|
+
const RedisManager_1 = require("./utilities/RedisManager");
|
|
24
|
+
const StateManager_1 = require("./utilities/StateManager");
|
|
25
|
+
const ConduitModule_1 = require("./classes/ConduitModule");
|
|
26
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
27
|
+
const utilities_1 = require("./utilities");
|
|
28
|
+
const grpc_health_check_1 = require("./protoUtils/grpc_health_check");
|
|
29
|
+
const types_1 = require("./types");
|
|
30
|
+
const fast_jwt_1 = require("fast-jwt");
|
|
31
|
+
const HealthCheck_1 = require("./classes/HealthCheck");
|
|
32
|
+
const Logger_1 = require("./utilities/Logger");
|
|
33
|
+
const winston_1 = __importDefault(require("winston"));
|
|
34
|
+
const path_1 = __importDefault(require("path"));
|
|
35
|
+
const metrics_1 = require("./metrics");
|
|
36
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
37
|
+
class ConduitGrpcSdk {
|
|
38
|
+
constructor(serverUrl, serviceHealthStatusGetter = () => types_1.HealthCheckStatus.SERVING, name, watchModules = true, urlRemap) {
|
|
88
39
|
this.urlRemap = urlRemap;
|
|
89
40
|
this._redisManager = null;
|
|
90
41
|
this._modules = {};
|
|
@@ -121,55 +72,37 @@ var ConduitGrpcSdk = /** @class */ (function () {
|
|
|
121
72
|
this._watchModules = watchModules;
|
|
122
73
|
this._serviceHealthStatusGetter = serviceHealthStatusGetter;
|
|
123
74
|
if (process.env.GRPC_KEY) {
|
|
124
|
-
|
|
75
|
+
const sign = (0, fast_jwt_1.createSigner)({ key: process.env.GRPC_KEY });
|
|
125
76
|
this._grpcToken = sign({
|
|
126
77
|
moduleName: this.name,
|
|
127
78
|
});
|
|
128
79
|
}
|
|
129
80
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!true) return [3 /*break*/, 7];
|
|
144
|
-
_a.label = 2;
|
|
145
|
-
case 2:
|
|
146
|
-
_a.trys.push([2, 4, , 6]);
|
|
147
|
-
return [4 /*yield*/, this.core.check()];
|
|
148
|
-
case 3:
|
|
149
|
-
state = _a.sent();
|
|
150
|
-
if (state === types_1.HealthCheckStatus.SERVING) {
|
|
151
|
-
ConduitGrpcSdk.Logger.log('Core connection established');
|
|
152
|
-
this._initialize();
|
|
153
|
-
return [3 /*break*/, 7];
|
|
154
|
-
}
|
|
155
|
-
return [3 /*break*/, 6];
|
|
156
|
-
case 4:
|
|
157
|
-
err_1 = _a.sent();
|
|
158
|
-
if (err_1.code === grpc_js_1.status.PERMISSION_DENIED) {
|
|
159
|
-
ConduitGrpcSdk.Logger.error(err_1);
|
|
160
|
-
process.exit(-1);
|
|
161
|
-
}
|
|
162
|
-
return [4 /*yield*/, (0, utilities_1.sleep)(1000)];
|
|
163
|
-
case 5:
|
|
164
|
-
_a.sent();
|
|
165
|
-
return [3 /*break*/, 6];
|
|
166
|
-
case 6: return [3 /*break*/, 1];
|
|
167
|
-
case 7: return [2 /*return*/];
|
|
81
|
+
async initialize() {
|
|
82
|
+
if (this.name === 'core') {
|
|
83
|
+
return this._initialize();
|
|
84
|
+
}
|
|
85
|
+
this._core = new modules_1.Core(this.name, this.serverUrl, this._grpcToken);
|
|
86
|
+
ConduitGrpcSdk.Logger.log('Waiting for Core...');
|
|
87
|
+
while (true) {
|
|
88
|
+
try {
|
|
89
|
+
const state = await this.core.check();
|
|
90
|
+
if (state === types_1.HealthCheckStatus.SERVING) {
|
|
91
|
+
ConduitGrpcSdk.Logger.log('Core connection established');
|
|
92
|
+
this._initialize();
|
|
93
|
+
break;
|
|
168
94
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
if (err.code === grpc_js_1.status.PERMISSION_DENIED) {
|
|
98
|
+
ConduitGrpcSdk.Logger.error(err);
|
|
99
|
+
process.exit(-1);
|
|
100
|
+
}
|
|
101
|
+
await (0, utilities_1.sleep)(1000);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
_initialize() {
|
|
173
106
|
if (this._initialized)
|
|
174
107
|
throw new Error("Module's grpc-sdk has already been initialized");
|
|
175
108
|
this._config = new modules_1.Config(this.name, this.serverUrl, this._serviceHealthStatusGetter, this._grpcToken);
|
|
@@ -181,275 +114,199 @@ var ConduitGrpcSdk = /** @class */ (function () {
|
|
|
181
114
|
this.watchModules();
|
|
182
115
|
}
|
|
183
116
|
this._initialized = true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
return
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
return null;
|
|
325
|
-
}
|
|
326
|
-
},
|
|
327
|
-
enumerable: false,
|
|
328
|
-
configurable: true
|
|
329
|
-
});
|
|
330
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "authorization", {
|
|
331
|
-
get: function () {
|
|
332
|
-
if (this._modules['authorization']) {
|
|
333
|
-
return this._modules['authorization'];
|
|
334
|
-
}
|
|
335
|
-
else {
|
|
336
|
-
ConduitGrpcSdk.Logger.warn('Authorization module not up yet!');
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
},
|
|
340
|
-
enumerable: false,
|
|
341
|
-
configurable: true
|
|
342
|
-
});
|
|
343
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "sms", {
|
|
344
|
-
get: function () {
|
|
345
|
-
if (this._modules['sms']) {
|
|
346
|
-
return this._modules['sms'];
|
|
347
|
-
}
|
|
348
|
-
else {
|
|
349
|
-
ConduitGrpcSdk.Logger.warn('SMS module not up yet!');
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
},
|
|
353
|
-
enumerable: false,
|
|
354
|
-
configurable: true
|
|
355
|
-
});
|
|
356
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "chat", {
|
|
357
|
-
get: function () {
|
|
358
|
-
if (this._modules['chat']) {
|
|
359
|
-
return this._modules['chat'];
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
ConduitGrpcSdk.Logger.warn('Chat module not up yet!');
|
|
363
|
-
return null;
|
|
364
|
-
}
|
|
365
|
-
},
|
|
366
|
-
enumerable: false,
|
|
367
|
-
configurable: true
|
|
368
|
-
});
|
|
369
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "functions", {
|
|
370
|
-
get: function () {
|
|
371
|
-
if (this._modules['functions']) {
|
|
372
|
-
return this._modules['functions'];
|
|
373
|
-
}
|
|
374
|
-
else {
|
|
375
|
-
ConduitGrpcSdk.Logger.warn('Functions module not up yet!');
|
|
376
|
-
return null;
|
|
377
|
-
}
|
|
378
|
-
},
|
|
379
|
-
enumerable: false,
|
|
380
|
-
configurable: true
|
|
381
|
-
});
|
|
382
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "redisDetails", {
|
|
383
|
-
get: function () {
|
|
384
|
-
if (this._redisDetails) {
|
|
385
|
-
return this._redisDetails;
|
|
386
|
-
}
|
|
387
|
-
else {
|
|
388
|
-
throw new Error('Redis not available');
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
enumerable: false,
|
|
392
|
-
configurable: true
|
|
393
|
-
});
|
|
394
|
-
ConduitGrpcSdk.prototype.watchModules = function () {
|
|
395
|
-
var _this = this;
|
|
396
|
-
var emitter = this.config.getModuleWatcher();
|
|
117
|
+
}
|
|
118
|
+
get bus() {
|
|
119
|
+
if (this._eventBus) {
|
|
120
|
+
return this._eventBus;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
ConduitGrpcSdk.Logger.warn('Event bus not initialized');
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
get state() {
|
|
128
|
+
if (this._stateManager) {
|
|
129
|
+
return this._stateManager;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
ConduitGrpcSdk.Logger.warn('State Manager not initialized');
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
get core() {
|
|
137
|
+
return this._core;
|
|
138
|
+
}
|
|
139
|
+
get config() {
|
|
140
|
+
return this._config;
|
|
141
|
+
}
|
|
142
|
+
get admin() {
|
|
143
|
+
return this._admin;
|
|
144
|
+
}
|
|
145
|
+
get router() {
|
|
146
|
+
if (this._modules['router']) {
|
|
147
|
+
return this._modules['router'];
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
ConduitGrpcSdk.Logger.warn('Router not up yet!');
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
get database() {
|
|
155
|
+
if (this._modules['database']) {
|
|
156
|
+
return this._modules['database'];
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
ConduitGrpcSdk.Logger.warn('Database provider not up yet!');
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
get databaseProvider() {
|
|
164
|
+
return this.database;
|
|
165
|
+
}
|
|
166
|
+
get storage() {
|
|
167
|
+
if (this._modules['storage']) {
|
|
168
|
+
return this._modules['storage'];
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
ConduitGrpcSdk.Logger.warn('Storage module not up yet!');
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
get forms() {
|
|
176
|
+
if (this._modules['forms']) {
|
|
177
|
+
return this._modules['forms'];
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
ConduitGrpcSdk.Logger.warn('Forms module not up yet!');
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
get emailProvider() {
|
|
185
|
+
if (this._modules['email']) {
|
|
186
|
+
return this._modules['email'];
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
ConduitGrpcSdk.Logger.warn('Email provider not up yet!');
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
get pushNotifications() {
|
|
194
|
+
if (this._modules['pushNotifications']) {
|
|
195
|
+
return this._modules['pushNotifications'];
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
ConduitGrpcSdk.Logger.warn('Push notifications module not up yet!');
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
get authentication() {
|
|
203
|
+
if (this._modules['authentication']) {
|
|
204
|
+
return this._modules['authentication'];
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
ConduitGrpcSdk.Logger.warn('Authentication module not up yet!');
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
get authorization() {
|
|
212
|
+
if (this._modules['authorization']) {
|
|
213
|
+
return this._modules['authorization'];
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
ConduitGrpcSdk.Logger.warn('Authorization module not up yet!');
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
get sms() {
|
|
221
|
+
if (this._modules['sms']) {
|
|
222
|
+
return this._modules['sms'];
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
ConduitGrpcSdk.Logger.warn('SMS module not up yet!');
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
get chat() {
|
|
230
|
+
if (this._modules['chat']) {
|
|
231
|
+
return this._modules['chat'];
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
ConduitGrpcSdk.Logger.warn('Chat module not up yet!');
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
get functions() {
|
|
239
|
+
if (this._modules['functions']) {
|
|
240
|
+
return this._modules['functions'];
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
ConduitGrpcSdk.Logger.warn('Functions module not up yet!');
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
get redisDetails() {
|
|
248
|
+
if (this._redisDetails) {
|
|
249
|
+
return this._redisDetails;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
throw new Error('Redis not available');
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
watchModules() {
|
|
256
|
+
const emitter = this.config.getModuleWatcher();
|
|
397
257
|
this.config.watchModules().then();
|
|
398
|
-
emitter.on('serving-modules-update',
|
|
399
|
-
Object.keys(
|
|
258
|
+
emitter.on('serving-modules-update', (modules) => {
|
|
259
|
+
Object.keys(this._modules).forEach(r => {
|
|
400
260
|
var _a;
|
|
401
|
-
if (r !==
|
|
402
|
-
|
|
403
|
-
if ((!found || found.length === 0) &&
|
|
404
|
-
(_a =
|
|
405
|
-
emitter.emit(
|
|
261
|
+
if (r !== this.name) {
|
|
262
|
+
const found = modules.filter((m) => m.moduleName === r && m.serving);
|
|
263
|
+
if ((!found || found.length === 0) && this._modules[r]) {
|
|
264
|
+
(_a = this._modules[r]) === null || _a === void 0 ? void 0 : _a.closeConnection();
|
|
265
|
+
emitter.emit(`module-connection-update:${r}`, false);
|
|
406
266
|
}
|
|
407
267
|
}
|
|
408
268
|
});
|
|
409
|
-
modules.forEach(
|
|
269
|
+
modules.forEach((m) => {
|
|
410
270
|
var _a;
|
|
411
|
-
if (m.moduleName !==
|
|
412
|
-
|
|
271
|
+
if (m.moduleName !== this.name) {
|
|
272
|
+
const alreadyActive = (_a = this._modules[m.moduleName]) === null || _a === void 0 ? void 0 : _a.active;
|
|
413
273
|
if (!alreadyActive && m.serving) {
|
|
414
|
-
if (
|
|
415
|
-
|
|
274
|
+
if (this._availableModules[m.moduleName] && this._modules[m.moduleName]) {
|
|
275
|
+
this._modules[m.moduleName].openConnection();
|
|
416
276
|
}
|
|
417
277
|
else {
|
|
418
|
-
|
|
278
|
+
this.createModuleClient(m.moduleName, m.url);
|
|
419
279
|
}
|
|
420
|
-
emitter.emit(
|
|
280
|
+
emitter.emit(`module-connection-update:${m.moduleName}`, true);
|
|
421
281
|
}
|
|
422
282
|
}
|
|
423
283
|
});
|
|
424
284
|
});
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
if (wait === void 0) { wait = true; }
|
|
429
|
-
var waitPromise = wait ? this.waitForExistence(moduleName) : Promise.resolve();
|
|
285
|
+
}
|
|
286
|
+
monitorModule(moduleName, callback, wait = true) {
|
|
287
|
+
const waitPromise = wait ? this.waitForExistence(moduleName) : Promise.resolve();
|
|
430
288
|
waitPromise
|
|
431
|
-
.then(
|
|
432
|
-
.then(
|
|
289
|
+
.then(() => { var _a, _b; return (_b = (_a = this._modules[moduleName]) === null || _a === void 0 ? void 0 : _a.healthClient) === null || _b === void 0 ? void 0 : _b.check({}); })
|
|
290
|
+
.then(res => {
|
|
433
291
|
callback((res === null || res === void 0 ? void 0 : res.status) === grpc_health_check_1.HealthCheckResponse_ServingStatus.SERVING);
|
|
434
292
|
})
|
|
435
|
-
.catch(
|
|
293
|
+
.catch(() => {
|
|
436
294
|
callback(false);
|
|
437
295
|
})
|
|
438
|
-
.then(
|
|
439
|
-
|
|
440
|
-
emitter.on(
|
|
296
|
+
.then(() => {
|
|
297
|
+
const emitter = this.config.getModuleWatcher();
|
|
298
|
+
emitter.on(`module-connection-update:${moduleName}`, callback);
|
|
441
299
|
});
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
emitter.removeAllListeners(
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
var promise = Promise.resolve();
|
|
300
|
+
}
|
|
301
|
+
unmonitorModule(moduleName) {
|
|
302
|
+
const emitter = this.config.getModuleWatcher();
|
|
303
|
+
emitter.removeAllListeners(`module-connection-update:${moduleName}`);
|
|
304
|
+
}
|
|
305
|
+
initializeEventBus() {
|
|
306
|
+
let promise = Promise.resolve();
|
|
450
307
|
if (process.env.REDIS_CONFIG) {
|
|
451
|
-
|
|
452
|
-
|
|
308
|
+
const redisConfig = process.env.REDIS_CONFIG;
|
|
309
|
+
let redisJson;
|
|
453
310
|
if (redisConfig.startsWith('{')) {
|
|
454
311
|
try {
|
|
455
312
|
redisJson = JSON.parse(redisConfig);
|
|
@@ -480,13 +337,13 @@ var ConduitGrpcSdk = /** @class */ (function () {
|
|
|
480
337
|
}
|
|
481
338
|
else {
|
|
482
339
|
promise = promise
|
|
483
|
-
.then(
|
|
484
|
-
.then(
|
|
340
|
+
.then(() => this.config.getRedisDetails())
|
|
341
|
+
.then((r) => {
|
|
485
342
|
if (r.redisConfig) {
|
|
486
|
-
|
|
343
|
+
this._redisDetails = JSON.parse(r.redisConfig);
|
|
487
344
|
}
|
|
488
345
|
else {
|
|
489
|
-
|
|
346
|
+
this._redisDetails = {
|
|
490
347
|
host: r.redisHost,
|
|
491
348
|
port: r.redisPort,
|
|
492
349
|
username: r.redisUsername,
|
|
@@ -496,155 +353,130 @@ var ConduitGrpcSdk = /** @class */ (function () {
|
|
|
496
353
|
});
|
|
497
354
|
}
|
|
498
355
|
return promise
|
|
499
|
-
.then(
|
|
356
|
+
.then(() => {
|
|
500
357
|
var _a;
|
|
501
|
-
if (
|
|
502
|
-
|
|
358
|
+
if (this._redisDetails.hasOwnProperty('nodes')) {
|
|
359
|
+
this._redisManager = new RedisManager_1.RedisManager(this._redisDetails);
|
|
503
360
|
}
|
|
504
361
|
else {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
362
|
+
const redisHost = (_a = this.urlRemap) !== null && _a !== void 0 ? _a : this._redisDetails.host;
|
|
363
|
+
this._redisManager = new RedisManager_1.RedisManager({
|
|
364
|
+
...this._redisDetails,
|
|
365
|
+
host: redisHost,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
this._eventBus = new EventBus_1.EventBus(this._redisManager);
|
|
369
|
+
this._stateManager = new StateManager_1.StateManager(this._redisManager, this.name);
|
|
370
|
+
return this._eventBus;
|
|
511
371
|
})
|
|
512
|
-
.catch(
|
|
372
|
+
.catch((err) => {
|
|
513
373
|
ConduitGrpcSdk.Logger.error('Failed to initialize event bus');
|
|
514
374
|
throw err;
|
|
515
375
|
});
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
},
|
|
526
|
-
enumerable: false,
|
|
527
|
-
configurable: true
|
|
528
|
-
});
|
|
376
|
+
}
|
|
377
|
+
get redisManager() {
|
|
378
|
+
if (this._redisManager) {
|
|
379
|
+
return this._redisManager;
|
|
380
|
+
}
|
|
381
|
+
else {
|
|
382
|
+
throw new Error('Redis not available');
|
|
383
|
+
}
|
|
384
|
+
}
|
|
529
385
|
/**
|
|
530
386
|
* Gets all the registered modules from the config and creates clients for them.
|
|
531
387
|
* This will only work on known modules, since the primary usage for the sdk is internal
|
|
532
388
|
*/
|
|
533
|
-
|
|
534
|
-
var _this = this;
|
|
389
|
+
initializeModules() {
|
|
535
390
|
return this._config.moduleList()
|
|
536
|
-
.then(
|
|
537
|
-
|
|
538
|
-
r.forEach(
|
|
539
|
-
|
|
391
|
+
.then(r => {
|
|
392
|
+
this.lastSearch = Date.now();
|
|
393
|
+
r.forEach(m => {
|
|
394
|
+
this.createModuleClient(m.moduleName, m.url);
|
|
540
395
|
});
|
|
541
396
|
return 'ok';
|
|
542
397
|
})
|
|
543
|
-
.catch(
|
|
398
|
+
.catch(err => {
|
|
544
399
|
if (err.code !== 5) {
|
|
545
400
|
ConduitGrpcSdk.Logger.error(err);
|
|
546
401
|
}
|
|
547
402
|
});
|
|
548
|
-
}
|
|
549
|
-
|
|
403
|
+
}
|
|
404
|
+
createModuleClient(moduleName, moduleUrl) {
|
|
550
405
|
if (this._modules[moduleName] ||
|
|
551
406
|
(!this._availableModules[moduleName] && !this._dynamicModules[moduleName]))
|
|
552
407
|
return;
|
|
553
408
|
if (this._availableModules[moduleName]) {
|
|
554
409
|
// ConduitGrpcSdk.Logger.log(`Creating gRPC client for ${moduleName}`);
|
|
555
|
-
this._modules[moduleName] = new this._availableModules[moduleName](this.name, this.urlRemap ?
|
|
410
|
+
this._modules[moduleName] = new this._availableModules[moduleName](this.name, this.urlRemap ? `${this.urlRemap}:${moduleUrl.split(':')[1]}` : moduleUrl, this._grpcToken);
|
|
556
411
|
}
|
|
557
412
|
else if (this._dynamicModules[moduleName]) {
|
|
558
413
|
// ConduitGrpcSdk.Logger.log(`Creating gRPC client for ${moduleName}`);
|
|
559
|
-
this._modules[moduleName] = new ConduitModule_1.ConduitModule(this.name, moduleName, this.urlRemap ?
|
|
414
|
+
this._modules[moduleName] = new ConduitModule_1.ConduitModule(this.name, moduleName, this.urlRemap ? `${this.urlRemap}:${moduleUrl.split(':')[1]}` : moduleUrl, this._grpcToken);
|
|
560
415
|
this._modules[moduleName].initializeClient(this._dynamicModules[moduleName]);
|
|
561
416
|
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
if (service === void 0) { service = ''; }
|
|
417
|
+
}
|
|
418
|
+
isModuleUp(moduleName, moduleUrl, service = '') {
|
|
565
419
|
return (0, HealthCheck_1.checkModuleHealth)(moduleName, moduleUrl, service, this._grpcToken);
|
|
566
|
-
}
|
|
567
|
-
|
|
420
|
+
}
|
|
421
|
+
moduleClient(name, type) {
|
|
568
422
|
this._dynamicModules[name] = type;
|
|
569
|
-
}
|
|
570
|
-
|
|
423
|
+
}
|
|
424
|
+
getModule(name) {
|
|
571
425
|
return this._modules[name];
|
|
572
|
-
}
|
|
573
|
-
|
|
426
|
+
}
|
|
427
|
+
getServiceClient(name) {
|
|
574
428
|
var _a;
|
|
575
429
|
return (_a = this._modules[name]) === null || _a === void 0 ? void 0 : _a.client;
|
|
576
|
-
}
|
|
577
|
-
|
|
430
|
+
}
|
|
431
|
+
getHealthClient(name) {
|
|
578
432
|
var _a;
|
|
579
433
|
return (_a = this._modules[name]) === null || _a === void 0 ? void 0 : _a.healthClient;
|
|
580
|
-
}
|
|
581
|
-
|
|
434
|
+
}
|
|
435
|
+
isAvailable(moduleName) {
|
|
582
436
|
var _a;
|
|
583
437
|
return !!((_a = this._modules[moduleName]) === null || _a === void 0 ? void 0 : _a.active);
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
case 1:
|
|
593
|
-
_a.sent();
|
|
594
|
-
return [3 /*break*/, 0];
|
|
595
|
-
case 2: return [2 /*return*/, true];
|
|
596
|
-
}
|
|
597
|
-
});
|
|
598
|
-
});
|
|
599
|
-
};
|
|
600
|
-
ConduitGrpcSdk.prototype.onceModuleUp = function (moduleName, callback) {
|
|
438
|
+
}
|
|
439
|
+
async waitForExistence(moduleName) {
|
|
440
|
+
while (!this._modules[moduleName]) {
|
|
441
|
+
await (0, utilities_1.sleep)(1000);
|
|
442
|
+
}
|
|
443
|
+
return true;
|
|
444
|
+
}
|
|
445
|
+
onceModuleUp(moduleName, callback) {
|
|
601
446
|
if (this.isAvailable(moduleName))
|
|
602
447
|
callback();
|
|
603
|
-
|
|
604
|
-
emitter.once(
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
emitter.once("module-connection-update:".concat(moduleName), function (serving) {
|
|
611
|
-
return serving ? null : callback();
|
|
612
|
-
});
|
|
613
|
-
};
|
|
448
|
+
const emitter = this.config.getModuleWatcher();
|
|
449
|
+
emitter.once(`module-connection-update:${moduleName}`, (serving) => serving ? callback() : null);
|
|
450
|
+
}
|
|
451
|
+
onceModuleDown(moduleName, callback) {
|
|
452
|
+
const emitter = this.config.getModuleWatcher();
|
|
453
|
+
emitter.once(`module-connection-update:${moduleName}`, (serving) => serving ? null : callback());
|
|
454
|
+
}
|
|
614
455
|
/**
|
|
615
456
|
* Used to refresh all modules to check for new registrations
|
|
616
457
|
* @param force If true will check for new modules no matter the interval
|
|
617
458
|
*/
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
return
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
Object.defineProperty(ConduitGrpcSdk.prototype, "grpcToken", {
|
|
629
|
-
get: function () {
|
|
630
|
-
return this._grpcToken;
|
|
631
|
-
},
|
|
632
|
-
enumerable: false,
|
|
633
|
-
configurable: true
|
|
634
|
-
});
|
|
635
|
-
ConduitGrpcSdk.Logger = new Logger_1.ConduitLogger([
|
|
636
|
-
new winston_1.default.transports.File({
|
|
637
|
-
filename: path_1.default.join(__dirname, '.logs/combined.log'),
|
|
638
|
-
level: 'info',
|
|
639
|
-
}),
|
|
640
|
-
new winston_1.default.transports.File({
|
|
641
|
-
filename: path_1.default.join(__dirname, '.logs/errors.log'),
|
|
642
|
-
level: 'error',
|
|
643
|
-
}),
|
|
644
|
-
]);
|
|
645
|
-
return ConduitGrpcSdk;
|
|
646
|
-
}());
|
|
459
|
+
async refreshModules(force) {
|
|
460
|
+
if (this.lastSearch < Date.now() - 3000 || force) {
|
|
461
|
+
return this.initializeModules();
|
|
462
|
+
}
|
|
463
|
+
return 'ok';
|
|
464
|
+
}
|
|
465
|
+
get grpcToken() {
|
|
466
|
+
return this._grpcToken;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
647
469
|
exports.default = ConduitGrpcSdk;
|
|
470
|
+
ConduitGrpcSdk.Logger = new Logger_1.ConduitLogger([
|
|
471
|
+
new winston_1.default.transports.File({
|
|
472
|
+
filename: path_1.default.join(__dirname, '.logs/combined.log'),
|
|
473
|
+
level: 'info',
|
|
474
|
+
}),
|
|
475
|
+
new winston_1.default.transports.File({
|
|
476
|
+
filename: path_1.default.join(__dirname, '.logs/errors.log'),
|
|
477
|
+
level: 'error',
|
|
478
|
+
}),
|
|
479
|
+
]);
|
|
648
480
|
__exportStar(require("./interfaces"), exports);
|
|
649
481
|
__exportStar(require("./classes"), exports);
|
|
650
482
|
__exportStar(require("./modules"), exports);
|