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
package/dist/lib/utils/util.js
DELETED
|
@@ -1,445 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.AppUtil = void 0;
|
|
30
|
-
const ModuleInfo = __importStar(require("@cabloy/module-info"));
|
|
31
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
32
|
-
const path_1 = __importDefault(require("path"));
|
|
33
|
-
const url_1 = require("url");
|
|
34
|
-
const is_type_of_1 = __importDefault(require("is-type-of"));
|
|
35
|
-
const security = __importStar(require("egg-security"));
|
|
36
|
-
const index_js_1 = require("../../types/index.js");
|
|
37
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
38
|
-
const resource_js_1 = require("../core/resource.js");
|
|
39
|
-
const compose_1 = require("@cabloy/compose");
|
|
40
|
-
const __EnvTests = ['unittest', 'test'];
|
|
41
|
-
class AppUtil extends beanSimple_js_1.BeanSimple {
|
|
42
|
-
instanceStarted(subdomain) {
|
|
43
|
-
return this.app.meta.appReadyInstances && this.app.meta.appReadyInstances[subdomain];
|
|
44
|
-
}
|
|
45
|
-
combineFetchPath(moduleName, arg) {
|
|
46
|
-
if (arg.substr(0, 2) === '//')
|
|
47
|
-
return arg.substr(1);
|
|
48
|
-
if (arg.charAt(0) === '/')
|
|
49
|
-
return `/api${arg}`;
|
|
50
|
-
const moduleInfo = typeof moduleName === 'string' ? ModuleInfo.parseInfo(moduleName) : moduleName;
|
|
51
|
-
if (!moduleInfo)
|
|
52
|
-
throw new Error('invalid url');
|
|
53
|
-
return `/api/${moduleInfo.url}/${arg}`;
|
|
54
|
-
}
|
|
55
|
-
combineApiPath(moduleName, arg) {
|
|
56
|
-
if (arg.charAt(0) === '/')
|
|
57
|
-
return arg;
|
|
58
|
-
const moduleInfo = typeof moduleName === 'string' ? ModuleInfo.parseInfo(moduleName) : moduleName;
|
|
59
|
-
if (!moduleInfo)
|
|
60
|
-
throw new Error('invalid url');
|
|
61
|
-
return `/${moduleInfo.url}/${arg}`;
|
|
62
|
-
}
|
|
63
|
-
combineQueries(url, queries) {
|
|
64
|
-
//
|
|
65
|
-
if (!queries)
|
|
66
|
-
return url;
|
|
67
|
-
//
|
|
68
|
-
let str = '';
|
|
69
|
-
for (const key of Object.keys(queries)) {
|
|
70
|
-
str += `${key}=${encodeURIComponent(queries[key])}&`;
|
|
71
|
-
}
|
|
72
|
-
if (str) {
|
|
73
|
-
str = str.substr(0, str.length - 1);
|
|
74
|
-
}
|
|
75
|
-
if (!str)
|
|
76
|
-
return url;
|
|
77
|
-
//
|
|
78
|
-
if (!url)
|
|
79
|
-
return '?' + str;
|
|
80
|
-
//
|
|
81
|
-
const pos = url.indexOf('?');
|
|
82
|
-
if (pos === -1)
|
|
83
|
-
return `${url}?${str}`;
|
|
84
|
-
if (pos === url.length - 1)
|
|
85
|
-
return `${url}${str}`;
|
|
86
|
-
return `${url}&${str}`;
|
|
87
|
-
}
|
|
88
|
-
createError(data, returnObject) {
|
|
89
|
-
const error = returnObject ? {} : new Error();
|
|
90
|
-
error.code = data.code !== undefined ? data.code : 500;
|
|
91
|
-
if (data.message && typeof data.message === 'object') {
|
|
92
|
-
error.message = JSON.stringify(data.message, null, 2);
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
error.message = data.message;
|
|
96
|
-
}
|
|
97
|
-
if (data.stack)
|
|
98
|
-
error.stack = data.stack;
|
|
99
|
-
if (data.name)
|
|
100
|
-
error.name = data.name;
|
|
101
|
-
if (data.errno)
|
|
102
|
-
error.errno = data.errno;
|
|
103
|
-
if (data.sqlMessage)
|
|
104
|
-
error.sqlMessage = data.sqlMessage;
|
|
105
|
-
if (data.sqlState)
|
|
106
|
-
error.sqlState = data.sqlState;
|
|
107
|
-
if (data.index)
|
|
108
|
-
error.index = data.index;
|
|
109
|
-
if (data.sql)
|
|
110
|
-
error.sql = data.sql;
|
|
111
|
-
return error;
|
|
112
|
-
}
|
|
113
|
-
async monkeyModule(ebAppMonkey, ebModulesMonkey, monkeyName, moduleTarget, ...monkeyData) {
|
|
114
|
-
// self: main
|
|
115
|
-
if (moduleTarget && moduleTarget.mainInstance && moduleTarget.mainInstance[monkeyName]) {
|
|
116
|
-
await moduleTarget.mainInstance[monkeyName](...monkeyData);
|
|
117
|
-
}
|
|
118
|
-
// module monkey
|
|
119
|
-
for (const key in ebModulesMonkey) {
|
|
120
|
-
const moduleMonkey = ebModulesMonkey[key];
|
|
121
|
-
if (moduleMonkey.monkeyInstance && moduleMonkey.monkeyInstance[monkeyName]) {
|
|
122
|
-
if (moduleTarget === undefined) {
|
|
123
|
-
// @ts-ignore ignore
|
|
124
|
-
await moduleMonkey.monkeyInstance[monkeyName](...monkeyData);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// @ts-ignore ignore
|
|
128
|
-
await moduleMonkey.monkeyInstance[monkeyName](moduleTarget, ...monkeyData);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
// app monkey
|
|
133
|
-
if (ebAppMonkey && ebAppMonkey[monkeyName]) {
|
|
134
|
-
if (moduleTarget === undefined) {
|
|
135
|
-
await ebAppMonkey[monkeyName](...monkeyData);
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
await ebAppMonkey[monkeyName](moduleTarget, ...monkeyData);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
getWhiteListCors(ctx) {
|
|
143
|
-
let whiteListCors;
|
|
144
|
-
const _config = ctx.config.module('a-base');
|
|
145
|
-
const _whiteList = (_config && _config.cors && _config.cors.whiteList) || [];
|
|
146
|
-
if (!Array.isArray(_whiteList)) {
|
|
147
|
-
whiteListCors = _whiteList.split(',');
|
|
148
|
-
}
|
|
149
|
-
else {
|
|
150
|
-
whiteListCors = _whiteList.concat();
|
|
151
|
-
}
|
|
152
|
-
// inherits from jsonp
|
|
153
|
-
let _whiteListJsonp = _config && _config.jsonp && _config.jsonp.whiteList;
|
|
154
|
-
if (_whiteListJsonp) {
|
|
155
|
-
if (!Array.isArray(_whiteListJsonp)) {
|
|
156
|
-
_whiteListJsonp = _whiteListJsonp.split(',');
|
|
157
|
-
}
|
|
158
|
-
whiteListCors = whiteListCors.concat(_whiteListJsonp);
|
|
159
|
-
}
|
|
160
|
-
// hostSelf
|
|
161
|
-
const hostSelf = ctx.bean.base.getAbsoluteUrl();
|
|
162
|
-
if (hostSelf) {
|
|
163
|
-
whiteListCors.push(hostSelf);
|
|
164
|
-
}
|
|
165
|
-
// ok
|
|
166
|
-
return whiteListCors;
|
|
167
|
-
}
|
|
168
|
-
isSafeDomain(ctx, origin) {
|
|
169
|
-
// origin is {protocol}{hostname}{port}...
|
|
170
|
-
if (!origin || origin === 'null' || origin === null)
|
|
171
|
-
return true;
|
|
172
|
-
let parsedUrl;
|
|
173
|
-
try {
|
|
174
|
-
parsedUrl = new url_1.URL(origin);
|
|
175
|
-
}
|
|
176
|
-
catch (_) {
|
|
177
|
-
return false;
|
|
178
|
-
}
|
|
179
|
-
// whiteList
|
|
180
|
-
const whiteListCors = this.getWhiteListCors(ctx);
|
|
181
|
-
if (security.utils.isSafeDomain(parsedUrl.hostname, whiteListCors) ||
|
|
182
|
-
security.utils.isSafeDomain(origin, whiteListCors)) {
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
isNullOrEmptyString(str) {
|
|
188
|
-
return str === undefined || str === null || str === '';
|
|
189
|
-
}
|
|
190
|
-
compose(chains, adapter) {
|
|
191
|
-
return (0, compose_1.compose)(chains, adapter);
|
|
192
|
-
}
|
|
193
|
-
composeAsync(chains, adapter) {
|
|
194
|
-
return (0, compose_1.composeAsync)(chains, adapter);
|
|
195
|
-
}
|
|
196
|
-
async createAnonymousContext({ locale, subdomain, module, instance }) {
|
|
197
|
-
// url
|
|
198
|
-
const url = module ? this.combineFetchPath(module, '') : '/api/a/base/';
|
|
199
|
-
// ctx
|
|
200
|
-
const ctx = this.app.createAnonymousContext({
|
|
201
|
-
method: 'post',
|
|
202
|
-
url,
|
|
203
|
-
});
|
|
204
|
-
ctx.req.ctx = ctx;
|
|
205
|
-
// locale
|
|
206
|
-
Object.defineProperty(ctx, 'locale', {
|
|
207
|
-
get() {
|
|
208
|
-
return locale || this.app.config.i18n.defaultLocale;
|
|
209
|
-
},
|
|
210
|
-
});
|
|
211
|
-
// subdomain
|
|
212
|
-
Object.defineProperty(ctx, 'subdomain', {
|
|
213
|
-
get() {
|
|
214
|
-
return subdomain;
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
// instance
|
|
218
|
-
if (subdomain !== undefined && subdomain !== null) {
|
|
219
|
-
ctx.instance = await ctx.bean.instance.get({ subdomain });
|
|
220
|
-
// start instance
|
|
221
|
-
if (instance) {
|
|
222
|
-
await ctx.bean.instance.checkAppReadyInstance();
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
// ok
|
|
226
|
-
return ctx;
|
|
227
|
-
}
|
|
228
|
-
async executeBean({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, ctxCaller, ctxParent, instance, }) {
|
|
229
|
-
// ctxModule
|
|
230
|
-
let ctxModule = beanModule;
|
|
231
|
-
if (!ctxModule && beanFullName) {
|
|
232
|
-
const beanOptions = resource_js_1.appResource.getBean(beanFullName);
|
|
233
|
-
ctxModule = beanOptions?.module;
|
|
234
|
-
}
|
|
235
|
-
if (!ctxModule) {
|
|
236
|
-
ctxModule = ctxCaller?.module?.info?.relativeName || ctxParent?.module?.info?.relativeName;
|
|
237
|
-
}
|
|
238
|
-
// ctx
|
|
239
|
-
const ctx = await this.createAnonymousContext({ locale, subdomain, module: ctxModule, instance });
|
|
240
|
-
// innerAccess
|
|
241
|
-
ctx.innerAccess = true;
|
|
242
|
-
// ctxCaller
|
|
243
|
-
if (ctxCaller) {
|
|
244
|
-
// multipart
|
|
245
|
-
ctx.multipart = function (options) {
|
|
246
|
-
return ctxCaller.multipart(options);
|
|
247
|
-
};
|
|
248
|
-
// delegateProperties
|
|
249
|
-
delegateProperties(ctx, ctxCaller);
|
|
250
|
-
// ctxCaller
|
|
251
|
-
ctx.ctxCaller = ctxCaller;
|
|
252
|
-
}
|
|
253
|
-
// ctxParent
|
|
254
|
-
if (ctxParent) {
|
|
255
|
-
// delegateProperties
|
|
256
|
-
delegateProperties(ctx, ctxParent);
|
|
257
|
-
// dbLevel
|
|
258
|
-
ctx.dbLevel = (ctxParent.dbLevel || 0) + 1;
|
|
259
|
-
}
|
|
260
|
-
// dbLevel
|
|
261
|
-
if (!ctxCaller && !ctxParent) {
|
|
262
|
-
ctx.dbLevel = 1;
|
|
263
|
-
}
|
|
264
|
-
// bean
|
|
265
|
-
const bean = beanFullName ? ctx.bean._getBean(beanFullName) : null;
|
|
266
|
-
if (!bean && beanFullName && !is_type_of_1.default.function(fn)) {
|
|
267
|
-
throw new Error(`bean not found: ${beanFullName}`);
|
|
268
|
-
}
|
|
269
|
-
// execute
|
|
270
|
-
let res;
|
|
271
|
-
if (transaction) {
|
|
272
|
-
res = await (0, index_js_1.Cast)(ctx).transaction.begin(async () => {
|
|
273
|
-
return await this._executeBeanFn({ fn, ctx, bean, context });
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
else {
|
|
277
|
-
res = await this._executeBeanFn({ fn, ctx, bean, context });
|
|
278
|
-
}
|
|
279
|
-
// tail done
|
|
280
|
-
await ctx.tailDone();
|
|
281
|
-
// ok
|
|
282
|
-
return res;
|
|
283
|
-
}
|
|
284
|
-
async _executeBeanFn({ fn, ctx, bean, context }) {
|
|
285
|
-
let res;
|
|
286
|
-
if (is_type_of_1.default.function(fn)) {
|
|
287
|
-
res = await fn({ ctx, bean, context });
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
fn = fn || 'execute';
|
|
291
|
-
if (!bean[fn]) {
|
|
292
|
-
throw new Error(`bean method not found: ${bean.__beanFullName__}:${fn}`);
|
|
293
|
-
}
|
|
294
|
-
res = await bean[fn](context);
|
|
295
|
-
}
|
|
296
|
-
return res;
|
|
297
|
-
}
|
|
298
|
-
async lock({ subdomain, resource, fn, options, redlock, }) {
|
|
299
|
-
// resource
|
|
300
|
-
const _lockResource = `redlock_${this.app.name}:${this.subdomainDesp(subdomain)}:${resource}`;
|
|
301
|
-
// options
|
|
302
|
-
const _lockOptions = Object.assign({}, this.app.config.queue.redlock.options, options);
|
|
303
|
-
// redlock
|
|
304
|
-
if (!redlock) {
|
|
305
|
-
redlock = this.app.meta.redlock.create(_lockOptions);
|
|
306
|
-
}
|
|
307
|
-
let _lock = await redlock.lock(_lockResource, _lockOptions.lockTTL);
|
|
308
|
-
// timer
|
|
309
|
-
let _lockTimer = null;
|
|
310
|
-
const _lockDone = () => {
|
|
311
|
-
if (_lockTimer) {
|
|
312
|
-
clearInterval(_lockTimer);
|
|
313
|
-
_lockTimer = null;
|
|
314
|
-
}
|
|
315
|
-
};
|
|
316
|
-
_lockTimer = setInterval(() => {
|
|
317
|
-
_lock
|
|
318
|
-
.extend(_lockOptions.lockTTL)
|
|
319
|
-
.then(lock => {
|
|
320
|
-
_lock = lock;
|
|
321
|
-
})
|
|
322
|
-
.catch(err => {
|
|
323
|
-
this.app.logger.error(err);
|
|
324
|
-
_lockDone();
|
|
325
|
-
});
|
|
326
|
-
}, _lockOptions.lockTTL / 2);
|
|
327
|
-
try {
|
|
328
|
-
const res = await fn();
|
|
329
|
-
_lockDone();
|
|
330
|
-
await _lock.unlock();
|
|
331
|
-
return res;
|
|
332
|
-
}
|
|
333
|
-
catch (err) {
|
|
334
|
-
_lockDone();
|
|
335
|
-
await _lock.unlock();
|
|
336
|
-
throw err;
|
|
337
|
-
}
|
|
338
|
-
}
|
|
339
|
-
subdomainDesp(subdomain) {
|
|
340
|
-
if (subdomain === undefined || subdomain === null)
|
|
341
|
-
return '~';
|
|
342
|
-
return subdomain || '-';
|
|
343
|
-
}
|
|
344
|
-
deprecated(oldUsage, newUsage) {
|
|
345
|
-
const message = '`'
|
|
346
|
-
.concat(oldUsage, '` is deprecated and will be removed in a later version. Use `')
|
|
347
|
-
.concat(newUsage, '` instead');
|
|
348
|
-
return console.warn(message);
|
|
349
|
-
}
|
|
350
|
-
checkGate(gate) {
|
|
351
|
-
// check none
|
|
352
|
-
if (!gate)
|
|
353
|
-
return true;
|
|
354
|
-
// check env
|
|
355
|
-
if (!this._checkGateEnv(gate.env))
|
|
356
|
-
return false;
|
|
357
|
-
// default
|
|
358
|
-
return true;
|
|
359
|
-
}
|
|
360
|
-
_checkGateEnv(env) {
|
|
361
|
-
// check none
|
|
362
|
-
if (!env)
|
|
363
|
-
return true;
|
|
364
|
-
if (!Array.isArray(env))
|
|
365
|
-
env = env.split(',');
|
|
366
|
-
const bingo = env.some(item => {
|
|
367
|
-
if (this.app.config.env === item)
|
|
368
|
-
return true;
|
|
369
|
-
if (__EnvTests.includes(this.app.config.env) && __EnvTests.includes(item))
|
|
370
|
-
return true;
|
|
371
|
-
return false;
|
|
372
|
-
});
|
|
373
|
-
if (!bingo)
|
|
374
|
-
return false;
|
|
375
|
-
return true;
|
|
376
|
-
}
|
|
377
|
-
requireDynamic(file) {
|
|
378
|
-
if (!file)
|
|
379
|
-
throw new Error('file should not empty');
|
|
380
|
-
let instance = require(file);
|
|
381
|
-
const mtime = this._requireDynamic_getFileTime(file);
|
|
382
|
-
if (instance.__requireDynamic_mtime === undefined) {
|
|
383
|
-
instance.__requireDynamic_mtime = mtime;
|
|
384
|
-
}
|
|
385
|
-
else if (instance.__requireDynamic_mtime !== mtime) {
|
|
386
|
-
delete require.cache[require.resolve(file)];
|
|
387
|
-
instance = require(file);
|
|
388
|
-
instance.__requireDynamic_mtime = mtime;
|
|
389
|
-
}
|
|
390
|
-
return instance;
|
|
391
|
-
}
|
|
392
|
-
_requireDynamic_getFileTime(file) {
|
|
393
|
-
if (!path_1.default.isAbsolute(file))
|
|
394
|
-
return null;
|
|
395
|
-
const exists = fs_extra_1.default.pathExistsSync(file);
|
|
396
|
-
if (!exists)
|
|
397
|
-
return null;
|
|
398
|
-
// stat
|
|
399
|
-
const stat = fs_extra_1.default.statSync(file);
|
|
400
|
-
return stat.mtime.valueOf();
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
exports.AppUtil = AppUtil;
|
|
404
|
-
function delegateProperties(ctx, ctxCaller) {
|
|
405
|
-
const req = ctx.req;
|
|
406
|
-
for (const property of ['cookies', 'session', 'user', 'state']) {
|
|
407
|
-
delegateProperty(ctx, ctxCaller, property);
|
|
408
|
-
}
|
|
409
|
-
for (const property of ['query', 'params', 'headers', 'body']) {
|
|
410
|
-
delegateProperty(ctx.request, ctxCaller.request, property);
|
|
411
|
-
if (ctx.request[property])
|
|
412
|
-
req[property] = ctx.request[property];
|
|
413
|
-
}
|
|
414
|
-
if (ctx.session)
|
|
415
|
-
req.session = ctx.session;
|
|
416
|
-
// if (ctx.query) req.query = ctx.query;
|
|
417
|
-
// if (ctx.request.body) req.body = ctx.request.body;
|
|
418
|
-
}
|
|
419
|
-
function delegateProperty(ctx, ctxCaller, property) {
|
|
420
|
-
const keyMock = `__executeBean__mock__${property}__`;
|
|
421
|
-
const keyOriginal = `__executeBean__mock__${property}__original__`;
|
|
422
|
-
if (['cookies', 'session', 'headers'].includes(property)) {
|
|
423
|
-
ctx[keyOriginal] = ctx[property];
|
|
424
|
-
}
|
|
425
|
-
Object.defineProperty(ctx, property, {
|
|
426
|
-
get() {
|
|
427
|
-
const value = ctxCaller && ctxCaller[property];
|
|
428
|
-
if (value)
|
|
429
|
-
return value;
|
|
430
|
-
//
|
|
431
|
-
if (['user', 'body'].includes(property))
|
|
432
|
-
return value;
|
|
433
|
-
//
|
|
434
|
-
if (['cookies', 'session', 'headers'].includes(property)) {
|
|
435
|
-
return ctx[keyOriginal];
|
|
436
|
-
}
|
|
437
|
-
//
|
|
438
|
-
if (!ctx[keyMock]) {
|
|
439
|
-
ctx[keyMock] = {};
|
|
440
|
-
}
|
|
441
|
-
return ctx[keyMock];
|
|
442
|
-
},
|
|
443
|
-
});
|
|
444
|
-
}
|
|
445
|
-
//# sourceMappingURL=util.js.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
2
|
-
import { VonaContext, PowerPartial } from '../../types/index.js';
|
|
3
|
-
import { IExecuteBeanCallback } from './util.js';
|
|
4
|
-
export declare class CtxUtil extends BeanSimple {
|
|
5
|
-
runInBackground(scope: any): void;
|
|
6
|
-
lock({ subdomain, resource, fn, options, redlock }: any): Promise<any>;
|
|
7
|
-
broadcastEmit({ locale, subdomain, module, broadcastName, data }: any): void;
|
|
8
|
-
queuePush(info: any): void;
|
|
9
|
-
queuePushAsync(info: any): Promise<unknown>;
|
|
10
|
-
_queuePushInfoPrepare(info: any): any;
|
|
11
|
-
executeBean({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, instance, }: {
|
|
12
|
-
locale?: string;
|
|
13
|
-
subdomain?: string;
|
|
14
|
-
beanModule?: string;
|
|
15
|
-
beanFullName?: string;
|
|
16
|
-
context?: any;
|
|
17
|
-
fn?: IExecuteBeanCallback | string;
|
|
18
|
-
transaction?: boolean;
|
|
19
|
-
instance?: boolean;
|
|
20
|
-
}): Promise<any>;
|
|
21
|
-
executeBeanIsolate({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, ctxParent, instance, }: {
|
|
22
|
-
locale?: string;
|
|
23
|
-
subdomain?: string | null;
|
|
24
|
-
beanModule?: string;
|
|
25
|
-
beanFullName?: string;
|
|
26
|
-
context?: any;
|
|
27
|
-
fn?: IExecuteBeanCallback | string;
|
|
28
|
-
transaction?: boolean;
|
|
29
|
-
ctxParent?: PowerPartial<VonaContext>;
|
|
30
|
-
instance?: boolean;
|
|
31
|
-
}): Promise<any>;
|
|
32
|
-
performAction({ innerAccess, method, url, query, params, headers, body }: any): Promise<any>;
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=utilCtx.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
|
-
exports.CtxUtil = void 0;
|
|
7
|
-
const performAction_js_1 = __importDefault(require("./performAction.js"));
|
|
8
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
9
|
-
class CtxUtil extends beanSimple_js_1.BeanSimple {
|
|
10
|
-
runInBackground(scope) {
|
|
11
|
-
const ctx = this.ctx;
|
|
12
|
-
ctx.runInBackground(async () => {
|
|
13
|
-
await ctx.meta.util.executeBeanIsolate({
|
|
14
|
-
fn: async ({ ctx }) => {
|
|
15
|
-
await scope({ ctx });
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async lock({ subdomain, resource, fn, options, redlock }) {
|
|
21
|
-
const ctx = this.ctx;
|
|
22
|
-
if (subdomain === undefined)
|
|
23
|
-
subdomain = ctx.subdomain;
|
|
24
|
-
return await ctx.app.meta.util.lock({ subdomain, resource, fn, options, redlock });
|
|
25
|
-
}
|
|
26
|
-
broadcastEmit({ locale, subdomain, module, broadcastName, data }) {
|
|
27
|
-
const ctx = this.ctx;
|
|
28
|
-
ctx.app.meta.broadcast.emit({
|
|
29
|
-
locale: locale === undefined ? ctx.locale : locale,
|
|
30
|
-
subdomain: subdomain === undefined ? ctx.subdomain : subdomain,
|
|
31
|
-
module,
|
|
32
|
-
broadcastName,
|
|
33
|
-
data,
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
queuePush(info) {
|
|
37
|
-
const ctx = this.ctx;
|
|
38
|
-
ctx.app.meta.queue.push(this._queuePushInfoPrepare(info));
|
|
39
|
-
}
|
|
40
|
-
async queuePushAsync(info) {
|
|
41
|
-
const ctx = this.ctx;
|
|
42
|
-
return await ctx.app.meta.queue.pushAsync(this._queuePushInfoPrepare(info));
|
|
43
|
-
}
|
|
44
|
-
_queuePushInfoPrepare(info) {
|
|
45
|
-
const ctx = this.ctx;
|
|
46
|
-
const dbLevel = !info.dbLevel ? ctx.dbLevel + 1 : info.dbLevel;
|
|
47
|
-
const locale = info.locale === undefined ? ctx.locale : info.locale;
|
|
48
|
-
const subdomain = info.subdomain === undefined ? ctx.subdomain : info.subdomain;
|
|
49
|
-
// new info
|
|
50
|
-
info = {
|
|
51
|
-
...info,
|
|
52
|
-
dbLevel,
|
|
53
|
-
locale,
|
|
54
|
-
subdomain,
|
|
55
|
-
};
|
|
56
|
-
if (!info.ctxParent)
|
|
57
|
-
info.ctxParent = {};
|
|
58
|
-
if (!info.ctxParent.request)
|
|
59
|
-
info.ctxParent.request = {};
|
|
60
|
-
if (!info.ctxParent.request.headers)
|
|
61
|
-
info.ctxParent.request.headers = {};
|
|
62
|
-
// headers
|
|
63
|
-
const headers = info.ctxParent.request.headers;
|
|
64
|
-
for (const key of ['x-clientid', 'x-scene']) {
|
|
65
|
-
if (!headers[key]) {
|
|
66
|
-
const value = key === 'x-clientid' ? ctx.bean.util.getFrontClientId() : ctx.bean.util.getFrontScene();
|
|
67
|
-
if (value) {
|
|
68
|
-
headers[key] = value;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
for (const key of ['host', 'origin', 'referer', 'user-agent']) {
|
|
73
|
-
if (!headers[key]) {
|
|
74
|
-
const value = ctx.request.headers[key];
|
|
75
|
-
if (value) {
|
|
76
|
-
headers[key] = value;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
// ok
|
|
81
|
-
return info;
|
|
82
|
-
}
|
|
83
|
-
async executeBean({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, instance, }) {
|
|
84
|
-
const ctx = this.ctx;
|
|
85
|
-
return await ctx.app.meta.util.executeBean({
|
|
86
|
-
locale: locale === undefined ? ctx.locale : locale,
|
|
87
|
-
subdomain: subdomain === undefined ? ctx.subdomain : subdomain,
|
|
88
|
-
context,
|
|
89
|
-
beanModule,
|
|
90
|
-
beanFullName,
|
|
91
|
-
transaction,
|
|
92
|
-
fn,
|
|
93
|
-
ctxCaller: ctx,
|
|
94
|
-
instance,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
async executeBeanIsolate({ locale, subdomain, beanModule, beanFullName, context, fn, transaction, ctxParent, instance, }) {
|
|
98
|
-
const ctx = this.ctx;
|
|
99
|
-
if (ctxParent) {
|
|
100
|
-
if (ctxParent.dbLevel === undefined) {
|
|
101
|
-
ctxParent = {
|
|
102
|
-
...ctxParent,
|
|
103
|
-
dbLevel: ctx.dbLevel,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
ctxParent = ctx;
|
|
109
|
-
}
|
|
110
|
-
return await ctx.app.meta.util.executeBean({
|
|
111
|
-
locale: locale === undefined ? ctx.locale : locale,
|
|
112
|
-
subdomain: subdomain === undefined ? ctx.subdomain : subdomain,
|
|
113
|
-
context,
|
|
114
|
-
beanModule,
|
|
115
|
-
beanFullName,
|
|
116
|
-
transaction,
|
|
117
|
-
fn,
|
|
118
|
-
ctxParent,
|
|
119
|
-
instance,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
async performAction({ innerAccess, method, url, query, params, headers, body }) {
|
|
123
|
-
const ctx = this.ctx;
|
|
124
|
-
return await (0, performAction_js_1.default)({
|
|
125
|
-
ctxCaller: ctx,
|
|
126
|
-
innerAccess,
|
|
127
|
-
method,
|
|
128
|
-
url,
|
|
129
|
-
query,
|
|
130
|
-
params,
|
|
131
|
-
headers,
|
|
132
|
-
body,
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
exports.CtxUtil = CtxUtil;
|
|
137
|
-
//# sourceMappingURL=utilCtx.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Application as EggApplication, EggLoaderOptions, Singleton } from 'egg';
|
|
2
|
-
import { EggPassport } from '@zhennann/egg-passport';
|
|
3
|
-
import { BeanContainer } from '../../lib/bean/beanContainer.js';
|
|
4
|
-
import { AppMeta } from '../../lib/core/meta.js';
|
|
5
|
-
import { Server as SocketServer } from 'socket.io';
|
|
6
|
-
import { Redis } from 'ioredis';
|
|
7
|
-
import { VonaConfig } from '../config/config.js';
|
|
8
|
-
export * as IORedis from 'ioredis';
|
|
9
|
-
export interface VonaApplication extends EggApplication {
|
|
10
|
-
options: EggLoaderOptions & {
|
|
11
|
-
flavor: any;
|
|
12
|
-
};
|
|
13
|
-
meta: AppMeta;
|
|
14
|
-
bean: BeanContainer;
|
|
15
|
-
redis: Singleton<Redis>;
|
|
16
|
-
io: SocketServer;
|
|
17
|
-
mysql: any;
|
|
18
|
-
passport: EggPassport;
|
|
19
|
-
config: VonaConfig;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=app.d.ts.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.IORedis = void 0;
|
|
27
|
-
exports.IORedis = __importStar(require("ioredis"));
|
|
28
|
-
//# sourceMappingURL=app.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./app.js"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|