vona-module-a-orm 5.0.58 → 5.0.59
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 +0 -42
- package/dist/index.js +166 -213
- package/dist/service/database.d.ts +3 -4
- package/dist/service/databaseClient_.d.ts +11 -6
- package/package.json +1 -1
- package/dist/bean/broadcast.databaseClientDispose.d.ts +0 -9
- package/dist/bean/broadcast.databaseClientReload.d.ts +0 -12
- package/dist/bean/event.databaseClientDispose.d.ts +0 -8
- package/dist/bean/event.databaseClientReload.d.ts +0 -11
|
@@ -86,14 +86,10 @@ declare module 'vona' {
|
|
|
86
86
|
/** service: end */
|
|
87
87
|
/** broadcast: begin */
|
|
88
88
|
export * from '../bean/broadcast.columnsClear.ts';
|
|
89
|
-
export * from '../bean/broadcast.databaseClientDispose.ts';
|
|
90
|
-
export * from '../bean/broadcast.databaseClientReload.ts';
|
|
91
89
|
import { type IDecoratorBroadcastOptions } from 'vona-module-a-broadcast';
|
|
92
90
|
declare module 'vona-module-a-broadcast' {
|
|
93
91
|
interface IBroadcastRecord {
|
|
94
92
|
'a-orm:columnsClear': IDecoratorBroadcastOptions;
|
|
95
|
-
'a-orm:databaseClientDispose': IDecoratorBroadcastOptions;
|
|
96
|
-
'a-orm:databaseClientReload': IDecoratorBroadcastOptions;
|
|
97
93
|
}
|
|
98
94
|
}
|
|
99
95
|
declare module 'vona-module-a-orm' {
|
|
@@ -103,35 +99,17 @@ declare module 'vona-module-a-orm' {
|
|
|
103
99
|
get $beanFullName(): 'a-orm.broadcast.columnsClear';
|
|
104
100
|
get $onionName(): 'a-orm:columnsClear';
|
|
105
101
|
}
|
|
106
|
-
interface BroadcastDatabaseClientDispose {
|
|
107
|
-
}
|
|
108
|
-
interface BroadcastDatabaseClientDispose {
|
|
109
|
-
get $beanFullName(): 'a-orm.broadcast.databaseClientDispose';
|
|
110
|
-
get $onionName(): 'a-orm:databaseClientDispose';
|
|
111
|
-
}
|
|
112
|
-
interface BroadcastDatabaseClientReload {
|
|
113
|
-
}
|
|
114
|
-
interface BroadcastDatabaseClientReload {
|
|
115
|
-
get $beanFullName(): 'a-orm.broadcast.databaseClientReload';
|
|
116
|
-
get $onionName(): 'a-orm:databaseClientReload';
|
|
117
|
-
}
|
|
118
102
|
}
|
|
119
103
|
/** broadcast: end */
|
|
120
104
|
/** broadcast: begin */
|
|
121
105
|
import type { BroadcastColumnsClear } from '../bean/broadcast.columnsClear.ts';
|
|
122
|
-
import type { BroadcastDatabaseClientDispose } from '../bean/broadcast.databaseClientDispose.ts';
|
|
123
|
-
import type { BroadcastDatabaseClientReload } from '../bean/broadcast.databaseClientReload.ts';
|
|
124
106
|
export interface IModuleBroadcast {
|
|
125
107
|
'columnsClear': BroadcastColumnsClear;
|
|
126
|
-
'databaseClientDispose': BroadcastDatabaseClientDispose;
|
|
127
|
-
'databaseClientReload': BroadcastDatabaseClientReload;
|
|
128
108
|
}
|
|
129
109
|
/** broadcast: end */
|
|
130
110
|
/** event: begin */
|
|
131
111
|
export * from '../bean/event.clientNameReal.ts';
|
|
132
112
|
export * from '../bean/event.columnsClear.ts';
|
|
133
|
-
export * from '../bean/event.databaseClientDispose.ts';
|
|
134
|
-
export * from '../bean/event.databaseClientReload.ts';
|
|
135
113
|
import 'vona';
|
|
136
114
|
declare module 'vona' {
|
|
137
115
|
}
|
|
@@ -148,44 +126,24 @@ declare module 'vona-module-a-orm' {
|
|
|
148
126
|
get $beanFullName(): 'a-orm.event.columnsClear';
|
|
149
127
|
get $onionName(): 'a-orm:columnsClear';
|
|
150
128
|
}
|
|
151
|
-
interface EventDatabaseClientDispose {
|
|
152
|
-
}
|
|
153
|
-
interface EventDatabaseClientDispose {
|
|
154
|
-
get $beanFullName(): 'a-orm.event.databaseClientDispose';
|
|
155
|
-
get $onionName(): 'a-orm:databaseClientDispose';
|
|
156
|
-
}
|
|
157
|
-
interface EventDatabaseClientReload {
|
|
158
|
-
}
|
|
159
|
-
interface EventDatabaseClientReload {
|
|
160
|
-
get $beanFullName(): 'a-orm.event.databaseClientReload';
|
|
161
|
-
get $onionName(): 'a-orm:databaseClientReload';
|
|
162
|
-
}
|
|
163
129
|
}
|
|
164
130
|
/** event: end */
|
|
165
131
|
/** event: begin */
|
|
166
132
|
import type { EventClientNameReal } from '../bean/event.clientNameReal.ts';
|
|
167
133
|
import type { EventColumnsClear } from '../bean/event.columnsClear.ts';
|
|
168
|
-
import type { EventDatabaseClientDispose } from '../bean/event.databaseClientDispose.ts';
|
|
169
|
-
import type { EventDatabaseClientReload } from '../bean/event.databaseClientReload.ts';
|
|
170
134
|
export interface IModuleEvent {
|
|
171
135
|
'clientNameReal': EventClientNameReal;
|
|
172
136
|
'columnsClear': EventColumnsClear;
|
|
173
|
-
'databaseClientDispose': EventDatabaseClientDispose;
|
|
174
|
-
'databaseClientReload': EventDatabaseClientReload;
|
|
175
137
|
}
|
|
176
138
|
/** event: end */
|
|
177
139
|
/** event: begin */
|
|
178
140
|
import type { TypeEventClientNameRealData, TypeEventClientNameRealResult } from '../bean/event.clientNameReal.ts';
|
|
179
141
|
import type { TypeEventColumnsClearData, TypeEventColumnsClearResult } from '../bean/event.columnsClear.ts';
|
|
180
|
-
import type { TypeEventDatabaseClientDisposeData, TypeEventDatabaseClientDisposeResult } from '../bean/event.databaseClientDispose.ts';
|
|
181
|
-
import type { TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult } from '../bean/event.databaseClientReload.ts';
|
|
182
142
|
import type { EventOn } from 'vona-module-a-event';
|
|
183
143
|
declare module 'vona-module-a-event' {
|
|
184
144
|
interface IEventRecord {
|
|
185
145
|
'a-orm:clientNameReal': EventOn<TypeEventClientNameRealData, TypeEventClientNameRealResult>;
|
|
186
146
|
'a-orm:columnsClear': EventOn<TypeEventColumnsClearData, TypeEventColumnsClearResult>;
|
|
187
|
-
'a-orm:databaseClientDispose': EventOn<TypeEventDatabaseClientDisposeData, TypeEventDatabaseClientDisposeResult>;
|
|
188
|
-
'a-orm:databaseClientReload': EventOn<TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult>;
|
|
189
147
|
}
|
|
190
148
|
}
|
|
191
149
|
/** event: end */
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import BigNumber$1, { BigNumber } from 'bignumber.js';
|
|
2
|
-
import { BeanInfo, BeanAopMethodBase, BeanBase, deepExtend,
|
|
2
|
+
import { BeanInfo, BeanAopMethodBase, BeanBase, deepExtend, appResource, Virtual, beanFullNameFromOnionName, cast, 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';
|
|
5
5
|
import { AsyncLocalStorage, AsyncResource } from 'node:async_hooks';
|
|
6
6
|
import knex from 'knex';
|
|
7
|
+
import { BeanMutateBase } from 'vona-module-a-beanmutate';
|
|
7
8
|
import { isNil, safeBoolean, isClass, ensureArray, hashkey } from '@cabloy/utils';
|
|
8
9
|
import { swapDeps } from '@cabloy/deps';
|
|
9
10
|
import { prepareClassType, getTargetDecoratorRules, getTargetDecoratorRuleColumnsMap, Api, v, OrderMaxBase, OrderCoreBase, getSchemaDynamic, SymbolSchemaDynamicRefId, addSchemaDynamic, mergeFieldsOpenapiMetadata } from 'vona-module-a-openapi';
|
|
@@ -17,21 +18,21 @@ import { configAllWithIgnoreNull, configAll, configRedisWithIgnoreNull, configRe
|
|
|
17
18
|
import { ServiceDatabaseAsyncLocalStorage as ServiceDatabaseAsyncLocalStorage$1, ServiceTransactionConsistency as ServiceTransactionConsistency_ } from 'vona-module-a-orm';
|
|
18
19
|
import { mutate } from 'mutate-on-copy';
|
|
19
20
|
|
|
20
|
-
var _dec$
|
|
21
|
-
let AopMethodTransaction = (_dec$
|
|
21
|
+
var _dec$v, _dec2$v, _class$v;
|
|
22
|
+
let AopMethodTransaction = (_dec$v = AopMethod(), _dec2$v = BeanInfo({
|
|
22
23
|
module: "a-orm"
|
|
23
|
-
}), _dec$
|
|
24
|
+
}), _dec$v(_class$v = _dec2$v(_class$v = class AopMethodTransaction extends BeanAopMethodBase {
|
|
24
25
|
execute(options, _args, next, _receiver, _prop) {
|
|
25
26
|
return this.bean.database.current.transaction.begin(() => {
|
|
26
27
|
return next();
|
|
27
28
|
}, options);
|
|
28
29
|
}
|
|
29
|
-
}) || _class$
|
|
30
|
+
}) || _class$v) || _class$v);
|
|
30
31
|
|
|
31
|
-
var _dec$
|
|
32
|
-
let ServiceDatabaseAsyncLocalStorage = (_dec$
|
|
32
|
+
var _dec$u, _dec2$u, _class$u;
|
|
33
|
+
let ServiceDatabaseAsyncLocalStorage = (_dec$u = Service(), _dec2$u = BeanInfo({
|
|
33
34
|
module: "a-orm"
|
|
34
|
-
}), _dec$
|
|
35
|
+
}), _dec$u(_class$u = _dec2$u(_class$u = class ServiceDatabaseAsyncLocalStorage extends BeanBase {
|
|
35
36
|
constructor(...args) {
|
|
36
37
|
super(...args);
|
|
37
38
|
this.dbStorage = void 0;
|
|
@@ -50,14 +51,14 @@ let ServiceDatabaseAsyncLocalStorage = (_dec$y = Service(), _dec2$y = BeanInfo({
|
|
|
50
51
|
return fn();
|
|
51
52
|
});
|
|
52
53
|
}
|
|
53
|
-
}) || _class$
|
|
54
|
+
}) || _class$u) || _class$u);
|
|
54
55
|
|
|
55
|
-
var _dec$
|
|
56
|
+
var _dec$t, _dec2$t, _class$t;
|
|
56
57
|
const SymbolColumnsCache = Symbol('SymbolColumnsCache');
|
|
57
58
|
const SymbolColumnsDefaultCache = Symbol('SymbolColumnsDefaultCache');
|
|
58
|
-
let ServiceColumnsCache = (_dec$
|
|
59
|
+
let ServiceColumnsCache = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
59
60
|
module: "a-orm"
|
|
60
|
-
}), _dec$
|
|
61
|
+
}), _dec$t(_class$t = _dec2$t(_class$t = class ServiceColumnsCache extends BeanBase {
|
|
61
62
|
constructor(...args) {
|
|
62
63
|
super(...args);
|
|
63
64
|
this.clientName = void 0;
|
|
@@ -112,12 +113,12 @@ let ServiceColumnsCache = (_dec$x = Service(), _dec2$x = BeanInfo({
|
|
|
112
113
|
return exists;
|
|
113
114
|
}
|
|
114
115
|
}
|
|
115
|
-
}) || _class$
|
|
116
|
+
}) || _class$t) || _class$t);
|
|
116
117
|
|
|
117
|
-
var _dec$
|
|
118
|
-
let ServiceColumns = (_dec$
|
|
118
|
+
var _dec$s, _dec2$s, _class$s;
|
|
119
|
+
let ServiceColumns = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
119
120
|
module: "a-orm"
|
|
120
|
-
}), _dec$
|
|
121
|
+
}), _dec$s(_class$s = _dec2$s(_class$s = class ServiceColumns extends BeanBase {
|
|
121
122
|
constructor(...args) {
|
|
122
123
|
super(...args);
|
|
123
124
|
this._db = void 0;
|
|
@@ -168,7 +169,7 @@ let ServiceColumns = (_dec$w = Service(), _dec2$w = BeanInfo({
|
|
|
168
169
|
columnsClear(tableName) {
|
|
169
170
|
return this.scope.service.database.columnsClear(this.db.clientName, tableName);
|
|
170
171
|
}
|
|
171
|
-
}) || _class$
|
|
172
|
+
}) || _class$s) || _class$s);
|
|
172
173
|
|
|
173
174
|
const TransactionIsolationLevelsMap = {
|
|
174
175
|
DEFAULT: undefined,
|
|
@@ -181,10 +182,10 @@ const TransactionIsolationLevelsMap = {
|
|
|
181
182
|
|
|
182
183
|
// export type TransactionPropagation=''
|
|
183
184
|
|
|
184
|
-
var _dec$
|
|
185
|
-
let ServiceDatabase = (_dec$
|
|
185
|
+
var _dec$r, _dec2$r, _class$r;
|
|
186
|
+
let ServiceDatabase = (_dec$r = Service(), _dec2$r = BeanInfo({
|
|
186
187
|
module: "a-orm"
|
|
187
|
-
}), _dec$
|
|
188
|
+
}), _dec$r(_class$r = _dec2$r(_class$r = class ServiceDatabase extends BeanBase {
|
|
188
189
|
get configDatabase() {
|
|
189
190
|
return this.app.config.database;
|
|
190
191
|
}
|
|
@@ -269,52 +270,50 @@ let ServiceDatabase = (_dec$v = Service(), _dec2$v = BeanInfo({
|
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
272
|
columnsClear(clientName, tableName) {
|
|
272
|
-
this.
|
|
273
|
+
this.columnsClearWorker(clientName, tableName);
|
|
273
274
|
this.scope.broadcast.columnsClear.emit({
|
|
274
275
|
clientName,
|
|
275
276
|
tableName
|
|
276
277
|
});
|
|
277
278
|
}
|
|
278
|
-
|
|
279
|
+
columnsClearWorker(clientName, tableName) {
|
|
279
280
|
this.scope.event.columnsClear.emitSync({
|
|
280
281
|
clientName: this.prepareClientNameReal(clientName),
|
|
281
282
|
tableName
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
|
-
async reloadClients(clientName, clientConfig
|
|
285
|
-
|
|
286
|
-
this.
|
|
285
|
+
async reloadClients(clientName, clientConfig) {
|
|
286
|
+
clientName = this.prepareClientName(clientName);
|
|
287
|
+
await this.bean.mutate.reloadInstances(ServiceDatabaseClient, {
|
|
287
288
|
clientName,
|
|
288
|
-
clientConfig
|
|
289
|
-
extraData
|
|
289
|
+
clientConfig
|
|
290
290
|
});
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
291
|
+
this.columnsClear(clientName);
|
|
292
|
+
}
|
|
293
|
+
async reloadClientsWorker(clientName, clientConfig) {
|
|
294
|
+
clientName = this.prepareClientName(clientName);
|
|
295
|
+
await this.bean.mutate.reloadInstancesWorker({
|
|
296
|
+
beanFullName: appResource.getBeanFullName(ServiceDatabaseClient),
|
|
297
|
+
data: {
|
|
298
|
+
clientName,
|
|
299
|
+
clientConfig
|
|
300
|
+
}
|
|
297
301
|
});
|
|
298
|
-
this.
|
|
302
|
+
this.columnsClearWorker(clientName);
|
|
299
303
|
}
|
|
300
304
|
async disposeClients(clientName) {
|
|
301
|
-
|
|
302
|
-
this.
|
|
305
|
+
clientName = this.prepareClientName(clientName);
|
|
306
|
+
await this.bean.mutate.disposeInstances(ServiceDatabaseClient, {
|
|
303
307
|
clientName
|
|
304
308
|
});
|
|
309
|
+
this.columnsClear(clientName);
|
|
305
310
|
}
|
|
306
|
-
|
|
307
|
-
await this.scope.event.databaseClientDispose.emit({
|
|
308
|
-
clientName: this.prepareClientName(clientName)
|
|
309
|
-
});
|
|
310
|
-
this.__columnsClearRaw(clientName);
|
|
311
|
-
}
|
|
312
|
-
}) || _class$v) || _class$v);
|
|
311
|
+
}) || _class$r) || _class$r);
|
|
313
312
|
|
|
314
|
-
var _dec$
|
|
315
|
-
let ServiceTransactionConsistency = (_dec$
|
|
313
|
+
var _dec$q, _dec2$q, _class$q;
|
|
314
|
+
let ServiceTransactionConsistency = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
316
315
|
module: "a-orm"
|
|
317
|
-
}), _dec$
|
|
316
|
+
}), _dec$q(_class$q = _dec2$q(_class$q = class ServiceTransactionConsistency extends BeanBase {
|
|
318
317
|
constructor(...args) {
|
|
319
318
|
super(...args);
|
|
320
319
|
this._commitCallbacks = [];
|
|
@@ -342,12 +341,12 @@ let ServiceTransactionConsistency = (_dec$u = Service(), _dec2$u = BeanInfo({
|
|
|
342
341
|
}
|
|
343
342
|
this._commitCallbacks = [];
|
|
344
343
|
}
|
|
345
|
-
}) || _class$
|
|
344
|
+
}) || _class$q) || _class$q);
|
|
346
345
|
|
|
347
|
-
var _dec$
|
|
348
|
-
let ServiceTransactionFiber = (_dec$
|
|
346
|
+
var _dec$p, _dec2$p, _class$p;
|
|
347
|
+
let ServiceTransactionFiber = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
349
348
|
module: "a-orm"
|
|
350
|
-
}), _dec$
|
|
349
|
+
}), _dec$p(_class$p = _dec2$p(_class$p = class ServiceTransactionFiber extends BeanBase {
|
|
351
350
|
constructor(...args) {
|
|
352
351
|
super(...args);
|
|
353
352
|
this._connection = void 0;
|
|
@@ -376,12 +375,12 @@ let ServiceTransactionFiber = (_dec$t = Service(), _dec2$t = BeanInfo({
|
|
|
376
375
|
await this._transactionConsistency.compensatesDone();
|
|
377
376
|
this._connection = undefined;
|
|
378
377
|
}
|
|
379
|
-
}) || _class$
|
|
378
|
+
}) || _class$p) || _class$p);
|
|
380
379
|
|
|
381
|
-
var _dec$
|
|
382
|
-
let ServiceTransactionState = (_dec$
|
|
380
|
+
var _dec$o, _dec2$o, _class$o;
|
|
381
|
+
let ServiceTransactionState = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
383
382
|
module: "a-orm"
|
|
384
|
-
}), _dec$
|
|
383
|
+
}), _dec$o(_class$o = _dec2$o(_class$o = class ServiceTransactionState extends BeanBase {
|
|
385
384
|
constructor(...args) {
|
|
386
385
|
super(...args);
|
|
387
386
|
this._fibers = {};
|
|
@@ -403,12 +402,12 @@ let ServiceTransactionState = (_dec$s = Service(), _dec2$s = BeanInfo({
|
|
|
403
402
|
const selector = this.serviceDatabase.prepareClientNameSelector(dbInfo);
|
|
404
403
|
delete this._fibers[selector];
|
|
405
404
|
}
|
|
406
|
-
}) || _class$
|
|
405
|
+
}) || _class$o) || _class$o);
|
|
407
406
|
|
|
408
|
-
var _dec$
|
|
409
|
-
let ServiceTransactionAsyncLocalStorage = (_dec$
|
|
407
|
+
var _dec$n, _dec2$n, _class$n;
|
|
408
|
+
let ServiceTransactionAsyncLocalStorage = (_dec$n = Service(), _dec2$n = BeanInfo({
|
|
410
409
|
module: "a-orm"
|
|
411
|
-
}), _dec$
|
|
410
|
+
}), _dec$n(_class$n = _dec2$n(_class$n = class ServiceTransactionAsyncLocalStorage extends BeanBase {
|
|
412
411
|
constructor(...args) {
|
|
413
412
|
super(...args);
|
|
414
413
|
this.transactionStorage = void 0;
|
|
@@ -429,12 +428,12 @@ let ServiceTransactionAsyncLocalStorage = (_dec$r = Service(), _dec2$r = BeanInf
|
|
|
429
428
|
return fn();
|
|
430
429
|
});
|
|
431
430
|
}
|
|
432
|
-
}) || _class$
|
|
431
|
+
}) || _class$n) || _class$n);
|
|
433
432
|
|
|
434
|
-
var _dec$
|
|
435
|
-
let ServiceTransaction = (_dec$
|
|
433
|
+
var _dec$m, _dec2$m, _class$m;
|
|
434
|
+
let ServiceTransaction = (_dec$m = Service(), _dec2$m = BeanInfo({
|
|
436
435
|
module: "a-orm"
|
|
437
|
-
}), _dec$
|
|
436
|
+
}), _dec$m(_class$m = _dec2$m(_class$m = class ServiceTransaction extends BeanBase {
|
|
438
437
|
constructor(...args) {
|
|
439
438
|
super(...args);
|
|
440
439
|
this._db = void 0;
|
|
@@ -553,7 +552,7 @@ let ServiceTransaction = (_dec$q = Service(), _dec2$q = BeanInfo({
|
|
|
553
552
|
}
|
|
554
553
|
return res;
|
|
555
554
|
}
|
|
556
|
-
}) || _class$
|
|
555
|
+
}) || _class$m) || _class$m);
|
|
557
556
|
function _translateTransactionOptions(options) {
|
|
558
557
|
if (!options) return undefined;
|
|
559
558
|
return {
|
|
@@ -562,10 +561,10 @@ function _translateTransactionOptions(options) {
|
|
|
562
561
|
};
|
|
563
562
|
}
|
|
564
563
|
|
|
565
|
-
var _dec$
|
|
566
|
-
let ServiceDb = (_dec$
|
|
564
|
+
var _dec$l, _dec2$l, _class$l;
|
|
565
|
+
let ServiceDb = (_dec$l = Service(), _dec2$l = BeanInfo({
|
|
567
566
|
module: "a-orm"
|
|
568
|
-
}), _dec$
|
|
567
|
+
}), _dec$l(_class$l = _dec2$l(_class$l = class ServiceDb extends BeanBase {
|
|
569
568
|
constructor(...args) {
|
|
570
569
|
super(...args);
|
|
571
570
|
this._client = void 0;
|
|
@@ -620,12 +619,12 @@ let ServiceDb = (_dec$p = Service(), _dec2$p = BeanInfo({
|
|
|
620
619
|
compensate(cb) {
|
|
621
620
|
return this.transaction.compensate(cb);
|
|
622
621
|
}
|
|
623
|
-
}) || _class$
|
|
622
|
+
}) || _class$l) || _class$l);
|
|
624
623
|
|
|
625
|
-
var _dec$
|
|
626
|
-
let ServiceDatabaseClient = (_dec$
|
|
624
|
+
var _dec$k, _dec2$k, _class$k;
|
|
625
|
+
let ServiceDatabaseClient = (_dec$k = Service(), _dec2$k = BeanInfo({
|
|
627
626
|
module: "a-orm"
|
|
628
|
-
}), _dec$
|
|
627
|
+
}), _dec$k(_class$k = _dec2$k(_class$k = class ServiceDatabaseClient extends BeanMutateBase {
|
|
629
628
|
constructor(...args) {
|
|
630
629
|
super(...args);
|
|
631
630
|
this.level = void 0;
|
|
@@ -634,8 +633,6 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
634
633
|
this.clientConfig = void 0;
|
|
635
634
|
this._knex = void 0;
|
|
636
635
|
this._db = void 0;
|
|
637
|
-
this._onDatabaseClientReloadCancel = void 0;
|
|
638
|
-
this._onDatabaseClientDisposeCancel = void 0;
|
|
639
636
|
}
|
|
640
637
|
get configDatabase() {
|
|
641
638
|
return this.app.config.database;
|
|
@@ -647,37 +644,33 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
647
644
|
return this._db;
|
|
648
645
|
}
|
|
649
646
|
__init__(clientNameSelector, clientConfig) {
|
|
647
|
+
super.__init__();
|
|
650
648
|
// db
|
|
651
649
|
this._db = this.bean._newBean(ServiceDb, this);
|
|
652
650
|
// load
|
|
653
651
|
this.__load(clientNameSelector, clientConfig);
|
|
654
|
-
// event: databaseClientReload
|
|
655
|
-
this._onDatabaseClientReloadCancel = this.scope.event.databaseClientReload.on(async ({
|
|
656
|
-
clientName,
|
|
657
|
-
clientConfig
|
|
658
|
-
}, next) => {
|
|
659
|
-
if (clientName === this.clientName) {
|
|
660
|
-
await this.reload(clientConfig);
|
|
661
|
-
}
|
|
662
|
-
await next();
|
|
663
|
-
});
|
|
664
|
-
// event: databaseClientDispose
|
|
665
|
-
this._onDatabaseClientDisposeCancel = this.scope.event.databaseClientDispose.on(async ({
|
|
666
|
-
clientName
|
|
667
|
-
}, next) => {
|
|
668
|
-
if (clientName === this.clientName) {
|
|
669
|
-
await this.bean.disposeInstance(this.$beanInstanceKey);
|
|
670
|
-
}
|
|
671
|
-
await next();
|
|
672
|
-
});
|
|
673
652
|
}
|
|
674
653
|
async __dispose__() {
|
|
654
|
+
await super.__dispose__();
|
|
675
655
|
this._db = undefined;
|
|
676
656
|
await this.__close();
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
657
|
+
}
|
|
658
|
+
async onReloadInstance({
|
|
659
|
+
clientName,
|
|
660
|
+
clientConfig
|
|
661
|
+
}) {
|
|
662
|
+
if (clientName === this.clientName) {
|
|
663
|
+
await this.reload(clientConfig);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
async onDisposeInstance({
|
|
667
|
+
clientName
|
|
668
|
+
}) {
|
|
669
|
+
if (clientName === this.clientName) {
|
|
670
|
+
await super.onDisposeInstance({
|
|
671
|
+
clientName
|
|
672
|
+
});
|
|
673
|
+
}
|
|
681
674
|
}
|
|
682
675
|
__load(clientNameSelector, clientConfig) {
|
|
683
676
|
// name
|
|
@@ -717,7 +710,7 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
717
710
|
}
|
|
718
711
|
|
|
719
712
|
// only used by startup, so no consider that workers broadcast
|
|
720
|
-
async
|
|
713
|
+
async changeConfigConnectionAndReloadWorker(databaseName) {
|
|
721
714
|
// set databaseName
|
|
722
715
|
const connDatabaseName = this._prepareDatabaseName(databaseName);
|
|
723
716
|
// set config
|
|
@@ -727,15 +720,15 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
727
720
|
// only used by startup, so no consider that workers broadcast
|
|
728
721
|
this.configDatabase.clients[this.clientName] = config;
|
|
729
722
|
// reload
|
|
730
|
-
await this.scope.service.database.
|
|
723
|
+
await this.scope.service.database.reloadClientsWorker(this.clientName, config);
|
|
731
724
|
// await this.scope.service.database.reloadClients(this.clientName, config);
|
|
732
725
|
}
|
|
733
|
-
}) || _class$
|
|
726
|
+
}) || _class$k) || _class$k);
|
|
734
727
|
|
|
735
|
-
var _dec$
|
|
736
|
-
let BeanDatabase = (_dec$
|
|
728
|
+
var _dec$j, _dec2$j, _class$j;
|
|
729
|
+
let BeanDatabase = (_dec$j = Bean(), _dec2$j = BeanInfo({
|
|
737
730
|
module: "a-orm"
|
|
738
|
-
}), _dec$
|
|
731
|
+
}), _dec$j(_class$j = _dec2$j(_class$j = class BeanDatabase extends BeanBase {
|
|
739
732
|
get current() {
|
|
740
733
|
return this.bean._getBean(ServiceDatabaseAsyncLocalStorage).current;
|
|
741
734
|
}
|
|
@@ -765,12 +758,12 @@ let BeanDatabase = (_dec$n = Bean(), _dec2$n = BeanInfo({
|
|
|
765
758
|
return this.bean._getBean(ServiceTransactionAsyncLocalStorage).run(fn);
|
|
766
759
|
});
|
|
767
760
|
}
|
|
768
|
-
}) || _class$
|
|
761
|
+
}) || _class$j) || _class$j);
|
|
769
762
|
|
|
770
|
-
var _dec$
|
|
771
|
-
let BeanDatabaseDialectBase = (_dec$
|
|
763
|
+
var _dec$i, _dec2$i, _dec3$7, _class$i;
|
|
764
|
+
let BeanDatabaseDialectBase = (_dec$i = Bean(), _dec2$i = Virtual(), _dec3$7 = BeanInfo({
|
|
772
765
|
module: "a-orm"
|
|
773
|
-
}), _dec$
|
|
766
|
+
}), _dec$i(_class$i = _dec2$i(_class$i = _dec3$7(_class$i = class BeanDatabaseDialectBase extends BeanBase {
|
|
774
767
|
getConfigBase() {
|
|
775
768
|
return undefined;
|
|
776
769
|
}
|
|
@@ -830,7 +823,7 @@ let BeanDatabaseDialectBase = (_dec$m = Bean(), _dec2$m = Virtual(), _dec3$7 = B
|
|
|
830
823
|
_columnTypePrefixes(type, prefixes) {
|
|
831
824
|
return prefixes.some(prefix => type.includes(prefix));
|
|
832
825
|
}
|
|
833
|
-
}) || _class$
|
|
826
|
+
}) || _class$i) || _class$i) || _class$i);
|
|
834
827
|
|
|
835
828
|
const OpAggrs = ['count', 'sum', 'avg', 'max', 'min'];
|
|
836
829
|
const OpJoint = {
|
|
@@ -1236,69 +1229,69 @@ function _initializerDefineProperty(e, i, r, l) {
|
|
|
1236
1229
|
});
|
|
1237
1230
|
}
|
|
1238
1231
|
|
|
1239
|
-
var _dec$
|
|
1232
|
+
var _dec$h, _dec2$h, _dec3$6, _dec4$4, _dec5$1, _dec6$1, _dec7$1, _class$h, _descriptor$4, _descriptor2$2, _descriptor3$1;
|
|
1240
1233
|
const app$1 = useApp();
|
|
1241
1234
|
const ormConfig$1 = app$1.util.getModuleConfigRaw('a-orm');
|
|
1242
1235
|
const ordersDefault = ormConfig$1?.rest?.query?.orders?.default ?? 'createdAt,desc';
|
|
1243
|
-
let DtoQueryBase = (_dec$
|
|
1236
|
+
let DtoQueryBase = (_dec$h = Api.field(v.optional(), v.array(String, {
|
|
1244
1237
|
separator: ','
|
|
1245
|
-
})), _dec2$
|
|
1238
|
+
})), _dec2$h = 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 = Api.field(v.optional(), z.union([z.string(), z.array(z.array(z.string()))])), _dec7$1 = Reflect.metadata("design:type", Object), _class$h = class DtoQueryBase {
|
|
1246
1239
|
constructor() {
|
|
1247
1240
|
_initializerDefineProperty(this, "columns", _descriptor$4, this);
|
|
1248
1241
|
_initializerDefineProperty(this, "where", _descriptor2$2, this);
|
|
1249
1242
|
_initializerDefineProperty(this, "orders", _descriptor3$1, this);
|
|
1250
1243
|
}
|
|
1251
|
-
}, _descriptor$4 = _applyDecoratedDescriptor(_class$
|
|
1244
|
+
}, _descriptor$4 = _applyDecoratedDescriptor(_class$h.prototype, "columns", [_dec$h, _dec2$h], {
|
|
1252
1245
|
configurable: true,
|
|
1253
1246
|
enumerable: true,
|
|
1254
1247
|
writable: true,
|
|
1255
1248
|
initializer: null
|
|
1256
|
-
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$
|
|
1249
|
+
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$h.prototype, "where", [_dec3$6, _dec4$4], {
|
|
1257
1250
|
configurable: true,
|
|
1258
1251
|
enumerable: true,
|
|
1259
1252
|
writable: true,
|
|
1260
1253
|
initializer: null
|
|
1261
|
-
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$
|
|
1254
|
+
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$h.prototype, "orders", [_dec5$1, _dec6$1, _dec7$1], {
|
|
1262
1255
|
configurable: true,
|
|
1263
1256
|
enumerable: true,
|
|
1264
1257
|
writable: true,
|
|
1265
1258
|
initializer: null
|
|
1266
|
-
}), _class$
|
|
1259
|
+
}), _class$h);
|
|
1267
1260
|
|
|
1268
|
-
var _dec$
|
|
1261
|
+
var _dec$g, _dec2$g, _dec3$5, _dec4$3, _class$g, _descriptor$3, _descriptor2$1;
|
|
1269
1262
|
const app = useApp();
|
|
1270
1263
|
const ormConfig = app.util.getModuleConfigRaw('a-orm');
|
|
1271
1264
|
const pageSizeDefault = ormConfig?.rest?.query?.pageSize?.default ?? 20;
|
|
1272
1265
|
const pageSizeMax = ormConfig?.rest?.query?.pageSize?.max ?? 100;
|
|
1273
|
-
let DtoQueryPageBase = (_dec$
|
|
1266
|
+
let DtoQueryPageBase = (_dec$g = Api.field(z.number().min(1).default(1)), _dec2$g = 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$g = class DtoQueryPageBase extends DtoQueryBase {
|
|
1274
1267
|
constructor(...args) {
|
|
1275
1268
|
super(...args);
|
|
1276
1269
|
_initializerDefineProperty(this, "pageNo", _descriptor$3, this);
|
|
1277
1270
|
_initializerDefineProperty(this, "pageSize", _descriptor2$1, this);
|
|
1278
1271
|
}
|
|
1279
|
-
}, _descriptor$3 = _applyDecoratedDescriptor(_class$
|
|
1272
|
+
}, _descriptor$3 = _applyDecoratedDescriptor(_class$g.prototype, "pageNo", [_dec$g, _dec2$g], {
|
|
1280
1273
|
configurable: true,
|
|
1281
1274
|
enumerable: true,
|
|
1282
1275
|
writable: true,
|
|
1283
1276
|
initializer: null
|
|
1284
|
-
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$
|
|
1277
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$g.prototype, "pageSize", [_dec3$5, _dec4$3], {
|
|
1285
1278
|
configurable: true,
|
|
1286
1279
|
enumerable: true,
|
|
1287
1280
|
writable: true,
|
|
1288
1281
|
initializer: null
|
|
1289
|
-
}), _class$
|
|
1282
|
+
}), _class$g);
|
|
1290
1283
|
|
|
1291
1284
|
const SymbolKeyFieldsMore = Symbol('$fieldsMore');
|
|
1292
1285
|
|
|
1293
1286
|
class EntityBaseEmpty {}
|
|
1294
1287
|
|
|
1295
|
-
var _dec$
|
|
1296
|
-
let EntityBaseInner = (_dec$
|
|
1288
|
+
var _dec$f, _dec2$f, _dec3$4, _dec4$2, _dec5, _dec6, _dec7, _dec8, _class$f, _descriptor$2, _descriptor2, _descriptor3, _descriptor4;
|
|
1289
|
+
let EntityBaseInner = (_dec$f = Api.field(v.openapi({
|
|
1297
1290
|
title: $locale('CreatedAt'),
|
|
1298
1291
|
rest: {
|
|
1299
1292
|
order: OrderMaxBase - 2
|
|
1300
1293
|
}
|
|
1301
|
-
})), _dec2$
|
|
1294
|
+
})), _dec2$f = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec3$4 = Api.field(v.openapi({
|
|
1302
1295
|
title: $locale('UpdatedAt'),
|
|
1303
1296
|
rest: {
|
|
1304
1297
|
order: OrderMaxBase - 1
|
|
@@ -1313,7 +1306,7 @@ let EntityBaseInner = (_dec$j = Api.field(v.openapi({
|
|
|
1313
1306
|
rest: {
|
|
1314
1307
|
visible: false
|
|
1315
1308
|
}
|
|
1316
|
-
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$
|
|
1309
|
+
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$f = class EntityBaseInner extends EntityBaseEmpty {
|
|
1317
1310
|
constructor(...args) {
|
|
1318
1311
|
super(...args);
|
|
1319
1312
|
_initializerDefineProperty(this, "createdAt", _descriptor$2, this);
|
|
@@ -1321,63 +1314,63 @@ let EntityBaseInner = (_dec$j = Api.field(v.openapi({
|
|
|
1321
1314
|
_initializerDefineProperty(this, "deleted", _descriptor3, this);
|
|
1322
1315
|
_initializerDefineProperty(this, "iid", _descriptor4, this);
|
|
1323
1316
|
}
|
|
1324
|
-
}, _descriptor$2 = _applyDecoratedDescriptor(_class$
|
|
1317
|
+
}, _descriptor$2 = _applyDecoratedDescriptor(_class$f.prototype, "createdAt", [_dec$f, _dec2$f], {
|
|
1325
1318
|
configurable: true,
|
|
1326
1319
|
enumerable: true,
|
|
1327
1320
|
writable: true,
|
|
1328
1321
|
initializer: null
|
|
1329
|
-
}), _descriptor2 = _applyDecoratedDescriptor(_class$
|
|
1322
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class$f.prototype, "updatedAt", [_dec3$4, _dec4$2], {
|
|
1330
1323
|
configurable: true,
|
|
1331
1324
|
enumerable: true,
|
|
1332
1325
|
writable: true,
|
|
1333
1326
|
initializer: null
|
|
1334
|
-
}), _descriptor3 = _applyDecoratedDescriptor(_class$
|
|
1327
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class$f.prototype, "deleted", [_dec5, _dec6], {
|
|
1335
1328
|
configurable: true,
|
|
1336
1329
|
enumerable: true,
|
|
1337
1330
|
writable: true,
|
|
1338
1331
|
initializer: null
|
|
1339
|
-
}), _descriptor4 = _applyDecoratedDescriptor(_class$
|
|
1332
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class$f.prototype, "iid", [_dec7, _dec8], {
|
|
1340
1333
|
configurable: true,
|
|
1341
1334
|
enumerable: true,
|
|
1342
1335
|
writable: true,
|
|
1343
1336
|
initializer: null
|
|
1344
|
-
}), _class$
|
|
1337
|
+
}), _class$f);
|
|
1345
1338
|
|
|
1346
|
-
var _dec$
|
|
1347
|
-
let EntityBase = (_dec$
|
|
1339
|
+
var _dec$e, _dec2$e, _class$e, _descriptor$1;
|
|
1340
|
+
let EntityBase = (_dec$e = Api.field(v.openapi({
|
|
1348
1341
|
title: $locale('TableIdentity'),
|
|
1349
1342
|
rest: {
|
|
1350
1343
|
order: OrderCoreBase + 1
|
|
1351
1344
|
}
|
|
1352
|
-
}), v.tableIdentity()), _dec2$
|
|
1345
|
+
}), v.tableIdentity()), _dec2$e = Reflect.metadata("design:type", typeof TableIdentity === "undefined" ? Object : TableIdentity), _class$e = class EntityBase extends EntityBaseInner {
|
|
1353
1346
|
constructor(...args) {
|
|
1354
1347
|
super(...args);
|
|
1355
1348
|
_initializerDefineProperty(this, "id", _descriptor$1, this);
|
|
1356
1349
|
}
|
|
1357
|
-
}, _descriptor$1 = _applyDecoratedDescriptor(_class$
|
|
1350
|
+
}, _descriptor$1 = _applyDecoratedDescriptor(_class$e.prototype, "id", [_dec$e, _dec2$e], {
|
|
1358
1351
|
configurable: true,
|
|
1359
1352
|
enumerable: true,
|
|
1360
1353
|
writable: true,
|
|
1361
1354
|
initializer: null
|
|
1362
|
-
}), _class$
|
|
1355
|
+
}), _class$e);
|
|
1363
1356
|
|
|
1364
|
-
var _dec$
|
|
1365
|
-
let EntityBaseSimple = (_dec$
|
|
1357
|
+
var _dec$d, _dec2$d, _class$d, _descriptor;
|
|
1358
|
+
let EntityBaseSimple = (_dec$d = Api.field(v.openapi({
|
|
1366
1359
|
title: $locale('TableIdentity'),
|
|
1367
1360
|
rest: {
|
|
1368
1361
|
order: OrderCoreBase + 1
|
|
1369
1362
|
}
|
|
1370
|
-
})), _dec2$
|
|
1363
|
+
})), _dec2$d = Reflect.metadata("design:type", Number), _class$d = class EntityBaseSimple extends EntityBaseInner {
|
|
1371
1364
|
constructor(...args) {
|
|
1372
1365
|
super(...args);
|
|
1373
1366
|
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
1374
1367
|
}
|
|
1375
|
-
}, _descriptor = _applyDecoratedDescriptor(_class$
|
|
1368
|
+
}, _descriptor = _applyDecoratedDescriptor(_class$d.prototype, "id", [_dec$d, _dec2$d], {
|
|
1376
1369
|
configurable: true,
|
|
1377
1370
|
enumerable: true,
|
|
1378
1371
|
writable: true,
|
|
1379
1372
|
initializer: null
|
|
1380
|
-
}), _class$
|
|
1373
|
+
}), _class$d);
|
|
1381
1374
|
|
|
1382
1375
|
const SymbolKeyEntity = Symbol('$entity');
|
|
1383
1376
|
const SymbolKeyEntityMeta = Symbol('$entityMeta');
|
|
@@ -2170,10 +2163,10 @@ class BeanModelCrudTable extends BeanModelCrudInner {
|
|
|
2170
2163
|
}
|
|
2171
2164
|
}
|
|
2172
2165
|
|
|
2173
|
-
var _dec$
|
|
2174
|
-
let BeanModel = (_dec$
|
|
2166
|
+
var _dec$c, _dec2$c, _dec3$3, _class$c;
|
|
2167
|
+
let BeanModel = (_dec$c = Bean(), _dec2$c = Virtual(), _dec3$3 = BeanInfo({
|
|
2175
2168
|
module: "a-orm"
|
|
2176
|
-
}), _dec$
|
|
2169
|
+
}), _dec$c(_class$c = _dec2$c(_class$c = _dec3$3(_class$c = class BeanModel extends BeanModelCrudTable {}) || _class$c) || _class$c) || _class$c);
|
|
2177
2170
|
|
|
2178
2171
|
const SymbolCacheOptions = Symbol('SymbolCacheOptions');
|
|
2179
2172
|
const SymbolCacheEnabled = Symbol('SymbolCacheEnabled');
|
|
@@ -2248,10 +2241,10 @@ class ModelCacheBase extends BeanBase {
|
|
|
2248
2241
|
}
|
|
2249
2242
|
}
|
|
2250
2243
|
|
|
2251
|
-
var _dec$
|
|
2252
|
-
let ServiceCacheEntity = (_dec$
|
|
2244
|
+
var _dec$b, _dec2$b, _class$b;
|
|
2245
|
+
let ServiceCacheEntity = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
2253
2246
|
module: "a-orm"
|
|
2254
|
-
}), _dec$
|
|
2247
|
+
}), _dec$b(_class$b = _dec2$b(_class$b = class ServiceCacheEntity extends ModelCacheBase {
|
|
2255
2248
|
__init__(model) {
|
|
2256
2249
|
super.__init__(model, 'entity');
|
|
2257
2250
|
}
|
|
@@ -2274,12 +2267,12 @@ let ServiceCacheEntity = (_dec$f = Service(), _dec2$f = BeanInfo({
|
|
|
2274
2267
|
get keysAux() {
|
|
2275
2268
|
return this._model.options.cache?.keysAux;
|
|
2276
2269
|
}
|
|
2277
|
-
}) || _class$
|
|
2270
|
+
}) || _class$b) || _class$b);
|
|
2278
2271
|
|
|
2279
|
-
var _dec$
|
|
2280
|
-
let ServiceCacheQuery = (_dec$
|
|
2272
|
+
var _dec$a, _dec2$a, _class$a;
|
|
2273
|
+
let ServiceCacheQuery = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
2281
2274
|
module: "a-orm"
|
|
2282
|
-
}), _dec$
|
|
2275
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class ServiceCacheQuery extends ModelCacheBase {
|
|
2283
2276
|
__init__(model) {
|
|
2284
2277
|
super.__init__(model, 'query');
|
|
2285
2278
|
}
|
|
@@ -2289,7 +2282,7 @@ let ServiceCacheQuery = (_dec$e = Service(), _dec2$e = BeanInfo({
|
|
|
2289
2282
|
const cache = this.getInstance(table);
|
|
2290
2283
|
await cache.clear();
|
|
2291
2284
|
}
|
|
2292
|
-
}) || _class$
|
|
2285
|
+
}) || _class$a) || _class$a);
|
|
2293
2286
|
|
|
2294
2287
|
function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
2295
2288
|
// collect
|
|
@@ -2334,10 +2327,10 @@ function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
|
2334
2327
|
return relations;
|
|
2335
2328
|
}
|
|
2336
2329
|
|
|
2337
|
-
var _dec$
|
|
2338
|
-
let ServiceRelations = (_dec$
|
|
2330
|
+
var _dec$9, _dec2$9, _class$9;
|
|
2331
|
+
let ServiceRelations = (_dec$9 = Service(), _dec2$9 = BeanInfo({
|
|
2339
2332
|
module: "a-orm"
|
|
2340
|
-
}), _dec$
|
|
2333
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = class ServiceRelations extends BeanBase {
|
|
2341
2334
|
constructor(...args) {
|
|
2342
2335
|
super(...args);
|
|
2343
2336
|
this._model = void 0;
|
|
@@ -2869,7 +2862,7 @@ let ServiceRelations = (_dec$d = Service(), _dec2$d = BeanInfo({
|
|
|
2869
2862
|
handleRelationsCollection(includeWrapper) {
|
|
2870
2863
|
return handleRelationsCollection(this._model.options.relations, includeWrapper);
|
|
2871
2864
|
}
|
|
2872
|
-
}) || _class$
|
|
2865
|
+
}) || _class$9) || _class$9);
|
|
2873
2866
|
|
|
2874
2867
|
class BeanModelCrud extends BeanModelCrudInner {
|
|
2875
2868
|
async mget(ids, options) {
|
|
@@ -3530,16 +3523,16 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3530
3523
|
}
|
|
3531
3524
|
}
|
|
3532
3525
|
|
|
3533
|
-
var _dec$
|
|
3534
|
-
let BeanModelBase = (_dec$
|
|
3526
|
+
var _dec$8, _dec2$8, _dec3$2, _class$8;
|
|
3527
|
+
let BeanModelBase = (_dec$8 = Bean(), _dec2$8 = Virtual(), _dec3$2 = BeanInfo({
|
|
3535
3528
|
module: "a-orm"
|
|
3536
|
-
}), _dec$
|
|
3529
|
+
}), _dec$8(_class$8 = _dec2$8(_class$8 = _dec3$2(_class$8 = class BeanModelBase extends BeanModelCache {}) || _class$8) || _class$8) || _class$8);
|
|
3537
3530
|
|
|
3538
|
-
var _dec$
|
|
3531
|
+
var _dec$7, _dec2$7, _dec3$1, _dec4$1, _class$7;
|
|
3539
3532
|
const SymbolModuleScope$1 = Symbol('SymbolModuleScope');
|
|
3540
|
-
let ServiceEntityResolver = (_dec$
|
|
3533
|
+
let ServiceEntityResolver = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
3541
3534
|
module: "a-orm"
|
|
3542
|
-
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3535
|
+
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", [String]), _dec$7(_class$7 = _dec2$7(_class$7 = _dec3$1(_class$7 = _dec4$1(_class$7 = class ServiceEntityResolver extends BeanBase {
|
|
3543
3536
|
constructor(moduleScope) {
|
|
3544
3537
|
super();
|
|
3545
3538
|
this[SymbolModuleScope$1] = void 0;
|
|
@@ -3554,13 +3547,13 @@ let ServiceEntityResolver = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
|
3554
3547
|
}
|
|
3555
3548
|
return this.__instances[prop];
|
|
3556
3549
|
}
|
|
3557
|
-
}) || _class$
|
|
3550
|
+
}) || _class$7) || _class$7) || _class$7) || _class$7);
|
|
3558
3551
|
|
|
3559
|
-
var _dec$
|
|
3552
|
+
var _dec$6, _dec2$6, _dec3, _dec4, _class$6;
|
|
3560
3553
|
const SymbolModuleScope = Symbol('SymbolModuleScope');
|
|
3561
|
-
let ServiceModelResolver = (_dec$
|
|
3554
|
+
let ServiceModelResolver = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
3562
3555
|
module: "a-orm"
|
|
3563
|
-
}), _dec3 = Reflect.metadata("design:type", Function), _dec4 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3556
|
+
}), _dec3 = Reflect.metadata("design:type", Function), _dec4 = Reflect.metadata("design:paramtypes", [String]), _dec$6(_class$6 = _dec2$6(_class$6 = _dec3(_class$6 = _dec4(_class$6 = class ServiceModelResolver extends BeanBase {
|
|
3564
3557
|
constructor(moduleScope) {
|
|
3565
3558
|
super();
|
|
3566
3559
|
this[SymbolModuleScope] = void 0;
|
|
@@ -3570,72 +3563,32 @@ let ServiceModelResolver = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
3570
3563
|
const beanFullName = `${this[SymbolModuleScope]}.model.${prop}`;
|
|
3571
3564
|
return this.bean._getBean(beanFullName);
|
|
3572
3565
|
}
|
|
3573
|
-
}) || _class$
|
|
3566
|
+
}) || _class$6) || _class$6) || _class$6) || _class$6);
|
|
3574
3567
|
|
|
3575
|
-
var _dec$
|
|
3576
|
-
let BroadcastColumnsClear = (_dec$
|
|
3568
|
+
var _dec$5, _dec2$5, _class$5;
|
|
3569
|
+
let BroadcastColumnsClear = (_dec$5 = Broadcast(), _dec2$5 = BeanInfo({
|
|
3577
3570
|
module: "a-orm"
|
|
3578
|
-
}), _dec$
|
|
3571
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class BroadcastColumnsClear extends BeanBroadcastBase {
|
|
3579
3572
|
async execute(data, isEmitter) {
|
|
3580
3573
|
const {
|
|
3581
3574
|
clientName,
|
|
3582
3575
|
tableName
|
|
3583
3576
|
} = data;
|
|
3584
3577
|
if (!isEmitter) {
|
|
3585
|
-
await cast(this.scope.service.database).
|
|
3578
|
+
await cast(this.scope.service.database).columnsClearWorker(clientName, tableName);
|
|
3586
3579
|
}
|
|
3587
3580
|
}
|
|
3588
|
-
}) || _class$
|
|
3589
|
-
|
|
3590
|
-
var _dec$8, _dec2$8, _class$8;
|
|
3591
|
-
let BroadcastDatabaseClientDispose = (_dec$8 = Broadcast(), _dec2$8 = BeanInfo({
|
|
3592
|
-
module: "a-orm"
|
|
3593
|
-
}), _dec$8(_class$8 = _dec2$8(_class$8 = class BroadcastDatabaseClientDispose extends BeanBroadcastBase {
|
|
3594
|
-
async execute(data, isEmitter) {
|
|
3595
|
-
const {
|
|
3596
|
-
clientName
|
|
3597
|
-
} = data;
|
|
3598
|
-
if (!isEmitter) {
|
|
3599
|
-
await cast(this.scope.service.database).disposeClientsRaw(clientName);
|
|
3600
|
-
}
|
|
3601
|
-
}
|
|
3602
|
-
}) || _class$8) || _class$8);
|
|
3603
|
-
|
|
3604
|
-
var _dec$7, _dec2$7, _class$7;
|
|
3605
|
-
let BroadcastDatabaseClientReload = (_dec$7 = Broadcast(), _dec2$7 = BeanInfo({
|
|
3606
|
-
module: "a-orm"
|
|
3607
|
-
}), _dec$7(_class$7 = _dec2$7(_class$7 = class BroadcastDatabaseClientReload extends BeanBroadcastBase {
|
|
3608
|
-
async execute(data, isEmitter) {
|
|
3609
|
-
const {
|
|
3610
|
-
clientName,
|
|
3611
|
-
clientConfig,
|
|
3612
|
-
extraData
|
|
3613
|
-
} = data;
|
|
3614
|
-
if (!isEmitter) {
|
|
3615
|
-
await cast(this.scope.service.database).reloadClientsRaw(clientName, clientConfig, extraData);
|
|
3616
|
-
}
|
|
3617
|
-
}
|
|
3618
|
-
}) || _class$7) || _class$7);
|
|
3619
|
-
|
|
3620
|
-
var _dec$6, _dec2$6, _class$6;
|
|
3621
|
-
let EventClientNameReal = (_dec$6 = Event(), _dec2$6 = BeanInfo({
|
|
3622
|
-
module: "a-orm"
|
|
3623
|
-
}), _dec$6(_class$6 = _dec2$6(_class$6 = class EventClientNameReal extends BeanEventBase {}) || _class$6) || _class$6);
|
|
3624
|
-
|
|
3625
|
-
var _dec$5, _dec2$5, _class$5;
|
|
3626
|
-
let EventColumnsClear = (_dec$5 = Event(), _dec2$5 = BeanInfo({
|
|
3627
|
-
module: "a-orm"
|
|
3628
|
-
}), _dec$5(_class$5 = _dec2$5(_class$5 = class EventColumnsClear extends BeanEventBase {}) || _class$5) || _class$5);
|
|
3581
|
+
}) || _class$5) || _class$5);
|
|
3629
3582
|
|
|
3630
3583
|
var _dec$4, _dec2$4, _class$4;
|
|
3631
|
-
let
|
|
3584
|
+
let EventClientNameReal = (_dec$4 = Event(), _dec2$4 = BeanInfo({
|
|
3632
3585
|
module: "a-orm"
|
|
3633
|
-
}), _dec$4(_class$4 = _dec2$4(_class$4 = class
|
|
3586
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class EventClientNameReal extends BeanEventBase {}) || _class$4) || _class$4);
|
|
3634
3587
|
|
|
3635
3588
|
var _dec$3, _dec2$3, _class$3;
|
|
3636
|
-
let
|
|
3589
|
+
let EventColumnsClear = (_dec$3 = Event(), _dec2$3 = BeanInfo({
|
|
3637
3590
|
module: "a-orm"
|
|
3638
|
-
}), _dec$3(_class$3 = _dec2$3(_class$3 = class
|
|
3591
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class EventColumnsClear extends BeanEventBase {}) || _class$3) || _class$3);
|
|
3639
3592
|
|
|
3640
3593
|
var _dec$2, _dec2$2, _class$2;
|
|
3641
3594
|
let QueueDoubleDelete = (_dec$2 = Queue({
|
|
@@ -4394,4 +4347,4 @@ const $relationMutate = {
|
|
|
4394
4347
|
belongsToMany
|
|
4395
4348
|
};
|
|
4396
4349
|
|
|
4397
|
-
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear,
|
|
4350
|
+
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear, Database, DatabaseDialect, DtoQueryBase, DtoQueryPageBase, Entity, EntityBase, EntityBaseEmpty, EntityBaseInner, EntityBaseSimple, Errors, 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, getClassEntityFromClassModel, getTableOrTableAlias, getTargetColumnName, isAggrColumn, isRaw, isRef, locales, prepareClassModel, prepareColumns };
|
|
@@ -13,9 +13,8 @@ export declare class ServiceDatabase extends BeanBase {
|
|
|
13
13
|
getDefaultClientName(): keyof IDatabaseClientRecord;
|
|
14
14
|
prepareClientNameReal(clientName?: keyof IDatabaseClientRecord): keyof IDatabaseClientRecord;
|
|
15
15
|
columnsClear(clientName?: keyof IDatabaseClientRecord, tableName?: string): void;
|
|
16
|
-
private
|
|
17
|
-
reloadClients(clientName?: keyof IDatabaseClientRecord, clientConfig?: ConfigDatabaseClient
|
|
18
|
-
|
|
16
|
+
private columnsClearWorker;
|
|
17
|
+
reloadClients(clientName?: keyof IDatabaseClientRecord, clientConfig?: ConfigDatabaseClient): Promise<void>;
|
|
18
|
+
reloadClientsWorker(clientName?: keyof IDatabaseClientRecord, clientConfig?: ConfigDatabaseClient): Promise<void>;
|
|
19
19
|
disposeClients(clientName?: keyof IDatabaseClientRecord): Promise<void>;
|
|
20
|
-
disposeClientsRaw(clientName?: keyof IDatabaseClientRecord): Promise<void>;
|
|
21
20
|
}
|
|
@@ -1,30 +1,35 @@
|
|
|
1
1
|
import type { Knex } from 'knex';
|
|
2
2
|
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
3
3
|
import type { IDatabaseClientRecord } from '../types/database.ts';
|
|
4
|
-
import {
|
|
4
|
+
import { BeanMutateBase } from 'vona-module-a-beanmutate';
|
|
5
5
|
import { ServiceDb } from './db_.ts';
|
|
6
6
|
export interface IPrepareDatabaseNameResult {
|
|
7
7
|
database?: string;
|
|
8
8
|
filename?: string;
|
|
9
9
|
}
|
|
10
|
-
export declare class ServiceDatabaseClient extends
|
|
10
|
+
export declare class ServiceDatabaseClient extends BeanMutateBase {
|
|
11
11
|
level: number;
|
|
12
12
|
clientName: keyof IDatabaseClientRecord;
|
|
13
13
|
clientNameSelector: string;
|
|
14
14
|
clientConfig: ConfigDatabaseClient;
|
|
15
15
|
private _knex;
|
|
16
16
|
private _db;
|
|
17
|
-
private _onDatabaseClientReloadCancel?;
|
|
18
|
-
private _onDatabaseClientDisposeCancel?;
|
|
19
17
|
get configDatabase(): import("../types/config.ts").ConfigDatabase;
|
|
20
18
|
get connection(): Knex;
|
|
21
19
|
get db(): ServiceDb;
|
|
22
|
-
protected __init__(clientNameSelector
|
|
20
|
+
protected __init__(clientNameSelector?: string, clientConfig?: ConfigDatabaseClient): void;
|
|
23
21
|
protected __dispose__(): Promise<void>;
|
|
22
|
+
protected onReloadInstance({ clientName, clientConfig }: {
|
|
23
|
+
clientName: any;
|
|
24
|
+
clientConfig: any;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
protected onDisposeInstance({ clientName }: {
|
|
27
|
+
clientName: any;
|
|
28
|
+
}): Promise<void>;
|
|
24
29
|
private __load;
|
|
25
30
|
private __close;
|
|
26
31
|
reload(clientConfig?: ConfigDatabaseClient): Promise<void>;
|
|
27
32
|
getDatabaseName(): string;
|
|
28
33
|
private _prepareDatabaseName;
|
|
29
|
-
|
|
34
|
+
changeConfigConnectionAndReloadWorker(databaseName: string): Promise<void>;
|
|
30
35
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { IBroadcastExecute } from 'vona-module-a-broadcast';
|
|
2
|
-
import type { IDatabaseClientRecord } from '../types/database.ts';
|
|
3
|
-
import { BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
4
|
-
export interface TypeBroadcastDatabaseClientDisposeJobData {
|
|
5
|
-
clientName?: keyof IDatabaseClientRecord;
|
|
6
|
-
}
|
|
7
|
-
export declare class BroadcastDatabaseClientDispose extends BeanBroadcastBase<TypeBroadcastDatabaseClientDisposeJobData> implements IBroadcastExecute<TypeBroadcastDatabaseClientDisposeJobData> {
|
|
8
|
-
execute(data: TypeBroadcastDatabaseClientDisposeJobData, isEmitter?: boolean): Promise<void>;
|
|
9
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { IBroadcastExecute } from 'vona-module-a-broadcast';
|
|
2
|
-
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
3
|
-
import type { IDatabaseClientRecord } from '../types/database.ts';
|
|
4
|
-
import { BeanBroadcastBase } from 'vona-module-a-broadcast';
|
|
5
|
-
export interface TypeBroadcastDatabaseClientReloadJobData {
|
|
6
|
-
clientName?: keyof IDatabaseClientRecord;
|
|
7
|
-
clientConfig?: ConfigDatabaseClient;
|
|
8
|
-
extraData?: any;
|
|
9
|
-
}
|
|
10
|
-
export declare class BroadcastDatabaseClientReload extends BeanBroadcastBase<TypeBroadcastDatabaseClientReloadJobData> implements IBroadcastExecute<TypeBroadcastDatabaseClientReloadJobData> {
|
|
11
|
-
execute(data: TypeBroadcastDatabaseClientReloadJobData, isEmitter?: boolean): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { IDatabaseClientRecord } from '../types/database.ts';
|
|
2
|
-
import { BeanEventBase } from 'vona-module-a-event';
|
|
3
|
-
export interface TypeEventDatabaseClientDisposeData {
|
|
4
|
-
clientName: keyof IDatabaseClientRecord;
|
|
5
|
-
}
|
|
6
|
-
export type TypeEventDatabaseClientDisposeResult = void;
|
|
7
|
-
export declare class EventDatabaseClientDispose extends BeanEventBase<TypeEventDatabaseClientDisposeData, TypeEventDatabaseClientDisposeResult> {
|
|
8
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { ConfigDatabaseClient } from '../types/config.ts';
|
|
2
|
-
import type { IDatabaseClientRecord } from '../types/database.ts';
|
|
3
|
-
import { BeanEventBase } from 'vona-module-a-event';
|
|
4
|
-
export interface TypeEventDatabaseClientReloadData {
|
|
5
|
-
clientName: keyof IDatabaseClientRecord;
|
|
6
|
-
clientConfig?: ConfigDatabaseClient;
|
|
7
|
-
extraData?: any;
|
|
8
|
-
}
|
|
9
|
-
export type TypeEventDatabaseClientReloadResult = void;
|
|
10
|
-
export declare class EventDatabaseClientReload extends BeanEventBase<TypeEventDatabaseClientReloadData, TypeEventDatabaseClientReloadResult> {
|
|
11
|
-
}
|