@tiledesk/tiledesk-tybot-connector 2.0.20 → 2.0.21-rc10
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 +27 -2
- package/Logger.js +3 -0
- package/engine/mock/MockBotsDataSource.js +1 -2
- package/index.js +3 -0
- package/logs/app.log +5296 -0
- package/package.json +1 -1
- package/services/LLMService.js +105 -0
- package/services/QuotasService.js +69 -0
- package/tiledeskChatbotPlugs/DirectivesChatbotPlug.js +29 -11
- package/tiledeskChatbotPlugs/directives/DirAddKbContent.js +26 -25
- package/tiledeskChatbotPlugs/directives/DirAskGPTV2.js +37 -109
- package/tiledeskChatbotPlugs/directives/DirReplyV2.js +1 -0
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2.js +1 -1
- package/tiledeskChatbotPlugs/directives/DirWebResponse.js +1 -0
- package/tiledeskChatbotPlugs/directives/Directives.js +1 -0
- package/utils/TiledeskChatbotUtil.js +203 -27
- package/TdCache copy.js +0 -242
- package/tiledeskChatbotPlugs/directives/DirWebRequestV2_old.js +0 -418
|
@@ -307,32 +307,204 @@ class TiledeskChatbotUtil {
|
|
|
307
307
|
if (command.message.attributes && command.message.attributes.attachment && command.message.attributes.attachment.json_buttons){
|
|
308
308
|
// console.log("command with buttons ok:")
|
|
309
309
|
let json_buttons_string = command.message.attributes.attachment.json_buttons;
|
|
310
|
-
|
|
311
|
-
let final_buttons =
|
|
310
|
+
console.log("json_buttons_string:", json_buttons_string)
|
|
311
|
+
let final_buttons = this.renderJSONButtons(json_buttons_string, flow_attributes);
|
|
312
|
+
// let final_buttons = [];
|
|
313
|
+
// try {
|
|
314
|
+
// // fill buttons
|
|
315
|
+
// const filler = new Filler();
|
|
316
|
+
// json_buttons_string = filler.fill(json_buttons_string, flow_attributes);
|
|
317
|
+
// let json_buttons = JSON.parse(json_buttons_string);
|
|
318
|
+
// if (Array.isArray(json_buttons)) {
|
|
319
|
+
// json_buttons.forEach(button => {
|
|
320
|
+
// if (button.value && button.type === "action" && button.action) {
|
|
321
|
+
// button.show_echo = true;
|
|
322
|
+
// final_buttons.push(button);
|
|
323
|
+
// }
|
|
324
|
+
// else if (button.value && button.type === "text") {
|
|
325
|
+
// button.show_echo = true;
|
|
326
|
+
// final_buttons.push(button);
|
|
327
|
+
// }
|
|
328
|
+
// else if (button.value && button.type === "url" && button.link) {
|
|
329
|
+
// button.show_echo = true;
|
|
330
|
+
// final_buttons.push(button);
|
|
331
|
+
// }
|
|
332
|
+
// else {
|
|
333
|
+
// winston.verbose("Invalid button. Skipping:", button);
|
|
334
|
+
// }
|
|
335
|
+
// });
|
|
336
|
+
// }
|
|
337
|
+
|
|
338
|
+
// // "buttons": [
|
|
339
|
+
// // {
|
|
340
|
+
// // "type": "action",
|
|
341
|
+
// // "value": "Button1", // obbligatorio sempre
|
|
342
|
+
// // "action": "#bb347206-d639-4926-94c9-e94930623dce", // mandatory
|
|
343
|
+
// // "show_echo": true, // lo inserisco sempre
|
|
344
|
+
// // "alias": "button1 alias"
|
|
345
|
+
// // },
|
|
346
|
+
// // {
|
|
347
|
+
// // "type": "text",
|
|
348
|
+
// // "value": "Button2 text", // obbligatorio sempre
|
|
349
|
+
// // "show_echo": true // lo inserisco sempre
|
|
350
|
+
// // },
|
|
351
|
+
// // {
|
|
352
|
+
// // "type": "url",
|
|
353
|
+
// // "value": "Button3 link", // obbligatorio sempre
|
|
354
|
+
// // "link": "http://", // obbligatorio
|
|
355
|
+
// // "show_echo": true // lo inserisco sempre
|
|
356
|
+
// // }
|
|
357
|
+
// // ]
|
|
358
|
+
// }
|
|
359
|
+
// catch(error) {
|
|
360
|
+
// winston.warn("Invalid json_buttons:", error)
|
|
361
|
+
// }
|
|
362
|
+
if (final_buttons && final_buttons.length > 0) {
|
|
363
|
+
command.message.attributes.attachment.buttons = final_buttons;
|
|
364
|
+
delete command.message.attributes.attachment.json_buttons;
|
|
365
|
+
}
|
|
366
|
+
else {
|
|
367
|
+
winston.verbose("Invalid json_buttons. Skipping...")
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
return all_buttons;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
static renderJSONButtons(json_buttons_string, flow_attributes) {
|
|
378
|
+
let final_buttons = [];
|
|
379
|
+
try {
|
|
380
|
+
// fill buttons
|
|
381
|
+
const filler = new Filler();
|
|
382
|
+
json_buttons_string = filler.fill(json_buttons_string, flow_attributes);
|
|
383
|
+
let json_buttons = JSON.parse(json_buttons_string);
|
|
384
|
+
if (Array.isArray(json_buttons)) {
|
|
385
|
+
json_buttons.forEach(button => {
|
|
386
|
+
if (button.value && button.type === "action" && button.action) {
|
|
387
|
+
button.show_echo = true;
|
|
388
|
+
final_buttons.push(button);
|
|
389
|
+
}
|
|
390
|
+
else if (button.value && button.type === "text") {
|
|
391
|
+
button.show_echo = true;
|
|
392
|
+
final_buttons.push(button);
|
|
393
|
+
}
|
|
394
|
+
else if (button.value && button.type === "url" && button.link) {
|
|
395
|
+
button.show_echo = true;
|
|
396
|
+
final_buttons.push(button);
|
|
397
|
+
}
|
|
398
|
+
else {
|
|
399
|
+
winston.verbose("Invalid button. Skipping:", button);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
// "buttons": [
|
|
405
|
+
// {
|
|
406
|
+
// "type": "action",
|
|
407
|
+
// "value": "Button1", // obbligatorio sempre
|
|
408
|
+
// "action": "#bb347206-d639-4926-94c9-e94930623dce", // mandatory
|
|
409
|
+
// "show_echo": true, // lo inserisco sempre
|
|
410
|
+
// "alias": "button1 alias"
|
|
411
|
+
// },
|
|
412
|
+
// {
|
|
413
|
+
// "type": "text",
|
|
414
|
+
// "value": "Button2 text", // obbligatorio sempre
|
|
415
|
+
// "show_echo": true // lo inserisco sempre
|
|
416
|
+
// },
|
|
417
|
+
// {
|
|
418
|
+
// "type": "url",
|
|
419
|
+
// "value": "Button3 link", // obbligatorio sempre
|
|
420
|
+
// "link": "http://", // obbligatorio
|
|
421
|
+
// "show_echo": true // lo inserisco sempre
|
|
422
|
+
// }
|
|
423
|
+
// ]
|
|
424
|
+
}
|
|
425
|
+
catch(error) {
|
|
426
|
+
winston.warn("Invalid json_buttons:", error)
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
return final_buttons;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
static replaceJSONGalleries(message, flow_attributes) {
|
|
433
|
+
console.log("replaceJSONGalleries...");
|
|
434
|
+
if (message.attributes && message.attributes.commands) {
|
|
435
|
+
console.log("message.attributes && message.attributes.commands...");
|
|
436
|
+
let commands = message.attributes.commands;
|
|
437
|
+
if (commands.length > 0) {
|
|
438
|
+
console.log("commands.length > 0");
|
|
439
|
+
for (let i = 0; i < commands.length; i++) {
|
|
440
|
+
let command = commands[i];
|
|
441
|
+
console.log("command:", JSON.stringify(command));
|
|
442
|
+
if (command.type === 'message' && command.message) {
|
|
443
|
+
console.log("command.type === 'message' && command.message");
|
|
444
|
+
if (command.message.attributes && command.message.attributes.attachment && command.message.attributes.attachment.json_gallery){
|
|
445
|
+
console.log("command with json_galley")
|
|
446
|
+
let final_gallery = [];
|
|
312
447
|
try {
|
|
313
|
-
// fill
|
|
448
|
+
// fill previews
|
|
314
449
|
const filler = new Filler();
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
button.show_echo = true;
|
|
325
|
-
final_buttons.push(button);
|
|
326
|
-
}
|
|
327
|
-
else if (button.value && button.type === "url" && button.link) {
|
|
328
|
-
button.show_echo = true;
|
|
329
|
-
final_buttons.push(button);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
winston.verbose("Invalid button. Skipping:", button);
|
|
450
|
+
let json_gallery_string = command.message.attributes.attachment.json_gallery;
|
|
451
|
+
console.log("gallerystring is:", json_gallery_string)
|
|
452
|
+
json_gallery_string = filler.fill(json_gallery_string, flow_attributes);
|
|
453
|
+
let json_gallery = JSON.parse(json_gallery_string);
|
|
454
|
+
if (Array.isArray(json_gallery)) {
|
|
455
|
+
console.log("is gallery")
|
|
456
|
+
json_gallery.forEach(el => {
|
|
457
|
+
if (el.buttons) {
|
|
458
|
+
el.buttons = TiledeskChatbotUtil.renderJSONButtons(JSON.stringify(el.buttons));
|
|
333
459
|
}
|
|
460
|
+
final_gallery.push(el);
|
|
334
461
|
});
|
|
462
|
+
console.log("final: ", final_gallery)
|
|
463
|
+
}
|
|
464
|
+
else {
|
|
465
|
+
winston.verbose("Invalid json_gallery.");
|
|
335
466
|
}
|
|
467
|
+
// "gallery": [
|
|
468
|
+
// {
|
|
469
|
+
// "preview": {
|
|
470
|
+
// "src": "https://eu.rtmv3.tiledesk.com/api/images?path=uploads%2Fusers%2F63a05d755f117f0013541383%2Fimages%2F8913ff2c-d788-45e1-ac71-ee5bae8479e2%2Fhybrid-settings.png",
|
|
471
|
+
// "uid": "mcamfa6s"
|
|
472
|
+
// },
|
|
473
|
+
// "title": "Title 1",
|
|
474
|
+
// "description": "Description 1",
|
|
475
|
+
// "buttons": [
|
|
476
|
+
// {
|
|
477
|
+
// "uid": "0a956f4637584ee4862360c19a161f8f",
|
|
478
|
+
// "type": "url",
|
|
479
|
+
// "value": "Prod1",
|
|
480
|
+
// "link": "https://URL1",
|
|
481
|
+
// "target": "blank",
|
|
482
|
+
// "action": "",
|
|
483
|
+
// "attributes": "",
|
|
484
|
+
// "show_echo": true
|
|
485
|
+
// },
|
|
486
|
+
// {
|
|
487
|
+
// "uid": "4a87abe3d03a4b6fbdbc3fc33c4a8430",
|
|
488
|
+
// "type": "action",
|
|
489
|
+
// "value": "Prod1.1 (connector)",
|
|
490
|
+
// "link": "",
|
|
491
|
+
// "target": "blank",
|
|
492
|
+
// "action": "#0f7aaefd-3147-466b-82a4-06756f36eea5",
|
|
493
|
+
// "attributes": "",
|
|
494
|
+
// "show_echo": true
|
|
495
|
+
// },
|
|
496
|
+
// {
|
|
497
|
+
// "uid": "31fac2c82ce24da0a2e9850a32165fe8",
|
|
498
|
+
// "type": "text",
|
|
499
|
+
// "value": "Prod1.2 (text)",
|
|
500
|
+
// "link": "https://url2",
|
|
501
|
+
// "target": "blank",
|
|
502
|
+
// "action": "",
|
|
503
|
+
// "attributes": "",
|
|
504
|
+
// "show_echo": true
|
|
505
|
+
// }
|
|
506
|
+
// ]
|
|
507
|
+
// },
|
|
336
508
|
|
|
337
509
|
// "buttons": [
|
|
338
510
|
// {
|
|
@@ -356,21 +528,23 @@ class TiledeskChatbotUtil {
|
|
|
356
528
|
// ]
|
|
357
529
|
}
|
|
358
530
|
catch(error) {
|
|
359
|
-
winston.warn("
|
|
531
|
+
winston.warn("Error on JSON gallery parsing:", error);
|
|
360
532
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
533
|
+
console.log("final gallery...", final_gallery)
|
|
534
|
+
if (final_gallery && final_gallery.length > 0) {
|
|
535
|
+
console.log("updating with final gallery...", final_gallery)
|
|
536
|
+
command.message.attributes.attachment.gallery = final_gallery;
|
|
537
|
+
delete command.message.attributes.attachment.json_gallery;
|
|
364
538
|
}
|
|
365
539
|
else {
|
|
366
|
-
winston.verbose("Invalid
|
|
540
|
+
winston.verbose("Invalid JSON Gallery.")
|
|
367
541
|
}
|
|
368
542
|
}
|
|
369
543
|
}
|
|
370
544
|
}
|
|
371
545
|
}
|
|
372
546
|
}
|
|
373
|
-
return
|
|
547
|
+
return message;
|
|
374
548
|
}
|
|
375
549
|
|
|
376
550
|
static buttonByText(text, buttons) {
|
|
@@ -604,8 +778,10 @@ class TiledeskChatbotUtil {
|
|
|
604
778
|
}
|
|
605
779
|
let currentLeadName = await chatbot.getParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY);
|
|
606
780
|
winston.debug("(TiledeskChatbotUtil) You lead email from attributes: " + currentLeadEmail);
|
|
781
|
+
console.log("currentLeadName: ", currentLeadName)
|
|
607
782
|
if (message.request.lead.fullname && !currentLeadName) {
|
|
608
783
|
// worth saving
|
|
784
|
+
console.log("inside if")
|
|
609
785
|
winston.debug("(TiledeskChatbotUtil) worth saving email");
|
|
610
786
|
try {
|
|
611
787
|
await chatbot.addParameter(TiledeskChatbotConst.REQ_LEAD_USERFULLNAME_KEY, message.request.lead.fullname);
|
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 };
|