grpc-js-reflection-client 1.4.0-alpha-0 → 1.4.0-alpha-1
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/package.json +12 -12
- package/dist/examples/getProtoObj.d.ts +0 -1
- package/dist/examples/getProtoObj.js +0 -28
- package/dist/examples/getProtoObj.js.map +0 -1
- package/dist/examples/listServices.d.ts +0 -1
- package/dist/examples/listServices.js +0 -14
- package/dist/examples/listServices.js.map +0 -1
- package/dist/examples/otherMethods.d.ts +0 -1
- package/dist/examples/otherMethods.js +0 -21
- package/dist/examples/otherMethods.js.map +0 -1
- package/dist/src/Descriptor.d.ts +0 -19
- package/dist/src/Descriptor.js +0 -38
- package/dist/src/Descriptor.js.map +0 -1
- package/dist/src/Exceptions/ReflectionException.d.ts +0 -2
- package/dist/src/Exceptions/ReflectionException.js +0 -7
- package/dist/src/Exceptions/ReflectionException.js.map +0 -1
- package/dist/src/Exceptions/ReflectionRequestException.d.ts +0 -2
- package/dist/src/Exceptions/ReflectionRequestException.js +0 -7
- package/dist/src/Exceptions/ReflectionRequestException.js.map +0 -1
- package/dist/src/Exceptions/index.d.ts +0 -2
- package/dist/src/Exceptions/index.js +0 -19
- package/dist/src/Exceptions/index.js.map +0 -1
- package/dist/src/GrpcReflection.d.ts +0 -23
- package/dist/src/GrpcReflection.js +0 -152
- package/dist/src/GrpcReflection.js.map +0 -1
- package/dist/src/Helpers/index.d.ts +0 -2
- package/dist/src/Helpers/index.js +0 -19
- package/dist/src/Helpers/index.js.map +0 -1
- package/dist/src/Helpers/packageObjectHelper.d.ts +0 -16
- package/dist/src/Helpers/packageObjectHelper.js +0 -13
- package/dist/src/Helpers/packageObjectHelper.js.map +0 -1
- package/dist/src/Helpers/serviceHelper.d.ts +0 -5
- package/dist/src/Helpers/serviceHelper.js +0 -20
- package/dist/src/Helpers/serviceHelper.js.map +0 -1
- package/dist/src/Helpers/serviceHelper.spec.d.ts +0 -1
- package/dist/src/Helpers/serviceHelper.spec.js +0 -73
- package/dist/src/Helpers/serviceHelper.spec.js.map +0 -1
- package/dist/src/Proto/v1.d.ts +0 -299
- package/dist/src/Proto/v1.js +0 -843
- package/dist/src/Proto/v1.js.map +0 -1
- package/dist/src/Proto/v1alpha.d.ts +0 -299
- package/dist/src/Proto/v1alpha.js +0 -843
- package/dist/src/Proto/v1alpha.js.map +0 -1
- package/dist/src/Types/ListMethodsType.d.ts +0 -5
- package/dist/src/Types/ListMethodsType.js +0 -3
- package/dist/src/Types/ListMethodsType.js.map +0 -1
- package/dist/src/Types/getAllExtensionNumbersOfTypeType.d.ts +0 -4
- package/dist/src/Types/getAllExtensionNumbersOfTypeType.js +0 -3
- package/dist/src/Types/getAllExtensionNumbersOfTypeType.js.map +0 -1
- package/dist/src/Types/index.d.ts +0 -1
- package/dist/src/Types/index.js +0 -18
- package/dist/src/Types/index.js.map +0 -1
- package/dist/src/index.d.ts +0 -5
- package/dist/src/index.js +0 -22
- package/dist/src/index.js.map +0 -1
- package/dist/tests/e2e/addressbook.test.d.ts +0 -1
- package/dist/tests/e2e/addressbook.test.js +0 -37
- package/dist/tests/e2e/addressbook.test.js.map +0 -1
- package/dist/tests/e2e/grpc-node-grpc-reflection-server/server.d.ts +0 -1
- package/dist/tests/e2e/grpc-node-grpc-reflection-server/server.js +0 -29
- package/dist/tests/e2e/grpc-node-grpc-reflection-server/server.js.map +0 -1
- package/dist/tests/e2e/grpc-node-server-reflection/server.d.ts +0 -1
- package/dist/tests/e2e/grpc-node-server-reflection/server.js +0 -29
- package/dist/tests/e2e/grpc-node-server-reflection/server.js.map +0 -1
- package/dist/tests/e2e/grpc-reflection-server.test.d.ts +0 -1
- package/dist/tests/e2e/grpc-reflection-server.test.js +0 -36
- package/dist/tests/e2e/grpc-reflection-server.test.js.map +0 -1
- package/dist/tests/e2e/helloWorld.test.d.ts +0 -1
- package/dist/tests/e2e/helloWorld.test.js +0 -76
- package/dist/tests/e2e/helloWorld.test.js.map +0 -1
- package/dist/tests/e2e/helpers.test.d.ts +0 -1
- package/dist/tests/e2e/helpers.test.js +0 -52
- package/dist/tests/e2e/helpers.test.js.map +0 -1
- package/dist/tests/e2e/listMethods.test.d.ts +0 -1
- package/dist/tests/e2e/listMethods.test.js +0 -24
- package/dist/tests/e2e/listMethods.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grpc-js-reflection-client",
|
|
3
|
-
"version": "1.4.0-alpha-
|
|
3
|
+
"version": "1.4.0-alpha-1",
|
|
4
4
|
"description": "Package use Grpc reflection api to download grpc proto descriptor. Now you don't have to add proto file to each package. Simple direct download proto package from example microservice without any files.",
|
|
5
5
|
"author": "gawsoft.com",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"prepack": "npm run build",
|
|
15
15
|
"prepare": "npm run build",
|
|
16
16
|
"prebuild": "rimraf dist",
|
|
17
|
-
"build": "tsc",
|
|
17
|
+
"build": "tsc -p tsconfig.build.json",
|
|
18
18
|
"release": "bin/release.sh",
|
|
19
19
|
"test:start-node-server": "ts-node tests/e2e/grpc-node-server-reflection/server.ts",
|
|
20
20
|
"test:start-node-server2": "ts-node tests/e2e/grpc-node-grpc-reflection-server/server.ts",
|
|
@@ -28,25 +28,25 @@
|
|
|
28
28
|
"url": "https://github.com/gawsoftpl/grpc-js-reflection-api-client.git"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@grpc/grpc-js": "^1.14.
|
|
31
|
+
"@grpc/grpc-js": "^1.14.3"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"lodash": "^4.
|
|
35
|
-
"
|
|
34
|
+
"lodash": "^4.18.1",
|
|
35
|
+
"google-protobuf": "^4.0.2",
|
|
36
|
+
"protobufjs": "^8.0.1"
|
|
36
37
|
},
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@grpc/reflection": "^1.0.4",
|
|
39
40
|
"@types/jest": "^30.0.0",
|
|
40
|
-
"@types/node": "^
|
|
41
|
-
"@types/lodash": "^4.17.
|
|
42
|
-
"grpc-node-server-reflection": "^1.0.2",
|
|
41
|
+
"@types/node": "^25.6.0",
|
|
42
|
+
"@types/lodash": "^4.17.24",
|
|
43
43
|
"jest": "^30.2.0",
|
|
44
44
|
"reflect-metadata": "^0.2.2",
|
|
45
|
-
"rimraf": "^6.1.
|
|
46
|
-
"ts-jest": "^29.4.
|
|
47
|
-
"ts-loader": "^9.5.
|
|
45
|
+
"rimraf": "^6.1.3",
|
|
46
|
+
"ts-jest": "^29.4.9",
|
|
47
|
+
"ts-loader": "^9.5.7",
|
|
48
48
|
"ts-node": "^10.9.2",
|
|
49
|
-
"typescript": "^
|
|
49
|
+
"typescript": "^6.0.3"
|
|
50
50
|
},
|
|
51
51
|
"jest": {
|
|
52
52
|
"moduleFileExtensions": [
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const GrpcReflection_1 = require("../src/GrpcReflection");
|
|
4
|
-
const grpc = require("@grpc/grpc-js");
|
|
5
|
-
try {
|
|
6
|
-
(async () => {
|
|
7
|
-
const client = new GrpcReflection_1.GrpcReflection('0.0.0.0:3000', grpc.credentials.createInsecure());
|
|
8
|
-
const descriptor = await client.getDescriptorBySymbol('apidata');
|
|
9
|
-
const packageObject = descriptor.getPackageObject({
|
|
10
|
-
keepCase: true,
|
|
11
|
-
enums: String,
|
|
12
|
-
longs: String
|
|
13
|
-
});
|
|
14
|
-
var proto = new packageObject.apidata.ApiKeyService('0.0.0.0:3000', grpc.credentials.createInsecure());
|
|
15
|
-
var metadata = new grpc.Metadata();
|
|
16
|
-
metadata.add('authorization', "abc");
|
|
17
|
-
proto.Add({ "user_id": "A" }, metadata, (d) => {
|
|
18
|
-
console.log(d);
|
|
19
|
-
});
|
|
20
|
-
proto.Add({ "user_id": "A" }, metadata, (d) => {
|
|
21
|
-
console.log(d);
|
|
22
|
-
});
|
|
23
|
-
})();
|
|
24
|
-
}
|
|
25
|
-
catch (e) {
|
|
26
|
-
console.log(e);
|
|
27
|
-
}
|
|
28
|
-
//# sourceMappingURL=getProtoObj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getProtoObj.js","sourceRoot":"","sources":["../../examples/getProtoObj.ts"],"names":[],"mappings":";;AACA,0DAAuD;AACvD,sCAAsC;AAMtC,IAAI,CAAC;IACD,CAAC,KAAK,IAAI,EAAE;QACR,MAAM,MAAM,GAAG,IAAI,+BAAc,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;QAGrF,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAGjE,MAAM,aAAa,GAAG,UAAU,CAAC,gBAAgB,CAAC;YAC9C,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,MAAM;SAChB,CAAC,CAAC;QAIH,IAAI,KAAK,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,aAAa,CAC/C,cAAc,EACd,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CACpC,CAAC;QAGF,IAAI,QAAQ,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACnC,QAAQ,CAAC,GAAG,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;QAGrC,KAAK,CAAC,GAAG,CAAC,EAAC,SAAS,EAAC,GAAG,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAC,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,KAAK,CAAC,GAAG,CAAC,EAAC,SAAS,EAAC,GAAG,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAC,EAAE;YACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;IAEP,CAAC,CAAC,EAAE,CAAC;AAET,CAAC;AAAA,OAAM,CAAC,EAAC,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const GrpcReflection_1 = require("../src/GrpcReflection");
|
|
4
|
-
const grpc = require("@grpc/grpc-js");
|
|
5
|
-
try {
|
|
6
|
-
(async () => {
|
|
7
|
-
const c = new GrpcReflection_1.GrpcReflection('0.0.0.0:3000', grpc.credentials.createInsecure());
|
|
8
|
-
console.log(await c.listServices());
|
|
9
|
-
})();
|
|
10
|
-
}
|
|
11
|
-
catch (e) {
|
|
12
|
-
console.log(e);
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=listServices.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"listServices.js","sourceRoot":"","sources":["../../examples/listServices.ts"],"names":[],"mappings":";;AACA,0DAAuD;AAEvD,sCAAsC;AAKtC,IAAI,CAAC;IACD,CAAC,KAAK,IAAI,EAAE;QACR,MAAM,CAAC,GAAG,IAAI,+BAAc,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;IACxC,CAAC,CAAC,EAAE,CAAC;AAET,CAAC;AAAA,OAAM,CAAC,EAAC,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const GrpcReflection_1 = require("../src/GrpcReflection");
|
|
4
|
-
const grpc = require("@grpc/grpc-js");
|
|
5
|
-
try {
|
|
6
|
-
(async () => {
|
|
7
|
-
const c = new GrpcReflection_1.GrpcReflection('0.0.0.0:3000', grpc.credentials.createInsecure());
|
|
8
|
-
const descriptor = await c.getDescriptorBySymbol('apidata');
|
|
9
|
-
const descriptorMessage = descriptor.getDescriptorMessage();
|
|
10
|
-
console.log(descriptorMessage);
|
|
11
|
-
const packageDefinition = descriptor.getPackageDefinition({
|
|
12
|
-
keepCase: true,
|
|
13
|
-
enums: String
|
|
14
|
-
});
|
|
15
|
-
const buffer = descriptor.getDescriptorBuffer();
|
|
16
|
-
})();
|
|
17
|
-
}
|
|
18
|
-
catch (e) {
|
|
19
|
-
console.log(e);
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=otherMethods.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otherMethods.js","sourceRoot":"","sources":["../../examples/otherMethods.ts"],"names":[],"mappings":";;AACA,0DAAuD;AACvD,sCAAsC;AAKtC,IAAI,CAAC;IACD,CAAC,KAAK,IAAI,EAAE;QACR,MAAM,CAAC,GAAG,IAAI,+BAAc,CAAC,cAAc,EAAE,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,CAAC;QAGhF,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC;QAG5D,MAAM,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,EAAE,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAG/B,MAAM,iBAAiB,GAAG,UAAU,CAAC,oBAAoB,CAAC;YACtD,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,MAAM;SAChB,CAAC,CAAC;QAIH,MAAM,MAAM,GAAG,UAAU,CAAC,mBAAmB,EAAE,CAAC;IAGpD,CAAC,CAAC,EAAE,CAAC;AAET,CAAC;AAAA,OAAM,CAAC,EAAC,CAAC;IACN,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AACnB,CAAC"}
|
package/dist/src/Descriptor.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Root } from 'protobufjs';
|
|
2
|
-
import * as descriptor from 'protobufjs/ext/descriptor';
|
|
3
|
-
import * as protoLoader from '@grpc/proto-loader';
|
|
4
|
-
import * as grpc from '@grpc/grpc-js';
|
|
5
|
-
import { PackageDefinition } from "@grpc/proto-loader";
|
|
6
|
-
declare module 'protobufjs' {
|
|
7
|
-
interface Root {
|
|
8
|
-
toDescriptor(syntax: string): protobuf.Message;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export declare class Descriptor {
|
|
12
|
-
private root;
|
|
13
|
-
constructor(protoBufJsRoot: Root);
|
|
14
|
-
getProtobufJsRoot(): Root;
|
|
15
|
-
getDescriptorMessage(syntax?: string): import("protobufjs").Message<descriptor.IFileDescriptorSet> & descriptor.IFileDescriptorSet;
|
|
16
|
-
getDescriptorBuffer(syntax?: string): Uint8Array;
|
|
17
|
-
getPackageDefinition(options?: protoLoader.Options, syntax?: string): PackageDefinition;
|
|
18
|
-
getPackageObject(options?: protoLoader.Options): grpc.GrpcObject;
|
|
19
|
-
}
|
package/dist/src/Descriptor.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Descriptor = void 0;
|
|
4
|
-
const descriptor = require("protobufjs/ext/descriptor");
|
|
5
|
-
const protoLoader = require("@grpc/proto-loader");
|
|
6
|
-
const grpc = require("@grpc/grpc-js");
|
|
7
|
-
class Descriptor {
|
|
8
|
-
constructor(protoBufJsRoot) {
|
|
9
|
-
this.root = protoBufJsRoot;
|
|
10
|
-
if (typeof this.root.toDescriptor !== 'function') {
|
|
11
|
-
throw new Error("Protobuf.js 'ext/descriptor' module was not correctly loaded.");
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
getProtobufJsRoot() {
|
|
15
|
-
return this.root;
|
|
16
|
-
}
|
|
17
|
-
getDescriptorMessage(syntax = "proto3") {
|
|
18
|
-
return this.root.toDescriptor(syntax);
|
|
19
|
-
}
|
|
20
|
-
getDescriptorBuffer(syntax = "proto3") {
|
|
21
|
-
const message = this.getDescriptorMessage(syntax);
|
|
22
|
-
return descriptor.FileDescriptorSet.encode(message).finish();
|
|
23
|
-
}
|
|
24
|
-
getPackageDefinition(options, syntax = "proto3") {
|
|
25
|
-
const bufferDescription = Buffer.from(this.getDescriptorBuffer(syntax));
|
|
26
|
-
return protoLoader.loadFileDescriptorSetFromBuffer(bufferDescription, options !== null && options !== void 0 ? options : {
|
|
27
|
-
defaults: true,
|
|
28
|
-
enums: String,
|
|
29
|
-
longs: String,
|
|
30
|
-
oneofs: true,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
getPackageObject(options) {
|
|
34
|
-
return grpc.loadPackageDefinition(this.getPackageDefinition(options));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.Descriptor = Descriptor;
|
|
38
|
-
//# sourceMappingURL=Descriptor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Descriptor.js","sourceRoot":"","sources":["../../src/Descriptor.ts"],"names":[],"mappings":";;;AAGA,wDAAwD;AACxD,kDAAkD;AAClD,sCAAsC;AAStC,MAAa,UAAU;IAInB,YAAY,cAAoB;QAC5B,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAG3B,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;QACrF,CAAC;IACL,CAAC;IAED,iBAAiB;QACb,OAAO,IAAI,CAAC,IAAI,CAAC;IACrB,CAAC;IAOD,oBAAoB,CAAC,SAAiB,QAAQ;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;IAKD,mBAAmB,CAAC,SAAiB,QAAQ;QACzC,MAAM,OAAO,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAElD,OAAO,UAAU,CAAC,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC;IAED,oBAAoB,CAAC,OAA6B,EAAE,SAAiB,QAAQ;QACzE,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC;QACxE,OAAO,WAAW,CAAC,+BAA+B,CAAC,iBAAiB,EAAE,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI;YAC7E,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,MAAM;YACb,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,IAAI;SACf,CAAC,CAAC;IACP,CAAC;IAED,gBAAgB,CAAC,OAA6B;QAC1C,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC,CAAC;IAC1E,CAAC;CACJ;AAhDD,gCAgDC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReflectionException = void 0;
|
|
4
|
-
class ReflectionException extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.ReflectionException = ReflectionException;
|
|
7
|
-
//# sourceMappingURL=ReflectionException.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReflectionException.js","sourceRoot":"","sources":["../../../src/Exceptions/ReflectionException.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;CAAE;AAAhD,kDAAgD"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReflectionRequestException = void 0;
|
|
4
|
-
class ReflectionRequestException extends Error {
|
|
5
|
-
}
|
|
6
|
-
exports.ReflectionRequestException = ReflectionRequestException;
|
|
7
|
-
//# sourceMappingURL=ReflectionRequestException.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ReflectionRequestException.js","sourceRoot":"","sources":["../../../src/Exceptions/ReflectionRequestException.ts"],"names":[],"mappings":";;;AAAA,MAAa,0BAA2B,SAAQ,KAAK;CAAE;AAAvD,gEAAuD"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./ReflectionException"), exports);
|
|
18
|
-
__exportStar(require("./ReflectionRequestException"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Exceptions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAsC;AACtC,+DAA6C"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import { Descriptor } from "./Descriptor";
|
|
3
|
-
import { GetAllExtensionNumbersOfType } from "./Types";
|
|
4
|
-
import { ListMethodsType } from "./Types/ListMethodsType";
|
|
5
|
-
export declare class GrpcReflection {
|
|
6
|
-
private client;
|
|
7
|
-
private version;
|
|
8
|
-
private reflectionRequestConstructor;
|
|
9
|
-
constructor(host: string, credentials: any, options?: grpc.ChannelOptions, version?: string);
|
|
10
|
-
listServices(prefix?: string, options?: grpc.CallOptions): Promise<Array<string>>;
|
|
11
|
-
listMethods(service: string, options?: grpc.CallOptions): Promise<Array<ListMethodsType>>;
|
|
12
|
-
protected generateServicePath(service: string): Array<string>;
|
|
13
|
-
getServiceMethods(descriptor: grpc.GrpcObject, service: string): Array<ListMethodsType>;
|
|
14
|
-
getDescriptorByFileName(file_name: string, options?: grpc.CallOptions): Promise<Descriptor>;
|
|
15
|
-
getDescriptorBySymbol(symbol: string, options?: grpc.CallOptions): Promise<Descriptor>;
|
|
16
|
-
getAllExtensionNumbersOfType(package_type: string, options?: grpc.CallOptions): Promise<GetAllExtensionNumbersOfType>;
|
|
17
|
-
private request;
|
|
18
|
-
private resolveFileDescriptorSet;
|
|
19
|
-
private resolveDescriptorRecursive;
|
|
20
|
-
private getProtoDescriptorBySymbol;
|
|
21
|
-
private getProtoDescriptorByFileName;
|
|
22
|
-
private setProtoReflectionClient;
|
|
23
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GrpcReflection = void 0;
|
|
4
|
-
const Exceptions_1 = require("./Exceptions");
|
|
5
|
-
const protobufjs = require("protobufjs");
|
|
6
|
-
const Descriptor_1 = require("./Descriptor");
|
|
7
|
-
const descriptor_1 = require("protobufjs/ext/descriptor");
|
|
8
|
-
const lodash_1 = require("lodash");
|
|
9
|
-
const v1 = require("./Proto/v1");
|
|
10
|
-
const v1alpha = require("./Proto/v1alpha");
|
|
11
|
-
class GrpcReflection {
|
|
12
|
-
constructor(host, credentials, options = {}, version = "v1alpha") {
|
|
13
|
-
this.version = version;
|
|
14
|
-
this.setProtoReflectionClient(host, credentials, options);
|
|
15
|
-
}
|
|
16
|
-
async listServices(prefix = '*', options = {}) {
|
|
17
|
-
const response = await this.request({
|
|
18
|
-
listServices: prefix
|
|
19
|
-
}, options);
|
|
20
|
-
return response.listServicesResponse.service.map(service => service.name);
|
|
21
|
-
}
|
|
22
|
-
async listMethods(service, options = {}) {
|
|
23
|
-
const descriptor = await this.getDescriptorBySymbol(service, options);
|
|
24
|
-
const packageObject = descriptor.getPackageObject({
|
|
25
|
-
keepCase: true,
|
|
26
|
-
enums: String,
|
|
27
|
-
longs: String
|
|
28
|
-
});
|
|
29
|
-
return this.getServiceMethods(packageObject, service);
|
|
30
|
-
}
|
|
31
|
-
generateServicePath(service) {
|
|
32
|
-
return service.split('.').reverse();
|
|
33
|
-
}
|
|
34
|
-
getServiceMethods(descriptor, service) {
|
|
35
|
-
let anti_recursive = 0;
|
|
36
|
-
let actualDescriptor = descriptor;
|
|
37
|
-
const path = this.generateServicePath(service);
|
|
38
|
-
do {
|
|
39
|
-
const serviceName = path.pop();
|
|
40
|
-
if (serviceName && serviceName in actualDescriptor) {
|
|
41
|
-
actualDescriptor = actualDescriptor[serviceName];
|
|
42
|
-
}
|
|
43
|
-
anti_recursive++;
|
|
44
|
-
} while (path.length > 0 && anti_recursive < 100);
|
|
45
|
-
if ('service' in actualDescriptor) {
|
|
46
|
-
return Object.entries(actualDescriptor.service)
|
|
47
|
-
.map(([methodName, methodDefinition]) => ({
|
|
48
|
-
name: methodName,
|
|
49
|
-
definition: methodDefinition
|
|
50
|
-
}));
|
|
51
|
-
}
|
|
52
|
-
throw new Exceptions_1.ReflectionRequestException('Not found service');
|
|
53
|
-
}
|
|
54
|
-
async getDescriptorByFileName(file_name, options = {}) {
|
|
55
|
-
const descriptor = await this.getProtoDescriptorByFileName(file_name, options);
|
|
56
|
-
return await this.resolveFileDescriptorSet(descriptor, options);
|
|
57
|
-
}
|
|
58
|
-
async getDescriptorBySymbol(symbol, options = {}) {
|
|
59
|
-
const descriptor = await this.getProtoDescriptorBySymbol(symbol, options);
|
|
60
|
-
return await this.resolveFileDescriptorSet(descriptor, options);
|
|
61
|
-
}
|
|
62
|
-
async getAllExtensionNumbersOfType(package_type, options = {}) {
|
|
63
|
-
const response = await this.request({
|
|
64
|
-
allExtensionNumbersOfType: package_type
|
|
65
|
-
}, options);
|
|
66
|
-
return {
|
|
67
|
-
base_type_name: response.allExtensionNumbersResponse.baseTypeName,
|
|
68
|
-
extension_number: typeof (response.allExtensionNumbersResponse.extensionNumber) !== "undefined" ? response.allExtensionNumbersResponse.extensionNumber : []
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
async request(payload, options) {
|
|
72
|
-
return new Promise((resolve, reject) => {
|
|
73
|
-
const payloadObject = this.reflectionRequestConstructor(payload);
|
|
74
|
-
const call = this.client.ServerReflectionInfo(options);
|
|
75
|
-
call.on('data', (data) => {
|
|
76
|
-
if (data.errorResponse) {
|
|
77
|
-
reject(new Exceptions_1.ReflectionRequestException(data.errorResponse.errorMessage));
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
resolve(data);
|
|
81
|
-
});
|
|
82
|
-
call.on('error', (err) => {
|
|
83
|
-
reject(new Exceptions_1.ReflectionRequestException(err));
|
|
84
|
-
});
|
|
85
|
-
call.on('end', () => { });
|
|
86
|
-
call.write(payloadObject);
|
|
87
|
-
call.end();
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
async resolveFileDescriptorSet(fileDescriptorProtoBytes, options) {
|
|
91
|
-
const fileDescriptorSet = descriptor_1.FileDescriptorSet.create();
|
|
92
|
-
const fileDescriptorProtos = await this.resolveDescriptorRecursive(fileDescriptorProtoBytes, options);
|
|
93
|
-
(0, lodash_1.set)(fileDescriptorSet, 'file', Array.from(fileDescriptorProtos.values()));
|
|
94
|
-
return new Descriptor_1.Descriptor(protobufjs.Root.fromDescriptor(fileDescriptorSet));
|
|
95
|
-
}
|
|
96
|
-
async resolveDescriptorRecursive(fileDescriptorProtoBytes, options) {
|
|
97
|
-
let fileDescriptorProtos = new Map();
|
|
98
|
-
let needsDependencyResolution = new Set();
|
|
99
|
-
for (const item of fileDescriptorProtoBytes) {
|
|
100
|
-
const fileDescriptorProto = descriptor_1.FileDescriptorProto.decode(item);
|
|
101
|
-
if (fileDescriptorProto.dependency) {
|
|
102
|
-
const dependencies = fileDescriptorProto.dependency;
|
|
103
|
-
for (const dep of dependencies) {
|
|
104
|
-
needsDependencyResolution.add(dep);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
if (!fileDescriptorProtos.has(fileDescriptorProto.name)) {
|
|
108
|
-
fileDescriptorProtos.set(fileDescriptorProto.name, fileDescriptorProto);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
for (const dep of needsDependencyResolution) {
|
|
112
|
-
if (fileDescriptorProtos.has(dep)) {
|
|
113
|
-
continue;
|
|
114
|
-
}
|
|
115
|
-
const depProtoBytes = await this.getProtoDescriptorByFileName(dep, options);
|
|
116
|
-
const protoDependencies = await this.resolveDescriptorRecursive(depProtoBytes, options);
|
|
117
|
-
fileDescriptorProtos = new Map([
|
|
118
|
-
...fileDescriptorProtos,
|
|
119
|
-
...protoDependencies,
|
|
120
|
-
]);
|
|
121
|
-
}
|
|
122
|
-
return fileDescriptorProtos;
|
|
123
|
-
}
|
|
124
|
-
async getProtoDescriptorBySymbol(symbol, options) {
|
|
125
|
-
const response = await this.request({
|
|
126
|
-
fileContainingSymbol: symbol
|
|
127
|
-
}, options);
|
|
128
|
-
return response.fileDescriptorResponse.fileDescriptorProto;
|
|
129
|
-
}
|
|
130
|
-
async getProtoDescriptorByFileName(file_name, options) {
|
|
131
|
-
const response = await this.request({
|
|
132
|
-
fileByFilename: file_name
|
|
133
|
-
}, options);
|
|
134
|
-
return response.fileDescriptorResponse.fileDescriptorProto;
|
|
135
|
-
}
|
|
136
|
-
setProtoReflectionClient(host, credentials, options = {}) {
|
|
137
|
-
switch (this.version) {
|
|
138
|
-
case 'v1':
|
|
139
|
-
this.client = new v1.grpc.reflection.v1.ServerReflectionClient(host, credentials, options);
|
|
140
|
-
this.reflectionRequestConstructor = v1.grpc.reflection.v1.ServerReflectionRequest.fromObject;
|
|
141
|
-
break;
|
|
142
|
-
case 'v1alpha':
|
|
143
|
-
this.client = new v1alpha.grpc.reflection.v1alpha.ServerReflectionClient(host, credentials, options);
|
|
144
|
-
this.reflectionRequestConstructor = v1alpha.grpc.reflection.v1alpha.ServerReflectionRequest.fromObject;
|
|
145
|
-
break;
|
|
146
|
-
default:
|
|
147
|
-
throw new Exceptions_1.ReflectionRequestException('Unknown proto version available: [v1, v1alpha]');
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
exports.GrpcReflection = GrpcReflection;
|
|
152
|
-
//# sourceMappingURL=GrpcReflection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GrpcReflection.js","sourceRoot":"","sources":["../../src/GrpcReflection.ts"],"names":[],"mappings":";;;AACA,6CAA0D;AAC1D,yCAAyC;AACzC,6CAA0C;AAE1C,0DAImC;AACnC,mCAA6B;AAG7B,iCAAkC;AAClC,2CAA4C;AAG5C,MAAa,cAAc;IAKvB,YACI,IAAY,EACZ,WAAgB,EAChB,UAA+B,EAAE,EACjC,UAAkB,SAAS;QAE3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,wBAAwB,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,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gDAAgD,CAAC,CAAA;QAC1F,CAAC;IACT,CAAC;CACJ;AA7QD,wCA6QC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./packageObjectHelper"), exports);
|
|
18
|
-
__exportStar(require("./serviceHelper"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/Helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,kDAA+B"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ChannelCredentials, GrpcObject } from "@grpc/grpc-js";
|
|
2
|
-
import { Options } from "@grpc/proto-loader";
|
|
3
|
-
type DescriptorServiceHelperOptionsByProtoFileName = {
|
|
4
|
-
proto_filename: string;
|
|
5
|
-
};
|
|
6
|
-
type DescriptorServiceHelperOptionsByProtoSymbol = {
|
|
7
|
-
proto_symbol: string;
|
|
8
|
-
};
|
|
9
|
-
type DescriptorServiceHelperOptionsSelector = DescriptorServiceHelperOptionsByProtoFileName | DescriptorServiceHelperOptionsByProtoSymbol;
|
|
10
|
-
export type DescriptorServiceHelperOptions = {
|
|
11
|
-
host: string;
|
|
12
|
-
credentials: ChannelCredentials;
|
|
13
|
-
protoLoaderOptions?: Options;
|
|
14
|
-
} & DescriptorServiceHelperOptionsSelector;
|
|
15
|
-
export declare const packageObjectHelper: <T = GrpcObject>(options: DescriptorServiceHelperOptions) => Promise<T>;
|
|
16
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.packageObjectHelper = void 0;
|
|
4
|
-
const GrpcReflection_1 = require("../GrpcReflection");
|
|
5
|
-
const packageObjectHelper = async (options) => {
|
|
6
|
-
const client = new GrpcReflection_1.GrpcReflection(options.host, options.credentials);
|
|
7
|
-
const descriptor = 'proto_filename' in options
|
|
8
|
-
? await client.getDescriptorByFileName(options.proto_filename)
|
|
9
|
-
: await client.getDescriptorBySymbol(options.proto_symbol);
|
|
10
|
-
return descriptor.getPackageObject(options.protoLoaderOptions);
|
|
11
|
-
};
|
|
12
|
-
exports.packageObjectHelper = packageObjectHelper;
|
|
13
|
-
//# sourceMappingURL=packageObjectHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"packageObjectHelper.js","sourceRoot":"","sources":["../../../src/Helpers/packageObjectHelper.ts"],"names":[],"mappings":";;;AAEA,sDAAiD;AAmC1C,MAAM,mBAAmB,GAAG,KAAK,EAAe,OAAuC,EAAe,EAAE;IAG3G,MAAM,MAAM,GAAG,IAAI,+BAAc,CAC7B,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,WAAW,CACtB,CAAC;IAGF,MAAM,UAAU,GACZ,gBAAgB,IAAI,OAAO;QACvB,CAAC,CAAC,MAAM,MAAM,CAAC,uBAAuB,CAAC,OAAO,CAAC,cAAc,CAAC;QAC9D,CAAC,CAAC,MAAM,MAAM,CAAC,qBAAqB,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAGnE,OAAO,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,kBAAkB,CAAM,CAAC;AACxE,CAAC,CAAA;AAhBY,QAAA,mBAAmB,uBAgB/B"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.serviceHelper = void 0;
|
|
4
|
-
const packageObjectHelper_1 = require("./packageObjectHelper");
|
|
5
|
-
const serviceHelper = async (options) => {
|
|
6
|
-
const packageObject = await (0, packageObjectHelper_1.packageObjectHelper)(options);
|
|
7
|
-
const pathToService = options.servicePath.split('.');
|
|
8
|
-
let service = packageObject;
|
|
9
|
-
let concatenatePath = [];
|
|
10
|
-
do {
|
|
11
|
-
const servicePath = pathToService.shift();
|
|
12
|
-
concatenatePath.push(servicePath);
|
|
13
|
-
if (!(servicePath in service))
|
|
14
|
-
throw new Error(`Wrong servicePath ${concatenatePath.join('.')} do not exists in packageObject. Try method: listServices in GrpcReflection class to list all services in grpc server`);
|
|
15
|
-
service = service[servicePath];
|
|
16
|
-
} while (pathToService.length > 0);
|
|
17
|
-
return new service(options.host, options.credentials);
|
|
18
|
-
};
|
|
19
|
-
exports.serviceHelper = serviceHelper;
|
|
20
|
-
//# sourceMappingURL=serviceHelper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serviceHelper.js","sourceRoot":"","sources":["../../../src/Helpers/serviceHelper.ts"],"names":[],"mappings":";;;AAAA,+DAA0F;AAsBnF,MAAM,aAAa,GAAG,KAAK,EAAI,OAAiC,EAAc,EAAE;IAEnF,MAAM,aAAa,GAAG,MAAM,IAAA,yCAAmB,EAAC,OAAO,CAAC,CAAC;IAEzD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,OAAO,GAAQ,aAAa,CAAC;IACjC,IAAI,eAAe,GAAG,EAAE,CAAC;IACzB,GAAG,CAAC;QACA,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,EAAE,CAAC;QAC1C,eAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAClC,IAAI,CAAC,CAAC,WAAW,IAAI,OAAO,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,eAAe,CAAC,IAAI,CAAC,GAAG,CAAC,uHAAuH,CAAC,CAAC;QACtN,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC,QAAM,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;IAGjC,OAAO,IAAI,OAAO,CACd,OAAO,CAAC,IAAI,EACZ,OAAO,CAAC,WAAW,CACtB,CAAC;AACN,CAAC,CAAA;AAnBY,QAAA,aAAa,iBAmBzB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const grpc = require("@grpc/grpc-js");
|
|
4
|
-
const proto_loader_1 = require("@grpc/proto-loader");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
jest.mock('./packageObjectHelper', () => {
|
|
7
|
-
const originalModule = jest.requireActual('./packageObjectHelper');
|
|
8
|
-
originalModule.packageObjectHelper = jest.fn().mockImplementation((options) => {
|
|
9
|
-
const packageDefinition = (0, proto_loader_1.loadSync)((0, path_1.join)(__dirname, `../../tests/protos/${options['proto_filename']}`), options.protoLoaderOptions);
|
|
10
|
-
return grpc.loadPackageDefinition(packageDefinition);
|
|
11
|
-
});
|
|
12
|
-
return Object.assign({ __esModule: true }, originalModule);
|
|
13
|
-
});
|
|
14
|
-
const serviceHelper_1 = require("./serviceHelper");
|
|
15
|
-
describe("Test Helpers", () => {
|
|
16
|
-
it('Should return grpc service for addressbook', (done) => {
|
|
17
|
-
(0, serviceHelper_1.serviceHelper)({
|
|
18
|
-
host: "localhost:545f4",
|
|
19
|
-
servicePath: "addressbook.AddressesService",
|
|
20
|
-
credentials: grpc.ChannelCredentials.createInsecure(),
|
|
21
|
-
proto_filename: 'addressbook.proto',
|
|
22
|
-
protoLoaderOptions: {
|
|
23
|
-
keepCase: true
|
|
24
|
-
}
|
|
25
|
-
}).then(d => {
|
|
26
|
-
expect(d['Add']).toBeDefined();
|
|
27
|
-
done();
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it('Should return grpc service for helloworld', (done) => {
|
|
31
|
-
(0, serviceHelper_1.serviceHelper)({
|
|
32
|
-
host: "localhost:545f4",
|
|
33
|
-
servicePath: "helloworld.Greeter",
|
|
34
|
-
credentials: grpc.ChannelCredentials.createInsecure(),
|
|
35
|
-
proto_filename: 'helloworld.proto',
|
|
36
|
-
protoLoaderOptions: {
|
|
37
|
-
keepCase: true
|
|
38
|
-
}
|
|
39
|
-
}).then(proto => {
|
|
40
|
-
expect(proto['SayHello']).toBeDefined();
|
|
41
|
-
done();
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
it('Should raise exception on wrong servicePath', (done) => {
|
|
45
|
-
(0, serviceHelper_1.serviceHelper)({
|
|
46
|
-
host: "localhost:545f4",
|
|
47
|
-
servicePath: "addressbook.WrongServiceName",
|
|
48
|
-
credentials: grpc.ChannelCredentials.createInsecure(),
|
|
49
|
-
proto_filename: 'addressbook.proto',
|
|
50
|
-
protoLoaderOptions: {
|
|
51
|
-
keepCase: true
|
|
52
|
-
}
|
|
53
|
-
}).catch(e => {
|
|
54
|
-
expect(e.message).toContain('Wrong servicePath');
|
|
55
|
-
done();
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
it('Should raise exception on wrong servicePath #2', (done) => {
|
|
59
|
-
(0, serviceHelper_1.serviceHelper)({
|
|
60
|
-
host: "localhost:545f4",
|
|
61
|
-
servicePath: "addressbook.AddressesService.WrongServicename",
|
|
62
|
-
credentials: grpc.ChannelCredentials.createInsecure(),
|
|
63
|
-
proto_filename: 'addressbook.proto',
|
|
64
|
-
protoLoaderOptions: {
|
|
65
|
-
keepCase: true
|
|
66
|
-
}
|
|
67
|
-
}).catch(e => {
|
|
68
|
-
expect(e.message).toContain('Wrong servicePath addressbook.AddressesService.WrongServicename');
|
|
69
|
-
done();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
//# sourceMappingURL=serviceHelper.spec.js.map
|