@nocobase/data-source-manager 2.0.0-alpha.59 → 2.0.0-alpha.60
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.
|
@@ -48,8 +48,8 @@ const _DataSourceFactory = class _DataSourceFactory {
|
|
|
48
48
|
throw new Error(`Data source type "${type}" not found`);
|
|
49
49
|
}
|
|
50
50
|
const environment = (_a = this.dataSourceManager.options.app) == null ? void 0 : _a.environment;
|
|
51
|
-
const { logger, sqlLogger, ...others } = options;
|
|
52
|
-
const opts = { logger, sqlLogger, ...others };
|
|
51
|
+
const { logger, sqlLogger, databaseInstance, ...others } = options;
|
|
52
|
+
const opts = { logger, sqlLogger, databaseInstance, ...others };
|
|
53
53
|
if (environment) {
|
|
54
54
|
Object.assign(opts, environment.renderJsonTemplate(others));
|
|
55
55
|
}
|
|
@@ -72,11 +72,15 @@ const _DataSourceManager = class _DataSourceManager {
|
|
|
72
72
|
for (const hook of this.beforeAddHooks) {
|
|
73
73
|
hook(dataSource);
|
|
74
74
|
}
|
|
75
|
-
await dataSource.load(options);
|
|
76
75
|
const oldDataSource = this.dataSources.get(dataSource.name);
|
|
77
76
|
if (oldDataSource) {
|
|
78
|
-
|
|
77
|
+
if (options.reuseDB === true) {
|
|
78
|
+
await oldDataSource.cleanCache();
|
|
79
|
+
} else {
|
|
80
|
+
await oldDataSource.close();
|
|
81
|
+
}
|
|
79
82
|
}
|
|
83
|
+
await dataSource.load(options);
|
|
80
84
|
this.dataSources.set(dataSource.name, dataSource);
|
|
81
85
|
for (const hook of this.onceHooks) {
|
|
82
86
|
hook(dataSource);
|
package/lib/data-source.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare abstract class DataSource extends EventEmitter {
|
|
|
41
41
|
emitLoadingProgress(progress: LoadingProgress): void;
|
|
42
42
|
load(options?: any): Promise<void>;
|
|
43
43
|
close(): Promise<void>;
|
|
44
|
+
cleanCache(): Promise<void>;
|
|
44
45
|
abstract createCollectionManager(options?: any): ICollectionManager;
|
|
45
46
|
protected collectionToResourceMiddleware(): (ctx: any, next: any) => Promise<any>;
|
|
46
47
|
}
|
package/lib/data-source.js
CHANGED
|
@@ -125,6 +125,8 @@ const _DataSource = class _DataSource extends import_events.default {
|
|
|
125
125
|
}
|
|
126
126
|
async close() {
|
|
127
127
|
}
|
|
128
|
+
async cleanCache() {
|
|
129
|
+
}
|
|
128
130
|
collectionToResourceMiddleware() {
|
|
129
131
|
const self = this;
|
|
130
132
|
return /* @__PURE__ */ __name(async function collectionToResource(ctx, next) {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.60",
|
|
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": "2.0.0-alpha.
|
|
10
|
-
"@nocobase/cache": "2.0.0-alpha.
|
|
11
|
-
"@nocobase/database": "2.0.0-alpha.
|
|
12
|
-
"@nocobase/resourcer": "2.0.0-alpha.
|
|
13
|
-
"@nocobase/utils": "2.0.0-alpha.
|
|
9
|
+
"@nocobase/actions": "2.0.0-alpha.60",
|
|
10
|
+
"@nocobase/cache": "2.0.0-alpha.60",
|
|
11
|
+
"@nocobase/database": "2.0.0-alpha.60",
|
|
12
|
+
"@nocobase/resourcer": "2.0.0-alpha.60",
|
|
13
|
+
"@nocobase/utils": "2.0.0-alpha.60",
|
|
14
14
|
"@types/jsonwebtoken": "^8.5.8",
|
|
15
15
|
"jsonwebtoken": "^9.0.2"
|
|
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": "9113d61ce85b60b7ba3d0e5ca64182d92a15ece4"
|
|
23
23
|
}
|