baja-lite 1.2.1 → 1.3.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 CHANGED
@@ -1,5 +1,6 @@
1
+ import { DBType, _Hump } from 'baja-lite-field';
1
2
  import { getEnums } from './enum.js';
2
- import { _primaryDB, _dao, logger, DBType, _sqlCache, _GlobalSqlOption, _defOption, SqlCache, SqliteRemote, _Hump, ColumnMode, _enums } from './sql.js';
3
+ import { ColumnMode, SqlCache, SqliteRemote, _GlobalSqlOption, _dao, _defOption, _enums, _primaryDB, _sqlCache, logger } from './sql.js';
3
4
  export const BootRomote = async function (options) {
4
5
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
5
6
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
package/boot.js CHANGED
@@ -1,5 +1,6 @@
1
+ import { _Hump, DBType } from 'baja-lite-field';
1
2
  import { getEnums } from './enum.js';
2
- import { _GlobalSqlOption, _enums, _EventBus, _defOption, logger, _sqlCache, SqlCache, _dao, DBType, _primaryDB, SqliteRemote, _fs, _path, Mysql, Sqlite, _Hump, ColumnMode, Postgresql } from './sql.js';
3
+ import { _dao, _defOption, _enums, _EventBus, _fs, _GlobalSqlOption, _path, _primaryDB, _sqlCache, ColumnMode, logger, Mysql, Postgresql, SqlCache, Sqlite, SqliteRemote } from './sql.js';
3
4
  export const Boot = async function (options) {
4
5
  globalThis[_GlobalSqlOption] = Object.assign({}, _defOption, options);
5
6
  globalThis[_Hump] = globalThis[_GlobalSqlOption].columnMode === ColumnMode.HUMP;
package/code.js CHANGED
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import path from 'path';
3
2
  import fs from 'fs';
4
- import { start } from 'repl';
5
- import { createPool } from 'mysql2/promise';
6
3
  import mustache from 'mustache';
4
+ import { createPool } from 'mysql2/promise';
5
+ import path from 'path';
6
+ import { start } from 'repl';
7
7
  import { mkdir } from 'shelljs';
8
8
  const lxMap = {
9
9
  tinyint: "number",
package/index.d.ts CHANGED
@@ -10,3 +10,4 @@ export * from './snowflake.js';
10
10
  export * from './sql.js';
11
11
  export * from './sqlite.js';
12
12
  export * from './string.js';
13
+ export * from './validate.js';
package/index.js CHANGED
@@ -10,3 +10,4 @@ export * from './snowflake.js';
10
10
  export * from './sql.js';
11
11
  export * from './sqlite.js';
12
12
  export * from './string.js';
13
+ export * from './validate.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "baja-lite",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "description": "some util for self",
5
5
  "homepage": "https://github.com/void-soul/util-man",
6
6
  "repository": {
@@ -23,7 +23,6 @@
23
23
  "bin": {
24
24
  "baja": "./code.js"
25
25
  },
26
- "models": "./index.js",
27
26
  "scripts": {
28
27
  "dist": "node ./ci.js",
29
28
  "mysql": "bun --inspect ./src/test-mysql.ts",
@@ -31,14 +30,15 @@
31
30
  "postgres": "bun --inspect ./src/test-postgresql.ts",
32
31
  "postgres2": "node inspect ./dist/cjs/test-postgresql.js",
33
32
  "sqlite": "node inspect ./dist/cjs/test-sqlite.js",
34
- "xml": "bun --inspect ./src/test-xml.ts",
35
33
  "test": "bun --inspect ./src/test.ts",
36
- "test2": "node inspect ./dist/cjs/tes.js"
34
+ "test2": "node inspect ./dist/cjs/tes.js",
35
+ "xml": "bun --inspect ./src/test-xml.ts"
37
36
  },
38
37
  "dependencies": {
39
- "@msgpack/msgpack": "3.1.0",
38
+ "@msgpack/msgpack": "3.1.1",
40
39
  "@types/request-promise": "4.1.51",
41
- "axios": "1.8.1",
40
+ "axios": "1.8.4",
41
+ "baja-lite-field": "1.3.1",
42
42
  "decimal.js": "10.5.0",
43
43
  "html-parse-stringify": "3.0.1",
44
44
  "iterare": "1.2.1",
@@ -57,18 +57,18 @@
57
57
  "@types/better-sqlite3": "7.6.12",
58
58
  "@types/lodash.get": "4.4.9",
59
59
  "@types/mustache": "4.2.5",
60
- "@types/node": "22.13.0",
60
+ "@types/node": "22.13.10",
61
61
  "@types/pg-pool": "2.0.6",
62
62
  "@types/shelljs": "0.8.15",
63
63
  "@types/sqlstring": "2.3.2",
64
- "@typescript-eslint/eslint-plugin": "8.26.0",
65
- "@typescript-eslint/parser": "8.26.0",
66
- "better-sqlite3": "11.8.1",
64
+ "@typescript-eslint/eslint-plugin": "8.27.0",
65
+ "@typescript-eslint/parser": "8.27.0",
66
+ "better-sqlite3": "11.9.1",
67
67
  "ioredis": "5.6.0",
68
- "mongodb": "6.14.2",
69
- "mysql2": "3.13.0",
70
- "pg": "8.13.3",
71
- "pg-pool": "3.7.1",
68
+ "mongodb": "6.15.0",
69
+ "mysql2": "3.14.0",
70
+ "pg": "8.14.1",
71
+ "pg-pool": "3.8.0",
72
72
  "redlock": "5.0.0-beta.2",
73
73
  "shelljs": "0.8.5",
74
74
  "typescript": "5.7.3"
@@ -78,5 +78,6 @@
78
78
  },
79
79
  "publishConfig": {
80
80
  "access": "public"
81
- }
81
+ },
82
+ "models": "./index.js"
82
83
  }
package/sql.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { ExtensionCodec } from "@msgpack/msgpack";
2
+ import { _columns, _columnsNoId, _def, _deleteState, _fields, _ids, _index, _logicIds, _stateFileName, AField, DBType, FieldOption } from 'baja-lite-field';
2
3
  import { XML } from './convert-xml.js';
3
4
  import { EnumMap } from './enum.js';
4
5
  import { ArrayList } from './list.js';
@@ -8,16 +9,7 @@ declare const _tableName: unique symbol;
8
9
  declare const _className: unique symbol;
9
10
  declare const _ClassName: unique symbol;
10
11
  declare const _vueName: unique symbol;
11
- declare const _ids: unique symbol;
12
- declare const _logicIds: unique symbol;
13
- declare const _columns: unique symbol;
14
- declare const _columnsNoId: unique symbol;
15
- declare const _fields: unique symbol;
16
- declare const _stateFileName: unique symbol;
17
- declare const _deleteState: unique symbol;
18
12
  declare const _transformer: unique symbol;
19
- declare const _index: unique symbol;
20
- declare const _def: unique symbol;
21
13
  declare const _comment: unique symbol;
22
14
  export declare const _sqlCache: unique symbol;
23
15
  export declare const _dao: unique symbol;
@@ -30,21 +22,11 @@ declare const _daoDB: unique symbol;
30
22
  declare const _sqliteRemoteName: unique symbol;
31
23
  declare const _SqlOption: unique symbol;
32
24
  export declare const _enums: unique symbol;
33
- export declare const _Hump: unique symbol;
34
25
  export declare const _GlobalSqlOption: unique symbol;
35
26
  export declare const _EventBus: unique symbol;
36
27
  export declare const _path: unique symbol;
37
28
  export declare const _fs: unique symbol;
38
29
  export declare const logger: import("pino").Logger<never, boolean>;
39
- export declare enum DBType {
40
- Mysql = 0,
41
- Postgresql = 1,
42
- Sqlite = 2,
43
- Mongo = 3,
44
- SqliteRemote = 4,
45
- Redis = 5,
46
- RedisLock = 6
47
- }
48
30
  export declare enum MapperIfUndefined {
49
31
  Null = 0,
50
32
  Skip = 1,
@@ -135,32 +117,6 @@ export declare enum SelectResult {
135
117
  /** 多行多列并封装ArrayList */
136
118
  RS_CS_List = 7
137
119
  }
138
- export declare enum SqlType {
139
- tinyint = 0,
140
- smallint = 1,
141
- mediumint = 2,
142
- int = 3,
143
- bigint = 4,
144
- float = 5,
145
- double = 6,
146
- decimal = 7,
147
- date = 8,
148
- time = 9,
149
- year = 10,
150
- datetime = 11,
151
- timestamp = 12,
152
- char = 13,
153
- varchar = 14,
154
- tinyblob = 15,
155
- tinytext = 16,
156
- blob = 17,
157
- text = 18,
158
- mediumblob = 19,
159
- mediumtext = 20,
160
- longblob = 21,
161
- longtext = 22,
162
- json = 23
163
- }
164
120
  export declare enum ColumnMode {
165
121
  NONE = 0,
166
122
  HUMP = 1
@@ -490,44 +446,6 @@ export interface GlobalSqlOption extends GlobalSqlOptionForWeb {
490
446
  */
491
447
  jsMode?: boolean;
492
448
  }
493
- interface FieldOption extends Object {
494
- type?: SqlType;
495
- /** @deprecated 属性名称:TS注解不需要,JS手动注入需要 */
496
- P?: string;
497
- length?: number;
498
- scale?: number;
499
- def?: any;
500
- index?: boolean;
501
- id?: boolean;
502
- logicDelete?: string | number;
503
- /** 是否逻辑唯一,用于导入时检测数据是否存在 */
504
- logicId?: boolean;
505
- /** 仅在生成 表时有效 */
506
- notNull?: boolean;
507
- /** 注释,影响到默认导出导入标题 */
508
- comment?: string;
509
- /** 可以导入的字段,默认TRUE,ID默认FALSE */
510
- importable?: boolean;
511
- /** 可以导出的字段,默认TRUE,ID默认FALSE */
512
- exportable?: boolean;
513
- /** sqlite 无效,与UUID只能有一个 */
514
- uuidShort?: boolean;
515
- /** 与uuidShort只能有一个 */
516
- uuid?: boolean;
517
- }
518
- interface AField extends FieldOption {
519
- /** 安全列名 */
520
- C2: () => string;
521
- /** @deprecated 数据列名称 */
522
- C?: () => string;
523
- /** 查询用:b_id bId */
524
- C3: () => string;
525
- [DBType.Postgresql]: () => string;
526
- [DBType.Mysql]: () => string;
527
- [DBType.Sqlite]: () => string;
528
- [DBType.SqliteRemote]: () => string;
529
- Data2SQL: (data: any) => any;
530
- }
531
449
  export interface PageQuery<L> {
532
450
  sum?: Record<string, number>;
533
451
  total?: number;
@@ -743,7 +661,6 @@ export declare class SqlCache {
743
661
  [k: string]: any;
744
662
  }): string;
745
663
  }
746
- export declare const Field: (config: FieldOption) => (object: object, propertyName: string) => void;
747
664
  export declare const DB: (config: ServiceOption) => <C extends {
748
665
  new (...args: any[]): {};
749
666
  }>(constructor: C) => {
@@ -1418,6 +1335,8 @@ export declare class SqlService<T extends object> {
1418
1335
  */
1419
1336
  private _createTable;
1420
1337
  private _matchSqlid;
1338
+ private _setParam;
1339
+ private _generSql;
1421
1340
  }
1422
1341
  declare class StreamQuery<T extends object> {
1423
1342
  private _prefix;
@@ -1445,6 +1364,11 @@ declare class StreamQuery<T extends object> {
1445
1364
  reset(): this;
1446
1365
  /** 为下次链条执行提供条件判断:非异步方法跳过,异步方法不执行并返回默认值 */
1447
1366
  if(condition: boolean): this;
1367
+ eqs(keys: (keyof T)[], value: string | number, { paramName, skipEmptyString, breakExcuteIfSkip }?: {
1368
+ paramName?: string | undefined;
1369
+ skipEmptyString?: boolean | undefined;
1370
+ breakExcuteIfSkip?: boolean | undefined;
1371
+ }): this;
1448
1372
  eq(key: keyof T, value: string | number, { paramName, skipEmptyString, breakExcuteIfSkip }?: {
1449
1373
  paramName?: string | undefined;
1450
1374
  skipEmptyString?: boolean | undefined;
@@ -1776,6 +1700,7 @@ declare class StreamQuery<T extends object> {
1776
1700
  }): number;
1777
1701
  private _where;
1778
1702
  private _;
1703
+ private __;
1779
1704
  private _null;
1780
1705
  private _key;
1781
1706
  private _between;