Some checks failed
test / test (push) Failing after 24s
Реализация целевого дизайна (docs/architecture/target-design.md): - src/: модульная структура (config, logger, errors, http, core: auth/history/jobs/engines/comfy/codex/images) - Очередь заданий: FIFO, кониурентность codex=1 / comfy-upscale=2, MAX_QUEUED_JOBS=5, JSONL-журнал и восстановление после рестарта (running → interrupted, upscale requeue) - Персистентные сессии (sha256-хеши токенов), scrypt-хеш пароля, rate-limit входа, Origin-проверка, magic-byte валидация аплоадов - Атомарная запись манифеста истории, каскадное удаление, URL с фактическим расширением + 302-алиас /image.jpg, миграция history/ → data/history - Даунскейл sharp до 1024px перед Codex + масштабирование области референса - SSE /api/events с фолбэком на polling, фронтенд переведён на ES-модули (public/js/) - Тесты node:test + supertest (27), CI workflow test.yml, Docker/деплой: том kadr-data - Документация: README, docs/architecture/
55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
"use strict";
|
||
|
||
/**
|
||
* @typedef {Object} EngineContext
|
||
* @property {import('../../config').loadConfig} config
|
||
* @property {import('../../logger').Logger} logger
|
||
* @property {import('../history/history-service').HistoryService} history
|
||
* @property {import('../comfy/comfy-client').ComfyClient} comfyClient
|
||
* @property {import('../comfy/comfy-runtime').ComfyRuntime} comfyRuntime
|
||
* @property {import('../codex/cli').CodexCli} codexCli
|
||
*
|
||
* @typedef {Object} EngineResult
|
||
* @property {boolean} ok
|
||
* @property {import('../history/history-store').Version} [version]
|
||
* @property {object} [extra]
|
||
* @property {string} [error]
|
||
* @property {any} [details]
|
||
*/
|
||
|
||
class EngineRegistry {
|
||
constructor() {
|
||
this._factories = new Map();
|
||
}
|
||
|
||
/**
|
||
* Регистрирует фабрику движка для типа задания.
|
||
* @param {string} type - 'edit' | 'upscale' | 'suggest'
|
||
* @param {(ctx: EngineContext) => { run: (job: any) => Promise<EngineResult> }} factory
|
||
*/
|
||
register(type, factory) {
|
||
this._factories.set(type, factory);
|
||
}
|
||
|
||
/**
|
||
* Создаёт экземпляр движка для указанного типа задания.
|
||
* @param {string} type
|
||
* @param {EngineContext} ctx
|
||
*/
|
||
create(type, ctx) {
|
||
const factory = this._factories.get(type);
|
||
if (!factory) {
|
||
throw new Error(`Не найден движок для типа задания: ${type}`);
|
||
}
|
||
return factory(ctx);
|
||
}
|
||
|
||
has(type) {
|
||
return this._factories.has(type);
|
||
}
|
||
}
|
||
|
||
module.exports = {
|
||
EngineRegistry,
|
||
};
|