@faasjs/knex 0.0.2-beta.397 → 0.0.2-beta.400
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 +0 -2
- package/dist/index.js +8 -9
- package/dist/index.mjs +8 -9
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Plugin, DeployData, Next, MountData, UseifyPlugin } from '@faasjs/func';
|
|
2
|
-
import { Logger } from '@faasjs/logger';
|
|
3
2
|
import { Knex as Knex$1 } from 'knex';
|
|
4
3
|
|
|
5
4
|
declare type KnexConfig = {
|
|
@@ -15,7 +14,6 @@ declare class Knex implements Plugin {
|
|
|
15
14
|
config: Knex$1.Config;
|
|
16
15
|
adapter: Knex$1;
|
|
17
16
|
query: Knex$1;
|
|
18
|
-
logger: Logger;
|
|
19
17
|
/**
|
|
20
18
|
* 创建插件实例
|
|
21
19
|
* @param config {object} 配置
|
package/dist/index.js
CHANGED
|
@@ -52,7 +52,6 @@ var Knex = class {
|
|
|
52
52
|
this.name = this.type;
|
|
53
53
|
this.config = /* @__PURE__ */ Object.create(null);
|
|
54
54
|
}
|
|
55
|
-
this.logger = new import_logger.Logger(this.name);
|
|
56
55
|
}
|
|
57
56
|
async onDeploy(data, next) {
|
|
58
57
|
const client = data.config.plugins[this.name].config.client;
|
|
@@ -63,7 +62,7 @@ var Knex = class {
|
|
|
63
62
|
data.dependencies["better-sqlite3"] = "*";
|
|
64
63
|
else
|
|
65
64
|
data.dependencies[client] = "*";
|
|
66
|
-
this.
|
|
65
|
+
new import_logger.Logger(this.name).debug("add dependencies: " + client);
|
|
67
66
|
await next();
|
|
68
67
|
}
|
|
69
68
|
async onMount(data, next) {
|
|
@@ -120,23 +119,23 @@ var Knex = class {
|
|
|
120
119
|
__knexQueryUid,
|
|
121
120
|
bindings
|
|
122
121
|
}) => {
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
data.logger.time(`Knex${__knexQueryUid}`);
|
|
123
|
+
data.logger.debug("[%s] query begin: %s %j", this.name, sql, bindings);
|
|
125
124
|
}).on("query-response", (response, {
|
|
126
125
|
sql,
|
|
127
126
|
__knexQueryUid,
|
|
128
127
|
bindings
|
|
129
128
|
}) => {
|
|
130
|
-
|
|
129
|
+
data.logger.timeEnd(`Knex${__knexQueryUid}`, "[%s] query done: %s %j %j", this.name, sql, bindings, response);
|
|
131
130
|
}).on("query-error", (_, {
|
|
132
131
|
__knexQueryUid,
|
|
133
132
|
sql,
|
|
134
133
|
bindings
|
|
135
134
|
}) => {
|
|
136
|
-
|
|
135
|
+
data.logger.timeEnd(`Knex${__knexQueryUid}`, "[%s] query failed: %s %j", this.name, sql, bindings);
|
|
137
136
|
});
|
|
138
137
|
this.query = this.adapter;
|
|
139
|
-
|
|
138
|
+
data.logger.debug("[%s] connected", this.name);
|
|
140
139
|
global.FaasJS_Knex[this.name] = this;
|
|
141
140
|
await next();
|
|
142
141
|
}
|
|
@@ -147,12 +146,12 @@ var Knex = class {
|
|
|
147
146
|
}
|
|
148
147
|
async transaction(scope, config) {
|
|
149
148
|
if (!this.adapter)
|
|
150
|
-
throw Error(
|
|
149
|
+
throw Error(`[${this.name}] Client not initialized.`);
|
|
151
150
|
return this.adapter.transaction(scope, config);
|
|
152
151
|
}
|
|
153
152
|
schema() {
|
|
154
153
|
if (!this.adapter)
|
|
155
|
-
throw Error(
|
|
154
|
+
throw Error(`[${this.name}] Client not initialized.`);
|
|
156
155
|
return this.adapter.schema;
|
|
157
156
|
}
|
|
158
157
|
async quit() {
|
package/dist/index.mjs
CHANGED
|
@@ -28,7 +28,6 @@ var Knex = class {
|
|
|
28
28
|
this.name = this.type;
|
|
29
29
|
this.config = /* @__PURE__ */ Object.create(null);
|
|
30
30
|
}
|
|
31
|
-
this.logger = new Logger(this.name);
|
|
32
31
|
}
|
|
33
32
|
async onDeploy(data, next) {
|
|
34
33
|
const client = data.config.plugins[this.name].config.client;
|
|
@@ -39,7 +38,7 @@ var Knex = class {
|
|
|
39
38
|
data.dependencies["better-sqlite3"] = "*";
|
|
40
39
|
else
|
|
41
40
|
data.dependencies[client] = "*";
|
|
42
|
-
this.
|
|
41
|
+
new Logger(this.name).debug("add dependencies: " + client);
|
|
43
42
|
await next();
|
|
44
43
|
}
|
|
45
44
|
async onMount(data, next) {
|
|
@@ -96,23 +95,23 @@ var Knex = class {
|
|
|
96
95
|
__knexQueryUid,
|
|
97
96
|
bindings
|
|
98
97
|
}) => {
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
data.logger.time(`Knex${__knexQueryUid}`);
|
|
99
|
+
data.logger.debug("[%s] query begin: %s %j", this.name, sql, bindings);
|
|
101
100
|
}).on("query-response", (response, {
|
|
102
101
|
sql,
|
|
103
102
|
__knexQueryUid,
|
|
104
103
|
bindings
|
|
105
104
|
}) => {
|
|
106
|
-
|
|
105
|
+
data.logger.timeEnd(`Knex${__knexQueryUid}`, "[%s] query done: %s %j %j", this.name, sql, bindings, response);
|
|
107
106
|
}).on("query-error", (_, {
|
|
108
107
|
__knexQueryUid,
|
|
109
108
|
sql,
|
|
110
109
|
bindings
|
|
111
110
|
}) => {
|
|
112
|
-
|
|
111
|
+
data.logger.timeEnd(`Knex${__knexQueryUid}`, "[%s] query failed: %s %j", this.name, sql, bindings);
|
|
113
112
|
});
|
|
114
113
|
this.query = this.adapter;
|
|
115
|
-
|
|
114
|
+
data.logger.debug("[%s] connected", this.name);
|
|
116
115
|
global.FaasJS_Knex[this.name] = this;
|
|
117
116
|
await next();
|
|
118
117
|
}
|
|
@@ -123,12 +122,12 @@ var Knex = class {
|
|
|
123
122
|
}
|
|
124
123
|
async transaction(scope, config) {
|
|
125
124
|
if (!this.adapter)
|
|
126
|
-
throw Error(
|
|
125
|
+
throw Error(`[${this.name}] Client not initialized.`);
|
|
127
126
|
return this.adapter.transaction(scope, config);
|
|
128
127
|
}
|
|
129
128
|
schema() {
|
|
130
129
|
if (!this.adapter)
|
|
131
|
-
throw Error(
|
|
130
|
+
throw Error(`[${this.name}] Client not initialized.`);
|
|
132
131
|
return this.adapter.schema;
|
|
133
132
|
}
|
|
134
133
|
async quit() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faasjs/knex",
|
|
3
|
-
"version": "0.0.2-beta.
|
|
3
|
+
"version": "0.0.2-beta.400",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"dist"
|
|
23
23
|
],
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@faasjs/deep_merge": "^0.0.2-beta.
|
|
26
|
-
"@faasjs/func": "^0.0.2-beta.
|
|
27
|
-
"@faasjs/logger": "^0.0.2-beta.
|
|
25
|
+
"@faasjs/deep_merge": "^0.0.2-beta.400",
|
|
26
|
+
"@faasjs/func": "^0.0.2-beta.400",
|
|
27
|
+
"@faasjs/logger": "^0.0.2-beta.400",
|
|
28
28
|
"knex": "*"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"typescript": "*"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"npm": ">=8.0.0"
|
|
41
|
+
"npm": ">=8.0.0",
|
|
42
|
+
"node": ">=16.0.0"
|
|
42
43
|
}
|
|
43
44
|
}
|