vona-module-a-executor 5.0.28 → 5.0.29

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.
Files changed (2) hide show
  1. package/dist/index.js +25 -37
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BeanInfo, BeanBase, cast, deepExtend, BeanScopeBase } from 'vona';
2
+ import { __decorate, __metadata } from 'tslib';
2
3
  import { isNil, combineParamsAndQuery } from '@cabloy/utils';
3
4
  import { Bean, Service, Scope } from 'vona-module-a-bean';
4
5
  import { Aspect } from 'vona-module-a-aspect';
@@ -16,7 +17,6 @@ function __delegateProperty(ctx, ctxCaller, property) {
16
17
  if (!ctxCaller[property]) ctxCaller[property] = {};
17
18
  ctx[property] = ctxCaller[property];
18
19
  }
19
-
20
20
  // export function delegateProperty(ctx, ctxCaller, property) {
21
21
  // if (!ctxCaller[property]) return;
22
22
  // if (!ctx[property]) ctx[property] = {};
@@ -24,7 +24,6 @@ function __delegateProperty(ctx, ctxCaller, property) {
24
24
  // ctx[property][key] = ctxCaller[property][key];
25
25
  // }
26
26
  // }
27
-
28
27
  // function _delegateProperty(ctx, ctxCaller, property) {
29
28
  // const keyMock = `__executeBean__mock__${property}__`;
30
29
  // const keyOriginal = `__executeBean__mock__${property}__original__`;
@@ -48,10 +47,7 @@ function __delegateProperty(ctx, ctxCaller, property) {
48
47
  // });
49
48
  // }
50
49
 
51
- var _dec$2, _dec2$2, _class$2;
52
- let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
53
- module: "a-executor"
54
- }), _dec$2(_class$2 = _dec2$2(_class$2 = class BeanExecutor extends BeanBase {
50
+ let BeanExecutor = class BeanExecutor extends BeanBase {
55
51
  async performAction(method, path, options) {
56
52
  // url
57
53
  const url = this.app.util.combineApiPath(path, '', true, true);
@@ -89,16 +85,14 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
89
85
  options = Object.assign({}, options);
90
86
  // innerAccess
91
87
  const innerAccess = options.innerAccess !== false;
92
- // ctx ref
93
- const ctxRef = innerAccess ? this.ctx : undefined;
94
88
  // isolate
95
- const isolate = !ctxRef || options.instanceName !== undefined;
96
- const ctxCaller = !isolate && ctxRef ? ctxRef : undefined;
97
- // locale/instanceName
98
- if (ctxRef) {
99
- options.locale = options.locale === undefined ? ctxRef.locale : options.locale;
100
- options.tz = options.tz === undefined ? ctxRef.tz : options.tz;
101
- options.instanceName = options.instanceName === undefined ? ctxRef.instanceName : options.instanceName;
89
+ const isolate = !this.ctx || options.instanceName !== undefined || !innerAccess && this.ctx?.instanceName === null;
90
+ const ctxCaller = !isolate && this.ctx ? this.ctx : undefined;
91
+ // locale/tz/instanceName
92
+ if (!isolate && this.ctx) {
93
+ options.locale = options.locale === undefined ? this.ctx.locale : options.locale;
94
+ options.tz = options.tz === undefined ? this.ctx.tz : options.tz;
95
+ options.instanceName = options.instanceName === undefined ? !innerAccess && this.ctx.instanceName === null ? undefined : this.ctx.instanceName : options.instanceName;
102
96
  }
103
97
  // run
104
98
  const ctx = this.app.createAnonymousContext(options.req, options.res);
@@ -160,25 +154,15 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
160
154
  // ok
161
155
  return res;
162
156
  }
163
- }) || _class$2) || _class$2);
164
-
165
- function _applyDecoratedDescriptor(i, e, r, n, l) {
166
- var a = {};
167
- return Object.keys(n).forEach(function (i) {
168
- a[i] = n[i];
169
- }), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = true), a = r.slice().reverse().reduce(function (r, n) {
170
- return n(i, e, r) || r;
171
- }, 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;
172
- }
157
+ };
158
+ BeanExecutor = __decorate([Bean(), BeanInfo({
159
+ module: "a-executor"
160
+ })], BeanExecutor);
173
161
 
174
162
  const SymbolRouterMiddleware = Symbol('SymbolRouterMiddleware');
175
163
 
176
- var _dec$1, _dec2$1, _dec3, _dec4, _dec5, _class$1, _class2;
177
- let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
178
- module: "a-executor"
179
- }), _dec3 = Aspect.aopMethod('a-logger:log', {
180
- level: 'debug'
181
- }), _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 {
164
+ var _a;
165
+ let ServiceExecutor = class ServiceExecutor extends BeanBase {
182
166
  async performActionInner(method, url, options) {
183
167
  // app
184
168
  const app = this.app;
@@ -275,8 +259,13 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
275
259
  }
276
260
  return options;
277
261
  }
278
- }, _applyDecoratedDescriptor(_class2.prototype, "performActionInner", [_dec3, _dec4, _dec5], Object.getOwnPropertyDescriptor(_class2.prototype, "performActionInner"), _class2.prototype), _class2)) || _class$1) || _class$1);
279
-
262
+ };
263
+ __decorate([Aspect.aopMethod('a-logger:log', {
264
+ level: 'debug'
265
+ }), __metadata("design:type", Function), __metadata("design:paramtypes", [typeof (_a = typeof METHOD !== "undefined" && METHOD) === "function" ? _a : Object, String, Object]), __metadata("design:returntype", Promise)], ServiceExecutor.prototype, "performActionInner", null);
266
+ ServiceExecutor = __decorate([Service(), BeanInfo({
267
+ module: "a-executor"
268
+ })], ServiceExecutor);
280
269
  // for (const key of ['x-clientid', 'x-scene']) {
281
270
  // if (!headers[key]) {
282
271
  // const value =
@@ -297,11 +286,10 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
297
286
  // }
298
287
  // }
299
288
 
300
- var _dec, _dec2, _class;
301
- let ScopeModuleAExecutor = (_dec = Scope(), _dec2 = BeanInfo({
289
+ let ScopeModuleAExecutor = class ScopeModuleAExecutor extends BeanScopeBase {};
290
+ ScopeModuleAExecutor = __decorate([Scope(), BeanInfo({
302
291
  module: "a-executor"
303
- }), _dec(_class = _dec2(_class = class ScopeModuleAExecutor extends BeanScopeBase {}) || _class) || _class);
304
-
292
+ })], ScopeModuleAExecutor);
305
293
  /** scope: end */
306
294
 
307
295
  export { BeanExecutor, ScopeModuleAExecutor, ServiceExecutor, SymbolRouterMiddleware };
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.28",
4
+ "version": "5.0.29",
5
5
  "title": "a-executor",
6
6
  "vonaModule": {
7
7
  "dependencies": {}