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

Commit cf75d20

Browse files
committed
BREAKING CHANGE: use native fetch, remove axios
1 parent 4b72871 commit cf75d20

File tree

14 files changed

+300
-333
lines changed

14 files changed

+300
-333
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"**/dist/**"
1616
],
1717
"dependencies": {
18-
"axios": "0.26.1",
1918
"uuid": "8.3.2"
2019
},
2120
"devDependencies": {
2221
"@types/jest": "27.4.1",
2322
"@types/uuid": "8.3.4",
23+
"@types/node": "17.0.25",
2424
"dotenv": "10.0.0",
2525
"jest": "27.5.1",
2626
"ts-jest": "27.1.4",
@@ -37,5 +37,8 @@
3737
"bugs": {
3838
"url": "https://github.com/dubisdev/todoist-rest-client/issues"
3939
},
40-
"homepage": "https://github.com/dubisdev/todoist-rest-client#readme"
40+
"homepage": "https://github.com/dubisdev/todoist-rest-client#readme",
41+
"engines": {
42+
"node": ">=18"
43+
}
4144
}

src/definitions/Client.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
11
import {
2-
TaskModule,
3-
ProjectModule,
4-
SectionModule,
5-
LabelModule,
6-
CommentModule,
7-
ExtrasModule,
2+
TaskModule,
3+
ProjectModule,
4+
SectionModule,
5+
LabelModule,
6+
CommentModule,
7+
ExtrasModule,
88
} from ".";
9-
import { AxiosRequestHeaders } from "axios";
109

11-
export interface AuthHeader extends AxiosRequestHeaders {
12-
Authorization: string;
10+
export interface AuthHeader {
11+
Authorization: string;
1312
}
1413

1514
export interface TDSClient {
16-
apiToken: string;
17-
task: TaskModule;
18-
project: ProjectModule;
19-
section: SectionModule;
20-
label: LabelModule;
21-
comment: CommentModule;
22-
extras: ExtrasModule;
15+
apiToken: string;
16+
task: TaskModule;
17+
project: ProjectModule;
18+
section: SectionModule;
19+
label: LabelModule;
20+
comment: CommentModule;
21+
extras: ExtrasModule;
2322
}
2423

2524
export interface ClientConstructor {
26-
(apiToken?: string): TDSClient;
25+
(apiToken?: string): TDSClient;
2726
}

src/definitions/Comments.ts

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,91 +1,89 @@
1-
import { AxiosResponse } from "axios";
2-
31
export interface CommentModule {
4-
get: (id: string | number) => Promise<APICommentObject>;
5-
create: (comment: CreatableComment) => Promise<APICommentObject>;
6-
delete: (id: number | string) => Promise<AxiosResponse>;
7-
getAll: (params: CommentSearchableParams) => Promise<APICommentObject[]>;
8-
update: (
9-
id: number | string,
10-
comment: CommentUpdatableParameters
11-
) => Promise<AxiosResponse>;
2+
get: (id: string | number) => Promise<APICommentObject>;
3+
create: (comment: CreatableComment) => Promise<APICommentObject>;
4+
delete: (id: number | string) => Promise<Response>;
5+
getAll: (params: CommentSearchableParams) => Promise<APICommentObject[]>;
6+
update: (
7+
id: number | string,
8+
comment: CommentUpdatableParameters
9+
) => Promise<Response>;
1210
}
1311

1412
/* CLIENT-LEVEL INTERFACES */
1513

1614
export type UserCreatedComment =
17-
| UserCreatedProjectComment
18-
| UserCreatedTaskComment;
15+
| UserCreatedProjectComment
16+
| UserCreatedTaskComment;
1917

2018
export type UserCreatedProjectComment = {
21-
task_id?: undefined;
22-
project_id: number;
23-
content?: string;
24-
attachment?: TodoistFile;
19+
task_id?: undefined;
20+
project_id: number;
21+
content?: string;
22+
attachment?: TodoistFile;
2523
};
2624

2725
export type UserCreatedTaskComment = {
28-
task_id: number;
29-
project_id?: undefined;
30-
content?: string;
31-
attachment?: TodoistFile;
26+
task_id: number;
27+
project_id?: undefined;
28+
content?: string;
29+
attachment?: TodoistFile;
3230
};
3331

3432
export type CreatableComment = UserCreatedComment & {
35-
content: string;
33+
content: string;
3634
};
3735

3836
/* API-LEVEL INTERFACES */
3937

4038
export type APICommentObject = APIProjectCommentObject | APITaskCommentObject;
4139

4240
export type APIProjectCommentObject = {
43-
id: number;
44-
project_id: number;
45-
task_id?: undefined;
46-
posted: string;
47-
content: string;
48-
attachment?: TodoistFile;
41+
id: number;
42+
project_id: number;
43+
task_id?: undefined;
44+
posted: string;
45+
content: string;
46+
attachment?: TodoistFile;
4947
};
5048
export type APITaskCommentObject = {
51-
id: number;
52-
task_id: number;
53-
project_id?: undefined;
54-
posted: string;
55-
content: string;
56-
attachment?: TodoistFile;
49+
id: number;
50+
task_id: number;
51+
project_id?: undefined;
52+
posted: string;
53+
content: string;
54+
attachment?: TodoistFile;
5755
};
5856

5957
// See https://developer.todoist.com/rest/v1/#update-a-comment
6058
export interface CommentUpdatableParameters {
61-
content: string;
59+
content: string;
6260
}
6361

6462
export type CommentSearchableParams =
65-
| { project_id: number; task_id?: undefined }
66-
| { task_id: number; project_id?: undefined };
63+
| { project_id: number; task_id?: undefined }
64+
| { task_id: number; project_id?: undefined };
6765

6866
export interface BaseFileProperties {
69-
file_name: string;
70-
file_size: number;
71-
file_type: string;
72-
file_url: string;
73-
upload_state?: "pending" | "completed";
67+
file_name: string;
68+
file_size: number;
69+
file_type: string;
70+
file_url: string;
71+
upload_state?: "pending" | "completed";
7472
}
7573

7674
export interface ImageFileProperties {
77-
tn_l: [string, number, number];
78-
tn_m: [string, number, number];
79-
tn_s: [string, number, number];
80-
file_duration?: undefined;
75+
tn_l: [string, number, number];
76+
tn_m: [string, number, number];
77+
tn_s: [string, number, number];
78+
file_duration?: undefined;
8179
}
8280

8381
export interface AudioFileProperties {
84-
file_duration: number;
85-
tn_l?: undefined;
86-
tn_m?: undefined;
87-
tn_s?: undefined;
82+
file_duration: number;
83+
tn_l?: undefined;
84+
tn_m?: undefined;
85+
tn_s?: undefined;
8886
}
8987

9088
export type TodoistFile = BaseFileProperties &
91-
(ImageFileProperties | AudioFileProperties);
89+
(ImageFileProperties | AudioFileProperties);

src/definitions/Labels.ts

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,43 @@
1-
import { AxiosResponse } from "axios";
21
import { TodoistAPIColors } from ".";
32

43
export interface LabelModule {
5-
create: (label: CreatableLabel) => Promise<APILabelObject>;
6-
delete: (id: number | string) => Promise<AxiosResponse>;
7-
getAll: () => Promise<APILabelObject[]>;
8-
get: (id: string | number) => Promise<APILabelObject>;
9-
update: (
10-
id: number | string,
11-
label: LabelUpdatableParameters
12-
) => Promise<AxiosResponse>;
4+
create: (label: CreatableLabel) => Promise<APILabelObject>;
5+
delete: (id: number | string) => Promise<Response>;
6+
getAll: () => Promise<APILabelObject[]>;
7+
get: (id: string | number) => Promise<APILabelObject>;
8+
update: (
9+
id: number | string,
10+
label: LabelUpdatableParameters
11+
) => Promise<Response>;
1312
}
1413

1514
/* CLIENT-LEVEL INTERFACES */
1615

1716
export interface UserCreatedLabel {
18-
name?: string;
19-
order?: number;
20-
color?: TodoistAPIColors;
21-
favorite?: boolean;
17+
name?: string;
18+
order?: number;
19+
color?: TodoistAPIColors;
20+
favorite?: boolean;
2221
}
2322

2423
export interface CreatableLabel extends UserCreatedLabel {
25-
name: string;
24+
name: string;
2625
}
2726

2827
/* API-LEVEL INTERFACES */
2928

3029
export interface APILabelObject {
31-
id: number;
32-
name: string;
33-
color: TodoistAPIColors;
34-
order: number;
35-
favorite: boolean;
30+
id: number;
31+
name: string;
32+
color: TodoistAPIColors;
33+
order: number;
34+
favorite: boolean;
3635
}
3736

3837
// See https://developer.todoist.com/rest/v1/#update-a-label
3938
export interface LabelUpdatableParameters {
40-
name?: string;
41-
color?: TodoistAPIColors;
42-
order?: number;
43-
favorite?: boolean;
39+
name?: string;
40+
color?: TodoistAPIColors;
41+
order?: number;
42+
favorite?: boolean;
4443
}

0 commit comments

Comments
 (0)