UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.

189 lines 7.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImageToVideo35 = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class ImageToVideo35 { constructor() { this.description = { displayName: 'Wiro - Image To Video V3 5', name: 'imageToVideo35', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'PixVerse image-to-video model v3.5', defaults: { name: 'Wiro - Image To Video V3 5', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Image URL', name: 'inputImageUrl', type: 'string', default: '', description: 'First frame of the video', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', required: true, description: 'The prompt to generate the video', }, { displayName: 'Negative Prompt', name: 'negativePrompt', type: 'string', default: '', description: 'Specify what to exclude from the output', }, { displayName: 'Duration', name: 'duration', type: 'options', default: '5', required: true, description: 'Duration of the video', options: [ { name: '5', value: '5' }, { name: '8', value: '8' }, ], }, { displayName: 'Quality', name: 'quality', type: 'options', default: '1080p', required: true, description: 'Quality of the video', options: [ { name: '1080p', value: '1080p' }, { name: '360p(Turbo)', value: '360p' }, { name: '540p', value: '540p' }, { name: '720p', value: '720p' }, ], }, { displayName: 'Motion Mode', name: 'motionMode', type: 'options', default: 'fast', description: 'Fast only available when duration is 5. 1080p does not support fast.', options: [ { name: 'Fast', value: 'fast' }, { name: 'Normal', value: 'normal' }, ], }, { displayName: 'Style', name: 'style', type: 'options', default: '3d_animation', description: 'You can leave style empty', options: [ { name: '3d Animation', value: '3d_animation' }, { name: 'Anime', value: 'anime' }, { name: 'Clay', value: 'clay' }, { name: 'Comic', value: 'comic' }, { name: 'Cyberpunk', value: 'cyberpunk' }, ], }, { displayName: 'Seed', name: 'seed', type: 'number', default: 0, description: 'Leave null to randomize', }, { displayName: 'Watermark', name: 'Watermark', type: 'options', default: 'false', description: 'Select option for watermark', options: [ { name: 'False', value: 'false' }, { name: 'True', value: 'true' }, ], }, ], }; } async execute() { const returnData = []; const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, ''); const prompt = this.getNodeParameter('prompt', 0); const negativePrompt = this.getNodeParameter('negativePrompt', 0, ''); const duration = this.getNodeParameter('duration', 0); const quality = this.getNodeParameter('quality', 0); const motionMode = this.getNodeParameter('motionMode', 0, ''); const style = this.getNodeParameter('style', 0, ''); const seed = this.getNodeParameter('seed', 0, 0); const Watermark = this.getNodeParameter('Watermark', 0, ''); const credentials = await this.getCredentials('wiroApi'); const apiKey = credentials.apiKey; const apiSecret = credentials.apiSecret; const headers = (0, auth_1.generateWiroAuthHeaders)(apiKey, apiSecret); const response = await this.helpers.httpRequest({ method: 'POST', url: 'https://api.wiro.ai/v1/Run/PixVerse/image-to-video-v3.5', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageUrl, prompt, negativePrompt, duration, quality, motionMode, style, seed, Watermark, }, }); if (!(response === null || response === void 0 ? void 0 : response.taskid) || !(response === null || response === void 0 ? void 0 : response.socketaccesstoken)) { throw new n8n_workflow_1.NodeApiError(this.getNode(), { message: 'Wiro API did not return a valid task ID or socket access token ' + JSON.stringify(response), }); } const taskid = response.taskid; const socketaccesstoken = response.socketaccesstoken; const result = await polling_1.pollTaskUntilComplete.call(this, socketaccesstoken, headers); const responseJSON = { taskid: taskid, url: '', status: '', }; switch (result) { case '-1': case '-2': case '-3': case '-4': responseJSON.status = 'failed'; break; default: responseJSON.status = 'completed'; responseJSON.url = result !== null && result !== void 0 ? result : ''; } returnData.push({ json: responseJSON, }); return [returnData]; } } exports.ImageToVideo35 = ImageToVideo35; //# sourceMappingURL=ImageToVideo35.node.js.map