oak-backend-base 2.3.0 → 2.3.2
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.d.ts +2 -0
- package/lib/AppLoader.js +16 -9
- package/package.json +4 -4
package/lib/AppLoader.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { AppLoader as GeneralAppLoader, EntityDict } from "oak-domain/lib/types"
|
|
|
3
3
|
import { DbStore } from "./DbStore";
|
|
4
4
|
import { MySQLConfiguration } from 'oak-db/lib/MySQL/types/Configuration';
|
|
5
5
|
import { AsyncContext } from "oak-domain/lib/store/AsyncRowStore";
|
|
6
|
+
import { Endpoint } from 'oak-domain/lib/types/Endpoint';
|
|
6
7
|
export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>> extends GeneralAppLoader<ED, Cxt> {
|
|
7
8
|
private dbStore;
|
|
8
9
|
private aspectDict;
|
|
@@ -13,6 +14,7 @@ export declare class AppLoader<ED extends EntityDict & BaseEntityDict, Cxt exten
|
|
|
13
14
|
execAspect(name: string, context: Cxt, params?: any): Promise<any>;
|
|
14
15
|
initialize(dropIfExists?: boolean): Promise<void>;
|
|
15
16
|
getStore(): DbStore<ED, Cxt>;
|
|
17
|
+
getEndpoints(): Record<string, Endpoint<ED, Cxt>>;
|
|
16
18
|
startWatchers(): void;
|
|
17
19
|
startTimers(): void;
|
|
18
20
|
execStartRoutines(): Promise<void>;
|
package/lib/AppLoader.js
CHANGED
|
@@ -13,13 +13,14 @@ const index_1 = tslib_1.__importStar(require("oak-common-aspect/lib/index"));
|
|
|
13
13
|
function initTriggers(dbStore, path) {
|
|
14
14
|
const triggers = require(`${path}/lib/triggers/index`).default;
|
|
15
15
|
const checkers = require(`${path}/lib/checkers/index`).default;
|
|
16
|
+
const authDict = require(`${path}/lib/auth/index`).default;
|
|
16
17
|
const { ActionDefDict } = require(`${path}/lib/oak-app-domain/ActionDefDict`);
|
|
17
18
|
const { triggers: adTriggers, checkers: adCheckers } = (0, actionDef_1.analyzeActionDefDict)(dbStore.getSchema(), ActionDefDict);
|
|
18
19
|
triggers.forEach((trigger) => dbStore.registerTrigger(trigger));
|
|
19
20
|
adTriggers.forEach((trigger) => dbStore.registerTrigger(trigger));
|
|
20
21
|
checkers.forEach((checker) => dbStore.registerChecker(checker));
|
|
21
22
|
adCheckers.forEach((checker) => dbStore.registerChecker(checker));
|
|
22
|
-
const dynamicCheckers = (0, checkers_1.createDynamicCheckers)(dbStore.getSchema());
|
|
23
|
+
const dynamicCheckers = (0, checkers_1.createDynamicCheckers)(dbStore.getSchema(), authDict);
|
|
23
24
|
dynamicCheckers.forEach((checker) => dbStore.registerChecker(checker));
|
|
24
25
|
const dynamicTriggers = (0, triggers_1.createDynamicTriggers)(dbStore.getSchema());
|
|
25
26
|
dynamicTriggers.forEach((trigger) => dbStore.registerTrigger(trigger));
|
|
@@ -120,14 +121,16 @@ class AppLoader extends types_1.AppLoader {
|
|
|
120
121
|
// 对area暂时处理一下
|
|
121
122
|
rows = require('./data/area.json');
|
|
122
123
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
if (rows.length > 0) {
|
|
125
|
+
await this.dbStore.operate(entity, {
|
|
126
|
+
data: rows,
|
|
127
|
+
action: 'create',
|
|
128
|
+
}, context, {
|
|
129
|
+
dontCollect: true,
|
|
130
|
+
dontCreateOper: true,
|
|
131
|
+
});
|
|
132
|
+
console.log(`data in ${entity} initialized!`);
|
|
133
|
+
}
|
|
131
134
|
}
|
|
132
135
|
await context.commit();
|
|
133
136
|
this.dbStore.disconnect();
|
|
@@ -135,6 +138,10 @@ class AppLoader extends types_1.AppLoader {
|
|
|
135
138
|
getStore() {
|
|
136
139
|
return this.dbStore;
|
|
137
140
|
}
|
|
141
|
+
getEndpoints() {
|
|
142
|
+
const endpoints = require(`${this.path}/lib/endpoints/index`).default;
|
|
143
|
+
return endpoints;
|
|
144
|
+
}
|
|
138
145
|
startWatchers() {
|
|
139
146
|
startWatchers(this.dbStore, this.path, this.contextBuilder);
|
|
140
147
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oak-backend-base",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.2",
|
|
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.2.
|
|
25
|
-
"oak-domain": "^2.
|
|
23
|
+
"oak-common-aspect": "^2.1.4",
|
|
24
|
+
"oak-db": "^2.2.2",
|
|
25
|
+
"oak-domain": "^2.4.0",
|
|
26
26
|
"uuid": "^8.3.2"
|
|
27
27
|
},
|
|
28
28
|
"license": "ISC",
|