mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor: Format nodes-base package (A-F) (#3800)
* 🔨 prettier formated nodes - A * 🔨 prettier formated nodes - B * ⚡ prettier formated nodes - C * ⚡ prettier formated nodes - D * ⚡ prettier formated nodes - E-F * 🎨 Adjust nodes-base formatting command (#3805) * Format additional files in nodes A-F (#3811) * ⚡ fixes * 🎨 Add Mindee to ignored dirs Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
@@ -12,94 +10,44 @@ import {
|
||||
NodeOperationError,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
clickupApiRequest,
|
||||
clickupApiRequestAllItems,
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
import { clickupApiRequest, clickupApiRequestAllItems, validateJSON } from './GenericFunctions';
|
||||
|
||||
import {
|
||||
checklistFields,
|
||||
checklistOperations,
|
||||
} from './ChecklistDescription';
|
||||
import { checklistFields, checklistOperations } from './ChecklistDescription';
|
||||
|
||||
import {
|
||||
checklistItemFields,
|
||||
checklistItemOperations,
|
||||
} from './ChecklistItemDescription';
|
||||
import { checklistItemFields, checklistItemOperations } from './ChecklistItemDescription';
|
||||
|
||||
import {
|
||||
commentFields,
|
||||
commentOperations,
|
||||
} from './CommentDescription';
|
||||
import { commentFields, commentOperations } from './CommentDescription';
|
||||
|
||||
import {
|
||||
folderFields,
|
||||
folderOperations,
|
||||
} from './FolderDescription';
|
||||
import { folderFields, folderOperations } from './FolderDescription';
|
||||
|
||||
import {
|
||||
goalFields,
|
||||
goalOperations,
|
||||
} from './GoalDescription';
|
||||
import { goalFields, goalOperations } from './GoalDescription';
|
||||
|
||||
import {
|
||||
goalKeyResultFields,
|
||||
goalKeyResultOperations,
|
||||
} from './GoalKeyResultDescription';
|
||||
import { goalKeyResultFields, goalKeyResultOperations } from './GoalKeyResultDescription';
|
||||
|
||||
// import {
|
||||
// guestFields,
|
||||
// guestOperations,
|
||||
// } from './guestDescription';
|
||||
|
||||
import {
|
||||
taskFields,
|
||||
taskOperations,
|
||||
} from './TaskDescription';
|
||||
import { taskFields, taskOperations } from './TaskDescription';
|
||||
|
||||
import {
|
||||
taskListFields,
|
||||
taskListOperations,
|
||||
} from './TaskListDescription';
|
||||
import { taskListFields, taskListOperations } from './TaskListDescription';
|
||||
|
||||
import {
|
||||
taskTagFields,
|
||||
taskTagOperations,
|
||||
} from './TaskTagDescription';
|
||||
import { taskTagFields, taskTagOperations } from './TaskTagDescription';
|
||||
|
||||
import {
|
||||
spaceTagFields,
|
||||
spaceTagOperations,
|
||||
} from './SpaceTagDescription';
|
||||
import { spaceTagFields, spaceTagOperations } from './SpaceTagDescription';
|
||||
|
||||
import {
|
||||
taskDependencyFields,
|
||||
taskDependencyOperations,
|
||||
} from './TaskDependencyDescription';
|
||||
import { taskDependencyFields, taskDependencyOperations } from './TaskDependencyDescription';
|
||||
|
||||
import {
|
||||
timeEntryFields,
|
||||
timeEntryOperations,
|
||||
} from './TimeEntryDescription';
|
||||
import { timeEntryFields, timeEntryOperations } from './TimeEntryDescription';
|
||||
|
||||
import {
|
||||
timeEntryTagFields,
|
||||
timeEntryTagOperations,
|
||||
} from './TimeEntryTagDescription';
|
||||
import { timeEntryTagFields, timeEntryTagOperations } from './TimeEntryTagDescription';
|
||||
|
||||
import {
|
||||
listFields,
|
||||
listOperations,
|
||||
} from './ListDescription';
|
||||
import { listFields, listOperations } from './ListDescription';
|
||||
|
||||
import {
|
||||
ITask,
|
||||
} from './TaskInterface';
|
||||
import { ITask } from './TaskInterface';
|
||||
|
||||
import {
|
||||
IList,
|
||||
} from './ListInterface';
|
||||
import { IList } from './ListInterface';
|
||||
|
||||
import moment from 'moment-timezone';
|
||||
|
||||
@@ -123,9 +71,7 @@ export class ClickUp implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'accessToken',
|
||||
],
|
||||
authentication: ['accessToken'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -134,9 +80,7 @@ export class ClickUp implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
authentication: [
|
||||
'oAuth2',
|
||||
],
|
||||
authentication: ['oAuth2'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -366,8 +310,7 @@ export class ClickUp implements INodeType {
|
||||
let url: string;
|
||||
if (listId) {
|
||||
url = `/list/${listId}/member`;
|
||||
}
|
||||
else if (taskId) {
|
||||
} else if (taskId) {
|
||||
url = `/task/${taskId}/member`;
|
||||
} else {
|
||||
return returnData;
|
||||
@@ -405,7 +348,11 @@ export class ClickUp implements INodeType {
|
||||
async getTimeEntryTags(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const teamId = this.getCurrentNodeParameter('team') as string;
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { data: tags } = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries/tags`);
|
||||
const { data: tags } = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/team/${teamId}/time_entries/tags`,
|
||||
);
|
||||
for (const tag of tags) {
|
||||
const tagName = tag.name;
|
||||
const tagId = JSON.stringify(tag);
|
||||
@@ -456,7 +403,11 @@ export class ClickUp implements INodeType {
|
||||
const listId = this.getCurrentNodeParameter('list') as string;
|
||||
const archived = this.getCurrentNodeParameter('archived') as string;
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { tasks } = await clickupApiRequest.call(this, 'GET', `/list/${listId}/task?archived=${archived}`);
|
||||
const { tasks } = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/list/${listId}/task?archived=${archived}`,
|
||||
);
|
||||
for (const task of tasks) {
|
||||
const taskName = task.name;
|
||||
const taskId = task.id;
|
||||
@@ -489,12 +440,21 @@ export class ClickUp implements INodeType {
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/checklist`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/task/${taskId}/checklist`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.checklist;
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const checklistId = this.getNodeParameter('checklist', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/checklist/${checklistId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/checklist/${checklistId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -507,7 +467,12 @@ export class ClickUp implements INodeType {
|
||||
if (updateFields.position) {
|
||||
body.position = updateFields.position as number;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/checklist/${checklistId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/checklist/${checklistId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.checklist;
|
||||
}
|
||||
}
|
||||
@@ -522,13 +487,22 @@ export class ClickUp implements INodeType {
|
||||
if (additionalFields.assignee) {
|
||||
body.assignee = parseInt(additionalFields.assignee as string, 10);
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/checklist/${checklistId}/checklist_item`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/checklist/${checklistId}/checklist_item`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.checklist;
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const checklistId = this.getNodeParameter('checklist', i) as string;
|
||||
const checklistItemId = this.getNodeParameter('checklistItem', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/checklist/${checklistId}/checklist_item/${checklistItemId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/checklist/${checklistId}/checklist_item/${checklistItemId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -548,7 +522,12 @@ export class ClickUp implements INodeType {
|
||||
if (updateFields.resolved) {
|
||||
body.resolved = updateFields.resolved as boolean;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/checklist/${checklistId}/checklist_item/${checklistItemId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/checklist/${checklistId}/checklist_item/${checklistItemId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.checklist;
|
||||
}
|
||||
}
|
||||
@@ -567,7 +546,12 @@ export class ClickUp implements INodeType {
|
||||
if (additionalFields.notifyAll) {
|
||||
body.notify_all = additionalFields.notifyAll as boolean;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/${resource}/${id}/comment`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/${resource}/${id}/comment`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const commentId = this.getNodeParameter('comment', i) as string;
|
||||
@@ -578,7 +562,13 @@ export class ClickUp implements INodeType {
|
||||
const resource = this.getNodeParameter('commentsOn', i) as string;
|
||||
const id = this.getNodeParameter('id', i) as string;
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/${resource}/${id}/comment`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/${resource}/${id}/comment`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.comments;
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
@@ -606,7 +596,12 @@ export class ClickUp implements INodeType {
|
||||
const body: IDataObject = {
|
||||
name,
|
||||
};
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/folder`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/space/${spaceId}/folder`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const folderId = this.getNodeParameter('folder', i) as string;
|
||||
@@ -624,7 +619,13 @@ export class ClickUp implements INodeType {
|
||||
qs.archived = filters.archived as boolean;
|
||||
}
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/space/${spaceId}/folder`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/space/${spaceId}/folder`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.folders;
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
@@ -659,7 +660,9 @@ export class ClickUp implements INodeType {
|
||||
body.color = additionalFields.color as string;
|
||||
}
|
||||
if (additionalFields.owners) {
|
||||
body.owners = ((additionalFields.owners as string).split(',') as string[]).map((e: string) => parseInt(e, 10));
|
||||
body.owners = ((additionalFields.owners as string).split(',') as string[]).map(
|
||||
(e: string) => parseInt(e, 10),
|
||||
);
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/goal`, body);
|
||||
responseData = responseData.goal;
|
||||
@@ -677,10 +680,15 @@ export class ClickUp implements INodeType {
|
||||
if (operation === 'getAll') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/goal`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/team/${teamId}/goal`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.goals;
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
|
||||
}
|
||||
if (operation === 'update') {
|
||||
const goalId = this.getNodeParameter('goal', i) as string;
|
||||
@@ -699,10 +707,14 @@ export class ClickUp implements INodeType {
|
||||
body.color = updateFields.color as string;
|
||||
}
|
||||
if (updateFields.addOwners) {
|
||||
body.add_owners = ((updateFields.addOwners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)) as number[];
|
||||
body.add_owners = ((updateFields.addOwners as string).split(',') as string[]).map(
|
||||
(e: string) => parseInt(e, 10),
|
||||
) as number[];
|
||||
}
|
||||
if (updateFields.removeOwners) {
|
||||
body.rem_owners = ((updateFields.removeOwners as string).split(',') as string[]).map((e: string) => parseInt(e, 10)) as number[];
|
||||
body.rem_owners = ((updateFields.removeOwners as string).split(',') as string[]).map(
|
||||
(e: string) => parseInt(e, 10),
|
||||
) as number[];
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/goal/${goalId}`, body);
|
||||
responseData = responseData.goal;
|
||||
@@ -720,14 +732,26 @@ export class ClickUp implements INodeType {
|
||||
};
|
||||
if (type === 'number' || type === 'currency') {
|
||||
if (!additionalFields.unit) {
|
||||
throw new NodeOperationError(this.getNode(), 'Unit field must be set', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Unit field must be set', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (type === 'number' || type === 'percentaje'
|
||||
|| type === 'automatic' || type === 'currency') {
|
||||
if (additionalFields.stepsStart === undefined
|
||||
|| !additionalFields.stepsEnd === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'Steps start and steps end fields must be set', { itemIndex: i });
|
||||
if (
|
||||
type === 'number' ||
|
||||
type === 'percentaje' ||
|
||||
type === 'automatic' ||
|
||||
type === 'currency'
|
||||
) {
|
||||
if (
|
||||
additionalFields.stepsStart === undefined ||
|
||||
!additionalFields.stepsEnd === undefined
|
||||
) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'Steps start and steps end fields must be set',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
}
|
||||
if (additionalFields.unit) {
|
||||
@@ -746,14 +770,25 @@ export class ClickUp implements INodeType {
|
||||
body.list_ids = (additionalFields.listIds as string).split(',');
|
||||
}
|
||||
if (additionalFields.owners) {
|
||||
body.owners = ((additionalFields.owners as string).split(',') as string[]).map((e: string) => parseInt(e, 10));
|
||||
body.owners = ((additionalFields.owners as string).split(',') as string[]).map(
|
||||
(e: string) => parseInt(e, 10),
|
||||
);
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/goal/${goalId}/key_result`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/goal/${goalId}/key_result`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.key_result;
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const keyResultId = this.getNodeParameter('keyResult', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/key_result/${keyResultId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/key_result/${keyResultId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -778,7 +813,12 @@ export class ClickUp implements INodeType {
|
||||
if (updateFields.unit) {
|
||||
body.unit = updateFields.unit as string;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/key_result/${keyResultId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/key_result/${keyResultId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.key_result;
|
||||
}
|
||||
}
|
||||
@@ -799,19 +839,32 @@ export class ClickUp implements INodeType {
|
||||
if (additionalFields.canSeeTimeEstimated) {
|
||||
body.can_see_time_estimated = additionalFields.canSeeTimeEstimated as boolean;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/guest`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/team/${teamId}/guest`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.team;
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
const guestId = this.getNodeParameter('guest', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/guest/${guestId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/team/${teamId}/guest/${guestId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
const guestId = this.getNodeParameter('guest', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/guest/${guestId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/team/${teamId}/guest/${guestId}`,
|
||||
);
|
||||
responseData = responseData.team;
|
||||
}
|
||||
if (operation === 'update') {
|
||||
@@ -831,7 +884,12 @@ export class ClickUp implements INodeType {
|
||||
if (updateFields.canSeeTimeEstimated) {
|
||||
body.can_see_time_estimated = updateFields.canSeeTimeEstimated as boolean;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/team/${teamId}/guest/${guestId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/team/${teamId}/guest/${guestId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.team;
|
||||
}
|
||||
}
|
||||
@@ -846,7 +904,9 @@ export class ClickUp implements INodeType {
|
||||
if (additionalFields.customFieldsJson) {
|
||||
const customFields = validateJSON(additionalFields.customFieldsJson as string);
|
||||
if (customFields === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'Custom Fields: Invalid JSON', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Custom Fields: Invalid JSON', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
body.custom_fields = customFields;
|
||||
}
|
||||
@@ -933,11 +993,15 @@ export class ClickUp implements INodeType {
|
||||
}
|
||||
if (updateFields.addAssignees) {
|
||||
//@ts-ignore
|
||||
body.assignees.add = ((updateFields.addAssignees as string).split(',') as string[]).map((e: string) => parseInt(e, 10));
|
||||
body.assignees.add = (
|
||||
(updateFields.addAssignees as string).split(',') as string[]
|
||||
).map((e: string) => parseInt(e, 10));
|
||||
}
|
||||
if (updateFields.removeAssignees) {
|
||||
//@ts-ignore
|
||||
body.assignees.rem = ((updateFields.removeAssignees as string).split(',') as string[]).map((e: string) => parseInt(e, 10));
|
||||
body.assignees.rem = (
|
||||
(updateFields.removeAssignees as string).split(',') as string[]
|
||||
).map((e: string) => parseInt(e, 10));
|
||||
}
|
||||
if (updateFields.status) {
|
||||
body.status = updateFields.status as string;
|
||||
@@ -995,13 +1059,15 @@ export class ClickUp implements INodeType {
|
||||
qs.date_updated_lt = new Date(filters.dateUpdatedLt as string).getTime();
|
||||
}
|
||||
if (filters.customFieldsUi) {
|
||||
const customFieldsValues = (filters.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
|
||||
const customFieldsValues = (filters.customFieldsUi as IDataObject)
|
||||
.customFieldsValues as IDataObject[];
|
||||
if (customFieldsValues) {
|
||||
const customFields: IDataObject[] = [];
|
||||
for (const customFieldValue of customFieldsValues) {
|
||||
customFields.push({
|
||||
field_id: customFieldValue.fieldId,
|
||||
operator: (customFieldValue.operator === 'equal') ? '=' : customFieldValue.operator,
|
||||
operator:
|
||||
customFieldValue.operator === 'equal' ? '=' : customFieldValue.operator,
|
||||
value: customFieldValue.value as string,
|
||||
});
|
||||
}
|
||||
@@ -1012,10 +1078,24 @@ export class ClickUp implements INodeType {
|
||||
|
||||
const listId = this.getNodeParameter('list', i) as string;
|
||||
if (returnAll === true) {
|
||||
responseData = await clickupApiRequestAllItems.call(this, 'tasks', 'GET', `/list/${listId}/task`, {}, qs);
|
||||
responseData = await clickupApiRequestAllItems.call(
|
||||
this,
|
||||
'tasks',
|
||||
'GET',
|
||||
`/list/${listId}/task`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequestAllItems.call(this, 'tasks', 'GET', `/list/${listId}/task`, {}, qs);
|
||||
responseData = await clickupApiRequestAllItems.call(
|
||||
this,
|
||||
'tasks',
|
||||
'GET',
|
||||
`/list/${listId}/task`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
}
|
||||
@@ -1023,11 +1103,23 @@ export class ClickUp implements INodeType {
|
||||
const taskId = this.getNodeParameter('id', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/task/${taskId}/member`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.members;
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/task/${taskId}/member`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/task/${taskId}/member`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.members;
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
@@ -1043,7 +1135,9 @@ export class ClickUp implements INodeType {
|
||||
if (jsonParse === true) {
|
||||
body.value = validateJSON(body.value);
|
||||
if (body.value === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Value is invalid JSON!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
//@ts-ignore
|
||||
@@ -1051,7 +1145,12 @@ export class ClickUp implements INodeType {
|
||||
body.value = parseInt(body.value, 10);
|
||||
}
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/field/${fieldId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/task/${taskId}/field/${fieldId}`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const taskId = this.getNodeParameter('id', i) as string;
|
||||
@@ -1066,7 +1165,13 @@ export class ClickUp implements INodeType {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const qs: IDataObject = {};
|
||||
Object.assign(qs, additionalFields);
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/tag/${name}`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/task/${taskId}/tag/${name}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'remove') {
|
||||
@@ -1075,7 +1180,13 @@ export class ClickUp implements INodeType {
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
const qs: IDataObject = {};
|
||||
Object.assign(qs, additionalFields);
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/tag/${name}`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/task/${taskId}/tag/${name}`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
@@ -1083,13 +1194,21 @@ export class ClickUp implements INodeType {
|
||||
if (operation === 'add') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/list/${listId}/task/${taskId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/list/${listId}/task/${taskId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'remove') {
|
||||
const taskId = this.getNodeParameter('taskId', i) as string;
|
||||
const listId = this.getNodeParameter('listId', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/list/${listId}/task/${taskId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/list/${listId}/task/${taskId}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
@@ -1101,7 +1220,12 @@ export class ClickUp implements INodeType {
|
||||
|
||||
body.depends_on = dependsOnTaskId;
|
||||
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/task/${taskId}/dependency`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/task/${taskId}/dependency`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
@@ -1110,7 +1234,13 @@ export class ClickUp implements INodeType {
|
||||
|
||||
qs.depends_on = dependsOnTaskId;
|
||||
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/task/${taskId}/dependency`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/task/${taskId}/dependency`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
}
|
||||
@@ -1128,7 +1258,7 @@ export class ClickUp implements INodeType {
|
||||
}
|
||||
|
||||
if (body.duration) {
|
||||
body.duration = body.duration as number * 60000;
|
||||
body.duration = (body.duration as number) * 60000;
|
||||
}
|
||||
|
||||
if (body.task) {
|
||||
@@ -1136,7 +1266,12 @@ export class ClickUp implements INodeType {
|
||||
body.custom_task_ids = true;
|
||||
}
|
||||
|
||||
responseData = await clickupApiRequest.call(this, 'PUT', `/team/${teamId}/time_entries/${timeEntryId}`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'PUT',
|
||||
`/team/${teamId}/time_entries/${timeEntryId}`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.data;
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -1152,7 +1287,13 @@ export class ClickUp implements INodeType {
|
||||
if (filters.end_date) {
|
||||
qs.end_date = moment.tz(qs.end_date, timezone).valueOf();
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/team/${teamId}/time_entries`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
responseData = responseData.data;
|
||||
|
||||
@@ -1160,7 +1301,6 @@ export class ClickUp implements INodeType {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
|
||||
}
|
||||
if (operation === 'get') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
@@ -1191,10 +1331,15 @@ export class ClickUp implements INodeType {
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
if (body.tags) {
|
||||
body.tags = (body.tags as string[]).map((tag) => (JSON.parse(tag)));
|
||||
body.tags = (body.tags as string[]).map((tag) => JSON.parse(tag));
|
||||
}
|
||||
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/team/${teamId}/time_entries`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.data;
|
||||
}
|
||||
if (operation === 'start') {
|
||||
@@ -1204,23 +1349,38 @@ export class ClickUp implements INodeType {
|
||||
body.tid = taskId;
|
||||
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
|
||||
Object.assign(body, additionalFields);
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/start`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/team/${teamId}/time_entries/start`,
|
||||
body,
|
||||
);
|
||||
responseData = responseData.data;
|
||||
}
|
||||
if (operation === 'stop') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/stop`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/team/${teamId}/time_entries/stop`,
|
||||
);
|
||||
|
||||
if (responseData.data) {
|
||||
responseData = responseData.data;
|
||||
} else {
|
||||
throw new NodeOperationError(this.getNode(), 'There seems to be nothing to stop.', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'There seems to be nothing to stop.', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
const timeEntryId = this.getNodeParameter('timeEntry', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/${timeEntryId}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/team/${teamId}/time_entries/${timeEntryId}`,
|
||||
);
|
||||
responseData = responseData.data;
|
||||
}
|
||||
}
|
||||
@@ -1234,17 +1394,28 @@ export class ClickUp implements INodeType {
|
||||
if (tagsUi) {
|
||||
const tags = (tagsUi as IDataObject).tagsValues as IDataObject[];
|
||||
if (tags === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'At least one tag must be set', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'At least one tag must be set', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
body.tags = tags;
|
||||
}
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/team/${teamId}/time_entries/tags`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/team/${teamId}/time_entries/tags`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/team/${teamId}/time_entries/tags`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/team/${teamId}/time_entries/tags`,
|
||||
);
|
||||
|
||||
responseData = responseData.data;
|
||||
|
||||
@@ -1252,7 +1423,6 @@ export class ClickUp implements INodeType {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = responseData.splice(0, limit);
|
||||
}
|
||||
|
||||
}
|
||||
if (operation === 'remove') {
|
||||
const teamId = this.getNodeParameter('team', i) as string;
|
||||
@@ -1260,11 +1430,15 @@ export class ClickUp implements INodeType {
|
||||
const tagNames = this.getNodeParameter('tagNames', i) as string[];
|
||||
const body: IDataObject = {};
|
||||
body.time_entry_ids = timeEntryIds.split(',');
|
||||
body.tags = tagNames.map((tag) => (JSON.parse(tag).name));
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/team/${teamId}/time_entries/tags`, body);
|
||||
body.tags = tagNames.map((tag) => JSON.parse(tag).name);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/team/${teamId}/time_entries/tags`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
|
||||
}
|
||||
if (resource === 'spaceTag') {
|
||||
if (operation === 'create') {
|
||||
@@ -1279,13 +1453,22 @@ export class ClickUp implements INodeType {
|
||||
tag_fg: foregroundColor,
|
||||
},
|
||||
};
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/tag`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/space/${spaceId}/tag`,
|
||||
body,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'delete') {
|
||||
const spaceId = this.getNodeParameter('space', i) as string;
|
||||
const name = this.getNodeParameter('name', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'DELETE', `/space/${spaceId}/tag/${name}`);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'DELETE',
|
||||
`/space/${spaceId}/tag/${name}`,
|
||||
);
|
||||
responseData = { success: true };
|
||||
}
|
||||
if (operation === 'getAll') {
|
||||
@@ -1343,21 +1526,43 @@ export class ClickUp implements INodeType {
|
||||
body.status = additionalFields.status as string;
|
||||
}
|
||||
if (folderless) {
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/space/${spaceId}/list`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/space/${spaceId}/list`,
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
const folderId = this.getNodeParameter('folder', i) as string;
|
||||
responseData = await clickupApiRequest.call(this, 'POST', `/folder/${folderId}/list`, body);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'POST',
|
||||
`/folder/${folderId}/list`,
|
||||
body,
|
||||
);
|
||||
}
|
||||
}
|
||||
if (operation === 'member') {
|
||||
const listId = this.getNodeParameter('id', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll === true) {
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/list/${listId}/member`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.members;
|
||||
} else {
|
||||
qs.limit = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await clickupApiRequest.call(this, 'GET', `/list/${listId}/member`, {}, qs);
|
||||
responseData = await clickupApiRequest.call(
|
||||
this,
|
||||
'GET',
|
||||
`/list/${listId}/member`,
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.members;
|
||||
responseData = responseData.splice(0, qs.limit);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user