@conduitplatform/grpc-sdk 0.16.0-alpha.2 → 0.16.0-alpha.21
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/README.mdx +1 -7
- package/dist/classes/ConduitAuthorizedResource.js +5 -6
- package/dist/classes/ConduitAuthorizedResource.js.map +1 -1
- package/dist/classes/ConduitModule.d.ts +9 -6
- package/dist/classes/ConduitModule.js +68 -141
- package/dist/classes/ConduitModule.js.map +1 -1
- package/dist/classes/ConduitSchema.js +3 -4
- package/dist/classes/ConduitSchema.js.map +1 -1
- package/dist/classes/Error.js +17 -40
- package/dist/classes/Error.js.map +1 -1
- package/dist/classes/HealthCheck.js +30 -71
- package/dist/classes/HealthCheck.js.map +1 -1
- package/dist/classes/index.d.ts +2 -6
- package/dist/classes/index.js +2 -6
- package/dist/classes/index.js.map +1 -1
- package/dist/index.d.ts +34 -31
- package/dist/index.js +331 -499
- package/dist/index.js.map +1 -1
- package/dist/interceptors/grpcSignedToken.d.ts +1 -1
- package/dist/interceptors/grpcSignedToken.js +7 -79
- package/dist/interceptors/grpcSignedToken.js.map +1 -1
- package/dist/interceptors/moduleName.d.ts +1 -1
- package/dist/interceptors/moduleName.js +7 -79
- package/dist/interceptors/moduleName.js.map +1 -1
- package/dist/interfaces/ConduitMiddleware.js.map +1 -0
- package/dist/{routing/interfaces → interfaces}/ConduitRoute.d.ts +2 -3
- package/dist/interfaces/ConduitRoute.js.map +1 -0
- package/dist/{routing → interfaces}/ConduitRouteReturn.d.ts +3 -3
- package/dist/{routing → interfaces}/ConduitRouteReturn.js +9 -18
- package/dist/interfaces/ConduitRouteReturn.js.map +1 -0
- package/dist/interfaces/ConduitSchemaExtension.d.ts +1 -1
- package/dist/interfaces/GrpcCallback.d.ts +1 -1
- package/dist/{utilities/Logger.d.ts → interfaces/IConduitLogger.d.ts} +4 -7
- package/dist/interfaces/{ConduitService.js → IConduitLogger.js} +1 -1
- package/dist/interfaces/IConduitLogger.js.map +1 -0
- package/dist/{metrics/index.d.ts → interfaces/IConduitMetrics.d.ts} +5 -11
- package/dist/interfaces/IConduitMetrics.js +3 -0
- package/dist/interfaces/IConduitMetrics.js.map +1 -0
- package/dist/interfaces/Indexable.d.ts +7 -8
- package/dist/interfaces/Model.d.ts +66 -13
- package/dist/interfaces/Model.js.map +1 -1
- package/dist/interfaces/Params.d.ts +3 -3
- package/dist/interfaces/ProxyRoute.js.map +1 -0
- package/dist/interfaces/RawQuery.d.ts +2 -2
- package/dist/interfaces/Route.d.ts +64 -0
- package/dist/interfaces/Route.js +12 -0
- package/dist/interfaces/Route.js.map +1 -0
- package/dist/{routing/interfaces → interfaces}/Socket.d.ts +4 -5
- package/dist/interfaces/Socket.js.map +1 -0
- package/dist/interfaces/UntypedArray.d.ts +1 -1
- package/dist/interfaces/index.d.ts +9 -2
- package/dist/interfaces/index.js +9 -2
- package/dist/interfaces/index.js.map +1 -1
- package/dist/{routing/interfaces → interfaces}/types.d.ts +11 -9
- package/dist/{routing/interfaces → interfaces}/types.js.map +1 -1
- package/dist/module.proto +72 -0
- package/dist/modules/admin/index.d.ts +5 -5
- package/dist/modules/admin/index.js +18 -37
- package/dist/modules/admin/index.js.map +1 -1
- package/dist/modules/authentication/index.d.ts +5 -2
- package/dist/modules/authentication/index.js +30 -40
- package/dist/modules/authentication/index.js.map +1 -1
- package/dist/modules/authorization/index.d.ts +6 -2
- package/dist/modules/authorization/index.js +38 -47
- package/dist/modules/authorization/index.js.map +1 -1
- package/dist/modules/chat/index.js +16 -34
- package/dist/modules/chat/index.js.map +1 -1
- package/dist/modules/config/index.d.ts +14 -5
- package/dist/modules/config/index.js +85 -177
- package/dist/modules/config/index.js.map +1 -1
- package/dist/modules/core/index.js +8 -26
- package/dist/modules/core/index.js.map +1 -1
- package/dist/modules/database/index.d.ts +24 -14
- package/dist/modules/database/index.js +193 -134
- 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/index.d.ts +0 -2
- package/dist/modules/index.js +0 -2
- package/dist/modules/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.d.ts +5 -5
- package/dist/modules/router/index.js +20 -39
- package/dist/modules/router/index.js.map +1 -1
- package/dist/modules/sms/index.js +17 -35
- package/dist/modules/sms/index.js.map +1 -1
- package/dist/modules/storage/index.d.ts +8 -4
- package/dist/modules/storage/index.js +66 -37
- package/dist/modules/storage/index.js.map +1 -1
- package/dist/protoUtils/authentication.d.ts +127 -46
- package/dist/protoUtils/authentication.js +481 -220
- package/dist/protoUtils/authentication.js.map +1 -1
- package/dist/protoUtils/authorization.d.ts +147 -82
- package/dist/protoUtils/authorization.js +684 -512
- package/dist/protoUtils/authorization.js.map +1 -1
- package/dist/protoUtils/chat.d.ts +7 -61
- package/dist/protoUtils/chat.js +130 -313
- package/dist/protoUtils/chat.js.map +1 -1
- package/dist/protoUtils/core.d.ts +88 -107
- package/dist/protoUtils/core.js +699 -733
- package/dist/protoUtils/core.js.map +1 -1
- package/dist/protoUtils/database.d.ts +195 -15
- package/dist/protoUtils/database.js +1077 -666
- package/dist/protoUtils/database.js.map +1 -1
- package/dist/protoUtils/email.d.ts +3 -48
- package/dist/protoUtils/email.js +145 -284
- package/dist/protoUtils/email.js.map +1 -1
- package/dist/protoUtils/google/protobuf/empty.d.ts +27 -0
- package/dist/protoUtils/google/protobuf/empty.js +46 -0
- package/dist/protoUtils/google/protobuf/empty.js.map +1 -0
- package/dist/protoUtils/grpc_health_check.d.ts +3 -4
- package/dist/protoUtils/grpc_health_check.js +37 -36
- package/dist/protoUtils/grpc_health_check.js.map +1 -1
- package/dist/protoUtils/index.d.ts +12 -0
- package/dist/{routing/interfaces → protoUtils}/index.js +12 -6
- package/dist/protoUtils/index.js.map +1 -0
- package/dist/protoUtils/module.d.ts +251 -0
- package/dist/protoUtils/module.js +874 -0
- package/dist/protoUtils/module.js.map +1 -0
- package/dist/protoUtils/push-notifications.d.ts +7 -50
- package/dist/protoUtils/push-notifications.js +269 -356
- package/dist/protoUtils/push-notifications.js.map +1 -1
- package/dist/protoUtils/router.d.ts +45 -111
- package/dist/protoUtils/router.js +357 -575
- package/dist/protoUtils/router.js.map +1 -1
- package/dist/protoUtils/sms.d.ts +3 -48
- package/dist/protoUtils/sms.js +120 -219
- package/dist/protoUtils/sms.js.map +1 -1
- package/dist/protoUtils/storage.d.ts +144 -62
- package/dist/protoUtils/storage.js +782 -282
- package/dist/protoUtils/storage.js.map +1 -1
- package/dist/types/db.d.ts +11 -11
- package/dist/types/index.d.ts +3 -10
- package/dist/types/index.js +21 -24
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/EventBus.d.ts +3 -1
- package/dist/utilities/EventBus.js +38 -17
- package/dist/utilities/EventBus.js.map +1 -1
- package/dist/utilities/RedisManager.js +11 -21
- package/dist/utilities/RedisManager.js.map +1 -1
- package/dist/utilities/StateManager.js +13 -14
- package/dist/utilities/StateManager.js.map +1 -1
- package/dist/utilities/env.js +4 -4
- package/dist/utilities/env.js.map +1 -1
- package/dist/utilities/index.d.ts +3 -2
- package/dist/utilities/index.js +3 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/sleep.js +1 -1
- package/dist/utilities/sleep.js.map +1 -1
- package/package.json +24 -25
- package/dist/classes/ConduitActiveSchema.d.ts +0 -19
- package/dist/classes/ConduitActiveSchema.js +0 -57
- package/dist/classes/ConduitActiveSchema.js.map +0 -1
- package/dist/classes/ConduitServiceModule.d.ts +0 -26
- package/dist/classes/ConduitServiceModule.js +0 -166
- package/dist/classes/ConduitServiceModule.js.map +0 -1
- package/dist/classes/ConfigController.d.ts +0 -7
- package/dist/classes/ConfigController.js +0 -27
- package/dist/classes/ConfigController.js.map +0 -1
- package/dist/classes/GrpcServer.d.ts +0 -22
- package/dist/classes/GrpcServer.js +0 -207
- package/dist/classes/GrpcServer.js.map +0 -1
- package/dist/classes/ManagedModule.d.ts +0 -74
- package/dist/classes/ManagedModule.js +0 -333
- package/dist/classes/ManagedModule.js.map +0 -1
- package/dist/classes/ModuleManager.d.ts +0 -11
- package/dist/classes/ModuleManager.js +0 -204
- package/dist/classes/ModuleManager.js.map +0 -1
- package/dist/helpers/GrpcHelper.d.ts +0 -8
- package/dist/helpers/GrpcHelper.js +0 -43
- package/dist/helpers/GrpcHelper.js.map +0 -1
- package/dist/helpers/TypeHelpers.d.ts +0 -44
- package/dist/helpers/TypeHelpers.js +0 -144
- package/dist/helpers/TypeHelpers.js.map +0 -1
- package/dist/helpers/index.d.ts +0 -3
- package/dist/helpers/index.js +0 -20
- package/dist/helpers/index.js.map +0 -1
- package/dist/helpers/wrapGrpcFunctions.d.ts +0 -5
- package/dist/helpers/wrapGrpcFunctions.js +0 -56
- package/dist/helpers/wrapGrpcFunctions.js.map +0 -1
- package/dist/interfaces/ConduitService.d.ts +0 -8
- package/dist/interfaces/ConduitService.js.map +0 -1
- package/dist/metrics/MetricsServer.d.ts +0 -9
- package/dist/metrics/MetricsServer.js +0 -94
- package/dist/metrics/MetricsServer.js.map +0 -1
- package/dist/metrics/clientMiddleware.d.ts +0 -2
- package/dist/metrics/clientMiddleware.js +0 -265
- package/dist/metrics/clientMiddleware.js.map +0 -1
- package/dist/metrics/config/defaults.d.ts +0 -91
- package/dist/metrics/config/defaults.js +0 -93
- package/dist/metrics/config/defaults.js.map +0 -1
- package/dist/metrics/index.js +0 -152
- package/dist/metrics/index.js.map +0 -1
- package/dist/modules/forms/index.d.ts +0 -6
- package/dist/modules/forms/index.js +0 -32
- package/dist/modules/forms/index.js.map +0 -1
- package/dist/modules/functions/index.d.ts +0 -6
- package/dist/modules/functions/index.js +0 -32
- package/dist/modules/functions/index.js.map +0 -1
- package/dist/protoUtils/forms.d.ts +0 -58
- package/dist/protoUtils/forms.js +0 -127
- package/dist/protoUtils/forms.js.map +0 -1
- package/dist/protoUtils/functions.d.ts +0 -58
- package/dist/protoUtils/functions.js +0 -127
- package/dist/protoUtils/functions.js.map +0 -1
- package/dist/routing/ConduitRouteReturn.js.map +0 -1
- package/dist/routing/ProxyRouteBuilder.d.ts +0 -21
- package/dist/routing/ProxyRouteBuilder.js +0 -81
- package/dist/routing/ProxyRouteBuilder.js.map +0 -1
- package/dist/routing/RouteBuilder.d.ts +0 -24
- package/dist/routing/RouteBuilder.js +0 -107
- package/dist/routing/RouteBuilder.js.map +0 -1
- package/dist/routing/RoutingManager.d.ts +0 -33
- package/dist/routing/RoutingManager.js +0 -201
- package/dist/routing/RoutingManager.js.map +0 -1
- package/dist/routing/RoutingUtilities.d.ts +0 -7
- package/dist/routing/RoutingUtilities.js +0 -13
- package/dist/routing/RoutingUtilities.js.map +0 -1
- package/dist/routing/index.d.ts +0 -7
- package/dist/routing/index.js +0 -24
- package/dist/routing/index.js.map +0 -1
- package/dist/routing/interfaces/ConduitMiddleware.js.map +0 -1
- package/dist/routing/interfaces/ConduitRoute.js.map +0 -1
- package/dist/routing/interfaces/ProxyRoute.js.map +0 -1
- package/dist/routing/interfaces/Route.d.ts +0 -52
- package/dist/routing/interfaces/Route.js +0 -21
- package/dist/routing/interfaces/Route.js.map +0 -1
- package/dist/routing/interfaces/Socket.js.map +0 -1
- package/dist/routing/interfaces/index.d.ts +0 -6
- package/dist/routing/interfaces/index.js.map +0 -1
- package/dist/routing/wrapRouterFunctions.d.ts +0 -8
- package/dist/routing/wrapRouterFunctions.js +0 -132
- package/dist/routing/wrapRouterFunctions.js.map +0 -1
- package/dist/utilities/Logger.js +0 -255
- package/dist/utilities/Logger.js.map +0 -1
- package/dist/utilities/linearBackoffTimeout.d.ts +0 -10
- package/dist/utilities/linearBackoffTimeout.js +0 -119
- package/dist/utilities/linearBackoffTimeout.js.map +0 -1
- package/dist/utilities/merge.d.ts +0 -1
- package/dist/utilities/merge.js +0 -15
- package/dist/utilities/merge.js.map +0 -1
- /package/dist/{routing/interfaces → interfaces}/ConduitMiddleware.d.ts +0 -0
- /package/dist/{routing/interfaces → interfaces}/ConduitMiddleware.js +0 -0
- /package/dist/{routing/interfaces → interfaces}/ConduitRoute.js +0 -0
- /package/dist/{routing/interfaces → interfaces}/ProxyRoute.d.ts +0 -0
- /package/dist/{routing/interfaces → interfaces}/ProxyRoute.js +0 -0
- /package/dist/{routing/interfaces → interfaces}/Socket.js +0 -0
- /package/dist/{routing/interfaces → interfaces}/types.js +0 -0
package/README.mdx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# Conduit gRPC SDK
|
|
2
2
|
|
|
3
3
|
This library provides a framework to bind all Conduit modules in a safe and consistent way.<br />
|
|
4
|
-
It is also used to provide syntactic sugar that makes development easier.
|
|
5
4
|
|
|
6
5
|
## Build Steps
|
|
7
6
|
|
|
@@ -10,12 +9,7 @@ It is also used to provide syntactic sugar that makes development easier.
|
|
|
10
9
|
|
|
11
10
|
## Features ✔️
|
|
12
11
|
|
|
13
|
-
- Service
|
|
14
|
-
- Application route registration
|
|
15
|
-
- Administrative route registration
|
|
12
|
+
- Service discovery
|
|
16
13
|
- Provides wrappers for gRPC handlers to support async
|
|
17
|
-
- Parses incoming requests and outgoing responses to JSON
|
|
18
14
|
- Provides health check service out of the box
|
|
19
|
-
- Manages the gRPC server so you don't have to
|
|
20
15
|
- Provides typings for common Conduit models
|
|
21
|
-
- Provides classes to facilitate building your own Conduit modules
|
|
@@ -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"}
|
|
@@ -3,25 +3,28 @@ import { CompatServiceDefinition } from 'nice-grpc/lib/service-definitions';
|
|
|
3
3
|
import { Channel, Client } from 'nice-grpc';
|
|
4
4
|
import { HealthDefinition } from '../protoUtils/grpc_health_check';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
|
+
import { ConduitModuleDefinition } from '../protoUtils';
|
|
6
7
|
export declare class ConduitModule<T extends CompatServiceDefinition> {
|
|
7
8
|
readonly _clientName: string;
|
|
8
9
|
private readonly _serviceName;
|
|
9
10
|
private readonly _serviceUrl;
|
|
10
11
|
private readonly _grpcToken?;
|
|
11
|
-
active: boolean;
|
|
12
|
-
private _client?;
|
|
13
|
-
private _healthClient?;
|
|
14
12
|
protected channel?: Channel;
|
|
15
13
|
protected protoPath?: string;
|
|
16
14
|
protected type?: T;
|
|
17
15
|
protected readonly healthCheckEmitter: EventEmitter;
|
|
18
16
|
constructor(_clientName: string, _serviceName: string, _serviceUrl: string, _grpcToken?: string | undefined);
|
|
19
|
-
|
|
20
|
-
openConnection(): void;
|
|
17
|
+
private _client?;
|
|
21
18
|
get client(): Client<T> | undefined;
|
|
19
|
+
private _healthClient?;
|
|
22
20
|
get healthClient(): Client<typeof HealthDefinition> | undefined;
|
|
21
|
+
private _moduleClient?;
|
|
22
|
+
get moduleClient(): Client<typeof ConduitModuleDefinition> | undefined;
|
|
23
|
+
get active(): boolean;
|
|
23
24
|
get healthCheckWatcher(): EventEmitter;
|
|
25
|
+
initializeClient(type: T): Client<T>;
|
|
26
|
+
openConnection(): void;
|
|
24
27
|
closeConnection(): void;
|
|
25
|
-
check(service?: string): Promise<import("../protoUtils
|
|
28
|
+
check(service?: string): Promise<import("../protoUtils").HealthCheckResponse_ServingStatus>;
|
|
26
29
|
watch(service?: string): Promise<void>;
|
|
27
30
|
}
|
|
@@ -1,77 +1,55 @@
|
|
|
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
|
+
const protoUtils_1 = require("../protoUtils");
|
|
10
|
+
class ConduitModule {
|
|
11
|
+
constructor(_clientName, _serviceName, _serviceUrl, _grpcToken) {
|
|
54
12
|
this._clientName = _clientName;
|
|
55
13
|
this._serviceName = _serviceName;
|
|
56
14
|
this._serviceUrl = _serviceUrl;
|
|
57
15
|
this._grpcToken = _grpcToken;
|
|
58
|
-
this.active = false;
|
|
59
16
|
this.healthCheckEmitter = new events_1.EventEmitter();
|
|
60
17
|
}
|
|
61
|
-
|
|
18
|
+
get client() {
|
|
19
|
+
return this._client;
|
|
20
|
+
}
|
|
21
|
+
get healthClient() {
|
|
22
|
+
return this._healthClient;
|
|
23
|
+
}
|
|
24
|
+
get moduleClient() {
|
|
25
|
+
return this._moduleClient;
|
|
26
|
+
}
|
|
27
|
+
get active() {
|
|
28
|
+
if (!this.channel) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
const connectivityState = this.channel.getConnectivityState(true);
|
|
32
|
+
return connectivityState === 2 || connectivityState === 1 || connectivityState === 0;
|
|
33
|
+
}
|
|
34
|
+
get healthCheckWatcher() {
|
|
35
|
+
return this.healthCheckEmitter;
|
|
36
|
+
}
|
|
37
|
+
initializeClient(type) {
|
|
62
38
|
if (this._client)
|
|
63
39
|
return this._client;
|
|
64
40
|
this.type = type;
|
|
65
41
|
this.openConnection();
|
|
66
42
|
return this._client;
|
|
67
|
-
}
|
|
68
|
-
|
|
43
|
+
}
|
|
44
|
+
openConnection() {
|
|
45
|
+
if (this.channel)
|
|
46
|
+
return;
|
|
69
47
|
// ConduitGrpcSdk.Logger.log(`Opening connection for ${this._serviceName}`);
|
|
70
48
|
this.channel = (0, nice_grpc_1.createChannel)(this._serviceUrl, undefined, {
|
|
71
49
|
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
72
50
|
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
73
51
|
});
|
|
74
|
-
|
|
52
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)()
|
|
75
53
|
.use(this._grpcToken
|
|
76
54
|
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(this._grpcToken)
|
|
77
55
|
: (0, interceptors_1.getModuleNameInterceptor)(this._clientName))
|
|
@@ -86,98 +64,47 @@ var ConduitModule = /** @class */ (function () {
|
|
|
86
64
|
},
|
|
87
65
|
});
|
|
88
66
|
this._healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, this.channel);
|
|
89
|
-
this.
|
|
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 () {
|
|
67
|
+
this._moduleClient = clientFactory.create(protoUtils_1.ConduitModuleDefinition, this.channel);
|
|
68
|
+
const monitorChannel = () => {
|
|
69
|
+
if (!this.channel)
|
|
70
|
+
return;
|
|
71
|
+
try {
|
|
72
|
+
const state = this.channel.getConnectivityState(true);
|
|
73
|
+
this.channel.watchConnectivityState(state, Infinity, monitorChannel);
|
|
74
|
+
}
|
|
75
|
+
catch (e) { }
|
|
76
|
+
};
|
|
77
|
+
monitorChannel();
|
|
78
|
+
}
|
|
79
|
+
closeConnection() {
|
|
113
80
|
if (!this.channel)
|
|
114
81
|
return;
|
|
115
82
|
// ConduitGrpcSdk.Logger.warn(`Closing connection for ${this._serviceName}`);
|
|
116
83
|
this.channel.close();
|
|
117
84
|
this.channel = undefined;
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (service === void 0) { service = ''; }
|
|
122
|
-
return this.healthClient.check({ service: service }).then(function (res) {
|
|
85
|
+
}
|
|
86
|
+
check(service = '') {
|
|
87
|
+
return this.healthClient.check({ service }).then((res) => {
|
|
123
88
|
return res.status;
|
|
124
89
|
});
|
|
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
|
-
}());
|
|
90
|
+
}
|
|
91
|
+
async watch(service = '') {
|
|
92
|
+
var _a;
|
|
93
|
+
const self = this;
|
|
94
|
+
const serviceName = (_a = this.type) === null || _a === void 0 ? void 0 : _a.name;
|
|
95
|
+
this.healthCheckEmitter.setMaxListeners(150);
|
|
96
|
+
try {
|
|
97
|
+
const call = this.healthClient.watch({ service });
|
|
98
|
+
for await (const data of call) {
|
|
99
|
+
self.healthCheckEmitter.emit(`grpc-health-change:${serviceName}`, data.status);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
// uncomment for debug when needed
|
|
104
|
+
// currently is misleading if left on
|
|
105
|
+
// ConduitGrpcSdk.Logger.warn('Connection to gRPC server closed');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
182
109
|
exports.ConduitModule = ConduitModule;
|
|
183
110
|
//# sourceMappingURL=ConduitModule.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitModule.js","sourceRoot":"","sources":["../../src/classes/ConduitModule.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConduitModule.js","sourceRoot":"","sources":["../../src/classes/ConduitModule.ts"],"names":[],"mappings":";;;AAAA,kDAA0F;AAE1F,yCAAgF;AAChF,yFAAoE;AACpE,uEAAwF;AACxF,mCAAsC;AACtC,8CAAwD;AAExD,MAAa,aAAa;IAMxB,YACW,WAAmB,EACX,YAAoB,EACpB,WAAmB,EACnB,UAAmB;QAH3B,gBAAW,GAAX,WAAW,CAAQ;QACX,iBAAY,GAAZ,YAAY,CAAQ;QACpB,gBAAW,GAAX,WAAW,CAAQ;QACnB,eAAU,GAAV,UAAU,CAAS;QANnB,uBAAkB,GAAG,IAAI,qBAAY,EAAE,CAAC;IAOxD,CAAC;IAIJ,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAID,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAID,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED,IAAI,MAAM;QACR,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,KAAK,CAAC;SACd;QACD,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAClE,OAAO,iBAAiB,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,IAAI,iBAAiB,KAAK,CAAC,CAAC;IACvF,CAAC;IAED,IAAI,kBAAkB;QACpB,OAAO,IAAI,CAAC,kBAAkB,CAAC;IACjC,CAAC;IAED,gBAAgB,CAAC,IAAO;QACtB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,OAAO,IAAI,CAAC,OAAQ,CAAC;IACvB,CAAC;IAED,cAAc;QACZ,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,4EAA4E;QAC5E,IAAI,CAAC,OAAO,GAAG,IAAA,yBAAa,EAAC,IAAI,CAAC,WAAW,EAAE,SAAS,EAAE;YACxD,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;YACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;SAClD,CAAC,CAAC;QACH,MAAM,aAAa,GAAG,IAAA,+BAAmB,GAAE;aACxC,GAAG,CACF,IAAI,CAAC,UAAU;YACb,CAAC,CAAC,IAAA,4CAA6B,EAAC,IAAI,CAAC,UAAU,CAAC;YAChD,CAAC,CAAC,IAAA,uCAAwB,EAAC,IAAI,CAAC,WAAW,CAAC,CAC/C;aACA,GAAG,CAAC,mDAAe,CAAC,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,IAAK,EAAE,IAAI,CAAC,OAAO,EAAE;YAC5D,GAAG,EAAE;gBACH,2DAA2D;gBAC3D,iBAAiB,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC;gBAC9B,gBAAgB,EAAE,GAAG;gBACrB,gBAAgB,EAAE,CAAC;gBACnB,KAAK,EAAE,IAAI;aACZ;SACF,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC1E,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAuB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACjF,MAAM,cAAc,GAAG,GAAG,EAAE;YAC1B,IAAI,CAAC,IAAI,CAAC,OAAO;gBAAE,OAAO;YAC1B,IAAI;gBACF,MAAM,KAAK,GAAG,IAAI,CAAC,OAAQ,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;gBACvD,IAAI,CAAC,OAAQ,CAAC,sBAAsB,CAAC,KAAK,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;aACvE;YAAC,OAAO,CAAC,EAAE,GAAE;QAChB,CAAC,CAAC;QACF,cAAc,EAAE,CAAC;IACnB,CAAC;IAED,eAAe;QACb,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAO;QAC1B,6EAA6E;QAC7E,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,UAAkB,EAAE;QACxB,OAAO,IAAI,CAAC,YAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,GAAwB,EAAE,EAAE;YAC7E,OAAO,GAAG,CAAC,MAAM,CAAC;QACpB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,UAAkB,EAAE;;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC;QAClB,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,IAAI,0CAAE,IAAI,CAAC;QACpC,IAAI,CAAC,kBAAkB,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;QAC7C,IAAI;YACF,MAAM,IAAI,GAAG,IAAI,CAAC,YAAa,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;YACnD,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,EAAE;gBAC7B,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,sBAAsB,WAAW,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;aAChF;SACF;QAAC,OAAO,KAAK,EAAE;YACd,kCAAkC;YAClC,qCAAqC;YACrC,kEAAkE;SACnE;IACH,CAAC;CACF;AAjHD,sCAiHC"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConduitSchema = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
class ConduitSchema {
|
|
5
|
+
constructor(name, fields, modelOptions, collectionName) {
|
|
6
6
|
this.ownerModule = 'unknown';
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.fields = fields;
|
|
9
9
|
this.modelOptions = modelOptions !== null && modelOptions !== void 0 ? modelOptions : {};
|
|
10
10
|
this.collectionName = collectionName && collectionName !== '' ? collectionName : '';
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
}());
|
|
12
|
+
}
|
|
14
13
|
exports.ConduitSchema = ConduitSchema;
|
|
15
14
|
//# sourceMappingURL=ConduitSchema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConduitSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitSchema.ts"],"names":[],"mappings":";;;AAEA;
|
|
1
|
+
{"version":3,"file":"ConduitSchema.js","sourceRoot":"","sources":["../../src/classes/ConduitSchema.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IAQxB,YACE,IAAY,EACZ,MAAoB,EACpB,YAAmC,EACnC,cAAuB;QAPzB,gBAAW,GAAW,SAAS,CAAC;QAS9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,cAAc,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC;IACtF,CAAC;CACF;AAnBD,sCAmBC"}
|
package/dist/classes/Error.js
CHANGED
|
@@ -1,51 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
3
|
exports.ConduitError = void 0;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
_this.status = status;
|
|
26
|
-
return _this;
|
|
4
|
+
class ConduitError extends Error {
|
|
5
|
+
constructor(name, status, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = name;
|
|
8
|
+
this.message = message;
|
|
9
|
+
this.status = status;
|
|
27
10
|
}
|
|
28
|
-
|
|
29
|
-
if (message === void 0) { message = 'Unauthorized'; }
|
|
11
|
+
static unauthorized(message = 'Unauthorized') {
|
|
30
12
|
return new ConduitError('UNAUTHORIZED', 401, message);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (message === void 0) { message = 'Resource not found'; }
|
|
13
|
+
}
|
|
14
|
+
static notFound(message = 'Resource not found') {
|
|
34
15
|
return new ConduitError('NOT_FOUND', 404, message);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (message === void 0) { message = 'Forbidden'; }
|
|
16
|
+
}
|
|
17
|
+
static forbidden(message = 'Forbidden') {
|
|
38
18
|
return new ConduitError('FORBIDDEN', 403, message);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (message === void 0) { message = 'Request data are invalid'; }
|
|
19
|
+
}
|
|
20
|
+
static userInput(message = 'Request data are invalid') {
|
|
42
21
|
return new ConduitError('USER_INPUT_ERROR', 400, message);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (message === void 0) { message = 'Something went wrong'; }
|
|
22
|
+
}
|
|
23
|
+
static internalServerError(message = 'Something went wrong') {
|
|
46
24
|
throw new ConduitError('INTERNAL_SERVER_ERROR', 500, message);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
}(Error));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
50
27
|
exports.ConduitError = ConduitError;
|
|
51
28
|
//# sourceMappingURL=Error.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../src/classes/Error.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Error.js","sourceRoot":"","sources":["../../src/classes/Error.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAa,SAAQ,KAAK;IAKrC,YAAY,IAAY,EAAE,MAAc,EAAE,OAAe;QACvD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,UAAkB,cAAc;QAClD,OAAO,IAAI,YAAY,CAAC,cAAc,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,UAAkB,oBAAoB;QACpD,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,UAAkB,WAAW;QAC5C,OAAO,IAAI,YAAY,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,CAAC,SAAS,CAAC,UAAkB,0BAA0B;QAC3D,OAAO,IAAI,YAAY,CAAC,kBAAkB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,OAAO,GAAG,sBAAsB;QACzD,MAAM,IAAI,YAAY,CAAC,uBAAuB,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;CACF;AA/BD,oCA+BC"}
|
|
@@ -1,79 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
6
|
exports.checkModuleHealth = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function checkModuleHealth(clientName, serviceUrl, service, grpcToken) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return __generator(this, function (_a) {
|
|
49
|
-
switch (_a.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
channel = (0, nice_grpc_1.createChannel)(serviceUrl, undefined, {
|
|
52
|
-
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
53
|
-
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
54
|
-
});
|
|
55
|
-
clientFactory = (0, nice_grpc_1.createClientFactory)()
|
|
56
|
-
.use((0, clientMiddleware_1.clientMiddleware)())
|
|
57
|
-
.use(grpcToken
|
|
58
|
-
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(grpcToken)
|
|
59
|
-
: (0, interceptors_1.getModuleNameInterceptor)(clientName));
|
|
60
|
-
_healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, channel);
|
|
61
|
-
return [4 /*yield*/, _healthClient
|
|
62
|
-
.check({ service: service })
|
|
63
|
-
.then(function (res) {
|
|
64
|
-
return res.status;
|
|
65
|
-
})
|
|
66
|
-
.catch(function (err) { return (error = err); })];
|
|
67
|
-
case 1:
|
|
68
|
-
status = _a.sent();
|
|
69
|
-
channel.close();
|
|
70
|
-
if (!error) {
|
|
71
|
-
return [2 /*return*/, status];
|
|
72
|
-
}
|
|
73
|
-
throw error;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
7
|
+
const interceptors_1 = require("../interceptors");
|
|
8
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
9
|
+
const grpc_health_check_1 = require("../protoUtils/grpc_health_check");
|
|
10
|
+
const index_1 = __importDefault(require("../index"));
|
|
11
|
+
async function checkModuleHealth(clientName, serviceUrl, service = '', grpcToken) {
|
|
12
|
+
const channel = (0, nice_grpc_1.createChannel)(serviceUrl, undefined, {
|
|
13
|
+
'grpc.max_receive_message_length': 1024 * 1024 * 100,
|
|
14
|
+
'grpc.max_send_message_length': 1024 * 1024 * 100,
|
|
76
15
|
});
|
|
16
|
+
const clientFactory = (0, nice_grpc_1.createClientFactory)();
|
|
17
|
+
for (const interceptor of index_1.default.interceptors) {
|
|
18
|
+
clientFactory.use(interceptor);
|
|
19
|
+
}
|
|
20
|
+
clientFactory.use(grpcToken
|
|
21
|
+
? (0, interceptors_1.getGrpcSignedTokenInterceptor)(grpcToken)
|
|
22
|
+
: (0, interceptors_1.getModuleNameInterceptor)(clientName));
|
|
23
|
+
const _healthClient = clientFactory.create(grpc_health_check_1.HealthDefinition, channel);
|
|
24
|
+
let error;
|
|
25
|
+
const status = await _healthClient
|
|
26
|
+
.check({ service })
|
|
27
|
+
.then((res) => {
|
|
28
|
+
return res.status;
|
|
29
|
+
})
|
|
30
|
+
.catch(err => (error = err));
|
|
31
|
+
channel.close();
|
|
32
|
+
if (!error) {
|
|
33
|
+
return status;
|
|
34
|
+
}
|
|
35
|
+
throw error;
|
|
77
36
|
}
|
|
78
37
|
exports.checkModuleHealth = checkModuleHealth;
|
|
79
38
|
//# sourceMappingURL=HealthCheck.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HealthCheck.js","sourceRoot":"","sources":["../../src/classes/HealthCheck.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HealthCheck.js","sourceRoot":"","sources":["../../src/classes/HealthCheck.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0F;AAC1F,yCAA+D;AAC/D,uEAAwF;AACxF,qDAAsC;AAE/B,KAAK,UAAU,iBAAiB,CACrC,UAAkB,EAClB,UAAkB,EAClB,UAAkB,EAAE,EACpB,SAAkB;IAElB,MAAM,OAAO,GAAG,IAAA,yBAAa,EAAC,UAAU,EAAE,SAAS,EAAE;QACnD,iCAAiC,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;QACpD,8BAA8B,EAAE,IAAI,GAAG,IAAI,GAAG,GAAG;KAClD,CAAC,CAAC;IACH,MAAM,aAAa,GAAG,IAAA,+BAAmB,GAAE,CAAC;IAC5C,KAAK,MAAM,WAAW,IAAI,eAAc,CAAC,YAAY,EAAE;QACrD,aAAa,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;KAChC;IACD,aAAa,CAAC,GAAG,CACf,SAAS;QACP,CAAC,CAAC,IAAA,4CAA6B,EAAC,SAAS,CAAC;QAC1C,CAAC,CAAC,IAAA,uCAAwB,EAAC,UAAU,CAAC,CACzC,CAAC;IACF,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,oCAAgB,EAAE,OAAO,CAAC,CAAC;IAEtE,IAAI,KAAK,CAAC;IACV,MAAM,MAAM,GAAG,MAAM,aAAa;SAC/B,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;SAClB,IAAI,CAAC,CAAC,GAAwB,EAAE,EAAE;QACjC,OAAO,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,EAAE,CAAC;IAChB,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,MAAM,CAAC;KACf;IACD,MAAM,KAAK,CAAC;AACd,CAAC;AAjCD,8CAiCC"}
|
package/dist/classes/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
export * from './Error';
|
|
2
|
+
export * from './ConduitModule';
|
|
3
|
+
export * from './HealthCheck';
|
|
2
4
|
export * from './ConduitSchema';
|
|
3
|
-
export * from './ConduitActiveSchema';
|
|
4
|
-
export * from './GrpcServer';
|
|
5
|
-
export * from './ConduitServiceModule';
|
|
6
|
-
export * from './ManagedModule';
|
|
7
|
-
export * from './ModuleManager';
|
|
8
|
-
export * from './ConfigController';
|
|
9
5
|
export * from './ConduitAuthorizedResource';
|
package/dist/classes/index.js
CHANGED
|
@@ -15,12 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./Error"), exports);
|
|
18
|
+
__exportStar(require("./ConduitModule"), exports);
|
|
19
|
+
__exportStar(require("./HealthCheck"), exports);
|
|
18
20
|
__exportStar(require("./ConduitSchema"), exports);
|
|
19
|
-
__exportStar(require("./ConduitActiveSchema"), exports);
|
|
20
|
-
__exportStar(require("./GrpcServer"), exports);
|
|
21
|
-
__exportStar(require("./ConduitServiceModule"), exports);
|
|
22
|
-
__exportStar(require("./ManagedModule"), exports);
|
|
23
|
-
__exportStar(require("./ModuleManager"), exports);
|
|
24
|
-
__exportStar(require("./ConfigController"), exports);
|
|
25
21
|
__exportStar(require("./ConduitAuthorizedResource"), exports);
|
|
26
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,kDAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/classes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,kDAAgC;AAChC,gDAA8B;AAC9B,kDAAgC;AAChC,8DAA4C"}
|