@wiro-ai/n8n-nodes-wiroai
Version:
n8n community node for Wiro AI — 290+ AI models: video, image, audio, LLM, 3D, and more.
186 lines • 7.16 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IcLight = void 0;
const n8n_workflow_1 = require("n8n-workflow");
const auth_1 = require("../utils/auth");
const polling_1 = require("../utils/polling");
class IcLight {
constructor() {
this.description = {
displayName: 'Wiro - Change Scene & Light',
name: 'icLight',
icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' },
group: ['transform'],
version: 1,
description: 'More Lighting! IC-Light is used to manipulate the illumination of images using a text-condition',
defaults: {
name: 'Wiro - Change Scene & Light',
},
inputs: [n8n_workflow_1.NodeConnectionTypes.Main],
outputs: [n8n_workflow_1.NodeConnectionTypes.Main],
usableAsTool: true,
credentials: [
{
name: 'wiroApi',
required: true,
},
],
properties: [
{
displayName: 'Foreground Image URL',
name: 'inputImageUrl',
type: 'string',
default: '',
description: 'Foreground-image-help',
},
{
displayName: 'Prompt',
name: 'prompt',
type: 'string',
default: '',
description: 'Prompt-help',
},
{
displayName: 'Negativeprompt',
name: 'negativePrompt',
type: 'string',
default: '',
description: 'Negativeprompt-help',
},
{
displayName: 'Numberofoutputs',
name: 'samples',
type: 'number',
default: 0,
description: 'Numberofoutputs-help',
},
{
displayName: 'Inferencesteps',
name: 'steps',
type: 'number',
default: 0,
description: 'Inferencesteps-help',
},
{
displayName: 'Guidancescale',
name: 'scale',
type: 'number',
default: 0,
description: 'Guidancescale-help',
},
{
displayName: 'Highres Scale',
name: 'highres_scale',
type: 'number',
default: 0,
description: 'Highres-scale-help',
},
{
displayName: 'Lowres Denoise',
name: 'lowres_denoise',
type: 'number',
default: 0,
description: 'Highres-scale-help',
},
{
displayName: 'Highres Denoise',
name: 'highres_denoise',
type: 'number',
default: 0,
description: 'Highres-denoise-help',
},
{
displayName: 'Seed',
name: 'seed',
type: 'string',
default: '',
description: 'Seed-help',
},
{
displayName: 'Bg Source',
name: 'bg_source',
type: 'options',
default: 'Bottom Light',
description: 'Bg-source-help',
options: [
{ name: 'Bottom Light', value: 'Bottom Light' },
{ name: 'Left Light', value: 'Left Light' },
{ name: 'None', value: 'None' },
{ name: 'Right Light', value: 'Right Light' },
{ name: 'Top Light', value: 'Top Light' },
],
},
],
};
}
async execute() {
const returnData = [];
const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, '');
const prompt = this.getNodeParameter('prompt', 0, '');
const negativePrompt = this.getNodeParameter('negativePrompt', 0, '');
const samples = this.getNodeParameter('samples', 0, 0);
const steps = this.getNodeParameter('steps', 0, 0);
const scale = this.getNodeParameter('scale', 0, 0);
const highres_scale = this.getNodeParameter('highres_scale', 0, 0);
const lowres_denoise = this.getNodeParameter('lowres_denoise', 0, 0);
const highres_denoise = this.getNodeParameter('highres_denoise', 0, 0);
const seed = this.getNodeParameter('seed', 0, '');
const bg_source = this.getNodeParameter('bg_source', 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/ic-light',
headers: {
...headers,
'Content-Type': 'application/json',
},
body: {
inputImageUrl,
prompt,
negativePrompt,
samples,
steps,
scale,
highres_scale,
lowres_denoise,
highres_denoise,
seed,
bg_source,
},
});
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.IcLight = IcLight;
//# sourceMappingURL=IcLight.node.js.map