@nocobase/database 1.2.2-alpha → 1.2.4-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.
|
@@ -49,7 +49,14 @@ const _MultipleSelectInterface = class _MultipleSelectInterface extends import_b
|
|
|
49
49
|
const enumConfig = ((_a = this.options.uiSchema) == null ? void 0 : _a.enum) || [];
|
|
50
50
|
return items.map((item) => {
|
|
51
51
|
const option = enumConfig.find((option2) => option2.label === item);
|
|
52
|
-
|
|
52
|
+
if (option) {
|
|
53
|
+
return option.value;
|
|
54
|
+
}
|
|
55
|
+
const valueOption = enumConfig.find((option2) => option2.value === item);
|
|
56
|
+
if (valueOption) {
|
|
57
|
+
return valueOption.value;
|
|
58
|
+
}
|
|
59
|
+
throw new Error(`"${item}" is not a valid option in ${ctx.field.name} field.`);
|
|
53
60
|
});
|
|
54
61
|
}
|
|
55
62
|
toString(value, ctx) {
|
|
@@ -34,9 +34,19 @@ var import_base_interface = require("./base-interface");
|
|
|
34
34
|
const _SelectInterface = class _SelectInterface extends import_base_interface.BaseInterface {
|
|
35
35
|
async toValue(str, ctx) {
|
|
36
36
|
var _a;
|
|
37
|
+
if (!str) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
37
40
|
const enumConfig = ((_a = this.options.uiSchema) == null ? void 0 : _a.enum) || [];
|
|
38
41
|
const option = enumConfig.find((item) => item.label === str);
|
|
39
|
-
|
|
42
|
+
if (option) {
|
|
43
|
+
return option.value;
|
|
44
|
+
}
|
|
45
|
+
const valueOption = enumConfig.find((item) => item.value === str);
|
|
46
|
+
if (valueOption) {
|
|
47
|
+
return valueOption.value;
|
|
48
|
+
}
|
|
49
|
+
throw new Error(`"${str}" is not a valid option in ${ctx.field.name} field.`);
|
|
40
50
|
}
|
|
41
51
|
toString(value, ctx) {
|
|
42
52
|
var _a;
|
|
@@ -44,6 +44,11 @@ const _ToManyInterface = class _ToManyInterface extends import_base_interface.Ba
|
|
|
44
44
|
},
|
|
45
45
|
transaction
|
|
46
46
|
});
|
|
47
|
+
items.forEach((item) => {
|
|
48
|
+
if (!targetInstances.find((targetInstance) => targetInstance[filterKey] === item)) {
|
|
49
|
+
throw new Error(`"${item}" not found in ${targetCollection.model.name} ${filterKey}`);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
47
52
|
const primaryKeyAttribute = targetCollection.model.primaryKeyAttribute;
|
|
48
53
|
return targetInstances.map((targetInstance) => targetInstance[primaryKeyAttribute]);
|
|
49
54
|
}
|
|
@@ -36,6 +36,9 @@ const _ToOneInterface = class _ToOneInterface extends import_base_interface.Base
|
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
38
|
async toValue(str, ctx) {
|
|
39
|
+
if (!str) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
39
42
|
const { filterKey, targetCollection, transaction } = ctx;
|
|
40
43
|
const targetInstance = await targetCollection.repository.findOne({
|
|
41
44
|
filter: {
|
|
@@ -43,11 +46,11 @@ const _ToOneInterface = class _ToOneInterface extends import_base_interface.Base
|
|
|
43
46
|
},
|
|
44
47
|
transaction
|
|
45
48
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
return targetInstance[primaryKeyAttribute];
|
|
49
|
+
if (!targetInstance) {
|
|
50
|
+
throw new Error(`"${str}" not found in ${targetCollection.model.name} ${filterKey}`);
|
|
49
51
|
}
|
|
50
|
-
|
|
52
|
+
const primaryKeyAttribute = targetCollection.model.primaryKeyAttribute;
|
|
53
|
+
return targetInstance[primaryKeyAttribute];
|
|
51
54
|
}
|
|
52
55
|
};
|
|
53
56
|
__name(_ToOneInterface, "ToOneInterface");
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/database",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4-alpha",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
7
7
|
"license": "AGPL-3.0",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@nocobase/logger": "1.2.
|
|
10
|
-
"@nocobase/utils": "1.2.
|
|
9
|
+
"@nocobase/logger": "1.2.4-alpha",
|
|
10
|
+
"@nocobase/utils": "1.2.4-alpha",
|
|
11
11
|
"async-mutex": "^0.3.2",
|
|
12
12
|
"chalk": "^4.1.1",
|
|
13
13
|
"cron-parser": "4.4.0",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"url": "git+https://github.com/nocobase/nocobase.git",
|
|
39
39
|
"directory": "packages/database"
|
|
40
40
|
},
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "bacfa9133d38339862eee143c516432c2327099e"
|
|
42
42
|
}
|