vona 5.0.4 → 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 +8 -0
- package/README.en-US.md +63 -0
- package/README.md +63 -1
- package/package.json +6 -76
- package/LICENSE.en-US +0 -3
- 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 -514
- 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 -21
- 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/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 -12
- 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 -65
- package/dist/lib/core/meta.js +0 -335
- 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 -172
- package/dist/lib/decorator/class/aop.d.ts +0 -3
- package/dist/lib/decorator/class/aop.js +0 -23
- package/dist/lib/decorator/class/atom.d.ts +0 -3
- package/dist/lib/decorator/class/atom.js +0 -22
- 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 -3
- package/dist/lib/decorator/class/controller.js +0 -22
- package/dist/lib/decorator/class/index.d.ts +0 -10
- package/dist/lib/decorator/class/index.js +0 -26
- 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 -28
- 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 -3
- package/dist/lib/decorator/class/service.js +0 -23
- 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 -55
- 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 -21
- package/dist/lib/framework/loader.js +0 -57
- 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 -134
- package/dist/lib/module/moduleMeta.d.ts +0 -3
- package/dist/lib/module/moduleMeta.js +0 -26
- 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 -19
- 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 -25
- 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 -3
- package/dist/types/utils/index.js +0 -19
- package/dist/types/utils/powerPartial.d.ts +0 -4
- package/dist/types/utils/powerPartial.js +0 -3
package/dist/lib/base/model.js
DELETED
|
@@ -1,253 +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.Model = void 0;
|
|
7
|
-
const is_type_of_1 = __importDefault(require("is-type-of"));
|
|
8
|
-
const beanSimple_js_1 = require("../bean/beanSimple.js");
|
|
9
|
-
let __columns = {};
|
|
10
|
-
class Model extends beanSimple_js_1.BeanSimple {
|
|
11
|
-
constructor({ table, options = {} }) {
|
|
12
|
-
super();
|
|
13
|
-
this.table = table;
|
|
14
|
-
this.options = options;
|
|
15
|
-
}
|
|
16
|
-
get disableDeleted() {
|
|
17
|
-
return this.options.disableDeleted === undefined
|
|
18
|
-
? this.app.config.model.disableDeleted
|
|
19
|
-
: this.options.disableDeleted;
|
|
20
|
-
}
|
|
21
|
-
get disableInstance() {
|
|
22
|
-
return this.options.disableInstance === undefined
|
|
23
|
-
? this.app.config.model.disableInstance
|
|
24
|
-
: this.options.disableInstance;
|
|
25
|
-
}
|
|
26
|
-
async columns(tableName) {
|
|
27
|
-
tableName = tableName || this.table;
|
|
28
|
-
let columns = __columns[tableName];
|
|
29
|
-
if (!columns) {
|
|
30
|
-
const list = await this.ctx.db.query(`show columns from ${this.ctx.db.format('??', tableName)}`);
|
|
31
|
-
columns = __columns[tableName] = {};
|
|
32
|
-
for (const item of list) {
|
|
33
|
-
columns[item.Field] = item;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return columns;
|
|
37
|
-
}
|
|
38
|
-
columnsClear(tableName) {
|
|
39
|
-
tableName = tableName || this.table;
|
|
40
|
-
const exists = __columns[tableName];
|
|
41
|
-
delete __columns[tableName];
|
|
42
|
-
return exists;
|
|
43
|
-
}
|
|
44
|
-
columnsClearAll() {
|
|
45
|
-
const exists = Object.keys(__columns).length > 0;
|
|
46
|
-
__columns = {};
|
|
47
|
-
return exists;
|
|
48
|
-
}
|
|
49
|
-
async prepareData(item) {
|
|
50
|
-
// columns
|
|
51
|
-
const columns = await this.columns();
|
|
52
|
-
// data
|
|
53
|
-
const data = {};
|
|
54
|
-
for (const columnName in columns) {
|
|
55
|
-
if (item[columnName] !== undefined) {
|
|
56
|
-
data[columnName] = item[columnName];
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return data;
|
|
60
|
-
}
|
|
61
|
-
async default(data) {
|
|
62
|
-
data = data || {};
|
|
63
|
-
// columns
|
|
64
|
-
const columns = await this.columns();
|
|
65
|
-
for (const columnName in columns) {
|
|
66
|
-
const column = columns[columnName];
|
|
67
|
-
data[columnName] = this._coerceTypeOfDefault(column);
|
|
68
|
-
}
|
|
69
|
-
return data;
|
|
70
|
-
}
|
|
71
|
-
_coerceTypeOfDefault(column) {
|
|
72
|
-
// type
|
|
73
|
-
let type = column.Type;
|
|
74
|
-
const pos = type.indexOf('(');
|
|
75
|
-
if (pos > -1)
|
|
76
|
-
type = type.substring(0, pos);
|
|
77
|
-
// default value
|
|
78
|
-
const value = column.Default;
|
|
79
|
-
// coerce
|
|
80
|
-
if (value === null)
|
|
81
|
-
return value;
|
|
82
|
-
if (['timestamp'].includes(type) && value === 'CURRENT_TIMESTAMP')
|
|
83
|
-
return new Date();
|
|
84
|
-
if (['bit', 'bool'].includes(type))
|
|
85
|
-
return Boolean(value);
|
|
86
|
-
if (['float', 'double'].includes(type))
|
|
87
|
-
return Number(value);
|
|
88
|
-
if (['tinyint', 'smallint', 'mediumint', 'int', 'bigint'].includes(type))
|
|
89
|
-
return Number(value);
|
|
90
|
-
// others
|
|
91
|
-
return value;
|
|
92
|
-
}
|
|
93
|
-
async create(data, ...args) {
|
|
94
|
-
const data2 = await this.prepareData(data);
|
|
95
|
-
const res = await this.insert(data2, ...args);
|
|
96
|
-
return res.insertId;
|
|
97
|
-
}
|
|
98
|
-
async write(data, ...args) {
|
|
99
|
-
const data2 = await this.prepareData(data);
|
|
100
|
-
return await this.update(data2, ...args);
|
|
101
|
-
}
|
|
102
|
-
_rowCheck(row) {
|
|
103
|
-
if ((!this.table || !this.disableInstance) && row.iid === undefined) {
|
|
104
|
-
row.iid = this.ctx.instance.id;
|
|
105
|
-
}
|
|
106
|
-
if (this.table && !this.disableDeleted && row.deleted === undefined) {
|
|
107
|
-
row.deleted = 0;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
_insertRowsCheck(rows) {
|
|
111
|
-
if (!Array.isArray(rows))
|
|
112
|
-
return this._rowCheck(rows);
|
|
113
|
-
for (const row of rows) {
|
|
114
|
-
this._rowCheck(row);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
exports.Model = Model;
|
|
119
|
-
[
|
|
120
|
-
'literals', //
|
|
121
|
-
'escape',
|
|
122
|
-
'escapeId',
|
|
123
|
-
'format',
|
|
124
|
-
'_formatValue',
|
|
125
|
-
'_formatWhere',
|
|
126
|
-
'_where',
|
|
127
|
-
'_orders',
|
|
128
|
-
'raw',
|
|
129
|
-
'query',
|
|
130
|
-
'queryOne',
|
|
131
|
-
'_query',
|
|
132
|
-
'_selectColumns',
|
|
133
|
-
'_limit',
|
|
134
|
-
].forEach(method => {
|
|
135
|
-
Object.defineProperty(Model.prototype, method, {
|
|
136
|
-
get() {
|
|
137
|
-
if (is_type_of_1.default.function(this.ctx.db[method])) {
|
|
138
|
-
return function (...args) {
|
|
139
|
-
return this.ctx.db[method](...args);
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
// property
|
|
143
|
-
return this.ctx.db[method];
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
['insert'].forEach(method => {
|
|
148
|
-
Object.defineProperty(Model.prototype, method, {
|
|
149
|
-
get() {
|
|
150
|
-
return function (...args) {
|
|
151
|
-
if (args.length === 0) {
|
|
152
|
-
args.push({});
|
|
153
|
-
}
|
|
154
|
-
if (this.table) {
|
|
155
|
-
args.unshift(this.table);
|
|
156
|
-
}
|
|
157
|
-
this._insertRowsCheck(args[1]);
|
|
158
|
-
return this.ctx.db[method](...args);
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
['update'].forEach(method => {
|
|
164
|
-
Object.defineProperty(Model.prototype, method, {
|
|
165
|
-
get() {
|
|
166
|
-
return function (...args) {
|
|
167
|
-
const _args = [];
|
|
168
|
-
if (this.table)
|
|
169
|
-
_args.push(this.table);
|
|
170
|
-
for (const arg of args)
|
|
171
|
-
_args.push(arg);
|
|
172
|
-
if (_args[2] && _args[2].where) {
|
|
173
|
-
this._rowCheck(_args[2].where);
|
|
174
|
-
}
|
|
175
|
-
return this.ctx.db[method](..._args);
|
|
176
|
-
};
|
|
177
|
-
},
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
['delete'].forEach(method => {
|
|
181
|
-
Object.defineProperty(Model.prototype, method, {
|
|
182
|
-
get() {
|
|
183
|
-
return function (...args) {
|
|
184
|
-
const _args = [];
|
|
185
|
-
if (this.table)
|
|
186
|
-
_args.push(this.table);
|
|
187
|
-
for (const arg of args)
|
|
188
|
-
_args.push(arg);
|
|
189
|
-
_args[1] = _args[1] || {};
|
|
190
|
-
this._rowCheck(_args[1]);
|
|
191
|
-
if (this.table && !this.disableDeleted) {
|
|
192
|
-
const sql = this.ctx.db.format('UPDATE ?? SET deleted=1 ', [_args[0]]) + this.ctx.db._where(_args[1]);
|
|
193
|
-
return this.ctx.db.query(sql);
|
|
194
|
-
}
|
|
195
|
-
return this.ctx.db[method](..._args);
|
|
196
|
-
};
|
|
197
|
-
},
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
['count'].forEach(method => {
|
|
201
|
-
Object.defineProperty(Model.prototype, method, {
|
|
202
|
-
get() {
|
|
203
|
-
return function (...args) {
|
|
204
|
-
const _args = [];
|
|
205
|
-
if (this.table)
|
|
206
|
-
_args.push(this.table);
|
|
207
|
-
for (const arg of args)
|
|
208
|
-
_args.push(arg);
|
|
209
|
-
_args[1] = _args[1] || {};
|
|
210
|
-
this._rowCheck(_args[1]);
|
|
211
|
-
return this.ctx.db[method](..._args);
|
|
212
|
-
};
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
['get'].forEach(method => {
|
|
217
|
-
Object.defineProperty(Model.prototype, method, {
|
|
218
|
-
get() {
|
|
219
|
-
return function (...args) {
|
|
220
|
-
// console.log(this.constructor.name, arguments);
|
|
221
|
-
const _args = [];
|
|
222
|
-
if (this.table)
|
|
223
|
-
_args.push(this.table);
|
|
224
|
-
for (const arg of args)
|
|
225
|
-
_args.push(arg);
|
|
226
|
-
_args[1] = _args[1] || {};
|
|
227
|
-
// if (_args[1].id) {
|
|
228
|
-
// return this.ctx.db[method].apply(this.ctx.db, _args);
|
|
229
|
-
// }
|
|
230
|
-
this._rowCheck(_args[1]);
|
|
231
|
-
return this.ctx.db[method](..._args);
|
|
232
|
-
};
|
|
233
|
-
},
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
['select'].forEach(method => {
|
|
237
|
-
Object.defineProperty(Model.prototype, method, {
|
|
238
|
-
get() {
|
|
239
|
-
return function (...args) {
|
|
240
|
-
const _args = [];
|
|
241
|
-
if (this.table)
|
|
242
|
-
_args.push(this.table);
|
|
243
|
-
for (const arg of args)
|
|
244
|
-
_args.push(arg);
|
|
245
|
-
_args[1] = _args[1] || {};
|
|
246
|
-
_args[1].where = _args[1].where || {};
|
|
247
|
-
this._rowCheck(_args[1].where);
|
|
248
|
-
return this.ctx.db[method](..._args);
|
|
249
|
-
};
|
|
250
|
-
},
|
|
251
|
-
});
|
|
252
|
-
});
|
|
253
|
-
//# sourceMappingURL=model.js.map
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeanLocal = void 0;
|
|
4
|
-
const beanModuleScopeBase_js_1 = require("./beanModuleScopeBase.js");
|
|
5
|
-
class BeanLocal extends beanModuleScopeBase_js_1.BeanModuleScopeBase {
|
|
6
|
-
// magic
|
|
7
|
-
__get__(prop) {
|
|
8
|
-
return this.bean._getBean(`${this.moduleScope}.local.${prop}`);
|
|
9
|
-
}
|
|
10
|
-
// beanLocal has no __beanFullName__
|
|
11
|
-
module(moduleScope) {
|
|
12
|
-
return this.bean._newBeanScope(BeanLocal, moduleScope);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.BeanLocal = BeanLocal;
|
|
16
|
-
//# sourceMappingURL=_beanLocal_.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BeanBaseSimple } from './beanBaseSimple.js';
|
|
2
|
-
import { IModuleLocaleText } from './resource/locale/type.js';
|
|
3
|
-
import { IBeanScopeRecord, TypeBeanScopeRecordKeys } from './type.js';
|
|
4
|
-
export declare class BeanBase<TScopeModule = unknown> extends BeanBaseSimple {
|
|
5
|
-
protected get $text(): IModuleLocaleText;
|
|
6
|
-
protected get scope(): TScopeModule;
|
|
7
|
-
protected getScope<K extends TypeBeanScopeRecordKeys>(moduleScope: K): IBeanScopeRecord[K];
|
|
8
|
-
protected getScope(): TScopeModule;
|
|
9
|
-
protected __get__(prop: PropertyKey): undefined;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=beanBase.d.ts.map
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeanBase = void 0;
|
|
4
|
-
const word_utils_1 = require("@cabloy/word-utils");
|
|
5
|
-
const beanBaseSimple_js_1 = require("./beanBaseSimple.js");
|
|
6
|
-
const SymbolText = Symbol('SymbolText');
|
|
7
|
-
class BeanBase extends beanBaseSimple_js_1.BeanBaseSimple {
|
|
8
|
-
get $text() {
|
|
9
|
-
if (!this[SymbolText]) {
|
|
10
|
-
this[SymbolText] = this.ctx.meta.locale.createLocaleText(this.moduleBelong);
|
|
11
|
-
}
|
|
12
|
-
return this[SymbolText];
|
|
13
|
-
}
|
|
14
|
-
get scope() {
|
|
15
|
-
return this.getScope();
|
|
16
|
-
}
|
|
17
|
-
getScope(moduleScope) {
|
|
18
|
-
if (!moduleScope) {
|
|
19
|
-
return this.bean.scope(this.moduleBelong);
|
|
20
|
-
}
|
|
21
|
-
return this.bean.scope(moduleScope);
|
|
22
|
-
}
|
|
23
|
-
__get__(prop) {
|
|
24
|
-
if (typeof prop === 'string' && prop.startsWith('$scope')) {
|
|
25
|
-
let moduleName = (0, word_utils_1.splitWords)(prop.substring('$scope'.length), true, '-');
|
|
26
|
-
if (!moduleName?.includes('-')) {
|
|
27
|
-
moduleName = 'a-' + moduleName;
|
|
28
|
-
}
|
|
29
|
-
return this.getScope(moduleName);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.BeanBase = BeanBase;
|
|
34
|
-
//# sourceMappingURL=beanBase.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BeanSimple } from './beanSimple.js';
|
|
2
|
-
export declare class BeanBaseSimple extends BeanSimple {
|
|
3
|
-
private __beanFullName__;
|
|
4
|
-
private __moduleBelong__?;
|
|
5
|
-
constructor(moduleBelong?: string);
|
|
6
|
-
protected get moduleBelong(): string;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=beanBaseSimple.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BeanBaseSimple = void 0;
|
|
4
|
-
const resource_js_1 = require("../core/resource.js");
|
|
5
|
-
const beanSimple_js_1 = require("./beanSimple.js");
|
|
6
|
-
class BeanBaseSimple extends beanSimple_js_1.BeanSimple {
|
|
7
|
-
constructor(moduleBelong) {
|
|
8
|
-
super();
|
|
9
|
-
Object.defineProperty(this, "__beanFullName__", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
configurable: true,
|
|
12
|
-
writable: true,
|
|
13
|
-
value: void 0
|
|
14
|
-
});
|
|
15
|
-
Object.defineProperty(this, "__moduleBelong__", {
|
|
16
|
-
enumerable: true,
|
|
17
|
-
configurable: true,
|
|
18
|
-
writable: true,
|
|
19
|
-
value: void 0
|
|
20
|
-
});
|
|
21
|
-
if (moduleBelong && typeof moduleBelong !== 'string') {
|
|
22
|
-
throw new Error(`moduleBelong not valid: ${moduleBelong}`);
|
|
23
|
-
}
|
|
24
|
-
this.__moduleBelong__ = moduleBelong;
|
|
25
|
-
}
|
|
26
|
-
get moduleBelong() {
|
|
27
|
-
return this.__moduleBelong__ || resource_js_1.appResource._getModuleBelong(this.__beanFullName__);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
exports.BeanBaseSimple = BeanBaseSimple;
|
|
31
|
-
//# sourceMappingURL=beanBaseSimple.js.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { VonaApplication, VonaContext } from '../../types/index.js';
|
|
2
|
-
import { Constructable } from '../decorator/index.js';
|
|
3
|
-
import { IBeanRecord, IBeanRecordGlobal, IBeanScopeRecord, TypeBeanScopeRecordKeys } from './type.js';
|
|
4
|
-
declare const BeanContainerInstances: unique symbol;
|
|
5
|
-
export interface BeanContainer extends IBeanRecordGlobal {
|
|
6
|
-
}
|
|
7
|
-
export declare class BeanContainer {
|
|
8
|
-
private app;
|
|
9
|
-
private ctx;
|
|
10
|
-
private [BeanContainerInstances];
|
|
11
|
-
static create(app: VonaApplication, ctx: VonaContext | null): BeanContainer;
|
|
12
|
-
protected constructor(app: VonaApplication, ctx: VonaContext | null);
|
|
13
|
-
/** get specific module's scope */
|
|
14
|
-
scope<K extends TypeBeanScopeRecordKeys>(moduleScope: K): IBeanScopeRecord[K];
|
|
15
|
-
scope<T>(moduleScope: string): T;
|
|
16
|
-
_getBean<T>(A: Constructable<T>): T;
|
|
17
|
-
_getBean<K extends keyof IBeanRecord>(beanFullName: K): IBeanRecord[K];
|
|
18
|
-
_getBeanSelector<T>(A: Constructable<T>, selector?: string): T;
|
|
19
|
-
_getBeanSelector<K extends keyof IBeanRecord>(beanFullName: K, selector?: string): IBeanRecord[K];
|
|
20
|
-
_newBean<T>(A: Constructable<T>, ...args: any[]): T;
|
|
21
|
-
_newBean<K extends keyof IBeanRecord>(beanFullName: K, ...args: any[]): IBeanRecord[K];
|
|
22
|
-
_newBeanSelector<T>(A: Constructable<T>, selector?: string, ...args: any[]): T;
|
|
23
|
-
_newBeanSelector<K extends keyof IBeanRecord>(beanFullName: K, selector?: string, ...args: any[]): IBeanRecord[K];
|
|
24
|
-
private _createBeanInstance;
|
|
25
|
-
private _injectBeanInstance;
|
|
26
|
-
private _injectBeanInstancePropLazy;
|
|
27
|
-
private _injectBeanInstanceProp;
|
|
28
|
-
private _patchBeanInstance;
|
|
29
|
-
private _newBeanProxy;
|
|
30
|
-
private _getInstanceMethodProxy;
|
|
31
|
-
private _prepareAopChains;
|
|
32
|
-
private _getAopChains;
|
|
33
|
-
private _getAopChainsProp;
|
|
34
|
-
private __composeForPropAdapter;
|
|
35
|
-
private __composeForProp;
|
|
36
|
-
private __composeForPropAsync;
|
|
37
|
-
}
|
|
38
|
-
export {};
|
|
39
|
-
//# sourceMappingURL=beanContainer.d.ts.map
|