@zintrust/db-mysql 2.0.0 → 2.0.1
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.d.ts +7 -0
- package/dist/index.js +43 -3
- package/package.json +5 -3
- package/dist/build-manifest.json +0 -51
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,13 @@ export type DatabaseConfig = {
|
|
|
10
10
|
logging?: boolean;
|
|
11
11
|
ssl?: boolean;
|
|
12
12
|
socketTimeoutMs?: number;
|
|
13
|
+
connectTimeoutMs?: number;
|
|
14
|
+
acquireTimeoutMs?: number;
|
|
15
|
+
enableKeepAlive?: boolean;
|
|
16
|
+
keepAliveInitialDelayMs?: number;
|
|
17
|
+
waitTimeoutSeconds?: number;
|
|
18
|
+
netReadTimeoutSeconds?: number;
|
|
19
|
+
netWriteTimeoutSeconds?: number;
|
|
13
20
|
readHosts?: string[];
|
|
14
21
|
};
|
|
15
22
|
export type QueryResult = {
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ const getSocketTimeoutMs = (config) => {
|
|
|
19
19
|
}
|
|
20
20
|
return 30000;
|
|
21
21
|
};
|
|
22
|
-
const createWorkersPool = async ({ mysql, host, port, database, user, password, tlsEnabled, timeoutMs, }) => {
|
|
22
|
+
const createWorkersPool = async ({ mysql, host, port, database, user, password, tlsEnabled, timeoutMs, connectTimeoutMs, acquireTimeoutMs, enableKeepAlive, keepAliveInitialDelayMs, sessionVariables, }) => {
|
|
23
23
|
if (!Cloudflare.isCloudflareSocketsEnabled()) {
|
|
24
24
|
throw ErrorFactory.createConfigError('Cloudflare sockets are disabled. Set ENABLE_CLOUDFLARE_SOCKETS=true to use MySQL sockets on Workers.');
|
|
25
25
|
}
|
|
@@ -34,10 +34,15 @@ const createWorkersPool = async ({ mysql, host, port, database, user, password,
|
|
|
34
34
|
connectionLimit: 10,
|
|
35
35
|
namedPlaceholders: false,
|
|
36
36
|
disableEval: true,
|
|
37
|
+
connectTimeout: connectTimeoutMs,
|
|
38
|
+
acquireTimeout: acquireTimeoutMs,
|
|
39
|
+
enableKeepAlive,
|
|
40
|
+
keepAliveInitialDelay: keepAliveInitialDelayMs,
|
|
41
|
+
sessionVariables,
|
|
37
42
|
stream: () => createSocket({ host, port, tls: tlsEnabled, timeoutMs }),
|
|
38
43
|
});
|
|
39
44
|
};
|
|
40
|
-
const createNodePool = (mysql, host, port, database, user, password, nodeMysqlSslConfig) => {
|
|
45
|
+
const createNodePool = ({ mysql, host, port, database, user, password, nodeMysqlSslConfig, connectTimeoutMs, acquireTimeoutMs, enableKeepAlive, keepAliveInitialDelayMs, sessionVariables, }) => {
|
|
41
46
|
return mysql.createPool({
|
|
42
47
|
host,
|
|
43
48
|
port,
|
|
@@ -48,6 +53,11 @@ const createNodePool = (mysql, host, port, database, user, password, nodeMysqlSs
|
|
|
48
53
|
waitForConnections: true,
|
|
49
54
|
connectionLimit: 10,
|
|
50
55
|
namedPlaceholders: false,
|
|
56
|
+
connectTimeout: connectTimeoutMs,
|
|
57
|
+
acquireTimeout: acquireTimeoutMs,
|
|
58
|
+
enableKeepAlive,
|
|
59
|
+
keepAliveInitialDelay: keepAliveInitialDelayMs,
|
|
60
|
+
sessionVariables,
|
|
51
61
|
});
|
|
52
62
|
};
|
|
53
63
|
const describeDriverError = (error) => {
|
|
@@ -149,6 +159,13 @@ function normalizeQueryResult(raw) {
|
|
|
149
159
|
}
|
|
150
160
|
return { rows: [], rowCount: 0 };
|
|
151
161
|
}
|
|
162
|
+
const getSessionVariables = (config) => {
|
|
163
|
+
const sessionVariables = {};
|
|
164
|
+
sessionVariables.wait_timeout = config.waitTimeoutSeconds ?? 28800;
|
|
165
|
+
sessionVariables.net_read_timeout = config.netReadTimeoutSeconds ?? 120;
|
|
166
|
+
sessionVariables.net_write_timeout = config.netWriteTimeoutSeconds ?? 120;
|
|
167
|
+
return sessionVariables;
|
|
168
|
+
};
|
|
152
169
|
async function connect(state, config) {
|
|
153
170
|
if (state.connected)
|
|
154
171
|
return;
|
|
@@ -159,6 +176,11 @@ async function connect(state, config) {
|
|
|
159
176
|
const tlsEnabled = Boolean(config.ssl);
|
|
160
177
|
const nodeMysqlSslConfig = getNodeMysqlSslConfig(tlsEnabled);
|
|
161
178
|
const timeoutMs = getSocketTimeoutMs(config);
|
|
179
|
+
const connectTimeoutMs = config.connectTimeoutMs ?? Math.max(timeoutMs, 60000);
|
|
180
|
+
const acquireTimeoutMs = config.acquireTimeoutMs ?? Math.max(timeoutMs, 60000);
|
|
181
|
+
const enableKeepAlive = config.enableKeepAlive ?? true;
|
|
182
|
+
const keepAliveInitialDelayMs = config.keepAliveInitialDelayMs ?? 0;
|
|
183
|
+
const sessionVariables = getSessionVariables(config);
|
|
162
184
|
if (isWorkersRuntime) {
|
|
163
185
|
state.pool = await createWorkersPool({
|
|
164
186
|
mysql,
|
|
@@ -169,10 +191,28 @@ async function connect(state, config) {
|
|
|
169
191
|
password,
|
|
170
192
|
tlsEnabled,
|
|
171
193
|
timeoutMs,
|
|
194
|
+
connectTimeoutMs,
|
|
195
|
+
acquireTimeoutMs,
|
|
196
|
+
enableKeepAlive,
|
|
197
|
+
keepAliveInitialDelayMs,
|
|
198
|
+
sessionVariables,
|
|
172
199
|
});
|
|
173
200
|
}
|
|
174
201
|
else {
|
|
175
|
-
state.pool = createNodePool(
|
|
202
|
+
state.pool = createNodePool({
|
|
203
|
+
mysql,
|
|
204
|
+
host,
|
|
205
|
+
port,
|
|
206
|
+
database,
|
|
207
|
+
user,
|
|
208
|
+
password,
|
|
209
|
+
nodeMysqlSslConfig,
|
|
210
|
+
connectTimeoutMs,
|
|
211
|
+
acquireTimeoutMs,
|
|
212
|
+
enableKeepAlive,
|
|
213
|
+
keepAliveInitialDelayMs,
|
|
214
|
+
sessionVariables,
|
|
215
|
+
});
|
|
176
216
|
}
|
|
177
217
|
// Probe.
|
|
178
218
|
await state.pool.execute('SELECT 1');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zintrust/db-mysql",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "MySQL and MariaDB database adapter for ZinTrust.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,9 @@
|
|
|
26
26
|
"@zintrust/core": "*"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|
|
29
|
-
"access": "public"
|
|
29
|
+
"access": "public",
|
|
30
|
+
"registry": "https://registry.npmjs.org/",
|
|
31
|
+
"tag": "next"
|
|
30
32
|
},
|
|
31
33
|
"keywords": [
|
|
32
34
|
"zintrust",
|
|
@@ -42,4 +44,4 @@
|
|
|
42
44
|
"dependencies": {
|
|
43
45
|
"mysql2": "^3.22.3"
|
|
44
46
|
}
|
|
45
|
-
}
|
|
47
|
+
}
|
package/dist/build-manifest.json
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@zintrust/db-mysql",
|
|
3
|
-
"version": "2.0.0",
|
|
4
|
-
"buildDate": "2026-05-20T20:01:33.335Z",
|
|
5
|
-
"buildEnvironment": {
|
|
6
|
-
"node": "v20.20.2",
|
|
7
|
-
"platform": "linux",
|
|
8
|
-
"arch": "x64"
|
|
9
|
-
},
|
|
10
|
-
"git": {
|
|
11
|
-
"commit": "be96835b",
|
|
12
|
-
"branch": "master"
|
|
13
|
-
},
|
|
14
|
-
"package": {
|
|
15
|
-
"engines": {
|
|
16
|
-
"node": ">=20.0.0"
|
|
17
|
-
},
|
|
18
|
-
"dependencies": [
|
|
19
|
-
"mysql2"
|
|
20
|
-
],
|
|
21
|
-
"peerDependencies": [
|
|
22
|
-
"@zintrust/core"
|
|
23
|
-
]
|
|
24
|
-
},
|
|
25
|
-
"files": {
|
|
26
|
-
"common.d.ts": {
|
|
27
|
-
"size": 615,
|
|
28
|
-
"sha256": "fafe13a87e5239d41b537dcdf23d7fc84c25d7b34207d272f149cbadfebfb417"
|
|
29
|
-
},
|
|
30
|
-
"common.js": {
|
|
31
|
-
"size": 580,
|
|
32
|
-
"sha256": "71e659214b8f208ec303756a4ed796f9904a5c2d5f6ba71ae03603be3773851c"
|
|
33
|
-
},
|
|
34
|
-
"index.d.ts": {
|
|
35
|
-
"size": 1460,
|
|
36
|
-
"sha256": "e3fee6b22d26a931b8a8254267ad5621b1fcf26c606b7749190ee4ccfed24cd3"
|
|
37
|
-
},
|
|
38
|
-
"index.js": {
|
|
39
|
-
"size": 11637,
|
|
40
|
-
"sha256": "7611cee2b530aceffb49c4a99cd7c08f61478953fd4e1ec7231c38e4ae607a9f"
|
|
41
|
-
},
|
|
42
|
-
"register.d.ts": {
|
|
43
|
-
"size": 180,
|
|
44
|
-
"sha256": "1ac7cca6cfbda8e5a65153917d4bbb4dd4fbe309dcabf9d9bdfb1eea6e97e52e"
|
|
45
|
-
},
|
|
46
|
-
"register.js": {
|
|
47
|
-
"size": 1066,
|
|
48
|
-
"sha256": "776afb1a7728d8448454a5aee172ce123d81ccf0619cf0228578d55e10697b62"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|