From 9f6db09edf80664e3271c9d22f472ee02b2a7bfa Mon Sep 17 00:00:00 2001 From: "atharva.dev" Date: Wed, 22 Oct 2025 10:14:14 +0000 Subject: [PATCH] npm build successful --- .gitignore | 2 + nodes/SecloreProtect/SecloreProtect.node.ts | 414 ++++++++++---------- package.json | 7 +- tsconfig.json | 3 +- 4 files changed, 214 insertions(+), 212 deletions(-) diff --git a/.gitignore b/.gitignore index de4d1f0..2a61503 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ dist node_modules +package-lock.json +.n8n/.env \ No newline at end of file diff --git a/nodes/SecloreProtect/SecloreProtect.node.ts b/nodes/SecloreProtect/SecloreProtect.node.ts index accc028..5ea9301 100644 --- a/nodes/SecloreProtect/SecloreProtect.node.ts +++ b/nodes/SecloreProtect/SecloreProtect.node.ts @@ -1,229 +1,227 @@ import { - IExecuteFunctions, - INodeExecutionData, - INodeType, - INodeTypeDescription, - NodeOperationError, + IExecuteFunctions, + INodeExecutionData, + INodeType, + INodeTypeDescription, + NodeOperationError, } from 'n8n-workflow'; import { SecloreDRMFileService } from './Services/SecloreDRMFileService'; export class SecloreProtect implements INodeType { - description: INodeTypeDescription = { - displayName: 'Seclore Protect', - name: 'secloreProtect', - icon: 'file:SecloreProtect.svg', - group: ['transform'], - version: 1, - subtitle: '={{$parameter["operation"]}}', - description: 'Protect files using Seclore DRM with HotFolder configuration', - defaults: { - name: 'Seclore Protect', - }, - inputs: ['main'], - outputs: ['main'], - credentials: [ - { - name: 'secloreProtectApi', - required: true, - }, - ], - properties: [ - { - displayName: 'Operation', - name: 'operation', - type: 'options', - noDataExpression: true, - options: [ - { - name: 'Protect File with HotFolder', - value: 'protectWithHotFolder', - description: 'Protect a file using HotFolder ID configuration', - action: 'Protect file with HotFolder', - }, - ], - default: 'protectWithHotFolder', - }, - { - displayName: 'HotFolder ID', - name: 'hotfolderId', - type: 'string', - required: true, - default: '', - placeholder: 'e.g., hf-12345', - description: 'The ID of the HotFolder configuration to use for protection', - displayOptions: { - show: { - operation: ['protectWithHotFolder'], - }, - }, - }, - { - displayName: 'Input Binary Property', - name: 'binaryPropertyName', - type: 'string', - default: 'data', - required: true, - description: 'Name of the binary property that contains the file to protect', - displayOptions: { - show: { - operation: ['protectWithHotFolder'], - }, - }, - }, - { - displayName: 'Output Binary Property', - name: 'outputBinaryPropertyName', - type: 'string', - default: 'data', - required: true, - description: 'Name of the binary property where the protected file will be stored', - displayOptions: { - show: { - operation: ['protectWithHotFolder'], - }, - }, - }, - { - displayName: 'Correlation ID', - name: 'correlationId', - type: 'string', - default: '', - placeholder: 'e.g., req-12345', - description: 'Optional correlation ID for request tracking and logging', - displayOptions: { - show: { - operation: ['protectWithHotFolder'], - }, - }, - }, - { - displayName: 'Retry Count', - name: 'retryCount', - type: 'number', - default: 3, - description: 'Number of retry attempts for failed requests', - displayOptions: { - show: { - operation: ['protectWithHotFolder'], - }, - }, - }, - ], - }; + description: INodeTypeDescription = { + displayName: 'Seclore Protect', + name: 'secloreProtect', + icon: 'file:SecloreProtect.svg', + group: ['transform'], + version: 1, + subtitle: '={{$parameter["operation"]}}', + description: 'Protect files using Seclore DRM with HotFolder configuration', + defaults: { + name: 'Seclore Protect', + }, + inputs: ['main'], + outputs: ['main'], + credentials: [ + { + name: 'secloreProtectApi', + required: true, + }, + ], + properties: [ + { + displayName: 'Operation', + name: 'operation', + type: 'options', + noDataExpression: true, + options: [ + { + name: 'Protect File with HotFolder', + value: 'protectWithHotFolder', + description: 'Protect a file using HotFolder ID configuration', + action: 'Protect file with HotFolder', + }, + ], + default: 'protectWithHotFolder', + }, + { + displayName: 'HotFolder ID', + name: 'hotfolderId', + type: 'string', + required: true, + default: '', + placeholder: 'e.g., hf-12345', + description: 'The ID of the HotFolder configuration to use for protection', + displayOptions: { + show: { + operation: ['protectWithHotFolder'], + }, + }, + }, + { + displayName: 'Input Binary Property', + name: 'binaryPropertyName', + type: 'string', + default: 'data', + required: true, + description: 'Name of the binary property that contains the file to protect', + displayOptions: { + show: { + operation: ['protectWithHotFolder'], + }, + }, + }, + { + displayName: 'Output Binary Property', + name: 'outputBinaryPropertyName', + type: 'string', + default: 'data', + required: true, + description: 'Name of the binary property where the protected file will be stored', + displayOptions: { + show: { + operation: ['protectWithHotFolder'], + }, + }, + }, + { + displayName: 'Correlation ID', + name: 'correlationId', + type: 'string', + default: '', + placeholder: 'e.g., req-12345', + description: 'Optional correlation ID for request tracking and logging', + displayOptions: { + show: { + operation: ['protectWithHotFolder'], + }, + }, + }, + { + displayName: 'Retry Count', + name: 'retryCount', + type: 'number', + default: 3, + description: 'Number of retry attempts for failed requests', + displayOptions: { + show: { + operation: ['protectWithHotFolder'], + }, + }, + }, + ], + }; - async execute(this: IExecuteFunctions): Promise { - const items = this.getInputData(); - const returnData: INodeExecutionData[] = []; + async execute(this: IExecuteFunctions): Promise { + const items = this.getInputData(); + const returnData: INodeExecutionData[] = []; - // Get credentials - const credentials = await this.getCredentials('secloreProtectApi'); - const baseUrl = credentials.baseUrl as string; - const tenantId = credentials.tenantId as string; - const tenantSecret = credentials.tenantSecret as string; + // Get credentials + const credentials = await this.getCredentials('secloreProtectApi'); + const baseUrl = credentials.baseUrl as string; + const tenantId = credentials.tenantId as string; + const tenantSecret = credentials.tenantSecret as string; - // Initialize the file service - const fileService = new SecloreDRMFileService( - this, - baseUrl, - tenantId, - tenantSecret - ); + // Initialize the file service + const fileService = new SecloreDRMFileService(this, baseUrl, tenantId, tenantSecret); - // Get node parameters - const operation = this.getNodeParameter('operation', 0) as string; + // Get node parameters + const operation = this.getNodeParameter('operation', 0) as string; - for (let i = 0; i < items.length; i++) { - try { - if (operation === 'protectWithHotFolder') { - // Get parameters for this item - const hotfolderId = this.getNodeParameter('hotfolderId', i) as string; - const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; - const outputBinaryPropertyName = this.getNodeParameter('outputBinaryPropertyName', i) as string; - const correlationId = this.getNodeParameter('correlationId', i) as string; - const retryCount = this.getNodeParameter('retryCount', i) as number; + for (let i = 0; i < items.length; i++) { + try { + if (operation === 'protectWithHotFolder') { + // Get parameters for this item + const hotfolderId = this.getNodeParameter('hotfolderId', i) as string; + const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i) as string; + const outputBinaryPropertyName = this.getNodeParameter( + 'outputBinaryPropertyName', + i, + ) as string; + const correlationId = this.getNodeParameter('correlationId', i) as string; + const retryCount = this.getNodeParameter('retryCount', i) as number; - // Validate required parameters - if (!hotfolderId) { - throw new NodeOperationError(this.getNode(), 'HotFolder ID is required', { - itemIndex: i, - }); - } + // Validate required parameters + if (!hotfolderId) { + throw new NodeOperationError(this.getNode(), 'HotFolder ID is required', { + itemIndex: i, + }); + } - // Get input binary data - const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName); - const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); + // Get input binary data + const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName); + const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName); - // Upload the file first - const uploadResult = await fileService.uploadFile( - new Uint8Array(fileBuffer), - binaryData.fileName || 'file', - correlationId || undefined, - retryCount - ); + // Upload the file first + const uploadResult = await fileService.uploadFile( + new Uint8Array(fileBuffer), + binaryData.fileName || 'file', + correlationId || undefined, + retryCount, + ); - // Protect the uploaded file with HotFolder - const protectResult = await fileService.protectWithHotFolder( - { - hotfolderId, - fileStorageId: uploadResult.fileStorageId, - }, - correlationId || undefined, - retryCount - ); + // Protect the uploaded file with HotFolder + const protectResult = await fileService.protectWithHotFolder( + { + hotfolderId, + fileStorageId: uploadResult.fileStorageId, + }, + correlationId || undefined, + retryCount, + ); - // Download the protected file - const protectedFileData = await fileService.downloadFile( - protectResult.fileStorageId, - correlationId || undefined, - retryCount - ); + // Download the protected file + const protectedFileData = await fileService.downloadFile( + protectResult.fileStorageId, + correlationId || undefined, + retryCount, + ); - // Create output binary data - const outputBinaryData = await this.helpers.prepareBinaryData( - protectedFileData.buffer, - binaryData.fileName || 'protected_file', - binaryData.mimeType - ); + // Create output binary data + const outputBinaryData = await this.helpers.prepareBinaryData( + Buffer.from(protectedFileData), + binaryData.fileName || 'protected_file', + binaryData.mimeType, + ); - // Create return item with binary data and metadata - const returnItem: INodeExecutionData = { - json: { - success: true, - originalFileStorageId: uploadResult.fileStorageId, - protectedFileStorageId: protectResult.fileStorageId, - secloreFileId: protectResult.secloreFileId, - hotfolderId, - fileName: binaryData.fileName, - fileSize: protectedFileData.length, - correlationId: correlationId || null, - }, - binary: { - [outputBinaryPropertyName]: outputBinaryData, - }, - }; + // Create return item with binary data and metadata + const returnItem: INodeExecutionData = { + json: { + success: true, + originalFileStorageId: uploadResult.fileStorageId, + protectedFileStorageId: protectResult.fileStorageId, + secloreFileId: protectResult.secloreFileId, + hotfolderId, + fileName: binaryData.fileName, + fileSize: protectedFileData.length, + correlationId: correlationId || null, + }, + binary: { + [outputBinaryPropertyName]: outputBinaryData, + }, + }; - returnData.push(returnItem); - } - } catch (error) { - // Handle errors gracefully - if (this.continueOnFail()) { - const returnItem: INodeExecutionData = { - json: { - success: false, - error: error.message, - itemIndex: i, - }, - }; - returnData.push(returnItem); - } else { - throw new NodeOperationError(this.getNode(), error.message, { - itemIndex: i, - }); - } - } - } + returnData.push(returnItem); + } + } catch (error) { + // Handle errors gracefully + if (this.continueOnFail()) { + const returnItem: INodeExecutionData = { + json: { + success: false, + error: error.message, + itemIndex: i, + }, + }; + returnData.push(returnItem); + } else { + throw new NodeOperationError(this.getNode(), error.message, { + itemIndex: i, + }); + } + } + } - return [returnData]; - } + return [returnData]; + } } diff --git a/package.json b/package.json index 395533e..7f5d8eb 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { "name": "n8n-nodes-secloreprotect", "version": "0.1.0", - "description": "", + "description": "n8n community node for Seclore Protect - secure file protection using DRM technology", "license": "MIT", "homepage": "", "keywords": [ "n8n-community-node-package" ], "author": { - "name": "", - "email": "" + "name": "Seclore Technology", + "email": "support@seclore.com" }, "repository": { "type": "git", @@ -39,6 +39,7 @@ }, "devDependencies": { "@n8n/node-cli": "*", + "@types/node": "^24.9.1", "eslint": "9.32.0", "prettier": "3.6.2", "release-it": "^19.0.4", diff --git a/tsconfig.json b/tsconfig.json index b73660f..e084103 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,7 +19,8 @@ "declaration": true, "sourceMap": true, "skipLibCheck": true, - "outDir": "./dist/" + "outDir": "./dist/", + "types": ["node"] }, "include": ["credentials/**/*", "nodes/**/*", "nodes/**/*.json", "package.json"] }