forked from TrafficGuard/typedai
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcodeTaskRepository.ts
More file actions
72 lines (64 loc) · 2.83 KB
/
codeTaskRepository.ts
File metadata and controls
72 lines (64 loc) · 2.83 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
71
72
import type { CodeTask, CodeTaskPreset, UpdateCodeTaskData } from '#shared/codeTask/codeTask.model';
/**
* Interface defining the persistence operations for Code tasks and presets.
*/
export interface CodeTaskRepository {
/**
* Saves a new CodeTask to the persistent store.
* Implementations should handle setting appropriate timestamps if not provided.
* @param codeTask The complete CodeTask object to save.
* @returns The ID of the saved codeTask.
* @throws Error if a codeTask with the same ID already exists.
*/
createCodeTask(codeTask: CodeTask): Promise<string>;
/**
* Retrieves a specific CodeTask by its ID for a given user.
* @param userId The ID of the user owning the codeTask.
* @param codeTaskId The ID of the CodeTask to retrieve.
* @returns The CodeTask if found and authorized, otherwise null.
*/
getCodeTask(userId: string, codeTaskId: string): Promise<CodeTask | null>;
/**
* Lists all CodeTasks for a specific user, ordered by creation date descending.
* @param userId The ID of the user whose codeTasks to list.
* @returns An array of CodeTasks.
*/
listCodeTasks(userId: string): Promise<CodeTask[]>;
/**
* Updates specified fields of an existing CodeTask.
* Implementations should handle updating the 'updatedAt' timestamp.
* @param userId The ID of the user owning the codeTask.
* @param codeTaskId The ID of the CodeTask to update.
* @param updates An object containing the fields to update.
* @throws Error if the codeTask is not found for the user.
*/
updateCodeTask(userId: string, codeTaskId: string, updates: UpdateCodeTaskData): Promise<void>;
/**
* Deletes a CodeTask by its ID for a given user.
* Should not throw an error if the codeTask doesn't exist.
* @param userId The ID of the user owning the codeTask.
* @param codeTaskId The ID of the CodeTask to delete.
*/
deleteCodeTask(userId: string, codeTaskId: string): Promise<void>;
/**
* Saves a new CodeTaskPreset to the persistent store.
* Implementations should handle setting appropriate timestamps if not provided.
* @param preset The complete CodeTaskPreset object to save.
* @returns The ID of the saved preset.
* @throws Error if a preset with the same ID already exists.
*/
saveCodeTaskPreset(preset: CodeTaskPreset): Promise<string>;
/**
* Lists all CodeTaskPresets for a specific user, ordered by creation date descending.
* @param userId The ID of the user whose presets to list.
* @returns An array of CodeTaskPresets.
*/
listCodeTaskPresets(userId: string): Promise<CodeTaskPreset[]>;
/**
* Deletes a CodeTaskPreset by its ID for a given user.
* Should not throw an error if the preset doesn't exist.
* @param userId The ID of the user owning the preset.
* @param presetId The ID of the CodeTaskPreset to delete.
*/
deleteCodeTaskPreset(userId: string, presetId: string): Promise<void>;
}