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

152 lines
3.4 KiB
TypeScript

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