UNPKG

@wiro-ai/n8n-nodes-wiroai

Version:

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

143 lines 5.94 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Seedream4 = void 0; const n8n_workflow_1 = require("n8n-workflow"); const auth_1 = require("../utils/auth"); const polling_1 = require("../utils/polling"); class Seedream4 { constructor() { this.description = { displayName: 'Wiro - Seedream V4', name: 'seedream4', icon: { light: 'file:wiro.svg', dark: 'file:wiro.svg' }, group: ['transform'], version: 1, description: 'Access the Seedream 4.0 API for fast high resolution image generation and editing. Simple integ', defaults: { name: 'Wiro - Seedream V4', }, 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 list of input image URL(s) and/or file(s) for creating, editing or combining images', }, { displayName: 'Prompt', name: 'prompt', type: 'string', default: '', required: true, description: 'Please provide how many images you want to generate in the prompt. Edit max images according to it.', }, { displayName: 'Size', name: 'size', type: 'options', default: '1440x2560', required: true, description: 'Output image(s) resolution', options: [ { name: '1440x2560 (9:16)', value: '1440x2560' }, { name: '1664x2496 (2:3)', value: '1664x2496' }, { name: '1728x2304 (3:4)', value: '1728x2304' }, { name: '2048x2048 (1:1)', value: '2048x2048' }, { name: '2304x1728 (4:3)', value: '2304x1728' }, { name: '2496x1664 (3:2)', value: '2496x1664' }, { name: '2560x1440 (16:9)', value: '2560x1440' }, { name: '3024x1296 (21:9)', value: '3024x1296' }, ], }, { displayName: 'Maximum Number Of Output Images', name: 'maxImages', type: 'number', default: 0, required: true, description: 'This is the limiter for number of outputs. Number of input reference images + Number of generated must be smaller then or equal to 15.', }, { displayName: 'Watermark', name: 'watermark', type: 'options', default: 'false', required: true, description: 'Whether the generated image(s) contains a watermark', options: [ { name: 'False', value: 'false' }, { name: 'True', value: 'true' }, ], }, ], }; } async execute() { const returnData = []; const inputImageUrl = this.getNodeParameter('inputImageUrl', 0, ''); const prompt = this.getNodeParameter('prompt', 0); const size = this.getNodeParameter('size', 0); const maxImages = this.getNodeParameter('maxImages', 0); const watermark = this.getNodeParameter('watermark', 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/ByteDance/seedream-v4', headers: { ...headers, 'Content-Type': 'application/json', }, body: { inputImageUrl, prompt, size, maxImages, watermark, }, }); 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.Seedream4 = Seedream4; //# sourceMappingURL=Seedream4.node.js.map