UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

158 lines 6.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VirtualTryOn = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class VirtualTryOn { constructor() { this.description = { displayName: 'Wiro - Virtual Try-on', name: 'virtualTryOn', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Integrate the Wiro Virtual Try-On API to deliver hyper-realistic apparel fitting directly in yo', defaults: { name: 'Wiro - Virtual Try-on', }, inputs: [n8n_workflow_1.NodeConnectionTypes.Main], outputs: [n8n_workflow_1.NodeConnectionTypes.Main], usableAsTool: true, credentials: [ { name: 'wiroApi', required: true, }, ], properties: [ { displayName: 'Human Image URL', name: 'inputImageHumanUrl', type: 'string', default: '', required: true, description: 'Upload the photo of the person who will model the outfit', }, { displayName: 'Garment Images URL', name: 'inputImageClothesUrl', type: 'string', default: '', description: 'Upload images of garments and accessories to try on (max. 2).', }, { displayName: 'Photography Style', name: 'style', type: 'options', default: 'indoor', description: 'Choose the photography style and environment for the output image', options: [ { name: 'Indoor Lifestyle', value: 'indoor' }, { name: 'Outdoor Location', value: 'outdoor' }, { name: 'Studio Photography', value: 'studio' }, { name: 'Virtual Try On (Keep Original Scene)', value: 'virtual-try-on' }, ], }, { displayName: 'Posture', name: 'pose', type: 'options', default: 'auto', description: 'Choose the body posture for the model', options: [ { name: 'Auto (Best For Garment)', value: 'auto' }, { name: 'Side Profile', value: 'side-profile' }, { name: 'Sitting', value: 'sitting' }, { name: 'Standing', value: 'standing' }, ], }, { displayName: 'Shot Type', name: 'plan', type: 'options', default: 'auto', description: 'Choose the framing/composition type. Note: Headshot ignores footwear, Medium Shot ignores lower body items.', options: [ { name: 'Auto (Best For Garment)', value: 'auto' }, { name: 'Headshot (Shoulders Up)', value: 'headshot' }, { name: 'Medium Shot (Waist Up)', value: 'medium-shot' }, { name: 'Wide Shot (Full Body)', value: 'wide-shot' }, ], }, { displayName: 'Output Type', name: 'outputType', type: 'options', default: 'image', description: 'Select option for output type', options: [ { name: 'Image', value: 'image' }, { name: 'Image & Video', value: 'both' }, { name: 'Video', value: 'video' }, ], }, ], }; } async execute() { const returnData = []; const inputImageHumanUrl = this.getNodeParameter('inputImageHumanUrl', 0); const inputImageClothesUrl = this.getNodeParameter('inputImageClothesUrl', 0, ''); const style = this.getNodeParameter('style', 0, ''); const pose = this.getNodeParameter('pose', 0, ''); const plan = this.getNodeParameter('plan', 0, ''); const outputType = this.getNodeParameter('outputType', 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/Virtual Try-On', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageHumanUrl, inputImageClothesUrl, style, pose, plan, outputType, }, }); 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.VirtualTryOn = VirtualTryOn; //# sourceMappingURL=VirtualTryOn.node.js.map