@nymphjs/driver-mysql 1.0.0-beta.12 → 1.0.0-beta.121
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 +563 -0
- package/README.md +1 -1
- package/dist/MySQLDriver.d.ts +107 -24
- package/dist/MySQLDriver.js +1632 -755
- package/dist/MySQLDriver.js.map +1 -1
- package/dist/MySQLDriver.test.js +13 -12
- package/dist/MySQLDriver.test.js.map +1 -1
- package/dist/conf/defaults.d.ts +1 -1
- package/dist/conf/defaults.js +1 -3
- package/dist/conf/defaults.js.map +1 -1
- package/dist/conf/index.d.ts +66 -2
- package/dist/conf/index.js +2 -8
- package/dist/conf/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +4 -24
- package/dist/index.js.map +1 -1
- package/jest.config.js +31 -6
- package/package.json +31 -23
- package/src/MySQLDriver.test.ts +16 -5
- package/src/MySQLDriver.ts +2283 -1071
- package/src/conf/defaults.ts +1 -1
- package/src/conf/index.ts +67 -2
- package/src/index.ts +2 -2
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -0
- package/dist/conf/d.d.ts +0 -15
- package/dist/conf/d.js +0 -3
- package/dist/conf/d.js.map +0 -1
- package/dist/runMysqlSync.js +0 -44
- package/src/conf/d.ts +0 -67
- package/src/runMysqlSync.js +0 -44
- package/src/testmysql.js +0 -32
package/src/conf/defaults.ts
CHANGED
package/src/conf/index.ts
CHANGED
|
@@ -1,4 +1,69 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PoolOptions } from 'mysql2';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* MySQL Driver Config
|
|
5
|
+
*/
|
|
6
|
+
export interface MySQLDriverConfig {
|
|
7
|
+
/**
|
|
8
|
+
* The host on which to connect to MySQL. Can include a port, like
|
|
9
|
+
* hostname:port.
|
|
10
|
+
*/
|
|
11
|
+
host: string;
|
|
12
|
+
/**
|
|
13
|
+
* The port on which to connect to MySQL.
|
|
14
|
+
*/
|
|
15
|
+
port: number;
|
|
16
|
+
/**
|
|
17
|
+
* The MySQL user.
|
|
18
|
+
*/
|
|
19
|
+
user: string;
|
|
20
|
+
/**
|
|
21
|
+
* The MySQL password.
|
|
22
|
+
*/
|
|
23
|
+
password: string;
|
|
24
|
+
/**
|
|
25
|
+
* The MySQL database.
|
|
26
|
+
*/
|
|
27
|
+
database: string;
|
|
28
|
+
/**
|
|
29
|
+
* If you need to use custom options, like SSL, you can provide them here in
|
|
30
|
+
* place of the above options.
|
|
31
|
+
*/
|
|
32
|
+
customPoolConfig: PoolOptions | null;
|
|
33
|
+
/**
|
|
34
|
+
* The MySQL table name prefix.
|
|
35
|
+
*/
|
|
36
|
+
prefix: string;
|
|
37
|
+
/**
|
|
38
|
+
* The MySQL table engine.
|
|
39
|
+
*
|
|
40
|
+
* You should use MYISAM if you are using MySQL < 5.6.
|
|
41
|
+
*
|
|
42
|
+
* Options are: Any MySQL storage engine supported on your server.
|
|
43
|
+
*/
|
|
44
|
+
engine: string;
|
|
45
|
+
/**
|
|
46
|
+
* Whether to use transactions. If your table engine doesn't support
|
|
47
|
+
* it (like MYISAM), you should turn this off.
|
|
48
|
+
*/
|
|
49
|
+
transactions: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Whether to use foreign keys. If your table engine doesn't support
|
|
52
|
+
* it (like MYISAM), you should turn this off.
|
|
53
|
+
*/
|
|
54
|
+
foreignKeys: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether to use row locking. If your table engine doesn't support
|
|
57
|
+
* it (like MYISAM), you should turn this off.
|
|
58
|
+
*/
|
|
59
|
+
rowLocking: boolean;
|
|
60
|
+
/**
|
|
61
|
+
* Whether to use table locking. If you use row locking, this should be off.
|
|
62
|
+
* If you can't use row locking (like with MYISAM), you can use table
|
|
63
|
+
* locking to ensure data consistency.
|
|
64
|
+
*/
|
|
65
|
+
tableLocking: boolean;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
import defaults from './defaults.js';
|
|
4
69
|
export { defaults as MySQLDriverConfigDefaults };
|
package/src/index.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -2,10 +2,13 @@
|
|
|
2
2
|
"extends": "@tsconfig/recommended/tsconfig.json",
|
|
3
3
|
|
|
4
4
|
"compilerOptions": {
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"types": ["node", "jest"],
|
|
6
|
+
"module": "nodenext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"lib": ["es2023"],
|
|
9
|
+
"target": "es2023",
|
|
7
10
|
"noImplicitAny": true,
|
|
8
|
-
"removeComments":
|
|
11
|
+
"removeComments": false,
|
|
9
12
|
"sourceMap": true,
|
|
10
13
|
"outDir": "dist",
|
|
11
14
|
"resolveJsonModule": true,
|
package/typedoc.json
ADDED
package/dist/conf/d.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { default as MySQLType } from '@types/mysql';
|
|
2
|
-
export interface MySQLDriverConfig {
|
|
3
|
-
host: string;
|
|
4
|
-
port: number;
|
|
5
|
-
user: string;
|
|
6
|
-
password: string;
|
|
7
|
-
database: string;
|
|
8
|
-
customPoolConfig: MySQLType.PoolConfig | null;
|
|
9
|
-
prefix: string;
|
|
10
|
-
engine: string;
|
|
11
|
-
transactions: boolean;
|
|
12
|
-
foreignKeys: boolean;
|
|
13
|
-
rowLocking: boolean;
|
|
14
|
-
tableLocking: boolean;
|
|
15
|
-
}
|
package/dist/conf/d.js
DELETED
package/dist/conf/d.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"d.js","sourceRoot":"","sources":["../../src/conf/d.ts"],"names":[],"mappings":""}
|
package/dist/runMysqlSync.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const mysql = require('@vlasky/mysql');
|
|
2
|
-
|
|
3
|
-
let stdin = '';
|
|
4
|
-
|
|
5
|
-
process.stdin.on('data', (data) => {
|
|
6
|
-
if (data != null) {
|
|
7
|
-
stdin += data.toString();
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
process.stdin.on('end', () => {
|
|
12
|
-
run();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
async function run() {
|
|
16
|
-
try {
|
|
17
|
-
const { mysqlConfig, query, params } = JSON.parse(stdin);
|
|
18
|
-
const pool = mysql.createPool(mysqlConfig);
|
|
19
|
-
const [results, fields] = await new Promise((resolve, reject) =>
|
|
20
|
-
pool.query(query, params, (error, results, fields) => {
|
|
21
|
-
if (error) {
|
|
22
|
-
reject(error);
|
|
23
|
-
}
|
|
24
|
-
resolve([results, fields]);
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
process.stdout.end(
|
|
28
|
-
JSON.stringify({
|
|
29
|
-
results,
|
|
30
|
-
fields,
|
|
31
|
-
}),
|
|
32
|
-
'utf8',
|
|
33
|
-
() => {
|
|
34
|
-
pool.end(() => {
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
process.stderr.end(JSON.stringify(e), 'utf8', () => {
|
|
41
|
-
process.exit(1);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/conf/d.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
// @ts-ignore: types are wonky with @vlasky/mysql.
|
|
2
|
-
import { default as MySQLType } from '@types/mysql';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* MySQL Driver Config
|
|
6
|
-
*/
|
|
7
|
-
export interface MySQLDriverConfig {
|
|
8
|
-
/**
|
|
9
|
-
* The host on which to connect to MySQL. Can include a port, like
|
|
10
|
-
* hostname:port.
|
|
11
|
-
*/
|
|
12
|
-
host: string;
|
|
13
|
-
/**
|
|
14
|
-
* The port on which to connect to MySQL.
|
|
15
|
-
*/
|
|
16
|
-
port: number;
|
|
17
|
-
/**
|
|
18
|
-
* The MySQL user.
|
|
19
|
-
*/
|
|
20
|
-
user: string;
|
|
21
|
-
/**
|
|
22
|
-
* The MySQL password.
|
|
23
|
-
*/
|
|
24
|
-
password: string;
|
|
25
|
-
/**
|
|
26
|
-
* The MySQL database.
|
|
27
|
-
*/
|
|
28
|
-
database: string;
|
|
29
|
-
/**
|
|
30
|
-
* If you need to use custom options, like SSL, you can provide them here in
|
|
31
|
-
* place of the above options.
|
|
32
|
-
*/
|
|
33
|
-
customPoolConfig: MySQLType.PoolConfig | null;
|
|
34
|
-
/**
|
|
35
|
-
* The MySQL table name prefix.
|
|
36
|
-
*/
|
|
37
|
-
prefix: string;
|
|
38
|
-
/**
|
|
39
|
-
* The MySQL table engine.
|
|
40
|
-
*
|
|
41
|
-
* You should use MYISAM if you are using MySQL < 5.6.
|
|
42
|
-
*
|
|
43
|
-
* Options are: Any MySQL storage engine supported on your server.
|
|
44
|
-
*/
|
|
45
|
-
engine: string;
|
|
46
|
-
/**
|
|
47
|
-
* Whether to use transactions. If your table engine doesn't support
|
|
48
|
-
* it (like MYISAM), you should turn this off.
|
|
49
|
-
*/
|
|
50
|
-
transactions: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Whether to use foreign keys. If your table engine doesn't support
|
|
53
|
-
* it (like MYISAM), you should turn this off.
|
|
54
|
-
*/
|
|
55
|
-
foreignKeys: boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Whether to use row locking. If your table engine doesn't support
|
|
58
|
-
* it (like MYISAM), you should turn this off.
|
|
59
|
-
*/
|
|
60
|
-
rowLocking: boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Whether to use table locking. If you use row locking, this should be off.
|
|
63
|
-
* If you can't use row locking (like with MYISAM), you can use table
|
|
64
|
-
* locking to ensure data consistency.
|
|
65
|
-
*/
|
|
66
|
-
tableLocking: boolean;
|
|
67
|
-
}
|
package/src/runMysqlSync.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const mysql = require('@vlasky/mysql');
|
|
2
|
-
|
|
3
|
-
let stdin = '';
|
|
4
|
-
|
|
5
|
-
process.stdin.on('data', (data) => {
|
|
6
|
-
if (data != null) {
|
|
7
|
-
stdin += data.toString();
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
process.stdin.on('end', () => {
|
|
12
|
-
run();
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
async function run() {
|
|
16
|
-
try {
|
|
17
|
-
const { mysqlConfig, query, params } = JSON.parse(stdin);
|
|
18
|
-
const pool = mysql.createPool(mysqlConfig);
|
|
19
|
-
const [results, fields] = await new Promise((resolve, reject) =>
|
|
20
|
-
pool.query(query, params, (error, results, fields) => {
|
|
21
|
-
if (error) {
|
|
22
|
-
reject(error);
|
|
23
|
-
}
|
|
24
|
-
resolve([results, fields]);
|
|
25
|
-
})
|
|
26
|
-
);
|
|
27
|
-
process.stdout.end(
|
|
28
|
-
JSON.stringify({
|
|
29
|
-
results,
|
|
30
|
-
fields,
|
|
31
|
-
}),
|
|
32
|
-
'utf8',
|
|
33
|
-
() => {
|
|
34
|
-
pool.end(() => {
|
|
35
|
-
process.exit(0);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
);
|
|
39
|
-
} catch (e) {
|
|
40
|
-
process.stderr.end(JSON.stringify(e), 'utf8', () => {
|
|
41
|
-
process.exit(1);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
package/src/testmysql.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const cp = require('child_process');
|
|
2
|
-
|
|
3
|
-
const mysqlConfig = {
|
|
4
|
-
host: 'localhost',
|
|
5
|
-
user: 'nymph',
|
|
6
|
-
password: 'nymph',
|
|
7
|
-
database: 'nymph',
|
|
8
|
-
insecureAuth: true,
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const query = 'SELECT ? AS message;';
|
|
12
|
-
const params = ['Hello, world.'];
|
|
13
|
-
|
|
14
|
-
// const query =
|
|
15
|
-
// 'CREATE TABLE test (`id` INT UNSIGNED NOT NULL, PRIMARY KEY (`id`));';
|
|
16
|
-
// const params = [];
|
|
17
|
-
|
|
18
|
-
// const query = 'SELECT LOWER(HEX(UNHEX(?))) AS message;';
|
|
19
|
-
// const params = ['FF'];
|
|
20
|
-
|
|
21
|
-
const output = cp.spawnSync(process.argv0, [__dirname + '/runMysqlSync.js'], {
|
|
22
|
-
input: JSON.stringify({ mysqlConfig, query, params }),
|
|
23
|
-
timeout: 30000,
|
|
24
|
-
maxBuffer: 100 * 1024 * 1024,
|
|
25
|
-
encoding: 'utf8',
|
|
26
|
-
windowsHide: true,
|
|
27
|
-
});
|
|
28
|
-
const result = JSON.parse(output.stdout);
|
|
29
|
-
const err = output.status === 0 ? null : JSON.parse(output.stderr);
|
|
30
|
-
|
|
31
|
-
if (err) throw new Error(err.message);
|
|
32
|
-
console.log('Server reply: ', result);
|