From 86a372b02f0736375702732191d935dfc0a14533 Mon Sep 17 00:00:00 2001 From: psychedelicious <4822129+psychedelicious@users.noreply.github.com> Date: Fri, 16 Feb 2024 21:57:30 +1100 Subject: [PATCH] refactor(ui): url builders for each router The MM2 router is at `api/v2/models`. URL builder utils make this a bit easier to manage. --- .../web/src/services/api/endpoints/appInfo.ts | 24 +++++--- .../web/src/services/api/endpoints/boards.ts | 20 +++++-- .../web/src/services/api/endpoints/images.ts | 56 ++++++++++++------- .../web/src/services/api/endpoints/models.ts | 53 +++++++++++------- .../web/src/services/api/endpoints/queue.ts | 40 +++++++------ .../src/services/api/endpoints/utilities.ts | 12 +++- .../src/services/api/endpoints/workflows.ts | 20 +++++-- .../frontend/web/src/services/api/index.ts | 5 +- .../frontend/web/src/services/api/schema.ts | 36 ++++++------ .../frontend/web/src/services/api/types.ts | 6 +- .../frontend/web/src/services/api/util.ts | 3 +- invokeai/frontend/web/vite.config.mts | 6 +- 12 files changed, 178 insertions(+), 103 deletions(-) diff --git a/invokeai/frontend/web/src/services/api/endpoints/appInfo.ts b/invokeai/frontend/web/src/services/api/endpoints/appInfo.ts index c0916f568e..a7efaafcc8 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/appInfo.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/appInfo.ts @@ -3,27 +3,35 @@ import type { OpenAPIV3_1 } from 'openapi-types'; import type { paths } from 'services/api/schema'; import type { AppConfig, AppDependencyVersions, AppVersion } from 'services/api/types'; -import { api } from '..'; +import { api, buildV1Url } from '..'; + +/** + * Builds an endpoint URL for the app router + * @example + * buildAppInfoUrl('some-path') + * // '/api/v1/app/some-path' + */ +const buildAppInfoUrl = (path: string = '') => buildV1Url(`app/${path}`); export const appInfoApi = api.injectEndpoints({ endpoints: (build) => ({ getAppVersion: build.query({ query: () => ({ - url: `app/version`, + url: buildAppInfoUrl('version'), method: 'GET', }), providesTags: ['FetchOnReconnect'], }), getAppDeps: build.query({ query: () => ({ - url: `app/app_deps`, + url: buildAppInfoUrl('app_deps'), method: 'GET', }), providesTags: ['FetchOnReconnect'], }), getAppConfig: build.query({ query: () => ({ - url: `app/config`, + url: buildAppInfoUrl('config'), method: 'GET', }), providesTags: ['FetchOnReconnect'], @@ -33,28 +41,28 @@ export const appInfoApi = api.injectEndpoints({ void >({ query: () => ({ - url: `app/invocation_cache/status`, + url: buildAppInfoUrl('invocation_cache/status'), method: 'GET', }), providesTags: ['InvocationCacheStatus', 'FetchOnReconnect'], }), clearInvocationCache: build.mutation({ query: () => ({ - url: `app/invocation_cache`, + url: buildAppInfoUrl('invocation_cache'), method: 'DELETE', }), invalidatesTags: ['InvocationCacheStatus'], }), enableInvocationCache: build.mutation({ query: () => ({ - url: `app/invocation_cache/enable`, + url: buildAppInfoUrl('invocation_cache/enable'), method: 'PUT', }), invalidatesTags: ['InvocationCacheStatus'], }), disableInvocationCache: build.mutation({ query: () => ({ - url: `app/invocation_cache/disable`, + url: buildAppInfoUrl('invocation_cache/disable'), method: 'PUT', }), invalidatesTags: ['InvocationCacheStatus'], diff --git a/invokeai/frontend/web/src/services/api/endpoints/boards.ts b/invokeai/frontend/web/src/services/api/endpoints/boards.ts index 6977a2bd53..8efda86737 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/boards.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/boards.ts @@ -9,7 +9,15 @@ import type { import { getListImagesUrl } from 'services/api/util'; import type { ApiTagDescription } from '..'; -import { api, LIST_TAG } from '..'; +import { api, buildV1Url, LIST_TAG } from '..'; + +/** + * Builds an endpoint URL for the boards router + * @example + * buildBoardsUrl('some-path') + * // '/api/v1/boards/some-path' + */ +export const buildBoardsUrl = (path: string = '') => buildV1Url(`boards/${path}`); export const boardsApi = api.injectEndpoints({ endpoints: (build) => ({ @@ -17,7 +25,7 @@ export const boardsApi = api.injectEndpoints({ * Boards Queries */ listBoards: build.query({ - query: (arg) => ({ url: 'boards/', params: arg }), + query: (arg) => ({ url: buildBoardsUrl(), params: arg }), providesTags: (result) => { // any list of boards const tags: ApiTagDescription[] = [{ type: 'Board', id: LIST_TAG }, 'FetchOnReconnect']; @@ -38,7 +46,7 @@ export const boardsApi = api.injectEndpoints({ listAllBoards: build.query, void>({ query: () => ({ - url: 'boards/', + url: buildBoardsUrl(), params: { all: true }, }), providesTags: (result) => { @@ -61,7 +69,7 @@ export const boardsApi = api.injectEndpoints({ listAllImageNamesForBoard: build.query, string>({ query: (board_id) => ({ - url: `boards/${board_id}/image_names`, + url: buildBoardsUrl(`${board_id}/image_names`), }), providesTags: (result, error, arg) => [{ type: 'ImageNameList', id: arg }, 'FetchOnReconnect'], keepUnusedDataFor: 0, @@ -107,7 +115,7 @@ export const boardsApi = api.injectEndpoints({ createBoard: build.mutation({ query: (board_name) => ({ - url: `boards/`, + url: buildBoardsUrl(), method: 'POST', params: { board_name }, }), @@ -116,7 +124,7 @@ export const boardsApi = api.injectEndpoints({ updateBoard: build.mutation({ query: ({ board_id, changes }) => ({ - url: `boards/${board_id}`, + url: buildBoardsUrl(board_id), method: 'PATCH', body: changes, }), diff --git a/invokeai/frontend/web/src/services/api/endpoints/images.ts b/invokeai/frontend/web/src/services/api/endpoints/images.ts index 181c8d23fc..49eb28390f 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/images.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/images.ts @@ -26,8 +26,24 @@ import { } from 'services/api/util'; import type { ApiTagDescription } from '..'; -import { api, LIST_TAG } from '..'; -import { boardsApi } from './boards'; +import { api, buildV1Url, LIST_TAG } from '..'; +import { boardsApi, buildBoardsUrl } from './boards'; + +/** + * Builds an endpoint URL for the images router + * @example + * buildImagesUrl('some-path') + * // '/api/v1/images/some-path' + */ +const buildImagesUrl = (path: string = '') => buildV1Url(`images/${path}`); + +/** + * Builds an endpoint URL for the board_images router + * @example + * buildBoardImagesUrl('some-path') + * // '/api/v1/board_images/some-path' + */ +const buildBoardImagesUrl = (path: string = '') => buildV1Url(`board_images/${path}`); export const imagesApi = api.injectEndpoints({ endpoints: (build) => ({ @@ -90,20 +106,20 @@ export const imagesApi = api.injectEndpoints({ keepUnusedDataFor: 86400, }), getIntermediatesCount: build.query({ - query: () => ({ url: 'images/intermediates' }), + query: () => ({ url: buildImagesUrl('intermediates') }), providesTags: ['IntermediatesCount', 'FetchOnReconnect'], }), clearIntermediates: build.mutation({ - query: () => ({ url: `images/intermediates`, method: 'DELETE' }), + query: () => ({ url: buildImagesUrl('intermediates'), method: 'DELETE' }), invalidatesTags: ['IntermediatesCount'], }), getImageDTO: build.query({ - query: (image_name) => ({ url: `images/i/${image_name}` }), + query: (image_name) => ({ url: buildImagesUrl(`i/${image_name}`) }), providesTags: (result, error, image_name) => [{ type: 'Image', id: image_name }], keepUnusedDataFor: 86400, // 24 hours }), getImageMetadata: build.query({ - query: (image_name) => ({ url: `images/i/${image_name}/metadata` }), + query: (image_name) => ({ url: buildImagesUrl(`i/${image_name}/metadata`) }), providesTags: (result, error, image_name) => [{ type: 'ImageMetadata', id: image_name }], transformResponse: ( response: paths['/api/v1/images/i/{image_name}/metadata']['get']['responses']['200']['content']['application/json'] @@ -130,7 +146,7 @@ export const imagesApi = api.injectEndpoints({ }), deleteImage: build.mutation({ query: ({ image_name }) => ({ - url: `images/i/${image_name}`, + url: buildImagesUrl(`i/${image_name}`), method: 'DELETE', }), async onQueryStarted(imageDTO, { dispatch, queryFulfilled }) { @@ -185,7 +201,7 @@ export const imagesApi = api.injectEndpoints({ query: ({ imageDTOs }) => { const image_names = imageDTOs.map((imageDTO) => imageDTO.image_name); return { - url: `images/delete`, + url: buildImagesUrl('delete'), method: 'POST', body: { image_names, @@ -258,7 +274,7 @@ export const imagesApi = api.injectEndpoints({ */ changeImageIsIntermediate: build.mutation({ query: ({ imageDTO, is_intermediate }) => ({ - url: `images/i/${imageDTO.image_name}`, + url: buildImagesUrl(`i/${imageDTO.image_name}`), method: 'PATCH', body: { is_intermediate }, }), @@ -380,7 +396,7 @@ export const imagesApi = api.injectEndpoints({ */ changeImageSessionId: build.mutation({ query: ({ imageDTO, session_id }) => ({ - url: `images/i/${imageDTO.image_name}`, + url: buildImagesUrl(`i/${imageDTO.image_name}`), method: 'PATCH', body: { session_id }, }), @@ -417,7 +433,7 @@ export const imagesApi = api.injectEndpoints({ { imageDTOs: ImageDTO[] } >({ query: ({ imageDTOs: images }) => ({ - url: `images/star`, + url: buildImagesUrl('star'), method: 'POST', body: { image_names: images.map((img) => img.image_name) }, }), @@ -511,7 +527,7 @@ export const imagesApi = api.injectEndpoints({ { imageDTOs: ImageDTO[] } >({ query: ({ imageDTOs: images }) => ({ - url: `images/unstar`, + url: buildImagesUrl('unstar'), method: 'POST', body: { image_names: images.map((img) => img.image_name) }, }), @@ -611,7 +627,7 @@ export const imagesApi = api.injectEndpoints({ const formData = new FormData(); formData.append('file', file); return { - url: `images/upload`, + url: buildImagesUrl('upload'), method: 'POST', body: formData, params: { @@ -674,7 +690,7 @@ export const imagesApi = api.injectEndpoints({ }), deleteBoard: build.mutation({ - query: (board_id) => ({ url: `boards/${board_id}`, method: 'DELETE' }), + query: (board_id) => ({ url: buildBoardsUrl(board_id), method: 'DELETE' }), invalidatesTags: () => [ { type: 'Board', id: LIST_TAG }, // invalidate the 'No Board' cache @@ -764,7 +780,7 @@ export const imagesApi = api.injectEndpoints({ deleteBoardAndImages: build.mutation({ query: (board_id) => ({ - url: `boards/${board_id}`, + url: buildBoardsUrl(board_id), method: 'DELETE', params: { include_images: true }, }), @@ -840,7 +856,7 @@ export const imagesApi = api.injectEndpoints({ query: ({ board_id, imageDTO }) => { const { image_name } = imageDTO; return { - url: `board_images/`, + url: buildBoardImagesUrl(), method: 'POST', body: { board_id, image_name }, }; @@ -961,7 +977,7 @@ export const imagesApi = api.injectEndpoints({ query: ({ imageDTO }) => { const { image_name } = imageDTO; return { - url: `board_images/`, + url: buildBoardImagesUrl(), method: 'DELETE', body: { image_name }, }; @@ -1080,7 +1096,7 @@ export const imagesApi = api.injectEndpoints({ } >({ query: ({ board_id, imageDTOs }) => ({ - url: `board_images/batch`, + url: buildBoardImagesUrl('batch'), method: 'POST', body: { image_names: imageDTOs.map((i) => i.image_name), @@ -1197,7 +1213,7 @@ export const imagesApi = api.injectEndpoints({ } >({ query: ({ imageDTOs }) => ({ - url: `board_images/batch/delete`, + url: buildBoardImagesUrl('batch/delete'), method: 'POST', body: { image_names: imageDTOs.map((i) => i.image_name), @@ -1321,7 +1337,7 @@ export const imagesApi = api.injectEndpoints({ components['schemas']['Body_download_images_from_list'] >({ query: ({ image_names, board_id }) => ({ - url: `images/download`, + url: buildImagesUrl('download'), method: 'POST', body: { image_names, diff --git a/invokeai/frontend/web/src/services/api/endpoints/models.ts b/invokeai/frontend/web/src/services/api/endpoints/models.ts index 97e221454d..9a7f108056 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/models.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/models.ts @@ -19,7 +19,10 @@ import type { } from 'services/api/types'; import type { ApiTagDescription, tagTypes } from '..'; -import { api, LIST_TAG } from '..'; +import { api, buildV2Url, LIST_TAG } from '..'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +export const getModelId = (input: any): any => input; type UpdateMainModelArg = { base_model: BaseModelType; @@ -36,6 +39,8 @@ type UpdateLoRAModelArg = { type UpdateMainModelResponse = paths['/api/v2/models/i/{key}']['patch']['responses']['200']['content']['application/json']; +type ListModelsArg = NonNullable; + type UpdateLoRAModelResponse = UpdateMainModelResponse; type DeleteMainModelArg = { @@ -152,17 +157,25 @@ const buildTransformResponse = return adapter.setAll(adapter.getInitialState(), response.models); }; +/** + * Builds an endpoint URL for the models router + * @example + * buildModelsUrl('some-path') + * // '/api/v1/models/some-path' + */ +const buildModelsUrl = (path: string = '') => buildV2Url(`models/${path}`); + export const modelsApi = api.injectEndpoints({ endpoints: (build) => ({ getMainModels: build.query, BaseModelType[]>({ query: (base_models) => { - const params = { + const params: ListModelsArg = { model_type: 'main', base_models, }; const query = queryString.stringify(params, { arrayFormat: 'none' }); - return `models/?${query}`; + return buildModelsUrl(`?${query}`); }, providesTags: buildProvidesTags('MainModel'), transformResponse: buildTransformResponse(mainModelsAdapter), @@ -170,7 +183,7 @@ export const modelsApi = api.injectEndpoints({ updateMainModels: build.mutation({ query: ({ base_model, model_name, body }) => { return { - url: `models/${base_model}/main/${model_name}`, + url: buildModelsUrl(`${base_model}/main/${model_name}`), method: 'PATCH', body: body, }; @@ -180,7 +193,7 @@ export const modelsApi = api.injectEndpoints({ importMainModels: build.mutation({ query: ({ body }) => { return { - url: `models/import`, + url: buildModelsUrl('import'), method: 'POST', body: body, }; @@ -190,7 +203,7 @@ export const modelsApi = api.injectEndpoints({ addMainModels: build.mutation({ query: ({ body }) => { return { - url: `models/add`, + url: buildModelsUrl('add'), method: 'POST', body: body, }; @@ -200,7 +213,7 @@ export const modelsApi = api.injectEndpoints({ deleteMainModels: build.mutation({ query: ({ base_model, model_name, model_type }) => { return { - url: `models/${base_model}/${model_type}/${model_name}`, + url: buildModelsUrl(`${base_model}/${model_type}/${model_name}`), method: 'DELETE', }; }, @@ -209,7 +222,7 @@ export const modelsApi = api.injectEndpoints({ convertMainModels: build.mutation({ query: ({ base_model, model_name, convert_dest_directory }) => { return { - url: `models/convert/${base_model}/main/${model_name}`, + url: buildModelsUrl(`convert/${base_model}/main/${model_name}`), method: 'PUT', params: { convert_dest_directory }, }; @@ -219,7 +232,7 @@ export const modelsApi = api.injectEndpoints({ mergeMainModels: build.mutation({ query: ({ base_model, body }) => { return { - url: `models/merge/${base_model}`, + url: buildModelsUrl(`merge/${base_model}`), method: 'PUT', body: body, }; @@ -229,21 +242,21 @@ export const modelsApi = api.injectEndpoints({ syncModels: build.mutation({ query: () => { return { - url: `models/sync`, + url: buildModelsUrl('sync'), method: 'POST', }; }, invalidatesTags: ['Model'], }), getLoRAModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 'lora' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 'lora' } }), providesTags: buildProvidesTags('LoRAModel'), transformResponse: buildTransformResponse(loraModelsAdapter), }), updateLoRAModels: build.mutation({ query: ({ base_model, model_name, body }) => { return { - url: `models/${base_model}/lora/${model_name}`, + url: buildModelsUrl(`${base_model}/lora/${model_name}`), method: 'PATCH', body: body, }; @@ -253,34 +266,34 @@ export const modelsApi = api.injectEndpoints({ deleteLoRAModels: build.mutation({ query: ({ base_model, model_name }) => { return { - url: `models/${base_model}/lora/${model_name}`, + url: buildModelsUrl(`${base_model}/lora/${model_name}`), method: 'DELETE', }; }, invalidatesTags: [{ type: 'LoRAModel', id: LIST_TAG }], }), getControlNetModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 'controlnet' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 'controlnet' } }), providesTags: buildProvidesTags('ControlNetModel'), transformResponse: buildTransformResponse(controlNetModelsAdapter), }), getIPAdapterModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 'ip_adapter' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 'ip_adapter' } }), providesTags: buildProvidesTags('IPAdapterModel'), transformResponse: buildTransformResponse(ipAdapterModelsAdapter), }), getT2IAdapterModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 't2i_adapter' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 't2i_adapter' } }), providesTags: buildProvidesTags('T2IAdapterModel'), transformResponse: buildTransformResponse(t2iAdapterModelsAdapter), }), getVaeModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 'vae' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 'vae' } }), providesTags: buildProvidesTags('VaeModel'), transformResponse: buildTransformResponse(vaeModelsAdapter), }), getTextualInversionModels: build.query, void>({ - query: () => ({ url: 'models/', params: { model_type: 'embedding' } }), + query: () => ({ url: buildModelsUrl(), params: { model_type: 'embedding' } }), providesTags: buildProvidesTags('TextualInversionModel'), transformResponse: buildTransformResponse(textualInversionModelsAdapter), }), @@ -288,14 +301,14 @@ export const modelsApi = api.injectEndpoints({ query: (arg) => { const folderQueryStr = queryString.stringify(arg, {}); return { - url: `/models/search?${folderQueryStr}`, + url: buildModelsUrl(`search?${folderQueryStr}`), }; }, }), getCheckpointConfigs: build.query({ query: () => { return { - url: `/models/ckpt_confs`, + url: buildModelsUrl(`ckpt_confs`), }; }, }), diff --git a/invokeai/frontend/web/src/services/api/endpoints/queue.ts b/invokeai/frontend/web/src/services/api/endpoints/queue.ts index 6c0798a936..385aa8ad12 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/queue.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/queue.ts @@ -7,7 +7,15 @@ import queryString from 'query-string'; import type { components, paths } from 'services/api/schema'; import type { ApiTagDescription } from '..'; -import { api } from '..'; +import { api, buildV1Url } from '..'; + +/** + * Builds an endpoint URL for the queue router + * @example + * buildQueueUrl('some-path') + * // '/api/v1/queue/queue_id/some-path' + */ +const buildQueueUrl = (path: string = '') => buildV1Url(`queue/${$queueId.get()}/${path}`); const getListQueueItemsUrl = (queryArgs?: paths['/api/v1/queue/{queue_id}/list']['get']['parameters']['query']) => { const query = queryArgs @@ -17,10 +25,10 @@ const getListQueueItemsUrl = (queryArgs?: paths['/api/v1/queue/{queue_id}/list'] : undefined; if (query) { - return `queue/${$queueId.get()}/list?${query}`; + return buildQueueUrl(`list?${query}`); } - return `queue/${$queueId.get()}/list`; + return buildQueueUrl('list'); }; export type SessionQueueItemStatus = NonNullable< @@ -58,7 +66,7 @@ export const queueApi = api.injectEndpoints({ paths['/api/v1/queue/{queue_id}/enqueue_batch']['post']['requestBody']['content']['application/json'] >({ query: (arg) => ({ - url: `queue/${$queueId.get()}/enqueue_batch`, + url: buildQueueUrl('enqueue_batch'), body: arg, method: 'POST', }), @@ -78,7 +86,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/processor/resume`, + url: buildQueueUrl('processor/resume'), method: 'PUT', }), invalidatesTags: ['CurrentSessionQueueItem', 'SessionQueueStatus'], @@ -88,7 +96,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/processor/pause`, + url: buildQueueUrl('processor/pause'), method: 'PUT', }), invalidatesTags: ['CurrentSessionQueueItem', 'SessionQueueStatus'], @@ -98,7 +106,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/prune`, + url: buildQueueUrl('prune'), method: 'PUT', }), invalidatesTags: ['SessionQueueStatus', 'BatchStatus'], @@ -117,7 +125,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/clear`, + url: buildQueueUrl('clear'), method: 'PUT', }), invalidatesTags: [ @@ -142,7 +150,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/current`, + url: buildQueueUrl('current'), method: 'GET', }), providesTags: (result) => { @@ -158,7 +166,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/next`, + url: buildQueueUrl('next'), method: 'GET', }), providesTags: (result) => { @@ -174,7 +182,7 @@ export const queueApi = api.injectEndpoints({ void >({ query: () => ({ - url: `queue/${$queueId.get()}/status`, + url: buildQueueUrl('status'), method: 'GET', }), providesTags: ['SessionQueueStatus', 'FetchOnReconnect'], @@ -184,7 +192,7 @@ export const queueApi = api.injectEndpoints({ { batch_id: string } >({ query: ({ batch_id }) => ({ - url: `queue/${$queueId.get()}/b/${batch_id}/status`, + url: buildQueueUrl(`/b/${batch_id}/status`), method: 'GET', }), providesTags: (result) => { @@ -200,7 +208,7 @@ export const queueApi = api.injectEndpoints({ number >({ query: (item_id) => ({ - url: `queue/${$queueId.get()}/i/${item_id}`, + url: buildQueueUrl(`i/${item_id}`), method: 'GET', }), providesTags: (result) => { @@ -216,7 +224,7 @@ export const queueApi = api.injectEndpoints({ number >({ query: (item_id) => ({ - url: `queue/${$queueId.get()}/i/${item_id}/cancel`, + url: buildQueueUrl(`i/${item_id}/cancel`), method: 'PUT', }), onQueryStarted: async (item_id, { dispatch, queryFulfilled }) => { @@ -253,7 +261,7 @@ export const queueApi = api.injectEndpoints({ paths['/api/v1/queue/{queue_id}/cancel_by_batch_ids']['put']['requestBody']['content']['application/json'] >({ query: (body) => ({ - url: `queue/${$queueId.get()}/cancel_by_batch_ids`, + url: buildQueueUrl('cancel_by_batch_ids'), method: 'PUT', body, }), @@ -279,7 +287,7 @@ export const queueApi = api.injectEndpoints({ method: 'GET', }), serializeQueryArgs: () => { - return `queue/${$queueId.get()}/list`; + return buildQueueUrl('list'); }, transformResponse: (response: components['schemas']['CursorPaginatedResults_SessionQueueItemDTO_']) => queueItemsAdapter.addMany( diff --git a/invokeai/frontend/web/src/services/api/endpoints/utilities.ts b/invokeai/frontend/web/src/services/api/endpoints/utilities.ts index c08ee62dc9..309dd2dc79 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/utilities.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/utilities.ts @@ -1,6 +1,14 @@ import type { components } from 'services/api/schema'; -import { api } from '..'; +import { api, buildV1Url } from '..'; + +/** + * Builds an endpoint URL for the utilities router + * @example + * buildUtilitiesUrl('some-path') + * // '/api/v1/utilities/some-path' + */ +const buildUtilitiesUrl = (path: string = '') => buildV1Url(`utilities/${path}`); export const utilitiesApi = api.injectEndpoints({ endpoints: (build) => ({ @@ -9,7 +17,7 @@ export const utilitiesApi = api.injectEndpoints({ { prompt: string; max_prompts: number } >({ query: (arg) => ({ - url: 'utilities/dynamicprompts', + url: buildUtilitiesUrl('dynamicprompts'), body: arg, method: 'POST', }), diff --git a/invokeai/frontend/web/src/services/api/endpoints/workflows.ts b/invokeai/frontend/web/src/services/api/endpoints/workflows.ts index c382f7e111..1e64809e5a 100644 --- a/invokeai/frontend/web/src/services/api/endpoints/workflows.ts +++ b/invokeai/frontend/web/src/services/api/endpoints/workflows.ts @@ -1,6 +1,14 @@ import type { paths } from 'services/api/schema'; -import { api, LIST_TAG } from '..'; +import { api, buildV1Url, LIST_TAG } from '..'; + +/** + * Builds an endpoint URL for the workflows router + * @example + * buildWorkflowsUrl('some-path') + * // '/api/v1/workflows/some-path' + */ +const buildWorkflowsUrl = (path: string = '') => buildV1Url(`workflows/${path}`); export const workflowsApi = api.injectEndpoints({ endpoints: (build) => ({ @@ -8,7 +16,7 @@ export const workflowsApi = api.injectEndpoints({ paths['/api/v1/workflows/i/{workflow_id}']['get']['responses']['200']['content']['application/json'], string >({ - query: (workflow_id) => `workflows/i/${workflow_id}`, + query: (workflow_id) => buildWorkflowsUrl(`i/${workflow_id}`), providesTags: (result, error, workflow_id) => [{ type: 'Workflow', id: workflow_id }, 'FetchOnReconnect'], onQueryStarted: async (arg, api) => { const { dispatch, queryFulfilled } = api; @@ -22,7 +30,7 @@ export const workflowsApi = api.injectEndpoints({ }), deleteWorkflow: build.mutation({ query: (workflow_id) => ({ - url: `workflows/i/${workflow_id}`, + url: buildWorkflowsUrl(`i/${workflow_id}`), method: 'DELETE', }), invalidatesTags: (result, error, workflow_id) => [ @@ -36,7 +44,7 @@ export const workflowsApi = api.injectEndpoints({ paths['/api/v1/workflows/']['post']['requestBody']['content']['application/json']['workflow'] >({ query: (workflow) => ({ - url: 'workflows/', + url: buildWorkflowsUrl(), method: 'POST', body: { workflow }, }), @@ -50,7 +58,7 @@ export const workflowsApi = api.injectEndpoints({ paths['/api/v1/workflows/i/{workflow_id}']['patch']['requestBody']['content']['application/json']['workflow'] >({ query: (workflow) => ({ - url: `workflows/i/${workflow.id}`, + url: buildWorkflowsUrl(`i/${workflow.id}`), method: 'PATCH', body: { workflow }, }), @@ -65,7 +73,7 @@ export const workflowsApi = api.injectEndpoints({ NonNullable >({ query: (params) => ({ - url: 'workflows/', + url: buildWorkflowsUrl(), params, }), providesTags: ['FetchOnReconnect', { type: 'Workflow', id: LIST_TAG }], diff --git a/invokeai/frontend/web/src/services/api/index.ts b/invokeai/frontend/web/src/services/api/index.ts index 8cb9aa8618..1f567d7905 100644 --- a/invokeai/frontend/web/src/services/api/index.ts +++ b/invokeai/frontend/web/src/services/api/index.ts @@ -54,7 +54,7 @@ const dynamicBaseQuery: BaseQueryFn { if (authToken) { headers.set('Authorization', `Bearer ${authToken}`); @@ -108,3 +108,6 @@ function getCircularReplacer() { return value; }; } + +export const buildV1Url = (path: string): string => `api/v1/${path}`; +export const buildV2Url = (path: string): string => `api/v2/${path}`; diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts index 3393e74d48..40fc262be2 100644 --- a/invokeai/frontend/web/src/services/api/schema.ts +++ b/invokeai/frontend/web/src/services/api/schema.ts @@ -4212,7 +4212,7 @@ export type components = { * @description The nodes in this graph */ nodes?: { - [key: string]: components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["HedImageProcessorInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["LineartImageProcessorInvocation"] | components["schemas"]["StringInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["GraphInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["MediapipeFaceProcessorInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["MlsdImageProcessorInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["MidasDepthImageProcessorInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["VaeLoaderInvocation"] | components["schemas"]["FloatInvocation"] | components["schemas"]["TileResamplerProcessorInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ColorMapImageProcessorInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["LoraLoaderInvocation"] | components["schemas"]["PidiImageProcessorInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["LeresImageProcessorInvocation"] | components["schemas"]["NormalbaeImageProcessorInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["SDXLLoraLoaderInvocation"] | components["schemas"]["StepParamEasingInvocation"] | components["schemas"]["DWOpenposeImageProcessorInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["LineartAnimeImageProcessorInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["ClipSkipInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["SegmentAnythingProcessorInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["CannyImageProcessorInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["ZoeDepthImageProcessorInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["AddInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["ContentShuffleImageProcessorInvocation"] | components["schemas"]["CvInpaintInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["ControlNetInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["DepthAnythingImageProcessorInvocation"]; + [key: string]: components["schemas"]["ControlNetInvocation"] | components["schemas"]["TileToPropertiesInvocation"] | components["schemas"]["LeresImageProcessorInvocation"] | components["schemas"]["SchedulerInvocation"] | components["schemas"]["DivideInvocation"] | components["schemas"]["MediapipeFaceProcessorInvocation"] | components["schemas"]["AddInvocation"] | components["schemas"]["StringInvocation"] | components["schemas"]["SDXLModelLoaderInvocation"] | components["schemas"]["ImagePasteInvocation"] | components["schemas"]["InfillPatchMatchInvocation"] | components["schemas"]["ImageInvocation"] | components["schemas"]["SubtractInvocation"] | components["schemas"]["SeamlessModeInvocation"] | components["schemas"]["FloatInvocation"] | components["schemas"]["ImageMultiplyInvocation"] | components["schemas"]["LineartImageProcessorInvocation"] | components["schemas"]["PidiImageProcessorInvocation"] | components["schemas"]["InfillColorInvocation"] | components["schemas"]["SDXLLoraLoaderInvocation"] | components["schemas"]["SaveImageInvocation"] | components["schemas"]["ColorMapImageProcessorInvocation"] | components["schemas"]["LoraLoaderInvocation"] | components["schemas"]["DenoiseLatentsInvocation"] | components["schemas"]["ScaleLatentsInvocation"] | components["schemas"]["ImageCropInvocation"] | components["schemas"]["NoiseInvocation"] | components["schemas"]["T2IAdapterInvocation"] | components["schemas"]["MaskCombineInvocation"] | components["schemas"]["CalculateImageTilesMinimumOverlapInvocation"] | components["schemas"]["StringSplitNegInvocation"] | components["schemas"]["ImageResizeInvocation"] | components["schemas"]["DWOpenposeImageProcessorInvocation"] | components["schemas"]["CannyImageProcessorInvocation"] | components["schemas"]["ConditioningCollectionInvocation"] | components["schemas"]["ImageBlurInvocation"] | components["schemas"]["ResizeLatentsInvocation"] | components["schemas"]["StringSplitInvocation"] | components["schemas"]["FaceIdentifierInvocation"] | components["schemas"]["ShowImageInvocation"] | components["schemas"]["IntegerInvocation"] | components["schemas"]["LineartAnimeImageProcessorInvocation"] | components["schemas"]["SDXLRefinerModelLoaderInvocation"] | components["schemas"]["SegmentAnythingProcessorInvocation"] | components["schemas"]["RangeInvocation"] | components["schemas"]["ZoeDepthImageProcessorInvocation"] | components["schemas"]["SDXLCompelPromptInvocation"] | components["schemas"]["DynamicPromptInvocation"] | components["schemas"]["ContentShuffleImageProcessorInvocation"] | components["schemas"]["CollectInvocation"] | components["schemas"]["ImageScaleInvocation"] | components["schemas"]["LaMaInfillInvocation"] | components["schemas"]["ImageChannelInvocation"] | components["schemas"]["StepParamEasingInvocation"] | components["schemas"]["CenterPadCropInvocation"] | components["schemas"]["CoreMetadataInvocation"] | components["schemas"]["CalculateImageTilesInvocation"] | components["schemas"]["ImageLerpInvocation"] | components["schemas"]["ClipSkipInvocation"] | components["schemas"]["CreateDenoiseMaskInvocation"] | components["schemas"]["StringJoinThreeInvocation"] | components["schemas"]["LatentsToImageInvocation"] | components["schemas"]["PairTileImageInvocation"] | components["schemas"]["IdealSizeInvocation"] | components["schemas"]["IntegerMathInvocation"] | components["schemas"]["InfillTileInvocation"] | components["schemas"]["ESRGANInvocation"] | components["schemas"]["LatentsInvocation"] | components["schemas"]["MidasDepthImageProcessorInvocation"] | components["schemas"]["FloatMathInvocation"] | components["schemas"]["StringCollectionInvocation"] | components["schemas"]["NormalbaeImageProcessorInvocation"] | components["schemas"]["SDXLRefinerCompelPromptInvocation"] | components["schemas"]["MaskFromAlphaInvocation"] | components["schemas"]["ImageChannelOffsetInvocation"] | components["schemas"]["FloatCollectionInvocation"] | components["schemas"]["ImageWatermarkInvocation"] | components["schemas"]["HedImageProcessorInvocation"] | components["schemas"]["ImageCollectionInvocation"] | components["schemas"]["VaeLoaderInvocation"] | components["schemas"]["MergeTilesToImageInvocation"] | components["schemas"]["ImageInverseLerpInvocation"] | components["schemas"]["GraphInvocation"] | components["schemas"]["ImageConvertInvocation"] | components["schemas"]["MergeMetadataInvocation"] | components["schemas"]["IterateInvocation"] | components["schemas"]["BlendLatentsInvocation"] | components["schemas"]["RangeOfSizeInvocation"] | components["schemas"]["MaskEdgeInvocation"] | components["schemas"]["MetadataItemInvocation"] | components["schemas"]["FloatToIntegerInvocation"] | components["schemas"]["DepthAnythingImageProcessorInvocation"] | components["schemas"]["StringReplaceInvocation"] | components["schemas"]["RoundInvocation"] | components["schemas"]["LatentsCollectionInvocation"] | components["schemas"]["CropLatentsCoreInvocation"] | components["schemas"]["BooleanCollectionInvocation"] | components["schemas"]["BlankImageInvocation"] | components["schemas"]["ImageNSFWBlurInvocation"] | components["schemas"]["MultiplyInvocation"] | components["schemas"]["FloatLinearRangeInvocation"] | components["schemas"]["FreeUInvocation"] | components["schemas"]["IPAdapterInvocation"] | components["schemas"]["RandomIntInvocation"] | components["schemas"]["MainModelLoaderInvocation"] | components["schemas"]["ImageChannelMultiplyInvocation"] | components["schemas"]["MetadataInvocation"] | components["schemas"]["StringJoinInvocation"] | components["schemas"]["FaceMaskInvocation"] | components["schemas"]["IntegerCollectionInvocation"] | components["schemas"]["RandomRangeInvocation"] | components["schemas"]["ImageHueAdjustmentInvocation"] | components["schemas"]["CompelInvocation"] | components["schemas"]["CalculateImageTilesEvenSplitInvocation"] | components["schemas"]["MlsdImageProcessorInvocation"] | components["schemas"]["CV2InfillInvocation"] | components["schemas"]["RandomFloatInvocation"] | components["schemas"]["ColorCorrectInvocation"] | components["schemas"]["PromptsFromFileInvocation"] | components["schemas"]["UnsharpMaskInvocation"] | components["schemas"]["ColorInvocation"] | components["schemas"]["BooleanInvocation"] | components["schemas"]["FaceOffInvocation"] | components["schemas"]["ConditioningInvocation"] | components["schemas"]["ImageToLatentsInvocation"] | components["schemas"]["TileResamplerProcessorInvocation"] | components["schemas"]["CvInpaintInvocation"]; }; /** * Edges @@ -4249,7 +4249,7 @@ export type components = { * @description The results of node executions */ results: { - [key: string]: components["schemas"]["ImageCollectionOutput"] | components["schemas"]["LatentsOutput"] | components["schemas"]["T2IAdapterOutput"] | components["schemas"]["MetadataOutput"] | components["schemas"]["ColorCollectionOutput"] | components["schemas"]["IntegerOutput"] | components["schemas"]["ConditioningOutput"] | components["schemas"]["BooleanOutput"] | components["schemas"]["SDXLRefinerModelLoaderOutput"] | components["schemas"]["ImageOutput"] | components["schemas"]["LatentsCollectionOutput"] | components["schemas"]["ModelLoaderOutput"] | components["schemas"]["MetadataItemOutput"] | components["schemas"]["CalculateImageTilesOutput"] | components["schemas"]["StringOutput"] | components["schemas"]["SDXLModelLoaderOutput"] | components["schemas"]["SeamlessModeOutput"] | components["schemas"]["NoiseOutput"] | components["schemas"]["StringPosNegOutput"] | components["schemas"]["ConditioningCollectionOutput"] | components["schemas"]["SDXLLoraLoaderOutput"] | components["schemas"]["String2Output"] | components["schemas"]["SchedulerOutput"] | components["schemas"]["VAEOutput"] | components["schemas"]["FaceMaskOutput"] | components["schemas"]["IdealSizeOutput"] | components["schemas"]["IntegerCollectionOutput"] | components["schemas"]["GraphInvocationOutput"] | components["schemas"]["IterateInvocationOutput"] | components["schemas"]["IPAdapterOutput"] | components["schemas"]["FloatCollectionOutput"] | components["schemas"]["ControlOutput"] | components["schemas"]["UNetOutput"] | components["schemas"]["LoraLoaderOutput"] | components["schemas"]["CollectInvocationOutput"] | components["schemas"]["DenoiseMaskOutput"] | components["schemas"]["FloatOutput"] | components["schemas"]["TileToPropertiesOutput"] | components["schemas"]["StringCollectionOutput"] | components["schemas"]["PairTileImageOutput"] | components["schemas"]["ClipSkipInvocationOutput"] | components["schemas"]["ColorOutput"] | components["schemas"]["FaceOffOutput"] | components["schemas"]["BooleanCollectionOutput"] | components["schemas"]["CLIPOutput"]; + [key: string]: components["schemas"]["SchedulerOutput"] | components["schemas"]["BooleanCollectionOutput"] | components["schemas"]["LoraLoaderOutput"] | components["schemas"]["IdealSizeOutput"] | components["schemas"]["ControlOutput"] | components["schemas"]["IPAdapterOutput"] | components["schemas"]["ImageOutput"] | components["schemas"]["CLIPOutput"] | components["schemas"]["ConditioningCollectionOutput"] | components["schemas"]["PairTileImageOutput"] | components["schemas"]["GraphInvocationOutput"] | components["schemas"]["CalculateImageTilesOutput"] | components["schemas"]["MetadataItemOutput"] | components["schemas"]["SeamlessModeOutput"] | components["schemas"]["SDXLModelLoaderOutput"] | components["schemas"]["ModelLoaderOutput"] | components["schemas"]["StringCollectionOutput"] | components["schemas"]["IntegerCollectionOutput"] | components["schemas"]["UNetOutput"] | components["schemas"]["SDXLLoraLoaderOutput"] | components["schemas"]["TileToPropertiesOutput"] | components["schemas"]["T2IAdapterOutput"] | components["schemas"]["BooleanOutput"] | components["schemas"]["FaceMaskOutput"] | components["schemas"]["FaceOffOutput"] | components["schemas"]["ColorCollectionOutput"] | components["schemas"]["FloatOutput"] | components["schemas"]["NoiseOutput"] | components["schemas"]["CollectInvocationOutput"] | components["schemas"]["ConditioningOutput"] | components["schemas"]["DenoiseMaskOutput"] | components["schemas"]["StringOutput"] | components["schemas"]["FloatCollectionOutput"] | components["schemas"]["VAEOutput"] | components["schemas"]["ClipSkipInvocationOutput"] | components["schemas"]["ColorOutput"] | components["schemas"]["ImageCollectionOutput"] | components["schemas"]["StringPosNegOutput"] | components["schemas"]["String2Output"] | components["schemas"]["IntegerOutput"] | components["schemas"]["LatentsCollectionOutput"] | components["schemas"]["LatentsOutput"] | components["schemas"]["MetadataOutput"] | components["schemas"]["SDXLRefinerModelLoaderOutput"] | components["schemas"]["IterateInvocationOutput"]; }; /** * Errors @@ -11119,17 +11119,11 @@ export type components = { */ VaeModelFormat: "checkpoint" | "diffusers"; /** - * StableDiffusion2ModelFormat + * T2IAdapterModelFormat * @description An enumeration. * @enum {string} */ - StableDiffusion2ModelFormat: "checkpoint" | "diffusers"; - /** - * CLIPVisionModelFormat - * @description An enumeration. - * @enum {string} - */ - CLIPVisionModelFormat: "diffusers"; + T2IAdapterModelFormat: "diffusers"; /** * StableDiffusionXLModelFormat * @description An enumeration. @@ -11142,12 +11136,6 @@ export type components = { * @enum {string} */ StableDiffusion1ModelFormat: "checkpoint" | "diffusers"; - /** - * ControlNetModelFormat - * @description An enumeration. - * @enum {string} - */ - ControlNetModelFormat: "checkpoint" | "diffusers"; /** * StableDiffusionOnnxModelFormat * @description An enumeration. @@ -11155,17 +11143,29 @@ export type components = { */ StableDiffusionOnnxModelFormat: "olive" | "onnx"; /** - * T2IAdapterModelFormat + * ControlNetModelFormat * @description An enumeration. * @enum {string} */ - T2IAdapterModelFormat: "diffusers"; + ControlNetModelFormat: "checkpoint" | "diffusers"; + /** + * StableDiffusion2ModelFormat + * @description An enumeration. + * @enum {string} + */ + StableDiffusion2ModelFormat: "checkpoint" | "diffusers"; /** * LoRAModelFormat * @description An enumeration. * @enum {string} */ LoRAModelFormat: "lycoris" | "diffusers"; + /** + * CLIPVisionModelFormat + * @description An enumeration. + * @enum {string} + */ + CLIPVisionModelFormat: "diffusers"; /** * IPAdapterModelFormat * @description An enumeration. diff --git a/invokeai/frontend/web/src/services/api/types.ts b/invokeai/frontend/web/src/services/api/types.ts index 7a02cc5568..4ae2f9b594 100644 --- a/invokeai/frontend/web/src/services/api/types.ts +++ b/invokeai/frontend/web/src/services/api/types.ts @@ -61,11 +61,13 @@ export type IPAdapterField = S['IPAdapterField']; // Model Configs // TODO(MM2): Can we make key required in the pydantic model? -type KeyRequired = SetRequired; +type KeyRequired = SetRequired; export type LoRAConfig = KeyRequired; // TODO(MM2): Can we rename this from Vae -> VAE export type VAEConfig = KeyRequired | KeyRequired; -export type ControlNetConfig = KeyRequired | KeyRequired; +export type ControlNetConfig = + | KeyRequired + | KeyRequired; export type IPAdapterConfig = KeyRequired; // TODO(MM2): Can we rename this to T2IAdapterConfig export type T2IAdapterConfig = KeyRequired; diff --git a/invokeai/frontend/web/src/services/api/util.ts b/invokeai/frontend/web/src/services/api/util.ts index f7f36f4630..a7a5d6451e 100644 --- a/invokeai/frontend/web/src/services/api/util.ts +++ b/invokeai/frontend/web/src/services/api/util.ts @@ -3,6 +3,7 @@ import { getSelectorsOptions } from 'app/store/createMemoizedSelector'; import { dateComparator } from 'common/util/dateComparator'; import { ASSETS_CATEGORIES, IMAGE_CATEGORIES } from 'features/gallery/store/types'; import queryString from 'query-string'; +import { buildV1Url } from 'services/api'; import type { ImageCache, ImageDTO, ListImagesArgs } from './types'; @@ -79,4 +80,4 @@ export const imagesSelectors = imagesAdapter.getSelectors(undefined, getSelector // Helper to create the url for the listImages endpoint. Also we use it to create the cache key. export const getListImagesUrl = (queryArgs: ListImagesArgs) => - `images/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`; + buildV1Url(`images/?${queryString.stringify(queryArgs, { arrayFormat: 'none' })}`); diff --git a/invokeai/frontend/web/vite.config.mts b/invokeai/frontend/web/vite.config.mts index f4dbae7123..32e3e1f64f 100644 --- a/invokeai/frontend/web/vite.config.mts +++ b/invokeai/frontend/web/vite.config.mts @@ -76,9 +76,9 @@ export default defineConfig(({ mode }) => { changeOrigin: true, }, // proxy nodes api - '/api/v1': { - target: 'http://127.0.0.1:9090/api/v1', - rewrite: (path) => path.replace(/^\/api\/v1/, ''), + '/api/': { + target: 'http://127.0.0.1:9090/api/', + rewrite: (path) => path.replace(/^\/api/, ''), changeOrigin: true, }, },