@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
199 lines • 8.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Veo3 = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class Veo3 {
constructor() {
this.description = {
displayName: 'Wiro - Veo3',
name: 'veo3',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'Google\'s veo3 model',
defaults: {
name: 'Wiro - Veo3',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Input Image URL',
name: 'inputImageUrl',
type: 'string',
default: '',
description: 'Optional. Input image for the first frame of the video.',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
required: true,
description: 'The prompt to generate the video',
},
{
displayName: 'Generate Audio',
name: 'generateAudio',
type: 'options',
default: 'false',
required: true,
description: 'Generate audio for the video',
options: [
{ name: 'False', value: 'false' },
{ name: 'True', value: 'true' },
],
},
{
displayName: 'Aspect Ratio',
name: 'aspectRatio',
type: 'options',
default: '16:9',
description: 'Aspect ratio of the generated video',
options: [
{ name: '16:9', value: '16:9' },
{ name: '9:16', value: '9:16' },
{ name: 'Match Input Image', value: 'match_input_image' },
],
},
{
displayName: 'Resolution',
name: 'resolution',
type: 'options',
default: '1080p',
description: 'Resolution of the generated video',
options: [
{ name: '1080p', value: '1080p' },
{ name: '720p', value: '720p' },
],
},
{
displayName: 'Negative Prompt',
name: 'negativePrompt',
type: 'string',
default: '',
description: 'A text string that describes anything you want to discourage the model from generating',
},
{
displayName: 'Enhance Prompt',
name: 'enhancePrompt',
type: 'options',
default: 'false',
description: 'Use Gemini to enhance your prompts for better quality videos',
options: [
{ name: 'False', value: 'false' },
{ name: 'True', value: 'true' },
],
},
{
displayName: 'Person Generation',
name: 'personGeneration',
type: 'options',
default: 'allow_adult',
description: 'The safety setting that controls whether people or face generation is allowed. allow_adult: Allow generation of adults only. dont_allow: Disallow the inclusion of people or faces in videos',
options: [
{ name: 'Allow Adults', value: 'allow_adult' },
{ name: 'Don\'t Allow', value: 'dont_allow' },
],
},
{
displayName: 'Seed',
name: 'seed',
type: 'number',
default: 0,
description: 'A number to make generated videos deterministic. For random result do not send.',
},
{
displayName: 'Duration Seconds',
name: 'durationSeconds',
type: 'options',
default: '4',
required: true,
description: 'Duration of the generated video in seconds. When using reference images duration is set to 8 by default.',
options: [
{ name: '4', value: '4' },
{ name: '6', value: '6' },
{ name: '8', value: '8' },
],
},
],
};
}
async execute() {
const returnData = [];
const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, '');
const prompt = this.getNodeParameter('prompt', 0);
const generateAudio = this.getNodeParameter('generateAudio', 0);
const aspectRatio = this.getNodeParameter('aspectRatio', 0, '');
const resolution = this.getNodeParameter('resolution', 0, '');
const negativePrompt = this.getNodeParameter('negativePrompt', 0, '');
const enhancePrompt = this.getNodeParameter('enhancePrompt', 0, '');
const personGeneration = this.getNodeParameter('personGeneration', 0, '');
const seed = this.getNodeParameter('seed', 0, 0);
const durationSeconds = this.getNodeParameter('durationSeconds', 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/google/veo3',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputImageUrl,
prompt,
generateAudio,
aspectRatio,
resolution,
negativePrompt,
enhancePrompt,
personGeneration,
seed,
durationSeconds,
},
});
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.Veo3 = Veo3;
//# sourceMappingURL=Veo3.node.js.map