@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
|
@@ -1,19 +1,4 @@
|
|
|
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
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
3
|
if (k2 === undefined) k2 = k;
|
|
19
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -37,142 +22,76 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
37
22
|
__setModuleDefault(result, mod);
|
|
38
23
|
return result;
|
|
39
24
|
};
|
|
40
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while (_) try {
|
|
56
|
-
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;
|
|
57
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
-
switch (op[0]) {
|
|
59
|
-
case 0: case 1: t = op; break;
|
|
60
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
-
default:
|
|
64
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
-
if (t[2]) _.ops.pop();
|
|
69
|
-
_.trys.pop(); continue;
|
|
70
|
-
}
|
|
71
|
-
op = body.call(thisArg, _);
|
|
72
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
27
|
};
|
|
79
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
29
|
exports.ManagedModule = void 0;
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
30
|
+
const __1 = __importStar(require(".."));
|
|
31
|
+
const ConduitServiceModule_1 = require("./ConduitServiceModule");
|
|
32
|
+
const ConfigController_1 = require("./ConfigController");
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
const grpc_js_1 = require("@grpc/grpc-js");
|
|
35
|
+
const convict_1 = __importDefault(require("convict"));
|
|
36
|
+
class ManagedModule extends ConduitServiceModule_1.ConduitServiceModule {
|
|
37
|
+
constructor(moduleName) {
|
|
38
|
+
super(moduleName);
|
|
39
|
+
this.configOverride = false;
|
|
40
|
+
}
|
|
41
|
+
get name() {
|
|
42
|
+
return this._moduleName;
|
|
43
|
+
}
|
|
44
|
+
get address() {
|
|
45
|
+
return this._address;
|
|
93
46
|
}
|
|
94
|
-
Object.defineProperty(ManagedModule.prototype, "name", {
|
|
95
|
-
get: function () {
|
|
96
|
-
return this._moduleName;
|
|
97
|
-
},
|
|
98
|
-
enumerable: false,
|
|
99
|
-
configurable: true
|
|
100
|
-
});
|
|
101
|
-
Object.defineProperty(ManagedModule.prototype, "address", {
|
|
102
|
-
get: function () {
|
|
103
|
-
return this._address;
|
|
104
|
-
},
|
|
105
|
-
enumerable: false,
|
|
106
|
-
configurable: true
|
|
107
|
-
});
|
|
108
47
|
/**
|
|
109
48
|
* This is the first function triggered on module spin up.
|
|
110
49
|
* @param grpcSdk {ConduitGrpcSdk}
|
|
111
50
|
* @param address {string} external address:port of service (LoadBalancer)
|
|
112
51
|
* @param port {string} port to bring up gRPC service
|
|
113
52
|
*/
|
|
114
|
-
|
|
53
|
+
initialize(grpcSdk, address, port) {
|
|
115
54
|
this.grpcSdk = grpcSdk;
|
|
116
55
|
this._address = address;
|
|
117
56
|
this._port = port;
|
|
118
57
|
if (this.configSchema) {
|
|
119
58
|
this.config = (0, convict_1.default)(this.configSchema);
|
|
120
59
|
}
|
|
121
|
-
}
|
|
60
|
+
}
|
|
122
61
|
/**
|
|
123
62
|
* This is triggered before spinning up the Grpc Server
|
|
124
63
|
* of the module. On this stage, the redis bus and state have
|
|
125
64
|
* not yet been initialized, and only communications with Conduit core
|
|
126
65
|
* have been established.
|
|
127
66
|
*/
|
|
128
|
-
|
|
129
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
130
|
-
return [2 /*return*/];
|
|
131
|
-
}); });
|
|
132
|
-
};
|
|
67
|
+
async preServerStart() { }
|
|
133
68
|
/**
|
|
134
69
|
* This is triggered right after Grpc Server start.
|
|
135
70
|
* At this stage the core module will communicate with your service
|
|
136
71
|
* for health checks, and the Bus and State management mechanics
|
|
137
72
|
* are online and available.
|
|
138
73
|
*/
|
|
139
|
-
|
|
140
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
141
|
-
return [2 /*return*/];
|
|
142
|
-
}); });
|
|
143
|
-
};
|
|
74
|
+
async onServerStart() { }
|
|
144
75
|
/**
|
|
145
76
|
* Triggers right before registering the module with Conduit Core.
|
|
146
77
|
*/
|
|
147
|
-
|
|
148
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
149
|
-
return [2 /*return*/];
|
|
150
|
-
}); });
|
|
151
|
-
};
|
|
78
|
+
async preRegister() { }
|
|
152
79
|
/**
|
|
153
80
|
* Triggers when module has been registered with Conduit Core
|
|
154
81
|
* This is the step where you should initialize your
|
|
155
82
|
* module's general routing (admin or client) and any other operation,
|
|
156
83
|
* that would require other modules being able to reach you
|
|
157
84
|
*/
|
|
158
|
-
|
|
159
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
160
|
-
return [2 /*return*/];
|
|
161
|
-
}); });
|
|
162
|
-
};
|
|
85
|
+
async onRegister() { }
|
|
163
86
|
/**
|
|
164
87
|
* This is triggered when the module receives new configuration.
|
|
165
88
|
* At this step the configuration has not been checked yet,
|
|
166
89
|
* and has only been parsed.
|
|
167
90
|
* @param config
|
|
168
91
|
*/
|
|
169
|
-
|
|
170
|
-
return
|
|
171
|
-
|
|
172
|
-
return [2 /*return*/, config];
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
};
|
|
92
|
+
async preConfig(config) {
|
|
93
|
+
return config;
|
|
94
|
+
}
|
|
176
95
|
/**
|
|
177
96
|
* This is triggered when new configuration has been applied.
|
|
178
97
|
* This happens either when changes are being made on the configuration,
|
|
@@ -180,154 +99,83 @@ var ManagedModule = /** @class */ (function (_super) {
|
|
|
180
99
|
* In either case the configuration is now available through the
|
|
181
100
|
* Config Controller of the sdk.
|
|
182
101
|
*/
|
|
183
|
-
|
|
184
|
-
return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
185
|
-
return [2 /*return*/];
|
|
186
|
-
}); });
|
|
187
|
-
};
|
|
102
|
+
async onConfig() { }
|
|
188
103
|
/**
|
|
189
104
|
* Registers common and module-specific metric types.
|
|
190
105
|
*/
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}
|
|
202
|
-
return [2 /*return*/];
|
|
203
|
-
});
|
|
204
|
-
});
|
|
205
|
-
};
|
|
106
|
+
async registerMetrics() {
|
|
107
|
+
if (__1.default.Metrics) {
|
|
108
|
+
__1.default.Metrics.initializeDefaultMetrics();
|
|
109
|
+
if (this.metricsSchema) {
|
|
110
|
+
Object.values(this.metricsSchema).forEach(metric => {
|
|
111
|
+
__1.default.Metrics.registerMetric(metric.type, metric.config);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
206
116
|
/**
|
|
207
117
|
* Initializes metric startup values.
|
|
208
118
|
* Implemented by individual modules.
|
|
209
119
|
*/
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
_a._port = (_b.sent()).toString();
|
|
226
|
-
return [2 /*return*/];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
ManagedModule.prototype.startGrpcServer = function () {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
-
return __generator(this, function (_a) {
|
|
234
|
-
switch (_a.label) {
|
|
235
|
-
case 0:
|
|
236
|
-
if (!this.service) return [3 /*break*/, 4];
|
|
237
|
-
this._serviceName = this.service.protoDescription.substring(this.service.protoDescription.indexOf('.') + 1);
|
|
238
|
-
return [4 /*yield*/, this.grpcServer.addService(this.service.protoPath, this.service.protoDescription, this.service.functions)];
|
|
239
|
-
case 1:
|
|
240
|
-
_a.sent();
|
|
241
|
-
return [4 /*yield*/, this.addHealthCheckService()];
|
|
242
|
-
case 2:
|
|
243
|
-
_a.sent();
|
|
244
|
-
return [4 /*yield*/, this.grpcServer.start()];
|
|
245
|
-
case 3:
|
|
246
|
-
_a.sent();
|
|
247
|
-
__1.default.Logger.log('gRPC server listening on ' + this._port);
|
|
248
|
-
_a.label = 4;
|
|
249
|
-
case 4: return [2 /*return*/];
|
|
250
|
-
}
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
};
|
|
254
|
-
ManagedModule.prototype.setConfig = function (call, callback) {
|
|
120
|
+
async initializeMetrics() { }
|
|
121
|
+
async createGrpcServer() {
|
|
122
|
+
this.grpcServer = new __1.GrpcServer(this._port);
|
|
123
|
+
this._port = (await this.grpcServer.createNewServer()).toString();
|
|
124
|
+
}
|
|
125
|
+
async startGrpcServer() {
|
|
126
|
+
if (this.service) {
|
|
127
|
+
this._serviceName = this.service.protoDescription.substring(this.service.protoDescription.indexOf('.') + 1);
|
|
128
|
+
await this.grpcServer.addService(this.service.protoPath, this.service.protoDescription, this.service.functions);
|
|
129
|
+
await this.addHealthCheckService();
|
|
130
|
+
await this.grpcServer.start();
|
|
131
|
+
__1.default.Logger.log('gRPC server listening on ' + this._port);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
async setConfig(call, callback) {
|
|
255
135
|
var _a;
|
|
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
|
-
return [4 /*yield*/, this.onConfig()];
|
|
291
|
-
case 2:
|
|
292
|
-
_b.sent();
|
|
293
|
-
(_a = this.grpcSdk.bus) === null || _a === void 0 ? void 0 : _a.publish((0, lodash_1.kebabCase)(this.name) + ':config:update', JSON.stringify(config));
|
|
294
|
-
return [3 /*break*/, 4];
|
|
295
|
-
case 3:
|
|
296
|
-
e_1 = _b.sent();
|
|
297
|
-
return [2 /*return*/, callback({ code: grpc_js_1.status.INTERNAL, message: e_1.message })];
|
|
298
|
-
case 4: return [2 /*return*/];
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
};
|
|
136
|
+
try {
|
|
137
|
+
if (!this.config) {
|
|
138
|
+
return callback({
|
|
139
|
+
code: grpc_js_1.status.INVALID_ARGUMENT,
|
|
140
|
+
message: 'Module is not configurable',
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
let config = JSON.parse(call.request.newConfig);
|
|
144
|
+
config = (0, __1.merge)(this.config.getProperties(), config);
|
|
145
|
+
config = await this.preConfig(config);
|
|
146
|
+
const previousConfig = this.config.getProperties();
|
|
147
|
+
try {
|
|
148
|
+
this.config.load(config).validate({
|
|
149
|
+
allowed: 'strict',
|
|
150
|
+
});
|
|
151
|
+
config = this.config.getProperties();
|
|
152
|
+
callback(null, { updatedConfig: JSON.stringify(config) });
|
|
153
|
+
}
|
|
154
|
+
catch (e) {
|
|
155
|
+
this.config = (0, convict_1.default)(this.configSchema);
|
|
156
|
+
this.config.load(previousConfig);
|
|
157
|
+
return callback({
|
|
158
|
+
code: grpc_js_1.status.INVALID_ARGUMENT,
|
|
159
|
+
message: 'Invalid configuration values: ' + e.message,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
ConfigController_1.ConfigController.getInstance().config = config;
|
|
163
|
+
await this.onConfig();
|
|
164
|
+
(_a = this.grpcSdk.bus) === null || _a === void 0 ? void 0 : _a.publish((0, lodash_1.kebabCase)(this.name) + ':config:update', JSON.stringify(config));
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
return callback({ code: grpc_js_1.status.INTERNAL, message: e.message });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
303
170
|
/** Used to update the module's configuration on initial Redis/DB reconciliation. */
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
this.grpcSdk.bus.subscribe("".concat(this.name, ":config:update"), function (message) { return __awaiter(_this, void 0, void 0, function () {
|
|
311
|
-
var _a;
|
|
312
|
-
return __generator(this, function (_b) {
|
|
313
|
-
switch (_b.label) {
|
|
314
|
-
case 0:
|
|
315
|
-
_a = ConfigController_1.ConfigController.getInstance();
|
|
316
|
-
return [4 /*yield*/, this.preConfig(JSON.parse(message))];
|
|
317
|
-
case 1:
|
|
318
|
-
_a.config = _b.sent();
|
|
319
|
-
return [4 /*yield*/, this.onConfig()];
|
|
320
|
-
case 2:
|
|
321
|
-
_b.sent();
|
|
322
|
-
return [2 /*return*/];
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
}); });
|
|
326
|
-
return [2 /*return*/];
|
|
327
|
-
});
|
|
171
|
+
async handleConfigSyncUpdate() {
|
|
172
|
+
if (!this.config)
|
|
173
|
+
return;
|
|
174
|
+
this.grpcSdk.bus.subscribe(`${this.name}:config:update`, async (message) => {
|
|
175
|
+
ConfigController_1.ConfigController.getInstance().config = await this.preConfig(JSON.parse(message));
|
|
176
|
+
await this.onConfig();
|
|
328
177
|
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
}(ConduitServiceModule_1.ConduitServiceModule));
|
|
178
|
+
}
|
|
179
|
+
}
|
|
332
180
|
exports.ManagedModule = ManagedModule;
|
|
333
181
|
//# sourceMappingURL=ManagedModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ManagedModule.js","sourceRoot":"","sources":["../../src/classes/ManagedModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"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