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

View File

@ -115,6 +115,15 @@ export const parseFieldType = (
* Any other cases we ignore. * 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 firstType: string | undefined;
let secondType: string | undefined; let secondType: string | undefined;
@ -154,6 +163,13 @@ export const parseFieldType = (
isPolymorphic: true, // <-- don't forget, polymorphic! isPolymorphic: true, // <-- don't forget, polymorphic!
}; };
} }
throw new UnsupportedFieldTypeError(
t('nodes.unsupportedMismatchedUnion', {
firstType,
secondType,
})
);
} }
} else if (schemaObject.enum) { } else if (schemaObject.enum) {
return { name: 'EnumField', isCollection: false, isPolymorphic: false }; return { name: 'EnumField', isCollection: false, isPolymorphic: false };