@doist/todoist-api-typescript 4.0.0-alpha.2 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TodoistApi.d.ts +246 -9
- package/dist/TodoistApi.js +319 -25
- package/dist/authentication.d.ts +78 -4
- package/dist/authentication.js +58 -0
- package/dist/consts/endpoints.d.ts +2 -1
- package/dist/consts/endpoints.js +2 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/restClient.d.ts +1 -1
- package/dist/restClient.js +2 -2
- package/dist/testUtils/asserts.d.ts +0 -1
- package/dist/testUtils/asserts.js +1 -65
- package/dist/testUtils/testDefaults.d.ts +2 -2
- package/dist/types/entities.d.ts +477 -178
- package/dist/types/entities.js +107 -88
- package/dist/types/requests.d.ts +147 -29
- package/dist/types/sync.d.ts +21 -0
- package/dist/types/sync.js +2 -0
- package/dist/utils/colors.d.ts +14 -0
- package/dist/utils/colors.js +14 -0
- package/dist/utils/sanitization.d.ts +29 -0
- package/dist/utils/sanitization.js +29 -0
- package/dist/utils/taskConverters.js +1 -1
- package/dist/utils/validators.d.ts +1 -1
- package/dist/utils/validators.js +7 -7
- package/package.json +10 -10
package/dist/types/entities.js
CHANGED
|
@@ -1,98 +1,117 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
exports.
|
|
6
|
-
|
|
7
|
-
isRecurring:
|
|
8
|
-
string:
|
|
9
|
-
date:
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
exports.Duration = (0, runtypes_1.Record)({
|
|
16
|
-
amount: runtypes_1.Number.withConstraint(function (n) { return n > 0 || 'Value should be greater than zero'; }),
|
|
17
|
-
unit: (0, runtypes_1.Union)((0, runtypes_1.Literal)('minute'), (0, runtypes_1.Literal)('day')),
|
|
3
|
+
exports.ColorSchema = exports.UserSchema = exports.CommentSchema = exports.AttachmentSchema = exports.LabelSchema = exports.SectionSchema = exports.ProjectSchema = exports.TaskSchema = exports.DeadlineSchema = exports.DurationSchema = exports.DueDateSchema = void 0;
|
|
4
|
+
var zod_1 = require("zod");
|
|
5
|
+
exports.DueDateSchema = zod_1.z
|
|
6
|
+
.object({
|
|
7
|
+
isRecurring: zod_1.z.boolean(),
|
|
8
|
+
string: zod_1.z.string(),
|
|
9
|
+
date: zod_1.z.string(),
|
|
10
|
+
})
|
|
11
|
+
.extend({
|
|
12
|
+
datetime: zod_1.z.string().nullable().optional(),
|
|
13
|
+
timezone: zod_1.z.string().nullable().optional(),
|
|
14
|
+
lang: zod_1.z.string().nullable().optional(),
|
|
18
15
|
});
|
|
19
|
-
exports.
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
exports.DurationSchema = zod_1.z.object({
|
|
17
|
+
amount: zod_1.z.number().positive('Value should be greater than zero'),
|
|
18
|
+
unit: zod_1.z.enum(['minute', 'day']),
|
|
22
19
|
});
|
|
23
|
-
exports.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
assigneeId: runtypes_1.String.Or(runtypes_1.Null),
|
|
27
|
-
projectId: runtypes_1.String,
|
|
28
|
-
sectionId: runtypes_1.String.Or(runtypes_1.Null),
|
|
29
|
-
parentId: runtypes_1.String.Or(runtypes_1.Null),
|
|
30
|
-
order: exports.Int,
|
|
31
|
-
content: runtypes_1.String,
|
|
32
|
-
description: runtypes_1.String,
|
|
33
|
-
isCompleted: runtypes_1.Boolean,
|
|
34
|
-
labels: (0, runtypes_1.Array)(runtypes_1.String),
|
|
35
|
-
priority: exports.Int,
|
|
36
|
-
commentCount: exports.Int,
|
|
37
|
-
creatorId: runtypes_1.String,
|
|
38
|
-
createdAt: runtypes_1.String,
|
|
39
|
-
due: exports.DueDate.Or(runtypes_1.Null),
|
|
40
|
-
url: runtypes_1.String,
|
|
41
|
-
duration: exports.Duration.Or(runtypes_1.Null),
|
|
42
|
-
deadline: exports.Deadline.Or(runtypes_1.Null),
|
|
20
|
+
exports.DeadlineSchema = zod_1.z.object({
|
|
21
|
+
date: zod_1.z.string(),
|
|
22
|
+
lang: zod_1.z.string(),
|
|
43
23
|
});
|
|
44
|
-
exports.
|
|
45
|
-
id:
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
24
|
+
exports.TaskSchema = zod_1.z.object({
|
|
25
|
+
id: zod_1.z.string(),
|
|
26
|
+
assignerId: zod_1.z.string().nullable(),
|
|
27
|
+
assigneeId: zod_1.z.string().nullable(),
|
|
28
|
+
projectId: zod_1.z.string(),
|
|
29
|
+
sectionId: zod_1.z.string().nullable(),
|
|
30
|
+
parentId: zod_1.z.string().nullable(),
|
|
31
|
+
order: zod_1.z.number().int(),
|
|
32
|
+
content: zod_1.z.string(),
|
|
33
|
+
description: zod_1.z.string(),
|
|
34
|
+
isCompleted: zod_1.z.boolean(),
|
|
35
|
+
labels: zod_1.z.array(zod_1.z.string()),
|
|
36
|
+
priority: zod_1.z.number().int(),
|
|
37
|
+
commentCount: zod_1.z.number().int(),
|
|
38
|
+
creatorId: zod_1.z.string(),
|
|
39
|
+
createdAt: zod_1.z.string(),
|
|
40
|
+
due: exports.DueDateSchema.nullable(),
|
|
41
|
+
url: zod_1.z.string(),
|
|
42
|
+
duration: exports.DurationSchema.nullable(),
|
|
43
|
+
deadline: exports.DeadlineSchema.nullable(),
|
|
57
44
|
});
|
|
58
|
-
exports.
|
|
59
|
-
id:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
45
|
+
exports.ProjectSchema = zod_1.z.object({
|
|
46
|
+
id: zod_1.z.string(),
|
|
47
|
+
parentId: zod_1.z.string().nullable(),
|
|
48
|
+
order: zod_1.z.number().int().nullable(),
|
|
49
|
+
color: zod_1.z.string(),
|
|
50
|
+
name: zod_1.z.string(),
|
|
51
|
+
commentCount: zod_1.z.number().int(),
|
|
52
|
+
isShared: zod_1.z.boolean(),
|
|
53
|
+
isFavorite: zod_1.z.boolean(),
|
|
54
|
+
isInboxProject: zod_1.z.boolean(),
|
|
55
|
+
isTeamInbox: zod_1.z.boolean(),
|
|
56
|
+
url: zod_1.z.string(),
|
|
57
|
+
viewStyle: zod_1.z.string(),
|
|
63
58
|
});
|
|
64
|
-
exports.
|
|
65
|
-
id:
|
|
66
|
-
order:
|
|
67
|
-
name:
|
|
68
|
-
|
|
69
|
-
isFavorite: runtypes_1.Boolean,
|
|
59
|
+
exports.SectionSchema = zod_1.z.object({
|
|
60
|
+
id: zod_1.z.string(),
|
|
61
|
+
order: zod_1.z.number().int(),
|
|
62
|
+
name: zod_1.z.string(),
|
|
63
|
+
projectId: zod_1.z.string(),
|
|
70
64
|
});
|
|
71
|
-
exports.
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
fileUrl: runtypes_1.String.Or(runtypes_1.Null),
|
|
78
|
-
fileDuration: exports.Int.Or(runtypes_1.Null),
|
|
79
|
-
uploadState: (0, runtypes_1.Union)((0, runtypes_1.Literal)('pending'), (0, runtypes_1.Literal)('completed')).Or(runtypes_1.Null),
|
|
80
|
-
image: runtypes_1.String.Or(runtypes_1.Null),
|
|
81
|
-
imageWidth: exports.Int.Or(runtypes_1.Null),
|
|
82
|
-
imageHeight: exports.Int.Or(runtypes_1.Null),
|
|
83
|
-
url: runtypes_1.String.Or(runtypes_1.Null),
|
|
84
|
-
title: runtypes_1.String.Or(runtypes_1.Null),
|
|
85
|
-
}));
|
|
86
|
-
exports.Comment = (0, runtypes_1.Record)({
|
|
87
|
-
id: runtypes_1.String,
|
|
88
|
-
taskId: runtypes_1.String.Or(runtypes_1.Null),
|
|
89
|
-
projectId: runtypes_1.String.Or(runtypes_1.Null),
|
|
90
|
-
content: runtypes_1.String,
|
|
91
|
-
postedAt: runtypes_1.String,
|
|
92
|
-
attachment: exports.Attachment.Or(runtypes_1.Null),
|
|
65
|
+
exports.LabelSchema = zod_1.z.object({
|
|
66
|
+
id: zod_1.z.string(),
|
|
67
|
+
order: zod_1.z.number().int().nullable(),
|
|
68
|
+
name: zod_1.z.string(),
|
|
69
|
+
color: zod_1.z.string(),
|
|
70
|
+
isFavorite: zod_1.z.boolean(),
|
|
93
71
|
});
|
|
94
|
-
exports.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
72
|
+
exports.AttachmentSchema = zod_1.z
|
|
73
|
+
.object({
|
|
74
|
+
resourceType: zod_1.z.string(),
|
|
75
|
+
})
|
|
76
|
+
.extend({
|
|
77
|
+
fileName: zod_1.z.string().nullable().optional(),
|
|
78
|
+
fileSize: zod_1.z.number().int().nullable().optional(),
|
|
79
|
+
fileType: zod_1.z.string().nullable().optional(),
|
|
80
|
+
fileUrl: zod_1.z.string().nullable().optional(),
|
|
81
|
+
fileDuration: zod_1.z.number().int().nullable().optional(),
|
|
82
|
+
uploadState: zod_1.z.enum(['pending', 'completed']).nullable().optional(),
|
|
83
|
+
image: zod_1.z.string().nullable().optional(),
|
|
84
|
+
imageWidth: zod_1.z.number().int().nullable().optional(),
|
|
85
|
+
imageHeight: zod_1.z.number().int().nullable().optional(),
|
|
86
|
+
url: zod_1.z.string().nullable().optional(),
|
|
87
|
+
title: zod_1.z.string().nullable().optional(),
|
|
88
|
+
});
|
|
89
|
+
exports.CommentSchema = zod_1.z.object({
|
|
90
|
+
id: zod_1.z.string(),
|
|
91
|
+
taskId: zod_1.z.string().nullable(),
|
|
92
|
+
projectId: zod_1.z.string().nullable(),
|
|
93
|
+
content: zod_1.z.string(),
|
|
94
|
+
postedAt: zod_1.z.string(),
|
|
95
|
+
attachment: exports.AttachmentSchema.nullable(),
|
|
96
|
+
});
|
|
97
|
+
exports.UserSchema = zod_1.z.object({
|
|
98
|
+
id: zod_1.z.string(),
|
|
99
|
+
name: zod_1.z.string(),
|
|
100
|
+
email: zod_1.z.string(),
|
|
101
|
+
});
|
|
102
|
+
exports.ColorSchema = zod_1.z.object({
|
|
103
|
+
/** @deprecated No longer used */
|
|
104
|
+
id: zod_1.z.number(),
|
|
105
|
+
/** The key of the color (i.e. 'berry_red') */
|
|
106
|
+
key: zod_1.z.string(),
|
|
107
|
+
/** The display name of the color (i.e. 'Berry Red') */
|
|
108
|
+
displayName: zod_1.z.string(),
|
|
109
|
+
/** @deprecated Use {@link Color.displayName} instead */
|
|
110
|
+
name: zod_1.z.string(),
|
|
111
|
+
/** The hex value of the color (i.e. '#b8255f') */
|
|
112
|
+
hexValue: zod_1.z.string(),
|
|
113
|
+
/**
|
|
114
|
+
* @deprecated Use {@link Color.hexValue} instead
|
|
115
|
+
*/
|
|
116
|
+
value: zod_1.z.string(),
|
|
98
117
|
});
|
package/dist/types/requests.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { RequireAllOrNone, RequireOneOrNone, RequireExactlyOne } from 'type-fest';
|
|
2
|
-
import type { Comment, Duration, Label, Project, ProjectViewStyle, Section, Task, User } from './entities';
|
|
2
|
+
import type { Comment, Deadline, DueDate, Duration, Label, Project, ProjectViewStyle, Section, Task, User } from './entities';
|
|
3
|
+
/**
|
|
4
|
+
* @see https://developer.todoist.com/rest/v2/#create-a-new-task
|
|
5
|
+
*/
|
|
3
6
|
export type AddTaskArgs = {
|
|
4
7
|
content: string;
|
|
5
8
|
description?: string;
|
|
@@ -21,13 +24,9 @@ export type AddTaskArgs = {
|
|
|
21
24
|
duration?: Duration['amount'];
|
|
22
25
|
durationUnit?: Duration['unit'];
|
|
23
26
|
}>;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
reminder?: string;
|
|
28
|
-
autoReminder?: boolean;
|
|
29
|
-
meta?: boolean;
|
|
30
|
-
};
|
|
27
|
+
/**
|
|
28
|
+
* @see https://developer.todoist.com/rest/v2/#tasks
|
|
29
|
+
*/
|
|
31
30
|
export type GetTasksArgs = {
|
|
32
31
|
projectId?: string;
|
|
33
32
|
sectionId?: string;
|
|
@@ -38,10 +37,16 @@ export type GetTasksArgs = {
|
|
|
38
37
|
cursor?: string | null;
|
|
39
38
|
limit?: number;
|
|
40
39
|
};
|
|
40
|
+
/**
|
|
41
|
+
* @see https://developer.todoist.com/rest/v2/#tasks
|
|
42
|
+
*/
|
|
41
43
|
export type GetTasksResponse = {
|
|
42
44
|
results: Task[];
|
|
43
45
|
nextCursor: string | null;
|
|
44
46
|
};
|
|
47
|
+
/**
|
|
48
|
+
* @see https://developer.todoist.com/rest/v2/#update-a-task
|
|
49
|
+
*/
|
|
45
50
|
export type UpdateTaskArgs = {
|
|
46
51
|
content?: string;
|
|
47
52
|
description?: string;
|
|
@@ -59,14 +64,67 @@ export type UpdateTaskArgs = {
|
|
|
59
64
|
duration?: Duration['amount'];
|
|
60
65
|
durationUnit?: Duration['unit'];
|
|
61
66
|
}>;
|
|
67
|
+
/**
|
|
68
|
+
* @see https://developer.todoist.com/rest/v2/#quick-add-task
|
|
69
|
+
*/
|
|
70
|
+
export type QuickAddTaskArgs = {
|
|
71
|
+
text: string;
|
|
72
|
+
note?: string;
|
|
73
|
+
reminder?: string;
|
|
74
|
+
autoReminder?: boolean;
|
|
75
|
+
meta?: boolean;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* @see https://developer.todoist.com/rest/v2/#quick-add-task
|
|
79
|
+
*/
|
|
80
|
+
export type SyncTask = {
|
|
81
|
+
id: string;
|
|
82
|
+
projectId: string;
|
|
83
|
+
content: string;
|
|
84
|
+
description: string;
|
|
85
|
+
priority: number;
|
|
86
|
+
sectionId: string | null;
|
|
87
|
+
parentId: string | null;
|
|
88
|
+
childOrder: number;
|
|
89
|
+
labels: string[];
|
|
90
|
+
assignedByUid: string | null;
|
|
91
|
+
responsibleUid: string | null;
|
|
92
|
+
checked: boolean;
|
|
93
|
+
addedAt: string;
|
|
94
|
+
addedByUid: string | null;
|
|
95
|
+
duration: Duration | null;
|
|
96
|
+
due: DueDate | null;
|
|
97
|
+
deadline: Deadline | null;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* @see https://developer.todoist.com/rest/v2/#quick-add-task
|
|
101
|
+
*/
|
|
102
|
+
export type QuickAddTaskResponse = SyncTask;
|
|
103
|
+
/**
|
|
104
|
+
* @see https://developer.todoist.com/sync/v9/#move-an-item
|
|
105
|
+
*/
|
|
106
|
+
export type MoveTaskArgs = RequireExactlyOne<{
|
|
107
|
+
projectId?: string;
|
|
108
|
+
sectionId?: string;
|
|
109
|
+
parentId?: string;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-projects
|
|
113
|
+
*/
|
|
62
114
|
export type GetProjectsArgs = {
|
|
63
115
|
cursor?: string | null;
|
|
64
116
|
limit?: number;
|
|
65
117
|
};
|
|
118
|
+
/**
|
|
119
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-projects
|
|
120
|
+
*/
|
|
66
121
|
export type GetProjectsResponse = {
|
|
67
122
|
results: Project[];
|
|
68
123
|
nextCursor: string | null;
|
|
69
124
|
};
|
|
125
|
+
/**
|
|
126
|
+
* @see https://developer.todoist.com/rest/v2/#create-a-new-project
|
|
127
|
+
*/
|
|
70
128
|
export type AddProjectArgs = {
|
|
71
129
|
name: string;
|
|
72
130
|
parentId?: string;
|
|
@@ -74,73 +132,146 @@ export type AddProjectArgs = {
|
|
|
74
132
|
isFavorite?: boolean;
|
|
75
133
|
viewStyle?: ProjectViewStyle;
|
|
76
134
|
};
|
|
135
|
+
/**
|
|
136
|
+
* @see https://developer.todoist.com/rest/v2/#update-a-project
|
|
137
|
+
*/
|
|
77
138
|
export type UpdateProjectArgs = {
|
|
78
139
|
name?: string;
|
|
79
140
|
color?: string;
|
|
80
141
|
isFavorite?: boolean;
|
|
81
142
|
viewStyle?: ProjectViewStyle;
|
|
82
143
|
};
|
|
144
|
+
/**
|
|
145
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-collaborators
|
|
146
|
+
*/
|
|
83
147
|
export type GetProjectCollaboratorsArgs = {
|
|
84
148
|
cursor?: string | null;
|
|
85
149
|
limit?: number;
|
|
86
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-collaborators
|
|
153
|
+
*/
|
|
87
154
|
export type GetProjectCollaboratorsResponse = {
|
|
88
155
|
results: User[];
|
|
89
156
|
nextCursor: string | null;
|
|
90
157
|
};
|
|
158
|
+
/**
|
|
159
|
+
* @see https://developer.todoist.com/rest/v2/#sections
|
|
160
|
+
*/
|
|
91
161
|
export type GetSectionsArgs = {
|
|
92
162
|
projectId: string | null;
|
|
93
163
|
cursor?: string | null;
|
|
94
164
|
limit?: number;
|
|
95
165
|
};
|
|
166
|
+
/**
|
|
167
|
+
* @see https://developer.todoist.com/rest/v2/#sections
|
|
168
|
+
*/
|
|
96
169
|
export type GetSectionsResponse = {
|
|
97
170
|
results: Section[];
|
|
98
171
|
nextCursor: string | null;
|
|
99
172
|
};
|
|
173
|
+
/**
|
|
174
|
+
* @see https://developer.todoist.com/rest/v2/#create-a-new-section
|
|
175
|
+
*/
|
|
100
176
|
export type AddSectionArgs = {
|
|
101
177
|
name: string;
|
|
102
178
|
projectId: string;
|
|
103
179
|
order?: number | null;
|
|
104
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* @see https://developer.todoist.com/rest/v2/#update-a-section
|
|
183
|
+
*/
|
|
105
184
|
export type UpdateSectionArgs = {
|
|
106
185
|
name: string;
|
|
107
186
|
};
|
|
187
|
+
/**
|
|
188
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-personal-labels
|
|
189
|
+
*/
|
|
108
190
|
export type GetLabelsArgs = {
|
|
109
191
|
cursor?: string | null;
|
|
110
192
|
limit?: number;
|
|
111
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-personal-labels
|
|
196
|
+
*/
|
|
112
197
|
export type GetLabelsResponse = {
|
|
113
198
|
results: Label[];
|
|
114
199
|
nextCursor: string | null;
|
|
115
200
|
};
|
|
201
|
+
/**
|
|
202
|
+
* @see https://developer.todoist.com/rest/v2/#create-a-new-personal-label
|
|
203
|
+
*/
|
|
116
204
|
export type AddLabelArgs = {
|
|
117
205
|
name: string;
|
|
118
206
|
order?: number | null;
|
|
119
207
|
color?: string | number;
|
|
120
208
|
isFavorite?: boolean;
|
|
121
209
|
};
|
|
210
|
+
/**
|
|
211
|
+
* @see https://developer.todoist.com/rest/v2/#update-a-personal-label
|
|
212
|
+
*/
|
|
122
213
|
export type UpdateLabelArgs = {
|
|
123
214
|
name?: string;
|
|
124
215
|
order?: number | null;
|
|
125
216
|
color?: string;
|
|
126
217
|
isFavorite?: boolean;
|
|
127
218
|
};
|
|
128
|
-
|
|
219
|
+
/**
|
|
220
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-shared-labels
|
|
221
|
+
*/
|
|
222
|
+
export type GetSharedLabelsArgs = {
|
|
223
|
+
omitPersonal?: boolean;
|
|
129
224
|
cursor?: string | null;
|
|
130
225
|
limit?: number;
|
|
131
226
|
};
|
|
132
|
-
|
|
133
|
-
|
|
227
|
+
/**
|
|
228
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-shared-labels
|
|
229
|
+
*/
|
|
230
|
+
export type GetSharedLabelsResponse = {
|
|
231
|
+
results: string[];
|
|
134
232
|
nextCursor: string | null;
|
|
135
233
|
};
|
|
136
|
-
|
|
234
|
+
/**
|
|
235
|
+
* @see https://developer.todoist.com/rest/v2/#rename-shared-labels
|
|
236
|
+
*/
|
|
237
|
+
export type RenameSharedLabelArgs = {
|
|
238
|
+
name: string;
|
|
239
|
+
newName: string;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* @see https://developer.todoist.com/rest/v2/#remove-shared-labels
|
|
243
|
+
*/
|
|
244
|
+
export type RemoveSharedLabelArgs = {
|
|
245
|
+
name: string;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-comments
|
|
249
|
+
*/
|
|
250
|
+
export type GetTaskCommentsArgs = {
|
|
137
251
|
taskId: string;
|
|
138
252
|
projectId?: never;
|
|
253
|
+
cursor?: string | null;
|
|
254
|
+
limit?: number;
|
|
139
255
|
};
|
|
140
|
-
|
|
256
|
+
/**
|
|
257
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-comments
|
|
258
|
+
*/
|
|
259
|
+
export type GetProjectCommentsArgs = {
|
|
141
260
|
projectId: string;
|
|
142
261
|
taskId?: never;
|
|
262
|
+
cursor?: string | null;
|
|
263
|
+
limit?: number;
|
|
143
264
|
};
|
|
265
|
+
/**
|
|
266
|
+
* @see https://developer.todoist.com/rest/v2/#get-all-comments
|
|
267
|
+
*/
|
|
268
|
+
export type GetCommentsResponse = {
|
|
269
|
+
results: Comment[];
|
|
270
|
+
nextCursor: string | null;
|
|
271
|
+
};
|
|
272
|
+
/**
|
|
273
|
+
* @see https://developer.todoist.com/rest/v2/#create-a-new-comment
|
|
274
|
+
*/
|
|
144
275
|
export type AddCommentArgs = {
|
|
145
276
|
content: string;
|
|
146
277
|
attachment?: {
|
|
@@ -153,22 +284,9 @@ export type AddCommentArgs = {
|
|
|
153
284
|
taskId?: string;
|
|
154
285
|
projectId?: string;
|
|
155
286
|
}>;
|
|
287
|
+
/**
|
|
288
|
+
* @see https://developer.todoist.com/rest/v2/#update-a-comment
|
|
289
|
+
*/
|
|
156
290
|
export type UpdateCommentArgs = {
|
|
157
291
|
content: string;
|
|
158
292
|
};
|
|
159
|
-
export type GetSharedLabelsArgs = {
|
|
160
|
-
omitPersonal?: boolean;
|
|
161
|
-
cursor?: string | null;
|
|
162
|
-
limit?: number;
|
|
163
|
-
};
|
|
164
|
-
export type GetSharedLabelsResponse = {
|
|
165
|
-
results: string[];
|
|
166
|
-
nextCursor: string | null;
|
|
167
|
-
};
|
|
168
|
-
export type RenameSharedLabelArgs = {
|
|
169
|
-
name: string;
|
|
170
|
-
newName: string;
|
|
171
|
-
};
|
|
172
|
-
export type RemoveSharedLabelArgs = {
|
|
173
|
-
name: string;
|
|
174
|
-
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SyncTask } from './requests';
|
|
2
|
+
export type Command = {
|
|
3
|
+
type: string;
|
|
4
|
+
uuid: string;
|
|
5
|
+
args: Record<string, unknown>;
|
|
6
|
+
};
|
|
7
|
+
export type SyncError = {
|
|
8
|
+
error: string;
|
|
9
|
+
error_code: number;
|
|
10
|
+
error_extra: Record<string, unknown>;
|
|
11
|
+
error_tag: string;
|
|
12
|
+
http_code: number;
|
|
13
|
+
};
|
|
14
|
+
export type SyncRequest = {
|
|
15
|
+
commands: Command[];
|
|
16
|
+
resource_types?: string[];
|
|
17
|
+
};
|
|
18
|
+
export type SyncResponse = {
|
|
19
|
+
items?: SyncTask[];
|
|
20
|
+
sync_status?: Record<string, 'ok' | SyncError>;
|
|
21
|
+
};
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -22,11 +22,25 @@ export declare const taupe: Color;
|
|
|
22
22
|
export declare const colors: readonly [Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color, Color];
|
|
23
23
|
export declare const defaultColor: Color;
|
|
24
24
|
/**
|
|
25
|
+
* @private
|
|
25
26
|
* @deprecated Use {@link getColorByKey} instead
|
|
26
27
|
*/
|
|
27
28
|
export declare function getColorById(colorId: number): Color;
|
|
28
29
|
/**
|
|
30
|
+
* @private
|
|
29
31
|
* @deprecated Use {@link getColorByKey} instead
|
|
30
32
|
*/
|
|
31
33
|
export declare function getColorByName(colorName: string): Color;
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves a {@link Color} object by its key identifier.
|
|
36
|
+
*
|
|
37
|
+
* @param colorKey - The unique key identifier of the color to find (e.g., 'berry_red', 'sky_blue')
|
|
38
|
+
* @returns The matching Color object if found, otherwise returns the default color (charcoal)
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const color = getColorByKey('berry_red');
|
|
43
|
+
* console.log(color.hexValue); // '#b8255f'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
32
46
|
export declare function getColorByKey(colorKey: string): Color;
|
package/dist/utils/colors.js
CHANGED
|
@@ -185,6 +185,7 @@ exports.colors = [
|
|
|
185
185
|
];
|
|
186
186
|
exports.defaultColor = exports.charcoal;
|
|
187
187
|
/**
|
|
188
|
+
* @private
|
|
188
189
|
* @deprecated Use {@link getColorByKey} instead
|
|
189
190
|
*/
|
|
190
191
|
function getColorById(colorId) {
|
|
@@ -193,6 +194,7 @@ function getColorById(colorId) {
|
|
|
193
194
|
}
|
|
194
195
|
exports.getColorById = getColorById;
|
|
195
196
|
/**
|
|
197
|
+
* @private
|
|
196
198
|
* @deprecated Use {@link getColorByKey} instead
|
|
197
199
|
*/
|
|
198
200
|
function getColorByName(colorName) {
|
|
@@ -200,6 +202,18 @@ function getColorByName(colorName) {
|
|
|
200
202
|
return color !== null && color !== void 0 ? color : exports.defaultColor;
|
|
201
203
|
}
|
|
202
204
|
exports.getColorByName = getColorByName;
|
|
205
|
+
/**
|
|
206
|
+
* Retrieves a {@link Color} object by its key identifier.
|
|
207
|
+
*
|
|
208
|
+
* @param colorKey - The unique key identifier of the color to find (e.g., 'berry_red', 'sky_blue')
|
|
209
|
+
* @returns The matching Color object if found, otherwise returns the default color (charcoal)
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* ```typescript
|
|
213
|
+
* const color = getColorByKey('berry_red');
|
|
214
|
+
* console.log(color.hexValue); // '#b8255f'
|
|
215
|
+
* ```
|
|
216
|
+
*/
|
|
203
217
|
function getColorByKey(colorKey) {
|
|
204
218
|
var color = exports.colors.find(function (color) { return color.key === colorKey; });
|
|
205
219
|
return color !== null && color !== void 0 ? color : exports.defaultColor;
|
|
@@ -2,5 +2,34 @@ import { Task } from '../types';
|
|
|
2
2
|
export type TaskWithSanitizedContent = Task & {
|
|
3
3
|
sanitizedContent: string;
|
|
4
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Sanitizes a string by removing Todoist's formatting syntax (e.g. bold, italic, code blocks, links).
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // Removes bold/italic formatting
|
|
10
|
+
* getSanitizedContent('Some **bold** and *italic*') // 'Some bold and italic'
|
|
11
|
+
*
|
|
12
|
+
* // Removes markdown links
|
|
13
|
+
* getSanitizedContent('A [markdown](http://url.com) link') // 'A markdown link'
|
|
14
|
+
*
|
|
15
|
+
* // Removes app-specific links
|
|
16
|
+
* getSanitizedContent('A [[gmail=id, link from gmail]]') // 'A link from gmail'
|
|
17
|
+
*
|
|
18
|
+
* @param input - The string to sanitize
|
|
19
|
+
* @returns The sanitized string with all formatting removed
|
|
20
|
+
*/
|
|
5
21
|
export declare function getSanitizedContent(input: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Takes an array of tasks and returns a new array with sanitized content
|
|
24
|
+
* added as 'sanitizedContent' property to each task.
|
|
25
|
+
*
|
|
26
|
+
* @see {@link getSanitizedContent}
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* const tasks = [{ content: '**Bold** task', ... }]
|
|
30
|
+
* getSanitizedTasks(tasks) // [{ content: '**Bold** task', sanitizedContent: 'Bold task', ... }]
|
|
31
|
+
*
|
|
32
|
+
* @param tasks - Array of Task objects to sanitize
|
|
33
|
+
* @returns Array of tasks with added sanitizedContent property
|
|
34
|
+
*/
|
|
6
35
|
export declare function getSanitizedTasks(tasks: Task[]): TaskWithSanitizedContent[];
|
|
@@ -83,6 +83,22 @@ function removeAppLinks(input) {
|
|
|
83
83
|
}
|
|
84
84
|
return input;
|
|
85
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Sanitizes a string by removing Todoist's formatting syntax (e.g. bold, italic, code blocks, links).
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* // Removes bold/italic formatting
|
|
91
|
+
* getSanitizedContent('Some **bold** and *italic*') // 'Some bold and italic'
|
|
92
|
+
*
|
|
93
|
+
* // Removes markdown links
|
|
94
|
+
* getSanitizedContent('A [markdown](http://url.com) link') // 'A markdown link'
|
|
95
|
+
*
|
|
96
|
+
* // Removes app-specific links
|
|
97
|
+
* getSanitizedContent('A [[gmail=id, link from gmail]]') // 'A link from gmail'
|
|
98
|
+
*
|
|
99
|
+
* @param input - The string to sanitize
|
|
100
|
+
* @returns The sanitized string with all formatting removed
|
|
101
|
+
*/
|
|
86
102
|
function getSanitizedContent(input) {
|
|
87
103
|
input = removeStyleFormatting(input);
|
|
88
104
|
input = removeCodeFormatting(input);
|
|
@@ -93,6 +109,19 @@ function getSanitizedContent(input) {
|
|
|
93
109
|
return input;
|
|
94
110
|
}
|
|
95
111
|
exports.getSanitizedContent = getSanitizedContent;
|
|
112
|
+
/**
|
|
113
|
+
* Takes an array of tasks and returns a new array with sanitized content
|
|
114
|
+
* added as 'sanitizedContent' property to each task.
|
|
115
|
+
*
|
|
116
|
+
* @see {@link getSanitizedContent}
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* const tasks = [{ content: '**Bold** task', ... }]
|
|
120
|
+
* getSanitizedTasks(tasks) // [{ content: '**Bold** task', sanitizedContent: 'Bold task', ... }]
|
|
121
|
+
*
|
|
122
|
+
* @param tasks - Array of Task objects to sanitize
|
|
123
|
+
* @returns Array of tasks with added sanitizedContent property
|
|
124
|
+
*/
|
|
96
125
|
function getSanitizedTasks(tasks) {
|
|
97
126
|
return tasks.map(function (task) { return (__assign(__assign({}, task), { sanitizedContent: getSanitizedContent(task.content) })); });
|
|
98
127
|
}
|
|
@@ -17,7 +17,7 @@ function getTaskFromQuickAddResponse(responseData) {
|
|
|
17
17
|
isCompleted: responseData.checked,
|
|
18
18
|
labels: responseData.labels,
|
|
19
19
|
priority: responseData.priority,
|
|
20
|
-
commentCount: 0,
|
|
20
|
+
commentCount: 0, // Will always be 0 for a quick add
|
|
21
21
|
createdAt: responseData.addedAt,
|
|
22
22
|
url: getTaskUrlFromQuickAddResponse(responseData),
|
|
23
23
|
creatorId: (_a = responseData.addedByUid) !== null && _a !== void 0 ? _a : '',
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type Task, type Project, type Section, type Label, type Comment, type User } from '../types/entities';
|
|
2
2
|
export declare function validateTask(input: unknown): Task;
|
|
3
3
|
export declare function validateTaskArray(input: unknown[]): Task[];
|
|
4
4
|
export declare function validateProject(input: unknown): Project;
|