baja-lite 1.6.7 → 1.7.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/boot-remote.js +8 -2
- package/boot.js +9 -3
- package/code.js +0 -0
- package/package.json +3 -3
- package/sql.d.ts +48 -3
- package/sql.js +179 -147
- package/sqlite.js +18 -20
- package/test-mysql.js +1 -1
package/boot-remote.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DBType, _Hump, getEnums } from 'baja-lite-field';
|
|
2
|
-
import { ColumnMode, SqlCache, SqliteRemote, _Context, _DataConvert, _GlobalSqlOption, _dao, _defOption, _enum, _primaryDB, _sqlCache
|
|
2
|
+
import { ColumnMode, PrinterLogger, SqlCache, SqliteRemote, _Context, _DataConvert, _GlobalSqlOption, _LoggerService, _dao, _defOption, _enum, _primaryDB, _sqlCache } from './sql.js';
|
|
3
3
|
export const BootRomote = async function (options) {
|
|
4
4
|
globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
|
|
5
5
|
if (options.skipEmptyString !== undefined) {
|
|
@@ -17,8 +17,14 @@ export const BootRomote = async function (options) {
|
|
|
17
17
|
if (options.SqliteRemote !== undefined) {
|
|
18
18
|
globalThis[_GlobalSqlOption].SqliteRemote = options.SqliteRemote;
|
|
19
19
|
}
|
|
20
|
+
if (options.logger) {
|
|
21
|
+
globalThis[_LoggerService] = options.logger;
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
globalThis[_LoggerService] = new PrinterLogger();
|
|
25
|
+
}
|
|
26
|
+
globalThis[_LoggerService].setLogLevels(options.log ? (options.log instanceof Array ? options.log : [options.log]) : ['info']);
|
|
20
27
|
globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
|
|
21
|
-
logger.level = options.log ?? 'info';
|
|
22
28
|
globalThis[_sqlCache] = new SqlCache();
|
|
23
29
|
if (options.sqlMap) {
|
|
24
30
|
await globalThis[_sqlCache].init(options);
|
package/boot.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _Hump, DBType, getEnums } from 'baja-lite-field';
|
|
2
2
|
import events from 'events';
|
|
3
|
-
import { _Context, _dao, _DataConvert, _defOption, _enum, _EventBus, _fs, _GlobalSqlOption, _path, _primaryDB, _sqlCache, ColumnMode,
|
|
3
|
+
import { _Context, _dao, _DataConvert, _defOption, _enum, _EventBus, _fs, _GlobalSqlOption, _LoggerService, _path, _primaryDB, _sqlCache, ColumnMode, Mysql, Postgresql, PrinterLogger, SqlCache, Sqlite, SqliteRemote } from './sql.js';
|
|
4
4
|
export const Boot = async function (options) {
|
|
5
5
|
globalThis[_GlobalSqlOption] = Object.assign({}, _defOption);
|
|
6
6
|
if (options.skipEmptyString !== undefined) {
|
|
@@ -15,8 +15,14 @@ export const Boot = async function (options) {
|
|
|
15
15
|
if (options.maxDeal !== undefined) {
|
|
16
16
|
globalThis[_GlobalSqlOption].maxDeal = options.maxDeal;
|
|
17
17
|
}
|
|
18
|
+
if (options.logger) {
|
|
19
|
+
globalThis[_LoggerService] = options.logger;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
globalThis[_LoggerService] = new PrinterLogger();
|
|
23
|
+
}
|
|
24
|
+
globalThis[_LoggerService].setLogLevels(options.log ? (options.log instanceof Array ? options.log : [options.log]) : ['info']);
|
|
18
25
|
globalThis[_Hump] = options.columnMode === ColumnMode.HUMP;
|
|
19
|
-
logger.level = options.log ?? 'info';
|
|
20
26
|
globalThis[_sqlCache] = new SqlCache();
|
|
21
27
|
if (options.sqlDir) {
|
|
22
28
|
globalThis[_path] = await import('path');
|
|
@@ -142,7 +148,7 @@ export const Boot = async function (options) {
|
|
|
142
148
|
const { EventEmitter } = await import('events');
|
|
143
149
|
const event = new EventEmitter({ captureRejections: true });
|
|
144
150
|
event.on('error', error => {
|
|
145
|
-
|
|
151
|
+
globalThis[_LoggerService].error('event-bus', error);
|
|
146
152
|
});
|
|
147
153
|
globalThis[_EventBus] = event;
|
|
148
154
|
}
|
package/code.js
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "baja-lite",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "some util for self",
|
|
5
5
|
"homepage": "https://github.com/void-soul/baja-lite",
|
|
6
6
|
"repository": {
|
|
@@ -44,11 +44,11 @@
|
|
|
44
44
|
"iterare": "1.2.1",
|
|
45
45
|
"mustache": "4.2.0",
|
|
46
46
|
"pino": "10.1.0",
|
|
47
|
-
"pino-pretty": "13.1.
|
|
47
|
+
"pino-pretty": "13.1.3",
|
|
48
48
|
"reflect-metadata": "0.2.2",
|
|
49
49
|
"request": "2.88.2",
|
|
50
50
|
"request-promise": "4.2.6",
|
|
51
|
-
"sql-formatter": "15.6.
|
|
51
|
+
"sql-formatter": "15.6.12",
|
|
52
52
|
"sqlstring": "2.3.3",
|
|
53
53
|
"tslib": "2.8.1"
|
|
54
54
|
},
|
package/sql.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ExtensionCodec } from "@msgpack/msgpack";
|
|
2
2
|
import { _columns, _columnsNoId, _def, _deleteState, _fields, _ids, _index, _logicIds, _stateFileName, AField, DBType, EnumMap, FieldOption } from 'baja-lite-field';
|
|
3
|
-
import pino from 'pino';
|
|
4
3
|
import { XML } from './convert-xml.js';
|
|
5
4
|
export declare const extensionCodec: ExtensionCodec<undefined>;
|
|
6
5
|
declare const _daoDBName: unique symbol;
|
|
@@ -25,9 +24,9 @@ export declare const _Context: unique symbol;
|
|
|
25
24
|
export declare const _enum: unique symbol;
|
|
26
25
|
export declare const _GlobalSqlOption: unique symbol;
|
|
27
26
|
export declare const _EventBus: unique symbol;
|
|
27
|
+
export declare const _LoggerService: unique symbol;
|
|
28
28
|
export declare const _path: unique symbol;
|
|
29
29
|
export declare const _fs: unique symbol;
|
|
30
|
-
export declare const logger: pino.Logger<never, boolean>;
|
|
31
30
|
export declare enum MapperIfUndefined {
|
|
32
31
|
Null = 0,
|
|
33
32
|
Skip = 1,
|
|
@@ -209,7 +208,7 @@ export interface GlobalSqlOptionForWeb {
|
|
|
209
208
|
service: SqliteRemoteInterface;
|
|
210
209
|
};
|
|
211
210
|
/** 日志等级 */
|
|
212
|
-
log?:
|
|
211
|
+
log?: LogLevel[] | LogLevel;
|
|
213
212
|
/**
|
|
214
213
|
作用与sqlDir类似,不同在于sqlMap`不需要`目录,而是直接指定一个sqlModel对象,对象的格式和sqlDir的文件内容一样。
|
|
215
214
|
** 适用于简单使用
|
|
@@ -260,6 +259,8 @@ export interface GlobalSqlOptionForWeb {
|
|
|
260
259
|
dataConvert?: Record<string, (data: any) => any>;
|
|
261
260
|
/** 公开上下文 */
|
|
262
261
|
ctx?: any;
|
|
262
|
+
/** 日志服务 */
|
|
263
|
+
logger?: LoggerService;
|
|
263
264
|
}
|
|
264
265
|
/**
|
|
265
266
|
# 全局行为配置文件
|
|
@@ -2148,4 +2149,48 @@ export declare function MethodCache<T = any>(config: {
|
|
|
2148
2149
|
/** 随着当前用户sesion的清空而一起清空 */
|
|
2149
2150
|
clearWithSession?: boolean;
|
|
2150
2151
|
}): (target: T, _propertyKey: string, descriptor: PropertyDescriptor) => void;
|
|
2152
|
+
export declare const LOG_LEVELS: ["verbose", "debug", "info", "warn", "error", "fatal"];
|
|
2153
|
+
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
2154
|
+
export interface LoggerService {
|
|
2155
|
+
/**
|
|
2156
|
+
* Write a 'log' level log.
|
|
2157
|
+
*/
|
|
2158
|
+
log(message: any, ...optionalParams: any[]): any;
|
|
2159
|
+
/**
|
|
2160
|
+
* Write an 'error' level log.
|
|
2161
|
+
*/
|
|
2162
|
+
error(message: any, ...optionalParams: any[]): any;
|
|
2163
|
+
/**
|
|
2164
|
+
* Write a 'warn' level log.
|
|
2165
|
+
*/
|
|
2166
|
+
warn(message: any, ...optionalParams: any[]): any;
|
|
2167
|
+
/**
|
|
2168
|
+
* Write a 'debug' level log.
|
|
2169
|
+
*/
|
|
2170
|
+
debug?(message: any, ...optionalParams: any[]): any;
|
|
2171
|
+
/**
|
|
2172
|
+
* Write a 'verbose' level log.
|
|
2173
|
+
*/
|
|
2174
|
+
verbose?(message: any, ...optionalParams: any[]): any;
|
|
2175
|
+
/**
|
|
2176
|
+
* Write a 'fatal' level log.
|
|
2177
|
+
*/
|
|
2178
|
+
fatal?(message: any, ...optionalParams: any[]): any;
|
|
2179
|
+
/**
|
|
2180
|
+
* Set log levels.
|
|
2181
|
+
* @param levels log levels
|
|
2182
|
+
*/
|
|
2183
|
+
setLogLevels(levels: LogLevel[]): any;
|
|
2184
|
+
}
|
|
2185
|
+
export declare class PrinterLogger implements LoggerService {
|
|
2186
|
+
private logger;
|
|
2187
|
+
constructor();
|
|
2188
|
+
log(message: any, ...optionalParams: any[]): void;
|
|
2189
|
+
fatal(message: any, ...optionalParams: any[]): void;
|
|
2190
|
+
error(message: any, ...optionalParams: any[]): void;
|
|
2191
|
+
warn(message: any, ...optionalParams: any[]): void;
|
|
2192
|
+
debug?(message: any, ...optionalParams: any[]): void;
|
|
2193
|
+
verbose?(message: any, ...optionalParams: any[]): void;
|
|
2194
|
+
setLogLevels(levels: LogLevel[]): void;
|
|
2195
|
+
}
|
|
2151
2196
|
export {};
|