oak-backend-base 2.2.0 → 2.3.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 +11 -8
- package/package.json +4 -4
package/lib/AppLoader.js
CHANGED
|
@@ -9,10 +9,10 @@ const triggers_1 = require("oak-domain/lib/triggers");
|
|
|
9
9
|
const uuid_1 = require("oak-domain/lib/utils/uuid");
|
|
10
10
|
const types_1 = require("oak-domain/lib/types");
|
|
11
11
|
const DbStore_1 = require("./DbStore");
|
|
12
|
-
const index_1 = tslib_1.
|
|
12
|
+
const index_1 = tslib_1.__importStar(require("oak-common-aspect/lib/index"));
|
|
13
13
|
function initTriggers(dbStore, path) {
|
|
14
|
-
const triggers = require(`${path}/lib/triggers/index`);
|
|
15
|
-
const checkers = require(`${path}/lib/checkers/index`);
|
|
14
|
+
const triggers = require(`${path}/lib/triggers/index`).default;
|
|
15
|
+
const checkers = require(`${path}/lib/checkers/index`).default;
|
|
16
16
|
const { ActionDefDict } = require(`${path}/lib/oak-app-domain/ActionDefDict`);
|
|
17
17
|
const { triggers: adTriggers, checkers: adCheckers } = (0, actionDef_1.analyzeActionDefDict)(dbStore.getSchema(), ActionDefDict);
|
|
18
18
|
triggers.forEach((trigger) => dbStore.registerTrigger(trigger));
|
|
@@ -25,7 +25,7 @@ function initTriggers(dbStore, path) {
|
|
|
25
25
|
dynamicTriggers.forEach((trigger) => dbStore.registerTrigger(trigger));
|
|
26
26
|
}
|
|
27
27
|
function startWatchers(dbStore, path, contextBuilder) {
|
|
28
|
-
const watchers = require(`${path}/lib/watchers/index`);
|
|
28
|
+
const watchers = require(`${path}/lib/watchers/index`).default;
|
|
29
29
|
const { ActionDefDict } = require(`${path}/lib/oak-app-domain/ActionDefDict`);
|
|
30
30
|
const { watchers: adWatchers } = (0, actionDef_1.analyzeActionDefDict)(dbStore.getSchema(), ActionDefDict);
|
|
31
31
|
const totalWatchers = watchers.concat(adWatchers);
|
|
@@ -85,7 +85,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
85
85
|
constructor(path, contextBuilder, dbConfig) {
|
|
86
86
|
super(path);
|
|
87
87
|
const { storageSchema } = require(`${path}/lib/oak-app-domain/Storage`);
|
|
88
|
-
this.aspectDict = Object.assign({}, index_1.default, require(`${path}/lib/aspects/index`));
|
|
88
|
+
this.aspectDict = Object.assign({}, index_1.default, require(`${path}/lib/aspects/index`).default);
|
|
89
89
|
this.dbStore = new DbStore_1.DbStore(storageSchema, contextBuilder, dbConfig);
|
|
90
90
|
this.contextBuilder = contextBuilder;
|
|
91
91
|
}
|
|
@@ -94,9 +94,12 @@ class AppLoader extends types_1.AppLoader {
|
|
|
94
94
|
if (!initialize) {
|
|
95
95
|
initTriggers(this.dbStore, path);
|
|
96
96
|
}
|
|
97
|
+
const { importations, exportations } = require(`${path}/lib/ports/index`);
|
|
98
|
+
(0, index_1.registerPorts)(importations || [], exportations || []);
|
|
97
99
|
this.dbStore.connect();
|
|
98
100
|
}
|
|
99
101
|
async unmount() {
|
|
102
|
+
(0, index_1.clearPorts)();
|
|
100
103
|
this.dbStore.disconnect();
|
|
101
104
|
}
|
|
102
105
|
async execAspect(name, context, params) {
|
|
@@ -108,7 +111,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
108
111
|
}
|
|
109
112
|
async initialize(dropIfExists) {
|
|
110
113
|
await this.dbStore.initialize(dropIfExists);
|
|
111
|
-
const data = require(`${this.path}/lib/data/index`);
|
|
114
|
+
const data = require(`${this.path}/lib/data/index`).default;
|
|
112
115
|
const context = await this.contextBuilder()(this.dbStore);
|
|
113
116
|
await context.begin();
|
|
114
117
|
for (const entity in data) {
|
|
@@ -136,7 +139,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
136
139
|
startWatchers(this.dbStore, this.path, this.contextBuilder);
|
|
137
140
|
}
|
|
138
141
|
startTimers() {
|
|
139
|
-
const timers = require(`${this.path}/lib/
|
|
142
|
+
const timers = require(`${this.path}/lib/timers/index`).default;
|
|
140
143
|
for (const timer of timers) {
|
|
141
144
|
const { cron, fn, name } = timer;
|
|
142
145
|
(0, node_schedule_1.scheduleJob)(name, cron, async (date) => {
|
|
@@ -157,7 +160,7 @@ class AppLoader extends types_1.AppLoader {
|
|
|
157
160
|
}
|
|
158
161
|
}
|
|
159
162
|
async execStartRoutines() {
|
|
160
|
-
const routines = require(`${this.path}/lib/routines/start`);
|
|
163
|
+
const routines = require(`${this.path}/lib/routines/start`).default;
|
|
161
164
|
for (const routine of routines) {
|
|
162
165
|
const { name, fn } = routine;
|
|
163
166
|
const context = await this.contextBuilder()(this.dbStore);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-backend-base",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"description": "oak-backend-base",
|
|
5
5
|
"main": "lib/index",
|
|
6
6
|
"author": {
|
|
@@ -20,9 +20,9 @@
|
|
|
20
20
|
"mysql": "^2.18.1",
|
|
21
21
|
"mysql2": "^2.3.3",
|
|
22
22
|
"node-schedule": "^2.1.0",
|
|
23
|
-
"oak-common-aspect": "^2.1.
|
|
24
|
-
"oak-db": "^2.
|
|
25
|
-
"oak-domain": "^2.
|
|
23
|
+
"oak-common-aspect": "^2.1.3",
|
|
24
|
+
"oak-db": "^2.2.0",
|
|
25
|
+
"oak-domain": "^2.3.0",
|
|
26
26
|
"uuid": "^8.3.2"
|
|
27
27
|
},
|
|
28
28
|
"license": "ISC",
|