@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
121 lines • 4.6 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DanceFlow = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class DanceFlow {
constructor() {
this.description = {
displayName: 'Wiro - Dance Flow',
name: 'danceFlow',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'Make anyone dance - turn photos into lively, rhythm-synced dance videos in one seamless flow',
defaults: {
name: 'Wiro - Dance Flow',
},
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: 'URL of the file for input image URL',
},
{
displayName: 'Effect Type',
name: 'effectType',
type: 'string',
default: '',
description: 'Value for effect type',
},
{
displayName: 'Output Type',
name: 'outputType',
type: 'options',
default: 'image',
description: 'Select option for output type',
options: [
{ name: 'Only Image', value: 'image' },
{ name: 'Only Video', value: 'video' },
{ name: 'Video & Image', value: 'both' },
],
},
{
displayName: 'Seed',
name: 'seed',
type: 'string',
default: '',
description: 'Seed-help',
},
],
};
}
async execute() {
const returnData = [];
const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, '');
const effectType = this.getNodeParameter('effectType', 0, '');
const outputType = this.getNodeParameter('outputType', 0, '');
const seed = this.getNodeParameter('seed', 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/wiro/Dance Flow',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputImageUrl,
effectType,
outputType,
seed,
},
});
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.DanceFlow = DanceFlow;
//# sourceMappingURL=DanceFlow.node.js.map