@nocobase/data-source-manager 2.2.0-beta.16 → 2.2.0-beta.17
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.
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import type { TargetKey } from '@nocobase/database';
|
|
9
10
|
import { DataSource } from './data-source';
|
|
10
11
|
import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
11
12
|
export declare class CollectionManager implements ICollectionManager {
|
|
@@ -34,7 +35,7 @@ export declare class CollectionManager implements ICollectionManager {
|
|
|
34
35
|
hasCollection(name: string): boolean;
|
|
35
36
|
getCollection(name: string): ICollection;
|
|
36
37
|
getCollections(): Array<ICollection>;
|
|
37
|
-
getRepository(name: string, sourceId?:
|
|
38
|
+
getRepository(name: string, sourceId?: TargetKey): IRepository;
|
|
38
39
|
sync(): Promise<void>;
|
|
39
40
|
removeCollection(name: string): void;
|
|
40
41
|
protected newCollection(options: any): ICollection;
|
|
@@ -34,6 +34,7 @@ var import_database_introspector = require("./database-introspector/database-int
|
|
|
34
34
|
var import_postgres_introspector = require("./database-introspector/postgres-introspector");
|
|
35
35
|
var import_mariadb_introspector = require("./database-introspector/mariadb-introspector");
|
|
36
36
|
var import_data_source = require("./data-source");
|
|
37
|
+
const PRESERVED_LOGICAL_FIELD_TYPES_ON_SYNC = ["formula"];
|
|
37
38
|
const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source.DataSource {
|
|
38
39
|
createDatabaseIntrospector(db) {
|
|
39
40
|
if (db.isPostgresCompatibleDialect()) {
|
|
@@ -104,7 +105,8 @@ const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source
|
|
|
104
105
|
const incomingPossibleTypes = Array.isArray(fieldOptions.possibleTypes) ? fieldOptions.possibleTypes : fieldOptions.type ? [fieldOptions.type] : [];
|
|
105
106
|
const hasCompatibleStorageType = this.hasCompatibleStorageType(fieldOptions.type, modelOptions.type);
|
|
106
107
|
const shouldUseIncomingType = Boolean(fieldOptions.rawType) && Boolean(modelOptions.rawType || modelOptions.type) && (modelOptions.rawType ? fieldOptions.rawType !== modelOptions.rawType && !hasCompatibleStorageType : !incomingPossibleTypes.includes(modelOptions.type) && !hasCompatibleStorageType);
|
|
107
|
-
|
|
108
|
+
const shouldPreserveLogicalType = PRESERVED_LOGICAL_FIELD_TYPES_ON_SYNC.includes(modelOptions.type);
|
|
109
|
+
if (shouldUseIncomingType && !shouldPreserveLogicalType) {
|
|
108
110
|
newOptions.type = fieldOptions.type;
|
|
109
111
|
newOptions.interface = fieldOptions.interface;
|
|
110
112
|
newOptions.rawType = fieldOptions.rawType;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
import { Database } from '@nocobase/database';
|
|
10
|
+
import type { TargetKey } from '@nocobase/database';
|
|
10
11
|
import { DataSource } from './data-source';
|
|
11
12
|
import { CollectionOptions, ICollection, ICollectionManager, IField, IFieldInterface, IRepository, MergeOptions } from './types';
|
|
12
13
|
export declare class SequelizeCollectionManager implements ICollectionManager {
|
|
@@ -27,9 +28,9 @@ export declare class SequelizeCollectionManager implements ICollectionManager {
|
|
|
27
28
|
extendCollection(collectionOptions: CollectionOptions, mergeOptions?: MergeOptions): ICollection;
|
|
28
29
|
hasCollection(name: string): boolean;
|
|
29
30
|
getCollection(name: string): import("@nocobase/database").Collection<any, any>;
|
|
30
|
-
removeCollection(name: string):
|
|
31
|
+
removeCollection(name: string): import("@nocobase/database").Collection<any, any>;
|
|
31
32
|
getCollections(): import("@nocobase/database").Collection<any, any>[];
|
|
32
|
-
getRepository<R = IRepository>(name: string, sourceId?:
|
|
33
|
+
getRepository<R = IRepository>(name: string, sourceId?: TargetKey): R;
|
|
33
34
|
sync(): Promise<void>;
|
|
34
35
|
registerFieldInterface(name: string, fieldInterface: new (options: any) => IFieldInterface): void;
|
|
35
36
|
getFieldInterface(name: string): {
|
|
@@ -93,6 +93,7 @@ const _SequelizeCollectionManager = class _SequelizeCollectionManager {
|
|
|
93
93
|
return this.db.getCollection(name);
|
|
94
94
|
}
|
|
95
95
|
removeCollection(name) {
|
|
96
|
+
return this.db.removeCollection(name);
|
|
96
97
|
}
|
|
97
98
|
getCollections() {
|
|
98
99
|
const collectionsFilter = this.collectionsFilter();
|
package/lib/types.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
|
+
import type { TargetKey } from '@nocobase/database';
|
|
9
10
|
import { DataSource } from './data-source';
|
|
10
11
|
export type DataSourceConstructor<T extends DataSource = DataSource> = Omit<typeof DataSource, 'prototype'> & {
|
|
11
12
|
new (...args: any[]): T;
|
|
@@ -113,6 +114,6 @@ export interface ICollectionManager {
|
|
|
113
114
|
getCollection(name: string): ICollection;
|
|
114
115
|
getCollections(): Array<ICollection>;
|
|
115
116
|
removeCollection(name: string): void;
|
|
116
|
-
getRepository(name: string, sourceId?:
|
|
117
|
+
getRepository(name: string, sourceId?: TargetKey): IRepository;
|
|
117
118
|
sync(): Promise<void>;
|
|
118
119
|
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "2.2.0-beta.
|
|
3
|
+
"version": "2.2.0-beta.17",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "./lib/index.js",
|
|
7
7
|
"types": "./lib/index.d.ts",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/actions": "2.2.0-beta.
|
|
10
|
-
"@nocobase/cache": "2.2.0-beta.
|
|
11
|
-
"@nocobase/database": "2.2.0-beta.
|
|
12
|
-
"@nocobase/resourcer": "2.2.0-beta.
|
|
13
|
-
"@nocobase/utils": "2.2.0-beta.
|
|
9
|
+
"@nocobase/actions": "2.2.0-beta.17",
|
|
10
|
+
"@nocobase/cache": "2.2.0-beta.17",
|
|
11
|
+
"@nocobase/database": "2.2.0-beta.17",
|
|
12
|
+
"@nocobase/resourcer": "2.2.0-beta.17",
|
|
13
|
+
"@nocobase/utils": "2.2.0-beta.17",
|
|
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": "d7a69c4f47fe38b17a2ce1408258902cf64f6c83"
|
|
23
23
|
}
|