fix: add credentials export and fix logo display

- Add KDriveCredentials to n8n.credentials in package.json to make credentials discoverable
- Update build script to copy kdrive.svg to dist directory for proper logo display
- Update SVG logo with improved design
- Fix TypeScript types and error handling in GenericFunctions and KDrive node
- Add default values to node properties for better UX
This commit is contained in:
2025-12-23 10:13:13 +01:00
parent c609d6c1ee
commit 6dccaba278
12 changed files with 2506 additions and 24 deletions
+6 -6
View File
@@ -6,7 +6,7 @@ import {
INodePropertyOptions,
} from 'n8n-workflow';
import { OptionsWithUri } from 'request';
import * as request from 'request';
/**
* Make an API request to kDrive API
@@ -19,13 +19,13 @@ export async function kdriveApiRequest(
credentials: IDataObject,
returnFullResponse: boolean = false,
): Promise<any> {
const options: OptionsWithUri = {
const options: IHttpRequestOptions = {
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},
method,
uri: `https://api.infomaniak.com${endpoint}`,
method: method as any,
url: `https://api.infomaniak.com${endpoint}`,
body,
json: true,
};
@@ -43,7 +43,7 @@ export async function kdriveApiRequest(
// Handle form data for file uploads
if (endpoint.includes('/upload') && method === 'POST') {
options.formData = body;
(options as any).formData = body;
delete options.headers!['Content-Type'];
options.json = false;
}
@@ -56,7 +56,7 @@ export async function kdriveApiRequest(
}
return response;
} catch (error) {
} catch (error: any) {
handleApiError.call(this, error);
throw error;
}
+14 -6
View File
@@ -16,7 +16,7 @@ export class KDrive implements INodeType {
displayName: 'kDrive',
name: 'kDrive',
icon: 'file:kdrive.svg',
group: ['fileManagement'],
group: ['transform'],
version: 1,
description: 'Interact with Infomaniak kDrive API',
defaults: {
@@ -178,6 +178,7 @@ export class KDrive implements INodeType {
name: 'driveId',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['file', 'directory'],
@@ -191,6 +192,7 @@ export class KDrive implements INodeType {
displayName: 'File ID',
name: 'fileId',
type: 'string',
default: '',
displayOptions: {
show: {
resource: ['file'],
@@ -203,13 +205,13 @@ export class KDrive implements INodeType {
displayName: 'Parent Directory ID',
name: 'parentDirectoryId',
type: 'string',
default: 'root',
displayOptions: {
show: {
resource: ['file'],
operation: ['listFiles'],
},
},
default: 'root',
description: 'The ID of the parent directory (use "root" for root directory)',
},
// Directory ID for directory operations
@@ -217,13 +219,13 @@ export class KDrive implements INodeType {
displayName: 'Parent Directory ID',
name: 'parentDirectoryId',
type: 'string',
default: 'root',
displayOptions: {
show: {
resource: ['directory'],
operation: ['createDirectory', 'createFile'],
},
},
default: 'root',
description: 'The ID of the parent directory (use "root" for root directory)',
},
// Directory name for create directory
@@ -232,6 +234,7 @@ export class KDrive implements INodeType {
name: 'directoryName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['directory'],
@@ -246,6 +249,7 @@ export class KDrive implements INodeType {
name: 'fileName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['directory'],
@@ -262,6 +266,7 @@ export class KDrive implements INodeType {
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
displayOptions: {
show: {
resource: ['directory'],
@@ -278,6 +283,7 @@ export class KDrive implements INodeType {
typeOptions: {
alwaysOpenEditWindow: true,
},
default: '',
displayOptions: {
show: {
resource: ['file'],
@@ -291,6 +297,7 @@ export class KDrive implements INodeType {
name: 'uploadFileName',
type: 'string',
required: true,
default: '',
displayOptions: {
show: {
resource: ['file'],
@@ -303,13 +310,13 @@ export class KDrive implements INodeType {
displayName: 'Parent Directory ID',
name: 'uploadParentDirectoryId',
type: 'string',
default: 'root',
displayOptions: {
show: {
resource: ['file'],
operation: ['uploadFile'],
},
},
default: 'root',
description: 'The ID of the parent directory for upload (use "root" for root directory)',
},
// Search parameters
@@ -317,6 +324,7 @@ export class KDrive implements INodeType {
displayName: 'Search Query',
name: 'searchQuery',
type: 'string',
default: '',
displayOptions: {
show: {
resource: ['file'],
@@ -391,7 +399,7 @@ export class KDrive implements INodeType {
} else if (operation === 'downloadFile') {
const fileId = this.getNodeParameter('fileId', i) as string;
const response = await kdriveApiRequest.call(this, 'GET', `/2/drive/${driveId}/files/${fileId}/download`, {}, credentials, true);
returnData.push({ binary: response });
returnData.push({ json: {}, binary: { data: { mimeType: 'application/octet-stream', data: response } } });
} else if (operation === 'deleteFile') {
const fileId = this.getNodeParameter('fileId', i) as string;
const response = await kdriveApiRequest.call(this, 'DELETE', `/2/drive/${driveId}/files/${fileId}`, {}, credentials);
@@ -441,7 +449,7 @@ export class KDrive implements INodeType {
returnData.push({ json: response });
}
}
} catch (error) {
} catch (error: any) {
if (this.continueOnFail()) {
returnData.push({ json: { error: error.message } });
} else {
+6 -8
View File
@@ -1,8 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="24" height="24" rx="4" fill="#007BFF"/>
<path d="M17 10H7L12 5L17 10Z" fill="white"/>
<path d="M7 14H17L12 19L7 14Z" fill="white"/>
<path d="M12 12H7" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
<path d="M17 12H12" stroke="white" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.504232" fill-rule="evenodd" clip-rule="evenodd" d="M15.4092 4.08592C15.4092 2.88331 16.6052 2.06824 17.6893 2.53209L20.5262 3.74593C20.9604 3.93171 21.2961 4.29888 21.4484 4.75462L22.5763 8.12913C22.7579 8.67238 23.1974 9.08351 23.7423 9.21991L35.5456 12.1746C36.2821 12.359 36.8001 13.0345 36.8001 13.8105V27.9066C36.8001 29.0397 35.7289 29.8495 34.6708 29.5163L16.5707 23.8161C15.8803 23.5987 15.4092 22.9458 15.4092 22.2064V4.08592Z" fill="#A2BFFF"/>
<path opacity="0.8" fill-rule="evenodd" clip-rule="evenodd" d="M11.2954 7.45421C11.2954 6.25159 12.4914 5.43653 13.5755 5.90038L16.4124 7.11422C16.8466 7.3 17.1823 7.66717 17.3346 8.1229L18.4626 11.4974C18.6442 12.0407 19.0836 12.4518 19.6285 12.5882L31.4318 15.5429C32.1683 15.7273 32.6864 16.4028 32.6864 17.1788V31.2749C32.6864 32.408 31.6151 33.2178 30.557 32.8846L12.457 27.1844C11.7665 26.967 11.2954 26.3141 11.2954 25.5747V7.45421Z" fill="#A0BDFF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M7.18213 10.3172C7.18213 9.11463 8.37816 8.29957 9.46224 8.76342L12.2991 9.97725C12.7333 10.163 13.069 10.5302 13.2214 10.9859L14.3493 14.3605C14.5309 14.9037 14.9703 15.3148 15.5152 15.4512L27.3186 18.4059C28.055 18.5903 28.5731 19.2659 28.5731 20.0419V34.1379C28.5731 35.271 27.5018 36.0808 26.4437 35.7476L8.34368 30.0474C7.65326 29.83 7.18213 29.1771 7.18213 28.4378V10.3172Z" fill="#1A47FF"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.29676 18.4149C2.85383 17.1304 4.00652 15.8671 5.28881 16.2317L23.5708 21.4294C24.1227 21.5863 24.5552 22.0257 24.7126 22.5894L28.1562 34.9255C28.3356 35.568 27.7472 36.1582 27.1232 35.9616L7.9739 29.931C7.47572 29.7742 7.07963 29.385 6.90616 28.8819L3.29676 18.4149Z" fill="#5287FF"/>
</svg>

Before

Width:  |  Height:  |  Size: 497 B

After

Width:  |  Height:  |  Size: 1.8 KiB