sasat 0.22.8 → 0.22.9
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/cli/index.cjs +23 -5
- package/dist/cli/index.mjs +21 -3
- package/dist/comparison-Bkk-qNRi.d.cts +79 -0
- package/dist/comparison-HpKmxsjs.d.mts +79 -0
- package/dist/index-1a8KLRT7.d.mts +495 -0
- package/dist/index-lrk3IfPF.d.cts +495 -0
- package/dist/index.cjs +25 -829
- package/dist/index.d.cts +3 -495
- package/dist/index.d.mts +3 -495
- package/dist/index.mjs +2 -805
- package/dist/{migrate-mh3DLqgw.mjs → migrate-D-XR7Z0F.mjs} +90 -65
- package/dist/{migrate-COeYPag2.cjs → migrate-iJE4FjRh.cjs} +94 -63
- package/dist/migration/index.d.cts +2 -2
- package/dist/migration/index.d.mts +2 -2
- package/dist/src-CdwAbJV0.cjs +926 -0
- package/dist/src-DebKrtYl.mjs +806 -0
- package/dist/testing/index.cjs +70 -1
- package/dist/testing/index.d.cts +19 -2
- package/dist/testing/index.d.mts +19 -2
- package/dist/testing/index.mjs +69 -2
- package/dist/{util-IRlTD1y7.cjs → util-C5Jevn5B.cjs} +130 -0
- package/dist/{util-BcMcffJ8.mjs → util-Dkw5bD7a.mjs} +107 -1
- package/package.json +1 -1
- package/dist/comparison-CEpYTo3e.d.mts +0 -42
- package/dist/comparison-CIb9xu5T.d.cts +0 -42
- package/dist/dbClient-Bnk1JKBU.d.cts +0 -35
- package/dist/dbClient-TBYnlvTc.d.mts +0 -35
- package/dist/getDbClient-CNcumqpO.mjs +0 -108
- package/dist/getDbClient-Dnkk-peb.cjs +0 -131
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { a as SqlString, o as config } from "./util-BcMcffJ8.mjs";
|
|
2
|
-
import { createConnection, createPool } from "mysql2/promise";
|
|
3
|
-
//#region src/db/formatQuery.ts
|
|
4
|
-
const formatQuery = (str, ...params) => {
|
|
5
|
-
let ret = str[0];
|
|
6
|
-
for (let i = 0; i < params.length; i++) {
|
|
7
|
-
if (typeof params[i] === "function") ret += params[i]();
|
|
8
|
-
else if (Array.isArray(params[i])) ret += params[i].map((it) => SqlString.escape(it)).join(", ");
|
|
9
|
-
else ret += SqlString.escape(params[i]);
|
|
10
|
-
ret += str[i + 1];
|
|
11
|
-
}
|
|
12
|
-
return ret;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/db/connectors/dbClient.ts
|
|
16
|
-
const noop = () => {};
|
|
17
|
-
var SQLClient = class {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.logger = noop;
|
|
20
|
-
}
|
|
21
|
-
rawQuery(sql) {
|
|
22
|
-
this.logger(sql);
|
|
23
|
-
return this.execSql(sql);
|
|
24
|
-
}
|
|
25
|
-
rawCommand(sql) {
|
|
26
|
-
this.logger(sql);
|
|
27
|
-
return this.execSql(sql);
|
|
28
|
-
}
|
|
29
|
-
query(templateString, ...params) {
|
|
30
|
-
return this.rawQuery(formatQuery(templateString, ...params));
|
|
31
|
-
}
|
|
32
|
-
command(templateString, ...params) {
|
|
33
|
-
return this.rawCommand(formatQuery(templateString, ...params));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var SQLTransaction = class extends SQLClient {};
|
|
37
|
-
var DBClient = class extends SQLClient {
|
|
38
|
-
constructor(logger = noop) {
|
|
39
|
-
super();
|
|
40
|
-
this._released = false;
|
|
41
|
-
this.logger = logger;
|
|
42
|
-
}
|
|
43
|
-
isReleased() {
|
|
44
|
-
return this._released;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/db/connectors/mysql/transaction.ts
|
|
49
|
-
var MySqlTransaction = class extends SQLTransaction {
|
|
50
|
-
constructor(connection) {
|
|
51
|
-
super();
|
|
52
|
-
this.connection = connection;
|
|
53
|
-
}
|
|
54
|
-
async commit() {
|
|
55
|
-
const result = await this.connection.commit();
|
|
56
|
-
await this.connection.end();
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
async rollback() {
|
|
60
|
-
await this.connection.rollback();
|
|
61
|
-
await this.connection.end();
|
|
62
|
-
}
|
|
63
|
-
async execSql(sql) {
|
|
64
|
-
return (await this.connection.query(sql))[0];
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/db/connectors/mysql/poolClient.ts
|
|
69
|
-
var MysqlPoolClient = class extends DBClient {
|
|
70
|
-
constructor(poolOption, logger) {
|
|
71
|
-
super(logger);
|
|
72
|
-
this.poolOption = poolOption;
|
|
73
|
-
this.pool = createPool({
|
|
74
|
-
dateStrings: true,
|
|
75
|
-
...poolOption
|
|
76
|
-
});
|
|
77
|
-
this.release = this.release.bind(this);
|
|
78
|
-
}
|
|
79
|
-
async transaction() {
|
|
80
|
-
const connection = await createConnection({
|
|
81
|
-
...config().db,
|
|
82
|
-
dateStrings: true,
|
|
83
|
-
...this.poolOption
|
|
84
|
-
});
|
|
85
|
-
await connection.beginTransaction();
|
|
86
|
-
return new MySqlTransaction(connection);
|
|
87
|
-
}
|
|
88
|
-
async release() {
|
|
89
|
-
await this.pool.end();
|
|
90
|
-
this._released = true;
|
|
91
|
-
}
|
|
92
|
-
async execSql(sql) {
|
|
93
|
-
return (await this.pool.query(sql))[0];
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/db/getDbClient.ts
|
|
98
|
-
let client;
|
|
99
|
-
const getDbClient = (option, logger) => {
|
|
100
|
-
if (client && !client.isReleased()) return client;
|
|
101
|
-
client = new MysqlPoolClient({
|
|
102
|
-
...config().db,
|
|
103
|
-
...option
|
|
104
|
-
}, logger);
|
|
105
|
-
return client;
|
|
106
|
-
};
|
|
107
|
-
//#endregion
|
|
108
|
-
export { formatQuery as i, MySqlTransaction as n, DBClient as r, getDbClient as t };
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
const require_util = require("./util-IRlTD1y7.cjs");
|
|
2
|
-
let mysql2_promise = require("mysql2/promise");
|
|
3
|
-
//#region src/db/formatQuery.ts
|
|
4
|
-
const formatQuery = (str, ...params) => {
|
|
5
|
-
let ret = str[0];
|
|
6
|
-
for (let i = 0; i < params.length; i++) {
|
|
7
|
-
if (typeof params[i] === "function") ret += params[i]();
|
|
8
|
-
else if (Array.isArray(params[i])) ret += params[i].map((it) => require_util.SqlString.escape(it)).join(", ");
|
|
9
|
-
else ret += require_util.SqlString.escape(params[i]);
|
|
10
|
-
ret += str[i + 1];
|
|
11
|
-
}
|
|
12
|
-
return ret;
|
|
13
|
-
};
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/db/connectors/dbClient.ts
|
|
16
|
-
const noop = () => {};
|
|
17
|
-
var SQLClient = class {
|
|
18
|
-
constructor() {
|
|
19
|
-
this.logger = noop;
|
|
20
|
-
}
|
|
21
|
-
rawQuery(sql) {
|
|
22
|
-
this.logger(sql);
|
|
23
|
-
return this.execSql(sql);
|
|
24
|
-
}
|
|
25
|
-
rawCommand(sql) {
|
|
26
|
-
this.logger(sql);
|
|
27
|
-
return this.execSql(sql);
|
|
28
|
-
}
|
|
29
|
-
query(templateString, ...params) {
|
|
30
|
-
return this.rawQuery(formatQuery(templateString, ...params));
|
|
31
|
-
}
|
|
32
|
-
command(templateString, ...params) {
|
|
33
|
-
return this.rawCommand(formatQuery(templateString, ...params));
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
var SQLTransaction = class extends SQLClient {};
|
|
37
|
-
var DBClient = class extends SQLClient {
|
|
38
|
-
constructor(logger = noop) {
|
|
39
|
-
super();
|
|
40
|
-
this._released = false;
|
|
41
|
-
this.logger = logger;
|
|
42
|
-
}
|
|
43
|
-
isReleased() {
|
|
44
|
-
return this._released;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/db/connectors/mysql/transaction.ts
|
|
49
|
-
var MySqlTransaction = class extends SQLTransaction {
|
|
50
|
-
constructor(connection) {
|
|
51
|
-
super();
|
|
52
|
-
this.connection = connection;
|
|
53
|
-
}
|
|
54
|
-
async commit() {
|
|
55
|
-
const result = await this.connection.commit();
|
|
56
|
-
await this.connection.end();
|
|
57
|
-
return result;
|
|
58
|
-
}
|
|
59
|
-
async rollback() {
|
|
60
|
-
await this.connection.rollback();
|
|
61
|
-
await this.connection.end();
|
|
62
|
-
}
|
|
63
|
-
async execSql(sql) {
|
|
64
|
-
return (await this.connection.query(sql))[0];
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region src/db/connectors/mysql/poolClient.ts
|
|
69
|
-
var MysqlPoolClient = class extends DBClient {
|
|
70
|
-
constructor(poolOption, logger) {
|
|
71
|
-
super(logger);
|
|
72
|
-
this.poolOption = poolOption;
|
|
73
|
-
this.pool = (0, mysql2_promise.createPool)({
|
|
74
|
-
dateStrings: true,
|
|
75
|
-
...poolOption
|
|
76
|
-
});
|
|
77
|
-
this.release = this.release.bind(this);
|
|
78
|
-
}
|
|
79
|
-
async transaction() {
|
|
80
|
-
const connection = await (0, mysql2_promise.createConnection)({
|
|
81
|
-
...require_util.config().db,
|
|
82
|
-
dateStrings: true,
|
|
83
|
-
...this.poolOption
|
|
84
|
-
});
|
|
85
|
-
await connection.beginTransaction();
|
|
86
|
-
return new MySqlTransaction(connection);
|
|
87
|
-
}
|
|
88
|
-
async release() {
|
|
89
|
-
await this.pool.end();
|
|
90
|
-
this._released = true;
|
|
91
|
-
}
|
|
92
|
-
async execSql(sql) {
|
|
93
|
-
return (await this.pool.query(sql))[0];
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
//#endregion
|
|
97
|
-
//#region src/db/getDbClient.ts
|
|
98
|
-
let client;
|
|
99
|
-
const getDbClient = (option, logger) => {
|
|
100
|
-
if (client && !client.isReleased()) return client;
|
|
101
|
-
client = new MysqlPoolClient({
|
|
102
|
-
...require_util.config().db,
|
|
103
|
-
...option
|
|
104
|
-
}, logger);
|
|
105
|
-
return client;
|
|
106
|
-
};
|
|
107
|
-
//#endregion
|
|
108
|
-
Object.defineProperty(exports, "DBClient", {
|
|
109
|
-
enumerable: true,
|
|
110
|
-
get: function() {
|
|
111
|
-
return DBClient;
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
Object.defineProperty(exports, "MySqlTransaction", {
|
|
115
|
-
enumerable: true,
|
|
116
|
-
get: function() {
|
|
117
|
-
return MySqlTransaction;
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
Object.defineProperty(exports, "formatQuery", {
|
|
121
|
-
enumerable: true,
|
|
122
|
-
get: function() {
|
|
123
|
-
return formatQuery;
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
Object.defineProperty(exports, "getDbClient", {
|
|
127
|
-
enumerable: true,
|
|
128
|
-
get: function() {
|
|
129
|
-
return getDbClient;
|
|
130
|
-
}
|
|
131
|
-
});
|