@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
129 lines • 5.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextToVideoHailuo02 = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class TextToVideoHailuo02 {
constructor() {
this.description = {
displayName: 'Wiro - Text To Video Hailuo 02',
name: 'textToVideoHailuo02',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'MiniMax',
defaults: {
name: 'Wiro - Text To Video Hailuo 02',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
description: 'The prompt to generate the video',
},
{
displayName: 'Prompt Optimizer',
name: 'promptOptimizer',
type: 'options',
default: 'false',
description: 'The model will automatically optimize the incoming prompt to improve the generation quality If necessary. For more precise control, this parameter can be set to False, and the model will follow the instructions more strictly. At this time It is recommended to provide finer prompts for best results',
options: [
{ name: 'False', value: 'false' },
{ name: 'True', value: 'true' },
],
},
{
displayName: 'Resolution',
name: 'resolution',
type: 'options',
default: '1080P',
description: '1080P resolution can only produce 6s videos',
options: [
{ name: '1080P', value: '1080P' },
{ name: '768P', value: '768P' },
],
},
{
displayName: 'Duration',
name: 'duration',
type: 'options',
default: '10',
required: true,
description: 'If resolution set to 1080p duration is 6 seconds by default. 10 seconds videos only available for 768P.',
options: [
{ name: '10', value: '10' },
{ name: '6', value: '6' },
],
},
],
};
}
async execute() {
const returnData = [];
const prompt = this.getNodeParameter('prompt', 0, '');
const promptOptimizer = this.getNodeParameter('promptOptimizer', 0, '');
const resolution = this.getNodeParameter('resolution', 0, '');
const duration = this.getNodeParameter('duration', 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/text-to-video-hailuo-02',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
prompt,
promptOptimizer,
resolution,
duration,
},
});
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.TextToVideoHailuo02 = TextToVideoHailuo02;
//# sourceMappingURL=TextToVideoHailuo02.node.js.map