UNPKG

n8n-nodes-selfhosthub

Version:

Collection of n8n nodes for self-hosted AI services, including Leonardo.ai integration for AI image and content generation capabilities.

207 lines 6.9 kB
"use strict"; // nodes/CreateJ2vMovie/schema/schema.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.API_RULES = void 0; exports.isMovieElement = isMovieElement; exports.isSceneElement = isSceneElement; exports.isSubtitleElement = isSubtitleElement; exports.isTextElement = isTextElement; exports.isHtmlElement = isHtmlElement; exports.isWebhookDestination = isWebhookDestination; exports.isFtpDestination = isFtpDestination; exports.isEmailDestination = isEmailDestination; exports.hasRequiredFields = hasRequiredFields; exports.hasRequiredExportFields = hasRequiredExportFields; exports.isValidDuration = isValidDuration; exports.isValidPosition = isValidPosition; exports.isValidWait = isValidWait; exports.isValidFtpPort = isValidFtpPort; /** * API rules and validation constants */ exports.API_RULES = { MOVIE_ELEMENT_TYPES: ['text', 'subtitles', 'audio', 'voice'], SCENE_ELEMENT_TYPES: ['video', 'audio', 'image', 'text', 'voice', 'component', 'audiogram', 'html'], REQUIRED_FIELDS: { movie: ['scenes'], scene: [], video: ['type'], audio: [], image: [], text: ['text', 'type'], voice: ['text', 'type'], subtitles: ['type'], component: ['component', 'type'], audiogram: [], html: [] }, EXPORT_RULES: { REQUIRED_FIELDS: { webhook: ['endpoint'], ftp: ['host', 'username', 'password'], email: ['to'] }, VALID_DESTINATION_TYPES: ['webhook', 'ftp', 'email'], SUPPORTS_MULTIPLE_DESTINATIONS: true, SINGLE_EXPORT_CONFIG: true // Currently only supports one item in exports array }, SUBTITLE_RULES: { ONLY_AT_MOVIE_LEVEL: true, NOT_ALLOWED_IN_SCENES: true }, VALIDATION_RANGES: { width: { min: 50, max: 3840 }, height: { min: 50, max: 3840 }, volume: { min: 0, max: 10 }, opacity: { min: 0, max: 1 }, 'z-index': { min: -99, max: 99 }, zoom: { min: -10, max: 10 }, 'pan-distance': { min: 0.01, max: 0.5 }, tolerance: { min: 1, max: 100 }, brightness: { min: -1, max: 1 }, contrast: { min: -1000, max: 1000 }, gamma: { min: 0.1, max: 10 }, saturation: { min: 0, max: 3 }, wait: { min: 0, max: 5 }, ftpPort: { min: 1, max: 65535 }, }, VALID_POSITIONS: [ 'top-left', 'top-center', 'top-right', 'center-left', 'center-center', 'center-right', 'bottom-left', 'bottom-center', 'bottom-right', 'custom' ], VALID_QUALITIES: ['low', 'medium', 'high', 'very_high'], VALID_RESOLUTIONS: [ 'sd', 'hd', 'full-hd', 'squared', 'instagram-story', 'instagram-feed', 'twitter-landscape', 'twitter-portrait', 'custom' ], VALID_RESIZE_MODES: ['cover', 'fill', 'fit', 'contain'], VALID_TEXT_STYLES: ['001', '002', '003', '004', '005', '006', '007', '008', '009', '010'], VALID_AI_MODELS: ['flux-pro', 'flux-schnell', 'freepik-classic'], VALID_ASPECT_RATIOS: ['horizontal', 'vertical', 'squared'], VALID_TTS_MODELS: ['azure', 'elevenlabs', 'elevenlabs-flash-v2-5'], VALID_PAN_DIRECTIONS: [ 'left', 'right', 'top', 'bottom', 'top-left', 'top-right', 'bottom-left', 'bottom-right' ], SPECIAL_DURATION_VALUES: [-1, -2], // -1 = intrinsic, -2 = match container }; /** * Type guard for movie-level elements */ function isMovieElement(element) { return Boolean(element && exports.API_RULES.MOVIE_ELEMENT_TYPES.includes(element.type)); } /** * Type guard for scene-level elements */ function isSceneElement(element) { return Boolean(element && exports.API_RULES.SCENE_ELEMENT_TYPES.includes(element.type)); } /** * Type guard for subtitle elements */ function isSubtitleElement(element) { return Boolean(element && element.type === 'subtitles'); } /** * Type guard for text elements */ function isTextElement(element) { return Boolean(element && element.type === 'text'); } /** * Type guard for HTML elements */ function isHtmlElement(element) { return Boolean(element && element.type === 'html'); } /** * Type guard for export destinations */ function isWebhookDestination(destination) { return Boolean(destination && destination.type === 'webhook'); } function isFtpDestination(destination) { return Boolean(destination && destination.type === 'ftp'); } function isEmailDestination(destination) { return Boolean(destination && destination.type === 'email'); } /** * Check if element has all required fields for its type */ function hasRequiredFields(element) { if (!element || !element.type) return false; const requiredFields = exports.API_RULES.REQUIRED_FIELDS[element.type]; if (!requiredFields) return true; return requiredFields.every(field => { const value = element[field]; if (value === undefined || value === null) return false; if (typeof value === 'string' && value.trim() === '') return false; return true; }); } /** * Check if export destination has all required fields for its type */ function hasRequiredExportFields(destination) { if (!destination || !destination.type) return false; const requiredFields = exports.API_RULES.EXPORT_RULES.REQUIRED_FIELDS[destination.type]; if (!requiredFields) return true; return requiredFields.every(field => { const value = destination[field]; if (value === undefined || value === null) return false; if (typeof value === 'string' && value.trim() === '') return false; return true; }); } /** * Validate duration value according to API rules */ function isValidDuration(duration) { if (duration === undefined || duration === null) return true; if (typeof duration === 'number') { return duration > 0 || exports.API_RULES.SPECIAL_DURATION_VALUES.includes(duration); } return false; } /** * Validate position value according to API rules */ function isValidPosition(position) { return exports.API_RULES.VALID_POSITIONS.includes(position); } /** * Validate wait time for HTML elements */ function isValidWait(wait) { if (wait === undefined || wait === null) return true; if (typeof wait === 'number') { return wait >= exports.API_RULES.VALIDATION_RANGES.wait.min && wait <= exports.API_RULES.VALIDATION_RANGES.wait.max; } return false; } /** * Validate FTP port number */ function isValidFtpPort(port) { if (port === undefined || port === null) return true; if (typeof port === 'number') { return port >= exports.API_RULES.VALIDATION_RANGES.ftpPort.min && port <= exports.API_RULES.VALIDATION_RANGES.ftpPort.max; } return false; } //# sourceMappingURL=schema.js.map