baja-lite 1.8.4 → 1.8.6

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.
Files changed (3) hide show
  1. package/package.json +2 -2
  2. package/sql.d.ts +3 -1
  3. package/sql.js +12 -13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baja-lite",
3
- "version": "1.8.4",
3
+ "version": "1.8.6",
4
4
  "description": "some util for self",
5
5
  "homepage": "https://github.com/void-soul/baja-lite",
6
6
  "repository": {
@@ -43,7 +43,7 @@
43
43
  "pino": "10.3.1",
44
44
  "pino-pretty": "13.1.3",
45
45
  "reflect-metadata": "0.2.2",
46
- "sql-formatter": "15.7.3",
46
+ "sql-formatter": "15.8.1",
47
47
  "sqlstring": "2.3.3",
48
48
  "tslib": "2.8.1"
49
49
  },
package/sql.d.ts CHANGED
@@ -2158,13 +2158,14 @@ export declare function MethodCache<T = any>(config: {
2158
2158
  /** 随着当前用户sesion的清空而一起清空 */
2159
2159
  clearWithSession?: boolean;
2160
2160
  }): (target: T, _propertyKey: string, descriptor: PropertyDescriptor) => void;
2161
- export declare const LOG_LEVELS: ["verbose", "debug", "info", "warn", "error", "fatal"];
2161
+ export declare const LOG_LEVELS: ["verbose", "debug", "info", "log", "warn", "error", "fatal"];
2162
2162
  export type LogLevel = (typeof LOG_LEVELS)[number];
2163
2163
  export interface LoggerService {
2164
2164
  /**
2165
2165
  * Write a 'log' level log.
2166
2166
  */
2167
2167
  log(message: any, ...optionalParams: any[]): any;
2168
+ info(message: any, ...optionalParams: any[]): any;
2168
2169
  /**
2169
2170
  * Write an 'error' level log.
2170
2171
  */
@@ -2195,6 +2196,7 @@ export declare class PrinterLogger implements LoggerService {
2195
2196
  private logger;
2196
2197
  constructor();
2197
2198
  log(message: any, ...optionalParams: any[]): void;
2199
+ info(message: any, ...optionalParams: any[]): void;
2198
2200
  fatal(message: any, ...optionalParams: any[]): void;
2199
2201
  error(message: any, ...optionalParams: any[]): void;
2200
2202
  warn(message: any, ...optionalParams: any[]): void;
package/sql.js CHANGED
@@ -18,7 +18,7 @@ import pino from 'pino';
18
18
  import { formatDialect, mysql, postgresql, sqlite } from 'sql-formatter';
19
19
  import tslib from 'tslib';
20
20
  import { convert } from './convert-xml.js';
21
- import { DatabaseError, Throw } from './error.js';
21
+ import { Throw } from './error.js';
22
22
  import { excuteSplit, ExcuteSplitMode, sleep } from './fn.js';
23
23
  import { add, calc, ten2Any } from './math.js';
24
24
  import { C2P, C2P2, P2C } from './object.js';
@@ -248,9 +248,8 @@ class MysqlConnection {
248
248
  resolve({ affectedRows: result.affectedRows, insertId: result.insertId });
249
249
  }
250
250
  catch (error) {
251
- const dbError = DatabaseError.query('MySQL execute failed', sql, params, error);
252
- globalThis[_LoggerService].error(dbError.getSafeMessage(), { cause: error });
253
- reject(dbError);
251
+ globalThis[_LoggerService].error(error.message, { cause: error });
252
+ reject(error);
254
253
  }
255
254
  });
256
255
  }
@@ -443,9 +442,8 @@ export class Mysql {
443
442
  resolve(new MysqlConnection(connection));
444
443
  }
445
444
  catch (error) {
446
- const dbError = DatabaseError.connection('Failed to create MySQL connection', error);
447
- globalThis[_LoggerService].error(dbError.getSafeMessage(), { cause: error });
448
- reject(dbError);
445
+ globalThis[_LoggerService].error(error.message, { cause: error });
446
+ reject(error);
449
447
  }
450
448
  });
451
449
  }
@@ -484,9 +482,8 @@ export class Mysql {
484
482
  await conn[_daoConnection].rollback();
485
483
  globalThis[_LoggerService].debug?.('rollback end!');
486
484
  }
487
- const dbError = error instanceof DatabaseError ? error : DatabaseError.transaction('MySQL transaction failed', error);
488
- globalThis[_LoggerService].error(dbError.getSafeMessage(), { cause: error });
489
- reject(dbError);
485
+ globalThis[_LoggerService].error(error.message, { cause: error });
486
+ reject(error);
490
487
  }
491
488
  finally {
492
489
  try {
@@ -802,9 +799,8 @@ export class Postgresql {
802
799
  await conn[_daoConnection].query('ROLLBACK');
803
800
  globalThis[_LoggerService].debug?.('rollback end!');
804
801
  }
805
- const dbError = error instanceof DatabaseError ? error : DatabaseError.transaction('PostgreSQL transaction failed', error);
806
- globalThis[_LoggerService].error(dbError.getSafeMessage(), { cause: error });
807
- reject(dbError);
802
+ globalThis[_LoggerService].error(error.message, { cause: error });
803
+ reject(error);
808
804
  }
809
805
  finally {
810
806
  try {
@@ -5451,6 +5447,9 @@ export class PrinterLogger {
5451
5447
  log(message, ...optionalParams) {
5452
5448
  this.logger.info(message, ...optionalParams);
5453
5449
  }
5450
+ info(message, ...optionalParams) {
5451
+ this.logger.info(message, ...optionalParams);
5452
+ }
5454
5453
  fatal(message, ...optionalParams) {
5455
5454
  this.logger.fatal(message, ...optionalParams);
5456
5455
  }