Этап 1: каркас монорепо, Docker Compose, Prisma-схема, healthcheck
- pnpm workspaces: apps/web, apps/api, packages/md, packages/shared - docker compose: db (PostgreSQL 16), api, web (nginx) - Prisma-схема и первая миграция (pg_trgm, GIN-индексы поиска) - GET /api/health, ESLint + Prettier, .env.example, README Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
9ed4d4ce43
commit
521533a8e3
@@ -0,0 +1,159 @@
|
||||
// Общие типы API: их импортируют и сервер, и клиент, чтобы формат ответов не расходился.
|
||||
|
||||
export type Role = 'ADMIN' | 'EDITOR' | 'VIEWER';
|
||||
export type ArticleStatus = 'DRAFT' | 'PUBLISHED';
|
||||
export type Visibility = 'PRIVATE' | 'PUBLIC';
|
||||
|
||||
/** Ключ цвета плашки раздела. Сами цвета лежат в CSS-токенах (--plq-*). */
|
||||
export type PlaqueColor = 'yellow' | 'orange' | 'blue' | 'green' | 'ink';
|
||||
export const PLAQUE_COLORS: PlaqueColor[] = ['yellow', 'orange', 'blue', 'green', 'ink'];
|
||||
|
||||
export interface HealthResponse {
|
||||
status: 'ok';
|
||||
db: 'ok';
|
||||
time: string;
|
||||
}
|
||||
|
||||
export interface UserDto {
|
||||
id: string;
|
||||
email: string;
|
||||
name: string;
|
||||
role: Role;
|
||||
}
|
||||
|
||||
export interface SpaceDto {
|
||||
id: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
icon: string | null;
|
||||
order: number;
|
||||
}
|
||||
|
||||
export interface SectionDto {
|
||||
id: string;
|
||||
spaceId: string;
|
||||
name: string;
|
||||
slug: string;
|
||||
/** Короткий код на плашке: «ВВ», «ВОК». */
|
||||
code: string;
|
||||
color: PlaqueColor;
|
||||
icon: string | null;
|
||||
order: number;
|
||||
}
|
||||
|
||||
/** Статья в списках: без тела. */
|
||||
export interface ArticleListItem {
|
||||
id: string;
|
||||
slug: string;
|
||||
title: string;
|
||||
summary: string;
|
||||
sectionId: string;
|
||||
order: number;
|
||||
tags: string[];
|
||||
equipment: string[];
|
||||
docCode: string | null;
|
||||
pinned: boolean;
|
||||
status: ArticleStatus;
|
||||
visibility: Visibility;
|
||||
version: number;
|
||||
updatedAt: string;
|
||||
/** Сколько рисунков в статье и сколько они весят (для «Скачать раздел»). */
|
||||
imageCount: number;
|
||||
bytes: number;
|
||||
}
|
||||
|
||||
export interface AttachmentDto {
|
||||
id: string;
|
||||
filename: string;
|
||||
url: string;
|
||||
size: number;
|
||||
}
|
||||
|
||||
export interface FactDto {
|
||||
/** Подпись: «Запас при зачистке кабеля». */
|
||||
label: string;
|
||||
/** Значение с **жирным** в Markdown-разметке. */
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface ArticleDto extends ArticleListItem {
|
||||
bodyMd: string;
|
||||
bodyHtml: string;
|
||||
attachments: AttachmentDto[];
|
||||
/** Адреса картинок статьи (полные и превью): нужны для офлайн-кеша. */
|
||||
images: string[];
|
||||
authorName: string | null;
|
||||
}
|
||||
|
||||
/** Всё дерево одним запросом: его хватает для главной, меню и офлайна. */
|
||||
export interface TreeResponse {
|
||||
spaces: SpaceDto[];
|
||||
sections: SectionDto[];
|
||||
articles: ArticleListItem[];
|
||||
}
|
||||
|
||||
export interface Highlight {
|
||||
t: string;
|
||||
hit: boolean;
|
||||
}
|
||||
|
||||
export interface SearchFact {
|
||||
value: Highlight[];
|
||||
label: Highlight[];
|
||||
articleSlug: string;
|
||||
articleTitle: string;
|
||||
}
|
||||
|
||||
export interface SearchArticle {
|
||||
slug: string;
|
||||
title: Highlight[];
|
||||
section: string;
|
||||
sectionId: string;
|
||||
snippet: Highlight[];
|
||||
pinned: boolean;
|
||||
}
|
||||
|
||||
export interface SearchResponse {
|
||||
q: string;
|
||||
facts: SearchFact[];
|
||||
articles: SearchArticle[];
|
||||
}
|
||||
|
||||
export interface RevisionDto {
|
||||
id: string;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
authorName: string | null;
|
||||
comment: string | null;
|
||||
}
|
||||
|
||||
export interface AdminUserDto extends UserDto {
|
||||
blocked: boolean;
|
||||
createdAt: string;
|
||||
lastSeenAt: string | null;
|
||||
}
|
||||
|
||||
export interface InviteDto {
|
||||
id: string;
|
||||
token: string;
|
||||
role: Role;
|
||||
expiresAt: string;
|
||||
usedAt: string | null;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export const ROLE_LABEL: Record<Role, string> = {
|
||||
ADMIN: 'Админ',
|
||||
EDITOR: 'Редактор',
|
||||
VIEWER: 'Читатель',
|
||||
};
|
||||
|
||||
/** Русское склонение: plural(3, ['статья','статьи','статей']) → «статьи». */
|
||||
export function plural(n: number, forms: [string, string, string]): string {
|
||||
const a = Math.abs(n) % 100;
|
||||
const b = a % 10;
|
||||
if (a > 10 && a < 20) return forms[2];
|
||||
if (b > 1 && b < 5) return forms[1];
|
||||
if (b === 1) return forms[0];
|
||||
return forms[2];
|
||||
}
|
||||
Reference in New Issue
Block a user