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

@ -1,7 +1,7 @@
{ {
"accessibility": { "accessibility": {
"copyMetadataJson": "Copy metadata JSON", "copyMetadataJson": "Copy metadata JSON",
"createIssue":"Create Issue", "createIssue": "Create Issue",
"exitViewer": "Exit Viewer", "exitViewer": "Exit Viewer",
"flipHorizontally": "Flip Horizontally", "flipHorizontally": "Flip Horizontally",
"flipVertically": "Flip Vertically", "flipVertically": "Flip Vertically",
@ -13,7 +13,7 @@
"nextImage": "Next Image", "nextImage": "Next Image",
"previousImage": "Previous Image", "previousImage": "Previous Image",
"reset": "Reset", "reset": "Reset",
"resetUI":"$t(accessibility.reset) UI", "resetUI": "$t(accessibility.reset) UI",
"rotateClockwise": "Rotate Clockwise", "rotateClockwise": "Rotate Clockwise",
"rotateCounterClockwise": "Rotate Counter-Clockwise", "rotateCounterClockwise": "Rotate Counter-Clockwise",
"showGalleryPanel": "Show Gallery Panel", "showGalleryPanel": "Show Gallery Panel",
@ -59,7 +59,7 @@
"back": "Back", "back": "Back",
"batch": "Batch Manager", "batch": "Batch Manager",
"cancel": "Cancel", "cancel": "Cancel",
"copyError":"$t(gallery.copy) Error", "copyError": "$t(gallery.copy) Error",
"close": "Close", "close": "Close",
"on": "On", "on": "On",
"checkpoint": "Checkpoint", "checkpoint": "Checkpoint",
@ -76,7 +76,7 @@
"error": "Error", "error": "Error",
"file": "File", "file": "File",
"folder": "Folder", "folder": "Folder",
"format":"format", "format": "format",
"generate": "Generate", "generate": "Generate",
"githubLabel": "Github", "githubLabel": "Github",
"hotkeysLabel": "Hotkeys", "hotkeysLabel": "Hotkeys",
@ -355,9 +355,9 @@
"autoSwitchNewImages": "Auto-Switch to New Images", "autoSwitchNewImages": "Auto-Switch to New Images",
"copy": "Copy", "copy": "Copy",
"currentlyInUse": "This image is currently in use in the following features:", "currentlyInUse": "This image is currently in use in the following features:",
"drop":"Drop", "drop": "Drop",
"dropOrUpload":"$t(gallery.drop) or Upload", "dropOrUpload": "$t(gallery.drop) or Upload",
"dropToUpload":"$t(gallery.drop) to Upload", "dropToUpload": "$t(gallery.drop) to Upload",
"deleteImage": "Delete Image", "deleteImage": "Delete Image",
"deleteImageBin": "Deleted images will be sent to your operating system's Bin.", "deleteImageBin": "Deleted images will be sent to your operating system's Bin.",
"deleteImagePermanent": "Deleted images cannot be restored.", "deleteImagePermanent": "Deleted images cannot be restored.",
@ -775,7 +775,7 @@
"esrganModel": "ESRGAN Model", "esrganModel": "ESRGAN Model",
"loading": "loading", "loading": "loading",
"noLoRAsAvailable": "No LoRAs available", "noLoRAsAvailable": "No LoRAs available",
"noLoRAsLoaded":"No LoRAs Loaded", "noLoRAsLoaded": "No LoRAs Loaded",
"noMatchingLoRAs": "No matching LoRAs", "noMatchingLoRAs": "No matching LoRAs",
"noMatchingModels": "No matching Models", "noMatchingModels": "No matching Models",
"noModelsAvailable": "No models available", "noModelsAvailable": "No models available",
@ -787,7 +787,7 @@
"nodes": { "nodes": {
"addNode": "Add Node", "addNode": "Add Node",
"addNodeToolTip": "Add Node (Shift+A, Space)", "addNodeToolTip": "Add Node (Shift+A, Space)",
"addLinearView":"Add to Linear View", "addLinearView": "Add to Linear View",
"animatedEdges": "Animated Edges", "animatedEdges": "Animated Edges",
"animatedEdgesHelp": "Animate selected edges and edges connected to selected nodes", "animatedEdgesHelp": "Animate selected edges and edges connected to selected nodes",
"boardField": "Board", "boardField": "Board",
@ -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.",
@ -979,7 +981,7 @@
"unknownField": "Unknown field", "unknownField": "Unknown field",
"unknownFieldType": "$t(nodes.unknownField) type", "unknownFieldType": "$t(nodes.unknownField) type",
"unknownNode": "Unknown Node", "unknownNode": "Unknown Node",
"unknownNodeType":"$t(nodes.unknownNode) type", "unknownNodeType": "$t(nodes.unknownNode) type",
"unknownTemplate": "Unknown Template", "unknownTemplate": "Unknown Template",
"unknownInput": "Unknown input: {{name}}", "unknownInput": "Unknown input: {{name}}",
"unkownInvocation": "Unknown Invocation type", "unkownInvocation": "Unknown Invocation type",
@ -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",
@ -1593,7 +1585,7 @@
"redo": "Redo", "redo": "Redo",
"resetView": "Reset View", "resetView": "Reset View",
"saveBoxRegionOnly": "Save Box Region Only", "saveBoxRegionOnly": "Save Box Region Only",
"saveMask":"Save $t(unifiedCanvas.mask)", "saveMask": "Save $t(unifiedCanvas.mask)",
"saveToGallery": "Save To Gallery", "saveToGallery": "Save To Gallery",
"scaledBoundingBox": "Scaled Bounding Box", "scaledBoundingBox": "Scaled Bounding Box",
"showCanvasDebugInfo": "Show Additional Canvas Info", "showCanvasDebugInfo": "Show Additional Canvas Info",

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 };