Files
portal/app/resources/js/composables/mockReports.ts
T
Дмитрий b912724cf7 chore(frontend): Sprint 4 Phase C — bundle analyzer + dead-code cleanup (audit O-refactor-06)
- rollup-plugin-visualizer + script `npm run build:analyze` (env BUILD_ANALYZE=1)
  Output: storage/bundle-analyze.html (gzip + brotli sizes), gitignored.
- cross-env установлен для Windows-совместимости env-переменной build:analyze.
- knip + knip.config.ts (entry app.ts + router/index.ts; ignore *.story.vue + tests/).
  ВАЖНО: knip падает с oxc-parser ArrayBuffer fail на этой машине
  (Windows quirk feedback memory) — конфиг сохранён для будущих запусков на
  Linux/macOS CI. Dead-code search выполнен вручную через grep по composables/.
- Удалены 4 unused exports + 4 private helpers, инициируемых только ими:
  * mockReports.ts: MOCK_JOBS, QuotaInfo (interface), MOCK_QUOTA
  * reportsMapper.ts: reportTypes()
  * mockTenantDetail.ts: expandTenantDetail() + 4 SAMPLE_* consts
    (SAMPLE_USERS/SAMPLE_PROJECTS/SAMPLE_BALANCE_HISTORY/SAMPLE_ACTIVITY)
  * useCsvDownload.ts: csvEscape() — снят `export` (используется внутри файла)

ESLint + vue-tsc + Vitest 416/416 + build — зелёные.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-10 04:59:58 +03:00

49 lines
2.1 KiB
TypeScript

/**
* Mock-данные для ReportsView.
*
* На API будет:
* POST /api/reports — создать отчёт (job).
* GET /api/reports — список (`reports` table из schema v8.7).
* GET /api/reports/{id}/file — скачать готовый файл (S3-presigned).
* POST /api/reports/{id}/retry — retry-failed (CTO-6: 3 попытки / 7 дней / только owner).
*
* Соответствует ТЗ §6.6 + CTO-6/CTO-7 (квота 3 одновременных).
*/
export type ReportType = 'deals' | 'managers' | 'sources' | 'billing';
export type ReportFormat = 'csv' | 'xlsx' | 'json' | 'pdf';
export type ReportStatus = 'queued' | 'running' | 'done' | 'failed';
export interface ReportTypeOption {
id: ReportType;
name: string;
description: string;
}
export const REPORT_TYPES: ReportTypeOption[] = [
{ id: 'deals', name: 'Сделки · детально', description: 'все колонки, фильтры применены' },
{ id: 'managers', name: 'Менеджеры', description: 'конверсия, средний чек, время в воронке' },
{ id: 'sources', name: 'Источники', description: 'Я.Директ / VK / Avito / прямые' },
{ id: 'billing', name: 'Биллинг', description: 'пополнения, списания, возвраты' },
];
export const REPORT_FORMATS: { id: ReportFormat; label: string }[] = [
{ id: 'csv', label: 'CSV' },
{ id: 'xlsx', label: 'XLSX' },
{ id: 'json', label: 'JSON' },
{ id: 'pdf', label: 'PDF' },
];
export interface ReportJob {
id: number;
title: string;
format: ReportFormat;
status: ReportStatus;
sizeText: string | null; // '1.8 MB' / null
rowsText: string | null; // '412 строк' / null
timeText: string; // '14:21 → 14:23' / 'в работе · ~30 секунд' / 'позиция 1' / '2/3 попытки · ошибка S3 timeout · 12:14' / '6 дней назад'
progress: number | null; // 0..100 для running
attempt: number; // 1..3
error: string | null;
}