feat(todoist): add app, authentication, docs (#826)
This commit is contained in:
@@ -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;
|
||||
@@ -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($);
|
||||
},
|
||||
});
|
||||
3
packages/backend/src/apps/todoist/triggers/index.ts
Normal file
3
packages/backend/src/apps/todoist/triggers/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import getTasks from './get-tasks';
|
||||
|
||||
export default [getTasks];
|
||||
Reference in New Issue
Block a user