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
fix: rls policies for external integration mapping
Brad Barbin2253bb48089d
diff --git a/apps/erp/app/components/Hyperlink.tsx b/apps/erp/app/components/Hyperlink.tsxindex 97c9b8eddb..6dbbf375ec 100644--- a/apps/erp/app/components/Hyperlink.tsx+++ b/apps/erp/app/components/Hyperlink.tsx@@ -1,6 +1,6 @@import { Button, cn } from "@carbon/react";import type { ComponentProps, PropsWithChildren } from "react";-import { LuSquareArrowOutUpRight } from "react-icons/lu";+import { LuPanelRight } from "react-icons/lu";import type { LinkProps } from "react-router";import { Link } from "react-router";@@ -23,7 +23,7 @@ const Hyperlink = ({<span className="flex flex-row items-center gap-1">{children}</span>{props.to && props.to !== "#" && (<Button- leftIcon={<LuSquareArrowOutUpRight />}+ rightIcon={<LuPanelRight />}variant="secondary"className="flex-shrink-0 opacity-0 transition-opacity duration-200 group-hover/hyperlink:opacity-100 no-underline"size="sm"diff --git a/apps/erp/app/routes/api+/integrations.onshape.sync.ts b/apps/erp/app/routes/api+/integrations.onshape.sync.tsindex 0939c22b87..84af42a2c4 100644--- a/apps/erp/app/routes/api+/integrations.onshape.sync.ts+++ b/apps/erp/app/routes/api+/integrations.onshape.sync.ts@@ -63,7 +63,7 @@ export async function action({ request }: ActionFunctionArgs) {const itemId = record.data?.itemId as string;// Upsert the OnShape mapping in externalIntegrationMapping- await client+ await getCarbonServiceRole().from("externalIntegrationMapping").delete().eq("entityType", "item")@@ -83,7 +83,7 @@ export async function action({ request }: ActionFunctionArgs) {companyId});} catch (error) {- console.error("Failed to sync onshape data");+ console.error("Failed to sync onshape data", error);return data({ success: false, message: "Invalid rows data" },{ status: 400 }diff --git a/packages/database/supabase/migrations/20260204001831_external-integration-mapping-rls.sql b/packages/database/supabase/migrations/20260204001831_external-integration-mapping-rls.sqlnew file mode 100644index 0000000000..928f550ed1--- /dev/null+++ b/packages/database/supabase/migrations/20260204001831_external-integration-mapping-rls.sql@@ -0,0 +1,23 @@+DROP POLICY IF EXISTS "manage_externalIntegrationMapping" ON "externalIntegrationMapping";++CREATE POLICY "SELECT" ON "externalIntegrationMapping"+FOR SELECT+USING (+ "companyId" = ANY (+ (+ SELECT+ get_companies_with_employee_role()+ )::text[]+ )+);++CREATE POLICY "INSERT" ON "externalIntegrationMapping"+FOR INSERT WITH CHECK (+ "companyId" = ANY (+ (+ SELECT+ get_companies_with_employee_role()+ )::text[]+ )+);+diff --git a/packages/ee/src/paperless-parts/lib/lib.ts b/packages/ee/src/paperless-parts/lib/lib.tsindex dc4506d760..b61e98dcc7 100644--- a/packages/ee/src/paperless-parts/lib/lib.ts+++ b/packages/ee/src/paperless-parts/lib/lib.ts@@ -1,4 +1,5 @@import { openai } from "@ai-sdk/openai";+import { getCarbonServiceRole } from "@carbon/auth";import type { Database } from "@carbon/database";import {getMaterialDescription,@@ -54,7 +55,7 @@ async function createPaperlessMapping(externalId: string,companyId: string): Promise<void> {- await carbon+ await getCarbonServiceRole().from("externalIntegrationMapping").delete().eq("entityType", entityType)