Skip to content

Commit 58ce622

Browse files
chore: Updates to v2 REST API (#53)
* chore: Updates to v2 REST API * chore: Corrects the fixtures * refactor: Clean up conditionals
1 parent 0bf122d commit 58ce622

File tree

6 files changed

+98
-104
lines changed

6 files changed

+98
-104
lines changed

package-lock.json

Lines changed: 56 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888
"prettier": "@doist/prettier-config",
8989
"dependencies": {
9090
"@doist/integrations-common": "1.0.17",
91-
"@doist/todoist-api-typescript": "1.5.0",
91+
"@doist/todoist-api-typescript": "2.0.1",
9292
"@doist/ui-extensions-core": "3.2.1",
9393
"@doist/ui-extensions-server": "1.1.0",
9494
"@nestjs/axios": "0.1.0",

src/services/actions.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export class ActionsService extends ActionsServiceBase {
121121
let sections: Section[] = []
122122

123123
try {
124-
tasks = await todoistClient.getTasks({ projectId: contextData.sourceId })
124+
tasks = await todoistClient.getTasks({ projectId: String(contextData.sourceId) })
125125

126126
if (tasks.length === 0) {
127127
return {

src/utils/csv-helpers.spec.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,23 @@ describe('CSV Helpers', () => {
6767
buildTask({
6868
overrides: {
6969
content: 'My awesome task',
70-
sectionId: 1234,
70+
sectionId: '1234',
7171
due: {
7272
string: '2022-08-09',
73-
recurring: false,
73+
isRecurring: false,
7474
date: new Date('2022-08-09').toISOString(),
7575
},
7676
priority: 4,
7777
description: 'This is a description',
78-
created: new Date(2022, 7, 5).toISOString(),
79-
assignee: 12345,
78+
createdAt: new Date(2022, 7, 5).toISOString(),
79+
assigneeId: '12345',
8080
},
8181
}),
8282
],
8383
sections: [
8484
buildSection({
8585
overrides: {
86-
id: 1234,
86+
id: '1234',
8787
name: 'My awesome section',
8888
},
8989
}),
@@ -105,18 +105,18 @@ describe('CSV Helpers', () => {
105105
tasks: [
106106
buildTask({
107107
overrides: {
108-
id: 10000001,
108+
id: '10000001',
109109
content: 'My awesome task',
110-
sectionId: 1234,
110+
sectionId: '1234',
111111
due: {
112112
string: '2022-08-09',
113-
recurring: false,
113+
isRecurring: false,
114114
date: new Date('2022-08-09').toISOString(),
115115
},
116116
priority: 4,
117117
description: 'This is a description',
118-
created: new Date(2022, 7, 5).toISOString(),
119-
assignee: 12345,
118+
createdAt: new Date(2022, 7, 5).toISOString(),
119+
assigneeId: '12345',
120120
},
121121
}),
122122
],
@@ -143,25 +143,25 @@ describe('CSV Helpers', () => {
143143
tasks: [
144144
buildTask({
145145
overrides: {
146-
id: 10000001,
146+
id: '10000001',
147147
content: 'My awesome task\nOn two lines',
148-
sectionId: 1234,
148+
sectionId: '1234',
149149
due: {
150150
string: '2022-08-09',
151-
recurring: false,
151+
isRecurring: false,
152152
date: new Date('2022-08-09').toISOString(),
153153
},
154154
priority: 4,
155155
description: 'This is a description\nAlso on two lines',
156-
created: new Date(2022, 7, 5).toISOString(),
157-
assignee: 12345,
156+
createdAt: new Date(2022, 7, 5).toISOString(),
157+
assigneeId: '12345',
158158
},
159159
}),
160160
],
161161
sections: [
162162
buildSection({
163163
overrides: {
164-
id: 1234,
164+
id: '1234',
165165
name: 'My awesome section',
166166
},
167167
}),
@@ -183,25 +183,25 @@ describe('CSV Helpers', () => {
183183
tasks: [
184184
buildTask({
185185
overrides: {
186-
id: 10000001,
186+
id: '10000001',
187187
content: 'My awesome task, but with a comma',
188-
sectionId: 1234,
188+
sectionId: '1234',
189189
due: {
190190
string: '2022-08-09',
191-
recurring: false,
191+
isRecurring: false,
192192
date: new Date('2022-08-09').toISOString(),
193193
},
194194
priority: 4,
195195
description: 'This is a description\nAlso on two lines',
196-
created: new Date(2022, 7, 5).toISOString(),
197-
assignee: 12345,
196+
createdAt: new Date(2022, 7, 5).toISOString(),
197+
assigneeId: '12345',
198198
},
199199
}),
200200
],
201201
sections: [
202202
buildSection({
203203
overrides: {
204-
id: 1234,
204+
id: '1234',
205205
name: 'My awesome section',
206206
},
207207
}),

src/utils/csv-helpers.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ function createTaskRow(
4848
items.push(sanitiseText(task.content))
4949
break
5050
case 'sectionId':
51-
items.push(task.sectionId.toString())
51+
items.push(task.sectionId ?? '')
5252
break
5353
case 'parentTaskId':
54-
items.push(task.parentId ? task.parentId.toString() : '')
54+
items.push(task.parentId ?? '')
5555
break
5656
}
5757
})
@@ -63,13 +63,13 @@ function createTaskRow(
6363

6464
switch (option) {
6565
case 'completed':
66-
items.push(task.completed ? 'true' : 'false')
66+
items.push(task.isCompleted ? 'true' : 'false')
6767
break
6868
case 'due':
69-
items.push(task.due ? task.due.string : '')
69+
items.push(task.due?.string ?? '')
7070
break
7171
case 'priority':
72-
items.push(task.priority ? task.priority.toString() : '')
72+
items.push(task.priority.toString())
7373
break
7474
case 'description':
7575
items.push(task.description ? sanitiseText(task.description) : '')
@@ -81,22 +81,22 @@ function createTaskRow(
8181
items.push(task.sectionId ? getSectionName(task.sectionId, sections) : '')
8282
break
8383
case 'assignee':
84-
items.push(task.assignee ? task.assignee.toString() : '')
84+
items.push(task.assigneeId ?? '')
8585
break
8686
case 'createdDate':
87-
items.push(task.created ? task.created : '')
87+
items.push(task.createdAt)
8888
break
8989
}
9090
})
9191
return items.join(DELIMITER)
9292
}
9393

94-
function getParentTaskName(parentTaskId: number, tasks: Task[]): string {
94+
function getParentTaskName(parentTaskId: string, tasks: Task[]): string {
9595
const task = tasks.find((x) => x.id === parentTaskId)
9696
return task?.content ? sanitiseText(task.content) : ''
9797
}
9898

99-
function getSectionName(sectionId: number, sections: Section[]): string {
99+
function getSectionName(sectionId: string, sections: Section[]): string {
100100
const section = sections.find((x) => x.id === sectionId)
101101
return section?.name ? sanitiseText(section.name) : ''
102102
}

0 commit comments

Comments
 (0)