Add the optional Immich integration and manual gallery push
Immich connections stay server-side with an encrypted API key, albums can be imported, and photos are only sent back when an event's push button is pressed: originals upload once, edited photos re-render, and edits hashes plus checksums skip anything already in Immich. This also lands the accompanying editor, cloud and administration work that was still uncommitted. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
+183
-1
@@ -1,4 +1,4 @@
|
||||
import type { EventRecord, PhotoRecord, Preset } from '../types';
|
||||
import type { EventRecord, Flag, PhotoRecord, Preset } from '../types';
|
||||
|
||||
export interface Health {
|
||||
ok: boolean;
|
||||
@@ -418,6 +418,75 @@ export interface MailStatus {
|
||||
gmail: boolean;
|
||||
}
|
||||
|
||||
export interface ImmichStatus {
|
||||
configured: boolean;
|
||||
enabled: boolean;
|
||||
/** The connection is configured server-wide by an administrator. */
|
||||
managed?: boolean;
|
||||
url: string;
|
||||
hasKey: boolean;
|
||||
autoSync: boolean;
|
||||
syncMinutes: number;
|
||||
trashOriginal: boolean;
|
||||
syncMetadata: boolean;
|
||||
lastSyncAt: number | null;
|
||||
lastError: string | null;
|
||||
version: string | null;
|
||||
albumCount: number;
|
||||
}
|
||||
|
||||
export interface ImmichAlbum {
|
||||
id: string;
|
||||
name: string;
|
||||
assetCount: number;
|
||||
/** A gallery created from a Luminary event is an upload destination, not an import source. */
|
||||
kind?: 'import' | 'gallery';
|
||||
updatedAt: number | null;
|
||||
startDate: number | null;
|
||||
endDate: number | null;
|
||||
thumbnailAssetId: string | null;
|
||||
/** Set when this account already imported the album. */
|
||||
eventId?: string | null;
|
||||
lastSyncAt?: number | null;
|
||||
}
|
||||
|
||||
export interface ImmichImportJob {
|
||||
id: string;
|
||||
albumId: string;
|
||||
albumName: string;
|
||||
eventId: string | null;
|
||||
state: 'running' | 'done' | 'error';
|
||||
scheduled?: boolean;
|
||||
total: number;
|
||||
done: number;
|
||||
skipped: number;
|
||||
failed: number;
|
||||
bytes: number;
|
||||
message: string;
|
||||
errors: string[];
|
||||
startedAt: number;
|
||||
finishedAt: number | null;
|
||||
}
|
||||
|
||||
export interface ImmichTestResult {
|
||||
ok: boolean;
|
||||
url: string;
|
||||
version: string;
|
||||
major: number;
|
||||
albumCount: number;
|
||||
}
|
||||
|
||||
export interface ImmichPushResult {
|
||||
ok: boolean;
|
||||
assetId: string;
|
||||
alreadyPushed: boolean;
|
||||
/** True when the photo already existed in Immich and no upload was made. */
|
||||
skipped?: boolean;
|
||||
trashed: boolean;
|
||||
associations: Partial<Record<'albums' | 'stack' | 'favorite' | 'sidecar', boolean>>;
|
||||
warning: string;
|
||||
}
|
||||
|
||||
export interface AdminOverview {
|
||||
users: AdminUser[];
|
||||
events: AdminEvent[];
|
||||
@@ -426,6 +495,7 @@ export interface AdminOverview {
|
||||
storage: { root: string; defaultRoot: string; custom: boolean; diskBytes?: number };
|
||||
quotas: AdminQuota[];
|
||||
mail: MailStatus;
|
||||
immich: ImmichStatus;
|
||||
}
|
||||
|
||||
export interface StorageChange {
|
||||
@@ -576,6 +646,118 @@ export function adminSetStorage(root: string): Promise<StorageChange> {
|
||||
});
|
||||
}
|
||||
|
||||
export function adminSaveImmich(input: {
|
||||
url: string;
|
||||
apiKey?: string;
|
||||
enabled?: boolean;
|
||||
}): Promise<ImmichStatus> {
|
||||
return request<{ immich: ImmichStatus }>('/api/admin/immich', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
}).then((res) => res.immich);
|
||||
}
|
||||
|
||||
export function adminTestImmich(): Promise<ImmichTestResult> {
|
||||
return request<ImmichTestResult>('/api/admin/immich/test', { method: 'POST' });
|
||||
}
|
||||
|
||||
export function adminDisconnectImmich(): Promise<ImmichStatus> {
|
||||
return request<{ immich: ImmichStatus }>('/api/admin/immich', { method: 'DELETE' }).then(
|
||||
(res) => res.immich,
|
||||
);
|
||||
}
|
||||
|
||||
export function getImmichStatus(): Promise<ImmichStatus> {
|
||||
return request<{ immich: ImmichStatus }>('/api/immich').then((res) => res.immich);
|
||||
}
|
||||
|
||||
export function saveImmichSettings(input: {
|
||||
url: string;
|
||||
apiKey?: string;
|
||||
enabled?: boolean;
|
||||
autoSync?: boolean;
|
||||
syncMinutes?: number;
|
||||
trashOriginal?: boolean;
|
||||
syncMetadata?: boolean;
|
||||
}): Promise<ImmichStatus> {
|
||||
return request<{ immich: ImmichStatus }>('/api/immich', {
|
||||
method: 'PUT',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(input),
|
||||
}).then((res) => res.immich);
|
||||
}
|
||||
|
||||
export function disconnectImmich(): Promise<ImmichStatus> {
|
||||
return request<{ immich: ImmichStatus }>('/api/immich', { method: 'DELETE' }).then(
|
||||
(res) => res.immich,
|
||||
);
|
||||
}
|
||||
|
||||
export function testImmich(): Promise<ImmichTestResult> {
|
||||
return request<ImmichTestResult>('/api/immich/test', { method: 'POST' });
|
||||
}
|
||||
|
||||
export function pushImmichPhoto(photoId: string, jpegBase64: string): Promise<ImmichPushResult> {
|
||||
return request<ImmichPushResult>(
|
||||
`/api/immich/photos/${encodeURIComponent(photoId)}/push`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ jpeg: jpegBase64 }),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export interface ImmichQueueEntry {
|
||||
photoId: string;
|
||||
name: string;
|
||||
/** Upload the untouched original, or the current rendered edit. */
|
||||
mode: 'original' | 'edit';
|
||||
}
|
||||
|
||||
/** The manual push plan for an event: originals and edits changed since last push. */
|
||||
export function immichEventQueue(
|
||||
eventId: string,
|
||||
): Promise<{ queue: ImmichQueueEntry[]; total: number }> {
|
||||
return request(`/api/immich/events/${encodeURIComponent(eventId)}/queue`);
|
||||
}
|
||||
|
||||
export function publishImmichOriginal(photoId: string): Promise<ImmichPushResult> {
|
||||
return request(
|
||||
`/api/immich/photos/${encodeURIComponent(photoId)}/publish`,
|
||||
{ method: 'POST' },
|
||||
);
|
||||
}
|
||||
|
||||
export function createImmichEventAlbum(
|
||||
eventId: string,
|
||||
name: string,
|
||||
): Promise<{ album: ImmichAlbum; event: EventRecord }> {
|
||||
return request('/api/immich/albums', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ eventId, name }),
|
||||
});
|
||||
}
|
||||
|
||||
export function immichAlbums(): Promise<ImmichAlbum[]> {
|
||||
return request<{ albums: ImmichAlbum[] }>('/api/immich/albums').then((res) => res.albums ?? []);
|
||||
}
|
||||
|
||||
export function immichImportAlbum(albumId: string): Promise<ImmichImportJob> {
|
||||
return request<{ job: ImmichImportJob }>(
|
||||
`/api/immich/albums/${encodeURIComponent(albumId)}/import`,
|
||||
{ method: 'POST' },
|
||||
).then((res) => res.job);
|
||||
}
|
||||
|
||||
export function getImmichJob(jobId: string): Promise<ImmichImportJob> {
|
||||
return request<{ job: ImmichImportJob }>(
|
||||
`/api/immich/jobs/${encodeURIComponent(jobId)}`,
|
||||
).then((res) => res.job);
|
||||
}
|
||||
|
||||
export function pushPresets(presets: Preset[]): Promise<void> {
|
||||
return request('/api/presets', {
|
||||
method: 'PUT',
|
||||
|
||||
Reference in New Issue
Block a user