@nocobase/data-source-manager 2.0.37 → 2.0.39
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/database-data-source.js +19 -4
- package/package.json +7 -7
|
@@ -58,19 +58,34 @@ const _DatabaseDataSource = class _DatabaseDataSource extends import_data_source
|
|
|
58
58
|
const loadedCollection = loadedCollections[collection.name];
|
|
59
59
|
if (!loadedCollection) return collection;
|
|
60
60
|
const collectionFields = collection.fields || [];
|
|
61
|
-
const
|
|
62
|
-
|
|
61
|
+
const loadedFieldsByName = Object.fromEntries((loadedCollection.fields || []).map((f) => [f.name, f]));
|
|
62
|
+
const loadedFieldsByColumn = (loadedCollection.fields || []).reduce(
|
|
63
|
+
(result, field) => {
|
|
64
|
+
const key = field.columnName || field.field || field.name;
|
|
65
|
+
result[key] = result[key] || [];
|
|
66
|
+
result[key].push(field);
|
|
67
|
+
return result;
|
|
68
|
+
},
|
|
69
|
+
{}
|
|
63
70
|
);
|
|
71
|
+
const isAliasField = /* @__PURE__ */ __name((field) => Boolean((field == null ? void 0 : field.field) && field.name !== field.field), "isAliasField");
|
|
64
72
|
const newFields = collectionFields.map((field) => {
|
|
65
|
-
|
|
73
|
+
var _a, _b;
|
|
74
|
+
const loadedField = loadedFieldsByName[field.name] || ((_a = loadedFieldsByColumn[field.columnName || field.field || field.name]) == null ? void 0 : _a.find(
|
|
75
|
+
(candidate) => !isAliasField(candidate)
|
|
76
|
+
)) || ((_b = loadedFieldsByColumn[field.columnName || field.field || field.name]) == null ? void 0 : _b[0]);
|
|
66
77
|
if (!loadedField) return field;
|
|
67
78
|
if (loadedField.possibleTypes) {
|
|
68
79
|
loadedField.possibleTypes = field.possibleTypes;
|
|
69
80
|
}
|
|
70
81
|
return this.mergeFieldOptions(field, loadedField);
|
|
71
82
|
});
|
|
83
|
+
const loadedMappedFields = (loadedCollection.fields || []).filter(
|
|
84
|
+
(field) => isAliasField(field) && !newFields.find((newField) => newField.name === field.name)
|
|
85
|
+
);
|
|
86
|
+
newFields.push(...loadedMappedFields);
|
|
72
87
|
const loadedAssociationFields = (loadedCollection.fields || []).filter(
|
|
73
|
-
(field) => ["belongsTo", "belongsToMany", "hasMany", "hasOne", "belongsToArray"].includes(field.type)
|
|
88
|
+
(field) => ["belongsTo", "belongsToMany", "hasMany", "hasOne", "belongsToArray"].includes(field.type) && !newFields.find((newField) => newField.name === field.name)
|
|
74
89
|
);
|
|
75
90
|
newFields.push(...loadedAssociationFields);
|
|
76
91
|
return {
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/data-source-manager",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.39",
|
|
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.0.
|
|
10
|
-
"@nocobase/cache": "2.0.
|
|
11
|
-
"@nocobase/database": "2.0.
|
|
12
|
-
"@nocobase/resourcer": "2.0.
|
|
13
|
-
"@nocobase/utils": "2.0.
|
|
9
|
+
"@nocobase/actions": "2.0.39",
|
|
10
|
+
"@nocobase/cache": "2.0.39",
|
|
11
|
+
"@nocobase/database": "2.0.39",
|
|
12
|
+
"@nocobase/resourcer": "2.0.39",
|
|
13
|
+
"@nocobase/utils": "2.0.39",
|
|
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": "1bef474287b73aeef2580e2b949a587435639756"
|
|
23
23
|
}
|