-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
70 lines (59 loc) · 2.13 KB
/
Copy pathindex.ts
File metadata and controls
70 lines (59 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import type { Bookmark, BrowserType } from '@dookmark/extension-bridge';
export const ACTIVITY_TYPES = ['CREATE', 'EDIT', 'DELETE', 'VISIT'] as const;
export type ActivityType = (typeof ACTIVITY_TYPES)[number];
export const DASHBOARD_PERIODS = [7, 30, 90, 365] as const;
export type DashboardPeriod = (typeof DASHBOARD_PERIODS)[number];
export interface DashboardCards {
totalBookmarks: number;
favorites: number;
totalVisits: number; // 선택 기간 내 방문 수
deltas: {
// 직전 동일 기간 대비 증감률(%). 비교 기준이 없으면(즐겨찾기) null.
bookmarks: number | null;
favorites: number | null;
visits: number | null;
};
}
export interface TrendPoint {
month: string; // YYYY-MM
added: number; // Bookmark.createdAt 기준 (과거 데이터 즉시 반영)
visits: number; // ActivityEvent VISIT 기준 (누적되며 채워짐)
}
export interface BrowserSlice {
browser: BrowserType;
count: number;
percent: number;
}
// 북마크의 부분집합 + 집계 필드 (원본 DBBookmark에서 Pick 해 필드 일관성 유지)
export type PopularBookmark = Pick<Bookmark, 'id' | 'title' | 'url'> & {
visits: number;
};
export type RecentBookmark = Pick<Bookmark, 'id' | 'title' | 'url'> & {
createdAt: string; // 와이어(JSON) 형태이므로 string
isFavorite: boolean;
};
export type TopFolder = Pick<Bookmark, 'id' | 'title'> & {
childCount: number;
};
export interface DashboardResponse {
period: DashboardPeriod;
cards: DashboardCards;
activityTrend: TrendPoint[];
browserDistribution: BrowserSlice[];
popularBookmarks: PopularBookmark[];
recentBookmarks: RecentBookmark[];
topFolders: TopFolder[];
summary: {
avgVisits: number; // 기간 내 방문 수 / 전체 북마크 수
totalFolders: number;
};
}
// 잔디 하루치 — 활동 종류를 소문자 키로 도출(Record + Lowercase)해 종류 추가 시 자동 반영
export type HeatmapDay = { date: string; total: number } & Record<
Lowercase<ActivityType>,
number
>;
export interface HeatmapResponse {
year: number;
days: HeatmapDay[]; // 활동이 있는 날짜만 반환(프론트가 격자를 채움)
}