Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
// SPDX-License-Identifier: AGPL-3.0-only
// Carbon (github.com/crbnos/carbon). Modified or adapted versions of this file,
// including ports, remain AGPLv3; serving them over a network requires releasing their source.
import { requirePermissions } from "@carbon/auth/auth.server";
import type { LoaderFunctionArgs } from "react-router";
import { getCompanyRestoreRuns } from "~/modules/settings/backups.service";
import { canManageBackups } from "~/modules/settings/settings.service";
// Polled by the restore progress modal. A restore run is "running" until its
// marker row appears (the job writes it once the wipe+load commits), then
// "ready" for keep/revert. Once kept or reverted the marker is gone again — the
// client knows which phase it's in, so it interprets absence accordingly.
export async function loader({ request, params }: LoaderFunctionArgs) {
const { client, companyId, email } = await requirePermissions(request, {
update: "settings"
});
if (!(await canManageBackups(client, companyId, email)))
throw new Response("Not found", { status: 404 });
const restoreRunId = params.restoreRunId;
const runs = await getCompanyRestoreRuns(client, companyId);
const run = runs.data?.find((r) => r.restoreRunId === restoreRunId);
// No marker → "gone". The client interprets it by phase: during a restore it
// means the job hasn't written its first heartbeat yet (transient); during a
// revert it means the revert finished (the marker is deleted on success).
return {
status: run?.status ?? ("gone" as const),
rows: run?.rows ?? 0,
error: run?.error ?? null,
progress: run?.progress ?? null,
startedAt: run?.startedAt ?? null
};
}