Mayo commited on
Commit
0ceaacf
·
unverified ·
1 Parent(s): 8a23004

refactor(ui): regenerate orval client against the v2 axum router

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. ui/lib/api/blobs/blobs.ts +0 -127
  2. ui/lib/api/default/default.msw.ts +1940 -0
  3. ui/lib/api/default/default.ts +0 -0
  4. ui/lib/api/documents/documents.ts +0 -646
  5. ui/lib/api/downloads/downloads.ts +0 -127
  6. ui/lib/api/exports/exports.ts +0 -250
  7. ui/lib/api/fetch.ts +19 -1
  8. ui/lib/api/jobs/jobs.ts +0 -362
  9. ui/lib/api/llm/llm.ts +0 -337
  10. ui/lib/api/processing/processing.ts +0 -378
  11. ui/lib/api/regions/regions.ts +0 -247
  12. ui/lib/api/schemas/addImageLayerResponse.ts +10 -0
  13. ui/lib/api/schemas/{getConfig200.ts → appConfig.ts} +1 -1
  14. ui/lib/api/schemas/appEvent.ts +44 -0
  15. ui/lib/api/schemas/blobRef.ts +10 -0
  16. ui/lib/api/schemas/configPatch.ts +26 -0
  17. ui/lib/api/schemas/createPagesFromPathsRequest.ts +10 -0
  18. ui/lib/api/schemas/createPagesResponse.ts +10 -0
  19. ui/lib/api/schemas/{importDocumentsBody.ts → createProjectRequest.ts} +2 -2
  20. ui/lib/api/schemas/{updateDocumentStyleRequest.ts → dataConfigPatch.ts} +2 -2
  21. ui/lib/api/schemas/documentDetail.ts +0 -40
  22. ui/lib/api/schemas/{downloadState.ts → downloadProgress.ts} +3 -5
  23. ui/lib/api/schemas/downloadStatus.ts +20 -0
  24. ui/lib/api/schemas/{getEngineCatalog200.ts → engineCatalog.ts} +2 -1
  25. ui/lib/api/schemas/{apiError.ts → errorEvent.ts} +2 -3
  26. ui/lib/api/schemas/exportBatchRequest.ts +0 -10
  27. ui/lib/api/schemas/exportDocumentParams.ts +0 -10
  28. ui/lib/api/schemas/{exportLayer.ts → exportFormat.ts} +4 -2
  29. ui/lib/api/schemas/exportProjectRequest.ts +16 -0
  30. ui/lib/api/schemas/fontPrediction.ts +8 -8
  31. ui/lib/api/schemas/getLlmCatalogParams.ts +0 -12
  32. ui/lib/api/schemas/googleFontCatalog.ts +10 -0
  33. ui/lib/api/schemas/googleFontCatalogResponse.ts +0 -11
  34. ui/lib/api/schemas/{googleFontCatalogEntry.ts → googleFontEntry.ts} +3 -2
  35. ui/lib/api/schemas/googleFontVariant.ts +12 -0
  36. ui/lib/api/schemas/{getDocumentThumbnailParams.ts → historyResult.ts} +3 -2
  37. ui/lib/api/schemas/httpConfigPatch.ts +23 -0
  38. ui/lib/api/schemas/imageData.ts +21 -0
  39. ui/lib/api/schemas/{textBlockInput.ts → imageDataPatch.ts} +15 -11
  40. ui/lib/api/schemas/{transferStatus.ts → imageRole.ts} +6 -6
  41. ui/lib/api/schemas/importDocumentsParams.ts +0 -10
  42. ui/lib/api/schemas/importProjectParams.ts +16 -0
  43. ui/lib/api/schemas/index.ts +63 -35
  44. ui/lib/api/schemas/inpaintRegionRequest.ts +0 -10
  45. ui/lib/api/schemas/jobFinishedEvent.ts +13 -0
  46. ui/lib/api/schemas/jobSummary.ts +14 -0
  47. ui/lib/api/schemas/listDownloadsResponse.ts +10 -0
  48. ui/lib/api/schemas/{brushRegionRequest.ts → listOperationsResponse.ts} +3 -4
  49. ui/lib/api/schemas/listProjectsResponse.ts +10 -0
  50. ui/lib/api/schemas/maskData.ts +12 -0
ui/lib/api/blobs/blobs.ts DELETED
@@ -1,127 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- QueryClient,
12
- QueryFunction,
13
- QueryKey,
14
- UndefinedInitialDataOptions,
15
- UseQueryOptions,
16
- UseQueryResult,
17
- } from '@tanstack/react-query'
18
-
19
- import { fetchApi } from '.././fetch'
20
- import type { ApiError } from '../schemas'
21
-
22
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
23
-
24
- export const getGetBlobUrl = (hash: string) => {
25
- return `/api/v1/blobs/${hash}`
26
- }
27
-
28
- export const getBlob = async (hash: string, options?: RequestInit): Promise<Blob> => {
29
- return fetchApi<Blob>(getGetBlobUrl(hash), {
30
- ...options,
31
- method: 'GET',
32
- })
33
- }
34
-
35
- export const getGetBlobQueryKey = (hash: string) => {
36
- return [`/api/v1/blobs/${hash}`] as const
37
- }
38
-
39
- export const getGetBlobQueryOptions = <
40
- TData = Awaited<ReturnType<typeof getBlob>>,
41
- TError = ApiError,
42
- >(
43
- hash: string,
44
- options?: {
45
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>>
46
- request?: SecondParameter<typeof fetchApi>
47
- },
48
- ) => {
49
- const { query: queryOptions, request: requestOptions } = options ?? {}
50
-
51
- const queryKey = queryOptions?.queryKey ?? getGetBlobQueryKey(hash)
52
-
53
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getBlob>>> = ({ signal }) =>
54
- getBlob(hash, { signal, ...requestOptions })
55
-
56
- return {
57
- queryKey,
58
- queryFn,
59
- enabled: !!hash,
60
- gcTime: 300000,
61
- retry: 1,
62
- ...queryOptions,
63
- } as UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData> & {
64
- queryKey: DataTag<QueryKey, TData, TError>
65
- }
66
- }
67
-
68
- export type GetBlobQueryResult = NonNullable<Awaited<ReturnType<typeof getBlob>>>
69
- export type GetBlobQueryError = ApiError
70
-
71
- export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = ApiError>(
72
- hash: string,
73
- options: {
74
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> &
75
- Pick<
76
- DefinedInitialDataOptions<
77
- Awaited<ReturnType<typeof getBlob>>,
78
- TError,
79
- Awaited<ReturnType<typeof getBlob>>
80
- >,
81
- 'initialData'
82
- >
83
- request?: SecondParameter<typeof fetchApi>
84
- },
85
- queryClient?: QueryClient,
86
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
87
- export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = ApiError>(
88
- hash: string,
89
- options?: {
90
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>> &
91
- Pick<
92
- UndefinedInitialDataOptions<
93
- Awaited<ReturnType<typeof getBlob>>,
94
- TError,
95
- Awaited<ReturnType<typeof getBlob>>
96
- >,
97
- 'initialData'
98
- >
99
- request?: SecondParameter<typeof fetchApi>
100
- },
101
- queryClient?: QueryClient,
102
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
103
- export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = ApiError>(
104
- hash: string,
105
- options?: {
106
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>>
107
- request?: SecondParameter<typeof fetchApi>
108
- },
109
- queryClient?: QueryClient,
110
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
111
-
112
- export function useGetBlob<TData = Awaited<ReturnType<typeof getBlob>>, TError = ApiError>(
113
- hash: string,
114
- options?: {
115
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getBlob>>, TError, TData>>
116
- request?: SecondParameter<typeof fetchApi>
117
- },
118
- queryClient?: QueryClient,
119
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
120
- const queryOptions = getGetBlobQueryOptions(hash, options)
121
-
122
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
123
- queryKey: DataTag<QueryKey, TData, TError>
124
- }
125
-
126
- return { ...query, queryKey: queryOptions.queryKey }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/default/default.msw.ts ADDED
@@ -0,0 +1,1940 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import { faker } from '@faker-js/faker'
7
+ import { HttpResponse, delay, http } from 'msw'
8
+ import type { RequestHandlerOptions } from 'msw'
9
+
10
+ import {
11
+ FontSource,
12
+ ImageRole,
13
+ JobStatus,
14
+ LlmProviderCatalogStatus,
15
+ LlmStateStatus,
16
+ LlmTargetKind,
17
+ MaskRole,
18
+ PipelineStep,
19
+ TextAlign,
20
+ TextDirection,
21
+ } from '../schemas'
22
+ import type {
23
+ AddImageLayerResponse,
24
+ AppConfig,
25
+ AppEvent,
26
+ CreatePagesResponse,
27
+ DataConfig,
28
+ EngineCatalog,
29
+ FontFaceInfo,
30
+ FontPrediction,
31
+ GoogleFontCatalog,
32
+ HistoryResult,
33
+ HttpConfig,
34
+ ListDownloadsResponse,
35
+ ListOperationsResponse,
36
+ ListProjectsResponse,
37
+ LlmCatalog,
38
+ LlmState,
39
+ LlmTarget,
40
+ MetaInfo,
41
+ PipelineConfig,
42
+ ProjectSummary,
43
+ PutMaskResponse,
44
+ SceneSnapshot,
45
+ StartDownloadResponse,
46
+ StartPipelineResponse,
47
+ TextShaderEffect,
48
+ TextStrokeStyle,
49
+ TextStyle,
50
+ Transform,
51
+ } from '../schemas'
52
+
53
+ export const getGetBlobResponseMock = (): ArrayBuffer =>
54
+ new ArrayBuffer(faker.number.int({ min: 1, max: 64 }))
55
+
56
+ export const getGetConfigResponseDataConfigMock = (
57
+ overrideResponse: Partial<DataConfig> = {},
58
+ ): DataConfig => ({
59
+ ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) },
60
+ ...overrideResponse,
61
+ })
62
+
63
+ export const getGetConfigResponseHttpConfigMock = (
64
+ overrideResponse: Partial<HttpConfig> = {},
65
+ ): HttpConfig => ({
66
+ ...{
67
+ connect_timeout: faker.number.int({ min: 0 }),
68
+ max_retries: faker.number.int({ min: 0 }),
69
+ read_timeout: faker.number.int({ min: 0 }),
70
+ },
71
+ ...overrideResponse,
72
+ })
73
+
74
+ export const getGetConfigResponsePipelineConfigMock = (
75
+ overrideResponse: Partial<PipelineConfig> = {},
76
+ ): PipelineConfig => ({
77
+ ...{
78
+ bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }),
79
+ detector: faker.string.alpha({ length: { min: 10, max: 20 } }),
80
+ font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }),
81
+ inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }),
82
+ ocr: faker.string.alpha({ length: { min: 10, max: 20 } }),
83
+ renderer: faker.string.alpha({ length: { min: 10, max: 20 } }),
84
+ segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }),
85
+ translator: faker.string.alpha({ length: { min: 10, max: 20 } }),
86
+ },
87
+ ...overrideResponse,
88
+ })
89
+
90
+ export const getGetConfigResponseMock = (
91
+ overrideResponse: Partial<Extract<AppConfig, object>> = {},
92
+ ): AppConfig => ({
93
+ data: faker.helpers.arrayElement([{ ...getGetConfigResponseDataConfigMock() }]),
94
+ http: faker.helpers.arrayElement([{ ...getGetConfigResponseHttpConfigMock() }]),
95
+ pipeline: faker.helpers.arrayElement([{ ...getGetConfigResponsePipelineConfigMock() }]),
96
+ providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
97
+ () => ({
98
+ api_key: faker.helpers.arrayElement([
99
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
100
+ undefined,
101
+ ]),
102
+ base_url: faker.helpers.arrayElement([
103
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
104
+ undefined,
105
+ ]),
106
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
107
+ }),
108
+ ),
109
+ ...overrideResponse,
110
+ })
111
+
112
+ export const getPatchConfigResponseDataConfigMock = (
113
+ overrideResponse: Partial<DataConfig> = {},
114
+ ): DataConfig => ({
115
+ ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) },
116
+ ...overrideResponse,
117
+ })
118
+
119
+ export const getPatchConfigResponseHttpConfigMock = (
120
+ overrideResponse: Partial<HttpConfig> = {},
121
+ ): HttpConfig => ({
122
+ ...{
123
+ connect_timeout: faker.number.int({ min: 0 }),
124
+ max_retries: faker.number.int({ min: 0 }),
125
+ read_timeout: faker.number.int({ min: 0 }),
126
+ },
127
+ ...overrideResponse,
128
+ })
129
+
130
+ export const getPatchConfigResponsePipelineConfigMock = (
131
+ overrideResponse: Partial<PipelineConfig> = {},
132
+ ): PipelineConfig => ({
133
+ ...{
134
+ bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }),
135
+ detector: faker.string.alpha({ length: { min: 10, max: 20 } }),
136
+ font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }),
137
+ inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }),
138
+ ocr: faker.string.alpha({ length: { min: 10, max: 20 } }),
139
+ renderer: faker.string.alpha({ length: { min: 10, max: 20 } }),
140
+ segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }),
141
+ translator: faker.string.alpha({ length: { min: 10, max: 20 } }),
142
+ },
143
+ ...overrideResponse,
144
+ })
145
+
146
+ export const getPatchConfigResponseMock = (
147
+ overrideResponse: Partial<Extract<AppConfig, object>> = {},
148
+ ): AppConfig => ({
149
+ data: faker.helpers.arrayElement([{ ...getPatchConfigResponseDataConfigMock() }]),
150
+ http: faker.helpers.arrayElement([{ ...getPatchConfigResponseHttpConfigMock() }]),
151
+ pipeline: faker.helpers.arrayElement([{ ...getPatchConfigResponsePipelineConfigMock() }]),
152
+ providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
153
+ () => ({
154
+ api_key: faker.helpers.arrayElement([
155
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
156
+ undefined,
157
+ ]),
158
+ base_url: faker.helpers.arrayElement([
159
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
160
+ undefined,
161
+ ]),
162
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
163
+ }),
164
+ ),
165
+ ...overrideResponse,
166
+ })
167
+
168
+ export const getListDownloadsResponseMock = (
169
+ overrideResponse: Partial<Extract<ListDownloadsResponse, object>> = {},
170
+ ): ListDownloadsResponse => ({
171
+ downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
172
+ () => ({
173
+ downloaded: faker.number.int({ min: 0 }),
174
+ filename: faker.string.alpha({ length: { min: 10, max: 20 } }),
175
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
176
+ status: faker.helpers.arrayElement([
177
+ { status: faker.helpers.arrayElement(['started'] as const) },
178
+ { status: faker.helpers.arrayElement(['downloading'] as const) },
179
+ { status: faker.helpers.arrayElement(['completed'] as const) },
180
+ {
181
+ reason: faker.string.alpha({ length: { min: 10, max: 20 } }),
182
+ status: faker.helpers.arrayElement(['failed'] as const),
183
+ },
184
+ ]),
185
+ total: faker.helpers.arrayElement([
186
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
187
+ undefined,
188
+ ]),
189
+ }),
190
+ ),
191
+ ...overrideResponse,
192
+ })
193
+
194
+ export const getStartDownloadResponseMock = (
195
+ overrideResponse: Partial<Extract<StartDownloadResponse, object>> = {},
196
+ ): StartDownloadResponse => ({
197
+ operationId: faker.string.alpha({ length: { min: 10, max: 20 } }),
198
+ ...overrideResponse,
199
+ })
200
+
201
+ export const getGetEngineCatalogResponseMock = (
202
+ overrideResponse: Partial<Extract<EngineCatalog, object>> = {},
203
+ ): EngineCatalog => ({
204
+ bubbleSegmenters: Array.from(
205
+ { length: faker.number.int({ min: 1, max: 10 }) },
206
+ (_, i) => i + 1,
207
+ ).map(() => ({
208
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
209
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
210
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
211
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
212
+ ),
213
+ })),
214
+ detectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
215
+ () => ({
216
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
217
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
218
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
219
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
220
+ ),
221
+ }),
222
+ ),
223
+ fontDetectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
224
+ () => ({
225
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
226
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
227
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
228
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
229
+ ),
230
+ }),
231
+ ),
232
+ inpainters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
233
+ () => ({
234
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
235
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
236
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
237
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
238
+ ),
239
+ }),
240
+ ),
241
+ ocr: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
242
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
243
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
244
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
245
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
246
+ ),
247
+ })),
248
+ renderers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
249
+ () => ({
250
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
251
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
252
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
253
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
254
+ ),
255
+ }),
256
+ ),
257
+ segmenters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
258
+ () => ({
259
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
260
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
261
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
262
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
263
+ ),
264
+ }),
265
+ ),
266
+ translators: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
267
+ () => ({
268
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
269
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
270
+ produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
271
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
272
+ ),
273
+ }),
274
+ ),
275
+ ...overrideResponse,
276
+ })
277
+
278
+ export const getEventsResponseLlmTargetMock = (
279
+ overrideResponse: Partial<LlmTarget> = {},
280
+ ): LlmTarget => ({
281
+ ...{
282
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
283
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
284
+ providerId: faker.helpers.arrayElement([
285
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
286
+ undefined,
287
+ ]),
288
+ },
289
+ ...overrideResponse,
290
+ })
291
+
292
+ export const getEventsResponseMock = (): AppEvent =>
293
+ faker.helpers.arrayElement([
294
+ {
295
+ event: faker.helpers.arrayElement(['jobStarted'] as const),
296
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
297
+ kind: faker.string.alpha({ length: { min: 10, max: 20 } }),
298
+ },
299
+ {
300
+ ...{
301
+ currentPage: faker.number.int({ min: 0 }),
302
+ currentStepIndex: faker.number.int({ min: 0 }),
303
+ jobId: faker.string.alpha({ length: { min: 10, max: 20 } }),
304
+ overallPercent: faker.number.int({ min: 0 }),
305
+ status: faker.helpers.arrayElement([
306
+ { status: faker.helpers.arrayElement(['running'] as const) },
307
+ { status: faker.helpers.arrayElement(['completed'] as const) },
308
+ { status: faker.helpers.arrayElement(['cancelled'] as const) },
309
+ {
310
+ reason: faker.string.alpha({ length: { min: 10, max: 20 } }),
311
+ status: faker.helpers.arrayElement(['failed'] as const),
312
+ },
313
+ ]),
314
+ step: faker.helpers.arrayElement([
315
+ faker.helpers.arrayElement([
316
+ null,
317
+ faker.helpers.arrayElement(Object.values(PipelineStep)),
318
+ ]),
319
+ undefined,
320
+ ]),
321
+ totalPages: faker.number.int({ min: 0 }),
322
+ totalSteps: faker.number.int({ min: 0 }),
323
+ },
324
+ ...{ event: faker.helpers.arrayElement(['jobProgress'] as const) },
325
+ },
326
+ {
327
+ ...{
328
+ error: faker.helpers.arrayElement([
329
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
330
+ undefined,
331
+ ]),
332
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
333
+ status: faker.helpers.arrayElement(Object.values(JobStatus)),
334
+ },
335
+ ...{ event: faker.helpers.arrayElement(['jobFinished'] as const) },
336
+ },
337
+ {
338
+ ...{
339
+ downloaded: faker.number.int({ min: 0 }),
340
+ filename: faker.string.alpha({ length: { min: 10, max: 20 } }),
341
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
342
+ status: faker.helpers.arrayElement([
343
+ { status: faker.helpers.arrayElement(['started'] as const) },
344
+ { status: faker.helpers.arrayElement(['downloading'] as const) },
345
+ { status: faker.helpers.arrayElement(['completed'] as const) },
346
+ {
347
+ reason: faker.string.alpha({ length: { min: 10, max: 20 } }),
348
+ status: faker.helpers.arrayElement(['failed'] as const),
349
+ },
350
+ ]),
351
+ total: faker.helpers.arrayElement([
352
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
353
+ undefined,
354
+ ]),
355
+ },
356
+ ...{ event: faker.helpers.arrayElement(['downloadProgress'] as const) },
357
+ },
358
+ {
359
+ event: faker.helpers.arrayElement(['llmLoading'] as const),
360
+ target: {
361
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
362
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
363
+ providerId: faker.helpers.arrayElement([
364
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
365
+ undefined,
366
+ ]),
367
+ },
368
+ },
369
+ {
370
+ event: faker.helpers.arrayElement(['llmLoaded'] as const),
371
+ target: {
372
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
373
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
374
+ providerId: faker.helpers.arrayElement([
375
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
376
+ undefined,
377
+ ]),
378
+ },
379
+ },
380
+ {
381
+ event: faker.helpers.arrayElement(['llmFailed'] as const),
382
+ target: faker.helpers.arrayElement([
383
+ faker.helpers.arrayElement([null, { ...getEventsResponseLlmTargetMock() }]),
384
+ undefined,
385
+ ]),
386
+ },
387
+ { event: faker.helpers.arrayElement(['llmUnloaded'] as const) },
388
+ {
389
+ ...{
390
+ downloads: Array.from(
391
+ { length: faker.number.int({ min: 1, max: 10 }) },
392
+ (_, i) => i + 1,
393
+ ).map(() => ({
394
+ downloaded: faker.number.int({ min: 0 }),
395
+ filename: faker.string.alpha({ length: { min: 10, max: 20 } }),
396
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
397
+ status: faker.helpers.arrayElement([
398
+ { status: faker.helpers.arrayElement(['started'] as const) },
399
+ { status: faker.helpers.arrayElement(['downloading'] as const) },
400
+ { status: faker.helpers.arrayElement(['completed'] as const) },
401
+ {
402
+ reason: faker.string.alpha({ length: { min: 10, max: 20 } }),
403
+ status: faker.helpers.arrayElement(['failed'] as const),
404
+ },
405
+ ]),
406
+ total: faker.helpers.arrayElement([
407
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
408
+ undefined,
409
+ ]),
410
+ })),
411
+ jobs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
412
+ () => ({
413
+ error: faker.helpers.arrayElement([
414
+ faker.helpers.arrayElement([
415
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
416
+ null,
417
+ ]),
418
+ undefined,
419
+ ]),
420
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
421
+ kind: faker.string.alpha({ length: { min: 10, max: 20 } }),
422
+ status: faker.helpers.arrayElement(Object.values(JobStatus)),
423
+ }),
424
+ ),
425
+ },
426
+ ...{ event: faker.helpers.arrayElement(['snapshot'] as const) },
427
+ },
428
+ ])
429
+
430
+ export const getListFontsResponseMock = (): FontFaceInfo[] =>
431
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
432
+ cached: faker.datatype.boolean(),
433
+ category: faker.helpers.arrayElement([
434
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
435
+ undefined,
436
+ ]),
437
+ familyName: faker.string.alpha({ length: { min: 10, max: 20 } }),
438
+ postScriptName: faker.string.alpha({ length: { min: 10, max: 20 } }),
439
+ source: faker.helpers.arrayElement(Object.values(FontSource)),
440
+ }))
441
+
442
+ export const getGetGoogleFontsCatalogResponseMock = (
443
+ overrideResponse: Partial<Extract<GoogleFontCatalog, object>> = {},
444
+ ): GoogleFontCatalog => ({
445
+ fonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({
446
+ category: faker.string.alpha({ length: { min: 10, max: 20 } }),
447
+ family: faker.string.alpha({ length: { min: 10, max: 20 } }),
448
+ subsets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
449
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
450
+ ),
451
+ variants: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
452
+ () => ({
453
+ filename: faker.string.alpha({ length: { min: 10, max: 20 } }),
454
+ style: faker.string.alpha({ length: { min: 10, max: 20 } }),
455
+ weight: faker.number.int({ min: 0 }),
456
+ }),
457
+ ),
458
+ })),
459
+ ...overrideResponse,
460
+ })
461
+
462
+ export const getGetGoogleFontFileResponseMock = (): ArrayBuffer =>
463
+ new ArrayBuffer(faker.number.int({ min: 1, max: 64 }))
464
+
465
+ export const getApplyCommandResponseMock = (
466
+ overrideResponse: Partial<Extract<HistoryResult, object>> = {},
467
+ ): HistoryResult => ({
468
+ epoch: faker.helpers.arrayElement([
469
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
470
+ undefined,
471
+ ]),
472
+ ...overrideResponse,
473
+ })
474
+
475
+ export const getRedoResponseMock = (
476
+ overrideResponse: Partial<Extract<HistoryResult, object>> = {},
477
+ ): HistoryResult => ({
478
+ epoch: faker.helpers.arrayElement([
479
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
480
+ undefined,
481
+ ]),
482
+ ...overrideResponse,
483
+ })
484
+
485
+ export const getUndoResponseMock = (
486
+ overrideResponse: Partial<Extract<HistoryResult, object>> = {},
487
+ ): HistoryResult => ({
488
+ epoch: faker.helpers.arrayElement([
489
+ faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]),
490
+ undefined,
491
+ ]),
492
+ ...overrideResponse,
493
+ })
494
+
495
+ export const getGetCatalogResponseMock = (
496
+ overrideResponse: Partial<Extract<LlmCatalog, object>> = {},
497
+ ): LlmCatalog => ({
498
+ localModels: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
499
+ () => ({
500
+ languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
501
+ () => faker.string.alpha({ length: { min: 10, max: 20 } }),
502
+ ),
503
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
504
+ target: {
505
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
506
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
507
+ providerId: faker.helpers.arrayElement([
508
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
509
+ undefined,
510
+ ]),
511
+ },
512
+ }),
513
+ ),
514
+ providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
515
+ () => ({
516
+ baseUrl: faker.helpers.arrayElement([
517
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
518
+ undefined,
519
+ ]),
520
+ error: faker.helpers.arrayElement([
521
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
522
+ undefined,
523
+ ]),
524
+ hasApiKey: faker.datatype.boolean(),
525
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
526
+ models: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
527
+ () => ({
528
+ languages: Array.from(
529
+ { length: faker.number.int({ min: 1, max: 10 }) },
530
+ (_, i) => i + 1,
531
+ ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })),
532
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
533
+ target: {
534
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
535
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
536
+ providerId: faker.helpers.arrayElement([
537
+ faker.helpers.arrayElement([
538
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
539
+ null,
540
+ ]),
541
+ undefined,
542
+ ]),
543
+ },
544
+ }),
545
+ ),
546
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
547
+ requiresApiKey: faker.datatype.boolean(),
548
+ requiresBaseUrl: faker.datatype.boolean(),
549
+ status: faker.helpers.arrayElement(Object.values(LlmProviderCatalogStatus)),
550
+ }),
551
+ ),
552
+ ...overrideResponse,
553
+ })
554
+
555
+ export const getGetCurrentLlmResponseLlmTargetMock = (
556
+ overrideResponse: Partial<LlmTarget> = {},
557
+ ): LlmTarget => ({
558
+ ...{
559
+ kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)),
560
+ modelId: faker.string.alpha({ length: { min: 10, max: 20 } }),
561
+ providerId: faker.helpers.arrayElement([
562
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
563
+ undefined,
564
+ ]),
565
+ },
566
+ ...overrideResponse,
567
+ })
568
+
569
+ export const getGetCurrentLlmResponseMock = (
570
+ overrideResponse: Partial<Extract<LlmState, object>> = {},
571
+ ): LlmState => ({
572
+ error: faker.helpers.arrayElement([
573
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
574
+ undefined,
575
+ ]),
576
+ status: faker.helpers.arrayElement(Object.values(LlmStateStatus)),
577
+ target: faker.helpers.arrayElement([
578
+ faker.helpers.arrayElement([null, { ...getGetCurrentLlmResponseLlmTargetMock() }]),
579
+ undefined,
580
+ ]),
581
+ ...overrideResponse,
582
+ })
583
+
584
+ export const getGetMetaResponseMock = (
585
+ overrideResponse: Partial<Extract<MetaInfo, object>> = {},
586
+ ): MetaInfo => ({
587
+ mlDevice: faker.string.alpha({ length: { min: 10, max: 20 } }),
588
+ version: faker.string.alpha({ length: { min: 10, max: 20 } }),
589
+ ...overrideResponse,
590
+ })
591
+
592
+ export const getListOperationsResponseMock = (
593
+ overrideResponse: Partial<Extract<ListOperationsResponse, object>> = {},
594
+ ): ListOperationsResponse => ({
595
+ operations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
596
+ () => ({
597
+ error: faker.helpers.arrayElement([
598
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
599
+ undefined,
600
+ ]),
601
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
602
+ kind: faker.string.alpha({ length: { min: 10, max: 20 } }),
603
+ status: faker.helpers.arrayElement(Object.values(JobStatus)),
604
+ }),
605
+ ),
606
+ ...overrideResponse,
607
+ })
608
+
609
+ export const getCreatePagesResponseMock = (
610
+ overrideResponse: Partial<Extract<CreatePagesResponse, object>> = {},
611
+ ): CreatePagesResponse => ({
612
+ pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
613
+ faker.string.uuid(),
614
+ ),
615
+ ...overrideResponse,
616
+ })
617
+
618
+ export const getCreatePagesFromPathsResponseMock = (
619
+ overrideResponse: Partial<Extract<CreatePagesResponse, object>> = {},
620
+ ): CreatePagesResponse => ({
621
+ pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
622
+ faker.string.uuid(),
623
+ ),
624
+ ...overrideResponse,
625
+ })
626
+
627
+ export const getAddImageLayerResponseMock = (
628
+ overrideResponse: Partial<Extract<AddImageLayerResponse, object>> = {},
629
+ ): AddImageLayerResponse => ({ node: faker.string.uuid(), ...overrideResponse })
630
+
631
+ export const getPutMaskResponseMock = (
632
+ overrideResponse: Partial<Extract<PutMaskResponse, object>> = {},
633
+ ): PutMaskResponse => ({
634
+ blob: faker.string.alpha({ length: { min: 10, max: 20 } }),
635
+ node: faker.string.uuid(),
636
+ ...overrideResponse,
637
+ })
638
+
639
+ export const getGetPageThumbnailResponseMock = (): ArrayBuffer =>
640
+ new ArrayBuffer(faker.number.int({ min: 1, max: 64 }))
641
+
642
+ export const getStartPipelineResponseMock = (
643
+ overrideResponse: Partial<Extract<StartPipelineResponse, object>> = {},
644
+ ): StartPipelineResponse => ({
645
+ operationId: faker.string.alpha({ length: { min: 10, max: 20 } }),
646
+ ...overrideResponse,
647
+ })
648
+
649
+ export const getListProjectsResponseMock = (
650
+ overrideResponse: Partial<Extract<ListProjectsResponse, object>> = {},
651
+ ): ListProjectsResponse => ({
652
+ projects: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
653
+ () => ({
654
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
655
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
656
+ path: faker.string.alpha({ length: { min: 10, max: 20 } }),
657
+ updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]),
658
+ }),
659
+ ),
660
+ ...overrideResponse,
661
+ })
662
+
663
+ export const getCreateProjectResponseMock = (
664
+ overrideResponse: Partial<Extract<ProjectSummary, object>> = {},
665
+ ): ProjectSummary => ({
666
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
667
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
668
+ path: faker.string.alpha({ length: { min: 10, max: 20 } }),
669
+ updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]),
670
+ ...overrideResponse,
671
+ })
672
+
673
+ export const getPutCurrentProjectResponseMock = (
674
+ overrideResponse: Partial<Extract<ProjectSummary, object>> = {},
675
+ ): ProjectSummary => ({
676
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
677
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
678
+ path: faker.string.alpha({ length: { min: 10, max: 20 } }),
679
+ updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]),
680
+ ...overrideResponse,
681
+ })
682
+
683
+ export const getExportCurrentProjectResponseMock = (): ArrayBuffer =>
684
+ new ArrayBuffer(faker.number.int({ min: 1, max: 64 }))
685
+
686
+ export const getImportProjectResponseMock = (
687
+ overrideResponse: Partial<Extract<ProjectSummary, object>> = {},
688
+ ): ProjectSummary => ({
689
+ id: faker.string.alpha({ length: { min: 10, max: 20 } }),
690
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
691
+ path: faker.string.alpha({ length: { min: 10, max: 20 } }),
692
+ updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]),
693
+ ...overrideResponse,
694
+ })
695
+
696
+ export const getGetSceneBinResponseMock = (): ArrayBuffer =>
697
+ new ArrayBuffer(faker.number.int({ min: 1, max: 64 }))
698
+
699
+ export const getGetSceneJsonResponseFontPredictionMock = (
700
+ overrideResponse: Partial<FontPrediction> = {},
701
+ ): FontPrediction => ({
702
+ ...{
703
+ angleDeg: faker.number.float({ fractionDigits: 2 }),
704
+ direction: faker.helpers.arrayElement(Object.values(TextDirection)),
705
+ fontSizePx: faker.number.float({ fractionDigits: 2 }),
706
+ lineHeight: faker.number.float({ fractionDigits: 2 }),
707
+ namedFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
708
+ () => ({
709
+ index: faker.number.int({ min: 0 }),
710
+ language: faker.helpers.arrayElement([
711
+ faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]),
712
+ undefined,
713
+ ]),
714
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
715
+ probability: faker.number.float({ fractionDigits: 2 }),
716
+ serif: faker.datatype.boolean(),
717
+ }),
718
+ ),
719
+ strokeColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
720
+ () => faker.number.int({ min: 0 }),
721
+ ),
722
+ strokeWidthPx: faker.number.float({ fractionDigits: 2 }),
723
+ textColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
724
+ () => faker.number.int({ min: 0 }),
725
+ ),
726
+ topFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(
727
+ () => ({
728
+ index: faker.number.int({ min: 0 }),
729
+ score: faker.number.float({ fractionDigits: 2 }),
730
+ }),
731
+ ),
732
+ },
733
+ ...overrideResponse,
734
+ })
735
+
736
+ export const getGetSceneJsonResponseTransformMock = (
737
+ overrideResponse: Partial<Transform> = {},
738
+ ): Transform => ({
739
+ ...{
740
+ height: faker.number.float({ fractionDigits: 2 }),
741
+ rotationDeg: faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), undefined]),
742
+ width: faker.number.float({ fractionDigits: 2 }),
743
+ x: faker.number.float({ fractionDigits: 2 }),
744
+ y: faker.number.float({ fractionDigits: 2 }),
745
+ },
746
+ ...overrideResponse,
747
+ })
748
+
749
+ export const getGetSceneJsonResponseTextShaderEffectMock = (
750
+ overrideResponse: Partial<TextShaderEffect> = {},
751
+ ): TextShaderEffect => ({
752
+ ...{
753
+ bold: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
754
+ italic: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
755
+ },
756
+ ...overrideResponse,
757
+ })
758
+
759
+ export const getGetSceneJsonResponseTextStrokeStyleMock = (
760
+ overrideResponse: Partial<TextStrokeStyle> = {},
761
+ ): TextStrokeStyle => ({
762
+ ...{
763
+ color: faker.helpers.arrayElement([
764
+ Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
765
+ faker.number.int({ min: 0 }),
766
+ ),
767
+ undefined,
768
+ ]),
769
+ enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
770
+ widthPx: faker.helpers.arrayElement([
771
+ faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]),
772
+ undefined,
773
+ ]),
774
+ },
775
+ ...overrideResponse,
776
+ })
777
+
778
+ export const getGetSceneJsonResponseTextStyleMock = (
779
+ overrideResponse: Partial<TextStyle> = {},
780
+ ): TextStyle => ({
781
+ ...{
782
+ color: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() =>
783
+ faker.number.int({ min: 0 }),
784
+ ),
785
+ effect: faker.helpers.arrayElement([
786
+ faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextShaderEffectMock() }]),
787
+ undefined,
788
+ ]),
789
+ fontFamilies: Array.from(
790
+ { length: faker.number.int({ min: 1, max: 10 }) },
791
+ (_, i) => i + 1,
792
+ ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })),
793
+ fontSize: faker.helpers.arrayElement([
794
+ faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]),
795
+ undefined,
796
+ ]),
797
+ stroke: faker.helpers.arrayElement([
798
+ faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextStrokeStyleMock() }]),
799
+ undefined,
800
+ ]),
801
+ textAlign: faker.helpers.arrayElement([
802
+ faker.helpers.arrayElement([null, faker.helpers.arrayElement(Object.values(TextAlign))]),
803
+ undefined,
804
+ ]),
805
+ },
806
+ ...overrideResponse,
807
+ })
808
+
809
+ export const getGetSceneJsonResponseMock = (
810
+ overrideResponse: Partial<Extract<SceneSnapshot, object>> = {},
811
+ ): SceneSnapshot => ({
812
+ epoch: faker.number.int({ min: 0 }),
813
+ scene: {
814
+ pages: {
815
+ [faker.string.alphanumeric(5)]: {
816
+ height: faker.number.int({ min: 0 }),
817
+ id: faker.string.uuid(),
818
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
819
+ nodes: {
820
+ [faker.string.alphanumeric(5)]: {
821
+ id: faker.string.uuid(),
822
+ kind: faker.helpers.arrayElement([
823
+ {
824
+ image: {
825
+ blob: faker.string.alpha({ length: { min: 10, max: 20 } }),
826
+ name: faker.helpers.arrayElement([
827
+ faker.helpers.arrayElement([
828
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
829
+ null,
830
+ ]),
831
+ undefined,
832
+ ]),
833
+ naturalHeight: faker.number.int({ min: 0 }),
834
+ naturalWidth: faker.number.int({ min: 0 }),
835
+ opacity: faker.helpers.arrayElement([
836
+ faker.number.float({ fractionDigits: 2 }),
837
+ undefined,
838
+ ]),
839
+ role: faker.helpers.arrayElement(Object.values(ImageRole)),
840
+ },
841
+ },
842
+ {
843
+ text: {
844
+ confidence: faker.helpers.arrayElement([
845
+ faker.number.float({ fractionDigits: 2 }),
846
+ undefined,
847
+ ]),
848
+ detectedFontSizePx: faker.helpers.arrayElement([
849
+ faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]),
850
+ undefined,
851
+ ]),
852
+ detector: faker.helpers.arrayElement([
853
+ faker.helpers.arrayElement([
854
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
855
+ null,
856
+ ]),
857
+ undefined,
858
+ ]),
859
+ fontPrediction: faker.helpers.arrayElement([
860
+ faker.helpers.arrayElement([
861
+ null,
862
+ { ...getGetSceneJsonResponseFontPredictionMock() },
863
+ ]),
864
+ undefined,
865
+ ]),
866
+ linePolygons: faker.helpers.arrayElement([
867
+ Array.from(
868
+ { length: faker.number.int({ min: 1, max: 10 }) },
869
+ (_, i) => i + 1,
870
+ ).map(() =>
871
+ Array.from(
872
+ { length: faker.number.int({ min: 1, max: 10 }) },
873
+ (_, i) => i + 1,
874
+ ).map(() =>
875
+ Array.from(
876
+ { length: faker.number.int({ min: 1, max: 10 }) },
877
+ (_, i) => i + 1,
878
+ ).map(() => faker.number.float({ fractionDigits: 2 })),
879
+ ),
880
+ ),
881
+ undefined,
882
+ ]),
883
+ lockLayoutBox: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]),
884
+ renderedDirection: faker.helpers.arrayElement([
885
+ faker.helpers.arrayElement([
886
+ null,
887
+ faker.helpers.arrayElement(Object.values(TextDirection)),
888
+ ]),
889
+ undefined,
890
+ ]),
891
+ rotationDeg: faker.helpers.arrayElement([
892
+ faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]),
893
+ undefined,
894
+ ]),
895
+ sourceDirection: faker.helpers.arrayElement([
896
+ faker.helpers.arrayElement([
897
+ null,
898
+ faker.helpers.arrayElement(Object.values(TextDirection)),
899
+ ]),
900
+ undefined,
901
+ ]),
902
+ sourceLang: faker.helpers.arrayElement([
903
+ faker.helpers.arrayElement([
904
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
905
+ null,
906
+ ]),
907
+ undefined,
908
+ ]),
909
+ sprite: faker.helpers.arrayElement([
910
+ faker.helpers.arrayElement([
911
+ null,
912
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
913
+ ]),
914
+ undefined,
915
+ ]),
916
+ spriteTransform: faker.helpers.arrayElement([
917
+ faker.helpers.arrayElement([
918
+ null,
919
+ { ...getGetSceneJsonResponseTransformMock() },
920
+ ]),
921
+ undefined,
922
+ ]),
923
+ style: faker.helpers.arrayElement([
924
+ faker.helpers.arrayElement([
925
+ null,
926
+ { ...getGetSceneJsonResponseTextStyleMock() },
927
+ ]),
928
+ undefined,
929
+ ]),
930
+ text: faker.helpers.arrayElement([
931
+ faker.helpers.arrayElement([
932
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
933
+ null,
934
+ ]),
935
+ undefined,
936
+ ]),
937
+ translation: faker.helpers.arrayElement([
938
+ faker.helpers.arrayElement([
939
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
940
+ null,
941
+ ]),
942
+ undefined,
943
+ ]),
944
+ },
945
+ },
946
+ {
947
+ mask: {
948
+ blob: faker.string.alpha({ length: { min: 10, max: 20 } }),
949
+ role: faker.helpers.arrayElement(Object.values(MaskRole)),
950
+ },
951
+ },
952
+ ]),
953
+ transform: faker.helpers.arrayElement([
954
+ {
955
+ height: faker.number.float({ fractionDigits: 2 }),
956
+ rotationDeg: faker.helpers.arrayElement([
957
+ faker.number.float({ fractionDigits: 2 }),
958
+ undefined,
959
+ ]),
960
+ width: faker.number.float({ fractionDigits: 2 }),
961
+ x: faker.number.float({ fractionDigits: 2 }),
962
+ y: faker.number.float({ fractionDigits: 2 }),
963
+ },
964
+ undefined,
965
+ ]),
966
+ visible: faker.datatype.boolean(),
967
+ },
968
+ },
969
+ width: faker.number.int({ min: 0 }),
970
+ },
971
+ },
972
+ project: {
973
+ createdAt: faker.date.past().toISOString().slice(0, 19) + 'Z',
974
+ name: faker.string.alpha({ length: { min: 10, max: 20 } }),
975
+ style: faker.helpers.arrayElement([
976
+ {
977
+ defaultFont: faker.helpers.arrayElement([
978
+ faker.helpers.arrayElement([
979
+ faker.string.alpha({ length: { min: 10, max: 20 } }),
980
+ null,
981
+ ]),
982
+ undefined,
983
+ ]),
984
+ },
985
+ undefined,
986
+ ]),
987
+ updatedAt: faker.date.past().toISOString().slice(0, 19) + 'Z',
988
+ },
989
+ },
990
+ ...overrideResponse,
991
+ })
992
+
993
+ export const getGetBlobMockHandler = (
994
+ overrideResponse?:
995
+ | ArrayBuffer
996
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer),
997
+ options?: RequestHandlerOptions,
998
+ ) => {
999
+ return http.get(
1000
+ '*/blobs/:hash',
1001
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1002
+ await delay(0)
1003
+
1004
+ const binaryBody =
1005
+ overrideResponse !== undefined
1006
+ ? typeof overrideResponse === 'function'
1007
+ ? await overrideResponse(info)
1008
+ : overrideResponse
1009
+ : getGetBlobResponseMock()
1010
+ return HttpResponse.arrayBuffer(
1011
+ binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0),
1012
+ { status: 200, headers: { 'Content-Type': 'application/octet-stream' } },
1013
+ )
1014
+ },
1015
+ options,
1016
+ )
1017
+ }
1018
+
1019
+ export const getGetConfigMockHandler = (
1020
+ overrideResponse?:
1021
+ | AppConfig
1022
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<AppConfig> | AppConfig),
1023
+ options?: RequestHandlerOptions,
1024
+ ) => {
1025
+ return http.get(
1026
+ '*/config',
1027
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1028
+ await delay(0)
1029
+
1030
+ return HttpResponse.json(
1031
+ overrideResponse !== undefined
1032
+ ? typeof overrideResponse === 'function'
1033
+ ? await overrideResponse(info)
1034
+ : overrideResponse
1035
+ : getGetConfigResponseMock(),
1036
+ { status: 200 },
1037
+ )
1038
+ },
1039
+ options,
1040
+ )
1041
+ }
1042
+
1043
+ export const getPatchConfigMockHandler = (
1044
+ overrideResponse?:
1045
+ | AppConfig
1046
+ | ((info: Parameters<Parameters<typeof http.patch>[1]>[0]) => Promise<AppConfig> | AppConfig),
1047
+ options?: RequestHandlerOptions,
1048
+ ) => {
1049
+ return http.patch(
1050
+ '*/config',
1051
+ async (info: Parameters<Parameters<typeof http.patch>[1]>[0]) => {
1052
+ await delay(0)
1053
+
1054
+ return HttpResponse.json(
1055
+ overrideResponse !== undefined
1056
+ ? typeof overrideResponse === 'function'
1057
+ ? await overrideResponse(info)
1058
+ : overrideResponse
1059
+ : getPatchConfigResponseMock(),
1060
+ { status: 200 },
1061
+ )
1062
+ },
1063
+ options,
1064
+ )
1065
+ }
1066
+
1067
+ export const getSetProviderSecretMockHandler = (
1068
+ overrideResponse?:
1069
+ | void
1070
+ | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<void> | void),
1071
+ options?: RequestHandlerOptions,
1072
+ ) => {
1073
+ return http.put(
1074
+ '*/config/providers/:id/secret',
1075
+ async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => {
1076
+ await delay(0)
1077
+ if (typeof overrideResponse === 'function') {
1078
+ await overrideResponse(info)
1079
+ }
1080
+
1081
+ return new HttpResponse(null, { status: 204 })
1082
+ },
1083
+ options,
1084
+ )
1085
+ }
1086
+
1087
+ export const getClearProviderSecretMockHandler = (
1088
+ overrideResponse?:
1089
+ | void
1090
+ | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
1091
+ options?: RequestHandlerOptions,
1092
+ ) => {
1093
+ return http.delete(
1094
+ '*/config/providers/:id/secret',
1095
+ async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => {
1096
+ await delay(0)
1097
+ if (typeof overrideResponse === 'function') {
1098
+ await overrideResponse(info)
1099
+ }
1100
+
1101
+ return new HttpResponse(null, { status: 204 })
1102
+ },
1103
+ options,
1104
+ )
1105
+ }
1106
+
1107
+ export const getListDownloadsMockHandler = (
1108
+ overrideResponse?:
1109
+ | ListDownloadsResponse
1110
+ | ((
1111
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1112
+ ) => Promise<ListDownloadsResponse> | ListDownloadsResponse),
1113
+ options?: RequestHandlerOptions,
1114
+ ) => {
1115
+ return http.get(
1116
+ '*/downloads',
1117
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1118
+ await delay(0)
1119
+
1120
+ return HttpResponse.json(
1121
+ overrideResponse !== undefined
1122
+ ? typeof overrideResponse === 'function'
1123
+ ? await overrideResponse(info)
1124
+ : overrideResponse
1125
+ : getListDownloadsResponseMock(),
1126
+ { status: 200 },
1127
+ )
1128
+ },
1129
+ options,
1130
+ )
1131
+ }
1132
+
1133
+ export const getStartDownloadMockHandler = (
1134
+ overrideResponse?:
1135
+ | StartDownloadResponse
1136
+ | ((
1137
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1138
+ ) => Promise<StartDownloadResponse> | StartDownloadResponse),
1139
+ options?: RequestHandlerOptions,
1140
+ ) => {
1141
+ return http.post(
1142
+ '*/downloads',
1143
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1144
+ await delay(0)
1145
+
1146
+ return HttpResponse.json(
1147
+ overrideResponse !== undefined
1148
+ ? typeof overrideResponse === 'function'
1149
+ ? await overrideResponse(info)
1150
+ : overrideResponse
1151
+ : getStartDownloadResponseMock(),
1152
+ { status: 202 },
1153
+ )
1154
+ },
1155
+ options,
1156
+ )
1157
+ }
1158
+
1159
+ export const getGetEngineCatalogMockHandler = (
1160
+ overrideResponse?:
1161
+ | EngineCatalog
1162
+ | ((
1163
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1164
+ ) => Promise<EngineCatalog> | EngineCatalog),
1165
+ options?: RequestHandlerOptions,
1166
+ ) => {
1167
+ return http.get(
1168
+ '*/engines',
1169
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1170
+ await delay(0)
1171
+
1172
+ return HttpResponse.json(
1173
+ overrideResponse !== undefined
1174
+ ? typeof overrideResponse === 'function'
1175
+ ? await overrideResponse(info)
1176
+ : overrideResponse
1177
+ : getGetEngineCatalogResponseMock(),
1178
+ { status: 200 },
1179
+ )
1180
+ },
1181
+ options,
1182
+ )
1183
+ }
1184
+
1185
+ export const getEventsMockHandler = (
1186
+ overrideResponse?:
1187
+ | AppEvent
1188
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<AppEvent> | AppEvent),
1189
+ options?: RequestHandlerOptions,
1190
+ ) => {
1191
+ return http.get(
1192
+ '*/events',
1193
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1194
+ await delay(0)
1195
+
1196
+ return HttpResponse.json(
1197
+ overrideResponse !== undefined
1198
+ ? typeof overrideResponse === 'function'
1199
+ ? await overrideResponse(info)
1200
+ : overrideResponse
1201
+ : getEventsResponseMock(),
1202
+ { status: 200 },
1203
+ )
1204
+ },
1205
+ options,
1206
+ )
1207
+ }
1208
+
1209
+ export const getListFontsMockHandler = (
1210
+ overrideResponse?:
1211
+ | FontFaceInfo[]
1212
+ | ((
1213
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1214
+ ) => Promise<FontFaceInfo[]> | FontFaceInfo[]),
1215
+ options?: RequestHandlerOptions,
1216
+ ) => {
1217
+ return http.get(
1218
+ '*/fonts',
1219
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1220
+ await delay(0)
1221
+
1222
+ return HttpResponse.json(
1223
+ overrideResponse !== undefined
1224
+ ? typeof overrideResponse === 'function'
1225
+ ? await overrideResponse(info)
1226
+ : overrideResponse
1227
+ : getListFontsResponseMock(),
1228
+ { status: 200 },
1229
+ )
1230
+ },
1231
+ options,
1232
+ )
1233
+ }
1234
+
1235
+ export const getGetGoogleFontsCatalogMockHandler = (
1236
+ overrideResponse?:
1237
+ | GoogleFontCatalog
1238
+ | ((
1239
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1240
+ ) => Promise<GoogleFontCatalog> | GoogleFontCatalog),
1241
+ options?: RequestHandlerOptions,
1242
+ ) => {
1243
+ return http.get(
1244
+ '*/google-fonts',
1245
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1246
+ await delay(0)
1247
+
1248
+ return HttpResponse.json(
1249
+ overrideResponse !== undefined
1250
+ ? typeof overrideResponse === 'function'
1251
+ ? await overrideResponse(info)
1252
+ : overrideResponse
1253
+ : getGetGoogleFontsCatalogResponseMock(),
1254
+ { status: 200 },
1255
+ )
1256
+ },
1257
+ options,
1258
+ )
1259
+ }
1260
+
1261
+ export const getFetchGoogleFontMockHandler = (
1262
+ overrideResponse?:
1263
+ | void
1264
+ | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<void> | void),
1265
+ options?: RequestHandlerOptions,
1266
+ ) => {
1267
+ return http.post(
1268
+ '*/google-fonts/:family/fetch',
1269
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1270
+ await delay(0)
1271
+ if (typeof overrideResponse === 'function') {
1272
+ await overrideResponse(info)
1273
+ }
1274
+
1275
+ return new HttpResponse(null, { status: 204 })
1276
+ },
1277
+ options,
1278
+ )
1279
+ }
1280
+
1281
+ export const getGetGoogleFontFileMockHandler = (
1282
+ overrideResponse?:
1283
+ | ArrayBuffer
1284
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer),
1285
+ options?: RequestHandlerOptions,
1286
+ ) => {
1287
+ return http.get(
1288
+ '*/google-fonts/:family/:file',
1289
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1290
+ await delay(0)
1291
+
1292
+ const binaryBody =
1293
+ overrideResponse !== undefined
1294
+ ? typeof overrideResponse === 'function'
1295
+ ? await overrideResponse(info)
1296
+ : overrideResponse
1297
+ : getGetGoogleFontFileResponseMock()
1298
+ return HttpResponse.arrayBuffer(
1299
+ binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0),
1300
+ { status: 200, headers: { 'Content-Type': 'font/ttf' } },
1301
+ )
1302
+ },
1303
+ options,
1304
+ )
1305
+ }
1306
+
1307
+ export const getApplyCommandMockHandler = (
1308
+ overrideResponse?:
1309
+ | HistoryResult
1310
+ | ((
1311
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1312
+ ) => Promise<HistoryResult> | HistoryResult),
1313
+ options?: RequestHandlerOptions,
1314
+ ) => {
1315
+ return http.post(
1316
+ '*/history/apply',
1317
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1318
+ await delay(0)
1319
+
1320
+ return HttpResponse.json(
1321
+ overrideResponse !== undefined
1322
+ ? typeof overrideResponse === 'function'
1323
+ ? await overrideResponse(info)
1324
+ : overrideResponse
1325
+ : getApplyCommandResponseMock(),
1326
+ { status: 200 },
1327
+ )
1328
+ },
1329
+ options,
1330
+ )
1331
+ }
1332
+
1333
+ export const getRedoMockHandler = (
1334
+ overrideResponse?:
1335
+ | HistoryResult
1336
+ | ((
1337
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1338
+ ) => Promise<HistoryResult> | HistoryResult),
1339
+ options?: RequestHandlerOptions,
1340
+ ) => {
1341
+ return http.post(
1342
+ '*/history/redo',
1343
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1344
+ await delay(0)
1345
+
1346
+ return HttpResponse.json(
1347
+ overrideResponse !== undefined
1348
+ ? typeof overrideResponse === 'function'
1349
+ ? await overrideResponse(info)
1350
+ : overrideResponse
1351
+ : getRedoResponseMock(),
1352
+ { status: 200 },
1353
+ )
1354
+ },
1355
+ options,
1356
+ )
1357
+ }
1358
+
1359
+ export const getUndoMockHandler = (
1360
+ overrideResponse?:
1361
+ | HistoryResult
1362
+ | ((
1363
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1364
+ ) => Promise<HistoryResult> | HistoryResult),
1365
+ options?: RequestHandlerOptions,
1366
+ ) => {
1367
+ return http.post(
1368
+ '*/history/undo',
1369
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1370
+ await delay(0)
1371
+
1372
+ return HttpResponse.json(
1373
+ overrideResponse !== undefined
1374
+ ? typeof overrideResponse === 'function'
1375
+ ? await overrideResponse(info)
1376
+ : overrideResponse
1377
+ : getUndoResponseMock(),
1378
+ { status: 200 },
1379
+ )
1380
+ },
1381
+ options,
1382
+ )
1383
+ }
1384
+
1385
+ export const getGetCatalogMockHandler = (
1386
+ overrideResponse?:
1387
+ | LlmCatalog
1388
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<LlmCatalog> | LlmCatalog),
1389
+ options?: RequestHandlerOptions,
1390
+ ) => {
1391
+ return http.get(
1392
+ '*/llm/catalog',
1393
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1394
+ await delay(0)
1395
+
1396
+ return HttpResponse.json(
1397
+ overrideResponse !== undefined
1398
+ ? typeof overrideResponse === 'function'
1399
+ ? await overrideResponse(info)
1400
+ : overrideResponse
1401
+ : getGetCatalogResponseMock(),
1402
+ { status: 200 },
1403
+ )
1404
+ },
1405
+ options,
1406
+ )
1407
+ }
1408
+
1409
+ export const getGetCurrentLlmMockHandler = (
1410
+ overrideResponse?:
1411
+ | LlmState
1412
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<LlmState> | LlmState),
1413
+ options?: RequestHandlerOptions,
1414
+ ) => {
1415
+ return http.get(
1416
+ '*/llm/current',
1417
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1418
+ await delay(0)
1419
+
1420
+ return HttpResponse.json(
1421
+ overrideResponse !== undefined
1422
+ ? typeof overrideResponse === 'function'
1423
+ ? await overrideResponse(info)
1424
+ : overrideResponse
1425
+ : getGetCurrentLlmResponseMock(),
1426
+ { status: 200 },
1427
+ )
1428
+ },
1429
+ options,
1430
+ )
1431
+ }
1432
+
1433
+ export const getPutCurrentLlmMockHandler = (
1434
+ overrideResponse?:
1435
+ | void
1436
+ | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<void> | void),
1437
+ options?: RequestHandlerOptions,
1438
+ ) => {
1439
+ return http.put(
1440
+ '*/llm/current',
1441
+ async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => {
1442
+ await delay(0)
1443
+ if (typeof overrideResponse === 'function') {
1444
+ await overrideResponse(info)
1445
+ }
1446
+
1447
+ return new HttpResponse(null, { status: 204 })
1448
+ },
1449
+ options,
1450
+ )
1451
+ }
1452
+
1453
+ export const getDeleteCurrentLlmMockHandler = (
1454
+ overrideResponse?:
1455
+ | void
1456
+ | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
1457
+ options?: RequestHandlerOptions,
1458
+ ) => {
1459
+ return http.delete(
1460
+ '*/llm/current',
1461
+ async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => {
1462
+ await delay(0)
1463
+ if (typeof overrideResponse === 'function') {
1464
+ await overrideResponse(info)
1465
+ }
1466
+
1467
+ return new HttpResponse(null, { status: 204 })
1468
+ },
1469
+ options,
1470
+ )
1471
+ }
1472
+
1473
+ export const getGetMetaMockHandler = (
1474
+ overrideResponse?:
1475
+ | MetaInfo
1476
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<MetaInfo> | MetaInfo),
1477
+ options?: RequestHandlerOptions,
1478
+ ) => {
1479
+ return http.get(
1480
+ '*/meta',
1481
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1482
+ await delay(0)
1483
+
1484
+ return HttpResponse.json(
1485
+ overrideResponse !== undefined
1486
+ ? typeof overrideResponse === 'function'
1487
+ ? await overrideResponse(info)
1488
+ : overrideResponse
1489
+ : getGetMetaResponseMock(),
1490
+ { status: 200 },
1491
+ )
1492
+ },
1493
+ options,
1494
+ )
1495
+ }
1496
+
1497
+ export const getListOperationsMockHandler = (
1498
+ overrideResponse?:
1499
+ | ListOperationsResponse
1500
+ | ((
1501
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1502
+ ) => Promise<ListOperationsResponse> | ListOperationsResponse),
1503
+ options?: RequestHandlerOptions,
1504
+ ) => {
1505
+ return http.get(
1506
+ '*/operations',
1507
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1508
+ await delay(0)
1509
+
1510
+ return HttpResponse.json(
1511
+ overrideResponse !== undefined
1512
+ ? typeof overrideResponse === 'function'
1513
+ ? await overrideResponse(info)
1514
+ : overrideResponse
1515
+ : getListOperationsResponseMock(),
1516
+ { status: 200 },
1517
+ )
1518
+ },
1519
+ options,
1520
+ )
1521
+ }
1522
+
1523
+ export const getCancelOperationMockHandler = (
1524
+ overrideResponse?:
1525
+ | void
1526
+ | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
1527
+ options?: RequestHandlerOptions,
1528
+ ) => {
1529
+ return http.delete(
1530
+ '*/operations/:id',
1531
+ async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => {
1532
+ await delay(0)
1533
+ if (typeof overrideResponse === 'function') {
1534
+ await overrideResponse(info)
1535
+ }
1536
+
1537
+ return new HttpResponse(null, { status: 204 })
1538
+ },
1539
+ options,
1540
+ )
1541
+ }
1542
+
1543
+ export const getCreatePagesMockHandler = (
1544
+ overrideResponse?:
1545
+ | CreatePagesResponse
1546
+ | ((
1547
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1548
+ ) => Promise<CreatePagesResponse> | CreatePagesResponse),
1549
+ options?: RequestHandlerOptions,
1550
+ ) => {
1551
+ return http.post(
1552
+ '*/pages',
1553
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1554
+ await delay(0)
1555
+
1556
+ return HttpResponse.json(
1557
+ overrideResponse !== undefined
1558
+ ? typeof overrideResponse === 'function'
1559
+ ? await overrideResponse(info)
1560
+ : overrideResponse
1561
+ : getCreatePagesResponseMock(),
1562
+ { status: 200 },
1563
+ )
1564
+ },
1565
+ options,
1566
+ )
1567
+ }
1568
+
1569
+ export const getCreatePagesFromPathsMockHandler = (
1570
+ overrideResponse?:
1571
+ | CreatePagesResponse
1572
+ | ((
1573
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1574
+ ) => Promise<CreatePagesResponse> | CreatePagesResponse),
1575
+ options?: RequestHandlerOptions,
1576
+ ) => {
1577
+ return http.post(
1578
+ '*/pages/from-paths',
1579
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1580
+ await delay(0)
1581
+
1582
+ return HttpResponse.json(
1583
+ overrideResponse !== undefined
1584
+ ? typeof overrideResponse === 'function'
1585
+ ? await overrideResponse(info)
1586
+ : overrideResponse
1587
+ : getCreatePagesFromPathsResponseMock(),
1588
+ { status: 200 },
1589
+ )
1590
+ },
1591
+ options,
1592
+ )
1593
+ }
1594
+
1595
+ export const getAddImageLayerMockHandler = (
1596
+ overrideResponse?:
1597
+ | AddImageLayerResponse
1598
+ | ((
1599
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1600
+ ) => Promise<AddImageLayerResponse> | AddImageLayerResponse),
1601
+ options?: RequestHandlerOptions,
1602
+ ) => {
1603
+ return http.post(
1604
+ '*/pages/:id/image-layers',
1605
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1606
+ await delay(0)
1607
+
1608
+ return HttpResponse.json(
1609
+ overrideResponse !== undefined
1610
+ ? typeof overrideResponse === 'function'
1611
+ ? await overrideResponse(info)
1612
+ : overrideResponse
1613
+ : getAddImageLayerResponseMock(),
1614
+ { status: 200 },
1615
+ )
1616
+ },
1617
+ options,
1618
+ )
1619
+ }
1620
+
1621
+ export const getPutMaskMockHandler = (
1622
+ overrideResponse?:
1623
+ | PutMaskResponse
1624
+ | ((
1625
+ info: Parameters<Parameters<typeof http.put>[1]>[0],
1626
+ ) => Promise<PutMaskResponse> | PutMaskResponse),
1627
+ options?: RequestHandlerOptions,
1628
+ ) => {
1629
+ return http.put(
1630
+ '*/pages/:id/masks/:role',
1631
+ async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => {
1632
+ await delay(0)
1633
+
1634
+ return HttpResponse.json(
1635
+ overrideResponse !== undefined
1636
+ ? typeof overrideResponse === 'function'
1637
+ ? await overrideResponse(info)
1638
+ : overrideResponse
1639
+ : getPutMaskResponseMock(),
1640
+ { status: 200 },
1641
+ )
1642
+ },
1643
+ options,
1644
+ )
1645
+ }
1646
+
1647
+ export const getGetPageThumbnailMockHandler = (
1648
+ overrideResponse?:
1649
+ | ArrayBuffer
1650
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer),
1651
+ options?: RequestHandlerOptions,
1652
+ ) => {
1653
+ return http.get(
1654
+ '*/pages/:id/thumbnail',
1655
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1656
+ await delay(0)
1657
+
1658
+ const binaryBody =
1659
+ overrideResponse !== undefined
1660
+ ? typeof overrideResponse === 'function'
1661
+ ? await overrideResponse(info)
1662
+ : overrideResponse
1663
+ : getGetPageThumbnailResponseMock()
1664
+ return HttpResponse.arrayBuffer(
1665
+ binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0),
1666
+ { status: 200, headers: { 'Content-Type': 'image/webp' } },
1667
+ )
1668
+ },
1669
+ options,
1670
+ )
1671
+ }
1672
+
1673
+ export const getStartPipelineMockHandler = (
1674
+ overrideResponse?:
1675
+ | StartPipelineResponse
1676
+ | ((
1677
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1678
+ ) => Promise<StartPipelineResponse> | StartPipelineResponse),
1679
+ options?: RequestHandlerOptions,
1680
+ ) => {
1681
+ return http.post(
1682
+ '*/pipelines',
1683
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1684
+ await delay(0)
1685
+
1686
+ return HttpResponse.json(
1687
+ overrideResponse !== undefined
1688
+ ? typeof overrideResponse === 'function'
1689
+ ? await overrideResponse(info)
1690
+ : overrideResponse
1691
+ : getStartPipelineResponseMock(),
1692
+ { status: 200 },
1693
+ )
1694
+ },
1695
+ options,
1696
+ )
1697
+ }
1698
+
1699
+ export const getListProjectsMockHandler = (
1700
+ overrideResponse?:
1701
+ | ListProjectsResponse
1702
+ | ((
1703
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1704
+ ) => Promise<ListProjectsResponse> | ListProjectsResponse),
1705
+ options?: RequestHandlerOptions,
1706
+ ) => {
1707
+ return http.get(
1708
+ '*/projects',
1709
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1710
+ await delay(0)
1711
+
1712
+ return HttpResponse.json(
1713
+ overrideResponse !== undefined
1714
+ ? typeof overrideResponse === 'function'
1715
+ ? await overrideResponse(info)
1716
+ : overrideResponse
1717
+ : getListProjectsResponseMock(),
1718
+ { status: 200 },
1719
+ )
1720
+ },
1721
+ options,
1722
+ )
1723
+ }
1724
+
1725
+ export const getCreateProjectMockHandler = (
1726
+ overrideResponse?:
1727
+ | ProjectSummary
1728
+ | ((
1729
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1730
+ ) => Promise<ProjectSummary> | ProjectSummary),
1731
+ options?: RequestHandlerOptions,
1732
+ ) => {
1733
+ return http.post(
1734
+ '*/projects',
1735
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1736
+ await delay(0)
1737
+
1738
+ return HttpResponse.json(
1739
+ overrideResponse !== undefined
1740
+ ? typeof overrideResponse === 'function'
1741
+ ? await overrideResponse(info)
1742
+ : overrideResponse
1743
+ : getCreateProjectResponseMock(),
1744
+ { status: 200 },
1745
+ )
1746
+ },
1747
+ options,
1748
+ )
1749
+ }
1750
+
1751
+ export const getPutCurrentProjectMockHandler = (
1752
+ overrideResponse?:
1753
+ | ProjectSummary
1754
+ | ((
1755
+ info: Parameters<Parameters<typeof http.put>[1]>[0],
1756
+ ) => Promise<ProjectSummary> | ProjectSummary),
1757
+ options?: RequestHandlerOptions,
1758
+ ) => {
1759
+ return http.put(
1760
+ '*/projects/current',
1761
+ async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => {
1762
+ await delay(0)
1763
+
1764
+ return HttpResponse.json(
1765
+ overrideResponse !== undefined
1766
+ ? typeof overrideResponse === 'function'
1767
+ ? await overrideResponse(info)
1768
+ : overrideResponse
1769
+ : getPutCurrentProjectResponseMock(),
1770
+ { status: 200 },
1771
+ )
1772
+ },
1773
+ options,
1774
+ )
1775
+ }
1776
+
1777
+ export const getDeleteCurrentProjectMockHandler = (
1778
+ overrideResponse?:
1779
+ | void
1780
+ | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void),
1781
+ options?: RequestHandlerOptions,
1782
+ ) => {
1783
+ return http.delete(
1784
+ '*/projects/current',
1785
+ async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => {
1786
+ await delay(0)
1787
+ if (typeof overrideResponse === 'function') {
1788
+ await overrideResponse(info)
1789
+ }
1790
+
1791
+ return new HttpResponse(null, { status: 204 })
1792
+ },
1793
+ options,
1794
+ )
1795
+ }
1796
+
1797
+ export const getExportCurrentProjectMockHandler = (
1798
+ overrideResponse?:
1799
+ | ArrayBuffer
1800
+ | ((
1801
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1802
+ ) => Promise<ArrayBuffer> | ArrayBuffer),
1803
+ options?: RequestHandlerOptions,
1804
+ ) => {
1805
+ return http.post(
1806
+ '*/projects/current/export',
1807
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1808
+ await delay(0)
1809
+
1810
+ const binaryBody =
1811
+ overrideResponse !== undefined
1812
+ ? typeof overrideResponse === 'function'
1813
+ ? await overrideResponse(info)
1814
+ : overrideResponse
1815
+ : getExportCurrentProjectResponseMock()
1816
+ return HttpResponse.arrayBuffer(
1817
+ binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0),
1818
+ { status: 200, headers: { 'Content-Type': 'application/octet-stream' } },
1819
+ )
1820
+ },
1821
+ options,
1822
+ )
1823
+ }
1824
+
1825
+ export const getImportProjectMockHandler = (
1826
+ overrideResponse?:
1827
+ | ProjectSummary
1828
+ | ((
1829
+ info: Parameters<Parameters<typeof http.post>[1]>[0],
1830
+ ) => Promise<ProjectSummary> | ProjectSummary),
1831
+ options?: RequestHandlerOptions,
1832
+ ) => {
1833
+ return http.post(
1834
+ '*/projects/import',
1835
+ async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => {
1836
+ await delay(0)
1837
+
1838
+ return HttpResponse.json(
1839
+ overrideResponse !== undefined
1840
+ ? typeof overrideResponse === 'function'
1841
+ ? await overrideResponse(info)
1842
+ : overrideResponse
1843
+ : getImportProjectResponseMock(),
1844
+ { status: 200 },
1845
+ )
1846
+ },
1847
+ options,
1848
+ )
1849
+ }
1850
+
1851
+ export const getGetSceneBinMockHandler = (
1852
+ overrideResponse?:
1853
+ | ArrayBuffer
1854
+ | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer),
1855
+ options?: RequestHandlerOptions,
1856
+ ) => {
1857
+ return http.get(
1858
+ '*/scene.bin',
1859
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1860
+ await delay(0)
1861
+
1862
+ const binaryBody =
1863
+ overrideResponse !== undefined
1864
+ ? typeof overrideResponse === 'function'
1865
+ ? await overrideResponse(info)
1866
+ : overrideResponse
1867
+ : getGetSceneBinResponseMock()
1868
+ return HttpResponse.arrayBuffer(
1869
+ binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0),
1870
+ { status: 200, headers: { 'Content-Type': 'application/octet-stream' } },
1871
+ )
1872
+ },
1873
+ options,
1874
+ )
1875
+ }
1876
+
1877
+ export const getGetSceneJsonMockHandler = (
1878
+ overrideResponse?:
1879
+ | SceneSnapshot
1880
+ | ((
1881
+ info: Parameters<Parameters<typeof http.get>[1]>[0],
1882
+ ) => Promise<SceneSnapshot> | SceneSnapshot),
1883
+ options?: RequestHandlerOptions,
1884
+ ) => {
1885
+ return http.get(
1886
+ '*/scene.json',
1887
+ async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => {
1888
+ await delay(0)
1889
+
1890
+ return HttpResponse.json(
1891
+ overrideResponse !== undefined
1892
+ ? typeof overrideResponse === 'function'
1893
+ ? await overrideResponse(info)
1894
+ : overrideResponse
1895
+ : getGetSceneJsonResponseMock(),
1896
+ { status: 200 },
1897
+ )
1898
+ },
1899
+ options,
1900
+ )
1901
+ }
1902
+ export const getDefaultMock = () => [
1903
+ getGetBlobMockHandler(),
1904
+ getGetConfigMockHandler(),
1905
+ getPatchConfigMockHandler(),
1906
+ getSetProviderSecretMockHandler(),
1907
+ getClearProviderSecretMockHandler(),
1908
+ getListDownloadsMockHandler(),
1909
+ getStartDownloadMockHandler(),
1910
+ getGetEngineCatalogMockHandler(),
1911
+ getEventsMockHandler(),
1912
+ getListFontsMockHandler(),
1913
+ getGetGoogleFontsCatalogMockHandler(),
1914
+ getFetchGoogleFontMockHandler(),
1915
+ getGetGoogleFontFileMockHandler(),
1916
+ getApplyCommandMockHandler(),
1917
+ getRedoMockHandler(),
1918
+ getUndoMockHandler(),
1919
+ getGetCatalogMockHandler(),
1920
+ getGetCurrentLlmMockHandler(),
1921
+ getPutCurrentLlmMockHandler(),
1922
+ getDeleteCurrentLlmMockHandler(),
1923
+ getGetMetaMockHandler(),
1924
+ getListOperationsMockHandler(),
1925
+ getCancelOperationMockHandler(),
1926
+ getCreatePagesMockHandler(),
1927
+ getCreatePagesFromPathsMockHandler(),
1928
+ getAddImageLayerMockHandler(),
1929
+ getPutMaskMockHandler(),
1930
+ getGetPageThumbnailMockHandler(),
1931
+ getStartPipelineMockHandler(),
1932
+ getListProjectsMockHandler(),
1933
+ getCreateProjectMockHandler(),
1934
+ getPutCurrentProjectMockHandler(),
1935
+ getDeleteCurrentProjectMockHandler(),
1936
+ getExportCurrentProjectMockHandler(),
1937
+ getImportProjectMockHandler(),
1938
+ getGetSceneBinMockHandler(),
1939
+ getGetSceneJsonMockHandler(),
1940
+ ]
ui/lib/api/default/default.ts ADDED
The diff for this file is too large to render. See raw diff
 
ui/lib/api/documents/documents.ts DELETED
@@ -1,646 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation, useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- MutationFunction,
12
- QueryClient,
13
- QueryFunction,
14
- QueryKey,
15
- UndefinedInitialDataOptions,
16
- UseMutationOptions,
17
- UseMutationResult,
18
- UseQueryOptions,
19
- UseQueryResult,
20
- } from '@tanstack/react-query'
21
-
22
- import { fetchApi } from '.././fetch'
23
- import type {
24
- ApiError,
25
- DocumentDetail,
26
- DocumentSummary,
27
- GetDocumentThumbnailParams,
28
- ImportDocumentsBody,
29
- ImportDocumentsParams,
30
- ImportResult,
31
- ReorderRequest,
32
- UpdateDocumentStyleRequest,
33
- } from '../schemas'
34
-
35
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
36
-
37
- export const getListDocumentsUrl = () => {
38
- return `/api/v1/documents`
39
- }
40
-
41
- export const listDocuments = async (options?: RequestInit): Promise<DocumentSummary[]> => {
42
- return fetchApi<DocumentSummary[]>(getListDocumentsUrl(), {
43
- ...options,
44
- method: 'GET',
45
- })
46
- }
47
-
48
- export const getListDocumentsQueryKey = () => {
49
- return [`/api/v1/documents`] as const
50
- }
51
-
52
- export const getListDocumentsQueryOptions = <
53
- TData = Awaited<ReturnType<typeof listDocuments>>,
54
- TError = ApiError,
55
- >(options?: {
56
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDocuments>>, TError, TData>>
57
- request?: SecondParameter<typeof fetchApi>
58
- }) => {
59
- const { query: queryOptions, request: requestOptions } = options ?? {}
60
-
61
- const queryKey = queryOptions?.queryKey ?? getListDocumentsQueryKey()
62
-
63
- const queryFn: QueryFunction<Awaited<ReturnType<typeof listDocuments>>> = ({ signal }) =>
64
- listDocuments({ signal, ...requestOptions })
65
-
66
- return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions<
67
- Awaited<ReturnType<typeof listDocuments>>,
68
- TError,
69
- TData
70
- > & { queryKey: DataTag<QueryKey, TData, TError> }
71
- }
72
-
73
- export type ListDocumentsQueryResult = NonNullable<Awaited<ReturnType<typeof listDocuments>>>
74
- export type ListDocumentsQueryError = ApiError
75
-
76
- export function useListDocuments<
77
- TData = Awaited<ReturnType<typeof listDocuments>>,
78
- TError = ApiError,
79
- >(
80
- options: {
81
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDocuments>>, TError, TData>> &
82
- Pick<
83
- DefinedInitialDataOptions<
84
- Awaited<ReturnType<typeof listDocuments>>,
85
- TError,
86
- Awaited<ReturnType<typeof listDocuments>>
87
- >,
88
- 'initialData'
89
- >
90
- request?: SecondParameter<typeof fetchApi>
91
- },
92
- queryClient?: QueryClient,
93
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
94
- export function useListDocuments<
95
- TData = Awaited<ReturnType<typeof listDocuments>>,
96
- TError = ApiError,
97
- >(
98
- options?: {
99
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDocuments>>, TError, TData>> &
100
- Pick<
101
- UndefinedInitialDataOptions<
102
- Awaited<ReturnType<typeof listDocuments>>,
103
- TError,
104
- Awaited<ReturnType<typeof listDocuments>>
105
- >,
106
- 'initialData'
107
- >
108
- request?: SecondParameter<typeof fetchApi>
109
- },
110
- queryClient?: QueryClient,
111
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
112
- export function useListDocuments<
113
- TData = Awaited<ReturnType<typeof listDocuments>>,
114
- TError = ApiError,
115
- >(
116
- options?: {
117
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDocuments>>, TError, TData>>
118
- request?: SecondParameter<typeof fetchApi>
119
- },
120
- queryClient?: QueryClient,
121
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
122
-
123
- export function useListDocuments<
124
- TData = Awaited<ReturnType<typeof listDocuments>>,
125
- TError = ApiError,
126
- >(
127
- options?: {
128
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDocuments>>, TError, TData>>
129
- request?: SecondParameter<typeof fetchApi>
130
- },
131
- queryClient?: QueryClient,
132
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
133
- const queryOptions = getListDocumentsQueryOptions(options)
134
-
135
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
136
- queryKey: DataTag<QueryKey, TData, TError>
137
- }
138
-
139
- return { ...query, queryKey: queryOptions.queryKey }
140
- }
141
-
142
- export const getImportDocumentsUrl = (params?: ImportDocumentsParams) => {
143
- const normalizedParams = new URLSearchParams()
144
-
145
- Object.entries(params || {}).forEach(([key, value]) => {
146
- if (value !== undefined) {
147
- normalizedParams.append(key, value === null ? 'null' : value.toString())
148
- }
149
- })
150
-
151
- const stringifiedParams = normalizedParams.toString()
152
-
153
- return stringifiedParams.length > 0
154
- ? `/api/v1/documents?${stringifiedParams}`
155
- : `/api/v1/documents`
156
- }
157
-
158
- export const importDocuments = async (
159
- importDocumentsBody: ImportDocumentsBody,
160
- params?: ImportDocumentsParams,
161
- options?: RequestInit,
162
- ): Promise<ImportResult> => {
163
- const formData = new FormData()
164
- importDocumentsBody.files.forEach((value) => formData.append(`files`, value))
165
-
166
- return fetchApi<ImportResult>(getImportDocumentsUrl(params), {
167
- ...options,
168
- method: 'POST',
169
- body: formData,
170
- })
171
- }
172
-
173
- export const getImportDocumentsMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
174
- mutation?: UseMutationOptions<
175
- Awaited<ReturnType<typeof importDocuments>>,
176
- TError,
177
- { data: ImportDocumentsBody; params?: ImportDocumentsParams },
178
- TContext
179
- >
180
- request?: SecondParameter<typeof fetchApi>
181
- }): UseMutationOptions<
182
- Awaited<ReturnType<typeof importDocuments>>,
183
- TError,
184
- { data: ImportDocumentsBody; params?: ImportDocumentsParams },
185
- TContext
186
- > => {
187
- const mutationKey = ['importDocuments']
188
- const { mutation: mutationOptions, request: requestOptions } = options
189
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
190
- ? options
191
- : { ...options, mutation: { ...options.mutation, mutationKey } }
192
- : { mutation: { mutationKey }, request: undefined }
193
-
194
- const mutationFn: MutationFunction<
195
- Awaited<ReturnType<typeof importDocuments>>,
196
- { data: ImportDocumentsBody; params?: ImportDocumentsParams }
197
- > = (props) => {
198
- const { data, params } = props ?? {}
199
-
200
- return importDocuments(data, params, requestOptions)
201
- }
202
-
203
- return { mutationFn, ...mutationOptions }
204
- }
205
-
206
- export type ImportDocumentsMutationResult = NonNullable<Awaited<ReturnType<typeof importDocuments>>>
207
- export type ImportDocumentsMutationBody = ImportDocumentsBody
208
- export type ImportDocumentsMutationError = ApiError
209
-
210
- export const useImportDocuments = <TError = ApiError, TContext = unknown>(
211
- options?: {
212
- mutation?: UseMutationOptions<
213
- Awaited<ReturnType<typeof importDocuments>>,
214
- TError,
215
- { data: ImportDocumentsBody; params?: ImportDocumentsParams },
216
- TContext
217
- >
218
- request?: SecondParameter<typeof fetchApi>
219
- },
220
- queryClient?: QueryClient,
221
- ): UseMutationResult<
222
- Awaited<ReturnType<typeof importDocuments>>,
223
- TError,
224
- { data: ImportDocumentsBody; params?: ImportDocumentsParams },
225
- TContext
226
- > => {
227
- return useMutation(getImportDocumentsMutationOptions(options), queryClient)
228
- }
229
- export const getReorderDocumentsUrl = () => {
230
- return `/api/v1/documents/order`
231
- }
232
-
233
- export const reorderDocuments = async (
234
- reorderRequest: ReorderRequest,
235
- options?: RequestInit,
236
- ): Promise<DocumentSummary[]> => {
237
- return fetchApi<DocumentSummary[]>(getReorderDocumentsUrl(), {
238
- ...options,
239
- method: 'PUT',
240
- headers: { 'Content-Type': 'application/json', ...options?.headers },
241
- body: JSON.stringify(reorderRequest),
242
- })
243
- }
244
-
245
- export const getReorderDocumentsMutationOptions = <
246
- TError = ApiError,
247
- TContext = unknown,
248
- >(options?: {
249
- mutation?: UseMutationOptions<
250
- Awaited<ReturnType<typeof reorderDocuments>>,
251
- TError,
252
- { data: ReorderRequest },
253
- TContext
254
- >
255
- request?: SecondParameter<typeof fetchApi>
256
- }): UseMutationOptions<
257
- Awaited<ReturnType<typeof reorderDocuments>>,
258
- TError,
259
- { data: ReorderRequest },
260
- TContext
261
- > => {
262
- const mutationKey = ['reorderDocuments']
263
- const { mutation: mutationOptions, request: requestOptions } = options
264
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
265
- ? options
266
- : { ...options, mutation: { ...options.mutation, mutationKey } }
267
- : { mutation: { mutationKey }, request: undefined }
268
-
269
- const mutationFn: MutationFunction<
270
- Awaited<ReturnType<typeof reorderDocuments>>,
271
- { data: ReorderRequest }
272
- > = (props) => {
273
- const { data } = props ?? {}
274
-
275
- return reorderDocuments(data, requestOptions)
276
- }
277
-
278
- return { mutationFn, ...mutationOptions }
279
- }
280
-
281
- export type ReorderDocumentsMutationResult = NonNullable<
282
- Awaited<ReturnType<typeof reorderDocuments>>
283
- >
284
- export type ReorderDocumentsMutationBody = ReorderRequest
285
- export type ReorderDocumentsMutationError = ApiError
286
-
287
- export const useReorderDocuments = <TError = ApiError, TContext = unknown>(
288
- options?: {
289
- mutation?: UseMutationOptions<
290
- Awaited<ReturnType<typeof reorderDocuments>>,
291
- TError,
292
- { data: ReorderRequest },
293
- TContext
294
- >
295
- request?: SecondParameter<typeof fetchApi>
296
- },
297
- queryClient?: QueryClient,
298
- ): UseMutationResult<
299
- Awaited<ReturnType<typeof reorderDocuments>>,
300
- TError,
301
- { data: ReorderRequest },
302
- TContext
303
- > => {
304
- return useMutation(getReorderDocumentsMutationOptions(options), queryClient)
305
- }
306
- export const getGetDocumentUrl = (documentId: string) => {
307
- return `/api/v1/documents/${documentId}`
308
- }
309
-
310
- export const getDocument = async (
311
- documentId: string,
312
- options?: RequestInit,
313
- ): Promise<DocumentDetail> => {
314
- return fetchApi<DocumentDetail>(getGetDocumentUrl(documentId), {
315
- ...options,
316
- method: 'GET',
317
- })
318
- }
319
-
320
- export const getGetDocumentQueryKey = (documentId: string) => {
321
- return [`/api/v1/documents/${documentId}`] as const
322
- }
323
-
324
- export const getGetDocumentQueryOptions = <
325
- TData = Awaited<ReturnType<typeof getDocument>>,
326
- TError = ApiError,
327
- >(
328
- documentId: string,
329
- options?: {
330
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData>>
331
- request?: SecondParameter<typeof fetchApi>
332
- },
333
- ) => {
334
- const { query: queryOptions, request: requestOptions } = options ?? {}
335
-
336
- const queryKey = queryOptions?.queryKey ?? getGetDocumentQueryKey(documentId)
337
-
338
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getDocument>>> = ({ signal }) =>
339
- getDocument(documentId, { signal, ...requestOptions })
340
-
341
- return {
342
- queryKey,
343
- queryFn,
344
- enabled: !!documentId,
345
- gcTime: 300000,
346
- retry: 1,
347
- ...queryOptions,
348
- } as UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData> & {
349
- queryKey: DataTag<QueryKey, TData, TError>
350
- }
351
- }
352
-
353
- export type GetDocumentQueryResult = NonNullable<Awaited<ReturnType<typeof getDocument>>>
354
- export type GetDocumentQueryError = ApiError
355
-
356
- export function useGetDocument<TData = Awaited<ReturnType<typeof getDocument>>, TError = ApiError>(
357
- documentId: string,
358
- options: {
359
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData>> &
360
- Pick<
361
- DefinedInitialDataOptions<
362
- Awaited<ReturnType<typeof getDocument>>,
363
- TError,
364
- Awaited<ReturnType<typeof getDocument>>
365
- >,
366
- 'initialData'
367
- >
368
- request?: SecondParameter<typeof fetchApi>
369
- },
370
- queryClient?: QueryClient,
371
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
372
- export function useGetDocument<TData = Awaited<ReturnType<typeof getDocument>>, TError = ApiError>(
373
- documentId: string,
374
- options?: {
375
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData>> &
376
- Pick<
377
- UndefinedInitialDataOptions<
378
- Awaited<ReturnType<typeof getDocument>>,
379
- TError,
380
- Awaited<ReturnType<typeof getDocument>>
381
- >,
382
- 'initialData'
383
- >
384
- request?: SecondParameter<typeof fetchApi>
385
- },
386
- queryClient?: QueryClient,
387
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
388
- export function useGetDocument<TData = Awaited<ReturnType<typeof getDocument>>, TError = ApiError>(
389
- documentId: string,
390
- options?: {
391
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData>>
392
- request?: SecondParameter<typeof fetchApi>
393
- },
394
- queryClient?: QueryClient,
395
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
396
-
397
- export function useGetDocument<TData = Awaited<ReturnType<typeof getDocument>>, TError = ApiError>(
398
- documentId: string,
399
- options?: {
400
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getDocument>>, TError, TData>>
401
- request?: SecondParameter<typeof fetchApi>
402
- },
403
- queryClient?: QueryClient,
404
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
405
- const queryOptions = getGetDocumentQueryOptions(documentId, options)
406
-
407
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
408
- queryKey: DataTag<QueryKey, TData, TError>
409
- }
410
-
411
- return { ...query, queryKey: queryOptions.queryKey }
412
- }
413
-
414
- export const getUpdateDocumentStyleUrl = (documentId: string) => {
415
- return `/api/v1/documents/${documentId}/style`
416
- }
417
-
418
- export const updateDocumentStyle = async (
419
- documentId: string,
420
- updateDocumentStyleRequest: UpdateDocumentStyleRequest,
421
- options?: RequestInit,
422
- ): Promise<UpdateDocumentStyleRequest> => {
423
- return fetchApi<UpdateDocumentStyleRequest>(getUpdateDocumentStyleUrl(documentId), {
424
- ...options,
425
- method: 'PATCH',
426
- headers: { 'Content-Type': 'application/json', ...options?.headers },
427
- body: JSON.stringify(updateDocumentStyleRequest),
428
- })
429
- }
430
-
431
- export const getUpdateDocumentStyleMutationOptions = <
432
- TError = ApiError,
433
- TContext = unknown,
434
- >(options?: {
435
- mutation?: UseMutationOptions<
436
- Awaited<ReturnType<typeof updateDocumentStyle>>,
437
- TError,
438
- { documentId: string; data: UpdateDocumentStyleRequest },
439
- TContext
440
- >
441
- request?: SecondParameter<typeof fetchApi>
442
- }): UseMutationOptions<
443
- Awaited<ReturnType<typeof updateDocumentStyle>>,
444
- TError,
445
- { documentId: string; data: UpdateDocumentStyleRequest },
446
- TContext
447
- > => {
448
- const mutationKey = ['updateDocumentStyle']
449
- const { mutation: mutationOptions, request: requestOptions } = options
450
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
451
- ? options
452
- : { ...options, mutation: { ...options.mutation, mutationKey } }
453
- : { mutation: { mutationKey }, request: undefined }
454
-
455
- const mutationFn: MutationFunction<
456
- Awaited<ReturnType<typeof updateDocumentStyle>>,
457
- { documentId: string; data: UpdateDocumentStyleRequest }
458
- > = (props) => {
459
- const { documentId, data } = props ?? {}
460
-
461
- return updateDocumentStyle(documentId, data, requestOptions)
462
- }
463
-
464
- return { mutationFn, ...mutationOptions }
465
- }
466
-
467
- export type UpdateDocumentStyleMutationResult = NonNullable<
468
- Awaited<ReturnType<typeof updateDocumentStyle>>
469
- >
470
- export type UpdateDocumentStyleMutationBody = UpdateDocumentStyleRequest
471
- export type UpdateDocumentStyleMutationError = ApiError
472
-
473
- export const useUpdateDocumentStyle = <TError = ApiError, TContext = unknown>(
474
- options?: {
475
- mutation?: UseMutationOptions<
476
- Awaited<ReturnType<typeof updateDocumentStyle>>,
477
- TError,
478
- { documentId: string; data: UpdateDocumentStyleRequest },
479
- TContext
480
- >
481
- request?: SecondParameter<typeof fetchApi>
482
- },
483
- queryClient?: QueryClient,
484
- ): UseMutationResult<
485
- Awaited<ReturnType<typeof updateDocumentStyle>>,
486
- TError,
487
- { documentId: string; data: UpdateDocumentStyleRequest },
488
- TContext
489
- > => {
490
- return useMutation(getUpdateDocumentStyleMutationOptions(options), queryClient)
491
- }
492
- export const getGetDocumentThumbnailUrl = (
493
- documentId: string,
494
- params?: GetDocumentThumbnailParams,
495
- ) => {
496
- const normalizedParams = new URLSearchParams()
497
-
498
- Object.entries(params || {}).forEach(([key, value]) => {
499
- if (value !== undefined) {
500
- normalizedParams.append(key, value === null ? 'null' : value.toString())
501
- }
502
- })
503
-
504
- const stringifiedParams = normalizedParams.toString()
505
-
506
- return stringifiedParams.length > 0
507
- ? `/api/v1/documents/${documentId}/thumbnail?${stringifiedParams}`
508
- : `/api/v1/documents/${documentId}/thumbnail`
509
- }
510
-
511
- export const getDocumentThumbnail = async (
512
- documentId: string,
513
- params?: GetDocumentThumbnailParams,
514
- options?: RequestInit,
515
- ): Promise<Blob> => {
516
- return fetchApi<Blob>(getGetDocumentThumbnailUrl(documentId, params), {
517
- ...options,
518
- method: 'GET',
519
- })
520
- }
521
-
522
- export const getGetDocumentThumbnailQueryKey = (
523
- documentId: string,
524
- params?: GetDocumentThumbnailParams,
525
- ) => {
526
- return [`/api/v1/documents/${documentId}/thumbnail`, ...(params ? [params] : [])] as const
527
- }
528
-
529
- export const getGetDocumentThumbnailQueryOptions = <
530
- TData = Awaited<ReturnType<typeof getDocumentThumbnail>>,
531
- TError = ApiError,
532
- >(
533
- documentId: string,
534
- params?: GetDocumentThumbnailParams,
535
- options?: {
536
- query?: Partial<
537
- UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData>
538
- >
539
- request?: SecondParameter<typeof fetchApi>
540
- },
541
- ) => {
542
- const { query: queryOptions, request: requestOptions } = options ?? {}
543
-
544
- const queryKey = queryOptions?.queryKey ?? getGetDocumentThumbnailQueryKey(documentId, params)
545
-
546
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getDocumentThumbnail>>> = ({ signal }) =>
547
- getDocumentThumbnail(documentId, params, { signal, ...requestOptions })
548
-
549
- return {
550
- queryKey,
551
- queryFn,
552
- enabled: !!documentId,
553
- gcTime: 300000,
554
- retry: 1,
555
- ...queryOptions,
556
- } as UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData> & {
557
- queryKey: DataTag<QueryKey, TData, TError>
558
- }
559
- }
560
-
561
- export type GetDocumentThumbnailQueryResult = NonNullable<
562
- Awaited<ReturnType<typeof getDocumentThumbnail>>
563
- >
564
- export type GetDocumentThumbnailQueryError = ApiError
565
-
566
- export function useGetDocumentThumbnail<
567
- TData = Awaited<ReturnType<typeof getDocumentThumbnail>>,
568
- TError = ApiError,
569
- >(
570
- documentId: string,
571
- params: undefined | GetDocumentThumbnailParams,
572
- options: {
573
- query: Partial<
574
- UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData>
575
- > &
576
- Pick<
577
- DefinedInitialDataOptions<
578
- Awaited<ReturnType<typeof getDocumentThumbnail>>,
579
- TError,
580
- Awaited<ReturnType<typeof getDocumentThumbnail>>
581
- >,
582
- 'initialData'
583
- >
584
- request?: SecondParameter<typeof fetchApi>
585
- },
586
- queryClient?: QueryClient,
587
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
588
- export function useGetDocumentThumbnail<
589
- TData = Awaited<ReturnType<typeof getDocumentThumbnail>>,
590
- TError = ApiError,
591
- >(
592
- documentId: string,
593
- params?: GetDocumentThumbnailParams,
594
- options?: {
595
- query?: Partial<
596
- UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData>
597
- > &
598
- Pick<
599
- UndefinedInitialDataOptions<
600
- Awaited<ReturnType<typeof getDocumentThumbnail>>,
601
- TError,
602
- Awaited<ReturnType<typeof getDocumentThumbnail>>
603
- >,
604
- 'initialData'
605
- >
606
- request?: SecondParameter<typeof fetchApi>
607
- },
608
- queryClient?: QueryClient,
609
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
610
- export function useGetDocumentThumbnail<
611
- TData = Awaited<ReturnType<typeof getDocumentThumbnail>>,
612
- TError = ApiError,
613
- >(
614
- documentId: string,
615
- params?: GetDocumentThumbnailParams,
616
- options?: {
617
- query?: Partial<
618
- UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData>
619
- >
620
- request?: SecondParameter<typeof fetchApi>
621
- },
622
- queryClient?: QueryClient,
623
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
624
-
625
- export function useGetDocumentThumbnail<
626
- TData = Awaited<ReturnType<typeof getDocumentThumbnail>>,
627
- TError = ApiError,
628
- >(
629
- documentId: string,
630
- params?: GetDocumentThumbnailParams,
631
- options?: {
632
- query?: Partial<
633
- UseQueryOptions<Awaited<ReturnType<typeof getDocumentThumbnail>>, TError, TData>
634
- >
635
- request?: SecondParameter<typeof fetchApi>
636
- },
637
- queryClient?: QueryClient,
638
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
639
- const queryOptions = getGetDocumentThumbnailQueryOptions(documentId, params, options)
640
-
641
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
642
- queryKey: DataTag<QueryKey, TData, TError>
643
- }
644
-
645
- return { ...query, queryKey: queryOptions.queryKey }
646
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/downloads/downloads.ts DELETED
@@ -1,127 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- QueryClient,
12
- QueryFunction,
13
- QueryKey,
14
- UndefinedInitialDataOptions,
15
- UseQueryOptions,
16
- UseQueryResult,
17
- } from '@tanstack/react-query'
18
-
19
- import { fetchApi } from '.././fetch'
20
- import type { DownloadState } from '../schemas'
21
-
22
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
23
-
24
- export const getListDownloadsUrl = () => {
25
- return `/api/v1/downloads`
26
- }
27
-
28
- export const listDownloads = async (options?: RequestInit): Promise<DownloadState[]> => {
29
- return fetchApi<DownloadState[]>(getListDownloadsUrl(), {
30
- ...options,
31
- method: 'GET',
32
- })
33
- }
34
-
35
- export const getListDownloadsQueryKey = () => {
36
- return [`/api/v1/downloads`] as const
37
- }
38
-
39
- export const getListDownloadsQueryOptions = <
40
- TData = Awaited<ReturnType<typeof listDownloads>>,
41
- TError = unknown,
42
- >(options?: {
43
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>>
44
- request?: SecondParameter<typeof fetchApi>
45
- }) => {
46
- const { query: queryOptions, request: requestOptions } = options ?? {}
47
-
48
- const queryKey = queryOptions?.queryKey ?? getListDownloadsQueryKey()
49
-
50
- const queryFn: QueryFunction<Awaited<ReturnType<typeof listDownloads>>> = ({ signal }) =>
51
- listDownloads({ signal, ...requestOptions })
52
-
53
- return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions<
54
- Awaited<ReturnType<typeof listDownloads>>,
55
- TError,
56
- TData
57
- > & { queryKey: DataTag<QueryKey, TData, TError> }
58
- }
59
-
60
- export type ListDownloadsQueryResult = NonNullable<Awaited<ReturnType<typeof listDownloads>>>
61
- export type ListDownloadsQueryError = unknown
62
-
63
- export function useListDownloads<
64
- TData = Awaited<ReturnType<typeof listDownloads>>,
65
- TError = unknown,
66
- >(
67
- options: {
68
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> &
69
- Pick<
70
- DefinedInitialDataOptions<
71
- Awaited<ReturnType<typeof listDownloads>>,
72
- TError,
73
- Awaited<ReturnType<typeof listDownloads>>
74
- >,
75
- 'initialData'
76
- >
77
- request?: SecondParameter<typeof fetchApi>
78
- },
79
- queryClient?: QueryClient,
80
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
81
- export function useListDownloads<
82
- TData = Awaited<ReturnType<typeof listDownloads>>,
83
- TError = unknown,
84
- >(
85
- options?: {
86
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>> &
87
- Pick<
88
- UndefinedInitialDataOptions<
89
- Awaited<ReturnType<typeof listDownloads>>,
90
- TError,
91
- Awaited<ReturnType<typeof listDownloads>>
92
- >,
93
- 'initialData'
94
- >
95
- request?: SecondParameter<typeof fetchApi>
96
- },
97
- queryClient?: QueryClient,
98
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
99
- export function useListDownloads<
100
- TData = Awaited<ReturnType<typeof listDownloads>>,
101
- TError = unknown,
102
- >(
103
- options?: {
104
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>>
105
- request?: SecondParameter<typeof fetchApi>
106
- },
107
- queryClient?: QueryClient,
108
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
109
-
110
- export function useListDownloads<
111
- TData = Awaited<ReturnType<typeof listDownloads>>,
112
- TError = unknown,
113
- >(
114
- options?: {
115
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listDownloads>>, TError, TData>>
116
- request?: SecondParameter<typeof fetchApi>
117
- },
118
- queryClient?: QueryClient,
119
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
120
- const queryOptions = getListDownloadsQueryOptions(options)
121
-
122
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
123
- queryKey: DataTag<QueryKey, TData, TError>
124
- }
125
-
126
- return { ...query, queryKey: queryOptions.queryKey }
127
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/exports/exports.ts DELETED
@@ -1,250 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation, useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- MutationFunction,
12
- QueryClient,
13
- QueryFunction,
14
- QueryKey,
15
- UndefinedInitialDataOptions,
16
- UseMutationOptions,
17
- UseMutationResult,
18
- UseQueryOptions,
19
- UseQueryResult,
20
- } from '@tanstack/react-query'
21
-
22
- import { fetchApi } from '.././fetch'
23
- import type { ApiError, ExportBatchRequest, ExportDocumentParams, ExportResult } from '../schemas'
24
-
25
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
26
-
27
- export const getExportDocumentUrl = (
28
- documentId: string,
29
- format: string,
30
- params?: ExportDocumentParams,
31
- ) => {
32
- const normalizedParams = new URLSearchParams()
33
-
34
- Object.entries(params || {}).forEach(([key, value]) => {
35
- if (value !== undefined) {
36
- normalizedParams.append(key, value === null ? 'null' : value.toString())
37
- }
38
- })
39
-
40
- const stringifiedParams = normalizedParams.toString()
41
-
42
- return stringifiedParams.length > 0
43
- ? `/api/v1/documents/${documentId}/export/${format}?${stringifiedParams}`
44
- : `/api/v1/documents/${documentId}/export/${format}`
45
- }
46
-
47
- export const exportDocument = async (
48
- documentId: string,
49
- format: string,
50
- params?: ExportDocumentParams,
51
- options?: RequestInit,
52
- ): Promise<Blob> => {
53
- return fetchApi<Blob>(getExportDocumentUrl(documentId, format, params), {
54
- ...options,
55
- method: 'GET',
56
- })
57
- }
58
-
59
- export const getExportDocumentQueryKey = (
60
- documentId: string,
61
- format: string,
62
- params?: ExportDocumentParams,
63
- ) => {
64
- return [`/api/v1/documents/${documentId}/export/${format}`, ...(params ? [params] : [])] as const
65
- }
66
-
67
- export const getExportDocumentQueryOptions = <
68
- TData = Awaited<ReturnType<typeof exportDocument>>,
69
- TError = ApiError,
70
- >(
71
- documentId: string,
72
- format: string,
73
- params?: ExportDocumentParams,
74
- options?: {
75
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData>>
76
- request?: SecondParameter<typeof fetchApi>
77
- },
78
- ) => {
79
- const { query: queryOptions, request: requestOptions } = options ?? {}
80
-
81
- const queryKey = queryOptions?.queryKey ?? getExportDocumentQueryKey(documentId, format, params)
82
-
83
- const queryFn: QueryFunction<Awaited<ReturnType<typeof exportDocument>>> = ({ signal }) =>
84
- exportDocument(documentId, format, params, { signal, ...requestOptions })
85
-
86
- return {
87
- queryKey,
88
- queryFn,
89
- enabled: !!(documentId && format),
90
- gcTime: 300000,
91
- retry: 1,
92
- ...queryOptions,
93
- } as UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData> & {
94
- queryKey: DataTag<QueryKey, TData, TError>
95
- }
96
- }
97
-
98
- export type ExportDocumentQueryResult = NonNullable<Awaited<ReturnType<typeof exportDocument>>>
99
- export type ExportDocumentQueryError = ApiError
100
-
101
- export function useExportDocument<
102
- TData = Awaited<ReturnType<typeof exportDocument>>,
103
- TError = ApiError,
104
- >(
105
- documentId: string,
106
- format: string,
107
- params: undefined | ExportDocumentParams,
108
- options: {
109
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData>> &
110
- Pick<
111
- DefinedInitialDataOptions<
112
- Awaited<ReturnType<typeof exportDocument>>,
113
- TError,
114
- Awaited<ReturnType<typeof exportDocument>>
115
- >,
116
- 'initialData'
117
- >
118
- request?: SecondParameter<typeof fetchApi>
119
- },
120
- queryClient?: QueryClient,
121
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
122
- export function useExportDocument<
123
- TData = Awaited<ReturnType<typeof exportDocument>>,
124
- TError = ApiError,
125
- >(
126
- documentId: string,
127
- format: string,
128
- params?: ExportDocumentParams,
129
- options?: {
130
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData>> &
131
- Pick<
132
- UndefinedInitialDataOptions<
133
- Awaited<ReturnType<typeof exportDocument>>,
134
- TError,
135
- Awaited<ReturnType<typeof exportDocument>>
136
- >,
137
- 'initialData'
138
- >
139
- request?: SecondParameter<typeof fetchApi>
140
- },
141
- queryClient?: QueryClient,
142
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
143
- export function useExportDocument<
144
- TData = Awaited<ReturnType<typeof exportDocument>>,
145
- TError = ApiError,
146
- >(
147
- documentId: string,
148
- format: string,
149
- params?: ExportDocumentParams,
150
- options?: {
151
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData>>
152
- request?: SecondParameter<typeof fetchApi>
153
- },
154
- queryClient?: QueryClient,
155
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
156
-
157
- export function useExportDocument<
158
- TData = Awaited<ReturnType<typeof exportDocument>>,
159
- TError = ApiError,
160
- >(
161
- documentId: string,
162
- format: string,
163
- params?: ExportDocumentParams,
164
- options?: {
165
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof exportDocument>>, TError, TData>>
166
- request?: SecondParameter<typeof fetchApi>
167
- },
168
- queryClient?: QueryClient,
169
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
170
- const queryOptions = getExportDocumentQueryOptions(documentId, format, params, options)
171
-
172
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
173
- queryKey: DataTag<QueryKey, TData, TError>
174
- }
175
-
176
- return { ...query, queryKey: queryOptions.queryKey }
177
- }
178
-
179
- export const getBatchExportUrl = () => {
180
- return `/api/v1/exports`
181
- }
182
-
183
- export const batchExport = async (
184
- exportBatchRequest: ExportBatchRequest,
185
- options?: RequestInit,
186
- ): Promise<ExportResult> => {
187
- return fetchApi<ExportResult>(getBatchExportUrl(), {
188
- ...options,
189
- method: 'POST',
190
- headers: { 'Content-Type': 'application/json', ...options?.headers },
191
- body: JSON.stringify(exportBatchRequest),
192
- })
193
- }
194
-
195
- export const getBatchExportMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
196
- mutation?: UseMutationOptions<
197
- Awaited<ReturnType<typeof batchExport>>,
198
- TError,
199
- { data: ExportBatchRequest },
200
- TContext
201
- >
202
- request?: SecondParameter<typeof fetchApi>
203
- }): UseMutationOptions<
204
- Awaited<ReturnType<typeof batchExport>>,
205
- TError,
206
- { data: ExportBatchRequest },
207
- TContext
208
- > => {
209
- const mutationKey = ['batchExport']
210
- const { mutation: mutationOptions, request: requestOptions } = options
211
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
212
- ? options
213
- : { ...options, mutation: { ...options.mutation, mutationKey } }
214
- : { mutation: { mutationKey }, request: undefined }
215
-
216
- const mutationFn: MutationFunction<
217
- Awaited<ReturnType<typeof batchExport>>,
218
- { data: ExportBatchRequest }
219
- > = (props) => {
220
- const { data } = props ?? {}
221
-
222
- return batchExport(data, requestOptions)
223
- }
224
-
225
- return { mutationFn, ...mutationOptions }
226
- }
227
-
228
- export type BatchExportMutationResult = NonNullable<Awaited<ReturnType<typeof batchExport>>>
229
- export type BatchExportMutationBody = ExportBatchRequest
230
- export type BatchExportMutationError = ApiError
231
-
232
- export const useBatchExport = <TError = ApiError, TContext = unknown>(
233
- options?: {
234
- mutation?: UseMutationOptions<
235
- Awaited<ReturnType<typeof batchExport>>,
236
- TError,
237
- { data: ExportBatchRequest },
238
- TContext
239
- >
240
- request?: SecondParameter<typeof fetchApi>
241
- },
242
- queryClient?: QueryClient,
243
- ): UseMutationResult<
244
- Awaited<ReturnType<typeof batchExport>>,
245
- TError,
246
- { data: ExportBatchRequest },
247
- TContext
248
- > => {
249
- return useMutation(getBatchExportMutationOptions(options), queryClient)
250
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/fetch.ts CHANGED
@@ -1,7 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
1
  export const fetchApi = async <T>(url: string, options?: RequestInit): Promise<T> => {
2
  const res = await fetch(url, options)
3
  if (!res.ok) {
4
- throw await res.json().catch(() => ({ status: res.status, message: res.statusText }))
 
 
 
 
 
 
 
5
  }
6
  if ([204, 205, 304].includes(res.status)) {
7
  return undefined as T
 
1
+ export class ApiError extends Error {
2
+ readonly status: number
3
+ readonly body: unknown
4
+ constructor(status: number, message: string, body?: unknown) {
5
+ super(message)
6
+ this.name = 'ApiError'
7
+ this.status = status
8
+ this.body = body
9
+ }
10
+ }
11
+
12
  export const fetchApi = async <T>(url: string, options?: RequestInit): Promise<T> => {
13
  const res = await fetch(url, options)
14
  if (!res.ok) {
15
+ const body = await res.json().catch(() => null)
16
+ const message =
17
+ (body && typeof body === 'object' && 'message' in body && typeof body.message === 'string'
18
+ ? body.message
19
+ : null) ??
20
+ res.statusText ??
21
+ `HTTP ${res.status}`
22
+ throw new ApiError(res.status, message, body)
23
  }
24
  if ([204, 205, 304].includes(res.status)) {
25
  return undefined as T
ui/lib/api/jobs/jobs.ts DELETED
@@ -1,362 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation, useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- MutationFunction,
12
- QueryClient,
13
- QueryFunction,
14
- QueryKey,
15
- UndefinedInitialDataOptions,
16
- UseMutationOptions,
17
- UseMutationResult,
18
- UseQueryOptions,
19
- UseQueryResult,
20
- } from '@tanstack/react-query'
21
-
22
- import { fetchApi } from '.././fetch'
23
- import type { ApiError, JobState, PipelineJobRequest } from '../schemas'
24
-
25
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
26
-
27
- export const getListJobsUrl = () => {
28
- return `/api/v1/jobs`
29
- }
30
-
31
- export const listJobs = async (options?: RequestInit): Promise<JobState[]> => {
32
- return fetchApi<JobState[]>(getListJobsUrl(), {
33
- ...options,
34
- method: 'GET',
35
- })
36
- }
37
-
38
- export const getListJobsQueryKey = () => {
39
- return [`/api/v1/jobs`] as const
40
- }
41
-
42
- export const getListJobsQueryOptions = <
43
- TData = Awaited<ReturnType<typeof listJobs>>,
44
- TError = unknown,
45
- >(options?: {
46
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listJobs>>, TError, TData>>
47
- request?: SecondParameter<typeof fetchApi>
48
- }) => {
49
- const { query: queryOptions, request: requestOptions } = options ?? {}
50
-
51
- const queryKey = queryOptions?.queryKey ?? getListJobsQueryKey()
52
-
53
- const queryFn: QueryFunction<Awaited<ReturnType<typeof listJobs>>> = ({ signal }) =>
54
- listJobs({ signal, ...requestOptions })
55
-
56
- return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions<
57
- Awaited<ReturnType<typeof listJobs>>,
58
- TError,
59
- TData
60
- > & { queryKey: DataTag<QueryKey, TData, TError> }
61
- }
62
-
63
- export type ListJobsQueryResult = NonNullable<Awaited<ReturnType<typeof listJobs>>>
64
- export type ListJobsQueryError = unknown
65
-
66
- export function useListJobs<TData = Awaited<ReturnType<typeof listJobs>>, TError = unknown>(
67
- options: {
68
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof listJobs>>, TError, TData>> &
69
- Pick<
70
- DefinedInitialDataOptions<
71
- Awaited<ReturnType<typeof listJobs>>,
72
- TError,
73
- Awaited<ReturnType<typeof listJobs>>
74
- >,
75
- 'initialData'
76
- >
77
- request?: SecondParameter<typeof fetchApi>
78
- },
79
- queryClient?: QueryClient,
80
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
81
- export function useListJobs<TData = Awaited<ReturnType<typeof listJobs>>, TError = unknown>(
82
- options?: {
83
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listJobs>>, TError, TData>> &
84
- Pick<
85
- UndefinedInitialDataOptions<
86
- Awaited<ReturnType<typeof listJobs>>,
87
- TError,
88
- Awaited<ReturnType<typeof listJobs>>
89
- >,
90
- 'initialData'
91
- >
92
- request?: SecondParameter<typeof fetchApi>
93
- },
94
- queryClient?: QueryClient,
95
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
96
- export function useListJobs<TData = Awaited<ReturnType<typeof listJobs>>, TError = unknown>(
97
- options?: {
98
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listJobs>>, TError, TData>>
99
- request?: SecondParameter<typeof fetchApi>
100
- },
101
- queryClient?: QueryClient,
102
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
103
-
104
- export function useListJobs<TData = Awaited<ReturnType<typeof listJobs>>, TError = unknown>(
105
- options?: {
106
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof listJobs>>, TError, TData>>
107
- request?: SecondParameter<typeof fetchApi>
108
- },
109
- queryClient?: QueryClient,
110
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
111
- const queryOptions = getListJobsQueryOptions(options)
112
-
113
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
114
- queryKey: DataTag<QueryKey, TData, TError>
115
- }
116
-
117
- return { ...query, queryKey: queryOptions.queryKey }
118
- }
119
-
120
- export const getStartPipelineUrl = () => {
121
- return `/api/v1/jobs/pipeline`
122
- }
123
-
124
- export const startPipeline = async (
125
- pipelineJobRequest: PipelineJobRequest,
126
- options?: RequestInit,
127
- ): Promise<JobState> => {
128
- return fetchApi<JobState>(getStartPipelineUrl(), {
129
- ...options,
130
- method: 'POST',
131
- headers: { 'Content-Type': 'application/json', ...options?.headers },
132
- body: JSON.stringify(pipelineJobRequest),
133
- })
134
- }
135
-
136
- export const getStartPipelineMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
137
- mutation?: UseMutationOptions<
138
- Awaited<ReturnType<typeof startPipeline>>,
139
- TError,
140
- { data: PipelineJobRequest },
141
- TContext
142
- >
143
- request?: SecondParameter<typeof fetchApi>
144
- }): UseMutationOptions<
145
- Awaited<ReturnType<typeof startPipeline>>,
146
- TError,
147
- { data: PipelineJobRequest },
148
- TContext
149
- > => {
150
- const mutationKey = ['startPipeline']
151
- const { mutation: mutationOptions, request: requestOptions } = options
152
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
153
- ? options
154
- : { ...options, mutation: { ...options.mutation, mutationKey } }
155
- : { mutation: { mutationKey }, request: undefined }
156
-
157
- const mutationFn: MutationFunction<
158
- Awaited<ReturnType<typeof startPipeline>>,
159
- { data: PipelineJobRequest }
160
- > = (props) => {
161
- const { data } = props ?? {}
162
-
163
- return startPipeline(data, requestOptions)
164
- }
165
-
166
- return { mutationFn, ...mutationOptions }
167
- }
168
-
169
- export type StartPipelineMutationResult = NonNullable<Awaited<ReturnType<typeof startPipeline>>>
170
- export type StartPipelineMutationBody = PipelineJobRequest
171
- export type StartPipelineMutationError = ApiError
172
-
173
- export const useStartPipeline = <TError = ApiError, TContext = unknown>(
174
- options?: {
175
- mutation?: UseMutationOptions<
176
- Awaited<ReturnType<typeof startPipeline>>,
177
- TError,
178
- { data: PipelineJobRequest },
179
- TContext
180
- >
181
- request?: SecondParameter<typeof fetchApi>
182
- },
183
- queryClient?: QueryClient,
184
- ): UseMutationResult<
185
- Awaited<ReturnType<typeof startPipeline>>,
186
- TError,
187
- { data: PipelineJobRequest },
188
- TContext
189
- > => {
190
- return useMutation(getStartPipelineMutationOptions(options), queryClient)
191
- }
192
- export const getGetJobUrl = (jobId: string) => {
193
- return `/api/v1/jobs/${jobId}`
194
- }
195
-
196
- export const getJob = async (jobId: string, options?: RequestInit): Promise<JobState> => {
197
- return fetchApi<JobState>(getGetJobUrl(jobId), {
198
- ...options,
199
- method: 'GET',
200
- })
201
- }
202
-
203
- export const getGetJobQueryKey = (jobId: string) => {
204
- return [`/api/v1/jobs/${jobId}`] as const
205
- }
206
-
207
- export const getGetJobQueryOptions = <
208
- TData = Awaited<ReturnType<typeof getJob>>,
209
- TError = ApiError,
210
- >(
211
- jobId: string,
212
- options?: {
213
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData>>
214
- request?: SecondParameter<typeof fetchApi>
215
- },
216
- ) => {
217
- const { query: queryOptions, request: requestOptions } = options ?? {}
218
-
219
- const queryKey = queryOptions?.queryKey ?? getGetJobQueryKey(jobId)
220
-
221
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getJob>>> = ({ signal }) =>
222
- getJob(jobId, { signal, ...requestOptions })
223
-
224
- return {
225
- queryKey,
226
- queryFn,
227
- enabled: !!jobId,
228
- gcTime: 300000,
229
- retry: 1,
230
- ...queryOptions,
231
- } as UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData> & {
232
- queryKey: DataTag<QueryKey, TData, TError>
233
- }
234
- }
235
-
236
- export type GetJobQueryResult = NonNullable<Awaited<ReturnType<typeof getJob>>>
237
- export type GetJobQueryError = ApiError
238
-
239
- export function useGetJob<TData = Awaited<ReturnType<typeof getJob>>, TError = ApiError>(
240
- jobId: string,
241
- options: {
242
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData>> &
243
- Pick<
244
- DefinedInitialDataOptions<
245
- Awaited<ReturnType<typeof getJob>>,
246
- TError,
247
- Awaited<ReturnType<typeof getJob>>
248
- >,
249
- 'initialData'
250
- >
251
- request?: SecondParameter<typeof fetchApi>
252
- },
253
- queryClient?: QueryClient,
254
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
255
- export function useGetJob<TData = Awaited<ReturnType<typeof getJob>>, TError = ApiError>(
256
- jobId: string,
257
- options?: {
258
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData>> &
259
- Pick<
260
- UndefinedInitialDataOptions<
261
- Awaited<ReturnType<typeof getJob>>,
262
- TError,
263
- Awaited<ReturnType<typeof getJob>>
264
- >,
265
- 'initialData'
266
- >
267
- request?: SecondParameter<typeof fetchApi>
268
- },
269
- queryClient?: QueryClient,
270
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
271
- export function useGetJob<TData = Awaited<ReturnType<typeof getJob>>, TError = ApiError>(
272
- jobId: string,
273
- options?: {
274
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData>>
275
- request?: SecondParameter<typeof fetchApi>
276
- },
277
- queryClient?: QueryClient,
278
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
279
-
280
- export function useGetJob<TData = Awaited<ReturnType<typeof getJob>>, TError = ApiError>(
281
- jobId: string,
282
- options?: {
283
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getJob>>, TError, TData>>
284
- request?: SecondParameter<typeof fetchApi>
285
- },
286
- queryClient?: QueryClient,
287
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
288
- const queryOptions = getGetJobQueryOptions(jobId, options)
289
-
290
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
291
- queryKey: DataTag<QueryKey, TData, TError>
292
- }
293
-
294
- return { ...query, queryKey: queryOptions.queryKey }
295
- }
296
-
297
- export const getCancelJobUrl = (jobId: string) => {
298
- return `/api/v1/jobs/${jobId}`
299
- }
300
-
301
- export const cancelJob = async (jobId: string, options?: RequestInit): Promise<void> => {
302
- return fetchApi<void>(getCancelJobUrl(jobId), {
303
- ...options,
304
- method: 'DELETE',
305
- })
306
- }
307
-
308
- export const getCancelJobMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
309
- mutation?: UseMutationOptions<
310
- Awaited<ReturnType<typeof cancelJob>>,
311
- TError,
312
- { jobId: string },
313
- TContext
314
- >
315
- request?: SecondParameter<typeof fetchApi>
316
- }): UseMutationOptions<
317
- Awaited<ReturnType<typeof cancelJob>>,
318
- TError,
319
- { jobId: string },
320
- TContext
321
- > => {
322
- const mutationKey = ['cancelJob']
323
- const { mutation: mutationOptions, request: requestOptions } = options
324
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
325
- ? options
326
- : { ...options, mutation: { ...options.mutation, mutationKey } }
327
- : { mutation: { mutationKey }, request: undefined }
328
-
329
- const mutationFn: MutationFunction<Awaited<ReturnType<typeof cancelJob>>, { jobId: string }> = (
330
- props,
331
- ) => {
332
- const { jobId } = props ?? {}
333
-
334
- return cancelJob(jobId, requestOptions)
335
- }
336
-
337
- return { mutationFn, ...mutationOptions }
338
- }
339
-
340
- export type CancelJobMutationResult = NonNullable<Awaited<ReturnType<typeof cancelJob>>>
341
-
342
- export type CancelJobMutationError = ApiError
343
-
344
- export const useCancelJob = <TError = ApiError, TContext = unknown>(
345
- options?: {
346
- mutation?: UseMutationOptions<
347
- Awaited<ReturnType<typeof cancelJob>>,
348
- TError,
349
- { jobId: string },
350
- TContext
351
- >
352
- request?: SecondParameter<typeof fetchApi>
353
- },
354
- queryClient?: QueryClient,
355
- ): UseMutationResult<
356
- Awaited<ReturnType<typeof cancelJob>>,
357
- TError,
358
- { jobId: string },
359
- TContext
360
- > => {
361
- return useMutation(getCancelJobMutationOptions(options), queryClient)
362
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/llm/llm.ts DELETED
@@ -1,337 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation, useQuery } from '@tanstack/react-query'
7
- import type {
8
- DataTag,
9
- DefinedInitialDataOptions,
10
- DefinedUseQueryResult,
11
- MutationFunction,
12
- QueryClient,
13
- QueryFunction,
14
- QueryKey,
15
- UndefinedInitialDataOptions,
16
- UseMutationOptions,
17
- UseMutationResult,
18
- UseQueryOptions,
19
- UseQueryResult,
20
- } from '@tanstack/react-query'
21
-
22
- import { fetchApi } from '.././fetch'
23
- import type { ApiError, LlmCatalog, LlmLoadRequest, LlmState } from '../schemas'
24
-
25
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
26
-
27
- export const getGetLlmUrl = () => {
28
- return `/api/v1/llm`
29
- }
30
-
31
- export const getLlm = async (options?: RequestInit): Promise<LlmState> => {
32
- return fetchApi<LlmState>(getGetLlmUrl(), {
33
- ...options,
34
- method: 'GET',
35
- })
36
- }
37
-
38
- export const getGetLlmQueryKey = () => {
39
- return [`/api/v1/llm`] as const
40
- }
41
-
42
- export const getGetLlmQueryOptions = <
43
- TData = Awaited<ReturnType<typeof getLlm>>,
44
- TError = ApiError,
45
- >(options?: {
46
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlm>>, TError, TData>>
47
- request?: SecondParameter<typeof fetchApi>
48
- }) => {
49
- const { query: queryOptions, request: requestOptions } = options ?? {}
50
-
51
- const queryKey = queryOptions?.queryKey ?? getGetLlmQueryKey()
52
-
53
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getLlm>>> = ({ signal }) =>
54
- getLlm({ signal, ...requestOptions })
55
-
56
- return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions<
57
- Awaited<ReturnType<typeof getLlm>>,
58
- TError,
59
- TData
60
- > & { queryKey: DataTag<QueryKey, TData, TError> }
61
- }
62
-
63
- export type GetLlmQueryResult = NonNullable<Awaited<ReturnType<typeof getLlm>>>
64
- export type GetLlmQueryError = ApiError
65
-
66
- export function useGetLlm<TData = Awaited<ReturnType<typeof getLlm>>, TError = ApiError>(
67
- options: {
68
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlm>>, TError, TData>> &
69
- Pick<
70
- DefinedInitialDataOptions<
71
- Awaited<ReturnType<typeof getLlm>>,
72
- TError,
73
- Awaited<ReturnType<typeof getLlm>>
74
- >,
75
- 'initialData'
76
- >
77
- request?: SecondParameter<typeof fetchApi>
78
- },
79
- queryClient?: QueryClient,
80
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
81
- export function useGetLlm<TData = Awaited<ReturnType<typeof getLlm>>, TError = ApiError>(
82
- options?: {
83
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlm>>, TError, TData>> &
84
- Pick<
85
- UndefinedInitialDataOptions<
86
- Awaited<ReturnType<typeof getLlm>>,
87
- TError,
88
- Awaited<ReturnType<typeof getLlm>>
89
- >,
90
- 'initialData'
91
- >
92
- request?: SecondParameter<typeof fetchApi>
93
- },
94
- queryClient?: QueryClient,
95
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
96
- export function useGetLlm<TData = Awaited<ReturnType<typeof getLlm>>, TError = ApiError>(
97
- options?: {
98
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlm>>, TError, TData>>
99
- request?: SecondParameter<typeof fetchApi>
100
- },
101
- queryClient?: QueryClient,
102
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
103
-
104
- export function useGetLlm<TData = Awaited<ReturnType<typeof getLlm>>, TError = ApiError>(
105
- options?: {
106
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlm>>, TError, TData>>
107
- request?: SecondParameter<typeof fetchApi>
108
- },
109
- queryClient?: QueryClient,
110
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
111
- const queryOptions = getGetLlmQueryOptions(options)
112
-
113
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
114
- queryKey: DataTag<QueryKey, TData, TError>
115
- }
116
-
117
- return { ...query, queryKey: queryOptions.queryKey }
118
- }
119
-
120
- export const getLoadLlmUrl = () => {
121
- return `/api/v1/llm`
122
- }
123
-
124
- export const loadLlm = async (
125
- llmLoadRequest: LlmLoadRequest,
126
- options?: RequestInit,
127
- ): Promise<LlmState> => {
128
- return fetchApi<LlmState>(getLoadLlmUrl(), {
129
- ...options,
130
- method: 'PUT',
131
- headers: { 'Content-Type': 'application/json', ...options?.headers },
132
- body: JSON.stringify(llmLoadRequest),
133
- })
134
- }
135
-
136
- export const getLoadLlmMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
137
- mutation?: UseMutationOptions<
138
- Awaited<ReturnType<typeof loadLlm>>,
139
- TError,
140
- { data: LlmLoadRequest },
141
- TContext
142
- >
143
- request?: SecondParameter<typeof fetchApi>
144
- }): UseMutationOptions<
145
- Awaited<ReturnType<typeof loadLlm>>,
146
- TError,
147
- { data: LlmLoadRequest },
148
- TContext
149
- > => {
150
- const mutationKey = ['loadLlm']
151
- const { mutation: mutationOptions, request: requestOptions } = options
152
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
153
- ? options
154
- : { ...options, mutation: { ...options.mutation, mutationKey } }
155
- : { mutation: { mutationKey }, request: undefined }
156
-
157
- const mutationFn: MutationFunction<
158
- Awaited<ReturnType<typeof loadLlm>>,
159
- { data: LlmLoadRequest }
160
- > = (props) => {
161
- const { data } = props ?? {}
162
-
163
- return loadLlm(data, requestOptions)
164
- }
165
-
166
- return { mutationFn, ...mutationOptions }
167
- }
168
-
169
- export type LoadLlmMutationResult = NonNullable<Awaited<ReturnType<typeof loadLlm>>>
170
- export type LoadLlmMutationBody = LlmLoadRequest
171
- export type LoadLlmMutationError = ApiError
172
-
173
- export const useLoadLlm = <TError = ApiError, TContext = unknown>(
174
- options?: {
175
- mutation?: UseMutationOptions<
176
- Awaited<ReturnType<typeof loadLlm>>,
177
- TError,
178
- { data: LlmLoadRequest },
179
- TContext
180
- >
181
- request?: SecondParameter<typeof fetchApi>
182
- },
183
- queryClient?: QueryClient,
184
- ): UseMutationResult<
185
- Awaited<ReturnType<typeof loadLlm>>,
186
- TError,
187
- { data: LlmLoadRequest },
188
- TContext
189
- > => {
190
- return useMutation(getLoadLlmMutationOptions(options), queryClient)
191
- }
192
- export const getUnloadLlmUrl = () => {
193
- return `/api/v1/llm`
194
- }
195
-
196
- export const unloadLlm = async (options?: RequestInit): Promise<LlmState> => {
197
- return fetchApi<LlmState>(getUnloadLlmUrl(), {
198
- ...options,
199
- method: 'DELETE',
200
- })
201
- }
202
-
203
- export const getUnloadLlmMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
204
- mutation?: UseMutationOptions<Awaited<ReturnType<typeof unloadLlm>>, TError, void, TContext>
205
- request?: SecondParameter<typeof fetchApi>
206
- }): UseMutationOptions<Awaited<ReturnType<typeof unloadLlm>>, TError, void, TContext> => {
207
- const mutationKey = ['unloadLlm']
208
- const { mutation: mutationOptions, request: requestOptions } = options
209
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
210
- ? options
211
- : { ...options, mutation: { ...options.mutation, mutationKey } }
212
- : { mutation: { mutationKey }, request: undefined }
213
-
214
- const mutationFn: MutationFunction<Awaited<ReturnType<typeof unloadLlm>>, void> = () => {
215
- return unloadLlm(requestOptions)
216
- }
217
-
218
- return { mutationFn, ...mutationOptions }
219
- }
220
-
221
- export type UnloadLlmMutationResult = NonNullable<Awaited<ReturnType<typeof unloadLlm>>>
222
-
223
- export type UnloadLlmMutationError = ApiError
224
-
225
- export const useUnloadLlm = <TError = ApiError, TContext = unknown>(
226
- options?: {
227
- mutation?: UseMutationOptions<Awaited<ReturnType<typeof unloadLlm>>, TError, void, TContext>
228
- request?: SecondParameter<typeof fetchApi>
229
- },
230
- queryClient?: QueryClient,
231
- ): UseMutationResult<Awaited<ReturnType<typeof unloadLlm>>, TError, void, TContext> => {
232
- return useMutation(getUnloadLlmMutationOptions(options), queryClient)
233
- }
234
- export const getGetLlmCatalogUrl = () => {
235
- return `/api/v1/llm/catalog`
236
- }
237
-
238
- export const getLlmCatalog = async (options?: RequestInit): Promise<LlmCatalog> => {
239
- return fetchApi<LlmCatalog>(getGetLlmCatalogUrl(), {
240
- ...options,
241
- method: 'GET',
242
- })
243
- }
244
-
245
- export const getGetLlmCatalogQueryKey = () => {
246
- return [`/api/v1/llm/catalog`] as const
247
- }
248
-
249
- export const getGetLlmCatalogQueryOptions = <
250
- TData = Awaited<ReturnType<typeof getLlmCatalog>>,
251
- TError = ApiError,
252
- >(options?: {
253
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlmCatalog>>, TError, TData>>
254
- request?: SecondParameter<typeof fetchApi>
255
- }) => {
256
- const { query: queryOptions, request: requestOptions } = options ?? {}
257
-
258
- const queryKey = queryOptions?.queryKey ?? getGetLlmCatalogQueryKey()
259
-
260
- const queryFn: QueryFunction<Awaited<ReturnType<typeof getLlmCatalog>>> = ({ signal }) =>
261
- getLlmCatalog({ signal, ...requestOptions })
262
-
263
- return { queryKey, queryFn, gcTime: 300000, retry: 1, ...queryOptions } as UseQueryOptions<
264
- Awaited<ReturnType<typeof getLlmCatalog>>,
265
- TError,
266
- TData
267
- > & { queryKey: DataTag<QueryKey, TData, TError> }
268
- }
269
-
270
- export type GetLlmCatalogQueryResult = NonNullable<Awaited<ReturnType<typeof getLlmCatalog>>>
271
- export type GetLlmCatalogQueryError = ApiError
272
-
273
- export function useGetLlmCatalog<
274
- TData = Awaited<ReturnType<typeof getLlmCatalog>>,
275
- TError = ApiError,
276
- >(
277
- options: {
278
- query: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlmCatalog>>, TError, TData>> &
279
- Pick<
280
- DefinedInitialDataOptions<
281
- Awaited<ReturnType<typeof getLlmCatalog>>,
282
- TError,
283
- Awaited<ReturnType<typeof getLlmCatalog>>
284
- >,
285
- 'initialData'
286
- >
287
- request?: SecondParameter<typeof fetchApi>
288
- },
289
- queryClient?: QueryClient,
290
- ): DefinedUseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
291
- export function useGetLlmCatalog<
292
- TData = Awaited<ReturnType<typeof getLlmCatalog>>,
293
- TError = ApiError,
294
- >(
295
- options?: {
296
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlmCatalog>>, TError, TData>> &
297
- Pick<
298
- UndefinedInitialDataOptions<
299
- Awaited<ReturnType<typeof getLlmCatalog>>,
300
- TError,
301
- Awaited<ReturnType<typeof getLlmCatalog>>
302
- >,
303
- 'initialData'
304
- >
305
- request?: SecondParameter<typeof fetchApi>
306
- },
307
- queryClient?: QueryClient,
308
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
309
- export function useGetLlmCatalog<
310
- TData = Awaited<ReturnType<typeof getLlmCatalog>>,
311
- TError = ApiError,
312
- >(
313
- options?: {
314
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlmCatalog>>, TError, TData>>
315
- request?: SecondParameter<typeof fetchApi>
316
- },
317
- queryClient?: QueryClient,
318
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> }
319
-
320
- export function useGetLlmCatalog<
321
- TData = Awaited<ReturnType<typeof getLlmCatalog>>,
322
- TError = ApiError,
323
- >(
324
- options?: {
325
- query?: Partial<UseQueryOptions<Awaited<ReturnType<typeof getLlmCatalog>>, TError, TData>>
326
- request?: SecondParameter<typeof fetchApi>
327
- },
328
- queryClient?: QueryClient,
329
- ): UseQueryResult<TData, TError> & { queryKey: DataTag<QueryKey, TData, TError> } {
330
- const queryOptions = getGetLlmCatalogQueryOptions(options)
331
-
332
- const query = useQuery(queryOptions, queryClient) as UseQueryResult<TData, TError> & {
333
- queryKey: DataTag<QueryKey, TData, TError>
334
- }
335
-
336
- return { ...query, queryKey: queryOptions.queryKey }
337
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/processing/processing.ts DELETED
@@ -1,378 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation } from '@tanstack/react-query'
7
- import type {
8
- MutationFunction,
9
- QueryClient,
10
- UseMutationOptions,
11
- UseMutationResult,
12
- } from '@tanstack/react-query'
13
-
14
- import { fetchApi } from '.././fetch'
15
- import type { ApiError, RenderRequest, TranslateRequest } from '../schemas'
16
-
17
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
18
-
19
- export const getDetectDocumentUrl = (documentId: string) => {
20
- return `/api/v1/documents/${documentId}/detect`
21
- }
22
-
23
- export const detectDocument = async (documentId: string, options?: RequestInit): Promise<void> => {
24
- return fetchApi<void>(getDetectDocumentUrl(documentId), {
25
- ...options,
26
- method: 'POST',
27
- })
28
- }
29
-
30
- export const getDetectDocumentMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
31
- mutation?: UseMutationOptions<
32
- Awaited<ReturnType<typeof detectDocument>>,
33
- TError,
34
- { documentId: string },
35
- TContext
36
- >
37
- request?: SecondParameter<typeof fetchApi>
38
- }): UseMutationOptions<
39
- Awaited<ReturnType<typeof detectDocument>>,
40
- TError,
41
- { documentId: string },
42
- TContext
43
- > => {
44
- const mutationKey = ['detectDocument']
45
- const { mutation: mutationOptions, request: requestOptions } = options
46
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
47
- ? options
48
- : { ...options, mutation: { ...options.mutation, mutationKey } }
49
- : { mutation: { mutationKey }, request: undefined }
50
-
51
- const mutationFn: MutationFunction<
52
- Awaited<ReturnType<typeof detectDocument>>,
53
- { documentId: string }
54
- > = (props) => {
55
- const { documentId } = props ?? {}
56
-
57
- return detectDocument(documentId, requestOptions)
58
- }
59
-
60
- return { mutationFn, ...mutationOptions }
61
- }
62
-
63
- export type DetectDocumentMutationResult = NonNullable<Awaited<ReturnType<typeof detectDocument>>>
64
-
65
- export type DetectDocumentMutationError = ApiError
66
-
67
- export const useDetectDocument = <TError = ApiError, TContext = unknown>(
68
- options?: {
69
- mutation?: UseMutationOptions<
70
- Awaited<ReturnType<typeof detectDocument>>,
71
- TError,
72
- { documentId: string },
73
- TContext
74
- >
75
- request?: SecondParameter<typeof fetchApi>
76
- },
77
- queryClient?: QueryClient,
78
- ): UseMutationResult<
79
- Awaited<ReturnType<typeof detectDocument>>,
80
- TError,
81
- { documentId: string },
82
- TContext
83
- > => {
84
- return useMutation(getDetectDocumentMutationOptions(options), queryClient)
85
- }
86
- export const getInpaintDocumentUrl = (documentId: string) => {
87
- return `/api/v1/documents/${documentId}/inpaint`
88
- }
89
-
90
- export const inpaintDocument = async (documentId: string, options?: RequestInit): Promise<void> => {
91
- return fetchApi<void>(getInpaintDocumentUrl(documentId), {
92
- ...options,
93
- method: 'POST',
94
- })
95
- }
96
-
97
- export const getInpaintDocumentMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
98
- mutation?: UseMutationOptions<
99
- Awaited<ReturnType<typeof inpaintDocument>>,
100
- TError,
101
- { documentId: string },
102
- TContext
103
- >
104
- request?: SecondParameter<typeof fetchApi>
105
- }): UseMutationOptions<
106
- Awaited<ReturnType<typeof inpaintDocument>>,
107
- TError,
108
- { documentId: string },
109
- TContext
110
- > => {
111
- const mutationKey = ['inpaintDocument']
112
- const { mutation: mutationOptions, request: requestOptions } = options
113
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
114
- ? options
115
- : { ...options, mutation: { ...options.mutation, mutationKey } }
116
- : { mutation: { mutationKey }, request: undefined }
117
-
118
- const mutationFn: MutationFunction<
119
- Awaited<ReturnType<typeof inpaintDocument>>,
120
- { documentId: string }
121
- > = (props) => {
122
- const { documentId } = props ?? {}
123
-
124
- return inpaintDocument(documentId, requestOptions)
125
- }
126
-
127
- return { mutationFn, ...mutationOptions }
128
- }
129
-
130
- export type InpaintDocumentMutationResult = NonNullable<Awaited<ReturnType<typeof inpaintDocument>>>
131
-
132
- export type InpaintDocumentMutationError = ApiError
133
-
134
- export const useInpaintDocument = <TError = ApiError, TContext = unknown>(
135
- options?: {
136
- mutation?: UseMutationOptions<
137
- Awaited<ReturnType<typeof inpaintDocument>>,
138
- TError,
139
- { documentId: string },
140
- TContext
141
- >
142
- request?: SecondParameter<typeof fetchApi>
143
- },
144
- queryClient?: QueryClient,
145
- ): UseMutationResult<
146
- Awaited<ReturnType<typeof inpaintDocument>>,
147
- TError,
148
- { documentId: string },
149
- TContext
150
- > => {
151
- return useMutation(getInpaintDocumentMutationOptions(options), queryClient)
152
- }
153
- export const getRecognizeDocumentUrl = (documentId: string) => {
154
- return `/api/v1/documents/${documentId}/recognize`
155
- }
156
-
157
- export const recognizeDocument = async (
158
- documentId: string,
159
- options?: RequestInit,
160
- ): Promise<void> => {
161
- return fetchApi<void>(getRecognizeDocumentUrl(documentId), {
162
- ...options,
163
- method: 'POST',
164
- })
165
- }
166
-
167
- export const getRecognizeDocumentMutationOptions = <
168
- TError = ApiError,
169
- TContext = unknown,
170
- >(options?: {
171
- mutation?: UseMutationOptions<
172
- Awaited<ReturnType<typeof recognizeDocument>>,
173
- TError,
174
- { documentId: string },
175
- TContext
176
- >
177
- request?: SecondParameter<typeof fetchApi>
178
- }): UseMutationOptions<
179
- Awaited<ReturnType<typeof recognizeDocument>>,
180
- TError,
181
- { documentId: string },
182
- TContext
183
- > => {
184
- const mutationKey = ['recognizeDocument']
185
- const { mutation: mutationOptions, request: requestOptions } = options
186
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
187
- ? options
188
- : { ...options, mutation: { ...options.mutation, mutationKey } }
189
- : { mutation: { mutationKey }, request: undefined }
190
-
191
- const mutationFn: MutationFunction<
192
- Awaited<ReturnType<typeof recognizeDocument>>,
193
- { documentId: string }
194
- > = (props) => {
195
- const { documentId } = props ?? {}
196
-
197
- return recognizeDocument(documentId, requestOptions)
198
- }
199
-
200
- return { mutationFn, ...mutationOptions }
201
- }
202
-
203
- export type RecognizeDocumentMutationResult = NonNullable<
204
- Awaited<ReturnType<typeof recognizeDocument>>
205
- >
206
-
207
- export type RecognizeDocumentMutationError = ApiError
208
-
209
- export const useRecognizeDocument = <TError = ApiError, TContext = unknown>(
210
- options?: {
211
- mutation?: UseMutationOptions<
212
- Awaited<ReturnType<typeof recognizeDocument>>,
213
- TError,
214
- { documentId: string },
215
- TContext
216
- >
217
- request?: SecondParameter<typeof fetchApi>
218
- },
219
- queryClient?: QueryClient,
220
- ): UseMutationResult<
221
- Awaited<ReturnType<typeof recognizeDocument>>,
222
- TError,
223
- { documentId: string },
224
- TContext
225
- > => {
226
- return useMutation(getRecognizeDocumentMutationOptions(options), queryClient)
227
- }
228
- export const getRenderDocumentUrl = (documentId: string) => {
229
- return `/api/v1/documents/${documentId}/render`
230
- }
231
-
232
- export const renderDocument = async (
233
- documentId: string,
234
- renderRequest: RenderRequest,
235
- options?: RequestInit,
236
- ): Promise<void> => {
237
- return fetchApi<void>(getRenderDocumentUrl(documentId), {
238
- ...options,
239
- method: 'POST',
240
- headers: { 'Content-Type': 'application/json', ...options?.headers },
241
- body: JSON.stringify(renderRequest),
242
- })
243
- }
244
-
245
- export const getRenderDocumentMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
246
- mutation?: UseMutationOptions<
247
- Awaited<ReturnType<typeof renderDocument>>,
248
- TError,
249
- { documentId: string; data: RenderRequest },
250
- TContext
251
- >
252
- request?: SecondParameter<typeof fetchApi>
253
- }): UseMutationOptions<
254
- Awaited<ReturnType<typeof renderDocument>>,
255
- TError,
256
- { documentId: string; data: RenderRequest },
257
- TContext
258
- > => {
259
- const mutationKey = ['renderDocument']
260
- const { mutation: mutationOptions, request: requestOptions } = options
261
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
262
- ? options
263
- : { ...options, mutation: { ...options.mutation, mutationKey } }
264
- : { mutation: { mutationKey }, request: undefined }
265
-
266
- const mutationFn: MutationFunction<
267
- Awaited<ReturnType<typeof renderDocument>>,
268
- { documentId: string; data: RenderRequest }
269
- > = (props) => {
270
- const { documentId, data } = props ?? {}
271
-
272
- return renderDocument(documentId, data, requestOptions)
273
- }
274
-
275
- return { mutationFn, ...mutationOptions }
276
- }
277
-
278
- export type RenderDocumentMutationResult = NonNullable<Awaited<ReturnType<typeof renderDocument>>>
279
- export type RenderDocumentMutationBody = RenderRequest
280
- export type RenderDocumentMutationError = ApiError
281
-
282
- export const useRenderDocument = <TError = ApiError, TContext = unknown>(
283
- options?: {
284
- mutation?: UseMutationOptions<
285
- Awaited<ReturnType<typeof renderDocument>>,
286
- TError,
287
- { documentId: string; data: RenderRequest },
288
- TContext
289
- >
290
- request?: SecondParameter<typeof fetchApi>
291
- },
292
- queryClient?: QueryClient,
293
- ): UseMutationResult<
294
- Awaited<ReturnType<typeof renderDocument>>,
295
- TError,
296
- { documentId: string; data: RenderRequest },
297
- TContext
298
- > => {
299
- return useMutation(getRenderDocumentMutationOptions(options), queryClient)
300
- }
301
- export const getTranslateDocumentUrl = (documentId: string) => {
302
- return `/api/v1/documents/${documentId}/translate`
303
- }
304
-
305
- export const translateDocument = async (
306
- documentId: string,
307
- translateRequest: TranslateRequest,
308
- options?: RequestInit,
309
- ): Promise<void> => {
310
- return fetchApi<void>(getTranslateDocumentUrl(documentId), {
311
- ...options,
312
- method: 'POST',
313
- headers: { 'Content-Type': 'application/json', ...options?.headers },
314
- body: JSON.stringify(translateRequest),
315
- })
316
- }
317
-
318
- export const getTranslateDocumentMutationOptions = <
319
- TError = ApiError,
320
- TContext = unknown,
321
- >(options?: {
322
- mutation?: UseMutationOptions<
323
- Awaited<ReturnType<typeof translateDocument>>,
324
- TError,
325
- { documentId: string; data: TranslateRequest },
326
- TContext
327
- >
328
- request?: SecondParameter<typeof fetchApi>
329
- }): UseMutationOptions<
330
- Awaited<ReturnType<typeof translateDocument>>,
331
- TError,
332
- { documentId: string; data: TranslateRequest },
333
- TContext
334
- > => {
335
- const mutationKey = ['translateDocument']
336
- const { mutation: mutationOptions, request: requestOptions } = options
337
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
338
- ? options
339
- : { ...options, mutation: { ...options.mutation, mutationKey } }
340
- : { mutation: { mutationKey }, request: undefined }
341
-
342
- const mutationFn: MutationFunction<
343
- Awaited<ReturnType<typeof translateDocument>>,
344
- { documentId: string; data: TranslateRequest }
345
- > = (props) => {
346
- const { documentId, data } = props ?? {}
347
-
348
- return translateDocument(documentId, data, requestOptions)
349
- }
350
-
351
- return { mutationFn, ...mutationOptions }
352
- }
353
-
354
- export type TranslateDocumentMutationResult = NonNullable<
355
- Awaited<ReturnType<typeof translateDocument>>
356
- >
357
- export type TranslateDocumentMutationBody = TranslateRequest
358
- export type TranslateDocumentMutationError = ApiError
359
-
360
- export const useTranslateDocument = <TError = ApiError, TContext = unknown>(
361
- options?: {
362
- mutation?: UseMutationOptions<
363
- Awaited<ReturnType<typeof translateDocument>>,
364
- TError,
365
- { documentId: string; data: TranslateRequest },
366
- TContext
367
- >
368
- request?: SecondParameter<typeof fetchApi>
369
- },
370
- queryClient?: QueryClient,
371
- ): UseMutationResult<
372
- Awaited<ReturnType<typeof translateDocument>>,
373
- TError,
374
- { documentId: string; data: TranslateRequest },
375
- TContext
376
- > => {
377
- return useMutation(getTranslateDocumentMutationOptions(options), queryClient)
378
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/regions/regions.ts DELETED
@@ -1,247 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import { useMutation } from '@tanstack/react-query'
7
- import type {
8
- MutationFunction,
9
- QueryClient,
10
- UseMutationOptions,
11
- UseMutationResult,
12
- } from '@tanstack/react-query'
13
-
14
- import { fetchApi } from '.././fetch'
15
- import type {
16
- ApiError,
17
- BrushRegionRequest,
18
- InpaintRegionRequest,
19
- MaskRegionRequest,
20
- } from '../schemas'
21
-
22
- type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1]
23
-
24
- export const getUpdateBrushLayerUrl = (documentId: string) => {
25
- return `/api/v1/documents/${documentId}/brush-layer`
26
- }
27
-
28
- export const updateBrushLayer = async (
29
- documentId: string,
30
- brushRegionRequest: BrushRegionRequest,
31
- options?: RequestInit,
32
- ): Promise<void> => {
33
- return fetchApi<void>(getUpdateBrushLayerUrl(documentId), {
34
- ...options,
35
- method: 'PUT',
36
- headers: { 'Content-Type': 'application/json', ...options?.headers },
37
- body: JSON.stringify(brushRegionRequest),
38
- })
39
- }
40
-
41
- export const getUpdateBrushLayerMutationOptions = <
42
- TError = ApiError,
43
- TContext = unknown,
44
- >(options?: {
45
- mutation?: UseMutationOptions<
46
- Awaited<ReturnType<typeof updateBrushLayer>>,
47
- TError,
48
- { documentId: string; data: BrushRegionRequest },
49
- TContext
50
- >
51
- request?: SecondParameter<typeof fetchApi>
52
- }): UseMutationOptions<
53
- Awaited<ReturnType<typeof updateBrushLayer>>,
54
- TError,
55
- { documentId: string; data: BrushRegionRequest },
56
- TContext
57
- > => {
58
- const mutationKey = ['updateBrushLayer']
59
- const { mutation: mutationOptions, request: requestOptions } = options
60
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
61
- ? options
62
- : { ...options, mutation: { ...options.mutation, mutationKey } }
63
- : { mutation: { mutationKey }, request: undefined }
64
-
65
- const mutationFn: MutationFunction<
66
- Awaited<ReturnType<typeof updateBrushLayer>>,
67
- { documentId: string; data: BrushRegionRequest }
68
- > = (props) => {
69
- const { documentId, data } = props ?? {}
70
-
71
- return updateBrushLayer(documentId, data, requestOptions)
72
- }
73
-
74
- return { mutationFn, ...mutationOptions }
75
- }
76
-
77
- export type UpdateBrushLayerMutationResult = NonNullable<
78
- Awaited<ReturnType<typeof updateBrushLayer>>
79
- >
80
- export type UpdateBrushLayerMutationBody = BrushRegionRequest
81
- export type UpdateBrushLayerMutationError = ApiError
82
-
83
- export const useUpdateBrushLayer = <TError = ApiError, TContext = unknown>(
84
- options?: {
85
- mutation?: UseMutationOptions<
86
- Awaited<ReturnType<typeof updateBrushLayer>>,
87
- TError,
88
- { documentId: string; data: BrushRegionRequest },
89
- TContext
90
- >
91
- request?: SecondParameter<typeof fetchApi>
92
- },
93
- queryClient?: QueryClient,
94
- ): UseMutationResult<
95
- Awaited<ReturnType<typeof updateBrushLayer>>,
96
- TError,
97
- { documentId: string; data: BrushRegionRequest },
98
- TContext
99
- > => {
100
- return useMutation(getUpdateBrushLayerMutationOptions(options), queryClient)
101
- }
102
- export const getInpaintRegionUrl = (documentId: string) => {
103
- return `/api/v1/documents/${documentId}/inpaint-region`
104
- }
105
-
106
- export const inpaintRegion = async (
107
- documentId: string,
108
- inpaintRegionRequest: InpaintRegionRequest,
109
- options?: RequestInit,
110
- ): Promise<void> => {
111
- return fetchApi<void>(getInpaintRegionUrl(documentId), {
112
- ...options,
113
- method: 'POST',
114
- headers: { 'Content-Type': 'application/json', ...options?.headers },
115
- body: JSON.stringify(inpaintRegionRequest),
116
- })
117
- }
118
-
119
- export const getInpaintRegionMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
120
- mutation?: UseMutationOptions<
121
- Awaited<ReturnType<typeof inpaintRegion>>,
122
- TError,
123
- { documentId: string; data: InpaintRegionRequest },
124
- TContext
125
- >
126
- request?: SecondParameter<typeof fetchApi>
127
- }): UseMutationOptions<
128
- Awaited<ReturnType<typeof inpaintRegion>>,
129
- TError,
130
- { documentId: string; data: InpaintRegionRequest },
131
- TContext
132
- > => {
133
- const mutationKey = ['inpaintRegion']
134
- const { mutation: mutationOptions, request: requestOptions } = options
135
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
136
- ? options
137
- : { ...options, mutation: { ...options.mutation, mutationKey } }
138
- : { mutation: { mutationKey }, request: undefined }
139
-
140
- const mutationFn: MutationFunction<
141
- Awaited<ReturnType<typeof inpaintRegion>>,
142
- { documentId: string; data: InpaintRegionRequest }
143
- > = (props) => {
144
- const { documentId, data } = props ?? {}
145
-
146
- return inpaintRegion(documentId, data, requestOptions)
147
- }
148
-
149
- return { mutationFn, ...mutationOptions }
150
- }
151
-
152
- export type InpaintRegionMutationResult = NonNullable<Awaited<ReturnType<typeof inpaintRegion>>>
153
- export type InpaintRegionMutationBody = InpaintRegionRequest
154
- export type InpaintRegionMutationError = ApiError
155
-
156
- export const useInpaintRegion = <TError = ApiError, TContext = unknown>(
157
- options?: {
158
- mutation?: UseMutationOptions<
159
- Awaited<ReturnType<typeof inpaintRegion>>,
160
- TError,
161
- { documentId: string; data: InpaintRegionRequest },
162
- TContext
163
- >
164
- request?: SecondParameter<typeof fetchApi>
165
- },
166
- queryClient?: QueryClient,
167
- ): UseMutationResult<
168
- Awaited<ReturnType<typeof inpaintRegion>>,
169
- TError,
170
- { documentId: string; data: InpaintRegionRequest },
171
- TContext
172
- > => {
173
- return useMutation(getInpaintRegionMutationOptions(options), queryClient)
174
- }
175
- export const getUpdateMaskUrl = (documentId: string) => {
176
- return `/api/v1/documents/${documentId}/mask`
177
- }
178
-
179
- export const updateMask = async (
180
- documentId: string,
181
- maskRegionRequest: MaskRegionRequest,
182
- options?: RequestInit,
183
- ): Promise<void> => {
184
- return fetchApi<void>(getUpdateMaskUrl(documentId), {
185
- ...options,
186
- method: 'PUT',
187
- headers: { 'Content-Type': 'application/json', ...options?.headers },
188
- body: JSON.stringify(maskRegionRequest),
189
- })
190
- }
191
-
192
- export const getUpdateMaskMutationOptions = <TError = ApiError, TContext = unknown>(options?: {
193
- mutation?: UseMutationOptions<
194
- Awaited<ReturnType<typeof updateMask>>,
195
- TError,
196
- { documentId: string; data: MaskRegionRequest },
197
- TContext
198
- >
199
- request?: SecondParameter<typeof fetchApi>
200
- }): UseMutationOptions<
201
- Awaited<ReturnType<typeof updateMask>>,
202
- TError,
203
- { documentId: string; data: MaskRegionRequest },
204
- TContext
205
- > => {
206
- const mutationKey = ['updateMask']
207
- const { mutation: mutationOptions, request: requestOptions } = options
208
- ? options.mutation && 'mutationKey' in options.mutation && options.mutation.mutationKey
209
- ? options
210
- : { ...options, mutation: { ...options.mutation, mutationKey } }
211
- : { mutation: { mutationKey }, request: undefined }
212
-
213
- const mutationFn: MutationFunction<
214
- Awaited<ReturnType<typeof updateMask>>,
215
- { documentId: string; data: MaskRegionRequest }
216
- > = (props) => {
217
- const { documentId, data } = props ?? {}
218
-
219
- return updateMask(documentId, data, requestOptions)
220
- }
221
-
222
- return { mutationFn, ...mutationOptions }
223
- }
224
-
225
- export type UpdateMaskMutationResult = NonNullable<Awaited<ReturnType<typeof updateMask>>>
226
- export type UpdateMaskMutationBody = MaskRegionRequest
227
- export type UpdateMaskMutationError = ApiError
228
-
229
- export const useUpdateMask = <TError = ApiError, TContext = unknown>(
230
- options?: {
231
- mutation?: UseMutationOptions<
232
- Awaited<ReturnType<typeof updateMask>>,
233
- TError,
234
- { documentId: string; data: MaskRegionRequest },
235
- TContext
236
- >
237
- request?: SecondParameter<typeof fetchApi>
238
- },
239
- queryClient?: QueryClient,
240
- ): UseMutationResult<
241
- Awaited<ReturnType<typeof updateMask>>,
242
- TError,
243
- { documentId: string; data: MaskRegionRequest },
244
- TContext
245
- > => {
246
- return useMutation(getUpdateMaskMutationOptions(options), queryClient)
247
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/addImageLayerResponse.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { NodeId } from './nodeId'
7
+
8
+ export interface AddImageLayerResponse {
9
+ node: NodeId
10
+ }
ui/lib/api/schemas/{getConfig200.ts → appConfig.ts} RENAMED
@@ -8,7 +8,7 @@ import type { HttpConfig } from './httpConfig'
8
  import type { PipelineConfig } from './pipelineConfig'
9
  import type { ProviderConfig } from './providerConfig'
10
 
11
- export type GetConfig200 = {
12
  data?: DataConfig
13
  http?: HttpConfig
14
  pipeline?: PipelineConfig
 
8
  import type { PipelineConfig } from './pipelineConfig'
9
  import type { ProviderConfig } from './providerConfig'
10
 
11
+ export interface AppConfig {
12
  data?: DataConfig
13
  http?: HttpConfig
14
  pipeline?: PipelineConfig
ui/lib/api/schemas/appEvent.ts ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { DownloadProgress } from './downloadProgress'
7
+ import type { JobFinishedEvent } from './jobFinishedEvent'
8
+ import type { LlmTarget } from './llmTarget'
9
+ import type { PipelineProgress } from './pipelineProgress'
10
+ import type { SnapshotEvent } from './snapshotEvent'
11
+
12
+ export type AppEvent =
13
+ | {
14
+ event: 'jobStarted'
15
+ id: string
16
+ kind: string
17
+ }
18
+ | (PipelineProgress & {
19
+ event: 'jobProgress'
20
+ })
21
+ | (JobFinishedEvent & {
22
+ event: 'jobFinished'
23
+ })
24
+ | (DownloadProgress & {
25
+ event: 'downloadProgress'
26
+ })
27
+ | {
28
+ event: 'llmLoading'
29
+ target: LlmTarget
30
+ }
31
+ | {
32
+ event: 'llmLoaded'
33
+ target: LlmTarget
34
+ }
35
+ | {
36
+ event: 'llmFailed'
37
+ target?: null | LlmTarget
38
+ }
39
+ | {
40
+ event: 'llmUnloaded'
41
+ }
42
+ | (SnapshotEvent & {
43
+ event: 'snapshot'
44
+ })
ui/lib/api/schemas/blobRef.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ /**
8
+ * Hex-encoded blake3 hash of an immutable blob.
9
+ */
10
+ export type BlobRef = string
ui/lib/api/schemas/configPatch.ts ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { DataConfigPatch } from './dataConfigPatch'
7
+ import type { HttpConfigPatch } from './httpConfigPatch'
8
+ import type { PipelineConfigPatch } from './pipelineConfigPatch'
9
+ import type { ProviderPatch } from './providerPatch'
10
+
11
+ /**
12
+ * Sparse patch for `koharu_app::AppConfig`. Missing fields mean "leave
13
+ as-is". The `providers` field, if present, replaces the whole provider
14
+ list — we do not merge by id because ordering is meaningful.
15
+ */
16
+ export interface ConfigPatch {
17
+ data?: null | DataConfigPatch
18
+ http?: null | HttpConfigPatch
19
+ pipeline?: null | PipelineConfigPatch
20
+ /**
21
+ * If present, replaces the entire list. Api_key values of `"[REDACTED]"`
22
+ are interpreted as "leave the existing secret alone".
23
+ * @nullable
24
+ */
25
+ providers?: ProviderPatch[] | null
26
+ }
ui/lib/api/schemas/createPagesFromPathsRequest.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ export interface CreatePagesFromPathsRequest {
8
+ paths: string[]
9
+ replace?: boolean
10
+ }
ui/lib/api/schemas/createPagesResponse.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { PageId } from './pageId'
7
+
8
+ export interface CreatePagesResponse {
9
+ pages: PageId[]
10
+ }
ui/lib/api/schemas/{importDocumentsBody.ts → createProjectRequest.ts} RENAMED
@@ -4,6 +4,6 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export type ImportDocumentsBody = {
8
- files: Blob[]
9
  }
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export interface CreateProjectRequest {
8
+ name: string
9
  }
ui/lib/api/schemas/{updateDocumentStyleRequest.ts → dataConfigPatch.ts} RENAMED
@@ -4,7 +4,7 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export interface UpdateDocumentStyleRequest {
8
  /** @nullable */
9
- defaultFont?: string | null
10
  }
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export interface DataConfigPatch {
8
  /** @nullable */
9
+ path?: string | null
10
  }
ui/lib/api/schemas/documentDetail.ts DELETED
@@ -1,40 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { DocumentStyle } from './documentStyle'
7
- import type { TextBlockDetail } from './textBlockDetail'
8
-
9
- export interface DocumentDetail {
10
- /**
11
- * Blob hash for the brush layer.
12
- * @nullable
13
- */
14
- brushLayer?: string | null
15
- /** @minimum 0 */
16
- height: number
17
- id: string
18
- /** Blob hash for the source image layer. */
19
- image: string
20
- /**
21
- * Blob hash for the inpainted layer.
22
- * @nullable
23
- */
24
- inpainted?: string | null
25
- name: string
26
- /**
27
- * Blob hash for the rendered composite layer.
28
- * @nullable
29
- */
30
- rendered?: string | null
31
- /**
32
- * Blob hash for the segmentation mask layer.
33
- * @nullable
34
- */
35
- segment?: string | null
36
- style?: null | DocumentStyle
37
- textBlocks: TextBlockDetail[]
38
- /** @minimum 0 */
39
- width: number
40
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/{downloadState.ts → downloadProgress.ts} RENAMED
@@ -3,16 +3,14 @@
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
- import type { TransferStatus } from './transferStatus'
7
 
8
- export interface DownloadState {
9
  /** @minimum 0 */
10
  downloaded: number
11
- /** @nullable */
12
- error?: string | null
13
  filename: string
14
  id: string
15
- status: TransferStatus
16
  /**
17
  * @minimum 0
18
  * @nullable
 
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
+ import type { DownloadStatus } from './downloadStatus'
7
 
8
+ export interface DownloadProgress {
9
  /** @minimum 0 */
10
  downloaded: number
 
 
11
  filename: string
12
  id: string
13
+ status: DownloadStatus
14
  /**
15
  * @minimum 0
16
  * @nullable
ui/lib/api/schemas/downloadStatus.ts ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ export type DownloadStatus =
8
+ | {
9
+ status: 'started'
10
+ }
11
+ | {
12
+ status: 'downloading'
13
+ }
14
+ | {
15
+ status: 'completed'
16
+ }
17
+ | {
18
+ reason: string
19
+ status: 'failed'
20
+ }
ui/lib/api/schemas/{getEngineCatalog200.ts → engineCatalog.ts} RENAMED
@@ -5,7 +5,8 @@
5
  */
6
  import type { EngineCatalogEntry } from './engineCatalogEntry'
7
 
8
- export type GetEngineCatalog200 = {
 
9
  detectors: EngineCatalogEntry[]
10
  fontDetectors: EngineCatalogEntry[]
11
  inpainters: EngineCatalogEntry[]
 
5
  */
6
  import type { EngineCatalogEntry } from './engineCatalogEntry'
7
 
8
+ export interface EngineCatalog {
9
+ bubbleSegmenters: EngineCatalogEntry[]
10
  detectors: EngineCatalogEntry[]
11
  fontDetectors: EngineCatalogEntry[]
12
  inpainters: EngineCatalogEntry[]
ui/lib/api/schemas/{apiError.ts → errorEvent.ts} RENAMED
@@ -4,8 +4,7 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export interface ApiError {
8
  message: string
9
- /** @minimum 0 */
10
- status: number
11
  }
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export interface ErrorEvent {
8
  message: string
9
+ scope: string
 
10
  }
ui/lib/api/schemas/exportBatchRequest.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { ExportLayer } from './exportLayer'
7
-
8
- export interface ExportBatchRequest {
9
- layer?: null | ExportLayer
10
- }
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/exportDocumentParams.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { ExportLayer } from './exportLayer'
7
-
8
- export type ExportDocumentParams = {
9
- layer?: null | ExportLayer
10
- }
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/{exportLayer.ts → exportFormat.ts} RENAMED
@@ -4,9 +4,11 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export type ExportLayer = (typeof ExportLayer)[keyof typeof ExportLayer]
8
 
9
- export const ExportLayer = {
 
 
10
  rendered: 'rendered',
11
  inpainted: 'inpainted',
12
  } as const
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export type ExportFormat = (typeof ExportFormat)[keyof typeof ExportFormat]
8
 
9
+ export const ExportFormat = {
10
+ khr: 'khr',
11
+ psd: 'psd',
12
  rendered: 'rendered',
13
  inpainted: 'inpainted',
14
  } as const
ui/lib/api/schemas/exportProjectRequest.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { ExportFormat } from './exportFormat'
7
+ import type { PageId } from './pageId'
8
+
9
+ export interface ExportProjectRequest {
10
+ format: ExportFormat
11
+ /**
12
+ * Optional subset of pages; defaults to every page.
13
+ * @nullable
14
+ */
15
+ pages?: PageId[] | null
16
+ }
ui/lib/api/schemas/fontPrediction.ts CHANGED
@@ -8,13 +8,13 @@ import type { TextDirection } from './textDirection'
8
  import type { TopFont } from './topFont'
9
 
10
  export interface FontPrediction {
11
- angle_deg: number
12
  direction: TextDirection
13
- font_size_px: number
14
- line_height: number
15
- named_fonts: NamedFontPrediction[]
16
- stroke_color: number[]
17
- stroke_width_px: number
18
- text_color: number[]
19
- top_fonts: TopFont[]
20
  }
 
8
  import type { TopFont } from './topFont'
9
 
10
  export interface FontPrediction {
11
+ angleDeg: number
12
  direction: TextDirection
13
+ fontSizePx: number
14
+ lineHeight: number
15
+ namedFonts: NamedFontPrediction[]
16
+ strokeColor: number[]
17
+ strokeWidthPx: number
18
+ textColor: number[]
19
+ topFonts: TopFont[]
20
  }
ui/lib/api/schemas/getLlmCatalogParams.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Generated by orval v8.6.2 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
-
7
- export type GetLlmCatalogParams = {
8
- /**
9
- * @nullable
10
- */
11
- language?: string | null
12
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/googleFontCatalog.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { GoogleFontEntry } from './googleFontEntry'
7
+
8
+ export interface GoogleFontCatalog {
9
+ fonts: GoogleFontEntry[]
10
+ }
ui/lib/api/schemas/googleFontCatalogResponse.ts DELETED
@@ -1,11 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { GoogleFontCatalogEntry } from './googleFontCatalogEntry'
7
-
8
- export interface GoogleFontCatalogResponse {
9
- fonts: GoogleFontCatalogEntry[]
10
- recommended: string[]
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/{googleFontCatalogEntry.ts → googleFontEntry.ts} RENAMED
@@ -3,10 +3,11 @@
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
 
6
 
7
- export interface GoogleFontCatalogEntry {
8
- cached: boolean
9
  category: string
10
  family: string
11
  subsets: string[]
 
12
  }
 
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
+ import type { GoogleFontVariant } from './googleFontVariant'
7
 
8
+ export interface GoogleFontEntry {
 
9
  category: string
10
  family: string
11
  subsets: string[]
12
+ variants: GoogleFontVariant[]
13
  }
ui/lib/api/schemas/googleFontVariant.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ export interface GoogleFontVariant {
8
+ filename: string
9
+ style: string
10
+ /** @minimum 0 */
11
+ weight: number
12
+ }
ui/lib/api/schemas/{getDocumentThumbnailParams.ts → historyResult.ts} RENAMED
@@ -4,10 +4,11 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export type GetDocumentThumbnailParams = {
8
  /**
 
9
  * @minimum 0
10
  * @nullable
11
  */
12
- size?: number | null
13
  }
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export interface HistoryResult {
8
  /**
9
+ * New epoch. `None` only for a no-op undo/redo at the stack boundary.
10
  * @minimum 0
11
  * @nullable
12
  */
13
+ epoch?: number | null
14
  }
ui/lib/api/schemas/httpConfigPatch.ts ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ export interface HttpConfigPatch {
8
+ /**
9
+ * @minimum 0
10
+ * @nullable
11
+ */
12
+ connectTimeout?: number | null
13
+ /**
14
+ * @minimum 0
15
+ * @nullable
16
+ */
17
+ maxRetries?: number | null
18
+ /**
19
+ * @minimum 0
20
+ * @nullable
21
+ */
22
+ readTimeout?: number | null
23
+ }
ui/lib/api/schemas/imageData.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { BlobRef } from './blobRef'
7
+ import type { ImageRole } from './imageRole'
8
+
9
+ export interface ImageData {
10
+ blob: BlobRef
11
+ /** @nullable */
12
+ name?: string | null
13
+ /** @minimum 0 */
14
+ naturalHeight: number
15
+ /** @minimum 0 */
16
+ naturalWidth: number
17
+ opacity?: number
18
+ /** Role tags differentiate source / inpainted / rendered / user-imported images.
19
+ Role is immutable on an existing node — switching roles = delete + add. */
20
+ role: ImageRole
21
+ }
ui/lib/api/schemas/{textBlockInput.ts → imageDataPatch.ts} RENAMED
@@ -3,18 +3,22 @@
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
- import type { TextStyle } from './textStyle'
7
 
8
- export interface TextBlockInput {
9
- height: number
10
  /** @nullable */
11
- id?: string | null
12
- style?: null | TextStyle
 
 
 
 
 
 
 
 
 
13
  /** @nullable */
14
- text?: string | null
15
- /** @nullable */
16
- translation?: string | null
17
- width: number
18
- x: number
19
- y: number
20
  }
 
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
+ import type { BlobRef } from './blobRef'
7
 
8
+ export interface ImageDataPatch {
9
+ blob?: null | BlobRef
10
  /** @nullable */
11
+ name?: string | null
12
+ /**
13
+ * @minimum 0
14
+ * @nullable
15
+ */
16
+ naturalHeight?: number | null
17
+ /**
18
+ * @minimum 0
19
+ * @nullable
20
+ */
21
+ naturalWidth?: number | null
22
  /** @nullable */
23
+ opacity?: number | null
 
 
 
 
 
24
  }
ui/lib/api/schemas/{transferStatus.ts → imageRole.ts} RENAMED
@@ -4,11 +4,11 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export type TransferStatus = (typeof TransferStatus)[keyof typeof TransferStatus]
8
 
9
- export const TransferStatus = {
10
- started: 'started',
11
- downloading: 'downloading',
12
- completed: 'completed',
13
- failed: 'failed',
14
  } as const
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export type ImageRole = (typeof ImageRole)[keyof typeof ImageRole]
8
 
9
+ export const ImageRole = {
10
+ source: 'source',
11
+ inpainted: 'inpainted',
12
+ rendered: 'rendered',
13
+ custom: 'custom',
14
  } as const
ui/lib/api/schemas/importDocumentsParams.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { ImportMode } from './importMode'
7
-
8
- export type ImportDocumentsParams = {
9
- mode?: null | ImportMode
10
- }
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/importProjectParams.ts ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+
7
+ export type ImportProjectParams = {
8
+ /**
9
+ * Optional absolute destination path for the extracted `.khrproj/`
10
+ directory. When omitted, the server allocates a directory under
11
+ `{data.path}/projects/` using a timestamp-and-random suffix. Must not
12
+ already exist when provided.
13
+ * @nullable
14
+ */
15
+ path?: string | null
16
+ }
ui/lib/api/schemas/index.ts CHANGED
@@ -4,35 +4,40 @@
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
- export * from './apiError'
8
- export * from './brushRegionRequest'
9
- export * from './createTextBlock'
 
 
 
 
 
10
  export * from './dataConfig'
11
- export * from './documentDetail'
12
- export * from './documentStyle'
13
- export * from './documentSummary'
14
- export * from './downloadState'
15
  export * from './engineCatalogEntry'
16
- export * from './exportBatchRequest'
17
- export * from './exportDocumentParams'
18
- export * from './exportLayer'
19
- export * from './exportResult'
20
  export * from './fontFaceInfo'
21
  export * from './fontPrediction'
22
  export * from './fontSource'
23
- export * from './getConfig200'
24
- export * from './getDocumentThumbnailParams'
25
- export * from './getEngineCatalog200'
26
- export * from './googleFontCatalogEntry'
27
- export * from './googleFontCatalogResponse'
28
  export * from './httpConfig'
29
- export * from './importDocumentsBody'
30
- export * from './importDocumentsParams'
31
- export * from './importMode'
32
- export * from './importResult'
33
- export * from './inpaintRegionRequest'
34
- export * from './jobState'
35
  export * from './jobStatus'
 
 
 
 
36
  export * from './llmCatalog'
37
  export * from './llmCatalogModel'
38
  export * from './llmGenerationOptions'
@@ -43,27 +48,50 @@ export * from './llmState'
43
  export * from './llmStateStatus'
44
  export * from './llmTarget'
45
  export * from './llmTargetKind'
46
- export * from './maskRegionRequest'
 
 
47
  export * from './metaInfo'
48
  export * from './namedFontPrediction'
 
 
 
 
 
 
 
 
 
 
 
49
  export * from './pipelineConfig'
50
- export * from './pipelineJobRequest'
51
- export * from './pipelineLlmRequest'
 
 
 
 
 
 
52
  export * from './providerConfig'
 
 
 
53
  export * from './region'
54
- export * from './renderRequest'
55
- export * from './reorderRequest'
 
 
 
 
 
 
56
  export * from './textAlign'
57
- export * from './textBlockDetail'
58
- export * from './textBlockInput'
59
- export * from './textBlockPatch'
60
  export * from './textDirection'
61
  export * from './textShaderEffect'
62
  export * from './textStrokeStyle'
63
  export * from './textStyle'
64
  export * from './topFont'
65
- export * from './transferStatus'
66
- export * from './translateRequest'
67
- export * from './updateConfig200'
68
- export * from './updateConfigBody'
69
- export * from './updateDocumentStyleRequest'
 
4
  * OpenAPI spec version: 0.0.1
5
  */
6
 
7
+ export * from './addImageLayerResponse'
8
+ export * from './appConfig'
9
+ export * from './appEvent'
10
+ export * from './blobRef'
11
+ export * from './configPatch'
12
+ export * from './createPagesFromPathsRequest'
13
+ export * from './createPagesResponse'
14
+ export * from './createProjectRequest'
15
  export * from './dataConfig'
16
+ export * from './dataConfigPatch'
17
+ export * from './downloadProgress'
18
+ export * from './downloadStatus'
19
+ export * from './engineCatalog'
20
  export * from './engineCatalogEntry'
21
+ export * from './exportFormat'
22
+ export * from './exportProjectRequest'
 
 
23
  export * from './fontFaceInfo'
24
  export * from './fontPrediction'
25
  export * from './fontSource'
26
+ export * from './googleFontCatalog'
27
+ export * from './googleFontEntry'
28
+ export * from './googleFontVariant'
29
+ export * from './historyResult'
 
30
  export * from './httpConfig'
31
+ export * from './httpConfigPatch'
32
+ export * from './imageData'
33
+ export * from './imageDataPatch'
34
+ export * from './imageRole'
35
+ export * from './jobFinishedEvent'
 
36
  export * from './jobStatus'
37
+ export * from './jobSummary'
38
+ export * from './listDownloadsResponse'
39
+ export * from './listOperationsResponse'
40
+ export * from './listProjectsResponse'
41
  export * from './llmCatalog'
42
  export * from './llmCatalogModel'
43
  export * from './llmGenerationOptions'
 
48
  export * from './llmStateStatus'
49
  export * from './llmTarget'
50
  export * from './llmTargetKind'
51
+ export * from './maskData'
52
+ export * from './maskDataPatch'
53
+ export * from './maskRole'
54
  export * from './metaInfo'
55
  export * from './namedFontPrediction'
56
+ export * from './node'
57
+ export * from './nodeDataPatch'
58
+ export * from './nodeId'
59
+ export * from './nodeKind'
60
+ export * from './nodePatch'
61
+ export * from './op'
62
+ export * from './openProjectRequest'
63
+ export * from './page'
64
+ export * from './pageId'
65
+ export * from './pageNodes'
66
+ export * from './pagePatch'
67
  export * from './pipelineConfig'
68
+ export * from './pipelineConfigPatch'
69
+ export * from './pipelineProgress'
70
+ export * from './pipelineStatus'
71
+ export * from './pipelineStep'
72
+ export * from './projectMeta'
73
+ export * from './projectMetaPatch'
74
+ export * from './projectStyle'
75
+ export * from './projectSummary'
76
  export * from './providerConfig'
77
+ export * from './providerPatch'
78
+ export * from './providerSecretRequest'
79
+ export * from './putMaskResponse'
80
  export * from './region'
81
+ export * from './scene'
82
+ export * from './scenePages'
83
+ export * from './sceneSnapshot'
84
+ export * from './snapshotEvent'
85
+ export * from './startDownloadRequest'
86
+ export * from './startDownloadResponse'
87
+ export * from './startPipelineRequest'
88
+ export * from './startPipelineResponse'
89
  export * from './textAlign'
90
+ export * from './textData'
91
+ export * from './textDataPatch'
 
92
  export * from './textDirection'
93
  export * from './textShaderEffect'
94
  export * from './textStrokeStyle'
95
  export * from './textStyle'
96
  export * from './topFont'
97
+ export * from './transform'
 
 
 
 
ui/lib/api/schemas/inpaintRegionRequest.ts DELETED
@@ -1,10 +0,0 @@
1
- /**
2
- * Generated by orval v8.8.0 🍺
3
- * Do not edit manually.
4
- * OpenAPI spec version: 0.0.1
5
- */
6
- import type { Region } from './region'
7
-
8
- export interface InpaintRegionRequest {
9
- region: Region
10
- }
 
 
 
 
 
 
 
 
 
 
 
ui/lib/api/schemas/jobFinishedEvent.ts ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { JobStatus } from './jobStatus'
7
+
8
+ export interface JobFinishedEvent {
9
+ /** @nullable */
10
+ error?: string | null
11
+ id: string
12
+ status: JobStatus
13
+ }
ui/lib/api/schemas/jobSummary.ts ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { JobStatus } from './jobStatus'
7
+
8
+ export interface JobSummary {
9
+ /** @nullable */
10
+ error?: string | null
11
+ id: string
12
+ kind: string
13
+ status: JobStatus
14
+ }
ui/lib/api/schemas/listDownloadsResponse.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { DownloadProgress } from './downloadProgress'
7
+
8
+ export interface ListDownloadsResponse {
9
+ downloads: DownloadProgress[]
10
+ }
ui/lib/api/schemas/{brushRegionRequest.ts → listOperationsResponse.ts} RENAMED
@@ -3,9 +3,8 @@
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
- import type { Region } from './region'
7
 
8
- export interface BrushRegionRequest {
9
- data: number[]
10
- region: Region
11
  }
 
3
  * Do not edit manually.
4
  * OpenAPI spec version: 0.0.1
5
  */
6
+ import type { JobSummary } from './jobSummary'
7
 
8
+ export interface ListOperationsResponse {
9
+ operations: JobSummary[]
 
10
  }
ui/lib/api/schemas/listProjectsResponse.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { ProjectSummary } from './projectSummary'
7
+
8
+ export interface ListProjectsResponse {
9
+ projects: ProjectSummary[]
10
+ }
ui/lib/api/schemas/maskData.ts ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Generated by orval v8.8.0 🍺
3
+ * Do not edit manually.
4
+ * OpenAPI spec version: 0.0.1
5
+ */
6
+ import type { BlobRef } from './blobRef'
7
+ import type { MaskRole } from './maskRole'
8
+
9
+ export interface MaskData {
10
+ blob: BlobRef
11
+ role: MaskRole
12
+ }