@arcaelas/whatsapp 1.0.21 → 1.2.2
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/API.md +776 -0
- package/DOC.md +532 -0
- package/build/Chat.d.ts +335 -0
- package/build/Chat.js +396 -0
- package/build/Chat.js.map +1 -0
- package/build/Contact.d.ts +828 -0
- package/build/Contact.js +188 -0
- package/build/Contact.js.map +1 -0
- package/build/Message.d.ts +525 -0
- package/build/Message.js +445 -0
- package/build/Message.js.map +1 -0
- package/build/WhatsApp.d.ts +68 -0
- package/build/WhatsApp.js +399 -0
- package/build/WhatsApp.js.map +1 -0
- package/build/index.d.ts +11 -107
- package/build/index.js +1 -1
- package/build/index.js.map +3 -3
- package/build/store/driver/FileEngine.d.ts +23 -0
- package/build/store/driver/FileEngine.js +90 -0
- package/build/store/driver/FileEngine.js.map +1 -0
- package/build/store/driver/RedisEngine.d.ts +38 -0
- package/build/store/driver/RedisEngine.js +69 -0
- package/build/store/driver/RedisEngine.js.map +1 -0
- package/build/store/engine.d.ts +54 -0
- package/build/store/engine.js +7 -0
- package/build/store/engine.js.map +1 -0
- package/build/store/index.d.ts +8 -0
- package/build/store/index.js +12 -0
- package/build/store/index.js.map +1 -0
- package/context7.json +4 -0
- package/package.json +59 -52
- package/tsconfig.json +25 -25
- package/build/model/base.d.ts +0 -28
- package/build/model/base.js +0 -65
- package/build/model/base.js.map +0 -1
- package/build/model/chat.d.ts +0 -112
- package/build/model/chat.js +0 -105
- package/build/model/chat.js.map +0 -1
- package/build/model/contact.d.ts +0 -16
- package/build/model/contact.js +0 -22
- package/build/model/contact.js.map +0 -1
- package/build/model/message.d.ts +0 -159
- package/build/model/message.js +0 -206
- package/build/model/message.js.map +0 -1
- package/build/static/Store.d.ts +0 -137
- package/build/static/Store.js +0 -238
- package/build/static/Store.js.map +0 -1
- package/build/static/useCache.d.ts +0 -12
- package/build/static/useCache.js +0 -43
- package/build/static/useCache.js.map +0 -1
package/build/static/Store.d.ts
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import * as Baileys from 'baileys';
|
|
2
|
-
/**
|
|
3
|
-
* @module Store
|
|
4
|
-
* @description
|
|
5
|
-
* Minimal contract that any persistence backend used by **@arcaelas/whatsapp**
|
|
6
|
-
* must implement.
|
|
7
|
-
*
|
|
8
|
-
* - **Strict key–value model** → **all keys are `string`**.
|
|
9
|
-
* - **Values can only be `string` or `null`**.
|
|
10
|
-
* - **The interface itself does *not* handle serialization**.
|
|
11
|
-
* Implementations decide whether to apply `JSON.stringify`/`JSON.parse`,
|
|
12
|
-
* BSON, Base64, etc. — as long as they expose/consume `string | null`.
|
|
13
|
-
*
|
|
14
|
-
* This design works from an in‑memory `Map` up to Redis, SQLite, or even S3,
|
|
15
|
-
* while keeping a uniform, fully‑asynchronous API.
|
|
16
|
-
*/
|
|
17
|
-
export interface Engine {
|
|
18
|
-
/**
|
|
19
|
-
* Check whether a key exists.
|
|
20
|
-
*
|
|
21
|
-
* @param key Key to test.
|
|
22
|
-
* @returns `true` if present; `false` otherwise.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* const logged = await store.has('session');
|
|
26
|
-
*/
|
|
27
|
-
has(key: string): Promise<boolean>;
|
|
28
|
-
/**
|
|
29
|
-
* Retrieve the value associated with a key.
|
|
30
|
-
*
|
|
31
|
-
* @param key Key to read.
|
|
32
|
-
* @param fallback Default value if the key is missing (`null` if omitted).
|
|
33
|
-
* @returns Stored `string` or `fallback`.
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* const raw = await store.get('user:123'); // '{"name":"Miguel"}'
|
|
37
|
-
*/
|
|
38
|
-
get(key: string, fallback?: string | null): Promise<string | null>;
|
|
39
|
-
/**
|
|
40
|
-
* Store a **string value**.
|
|
41
|
-
*
|
|
42
|
-
* > Passing `null` or `undefined` deletes the key (same as `delete()`).
|
|
43
|
-
*
|
|
44
|
-
* @param key Destination key.
|
|
45
|
-
* @param value String to save, or `null` to remove.
|
|
46
|
-
* @returns `true` on success; `false` on failure.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* await store.set('token', 'abc123');
|
|
50
|
-
*/
|
|
51
|
-
set(key: string, value: string | null): Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* Remove a key.
|
|
54
|
-
*
|
|
55
|
-
* @param key Key to unset.
|
|
56
|
-
* @returns `true` if removed; `false` if it did not exist.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* await store.unset('cache:config');
|
|
60
|
-
*/
|
|
61
|
-
unset(key: string): Promise<boolean>;
|
|
62
|
-
/**
|
|
63
|
-
* @description
|
|
64
|
-
* Filter keys using a **glob pattern** (`*` as wildcard).
|
|
65
|
-
* - `user:*` → everything starting with `user:`
|
|
66
|
-
* - `log:*:error` → simultaneous prefix and suffix
|
|
67
|
-
* @param pattern Glob pattern.
|
|
68
|
-
* @returns Array of matching keys.
|
|
69
|
-
* @example
|
|
70
|
-
* const keys = await store.match('user:*:active');
|
|
71
|
-
*/
|
|
72
|
-
match(pattern: string): Promise<string[]>;
|
|
73
|
-
}
|
|
74
|
-
export default class Store {
|
|
75
|
-
readonly engine: Engine;
|
|
76
|
-
constructor(engine: Engine);
|
|
77
|
-
document: {
|
|
78
|
-
set: (pathname: string, content: any) => Promise<boolean>;
|
|
79
|
-
get: <T>(pathname: string) => Promise<T | null>;
|
|
80
|
-
has: (pathname: string) => Promise<boolean>;
|
|
81
|
-
unset: (pathname: string) => Promise<boolean>;
|
|
82
|
-
keys: () => {
|
|
83
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
84
|
-
};
|
|
85
|
-
values: () => {
|
|
86
|
-
[Symbol.asyncIterator](): AsyncGenerator<any, void, unknown>;
|
|
87
|
-
};
|
|
88
|
-
entries: () => {
|
|
89
|
-
[Symbol.asyncIterator](): AsyncGenerator<readonly [string, any], void, unknown>;
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
contact: {
|
|
93
|
-
set: (contact: Baileys.Contact) => Promise<boolean>;
|
|
94
|
-
get: (id: Baileys.Contact["id"]) => Promise<Baileys.Contact | null>;
|
|
95
|
-
has: (id: Baileys.Contact["id"]) => Promise<boolean>;
|
|
96
|
-
unset: (id: Baileys.Contact["id"]) => Promise<boolean>;
|
|
97
|
-
keys: () => {
|
|
98
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
99
|
-
};
|
|
100
|
-
values: () => {
|
|
101
|
-
[Symbol.asyncIterator](): AsyncGenerator<Baileys.Contact, void, unknown>;
|
|
102
|
-
};
|
|
103
|
-
entries: () => {
|
|
104
|
-
[Symbol.asyncIterator](): AsyncGenerator<readonly [string, Baileys.Contact], void, unknown>;
|
|
105
|
-
};
|
|
106
|
-
};
|
|
107
|
-
chat: {
|
|
108
|
-
set: (chat: Baileys.Chat) => Promise<boolean>;
|
|
109
|
-
get: (id: Baileys.Chat["id"]) => Promise<Baileys.Chat | null>;
|
|
110
|
-
has: (id: Baileys.Chat["id"]) => Promise<boolean>;
|
|
111
|
-
unset: (id: Baileys.Chat["id"]) => Promise<boolean>;
|
|
112
|
-
keys: () => {
|
|
113
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
114
|
-
};
|
|
115
|
-
values: () => {
|
|
116
|
-
[Symbol.asyncIterator](): AsyncGenerator<Baileys.Chat, void, unknown>;
|
|
117
|
-
};
|
|
118
|
-
entries: () => {
|
|
119
|
-
[Symbol.asyncIterator](): AsyncGenerator<readonly [string, Baileys.Chat], void, unknown>;
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
message: {
|
|
123
|
-
set: (message: Baileys.WAProto.IWebMessageInfo) => Promise<boolean>;
|
|
124
|
-
get: (id: string) => Promise<Baileys.WAProto.IWebMessageInfo | null>;
|
|
125
|
-
has: (id: string) => Promise<boolean>;
|
|
126
|
-
unset: (id: string) => Promise<boolean>;
|
|
127
|
-
keys: () => {
|
|
128
|
-
[Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
|
|
129
|
-
};
|
|
130
|
-
values: () => {
|
|
131
|
-
[Symbol.asyncIterator](): AsyncGenerator<Baileys.WAProto.IWebMessageInfo, void, unknown>;
|
|
132
|
-
};
|
|
133
|
-
entries: () => {
|
|
134
|
-
[Symbol.asyncIterator](): AsyncGenerator<readonly [string, Baileys.WAProto.IWebMessageInfo], void, unknown>;
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
}
|
package/build/static/Store.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
const Baileys = __importStar(require("baileys"));
|
|
37
|
-
class Store {
|
|
38
|
-
constructor(engine) {
|
|
39
|
-
this.engine = engine;
|
|
40
|
-
this.document = {
|
|
41
|
-
set: async (pathname, content) => {
|
|
42
|
-
// prettier-ignore
|
|
43
|
-
return await this.engine.set(`document/${pathname}`, JSON.stringify(content, Baileys.BufferJSON.replacer));
|
|
44
|
-
},
|
|
45
|
-
get: async (pathname) => {
|
|
46
|
-
// prettier-ignore
|
|
47
|
-
return JSON.parse(await this.engine.get(`document/${pathname}`) ?? 'null', Baileys.BufferJSON.reviver);
|
|
48
|
-
},
|
|
49
|
-
has: async (pathname) => {
|
|
50
|
-
return await this.engine.has(`document/${pathname}`);
|
|
51
|
-
},
|
|
52
|
-
unset: async (pathname) => {
|
|
53
|
-
return await this.engine.unset(`document/${pathname}`);
|
|
54
|
-
},
|
|
55
|
-
keys: () => {
|
|
56
|
-
const _this = this;
|
|
57
|
-
return {
|
|
58
|
-
async *[Symbol.asyncIterator]() {
|
|
59
|
-
for (const key of await _this.engine.match('document/*')) {
|
|
60
|
-
const [, _key] = key.match(/document\/(.*)/) ?? [];
|
|
61
|
-
yield _key;
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
values: () => {
|
|
67
|
-
const _this = this;
|
|
68
|
-
return {
|
|
69
|
-
async *[Symbol.asyncIterator]() {
|
|
70
|
-
for await (const key of _this.document.keys()) {
|
|
71
|
-
yield await _this.document.get(key);
|
|
72
|
-
}
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
entries: () => {
|
|
77
|
-
const _this = this;
|
|
78
|
-
return {
|
|
79
|
-
async *[Symbol.asyncIterator]() {
|
|
80
|
-
for await (const key of _this.document.keys()) {
|
|
81
|
-
yield [key, await _this.document.get(key)];
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
this.contact = {
|
|
88
|
-
set: async (contact) => {
|
|
89
|
-
// prettier-ignore
|
|
90
|
-
return this.engine.set(`contact/${contact.id}/index`, JSON.stringify(contact, Baileys.BufferJSON.replacer));
|
|
91
|
-
},
|
|
92
|
-
get: async (id) => {
|
|
93
|
-
// prettier-ignore
|
|
94
|
-
return JSON.parse(await this.engine.get(`contact/${id}/index`) ?? 'null', Baileys.BufferJSON.reviver);
|
|
95
|
-
},
|
|
96
|
-
has: async (id) => {
|
|
97
|
-
return await this.engine.has(`contact/${id}/index`);
|
|
98
|
-
},
|
|
99
|
-
unset: async (id) => {
|
|
100
|
-
return await this.engine.unset(`contact/${id}/index`);
|
|
101
|
-
},
|
|
102
|
-
keys: () => {
|
|
103
|
-
const _this = this;
|
|
104
|
-
return {
|
|
105
|
-
async *[Symbol.asyncIterator]() {
|
|
106
|
-
for await (const key of await _this.engine.match('contact/*/index')) {
|
|
107
|
-
const [, id] = key.match(/contact\/([^/]+)\/index/) ?? [];
|
|
108
|
-
yield id;
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
},
|
|
113
|
-
values: () => {
|
|
114
|
-
const _this = this;
|
|
115
|
-
return {
|
|
116
|
-
async *[Symbol.asyncIterator]() {
|
|
117
|
-
for await (const id of _this.contact.keys()) {
|
|
118
|
-
yield (await _this.contact.get(id));
|
|
119
|
-
}
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
},
|
|
123
|
-
entries: () => {
|
|
124
|
-
const _this = this;
|
|
125
|
-
return {
|
|
126
|
-
async *[Symbol.asyncIterator]() {
|
|
127
|
-
for await (const id of _this.contact.keys()) {
|
|
128
|
-
yield [id, (await _this.contact.get(id))];
|
|
129
|
-
}
|
|
130
|
-
},
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
this.chat = {
|
|
135
|
-
set: async (chat) => {
|
|
136
|
-
// prettier-ignore
|
|
137
|
-
return this.engine.set(`chat/${chat.id}/index`, JSON.stringify(chat, Baileys.BufferJSON.replacer));
|
|
138
|
-
},
|
|
139
|
-
get: async (id) => {
|
|
140
|
-
// prettier-ignore
|
|
141
|
-
return JSON.parse(await this.engine.get(`chat/${id}/index`) ?? 'null', Baileys.BufferJSON.reviver);
|
|
142
|
-
},
|
|
143
|
-
has: async (id) => {
|
|
144
|
-
return await this.engine.has(`chat/${id}/index`);
|
|
145
|
-
},
|
|
146
|
-
unset: async (id) => {
|
|
147
|
-
for (const key of await this.engine.match(`chat/${id}/*`)) {
|
|
148
|
-
await this.engine.unset(key);
|
|
149
|
-
}
|
|
150
|
-
return true;
|
|
151
|
-
},
|
|
152
|
-
keys: () => {
|
|
153
|
-
const _this = this;
|
|
154
|
-
return {
|
|
155
|
-
async *[Symbol.asyncIterator]() {
|
|
156
|
-
for await (const key of await _this.engine.match('chat/*/index')) {
|
|
157
|
-
const [, id] = key.match(/chat\/([^/]+)\/index/) ?? [];
|
|
158
|
-
yield id;
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
values: () => {
|
|
164
|
-
const _this = this;
|
|
165
|
-
return {
|
|
166
|
-
async *[Symbol.asyncIterator]() {
|
|
167
|
-
for await (const id of _this.chat.keys()) {
|
|
168
|
-
yield (await _this.chat.get(id));
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
},
|
|
173
|
-
entries: () => {
|
|
174
|
-
const _this = this;
|
|
175
|
-
return {
|
|
176
|
-
async *[Symbol.asyncIterator]() {
|
|
177
|
-
for await (const id of _this.chat.keys()) {
|
|
178
|
-
yield [id, (await _this.chat.get(id))];
|
|
179
|
-
}
|
|
180
|
-
},
|
|
181
|
-
};
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
this.message = {
|
|
185
|
-
set: async (message) => {
|
|
186
|
-
// prettier-ignore
|
|
187
|
-
return await this.engine.set(`chat/${message.key.remoteJid}/message/${message.key.id}/index`, JSON.stringify(message, Baileys.BufferJSON.replacer));
|
|
188
|
-
},
|
|
189
|
-
get: async (id) => {
|
|
190
|
-
const [key] = await this.engine.match(`chat/*/${id}/index`);
|
|
191
|
-
// prettier-ignore
|
|
192
|
-
return JSON.parse((await this.engine.get(key)), Baileys.BufferJSON.reviver);
|
|
193
|
-
},
|
|
194
|
-
has: async (id) => {
|
|
195
|
-
const [key] = await this.engine.match(`chat/*/${id}/index`);
|
|
196
|
-
return !!key;
|
|
197
|
-
},
|
|
198
|
-
unset: async (id) => {
|
|
199
|
-
const [key] = await this.engine.match(`chat/*/${id}/index`);
|
|
200
|
-
return await this.engine.unset(key);
|
|
201
|
-
},
|
|
202
|
-
keys: () => {
|
|
203
|
-
const _this = this;
|
|
204
|
-
return {
|
|
205
|
-
async *[Symbol.asyncIterator]() {
|
|
206
|
-
const keys = await _this.engine.match('chat/*/message/*/index');
|
|
207
|
-
for (const key of keys) {
|
|
208
|
-
const [, , id] = key.match(/chat\/([^/]+)\/message\/([^/]+)\/index/) ?? [];
|
|
209
|
-
yield id;
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
values: () => {
|
|
215
|
-
const _this = this;
|
|
216
|
-
return {
|
|
217
|
-
async *[Symbol.asyncIterator]() {
|
|
218
|
-
for await (const key of _this.message.keys()) {
|
|
219
|
-
yield (await _this.message.get(key));
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
};
|
|
223
|
-
},
|
|
224
|
-
entries: () => {
|
|
225
|
-
const _this = this;
|
|
226
|
-
return {
|
|
227
|
-
async *[Symbol.asyncIterator]() {
|
|
228
|
-
for await (const key of _this.message.keys()) {
|
|
229
|
-
yield [key, (await _this.message.get(key))];
|
|
230
|
-
}
|
|
231
|
-
},
|
|
232
|
-
};
|
|
233
|
-
},
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.default = Store;
|
|
238
|
-
//# sourceMappingURL=Store.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Store.js","sourceRoot":"","sources":["../../src/static/Store.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AA+EnC,MAAqB,KAAK;IACtB,YAAqB,MAAc;QAAd,WAAM,GAAN,MAAM,CAAQ;QAEnC,aAAQ,GAAG;YACP,GAAG,EAAE,KAAK,EAAE,QAAgB,EAAE,OAAY,EAAoB,EAAE;gBAC5D,kBAAkB;gBAClB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACxB,YAAY,QAAQ,EAAE,EACtB,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,QAAQ,CAAC,CACvD,CAAC;YACN,CAAC;YACD,GAAG,EAAE,KAAK,EAAK,QAAgB,EAAqB,EAAE;gBAClD,kBAAkB;gBAClB,OAAO,IAAI,CAAC,KAAK,CACb,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,QAAQ,EAAE,CAAC,IAAI,MAAM,EACvD,OAAO,CAAC,UAAU,CAAC,OAAO,CAC7B,CAAC;YACN,CAAC;YACD,GAAG,EAAE,KAAK,EAAE,QAAgB,EAAoB,EAAE;gBAC9C,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,QAAQ,EAAE,CAAC,CAAC;YACzD,CAAC;YACD,KAAK,EAAE,KAAK,EAAE,QAAgB,EAAoB,EAAE;gBAChD,OAAO,MAAM,IAAI,CAAC,MAAM,CA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GAAG,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;4BAC3C,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAE,CAAU,CAAC;wBAC1D,CAAC;oBACL,CAAC;iBACJ,CAAC;YACN,CAAC;SACJ,CAAC;IA/NoC,CAAC;CAgO1C;AAjOD,wBAiOC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import * as Baileys from 'baileys';
|
|
2
|
-
import Store from './Store';
|
|
3
|
-
export default function useCache(store: Store): Promise<{
|
|
4
|
-
save: () => Promise<boolean>;
|
|
5
|
-
state: {
|
|
6
|
-
creds: Baileys.AuthenticationCreds;
|
|
7
|
-
keys: {
|
|
8
|
-
get(type: string, ids: string[]): Promise<any>;
|
|
9
|
-
set(data: Record<string, Record<string, any>>): Promise<void>;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
}>;
|
package/build/static/useCache.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = useCache;
|
|
4
|
-
const baileys_1 = require("baileys");
|
|
5
|
-
async function useCache(store) {
|
|
6
|
-
// prettier-ignore
|
|
7
|
-
const creds = await store
|
|
8
|
-
.document.get('creds.json')
|
|
9
|
-
.then((e) => e ?? (0, baileys_1.initAuthCreds)());
|
|
10
|
-
return {
|
|
11
|
-
save: () => store.document.set('creds.json', creds),
|
|
12
|
-
state: {
|
|
13
|
-
creds,
|
|
14
|
-
keys: {
|
|
15
|
-
async get(type, ids) {
|
|
16
|
-
const data = {};
|
|
17
|
-
for (const id of ids) {
|
|
18
|
-
let value = await store.document.get(`${type}/${id}`);
|
|
19
|
-
if (value && type === 'app-state-sync-key') {
|
|
20
|
-
value = baileys_1.proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
21
|
-
}
|
|
22
|
-
data[id] = value;
|
|
23
|
-
}
|
|
24
|
-
return data;
|
|
25
|
-
},
|
|
26
|
-
async set(data) {
|
|
27
|
-
const tasks = [];
|
|
28
|
-
// prettier-ignore
|
|
29
|
-
for (const category in data) {
|
|
30
|
-
for (const id in data[category]) {
|
|
31
|
-
const value = data[category][id];
|
|
32
|
-
tasks.push(value
|
|
33
|
-
? store.document.set(`${category}/${id}.json`, value)
|
|
34
|
-
: store.document.unset(`${category}/${id}.json`));
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
await Promise.all(tasks);
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=useCache.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useCache.js","sourceRoot":"","sources":["../../src/static/useCache.ts"],"names":[],"mappings":";;AAIA,2BAsCC;AAzCD,qCAA+C;AAGhC,KAAK,UAAU,QAAQ,CAAC,KAAY;IAC/C,kBAAkB;IAClB,MAAM,KAAK,GAAG,MAAM,KAAK;SACpB,QAAQ,CAAC,GAAG,CAA8B,YAAY,CAAC;SACvD,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,IAAA,uBAAa,GAAE,CAAC,CAAC;IACvC,OAAO;QACH,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC;QACnD,KAAK,EAAE;YACH,KAAK;YACL,IAAI,EAAE;gBACF,KAAK,CAAC,GAAG,CAAC,IAAY,EAAE,GAAa;oBACjC,MAAM,IAAI,GAAQ,EAAE,CAAC;oBACrB,KAAK,MAAM,EAAE,IAAI,GAAG,EAAE,CAAC;wBACnB,IAAI,KAAK,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,GAAG,CAA4C,GAAG,IAAI,IAAI,EAAE,EAAE,CAAC,CAAC;wBACjG,IAAI,KA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