Download ui/lib/api/default/default.msw.ts from Jadewave/trans2: direct link, hf CLI and curl.
- Browser
- Download file 69.7 kB
-
https://huggingface.co/spaces/Jadewave/trans2/resolve/main/ui/lib/api/default/default.msw.ts
- Command line
-
hf download hf://spaces/Jadewave/trans2/ui/lib/api/default/default.msw.ts
-
curl -L -o default.msw.ts https://huggingface.co/spaces/Jadewave/trans2/resolve/main/ui/lib/api/default/default.msw.ts
69.7 kB
| /** | |
| * Generated by orval v8.8.1 🍺 | |
| * Do not edit manually. | |
| * OpenAPI spec version: 0.0.1 | |
| */ | |
| import { faker } from '@faker-js/faker' | |
| import { HttpResponse, delay, http } from 'msw' | |
| import type { RequestHandlerOptions } from 'msw' | |
| import { | |
| CodexAuthAttemptStatus, | |
| FontSource, | |
| ImageRole, | |
| JobStatus, | |
| LlmProviderCatalogStatus, | |
| LlmStateStatus, | |
| LlmTargetKind, | |
| MaskRole, | |
| PipelineStep, | |
| TextAlign, | |
| TextDirection, | |
| } from '../schemas' | |
| import type { | |
| AddImageLayerResponse, | |
| AppConfig, | |
| AppEvent, | |
| CodexAuthStatus, | |
| CodexDeviceLogin, | |
| CodexDeviceLoginStatus, | |
| CodexImageGenerationResponse, | |
| CreatePagesResponse, | |
| DataConfig, | |
| EngineCatalog, | |
| FontFaceInfo, | |
| FontPrediction, | |
| GoogleFontCatalog, | |
| HistoryResult, | |
| HttpConfig, | |
| ListDownloadsResponse, | |
| ListOperationsResponse, | |
| ListProjectsResponse, | |
| LlmCatalog, | |
| LlmState, | |
| LlmTarget, | |
| MetaInfo, | |
| PipelineConfig, | |
| ProjectSummary, | |
| PutMaskResponse, | |
| SceneSnapshot, | |
| StartDownloadResponse, | |
| StartPipelineResponse, | |
| TextShaderEffect, | |
| TextStrokeStyle, | |
| TextStyle, | |
| Transform, | |
| } from '../schemas' | |
| export const getStartCodexDeviceLoginResponseMock = ( | |
| overrideResponse: Partial<Extract<CodexDeviceLogin, object>> = {}, | |
| ): CodexDeviceLogin => ({ | |
| intervalSeconds: faker.number.int({ min: 0 }), | |
| loginId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| timeoutSeconds: faker.number.int({ min: 0 }), | |
| userCode: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| verificationUrl: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ...overrideResponse, | |
| }) | |
| export const getGetCodexAuthStatusResponseCodexDeviceLoginStatusMock = ( | |
| overrideResponse: Partial<CodexDeviceLoginStatus> = {}, | |
| ): CodexDeviceLoginStatus => ({ | |
| ...{ | |
| accountId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| loginId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(Object.values(CodexAuthAttemptStatus)), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetCodexAuthStatusResponseMock = ( | |
| overrideResponse: Partial<Extract<CodexAuthStatus, object>> = {}, | |
| ): CodexAuthStatus => ({ | |
| accountId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| login: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| { ...getGetCodexAuthStatusResponseCodexDeviceLoginStatusMock() }, | |
| ]), | |
| undefined, | |
| ]), | |
| signedIn: faker.datatype.boolean(), | |
| ...overrideResponse, | |
| }) | |
| export const getStartCodexImageGenerationResponseMock = ( | |
| overrideResponse: Partial<Extract<CodexImageGenerationResponse, object>> = {}, | |
| ): CodexImageGenerationResponse => ({ | |
| operationId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ...overrideResponse, | |
| }) | |
| export const getGetBlobResponseMock = (): ArrayBuffer => | |
| new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) | |
| export const getGetConfigResponseDataConfigMock = ( | |
| overrideResponse: Partial<DataConfig> = {}, | |
| ): DataConfig => ({ | |
| ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetConfigResponseHttpConfigMock = ( | |
| overrideResponse: Partial<HttpConfig> = {}, | |
| ): HttpConfig => ({ | |
| ...{ | |
| connect_timeout: faker.number.int({ min: 0 }), | |
| max_retries: faker.number.int({ min: 0 }), | |
| read_timeout: faker.number.int({ min: 0 }), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetConfigResponsePipelineConfigMock = ( | |
| overrideResponse: Partial<PipelineConfig> = {}, | |
| ): PipelineConfig => ({ | |
| ...{ | |
| bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| detector: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ocr: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| renderer: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| translator: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetConfigResponseMock = ( | |
| overrideResponse: Partial<Extract<AppConfig, object>> = {}, | |
| ): AppConfig => ({ | |
| data: faker.helpers.arrayElement([{ ...getGetConfigResponseDataConfigMock() }]), | |
| http: faker.helpers.arrayElement([{ ...getGetConfigResponseHttpConfigMock() }]), | |
| pipeline: faker.helpers.arrayElement([{ ...getGetConfigResponsePipelineConfigMock() }]), | |
| providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| api_key: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| base_url: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getPatchConfigResponseDataConfigMock = ( | |
| overrideResponse: Partial<DataConfig> = {}, | |
| ): DataConfig => ({ | |
| ...{ path: faker.string.alpha({ length: { min: 10, max: 20 } }) }, | |
| ...overrideResponse, | |
| }) | |
| export const getPatchConfigResponseHttpConfigMock = ( | |
| overrideResponse: Partial<HttpConfig> = {}, | |
| ): HttpConfig => ({ | |
| ...{ | |
| connect_timeout: faker.number.int({ min: 0 }), | |
| max_retries: faker.number.int({ min: 0 }), | |
| read_timeout: faker.number.int({ min: 0 }), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getPatchConfigResponsePipelineConfigMock = ( | |
| overrideResponse: Partial<PipelineConfig> = {}, | |
| ): PipelineConfig => ({ | |
| ...{ | |
| bubble_segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| detector: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| font_detector: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| inpainter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ocr: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| renderer: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| segmenter: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| translator: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getPatchConfigResponseMock = ( | |
| overrideResponse: Partial<Extract<AppConfig, object>> = {}, | |
| ): AppConfig => ({ | |
| data: faker.helpers.arrayElement([{ ...getPatchConfigResponseDataConfigMock() }]), | |
| http: faker.helpers.arrayElement([{ ...getPatchConfigResponseHttpConfigMock() }]), | |
| pipeline: faker.helpers.arrayElement([{ ...getPatchConfigResponsePipelineConfigMock() }]), | |
| providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| api_key: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| base_url: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getListDownloadsResponseMock = ( | |
| overrideResponse: Partial<Extract<ListDownloadsResponse, object>> = {}, | |
| ): ListDownloadsResponse => ({ | |
| downloads: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| downloaded: faker.number.int({ min: 0 }), | |
| filename: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement([ | |
| { status: faker.helpers.arrayElement(['started'] as const) }, | |
| { status: faker.helpers.arrayElement(['downloading'] as const) }, | |
| { status: faker.helpers.arrayElement(['completed'] as const) }, | |
| { | |
| reason: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(['failed'] as const), | |
| }, | |
| ]), | |
| total: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getStartDownloadResponseMock = ( | |
| overrideResponse: Partial<Extract<StartDownloadResponse, object>> = {}, | |
| ): StartDownloadResponse => ({ | |
| operationId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ...overrideResponse, | |
| }) | |
| export const getGetEngineCatalogResponseMock = ( | |
| overrideResponse: Partial<Extract<EngineCatalog, object>> = {}, | |
| ): EngineCatalog => ({ | |
| bubbleSegmenters: Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| })), | |
| detectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| fontDetectors: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| inpainters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| ocr: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| })), | |
| renderers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| segmenters: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| translators: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| produces: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getEventsResponseLlmTargetMock = ( | |
| overrideResponse: Partial<LlmTarget> = {}, | |
| ): LlmTarget => ({ | |
| ...{ | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getEventsResponseMock = (): AppEvent => | |
| faker.helpers.arrayElement([ | |
| { | |
| event: faker.helpers.arrayElement(['jobStarted'] as const), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| kind: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| }, | |
| { | |
| ...{ | |
| currentPage: faker.number.int({ min: 0 }), | |
| currentStepIndex: faker.number.int({ min: 0 }), | |
| jobId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| overallPercent: faker.number.int({ min: 0 }), | |
| status: faker.helpers.arrayElement([ | |
| { status: faker.helpers.arrayElement(['running'] as const) }, | |
| { status: faker.helpers.arrayElement(['completed'] as const) }, | |
| { status: faker.helpers.arrayElement(['cancelled'] as const) }, | |
| { | |
| reason: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(['failed'] as const), | |
| }, | |
| ]), | |
| step: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| faker.helpers.arrayElement(Object.values(PipelineStep)), | |
| ]), | |
| undefined, | |
| ]), | |
| totalPages: faker.number.int({ min: 0 }), | |
| totalSteps: faker.number.int({ min: 0 }), | |
| }, | |
| ...{ event: faker.helpers.arrayElement(['jobProgress'] as const) }, | |
| }, | |
| { | |
| ...{ | |
| jobId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| message: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| pageIndex: faker.number.int({ min: 0 }), | |
| stepId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| totalPages: faker.number.int({ min: 0 }), | |
| }, | |
| ...{ event: faker.helpers.arrayElement(['jobWarning'] as const) }, | |
| }, | |
| { | |
| ...{ | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(Object.values(JobStatus)), | |
| }, | |
| ...{ event: faker.helpers.arrayElement(['jobFinished'] as const) }, | |
| }, | |
| { | |
| ...{ | |
| downloaded: faker.number.int({ min: 0 }), | |
| filename: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement([ | |
| { status: faker.helpers.arrayElement(['started'] as const) }, | |
| { status: faker.helpers.arrayElement(['downloading'] as const) }, | |
| { status: faker.helpers.arrayElement(['completed'] as const) }, | |
| { | |
| reason: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(['failed'] as const), | |
| }, | |
| ]), | |
| total: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| ...{ event: faker.helpers.arrayElement(['downloadProgress'] as const) }, | |
| }, | |
| { | |
| event: faker.helpers.arrayElement(['llmLoading'] as const), | |
| target: { | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| }, | |
| { | |
| event: faker.helpers.arrayElement(['llmLoaded'] as const), | |
| target: { | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| }, | |
| { | |
| event: faker.helpers.arrayElement(['llmFailed'] as const), | |
| target: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([null, { ...getEventsResponseLlmTargetMock() }]), | |
| undefined, | |
| ]), | |
| }, | |
| { event: faker.helpers.arrayElement(['llmUnloaded'] as const) }, | |
| { | |
| ...{ | |
| downloads: Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => ({ | |
| downloaded: faker.number.int({ min: 0 }), | |
| filename: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement([ | |
| { status: faker.helpers.arrayElement(['started'] as const) }, | |
| { status: faker.helpers.arrayElement(['downloading'] as const) }, | |
| { status: faker.helpers.arrayElement(['completed'] as const) }, | |
| { | |
| reason: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(['failed'] as const), | |
| }, | |
| ]), | |
| total: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| })), | |
| jobs: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| kind: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(Object.values(JobStatus)), | |
| }), | |
| ), | |
| }, | |
| ...{ event: faker.helpers.arrayElement(['snapshot'] as const) }, | |
| }, | |
| ]) | |
| export const getListFontsResponseMock = (): FontFaceInfo[] => | |
| Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | |
| cached: faker.datatype.boolean(), | |
| category: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| familyName: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| postScriptName: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| source: faker.helpers.arrayElement(Object.values(FontSource)), | |
| })) | |
| export const getGetGoogleFontsCatalogResponseMock = ( | |
| overrideResponse: Partial<Extract<GoogleFontCatalog, object>> = {}, | |
| ): GoogleFontCatalog => ({ | |
| fonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => ({ | |
| category: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| family: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| subsets: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| variants: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| filename: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| style: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| weight: faker.number.int({ min: 0 }), | |
| }), | |
| ), | |
| })), | |
| ...overrideResponse, | |
| }) | |
| export const getGetGoogleFontFileResponseMock = (): ArrayBuffer => | |
| new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) | |
| export const getApplyCommandResponseMock = ( | |
| overrideResponse: Partial<Extract<HistoryResult, object>> = {}, | |
| ): HistoryResult => ({ | |
| epoch: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| ...overrideResponse, | |
| }) | |
| export const getRedoResponseMock = ( | |
| overrideResponse: Partial<Extract<HistoryResult, object>> = {}, | |
| ): HistoryResult => ({ | |
| epoch: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| ...overrideResponse, | |
| }) | |
| export const getUndoResponseMock = ( | |
| overrideResponse: Partial<Extract<HistoryResult, object>> = {}, | |
| ): HistoryResult => ({ | |
| epoch: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.int({ min: 0 }), null]), | |
| undefined, | |
| ]), | |
| ...overrideResponse, | |
| }) | |
| export const getGetCatalogResponseMock = ( | |
| overrideResponse: Partial<Extract<LlmCatalog, object>> = {}, | |
| ): LlmCatalog => ({ | |
| localModels: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| languages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| target: { | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| }), | |
| ), | |
| providers: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| baseUrl: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| hasApiKey: faker.datatype.boolean(), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| models: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| languages: Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| target: { | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| }, | |
| }), | |
| ), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| requiresApiKey: faker.datatype.boolean(), | |
| requiresBaseUrl: faker.datatype.boolean(), | |
| status: faker.helpers.arrayElement(Object.values(LlmProviderCatalogStatus)), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getGetCurrentLlmResponseLlmTargetMock = ( | |
| overrideResponse: Partial<LlmTarget> = {}, | |
| ): LlmTarget => ({ | |
| ...{ | |
| kind: faker.helpers.arrayElement(Object.values(LlmTargetKind)), | |
| modelId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| providerId: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetCurrentLlmResponseMock = ( | |
| overrideResponse: Partial<Extract<LlmState, object>> = {}, | |
| ): LlmState => ({ | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| status: faker.helpers.arrayElement(Object.values(LlmStateStatus)), | |
| target: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([null, { ...getGetCurrentLlmResponseLlmTargetMock() }]), | |
| undefined, | |
| ]), | |
| ...overrideResponse, | |
| }) | |
| export const getGetMetaResponseMock = ( | |
| overrideResponse: Partial<Extract<MetaInfo, object>> = {}, | |
| ): MetaInfo => ({ | |
| mlDevice: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| version: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ...overrideResponse, | |
| }) | |
| export const getListOperationsResponseMock = ( | |
| overrideResponse: Partial<Extract<ListOperationsResponse, object>> = {}, | |
| ): ListOperationsResponse => ({ | |
| operations: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| error: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| kind: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| status: faker.helpers.arrayElement(Object.values(JobStatus)), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getCreatePagesResponseMock = ( | |
| overrideResponse: Partial<Extract<CreatePagesResponse, object>> = {}, | |
| ): CreatePagesResponse => ({ | |
| pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => | |
| faker.string.uuid(), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getCreatePagesFromPathsResponseMock = ( | |
| overrideResponse: Partial<Extract<CreatePagesResponse, object>> = {}, | |
| ): CreatePagesResponse => ({ | |
| pages: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => | |
| faker.string.uuid(), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getAddImageLayerResponseMock = ( | |
| overrideResponse: Partial<Extract<AddImageLayerResponse, object>> = {}, | |
| ): AddImageLayerResponse => ({ node: faker.string.uuid(), ...overrideResponse }) | |
| export const getPutMaskResponseMock = ( | |
| overrideResponse: Partial<Extract<PutMaskResponse, object>> = {}, | |
| ): PutMaskResponse => ({ | |
| blob: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| node: faker.string.uuid(), | |
| ...overrideResponse, | |
| }) | |
| export const getGetPageThumbnailResponseMock = (): ArrayBuffer => | |
| new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) | |
| export const getStartPipelineResponseMock = ( | |
| overrideResponse: Partial<Extract<StartPipelineResponse, object>> = {}, | |
| ): StartPipelineResponse => ({ | |
| operationId: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ...overrideResponse, | |
| }) | |
| export const getListProjectsResponseMock = ( | |
| overrideResponse: Partial<Extract<ListProjectsResponse, object>> = {}, | |
| ): ListProjectsResponse => ({ | |
| projects: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| path: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), | |
| }), | |
| ), | |
| ...overrideResponse, | |
| }) | |
| export const getCreateProjectResponseMock = ( | |
| overrideResponse: Partial<Extract<ProjectSummary, object>> = {}, | |
| ): ProjectSummary => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| path: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), | |
| ...overrideResponse, | |
| }) | |
| export const getPutCurrentProjectResponseMock = ( | |
| overrideResponse: Partial<Extract<ProjectSummary, object>> = {}, | |
| ): ProjectSummary => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| path: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), | |
| ...overrideResponse, | |
| }) | |
| export const getExportCurrentProjectResponseMock = (): ArrayBuffer => | |
| new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) | |
| export const getImportProjectResponseMock = ( | |
| overrideResponse: Partial<Extract<ProjectSummary, object>> = {}, | |
| ): ProjectSummary => ({ | |
| id: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| path: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| updatedAtMs: faker.helpers.arrayElement([faker.number.int({ min: 0 }), undefined]), | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneBinResponseMock = (): ArrayBuffer => | |
| new ArrayBuffer(faker.number.int({ min: 1, max: 64 })) | |
| export const getGetSceneJsonResponseFontPredictionMock = ( | |
| overrideResponse: Partial<FontPrediction> = {}, | |
| ): FontPrediction => ({ | |
| ...{ | |
| angleDeg: faker.number.float({ fractionDigits: 2 }), | |
| direction: faker.helpers.arrayElement(Object.values(TextDirection)), | |
| fontSizePx: faker.number.float({ fractionDigits: 2 }), | |
| lineHeight: faker.number.float({ fractionDigits: 2 }), | |
| namedFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| index: faker.number.int({ min: 0 }), | |
| language: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.string.alpha({ length: { min: 10, max: 20 } }), null]), | |
| undefined, | |
| ]), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| probability: faker.number.float({ fractionDigits: 2 }), | |
| serif: faker.datatype.boolean(), | |
| }), | |
| ), | |
| strokeColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.number.int({ min: 0 }), | |
| ), | |
| strokeWidthPx: faker.number.float({ fractionDigits: 2 }), | |
| textColor: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => faker.number.int({ min: 0 }), | |
| ), | |
| topFonts: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map( | |
| () => ({ | |
| index: faker.number.int({ min: 0 }), | |
| score: faker.number.float({ fractionDigits: 2 }), | |
| }), | |
| ), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneJsonResponseTransformMock = ( | |
| overrideResponse: Partial<Transform> = {}, | |
| ): Transform => ({ | |
| ...{ | |
| height: faker.number.float({ fractionDigits: 2 }), | |
| rotationDeg: faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), undefined]), | |
| width: faker.number.float({ fractionDigits: 2 }), | |
| x: faker.number.float({ fractionDigits: 2 }), | |
| y: faker.number.float({ fractionDigits: 2 }), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneJsonResponseTextShaderEffectMock = ( | |
| overrideResponse: Partial<TextShaderEffect> = {}, | |
| ): TextShaderEffect => ({ | |
| ...{ | |
| bold: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), | |
| italic: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneJsonResponseTextStrokeStyleMock = ( | |
| overrideResponse: Partial<TextStrokeStyle> = {}, | |
| ): TextStrokeStyle => ({ | |
| ...{ | |
| color: faker.helpers.arrayElement([ | |
| Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => | |
| faker.number.int({ min: 0 }), | |
| ), | |
| undefined, | |
| ]), | |
| enabled: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), | |
| widthPx: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), | |
| undefined, | |
| ]), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneJsonResponseTextStyleMock = ( | |
| overrideResponse: Partial<TextStyle> = {}, | |
| ): TextStyle => ({ | |
| ...{ | |
| color: Array.from({ length: faker.number.int({ min: 1, max: 10 }) }, (_, i) => i + 1).map(() => | |
| faker.number.int({ min: 0 }), | |
| ), | |
| effect: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextShaderEffectMock() }]), | |
| undefined, | |
| ]), | |
| fontFamilies: Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => faker.string.alpha({ length: { min: 10, max: 20 } })), | |
| fontSize: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), | |
| undefined, | |
| ]), | |
| stroke: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([null, { ...getGetSceneJsonResponseTextStrokeStyleMock() }]), | |
| undefined, | |
| ]), | |
| textAlign: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([null, faker.helpers.arrayElement(Object.values(TextAlign))]), | |
| undefined, | |
| ]), | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getGetSceneJsonResponseMock = ( | |
| overrideResponse: Partial<Extract<SceneSnapshot, object>> = {}, | |
| ): SceneSnapshot => ({ | |
| epoch: faker.number.int({ min: 0 }), | |
| scene: { | |
| pages: { | |
| [faker.string.alphanumeric(5)]: { | |
| height: faker.number.int({ min: 0 }), | |
| id: faker.string.uuid(), | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| nodes: { | |
| [faker.string.alphanumeric(5)]: { | |
| id: faker.string.uuid(), | |
| kind: faker.helpers.arrayElement([ | |
| { | |
| image: { | |
| blob: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| name: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| naturalHeight: faker.number.int({ min: 0 }), | |
| naturalWidth: faker.number.int({ min: 0 }), | |
| opacity: faker.helpers.arrayElement([ | |
| faker.number.float({ fractionDigits: 2 }), | |
| undefined, | |
| ]), | |
| role: faker.helpers.arrayElement(Object.values(ImageRole)), | |
| }, | |
| }, | |
| { | |
| text: { | |
| confidence: faker.helpers.arrayElement([ | |
| faker.number.float({ fractionDigits: 2 }), | |
| undefined, | |
| ]), | |
| detectedFontSizePx: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), | |
| undefined, | |
| ]), | |
| detector: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| fontPrediction: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| { ...getGetSceneJsonResponseFontPredictionMock() }, | |
| ]), | |
| undefined, | |
| ]), | |
| linePolygons: faker.helpers.arrayElement([ | |
| Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => | |
| Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => | |
| Array.from( | |
| { length: faker.number.int({ min: 1, max: 10 }) }, | |
| (_, i) => i + 1, | |
| ).map(() => faker.number.float({ fractionDigits: 2 })), | |
| ), | |
| ), | |
| undefined, | |
| ]), | |
| lockLayoutBox: faker.helpers.arrayElement([faker.datatype.boolean(), undefined]), | |
| renderedDirection: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| faker.helpers.arrayElement(Object.values(TextDirection)), | |
| ]), | |
| undefined, | |
| ]), | |
| rotationDeg: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([faker.number.float({ fractionDigits: 2 }), null]), | |
| undefined, | |
| ]), | |
| sourceDirection: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| faker.helpers.arrayElement(Object.values(TextDirection)), | |
| ]), | |
| undefined, | |
| ]), | |
| sourceLang: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| sprite: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| ]), | |
| undefined, | |
| ]), | |
| spriteTransform: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| { ...getGetSceneJsonResponseTransformMock() }, | |
| ]), | |
| undefined, | |
| ]), | |
| style: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| null, | |
| { ...getGetSceneJsonResponseTextStyleMock() }, | |
| ]), | |
| undefined, | |
| ]), | |
| text: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| translation: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| }, | |
| }, | |
| { | |
| mask: { | |
| blob: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| role: faker.helpers.arrayElement(Object.values(MaskRole)), | |
| }, | |
| }, | |
| ]), | |
| transform: faker.helpers.arrayElement([ | |
| { | |
| height: faker.number.float({ fractionDigits: 2 }), | |
| rotationDeg: faker.helpers.arrayElement([ | |
| faker.number.float({ fractionDigits: 2 }), | |
| undefined, | |
| ]), | |
| width: faker.number.float({ fractionDigits: 2 }), | |
| x: faker.number.float({ fractionDigits: 2 }), | |
| y: faker.number.float({ fractionDigits: 2 }), | |
| }, | |
| undefined, | |
| ]), | |
| visible: faker.datatype.boolean(), | |
| }, | |
| }, | |
| width: faker.number.int({ min: 0 }), | |
| }, | |
| }, | |
| project: { | |
| createdAt: faker.date.past().toISOString().slice(0, 19) + 'Z', | |
| name: faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| style: faker.helpers.arrayElement([ | |
| { | |
| defaultFont: faker.helpers.arrayElement([ | |
| faker.helpers.arrayElement([ | |
| faker.string.alpha({ length: { min: 10, max: 20 } }), | |
| null, | |
| ]), | |
| undefined, | |
| ]), | |
| }, | |
| undefined, | |
| ]), | |
| updatedAt: faker.date.past().toISOString().slice(0, 19) + 'Z', | |
| }, | |
| }, | |
| ...overrideResponse, | |
| }) | |
| export const getStartCodexDeviceLoginMockHandler = ( | |
| overrideResponse?: | |
| | CodexDeviceLogin | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<CodexDeviceLogin> | CodexDeviceLogin), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/ai/codex/auth/device-code', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getStartCodexDeviceLoginResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getDeleteCodexSessionMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.delete( | |
| '*/ai/codex/auth/session', | |
| async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetCodexAuthStatusMockHandler = ( | |
| overrideResponse?: | |
| | CodexAuthStatus | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<CodexAuthStatus> | CodexAuthStatus), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/ai/codex/auth/status', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetCodexAuthStatusResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getStartCodexImageGenerationMockHandler = ( | |
| overrideResponse?: | |
| | CodexImageGenerationResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<CodexImageGenerationResponse> | CodexImageGenerationResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/ai/codex/images', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getStartCodexImageGenerationResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetBlobMockHandler = ( | |
| overrideResponse?: | |
| | ArrayBuffer | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/blobs/:hash', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| const binaryBody = | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetBlobResponseMock() | |
| return HttpResponse.arrayBuffer( | |
| binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), | |
| { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetConfigMockHandler = ( | |
| overrideResponse?: | |
| | AppConfig | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<AppConfig> | AppConfig), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/config', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetConfigResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getPatchConfigMockHandler = ( | |
| overrideResponse?: | |
| | AppConfig | |
| | ((info: Parameters<Parameters<typeof http.patch>[1]>[0]) => Promise<AppConfig> | AppConfig), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.patch( | |
| '*/config', | |
| async (info: Parameters<Parameters<typeof http.patch>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getPatchConfigResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getSetProviderSecretMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.put( | |
| '*/config/providers/:id/secret', | |
| async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getClearProviderSecretMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.delete( | |
| '*/config/providers/:id/secret', | |
| async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getListDownloadsMockHandler = ( | |
| overrideResponse?: | |
| | ListDownloadsResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<ListDownloadsResponse> | ListDownloadsResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/downloads', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getListDownloadsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getStartDownloadMockHandler = ( | |
| overrideResponse?: | |
| | StartDownloadResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<StartDownloadResponse> | StartDownloadResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/downloads', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getStartDownloadResponseMock(), | |
| { status: 202 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetEngineCatalogMockHandler = ( | |
| overrideResponse?: | |
| | EngineCatalog | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<EngineCatalog> | EngineCatalog), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/engines', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetEngineCatalogResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getEventsMockHandler = ( | |
| overrideResponse?: | |
| | AppEvent | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<AppEvent> | AppEvent), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/events', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getEventsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getListFontsMockHandler = ( | |
| overrideResponse?: | |
| | FontFaceInfo[] | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<FontFaceInfo[]> | FontFaceInfo[]), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/fonts', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getListFontsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetGoogleFontsCatalogMockHandler = ( | |
| overrideResponse?: | |
| | GoogleFontCatalog | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<GoogleFontCatalog> | GoogleFontCatalog), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/google-fonts', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetGoogleFontsCatalogResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getFetchGoogleFontMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.post>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/google-fonts/:family/fetch', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetGoogleFontFileMockHandler = ( | |
| overrideResponse?: | |
| | ArrayBuffer | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/google-fonts/:family/:file', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| const binaryBody = | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetGoogleFontFileResponseMock() | |
| return HttpResponse.arrayBuffer( | |
| binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), | |
| { status: 200, headers: { 'Content-Type': 'font/ttf' } }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getApplyCommandMockHandler = ( | |
| overrideResponse?: | |
| | HistoryResult | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<HistoryResult> | HistoryResult), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/history/apply', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getApplyCommandResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getRedoMockHandler = ( | |
| overrideResponse?: | |
| | HistoryResult | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<HistoryResult> | HistoryResult), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/history/redo', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getRedoResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getUndoMockHandler = ( | |
| overrideResponse?: | |
| | HistoryResult | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<HistoryResult> | HistoryResult), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/history/undo', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getUndoResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetCatalogMockHandler = ( | |
| overrideResponse?: | |
| | LlmCatalog | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<LlmCatalog> | LlmCatalog), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/llm/catalog', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetCatalogResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetCurrentLlmMockHandler = ( | |
| overrideResponse?: | |
| | LlmState | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<LlmState> | LlmState), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/llm/current', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetCurrentLlmResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getPutCurrentLlmMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.put>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.put( | |
| '*/llm/current', | |
| async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getDeleteCurrentLlmMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.delete( | |
| '*/llm/current', | |
| async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetMetaMockHandler = ( | |
| overrideResponse?: | |
| | MetaInfo | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<MetaInfo> | MetaInfo), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/meta', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetMetaResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getListOperationsMockHandler = ( | |
| overrideResponse?: | |
| | ListOperationsResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<ListOperationsResponse> | ListOperationsResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/operations', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getListOperationsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getCancelOperationMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.delete( | |
| '*/operations/:id', | |
| async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getCreatePagesMockHandler = ( | |
| overrideResponse?: | |
| | CreatePagesResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<CreatePagesResponse> | CreatePagesResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/pages', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getCreatePagesResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getCreatePagesFromPathsMockHandler = ( | |
| overrideResponse?: | |
| | CreatePagesResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<CreatePagesResponse> | CreatePagesResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/pages/from-paths', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getCreatePagesFromPathsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getAddImageLayerMockHandler = ( | |
| overrideResponse?: | |
| | AddImageLayerResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<AddImageLayerResponse> | AddImageLayerResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/pages/:id/image-layers', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getAddImageLayerResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getPutMaskMockHandler = ( | |
| overrideResponse?: | |
| | PutMaskResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.put>[1]>[0], | |
| ) => Promise<PutMaskResponse> | PutMaskResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.put( | |
| '*/pages/:id/masks/:role', | |
| async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getPutMaskResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetPageThumbnailMockHandler = ( | |
| overrideResponse?: | |
| | ArrayBuffer | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/pages/:id/thumbnail', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| const binaryBody = | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetPageThumbnailResponseMock() | |
| return HttpResponse.arrayBuffer( | |
| binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), | |
| { status: 200, headers: { 'Content-Type': 'image/webp' } }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getStartPipelineMockHandler = ( | |
| overrideResponse?: | |
| | StartPipelineResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<StartPipelineResponse> | StartPipelineResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/pipelines', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getStartPipelineResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getListProjectsMockHandler = ( | |
| overrideResponse?: | |
| | ListProjectsResponse | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<ListProjectsResponse> | ListProjectsResponse), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/projects', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getListProjectsResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getCreateProjectMockHandler = ( | |
| overrideResponse?: | |
| | ProjectSummary | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<ProjectSummary> | ProjectSummary), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/projects', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getCreateProjectResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getPutCurrentProjectMockHandler = ( | |
| overrideResponse?: | |
| | ProjectSummary | |
| | (( | |
| info: Parameters<Parameters<typeof http.put>[1]>[0], | |
| ) => Promise<ProjectSummary> | ProjectSummary), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.put( | |
| '*/projects/current', | |
| async (info: Parameters<Parameters<typeof http.put>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getPutCurrentProjectResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getDeleteCurrentProjectMockHandler = ( | |
| overrideResponse?: | |
| | void | |
| | ((info: Parameters<Parameters<typeof http.delete>[1]>[0]) => Promise<void> | void), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.delete( | |
| '*/projects/current', | |
| async (info: Parameters<Parameters<typeof http.delete>[1]>[0]) => { | |
| await delay(0) | |
| if (typeof overrideResponse === 'function') { | |
| await overrideResponse(info) | |
| } | |
| return new HttpResponse(null, { status: 204 }) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getExportCurrentProjectMockHandler = ( | |
| overrideResponse?: | |
| | ArrayBuffer | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<ArrayBuffer> | ArrayBuffer), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/projects/current/export', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| const binaryBody = | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getExportCurrentProjectResponseMock() | |
| return HttpResponse.arrayBuffer( | |
| binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), | |
| { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getImportProjectMockHandler = ( | |
| overrideResponse?: | |
| | ProjectSummary | |
| | (( | |
| info: Parameters<Parameters<typeof http.post>[1]>[0], | |
| ) => Promise<ProjectSummary> | ProjectSummary), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.post( | |
| '*/projects/import', | |
| async (info: Parameters<Parameters<typeof http.post>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getImportProjectResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetSceneBinMockHandler = ( | |
| overrideResponse?: | |
| | ArrayBuffer | |
| | ((info: Parameters<Parameters<typeof http.get>[1]>[0]) => Promise<ArrayBuffer> | ArrayBuffer), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/scene.bin', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| const binaryBody = | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetSceneBinResponseMock() | |
| return HttpResponse.arrayBuffer( | |
| binaryBody instanceof ArrayBuffer ? binaryBody : new ArrayBuffer(0), | |
| { status: 200, headers: { 'Content-Type': 'application/octet-stream' } }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getGetSceneJsonMockHandler = ( | |
| overrideResponse?: | |
| | SceneSnapshot | |
| | (( | |
| info: Parameters<Parameters<typeof http.get>[1]>[0], | |
| ) => Promise<SceneSnapshot> | SceneSnapshot), | |
| options?: RequestHandlerOptions, | |
| ) => { | |
| return http.get( | |
| '*/scene.json', | |
| async (info: Parameters<Parameters<typeof http.get>[1]>[0]) => { | |
| await delay(0) | |
| return HttpResponse.json( | |
| overrideResponse !== undefined | |
| ? typeof overrideResponse === 'function' | |
| ? await overrideResponse(info) | |
| : overrideResponse | |
| : getGetSceneJsonResponseMock(), | |
| { status: 200 }, | |
| ) | |
| }, | |
| options, | |
| ) | |
| } | |
| export const getDefaultMock = () => [ | |
| getStartCodexDeviceLoginMockHandler(), | |
| getDeleteCodexSessionMockHandler(), | |
| getGetCodexAuthStatusMockHandler(), | |
| getStartCodexImageGenerationMockHandler(), | |
| getGetBlobMockHandler(), | |
| getGetConfigMockHandler(), | |
| getPatchConfigMockHandler(), | |
| getSetProviderSecretMockHandler(), | |
| getClearProviderSecretMockHandler(), | |
| getListDownloadsMockHandler(), | |
| getStartDownloadMockHandler(), | |
| getGetEngineCatalogMockHandler(), | |
| getEventsMockHandler(), | |
| getListFontsMockHandler(), | |
| getGetGoogleFontsCatalogMockHandler(), | |
| getFetchGoogleFontMockHandler(), | |
| getGetGoogleFontFileMockHandler(), | |
| getApplyCommandMockHandler(), | |
| getRedoMockHandler(), | |
| getUndoMockHandler(), | |
| getGetCatalogMockHandler(), | |
| getGetCurrentLlmMockHandler(), | |
| getPutCurrentLlmMockHandler(), | |
| getDeleteCurrentLlmMockHandler(), | |
| getGetMetaMockHandler(), | |
| getListOperationsMockHandler(), | |
| getCancelOperationMockHandler(), | |
| getCreatePagesMockHandler(), | |
| getCreatePagesFromPathsMockHandler(), | |
| getAddImageLayerMockHandler(), | |
| getPutMaskMockHandler(), | |
| getGetPageThumbnailMockHandler(), | |
| getStartPipelineMockHandler(), | |
| getListProjectsMockHandler(), | |
| getCreateProjectMockHandler(), | |
| getPutCurrentProjectMockHandler(), | |
| getDeleteCurrentProjectMockHandler(), | |
| getExportCurrentProjectMockHandler(), | |
| getImportProjectMockHandler(), | |
| getGetSceneBinMockHandler(), | |
| getGetSceneJsonMockHandler(), | |
| ] | |