baja-lite 1.0.7 → 1.0.10

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/cjs/sql.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  import { XML } from './convert-xml';
2
2
  import { ArrayList } from './list';
3
+ import { EnumMap } from 'enum';
3
4
  declare const _daoDBName: unique symbol;
4
5
  declare const _tableName: unique symbol;
5
6
  declare const _className: unique symbol;
6
7
  declare const _ClassName: unique symbol;
7
8
  declare const _vueName: unique symbol;
8
9
  declare const _ids: unique symbol;
10
+ declare const _logicIds: unique symbol;
9
11
  declare const _columns: unique symbol;
10
12
  declare const _columnsNoId: unique symbol;
11
13
  declare const _fields: unique symbol;
@@ -14,16 +16,19 @@ declare const _deleteState: unique symbol;
14
16
  declare const _transformer: unique symbol;
15
17
  declare const _index: unique symbol;
16
18
  declare const _def: unique symbol;
19
+ declare const _comment: unique symbol;
17
20
  export declare const _sqlCache: unique symbol;
18
21
  export declare const _dao: unique symbol;
19
22
  export declare const _primaryDB: unique symbol;
20
23
  declare const _dbType: unique symbol;
24
+ declare const _formatDialect: unique symbol;
21
25
  declare const _sqlite_version: unique symbol;
22
26
  declare const _daoConnection: unique symbol;
23
27
  declare const _inTransaction: unique symbol;
24
28
  declare const _daoDB: unique symbol;
25
29
  declare const _sqliteRemoteName: unique symbol;
26
30
  declare const _SqlOption: unique symbol;
31
+ export declare const _enums: unique symbol;
27
32
  export declare const _Hump: unique symbol;
28
33
  export declare const _GlobalSqlOption: unique symbol;
29
34
  export declare const _EventBus: unique symbol;
@@ -213,6 +218,8 @@ interface ServiceOption {
213
218
  dbType?: DBType;
214
219
  /** SQLite版本以及升级为该版本时需要执行的SQL,初始版本为0.0.1,切记每个位置不要变为两位数*/
215
220
  sqliteVersion?: string;
221
+ /** 备注 */
222
+ comment?: string;
216
223
  }
217
224
  /**
218
225
  # 全局行为配置文件
@@ -274,6 +281,23 @@ export interface GlobalSqlOptionForWeb {
274
281
  ]
275
282
  */
276
283
  sqlMapperMap?: SqlMappers;
284
+ /** 提供的枚举MAP */
285
+ enums?: EnumMap;
286
+ /**
287
+ * `列名与属性映射` 是否自动将下划线转为驼峰,默认NONE,即不转.
288
+ * 当设置为columnMode.HUMP时,切记将代码生成器中属性名称改对
289
+ * # 自定义sql查询时,无法自动转换哦,可使用标签转换:
290
+ *```
291
+ SELECT
292
+ * {{#hump}} seller_sku2, seller_sku {{/hump}}
293
+ * ```
294
+ * 转换为
295
+ *```
296
+ SELECT
297
+ * {{#hump}} seller_sku2 sellerSku2, seller_sku sellerSku {{/hump}}
298
+ * ```
299
+ */
300
+ columnMode?: ColumnMode;
277
301
  }
278
302
  /**
279
303
  # 全局行为配置文件
@@ -335,12 +359,13 @@ export interface GlobalSqlOption extends GlobalSqlOptionForWeb {
335
359
  export default {
336
360
  'sql_1': 'SELECT * FROM user WHERE username = :username',
337
361
  'sql_2': (options: {
338
- ctx: any;
362
+ ctx?: any;
339
363
  isCount?: boolean;
364
+ isSum?: boolean;
340
365
  limitStart?: number;
341
366
  limitEnd?: number;
342
367
  orderBy?: string;
343
- [k: string]: any;
368
+ params?: Record<string, any>;
344
369
  }) => {
345
370
  return `
346
371
  SELECT * FROM user u LEFT JOIN organ o ON u.orgid = o.orgid
@@ -405,21 +430,6 @@ export interface GlobalSqlOption extends GlobalSqlOptionForWeb {
405
430
  ```
406
431
  */
407
432
  Redis?: Record<string, Record<string, any>> | Record<string, any>;
408
- /**
409
- * `列名与属性映射` 是否自动将下划线转为驼峰,默认NONE,即不转.
410
- * 当设置为columnMode.HUMP时,切记将代码生成器中属性名称改对
411
- * # 自定义sql查询时,无法自动转换哦,可使用标签转换:
412
- *```
413
- SELECT
414
- * {{#hump}} seller_sku2, seller_sku {{/hump}}
415
- * ```
416
- * 转换为
417
- *```
418
- SELECT
419
- * {{#hump}} seller_sku2 sellerSku2, seller_sku sellerSku {{/hump}}
420
- * ```
421
- */
422
- columnMode?: ColumnMode;
423
433
  /**
424
434
  * 读取查询语句时,是否扫描JS文件?
425
435
  * JS文件需要默认导出一个 SqlModel对象
@@ -436,9 +446,16 @@ interface FieldOption extends Object {
436
446
  index?: boolean;
437
447
  id?: boolean;
438
448
  logicDelete?: string | number;
449
+ /** 是否逻辑唯一,用于导入时检测数据是否存在 */
450
+ logicId?: boolean;
439
451
  /** 仅在生成 表时有效 */
440
452
  notNull?: boolean;
453
+ /** 注释,影响到默认导出导入标题 */
441
454
  comment?: string;
455
+ /** 可以导入的字段,默认TRUE,ID默认FALSE */
456
+ importable?: boolean;
457
+ /** 可以导出的字段,默认TRUE,ID默认FALSE */
458
+ exportable?: boolean;
442
459
  /** sqlite 无效,与UUID只能有一个 */
443
460
  uuidShort?: boolean;
444
461
  /** 与uuidShort只能有一个 */
@@ -454,6 +471,7 @@ interface AField extends FieldOption {
454
471
  [DBType.Mysql]: () => string;
455
472
  [DBType.Sqlite]: () => string;
456
473
  [DBType.SqliteRemote]: () => string;
474
+ Data2SQL: (data: any) => any;
457
475
  }
458
476
  export interface PageQuery<L> {
459
477
  sum?: Record<string, number>;
@@ -463,14 +481,11 @@ export interface PageQuery<L> {
463
481
  }
464
482
  /** sqlite electron服务端需要支持的接口 */
465
483
  export interface SqliteRemoteInterface {
466
- execute(dbName: string, sql?: string, params?: any): Promise<{
467
- affectedRows: number;
468
- insertId: bigint;
469
- }>;
470
- pluck<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column | null>;
471
- get<One_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<One_Row_Many_Column | null>;
472
- raw<Many_Row_One_Column = any>(dbName: string, sql?: string, params?: any): Promise<Many_Row_One_Column[]>;
473
- query<Many_Row_Many_Column = any>(dbName: string, sql?: string, params?: any): Promise<Many_Row_Many_Column[]>;
484
+ execute(inData: Uint8Array): Promise<Uint8Array>;
485
+ pluck(inData: Uint8Array): Promise<Uint8Array>;
486
+ get(inData: Uint8Array): Promise<Uint8Array>;
487
+ raw(inData: Uint8Array): Promise<Uint8Array>;
488
+ query(inData: Uint8Array): Promise<Uint8Array>;
474
489
  initDB(dbName: string): Promise<void>;
475
490
  export(dbName: string): Promise<void>;
476
491
  restore(dbName: string, fromName: string): Promise<void>;
@@ -575,6 +590,7 @@ export declare class SqliteRemoteConnection implements Connection {
575
590
  export declare class SqliteRemote implements Dao {
576
591
  [_sqliteRemoteName]: string;
577
592
  [_daoDB]: SqliteRemoteInterface;
593
+ private connection?;
578
594
  constructor(db: SqliteRemoteInterface, name: string);
579
595
  createConnection(sync: SyncMode.Sync): Connection | null;
580
596
  createConnection(sync: SyncMode.Async): Promise<Connection | null>;
@@ -592,22 +608,22 @@ export declare class SqliteRemote implements Dao {
592
608
  export type SqlMapper = ([string, string[], any?])[];
593
609
  export type SqlMappers = Record<string, SqlMapper>;
594
610
  export type SqlModel = Record<string, string | ((options: {
595
- ctx: any;
611
+ ctx?: any;
596
612
  isCount?: boolean;
597
613
  isSum?: boolean;
598
614
  limitStart?: number;
599
615
  limitEnd?: number;
600
616
  orderBy?: string;
601
- [k: string]: any;
617
+ params?: any;
602
618
  }) => string)>;
603
619
  type _SqlModel = Record<string, string | ((options: {
604
- ctx: any;
620
+ ctx?: any;
605
621
  isCount?: boolean;
606
622
  isSum?: boolean;
607
623
  limitStart?: number;
608
624
  limitEnd?: number;
609
625
  orderBy?: string;
610
- [k: string]: any;
626
+ params?: any;
611
627
  }) => string) | XML[]>;
612
628
  /**
613
629
  * ifUndefined默认是MapperIfUndefined.Skip
@@ -644,7 +660,7 @@ export declare class SqlCache {
644
660
  jsMode?: boolean;
645
661
  }): Promise<void>;
646
662
  load(sqlids: string[], options: {
647
- ctx: any;
663
+ ctx?: any;
648
664
  isCount?: boolean;
649
665
  isSum?: boolean;
650
666
  limitStart?: number;
@@ -664,6 +680,7 @@ export declare const DB: (config: ServiceOption) => <C extends {
664
680
  [_vueName]: string | undefined;
665
681
  [_daoDBName]: string | undefined;
666
682
  [_dbType]: DBType;
683
+ [_formatDialect]: any;
667
684
  [_sqlite_version]: string | undefined;
668
685
  [_SqlOption]: {
669
686
  maxDeal: number;
@@ -672,11 +689,13 @@ export declare const DB: (config: ServiceOption) => <C extends {
672
689
  skipEmptyString: boolean;
673
690
  } & ServiceOption;
674
691
  [_ids]: any;
692
+ [_logicIds]: any;
675
693
  [_fields]: any;
676
694
  [_columns]: any;
677
695
  [_columnsNoId]: any;
678
696
  [_index]: any;
679
697
  [_def]: any;
698
+ [_comment]: string | undefined;
680
699
  [_stateFileName]: any;
681
700
  [_deleteState]: any;
682
701
  [_transformer]: <L extends Object>(data: L, option?: MethodOption & {
@@ -733,6 +752,7 @@ export declare class SqlService<T extends object> {
733
752
  private [_ClassName]?;
734
753
  private [_vueName]?;
735
754
  private [_daoDBName]?;
755
+ private [_comment]?;
736
756
  private [_ids]?;
737
757
  private [_fields]?;
738
758
  private [_columns]?;
@@ -741,6 +761,7 @@ export declare class SqlService<T extends object> {
741
761
  private [_deleteState]?;
742
762
  private [_SqlOption]?;
743
763
  private [_dbType]?;
764
+ private [_formatDialect]?;
744
765
  private [_sqlite_version]?;
745
766
  private [_index]?;
746
767
  private [_def]?;
@@ -1246,8 +1267,8 @@ export declare class SqlService<T extends object> {
1246
1267
  sqlId: string;
1247
1268
  context?: any;
1248
1269
  params: Record<string, any>;
1249
- pageSize: number;
1250
- pageNumber: number;
1270
+ pageSize?: number;
1271
+ pageNumber?: number;
1251
1272
  limitSelf?: boolean;
1252
1273
  countSelf?: boolean;
1253
1274
  sumSelf?: boolean;
@@ -1261,8 +1282,8 @@ export declare class SqlService<T extends object> {
1261
1282
  sqlId: string;
1262
1283
  context?: any;
1263
1284
  params: Record<string, any>;
1264
- pageSize: number;
1265
- pageNumber: number;
1285
+ pageSize?: number;
1286
+ pageNumber?: number;
1266
1287
  limitSelf?: boolean;
1267
1288
  countSelf?: boolean;
1268
1289
  sumSelf?: boolean;
@@ -1271,6 +1292,40 @@ export declare class SqlService<T extends object> {
1271
1292
  mapper?: string | SqlMapper;
1272
1293
  mapperIfUndefined?: MapperIfUndefined;
1273
1294
  }): PageQuery<L>;
1295
+ /**
1296
+ * 导出数据,可以为EJS-EXCEL直接使用
1297
+ * @param list
1298
+ * @returns
1299
+ */
1300
+ exp<L = T>(list: L[]): {
1301
+ title: string | undefined;
1302
+ titleSpan: string;
1303
+ columnTitles: string[];
1304
+ datas: any[][];
1305
+ };
1306
+ /**
1307
+ * 导入数据的模板
1308
+ * @returns
1309
+ */
1310
+ imp(): {
1311
+ title: string | undefined;
1312
+ titleSpan: string;
1313
+ columnTitles: string[];
1314
+ };
1315
+ /**
1316
+ * 初始化表结构
1317
+ * 只有sqlite、sqliteremote需要
1318
+ * force: 是否强制,默认false, 强制时会删除再创建
1319
+ * @param option
1320
+ */
1321
+ init(option?: MethodOption & {
1322
+ sync?: SyncMode.Async;
1323
+ force?: boolean;
1324
+ }): Promise<void>;
1325
+ init(option: MethodOption & {
1326
+ sync: SyncMode.Sync;
1327
+ force?: boolean;
1328
+ }): void;
1274
1329
  /**
1275
1330
  #创建表
1276
1331
  ** `tableName` 表名称