feat(clickup): add new tasks trigger

This commit is contained in:
Rıdvan Akca
2024-02-14 15:30:37 +03:00
committed by Ali BARIN
parent 6c11bfe93d
commit 200e483574
6 changed files with 262 additions and 2 deletions

View File

@@ -1,5 +1,7 @@
import listFolders from './list-folders/index.js';
import listLists from './list-lists/index.js';
import listSpaces from './list-spaces/index.js';
import listTasks from './list-tasks/index.js';
import listWorkspaces from './list-workspaces/index.js';
export default [listFolders, listSpaces, listWorkspaces];
export default [listFolders, listLists, listSpaces, listTasks, listWorkspaces];

View File

@@ -0,0 +1,28 @@
export default {
name: 'List lists',
key: 'listLists',
async run($) {
const lists = {
data: [],
};
const folderId = $.step.parameters.folderId;
if (!folderId) {
return lists;
}
const { data } = await $.http.get(`/v2/folder/${folderId}/list`);
if (data.lists) {
for (const list of data.lists) {
lists.data.push({
value: list.id,
name: list.name,
});
}
}
return lists;
},
};

View File

@@ -0,0 +1,41 @@
export default {
name: 'List tasks',
key: 'listTasks',
async run($) {
const tasks = {
data: [],
};
const listId = $.step.parameters.listId;
let next = false;
if (!listId) {
return tasks;
}
const params = {
order_by: 'created',
reverse: true,
};
do {
const { data } = await $.http.get(`/v2/list/${listId}/task`, { params });
if (data.last_page) {
next = false;
} else {
next = true;
}
if (data.tasks) {
for (const task of data.tasks) {
tasks.data.push({
value: task.id,
name: task.name,
});
}
}
} while (next);
return tasks;
},
};