vona-module-a-orm 5.0.58 → 5.0.60
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 -214
- 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
|
|
@@ -687,7 +680,6 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
687
680
|
this.clientName = dbInfo.clientName;
|
|
688
681
|
// config
|
|
689
682
|
this.clientConfig = clientConfig ? deepExtend({}, clientConfig) : this.scope.service.database.getClientConfig(this.clientName);
|
|
690
|
-
this.$loggerChild('database').debug('clientName: %s, clientConfig: %j', this.clientName, this.clientConfig);
|
|
691
683
|
// knex
|
|
692
684
|
this._knex = knex(this.clientConfig);
|
|
693
685
|
}
|
|
@@ -717,7 +709,7 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
717
709
|
}
|
|
718
710
|
|
|
719
711
|
// only used by startup, so no consider that workers broadcast
|
|
720
|
-
async
|
|
712
|
+
async changeConfigConnectionAndReloadWorker(databaseName) {
|
|
721
713
|
// set databaseName
|
|
722
714
|
const connDatabaseName = this._prepareDatabaseName(databaseName);
|
|
723
715
|
// set config
|
|
@@ -727,15 +719,15 @@ let ServiceDatabaseClient = (_dec$o = Service(), _dec2$o = BeanInfo({
|
|
|
727
719
|
// only used by startup, so no consider that workers broadcast
|
|
728
720
|
this.configDatabase.clients[this.clientName] = config;
|
|
729
721
|
// reload
|
|
730
|
-
await this.scope.service.database.
|
|
722
|
+
await this.scope.service.database.reloadClientsWorker(this.clientName, config);
|
|
731
723
|
// await this.scope.service.database.reloadClients(this.clientName, config);
|
|
732
724
|
}
|
|
733
|
-
}) || _class$
|
|
725
|
+
}) || _class$k) || _class$k);
|
|
734
726
|
|
|
735
|
-
var _dec$
|
|
736
|
-
let BeanDatabase = (_dec$
|
|
727
|
+
var _dec$j, _dec2$j, _class$j;
|
|
728
|
+
let BeanDatabase = (_dec$j = Bean(), _dec2$j = BeanInfo({
|
|
737
729
|
module: "a-orm"
|
|
738
|
-
}), _dec$
|
|
730
|
+
}), _dec$j(_class$j = _dec2$j(_class$j = class BeanDatabase extends BeanBase {
|
|
739
731
|
get current() {
|
|
740
732
|
return this.bean._getBean(ServiceDatabaseAsyncLocalStorage).current;
|
|
741
733
|
}
|
|
@@ -765,12 +757,12 @@ let BeanDatabase = (_dec$n = Bean(), _dec2$n = BeanInfo({
|
|
|
765
757
|
return this.bean._getBean(ServiceTransactionAsyncLocalStorage).run(fn);
|
|
766
758
|
});
|
|
767
759
|
}
|
|
768
|
-
}) || _class$
|
|
760
|
+
}) || _class$j) || _class$j);
|
|
769
761
|
|
|
770
|
-
var _dec$
|
|
771
|
-
let BeanDatabaseDialectBase = (_dec$
|
|
762
|
+
var _dec$i, _dec2$i, _dec3$7, _class$i;
|
|
763
|
+
let BeanDatabaseDialectBase = (_dec$i = Bean(), _dec2$i = Virtual(), _dec3$7 = BeanInfo({
|
|
772
764
|
module: "a-orm"
|
|
773
|
-
}), _dec$
|
|
765
|
+
}), _dec$i(_class$i = _dec2$i(_class$i = _dec3$7(_class$i = class BeanDatabaseDialectBase extends BeanBase {
|
|
774
766
|
getConfigBase() {
|
|
775
767
|
return undefined;
|
|
776
768
|
}
|
|
@@ -830,7 +822,7 @@ let BeanDatabaseDialectBase = (_dec$m = Bean(), _dec2$m = Virtual(), _dec3$7 = B
|
|
|
830
822
|
_columnTypePrefixes(type, prefixes) {
|
|
831
823
|
return prefixes.some(prefix => type.includes(prefix));
|
|
832
824
|
}
|
|
833
|
-
}) || _class$
|
|
825
|
+
}) || _class$i) || _class$i) || _class$i);
|
|
834
826
|
|
|
835
827
|
const OpAggrs = ['count', 'sum', 'avg', 'max', 'min'];
|
|
836
828
|
const OpJoint = {
|
|
@@ -1236,69 +1228,69 @@ function _initializerDefineProperty(e, i, r, l) {
|
|
|
1236
1228
|
});
|
|
1237
1229
|
}
|
|
1238
1230
|
|
|
1239
|
-
var _dec$
|
|
1231
|
+
var _dec$h, _dec2$h, _dec3$6, _dec4$4, _dec5$1, _dec6$1, _dec7$1, _class$h, _descriptor$4, _descriptor2$2, _descriptor3$1;
|
|
1240
1232
|
const app$1 = useApp();
|
|
1241
1233
|
const ormConfig$1 = app$1.util.getModuleConfigRaw('a-orm');
|
|
1242
1234
|
const ordersDefault = ormConfig$1?.rest?.query?.orders?.default ?? 'createdAt,desc';
|
|
1243
|
-
let DtoQueryBase = (_dec$
|
|
1235
|
+
let DtoQueryBase = (_dec$h = Api.field(v.optional(), v.array(String, {
|
|
1244
1236
|
separator: ','
|
|
1245
|
-
})), _dec2$
|
|
1237
|
+
})), _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
1238
|
constructor() {
|
|
1247
1239
|
_initializerDefineProperty(this, "columns", _descriptor$4, this);
|
|
1248
1240
|
_initializerDefineProperty(this, "where", _descriptor2$2, this);
|
|
1249
1241
|
_initializerDefineProperty(this, "orders", _descriptor3$1, this);
|
|
1250
1242
|
}
|
|
1251
|
-
}, _descriptor$4 = _applyDecoratedDescriptor(_class$
|
|
1243
|
+
}, _descriptor$4 = _applyDecoratedDescriptor(_class$h.prototype, "columns", [_dec$h, _dec2$h], {
|
|
1252
1244
|
configurable: true,
|
|
1253
1245
|
enumerable: true,
|
|
1254
1246
|
writable: true,
|
|
1255
1247
|
initializer: null
|
|
1256
|
-
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$
|
|
1248
|
+
}), _descriptor2$2 = _applyDecoratedDescriptor(_class$h.prototype, "where", [_dec3$6, _dec4$4], {
|
|
1257
1249
|
configurable: true,
|
|
1258
1250
|
enumerable: true,
|
|
1259
1251
|
writable: true,
|
|
1260
1252
|
initializer: null
|
|
1261
|
-
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$
|
|
1253
|
+
}), _descriptor3$1 = _applyDecoratedDescriptor(_class$h.prototype, "orders", [_dec5$1, _dec6$1, _dec7$1], {
|
|
1262
1254
|
configurable: true,
|
|
1263
1255
|
enumerable: true,
|
|
1264
1256
|
writable: true,
|
|
1265
1257
|
initializer: null
|
|
1266
|
-
}), _class$
|
|
1258
|
+
}), _class$h);
|
|
1267
1259
|
|
|
1268
|
-
var _dec$
|
|
1260
|
+
var _dec$g, _dec2$g, _dec3$5, _dec4$3, _class$g, _descriptor$3, _descriptor2$1;
|
|
1269
1261
|
const app = useApp();
|
|
1270
1262
|
const ormConfig = app.util.getModuleConfigRaw('a-orm');
|
|
1271
1263
|
const pageSizeDefault = ormConfig?.rest?.query?.pageSize?.default ?? 20;
|
|
1272
1264
|
const pageSizeMax = ormConfig?.rest?.query?.pageSize?.max ?? 100;
|
|
1273
|
-
let DtoQueryPageBase = (_dec$
|
|
1265
|
+
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
1266
|
constructor(...args) {
|
|
1275
1267
|
super(...args);
|
|
1276
1268
|
_initializerDefineProperty(this, "pageNo", _descriptor$3, this);
|
|
1277
1269
|
_initializerDefineProperty(this, "pageSize", _descriptor2$1, this);
|
|
1278
1270
|
}
|
|
1279
|
-
}, _descriptor$3 = _applyDecoratedDescriptor(_class$
|
|
1271
|
+
}, _descriptor$3 = _applyDecoratedDescriptor(_class$g.prototype, "pageNo", [_dec$g, _dec2$g], {
|
|
1280
1272
|
configurable: true,
|
|
1281
1273
|
enumerable: true,
|
|
1282
1274
|
writable: true,
|
|
1283
1275
|
initializer: null
|
|
1284
|
-
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$
|
|
1276
|
+
}), _descriptor2$1 = _applyDecoratedDescriptor(_class$g.prototype, "pageSize", [_dec3$5, _dec4$3], {
|
|
1285
1277
|
configurable: true,
|
|
1286
1278
|
enumerable: true,
|
|
1287
1279
|
writable: true,
|
|
1288
1280
|
initializer: null
|
|
1289
|
-
}), _class$
|
|
1281
|
+
}), _class$g);
|
|
1290
1282
|
|
|
1291
1283
|
const SymbolKeyFieldsMore = Symbol('$fieldsMore');
|
|
1292
1284
|
|
|
1293
1285
|
class EntityBaseEmpty {}
|
|
1294
1286
|
|
|
1295
|
-
var _dec$
|
|
1296
|
-
let EntityBaseInner = (_dec$
|
|
1287
|
+
var _dec$f, _dec2$f, _dec3$4, _dec4$2, _dec5, _dec6, _dec7, _dec8, _class$f, _descriptor$2, _descriptor2, _descriptor3, _descriptor4;
|
|
1288
|
+
let EntityBaseInner = (_dec$f = Api.field(v.openapi({
|
|
1297
1289
|
title: $locale('CreatedAt'),
|
|
1298
1290
|
rest: {
|
|
1299
1291
|
order: OrderMaxBase - 2
|
|
1300
1292
|
}
|
|
1301
|
-
})), _dec2$
|
|
1293
|
+
})), _dec2$f = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec3$4 = Api.field(v.openapi({
|
|
1302
1294
|
title: $locale('UpdatedAt'),
|
|
1303
1295
|
rest: {
|
|
1304
1296
|
order: OrderMaxBase - 1
|
|
@@ -1313,7 +1305,7 @@ let EntityBaseInner = (_dec$j = Api.field(v.openapi({
|
|
|
1313
1305
|
rest: {
|
|
1314
1306
|
visible: false
|
|
1315
1307
|
}
|
|
1316
|
-
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$
|
|
1308
|
+
}), v.default(0)), _dec8 = Reflect.metadata("design:type", Number), _class$f = class EntityBaseInner extends EntityBaseEmpty {
|
|
1317
1309
|
constructor(...args) {
|
|
1318
1310
|
super(...args);
|
|
1319
1311
|
_initializerDefineProperty(this, "createdAt", _descriptor$2, this);
|
|
@@ -1321,63 +1313,63 @@ let EntityBaseInner = (_dec$j = Api.field(v.openapi({
|
|
|
1321
1313
|
_initializerDefineProperty(this, "deleted", _descriptor3, this);
|
|
1322
1314
|
_initializerDefineProperty(this, "iid", _descriptor4, this);
|
|
1323
1315
|
}
|
|
1324
|
-
}, _descriptor$2 = _applyDecoratedDescriptor(_class$
|
|
1316
|
+
}, _descriptor$2 = _applyDecoratedDescriptor(_class$f.prototype, "createdAt", [_dec$f, _dec2$f], {
|
|
1325
1317
|
configurable: true,
|
|
1326
1318
|
enumerable: true,
|
|
1327
1319
|
writable: true,
|
|
1328
1320
|
initializer: null
|
|
1329
|
-
}), _descriptor2 = _applyDecoratedDescriptor(_class$
|
|
1321
|
+
}), _descriptor2 = _applyDecoratedDescriptor(_class$f.prototype, "updatedAt", [_dec3$4, _dec4$2], {
|
|
1330
1322
|
configurable: true,
|
|
1331
1323
|
enumerable: true,
|
|
1332
1324
|
writable: true,
|
|
1333
1325
|
initializer: null
|
|
1334
|
-
}), _descriptor3 = _applyDecoratedDescriptor(_class$
|
|
1326
|
+
}), _descriptor3 = _applyDecoratedDescriptor(_class$f.prototype, "deleted", [_dec5, _dec6], {
|
|
1335
1327
|
configurable: true,
|
|
1336
1328
|
enumerable: true,
|
|
1337
1329
|
writable: true,
|
|
1338
1330
|
initializer: null
|
|
1339
|
-
}), _descriptor4 = _applyDecoratedDescriptor(_class$
|
|
1331
|
+
}), _descriptor4 = _applyDecoratedDescriptor(_class$f.prototype, "iid", [_dec7, _dec8], {
|
|
1340
1332
|
configurable: true,
|
|
1341
1333
|
enumerable: true,
|
|
1342
1334
|
writable: true,
|
|
1343
1335
|
initializer: null
|
|
1344
|
-
}), _class$
|
|
1336
|
+
}), _class$f);
|
|
1345
1337
|
|
|
1346
|
-
var _dec$
|
|
1347
|
-
let EntityBase = (_dec$
|
|
1338
|
+
var _dec$e, _dec2$e, _class$e, _descriptor$1;
|
|
1339
|
+
let EntityBase = (_dec$e = Api.field(v.openapi({
|
|
1348
1340
|
title: $locale('TableIdentity'),
|
|
1349
1341
|
rest: {
|
|
1350
1342
|
order: OrderCoreBase + 1
|
|
1351
1343
|
}
|
|
1352
|
-
}), v.tableIdentity()), _dec2$
|
|
1344
|
+
}), v.tableIdentity()), _dec2$e = Reflect.metadata("design:type", typeof TableIdentity === "undefined" ? Object : TableIdentity), _class$e = class EntityBase extends EntityBaseInner {
|
|
1353
1345
|
constructor(...args) {
|
|
1354
1346
|
super(...args);
|
|
1355
1347
|
_initializerDefineProperty(this, "id", _descriptor$1, this);
|
|
1356
1348
|
}
|
|
1357
|
-
}, _descriptor$1 = _applyDecoratedDescriptor(_class$
|
|
1349
|
+
}, _descriptor$1 = _applyDecoratedDescriptor(_class$e.prototype, "id", [_dec$e, _dec2$e], {
|
|
1358
1350
|
configurable: true,
|
|
1359
1351
|
enumerable: true,
|
|
1360
1352
|
writable: true,
|
|
1361
1353
|
initializer: null
|
|
1362
|
-
}), _class$
|
|
1354
|
+
}), _class$e);
|
|
1363
1355
|
|
|
1364
|
-
var _dec$
|
|
1365
|
-
let EntityBaseSimple = (_dec$
|
|
1356
|
+
var _dec$d, _dec2$d, _class$d, _descriptor;
|
|
1357
|
+
let EntityBaseSimple = (_dec$d = Api.field(v.openapi({
|
|
1366
1358
|
title: $locale('TableIdentity'),
|
|
1367
1359
|
rest: {
|
|
1368
1360
|
order: OrderCoreBase + 1
|
|
1369
1361
|
}
|
|
1370
|
-
})), _dec2$
|
|
1362
|
+
})), _dec2$d = Reflect.metadata("design:type", Number), _class$d = class EntityBaseSimple extends EntityBaseInner {
|
|
1371
1363
|
constructor(...args) {
|
|
1372
1364
|
super(...args);
|
|
1373
1365
|
_initializerDefineProperty(this, "id", _descriptor, this);
|
|
1374
1366
|
}
|
|
1375
|
-
}, _descriptor = _applyDecoratedDescriptor(_class$
|
|
1367
|
+
}, _descriptor = _applyDecoratedDescriptor(_class$d.prototype, "id", [_dec$d, _dec2$d], {
|
|
1376
1368
|
configurable: true,
|
|
1377
1369
|
enumerable: true,
|
|
1378
1370
|
writable: true,
|
|
1379
1371
|
initializer: null
|
|
1380
|
-
}), _class$
|
|
1372
|
+
}), _class$d);
|
|
1381
1373
|
|
|
1382
1374
|
const SymbolKeyEntity = Symbol('$entity');
|
|
1383
1375
|
const SymbolKeyEntityMeta = Symbol('$entityMeta');
|
|
@@ -2170,10 +2162,10 @@ class BeanModelCrudTable extends BeanModelCrudInner {
|
|
|
2170
2162
|
}
|
|
2171
2163
|
}
|
|
2172
2164
|
|
|
2173
|
-
var _dec$
|
|
2174
|
-
let BeanModel = (_dec$
|
|
2165
|
+
var _dec$c, _dec2$c, _dec3$3, _class$c;
|
|
2166
|
+
let BeanModel = (_dec$c = Bean(), _dec2$c = Virtual(), _dec3$3 = BeanInfo({
|
|
2175
2167
|
module: "a-orm"
|
|
2176
|
-
}), _dec$
|
|
2168
|
+
}), _dec$c(_class$c = _dec2$c(_class$c = _dec3$3(_class$c = class BeanModel extends BeanModelCrudTable {}) || _class$c) || _class$c) || _class$c);
|
|
2177
2169
|
|
|
2178
2170
|
const SymbolCacheOptions = Symbol('SymbolCacheOptions');
|
|
2179
2171
|
const SymbolCacheEnabled = Symbol('SymbolCacheEnabled');
|
|
@@ -2248,10 +2240,10 @@ class ModelCacheBase extends BeanBase {
|
|
|
2248
2240
|
}
|
|
2249
2241
|
}
|
|
2250
2242
|
|
|
2251
|
-
var _dec$
|
|
2252
|
-
let ServiceCacheEntity = (_dec$
|
|
2243
|
+
var _dec$b, _dec2$b, _class$b;
|
|
2244
|
+
let ServiceCacheEntity = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
2253
2245
|
module: "a-orm"
|
|
2254
|
-
}), _dec$
|
|
2246
|
+
}), _dec$b(_class$b = _dec2$b(_class$b = class ServiceCacheEntity extends ModelCacheBase {
|
|
2255
2247
|
__init__(model) {
|
|
2256
2248
|
super.__init__(model, 'entity');
|
|
2257
2249
|
}
|
|
@@ -2274,12 +2266,12 @@ let ServiceCacheEntity = (_dec$f = Service(), _dec2$f = BeanInfo({
|
|
|
2274
2266
|
get keysAux() {
|
|
2275
2267
|
return this._model.options.cache?.keysAux;
|
|
2276
2268
|
}
|
|
2277
|
-
}) || _class$
|
|
2269
|
+
}) || _class$b) || _class$b);
|
|
2278
2270
|
|
|
2279
|
-
var _dec$
|
|
2280
|
-
let ServiceCacheQuery = (_dec$
|
|
2271
|
+
var _dec$a, _dec2$a, _class$a;
|
|
2272
|
+
let ServiceCacheQuery = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
2281
2273
|
module: "a-orm"
|
|
2282
|
-
}), _dec$
|
|
2274
|
+
}), _dec$a(_class$a = _dec2$a(_class$a = class ServiceCacheQuery extends ModelCacheBase {
|
|
2283
2275
|
__init__(model) {
|
|
2284
2276
|
super.__init__(model, 'query');
|
|
2285
2277
|
}
|
|
@@ -2289,7 +2281,7 @@ let ServiceCacheQuery = (_dec$e = Service(), _dec2$e = BeanInfo({
|
|
|
2289
2281
|
const cache = this.getInstance(table);
|
|
2290
2282
|
await cache.clear();
|
|
2291
2283
|
}
|
|
2292
|
-
}) || _class$
|
|
2284
|
+
}) || _class$a) || _class$a);
|
|
2293
2285
|
|
|
2294
2286
|
function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
2295
2287
|
// collect
|
|
@@ -2334,10 +2326,10 @@ function handleRelationsCollection(relationsStatic, includeWrapper) {
|
|
|
2334
2326
|
return relations;
|
|
2335
2327
|
}
|
|
2336
2328
|
|
|
2337
|
-
var _dec$
|
|
2338
|
-
let ServiceRelations = (_dec$
|
|
2329
|
+
var _dec$9, _dec2$9, _class$9;
|
|
2330
|
+
let ServiceRelations = (_dec$9 = Service(), _dec2$9 = BeanInfo({
|
|
2339
2331
|
module: "a-orm"
|
|
2340
|
-
}), _dec$
|
|
2332
|
+
}), _dec$9(_class$9 = _dec2$9(_class$9 = class ServiceRelations extends BeanBase {
|
|
2341
2333
|
constructor(...args) {
|
|
2342
2334
|
super(...args);
|
|
2343
2335
|
this._model = void 0;
|
|
@@ -2869,7 +2861,7 @@ let ServiceRelations = (_dec$d = Service(), _dec2$d = BeanInfo({
|
|
|
2869
2861
|
handleRelationsCollection(includeWrapper) {
|
|
2870
2862
|
return handleRelationsCollection(this._model.options.relations, includeWrapper);
|
|
2871
2863
|
}
|
|
2872
|
-
}) || _class$
|
|
2864
|
+
}) || _class$9) || _class$9);
|
|
2873
2865
|
|
|
2874
2866
|
class BeanModelCrud extends BeanModelCrudInner {
|
|
2875
2867
|
async mget(ids, options) {
|
|
@@ -3530,16 +3522,16 @@ class BeanModelCache extends BeanModelCrud {
|
|
|
3530
3522
|
}
|
|
3531
3523
|
}
|
|
3532
3524
|
|
|
3533
|
-
var _dec$
|
|
3534
|
-
let BeanModelBase = (_dec$
|
|
3525
|
+
var _dec$8, _dec2$8, _dec3$2, _class$8;
|
|
3526
|
+
let BeanModelBase = (_dec$8 = Bean(), _dec2$8 = Virtual(), _dec3$2 = BeanInfo({
|
|
3535
3527
|
module: "a-orm"
|
|
3536
|
-
}), _dec$
|
|
3528
|
+
}), _dec$8(_class$8 = _dec2$8(_class$8 = _dec3$2(_class$8 = class BeanModelBase extends BeanModelCache {}) || _class$8) || _class$8) || _class$8);
|
|
3537
3529
|
|
|
3538
|
-
var _dec$
|
|
3530
|
+
var _dec$7, _dec2$7, _dec3$1, _dec4$1, _class$7;
|
|
3539
3531
|
const SymbolModuleScope$1 = Symbol('SymbolModuleScope');
|
|
3540
|
-
let ServiceEntityResolver = (_dec$
|
|
3532
|
+
let ServiceEntityResolver = (_dec$7 = Service(), _dec2$7 = BeanInfo({
|
|
3541
3533
|
module: "a-orm"
|
|
3542
|
-
}), _dec3$1 = Reflect.metadata("design:type", Function), _dec4$1 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3534
|
+
}), _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
3535
|
constructor(moduleScope) {
|
|
3544
3536
|
super();
|
|
3545
3537
|
this[SymbolModuleScope$1] = void 0;
|
|
@@ -3554,13 +3546,13 @@ let ServiceEntityResolver = (_dec$b = Service(), _dec2$b = BeanInfo({
|
|
|
3554
3546
|
}
|
|
3555
3547
|
return this.__instances[prop];
|
|
3556
3548
|
}
|
|
3557
|
-
}) || _class$
|
|
3549
|
+
}) || _class$7) || _class$7) || _class$7) || _class$7);
|
|
3558
3550
|
|
|
3559
|
-
var _dec$
|
|
3551
|
+
var _dec$6, _dec2$6, _dec3, _dec4, _class$6;
|
|
3560
3552
|
const SymbolModuleScope = Symbol('SymbolModuleScope');
|
|
3561
|
-
let ServiceModelResolver = (_dec$
|
|
3553
|
+
let ServiceModelResolver = (_dec$6 = Service(), _dec2$6 = BeanInfo({
|
|
3562
3554
|
module: "a-orm"
|
|
3563
|
-
}), _dec3 = Reflect.metadata("design:type", Function), _dec4 = Reflect.metadata("design:paramtypes", [String]), _dec$
|
|
3555
|
+
}), _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
3556
|
constructor(moduleScope) {
|
|
3565
3557
|
super();
|
|
3566
3558
|
this[SymbolModuleScope] = void 0;
|
|
@@ -3570,72 +3562,32 @@ let ServiceModelResolver = (_dec$a = Service(), _dec2$a = BeanInfo({
|
|
|
3570
3562
|
const beanFullName = `${this[SymbolModuleScope]}.model.${prop}`;
|
|
3571
3563
|
return this.bean._getBean(beanFullName);
|
|
3572
3564
|
}
|
|
3573
|
-
}) || _class$
|
|
3565
|
+
}) || _class$6) || _class$6) || _class$6) || _class$6);
|
|
3574
3566
|
|
|
3575
|
-
var _dec$
|
|
3576
|
-
let BroadcastColumnsClear = (_dec$
|
|
3567
|
+
var _dec$5, _dec2$5, _class$5;
|
|
3568
|
+
let BroadcastColumnsClear = (_dec$5 = Broadcast(), _dec2$5 = BeanInfo({
|
|
3577
3569
|
module: "a-orm"
|
|
3578
|
-
}), _dec$
|
|
3570
|
+
}), _dec$5(_class$5 = _dec2$5(_class$5 = class BroadcastColumnsClear extends BeanBroadcastBase {
|
|
3579
3571
|
async execute(data, isEmitter) {
|
|
3580
3572
|
const {
|
|
3581
3573
|
clientName,
|
|
3582
3574
|
tableName
|
|
3583
3575
|
} = data;
|
|
3584
3576
|
if (!isEmitter) {
|
|
3585
|
-
await cast(this.scope.service.database).
|
|
3577
|
+
await cast(this.scope.service.database).columnsClearWorker(clientName, tableName);
|
|
3586
3578
|
}
|
|
3587
3579
|
}
|
|
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);
|
|
3580
|
+
}) || _class$5) || _class$5);
|
|
3629
3581
|
|
|
3630
3582
|
var _dec$4, _dec2$4, _class$4;
|
|
3631
|
-
let
|
|
3583
|
+
let EventClientNameReal = (_dec$4 = Event(), _dec2$4 = BeanInfo({
|
|
3632
3584
|
module: "a-orm"
|
|
3633
|
-
}), _dec$4(_class$4 = _dec2$4(_class$4 = class
|
|
3585
|
+
}), _dec$4(_class$4 = _dec2$4(_class$4 = class EventClientNameReal extends BeanEventBase {}) || _class$4) || _class$4);
|
|
3634
3586
|
|
|
3635
3587
|
var _dec$3, _dec2$3, _class$3;
|
|
3636
|
-
let
|
|
3588
|
+
let EventColumnsClear = (_dec$3 = Event(), _dec2$3 = BeanInfo({
|
|
3637
3589
|
module: "a-orm"
|
|
3638
|
-
}), _dec$3(_class$3 = _dec2$3(_class$3 = class
|
|
3590
|
+
}), _dec$3(_class$3 = _dec2$3(_class$3 = class EventColumnsClear extends BeanEventBase {}) || _class$3) || _class$3);
|
|
3639
3591
|
|
|
3640
3592
|
var _dec$2, _dec2$2, _class$2;
|
|
3641
3593
|
let QueueDoubleDelete = (_dec$2 = Queue({
|
|
@@ -4394,4 +4346,4 @@ const $relationMutate = {
|
|
|
4394
4346
|
belongsToMany
|
|
4395
4347
|
};
|
|
4396
4348
|
|
|
4397
|
-
export { $Dto, $column, $columns, $columnsAll, $locale, $relation, $relationDynamic, $relationMutate, $tableColumns, $tableComments, $tableDefaults, $tableName, AopMethodTransaction, BeanDatabase, BeanDatabaseDialectBase, BeanModel, BeanModelBase, BeanModelMeta, BroadcastColumnsClear,
|
|
4349
|
+
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
|
-
}
|