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.
/**
* Insert `row` into a name-sorted list store, or return the list unchanged if a
* row with the same id already exists. Used by create-on-the-fly flows (which
* append synchronously) and the realtime INSERT handlers (which may deliver the
* same row later) so the two paths never double-add.
*/
export function upsertIntoListStore<T extends { id: string; name: string }>(
rows: T[],
row: T
): T[] {
return rows.some((r) => r.id === row.id)
? rows
: [...rows, row].sort((a, b) => a.name.localeCompare(b.name));
}