From a651d3d16f5ef58f372c3efaa1f49be78f2388ed Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Sun, 31 May 2026 17:49:59 +0300 Subject: [PATCH] refactor(font): absorb FetchFontsByIds store into Font entity FetchFontsByIds was data-access for the Font aggregate wearing a feature costume: a single FontsByIdsStore (BaseQueryStore over Font's proxy API), no UI, consumed only by comparisonStore. Move it beside fontCatalogStore in the Font entity, collapse its deep $entities/Font imports to relative paths, expose via the Font public API, and delete the feature slice. --- .../store/fontsByIdsStore/fontsByIdsStore.svelte.ts | 10 +++++----- .../store/fontsByIdsStore/fontsByIdsStore.test.ts | 10 +++++----- src/entities/Font/model/store/index.ts | 3 +++ src/features/FetchFontsByIds/index.ts | 1 - src/features/FetchFontsByIds/model/index.ts | 1 - .../model/stores/comparisonStore.svelte.ts | 2 +- 6 files changed, 14 insertions(+), 13 deletions(-) rename src/{features/FetchFontsByIds => entities/Font}/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts (93%) rename src/{features/FetchFontsByIds => entities/Font}/model/store/fontsByIdsStore/fontsByIdsStore.test.ts (97%) delete mode 100644 src/features/FetchFontsByIds/index.ts delete mode 100644 src/features/FetchFontsByIds/model/index.ts diff --git a/src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts b/src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts similarity index 93% rename from src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts rename to src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts index 7285768..a2cb585 100644 --- a/src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts +++ b/src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.svelte.ts @@ -1,14 +1,14 @@ +import { fontKeys } from '$shared/api/queryKeys'; +import { BaseQueryStore } from '$shared/lib'; import { fetchFontsByIds, seedFontCache, -} from '$entities/Font/api/proxy/proxyFonts'; +} from '../../../api/proxy/proxyFonts'; import { FontNetworkError, FontResponseError, -} from '$entities/Font/lib/errors/errors'; -import type { UnifiedFont } from '$entities/Font/model/types'; -import { fontKeys } from '$shared/api/queryKeys'; -import { BaseQueryStore } from '$shared/lib'; +} from '../../../lib/errors/errors'; +import type { UnifiedFont } from '../../types'; /** * Internal fetcher that seeds the cache and handles error wrapping. diff --git a/src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.test.ts b/src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.test.ts similarity index 97% rename from src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.test.ts rename to src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.test.ts index 7849535..0acf5a9 100644 --- a/src/features/FetchFontsByIds/model/store/fontsByIdsStore/fontsByIdsStore.test.ts +++ b/src/entities/Font/model/store/fontsByIdsStore/fontsByIdsStore.test.ts @@ -1,8 +1,3 @@ -import * as api from '$entities/Font/api/proxy/proxyFonts'; -import { - FontNetworkError, - FontResponseError, -} from '$entities/Font/lib/errors/errors'; import { queryClient } from '$shared/api/queryClient'; import { fontKeys } from '$shared/api/queryKeys'; import { @@ -12,6 +7,11 @@ import { it, vi, } from 'vitest'; +import * as api from '../../../api/proxy/proxyFonts'; +import { + FontNetworkError, + FontResponseError, +} from '../../../lib/errors/errors'; import { FontsByIdsStore } from './fontsByIdsStore.svelte'; describe('FontsByIdsStore', () => { diff --git a/src/entities/Font/model/store/index.ts b/src/entities/Font/model/store/index.ts index 97ebad0..52dda36 100644 --- a/src/entities/Font/model/store/index.ts +++ b/src/entities/Font/model/store/index.ts @@ -7,3 +7,6 @@ export { FontCatalogStore, fontCatalogStore, } from './fontCatalogStore/fontCatalogStore.svelte'; + +// Batch fetch by IDs (detail-cache seeding) +export { FontsByIdsStore } from './fontsByIdsStore/fontsByIdsStore.svelte'; diff --git a/src/features/FetchFontsByIds/index.ts b/src/features/FetchFontsByIds/index.ts deleted file mode 100644 index 600c651..0000000 --- a/src/features/FetchFontsByIds/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { FontsByIdsStore } from './model'; diff --git a/src/features/FetchFontsByIds/model/index.ts b/src/features/FetchFontsByIds/model/index.ts deleted file mode 100644 index c449f87..0000000 --- a/src/features/FetchFontsByIds/model/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { FontsByIdsStore } from './store/fontsByIdsStore/fontsByIdsStore.svelte'; diff --git a/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts b/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts index f43cce4..54b6ab3 100644 --- a/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts +++ b/src/widgets/ComparisonView/model/stores/comparisonStore.svelte.ts @@ -15,13 +15,13 @@ import { type FontLoadRequestConfig, + FontsByIdsStore, type UnifiedFont, fontCatalogStore, fontLifecycleManager, getFontUrl, } from '$entities/Font'; import { typographySettingsStore } from '$features/AdjustTypography/model'; -import { FontsByIdsStore } from '$features/FetchFontsByIds'; import { createPersistentStore } from '$shared/lib'; import { untrack } from 'svelte'; import { getPretextFontString } from '../../lib';