vona-module-a-executor 5.0.13 → 5.0.15

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.
@@ -20,7 +20,7 @@ declare module 'vona' {
20
20
  /** service: begin */
21
21
  export * from '../service/executor.ts';
22
22
  import 'vona';
23
- declare module 'vona-module-a-web' {
23
+ declare module 'vona-module-a-bean' {
24
24
  interface IServiceRecord {
25
25
  'a-executor:executor': never;
26
26
  }
@@ -28,6 +28,10 @@ declare module 'vona-module-a-web' {
28
28
  declare module 'vona-module-a-executor' {
29
29
  interface ServiceExecutor {
30
30
  }
31
+ interface ServiceExecutor {
32
+ get $beanFullName(): 'a-executor.service.executor';
33
+ get $onionName(): 'a-executor:executor';
34
+ }
31
35
  }
32
36
  /** service: end */
33
37
  /** service: begin */
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { BeanInfo, BeanBase, cast, deepExtend, BeanScopeBase } from 'vona';
2
- import { Bean, Scope } from 'vona-module-a-bean';
3
- import { combineParamsAndQuery } from '@cabloy/utils';
4
- import { Service } from 'vona-module-a-web';
2
+ import { isNil, combineParamsAndQuery } from '@cabloy/utils';
3
+ import { Bean, Service, Scope } from 'vona-module-a-bean';
4
+ import { Aspect } from 'vona-module-a-aspect';
5
5
 
6
6
  function __delegateProperties(ctx, ctxCaller) {
7
7
  for (const property of ['state']) {
@@ -58,7 +58,7 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
58
58
  return await this.scope.service.executor.performActionInner(method, url, options);
59
59
  }
60
60
  runInBackground(fn) {
61
- return this.bean.database.newDbIsolate(() => {
61
+ return this.bean.database.switchDbIsolate(() => {
62
62
  return this.newCtx(fn);
63
63
  });
64
64
  }
@@ -70,16 +70,17 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
70
70
  }
71
71
  async mockCtx(fn, options) {
72
72
  options = Object.assign({}, options);
73
- options.dbInfo = options.dbInfo === undefined ? true : options.dbInfo;
73
+ options.dbInfo = isNil(options.dbInfo) ? {
74
+ level: 1
75
+ } : options.dbInfo;
74
76
  options.instanceName = options.instanceName === undefined ? this.ctx?.instanceName ?? '' : options.instanceName;
75
77
  return this.newCtx(fn, options);
76
78
  }
77
79
  async newCtx(fn, options) {
78
- if (!options?.dbInfo) return this._newCtxInner(fn, options);
79
- const dbInfo = options.dbInfo === true ? {} : options.dbInfo;
80
- return this.bean.database.newDb(() => {
80
+ if (isNil(options?.dbInfo)) return this._newCtxInner(fn, options);
81
+ return this.bean.database.switchDb(() => {
81
82
  return this._newCtxInner(fn, options);
82
- }, dbInfo);
83
+ }, options?.dbInfo);
83
84
  }
84
85
  async _newCtxInner(fn, options) {
85
86
  options = Object.assign({}, options);
@@ -147,12 +148,23 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
147
148
  }
148
149
  }) || _class$2) || _class$2);
149
150
 
151
+ function _applyDecoratedDescriptor(i, e, r, n, l) {
152
+ var a = {};
153
+ return Object.keys(n).forEach(function (i) {
154
+ a[i] = n[i];
155
+ }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
156
+ return n(i, e, r) || r;
157
+ }, a), l && void 0 !== a.initializer && (a.value = a.initializer ? a.initializer.call(l) : void 0, a.initializer = void 0), void 0 === a.initializer ? (Object.defineProperty(i, e, a), null) : a;
158
+ }
159
+
150
160
  const SymbolRouterMiddleware = Symbol('SymbolRouterMiddleware');
151
161
 
152
- var _dec$1, _dec2$1, _class$1;
162
+ var _dec$1, _dec2$1, _dec3, _dec4, _dec5, _class$1, _class2;
153
163
  let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
154
164
  module: "a-executor"
155
- }), _dec$1(_class$1 = _dec2$1(_class$1 = class ServiceExecutor extends BeanBase {
165
+ }), _dec3 = Aspect.aopMethod('a-logger:log', {
166
+ level: 'debug'
167
+ }), _dec4 = Reflect.metadata("design:type", Function), _dec5 = Reflect.metadata("design:paramtypes", [typeof METHOD === "undefined" ? Object : METHOD, String, typeof IPerformActionOptions === "undefined" ? Object : IPerformActionOptions]), _dec$1(_class$1 = _dec2$1(_class$1 = (_class2 = class ServiceExecutor extends BeanBase {
156
168
  async performActionInner(method, url, options) {
157
169
  // app
158
170
  const app = this.app;
@@ -218,14 +230,14 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
218
230
  const clientName = options?.dbInfo?.clientName ?? current?.clientName;
219
231
  const locale = options?.locale === undefined ? this.ctx?.locale : options.locale;
220
232
  const instanceName = options?.instanceName === undefined ? this.ctx?.instanceName : options.instanceName;
221
- options = {
233
+ options = Object.assign({}, options, {
222
234
  dbInfo: {
223
235
  level,
224
236
  clientName
225
237
  },
226
238
  locale,
227
239
  instanceName
228
- };
240
+ });
229
241
  if (this.ctx) {
230
242
  options = deepExtend({
231
243
  extraData: {
@@ -247,7 +259,7 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
247
259
  }
248
260
  return options;
249
261
  }
250
- }) || _class$1) || _class$1);
262
+ }, _applyDecoratedDescriptor(_class2.prototype, "performActionInner", [_dec3, _dec4, _dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "performActionInner"), _class2.prototype), _class2)) || _class$1) || _class$1);
251
263
 
252
264
  // for (const key of ['x-clientid', 'x-scene']) {
253
265
  // if (!headers[key]) {
@@ -1,6 +1,6 @@
1
1
  import type { ContextState, IInstanceRecord, ILocaleInfos, PowerPartial } from 'vona';
2
- import type { IDbInfo, ITransactionOptions } from 'vona-module-a-database';
3
2
  import type { ConfigOnions } from 'vona-module-a-onion';
3
+ import type { IDbInfo, ITransactionOptions } from 'vona-module-a-orm';
4
4
  export declare const SymbolRouterMiddleware: unique symbol;
5
5
  export interface INewCtxExtraData {
6
6
  state?: ContextState;
@@ -9,7 +9,7 @@ export interface INewCtxExtraData {
9
9
  };
10
10
  }
11
11
  export interface INewCtxOptions extends INewCtxBaseOptions {
12
- dbInfo?: IDbInfo | true;
12
+ dbInfo?: Partial<IDbInfo>;
13
13
  }
14
14
  export interface INewCtxBaseOptions {
15
15
  locale?: keyof ILocaleInfos;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-executor",
3
3
  "type": "module",
4
- "version": "5.0.13",
4
+ "version": "5.0.15",
5
5
  "title": "a-executor",
6
6
  "vonaModule": {
7
7
  "dependencies": {}