feat(ui): add errors for invalid polymorphic types

This commit is contained in:
psychedelicious 2023-11-26 20:44:39 +11:00
parent e85f2254f0
commit a703e1b3d3
2 changed files with 34 additions and 26 deletions

View File

@ -971,6 +971,8 @@
"outputFieldTypeParseError": "Unable to parse type of output field {{node}}.{{field}} ({{message}})",
"unableToExtractSchemaNameFromRef": "unable to extract schema name from ref",
"unsupportedArrayItemType": "unsupported array item type \"{{type}}\"",
"unsupportedAnyOfLength": "too many union members ({{count}})",
"unsupportedMismatchedUnion": "mismatched polymorphic type with members {{firstType}} and {{secondType}}",
"unableToParseFieldType": "unable to parse field type",
"uNetField": "UNet",
"uNetFieldDescription": "UNet submodel.",
@ -1353,15 +1355,11 @@
},
"compositingBlur": {
"heading": "Blur",
"paragraphs": [
"The blur radius of the mask."
]
"paragraphs": ["The blur radius of the mask."]
},
"compositingBlurMethod": {
"heading": "Blur Method",
"paragraphs": [
"The method of blur applied to the masked area."
]
"paragraphs": ["The method of blur applied to the masked area."]
},
"compositingCoherencePass": {
"heading": "Coherence Pass",
@ -1371,9 +1369,7 @@
},
"compositingCoherenceMode": {
"heading": "Mode",
"paragraphs": [
"The mode of the Coherence Pass."
]
"paragraphs": ["The mode of the Coherence Pass."]
},
"compositingCoherenceSteps": {
"heading": "Steps",
@ -1391,9 +1387,7 @@
},
"compositingMaskAdjustments": {
"heading": "Mask Adjustments",
"paragraphs": [
"Adjust the mask."
]
"paragraphs": ["Adjust the mask."]
},
"controlNetBeginEnd": {
"heading": "Begin / End Step Percentage",
@ -1451,9 +1445,7 @@
},
"infillMethod": {
"heading": "Infill Method",
"paragraphs": [
"Method to infill the selected area."
]
"paragraphs": ["Method to infill the selected area."]
},
"lora": {
"heading": "LoRA Weight",

View File

@ -115,6 +115,15 @@ export const parseFieldType = (
* Any other cases we ignore.
*/
if (filteredAnyOf.length !== 2) {
// This is a union of more than 2 types, which we don't support
throw new UnsupportedFieldTypeError(
t('nodes.unsupportedAnyOfLength', {
count: filteredAnyOf.length,
})
);
}
let firstType: string | undefined;
let secondType: string | undefined;
@ -154,6 +163,13 @@ export const parseFieldType = (
isPolymorphic: true, // <-- don't forget, polymorphic!
};
}
throw new UnsupportedFieldTypeError(
t('nodes.unsupportedMismatchedUnion', {
firstType,
secondType,
})
);
}
} else if (schemaObject.enum) {
return { name: 'EnumField', isCollection: false, isPolymorphic: false };