From 1c7a38f6bab108daa47401cd98c185590bf299a8 Mon Sep 17 00:00:00 2001 From: Gerard de Vries <85509036+GKdeVries@users.noreply.github.com> Date: Wed, 22 Jan 2025 12:43:13 +0100 Subject: [PATCH] feat(Jira Software Node): Personal Access Token credential type (#11038) --- .../JiraSoftwareServerPatApi.credentials.ts | 47 +++++++++++++++++++ .../nodes-base/nodes/Jira/GenericFunctions.ts | 5 +- packages/nodes-base/nodes/Jira/Jira.node.ts | 36 ++++++++++---- .../nodes-base/nodes/Jira/JiraTrigger.node.ts | 14 ++++++ packages/nodes-base/package.json | 1 + 5 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 packages/nodes-base/credentials/JiraSoftwareServerPatApi.credentials.ts diff --git a/packages/nodes-base/credentials/JiraSoftwareServerPatApi.credentials.ts b/packages/nodes-base/credentials/JiraSoftwareServerPatApi.credentials.ts new file mode 100644 index 0000000000..96dabd5808 --- /dev/null +++ b/packages/nodes-base/credentials/JiraSoftwareServerPatApi.credentials.ts @@ -0,0 +1,47 @@ +import type { + IAuthenticateGeneric, + ICredentialTestRequest, + ICredentialType, + INodeProperties, +} from 'n8n-workflow'; + +export class JiraSoftwareServerPatApi implements ICredentialType { + name = 'jiraSoftwareServerPatApi'; + + displayName = 'Jira SW Server (PAT) API'; + + documentationUrl = 'jira'; + + properties: INodeProperties[] = [ + { + displayName: 'Personal Access Token', + name: 'personalAccessToken', + typeOptions: { password: true }, + type: 'string', + default: '', + }, + { + displayName: 'Domain', + name: 'domain', + type: 'string', + default: '', + placeholder: 'https://example.com', + }, + ]; + + authenticate: IAuthenticateGeneric = { + type: 'generic', + properties: { + headers: { + Authorization: '=Bearer {{$credentials.personalAccessToken}}', + }, + }, + }; + + test: ICredentialTestRequest = { + request: { + baseURL: '={{$credentials?.domain}}', + url: '/rest/api/2/project', + }, + }; +} diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index b5ea100ca1..129b78ad73 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -28,6 +28,9 @@ export async function jiraSoftwareCloudApiRequest( if (jiraVersion === 'server') { domain = (await this.getCredentials('jiraSoftwareServerApi')).domain as string; credentialType = 'jiraSoftwareServerApi'; + } else if (jiraVersion === 'serverPat') { + domain = (await this.getCredentials('jiraSoftwareServerPatApi')).domain as string; + credentialType = 'jiraSoftwareServerPatApi'; } else { domain = (await this.getCredentials('jiraSoftwareCloudApi')).domain as string; credentialType = 'jiraSoftwareCloudApi'; @@ -233,7 +236,7 @@ export async function getUsers(this: ILoadOptionsFunctions): Promise