Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions sake/src/lib/server/application/composition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ import { DeleteDeviceUseCase } from '$lib/server/application/use-cases/DeleteDev
import { GetAppVersionUseCase } from '$lib/server/application/use-cases/GetAppVersionUseCase';
import { getActivatedSearchProviders } from '$lib/server/config/activatedProviders';
import { SEARCH_PROVIDER_IDS } from '$lib/types/Search/Provider';
import { MetadataAggregatorService } from '$lib/server/application/services/MetadataAggregatorService';
import { ExternalBookMetadataService } from '$lib/server/application/services/ExternalBookMetadataService';
import { GoogleBooksMetadataProvider } from '$lib/server/infrastructure/metadata-providers/googleBooksMetadataProvider';
import { OpenLibraryMetadataProvider } from '$lib/server/infrastructure/metadata-providers/openLibraryMetadataProvider';
import { ManagedBookCoverService } from '$lib/server/application/services/ManagedBookCoverService';
import { GetLibraryCoverUseCase } from '$lib/server/application/use-cases/GetLibraryCoverUseCase';
import { ImportLibraryBookCoverUseCase } from '$lib/server/application/use-cases/ImportLibraryBookCoverUseCase';
Expand Down Expand Up @@ -113,12 +117,22 @@ export const deviceProgressDownloadRepository = new DeviceProgressDownloadReposi
export const bookProgressHistoryRepository = new BookProgressHistoryRepository();
export const managedBookCoverService = new ManagedBookCoverService(storage);

export const baselineMetadataAggregator = new MetadataAggregatorService([
new GoogleBooksMetadataProvider(),
new OpenLibraryMetadataProvider()
]);
export const externalBookMetadataService = new ExternalBookMetadataService(
baselineMetadataAggregator
);

export const downloadBookUseCase = new DownloadBookUseCase(
zlibraryClient,
bookRepository,
storage,
() => DavUploadServiceFactory.createS3(),
managedBookCoverService
managedBookCoverService,
undefined,
externalBookMetadataService
);
export const queueDownloadUseCase = new QueueDownloadUseCase(downloadQueue);
export const queueSearchBookUseCase = new QueueSearchBookUseCase(downloadQueue);
Expand Down Expand Up @@ -152,7 +166,8 @@ export const getLibraryBookDetailUseCase = new GetLibraryBookDetailUseCase(
shelfRepository
);
export const refetchLibraryBookMetadataUseCase = new RefetchLibraryBookMetadataUseCase(
bookRepository
bookRepository,
externalBookMetadataService
);
export const getNewBooksForDeviceUseCase = new GetNewBooksForDeviceUseCase(bookRepository);
export const confirmDownloadUseCase = new ConfirmDownloadUseCase(deviceDownloadRepository);
Expand Down
61 changes: 61 additions & 0 deletions sake/src/lib/server/application/ports/MetadataProviderPort.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import type { ApiResult } from '$lib/server/http/api';
import type { MetadataProviderId } from '$lib/types/Metadata/Provider';

export interface MetadataQuery {
title?: string | null;
author?: string | null;
isbn?: string | null;
language?: string | null;
googleBooksId?: string | null;
openLibraryKey?: string | null;
hardcoverId?: string | null;
limit?: number;
}

export interface MetadataCoverCandidate {
url: string;
width?: number;
height?: number;
source: string;
}

export interface MetadataCandidate {
providerId: MetadataProviderId;
providerScore: number;
identifiers: {
isbn10: string | null;
isbn13: string | null;
asin: string | null;
googleBooksId: string | null;
openLibraryKey: string | null;
hardcoverId: string | null;
};
title: string;
subtitle: string | null;
authors: string[];
description: string | null;
descriptionFormat: 'text' | 'html' | 'markdown';
subjects: string[];
series: string | null;
seriesIndex: number | null;
publisher: string | null;
publishedDate: { year: number | null; month: number | null; day: number | null };
language: string | null;
pageCount: number | null;
covers: MetadataCoverCandidate[];
rating: { average: number | null; count: number | null };
sourceUrl: string | null;
}

export interface MetadataProviderCapabilities {
touchedFields: ReadonlySet<string>;
hasCover: boolean;
hasRating: boolean;
requiresIsbn: boolean;
}

export interface MetadataProviderPort {
readonly id: MetadataProviderId;
readonly capabilities: MetadataProviderCapabilities;
lookup(query: MetadataQuery): Promise<ApiResult<MetadataCandidate[]>>;
}
Loading
Loading