@ekhein/lamda-node-sdk 2.1.5 → 2.1.6

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.
@@ -14,7 +14,9 @@ function RemoteExceptionInterceptor() {
14
14
  const { name, args } = JSON.parse(exception);
15
15
  throw new remoteCall_exception_1.RemoteCallException(call, name, args);
16
16
  }
17
- catch (_) {
17
+ catch (e) {
18
+ if (e instanceof remoteCall_exception_1.RemoteCallException)
19
+ throw e;
18
20
  throw new remoteRpc_exception_1.RemoteRPCException(call, error);
19
21
  }
20
22
  }
package/dist/main.d.ts CHANGED
@@ -16,7 +16,7 @@ export declare class Device {
16
16
  readonly Settings: SettingsClient;
17
17
  private channel;
18
18
  private client;
19
- constructor(host?: string, prot?: number);
19
+ constructor(host?: string, port?: string | number);
20
20
  click(selector: Partial<Selector>, corner?: Corner): Promise<import("./rpc/types").Boolean>;
21
21
  clickEx(keys: string, keyboard: Record<"0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9", Partial<Selector>>): Promise<void>;
22
22
  waitFor(selector: Partial<Selector>, timeout?: number): Promise<true>;
@@ -33,3 +33,17 @@ export declare class Device {
33
33
  };
34
34
  }): Promise<any>;
35
35
  }
36
+ export declare class Storage {
37
+ private readonly container;
38
+ private readonly $;
39
+ constructor(container: string, $: Device);
40
+ set(key: string, data: any): Promise<boolean>;
41
+ setex(key: string, data: any, ttl: number): Promise<boolean>;
42
+ setnx(key: string, data: any): Promise<boolean>;
43
+ expire(key: string, ttl: number): Promise<boolean>;
44
+ get<T = any>(key: string): Promise<T>;
45
+ ttl(key: string): Promise<number>;
46
+ exists(key: string): Promise<boolean>;
47
+ delete(key: string): Promise<boolean>;
48
+ clear(): Promise<boolean>;
49
+ }
package/dist/main.js CHANGED
@@ -9,7 +9,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Device = void 0;
12
+ exports.Storage = exports.Device = void 0;
13
+ const msgpackr_1 = require("msgpackr");
13
14
  const nice_grpc_1 = require("nice-grpc");
14
15
  const inject_decorator_1 = require("./decorators/inject.decorator");
15
16
  const android_intent_1 = require("./constants/android.intent");
@@ -20,8 +21,8 @@ const services_1 = require("./rpc/services");
20
21
  class Device {
21
22
  channel;
22
23
  client;
23
- constructor(host = "127.0.0.1", prot = 65000) {
24
- const address = Array(host, prot).join(":");
24
+ constructor(host = process.env.LAMDA_HOST ?? "127.0.0.1", port = process.env.LAMDA_PORT ?? 65000) {
25
+ const address = Array(host, port).join(":");
25
26
  const credentials = nice_grpc_1.ChannelCredentials.createInsecure();
26
27
  this.client = (0, nice_grpc_1.createClientFactory)()
27
28
  .use((0, remoteException_Interceptor_1.RemoteExceptionInterceptor)());
@@ -153,3 +154,60 @@ __decorate([
153
154
  (0, inject_decorator_1.Inject)(services_1.SettingsDefinition),
154
155
  __metadata("design:type", Object)
155
156
  ], Device.prototype, "Settings", void 0);
157
+ class Storage {
158
+ container;
159
+ $;
160
+ constructor(container, $) {
161
+ this.container = container;
162
+ this.$ = $;
163
+ }
164
+ async set(key, data) {
165
+ const value = (0, msgpackr_1.pack)(data);
166
+ return this.$.Storage
167
+ .set({ container: this.container, key, value })
168
+ .then(async (r) => r.value);
169
+ }
170
+ async setex(key, data, ttl) {
171
+ const value = (0, msgpackr_1.pack)(data);
172
+ return this.$.Storage
173
+ .setex({ container: this.container, key, value, ttl })
174
+ .then(async (r) => r.value);
175
+ }
176
+ async setnx(key, data) {
177
+ const value = (0, msgpackr_1.pack)(data);
178
+ return this.$.Storage
179
+ .setnx({ container: this.container, key, value })
180
+ .then(async (r) => r.value);
181
+ }
182
+ async expire(key, ttl) {
183
+ return this.$.Storage
184
+ .expire({ container: this.container, key, ttl })
185
+ .then(async (r) => r.value);
186
+ }
187
+ async get(key) {
188
+ return this.$.Storage
189
+ .get({ container: this.container, key })
190
+ .then(async (r) => (0, msgpackr_1.unpack)(r.value));
191
+ }
192
+ async ttl(key) {
193
+ return this.$.Storage
194
+ .ttl({ container: this.container, key })
195
+ .then(r => r.value);
196
+ }
197
+ async exists(key) {
198
+ return this.$.Storage
199
+ .exists({ container: this.container, key })
200
+ .then(async (r) => r.value);
201
+ }
202
+ async delete(key) {
203
+ return this.$.Storage
204
+ .delete({ container: this.container, key })
205
+ .then(async (r) => r.value);
206
+ }
207
+ async clear() {
208
+ return this.$.Storage
209
+ .clearContainer({ container: this.container })
210
+ .then(async (r) => r.value);
211
+ }
212
+ }
213
+ exports.Storage = Storage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekhein/lamda-node-sdk",
3
- "version": "2.1.5",
3
+ "version": "2.1.6",
4
4
  "author": "ekhein",
5
5
  "license": "MIT",
6
6
  "main": "./dist/main.js",
@@ -17,6 +17,7 @@
17
17
  "dependencies": {
18
18
  "@bufbuild/protobuf": "^2.4.0",
19
19
  "long": "^5.3.2",
20
+ "msgpackr": "^1.11.5",
20
21
  "nice-grpc": "^2.1.12",
21
22
  "nice-grpc-common": "^2.0.2",
22
23
  "protobufjs": "^7.5.2"