oak-backend-base 3.5.1 → 4.0.0
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 +13 -62
- package/lib/Synchronizer.js +1 -1
- 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,65 +35,15 @@ 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;
|
|
38
|
+
if (sth) {
|
|
39
|
+
sthExternal.push(sth);
|
|
52
40
|
}
|
|
53
|
-
(0,
|
|
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
|
-
});
|
|
87
|
-
}
|
|
88
|
-
Object.assign(sthOut, sth);
|
|
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);
|
|
93
45
|
await context.begin();
|
|
94
|
-
|
|
95
|
-
await context.initialize(JSON.parse(cxtStr));
|
|
96
|
-
}
|
|
46
|
+
await context.initialize(cxtStr ? JSON.parse(cxtStr) : undefined);
|
|
97
47
|
context.headers = headers;
|
|
98
48
|
return context;
|
|
99
49
|
}
|
|
@@ -114,8 +64,9 @@ class AppLoader extends types_1.AppLoader {
|
|
|
114
64
|
super(path);
|
|
115
65
|
const { dbConfig } = this.getConfiguration();
|
|
116
66
|
const { storageSchema } = require(`${path}/lib/oak-app-domain/Storage`);
|
|
117
|
-
const
|
|
118
|
-
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');
|
|
119
70
|
this.aspectDict = Object.assign({}, index_1.default, this.requireSth('lib/aspects/index'));
|
|
120
71
|
this.dbStore = new DbStore_1.DbStore(storageSchema, () => this.contextBuilder(this.dbStore), dbConfig, authDeduceRelationMap, selectFreeEntities, updateFreeDict);
|
|
121
72
|
if (ns) {
|
|
@@ -124,7 +75,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
124
75
|
const { BackendRuntimeContext } = require(`${path}/lib/context/BackendRuntimeContext`);
|
|
125
76
|
this.contextBuilder = (store) => {
|
|
126
77
|
const context = new BackendRuntimeContext(store);
|
|
127
|
-
context.clusterInfo = (0,
|
|
78
|
+
context.clusterInfo = (0, env_1.getClusterInfo)();
|
|
128
79
|
const originCommit = context.commit;
|
|
129
80
|
context.commit = async () => {
|
|
130
81
|
const { eventOperationMap, opRecords } = context;
|
|
@@ -148,8 +99,8 @@ class AppLoader extends types_1.AppLoader {
|
|
|
148
99
|
initTriggers() {
|
|
149
100
|
const triggers = this.requireSth('lib/triggers/index');
|
|
150
101
|
const checkers = this.requireSth('lib/checkers/index');
|
|
151
|
-
const {
|
|
152
|
-
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);
|
|
153
104
|
triggers.forEach((trigger) => this.registerTrigger(trigger));
|
|
154
105
|
adTriggers.forEach((trigger) => this.registerTrigger(trigger));
|
|
155
106
|
checkers.forEach((checker) => this.dbStore.registerChecker(checker));
|
|
@@ -333,7 +284,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
333
284
|
startWatchers() {
|
|
334
285
|
const watchers = this.requireSth('lib/watchers/index');
|
|
335
286
|
const { ActionDefDict } = require(`${this.path}/lib/oak-app-domain/ActionDefDict`);
|
|
336
|
-
const { watchers: adWatchers } = (0, IntrinsicLogics_1.
|
|
287
|
+
const { watchers: adWatchers } = (0, IntrinsicLogics_1.makeIntrinsicLogics)(this.dbStore.getSchema(), ActionDefDict);
|
|
337
288
|
const totalWatchers = watchers.concat(adWatchers);
|
|
338
289
|
let count = 0;
|
|
339
290
|
const execOne = async (watcher, start) => {
|
package/lib/Synchronizer.js
CHANGED
|
@@ -229,7 +229,7 @@ class Synchronizer {
|
|
|
229
229
|
this.pushOperToChannel(oper2, userId, url, endpoint, entity, entityId, selfEncryptInfo, onSynchronized);
|
|
230
230
|
};
|
|
231
231
|
for (const userId in userSendDict) {
|
|
232
|
-
if (userId !== operatorId) {
|
|
232
|
+
if (userId !== operatorId || oper.bornAt) {
|
|
233
233
|
await pushToUserIdFn(userId);
|
|
234
234
|
pushed = true;
|
|
235
235
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-backend-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
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.30",
|
|
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"
|