@builderbot/database-mysql 1.0.23-alpha.0 → 1.0.24-alpha.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/dist/index.cjs +14 -13
- package/dist/mysqlAdapter.d.ts +2 -2
- package/dist/mysqlAdapter.d.ts.map +1 -1
- package/dist/types.d.ts +2 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,10 @@ class MysqlAdapter extends bot.MemoryDB {
|
|
|
7
7
|
constructor(_credentials) {
|
|
8
8
|
super();
|
|
9
9
|
this.listHistory = [];
|
|
10
|
-
this.credentials = {
|
|
10
|
+
this.credentials = {
|
|
11
|
+
host: null, user: null, database: null, password: null,
|
|
12
|
+
port: 3306
|
|
13
|
+
};
|
|
11
14
|
this.getPrevByNumber = async (from) => {
|
|
12
15
|
return await new Promise((resolve, reject) => {
|
|
13
16
|
const sql = `SELECT * FROM history WHERE phone='${from}' ORDER BY id DESC`;
|
|
@@ -27,9 +30,7 @@ class MysqlAdapter extends bot.MemoryDB {
|
|
|
27
30
|
});
|
|
28
31
|
};
|
|
29
32
|
this.save = async (ctx) => {
|
|
30
|
-
const values = [
|
|
31
|
-
[ctx.ref, ctx.keyword, ctx.answer, ctx.refSerialize, ctx.from, JSON.stringify(ctx.options)],
|
|
32
|
-
];
|
|
33
|
+
const values = [[ctx.ref, ctx.keyword, ctx.answer, ctx.refSerialize, ctx.from, JSON.stringify(ctx.options)]];
|
|
33
34
|
const sql = 'INSERT INTO history (ref, keyword, answer, refSerialize, phone, options) values ?';
|
|
34
35
|
this.db.query(sql, [values], (err) => {
|
|
35
36
|
if (err)
|
|
@@ -38,15 +39,15 @@ class MysqlAdapter extends bot.MemoryDB {
|
|
|
38
39
|
};
|
|
39
40
|
this.createTable = () => new Promise((resolve) => {
|
|
40
41
|
const tableName = 'history';
|
|
41
|
-
const sql = `CREATE TABLE ${tableName}
|
|
42
|
-
(id INT AUTO_INCREMENT PRIMARY KEY,
|
|
43
|
-
ref varchar(255) DEFAULT NULL,
|
|
44
|
-
keyword varchar(255) NULL,
|
|
45
|
-
answer longtext NOT NULL,
|
|
46
|
-
refSerialize varchar(255) NOT NULL,
|
|
47
|
-
phone varchar(255) NOT NULL,
|
|
48
|
-
options longtext NOT NULL,
|
|
49
|
-
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
|
|
42
|
+
const sql = `CREATE TABLE ${tableName}
|
|
43
|
+
(id INT AUTO_INCREMENT PRIMARY KEY,
|
|
44
|
+
ref varchar(255) DEFAULT NULL,
|
|
45
|
+
keyword varchar(255) NULL,
|
|
46
|
+
answer longtext NOT NULL,
|
|
47
|
+
refSerialize varchar(255) NOT NULL,
|
|
48
|
+
phone varchar(255) NOT NULL,
|
|
49
|
+
options longtext NOT NULL,
|
|
50
|
+
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)
|
|
50
51
|
CHARACTER SET utf8mb4 COLLATE utf8mb4_General_ci`;
|
|
51
52
|
this.db.query(sql, (err) => {
|
|
52
53
|
if (err)
|
package/dist/mysqlAdapter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MemoryDB } from '@builderbot/bot';
|
|
2
|
-
import { Connection } from 'mysql2';
|
|
2
|
+
import type { Connection } from 'mysql2';
|
|
3
3
|
|
|
4
|
-
import { HistoryRow, MysqlAdapterCredentials } from './types';
|
|
4
|
+
import type { HistoryRow, MysqlAdapterCredentials } from './types';
|
|
5
5
|
declare class MysqlAdapter extends MemoryDB {
|
|
6
6
|
db: Connection;
|
|
7
7
|
listHistory: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mysqlAdapter.d.ts","sourceRoot":"","sources":["../src/mysqlAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,
|
|
1
|
+
{"version":3,"file":"mysqlAdapter.d.ts","sourceRoot":"","sources":["../src/mysqlAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAC1C,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,QAAQ,CAAA;AAGjE,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAA;AAElE,cAAM,YAAa,SAAQ,QAAQ;IAC/B,EAAE,EAAE,UAAU,CAAA;IACd,WAAW,QAAK;IAChB,WAAW,EAAE,uBAAuB,CAGnC;gBAEW,YAAY,EAAE,uBAAuB;IAM3C,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAe3B,eAAe,SAAgB,GAAG,KAAG,QAAQ,UAAU,CAAC,CAiBvD;IAED,IAAI,QAAe;QACf,GAAG,EAAE,MAAM,CAAA;QACX,OAAO,EAAE,MAAM,CAAA;QACf,MAAM,EAAE,GAAG,CAAA;QACX,YAAY,EAAE,MAAM,CAAA;QACpB,IAAI,EAAE,MAAM,CAAA;QACZ,OAAO,EAAE,GAAG,CAAA;KACf,KAAG,QAAQ,IAAI,CAAC,CAOhB;IAED,WAAW,QAAO,QAAQ,OAAO,CAAC,CAoB5B;IAEN,gBAAgB,QAAO,QAAQ,OAAO,CAAC,CAYjC;CACT;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { RowDataPacket } from 'mysql2';
|
|
1
|
+
import type { RowDataPacket } from 'mysql2';
|
|
2
2
|
export interface MysqlAdapterCredentials {
|
|
3
3
|
host: string;
|
|
4
4
|
user: string;
|
|
5
5
|
database: string;
|
|
6
6
|
password: string;
|
|
7
|
+
port: number;
|
|
7
8
|
}
|
|
8
9
|
export interface HistoryRow extends RowDataPacket {
|
|
9
10
|
id: number;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AAE3C,MAAM,WAAW,uBAAuB;IACpC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,UAAW,SAAQ,aAAa;IAC7C,EAAE,EAAE,MAAM,CAAA;IACV,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,EAAE,IAAI,CAAA;CACnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builderbot/database-mysql",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24-alpha.0",
|
|
4
4
|
"description": "Esto es el conector a Mysql",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"author": "Leifer Mendez <leifer33@gmail.com>",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/codigoencasa/bot-whatsapp#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@builderbot/bot": "^1.0.
|
|
33
|
+
"@builderbot/bot": "^1.0.24-alpha.0",
|
|
34
34
|
"mysql2": "^2.3.3"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"tslib": "^2.6.2",
|
|
47
47
|
"tsm": "^2.3.0"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "955cb22f5fbc30c60ac83edeb7f4261ca46f1ab3"
|
|
50
50
|
}
|