@nocobase/data-source-manager 1.2.10-alpha → 1.2.12-alpha
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.
|
@@ -19,6 +19,7 @@ export declare class DataSourceManager {
|
|
|
19
19
|
factory: DataSourceFactory;
|
|
20
20
|
protected middlewares: any[];
|
|
21
21
|
private onceHooks;
|
|
22
|
+
private beforeAddHooks;
|
|
22
23
|
constructor(options?: {});
|
|
23
24
|
get(dataSourceKey: string): DataSource;
|
|
24
25
|
add(dataSource: DataSource, options?: any): Promise<void>;
|
|
@@ -27,6 +28,7 @@ export declare class DataSourceManager {
|
|
|
27
28
|
registerDataSourceType(type: string, DataSourceClass: typeof DataSource): void;
|
|
28
29
|
getDataSourceType(type: string): typeof DataSource | undefined;
|
|
29
30
|
buildDataSourceByType(type: string, options?: any): DataSource;
|
|
31
|
+
beforeAddDataSource(hook: DataSourceHook): void;
|
|
30
32
|
afterAddDataSource(hook: DataSourceHook): void;
|
|
31
33
|
private addHookAndRun;
|
|
32
34
|
}
|
|
@@ -44,10 +44,14 @@ const _DataSourceManager = class _DataSourceManager {
|
|
|
44
44
|
factory = new import_data_source_factory.DataSourceFactory();
|
|
45
45
|
middlewares = [];
|
|
46
46
|
onceHooks = [];
|
|
47
|
+
beforeAddHooks = [];
|
|
47
48
|
get(dataSourceKey) {
|
|
48
49
|
return this.dataSources.get(dataSourceKey);
|
|
49
50
|
}
|
|
50
51
|
async add(dataSource, options = {}) {
|
|
52
|
+
for (const hook of this.beforeAddHooks) {
|
|
53
|
+
hook(dataSource);
|
|
54
|
+
}
|
|
51
55
|
await dataSource.load(options);
|
|
52
56
|
this.dataSources.set(dataSource.name, dataSource);
|
|
53
57
|
for (const hook of this.onceHooks) {
|
|
@@ -77,6 +81,12 @@ const _DataSourceManager = class _DataSourceManager {
|
|
|
77
81
|
buildDataSourceByType(type, options = {}) {
|
|
78
82
|
return this.factory.create(type, options);
|
|
79
83
|
}
|
|
84
|
+
beforeAddDataSource(hook) {
|
|
85
|
+
this.beforeAddHooks.push(hook);
|
|
86
|
+
for (const dataSource of this.dataSources.values()) {
|
|
87
|
+
hook(dataSource);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
afterAddDataSource(hook) {
|
|
81
91
|
this.addHookAndRun(hook);
|
|
82
92
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.12-alpha",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "1.2.
|
|
10
|
-
"@nocobase/cache": "1.2.
|
|
11
|
-
"@nocobase/database": "1.2.
|
|
12
|
-
"@nocobase/resourcer": "1.2.
|
|
13
|
-
"@nocobase/utils": "1.2.
|
|
9
|
+
"@nocobase/actions": "1.2.12-alpha",
|
|
10
|
+
"@nocobase/cache": "1.2.12-alpha",
|
|
11
|
+
"@nocobase/database": "1.2.12-alpha",
|
|
12
|
+
"@nocobase/resourcer": "1.2.12-alpha",
|
|
13
|
+
"@nocobase/utils": "1.2.12-alpha",
|
|
14
14
|
"@types/jsonwebtoken": "^8.5.8",
|
|
15
15
|
"jsonwebtoken": "^8.5.1"
|
|
16
16
|
},
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
20
20
|
"directory": "packages/auth"
|
|
21
21
|
},
|
|
22
|
-
"gitHead": "
|
|
22
|
+
"gitHead": "553231d4882496cb7f1f17fa7541899ce82a27ab"
|
|
23
23
|
}
|