oak-backend-base 3.5.2 → 4.0.1
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/lib/AppLoader.js +12 -59
- package/package.json +5 -5
package/lib/AppLoader.js
CHANGED
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const fs_1 = require("fs");
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const node_schedule_1 = require("node-schedule");
|
|
8
|
-
const env_1 = require("oak-domain/lib/compiler/env");
|
|
9
8
|
const IntrinsicLogics_1 = require("oak-domain/lib/store/IntrinsicLogics");
|
|
10
9
|
const lodash_1 = require("oak-domain/lib/utils/lodash");
|
|
11
10
|
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
@@ -13,8 +12,9 @@ const types_1 = require("oak-domain/lib/types");
|
|
|
13
12
|
const DbStore_1 = require("./DbStore");
|
|
14
13
|
const index_1 = tslib_1.__importStar(require("oak-common-aspect/lib/index"));
|
|
15
14
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
15
|
+
const dependencyBuilder_1 = require("oak-domain/lib/compiler/dependencyBuilder");
|
|
16
16
|
const DataSubscriber_1 = tslib_1.__importDefault(require("./cluster/DataSubscriber"));
|
|
17
|
-
const
|
|
17
|
+
const env_1 = require("./cluster/env");
|
|
18
18
|
const Synchronizer_1 = tslib_1.__importDefault(require("./Synchronizer"));
|
|
19
19
|
class AppLoader extends types_1.AppLoader {
|
|
20
20
|
dbStore;
|
|
@@ -35,58 +35,10 @@ class AppLoader extends types_1.AppLoader {
|
|
|
35
35
|
return require(depFilePath).default;
|
|
36
36
|
}
|
|
37
37
|
}).filter(ele => !!ele);
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
sth = [];
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
sth = {};
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (sth instanceof Array) {
|
|
47
|
-
sthExternal.forEach((sth2, idx) => {
|
|
48
|
-
(0, assert_1.default)(sth2 instanceof Array, `${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象不是数组,与项目对应路径的输出不一致`);
|
|
49
|
-
sth.push(...sth2);
|
|
50
|
-
});
|
|
51
|
-
return sth;
|
|
52
|
-
}
|
|
53
|
-
(0, assert_1.default)(typeof sth === 'object');
|
|
54
|
-
const sthOut = {};
|
|
55
|
-
sthExternal.forEach((sth2, idx) => {
|
|
56
|
-
(0, assert_1.default)(typeof sth2 === 'object' && !(sth2 instanceof Array), `${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象不是非数组对象,与项目对应路径的输出不一致`);
|
|
57
|
-
const inter = (0, lodash_1.intersection)(Object.keys(sthOut), Object.keys(sth2));
|
|
58
|
-
if (inter.length > 0) {
|
|
59
|
-
console.warn(`${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象中的key值【${inter.join(',')}】与其它对应路径输出的key值有冲突,请仔细检查避免错误`);
|
|
60
|
-
inter.forEach((ele) => {
|
|
61
|
-
if (sth2[ele] instanceof Array && sthOut[ele]) {
|
|
62
|
-
(0, assert_1.default)(sthOut[ele] instanceof Array, `${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象的${ele}键值是数组,但之前的相应对象的${ele}却不是,请仔细检查以避免错误`);
|
|
63
|
-
console.warn(`${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象中的key值【${ele}】与其它对应路径输出的key值【${ele}】将以数组格式进行合并,请仔细检查避免错误`);
|
|
64
|
-
sth2[ele].push(...sthOut[ele]);
|
|
65
|
-
}
|
|
66
|
-
else if (!(sth2[ele] instanceof Array) && sthOut[ele]) {
|
|
67
|
-
(0, assert_1.default)(!(sthOut[ele] instanceof Array), `${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象的${ele}键值不是数组,但之前的相应对象的${ele}却是,请仔细检查以避免错误`);
|
|
68
|
-
console.warn(`${(0, path_1.join)(this.path, 'node_modules', this.externalDependencies[idx], filePath)}中的default输出对象中的key值【${ele}】将对与其它对应路径输出的key值【${ele}】进行覆盖,请仔细检查避免错误`);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
Object.assign(sthOut, sth2);
|
|
73
|
-
});
|
|
74
|
-
const inter = (0, lodash_1.intersection)(Object.keys(sthOut), Object.keys(sth));
|
|
75
|
-
if (inter.length > 0) {
|
|
76
|
-
inter.forEach((ele) => {
|
|
77
|
-
if (sth[ele] instanceof Array && sthOut[ele]) {
|
|
78
|
-
(0, assert_1.default)(sthOut[ele] instanceof Array, `项目${filePath}中的default输出对象的${ele}键值是数组,但之前的相应对象的${ele}却不是,请仔细检查以避免错误`);
|
|
79
|
-
console.warn(`项目${filePath}中的default输出对象中的key值【${ele}】与其它引用包该路径输出的key值【${ele}】将以数组格式进行合并,请仔细检查避免错误`);
|
|
80
|
-
sth[ele].push(...sthOut[ele]);
|
|
81
|
-
}
|
|
82
|
-
else if (!(sth[ele] instanceof Array) && sthOut[ele]) {
|
|
83
|
-
(0, assert_1.default)(!(sthOut[ele] instanceof Array), `项目${filePath}中的default输出对象的${ele}键值不是数组,但之前的相应对象的${ele}却是,请仔细检查以避免错误`);
|
|
84
|
-
console.warn(`项目${filePath}中的default输出对象中的key值【${ele}】将对其它引用包该路径输出的key值【${ele}】进行覆盖,请仔细检查避免错误`);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
38
|
+
if (sth) {
|
|
39
|
+
sthExternal.push(sth);
|
|
87
40
|
}
|
|
88
|
-
|
|
89
|
-
return sthOut;
|
|
41
|
+
return (0, lodash_1.mergeConcatMany)(sthExternal);
|
|
90
42
|
}
|
|
91
43
|
async makeContext(cxtStr, headers) {
|
|
92
44
|
const context = this.contextBuilder(this.dbStore);
|
|
@@ -112,8 +64,9 @@ class AppLoader extends types_1.AppLoader {
|
|
|
112
64
|
super(path);
|
|
113
65
|
const { dbConfig } = this.getConfiguration();
|
|
114
66
|
const { storageSchema } = require(`${path}/lib/oak-app-domain/Storage`);
|
|
115
|
-
const
|
|
116
|
-
this.externalDependencies =
|
|
67
|
+
const depGraph = (0, dependencyBuilder_1.analyzeDepedency)(process.cwd());
|
|
68
|
+
this.externalDependencies = Object.keys(depGraph.nodeDict);
|
|
69
|
+
const { authDeduceRelationMap, selectFreeEntities, updateFreeDict } = this.requireSth('lib/configuration/relation');
|
|
117
70
|
this.aspectDict = Object.assign({}, index_1.default, this.requireSth('lib/aspects/index'));
|
|
118
71
|
this.dbStore = new DbStore_1.DbStore(storageSchema, () => this.contextBuilder(this.dbStore), dbConfig, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
|
|
119
72
|
if (ns) {
|
|
@@ -122,7 +75,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
122
75
|
const { BackendRuntimeContext } = require(`${path}/lib/context/BackendRuntimeContext`);
|
|
123
76
|
this.contextBuilder = (store) => {
|
|
124
77
|
const context = new BackendRuntimeContext(store);
|
|
125
|
-
context.clusterInfo = (0,
|
|
78
|
+
context.clusterInfo = (0, env_1.getClusterInfo)();
|
|
126
79
|
const originCommit = context.commit;
|
|
127
80
|
context.commit = async () => {
|
|
128
81
|
const { eventOperationMap, opRecords } = context;
|
|
@@ -146,8 +99,8 @@ class AppLoader extends types_1.AppLoader {
|
|
|
146
99
|
initTriggers() {
|
|
147
100
|
const triggers = this.requireSth('lib/triggers/index');
|
|
148
101
|
const checkers = this.requireSth('lib/checkers/index');
|
|
149
|
-
const {
|
|
150
|
-
const { triggers: adTriggers, checkers: adCheckers } = (0, IntrinsicLogics_1.
|
|
102
|
+
const { actionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
|
103
|
+
const { triggers: adTriggers, checkers: adCheckers } = (0, IntrinsicLogics_1.makeIntrinsicLogics)(this.dbStore.getSchema(), actionDefDict);
|
|
151
104
|
triggers.forEach((trigger) => this.registerTrigger(trigger));
|
|
152
105
|
adTriggers.forEach((trigger) => this.registerTrigger(trigger));
|
|
153
106
|
checkers.forEach((checker) => this.dbStore.registerChecker(checker));
|
|
@@ -331,7 +284,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
331
284
|
startWatchers() {
|
|
332
285
|
const watchers = this.requireSth('lib/watchers/index');
|
|
333
286
|
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
|
334
|
-
const { watchers: adWatchers } = (0, IntrinsicLogics_1.
|
|
287
|
+
const { watchers: adWatchers } = (0, IntrinsicLogics_1.makeIntrinsicLogics)(this.dbStore.getSchema(), ActionDefDict);
|
|
335
288
|
const totalWatchers = watchers.concat(adWatchers);
|
|
336
289
|
let count = 0;
|
|
337
290
|
const execOne = async (watcher, start) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-backend-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"description": "oak-backend-base",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"author": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"mysql": "^2.18.1",
|
|
21
21
|
"mysql2": "^2.3.3",
|
|
22
22
|
"node-schedule": "^2.1.0",
|
|
23
|
-
"oak-common-aspect": "^
|
|
24
|
-
"oak-db": "^3.
|
|
25
|
-
"oak-domain": "^
|
|
26
|
-
"oak-frontend-base": "^
|
|
23
|
+
"oak-common-aspect": "^3.0.0",
|
|
24
|
+
"oak-db": "^3.3.0",
|
|
25
|
+
"oak-domain": "^5.0.0",
|
|
26
|
+
"oak-frontend-base": "^5.0.0",
|
|
27
27
|
"socket.io": "^4.7.2",
|
|
28
28
|
"socket.io-client": "^4.7.2",
|
|
29
29
|
"uuid": "^8.3.2"
|