UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

151 lines 6.64 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Kling3MotionControl = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class Kling3MotionControl { constructor() { this.description = { displayName: 'Wiro - Kling V3 Motion Control', name: 'kling3MotionControl', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Generate high-quality image-to-video content with Kling V3 Motion Control. Customize video mode', defaults: { name: 'Wiro - Kling V3 Motion Control', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Mode', name: 'mode', type: 'options', default: 'pro', required: true, description: 'Video generation mode. \'std\': Standard mode (cost-effective). \'pro\': Professional mode (higher quality)', options: [ { name: 'Pro', value: 'pro' }, { name: 'Std', value: 'std' }, ], }, { displayName: 'Input Image URL', name: 'inputImageUrl', type: 'string', default: '', required: true, description: 'Reference image. The characters, backgrounds, and other elements in the generated video are based on the reference image. Supports .jpg/.jpeg/.png, max 10MB, dimensions 340px-3850px, aspect ratio 1:2.5 to 2.5:1', }, { displayName: 'Video URL', name: 'inputVideoUrl', type: 'string', default: '', required: true, description: 'Reference video. The character actions in the generated video are consistent with the reference video. Supports .mp4/.mov, max 100MB, 3-30 seconds duration depending on character_orientation', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', description: 'Text prompt for video generation. You can add elements to the screen and achieve motion effects through prompt words.', }, { displayName: 'Keep Original Sound', name: 'originalSound', type: 'options', default: 'no', required: true, description: 'Whether to keep the original sound of the video', options: [ { name: 'No', value: 'no' }, { name: 'Yes', value: 'yes' }, ], }, { displayName: 'Character Orientation', name: 'characterOrientation', type: 'options', default: 'image', required: true, description: 'Generate the orientation of the characters in the video. \'image\': same orientation as the person in the picture (max 10s video). \'video\': consistent with the orientation of the characters in the video (max 30s video)', options: [ { name: 'Image', value: 'image' }, { name: 'Video', value: 'video' }, ], }, ], }; } async execute() { const returnData = []; const mode = this.getNodeParameter('mode', 0); const inputImageUrl = this.getNodeParameter('inputImageUrl', 0); const inputVideoUrl = this.getNodeParameter('inputVideoUrl', 0); const prompt = this.getNodeParameter('prompt', 0, ''); const originalSound = this.getNodeParameter('originalSound', 0); const characterOrientation = this.getNodeParameter('characterOrientation', 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/klingai/kling-v3-motion-control', headers: { ...headers, 'Content-Type': 'application/json', }, body: { mode, inputImageUrl, inputVideoUrl, prompt, originalSound, characterOrientation, }, }); 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.Kling3MotionControl = Kling3MotionControl; //# sourceMappingURL=Kling3MotionControl.node.js.map