vona-module-a-executor 5.0.28 → 5.0.30
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/index.js +29 -37
- 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
|
-
|
|
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);
|
|
@@ -66,6 +62,10 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
|
66
62
|
options = Object.assign({}, options);
|
|
67
63
|
// instanceName !== undefined means isolate
|
|
68
64
|
options.instanceName = options.instanceName === undefined ? this.ctx?.instanceName : options.instanceName;
|
|
65
|
+
if (options.instanceName === this.ctx?.instanceName) {
|
|
66
|
+
options.locale = options.locale === undefined ? this.ctx?.locale : options.locale;
|
|
67
|
+
options.tz = options.tz === undefined ? this.ctx?.tz : options.tz;
|
|
68
|
+
}
|
|
69
69
|
return this.newCtx(fn, options);
|
|
70
70
|
}
|
|
71
71
|
async mockCtx(fn, options) {
|
|
@@ -89,16 +89,14 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
|
89
89
|
options = Object.assign({}, options);
|
|
90
90
|
// innerAccess
|
|
91
91
|
const innerAccess = options.innerAccess !== false;
|
|
92
|
-
// ctx ref
|
|
93
|
-
const ctxRef = innerAccess ? this.ctx : undefined;
|
|
94
92
|
// isolate
|
|
95
|
-
const isolate = !
|
|
96
|
-
const ctxCaller = !isolate &&
|
|
97
|
-
// locale/instanceName
|
|
98
|
-
if (
|
|
99
|
-
options.locale = options.locale === undefined ?
|
|
100
|
-
options.tz = options.tz === undefined ?
|
|
101
|
-
options.instanceName = options.instanceName === undefined ?
|
|
93
|
+
const isolate = !this.ctx || options.instanceName !== undefined || !innerAccess && this.ctx?.instanceName === null;
|
|
94
|
+
const ctxCaller = !isolate && this.ctx ? this.ctx : undefined;
|
|
95
|
+
// locale/tz/instanceName
|
|
96
|
+
if (!isolate && this.ctx) {
|
|
97
|
+
options.locale = options.locale === undefined ? this.ctx.locale : options.locale;
|
|
98
|
+
options.tz = options.tz === undefined ? this.ctx.tz : options.tz;
|
|
99
|
+
options.instanceName = options.instanceName === undefined ? !innerAccess && this.ctx.instanceName === null ? undefined : this.ctx.instanceName : options.instanceName;
|
|
102
100
|
}
|
|
103
101
|
// run
|
|
104
102
|
const ctx = this.app.createAnonymousContext(options.req, options.res);
|
|
@@ -160,25 +158,15 @@ let BeanExecutor = (_dec$2 = Bean(), _dec2$2 = BeanInfo({
|
|
|
160
158
|
// ok
|
|
161
159
|
return res;
|
|
162
160
|
}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
-
}
|
|
161
|
+
};
|
|
162
|
+
BeanExecutor = __decorate([Bean(), BeanInfo({
|
|
163
|
+
module: "a-executor"
|
|
164
|
+
})], BeanExecutor);
|
|
173
165
|
|
|
174
166
|
const SymbolRouterMiddleware = Symbol('SymbolRouterMiddleware');
|
|
175
167
|
|
|
176
|
-
var
|
|
177
|
-
let ServiceExecutor =
|
|
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 {
|
|
168
|
+
var _a;
|
|
169
|
+
let ServiceExecutor = class ServiceExecutor extends BeanBase {
|
|
182
170
|
async performActionInner(method, url, options) {
|
|
183
171
|
// app
|
|
184
172
|
const app = this.app;
|
|
@@ -275,8 +263,13 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
275
263
|
}
|
|
276
264
|
return options;
|
|
277
265
|
}
|
|
278
|
-
}
|
|
279
|
-
|
|
266
|
+
};
|
|
267
|
+
__decorate([Aspect.aopMethod('a-logger:log', {
|
|
268
|
+
level: 'debug'
|
|
269
|
+
}), __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);
|
|
270
|
+
ServiceExecutor = __decorate([Service(), BeanInfo({
|
|
271
|
+
module: "a-executor"
|
|
272
|
+
})], ServiceExecutor);
|
|
280
273
|
// for (const key of ['x-clientid', 'x-scene']) {
|
|
281
274
|
// if (!headers[key]) {
|
|
282
275
|
// const value =
|
|
@@ -297,11 +290,10 @@ let ServiceExecutor = (_dec$1 = Service(), _dec2$1 = BeanInfo({
|
|
|
297
290
|
// }
|
|
298
291
|
// }
|
|
299
292
|
|
|
300
|
-
|
|
301
|
-
|
|
293
|
+
let ScopeModuleAExecutor = class ScopeModuleAExecutor extends BeanScopeBase {};
|
|
294
|
+
ScopeModuleAExecutor = __decorate([Scope(), BeanInfo({
|
|
302
295
|
module: "a-executor"
|
|
303
|
-
}),
|
|
304
|
-
|
|
296
|
+
})], ScopeModuleAExecutor);
|
|
305
297
|
/** scope: end */
|
|
306
298
|
|
|
307
299
|
export { BeanExecutor, ScopeModuleAExecutor, ServiceExecutor, SymbolRouterMiddleware };
|