mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
feat(Twake Node): Update icon, add cred test and custom operation support (#3431)
* Update icon, add cred injection and test, update url for integration * ⚡ Fix error display for some edge cases Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
|
IAuthenticateBearer,
|
||||||
|
ICredentialTestRequest,
|
||||||
ICredentialType,
|
ICredentialType,
|
||||||
INodeProperties,
|
INodeProperties,
|
||||||
} from 'n8n-workflow';
|
} from 'n8n-workflow';
|
||||||
@@ -15,4 +17,18 @@ export class TwakeCloudApi implements ICredentialType {
|
|||||||
default: '',
|
default: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
authenticate = {
|
||||||
|
type: 'bearer',
|
||||||
|
properties: {
|
||||||
|
tokenPropertyName: 'workspaceKey',
|
||||||
|
},
|
||||||
|
} as IAuthenticateBearer;
|
||||||
|
|
||||||
|
test: ICredentialTestRequest = {
|
||||||
|
request: {
|
||||||
|
baseURL: 'https://plugins.twake.app/plugins/n8n',
|
||||||
|
url: '/channel',
|
||||||
|
method: 'POST',
|
||||||
|
},
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,15 +28,12 @@ export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions |
|
|||||||
method,
|
method,
|
||||||
body,
|
body,
|
||||||
qs: query,
|
qs: query,
|
||||||
uri: uri || `https://connectors.albatros.twakeapp.com/n8n${resource}`,
|
uri: uri || `https://plugins.twake.app/plugins/n8n${resource}`,
|
||||||
json: true,
|
json: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// if (authenticationMethod === 'cloud') {
|
// if (authenticationMethod === 'cloud') {
|
||||||
const credentials = await this.getCredentials('twakeCloudApi');
|
|
||||||
options.headers!.Authorization = `Bearer ${credentials.workspaceKey}`;
|
|
||||||
|
|
||||||
// } else {
|
// } else {
|
||||||
// const credentials = await this.getCredentials('twakeServerApi');
|
// const credentials = await this.getCredentials('twakeServerApi');
|
||||||
// options.auth = { user: credentials!.publicId as string, pass: credentials!.privateApiKey as string };
|
// options.auth = { user: credentials!.publicId as string, pass: credentials!.privateApiKey as string };
|
||||||
@@ -44,9 +41,9 @@ export async function twakeApiRequest(this: IHookFunctions | IExecuteFunctions |
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await this.helpers.request!(options);
|
return await this.helpers.requestWithAuthentication.call(this, 'twakeCloudApi', options);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error.error.code === 'ECONNREFUSED') {
|
if (error.error?.code === 'ECONNREFUSED') {
|
||||||
throw new NodeApiError(this.getNode(), error, { message: 'Twake host is not accessible!' });
|
throw new NodeApiError(this.getNode(), error, { message: 'Twake host is not accessible!' });
|
||||||
}
|
}
|
||||||
throw new NodeApiError(this.getNode(), error);
|
throw new NodeApiError(this.getNode(), error);
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 3.6 KiB |
Reference in New Issue
Block a user