Extend Confluence Document Loader to Support Server/Data Center with PAT (#1998)
* Extend Confluence Document Loader to Support Server/Data Center with PAT - Update authentication to use Personal Access Token (PAT) - Expand compatibility to include both Confluence Cloud and Server/Data Center * Update ConfluenceServerDCApi.credential.ts * use the same confluence loader with different connection logic * use the same confluence loader with different connection logic * Apply Prettier formatting
This commit is contained in:
parent
7e84049990
commit
4ca82ee733
|
|
@ -1,6 +1,6 @@
|
|||
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||
|
||||
class ConfluenceApi implements INodeCredential {
|
||||
class ConfluenceCloudApi implements INodeCredential {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
|
|
@ -8,8 +8,8 @@ class ConfluenceApi implements INodeCredential {
|
|||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Confluence API'
|
||||
this.name = 'confluenceApi'
|
||||
this.label = 'Confluence Cloud API'
|
||||
this.name = 'confluenceCloudApi'
|
||||
this.version = 1.0
|
||||
this.description =
|
||||
'Refer to <a target="_blank" href="https://support.atlassian.com/confluence-cloud/docs/manage-oauth-access-tokens/">official guide</a> on how to get Access Token or <a target="_blank" href="https://id.atlassian.com/manage-profile/security/api-tokens">API Token</a> on Confluence'
|
||||
|
|
@ -30,4 +30,4 @@ class ConfluenceApi implements INodeCredential {
|
|||
}
|
||||
}
|
||||
|
||||
module.exports = { credClass: ConfluenceApi }
|
||||
module.exports = { credClass: ConfluenceCloudApi }
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
import { INodeParams, INodeCredential } from '../src/Interface'
|
||||
|
||||
class ConfluenceServerDCApi implements INodeCredential {
|
||||
label: string
|
||||
name: string
|
||||
version: number
|
||||
description: string
|
||||
inputs: INodeParams[]
|
||||
|
||||
constructor() {
|
||||
this.label = 'Confluence Server/Data Center API'
|
||||
this.name = 'confluenceServerDCApi'
|
||||
this.version = 1.0
|
||||
this.description =
|
||||
'Refer to <a target="_blank" href="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html/">official guide</a> on how to get Personal Access Token</a> on Confluence'
|
||||
this.inputs = [
|
||||
{
|
||||
label: 'Personal Access Token',
|
||||
name: 'personalAccessToken',
|
||||
type: 'password',
|
||||
placeholder: '<CONFLUENCE_PERSONAL_ACCESS_TOKEN>'
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { credClass: ConfluenceServerDCApi }
|
||||
|
|
@ -28,7 +28,7 @@ class Confluence_DocumentLoaders implements INode {
|
|||
label: 'Connect Credential',
|
||||
name: 'credential',
|
||||
type: 'credential',
|
||||
credentialNames: ['confluenceApi']
|
||||
credentialNames: ['confluenceCloudApi', 'confluenceServerDCApi']
|
||||
}
|
||||
this.inputs = [
|
||||
{
|
||||
|
|
@ -77,16 +77,24 @@ class Confluence_DocumentLoaders implements INode {
|
|||
|
||||
const credentialData = await getCredentialData(nodeData.credential ?? '', options)
|
||||
const accessToken = getCredentialParam('accessToken', credentialData, nodeData)
|
||||
const personalAccessToken = getCredentialParam('personalAccessToken', credentialData, nodeData)
|
||||
const username = getCredentialParam('username', credentialData, nodeData)
|
||||
|
||||
const confluenceOptions: ConfluencePagesLoaderParams = {
|
||||
username,
|
||||
accessToken,
|
||||
let confluenceOptions: ConfluencePagesLoaderParams = {
|
||||
baseUrl,
|
||||
spaceKey,
|
||||
limit
|
||||
}
|
||||
|
||||
if (accessToken) {
|
||||
// Confluence Cloud credentials
|
||||
confluenceOptions.username = username
|
||||
confluenceOptions.accessToken = accessToken
|
||||
} else if (personalAccessToken) {
|
||||
// Confluence Server/Data Center credentials
|
||||
confluenceOptions.personalAccessToken = personalAccessToken
|
||||
}
|
||||
|
||||
const loader = new ConfluencePagesLoader(confluenceOptions)
|
||||
|
||||
let docs = []
|
||||
|
|
|
|||
Loading…
Reference in New Issue