Move migration types to corresponding file

This commit is contained in:
schroda
2026-05-15 12:28:08 +02:00
parent 8840b88bc9
commit 7a5b5624e7
2 changed files with 38 additions and 32 deletions

View File

@@ -7,44 +7,24 @@
*/ */
import { requestManager } from '@/lib/requests/RequestManager.ts'; import { requestManager } from '@/lib/requests/RequestManager.ts';
import type { import type { SetChapterMetasItemInput } from '@/lib/graphql/generated/graphql.ts';
GetMangaToMigrateQuery,
GetMangaToMigrateToFetchMutation,
SetChapterMetasItemInput,
} from '@/lib/graphql/generated/graphql.ts';
import type { MangaIdInfo } from '@/features/manga/Manga.types.ts'; import type { MangaIdInfo } from '@/features/manga/Manga.types.ts';
import { Chapters } from '@/features/chapter/services/Chapters.ts'; import { Chapters } from '@/features/chapter/services/Chapters.ts';
import { ALL_APP_METADATA_KEY_PREFIXES } from '@/features/metadata/Metadata.constants.ts'; import { ALL_APP_METADATA_KEY_PREFIXES } from '@/features/metadata/Metadata.constants.ts';
import type { MigrateMode, MigrateOptions } from '@/features/migration/Migration.types.ts';
import type { import type {
ChapterBookmarkInfo, MangaToMigrate,
ChapterDownloadInfo, MangaToMigrateTo,
ChapterIdInfo, MigrateAction,
ChapterNumberInfo, MigrateActionCreator,
ChapterReadInfo, MigrateMode,
} from '@/features/chapter/Chapter.types.ts'; MigrateOptions,
import type { GqlMetaHolder } from '@/features/metadata/Metadata.types.ts'; MigrationChapter,
} from '@/features/migration/Migration.types.ts';
import { getMetadataServerSettings } from '@/features/settings/services/ServerSettingsMetadata.ts'; import { getMetadataServerSettings } from '@/features/settings/services/ServerSettingsMetadata.ts';
import { Queue } from '@/lib/Queue.ts'; import { Queue } from '@/lib/Queue.ts';
import type { TrackerIdInfo } from '@/features/tracker/Tracker.types.ts'; import type { TrackerIdInfo } from '@/features/tracker/Tracker.types.ts';
import { assertIsDefined } from '@/base/Asserts.ts'; import { assertIsDefined } from '@/base/Asserts.ts';
type MangaToMigrate = NonNullable<GetMangaToMigrateQuery['manga']>;
type MangaToMigrateTo = NonNullable<GetMangaToMigrateToFetchMutation['fetchManga']>['manga'];
export type MigrationChapter = ChapterIdInfo &
ChapterReadInfo &
ChapterBookmarkInfo &
ChapterNumberInfo &
ChapterDownloadInfo &
GqlMetaHolder;
type MigrateAction = { copy: () => Promise<unknown>[]; cleanup: () => Promise<unknown>[] };
type MigrateActionCreator = () => MigrateAction;
const performMigrationAction = async (migrateAction: keyof MigrateAction, ...actions: MigrateAction[]) =>
Promise.all(actions.flatMap((action) => action[migrateAction]()));
export class MangaMigration { export class MangaMigration {
private static trackerQueue = new Map<TrackerIdInfo['id'], Queue>(); private static trackerQueue = new Map<TrackerIdInfo['id'], Queue>();
@@ -94,7 +74,7 @@ export class MangaMigration {
// only happens in case the copy succeeded // only happens in case the copy succeeded
// oxlint-disable-next-line no-await-in-loop // oxlint-disable-next-line no-await-in-loop
await performMigrationAction(migrationAction, ...actions); await Promise.all(actions.flatMap((action) => action[migrationAction]()));
} }
}; };

View File

@@ -6,7 +6,11 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. * file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/ */
import type { GetMigratableSourcesQuery } from '@/lib/graphql/generated/graphql.ts'; import type {
GetMangaToMigrateQuery,
GetMangaToMigrateToFetchMutation,
GetMigratableSourcesQuery,
} from '@/lib/graphql/generated/graphql.ts';
import type { import type {
SourceDisplayNameInfo, SourceDisplayNameInfo,
SourceIconInfo, SourceIconInfo,
@@ -23,7 +27,14 @@ import type {
MangaThumbnailInfo, MangaThumbnailInfo,
MangaTitleInfo, MangaTitleInfo,
} from '@/features/manga/Manga.types.ts'; } from '@/features/manga/Manga.types.ts';
import type { ChapterNumberInfo } from '@/features/chapter/Chapter.types.ts'; import type {
ChapterBookmarkInfo,
ChapterDownloadInfo,
ChapterIdInfo,
ChapterNumberInfo,
ChapterReadInfo,
} from '@/features/chapter/Chapter.types.ts';
import type { GqlMetaHolder } from '@/features/metadata/Metadata.types.ts';
export enum SortBy { export enum SortBy {
SOURCE_NAME, SOURCE_NAME,
@@ -136,3 +147,18 @@ export interface SourceItem extends SourceIdInfo, SourceNameInfo, SourceLanguage
export type TMigratableSource = NonNullable<GetMigratableSourcesQuery['mangas']['nodes'][number]['source']> & { export type TMigratableSource = NonNullable<GetMigratableSourcesQuery['mangas']['nodes'][number]['source']> & {
mangaCount: number; mangaCount: number;
}; };
export type MangaToMigrate = NonNullable<GetMangaToMigrateQuery['manga']>;
export type MangaToMigrateTo = NonNullable<GetMangaToMigrateToFetchMutation['fetchManga']>['manga'];
export type MigrationChapter = ChapterIdInfo &
ChapterReadInfo &
ChapterBookmarkInfo &
ChapterNumberInfo &
ChapterDownloadInfo &
GqlMetaHolder;
export type MigrateAction = { copy: () => Promise<unknown>[]; cleanup: () => Promise<unknown>[] };
export type MigrateActionCreator = () => MigrateAction;