mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
tidy(ui): clean up unused code 2
types and schemas
This commit is contained in:
parent
c94d607089
commit
7bd9bf3ba5
@ -7,14 +7,9 @@ import type {
|
|||||||
ImageField,
|
ImageField,
|
||||||
ImageOutput,
|
ImageOutput,
|
||||||
IPAdapterField,
|
IPAdapterField,
|
||||||
ModelInfo,
|
|
||||||
ModelType,
|
|
||||||
ProgressImage,
|
ProgressImage,
|
||||||
SchedulerField,
|
SchedulerField,
|
||||||
SDXLRefinerModelField,
|
|
||||||
SubModelType,
|
|
||||||
T2IAdapterField,
|
T2IAdapterField,
|
||||||
VAEField,
|
|
||||||
} from 'features/nodes/types/common';
|
} from 'features/nodes/types/common';
|
||||||
import type { S } from 'services/api/types';
|
import type { S } from 'services/api/types';
|
||||||
import type { Equals, Extends } from 'tsafe';
|
import type { Equals, Extends } from 'tsafe';
|
||||||
@ -32,23 +27,13 @@ describe('Common types', () => {
|
|||||||
test('BoardField', () => assert<Equals<BoardField, S['BoardField']>>());
|
test('BoardField', () => assert<Equals<BoardField, S['BoardField']>>());
|
||||||
test('ColorField', () => assert<Equals<ColorField, S['ColorField']>>());
|
test('ColorField', () => assert<Equals<ColorField, S['ColorField']>>());
|
||||||
test('SchedulerField', () => assert<Equals<SchedulerField, NonNullable<S['SchedulerInvocation']['scheduler']>>>());
|
test('SchedulerField', () => assert<Equals<SchedulerField, NonNullable<S['SchedulerInvocation']['scheduler']>>>());
|
||||||
// test('MainModelField', () => assert<Equals<MainModelField, S['MainModelField']>>());
|
|
||||||
test('SDXLRefinerModelField', () => assert<Equals<SDXLRefinerModelField, S['MainModelField']>>());
|
|
||||||
test('VAEField', () => assert<Extends<S['VaeField'], VAEField>>());
|
|
||||||
test('ControlField', () => assert<Equals<ControlField, S['ControlField']>>());
|
test('ControlField', () => assert<Equals<ControlField, S['ControlField']>>());
|
||||||
// @ts-expect-error TODO(psyche): fix types
|
// @ts-expect-error TODO(psyche): fix types
|
||||||
test('IPAdapterField', () => assert<Extends<IPAdapterField, S['IPAdapterField']>>());
|
test('IPAdapterField', () => assert<Extends<IPAdapterField, S['IPAdapterField']>>());
|
||||||
test('T2IAdapterField', () => assert<Equals<T2IAdapterField, S['T2IAdapterField']>>());
|
test('T2IAdapterField', () => assert<Equals<T2IAdapterField, S['T2IAdapterField']>>());
|
||||||
// test('LoRAModelField', () => assert<Equals<LoRAModelField, S['LoRAModelField']>>());
|
|
||||||
// test('ControlNetModelField', () => assert<Equals<ControlNetModelField, S['ControlNetModelField']>>());
|
|
||||||
// test('IPAdapterModelField', () => assert<Equals<IPAdapterModelField, S['IPAdapterModelField']>>());
|
|
||||||
// test('T2IAdapterModelField', () => assert<Equals<T2IAdapterModelField, S['T2IAdapterModelField']>>());
|
|
||||||
|
|
||||||
// Model component types
|
// Model component types
|
||||||
test('BaseModel', () => assert<Equals<BaseModel, S['BaseModelType']>>());
|
test('BaseModel', () => assert<Equals<BaseModel, S['BaseModelType']>>());
|
||||||
test('ModelType', () => assert<Equals<ModelType, S['ModelType']>>());
|
|
||||||
test('SubModelType', () => assert<Equals<SubModelType, S['SubModelType']>>());
|
|
||||||
test('ModelInfo', () => assert<Equals<ModelInfo, S['ModelInfo']>>());
|
|
||||||
|
|
||||||
// Misc types
|
// Misc types
|
||||||
// @ts-expect-error TODO(psyche): There is no `ProgressImage` in the server types yet
|
// @ts-expect-error TODO(psyche): There is no `ProgressImage` in the server types yet
|
||||||
|
@ -64,7 +64,6 @@ export const zModelType = z.enum([
|
|||||||
'ip_adapter',
|
'ip_adapter',
|
||||||
'clip_vision',
|
'clip_vision',
|
||||||
't2i_adapter',
|
't2i_adapter',
|
||||||
'onnx', // TODO(psyche): Remove this when removed from backend
|
|
||||||
]);
|
]);
|
||||||
export const zModelName = z.string().min(3);
|
export const zModelName = z.string().min(3);
|
||||||
export const zModelIdentifier = z.object({
|
export const zModelIdentifier = z.object({
|
||||||
@ -80,49 +79,6 @@ export type BaseModel = z.infer<typeof zBaseModel>;
|
|||||||
export type ModelType = z.infer<typeof zModelType>;
|
export type ModelType = z.infer<typeof zModelType>;
|
||||||
export type ModelIdentifier = z.infer<typeof zModelIdentifier>;
|
export type ModelIdentifier = z.infer<typeof zModelIdentifier>;
|
||||||
export type ModelIdentifierWithBase = z.infer<typeof zModelIdentifierWithBase>;
|
export type ModelIdentifierWithBase = z.infer<typeof zModelIdentifierWithBase>;
|
||||||
export const zMainModelField = zModelIdentifierWithBase;
|
|
||||||
export type MainModelField = z.infer<typeof zMainModelField>;
|
|
||||||
|
|
||||||
export const zSDXLRefinerModelField = zModelIdentifier;
|
|
||||||
export type SDXLRefinerModelField = z.infer<typeof zSDXLRefinerModelField>;
|
|
||||||
|
|
||||||
export const zSubModelType = z.enum([
|
|
||||||
'unet',
|
|
||||||
'text_encoder',
|
|
||||||
'text_encoder_2',
|
|
||||||
'tokenizer',
|
|
||||||
'tokenizer_2',
|
|
||||||
'vae',
|
|
||||||
'vae_decoder',
|
|
||||||
'vae_encoder',
|
|
||||||
'scheduler',
|
|
||||||
'safety_checker',
|
|
||||||
]);
|
|
||||||
export type SubModelType = z.infer<typeof zSubModelType>;
|
|
||||||
|
|
||||||
export const zVAEModelField = zModelIdentifierWithBase;
|
|
||||||
|
|
||||||
const zModelInfo = zModelIdentifier.extend({
|
|
||||||
submodel_type: zSubModelType.nullish(),
|
|
||||||
});
|
|
||||||
export type ModelInfo = z.infer<typeof zModelInfo>;
|
|
||||||
|
|
||||||
export const zLoRAModelField = zModelIdentifierWithBase;
|
|
||||||
export type LoRAModelField = z.infer<typeof zLoRAModelField>;
|
|
||||||
|
|
||||||
export const zControlNetModelField = zModelIdentifierWithBase;
|
|
||||||
export type ControlNetModelField = z.infer<typeof zControlNetModelField>;
|
|
||||||
|
|
||||||
export const zIPAdapterModelField = zModelIdentifierWithBase;
|
|
||||||
export type IPAdapterModelField = z.infer<typeof zIPAdapterModelField>;
|
|
||||||
|
|
||||||
export const zT2IAdapterModelField = zModelIdentifierWithBase;
|
|
||||||
export type T2IAdapterModelField = z.infer<typeof zT2IAdapterModelField>;
|
|
||||||
|
|
||||||
export const zVAEField = z.object({
|
|
||||||
vae: zModelInfo,
|
|
||||||
});
|
|
||||||
export type VAEField = z.infer<typeof zVAEField>;
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region Control Adapters
|
// #region Control Adapters
|
||||||
|
@ -23,14 +23,6 @@ export const SHARED_NODE_PROPERTIES: Partial<Node> = {
|
|||||||
dragHandle: `.${DRAG_HANDLE_CLASSNAME}`,
|
dragHandle: `.${DRAG_HANDLE_CLASSNAME}`,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper for getting the kind of a field.
|
|
||||||
*/
|
|
||||||
export const KIND_MAP = {
|
|
||||||
input: 'inputs' as const,
|
|
||||||
output: 'outputs' as const,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model types' handles are rendered as squares in the UI.
|
* Model types' handles are rendered as squares in the UI.
|
||||||
*/
|
*/
|
||||||
|
@ -3,14 +3,9 @@ import { z } from 'zod';
|
|||||||
import {
|
import {
|
||||||
zBoardField,
|
zBoardField,
|
||||||
zColorField,
|
zColorField,
|
||||||
zControlNetModelField,
|
|
||||||
zImageField,
|
zImageField,
|
||||||
zIPAdapterModelField,
|
zModelIdentifierWithBase,
|
||||||
zLoRAModelField,
|
|
||||||
zMainModelField,
|
|
||||||
zSchedulerField,
|
zSchedulerField,
|
||||||
zT2IAdapterModelField,
|
|
||||||
zVAEModelField,
|
|
||||||
} from './common';
|
} from './common';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -313,7 +308,7 @@ export const isColorFieldInputTemplate = (val: unknown): val is ColorFieldInputT
|
|||||||
export const zMainModelFieldType = zFieldTypeBase.extend({
|
export const zMainModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('MainModelField'),
|
name: z.literal('MainModelField'),
|
||||||
});
|
});
|
||||||
export const zMainModelFieldValue = zMainModelField.optional();
|
export const zMainModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zMainModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zMainModelFieldValue,
|
value: zMainModelFieldValue,
|
||||||
});
|
});
|
||||||
@ -391,7 +386,7 @@ export const isSDXLRefinerModelFieldInputTemplate = (val: unknown): val is SDXLR
|
|||||||
export const zVAEModelFieldType = zFieldTypeBase.extend({
|
export const zVAEModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('VAEModelField'),
|
name: z.literal('VAEModelField'),
|
||||||
});
|
});
|
||||||
export const zVAEModelFieldValue = zVAEModelField.optional();
|
export const zVAEModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zVAEModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zVAEModelFieldValue,
|
value: zVAEModelFieldValue,
|
||||||
});
|
});
|
||||||
@ -417,7 +412,7 @@ export const isVAEModelFieldInputTemplate = (val: unknown): val is VAEModelField
|
|||||||
export const zLoRAModelFieldType = zFieldTypeBase.extend({
|
export const zLoRAModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('LoRAModelField'),
|
name: z.literal('LoRAModelField'),
|
||||||
});
|
});
|
||||||
export const zLoRAModelFieldValue = zLoRAModelField.optional();
|
export const zLoRAModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zLoRAModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zLoRAModelFieldValue,
|
value: zLoRAModelFieldValue,
|
||||||
});
|
});
|
||||||
@ -443,7 +438,7 @@ export const isLoRAModelFieldInputTemplate = (val: unknown): val is LoRAModelFie
|
|||||||
export const zControlNetModelFieldType = zFieldTypeBase.extend({
|
export const zControlNetModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('ControlNetModelField'),
|
name: z.literal('ControlNetModelField'),
|
||||||
});
|
});
|
||||||
export const zControlNetModelFieldValue = zControlNetModelField.optional();
|
export const zControlNetModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zControlNetModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zControlNetModelFieldValue,
|
value: zControlNetModelFieldValue,
|
||||||
});
|
});
|
||||||
@ -471,7 +466,7 @@ export const isControlNetModelFieldValue = (v: unknown): v is ControlNetModelFie
|
|||||||
export const zIPAdapterModelFieldType = zFieldTypeBase.extend({
|
export const zIPAdapterModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('IPAdapterModelField'),
|
name: z.literal('IPAdapterModelField'),
|
||||||
});
|
});
|
||||||
export const zIPAdapterModelFieldValue = zIPAdapterModelField.optional();
|
export const zIPAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zIPAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zIPAdapterModelFieldValue,
|
value: zIPAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
@ -499,7 +494,7 @@ export const isIPAdapterModelFieldValue = (val: unknown): val is IPAdapterModelF
|
|||||||
export const zT2IAdapterModelFieldType = zFieldTypeBase.extend({
|
export const zT2IAdapterModelFieldType = zFieldTypeBase.extend({
|
||||||
name: z.literal('T2IAdapterModelField'),
|
name: z.literal('T2IAdapterModelField'),
|
||||||
});
|
});
|
||||||
export const zT2IAdapterModelFieldValue = zT2IAdapterModelField.optional();
|
export const zT2IAdapterModelFieldValue = zModelIdentifierWithBase.optional();
|
||||||
export const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
export const zT2IAdapterModelFieldInputInstance = zFieldInputInstanceBase.extend({
|
||||||
value: zT2IAdapterModelFieldValue,
|
value: zT2IAdapterModelFieldValue,
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user