n8n-nodes-seclore/nodes/SecloreProtect/SecloreProtect.node.ts

180 lines
4.1 KiB
TypeScript
Raw Normal View History

2025-10-22 09:19:18 +00:00
import {
2025-10-22 10:14:14 +00:00
INodeType,
INodeTypeDescription,
2025-10-22 09:19:18 +00:00
} from 'n8n-workflow';
2025-10-27 12:17:21 +00:00
import { protectWithHotFolder } from './operations/protectWithHotFolder';
import { unprotect } from './operations/unprotect';
2025-10-22 09:19:18 +00:00
export class SecloreProtect implements INodeType {
2025-10-22 10:14:14 +00:00
description: INodeTypeDescription = {
displayName: 'Seclore Protect',
name: 'secloreProtect',
2025-10-27 12:17:21 +00:00
icon: 'file:../../icons/seclore.svg',
2025-10-24 06:10:55 +00:00
usableAsTool: true, // TODO: make it false/ don't allow it to be used as a tool
2025-10-22 10:14:14 +00:00
group: ['transform'],
version: 1,
2025-10-27 12:06:40 +00:00
subtitle: '={{$parameter["resource"] + ": " + $parameter["operation"]}}',
description: 'Protect files using Seclore DRM',
2025-10-22 10:14:14 +00:00
defaults: {
name: 'Seclore Protect',
},
inputs: ['main'],
outputs: ['main'],
credentials: [
{
name: 'secloreProtectApi',
required: true,
},
],
properties: [
2025-10-27 12:06:40 +00:00
{
displayName: 'Resource',
name: 'resource',
type: 'options',
noDataExpression: true,
options: [
{
name: 'Protection',
value: 'protection',
description: 'File protection operations',
},
],
default: 'protection',
},
2025-10-22 10:14:14 +00:00
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
2025-10-27 12:06:40 +00:00
displayOptions: {
show: {
resource: ['protection'],
},
},
2025-10-22 10:14:14 +00:00
options: [
{
2025-10-27 12:06:40 +00:00
name: 'Protect with Hot Folder',
2025-10-22 10:14:14 +00:00
value: 'protectWithHotFolder',
description: 'Protect a file using HotFolder ID configuration',
2025-10-24 06:10:55 +00:00
action: 'Protect file with hotfolder',
2025-10-22 10:14:14 +00:00
},
2025-10-27 12:06:40 +00:00
{
name: 'Unprotect',
value: 'unprotect',
description: 'Unprotect a file using file ID',
action: 'Unprotect file',
},
2025-10-22 10:14:14 +00:00
],
default: 'protectWithHotFolder',
},
{
displayName: 'HotFolder ID',
name: 'hotfolderId',
type: 'string',
required: true,
2025-10-27 12:06:40 +00:00
default: '1000201',
placeholder: '1000201',
2025-10-22 10:14:14 +00:00
description: 'The ID of the HotFolder configuration to use for protection',
displayOptions: {
show: {
2025-10-27 12:06:40 +00:00
resource: ['protection'],
2025-10-22 10:14:14 +00:00
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: {
2025-10-27 12:06:40 +00:00
resource: ['protection'],
2025-10-22 10:14:14 +00:00
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: {
2025-10-27 12:06:40 +00:00
resource: ['protection'],
2025-10-22 10:14:14 +00:00
operation: ['protectWithHotFolder'],
},
},
},
{
displayName: 'Retry Count',
name: 'retryCount',
type: 'number',
default: 3,
description: 'Number of retry attempts for failed requests',
displayOptions: {
show: {
2025-10-27 12:06:40 +00:00
resource: ['protection'],
2025-10-22 10:14:14 +00:00
operation: ['protectWithHotFolder'],
},
},
},
2025-10-27 12:06:40 +00:00
// Unprotect operation parameters
{
2025-10-27 12:17:21 +00:00
displayName: 'Input Binary Property',
name: 'binaryPropertyName',
2025-10-27 12:06:40 +00:00
type: 'string',
default: 'data',
required: true,
2025-10-27 12:17:21 +00:00
description: 'Name of the binary property that contains the protected file to unprotect',
2025-10-27 12:06:40 +00:00
displayOptions: {
show: {
resource: ['protection'],
operation: ['unprotect'],
},
},
},
{
displayName: 'Correlation ID',
name: 'correlationId',
type: 'string',
default: '',
placeholder: 'e.g., req-12345',
description: 'Optional correlation ID for request tracking and logging',
displayOptions: {
show: {
resource: ['protection'],
operation: ['unprotect'],
},
},
},
{
displayName: 'Retry Count',
name: 'retryCount',
type: 'number',
default: 3,
description: 'Number of retry attempts for failed requests',
displayOptions: {
show: {
resource: ['protection'],
operation: ['unprotect'],
},
},
},
2025-10-22 10:14:14 +00:00
],
};
2025-10-27 12:06:40 +00:00
customOperations = {
protection: {
2025-10-27 12:17:21 +00:00
protectWithHotFolder,
unprotect,
2025-10-27 12:06:40 +00:00
},
};
2025-10-22 09:19:18 +00:00
}