feat(todoist): add app, authentication, docs (#826)

This commit is contained in:
Ian Levesque
2023-01-07 09:09:39 -05:00
committed by GitHub
parent ff0bde059a
commit 1a4a1f7f8b
19 changed files with 418 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { IGlobalVariable } from '@automatisch/types';
const getActiveTasks = async ($: IGlobalVariable) => {
const params = {
project_id: ($.step.parameters.projectId as string)?.trim(),
section_id: ($.step.parameters.sectionId as string)?.trim(),
label: ($.step.parameters.label as string)?.trim(),
filter: ($.step.parameters.filter as string)?.trim(),
};
const response = await $.http.get('/tasks', { params });
// todoist api doesn't offer sorting, so we inverse sort on id here
response.data.sort((a: { id: number; }, b: { id: number; }) => {
return b.id - a.id;
})
for (const task of response.data) {
$.pushTriggerItem({
raw: task,
meta:{
internalId: task.id as string,
}
});
}
};
export default getActiveTasks;

View File

@@ -0,0 +1,80 @@
import defineTrigger from '../../../../helpers/define-trigger';
import getActiveTasks from './get-tasks';
export default defineTrigger({
name: 'Get Active Tasks',
key: 'getActiveTasks',
pollInterval: 15,
description: 'Triggers when new Task(s) are found',
arguments: [
{
label: 'Project ID',
key: 'projectId',
type: 'dropdown' as const,
required: false,
variables: false,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listProjects',
},
],
},
},
{
label: 'Section ID',
key: 'sectionId',
type: 'dropdown' as const,
required: false,
variables: false,
dependsOn: ['parameters.projectId'],
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listSections',
},
{
name: 'parameters.projectId',
value: '{parameters.projectId}',
},
],
},
},
{
label: 'Label',
key: 'label',
type: 'dropdown' as const,
required: false,
variables: false,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listLabels',
},
],
},
},
{
label: 'Filter',
key: 'filter',
type: 'string' as const,
required: false,
variables: false,
description:
'Limit queried tasks to this filter. Example: "Meeting & today"',
},
],
async run($) {
await getActiveTasks($);
},
});

View File

@@ -0,0 +1,3 @@
import getTasks from './get-tasks';
export default [getTasks];