vona 1.0.0 → 5.0.7
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 +21 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -0
- package/dist/app/extend/context.d.ts +4 -0
- package/dist/app/extend/context.js +152 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +35 -0
- package/dist/lib/base/dbTransaction.d.ts +12 -0
- package/dist/lib/base/dbTransaction.js +55 -0
- package/dist/lib/base/error.d.ts +18 -0
- package/dist/lib/base/error.js +70 -0
- package/dist/lib/base/model.d.ts +22 -0
- package/dist/lib/base/model.js +253 -0
- package/dist/lib/bean/_beanLocal_.d.ts +6 -0
- package/dist/lib/bean/_beanLocal_.js +16 -0
- package/dist/lib/bean/beanBase.d.ts +11 -0
- package/dist/lib/bean/beanBase.js +34 -0
- package/dist/lib/bean/beanBaseSimple.d.ts +8 -0
- package/dist/lib/bean/beanBaseSimple.js +31 -0
- package/dist/lib/bean/beanContainer.d.ts +39 -0
- package/dist/lib/bean/beanContainer.js +516 -0
- package/dist/lib/bean/beanLocal.d.ts +6 -0
- package/dist/lib/bean/beanLocal.js +16 -0
- package/dist/lib/bean/beanModuleScopeBase.d.ts +10 -0
- package/dist/lib/bean/beanModuleScopeBase.js +28 -0
- package/dist/lib/bean/beanScopeBase.d.ts +6 -0
- package/dist/lib/bean/beanScopeBase.js +19 -0
- package/dist/lib/bean/beanScopeScene.d.ts +12 -0
- package/dist/lib/bean/beanScopeScene.js +23 -0
- package/dist/lib/bean/beanSimple.d.ts +7 -0
- package/dist/lib/bean/beanSimple.js +24 -0
- package/dist/lib/bean/index.d.ts +8 -0
- package/dist/lib/bean/index.js +24 -0
- package/dist/lib/bean/resource/config/broadcast.d.ts +7 -0
- package/dist/lib/bean/resource/config/broadcast.js +3 -0
- package/dist/lib/bean/resource/config/index.d.ts +2 -0
- package/dist/lib/bean/resource/config/index.js +18 -0
- package/dist/lib/bean/resource/config/middleware.d.ts +9 -0
- package/dist/lib/bean/resource/config/middleware.js +3 -0
- package/dist/lib/bean/resource/config/startup.d.ts +9 -0
- package/dist/lib/bean/resource/config/startup.js +3 -0
- package/dist/lib/bean/resource/config/type.d.ts +43 -0
- package/dist/lib/bean/resource/config/type.js +3 -0
- package/dist/lib/bean/resource/constant/index.d.ts +2 -0
- package/dist/lib/bean/resource/constant/index.js +18 -0
- package/dist/lib/bean/resource/constant/type.d.ts +2 -0
- package/dist/lib/bean/resource/constant/type.js +3 -0
- package/dist/lib/bean/resource/entity/entityBase.d.ts +18 -0
- package/dist/lib/bean/resource/entity/entityBase.js +20 -0
- package/dist/lib/bean/resource/entity/index.d.ts +2 -0
- package/dist/lib/bean/resource/entity/index.js +18 -0
- package/dist/lib/bean/resource/entity/type.d.ts +4 -0
- package/dist/lib/bean/resource/entity/type.js +3 -0
- package/dist/lib/bean/resource/error/beanScopeError.d.ts +11 -0
- package/dist/lib/bean/resource/error/beanScopeError.js +34 -0
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.d.ts +14 -0
- package/dist/lib/bean/resource/error/beanScopeErrorImpl.js +35 -0
- package/dist/lib/bean/resource/error/errorClass.d.ts +18 -0
- package/dist/lib/bean/resource/error/errorClass.js +78 -0
- package/dist/lib/bean/resource/error/errorContext.d.ts +38 -0
- package/dist/lib/bean/resource/error/errorContext.js +3 -0
- package/dist/lib/bean/resource/error/errorGlobal.d.ts +8 -0
- package/dist/lib/bean/resource/error/errorGlobal.js +3 -0
- package/dist/lib/bean/resource/error/errorInternal.d.ts +67 -0
- package/dist/lib/bean/resource/error/errorInternal.js +70 -0
- package/dist/lib/bean/resource/error/errorObject.d.ts +5 -0
- package/dist/lib/bean/resource/error/errorObject.js +3 -0
- package/dist/lib/bean/resource/error/index.d.ts +9 -0
- package/dist/lib/bean/resource/error/index.js +25 -0
- package/dist/lib/bean/resource/error/type.d.ts +9 -0
- package/dist/lib/bean/resource/error/type.js +3 -0
- package/dist/lib/bean/resource/index.d.ts +8 -0
- package/dist/lib/bean/resource/index.js +24 -0
- package/dist/lib/bean/resource/locale/beanScopeLocale.d.ts +11 -0
- package/dist/lib/bean/resource/locale/beanScopeLocale.js +33 -0
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.d.ts +3 -0
- package/dist/lib/bean/resource/locale/beanScopeLocaleImpl.js +14 -0
- package/dist/lib/bean/resource/locale/index.d.ts +4 -0
- package/dist/lib/bean/resource/locale/index.js +20 -0
- package/dist/lib/bean/resource/locale/localeCtx.d.ts +8 -0
- package/dist/lib/bean/resource/locale/localeCtx.js +63 -0
- package/dist/lib/bean/resource/locale/type.d.ts +19 -0
- package/dist/lib/bean/resource/locale/type.js +3 -0
- package/dist/lib/bean/resource/model/beanModelBase.d.ts +24 -0
- package/dist/lib/bean/resource/model/beanModelBase.js +165 -0
- package/dist/lib/bean/resource/model/beanModelBaseInner.d.ts +29 -0
- package/dist/lib/bean/resource/model/beanModelBaseInner.js +86 -0
- package/dist/lib/bean/resource/model/index.d.ts +2 -0
- package/dist/lib/bean/resource/model/index.js +18 -0
- package/dist/lib/bean/resource/model/type.d.ts +14 -0
- package/dist/lib/bean/resource/model/type.js +3 -0
- package/dist/lib/bean/resource/route/index.d.ts +2 -0
- package/dist/lib/bean/resource/route/index.js +18 -0
- package/dist/lib/bean/resource/route/type.d.ts +60 -0
- package/dist/lib/bean/resource/route/type.js +3 -0
- package/dist/lib/bean/scope/beanScopeBase.d.ts +19 -0
- package/dist/lib/bean/scope/beanScopeBase.js +104 -0
- package/dist/lib/bean/scope/beanScopeBean.d.ts +10 -0
- package/dist/lib/bean/scope/beanScopeBean.js +34 -0
- package/dist/lib/bean/scope/beanScopeError.d.ts +11 -0
- package/dist/lib/bean/scope/beanScopeError.js +21 -0
- package/dist/lib/bean/scope/beanScopeErrorImpl.d.ts +14 -0
- package/dist/lib/bean/scope/beanScopeErrorImpl.js +21 -0
- package/dist/lib/bean/scope/beanScopeScene.d.ts +12 -0
- package/dist/lib/bean/scope/beanScopeScene.js +42 -0
- package/dist/lib/bean/scope/index.d.ts +5 -0
- package/dist/lib/bean/scope/index.js +21 -0
- package/dist/lib/bean/scope/type.d.ts +21 -0
- package/dist/lib/bean/scope/type.js +3 -0
- package/dist/lib/bean/type.d.ts +17 -0
- package/dist/lib/bean/type.js +4 -0
- package/dist/lib/core/index.d.ts +5 -0
- package/dist/lib/core/index.js +21 -0
- package/dist/lib/core/meta.d.ts +68 -0
- package/dist/lib/core/meta.js +345 -0
- package/dist/lib/core/metaCtx.d.ts +16 -0
- package/dist/lib/core/metaCtx.js +71 -0
- package/dist/lib/core/metadata.d.ts +12 -0
- package/dist/lib/core/metadata.js +52 -0
- package/dist/lib/core/resource.d.ts +29 -0
- package/dist/lib/core/resource.js +173 -0
- package/dist/lib/decorator/class/aop.d.ts +3 -0
- package/dist/lib/decorator/class/aop.js +22 -0
- package/dist/lib/decorator/class/atom.d.ts +2 -0
- package/dist/lib/decorator/class/atom.js +20 -0
- package/dist/lib/decorator/class/bean.d.ts +3 -0
- package/dist/lib/decorator/class/bean.js +23 -0
- package/dist/lib/decorator/class/controller.d.ts +2 -0
- package/dist/lib/decorator/class/controller.js +20 -0
- package/dist/lib/decorator/class/entity.d.ts +4 -0
- package/dist/lib/decorator/class/entity.js +33 -0
- package/dist/lib/decorator/class/index.d.ts +11 -0
- package/dist/lib/decorator/class/index.js +27 -0
- package/dist/lib/decorator/class/local.d.ts +3 -0
- package/dist/lib/decorator/class/local.js +23 -0
- package/dist/lib/decorator/class/model.d.ts +3 -0
- package/dist/lib/decorator/class/model.js +21 -0
- package/dist/lib/decorator/class/scope.d.ts +2 -0
- package/dist/lib/decorator/class/scope.js +20 -0
- package/dist/lib/decorator/class/service.d.ts +2 -0
- package/dist/lib/decorator/class/service.js +20 -0
- package/dist/lib/decorator/class/use.d.ts +5 -0
- package/dist/lib/decorator/class/use.js +43 -0
- package/dist/lib/decorator/class/util.d.ts +3 -0
- package/dist/lib/decorator/class/util.js +10 -0
- package/dist/lib/decorator/class/virtual.d.ts +3 -0
- package/dist/lib/decorator/class/virtual.js +24 -0
- package/dist/lib/decorator/index.d.ts +7 -0
- package/dist/lib/decorator/index.js +23 -0
- package/dist/lib/decorator/interface/beanOptions.d.ts +44 -0
- package/dist/lib/decorator/interface/beanOptions.js +8 -0
- package/dist/lib/decorator/interface/useOptions.d.ts +14 -0
- package/dist/lib/decorator/interface/useOptions.js +3 -0
- package/dist/lib/decorator/type/constructable.d.ts +2 -0
- package/dist/lib/decorator/type/constructable.js +3 -0
- package/dist/lib/decorator/type/containerScope.d.ts +2 -0
- package/dist/lib/decorator/type/containerScope.js +3 -0
- package/dist/lib/decorator/type/injectionScope.d.ts +2 -0
- package/dist/lib/decorator/type/injectionScope.js +3 -0
- package/dist/lib/error/error.d.ts +18 -0
- package/dist/lib/error/error.js +71 -0
- package/dist/lib/error/errorClass.d.ts +18 -0
- package/dist/lib/error/errorClass.js +72 -0
- package/dist/lib/error/errorContext.d.ts +38 -0
- package/dist/lib/error/errorContext.js +3 -0
- package/dist/lib/error/errorGlobal.d.ts +8 -0
- package/dist/lib/error/errorGlobal.js +3 -0
- package/dist/lib/error/errorInternal.d.ts +67 -0
- package/dist/lib/error/errorInternal.js +70 -0
- package/dist/lib/error/errorObject.d.ts +5 -0
- package/dist/lib/error/errorObject.js +3 -0
- package/dist/lib/error/index.d.ts +5 -0
- package/dist/lib/error/index.js +21 -0
- package/dist/lib/framework/bootstrap.d.ts +9 -0
- package/dist/lib/framework/bootstrap.js +35 -0
- package/dist/lib/framework/framework.d.ts +11 -0
- package/dist/lib/framework/framework.js +28 -0
- package/dist/lib/framework/loader.d.ts +24 -0
- package/dist/lib/framework/loader.js +69 -0
- package/dist/lib/framework/meta.d.ts +2 -0
- package/dist/lib/framework/meta.js +23 -0
- package/dist/lib/framework/metaClass.d.ts +2 -0
- package/dist/lib/framework/metaClass.js +26 -0
- package/dist/lib/framework/moduleInfo.d.ts +3 -0
- package/dist/lib/framework/moduleInfo.js +67 -0
- package/dist/lib/framework/util.d.ts +4 -0
- package/dist/lib/framework/util.js +15 -0
- package/dist/lib/module/asset/errors.d.ts +68 -0
- package/dist/lib/module/asset/errors.js +69 -0
- package/dist/lib/module/bean/index.d.ts +4 -0
- package/dist/lib/module/bean/index.js +24 -0
- package/dist/lib/module/broadcast/broadcast.d.ts +3 -0
- package/dist/lib/module/broadcast/broadcast.js +49 -0
- package/dist/lib/module/broadcast/broadcastClient.d.ts +24 -0
- package/dist/lib/module/broadcast/broadcastClient.js +91 -0
- package/dist/lib/module/cluster/agent.d.ts +3 -0
- package/dist/lib/module/cluster/agent.js +22 -0
- package/dist/lib/module/cluster/app.d.ts +3 -0
- package/dist/lib/module/cluster/app.js +26 -0
- package/dist/lib/module/config.d.ts +3 -0
- package/dist/lib/module/config.js +67 -0
- package/dist/lib/module/constant.d.ts +3 -0
- package/dist/lib/module/constant.js +46 -0
- package/dist/lib/module/contextPatch.d.ts +3 -0
- package/dist/lib/module/contextPatch.js +16 -0
- package/dist/lib/module/errors.d.ts +3 -0
- package/dist/lib/module/errors.js +49 -0
- package/dist/lib/module/index.d.ts +2 -0
- package/dist/lib/module/index.js +3 -0
- package/dist/lib/module/loader.d.ts +5 -0
- package/dist/lib/module/loader.js +73 -0
- package/dist/lib/module/locales.d.ts +3 -0
- package/dist/lib/module/locales.js +132 -0
- package/dist/lib/module/messenger.d.ts +25 -0
- package/dist/lib/module/messenger.js +128 -0
- package/dist/lib/module/middleware.d.ts +3 -0
- package/dist/lib/module/middleware.js +113 -0
- package/dist/lib/module/model.d.ts +3 -0
- package/dist/lib/module/model.js +47 -0
- package/dist/lib/module/module.d.ts +12 -0
- package/dist/lib/module/module.js +135 -0
- package/dist/lib/module/moduleMeta.d.ts +3 -0
- package/dist/lib/module/moduleMeta.js +23 -0
- package/dist/lib/module/queue/queue.d.ts +3 -0
- package/dist/lib/module/queue/queue.js +59 -0
- package/dist/lib/module/queue/queueClient.d.ts +26 -0
- package/dist/lib/module/queue/queueClient.js +262 -0
- package/dist/lib/module/redis.d.ts +11 -0
- package/dist/lib/module/redis.js +46 -0
- package/dist/lib/module/reload/development.d.ts +3 -0
- package/dist/lib/module/reload/development.js +98 -0
- package/dist/lib/module/reload/reload.d.ts +16 -0
- package/dist/lib/module/reload/reload.js +113 -0
- package/dist/lib/module/reload.d.ts +7 -0
- package/dist/lib/module/reload.js +17 -0
- package/dist/lib/module/route.d.ts +10 -0
- package/dist/lib/module/route.js +239 -0
- package/dist/lib/module/schedule.d.ts +3 -0
- package/dist/lib/module/schedule.js +129 -0
- package/dist/lib/module/service.d.ts +3 -0
- package/dist/lib/module/service.js +35 -0
- package/dist/lib/module/socketio.d.ts +5 -0
- package/dist/lib/module/socketio.js +47 -0
- package/dist/lib/module/startup.d.ts +2 -0
- package/dist/lib/module/startup.js +134 -0
- package/dist/lib/module/version/clear.d.ts +2 -0
- package/dist/lib/module/version/clear.js +42 -0
- package/dist/lib/module/version/ready.d.ts +6 -0
- package/dist/lib/module/version/ready.js +106 -0
- package/dist/lib/resource/error/errorClass.d.ts +18 -0
- package/dist/lib/resource/error/errorClass.js +72 -0
- package/dist/lib/resource/error/errorContext.d.ts +38 -0
- package/dist/lib/resource/error/errorContext.js +3 -0
- package/dist/lib/resource/error/errorGlobal.d.ts +8 -0
- package/dist/lib/resource/error/errorGlobal.js +3 -0
- package/dist/lib/resource/error/errorInternal.d.ts +67 -0
- package/dist/lib/resource/error/errorInternal.js +70 -0
- package/dist/lib/resource/error/errorObject.d.ts +5 -0
- package/dist/lib/resource/error/errorObject.js +3 -0
- package/dist/lib/resource/error/index.d.ts +5 -0
- package/dist/lib/resource/error/index.js +21 -0
- package/dist/lib/utils/index.d.ts +2 -0
- package/dist/lib/utils/index.js +18 -0
- package/dist/lib/utils/isClass.d.ts +2 -0
- package/dist/lib/utils/isClass.js +20 -0
- package/dist/lib/utils/mockUtil.d.ts +11 -0
- package/dist/lib/utils/mockUtil.js +34 -0
- package/dist/lib/utils/mockUtilCtx.d.ts +10 -0
- package/dist/lib/utils/mockUtilCtx.js +35 -0
- package/dist/lib/utils/performAction.d.ts +19 -0
- package/dist/lib/utils/performAction.js +137 -0
- package/dist/lib/utils/util.d.ts +63 -0
- package/dist/lib/utils/util.js +445 -0
- package/dist/lib/utils/utilCtx.d.ts +34 -0
- package/dist/lib/utils/utilCtx.js +137 -0
- package/dist/types/application/app.d.ts +21 -0
- package/dist/types/application/app.js +28 -0
- package/dist/types/application/index.d.ts +2 -0
- package/dist/types/application/index.js +18 -0
- package/dist/types/config/appInfo.d.ts +4 -0
- package/dist/types/config/appInfo.js +3 -0
- package/dist/types/config/config.d.ts +10 -0
- package/dist/types/config/config.js +3 -0
- package/dist/types/config/development.d.ts +4 -0
- package/dist/types/config/development.js +3 -0
- package/dist/types/config/index.d.ts +4 -0
- package/dist/types/config/index.js +20 -0
- package/dist/types/config/locale.d.ts +10 -0
- package/dist/types/config/locale.js +7 -0
- package/dist/types/context/contextBase.d.ts +21 -0
- package/dist/types/context/contextBase.js +3 -0
- package/dist/types/context/contextConfig.d.ts +4 -0
- package/dist/types/context/contextConfig.js +3 -0
- package/dist/types/context/contextError.d.ts +25 -0
- package/dist/types/context/contextError.js +3 -0
- package/dist/types/context/contextLocale.d.ts +9 -0
- package/dist/types/context/contextLocale.js +3 -0
- package/dist/types/context/contextOthers.d.ts +4 -0
- package/dist/types/context/contextOthers.js +3 -0
- package/dist/types/context/contextState.d.ts +8 -0
- package/dist/types/context/contextState.js +3 -0
- package/dist/types/context/index.d.ts +18 -0
- package/dist/types/context/index.js +18 -0
- package/dist/types/enum/appEvent.d.ts +5 -0
- package/dist/types/enum/appEvent.js +9 -0
- package/dist/types/enum/index.d.ts +2 -0
- package/dist/types/enum/index.js +18 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.js +23 -0
- package/dist/types/interface/broadcast.d.ts +5 -0
- package/dist/types/interface/broadcast.js +3 -0
- package/dist/types/interface/error.d.ts +8 -0
- package/dist/types/interface/error.js +3 -0
- package/dist/types/interface/index.d.ts +6 -0
- package/dist/types/interface/index.js +22 -0
- package/dist/types/interface/module.d.ts +32 -0
- package/dist/types/interface/module.js +18 -0
- package/dist/types/interface/monkey.d.ts +22 -0
- package/dist/types/interface/monkey.js +3 -0
- package/dist/types/interface/queue.d.ts +29 -0
- package/dist/types/interface/queue.js +3 -0
- package/dist/types/interface/schedule.d.ts +11 -0
- package/dist/types/interface/schedule.js +3 -0
- package/dist/types/utils/cast.d.ts +6 -0
- package/dist/types/utils/cast.js +8 -0
- package/dist/types/utils/index.d.ts +4 -0
- package/dist/types/utils/index.js +20 -0
- package/dist/types/utils/powerPartial.d.ts +4 -0
- package/dist/types/utils/powerPartial.js +3 -0
- package/dist/types/utils/type.d.ts +4 -0
- package/dist/types/utils/type.js +3 -0
- package/package.json +62 -14
|
@@ -0,0 +1,11 @@
|
|
|
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
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
|
@@ -0,0 +1,10 @@
|
|
|
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
|
|
@@ -0,0 +1,35 @@
|
|
|
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
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
|
@@ -0,0 +1,137 @@
|
|
|
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
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|