forked from activepieces/activepieces
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(todoist): add support for natural language due dates
- Loading branch information
1 parent
429d7fe
commit 36eac0c
Showing
5 changed files
with
292 additions
and
252 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.8" | ||
} | ||
"version": "0.3.9" | ||
} |
122 changes: 67 additions & 55 deletions
122
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,65 +1,77 @@ | ||
import { createAction, Property } from '@activepieces/pieces-framework'; | ||
import { assertNotNullOrUndefined } from '@activepieces/shared'; | ||
import { todoistRestClient } from '../common/client/rest-client'; | ||
import { todoistProjectIdDropdown, todoistSectionIdDropdown } 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( | ||
"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, | ||
}, | ||
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: | ||
"Can be either a specific date in YYYY-MM-DD format relative to user's timezone, a specific date and time in RFC3339 format, or a human defined date (e.g. 'next Monday') using local time", | ||
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, | ||
}); | ||
}, | ||
}); |
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
Oops, something went wrong.