@conduitplatform/grpc-sdk 0.15.18 → 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 +165 -146
- package/dist/protoUtils/authentication.js.map +1 -1
- package/dist/protoUtils/authorization.d.ts +1 -1
- package/dist/protoUtils/authorization.js +292 -351
- package/dist/protoUtils/authorization.js.map +1 -1
- package/dist/protoUtils/chat.d.ts +1 -1
- package/dist/protoUtils/chat.js +156 -192
- package/dist/protoUtils/chat.js.map +1 -1
- package/dist/protoUtils/core.d.ts +1 -1
- package/dist/protoUtils/core.js +555 -517
- package/dist/protoUtils/core.js.map +1 -1
- package/dist/protoUtils/database.d.ts +1 -1
- package/dist/protoUtils/database.js +485 -476
- package/dist/protoUtils/database.js.map +1 -1
- package/dist/protoUtils/email.d.ts +1 -1
- package/dist/protoUtils/email.js +157 -185
- package/dist/protoUtils/email.js.map +1 -1
- package/dist/protoUtils/forms.d.ts +1 -1
- package/dist/protoUtils/forms.js +33 -31
- package/dist/protoUtils/forms.js.map +1 -1
- package/dist/protoUtils/functions.d.ts +1 -1
- package/dist/protoUtils/functions.js +33 -31
- 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 +32 -30
- 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 +220 -240
- package/dist/protoUtils/push-notifications.js.map +1 -1
- package/dist/protoUtils/router.d.ts +1 -1
- package/dist/protoUtils/router.js +326 -332
- package/dist/protoUtils/router.js.map +1 -1
- package/dist/protoUtils/sms.d.ts +1 -1
- package/dist/protoUtils/sms.js +137 -125
- package/dist/protoUtils/sms.js.map +1 -1
- package/dist/protoUtils/storage.d.ts +1 -1
- package/dist/protoUtils/storage.js +165 -139
- 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,57 +1,39 @@
|
|
|
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.ConduitActiveSchema = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
ConduitActiveSchema.prototype.findOne = function (query, select, populate) {
|
|
4
|
+
const ConduitSchema_1 = require("./ConduitSchema");
|
|
5
|
+
class ConduitActiveSchema extends ConduitSchema_1.ConduitSchema {
|
|
6
|
+
constructor(dbInstance, name, fields, modelOptions, collectionName) {
|
|
7
|
+
super(name, fields !== null && fields !== void 0 ? fields : {}, modelOptions, collectionName);
|
|
8
|
+
this.dbInstance = dbInstance;
|
|
9
|
+
}
|
|
10
|
+
findOne(query, select, populate) {
|
|
28
11
|
return this.dbInstance.findOne(this.name, query, select, populate);
|
|
29
|
-
}
|
|
30
|
-
|
|
12
|
+
}
|
|
13
|
+
findMany(query, select, skip, limit, sort, populate) {
|
|
31
14
|
return this.dbInstance.findMany(this.name, query, select, skip, limit, sort, populate);
|
|
32
|
-
}
|
|
33
|
-
|
|
15
|
+
}
|
|
16
|
+
create(query) {
|
|
34
17
|
return this.dbInstance.create(this.name, query);
|
|
35
|
-
}
|
|
36
|
-
|
|
18
|
+
}
|
|
19
|
+
createMany(query) {
|
|
37
20
|
return this.dbInstance.createMany(this.name, query);
|
|
38
|
-
}
|
|
39
|
-
|
|
21
|
+
}
|
|
22
|
+
findByIdAndUpdate(id, document, updateProvidedOnly, populate) {
|
|
40
23
|
return this.dbInstance.findByIdAndUpdate(this.name, id, document, updateProvidedOnly, populate);
|
|
41
|
-
}
|
|
42
|
-
|
|
24
|
+
}
|
|
25
|
+
updateMany(filterQuery, query, updateProvidedOnly) {
|
|
43
26
|
return this.dbInstance.updateMany(this.name, filterQuery, query, updateProvidedOnly);
|
|
44
|
-
}
|
|
45
|
-
|
|
27
|
+
}
|
|
28
|
+
deleteOne(query) {
|
|
46
29
|
return this.dbInstance.deleteOne(this.name, query);
|
|
47
|
-
}
|
|
48
|
-
|
|
30
|
+
}
|
|
31
|
+
deleteMany(query) {
|
|
49
32
|
return this.dbInstance.deleteMany(this.name, query);
|
|
50
|
-
}
|
|
51
|
-
|
|
33
|
+
}
|
|
34
|
+
countDocuments(query) {
|
|
52
35
|
return this.dbInstance.countDocuments(this.name, query);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
}(ConduitSchema_1.ConduitSchema));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
56
38
|
exports.ConduitActiveSchema = ConduitActiveSchema;
|
|
57
39
|
//# sourceMappingURL=ConduitActiveSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitActiveSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitActiveSchema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConduitActiveSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitActiveSchema.ts"],"names":[],"mappings":";;;AACA,mDAAgD;AAIhD,MAAa,mBAAuB,SAAQ,6BAAa;IAGvD,YACE,UAA4B,EAC5B,IAAY,EACZ,MAAqB,EACrB,YAAmC,EACnC,cAAuB;QAEvB,KAAK,CAAC,IAAI,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,EAAE,EAAE,YAAY,EAAE,cAAc,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED,OAAO,CACL,KAAe,EACf,MAAe,EACf,QAA4B;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IACxE,CAAC;IAED,QAAQ,CACN,KAAe,EACf,MAAe,EACf,IAAa,EACb,KAAc,EACd,IAAsD,EACtD,QAA4B;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,CAC7B,IAAI,CAAC,IAAI,EACT,KAAK,EACL,MAAM,EACN,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,KAAe;QACpB,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CAAC,KAAiB;QAC1B,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAI,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC;IAED,iBAAiB,CACf,EAAU,EACV,QAAkB,EAClB,kBAA4B,EAC5B,QAA4B;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CACtC,IAAI,CAAC,IAAI,EACT,EAAE,EACF,QAAQ,EACR,kBAAkB,EAClB,QAAQ,CACT,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,WAAqB,EAAE,KAAe,EAAE,kBAA4B;QAC7E,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,kBAAkB,CAAC,CAAC;IACvF,CAAC;IAED,SAAS,CAAC,KAAe;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACrD,CAAC;IAED,UAAU,CAAC,KAAe;QACxB,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACtD,CAAC;IAED,cAAc,CAAC,KAAe;QAC5B,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC;CACF;AA/ED,kDA+EC"}
|
|
@@ -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,56 +1,13 @@
|
|
|
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
|
-
|
|
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
|
+
class ConduitModule {
|
|
10
|
+
constructor(_clientName, _serviceName, _serviceUrl, _grpcToken) {
|
|
54
11
|
this._clientName = _clientName;
|
|
55
12
|
this._serviceName = _serviceName;
|
|
56
13
|
this._serviceUrl = _serviceUrl;
|
|
@@ -58,20 +15,20 @@ var ConduitModule = /** @class */ (function () {
|
|
|
58
15
|
this.active = false;
|
|
59
16
|
this.healthCheckEmitter = new events_1.EventEmitter();
|
|
60
17
|
}
|
|
61
|
-
|
|
18
|
+
initializeClient(type) {
|
|
62
19
|
if (this._client)
|
|
63
20
|
return this._client;
|
|
64
21
|
this.type = type;
|
|
65
22
|
this.openConnection();
|
|
66
23
|
return this._client;
|
|
67
|
-
}
|
|
68
|
-
|
|
24
|
+
}
|
|
25
|
+
openConnection() {
|
|
69
26
|
// ConduitGrpcSdk.Logger.log(`Opening connection for ${this._serviceName}`);
|
|
70
27
|
this.channel = (0, nice_grpc_1.createChannel)(this._serviceUrl, undefined, {
|
|
71
28
|
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
72
29
|
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
73
30
|
});
|
|
74
|
-
|
|
31
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)()
|
|
75
32
|
.use(this._grpcToken
|
|
76
33
|
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(this._grpcToken)
|
|
77
34
|
: (0, interceptors_1.getModuleNameInterceptor)(this._clientName))
|
|
@@ -87,97 +44,46 @@ var ConduitModule = /** @class */ (function () {
|
|
|
87
44
|
});
|
|
88
45
|
this._healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, this.channel);
|
|
89
46
|
this.active = true;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
},
|
|
102
|
-
enumerable: false,
|
|
103
|
-
configurable: true
|
|
104
|
-
});
|
|
105
|
-
Object.defineProperty(ConduitModule.prototype, "healthCheckWatcher", {
|
|
106
|
-
get: function () {
|
|
107
|
-
return this.healthCheckEmitter;
|
|
108
|
-
},
|
|
109
|
-
enumerable: false,
|
|
110
|
-
configurable: true
|
|
111
|
-
});
|
|
112
|
-
ConduitModule.prototype.closeConnection = function () {
|
|
47
|
+
}
|
|
48
|
+
get client() {
|
|
49
|
+
return this._client;
|
|
50
|
+
}
|
|
51
|
+
get healthClient() {
|
|
52
|
+
return this._healthClient;
|
|
53
|
+
}
|
|
54
|
+
get healthCheckWatcher() {
|
|
55
|
+
return this.healthCheckEmitter;
|
|
56
|
+
}
|
|
57
|
+
closeConnection() {
|
|
113
58
|
if (!this.channel)
|
|
114
59
|
return;
|
|
115
60
|
// ConduitGrpcSdk.Logger.warn(`Closing connection for ${this._serviceName}`);
|
|
116
61
|
this.channel.close();
|
|
117
62
|
this.channel = undefined;
|
|
118
63
|
this.active = false;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return this.healthClient.check({ service: service }).then(function (res) {
|
|
64
|
+
}
|
|
65
|
+
check(service = '') {
|
|
66
|
+
return this.healthClient.check({ service }).then((res) => {
|
|
123
67
|
return res.status;
|
|
124
68
|
});
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
var
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
_c.trys.push([2, 7, 8, 13]);
|
|
145
|
-
call_1 = __asyncValues(call);
|
|
146
|
-
_c.label = 3;
|
|
147
|
-
case 3: return [4 /*yield*/, call_1.next()];
|
|
148
|
-
case 4:
|
|
149
|
-
if (!(call_1_1 = _c.sent(), !call_1_1.done)) return [3 /*break*/, 6];
|
|
150
|
-
data = call_1_1.value;
|
|
151
|
-
self.healthCheckEmitter.emit("grpc-health-change:".concat(serviceName), data.status);
|
|
152
|
-
_c.label = 5;
|
|
153
|
-
case 5: return [3 /*break*/, 3];
|
|
154
|
-
case 6: return [3 /*break*/, 13];
|
|
155
|
-
case 7:
|
|
156
|
-
e_1_1 = _c.sent();
|
|
157
|
-
e_1 = { error: e_1_1 };
|
|
158
|
-
return [3 /*break*/, 13];
|
|
159
|
-
case 8:
|
|
160
|
-
_c.trys.push([8, , 11, 12]);
|
|
161
|
-
if (!(call_1_1 && !call_1_1.done && (_a = call_1.return))) return [3 /*break*/, 10];
|
|
162
|
-
return [4 /*yield*/, _a.call(call_1)];
|
|
163
|
-
case 9:
|
|
164
|
-
_c.sent();
|
|
165
|
-
_c.label = 10;
|
|
166
|
-
case 10: return [3 /*break*/, 12];
|
|
167
|
-
case 11:
|
|
168
|
-
if (e_1) throw e_1.error;
|
|
169
|
-
return [7 /*endfinally*/];
|
|
170
|
-
case 12: return [7 /*endfinally*/];
|
|
171
|
-
case 13: return [3 /*break*/, 15];
|
|
172
|
-
case 14:
|
|
173
|
-
error_1 = _c.sent();
|
|
174
|
-
return [3 /*break*/, 15];
|
|
175
|
-
case 15: return [2 /*return*/];
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
return ConduitModule;
|
|
181
|
-
}());
|
|
69
|
+
}
|
|
70
|
+
async watch(service = '') {
|
|
71
|
+
var _a;
|
|
72
|
+
const self = this;
|
|
73
|
+
const serviceName = (_a = this.type) === null || _a === void 0 ? void 0 : _a.name;
|
|
74
|
+
this.healthCheckEmitter.setMaxListeners(150);
|
|
75
|
+
try {
|
|
76
|
+
const call = this.healthClient.watch({ service });
|
|
77
|
+
for await (const data of call) {
|
|
78
|
+
self.healthCheckEmitter.emit(`grpc-health-change:${serviceName}`, data.status);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
// uncomment for debug when needed
|
|
83
|
+
// currently is misleading if left on
|
|
84
|
+
// ConduitGrpcSdk.Logger.warn('Connection to gRPC server closed');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
182
88
|
exports.ConduitModule = ConduitModule;
|
|
183
89
|
//# 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;AAGtC,MAAa,aAAa;IASxB,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;QAZtC,WAAM,GAAY,KAAK,CAAC;QAML,uBAAkB,GAAG,IAAI,qBAAY,EAAE,CAAC;IAOxD,CAAC;IAEJ,gBAA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
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;IAOxB,YACE,IAAY,EACZ,MAAoB,EACpB,YAAmC,EACnC,cAAuB;QANzB,gBAAW,GAAW,SAAS,CAAC;QAQ9B,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;AAlBD,sCAkBC"}
|
|
@@ -22,118 +22,60 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
22
22
|
__setModuleDefault(result, mod);
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
27
|
};
|
|
64
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
29
|
exports.ConduitServiceModule = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
30
|
+
const __1 = __importStar(require(".."));
|
|
31
|
+
const path_1 = __importDefault(require("path"));
|
|
32
|
+
const events_1 = require("events");
|
|
33
|
+
const lodash_1 = require("lodash");
|
|
34
|
+
class ConduitServiceModule {
|
|
35
|
+
constructor(moduleName) {
|
|
72
36
|
this._serviceHealthState = __1.HealthCheckStatus.SERVING; // default for health-agnostic modules
|
|
73
37
|
this.events = new events_1.EventEmitter();
|
|
74
38
|
this._moduleName = (0, lodash_1.camelCase)(moduleName);
|
|
75
39
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
});
|
|
97
|
-
Object.defineProperty(ConduitServiceModule.prototype, "port", {
|
|
98
|
-
get: function () {
|
|
99
|
-
return this._port;
|
|
100
|
-
},
|
|
101
|
-
enumerable: false,
|
|
102
|
-
configurable: true
|
|
103
|
-
});
|
|
104
|
-
ConduitServiceModule.prototype.addHealthCheckService = function () {
|
|
105
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
106
|
-
return __generator(this, function (_a) {
|
|
107
|
-
switch (_a.label) {
|
|
108
|
-
case 0: return [4 /*yield*/, this.grpcServer.addService(path_1.default.resolve(__dirname, '../grpc_health_check.proto'), 'grpc.health.v1.Health', {
|
|
109
|
-
Check: this.healthCheck.bind(this),
|
|
110
|
-
Watch: this.healthWatch.bind(this),
|
|
111
|
-
})];
|
|
112
|
-
case 1:
|
|
113
|
-
_a.sent();
|
|
114
|
-
return [2 /*return*/];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
40
|
+
get healthState() {
|
|
41
|
+
return this._serviceHealthState;
|
|
42
|
+
}
|
|
43
|
+
set grpcSdk(grpcSdk) {
|
|
44
|
+
if (this._grpcSdk)
|
|
45
|
+
throw new Error('grpcSdk already defined');
|
|
46
|
+
this._grpcSdk = grpcSdk;
|
|
47
|
+
}
|
|
48
|
+
get grpcSdk() {
|
|
49
|
+
if (!this._grpcSdk)
|
|
50
|
+
throw new Error('grpcSdk not defined yet');
|
|
51
|
+
return this._grpcSdk;
|
|
52
|
+
}
|
|
53
|
+
get port() {
|
|
54
|
+
return this._port;
|
|
55
|
+
}
|
|
56
|
+
async addHealthCheckService() {
|
|
57
|
+
await this.grpcServer.addService(path_1.default.resolve(__dirname, '../grpc_health_check.proto'), 'grpc.health.v1.Health', {
|
|
58
|
+
Check: this.healthCheck.bind(this),
|
|
59
|
+
Watch: this.healthWatch.bind(this),
|
|
117
60
|
});
|
|
118
|
-
}
|
|
119
|
-
|
|
61
|
+
}
|
|
62
|
+
updateHealth(state, init = false) {
|
|
120
63
|
var _a, _b;
|
|
121
|
-
if (init === void 0) { init = false; }
|
|
122
64
|
if ((state === __1.HealthCheckStatus.UNKNOWN && !init) ||
|
|
123
65
|
state === __1.HealthCheckStatus.SERVICE_UNKNOWN) {
|
|
124
|
-
throw new Error(
|
|
66
|
+
throw new Error(`Cannot explicitly set gRPC health state to ${__1.HealthCheckStatus[state]}`);
|
|
125
67
|
}
|
|
126
68
|
if (!init) {
|
|
127
69
|
(_a = __1.default.Metrics) === null || _a === void 0 ? void 0 : _a.set('module_health_state', state === __1.HealthCheckStatus.SERVING ? 1 : 0);
|
|
128
70
|
}
|
|
129
71
|
if (this._serviceHealthState !== state) {
|
|
130
72
|
this._serviceHealthState = state;
|
|
131
|
-
this.events.emit(
|
|
73
|
+
this.events.emit(`grpc-health-change:${this._serviceName}`, state);
|
|
132
74
|
(_b = this._grpcSdk) === null || _b === void 0 ? void 0 : _b.config.moduleHealthProbe(this._moduleName, this._address);
|
|
133
75
|
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
76
|
+
}
|
|
77
|
+
healthCheck(call, callback) {
|
|
78
|
+
const service = call.request.service.substring(call.request.service.indexOf('.') + 1);
|
|
137
79
|
if (service && service !== this._serviceName) {
|
|
138
80
|
callback(null, {
|
|
139
81
|
status: __1.HealthCheckStatus.SERVICE_UNKNOWN,
|
|
@@ -144,23 +86,22 @@ var ConduitServiceModule = /** @class */ (function () {
|
|
|
144
86
|
status: this._serviceHealthState,
|
|
145
87
|
});
|
|
146
88
|
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
|
|
89
|
+
}
|
|
90
|
+
healthWatch(call) {
|
|
91
|
+
const service = call.request.service.substring(call.request.service.indexOf('.') + 1);
|
|
150
92
|
if (service && service !== this._serviceName) {
|
|
151
93
|
call.write({
|
|
152
94
|
status: __1.HealthCheckStatus.SERVICE_UNKNOWN,
|
|
153
95
|
});
|
|
154
96
|
}
|
|
155
97
|
else {
|
|
156
|
-
this.events.on(
|
|
98
|
+
this.events.on(`grpc-health-change:${this._serviceName}`, (status) => {
|
|
157
99
|
call.write({
|
|
158
100
|
status: status,
|
|
159
101
|
});
|
|
160
102
|
});
|
|
161
103
|
}
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
}());
|
|
104
|
+
}
|
|
105
|
+
}
|
|
165
106
|
exports.ConduitServiceModule = ConduitServiceModule;
|
|
166
107
|
//# sourceMappingURL=ConduitServiceModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitServiceModule.js","sourceRoot":"","sources":["../../src/classes/ConduitServiceModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConduitServiceModule.js","sourceRoot":"","sources":["../../src/classes/ConduitServiceModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wCAAmE;AACnE,gDAAwB;AACxB,mCAAsC;AACtC,mCAAmC;AAUnC,MAAsB,oBAAoB;IAUxC,YAAsB,UAAkB;QAHhC,wBAAmB,GAAsB,qBAAiB,CAAC,OAAO,CAAC,CAAC,sCAAsC;QAC/F,WAAM,GAAiB,IAAI,qBAAY,EAAE,CAAC;QAG3D,IAAI,CAAC,WAAW,GAAG,IAAA,kBAAS,EAAC,UAAU,CAAC,CAAC;IAC3C,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC;IAED,IAAW,OAAO,CAAC,OAAuB;QACxC,IAAI,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC9D,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,IAAW,OAAO;QAChB,IAAI,CAAC,IAAI,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAES,KAAK,CAAC,qBAAqB;QACnC,MAAM,IAAI,CAAC,UAAU,CAAC,UAAU,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OAAO,KAAK,IAAI,CAAC,YAAY,EAAE;YAC5C,QAAQ,CAAC,IAAI,EAAE;gBACb,MAAM,EACJ,qBAAiB,CAAC,eAA+D;aACpF,CAAC,CAAC;SACJ;aAAM;YACL,QAAQ,CAAC,IAAI,EAAE;gBACb,MAAM,EAAE,IAAI,CAAC,mBAAmE;aACjF,CAAC,CAAC;SACJ;IACH,CAAC;IAED,WAAW,CAAC,IAAmE;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACtF,IAAI,OAAO,IAAI,OAAO,KAAK,IAAI,CAAC,YAAY,EAAE;YAC5C,IAAI,CAAC,KAAK,CAAC;gBACT,MAAM,EACJ,qBAAiB,CAAC,eAA+D;aACpF,CAAC,CAAC;SACJ;aAAM;YACL,IAAI,CAAC,MAAM,CAAC,EAAE,CACZ,sBAAsB,IAAI,CAAC,YAAY,EAAE,EACzC,CAAC,MAAyB,EAAE,EAAE;gBAC5B,IAAI,CAAC,KAAK,CAAC;oBACT,MAAM,EAAE,MAAsD;iBAC/D,CAAC,CAAC;YACL,CAAC,CACF,CAAC;SACH;IACH,CAAC;CACF;AApGD,oDAoGC"}
|
|
@@ -1,27 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConfigController = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ConfigController {
|
|
5
|
+
get config() {
|
|
6
|
+
// return copy of config and not the original object;
|
|
7
|
+
return Object.assign({}, this._config);
|
|
6
8
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
},
|
|
12
|
-
set: function (config) {
|
|
13
|
-
this._config = config;
|
|
14
|
-
},
|
|
15
|
-
enumerable: false,
|
|
16
|
-
configurable: true
|
|
17
|
-
});
|
|
18
|
-
ConfigController.getInstance = function () {
|
|
9
|
+
set config(config) {
|
|
10
|
+
this._config = config;
|
|
11
|
+
}
|
|
12
|
+
static getInstance() {
|
|
19
13
|
if (!ConfigController.instance) {
|
|
20
14
|
ConfigController.instance = new ConfigController();
|
|
21
15
|
}
|
|
22
16
|
return ConfigController.instance;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}());
|
|
17
|
+
}
|
|
18
|
+
}
|
|
26
19
|
exports.ConfigController = ConfigController;
|
|
27
20
|
//# sourceMappingURL=ConfigController.js.map
|