vona-module-a-executor 5.0.16 → 5.0.17

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.
@@ -8,5 +8,6 @@ export declare class BeanExecutor extends BeanBase {
8
8
  newCtxIsolate<RESULT>(fn: FunctionAsync<RESULT>, options?: INewCtxOptions): Promise<RESULT>;
9
9
  mockCtx<RESULT>(fn: FunctionAsync<RESULT>, options?: INewCtxOptions): Promise<RESULT>;
10
10
  newCtx<RESULT>(fn: FunctionAsync<RESULT>, options?: INewCtxOptions): Promise<RESULT>;
11
- private _newCtxInner;
11
+ private _newCtxInnerStep1;
12
+ private _newCtxInnerStep2;
12
13
  }
package/dist/index.js CHANGED
@@ -77,12 +77,14 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
77
77
  return this.newCtx(fn, options);
78
78
  }
79
79
  async newCtx(fn, options) {
80
- if (isNil(options?.dbInfo)) return this._newCtxInner(fn, options);
81
- return this.bean.database.switchDb(() => {
82
- return this._newCtxInner(fn, options);
83
- }, options?.dbInfo);
80
+ return this._newCtxInnerStep1(() => {
81
+ if (isNil(options?.dbInfo)) return this._newCtxInnerStep2(fn, options);
82
+ return this.bean.database.switchDb(() => {
83
+ return this._newCtxInnerStep2(fn, options);
84
+ }, options?.dbInfo);
85
+ }, options);
84
86
  }
85
- async _newCtxInner(fn, options) {
87
+ async _newCtxInnerStep1(fn, options) {
86
88
  options = Object.assign({}, options);
87
89
  // innerAccess
88
90
  const innerAccess = options.innerAccess !== false;
@@ -122,30 +124,33 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
122
124
  __delegateProperties(ctx, options.extraData);
123
125
  }
124
126
  }
125
- // instance
126
- const instanceName = ctx.instanceName; // use default instanceName when undefined
127
- if (instanceName !== undefined && instanceName !== null) {
128
- ctx.instance = await this.bean.instance.get(instanceName);
129
- // start instance
130
- if (options.instance) {
131
- await this.$scope.instance.service.instance.checkAppReadyInstance(true);
132
- }
133
- }
134
- // execute
135
- let res;
136
- if (options.transaction) {
137
- res = await this.bean.database.current.transaction.begin(async () => {
138
- return await fn();
139
- }, options.transactionOptions);
140
- } else {
141
- res = await fn();
142
- }
143
- // commitsDone
144
- await ctx.commitsDone();
145
- // ok
146
- return res;
127
+ return await fn();
147
128
  });
148
129
  }
130
+ async _newCtxInnerStep2(fn, options) {
131
+ // instance
132
+ const instanceName = this.ctx.instanceName; // use default instanceName when undefined
133
+ if (instanceName !== undefined && instanceName !== null) {
134
+ this.ctx.instance = await this.bean.instance.get(instanceName);
135
+ // start instance
136
+ if (options?.instance) {
137
+ await this.$scope.instance.service.instance.checkAppReadyInstance(true);
138
+ }
139
+ }
140
+ // execute
141
+ let res;
142
+ if (options?.transaction) {
143
+ res = await this.bean.database.current.transaction.begin(async () => {
144
+ return await fn();
145
+ }, options?.transactionOptions);
146
+ } else {
147
+ res = await fn();
148
+ }
149
+ // commitsDone
150
+ await this.ctx.commitsDone();
151
+ // ok
152
+ return res;
153
+ }
149
154
  }) || _class$2) || _class$2);
150
155
 
151
156
  function _applyDecoratedDescriptor(i, e, r, n, l) {
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.16",
4
+ "version": "5.0.17",
5
5
  "title": "a-executor",
6
6
  "vonaModule": {
7
7
  "dependencies": {}