Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4641 from kishanprmr/todoist
feat(todoist): update task, find task and mark task completed action
- Loading branch information
Showing
10 changed files
with
528 additions
and
291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
{ | ||
"name": "@activepieces/piece-todoist", | ||
"version": "0.3.7" | ||
"version": "0.3.8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 55 additions & 60 deletions
115
packages/pieces/community/todoist/src/lib/actions/create-task-action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,65 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { assertNotNullOrUndefined } from '@activepieces/shared'; | ||
import { todoistRestClient } from '../common/client/rest-client'; | ||
import { todoistProjectIdDropdown } from '../common/props'; | ||
import { todoistProjectIdDropdown, todoistSectionIdDropdown } from '../common/props'; | ||
import { TodoistCreateTaskRequest } from '../common/models'; | ||
import { todoistAuth } from '../..'; | ||
|
||
export const todoistCreateTaskAction = createAction({ | ||
auth: todoistAuth, | ||
name: 'create_task', | ||
displayName: 'Create Task', | ||
description: 'Create task', | ||
props: { | ||
project_id: todoistProjectIdDropdown, | ||
content: Property.LongText({ | ||
displayName: 'content', | ||
description: | ||
"The task's content. It may contain some markdown-formatted text and hyperlinks", | ||
required: true, | ||
}), | ||
description: Property.LongText({ | ||
displayName: 'Description', | ||
description: | ||
'A description for the task. This value may contain some markdown-formatted text and hyperlinks.', | ||
required: false, | ||
}), | ||
labels: Property.Array({ | ||
displayName: 'Labels', | ||
required: false, | ||
description: | ||
"The task's labels (a list of names that may represent either personal or shared labels)", | ||
}), | ||
priority: Property.Number({ | ||
displayName: 'Priority', | ||
description: 'Task priority from 1 (normal) to 4 (urgent)', | ||
required: false, | ||
}), | ||
due_date: Property.ShortText({ | ||
displayName: 'Due date', | ||
description: | ||
"Specific date in YYYY-MM-DD format relative to user's timezone", | ||
required: false, | ||
}), | ||
section_id: Property.ShortText({ | ||
displayName: 'Section', | ||
description: | ||
"A section for the task. It should be a Section ID under the same project", | ||
required: false, | ||
}), | ||
}, | ||
auth: todoistAuth, | ||
name: 'create_task', | ||
displayName: 'Create Task', | ||
description: 'Create task', | ||
props: { | ||
project_id: todoistProjectIdDropdown( | ||
"Task project ID. If not set, task is put to user's Inbox.", | ||
), | ||
content: Property.LongText({ | ||
displayName: 'content', | ||
description: "The task's content. It may contain some markdown-formatted text and hyperlinks", | ||
required: true, | ||
}), | ||
description: Property.LongText({ | ||
displayName: 'Description', | ||
description: | ||
'A description for the task. This value may contain some markdown-formatted text and hyperlinks.', | ||
required: false, | ||
}), | ||
labels: Property.Array({ | ||
displayName: 'Labels', | ||
required: false, | ||
description: | ||
"The task's labels (a list of names that may represent either personal or shared labels)", | ||
}), | ||
priority: Property.Number({ | ||
displayName: 'Priority', | ||
description: 'Task priority from 1 (normal) to 4 (urgent)', | ||
required: false, | ||
}), | ||
due_date: Property.ShortText({ | ||
displayName: 'Due date', | ||
description: "Specific date in YYYY-MM-DD format relative to user's timezone", | ||
required: false, | ||
}), | ||
section_id: todoistSectionIdDropdown, | ||
}, | ||
|
||
async run({ auth, propsValue }) { | ||
const token = auth.access_token; | ||
const { project_id, content, description, labels, priority, due_date, section_id} = | ||
propsValue as TodoistCreateTaskRequest; | ||
async run({ auth, propsValue }) { | ||
const token = auth.access_token; | ||
const { project_id, content, description, labels, priority, due_date, section_id } = | ||
propsValue as TodoistCreateTaskRequest; | ||
|
||
assertNotNullOrUndefined(token, 'token'); | ||
assertNotNullOrUndefined(content, 'content'); | ||
return await todoistRestClient.tasks.create({ | ||
token, | ||
project_id, | ||
content, | ||
description, | ||
labels, | ||
priority, | ||
due_date, | ||
section_id | ||
}); | ||
}, | ||
assertNotNullOrUndefined(token, 'token'); | ||
assertNotNullOrUndefined(content, 'content'); | ||
return await todoistRestClient.tasks.create({ | ||
token, | ||
project_id, | ||
content, | ||
description, | ||
labels, | ||
priority, | ||
due_date, | ||
section_id, | ||
}); | ||
}, | ||
}); |
36 changes: 36 additions & 0 deletions
36
packages/pieces/community/todoist/src/lib/actions/find-task.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { todoistAuth } from '../..'; | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { todoistProjectIdDropdown } from '../common/props'; | ||
import { todoistRestClient } from '../common/client/rest-client'; | ||
import { assertNotNullOrUndefined } from '@activepieces/shared'; | ||
|
||
export const todoistFindTaskAction = createAction({ | ||
auth: todoistAuth, | ||
name: 'find_task', | ||
displayName: 'Find Task', | ||
description: 'Finds a task by name.', | ||
props: { | ||
name: Property.ShortText({ | ||
displayName: 'Name', | ||
description: 'The name of the task to search for.', | ||
required: true, | ||
}), | ||
project_id: todoistProjectIdDropdown( | ||
'Search for tasks within the selected project. If left blank, then all projects are searched.', | ||
), | ||
}, | ||
async run(context) { | ||
const token = context.auth.access_token; | ||
const { name, project_id } = context.propsValue; | ||
|
||
assertNotNullOrUndefined(token, 'token'); | ||
const tasks = await todoistRestClient.tasks.list({ token, project_id }); | ||
|
||
const matchedTask = tasks.find((task) => task.content == name); | ||
if (!matchedTask) { | ||
throw new Error('Task not found'); | ||
} else { | ||
return matchedTask; | ||
} | ||
}, | ||
}); |
25 changes: 25 additions & 0 deletions
25
packages/pieces/community/todoist/src/lib/actions/mark-task-completed.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { assertNotNullOrUndefined } from '@activepieces/shared'; | ||
import { todoistAuth } from '../..'; | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { todoistRestClient } from '../common/client/rest-client'; | ||
|
||
export const todoistMarkTaskCompletedAction = createAction({ | ||
auth: todoistAuth, | ||
name: 'mark_task_completed', | ||
displayName: 'Mark Task as Completed', | ||
description: 'Marks a task as being completed.', | ||
props: { | ||
task_id: Property.ShortText({ | ||
displayName: 'Task ID', | ||
required: true, | ||
}), | ||
}, | ||
async run(context) { | ||
const token = context.auth.access_token; | ||
const { task_id } = context.propsValue; | ||
|
||
assertNotNullOrUndefined(token, 'token'); | ||
|
||
return await todoistRestClient.tasks.close({ token, task_id }); | ||
}, | ||
}); |
61 changes: 61 additions & 0 deletions
61
packages/pieces/community/todoist/src/lib/actions/update-task.action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { assertNotNullOrUndefined } from '@activepieces/shared'; | ||
import { todoistRestClient } from '../common/client/rest-client'; | ||
import { todoistAuth } from '../..'; | ||
|
||
export const todoistUpdateTaskAction = createAction({ | ||
auth: todoistAuth, | ||
name: 'update_task', | ||
displayName: 'Update Task', | ||
description: 'Updates an existing task.', | ||
props: { | ||
task_id: Property.ShortText({ | ||
displayName: 'Task ID', | ||
required: true, | ||
}), | ||
content: Property.LongText({ | ||
displayName: 'content', | ||
description: "The task's content. It may contain some markdown-formatted text and hyperlinks", | ||
required: false, | ||
}), | ||
description: Property.LongText({ | ||
displayName: 'Description', | ||
description: | ||
'A description for the task. This value may contain some markdown-formatted text and hyperlinks.', | ||
required: false, | ||
}), | ||
labels: Property.Array({ | ||
displayName: 'Labels', | ||
required: false, | ||
description: | ||
"The task's labels (a list of names that may represent either personal or shared labels)", | ||
}), | ||
priority: Property.Number({ | ||
displayName: 'Priority', | ||
description: 'Task priority from 1 (normal) to 4 (urgent)', | ||
required: false, | ||
}), | ||
due_date: Property.ShortText({ | ||
displayName: 'Due date', | ||
description: "Specific date in YYYY-MM-DD format relative to user's timezone", | ||
required: false, | ||
}), | ||
}, | ||
|
||
async run({ auth, propsValue }) { | ||
const token = auth.access_token; | ||
const { task_id, content, description, priority, due_date } = propsValue; | ||
const labels = propsValue.labels as string[]; | ||
|
||
assertNotNullOrUndefined(token, 'token'); | ||
return await todoistRestClient.tasks.update({ | ||
token, | ||
task_id, | ||
content, | ||
description, | ||
labels, | ||
priority, | ||
due_date, | ||
}); | ||
}, | ||
}); |
Oops, something went wrong.