diff --git a/web/src/ambient.d.ts b/web/src/ambient.d.ts new file mode 100644 index 0000000..84a1339 --- /dev/null +++ b/web/src/ambient.d.ts @@ -0,0 +1,19 @@ +// Ambient module declarations for SvelteKit environment variables and enhanced images + +declare module '$env/dynamic/public' { + export const env: { + PUBLIC_API_URL: string; + [key: string]: string | undefined; + }; +} + +declare module '$env/static/public' { + export const PUBLIC_VERSION: string; + export const PUBLIC_API_URL: string; +} + +// Enhanced image module declarations +declare module '*?enhanced' { + const value: unknown; + export default value; +} diff --git a/web/src/app.d.ts b/web/src/app.d.ts index da08e6d..5c3ead9 100644 --- a/web/src/app.d.ts +++ b/web/src/app.d.ts @@ -10,4 +10,23 @@ declare global { } } +// Environment variables declarations +declare module '$env/dynamic/public' { + export const env: { + PUBLIC_API_URL: string; + [key: string]: string | undefined; + }; +} + +declare module '$env/static/public' { + export const PUBLIC_VERSION: string; + export const PUBLIC_API_URL: string; +} + +// Enhanced image module declarations +declare module '*?enhanced' { + const value: unknown; + export default value; +} + export {}; diff --git a/web/src/lib/components/add-media-card.svelte b/web/src/lib/components/add-media-card.svelte index 0151001..a79400b 100644 --- a/web/src/lib/components/add-media-card.svelte +++ b/web/src/lib/components/add-media-card.svelte @@ -9,7 +9,7 @@ const apiUrl = env.PUBLIC_API_URL; let loading = $state(false); - let errorMessage = $state(null); + let errorMessage = $state(null); let { result, isShow = true }: { result: MetaDataProviderSearchResult; isShow: boolean } = $props(); console.log('Add Show Card Result: ', result); @@ -28,7 +28,7 @@ if (response.ok) { await goto(`${base}/dashboard/${isShow ? 'tv' : 'movies'}/` + responseData.id); } else { - errorMessage = 'Error occurred: ' + responseData; + errorMessage = 'Error occurred: ' + JSON.stringify(responseData); } loading = false; } @@ -63,7 +63,7 @@ @@ -179,7 +179,7 @@ {/if} {:else} - There are currently no requests. + There are currently no requests. {/each} diff --git a/web/src/lib/components/user-data-table.svelte b/web/src/lib/components/user-data-table.svelte index f4c33bb..8ce3782 100644 --- a/web/src/lib/components/user-data-table.svelte +++ b/web/src/lib/components/user-data-table.svelte @@ -39,9 +39,9 @@ toast.success(`User ${selectedUser.email} updated successfully.`); dialogOpen = false; - const idx = sortedUsers.findIndex((u) => u.id === selectedUser.id); + const idx = sortedUsers.findIndex((u) => u.id === selectedUser!.id); if (idx !== -1) { - sortedUsers[idx] = selectedUser; + sortedUsers[idx] = selectedUser!; } selectedUser = null; diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index 3e34a92..8007217 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -33,7 +33,7 @@ export function getTorrentStatusString(value: number): string { return torrentStatusMap[value] || 'unknown'; } -export function getFullyQualifiedMediaName(media: { name: string; year: number }): string { +export function getFullyQualifiedMediaName(media: { name: string; year: number | null }): string { let name = media.name; if (media.year != null) { name += ' (' + media.year + ')'; @@ -45,13 +45,16 @@ export function convertTorrentSeasonRangeToIntegerRange(torrent: { season?: number[]; seasons?: number[]; }): string { - if (torrent?.season?.length === 1) return torrent.season[0]?.toString(); - if (torrent?.season?.length >= 2) - return torrent.season[0]?.toString() + '-' + torrent.season.at(-1).toString(); - if (torrent?.seasons?.length === 1) return torrent.seasons[0]?.toString(); - if (torrent?.seasons?.length >= 2) - return torrent.seasons[0]?.toString() + '-' + torrent.seasons.at(-1).toString(); - else { + if (torrent?.season?.length === 1) return torrent.season[0]?.toString() || ''; + if (torrent?.season?.length && torrent.season.length >= 2) { + const lastSeason = torrent.season.at(-1); + return torrent.season[0]?.toString() + '-' + (lastSeason?.toString() || ''); + } + if (torrent?.seasons?.length === 1) return torrent.seasons[0]?.toString() || ''; + if (torrent?.seasons?.length && torrent.seasons.length >= 2) { + const lastSeason = torrent.seasons.at(-1); + return torrent.seasons[0]?.toString() + '-' + (lastSeason?.toString() || ''); + } else { console.log('Error parsing season range: ' + torrent?.seasons + torrent?.season); return 'Error parsing season range: ' + torrent?.seasons + torrent?.season; } diff --git a/web/src/routes/dashboard/+page.svelte b/web/src/routes/dashboard/+page.svelte index d1d5e92..8b2da41 100644 --- a/web/src/routes/dashboard/+page.svelte +++ b/web/src/routes/dashboard/+page.svelte @@ -6,7 +6,7 @@ import { base } from '$app/paths'; import { onMount } from 'svelte'; import { env } from '$env/dynamic/public'; - import { MetaDataProviderSearchResult } from '$lib/types'; + import type { MetaDataProviderSearchResult } from '$lib/types'; const apiUrl = env.PUBLIC_API_URL; diff --git a/web/src/routes/dashboard/movies/+page.svelte b/web/src/routes/dashboard/movies/+page.svelte index 4d07573..fbf2216 100644 --- a/web/src/routes/dashboard/movies/+page.svelte +++ b/web/src/routes/dashboard/movies/+page.svelte @@ -9,9 +9,10 @@ import { toast } from 'svelte-sonner'; import { env } from '$env/dynamic/public'; import { Skeleton } from '$lib/components/ui/skeleton'; + import type { PublicMovie } from '$lib/types'; const apiUrl = env.PUBLIC_API_URL; - let movies; + let movies: PublicMovie[] = []; let loading = false; onMount(async () => { loading = true; diff --git a/web/src/routes/dashboard/movies/[movieId=uuid]/+page.ts b/web/src/routes/dashboard/movies/[movieId=uuid]/+page.ts index 7eee298..5c1e653 100644 --- a/web/src/routes/dashboard/movies/[movieId=uuid]/+page.ts +++ b/web/src/routes/dashboard/movies/[movieId=uuid]/+page.ts @@ -1,8 +1,8 @@ -import type { LayoutLoad } from './$types'; +import type { PageLoad } from './$types'; import { env } from '$env/dynamic/public'; import { error } from '@sveltejs/kit'; -export const load: LayoutLoad = async ({ params, fetch }) => { +export const load: PageLoad = async ({ params, fetch }) => { const res = await fetch(`${env.PUBLIC_API_URL}/movies/${params.movieId}`, { credentials: 'include' }); diff --git a/web/src/routes/dashboard/movies/requests/+page.svelte b/web/src/routes/dashboard/movies/requests/+page.svelte index 2550bd1..0972fba 100644 --- a/web/src/routes/dashboard/movies/requests/+page.svelte +++ b/web/src/routes/dashboard/movies/requests/+page.svelte @@ -43,5 +43,5 @@

Movie Requests

- + diff --git a/web/src/routes/dashboard/settings/+page.svelte b/web/src/routes/dashboard/settings/+page.svelte index 4ff38f5..fce0dfc 100644 --- a/web/src/routes/dashboard/settings/+page.svelte +++ b/web/src/routes/dashboard/settings/+page.svelte @@ -8,9 +8,10 @@ import * as Sidebar from '$lib/components/ui/sidebar/index.js'; import * as Breadcrumb from '$lib/components/ui/breadcrumb/index.js'; import { base } from '$app/paths'; + import type { User } from '$lib/types'; - let currentUser = getContext('user'); - let users = page.data.users; + let currentUser: () => User = getContext('user'); + let users = $state(page.data.users); @@ -56,7 +57,7 @@ Edit or delete users - + {/if} diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/+layout.svelte b/web/src/routes/dashboard/tv/[showId=uuid]/+layout.svelte index 91bc33d..3cbecae 100644 --- a/web/src/routes/dashboard/tv/[showId=uuid]/+layout.svelte +++ b/web/src/routes/dashboard/tv/[showId=uuid]/+layout.svelte @@ -6,7 +6,7 @@ const showData = $derived(data.showData); setContext('show', () => showData); - const fetchError = $derived(data.error); + const fetchError = $derived((data as { error?: string }).error || null); {#if fetchError} diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte index 34a6a63..2393fc2 100644 --- a/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte +++ b/web/src/routes/dashboard/tv/[showId=uuid]/+page.svelte @@ -7,7 +7,7 @@ import { ImageOff } from 'lucide-svelte'; import * as Table from '$lib/components/ui/table/index.js'; import { getContext } from 'svelte'; - import type { RichShowTorrent, Show, User } from '$lib/types.js'; + import type { PublicShow, RichShowTorrent, Show, User } from '$lib/types.js'; import { getFullyQualifiedMediaName } from '$lib/utils'; import DownloadSeasonDialog from '$lib/components/download-season-dialog.svelte'; import CheckmarkX from '$lib/components/checkmark-x.svelte'; @@ -48,10 +48,10 @@ - {getFullyQualifiedMediaName(show)} - MediaManager + {getFullyQualifiedMediaName(show())} - MediaManager @@ -122,7 +122,7 @@ {/if} {/if} - +
@@ -146,7 +146,7 @@ > {season.number} - + {season.name} {season.overview} @@ -154,7 +154,7 @@ {/each} {:else} - No season data available. + No season data available. {/if} diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.svelte b/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.svelte index 26b6524..c1bf7b3 100644 --- a/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.svelte +++ b/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.svelte @@ -12,7 +12,7 @@ let seasonFiles: PublicSeasonFile[] = $state(page.data.files); let season: Season = $state(page.data.season); - let show: ()=> Show = getContext('show'); + let show: () => Show = getContext('show'); console.log('loaded files', seasonFiles); diff --git a/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.ts b/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.ts index 9b9190f..41206cc 100644 --- a/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.ts +++ b/web/src/routes/dashboard/tv/[showId=uuid]/[SeasonId=uuid]/+page.ts @@ -39,7 +39,7 @@ export const load: PageLoad = async ({ fetch, params }) => { } catch (error) { console.error('An error occurred while fetching TV show files:', error); return { - error: `An unexpected error occurred: ${error.message || 'Unknown error'}`, + error: `An unexpected error occurred: ${error instanceof Error ? error.message : 'Unknown error'}`, files: [], season: null }; diff --git a/web/src/routes/dashboard/tv/requests/+page.svelte b/web/src/routes/dashboard/tv/requests/+page.svelte index 8fc4fe5..c459161 100644 --- a/web/src/routes/dashboard/tv/requests/+page.svelte +++ b/web/src/routes/dashboard/tv/requests/+page.svelte @@ -44,5 +44,5 @@

Season Requests

- +
diff --git a/web/src/routes/login/reset-password/+page.svelte b/web/src/routes/login/reset-password/+page.svelte index 97582ee..58e9fd7 100644 --- a/web/src/routes/login/reset-password/+page.svelte +++ b/web/src/routes/login/reset-password/+page.svelte @@ -108,7 +108,7 @@ bind:value={newPassword} disabled={isLoading} required - minlength="1" + minlength={1} />
@@ -120,7 +120,7 @@ bind:value={confirmPassword} disabled={isLoading} required - minlength="1" + minlength={1} />