mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
n8n-3867-progressively-apply-prettier-to-all (#3873)
* 🔨 formatting nodes with prettier
This commit is contained in:
@@ -1,11 +1,6 @@
|
||||
import { mergeWith } from 'lodash';
|
||||
|
||||
import {
|
||||
mergeWith,
|
||||
} from 'lodash';
|
||||
|
||||
import {
|
||||
IExecuteFunctions,
|
||||
} from 'n8n-core';
|
||||
import { IExecuteFunctions } from 'n8n-core';
|
||||
|
||||
import {
|
||||
IBinaryData,
|
||||
@@ -26,20 +21,11 @@ import {
|
||||
validateJSON,
|
||||
} from './GenericFunctions';
|
||||
|
||||
import {
|
||||
issueAttachmentFields,
|
||||
issueAttachmentOperations,
|
||||
} from './IssueAttachmentDescription';
|
||||
import { issueAttachmentFields, issueAttachmentOperations } from './IssueAttachmentDescription';
|
||||
|
||||
import {
|
||||
issueCommentFields,
|
||||
issueCommentOperations,
|
||||
} from './IssueCommentDescription';
|
||||
import { issueCommentFields, issueCommentOperations } from './IssueCommentDescription';
|
||||
|
||||
import {
|
||||
issueFields,
|
||||
issueOperations,
|
||||
} from './IssueDescription';
|
||||
import { issueFields, issueOperations } from './IssueDescription';
|
||||
|
||||
import {
|
||||
IFields,
|
||||
@@ -49,10 +35,7 @@ import {
|
||||
NotificationRecipientsRestrictions,
|
||||
} from './IssueInterface';
|
||||
|
||||
import {
|
||||
userFields,
|
||||
userOperations,
|
||||
} from './UserDescription';
|
||||
import { userFields, userOperations } from './UserDescription';
|
||||
|
||||
export class Jira implements INodeType {
|
||||
description: INodeTypeDescription = {
|
||||
@@ -74,9 +57,7 @@ export class Jira implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jiraVersion: [
|
||||
'cloud',
|
||||
],
|
||||
jiraVersion: ['cloud'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -85,9 +66,7 @@ export class Jira implements INodeType {
|
||||
required: true,
|
||||
displayOptions: {
|
||||
show: {
|
||||
jiraVersion: [
|
||||
'server',
|
||||
],
|
||||
jiraVersion: ['server'],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -118,7 +97,8 @@ export class Jira implements INodeType {
|
||||
{
|
||||
name: 'Issue',
|
||||
value: 'issue',
|
||||
description: 'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask',
|
||||
description:
|
||||
'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask',
|
||||
},
|
||||
{
|
||||
name: 'Issue Attachment',
|
||||
@@ -164,7 +144,12 @@ export class Jira implements INodeType {
|
||||
projects = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET');
|
||||
} else {
|
||||
endpoint = '/api/2/project/search';
|
||||
projects = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', endpoint, 'GET');
|
||||
projects = await jiraSoftwareCloudApiRequestAllItems.call(
|
||||
this,
|
||||
'values',
|
||||
endpoint,
|
||||
'GET',
|
||||
);
|
||||
}
|
||||
|
||||
if (projects.values && Array.isArray(projects.values)) {
|
||||
@@ -180,8 +165,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -193,7 +182,11 @@ export class Jira implements INodeType {
|
||||
async getIssueTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
|
||||
const projectId = this.getCurrentNodeParameter('project');
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
const { issueTypes } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${projectId}`, 'GET');
|
||||
const { issueTypes } = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/project/${projectId}`,
|
||||
'GET',
|
||||
);
|
||||
for (const issueType of issueTypes) {
|
||||
const issueTypeName = issueType.name;
|
||||
const issueTypeId = issueType.id;
|
||||
@@ -204,8 +197,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return returnData;
|
||||
@@ -229,8 +226,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -255,8 +256,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -272,23 +277,24 @@ export class Jira implements INodeType {
|
||||
|
||||
if (jiraVersion === 'server') {
|
||||
endpoint = '/api/2/user/search';
|
||||
query.username = '\'';
|
||||
query.username = "'";
|
||||
}
|
||||
|
||||
const users = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET', {}, query);
|
||||
|
||||
return users.reduce((activeUsers: INodePropertyOptions[], user: IDataObject) => {
|
||||
if (user.active) {
|
||||
activeUsers.push({
|
||||
name: user.displayName as string,
|
||||
value: (user.accountId || user.name) as string,
|
||||
});
|
||||
}
|
||||
return activeUsers;
|
||||
}, []).sort((a: INodePropertyOptions, b: INodePropertyOptions) => {
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
|
||||
return users
|
||||
.reduce((activeUsers: INodePropertyOptions[], user: IDataObject) => {
|
||||
if (user.active) {
|
||||
activeUsers.push({
|
||||
name: user.displayName as string,
|
||||
value: (user.accountId || user.name) as string,
|
||||
});
|
||||
}
|
||||
return activeUsers;
|
||||
}, [])
|
||||
.sort((a: INodePropertyOptions, b: INodePropertyOptions) => {
|
||||
return a.name.toLowerCase() > b.name.toLowerCase() ? 1 : -1;
|
||||
});
|
||||
},
|
||||
|
||||
// Get all the groups to display them to user so that he can
|
||||
@@ -309,8 +315,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -323,7 +333,11 @@ export class Jira implements INodeType {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const issueKey = this.getCurrentNodeParameter('issueKey');
|
||||
const transitions = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET');
|
||||
const transitions = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}/transitions`,
|
||||
'GET',
|
||||
);
|
||||
|
||||
for (const transition of transitions.transitions) {
|
||||
returnData.push({
|
||||
@@ -333,8 +347,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -353,15 +371,28 @@ export class Jira implements INodeType {
|
||||
issueTypeId = this.getCurrentNodeParameter('issueType') as string;
|
||||
} else {
|
||||
const issueKey = this.getCurrentNodeParameter('issueKey') as string;
|
||||
const res = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, {});
|
||||
const res = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}`,
|
||||
'GET',
|
||||
{},
|
||||
{},
|
||||
);
|
||||
projectId = res.fields.project.id;
|
||||
issueTypeId = res.fields.issuetype.id;
|
||||
}
|
||||
|
||||
const res = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/createmeta?projectIds=${projectId}&issueTypeIds=${issueTypeId}&expand=projects.issuetypes.fields`, 'GET');
|
||||
const res = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/createmeta?projectIds=${projectId}&issueTypeIds=${issueTypeId}&expand=projects.issuetypes.fields`,
|
||||
'GET',
|
||||
);
|
||||
|
||||
// tslint:disable-next-line: no-any
|
||||
const fields = res.projects.find((o: any) => o.id === projectId).issuetypes.find((o: any) => o.id === issueTypeId).fields;
|
||||
const fields = res.projects
|
||||
// tslint:disable-next-line:no-any
|
||||
.find((o: any) => o.id === projectId)
|
||||
// tslint:disable-next-line:no-any
|
||||
.issuetypes.find((o: any) => o.id === issueTypeId).fields;
|
||||
for (const key of Object.keys(fields)) {
|
||||
const field = fields[key];
|
||||
if (field.schema && Object.keys(field.schema).includes('customId')) {
|
||||
@@ -380,7 +411,11 @@ export class Jira implements INodeType {
|
||||
const returnData: INodePropertyOptions[] = [];
|
||||
|
||||
const project = this.getCurrentNodeParameter('project');
|
||||
const { values: components } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${project}/component`, 'GET');
|
||||
const { values: components } = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/project/${project}/component`,
|
||||
'GET',
|
||||
);
|
||||
|
||||
for (const component of components) {
|
||||
returnData.push({
|
||||
@@ -390,8 +425,12 @@ export class Jira implements INodeType {
|
||||
}
|
||||
|
||||
returnData.sort((a, b) => {
|
||||
if (a.name < b.name) { return -1; }
|
||||
if (a.name > b.name) { return 1; }
|
||||
if (a.name < b.name) {
|
||||
return -1;
|
||||
}
|
||||
if (a.name > b.name) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
@@ -469,28 +508,39 @@ export class Jira implements INodeType {
|
||||
qs.updateHistory = additionalFields.updateHistory as boolean;
|
||||
}
|
||||
if (additionalFields.componentIds) {
|
||||
fields.components = (additionalFields.componentIds as string[]).map(id => ({ id }));
|
||||
fields.components = (additionalFields.componentIds as string[]).map((id) => ({ id }));
|
||||
}
|
||||
if (additionalFields.customFieldsUi) {
|
||||
const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
|
||||
const customFields = (additionalFields.customFieldsUi as IDataObject)
|
||||
.customFieldsValues as IDataObject[];
|
||||
if (customFields) {
|
||||
const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
|
||||
const data = customFields.reduce(
|
||||
(obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }),
|
||||
{},
|
||||
);
|
||||
Object.assign(fields, data);
|
||||
}
|
||||
}
|
||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body, qs);
|
||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
'/api/2/issuetype',
|
||||
'GET',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
const subtaskIssues = [];
|
||||
for (const issueType of issueTypes) {
|
||||
if (issueType.subtask) {
|
||||
subtaskIssues.push(issueType.id);
|
||||
}
|
||||
}
|
||||
if (!additionalFields.parentIssueKey
|
||||
&& subtaskIssues.includes(issueTypeId)) {
|
||||
throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task', { itemIndex: i });
|
||||
|
||||
} else if (additionalFields.parentIssueKey
|
||||
&& subtaskIssues.includes(issueTypeId)) {
|
||||
if (!additionalFields.parentIssueKey && subtaskIssues.includes(issueTypeId)) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'You must define a Parent Issue Key when Issue type is sub-task',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
} else if (additionalFields.parentIssueKey && subtaskIssues.includes(issueTypeId)) {
|
||||
fields.parent = {
|
||||
key: (additionalFields.parentIssueKey as string).toUpperCase(),
|
||||
};
|
||||
@@ -552,25 +602,38 @@ export class Jira implements INodeType {
|
||||
fields.description = updateFields.description as string;
|
||||
}
|
||||
if (updateFields.customFieldsUi) {
|
||||
const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
|
||||
const customFields = (updateFields.customFieldsUi as IDataObject)
|
||||
.customFieldsValues as IDataObject[];
|
||||
if (customFields) {
|
||||
const data = customFields.reduce((obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }), {});
|
||||
const data = customFields.reduce(
|
||||
(obj, value) => Object.assign(obj, { [`${value.fieldId}`]: value.fieldValue }),
|
||||
{},
|
||||
);
|
||||
Object.assign(fields, data);
|
||||
}
|
||||
}
|
||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issuetype', 'GET', body);
|
||||
const issueTypes = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
'/api/2/issuetype',
|
||||
'GET',
|
||||
body,
|
||||
);
|
||||
const subtaskIssues = [];
|
||||
for (const issueType of issueTypes) {
|
||||
if (issueType.subtask) {
|
||||
subtaskIssues.push(issueType.id);
|
||||
}
|
||||
}
|
||||
if (!updateFields.parentIssueKey
|
||||
&& subtaskIssues.includes(updateFields.issueType)) {
|
||||
throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task', { itemIndex: i });
|
||||
|
||||
} else if (updateFields.parentIssueKey
|
||||
&& subtaskIssues.includes(updateFields.issueType)) {
|
||||
if (!updateFields.parentIssueKey && subtaskIssues.includes(updateFields.issueType)) {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
'You must define a Parent Issue Key when Issue type is sub-task',
|
||||
{ itemIndex: i },
|
||||
);
|
||||
} else if (
|
||||
updateFields.parentIssueKey &&
|
||||
subtaskIssues.includes(updateFields.issueType)
|
||||
) {
|
||||
fields.parent = {
|
||||
key: (updateFields.parentIssueKey as string).toUpperCase(),
|
||||
};
|
||||
@@ -578,10 +641,20 @@ export class Jira implements INodeType {
|
||||
body.fields = fields;
|
||||
|
||||
if (updateFields.statusId) {
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'POST', { transition: { id: updateFields.statusId } });
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}/transitions`,
|
||||
'POST',
|
||||
{ transition: { id: updateFields.statusId } },
|
||||
);
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'PUT', body);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}`,
|
||||
'PUT',
|
||||
body,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
}
|
||||
@@ -609,19 +682,27 @@ export class Jira implements INodeType {
|
||||
if (additionalFields.updateHistory) {
|
||||
qs.updateHistory = additionalFields.updateHistory as string;
|
||||
}
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
|
||||
if (simplifyOutput) {
|
||||
// Use rendered fields if requested and available
|
||||
qs.expand = qs.expand || '';
|
||||
if (
|
||||
(qs.expand as string).toLowerCase().indexOf('renderedfields') !== -1 &&
|
||||
responseData.renderedFields && Object.keys(responseData.renderedFields).length
|
||||
responseData.renderedFields &&
|
||||
Object.keys(responseData.renderedFields).length
|
||||
) {
|
||||
responseData.fields = mergeWith(
|
||||
responseData.fields,
|
||||
responseData.renderedFields,
|
||||
(a,b) => b === null ? a : b);
|
||||
(a, b) => (b === null ? a : b),
|
||||
);
|
||||
}
|
||||
returnData.push(simplifyIssueOutput(responseData));
|
||||
} else {
|
||||
@@ -649,11 +730,22 @@ export class Jira implements INodeType {
|
||||
}
|
||||
}
|
||||
if (returnAll) {
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'issues', `/api/2/search`, 'POST', body);
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(
|
||||
this,
|
||||
'issues',
|
||||
`/api/2/search`,
|
||||
'POST',
|
||||
body,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
body.maxResults = limit;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/search`, 'POST', body);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/search`,
|
||||
'POST',
|
||||
body,
|
||||
);
|
||||
responseData = responseData.issues;
|
||||
}
|
||||
returnData.push(...responseData);
|
||||
@@ -665,10 +757,21 @@ export class Jira implements INodeType {
|
||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
if (returnAll) {
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', `/api/2/issue/${issueKey}/changelog`, 'GET');
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(
|
||||
this,
|
||||
'values',
|
||||
`/api/2/issue/${issueKey}/changelog`,
|
||||
'GET',
|
||||
);
|
||||
} else {
|
||||
qs.maxResults = this.getNodeParameter('limit', i) as number;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/changelog`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}/changelog`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.values;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData);
|
||||
@@ -688,7 +791,9 @@ export class Jira implements INodeType {
|
||||
body.htmlBody = additionalFields.htmlBody as string;
|
||||
}
|
||||
if (!jsonActive) {
|
||||
const notificationRecipientsValues = (this.getNodeParameter('notificationRecipientsUi', i) as IDataObject).notificationRecipientsValues as IDataObject[];
|
||||
const notificationRecipientsValues = (
|
||||
this.getNodeParameter('notificationRecipientsUi', i) as IDataObject
|
||||
).notificationRecipientsValues as IDataObject[];
|
||||
const notificationRecipients: INotificationRecipients = {};
|
||||
if (notificationRecipientsValues) {
|
||||
// @ts-ignore
|
||||
@@ -714,7 +819,7 @@ export class Jira implements INodeType {
|
||||
// @ts-ignore
|
||||
if (notificationRecipientsValues.users.length > 0) {
|
||||
// @ts-ignore
|
||||
notificationRecipients.users = notificationRecipientsValues.users.map(user => {
|
||||
notificationRecipients.users = notificationRecipientsValues.users.map((user) => {
|
||||
return {
|
||||
accountId: user,
|
||||
};
|
||||
@@ -723,7 +828,7 @@ export class Jira implements INodeType {
|
||||
// @ts-ignore
|
||||
if (notificationRecipientsValues.groups.length > 0) {
|
||||
// @ts-ignore
|
||||
notificationRecipients.groups = notificationRecipientsValues.groups.map(group => {
|
||||
notificationRecipients.groups = notificationRecipientsValues.groups.map((group) => {
|
||||
return {
|
||||
name: group,
|
||||
};
|
||||
@@ -731,31 +836,44 @@ export class Jira implements INodeType {
|
||||
}
|
||||
}
|
||||
body.to = notificationRecipients;
|
||||
const notificationRecipientsRestrictionsValues = (this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject).notificationRecipientsRestrictionsValues as IDataObject[];
|
||||
const notificationRecipientsRestrictionsValues = (
|
||||
this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject
|
||||
).notificationRecipientsRestrictionsValues as IDataObject[];
|
||||
const notificationRecipientsRestrictions: NotificationRecipientsRestrictions = {};
|
||||
if (notificationRecipientsRestrictionsValues) {
|
||||
// @ts-ignore
|
||||
if (notificationRecipientsRestrictionsValues.groups.length > 0) {
|
||||
// @ts-ignore
|
||||
notificationRecipientsRestrictions.groups = notificationRecipientsRestrictionsValues.groups.map(group => {
|
||||
return {
|
||||
name: group,
|
||||
};
|
||||
});
|
||||
notificationRecipientsRestrictions.groups =
|
||||
// @ts-ignore
|
||||
notificationRecipientsRestrictionsValues.groups.map((group) => {
|
||||
return {
|
||||
name: group,
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
body.restrict = notificationRecipientsRestrictions;
|
||||
} else {
|
||||
const notificationRecipientsJson = validateJSON(this.getNodeParameter('notificationRecipientsJson', i) as string);
|
||||
const notificationRecipientsJson = validateJSON(
|
||||
this.getNodeParameter('notificationRecipientsJson', i) as string,
|
||||
);
|
||||
if (notificationRecipientsJson) {
|
||||
body.to = notificationRecipientsJson;
|
||||
}
|
||||
const notificationRecipientsRestrictionsJson = validateJSON(this.getNodeParameter('notificationRecipientsRestrictionsJson', i) as string);
|
||||
const notificationRecipientsRestrictionsJson = validateJSON(
|
||||
this.getNodeParameter('notificationRecipientsRestrictionsJson', i) as string,
|
||||
);
|
||||
if (notificationRecipientsRestrictionsJson) {
|
||||
body.restrict = notificationRecipientsRestrictionsJson;
|
||||
}
|
||||
}
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/notify`, 'POST', body, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}/notify`,
|
||||
'POST',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
@@ -773,7 +891,13 @@ export class Jira implements INodeType {
|
||||
if (additionalFields.skipRemoteOnlyCondition) {
|
||||
qs.skipRemoteOnlyCondition = additionalFields.skipRemoteOnlyCondition as boolean;
|
||||
}
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}/transitions`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.transitions;
|
||||
returnData.push.apply(returnData, responseData);
|
||||
}
|
||||
@@ -784,13 +908,19 @@ export class Jira implements INodeType {
|
||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||
const deleteSubtasks = this.getNodeParameter('deleteSubtasks', i) as boolean;
|
||||
qs.deleteSubtasks = deleteSubtasks;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'DELETE', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}`,
|
||||
'DELETE',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (resource === 'issueAttachment') {
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
|
||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-issue-issueidorkey-attachments-post
|
||||
if (operation === 'add') {
|
||||
@@ -799,7 +929,9 @@ export class Jira implements INodeType {
|
||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||
|
||||
if (items[i].binary === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
const item = items[i].binary as IBinaryKeyData;
|
||||
@@ -808,7 +940,11 @@ export class Jira implements INodeType {
|
||||
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
|
||||
|
||||
if (binaryData === undefined) {
|
||||
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`, { itemIndex: i });
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`No binary data property "${binaryPropertyName}" does not exists on item!`,
|
||||
{ itemIndex: i },
|
||||
);
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
@@ -836,7 +972,13 @@ export class Jira implements INodeType {
|
||||
if (operation === 'remove') {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'DELETE', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/attachment/${attachmentId}`,
|
||||
'DELETE',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
}
|
||||
@@ -845,17 +987,38 @@ export class Jira implements INodeType {
|
||||
const download = this.getNodeParameter('download', 0) as boolean;
|
||||
for (let i = 0; i < length; i++) {
|
||||
const attachmentId = this.getNodeParameter('attachmentId', i) as string;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/attachment/${attachmentId}`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/attachment/${attachmentId}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push({ json: responseData });
|
||||
}
|
||||
if (download) {
|
||||
const binaryPropertyName = this.getNodeParameter('binaryProperty', 0) as string;
|
||||
for (const [index, attachment] of returnData.entries()) {
|
||||
returnData[index]['binary'] = {};
|
||||
|
||||
const buffer = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
'',
|
||||
'GET',
|
||||
{},
|
||||
{},
|
||||
// @ts-ignore
|
||||
attachment?.json!.content,
|
||||
{ json: false, encoding: null },
|
||||
);
|
||||
//@ts-ignore
|
||||
const buffer = await jiraSoftwareCloudApiRequest.call(this, '', 'GET', {}, {}, attachment?.json!.content, { json: false, encoding: null });
|
||||
//@ts-ignore
|
||||
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType);
|
||||
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(
|
||||
buffer,
|
||||
// @ts-ignore
|
||||
attachment.json.filename,
|
||||
// @ts-ignore
|
||||
attachment.json.mimeType,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -864,7 +1027,15 @@ export class Jira implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
|
||||
const { fields: { attachment } } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs);
|
||||
const {
|
||||
fields: { attachment },
|
||||
} = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/2/issue/${issueKey}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
responseData = attachment;
|
||||
if (returnAll === false) {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
@@ -878,16 +1049,31 @@ export class Jira implements INodeType {
|
||||
for (const [index, attachment] of returnData.entries()) {
|
||||
returnData[index]['binary'] = {};
|
||||
//@ts-ignore
|
||||
const buffer = await jiraSoftwareCloudApiRequest.call(this, '', 'GET', {}, {}, attachment.json.content, { json: false, encoding: null });
|
||||
const buffer = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
'',
|
||||
'GET',
|
||||
{},
|
||||
{},
|
||||
// @ts-ignore
|
||||
attachment.json.content,
|
||||
{ json: false, encoding: null },
|
||||
);
|
||||
//@ts-ignore
|
||||
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType);
|
||||
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(
|
||||
buffer,
|
||||
// @ts-ignore
|
||||
attachment.json.filename,
|
||||
// @ts-ignore
|
||||
attachment.json.mimeType,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'issueComment') {
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
|
||||
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-post
|
||||
if (operation === 'add') {
|
||||
@@ -929,13 +1115,21 @@ export class Jira implements INodeType {
|
||||
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
||||
const json = validateJSON(commentJson);
|
||||
if (json === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(body, { body: json });
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'POST', body, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment`,
|
||||
'POST',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
@@ -946,7 +1140,13 @@ export class Jira implements INodeType {
|
||||
const commentId = this.getNodeParameter('commentId', i) as string;
|
||||
const options = this.getNodeParameter('options', i) as IDataObject;
|
||||
Object.assign(qs, options);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
@@ -959,11 +1159,24 @@ export class Jira implements INodeType {
|
||||
const body: IDataObject = {};
|
||||
Object.assign(qs, options);
|
||||
if (returnAll) {
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'comments', `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequestAllItems.call(
|
||||
this,
|
||||
'comments',
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment`,
|
||||
'GET',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i) as number;
|
||||
body.maxResults = limit;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'GET', body, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment`,
|
||||
'GET',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
responseData = responseData.comments;
|
||||
}
|
||||
returnData.push.apply(returnData, responseData);
|
||||
@@ -974,7 +1187,13 @@ export class Jira implements INodeType {
|
||||
for (let i = 0; i < length; i++) {
|
||||
const issueKey = this.getNodeParameter('issueKey', i) as string;
|
||||
const commentId = this.getNodeParameter('commentId', i) as string;
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'DELETE', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`,
|
||||
'DELETE',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
}
|
||||
@@ -1018,19 +1237,27 @@ export class Jira implements INodeType {
|
||||
const commentJson = this.getNodeParameter('commentJson', i) as string;
|
||||
const json = validateJSON(commentJson);
|
||||
if (json === '') {
|
||||
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', { itemIndex: i });
|
||||
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON', {
|
||||
itemIndex: i,
|
||||
});
|
||||
}
|
||||
|
||||
Object.assign(body, { body: json });
|
||||
}
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'PUT', body, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`,
|
||||
'PUT',
|
||||
body,
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (resource === 'user') {
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : '3' as string;
|
||||
const apiVersion = jiraVersion === 'server' ? '2' : ('3' as string);
|
||||
|
||||
if (operation === 'create') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-post
|
||||
@@ -1045,14 +1272,26 @@ export class Jira implements INodeType {
|
||||
|
||||
Object.assign(body, additionalFields);
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'POST', body, {});
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/user`,
|
||||
'POST',
|
||||
body,
|
||||
{},
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
} else if (operation === 'delete') {
|
||||
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-delete
|
||||
for (let i = 0; i < length; i++) {
|
||||
qs.accountId = this.getNodeParameter('accountId', i);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'DELETE', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/user`,
|
||||
'DELETE',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push({ success: true });
|
||||
}
|
||||
} else if (operation === 'get') {
|
||||
@@ -1066,7 +1305,13 @@ export class Jira implements INodeType {
|
||||
qs.expand = expand.join(',');
|
||||
}
|
||||
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'GET', {}, qs);
|
||||
responseData = await jiraSoftwareCloudApiRequest.call(
|
||||
this,
|
||||
`/api/${apiVersion}/user`,
|
||||
'GET',
|
||||
{},
|
||||
qs,
|
||||
);
|
||||
returnData.push(responseData);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user