UNPKG

n8n-nodes-comfyui-media

Version:

n8n node to integrate with ComfyUI stable diffusion workflows for image to video conversion

31 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Poller = void 0; class Poller { constructor(api, apiUrl, headers) { this.api = api; this.apiUrl = apiUrl; this.headers = headers; } async waitForCompletion(promptId, timeout) { var _a; let attempts = 0; const maxAttempts = 60 * timeout; while (attempts < maxAttempts) { await new Promise(r => setTimeout(r, 1000)); attempts++; const history = await this.api.request({ method: 'GET', url: `${this.apiUrl}/history/${promptId}`, headers: this.headers, json: true, }); const result = history[promptId]; if ((_a = result === null || result === void 0 ? void 0 : result.status) === null || _a === void 0 ? void 0 : _a.completed) return result; } throw new Error(`Timeout after ${timeout} minutes`); } } exports.Poller = Poller; //# sourceMappingURL=poller.js.map