n8n-nodes-comfyui-media
Version:
n8n node to integrate with ComfyUI stable diffusion workflows for image to video conversion
44 lines • 1.62 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BinaryInputProvider = exports.Base64InputProvider = exports.UrlInputProvider = void 0;
class UrlInputProvider {
constructor(api, url) {
this.api = api;
this.url = url;
}
async getBuffer() {
const response = await this.api.request({ method: 'GET', url: this.url, encoding: null });
return Buffer.from(response);
}
}
exports.UrlInputProvider = UrlInputProvider;
class Base64InputProvider {
constructor(base64) {
this.base64 = base64;
}
async getBuffer() {
return Buffer.from(this.base64, 'base64');
}
}
exports.Base64InputProvider = Base64InputProvider;
class BinaryInputProvider {
constructor(helpers, binaryProperty, items) {
this.helpers = helpers;
this.binaryProperty = binaryProperty;
this.items = items;
}
async getBuffer() {
var _a;
let propertyName = this.binaryProperty;
if (!((_a = this.items[0].binary) === null || _a === void 0 ? void 0 : _a[propertyName])) {
const fallback = Object.keys(this.items[0].binary || {})
.find(k => { var _a; return (_a = this.items[0].binary[k].mimeType) === null || _a === void 0 ? void 0 : _a.startsWith('image/'); });
if (!fallback)
throw new Error(`No valid binary property found`);
propertyName = fallback;
}
return this.helpers.getBinaryDataBuffer(0, propertyName);
}
}
exports.BinaryInputProvider = BinaryInputProvider;
//# sourceMappingURL=inputProviders.js.map