vona-module-a-orm 5.0.49 → 5.0.51
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/cli/model/metadata/generate.ts +2 -1
- package/dist/bean/bean.databaseDialectBase.d.ts +1 -1
- package/dist/bean/bean.model/bean.model_cache.d.ts +4 -2
- package/dist/bean/bean.model/bean.model_crud.d.ts +2 -1
- package/dist/bean/bean.model/bean.model_crud_inner.d.ts +2 -1
- package/dist/bean/bean.model/bean.model_crud_table.d.ts +2 -1
- package/dist/config/config.d.ts +9 -1
- package/dist/index.js +161 -63
- package/dist/lib/dto/dto.d.ts +6 -0
- package/dist/lib/dto/dtoQuery.d.ts +3 -0
- package/dist/lib/dto/dtoQueryPage.d.ts +3 -0
- package/dist/lib/dto/dtoSelectAndCount.d.ts +6 -0
- package/dist/service/cacheEntity_.d.ts +1 -1
- package/dist/service/relations_.d.ts +1 -1
- package/dist/types/dto/dtoMutate.d.ts +1 -1
- package/dist/types/dto/dtoQueryBase.d.ts +5 -0
- package/dist/types/dto/dtoQueryPageBase.d.ts +5 -0
- package/dist/types/dto/dtoSelectAndCount.d.ts +8 -0
- package/dist/types/dto/index.d.ts +3 -0
- package/dist/types/entityBase.d.ts +1 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/model.d.ts +2 -1
- package/dist/types/modelWhere.d.ts +1 -1
- package/dist/types/relations.d.ts +5 -0
- package/dist/types/relationsMutate.d.ts +1 -1
- package/package.json +1 -1
- package/dist/types/tableIdentity.d.ts +0 -1
|
@@ -28,6 +28,7 @@ export default async function (options: IMetadataCustomGenerateOptions): Promise
|
|
|
28
28
|
[SymbolKeyModelOptions]: ${opionsName};
|
|
29
29
|
get<T extends IModelGetOptions<${entityName},${className}>>(where: TypeModelWhere<${entityName}>, options?: T): Promise<TypeModelRelationResult<${entityName}, ${className}, T> | undefined>;
|
|
30
30
|
mget<T extends IModelGetOptions<${entityName},${className}>>(ids: TableIdentity[], options?: T): Promise<TypeModelRelationResult<${entityName}, ${className}, T>[]>;
|
|
31
|
+
selectAndCount<T extends IModelSelectParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelSelectAndCount<${entityName}, ${className}, T>>;
|
|
31
32
|
select<T extends IModelSelectParams<${entityName},${className},ModelJoins>, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<TypeModelRelationResult<${entityName}, ${className}, T>[]>;
|
|
32
33
|
insert<T extends IModelInsertOptions<${entityName},${className}>>(data?: TypeModelMutateRelationData<${entityName},${className}, T>, options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T, true>>;
|
|
33
34
|
insertBulk<T extends IModelInsertOptions<${entityName},${className}>>(items: TypeModelMutateRelationData<${entityName},${className}, T>[], options?: T): Promise<TypeModelMutateRelationData<${entityName},${className}, T, true>[]>;
|
|
@@ -52,7 +53,7 @@ export default async function (options: IMetadataCustomGenerateOptions): Promise
|
|
|
52
53
|
if (contentRelations.length === 0 && contentRecords.length === 0 && contentModels.length === 0) return '';
|
|
53
54
|
// combine
|
|
54
55
|
const content = `/** ${sceneName}: begin */
|
|
55
|
-
import type { IModelGetOptions, IModelMethodOptions, IModelSelectParams,
|
|
56
|
+
import type { IModelGetOptions, IModelMethodOptions, IModelSelectParams, TypeModelSelectAndCount, TypeModelRelationResult, TypeModelWhere, IModelInsertOptions, TypeModelMutateRelationData, IModelDeleteOptions, IModelUpdateOptions, IModelMutateOptions, IModelSelectCountParams, IModelSelectAggrParams, TypeModelAggrRelationResult, IModelSelectGroupParams, TypeModelGroupRelationResult } from 'vona-module-a-orm';
|
|
56
57
|
import { SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyModelOptions } from 'vona-module-a-orm';
|
|
57
58
|
declare module 'vona-module-${moduleName}' {
|
|
58
59
|
${contentRelations.join('\n')}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
3
|
import type { ITableColumn } from '../types/columns.ts';
|
|
3
4
|
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
4
5
|
import type { IFetchDatabasesResultItem, IFetchIndexesResultItem } from '../types/dialect.ts';
|
|
5
|
-
import type { TableIdentity } from '../types/tableIdentity.ts';
|
|
6
6
|
import { BeanBase } from 'vona';
|
|
7
7
|
export declare class BeanDatabaseDialectBase extends BeanBase {
|
|
8
8
|
getConfigBase(): ConfigDatabaseClient | undefined;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
2
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,
|
|
3
|
+
import type { IDatabaseClientRecord, IModelDeleteOptions, IModelGetOptions, IModelInsertOptions, IModelMethodOptions, IModelMethodOptionsGeneral, IModelMutateOptions, IModelRecord, IModelSelectAggrParams, IModelSelectCountParams, IModelSelectGroupParams, IModelSelectParams, IModelUpdateOptions, ITableRecord, TypeModelAggrRelationResult, TypeModelClassLikeGeneral, TypeModelGroupRelationResult, TypeModelsClassLikeGeneral, TypeModelWhere } from '../../types/index.ts';
|
|
4
|
+
import BigNumber from 'bignumber.js';
|
|
4
5
|
import { ServiceCacheEntity } from '../../service/cacheEntity_.ts';
|
|
5
6
|
import { ServiceCacheQuery } from '../../service/cacheQuery_.ts';
|
|
6
7
|
import { ServiceRelations } from '../../service/relations_.ts';
|
|
@@ -25,6 +26,7 @@ export declare class BeanModelCache<TRecord extends {} = {}> extends BeanModelCr
|
|
|
25
26
|
private __aggregate_raw;
|
|
26
27
|
group<T extends IModelSelectGroupParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<TypeModelGroupRelationResult<TRecord, T>[]>;
|
|
27
28
|
private __group_raw;
|
|
29
|
+
selectAndCount<T extends IModelSelectParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, modelJoins?: ModelJoins): Promise<any>;
|
|
28
30
|
select<T extends IModelSelectParams<TRecord>, ModelJoins extends TypeModelsClassLikeGeneral | undefined>(params?: T, options?: IModelMethodOptions, _modelJoins?: ModelJoins): Promise<any[]>;
|
|
29
31
|
private __select_raw;
|
|
30
32
|
private __select_cache;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type BigNumber from 'bignumber.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TableIdentity } from 'table-identity';
|
|
3
|
+
import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectParams, IModelUpdateOptionsGeneral, TypeModelWhere } from '../../types/index.ts';
|
|
3
4
|
import { BeanModelCrudInner } from './bean.model_crud_inner.ts';
|
|
4
5
|
export declare class BeanModelCrud<TRecord extends {} = {}> extends BeanModelCrudInner<TRecord> {
|
|
5
6
|
mget(ids: TableIdentity[], options?: IModelGetOptionsGeneral<TRecord>): Promise<Partial<TRecord>[]>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type BigNumber from 'bignumber.js';
|
|
2
2
|
import type { Knex } from 'knex';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TableIdentity } from 'table-identity';
|
|
4
|
+
import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectGeneralParams, IModelSelectParams, IModelUpdateOptionsGeneral, ITableRecord, TypeModelWhere } from '../../types/index.ts';
|
|
4
5
|
import { BeanModelView } from './bean.model_view.ts';
|
|
5
6
|
export declare class BeanModelCrudInner<TRecord extends {}> extends BeanModelView<TRecord> {
|
|
6
7
|
protected _mget(table?: keyof ITableRecord, ids?: TableIdentity[], options?: IModelGetOptionsGeneral<TRecord>): Promise<TRecord[]>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type BigNumber from 'bignumber.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { TableIdentity } from 'table-identity';
|
|
3
|
+
import type { IModelCountParams, IModelGetOptionsGeneral, IModelMethodOptionsGeneral, IModelSelectParams, IModelUpdateOptionsGeneral, ITableRecord, TypeModelWhere } from '../../types/index.ts';
|
|
3
4
|
import { BeanModelCrudInner } from './bean.model_crud_inner.ts';
|
|
4
5
|
export declare class BeanModelCrudTable<TRecord extends {}> extends BeanModelCrudInner<TRecord> {
|
|
5
6
|
mget(table: keyof ITableRecord, ids: TableIdentity[], options?: Omit<IModelGetOptionsGeneral<TRecord>, 'include' | 'with'>): Promise<TRecord[]>;
|
package/dist/config/config.d.ts
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
+
import type { TableIdentityType } from 'table-identity';
|
|
1
2
|
import type { TypeBeanRecordGeneralSelectorKeys, VonaApplication } from 'vona';
|
|
2
3
|
import type { IOnionOptionsMeta } from 'vona-module-a-onion';
|
|
3
4
|
import type { TSummerCachePreset } from 'vona-module-a-summer';
|
|
4
5
|
import type { IDatabaseClientDialectRecord } from '../types/database.ts';
|
|
5
|
-
import type { TableIdentityType } from '../types/tableIdentity.ts';
|
|
6
6
|
export type TypeDataBaseConfigDialects = Record<keyof IDatabaseClientDialectRecord, TypeBeanRecordGeneralSelectorKeys<'databaseDialect'>>;
|
|
7
7
|
export declare function config(_app: VonaApplication): {
|
|
8
|
+
rest: {
|
|
9
|
+
query: {
|
|
10
|
+
pageSize: {
|
|
11
|
+
default: number;
|
|
12
|
+
max: number;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
8
16
|
table: {
|
|
9
17
|
identityType: TableIdentityType;
|
|
10
18
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BigNumber } from 'bignumber.js';
|
|
1
|
+
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
2
2
|
import { BeanInfo, BeanAopMethodBase, BeanBase, deepExtend, Virtual, appResource, beanFullNameFromOnionName, cast, appMetadata, useApp, BeanSimple, combineConfigDefault, BeanScopeBase, createBeanDecorator, PickClassInner, $Class } from 'vona';
|
|
3
3
|
import { AopMethod, Aspect } from 'vona-module-a-aspect';
|
|
4
4
|
import { Service, Bean, Scope } from 'vona-module-a-bean';
|
|
@@ -9,30 +9,29 @@ import { swapDeps } from '@cabloy/deps';
|
|
|
9
9
|
import { prepareClassType, getTargetDecoratorRules, Api, v, OrderMaxBase, OrderCoreBase, getSchemaDynamic, SymbolSchemaDynamicRefId, addSchemaDynamic, mergeFieldsOpenapiMetadata } from 'vona-module-a-openapi';
|
|
10
10
|
import { ZodMetadata } from '@cabloy/zod-query';
|
|
11
11
|
import { SymbolDecoratorRuleColumn } from 'vona-module-a-openapiutils';
|
|
12
|
-
|
|
12
|
+
import z from 'zod';
|
|
13
13
|
import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
14
14
|
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
15
15
|
import { Schedule } from 'vona-module-a-schedule';
|
|
16
16
|
import { configAllWithIgnoreNull, configAll, configRedisWithIgnoreNull, configRedis } from 'vona-module-a-summer';
|
|
17
17
|
import { ServiceDatabaseAsyncLocalStorage as ServiceDatabaseAsyncLocalStorage$1, ServiceTransactionConsistency as ServiceTransactionConsistency_ } from 'vona-module-a-orm';
|
|
18
18
|
import { mutate } from 'mutate-on-copy';
|
|
19
|
-
import z from 'zod';
|
|
20
19
|
|
|
21
|
-
var _dec$
|
|
22
|
-
let AopMethodTransaction = (_dec$
|
|
20
|
+
var _dec$w, _dec2$w, _class$w;
|
|
21
|
+
let AopMethodTransaction = (_dec$w = AopMethod(), _dec2$w = BeanInfo({
|
|
23
22
|
module: "a-orm"
|
|
24
|
-
}), _dec$
|
|
23
|
+
}), _dec$w(_class$w = _dec2$w(_class$w = class AopMethodTransaction extends BeanAopMethodBase {
|
|
25
24
|
execute(options, _args, next, _receiver, _prop) {
|
|
26
25
|
return this.bean.database.current.transaction.begin(() => {
|
|
27
26
|
return next();
|
|
28
27
|
}, options);
|
|
29
28
|
}
|
|
30
|
-
}) || _class$
|
|
29
|
+
}) || _class$w) || _class$w);
|
|
31
30
|
|
|
32
|
-
var _dec$
|
|
33
|
-
let ServiceDatabaseAsyncLocalStorage = (_dec$
|
|
31
|
+
var _dec$v, _dec2$v, _class$v;
|
|
32
|
+
let ServiceDatabaseAsyncLocalStorage = (_dec$v = Service(), _dec2$v = BeanInfo({
|
|
34
33
|
module: "a-orm"
|
|
35
|
-
}), _dec$
|
|
34
|
+
}), _dec$v(_class$v = _dec2$v(_class$v = class ServiceDatabaseAsyncLocalStorage extends BeanBase {
|
|
36
35
|
constructor(...args) {
|
|
37
36
|
super(...args);
|
|
38
37
|
this.dbStorage = void 0;
|
|
@@ -51,14 +50,14 @@ let ServiceDatabaseAsyncLocalStorage = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
|
51
50
|
return fn();
|
|
52
51
|
});
|
|
53
52
|
}
|
|
54
|
-
}) || _class$
|
|
53
|
+
}) || _class$v) || _class$v);
|
|
55
54
|
|
|
56
|
-
var _dec$
|
|
55
|
+
var _dec$u, _dec2$u, _class$u;
|
|
57
56
|
const SymbolColumnsCache = Symbol('SymbolColumnsCache');
|
|
58
57
|
const SymbolColumnsDefaultCache = Symbol('SymbolColumnsDefaultCache');
|
|
59
|
-
let ServiceColumnsCache = (_dec$
|
|
58
|
+
let ServiceColumnsCache = (_dec$u = Service(), _dec2$u = BeanInfo({
|
|
60
59
|
module: "a-orm"
|
|
61
|
-
}), _dec$
|
|
60
|
+
}), _dec$u(_class$u = _dec2$u(_class$u = class ServiceColumnsCache extends BeanBase {
|
|
62
61
|
constructor(...args) {
|
|
63
62
|
super(...args);
|
|
64
63
|
this.clientName = void 0;
|
|
@@ -113,12 +112,12 @@ let ServiceColumnsCache = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
|
113
112
|
return exists;
|
|
114
113
|
}
|
|
115
114
|
}
|
|
116
|
-
}) || _class$
|
|
115
|
+
}) || _class$u) || _class$u);
|
|
117
116
|
|
|
118
|
-
var _dec$
|
|
119
|
-
let ServiceColumns = (_dec$
|
|
117
|
+
var _dec$t, _dec2$t, _class$t;
|
|
118
|
+
let ServiceColumns = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
120
119
|
module: "a-orm"
|
|
121
|
-
}), _dec$
|
|
120
|
+
}), _dec$t(_class$t = _dec2$t(_class$t = class ServiceColumns extends BeanBase {
|
|
122
121
|
constructor(...args) {
|
|
123
122
|
super(...args);
|
|
124
123
|
this._db = void 0;
|
|
@@ -169,7 +168,7 @@ let ServiceColumns = (_dec$r = Service(), _dec2$r = BeanInfo({
|
|
|
169
168
|
columnsClear(tableName) {
|
|
170
169
|
return this.scope.service.database.columnsClear(this.db.clientName, tableName);
|
|
171
170
|
}
|
|
172
|
-
}) || _class$
|
|
171
|
+
}) || _class$t) || _class$t);
|
|
173
172
|
|
|
174
173
|
const TransactionIsolationLevelsMap = {
|
|
175
174
|
DEFAULT: undefined,
|
|
@@ -182,10 +181,10 @@ const TransactionIsolationLevelsMap = {
|
|
|
182
181
|
|
|
183
182
|
// export type TransactionPropagation=''
|
|
184
183
|
|
|
185
|
-
var _dec$
|
|
186
|
-
let ServiceDatabase = (_dec$
|
|
184
|
+
var _dec$s, _dec2$s, _class$s;
|
|
185
|
+
let ServiceDatabase = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
187
186
|
module: "a-orm"
|
|
188
|
-
}), _dec$
|
|
187
|
+
}), _dec$s(_class$s = _dec2$s(_class$s = class ServiceDatabase extends BeanBase {
|
|
189
188
|
getDialect(client) {
|
|
190
189
|
if (!client) throw new Error('database dialect not specified');
|
|
191
190
|
const beanFullName = this.scope.config.dialects[client];
|
|
@@ -271,12 +270,12 @@ let ServiceDatabase = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
|
271
270
|
});
|
|
272
271
|
this.__columnsClearRaw(clientName);
|
|
273
272
|
}
|
|
274
|
-
}) || _class$
|
|
273
|
+
}) || _class$s) || _class$s);
|
|
275
274
|
|
|
276
|
-
var _dec$
|
|
277
|
-
let ServiceTransactionConsistency = (_dec$
|
|
275
|
+
var _dec$r, _dec2$r, _class$r;
|
|
276
|
+
let ServiceTransactionConsistency = (_dec$r = Service(), _dec2$r = BeanInfo({
|
|
278
277
|
module: "a-orm"
|
|
279
|
-
}), _dec$
|
|
278
|
+
}), _dec$r(_class$r = _dec2$r(_class$r = class ServiceTransactionConsistency extends BeanBase {
|
|
280
279
|
constructor(...args) {
|
|
281
280
|
super(...args);
|
|
282
281
|
this._commitCallbacks = [];
|
|
@@ -304,12 +303,12 @@ let ServiceTransactionConsistency = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
|
304
303
|
}
|
|
305
304
|
this._commitCallbacks = [];
|
|
306
305
|
}
|
|
307
|
-
}) || _class$
|
|
306
|
+
}) || _class$r) || _class$r);
|
|
308
307
|
|
|
309
|
-
var _dec$
|
|
310
|
-
let ServiceTransactionFiber = (_dec$
|
|
308
|
+
var _dec$q, _dec2$q, _class$q;
|
|
309
|
+
let ServiceTransactionFiber = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
311
310
|
module: "a-orm"
|
|
312
|
-
}), _dec$
|
|
311
|
+
}), _dec$q(_class$q = _dec2$q(_class$q = class ServiceTransactionFiber extends BeanBase {
|
|
313
312
|
constructor(...args) {
|
|
314
313
|
super(...args);
|
|
315
314
|
this._connection = void 0;
|
|
@@ -338,12 +337,12 @@ let ServiceTransactionFiber = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
338
337
|
await this._transactionConsistency.compensateDone();
|
|
339
338
|
this._connection = undefined;
|
|
340
339
|
}
|
|
341
|
-
}) || _class$
|
|
340
|
+
}) || _class$q) || _class$q);
|
|
342
341
|
|
|
343
|
-
var _dec$
|
|
344
|
-
let ServiceTransactionState = (_dec$
|
|
342
|
+
var _dec$p, _dec2$p, _class$p;
|
|
343
|
+
let ServiceTransactionState = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
345
344
|
module: "a-orm"
|
|
346
|
-
}), _dec$
|
|
345
|
+
}), _dec$p(_class$p = _dec2$p(_class$p = class ServiceTransactionState extends BeanBase {
|
|
347
346
|
constructor(...args) {
|
|
348
347
|
super(...args);
|
|
349
348
|
this._fibers = {};
|
|
@@ -365,12 +364,12 @@ let ServiceTransactionState = (_dec$n = Service(), _dec2$n = BeanInfo({
|
|
|
365
364
|
const selector = this.serviceDatabase.prepareClientNameSelector(dbInfo);
|
|
366
365
|
delete this._fibers[selector];
|
|
367
366
|
}
|
|
368
|
-
}) || _class$
|
|
367
|
+
}) || _class$p) || _class$p);
|
|
369
368
|
|
|
370
|
-
var _dec$
|
|
371
|
-
let ServiceTransactionAsyncLocalStorage = (_dec$
|
|
369
|
+
var _dec$o, _dec2$o, _class$o;
|
|
370
|
+
let ServiceTransactionAsyncLocalStorage = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
372
371
|
module: "a-orm"
|
|
373
|
-
}), _dec$
|
|
372
|
+
}), _dec$o(_class$o = _dec2$o(_class$o = class ServiceTransactionAsyncLocalStorage extends BeanBase {
|
|
374
373
|
constructor(...args) {
|
|
375
374
|
super(...args);
|
|
376
375
|
this.transactionStorage = void 0;
|
|
@@ -391,12 +390,12 @@ let ServiceTransactionAsyncLocalStorage = (_dec$m = Service(), _dec2$m = BeanInf
|
|
|
391
390
|
return fn();
|
|
392
391
|
});
|
|
393
392
|
}
|
|
394
|
-
}) || _class$
|
|
393
|
+
}) || _class$o) || _class$o);
|
|
395
394
|
|
|
396
|
-
var _dec$
|
|
397
|
-
let ServiceTransaction = (_dec$
|
|
395
|
+
var _dec$n, _dec2$n, _class$n;
|
|
396
|
+
let ServiceTransaction = (_dec$n = Service(), _dec2$n = BeanInfo({
|
|
398
397
|
module: "a-orm"
|
|
399
|
-
}), _dec$
|
|
398
|
+
}), _dec$n(_class$n = _dec2$n(_class$n = class ServiceTransaction extends BeanBase {
|
|
400
399
|
constructor(...args) {
|
|
401
400
|
super(...args);
|
|
402
401
|
this._db = void 0;
|
|
@@ -517,7 +516,7 @@ let ServiceTransaction = (_dec$l = Service(), _dec2$l = BeanInfo({
|
|
|
517
516
|
}
|
|
518
517
|
return res;
|
|
519
518
|
}
|
|
520
|
-
}) || _class$
|
|
519
|
+
}) || _class$n) || _class$n);
|
|
521
520
|
function _translateTransactionOptions(options) {
|
|
522
521
|
if (!options) return undefined;
|
|
523
522
|
return {
|
|
@@ -526,10 +525,10 @@ function _translateTransactionOptions(options) {
|
|
|
526
525
|
};
|
|
527
526
|
}
|
|
528
527
|
|
|
529
|
-
var _dec$
|
|
530
|
-
let ServiceDb = (_dec$
|
|
528
|
+
var _dec$m, _dec2$m, _class$m;
|
|
529
|
+
let ServiceDb = (_dec$m = Service(), _dec2$m = BeanInfo({
|
|
531
530
|
module: "a-orm"
|
|
532
|
-
}), _dec$
|
|
531
|
+
}), _dec$m(_class$m = _dec2$m(_class$m = class ServiceDb extends BeanBase {
|
|
533
532
|
constructor(...args) {
|
|
534
533
|
super(...args);
|
|
535
534
|
this._client = void 0;
|
|
@@ -584,12 +583,12 @@ let ServiceDb = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
|
584
583
|
compensate(cb) {
|
|
585
584
|
return this.transaction.compensate(cb);
|
|
586
585
|
}
|
|
587
|
-
}) || _class$
|
|
586
|
+
}) || _class$m) || _class$m);
|
|
588
587
|
|
|
589
|
-
var _dec$
|
|
590
|
-
let ServiceDatabaseClient = (_dec$
|
|
588
|
+
var _dec$l, _dec2$l, _class$l;
|
|
589
|
+
let ServiceDatabaseClient = (_dec$l = Service(), _dec2$l = BeanInfo({
|
|
591
590
|
module: "a-orm"
|
|
592
|
-
}), _dec$
|
|
591
|
+
}), _dec$l(_class$l = _dec2$l(_class$l = class ServiceDatabaseClient extends BeanBase {
|
|
593
592
|
constructor(...args) {
|
|
594
593
|
super(...args);
|
|
595
594
|
this.level = void 0;
|
|
@@ -695,12 +694,12 @@ let ServiceDatabaseClient = (_dec$j = Service(), _dec2$j = BeanInfo({
|
|
|
695
694
|
// reload
|
|
696
695
|
await this.reload(config);
|
|
697
696
|
}
|
|
698
|
-
}) || _class$
|
|
697
|
+
}) || _class$l) || _class$l);
|
|
699
698
|
|
|
700
|
-
var _dec$
|
|
701
|
-
let BeanDatabase = (_dec$
|
|
699
|
+
var _dec$k, _dec2$k, _class$k;
|
|
700
|
+
let BeanDatabase = (_dec$k = Bean(), _dec2$k = BeanInfo({
|
|
702
701
|
module: "a-orm"
|
|
703
|
-
}), _dec$
|
|
702
|
+
}), _dec$k(_class$k = _dec2$k(_class$k = class BeanDatabase extends BeanBase {
|
|
704
703
|
get current() {
|
|
705
704
|
return this.bean._getBean(ServiceDatabaseAsyncLocalStorage).current;
|
|
706
705
|
}
|
|
@@ -730,12 +729,12 @@ let BeanDatabase = (_dec$i = Bean(), _dec2$i = BeanInfo({
|
|
|
730
729
|
return this.bean._getBean(ServiceTransactionAsyncLocalStorage).run(fn);
|
|
731
730
|
});
|
|
732
731
|
}
|
|
733
|
-
}) || _class$
|
|
732
|
+
}) || _class$k) || _class$k);
|
|
734
733
|
|
|
735
|
-
var _dec$
|
|
736
|
-
let BeanDatabaseDialectBase = (_dec$
|
|
734
|
+
var _dec$j, _dec2$j, _dec3$7, _class$j;
|
|
735
|
+
let BeanDatabaseDialectBase = (_dec$j = Bean(), _dec2$j = Virtual(), _dec3$7 = BeanInfo({
|
|
737
736
|
module: "a-orm"
|
|
738
|
-
}), _dec$
|
|
737
|
+
}), _dec$j(_class$j = _dec2$j(_class$j = _dec3$7(_class$j = class BeanDatabaseDialectBase extends BeanBase {
|
|
739
738
|
getConfigBase() {
|
|
740
739
|
return undefined;
|
|
741
740
|
}
|
|
@@ -795,7 +794,7 @@ let BeanDatabaseDialectBase = (_dec$h = Bean(), _dec2$h = Virtual(), _dec3$5 = B
|
|
|
795
794
|
_columnTypePrefixes(type, prefixes) {
|
|
796
795
|
return prefixes.some(prefix => type.includes(prefix));
|
|
797
796
|
}
|
|
798
|
-
}) || _class$
|
|
797
|
+
}) || _class$j) || _class$j) || _class$j);
|
|
799
798
|
|
|
800
799
|
const OpAggrs = ['count', 'sum', 'avg', 'max', 'min'];
|
|
801
800
|
const OpJoint = {
|
|
@@ -1161,8 +1160,6 @@ function _prepareClassEntity(classEntity) {
|
|
|
1161
1160
|
return isClass(classEntity) ? classEntity : cast(classEntity)();
|
|
1162
1161
|
}
|
|
1163
1162
|
|
|
1164
|
-
const SymbolKeyFieldsMore = Symbol('$fieldsMore');
|
|
1165
|
-
|
|
1166
1163
|
function _applyDecoratedDescriptor(i, e, r, n, l) {
|
|
1167
1164
|
var a = {};
|
|
1168
1165
|
return Object.keys(n).forEach(function (i) {
|
|
@@ -1180,6 +1177,57 @@ function _initializerDefineProperty(e, i, r, l) {
|
|
|
1180
1177
|
});
|
|
1181
1178
|
}
|
|
1182
1179
|
|
|
1180
|
+
var _dec$i, _dec2$i, _dec3$6, _dec4$4, _dec5$1, _dec6$1, _class$i, _descriptor$4, _descriptor2$2, _descriptor3$1;
|
|
1181
|
+
let DtoQueryBase = (_dec$i = Api.field(v.optional(), v.array(String, {
|
|
1182
|
+
separator: ','
|
|
1183
|
+
})), _dec2$i = Reflect.metadata("design:type", Array), _dec3$6 = Api.field(v.optional(), z.object({}).passthrough()), _dec4$4 = Reflect.metadata("design:type", Object), _dec5$1 = Api.field(v.optional(), z.union([z.string(), z.array(z.array(z.string()))])), _dec6$1 = Reflect.metadata("design:type", Object), _class$i = class DtoQueryBase {
|
|
1184
|
+
constructor() {
|
|
1185
|
+
_initializerDefineProperty(this, "columns", _descriptor$4, this);
|
|
1186
|
+
_initializerDefineProperty(this, "where", _descriptor2$2, this);
|
|
1187
|
+
_initializerDefineProperty(this, "orders", _descriptor3$1, this);
|
|
1188
|
+
}
|
|
1189
|
+
}, _descriptor$4 = _applyDecoratedDescriptor(_class$i.prototype, "columns", [_dec$i, _dec2$i], {
|
|
1190
|
+
configurable: true,
|
|
1191
|
+
enumerable: true,
|
|
1192
|
+
writable: true,
|
|
1193
|
+
initializer: null
|
|
1194
|
+
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$i.prototype, "where", [_dec3$6, _dec4$4], {
|
|
1195
|
+
configurable: true,
|
|
1196
|
+
enumerable: true,
|
|
1197
|
+
writable: true,
|
|
1198
|
+
initializer: null
|
|
1199
|
+
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$i.prototype, "orders", [_dec5$1, _dec6$1], {
|
|
1200
|
+
configurable: true,
|
|
1201
|
+
enumerable: true,
|
|
1202
|
+
writable: true,
|
|
1203
|
+
initializer: null
|
|
1204
|
+
}), _class$i);
|
|
1205
|
+
|
|
1206
|
+
var _dec$h, _dec2$h, _dec3$5, _dec4$3, _class$h, _descriptor$3, _descriptor2$1;
|
|
1207
|
+
const app = useApp();
|
|
1208
|
+
const ormConfig = app.util.getModuleConfigRaw('a-orm');
|
|
1209
|
+
const pageSizeDefault = ormConfig?.rest?.query?.pageSize?.default ?? 20;
|
|
1210
|
+
const pageSizeMax = ormConfig?.rest?.query?.pageSize?.max ?? 100;
|
|
1211
|
+
let DtoQueryPageBase = (_dec$h = Api.field(z.number().min(1).default(1)), _dec2$h = Reflect.metadata("design:type", Number), _dec3$5 = Api.field(z.number().min(1).max(pageSizeMax).default(pageSizeDefault)), _dec4$3 = Reflect.metadata("design:type", Number), _class$h = class DtoQueryPageBase extends DtoQueryBase {
|
|
1212
|
+
constructor(...args) {
|
|
1213
|
+
super(...args);
|
|
1214
|
+
_initializerDefineProperty(this, "pageNo", _descriptor$3, this);
|
|
1215
|
+
_initializerDefineProperty(this, "pageSize", _descriptor2$1, this);
|
|
1216
|
+
}
|
|
1217
|
+
}, _descriptor$3 = _applyDecoratedDescriptor(_class$h.prototype, "pageNo", [_dec$h, _dec2$h], {
|
|
1218
|
+
configurable: true,
|
|
1219
|
+
enumerable: true,
|
|
1220
|
+
writable: true,
|
|
1221
|
+
initializer: null
|
|
1222
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$h.prototype, "pageSize", [_dec3$5, _dec4$3], {
|
|
1223
|
+
configurable: true,
|
|
1224
|
+
enumerable: true,
|
|
1225
|
+
writable: true,
|
|
1226
|
+
initializer: null
|
|
1227
|
+
}), _class$h);
|
|
1228
|
+
|
|
1229
|
+
const SymbolKeyFieldsMore = Symbol('$fieldsMore');
|
|
1230
|
+
|
|
1183
1231
|
class EntityBaseEmpty {}
|
|
1184
1232
|
|
|
1185
1233
|
var _dec$g, _dec2$g, _dec3$4, _dec4$2, _dec5, _dec6, _dec7, _dec8, _class$g, _descriptor$2, _descriptor2, _descriptor3, _descriptor4;
|
|
@@ -2912,6 +2960,29 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
2912
2960
|
const items = await this.__select_cache(table, params, options);
|
|
2913
2961
|
return this.convertItemsToBigNumber(items);
|
|
2914
2962
|
}
|
|
2963
|
+
async selectAndCount(params, options, modelJoins) {
|
|
2964
|
+
// count
|
|
2965
|
+
const paramsCount = Object.assign({}, params, {
|
|
2966
|
+
columns: undefined,
|
|
2967
|
+
orders: undefined,
|
|
2968
|
+
limit: undefined,
|
|
2969
|
+
offset: undefined
|
|
2970
|
+
});
|
|
2971
|
+
let count = await this.count(paramsCount, options, modelJoins);
|
|
2972
|
+
if (!count) count = BigNumber$1(0);
|
|
2973
|
+
// list
|
|
2974
|
+
let list;
|
|
2975
|
+
if (count.eq(0)) {
|
|
2976
|
+
list = [];
|
|
2977
|
+
} else {
|
|
2978
|
+
list = await this.select(params, options, modelJoins);
|
|
2979
|
+
}
|
|
2980
|
+
// ok
|
|
2981
|
+
return {
|
|
2982
|
+
list,
|
|
2983
|
+
total: count
|
|
2984
|
+
};
|
|
2985
|
+
}
|
|
2915
2986
|
async select(params, options, _modelJoins) {
|
|
2916
2987
|
const items = await this.__select_raw(undefined, params, options);
|
|
2917
2988
|
return await this.relations.handleRelationsMany(items, params, options);
|
|
@@ -3399,6 +3470,14 @@ let ScheduleSoftDeletionPrune = (_dec$1 = Schedule({
|
|
|
3399
3470
|
|
|
3400
3471
|
function config(_app) {
|
|
3401
3472
|
return {
|
|
3473
|
+
rest: {
|
|
3474
|
+
query: {
|
|
3475
|
+
pageSize: {
|
|
3476
|
+
default: 20,
|
|
3477
|
+
max: 100
|
|
3478
|
+
}
|
|
3479
|
+
}
|
|
3480
|
+
},
|
|
3402
3481
|
table: {
|
|
3403
3482
|
identityType: 'string'
|
|
3404
3483
|
},
|
|
@@ -3922,6 +4001,22 @@ function DtoCreate(modelLike, params) {
|
|
|
3922
4001
|
return _DtoMutate_raw(modelLike, params, 'create', ['id', 'iid', 'deleted', 'createdAt', 'updatedAt'], true);
|
|
3923
4002
|
}
|
|
3924
4003
|
|
|
4004
|
+
function DtoQuery(classRef, keys) {
|
|
4005
|
+
return $Class.mixin(DtoQueryBase, $Class.partial($Class.pick(classRef, keys)));
|
|
4006
|
+
}
|
|
4007
|
+
|
|
4008
|
+
function DtoQueryPage(classRef, keys) {
|
|
4009
|
+
return $Class.mixin(DtoQueryPageBase, $Class.partial($Class.pick(classRef, keys)));
|
|
4010
|
+
}
|
|
4011
|
+
|
|
4012
|
+
function DtoSelectAndCount(modelLike, params) {
|
|
4013
|
+
class TargetClass {}
|
|
4014
|
+
const DtoGetResult = DtoGet(modelLike, params);
|
|
4015
|
+
Api.field(v.array(DtoGetResult))(TargetClass.prototype, 'list');
|
|
4016
|
+
Api.field(v.bigNumber())(TargetClass.prototype, 'total');
|
|
4017
|
+
return TargetClass;
|
|
4018
|
+
}
|
|
4019
|
+
|
|
3925
4020
|
function DtoUpdate(modelLike, params) {
|
|
3926
4021
|
return _DtoMutate_raw(modelLike, params, 'update', ['id', 'iid', 'deleted', 'createdAt', 'updatedAt'], true);
|
|
3927
4022
|
}
|
|
@@ -3933,7 +4028,10 @@ const $Dto = {
|
|
|
3933
4028
|
update: DtoUpdate,
|
|
3934
4029
|
get: DtoGet,
|
|
3935
4030
|
aggregate: DtoAggregate,
|
|
3936
|
-
group: DtoGroup
|
|
4031
|
+
group: DtoGroup,
|
|
4032
|
+
query: DtoQuery,
|
|
4033
|
+
queryPage: DtoQueryPage,
|
|
4034
|
+
selectAndCount: DtoSelectAndCount
|
|
3937
4035
|
};
|
|
3938
4036
|
|
|
3939
4037
|
// const __tableNames = new Set();
|
|
@@ -4143,4 +4241,4 @@ const $relationMutate = {
|
|
|
4143
4241
|
belongsToMany
|
|
4144
4242
|
};
|
|
4145
4243
|
|
|
4146
|
-
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, BroadcastDatabaseClientReload, Database, DatabaseDialect, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, Errors, EventClientNameReal, EventColumnsClear, EventDatabaseClientReload, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, ScheduleSoftDeletionPrune, ScopeModuleAOrm, ServiceCacheEntity, ServiceCacheQuery, ServiceColumns, ServiceColumnsCache, ServiceDatabase, ServiceDatabaseAsyncLocalStorage, ServiceDatabaseClient, ServiceDb, ServiceEntityResolver, ServiceModelResolver, ServiceRelations, ServiceTransaction, ServiceTransactionAsyncLocalStorage, ServiceTransactionConsistency, ServiceTransactionFiber, ServiceTransactionState, SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyFieldsMore, SymbolKeyModelOptions, TransactionIsolationLevelsMap, buildWhere, config, configDefault, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isAggrColumn, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
|
4244
|
+
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, BroadcastDatabaseClientReload, Database, DatabaseDialect, DtoQueryBase, DtoQueryPageBase, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, Errors, EventClientNameReal, EventColumnsClear, EventDatabaseClientReload, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, ScheduleSoftDeletionPrune, ScopeModuleAOrm, ServiceCacheEntity, ServiceCacheQuery, ServiceColumns, ServiceColumnsCache, ServiceDatabase, ServiceDatabaseAsyncLocalStorage, ServiceDatabaseClient, ServiceDb, ServiceEntityResolver, ServiceModelResolver, ServiceRelations, ServiceTransaction, ServiceTransactionAsyncLocalStorage, ServiceTransactionConsistency, ServiceTransactionFiber, ServiceTransactionState, SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyFieldsMore, SymbolKeyModelOptions, TransactionIsolationLevelsMap, buildWhere, config, configDefault, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isAggrColumn, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
package/dist/lib/dto/dto.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { DtoAggregate } from './dtoAggregate.ts';
|
|
|
2
2
|
import { DtoCreate } from './dtoCreate.ts';
|
|
3
3
|
import { DtoGet } from './dtoGet.ts';
|
|
4
4
|
import { DtoGroup } from './dtoGroup.ts';
|
|
5
|
+
import { DtoQuery } from './dtoQuery.ts';
|
|
6
|
+
import { DtoQueryPage } from './dtoQueryPage.ts';
|
|
7
|
+
import { DtoSelectAndCount } from './dtoSelectAndCount.ts';
|
|
5
8
|
import { DtoUpdate } from './dtoUpdate.ts';
|
|
6
9
|
export declare const $Dto: {
|
|
7
10
|
create: typeof DtoCreate;
|
|
@@ -9,4 +12,7 @@ export declare const $Dto: {
|
|
|
9
12
|
get: typeof DtoGet;
|
|
10
13
|
aggregate: typeof DtoAggregate;
|
|
11
14
|
group: typeof DtoGroup;
|
|
15
|
+
query: typeof DtoQuery;
|
|
16
|
+
queryPage: typeof DtoQueryPage;
|
|
17
|
+
selectAndCount: typeof DtoSelectAndCount;
|
|
12
18
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Constructable } from 'vona';
|
|
2
|
+
import { DtoQueryBase } from '../../types/dto/dtoQueryBase.ts';
|
|
3
|
+
export declare function DtoQuery<T, K extends keyof T>(classRef: Constructable<T>, keys: K[]): new (...args: any[]) => ((k: DtoQueryBase) => void) | (Partial<Pick<T, K>> extends infer T_1 ? T_1 extends Partial<Pick<T, K>> ? T_1 extends any ? (k: T_1) => void : never : never : never) extends (k: infer I) => void ? I : never;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { Constructable } from 'vona';
|
|
2
|
+
import { DtoQueryPageBase } from '../../types/dto/dtoQueryPageBase.ts';
|
|
3
|
+
export declare function DtoQueryPage<T, KEYS extends Array<keyof T>>(classRef: Constructable<T>, keys: KEYS): new (...args: any[]) => ((k: DtoQueryPageBase) => void) | (Partial<Pick<T, KEYS[number]>> extends infer T_1 ? T_1 extends Partial<Pick<T, KEYS[number]>> ? T_1 extends any ? (k: T_1) => void : never : never : never) extends (k: infer I) => void ? I : never;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Constructable } from 'vona';
|
|
2
|
+
import type { BeanModelMeta } from '../../bean/bean.model/bean.model_meta.ts';
|
|
3
|
+
import type { IDtoGetParams } from '../../types/dto/dtoGet.ts';
|
|
4
|
+
import type { TypeDtoSelectAndCountResult } from '../../types/dto/dtoSelectAndCount.ts';
|
|
5
|
+
import type { IModelClassRecord } from '../../types/onion/model.ts';
|
|
6
|
+
export declare function DtoSelectAndCount<ModelLike extends BeanModelMeta | (keyof IModelClassRecord), T extends IDtoGetParams<ModelLike> | undefined = undefined>(modelLike: ModelLike extends BeanModelMeta ? ((() => Constructable<ModelLike>) | Constructable<ModelLike>) : ModelLike, params?: T): Constructable<TypeDtoSelectAndCountResult<ModelLike, T>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { BeanModelCache } from '../bean/bean.model/bean.model_cache.ts';
|
|
2
3
|
import type { ITableRecord } from '../types/onion/table.ts';
|
|
3
|
-
import type { TableIdentity } from '../types/tableIdentity.ts';
|
|
4
4
|
import { ModelCacheBase } from '../lib/modelCacheBase.ts';
|
|
5
5
|
export declare class ServiceCacheEntity extends ModelCacheBase {
|
|
6
6
|
protected __init__(model: BeanModelCache): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { BeanModelCache } from '../bean/bean.model/bean.model_cache.ts';
|
|
2
3
|
import type { IModelMethodOptions, IModelRelationIncludeWrapper } from '../types/model.ts';
|
|
3
|
-
import type { TableIdentity } from '../types/tableIdentity.ts';
|
|
4
4
|
import { BeanBase } from 'vona';
|
|
5
5
|
export declare class ServiceRelations extends BeanBase {
|
|
6
6
|
protected _model: BeanModelCache;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { OmitNever, TypeOmitStringUnion } from 'vona';
|
|
2
3
|
import type { BeanModelMeta } from '../../bean/bean.model/bean.model_meta.ts';
|
|
3
4
|
import type { IModelRelationIncludeWrapper } from '../model.ts';
|
|
4
5
|
import type { TypeModelColumnsStrict } from '../modelWhere.ts';
|
|
5
6
|
import type { IDecoratorModelOptions, IModelClassRecord } from '../onion/model.ts';
|
|
6
7
|
import type { TypeModelOfModelLike, TypeSymbolKeyEntity, TypeUtilEntityOmit, TypeUtilEntityPartial, TypeUtilEntitySelector, TypeUtilGetColumnsFromRelationAndIncludeWrapper, TypeUtilGetModelOptions, TypeUtilGetParamsColumns, TypeUtilGetParamsInlcude, TypeUtilGetParamsWith, TypeUtilGetRelationEntity, TypeUtilGetRelationModel, TypeUtilGetRelationOptions, TypeUtilGetRelationOptionsAutoload, TypeUtilGetRelationType, TypeUtilPrepareColumns } from '../relations.ts';
|
|
7
|
-
import type { TableIdentity } from '../tableIdentity.ts';
|
|
8
8
|
export type TypeDtoMutateType = 'create' | 'update' | 'mutate';
|
|
9
9
|
export type IDtoMutateParams<ModelLike extends BeanModelMeta | (keyof IModelClassRecord)> = IBuildDtoMutateParams<TypeModelOfModelLike<ModelLike>[TypeSymbolKeyEntity], TypeModelOfModelLike<ModelLike>>;
|
|
10
10
|
export interface IBuildDtoMutateParams<TRecord, Model extends BeanModelMeta> extends IModelRelationIncludeWrapper<Model>, IBuildDtoMutateParamsBasic<TRecord> {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type BigNumber from 'bignumber.js';
|
|
2
|
+
import type { BeanModelMeta } from '../../bean/bean.model/bean.model_meta.ts';
|
|
3
|
+
import type { IModelClassRecord } from '../onion/model.ts';
|
|
4
|
+
import type { TypeDtoGetResult } from './dtoGet.ts';
|
|
5
|
+
export interface TypeDtoSelectAndCountResult<ModelLike extends BeanModelMeta | (keyof IModelClassRecord), TOptionsRelation> {
|
|
6
|
+
list: TypeDtoGetResult<ModelLike, TOptionsRelation>[];
|
|
7
|
+
total: BigNumber;
|
|
8
|
+
}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/model.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
2
|
import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
|
|
3
3
|
import type { TypeModelColumn, TypeModelColumns, TypeModelColumnsPatch, TypeModelWhere } from './modelWhere.ts';
|
|
4
|
-
import type { TypeModelParamsInclude, TypeModelsClassLikeGeneral } from './relations.ts';
|
|
4
|
+
import type { TypeModelOfModelLike, TypeModelParamsInclude, TypeModelsClassLikeGeneral, TypeSymbolKeyEntity } from './relations.ts';
|
|
5
5
|
import type { TypeEntityTableColumnNamesOfGeneral, TypeEntityTableColumnsOfGeneral } from './relationsColumns.ts';
|
|
6
6
|
import type { TypeModelMutateParamsInclude } from './relationsMutate.ts';
|
|
7
7
|
import type { TypeEntityTableNamesOfGeneral } from './relationsTables.ts';
|
|
@@ -29,6 +29,7 @@ export interface IBuildModelSelectParamsBasic<TRecord, COLUMNS extends TypeModel
|
|
|
29
29
|
limit?: number;
|
|
30
30
|
offset?: number;
|
|
31
31
|
}
|
|
32
|
+
export type IQueryParams<Model extends BeanModelMeta = BeanModelMeta, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined> = IModelSelectParams<TypeModelOfModelLike<Model>[TypeSymbolKeyEntity], Model, ModelJoins>;
|
|
32
33
|
export type IModelSelectParams<TRecord, Model extends BeanModelMeta = BeanModelMeta, ModelJoins extends TypeModelsClassLikeGeneral | undefined = undefined> = IBuildModelSelectParams<TRecord, Model, TypeEntityTableNamesOfGeneral<ModelJoins, Model>, TypeEntityTableColumnNamesOfGeneral<ModelJoins, Model>, TypeEntityTableColumnsOfGeneral<ModelJoins, Model>>;
|
|
33
34
|
export interface IBuildModelCountParams<TRecord, _Model extends BeanModelMeta | undefined = undefined, TableNames = undefined, ColumnNames = keyof TRecord, Columns extends {} | undefined = undefined> {
|
|
34
35
|
distinct?: boolean | (keyof TRecord) | (keyof TRecord)[];
|
|
@@ -57,7 +57,7 @@ export declare const Op: {
|
|
|
57
57
|
};
|
|
58
58
|
export declare const OpJointValues: ("_and_" | "_or_" | "_not_" | "_exists_" | "_notExists_")[];
|
|
59
59
|
export declare const OpNormalValues: ("_eq_" | "_notEq_" | "_gt_" | "_gte_" | "_lt_" | "_lte_" | "_in_" | "_notIn_" | "_is_" | "_isNot_" | "_between_" | "_notBetween_" | "_startsWith_" | "_endsWith_" | "_includes_" | "_startsWithI_" | "_endsWithI_" | "_includesI_" | "_ref_")[];
|
|
60
|
-
export declare const OpValues: ("
|
|
60
|
+
export declare const OpValues: ("_eq_" | "_notEq_" | "_gt_" | "_gte_" | "_lt_" | "_lte_" | "_in_" | "_notIn_" | "_is_" | "_isNot_" | "_between_" | "_notBetween_" | "_startsWith_" | "_endsWith_" | "_includes_" | "_startsWithI_" | "_endsWithI_" | "_includesI_" | "_ref_" | "_and_" | "_or_" | "_not_" | "_exists_" | "_notExists_" | "_skip_")[];
|
|
61
61
|
export type TypeOpsJointPostfix<Op> = {
|
|
62
62
|
[KEY in keyof Op]: Op[KEY] | (KEY extends string ? `_${KEY}_${number}` : never);
|
|
63
63
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type BigNumber from 'bignumber.js';
|
|
1
2
|
import type { Constructable, OmitNever } from 'vona';
|
|
2
3
|
import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
|
|
3
4
|
import type { TypeDepthPrev, TypeDepthPrevMax } from './depth.ts';
|
|
@@ -94,6 +95,10 @@ export type TypeUtilEntityPartial<TRecord, TColumns> = [
|
|
|
94
95
|
TColumns
|
|
95
96
|
] extends [keyof TRecord] ? Partial<Pick<TRecord, TColumns>> & Omit<TRecord, TColumns> : TRecord;
|
|
96
97
|
export type TypeUtilGetColumnsFromRelationAndIncludeWrapper<Relation, IncludeWrapper extends {} | undefined | unknown> = TypeUtilGetParamsColumns<IncludeWrapper> extends string | string[] ? TypeUtilGetParamsColumns<IncludeWrapper> : TypeUtilGetRelationOptionsColumns<Relation>;
|
|
98
|
+
export interface TypeModelSelectAndCount<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Aggrs = undefined, Groups = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> {
|
|
99
|
+
list: TypeModelRelationResult<TRecord, TModel, TOptionsRelation, TColumns, Aggrs, Groups, Depth>[];
|
|
100
|
+
total: BigNumber;
|
|
101
|
+
}
|
|
97
102
|
export type TypeModelRelationResult<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Aggrs = undefined, Groups = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> = Groups extends string | string[] ? TypeModelGroupRelationResultGroups<TRecord, Aggrs, Groups, TColumns> : Aggrs extends {} ? TypeModelAggrRelationResultAggrs<Aggrs> : TypeModelRelationResult_Normal<TRecord, TModel, TOptionsRelation, TColumns, Depth>;
|
|
98
103
|
export type TypeModelRelationResult_Normal<TRecord, TModel extends BeanModelMeta | undefined, TOptionsRelation, TColumns = undefined, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> = TypeUtilEntitySelector<TRecord, TypeUtilPrepareColumns<TColumns extends string | string[] ? TColumns : TypeUtilGetParamsColumns<TOptionsRelation>>> & (TModel extends BeanModelMeta ? (OmitNever<TypeModelRelationResultMergeInclude<TypeUtilGetModelOptions<TModel>, TypeUtilGetParamsInlcude<TOptionsRelation>, Depth>> & OmitNever<TypeModelRelationResultMergeWith<TypeUtilGetParamsWith<TOptionsRelation>, Depth>>) : {});
|
|
99
104
|
export type TypeModelRelationResultMergeInclude<TModelOptions extends IDecoratorModelOptions, TInclude extends {} | undefined | unknown, Depth extends TypeDepthPrev[number] = TypeDepthPrevMax> = {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { TableIdentity } from 'table-identity';
|
|
1
2
|
import type { OmitNever } from 'vona';
|
|
2
3
|
import type { BeanModelMeta } from '../bean/bean.model/bean.model_meta.ts';
|
|
3
4
|
import type { IDecoratorModelOptions } from './onion/model.ts';
|
|
4
5
|
import type { TypeUtilGetModelOptions, TypeUtilGetParamsInlcude, TypeUtilGetParamsWith, TypeUtilGetRelationEntity, TypeUtilGetRelationModel, TypeUtilGetRelationOptions, TypeUtilGetRelationOptionsAutoload, TypeUtilGetRelationType } from './relations.ts';
|
|
5
6
|
import type { IModelRelationOptionsMetaWrapper } from './relationsDef.ts';
|
|
6
|
-
import type { TableIdentity } from './tableIdentity.ts';
|
|
7
7
|
export type TypeModelMutateParamsInclude<MODEL extends BeanModelMeta | undefined> = TypeModelMutateParamsIncludeByModelOptions<TypeUtilGetModelOptions<MODEL>>;
|
|
8
8
|
export type TypeModelMutateParamsIncludeByModelOptions<ModelOptions extends IDecoratorModelOptions | undefined> = ModelOptions extends IDecoratorModelOptions ? {
|
|
9
9
|
[relationName in keyof ModelOptions['relations']]?: TypeModelMutateParamsRelationOptions<ModelOptions['relations'][relationName]>;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from 'table-identity';
|