vona-module-a-orm 5.0.37

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 (116) hide show
  1. package/LICENSE +21 -0
  2. package/cli/databaseDialect/boilerplate/{{sceneName}}.{{beanName}}.ts_ +4 -0
  3. package/cli/entity/boilerplate/{{beanName}}.ts_ +7 -0
  4. package/cli/entity/metadata/generate.ts +52 -0
  5. package/cli/model/boilerplate/{{beanName}}.ts_ +8 -0
  6. package/cli/model/metadata/generate.ts +285 -0
  7. package/dist/.metadata/index.d.ts +246 -0
  8. package/dist/.metadata/this.d.ts +2 -0
  9. package/dist/bean/aopMethod.transaction.d.ts +9 -0
  10. package/dist/bean/bean.database.d.ts +12 -0
  11. package/dist/bean/bean.databaseDialectBase.d.ts +20 -0
  12. package/dist/bean/bean.model/bean.model_cache.d.ts +56 -0
  13. package/dist/bean/bean.model/bean.model_crud.d.ts +13 -0
  14. package/dist/bean/bean.model/bean.model_crud_inner.d.ts +15 -0
  15. package/dist/bean/bean.model/bean.model_crud_table.d.ts +13 -0
  16. package/dist/bean/bean.model/bean.model_knex.d.ts +15 -0
  17. package/dist/bean/bean.model/bean.model_meta.d.ts +40 -0
  18. package/dist/bean/bean.model/bean.model_utils.d.ts +39 -0
  19. package/dist/bean/bean.model/bean.model_view.d.ts +14 -0
  20. package/dist/bean/bean.model.d.ts +3 -0
  21. package/dist/bean/bean.modelBase.d.ts +3 -0
  22. package/dist/bean/broadcast.columnsClear.d.ts +10 -0
  23. package/dist/bean/broadcast.databaseClientReload.d.ts +12 -0
  24. package/dist/bean/event.clientNameReal.d.ts +6 -0
  25. package/dist/bean/event.columnsClear.d.ts +9 -0
  26. package/dist/bean/event.databaseClientReload.d.ts +11 -0
  27. package/dist/bean/schedule.softDeletionPrune.d.ts +6 -0
  28. package/dist/common/buildWhere.d.ts +4 -0
  29. package/dist/common/checkWhere.d.ts +1 -0
  30. package/dist/common/index.d.ts +3 -0
  31. package/dist/common/utils.d.ts +10 -0
  32. package/dist/config/config.d.ts +72 -0
  33. package/dist/config/errors.d.ts +3 -0
  34. package/dist/config/locale/en-us.d.ts +9 -0
  35. package/dist/config/locale/zh-cn.d.ts +9 -0
  36. package/dist/extend/index.d.ts +4 -0
  37. package/dist/extend/schemaBuilder.d.ts +13 -0
  38. package/dist/extend/tableBuilder.d.ts +22 -0
  39. package/dist/index.d.ts +7 -0
  40. package/dist/index.js +4085 -0
  41. package/dist/lib/columns.d.ts +9 -0
  42. package/dist/lib/database.d.ts +6 -0
  43. package/dist/lib/databaseDialect.d.ts +1 -0
  44. package/dist/lib/dto/dto.d.ts +12 -0
  45. package/dist/lib/dto/dtoAggregate.d.ts +8 -0
  46. package/dist/lib/dto/dtoCreate.d.ts +5 -0
  47. package/dist/lib/dto/dtoGet.d.ts +8 -0
  48. package/dist/lib/dto/dtoGroup.d.ts +8 -0
  49. package/dist/lib/dto/dtoMutate.d.ts +8 -0
  50. package/dist/lib/dto/dtoUpdate.d.ts +5 -0
  51. package/dist/lib/dto/index.d.ts +1 -0
  52. package/dist/lib/entity.d.ts +3 -0
  53. package/dist/lib/index.d.ts +10 -0
  54. package/dist/lib/model.d.ts +2 -0
  55. package/dist/lib/modelCacheBase.d.ts +20 -0
  56. package/dist/lib/relations.d.ts +15 -0
  57. package/dist/lib/relationsDynamic.d.ts +15 -0
  58. package/dist/lib/relationsMutate.d.ts +14 -0
  59. package/dist/lib/relationsStatic.d.ts +9 -0
  60. package/dist/main.d.ts +9 -0
  61. package/dist/service/cacheEntity_.d.ts +10 -0
  62. package/dist/service/cacheQuery_.d.ts +7 -0
  63. package/dist/service/columnsCache_.d.ts +22 -0
  64. package/dist/service/columns_.d.ts +13 -0
  65. package/dist/service/database.d.ts +17 -0
  66. package/dist/service/databaseAsyncLocalStorage_.d.ts +10 -0
  67. package/dist/service/databaseClient_.d.ts +30 -0
  68. package/dist/service/db_.d.ts +26 -0
  69. package/dist/service/entityResolver_.d.ts +9 -0
  70. package/dist/service/modelResolver_.d.ts +8 -0
  71. package/dist/service/relations_.d.ts +19 -0
  72. package/dist/service/transactionAsyncLocalStorage_.d.ts +10 -0
  73. package/dist/service/transactionConsistency/342/200/214_.d.ts +10 -0
  74. package/dist/service/transactionFiber_.d.ts +13 -0
  75. package/dist/service/transactionState_.d.ts +11 -0
  76. package/dist/service/transaction_.d.ts +18 -0
  77. package/dist/types/columns.d.ts +6 -0
  78. package/dist/types/config.d.ts +14 -0
  79. package/dist/types/database.d.ts +47 -0
  80. package/dist/types/dialect.d.ts +6 -0
  81. package/dist/types/dto/dtoAggregate.d.ts +2 -0
  82. package/dist/types/dto/dtoGet.d.ts +12 -0
  83. package/dist/types/dto/dtoGroup.d.ts +2 -0
  84. package/dist/types/dto/dtoMutate.d.ts +14 -0
  85. package/dist/types/dto/index.d.ts +4 -0
  86. package/dist/types/entity.d.ts +15 -0
  87. package/dist/types/entityBase.d.ts +5 -0
  88. package/dist/types/entityBaseEmpty.d.ts +2 -0
  89. package/dist/types/entityBaseInner.d.ts +7 -0
  90. package/dist/types/entityBaseSimple.d.ts +4 -0
  91. package/dist/types/extra.d.ts +11 -0
  92. package/dist/types/index.d.ts +30 -0
  93. package/dist/types/logger.d.ts +7 -0
  94. package/dist/types/model.d.ts +79 -0
  95. package/dist/types/modelAggr.d.ts +26 -0
  96. package/dist/types/modelCount.d.ts +15 -0
  97. package/dist/types/modelGeneral.d.ts +23 -0
  98. package/dist/types/modelGroup.d.ts +23 -0
  99. package/dist/types/modelWhere.d.ts +86 -0
  100. package/dist/types/onion/databaseDialect.d.ts +17 -0
  101. package/dist/types/onion/entity.d.ts +26 -0
  102. package/dist/types/onion/index.d.ts +4 -0
  103. package/dist/types/onion/model.d.ts +55 -0
  104. package/dist/types/onion/table.d.ts +2 -0
  105. package/dist/types/relations.d.ts +102 -0
  106. package/dist/types/relationsAggr.d.ts +16 -0
  107. package/dist/types/relationsColumns.d.ts +45 -0
  108. package/dist/types/relationsDef.d.ts +59 -0
  109. package/dist/types/relationsDefDynamic.d.ts +56 -0
  110. package/dist/types/relationsDefMutate.d.ts +9 -0
  111. package/dist/types/relationsGroup.d.ts +21 -0
  112. package/dist/types/relationsMutate.d.ts +25 -0
  113. package/dist/types/relationsTables.d.ts +15 -0
  114. package/dist/types/tableIdentity.d.ts +1 -0
  115. package/dist/types/transaction.d.ts +18 -0
  116. package/package.json +74 -0
@@ -0,0 +1,20 @@
1
+ import type { Knex } from 'knex';
2
+ import type { ITableColumn } from '../types/columns.ts';
3
+ import type { ConfigDatabaseClient } from '../types/config.ts';
4
+ import type { IFetchDatabasesResultItem, IFetchIndexesResultItem } from '../types/dialect.ts';
5
+ import type { TableIdentity } from '../types/tableIdentity.ts';
6
+ import { BeanBase } from 'vona';
7
+ export declare class BeanDatabaseDialectBase extends BeanBase {
8
+ getConfigBase(): ConfigDatabaseClient | undefined;
9
+ fetchDatabases(_schemaBuilder: Knex.SchemaBuilder, _databasePrefix: string): Promise<IFetchDatabasesResultItem[]>;
10
+ createDatabase(_schemaBuilder: Knex.SchemaBuilder, _databaseName: string): Promise<void>;
11
+ dropDatabase(_schemaBuilder: Knex.SchemaBuilder, _databaseName: string): Promise<void>;
12
+ fetchIndexes(_schemaBuilder: Knex.SchemaBuilder, _tableName: string): Promise<IFetchIndexesResultItem[]>;
13
+ insert(_builder: Knex.QueryBuilder): Promise<TableIdentity[]>;
14
+ query(_result: any): void;
15
+ viewDependents(_builder: Knex.QueryBuilder, _viewName: string): Promise<string[]>;
16
+ coerceColumn(column: Knex.ColumnInfo): ITableColumn;
17
+ protected _coerceColumnValue(type: string, value: any): any;
18
+ protected _safeNumber(value: any): number | undefined;
19
+ protected _columnTypePrefixes(type: string, prefixes: string[]): boolean;
20
+ }
@@ -0,0 +1,56 @@
1
+ import type BigNumber from 'bignumber.js';
2
+ import type { ServiceDb } from '../../service/db_.ts';
3
+ import type { IDatabaseClientRecord, IModelDeleteOptions, IModelGetOptions, IModelInsertOptions, IModelMethodOptions, IModelMethodOptionsGeneral, IModelMutateOptions, IModelRecord, IModelSelectAggrParams, IModelSelectCountParams, IModelSelectGroupParams, IModelSelectParams, IModelUpdateOptions, ITableRecord, TableIdentity, TypeModelAggrRelationResult, TypeModelClassLikeGeneral, TypeModelGroupRelationResult, TypeModelsClassLikeGeneral, TypeModelWhere } from '../../types/index.ts';
4
+ import { ServiceCacheEntity } from '../../service/cacheEntity_.ts';
5
+ import { ServiceCacheQuery } from '../../service/cacheQuery_.ts';
6
+ import { ServiceRelations } from '../../service/relations_.ts';
7
+ import { BeanModelCrud } from './bean.model_crud.ts';
8
+ declare const SymbolModelsClearAll: unique symbol;
9
+ export declare class BeanModelCache<TRecord extends {} = {}> extends BeanModelCrud<TRecord> {
10
+ cacheQuery: ServiceCacheQuery;
11
+ cacheEntity: ServiceCacheEntity;
12
+ protected relations: ServiceRelations;
13
+ protected [SymbolModelsClearAll]: Record<keyof IModelRecord, TypeModelClassLikeGeneral[]>;
14
+ protected __init__(clientName?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): void;
15
+ insert<T extends IModelInsertOptions<TRecord>>(data?: Partial<TRecord>, options?: T): Promise<TRecord>;
16
+ insertBulk<T extends IModelInsertOptions<TRecord>>(items: Partial<TRecord>[], options?: T): Promise<TRecord[]>;
17
+ __insertBulk_raw(table: keyof ITableRecord | undefined, items: Partial<TRecord>[], options?: IModelMutateOptions<TRecord>): Promise<TRecord[]>;
18
+ mutate<T extends IModelMutateOptions<TRecord>>(data?: Partial<TRecord>, options?: T): Promise<Partial<TRecord>>;
19
+ mutateBulk<T extends IModelMutateOptions<TRecord>>(items: Partial<TRecord>[], options?: T): Promise<Partial<TRecord>[]>;
20
+ __mutateBulk_raw(table: keyof ITableRecord | undefined, items: Partial<TRecord>[], options?: IModelMutateOptions<TRecord>): Promise<TRecord[]>;
21
+ mget<T extends IModelGetOptions<TRecord>>(ids: TableIdentity[], options?: T): Promise<Partial<TRecord>[]>;
22
+ private __mget_raw;
23
+ count<T extends IModelSelectCountParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<BigNumber | undefined>;
24
+ aggregate<T extends IModelSelectAggrParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<TypeModelAggrRelationResult<T>>;
25
+ private __aggregate_raw;
26
+ group<T extends IModelSelectGroupParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<TypeModelGroupRelationResult<TRecord, T>[]>;
27
+ private __group_raw;
28
+ select<T extends IModelSelectParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<any[]>;
29
+ private __select_raw;
30
+ private __select_cache;
31
+ get<T extends IModelGetOptions<TRecord>>(where: TypeModelWhere<TRecord>, options?: T): Promise<Partial<TRecord> | undefined>;
32
+ private __get_raw;
33
+ update<T extends IModelUpdateOptions<TRecord>>(data: Partial<TRecord>, options?: T): Promise<Partial<TRecord>>;
34
+ updateBulk<T extends IModelUpdateOptions<TRecord>>(items: Partial<TRecord>[], options?: T): Promise<Partial<TRecord>[]>;
35
+ __updateBulk_raw<T extends IModelUpdateOptions<TRecord>>(table: keyof ITableRecord | undefined, items: Partial<TRecord>[], options?: T): Promise<void>;
36
+ __update_raw(table: keyof ITableRecord | undefined, data: Partial<TRecord>, options?: IModelUpdateOptions<TRecord>): Promise<TableIdentity[] | void>;
37
+ delete<T extends IModelDeleteOptions<TRecord>>(where?: TypeModelWhere<TRecord>, options?: T): Promise<void>;
38
+ deleteBulk<T extends IModelDeleteOptions<TRecord>>(ids: TableIdentity[], options?: T): Promise<void>;
39
+ __deleteBulk_raw_with_relations<T extends IModelDeleteOptions<TRecord>>(table: keyof ITableRecord | undefined, ids: TableIdentity[], options?: T): Promise<void>;
40
+ __delete_raw(table: keyof ITableRecord | undefined, where?: TypeModelWhere<TRecord>, options?: IModelMethodOptions): Promise<TableIdentity[] | void>;
41
+ private __get_key;
42
+ private __filterMGetColumns;
43
+ private __filterGetColumns;
44
+ cacheEntityDel(id: TableIdentity | TableIdentity[], table?: keyof ITableRecord): Promise<void>;
45
+ cacheEntityClear(table?: keyof ITableRecord): Promise<void>;
46
+ cacheQueryClear(table?: keyof ITableRecord): Promise<void>;
47
+ private _cacheQueryClearModelsClear;
48
+ private _getModelsClear;
49
+ private _getModelsClearAll;
50
+ private _collectModelsClearAll;
51
+ protected _checkDisableCacheQueryByOptions(options?: IModelMethodOptionsGeneral): boolean;
52
+ protected _checkDisableCacheEntityByOptions(options?: IModelMethodOptionsGeneral): boolean;
53
+ private __checkIfOnlyKey;
54
+ private __checkCacheKeyValid;
55
+ }
56
+ export {};
@@ -0,0 +1,13 @@
1
+ import type BigNumber from 'bignumber.js';
2
+ import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectParams, IModelUpdateOptionsGeneral, TableIdentity, TypeModelWhere } from '../../types/index.ts';
3
+ import { BeanModelCrudInner } from './bean.model_crud_inner.ts';
4
+ export declare class BeanModelCrud<TRecord extends {} = {}> extends BeanModelCrudInner<TRecord> {
5
+ mget(ids: TableIdentity[], options?: IModelGetOptionsGeneral<TRecord>): Promise<Partial<TRecord>[]>;
6
+ select(params?: IModelSelectParams<TRecord>, options?: IModelMethodOptionsGeneral): Promise<Partial<TRecord>[]>;
7
+ get(where: TypeModelWhere<TRecord>, options?: IModelGetOptionsGeneral<TRecord>): Promise<Partial<TRecord> | undefined>;
8
+ count(params?: IModelCountParams<TRecord>, options?: IModelMethodOptionsGeneral): Promise<BigNumber | undefined>;
9
+ insert(data?: Partial<TRecord>, options?: IModelMethodOptionsGeneral): Promise<TRecord>;
10
+ insertBulk(data: Partial<TRecord>[], options?: IModelMethodOptionsGeneral): Promise<TRecord[]>;
11
+ update(data: Partial<TRecord>, options?: IModelUpdateOptionsGeneral<TRecord>): Promise<Partial<TRecord>>;
12
+ delete(where?: TypeModelWhere<TRecord>, options?: IModelMethodOptionsGeneral): Promise<void>;
13
+ }
@@ -0,0 +1,15 @@
1
+ import type BigNumber from 'bignumber.js';
2
+ import type { Knex } from 'knex';
3
+ import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectGeneralParams, IModelSelectParams, IModelUpdateOptionsGeneral, ITableRecord, TableIdentity, TypeModelWhere } from '../../types/index.ts';
4
+ import { BeanModelView } from './bean.model_view.ts';
5
+ export declare class BeanModelCrudInner<TRecord extends {}> extends BeanModelView<TRecord> {
6
+ protected _mget(table?: keyof ITableRecord, ids?: TableIdentity[], options?: IModelGetOptionsGeneral<TRecord>): Promise<TRecord[]>;
7
+ protected _mget_original(table?: keyof ITableRecord, ids?: TableIdentity[], options?: IModelGetOptionsGeneral<TRecord>): Promise<(TRecord | undefined)[]>;
8
+ protected _select<T extends IModelSelectParams<TRecord>>(table?: keyof ITableRecord, params?: T, options?: IModelMethodOptionsGeneral, builder?: Knex.QueryBuilder<TRecord, TRecord[]>): Promise<TRecord[]>;
9
+ protected _select_buildParams<T extends IModelSelectGeneralParams<TRecord>>(table: keyof ITableRecord, params?: T, options?: IModelMethodOptionsGeneral): Knex.QueryBuilder<TRecord, TRecord[]>;
10
+ protected _get(table: keyof ITableRecord | undefined, where: TypeModelWhere<TRecord>, options?: IModelGetOptionsGeneral<TRecord>): Promise<TRecord | undefined>;
11
+ protected _count(table?: keyof ITableRecord, params?: IModelCountParams<TRecord>, options?: IModelMethodOptionsGeneral): Promise<BigNumber | undefined>;
12
+ protected _insertBulk(table?: keyof ITableRecord, data?: Partial<TRecord> | Partial<TRecord>[], options?: IModelMethodOptionsGeneral): Promise<TRecord | TRecord[]>;
13
+ protected _update(table: keyof ITableRecord | undefined, data: Partial<TRecord>, options?: IModelUpdateOptionsGeneral<TRecord>): Promise<Partial<TRecord>>;
14
+ protected _delete(table?: keyof ITableRecord, where?: TypeModelWhere<TRecord>, options?: IModelMethodOptionsGeneral): Promise<void>;
15
+ }
@@ -0,0 +1,13 @@
1
+ import type BigNumber from 'bignumber.js';
2
+ import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectParams, IModelUpdateOptionsGeneral, ITableRecord, TableIdentity, TypeModelWhere } from '../../types/index.ts';
3
+ import { BeanModelCrudInner } from './bean.model_crud_inner.ts';
4
+ export declare class BeanModelCrudTable<TRecord extends {}> extends BeanModelCrudInner<TRecord> {
5
+ mget(table: keyof ITableRecord, ids: TableIdentity[], options?: Omit<IModelGetOptionsGeneral<TRecord>, 'include' | 'with'>): Promise<TRecord[]>;
6
+ select(table: keyof ITableRecord, params?: Omit<IModelSelectParams<TRecord>, 'include' | 'with'>, options?: IModelMethodOptionsGeneral): Promise<TRecord[]>;
7
+ get(table: keyof ITableRecord, where: TypeModelWhere<TRecord>, options?: Omit<IModelGetOptionsGeneral<TRecord>, 'include' | 'with'>): Promise<TRecord | undefined>;
8
+ count(table: keyof ITableRecord, params?: IModelCountParams<TRecord>, options?: IModelMethodOptionsGeneral): Promise<BigNumber | undefined>;
9
+ insert(table: keyof ITableRecord, data?: Partial<TRecord>, options?: IModelMethodOptionsGeneral): Promise<TRecord>;
10
+ insertBulk(table: keyof ITableRecord, data: Partial<TRecord>[], options?: IModelMethodOptionsGeneral): Promise<TRecord[]>;
11
+ update(table: keyof ITableRecord, data: Partial<TRecord>, options?: IModelUpdateOptionsGeneral<TRecord>): Promise<Partial<TRecord>>;
12
+ delete(table: keyof ITableRecord, where?: TypeModelWhere<TRecord>, options?: IModelMethodOptionsGeneral): Promise<void>;
13
+ }
@@ -0,0 +1,15 @@
1
+ import type { Knex } from 'knex';
2
+ import type { IModelMethodOptionsGeneral, ITableRecord } from '../../types/index.ts';
3
+ import { BeanModelUtils } from './bean.model_utils.ts';
4
+ export declare class BeanModelKnex<TRecord extends {}> extends BeanModelUtils<TRecord> {
5
+ get schema(): Knex.SchemaBuilder;
6
+ builder<TRecord2 extends {} = TRecord, TResult2 = TRecord2>(table?: Knex.TableDescriptor): Knex.QueryBuilder<TRecord2, TResult2[]>;
7
+ builderSelect<TRecord2 extends {} = TRecord, TResult2 = TRecord2>(options?: IModelMethodOptionsGeneral): Knex.QueryBuilder<TRecord2, TResult2[]>;
8
+ builderSelect<TRecord2 extends {} = TRecord, TResult2 = TRecord2>(table: keyof ITableRecord, options?: IModelMethodOptionsGeneral): Knex.QueryBuilder<TRecord2, TResult2[]>;
9
+ query(value: Knex.Value): Promise<TRecord[]>;
10
+ query(sql: string, binding: Knex.RawBinding): Promise<TRecord[]>;
11
+ query(sql: string, bindings: readonly Knex.RawBinding[] | Knex.ValueDict): Promise<TRecord[]>;
12
+ queryOne(value: Knex.Value): Promise<TRecord | undefined>;
13
+ queryOne(sql: string, binding: Knex.RawBinding): Promise<TRecord | undefined>;
14
+ queryOne(sql: string, bindings: readonly Knex.RawBinding[] | Knex.ValueDict): Promise<TRecord | undefined>;
15
+ }
@@ -0,0 +1,40 @@
1
+ import type { ServiceDb } from '../../service/db_.ts';
2
+ import type { IDatabaseClientRecord, IDecoratorModelOptions, IModelClassRecord, IModelMethodOptionsGeneral, IModelUpdateOptionsGeneral, ITableRecord, TypeEntityMeta, TypeModelClassLike, TypeModelRelationOptionsMetaClient } from '../../types/index.ts';
3
+ import type { BeanModel } from '../bean.model.ts';
4
+ import { BeanBase } from 'vona';
5
+ import { SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyModelOptions } from '../../types/index.ts';
6
+ declare const SymbolModelDb: unique symbol;
7
+ declare const SymbolModelTable: unique symbol;
8
+ export declare class BeanModelMeta<TRecord extends {} = {}> extends BeanBase {
9
+ [SymbolKeyEntity]: TRecord;
10
+ [SymbolKeyEntityMeta]: TypeEntityMeta<TRecord>;
11
+ [SymbolKeyModelOptions]: IDecoratorModelOptions;
12
+ private [SymbolModelDb]?;
13
+ private [SymbolModelTable]?;
14
+ protected __init__(clientName?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): void;
15
+ protected get self(): BeanModel<any>;
16
+ protected get connection(): import("knex").Knex<any, any[]>;
17
+ protected get dialect(): import("vona-module-a-orm").BeanDatabaseDialectBase;
18
+ get scopeOrm(): import("vona-module-a-orm").ScopeModuleAOrm;
19
+ get modelViewRecord(): import("vona-module-a-version").ModelViewRecord;
20
+ get db(): ServiceDb;
21
+ private _getDb;
22
+ getTable(): keyof ITableRecord;
23
+ private _getTable;
24
+ get options(): IDecoratorModelOptions;
25
+ get disableInstance(): boolean;
26
+ get disableDeleted(): boolean;
27
+ get disableCreateTime(): boolean;
28
+ get disableUpdateTime(): boolean;
29
+ protected _prepareDisableInstanceByOptions(table: keyof ITableRecord, data: any, options?: IModelMethodOptionsGeneral, useRaw?: boolean): any;
30
+ protected _prepareDisableDeletedByOptions(table: keyof ITableRecord, data: any, options?: IModelMethodOptionsGeneral, useRaw?: boolean): any;
31
+ protected _prepareDisableDeletedByOptionsSimple(options?: IModelMethodOptionsGeneral): boolean | undefined;
32
+ protected _checkIfEntityValidByDeleted(entity: any, options?: IModelMethodOptionsGeneral): boolean;
33
+ protected _checkDisableInstanceByOptions(options?: IModelMethodOptionsGeneral): boolean;
34
+ protected _checkDisableDeletedByOptions(options?: IModelMethodOptionsGeneral): boolean;
35
+ protected _checkDisableCreateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
36
+ protected _checkDisableUpdateTimeByOptions(options?: IModelUpdateOptionsGeneral<TRecord>): boolean;
37
+ newInstance(client?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): this;
38
+ newInstanceTarget<MODEL extends BeanModelMeta | (keyof IModelClassRecord)>(modelClassTarget: TypeModelClassLike<MODEL>, client?: TypeModelRelationOptionsMetaClient, table?: keyof ITableRecord): BeanModelMeta;
39
+ }
40
+ export {};
@@ -0,0 +1,39 @@
1
+ import type { Knex } from 'knex';
2
+ import type { IModelMethodOptionsGeneral, IModelSelectParamsJoin, IModelSelectParamsPage, ITableColumns, ITableRecord, TypeModelColumn, TypeModelColumns, TypeModelColumnsStrict, TypeModelSelectAggrParamsAggrs, TypeModelSelectGroupParamsColumns, TypeModelWhere } from '../../types/index.ts';
3
+ import { BeanModelMeta } from './bean.model_meta.ts';
4
+ export declare class BeanModelUtils<TRecord extends {}> extends BeanModelMeta<TRecord> {
5
+ prepareData(item?: Partial<TRecord>): Promise<[TRecord, TRecord]>;
6
+ prepareData(table: keyof ITableRecord, item?: Partial<TRecord>): Promise<[TRecord, TRecord]>;
7
+ defaultData(table?: keyof ITableRecord): Promise<TRecord>;
8
+ columns(table?: keyof ITableRecord): Promise<ITableColumns>;
9
+ isRaw(raw: any): boolean;
10
+ raw(value: Knex.Value): Knex.Raw<any>;
11
+ raw<TRecord2 extends {} = TRecord, TResult2 = TRecord2>(sql: string, binding: Knex.RawBinding): Knex.Raw<TResult2>;
12
+ raw<TRecord2 extends {} = TRecord, TResult2 = TRecord2>(sql: string, bindings: readonly Knex.RawBinding[] | Knex.ValueDict): Knex.Raw<TResult2>;
13
+ ref<TSrc extends string>(src: TSrc): Knex.Ref<TSrc, {
14
+ [K in TSrc]: TSrc;
15
+ }>;
16
+ toIdentifier(name: string | string[]): Knex.Raw<any>;
17
+ buildWhere(builder: Knex.QueryBuilder, wheres?: TypeModelWhere<TRecord>): void;
18
+ buildJoin(builder: Knex.QueryBuilder, join?: IModelSelectParamsJoin<TRecord, ''>): void;
19
+ buildJoins(builder: Knex.QueryBuilder, joins?: IModelSelectParamsJoin<TRecord, ''>[]): void;
20
+ buildDistinct(builder: Knex.QueryBuilder, distinct?: boolean | (keyof TRecord) | (keyof TRecord)[]): void;
21
+ buildCount(builder: Knex.QueryBuilder, column?: TypeModelColumn<TRecord>, distinct?: boolean | (keyof TRecord) | (keyof TRecord)[]): void;
22
+ buildOrders(builder: Knex.QueryBuilder, orders: any): void;
23
+ buildLimit(builder: Knex.QueryBuilder, limit?: number): void;
24
+ buildOffset(builder: Knex.QueryBuilder, offset?: number): void;
25
+ buildColumns(builder: Knex.QueryBuilder, columns?: TypeModelColumns<TRecord>, groups?: (keyof TRecord)[] | undefined): void;
26
+ buildGroups(builder: Knex.QueryBuilder, groups?: TypeModelColumnsStrict<TRecord>): (keyof TRecord)[] | undefined;
27
+ buildAggrs(builder: Knex.QueryBuilder, aggrs?: TypeModelSelectAggrParamsAggrs<TRecord>): void;
28
+ buildPage(builder: Knex.QueryBuilder, page?: IModelSelectParamsPage): void;
29
+ prepareHaving(builder: Knex.QueryBuilder, having?: TypeModelWhere<TRecord, TypeModelSelectGroupParamsColumns<TRecord>>): void;
30
+ buildHaving(builder: Knex.QueryBuilder, having: TypeModelWhere<TRecord, TypeModelSelectGroupParamsColumns<TRecord>>): void;
31
+ prepareWhere(builder: Knex.QueryBuilder, table?: keyof ITableRecord, where?: TypeModelWhere<TRecord>, options?: IModelMethodOptionsGeneral): void;
32
+ convertItemsToBigNumber(items: {}[]): {}[];
33
+ extractCount(result: Array<object> | object, columnName?: string): BigNumber;
34
+ extractFirstNumber<T = number | BigNumber | undefined>(result: Array<object> | object, defaultValue?: T, columnName?: string): T extends undefined ? BigNumber | undefined : BigNumber;
35
+ extractFirstValue(result: Array<object> | object, defaultValue?: any, columnName?: string): any | undefined;
36
+ private _extractFirstValue;
37
+ protected _prepareWhereByOptions(table: keyof ITableRecord, where: any, options?: IModelMethodOptionsGeneral): any;
38
+ protected _prepareInsertDataByOptions(table: keyof ITableRecord, data: any, options?: IModelMethodOptionsGeneral): any;
39
+ }
@@ -0,0 +1,14 @@
1
+ import type { Knex } from 'knex';
2
+ import { BeanModelKnex } from './bean.model_knex.ts';
3
+ export declare class BeanModelView<TRecord extends {}> extends BeanModelKnex<TRecord> {
4
+ createView(viewName: string, callback?: (viewBuilder: Knex.ViewBuilder) => any): Promise<void>;
5
+ dropView(viewName: string, disableRemoveRecord?: boolean): Promise<void>;
6
+ alterView(viewName: string, callback?: (viewBuilder: Knex.ViewBuilder) => any): Promise<void>;
7
+ createTable(tableName: string, callback: (tableBuilder: Knex.CreateTableBuilder) => any): Promise<void>;
8
+ dropTable(tableName: string): Promise<void>;
9
+ alterTable(tableName: string, callback: (tableBuilder: Knex.CreateTableBuilder) => any, alterViewAuto?: boolean): Promise<void>;
10
+ viewDependents(viewName: string): Promise<string[]>;
11
+ viewDependentsAll(viewName: string): Promise<string[]>;
12
+ private _viewDependentsAll_inner;
13
+ private _viewDependentsAll_handle;
14
+ }
@@ -0,0 +1,3 @@
1
+ import { BeanModelCrudTable } from './bean.model/bean.model_crud_table.ts';
2
+ export declare class BeanModel<TRecord extends {} = any> extends BeanModelCrudTable<TRecord> {
3
+ }
@@ -0,0 +1,3 @@
1
+ import { BeanModelCache } from './bean.model/bean.model_cache.ts';
2
+ export declare class BeanModelBase<TRecord extends {} = any> extends BeanModelCache<TRecord> {
3
+ }
@@ -0,0 +1,10 @@
1
+ import type { IBroadcastExecute } from 'vona-module-a-broadcast';
2
+ import type { IDatabaseClientRecord } from '../types/database.ts';
3
+ import { BeanBroadcastBase } from 'vona-module-a-broadcast';
4
+ export interface TypeBroadcastColumnsClearJobData {
5
+ clientName?: keyof IDatabaseClientRecord;
6
+ tableName?: string;
7
+ }
8
+ export declare class BroadcastColumnsClear extends BeanBroadcastBase<TypeBroadcastColumnsClearJobData> implements IBroadcastExecute<TypeBroadcastColumnsClearJobData> {
9
+ execute(data: TypeBroadcastColumnsClearJobData, isEmitter?: boolean): Promise<void>;
10
+ }
@@ -0,0 +1,12 @@
1
+ import type { IBroadcastExecute } from 'vona-module-a-broadcast';
2
+ import type { ConfigDatabaseClient } from '../types/config.ts';
3
+ import type { IDatabaseClientRecord } from '../types/database.ts';
4
+ import { BeanBroadcastBase } from 'vona-module-a-broadcast';
5
+ export interface TypeBroadcastDatabaseClientReloadJobData {
6
+ clientName?: keyof IDatabaseClientRecord;
7
+ clientConfig?: ConfigDatabaseClient;
8
+ extraData?: any;
9
+ }
10
+ export declare class BroadcastDatabaseClientReload extends BeanBroadcastBase<TypeBroadcastDatabaseClientReloadJobData> implements IBroadcastExecute<TypeBroadcastDatabaseClientReloadJobData> {
11
+ execute(data: TypeBroadcastDatabaseClientReloadJobData, isEmitter?: boolean): Promise<void>;
12
+ }
@@ -0,0 +1,6 @@
1
+ import type { IDatabaseClientRecord } from '../types/database.ts';
2
+ import { BeanEventBase } from 'vona-module-a-event';
3
+ export type TypeEventClientNameRealData = keyof IDatabaseClientRecord;
4
+ export type TypeEventClientNameRealResult = keyof IDatabaseClientRecord;
5
+ export declare class EventClientNameReal extends BeanEventBase<TypeEventClientNameRealData, TypeEventClientNameRealResult> {
6
+ }
@@ -0,0 +1,9 @@
1
+ import type { IDatabaseClientRecord } from '../types/database.ts';
2
+ import { BeanEventBase } from 'vona-module-a-event';
3
+ export interface TypeEventColumnsClearData {
4
+ clientName: keyof IDatabaseClientRecord;
5
+ tableName?: string;
6
+ }
7
+ export type TypeEventColumnsClearResult = void;
8
+ export declare class EventColumnsClear extends BeanEventBase<TypeEventColumnsClearData, TypeEventColumnsClearResult> {
9
+ }
@@ -0,0 +1,11 @@
1
+ import type { ConfigDatabaseClient } from '../types/config.ts';
2
+ import type { IDatabaseClientRecord } from '../types/database.ts';
3
+ import { BeanEventBase } from 'vona-module-a-event';
4
+ export interface TypeEventDatabaseClientReloadData {
5
+ clientName: keyof IDatabaseClientRecord;
6
+ clientConfig?: ConfigDatabaseClient;
7
+ extraData?: any;
8
+ }
9
+ export type TypeEventDatabaseClientReloadResult = void;
10
+ export declare class EventDatabaseClientReload extends BeanEventBase<TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult> {
11
+ }
@@ -0,0 +1,6 @@
1
+ import type { IScheduleExecute } from 'vona-module-a-schedule';
2
+ import { BeanBase } from 'vona';
3
+ export declare class ScheduleSoftDeletionPrune extends BeanBase implements IScheduleExecute {
4
+ execute(): Promise<void>;
5
+ private _modulePrune;
6
+ }
@@ -0,0 +1,4 @@
1
+ import type { Knex } from 'knex';
2
+ import type { TypeModelWhere } from '../types/modelWhere.ts';
3
+ export declare function buildWhere<TRecord>(knex: Knex, builder: Knex.QueryBuilder, wheres: TypeModelWhere<TRecord>, having?: boolean): void;
4
+ export declare function isAggrColumn(column: string): boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './buildWhere.ts';
2
+ export * from './checkWhere.ts';
3
+ export * from './utils.ts';
@@ -0,0 +1,10 @@
1
+ import type { Constructable } from 'vona';
2
+ import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
3
+ import type { TypeModelColumn, TypeModelColumns } from '../types/modelWhere.ts';
4
+ import type { IModelClassRecord } from '../types/onion/model.ts';
5
+ export declare function isRaw(raw: any): boolean;
6
+ export declare function getTableOrTableAlias(table: string): string;
7
+ export declare function getTargetColumnName(column: string): string;
8
+ export declare function prepareColumns<TRecord>(columns?: TypeModelColumns<TRecord>): Array<TypeModelColumn<TRecord>> | undefined;
9
+ export declare function prepareClassModel<ModelLike extends BeanModelMeta | (keyof IModelClassRecord)>(classType: ModelLike extends BeanModelMeta ? ((() => Constructable<ModelLike>) | Constructable<ModelLike>) : ModelLike): Constructable<ModelLike>;
10
+ export declare function getClassEntityFromClassModel<T>(modelClass: Constructable<T>): Constructable<any>;
@@ -0,0 +1,72 @@
1
+ import type { TypeBeanRecordGeneralSelectorKeys, VonaApplication } from 'vona';
2
+ import type { IOnionOptionsMeta } from 'vona-module-a-onion';
3
+ import type { TSummerCachePreset } from 'vona-module-a-summer';
4
+ import type { IDatabaseClientDialectRecord } from '../types/database.ts';
5
+ import type { TableIdentityType } from '../types/tableIdentity.ts';
6
+ export type TypeDataBaseConfigDialects = Record<keyof IDatabaseClientDialectRecord, TypeBeanRecordGeneralSelectorKeys<'databaseDialect'>>;
7
+ export declare function config(_app: VonaApplication): {
8
+ table: {
9
+ identityType: TableIdentityType;
10
+ };
11
+ model: {
12
+ disableDeleted: boolean;
13
+ disableInstance: boolean;
14
+ disableCreateTime: boolean;
15
+ disableUpdateTime: boolean;
16
+ };
17
+ softDeletionPrune: {
18
+ enable: boolean;
19
+ expired: number;
20
+ };
21
+ dialects: TypeDataBaseConfigDialects;
22
+ summer: {
23
+ enable: boolean;
24
+ meta: IOnionOptionsMeta;
25
+ presetDefault: TSummerCachePreset;
26
+ preset: {
27
+ redis: import("vona-module-a-summer").IDecoratorSummerCacheOptions;
28
+ redisWithIgnoreNull: {
29
+ ignoreNull: boolean;
30
+ preset?: TSummerCachePreset;
31
+ mode?: import("vona-module-a-summer").TSummerCacheMode;
32
+ mem?: {
33
+ max?: number;
34
+ ttl?: number;
35
+ updateAgeOnGet?: boolean;
36
+ updateAgeOnHas?: boolean;
37
+ broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
38
+ };
39
+ redis?: {
40
+ ttl: number;
41
+ updateAgeOnGet?: boolean;
42
+ client?: keyof import("vona-module-a-redis").IRedisClientRecord;
43
+ };
44
+ enable?: boolean;
45
+ meta?: Omit<IOnionOptionsMeta, never> | undefined;
46
+ };
47
+ all: import("vona-module-a-summer").IDecoratorSummerCacheOptions;
48
+ allWithIgnoreNull: {
49
+ ignoreNull: boolean;
50
+ preset?: TSummerCachePreset;
51
+ mode?: import("vona-module-a-summer").TSummerCacheMode;
52
+ mem?: {
53
+ max?: number;
54
+ ttl?: number;
55
+ updateAgeOnGet?: boolean;
56
+ updateAgeOnHas?: boolean;
57
+ broadcastOnSet?: import("vona-module-a-cache").TypeBroadcastOnSet;
58
+ };
59
+ redis?: {
60
+ ttl: number;
61
+ updateAgeOnGet?: boolean;
62
+ client?: keyof import("vona-module-a-redis").IRedisClientRecord;
63
+ };
64
+ enable?: boolean;
65
+ meta?: Omit<IOnionOptionsMeta, never> | undefined;
66
+ };
67
+ };
68
+ redis: {
69
+ client: string;
70
+ };
71
+ };
72
+ };
@@ -0,0 +1,3 @@
1
+ export declare enum Errors {
2
+ ShouldSpecifyTable = 1001
3
+ }
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ TableIdentity: string;
3
+ CreatedAt: string;
4
+ UpdatedAt: string;
5
+ Deleted: string;
6
+ InstanceId: string;
7
+ ShouldSpecifyTable: string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,9 @@
1
+ declare const _default: {
2
+ TableIdentity: string;
3
+ CreatedAt: string;
4
+ UpdatedAt: string;
5
+ Deleted: string;
6
+ InstanceId: string;
7
+ ShouldSpecifyTable: string;
8
+ };
9
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { VonaApplication } from 'vona';
2
+ export * from './schemaBuilder.ts';
3
+ export * from './tableBuilder.ts';
4
+ export declare function ExtendKnex(app: VonaApplication): void;
@@ -0,0 +1,13 @@
1
+ import type { VonaApplication } from 'vona';
2
+ import type { IFetchDatabasesResultItem, IFetchIndexesResultItem } from '../types/dialect.ts';
3
+ export declare function ExtendSchemaBuilder(app: VonaApplication): void;
4
+ declare module 'knex' {
5
+ namespace Knex {
6
+ interface SchemaBuilder {
7
+ fetchDatabases(databasePrefix: string): Promise<IFetchDatabasesResultItem[]>;
8
+ createDatabase(databaseName: string): Promise<void>;
9
+ dropDatabase(databaseName: string): Promise<void>;
10
+ fetchIndexes(tableName: string): Promise<IFetchIndexesResultItem[]>;
11
+ }
12
+ }
13
+ }
@@ -0,0 +1,22 @@
1
+ import type { VonaApplication } from 'vona';
2
+ export interface IBasicFieldsOptions {
3
+ id?: boolean;
4
+ timestamps?: boolean;
5
+ deleted?: boolean;
6
+ iid?: boolean;
7
+ }
8
+ export declare function ExtendTableBuilder(app: VonaApplication): void;
9
+ declare module 'knex' {
10
+ namespace Knex {
11
+ interface TableBuilder {
12
+ basicFields(options?: IBasicFieldsOptions): Knex.TableBuilder;
13
+ basicFieldsSimple(options?: IBasicFieldsOptions): Knex.TableBuilder;
14
+ tableIdentity(columnName?: string): Knex.ColumnBuilder;
15
+ userId(columnName?: string): Knex.ColumnBuilder;
16
+ int0(columnName: string): Knex.ColumnBuilder;
17
+ int1(columnName: string): Knex.ColumnBuilder;
18
+ description(length?: number): Knex.ColumnBuilder;
19
+ content(useText?: boolean): Knex.ColumnBuilder;
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,7 @@
1
+ import 'bignumber.js';
2
+ export * from './.metadata/index.ts';
3
+ export * from './bean/bean.model/bean.model_meta.ts';
4
+ export * from './common/index.ts';
5
+ export * from './extend/index.ts';
6
+ export * from './lib/index.ts';
7
+ export * from './types/index.ts';