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.
export const SUPPORT_EMAIL = "[email protected]";
/** Carbon-internal email domains — the single source of truth for the
* "is this a Carbon employee" gate (used both client- and server-side). */
export const INTERNAL_EMAIL_DOMAINS = ["@carbon.us.org", "@carbon.ms"];
/** True for Carbon-internal users; gates internal-only features. Normalizes the
* address so the client flag and the server gate never diverge on casing. */
export function isInternalEmail(email: string | null | undefined): boolean {
const normalized = (email ?? "").toLowerCase().trim();
return INTERNAL_EMAIL_DOMAINS.some((domain) => normalized.endsWith(domain));
}
/**
* Whether this account is subject to the ITAR **entity** gate — the Carbon
* GovCloud Rider, which binds a customer's own organization.
*
* Carbon staff provision customer tenants, which makes them an admin there
* (`seed-company` gives the creating user the Admin employee type, so they hold
* `users_update`). That permission is what the entity screen keys on, so without
* this exemption the staff member who created the company is the one put in
* front of "accept on behalf of <customer>" — a document only the customer can
* sign. Staff are never a representative of the customer entity, so the screen
* is neither shown to them nor acceptable by them; the customer's own first
* admin binds the customer.
*
* Staff are still subject to the **user** gate: the U.S.-Person attestation is
* about the individual, so every account touching a controlled tenant makes it,
* per company, ours included.
*/
export function requiresItarEntityCertification(
email: string | null | undefined
): boolean {
return !isInternalEmail(email);
}
export const FILE_SIZE_LIMIT_MB = {
CAD_MODEL_UPLOAD: 2560, // 2.5 GB — matches temp-staging bucket cap
DOCUMENT_UPLOAD: 50
} as const;
// Raw CAD source is kept in `temp-staging` and shown as a file in the documents
// list only when <= this (the served-bucket cap). Larger raws are hidden from
// the files list until the compact pipeline shrinks them (`.xbf.zst` /
// `.{ext}.zst`); the scheduled prune deletes only ORPHANED fat raws — anything
// a modelUpload still points at is kept until compaction succeeds.
export const MODEL_RAW_KEEP_MAX_BYTES = 50 * 1024 * 1024;
export const PO_EMAIL_ATTACHMENT_LIMIT_MB = 25;
export const PO_EMAIL_ATTACHMENT_WARN_MB = 20;
export const getFileSizeLimit = (type: keyof typeof FILE_SIZE_LIMIT_MB) => {
const valueMegaBytes = FILE_SIZE_LIMIT_MB[type];
const valueBytes = valueMegaBytes * 1024 * 1024;
return {
get megabytes() {
return valueMegaBytes;
},
format() {
return `${valueMegaBytes} ${valueMegaBytes > 1 ? "MBs" : "MB"}`;
},
get bytes() {
return valueBytes;
}
} as const;
};