-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtasks.types.ts
More file actions
50 lines (44 loc) · 1.43 KB
/
Copy pathtasks.types.ts
File metadata and controls
50 lines (44 loc) · 1.43 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
import { SortOrder, TaskSortField } from './entities/task-sort.enum';
import { TaskStatus } from './entities/task-status.enum';
import { Task, TaskPriority } from './entities/task.entity';
import { CursorPayload } from './pagination/cursor.codec';
/**
* Domain query model — the storage-agnostic description of "which tasks, in
* what order, which page". The service builds this from the HTTP DTO; each
* repository implementation decides HOW to satisfy it (JS array ops in memory,
* `WHERE/ORDER BY/LIMIT` in SQL, an aggregation pipeline in Mongo …).
*
* Keeping this separate from the HTTP DTO means the data layer has zero
* knowledge of the web layer.
*/
export interface TaskFilter {
status?: TaskStatus;
priority?: TaskPriority;
tag?: string;
}
export interface TaskSort {
field: TaskSortField;
order: SortOrder;
}
export interface TaskPageRequest {
/** Decoded keyset anchor (the service decodes the opaque token before this). */
cursor?: CursorPayload;
limit?: number;
}
export interface TaskQuery {
filter: TaskFilter;
sort: TaskSort;
page: TaskPageRequest;
}
/** A page of tasks plus the cursor needed to fetch the next page. */
export interface TaskPage {
items: Task[];
nextCursor: string | null;
total: number;
}
/** Aggregate task counts grouped by status and by priority. */
export interface TaskStats {
total: number;
byStatus: Record<TaskStatus, number>;
byPriority: Record<TaskPriority, number>;
}