@ekhein/lamda-node-sdk 2.0.2 → 2.0.4
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ClientMiddlewareCall } from "nice-grpc";
|
|
2
|
+
export declare class RemoteRPCException<Request, Response> extends Error {
|
|
3
|
+
readonly call: ClientMiddlewareCall<Request, Response>;
|
|
4
|
+
readonly error: {
|
|
5
|
+
code: number;
|
|
6
|
+
details: string;
|
|
7
|
+
};
|
|
8
|
+
constructor(call: ClientMiddlewareCall<Request, Response>, error: {
|
|
9
|
+
code: number;
|
|
10
|
+
details: string;
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { format } from 'util';
|
|
2
|
+
export class RemoteRPCException extends Error {
|
|
3
|
+
call;
|
|
4
|
+
error;
|
|
5
|
+
constructor(call, error) {
|
|
6
|
+
super(format("%s %s::%s", RemoteRPCException.name, call.method.path, error.details));
|
|
7
|
+
this.call = call;
|
|
8
|
+
this.error = error;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RemoteRPCException } from "../exceptions/remoteRpc.exception";
|
|
1
2
|
import { RemoteCallException } from "../exceptions/remoteCall.exception";
|
|
2
3
|
export function RemoteExceptionInterceptor() {
|
|
3
4
|
return async function* (call, options) {
|
|
@@ -5,9 +6,14 @@ export function RemoteExceptionInterceptor() {
|
|
|
5
6
|
return yield* call.next(call.request, options);
|
|
6
7
|
}
|
|
7
8
|
catch (error) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
try {
|
|
10
|
+
const { exception } = JSON.parse(error.details);
|
|
11
|
+
const { name, args } = JSON.parse(exception);
|
|
12
|
+
throw new RemoteCallException(call, name, args);
|
|
13
|
+
}
|
|
14
|
+
catch (_) {
|
|
15
|
+
throw new RemoteRPCException(call, error);
|
|
16
|
+
}
|
|
11
17
|
}
|
|
12
18
|
};
|
|
13
19
|
}
|
package/dist/main.d.ts
CHANGED
|
@@ -22,4 +22,11 @@ export declare class Device {
|
|
|
22
22
|
passwd(pwd: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Parameters<typeof this.UiAutomator["selectorClick"]>[0]>): Promise<void>;
|
|
23
23
|
open(data: string): Promise<import("./rpc/types").Boolean>;
|
|
24
24
|
stop(...args: Parameters<typeof this.Application["stopApplication"]>): Promise<import("./rpc/types").Boolean>;
|
|
25
|
+
call(args: {
|
|
26
|
+
package: string;
|
|
27
|
+
callinfo: {
|
|
28
|
+
method: string;
|
|
29
|
+
args: Array<any>;
|
|
30
|
+
};
|
|
31
|
+
}): Promise<any>;
|
|
25
32
|
}
|
package/dist/main.js
CHANGED
|
@@ -25,22 +25,22 @@ export class Device {
|
|
|
25
25
|
this.channel = createChannel(address, credentials, {
|
|
26
26
|
["grpc.max_send_message_length"]: 64 * 1024 * 1024,
|
|
27
27
|
["grpc.max_receive_message_length"]: 128 * 1024 * 1024,
|
|
28
|
-
["grpc.keepalive_time_ms"]:
|
|
28
|
+
["grpc.keepalive_time_ms"]: 60 * 1000,
|
|
29
29
|
["grpc.keepalive_timeout_ms"]: 15 * 1000,
|
|
30
30
|
["grpc.keepalive_permit_without_calls"]: 1,
|
|
31
31
|
["grpc.max_pings_without_data"]: 0,
|
|
32
32
|
["grpc.enable_http_proxy"]: 0,
|
|
33
33
|
["grpc.service_config"]: JSON.stringify({
|
|
34
34
|
["methodConfig"]: [{
|
|
35
|
-
["name"]: [{}]
|
|
35
|
+
["name"]: [{}],
|
|
36
|
+
["retryPolicy"]: {
|
|
37
|
+
["maxAttempts"]: 5,
|
|
38
|
+
["retryableStatusCodes"]: ["UNAVAILABLE"],
|
|
39
|
+
["backoffMultiplier"]: 2,
|
|
40
|
+
["initialBackoff"]: "0.5s",
|
|
41
|
+
["maxBackoff"]: "15s",
|
|
42
|
+
}
|
|
36
43
|
}],
|
|
37
|
-
["retryPolicy"]: {
|
|
38
|
-
["maxAttempts"]: 5,
|
|
39
|
-
["retryableStatusCodes"]: ["UNAVAILABLE"],
|
|
40
|
-
["backoffMultiplier"]: 2,
|
|
41
|
-
["initialBackoff"]: "0.5s",
|
|
42
|
-
["maxBackoff"]: "15s",
|
|
43
|
-
}
|
|
44
44
|
})
|
|
45
45
|
});
|
|
46
46
|
}
|
|
@@ -80,6 +80,14 @@ export class Device {
|
|
|
80
80
|
return this.Application
|
|
81
81
|
.stopApplication(...args);
|
|
82
82
|
}
|
|
83
|
+
async call(args) {
|
|
84
|
+
const callinfo = JSON.stringify(args.callinfo);
|
|
85
|
+
return this.Application
|
|
86
|
+
.callScript({ ...args, callinfo })
|
|
87
|
+
.then(async (call) => {
|
|
88
|
+
return JSON.parse(call.callresult);
|
|
89
|
+
});
|
|
90
|
+
}
|
|
83
91
|
}
|
|
84
92
|
__decorate([
|
|
85
93
|
Inject(UtilDefinition),
|