Mark completed tasks across all 6 phases, document code-first router approach deviation, update Phase 6 plan with actual steps
6.1 KiB
6.1 KiB
Frontend Infrastructure Tooling — Tasks
Phase 1: ky Migration
- Доработать
shared/api/kyClient.ts: добавить normalizeEnvelope, request, kyApi, configureKyAuth - Экспортировать
kyApi(create экземпляр) иconfigureKyAuthиз kyClient - Перевести
entities/session/api/sessionApi.tsна kyApi - Перевести
entities/stock/api/stockApi.tsна kyApi - Перевести
entities/bond/api/bondApi.tsна kyApi - Перевести
entities/search/api/searchApi.tsна kyApi - Перевести
entities/portfolio/api/portfolioApi.tsна kyApi - Перевести
entities/broker-account/api/brokerAccountApi.tsна kyApi - Перевести
entities/broker-position/api/brokerPositionApi.tsна kyApi - Перевести
entities/broker-operation/api/brokerOperationApi.tsна kyApi - Перевести
entities/broker-event/api/brokerEventApi.tsна kyApi - Перевести
features/screener/api/screenerApi.tsна kyApi - Удалить
shared/api/client.ts - Заменить
configureAuth()наconfigureKyAuth()в SessionProvider npm run test— все тесты проходятnpm run build— сборка проходит
Phase 2: Biome Migration
- Research: проверить Biome plugin system на поддержку FSD/import-no-restricted-paths
- Установить
@biomejs/biome(devDependency) - Запустить
npx @biomejs/biome migrate eslint --write - Создать и настроить
biome.jsonпод проект - ESLint оставлен только для FSD-правил (
.eslintrc.cjs) - Удалить зависимости: prettier, @typescript-eslint/, eslint-plugin- (ESLint core пока нужен для FSD)
- Удалить
.prettierrcи.prettierignore— форматирование перешло к Biome - Обновить
package.json:lint→biome check src/ - Обновить
.gitea/workflows/ci.yml: заменить eslint на biome для frontend - Обновить pre-commit hook (lint-staged → biome + prettier)
- Прогнать
biome check --write src/ npm run test— все тесты проходятnpm run build— сборка проходит
Phase 3: Unify API Types
- Аудит импортов: entity API используют
types.ts(codegen) илиresponses.ts? - Переключить все импорты с
responses.tsнаtypes.ts(если типы есть в codegen) - Удалить
shared/api/responses.ts(после переключения) - normalizeEnvelope перенесён в
shared/api/kyClient.ts npm run build— сборка проходит
Phase 4: MSW Browser
- Создать
shared/lib/test/browser.ts(setupWorker из msw/browser) - Установить и прокинуть mockServiceWorker.js:
npx msw init public/ - Создать
shared/config/env.tsс чтением и экспортом VITE_API_MOCK + VITE_API_URL - В
main.tsx: приVITE_API_MOCK === 'true'запускатьworker.start() - Проверить:
VITE_API_MOCK=true npm run devбез бэкенда — приложение работает - Проверить:
VITE_API_MOCK=false npm run dev— запросы идут на бэкенд
Phase 5: Env Validation
- Разработать Zod-схему в
shared/config/env.tsдля всех VITE_* переменных - Валидация env выполняется при импорте (safeParse в модуле env.ts)
- Проверить: при отсутствии обязательной переменной — понятная ошибка
Phase 6: TanStack Router
Setup
- Установить
@tanstack/react-router,@tanstack/router-devtools Установить(решение: code-first, без плагина)@tanstack/router-plugin
Route files
- Создать
src/app/routing/routeTree.tsx— все маршруты (code-first)- root route + AppLayout
- index → HomePage
- stocks/$secid → StockPage
- bonds/$secid → BondPage
- screener → ScreenerPage
- login → LoginPage
- register → RegisterPage
- profile → ProfilePage (guard)
- portfolios → PortfoliosListPage (guard)
- portfolios/$id → PortfolioDetailPage (guard)
- broker → BrokerAccountsPage (guard)
- broker/$accountId → BrokerAccountOverviewPage (guard)
- broker/$accountId/shares → BrokerPositionsPage (guard)
- broker/$accountId/bonds → BrokerPositionsPage (guard)
- broker/$accountId/operations → BrokerOperationsPage (guard)
- broker/$accountId/events → BrokerEventsPage (guard)
Router integration
- Создать
app/routing/router.ts:createRouter()с Route Tree - Настроить
beforeLoadдля guard'ов (requireAuth) - Настроить loaders для предзагрузки (TanStack Query) — отложено
- Заменить
<BrowserRouter>+<Routes>→<RouterProvider>вApp.tsx
Replace imports
- Заменить
Link→@tanstack/react-routerLink по всему проекту - Заменить
useNavigate→@tanstack/react-router - Заменить
useParams→@tanstack/react-router - Заменить
useSearchParams→useSearchParamsCompat(временная обёртка) - Заменить
useLocation→@tanstack/react-router
Tests
- Заменить
MemoryRouterв тестах наcreateMemoryHistory+RouterProvider - Обновить тестовые утилиты (
test-utils.tsx) npm run test— все тесты проходят (125)npm run build— сборка проходит
Devtools
- Настроить
@tanstack/router-devtoolsв dev-режиме - Проверить навигацию по всем страницам вручную — отложено