diff --git a/ui/lib/api/blobs/blobs.ts b/ui/lib/api/blobs/blobs.ts deleted file mode 100644 index bb8f501a824bec2bdaee9a88e396f358e2161736..0000000000000000000000000000000000000000 --- a/ui/lib/api/blobs/blobs.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { ApiError } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getGetBlobUrl = (hash: string) => { - return `/api/v1/blobs/${hash}` -} - -export const getBlob = async (hash: string, options?: RequestInit): Promise => { - return fetchApi(getGetBlobUrl(hash), { - ...options, - method: 'GET', - }) -} - -export const getGetBlobQueryKey = (hash: string) => { - return [`/api/v1/blobs/${hash}`] as const -} - -export const getGetBlobQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - hash: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetBlobQueryKey(hash) - - const queryFn: QueryFunction>> = ({ signal }) => - getBlob(hash, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!hash, - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type GetBlobQueryResult = NonNullable>> -export type GetBlobQueryError = ApiError - -export function useGetBlob>, TError = ApiError>( - hash: string, - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetBlob>, TError = ApiError>( - hash: string, - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetBlob>, TError = ApiError>( - hash: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetBlob>, TError = ApiError>( - hash: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetBlobQueryOptions(hash, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} diff --git a/ui/lib/api/default/default.msw.ts b/ui/lib/api/default/default.msw.ts new file mode 100644 index 0000000000000000000000000000000000000000..c2b11704b94f1e256bdfe32daed5f37eb7f3d0a3 --- /dev/null +++ b/ui/lib/api/default/default.msw.ts @@ -0,0 +1,1940 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import { faker } from '@faker-js/faker' +import { HttpResponse, delay, http } from 'msw' +import type { RequestHandlerOptions } from 'msw' + +import { + FontSource, + ImageRole, + JobStatus, + LlmProviderCatalogStatus, + LlmStateStatus, + LlmTargetKind, + MaskRole, + PipelineStep, + TextAlign, + TextDirection, +} from '../schemas' +import type { + AddImageLayerResponse, + AppConfig, + AppEvent, + CreatePagesResponse, + DataConfig, + EngineCatalog, + FontFaceInfo, + FontPrediction, + GoogleFontCatalog, + HistoryResult, + HttpConfig, + ListDownloadsResponse, + ListOperationsResponse, + ListProjectsResponse, + LlmCatalog, + LlmState, + LlmTarget, + MetaInfo, + PipelineConfig, + ProjectSummary, + PutMaskResponse, + SceneSnapshot, + StartDownloadResponse, + StartPipelineResponse, + TextShaderEffect, + TextStrokeStyle, + TextStyle, + Transform, +} from '../schemas' + +export const getGetBlobResponseMock = (): ArrayBuffer => + new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) + +export const getGetConfigResponseDataConfigMock = ( + overrideResponse: Partial = {}, +): DataConfig => ({ + ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ...overrideResponse, +}) + +export const getGetConfigResponseHttpConfigMock = ( + overrideResponse: Partial = {}, +): HttpConfig => ({ + ...{ + connect_timeout: faker.number.int({ min: 0 }), + max_retries: faker.number.int({ min: 0 }), + read_timeout: faker.number.int({ min: 0 }), + }, + ...overrideResponse, +}) + +export const getGetConfigResponsePipelineConfigMock = ( + overrideResponse: Partial = {}, +): PipelineConfig => ({ + ...{ + bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), + detector: faker.string.alpha({ length: { min: 10, max: 20 } }), + font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }), + inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }), + ocr: faker.string.alpha({ length: { min: 10, max: 20 } }), + renderer: faker.string.alpha({ length: { min: 10, max: 20 } }), + segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), + translator: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getGetConfigResponseMock = ( + overrideResponse: Partial> = {}, +): AppConfig => ({ + data: faker.helpers.arrayElement([{ ...getGetConfigResponseDataConfigMock() }]), + http: faker.helpers.arrayElement([{ ...getGetConfigResponseHttpConfigMock() }]), + pipeline: faker.helpers.arrayElement([{ ...getGetConfigResponsePipelineConfigMock() }]), + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + api_key: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + base_url: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + }), + ), + ...overrideResponse, +}) + +export const getPatchConfigResponseDataConfigMock = ( + overrideResponse: Partial = {}, +): DataConfig => ({ + ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) }, + ...overrideResponse, +}) + +export const getPatchConfigResponseHttpConfigMock = ( + overrideResponse: Partial = {}, +): HttpConfig => ({ + ...{ + connect_timeout: faker.number.int({ min: 0 }), + max_retries: faker.number.int({ min: 0 }), + read_timeout: faker.number.int({ min: 0 }), + }, + ...overrideResponse, +}) + +export const getPatchConfigResponsePipelineConfigMock = ( + overrideResponse: Partial = {}, +): PipelineConfig => ({ + ...{ + bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), + detector: faker.string.alpha({ length: { min: 10, max: 20 } }), + font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }), + inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }), + ocr: faker.string.alpha({ length: { min: 10, max: 20 } }), + renderer: faker.string.alpha({ length: { min: 10, max: 20 } }), + segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), + translator: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + ...overrideResponse, +}) + +export const getPatchConfigResponseMock = ( + overrideResponse: Partial> = {}, +): AppConfig => ({ + data: faker.helpers.arrayElement([{ ...getPatchConfigResponseDataConfigMock() }]), + http: faker.helpers.arrayElement([{ ...getPatchConfigResponseHttpConfigMock() }]), + pipeline: faker.helpers.arrayElement([{ ...getPatchConfigResponsePipelineConfigMock() }]), + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + api_key: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + base_url: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + }), + ), + ...overrideResponse, +}) + +export const getListDownloadsResponseMock = ( + overrideResponse: Partial> = {}, +): ListDownloadsResponse => ({ + downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + downloaded: faker.number.int({ min: 0 }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement([ + { status: faker.helpers.arrayElement(['started'] as const) }, + { status: faker.helpers.arrayElement(['downloading'] as const) }, + { status: faker.helpers.arrayElement(['completed'] as const) }, + { + reason: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(['failed'] as const), + }, + ]), + total: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + }), + ), + ...overrideResponse, +}) + +export const getStartDownloadResponseMock = ( + overrideResponse: Partial> = {}, +): StartDownloadResponse => ({ + operationId: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getGetEngineCatalogResponseMock = ( + overrideResponse: Partial> = {}, +): EngineCatalog => ({ + bubbleSegmenters: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + })), + detectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + fontDetectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + inpainters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + ocr: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + })), + renderers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + segmenters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + translators: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + }), + ), + ...overrideResponse, +}) + +export const getEventsResponseLlmTargetMock = ( + overrideResponse: Partial = {}, +): LlmTarget => ({ + ...{ + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getEventsResponseMock = (): AppEvent => + faker.helpers.arrayElement([ + { + event: faker.helpers.arrayElement(['jobStarted'] as const), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + }, + { + ...{ + currentPage: faker.number.int({ min: 0 }), + currentStepIndex: faker.number.int({ min: 0 }), + jobId: faker.string.alpha({ length: { min: 10, max: 20 } }), + overallPercent: faker.number.int({ min: 0 }), + status: faker.helpers.arrayElement([ + { status: faker.helpers.arrayElement(['running'] as const) }, + { status: faker.helpers.arrayElement(['completed'] as const) }, + { status: faker.helpers.arrayElement(['cancelled'] as const) }, + { + reason: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(['failed'] as const), + }, + ]), + step: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + faker.helpers.arrayElement(Object.values(PipelineStep)), + ]), + undefined, + ]), + totalPages: faker.number.int({ min: 0 }), + totalSteps: faker.number.int({ min: 0 }), + }, + ...{ event: faker.helpers.arrayElement(['jobProgress'] as const) }, + }, + { + ...{ + error: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(JobStatus)), + }, + ...{ event: faker.helpers.arrayElement(['jobFinished'] as const) }, + }, + { + ...{ + downloaded: faker.number.int({ min: 0 }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement([ + { status: faker.helpers.arrayElement(['started'] as const) }, + { status: faker.helpers.arrayElement(['downloading'] as const) }, + { status: faker.helpers.arrayElement(['completed'] as const) }, + { + reason: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(['failed'] as const), + }, + ]), + total: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + }, + ...{ event: faker.helpers.arrayElement(['downloadProgress'] as const) }, + }, + { + event: faker.helpers.arrayElement(['llmLoading'] as const), + target: { + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + }, + { + event: faker.helpers.arrayElement(['llmLoaded'] as const), + target: { + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + }, + { + event: faker.helpers.arrayElement(['llmFailed'] as const), + target: faker.helpers.arrayElement([ + faker.helpers.arrayElement([null, { ...getEventsResponseLlmTargetMock() }]), + undefined, + ]), + }, + { event: faker.helpers.arrayElement(['llmUnloaded'] as const) }, + { + ...{ + downloads: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => ({ + downloaded: faker.number.int({ min: 0 }), + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement([ + { status: faker.helpers.arrayElement(['started'] as const) }, + { status: faker.helpers.arrayElement(['downloading'] as const) }, + { status: faker.helpers.arrayElement(['completed'] as const) }, + { + reason: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(['failed'] as const), + }, + ]), + total: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + })), + jobs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + error: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(JobStatus)), + }), + ), + }, + ...{ event: faker.helpers.arrayElement(['snapshot'] as const) }, + }, + ]) + +export const getListFontsResponseMock = (): FontFaceInfo[] => + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + cached: faker.datatype.boolean(), + category: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + familyName: faker.string.alpha({ length: { min: 10, max: 20 } }), + postScriptName: faker.string.alpha({ length: { min: 10, max: 20 } }), + source: faker.helpers.arrayElement(Object.values(FontSource)), + })) + +export const getGetGoogleFontsCatalogResponseMock = ( + overrideResponse: Partial> = {}, +): GoogleFontCatalog => ({ + fonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ + category: faker.string.alpha({ length: { min: 10, max: 20 } }), + family: faker.string.alpha({ length: { min: 10, max: 20 } }), + subsets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + variants: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + filename: faker.string.alpha({ length: { min: 10, max: 20 } }), + style: faker.string.alpha({ length: { min: 10, max: 20 } }), + weight: faker.number.int({ min: 0 }), + }), + ), + })), + ...overrideResponse, +}) + +export const getGetGoogleFontFileResponseMock = (): ArrayBuffer => + new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) + +export const getApplyCommandResponseMock = ( + overrideResponse: Partial> = {}, +): HistoryResult => ({ + epoch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getRedoResponseMock = ( + overrideResponse: Partial> = {}, +): HistoryResult => ({ + epoch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getUndoResponseMock = ( + overrideResponse: Partial> = {}, +): HistoryResult => ({ + epoch: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), + undefined, + ]), + ...overrideResponse, +}) + +export const getGetCatalogResponseMock = ( + overrideResponse: Partial> = {}, +): LlmCatalog => ({ + localModels: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.string.alpha({ length: { min: 10, max: 20 } }), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + target: { + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + }), + ), + providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + baseUrl: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + error: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + hasApiKey: faker.datatype.boolean(), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + models: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + languages: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + target: { + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + }, + }), + ), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + requiresApiKey: faker.datatype.boolean(), + requiresBaseUrl: faker.datatype.boolean(), + status: faker.helpers.arrayElement(Object.values(LlmProviderCatalogStatus)), + }), + ), + ...overrideResponse, +}) + +export const getGetCurrentLlmResponseLlmTargetMock = ( + overrideResponse: Partial = {}, +): LlmTarget => ({ + ...{ + kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), + modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), + providerId: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getGetCurrentLlmResponseMock = ( + overrideResponse: Partial> = {}, +): LlmState => ({ + error: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + status: faker.helpers.arrayElement(Object.values(LlmStateStatus)), + target: faker.helpers.arrayElement([ + faker.helpers.arrayElement([null, { ...getGetCurrentLlmResponseLlmTargetMock() }]), + undefined, + ]), + ...overrideResponse, +}) + +export const getGetMetaResponseMock = ( + overrideResponse: Partial> = {}, +): MetaInfo => ({ + mlDevice: faker.string.alpha({ length: { min: 10, max: 20 } }), + version: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getListOperationsResponseMock = ( + overrideResponse: Partial> = {}, +): ListOperationsResponse => ({ + operations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + error: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + kind: faker.string.alpha({ length: { min: 10, max: 20 } }), + status: faker.helpers.arrayElement(Object.values(JobStatus)), + }), + ), + ...overrideResponse, +}) + +export const getCreatePagesResponseMock = ( + overrideResponse: Partial> = {}, +): CreatePagesResponse => ({ + pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + ...overrideResponse, +}) + +export const getCreatePagesFromPathsResponseMock = ( + overrideResponse: Partial> = {}, +): CreatePagesResponse => ({ + pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.string.uuid(), + ), + ...overrideResponse, +}) + +export const getAddImageLayerResponseMock = ( + overrideResponse: Partial> = {}, +): AddImageLayerResponse => ({ node: faker.string.uuid(), ...overrideResponse }) + +export const getPutMaskResponseMock = ( + overrideResponse: Partial> = {}, +): PutMaskResponse => ({ + blob: faker.string.alpha({ length: { min: 10, max: 20 } }), + node: faker.string.uuid(), + ...overrideResponse, +}) + +export const getGetPageThumbnailResponseMock = (): ArrayBuffer => + new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) + +export const getStartPipelineResponseMock = ( + overrideResponse: Partial> = {}, +): StartPipelineResponse => ({ + operationId: faker.string.alpha({ length: { min: 10, max: 20 } }), + ...overrideResponse, +}) + +export const getListProjectsResponseMock = ( + overrideResponse: Partial> = {}, +): ListProjectsResponse => ({ + projects: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + path: faker.string.alpha({ length: { min: 10, max: 20 } }), + updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), + }), + ), + ...overrideResponse, +}) + +export const getCreateProjectResponseMock = ( + overrideResponse: Partial> = {}, +): ProjectSummary => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + path: faker.string.alpha({ length: { min: 10, max: 20 } }), + updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), + ...overrideResponse, +}) + +export const getPutCurrentProjectResponseMock = ( + overrideResponse: Partial> = {}, +): ProjectSummary => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + path: faker.string.alpha({ length: { min: 10, max: 20 } }), + updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), + ...overrideResponse, +}) + +export const getExportCurrentProjectResponseMock = (): ArrayBuffer => + new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) + +export const getImportProjectResponseMock = ( + overrideResponse: Partial> = {}, +): ProjectSummary => ({ + id: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + path: faker.string.alpha({ length: { min: 10, max: 20 } }), + updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), + ...overrideResponse, +}) + +export const getGetSceneBinResponseMock = (): ArrayBuffer => + new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) + +export const getGetSceneJsonResponseFontPredictionMock = ( + overrideResponse: Partial = {}, +): FontPrediction => ({ + ...{ + angleDeg: faker.number.float({ fractionDigits: 2 }), + direction: faker.helpers.arrayElement(Object.values(TextDirection)), + fontSizePx: faker.number.float({ fractionDigits: 2 }), + lineHeight: faker.number.float({ fractionDigits: 2 }), + namedFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + index: faker.number.int({ min: 0 }), + language: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), + undefined, + ]), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + probability: faker.number.float({ fractionDigits: 2 }), + serif: faker.datatype.boolean(), + }), + ), + strokeColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.number.int({ min: 0 }), + ), + strokeWidthPx: faker.number.float({ fractionDigits: 2 }), + textColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => faker.number.int({ min: 0 }), + ), + topFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( + () => ({ + index: faker.number.int({ min: 0 }), + score: faker.number.float({ fractionDigits: 2 }), + }), + ), + }, + ...overrideResponse, +}) + +export const getGetSceneJsonResponseTransformMock = ( + overrideResponse: Partial = {}, +): Transform => ({ + ...{ + height: faker.number.float({ fractionDigits: 2 }), + rotationDeg: faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), undefined]), + width: faker.number.float({ fractionDigits: 2 }), + x: faker.number.float({ fractionDigits: 2 }), + y: faker.number.float({ fractionDigits: 2 }), + }, + ...overrideResponse, +}) + +export const getGetSceneJsonResponseTextShaderEffectMock = ( + overrideResponse: Partial = {}, +): TextShaderEffect => ({ + ...{ + bold: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + italic: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + }, + ...overrideResponse, +}) + +export const getGetSceneJsonResponseTextStrokeStyleMock = ( + overrideResponse: Partial = {}, +): TextStrokeStyle => ({ + ...{ + color: faker.helpers.arrayElement([ + Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: 0 }), + ), + undefined, + ]), + enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + widthPx: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getGetSceneJsonResponseTextStyleMock = ( + overrideResponse: Partial = {}, +): TextStyle => ({ + ...{ + color: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => + faker.number.int({ min: 0 }), + ), + effect: faker.helpers.arrayElement([ + faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextShaderEffectMock() }]), + undefined, + ]), + fontFamilies: Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })), + fontSize: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), + undefined, + ]), + stroke: faker.helpers.arrayElement([ + faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextStrokeStyleMock() }]), + undefined, + ]), + textAlign: faker.helpers.arrayElement([ + faker.helpers.arrayElement([null, faker.helpers.arrayElement(Object.values(TextAlign))]), + undefined, + ]), + }, + ...overrideResponse, +}) + +export const getGetSceneJsonResponseMock = ( + overrideResponse: Partial> = {}, +): SceneSnapshot => ({ + epoch: faker.number.int({ min: 0 }), + scene: { + pages: { + [faker.string.alphanumeric(5)]: { + height: faker.number.int({ min: 0 }), + id: faker.string.uuid(), + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + nodes: { + [faker.string.alphanumeric(5)]: { + id: faker.string.uuid(), + kind: faker.helpers.arrayElement([ + { + image: { + blob: faker.string.alpha({ length: { min: 10, max: 20 } }), + name: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + naturalHeight: faker.number.int({ min: 0 }), + naturalWidth: faker.number.int({ min: 0 }), + opacity: faker.helpers.arrayElement([ + faker.number.float({ fractionDigits: 2 }), + undefined, + ]), + role: faker.helpers.arrayElement(Object.values(ImageRole)), + }, + }, + { + text: { + confidence: faker.helpers.arrayElement([ + faker.number.float({ fractionDigits: 2 }), + undefined, + ]), + detectedFontSizePx: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), + undefined, + ]), + detector: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + fontPrediction: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + { ...getGetSceneJsonResponseFontPredictionMock() }, + ]), + undefined, + ]), + linePolygons: faker.helpers.arrayElement([ + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => + Array.from( + { length: faker.number.int({ min: 1, max: 10 }) }, + (_, i) => i + 1, + ).map(() => faker.number.float({ fractionDigits: 2 })), + ), + ), + undefined, + ]), + lockLayoutBox: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), + renderedDirection: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + faker.helpers.arrayElement(Object.values(TextDirection)), + ]), + undefined, + ]), + rotationDeg: faker.helpers.arrayElement([ + faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), + undefined, + ]), + sourceDirection: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + faker.helpers.arrayElement(Object.values(TextDirection)), + ]), + undefined, + ]), + sourceLang: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + sprite: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + faker.string.alpha({ length: { min: 10, max: 20 } }), + ]), + undefined, + ]), + spriteTransform: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + { ...getGetSceneJsonResponseTransformMock() }, + ]), + undefined, + ]), + style: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + null, + { ...getGetSceneJsonResponseTextStyleMock() }, + ]), + undefined, + ]), + text: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + translation: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + }, + }, + { + mask: { + blob: faker.string.alpha({ length: { min: 10, max: 20 } }), + role: faker.helpers.arrayElement(Object.values(MaskRole)), + }, + }, + ]), + transform: faker.helpers.arrayElement([ + { + height: faker.number.float({ fractionDigits: 2 }), + rotationDeg: faker.helpers.arrayElement([ + faker.number.float({ fractionDigits: 2 }), + undefined, + ]), + width: faker.number.float({ fractionDigits: 2 }), + x: faker.number.float({ fractionDigits: 2 }), + y: faker.number.float({ fractionDigits: 2 }), + }, + undefined, + ]), + visible: faker.datatype.boolean(), + }, + }, + width: faker.number.int({ min: 0 }), + }, + }, + project: { + createdAt: faker.date.past().toISOString().slice(0, 19) + 'Z', + name: faker.string.alpha({ length: { min: 10, max: 20 } }), + style: faker.helpers.arrayElement([ + { + defaultFont: faker.helpers.arrayElement([ + faker.helpers.arrayElement([ + faker.string.alpha({ length: { min: 10, max: 20 } }), + null, + ]), + undefined, + ]), + }, + undefined, + ]), + updatedAt: faker.date.past().toISOString().slice(0, 19) + 'Z', + }, + }, + ...overrideResponse, +}) + +export const getGetBlobMockHandler = ( + overrideResponse?: + | ArrayBuffer + | ((info: Parameters[1]>[0]) => Promise | ArrayBuffer), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/blobs/:hash', + async (info: Parameters[1]>[0]) => { + await delay(0) + + const binaryBody = + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetBlobResponseMock() + return HttpResponse.arrayBuffer( + binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), + { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, + ) + }, + options, + ) +} + +export const getGetConfigMockHandler = ( + overrideResponse?: + | AppConfig + | ((info: Parameters[1]>[0]) => Promise | AppConfig), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/config', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetConfigResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getPatchConfigMockHandler = ( + overrideResponse?: + | AppConfig + | ((info: Parameters[1]>[0]) => Promise | AppConfig), + options?: RequestHandlerOptions, +) => { + return http.patch( + '*/config', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getPatchConfigResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getSetProviderSecretMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.put( + '*/config/providers/:id/secret', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getClearProviderSecretMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.delete( + '*/config/providers/:id/secret', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getListDownloadsMockHandler = ( + overrideResponse?: + | ListDownloadsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ListDownloadsResponse), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/downloads', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getListDownloadsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getStartDownloadMockHandler = ( + overrideResponse?: + | StartDownloadResponse + | (( + info: Parameters[1]>[0], + ) => Promise | StartDownloadResponse), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/downloads', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getStartDownloadResponseMock(), + { status: 202 }, + ) + }, + options, + ) +} + +export const getGetEngineCatalogMockHandler = ( + overrideResponse?: + | EngineCatalog + | (( + info: Parameters[1]>[0], + ) => Promise | EngineCatalog), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/engines', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetEngineCatalogResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getEventsMockHandler = ( + overrideResponse?: + | AppEvent + | ((info: Parameters[1]>[0]) => Promise | AppEvent), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/events', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getEventsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getListFontsMockHandler = ( + overrideResponse?: + | FontFaceInfo[] + | (( + info: Parameters[1]>[0], + ) => Promise | FontFaceInfo[]), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/fonts', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getListFontsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getGetGoogleFontsCatalogMockHandler = ( + overrideResponse?: + | GoogleFontCatalog + | (( + info: Parameters[1]>[0], + ) => Promise | GoogleFontCatalog), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/google-fonts', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetGoogleFontsCatalogResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getFetchGoogleFontMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/google-fonts/:family/fetch', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getGetGoogleFontFileMockHandler = ( + overrideResponse?: + | ArrayBuffer + | ((info: Parameters[1]>[0]) => Promise | ArrayBuffer), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/google-fonts/:family/:file', + async (info: Parameters[1]>[0]) => { + await delay(0) + + const binaryBody = + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetGoogleFontFileResponseMock() + return HttpResponse.arrayBuffer( + binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), + { status: 200, headers: { 'Content-Type': 'font/ttf' } }, + ) + }, + options, + ) +} + +export const getApplyCommandMockHandler = ( + overrideResponse?: + | HistoryResult + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryResult), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/history/apply', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getApplyCommandResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getRedoMockHandler = ( + overrideResponse?: + | HistoryResult + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryResult), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/history/redo', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getRedoResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getUndoMockHandler = ( + overrideResponse?: + | HistoryResult + | (( + info: Parameters[1]>[0], + ) => Promise | HistoryResult), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/history/undo', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getUndoResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getGetCatalogMockHandler = ( + overrideResponse?: + | LlmCatalog + | ((info: Parameters[1]>[0]) => Promise | LlmCatalog), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/llm/catalog', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetCatalogResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getGetCurrentLlmMockHandler = ( + overrideResponse?: + | LlmState + | ((info: Parameters[1]>[0]) => Promise | LlmState), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/llm/current', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetCurrentLlmResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getPutCurrentLlmMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.put( + '*/llm/current', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getDeleteCurrentLlmMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.delete( + '*/llm/current', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getGetMetaMockHandler = ( + overrideResponse?: + | MetaInfo + | ((info: Parameters[1]>[0]) => Promise | MetaInfo), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/meta', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetMetaResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getListOperationsMockHandler = ( + overrideResponse?: + | ListOperationsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ListOperationsResponse), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/operations', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getListOperationsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getCancelOperationMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.delete( + '*/operations/:id', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getCreatePagesMockHandler = ( + overrideResponse?: + | CreatePagesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | CreatePagesResponse), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/pages', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getCreatePagesResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getCreatePagesFromPathsMockHandler = ( + overrideResponse?: + | CreatePagesResponse + | (( + info: Parameters[1]>[0], + ) => Promise | CreatePagesResponse), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/pages/from-paths', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getCreatePagesFromPathsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getAddImageLayerMockHandler = ( + overrideResponse?: + | AddImageLayerResponse + | (( + info: Parameters[1]>[0], + ) => Promise | AddImageLayerResponse), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/pages/:id/image-layers', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getAddImageLayerResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getPutMaskMockHandler = ( + overrideResponse?: + | PutMaskResponse + | (( + info: Parameters[1]>[0], + ) => Promise | PutMaskResponse), + options?: RequestHandlerOptions, +) => { + return http.put( + '*/pages/:id/masks/:role', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getPutMaskResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getGetPageThumbnailMockHandler = ( + overrideResponse?: + | ArrayBuffer + | ((info: Parameters[1]>[0]) => Promise | ArrayBuffer), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/pages/:id/thumbnail', + async (info: Parameters[1]>[0]) => { + await delay(0) + + const binaryBody = + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetPageThumbnailResponseMock() + return HttpResponse.arrayBuffer( + binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), + { status: 200, headers: { 'Content-Type': 'image/webp' } }, + ) + }, + options, + ) +} + +export const getStartPipelineMockHandler = ( + overrideResponse?: + | StartPipelineResponse + | (( + info: Parameters[1]>[0], + ) => Promise | StartPipelineResponse), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/pipelines', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getStartPipelineResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getListProjectsMockHandler = ( + overrideResponse?: + | ListProjectsResponse + | (( + info: Parameters[1]>[0], + ) => Promise | ListProjectsResponse), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/projects', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getListProjectsResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getCreateProjectMockHandler = ( + overrideResponse?: + | ProjectSummary + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectSummary), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/projects', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getCreateProjectResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getPutCurrentProjectMockHandler = ( + overrideResponse?: + | ProjectSummary + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectSummary), + options?: RequestHandlerOptions, +) => { + return http.put( + '*/projects/current', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getPutCurrentProjectResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getDeleteCurrentProjectMockHandler = ( + overrideResponse?: + | void + | ((info: Parameters[1]>[0]) => Promise | void), + options?: RequestHandlerOptions, +) => { + return http.delete( + '*/projects/current', + async (info: Parameters[1]>[0]) => { + await delay(0) + if (typeof overrideResponse === 'function') { + await overrideResponse(info) + } + + return new HttpResponse(null, { status: 204 }) + }, + options, + ) +} + +export const getExportCurrentProjectMockHandler = ( + overrideResponse?: + | ArrayBuffer + | (( + info: Parameters[1]>[0], + ) => Promise | ArrayBuffer), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/projects/current/export', + async (info: Parameters[1]>[0]) => { + await delay(0) + + const binaryBody = + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getExportCurrentProjectResponseMock() + return HttpResponse.arrayBuffer( + binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), + { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, + ) + }, + options, + ) +} + +export const getImportProjectMockHandler = ( + overrideResponse?: + | ProjectSummary + | (( + info: Parameters[1]>[0], + ) => Promise | ProjectSummary), + options?: RequestHandlerOptions, +) => { + return http.post( + '*/projects/import', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getImportProjectResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} + +export const getGetSceneBinMockHandler = ( + overrideResponse?: + | ArrayBuffer + | ((info: Parameters[1]>[0]) => Promise | ArrayBuffer), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/scene.bin', + async (info: Parameters[1]>[0]) => { + await delay(0) + + const binaryBody = + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetSceneBinResponseMock() + return HttpResponse.arrayBuffer( + binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), + { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, + ) + }, + options, + ) +} + +export const getGetSceneJsonMockHandler = ( + overrideResponse?: + | SceneSnapshot + | (( + info: Parameters[1]>[0], + ) => Promise | SceneSnapshot), + options?: RequestHandlerOptions, +) => { + return http.get( + '*/scene.json', + async (info: Parameters[1]>[0]) => { + await delay(0) + + return HttpResponse.json( + overrideResponse !== undefined + ? typeof overrideResponse === 'function' + ? await overrideResponse(info) + : overrideResponse + : getGetSceneJsonResponseMock(), + { status: 200 }, + ) + }, + options, + ) +} +export const getDefaultMock = () => [ + getGetBlobMockHandler(), + getGetConfigMockHandler(), + getPatchConfigMockHandler(), + getSetProviderSecretMockHandler(), + getClearProviderSecretMockHandler(), + getListDownloadsMockHandler(), + getStartDownloadMockHandler(), + getGetEngineCatalogMockHandler(), + getEventsMockHandler(), + getListFontsMockHandler(), + getGetGoogleFontsCatalogMockHandler(), + getFetchGoogleFontMockHandler(), + getGetGoogleFontFileMockHandler(), + getApplyCommandMockHandler(), + getRedoMockHandler(), + getUndoMockHandler(), + getGetCatalogMockHandler(), + getGetCurrentLlmMockHandler(), + getPutCurrentLlmMockHandler(), + getDeleteCurrentLlmMockHandler(), + getGetMetaMockHandler(), + getListOperationsMockHandler(), + getCancelOperationMockHandler(), + getCreatePagesMockHandler(), + getCreatePagesFromPathsMockHandler(), + getAddImageLayerMockHandler(), + getPutMaskMockHandler(), + getGetPageThumbnailMockHandler(), + getStartPipelineMockHandler(), + getListProjectsMockHandler(), + getCreateProjectMockHandler(), + getPutCurrentProjectMockHandler(), + getDeleteCurrentProjectMockHandler(), + getExportCurrentProjectMockHandler(), + getImportProjectMockHandler(), + getGetSceneBinMockHandler(), + getGetSceneJsonMockHandler(), +] diff --git a/ui/lib/api/default/default.ts b/ui/lib/api/default/default.ts new file mode 100644 index 0000000000000000000000000000000000000000..bd703efd9173bfcced0c19ca8dbe4c7aaff59db2 --- /dev/null +++ b/ui/lib/api/default/default.ts @@ -0,0 +1,3095 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import { useMutation, useQuery } from '@tanstack/react-query' +import type { + DataTag, + DefinedInitialDataOptions, + DefinedUseQueryResult, + MutationFunction, + QueryClient, + QueryFunction, + QueryKey, + UndefinedInitialDataOptions, + UseMutationOptions, + UseMutationResult, + UseQueryOptions, + UseQueryResult, +} from '@tanstack/react-query' + +import { fetchApi } from '.././fetch' +import type { + AddImageLayerResponse, + AppConfig, + AppEvent, + ConfigPatch, + CreatePagesFromPathsRequest, + CreatePagesResponse, + CreateProjectRequest, + EngineCatalog, + ExportProjectRequest, + FontFaceInfo, + GoogleFontCatalog, + HistoryResult, + ListDownloadsResponse, + ListOperationsResponse, + ListProjectsResponse, + LlmCatalog, + LlmLoadRequest, + LlmState, + MaskRole, + MetaInfo, + Op, + OpenProjectRequest, + PageId, + ProjectSummary, + ProviderSecretRequest, + PutMaskResponse, + SceneSnapshot, + StartDownloadRequest, + StartDownloadResponse, + StartPipelineRequest, + StartPipelineResponse, +} from '../schemas' + +type SecondParameter unknown> = Parameters[1] + +export const getGetBlobUrl = (hash: string) => { + return `/api/v1/blobs/${hash}` +} + +export const getBlob = async (hash: string, options?: RequestInit): Promise => { + return fetchApi(getGetBlobUrl(hash), { + ...options, + method: 'GET', + }) +} + +export const getGetBlobQueryKey = (hash: string) => { + return [`/api/v1/blobs/${hash}`] as const +} + +export const getGetBlobQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetBlobQueryKey(hash) + + const queryFn: QueryFunction>> = ({ signal }) => + getBlob(hash, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!hash, + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetBlobQueryResult = NonNullable>> +export type GetBlobQueryError = unknown + +export function useGetBlob>, TError = unknown>( + hash: string, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetBlob>, TError = unknown>( + hash: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetBlobQueryOptions(hash, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetConfigUrl = () => { + return `/api/v1/config` +} + +export const getConfig = async (options?: RequestInit): Promise => { + return fetchApi(getGetConfigUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetConfigQueryKey = () => { + return [`/api/v1/config`] as const +} + +export const getGetConfigQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetConfigQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getConfig({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetConfigQueryResult = NonNullable>> +export type GetConfigQueryError = unknown + +export function useGetConfig>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetConfig>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetConfigQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getPatchConfigUrl = () => { + return `/api/v1/config` +} + +export const patchConfig = async ( + configPatch: ConfigPatch, + options?: RequestInit, +): Promise => { + return fetchApi(getPatchConfigUrl(), { + ...options, + method: 'PATCH', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(configPatch), + }) +} + +export const getPatchConfigMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext +> => { + const mutationKey = ['patchConfig'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ConfigPatch } + > = (props) => { + const { data } = props ?? {} + + return patchConfig(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PatchConfigMutationResult = NonNullable>> +export type PatchConfigMutationBody = ConfigPatch +export type PatchConfigMutationError = unknown + +export const usePatchConfig = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ConfigPatch }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: ConfigPatch }, + TContext +> => { + return useMutation(getPatchConfigMutationOptions(options), queryClient) +} +/** + * @summary Save (or overwrite) the keyring secret for a provider. Creates the +provider entry in `config.providers` if it didn't exist. `PUT` because +setting the secret is idempotent for the same body. + */ +export const getSetProviderSecretUrl = (id: string) => { + return `/api/v1/config/providers/${id}/secret` +} + +export const setProviderSecret = async ( + id: string, + providerSecretRequest: ProviderSecretRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getSetProviderSecretUrl(id), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(providerSecretRequest), + }) +} + +export const getSetProviderSecretMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext +> => { + const mutationKey = ['setProviderSecret'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { id: string; data: ProviderSecretRequest } + > = (props) => { + const { id, data } = props ?? {} + + return setProviderSecret(id, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type SetProviderSecretMutationResult = NonNullable< + Awaited> +> +export type SetProviderSecretMutationBody = ProviderSecretRequest +export type SetProviderSecretMutationError = unknown + +/** + * @summary Save (or overwrite) the keyring secret for a provider. Creates the +provider entry in `config.providers` if it didn't exist. `PUT` because +setting the secret is idempotent for the same body. + */ +export const useSetProviderSecret = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string; data: ProviderSecretRequest }, + TContext +> => { + return useMutation(getSetProviderSecretMutationOptions(options), queryClient) +} +/** + * @summary Clear a provider's keyring secret. The provider entry itself is kept. + */ +export const getClearProviderSecretUrl = (id: string) => { + return `/api/v1/config/providers/${id}/secret` +} + +export const clearProviderSecret = async (id: string, options?: RequestInit): Promise => { + return fetchApi(getClearProviderSecretUrl(id), { + ...options, + method: 'DELETE', + }) +} + +export const getClearProviderSecretMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext +> => { + const mutationKey = ['clearProviderSecret'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { id: string } + > = (props) => { + const { id } = props ?? {} + + return clearProviderSecret(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ClearProviderSecretMutationResult = NonNullable< + Awaited> +> + +export type ClearProviderSecretMutationError = unknown + +/** + * @summary Clear a provider's keyring secret. The provider entry itself is kept. + */ +export const useClearProviderSecret = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string }, + TContext +> => { + return useMutation(getClearProviderSecretMutationOptions(options), queryClient) +} +export const getListDownloadsUrl = () => { + return `/api/v1/downloads` +} + +export const listDownloads = async (options?: RequestInit): Promise => { + return fetchApi(getListDownloadsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListDownloadsQueryKey = () => { + return [`/api/v1/downloads`] as const +} + +export const getListDownloadsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListDownloadsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listDownloads({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListDownloadsQueryResult = NonNullable>> +export type ListDownloadsQueryError = unknown + +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListDownloads< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListDownloadsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getStartDownloadUrl = () => { + return `/api/v1/downloads` +} + +export const startDownload = async ( + startDownloadRequest: StartDownloadRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getStartDownloadUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(startDownloadRequest), + }) +} + +export const getStartDownloadMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext +> => { + const mutationKey = ['startDownload'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: StartDownloadRequest } + > = (props) => { + const { data } = props ?? {} + + return startDownload(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type StartDownloadMutationResult = NonNullable>> +export type StartDownloadMutationBody = StartDownloadRequest +export type StartDownloadMutationError = unknown + +export const useStartDownload = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: StartDownloadRequest }, + TContext +> => { + return useMutation(getStartDownloadMutationOptions(options), queryClient) +} +export const getGetEngineCatalogUrl = () => { + return `/api/v1/engines` +} + +export const getEngineCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetEngineCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetEngineCatalogQueryKey = () => { + return [`/api/v1/engines`] as const +} + +export const getGetEngineCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetEngineCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getEngineCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetEngineCatalogQueryResult = NonNullable>> +export type GetEngineCatalogQueryError = unknown + +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetEngineCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetEngineCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getEventsUrl = () => { + return `/api/v1/events` +} + +export const events = async (options?: RequestInit): Promise => { + return fetchApi(getEventsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getEventsQueryKey = () => { + return [`/api/v1/events`] as const +} + +export const getEventsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getEventsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + events({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type EventsQueryResult = NonNullable>> +export type EventsQueryError = unknown + +export function useEvents>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useEvents>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getEventsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getListFontsUrl = () => { + return `/api/v1/fonts` +} + +export const listFonts = async (options?: RequestInit): Promise => { + return fetchApi(getListFontsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListFontsQueryKey = () => { + return [`/api/v1/fonts`] as const +} + +export const getListFontsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListFontsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listFonts({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListFontsQueryResult = NonNullable>> +export type ListFontsQueryError = unknown + +export function useListFonts>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListFonts>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListFontsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetGoogleFontsCatalogUrl = () => { + return `/api/v1/google-fonts` +} + +export const getGoogleFontsCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetGoogleFontsCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetGoogleFontsCatalogQueryKey = () => { + return [`/api/v1/google-fonts`] as const +} + +export const getGetGoogleFontsCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetGoogleFontsCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getGoogleFontsCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetGoogleFontsCatalogQueryResult = NonNullable< + Awaited> +> +export type GetGoogleFontsCatalogQueryError = unknown + +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetGoogleFontsCatalog< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial< + UseQueryOptions>, TError, TData> + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetGoogleFontsCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getFetchGoogleFontUrl = (family: string) => { + return `/api/v1/google-fonts/${family}/fetch` +} + +export const fetchGoogleFont = async (family: string, options?: RequestInit): Promise => { + return fetchApi(getFetchGoogleFontUrl(family), { + ...options, + method: 'POST', + }) +} + +export const getFetchGoogleFontMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext +> => { + const mutationKey = ['fetchGoogleFont'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { family: string } + > = (props) => { + const { family } = props ?? {} + + return fetchGoogleFont(family, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type FetchGoogleFontMutationResult = NonNullable>> + +export type FetchGoogleFontMutationError = unknown + +export const useFetchGoogleFont = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { family: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { family: string }, + TContext +> => { + return useMutation(getFetchGoogleFontMutationOptions(options), queryClient) +} +export const getGetGoogleFontFileUrl = (family: string, file: string) => { + return `/api/v1/google-fonts/${family}/${file}` +} + +export const getGoogleFontFile = async ( + family: string, + file: string, + options?: RequestInit, +): Promise => { + return fetchApi(getGetGoogleFontFileUrl(family, file), { + ...options, + method: 'GET', + }) +} + +export const getGetGoogleFontFileQueryKey = (family: string, file: string) => { + return [`/api/v1/google-fonts/${family}/${file}`] as const +} + +export const getGetGoogleFontFileQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetGoogleFontFileQueryKey(family, file) + + const queryFn: QueryFunction>> = ({ signal }) => + getGoogleFontFile(family, file, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!(family && file), + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetGoogleFontFileQueryResult = NonNullable< + Awaited> +> +export type GetGoogleFontFileQueryError = unknown + +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetGoogleFontFile< + TData = Awaited>, + TError = unknown, +>( + family: string, + file: string, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetGoogleFontFileQueryOptions(family, file, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getApplyCommandUrl = () => { + return `/api/v1/history/apply` +} + +export const applyCommand = async (op: Op, options?: RequestInit): Promise => { + return fetchApi(getApplyCommandUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(op), + }) +} + +export const getApplyCommandMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext +> => { + const mutationKey = ['applyCommand'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { data: Op }> = ( + props, + ) => { + const { data } = props ?? {} + + return applyCommand(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ApplyCommandMutationResult = NonNullable>> +export type ApplyCommandMutationBody = Op +export type ApplyCommandMutationError = unknown + +export const useApplyCommand = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: Op }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, { data: Op }, TContext> => { + return useMutation(getApplyCommandMutationOptions(options), queryClient) +} +export const getRedoUrl = () => { + return `/api/v1/history/redo` +} + +export const redo = async (options?: RequestInit): Promise => { + return fetchApi(getRedoUrl(), { + ...options, + method: 'POST', + }) +} + +export const getRedoMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['redo'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return redo(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type RedoMutationResult = NonNullable>> + +export type RedoMutationError = unknown + +export const useRedo = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getRedoMutationOptions(options), queryClient) +} +export const getUndoUrl = () => { + return `/api/v1/history/undo` +} + +export const undo = async (options?: RequestInit): Promise => { + return fetchApi(getUndoUrl(), { + ...options, + method: 'POST', + }) +} + +export const getUndoMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['undo'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return undo(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type UndoMutationResult = NonNullable>> + +export type UndoMutationError = unknown + +export const useUndo = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getUndoMutationOptions(options), queryClient) +} +export const getGetCatalogUrl = () => { + return `/api/v1/llm/catalog` +} + +export const getCatalog = async (options?: RequestInit): Promise => { + return fetchApi(getGetCatalogUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetCatalogQueryKey = () => { + return [`/api/v1/llm/catalog`] as const +} + +export const getGetCatalogQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetCatalogQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getCatalog({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetCatalogQueryResult = NonNullable>> +export type GetCatalogQueryError = unknown + +export function useGetCatalog>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetCatalog>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetCatalogQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const getCurrentLlm = async (options?: RequestInit): Promise => { + return fetchApi(getGetCurrentLlmUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetCurrentLlmQueryKey = () => { + return [`/api/v1/llm/current`] as const +} + +export const getGetCurrentLlmQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetCurrentLlmQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getCurrentLlm({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetCurrentLlmQueryResult = NonNullable>> +export type GetCurrentLlmQueryError = unknown + +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetCurrentLlm< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetCurrentLlmQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getPutCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const putCurrentLlm = async ( + llmLoadRequest: LlmLoadRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getPutCurrentLlmUrl(), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(llmLoadRequest), + }) +} + +export const getPutCurrentLlmMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext +> => { + const mutationKey = ['putCurrentLlm'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: LlmLoadRequest } + > = (props) => { + const { data } = props ?? {} + + return putCurrentLlm(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutCurrentLlmMutationResult = NonNullable>> +export type PutCurrentLlmMutationBody = LlmLoadRequest +export type PutCurrentLlmMutationError = unknown + +export const usePutCurrentLlm = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: LlmLoadRequest }, + TContext +> => { + return useMutation(getPutCurrentLlmMutationOptions(options), queryClient) +} +export const getDeleteCurrentLlmUrl = () => { + return `/api/v1/llm/current` +} + +export const deleteCurrentLlm = async (options?: RequestInit): Promise => { + return fetchApi(getDeleteCurrentLlmUrl(), { + ...options, + method: 'DELETE', + }) +} + +export const getDeleteCurrentLlmMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['deleteCurrentLlm'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return deleteCurrentLlm(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type DeleteCurrentLlmMutationResult = NonNullable< + Awaited> +> + +export type DeleteCurrentLlmMutationError = unknown + +export const useDeleteCurrentLlm = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getDeleteCurrentLlmMutationOptions(options), queryClient) +} +export const getGetMetaUrl = () => { + return `/api/v1/meta` +} + +export const getMeta = async (options?: RequestInit): Promise => { + return fetchApi(getGetMetaUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetMetaQueryKey = () => { + return [`/api/v1/meta`] as const +} + +export const getGetMetaQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetMetaQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getMeta({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetMetaQueryResult = NonNullable>> +export type GetMetaQueryError = unknown + +export function useGetMeta>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetMeta>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetMetaQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getListOperationsUrl = () => { + return `/api/v1/operations` +} + +export const listOperations = async (options?: RequestInit): Promise => { + return fetchApi(getListOperationsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListOperationsQueryKey = () => { + return [`/api/v1/operations`] as const +} + +export const getListOperationsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListOperationsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listOperations({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListOperationsQueryResult = NonNullable>> +export type ListOperationsQueryError = unknown + +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListOperations< + TData = Awaited>, + TError = unknown, +>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListOperationsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getCancelOperationUrl = (id: string) => { + return `/api/v1/operations/${id}` +} + +export const cancelOperation = async (id: string, options?: RequestInit): Promise => { + return fetchApi(getCancelOperationUrl(id), { + ...options, + method: 'DELETE', + }) +} + +export const getCancelOperationMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext +> => { + const mutationKey = ['cancelOperation'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { id: string } + > = (props) => { + const { id } = props ?? {} + + return cancelOperation(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CancelOperationMutationResult = NonNullable>> + +export type CancelOperationMutationError = unknown + +export const useCancelOperation = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: string }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: string }, + TContext +> => { + return useMutation(getCancelOperationMutationOptions(options), queryClient) +} +export const getCreatePagesUrl = () => { + return `/api/v1/pages` +} + +export const createPages = async (options?: RequestInit): Promise => { + return fetchApi(getCreatePagesUrl(), { + ...options, + method: 'POST', + }) +} + +export const getCreatePagesMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['createPages'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return createPages(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreatePagesMutationResult = NonNullable>> + +export type CreatePagesMutationError = unknown + +export const useCreatePages = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getCreatePagesMutationOptions(options), queryClient) +} +/** + * Web clients should keep using `POST /pages` with multipart. + * @summary Create pages by reading image files from absolute paths on the server's +filesystem. This is the Tauri desktop import path — the webview picker +returns paths, and the backend reads + decodes + hashes them in parallel +without a round-trip through JS memory or a multipart upload body. + */ +export const getCreatePagesFromPathsUrl = () => { + return `/api/v1/pages/from-paths` +} + +export const createPagesFromPaths = async ( + createPagesFromPathsRequest: CreatePagesFromPathsRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getCreatePagesFromPathsUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createPagesFromPathsRequest), + }) +} + +export const getCreatePagesFromPathsMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext +> => { + const mutationKey = ['createPagesFromPaths'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: CreatePagesFromPathsRequest } + > = (props) => { + const { data } = props ?? {} + + return createPagesFromPaths(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreatePagesFromPathsMutationResult = NonNullable< + Awaited> +> +export type CreatePagesFromPathsMutationBody = CreatePagesFromPathsRequest +export type CreatePagesFromPathsMutationError = unknown + +/** + * @summary Create pages by reading image files from absolute paths on the server's +filesystem. This is the Tauri desktop import path — the webview picker +returns paths, and the backend reads + decodes + hashes them in parallel +without a round-trip through JS memory or a multipart upload body. + */ +export const useCreatePagesFromPaths = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: CreatePagesFromPathsRequest }, + TContext +> => { + return useMutation(getCreatePagesFromPathsMutationOptions(options), queryClient) +} +export const getAddImageLayerUrl = (id: PageId) => { + return `/api/v1/pages/${id}/image-layers` +} + +export const addImageLayer = async ( + id: PageId, + options?: RequestInit, +): Promise => { + return fetchApi(getAddImageLayerUrl(id), { + ...options, + method: 'POST', + }) +} + +export const getAddImageLayerMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext +> => { + const mutationKey = ['addImageLayer'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, { id: PageId }> = ( + props, + ) => { + const { id } = props ?? {} + + return addImageLayer(id, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type AddImageLayerMutationResult = NonNullable>> + +export type AddImageLayerMutationError = unknown + +export const useAddImageLayer = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: PageId }, + TContext +> => { + return useMutation(getAddImageLayerMutationOptions(options), queryClient) +} +/** + * @summary Upsert the `Mask { role }` node on a page with the raw image bytes in +the body. Emits `Op::UpdateNode` if a mask of that role exists, else +`Op::AddNode`. Used by the repair-brush / segment-edit flow; the +follow-up localized inpaint is a separate `POST /pipelines` call. + */ +export const getPutMaskUrl = (id: PageId, role: MaskRole) => { + return `/api/v1/pages/${id}/masks/${role}` +} + +export const putMask = async ( + id: PageId, + role: MaskRole, + putMaskBody: Blob, + options?: RequestInit, +): Promise => { + return fetchApi(getPutMaskUrl(id, role), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'image/png', ...options?.headers }, + body: JSON.stringify(putMaskBody), + }) +} + +export const getPutMaskMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext +> => { + const mutationKey = ['putMask'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { id: PageId; role: MaskRole; data: Blob } + > = (props) => { + const { id, role, data } = props ?? {} + + return putMask(id, role, data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutMaskMutationResult = NonNullable>> +export type PutMaskMutationBody = Blob +export type PutMaskMutationError = unknown + +/** + * @summary Upsert the `Mask { role }` node on a page with the raw image bytes in +the body. Emits `Op::UpdateNode` if a mask of that role exists, else +`Op::AddNode`. Used by the repair-brush / segment-edit flow; the +follow-up localized inpaint is a separate `POST /pipelines` call. + */ +export const usePutMask = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { id: PageId; role: MaskRole; data: Blob }, + TContext +> => { + return useMutation(getPutMaskMutationOptions(options), queryClient) +} +export const getGetPageThumbnailUrl = (id: PageId) => { + return `/api/v1/pages/${id}/thumbnail` +} + +export const getPageThumbnail = async (id: PageId, options?: RequestInit): Promise => { + return fetchApi(getGetPageThumbnailUrl(id), { + ...options, + method: 'GET', + }) +} + +export const getGetPageThumbnailQueryKey = (id: PageId) => { + return [`/api/v1/pages/${id}/thumbnail`] as const +} + +export const getGetPageThumbnailQueryOptions = < + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, +) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetPageThumbnailQueryKey(id) + + const queryFn: QueryFunction>> = ({ signal }) => + getPageThumbnail(id, { signal, ...requestOptions }) + + return { + queryKey, + queryFn, + enabled: !!id, + gcTime: 300000, + retry: 1, + ...queryOptions, + } as UseQueryOptions>, TError, TData> & { + queryKey: DataTag + } +} + +export type GetPageThumbnailQueryResult = NonNullable>> +export type GetPageThumbnailQueryError = unknown + +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetPageThumbnail< + TData = Awaited>, + TError = unknown, +>( + id: PageId, + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetPageThumbnailQueryOptions(id, options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getStartPipelineUrl = () => { + return `/api/v1/pipelines` +} + +export const startPipeline = async ( + startPipelineRequest: StartPipelineRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getStartPipelineUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(startPipelineRequest), + }) +} + +export const getStartPipelineMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext +> => { + const mutationKey = ['startPipeline'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: StartPipelineRequest } + > = (props) => { + const { data } = props ?? {} + + return startPipeline(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type StartPipelineMutationResult = NonNullable>> +export type StartPipelineMutationBody = StartPipelineRequest +export type StartPipelineMutationError = unknown + +export const useStartPipeline = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: StartPipelineRequest }, + TContext +> => { + return useMutation(getStartPipelineMutationOptions(options), queryClient) +} +export const getListProjectsUrl = () => { + return `/api/v1/projects` +} + +export const listProjects = async (options?: RequestInit): Promise => { + return fetchApi(getListProjectsUrl(), { + ...options, + method: 'GET', + }) +} + +export const getListProjectsQueryKey = () => { + return [`/api/v1/projects`] as const +} + +export const getListProjectsQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getListProjectsQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + listProjects({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type ListProjectsQueryResult = NonNullable>> +export type ListProjectsQueryError = unknown + +export function useListProjects>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useListProjects>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getListProjectsQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getCreateProjectUrl = () => { + return `/api/v1/projects` +} + +export const createProject = async ( + createProjectRequest: CreateProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getCreateProjectUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(createProjectRequest), + }) +} + +export const getCreateProjectMutationOptions = (options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext +> => { + const mutationKey = ['createProject'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: CreateProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return createProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type CreateProjectMutationResult = NonNullable>> +export type CreateProjectMutationBody = CreateProjectRequest +export type CreateProjectMutationError = unknown + +export const useCreateProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: CreateProjectRequest }, + TContext +> => { + return useMutation(getCreateProjectMutationOptions(options), queryClient) +} +export const getPutCurrentProjectUrl = () => { + return `/api/v1/projects/current` +} + +export const putCurrentProject = async ( + openProjectRequest: OpenProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getPutCurrentProjectUrl(), { + ...options, + method: 'PUT', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(openProjectRequest), + }) +} + +export const getPutCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext +> => { + const mutationKey = ['putCurrentProject'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: OpenProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return putCurrentProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type PutCurrentProjectMutationResult = NonNullable< + Awaited> +> +export type PutCurrentProjectMutationBody = OpenProjectRequest +export type PutCurrentProjectMutationError = unknown + +export const usePutCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: OpenProjectRequest }, + TContext +> => { + return useMutation(getPutCurrentProjectMutationOptions(options), queryClient) +} +export const getDeleteCurrentProjectUrl = () => { + return `/api/v1/projects/current` +} + +export const deleteCurrentProject = async (options?: RequestInit): Promise => { + return fetchApi(getDeleteCurrentProjectUrl(), { + ...options, + method: 'DELETE', + }) +} + +export const getDeleteCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + void, + TContext +> => { + const mutationKey = ['deleteCurrentProject'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + void + > = () => { + return deleteCurrentProject(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type DeleteCurrentProjectMutationResult = NonNullable< + Awaited> +> + +export type DeleteCurrentProjectMutationError = unknown + +export const useDeleteCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + void, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getDeleteCurrentProjectMutationOptions(options), queryClient) +} +export const getExportCurrentProjectUrl = () => { + return `/api/v1/projects/current/export` +} + +export const exportCurrentProject = async ( + exportProjectRequest: ExportProjectRequest, + options?: RequestInit, +): Promise => { + return fetchApi(getExportCurrentProjectUrl(), { + ...options, + method: 'POST', + headers: { 'Content-Type': 'application/json', ...options?.headers }, + body: JSON.stringify(exportProjectRequest), + }) +} + +export const getExportCurrentProjectMutationOptions = < + TError = unknown, + TContext = unknown, +>(options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext + > + request?: SecondParameter +}): UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext +> => { + const mutationKey = ['exportCurrentProject'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction< + Awaited>, + { data: ExportProjectRequest } + > = (props) => { + const { data } = props ?? {} + + return exportCurrentProject(data, requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ExportCurrentProjectMutationResult = NonNullable< + Awaited> +> +export type ExportCurrentProjectMutationBody = ExportProjectRequest +export type ExportCurrentProjectMutationError = unknown + +export const useExportCurrentProject = ( + options?: { + mutation?: UseMutationOptions< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult< + Awaited>, + TError, + { data: ExportProjectRequest }, + TContext +> => { + return useMutation(getExportCurrentProjectMutationOptions(options), queryClient) +} +export const getImportProjectUrl = () => { + return `/api/v1/projects/import` +} + +export const importProject = async (options?: RequestInit): Promise => { + return fetchApi(getImportProjectUrl(), { + ...options, + method: 'POST', + }) +} + +export const getImportProjectMutationOptions = (options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter +}): UseMutationOptions>, TError, void, TContext> => { + const mutationKey = ['importProject'] + const { mutation: mutationOptions, request: requestOptions } = options + ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey + ? options + : { ...options, mutation: { ...options.mutation, mutationKey } } + : { mutation: { mutationKey }, request: undefined } + + const mutationFn: MutationFunction>, void> = () => { + return importProject(requestOptions) + } + + return { mutationFn, ...mutationOptions } +} + +export type ImportProjectMutationResult = NonNullable>> + +export type ImportProjectMutationError = unknown + +export const useImportProject = ( + options?: { + mutation?: UseMutationOptions>, TError, void, TContext> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseMutationResult>, TError, void, TContext> => { + return useMutation(getImportProjectMutationOptions(options), queryClient) +} +export const getGetSceneBinUrl = () => { + return `/api/v1/scene.bin` +} + +export const getSceneBin = async (options?: RequestInit): Promise => { + return fetchApi(getGetSceneBinUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetSceneBinQueryKey = () => { + return [`/api/v1/scene.bin`] as const +} + +export const getGetSceneBinQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetSceneBinQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getSceneBin({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetSceneBinQueryResult = NonNullable>> +export type GetSceneBinQueryError = unknown + +export function useGetSceneBin>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetSceneBin>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetSceneBinQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} + +export const getGetSceneJsonUrl = () => { + return `/api/v1/scene.json` +} + +export const getSceneJson = async (options?: RequestInit): Promise => { + return fetchApi(getGetSceneJsonUrl(), { + ...options, + method: 'GET', + }) +} + +export const getGetSceneJsonQueryKey = () => { + return [`/api/v1/scene.json`] as const +} + +export const getGetSceneJsonQueryOptions = < + TData = Awaited>, + TError = unknown, +>(options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter +}) => { + const { query: queryOptions, request: requestOptions } = options ?? {} + + const queryKey = queryOptions?.queryKey ?? getGetSceneJsonQueryKey() + + const queryFn: QueryFunction>> = ({ signal }) => + getSceneJson({ signal, ...requestOptions }) + + return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< + Awaited>, + TError, + TData + > & { queryKey: DataTag } +} + +export type GetSceneJsonQueryResult = NonNullable>> +export type GetSceneJsonQueryError = unknown + +export function useGetSceneJson>, TError = unknown>( + options: { + query: Partial>, TError, TData>> & + Pick< + DefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): DefinedUseQueryResult & { queryKey: DataTag } +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> & + Pick< + UndefinedInitialDataOptions< + Awaited>, + TError, + Awaited> + >, + 'initialData' + > + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } + +export function useGetSceneJson>, TError = unknown>( + options?: { + query?: Partial>, TError, TData>> + request?: SecondParameter + }, + queryClient?: QueryClient, +): UseQueryResult & { queryKey: DataTag } { + const queryOptions = getGetSceneJsonQueryOptions(options) + + const query = useQuery(queryOptions, queryClient) as UseQueryResult & { + queryKey: DataTag + } + + return { ...query, queryKey: queryOptions.queryKey } +} diff --git a/ui/lib/api/documents/documents.ts b/ui/lib/api/documents/documents.ts deleted file mode 100644 index 8193ac37bce055346e2a9941e36cc760609b1250..0000000000000000000000000000000000000000 --- a/ui/lib/api/documents/documents.ts +++ /dev/null @@ -1,646 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { - ApiError, - DocumentDetail, - DocumentSummary, - GetDocumentThumbnailParams, - ImportDocumentsBody, - ImportDocumentsParams, - ImportResult, - ReorderRequest, - UpdateDocumentStyleRequest, -} from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getListDocumentsUrl = () => { - return `/api/v1/documents` -} - -export const listDocuments = async (options?: RequestInit): Promise => { - return fetchApi(getListDocumentsUrl(), { - ...options, - method: 'GET', - }) -} - -export const getListDocumentsQueryKey = () => { - return [`/api/v1/documents`] as const -} - -export const getListDocumentsQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getListDocumentsQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - listDocuments({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type ListDocumentsQueryResult = NonNullable>> -export type ListDocumentsQueryError = ApiError - -export function useListDocuments< - TData = Awaited>, - TError = ApiError, ->( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useListDocuments< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useListDocuments< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useListDocuments< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getListDocumentsQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getImportDocumentsUrl = (params?: ImportDocumentsParams) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v1/documents?${stringifiedParams}` - : `/api/v1/documents` -} - -export const importDocuments = async ( - importDocumentsBody: ImportDocumentsBody, - params?: ImportDocumentsParams, - options?: RequestInit, -): Promise => { - const formData = new FormData() - importDocumentsBody.files.forEach((value) => formData.append(`files`, value)) - - return fetchApi(getImportDocumentsUrl(params), { - ...options, - method: 'POST', - body: formData, - }) -} - -export const getImportDocumentsMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportDocumentsBody; params?: ImportDocumentsParams }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ImportDocumentsBody; params?: ImportDocumentsParams }, - TContext -> => { - const mutationKey = ['importDocuments'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ImportDocumentsBody; params?: ImportDocumentsParams } - > = (props) => { - const { data, params } = props ?? {} - - return importDocuments(data, params, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ImportDocumentsMutationResult = NonNullable>> -export type ImportDocumentsMutationBody = ImportDocumentsBody -export type ImportDocumentsMutationError = ApiError - -export const useImportDocuments = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ImportDocumentsBody; params?: ImportDocumentsParams }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: ImportDocumentsBody; params?: ImportDocumentsParams }, - TContext -> => { - return useMutation(getImportDocumentsMutationOptions(options), queryClient) -} -export const getReorderDocumentsUrl = () => { - return `/api/v1/documents/order` -} - -export const reorderDocuments = async ( - reorderRequest: ReorderRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getReorderDocumentsUrl(), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(reorderRequest), - }) -} - -export const getReorderDocumentsMutationOptions = < - TError = ApiError, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReorderRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ReorderRequest }, - TContext -> => { - const mutationKey = ['reorderDocuments'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ReorderRequest } - > = (props) => { - const { data } = props ?? {} - - return reorderDocuments(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type ReorderDocumentsMutationResult = NonNullable< - Awaited> -> -export type ReorderDocumentsMutationBody = ReorderRequest -export type ReorderDocumentsMutationError = ApiError - -export const useReorderDocuments = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ReorderRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: ReorderRequest }, - TContext -> => { - return useMutation(getReorderDocumentsMutationOptions(options), queryClient) -} -export const getGetDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}` -} - -export const getDocument = async ( - documentId: string, - options?: RequestInit, -): Promise => { - return fetchApi(getGetDocumentUrl(documentId), { - ...options, - method: 'GET', - }) -} - -export const getGetDocumentQueryKey = (documentId: string) => { - return [`/api/v1/documents/${documentId}`] as const -} - -export const getGetDocumentQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetDocumentQueryKey(documentId) - - const queryFn: QueryFunction>> = ({ signal }) => - getDocument(documentId, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!documentId, - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type GetDocumentQueryResult = NonNullable>> -export type GetDocumentQueryError = ApiError - -export function useGetDocument>, TError = ApiError>( - documentId: string, - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetDocument>, TError = ApiError>( - documentId: string, - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetDocument>, TError = ApiError>( - documentId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetDocument>, TError = ApiError>( - documentId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetDocumentQueryOptions(documentId, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getUpdateDocumentStyleUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/style` -} - -export const updateDocumentStyle = async ( - documentId: string, - updateDocumentStyleRequest: UpdateDocumentStyleRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getUpdateDocumentStyleUrl(documentId), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(updateDocumentStyleRequest), - }) -} - -export const getUpdateDocumentStyleMutationOptions = < - TError = ApiError, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: UpdateDocumentStyleRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: UpdateDocumentStyleRequest }, - TContext -> => { - const mutationKey = ['updateDocumentStyle'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: UpdateDocumentStyleRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return updateDocumentStyle(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type UpdateDocumentStyleMutationResult = NonNullable< - Awaited> -> -export type UpdateDocumentStyleMutationBody = UpdateDocumentStyleRequest -export type UpdateDocumentStyleMutationError = ApiError - -export const useUpdateDocumentStyle = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: UpdateDocumentStyleRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: UpdateDocumentStyleRequest }, - TContext -> => { - return useMutation(getUpdateDocumentStyleMutationOptions(options), queryClient) -} -export const getGetDocumentThumbnailUrl = ( - documentId: string, - params?: GetDocumentThumbnailParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v1/documents/${documentId}/thumbnail?${stringifiedParams}` - : `/api/v1/documents/${documentId}/thumbnail` -} - -export const getDocumentThumbnail = async ( - documentId: string, - params?: GetDocumentThumbnailParams, - options?: RequestInit, -): Promise => { - return fetchApi(getGetDocumentThumbnailUrl(documentId, params), { - ...options, - method: 'GET', - }) -} - -export const getGetDocumentThumbnailQueryKey = ( - documentId: string, - params?: GetDocumentThumbnailParams, -) => { - return [`/api/v1/documents/${documentId}/thumbnail`, ...(params ? [params] : [])] as const -} - -export const getGetDocumentThumbnailQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - params?: GetDocumentThumbnailParams, - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetDocumentThumbnailQueryKey(documentId, params) - - const queryFn: QueryFunction>> = ({ signal }) => - getDocumentThumbnail(documentId, params, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!documentId, - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type GetDocumentThumbnailQueryResult = NonNullable< - Awaited> -> -export type GetDocumentThumbnailQueryError = ApiError - -export function useGetDocumentThumbnail< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - params: undefined | GetDocumentThumbnailParams, - options: { - query: Partial< - UseQueryOptions>, TError, TData> - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetDocumentThumbnail< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - params?: GetDocumentThumbnailParams, - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetDocumentThumbnail< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - params?: GetDocumentThumbnailParams, - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetDocumentThumbnail< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - params?: GetDocumentThumbnailParams, - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetDocumentThumbnailQueryOptions(documentId, params, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} diff --git a/ui/lib/api/downloads/downloads.ts b/ui/lib/api/downloads/downloads.ts deleted file mode 100644 index 0603312310462bec484f40be688da3bf7ca777c0..0000000000000000000000000000000000000000 --- a/ui/lib/api/downloads/downloads.ts +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { DownloadState } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getListDownloadsUrl = () => { - return `/api/v1/downloads` -} - -export const listDownloads = async (options?: RequestInit): Promise => { - return fetchApi(getListDownloadsUrl(), { - ...options, - method: 'GET', - }) -} - -export const getListDownloadsQueryKey = () => { - return [`/api/v1/downloads`] as const -} - -export const getListDownloadsQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getListDownloadsQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - listDownloads({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type ListDownloadsQueryResult = NonNullable>> -export type ListDownloadsQueryError = unknown - -export function useListDownloads< - TData = Awaited>, - TError = unknown, ->( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useListDownloads< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useListDownloads< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useListDownloads< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getListDownloadsQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} diff --git a/ui/lib/api/exports/exports.ts b/ui/lib/api/exports/exports.ts deleted file mode 100644 index 6b009d008a8343c8d84016b2194f5aac1be006a9..0000000000000000000000000000000000000000 --- a/ui/lib/api/exports/exports.ts +++ /dev/null @@ -1,250 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { ApiError, ExportBatchRequest, ExportDocumentParams, ExportResult } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getExportDocumentUrl = ( - documentId: string, - format: string, - params?: ExportDocumentParams, -) => { - const normalizedParams = new URLSearchParams() - - Object.entries(params || {}).forEach(([key, value]) => { - if (value !== undefined) { - normalizedParams.append(key, value === null ? 'null' : value.toString()) - } - }) - - const stringifiedParams = normalizedParams.toString() - - return stringifiedParams.length > 0 - ? `/api/v1/documents/${documentId}/export/${format}?${stringifiedParams}` - : `/api/v1/documents/${documentId}/export/${format}` -} - -export const exportDocument = async ( - documentId: string, - format: string, - params?: ExportDocumentParams, - options?: RequestInit, -): Promise => { - return fetchApi(getExportDocumentUrl(documentId, format, params), { - ...options, - method: 'GET', - }) -} - -export const getExportDocumentQueryKey = ( - documentId: string, - format: string, - params?: ExportDocumentParams, -) => { - return [`/api/v1/documents/${documentId}/export/${format}`, ...(params ? [params] : [])] as const -} - -export const getExportDocumentQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - format: string, - params?: ExportDocumentParams, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getExportDocumentQueryKey(documentId, format, params) - - const queryFn: QueryFunction>> = ({ signal }) => - exportDocument(documentId, format, params, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!(documentId && format), - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type ExportDocumentQueryResult = NonNullable>> -export type ExportDocumentQueryError = ApiError - -export function useExportDocument< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - format: string, - params: undefined | ExportDocumentParams, - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useExportDocument< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - format: string, - params?: ExportDocumentParams, - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useExportDocument< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - format: string, - params?: ExportDocumentParams, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useExportDocument< - TData = Awaited>, - TError = ApiError, ->( - documentId: string, - format: string, - params?: ExportDocumentParams, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getExportDocumentQueryOptions(documentId, format, params, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getBatchExportUrl = () => { - return `/api/v1/exports` -} - -export const batchExport = async ( - exportBatchRequest: ExportBatchRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getBatchExportUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(exportBatchRequest), - }) -} - -export const getBatchExportMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ExportBatchRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: ExportBatchRequest }, - TContext -> => { - const mutationKey = ['batchExport'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: ExportBatchRequest } - > = (props) => { - const { data } = props ?? {} - - return batchExport(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type BatchExportMutationResult = NonNullable>> -export type BatchExportMutationBody = ExportBatchRequest -export type BatchExportMutationError = ApiError - -export const useBatchExport = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: ExportBatchRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: ExportBatchRequest }, - TContext -> => { - return useMutation(getBatchExportMutationOptions(options), queryClient) -} diff --git a/ui/lib/api/fetch.ts b/ui/lib/api/fetch.ts index 949184fe011008359b064451a2f38732b9fb0052..27e22e499f93aa2e42357d60e2cf66de4ff03885 100644 --- a/ui/lib/api/fetch.ts +++ b/ui/lib/api/fetch.ts @@ -1,7 +1,25 @@ +export class ApiError extends Error { + readonly status: number + readonly body: unknown + constructor(status: number, message: string, body?: unknown) { + super(message) + this.name = 'ApiError' + this.status = status + this.body = body + } +} + export const fetchApi = async (url: string, options?: RequestInit): Promise => { const res = await fetch(url, options) if (!res.ok) { - throw await res.json().catch(() => ({ status: res.status, message: res.statusText })) + const body = await res.json().catch(() => null) + const message = + (body && typeof body === 'object' && 'message' in body && typeof body.message === 'string' + ? body.message + : null) ?? + res.statusText ?? + `HTTP ${res.status}` + throw new ApiError(res.status, message, body) } if ([204, 205, 304].includes(res.status)) { return undefined as T diff --git a/ui/lib/api/jobs/jobs.ts b/ui/lib/api/jobs/jobs.ts deleted file mode 100644 index 7b2877b8245f3e6c3bebf67b7c2967d3c8aa387f..0000000000000000000000000000000000000000 --- a/ui/lib/api/jobs/jobs.ts +++ /dev/null @@ -1,362 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { ApiError, JobState, PipelineJobRequest } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getListJobsUrl = () => { - return `/api/v1/jobs` -} - -export const listJobs = async (options?: RequestInit): Promise => { - return fetchApi(getListJobsUrl(), { - ...options, - method: 'GET', - }) -} - -export const getListJobsQueryKey = () => { - return [`/api/v1/jobs`] as const -} - -export const getListJobsQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getListJobsQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - listJobs({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type ListJobsQueryResult = NonNullable>> -export type ListJobsQueryError = unknown - -export function useListJobs>, TError = unknown>( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useListJobs>, TError = unknown>( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useListJobs>, TError = unknown>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useListJobs>, TError = unknown>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getListJobsQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getStartPipelineUrl = () => { - return `/api/v1/jobs/pipeline` -} - -export const startPipeline = async ( - pipelineJobRequest: PipelineJobRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getStartPipelineUrl(), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(pipelineJobRequest), - }) -} - -export const getStartPipelineMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PipelineJobRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: PipelineJobRequest }, - TContext -> => { - const mutationKey = ['startPipeline'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: PipelineJobRequest } - > = (props) => { - const { data } = props ?? {} - - return startPipeline(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type StartPipelineMutationResult = NonNullable>> -export type StartPipelineMutationBody = PipelineJobRequest -export type StartPipelineMutationError = ApiError - -export const useStartPipeline = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: PipelineJobRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: PipelineJobRequest }, - TContext -> => { - return useMutation(getStartPipelineMutationOptions(options), queryClient) -} -export const getGetJobUrl = (jobId: string) => { - return `/api/v1/jobs/${jobId}` -} - -export const getJob = async (jobId: string, options?: RequestInit): Promise => { - return fetchApi(getGetJobUrl(jobId), { - ...options, - method: 'GET', - }) -} - -export const getGetJobQueryKey = (jobId: string) => { - return [`/api/v1/jobs/${jobId}`] as const -} - -export const getGetJobQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - jobId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetJobQueryKey(jobId) - - const queryFn: QueryFunction>> = ({ signal }) => - getJob(jobId, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!jobId, - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type GetJobQueryResult = NonNullable>> -export type GetJobQueryError = ApiError - -export function useGetJob>, TError = ApiError>( - jobId: string, - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetJob>, TError = ApiError>( - jobId: string, - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetJob>, TError = ApiError>( - jobId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetJob>, TError = ApiError>( - jobId: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetJobQueryOptions(jobId, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getCancelJobUrl = (jobId: string) => { - return `/api/v1/jobs/${jobId}` -} - -export const cancelJob = async (jobId: string, options?: RequestInit): Promise => { - return fetchApi(getCancelJobUrl(jobId), { - ...options, - method: 'DELETE', - }) -} - -export const getCancelJobMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { jobId: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { jobId: string }, - TContext -> => { - const mutationKey = ['cancelJob'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, { jobId: string }> = ( - props, - ) => { - const { jobId } = props ?? {} - - return cancelJob(jobId, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type CancelJobMutationResult = NonNullable>> - -export type CancelJobMutationError = ApiError - -export const useCancelJob = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { jobId: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { jobId: string }, - TContext -> => { - return useMutation(getCancelJobMutationOptions(options), queryClient) -} diff --git a/ui/lib/api/llm/llm.ts b/ui/lib/api/llm/llm.ts deleted file mode 100644 index 2d9ddb1d30cf708ffe6e8b25fb0710c73c34d4e3..0000000000000000000000000000000000000000 --- a/ui/lib/api/llm/llm.ts +++ /dev/null @@ -1,337 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { ApiError, LlmCatalog, LlmLoadRequest, LlmState } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getGetLlmUrl = () => { - return `/api/v1/llm` -} - -export const getLlm = async (options?: RequestInit): Promise => { - return fetchApi(getGetLlmUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetLlmQueryKey = () => { - return [`/api/v1/llm`] as const -} - -export const getGetLlmQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetLlmQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getLlm({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetLlmQueryResult = NonNullable>> -export type GetLlmQueryError = ApiError - -export function useGetLlm>, TError = ApiError>( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetLlm>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetLlm>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetLlm>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetLlmQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getLoadLlmUrl = () => { - return `/api/v1/llm` -} - -export const loadLlm = async ( - llmLoadRequest: LlmLoadRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getLoadLlmUrl(), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(llmLoadRequest), - }) -} - -export const getLoadLlmMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LlmLoadRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: LlmLoadRequest }, - TContext -> => { - const mutationKey = ['loadLlm'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: LlmLoadRequest } - > = (props) => { - const { data } = props ?? {} - - return loadLlm(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type LoadLlmMutationResult = NonNullable>> -export type LoadLlmMutationBody = LlmLoadRequest -export type LoadLlmMutationError = ApiError - -export const useLoadLlm = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: LlmLoadRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: LlmLoadRequest }, - TContext -> => { - return useMutation(getLoadLlmMutationOptions(options), queryClient) -} -export const getUnloadLlmUrl = () => { - return `/api/v1/llm` -} - -export const unloadLlm = async (options?: RequestInit): Promise => { - return fetchApi(getUnloadLlmUrl(), { - ...options, - method: 'DELETE', - }) -} - -export const getUnloadLlmMutationOptions = (options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter -}): UseMutationOptions>, TError, void, TContext> => { - const mutationKey = ['unloadLlm'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction>, void> = () => { - return unloadLlm(requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type UnloadLlmMutationResult = NonNullable>> - -export type UnloadLlmMutationError = ApiError - -export const useUnloadLlm = ( - options?: { - mutation?: UseMutationOptions>, TError, void, TContext> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult>, TError, void, TContext> => { - return useMutation(getUnloadLlmMutationOptions(options), queryClient) -} -export const getGetLlmCatalogUrl = () => { - return `/api/v1/llm/catalog` -} - -export const getLlmCatalog = async (options?: RequestInit): Promise => { - return fetchApi(getGetLlmCatalogUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetLlmCatalogQueryKey = () => { - return [`/api/v1/llm/catalog`] as const -} - -export const getGetLlmCatalogQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetLlmCatalogQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getLlmCatalog({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetLlmCatalogQueryResult = NonNullable>> -export type GetLlmCatalogQueryError = ApiError - -export function useGetLlmCatalog< - TData = Awaited>, - TError = ApiError, ->( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetLlmCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetLlmCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetLlmCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetLlmCatalogQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} diff --git a/ui/lib/api/processing/processing.ts b/ui/lib/api/processing/processing.ts deleted file mode 100644 index 6bef459e17b6625c76b3dff22451aa88f9b34640..0000000000000000000000000000000000000000 --- a/ui/lib/api/processing/processing.ts +++ /dev/null @@ -1,378 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation } from '@tanstack/react-query' -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { ApiError, RenderRequest, TranslateRequest } from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getDetectDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/detect` -} - -export const detectDocument = async (documentId: string, options?: RequestInit): Promise => { - return fetchApi(getDetectDocumentUrl(documentId), { - ...options, - method: 'POST', - }) -} - -export const getDetectDocumentMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - const mutationKey = ['detectDocument'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string } - > = (props) => { - const { documentId } = props ?? {} - - return detectDocument(documentId, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type DetectDocumentMutationResult = NonNullable>> - -export type DetectDocumentMutationError = ApiError - -export const useDetectDocument = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - return useMutation(getDetectDocumentMutationOptions(options), queryClient) -} -export const getInpaintDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/inpaint` -} - -export const inpaintDocument = async (documentId: string, options?: RequestInit): Promise => { - return fetchApi(getInpaintDocumentUrl(documentId), { - ...options, - method: 'POST', - }) -} - -export const getInpaintDocumentMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - const mutationKey = ['inpaintDocument'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string } - > = (props) => { - const { documentId } = props ?? {} - - return inpaintDocument(documentId, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type InpaintDocumentMutationResult = NonNullable>> - -export type InpaintDocumentMutationError = ApiError - -export const useInpaintDocument = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - return useMutation(getInpaintDocumentMutationOptions(options), queryClient) -} -export const getRecognizeDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/recognize` -} - -export const recognizeDocument = async ( - documentId: string, - options?: RequestInit, -): Promise => { - return fetchApi(getRecognizeDocumentUrl(documentId), { - ...options, - method: 'POST', - }) -} - -export const getRecognizeDocumentMutationOptions = < - TError = ApiError, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - const mutationKey = ['recognizeDocument'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string } - > = (props) => { - const { documentId } = props ?? {} - - return recognizeDocument(documentId, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type RecognizeDocumentMutationResult = NonNullable< - Awaited> -> - -export type RecognizeDocumentMutationError = ApiError - -export const useRecognizeDocument = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string }, - TContext -> => { - return useMutation(getRecognizeDocumentMutationOptions(options), queryClient) -} -export const getRenderDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/render` -} - -export const renderDocument = async ( - documentId: string, - renderRequest: RenderRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getRenderDocumentUrl(documentId), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(renderRequest), - }) -} - -export const getRenderDocumentMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: RenderRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: RenderRequest }, - TContext -> => { - const mutationKey = ['renderDocument'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: RenderRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return renderDocument(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type RenderDocumentMutationResult = NonNullable>> -export type RenderDocumentMutationBody = RenderRequest -export type RenderDocumentMutationError = ApiError - -export const useRenderDocument = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: RenderRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: RenderRequest }, - TContext -> => { - return useMutation(getRenderDocumentMutationOptions(options), queryClient) -} -export const getTranslateDocumentUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/translate` -} - -export const translateDocument = async ( - documentId: string, - translateRequest: TranslateRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getTranslateDocumentUrl(documentId), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(translateRequest), - }) -} - -export const getTranslateDocumentMutationOptions = < - TError = ApiError, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TranslateRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TranslateRequest }, - TContext -> => { - const mutationKey = ['translateDocument'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: TranslateRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return translateDocument(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type TranslateDocumentMutationResult = NonNullable< - Awaited> -> -export type TranslateDocumentMutationBody = TranslateRequest -export type TranslateDocumentMutationError = ApiError - -export const useTranslateDocument = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TranslateRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: TranslateRequest }, - TContext -> => { - return useMutation(getTranslateDocumentMutationOptions(options), queryClient) -} diff --git a/ui/lib/api/regions/regions.ts b/ui/lib/api/regions/regions.ts deleted file mode 100644 index 553d60c9f51787c392d96be3c8a05c312705b51a..0000000000000000000000000000000000000000 --- a/ui/lib/api/regions/regions.ts +++ /dev/null @@ -1,247 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation } from '@tanstack/react-query' -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { - ApiError, - BrushRegionRequest, - InpaintRegionRequest, - MaskRegionRequest, -} from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getUpdateBrushLayerUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/brush-layer` -} - -export const updateBrushLayer = async ( - documentId: string, - brushRegionRequest: BrushRegionRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getUpdateBrushLayerUrl(documentId), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(brushRegionRequest), - }) -} - -export const getUpdateBrushLayerMutationOptions = < - TError = ApiError, - TContext = unknown, ->(options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: BrushRegionRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: BrushRegionRequest }, - TContext -> => { - const mutationKey = ['updateBrushLayer'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: BrushRegionRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return updateBrushLayer(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type UpdateBrushLayerMutationResult = NonNullable< - Awaited> -> -export type UpdateBrushLayerMutationBody = BrushRegionRequest -export type UpdateBrushLayerMutationError = ApiError - -export const useUpdateBrushLayer = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: BrushRegionRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: BrushRegionRequest }, - TContext -> => { - return useMutation(getUpdateBrushLayerMutationOptions(options), queryClient) -} -export const getInpaintRegionUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/inpaint-region` -} - -export const inpaintRegion = async ( - documentId: string, - inpaintRegionRequest: InpaintRegionRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getInpaintRegionUrl(documentId), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(inpaintRegionRequest), - }) -} - -export const getInpaintRegionMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: InpaintRegionRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: InpaintRegionRequest }, - TContext -> => { - const mutationKey = ['inpaintRegion'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: InpaintRegionRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return inpaintRegion(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type InpaintRegionMutationResult = NonNullable>> -export type InpaintRegionMutationBody = InpaintRegionRequest -export type InpaintRegionMutationError = ApiError - -export const useInpaintRegion = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: InpaintRegionRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: InpaintRegionRequest }, - TContext -> => { - return useMutation(getInpaintRegionMutationOptions(options), queryClient) -} -export const getUpdateMaskUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/mask` -} - -export const updateMask = async ( - documentId: string, - maskRegionRequest: MaskRegionRequest, - options?: RequestInit, -): Promise => { - return fetchApi(getUpdateMaskUrl(documentId), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(maskRegionRequest), - }) -} - -export const getUpdateMaskMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: MaskRegionRequest }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: MaskRegionRequest }, - TContext -> => { - const mutationKey = ['updateMask'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: MaskRegionRequest } - > = (props) => { - const { documentId, data } = props ?? {} - - return updateMask(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type UpdateMaskMutationResult = NonNullable>> -export type UpdateMaskMutationBody = MaskRegionRequest -export type UpdateMaskMutationError = ApiError - -export const useUpdateMask = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: MaskRegionRequest }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: MaskRegionRequest }, - TContext -> => { - return useMutation(getUpdateMaskMutationOptions(options), queryClient) -} diff --git a/ui/lib/api/schemas/addImageLayerResponse.ts b/ui/lib/api/schemas/addImageLayerResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..732b2247fa962edf2d3a38a9df9dd88e662ee3a6 --- /dev/null +++ b/ui/lib/api/schemas/addImageLayerResponse.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { NodeId } from './nodeId' + +export interface AddImageLayerResponse { + node: NodeId +} diff --git a/ui/lib/api/schemas/getConfig200.ts b/ui/lib/api/schemas/appConfig.ts similarity index 93% rename from ui/lib/api/schemas/getConfig200.ts rename to ui/lib/api/schemas/appConfig.ts index 376708f8d8b698689a6f1a750daf2e3615e07b78..d283e22733a764f02fda9951cb53d1586e7d13ce 100644 --- a/ui/lib/api/schemas/getConfig200.ts +++ b/ui/lib/api/schemas/appConfig.ts @@ -8,7 +8,7 @@ import type { HttpConfig } from './httpConfig' import type { PipelineConfig } from './pipelineConfig' import type { ProviderConfig } from './providerConfig' -export type GetConfig200 = { +export interface AppConfig { data?: DataConfig http?: HttpConfig pipeline?: PipelineConfig diff --git a/ui/lib/api/schemas/appEvent.ts b/ui/lib/api/schemas/appEvent.ts new file mode 100644 index 0000000000000000000000000000000000000000..50db2b143de10cf5306aa361f592969a07abf418 --- /dev/null +++ b/ui/lib/api/schemas/appEvent.ts @@ -0,0 +1,44 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { DownloadProgress } from './downloadProgress' +import type { JobFinishedEvent } from './jobFinishedEvent' +import type { LlmTarget } from './llmTarget' +import type { PipelineProgress } from './pipelineProgress' +import type { SnapshotEvent } from './snapshotEvent' + +export type AppEvent = + | { + event: 'jobStarted' + id: string + kind: string + } + | (PipelineProgress & { + event: 'jobProgress' + }) + | (JobFinishedEvent & { + event: 'jobFinished' + }) + | (DownloadProgress & { + event: 'downloadProgress' + }) + | { + event: 'llmLoading' + target: LlmTarget + } + | { + event: 'llmLoaded' + target: LlmTarget + } + | { + event: 'llmFailed' + target?: null | LlmTarget + } + | { + event: 'llmUnloaded' + } + | (SnapshotEvent & { + event: 'snapshot' + }) diff --git a/ui/lib/api/schemas/blobRef.ts b/ui/lib/api/schemas/blobRef.ts new file mode 100644 index 0000000000000000000000000000000000000000..1c7485c0569bffb81de55afaeb66faa914d9e63e --- /dev/null +++ b/ui/lib/api/schemas/blobRef.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +/** + * Hex-encoded blake3 hash of an immutable blob. + */ +export type BlobRef = string diff --git a/ui/lib/api/schemas/brushRegionRequest.ts b/ui/lib/api/schemas/brushRegionRequest.ts deleted file mode 100644 index 6bd776c12d5c7528df4e07c6e7c867e2083299d3..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/brushRegionRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { Region } from './region' - -export interface BrushRegionRequest { - data: number[] - region: Region -} diff --git a/ui/lib/api/schemas/configPatch.ts b/ui/lib/api/schemas/configPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..492a43056c9d6420cc51293f8b05f8fd7019430d --- /dev/null +++ b/ui/lib/api/schemas/configPatch.ts @@ -0,0 +1,26 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { DataConfigPatch } from './dataConfigPatch' +import type { HttpConfigPatch } from './httpConfigPatch' +import type { PipelineConfigPatch } from './pipelineConfigPatch' +import type { ProviderPatch } from './providerPatch' + +/** + * Sparse patch for `koharu_app::AppConfig`. Missing fields mean "leave +as-is". The `providers` field, if present, replaces the whole provider +list — we do not merge by id because ordering is meaningful. + */ +export interface ConfigPatch { + data?: null | DataConfigPatch + http?: null | HttpConfigPatch + pipeline?: null | PipelineConfigPatch + /** + * If present, replaces the entire list. Api_key values of `"[REDACTED]"` + are interpreted as "leave the existing secret alone". + * @nullable + */ + providers?: ProviderPatch[] | null +} diff --git a/ui/lib/api/schemas/createPagesFromPathsRequest.ts b/ui/lib/api/schemas/createPagesFromPathsRequest.ts new file mode 100644 index 0000000000000000000000000000000000000000..9b8fb01e578d49c4ad51f07410501f76f60a793f --- /dev/null +++ b/ui/lib/api/schemas/createPagesFromPathsRequest.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface CreatePagesFromPathsRequest { + paths: string[] + replace?: boolean +} diff --git a/ui/lib/api/schemas/createPagesResponse.ts b/ui/lib/api/schemas/createPagesResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..db1b6fd1ffedb877b85372bd223de0e6ee3b47ff --- /dev/null +++ b/ui/lib/api/schemas/createPagesResponse.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { PageId } from './pageId' + +export interface CreatePagesResponse { + pages: PageId[] +} diff --git a/ui/lib/api/schemas/importDocumentsBody.ts b/ui/lib/api/schemas/createProjectRequest.ts similarity index 64% rename from ui/lib/api/schemas/importDocumentsBody.ts rename to ui/lib/api/schemas/createProjectRequest.ts index df1ca4486c8d2968635364dd362ef242c3fdb8a0..a1570d4795383bb4a780f0c6f2be99f4e55c6dd0 100644 --- a/ui/lib/api/schemas/importDocumentsBody.ts +++ b/ui/lib/api/schemas/createProjectRequest.ts @@ -4,6 +4,6 @@ * OpenAPI spec version: 0.0.1 */ -export type ImportDocumentsBody = { - files: Blob[] +export interface CreateProjectRequest { + name: string } diff --git a/ui/lib/api/schemas/updateDocumentStyleRequest.ts b/ui/lib/api/schemas/dataConfigPatch.ts similarity index 61% rename from ui/lib/api/schemas/updateDocumentStyleRequest.ts rename to ui/lib/api/schemas/dataConfigPatch.ts index 7cd9ae4eb46d102b4761e498889db270e27cfaa9..93f6e85f125c98a55dfd5de6cac1def753d03761 100644 --- a/ui/lib/api/schemas/updateDocumentStyleRequest.ts +++ b/ui/lib/api/schemas/dataConfigPatch.ts @@ -4,7 +4,7 @@ * OpenAPI spec version: 0.0.1 */ -export interface UpdateDocumentStyleRequest { +export interface DataConfigPatch { /** @nullable */ - defaultFont?: string | null + path?: string | null } diff --git a/ui/lib/api/schemas/documentDetail.ts b/ui/lib/api/schemas/documentDetail.ts deleted file mode 100644 index d72c94fbfcb0c8081516f2aafc0b9c05d56de8bf..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/documentDetail.ts +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { DocumentStyle } from './documentStyle' -import type { TextBlockDetail } from './textBlockDetail' - -export interface DocumentDetail { - /** - * Blob hash for the brush layer. - * @nullable - */ - brushLayer?: string | null - /** @minimum 0 */ - height: number - id: string - /** Blob hash for the source image layer. */ - image: string - /** - * Blob hash for the inpainted layer. - * @nullable - */ - inpainted?: string | null - name: string - /** - * Blob hash for the rendered composite layer. - * @nullable - */ - rendered?: string | null - /** - * Blob hash for the segmentation mask layer. - * @nullable - */ - segment?: string | null - style?: null | DocumentStyle - textBlocks: TextBlockDetail[] - /** @minimum 0 */ - width: number -} diff --git a/ui/lib/api/schemas/documentSummary.ts b/ui/lib/api/schemas/documentSummary.ts deleted file mode 100644 index 58ea2fda2c72367a43df809a47a004962d247c77..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/documentSummary.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ - -export interface DocumentSummary { - hasBrushLayer: boolean - hasInpainted: boolean - hasRendered: boolean - hasSegment: boolean - /** @minimum 0 */ - height: number - id: string - name: string - /** @minimum 0 */ - order: number - /** @minimum 0 */ - textBlockCount: number - /** @minimum 0 */ - width: number -} diff --git a/ui/lib/api/schemas/downloadState.ts b/ui/lib/api/schemas/downloadProgress.ts similarity index 60% rename from ui/lib/api/schemas/downloadState.ts rename to ui/lib/api/schemas/downloadProgress.ts index 36ac8ed2dc48735f51aa72331d8c01d24028c22b..027d8358758de98782f008f20e80581db52f1fe8 100644 --- a/ui/lib/api/schemas/downloadState.ts +++ b/ui/lib/api/schemas/downloadProgress.ts @@ -3,16 +3,14 @@ * Do not edit manually. * OpenAPI spec version: 0.0.1 */ -import type { TransferStatus } from './transferStatus' +import type { DownloadStatus } from './downloadStatus' -export interface DownloadState { +export interface DownloadProgress { /** @minimum 0 */ downloaded: number - /** @nullable */ - error?: string | null filename: string id: string - status: TransferStatus + status: DownloadStatus /** * @minimum 0 * @nullable diff --git a/ui/lib/api/schemas/downloadStatus.ts b/ui/lib/api/schemas/downloadStatus.ts new file mode 100644 index 0000000000000000000000000000000000000000..a6ca5cc0f91a6b6e5f675544aaf49b6443ab0188 --- /dev/null +++ b/ui/lib/api/schemas/downloadStatus.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type DownloadStatus = + | { + status: 'started' + } + | { + status: 'downloading' + } + | { + status: 'completed' + } + | { + reason: string + status: 'failed' + } diff --git a/ui/lib/api/schemas/getEngineCatalog200.ts b/ui/lib/api/schemas/engineCatalog.ts similarity index 84% rename from ui/lib/api/schemas/getEngineCatalog200.ts rename to ui/lib/api/schemas/engineCatalog.ts index 72f195f694c3e177b5d15564a2c6151b60d943e3..283893252f5138e41511f455ff698650dd0d8f6e 100644 --- a/ui/lib/api/schemas/getEngineCatalog200.ts +++ b/ui/lib/api/schemas/engineCatalog.ts @@ -5,7 +5,8 @@ */ import type { EngineCatalogEntry } from './engineCatalogEntry' -export type GetEngineCatalog200 = { +export interface EngineCatalog { + bubbleSegmenters: EngineCatalogEntry[] detectors: EngineCatalogEntry[] fontDetectors: EngineCatalogEntry[] inpainters: EngineCatalogEntry[] diff --git a/ui/lib/api/schemas/apiError.ts b/ui/lib/api/schemas/errorEvent.ts similarity index 64% rename from ui/lib/api/schemas/apiError.ts rename to ui/lib/api/schemas/errorEvent.ts index 08e80fdd7aef1544c60100cdcd7561ab92983bef..8c436afc745c99e5c74e51ccfb0f2c143d111577 100644 --- a/ui/lib/api/schemas/apiError.ts +++ b/ui/lib/api/schemas/errorEvent.ts @@ -4,8 +4,7 @@ * OpenAPI spec version: 0.0.1 */ -export interface ApiError { +export interface ErrorEvent { message: string - /** @minimum 0 */ - status: number + scope: string } diff --git a/ui/lib/api/schemas/exportBatchRequest.ts b/ui/lib/api/schemas/exportBatchRequest.ts deleted file mode 100644 index 56acf4368c9d8b447206ec2d57817c04db93ec67..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/exportBatchRequest.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { ExportLayer } from './exportLayer' - -export interface ExportBatchRequest { - layer?: null | ExportLayer -} diff --git a/ui/lib/api/schemas/exportDocumentParams.ts b/ui/lib/api/schemas/exportDocumentParams.ts deleted file mode 100644 index 4d69662ae8d73cc686fc9c4d452c3047709c030b..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/exportDocumentParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { ExportLayer } from './exportLayer' - -export type ExportDocumentParams = { - layer?: null | ExportLayer -} diff --git a/ui/lib/api/schemas/exportLayer.ts b/ui/lib/api/schemas/exportFormat.ts similarity index 54% rename from ui/lib/api/schemas/exportLayer.ts rename to ui/lib/api/schemas/exportFormat.ts index 17cd6507b7339a6351f1808b22b8074c63a2a1c7..a51eb8883ea0a00ca5a82f47683ea3fe9d6e67a4 100644 --- a/ui/lib/api/schemas/exportLayer.ts +++ b/ui/lib/api/schemas/exportFormat.ts @@ -4,9 +4,11 @@ * OpenAPI spec version: 0.0.1 */ -export type ExportLayer = (typeof ExportLayer)[keyof typeof ExportLayer] +export type ExportFormat = (typeof ExportFormat)[keyof typeof ExportFormat] -export const ExportLayer = { +export const ExportFormat = { + khr: 'khr', + psd: 'psd', rendered: 'rendered', inpainted: 'inpainted', } as const diff --git a/ui/lib/api/schemas/exportProjectRequest.ts b/ui/lib/api/schemas/exportProjectRequest.ts new file mode 100644 index 0000000000000000000000000000000000000000..c31f02793c769beb9fba164c2cfb625c91cf74e0 --- /dev/null +++ b/ui/lib/api/schemas/exportProjectRequest.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ExportFormat } from './exportFormat' +import type { PageId } from './pageId' + +export interface ExportProjectRequest { + format: ExportFormat + /** + * Optional subset of pages; defaults to every page. + * @nullable + */ + pages?: PageId[] | null +} diff --git a/ui/lib/api/schemas/fontPrediction.ts b/ui/lib/api/schemas/fontPrediction.ts index 97501f3f8c9cd18c2b1691066215aef7bc5f3ea1..eda2bc21f6508f04003379f82e734385918d2210 100644 --- a/ui/lib/api/schemas/fontPrediction.ts +++ b/ui/lib/api/schemas/fontPrediction.ts @@ -8,13 +8,13 @@ import type { TextDirection } from './textDirection' import type { TopFont } from './topFont' export interface FontPrediction { - angle_deg: number + angleDeg: number direction: TextDirection - font_size_px: number - line_height: number - named_fonts: NamedFontPrediction[] - stroke_color: number[] - stroke_width_px: number - text_color: number[] - top_fonts: TopFont[] + fontSizePx: number + lineHeight: number + namedFonts: NamedFontPrediction[] + strokeColor: number[] + strokeWidthPx: number + textColor: number[] + topFonts: TopFont[] } diff --git a/ui/lib/api/schemas/getLlmCatalogParams.ts b/ui/lib/api/schemas/getLlmCatalogParams.ts deleted file mode 100644 index 4ac76ba5ed2c9c13b6af5e1dd9edcf2f4892c778..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/getLlmCatalogParams.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.6.2 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ - -export type GetLlmCatalogParams = { - /** - * @nullable - */ - language?: string | null -} diff --git a/ui/lib/api/schemas/googleFontCatalog.ts b/ui/lib/api/schemas/googleFontCatalog.ts new file mode 100644 index 0000000000000000000000000000000000000000..ac39d48ac11425f642bdd3b825175a07be796d69 --- /dev/null +++ b/ui/lib/api/schemas/googleFontCatalog.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { GoogleFontEntry } from './googleFontEntry' + +export interface GoogleFontCatalog { + fonts: GoogleFontEntry[] +} diff --git a/ui/lib/api/schemas/googleFontCatalogResponse.ts b/ui/lib/api/schemas/googleFontCatalogResponse.ts deleted file mode 100644 index 0cdbb2f889f7ea0aca7da8ee80f3d2d2ca6a231c..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/googleFontCatalogResponse.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { GoogleFontCatalogEntry } from './googleFontCatalogEntry' - -export interface GoogleFontCatalogResponse { - fonts: GoogleFontCatalogEntry[] - recommended: string[] -} diff --git a/ui/lib/api/schemas/googleFontCatalogEntry.ts b/ui/lib/api/schemas/googleFontEntry.ts similarity index 55% rename from ui/lib/api/schemas/googleFontCatalogEntry.ts rename to ui/lib/api/schemas/googleFontEntry.ts index 0bf3d572329448fdd95a29d082a9a5e79ea16384..98760b6679f51785f8331b3a55bbc69eaac212c8 100644 --- a/ui/lib/api/schemas/googleFontCatalogEntry.ts +++ b/ui/lib/api/schemas/googleFontEntry.ts @@ -3,10 +3,11 @@ * Do not edit manually. * OpenAPI spec version: 0.0.1 */ +import type { GoogleFontVariant } from './googleFontVariant' -export interface GoogleFontCatalogEntry { - cached: boolean +export interface GoogleFontEntry { category: string family: string subsets: string[] + variants: GoogleFontVariant[] } diff --git a/ui/lib/api/schemas/googleFontVariant.ts b/ui/lib/api/schemas/googleFontVariant.ts new file mode 100644 index 0000000000000000000000000000000000000000..621bb4b1b0e16a1f7bf68835b1441505376a7fb9 --- /dev/null +++ b/ui/lib/api/schemas/googleFontVariant.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface GoogleFontVariant { + filename: string + style: string + /** @minimum 0 */ + weight: number +} diff --git a/ui/lib/api/schemas/getDocumentThumbnailParams.ts b/ui/lib/api/schemas/historyResult.ts similarity index 52% rename from ui/lib/api/schemas/getDocumentThumbnailParams.ts rename to ui/lib/api/schemas/historyResult.ts index 5377dd5df360aac566a860845bcb8c5ca5900a74..87a81b595c054b82352d407562f238655d0160c7 100644 --- a/ui/lib/api/schemas/getDocumentThumbnailParams.ts +++ b/ui/lib/api/schemas/historyResult.ts @@ -4,10 +4,11 @@ * OpenAPI spec version: 0.0.1 */ -export type GetDocumentThumbnailParams = { +export interface HistoryResult { /** + * New epoch. `None` only for a no-op undo/redo at the stack boundary. * @minimum 0 * @nullable */ - size?: number | null + epoch?: number | null } diff --git a/ui/lib/api/schemas/httpConfigPatch.ts b/ui/lib/api/schemas/httpConfigPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..8158aae87114fc37be81e5f095efc8f3254f9486 --- /dev/null +++ b/ui/lib/api/schemas/httpConfigPatch.ts @@ -0,0 +1,23 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface HttpConfigPatch { + /** + * @minimum 0 + * @nullable + */ + connectTimeout?: number | null + /** + * @minimum 0 + * @nullable + */ + maxRetries?: number | null + /** + * @minimum 0 + * @nullable + */ + readTimeout?: number | null +} diff --git a/ui/lib/api/schemas/imageData.ts b/ui/lib/api/schemas/imageData.ts new file mode 100644 index 0000000000000000000000000000000000000000..c3a5b3504b8e940b7bf971ba2aa11ac46eb8aa25 --- /dev/null +++ b/ui/lib/api/schemas/imageData.ts @@ -0,0 +1,21 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' +import type { ImageRole } from './imageRole' + +export interface ImageData { + blob: BlobRef + /** @nullable */ + name?: string | null + /** @minimum 0 */ + naturalHeight: number + /** @minimum 0 */ + naturalWidth: number + opacity?: number + /** Role tags differentiate source / inpainted / rendered / user-imported images. + Role is immutable on an existing node — switching roles = delete + add. */ + role: ImageRole +} diff --git a/ui/lib/api/schemas/imageDataPatch.ts b/ui/lib/api/schemas/imageDataPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..ae9e2b1ffe98a84cd681b977cf28a1ff94d99320 --- /dev/null +++ b/ui/lib/api/schemas/imageDataPatch.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' + +export interface ImageDataPatch { + blob?: null | BlobRef + /** @nullable */ + name?: string | null + /** + * @minimum 0 + * @nullable + */ + naturalHeight?: number | null + /** + * @minimum 0 + * @nullable + */ + naturalWidth?: number | null + /** @nullable */ + opacity?: number | null +} diff --git a/ui/lib/api/schemas/imageRole.ts b/ui/lib/api/schemas/imageRole.ts new file mode 100644 index 0000000000000000000000000000000000000000..cb0b15e70ab702b580a98b4f487535bd2ef3f161 --- /dev/null +++ b/ui/lib/api/schemas/imageRole.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type ImageRole = (typeof ImageRole)[keyof typeof ImageRole] + +export const ImageRole = { + source: 'source', + inpainted: 'inpainted', + rendered: 'rendered', + custom: 'custom', +} as const diff --git a/ui/lib/api/schemas/importDocumentsParams.ts b/ui/lib/api/schemas/importDocumentsParams.ts deleted file mode 100644 index 94d9bc1b61d6b8eea26f3c2cfd6063246cebcb68..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/importDocumentsParams.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { ImportMode } from './importMode' - -export type ImportDocumentsParams = { - mode?: null | ImportMode -} diff --git a/ui/lib/api/schemas/importMode.ts b/ui/lib/api/schemas/importMode.ts deleted file mode 100644 index 8a331cb464f296053e6392e481b1773eca0a45cc..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/importMode.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ - -export type ImportMode = (typeof ImportMode)[keyof typeof ImportMode] - -export const ImportMode = { - replace: 'replace', - append: 'append', -} as const diff --git a/ui/lib/api/schemas/importProjectParams.ts b/ui/lib/api/schemas/importProjectParams.ts new file mode 100644 index 0000000000000000000000000000000000000000..e6ff32cca329415e5b480b890e3cac45817e557f --- /dev/null +++ b/ui/lib/api/schemas/importProjectParams.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type ImportProjectParams = { + /** + * Optional absolute destination path for the extracted `.khrproj/` +directory. When omitted, the server allocates a directory under +`{data.path}/projects/` using a timestamp-and-random suffix. Must not +already exist when provided. + * @nullable + */ + path?: string | null +} diff --git a/ui/lib/api/schemas/importResult.ts b/ui/lib/api/schemas/importResult.ts deleted file mode 100644 index 1445c274273fe43df9e3dbd1c7009533f53eb6f2..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/importResult.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { DocumentSummary } from './documentSummary' - -export interface ImportResult { - documents: DocumentSummary[] - /** @minimum 0 */ - totalCount: number -} diff --git a/ui/lib/api/schemas/index.ts b/ui/lib/api/schemas/index.ts index 8ea37046aa846553beb20d98c138d30cfe3596f3..435a540cbbd33a800b5ba25b4ac2cd95d89a8e4d 100644 --- a/ui/lib/api/schemas/index.ts +++ b/ui/lib/api/schemas/index.ts @@ -4,35 +4,40 @@ * OpenAPI spec version: 0.0.1 */ -export * from './apiError' -export * from './brushRegionRequest' -export * from './createTextBlock' +export * from './addImageLayerResponse' +export * from './appConfig' +export * from './appEvent' +export * from './blobRef' +export * from './configPatch' +export * from './createPagesFromPathsRequest' +export * from './createPagesResponse' +export * from './createProjectRequest' export * from './dataConfig' -export * from './documentDetail' -export * from './documentStyle' -export * from './documentSummary' -export * from './downloadState' +export * from './dataConfigPatch' +export * from './downloadProgress' +export * from './downloadStatus' +export * from './engineCatalog' export * from './engineCatalogEntry' -export * from './exportBatchRequest' -export * from './exportDocumentParams' -export * from './exportLayer' -export * from './exportResult' +export * from './exportFormat' +export * from './exportProjectRequest' export * from './fontFaceInfo' export * from './fontPrediction' export * from './fontSource' -export * from './getConfig200' -export * from './getDocumentThumbnailParams' -export * from './getEngineCatalog200' -export * from './googleFontCatalogEntry' -export * from './googleFontCatalogResponse' +export * from './googleFontCatalog' +export * from './googleFontEntry' +export * from './googleFontVariant' +export * from './historyResult' export * from './httpConfig' -export * from './importDocumentsBody' -export * from './importDocumentsParams' -export * from './importMode' -export * from './importResult' -export * from './inpaintRegionRequest' -export * from './jobState' +export * from './httpConfigPatch' +export * from './imageData' +export * from './imageDataPatch' +export * from './imageRole' +export * from './jobFinishedEvent' export * from './jobStatus' +export * from './jobSummary' +export * from './listDownloadsResponse' +export * from './listOperationsResponse' +export * from './listProjectsResponse' export * from './llmCatalog' export * from './llmCatalogModel' export * from './llmGenerationOptions' @@ -43,27 +48,50 @@ export * from './llmState' export * from './llmStateStatus' export * from './llmTarget' export * from './llmTargetKind' -export * from './maskRegionRequest' +export * from './maskData' +export * from './maskDataPatch' +export * from './maskRole' export * from './metaInfo' export * from './namedFontPrediction' +export * from './node' +export * from './nodeDataPatch' +export * from './nodeId' +export * from './nodeKind' +export * from './nodePatch' +export * from './op' +export * from './openProjectRequest' +export * from './page' +export * from './pageId' +export * from './pageNodes' +export * from './pagePatch' export * from './pipelineConfig' -export * from './pipelineJobRequest' -export * from './pipelineLlmRequest' +export * from './pipelineConfigPatch' +export * from './pipelineProgress' +export * from './pipelineStatus' +export * from './pipelineStep' +export * from './projectMeta' +export * from './projectMetaPatch' +export * from './projectStyle' +export * from './projectSummary' export * from './providerConfig' +export * from './providerPatch' +export * from './providerSecretRequest' +export * from './putMaskResponse' export * from './region' -export * from './renderRequest' -export * from './reorderRequest' +export * from './scene' +export * from './scenePages' +export * from './sceneSnapshot' +export * from './snapshotEvent' +export * from './startDownloadRequest' +export * from './startDownloadResponse' +export * from './startPipelineRequest' +export * from './startPipelineResponse' export * from './textAlign' -export * from './textBlockDetail' -export * from './textBlockInput' -export * from './textBlockPatch' +export * from './textData' +export * from './textDataPatch' export * from './textDirection' export * from './textShaderEffect' export * from './textStrokeStyle' export * from './textStyle' export * from './topFont' -export * from './transferStatus' -export * from './translateRequest' -export * from './updateConfig200' -export * from './updateConfigBody' -export * from './updateDocumentStyleRequest' +export * from './transform' diff --git a/ui/lib/api/schemas/inpaintRegionRequest.ts b/ui/lib/api/schemas/inpaintRegionRequest.ts deleted file mode 100644 index 20dce02f088730fba96c52f6626f9d32421166c0..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/inpaintRegionRequest.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { Region } from './region' - -export interface InpaintRegionRequest { - region: Region -} diff --git a/ui/lib/api/schemas/jobFinishedEvent.ts b/ui/lib/api/schemas/jobFinishedEvent.ts new file mode 100644 index 0000000000000000000000000000000000000000..71b80ad2c36f7205f96f802db7632e3d1607ce97 --- /dev/null +++ b/ui/lib/api/schemas/jobFinishedEvent.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { JobStatus } from './jobStatus' + +export interface JobFinishedEvent { + /** @nullable */ + error?: string | null + id: string + status: JobStatus +} diff --git a/ui/lib/api/schemas/jobSummary.ts b/ui/lib/api/schemas/jobSummary.ts new file mode 100644 index 0000000000000000000000000000000000000000..eb7d711f0b1eb570736d6d49029f0c3462268903 --- /dev/null +++ b/ui/lib/api/schemas/jobSummary.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { JobStatus } from './jobStatus' + +export interface JobSummary { + /** @nullable */ + error?: string | null + id: string + kind: string + status: JobStatus +} diff --git a/ui/lib/api/schemas/listDownloadsResponse.ts b/ui/lib/api/schemas/listDownloadsResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..588e636915f39e1919036e8a9e076eee4399abc0 --- /dev/null +++ b/ui/lib/api/schemas/listDownloadsResponse.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { DownloadProgress } from './downloadProgress' + +export interface ListDownloadsResponse { + downloads: DownloadProgress[] +} diff --git a/ui/lib/api/schemas/listOperationsResponse.ts b/ui/lib/api/schemas/listOperationsResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..ca25efb5ae89b94b27fe3410f324d3d81e43cbd3 --- /dev/null +++ b/ui/lib/api/schemas/listOperationsResponse.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { JobSummary } from './jobSummary' + +export interface ListOperationsResponse { + operations: JobSummary[] +} diff --git a/ui/lib/api/schemas/listProjectsResponse.ts b/ui/lib/api/schemas/listProjectsResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..27be6c64ca10d54a8e1888ce1fc45ff7da4d194b --- /dev/null +++ b/ui/lib/api/schemas/listProjectsResponse.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ProjectSummary } from './projectSummary' + +export interface ListProjectsResponse { + projects: ProjectSummary[] +} diff --git a/ui/lib/api/schemas/maskData.ts b/ui/lib/api/schemas/maskData.ts new file mode 100644 index 0000000000000000000000000000000000000000..8037f98a75aeb9327c646936344a705af456572b --- /dev/null +++ b/ui/lib/api/schemas/maskData.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' +import type { MaskRole } from './maskRole' + +export interface MaskData { + blob: BlobRef + role: MaskRole +} diff --git a/ui/lib/api/schemas/maskDataPatch.ts b/ui/lib/api/schemas/maskDataPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..057c902c851dc76d61a9df2f03eb7aae23ff901d --- /dev/null +++ b/ui/lib/api/schemas/maskDataPatch.ts @@ -0,0 +1,10 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' + +export interface MaskDataPatch { + blob?: null | BlobRef +} diff --git a/ui/lib/api/schemas/maskRegionRequest.ts b/ui/lib/api/schemas/maskRegionRequest.ts deleted file mode 100644 index 09bfb1265e272e895804d2c534fba5f391a4c7c5..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/maskRegionRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { Region } from './region' - -export interface MaskRegionRequest { - data: number[] - region?: null | Region -} diff --git a/ui/lib/api/schemas/maskRole.ts b/ui/lib/api/schemas/maskRole.ts new file mode 100644 index 0000000000000000000000000000000000000000..be193379021fe9ce8cde8f820f225fd0edcb4e79 --- /dev/null +++ b/ui/lib/api/schemas/maskRole.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type MaskRole = (typeof MaskRole)[keyof typeof MaskRole] + +export const MaskRole = { + brushInpaint: 'brushInpaint', + segment: 'segment', + bubble: 'bubble', +} as const diff --git a/ui/lib/api/schemas/node.ts b/ui/lib/api/schemas/node.ts new file mode 100644 index 0000000000000000000000000000000000000000..524e8aa3c36d7eb8b73792bd8e641999089e436c --- /dev/null +++ b/ui/lib/api/schemas/node.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { NodeId } from './nodeId' +import type { NodeKind } from './nodeKind' +import type { Transform } from './transform' + +export interface Node { + id: NodeId + kind: NodeKind + transform?: Transform + visible: boolean +} diff --git a/ui/lib/api/schemas/nodeDataPatch.ts b/ui/lib/api/schemas/nodeDataPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..78691abae14278c8f1ba1c6b6de614fb7a788746 --- /dev/null +++ b/ui/lib/api/schemas/nodeDataPatch.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ImageDataPatch } from './imageDataPatch' +import type { MaskDataPatch } from './maskDataPatch' +import type { TextDataPatch } from './textDataPatch' + +export type NodeDataPatch = + | { + text: TextDataPatch + } + | { + image: ImageDataPatch + } + | { + mask: MaskDataPatch + } diff --git a/ui/lib/api/schemas/reorderRequest.ts b/ui/lib/api/schemas/nodeId.ts similarity index 65% rename from ui/lib/api/schemas/reorderRequest.ts rename to ui/lib/api/schemas/nodeId.ts index 26e8f07e1862eeefbd345379c66ef6409b8b978d..8e8acf8f028bcd98303f948415471f67847b84ac 100644 --- a/ui/lib/api/schemas/reorderRequest.ts +++ b/ui/lib/api/schemas/nodeId.ts @@ -4,6 +4,4 @@ * OpenAPI spec version: 0.0.1 */ -export interface ReorderRequest { - ids: string[] -} +export type NodeId = string diff --git a/ui/lib/api/schemas/nodeKind.ts b/ui/lib/api/schemas/nodeKind.ts new file mode 100644 index 0000000000000000000000000000000000000000..3d3102b147601f7e94c696e60acf544de5db39de --- /dev/null +++ b/ui/lib/api/schemas/nodeKind.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ImageData } from './imageData' +import type { MaskData } from './maskData' +import type { TextData } from './textData' + +export type NodeKind = + | { + image: ImageData + } + | { + text: TextData + } + | { + mask: MaskData + } diff --git a/ui/lib/api/schemas/nodePatch.ts b/ui/lib/api/schemas/nodePatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..c55174e64949838f2e9aaa2ae72aaa7dc662a10a --- /dev/null +++ b/ui/lib/api/schemas/nodePatch.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { NodeDataPatch } from './nodeDataPatch' +import type { Transform } from './transform' + +export interface NodePatch { + data?: null | NodeDataPatch + transform?: null | Transform + /** @nullable */ + visible?: boolean | null +} diff --git a/ui/lib/api/schemas/op.ts b/ui/lib/api/schemas/op.ts new file mode 100644 index 0000000000000000000000000000000000000000..b7eec6bb90359724aea7e9aba406aa8213cd3a26 --- /dev/null +++ b/ui/lib/api/schemas/op.ts @@ -0,0 +1,86 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { Node } from './node' +import type { NodeId } from './nodeId' +import type { NodePatch } from './nodePatch' +import type { Page } from './page' +import type { PageId } from './pageId' +import type { PagePatch } from './pagePatch' +import type { ProjectMetaPatch } from './projectMetaPatch' + +export type Op = + | { + updateProjectMeta: { + patch: ProjectMetaPatch + prev?: ProjectMetaPatch + } + } + | { + addPage: { + /** @minimum 0 */ + at: number + page: Page + } + } + | { + removePage: { + id: PageId + /** @minimum 0 */ + prev_index: number + prev_page: Page + } + } + | { + updatePage: { + id: PageId + patch: PagePatch + prev?: PagePatch + } + } + | { + reorderPages: { + order: PageId[] + prev_order: PageId[] + } + } + | { + addNode: { + /** @minimum 0 */ + at: number + node: Node + page: PageId + } + } + | { + removeNode: { + id: NodeId + page: PageId + /** @minimum 0 */ + prev_index: number + prev_node: Node + } + } + | { + updateNode: { + id: NodeId + page: PageId + patch: NodePatch + prev?: NodePatch + } + } + | { + reorderNodes: { + order: NodeId[] + page: PageId + prev_order: NodeId[] + } + } + | { + batch: { + label: string + ops: Op[] + } + } diff --git a/ui/lib/api/schemas/openProjectRequest.ts b/ui/lib/api/schemas/openProjectRequest.ts new file mode 100644 index 0000000000000000000000000000000000000000..e678e0cf8943f3a6a84e37f1d1e9ce0dd871e265 --- /dev/null +++ b/ui/lib/api/schemas/openProjectRequest.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface OpenProjectRequest { + /** `.khrproj/` directory basename (no extension). Must exist under the + managed projects directory. */ + id: string +} diff --git a/ui/lib/api/schemas/page.ts b/ui/lib/api/schemas/page.ts new file mode 100644 index 0000000000000000000000000000000000000000..d52fd8c6ede2c511a0104d427baa7c5ba1f138e4 --- /dev/null +++ b/ui/lib/api/schemas/page.ts @@ -0,0 +1,19 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { PageId } from './pageId' +import type { PageNodes } from './pageNodes' + +export interface Page { + /** @minimum 0 */ + height: number + id: PageId + name: string + /** Stacking = insertion order. Bottom-first: `source` is typically first, + `rendered` typically last. */ + nodes: PageNodes + /** @minimum 0 */ + width: number +} diff --git a/ui/lib/api/schemas/pageId.ts b/ui/lib/api/schemas/pageId.ts new file mode 100644 index 0000000000000000000000000000000000000000..effb40a58e1edbb1797c2be0b11d6b318498c991 --- /dev/null +++ b/ui/lib/api/schemas/pageId.ts @@ -0,0 +1,7 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type PageId = string diff --git a/ui/lib/api/schemas/pageNodes.ts b/ui/lib/api/schemas/pageNodes.ts new file mode 100644 index 0000000000000000000000000000000000000000..1eb528434f1b6a571053c5e608848162b79d2943 --- /dev/null +++ b/ui/lib/api/schemas/pageNodes.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { Node } from './node' + +/** + * Stacking = insertion order. Bottom-first: `source` is typically first, +`rendered` typically last. + */ +export type PageNodes = { [key: string]: Node } diff --git a/ui/lib/api/schemas/pagePatch.ts b/ui/lib/api/schemas/pagePatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..e19877eeb75f42a2c16a184e253d9bbae70464dd --- /dev/null +++ b/ui/lib/api/schemas/pagePatch.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface PagePatch { + /** + * @minimum 0 + * @nullable + */ + height?: number | null + /** @nullable */ + name?: string | null + /** + * @minimum 0 + * @nullable + */ + width?: number | null +} diff --git a/ui/lib/api/schemas/pipelineConfig.ts b/ui/lib/api/schemas/pipelineConfig.ts index 90d431f3f68ded1fff29750913b7eb47a68afb50..0a388e6aa2003afeb9f2ca6d37073403d8faf678 100644 --- a/ui/lib/api/schemas/pipelineConfig.ts +++ b/ui/lib/api/schemas/pipelineConfig.ts @@ -10,6 +10,7 @@ Values are engine IDs (e.g. "pp-doclayout-v3", "comic-text-detector"). Empty string means use default. */ export interface PipelineConfig { + bubble_segmenter?: string detector?: string font_detector?: string inpainter?: string diff --git a/ui/lib/api/schemas/pipelineConfigPatch.ts b/ui/lib/api/schemas/pipelineConfigPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..4a0c1c166717fb76cffe5916b1cfc38160ff820c --- /dev/null +++ b/ui/lib/api/schemas/pipelineConfigPatch.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface PipelineConfigPatch { + /** @nullable */ + bubbleSegmenter?: string | null + /** @nullable */ + detector?: string | null + /** @nullable */ + fontDetector?: string | null + /** @nullable */ + inpainter?: string | null + /** @nullable */ + ocr?: string | null + /** @nullable */ + renderer?: string | null + /** @nullable */ + segmenter?: string | null + /** @nullable */ + translator?: string | null +} diff --git a/ui/lib/api/schemas/pipelineJobRequest.ts b/ui/lib/api/schemas/pipelineJobRequest.ts deleted file mode 100644 index 49ead4085f79fc72345b1c252152aefd20ac04c6..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/pipelineJobRequest.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { PipelineLlmRequest } from './pipelineLlmRequest' -import type { TextShaderEffect } from './textShaderEffect' -import type { TextStrokeStyle } from './textStrokeStyle' - -export interface PipelineJobRequest { - /** @nullable */ - defaultFont?: string | null - /** @nullable */ - documentId?: string | null - /** @nullable */ - language?: string | null - llm?: null | PipelineLlmRequest - shaderEffect?: null | TextShaderEffect - shaderStroke?: null | TextStrokeStyle - /** @nullable */ - systemPrompt?: string | null -} diff --git a/ui/lib/api/schemas/pipelineLlmRequest.ts b/ui/lib/api/schemas/pipelineLlmRequest.ts deleted file mode 100644 index a3cf9247a2bd4ff9c8c5cfb9dc72cdb7258c2969..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/pipelineLlmRequest.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { LlmGenerationOptions } from './llmGenerationOptions' -import type { LlmTarget } from './llmTarget' - -export interface PipelineLlmRequest { - options?: null | LlmGenerationOptions - target: LlmTarget -} diff --git a/ui/lib/api/schemas/jobState.ts b/ui/lib/api/schemas/pipelineProgress.ts similarity index 51% rename from ui/lib/api/schemas/jobState.ts rename to ui/lib/api/schemas/pipelineProgress.ts index 1d639db7f9827d329f7d44a67bd6c3cf69fadec7..1e43f178789e711d43598baff02f594845220946 100644 --- a/ui/lib/api/schemas/jobState.ts +++ b/ui/lib/api/schemas/pipelineProgress.ts @@ -3,24 +3,21 @@ * Do not edit manually. * OpenAPI spec version: 0.0.1 */ -import type { JobStatus } from './jobStatus' +import type { PipelineStatus } from './pipelineStatus' +import type { PipelineStep } from './pipelineStep' -export interface JobState { +export interface PipelineProgress { /** @minimum 0 */ - currentDocument: number + currentPage: number /** @minimum 0 */ currentStepIndex: number - /** @nullable */ - error?: string | null - id: string - kind: string + jobId: string /** @minimum 0 */ overallPercent: number - status: JobStatus - /** @nullable */ - step?: string | null + status: PipelineStatus + step?: null | PipelineStep /** @minimum 0 */ - totalDocuments: number + totalPages: number /** @minimum 0 */ totalSteps: number } diff --git a/ui/lib/api/schemas/pipelineStatus.ts b/ui/lib/api/schemas/pipelineStatus.ts new file mode 100644 index 0000000000000000000000000000000000000000..848a5f2a6f4c970f23deb54dde56faf20099b566 --- /dev/null +++ b/ui/lib/api/schemas/pipelineStatus.ts @@ -0,0 +1,20 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type PipelineStatus = + | { + status: 'running' + } + | { + status: 'completed' + } + | { + status: 'cancelled' + } + | { + reason: string + status: 'failed' + } diff --git a/ui/lib/api/schemas/pipelineStep.ts b/ui/lib/api/schemas/pipelineStep.ts new file mode 100644 index 0000000000000000000000000000000000000000..0868d0af024cc1239471897b13d701c65dbdb664 --- /dev/null +++ b/ui/lib/api/schemas/pipelineStep.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export type PipelineStep = (typeof PipelineStep)[keyof typeof PipelineStep] + +export const PipelineStep = { + detect: 'detect', + ocr: 'ocr', + inpaint: 'inpaint', + llmGenerate: 'llmGenerate', + render: 'render', +} as const diff --git a/ui/lib/api/schemas/projectMeta.ts b/ui/lib/api/schemas/projectMeta.ts new file mode 100644 index 0000000000000000000000000000000000000000..0847bcbb9537db89de4d3c12037b9890594d8928 --- /dev/null +++ b/ui/lib/api/schemas/projectMeta.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ProjectStyle } from './projectStyle' + +export interface ProjectMeta { + createdAt: string + name: string + style?: ProjectStyle + updatedAt: string +} diff --git a/ui/lib/api/schemas/projectMetaPatch.ts b/ui/lib/api/schemas/projectMetaPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..a1c19e867b4328b176d0bf8b8a07acb5ba4ad191 --- /dev/null +++ b/ui/lib/api/schemas/projectMetaPatch.ts @@ -0,0 +1,14 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ProjectStyle } from './projectStyle' + +export interface ProjectMetaPatch { + /** @nullable */ + name?: string | null + style?: null | ProjectStyle + /** @nullable */ + updatedAt?: string | null +} diff --git a/ui/lib/api/schemas/documentStyle.ts b/ui/lib/api/schemas/projectStyle.ts similarity index 81% rename from ui/lib/api/schemas/documentStyle.ts rename to ui/lib/api/schemas/projectStyle.ts index f919f8227b1e59620c8c6ca486679c86516f5b78..e35222b69c5358a4ebe41033baeadb87f05142e2 100644 --- a/ui/lib/api/schemas/documentStyle.ts +++ b/ui/lib/api/schemas/projectStyle.ts @@ -4,7 +4,7 @@ * OpenAPI spec version: 0.0.1 */ -export interface DocumentStyle { +export interface ProjectStyle { /** @nullable */ defaultFont?: string | null } diff --git a/ui/lib/api/schemas/projectSummary.ts b/ui/lib/api/schemas/projectSummary.ts new file mode 100644 index 0000000000000000000000000000000000000000..e26200cb12fcdc38d242f10b57c54ac31313586a --- /dev/null +++ b/ui/lib/api/schemas/projectSummary.ts @@ -0,0 +1,21 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface ProjectSummary { + /** Stable identifier — the `.khrproj` directory basename (without the + extension). Clients address projects by this. */ + id: string + name: string + /** Absolute filesystem path. Informational; clients never need to pass + it back in — they use `id`. */ + path: string + /** + * Last modification time of the project directory on disk (ms since + UNIX epoch). Used for "recent projects" ordering. + * @minimum 0 + */ + updatedAtMs?: number +} diff --git a/ui/lib/api/schemas/providerPatch.ts b/ui/lib/api/schemas/providerPatch.ts new file mode 100644 index 0000000000000000000000000000000000000000..8b241b1a87f08e3e370089477823f218f098e625 --- /dev/null +++ b/ui/lib/api/schemas/providerPatch.ts @@ -0,0 +1,16 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface ProviderPatch { + /** + * `"[REDACTED]"` → keep existing keyring secret; empty → clear; otherwise save. + * @nullable + */ + apiKey?: string | null + /** @nullable */ + baseUrl?: string | null + id: string +} diff --git a/ui/lib/api/schemas/exportResult.ts b/ui/lib/api/schemas/providerSecretRequest.ts similarity index 59% rename from ui/lib/api/schemas/exportResult.ts rename to ui/lib/api/schemas/providerSecretRequest.ts index a8eafeb9484f32063edb5773108dfdcdf4d95505..57c2d10b51d240392006410b6358ece3391be9e5 100644 --- a/ui/lib/api/schemas/exportResult.ts +++ b/ui/lib/api/schemas/providerSecretRequest.ts @@ -4,7 +4,6 @@ * OpenAPI spec version: 0.0.1 */ -export interface ExportResult { - /** @minimum 0 */ - count: number +export interface ProviderSecretRequest { + secret: string } diff --git a/ui/lib/api/schemas/putMaskResponse.ts b/ui/lib/api/schemas/putMaskResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..805ec8f51016a3dfbaa437ab4bb9d152e504eb0d --- /dev/null +++ b/ui/lib/api/schemas/putMaskResponse.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' +import type { NodeId } from './nodeId' + +export interface PutMaskResponse { + blob: BlobRef + node: NodeId +} diff --git a/ui/lib/api/schemas/renderRequest.ts b/ui/lib/api/schemas/renderRequest.ts deleted file mode 100644 index 5c60293bc1e61dcd7aa356443a2113d2199e6102..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/renderRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { TextShaderEffect } from './textShaderEffect' -import type { TextStrokeStyle } from './textStrokeStyle' - -export interface RenderRequest { - shaderEffect?: null | TextShaderEffect - shaderStroke?: null | TextStrokeStyle - /** @nullable */ - textBlockId?: string | null -} diff --git a/ui/lib/api/schemas/scene.ts b/ui/lib/api/schemas/scene.ts new file mode 100644 index 0000000000000000000000000000000000000000..e7b6562b1373d281cbfc267c9fd46bc52e12ed42 --- /dev/null +++ b/ui/lib/api/schemas/scene.ts @@ -0,0 +1,13 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { ProjectMeta } from './projectMeta' +import type { ScenePages } from './scenePages' + +export interface Scene { + /** Pages in insertion order; `IndexMap` ordering *is* the page order. */ + pages: ScenePages + project: ProjectMeta +} diff --git a/ui/lib/api/schemas/scenePages.ts b/ui/lib/api/schemas/scenePages.ts new file mode 100644 index 0000000000000000000000000000000000000000..7abbe407f8d83dc37e8544c11657ea1d793050bc --- /dev/null +++ b/ui/lib/api/schemas/scenePages.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { Page } from './page' + +/** + * Pages in insertion order; `IndexMap` ordering *is* the page order. + */ +export type ScenePages = { [key: string]: Page } diff --git a/ui/lib/api/schemas/sceneSnapshot.ts b/ui/lib/api/schemas/sceneSnapshot.ts new file mode 100644 index 0000000000000000000000000000000000000000..8c049fe551090ff036805b96eebfd6d1879593b3 --- /dev/null +++ b/ui/lib/api/schemas/sceneSnapshot.ts @@ -0,0 +1,15 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { Scene } from './scene' + +/** + * JSON-shaped scene snapshot for the UI (no postcard decoder in JS). + */ +export interface SceneSnapshot { + /** @minimum 0 */ + epoch: number + scene: Scene +} diff --git a/ui/lib/api/schemas/snapshotEvent.ts b/ui/lib/api/schemas/snapshotEvent.ts new file mode 100644 index 0000000000000000000000000000000000000000..8615d86713e631c03261d8d6093054ee19450d81 --- /dev/null +++ b/ui/lib/api/schemas/snapshotEvent.ts @@ -0,0 +1,12 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { DownloadProgress } from './downloadProgress' +import type { JobSummary } from './jobSummary' + +export interface SnapshotEvent { + downloads: DownloadProgress[] + jobs: JobSummary[] +} diff --git a/ui/lib/api/schemas/startDownloadRequest.ts b/ui/lib/api/schemas/startDownloadRequest.ts new file mode 100644 index 0000000000000000000000000000000000000000..a393dcf26725de131b0162d7f4635ed3f6d18e79 --- /dev/null +++ b/ui/lib/api/schemas/startDownloadRequest.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface StartDownloadRequest { + /** Package id, as declared via `declare_hf_model_package!` + (e.g. `"model:comic-text-detector:yolo-v5"`). */ + modelId: string +} diff --git a/ui/lib/api/schemas/startDownloadResponse.ts b/ui/lib/api/schemas/startDownloadResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..ced5098f7a12d44915eb5c0a65c1c54064cbc05f --- /dev/null +++ b/ui/lib/api/schemas/startDownloadResponse.ts @@ -0,0 +1,11 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface StartDownloadResponse { + /** Operation id. Reusing the package id keeps ids meaningful for clients + watching progress events. */ + operationId: string +} diff --git a/ui/lib/api/schemas/startPipelineRequest.ts b/ui/lib/api/schemas/startPipelineRequest.ts new file mode 100644 index 0000000000000000000000000000000000000000..140ed44df54b02aa406ea32194d9e7459a9d0e30 --- /dev/null +++ b/ui/lib/api/schemas/startPipelineRequest.ts @@ -0,0 +1,24 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { PageId } from './pageId' +import type { Region } from './region' + +export interface StartPipelineRequest { + /** @nullable */ + defaultFont?: string | null + /** + * `None` → whole project, `Some(pages)` → just those pages. + * @nullable + */ + pages?: PageId[] | null + region?: null | Region + /** Engine ids (`inventory::submit!` ids) to run in order. */ + steps: string[] + /** @nullable */ + systemPrompt?: string | null + /** @nullable */ + targetLanguage?: string | null +} diff --git a/ui/lib/api/schemas/startPipelineResponse.ts b/ui/lib/api/schemas/startPipelineResponse.ts new file mode 100644 index 0000000000000000000000000000000000000000..17f6b5842dcbdefb882ef343f775f00da51b9b0c --- /dev/null +++ b/ui/lib/api/schemas/startPipelineResponse.ts @@ -0,0 +1,9 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ + +export interface StartPipelineResponse { + operationId: string +} diff --git a/ui/lib/api/schemas/textBlockInput.ts b/ui/lib/api/schemas/textBlockInput.ts deleted file mode 100644 index c06b6716add0ab9dcfa25ea8a42c2e0e0f6a3b2a..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/textBlockInput.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { TextStyle } from './textStyle' - -export interface TextBlockInput { - height: number - /** @nullable */ - id?: string | null - style?: null | TextStyle - /** @nullable */ - text?: string | null - /** @nullable */ - translation?: string | null - width: number - x: number - y: number -} diff --git a/ui/lib/api/schemas/textBlockPatch.ts b/ui/lib/api/schemas/textBlockPatch.ts deleted file mode 100644 index 0f07c9086eb58b1012c9012f73daa594619aefa8..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/textBlockPatch.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { TextStyle } from './textStyle' - -export interface TextBlockPatch { - /** @nullable */ - height?: number | null - style?: null | TextStyle - /** @nullable */ - text?: string | null - /** @nullable */ - translation?: string | null - /** @nullable */ - width?: number | null - /** @nullable */ - x?: number | null - /** @nullable */ - y?: number | null -} diff --git a/ui/lib/api/schemas/textData.ts b/ui/lib/api/schemas/textData.ts new file mode 100644 index 0000000000000000000000000000000000000000..bdbb63670f683dff8ff05bdaf1a95b6a6c38b56d --- /dev/null +++ b/ui/lib/api/schemas/textData.ts @@ -0,0 +1,35 @@ +/** + * Generated by orval v8.8.0 🍺 + * Do not edit manually. + * OpenAPI spec version: 0.0.1 + */ +import type { BlobRef } from './blobRef' +import type { FontPrediction } from './fontPrediction' +import type { TextDirection } from './textDirection' +import type { TextStyle } from './textStyle' +import type { Transform } from './transform' + +export interface TextData { + confidence?: number + /** @nullable */ + detectedFontSizePx?: number | null + /** @nullable */ + detector?: string | null + fontPrediction?: null | FontPrediction + /** @nullable */ + linePolygons?: number[][][] | null + lockLayoutBox?: boolean + renderedDirection?: null | TextDirection + /** @nullable */ + rotationDeg?: number | null + sourceDirection?: null | TextDirection + /** @nullable */ + sourceLang?: string | null + sprite?: null | BlobRef + spriteTransform?: null | Transform + style?: null | TextStyle + /** @nullable */ + text?: string | null + /** @nullable */ + translation?: string | null +} diff --git a/ui/lib/api/schemas/textBlockDetail.ts b/ui/lib/api/schemas/textDataPatch.ts similarity index 60% rename from ui/lib/api/schemas/textBlockDetail.ts rename to ui/lib/api/schemas/textDataPatch.ts index 74217b517cfd4203b16d4ebd5a626cef35fe411c..b99accc233c760487273504c42e3a06eccb0c48c 100644 --- a/ui/lib/api/schemas/textBlockDetail.ts +++ b/ui/lib/api/schemas/textDataPatch.ts @@ -3,49 +3,39 @@ * Do not edit manually. * OpenAPI spec version: 0.0.1 */ +import type { BlobRef } from './blobRef' import type { FontPrediction } from './fontPrediction' import type { TextDirection } from './textDirection' import type { TextStyle } from './textStyle' +import type { Transform } from './transform' -export interface TextBlockDetail { - confidence: number +/** + * For fields where "set to None" is meaningful (e.g. clearing a translation), +the outer `Option` is "patch present", the inner is "value present". + */ +export interface TextDataPatch { + /** @nullable */ + confidence?: number | null /** @nullable */ detectedFontSizePx?: number | null /** @nullable */ detector?: string | null fontPrediction?: null | FontPrediction - height: number - id: string /** @nullable */ linePolygons?: number[][][] | null /** @nullable */ - renderHeight?: number | null - /** @nullable */ - renderWidth?: number | null - /** - * Actual render area position/size (when bubble expansion is used). - * @nullable - */ - renderX?: number | null - /** @nullable */ - renderY?: number | null - /** - * Blob hash for the rendered text block sprite. - * @nullable - */ - rendered?: string | null + lockLayoutBox?: boolean | null renderedDirection?: null | TextDirection /** @nullable */ rotationDeg?: number | null sourceDirection?: null | TextDirection /** @nullable */ - sourceLanguage?: string | null + sourceLang?: string | null + sprite?: null | BlobRef + spriteTransform?: null | Transform style?: null | TextStyle /** @nullable */ text?: string | null /** @nullable */ translation?: string | null - width: number - x: number - y: number } diff --git a/ui/lib/api/schemas/textDirection.ts b/ui/lib/api/schemas/textDirection.ts index 09ac017d9d55491864582c50b7945d817c49d1ae..a6a8e42163550a979c6a64a40f795c948a902f92 100644 --- a/ui/lib/api/schemas/textDirection.ts +++ b/ui/lib/api/schemas/textDirection.ts @@ -4,9 +4,12 @@ * OpenAPI spec version: 0.0.1 */ +/** + * Reading axis of a text block. + */ export type TextDirection = (typeof TextDirection)[keyof typeof TextDirection] export const TextDirection = { - Horizontal: 'Horizontal', - Vertical: 'Vertical', + horizontal: 'horizontal', + vertical: 'vertical', } as const diff --git a/ui/lib/api/schemas/transferStatus.ts b/ui/lib/api/schemas/transferStatus.ts deleted file mode 100644 index 8f873353843c8da216d1b56b5d122539fbff001b..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/transferStatus.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ - -export type TransferStatus = (typeof TransferStatus)[keyof typeof TransferStatus] - -export const TransferStatus = { - started: 'started', - downloading: 'downloading', - completed: 'completed', - failed: 'failed', -} as const diff --git a/ui/lib/api/schemas/createTextBlock.ts b/ui/lib/api/schemas/transform.ts similarity index 75% rename from ui/lib/api/schemas/createTextBlock.ts rename to ui/lib/api/schemas/transform.ts index 2e4430ea9cdafd2633305ef88d6e9bc2a09f7d05..d898489e2b51ff9c85377f16aca4fc106acf2c0f 100644 --- a/ui/lib/api/schemas/createTextBlock.ts +++ b/ui/lib/api/schemas/transform.ts @@ -4,8 +4,9 @@ * OpenAPI spec version: 0.0.1 */ -export interface CreateTextBlock { +export interface Transform { height: number + rotationDeg?: number width: number x: number y: number diff --git a/ui/lib/api/schemas/translateRequest.ts b/ui/lib/api/schemas/translateRequest.ts deleted file mode 100644 index d17abf9a6ff577cce71431a569acd53d18459f58..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/translateRequest.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ - -export interface TranslateRequest { - /** @nullable */ - language?: string | null - /** @nullable */ - systemPrompt?: string | null - /** @nullable */ - textBlockId?: string | null -} diff --git a/ui/lib/api/schemas/updateConfig200.ts b/ui/lib/api/schemas/updateConfig200.ts deleted file mode 100644 index bfd91cfcf68b73674d99c5dc5590f161f3d75204..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/updateConfig200.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { DataConfig } from './dataConfig' -import type { HttpConfig } from './httpConfig' -import type { PipelineConfig } from './pipelineConfig' -import type { ProviderConfig } from './providerConfig' - -export type UpdateConfig200 = { - data?: DataConfig - http?: HttpConfig - pipeline?: PipelineConfig - providers?: ProviderConfig[] -} diff --git a/ui/lib/api/schemas/updateConfigBody.ts b/ui/lib/api/schemas/updateConfigBody.ts deleted file mode 100644 index 5eb8ea9814ccdb6acbd2ff4d03f91c16e0fe12de..0000000000000000000000000000000000000000 --- a/ui/lib/api/schemas/updateConfigBody.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import type { DataConfig } from './dataConfig' -import type { HttpConfig } from './httpConfig' -import type { PipelineConfig } from './pipelineConfig' -import type { ProviderConfig } from './providerConfig' - -export type UpdateConfigBody = { - data?: DataConfig - http?: HttpConfig - pipeline?: PipelineConfig - providers?: ProviderConfig[] -} diff --git a/ui/lib/api/system/system.ts b/ui/lib/api/system/system.ts deleted file mode 100644 index 9856494414fc0537ac1fe1072ca07d3df5e93df1..0000000000000000000000000000000000000000 --- a/ui/lib/api/system/system.ts +++ /dev/null @@ -1,796 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation, useQuery } from '@tanstack/react-query' -import type { - DataTag, - DefinedInitialDataOptions, - DefinedUseQueryResult, - MutationFunction, - QueryClient, - QueryFunction, - QueryKey, - UndefinedInitialDataOptions, - UseMutationOptions, - UseMutationResult, - UseQueryOptions, - UseQueryResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { - ApiError, - FontFaceInfo, - GetConfig200, - GetEngineCatalog200, - GoogleFontCatalogResponse, - MetaInfo, - UpdateConfig200, - UpdateConfigBody, -} from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getGetConfigUrl = () => { - return `/api/v1/config` -} - -export const getConfig = async (options?: RequestInit): Promise => { - return fetchApi(getGetConfigUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetConfigQueryKey = () => { - return [`/api/v1/config`] as const -} - -export const getGetConfigQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetConfigQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getConfig({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetConfigQueryResult = NonNullable>> -export type GetConfigQueryError = ApiError - -export function useGetConfig>, TError = ApiError>( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetConfig>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetConfig>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetConfig>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetConfigQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getUpdateConfigUrl = () => { - return `/api/v1/config` -} - -export const updateConfig = async ( - updateConfigBody: UpdateConfigBody, - options?: RequestInit, -): Promise => { - return fetchApi(getUpdateConfigUrl(), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(updateConfigBody), - }) -} - -export const getUpdateConfigMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: UpdateConfigBody }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { data: UpdateConfigBody }, - TContext -> => { - const mutationKey = ['updateConfig'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { data: UpdateConfigBody } - > = (props) => { - const { data } = props ?? {} - - return updateConfig(data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type UpdateConfigMutationResult = NonNullable>> -export type UpdateConfigMutationBody = UpdateConfigBody -export type UpdateConfigMutationError = ApiError - -export const useUpdateConfig = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { data: UpdateConfigBody }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { data: UpdateConfigBody }, - TContext -> => { - return useMutation(getUpdateConfigMutationOptions(options), queryClient) -} -export const getGetEngineCatalogUrl = () => { - return `/api/v1/engines` -} - -export const getEngineCatalog = async (options?: RequestInit): Promise => { - return fetchApi(getGetEngineCatalogUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetEngineCatalogQueryKey = () => { - return [`/api/v1/engines`] as const -} - -export const getGetEngineCatalogQueryOptions = < - TData = Awaited>, - TError = unknown, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetEngineCatalogQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getEngineCatalog({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetEngineCatalogQueryResult = NonNullable>> -export type GetEngineCatalogQueryError = unknown - -export function useGetEngineCatalog< - TData = Awaited>, - TError = unknown, ->( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetEngineCatalog< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetEngineCatalog< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetEngineCatalog< - TData = Awaited>, - TError = unknown, ->( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetEngineCatalogQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getListFontsUrl = () => { - return `/api/v1/fonts` -} - -export const listFonts = async (options?: RequestInit): Promise => { - return fetchApi(getListFontsUrl(), { - ...options, - method: 'GET', - }) -} - -export const getListFontsQueryKey = () => { - return [`/api/v1/fonts`] as const -} - -export const getListFontsQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getListFontsQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - listFonts({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type ListFontsQueryResult = NonNullable>> -export type ListFontsQueryError = ApiError - -export function useListFonts>, TError = ApiError>( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useListFonts>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useListFonts>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useListFonts>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getListFontsQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getGetGoogleFontsCatalogUrl = () => { - return `/api/v1/fonts/google/catalog` -} - -export const getGoogleFontsCatalog = async ( - options?: RequestInit, -): Promise => { - return fetchApi(getGetGoogleFontsCatalogUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetGoogleFontsCatalogQueryKey = () => { - return [`/api/v1/fonts/google/catalog`] as const -} - -export const getGetGoogleFontsCatalogQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetGoogleFontsCatalogQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getGoogleFontsCatalog({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetGoogleFontsCatalogQueryResult = NonNullable< - Awaited> -> -export type GetGoogleFontsCatalogQueryError = ApiError - -export function useGetGoogleFontsCatalog< - TData = Awaited>, - TError = ApiError, ->( - options: { - query: Partial< - UseQueryOptions>, TError, TData> - > & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetGoogleFontsCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetGoogleFontsCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetGoogleFontsCatalog< - TData = Awaited>, - TError = ApiError, ->( - options?: { - query?: Partial< - UseQueryOptions>, TError, TData> - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetGoogleFontsCatalogQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getFetchGoogleFontUrl = (family: string) => { - return `/api/v1/fonts/google/${family}/fetch` -} - -export const fetchGoogleFont = async ( - family: string, - options?: RequestInit, -): Promise => { - return fetchApi(getFetchGoogleFontUrl(family), { - ...options, - method: 'POST', - }) -} - -export const getFetchGoogleFontMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { family: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { family: string }, - TContext -> => { - const mutationKey = ['fetchGoogleFont'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { family: string } - > = (props) => { - const { family } = props ?? {} - - return fetchGoogleFont(family, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type FetchGoogleFontMutationResult = NonNullable>> - -export type FetchGoogleFontMutationError = ApiError - -export const useFetchGoogleFont = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { family: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { family: string }, - TContext -> => { - return useMutation(getFetchGoogleFontMutationOptions(options), queryClient) -} -export const getGetGoogleFontFileUrl = (family: string) => { - return `/api/v1/fonts/google/${family}/file` -} - -export const getGoogleFontFile = async (family: string, options?: RequestInit): Promise => { - return fetchApi(getGetGoogleFontFileUrl(family), { - ...options, - method: 'GET', - }) -} - -export const getGetGoogleFontFileQueryKey = (family: string) => { - return [`/api/v1/fonts/google/${family}/file`] as const -} - -export const getGetGoogleFontFileQueryOptions = < - TData = Awaited>, - TError = ApiError, ->( - family: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, -) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetGoogleFontFileQueryKey(family) - - const queryFn: QueryFunction>> = ({ signal }) => - getGoogleFontFile(family, { signal, ...requestOptions }) - - return { - queryKey, - queryFn, - enabled: !!family, - gcTime: 300000, - retry: 1, - ...queryOptions, - } as UseQueryOptions>, TError, TData> & { - queryKey: DataTag - } -} - -export type GetGoogleFontFileQueryResult = NonNullable< - Awaited> -> -export type GetGoogleFontFileQueryError = ApiError - -export function useGetGoogleFontFile< - TData = Awaited>, - TError = ApiError, ->( - family: string, - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetGoogleFontFile< - TData = Awaited>, - TError = ApiError, ->( - family: string, - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetGoogleFontFile< - TData = Awaited>, - TError = ApiError, ->( - family: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetGoogleFontFile< - TData = Awaited>, - TError = ApiError, ->( - family: string, - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetGoogleFontFileQueryOptions(family, options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} - -export const getGetMetaUrl = () => { - return `/api/v1/meta` -} - -export const getMeta = async (options?: RequestInit): Promise => { - return fetchApi(getGetMetaUrl(), { - ...options, - method: 'GET', - }) -} - -export const getGetMetaQueryKey = () => { - return [`/api/v1/meta`] as const -} - -export const getGetMetaQueryOptions = < - TData = Awaited>, - TError = ApiError, ->(options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter -}) => { - const { query: queryOptions, request: requestOptions } = options ?? {} - - const queryKey = queryOptions?.queryKey ?? getGetMetaQueryKey() - - const queryFn: QueryFunction>> = ({ signal }) => - getMeta({ signal, ...requestOptions }) - - return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions< - Awaited>, - TError, - TData - > & { queryKey: DataTag } -} - -export type GetMetaQueryResult = NonNullable>> -export type GetMetaQueryError = ApiError - -export function useGetMeta>, TError = ApiError>( - options: { - query: Partial>, TError, TData>> & - Pick< - DefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): DefinedUseQueryResult & { queryKey: DataTag } -export function useGetMeta>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> & - Pick< - UndefinedInitialDataOptions< - Awaited>, - TError, - Awaited> - >, - 'initialData' - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } -export function useGetMeta>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } - -export function useGetMeta>, TError = ApiError>( - options?: { - query?: Partial>, TError, TData>> - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseQueryResult & { queryKey: DataTag } { - const queryOptions = getGetMetaQueryOptions(options) - - const query = useQuery(queryOptions, queryClient) as UseQueryResult & { - queryKey: DataTag - } - - return { ...query, queryKey: queryOptions.queryKey } -} diff --git a/ui/lib/api/text-blocks/text-blocks.ts b/ui/lib/api/text-blocks/text-blocks.ts deleted file mode 100644 index 0719dfbb2d61e010773abc74a23a48d7fd1e47fa..0000000000000000000000000000000000000000 --- a/ui/lib/api/text-blocks/text-blocks.ts +++ /dev/null @@ -1,315 +0,0 @@ -/** - * Generated by orval v8.8.0 🍺 - * Do not edit manually. - * OpenAPI spec version: 0.0.1 - */ -import { useMutation } from '@tanstack/react-query' -import type { - MutationFunction, - QueryClient, - UseMutationOptions, - UseMutationResult, -} from '@tanstack/react-query' - -import { fetchApi } from '.././fetch' -import type { - ApiError, - CreateTextBlock, - TextBlockDetail, - TextBlockInput, - TextBlockPatch, -} from '../schemas' - -type SecondParameter unknown> = Parameters[1] - -export const getPutTextBlocksUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/text-blocks` -} - -export const putTextBlocks = async ( - documentId: string, - textBlockInput: TextBlockInput[], - options?: RequestInit, -): Promise => { - return fetchApi(getPutTextBlocksUrl(documentId), { - ...options, - method: 'PUT', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(textBlockInput), - }) -} - -export const getPutTextBlocksMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TextBlockInput[] }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TextBlockInput[] }, - TContext -> => { - const mutationKey = ['putTextBlocks'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: TextBlockInput[] } - > = (props) => { - const { documentId, data } = props ?? {} - - return putTextBlocks(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type PutTextBlocksMutationResult = NonNullable>> -export type PutTextBlocksMutationBody = TextBlockInput[] -export type PutTextBlocksMutationError = ApiError - -export const usePutTextBlocks = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: TextBlockInput[] }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: TextBlockInput[] }, - TContext -> => { - return useMutation(getPutTextBlocksMutationOptions(options), queryClient) -} -export const getCreateTextBlockUrl = (documentId: string) => { - return `/api/v1/documents/${documentId}/text-blocks` -} - -export const createTextBlock = async ( - documentId: string, - createTextBlock: CreateTextBlock, - options?: RequestInit, -): Promise => { - return fetchApi(getCreateTextBlockUrl(documentId), { - ...options, - method: 'POST', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(createTextBlock), - }) -} - -export const getCreateTextBlockMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: CreateTextBlock }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: CreateTextBlock }, - TContext -> => { - const mutationKey = ['createTextBlock'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; data: CreateTextBlock } - > = (props) => { - const { documentId, data } = props ?? {} - - return createTextBlock(documentId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type CreateTextBlockMutationResult = NonNullable>> -export type CreateTextBlockMutationBody = CreateTextBlock -export type CreateTextBlockMutationError = ApiError - -export const useCreateTextBlock = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; data: CreateTextBlock }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; data: CreateTextBlock }, - TContext -> => { - return useMutation(getCreateTextBlockMutationOptions(options), queryClient) -} -export const getDeleteTextBlockUrl = (documentId: string, textBlockId: string) => { - return `/api/v1/documents/${documentId}/text-blocks/${textBlockId}` -} - -export const deleteTextBlock = async ( - documentId: string, - textBlockId: string, - options?: RequestInit, -): Promise => { - return fetchApi(getDeleteTextBlockUrl(documentId, textBlockId), { - ...options, - method: 'DELETE', - }) -} - -export const getDeleteTextBlockMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string }, - TContext -> => { - const mutationKey = ['deleteTextBlock'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; textBlockId: string } - > = (props) => { - const { documentId, textBlockId } = props ?? {} - - return deleteTextBlock(documentId, textBlockId, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type DeleteTextBlockMutationResult = NonNullable>> - -export type DeleteTextBlockMutationError = ApiError - -export const useDeleteTextBlock = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; textBlockId: string }, - TContext -> => { - return useMutation(getDeleteTextBlockMutationOptions(options), queryClient) -} -export const getPatchTextBlockUrl = (documentId: string, textBlockId: string) => { - return `/api/v1/documents/${documentId}/text-blocks/${textBlockId}` -} - -export const patchTextBlock = async ( - documentId: string, - textBlockId: string, - textBlockPatch: TextBlockPatch, - options?: RequestInit, -): Promise => { - return fetchApi(getPatchTextBlockUrl(documentId, textBlockId), { - ...options, - method: 'PATCH', - headers: { 'Content-Type': 'application/json', ...options?.headers }, - body: JSON.stringify(textBlockPatch), - }) -} - -export const getPatchTextBlockMutationOptions = (options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string; data: TextBlockPatch }, - TContext - > - request?: SecondParameter -}): UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string; data: TextBlockPatch }, - TContext -> => { - const mutationKey = ['patchTextBlock'] - const { mutation: mutationOptions, request: requestOptions } = options - ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey - ? options - : { ...options, mutation: { ...options.mutation, mutationKey } } - : { mutation: { mutationKey }, request: undefined } - - const mutationFn: MutationFunction< - Awaited>, - { documentId: string; textBlockId: string; data: TextBlockPatch } - > = (props) => { - const { documentId, textBlockId, data } = props ?? {} - - return patchTextBlock(documentId, textBlockId, data, requestOptions) - } - - return { mutationFn, ...mutationOptions } -} - -export type PatchTextBlockMutationResult = NonNullable>> -export type PatchTextBlockMutationBody = TextBlockPatch -export type PatchTextBlockMutationError = ApiError - -export const usePatchTextBlock = ( - options?: { - mutation?: UseMutationOptions< - Awaited>, - TError, - { documentId: string; textBlockId: string; data: TextBlockPatch }, - TContext - > - request?: SecondParameter - }, - queryClient?: QueryClient, -): UseMutationResult< - Awaited>, - TError, - { documentId: string; textBlockId: string; data: TextBlockPatch }, - TContext -> => { - return useMutation(getPatchTextBlockMutationOptions(options), queryClient) -} diff --git a/ui/openapi.json b/ui/openapi.json index 24c0df114a43c60e18a9f8c14529f3af274bd292..79cae23f49e9ebdc5312916397a0cb84cc02d02d 100644 --- a/ui/openapi.json +++ b/ui/openapi.json @@ -7,12 +7,12 @@ "paths": { "/blobs/{hash}": { "get": { - "tags": ["blobs"], - "operationId": "getBlob", + "operationId": "get_blob", "parameters": [ { "name": "hash", "in": "path", + "description": "Blake3 hash of the blob", "required": true, "schema": { "type": "string" @@ -23,36 +23,7 @@ "200": { "description": "", "content": { - "application/octet-stream": { - "schema": { - "type": "array", - "items": { - "type": "integer", - "format": "int32", - "minimum": 0 - } - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } + "application/octet-stream": {} } } } @@ -60,133 +31,27 @@ }, "/config": { "get": { - "tags": ["system"], - "operationId": "getConfig", + "operationId": "get_config", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "data": { - "oneOf": [ - { - "$ref": "#/components/schemas/DataConfig" - } - ], - "default": { - "path": "C:\\Users\\Mayo\\AppData\\Local\\Koharu" - } - }, - "http": { - "oneOf": [ - { - "$ref": "#/components/schemas/HttpConfig" - } - ], - "default": { - "connect_timeout": 20, - "max_retries": 3, - "read_timeout": 300 - } - }, - "pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/PipelineConfig" - } - ], - "default": { - "detector": "comic-text-bubble-detector", - "font_detector": "yuzumarker-font-detection", - "inpainter": "aot-inpainting", - "ocr": "paddle-ocr-vl-1.5", - "renderer": "koharu-renderer", - "segmenter": "comic-text-detector-seg", - "translator": "llm" - } - }, - "providers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ProviderConfig" - }, - "default": [] - } - } - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/AppConfig" } } } } } }, - "put": { - "tags": ["system"], - "operationId": "updateConfig", + "patch": { + "operationId": "patch_config", "requestBody": { "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "data": { - "oneOf": [ - { - "$ref": "#/components/schemas/DataConfig" - } - ], - "default": { - "path": "C:\\Users\\Mayo\\AppData\\Local\\Koharu" - } - }, - "http": { - "oneOf": [ - { - "$ref": "#/components/schemas/HttpConfig" - } - ], - "default": { - "connect_timeout": 20, - "max_retries": 3, - "read_timeout": 300 - } - }, - "pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/PipelineConfig" - } - ], - "default": { - "detector": "comic-text-bubble-detector", - "font_detector": "yuzumarker-font-detection", - "inpainter": "aot-inpainting", - "ocr": "paddle-ocr-vl-1.5", - "renderer": "koharu-renderer", - "segmenter": "comic-text-detector-seg", - "translator": "llm" - } - }, - "providers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ProviderConfig" - }, - "default": [] - } - } + "$ref": "#/components/schemas/ConfigPatch" } } }, @@ -198,95 +63,76 @@ "content": { "application/json": { "schema": { - "type": "object", - "properties": { - "data": { - "oneOf": [ - { - "$ref": "#/components/schemas/DataConfig" - } - ], - "default": { - "path": "C:\\Users\\Mayo\\AppData\\Local\\Koharu" - } - }, - "http": { - "oneOf": [ - { - "$ref": "#/components/schemas/HttpConfig" - } - ], - "default": { - "connect_timeout": 20, - "max_retries": 3, - "read_timeout": 300 - } - }, - "pipeline": { - "oneOf": [ - { - "$ref": "#/components/schemas/PipelineConfig" - } - ], - "default": { - "detector": "comic-text-bubble-detector", - "font_detector": "yuzumarker-font-detection", - "inpainter": "aot-inpainting", - "ocr": "paddle-ocr-vl-1.5", - "renderer": "koharu-renderer", - "segmenter": "comic-text-detector-seg", - "translator": "llm" - } - }, - "providers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/ProviderConfig" - }, - "default": [] - } - } + "$ref": "#/components/schemas/AppConfig" } } } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } + } + } + } + }, + "/config/providers/{id}/secret": { + "put": { + "summary": "Save (or overwrite) the keyring secret for a provider. Creates the\nprovider entry in `config.providers` if it didn't exist. `PUT` because\nsetting the secret is idempotent for the same body.", + "operationId": "set_provider_secret", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Provider id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ProviderSecretRequest" } } + }, + "required": true + }, + "responses": { + "204": { + "description": "" + } + } + }, + "delete": { + "summary": "Clear a provider's keyring secret. The provider entry itself is kept.", + "operationId": "clear_provider_secret", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "Provider id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "" } } } }, - "/documents": { + "/downloads": { "get": { - "tags": ["documents"], - "operationId": "listDocuments", + "operationId": "list_downloads", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DocumentSummary" - } - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ListDownloadsResponse" } } } @@ -294,72 +140,58 @@ } }, "post": { - "tags": ["documents"], - "operationId": "importDocuments", - "parameters": [ - { - "name": "mode", - "in": "query", - "required": false, - "schema": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/ImportMode" - } - ] - } - } - ], + "operationId": "start_download", "requestBody": { "content": { - "multipart/form-data": { + "application/json": { "schema": { - "type": "object", - "required": ["files"], - "properties": { - "files": { - "type": "array", - "items": { - "type": "string", - "format": "binary" - } - } - } + "$ref": "#/components/schemas/StartDownloadRequest" } } }, "required": true }, "responses": { - "200": { + "202": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ImportResult" + "$ref": "#/components/schemas/StartDownloadResponse" } } } - }, - "400": { + } + } + } + }, + "/engines": { + "get": { + "operationId": "get_engine_catalog", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/EngineCatalog" } } } - }, - "503": { + } + } + } + }, + "/events": { + "get": { + "operationId": "events", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/AppEvent" } } } @@ -367,20 +199,9 @@ } } }, - "/documents/order": { - "put": { - "tags": ["documents"], - "operationId": "reorderDocuments", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ReorderRequest" - } - } - }, - "required": true - }, + "/fonts": { + "get": { + "operationId": "list_fonts", "responses": { "200": { "description": "", @@ -389,28 +210,25 @@ "schema": { "type": "array", "items": { - "$ref": "#/components/schemas/DocumentSummary" + "$ref": "#/components/schemas/FontFaceInfo" } } } } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + } + } + } + }, + "/google-fonts": { + "get": { + "operationId": "get_google_fonts_catalog", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/GoogleFontCatalog" } } } @@ -418,14 +236,14 @@ } } }, - "/documents/{document_id}": { - "get": { - "tags": ["documents"], - "operationId": "getDocument", + "/google-fonts/{family}/fetch": { + "post": { + "operationId": "fetch_google_font", "parameters": [ { - "name": "document_id", + "name": "family", "in": "path", + "description": "Google Fonts family name", "required": true, "schema": { "type": "string" @@ -433,83 +251,82 @@ } ], "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/DocumentDetail" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } + "204": { + "description": "" } } } }, - "/documents/{document_id}/brush-layer": { - "put": { - "tags": ["regions"], - "operationId": "updateBrushLayer", + "/google-fonts/{family}/{file}": { + "get": { + "operationId": "get_google_font_file", "parameters": [ { - "name": "document_id", + "name": "family", + "in": "path", + "description": "Google Fonts family name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "file", "in": "path", + "description": "Font filename", "required": true, "schema": { "type": "string" } } ], + "responses": { + "200": { + "description": "", + "content": { + "font/ttf": {} + } + } + } + } + }, + "/history/apply": { + "post": { + "operationId": "apply_command", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/BrushRegionRequest" + "$ref": "#/components/schemas/Op" } } }, "required": true }, "responses": { - "204": { - "description": "" - }, - "404": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/HistoryResult" } } } - }, - "503": { + } + } + } + }, + "/history/redo": { + "post": { + "operationId": "redo", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/HistoryResult" } } } @@ -517,40 +334,33 @@ } } }, - "/documents/{document_id}/detect": { + "/history/undo": { "post": { - "tags": ["processing"], - "operationId": "detectDocument", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], + "operationId": "undo", "responses": { - "204": { - "description": "" - }, - "404": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/HistoryResult" } } } - }, - "503": { + } + } + } + }, + "/llm/catalog": { + "get": { + "operationId": "get_catalog", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/LlmCatalog" } } } @@ -558,70 +368,76 @@ } } }, - "/documents/{document_id}/export/{format}": { + "/llm/current": { "get": { - "tags": ["exports"], - "operationId": "exportDocument", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "format", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "layer", - "in": "query", - "required": false, - "schema": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/ExportLayer" - } - ] - } - } - ], + "operationId": "get_current_llm", "responses": { "200": { "description": "", "content": { - "application/octet-stream": { + "application/json": { "schema": { - "type": "string" + "$ref": "#/components/schemas/LlmState" } } } + } + } + }, + "put": { + "operationId": "put_current_llm", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/LlmLoadRequest" + } + } }, - "404": { + "required": true + }, + "responses": { + "204": { + "description": "" + } + } + }, + "delete": { + "operationId": "delete_current_llm", + "responses": { + "204": { + "description": "" + } + } + } + }, + "/meta": { + "get": { + "operationId": "get_meta", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/MetaInfo" } } } - }, - "503": { + } + } + } + }, + "/operations": { + "get": { + "operationId": "list_operations", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ListOperationsResponse" } } } @@ -629,14 +445,14 @@ } } }, - "/documents/{document_id}/inpaint": { - "post": { - "tags": ["processing"], - "operationId": "inpaintDocument", + "/operations/{id}": { + "delete": { + "operationId": "cancel_operation", "parameters": [ { - "name": "document_id", + "name": "id", "in": "path", + "description": "Operation id", "required": true, "schema": { "type": "string" @@ -646,23 +462,25 @@ "responses": { "204": { "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + } + } + } + }, + "/pages": { + "post": { + "operationId": "create_pages", + "requestBody": { + "content": { + "multipart/form-data": {} + } + }, + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/CreatePagesResponse" } } } @@ -670,50 +488,28 @@ } } }, - "/documents/{document_id}/inpaint-region": { + "/pages/from-paths": { "post": { - "tags": ["regions"], - "operationId": "inpaintRegion", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], + "summary": "Create pages by reading image files from absolute paths on the server's\nfilesystem. This is the Tauri desktop import path — the webview picker\nreturns paths, and the backend reads + decodes + hashes them in parallel\nwithout a round-trip through JS memory or a multipart upload body.", + "description": "Web clients should keep using `POST /pages` with multipart.", + "operationId": "create_pages_from_paths", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/InpaintRegionRequest" + "$ref": "#/components/schemas/CreatePagesFromPathsRequest" } } }, "required": true }, "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/CreatePagesResponse" } } } @@ -721,50 +517,32 @@ } } }, - "/documents/{document_id}/mask": { - "put": { - "tags": ["regions"], - "operationId": "updateMask", + "/pages/{id}/image-layers": { + "post": { + "operationId": "add_image_layer", "parameters": [ { - "name": "document_id", + "name": "id", "in": "path", + "description": "Page id", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/PageId" } } ], "requestBody": { "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/MaskRegionRequest" - } - } - }, - "required": true + "multipart/form-data": {} + } }, "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/AddImageLayerResponse" } } } @@ -772,40 +550,42 @@ } } }, - "/documents/{document_id}/recognize": { - "post": { - "tags": ["processing"], - "operationId": "recognizeDocument", + "/pages/{id}/masks/{role}": { + "put": { + "summary": "Upsert the `Mask { role }` node on a page with the raw image bytes in\nthe body. Emits `Op::UpdateNode` if a mask of that role exists, else\n`Op::AddNode`. Used by the repair-brush / segment-edit flow; the\nfollow-up localized inpaint is a separate `POST /pipelines` call.", + "operationId": "put_mask", "parameters": [ { - "name": "document_id", + "name": "id", "in": "path", + "description": "Page id", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/PageId" + } + }, + { + "name": "role", + "in": "path", + "description": "Mask role (segment|brushInpaint)", + "required": true, + "schema": { + "$ref": "#/components/schemas/MaskRole" } } ], + "requestBody": { + "content": { + "image/png": {} + } + }, "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/PutMaskResponse" } } } @@ -813,77 +593,80 @@ } } }, - "/documents/{document_id}/render": { - "post": { - "tags": ["processing"], - "operationId": "renderDocument", + "/pages/{id}/thumbnail": { + "get": { + "operationId": "get_page_thumbnail", "parameters": [ { - "name": "document_id", + "name": "id", "in": "path", + "description": "Page id", "required": true, "schema": { - "type": "string" + "$ref": "#/components/schemas/PageId" } } ], + "responses": { + "200": { + "description": "", + "content": { + "image/webp": {} + } + } + } + } + }, + "/pipelines": { + "post": { + "operationId": "start_pipeline", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/RenderRequest" + "$ref": "#/components/schemas/StartPipelineRequest" } } }, "required": true }, "responses": { - "204": { - "description": "" - }, - "404": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/StartPipelineResponse" } } } - }, - "503": { + } + } + } + }, + "/projects": { + "get": { + "operationId": "list_projects", + "responses": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ListProjectsResponse" } } } } } - } - }, - "/documents/{document_id}/style": { - "patch": { - "tags": ["documents"], - "operationId": "updateDocumentStyle", - "parameters": [ - { - "name": "document_id", - "in": "path", - "description": "Document ID", - "required": true, - "schema": { - "type": "string" - } - } - ], + }, + "post": { + "operationId": "create_project", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UpdateDocumentStyleRequest" + "$ref": "#/components/schemas/CreateProjectRequest" } } }, @@ -895,27 +678,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UpdateDocumentStyleRequest" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ProjectSummary" } } } @@ -923,77 +686,49 @@ } } }, - "/documents/{document_id}/text-blocks": { + "/projects/current": { "put": { - "tags": ["text-blocks"], - "operationId": "putTextBlocks", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], + "operationId": "put_current_project", "requestBody": { "content": { "application/json": { "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/TextBlockInput" - } + "$ref": "#/components/schemas/OpenProjectRequest" } } }, "required": true }, "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { + "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ProjectSummary" } } } } } }, - "post": { - "tags": ["text-blocks"], - "operationId": "createTextBlock", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } + "delete": { + "operationId": "delete_current_project", + "responses": { + "204": { + "description": "" } - ], + } + } + }, + "/projects/current/export": { + "post": { + "operationId": "export_current_project", "requestBody": { "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/CreateTextBlock" + "$ref": "#/components/schemas/ExportProjectRequest" } } }, @@ -1001,772 +736,29 @@ }, "responses": { "200": { - "description": "", + "description": "Export bytes. Content-Type is `application/zip` when the format produces multiple files.", "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TextBlockDetail" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/documents/{document_id}/text-blocks/{text_block_id}": { - "delete": { - "tags": ["text-blocks"], - "operationId": "deleteTextBlock", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "text_block_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - }, - "patch": { - "tags": ["text-blocks"], - "operationId": "patchTextBlock", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "text_block_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TextBlockPatch" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TextBlockDetail" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/documents/{document_id}/thumbnail": { - "get": { - "tags": ["documents"], - "operationId": "getDocumentThumbnail", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - }, - { - "name": "size", - "in": "query", - "required": false, - "schema": { - "type": ["integer", "null"], - "format": "int32", - "minimum": 0 - } - } - ], - "responses": { - "200": { - "description": "", - "content": { - "image/webp": { - "schema": { - "type": "string" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/documents/{document_id}/translate": { - "post": { - "tags": ["processing"], - "operationId": "translateDocument", - "parameters": [ - { - "name": "document_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/TranslateRequest" - } - } - }, - "required": true - }, - "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/downloads": { - "get": { - "tags": ["downloads"], - "operationId": "listDownloads", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DownloadState" - } - } - } - } - } - } - } - }, - "/engines": { - "get": { - "tags": ["system"], - "operationId": "getEngineCatalog", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "object", - "required": [ - "detectors", - "fontDetectors", - "segmenters", - "ocr", - "translators", - "inpainters", - "renderers" - ], - "properties": { - "detectors": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "fontDetectors": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "inpainters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "ocr": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "renderers": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "segmenters": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - }, - "translators": { - "type": "array", - "items": { - "$ref": "#/components/schemas/EngineCatalogEntry" - } - } - } - } - } - } - } - } - } - }, - "/exports": { - "post": { - "tags": ["exports"], - "operationId": "batchExport", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExportBatchRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ExportResult" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/fonts": { - "get": { - "tags": ["system"], - "operationId": "listFonts", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/FontFaceInfo" - } - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/fonts/google/catalog": { - "get": { - "tags": ["system"], - "operationId": "getGoogleFontsCatalog", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/GoogleFontCatalogResponse" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/fonts/google/{family}/fetch": { - "post": { - "tags": ["system"], - "operationId": "fetchGoogleFont", - "parameters": [ - { - "name": "family", - "in": "path", - "description": "Font family name", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/FontFaceInfo" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/fonts/google/{family}/file": { - "get": { - "tags": ["system"], - "operationId": "getGoogleFontFile", - "parameters": [ - { - "name": "family", - "in": "path", - "description": "Font family name", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "Font file bytes", - "content": { - "font/ttf": {} - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/jobs": { - "get": { - "tags": ["jobs"], - "operationId": "listJobs", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "type": "array", - "items": { - "$ref": "#/components/schemas/JobState" - } - } - } - } - } - } - } - }, - "/jobs/pipeline": { - "post": { - "tags": ["jobs"], - "operationId": "startPipeline", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/PipelineJobRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JobState" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/jobs/{job_id}": { - "get": { - "tags": ["jobs"], - "operationId": "getJob", - "parameters": [ - { - "name": "job_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/JobState" - } - } - } - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - }, - "delete": { - "tags": ["jobs"], - "operationId": "cancelJob", - "parameters": [ - { - "name": "job_id", - "in": "path", - "required": true, - "schema": { - "type": "string" - } - } - ], - "responses": { - "204": { - "description": "" - }, - "404": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - } - }, - "/llm": { - "get": { - "tags": ["llm"], - "operationId": "getLlm", - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LlmState" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - } - } - }, - "put": { - "tags": ["llm"], - "operationId": "loadLlm", - "requestBody": { - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LlmLoadRequest" - } - } - }, - "required": true - }, - "responses": { - "200": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LlmState" - } - } - } - }, - "400": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } + "application/octet-stream": {} } } } - }, - "delete": { - "tags": ["llm"], - "operationId": "unloadLlm", + } + }, + "/projects/import": { + "post": { + "operationId": "import_project", + "requestBody": { + "content": { + "application/zip": {} + } + }, "responses": { "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LlmState" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/ProjectSummary" } } } @@ -1774,55 +766,29 @@ } } }, - "/llm/catalog": { + "/scene.bin": { "get": { - "tags": ["llm"], - "operationId": "getLlmCatalog", + "operationId": "get_scene_bin", "responses": { "200": { "description": "", "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LlmCatalog" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" - } - } + "application/octet-stream": {} } } } } }, - "/meta": { + "/scene.json": { "get": { - "tags": ["system"], - "operationId": "getMeta", + "operationId": "get_scene_json", "responses": { "200": { "description": "", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MetaInfo" - } - } - } - }, - "503": { - "description": "", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiError" + "$ref": "#/components/schemas/SceneSnapshot" } } } @@ -1833,189 +799,311 @@ }, "components": { "schemas": { - "ApiError": { + "AddImageLayerResponse": { "type": "object", - "required": ["status", "message"], + "required": ["node"], "properties": { - "message": { - "type": "string" - }, - "status": { - "type": "integer", - "format": "int32", - "minimum": 0 + "node": { + "$ref": "#/components/schemas/NodeId" } } }, - "BrushRegionRequest": { + "AppConfig": { "type": "object", - "required": ["data", "region"], "properties": { "data": { - "type": "array", - "items": { - "type": "integer", - "format": "int32", - "minimum": 0 + "oneOf": [ + { + "$ref": "#/components/schemas/DataConfig" + } + ], + "default": { + "path": "C:\\Users\\Mayo\\AppData\\Local\\Koharu" } }, - "region": { - "$ref": "#/components/schemas/Region" - } - } - }, - "CreateTextBlock": { - "type": "object", - "required": ["x", "y", "width", "height"], - "properties": { - "height": { - "type": "number", - "format": "float" - }, - "width": { - "type": "number", - "format": "float" + "http": { + "oneOf": [ + { + "$ref": "#/components/schemas/HttpConfig" + } + ], + "default": { + "connect_timeout": 20, + "max_retries": 3, + "read_timeout": 300 + } }, - "x": { - "type": "number", - "format": "float" + "pipeline": { + "oneOf": [ + { + "$ref": "#/components/schemas/PipelineConfig" + } + ], + "default": { + "bubble_segmenter": "speech-bubble-segmentation", + "detector": "pp-doclayout-v3", + "font_detector": "yuzumarker-font-detection", + "inpainter": "aot-inpainting", + "ocr": "paddle-ocr-vl-1.5", + "renderer": "koharu-renderer", + "segmenter": "comic-text-detector-seg", + "translator": "llm-translate" + } }, - "y": { - "type": "number", - "format": "float" - } - } - }, - "DataConfig": { - "type": "object", - "required": ["path"], - "properties": { - "path": { - "type": "string" + "providers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ProviderConfig" + }, + "default": [] } } }, - "DocumentDetail": { - "type": "object", - "required": ["id", "name", "width", "height", "textBlocks", "image"], - "properties": { - "brushLayer": { - "type": ["string", "null"], - "description": "Blob hash for the brush layer." + "AppEvent": { + "oneOf": [ + { + "type": "object", + "required": ["id", "kind", "event"], + "properties": { + "event": { + "type": "string", + "enum": ["jobStarted"] + }, + "id": { + "type": "string" + }, + "kind": { + "type": "string" + } + } }, - "height": { - "type": "integer", - "format": "int32", - "minimum": 0 + { + "allOf": [ + { + "$ref": "#/components/schemas/PipelineProgress" + }, + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["jobProgress"] + } + } + } + ] }, - "id": { - "type": "string" + { + "allOf": [ + { + "$ref": "#/components/schemas/JobFinishedEvent" + }, + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["jobFinished"] + } + } + } + ] }, - "image": { - "type": "string", - "description": "Blob hash for the source image layer." + { + "allOf": [ + { + "$ref": "#/components/schemas/DownloadProgress" + }, + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["downloadProgress"] + } + } + } + ] }, - "inpainted": { - "type": ["string", "null"], - "description": "Blob hash for the inpainted layer." + { + "type": "object", + "required": ["target", "event"], + "properties": { + "event": { + "type": "string", + "enum": ["llmLoading"] + }, + "target": { + "$ref": "#/components/schemas/LlmTarget" + } + } }, - "name": { - "type": "string" + { + "type": "object", + "required": ["target", "event"], + "properties": { + "event": { + "type": "string", + "enum": ["llmLoaded"] + }, + "target": { + "$ref": "#/components/schemas/LlmTarget" + } + } }, - "rendered": { - "type": ["string", "null"], - "description": "Blob hash for the rendered composite layer." + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["llmFailed"] + }, + "target": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/LlmTarget" + } + ] + } + } }, - "segment": { - "type": ["string", "null"], - "description": "Blob hash for the segmentation mask layer." + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["llmUnloaded"] + } + } }, - "style": { + { + "allOf": [ + { + "$ref": "#/components/schemas/SnapshotEvent" + }, + { + "type": "object", + "required": ["event"], + "properties": { + "event": { + "type": "string", + "enum": ["snapshot"] + } + } + } + ] + } + ] + }, + "BlobRef": { + "type": "string", + "description": "Hex-encoded blake3 hash of an immutable blob." + }, + "ConfigPatch": { + "type": "object", + "description": "Sparse patch for `koharu_app::AppConfig`. Missing fields mean \"leave\nas-is\". The `providers` field, if present, replaces the whole provider\nlist — we do not merge by id because ordering is meaningful.", + "properties": { + "data": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/DataConfigPatch" + } + ] + }, + "http": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/HttpConfigPatch" + } + ] + }, + "pipeline": { "oneOf": [ { "type": "null" }, { - "$ref": "#/components/schemas/DocumentStyle" + "$ref": "#/components/schemas/PipelineConfigPatch" } ] }, - "textBlocks": { + "providers": { + "type": ["array", "null"], + "items": { + "$ref": "#/components/schemas/ProviderPatch" + }, + "description": "If present, replaces the entire list. Api_key values of `\"[REDACTED]\"`\nare interpreted as \"leave the existing secret alone\"." + } + } + }, + "CreatePagesFromPathsRequest": { + "type": "object", + "required": ["paths"], + "properties": { + "paths": { "type": "array", "items": { - "$ref": "#/components/schemas/TextBlockDetail" + "type": "string" } }, - "width": { - "type": "integer", - "format": "int32", - "minimum": 0 + "replace": { + "type": "boolean" } } }, - "DocumentStyle": { + "CreatePagesResponse": { "type": "object", + "required": ["pages"], "properties": { - "defaultFont": { - "type": ["string", "null"] + "pages": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PageId" + } } } }, - "DocumentSummary": { + "CreateProjectRequest": { "type": "object", - "required": [ - "id", - "name", - "width", - "height", - "order", - "hasSegment", - "hasInpainted", - "hasBrushLayer", - "hasRendered", - "textBlockCount" - ], + "required": ["name"], "properties": { - "hasBrushLayer": { - "type": "boolean" - }, - "hasInpainted": { - "type": "boolean" - }, - "hasRendered": { - "type": "boolean" - }, - "hasSegment": { - "type": "boolean" - }, - "height": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "id": { - "type": "string" - }, "name": { "type": "string" - }, - "order": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, - "textBlockCount": { - "type": "integer", - "minimum": 0 - }, - "width": { - "type": "integer", - "format": "int32", - "minimum": 0 } } }, - "DownloadState": { + "DataConfig": { + "type": "object", + "required": ["path"], + "properties": { + "path": { + "type": "string" + } + } + }, + "DataConfigPatch": { + "type": "object", + "properties": { + "path": { + "type": ["string", "null"] + } + } + }, + "DownloadProgress": { "type": "object", "required": ["id", "filename", "downloaded", "status"], "properties": { @@ -2024,9 +1112,6 @@ "format": "int64", "minimum": 0 }, - "error": { - "type": ["string", "null"] - }, "filename": { "type": "string" }, @@ -2034,7 +1119,7 @@ "type": "string" }, "status": { - "$ref": "#/components/schemas/TransferStatus" + "$ref": "#/components/schemas/DownloadStatus" }, "total": { "type": ["integer", "null"], @@ -2043,6 +1128,116 @@ } } }, + "DownloadStatus": { + "oneOf": [ + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["started"] + } + } + }, + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["downloading"] + } + } + }, + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["completed"] + } + } + }, + { + "type": "object", + "required": ["reason", "status"], + "properties": { + "reason": { + "type": "string" + }, + "status": { + "type": "string", + "enum": ["failed"] + } + } + } + ] + }, + "EngineCatalog": { + "type": "object", + "required": [ + "detectors", + "fontDetectors", + "segmenters", + "bubbleSegmenters", + "ocr", + "translators", + "inpainters", + "renderers" + ], + "properties": { + "bubbleSegmenters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "detectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "fontDetectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "inpainters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "ocr": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "renderers": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "segmenters": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + }, + "translators": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EngineCatalogEntry" + } + } + } + }, "EngineCatalogEntry": { "type": "object", "required": ["id", "name", "produces"], @@ -2061,32 +1256,23 @@ } } }, - "ExportBatchRequest": { - "type": "object", - "properties": { - "layer": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/ExportLayer" - } - ] - } - } - }, - "ExportLayer": { + "ExportFormat": { "type": "string", - "enum": ["rendered", "inpainted"] + "enum": ["khr", "psd", "rendered", "inpainted"] }, - "ExportResult": { + "ExportProjectRequest": { "type": "object", - "required": ["count"], + "required": ["format"], "properties": { - "count": { - "type": "integer", - "minimum": 0 + "format": { + "$ref": "#/components/schemas/ExportFormat" + }, + "pages": { + "type": ["array", "null"], + "items": { + "$ref": "#/components/schemas/PageId" + }, + "description": "Optional subset of pages; defaults to every page." } } }, @@ -2114,39 +1300,39 @@ "FontPrediction": { "type": "object", "required": [ - "top_fonts", - "named_fonts", + "topFonts", + "namedFonts", "direction", - "text_color", - "stroke_color", - "font_size_px", - "stroke_width_px", - "line_height", - "angle_deg" + "textColor", + "strokeColor", + "fontSizePx", + "strokeWidthPx", + "lineHeight", + "angleDeg" ], "properties": { - "angle_deg": { + "angleDeg": { "type": "number", "format": "float" }, "direction": { "$ref": "#/components/schemas/TextDirection" }, - "font_size_px": { + "fontSizePx": { "type": "number", "format": "float" }, - "line_height": { + "lineHeight": { "type": "number", "format": "float" }, - "named_fonts": { + "namedFonts": { "type": "array", "items": { "$ref": "#/components/schemas/NamedFontPrediction" } }, - "stroke_color": { + "strokeColor": { "type": "array", "items": { "type": "integer", @@ -2154,11 +1340,11 @@ "minimum": 0 } }, - "stroke_width_px": { + "strokeWidthPx": { "type": "number", "format": "float" }, - "text_color": { + "textColor": { "type": "array", "items": { "type": "integer", @@ -2166,7 +1352,7 @@ "minimum": 0 } }, - "top_fonts": { + "topFonts": { "type": "array", "items": { "$ref": "#/components/schemas/TopFont" @@ -2178,13 +1364,22 @@ "type": "string", "enum": ["system", "google"] }, - "GoogleFontCatalogEntry": { + "GoogleFontCatalog": { "type": "object", - "required": ["family", "category", "subsets", "cached"], + "required": ["fonts"], + "properties": { + "fonts": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GoogleFontEntry" + } + } + } + }, + "GoogleFontEntry": { + "type": "object", + "required": ["family", "category", "subsets", "variants"], "properties": { - "cached": { - "type": "boolean" - }, "category": { "type": "string" }, @@ -2196,24 +1391,40 @@ "items": { "type": "string" } + }, + "variants": { + "type": "array", + "items": { + "$ref": "#/components/schemas/GoogleFontVariant" + } } } }, - "GoogleFontCatalogResponse": { + "GoogleFontVariant": { "type": "object", - "required": ["fonts", "recommended"], + "required": ["style", "weight", "filename"], "properties": { - "fonts": { - "type": "array", - "items": { - "$ref": "#/components/schemas/GoogleFontCatalogEntry" - } + "filename": { + "type": "string" }, - "recommended": { - "type": "array", - "items": { - "type": "string" - } + "style": { + "type": "string" + }, + "weight": { + "type": "integer", + "format": "int32", + "minimum": 0 + } + } + }, + "HistoryResult": { + "type": "object", + "properties": { + "epoch": { + "type": ["integer", "null"], + "format": "int64", + "description": "New epoch. `None` only for a no-op undo/redo at the stack boundary.", + "minimum": 0 } } }, @@ -2240,56 +1451,115 @@ } } }, - "ImportMode": { - "type": "string", - "enum": ["replace", "append"] - }, - "ImportResult": { + "HttpConfigPatch": { "type": "object", - "required": ["totalCount", "documents"], "properties": { - "documents": { - "type": "array", - "items": { - "$ref": "#/components/schemas/DocumentSummary" - } + "connectTimeout": { + "type": ["integer", "null"], + "format": "int64", + "minimum": 0 }, - "totalCount": { - "type": "integer", + "maxRetries": { + "type": ["integer", "null"], + "format": "int32", + "minimum": 0 + }, + "readTimeout": { + "type": ["integer", "null"], + "format": "int64", "minimum": 0 } } }, - "InpaintRegionRequest": { + "ImageData": { "type": "object", - "required": ["region"], + "required": ["role", "blob", "naturalWidth", "naturalHeight"], "properties": { - "region": { - "$ref": "#/components/schemas/Region" + "blob": { + "$ref": "#/components/schemas/BlobRef" + }, + "name": { + "type": ["string", "null"] + }, + "naturalHeight": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "naturalWidth": { + "type": "integer", + "format": "int32", + "minimum": 0 + }, + "opacity": { + "type": "number", + "format": "float" + }, + "role": { + "$ref": "#/components/schemas/ImageRole", + "description": "Role tags differentiate source / inpainted / rendered / user-imported images.\nRole is immutable on an existing node — switching roles = delete + add." } } }, - "JobState": { + "ImageDataPatch": { "type": "object", - "required": [ - "id", - "kind", - "status", - "currentDocument", - "totalDocuments", - "currentStepIndex", - "totalSteps", - "overallPercent" - ], "properties": { - "currentDocument": { - "type": "integer", + "blob": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/BlobRef" + } + ] + }, + "name": { + "type": ["string", "null"] + }, + "naturalHeight": { + "type": ["integer", "null"], + "format": "int32", "minimum": 0 }, - "currentStepIndex": { - "type": "integer", + "naturalWidth": { + "type": ["integer", "null"], + "format": "int32", "minimum": 0 }, + "opacity": { + "type": ["number", "null"], + "format": "float" + } + } + }, + "ImageRole": { + "type": "string", + "enum": ["source", "inpainted", "rendered", "custom"] + }, + "JobFinishedEvent": { + "type": "object", + "required": ["id", "status"], + "properties": { + "error": { + "type": ["string", "null"] + }, + "id": { + "type": "string" + }, + "status": { + "$ref": "#/components/schemas/JobStatus" + } + } + }, + "JobStatus": { + "type": "string", + "enum": ["running", "completed", "completed_with_errors", "cancelled", "failed"] + }, + "JobSummary": { + "type": "object", + "required": ["id", "kind", "status"], + "properties": { "error": { "type": ["string", "null"] }, @@ -2299,30 +1569,46 @@ "kind": { "type": "string" }, - "overallPercent": { - "type": "integer", - "format": "int32", - "minimum": 0 - }, "status": { "$ref": "#/components/schemas/JobStatus" - }, - "step": { - "type": ["string", "null"] - }, - "totalDocuments": { - "type": "integer", - "minimum": 0 - }, - "totalSteps": { - "type": "integer", - "minimum": 0 } } }, - "JobStatus": { - "type": "string", - "enum": ["running", "completed", "completed_with_errors", "cancelled", "failed"] + "ListDownloadsResponse": { + "type": "object", + "required": ["downloads"], + "properties": { + "downloads": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DownloadProgress" + } + } + } + }, + "ListOperationsResponse": { + "type": "object", + "required": ["operations"], + "properties": { + "operations": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JobSummary" + } + } + } + }, + "ListProjectsResponse": { + "type": "object", + "required": ["projects"], + "properties": { + "projects": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ProjectSummary" + } + } + } }, "LlmCatalog": { "type": "object", @@ -2462,89 +1748,500 @@ { "$ref": "#/components/schemas/LlmTarget" } - ] + ] + } + } + }, + "LlmStateStatus": { + "type": "string", + "enum": ["empty", "loading", "ready", "failed"] + }, + "LlmTarget": { + "type": "object", + "required": ["kind", "modelId"], + "properties": { + "kind": { + "$ref": "#/components/schemas/LlmTargetKind" + }, + "modelId": { + "type": "string" + }, + "providerId": { + "type": ["string", "null"] + } + } + }, + "LlmTargetKind": { + "type": "string", + "enum": ["local", "provider"] + }, + "MaskData": { + "type": "object", + "required": ["role", "blob"], + "properties": { + "blob": { + "$ref": "#/components/schemas/BlobRef" + }, + "role": { + "$ref": "#/components/schemas/MaskRole" + } + } + }, + "MaskDataPatch": { + "type": "object", + "properties": { + "blob": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/BlobRef" + } + ] + } + } + }, + "MaskRole": { + "type": "string", + "enum": ["brushInpaint", "segment", "bubble"] + }, + "MetaInfo": { + "type": "object", + "required": ["version", "mlDevice"], + "properties": { + "mlDevice": { + "type": "string" + }, + "version": { + "type": "string" + } + } + }, + "NamedFontPrediction": { + "type": "object", + "required": ["index", "name", "probability", "serif"], + "properties": { + "index": { + "type": "integer", + "minimum": 0 + }, + "language": { + "type": ["string", "null"] + }, + "name": { + "type": "string" + }, + "probability": { + "type": "number", + "format": "float" + }, + "serif": { + "type": "boolean" + } + } + }, + "Node": { + "type": "object", + "required": ["id", "visible", "kind"], + "properties": { + "id": { + "$ref": "#/components/schemas/NodeId" + }, + "kind": { + "$ref": "#/components/schemas/NodeKind" + }, + "transform": { + "$ref": "#/components/schemas/Transform" + }, + "visible": { + "type": "boolean" + } + } + }, + "NodeDataPatch": { + "oneOf": [ + { + "type": "object", + "required": ["text"], + "properties": { + "text": { + "$ref": "#/components/schemas/TextDataPatch" + } + } + }, + { + "type": "object", + "required": ["image"], + "properties": { + "image": { + "$ref": "#/components/schemas/ImageDataPatch" + } + } + }, + { + "type": "object", + "required": ["mask"], + "properties": { + "mask": { + "$ref": "#/components/schemas/MaskDataPatch" + } + } + } + ] + }, + "NodeId": { + "type": "string", + "format": "uuid" + }, + "NodeKind": { + "oneOf": [ + { + "type": "object", + "required": ["image"], + "properties": { + "image": { + "$ref": "#/components/schemas/ImageData" + } + } + }, + { + "type": "object", + "required": ["text"], + "properties": { + "text": { + "$ref": "#/components/schemas/TextData" + } + } + }, + { + "type": "object", + "required": ["mask"], + "properties": { + "mask": { + "$ref": "#/components/schemas/MaskData" + } + } + } + ] + }, + "NodePatch": { + "type": "object", + "properties": { + "data": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/NodeDataPatch" + } + ] + }, + "transform": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/Transform" + } + ] + }, + "visible": { + "type": ["boolean", "null"] + } + } + }, + "Op": { + "oneOf": [ + { + "type": "object", + "required": ["updateProjectMeta"], + "properties": { + "updateProjectMeta": { + "type": "object", + "required": ["patch"], + "properties": { + "patch": { + "$ref": "#/components/schemas/ProjectMetaPatch" + }, + "prev": { + "$ref": "#/components/schemas/ProjectMetaPatch" + } + } + } + } + }, + { + "type": "object", + "required": ["addPage"], + "properties": { + "addPage": { + "type": "object", + "required": ["page", "at"], + "properties": { + "at": { + "type": "integer", + "minimum": 0 + }, + "page": { + "$ref": "#/components/schemas/Page" + } + } + } + } + }, + { + "type": "object", + "required": ["removePage"], + "properties": { + "removePage": { + "type": "object", + "required": ["id", "prev_page", "prev_index"], + "properties": { + "id": { + "$ref": "#/components/schemas/PageId" + }, + "prev_index": { + "type": "integer", + "minimum": 0 + }, + "prev_page": { + "$ref": "#/components/schemas/Page" + } + } + } + } + }, + { + "type": "object", + "required": ["updatePage"], + "properties": { + "updatePage": { + "type": "object", + "required": ["id", "patch"], + "properties": { + "id": { + "$ref": "#/components/schemas/PageId" + }, + "patch": { + "$ref": "#/components/schemas/PagePatch" + }, + "prev": { + "$ref": "#/components/schemas/PagePatch" + } + } + } + } + }, + { + "type": "object", + "required": ["reorderPages"], + "properties": { + "reorderPages": { + "type": "object", + "required": ["order", "prev_order"], + "properties": { + "order": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PageId" + } + }, + "prev_order": { + "type": "array", + "items": { + "$ref": "#/components/schemas/PageId" + } + } + } + } + } + }, + { + "type": "object", + "required": ["addNode"], + "properties": { + "addNode": { + "type": "object", + "required": ["page", "node", "at"], + "properties": { + "at": { + "type": "integer", + "minimum": 0 + }, + "node": { + "$ref": "#/components/schemas/Node" + }, + "page": { + "$ref": "#/components/schemas/PageId" + } + } + } + } + }, + { + "type": "object", + "required": ["removeNode"], + "properties": { + "removeNode": { + "type": "object", + "required": ["page", "id", "prev_node", "prev_index"], + "properties": { + "id": { + "$ref": "#/components/schemas/NodeId" + }, + "page": { + "$ref": "#/components/schemas/PageId" + }, + "prev_index": { + "type": "integer", + "minimum": 0 + }, + "prev_node": { + "$ref": "#/components/schemas/Node" + } + } + } + } + }, + { + "type": "object", + "required": ["updateNode"], + "properties": { + "updateNode": { + "type": "object", + "required": ["page", "id", "patch"], + "properties": { + "id": { + "$ref": "#/components/schemas/NodeId" + }, + "page": { + "$ref": "#/components/schemas/PageId" + }, + "patch": { + "$ref": "#/components/schemas/NodePatch" + }, + "prev": { + "$ref": "#/components/schemas/NodePatch" + } + } + } + } + }, + { + "type": "object", + "required": ["reorderNodes"], + "properties": { + "reorderNodes": { + "type": "object", + "required": ["page", "order", "prev_order"], + "properties": { + "order": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NodeId" + } + }, + "page": { + "$ref": "#/components/schemas/PageId" + }, + "prev_order": { + "type": "array", + "items": { + "$ref": "#/components/schemas/NodeId" + } + } + } + } + } + }, + { + "type": "object", + "required": ["batch"], + "properties": { + "batch": { + "type": "object", + "required": ["ops", "label"], + "properties": { + "label": { + "type": "string" + }, + "ops": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Op" + } + } + } + } + } } - } - }, - "LlmStateStatus": { - "type": "string", - "enum": ["empty", "loading", "ready", "failed"] + ] }, - "LlmTarget": { + "OpenProjectRequest": { "type": "object", - "required": ["kind", "modelId"], + "required": ["id"], "properties": { - "kind": { - "$ref": "#/components/schemas/LlmTargetKind" - }, - "modelId": { - "type": "string" - }, - "providerId": { - "type": ["string", "null"] + "id": { + "type": "string", + "description": "`.khrproj/` directory basename (no extension). Must exist under the\nmanaged projects directory." } } }, - "LlmTargetKind": { - "type": "string", - "enum": ["local", "provider"] - }, - "MaskRegionRequest": { + "Page": { "type": "object", - "required": ["data"], + "required": ["id", "name", "width", "height", "nodes"], "properties": { - "data": { - "type": "array", - "items": { - "type": "integer", - "format": "int32", - "minimum": 0 - } + "height": { + "type": "integer", + "format": "int32", + "minimum": 0 }, - "region": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/Region" - } - ] - } - } - }, - "MetaInfo": { - "type": "object", - "required": ["version", "mlDevice"], - "properties": { - "mlDevice": { - "type": "string" + "id": { + "$ref": "#/components/schemas/PageId" }, - "version": { + "name": { "type": "string" + }, + "nodes": { + "type": "object", + "description": "Stacking = insertion order. Bottom-first: `source` is typically first,\n`rendered` typically last.", + "additionalProperties": { + "$ref": "#/components/schemas/Node" + }, + "propertyNames": { + "type": "string", + "format": "uuid" + } + }, + "width": { + "type": "integer", + "format": "int32", + "minimum": 0 } } }, - "NamedFontPrediction": { + "PageId": { + "type": "string", + "format": "uuid" + }, + "PagePatch": { "type": "object", - "required": ["index", "name", "probability", "serif"], "properties": { - "index": { - "type": "integer", + "height": { + "type": ["integer", "null"], + "format": "int32", "minimum": 0 }, - "language": { - "type": ["string", "null"] - }, "name": { - "type": "string" - }, - "probability": { - "type": "number", - "format": "float" + "type": ["string", "null"] }, - "serif": { - "type": "boolean" + "width": { + "type": ["integer", "null"], + "format": "int32", + "minimum": 0 } } }, @@ -2552,9 +2249,13 @@ "type": "object", "description": "Engine selection for each pipeline stage.\nValues are engine IDs (e.g. \"pp-doclayout-v3\", \"comic-text-detector\").\nEmpty string means use default.", "properties": { + "bubble_segmenter": { + "type": "string", + "default": "speech-bubble-segmentation" + }, "detector": { "type": "string", - "default": "comic-text-bubble-detector" + "default": "pp-doclayout-v3" }, "font_detector": { "type": "string", @@ -2578,89 +2279,264 @@ }, "translator": { "type": "string", - "default": "llm" + "default": "llm-translate" } } }, - "PipelineJobRequest": { + "PipelineConfigPatch": { "type": "object", "properties": { - "defaultFont": { + "bubbleSegmenter": { + "type": ["string", "null"] + }, + "detector": { "type": ["string", "null"] }, - "documentId": { + "fontDetector": { "type": ["string", "null"] }, - "language": { + "inpainter": { + "type": ["string", "null"] + }, + "ocr": { + "type": ["string", "null"] + }, + "renderer": { + "type": ["string", "null"] + }, + "segmenter": { + "type": ["string", "null"] + }, + "translator": { "type": ["string", "null"] + } + } + }, + "PipelineProgress": { + "type": "object", + "required": [ + "jobId", + "status", + "currentPage", + "totalPages", + "currentStepIndex", + "totalSteps", + "overallPercent" + ], + "properties": { + "currentPage": { + "type": "integer", + "minimum": 0 + }, + "currentStepIndex": { + "type": "integer", + "minimum": 0 + }, + "jobId": { + "type": "string" + }, + "overallPercent": { + "type": "integer", + "format": "int32", + "minimum": 0 }, - "llm": { + "status": { + "$ref": "#/components/schemas/PipelineStatus" + }, + "step": { "oneOf": [ { "type": "null" }, { - "$ref": "#/components/schemas/PipelineLlmRequest" + "$ref": "#/components/schemas/PipelineStep" } ] }, - "shaderEffect": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/TextShaderEffect" + "totalPages": { + "type": "integer", + "minimum": 0 + }, + "totalSteps": { + "type": "integer", + "minimum": 0 + } + } + }, + "PipelineStatus": { + "oneOf": [ + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["running"] } - ] + } }, - "shaderStroke": { - "oneOf": [ - { - "type": "null" + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["completed"] + } + } + }, + { + "type": "object", + "required": ["status"], + "properties": { + "status": { + "type": "string", + "enum": ["cancelled"] + } + } + }, + { + "type": "object", + "required": ["reason", "status"], + "properties": { + "reason": { + "type": "string" }, - { - "$ref": "#/components/schemas/TextStrokeStyle" + "status": { + "type": "string", + "enum": ["failed"] } - ] + } + } + ] + }, + "PipelineStep": { + "type": "string", + "enum": ["detect", "ocr", "inpaint", "llmGenerate", "render"] + }, + "ProjectMeta": { + "type": "object", + "required": ["name", "createdAt", "updatedAt"], + "properties": { + "createdAt": { + "type": "string", + "format": "date-time" }, - "systemPrompt": { - "type": ["string", "null"] + "name": { + "type": "string" + }, + "style": { + "$ref": "#/components/schemas/ProjectStyle" + }, + "updatedAt": { + "type": "string", + "format": "date-time" } } }, - "PipelineLlmRequest": { + "ProjectMetaPatch": { "type": "object", - "required": ["target"], "properties": { - "options": { + "name": { + "type": ["string", "null"] + }, + "style": { "oneOf": [ { "type": "null" }, { - "$ref": "#/components/schemas/LlmGenerationOptions" + "$ref": "#/components/schemas/ProjectStyle" } ] }, - "target": { - "$ref": "#/components/schemas/LlmTarget" + "updatedAt": { + "type": ["string", "null"], + "format": "date-time" + } + } + }, + "ProjectStyle": { + "type": "object", + "properties": { + "defaultFont": { + "type": ["string", "null"] + } + } + }, + "ProjectSummary": { + "type": "object", + "required": ["id", "name", "path"], + "properties": { + "id": { + "type": "string", + "description": "Stable identifier — the `.khrproj` directory basename (without the\nextension). Clients address projects by this." + }, + "name": { + "type": "string" + }, + "path": { + "type": "string", + "description": "Absolute filesystem path. Informational; clients never need to pass\nit back in — they use `id`." + }, + "updatedAtMs": { + "type": "integer", + "format": "int64", + "description": "Last modification time of the project directory on disk (ms since\nUNIX epoch). Used for \"recent projects\" ordering.", + "minimum": 0 + } + } + }, + "ProviderConfig": { + "type": "object", + "required": ["id"], + "properties": { + "api_key": { + "type": ["string", "null"], + "description": "Populated from the keyring on `load()`, never written to config.toml.\nSerializes as `\"[REDACTED]\"` in API responses.\nPopulated from keyring on `load()`. Serializes as `\"[REDACTED]\"`." + }, + "base_url": { + "type": ["string", "null"] + }, + "id": { + "type": "string" + } + } + }, + "ProviderPatch": { + "type": "object", + "required": ["id"], + "properties": { + "apiKey": { + "type": ["string", "null"], + "description": "`\"[REDACTED]\"` → keep existing keyring secret; empty → clear; otherwise save." + }, + "baseUrl": { + "type": ["string", "null"] + }, + "id": { + "type": "string" + } + } + }, + "ProviderSecretRequest": { + "type": "object", + "required": ["secret"], + "properties": { + "secret": { + "type": "string" } } }, - "ProviderConfig": { + "PutMaskResponse": { "type": "object", - "required": ["id"], + "required": ["node", "blob"], "properties": { - "api_key": { - "type": ["string", "null"], - "description": "Populated from the keyring on `load()`, never written to config.toml.\nSerializes as `\"[REDACTED]\"` in API responses.\nPopulated from keyring on `load()`. Serializes as `\"[REDACTED]\"`." - }, - "base_url": { - "type": ["string", "null"] + "blob": { + "$ref": "#/components/schemas/BlobRef" }, - "id": { - "type": "string" + "node": { + "$ref": "#/components/schemas/NodeId" } } }, @@ -2690,43 +2566,125 @@ } } }, - "RenderRequest": { + "Scene": { "type": "object", + "required": ["project", "pages"], "properties": { - "shaderEffect": { - "oneOf": [ - { - "type": "null" - }, - { - "$ref": "#/components/schemas/TextShaderEffect" - } - ] + "pages": { + "type": "object", + "description": "Pages in insertion order; `IndexMap` ordering *is* the page order.", + "additionalProperties": { + "$ref": "#/components/schemas/Page" + }, + "propertyNames": { + "type": "string", + "format": "uuid" + } + }, + "project": { + "$ref": "#/components/schemas/ProjectMeta" + } + } + }, + "SceneSnapshot": { + "type": "object", + "description": "JSON-shaped scene snapshot for the UI (no postcard decoder in JS).", + "required": ["epoch", "scene"], + "properties": { + "epoch": { + "type": "integer", + "format": "int64", + "minimum": 0 + }, + "scene": { + "$ref": "#/components/schemas/Scene" + } + } + }, + "SnapshotEvent": { + "type": "object", + "required": ["jobs", "downloads"], + "properties": { + "downloads": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DownloadProgress" + } + }, + "jobs": { + "type": "array", + "items": { + "$ref": "#/components/schemas/JobSummary" + } + } + } + }, + "StartDownloadRequest": { + "type": "object", + "required": ["modelId"], + "properties": { + "modelId": { + "type": "string", + "description": "Package id, as declared via `declare_hf_model_package!`\n(e.g. `\"model:comic-text-detector:yolo-v5\"`)." + } + } + }, + "StartDownloadResponse": { + "type": "object", + "required": ["operationId"], + "properties": { + "operationId": { + "type": "string", + "description": "Operation id. Reusing the package id keeps ids meaningful for clients\nwatching progress events." + } + } + }, + "StartPipelineRequest": { + "type": "object", + "required": ["steps"], + "properties": { + "defaultFont": { + "type": ["string", "null"] + }, + "pages": { + "type": ["array", "null"], + "items": { + "$ref": "#/components/schemas/PageId" + }, + "description": "`None` → whole project, `Some(pages)` → just those pages." }, - "shaderStroke": { + "region": { "oneOf": [ { "type": "null" }, { - "$ref": "#/components/schemas/TextStrokeStyle" + "$ref": "#/components/schemas/Region", + "description": "Optional bounding-box hint for inpainter engines (repair-brush)." } ] }, - "textBlockId": { + "steps": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Engine ids (`inventory::submit!` ids) to run in order." + }, + "systemPrompt": { + "type": ["string", "null"] + }, + "targetLanguage": { "type": ["string", "null"] } } }, - "ReorderRequest": { + "StartPipelineResponse": { "type": "object", - "required": ["ids"], + "required": ["operationId"], "properties": { - "ids": { - "type": "array", - "items": { - "type": "string" - } + "operationId": { + "type": "string" } } }, @@ -2734,9 +2692,8 @@ "type": "string", "enum": ["left", "center", "right"] }, - "TextBlockDetail": { + "TextData": { "type": "object", - "required": ["id", "x", "y", "width", "height", "confidence"], "properties": { "confidence": { "type": "number", @@ -2759,13 +2716,6 @@ } ] }, - "height": { - "type": "number", - "format": "float" - }, - "id": { - "type": "string" - }, "linePolygons": { "type": ["array", "null"], "items": { @@ -2779,26 +2729,8 @@ } } }, - "renderHeight": { - "type": ["number", "null"], - "format": "float" - }, - "renderWidth": { - "type": ["number", "null"], - "format": "float" - }, - "renderX": { - "type": ["number", "null"], - "format": "float", - "description": "Actual render area position/size (when bubble expansion is used)." - }, - "renderY": { - "type": ["number", "null"], - "format": "float" - }, - "rendered": { - "type": ["string", "null"], - "description": "Blob hash for the rendered text block sprite." + "lockLayoutBox": { + "type": "boolean" }, "renderedDirection": { "oneOf": [ @@ -2824,9 +2756,31 @@ } ] }, - "sourceLanguage": { + "sourceLang": { "type": ["string", "null"] }, + "sprite": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/BlobRef", + "description": "Renderer-produced sprite for this block." + } + ] + }, + "spriteTransform": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/Transform", + "description": "Sprite placement when the renderer expands past the bubble geometry." + } + ] + }, "style": { "oneOf": [ { @@ -2842,69 +2796,97 @@ }, "translation": { "type": ["string", "null"] - }, - "width": { - "type": "number", - "format": "float" - }, - "x": { - "type": "number", - "format": "float" - }, - "y": { - "type": "number", - "format": "float" } } }, - "TextBlockInput": { + "TextDataPatch": { "type": "object", - "required": ["x", "y", "width", "height"], + "description": "For fields where \"set to None\" is meaningful (e.g. clearing a translation),\nthe outer `Option` is \"patch present\", the inner is \"value present\".", "properties": { - "height": { - "type": "number", + "confidence": { + "type": ["number", "null"], "format": "float" }, - "id": { + "detectedFontSizePx": { + "type": ["number", "null"], + "format": "float" + }, + "detector": { "type": ["string", "null"] }, - "style": { + "fontPrediction": { "oneOf": [ { "type": "null" }, { - "$ref": "#/components/schemas/TextStyle" + "$ref": "#/components/schemas/FontPrediction" } ] }, - "text": { - "type": ["string", "null"] - }, - "translation": { - "type": ["string", "null"] + "linePolygons": { + "type": ["array", "null"], + "items": { + "type": "array", + "items": { + "type": "array", + "items": { + "type": "number", + "format": "float" + } + } + } }, - "width": { - "type": "number", - "format": "float" + "lockLayoutBox": { + "type": ["boolean", "null"] }, - "x": { - "type": "number", - "format": "float" + "renderedDirection": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/TextDirection" + } + ] }, - "y": { - "type": "number", - "format": "float" - } - } - }, - "TextBlockPatch": { - "type": "object", - "properties": { - "height": { + "rotationDeg": { "type": ["number", "null"], "format": "float" }, + "sourceDirection": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/TextDirection" + } + ] + }, + "sourceLang": { + "type": ["string", "null"] + }, + "sprite": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/BlobRef" + } + ] + }, + "spriteTransform": { + "oneOf": [ + { + "type": "null" + }, + { + "$ref": "#/components/schemas/Transform" + } + ] + }, "style": { "oneOf": [ { @@ -2920,24 +2902,13 @@ }, "translation": { "type": ["string", "null"] - }, - "width": { - "type": ["number", "null"], - "format": "float" - }, - "x": { - "type": ["number", "null"], - "format": "float" - }, - "y": { - "type": ["number", "null"], - "format": "float" } } }, "TextDirection": { "type": "string", - "enum": ["Horizontal", "Vertical"] + "description": "Reading axis of a text block.", + "enum": ["horizontal", "vertical"] }, "TextShaderEffect": { "type": "object", @@ -3038,29 +3009,29 @@ } } }, - "TransferStatus": { - "type": "string", - "enum": ["started", "downloading", "completed", "failed"] - }, - "TranslateRequest": { + "Transform": { "type": "object", + "required": ["x", "y", "width", "height"], "properties": { - "language": { - "type": ["string", "null"] + "height": { + "type": "number", + "format": "float" }, - "systemPrompt": { - "type": ["string", "null"] + "rotationDeg": { + "type": "number", + "format": "float" }, - "textBlockId": { - "type": ["string", "null"] - } - } - }, - "UpdateDocumentStyleRequest": { - "type": "object", - "properties": { - "defaultFont": { - "type": ["string", "null"] + "width": { + "type": "number", + "format": "float" + }, + "x": { + "type": "number", + "format": "float" + }, + "y": { + "type": "number", + "format": "float" } } } diff --git a/ui/orval.config.ts b/ui/orval.config.ts index 08e9bf64faf9877c14809210034ce69f3010160f..556abc4fa2c4b06dc7e8fd28cc084a2bb734642e 100644 --- a/ui/orval.config.ts +++ b/ui/orval.config.ts @@ -9,6 +9,10 @@ export default defineConfig({ client: 'react-query', mode: 'tags-split', baseUrl: '/api/v1', + mock: { + type: 'msw', + delay: 0, + }, override: { fetch: { includeHttpResponseReturnType: false, @@ -18,7 +22,10 @@ export default defineConfig({ name: 'fetchApi', }, operations: { - importDocuments: { + createPages: { + formData: true, + }, + addImageLayer: { formData: true, }, },