@ekhein/lamda-node-sdk 2.1.6 → 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 +42 -31
- 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): Promise<T>;
|
|
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,59 +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
|
-
async get(key) {
|
|
188
|
-
|
|
189
|
-
.get({
|
|
190
|
-
|
|
196
|
+
async get(key, defaultValue) {
|
|
197
|
+
const result = await this.$.Storage
|
|
198
|
+
.get({ key });
|
|
199
|
+
if (result.value.length == 0)
|
|
200
|
+
return defaultValue;
|
|
201
|
+
return (0, msgpackr_1.unpack)(result.value);
|
|
191
202
|
}
|
|
192
203
|
async ttl(key) {
|
|
193
|
-
|
|
194
|
-
.ttl({
|
|
195
|
-
|
|
204
|
+
const result = await this.$.Storage
|
|
205
|
+
.ttl({ key });
|
|
206
|
+
return result.value;
|
|
196
207
|
}
|
|
197
208
|
async exists(key) {
|
|
198
|
-
|
|
199
|
-
.exists({
|
|
200
|
-
|
|
209
|
+
const result = await this.$.Storage
|
|
210
|
+
.exists({ key });
|
|
211
|
+
return result.value;
|
|
201
212
|
}
|
|
202
213
|
async delete(key) {
|
|
203
|
-
|
|
204
|
-
.delete({
|
|
205
|
-
|
|
214
|
+
const result = await this.$.Storage
|
|
215
|
+
.delete({ key });
|
|
216
|
+
return result.value;
|
|
206
217
|
}
|
|
207
218
|
async clear() {
|
|
208
|
-
|
|
209
|
-
.clearContainer({ container: this.container })
|
|
210
|
-
|
|
219
|
+
const result = await this.$.Storage
|
|
220
|
+
.clearContainer({ container: this.container });
|
|
221
|
+
return result.value;
|
|
211
222
|
}
|
|
212
223
|
}
|
|
213
224
|
exports.Storage = Storage;
|