UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

99 lines 3.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImageToVideoHailuo01Subject = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class ImageToVideoHailuo01Subject { constructor() { this.description = { displayName: 'Wiro - Image To Video Hailuo 01 Subject', name: 'imageToVideoHailuo01Subject', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Generate 6s videos with an image. (Also known as Hailuo) MiniMax/image-to-video-01-subject is', defaults: { name: 'Wiro - Image To Video Hailuo 01 Subject', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Subject Reference Image URL', name: 'inputImageUrl', type: 'string', default: '', required: true, description: 'The model will generate a video based on the subject uploaded through this parameter. Currently, only a human face accepted.', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', description: 'The prompt to generate the video', }, ], }; } async execute() { const returnData = []; const inputImageUrl = this.getNodeParameter('inputImageUrl', 0); const prompt = this.getNodeParameter('prompt', 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/MiniMax/image-to-video-hailuo-01-subject', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageUrl, prompt, }, }); 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.ImageToVideoHailuo01Subject = ImageToVideoHailuo01Subject; //# sourceMappingURL=ImageToVideoHailuo01Subject.node.js.map