Новый сервис khbuild_process_viz: Гант и ARIS eEPC процесса to-be
Some checks failed
ci / test (push) Successful in 17s
ci / deploy (push) Failing after 22s

Читает таблицы khbuild_* (и архивные khnata_*) из Supabase и рисует SVG:
диаграмму Ганта (сроки из date_constraint и зависимостей, предупреждения о
противоречиях) и ARIS eEPC (дорожки ролей, функции, события, системы, данные).
Страница просмотра с вкладками, масштабом и фильтрами, доступ по токену.
Сервис добавлен в deploy/deploy.sh последним (порт 8086), документация в
docs/proposed, отклонение 16.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 08:24:50 +03:00
parent d8f3ddee37
commit 3fa8bb7e8e
30 changed files with 1246 additions and 4 deletions

View File

@@ -0,0 +1,70 @@
import type { Queryable } from "khb_common";
/** Наборы таблиц «звезды» процесса: актуальный khbuild_* и архив khnata_*. */
export const PROCESS_SETS = ["khbuild", "khnata"] as const;
export type ProcessSet = (typeof PROCESS_SETS)[number];
export interface ProcessRow {
id: string;
stage: string | null;
actionName: string | null;
description: string | null;
role: string | null;
responsibleName: string | null;
systemAsIs: string | null;
systemToBe: string | null;
dataIn: string[];
dataOut: string[];
dependsOn: string[];
duration: string | null;
dateConstraint: string | null;
questions: string | null;
}
export interface RoleRow { id: string; person: string | null; comment: string | null }
export interface SystemRow { id: string; name: string | null; comment: string | null }
export interface DataRow { id: string; description: string | null; role: string | null; comment: string | null }
export interface ProcessModel {
set: ProcessSet;
rows: ProcessRow[];
roles: RoleRow[];
systems: SystemRow[];
data: DataRow[];
}
type Raw = Record<string, unknown>;
const str = (v: unknown): string | null => (typeof v === "string" && v.trim() !== "" ? v : null);
const list = (...vs: unknown[]): string[] => vs.map(str).filter((v): v is string => v !== null);
export function mapRow(r: Raw): ProcessRow {
return {
id: String(r.id),
stage: str(r.stage),
actionName: str(r.action_name),
description: str(r.action_description),
role: str(r.responsible_role),
responsibleName: str(r.responsible_name),
systemAsIs: str(r.system_as_is),
systemToBe: str(r.system_to_be),
dataIn: list(r.data_in1, r.data_in2, r.data_in3),
dataOut: list(r.data_out1, r.data_out2, r.data_out3),
dependsOn: list(r.depends_on, r.depends_on2, r.depends_on3),
duration: str(r.duration),
dateConstraint: str(r.date_constraint),
questions: str(r.questions),
};
}
/** Читает «звезду» из БД. Имена таблиц берутся только из белого списка PROCESS_SETS. Отсутствующие колонки (в архиве khnata их меньше) дают null. */
export async function loadModel(db: Queryable, set: ProcessSet): Promise<ProcessModel> {
if (!PROCESS_SETS.includes(set)) throw new Error(`неизвестный набор: ${set}`);
const q = async (table: string): Promise<Raw[]> => (await db.query(`select * from ${set}_${table} order by id`)).rows as Raw[];
const [process, roles, systems, data] = await Promise.all([q("process"), q("roles"), q("systems"), q("data_objects")]);
return {
set,
rows: process.map(mapRow),
roles: roles.map((r) => ({ id: String(r.id), person: str(r.role_person), comment: str(r.comment) })),
systems: systems.map((r) => ({ id: String(r.id), name: str(r.system_name), comment: str(r.comment) })),
data: data.map((r) => ({ id: String(r.id), description: str(r.data_description), role: str(r.responsible_role), comment: str(r.comment) })),
};
}