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