mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): "Polymorphic" -> "CollectionOrScalar"
This new name more accurately represents that these are fields with a type of `T | T[]`, where the "base" type must be the same on both sides of the union.
This commit is contained in:
parent
5aaf2e8873
commit
3d4874dc34
@ -209,7 +209,7 @@ Field types are represented as structured objects:
|
|||||||
type FieldType = {
|
type FieldType = {
|
||||||
name: string;
|
name: string;
|
||||||
isCollection: boolean;
|
isCollection: boolean;
|
||||||
isPolymorphic: boolean;
|
isCollectionOrScalar: boolean;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -237,11 +237,11 @@ When a field is annotated as a list of a single type, the schema object has an `
|
|||||||
|
|
||||||
We use the item type for field type name, adding `isCollection: true` to the field type.
|
We use the item type for field type name, adding `isCollection: true` to the field type.
|
||||||
|
|
||||||
##### Polymorphic Types
|
##### Collection or Scalar Types
|
||||||
|
|
||||||
When a field is annotated as a union of a type and list of that type, the schema object has an `anyOf` property, which holds a list of valid types for the union.
|
When a field is annotated as a union of a type and list of that type, the schema object has an `anyOf` property, which holds a list of valid types for the union.
|
||||||
|
|
||||||
After verifying that the union has two members (a type and list of the same type), we use the type for field type name, adding `isPolymorphic: true` to the field type.
|
After verifying that the union has two members (a type and list of the same type), we use the type for field type name, adding `isCollectionOrScalar: true` to the field type.
|
||||||
|
|
||||||
##### Optional Fields
|
##### Optional Fields
|
||||||
|
|
||||||
|
@ -808,7 +808,7 @@
|
|||||||
"clipFieldDescription": "Tokenizer and text_encoder submodels.",
|
"clipFieldDescription": "Tokenizer and text_encoder submodels.",
|
||||||
"collection": "Collection",
|
"collection": "Collection",
|
||||||
"collectionFieldType": "{{name}} Collection",
|
"collectionFieldType": "{{name}} Collection",
|
||||||
"polymorphicFieldType": "{{name}} Polymorphic",
|
"collectionOrScalarFieldType": "{{name}} Collection|Scalar",
|
||||||
"collectionDescription": "TODO",
|
"collectionDescription": "TODO",
|
||||||
"collectionItem": "Collection Item",
|
"collectionItem": "Collection Item",
|
||||||
"collectionItemDescription": "TODO",
|
"collectionItemDescription": "TODO",
|
||||||
@ -975,7 +975,7 @@
|
|||||||
"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}})",
|
"unsupportedAnyOfLength": "too many union members ({{count}})",
|
||||||
"unsupportedMismatchedUnion": "mismatched polymorphic type with members {{firstType}} and {{secondType}}",
|
"unsupportedMismatchedUnion": "mismatched CollectionOrScalar type with base types {{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.",
|
||||||
|
@ -54,13 +54,13 @@ const FieldHandle = (props: FieldHandleProps) => {
|
|||||||
const color = getFieldColor(type);
|
const color = getFieldColor(type);
|
||||||
const s: CSSProperties = {
|
const s: CSSProperties = {
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
type.isCollection || type.isPolymorphic
|
type.isCollection || type.isCollectionOrScalar
|
||||||
? colorTokenToCssVar('base.900')
|
? colorTokenToCssVar('base.900')
|
||||||
: color,
|
: color,
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
width: '1rem',
|
width: '1rem',
|
||||||
height: '1rem',
|
height: '1rem',
|
||||||
borderWidth: type.isCollection || type.isPolymorphic ? 4 : 0,
|
borderWidth: type.isCollection || type.isCollectionOrScalar ? 4 : 0,
|
||||||
borderStyle: 'solid',
|
borderStyle: 'solid',
|
||||||
borderColor: color,
|
borderColor: color,
|
||||||
borderRadius: isModelType ? 4 : '100%',
|
borderRadius: isModelType ? 4 : '100%',
|
||||||
|
@ -25,7 +25,7 @@ export const useAnyOrDirectInputFieldNames = (nodeId: string) => {
|
|||||||
const fields = map(nodeTemplate.inputs).filter(
|
const fields = map(nodeTemplate.inputs).filter(
|
||||||
(field) =>
|
(field) =>
|
||||||
(['any', 'direct'].includes(field.input) ||
|
(['any', 'direct'].includes(field.input) ||
|
||||||
field.type.isPolymorphic) &&
|
field.type.isCollectionOrScalar) &&
|
||||||
keys(TEMPLATE_BUILDER_MAP).includes(field.type.name)
|
keys(TEMPLATE_BUILDER_MAP).includes(field.type.name)
|
||||||
);
|
);
|
||||||
return getSortedFilteredFieldNames(fields);
|
return getSortedFilteredFieldNames(fields);
|
||||||
|
@ -26,7 +26,8 @@ export const useConnectionInputFieldNames = (nodeId: string) => {
|
|||||||
// get the visible fields
|
// get the visible fields
|
||||||
const fields = map(nodeTemplate.inputs).filter(
|
const fields = map(nodeTemplate.inputs).filter(
|
||||||
(field) =>
|
(field) =>
|
||||||
(field.input === 'connection' && !field.type.isPolymorphic) ||
|
(field.input === 'connection' &&
|
||||||
|
!field.type.isCollectionOrScalar) ||
|
||||||
!keys(TEMPLATE_BUILDER_MAP).includes(field.type.name)
|
!keys(TEMPLATE_BUILDER_MAP).includes(field.type.name)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -13,8 +13,8 @@ export const useFieldTypeName = (fieldType?: FieldType): string => {
|
|||||||
if (fieldType.isCollection) {
|
if (fieldType.isCollection) {
|
||||||
return t('nodes.collectionFieldType', { name });
|
return t('nodes.collectionFieldType', { name });
|
||||||
}
|
}
|
||||||
if (fieldType.isPolymorphic) {
|
if (fieldType.isCollectionOrScalar) {
|
||||||
return t('nodes.polymorphicFieldType', { name });
|
return t('nodes.collectionOrScalarFieldType', { name });
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}, [fieldType, t]);
|
}, [fieldType, t]);
|
||||||
|
@ -29,8 +29,8 @@ export const validateSourceAndTargetTypes = (
|
|||||||
* Connection types must be the same for a connection, with exceptions:
|
* Connection types must be the same for a connection, with exceptions:
|
||||||
* - CollectionItem can connect to any non-Collection
|
* - CollectionItem can connect to any non-Collection
|
||||||
* - Non-Collections can connect to CollectionItem
|
* - Non-Collections can connect to CollectionItem
|
||||||
* - Anything (non-Collections, Collections, Polymorphics) can connect to Polymorphics of the same base type
|
* - Anything (non-Collections, Collections, CollectionOrScalar) can connect to CollectionOrScalar of the same base type
|
||||||
* - Generic Collection can connect to any other Collection or Polymorphic
|
* - Generic Collection can connect to any other Collection or CollectionOrScalar
|
||||||
* - Any Collection can connect to a Generic Collection
|
* - Any Collection can connect to a Generic Collection
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -40,23 +40,23 @@ export const validateSourceAndTargetTypes = (
|
|||||||
const isNonCollectionToCollectionItem =
|
const isNonCollectionToCollectionItem =
|
||||||
targetType.name === 'CollectionItemField' &&
|
targetType.name === 'CollectionItemField' &&
|
||||||
!sourceType.isCollection &&
|
!sourceType.isCollection &&
|
||||||
!sourceType.isPolymorphic;
|
!sourceType.isCollectionOrScalar;
|
||||||
|
|
||||||
const isAnythingToPolymorphicOfSameBaseType =
|
const isAnythingToCollectionOrScalarOfSameBaseType =
|
||||||
targetType.isPolymorphic && sourceType.name === targetType.name;
|
targetType.isCollectionOrScalar && sourceType.name === targetType.name;
|
||||||
|
|
||||||
const isGenericCollectionToAnyCollectionOrPolymorphic =
|
const isGenericCollectionToAnyCollectionOrCollectionOrScalar =
|
||||||
sourceType.name === 'CollectionField' &&
|
sourceType.name === 'CollectionField' &&
|
||||||
(targetType.isCollection || targetType.isPolymorphic);
|
(targetType.isCollection || targetType.isCollectionOrScalar);
|
||||||
|
|
||||||
const isCollectionToGenericCollection =
|
const isCollectionToGenericCollection =
|
||||||
targetType.name === 'CollectionField' && sourceType.isCollection;
|
targetType.name === 'CollectionField' && sourceType.isCollection;
|
||||||
|
|
||||||
const areBothTypesSingle =
|
const areBothTypesSingle =
|
||||||
!sourceType.isCollection &&
|
!sourceType.isCollection &&
|
||||||
!sourceType.isPolymorphic &&
|
!sourceType.isCollectionOrScalar &&
|
||||||
!targetType.isCollection &&
|
!targetType.isCollection &&
|
||||||
!targetType.isPolymorphic;
|
!targetType.isCollectionOrScalar;
|
||||||
|
|
||||||
const isIntToFloat =
|
const isIntToFloat =
|
||||||
areBothTypesSingle &&
|
areBothTypesSingle &&
|
||||||
@ -74,8 +74,8 @@ export const validateSourceAndTargetTypes = (
|
|||||||
return (
|
return (
|
||||||
isCollectionItemToNonCollection ||
|
isCollectionItemToNonCollection ||
|
||||||
isNonCollectionToCollectionItem ||
|
isNonCollectionToCollectionItem ||
|
||||||
isAnythingToPolymorphicOfSameBaseType ||
|
isAnythingToCollectionOrScalarOfSameBaseType ||
|
||||||
isGenericCollectionToAnyCollectionOrPolymorphic ||
|
isGenericCollectionToAnyCollectionOrCollectionOrScalar ||
|
||||||
isCollectionToGenericCollection ||
|
isCollectionToGenericCollection ||
|
||||||
isIntToFloat ||
|
isIntToFloat ||
|
||||||
isIntOrFloatToString ||
|
isIntOrFloatToString ||
|
||||||
|
@ -84,7 +84,7 @@ export type FieldOutputTemplateBase = z.infer<typeof zFieldOutputTemplateBase>;
|
|||||||
|
|
||||||
export const zFieldTypeBase = z.object({
|
export const zFieldTypeBase = z.object({
|
||||||
isCollection: z.boolean(),
|
isCollection: z.boolean(),
|
||||||
isPolymorphic: z.boolean(),
|
isCollectionOrScalar: z.boolean(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const zFieldIdentifier = z.object({
|
export const zFieldIdentifier = z.object({
|
||||||
|
@ -7,118 +7,146 @@ import { FieldTypeV1 } from './workflowV1';
|
|||||||
const FIELD_TYPE_V1_TO_STATEFUL_FIELD_TYPE_V2: {
|
const FIELD_TYPE_V1_TO_STATEFUL_FIELD_TYPE_V2: {
|
||||||
[key in FieldTypeV1]?: StatefulFieldType;
|
[key in FieldTypeV1]?: StatefulFieldType;
|
||||||
} = {
|
} = {
|
||||||
BoardField: { name: 'BoardField', isCollection: false, isPolymorphic: false },
|
BoardField: {
|
||||||
boolean: { name: 'BooleanField', isCollection: false, isPolymorphic: false },
|
name: 'BoardField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
|
boolean: {
|
||||||
|
name: 'BooleanField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
BooleanCollection: {
|
BooleanCollection: {
|
||||||
name: 'BooleanField',
|
name: 'BooleanField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
BooleanPolymorphic: {
|
BooleanPolymorphic: {
|
||||||
name: 'BooleanField',
|
name: 'BooleanField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
|
},
|
||||||
|
ColorField: {
|
||||||
|
name: 'ColorField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ColorField: { name: 'ColorField', isCollection: false, isPolymorphic: false },
|
|
||||||
ColorCollection: {
|
ColorCollection: {
|
||||||
name: 'ColorField',
|
name: 'ColorField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ColorPolymorphic: {
|
ColorPolymorphic: {
|
||||||
name: 'ColorField',
|
name: 'ColorField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
ControlNetModelField: {
|
ControlNetModelField: {
|
||||||
name: 'ControlNetModelField',
|
name: 'ControlNetModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
|
enum: { name: 'EnumField', isCollection: false, isCollectionOrScalar: false },
|
||||||
|
float: {
|
||||||
|
name: 'FloatField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
enum: { name: 'EnumField', isCollection: false, isPolymorphic: false },
|
|
||||||
float: { name: 'FloatField', isCollection: false, isPolymorphic: false },
|
|
||||||
FloatCollection: {
|
FloatCollection: {
|
||||||
name: 'FloatField',
|
name: 'FloatField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
FloatPolymorphic: {
|
FloatPolymorphic: {
|
||||||
name: 'FloatField',
|
name: 'FloatField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
ImageCollection: {
|
ImageCollection: {
|
||||||
name: 'ImageField',
|
name: 'ImageField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
|
ImageField: {
|
||||||
|
name: 'ImageField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ImageField: { name: 'ImageField', isCollection: false, isPolymorphic: false },
|
|
||||||
ImagePolymorphic: {
|
ImagePolymorphic: {
|
||||||
name: 'ImageField',
|
name: 'ImageField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
|
},
|
||||||
|
integer: {
|
||||||
|
name: 'IntegerField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
integer: { name: 'IntegerField', isCollection: false, isPolymorphic: false },
|
|
||||||
IntegerCollection: {
|
IntegerCollection: {
|
||||||
name: 'IntegerField',
|
name: 'IntegerField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
IntegerPolymorphic: {
|
IntegerPolymorphic: {
|
||||||
name: 'IntegerField',
|
name: 'IntegerField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
IPAdapterModelField: {
|
IPAdapterModelField: {
|
||||||
name: 'IPAdapterModelField',
|
name: 'IPAdapterModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
LoRAModelField: {
|
LoRAModelField: {
|
||||||
name: 'LoRAModelField',
|
name: 'LoRAModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
MainModelField: {
|
MainModelField: {
|
||||||
name: 'MainModelField',
|
name: 'MainModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
Scheduler: {
|
Scheduler: {
|
||||||
name: 'SchedulerField',
|
name: 'SchedulerField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
SDXLMainModelField: {
|
SDXLMainModelField: {
|
||||||
name: 'SDXLMainModelField',
|
name: 'SDXLMainModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
SDXLRefinerModelField: {
|
SDXLRefinerModelField: {
|
||||||
name: 'SDXLRefinerModelField',
|
name: 'SDXLRefinerModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
|
string: {
|
||||||
|
name: 'StringField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
string: { name: 'StringField', isCollection: false, isPolymorphic: false },
|
|
||||||
StringCollection: {
|
StringCollection: {
|
||||||
name: 'StringField',
|
name: 'StringField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
StringPolymorphic: {
|
StringPolymorphic: {
|
||||||
name: 'StringField',
|
name: 'StringField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
T2IAdapterModelField: {
|
T2IAdapterModelField: {
|
||||||
name: 'T2IAdapterModelField',
|
name: 'T2IAdapterModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
VaeModelField: {
|
VaeModelField: {
|
||||||
name: 'VAEModelField',
|
name: 'VAEModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -138,130 +166,142 @@ const FIELD_TYPE_V1_TO_STATEFUL_FIELD_TYPE_V2: {
|
|||||||
const FIELD_TYPE_V1_TO_STATELESS_FIELD_TYPE_V2: {
|
const FIELD_TYPE_V1_TO_STATELESS_FIELD_TYPE_V2: {
|
||||||
[key in FieldTypeV1]?: FieldType;
|
[key in FieldTypeV1]?: FieldType;
|
||||||
} = {
|
} = {
|
||||||
Any: { name: 'AnyField', isCollection: false, isPolymorphic: false },
|
Any: { name: 'AnyField', isCollection: false, isCollectionOrScalar: false },
|
||||||
ClipField: { name: 'ClipField', isCollection: false, isPolymorphic: false },
|
ClipField: {
|
||||||
|
name: 'ClipField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
Collection: {
|
Collection: {
|
||||||
name: 'CollectionField',
|
name: 'CollectionField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
CollectionItem: {
|
CollectionItem: {
|
||||||
name: 'CollectionItemField',
|
name: 'CollectionItemField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ConditioningCollection: {
|
ConditioningCollection: {
|
||||||
name: 'ConditioningField',
|
name: 'ConditioningField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ConditioningField: {
|
ConditioningField: {
|
||||||
name: 'ConditioningField',
|
name: 'ConditioningField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ConditioningPolymorphic: {
|
ConditioningPolymorphic: {
|
||||||
name: 'ConditioningField',
|
name: 'ConditioningField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
ControlCollection: {
|
ControlCollection: {
|
||||||
name: 'ControlField',
|
name: 'ControlField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ControlField: {
|
ControlField: {
|
||||||
name: 'ControlField',
|
name: 'ControlField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
ControlPolymorphic: {
|
ControlPolymorphic: {
|
||||||
name: 'ControlField',
|
name: 'ControlField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
DenoiseMaskField: {
|
DenoiseMaskField: {
|
||||||
name: 'DenoiseMaskField',
|
name: 'DenoiseMaskField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
IPAdapterField: {
|
IPAdapterField: {
|
||||||
name: 'IPAdapterField',
|
name: 'IPAdapterField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
IPAdapterCollection: {
|
IPAdapterCollection: {
|
||||||
name: 'IPAdapterField',
|
name: 'IPAdapterField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
IPAdapterPolymorphic: {
|
IPAdapterPolymorphic: {
|
||||||
name: 'IPAdapterField',
|
name: 'IPAdapterField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
LatentsField: {
|
LatentsField: {
|
||||||
name: 'LatentsField',
|
name: 'LatentsField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
LatentsCollection: {
|
LatentsCollection: {
|
||||||
name: 'LatentsField',
|
name: 'LatentsField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
LatentsPolymorphic: {
|
LatentsPolymorphic: {
|
||||||
name: 'LatentsField',
|
name: 'LatentsField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
MetadataField: {
|
MetadataField: {
|
||||||
name: 'MetadataField',
|
name: 'MetadataField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
MetadataCollection: {
|
MetadataCollection: {
|
||||||
name: 'MetadataField',
|
name: 'MetadataField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
MetadataItemField: {
|
MetadataItemField: {
|
||||||
name: 'MetadataItemField',
|
name: 'MetadataItemField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
MetadataItemCollection: {
|
MetadataItemCollection: {
|
||||||
name: 'MetadataItemField',
|
name: 'MetadataItemField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
MetadataItemPolymorphic: {
|
MetadataItemPolymorphic: {
|
||||||
name: 'MetadataItemField',
|
name: 'MetadataItemField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
},
|
},
|
||||||
ONNXModelField: {
|
ONNXModelField: {
|
||||||
name: 'ONNXModelField',
|
name: 'ONNXModelField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
T2IAdapterField: {
|
T2IAdapterField: {
|
||||||
name: 'T2IAdapterField',
|
name: 'T2IAdapterField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
T2IAdapterCollection: {
|
T2IAdapterCollection: {
|
||||||
name: 'T2IAdapterField',
|
name: 'T2IAdapterField',
|
||||||
isCollection: true,
|
isCollection: true,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
T2IAdapterPolymorphic: {
|
T2IAdapterPolymorphic: {
|
||||||
name: 'T2IAdapterField',
|
name: 'T2IAdapterField',
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true,
|
isCollectionOrScalar: true,
|
||||||
|
},
|
||||||
|
UNetField: {
|
||||||
|
name: 'UNetField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
|
},
|
||||||
|
VaeField: {
|
||||||
|
name: 'VaeField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
},
|
},
|
||||||
UNetField: { name: 'UNetField', isCollection: false, isPolymorphic: false },
|
|
||||||
VaeField: { name: 'VaeField', isCollection: false, isPolymorphic: false },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const FIELD_TYPE_V1_TO_FIELD_TYPE_V2_MAPPING = {
|
export const FIELD_TYPE_V1_TO_FIELD_TYPE_V2_MAPPING = {
|
||||||
|
@ -30,7 +30,7 @@ export const addControlNetToLinearGraph = (
|
|||||||
const controlNetMetadata: CoreMetadataInvocation['controlnets'] = [];
|
const controlNetMetadata: CoreMetadataInvocation['controlnets'] = [];
|
||||||
|
|
||||||
if (validControlNets.length) {
|
if (validControlNets.length) {
|
||||||
// Even though denoise_latents' control input is polymorphic, keep it simple and always use a collect
|
// Even though denoise_latents' control input is collection or scalar, keep it simple and always use a collect
|
||||||
const controlNetIterateNode: CollectInvocation = {
|
const controlNetIterateNode: CollectInvocation = {
|
||||||
id: CONTROL_NET_COLLECT,
|
id: CONTROL_NET_COLLECT,
|
||||||
type: 'collect',
|
type: 'collect',
|
||||||
|
@ -24,7 +24,7 @@ export const addIPAdapterToLinearGraph = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (validIPAdapters.length) {
|
if (validIPAdapters.length) {
|
||||||
// Even though denoise_latents' control input is polymorphic, keep it simple and always use a collect
|
// Even though denoise_latents' ip adapter input is collection or scalar, keep it simple and always use a collect
|
||||||
const ipAdapterCollectNode: CollectInvocation = {
|
const ipAdapterCollectNode: CollectInvocation = {
|
||||||
id: IP_ADAPTER_COLLECT,
|
id: IP_ADAPTER_COLLECT,
|
||||||
type: 'collect',
|
type: 'collect',
|
||||||
|
@ -24,7 +24,7 @@ export const addT2IAdaptersToLinearGraph = (
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (validT2IAdapters.length) {
|
if (validT2IAdapters.length) {
|
||||||
// Even though denoise_latents' control input is polymorphic, keep it simple and always use a collect
|
// Even though denoise_latents' t2i adapter input is collection or scalar, keep it simple and always use a collect
|
||||||
const t2iAdapterCollectNode: CollectInvocation = {
|
const t2iAdapterCollectNode: CollectInvocation = {
|
||||||
id: T2I_ADAPTER_COLLECT,
|
id: T2I_ADAPTER_COLLECT,
|
||||||
type: 'collect',
|
type: 'collect',
|
||||||
|
@ -31,15 +31,19 @@ type FieldInputTemplateBuilder<T extends FieldInputTemplate = any> = // valid `a
|
|||||||
schemaObject: InvocationFieldSchema;
|
schemaObject: InvocationFieldSchema;
|
||||||
baseField: Omit<T, 'type'>;
|
baseField: Omit<T, 'type'>;
|
||||||
isCollection: boolean;
|
isCollection: boolean;
|
||||||
isPolymorphic: boolean;
|
isCollectionOrScalar: boolean;
|
||||||
}) => T;
|
}) => T;
|
||||||
|
|
||||||
const buildIntegerFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildIntegerFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
IntegerFieldInputTemplate
|
IntegerFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: IntegerFieldInputTemplate = {
|
const template: IntegerFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'IntegerField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'IntegerField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? 0,
|
default: schemaObject.default ?? 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -74,10 +78,14 @@ const buildIntegerFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildFloatFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildFloatFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
FloatFieldInputTemplate
|
FloatFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: FloatFieldInputTemplate = {
|
const template: FloatFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'FloatField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'FloatField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? 0,
|
default: schemaObject.default ?? 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -112,10 +120,14 @@ const buildFloatFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildStringFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildStringFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
StringFieldInputTemplate
|
StringFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: StringFieldInputTemplate = {
|
const template: StringFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'StringField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'StringField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? '',
|
default: schemaObject.default ?? '',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -132,10 +144,14 @@ const buildStringFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildBooleanFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildBooleanFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
BooleanFieldInputTemplate
|
BooleanFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: BooleanFieldInputTemplate = {
|
const template: BooleanFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'BooleanField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'BooleanField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? false,
|
default: schemaObject.default ?? false,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -144,10 +160,14 @@ const buildBooleanFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
MainModelFieldInputTemplate
|
MainModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: MainModelFieldInputTemplate = {
|
const template: MainModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'MainModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'MainModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -156,10 +176,14 @@ const buildMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildSDXLMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildSDXLMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
SDXLMainModelFieldInputTemplate
|
SDXLMainModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: SDXLMainModelFieldInputTemplate = {
|
const template: SDXLMainModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'SDXLMainModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'SDXLMainModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -168,10 +192,14 @@ const buildSDXLMainModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildRefinerModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildRefinerModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
SDXLRefinerModelFieldInputTemplate
|
SDXLRefinerModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: SDXLRefinerModelFieldInputTemplate = {
|
const template: SDXLRefinerModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'SDXLRefinerModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'SDXLRefinerModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -180,10 +208,14 @@ const buildRefinerModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildVAEModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildVAEModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
VAEModelFieldInputTemplate
|
VAEModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: VAEModelFieldInputTemplate = {
|
const template: VAEModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'VAEModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'VAEModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -192,10 +224,14 @@ const buildVAEModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildLoRAModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildLoRAModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
LoRAModelFieldInputTemplate
|
LoRAModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: LoRAModelFieldInputTemplate = {
|
const template: LoRAModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'LoRAModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'LoRAModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -204,10 +240,14 @@ const buildLoRAModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildControlNetModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildControlNetModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
ControlNetModelFieldInputTemplate
|
ControlNetModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: ControlNetModelFieldInputTemplate = {
|
const template: ControlNetModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'ControlNetModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'ControlNetModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -216,10 +256,14 @@ const buildControlNetModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildIPAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildIPAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
IPAdapterModelFieldInputTemplate
|
IPAdapterModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: IPAdapterModelFieldInputTemplate = {
|
const template: IPAdapterModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'IPAdapterModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'IPAdapterModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,10 +272,14 @@ const buildIPAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildT2IAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildT2IAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
T2IAdapterModelFieldInputTemplate
|
T2IAdapterModelFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: T2IAdapterModelFieldInputTemplate = {
|
const template: T2IAdapterModelFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'T2IAdapterModelField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'T2IAdapterModelField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -240,10 +288,14 @@ const buildT2IAdapterModelFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildBoardFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildBoardFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
BoardFieldInputTemplate
|
BoardFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: BoardFieldInputTemplate = {
|
const template: BoardFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'BoardField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'BoardField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -252,10 +304,14 @@ const buildBoardFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildImageFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildImageFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
ImageFieldInputTemplate
|
ImageFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: ImageFieldInputTemplate = {
|
const template: ImageFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'ImageField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'ImageField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? undefined,
|
default: schemaObject.default ?? undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -264,11 +320,15 @@ const buildImageFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildEnumFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildEnumFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
EnumFieldInputTemplate
|
EnumFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const options = schemaObject.enum ?? [];
|
const options = schemaObject.enum ?? [];
|
||||||
const template: EnumFieldInputTemplate = {
|
const template: EnumFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'EnumField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'EnumField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
options,
|
options,
|
||||||
ui_choice_labels: schemaObject.ui_choice_labels,
|
ui_choice_labels: schemaObject.ui_choice_labels,
|
||||||
default: schemaObject.default ?? options[0],
|
default: schemaObject.default ?? options[0],
|
||||||
@ -279,10 +339,14 @@ const buildEnumFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildColorFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildColorFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
ColorFieldInputTemplate
|
ColorFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: ColorFieldInputTemplate = {
|
const template: ColorFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'ColorField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'ColorField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? { r: 127, g: 127, b: 127, a: 255 },
|
default: schemaObject.default ?? { r: 127, g: 127, b: 127, a: 255 },
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -291,10 +355,14 @@ const buildColorFieldInputTemplate: FieldInputTemplateBuilder<
|
|||||||
|
|
||||||
const buildSchedulerFieldInputTemplate: FieldInputTemplateBuilder<
|
const buildSchedulerFieldInputTemplate: FieldInputTemplateBuilder<
|
||||||
SchedulerFieldInputTemplate
|
SchedulerFieldInputTemplate
|
||||||
> = ({ schemaObject, baseField, isCollection, isPolymorphic }) => {
|
> = ({ schemaObject, baseField, isCollection, isCollectionOrScalar }) => {
|
||||||
const template: SchedulerFieldInputTemplate = {
|
const template: SchedulerFieldInputTemplate = {
|
||||||
...baseField,
|
...baseField,
|
||||||
type: { name: 'SchedulerField', isCollection, isPolymorphic },
|
type: {
|
||||||
|
name: 'SchedulerField',
|
||||||
|
isCollection,
|
||||||
|
isCollectionOrScalar,
|
||||||
|
},
|
||||||
default: schemaObject.default ?? 'euler',
|
default: schemaObject.default ?? 'euler',
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -361,7 +429,7 @@ export const buildFieldInputTemplate = (
|
|||||||
schemaObject: fieldSchema,
|
schemaObject: fieldSchema,
|
||||||
baseField,
|
baseField,
|
||||||
isCollection: fieldType.isCollection,
|
isCollection: fieldType.isCollection,
|
||||||
isPolymorphic: fieldType.isPolymorphic,
|
isCollectionOrScalar: fieldType.isCollectionOrScalar,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name: ui_type,
|
name: ui_type,
|
||||||
isCollection: isCollectionFieldType(ui_type),
|
isCollection: isCollectionFieldType(ui_type),
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else if (schemaObject.anyOf) {
|
} else if (schemaObject.anyOf) {
|
||||||
@ -103,14 +103,14 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
} else if (isSchemaObject(filteredAnyOf[0])) {
|
} else if (isSchemaObject(filteredAnyOf[0])) {
|
||||||
return parseFieldType(filteredAnyOf[0]);
|
return parseFieldType(filteredAnyOf[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Handle Polymorphic inputs, eg string | string[]. In OpenAPI, this is:
|
* Handle CollectionOrScalar inputs, eg string | string[]. In OpenAPI, this is:
|
||||||
* - an `anyOf` with two items
|
* - an `anyOf` with two items
|
||||||
* - one is an `ArraySchemaObject` with a single `SchemaObject or ReferenceObject` of type T in its `items`
|
* - one is an `ArraySchemaObject` with a single `SchemaObject or ReferenceObject` of type T in its `items`
|
||||||
* - the other is a `SchemaObject` or `ReferenceObject` of type T
|
* - the other is a `SchemaObject` or `ReferenceObject` of type T
|
||||||
@ -163,7 +163,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name: OPENAPI_TO_FIELD_TYPE_MAP[firstType] ?? firstType,
|
name: OPENAPI_TO_FIELD_TYPE_MAP[firstType] ?? firstType,
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: true, // <-- don't forget, polymorphic!
|
isCollectionOrScalar: true, // <-- don't forget, CollectionOrScalar type!
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,11 @@ export const parseFieldType = (
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (schemaObject.enum) {
|
} else if (schemaObject.enum) {
|
||||||
return { name: 'EnumField', isCollection: false, isPolymorphic: false };
|
return {
|
||||||
|
name: 'EnumField',
|
||||||
|
isCollection: false,
|
||||||
|
isCollectionOrScalar: false,
|
||||||
|
};
|
||||||
} else if (schemaObject.type) {
|
} else if (schemaObject.type) {
|
||||||
if (schemaObject.type === 'array') {
|
if (schemaObject.type === 'array') {
|
||||||
// We need to get the type of the items
|
// We need to get the type of the items
|
||||||
@ -201,7 +205,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: true, // <-- don't forget, collection!
|
isCollection: true, // <-- don't forget, collection!
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +219,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: true, // <-- don't forget, collection!
|
isCollection: true, // <-- don't forget, collection!
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
} else if (!isArray(schemaObject.type)) {
|
} else if (!isArray(schemaObject.type)) {
|
||||||
// This is an OpenAPI primitive - 'null', 'object', 'array', 'integer', 'number', 'string', 'boolean'
|
// This is an OpenAPI primitive - 'null', 'object', 'array', 'integer', 'number', 'string', 'boolean'
|
||||||
@ -231,7 +235,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +249,7 @@ export const parseFieldType = (
|
|||||||
return {
|
return {
|
||||||
name,
|
name,
|
||||||
isCollection: false,
|
isCollection: false,
|
||||||
isPolymorphic: false,
|
isCollectionOrScalar: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
throw new FieldTypeParseError(t('nodes.unableToParseFieldType'));
|
throw new FieldTypeParseError(t('nodes.unableToParseFieldType'));
|
||||||
|
Loading…
Reference in New Issue
Block a user