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
refactor: move carbon service role to it's own server-only export
Brad Barbinf71419c97026
diff --git a/README.md b/README.mdindex 597b588db9..558e95d241 100644--- a/README.md+++ b/README.md@@ -372,7 +372,7 @@ const { data, error } = await carbon.from("item").select("*");### From the Monorepo```tsx-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";const carbon = getCarbonServiceRole();// returns all items across companiesdiff --git a/apps/academy/app/routes/_auth+/callback.tsx b/apps/academy/app/routes/_auth+/callback.tsxindex d8708ea033..315a63378d 100644--- a/apps/academy/app/routes/_auth+/callback.tsx+++ b/apps/academy/app/routes/_auth+/callback.tsx@@ -2,10 +2,10 @@ import {assertIsPost,callbackValidator,carbonClient,- error,- getCarbonServiceRole+ error} from "@carbon/auth";import { refreshAccessToken } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import {destroyAuthSession,diff --git a/apps/academy/app/routes/_auth+/health.tsx b/apps/academy/app/routes/_auth+/health.tsxindex 0106517cf6..a18d48983c 100644--- a/apps/academy/app/routes/_auth+/health.tsx+++ b/apps/academy/app/routes/_auth+/health.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";export async function loader() {try {diff --git a/apps/erp/app/modules/production/production.server.ts b/apps/erp/app/modules/production/production.server.tsnew file mode 100644index 0000000000..38f55513f0--- /dev/null+++ b/apps/erp/app/modules/production/production.server.ts@@ -0,0 +1,34 @@+/**+ * Triggers a job scheduling task via Trigger.dev.+ * Supports both initial scheduling and rescheduling.+ */+export async function triggerJobSchedule(+ jobId: string,+ companyId: string,+ userId: string,+ mode: "initial" | "reschedule" = "reschedule",+ direction: "backward" | "forward" = "backward"+) {+ const { scheduleJob } = await import("@carbon/jobs/trigger/reschedule-job");++ const handle = await scheduleJob.trigger({+ jobId,+ companyId,+ userId,+ mode,+ direction+ });++ return { success: true, runId: handle.id };+}++/**+ * @deprecated Use triggerJobSchedule with mode="reschedule" instead.+ */+export async function triggerJobReschedule(+ jobId: string,+ companyId: string,+ userId: string+) {+ return triggerJobSchedule(jobId, companyId, userId, "reschedule", "backward");+}diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.tsindex 15a50f5ab2..1b072c9026 100644--- a/apps/erp/app/modules/production/production.service.ts+++ b/apps/erp/app/modules/production/production.service.ts@@ -1,4 +1,3 @@-import { getCarbonServiceRole } from "@carbon/auth";import type { Database, Json } from "@carbon/database";import { fetchAllFromTable } from "@carbon/database";import type { JSONContent } from "@carbon/react";@@ -77,14 +76,12 @@ export async function convertSalesOrderLinesToJobs(return salesOrderLines;}- const serviceRole = getCarbonServiceRole();-const lines = salesOrderLines.data;if (!lines) {return { data: null, error: "No lines found" };}- const opportunity = await serviceRole+ const opportunity = await client.from("opportunity").select("*, quotes(*), salesOrders(*)").eq("id", salesOrder.data?.opportunityId ?? "")@@ -98,7 +95,7 @@ export async function convertSalesOrderLinesToJobs(for await (const line of lines) {if (line.methodType === "Make" && line.itemId) {- const itemManufacturing = await serviceRole+ const itemManufacturing = await client.from("itemReplenishment").select("*").eq("itemId", line.itemId)@@ -111,7 +108,7 @@ export async function convertSalesOrderLinesToJobs(const jobsToCreate = Math.max(1, totalJobs);- const manufacturing = await serviceRole+ const manufacturing = await client.from("itemReplenishment").select("*").eq("itemId", line.itemId)@@ -119,7 +116,7 @@ export async function convertSalesOrderLinesToJobs(.single();for await (const index of Array.from({ length: jobsToCreate }).keys()) {- const nextSequence = await serviceRole.rpc("get_next_sequence", {+ const nextSequence = await client.rpc("get_next_sequence", {sequence_name: "job",company_id: companyId});@@ -141,7 +138,7 @@ export async function convertSalesOrderLinesToJobs(let locationId = line.locationId ?? salesOrder.data?.locationId;if (!locationId) {- const defaultLocation = await serviceRole+ const defaultLocation = await client.from("location").select("id").eq("companyId", companyId)@@ -156,7 +153,7 @@ export async function convertSalesOrderLinesToJobs(}const shelfId = await getDefaultShelfForJob(- serviceRole,+ client,line.itemId,locationId!,companyId@@ -190,14 +187,14 @@ export async function convertSalesOrderLinesToJobs(};// Calculate priority based on due date and deadline type- const priority = await calculateJobPriority(serviceRole, {+ const priority = await calculateJobPriority(client, {dueDate: data.dueDate ?? null,deadlineType: data.deadlineType,companyId,locationId: locationId!});- const createJob = await serviceRole+ const createJob = await client.from("job").insert({...data,@@ -218,18 +215,15 @@ export async function convertSalesOrderLinesToJobs(}if (quoteId) {- const upsertMethod = await serviceRole.functions.invoke(- "get-method",- {- body: {- type: "quoteLineToJob",- sourceId: `${quoteId}:${line.id}`,- targetId: createJob.data.id,- companyId,- userId- }+ const upsertMethod = await client.functions.invoke("get-method", {+ body: {+ type: "quoteLineToJob",+ sourceId: `${quoteId}:${line.id}`,+ targetId: createJob.data.id,+ companyId,+ userId}- );+ });if (upsertMethod.error) {errors.push(@@ -238,18 +232,15 @@ export async function convertSalesOrderLinesToJobs(continue;}} else {- const upsertMethod = await serviceRole.functions.invoke(- "get-method",- {- body: {- type: "itemToJob",- sourceId: data.itemId,- targetId: createJob.data.id,- companyId,- userId- }+ const upsertMethod = await client.functions.invoke("get-method", {+ body: {+ type: "itemToJob",+ sourceId: data.itemId,+ targetId: createJob.data.id,+ companyId,+ userId}- );+ });if (upsertMethod.error) {errors.push(@@ -259,7 +250,7 @@ export async function convertSalesOrderLinesToJobs(}}- await serviceRole.functions.invoke("recalculate", {+ await client.functions.invoke("recalculate", {body: {type: "jobRequirements",id: createJob.data.id,@@ -3086,38 +3077,3 @@ export async function upsertDemandProjections(error: hasError ? results.find((r) => r.error)?.error : null};}--/**- * Trigger a job scheduling task via Trigger.dev.- * Supports both initial scheduling and rescheduling.- */-export async function triggerJobSchedule(- jobId: string,- companyId: string,- userId: string,- mode: "initial" | "reschedule" = "reschedule",- direction: "backward" | "forward" = "backward"-) {- const { scheduleJob } = await import("@carbon/jobs/trigger/reschedule-job");-- const handle = await scheduleJob.trigger({- jobId,- companyId,- userId,- mode,- direction- });-- return { success: true, runId: handle.id };-}--/**- * @deprecated Use triggerJobSchedule with mode="reschedule" instead.- */-export async function triggerJobReschedule(- jobId: string,- companyId: string,- userId: string-) {- return triggerJobSchedule(jobId, companyId, userId, "reschedule", "backward");-}diff --git a/apps/erp/app/modules/settings/settings.server.ts b/apps/erp/app/modules/settings/settings.server.tsindex 12f1b706f8..b457e9dde4 100644--- a/apps/erp/app/modules/settings/settings.server.ts+++ b/apps/erp/app/modules/settings/settings.server.ts@@ -1,5 +1,6 @@import type { Database, Json } from "@carbon/database";import { getIntegrationConfigById } from "@carbon/ee";+import { getIntegrationServerHooks } from "@carbon/ee/hooks.server";import { redis } from "@carbon/kv";import type { SupabaseClient } from "@supabase/supabase-js";import type { z } from "zod";@@ -351,9 +352,11 @@ export async function getIntegrationHealth(};}- const check = getIntegrationConfigById(integration.id!);+ const serverHooks = getIntegrationServerHooks(integration.id!);+ const config = getIntegrationConfigById(integration.id!);+ const healthcheck = serverHooks?.onHealthcheck ?? config?.onHealthcheck;- if (!check || !check.onHealthcheck) {+ if (!healthcheck) {return {...integration,health: "healthy"@@ -372,7 +375,7 @@ export async function getIntegrationHealth(};}- const status = await check.onHealthcheck(+ const status = await healthcheck(companyId,integration.metadata as Record<string, any>);diff --git a/apps/erp/app/modules/users/users.server.ts b/apps/erp/app/modules/users/users.server.tsindex 7481e5b9f1..db60812cb0 100644--- a/apps/erp/app/modules/users/users.server.ts+++ b/apps/erp/app/modules/users/users.server.ts@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { deleteAuthAccount } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash, requireAuthSession } from "@carbon/auth/session.server";import {deactivateCustomer,diff --git a/apps/erp/app/routes/_public+/callback.tsx b/apps/erp/app/routes/_public+/callback.tsxindex 3e591a44dc..d582e0f658 100644--- a/apps/erp/app/routes/_public+/callback.tsx+++ b/apps/erp/app/routes/_public+/callback.tsx@@ -3,10 +3,10 @@ import {CONTROLLED_ENVIRONMENT,callbackValidator,carbonClient,- error,- getCarbonServiceRole+ error} from "@carbon/auth";import { refreshAccessToken } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import {destroyAuthSession,diff --git a/apps/erp/app/routes/_public+/invite.$code.tsx b/apps/erp/app/routes/_public+/invite.$code.tsxindex a120e8f2d8..a8324c1e2b 100644--- a/apps/erp/app/routes/_public+/invite.$code.tsx+++ b/apps/erp/app/routes/_public+/invite.$code.tsx@@ -2,9 +2,9 @@ import {CarbonEdition,error,getAppUrl,- getCarbonServiceRole,getPermissionCacheKey} from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import {flash,diff --git a/apps/erp/app/routes/api+/ai+/chat+/agents/purchasing-agent.ts b/apps/erp/app/routes/api+/ai+/chat+/agents/purchasing-agent.tsindex 073df03ea5..1e57db5b29 100644--- a/apps/erp/app/routes/api+/ai+/chat+/agents/purchasing-agent.ts+++ b/apps/erp/app/routes/api+/ai+/chat+/agents/purchasing-agent.ts@@ -1,5 +1,5 @@import { openai } from "@ai-sdk/openai";-import { createPurchaseOrderTool } from "../tools/create-purchase-order";+import { createPurchaseOrderTool } from "../tools/create-purchase-order.server";import { getPartTool } from "../tools/get-part";import { getSupplierTool } from "../tools/get-supplier";import { getSupplierForPartsTool } from "../tools/get-supplier-for-parts";diff --git a/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts b/apps/erp/app/routes/api+/ai+/chat+/tools/config.tsindex 0411dfb45d..ec03bfabb3 100644--- a/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts+++ b/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts@@ -2,7 +2,7 @@ import type { ToolConfig } from "../agents/shared/tools";// Dynamically import all tool configs from sibling files// Exclude config.ts itself to avoid circular imports-const toolModules = import.meta.glob("./*.ts", {+const toolModules = import.meta.glob(["./*.ts", "!./*.server.ts"], {eager: true}) as Record<string, { config: ToolConfig }>;diff --git a/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.server.ts b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.server.tsnew file mode 100644index 0000000000..f4b5830374--- /dev/null+++ b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.server.ts@@ -0,0 +1,244 @@+import { getAppUrl } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";+import { tool } from "ai";+import { getCurrencyByCode } from "~/modules/accounting/accounting.service";+import { getEmployeeJob } from "~/modules/people/people.service";+import {+ deletePurchaseOrder,+ getSupplier as getSupplierById,+ getSupplierPayment,+ getSupplierShipping,+ insertSupplierInteraction+} from "~/modules/purchasing/purchasing.service";+import { getNextSequence } from "~/modules/settings";+import { path } from "~/utils/path";+import type { ChatContext } from "../agents/shared/context";+import { createPurchaseOrderSchema } from "./create-purchase-order";++export const createPurchaseOrderTool = tool({+ description: "Create a purchase order from a list of parts and a supplier",+ inputSchema: createPurchaseOrderSchema,+ execute: async function (args, executionOptions) {+ const context = executionOptions.experimental_context as ChatContext;++ console.log(+ "[createPurchaseOrderTool] Starting purchase order creation with args:",+ args+ );++ const [+ nextSequence,+ supplierInteraction,+ supplier,+ supplierPayment,+ supplierShipping,+ employeeJob+ ] = await Promise.all([+ getNextSequence(+ getCarbonServiceRole(),+ "purchaseOrder",+ context.companyId+ ),+ insertSupplierInteraction(+ context.client,+ context.companyId,+ args.supplierId+ ),+ getSupplierById(context.client, args.supplierId),+ getSupplierPayment(context.client, args.supplierId),+ getSupplierShipping(context.client, args.supplierId),+ getEmployeeJob(context.client, context.userId, context.companyId)+ ]);++ if (!supplierInteraction.data) {+ return {+ error: "Failed to create supplier interaction"+ };+ }++ if (!supplier.data) {+ return {+ error: "Supplier not found"+ };+ }+ if (!supplierPayment.data) {+ return {+ error: "Supplier payment not found"+ };+ }+ if (!supplierShipping.data) {+ return {+ error: "Supplier shipping not found"+ };+ }++ const purchaseOrder = {+ purchaseOrderId: nextSequence.data ?? "",+ supplierId: args.supplierId,+ supplierInteractionId: supplierInteraction.data?.id ?? null,+ exchangeRate: 1,+ exchangeRateUpdatedAt: new Date().toISOString(),+ companyId: context.companyId,+ createdBy: context.userId+ };++ const {+ paymentTermId,+ invoiceSupplierId,+ invoiceSupplierContactId,+ invoiceSupplierLocationId+ } = supplierPayment.data;++ const { shippingMethodId, shippingTermId } = supplierShipping.data;++ if (supplier.data?.currencyCode) {+ const currency = await getCurrencyByCode(+ context.client,+ context.companyId,+ supplier.data?.currencyCode ?? ""+ );+ if (currency.data) {+ purchaseOrder.exchangeRate = currency.data.exchangeRate ?? 1;+ purchaseOrder.exchangeRateUpdatedAt = new Date().toISOString();+ }+ }++ const order = await context.client+ .from("purchaseOrder")+ .insert(purchaseOrder)+ .select("id, purchaseOrderId");++ if (!order) {+ return {+ error: "Failed to create purchase order"+ };+ }++ const purchaseOrderId = order.data?.[0]?.id ?? "";+ const locationId = employeeJob.data?.locationId ?? null;++ if (!purchaseOrderId) {+ return {+ error: "Failed to create purchase order"+ };+ }++ try {+ await Promise.all([+ context.client+ .from("purchaseOrderDelivery")+ .insert({+ id: purchaseOrderId,+ locationId: locationId,+ shippingMethodId: shippingMethodId ?? null,+ shippingTermId: shippingTermId ?? null,+ companyId: context.companyId+ })+ .select("id")+ .single(),+ context.client+ .from("purchaseOrderPayment")+ .insert({+ id: purchaseOrderId,+ invoiceSupplierId: invoiceSupplierId,+ invoiceSupplierContactId: invoiceSupplierContactId,+ invoiceSupplierLocationId: invoiceSupplierLocationId,+ paymentTermId: paymentTermId,+ companyId: context.companyId+ })+ .select("id")+ .single()+ ]);++ // Create purchase order lines for each part+ await Promise.all(+ args.parts.map(async (part: { partId: string; quantity: number }) => {+ // Get item details+ const [item, supplierPart] = await Promise.all([+ context.client+ .from("item")+ .select("*")+ .eq("id", part.partId)+ .eq("companyId", context.companyId)+ .single(),+ context.client+ .from("supplierPart")+ .select("*")+ .eq("itemId", part.partId)+ .eq("companyId", context.companyId)+ .eq("supplierId", args.supplierId)+ .single()+ ]);++ if (!item.data) {+ throw new Error(`Item with ID ${part.partId} not found`);+ }++ // Get item cost and replenishment info+ const [itemCost, itemReplenishment] = await Promise.all([+ context.client+ .from("itemCost")+ .select("*")+ .eq("itemId", part.partId)+ .eq("companyId", context.companyId)+ .single(),+ context.client+ .from("itemReplenishment")+ .select("*")+ .eq("itemId", part.partId)+ .eq("companyId", context.companyId)+ .single()+ ]);++ const lineData = {+ purchaseOrderId: purchaseOrderId,+ itemId: part.partId,+ description: item.data?.name,+ purchaseOrderLineType: item.data?.type,+ purchaseQuantity: part.quantity,+ supplierUnitPrice:+ (supplierPart?.data?.unitPrice ?? itemCost?.data?.unitCost ?? 0) /+ purchaseOrder.exchangeRate,+ supplierShippingCost: 0,+ purchaseUnitOfMeasureCode:+ supplierPart?.data?.supplierUnitOfMeasureCode ??+ itemReplenishment?.data?.purchasingUnitOfMeasureCode ??+ item.data?.unitOfMeasureCode ??+ "EA",+ inventoryUnitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",+ conversionFactor:+ supplierPart?.data?.conversionFactor ??+ itemReplenishment?.data?.conversionFactor ??+ 1,+ locationId: locationId,+ shelfId: null,+ supplierTaxAmount: 0,+ companyId: context.companyId,+ createdBy: context.userId+ };++ // Create the purchase order line+ return context.client+ .from("purchaseOrderLine")+ .insert(lineData)+ .select("id")+ .single();+ })+ );++ return {+ ...order.data,+ link: `${getAppUrl()}${path.to.purchaseOrder(purchaseOrderId)}`+ };+ } catch (error) {+ if (purchaseOrderId) {+ await deletePurchaseOrder(context.client, purchaseOrderId);+ }+ return {+ error: `Failed to create purchase order details: ${+ error instanceof Error ? error.message : String(error)+ }`+ };+ }+ }+});diff --git a/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.tsindex 3c1d1d2d71..ca50a3ee1e 100644--- a/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts+++ b/apps/erp/app/routes/api+/ai+/chat+/tools/create-purchase-order.ts@@ -1,19 +1,5 @@-import { getAppUrl, getCarbonServiceRole } from "@carbon/auth";-import { tool } from "ai";import { LuShoppingCart } from "react-icons/lu";import { z } from "zod";-import { getCurrencyByCode } from "~/modules/accounting/accounting.service";-import { getEmployeeJob } from "~/modules/people/people.service";-import {- deletePurchaseOrder,- getSupplier as getSupplierById,- getSupplierPayment,- getSupplierShipping,- insertSupplierInteraction-} from "~/modules/purchasing/purchasing.service";-import { getNextSequence } from "~/modules/settings";-import { path } from "~/utils/path";-import type { ChatContext } from "../agents/shared/context";import type { ToolConfig } from "../agents/shared/tools";export const config: ToolConfig = {@@ -32,232 +18,3 @@ export const createPurchaseOrderSchema = z.object({}))});--export const createPurchaseOrderTool = tool({- description: "Create a purchase order from a list of parts and a supplier",- inputSchema: createPurchaseOrderSchema,- execute: async function (args, executionOptions) {- const context = executionOptions.experimental_context as ChatContext;-- console.log(- "[createPurchaseOrderTool] Starting purchase order creation with args:",- args- );-- const [- nextSequence,- supplierInteraction,- supplier,- supplierPayment,- supplierShipping,- employeeJob- // purchaser- ] = await Promise.all([- getNextSequence(- getCarbonServiceRole(),- "purchaseOrder",- context.companyId- ),- insertSupplierInteraction(- context.client,- context.companyId,- args.supplierId- ),- getSupplierById(context.client, args.supplierId),- getSupplierPayment(context.client, args.supplierId),- getSupplierShipping(context.client, args.supplierId),- getEmployeeJob(context.client, context.userId, context.companyId)- ]);-- if (!supplierInteraction.data) {- return {- error: "Failed to create supplier interaction"- };- }-- if (!supplier.data) {- return {- error: "Supplier not found"- };- }- if (!supplierPayment.data) {- return {- error: "Supplier payment not found"- };- }- if (!supplierShipping.data) {- return {- error: "Supplier shipping not found"- };- }-- const purchaseOrder = {- purchaseOrderId: nextSequence.data ?? "",- supplierId: args.supplierId,- supplierInteractionId: supplierInteraction.data?.id ?? null,- exchangeRate: 1,- exchangeRateUpdatedAt: new Date().toISOString(),- companyId: context.companyId,- createdBy: context.userId- };-- const {- paymentTermId,- invoiceSupplierId,- invoiceSupplierContactId,- invoiceSupplierLocationId- } = supplierPayment.data;-- const { shippingMethodId, shippingTermId } = supplierShipping.data;-- if (supplier.data?.currencyCode) {- const currency = await getCurrencyByCode(- context.client,- context.companyId,- supplier.data?.currencyCode ?? ""- );- if (currency.data) {- purchaseOrder.exchangeRate = currency.data.exchangeRate ?? 1;- purchaseOrder.exchangeRateUpdatedAt = new Date().toISOString();- }- }-- const order = await context.client- .from("purchaseOrder")- .insert(purchaseOrder)- .select("id, purchaseOrderId");-- if (!order) {- return {- error: "Failed to create purchase order"- };- }-- const purchaseOrderId = order.data?.[0]?.id ?? "";- const locationId = employeeJob.data?.locationId ?? null;-- if (!purchaseOrderId) {- return {- error: "Failed to create purchase order"- };- }-- try {- await Promise.all([- context.client- .from("purchaseOrderDelivery")- .insert({- id: purchaseOrderId,- locationId: locationId,- shippingMethodId: shippingMethodId ?? null,- shippingTermId: shippingTermId ?? null,- companyId: context.companyId- })- .select("id")- .single(),- context.client- .from("purchaseOrderPayment")- .insert({- id: purchaseOrderId,- invoiceSupplierId: invoiceSupplierId,- invoiceSupplierContactId: invoiceSupplierContactId,- invoiceSupplierLocationId: invoiceSupplierLocationId,- paymentTermId: paymentTermId,- companyId: context.companyId- })- .select("id")- .single()- ]);-- // Create purchase order lines for each part- await Promise.all(- args.parts.map(async (part: { partId: string; quantity: number }) => {- // Get item details- const [item, supplierPart] = await Promise.all([- context.client- .from("item")- .select("*")- .eq("id", part.partId)- .eq("companyId", context.companyId)- .single(),- context.client- .from("supplierPart")- .select("*")- .eq("itemId", part.partId)- .eq("companyId", context.companyId)- .eq("supplierId", args.supplierId)- .single()- ]);-- if (!item.data) {- throw new Error(`Item with ID ${part.partId} not found`);- }-- // Get item cost and replenishment info- const [itemCost, itemReplenishment] = await Promise.all([- context.client- .from("itemCost")- .select("*")- .eq("itemId", part.partId)- .eq("companyId", context.companyId)- .single(),- context.client- .from("itemReplenishment")- .select("*")- .eq("itemId", part.partId)- .eq("companyId", context.companyId)- .single()- ]);-- const lineData = {- purchaseOrderId: purchaseOrderId,- itemId: part.partId,- description: item.data?.name,- purchaseOrderLineType: item.data?.type,- purchaseQuantity: part.quantity,- supplierUnitPrice:- (supplierPart?.data?.unitPrice ?? itemCost?.data?.unitCost ?? 0) /- purchaseOrder.exchangeRate,- supplierShippingCost: 0,- purchaseUnitOfMeasureCode:- supplierPart?.data?.supplierUnitOfMeasureCode ??- itemReplenishment?.data?.purchasingUnitOfMeasureCode ??- item.data?.unitOfMeasureCode ??- "EA",- inventoryUnitOfMeasureCode: item.data?.unitOfMeasureCode ?? "EA",- conversionFactor:- supplierPart?.data?.conversionFactor ??- itemReplenishment?.data?.conversionFactor ??- 1,- locationId: locationId,- shelfId: null,- supplierTaxAmount: 0,- companyId: context.companyId,- createdBy: context.userId- };-- // Create the purchase order line- return context.client- .from("purchaseOrderLine")- .insert(lineData)- .select("id")- .single();- })- );-- return {- ...order.data,- link: `${getAppUrl()}${path.to.purchaseOrder(purchaseOrderId)}`- };- } catch (error) {- if (purchaseOrderId) {- await deletePurchaseOrder(context.client, purchaseOrderId);- }- return {- error: `Failed to create purchase order details: ${- error instanceof Error ? error.message : String(error)- }`- };- }- }-});diff --git a/apps/erp/app/routes/api+/integrations.jira.issue.create.ts b/apps/erp/app/routes/api+/integrations.jira.issue.create.tsindex e9062c9ca0..8cf2af941f 100644--- a/apps/erp/app/routes/api+/integrations.jira.issue.create.ts+++ b/apps/erp/app/routes/api+/integrations.jira.issue.create.ts@@ -5,7 +5,7 @@ import {getJiraClient,linkActionToJiraIssue,tiptapToAdf-} from "@carbon/ee/jira";+} from "@carbon/ee/jira.server";import type { ActionFunction, LoaderFunction } from "react-router";import { data } from "react-router";import { getIssueAction } from "~/modules/quality/quality.service";diff --git a/apps/erp/app/routes/api+/integrations.jira.issue.link.ts b/apps/erp/app/routes/api+/integrations.jira.issue.link.tsindex cd5dbdc4ca..cf798f68bd 100644--- a/apps/erp/app/routes/api+/integrations.jira.issue.link.ts+++ b/apps/erp/app/routes/api+/integrations.jira.issue.link.ts@@ -6,7 +6,7 @@ import {linkActionToJiraIssue,tiptapToAdf,unlinkActionFromJiraIssue-} from "@carbon/ee/jira";+} from "@carbon/ee/jira.server";import type { ActionFunction, LoaderFunction } from "react-router";import { data } from "react-router";import { getIssueAction } from "~/modules/quality/quality.service";diff --git a/apps/erp/app/routes/api+/integrations.jira.issue.sync-notes.ts b/apps/erp/app/routes/api+/integrations.jira.issue.sync-notes.tsindex 0de0dfa840..7295c02ae9 100644--- a/apps/erp/app/routes/api+/integrations.jira.issue.sync-notes.ts+++ b/apps/erp/app/routes/api+/integrations.jira.issue.sync-notes.ts@@ -1,10 +1,10 @@import { requirePermissions } from "@carbon/auth/auth.server";-import type { TiptapDocument } from "@carbon/ee/jira";+import type { TiptapDocument } from "@carbon/ee/jira.server";import {getJiraClient,getJiraIssueFromExternalId,tiptapToAdf-} from "@carbon/ee/jira";+} from "@carbon/ee/jira.server";import type { ActionFunction } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/api+/integrations.jira.oauth.ts b/apps/erp/app/routes/api+/integrations.jira.oauth.tsindex 04929aba04..fc0e7b2c6f 100644--- a/apps/erp/app/routes/api+/integrations.jira.oauth.ts+++ b/apps/erp/app/routes/api+/integrations.jira.oauth.ts@@ -1,7 +1,10 @@import { VERCEL_URL } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { getIntegrationConfigById } from "@carbon/ee";-import { exchangeCodeForTokens, getAccessibleResources } from "@carbon/ee/jira";+import {+ exchangeCodeForTokens,+ getAccessibleResources+} from "@carbon/ee/jira.server";import type { LoaderFunctionArgs } from "react-router";import { data, redirect } from "react-router";import { upsertCompanyIntegration } from "~/modules/settings/settings.server";diff --git a/apps/erp/app/routes/api+/integrations.linear.issue.create.ts b/apps/erp/app/routes/api+/integrations.linear.issue.create.tsindex 3ddcd94fe8..5197796fd7 100644--- a/apps/erp/app/routes/api+/integrations.linear.issue.create.ts+++ b/apps/erp/app/routes/api+/integrations.linear.issue.create.ts@@ -4,7 +4,7 @@ import {getCompanyEmployees,getLinearClient,linkActionToLinearIssue-} from "@carbon/ee/linear";+} from "@carbon/ee/linear.server";import type { ActionFunction, LoaderFunction } from "react-router";import { data } from "react-router";import { getIssueAction } from "~/modules/quality/quality.service";diff --git a/apps/erp/app/routes/api+/integrations.linear.issue.link.ts b/apps/erp/app/routes/api+/integrations.linear.issue.link.tsindex ab4421a5a0..70cd70c74e 100644--- a/apps/erp/app/routes/api+/integrations.linear.issue.link.ts+++ b/apps/erp/app/routes/api+/integrations.linear.issue.link.ts@@ -4,7 +4,7 @@ import {getLinearClient,linkActionToLinearIssue,unlinkActionFromLinearIssue-} from "@carbon/ee/linear";+} from "@carbon/ee/linear.server";import type { ActionFunction, LoaderFunction } from "react-router";import { data } from "react-router";import { getIssueAction } from "~/modules/quality/quality.service";diff --git a/apps/erp/app/routes/api+/integrations.linear.issue.sync-notes.ts b/apps/erp/app/routes/api+/integrations.linear.issue.sync-notes.tsindex fbc875697d..e2cbd37bc2 100644--- a/apps/erp/app/routes/api+/integrations.linear.issue.sync-notes.ts+++ b/apps/erp/app/routes/api+/integrations.linear.issue.sync-notes.ts@@ -1,10 +1,10 @@import { requirePermissions } from "@carbon/auth/auth.server";-import type { TiptapDocument } from "@carbon/ee/linear";+import type { TiptapDocument } from "@carbon/ee/linear.server";import {getLinearClient,getLinearIssueFromExternalId,tiptapToMarkdown-} from "@carbon/ee/linear";+} from "@carbon/ee/linear.server";import type { ActionFunction } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/api+/integrations.onshape.oauth.ts b/apps/erp/app/routes/api+/integrations.onshape.oauth.tsindex 7bf87ab105..3945e6699b 100644--- a/apps/erp/app/routes/api+/integrations.onshape.oauth.ts+++ b/apps/erp/app/routes/api+/integrations.onshape.oauth.ts@@ -1,11 +1,11 @@import {- getCarbonServiceRole,ONSHAPE_CLIENT_ID,ONSHAPE_CLIENT_SECRET,ONSHAPE_OAUTH_REDIRECT_URL,VERCEL_URL} from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { Onshape } from "@carbon/ee";import type { LoaderFunctionArgs } from "react-router";import { data, redirect } from "react-router";diff --git a/apps/erp/app/routes/api+/integrations.onshape.sync.ts b/apps/erp/app/routes/api+/integrations.onshape.sync.tsindex 99da3ed587..998be7f332 100644--- a/apps/erp/app/routes/api+/integrations.onshape.sync.ts+++ b/apps/erp/app/routes/api+/integrations.onshape.sync.ts@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { onShapeDataValidator } from "@carbon/ee/onshape";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/api+/integrations.radan.$version.ts b/apps/erp/app/routes/api+/integrations.radan.$version.tsindex 88d05e6c01..54faf53810 100644--- a/apps/erp/app/routes/api+/integrations.radan.$version.ts+++ b/apps/erp/app/routes/api+/integrations.radan.$version.ts@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { LoaderFunctionArgs } from "react-router";import { data } from "react-router";import { z } from "zod";diff --git a/apps/erp/app/routes/api+/integrations.slack.interactive.ts b/apps/erp/app/routes/api+/integrations.slack.interactive.tsindex c3febcf282..376ae9df75 100644--- a/apps/erp/app/routes/api+/integrations.slack.interactive.ts+++ b/apps/erp/app/routes/api+/integrations.slack.interactive.ts@@ -1,4 +1,5 @@-import { ERP_URL, getCarbonServiceRole } from "@carbon/auth";+import { ERP_URL } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import {createIssueSlackThread,diff --git a/apps/erp/app/routes/api+/integrations.xero.oauth.ts b/apps/erp/app/routes/api+/integrations.xero.oauth.tsindex e2356cf324..181613dbc7 100644--- a/apps/erp/app/routes/api+/integrations.xero.oauth.ts+++ b/apps/erp/app/routes/api+/integrations.xero.oauth.ts@@ -1,11 +1,12 @@import { VERCEL_URL, XERO_CLIENT_ID, XERO_CLIENT_SECRET } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";-import { getIntegrationConfigById, Xero } from "@carbon/ee";+import { Xero } from "@carbon/ee";import {DEFAULT_SYNC_CONFIG,getProviderIntegration,ProviderID} from "@carbon/ee/accounting";+import { xeroOnInstall } from "@carbon/ee/xero/hooks.server";import type { LoaderFunctionArgs } from "react-router";import { data, redirect } from "react-router";import { upsertCompanyIntegration } from "~/modules/settings/settings.server";@@ -179,10 +180,7 @@ export async function loader({ request }: LoaderFunctionArgs) {companyId: companyId});- const config = getIntegrationConfigById(Xero.id);-- typeof config?.onInstall === "function" &&- (await config.onInstall(companyId));+ await xeroOnInstall(companyId);if (createdXeroIntegration?.data?.metadata) {const requestUrl = new URL(request.url);diff --git a/apps/erp/app/routes/api+/kanban.$id.tsx b/apps/erp/app/routes/api+/kanban.$id.tsxindex 39e05fd5e1..7ea67083b3 100644--- a/apps/erp/app/routes/api+/kanban.$id.tsx+++ b/apps/erp/app/routes/api+/kanban.$id.tsx@@ -1,5 +1,6 @@-import { getCarbonServiceRole, notFound } from "@carbon/auth";+import { notFound } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { Loading } from "@carbon/react";import { getLocalTimeZone, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/api+/mrp.ts b/apps/erp/app/routes/api+/mrp.tsindex 63b868c841..8d7f1d69e8 100644--- a/apps/erp/app/routes/api+/mrp.ts+++ b/apps/erp/app/routes/api+/mrp.ts@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { ActionFunctionArgs } from "react-router";import { runMRP } from "~/modules/production/production.service";diff --git a/apps/erp/app/routes/api+/purchasing.digital-quote.$id.tsx b/apps/erp/app/routes/api+/purchasing.digital-quote.$id.tsxindex b3de5ce455..51f55722f2 100644--- a/apps/erp/app/routes/api+/purchasing.digital-quote.$id.tsx+++ b/apps/erp/app/routes/api+/purchasing.digital-quote.$id.tsx@@ -1,4 +1,5 @@-import { assertIsPost, getCarbonServiceRole, notFound } from "@carbon/auth";+import { assertIsPost, notFound } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { notifyTask } from "@carbon/jobs/trigger/notify";import { NotificationEvent } from "@carbon/notifications";diff --git a/apps/erp/app/routes/api+/resources.trainings.ts b/apps/erp/app/routes/api+/resources.trainings.tsindex 4127d089af..66a314122f 100644--- a/apps/erp/app/routes/api+/resources.trainings.ts+++ b/apps/erp/app/routes/api+/resources.trainings.ts@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { LoaderFunctionArgs } from "react-router";import { getOutstandingTrainingsForUser } from "~/modules/resources";diff --git a/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx b/apps/erp/app/routes/api+/sales.digital-quote.$id.tsxindex 4f2e9bada5..957385d15b 100644--- a/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx+++ b/apps/erp/app/routes/api+/sales.digital-quote.$id.tsx@@ -1,4 +1,5 @@-import { assertIsPost, getCarbonServiceRole, notFound } from "@carbon/auth";+import { assertIsPost, notFound } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { notifyTask } from "@carbon/jobs/trigger/notify";import { NotificationEvent } from "@carbon/notifications";import { tasks } from "@trigger.dev/sdk";diff --git a/apps/erp/app/routes/api+/search.tsx b/apps/erp/app/routes/api+/search.tsxindex bfe9ad2377..974bcce408 100644--- a/apps/erp/app/routes/api+/search.tsx+++ b/apps/erp/app/routes/api+/search.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { getUserClaims } from "@carbon/auth/users.server";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/api+/webhook.jira.$companyId.ts b/apps/erp/app/routes/api+/webhook.jira.$companyId.tsindex ba804214ff..4a9e75f2be 100644--- a/apps/erp/app/routes/api+/webhook.jira.$companyId.ts+++ b/apps/erp/app/routes/api+/webhook.jira.$companyId.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { syncIssueFromJiraSchema } from "@carbon/jobs/trigger/jira";import { tasks } from "@trigger.dev/sdk";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/api+/webhook.linear.$companyId.ts b/apps/erp/app/routes/api+/webhook.linear.$companyId.tsindex 8cc8a5bf22..01fc36347b 100644--- a/apps/erp/app/routes/api+/webhook.linear.$companyId.ts+++ b/apps/erp/app/routes/api+/webhook.linear.$companyId.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { syncIssueFromLinearSchema } from "@carbon/jobs/trigger/linear";import { tasks } from "@trigger.dev/sdk";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/api+/webhook.paperless-parts.$companyId.ts b/apps/erp/app/routes/api+/webhook.paperless-parts.$companyId.tsindex eb53425188..893595df9a 100644--- a/apps/erp/app/routes/api+/webhook.paperless-parts.$companyId.ts+++ b/apps/erp/app/routes/api+/webhook.paperless-parts.$companyId.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { paperlessPartsTask } from "@carbon/jobs/trigger/paperless-parts";import { tasks } from "@trigger.dev/sdk";import crypto from "crypto";diff --git a/apps/erp/app/routes/api+/webhook.xero.ts b/apps/erp/app/routes/api+/webhook.xero.tsindex e20506f63a..90e2e2d524 100644--- a/apps/erp/app/routes/api+/webhook.xero.ts+++ b/apps/erp/app/routes/api+/webhook.xero.ts@@ -19,7 +19,8 @@* background job to prevent webhook timeouts and ensure reliability.*/-import { getCarbonServiceRole, XERO_WEBHOOK_SECRET } from "@carbon/auth";+import { XERO_WEBHOOK_SECRET } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type {AccountingEntity,AccountingProvider,diff --git a/apps/erp/app/routes/file+/job+/$jobId.traveler[.]pdf.tsx b/apps/erp/app/routes/file+/job+/$jobId.traveler[.]pdf.tsxindex 206cc96533..53c313a378 100644--- a/apps/erp/app/routes/file+/job+/$jobId.traveler[.]pdf.tsx+++ b/apps/erp/app/routes/file+/job+/$jobId.traveler[.]pdf.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { Footer, JobTravelerPageContent } from "@carbon/documents/pdf";import type { JSONContent } from "@carbon/react";import { flattenTree, generateBomIds } from "@carbon/utils";diff --git a/apps/erp/app/routes/file+/model+/$id.tsx b/apps/erp/app/routes/file+/model+/$id.tsxindex 67eb744a07..bdb454fbbe 100644--- a/apps/erp/app/routes/file+/model+/$id.tsx+++ b/apps/erp/app/routes/file+/model+/$id.tsx@@ -1,4 +1,5 @@-import { getCarbonServiceRole, notFound } from "@carbon/auth";+import { notFound } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { ModelViewer } from "@carbon/react";import type { LoaderFunctionArgs } from "react-router";import { useLoaderData } from "react-router";diff --git a/apps/erp/app/routes/file+/model+/public.$.tsx b/apps/erp/app/routes/file+/model+/public.$.tsxindex ecea4640b9..10af5c5c8a 100644--- a/apps/erp/app/routes/file+/model+/public.$.tsx+++ b/apps/erp/app/routes/file+/model+/public.$.tsx@@ -1,4 +1,5 @@-import { getCarbonServiceRole, notFound } from "@carbon/auth";+import { notFound } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { supportedModelTypes } from "@carbon/utils";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/file+/preview+/$bucket.$.tsx b/apps/erp/app/routes/file+/preview+/$bucket.$.tsxindex fc0bf4071e..1ed1ea1cb5 100644--- a/apps/erp/app/routes/file+/preview+/$bucket.$.tsx+++ b/apps/erp/app/routes/file+/preview+/$bucket.$.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { LoaderFunctionArgs } from "react-router";const supportedFileTypes: Record<string, string> = {diff --git a/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsxindex fabd009643..c13b59e75c 100644--- a/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx+++ b/apps/erp/app/routes/file+/shipment+/$id[.]pdf.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { PackingSlipPDF } from "@carbon/documents/pdf";import type { JSONContent } from "@carbon/react";import { renderToStream } from "@react-pdf/renderer";diff --git a/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx b/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsxindex 0fd4ffee11..11b8e693b5 100644--- a/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx+++ b/apps/erp/app/routes/file+/traveler+/$id[.]pdf.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { JobTravelerPDF } from "@carbon/documents/pdf";import type { JSONContent } from "@carbon/react";import { flattenTree, generateBomIds } from "@carbon/utils";diff --git a/apps/erp/app/routes/oauth+/token.tsx b/apps/erp/app/routes/oauth+/token.tsxindex b102db1dde..db952248c0 100644--- a/apps/erp/app/routes/oauth+/token.tsx+++ b/apps/erp/app/routes/oauth+/token.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/onboarding+/company.tsx b/apps/erp/app/routes/onboarding+/company.tsxindex 707b153dcb..40b938dc41 100644--- a/apps/erp/app/routes/onboarding+/company.tsx+++ b/apps/erp/app/routes/onboarding+/company.tsx@@ -1,9 +1,6 @@-import {- assertIsPost,- CarbonEdition,- getCarbonServiceRole-} from "@carbon/auth";+import { assertIsPost, CarbonEdition } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import { updateCompanySession } from "@carbon/auth/session.server";import { ValidatedForm, validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/onboarding+/user.tsx b/apps/erp/app/routes/onboarding+/user.tsxindex c5f8f32d44..88d20fac70 100644--- a/apps/erp/app/routes/onboarding+/user.tsx+++ b/apps/erp/app/routes/onboarding+/user.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { destroyAuthSession } from "@carbon/auth/session.server";import { ValidatedForm, validationError, validator } from "@carbon/form";import {diff --git a/apps/erp/app/routes/share+/customer.$id.$.tsx b/apps/erp/app/routes/share+/customer.$id.$.tsxindex 856aef1c18..98a7f10925 100644--- a/apps/erp/app/routes/share+/customer.$id.$.tsx+++ b/apps/erp/app/routes/share+/customer.$id.$.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { redis } from "@carbon/kv";import { supportedModelTypes } from "@carbon/utils";import { Ratelimit } from "@upstash/ratelimit";diff --git a/apps/erp/app/routes/share+/customer.$id.tsx b/apps/erp/app/routes/share+/customer.$id.tsxindex 87b0152b81..8328547e74 100644--- a/apps/erp/app/routes/share+/customer.$id.tsx+++ b/apps/erp/app/routes/share+/customer.$id.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import {Avatar,diff --git a/apps/erp/app/routes/share+/quote.$id.tsx b/apps/erp/app/routes/share+/quote.$id.tsxindex 98bb76b277..f0faa763ab 100644--- a/apps/erp/app/routes/share+/quote.$id.tsx+++ b/apps/erp/app/routes/share+/quote.$id.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { Input, ValidatedForm } from "@carbon/form";import type { JSONContent } from "@carbon/react";import {diff --git a/apps/erp/app/routes/share+/scar.$id.tsx b/apps/erp/app/routes/share+/scar.$id.tsxindex 842c08f242..3f96c789cb 100644--- a/apps/erp/app/routes/share+/scar.$id.tsx+++ b/apps/erp/app/routes/share+/scar.$id.tsx@@ -1,9 +1,5 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/share+/supplier-quote.$id.tsx b/apps/erp/app/routes/share+/supplier-quote.$id.tsxindex dea9971bfe..d72c6aeaf4 100644--- a/apps/erp/app/routes/share+/supplier-quote.$id.tsx+++ b/apps/erp/app/routes/share+/supplier-quote.$id.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { Input, TextArea, ValidatedForm } from "@carbon/form";import type { JSONContent } from "@carbon/react";import {diff --git a/apps/erp/app/routes/x+/customer+/$customerId.contacts.new.tsx b/apps/erp/app/routes/x+/customer+/$customerId.contacts.new.tsxindex 866ab5b8ea..e81628369f 100644--- a/apps/erp/app/routes/x+/customer+/$customerId.contacts.new.tsx+++ b/apps/erp/app/routes/x+/customer+/$customerId.contacts.new.tsx@@ -1,11 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound,- success-} from "@carbon/auth";+import { assertIsPost, error, notFound, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type {diff --git a/apps/erp/app/routes/x+/feedback.tsx b/apps/erp/app/routes/x+/feedback.tsxindex 7f9543ff2b..96fa64e762 100644--- a/apps/erp/app/routes/x+/feedback.tsx+++ b/apps/erp/app/routes/x+/feedback.tsx@@ -1,5 +1,6 @@-import { getCarbonServiceRole, SUPABASE_URL } from "@carbon/auth";+import { SUPABASE_URL } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import { getSlackClient } from "@carbon/lib/slack.server";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/issue+/new.tsx b/apps/erp/app/routes/x+/issue+/new.tsxindex 84aa320385..5aaa8c5d30 100644--- a/apps/erp/app/routes/x+/issue+/new.tsx+++ b/apps/erp/app/routes/x+/issue+/new.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- ERP_URL,- error,- getCarbonServiceRole-} from "@carbon/auth";+import { assertIsPost, ERP_URL, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { notifyIssueCreated } from "@carbon/ee/notifications";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/issue+/update.tsx b/apps/erp/app/routes/x+/issue+/update.tsxindex 186b64a9ed..9ebbaaf2fa 100644--- a/apps/erp/app/routes/x+/issue+/update.tsx+++ b/apps/erp/app/routes/x+/issue+/update.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { isIssueLocked } from "~/modules/quality";diff --git a/apps/erp/app/routes/x+/items+/methods+/get.tsx b/apps/erp/app/routes/x+/items+/methods+/get.tsxindex bd4213e0a5..18cec2e73f 100644--- a/apps/erp/app/routes/x+/items+/methods+/get.tsx+++ b/apps/erp/app/routes/x+/items+/methods+/get.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/items+/methods+/save.tsx b/apps/erp/app/routes/x+/items+/methods+/save.tsxindex 2910c500e3..e67fb293ed 100644--- a/apps/erp/app/routes/x+/items+/methods+/save.tsx+++ b/apps/erp/app/routes/x+/items+/methods+/save.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/items+/methods+/version.new.tsx b/apps/erp/app/routes/x+/items+/methods+/version.new.tsxindex 4acebc750d..c886624845 100644--- a/apps/erp/app/routes/x+/items+/methods+/version.new.tsx+++ b/apps/erp/app/routes/x+/items+/methods+/version.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx b/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsxindex 1581011c70..bb37c9430d 100644--- a/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx+++ b/apps/erp/app/routes/x+/items+/methods+/versions.activate.$id.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";import { activateMethodVersion } from "~/modules/items/items.service";diff --git a/apps/erp/app/routes/x+/items+/revisions.new.tsx b/apps/erp/app/routes/x+/items+/revisions.new.tsxindex 9af7fc398d..ce002201a7 100644--- a/apps/erp/app/routes/x+/items+/revisions.new.tsx+++ b/apps/erp/app/routes/x+/items+/revisions.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { revisionValidator } from "~/modules/items/items.models";diff --git a/apps/erp/app/routes/x+/job+/$jobId.complete.tsx b/apps/erp/app/routes/x+/job+/$jobId.complete.tsxindex 4f313e6211..d15f106fa2 100644--- a/apps/erp/app/routes/x+/job+/$jobId.complete.tsx+++ b/apps/erp/app/routes/x+/job+/$jobId.complete.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";diff --git a/apps/erp/app/routes/x+/job+/$jobId.configure.tsx b/apps/erp/app/routes/x+/job+/$jobId.configure.tsxindex fcb9667850..b85b4ecc92 100644--- a/apps/erp/app/routes/x+/job+/$jobId.configure.tsx+++ b/apps/erp/app/routes/x+/job+/$jobId.configure.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { recalculateTask } from "@carbon/jobs/trigger/recalculate";import { tasks } from "@trigger.dev/sdk";diff --git a/apps/erp/app/routes/x+/job+/$jobId.details.tsx b/apps/erp/app/routes/x+/job+/$jobId.details.tsxindex 0c5d8fa11f..eccd8aea61 100644--- a/apps/erp/app/routes/x+/job+/$jobId.details.tsx+++ b/apps/erp/app/routes/x+/job+/$jobId.details.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/job+/$jobId.recalculate.tsx b/apps/erp/app/routes/x+/job+/$jobId.recalculate.tsxindex b8a68d3a49..186db1c534 100644--- a/apps/erp/app/routes/x+/job+/$jobId.recalculate.tsx+++ b/apps/erp/app/routes/x+/job+/$jobId.recalculate.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/$jobId.status.tsx b/apps/erp/app/routes/x+/job+/$jobId.status.tsxindex 7a106bd505..4e7d6ff418 100644--- a/apps/erp/app/routes/x+/job+/$jobId.status.tsx+++ b/apps/erp/app/routes/x+/job+/$jobId.status.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/bulk.new.tsx b/apps/erp/app/routes/x+/job+/bulk.new.tsxindex 763860983a..8a1fda60bf 100644--- a/apps/erp/app/routes/x+/job+/bulk.new.tsx+++ b/apps/erp/app/routes/x+/job+/bulk.new.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import {diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.delete.$id.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.delete.$id.tsxindex e8693cd2e8..3a32c50436 100644--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.delete.$id.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.delete.$id.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsxindex 974540ff93..2a9800706e 100644--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.material.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.delete.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.delete.tsxindex 5533c10ce1..a6c368c737 100644--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.delete.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.delete.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";import { recalculateJobOperationDependencies } from "~/modules/production/production.service";diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsxindex dc94bf64ef..3cd5c8d4e7 100644--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.order.tsx b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.order.tsxindex 9c1cbd2060..a0c85569a2 100644--- a/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.order.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/$jobId.operation.order.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/methods+/get.tsx b/apps/erp/app/routes/x+/job+/methods+/get.tsxindex 441ab2dcfe..ec78df2982 100644--- a/apps/erp/app/routes/x+/job+/methods+/get.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/get.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { data, redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/methods+/operation.procedure.sync.tsx b/apps/erp/app/routes/x+/job+/methods+/operation.procedure.sync.tsxindex d9a3af0d15..69699100e6 100644--- a/apps/erp/app/routes/x+/job+/methods+/operation.procedure.sync.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/operation.procedure.sync.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";diff --git a/apps/erp/app/routes/x+/job+/methods+/save.tsx b/apps/erp/app/routes/x+/job+/methods+/save.tsxindex d6e43ca3ad..7d6f5c4df5 100644--- a/apps/erp/app/routes/x+/job+/methods+/save.tsx+++ b/apps/erp/app/routes/x+/job+/methods+/save.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { data, redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/job+/new.tsx b/apps/erp/app/routes/x+/job+/new.tsxindex 37a3a89c60..14bcc1f851 100644--- a/apps/erp/app/routes/x+/job+/new.tsx+++ b/apps/erp/app/routes/x+/job+/new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { recalculateTask } from "@carbon/jobs/trigger/recalculate";diff --git a/apps/erp/app/routes/x+/job+/update.tsx b/apps/erp/app/routes/x+/job+/update.tsxindex 63585c7740..df3156a8d8 100644--- a/apps/erp/app/routes/x+/job+/update.tsx+++ b/apps/erp/app/routes/x+/job+/update.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { recalculateTask } from "@carbon/jobs/trigger/recalculate";import { tasks } from "@trigger.dev/sdk";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/maintenance+/$dispatchId.add-and-issue.tsx b/apps/erp/app/routes/x+/maintenance+/$dispatchId.add-and-issue.tsxindex 1191c8bc16..fa938a5f80 100644--- a/apps/erp/app/routes/x+/maintenance+/$dispatchId.add-and-issue.tsx+++ b/apps/erp/app/routes/x+/maintenance+/$dispatchId.add-and-issue.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/maintenance+/$dispatchId.item.$itemId.delete.tsx b/apps/erp/app/routes/x+/maintenance+/$dispatchId.item.$itemId.delete.tsxindex 9a27a8be28..e03598d3fc 100644--- a/apps/erp/app/routes/x+/maintenance+/$dispatchId.item.$itemId.delete.tsx+++ b/apps/erp/app/routes/x+/maintenance+/$dispatchId.item.$itemId.delete.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.post.tsx b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.post.tsxindex cc16c2044c..ab5daf2da2 100644--- a/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.post.tsx+++ b/apps/erp/app/routes/x+/purchase-invoice+/$invoiceId.post.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { getCompanySettings } from "~/modules/settings";diff --git a/apps/erp/app/routes/x+/purchase-invoice+/new.tsx b/apps/erp/app/routes/x+/purchase-invoice+/new.tsxindex facbfb9afc..4b82a4d872 100644--- a/apps/erp/app/routes/x+/purchase-invoice+/new.tsx+++ b/apps/erp/app/routes/x+/purchase-invoice+/new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { getLocalTimeZone, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.delete.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.delete.tsxindex 0a710cb288..3dfad0ba81 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.delete.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.delete.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound-} from "@carbon/auth";+import { assertIsPost, error, notFound } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsxindex e68e0b076b..741505050f 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.finalize.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { PurchaseOrderEmail } from "@carbon/documents/email";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsxindex 371331853a..6b1a467ecc 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.status.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsxindex 3665097e94..d8b8133d80 100644--- a/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx+++ b/apps/erp/app/routes/x+/purchase-order+/$orderId.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { PurchaseOrderEmail } from "@carbon/documents/email";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/purchasing+/_index.tsx b/apps/erp/app/routes/x+/purchasing+/_index.tsxindex e6d1902ebb..45ac2eb61c 100644--- a/apps/erp/app/routes/x+/purchasing+/_index.tsx+++ b/apps/erp/app/routes/x+/purchasing+/_index.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {Badge,Button,diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsxindex 233f76e9cc..ef7a30462e 100644--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.$lineId.details.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.compare.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.compare.tsxindex 9140cadb17..daea6f2abe 100644--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.compare.tsx+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.compare.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { LoaderFunctionArgs } from "react-router";import { getSupplierQuotesForComparison } from "~/modules/purchasing";diff --git a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsxindex ac30205e2c..89fb4bae9e 100644--- a/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx+++ b/apps/erp/app/routes/x+/purchasing-rfq+/$rfqId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { type JSONContent, VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quality+/gauges.$id.tsx b/apps/erp/app/routes/x+/quality+/gauges.$id.tsxindex 8d73a00e90..65a7a1ced6 100644--- a/apps/erp/app/routes/x+/quality+/gauges.$id.tsx+++ b/apps/erp/app/routes/x+/quality+/gauges.$id.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { getLocalTimeZone, parseDate, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/x+/quality+/gauges.new.tsx b/apps/erp/app/routes/x+/quality+/gauges.new.tsxindex e747027594..cd2aca968d 100644--- a/apps/erp/app/routes/x+/quality+/gauges.new.tsx+++ b/apps/erp/app/routes/x+/quality+/gauges.new.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { getLocalTimeZone, parseDate, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/x+/quality-document+/$id.tsx b/apps/erp/app/routes/x+/quality-document+/$id.tsxindex a177e80727..1520dde1b9 100644--- a/apps/erp/app/routes/x+/quality-document+/$id.tsx+++ b/apps/erp/app/routes/x+/quality-document+/$id.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { Database } from "@carbon/database";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/quality-document+/update.tsx b/apps/erp/app/routes/x+/quality-document+/update.tsxindex 9421c0eecd..ecd005169b 100644--- a/apps/erp/app/routes/x+/quality-document+/update.tsx+++ b/apps/erp/app/routes/x+/quality-document+/update.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { NotificationEvent } from "@carbon/notifications";import type { SupabaseClient } from "@supabase/supabase-js";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsxindex d09ffa4e61..2a323d9803 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.configure.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsxindex 0744a8e964..0db1b27813 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.$lineId.details.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.convert.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.convert.tsxindex fa3e934d25..da09b52a4e 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.convert.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.convert.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import { parseAcceptLanguage } from "intl-parse-accept-language";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsxindex 6a75908293..852647634c 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.drag.tsx@@ -1,6 +1,7 @@import { openai } from "@ai-sdk/openai";-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { modelThumbnailTask } from "@carbon/jobs/trigger/model-thumbnail";import { supportedModelTypes } from "@carbon/utils";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.duplicate.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.duplicate.tsxindex 5f34584bde..e6aa0ccfa7 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.duplicate.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.duplicate.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { ActionFunctionArgs } from "react-router";import { copyQuote } from "~/modules/sales/sales.service";diff --git a/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx b/apps/erp/app/routes/x+/quote+/$quoteId.new.tsxindex 74b2386b0f..cedc1bf207 100644--- a/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx+++ b/apps/erp/app/routes/x+/quote+/$quoteId.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsxindex 934b377136..1d23db43a3 100644--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.$id.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.delete.$id.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.delete.$id.tsxindex 0c93c06e88..b49eca88f7 100644--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.delete.$id.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.delete.$id.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsxindex 00eb441c2a..cdd0295c2f 100644--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.material.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsxindex f96e4a890a..bb2c5d8ce9 100644--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.$id.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsxindex e054a46b87..cd105071fb 100644--- a/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/$quoteId.$lineId.operation.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/get.tsx b/apps/erp/app/routes/x+/quote+/methods+/get.tsxindex a8418dc599..a263d3f9c6 100644--- a/apps/erp/app/routes/x+/quote+/methods+/get.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/get.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { data, redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/quote+/methods+/operation.delete.tsx b/apps/erp/app/routes/x+/quote+/methods+/operation.delete.tsxindex be93f0d269..d70bc7760d 100644--- a/apps/erp/app/routes/x+/quote+/methods+/operation.delete.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/operation.delete.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";import { recalculateQuoteLinePrices } from "~/modules/sales";diff --git a/apps/erp/app/routes/x+/quote+/methods+/save.tsx b/apps/erp/app/routes/x+/quote+/methods+/save.tsxindex 39a66a9887..705e478d90 100644--- a/apps/erp/app/routes/x+/quote+/methods+/save.tsx+++ b/apps/erp/app/routes/x+/quote+/methods+/save.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { data, redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/receipt+/$receiptId.details.tsx b/apps/erp/app/routes/x+/receipt+/$receiptId.details.tsxindex 7b9e44549b..8f33ad2d79 100644--- a/apps/erp/app/routes/x+/receipt+/$receiptId.details.tsx+++ b/apps/erp/app/routes/x+/receipt+/$receiptId.details.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/receipt+/$receiptId.post.tsx b/apps/erp/app/routes/x+/receipt+/$receiptId.post.tsxindex 411ae89784..4c7492b721 100644--- a/apps/erp/app/routes/x+/receipt+/$receiptId.post.tsx+++ b/apps/erp/app/routes/x+/receipt+/$receiptId.post.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx b/apps/erp/app/routes/x+/receipt+/$receiptId.tsxindex 42aa53b1bf..1ef841bc4f 100644--- a/apps/erp/app/routes/x+/receipt+/$receiptId.tsx+++ b/apps/erp/app/routes/x+/receipt+/$receiptId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/receipt+/lines.split.tsx b/apps/erp/app/routes/x+/receipt+/lines.split.tsxindex 75942f5ef4..82576f7f90 100644--- a/apps/erp/app/routes/x+/receipt+/lines.split.tsx+++ b/apps/erp/app/routes/x+/receipt+/lines.split.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/receipt+/lines.tracking.tsx b/apps/erp/app/routes/x+/receipt+/lines.tracking.tsxindex c38fd7b370..7d43ceb638 100644--- a/apps/erp/app/routes/x+/receipt+/lines.tracking.tsx+++ b/apps/erp/app/routes/x+/receipt+/lines.tracking.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { TrackedEntityAttributes } from "@carbon/utils";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/receipt+/new.tsx b/apps/erp/app/routes/x+/receipt+/new.tsxindex 16153660d0..d50f228439 100644--- a/apps/erp/app/routes/x+/receipt+/new.tsx+++ b/apps/erp/app/routes/x+/receipt+/new.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/resources+/suggestions.new.tsx b/apps/erp/app/routes/x+/resources+/suggestions.new.tsxindex 5678ba3105..08f744bba9 100644--- a/apps/erp/app/routes/x+/resources+/suggestions.new.tsx+++ b/apps/erp/app/routes/x+/resources+/suggestions.new.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import type { notifyTask } from "@carbon/jobs/trigger/notify";import { NotificationEvent } from "@carbon/notifications";diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsxindex 032a12fb4b..b9b4cb7932 100644--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.post.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { SalesInvoiceEmail } from "@carbon/documents/email";import { validator } from "@carbon/form";import type { sendEmailResendTask } from "@carbon/jobs/trigger/send-email-resend";diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsxindex e6315c5000..5f8b41fff9 100644--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { VStack } from "@carbon/react";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.void.tsx b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.void.tsxindex 17ded47da4..a49a42c1cc 100644--- a/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.void.tsx+++ b/apps/erp/app/routes/x+/sales-invoice+/$invoiceId.void.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/sales-invoice+/new.tsx b/apps/erp/app/routes/x+/sales-invoice+/new.tsxindex 02fe7bf435..605569e616 100644--- a/apps/erp/app/routes/x+/sales-invoice+/new.tsx+++ b/apps/erp/app/routes/x+/sales-invoice+/new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { getLocalTimeZone, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsxindex 2250add290..2638abb4d4 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.details.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound-} from "@carbon/auth";+import { assertIsPost, error, notFound } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.job.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.job.tsxindex bf4aa76ff1..9ceca23174 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.job.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.job.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { recalculateTask } from "@carbon/jobs/trigger/recalculate";diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.shipment.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.shipment.tsxindex cb9293153e..b68ce424c0 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.shipment.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.$lineId.shipment.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.confirm.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.confirm.tsxindex e369be4741..7991089194 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.confirm.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.confirm.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import { getSalesOrderStatus } from "@carbon/utils";import { getLocalTimeZone, today } from "@internationalized/date";diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.lines.jobs.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.lines.jobs.tsxindex c4d6e1ec9d..b8442fafdf 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.lines.jobs.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.lines.jobs.tsx@@ -1,9 +1,11 @@import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";import { convertSalesOrderLinesToJobs } from "~/modules/production/production.service";+import { getSalesOrder } from "~/modules/sales";import { path, requestReferrer } from "~/utils/path";export async function action({ request, params }: ActionFunctionArgs) {@@ -21,14 +23,24 @@ export async function action({ request, params }: ActionFunctionArgs) {create: "production"});- const salesOrder = await convertSalesOrderLinesToJobs(client, {+ const salesOrder = await getSalesOrder(client, orderId);+ if (salesOrder.error) {+ throw redirect(+ path.to.salesOrder(orderId),+ await flash(request, error(salesOrder.error, "Failed to get sales order"))+ );+ }++ const serviceRole = getCarbonServiceRole();++ const convertedJobs = await convertSalesOrderLinesToJobs(serviceRole, {orderId,companyId,userId});- if (salesOrder.error) {- const errorObj = salesOrder.error as any;+ if (convertedJobs.error) {+ const errorObj = convertedJobs.error as any;const errorMessage =typeof errorObj === "string"? errorObj@@ -39,7 +51,7 @@ export async function action({ request, params }: ActionFunctionArgs) {await flash(request,error(- salesOrder.error,+ convertedJobs.error,`Failed to convert sales order lines to jobs: ${errorMessage}`))diff --git a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx b/apps/erp/app/routes/x+/sales-order+/$orderId.tsxindex 9088d9ea4b..fa15e056ef 100644--- a/apps/erp/app/routes/x+/sales-order+/$orderId.tsx+++ b/apps/erp/app/routes/x+/sales-order+/$orderId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsxindex 1605bdb08d..fdfe1fe031 100644--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.$lineId.details.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsxindex 690f48e2be..29e7a83162 100644--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.convert.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsxindex 1e8febddfc..a78f318127 100644--- a/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx+++ b/apps/erp/app/routes/x+/sales-rfq+/$rfqId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { JSONContent } from "@carbon/react";import { VStack } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/schedule+/dates.update.tsx b/apps/erp/app/routes/x+/schedule+/dates.update.tsxindex 679db02e14..b4c8040f6b 100644--- a/apps/erp/app/routes/x+/schedule+/dates.update.tsx+++ b/apps/erp/app/routes/x+/schedule+/dates.update.tsx@@ -2,7 +2,7 @@ import { requirePermissions } from "@carbon/auth/auth.server";import { validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { scheduleJobUpdateValidator } from "~/modules/production/production.models";-import { triggerJobReschedule } from "~/modules/production/production.service";+import { triggerJobReschedule } from "~/modules/production/production.server";export async function action({ request }: ActionFunctionArgs) {const { client, userId, companyId } = await requirePermissions(request, {diff --git a/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx b/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsxindex 2be27a65de..4e7c018138 100644--- a/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx+++ b/apps/erp/app/routes/x+/settings+/approval-rules.$id.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/settings+/approval-rules.new.tsx b/apps/erp/app/routes/x+/settings+/approval-rules.new.tsxindex 68880103f4..20052776bd 100644--- a/apps/erp/app/routes/x+/settings+/approval-rules.new.tsx+++ b/apps/erp/app/routes/x+/settings+/approval-rules.new.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs, LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/settings+/approval-rules.tsx b/apps/erp/app/routes/x+/settings+/approval-rules.tsxindex 92ffabbc4e..e0505a928c 100644--- a/apps/erp/app/routes/x+/settings+/approval-rules.tsx+++ b/apps/erp/app/routes/x+/settings+/approval-rules.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { LoaderFunctionArgs } from "react-router";import { Outlet, redirect, useLoaderData } from "react-router";diff --git a/apps/erp/app/routes/x+/settings+/audit-logs.tsx b/apps/erp/app/routes/x+/settings+/audit-logs.tsxindex 6cb400f82c..4eca0d84d4 100644--- a/apps/erp/app/routes/x+/settings+/audit-logs.tsx+++ b/apps/erp/app/routes/x+/settings+/audit-logs.tsx@@ -1,10 +1,6 @@-import {- CarbonEdition,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { CarbonEdition, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import {disableAuditLog,diff --git a/apps/erp/app/routes/x+/settings+/company.new.tsx b/apps/erp/app/routes/x+/settings+/company.new.tsxindex 0e5b39af89..85e43176d4 100644--- a/apps/erp/app/routes/x+/settings+/company.new.tsx+++ b/apps/erp/app/routes/x+/settings+/company.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import { updateCompanySession } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx b/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsxindex b5e9772561..aba92644b3 100644--- a/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx+++ b/apps/erp/app/routes/x+/settings+/integrations.deactivate.$id.tsx@@ -1,10 +1,8 @@import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";-import {- integrations as availableIntegrations,- getIntegrationConfigById-} from "@carbon/ee";+import { integrations as availableIntegrations } from "@carbon/ee";+import { getIntegrationServerHooks } from "@carbon/ee/hooks.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";import { deactivateIntegration } from "~/modules/settings/settings.server";@@ -40,9 +38,9 @@ export async function action({ request, params }: ActionFunctionArgs) {}// Call the onUninstall hook if defined- const config = getIntegrationConfigById(integrationId);- if (config && typeof config.onUninstall === "function") {- await config.onUninstall(companyId);+ const hooks = getIntegrationServerHooks(integrationId);+ if (hooks?.onUninstall) {+ await hooks.onUninstall(companyId);}throw redirect(diff --git a/apps/erp/app/routes/x+/shared+/import.$tableId.tsx b/apps/erp/app/routes/x+/shared+/import.$tableId.tsxindex 26605e3506..2e36bf4e70 100644--- a/apps/erp/app/routes/x+/shared+/import.$tableId.tsx+++ b/apps/erp/app/routes/x+/shared+/import.$tableId.tsx@@ -1,5 +1,6 @@-import { getCarbonServiceRole, notFound } from "@carbon/auth";+import { notFound } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import { z } from "zod";diff --git a/apps/erp/app/routes/x+/shipment+/$shipmentId.details.tsx b/apps/erp/app/routes/x+/shipment+/$shipmentId.details.tsxindex f55cc76a41..43d2abd610 100644--- a/apps/erp/app/routes/x+/shipment+/$shipmentId.details.tsx+++ b/apps/erp/app/routes/x+/shipment+/$shipmentId.details.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/shipment+/$shipmentId.post.tsx b/apps/erp/app/routes/x+/shipment+/$shipmentId.post.tsxindex 0ba93dea97..9f5ff4f459 100644--- a/apps/erp/app/routes/x+/shipment+/$shipmentId.post.tsx+++ b/apps/erp/app/routes/x+/shipment+/$shipmentId.post.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/shipment+/$shipmentId.void.tsx b/apps/erp/app/routes/x+/shipment+/$shipmentId.void.tsxindex cfd81a95df..de0adb38f3 100644--- a/apps/erp/app/routes/x+/shipment+/$shipmentId.void.tsx+++ b/apps/erp/app/routes/x+/shipment+/$shipmentId.void.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/shipment+/lines.split.tsx b/apps/erp/app/routes/x+/shipment+/lines.split.tsxindex fe3e387f53..905c75b9e3 100644--- a/apps/erp/app/routes/x+/shipment+/lines.split.tsx+++ b/apps/erp/app/routes/x+/shipment+/lines.split.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/shipment+/lines.tracking.tsx b/apps/erp/app/routes/x+/shipment+/lines.tracking.tsxindex 7d2ae7e94a..8d8244d170 100644--- a/apps/erp/app/routes/x+/shipment+/lines.tracking.tsx+++ b/apps/erp/app/routes/x+/shipment+/lines.tracking.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/erp/app/routes/x+/shipment+/new.tsx b/apps/erp/app/routes/x+/shipment+/new.tsxindex d45f5a5da3..b97fb40ca2 100644--- a/apps/erp/app/routes/x+/shipment+/new.tsx+++ b/apps/erp/app/routes/x+/shipment+/new.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.approval.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.approval.tsxindex 034f6f2759..cc7129fa46 100644--- a/apps/erp/app/routes/x+/supplier+/$supplierId.approval.tsx+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.approval.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { NotificationEvent } from "@carbon/notifications";diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.new.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.new.tsxindex bad552c6a1..68a928fb72 100644--- a/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.new.tsx+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.contacts.new.tsx@@ -1,11 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound,- success-} from "@carbon/auth";+import { assertIsPost, error, notFound, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type {diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsxindex 4aba279742..5bc9f94487 100644--- a/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.processes.delete.$id.tsx@@ -1,4 +1,4 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";import { flash } from "@carbon/auth/session.server";import type {@@ -9,12 +9,8 @@ import { redirect, useNavigate, useParams } from "react-router";import { ConfirmDelete } from "~/components/Modals";import { useRouteData } from "~/hooks";import type { SupplierProcess } from "~/modules/purchasing";-import {- deleteSupplierProcess,- getSupplierProcessById-} from "~/modules/purchasing";+import { deleteSupplierProcess } from "~/modules/purchasing";import { path } from "~/utils/path";-import { supplierProcessesQuery } from "~/utils/react-query";export async function action({ request, params }: ActionFunctionArgs) {assertIsPost(request);@@ -41,21 +37,10 @@ export async function action({ request, params }: ActionFunctionArgs) {return redirect(path.to.supplierProcesses(supplierId));}-export async function clientAction({- serverAction,- params-}: ClientActionFunctionArgs) {- const { id } = params;- if (id) {- const serviceRole = getCarbonServiceRole();- const supplierProcessId = await getSupplierProcessById(serviceRole, id);- if (supplierProcessId.data?.processId) {- window.clientCache?.setQueryData(- supplierProcessesQuery(supplierProcessId.data.processId).queryKey,- null- );- }- }+export async function clientAction({ serverAction }: ClientActionFunctionArgs) {+ window.clientCache?.invalidateQueries({+ queryKey: ["supplierProcesses"]+ });return await serverAction();}diff --git a/apps/erp/app/routes/x+/supplier+/$supplierId.tsx b/apps/erp/app/routes/x+/supplier+/$supplierId.tsxindex 9052cd1617..eb07e88200 100644--- a/apps/erp/app/routes/x+/supplier+/$supplierId.tsx+++ b/apps/erp/app/routes/x+/supplier+/$supplierId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { LoaderFunctionArgs } from "react-router";import { Outlet, redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsxindex 4365a2bb8e..9776473db6 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.$lineId.details.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { JSONContent } from "@carbon/react";diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.convert.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.convert.tsxindex b1046e9824..b4b4098e82 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.convert.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.convert.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { redirect } from "react-router";diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.new.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.new.tsxindex 2579dc26e6..a910ff5c7b 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.new.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.new.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/supplier-quote+/$id.tsx b/apps/erp/app/routes/x+/supplier-quote+/$id.tsxindex 9b44fc2d13..d56a25aac2 100644--- a/apps/erp/app/routes/x+/supplier-quote+/$id.tsx+++ b/apps/erp/app/routes/x+/supplier-quote+/$id.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { VStack } from "@carbon/react";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/erp/app/routes/x+/users+/employees.$employeeId.tsx b/apps/erp/app/routes/x+/users+/employees.$employeeId.tsxindex 66ab124043..52df1b62bc 100644--- a/apps/erp/app/routes/x+/users+/employees.$employeeId.tsx+++ b/apps/erp/app/routes/x+/users+/employees.$employeeId.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound-} from "@carbon/auth";+import { assertIsPost, error, notFound } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { Json } from "@carbon/database";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/users+/resend-invite.tsx b/apps/erp/app/routes/x+/users+/resend-invite.tsxindex 80a2a5684e..35b0bed53a 100644--- a/apps/erp/app/routes/x+/users+/resend-invite.tsx+++ b/apps/erp/app/routes/x+/users+/resend-invite.tsx@@ -1,11 +1,6 @@-import {- error,- getAppUrl,- getCarbonServiceRole,- RESEND_DOMAIN,- success-} from "@carbon/auth";+import { error, getAppUrl, RESEND_DOMAIN, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { InviteEmail } from "@carbon/documents/email";import { validationError, validator } from "@carbon/form";diff --git a/apps/erp/app/routes/x+/users+/revoke-invite.tsx b/apps/erp/app/routes/x+/users+/revoke-invite.tsxindex 54a64fff10..a2f10ba5d1 100644--- a/apps/erp/app/routes/x+/users+/revoke-invite.tsx+++ b/apps/erp/app/routes/x+/users+/revoke-invite.tsx@@ -1,10 +1,6 @@-import {- CarbonEdition,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { CarbonEdition, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { deactivateUser } from "@carbon/auth/users.server";import { validationError, validator } from "@carbon/form";diff --git a/apps/mes/app/routes/_public+/callback.tsx b/apps/mes/app/routes/_public+/callback.tsxindex a3444ef775..3e5f296ebe 100644--- a/apps/mes/app/routes/_public+/callback.tsx+++ b/apps/mes/app/routes/_public+/callback.tsx@@ -3,10 +3,10 @@ import {CONTROLLED_ENVIRONMENT,callbackValidator,carbonClient,- error,- getCarbonServiceRole+ error} from "@carbon/auth";import { refreshAccessToken } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import {destroyAuthSession,diff --git a/apps/mes/app/routes/file+/preview+/$bucket.$.tsx b/apps/mes/app/routes/file+/preview+/$bucket.$.tsxindex fc0bf4071e..1ed1ea1cb5 100644--- a/apps/mes/app/routes/file+/preview+/$bucket.$.tsx+++ b/apps/mes/app/routes/file+/preview+/$bucket.$.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { LoaderFunctionArgs } from "react-router";const supportedFileTypes: Record<string, string> = {diff --git a/apps/mes/app/routes/x+/adjustment.tsx b/apps/mes/app/routes/x+/adjustment.tsxindex dcd0e45b83..18dc1a6bee 100644--- a/apps/mes/app/routes/x+/adjustment.tsx+++ b/apps/mes/app/routes/x+/adjustment.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";import {diff --git a/apps/mes/app/routes/x+/assigned.tsx b/apps/mes/app/routes/x+/assigned.tsxindex 04f92a94c7..54bc5055fd 100644--- a/apps/mes/app/routes/x+/assigned.tsx+++ b/apps/mes/app/routes/x+/assigned.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {Button,Heading,diff --git a/apps/mes/app/routes/x+/complete.tsx b/apps/mes/app/routes/x+/complete.tsxindex f2aec1439a..fadcb13936 100644--- a/apps/mes/app/routes/x+/complete.tsx+++ b/apps/mes/app/routes/x+/complete.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";diff --git a/apps/mes/app/routes/x+/dispatch.$dispatchId.add-and-issue.tsx b/apps/mes/app/routes/x+/dispatch.$dispatchId.add-and-issue.tsxindex f316c96e73..e0e2afc02a 100644--- a/apps/mes/app/routes/x+/dispatch.$dispatchId.add-and-issue.tsx+++ b/apps/mes/app/routes/x+/dispatch.$dispatchId.add-and-issue.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/dispatch.$dispatchId.item.tsx b/apps/mes/app/routes/x+/dispatch.$dispatchId.item.tsxindex cae7fb2c86..d59c3ecaaa 100644--- a/apps/mes/app/routes/x+/dispatch.$dispatchId.item.tsx+++ b/apps/mes/app/routes/x+/dispatch.$dispatchId.item.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/dispatch.new.tsx b/apps/mes/app/routes/x+/dispatch.new.tsxindex c9d51ea402..3e3d9d97f8 100644--- a/apps/mes/app/routes/x+/dispatch.new.tsx+++ b/apps/mes/app/routes/x+/dispatch.new.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { notifyTask } from "@carbon/jobs/trigger/notify";diff --git a/apps/mes/app/routes/x+/end.$operationId.tsx b/apps/mes/app/routes/x+/end.$operationId.tsxindex b476f6fdb5..094a943640 100644--- a/apps/mes/app/routes/x+/end.$operationId.tsx+++ b/apps/mes/app/routes/x+/end.$operationId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole, success } from "@carbon/auth";+import { error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { FunctionRegion } from "@supabase/supabase-js";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/entity+/$id.convert.tsx b/apps/mes/app/routes/x+/entity+/$id.convert.tsxindex 98a6ba15be..61d8c4c3c2 100644--- a/apps/mes/app/routes/x+/entity+/$id.convert.tsx+++ b/apps/mes/app/routes/x+/entity+/$id.convert.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/entity+/$materialId.$trackedEntityId.scrap.tsx b/apps/mes/app/routes/x+/entity+/$materialId.$trackedEntityId.scrap.tsxindex 65aecd443d..36715d93f5 100644--- a/apps/mes/app/routes/x+/entity+/$materialId.$trackedEntityId.scrap.tsx+++ b/apps/mes/app/routes/x+/entity+/$materialId.$trackedEntityId.scrap.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/feedback.tsx b/apps/mes/app/routes/x+/feedback.tsxindex 7d0410955f..a30215e128 100644--- a/apps/mes/app/routes/x+/feedback.tsx+++ b/apps/mes/app/routes/x+/feedback.tsx@@ -1,5 +1,6 @@-import { getCarbonServiceRole, SUPABASE_URL } from "@carbon/auth";+import { SUPABASE_URL } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import { getSlackClient } from "@carbon/lib/slack.server";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/finish.tsx b/apps/mes/app/routes/x+/finish.tsxindex f341bdade5..315f21f01a 100644--- a/apps/mes/app/routes/x+/finish.tsx+++ b/apps/mes/app/routes/x+/finish.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/issue-tracked-entity.tsx b/apps/mes/app/routes/x+/issue-tracked-entity.tsxindex c907bf57f4..7f4953ae27 100644--- a/apps/mes/app/routes/x+/issue-tracked-entity.tsx+++ b/apps/mes/app/routes/x+/issue-tracked-entity.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/issue.tsx b/apps/mes/app/routes/x+/issue.tsxindex 94a132043a..193f609683 100644--- a/apps/mes/app/routes/x+/issue.tsx+++ b/apps/mes/app/routes/x+/issue.tsx@@ -1,5 +1,6 @@-import { assertIsPost, error, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost, error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";diff --git a/apps/mes/app/routes/x+/maintenance-event.tsx b/apps/mes/app/routes/x+/maintenance-event.tsxindex ab7ad4f13b..2413242ec0 100644--- a/apps/mes/app/routes/x+/maintenance-event.tsx+++ b/apps/mes/app/routes/x+/maintenance-event.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { getLocalTimeZone, now } from "@internationalized/date";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/operation.$operationId.tsx b/apps/mes/app/routes/x+/operation.$operationId.tsxindex 3dd020fb4c..c7535f434a 100644--- a/apps/mes/app/routes/x+/operation.$operationId.tsx+++ b/apps/mes/app/routes/x+/operation.$operationId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { LoaderFunctionArgs } from "react-router";import { redirect, useLoaderData, useParams } from "react-router";diff --git a/apps/mes/app/routes/x+/operations.tsx b/apps/mes/app/routes/x+/operations.tsxindex d691865ebe..2fed3c7dde 100644--- a/apps/mes/app/routes/x+/operations.tsx+++ b/apps/mes/app/routes/x+/operations.tsx@@ -1,5 +1,6 @@-import { getCarbonServiceRole, useCarbon } from "@carbon/auth";+import { useCarbon } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {Button,ClientOnly,diff --git a/apps/mes/app/routes/x+/record.$id.delete.tsx b/apps/mes/app/routes/x+/record.$id.delete.tsxindex 5a9a3c4226..fe7c59c60c 100644--- a/apps/mes/app/routes/x+/record.$id.delete.tsx+++ b/apps/mes/app/routes/x+/record.$id.delete.tsx@@ -1,11 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- notFound,- success-} from "@carbon/auth";+import { assertIsPost, error, notFound, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/record.tsx b/apps/mes/app/routes/x+/record.tsxindex cbfe2cc636..c71c9bf495 100644--- a/apps/mes/app/routes/x+/record.tsx+++ b/apps/mes/app/routes/x+/record.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import type { ActionFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/scrap.tsx b/apps/mes/app/routes/x+/scrap.tsxindex e677c2871c..60b9dc4a0e 100644--- a/apps/mes/app/routes/x+/scrap.tsx+++ b/apps/mes/app/routes/x+/scrap.tsx@@ -1,10 +1,6 @@-import {- assertIsPost,- error,- getCarbonServiceRole,- success-} from "@carbon/auth";+import { assertIsPost, error, success } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { validationError, validator } from "@carbon/form";import { FunctionRegion } from "@supabase/supabase-js";diff --git a/apps/mes/app/routes/x+/start.$operationId.tsx b/apps/mes/app/routes/x+/start.$operationId.tsxindex 5882846cc3..c888560c3d 100644--- a/apps/mes/app/routes/x+/start.$operationId.tsx+++ b/apps/mes/app/routes/x+/start.$operationId.tsx@@ -1,5 +1,6 @@-import { error, getCarbonServiceRole } from "@carbon/auth";+import { error } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { flash } from "@carbon/auth/session.server";import { getLocalTimeZone, now } from "@internationalized/date";import type { LoaderFunctionArgs } from "react-router";diff --git a/apps/mes/app/routes/x+/steps.inspection.tsx b/apps/mes/app/routes/x+/steps.inspection.tsxindex 424d43b7ae..a2d02f3575 100644--- a/apps/mes/app/routes/x+/steps.inspection.tsx+++ b/apps/mes/app/routes/x+/steps.inspection.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/mes/app/routes/x+/suggestion.tsx b/apps/mes/app/routes/x+/suggestion.tsxindex be0bf3dbc4..8f873a0b32 100644--- a/apps/mes/app/routes/x+/suggestion.tsx+++ b/apps/mes/app/routes/x+/suggestion.tsx@@ -1,5 +1,5 @@-import { getCarbonServiceRole } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { validator } from "@carbon/form";import type { notifyTask } from "@carbon/jobs/trigger/notify";import { NotificationEvent } from "@carbon/notifications";diff --git a/apps/mes/app/routes/x+/unconsume.tsx b/apps/mes/app/routes/x+/unconsume.tsxindex a640bd9dcc..0be6e0d626 100644--- a/apps/mes/app/routes/x+/unconsume.tsx+++ b/apps/mes/app/routes/x+/unconsume.tsx@@ -1,5 +1,6 @@-import { assertIsPost, getCarbonServiceRole } from "@carbon/auth";+import { assertIsPost } from "@carbon/auth";import { requirePermissions } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { FunctionRegion } from "@supabase/supabase-js";import type { ActionFunctionArgs } from "react-router";import { data } from "react-router";diff --git a/apps/starter/app/routes/_public+/callback.tsx b/apps/starter/app/routes/_public+/callback.tsxindex be28e6c245..39b1432e50 100644--- a/apps/starter/app/routes/_public+/callback.tsx+++ b/apps/starter/app/routes/_public+/callback.tsx@@ -2,10 +2,10 @@ import {assertIsPost,callbackValidator,carbonClient,- error,- getCarbonServiceRole+ error} from "@carbon/auth";import { refreshAccessToken } from "@carbon/auth/auth.server";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { setCompanyId } from "@carbon/auth/company.server";import {destroyAuthSession,diff --git a/apps/starter/app/routes/_public+/health.tsx b/apps/starter/app/routes/_public+/health.tsxindex 0106517cf6..a18d48983c 100644--- a/apps/starter/app/routes/_public+/health.tsx+++ b/apps/starter/app/routes/_public+/health.tsx@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";export async function loader() {try {diff --git a/llm/tasks/todo.md b/llm/tasks/todo.mdindex 0328e4b8a2..ffe083b1e2 100644--- a/llm/tasks/todo.md+++ b/llm/tasks/todo.md@@ -1,5 +1,14 @@-# Task Plan+# Migrate getCarbonServiceRole imports-## Current Tasks+## Task+Update all imports of `getCarbonServiceRole` from `@carbon/auth` to `@carbon/auth/client.server`.++## Plan+- [x] Find all files importing getCarbonServiceRole from @carbon/auth (~142 files)+- [x] Write and run a migration script+- [x] Verify no remaining old imports+- [x] Clean up migration script## Review+- [x] No files still importing getCarbonServiceRole from @carbon/auth (source files)+- [x] Spot checked 4 files for correctness (solo import, mixed imports, multi-named exports)diff --git a/packages/auth/package.json b/packages/auth/package.jsonindex 1f4aa3269e..2433d0cb7e 100644--- a/packages/auth/package.json+++ b/packages/auth/package.json@@ -12,6 +12,7 @@"exports": {".": "./src/index.ts","./auth.server": "./src/services/auth.server.ts",+ "./client.server": "./src/lib/supabase/client.server.ts","./company.server": "./src/services/company.server.ts","./session.server": "./src/services/session.server.ts","./users.server": "./src/services/users.server.ts",diff --git a/packages/auth/src/lib/supabase/client.server.ts b/packages/auth/src/lib/supabase/client.server.tsnew file mode 100644index 0000000000..b42538f4aa--- /dev/null+++ b/packages/auth/src/lib/supabase/client.server.ts@@ -0,0 +1,8 @@+import type { Database } from "@carbon/database";+import type { SupabaseClient } from "@supabase/supabase-js";+import { SUPABASE_SERVICE_ROLE_KEY } from "../../config/env";+import { getCarbonClient } from "./client";++export const getCarbonServiceRole = (): SupabaseClient<Database> => {+ return getCarbonClient(SUPABASE_SERVICE_ROLE_KEY!);+};diff --git a/packages/auth/src/lib/supabase/client.ts b/packages/auth/src/lib/supabase/client.tsindex d7e285cc32..c99b964c56 100644--- a/packages/auth/src/lib/supabase/client.ts+++ b/packages/auth/src/lib/supabase/client.ts@@ -1,16 +1,11 @@import type { Database } from "@carbon/database";-import { isBrowser } from "@carbon/utils";import type { SupabaseClient } from "@supabase/supabase-js";import { createClient } from "@supabase/supabase-js";import type { MutableRefObject } from "react";import type { StoreApi } from "zustand";-import {- SUPABASE_ANON_KEY,- SUPABASE_SERVICE_ROLE_KEY,- SUPABASE_URL-} from "../../config/env";+import { SUPABASE_ANON_KEY, SUPABASE_URL } from "../../config/env";-const getCarbonClient = (+export const getCarbonClient = (supabaseKey: string,accessToken?: string): SupabaseClient<Database, "public"> => {@@ -24,7 +19,7 @@ const getCarbonClient = (}: {};- const client = createClient<Database, "public">(SUPABASE_URL, supabaseKey, {+ const client = createClient<Database, "public">(SUPABASE_URL!, supabaseKey, {auth: {autoRefreshToken: false,persistSession: false@@ -37,8 +32,8 @@ const getCarbonClient = (export const getCarbonAPIKeyClient = (apiKey: string) => {const client = createClient<Database, "public">(- SUPABASE_URL,- SUPABASE_ANON_KEY,+ SUPABASE_URL!,+ SUPABASE_ANON_KEY!,{global: {headers: {@@ -54,13 +49,13 @@ export const getCarbonAPIKeyClient = (apiKey: string) => {export const createCarbonWithAuthGetter = (store: MutableRefObject<StoreApi<{ accessToken: string }>>) => {- return createClient<Database, "public">(SUPABASE_URL, SUPABASE_ANON_KEY, {+ return createClient<Database, "public">(SUPABASE_URL!, SUPABASE_ANON_KEY!, {auth: {autoRefreshToken: false,persistSession: false},async accessToken() {- if (!store.current) return;+ if (!store.current) return null;const state = store.current.getState();return state.accessToken;}@@ -68,16 +63,7 @@ export const createCarbonWithAuthGetter = (};export const getCarbon = (accessToken?: string) => {- return getCarbonClient(SUPABASE_ANON_KEY, accessToken);-};--export const getCarbonServiceRole = (): SupabaseClient<Database> => {- if (isBrowser)- throw new Error(- "getCarbonServiceRole is not available in browser and should NOT be used in insecure environments"- );-- return getCarbonClient(SUPABASE_SERVICE_ROLE_KEY);+ return getCarbonClient(SUPABASE_ANON_KEY!, accessToken);};export const carbonClient = getCarbon();diff --git a/packages/auth/src/lib/supabase/index.ts b/packages/auth/src/lib/supabase/index.tsindex 1e61737de1..9a3560cbc9 100644--- a/packages/auth/src/lib/supabase/index.ts+++ b/packages/auth/src/lib/supabase/index.ts@@ -1,10 +1,4 @@-import { carbonClient, getCarbon, getCarbonServiceRole } from "./client";+import { carbonClient, getCarbon } from "./client";import { CarbonProvider, useCarbon } from "./provider";-export {- carbonClient,- CarbonProvider,- getCarbon,- getCarbonServiceRole,- useCarbon-};+export { carbonClient, CarbonProvider, getCarbon, useCarbon };diff --git a/packages/auth/src/services/auth.server.ts b/packages/auth/src/services/auth.server.tsindex 9c207ff2b8..20e99edc87 100644--- a/packages/auth/src/services/auth.server.ts+++ b/packages/auth/src/services/auth.server.ts@@ -7,8 +7,9 @@ import type {import { createHash } from "crypto";import { redirect } from "react-router";import { REFRESH_ACCESS_TOKEN_THRESHOLD, VERCEL_URL } from "../config/env";-import { getCarbon, getCarbonServiceRole } from "../lib/supabase";+import { getCarbon } from "../lib/supabase";import { getCarbonAPIKeyClient } from "../lib/supabase/client";+import { getCarbonServiceRole } from "../lib/supabase/client.server";import type { AuthSession } from "../types";import { path } from "../utils/path";import { error } from "../utils/result";diff --git a/packages/auth/src/services/users.server.ts b/packages/auth/src/services/users.server.tsindex e81beeb1cb..16b1070b86 100644--- a/packages/auth/src/services/users.server.ts+++ b/packages/auth/src/services/users.server.ts@@ -4,7 +4,7 @@ import { updateSubscriptionQuantityForCompany } from "@carbon/stripe/stripe.servimport { Edition } from "@carbon/utils";import type { SupabaseClient } from "@supabase/supabase-js";import { CarbonEdition } from "../config/env";-import { getCarbonServiceRole } from "../lib/supabase";+import { getCarbonServiceRole } from "../lib/supabase/client.server";import type { Permission, Result } from "../types";import { error, success } from "../utils/result";import {diff --git a/packages/ee/package.json b/packages/ee/package.jsonindex 1d26af8a2e..f3fb87f19c 100644--- a/packages/ee/package.json+++ b/packages/ee/package.json@@ -7,13 +7,17 @@"./accounting": "./src/accounting/index.ts","./exchange-rates.server": "./src/exchange-rates/exchange-rates.server.ts","./jira": "./src/jira/lib/index.ts",+ "./jira.server": "./src/jira/lib/index.server.ts","./linear": "./src/linear/lib/index.ts",+ "./linear.server": "./src/linear/lib/index.server.ts","./notifications": "./src/notifications/index.ts","./onshape": "./src/onshape/lib/index.ts","./paperless-parts": "./src/paperless-parts/lib/index.ts","./slack.server": "./src/slack.server.ts","./slack/messages": "./src/slack/lib/messages.ts",- "./xero": "./src/accounting/providers/xero.ts"+ "./hooks.server": "./src/hooks.server.ts",+ "./xero": "./src/accounting/providers/xero.ts",+ "./xero/hooks.server": "./src/xero/hooks.server.ts"},"jest": {"preset": "@carbon/jest/node"diff --git a/packages/ee/src/hooks.server.ts b/packages/ee/src/hooks.server.tsnew file mode 100644index 0000000000..29e1a152b7--- /dev/null+++ b/packages/ee/src/hooks.server.ts@@ -0,0 +1,36 @@+import { jiraHealthcheck } from "./jira/hooks.server";+import { linearHealthcheck } from "./linear/hooks.server";+import type { IntegrationServerHooks } from "./types";+import {+ xeroHealthcheck,+ xeroOnInstall,+ xeroOnUninstall+} from "./xero/hooks.server";++/**+ * Server-side hooks registry for integrations.+ *+ * Hooks that depend on server-only modules (like getCarbonServiceRole)+ * cannot live in the integration config files because those are bundled+ * for both client and server. This registry maps integration IDs to+ * their server-only lifecycle hooks.+ */+const serverHooks: Record<string, IntegrationServerHooks> = {+ jira: {+ onHealthcheck: jiraHealthcheck+ },+ linear: {+ onHealthcheck: linearHealthcheck+ },+ xero: {+ onHealthcheck: xeroHealthcheck,+ onInstall: xeroOnInstall,+ onUninstall: xeroOnUninstall+ }+};++export function getIntegrationServerHooks(+ integrationId: string+): IntegrationServerHooks | undefined {+ return serverHooks[integrationId];+}diff --git a/packages/ee/src/jira/config.tsx b/packages/ee/src/jira/config.tsxindex a477a659bb..d008379990 100644--- a/packages/ee/src/jira/config.tsx+++ b/packages/ee/src/jira/config.tsx@@ -4,7 +4,6 @@ import { isBrowser } from "@carbon/utils";import type { SVGProps } from "react";import { z } from "zod";import { defineIntegration } from "../fns";-import { getJiraClient } from "./lib";export const Jira = defineIntegration({name: "Jira",@@ -30,7 +29,6 @@ export const Jira = defineIntegration({],tokenUrl: "https://auth.atlassian.com/oauth/token"},- onHealthcheck: healthcheck,schema: z.object({})});@@ -79,8 +77,3 @@ export function Logo(props: SVGProps<SVGSVGElement>) {</svg>);}--async function healthcheck(companyId: string, _: Record<string, unknown>) {- const jira = getJiraClient();- return await jira.healthcheck(companyId);-}diff --git a/packages/ee/src/jira/hooks.server.ts b/packages/ee/src/jira/hooks.server.tsnew file mode 100644index 0000000000..79925dc847--- /dev/null+++ b/packages/ee/src/jira/hooks.server.ts@@ -0,0 +1,9 @@+import { getJiraClient } from "./lib/client";++export async function jiraHealthcheck(+ companyId: string,+ _: Record<string, unknown>+) {+ const jira = getJiraClient();+ return await jira.healthcheck(companyId);+}diff --git a/packages/ee/src/jira/lib/client.ts b/packages/ee/src/jira/lib/client.tsindex 99792727c7..3bb2150466 100644--- a/packages/ee/src/jira/lib/client.ts+++ b/packages/ee/src/jira/lib/client.ts@@ -1,8 +1,5 @@-import {- getCarbonServiceRole,- JIRA_CLIENT_ID,- JIRA_CLIENT_SECRET-} from "@carbon/auth";+import { JIRA_CLIENT_ID, JIRA_CLIENT_SECRET } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { getJiraIntegration, updateJiraCredentials } from "./service";import type {CreateJiraIssueInput,diff --git a/packages/ee/src/jira/lib/index.server.ts b/packages/ee/src/jira/lib/index.server.tsnew file mode 100644index 0000000000..fe4bbfd4b1--- /dev/null+++ b/packages/ee/src/jira/lib/index.server.ts@@ -0,0 +1,5 @@+export * from "./client";+export * from "./richtext";+export * from "./service";+export * from "./types";+export * from "./utils";diff --git a/packages/ee/src/jira/lib/index.ts b/packages/ee/src/jira/lib/index.tsindex fe4bbfd4b1..0ad3cb37aa 100644--- a/packages/ee/src/jira/lib/index.ts+++ b/packages/ee/src/jira/lib/index.ts@@ -1,5 +1,3 @@-export * from "./client";export * from "./richtext";-export * from "./service";export * from "./types";export * from "./utils";diff --git a/packages/ee/src/jira/lib/service.ts b/packages/ee/src/jira/lib/service.tsindex dc1ff68a80..80f7100140 100644--- a/packages/ee/src/jira/lib/service.ts+++ b/packages/ee/src/jira/lib/service.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import type { SupabaseClient } from "@supabase/supabase-js";import { adfToTiptap } from "./richtext";diff --git a/packages/ee/src/linear/config.tsx b/packages/ee/src/linear/config.tsxindex fe56a37270..21128f313c 100644--- a/packages/ee/src/linear/config.tsx+++ b/packages/ee/src/linear/config.tsx@@ -3,8 +3,6 @@ import { isBrowser } from "@carbon/utils";import type { SVGProps } from "react";import { z } from "zod";import { defineIntegration } from "../fns";-import { getLinearClient } from "./lib";-export const Linear = defineIntegration({name: "Linear",id: "linear",@@ -25,7 +23,6 @@ export const Linear = defineIntegration({value: ""}],- onHealthcheck: healthcheck,schema: z.object({apiKey: z.string()@@ -87,9 +84,3 @@ export function Logo(props: SVGProps<SVGSVGElement>) {</svg>);}--async function healthcheck(companyId: string, _: Record<string, unknown>) {- const linear = getLinearClient();-- return await linear.healthcheck(companyId);-}diff --git a/packages/ee/src/linear/hooks.server.ts b/packages/ee/src/linear/hooks.server.tsnew file mode 100644index 0000000000..ff7c40d373--- /dev/null+++ b/packages/ee/src/linear/hooks.server.ts@@ -0,0 +1,9 @@+import { getLinearClient } from "./lib/client";++export async function linearHealthcheck(+ companyId: string,+ _: Record<string, unknown>+) {+ const linear = getLinearClient();+ return await linear.healthcheck(companyId);+}diff --git a/packages/ee/src/linear/lib/client.ts b/packages/ee/src/linear/lib/client.tsindex e7fcee5309..4cb91a20ac 100644--- a/packages/ee/src/linear/lib/client.ts+++ b/packages/ee/src/linear/lib/client.ts@@ -1,22 +1,8 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import axios, { type AxiosInstance } from "axios";-import type z from "zod";-import type { LinearIssueSchema } from "./service";import { getLinearIntegration } from "./service";+import type { LinearIssue, LinearTeam, LinearUser } from "./types";import type { LinearWorkStateType } from "./utils";--export type LinearIssue = z.infer<typeof LinearIssueSchema>;--export interface LinearTeam {- id: string;- name: string;-}--export interface LinearUser {- id: string;- email: string;- name: string;-}export class LinearClient {instance: AxiosInstance;diff --git a/packages/ee/src/linear/lib/index.server.ts b/packages/ee/src/linear/lib/index.server.tsnew file mode 100644index 0000000000..fe4bbfd4b1--- /dev/null+++ b/packages/ee/src/linear/lib/index.server.ts@@ -0,0 +1,5 @@+export * from "./client";+export * from "./richtext";+export * from "./service";+export * from "./types";+export * from "./utils";diff --git a/packages/ee/src/linear/lib/index.ts b/packages/ee/src/linear/lib/index.tsindex 7e92f9ddc4..0ad3cb37aa 100644--- a/packages/ee/src/linear/lib/index.ts+++ b/packages/ee/src/linear/lib/index.ts@@ -1,4 +1,3 @@-export * from "./client";export * from "./richtext";-export * from "./service";+export * from "./types";export * from "./utils";diff --git a/packages/ee/src/linear/lib/service.ts b/packages/ee/src/linear/lib/service.tsindex b9351489b1..dc596ea54c 100644--- a/packages/ee/src/linear/lib/service.ts+++ b/packages/ee/src/linear/lib/service.ts@@ -1,28 +1,9 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import type { SupabaseClient } from "@supabase/supabase-js";-import { z } from "zod";import { markdownToTiptap } from "./richtext";-import { LinearWorkStateType, mapLinearStatusToCarbonStatus } from "./utils";--export const LinearIssueSchema = z.object({- id: z.string(),- title: z.string(),- description: z.string().nullish(),- url: z.string(),- state: z.object({- name: z.string(),- color: z.string(),- type: z.nativeEnum(LinearWorkStateType)- }),- identifier: z.string(),- dueDate: z.string().nullish(),- assignee: z- .object({- email: z.string()- })- .nullish()-});+import { LinearIssueSchema } from "./types";+import { mapLinearStatusToCarbonStatus } from "./utils";export async function getLinearIntegration(client: SupabaseClient<Database>,diff --git a/packages/ee/src/linear/lib/types.ts b/packages/ee/src/linear/lib/types.tsnew file mode 100644index 0000000000..5e71fd0c37--- /dev/null+++ b/packages/ee/src/linear/lib/types.ts@@ -0,0 +1,34 @@+import { z } from "zod";+import { LinearWorkStateType } from "./utils";++export const LinearIssueSchema = z.object({+ id: z.string(),+ title: z.string(),+ description: z.string().nullish(),+ url: z.string(),+ state: z.object({+ name: z.string(),+ color: z.string(),+ type: z.nativeEnum(LinearWorkStateType)+ }),+ identifier: z.string(),+ dueDate: z.string().nullish(),+ assignee: z+ .object({+ email: z.string()+ })+ .nullish()+});++export type LinearIssue = z.infer<typeof LinearIssueSchema>;++export interface LinearTeam {+ id: string;+ name: string;+}++export interface LinearUser {+ id: string;+ email: string;+ name: string;+}diff --git a/packages/ee/src/notifications/services/jira.ts b/packages/ee/src/notifications/services/jira.tsindex 206765bd14..b446ef0cd3 100644--- a/packages/ee/src/notifications/services/jira.ts+++ b/packages/ee/src/notifications/services/jira.ts@@ -6,7 +6,7 @@ import {getJiraIssueFromExternalId,mapCarbonStatusToJiraCategory,tiptapToAdf-} from "../../jira/lib";+} from "../../jira/lib/index.server";import type { TiptapDocument } from "../../jira/lib/richtext";import type { NotificationEvent, NotificationService } from "../types";diff --git a/packages/ee/src/notifications/services/linear.ts b/packages/ee/src/notifications/services/linear.tsindex 14eb812624..a72cdc44b9 100644--- a/packages/ee/src/notifications/services/linear.ts+++ b/packages/ee/src/notifications/services/linear.ts@@ -1,13 +1,13 @@import { getUser } from "@carbon/auth";import type { Database } from "@carbon/database";import type { SupabaseClient } from "@supabase/supabase-js";-import type { TiptapDocument } from "../../linear/lib";+import type { TiptapDocument } from "../../linear/lib/index.server";import {getLinearClient,getLinearIssueFromExternalId,mapCarbonStatusToLinearStatus,tiptapToMarkdown-} from "../../linear/lib";+} from "../../linear/lib/index.server";import type { NotificationEvent, NotificationService } from "../types";const linear = getLinearClient();diff --git a/packages/ee/src/paperless-parts/lib/lib.ts b/packages/ee/src/paperless-parts/lib/lib.tsindex b61e98dcc7..df0308d2e3 100644--- a/packages/ee/src/paperless-parts/lib/lib.ts+++ b/packages/ee/src/paperless-parts/lib/lib.ts@@ -1,5 +1,5 @@import { openai } from "@ai-sdk/openai";-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import {getMaterialDescription,diff --git a/packages/ee/src/slack/lib/service.ts b/packages/ee/src/slack/lib/service.tsindex 25fe3b8da7..e0af645708 100644--- a/packages/ee/src/slack/lib/service.ts+++ b/packages/ee/src/slack/lib/service.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import type {slackDocumentAssignmentUpdate,diff --git a/packages/ee/src/xero/config.tsx b/packages/ee/src/xero/config.tsxindex e41a762018..8627046cf3 100644--- a/packages/ee/src/xero/config.tsx+++ b/packages/ee/src/xero/config.tsx@@ -1,14 +1,4 @@-import { getCarbonServiceRole, XERO_CLIENT_ID } from "@carbon/auth";-import type { CreateSubscriptionParams } from "@carbon/database/event";-import {- createEventSystemSubscription,- deleteEventSystemSubscriptionsByName-} from "@carbon/database/event";-import {- getProviderIntegration,- ProviderID,- type ProviderIntegrationMetadata-} from "@carbon/ee/accounting";+import { XERO_CLIENT_ID } from "@carbon/auth";import type { ComponentProps } from "react";import { z } from "zod";import { defineIntegration } from "../fns";@@ -226,50 +216,7 @@ export const Xero = defineIntegration({description: "Runs the initial backfill for the selected entities above",endpoint: "/api/integrations/xero/backfill"}- ],- async onHealthcheck(companyId, metadata) {- const provider = getProviderIntegration(- getCarbonServiceRole(),- companyId,- ProviderID.XERO,- metadata as ProviderIntegrationMetadata- );-- return await provider.validate();- },- async onInstall(companyId) {- const client = getCarbonServiceRole();-- const tables: CreateSubscriptionParams["table"][] = [- "address",- "customer",- "supplier",- "item",- "salesInvoice",- "purchaseInvoice",- "purchaseOrder",- "salesOrder"- ];-- for (const table of tables) {- await createEventSystemSubscription(client, {- table,- companyId,- name: "xero-sync",- operations: ["INSERT", "UPDATE", "DELETE"],- type: "SYNC",- config: {- provider: ProviderID.XERO- }- });- }- },- async onUninstall(companyId) {- const client = getCarbonServiceRole();-- // Delete all Xero sync subscriptions for this company- await deleteEventSystemSubscriptionsByName(client, companyId, "xero-sync");- }+ ]});function Logo(props: ComponentProps<"svg">) {diff --git a/packages/ee/src/xero/hooks.server.ts b/packages/ee/src/xero/hooks.server.tsnew file mode 100644index 0000000000..65699aa723--- /dev/null+++ b/packages/ee/src/xero/hooks.server.ts@@ -0,0 +1,58 @@+import { getCarbonServiceRole } from "@carbon/auth/client.server";+import type { CreateSubscriptionParams } from "@carbon/database/event";+import {+ createEventSystemSubscription,+ deleteEventSystemSubscriptionsByName+} from "@carbon/database/event";+import {+ getProviderIntegration,+ ProviderID,+ type ProviderIntegrationMetadata+} from "@carbon/ee/accounting";++export async function xeroHealthcheck(+ companyId: string,+ metadata: Record<string, unknown>+) {+ const provider = getProviderIntegration(+ getCarbonServiceRole(),+ companyId,+ ProviderID.XERO,+ metadata as ProviderIntegrationMetadata+ );++ return await provider.validate();+}++export async function xeroOnInstall(companyId: string) {+ const client = getCarbonServiceRole();++ const tables: CreateSubscriptionParams["table"][] = [+ "address",+ "customer",+ "supplier",+ "item",+ "salesInvoice",+ "purchaseInvoice",+ "purchaseOrder",+ "salesOrder"+ ];++ for (const table of tables) {+ await createEventSystemSubscription(client, {+ table,+ companyId,+ name: "xero-sync",+ operations: ["INSERT", "UPDATE", "DELETE"],+ type: "SYNC",+ config: {+ provider: ProviderID.XERO+ }+ });+ }+}++export async function xeroOnUninstall(companyId: string) {+ const client = getCarbonServiceRole();+ await deleteEventSystemSubscriptionsByName(client, companyId, "xero-sync");+}diff --git a/packages/jobs/trigger/accounting-backfill.ts b/packages/jobs/trigger/accounting-backfill.tsindex 87340de631..881f9bb22e 100644--- a/packages/jobs/trigger/accounting-backfill.ts+++ b/packages/jobs/trigger/accounting-backfill.ts@@ -9,7 +9,7 @@* This prevents unnecessary syncing (e.g., items configured as push-only* won't be pulled from Xero, and POs configured as push-only won't try to pull).*/-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {getPostgresClient,getPostgresConnectionPool,diff --git a/packages/jobs/trigger/audit-archive.ts b/packages/jobs/trigger/audit-archive.tsindex 99e65a6a33..342121807f 100644--- a/packages/jobs/trigger/audit-archive.ts+++ b/packages/jobs/trigger/audit-archive.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { auditConfig } from "@carbon/database/audit.config";import type { AuditLogEntry } from "@carbon/database/audit.types";import { logger, schedules } from "@trigger.dev/sdk/v3";@@ -45,6 +45,7 @@ export const auditLogArchiveTask = schedules.task({.select("id").eq("auditLogEnabled", true);+if (companiesError) {logger.error("Failed to fetch companies", { error: companiesError });throw new Error(`Failed to fetch companies: ${companiesError.message}`);diff --git a/packages/jobs/trigger/cleanup.ts b/packages/jobs/trigger/cleanup.tsindex aefd56db37..415dae9d3d 100644--- a/packages/jobs/trigger/cleanup.ts+++ b/packages/jobs/trigger/cleanup.ts@@ -1,4 +1,5 @@-import { getCarbonServiceRole, NOVU_API_URL, NOVU_SECRET_KEY } from "@carbon/auth";+import { NOVU_API_URL, NOVU_SECRET_KEY } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { TriggerPayload } from "@carbon/notifications";import {getSubscriberId,diff --git a/packages/jobs/trigger/dispatch.ts b/packages/jobs/trigger/dispatch.tsindex 161e6c4533..49c3c9e859 100644--- a/packages/jobs/trigger/dispatch.ts+++ b/packages/jobs/trigger/dispatch.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { NotificationEvent } from "@carbon/notifications";import { schedules } from "@trigger.dev/sdk";import { now, getLocalTimeZone } from "@internationalized/date";diff --git a/packages/jobs/trigger/event/audit.ts b/packages/jobs/trigger/event/audit.tsindex 2932d459d1..7eff882051 100644--- a/packages/jobs/trigger/event/audit.ts+++ b/packages/jobs/trigger/event/audit.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {auditConfig,getEntityConfigsForTable,diff --git a/packages/jobs/trigger/event/search.ts b/packages/jobs/trigger/event/search.tsindex 5e002470c8..c21287b9f9 100644--- a/packages/jobs/trigger/event/search.ts+++ b/packages/jobs/trigger/event/search.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { groupBy } from "@carbon/utils";import { logger, task } from "@trigger.dev/sdk/v3";import { z } from "zod";diff --git a/packages/jobs/trigger/event/sync.ts b/packages/jobs/trigger/event/sync.tsindex 807a0b1392..f071673a6a 100644--- a/packages/jobs/trigger/event/sync.ts+++ b/packages/jobs/trigger/event/sync.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {getPostgresClient,getPostgresConnectionPool,diff --git a/packages/jobs/trigger/jira.ts b/packages/jobs/trigger/jira.tsindex 53c5141add..1f4597f6eb 100644--- a/packages/jobs/trigger/jira.ts+++ b/packages/jobs/trigger/jira.ts@@ -1,9 +1,9 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {getCompanyEmployees,getJiraClient,linkActionToJiraIssue-} from "@carbon/ee/jira";+} from "@carbon/ee/jira.server";import { task } from "@trigger.dev/sdk";import { z } from "zod";diff --git a/packages/jobs/trigger/linear.ts b/packages/jobs/trigger/linear.tsindex 536ce82d87..283f36fd95 100644--- a/packages/jobs/trigger/linear.ts+++ b/packages/jobs/trigger/linear.ts@@ -1,9 +1,9 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {getCompanyEmployees,getLinearClient,linkActionToLinearIssue-} from "@carbon/ee/linear";+} from "@carbon/ee/linear.server";import { task } from "@trigger.dev/sdk";import { z } from "zod";diff --git a/packages/jobs/trigger/model-thumbnail.ts b/packages/jobs/trigger/model-thumbnail.tsindex db6ab2eee9..cdd43811c6 100644--- a/packages/jobs/trigger/model-thumbnail.ts+++ b/packages/jobs/trigger/model-thumbnail.ts@@ -1,9 +1,5 @@-import {- getCarbonServiceRole,- SUPABASE_ANON_KEY,- SUPABASE_URL,- VERCEL_URL,-} from "@carbon/auth";+import { SUPABASE_ANON_KEY, SUPABASE_URL, VERCEL_URL } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { task } from "@trigger.dev/sdk";diff --git a/packages/jobs/trigger/mrp.ts b/packages/jobs/trigger/mrp.tsindex e0daa4beb2..ecebf206b3 100644--- a/packages/jobs/trigger/mrp.ts+++ b/packages/jobs/trigger/mrp.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { schedules } from "@trigger.dev/sdk";const serviceRole = getCarbonServiceRole();diff --git a/packages/jobs/trigger/notify.ts b/packages/jobs/trigger/notify.tsindex 0a94a32f86..2b99382cd8 100644--- a/packages/jobs/trigger/notify.ts+++ b/packages/jobs/trigger/notify.ts@@ -1,10 +1,10 @@import {- getCarbonServiceRole,ERP_URL,NOVU_SECRET_KEY,VERCEL_URL,-NOVU_API_URL,+ NOVU_API_URL} from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { notifyTaskAssigned } from "@carbon/ee/notifications";import {diff --git a/packages/jobs/trigger/onboard.ts b/packages/jobs/trigger/onboard.tsindex 657ed7c656..1bc0e5febb 100644--- a/packages/jobs/trigger/onboard.ts+++ b/packages/jobs/trigger/onboard.ts@@ -1,5 +1,6 @@import { openai } from "@ai-sdk/openai";-import { getCarbonServiceRole, RESEND_DOMAIN } from "@carbon/auth";+import { RESEND_DOMAIN } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { GetStartedEmail, WelcomeEmail } from "@carbon/documents/email";import { resend, sendEmail } from "@carbon/lib/resend.server";diff --git a/packages/jobs/trigger/paperless-parts.ts b/packages/jobs/trigger/paperless-parts.tsindex f0d89cab47..b99c3c5d60 100644--- a/packages/jobs/trigger/paperless-parts.ts+++ b/packages/jobs/trigger/paperless-parts.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import {getCarbonOrderStatus,diff --git a/packages/jobs/trigger/post-transaction.ts b/packages/jobs/trigger/post-transaction.tsindex de7ea1804c..c7a12198c4 100644--- a/packages/jobs/trigger/post-transaction.ts+++ b/packages/jobs/trigger/post-transaction.ts@@ -1,7 +1,7 @@import { task } from "@trigger.dev/sdk";import { z } from "zod";-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";const serviceRole = getCarbonServiceRole();diff --git a/packages/jobs/trigger/recalculate.ts b/packages/jobs/trigger/recalculate.tsindex 72c6032850..a54ffd5bd9 100644--- a/packages/jobs/trigger/recalculate.ts+++ b/packages/jobs/trigger/recalculate.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { FunctionsResponse } from "@supabase/functions-js";import { FunctionRegion } from "@supabase/supabase-js";import { task } from "@trigger.dev/sdk";diff --git a/packages/jobs/trigger/reschedule-job.ts b/packages/jobs/trigger/reschedule-job.tsindex 3fe74be9ce..4dbf1b1969 100644--- a/packages/jobs/trigger/reschedule-job.ts+++ b/packages/jobs/trigger/reschedule-job.ts@@ -1,6 +1,6 @@+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { task } from "@trigger.dev/sdk";import { z } from "zod";-import { getCarbonServiceRole } from "@carbon/auth";const serviceRole = getCarbonServiceRole();diff --git a/packages/jobs/trigger/send-email-resend.ts b/packages/jobs/trigger/send-email-resend.tsindex 1cdeb872ab..b0efef14f5 100644--- a/packages/jobs/trigger/send-email-resend.ts+++ b/packages/jobs/trigger/send-email-resend.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { Resend as ResendConfig } from "@carbon/ee";import { task } from "@trigger.dev/sdk";import { Resend } from "resend";diff --git a/packages/jobs/trigger/slack-document-sync.ts b/packages/jobs/trigger/slack-document-sync.tsindex 08119e36b6..3126060d80 100644--- a/packages/jobs/trigger/slack-document-sync.ts+++ b/packages/jobs/trigger/slack-document-sync.ts@@ -1,4 +1,5 @@-import { getCarbonServiceRole, VERCEL_URL } from "@carbon/auth";+import { VERCEL_URL } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import {type DocumentType,diff --git a/packages/jobs/trigger/sync-external-accounting.ts b/packages/jobs/trigger/sync-external-accounting.tsindex 37eb7ef4bd..dd744c2e74 100644--- a/packages/jobs/trigger/sync-external-accounting.ts+++ b/packages/jobs/trigger/sync-external-accounting.ts@@ -13,7 +13,7 @@** Includes cooldown protection to prevent redundant syncs of the same entity.*/-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import {getPostgresClient,getPostgresConnectionPool,diff --git a/packages/jobs/trigger/timecard-auto-close.ts b/packages/jobs/trigger/timecard-auto-close.tsindex ba0c831eb0..a63209d694 100644--- a/packages/jobs/trigger/timecard-auto-close.ts+++ b/packages/jobs/trigger/timecard-auto-close.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { schedules } from "@trigger.dev/sdk";const serviceRole = getCarbonServiceRole();diff --git a/packages/jobs/trigger/update-exchange-rates.ts b/packages/jobs/trigger/update-exchange-rates.tsindex 02219ca995..76a4bb281b 100644--- a/packages/jobs/trigger/update-exchange-rates.ts+++ b/packages/jobs/trigger/update-exchange-rates.ts@@ -1,4 +1,5 @@-import { EXCHANGE_RATES_API_KEY, getCarbonServiceRole } from "@carbon/auth";+import { EXCHANGE_RATES_API_KEY } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Rates } from "@carbon/ee/exchange-rates.server";import { getExchangeRatesClient } from "@carbon/ee/exchange-rates.server";import { schedules } from "@trigger.dev/sdk";diff --git a/packages/jobs/trigger/update-permissions.ts b/packages/jobs/trigger/update-permissions.tsindex 4b59417787..f6189622a5 100644--- a/packages/jobs/trigger/update-permissions.ts+++ b/packages/jobs/trigger/update-permissions.ts@@ -4,11 +4,11 @@ import { z } from "zod";import type { Result } from "@carbon/auth";import {error,- getCarbonServiceRole,getClaims,getPermissionCacheKey,- success,+ success} from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { redis } from "@carbon/kv";import type { SupabaseClient } from "@supabase/supabase-js";diff --git a/packages/jobs/trigger/user-admin.ts b/packages/jobs/trigger/user-admin.tsindex 2db2d58be2..d75f541935 100644--- a/packages/jobs/trigger/user-admin.ts+++ b/packages/jobs/trigger/user-admin.ts@@ -2,12 +2,8 @@ import { task } from "@trigger.dev/sdk";import { z } from "zod";import type { Result } from "@carbon/auth";-import {- CarbonEdition,- getAppUrl,- getCarbonServiceRole,- RESEND_DOMAIN,-} from "@carbon/auth";+import { CarbonEdition, getAppUrl, RESEND_DOMAIN } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { deactivateUser } from "@carbon/auth/users.server";import { InviteEmail } from "@carbon/documents/email";import { sendEmail } from "@carbon/lib/resend.server";diff --git a/packages/jobs/trigger/weekly.ts b/packages/jobs/trigger/weekly.tsindex d622eecfc4..28f67c944f 100644--- a/packages/jobs/trigger/weekly.ts+++ b/packages/jobs/trigger/weekly.ts@@ -1,4 +1,4 @@-import { getCarbonServiceRole } from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import { NotificationEvent } from "@carbon/notifications";import { schedules } from "@trigger.dev/sdk";import { Edition } from "../../utils/src/types.ts";diff --git a/packages/stripe/src/stripe.server.ts b/packages/stripe/src/stripe.server.tsindex d315b7dd37..fa44fd7d31 100644--- a/packages/stripe/src/stripe.server.ts+++ b/packages/stripe/src/stripe.server.ts@@ -1,11 +1,11 @@import {CarbonEdition,getAppUrl,- getCarbonServiceRole,STRIPE_BYPASS_COMPANY_IDS,STRIPE_BYPASS_USER_IDS,STRIPE_SECRET_KEY} from "@carbon/auth";+import { getCarbonServiceRole } from "@carbon/auth/client.server";import type { Database } from "@carbon/database";import { redis } from "@carbon/kv";import { Edition, Plan } from "@carbon/utils";