@tiledesk/tiledesk-tybot-connector 2.0.7 → 2.0.8-rc1
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/CHANGELOG.md +34 -0
- package/Logger.js +30 -13
- package/engine/mock/MockBotsDataSource.js +1 -2
- package/index.js +3 -0
- package/logs/app.log +20243 -7549
- package/logs/app1.log +11065 -0
- package/package.json +3 -2
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +20 -8
- package/tiledeskChatbotPlugs/directives/DirIntent.js +6 -4
- package/tiledeskChatbotPlugs/directives/DirReply.js +6 -14
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +0 -38
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +3 -27
- package/TdCache copy.js +0 -242
- package/logs/app2.log +0 -46280
- package/logs/app3.log +0 -31686
- package/logs/app4.log +0 -46163
- package/logs/app5.log +0 -39983
- package/logs/app6.log +0 -5964
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +0 -417
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiledesk/tiledesk-tybot-connector",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8-rc1",
|
|
4
4
|
"description": "Tiledesk Tybot connector",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@tiledesk/tiledesk-chatbot-client": "^0.5.30",
|
|
16
16
|
"@tiledesk/tiledesk-chatbot-util": "^0.8.39",
|
|
17
17
|
"@tiledesk/tiledesk-client": "^0.10.13",
|
|
18
|
-
"@tiledesk/tiledesk-multi-worker": "^0.
|
|
18
|
+
"@tiledesk/tiledesk-multi-worker": "^0.3.1-rc10",
|
|
19
19
|
"accept-language-parser": "^1.5.0",
|
|
20
20
|
"app-root-path": "^3.1.0",
|
|
21
21
|
"axios": "^1.7.7",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"liquidjs": "^10.8.4",
|
|
30
30
|
"minimist-string": "^1.0.2",
|
|
31
31
|
"mongoose": "^6.3.5",
|
|
32
|
+
"mqtt": "^5.10.4",
|
|
32
33
|
"multer": "^1.4.5-lts.1",
|
|
33
34
|
"nanoid": "^3.1.25",
|
|
34
35
|
"redis": "^4.7.0",
|
|
@@ -222,14 +222,13 @@ class DirectivesChatbotPlug {
|
|
|
222
222
|
directive_name = directive.name.toLowerCase();
|
|
223
223
|
}
|
|
224
224
|
if (directive && directive.action) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
const action_id = directive.action["_tdActionId"];
|
|
226
|
+
const locked_action_id = await this.chatbot.currentLockedAction(this.supportRequest.request_id);
|
|
227
|
+
if ( locked_action_id && (locked_action_id !== action_id) ) {
|
|
228
|
+
let next_dir = await this.nextDirective(this.directives);
|
|
229
|
+
this.process(next_dir);
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
233
232
|
}
|
|
234
233
|
if (directive == null || (directive !== null && directive["name"] === undefined)) {
|
|
235
234
|
winston.debug("(DirectivesChatbotPlug) stop process(). directive is (null?): ", directive);
|
|
@@ -701,6 +700,19 @@ class DirectivesChatbotPlug {
|
|
|
701
700
|
}
|
|
702
701
|
});
|
|
703
702
|
}
|
|
703
|
+
else if (directive_name === Directives.WEBHOOK) {
|
|
704
|
+
// console.log(".....DirIntent")
|
|
705
|
+
new DirIntent(context).execute(directive, async (stop) => {
|
|
706
|
+
if (stop) {
|
|
707
|
+
if (context.log) { console.log("Stopping Actions on:", JSON.stringify(directive));}
|
|
708
|
+
this.theend();
|
|
709
|
+
}
|
|
710
|
+
else {
|
|
711
|
+
let next_dir = await this.nextDirective(this.directives);
|
|
712
|
+
this.process(next_dir);
|
|
713
|
+
}
|
|
714
|
+
});
|
|
715
|
+
}
|
|
704
716
|
else if (directive_name === Directives.WEB_RESPONSE) {
|
|
705
717
|
new DirWebResponse(context).execute(directive, async () => {
|
|
706
718
|
let next_dir = await this.nextDirective(this.directives);
|
|
@@ -62,10 +62,12 @@ class DirIntent {
|
|
|
62
62
|
"recipient": requestId,
|
|
63
63
|
"text": intent_command,
|
|
64
64
|
"id_project": projectId,
|
|
65
|
-
"request":
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
"request": this.supportRequest,
|
|
66
|
+
// "request": {
|
|
67
|
+
// "request_id": requestId,
|
|
68
|
+
// "id_project": projectId
|
|
69
|
+
// // "bot_id": botId
|
|
70
|
+
// }
|
|
69
71
|
},
|
|
70
72
|
"token": this.token
|
|
71
73
|
}
|
|
@@ -18,6 +18,7 @@ class DirReply {
|
|
|
18
18
|
this.token = context.token;
|
|
19
19
|
this.tdcache = context.tdcache;
|
|
20
20
|
this.log = context.log;
|
|
21
|
+
this.supportRequest = this.context.supportRequest;
|
|
21
22
|
this.logger = new Logger({ request_id: this.requestId, dev: this.context.supportRequest.draft });
|
|
22
23
|
|
|
23
24
|
this.API_ENDPOINT = context.API_ENDPOINT;
|
|
@@ -44,10 +45,10 @@ class DirReply {
|
|
|
44
45
|
callback();
|
|
45
46
|
return;
|
|
46
47
|
}
|
|
47
|
-
this.logger.info("
|
|
48
|
+
this.logger.info("Executing Action Reply ", directive.action)
|
|
48
49
|
|
|
49
50
|
this.go(action, () => {
|
|
50
|
-
this.logger.info("
|
|
51
|
+
this.logger.info("Action Reply terminated")
|
|
51
52
|
callback();
|
|
52
53
|
});
|
|
53
54
|
}
|
|
@@ -68,15 +69,16 @@ class DirReply {
|
|
|
68
69
|
const filler = new Filler();
|
|
69
70
|
// fill text attribute
|
|
70
71
|
message.text = filler.fill(message.text, requestAttributes);
|
|
71
|
-
this.logger.info("2 Sending reply " + message.text);
|
|
72
72
|
|
|
73
73
|
if (message.metadata) {
|
|
74
74
|
winston.debug("DirReply filling message 'metadata':", message.metadata);
|
|
75
75
|
if (message.metadata.src) {
|
|
76
76
|
message.metadata.src = filler.fill(message.metadata.src, requestAttributes);
|
|
77
|
+
this.logger.debug("Filled metadata.src with ", message.metadata.src);
|
|
77
78
|
}
|
|
78
79
|
if (message.metadata.name) {
|
|
79
80
|
message.metadata.name = filler.fill(message.metadata.name, requestAttributes);
|
|
81
|
+
this.logger.debug("Filled metadata.name with ", message.metadata.name);
|
|
80
82
|
}
|
|
81
83
|
}
|
|
82
84
|
winston.debug("DirReply filling commands'. Message:", message);
|
|
@@ -89,6 +91,7 @@ class DirReply {
|
|
|
89
91
|
let command = commands[i];
|
|
90
92
|
if (command.type === 'message' && command.message && command.message.text) {
|
|
91
93
|
command.message.text = filler.fill(command.message.text, requestAttributes);
|
|
94
|
+
this.logger.debug("Filled message.text with ", command.message.text)
|
|
92
95
|
TiledeskChatbotUtil.fillCommandAttachments(command, requestAttributes, this.log);
|
|
93
96
|
winston.debug("DirReply command filled: " + command.message.text);
|
|
94
97
|
}
|
|
@@ -143,15 +146,6 @@ class DirReply {
|
|
|
143
146
|
}
|
|
144
147
|
|
|
145
148
|
let cleanMessage = message;
|
|
146
|
-
this.logger.info("3 Sending reply (text) " + cleanMessage.text);
|
|
147
|
-
this.logger.info("4 Sending reply with clean message " + JSON.stringify(cleanMessage));
|
|
148
|
-
// cleanMessage = TiledeskChatbotUtil.removeEmptyReplyCommands(message);
|
|
149
|
-
// if (!TiledeskChatbotUtil.isValidReply(cleanMessage)) {
|
|
150
|
-
// console.log("invalid message", cleanMessage);
|
|
151
|
-
// callback(); // cancel reply operation
|
|
152
|
-
// return;
|
|
153
|
-
// }
|
|
154
|
-
|
|
155
149
|
cleanMessage.senderFullname = this.context.chatbot.bot.name;
|
|
156
150
|
winston.debug("DirReply reply with clean message: ", cleanMessage);
|
|
157
151
|
|
|
@@ -162,10 +156,8 @@ class DirReply {
|
|
|
162
156
|
(err) => {
|
|
163
157
|
if (err) {
|
|
164
158
|
winston.error("DirReply Error sending reply: ", err);
|
|
165
|
-
this.logger.error("Error sending reply: " + err);
|
|
166
159
|
}
|
|
167
160
|
winston.verbose("DirReply reply message sent")
|
|
168
|
-
this.logger.info("5 Reply message sent");
|
|
169
161
|
const delay = TiledeskChatbotUtil.totalMessageWait(cleanMessage);
|
|
170
162
|
if (delay > 0 && delay <= 30000) { // prevent long delays
|
|
171
163
|
setTimeout(() => {
|
|
@@ -96,42 +96,4 @@ class DirWebResponse {
|
|
|
96
96
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* A stub to send message to the "ext/botId" endpoint, hosted by tilebot on:
|
|
103
|
-
* /${TILEBOT_ROUTE}/ext/${botId}
|
|
104
|
-
*
|
|
105
|
-
* @param {Object} webResponse. The webhook response to send back
|
|
106
|
-
* @param {Object} projectId. The projectId
|
|
107
|
-
* @param {string} botId. Tiledesk botId
|
|
108
|
-
* @param {string} token. User token
|
|
109
|
-
*/
|
|
110
|
-
// function sendResponse(webResponse, projectId, botId, callback) {
|
|
111
|
-
// const url = `${WEBHOOK_URL}/${projectId}/${botId}`;
|
|
112
|
-
// const HTTPREQUEST = {
|
|
113
|
-
// url: url,
|
|
114
|
-
// headers: {
|
|
115
|
-
// 'Content-Type': 'application/json'
|
|
116
|
-
// },
|
|
117
|
-
// json: webResponse,
|
|
118
|
-
// method: 'POST'
|
|
119
|
-
// };
|
|
120
|
-
// myrequest(
|
|
121
|
-
// HTTPREQUEST,
|
|
122
|
-
// function (err, resbody) {
|
|
123
|
-
// if (err) {
|
|
124
|
-
// if (callback) {
|
|
125
|
-
// callback(err);
|
|
126
|
-
// }
|
|
127
|
-
// }
|
|
128
|
-
// else {
|
|
129
|
-
// if (callback) {
|
|
130
|
-
// callback(null, resbody);
|
|
131
|
-
// }
|
|
132
|
-
// }
|
|
133
|
-
// }, false
|
|
134
|
-
// );
|
|
135
|
-
// }
|
|
136
|
-
|
|
137
99
|
module.exports = { DirWebResponse };
|
|
@@ -58,6 +58,7 @@ class Directives {
|
|
|
58
58
|
static MOVE_TO_UNASSIGNED = "move_to_unassigned";
|
|
59
59
|
static CONNECT_BLOCK = "connect_block";
|
|
60
60
|
static ADD_TAGS = 'add_tags'
|
|
61
|
+
static WEBHOOK = 'webhook';
|
|
61
62
|
static WEB_RESPONSE = "web_response";
|
|
62
63
|
|
|
63
64
|
// static WHEN_ONLINE_MOVE_TO_AGENT = "whenonlinemovetoagent"; // DEPRECATED?
|
|
@@ -319,55 +319,31 @@ class TiledeskChatbotUtil {
|
|
|
319
319
|
json_buttons.forEach(button => {
|
|
320
320
|
if (button.value && button.type === "action" && button.action) {
|
|
321
321
|
button.show_echo = true;
|
|
322
|
-
// console.log("pushing:", button)
|
|
323
322
|
final_buttons.push(button);
|
|
324
323
|
}
|
|
325
324
|
else if (button.value && button.type === "text") {
|
|
326
325
|
button.show_echo = true;
|
|
327
|
-
// console.log("pushing:", button)
|
|
328
326
|
final_buttons.push(button);
|
|
329
327
|
}
|
|
330
328
|
else if (button.value && button.type === "url" && button.link) {
|
|
331
329
|
button.show_echo = true;
|
|
332
|
-
// console.log("pushing:", button)
|
|
333
330
|
final_buttons.push(button);
|
|
334
331
|
}
|
|
335
332
|
else {
|
|
336
|
-
|
|
333
|
+
winston.verbose("Invalid button. Skipping:", button);
|
|
337
334
|
}
|
|
338
335
|
});
|
|
339
336
|
}
|
|
340
|
-
|
|
341
|
-
// "buttons": [
|
|
342
|
-
// {
|
|
343
|
-
// "type": "action",
|
|
344
|
-
// "value": "Button1", // obbligatorio sempre
|
|
345
|
-
// "action": "#bb347206-d639-4926-94c9-e94930623dce", // mandatory
|
|
346
|
-
// "show_echo": true, // lo inserisco sempre
|
|
347
|
-
// "alias": "button1 alias"
|
|
348
|
-
// },
|
|
349
|
-
// {
|
|
350
|
-
// "type": "text",
|
|
351
|
-
// "value": "Button2 text", // obbligatorio sempre
|
|
352
|
-
// "show_echo": true // lo inserisco sempre
|
|
353
|
-
// },
|
|
354
|
-
// {
|
|
355
|
-
// "type": "url",
|
|
356
|
-
// "value": "Button3 link", // obbligatorio sempre
|
|
357
|
-
// "link": "http://", // obbligatorio
|
|
358
|
-
// "show_echo": true // lo inserisco sempre
|
|
359
|
-
// }
|
|
360
|
-
// ]
|
|
361
337
|
}
|
|
362
338
|
catch(error) {
|
|
363
|
-
|
|
339
|
+
winston.warn("Invalid json_buttons:", error)
|
|
364
340
|
}
|
|
365
341
|
if (final_buttons && final_buttons.length > 0) {
|
|
366
342
|
command.message.attributes.attachment.buttons = final_buttons;
|
|
367
343
|
delete command.message.attributes.attachment.json_buttons;
|
|
368
344
|
}
|
|
369
345
|
else {
|
|
370
|
-
|
|
346
|
+
winston.verbose("Invalid json_buttons. Skipping...")
|
|
371
347
|
}
|
|
372
348
|
}
|
|
373
349
|
}
|
package/TdCache copy.js
DELETED
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
const redis = require('redis');
|
|
2
|
-
|
|
3
|
-
class TdCache {
|
|
4
|
-
|
|
5
|
-
constructor(config) {
|
|
6
|
-
this.redis_host = config.host;
|
|
7
|
-
this.redis_port = config.port;
|
|
8
|
-
this.redis_password = config.password;
|
|
9
|
-
this.client = null;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
async connect(callback) {
|
|
13
|
-
// client = redis.createClient();
|
|
14
|
-
return new Promise( async (resolve, reject) => {
|
|
15
|
-
this.client = redis.createClient(
|
|
16
|
-
{
|
|
17
|
-
host: this.redis_host,
|
|
18
|
-
port: this.redis_port,
|
|
19
|
-
password: this.redis_password
|
|
20
|
-
});
|
|
21
|
-
this.client.on('error', err => {
|
|
22
|
-
reject(err);
|
|
23
|
-
if (callback) {
|
|
24
|
-
callback(err);
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
// this.client.on('connect', function() {
|
|
28
|
-
// console.log('Redis Connected!');
|
|
29
|
-
// });
|
|
30
|
-
this.client.on('ready',function() {
|
|
31
|
-
console.log("connected")
|
|
32
|
-
resolve();
|
|
33
|
-
if (callback) {
|
|
34
|
-
callback();
|
|
35
|
-
}
|
|
36
|
-
//console.log("Redis is ready.");
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
async set(key, value, options) {
|
|
42
|
-
//console.log("setting key value", key, value)
|
|
43
|
-
if (!options) {
|
|
44
|
-
options = {EX: 86400}
|
|
45
|
-
}
|
|
46
|
-
return new Promise( async (resolve, reject) => {
|
|
47
|
-
if (options && options.EX) {
|
|
48
|
-
//console.log("expires:", options.EX)
|
|
49
|
-
try {
|
|
50
|
-
await this.client.set(
|
|
51
|
-
key,
|
|
52
|
-
value,
|
|
53
|
-
'EX', options.EX);
|
|
54
|
-
}
|
|
55
|
-
catch(error) {
|
|
56
|
-
reject(error)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
try {
|
|
61
|
-
//console.log("setting here...key", key, value)
|
|
62
|
-
await this.client.set(
|
|
63
|
-
key,
|
|
64
|
-
value);
|
|
65
|
-
}
|
|
66
|
-
catch(error) {
|
|
67
|
-
console.error("Error", error);
|
|
68
|
-
reject(error)
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (options && options.callback) {
|
|
72
|
-
options.callback();
|
|
73
|
-
}
|
|
74
|
-
//console.log("resolving...", key);
|
|
75
|
-
return resolve();
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
async incr(key) {
|
|
80
|
-
// console.log("incr key:", key)
|
|
81
|
-
return new Promise( async (resolve, reject) => {
|
|
82
|
-
try {
|
|
83
|
-
// console.log("incr here...key", key)
|
|
84
|
-
await this.client.incr(key);
|
|
85
|
-
}
|
|
86
|
-
catch(error) {
|
|
87
|
-
console.error("Error on incr:", error);
|
|
88
|
-
reject(error)
|
|
89
|
-
}
|
|
90
|
-
return resolve();
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async hset(dict_key, key, value, options) {
|
|
95
|
-
//console.log("hsetting dict_key key value", dict_key, key, value)
|
|
96
|
-
return new Promise( async (resolve, reject) => {
|
|
97
|
-
if (options && options.EX) {
|
|
98
|
-
//console.log("expires:", options.EX)
|
|
99
|
-
try {
|
|
100
|
-
await this.client.hset(
|
|
101
|
-
dict_key,
|
|
102
|
-
key,
|
|
103
|
-
value,
|
|
104
|
-
'EX', options.EX);
|
|
105
|
-
}
|
|
106
|
-
catch(error) {
|
|
107
|
-
reject(error)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
try {
|
|
112
|
-
//console.log("setting here...key", key, value)
|
|
113
|
-
await this.client.hset(
|
|
114
|
-
dict_key,
|
|
115
|
-
key,
|
|
116
|
-
value);
|
|
117
|
-
}
|
|
118
|
-
catch(error) {
|
|
119
|
-
console.error("Error", error);
|
|
120
|
-
reject(error)
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
if (options && options.callback) {
|
|
124
|
-
options.callback();
|
|
125
|
-
}
|
|
126
|
-
return resolve();
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async hdel(dict_key, key, options) {
|
|
131
|
-
//console.log("hsetting dict_key key value", dict_key, key, value)
|
|
132
|
-
return new Promise( async (resolve, reject) => {
|
|
133
|
-
if (options && options.EX) {
|
|
134
|
-
//console.log("expires:", options.EX)
|
|
135
|
-
try {
|
|
136
|
-
await this.client.hdel(
|
|
137
|
-
dict_key,
|
|
138
|
-
key,
|
|
139
|
-
'EX', options.EX);
|
|
140
|
-
}
|
|
141
|
-
catch(error) {
|
|
142
|
-
reject(error)
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
try {
|
|
147
|
-
//console.log("setting here...key", key, value)
|
|
148
|
-
await this.client.hdel(
|
|
149
|
-
dict_key,
|
|
150
|
-
key);
|
|
151
|
-
}
|
|
152
|
-
catch(error) {
|
|
153
|
-
console.error("Error", error);
|
|
154
|
-
reject(error);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
if (options && options.callback) {
|
|
158
|
-
options.callback();
|
|
159
|
-
}
|
|
160
|
-
return resolve();
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
async setJSON(key, value, options) {
|
|
165
|
-
const _string = JSON.stringify(value);
|
|
166
|
-
return await this.set(key, _string, options);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
async get(key, callback) {
|
|
170
|
-
//console.log("getting key", key)
|
|
171
|
-
return new Promise( async (resolve, reject) => {
|
|
172
|
-
this.client.get(key, (err, value) => {
|
|
173
|
-
if (err) {
|
|
174
|
-
reject(err);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
if (callback) {
|
|
178
|
-
callback(value);
|
|
179
|
-
}
|
|
180
|
-
return resolve(value);
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
async hgetall(dict_key, callback) {
|
|
187
|
-
//console.log("hgetting dics", dict_key);
|
|
188
|
-
return new Promise( async (resolve, reject) => {
|
|
189
|
-
this.client.hgetall(dict_key, (err, value) => {
|
|
190
|
-
if (err) {
|
|
191
|
-
reject(err);
|
|
192
|
-
if (callback) {
|
|
193
|
-
callback(err, null);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
if (callback) {
|
|
198
|
-
callback(null, value);
|
|
199
|
-
}
|
|
200
|
-
resolve(value);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async hget(dict_key, key, callback) {
|
|
207
|
-
//console.log("hgetting dics", dict_key);
|
|
208
|
-
return new Promise( async (resolve, reject) => {
|
|
209
|
-
this.client.hget(dict_key, key, (err, value) => {
|
|
210
|
-
if (err) {
|
|
211
|
-
reject(err);
|
|
212
|
-
if (callback) {
|
|
213
|
-
callback(err, null);
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
if (callback) {
|
|
218
|
-
callback(null, value);
|
|
219
|
-
}
|
|
220
|
-
resolve(value);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
async getJSON(key, callback) {
|
|
227
|
-
const value = await this.get(key);
|
|
228
|
-
return JSON.parse(value);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
async del(key, callback) {
|
|
232
|
-
return new Promise( async (resolve, reject) => {
|
|
233
|
-
await this.client.del(key);
|
|
234
|
-
if (callback) {
|
|
235
|
-
callback();
|
|
236
|
-
}
|
|
237
|
-
return resolve();
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
module.exports = { TdCache };
|