feat(clickup/actions): add create task and find task by id (#1615)
* feat(clickup): add create task action * feat(clickup): add find task by id action * fix(clickup): send optional parameters only when provided --------- Co-authored-by: Ali BARIN <ali.barin53@gmail.com>
This commit is contained in:
294
packages/backend/src/apps/clickup/actions/create-task/index.js
Normal file
294
packages/backend/src/apps/clickup/actions/create-task/index.js
Normal file
@@ -0,0 +1,294 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Create task',
|
||||||
|
key: 'createTask',
|
||||||
|
description: 'Creates a new task.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Workspace',
|
||||||
|
key: 'workspaceId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listWorkspaces',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Space',
|
||||||
|
key: 'spaceId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
dependsOn: ['parameters.workspaceId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listSpaces',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.workspaceId',
|
||||||
|
value: '{parameters.workspaceId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Folder',
|
||||||
|
key: 'folderId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
dependsOn: ['parameters.spaceId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listFolders',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.spaceId',
|
||||||
|
value: '{parameters.spaceId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'List',
|
||||||
|
key: 'listId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
dependsOn: ['parameters.folderId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listLists',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.folderId',
|
||||||
|
value: '{parameters.folderId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Task Name',
|
||||||
|
key: 'taskName',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Task Description',
|
||||||
|
key: 'taskDescription',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Markdown Content',
|
||||||
|
key: 'markdownContent',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'False', value: 'false' },
|
||||||
|
{ label: 'True', value: 'true' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Assignees',
|
||||||
|
key: 'assigneeIds',
|
||||||
|
type: 'dynamic',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'Assignee',
|
||||||
|
key: 'assigneeId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.listId'],
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listAssignees',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.listId',
|
||||||
|
value: '{parameters.listId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Task Status',
|
||||||
|
key: 'taskStatus',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
dependsOn: ['parameters.listId'],
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listStatuses',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.listId',
|
||||||
|
value: '{parameters.listId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Tags',
|
||||||
|
key: 'tagIds',
|
||||||
|
type: 'dynamic',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
fields: [
|
||||||
|
{
|
||||||
|
label: 'tag',
|
||||||
|
key: 'tagId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listTags',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Priority',
|
||||||
|
key: 'priority',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{ label: 'Urgent', value: 1 },
|
||||||
|
{ label: 'High', value: 2 },
|
||||||
|
{ label: 'Normal', value: 3 },
|
||||||
|
{ label: 'Low', value: 4 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Due Date',
|
||||||
|
key: 'dueDate',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: 'format: integer <int64>',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Start Date',
|
||||||
|
key: 'startDate',
|
||||||
|
type: 'string',
|
||||||
|
required: false,
|
||||||
|
description: 'format: integer <int64>',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const {
|
||||||
|
listId,
|
||||||
|
taskName,
|
||||||
|
taskDescription,
|
||||||
|
markdownContent,
|
||||||
|
assigneeIds,
|
||||||
|
taskStatus,
|
||||||
|
tagIds,
|
||||||
|
priority,
|
||||||
|
dueDate,
|
||||||
|
startDate,
|
||||||
|
} = $.step.parameters;
|
||||||
|
|
||||||
|
const tags = tagIds.map((tag) => tag.tagId);
|
||||||
|
const assignees = assigneeIds.map((assignee) =>
|
||||||
|
Number(assignee.assigneeId)
|
||||||
|
);
|
||||||
|
|
||||||
|
const body = {
|
||||||
|
name: taskName,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (assignees.length) {
|
||||||
|
body.assignees = assignees;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (taskStatus) {
|
||||||
|
body.status = taskStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tags.length) {
|
||||||
|
body.tags = tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priority) {
|
||||||
|
body.priority = priority;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dueDate) {
|
||||||
|
body.due_date = dueDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startDate) {
|
||||||
|
body.start_date = startDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (markdownContent) {
|
||||||
|
body.markdown_description = taskDescription;
|
||||||
|
} else {
|
||||||
|
body.description = taskDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.post(`/v2/list/${listId}/task`, body);
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@@ -0,0 +1,82 @@
|
|||||||
|
import defineAction from '../../../../helpers/define-action.js';
|
||||||
|
|
||||||
|
export default defineAction({
|
||||||
|
name: 'Find task by id',
|
||||||
|
key: 'findTaskById',
|
||||||
|
description: 'Finds a task using id.',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
label: 'Task ID',
|
||||||
|
key: 'taskId',
|
||||||
|
type: 'string',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Use Custom ID',
|
||||||
|
key: 'useCustomId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'True',
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'False',
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
additionalFields: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicFields',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listFieldsWhenUsingCustomId',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'parameters.useCustomId',
|
||||||
|
value: '{parameters.useCustomId}',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Include Subtasks?',
|
||||||
|
key: 'includeSubtasks',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: false,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
options: [
|
||||||
|
{
|
||||||
|
label: 'True',
|
||||||
|
value: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'False',
|
||||||
|
value: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const { taskId, useCustomId, includeSubtasks } = $.step.parameters;
|
||||||
|
|
||||||
|
const params = {
|
||||||
|
custom_task_ids: useCustomId || false,
|
||||||
|
include_subtasks: includeSubtasks,
|
||||||
|
};
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/v2/task/${taskId}`, { params });
|
||||||
|
|
||||||
|
$.setActionItem({
|
||||||
|
raw: data,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
@@ -1,4 +1,6 @@
|
|||||||
import createFolder from './create-folder/index.js';
|
import createFolder from './create-folder/index.js';
|
||||||
import createList from './create-list/index.js';
|
import createList from './create-list/index.js';
|
||||||
|
import createTask from './create-task/index.js';
|
||||||
|
import findTaskById from './find-task-by-id/index.js';
|
||||||
|
|
||||||
export default [createFolder, createList];
|
export default [createFolder, createList, createTask, findTaskById];
|
||||||
|
@@ -1,7 +1,19 @@
|
|||||||
|
import listAssignees from './list-assignees/index.js';
|
||||||
import listFolders from './list-folders/index.js';
|
import listFolders from './list-folders/index.js';
|
||||||
import listLists from './list-lists/index.js';
|
import listLists from './list-lists/index.js';
|
||||||
import listSpaces from './list-spaces/index.js';
|
import listSpaces from './list-spaces/index.js';
|
||||||
|
import listStatuses from './list-statuses/index.js';
|
||||||
|
import listTags from './list-tags/index.js';
|
||||||
import listTasks from './list-tasks/index.js';
|
import listTasks from './list-tasks/index.js';
|
||||||
import listWorkspaces from './list-workspaces/index.js';
|
import listWorkspaces from './list-workspaces/index.js';
|
||||||
|
|
||||||
export default [listFolders, listLists, listSpaces, listTasks, listWorkspaces];
|
export default [
|
||||||
|
listAssignees,
|
||||||
|
listFolders,
|
||||||
|
listLists,
|
||||||
|
listSpaces,
|
||||||
|
listStatuses,
|
||||||
|
listTags,
|
||||||
|
listTasks,
|
||||||
|
listWorkspaces,
|
||||||
|
];
|
||||||
|
@@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List assignees',
|
||||||
|
key: 'listAssignees',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const assignees = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const listId = $.step.parameters.listId;
|
||||||
|
|
||||||
|
if (!listId) {
|
||||||
|
return assignees;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/v2/list/${listId}/member`);
|
||||||
|
|
||||||
|
if (data.members) {
|
||||||
|
for (const member of data.members) {
|
||||||
|
assignees.data.push({
|
||||||
|
value: member.id,
|
||||||
|
name: member.username,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return assignees;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List statuses',
|
||||||
|
key: 'listStatuses',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const statuses = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const listId = $.step.parameters.listId;
|
||||||
|
|
||||||
|
if (!listId) {
|
||||||
|
return statuses;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`/v2/list/${listId}`);
|
||||||
|
|
||||||
|
if (data.statuses) {
|
||||||
|
for (const status of data.statuses) {
|
||||||
|
statuses.data.push({
|
||||||
|
value: status.status,
|
||||||
|
name: status.status,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return statuses;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,28 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List tags',
|
||||||
|
key: 'listTags',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
const tags = {
|
||||||
|
data: [],
|
||||||
|
};
|
||||||
|
const spaceId = $.step.parameters.spaceId;
|
||||||
|
|
||||||
|
if (!spaceId) {
|
||||||
|
return spaceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { data } = await $.http.get(`v2/space/${spaceId}/tag`);
|
||||||
|
|
||||||
|
if (data.tags) {
|
||||||
|
for (const tag of data.tags) {
|
||||||
|
tags.data.push({
|
||||||
|
value: tag.name,
|
||||||
|
name: tag.name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return tags;
|
||||||
|
},
|
||||||
|
};
|
@@ -0,0 +1,3 @@
|
|||||||
|
import useCustomId from './use-custom-id/index.js';
|
||||||
|
|
||||||
|
export default [useCustomId];
|
@@ -0,0 +1,29 @@
|
|||||||
|
export default {
|
||||||
|
name: 'List workspaces when using custom id',
|
||||||
|
key: 'listFieldsWhenUsingCustomId',
|
||||||
|
|
||||||
|
async run($) {
|
||||||
|
if ($.step.parameters.useCustomId) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
label: 'Workspace',
|
||||||
|
key: 'workspaceId',
|
||||||
|
type: 'dropdown',
|
||||||
|
required: true,
|
||||||
|
description: '',
|
||||||
|
variables: true,
|
||||||
|
source: {
|
||||||
|
type: 'query',
|
||||||
|
name: 'getDynamicData',
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
name: 'key',
|
||||||
|
value: 'listWorkspaces',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
@@ -4,6 +4,7 @@ import auth from './auth/index.js';
|
|||||||
import triggers from './triggers/index.js';
|
import triggers from './triggers/index.js';
|
||||||
import dynamicData from './dynamic-data/index.js';
|
import dynamicData from './dynamic-data/index.js';
|
||||||
import actions from './actions/index.js';
|
import actions from './actions/index.js';
|
||||||
|
import dynamicFields from './dynamic-fields/index.js';
|
||||||
|
|
||||||
export default defineApp({
|
export default defineApp({
|
||||||
name: 'ClickUp',
|
name: 'ClickUp',
|
||||||
@@ -19,4 +20,5 @@ export default defineApp({
|
|||||||
triggers,
|
triggers,
|
||||||
dynamicData,
|
dynamicData,
|
||||||
actions,
|
actions,
|
||||||
|
dynamicFields,
|
||||||
});
|
});
|
||||||
|
@@ -59,6 +59,16 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/carbone/connection' },
|
{ text: 'Connection', link: '/apps/carbone/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
text: 'ClickUp',
|
||||||
|
collapsible: true,
|
||||||
|
collapsed: true,
|
||||||
|
items: [
|
||||||
|
{ text: 'Actions', link: '/apps/clickup/actions' },
|
||||||
|
{ text: 'Triggers', link: '/apps/clickup/triggers' },
|
||||||
|
{ text: 'Connection', link: '/apps/clickup/connection' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: 'Cryptography',
|
text: 'Cryptography',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
@@ -77,16 +87,6 @@ export default defineConfig({
|
|||||||
{ text: 'Connection', link: '/apps/datastore/connection' },
|
{ text: 'Connection', link: '/apps/datastore/connection' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
text: 'ClickUp',
|
|
||||||
collapsible: true,
|
|
||||||
collapsed: true,
|
|
||||||
items: [
|
|
||||||
{ text: 'Actions', link: '/apps/clickup/actions' },
|
|
||||||
{ text: 'Triggers', link: '/apps/clickup/triggers' },
|
|
||||||
{ text: 'Connection', link: '/apps/clickup/connection' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
text: 'DeepL',
|
text: 'DeepL',
|
||||||
collapsible: true,
|
collapsible: true,
|
||||||
|
@@ -5,6 +5,10 @@ items:
|
|||||||
desc: Creates a new folder.
|
desc: Creates a new folder.
|
||||||
- name: Create list
|
- name: Create list
|
||||||
desc: Creates a new list.
|
desc: Creates a new list.
|
||||||
|
- name: Create task
|
||||||
|
desc: Creates a new task.
|
||||||
|
- name: Find task by id
|
||||||
|
desc: Finds a task using id.
|
||||||
---
|
---
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
Reference in New Issue
Block a user