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 { z } from "zod";
import { isSeasonalTheme, themes } from "./themes";
export enum Edition {
Cloud = "cloud",
Enterprise = "enterprise",
Community = "community",
Test = "test"
}
export type Mode = "light" | "dark";
/** What the user chose; `system` follows the operating system. */
export type ModePreference = Mode | "system";
export const modeValidator = z.object({
mode: z.enum(["light", "dark", "system"])
});
/**
* A theme color by name — one of `themes`, or a seasonal theme (picking one
* turns it back on). Stored per browser, like the mode.
*/
export const themeColorValidator = z.object({
theme: z
.string()
.refine(
(name) => themes.some((t) => t.name === name) || isSeasonalTheme(name),
{ message: "Invalid theme" }
)
});
export enum Plan {
Starter = "STARTER",
Business = "BUSINESS",
Partner = "PARTNER",
Unknown = "UNKNOWN"
}
// DB stores partner tiers as `PARTNER-300/400/500` etc. Collapse them onto
// `Plan.Partner` so plan-gate checks (`requirement.includes(plan)`) match.
export const companyPlanCacheKey = (companyId: string) =>
`companyPlan:${companyId}`;
export function normalizePlanId(planId: string | null | undefined): Plan {
if (!planId) return Plan.Unknown;
if (planId.startsWith("PARTNER")) return Plan.Partner;
return planId as Plan;
}
export type PickPartial<T, K extends keyof T> = Omit<T, K> &
Partial<Pick<T, K>>;
export interface TrackedEntityAttributes {
"Batch Number"?: string;
Customer?: string;
"Fixed Asset"?: string;
Job?: string;
"Job Make Method"?: string;
"Job Operation"?: string;
"Job Operation Index"?: number;
"Purchase Order"?: string;
"Purchase Order Line"?: string;
"Receipt Line Index"?: number;
"Receipt Line"?: string;
Receipt?: string;
"Rental Agreement"?: string;
"Sales Order"?: string;
"Sales Order Line"?: string;
Supplier?: string;
"Serial Number"?: string;
"Shipment Line Index"?: number;
"Shipment Line"?: string;
Shipment?: string;
"Split Entity ID"?: string;
"Split From Entity ID"?: string;
"Merged From Entity IDs"?: string[];
Shelf?: string;
"Stock Transfer Line"?: string;
"Stock Transfer"?: string;
expirationDate?: string;
}
export interface TrackedActivityAttributes {
"Consumed Quantity"?: number;
"Job Make Method"?: string;
"Job Material"?: string;
"Job Operation"?: string;
"Job Operation Step"?: string;
// 1-based unit the consume was for (assembly view), so batch-parent issues can be
// attributed per-unit even though every unit shares one lot entity.
Unit?: number;
"Original Quantity"?: number;
"Picking List"?: string;
"Picking List Line"?: string;
"Production Event"?: string;
"Receipt Line"?: string;
"Remaining Quantity"?: number;
Employee?: string;
Inspector?: string;
Job?: string;
Receipt?: string;
"Work Center"?: string;
}