vona-module-a-orm 5.0.86 → 5.0.87
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/dist/.metadata/index.d.ts +17 -0
- package/dist/bean/bean.model/bean.model_cache.d.ts +2 -6
- package/dist/bean/hmr.model.d.ts +6 -0
- package/dist/index.js +216 -172
- package/dist/lib/const.d.ts +9 -0
- package/dist/lib/index.d.ts +1 -0
- package/dist/lib/modelCacheBase.d.ts +2 -2
- package/dist/service/databaseClient_.d.ts +1 -1
- package/dist/types/database.d.ts +1 -1
- package/package.json +2 -2
|
@@ -191,6 +191,23 @@ declare module 'vona-module-a-orm' {
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
/** schedule: end */
|
|
194
|
+
/** hmr: begin */
|
|
195
|
+
export * from '../bean/hmr.model.ts';
|
|
196
|
+
import 'vona';
|
|
197
|
+
declare module 'vona' {
|
|
198
|
+
interface IHmrRecord {
|
|
199
|
+
'a-orm:model': never;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
declare module 'vona-module-a-orm' {
|
|
203
|
+
interface HmrModel {
|
|
204
|
+
}
|
|
205
|
+
interface HmrModel {
|
|
206
|
+
get $beanFullName(): 'a-orm.hmr.model';
|
|
207
|
+
get $onionName(): 'a-orm:model';
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
/** hmr: end */
|
|
194
211
|
/** config: begin */
|
|
195
212
|
export * from '../config/config.ts';
|
|
196
213
|
import type { config } from '../config/config.ts';
|
|
@@ -1,17 +1,16 @@
|
|
|
1
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,
|
|
3
|
+
import type { IDatabaseClientRecord, IModelDeleteOptions, IModelGetOptions, IModelInsertOptions, IModelMethodOptions, IModelMethodOptionsGeneral, IModelMutateOptions, IModelSelectAggrParams, IModelSelectCountParams, IModelSelectGroupParams, IModelSelectParams, IModelUpdateOptions, ITableRecord, TypeModelAggrRelationResult, TypeModelGroupRelationResult, TypeModelsClassLikeGeneral, TypeModelWhere } from '../../types/index.ts';
|
|
4
4
|
import { ServiceCacheEntity } from '../../service/cacheEntity_.ts';
|
|
5
5
|
import { ServiceCacheQuery } from '../../service/cacheQuery_.ts';
|
|
6
6
|
import { ServiceRelations } from '../../service/relations_.ts';
|
|
7
7
|
import { BeanModelCrud } from './bean.model_crud.ts';
|
|
8
|
-
declare const SymbolModelsClearAll: unique symbol;
|
|
9
8
|
export declare class BeanModelCache<TRecord extends {} = {}> extends BeanModelCrud<TRecord> {
|
|
10
9
|
cacheQuery: ServiceCacheQuery;
|
|
11
10
|
cacheEntity: ServiceCacheEntity;
|
|
12
11
|
protected relations: ServiceRelations;
|
|
13
|
-
protected [SymbolModelsClearAll]: Record<keyof IModelRecord, TypeModelClassLikeGeneral[]>;
|
|
14
12
|
protected __init__(clientName?: keyof IDatabaseClientRecord | ServiceDb, table?: keyof ITableRecord): void;
|
|
13
|
+
protected __dispose__(): Promise<void>;
|
|
15
14
|
insert<T extends IModelInsertOptions<TRecord>>(data?: Partial<TRecord>, options?: T): Promise<TRecord>;
|
|
16
15
|
insertBulk<T extends IModelInsertOptions<TRecord>>(items: Partial<TRecord>[], options?: T): Promise<TRecord[]>;
|
|
17
16
|
__insertBulk_raw(table: keyof ITableRecord | undefined, items: Partial<TRecord>[], options?: IModelMutateOptions<TRecord>): Promise<TRecord[]>;
|
|
@@ -51,12 +50,9 @@ export declare class BeanModelCache<TRecord extends {} = {}> extends BeanModelCr
|
|
|
51
50
|
private _shardingCacheDoubleDelete;
|
|
52
51
|
private _cacheQueryClearModelsClear;
|
|
53
52
|
private _getModelsClear;
|
|
54
|
-
private _getModelsClearAll;
|
|
55
|
-
private _collectModelsClearAll;
|
|
56
53
|
protected _checkDisableCacheQueryByOptions(options?: IModelMethodOptionsGeneral): boolean;
|
|
57
54
|
protected _checkDisableCacheEntityByOptions(options?: IModelMethodOptionsGeneral): boolean;
|
|
58
55
|
private __checkIfOnlyKey;
|
|
59
56
|
private __checkCacheKeyValid;
|
|
60
57
|
protected __get__(prop: string): ((fieldValue?: any, options?: any) => Promise<Partial<TRecord> | undefined>) | ((fieldValue?: any, params?: any, options?: any, modelJoins?: any) => Promise<any[]>) | ((fieldValue: any, data: any, options?: any) => Promise<Partial<TRecord>>) | ((fieldValue: any, options?: any) => Promise<void>) | undefined;
|
|
61
58
|
}
|
|
62
|
-
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { IDecoratorBeanOptionsBase } from 'vona';
|
|
2
|
+
import type { IHmrReload } from 'vona-module-a-hmr';
|
|
3
|
+
import { BeanBase } from 'vona';
|
|
4
|
+
export declare class HmrModel extends BeanBase implements IHmrReload {
|
|
5
|
+
reload(_beanOptions: IDecoratorBeanOptionsBase): Promise<void>;
|
|
6
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { BeanInfo, BeanAopMethodBase, BeanBase, deepExtend, appResource, beanFullNameFromOnionName, Virtual, cast, useApp, BeanSimple, combineConfigDefault, BeanScopeBase, createBeanDecorator, PickClassInner, $Class } from 'vona';
|
|
2
|
+
import { BeanInfo, BeanAopMethodBase, BeanBase, deepExtend, appResource, beanFullNameFromOnionName, Virtual, cast, useApp, disposeInstance, BeanSimple, combineConfigDefault, BeanScopeBase, createBeanDecorator, PickClassInner, $Class } from 'vona';
|
|
3
3
|
import { AopMethod } from 'vona-module-a-aspect';
|
|
4
4
|
import { Service, Bean, Scope } from 'vona-module-a-bean';
|
|
5
5
|
import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
|
|
@@ -15,25 +15,26 @@ import { Broadcast, BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
|
15
15
|
import { Event, BeanEventBase } from 'vona-module-a-event';
|
|
16
16
|
import { Queue, BeanQueueBase } from 'vona-module-a-queue';
|
|
17
17
|
import { Schedule } from 'vona-module-a-schedule';
|
|
18
|
+
import { Hmr } from 'vona-module-a-hmr';
|
|
18
19
|
import { configAll, configRedis } from 'vona-module-a-summer';
|
|
19
20
|
import { ServiceDatabaseAsyncLocalStorage as ServiceDatabaseAsyncLocalStorage$1, ServiceTransactionConsistency as ServiceTransactionConsistency_ } from 'vona-module-a-orm';
|
|
20
21
|
import { mutate } from 'mutate-on-copy';
|
|
21
22
|
|
|
22
|
-
var _dec$
|
|
23
|
-
let AopMethodTransaction = (_dec$
|
|
23
|
+
var _dec$w, _dec2$w, _class$w;
|
|
24
|
+
let AopMethodTransaction = (_dec$w = AopMethod(), _dec2$w = BeanInfo({
|
|
24
25
|
module: "a-orm"
|
|
25
|
-
}), _dec$
|
|
26
|
+
}), _dec$w(_class$w = _dec2$w(_class$w = class AopMethodTransaction extends BeanAopMethodBase {
|
|
26
27
|
execute(options, _args, next, _receiver, _prop) {
|
|
27
28
|
return this.bean.database.current.transaction.begin(() => {
|
|
28
29
|
return next();
|
|
29
30
|
}, options);
|
|
30
31
|
}
|
|
31
|
-
}) || _class$
|
|
32
|
+
}) || _class$w) || _class$w);
|
|
32
33
|
|
|
33
|
-
var _dec$
|
|
34
|
-
let ServiceDatabaseAsyncLocalStorage = (_dec$
|
|
34
|
+
var _dec$v, _dec2$v, _class$v;
|
|
35
|
+
let ServiceDatabaseAsyncLocalStorage = (_dec$v = Service(), _dec2$v = BeanInfo({
|
|
35
36
|
module: "a-orm"
|
|
36
|
-
}), _dec$
|
|
37
|
+
}), _dec$v(_class$v = _dec2$v(_class$v = class ServiceDatabaseAsyncLocalStorage extends BeanBase {
|
|
37
38
|
constructor(...args) {
|
|
38
39
|
super(...args);
|
|
39
40
|
this.dbStorage = void 0;
|
|
@@ -52,14 +53,14 @@ let ServiceDatabaseAsyncLocalStorage = (_dec$u = Service(), _dec2$u = BeanInfo({
|
|
|
52
53
|
return fn();
|
|
53
54
|
});
|
|
54
55
|
}
|
|
55
|
-
}) || _class$
|
|
56
|
+
}) || _class$v) || _class$v);
|
|
56
57
|
|
|
57
|
-
var _dec$
|
|
58
|
+
var _dec$u, _dec2$u, _class$u;
|
|
58
59
|
const SymbolColumnsCache = Symbol('SymbolColumnsCache');
|
|
59
60
|
const SymbolColumnsDefaultCache = Symbol('SymbolColumnsDefaultCache');
|
|
60
|
-
let ServiceColumnsCache = (_dec$
|
|
61
|
+
let ServiceColumnsCache = (_dec$u = Service(), _dec2$u = BeanInfo({
|
|
61
62
|
module: "a-orm"
|
|
62
|
-
}), _dec$
|
|
63
|
+
}), _dec$u(_class$u = _dec2$u(_class$u = class ServiceColumnsCache extends BeanBase {
|
|
63
64
|
constructor(...args) {
|
|
64
65
|
super(...args);
|
|
65
66
|
this.clientName = void 0;
|
|
@@ -114,12 +115,12 @@ let ServiceColumnsCache = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
|
114
115
|
return exists;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
|
-
}) || _class$
|
|
118
|
+
}) || _class$u) || _class$u);
|
|
118
119
|
|
|
119
|
-
var _dec$
|
|
120
|
-
let ServiceColumns = (_dec$
|
|
120
|
+
var _dec$t, _dec2$t, _class$t;
|
|
121
|
+
let ServiceColumns = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
121
122
|
module: "a-orm"
|
|
122
|
-
}), _dec$
|
|
123
|
+
}), _dec$t(_class$t = _dec2$t(_class$t = class ServiceColumns extends BeanBase {
|
|
123
124
|
constructor(...args) {
|
|
124
125
|
super(...args);
|
|
125
126
|
this._db = void 0;
|
|
@@ -170,7 +171,7 @@ let ServiceColumns = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
|
170
171
|
columnsClear(tableName) {
|
|
171
172
|
return this.scope.service.database.columnsClear(this.db.clientName, tableName);
|
|
172
173
|
}
|
|
173
|
-
}) || _class$
|
|
174
|
+
}) || _class$t) || _class$t);
|
|
174
175
|
|
|
175
176
|
const TransactionIsolationLevelsMap = {
|
|
176
177
|
DEFAULT: undefined,
|
|
@@ -183,10 +184,10 @@ const TransactionIsolationLevelsMap = {
|
|
|
183
184
|
|
|
184
185
|
// export type TransactionPropagation=''
|
|
185
186
|
|
|
186
|
-
var _dec$
|
|
187
|
-
let ServiceDatabase = (_dec$
|
|
187
|
+
var _dec$s, _dec2$s, _class$s;
|
|
188
|
+
let ServiceDatabase = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
188
189
|
module: "a-orm"
|
|
189
|
-
}), _dec$
|
|
190
|
+
}), _dec$s(_class$s = _dec2$s(_class$s = class ServiceDatabase extends BeanBase {
|
|
190
191
|
get configDatabase() {
|
|
191
192
|
return this.app.config.database;
|
|
192
193
|
}
|
|
@@ -300,17 +301,17 @@ let ServiceDatabase = (_dec$r = Service(), _dec2$r = BeanInfo({
|
|
|
300
301
|
}
|
|
301
302
|
async disposeClients(clientName) {
|
|
302
303
|
clientName = this.prepareClientName(clientName);
|
|
303
|
-
await this.bean.mutate.
|
|
304
|
+
await this.bean.mutate.removeInstances(ServiceDatabaseClient, {
|
|
304
305
|
clientName
|
|
305
306
|
});
|
|
306
307
|
this.columnsClear(clientName);
|
|
307
308
|
}
|
|
308
|
-
}) || _class$
|
|
309
|
+
}) || _class$s) || _class$s);
|
|
309
310
|
|
|
310
|
-
var _dec$
|
|
311
|
-
let ServiceTransactionConsistency = (_dec$
|
|
311
|
+
var _dec$r, _dec2$r, _class$r;
|
|
312
|
+
let ServiceTransactionConsistency = (_dec$r = Service(), _dec2$r = BeanInfo({
|
|
312
313
|
module: "a-orm"
|
|
313
|
-
}), _dec$
|
|
314
|
+
}), _dec$r(_class$r = _dec2$r(_class$r = class ServiceTransactionConsistency extends BeanBase {
|
|
314
315
|
constructor(...args) {
|
|
315
316
|
super(...args);
|
|
316
317
|
this._commitCallbacks = [];
|
|
@@ -338,12 +339,12 @@ let ServiceTransactionConsistency = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
|
338
339
|
}
|
|
339
340
|
this._commitCallbacks = [];
|
|
340
341
|
}
|
|
341
|
-
}) || _class$
|
|
342
|
+
}) || _class$r) || _class$r);
|
|
342
343
|
|
|
343
|
-
var _dec$
|
|
344
|
-
let ServiceTransactionFiber = (_dec$
|
|
344
|
+
var _dec$q, _dec2$q, _class$q;
|
|
345
|
+
let ServiceTransactionFiber = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
345
346
|
module: "a-orm"
|
|
346
|
-
}), _dec$
|
|
347
|
+
}), _dec$q(_class$q = _dec2$q(_class$q = class ServiceTransactionFiber extends BeanBase {
|
|
347
348
|
constructor(...args) {
|
|
348
349
|
super(...args);
|
|
349
350
|
this._connection = void 0;
|
|
@@ -372,12 +373,12 @@ let ServiceTransactionFiber = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
|
372
373
|
await this._transactionConsistency.compensatesDone();
|
|
373
374
|
this._connection = undefined;
|
|
374
375
|
}
|
|
375
|
-
}) || _class$
|
|
376
|
+
}) || _class$q) || _class$q);
|
|
376
377
|
|
|
377
|
-
var _dec$
|
|
378
|
-
let ServiceTransactionState = (_dec$
|
|
378
|
+
var _dec$p, _dec2$p, _class$p;
|
|
379
|
+
let ServiceTransactionState = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
379
380
|
module: "a-orm"
|
|
380
|
-
}), _dec$
|
|
381
|
+
}), _dec$p(_class$p = _dec2$p(_class$p = class ServiceTransactionState extends BeanBase {
|
|
381
382
|
constructor(...args) {
|
|
382
383
|
super(...args);
|
|
383
384
|
this._fibers = {};
|
|
@@ -399,12 +400,12 @@ let ServiceTransactionState = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
399
400
|
const selector = this.serviceDatabase.prepareClientNameSelector(db.info, db.dialect);
|
|
400
401
|
delete this._fibers[selector];
|
|
401
402
|
}
|
|
402
|
-
}) || _class$
|
|
403
|
+
}) || _class$p) || _class$p);
|
|
403
404
|
|
|
404
|
-
var _dec$
|
|
405
|
-
let ServiceTransactionAsyncLocalStorage = (_dec$
|
|
405
|
+
var _dec$o, _dec2$o, _class$o;
|
|
406
|
+
let ServiceTransactionAsyncLocalStorage = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
406
407
|
module: "a-orm"
|
|
407
|
-
}), _dec$
|
|
408
|
+
}), _dec$o(_class$o = _dec2$o(_class$o = class ServiceTransactionAsyncLocalStorage extends BeanBase {
|
|
408
409
|
constructor(...args) {
|
|
409
410
|
super(...args);
|
|
410
411
|
this.transactionStorage = void 0;
|
|
@@ -425,12 +426,12 @@ let ServiceTransactionAsyncLocalStorage = (_dec$n = Service(), _dec2$n = BeanInf
|
|
|
425
426
|
return fn();
|
|
426
427
|
});
|
|
427
428
|
}
|
|
428
|
-
}) || _class$
|
|
429
|
+
}) || _class$o) || _class$o);
|
|
429
430
|
|
|
430
|
-
var _dec$
|
|
431
|
-
let ServiceTransaction = (_dec$
|
|
431
|
+
var _dec$n, _dec2$n, _class$n;
|
|
432
|
+
let ServiceTransaction = (_dec$n = Service(), _dec2$n = BeanInfo({
|
|
432
433
|
module: "a-orm"
|
|
433
|
-
}), _dec$
|
|
434
|
+
}), _dec$n(_class$n = _dec2$n(_class$n = class ServiceTransaction extends BeanBase {
|
|
434
435
|
constructor(...args) {
|
|
435
436
|
super(...args);
|
|
436
437
|
this._db = void 0;
|
|
@@ -549,7 +550,7 @@ let ServiceTransaction = (_dec$m = Service(), _dec2$m = BeanInfo({
|
|
|
549
550
|
}
|
|
550
551
|
return res;
|
|
551
552
|
}
|
|
552
|
-
}) || _class$
|
|
553
|
+
}) || _class$n) || _class$n);
|
|
553
554
|
function _translateTransactionOptions(options) {
|
|
554
555
|
if (!options) return undefined;
|
|
555
556
|
return {
|
|
@@ -558,10 +559,10 @@ function _translateTransactionOptions(options) {
|
|
|
558
559
|
};
|
|
559
560
|
}
|
|
560
561
|
|
|
561
|
-
var _dec$
|
|
562
|
-
let ServiceDb = (_dec$
|
|
562
|
+
var _dec$m, _dec2$m, _class$m;
|
|
563
|
+
let ServiceDb = (_dec$m = Service(), _dec2$m = BeanInfo({
|
|
563
564
|
module: "a-orm"
|
|
564
|
-
}), _dec$
|
|
565
|
+
}), _dec$m(_class$m = _dec2$m(_class$m = class ServiceDb extends BeanBase {
|
|
565
566
|
constructor(...args) {
|
|
566
567
|
super(...args);
|
|
567
568
|
this._client = void 0;
|
|
@@ -616,12 +617,12 @@ let ServiceDb = (_dec$l = Service(), _dec2$l = BeanInfo({
|
|
|
616
617
|
compensate(cb) {
|
|
617
618
|
return this.transaction.compensate(cb);
|
|
618
619
|
}
|
|
619
|
-
}) || _class$
|
|
620
|
+
}) || _class$m) || _class$m);
|
|
620
621
|
|
|
621
|
-
var _dec$
|
|
622
|
-
let ServiceDatabaseClient = (_dec$
|
|
622
|
+
var _dec$l, _dec2$l, _class$l;
|
|
623
|
+
let ServiceDatabaseClient = (_dec$l = Service(), _dec2$l = BeanInfo({
|
|
623
624
|
module: "a-orm"
|
|
624
|
-
}), _dec$
|
|
625
|
+
}), _dec$l(_class$l = _dec2$l(_class$l = class ServiceDatabaseClient extends BeanMutateBase {
|
|
625
626
|
constructor(...args) {
|
|
626
627
|
super(...args);
|
|
627
628
|
this.level = void 0;
|
|
@@ -660,11 +661,11 @@ let ServiceDatabaseClient = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
|
660
661
|
await this.reload(clientConfig);
|
|
661
662
|
}
|
|
662
663
|
}
|
|
663
|
-
async
|
|
664
|
+
async onRemoveInstance({
|
|
664
665
|
clientName
|
|
665
666
|
}) {
|
|
666
667
|
if (clientName === this.clientName) {
|
|
667
|
-
await super.
|
|
668
|
+
await super.onRemoveInstance({
|
|
668
669
|
clientName
|
|
669
670
|
});
|
|
670
671
|
}
|
|
@@ -690,6 +691,7 @@ let ServiceDatabaseClient = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
|
690
691
|
}
|
|
691
692
|
async reload(clientConfig) {
|
|
692
693
|
const clientConfigReal = this.scope.service.database.getClientConfig(this.clientName, clientConfig);
|
|
694
|
+
this.$mutate([this.clientNameSelector, clientConfigReal]);
|
|
693
695
|
await this.__close();
|
|
694
696
|
this.__load(this.clientNameSelector, clientConfigReal);
|
|
695
697
|
}
|
|
@@ -722,12 +724,12 @@ let ServiceDatabaseClient = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
|
722
724
|
await this.scope.service.database.reloadClientsWorker(this.clientName, config);
|
|
723
725
|
// await this.scope.service.database.reloadClients(this.clientName, config);
|
|
724
726
|
}
|
|
725
|
-
}) || _class$
|
|
727
|
+
}) || _class$l) || _class$l);
|
|
726
728
|
|
|
727
|
-
var _dec$
|
|
728
|
-
let BeanDatabase = (_dec$
|
|
729
|
+
var _dec$k, _dec2$k, _class$k;
|
|
730
|
+
let BeanDatabase = (_dec$k = Bean(), _dec2$k = BeanInfo({
|
|
729
731
|
module: "a-orm"
|
|
730
|
-
}), _dec$
|
|
732
|
+
}), _dec$k(_class$k = _dec2$k(_class$k = class BeanDatabase extends BeanBase {
|
|
731
733
|
get current() {
|
|
732
734
|
return this.bean._getBean(ServiceDatabaseAsyncLocalStorage).current;
|
|
733
735
|
}
|
|
@@ -767,12 +769,12 @@ let BeanDatabase = (_dec$j = Bean(), _dec2$j = BeanInfo({
|
|
|
767
769
|
return this.bean._getBean(ServiceTransactionAsyncLocalStorage).run(fn);
|
|
768
770
|
});
|
|
769
771
|
}
|
|
770
|
-
}) || _class$
|
|
772
|
+
}) || _class$k) || _class$k);
|
|
771
773
|
|
|
772
|
-
var _dec$
|
|
773
|
-
let BeanDatabaseDialectBase = (_dec$
|
|
774
|
+
var _dec$j, _dec2$j, _dec3$7, _class$j;
|
|
775
|
+
let BeanDatabaseDialectBase = (_dec$j = Bean(), _dec2$j = Virtual(), _dec3$7 = BeanInfo({
|
|
774
776
|
module: "a-orm"
|
|
775
|
-
}), _dec$
|
|
777
|
+
}), _dec$j(_class$j = _dec2$j(_class$j = _dec3$7(_class$j = class BeanDatabaseDialectBase extends BeanBase {
|
|
776
778
|
constructor(...args) {
|
|
777
779
|
super(...args);
|
|
778
780
|
this._capabilities = void 0;
|
|
@@ -889,7 +891,7 @@ let BeanDatabaseDialectBase = (_dec$i = Bean(), _dec2$i = Virtual(), _dec3$7 = B
|
|
|
889
891
|
_columnTypePrefixes(type, prefixes) {
|
|
890
892
|
return prefixes.some(prefix => type.includes(prefix));
|
|
891
893
|
}
|
|
892
|
-
}) || _class$
|
|
894
|
+
}) || _class$j) || _class$j) || _class$j);
|
|
893
895
|
|
|
894
896
|
const OpAggrs = ['count', 'sum', 'avg', 'max', 'min'];
|
|
895
897
|
const OpJoint = {
|
|
@@ -1279,69 +1281,69 @@ function _initializerDefineProperty(e, i, r, l) {
|
|
|
1279
1281
|
});
|
|
1280
1282
|
}
|
|
1281
1283
|
|
|
1282
|
-
var _dec$
|
|
1284
|
+
var _dec$i, _dec2$i, _dec3$6, _dec4$4, _dec5$1, _dec6$1, _class$i, _descriptor$4, _descriptor2$2, _descriptor3$1;
|
|
1283
1285
|
const app$1 = useApp();
|
|
1284
1286
|
const ormConfig$1 = app$1.util.getModuleConfigRaw('a-orm');
|
|
1285
1287
|
const ordersDefault = ormConfig$1?.rest?.query?.orders?.default ?? 'createdAt,desc';
|
|
1286
|
-
let DtoQueryBase = (_dec$
|
|
1288
|
+
let DtoQueryBase = (_dec$i = Api.field(v.optional(), v.array(String, {
|
|
1287
1289
|
separator: ','
|
|
1288
|
-
})), _dec2$
|
|
1290
|
+
})), _dec2$i = Reflect.metadata("design:type", Array), _dec3$6 = Api.field(v.optional(), z.looseObject({})), _dec4$4 = Reflect.metadata("design:type", Object), _dec5$1 = Api.field(v.default(ordersDefault), v.optional(), z.union([z.string(), z.array(z.array(z.string()))])), _dec6$1 = Reflect.metadata("design:type", Object), _class$i = class DtoQueryBase {
|
|
1289
1291
|
constructor() {
|
|
1290
1292
|
_initializerDefineProperty(this, "columns", _descriptor$4, this);
|
|
1291
1293
|
_initializerDefineProperty(this, "where", _descriptor2$2, this);
|
|
1292
1294
|
_initializerDefineProperty(this, "orders", _descriptor3$1, this);
|
|
1293
1295
|
}
|
|
1294
|
-
}, _descriptor$4 = _applyDecoratedDescriptor(_class$
|
|
1296
|
+
}, _descriptor$4 = _applyDecoratedDescriptor(_class$i.prototype, "columns", [_dec$i, _dec2$i], {
|
|
1295
1297
|
configurable: true,
|
|
1296
1298
|
enumerable: true,
|
|
1297
1299
|
writable: true,
|
|
1298
1300
|
initializer: null
|
|
1299
|
-
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$
|
|
1301
|
+
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$i.prototype, "where", [_dec3$6, _dec4$4], {
|
|
1300
1302
|
configurable: true,
|
|
1301
1303
|
enumerable: true,
|
|
1302
1304
|
writable: true,
|
|
1303
1305
|
initializer: null
|
|
1304
|
-
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$
|
|
1306
|
+
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$i.prototype, "orders", [_dec5$1, _dec6$1], {
|
|
1305
1307
|
configurable: true,
|
|
1306
1308
|
enumerable: true,
|
|
1307
1309
|
writable: true,
|
|
1308
1310
|
initializer: null
|
|
1309
|
-
}), _class$
|
|
1311
|
+
}), _class$i);
|
|
1310
1312
|
|
|
1311
|
-
var _dec$
|
|
1313
|
+
var _dec$h, _dec2$h, _dec3$5, _dec4$3, _class$h, _descriptor$3, _descriptor2$1;
|
|
1312
1314
|
const app = useApp();
|
|
1313
1315
|
const ormConfig = app.util.getModuleConfigRaw('a-orm');
|
|
1314
1316
|
const pageSizeDefault = ormConfig?.rest?.query?.pageSize?.default ?? 20;
|
|
1315
1317
|
const pageSizeMax = ormConfig?.rest?.query?.pageSize?.max ?? 100;
|
|
1316
|
-
let DtoQueryPageBase = (_dec$
|
|
1318
|
+
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 {
|
|
1317
1319
|
constructor(...args) {
|
|
1318
1320
|
super(...args);
|
|
1319
1321
|
_initializerDefineProperty(this, "pageNo", _descriptor$3, this);
|
|
1320
1322
|
_initializerDefineProperty(this, "pageSize", _descriptor2$1, this);
|
|
1321
1323
|
}
|
|
1322
|
-
}, _descriptor$3 = _applyDecoratedDescriptor(_class$
|
|
1324
|
+
}, _descriptor$3 = _applyDecoratedDescriptor(_class$h.prototype, "pageNo", [_dec$h, _dec2$h], {
|
|
1323
1325
|
configurable: true,
|
|
1324
1326
|
enumerable: true,
|
|
1325
1327
|
writable: true,
|
|
1326
1328
|
initializer: null
|
|
1327
|
-
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$
|
|
1329
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$h.prototype, "pageSize", [_dec3$5, _dec4$3], {
|
|
1328
1330
|
configurable: true,
|
|
1329
1331
|
enumerable: true,
|
|
1330
1332
|
writable: true,
|
|
1331
1333
|
initializer: null
|
|
1332
|
-
}), _class$
|
|
1334
|
+
}), _class$h);
|
|
1333
1335
|
|
|
1334
1336
|
const SymbolKeyFieldsMore = Symbol('$fieldsMore');
|
|
1335
1337
|
|
|
1336
1338
|
class EntityBaseEmpty {}
|
|
1337
1339
|
|
|
1338
|
-
var _dec$
|
|
1339
|
-
let EntityBaseInner = (_dec$
|
|
1340
|
+
var _dec$g, _dec2$g, _dec3$4, _dec4$2, _dec5, _dec6, _dec7, _dec8, _class$g, _descriptor$2, _descriptor2, _descriptor3, _descriptor4;
|
|
1341
|
+
let EntityBaseInner = (_dec$g = Api.field(v.openapi({
|
|
1340
1342
|
title: $locale('CreatedAt'),
|
|
1341
1343
|
rest: {
|
|
1342
1344
|
order: OrderMaxBase - 2
|
|
1343
1345
|
}
|
|
1344
|
-
})), _dec2$
|
|
1346
|
+
})), _dec2$g = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec3$4 = Api.field(v.openapi({
|
|
1345
1347
|
title: $locale('UpdatedAt'),
|
|
1346
1348
|
rest: {
|
|
1347
1349
|
order: OrderMaxBase - 1
|
|
@@ -1356,7 +1358,7 @@ let EntityBaseInner = (_dec$f = Api.field(v.openapi({
|
|
|
1356
1358
|
rest: {
|
|
1357
1359
|
visible: false
|
|
1358
1360
|
}
|
|
1359
|
-
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$
|
|
1361
|
+
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$g = class EntityBaseInner extends EntityBaseEmpty {
|
|
1360
1362
|
constructor(...args) {
|
|
1361
1363
|
super(...args);
|
|
1362
1364
|
_initializerDefineProperty(this, "createdAt", _descriptor$2, this);
|
|
@@ -1364,63 +1366,63 @@ let EntityBaseInner = (_dec$f = Api.field(v.openapi({
|
|
|
1364
1366
|
_initializerDefineProperty(this, "deleted", _descriptor3, this);
|
|
1365
1367
|
_initializerDefineProperty(this, "iid", _descriptor4, this);
|
|
1366
1368
|
}
|
|
1367
|
-
}, _descriptor$2 = _applyDecoratedDescriptor(_class$
|
|
1369
|
+
}, _descriptor$2 = _applyDecoratedDescriptor(_class$g.prototype, "createdAt", [_dec$g, _dec2$g], {
|
|
1368
1370
|
configurable: true,
|
|
1369
1371
|
enumerable: true,
|
|
1370
1372
|
writable: true,
|
|
1371
1373
|
initializer: null
|
|
1372
|
-
}), _descriptor2 = _applyDecoratedDescriptor(_class$
|
|
1374
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class$g.prototype, "updatedAt", [_dec3$4, _dec4$2], {
|
|
1373
1375
|
configurable: true,
|
|
1374
1376
|
enumerable: true,
|
|
1375
1377
|
writable: true,
|
|
1376
1378
|
initializer: null
|
|
1377
|
-
}), _descriptor3 = _applyDecoratedDescriptor(_class$
|
|
1379
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class$g.prototype, "deleted", [_dec5, _dec6], {
|
|
1378
1380
|
configurable: true,
|
|
1379
1381
|
enumerable: true,
|
|
1380
1382
|
writable: true,
|
|
1381
1383
|
initializer: null
|
|
1382
|
-
}), _descriptor4 = _applyDecoratedDescriptor(_class$
|
|
1384
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class$g.prototype, "iid", [_dec7, _dec8], {
|
|
1383
1385
|
configurable: true,
|
|
1384
1386
|
enumerable: true,
|
|
1385
1387
|
writable: true,
|
|
1386
1388
|
initializer: null
|
|
1387
|
-
}), _class$
|
|
1389
|
+
}), _class$g);
|
|
1388
1390
|
|
|
1389
|
-
var _dec$
|
|
1390
|
-
let EntityBase = (_dec$
|
|
1391
|
+
var _dec$f, _dec2$f, _class$f, _descriptor$1;
|
|
1392
|
+
let EntityBase = (_dec$f = Api.field(v.openapi({
|
|
1391
1393
|
title: $locale('TableIdentity'),
|
|
1392
1394
|
rest: {
|
|
1393
1395
|
order: OrderCoreBase + 1
|
|
1394
1396
|
}
|
|
1395
|
-
}), v.tableIdentity()), _dec2$
|
|
1397
|
+
}), v.tableIdentity()), _dec2$f = Reflect.metadata("design:type", typeof TableIdentity === "undefined" ? Object : TableIdentity), _class$f = class EntityBase extends EntityBaseInner {
|
|
1396
1398
|
constructor(...args) {
|
|
1397
1399
|
super(...args);
|
|
1398
1400
|
_initializerDefineProperty(this, "id", _descriptor$1, this);
|
|
1399
1401
|
}
|
|
1400
|
-
}, _descriptor$1 = _applyDecoratedDescriptor(_class$
|
|
1402
|
+
}, _descriptor$1 = _applyDecoratedDescriptor(_class$f.prototype, "id", [_dec$f, _dec2$f], {
|
|
1401
1403
|
configurable: true,
|
|
1402
1404
|
enumerable: true,
|
|
1403
1405
|
writable: true,
|
|
1404
1406
|
initializer: null
|
|
1405
|
-
}), _class$
|
|
1407
|
+
}), _class$f);
|
|
1406
1408
|
|
|
1407
|
-
var _dec$
|
|
1408
|
-
let EntityBaseSimple = (_dec$
|
|
1409
|
+
var _dec$e, _dec2$e, _class$e, _descriptor;
|
|
1410
|
+
let EntityBaseSimple = (_dec$e = Api.field(v.openapi({
|
|
1409
1411
|
title: $locale('TableIdentity'),
|
|
1410
1412
|
rest: {
|
|
1411
1413
|
order: OrderCoreBase + 1
|
|
1412
1414
|
}
|
|
1413
|
-
})), _dec2$
|
|
1415
|
+
})), _dec2$e = Reflect.metadata("design:type", Number), _class$e = class EntityBaseSimple extends EntityBaseInner {
|
|
1414
1416
|
constructor(...args) {
|
|
1415
1417
|
super(...args);
|
|
1416
1418
|
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
1417
1419
|
}
|
|
1418
|
-
}, _descriptor = _applyDecoratedDescriptor(_class$
|
|
1420
|
+
}, _descriptor = _applyDecoratedDescriptor(_class$e.prototype, "id", [_dec$e, _dec2$e], {
|
|
1419
1421
|
configurable: true,
|
|
1420
1422
|
enumerable: true,
|
|
1421
1423
|
writable: true,
|
|
1422
1424
|
initializer: null
|
|
1423
|
-
}), _class$
|
|
1425
|
+
}), _class$e);
|
|
1424
1426
|
|
|
1425
1427
|
const SymbolKeyEntity = Symbol('$entity');
|
|
1426
1428
|
const SymbolKeyEntityMeta = Symbol('$entityMeta');
|
|
@@ -2204,10 +2206,59 @@ class BeanModelCrudTable extends BeanModelCrudInner {
|
|
|
2204
2206
|
}
|
|
2205
2207
|
}
|
|
2206
2208
|
|
|
2207
|
-
var _dec$
|
|
2208
|
-
let BeanModel = (_dec$
|
|
2209
|
+
var _dec$d, _dec2$d, _dec3$3, _class$d;
|
|
2210
|
+
let BeanModel = (_dec$d = Bean(), _dec2$d = Virtual(), _dec3$3 = BeanInfo({
|
|
2209
2211
|
module: "a-orm"
|
|
2210
|
-
}), _dec$
|
|
2212
|
+
}), _dec$d(_class$d = _dec2$d(_class$d = _dec3$3(_class$d = class BeanModel extends BeanModelCrudTable {}) || _class$d) || _class$d) || _class$d);
|
|
2213
|
+
|
|
2214
|
+
const SymbolCacheModelsClear = Symbol('SymbolCacheModelsClearAll');
|
|
2215
|
+
const SymbolCacheModelCacheInstances = Symbol('SymbolCacheModelCacheInstances');
|
|
2216
|
+
function clearAllCacheModelsClear(app) {
|
|
2217
|
+
delete app.meta[SymbolCacheModelsClear];
|
|
2218
|
+
}
|
|
2219
|
+
async function clearCacheModelCacheInstance(app, beanFullName) {
|
|
2220
|
+
const cacheModelCacheInstances = getCacheModelCacheInstances(app);
|
|
2221
|
+
const instances = cacheModelCacheInstances[beanFullName];
|
|
2222
|
+
if (!instances) return;
|
|
2223
|
+
delete cacheModelCacheInstances[beanFullName];
|
|
2224
|
+
for (const cacheName in instances) {
|
|
2225
|
+
await app.bean._removeBean(instances[cacheName]);
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
function getCacheModelCacheInstances(app) {
|
|
2229
|
+
if (!app.meta[SymbolCacheModelCacheInstances]) app.meta[SymbolCacheModelCacheInstances] = {};
|
|
2230
|
+
return app.meta[SymbolCacheModelCacheInstances];
|
|
2231
|
+
}
|
|
2232
|
+
function getCacheModelsClear(app) {
|
|
2233
|
+
if (!app.meta[SymbolCacheModelsClear]) {
|
|
2234
|
+
app.meta[SymbolCacheModelsClear] = _collectModelsClear(app);
|
|
2235
|
+
}
|
|
2236
|
+
return app.meta[SymbolCacheModelsClear];
|
|
2237
|
+
}
|
|
2238
|
+
function _collectModelsClear(app) {
|
|
2239
|
+
const modelsClearAll = {};
|
|
2240
|
+
const onionSlices = app.bean.onion.model.getOnionsEnabledCached();
|
|
2241
|
+
for (const onionSlice of onionSlices) {
|
|
2242
|
+
const modelName = onionSlice.name;
|
|
2243
|
+
if (!modelsClearAll[modelName]) modelsClearAll[modelName] = [];
|
|
2244
|
+
//
|
|
2245
|
+
const modelsClear = onionSlice.beanOptions.options?.cache?.modelsClear;
|
|
2246
|
+
if (modelsClear) {
|
|
2247
|
+
const modelsClear2 = Array.isArray(modelsClear) ? modelsClear : [modelsClear];
|
|
2248
|
+
modelsClearAll[modelName].push(...modelsClear2);
|
|
2249
|
+
}
|
|
2250
|
+
//
|
|
2251
|
+
const modelsClearedBy = onionSlice.beanOptions.options?.cache?.modelsClearedBy;
|
|
2252
|
+
if (modelsClearedBy) {
|
|
2253
|
+
const modelsClearedBy2 = Array.isArray(modelsClearedBy) ? modelsClearedBy : [modelsClearedBy];
|
|
2254
|
+
for (const modelName2 of modelsClearedBy2) {
|
|
2255
|
+
if (!modelsClearAll[modelName2]) modelsClearAll[modelName2] = [];
|
|
2256
|
+
modelsClearAll[modelName2].push(modelName);
|
|
2257
|
+
}
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
return modelsClearAll;
|
|
2261
|
+
}
|
|
2211
2262
|
|
|
2212
2263
|
const SymbolCacheOptions = Symbol('SymbolCacheOptions');
|
|
2213
2264
|
const SymbolCacheEnabled = Symbol('SymbolCacheEnabled');
|
|
@@ -2227,7 +2278,14 @@ class ModelCacheBase extends BeanBase {
|
|
|
2227
2278
|
}
|
|
2228
2279
|
getInstance(table) {
|
|
2229
2280
|
if (this.options === false) throw new Error('cache disabled');
|
|
2230
|
-
|
|
2281
|
+
const beanFullName = this._model.$beanFullName;
|
|
2282
|
+
const cacheName = this.getName(table);
|
|
2283
|
+
const cacheModelCacheInstances = getCacheModelCacheInstances(this.app);
|
|
2284
|
+
if (!cacheModelCacheInstances[beanFullName]) cacheModelCacheInstances[beanFullName] = {};
|
|
2285
|
+
if (!cacheModelCacheInstances[beanFullName][cacheName]) {
|
|
2286
|
+
cacheModelCacheInstances[beanFullName][cacheName] = this.app.bean.summer.cache(cacheName, this.options);
|
|
2287
|
+
}
|
|
2288
|
+
return cacheModelCacheInstances[beanFullName][cacheName];
|
|
2231
2289
|
}
|
|
2232
2290
|
getName(table) {
|
|
2233
2291
|
const clientNameReal = this.$scope.orm.service.database.prepareClientNameReal(this._model.db.clientName);
|
|
@@ -2282,10 +2340,10 @@ class ModelCacheBase extends BeanBase {
|
|
|
2282
2340
|
}
|
|
2283
2341
|
}
|
|
2284
2342
|
|
|
2285
|
-
var _dec$
|
|
2286
|
-
let ServiceCacheEntity = (_dec$
|
|
2343
|
+
var _dec$c, _dec2$c, _class$c;
|
|
2344
|
+
let ServiceCacheEntity = (_dec$c = Service(), _dec2$c = BeanInfo({
|
|
2287
2345
|
module: "a-orm"
|
|
2288
|
-
}), _dec$
|
|
2346
|
+
}), _dec$c(_class$c = _dec2$c(_class$c = class ServiceCacheEntity extends ModelCacheBase {
|
|
2289
2347
|
__init__(model) {
|
|
2290
2348
|
super.__init__(model, 'entity');
|
|
2291
2349
|
}
|
|
@@ -2308,12 +2366,12 @@ let ServiceCacheEntity = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
|
2308
2366
|
get keysAux() {
|
|
2309
2367
|
return this._model.options.cache?.keysAux;
|
|
2310
2368
|
}
|
|
2311
|
-
}) || _class$
|
|
2369
|
+
}) || _class$c) || _class$c);
|
|
2312
2370
|
|
|
2313
|
-
var _dec$
|
|
2314
|
-
let ServiceCacheQuery = (_dec$
|
|
2371
|
+
var _dec$b, _dec2$b, _class$b;
|
|
2372
|
+
let ServiceCacheQuery = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
2315
2373
|
module: "a-orm"
|
|
2316
|
-
}), _dec$
|
|
2374
|
+
}), _dec$b(_class$b = _dec2$b(_class$b = class ServiceCacheQuery extends ModelCacheBase {
|
|
2317
2375
|
__init__(model) {
|
|
2318
2376
|
super.__init__(model, 'query');
|
|
2319
2377
|
}
|
|
@@ -2323,7 +2381,7 @@ let ServiceCacheQuery = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
2323
2381
|
const cache = this.getInstance(table);
|
|
2324
2382
|
await cache.clear();
|
|
2325
2383
|
}
|
|
2326
|
-
}) || _class$
|
|
2384
|
+
}) || _class$b) || _class$b);
|
|
2327
2385
|
|
|
2328
2386
|
function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
2329
2387
|
// collect
|
|
@@ -2368,10 +2426,10 @@ function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
|
2368
2426
|
return relations;
|
|
2369
2427
|
}
|
|
2370
2428
|
|
|
2371
|
-
var _dec$
|
|
2372
|
-
let ServiceRelations = (_dec$
|
|
2429
|
+
var _dec$a, _dec2$a, _class$a;
|
|
2430
|
+
let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
2373
2431
|
module: "a-orm"
|
|
2374
|
-
}), _dec$
|
|
2432
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class ServiceRelations extends BeanBase {
|
|
2375
2433
|
constructor(...args) {
|
|
2376
2434
|
super(...args);
|
|
2377
2435
|
this._model = void 0;
|
|
@@ -2903,7 +2961,7 @@ let ServiceRelations = (_dec$9 = Service(), _dec2$9 = BeanInfo({
|
|
|
2903
2961
|
handleRelationsCollection(includeWrapper) {
|
|
2904
2962
|
return handleRelationsCollection(this._model.options.relations, includeWrapper);
|
|
2905
2963
|
}
|
|
2906
|
-
}) || _class$
|
|
2964
|
+
}) || _class$a) || _class$a);
|
|
2907
2965
|
|
|
2908
2966
|
class BeanModelCrud extends BeanModelCrudInner {
|
|
2909
2967
|
async mget(ids, options) {
|
|
@@ -2932,14 +2990,12 @@ class BeanModelCrud extends BeanModelCrudInner {
|
|
|
2932
2990
|
}
|
|
2933
2991
|
}
|
|
2934
2992
|
|
|
2935
|
-
const SymbolModelsClearAll = Symbol('SymbolModelsClearAll');
|
|
2936
2993
|
class BeanModelCache extends BeanModelCrud {
|
|
2937
2994
|
constructor(...args) {
|
|
2938
2995
|
super(...args);
|
|
2939
2996
|
this.cacheQuery = void 0;
|
|
2940
2997
|
this.cacheEntity = void 0;
|
|
2941
2998
|
this.relations = void 0;
|
|
2942
|
-
this[SymbolModelsClearAll] = void 0;
|
|
2943
2999
|
}
|
|
2944
3000
|
__init__(clientName, table) {
|
|
2945
3001
|
super.__init__(clientName, table);
|
|
@@ -2947,6 +3003,10 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
2947
3003
|
this.cacheEntity = this.bean._newBean(ServiceCacheEntity, this);
|
|
2948
3004
|
this.relations = this.bean._newBean(ServiceRelations, this);
|
|
2949
3005
|
}
|
|
3006
|
+
async __dispose__() {
|
|
3007
|
+
await disposeInstance(this.cacheQuery);
|
|
3008
|
+
await disposeInstance(this.cacheEntity);
|
|
3009
|
+
}
|
|
2950
3010
|
async insert(data, options) {
|
|
2951
3011
|
if (!data) data = {};
|
|
2952
3012
|
const items = await this.insertBulk([data], options);
|
|
@@ -3490,39 +3550,9 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3490
3550
|
}
|
|
3491
3551
|
}
|
|
3492
3552
|
_getModelsClear(modelName) {
|
|
3493
|
-
const modelsClearAll = this.
|
|
3553
|
+
const modelsClearAll = getCacheModelsClear(this.app);
|
|
3494
3554
|
return modelsClearAll[modelName ?? this.$onionName];
|
|
3495
3555
|
}
|
|
3496
|
-
_getModelsClearAll() {
|
|
3497
|
-
if (!this[SymbolModelsClearAll]) {
|
|
3498
|
-
this[SymbolModelsClearAll] = this._collectModelsClearAll();
|
|
3499
|
-
}
|
|
3500
|
-
return this[SymbolModelsClearAll];
|
|
3501
|
-
}
|
|
3502
|
-
_collectModelsClearAll() {
|
|
3503
|
-
const modelsClearAll = {};
|
|
3504
|
-
const onionSlices = this.bean.onion.model.getOnionsEnabled();
|
|
3505
|
-
for (const onionSlice of onionSlices) {
|
|
3506
|
-
const modelName = onionSlice.name;
|
|
3507
|
-
if (!modelsClearAll[modelName]) modelsClearAll[modelName] = [];
|
|
3508
|
-
//
|
|
3509
|
-
const modelsClear = onionSlice.beanOptions.options?.cache?.modelsClear;
|
|
3510
|
-
if (modelsClear) {
|
|
3511
|
-
const modelsClear2 = Array.isArray(modelsClear) ? modelsClear : [modelsClear];
|
|
3512
|
-
modelsClearAll[modelName].push(...modelsClear2);
|
|
3513
|
-
}
|
|
3514
|
-
//
|
|
3515
|
-
const modelsClearedBy = onionSlice.beanOptions.options?.cache?.modelsClearedBy;
|
|
3516
|
-
if (modelsClearedBy) {
|
|
3517
|
-
const modelsClearedBy2 = Array.isArray(modelsClearedBy) ? modelsClearedBy : [modelsClearedBy];
|
|
3518
|
-
for (const modelName2 of modelsClearedBy2) {
|
|
3519
|
-
if (!modelsClearAll[modelName2]) modelsClearAll[modelName2] = [];
|
|
3520
|
-
modelsClearAll[modelName2].push(modelName);
|
|
3521
|
-
}
|
|
3522
|
-
}
|
|
3523
|
-
}
|
|
3524
|
-
return modelsClearAll;
|
|
3525
|
-
}
|
|
3526
3556
|
_checkDisableCacheQueryByOptions(options) {
|
|
3527
3557
|
if (options?.disableCacheQuery === true || options?.disableCacheQuery === false) {
|
|
3528
3558
|
return options?.disableCacheQuery;
|
|
@@ -3617,16 +3647,16 @@ function __parseMagicField(str) {
|
|
|
3617
3647
|
return [fieldName, op];
|
|
3618
3648
|
}
|
|
3619
3649
|
|
|
3620
|
-
var _dec$
|
|
3621
|
-
let BeanModelBase = (_dec$
|
|
3650
|
+
var _dec$9, _dec2$9, _dec3$2, _class$9;
|
|
3651
|
+
let BeanModelBase = (_dec$9 = Bean(), _dec2$9 = Virtual(), _dec3$2 = BeanInfo({
|
|
3622
3652
|
module: "a-orm"
|
|
3623
|
-
}), _dec$
|
|
3653
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = _dec3$2(_class$9 = class BeanModelBase extends BeanModelCache {}) || _class$9) || _class$9) || _class$9);
|
|
3624
3654
|
|
|
3625
|
-
var _dec$
|
|
3655
|
+
var _dec$8, _dec2$8, _dec3$1, _dec4$1, _class$8;
|
|
3626
3656
|
const SymbolModuleScope$1 = Symbol('SymbolModuleScope');
|
|
3627
|
-
let ServiceEntityResolver = (_dec$
|
|
3657
|
+
let ServiceEntityResolver = (_dec$8 = Service(), _dec2$8 = BeanInfo({
|
|
3628
3658
|
module: "a-orm"
|
|
3629
|
-
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3659
|
+
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", [String]), _dec$8(_class$8 = _dec2$8(_class$8 = _dec3$1(_class$8 = _dec4$1(_class$8 = class ServiceEntityResolver extends BeanBase {
|
|
3630
3660
|
constructor(moduleScope) {
|
|
3631
3661
|
super();
|
|
3632
3662
|
this[SymbolModuleScope$1] = void 0;
|
|
@@ -3641,13 +3671,13 @@ let ServiceEntityResolver = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
|
3641
3671
|
}
|
|
3642
3672
|
return this.__instances[prop];
|
|
3643
3673
|
}
|
|
3644
|
-
}) || _class$
|
|
3674
|
+
}) || _class$8) || _class$8) || _class$8) || _class$8);
|
|
3645
3675
|
|
|
3646
|
-
var _dec$
|
|
3676
|
+
var _dec$7, _dec2$7, _dec3, _dec4, _class$7;
|
|
3647
3677
|
const SymbolModuleScope = Symbol('SymbolModuleScope');
|
|
3648
|
-
let ServiceModelResolver = (_dec$
|
|
3678
|
+
let ServiceModelResolver = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
3649
3679
|
module: "a-orm"
|
|
3650
|
-
}), _dec3 = Reflect.metadata("design:type", Function), _dec4 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3680
|
+
}), _dec3 = Reflect.metadata("design:type", Function), _dec4 = Reflect.metadata("design:paramtypes", [String]), _dec$7(_class$7 = _dec2$7(_class$7 = _dec3(_class$7 = _dec4(_class$7 = class ServiceModelResolver extends BeanBase {
|
|
3651
3681
|
constructor(moduleScope) {
|
|
3652
3682
|
super();
|
|
3653
3683
|
this[SymbolModuleScope] = void 0;
|
|
@@ -3657,12 +3687,12 @@ let ServiceModelResolver = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
|
3657
3687
|
const beanFullName = `${this[SymbolModuleScope]}.model.${prop}`;
|
|
3658
3688
|
return this.bean._getBean(beanFullName);
|
|
3659
3689
|
}
|
|
3660
|
-
}) || _class$
|
|
3690
|
+
}) || _class$7) || _class$7) || _class$7) || _class$7);
|
|
3661
3691
|
|
|
3662
|
-
var _dec$
|
|
3663
|
-
let BroadcastColumnsClear = (_dec$
|
|
3692
|
+
var _dec$6, _dec2$6, _class$6;
|
|
3693
|
+
let BroadcastColumnsClear = (_dec$6 = Broadcast(), _dec2$6 = BeanInfo({
|
|
3664
3694
|
module: "a-orm"
|
|
3665
|
-
}), _dec$
|
|
3695
|
+
}), _dec$6(_class$6 = _dec2$6(_class$6 = class BroadcastColumnsClear extends BeanBroadcastBase {
|
|
3666
3696
|
async execute(data, isEmitter) {
|
|
3667
3697
|
const {
|
|
3668
3698
|
clientName,
|
|
@@ -3672,44 +3702,44 @@ let BroadcastColumnsClear = (_dec$5 = Broadcast(), _dec2$5 = BeanInfo({
|
|
|
3672
3702
|
await cast(this.scope.service.database).columnsClearWorker(clientName, tableName);
|
|
3673
3703
|
}
|
|
3674
3704
|
}
|
|
3675
|
-
}) || _class$
|
|
3705
|
+
}) || _class$6) || _class$6);
|
|
3676
3706
|
|
|
3677
|
-
var _dec$
|
|
3678
|
-
let EventClientNameReal = (_dec$
|
|
3707
|
+
var _dec$5, _dec2$5, _class$5;
|
|
3708
|
+
let EventClientNameReal = (_dec$5 = Event(), _dec2$5 = BeanInfo({
|
|
3679
3709
|
module: "a-orm"
|
|
3680
|
-
}), _dec$
|
|
3710
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class EventClientNameReal extends BeanEventBase {}) || _class$5) || _class$5);
|
|
3681
3711
|
|
|
3682
|
-
var _dec$
|
|
3683
|
-
let EventColumnsClear = (_dec$
|
|
3712
|
+
var _dec$4, _dec2$4, _class$4;
|
|
3713
|
+
let EventColumnsClear = (_dec$4 = Event(), _dec2$4 = BeanInfo({
|
|
3684
3714
|
module: "a-orm"
|
|
3685
|
-
}), _dec$
|
|
3715
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class EventColumnsClear extends BeanEventBase {}) || _class$4) || _class$4);
|
|
3686
3716
|
|
|
3687
|
-
var _dec$
|
|
3688
|
-
let QueueDoubleDelete = (_dec$
|
|
3717
|
+
var _dec$3, _dec2$3, _class$3;
|
|
3718
|
+
let QueueDoubleDelete = (_dec$3 = Queue({
|
|
3689
3719
|
options: {
|
|
3690
3720
|
job: {
|
|
3691
3721
|
delay: 3 * 1000
|
|
3692
3722
|
}
|
|
3693
3723
|
}
|
|
3694
|
-
}), _dec2$
|
|
3724
|
+
}), _dec2$3 = BeanInfo({
|
|
3695
3725
|
module: "a-orm"
|
|
3696
|
-
}), _dec$
|
|
3726
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class QueueDoubleDelete extends BeanQueueBase {
|
|
3697
3727
|
async execute(data, _options) {
|
|
3698
3728
|
const beanInstance = this.app.bean._newBean(data.beanFullName, data.clientName, data.table);
|
|
3699
3729
|
await beanInstance[data.method](...data.args);
|
|
3700
3730
|
}
|
|
3701
|
-
}) || _class$
|
|
3731
|
+
}) || _class$3) || _class$3);
|
|
3702
3732
|
|
|
3703
|
-
var _dec$
|
|
3704
|
-
let ScheduleSoftDeletionPrune = (_dec$
|
|
3733
|
+
var _dec$2, _dec2$2, _class$2;
|
|
3734
|
+
let ScheduleSoftDeletionPrune = (_dec$2 = Schedule({
|
|
3705
3735
|
repeat: {
|
|
3706
3736
|
every: 24 * 3600 * 1000
|
|
3707
3737
|
}
|
|
3708
|
-
}), _dec2$
|
|
3738
|
+
}), _dec2$2 = BeanInfo({
|
|
3709
3739
|
module: "a-orm"
|
|
3710
|
-
}), _dec$
|
|
3740
|
+
}), _dec$2(_class$2 = _dec2$2(_class$2 = class ScheduleSoftDeletionPrune extends BeanBase {
|
|
3711
3741
|
async execute() {
|
|
3712
|
-
const onionSlices = this.bean.onion.model.
|
|
3742
|
+
const onionSlices = this.bean.onion.model.getOnionsEnabledCached();
|
|
3713
3743
|
for (const onionSlice of onionSlices) {
|
|
3714
3744
|
if (onionSlice.beanOptions.options?.disableDeleted) continue;
|
|
3715
3745
|
let softDeletionPrune = onionSlice.beanOptions.options?.softDeletionPrune ?? this.scope.config.softDeletionPrune.enable;
|
|
@@ -3738,6 +3768,20 @@ let ScheduleSoftDeletionPrune = (_dec$1 = Schedule({
|
|
|
3738
3768
|
});
|
|
3739
3769
|
}
|
|
3740
3770
|
}
|
|
3771
|
+
}) || _class$2) || _class$2);
|
|
3772
|
+
|
|
3773
|
+
var _dec$1, _dec2$1, _class$1;
|
|
3774
|
+
// import { clearAllCacheModelsClear, clearCacheModelCacheInstance } from '../lib/const.ts';
|
|
3775
|
+
|
|
3776
|
+
let HmrModel = (_dec$1 = Hmr(), _dec2$1 = BeanInfo({
|
|
3777
|
+
module: "a-orm"
|
|
3778
|
+
}), _dec$1(_class$1 = _dec2$1(_class$1 = class HmrModel extends BeanBase {
|
|
3779
|
+
async reload(_beanOptions) {
|
|
3780
|
+
// more deps: dto/model
|
|
3781
|
+
this.app.bean.worker.reload();
|
|
3782
|
+
// clearAllCacheModelsClear(this.app);
|
|
3783
|
+
// await clearCacheModelCacheInstance(this.app, beanOptions.beanFullName);
|
|
3784
|
+
}
|
|
3741
3785
|
}) || _class$1) || _class$1);
|
|
3742
3786
|
|
|
3743
3787
|
function config(_app) {
|
|
@@ -4439,4 +4483,4 @@ const $relationMutate = {
|
|
|
4439
4483
|
belongsToMany
|
|
4440
4484
|
};
|
|
4441
4485
|
|
|
4442
|
-
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, DatabaseDialect, DtoQueryBase, DtoQueryPageBase, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, EventClientNameReal, EventColumnsClear, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, QueueDoubleDelete, 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, errors, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
|
4486
|
+
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, DatabaseDialect, DtoQueryBase, DtoQueryPageBase, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, EventClientNameReal, EventColumnsClear, ExtendKnex, ExtendSchemaBuilder, ExtendTableBuilder, HmrModel, Main, Model, Op, OpAggrs, OpJoint, OpJointValues, OpNormal, OpNormalValues, OpValues, QueueDoubleDelete, ScheduleSoftDeletionPrune, ScopeModuleAOrm, ServiceCacheEntity, ServiceCacheQuery, ServiceColumns, ServiceColumnsCache, ServiceDatabase, ServiceDatabaseAsyncLocalStorage, ServiceDatabaseClient, ServiceDb, ServiceEntityResolver, ServiceModelResolver, ServiceRelations, ServiceTransaction, ServiceTransactionAsyncLocalStorage, ServiceTransactionConsistency, ServiceTransactionFiber, ServiceTransactionState, SymbolCacheModelCacheInstances, SymbolCacheModelsClear, SymbolKeyEntity, SymbolKeyEntityMeta, SymbolKeyFieldsMore, SymbolKeyModelOptions, TransactionIsolationLevelsMap, buildWhere, clearAllCacheModelsClear, clearCacheModelCacheInstance, config, configDefault, errors, getCacheModelCacheInstances, getCacheModelsClear, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VonaApplication } from 'vona';
|
|
2
|
+
import type { IModelRecord } from '../types/onion/model.ts';
|
|
3
|
+
import type { TypeModelClassLikeGeneral } from '../types/relations.ts';
|
|
4
|
+
export declare const SymbolCacheModelsClear: unique symbol;
|
|
5
|
+
export declare const SymbolCacheModelCacheInstances: unique symbol;
|
|
6
|
+
export declare function clearAllCacheModelsClear(app: VonaApplication): void;
|
|
7
|
+
export declare function clearCacheModelCacheInstance(app: VonaApplication, beanFullName: string): Promise<void>;
|
|
8
|
+
export declare function getCacheModelCacheInstances(app: VonaApplication): any;
|
|
9
|
+
export declare function getCacheModelsClear(app: VonaApplication): Record<keyof IModelRecord, TypeModelClassLikeGeneral[]>;
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IDecoratorSummerCacheOptions } from 'vona-module-a-summer';
|
|
1
|
+
import type { BeanSummerCacheBase, IDecoratorSummerCacheOptions } from 'vona-module-a-summer';
|
|
2
2
|
import type { BeanModelCache } from '../bean/bean.model/bean.model_cache.ts';
|
|
3
3
|
import type { TypeModelCacheType } from '../types/model.ts';
|
|
4
4
|
import type { ITableRecord } from '../types/onion/table.ts';
|
|
@@ -10,7 +10,7 @@ export declare class ModelCacheBase extends BeanBase {
|
|
|
10
10
|
private _cacheType;
|
|
11
11
|
protected __init__(model: BeanModelCache, cacheType: TypeModelCacheType): void;
|
|
12
12
|
private get scopeOrm();
|
|
13
|
-
getInstance(table: keyof ITableRecord):
|
|
13
|
+
getInstance(table: keyof ITableRecord): BeanSummerCacheBase;
|
|
14
14
|
getName(table: keyof ITableRecord): string;
|
|
15
15
|
get options(): false | IDecoratorSummerCacheOptions;
|
|
16
16
|
get enabled(): any;
|
|
@@ -23,7 +23,7 @@ export declare class ServiceDatabaseClient extends BeanMutateBase {
|
|
|
23
23
|
clientName: any;
|
|
24
24
|
clientConfig: any;
|
|
25
25
|
}): Promise<void>;
|
|
26
|
-
protected
|
|
26
|
+
protected onRemoveInstance({ clientName }: {
|
|
27
27
|
clientName: any;
|
|
28
28
|
}): Promise<void>;
|
|
29
29
|
private __load;
|
package/dist/types/database.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ declare module 'vona' {
|
|
|
36
36
|
interface VonaConfigEnv {
|
|
37
37
|
DATABASE_DEFAULT_CLIENT: string | undefined;
|
|
38
38
|
DATABASE_CLIENT_SQLITE3_FILENAME: string | undefined;
|
|
39
|
-
DATABASE_CLIENT_SQLITE3_NATIVEBINDING: string | undefined;
|
|
39
|
+
DATABASE_CLIENT_SQLITE3_NATIVEBINDING: string | 'true' | 'false' | undefined;
|
|
40
40
|
DATABASE_CLIENT_PG_HOST: string | undefined;
|
|
41
41
|
DATABASE_CLIENT_PG_PORT: string | undefined;
|
|
42
42
|
DATABASE_CLIENT_PG_USER: string | undefined;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vona-module-a-orm",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.87",
|
|
5
5
|
"title": "a-orm",
|
|
6
6
|
"vonaModule": {
|
|
7
7
|
"capabilities": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
],
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"knex": "^3.1.0",
|
|
64
|
-
"table-identity": "^1.0.
|
|
64
|
+
"table-identity": "^1.0.13"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"clean-package": "^2.2.0",
|