diff --git a/apps/api/.pre-commit-config.yaml b/apps/api/.pre-commit-config.yaml index b48115ac..c9eac74b 100644 --- a/apps/api/.pre-commit-config.yaml +++ b/apps/api/.pre-commit-config.yaml @@ -32,6 +32,6 @@ repos: hooks: - id: flake8 - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 + rev: v1.10.0 hooks: - id: mypy diff --git a/apps/extension/package.json b/apps/extension/package.json index 57179bbb..0f0f9439 100644 --- a/apps/extension/package.json +++ b/apps/extension/package.json @@ -35,7 +35,7 @@ "autoprefixer": "^10.4.19", "postcss": "^8.4.38", "svelte": "^4.2.15", - "svelte-check": "^3.6.9", + "svelte-check": "^3.7.0", "tailwindcss": "^3.4.3", "tslib": "^2.6.2", "typescript": "^5.4.5", diff --git a/apps/extension/src/entrypoints/options/App.svelte b/apps/extension/src/entrypoints/options/App.svelte index 8b9cb0ca..7e8f2200 100644 --- a/apps/extension/src/entrypoints/options/App.svelte +++ b/apps/extension/src/entrypoints/options/App.svelte @@ -1,5 +1,5 @@ @@ -67,7 +67,7 @@ label="Quality:" helpText="The preferred quality for the download." bind:value={$settings.quality} - options={toSelectOptions(DownloadQualityEnum)} + options={toSelectOptions(DownloadQuality)} on:change={() => toast.success('Updated', 'Quality settings updated successfully.')} /> diff --git a/apps/web/package.json b/apps/web/package.json index 171ed541..9af8166f 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -26,10 +26,10 @@ "autoprefixer": "^10.4.19", "postcss": "^8.4.38", "svelte": "^4.2.15", - "svelte-check": "^3.6.9", + "svelte-check": "^3.7.0", "tailwindcss": "^3.4.3", "tslib": "^2.6.2", "typescript": "^5.4.5", - "vite": "^5.2.10" + "vite": "^5.2.11" } } diff --git a/apps/web/src/lib/stores/settings.ts b/apps/web/src/lib/stores/settings.ts index c7c41f39..6c139c3b 100644 --- a/apps/web/src/lib/stores/settings.ts +++ b/apps/web/src/lib/stores/settings.ts @@ -3,10 +3,10 @@ import { writable } from 'svelte/store'; import type { DownloadOptions } from '@yd/client'; import { - AudioFormatEnum, + AudioFormat, DEFAULT_DOWNLOAD_OPTIONS, - DownloadQualityEnum, - VideoFormatEnum + DownloadQuality, + VideoFormat } from '@yd/client'; const SETTINGS_KEY = 'yd-settings'; @@ -20,14 +20,14 @@ function createSettingsStore() { if (data !== null) { const parsedData = JSON.parse(data) as DownloadOptions; const supportedFormats = [ - ...Object.values(AudioFormatEnum), - ...Object.values(VideoFormatEnum) + ...Object.values(AudioFormat), + ...Object.values(VideoFormat) ]; // Make sure a value is set, if nothing is set use the default if (!supportedFormats.includes(parsedData.format)) { parsedData.format = DEFAULT_DOWNLOAD_OPTIONS.format; } - if (!Object.values(DownloadQualityEnum).includes(parsedData.quality)) { + if (!Object.values(DownloadQuality).includes(parsedData.quality)) { parsedData.quality = DEFAULT_DOWNLOAD_OPTIONS.quality; } if (parsedData.embed_metadata === undefined) { diff --git a/apps/web/src/routes/settings/+page.svelte b/apps/web/src/routes/settings/+page.svelte index af6ef976..8ec61a44 100644 --- a/apps/web/src/routes/settings/+page.svelte +++ b/apps/web/src/routes/settings/+page.svelte @@ -2,7 +2,7 @@ import config from '$lib/config'; import { settings, userSettings } from '$lib/stores/settings'; - import { AudioFormatEnum, DownloadQualityEnum, VideoFormatEnum } from '@yd/client'; + import { AudioFormat, DownloadQuality, VideoFormat } from '@yd/client'; import { Alert, CodeBracketIcon, @@ -38,11 +38,11 @@ const formatGroups = [ { text: 'Audio', - options: toSelectOptions(AudioFormatEnum) + options: toSelectOptions(AudioFormat) }, { text: 'Video', - options: toSelectOptions(VideoFormatEnum) + options: toSelectOptions(VideoFormat) } ]; @@ -69,7 +69,7 @@ label="Quality:" helpText="The preferred quality for the download." bind:value={$settings.quality} - options={toSelectOptions(DownloadQualityEnum)} + options={toSelectOptions(DownloadQuality)} on:change={() => toast.success('Updated', 'Quality settings updated successfully.')} /> diff --git a/packages/client/openapi-ts.config.ts b/packages/client/openapi-ts.config.ts index fac82ae5..7cfa70bb 100644 --- a/packages/client/openapi-ts.config.ts +++ b/packages/client/openapi-ts.config.ts @@ -6,7 +6,9 @@ export default defineConfig({ input, output: './src/generated', client: 'fetch', - enums: 'javascript', format: 'prettier', + types: { + enums: 'javascript' + }, schemas: false }); diff --git a/packages/client/package.json b/packages/client/package.json index cb986d4e..c6b90ac1 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -13,7 +13,7 @@ "format": "prettier --write ." }, "devDependencies": { - "@hey-api/openapi-ts": "^0.42.1", + "@hey-api/openapi-ts": "^0.43.0", "@yd/api": "workspace:*", "@yd/config": "workspace:*", "prettier": "^3.2.5", diff --git a/packages/client/src/generated/enums.gen.ts b/packages/client/src/generated/enums.gen.ts deleted file mode 100644 index a1b12904..00000000 --- a/packages/client/src/generated/enums.gen.ts +++ /dev/null @@ -1,32 +0,0 @@ -// This file is auto-generated by @hey-api/openapi-ts - -export const AudioFormatEnum = { - AAC: 'aac', - FLAC: 'flac', - M4A: 'm4a', - MP3: 'mp3', - OPUS: 'opus', - WAV: 'wav' -} as const; - -export const DownloadQualityEnum = { - BEST: 'best', - WORST: 'worst' -} as const; - -export const DownloadStateEnum = { - WAITING: 'WAITING', - DOWNLOADING: 'DOWNLOADING', - PROCESSING: 'PROCESSING', - DONE: 'DONE', - ERROR: 'ERROR' -} as const; - -export const VideoFormatEnum = { - AVI: 'avi', - FLV: 'flv', - MKV: 'mkv', - MOV: 'mov', - MP4: 'mp4', - WEBM: 'webm' -} as const; diff --git a/packages/client/src/generated/index.ts b/packages/client/src/generated/index.ts index fa3736bb..8675c0c3 100644 --- a/packages/client/src/generated/index.ts +++ b/packages/client/src/generated/index.ts @@ -2,6 +2,5 @@ export { ApiError } from './core/ApiError'; export { CancelablePromise, CancelError } from './core/CancelablePromise'; export { OpenAPI, type OpenAPIConfig } from './core/OpenAPI'; -export * from './enums.gen'; export * from './services.gen'; export * from './types.gen'; diff --git a/packages/client/src/generated/services.gen.ts b/packages/client/src/generated/services.gen.ts index 3c70810f..63504503 100644 --- a/packages/client/src/generated/services.gen.ts +++ b/packages/client/src/generated/services.gen.ts @@ -1,7 +1,28 @@ // This file is auto-generated by @hey-api/openapi-ts import type { CancelablePromise } from './core/CancelablePromise'; -import type { $OpenApiTs } from './types.gen'; +import type { + DeleteDownloadData, + DeleteDownloadResponse, + DeleteSessionResponse, + GetDownloadData, + GetDownloadFileData, + GetDownloadFileResponse, + GetDownloadResponse, + GetDownloadsOptionsResponse, + GetDownloadsResponse, + GetNextSearchResponse, + GetSearchData, + GetSearchResponse, + GetSessionResponse, + GetSessionValidateResponse, + GetVideoData, + GetVideoResponse, + PostDownloadsData, + PostDownloadsResponse, + PutDownloadsData, + PutDownloadsResponse +} from './types.gen'; import { OpenAPI } from './core/OpenAPI'; import { request as __request } from './core/request'; @@ -13,9 +34,7 @@ export class SearchService { * @returns Video Successful Response * @throws ApiError */ - public static getSearch( - data: $OpenApiTs['/search']['get']['req'] - ): CancelablePromise<$OpenApiTs['/search']['get']['res'][200]> { + public static getSearch(data: GetSearchData): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/search', @@ -35,7 +54,7 @@ export class SearchService { * @returns Video Successful Response * @throws ApiError */ - public static getNextSearch(): CancelablePromise<$OpenApiTs['/search/next']['get']['res'][200]> { + public static getNextSearch(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/search/next', @@ -53,9 +72,7 @@ export class SearchService { * @returns Video Successful Response * @throws ApiError */ - public static getVideo( - data: $OpenApiTs['/search/video']['get']['req'] - ): CancelablePromise<$OpenApiTs['/search/video']['get']['res'][200]> { + public static getVideo(data: GetVideoData): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/search/video', @@ -77,7 +94,7 @@ export class SessionService { * @returns Session Successful Response * @throws ApiError */ - public static getSession(): CancelablePromise<$OpenApiTs['/session']['get']['res'][200]> { + public static getSession(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/session' @@ -89,7 +106,7 @@ export class SessionService { * @returns void Successful Response * @throws ApiError */ - public static deleteSession(): CancelablePromise<$OpenApiTs['/session']['delete']['res'][204]> { + public static deleteSession(): CancelablePromise { return __request(OpenAPI, { method: 'DELETE', url: '/session', @@ -104,9 +121,7 @@ export class SessionService { * @returns Session Successful Response * @throws ApiError */ - public static getSessionValidate(): CancelablePromise< - $OpenApiTs['/session/validate']['get']['res'][200] - > { + public static getSessionValidate(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/session/validate', @@ -123,7 +138,7 @@ export class DownloadsService { * @returns Download Successful Response * @throws ApiError */ - public static getDownloads(): CancelablePromise<$OpenApiTs['/downloads']['get']['res'][200]> { + public static getDownloads(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/downloads', @@ -140,9 +155,7 @@ export class DownloadsService { * @returns Download Successful Response * @throws ApiError */ - public static putDownloads( - data: $OpenApiTs['/downloads']['put']['req'] - ): CancelablePromise<$OpenApiTs['/downloads']['put']['res'][200]> { + public static putDownloads(data: PutDownloadsData): CancelablePromise { return __request(OpenAPI, { method: 'PUT', url: '/downloads', @@ -162,9 +175,7 @@ export class DownloadsService { * @returns Download Successful Response * @throws ApiError */ - public static postDownloads( - data: $OpenApiTs['/downloads']['post']['req'] - ): CancelablePromise<$OpenApiTs['/downloads']['post']['res'][201]> { + public static postDownloads(data: PostDownloadsData): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/downloads', @@ -182,9 +193,7 @@ export class DownloadsService { * @returns AvailableDownloadOptions Successful Response * @throws ApiError */ - public static getDownloadsOptions(): CancelablePromise< - $OpenApiTs['/downloads/options']['get']['res'][200] - > { + public static getDownloadsOptions(): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/downloads/options', @@ -201,9 +210,7 @@ export class DownloadsService { * @returns Download Successful Response * @throws ApiError */ - public static getDownload( - data: $OpenApiTs['/downloads/{download_id}']['get']['req'] - ): CancelablePromise<$OpenApiTs['/downloads/{download_id}']['get']['res'][200]> { + public static getDownload(data: GetDownloadData): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/downloads/{download_id}', @@ -226,8 +233,8 @@ export class DownloadsService { * @throws ApiError */ public static deleteDownload( - data: $OpenApiTs['/downloads/{download_id}']['delete']['req'] - ): CancelablePromise<$OpenApiTs['/downloads/{download_id}']['delete']['res'][204]> { + data: DeleteDownloadData + ): CancelablePromise { return __request(OpenAPI, { method: 'DELETE', url: '/downloads/{download_id}', @@ -250,8 +257,8 @@ export class DownloadsService { * @throws ApiError */ public static getDownloadFile( - data: $OpenApiTs['/downloads/{download_id}/file']['get']['req'] - ): CancelablePromise<$OpenApiTs['/downloads/{download_id}/file']['get']['res'][200]> { + data: GetDownloadFileData + ): CancelablePromise { return __request(OpenAPI, { method: 'GET', url: '/downloads/{download_id}/file', diff --git a/packages/client/src/generated/types.gen.ts b/packages/client/src/generated/types.gen.ts index 36670366..1853ac7b 100644 --- a/packages/client/src/generated/types.gen.ts +++ b/packages/client/src/generated/types.gen.ts @@ -2,6 +2,15 @@ export type AudioFormat = 'aac' | 'flac' | 'm4a' | 'mp3' | 'opus' | 'wav'; +export const AudioFormat = { + AAC: 'aac', + FLAC: 'flac', + M4A: 'm4a', + MP3: 'mp3', + OPUS: 'opus', + WAV: 'wav' +} as const; + export type AvailableDownloadOptions = { format: Array; quality: Array; @@ -37,8 +46,21 @@ export type DownloadOptions = { export type DownloadQuality = 'best' | 'worst'; +export const DownloadQuality = { + BEST: 'best', + WORST: 'worst' +} as const; + export type DownloadState = 'WAITING' | 'DOWNLOADING' | 'PROCESSING' | 'DONE' | 'ERROR'; +export const DownloadState = { + WAITING: 'WAITING', + DOWNLOADING: 'DOWNLOADING', + PROCESSING: 'PROCESSING', + DONE: 'DONE', + ERROR: 'ERROR' +} as const; + export type DownloadStatus = { state: DownloadState; downloaded_bytes?: number | null; @@ -75,6 +97,69 @@ export type Video = { export type VideoFormat = 'avi' | 'flv' | 'mkv' | 'mov' | 'mp4' | 'webm'; +export const VideoFormat = { + AVI: 'avi', + FLV: 'flv', + MKV: 'mkv', + MOV: 'mov', + MP4: 'mp4', + WEBM: 'webm' +} as const; + +export type GetSearchData = { + query: string; +}; + +export type GetSearchResponse = Array