diff --git a/web/src/api/api.ts b/web/src/api/api.ts index 72162c5216..c11ac66534 100644 --- a/web/src/api/api.ts +++ b/web/src/api/api.ts @@ -1,26 +1,12 @@ import { - APIKeyApi, - ActivityApi, - AlbumApi, AssetApi, AssetApiFp, AssetJobName, - AuditApi, - AuthenticationApi, DownloadApi, - FaceApi, - JobApi, JobName, - LibraryApi, - OAuthApi, - PartnerApi, PersonApi, SearchApi, - ServerInfoApi, SharedLinkApi, - SystemConfigApi, - TrashApi, - UserApi, UserApiFp, base, common, @@ -29,25 +15,11 @@ import { import type { ApiParams as ApiParameters } from './types'; class ImmichApi { - public activityApi: ActivityApi; - public albumApi: AlbumApi; public downloadApi: DownloadApi; - public libraryApi: LibraryApi; public assetApi: AssetApi; - public auditApi: AuditApi; - public authenticationApi: AuthenticationApi; - public faceApi: FaceApi; - public jobApi: JobApi; - public keyApi: APIKeyApi; - public oauthApi: OAuthApi; - public partnerApi: PartnerApi; public searchApi: SearchApi; - public serverInfoApi: ServerInfoApi; public sharedLinkApi: SharedLinkApi; public personApi: PersonApi; - public systemConfigApi: SystemConfigApi; - public userApi: UserApi; - public trashApi: TrashApi; private config: configuration.Configuration; private key?: string; @@ -59,25 +31,11 @@ class ImmichApi { constructor(parameters: configuration.ConfigurationParameters) { this.config = new configuration.Configuration(parameters); - this.activityApi = new ActivityApi(this.config); - this.albumApi = new AlbumApi(this.config); - this.auditApi = new AuditApi(this.config); this.downloadApi = new DownloadApi(this.config); - this.libraryApi = new LibraryApi(this.config); this.assetApi = new AssetApi(this.config); - this.authenticationApi = new AuthenticationApi(this.config); - this.faceApi = new FaceApi(this.config); - this.jobApi = new JobApi(this.config); - this.keyApi = new APIKeyApi(this.config); - this.oauthApi = new OAuthApi(this.config); - this.partnerApi = new PartnerApi(this.config); this.searchApi = new SearchApi(this.config); - this.serverInfoApi = new ServerInfoApi(this.config); this.sharedLinkApi = new SharedLinkApi(this.config); this.personApi = new PersonApi(this.config); - this.systemConfigApi = new SystemConfigApi(this.config); - this.userApi = new UserApi(this.config); - this.trashApi = new TrashApi(this.config); } private createUrl(path: string, parameters?: Record) { diff --git a/web/src/api/utils.ts b/web/src/api/utils.ts index 18b992463e..0367e7905a 100644 --- a/web/src/api/utils.ts +++ b/web/src/api/utils.ts @@ -1,11 +1,11 @@ -import type { AxiosError, AxiosPromise } from 'axios'; +import { finishOAuth, linkOAuthAccount, startOAuth, unlinkOAuthAccount } from '@immich/sdk'; +import type { UserResponseDto } from '@immich/sdk/axios'; +import type { AxiosError } from 'axios'; import { - notificationController, NotificationType, + notificationController, } from '../lib/components/shared-components/notification/notification'; import { handleError } from '../lib/utils/handle-error'; -import { api } from './api'; -import type { UserResponseDto } from '@immich/sdk/axios'; export type ApiError = AxiosError<{ message: string }>; @@ -43,8 +43,8 @@ export const oauth = { authorize: async (location: Location) => { try { const redirectUri = location.href.split('?')[0]; - const { data } = await api.oauthApi.startOAuth({ oAuthConfigDto: { redirectUri } }); - window.location.href = data.url; + const { url } = await startOAuth({ oAuthConfigDto: { redirectUri } }); + window.location.href = url; return true; } catch (error) { handleError(error, 'Unable to login with OAuth'); @@ -52,12 +52,12 @@ export const oauth = { } }, login: (location: Location) => { - return api.oauthApi.finishOAuth({ oAuthCallbackDto: { url: location.href } }); + return finishOAuth({ oAuthCallbackDto: { url: location.href } }); }, - link: (location: Location): AxiosPromise => { - return api.oauthApi.linkOAuthAccount({ oAuthCallbackDto: { url: location.href } }); + link: (location: Location): Promise => { + return linkOAuthAccount({ oAuthCallbackDto: { url: location.href } }); }, unlink: () => { - return api.oauthApi.unlinkOAuthAccount(); + return unlinkOAuthAccount(); }, }; diff --git a/web/src/lib/components/admin-page/delete-confirm-dialoge.svelte b/web/src/lib/components/admin-page/delete-confirm-dialoge.svelte index dfb93f7033..1046b7ef67 100644 --- a/web/src/lib/components/admin-page/delete-confirm-dialoge.svelte +++ b/web/src/lib/components/admin-page/delete-confirm-dialoge.svelte @@ -1,8 +1,8 @@ - +

diff --git a/web/src/lib/components/admin-page/jobs/jobs-panel.svelte b/web/src/lib/components/admin-page/jobs/jobs-panel.svelte index 2efd2c1bf6..36d973d35a 100644 --- a/web/src/lib/components/admin-page/jobs/jobs-panel.svelte +++ b/web/src/lib/components/admin-page/jobs/jobs-panel.svelte @@ -21,6 +21,7 @@ import ConfirmDialogue from '../../shared-components/confirm-dialogue.svelte'; import JobTile from './job-tile.svelte'; import StorageMigrationDescription from './storage-migration-description.svelte'; + import { sendJobCommand } from '@immich/sdk'; export let jobs: AllJobStatusResponseDto; @@ -127,8 +128,7 @@ const title = jobDetails[jobId]?.title; try { - const { data } = await api.jobApi.sendJobCommand({ id: jobId, jobCommandDto: jobCommand }); - jobs[jobId] = data; + jobs[jobId] = await sendJobCommand({ id: jobId, jobCommandDto: jobCommand }); switch (jobCommand.command) { case JobCommand.Empty: { diff --git a/web/src/lib/components/admin-page/restore-dialoge.svelte b/web/src/lib/components/admin-page/restore-dialoge.svelte index 95525ed9d3..c585d60e93 100644 --- a/web/src/lib/components/admin-page/restore-dialoge.svelte +++ b/web/src/lib/components/admin-page/restore-dialoge.svelte @@ -1,7 +1,7 @@ - +

{user.name}'s account will be restored.

diff --git a/web/src/lib/components/admin-page/settings/admin-settings.svelte b/web/src/lib/components/admin-page/settings/admin-settings.svelte index 3f7ddf7614..1ad962b0de 100644 --- a/web/src/lib/components/admin-page/settings/admin-settings.svelte +++ b/web/src/lib/components/admin-page/settings/admin-settings.svelte @@ -1,15 +1,15 @@ diff --git a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte index 5e2d7b781b..475c3a65cb 100644 --- a/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte +++ b/web/src/lib/components/admin-page/settings/storage-template/storage-template-settings.svelte @@ -1,7 +1,12 @@ diff --git a/web/src/lib/components/album-page/share-info-modal.svelte b/web/src/lib/components/album-page/share-info-modal.svelte index d05760c390..39cfddfa6e 100644 --- a/web/src/lib/components/album-page/share-info-modal.svelte +++ b/web/src/lib/components/album-page/share-info-modal.svelte @@ -1,16 +1,17 @@ @@ -71,12 +66,12 @@ type="password" autocomplete="current-password" required - bind:value={confirmPassowrd} + bind:value={passwordConfirm} />
- {#if error} -

{error}

+ {#if errorMessage} +

{errorMessage}

{/if} {#if success} diff --git a/web/src/lib/components/forms/create-user-form.svelte b/web/src/lib/components/forms/create-user-form.svelte index b0434648c0..70daa1ef97 100644 --- a/web/src/lib/components/forms/create-user-form.svelte +++ b/web/src/lib/components/forms/create-user-form.svelte @@ -1,11 +1,11 @@ {#if !oauthLoading && $featureFlags.passwordLogin} -
+ {#if errorMessage}

{errorMessage} diff --git a/web/src/lib/components/onboarding-page/onboarding-storage-template.svelte b/web/src/lib/components/onboarding-page/onboarding-storage-template.svelte index a4dba7da5b..49fd685e95 100644 --- a/web/src/lib/components/onboarding-page/onboarding-storage-template.svelte +++ b/web/src/lib/components/onboarding-page/onboarding-storage-template.svelte @@ -1,14 +1,15 @@ diff --git a/web/src/lib/components/photos-page/actions/add-to-album.svelte b/web/src/lib/components/photos-page/actions/add-to-album.svelte index e89e6376d8..b34abac266 100644 --- a/web/src/lib/components/photos-page/actions/add-to-album.svelte +++ b/web/src/lib/components/photos-page/actions/add-to-album.svelte @@ -6,11 +6,12 @@ NotificationType, notificationController, } from '$lib/components/shared-components/notification/notification'; + import { AppRoute } from '$lib/constants'; import { addAssetsToAlbum } from '$lib/utils/asset-utils'; - import { type AlbumResponseDto, api } from '@api'; + import { type AlbumResponseDto } from '@api'; + import { createAlbum } from '@immich/sdk'; import { getMenuContext } from '../asset-select-context-menu.svelte'; import { getAssetControlContext } from '../asset-select-control-bar.svelte'; - import { AppRoute } from '$lib/constants'; export let shared = false; let showAlbumPicker = false; @@ -27,8 +28,8 @@ showAlbumPicker = false; const assetIds = [...getAssets()].map((asset) => asset.id); - api.albumApi.createAlbum({ createAlbumDto: { albumName, assetIds } }).then((response) => { - const { id, albumName } = response.data; + createAlbum({ createAlbumDto: { albumName, assetIds } }).then((response) => { + const { id, albumName } = response; notificationController.show({ message: `Added ${assetIds.length} to ${albumName}`, diff --git a/web/src/lib/components/photos-page/actions/remove-from-album.svelte b/web/src/lib/components/photos-page/actions/remove-from-album.svelte index 48b33719e5..a2a10297d6 100644 --- a/web/src/lib/components/photos-page/actions/remove-from-album.svelte +++ b/web/src/lib/components/photos-page/actions/remove-from-album.svelte @@ -5,10 +5,10 @@ NotificationType, notificationController, } from '$lib/components/shared-components/notification/notification'; - import { type AlbumResponseDto, api } from '@api'; + import { getAlbumInfo, removeAssetFromAlbum, type AlbumResponseDto } from '@immich/sdk'; + import { mdiDeleteOutline } from '@mdi/js'; import MenuOption from '../../shared-components/context-menu/menu-option.svelte'; import { getAssetControlContext } from '../asset-select-control-bar.svelte'; - import { mdiDeleteOutline } from '@mdi/js'; export let album: AlbumResponseDto; export let onRemove: ((assetIds: string[]) => void) | undefined; @@ -21,13 +21,12 @@ const removeFromAlbum = async () => { try { const ids = [...getAssets()].map((a) => a.id); - const { data: results } = await api.albumApi.removeAssetFromAlbum({ + const results = await removeAssetFromAlbum({ id: album.id, bulkIdsDto: { ids }, }); - const { data } = await api.albumApi.getAlbumInfo({ id: album.id }); - album = data; + album = await getAlbumInfo({ id: album.id }); onRemove?.(ids); diff --git a/web/src/lib/components/photos-page/actions/restore-assets.svelte b/web/src/lib/components/photos-page/actions/restore-assets.svelte index 5121be9ce3..e6570eafe2 100644 --- a/web/src/lib/components/photos-page/actions/restore-assets.svelte +++ b/web/src/lib/components/photos-page/actions/restore-assets.svelte @@ -1,15 +1,15 @@ diff --git a/web/src/lib/components/shared-components/profile-image-cropper.svelte b/web/src/lib/components/shared-components/profile-image-cropper.svelte index 81011486a7..54f06d2854 100644 --- a/web/src/lib/components/shared-components/profile-image-cropper.svelte +++ b/web/src/lib/components/shared-components/profile-image-cropper.svelte @@ -1,13 +1,14 @@ diff --git a/web/src/routes/(user)/sharing/+page.ts b/web/src/routes/(user)/sharing/+page.ts index 5f0291ed33..2fa8415e7c 100644 --- a/web/src/routes/(user)/sharing/+page.ts +++ b/web/src/routes/(user)/sharing/+page.ts @@ -1,11 +1,11 @@ import { authenticate } from '$lib/utils/auth'; -import { api } from '@api'; +import { getAllAlbums, getPartners } from '@immich/sdk'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate(); - const { data: sharedAlbums } = await api.albumApi.getAllAlbums({ shared: true }); - const { data: partners } = await api.partnerApi.getPartners({ direction: 'shared-with' }); + const sharedAlbums = await getAllAlbums({ shared: true }); + const partners = await getPartners({ direction: 'shared-with' }); return { sharedAlbums, diff --git a/web/src/routes/(user)/trash/+page.svelte b/web/src/routes/(user)/trash/+page.svelte index 7cd37e328f..3dc126d7b6 100644 --- a/web/src/routes/(user)/trash/+page.svelte +++ b/web/src/routes/(user)/trash/+page.svelte @@ -1,29 +1,29 @@ diff --git a/web/src/routes/admin/user-management/+page.ts b/web/src/routes/admin/user-management/+page.ts index 6fbb435bf5..e93cdc3c44 100644 --- a/web/src/routes/admin/user-management/+page.ts +++ b/web/src/routes/admin/user-management/+page.ts @@ -1,11 +1,11 @@ import { authenticate, requestServerInfo } from '$lib/utils/auth'; -import { api } from '@api'; +import { getAllUsers } from '@immich/sdk'; import type { PageLoad } from './$types'; export const load = (async () => { await authenticate({ admin: true }); await requestServerInfo(); - const { data: allUsers } = await api.userApi.getAllUsers({ isAll: false }); + const allUsers = await getAllUsers({ isAll: false }); return { allUsers, diff --git a/web/src/routes/auth/login/+page.svelte b/web/src/routes/auth/login/+page.svelte index 7ead2e2d93..2c19b5550a 100644 --- a/web/src/routes/auth/login/+page.svelte +++ b/web/src/routes/auth/login/+page.svelte @@ -5,7 +5,7 @@ import { AppRoute } from '$lib/constants'; import { featureFlags, serverConfig } from '$lib/stores/server-config.store'; import { resetSavedUser } from '$lib/stores/user.store'; - import { api } from '@api'; + import { logout } from '@immich/sdk'; import type { PageData } from './$types'; export let data: PageData; @@ -13,7 +13,7 @@ afterNavigate(async ({ from }) => { if (from?.url?.pathname === AppRoute.AUTH_CHANGE_PASSWORD) { resetSavedUser(); - await api.authenticationApi.logout(); + await logout(); } }); diff --git a/web/src/routes/auth/login/+page.ts b/web/src/routes/auth/login/+page.ts index 25d92f605a..c24eea46bc 100644 --- a/web/src/routes/auth/login/+page.ts +++ b/web/src/routes/auth/login/+page.ts @@ -1,11 +1,11 @@ import { AppRoute } from '$lib/constants'; -import { api } from '@api'; +import { getServerConfig } from '@immich/sdk'; import { redirect } from '@sveltejs/kit'; import type { PageLoad } from './$types'; export const load = (async () => { - const { data } = await api.serverInfoApi.getServerConfig(); - if (!data.isInitialized) { + const { isInitialized } = await getServerConfig(); + if (!isInitialized) { // Admin not registered redirect(302, AppRoute.AUTH_REGISTER); } diff --git a/web/src/routes/auth/onboarding/+page.svelte b/web/src/routes/auth/onboarding/+page.svelte index fbdd24fcc9..4cf42d4d3d 100644 --- a/web/src/routes/auth/onboarding/+page.svelte +++ b/web/src/routes/auth/onboarding/+page.svelte @@ -1,11 +1,11 @@