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
translation chagnes and sanity
aashud68daa70afaa
diff --git a/.claude/rules/table-csv-export.md b/.claude/rules/table-csv-export.mdindex cfe0c77369..7e8127f0d6 100644--- a/.claude/rules/table-csv-export.md+++ b/.claude/rules/table-csv-export.md@@ -17,12 +17,27 @@ table** built on this component — there is no opt-in prop.## Flow-`Table.tsx` → `TableHeader` → `Download`, passing three column maps:+`Table.tsx` → `TableHeader` → `Download`. The three column-derived maps are built+once by `buildColumnMaps(columns, translateLabel)` in+`apps/erp/app/components/Table/utils.ts` (memoized in `Table.tsx`):++- `accessors: Record<string, string>` (passed as `columnAccessors`) — export key →+ translated human header label. The export key is `accessorKey ?? column.id`. A+ column is included when it has a string header (non-JSX) **or** a+ `meta.exportValue`. The label prefers a non-empty string header, then+ `meta.filterHeader` (covers JSX/blank-header columns), then the raw string+ header. **Throws** `Invalid accessorKey {key}. Cannot contain '_'` if any+ accessorKey contains an underscore.+- `exportValues: Record<string, (row) => unknown>` — export key → `meta.exportValue`+ for columns that define one. Lets a column export a derived/composite value (or+ resolve an id to a name) instead of the raw accessor read. See "meta hooks".+- `sortKeyToLabel: Record<string, string>` — server-sort key (`meta.sortBy ??+ accessorKey`) → translated label, used by the `Sort` picker. Only string-header+ columns with an accessorKey are included, so JSX-header columns (e.g. MRP week+ columns) never flood the picker.++`Download` also receives:-- `columnAccessors: Record<string, string>` — accessorKey → translated human- header label. Built in `Table.tsx` from `columns` via `getAccessorKey` +- `translateLabel(column.header)`. **Throws** `Invalid accessorKey {key}. Cannot- contain '_'` if any accessorKey contains an underscore.- `columnVisibility: Record<string, boolean>` — keyed by column id.- `columnOrder: string[]` — column ids in display order.@@ -30,7 +45,24 @@ table** built on this component — there is no opt-in prop.(`useSavedViews()`) so the export mirrors what the user currently sees.`TableHeader` (`apps/erp/app/components/Table/components/TableHeader.tsx`) always-renders `<Download data={data} columnAccessors columnOrder columnVisibility />`.+renders `<Download data columnAccessors exportValues columnOrder columnVisibility />`+and passes `sortKeyToLabel` to `<Sort>`.++## meta hooks (`types.ts`)++`ColumnMeta` (declared in `apps/erp/app/components/Table/types.ts`) adds two+optional, export/sort-related fields:++- `exportValue?: (row: TData) => string | number | boolean | null | undefined` —+ the CSV value for this column, given the full row. Overrides the raw-accessor+ read. Use it when the displayed value is derived/composite, or when the+ accessorKey is an id whose name lives in another row field. Keep it in sync with+ the column's `cell` (the common pattern is a shared formatter used by both).+- `sortBy?: string` — server-sort column override. When set, the sort UI writes+ `?sort=<sortBy>:dir` instead of using the accessorKey (e.g. accessor+ `supplierTypeId`, sort by the resolved `type` name). Must name a real column on+ the view. The per-column header sort menu in `Table.tsx` uses `meta.sortBy ??+ accessorKey` too.## Download.tsx behavior@@ -44,7 +76,16 @@ renders `<Download data={data} columnAccessors columnOrder columnVisibility />`.are `in columnAccessors` AND not `columnVisibility[id] === false`. Syntheticcolumns (select / expand / actions) are absent from `columnAccessors`, so theydrop out. CSV headers are the `columnAccessors` label values.-- **ID → name substitution:** for the accessor keys `itemId`, `supplierId`,+- **Per-cell value:** for each kept column, if `exportValues[key]` exists it is+ called with the full row to produce the value; otherwise the raw accessor read+ is used, with the id→name substitution below. The result is then passed through+ `serializeForCsv` — a last-resort guardrail that `JSON.stringify`s a plain+ object (so a nested object never ships as `[object Object]` or explodes into+ stray columns); arrays, dates, and primitives pass through untouched. A column+ whose value is an object should supply a readable `meta.exportValue` rather than+ rely on this.+- **ID → name substitution** (only on the raw-accessor path, i.e. no+ `meta.exportValue`): for the accessor keys `itemId`, `supplierId`,`employeeId`, `customerId`, the raw id is replaced with the record's `name`via the `useItems` / `useSuppliers` / `usePeople` / `useCustomers` stores(`apps/erp/app/stores/`, imported from `~/stores`). Lookup is a memoized@@ -65,14 +106,19 @@ Just render `<Table>` — the button comes for free. No `enableExport`-style pro## Gotchas-- The underscore restriction is enforced at the `columnAccessors` build step in- `Table.tsx`, not in `Download.tsx` — a `_` in any accessorKey crashes the table- before export is even possible.+- The underscore restriction is enforced in `buildColumnMaps` (`utils.ts`), not in+ `Download.tsx` — a `_` in any accessorKey crashes the table (it's the first map+ built) before export is even possible.- Export uses `data` currently passed to the table (the current page/result set),not a full server-side dump.- The `name` substitution is keyed on the literal accessor strings `itemId` /- `supplierId` / `employeeId` / `customerId`; a column holding one of those ids- under a different accessor key will export the raw id.+ `supplierId` / `employeeId` / `customerId` **and only runs when the column has no+ `meta.exportValue`**; a column holding one of those ids under a different+ accessor key (or one that supplies its own `exportValue`) will not get the+ store-backed substitution — resolve the name yourself in `exportValue`.+- A column with a JSX header and no `meta.filterHeader` and no `meta.exportValue`+ is absent from all three maps — it neither exports nor appears in the sort+ picker. Give it a `filterHeader` (label) and/or an `exportValue` to include it.## Unrelated standalone CSVdiff --git a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysTable.tsx b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysTable.tsxindex d4999dc321..e8125f650f 100644--- a/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysTable.tsx+++ b/apps/erp/app/modules/settings/ui/ApiKeys/ApiKeysTable.tsx@@ -25,6 +25,15 @@ type ApiKeysTableProps = {count: number;};+// `apiKey.scopes` is a `Json` column; narrow it to the scope map shape once so+// the cell and the CSV export read it the same way without an `as any` cast.+function getScopes(apiKey: ApiKey): Record<string, string[]> | null {+ const { scopes } = apiKey;+ return scopes && typeof scopes === "object" && !Array.isArray(scopes)+ ? (scopes as Record<string, string[]>)+ : null;+}+function getScopeCount(scopes: Record<string, string[]> | null): number {if (!scopes) return 0;return Object.keys(scopes).length;@@ -78,11 +87,7 @@ const ApiKeysTable = memo(({ data, count }: ApiKeysTableProps) => {id: "scopes",header: t`Scopes`,cell: ({ row }) => {- const scopes = (row.original as any).scopes as Record<- string,- string[]- > | null;- const scopeCount = getScopeCount(scopes);+ const scopeCount = getScopeCount(getScopes(row.original));return (<Badge variant="secondary">{scopeCount === 0 ? t`No Access` : t`${scopeCount} permissions`}@@ -92,11 +97,7 @@ const ApiKeysTable = memo(({ data, count }: ApiKeysTableProps) => {meta: {icon: <LuShield />,exportValue: (row) => {- const scopes = (row as any).scopes as Record<- string,- string[]- > | null;- const scopeCount = getScopeCount(scopes);+ const scopeCount = getScopeCount(getScopes(row));return scopeCount === 0? t`No Access`: t`${scopeCount} permissions`;diff --git a/packages/locale/locales/de/erp.po b/packages/locale/locales/de/erp.poindex b72f3c8e40..f12bae8610 100644--- a/packages/locale/locales/de/erp.po+++ b/packages/locale/locales/de/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Bestellt"msgid "On Production Demand"-msgstr ""+msgstr "Im Produktionsbedarf"msgid "On Purchase Order"msgstr "In Bestellung"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Vorbeugungsmaßnahme"msgid "Present Week"-msgstr ""+msgstr "Aktuelle Woche"msgid "Prev"msgstr "Zurück"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Woche {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Woche {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/es/erp.po b/packages/locale/locales/es/erp.poindex 54cb3e36ca..9fbd64751f 100644--- a/packages/locale/locales/es/erp.po+++ b/packages/locale/locales/es/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Pedido realizado"msgid "On Production Demand"-msgstr ""+msgstr "En Demanda de Producción"msgid "On Purchase Order"msgstr "En Orden de Compra"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Acción preventiva"msgid "Present Week"-msgstr ""+msgstr "Semana actual"msgid "Prev"msgstr "Anterior"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Semana {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Semana {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/fr/erp.po b/packages/locale/locales/fr/erp.poindex 8c2e204fb2..eda8ae7485 100644--- a/packages/locale/locales/fr/erp.po+++ b/packages/locale/locales/fr/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Commandé"msgid "On Production Demand"-msgstr ""+msgstr "En demande de production"msgid "On Purchase Order"msgstr "En commande d'achat"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Action préventive"msgid "Present Week"-msgstr ""+msgstr "Semaine en cours"msgid "Prev"msgstr "Précédent"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Semaine {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Semaine {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/hi/erp.po b/packages/locale/locales/hi/erp.poindex c344903c85..feb7b221d0 100644--- a/packages/locale/locales/hi/erp.po+++ b/packages/locale/locales/hi/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "ऑर्डर पर"msgid "On Production Demand"-msgstr ""+msgstr "उत्पादन मांग पर"msgid "On Purchase Order"msgstr "खरीद आदेश पर"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "निवारक कार्रवाई"msgid "Present Week"-msgstr ""+msgstr "वर्तमान सप्ताह"msgid "Prev"msgstr "पिछला"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "सप्ताह {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "सप्ताह {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/it/erp.po b/packages/locale/locales/it/erp.poindex dbd186b0e9..f9961c4480 100644--- a/packages/locale/locales/it/erp.po+++ b/packages/locale/locales/it/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "In ordine"msgid "On Production Demand"-msgstr ""+msgstr "In Domanda di Produzione"msgid "On Purchase Order"msgstr "In Ordine di Acquisto"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Azione preventiva"msgid "Present Week"-msgstr ""+msgstr "Settimana corrente"msgid "Prev"msgstr "Prec"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Settimana {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Settimana {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/ja/erp.po b/packages/locale/locales/ja/erp.poindex 1ac7cb1d52..6f3c567599 100644--- a/packages/locale/locales/ja/erp.po+++ b/packages/locale/locales/ja/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "発注済み"msgid "On Production Demand"-msgstr ""+msgstr "生産需要中"msgid "On Purchase Order"msgstr "購買注文中"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "予防措置"msgid "Present Week"-msgstr ""+msgstr "今週"msgid "Prev"msgstr "前へ"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "週 {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "週 {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/pl/erp.po b/packages/locale/locales/pl/erp.poindex d65be2ff24..56d830654a 100644--- a/packages/locale/locales/pl/erp.po+++ b/packages/locale/locales/pl/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Zamówione"msgid "On Production Demand"-msgstr ""+msgstr "Na zapotrzebowaniu produkcyjnym"msgid "On Purchase Order"msgstr "Na zamówieniu zakupu"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Działanie zapobiegawcze"msgid "Present Week"-msgstr ""+msgstr "Bieżący tydzień"msgid "Prev"msgstr "Poprz"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Tydzień {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Tydzień {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/pt/erp.po b/packages/locale/locales/pt/erp.poindex b946cbc5e5..fec2e4ee20 100644--- a/packages/locale/locales/pt/erp.po+++ b/packages/locale/locales/pt/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Em pedido"msgid "On Production Demand"-msgstr ""+msgstr "Em Demanda de Produção"msgid "On Purchase Order"msgstr "Em Ordem de Compra"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Ação preventiva"msgid "Present Week"-msgstr ""+msgstr "Semana atual"msgid "Prev"msgstr "Anterior"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Semana {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Semana {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/ru/erp.po b/packages/locale/locales/ru/erp.poindex 97e4aface6..baba54d900 100644--- a/packages/locale/locales/ru/erp.po+++ b/packages/locale/locales/ru/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Заказано"msgid "On Production Demand"-msgstr ""+msgstr "На производственном спросе"msgid "On Purchase Order"msgstr "На заказе покупки"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Предупредительное действие"msgid "Present Week"-msgstr ""+msgstr "Текущая неделя"msgid "Prev"msgstr "Пред"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Неделя {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Неделя {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/tr/erp.po b/packages/locale/locales/tr/erp.poindex a2f2606e9f..753b1901ca 100644--- a/packages/locale/locales/tr/erp.po+++ b/packages/locale/locales/tr/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "Siparişte"msgid "On Production Demand"-msgstr ""+msgstr "Üretim Talebinde"msgid "On Purchase Order"msgstr "Satın Alma Siparişinde"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "Önleyici İşlem"msgid "Present Week"-msgstr ""+msgstr "Mevcut Hafta"msgid "Prev"msgstr "Önceki"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "Hafta {0} ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "Hafta {weekNumber}"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"diff --git a/packages/locale/locales/zh/erp.po b/packages/locale/locales/zh/erp.poindex 13bcbf4248..898b4a5e12 100644--- a/packages/locale/locales/zh/erp.po+++ b/packages/locale/locales/zh/erp.po@@ -6800,7 +6800,7 @@ msgid "On order"msgstr "已订购"msgid "On Production Demand"-msgstr ""+msgstr "生产需求上"msgid "On Purchase Order"msgstr "采购订单上"@@ -7419,7 +7419,7 @@ msgid "Prepayments (default)"msgstr "预防措施"msgid "Present Week"-msgstr ""+msgstr "本周"msgid "Prev"msgstr "上一页"@@ -11207,7 +11207,7 @@ msgid "Week {0} ({formattedDate})"msgstr "第 {0} 周 ({formattedDate})"msgid "Week {weekNumber}"-msgstr ""+msgstr "第 {weekNumber} 周"#. placeholder {0}: dateFormatter.format(parseDate(d.startDate).toDate(getLocalTimeZone()))msgid "Week of {0}"