vona 5.0.7 → 5.0.9
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,135 +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.ModuleTools = void 0;
|
|
30
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
31
|
-
const path_1 = __importDefault(require("path"));
|
|
32
|
-
const module_glob_1 = require("@cabloy/module-glob");
|
|
33
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
34
|
-
const node_url_1 = require("node:url");
|
|
35
|
-
const Path = __importStar(require("node:path"));
|
|
36
|
-
// const __import_type_serialization = true;
|
|
37
|
-
const __import_type_serialization = false;
|
|
38
|
-
class ModuleTools extends beanSimple_js_1.BeanSimple {
|
|
39
|
-
async prepare() {
|
|
40
|
-
const app = this.app;
|
|
41
|
-
// all modules
|
|
42
|
-
const { suites, modules, modulesArray } = await (0, module_glob_1.glob)({
|
|
43
|
-
projectMode: 'vona',
|
|
44
|
-
projectPath: path_1.default.join(app.options.baseDir, '../..'),
|
|
45
|
-
disabledModules: process.env.PROJECT_DISABLED_MODULES,
|
|
46
|
-
disabledSuites: process.env.PROJECT_DISABLED_SUITES,
|
|
47
|
-
log: false,
|
|
48
|
-
//log: !!app.meta.inAgent,
|
|
49
|
-
});
|
|
50
|
-
app.meta.suites = suites;
|
|
51
|
-
app.meta.modules = modules;
|
|
52
|
-
app.meta.modulesArray = modulesArray;
|
|
53
|
-
app.meta.modulesMonkey = {};
|
|
54
|
-
// app monkey
|
|
55
|
-
let pathAppMonkey;
|
|
56
|
-
if (app.meta.isTest || app.meta.isLocal) {
|
|
57
|
-
pathAppMonkey = _pathToHref(path_1.default.resolve(process.cwd(), 'src/backend/config/monkey.mts'));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
pathAppMonkey = _pathToHref(path_1.default.resolve(app.options.baseDir, 'config/monkey.mjs'));
|
|
61
|
-
}
|
|
62
|
-
if (fs_extra_1.default.existsSync(pathAppMonkey)) {
|
|
63
|
-
const AppMonkey = await import(pathAppMonkey);
|
|
64
|
-
app.meta.appMonkey = app.bean._newBean(AppMonkey.AppMonkey);
|
|
65
|
-
}
|
|
66
|
-
return modules;
|
|
67
|
-
}
|
|
68
|
-
async load() {
|
|
69
|
-
const app = this.app;
|
|
70
|
-
// 1. import
|
|
71
|
-
const modulesResource = await this._importModules();
|
|
72
|
-
// 2. resource
|
|
73
|
-
for (let i = 0; i < modulesResource.length; i++) {
|
|
74
|
-
const module = app.meta.modulesArray[i];
|
|
75
|
-
module.resource = modulesResource[i];
|
|
76
|
-
}
|
|
77
|
-
// 3. main / monkey
|
|
78
|
-
for (const module of app.meta.modulesArray) {
|
|
79
|
-
if (module.resource.Main) {
|
|
80
|
-
module.mainInstance = app.bean._newBean(module.resource.Main, module);
|
|
81
|
-
}
|
|
82
|
-
if (module.resource.Monkey) {
|
|
83
|
-
module.monkeyInstance = app.bean._newBean(module.resource.Monkey, module);
|
|
84
|
-
app.meta.modulesMonkey[module.info.relativeName] = module;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async monkey(monkeyName) {
|
|
89
|
-
const app = this.app;
|
|
90
|
-
for (const module of app.meta.modulesArray) {
|
|
91
|
-
await app.meta.util.monkeyModule(app.meta.appMonkey, app.meta.modulesMonkey, monkeyName, module);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
_getModuleIndexPath(module) {
|
|
95
|
-
const app = this.app;
|
|
96
|
-
const pathSrc = `${module.root}/src/index.ts`;
|
|
97
|
-
if ((app.meta.isTest || app.meta.isLocal) && fs_extra_1.default.existsSync(pathSrc)) {
|
|
98
|
-
return _pathToHref(pathSrc);
|
|
99
|
-
}
|
|
100
|
-
return _pathToHref(`${module.root}/dist/index.js`);
|
|
101
|
-
}
|
|
102
|
-
async _importModules_serialization() {
|
|
103
|
-
const modulesResource = [];
|
|
104
|
-
for (const module of this.app.meta.modulesArray) {
|
|
105
|
-
modulesResource.push(await import(this._getModuleIndexPath(module)));
|
|
106
|
-
}
|
|
107
|
-
return modulesResource;
|
|
108
|
-
}
|
|
109
|
-
async _importModules_parallelization() {
|
|
110
|
-
const promises = [];
|
|
111
|
-
for (const module of this.app.meta.modulesArray) {
|
|
112
|
-
promises.push(import(this._getModuleIndexPath(module)));
|
|
113
|
-
}
|
|
114
|
-
return await Promise.all(promises);
|
|
115
|
-
}
|
|
116
|
-
async _importModules() {
|
|
117
|
-
const timeBegin = new Date();
|
|
118
|
-
console.log(`import modules begin, pid: ${process.pid}`);
|
|
119
|
-
let modulesResource;
|
|
120
|
-
if (__import_type_serialization) {
|
|
121
|
-
modulesResource = await this._importModules_serialization();
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
modulesResource = await this._importModules_parallelization();
|
|
125
|
-
}
|
|
126
|
-
const timeEnd = new Date();
|
|
127
|
-
console.log(`import modules end, pid: ${process.pid}: ${(timeEnd.valueOf() - timeBegin.valueOf()) / 1000}s`);
|
|
128
|
-
return modulesResource;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
exports.ModuleTools = ModuleTools;
|
|
132
|
-
function _pathToHref(fileName) {
|
|
133
|
-
return Path.sep === '\\' ? (0, node_url_1.pathToFileURL)(fileName).href : fileName;
|
|
134
|
-
}
|
|
135
|
-
//# sourceMappingURL=module.js.map
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
async function default_1(app, modules) {
|
|
4
|
-
// all metas
|
|
5
|
-
app.meta.metas = {};
|
|
6
|
-
// load metas
|
|
7
|
-
await loadMetas();
|
|
8
|
-
async function loadMetas() {
|
|
9
|
-
for (const key in modules) {
|
|
10
|
-
const module = modules[key];
|
|
11
|
-
// module meta
|
|
12
|
-
if (typeof module.resource.meta === 'function') {
|
|
13
|
-
module.meta = module.resource.meta(app);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
module.meta = module.resource.meta;
|
|
17
|
-
}
|
|
18
|
-
app.meta.metas[module.info.relativeName] = module.meta;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.default = default_1;
|
|
23
|
-
//# sourceMappingURL=moduleMeta.js.map
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const queueClient_js_1 = require("./queueClient.js");
|
|
4
|
-
function default_1(app, modules) {
|
|
5
|
-
// queue
|
|
6
|
-
app.meta.queue = app.bean._newBean(queueClient_js_1.QueueClient);
|
|
7
|
-
// all queues
|
|
8
|
-
const ebQueues = (app.meta.queues = {});
|
|
9
|
-
// load queues
|
|
10
|
-
loadQueues();
|
|
11
|
-
function loadQueues() {
|
|
12
|
-
for (const key in modules) {
|
|
13
|
-
const module = modules[key];
|
|
14
|
-
const config = app.meta.configs[module.info.relativeName];
|
|
15
|
-
if (!config.queues)
|
|
16
|
-
continue;
|
|
17
|
-
for (const queueName in config.queues) {
|
|
18
|
-
const queueConfig = config.queues[queueName];
|
|
19
|
-
const fullKey = `${module.info.relativeName}:${queueName}`;
|
|
20
|
-
// bean
|
|
21
|
-
const beanName = queueConfig.bean;
|
|
22
|
-
if (!beanName)
|
|
23
|
-
throw new Error(`bean not set for queue: ${fullKey}`);
|
|
24
|
-
let bean;
|
|
25
|
-
if (typeof beanName === 'string') {
|
|
26
|
-
bean = {
|
|
27
|
-
module: module.info.relativeName,
|
|
28
|
-
name: beanName,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
bean = {
|
|
33
|
-
module: beanName.module || module.info.relativeName,
|
|
34
|
-
name: beanName.name,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
ebQueues[fullKey] = {
|
|
38
|
-
module: module.info.relativeName,
|
|
39
|
-
name: queueName,
|
|
40
|
-
config: queueConfig,
|
|
41
|
-
bean,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
app.meta._loadQueueWorkers = ({ subdomain }) => {
|
|
47
|
-
for (const fullKey in ebQueues) {
|
|
48
|
-
const queue = ebQueues[fullKey];
|
|
49
|
-
const info = {
|
|
50
|
-
subdomain,
|
|
51
|
-
module: queue.module,
|
|
52
|
-
queueName: queue.name,
|
|
53
|
-
};
|
|
54
|
-
app.meta.queue._ensureWorker(info);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
exports.default = default_1;
|
|
59
|
-
//# sourceMappingURL=queue.js.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as bull from 'bullmq';
|
|
2
|
-
import { IQueueCallbacks, IQueueQueue, IQueueQueues, IQueueWork, IQueueWorks } from '../../../types/index.js';
|
|
3
|
-
import { BeanSimple } from '../../bean/beanSimple.js';
|
|
4
|
-
export declare class QueueClient extends BeanSimple {
|
|
5
|
-
_workers: IQueueWorks;
|
|
6
|
-
_queues: IQueueQueues;
|
|
7
|
-
_queueCallbacks: IQueueCallbacks;
|
|
8
|
-
push(info: any): void;
|
|
9
|
-
pushAsync(info: any): Promise<unknown>;
|
|
10
|
-
_clearWorkers(): Promise<void>;
|
|
11
|
-
_createWorker(info: any, queueKey: any): IQueueWork;
|
|
12
|
-
_createQueue(info: any, queueKey: any): IQueueQueue;
|
|
13
|
-
_ensureWorker(info: any): void;
|
|
14
|
-
_ensureQueue(info: any): IQueueQueue;
|
|
15
|
-
_getQueue(info: any): bull.Queue<any, any, string>;
|
|
16
|
-
_callCallback(jobId: any, failedReason: any, data: any): void;
|
|
17
|
-
_queuePush(info: any, isAsync: any): Promise<unknown>;
|
|
18
|
-
_combineQueueKey({ subdomain, module, queueName }: {
|
|
19
|
-
subdomain: any;
|
|
20
|
-
module?: string | undefined;
|
|
21
|
-
queueName?: string | undefined;
|
|
22
|
-
}): string;
|
|
23
|
-
_performTask(job: any): Promise<any>;
|
|
24
|
-
_getRepeatKey(name: any, repeat: any): string;
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=queueClient.d.ts.map
|
|
@@ -1,262 +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.QueueClient = void 0;
|
|
27
|
-
const bull = __importStar(require("bullmq"));
|
|
28
|
-
const uuid = __importStar(require("uuid"));
|
|
29
|
-
const beanSimple_js_1 = require("../../bean/beanSimple.js");
|
|
30
|
-
class QueueClient extends beanSimple_js_1.BeanSimple {
|
|
31
|
-
constructor() {
|
|
32
|
-
super(...arguments);
|
|
33
|
-
Object.defineProperty(this, "_workers", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true,
|
|
37
|
-
value: {}
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(this, "_queues", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: {}
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(this, "_queueCallbacks", {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
configurable: true,
|
|
48
|
-
writable: true,
|
|
49
|
-
value: {}
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
push(info) {
|
|
53
|
-
if (!info.dbLevel)
|
|
54
|
-
info.dbLevel = 1;
|
|
55
|
-
this._queuePush(info, false);
|
|
56
|
-
}
|
|
57
|
-
// { locale, subdomain, module, queueName,queueNameSub,data }
|
|
58
|
-
pushAsync(info) {
|
|
59
|
-
if (!info.dbLevel)
|
|
60
|
-
throw new Error('should specify the info.dbLevel');
|
|
61
|
-
return this._queuePush(info, true);
|
|
62
|
-
}
|
|
63
|
-
async _clearWorkers() {
|
|
64
|
-
for (const queueKey in this._workers) {
|
|
65
|
-
const _worker = this._workers[queueKey];
|
|
66
|
-
await _worker.worker.close();
|
|
67
|
-
}
|
|
68
|
-
this._workers = {};
|
|
69
|
-
}
|
|
70
|
-
_createWorker(info, queueKey) {
|
|
71
|
-
const app = this.app;
|
|
72
|
-
// worker
|
|
73
|
-
const _worker = {};
|
|
74
|
-
// prefix
|
|
75
|
-
const prefix = `bull_${app.name}:queue`;
|
|
76
|
-
// queue config
|
|
77
|
-
const queueConfig = app.meta.queues[`${info.module}:${info.queueName}`].config;
|
|
78
|
-
// queueConfig.options: queue/worker/job/redlock
|
|
79
|
-
const workerOptions = (queueConfig.options && queueConfig.options.worker) || null;
|
|
80
|
-
const redlockOptions = (queueConfig.options && queueConfig.options.redlock) || null;
|
|
81
|
-
const _redlockOptions = Object.assign({}, app.config.queue.redlock.options, redlockOptions);
|
|
82
|
-
// redlock
|
|
83
|
-
if (!queueConfig.concurrency) {
|
|
84
|
-
_worker.redlock = app.meta.redlock.create(_redlockOptions);
|
|
85
|
-
}
|
|
86
|
-
// create work
|
|
87
|
-
const connectionWorker = app.redis.get('queue').duplicate();
|
|
88
|
-
const _workerOptions = Object.assign({}, app.config.queue.worker, workerOptions, {
|
|
89
|
-
prefix,
|
|
90
|
-
connection: connectionWorker,
|
|
91
|
-
});
|
|
92
|
-
_worker.worker = new bull.Worker(queueKey, async (job) => {
|
|
93
|
-
// concurrency
|
|
94
|
-
if (queueConfig.concurrency) {
|
|
95
|
-
return await this._performTask(job);
|
|
96
|
-
}
|
|
97
|
-
// redlock
|
|
98
|
-
const _lockResource = `queue:${queueKey}${job.data.queueNameSub ? '#' + job.data.queueNameSub : ''}`;
|
|
99
|
-
return await app.meta.util.lock({
|
|
100
|
-
// subdomain: job.data.subdomain, // need not
|
|
101
|
-
resource: _lockResource,
|
|
102
|
-
options: _redlockOptions,
|
|
103
|
-
redlock: _worker.redlock,
|
|
104
|
-
fn: async () => {
|
|
105
|
-
return await this._performTask(job);
|
|
106
|
-
},
|
|
107
|
-
});
|
|
108
|
-
}, _workerOptions);
|
|
109
|
-
_worker.worker.on('failed', (_job, err) => {
|
|
110
|
-
app.logger.error(err);
|
|
111
|
-
});
|
|
112
|
-
_worker.worker.on('error', err => {
|
|
113
|
-
if (err.message && err.message.indexOf('Missing lock for job') > -1) {
|
|
114
|
-
const workerInner = _worker.worker;
|
|
115
|
-
if (!workerInner.running) {
|
|
116
|
-
_worker.worker.run().catch(error => {
|
|
117
|
-
console.error(error);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
// ok
|
|
123
|
-
return _worker;
|
|
124
|
-
}
|
|
125
|
-
_createQueue(info, queueKey) {
|
|
126
|
-
const app = this.app;
|
|
127
|
-
// queue
|
|
128
|
-
const _queue = {};
|
|
129
|
-
// prefix
|
|
130
|
-
const prefix = `bull_${app.name}:queue`;
|
|
131
|
-
// queue config
|
|
132
|
-
const queueConfig = app.meta.queues[`${info.module}:${info.queueName}`].config;
|
|
133
|
-
// queueConfig.options: queue/worker/job/limiter
|
|
134
|
-
const queueOptions = (queueConfig.options && queueConfig.options.queue) || null;
|
|
135
|
-
// create queue
|
|
136
|
-
const connectionQueue = app.redis.get('queue').duplicate();
|
|
137
|
-
const _queueOptions = Object.assign({}, queueOptions, { prefix, connection: connectionQueue });
|
|
138
|
-
_queue.queue = new bull.Queue(queueKey, _queueOptions);
|
|
139
|
-
// create events
|
|
140
|
-
const connectionEvents = app.redis.get('queue').duplicate();
|
|
141
|
-
_queue.queueEvents = new bull.QueueEvents(queueKey, { prefix, connection: connectionEvents });
|
|
142
|
-
_queue.queueEvents.on('completed', ({ jobId, returnvalue }) => {
|
|
143
|
-
this._callCallback(jobId, null, returnvalue);
|
|
144
|
-
});
|
|
145
|
-
_queue.queueEvents.on('failed', ({ jobId, failedReason }) => {
|
|
146
|
-
this._callCallback(jobId, failedReason, null);
|
|
147
|
-
});
|
|
148
|
-
// ok
|
|
149
|
-
return _queue;
|
|
150
|
-
}
|
|
151
|
-
_ensureWorker(info) {
|
|
152
|
-
// queueKey
|
|
153
|
-
const queueKey = this._combineQueueKey(info);
|
|
154
|
-
// worker
|
|
155
|
-
if (!this._workers[queueKey]) {
|
|
156
|
-
this._workers[queueKey] = this._createWorker(info, queueKey);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
_ensureQueue(info) {
|
|
160
|
-
// worker
|
|
161
|
-
this._ensureWorker(info);
|
|
162
|
-
// queueKey
|
|
163
|
-
const queueKey = this._combineQueueKey(info);
|
|
164
|
-
// queue
|
|
165
|
-
if (!this._queues[queueKey]) {
|
|
166
|
-
this._queues[queueKey] = this._createQueue(info, queueKey);
|
|
167
|
-
}
|
|
168
|
-
// ok
|
|
169
|
-
return this._queues[queueKey];
|
|
170
|
-
}
|
|
171
|
-
_getQueue(info) {
|
|
172
|
-
return this._ensureQueue(info).queue;
|
|
173
|
-
}
|
|
174
|
-
_callCallback(jobId, failedReason, data) {
|
|
175
|
-
const _callback = this._queueCallbacks[jobId];
|
|
176
|
-
if (_callback) {
|
|
177
|
-
delete this._queueCallbacks[jobId];
|
|
178
|
-
_callback.callback(failedReason ? new Error(failedReason) : null, data);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
_queuePush(info, isAsync) {
|
|
182
|
-
const app = this.app;
|
|
183
|
-
// queue config
|
|
184
|
-
const fullKey = `${info.module}:${info.queueName}`;
|
|
185
|
-
const queueBase = app.meta.queues[fullKey];
|
|
186
|
-
if (!queueBase)
|
|
187
|
-
throw new Error(`queue config not found: ${fullKey}`);
|
|
188
|
-
const queueConfig = queueBase.config;
|
|
189
|
-
// queueConfig.options: queue/worker/job/limiter
|
|
190
|
-
const jobOptions = (queueConfig.options && queueConfig.options.job) || null;
|
|
191
|
-
// queue
|
|
192
|
-
const queue = this._getQueue(info);
|
|
193
|
-
// job
|
|
194
|
-
const jobId = (info.jobOptions && info.jobOptions.jobId) || uuid.v4();
|
|
195
|
-
const jobName = info.jobName || jobId;
|
|
196
|
-
const _jobOptions = Object.assign({}, jobOptions, info.jobOptions);
|
|
197
|
-
// not async
|
|
198
|
-
if (!isAsync) {
|
|
199
|
-
// add job
|
|
200
|
-
return queue.add(jobName, info, _jobOptions);
|
|
201
|
-
}
|
|
202
|
-
// async
|
|
203
|
-
return new Promise((resolve, reject) => {
|
|
204
|
-
// jobId
|
|
205
|
-
if (!_jobOptions.jobId) {
|
|
206
|
-
_jobOptions.jobId = jobId;
|
|
207
|
-
}
|
|
208
|
-
// callback
|
|
209
|
-
this._queueCallbacks[jobId] = {
|
|
210
|
-
info,
|
|
211
|
-
callback: (err, data) => {
|
|
212
|
-
if (err)
|
|
213
|
-
return reject(err);
|
|
214
|
-
resolve(data);
|
|
215
|
-
},
|
|
216
|
-
};
|
|
217
|
-
// add job
|
|
218
|
-
return queue.add(jobName, info, _jobOptions);
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
_combineQueueKey({ subdomain, module = '', queueName = '' }) {
|
|
222
|
-
const app = this.app;
|
|
223
|
-
subdomain = app.meta.util.subdomainDesp(subdomain);
|
|
224
|
-
return `${subdomain}||${module}||${queueName}`;
|
|
225
|
-
}
|
|
226
|
-
async _performTask(job) {
|
|
227
|
-
const app = this.app;
|
|
228
|
-
let { locale, subdomain, module, queueName, queueNameSub, data, ctxParent, dbLevel } = job.data;
|
|
229
|
-
// ctxParent
|
|
230
|
-
if (!ctxParent)
|
|
231
|
-
ctxParent = {};
|
|
232
|
-
ctxParent.dbLevel = dbLevel - 1;
|
|
233
|
-
// context
|
|
234
|
-
const context = { job, data };
|
|
235
|
-
if (queueNameSub) {
|
|
236
|
-
context.queueNameSub = queueNameSub;
|
|
237
|
-
}
|
|
238
|
-
// queue config
|
|
239
|
-
const queue = app.meta.queues[`${module}:${queueName}`];
|
|
240
|
-
// bean
|
|
241
|
-
const bean = queue.bean;
|
|
242
|
-
// execute
|
|
243
|
-
return await app.meta.util.executeBean({
|
|
244
|
-
locale,
|
|
245
|
-
subdomain,
|
|
246
|
-
context,
|
|
247
|
-
beanModule: bean.module,
|
|
248
|
-
beanFullName: `${bean.module}.queue.${bean.name}`,
|
|
249
|
-
transaction: queue.config.transaction,
|
|
250
|
-
ctxParent,
|
|
251
|
-
});
|
|
252
|
-
}
|
|
253
|
-
_getRepeatKey(name, repeat) {
|
|
254
|
-
const endDate = repeat.endDate ? new Date(repeat.endDate).getTime() : '';
|
|
255
|
-
const tz = repeat.tz || '';
|
|
256
|
-
const suffix = (repeat.cron ? repeat.cron : String(repeat.every)) || '';
|
|
257
|
-
const jobId = repeat.jobId ? repeat.jobId : '';
|
|
258
|
-
return `${name}:${jobId}:${endDate}:${tz}:${suffix}`;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
exports.QueueClient = QueueClient;
|
|
262
|
-
//# sourceMappingURL=queueClient.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import Bottleneck from 'bottleneck';
|
|
2
|
-
import { VonaApplication } from '../../types/index.js';
|
|
3
|
-
import { BeanSimple } from '../bean/beanSimple.js';
|
|
4
|
-
export declare class AppLimiter extends BeanSimple {
|
|
5
|
-
create(options: any): Bottleneck;
|
|
6
|
-
}
|
|
7
|
-
export declare class AppRedlock extends BeanSimple {
|
|
8
|
-
create(options: any): any;
|
|
9
|
-
}
|
|
10
|
-
export default function (app: VonaApplication): void;
|
|
11
|
-
//# sourceMappingURL=redis.d.ts.map
|
package/dist/lib/module/redis.js
DELETED
|
@@ -1,46 +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.AppRedlock = exports.AppLimiter = void 0;
|
|
7
|
-
const bottleneck_1 = __importDefault(require("bottleneck"));
|
|
8
|
-
const redlock_1 = __importDefault(require("redlock"));
|
|
9
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
10
|
-
class AppLimiter extends beanSimple_js_1.BeanSimple {
|
|
11
|
-
// https://github.com/SGrondin/bottleneck#clustering
|
|
12
|
-
create(options) {
|
|
13
|
-
options = options || {};
|
|
14
|
-
// datastore
|
|
15
|
-
options.datastore = 'ioredis';
|
|
16
|
-
// connection
|
|
17
|
-
if (options.connection === undefined) {
|
|
18
|
-
options.connection = new bottleneck_1.default.IORedisConnection({
|
|
19
|
-
client: this.app.redis.get('limiter'),
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
return new bottleneck_1.default(options);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.AppLimiter = AppLimiter;
|
|
26
|
-
class AppRedlock extends beanSimple_js_1.BeanSimple {
|
|
27
|
-
// https://github.com/mike-marcacci/node-redlock#configuration
|
|
28
|
-
create(options) {
|
|
29
|
-
// clients
|
|
30
|
-
const clients = [];
|
|
31
|
-
for (const clientName of this.app.config.queue.redlock.clients) {
|
|
32
|
-
const client = this.app.redis.get(clientName) || this.app.redis.get('limiter');
|
|
33
|
-
clients.push(client);
|
|
34
|
-
}
|
|
35
|
-
return new redlock_1.default(clients, options);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
exports.AppRedlock = AppRedlock;
|
|
39
|
-
function default_1(app) {
|
|
40
|
-
// limiter
|
|
41
|
-
app.meta.limiter = app.bean._newBean(AppLimiter);
|
|
42
|
-
// redlock
|
|
43
|
-
app.meta.redlock = app.bean._newBean(AppRedlock);
|
|
44
|
-
}
|
|
45
|
-
exports.default = default_1;
|
|
46
|
-
//# sourceMappingURL=redis.js.map
|
|
@@ -1,98 +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 path_1 = __importDefault(require("path"));
|
|
7
|
-
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
8
|
-
const chokidar_1 = __importDefault(require("chokidar"));
|
|
9
|
-
const debounce_1 = __importDefault(require("debounce"));
|
|
10
|
-
const process_helper_1 = require("@cabloy/process-helper");
|
|
11
|
-
const cast_js_1 = require("../../../types/utils/cast.js");
|
|
12
|
-
function default_1(app) {
|
|
13
|
-
let watcherDevelopment = null;
|
|
14
|
-
// only in development
|
|
15
|
-
if (app.meta.inAgent && app.meta.isLocal) {
|
|
16
|
-
_register();
|
|
17
|
-
}
|
|
18
|
-
// invoked in agent
|
|
19
|
-
function _register() {
|
|
20
|
-
// watchDirs
|
|
21
|
-
const watchDirs = _collectDevelopmentWatchDirs();
|
|
22
|
-
// close
|
|
23
|
-
if (watcherDevelopment) {
|
|
24
|
-
const _watcher = (0, cast_js_1.Cast)(watcherDevelopment);
|
|
25
|
-
if (!_watcher.__eb_closed) {
|
|
26
|
-
if (_watcher.__eb_ready) {
|
|
27
|
-
_watcher.close();
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
_watcher.__eb_closing = true;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
watcherDevelopment = null;
|
|
34
|
-
}
|
|
35
|
-
// watcher
|
|
36
|
-
const _watcher = chokidar_1.default.watch(watchDirs).on('change', (0, debounce_1.default)(info => {
|
|
37
|
-
_developmentChange(info);
|
|
38
|
-
}, app.config.development.debounce));
|
|
39
|
-
// on ready
|
|
40
|
-
const _watcher2 = (0, cast_js_1.Cast)(_watcher);
|
|
41
|
-
_watcher.once('ready', function () {
|
|
42
|
-
_watcher2.__eb_ready = true;
|
|
43
|
-
if (_watcher2.__eb_closing) {
|
|
44
|
-
_watcher.close();
|
|
45
|
-
_watcher2.__eb_closed = true;
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
// ok
|
|
49
|
-
watcherDevelopment = _watcher;
|
|
50
|
-
}
|
|
51
|
-
// invoked in agent
|
|
52
|
-
function _collectDevelopmentWatchDirs() {
|
|
53
|
-
const __pathes = [
|
|
54
|
-
'src/backend/config',
|
|
55
|
-
'src/backend/demo',
|
|
56
|
-
'src/module',
|
|
57
|
-
'src/module-vendor',
|
|
58
|
-
'src/suite',
|
|
59
|
-
'src/suite-vendor',
|
|
60
|
-
'packages-vona/vona',
|
|
61
|
-
];
|
|
62
|
-
const cwd = process.cwd();
|
|
63
|
-
const watchDirs = [];
|
|
64
|
-
for (const __path of __pathes) {
|
|
65
|
-
const pathDir = path_1.default.join(cwd, __path);
|
|
66
|
-
if (fs_extra_1.default.existsSync(pathDir)) {
|
|
67
|
-
watchDirs.push(pathDir);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return watchDirs;
|
|
71
|
-
// const pathSrc = path.resolve(this.app.config.baseDir, '..');
|
|
72
|
-
// let watchDirs = eggBornUtils.tools.globbySync(`${pathSrc}/**/backend/src`, { onlyDirectories: true });
|
|
73
|
-
// watchDirs = [path.join(pathSrc, 'backend/config')].concat(watchDirs);
|
|
74
|
-
// return watchDirs;
|
|
75
|
-
}
|
|
76
|
-
// invoked in agent
|
|
77
|
-
async function _developmentChange(info) {
|
|
78
|
-
info = info.replace(/\\/g, '/');
|
|
79
|
-
// extname
|
|
80
|
-
const extname = path_1.default.extname(info);
|
|
81
|
-
if (!['.ts', '.mts'].includes(extname))
|
|
82
|
-
return;
|
|
83
|
-
// log
|
|
84
|
-
app.logger.warn(`[agent:development] reload worker because ${info} changed`);
|
|
85
|
-
// tsc
|
|
86
|
-
if (extname !== '.mts') {
|
|
87
|
-
const __pathes = ['src/backend/config', 'src/backend/demo', 'packages-vona/vona'];
|
|
88
|
-
if (__pathes.some(item => info.indexOf(item) > -1)) {
|
|
89
|
-
const processHelper = new process_helper_1.ProcessHelper();
|
|
90
|
-
await processHelper.tsc();
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
// reload
|
|
94
|
-
app.meta.reload.now();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
exports.default = default_1;
|
|
98
|
-
//# sourceMappingURL=development.js.map
|