vona 5.0.7 → 5.0.8
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/LICENSE +2 -15
- package/README.en-US.md +63 -0
- package/README.md +63 -1
- package/package.json +6 -77
- package/README.zh-CN.md +0 -1
- package/dist/app/extend/context.d.ts +0 -4
- package/dist/app/extend/context.js +0 -152
- package/dist/index.d.ts +0 -11
- package/dist/index.js +0 -35
- package/dist/lib/base/dbTransaction.d.ts +0 -12
- package/dist/lib/base/dbTransaction.js +0 -55
- package/dist/lib/base/error.d.ts +0 -18
- package/dist/lib/base/error.js +0 -70
- package/dist/lib/base/model.d.ts +0 -22
- package/dist/lib/base/model.js +0 -253
- package/dist/lib/bean/_beanLocal_.d.ts +0 -6
- package/dist/lib/bean/_beanLocal_.js +0 -16
- package/dist/lib/bean/beanBase.d.ts +0 -11
- package/dist/lib/bean/beanBase.js +0 -34
- package/dist/lib/bean/beanBaseSimple.d.ts +0 -8
- package/dist/lib/bean/beanBaseSimple.js +0 -31
- package/dist/lib/bean/beanContainer.d.ts +0 -39
- package/dist/lib/bean/beanContainer.js +0 -516
- package/dist/lib/bean/beanLocal.d.ts +0 -6
- package/dist/lib/bean/beanLocal.js +0 -16
- package/dist/lib/bean/beanModuleScopeBase.d.ts +0 -10
- package/dist/lib/bean/beanModuleScopeBase.js +0 -28
- package/dist/lib/bean/beanScopeBase.d.ts +0 -6
- package/dist/lib/bean/beanScopeBase.js +0 -19
- package/dist/lib/bean/beanScopeScene.d.ts +0 -12
- package/dist/lib/bean/beanScopeScene.js +0 -23
- package/dist/lib/bean/beanSimple.d.ts +0 -7
- package/dist/lib/bean/beanSimple.js +0 -24
- package/dist/lib/bean/index.d.ts +0 -8
- package/dist/lib/bean/index.js +0 -24
- package/dist/lib/bean/resource/config/broadcast.d.ts +0 -7
- package/dist/lib/bean/resource/config/broadcast.js +0 -3
- package/dist/lib/bean/resource/config/index.d.ts +0 -2
- package/dist/lib/bean/resource/config/index.js +0 -18
- package/dist/lib/bean/resource/config/middleware.d.ts +0 -9
- package/dist/lib/bean/resource/config/middleware.js +0 -3
- package/dist/lib/bean/resource/config/startup.d.ts +0 -9
- package/dist/lib/bean/resource/config/startup.js +0 -3
- package/dist/lib/bean/resource/config/type.d.ts +0 -43
- package/dist/lib/bean/resource/config/type.js +0 -3
- package/dist/lib/bean/resource/constant/index.d.ts +0 -2
- package/dist/lib/bean/resource/constant/index.js +0 -18
- package/dist/lib/bean/resource/constant/type.d.ts +0 -2
- package/dist/lib/bean/resource/constant/type.js +0 -3
- package/dist/lib/bean/resource/entity/entityBase.d.ts +0 -18
- package/dist/lib/bean/resource/entity/entityBase.js +0 -20
- package/dist/lib/bean/resource/entity/index.d.ts +0 -2
- package/dist/lib/bean/resource/entity/index.js +0 -18
- package/dist/lib/bean/resource/entity/type.d.ts +0 -4
- package/dist/lib/bean/resource/entity/type.js +0 -3
- package/dist/lib/bean/resource/error/beanScopeError.d.ts +0 -11
- package/dist/lib/bean/resource/error/beanScopeError.js +0 -34
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +0 -14
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +0 -35
- package/dist/lib/bean/resource/error/errorClass.d.ts +0 -18
- package/dist/lib/bean/resource/error/errorClass.js +0 -78
- package/dist/lib/bean/resource/error/errorContext.d.ts +0 -38
- package/dist/lib/bean/resource/error/errorContext.js +0 -3
- package/dist/lib/bean/resource/error/errorGlobal.d.ts +0 -8
- package/dist/lib/bean/resource/error/errorGlobal.js +0 -3
- package/dist/lib/bean/resource/error/errorInternal.d.ts +0 -67
- package/dist/lib/bean/resource/error/errorInternal.js +0 -70
- package/dist/lib/bean/resource/error/errorObject.d.ts +0 -5
- package/dist/lib/bean/resource/error/errorObject.js +0 -3
- package/dist/lib/bean/resource/error/index.d.ts +0 -9
- package/dist/lib/bean/resource/error/index.js +0 -25
- package/dist/lib/bean/resource/error/type.d.ts +0 -9
- package/dist/lib/bean/resource/error/type.js +0 -3
- package/dist/lib/bean/resource/index.d.ts +0 -8
- package/dist/lib/bean/resource/index.js +0 -24
- package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +0 -11
- package/dist/lib/bean/resource/locale/beanScopeLocale.js +0 -33
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.d.ts +0 -3
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.js +0 -14
- package/dist/lib/bean/resource/locale/index.d.ts +0 -4
- package/dist/lib/bean/resource/locale/index.js +0 -20
- package/dist/lib/bean/resource/locale/localeCtx.d.ts +0 -8
- package/dist/lib/bean/resource/locale/localeCtx.js +0 -63
- package/dist/lib/bean/resource/locale/type.d.ts +0 -19
- package/dist/lib/bean/resource/locale/type.js +0 -3
- package/dist/lib/bean/resource/model/beanModelBase.d.ts +0 -24
- package/dist/lib/bean/resource/model/beanModelBase.js +0 -165
- package/dist/lib/bean/resource/model/beanModelBaseInner.d.ts +0 -29
- package/dist/lib/bean/resource/model/beanModelBaseInner.js +0 -86
- package/dist/lib/bean/resource/model/index.d.ts +0 -2
- package/dist/lib/bean/resource/model/index.js +0 -18
- package/dist/lib/bean/resource/model/type.d.ts +0 -14
- package/dist/lib/bean/resource/model/type.js +0 -3
- package/dist/lib/bean/resource/route/index.d.ts +0 -2
- package/dist/lib/bean/resource/route/index.js +0 -18
- package/dist/lib/bean/resource/route/type.d.ts +0 -60
- package/dist/lib/bean/resource/route/type.js +0 -3
- package/dist/lib/bean/scope/beanScopeBase.d.ts +0 -19
- package/dist/lib/bean/scope/beanScopeBase.js +0 -104
- package/dist/lib/bean/scope/beanScopeBean.d.ts +0 -10
- package/dist/lib/bean/scope/beanScopeBean.js +0 -34
- package/dist/lib/bean/scope/beanScopeError.d.ts +0 -11
- package/dist/lib/bean/scope/beanScopeError.js +0 -21
- package/dist/lib/bean/scope/beanScopeErrorImpl.d.ts +0 -14
- package/dist/lib/bean/scope/beanScopeErrorImpl.js +0 -21
- package/dist/lib/bean/scope/beanScopeScene.d.ts +0 -12
- package/dist/lib/bean/scope/beanScopeScene.js +0 -42
- package/dist/lib/bean/scope/index.d.ts +0 -5
- package/dist/lib/bean/scope/index.js +0 -21
- package/dist/lib/bean/scope/type.d.ts +0 -21
- package/dist/lib/bean/scope/type.js +0 -3
- package/dist/lib/bean/type.d.ts +0 -17
- package/dist/lib/bean/type.js +0 -4
- package/dist/lib/core/index.d.ts +0 -5
- package/dist/lib/core/index.js +0 -21
- package/dist/lib/core/meta.d.ts +0 -68
- package/dist/lib/core/meta.js +0 -345
- package/dist/lib/core/metaCtx.d.ts +0 -16
- package/dist/lib/core/metaCtx.js +0 -71
- package/dist/lib/core/metadata.d.ts +0 -12
- package/dist/lib/core/metadata.js +0 -52
- package/dist/lib/core/resource.d.ts +0 -29
- package/dist/lib/core/resource.js +0 -173
- package/dist/lib/decorator/class/aop.d.ts +0 -3
- package/dist/lib/decorator/class/aop.js +0 -22
- package/dist/lib/decorator/class/atom.d.ts +0 -2
- package/dist/lib/decorator/class/atom.js +0 -20
- package/dist/lib/decorator/class/bean.d.ts +0 -3
- package/dist/lib/decorator/class/bean.js +0 -23
- package/dist/lib/decorator/class/controller.d.ts +0 -2
- package/dist/lib/decorator/class/controller.js +0 -20
- package/dist/lib/decorator/class/entity.d.ts +0 -4
- package/dist/lib/decorator/class/entity.js +0 -33
- package/dist/lib/decorator/class/index.d.ts +0 -11
- package/dist/lib/decorator/class/index.js +0 -27
- package/dist/lib/decorator/class/local.d.ts +0 -3
- package/dist/lib/decorator/class/local.js +0 -23
- package/dist/lib/decorator/class/model.d.ts +0 -3
- package/dist/lib/decorator/class/model.js +0 -21
- package/dist/lib/decorator/class/scope.d.ts +0 -2
- package/dist/lib/decorator/class/scope.js +0 -20
- package/dist/lib/decorator/class/service.d.ts +0 -2
- package/dist/lib/decorator/class/service.js +0 -20
- package/dist/lib/decorator/class/use.d.ts +0 -5
- package/dist/lib/decorator/class/use.js +0 -43
- package/dist/lib/decorator/class/util.d.ts +0 -3
- package/dist/lib/decorator/class/util.js +0 -10
- package/dist/lib/decorator/class/virtual.d.ts +0 -3
- package/dist/lib/decorator/class/virtual.js +0 -24
- package/dist/lib/decorator/index.d.ts +0 -7
- package/dist/lib/decorator/index.js +0 -23
- package/dist/lib/decorator/interface/beanOptions.d.ts +0 -44
- package/dist/lib/decorator/interface/beanOptions.js +0 -8
- package/dist/lib/decorator/interface/useOptions.d.ts +0 -14
- package/dist/lib/decorator/interface/useOptions.js +0 -3
- package/dist/lib/decorator/type/constructable.d.ts +0 -2
- package/dist/lib/decorator/type/constructable.js +0 -3
- package/dist/lib/decorator/type/containerScope.d.ts +0 -2
- package/dist/lib/decorator/type/containerScope.js +0 -3
- package/dist/lib/decorator/type/injectionScope.d.ts +0 -2
- package/dist/lib/decorator/type/injectionScope.js +0 -3
- package/dist/lib/error/error.d.ts +0 -18
- package/dist/lib/error/error.js +0 -71
- package/dist/lib/error/errorClass.d.ts +0 -18
- package/dist/lib/error/errorClass.js +0 -72
- package/dist/lib/error/errorContext.d.ts +0 -38
- package/dist/lib/error/errorContext.js +0 -3
- package/dist/lib/error/errorGlobal.d.ts +0 -8
- package/dist/lib/error/errorGlobal.js +0 -3
- package/dist/lib/error/errorInternal.d.ts +0 -67
- package/dist/lib/error/errorInternal.js +0 -70
- package/dist/lib/error/errorObject.d.ts +0 -5
- package/dist/lib/error/errorObject.js +0 -3
- package/dist/lib/error/index.d.ts +0 -5
- package/dist/lib/error/index.js +0 -21
- package/dist/lib/framework/bootstrap.d.ts +0 -9
- package/dist/lib/framework/bootstrap.js +0 -35
- package/dist/lib/framework/framework.d.ts +0 -11
- package/dist/lib/framework/framework.js +0 -28
- package/dist/lib/framework/loader.d.ts +0 -24
- package/dist/lib/framework/loader.js +0 -69
- package/dist/lib/framework/meta.d.ts +0 -2
- package/dist/lib/framework/meta.js +0 -23
- package/dist/lib/framework/metaClass.d.ts +0 -2
- package/dist/lib/framework/metaClass.js +0 -26
- package/dist/lib/framework/moduleInfo.d.ts +0 -3
- package/dist/lib/framework/moduleInfo.js +0 -67
- package/dist/lib/framework/util.d.ts +0 -4
- package/dist/lib/framework/util.js +0 -15
- package/dist/lib/module/asset/errors.d.ts +0 -68
- package/dist/lib/module/asset/errors.js +0 -69
- package/dist/lib/module/bean/index.d.ts +0 -4
- package/dist/lib/module/bean/index.js +0 -24
- package/dist/lib/module/broadcast/broadcast.d.ts +0 -3
- package/dist/lib/module/broadcast/broadcast.js +0 -49
- package/dist/lib/module/broadcast/broadcastClient.d.ts +0 -24
- package/dist/lib/module/broadcast/broadcastClient.js +0 -91
- package/dist/lib/module/cluster/agent.d.ts +0 -3
- package/dist/lib/module/cluster/agent.js +0 -22
- package/dist/lib/module/cluster/app.d.ts +0 -3
- package/dist/lib/module/cluster/app.js +0 -26
- package/dist/lib/module/config.d.ts +0 -3
- package/dist/lib/module/config.js +0 -67
- package/dist/lib/module/constant.d.ts +0 -3
- package/dist/lib/module/constant.js +0 -46
- package/dist/lib/module/contextPatch.d.ts +0 -3
- package/dist/lib/module/contextPatch.js +0 -16
- package/dist/lib/module/errors.d.ts +0 -3
- package/dist/lib/module/errors.js +0 -49
- package/dist/lib/module/index.d.ts +0 -2
- package/dist/lib/module/index.js +0 -3
- package/dist/lib/module/loader.d.ts +0 -5
- package/dist/lib/module/loader.js +0 -73
- package/dist/lib/module/locales.d.ts +0 -3
- package/dist/lib/module/locales.js +0 -132
- package/dist/lib/module/messenger.d.ts +0 -25
- package/dist/lib/module/messenger.js +0 -128
- package/dist/lib/module/middleware.d.ts +0 -3
- package/dist/lib/module/middleware.js +0 -113
- package/dist/lib/module/model.d.ts +0 -3
- package/dist/lib/module/model.js +0 -47
- package/dist/lib/module/module.d.ts +0 -12
- package/dist/lib/module/module.js +0 -135
- package/dist/lib/module/moduleMeta.d.ts +0 -3
- package/dist/lib/module/moduleMeta.js +0 -23
- package/dist/lib/module/queue/queue.d.ts +0 -3
- package/dist/lib/module/queue/queue.js +0 -59
- package/dist/lib/module/queue/queueClient.d.ts +0 -26
- package/dist/lib/module/queue/queueClient.js +0 -262
- package/dist/lib/module/redis.d.ts +0 -11
- package/dist/lib/module/redis.js +0 -46
- package/dist/lib/module/reload/development.d.ts +0 -3
- package/dist/lib/module/reload/development.js +0 -98
- package/dist/lib/module/reload/reload.d.ts +0 -16
- package/dist/lib/module/reload/reload.js +0 -113
- package/dist/lib/module/reload.d.ts +0 -7
- package/dist/lib/module/reload.js +0 -17
- package/dist/lib/module/route.d.ts +0 -10
- package/dist/lib/module/route.js +0 -239
- package/dist/lib/module/schedule.d.ts +0 -3
- package/dist/lib/module/schedule.js +0 -129
- package/dist/lib/module/service.d.ts +0 -3
- package/dist/lib/module/service.js +0 -35
- package/dist/lib/module/socketio.d.ts +0 -5
- package/dist/lib/module/socketio.js +0 -47
- package/dist/lib/module/startup.d.ts +0 -2
- package/dist/lib/module/startup.js +0 -134
- package/dist/lib/module/version/clear.d.ts +0 -2
- package/dist/lib/module/version/clear.js +0 -42
- package/dist/lib/module/version/ready.d.ts +0 -6
- package/dist/lib/module/version/ready.js +0 -106
- package/dist/lib/resource/error/errorClass.d.ts +0 -18
- package/dist/lib/resource/error/errorClass.js +0 -72
- package/dist/lib/resource/error/errorContext.d.ts +0 -38
- package/dist/lib/resource/error/errorContext.js +0 -3
- package/dist/lib/resource/error/errorGlobal.d.ts +0 -8
- package/dist/lib/resource/error/errorGlobal.js +0 -3
- package/dist/lib/resource/error/errorInternal.d.ts +0 -67
- package/dist/lib/resource/error/errorInternal.js +0 -70
- package/dist/lib/resource/error/errorObject.d.ts +0 -5
- package/dist/lib/resource/error/errorObject.js +0 -3
- package/dist/lib/resource/error/index.d.ts +0 -5
- package/dist/lib/resource/error/index.js +0 -21
- package/dist/lib/utils/index.d.ts +0 -2
- package/dist/lib/utils/index.js +0 -18
- package/dist/lib/utils/isClass.d.ts +0 -2
- package/dist/lib/utils/isClass.js +0 -20
- package/dist/lib/utils/mockUtil.d.ts +0 -11
- package/dist/lib/utils/mockUtil.js +0 -34
- package/dist/lib/utils/mockUtilCtx.d.ts +0 -10
- package/dist/lib/utils/mockUtilCtx.js +0 -35
- package/dist/lib/utils/performAction.d.ts +0 -19
- package/dist/lib/utils/performAction.js +0 -137
- package/dist/lib/utils/util.d.ts +0 -63
- package/dist/lib/utils/util.js +0 -445
- package/dist/lib/utils/utilCtx.d.ts +0 -34
- package/dist/lib/utils/utilCtx.js +0 -137
- package/dist/types/application/app.d.ts +0 -21
- package/dist/types/application/app.js +0 -28
- package/dist/types/application/index.d.ts +0 -2
- package/dist/types/application/index.js +0 -18
- package/dist/types/config/appInfo.d.ts +0 -4
- package/dist/types/config/appInfo.js +0 -3
- package/dist/types/config/config.d.ts +0 -10
- package/dist/types/config/config.js +0 -3
- package/dist/types/config/development.d.ts +0 -4
- package/dist/types/config/development.js +0 -3
- package/dist/types/config/index.d.ts +0 -4
- package/dist/types/config/index.js +0 -20
- package/dist/types/config/locale.d.ts +0 -10
- package/dist/types/config/locale.js +0 -7
- package/dist/types/context/contextBase.d.ts +0 -21
- package/dist/types/context/contextBase.js +0 -3
- package/dist/types/context/contextConfig.d.ts +0 -4
- package/dist/types/context/contextConfig.js +0 -3
- package/dist/types/context/contextError.d.ts +0 -25
- package/dist/types/context/contextError.js +0 -3
- package/dist/types/context/contextLocale.d.ts +0 -9
- package/dist/types/context/contextLocale.js +0 -3
- package/dist/types/context/contextOthers.d.ts +0 -4
- package/dist/types/context/contextOthers.js +0 -3
- package/dist/types/context/contextState.d.ts +0 -8
- package/dist/types/context/contextState.js +0 -3
- package/dist/types/context/index.d.ts +0 -18
- package/dist/types/context/index.js +0 -18
- package/dist/types/enum/appEvent.d.ts +0 -5
- package/dist/types/enum/appEvent.js +0 -9
- package/dist/types/enum/index.d.ts +0 -2
- package/dist/types/enum/index.js +0 -18
- package/dist/types/index.d.ts +0 -7
- package/dist/types/index.js +0 -23
- package/dist/types/interface/broadcast.d.ts +0 -5
- package/dist/types/interface/broadcast.js +0 -3
- package/dist/types/interface/error.d.ts +0 -8
- package/dist/types/interface/error.js +0 -3
- package/dist/types/interface/index.d.ts +0 -6
- package/dist/types/interface/index.js +0 -22
- package/dist/types/interface/module.d.ts +0 -32
- package/dist/types/interface/module.js +0 -18
- package/dist/types/interface/monkey.d.ts +0 -22
- package/dist/types/interface/monkey.js +0 -3
- package/dist/types/interface/queue.d.ts +0 -29
- package/dist/types/interface/queue.js +0 -3
- package/dist/types/interface/schedule.d.ts +0 -11
- package/dist/types/interface/schedule.js +0 -3
- package/dist/types/utils/cast.d.ts +0 -6
- package/dist/types/utils/cast.js +0 -8
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/index.js +0 -20
- package/dist/types/utils/powerPartial.d.ts +0 -4
- package/dist/types/utils/powerPartial.js +0 -3
- package/dist/types/utils/type.d.ts +0 -4
- package/dist/types/utils/type.js +0 -3
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
2
|
-
export declare class AppMockUtil extends BeanSimple {
|
|
3
|
-
parseUrlFromModuleInfo(moduleInfo: any, apiPrefix?: string | boolean): string | null;
|
|
4
|
-
mockUrl(moduleInfo: any, url: any, apiPrefix?: string | boolean): string;
|
|
5
|
-
mockCtx(options?: {
|
|
6
|
-
locale?: string;
|
|
7
|
-
subdomain?: string | null;
|
|
8
|
-
module?: string;
|
|
9
|
-
}): Promise<import("../../index.js").VonaContext>;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=mockUtil.d.ts.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppMockUtil = void 0;
|
|
4
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
5
|
-
class AppMockUtil extends beanSimple_js_1.BeanSimple {
|
|
6
|
-
parseUrlFromModuleInfo(moduleInfo, apiPrefix = true) {
|
|
7
|
-
apiPrefix = _prepareApiPrefix(apiPrefix);
|
|
8
|
-
if (!moduleInfo)
|
|
9
|
-
return null;
|
|
10
|
-
return `${apiPrefix}/${moduleInfo.pid}/${moduleInfo.name}`;
|
|
11
|
-
}
|
|
12
|
-
mockUrl(moduleInfo, url, apiPrefix = true) {
|
|
13
|
-
apiPrefix = _prepareApiPrefix(apiPrefix);
|
|
14
|
-
if (url && url.charAt(0) === '/')
|
|
15
|
-
return `${apiPrefix}${url}`;
|
|
16
|
-
const prefix = this.parseUrlFromModuleInfo(moduleInfo, apiPrefix);
|
|
17
|
-
return url ? `${prefix}/${url}` : `${prefix}/`;
|
|
18
|
-
}
|
|
19
|
-
async mockCtx(options) {
|
|
20
|
-
options = options || {};
|
|
21
|
-
const locale = options.locale;
|
|
22
|
-
const subdomain = options.subdomain !== undefined ? options.subdomain : '';
|
|
23
|
-
const module = options.module;
|
|
24
|
-
const ctx = await this.app.meta.util.createAnonymousContext({ locale, subdomain, module });
|
|
25
|
-
return ctx;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.AppMockUtil = AppMockUtil;
|
|
29
|
-
function _prepareApiPrefix(apiPrefix) {
|
|
30
|
-
if (typeof apiPrefix === 'string')
|
|
31
|
-
return apiPrefix;
|
|
32
|
-
return apiPrefix ? '/api' : '';
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=mockUtil.js.map
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
2
|
-
export declare class CtxMockUtil extends BeanSimple {
|
|
3
|
-
login({ auth, password }: {
|
|
4
|
-
auth: any;
|
|
5
|
-
password?: string | undefined;
|
|
6
|
-
}): Promise<any>;
|
|
7
|
-
logout(): Promise<any>;
|
|
8
|
-
catchError(fnMethod: any, fnError: any): Promise<any>;
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=mockUtilCtx.d.ts.map
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CtxMockUtil = void 0;
|
|
4
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
5
|
-
class CtxMockUtil extends beanSimple_js_1.BeanSimple {
|
|
6
|
-
// login
|
|
7
|
-
async login({ auth, password = '123456' }) {
|
|
8
|
-
return await this.ctx.bean.authSimple.signinDirect({ data: { auth, password } });
|
|
9
|
-
}
|
|
10
|
-
// logout
|
|
11
|
-
async logout() {
|
|
12
|
-
return await this.ctx.bean.auth.logout();
|
|
13
|
-
}
|
|
14
|
-
// catchError
|
|
15
|
-
async catchError(fnMethod, fnError) {
|
|
16
|
-
let success;
|
|
17
|
-
let data;
|
|
18
|
-
try {
|
|
19
|
-
data = await fnMethod();
|
|
20
|
-
success = true;
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
success = false;
|
|
24
|
-
await fnError(err);
|
|
25
|
-
}
|
|
26
|
-
// success
|
|
27
|
-
if (success) {
|
|
28
|
-
const err = { code: 0 };
|
|
29
|
-
await fnError(err, data);
|
|
30
|
-
}
|
|
31
|
-
return data;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.CtxMockUtil = CtxMockUtil;
|
|
35
|
-
//# sourceMappingURL=mockUtilCtx.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* perform action of this or that module
|
|
3
|
-
* @param {string} options options
|
|
4
|
-
* @param {string} options.method method
|
|
5
|
-
* @param {string} options.url url
|
|
6
|
-
* @param {json} options.body body(optional)
|
|
7
|
-
* @return {promise} response.body.data or throw error
|
|
8
|
-
*/
|
|
9
|
-
export default function performAction({ ctxCaller, innerAccess, method, url, query, params, headers, body, }: {
|
|
10
|
-
ctxCaller: any;
|
|
11
|
-
innerAccess: any;
|
|
12
|
-
method: any;
|
|
13
|
-
url: any;
|
|
14
|
-
query: any;
|
|
15
|
-
params: any;
|
|
16
|
-
headers: any;
|
|
17
|
-
body: any;
|
|
18
|
-
}): Promise<any>;
|
|
19
|
-
//# sourceMappingURL=performAction.d.ts.map
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const http_1 = __importDefault(require("http"));
|
|
7
|
-
const koa_compose_1 = __importDefault(require("koa-compose"));
|
|
8
|
-
let __fnMiddleware;
|
|
9
|
-
/**
|
|
10
|
-
* perform action of this or that module
|
|
11
|
-
* @param {string} options options
|
|
12
|
-
* @param {string} options.method method
|
|
13
|
-
* @param {string} options.url url
|
|
14
|
-
* @param {json} options.body body(optional)
|
|
15
|
-
* @return {promise} response.body.data or throw error
|
|
16
|
-
*/
|
|
17
|
-
async function performAction({ ctxCaller, innerAccess,
|
|
18
|
-
// subdomain, deprecated
|
|
19
|
-
method, url, query, params, headers, body, }) {
|
|
20
|
-
// app
|
|
21
|
-
const app = ctxCaller.app;
|
|
22
|
-
// middleware
|
|
23
|
-
if (!__fnMiddleware) {
|
|
24
|
-
const middleware = app.middleware[app.middleware.length - 1];
|
|
25
|
-
__fnMiddleware = (0, koa_compose_1.default)([middleware]);
|
|
26
|
-
}
|
|
27
|
-
// request
|
|
28
|
-
url = app.meta.util.combineFetchPath(ctxCaller.module && ctxCaller.module.info, url);
|
|
29
|
-
const req = createRequest({ method, url }, ctxCaller);
|
|
30
|
-
// response
|
|
31
|
-
const res = new http_1.default.ServerResponse(req);
|
|
32
|
-
// default status code
|
|
33
|
-
res.statusCode = 404;
|
|
34
|
-
// ctx
|
|
35
|
-
const ctx = app.createContext(req, res);
|
|
36
|
-
// locale
|
|
37
|
-
Object.defineProperty(ctx, 'locale', {
|
|
38
|
-
get() {
|
|
39
|
-
return ctxCaller.locale;
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
// subdomain
|
|
43
|
-
Object.defineProperty(ctx, 'subdomain', {
|
|
44
|
-
get() {
|
|
45
|
-
return ctxCaller.subdomain;
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
// query params body
|
|
49
|
-
if (query) {
|
|
50
|
-
ctx.req.query = ctx.request.query = query;
|
|
51
|
-
}
|
|
52
|
-
if (params) {
|
|
53
|
-
ctx.req.params = ctx.request.params = params;
|
|
54
|
-
}
|
|
55
|
-
ctx.req.body = ctx.request.body = body !== undefined ? body : {}; // not undefined
|
|
56
|
-
// headers
|
|
57
|
-
delegateHeaders(ctx, ctxCaller, headers);
|
|
58
|
-
// multipart
|
|
59
|
-
ctx.multipart = function (options) {
|
|
60
|
-
return ctxCaller.multipart(options);
|
|
61
|
-
};
|
|
62
|
-
// cookies
|
|
63
|
-
delegateCookies(ctx, ctxCaller);
|
|
64
|
-
// XX should not delegate session, because session._ctx related to ctx
|
|
65
|
-
// not delegate ctx.user, because will create req.user by state.user
|
|
66
|
-
for (const property of ['state', 'socket', 'session', 'instance']) {
|
|
67
|
-
delegateProperty(ctx, ctxCaller, property);
|
|
68
|
-
}
|
|
69
|
-
// ctxCaller
|
|
70
|
-
ctx.ctxCaller = ctxCaller;
|
|
71
|
-
// innerAccess
|
|
72
|
-
if (innerAccess !== undefined)
|
|
73
|
-
ctx.innerAccess = innerAccess;
|
|
74
|
-
// invoke middleware
|
|
75
|
-
await __fnMiddleware(ctx);
|
|
76
|
-
// check result
|
|
77
|
-
if (ctx.status === 200) {
|
|
78
|
-
if (!ctx.body || ctx.body.code === undefined) {
|
|
79
|
-
// not check code, e.g. text/xml
|
|
80
|
-
return ctx.body;
|
|
81
|
-
}
|
|
82
|
-
if (ctx.body.code === 0) {
|
|
83
|
-
return ctx.body.data;
|
|
84
|
-
}
|
|
85
|
-
throw ctx.createError(ctx.body);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
throw ctx.createError({
|
|
89
|
-
code: ctx.status,
|
|
90
|
-
message: ctx.message || ctx.body,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.default = performAction;
|
|
95
|
-
function delegateHeaders(ctx, ctxCaller, headers) {
|
|
96
|
-
if (ctxCaller && ctxCaller.headers) {
|
|
97
|
-
Object.assign(ctx.headers, ctxCaller.headers);
|
|
98
|
-
}
|
|
99
|
-
if (headers) {
|
|
100
|
-
Object.assign(ctx.headers, headers);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
function delegateCookies(ctx, ctxCaller) {
|
|
104
|
-
const _cookies = ctx.cookies;
|
|
105
|
-
Object.defineProperty(ctx, 'cookies', {
|
|
106
|
-
get() {
|
|
107
|
-
return ctxCaller.cookies || _cookies;
|
|
108
|
-
},
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
function delegateProperty(ctx, ctxCaller, property) {
|
|
112
|
-
Object.defineProperty(ctx, property, {
|
|
113
|
-
get() {
|
|
114
|
-
return ctxCaller[property];
|
|
115
|
-
},
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
function createRequest({ method, url }, ctxCaller) {
|
|
119
|
-
// _req
|
|
120
|
-
const _req = ctxCaller.request;
|
|
121
|
-
// req
|
|
122
|
-
const req = new http_1.default.IncomingMessage(null);
|
|
123
|
-
req.headers = _req.headers;
|
|
124
|
-
req.host = _req.host;
|
|
125
|
-
req.hostname = _req.hostname;
|
|
126
|
-
req.protocol = _req.protocol;
|
|
127
|
-
req.secure = _req.secure;
|
|
128
|
-
req.method = method.toUpperCase();
|
|
129
|
-
req.url = url;
|
|
130
|
-
// path,
|
|
131
|
-
req.socket = {
|
|
132
|
-
remoteAddress: _req.socket.remoteAddress,
|
|
133
|
-
remotePort: _req.socket.remotePort,
|
|
134
|
-
};
|
|
135
|
-
return req;
|
|
136
|
-
}
|
|
137
|
-
//# sourceMappingURL=performAction.js.map
|
package/dist/lib/utils/util.d.ts
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import Redlock from 'redlock';
|
|
2
|
-
import { VonaContext, IModule, PowerPartial, TypeMonkeyName } from '../../types/index.js';
|
|
3
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
4
|
-
import { IModuleMiddlewareGate } from '../bean/index.js';
|
|
5
|
-
export interface IExecuteBeanCallbackParams {
|
|
6
|
-
ctx: VonaContext;
|
|
7
|
-
bean: any;
|
|
8
|
-
context: any;
|
|
9
|
-
}
|
|
10
|
-
export interface IExecuteBeanCallback {
|
|
11
|
-
(params: IExecuteBeanCallbackParams): Promise<any>;
|
|
12
|
-
}
|
|
13
|
-
export declare class AppUtil extends BeanSimple {
|
|
14
|
-
instanceStarted(subdomain: any): any;
|
|
15
|
-
combineFetchPath(moduleName: any, arg: any): any;
|
|
16
|
-
combineApiPath(moduleName: any, arg: any): any;
|
|
17
|
-
combineQueries(url: any, queries: any): any;
|
|
18
|
-
createError(data: any, returnObject?: boolean): any;
|
|
19
|
-
monkeyModule(ebAppMonkey: any, ebModulesMonkey: any, monkeyName: TypeMonkeyName, moduleTarget?: IModule, ...monkeyData: any[]): Promise<void>;
|
|
20
|
-
getWhiteListCors(ctx: any): any;
|
|
21
|
-
isSafeDomain(ctx: any, origin: any): boolean;
|
|
22
|
-
isNullOrEmptyString(str?: string | undefined | null): boolean;
|
|
23
|
-
compose(chains: any, adapter: any): (context: any, next?: any) => any;
|
|
24
|
-
composeAsync(chains: any, adapter: any): (context: any, next?: any) => Promise<any>;
|
|
25
|
-
createAnonymousContext({ locale, subdomain, module, instance }: {
|
|
26
|
-
locale: any;
|
|
27
|
-
subdomain: any;
|
|
28
|
-
module: any;
|
|
29
|
-
instance: any;
|
|
30
|
-
}): Promise<VonaContext>;
|
|
31
|
-
executeBean({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, ctxCaller, ctxParent, instance, }: {
|
|
32
|
-
locale?: string;
|
|
33
|
-
subdomain?: string;
|
|
34
|
-
beanModule?: string;
|
|
35
|
-
beanFullName?: string;
|
|
36
|
-
context: any;
|
|
37
|
-
fn?: any;
|
|
38
|
-
transaction?: boolean;
|
|
39
|
-
ctxCaller?: VonaContext;
|
|
40
|
-
ctxParent?: PowerPartial<VonaContext>;
|
|
41
|
-
instance?: boolean;
|
|
42
|
-
}): Promise<any>;
|
|
43
|
-
_executeBeanFn({ fn, ctx, bean, context }: {
|
|
44
|
-
fn: any;
|
|
45
|
-
ctx: any;
|
|
46
|
-
bean: any;
|
|
47
|
-
context: any;
|
|
48
|
-
}): Promise<any>;
|
|
49
|
-
lock({ subdomain, resource, fn, options, redlock, }: {
|
|
50
|
-
subdomain?: string;
|
|
51
|
-
resource: string;
|
|
52
|
-
fn: () => Promise<any>;
|
|
53
|
-
options: any;
|
|
54
|
-
redlock?: Redlock;
|
|
55
|
-
}): Promise<any>;
|
|
56
|
-
subdomainDesp(subdomain: any): any;
|
|
57
|
-
deprecated(oldUsage: any, newUsage: any): void;
|
|
58
|
-
checkGate(gate?: IModuleMiddlewareGate): boolean;
|
|
59
|
-
_checkGateEnv(env?: IModuleMiddlewareGate['env']): boolean;
|
|
60
|
-
requireDynamic(file: any): any;
|
|
61
|
-
private _requireDynamic_getFileTime;
|
|
62
|
-
}
|
|
63
|
-
//# sourceMappingURL=util.d.ts.map
|