rozod 2.1.1 → 3.1.0
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/lib/cache.d.ts +19 -6
- package/lib/cache.js +77 -14
- package/lib/endpoints/accountinformationv1.js +135 -135
- package/lib/endpoints/accountsettingsv1.js +162 -156
- package/lib/endpoints/assetdeliveryv1.js +34 -27
- package/lib/endpoints/assetdeliveryv2.js +39 -30
- package/lib/endpoints/authv1.js +400 -274
- package/lib/endpoints/authv2.js +269 -219
- package/lib/endpoints/authv3.js +15 -8
- package/lib/endpoints/avatarv1.js +168 -145
- package/lib/endpoints/avatarv2.js +87 -74
- package/lib/endpoints/avatarv3.js +57 -46
- package/lib/endpoints/badgesv1.js +78 -64
- package/lib/endpoints/catalogv1.js +145 -112
- package/lib/endpoints/chatv2.js +203 -196
- package/lib/endpoints/developv1.js +278 -525
- package/lib/endpoints/developv2.js +55 -37
- package/lib/endpoints/economyv1.js +6 -7
- package/lib/endpoints/friendsv1.js +161 -136
- package/lib/endpoints/gamejoinv1.js +88 -80
- package/lib/endpoints/gamesv1.js +253 -205
- package/lib/endpoints/gamesv2.js +42 -24
- package/lib/endpoints/groupsv1.js +466 -392
- package/lib/endpoints/groupsv2.js +62 -47
- package/lib/endpoints/inventoryv1.js +60 -47
- package/lib/endpoints/inventoryv2.js +46 -29
- package/lib/endpoints/itemconfigurationv1.js +563 -0
- package/lib/endpoints/presencev1.js +40 -35
- package/lib/endpoints/privatemessagesv1.js +87 -74
- package/lib/endpoints/thumbnailsv1.js +80 -62
- package/lib/endpoints/tradesv1.js +73 -63
- package/lib/endpoints/translationsv1.js +11 -13
- package/lib/endpoints/usersv1.js +304 -87
- package/lib/index.d.ts +52 -22
- package/lib/index.js +26 -18
- package/package.json +50 -45
- package/lib/endpoints/accountinformationv1.d.ts +0 -666
- package/lib/endpoints/accountsettingsv1.d.ts +0 -690
- package/lib/endpoints/assetdeliveryv1.d.ts +0 -1176
- package/lib/endpoints/assetdeliveryv2.d.ts +0 -1357
- package/lib/endpoints/authv1.d.ts +0 -1601
- package/lib/endpoints/authv2.d.ts +0 -1462
- package/lib/endpoints/authv3.d.ts +0 -46
- package/lib/endpoints/avatarv1.d.ts +0 -2021
- package/lib/endpoints/avatarv2.d.ts +0 -1132
- package/lib/endpoints/avatarv3.d.ts +0 -694
- package/lib/endpoints/badgesv1.d.ts +0 -767
- package/lib/endpoints/catalogv1.d.ts +0 -1977
- package/lib/endpoints/chatv2.d.ts +0 -2379
- package/lib/endpoints/developv1.d.ts +0 -2693
- package/lib/endpoints/developv2.d.ts +0 -692
- package/lib/endpoints/economyv1.d.ts +0 -23
- package/lib/endpoints/friendsv1.d.ts +0 -1349
- package/lib/endpoints/gamejoinv1.d.ts +0 -2321
- package/lib/endpoints/gamesv1.d.ts +0 -3220
- package/lib/endpoints/gamesv2.d.ts +0 -707
- package/lib/endpoints/groupsv1.d.ts +0 -6368
- package/lib/endpoints/groupsv2.d.ts +0 -583
- package/lib/endpoints/inventoryv1.d.ts +0 -589
- package/lib/endpoints/inventoryv2.d.ts +0 -341
- package/lib/endpoints/presencev1.d.ts +0 -155
- package/lib/endpoints/privatemessagesv1.d.ts +0 -702
- package/lib/endpoints/thumbnailsv1.d.ts +0 -1328
- package/lib/endpoints/tradesv1.d.ts +0 -566
- package/lib/endpoints/translationsv1.d.ts +0 -129
- package/lib/endpoints/usersv1.d.ts +0 -510
package/lib/cache.d.ts
CHANGED
|
@@ -1,9 +1,22 @@
|
|
|
1
|
+
type CacheEntry<T> = {
|
|
2
|
+
value: T;
|
|
3
|
+
expiresAt?: number;
|
|
4
|
+
};
|
|
5
|
+
interface CacheStore<T> {
|
|
6
|
+
get(key: string): Promise<CacheEntry<T> | null>;
|
|
7
|
+
set(key: string, value: CacheEntry<T>): Promise<void>;
|
|
8
|
+
delete(key: string): Promise<void>;
|
|
9
|
+
clear(): Promise<void>;
|
|
10
|
+
}
|
|
1
11
|
declare class Cache<T> {
|
|
2
|
-
private
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
12
|
+
private store;
|
|
13
|
+
constructor(store: CacheStore<T>);
|
|
14
|
+
get(key: string): Promise<T | null>;
|
|
15
|
+
set(key: string, value: T, ttl?: number): Promise<void>;
|
|
16
|
+
delete(key: string): Promise<void>;
|
|
17
|
+
clear(): Promise<void>;
|
|
7
18
|
}
|
|
8
|
-
export declare const cache: Cache<
|
|
19
|
+
export declare const cache: Cache<unknown>;
|
|
20
|
+
export declare const localStorageCache: Cache<unknown>;
|
|
21
|
+
export declare const chromeStorageCache: Cache<unknown>;
|
|
9
22
|
export {};
|
package/lib/cache.js
CHANGED
|
@@ -1,32 +1,95 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cache = void 0;
|
|
3
|
+
exports.chromeStorageCache = exports.localStorageCache = exports.cache = void 0;
|
|
4
|
+
class MemoryStore {
|
|
5
|
+
store = {};
|
|
6
|
+
async get(key) {
|
|
7
|
+
return this.store[key] || null;
|
|
8
|
+
}
|
|
9
|
+
async set(key, value) {
|
|
10
|
+
this.store[key] = value;
|
|
11
|
+
}
|
|
12
|
+
async delete(key) {
|
|
13
|
+
delete this.store[key];
|
|
14
|
+
}
|
|
15
|
+
async clear() {
|
|
16
|
+
this.store = {};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
class LocalStorageStore {
|
|
20
|
+
async get(key) {
|
|
21
|
+
const value = localStorage.getItem(key);
|
|
22
|
+
return value ? JSON.parse(value) : null;
|
|
23
|
+
}
|
|
24
|
+
async set(key, value) {
|
|
25
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
26
|
+
}
|
|
27
|
+
async delete(key) {
|
|
28
|
+
localStorage.removeItem(key);
|
|
29
|
+
}
|
|
30
|
+
async clear() {
|
|
31
|
+
localStorage.clear();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class ChromeStore {
|
|
35
|
+
async get(key) {
|
|
36
|
+
return new Promise((resolve) => {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
chrome.storage.local.get(key, (result) => {
|
|
39
|
+
resolve(result[key]);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async set(key, value) {
|
|
44
|
+
return new Promise((resolve) => {
|
|
45
|
+
let item = {};
|
|
46
|
+
item[key] = value;
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
chrome.storage.local.set(item, resolve);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async delete(key) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
// @ts-ignore
|
|
54
|
+
chrome.storage.local.remove(key, resolve);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
async clear() {
|
|
58
|
+
return new Promise((resolve) => {
|
|
59
|
+
// @ts-ignore
|
|
60
|
+
chrome.storage.local.clear(resolve);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
4
64
|
class Cache {
|
|
5
|
-
|
|
6
|
-
|
|
65
|
+
store;
|
|
66
|
+
constructor(store) {
|
|
67
|
+
this.store = store;
|
|
7
68
|
}
|
|
8
|
-
get(key) {
|
|
9
|
-
const entry = this.
|
|
69
|
+
async get(key) {
|
|
70
|
+
const entry = await this.store.get(key);
|
|
10
71
|
if (!entry) {
|
|
11
72
|
return null;
|
|
12
73
|
}
|
|
13
74
|
if (entry.expiresAt && entry.expiresAt < Date.now()) {
|
|
14
|
-
|
|
75
|
+
await this.delete(key);
|
|
15
76
|
return null;
|
|
16
77
|
}
|
|
17
78
|
return entry.value;
|
|
18
79
|
}
|
|
19
|
-
set(key, value, ttl) {
|
|
20
|
-
this.
|
|
80
|
+
async set(key, value, ttl) {
|
|
81
|
+
await this.store.set(key, {
|
|
21
82
|
value,
|
|
22
83
|
expiresAt: ttl ? Date.now() + ttl : undefined,
|
|
23
|
-
};
|
|
84
|
+
});
|
|
24
85
|
}
|
|
25
|
-
delete(key) {
|
|
26
|
-
|
|
86
|
+
async delete(key) {
|
|
87
|
+
await this.store.delete(key);
|
|
27
88
|
}
|
|
28
|
-
clear() {
|
|
29
|
-
this.
|
|
89
|
+
async clear() {
|
|
90
|
+
await this.store.clear();
|
|
30
91
|
}
|
|
31
92
|
}
|
|
32
|
-
exports.cache = new Cache();
|
|
93
|
+
exports.cache = new Cache(new MemoryStore());
|
|
94
|
+
exports.localStorageCache = new Cache(new LocalStorageStore());
|
|
95
|
+
exports.chromeStorageCache = new Cache(new ChromeStore());
|