kuwan-expresspack-core 0.1.9 → 0.1.11
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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RootOperationNode, LogEvent } from 'kysely';
|
|
2
|
+
|
|
3
|
+
type KyselyLoggerParams = {
|
|
4
|
+
sql: string;
|
|
5
|
+
params: readonly unknown[];
|
|
6
|
+
duration: number;
|
|
7
|
+
queryNode?: RootOperationNode;
|
|
8
|
+
error?: unknown;
|
|
9
|
+
};
|
|
10
|
+
type KyselyLoggerOptions = {
|
|
11
|
+
logger: (data: KyselyLoggerParams) => void;
|
|
12
|
+
merge: boolean;
|
|
13
|
+
logQueryNode: boolean;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Obtained from:
|
|
17
|
+
* https://github.com/subframe7536/kysely-sqlite-tools/blob/master/packages/sqlite-utils/src/logger.ts
|
|
18
|
+
*
|
|
19
|
+
* The goal was to log the SQL and parameters of the query executed by Kysely instead
|
|
20
|
+
* of having the SQL logs with the question marks.
|
|
21
|
+
*/
|
|
22
|
+
declare function createKyselyLogger(options: KyselyLoggerOptions): (event: LogEvent) => void;
|
|
23
|
+
|
|
24
|
+
export { type KyselyLoggerOptions, type KyselyLoggerParams, createKyselyLogger };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function L(g){let{logger:l,merge:y,logQueryNode:i}=g;return t=>{let{level:p,queryDurationMillis:u,query:{parameters:n,sql:c,query:d}}=t,a="__Q__",f=p==="error"?t.error:void 0,r=c.replace(/\r?\n/g," ").replace(/\s+/g," ");y&&n.forEach(o=>{let e=o;o instanceof Date&&(e=o.toLocaleString()),typeof e=="string"&&(e=`'${e}'`.replace(/\?/g,a)),r=r.replace(/\?/,e);});let s={sql:r.replace(new RegExp(a,"g"),"?"),params:n,duration:u,error:f};i&&(s.queryNode=d),l(s);}}
|
|
2
|
+
|
|
3
|
+
export { L as createKyselyLogger };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kuwan-expresspack-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.mjs",
|
|
@@ -68,6 +68,14 @@
|
|
|
68
68
|
"./utils/dynamic-import": {
|
|
69
69
|
"types": "./dist/utils/dynamic-import.d.ts",
|
|
70
70
|
"import": "./dist/utils/dynamic-import.mjs"
|
|
71
|
+
},
|
|
72
|
+
"./thrid-party/kysely-logger": {
|
|
73
|
+
"types": "./dist/third-party/kysely-logger.d.ts",
|
|
74
|
+
"import": "./dist/third-party/kysely-logger.mjs"
|
|
75
|
+
},
|
|
76
|
+
"./third-party/axios-agent": {
|
|
77
|
+
"types": "./dist/third-party/axios-agent.d.ts",
|
|
78
|
+
"import": "./dist/third-party/axios-agent.mjs"
|
|
71
79
|
}
|
|
72
80
|
},
|
|
73
81
|
"dependencies": {
|
|
@@ -103,7 +111,9 @@
|
|
|
103
111
|
"@types/express": "^5.0.3",
|
|
104
112
|
"eslint": "^9.37.0",
|
|
105
113
|
"express": "^5.1.0",
|
|
106
|
-
"typescript": "^5.9.3"
|
|
114
|
+
"typescript": "^5.9.3",
|
|
115
|
+
"kysely": "^0.28.8",
|
|
116
|
+
"axios": "^1.12.2"
|
|
107
117
|
},
|
|
108
118
|
"sideEffects": false,
|
|
109
119
|
"scripts": {
|