skyeye-sdk-js 1.0.8 → 1.0.9
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/src/SkyEyeClient.d.ts +4 -2
- package/dist/src/SkyEyeClient.js +51 -17
- package/dist/src/proto/dir.bat +37 -0
- package/dist/src/proto/protoc.bat +37 -0
- package/dist/src/proto/protoc.sh +32 -0
- package/dist/src/proto/skyeye_rpc.proto +3 -0
- package/dist/src/proto/skyeye_rpc_grpc_pb.js +77 -44
- package/dist/src/proto/skyeye_rpc_pb.js +328 -322
- package/dist/src/proto/tsconfig.json +118 -0
- package/dist/src/proto copy/skyeye_rpc.proto +11 -0
- package/dist/src/proto copy/skyeye_rpc_grpc_pb.js +44 -0
- package/dist/src/proto copy/skyeye_rpc_pb.d.ts +47 -0
- package/dist/src/proto copy/skyeye_rpc_pb.js +322 -0
- package/dist/test.js +18 -7
- package/package.json +11 -6
- package/src/SkyEyeClient.ts +52 -20
- package/src/proto/protoc.bat +37 -0
- package/src/proto/protoc.sh +32 -0
- package/src/proto/skyeye_rpc.proto +3 -0
- package/src/proto/skyeye_rpc_grpc_pb.js +77 -44
- package/src/proto/skyeye_rpc_pb.js +328 -322
- package/src/proto/tsconfig.json +118 -0
- package/src/proto_backup/skyeye_rpc.proto +11 -0
- package/src/proto_backup/skyeye_rpc_grpc_pb.js +44 -0
- package/src/proto_backup/skyeye_rpc_pb.d.ts +47 -0
- package/src/proto_backup/skyeye_rpc_pb.js +322 -0
- package/test.ts +22 -6
- package/dist/SkyEyeClient.d.ts +0 -71
- package/dist/SkyEyeClient.js +0 -831
- package/dist/SkyEyeClientFactory.d.ts +0 -10
- package/dist/SkyEyeClientFactory.js +0 -53
- /package/dist/src/{proto → proto copy}/skyeye_rpc_grpc_pb.d.ts +0 -0
- /package/src/{proto → proto_backup}/skyeye_rpc_grpc_pb.d.ts +0 -0
package/src/SkyEyeClient.ts
CHANGED
|
@@ -37,32 +37,40 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
constructor(host: string, port: string) {
|
|
40
|
-
super(host + ":" + port, grpc.credentials.createInsecure(),null);
|
|
40
|
+
super(host + ":" + port, grpc.credentials.createInsecure(), null);
|
|
41
41
|
this.host = host;
|
|
42
42
|
this.port = port;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
|
|
46
|
+
public async RunTestcase(json:string) {
|
|
47
|
+
try {
|
|
48
|
+
const request = new JSONRequest();
|
|
49
|
+
request.setRequest(json);
|
|
50
|
+
const stream = super.runTestcase(request);
|
|
51
|
+
return stream;
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.error("Error during RunTestcase:", error);
|
|
54
|
+
throw error;
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
|
|
59
|
+
public async Monitor(json:string) {
|
|
60
|
+
try {
|
|
61
|
+
const request = new JSONRequest();
|
|
62
|
+
request.setRequest(json);
|
|
63
|
+
const stream = super.Monitor(request);
|
|
64
|
+
return stream;
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.error("Error during RunTestcase:", error);
|
|
67
|
+
throw error;
|
|
62
68
|
}
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
|
|
72
|
+
|
|
73
|
+
|
|
66
74
|
public async call(request: JSONRequest) {
|
|
67
75
|
try {
|
|
68
76
|
this.printRequestLog(request)
|
|
@@ -86,6 +94,26 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
|
|
97
|
+
private printRequestLog(request: JSONRequest): void {
|
|
98
|
+
if (request.getRequest() != null) {
|
|
99
|
+
const base = JSON.parse(request.getRequest());
|
|
100
|
+
if (base.request.name === "SE_get_running_status" || base.request.name === "SE_get_all_class_info") {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
console.log("客户端请求-- ", JSON.stringify(base))
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
private printResponseLog(ackObj: any): void {
|
|
108
|
+
if (ackObj != null) {
|
|
109
|
+
const name = ackObj.name;
|
|
110
|
+
if (name === "SE_get_running_status" || name === "SE_get_all_class_info") {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
console.log(`客户端响应-- `, ackObj);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
89
117
|
|
|
90
118
|
public async runScriptRequest(filename: string) {
|
|
91
119
|
try {
|
|
@@ -770,20 +798,20 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
770
798
|
return this.port;
|
|
771
799
|
}
|
|
772
800
|
|
|
773
|
-
public initSkyEyeAndRun(pathSkyEye:string,fileName:string,
|
|
801
|
+
public initSkyEyeAndRun(pathSkyEye: string, fileName: string, port: string, skyeyeDir: string) {
|
|
774
802
|
console.log('runExample');
|
|
775
|
-
cp.exec(skyeyeDir+" -q "+port+"\n", (err: any, stdout: any, stderr: any) => {
|
|
803
|
+
cp.exec(skyeyeDir + " -q " + port + "\n", (err: any, stdout: any, stderr: any) => {
|
|
776
804
|
console.log('stdout: ' + stdout);
|
|
777
805
|
console.log('stderr: ' + stderr);
|
|
778
806
|
});
|
|
779
807
|
setTimeout(() => {
|
|
780
|
-
client = new JSONTransmissionClient('127.0.0.1:
|
|
808
|
+
client = new JSONTransmissionClient('127.0.0.1:' + port, grpc.credentials.createInsecure());
|
|
781
809
|
console.log('client:' + client);
|
|
782
810
|
const Jr = new JSONRequest();
|
|
783
811
|
Jr.setRequest("{\"request\": {\"name\": \"chdir\", \"args\": {\"path\":\"" + pathSkyEye + "\"}}}");
|
|
784
812
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
785
813
|
console.log("chdir res:" + response + error);
|
|
786
|
-
|
|
814
|
+
|
|
787
815
|
Jr.setRequest("{\"request\": {\"name\": \"run_script\", \"args\": {\"filename\":\"" + fileName + "\"}}}");
|
|
788
816
|
client.callSkyEye(Jr, (error: ServiceError | null, response: JSONResponse) => {
|
|
789
817
|
console.log("run_script res:" + response + error);
|
|
@@ -797,8 +825,12 @@ export class SkyEyeClient extends JSONTransmissionClient {
|
|
|
797
825
|
}
|
|
798
826
|
|
|
799
827
|
|
|
828
|
+
//与skyeye长连接
|
|
829
|
+
|
|
830
|
+
|
|
831
|
+
|
|
800
832
|
|
|
801
833
|
|
|
834
|
+
}
|
|
802
835
|
|
|
803
836
|
|
|
804
|
-
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
@echo off
|
|
2
|
+
|
|
3
|
+
rem set
|
|
4
|
+
rem cd /d D:\UpperComputer\develop\skyeye-sdk-js\src\proto2\protoc.bat
|
|
5
|
+
|
|
6
|
+
rem current dir
|
|
7
|
+
echo current dir %CD%
|
|
8
|
+
|
|
9
|
+
set PROTO_FILE=skyeye_rpc.proto
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
set PROTOC_GEN_TS_PATH=D:\UpperComputer\develop\skyeye-sdk-js\node_modules\.bin\protoc-gen-ts.cmd
|
|
13
|
+
set GRPC_TOOLS_NODE_PROTOC_PLUGIN=D:\UpperComputer\develop\skyeye-sdk-js\node_modules\.bin\grpc_tools_node_protoc_plugin.cmd
|
|
14
|
+
set GRPC_TOOLS_NODE_PROTOC=D:\UpperComputer\develop\skyeye-sdk-js\node_modules\.bin\grpc_tools_node_protoc.cmd
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
rem display path variables
|
|
19
|
+
echo PROTOC_GEN_TS_PATH: %PROTOC_GEN_TS_PATH%
|
|
20
|
+
echo GRPC_TOOLS_NODE_PROTOC_PLUGIN: %GRPC_TOOLS_NODE_PROTOC_PLUGIN%
|
|
21
|
+
echo GRPC_TOOLS_NODE_PROTOC: %GRPC_TOOLS_NODE_PROTOC%
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
rem 生成 JavaScript 文件
|
|
25
|
+
%GRPC_TOOLS_NODE_PROTOC% ^
|
|
26
|
+
--js_out=import_style=commonjs,binary:. ^
|
|
27
|
+
--grpc_out=. ^
|
|
28
|
+
--plugin=protoc-gen-grpc=%GRPC_TOOLS_NODE_PROTOC_PLUGIN% ^
|
|
29
|
+
-I . ^
|
|
30
|
+
%PROTO_FILE%
|
|
31
|
+
|
|
32
|
+
rem 生成 TypeScript 文件
|
|
33
|
+
%GRPC_TOOLS_NODE_PROTOC% ^
|
|
34
|
+
--plugin=protoc-gen-ts=%PROTOC_GEN_TS_PATH% ^
|
|
35
|
+
--ts_out=. ^
|
|
36
|
+
-I . ^
|
|
37
|
+
%PROTO_FILE%
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
BASEDIR=$(dirname "$0")
|
|
4
|
+
cd "${BASEDIR}"/../
|
|
5
|
+
|
|
6
|
+
PROTOC_GEN_TS_PATH="./node_modules/.bin/protoc-gen-ts"
|
|
7
|
+
GRPC_TOOLS_NODE_PROTOC_PLUGIN="./node_modules/.bin/grpc_tools_node_protoc_plugin"
|
|
8
|
+
GRPC_TOOLS_NODE_PROTOC="./node_modules/.bin/grpc_tools_node_protoc"
|
|
9
|
+
|
|
10
|
+
for f in ./src/proto2/*; do
|
|
11
|
+
|
|
12
|
+
# skip the non proto files
|
|
13
|
+
if [ "$(basename "$f")" == "index.ts" ]; then
|
|
14
|
+
continue
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# loop over all the available proto files and compile them into respective dir
|
|
18
|
+
# JavaScript code generating
|
|
19
|
+
${GRPC_TOOLS_NODE_PROTOC} \
|
|
20
|
+
--js_out=import_style=commonjs,binary:"${f}" \
|
|
21
|
+
--grpc_out="${f}" \
|
|
22
|
+
--plugin=protoc-gen-grpc="${GRPC_TOOLS_NODE_PROTOC_PLUGIN}" \
|
|
23
|
+
-I "${f}" \
|
|
24
|
+
"${f}"/*.proto
|
|
25
|
+
|
|
26
|
+
${GRPC_TOOLS_NODE_PROTOC} \
|
|
27
|
+
--plugin=protoc-gen-ts="${PROTOC_GEN_TS_PATH}" \
|
|
28
|
+
--ts_out="${f}" \
|
|
29
|
+
-I "${f}" \
|
|
30
|
+
"${f}"/*.proto
|
|
31
|
+
|
|
32
|
+
done
|
|
@@ -2,6 +2,9 @@ syntax = "proto3";
|
|
|
2
2
|
|
|
3
3
|
service JSONTransmission {
|
|
4
4
|
rpc CallSkyEye (JSONRequest) returns (JSONResponse){}
|
|
5
|
+
rpc SkyEyeLogReport (JSONRequest) returns (stream JSONResponse){};
|
|
6
|
+
rpc RunTestcase (JSONRequest) returns (stream JSONResponse){};
|
|
7
|
+
rpc Monitor (JSONRequest) returns (stream JSONResponse){};
|
|
5
8
|
}
|
|
6
9
|
message JSONRequest {
|
|
7
10
|
string request = 1;
|
|
@@ -1,44 +1,77 @@
|
|
|
1
|
-
// GENERATED CODE -- DO NOT EDIT!
|
|
2
|
-
|
|
3
|
-
'use strict';
|
|
4
|
-
var grpc = require('
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
function serialize_JSONRequest(arg) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function deserialize_JSONRequest(buffer_arg) {
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function serialize_JSONResponse(arg) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function deserialize_JSONResponse(buffer_arg) {
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var JSONTransmissionService = exports.JSONTransmissionService = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
1
|
+
// GENERATED CODE -- DO NOT EDIT!
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
var grpc = require('grpc');
|
|
5
|
+
var skyeye_rpc_pb = require('./skyeye_rpc_pb.js');
|
|
6
|
+
|
|
7
|
+
function serialize_JSONRequest(arg) {
|
|
8
|
+
if (!(arg instanceof skyeye_rpc_pb.JSONRequest)) {
|
|
9
|
+
throw new Error('Expected argument of type JSONRequest');
|
|
10
|
+
}
|
|
11
|
+
return Buffer.from(arg.serializeBinary());
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function deserialize_JSONRequest(buffer_arg) {
|
|
15
|
+
return skyeye_rpc_pb.JSONRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function serialize_JSONResponse(arg) {
|
|
19
|
+
if (!(arg instanceof skyeye_rpc_pb.JSONResponse)) {
|
|
20
|
+
throw new Error('Expected argument of type JSONResponse');
|
|
21
|
+
}
|
|
22
|
+
return Buffer.from(arg.serializeBinary());
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function deserialize_JSONResponse(buffer_arg) {
|
|
26
|
+
return skyeye_rpc_pb.JSONResponse.deserializeBinary(new Uint8Array(buffer_arg));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var JSONTransmissionService = exports.JSONTransmissionService = {
|
|
31
|
+
callSkyEye: {
|
|
32
|
+
path: '/JSONTransmission/CallSkyEye',
|
|
33
|
+
requestStream: false,
|
|
34
|
+
responseStream: false,
|
|
35
|
+
requestType: skyeye_rpc_pb.JSONRequest,
|
|
36
|
+
responseType: skyeye_rpc_pb.JSONResponse,
|
|
37
|
+
requestSerialize: serialize_JSONRequest,
|
|
38
|
+
requestDeserialize: deserialize_JSONRequest,
|
|
39
|
+
responseSerialize: serialize_JSONResponse,
|
|
40
|
+
responseDeserialize: deserialize_JSONResponse,
|
|
41
|
+
},
|
|
42
|
+
skyEyeLogReport: {
|
|
43
|
+
path: '/JSONTransmission/SkyEyeLogReport',
|
|
44
|
+
requestStream: false,
|
|
45
|
+
responseStream: true,
|
|
46
|
+
requestType: skyeye_rpc_pb.JSONRequest,
|
|
47
|
+
responseType: skyeye_rpc_pb.JSONResponse,
|
|
48
|
+
requestSerialize: serialize_JSONRequest,
|
|
49
|
+
requestDeserialize: deserialize_JSONRequest,
|
|
50
|
+
responseSerialize: serialize_JSONResponse,
|
|
51
|
+
responseDeserialize: deserialize_JSONResponse,
|
|
52
|
+
},
|
|
53
|
+
runTestcase: {
|
|
54
|
+
path: '/JSONTransmission/RunTestcase',
|
|
55
|
+
requestStream: false,
|
|
56
|
+
responseStream: true,
|
|
57
|
+
requestType: skyeye_rpc_pb.JSONRequest,
|
|
58
|
+
responseType: skyeye_rpc_pb.JSONResponse,
|
|
59
|
+
requestSerialize: serialize_JSONRequest,
|
|
60
|
+
requestDeserialize: deserialize_JSONRequest,
|
|
61
|
+
responseSerialize: serialize_JSONResponse,
|
|
62
|
+
responseDeserialize: deserialize_JSONResponse,
|
|
63
|
+
},
|
|
64
|
+
monitor: {
|
|
65
|
+
path: '/JSONTransmission/Monitor',
|
|
66
|
+
requestStream: false,
|
|
67
|
+
responseStream: true,
|
|
68
|
+
requestType: skyeye_rpc_pb.JSONRequest,
|
|
69
|
+
responseType: skyeye_rpc_pb.JSONResponse,
|
|
70
|
+
requestSerialize: serialize_JSONRequest,
|
|
71
|
+
requestDeserialize: deserialize_JSONRequest,
|
|
72
|
+
responseSerialize: serialize_JSONResponse,
|
|
73
|
+
responseDeserialize: deserialize_JSONResponse,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
exports.JSONTransmissionClient = grpc.makeGenericClientConstructor(JSONTransmissionService);
|