Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 5c8f93b

Browse files
committed
feat: add types for file objects
1 parent 57b5adc commit 5c8f93b

File tree

1 file changed

+29
-11
lines changed

1 file changed

+29
-11
lines changed

src/definitions/Comments.ts

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ export type UserCreatedProjectComment = {
2323
task_id?: undefined;
2424
project_id: number;
2525
content?: string;
26-
attachment?: object;
26+
attachment?: TodoistFile;
2727
};
2828

2929
export type UserCreatedTaskComment = {
3030
task_id: number;
3131
project_id?: undefined;
3232
content?: string;
33-
attachment?: object;
33+
attachment?: TodoistFile;
3434
};
3535

3636
export type CreatableComment = UserCreatedComment & {
@@ -41,28 +41,21 @@ export type CreatableComment = UserCreatedComment & {
4141

4242
export type APICommentObject = APIProjectCommentObject | APITaskCommentObject;
4343

44-
const myComment: APICommentObject = {
45-
id: 123456,
46-
posted: "",
47-
content: "",
48-
project_id: 123456,
49-
};
50-
5144
export type APIProjectCommentObject = {
5245
id: number;
5346
project_id: number;
5447
task_id?: undefined;
5548
posted: string;
5649
content: string;
57-
attachment?: object;
50+
attachment?: TodoistFile;
5851
};
5952
export type APITaskCommentObject = {
6053
id: number;
6154
task_id: number;
6255
project_id?: undefined;
6356
posted: string;
6457
content: string;
65-
attachment?: object;
58+
attachment?: TodoistFile;
6659
};
6760

6861
// See https://developer.todoist.com/rest/v1/#update-a-comment
@@ -73,3 +66,28 @@ export interface CommentUpdatableParameters {
7366
export type CommentSearchableParams =
7467
| { project_id: number; task_id?: undefined }
7568
| { task_id: number; project_id?: undefined };
69+
70+
export interface BaseFileProperties {
71+
file_name: string;
72+
file_size: number;
73+
file_type: string;
74+
file_url: string;
75+
upload_state?: "pending" | "completed";
76+
}
77+
78+
export interface ImageFileProperties {
79+
tn_l: [string, number, number];
80+
tn_m: [string, number, number];
81+
tn_s: [string, number, number];
82+
file_duration?: undefined;
83+
}
84+
85+
export interface AudioFileProperties {
86+
file_duration: number;
87+
tn_l?: undefined;
88+
tn_m?: undefined;
89+
tn_s?: undefined;
90+
}
91+
92+
export type TodoistFile = BaseFileProperties &
93+
(ImageFileProperties | AudioFileProperties);

0 commit comments

Comments
 (0)