@ekhein/lamda-node-sdk 2.1.7 → 2.1.8
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/main.d.ts +3 -3
- package/dist/main.js +40 -33
- package/package.json +1 -1
package/dist/main.d.ts
CHANGED
|
@@ -34,14 +34,14 @@ export declare class Device {
|
|
|
34
34
|
}): Promise<any>;
|
|
35
35
|
}
|
|
36
36
|
export declare class Storage {
|
|
37
|
-
private readonly container;
|
|
38
37
|
private readonly $;
|
|
39
|
-
|
|
38
|
+
private readonly container;
|
|
39
|
+
constructor($: Device, container: string);
|
|
40
40
|
set(key: string, data: any): Promise<boolean>;
|
|
41
41
|
setex(key: string, data: any, ttl: number): Promise<boolean>;
|
|
42
42
|
setnx(key: string, data: any): Promise<boolean>;
|
|
43
43
|
expire(key: string, ttl: number): Promise<boolean>;
|
|
44
|
-
get<T = any>(key: string, defaultValue?:
|
|
44
|
+
get<T = any>(key: string, defaultValue?: T): Promise<T>;
|
|
45
45
|
ttl(key: string): Promise<number>;
|
|
46
46
|
exists(key: string): Promise<boolean>;
|
|
47
47
|
delete(key: string): Promise<boolean>;
|
package/dist/main.js
CHANGED
|
@@ -155,63 +155,70 @@ __decorate([
|
|
|
155
155
|
__metadata("design:type", Object)
|
|
156
156
|
], Device.prototype, "Settings", void 0);
|
|
157
157
|
class Storage {
|
|
158
|
-
container;
|
|
159
158
|
$;
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
container;
|
|
160
|
+
constructor($, container) {
|
|
162
161
|
this.$ = $;
|
|
162
|
+
this.container = container;
|
|
163
|
+
for (const method in $.Storage) {
|
|
164
|
+
if (method != "clearAll") {
|
|
165
|
+
const origin = $.Storage[method];
|
|
166
|
+
$.Storage[method] = function (params) {
|
|
167
|
+
Object.assign(params, { container });
|
|
168
|
+
return origin.call(this, params);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
}
|
|
163
172
|
}
|
|
164
173
|
async set(key, data) {
|
|
165
174
|
const value = (0, msgpackr_1.pack)(data);
|
|
166
|
-
|
|
167
|
-
.set({
|
|
168
|
-
|
|
175
|
+
const result = await this.$.Storage
|
|
176
|
+
.set({ key, value });
|
|
177
|
+
return result.value;
|
|
169
178
|
}
|
|
170
179
|
async setex(key, data, ttl) {
|
|
171
180
|
const value = (0, msgpackr_1.pack)(data);
|
|
172
|
-
|
|
173
|
-
.setex({
|
|
174
|
-
|
|
181
|
+
const result = await this.$.Storage
|
|
182
|
+
.setex({ key, value, ttl });
|
|
183
|
+
return result.value;
|
|
175
184
|
}
|
|
176
185
|
async setnx(key, data) {
|
|
177
186
|
const value = (0, msgpackr_1.pack)(data);
|
|
178
|
-
|
|
179
|
-
.setnx({
|
|
180
|
-
|
|
187
|
+
const result = await this.$.Storage
|
|
188
|
+
.setnx({ key, value });
|
|
189
|
+
return result.value;
|
|
181
190
|
}
|
|
182
191
|
async expire(key, ttl) {
|
|
183
|
-
|
|
184
|
-
.expire({
|
|
185
|
-
|
|
192
|
+
const result = await this.$.Storage
|
|
193
|
+
.expire({ key, ttl });
|
|
194
|
+
return result.value;
|
|
186
195
|
}
|
|
187
196
|
async get(key, defaultValue) {
|
|
188
|
-
|
|
189
|
-
.get({
|
|
190
|
-
|
|
191
|
-
if (r.value.length)
|
|
192
|
-
return (0, msgpackr_1.unpack)(r.value);
|
|
197
|
+
const result = await this.$.Storage
|
|
198
|
+
.get({ key });
|
|
199
|
+
if (result.value.length == 0)
|
|
193
200
|
return defaultValue;
|
|
194
|
-
|
|
201
|
+
return (0, msgpackr_1.unpack)(result.value);
|
|
195
202
|
}
|
|
196
203
|
async ttl(key) {
|
|
197
|
-
|
|
198
|
-
.ttl({
|
|
199
|
-
|
|
204
|
+
const result = await this.$.Storage
|
|
205
|
+
.ttl({ key });
|
|
206
|
+
return result.value;
|
|
200
207
|
}
|
|
201
208
|
async exists(key) {
|
|
202
|
-
|
|
203
|
-
.exists({
|
|
204
|
-
|
|
209
|
+
const result = await this.$.Storage
|
|
210
|
+
.exists({ key });
|
|
211
|
+
return result.value;
|
|
205
212
|
}
|
|
206
213
|
async delete(key) {
|
|
207
|
-
|
|
208
|
-
.delete({
|
|
209
|
-
|
|
214
|
+
const result = await this.$.Storage
|
|
215
|
+
.delete({ key });
|
|
216
|
+
return result.value;
|
|
210
217
|
}
|
|
211
218
|
async clear() {
|
|
212
|
-
|
|
213
|
-
.clearContainer({ container: this.container })
|
|
214
|
-
|
|
219
|
+
const result = await this.$.Storage
|
|
220
|
+
.clearContainer({ container: this.container });
|
|
221
|
+
return result.value;
|
|
215
222
|
}
|
|
216
223
|
}
|
|
217
224
|
exports.Storage = Storage;
|