n8n/packages/nodes-base/nodes/Jira/Jira.node.ts

1115 lines
38 KiB
TypeScript
Raw Normal View History

2021-10-20 07:24:54 -07:00
import {
OptionsWithUri,
} from 'request';
2019-11-26 12:38:38 -08:00
import {
IExecuteFunctions,
} from 'n8n-core';
2020-04-23 22:59:19 -07:00
2019-11-26 12:38:38 -08:00
import {
IBinaryData,
IBinaryKeyData,
2021-10-20 07:24:54 -07:00
ICredentialsDecrypted,
ICredentialTestFunctions,
2019-11-26 12:38:38 -08:00
IDataObject,
ILoadOptionsFunctions,
:sparkles: Nodes as JSON and authentication redesign (#2401) * :sparkles: change FE to handle new object type * 🚸 improve UX of handling invalid credentials * 🚧 WIP * :art: fix typescript issues * 🐘 add migrations for all supported dbs * ✏️ add description to migrations * :zap: add credential update on import * :zap: resolve after merge issues * :shirt: fix lint issues * :zap: check credentials on workflow create/update * update interface * :shirt: fix ts issues * :zap: adaption to new credentials UI * :bug: intialize cache on BE for credentials check * :bug: fix undefined oldCredentials * :bug: fix deleting credential * :bug: fix check for undefined keys * :bug: fix disabling edit in execution * :art: just show credential name on execution view * ✏️ remove TODO * :zap: implement review suggestions * :zap: add cache to getCredentialsByType * ⏪ use getter instead of cache * ✏️ fix variable name typo * 🐘 include waiting nodes to migrations * :bug: fix reverting migrations command * :zap: update typeorm command * :sparkles: create db:revert command * 👕 fix lint error * :sparkles: Add optional authenticate method to credentials * :zap: Simplify code and add authentication support to MattermostApi * :shirt: Fix lint issue * :zap: Add support to own-mode * :shirt: Fix lint issue * :sparkles: Add support for predefined auth types bearer and headerAuth * :zap: Make sure that DateTime Node always returns strings * :zap: Add support for moment types to If Node * :zap: Make it possible for HTTP Request Node to use all credential types * :sparkles: Add basicAuth support * Add a new dropcontact node * :sparkles: First basic implementation of mainly JSON based nodes * :sparkles: Add fixedCollection support, added value parameter and expression support for value and property * Improvements to #2389 * :zap: Add credentials verification * :zap: Small improvement * :zap: set default time to 45 seconds * :sparkles: Add support for preSend and postReceive methods * :heavy_plus_sign: Add lodash merge and set depedency to workflow * :shirt: Fix lint issue * :zap: Improvements * :zap: Improvements * :zap: Improvements * :zap: Improvements * :zap: Improvements * :bug: Set siren and language correctly * :zap: Add support for requestDefaults * :zap: Add support for baseURL to httpRequest * :zap: Move baseURL to correct location * :sparkles: Add support for options loading * :bug: Fix error with fullAccess nodes * :sparkles: Add credential test functionality * :bug: Fix issue with OAuth autentication and lint issue * :zap: Fix build issue * :bug: Fix issue that url got always overwritten to empty * :sparkles: Add pagination support * :zap: Code fix required after merge * :zap: Remove not needed imports * :zap: Fix credential test * :sparkles: Add expression support for request properties and $self support on properties * :zap: Rename $self to $value * :shirt: Fix lint issue * :zap: Add example how to send data in path * :sparkles: Make it possible to not sent in dot notation * :sparkles: Add support for postReceive:rootProperty * :zap: Fix typo * :sparkles: Add support for postReceive:set * :zap: Some fixes * :zap: Small improvement * ;zap: Separate RoutingNode code * :zap: Simplify code and fix bug * :zap: Remove unused code * :sparkles: Make it possible to define "request" and "requestProperty" on options * :shirt: Fix lint issue * :zap: Change $credentials variables name * :sparkles: Enable expressions and access to credentials in requestDefaults * :zap: Make parameter option loading use RoutingNode.makeRoutingRequest * :sparkles: Allow requestOperations overwrite on LoadOptions * :sparkles: Make it possible to access current node parameters in loadOptions * :zap: Rename parameters variable to make future proof * :zap: Make it possible to use offset-pagination with body * :sparkles: Add support for queryAuth * :zap: Never return more items than requested * :sparkles: Make it possible to overwrite requestOperations on parameter and option level * :shirt: Fix lint issue * :sparkles: Allow simplified auth also with regular nodes * :sparkles: Add support for receiving binary data * :bug: Fix example node * :zap: Rename property "name" to "displayName" in loadOptions * :zap: Send data by default as "query" if nothing is set * :zap: Rename $self to $parent * :zap: Change to work with INodeExecutionData instead of IDataObject * :zap: Improve binaryData handling * :zap: Property design improvements * :zap: Fix property name * :rotating_light: Add some tests * :zap: Add also test for request * :zap: Improve test and fix issues * :zap: Improvements to loadOptions * :zap: Normalize loadOptions with rest of code * :zap: Add info text * :sparkles: Add support for $value in postReceive * :rotating_light: Add tests for RoutingNode.runNode * :zap: Remove TODOs and make url property optional * :zap: Fix bug and lint issue * :bug: Fix bug that not the correct property got used * :rotating_light: Add tests for CredentialsHelper.authenticate * :zap: Improve code and resolve expressions also everywhere for loadOptions and credential test requests * :sparkles: Make it possible to define multiple preSend and postReceive actions * :sparkles: Allow to define tests on credentials * :zap: Remove test data * :arrow_up: Update package-lock.json file * :zap: Remove old not longer used code Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: PaulineDropcontact <pauline@dropcontact.io> Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
2022-02-05 13:55:43 -08:00
INodeCredentialTestResult,
2020-04-23 22:59:19 -07:00
INodeExecutionData,
2019-11-26 12:38:38 -08:00
INodePropertyOptions,
2020-04-23 22:59:19 -07:00
INodeType,
INodeTypeDescription,
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
NodeOperationError,
2019-11-26 12:38:38 -08:00
} from 'n8n-workflow';
2020-04-23 22:59:19 -07:00
2019-11-26 12:38:38 -08:00
import {
jiraSoftwareCloudApiRequest,
jiraSoftwareCloudApiRequestAllItems,
2019-11-26 12:38:38 -08:00
validateJSON,
} from './GenericFunctions';
2020-04-23 22:59:19 -07:00
import {
issueAttachmentFields,
issueAttachmentOperations,
} from './IssueAttachmentDescription';
import {
issueCommentFields,
issueCommentOperations,
} from './IssueCommentDescription';
2019-11-27 14:42:28 -08:00
import {
issueFields,
issueOperations,
2019-11-27 14:42:28 -08:00
} from './IssueDescription';
2020-04-23 22:59:19 -07:00
import {
IFields,
2020-04-23 22:59:19 -07:00
IIssue,
2019-11-29 14:30:00 -08:00
INotificationRecipients,
2020-04-23 22:59:19 -07:00
INotify,
2019-11-29 14:30:00 -08:00
NotificationRecipientsRestrictions,
} from './IssueInterface';
2019-11-26 12:38:38 -08:00
import {
userFields,
userOperations,
} from './UserDescription';
2020-05-12 06:08:19 -07:00
export class Jira implements INodeType {
2019-11-26 12:38:38 -08:00
description: INodeTypeDescription = {
2020-02-01 15:15:56 -08:00
displayName: 'Jira Software',
2020-05-12 06:08:19 -07:00
name: 'jira',
icon: 'file:jira.svg',
2019-11-26 12:38:38 -08:00
group: ['output'],
version: 1,
subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
2020-02-01 15:15:56 -08:00
description: 'Consume Jira Software API',
2019-11-26 12:38:38 -08:00
defaults: {
2020-05-12 06:08:19 -07:00
name: 'Jira',
2019-11-26 12:38:38 -08:00
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'jiraSoftwareCloudApi',
2019-11-26 12:38:38 -08:00
required: true,
2020-02-02 07:01:56 -08:00
displayOptions: {
show: {
jiraVersion: [
'cloud',
],
},
},
2021-10-20 07:24:54 -07:00
testedBy: 'jiraSoftwareApiTest',
2020-02-02 07:01:56 -08:00
},
{
name: 'jiraSoftwareServerApi',
required: true,
displayOptions: {
show: {
jiraVersion: [
'server',
],
},
},
2021-10-20 07:24:54 -07:00
testedBy: 'jiraSoftwareApiTest',
2020-02-01 15:15:56 -08:00
},
2019-11-26 12:38:38 -08:00
],
properties: [
2020-02-02 07:01:56 -08:00
{
displayName: 'Jira Version',
name: 'jiraVersion',
type: 'options',
options: [
{
name: 'Cloud',
value: 'cloud',
},
{
name: 'Server (Self Hosted)',
value: 'server',
},
],
default: 'cloud',
},
2019-11-26 12:38:38 -08:00
{
displayName: 'Resource',
name: 'resource',
type: 'options',
options: [
{
name: 'Issue',
value: 'issue',
description: 'Creates an issue or, where the option to create subtasks is enabled in Jira, a subtask',
},
{
name: 'Issue Attachment',
value: 'issueAttachment',
description: 'Add, remove, and get an attachment from an issue.',
},
{
name: 'Issue Comment',
value: 'issueComment',
description: 'Get, create, update, and delete a comment from an issue.',
},
{
name: 'User',
value: 'user',
description: 'Get, create and delete a user.',
},
2019-11-26 12:38:38 -08:00
],
default: 'issue',
description: 'Resource to consume.',
},
2020-02-01 15:15:56 -08:00
...issueOperations,
2019-11-27 14:42:28 -08:00
...issueFields,
...issueAttachmentOperations,
...issueAttachmentFields,
...issueCommentOperations,
...issueCommentFields,
...userOperations,
...userFields,
2019-11-26 12:38:38 -08:00
],
};
2019-11-27 14:42:28 -08:00
methods = {
2021-10-20 07:24:54 -07:00
credentialTest: {
:sparkles: Nodes as JSON and authentication redesign (#2401) * :sparkles: change FE to handle new object type * 🚸 improve UX of handling invalid credentials * 🚧 WIP * :art: fix typescript issues * 🐘 add migrations for all supported dbs * ✏️ add description to migrations * :zap: add credential update on import * :zap: resolve after merge issues * :shirt: fix lint issues * :zap: check credentials on workflow create/update * update interface * :shirt: fix ts issues * :zap: adaption to new credentials UI * :bug: intialize cache on BE for credentials check * :bug: fix undefined oldCredentials * :bug: fix deleting credential * :bug: fix check for undefined keys * :bug: fix disabling edit in execution * :art: just show credential name on execution view * ✏️ remove TODO * :zap: implement review suggestions * :zap: add cache to getCredentialsByType * ⏪ use getter instead of cache * ✏️ fix variable name typo * 🐘 include waiting nodes to migrations * :bug: fix reverting migrations command * :zap: update typeorm command * :sparkles: create db:revert command * 👕 fix lint error * :sparkles: Add optional authenticate method to credentials * :zap: Simplify code and add authentication support to MattermostApi * :shirt: Fix lint issue * :zap: Add support to own-mode * :shirt: Fix lint issue * :sparkles: Add support for predefined auth types bearer and headerAuth * :zap: Make sure that DateTime Node always returns strings * :zap: Add support for moment types to If Node * :zap: Make it possible for HTTP Request Node to use all credential types * :sparkles: Add basicAuth support * Add a new dropcontact node * :sparkles: First basic implementation of mainly JSON based nodes * :sparkles: Add fixedCollection support, added value parameter and expression support for value and property * Improvements to #2389 * :zap: Add credentials verification * :zap: Small improvement * :zap: set default time to 45 seconds * :sparkles: Add support for preSend and postReceive methods * :heavy_plus_sign: Add lodash merge and set depedency to workflow * :shirt: Fix lint issue * :zap: Improvements * :zap: Improvements * :zap: Improvements * :zap: Improvements * :zap: Improvements * :bug: Set siren and language correctly * :zap: Add support for requestDefaults * :zap: Add support for baseURL to httpRequest * :zap: Move baseURL to correct location * :sparkles: Add support for options loading * :bug: Fix error with fullAccess nodes * :sparkles: Add credential test functionality * :bug: Fix issue with OAuth autentication and lint issue * :zap: Fix build issue * :bug: Fix issue that url got always overwritten to empty * :sparkles: Add pagination support * :zap: Code fix required after merge * :zap: Remove not needed imports * :zap: Fix credential test * :sparkles: Add expression support for request properties and $self support on properties * :zap: Rename $self to $value * :shirt: Fix lint issue * :zap: Add example how to send data in path * :sparkles: Make it possible to not sent in dot notation * :sparkles: Add support for postReceive:rootProperty * :zap: Fix typo * :sparkles: Add support for postReceive:set * :zap: Some fixes * :zap: Small improvement * ;zap: Separate RoutingNode code * :zap: Simplify code and fix bug * :zap: Remove unused code * :sparkles: Make it possible to define "request" and "requestProperty" on options * :shirt: Fix lint issue * :zap: Change $credentials variables name * :sparkles: Enable expressions and access to credentials in requestDefaults * :zap: Make parameter option loading use RoutingNode.makeRoutingRequest * :sparkles: Allow requestOperations overwrite on LoadOptions * :sparkles: Make it possible to access current node parameters in loadOptions * :zap: Rename parameters variable to make future proof * :zap: Make it possible to use offset-pagination with body * :sparkles: Add support for queryAuth * :zap: Never return more items than requested * :sparkles: Make it possible to overwrite requestOperations on parameter and option level * :shirt: Fix lint issue * :sparkles: Allow simplified auth also with regular nodes * :sparkles: Add support for receiving binary data * :bug: Fix example node * :zap: Rename property "name" to "displayName" in loadOptions * :zap: Send data by default as "query" if nothing is set * :zap: Rename $self to $parent * :zap: Change to work with INodeExecutionData instead of IDataObject * :zap: Improve binaryData handling * :zap: Property design improvements * :zap: Fix property name * :rotating_light: Add some tests * :zap: Add also test for request * :zap: Improve test and fix issues * :zap: Improvements to loadOptions * :zap: Normalize loadOptions with rest of code * :zap: Add info text * :sparkles: Add support for $value in postReceive * :rotating_light: Add tests for RoutingNode.runNode * :zap: Remove TODOs and make url property optional * :zap: Fix bug and lint issue * :bug: Fix bug that not the correct property got used * :rotating_light: Add tests for CredentialsHelper.authenticate * :zap: Improve code and resolve expressions also everywhere for loadOptions and credential test requests * :sparkles: Make it possible to define multiple preSend and postReceive actions * :sparkles: Allow to define tests on credentials * :zap: Remove test data * :arrow_up: Update package-lock.json file * :zap: Remove old not longer used code Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Mutasem <mutdmour@gmail.com> Co-authored-by: PaulineDropcontact <pauline@dropcontact.io> Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
2022-02-05 13:55:43 -08:00
async jiraSoftwareApiTest(this: ICredentialTestFunctions, credential: ICredentialsDecrypted): Promise<INodeCredentialTestResult> {
2021-10-20 07:24:54 -07:00
const credentials = credential.data;
2021-10-20 20:24:03 -07:00
const data = Buffer.from(`${credentials!.email}:${credentials!.password || credentials!.apiToken}`).toString('base64');
2021-10-20 07:24:54 -07:00
const options: OptionsWithUri = {
headers: {
Authorization: `Basic ${data}`,
Accept: 'application/json',
'Content-Type': 'application/json',
'X-Atlassian-Token': 'no-check',
},
method: 'GET',
2021-10-20 20:24:03 -07:00
uri: `${credentials!.domain}/rest/api/2/project`,
2021-10-20 07:24:54 -07:00
qs: {
recent: 0,
},
json: true,
timeout: 5000,
};
try {
2021-10-20 20:24:03 -07:00
await this.helpers.request!(options);
2021-10-20 07:24:54 -07:00
} catch (err) {
return {
status: 'Error',
2021-11-11 03:08:05 -08:00
message: `Connection details not valid: ${err.message}`,
2021-10-20 07:24:54 -07:00
};
}
return {
status: 'OK',
message: 'Authentication successful!',
};
},
},
2019-11-27 14:42:28 -08:00
loadOptions: {
// Get all the projects to display them to user so that he can
// select them easily
async getProjects(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
let endpoint = '';
let projects;
if (jiraVersion === 'server') {
endpoint = '/api/2/project';
projects = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET');
} else {
endpoint = '/api/2/project/search';
projects = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', endpoint, 'GET');
2020-02-01 15:15:56 -08:00
}
2020-04-23 22:59:19 -07:00
2020-02-01 15:15:56 -08:00
if (projects.values && Array.isArray(projects.values)) {
projects = projects.values;
}
for (const project of projects) {
2019-11-27 14:42:28 -08:00
const projectName = project.name;
const projectId = project.id;
returnData.push({
name: projectName,
value: projectId,
});
}
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-27 14:42:28 -08:00
return returnData;
},
// Get all the issue types to display them to user so that he can
// select them easily
async getIssueTypes(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
2020-04-23 22:59:19 -07:00
const projectId = this.getCurrentNodeParameter('project');
2019-11-27 14:42:28 -08:00
const returnData: INodePropertyOptions[] = [];
const { issueTypes } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${projectId}`, 'GET');
for (const issueType of issueTypes) {
const issueTypeName = issueType.name;
const issueTypeId = issueType.id;
returnData.push({
name: issueTypeName,
value: issueTypeId,
});
2019-11-27 14:42:28 -08:00
}
2020-05-05 13:56:24 -07:00
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-27 14:42:28 -08:00
return returnData;
},
// Get all the labels to display them to user so that he can
// select them easily
async getLabels(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const labels = await jiraSoftwareCloudApiRequest.call(this, '/api/2/label', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-27 14:42:28 -08:00
for (const label of labels.values) {
const labelName = label;
const labelId = label;
returnData.push({
name: labelName,
value: labelId,
});
}
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-27 14:42:28 -08:00
return returnData;
},
// Get all the priorities to display them to user so that he can
// select them easily
async getPriorities(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const priorities = await jiraSoftwareCloudApiRequest.call(this, '/api/2/priority', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-27 14:42:28 -08:00
for (const priority of priorities) {
const priorityName = priority.name;
const priorityId = priority.id;
returnData.push({
name: priorityName,
value: priorityId,
});
}
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-27 14:42:28 -08:00
return returnData;
},
// Get all the users to display them to user so that he can
// select them easily
async getUsers(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-05-05 13:56:24 -07:00
const jiraVersion = this.getCurrentNodeParameter('jiraVersion') as string;
if (jiraVersion === 'server') {
// the interface call must bring username
const users = await jiraSoftwareCloudApiRequest.call(this, '/api/2/user/search', 'GET', {},
{
2021-01-13 11:20:30 -08:00
username: '\'',
2020-10-22 09:00:28 -07:00
},
);
for (const user of users) {
const userName = user.displayName;
const userId = user.name;
2020-05-05 13:56:24 -07:00
returnData.push({
name: userName,
value: userId,
});
}
} else {
const users = await jiraSoftwareCloudApiRequest.call(this, '/api/2/users/search', 'GET');
2020-04-23 22:59:19 -07:00
for (const user of users) {
const userName = user.displayName;
const userId = user.accountId;
2019-11-27 14:42:28 -08:00
returnData.push({
name: userName,
value: userId,
});
}
2019-11-27 14:42:28 -08:00
}
2020-05-05 13:56:24 -07:00
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-27 14:42:28 -08:00
return returnData;
},
2019-11-29 14:30:00 -08:00
// Get all the groups to display them to user so that he can
// select them easily
async getGroups(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
2020-04-23 22:59:19 -07:00
const groups = await jiraSoftwareCloudApiRequest.call(this, '/api/2/groups/picker', 'GET');
2020-04-23 22:59:19 -07:00
2019-11-29 14:30:00 -08:00
for (const group of groups.groups) {
const groupName = group.name;
const groupId = group.name;
returnData.push({
name: groupName,
value: groupId,
});
}
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2019-11-29 14:30:00 -08:00
return returnData;
2020-04-24 00:50:56 -07:00
},
// Get all the groups to display them to user so that he can
// select them easily
async getTransitions(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const issueKey = this.getCurrentNodeParameter('issueKey');
const transitions = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET');
2020-04-24 00:50:56 -07:00
for (const transition of transitions.transitions) {
returnData.push({
name: transition.name,
value: transition.id,
});
}
2020-11-09 22:49:43 -08:00
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
2020-04-24 00:50:56 -07:00
return returnData;
},
// Get all the custom fields to display them to user so that he can
// select them easily
async getCustomFields(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const operation = this.getCurrentNodeParameter('operation') as string;
let projectId: string;
let issueTypeId: string;
if (operation === 'create') {
projectId = this.getCurrentNodeParameter('project') as string;
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', {}, {});
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');
2021-10-20 07:24:54 -07:00
// tslint:disable-next-line: no-any
const fields = res.projects.find((o: any) => o.id === projectId).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')) {
returnData.push({
name: field.name,
value: field.key || field.fieldId,
});
}
}
return returnData;
},
// Get all the components to display them to user so that he can
// select them easily
async getProjectComponents(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {
const returnData: INodePropertyOptions[] = [];
const project = this.getCurrentNodeParameter('project');
const { values: components } = await jiraSoftwareCloudApiRequest.call(this, `/api/2/project/${project}/component`, 'GET');
for (const component of components) {
returnData.push({
name: component.name,
value: component.id,
});
}
returnData.sort((a, b) => {
if (a.name < b.name) { return -1; }
if (a.name > b.name) { return 1; }
return 0;
});
return returnData;
},
2020-10-22 06:46:03 -07:00
},
2019-11-27 14:42:28 -08:00
};
2019-11-26 12:38:38 -08:00
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
2019-11-27 14:42:28 -08:00
const items = this.getInputData();
const returnData: IDataObject[] = [];
const length = items.length as unknown as number;
let responseData;
2019-11-29 14:30:00 -08:00
const qs: IDataObject = {};
2019-12-02 13:40:24 -08:00
const resource = this.getNodeParameter('resource', 0) as string;
const operation = this.getNodeParameter('operation', 0) as string;
const jiraVersion = this.getNodeParameter('jiraVersion', 0) as string;
if (resource === 'issue') {
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-post
if (operation === 'create') {
for (let i = 0; i < length; i++) {
2019-11-27 14:42:28 -08:00
const summary = this.getNodeParameter('summary', i) as string;
const projectId = this.getNodeParameter('project', i) as string;
const issueTypeId = this.getNodeParameter('issueType', i) as string;
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
const body: IIssue = {};
const fields: IFields = {
summary,
project: {
id: projectId,
},
issuetype: {
id: issueTypeId,
},
2019-11-27 14:42:28 -08:00
};
if (additionalFields.labels) {
fields.labels = additionalFields.labels as string[];
2019-11-27 14:42:28 -08:00
}
if (additionalFields.serverLabels) {
fields.labels = additionalFields.serverLabels as string[];
}
2019-11-27 14:42:28 -08:00
if (additionalFields.priority) {
fields.priority = {
2019-11-27 14:42:28 -08:00
id: additionalFields.priority as string,
};
}
if (additionalFields.assignee) {
2020-05-05 13:56:24 -07:00
if (jiraVersion === 'server') {
fields.assignee = {
name: additionalFields.assignee as string,
};
} else {
fields.assignee = {
id: additionalFields.assignee as string,
};
}
2019-11-27 14:42:28 -08:00
}
if (additionalFields.reporter) {
if (jiraVersion === 'server') {
fields.reporter = {
name: additionalFields.reporter as string,
};
} else {
fields.reporter = {
id: additionalFields.reporter as string,
};
}
}
if (additionalFields.description) {
fields.description = additionalFields.description as string;
}
2019-11-29 14:30:00 -08:00
if (additionalFields.updateHistory) {
qs.updateHistory = additionalFields.updateHistory as boolean;
}
if (additionalFields.componentIds) {
fields.components = (additionalFields.componentIds as string[]).map(id => ({ id }));
}
if (additionalFields.customFieldsUi) {
const customFields = (additionalFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
if (customFields) {
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);
2019-11-29 14:30:00 -08:00
const subtaskIssues = [];
for (const issueType of issueTypes) {
if (issueType.subtask) {
subtaskIssues.push(issueType.id);
2019-11-27 14:42:28 -08:00
}
}
2019-12-01 13:47:53 -08:00
if (!additionalFields.parentIssueKey
&& subtaskIssues.includes(issueTypeId)) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task');
2019-11-29 14:30:00 -08:00
2019-12-01 13:47:53 -08:00
} else if (additionalFields.parentIssueKey
&& subtaskIssues.includes(issueTypeId)) {
2019-11-29 14:30:00 -08:00
fields.parent = {
2019-12-01 13:47:53 -08:00
key: (additionalFields.parentIssueKey as string).toUpperCase(),
2019-11-29 14:30:00 -08:00
};
}
body.fields = fields;
responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issue', 'POST', body);
returnData.push(responseData);
2019-11-27 14:42:28 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-put
if (operation === 'update') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;
2019-11-29 14:30:00 -08:00
const body: IIssue = {};
2019-12-01 13:47:53 -08:00
const fields: IFields = {};
if (updateFields.summary) {
fields.summary = updateFields.summary as string;
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
if (updateFields.issueType) {
fields.issuetype = {
id: updateFields.issueType as string,
};
}
if (updateFields.labels) {
fields.labels = updateFields.labels as string[];
}
if (updateFields.serverLabels) {
fields.labels = updateFields.serverLabels as string[];
}
2019-12-01 13:47:53 -08:00
if (updateFields.priority) {
2019-11-29 14:30:00 -08:00
fields.priority = {
2019-12-01 13:47:53 -08:00
id: updateFields.priority as string,
2019-11-29 14:30:00 -08:00
};
}
2019-12-01 13:47:53 -08:00
if (updateFields.assignee) {
2020-05-05 13:56:24 -07:00
if (jiraVersion === 'server') {
fields.assignee = {
name: updateFields.assignee as string,
};
} else {
fields.assignee = {
id: updateFields.assignee as string,
};
}
2019-11-29 14:30:00 -08:00
}
if (updateFields.reporter) {
if (jiraVersion === 'server') {
fields.reporter = {
name: updateFields.reporter as string,
};
} else {
fields.reporter = {
id: updateFields.reporter as string,
};
}
}
2019-12-01 13:47:53 -08:00
if (updateFields.description) {
fields.description = updateFields.description as string;
2019-11-29 14:30:00 -08:00
}
if (updateFields.customFieldsUi) {
const customFields = (updateFields.customFieldsUi as IDataObject).customFieldsValues as IDataObject[];
if (customFields) {
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);
2019-11-29 14:30:00 -08:00
const subtaskIssues = [];
for (const issueType of issueTypes) {
if (issueType.subtask) {
subtaskIssues.push(issueType.id);
}
}
2019-12-01 13:47:53 -08:00
if (!updateFields.parentIssueKey
&& subtaskIssues.includes(updateFields.issueType)) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'You must define a Parent Issue Key when Issue type is sub-task');
2019-11-29 14:30:00 -08:00
2019-12-01 13:47:53 -08:00
} else if (updateFields.parentIssueKey
&& subtaskIssues.includes(updateFields.issueType)) {
2019-11-29 14:30:00 -08:00
fields.parent = {
2019-12-01 13:47:53 -08:00
key: (updateFields.parentIssueKey as string).toUpperCase(),
2019-11-29 14:30:00 -08:00
};
}
body.fields = fields;
2020-04-23 22:59:19 -07:00
if (updateFields.statusId) {
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'POST', { transition: { id: updateFields.statusId } });
2019-11-29 14:30:00 -08:00
}
2020-04-23 22:59:19 -07:00
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'PUT', body);
returnData.push({ success: true });
2019-11-29 14:30:00 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-get
if (operation === 'get') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.fields) {
qs.fields = additionalFields.fields as string;
}
if (additionalFields.fieldsByKey) {
qs.fieldsByKey = additionalFields.fieldsByKey as boolean;
}
if (additionalFields.expand) {
qs.expand = additionalFields.expand as string;
}
if (additionalFields.properties) {
qs.properties = additionalFields.properties as string;
}
if (additionalFields.updateHistory) {
qs.updateHistory = additionalFields.updateHistory as string;
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}`, 'GET', {}, qs);
returnData.push(responseData);
2019-11-29 14:30:00 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-search-post
if (operation === 'getAll') {
for (let i = 0; i < length; i++) {
2020-02-02 07:01:56 -08:00
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
const body: IDataObject = {};
if (options.fields) {
body.fields = (options.fields as string).split(',') as string[];
}
if (options.jql) {
body.jql = options.jql as string;
}
if (options.expand) {
if (typeof options.expand === 'string') {
body.expand = options.expand.split(',');
} else {
body.expand = options.expand;
}
2020-02-02 07:01:56 -08:00
}
if (returnAll) {
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'issues', `/api/2/search`, 'POST', body);
2020-02-02 07:01:56 -08:00
} else {
const limit = this.getNodeParameter('limit', i) as number;
body.maxResults = limit;
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/search`, 'POST', body);
2020-02-02 07:01:56 -08:00
responseData = responseData.issues;
}
returnData.push.apply(returnData, responseData);
2020-02-02 07:01:56 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-changelog-get
if (operation === 'changelog') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
const issueKey = this.getNodeParameter('issueKey', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
2020-04-23 22:59:19 -07:00
if (returnAll) {
responseData = await jiraSoftwareCloudApiRequestAllItems.call(this, 'values', `/api/2/issue/${issueKey}/changelog`, 'GET');
2020-04-23 22:59:19 -07:00
} else {
qs.maxResults = this.getNodeParameter('limit', i) as number;
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/changelog`, 'GET', {}, qs);
2020-04-23 22:59:19 -07:00
responseData = responseData.values;
2019-11-29 14:30:00 -08:00
}
returnData.push.apply(returnData, responseData);
2019-11-29 14:30:00 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-notify-post
if (operation === 'notify') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
2019-11-29 14:30:00 -08:00
const jsonActive = this.getNodeParameter('jsonParameters', 0) as boolean;
const body: INotify = {};
2019-12-01 13:47:53 -08:00
if (additionalFields.textBody) {
body.textBody = additionalFields.textBody as string;
}
if (additionalFields.htmlBody) {
body.htmlBody = additionalFields.htmlBody as string;
}
2019-11-29 14:30:00 -08:00
if (!jsonActive) {
const notificationRecipientsValues = (this.getNodeParameter('notificationRecipientsUi', i) as IDataObject).notificationRecipientsValues as IDataObject[];
const notificationRecipients: INotificationRecipients = {};
if (notificationRecipientsValues) {
// @ts-ignore
if (notificationRecipientsValues.reporter) {
// @ts-ignore
notificationRecipients.reporter = notificationRecipientsValues.reporter as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.assignee) {
// @ts-ignore
notificationRecipients.assignee = notificationRecipientsValues.assignee as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.assignee) {
// @ts-ignore
notificationRecipients.watchers = notificationRecipientsValues.watchers as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.voters) {
// @ts-ignore
notificationRecipients.watchers = notificationRecipientsValues.voters as boolean;
}
// @ts-ignore
if (notificationRecipientsValues.users.length > 0) {
// @ts-ignore
notificationRecipients.users = notificationRecipientsValues.users.map(user => {
return {
2020-10-22 06:46:03 -07:00
accountId: user,
2019-11-29 14:30:00 -08:00
};
});
}
// @ts-ignore
if (notificationRecipientsValues.groups.length > 0) {
// @ts-ignore
notificationRecipients.groups = notificationRecipientsValues.groups.map(group => {
return {
2020-10-22 06:46:03 -07:00
name: group,
2019-11-29 14:30:00 -08:00
};
});
}
}
body.to = notificationRecipients;
const notificationRecipientsRestrictionsValues = (this.getNodeParameter('notificationRecipientsRestrictionsUi', i) as IDataObject).notificationRecipientsRestrictionsValues as IDataObject[];
const notificationRecipientsRestrictions: NotificationRecipientsRestrictions = {};
if (notificationRecipientsRestrictionsValues) {
// @ts-ignore
if (notificationRecipientsRestrictionsValues.groups.length > 0) {
2019-11-29 14:30:00 -08:00
// @ts-ignore
notificationRecipientsRestrictions.groups = notificationRecipientsRestrictionsValues.groups.map(group => {
return {
2020-10-22 06:46:03 -07:00
name: group,
2019-11-29 14:30:00 -08:00
};
});
}
}
body.restrict = notificationRecipientsRestrictions;
} else {
const notificationRecipientsJson = validateJSON(this.getNodeParameter('notificationRecipientsJson', i) as string);
if (notificationRecipientsJson) {
body.to = notificationRecipientsJson;
}
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);
returnData.push(responseData);
2019-11-29 14:30:00 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-transitions-get
if (operation === 'transitions') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
const issueKey = this.getNodeParameter('issueKey', i) as string;
2019-12-01 13:47:53 -08:00
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
if (additionalFields.transitionId) {
qs.transitionId = additionalFields.transitionId as string;
2019-11-29 14:30:00 -08:00
}
2019-12-01 13:47:53 -08:00
if (additionalFields.expand) {
qs.expand = additionalFields.expand as string;
}
if (additionalFields.skipRemoteOnlyCondition) {
qs.skipRemoteOnlyCondition = additionalFields.skipRemoteOnlyCondition as boolean;
2019-11-29 14:30:00 -08:00
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/2/issue/${issueKey}/transitions`, 'GET', {}, qs);
2020-04-23 22:59:19 -07:00
responseData = responseData.transitions;
returnData.push.apply(returnData, responseData);
2019-11-29 14:30:00 -08:00
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-delete
if (operation === 'delete') {
for (let i = 0; i < length; i++) {
2019-11-29 14:30:00 -08:00
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);
returnData.push({ success: true });
2019-11-29 14:30:00 -08:00
}
2019-11-27 14:42:28 -08:00
}
}
if (resource === 'issueAttachment') {
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') {
for (let i = 0; i < length; i++) {
const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string;
const issueKey = this.getNodeParameter('issueKey', i) as string;
if (items[i].binary === undefined) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'No binary data exists on item!');
}
const item = items[i].binary as IBinaryKeyData;
const binaryData = item[binaryPropertyName] as IBinaryData;
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
if (binaryData === undefined) {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), `No binary data property "${binaryPropertyName}" does not exists on item!`);
}
responseData = await jiraSoftwareCloudApiRequest.call(
this,
`/api/${apiVersion}/issue/${issueKey}/attachments`,
'POST',
{},
{},
undefined,
{
formData: {
file: {
value: binaryDataBuffer,
options: {
filename: binaryData.fileName,
},
},
},
},
);
returnData.push.apply(returnData, responseData);
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-attachment-id-delete
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);
returnData.push({ success: true });
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-attachments/#api-rest-api-3-attachment-id-get
if (operation === 'get') {
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);
returnData.push({ json: responseData });
}
if (download) {
const binaryPropertyName = this.getNodeParameter('binaryProperty', 0) as string;
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 });
//@ts-ignore
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType);
}
}
}
if (operation === 'getAll') {
const download = this.getNodeParameter('download', 0) as boolean;
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);
responseData = attachment;
if (returnAll === false) {
const limit = this.getNodeParameter('limit', i) as number;
responseData = responseData.slice(0, limit);
}
responseData = responseData.map((data: IDataObject) => ({ json: data }));
returnData.push.apply(returnData, responseData);
}
if (download) {
const binaryPropertyName = this.getNodeParameter('binaryProperty', 0) as string;
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 });
//@ts-ignore
returnData[index]['binary'][binaryPropertyName] = await this.helpers.prepareBinaryData(buffer, attachment.json.filename, attachment.json.mimeType);
}
}
}
}
if (resource === 'issueComment') {
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') {
for (let i = 0; i < length; i++) {
const jsonParameters = this.getNodeParameter('jsonParameters', 0) as boolean;
const issueKey = this.getNodeParameter('issueKey', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
const body: IDataObject = {};
if (options.expand) {
qs.expand = options.expand as string;
delete options.expand;
}
Object.assign(body, options);
if (jsonParameters === false) {
const comment = this.getNodeParameter('comment', i) as string;
if (jiraVersion === 'server') {
Object.assign(body, { body: comment });
} else {
Object.assign(body, {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: comment,
},
],
},
],
},
});
}
} else {
const commentJson = this.getNodeParameter('commentJson', i) as string;
const json = validateJSON(commentJson);
if (json === '') {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON');
}
Object.assign(body, { body: json });
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment`, 'POST', body, qs);
returnData.push(responseData);
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v2/#api-rest-api-2-issue-issueIdOrKey-get
if (operation === 'get') {
for (let i = 0; i < length; i++) {
const issueKey = this.getNodeParameter('issueKey', i) as string;
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);
returnData.push(responseData);
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-get
if (operation === 'getAll') {
for (let i = 0; i < length; i++) {
const issueKey = this.getNodeParameter('issueKey', i) as string;
const returnAll = this.getNodeParameter('returnAll', i) as boolean;
const options = this.getNodeParameter('options', i) as IDataObject;
const body: IDataObject = {};
Object.assign(qs, options);
if (returnAll) {
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 = responseData.comments;
}
returnData.push.apply(returnData, responseData);
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-delete
if (operation === 'remove') {
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);
returnData.push({ success: true });
}
}
//https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-comments/#api-rest-api-3-issue-issueidorkey-comment-id-put
if (operation === 'update') {
for (let i = 0; i < length; i++) {
const issueKey = this.getNodeParameter('issueKey', i) as string;
const commentId = this.getNodeParameter('commentId', i) as string;
const options = this.getNodeParameter('options', i) as IDataObject;
const jsonParameters = this.getNodeParameter('jsonParameters', 0) as boolean;
const body: IDataObject = {};
if (options.expand) {
qs.expand = options.expand as string;
delete options.expand;
}
Object.assign(qs, options);
if (jsonParameters === false) {
const comment = this.getNodeParameter('comment', i) as string;
if (jiraVersion === 'server') {
Object.assign(body, { body: comment });
} else {
Object.assign(body, {
body: {
type: 'doc',
version: 1,
content: [
{
type: 'paragraph',
content: [
{
type: 'text',
text: comment,
},
],
},
],
},
});
}
} else {
const commentJson = this.getNodeParameter('commentJson', i) as string;
const json = validateJSON(commentJson);
if (json === '') {
:sparkles: Improve node error handling (#1309) * Add path mapping and response error interfaces * Add error handling and throwing functionality * Refactor error handling into a single function * Re-implement error handling in Hacker News node * Fix linting details * Re-implement error handling in Spotify node * Re-implement error handling in G Suite Admin node * :construction: create basic setup NodeError * :construction: add httpCodes * :construction: add path priolist * :construction: handle statusCode in error, adjust interfaces * :construction: fixing type issues w/Ivan * :construction: add error exploration * 👔 fix linter issues * :wrench: improve object check * :construction: remove path passing from NodeApiError * :construction: add multi error + refactor findProperty method * 👔 allow any * :wrench: handle multi error message callback * :zap: change return type of callback * :zap: add customCallback to MultiError * :construction: refactor to use INode * :hammer: handle arrays, continue search after first null property found * 🚫 refactor method access * :construction: setup NodeErrorView * :zap: change timestamp to Date.now * :books: Add documentation for methods and constants * :construction: change message setting * 🚚 move NodeErrors to workflow * :sparkles: add new ErrorView for Nodes * :art: improve error notification * :art: refactor interfaces * :zap: add WorkflowOperationError, refactor error throwing * 👕 fix linter issues * :art: rename param * :bug: fix handling normal errors * :zap: add usage of NodeApiError * :art: fix throw new error instead of constructor * :art: remove unnecessary code/comments * :art: adjusted spacing + updated status messages * :art: fix tab indentation * ✨ Replace current errors with custom errors (#1576) * :zap: Introduce NodeApiError in catch blocks * :zap: Introduce NodeOperationError in nodes * :zap: Add missing errors and remove incompatible * :zap: Fix NodeOperationError in incompatible nodes * :wrench: Adjust error handling in missed nodes PayPal, FileMaker, Reddit, Taiga and Facebook Graph API nodes * :hammer: Adjust Strava Trigger node error handling * :hammer: Adjust AWS nodes error handling * :hammer: Remove duplicate instantiation of NodeApiError * :bug: fix strava trigger node error handling * Add XML parsing to NodeApiError constructor (#1633) * :bug: Remove type annotation from catch variable * :sparkles: Add XML parsing to NodeApiError * :zap: Simplify error handling in Rekognition node * :zap: Pass in XML flag in generic functions * :fire: Remove try/catch wrappers at call sites * :hammer: Refactor setting description from XML * :hammer: Refactor let to const in resource loaders * :zap: Find property in parsed XML * :zap: Change let to const * :fire: Remove unneeded try/catch block * :shirt: Fix linting issues * :bug: Fix errors from merge conflict resolution * :zap: Add custom errors to latest contributions * :shirt: Fix linting issues * :zap: Refactor MongoDB helpers for custom errors * :bug: Correct custom error type * :zap: Apply feedback to A nodes * :zap: Apply feedback to missed A node * :zap: Apply feedback to B-D nodes * :zap: Apply feedback to E-F nodes * :zap: Apply feedback to G nodes * :zap: Apply feedback to H-L nodes * :zap: Apply feedback to M nodes * :zap: Apply feedback to P nodes * :zap: Apply feedback to R nodes * :zap: Apply feedback to S nodes * :zap: Apply feedback to T nodes * :zap: Apply feedback to V-Z nodes * :zap: Add HTTP code to iterable node error * :hammer: Standardize e as error * :hammer: Standardize err as error * :zap: Fix error handling for non-standard nodes Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com> Co-authored-by: Ben Hesseldieck <1849459+BHesseldieck@users.noreply.github.com>
2021-04-16 09:33:36 -07:00
throw new NodeOperationError(this.getNode(), 'Document Format must be a valid JSON');
}
Object.assign(body, { body: json });
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/issue/${issueKey}/comment/${commentId}`, 'PUT', body, qs);
returnData.push(responseData);
}
}
2019-11-27 14:42:28 -08:00
}
if (resource === 'user') {
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
for (let i = 0; i < length; i++) {
const body = {
name: this.getNodeParameter('username', i),
emailAddress: this.getNodeParameter('emailAddress', i),
displayName: this.getNodeParameter('displayName', i),
};
const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;
Object.assign(body, additionalFields);
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);
returnData.push({ success: true });
}
} else if (operation === 'get') {
// https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-get
for (let i = 0; i < length; i++) {
qs.accountId = this.getNodeParameter('accountId', i);
const { expand } = this.getNodeParameter('additionalFields', i) as { expand: string[] };
if (expand) {
qs.expand = expand.join(',');
}
responseData = await jiraSoftwareCloudApiRequest.call(this, `/api/${apiVersion}/user`, 'GET', {}, qs);
returnData.push(responseData);
}
}
}
if (resource === 'issueAttachment' && (operation === 'getAll' || operation === 'get')) {
return this.prepareOutputData(returnData as unknown as INodeExecutionData[]);
} else {
return [this.helpers.returnJsonArray(returnData)];
}
2019-11-26 12:38:38 -08:00
}
}