Skip to content

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.

feat: add radan integration

Brad Barbin6d4f97c25cc9
diff --git a/apps/erp/app/modules/production/production.service.ts b/apps/erp/app/modules/production/production.service.ts
index a596cd703a..63b2fd1786 100644
--- a/apps/erp/app/modules/production/production.service.ts
+++ b/apps/erp/app/modules/production/production.service.ts
@@ -155,7 +155,12 @@ export async function deleteScrapReason(
export async function getJobDocuments(
client: SupabaseClient<Database>,
companyId: string,
- job: Job
+ job: {
+ id: string | null;
+ salesOrderLineId?: string | null;
+ quoteLineId?: string | null;
+ itemId?: string | null;
+ }
): Promise<StorageItem[]> {
const promises: Promise<
| {
@@ -199,6 +204,45 @@ export async function getJobDocuments(
];
}
+export async function getJobDocumentsWithItemId(
+ client: SupabaseClient<Database>,
+ companyId: string,
+ job: Job,
+ itemId: string
+): Promise<StorageItem[]> {
+ if (job.salesOrderLineId || job.quoteLineId) {
+ const opportunityLine = job.salesOrderLineId || job.quoteLineId;
+
+ const [opportunityLineFiles, jobFiles, itemFiles] = await Promise.all([
+ client.storage
+ .from("private")
+ .list(`${companyId}/opportunity-line/${opportunityLine}`),
+ client.storage.from("private").list(`${companyId}/job/${job.id}`),
+ client.storage.from("private").list(`${companyId}/parts/${itemId}`),
+ ]);
+
+ // Combine and return both sets of files
+ return [
+ ...(opportunityLineFiles.data?.map((f) => ({
+ ...f,
+ bucket: "opportunity-line",
+ })) || []),
+ ...(jobFiles.data?.map((f) => ({ ...f, bucket: "job" })) || []),
+ ...(itemFiles.data?.map((f) => ({ ...f, bucket: "parts" })) || []),
+ ];
+ } else {
+ const [jobFiles, itemFiles] = await Promise.all([
+ client.storage.from("private").list(`${companyId}/job/${job.id}`),
+ client.storage.from("private").list(`${companyId}/parts/${itemId}`),
+ ]);
+
+ return [
+ ...(jobFiles.data?.map((f) => ({ ...f, bucket: "job" })) || []),
+ ...(itemFiles.data?.map((f) => ({ ...f, bucket: "parts" })) || []),
+ ];
+ }
+}
+
export async function getJob(client: SupabaseClient<Database>, id: string) {
return client.from("jobs").select("*").eq("id", id).single();
}
diff --git a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
index 318d60e158..69538b4ccf 100644
--- a/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
+++ b/apps/erp/app/modules/settings/ui/Integrations/IntegrationForm.tsx
@@ -16,6 +16,7 @@ import {
} from "@carbon/react";
import { SUPPORT_EMAIL } from "@carbon/utils";
import { useParams } from "@remix-run/react";
+import { Processes } from "~/components/Form";
import { usePermissions, useUser } from "~/hooks";
import { path } from "~/utils/path";
@@ -122,6 +123,10 @@ export function IntegrationForm({
description={setting.label}
/>
);
+ case "processes":
+ return (
+ <Processes name={setting.name} label={setting.label} />
+ );
default:
return null;
}
diff --git a/apps/erp/app/routes/api+/integrations.radan.$version.ts b/apps/erp/app/routes/api+/integrations.radan.$version.ts
new file mode 100644
index 0000000000..bb5c5707dd
--- /dev/null
+++ b/apps/erp/app/routes/api+/integrations.radan.$version.ts
@@ -0,0 +1,91 @@
+import { getCarbonServiceRole } from "@carbon/auth";
+import { requirePermissions } from "@carbon/auth/auth.server";
+import type { LoaderFunctionArgs } from "@vercel/remix";
+import { json } from "@vercel/remix";
+import z from "zod";
+import { getJobDocuments } from "~/modules/production/production.service";
+import { getCompanyIntegration } from "~/modules/settings/settings.server";
+
+export const config = {
+ maxDuration: 300,
+ runtime: "nodejs",
+};
+
+const integrationMetadataParser = z.object({
+ processes: z.array(z.string()),
+});
+
+export async function loader({ request, params }: LoaderFunctionArgs) {
+ const { client, companyId } = await requirePermissions(request, {});
+
+ const integration = await getCompanyIntegration(client, companyId, "radan");
+ if (!integration) {
+ return json(
+ { success: false, error: "Integration not active" },
+ { status: 400 }
+ );
+ }
+
+ const metadata = integrationMetadataParser.safeParse(integration.metadata);
+ if (!metadata.success) {
+ return json({ success: false, error: "Invalid metadata" }, { status: 400 });
+ }
+
+ const { processes } = metadata.data;
+
+ if (!params.version) {
+ return json(
+ { success: false, error: "Version is required" },
+ { status: 400 }
+ );
+ }
+
+ if (params.version === "v1") {
+ const result = await client.rpc("get_radan_v1", {
+ company_id: companyId,
+ processes,
+ });
+
+ if (result.error) {
+ return json(
+ { success: false, error: result.error.message },
+ { status: 500 }
+ );
+ }
+
+ // Cache for job documents to avoid duplicate fetches
+ const jobDocumentsCache = new Map();
+ const serviceRole = getCarbonServiceRole();
+
+ // Enrich data with job documents
+ const enrichedData = await Promise.all(
+ result.data.map(async (item: any) => {
+ if (item.jobId) {
+ let documents;
+ if (jobDocumentsCache.has(item.jobId)) {
+ documents = jobDocumentsCache.get(item.jobId);
+ } else {
+ documents = await getJobDocuments(serviceRole, companyId, {
+ id: item.jobId,
+ salesOrderLineId: item.salesOrderLineId,
+ itemId: item.itemId,
+ });
+ jobDocumentsCache.set(item.jobId, documents);
+ }
+ return {
+ ...item,
+ documents,
+ };
+ }
+ return item;
+ })
+ );
+
+ return json({ success: true, data: enrichedData });
+ }
+
+ return json({
+ success: false,
+ error: `version ${params.version} is invalid`,
+ });
+}
diff --git a/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts b/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts
deleted file mode 100644
index 2119323540..0000000000
--- a/apps/erp/app/routes/api+/integrations.radan.$version[.]csv.ts
+++ /dev/null
@@ -1,37 +0,0 @@
-import { getCarbonServiceRole } from "@carbon/auth";
-import { requirePermissions } from "@carbon/auth/auth.server";
-import type { LoaderFunctionArgs } from "@vercel/remix";
-import { json } from "@vercel/remix";
-
-export async function loader({ request, params }: LoaderFunctionArgs) {
- const { companyId } = await requirePermissions(request, {});
-
- const serviceRole = getCarbonServiceRole();
-
- if (!params.version) {
- return json(
- { success: false, error: "Version is required" },
- { status: 400 }
- );
- }
-
- if (params.version === "v1") {
- const result = await serviceRole.rpc("radan_v1", {
- company_id: companyId,
- });
-
- if (result.error) {
- return json(
- { success: false, error: result.error.message },
- { status: 500 }
- );
- }
-
- return json({ success: true, data: result.data });
- }
-
- return json({
- success: false,
- error: `version ${params.version} is invalid`,
- });
-}
diff --git a/docs/integrations/radan.md b/docs/integrations/radan.md
new file mode 100644
index 0000000000..d88cce2043
--- /dev/null
+++ b/docs/integrations/radan.md
@@ -0,0 +1,121 @@
+# Radan Integration
+
+> **⚠️ Work in Progress**
+>
+> This integration is currently under development and may not be fully functional. Please check back later for updates.
+
+## Setup
+
+The integration involved two parts.
+
+1. Enabling the integration in Carbon
+2. Generating an API Key for the Radan client
+
+### Enabling the integration in Carbon
+
+1. In Carbon, navigate to Settings > Integrations
+2. Install the Radan integration
+3. Select the relevant processes (e.g. Laser, Plasma)
+
+### Generating an API Key for the Radan client
+
+1. In Carbon, navigate to Settings > API Key
+2. Generate a new API Key and save it.
+
+## Using the API
+
+Now you can fetch data for the integration using your API key:
+
+```bash
+curl 'https://app.carbon.ms/api/integrations/radan/v1' \
+-H "carbon-key: <your-api-key>"
+```
+
+Here's what an error looks like:
+
+```json
+{
+ "success": false,
+ "error": "Integration not active"
+}
+```
+
+And here's what a success looks like:
+
+> **⚠️ Heads Up!**
+>
+> There is mechanism in Carbon to determine which file is relevant for nesting so we must send them all (in the documents array)
+
+```json
+{
+ "success": true,
+ "data": [
+ {
+ "id": "pjSnUdrsFZmWDbCN1hvi2",
+ "assignee": null,
+ "description": "Laser",
+ "documents": [
+ {
+ "name": "X32329302.dxf",
+ "id": "d44c320d-b792-49da-b0fc-954cd09ed044",
+ "updated_at": "2025-09-02T12:39:03.795Z",
+ "created_at": "2025-09-02T12:39:03.795Z",
+ "last_accessed_at": "2025-09-02T12:39:03.795Z",
+ "metadata": {
+ "eTag": "\"8cddafa69a599294d7edd2ab359bc4ec\"",
+ "size": 28450,
+ "mimetype": "application/dxf",
+ "cacheControl": "max-age=43200",
+ "lastModified": "2025-09-02T12:39:03.788Z",
+ "contentLength": 28450,
+ "httpStatusCode": 200
+ },
+ "bucket": "parts"
+ }
+ ],
+ "itemDescription": "X32329302",
+ "itemId": "item_L2Pou8zCzNtZRzb9uyNMSD",
+ "itemReadableId": "X32329302",
+ "jobCustomerId": "cust_YVLo9Pkj2M9nShpwu5Ezaq",
+ "jobDeadlineType": "Hard Deadline",
+ "jobDueDate": "2025-05-15",
+ "jobId": "job_PVuhmo2W16NBy2Zsn9Dpy5",
+ "jobLocationName": "Headquarters",
+ "jobMakeMethodId": "jmm_S6DhS6kyTqbEoLyAXBthHs",
+ "jobReadableId": "J000001",
+ "jobStatus": "Ready",
+ "laborTime": 0,
+ "laborUnit": "Minutes/Piece",
+ "machineTime": 2,
+ "machineUnit": "Minutes/Piece",
+ "materialDimension": "1/4\"",
+ "materialFinish": null,
+ "materialForm": "Plate",
+ "materialGrade": "A36",
+ "materialItemDescription": "A36 Steel Plate 1/4\"",
+ "materialItemReadableId": "A36-STEEL-PLT-1/4\"",
+ "materialSubstance": "Steel",
+ "operationOrder": 1,
+ "operationOrderType": "After Previous",
+ "operationQuantity": 20,
+ "operationStatus": "Ready",
+ "parentMaterialId": null,
+ "priority": 1,
+ "processId": "pr_D1sq4wcav2cixyzf7C9Xci",
+ "quantityComplete": 0,
+ "quantityScrapped": 0,
+ "salesOrderId": "so_EjraNLcHiMNM7NzR9enVSC",
+ "salesOrderLineId": "8U5bd4Hzzvxp59jkYjj64e",
+ "salesOrderReadableId": "SO000001",
+ "setupTime": 20,
+ "setupUnit": "Total Minutes",
+ "tags": [],
+ "workCenterId": null
+ }
+ ]
+}
+```
+
+## Webhook
+
+A webhook will be implemented for the data to be returned that uses the same auth mechanism, but this will be determined at a later date.
diff --git a/packages/database/src/types.ts b/packages/database/src/types.ts
index 939d515d7f..2af9b67642 100644
--- a/packages/database/src/types.ts
+++ b/packages/database/src/types.ts
@@ -43526,14 +43526,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -47232,6 +47232,54 @@ export type Database = {
version: number
}[]
}
+ get_radan_v1: {
+ Args: {
+ company_id: string
+ processes: string[]
+ }
+ Returns: {
+ id: string
+ jobId: string
+ operationOrder: number
+ priority: number
+ processId: string
+ workCenterId: string
+ description: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
+ operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
+ jobMakeMethodId: string
+ assignee: string
+ tags: string[]
+ jobReadableId: string
+ jobStatus: Database["public"]["Enums"]["jobStatus"]
+ jobDueDate: string
+ jobDeadlineType: Database["public"]["Enums"]["deadlineType"]
+ jobCustomerId: string
+ jobLocationName: string
+ salesOrderReadableId: string
+ salesOrderId: string
+ salesOrderLineId: string
+ parentMaterialId: string
+ itemReadableId: string
+ itemDescription: string
+ operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
+ operationQuantity: number
+ quantityComplete: number
+ quantityScrapped: number
+ materialItemReadableId: string
+ materialItemDescription: string
+ materialSubstance: string
+ materialForm: string
+ materialDimension: string
+ materialFinish: string
+ materialGrade: string
+ }[]
+ }
get_recent_job_operations_by_employee: {
Args: {
employee_id: string
@@ -47487,6 +47535,54 @@ export type Database = {
}
Returns: string
}
+ radan_v1: {
+ Args: {
+ company_id: string
+ processes: string[]
+ }
+ Returns: {
+ id: string
+ jobId: string
+ operationOrder: number
+ priority: number
+ processId: string
+ workCenterId: string
+ description: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
+ operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
+ jobMakeMethodId: string
+ assignee: string
+ tags: string[]
+ jobReadableId: string
+ jobStatus: Database["public"]["Enums"]["jobStatus"]
+ jobDueDate: string
+ jobDeadlineType: Database["public"]["Enums"]["deadlineType"]
+ jobCustomerId: string
+ jobLocationName: string
+ salesOrderReadableId: string
+ salesOrderId: string
+ salesOrderLineId: string
+ parentMaterialId: string
+ itemReadableId: string
+ itemDescription: string
+ operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
+ operationQuantity: number
+ quantityComplete: number
+ quantityScrapped: number
+ materialItemReadableId: string
+ materialItemDescription: string
+ materialSubstance: string
+ materialForm: string
+ materialDimension: string
+ materialFinish: string
+ materialGrade: string
+ }[]
+ }
suppliers_search: {
Args: {
query_embedding: string
diff --git a/packages/database/supabase/functions/lib/types.ts b/packages/database/supabase/functions/lib/types.ts
index 939d515d7f..2af9b67642 100644
--- a/packages/database/supabase/functions/lib/types.ts
+++ b/packages/database/supabase/functions/lib/types.ts
@@ -43526,14 +43526,14 @@ export type Database = {
Relationships: [
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["invoiceCountryCode"]
+ columns: ["customerCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
},
{
foreignKeyName: "address_countryCode_fkey"
- columns: ["customerCountryCode"]
+ columns: ["invoiceCountryCode"]
isOneToOne: false
referencedRelation: "country"
referencedColumns: ["alpha2"]
@@ -47232,6 +47232,54 @@ export type Database = {
version: number
}[]
}
+ get_radan_v1: {
+ Args: {
+ company_id: string
+ processes: string[]
+ }
+ Returns: {
+ id: string
+ jobId: string
+ operationOrder: number
+ priority: number
+ processId: string
+ workCenterId: string
+ description: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
+ operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
+ jobMakeMethodId: string
+ assignee: string
+ tags: string[]
+ jobReadableId: string
+ jobStatus: Database["public"]["Enums"]["jobStatus"]
+ jobDueDate: string
+ jobDeadlineType: Database["public"]["Enums"]["deadlineType"]
+ jobCustomerId: string
+ jobLocationName: string
+ salesOrderReadableId: string
+ salesOrderId: string
+ salesOrderLineId: string
+ parentMaterialId: string
+ itemReadableId: string
+ itemDescription: string
+ operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
+ operationQuantity: number
+ quantityComplete: number
+ quantityScrapped: number
+ materialItemReadableId: string
+ materialItemDescription: string
+ materialSubstance: string
+ materialForm: string
+ materialDimension: string
+ materialFinish: string
+ materialGrade: string
+ }[]
+ }
get_recent_job_operations_by_employee: {
Args: {
employee_id: string
@@ -47487,6 +47535,54 @@ export type Database = {
}
Returns: string
}
+ radan_v1: {
+ Args: {
+ company_id: string
+ processes: string[]
+ }
+ Returns: {
+ id: string
+ jobId: string
+ operationOrder: number
+ priority: number
+ processId: string
+ workCenterId: string
+ description: string
+ setupTime: number
+ setupUnit: Database["public"]["Enums"]["factor"]
+ laborTime: number
+ laborUnit: Database["public"]["Enums"]["factor"]
+ machineTime: number
+ machineUnit: Database["public"]["Enums"]["factor"]
+ operationOrderType: Database["public"]["Enums"]["methodOperationOrder"]
+ jobMakeMethodId: string
+ assignee: string
+ tags: string[]
+ jobReadableId: string
+ jobStatus: Database["public"]["Enums"]["jobStatus"]
+ jobDueDate: string
+ jobDeadlineType: Database["public"]["Enums"]["deadlineType"]
+ jobCustomerId: string
+ jobLocationName: string
+ salesOrderReadableId: string
+ salesOrderId: string
+ salesOrderLineId: string
+ parentMaterialId: string
+ itemReadableId: string
+ itemDescription: string
+ operationStatus: Database["public"]["Enums"]["jobOperationStatus"]
+ operationQuantity: number
+ quantityComplete: number
+ quantityScrapped: number
+ materialItemReadableId: string
+ materialItemDescription: string
+ materialSubstance: string
+ materialForm: string
+ materialDimension: string
+ materialFinish: string
+ materialGrade: string
+ }[]
+ }
suppliers_search: {
Args: {
query_embedding: string
diff --git a/packages/database/supabase/migrations/20250827201650_radan-v1.sql b/packages/database/supabase/migrations/20250827201650_radan-v1.sql
index e69de29bb2..95d248a258 100644
--- a/packages/database/supabase/migrations/20250827201650_radan-v1.sql
+++ b/packages/database/supabase/migrations/20250827201650_radan-v1.sql
@@ -0,0 +1,289 @@
+INSERT INTO "integration" ("id", "jsonschema")
+VALUES
+ ('radan', '{"type": "object", "properties": {"processes": {"type": "array", "items": {"type": "string"}}}}'::json);
+
+DROP FUNCTION IF EXISTS get_radan_v1;
+CREATE OR REPLACE FUNCTION get_radan_v1(
+ company_id TEXT,
+ processes TEXT[]
+)
+RETURNS TABLE (
+ "id" TEXT,
+ "jobId" TEXT,
+ "operationOrder" DOUBLE PRECISION,
+ "priority" DOUBLE PRECISION,
+ "processId" TEXT,
+ "workCenterId" TEXT,
+ "description" TEXT,
+ "setupTime" NUMERIC,
+ "setupUnit" factor,
+ "laborTime" NUMERIC,
+ "laborUnit" factor,
+ "machineTime" NUMERIC,
+ "machineUnit" factor,
+ "operationOrderType" "methodOperationOrder",
+ "jobMakeMethodId" TEXT,
+ "assignee" TEXT,
+ "tags" TEXT[],
+ "jobReadableId" TEXT,
+ "jobStatus" "jobStatus",
+ "jobDueDate" DATE,
+ "jobDeadlineType" "deadlineType",
+ "jobCustomerId" TEXT,
+ "jobLocationName" TEXT,
+ "salesOrderReadableId" TEXT,
+ "salesOrderId" TEXT,
+ "salesOrderLineId" TEXT,
+ "parentMaterialId" TEXT,
+ "itemId" TEXT,
+ "itemReadableId" TEXT,
+ "itemDescription" TEXT,
+ "operationStatus" "jobOperationStatus",
+ "operationQuantity" NUMERIC,
+ "quantityComplete" NUMERIC,
+ "quantityScrapped" NUMERIC,
+ "materialItemReadableId" TEXT,
+ "materialItemDescription" TEXT,
+ "materialSubstance" TEXT,
+ "materialForm" TEXT,
+ "materialDimension" TEXT,
+ "materialFinish" TEXT,
+ "materialGrade" TEXT
+)
+SECURITY INVOKER
+AS $$
+BEGIN
+ RETURN QUERY
+ WITH relevant_jobs AS (
+ SELECT
+ j."id",
+ j."jobId",
+ j."status",
+ j."dueDate",
+ j."deadlineType",
+ j."customerId",
+ l."name" AS "locationName",
+ so."salesOrderId" AS "salesOrderReadableId",
+ so."id" AS "salesOrderId",
+ j."salesOrderLineId"
+
+ FROM "job" j
+ LEFT JOIN "salesOrderLine" sol ON sol."id" = j."salesOrderLineId"
+ LEFT JOIN "salesOrder" so ON so."id" = sol."salesOrderId"
+ LEFT JOIN "location" l ON l."id" = j."locationId"
+ WHERE l."companyId" = company_id
+ AND (j."status" = 'Ready' OR j."status" = 'In Progress' OR j."status" = 'Paused')
+ )
+ SELECT
+ jo."id",
+ jo."jobId",
+ jo."order" AS "operationOrder",
+ jo."priority",
+ jo."processId",
+ jo."workCenterId",
+ jo."description",
+ jo."setupTime",
+ jo."setupUnit",
+ jo."laborTime",
+ jo."laborUnit",
+ jo."machineTime",
+ jo."machineUnit",
+ jo."operationOrder" AS "operationOrderType",
+ jo."jobMakeMethodId",
+ jo."assignee",
+ jo."tags",
+ rj."jobId" AS "jobReadableId",
+ rj."status" AS "jobStatus",
+ rj."dueDate" AS "jobDueDate",
+ rj."deadlineType" AS "jobDeadlineType",
+ rj."customerId" AS "jobCustomerId",
+ rj."locationName" AS "jobLocationName",
+ rj."salesOrderReadableId",
+ rj."salesOrderId",
+ rj."salesOrderLineId",
+ jmm."parentMaterialId",
+ i."id" AS "itemId",
+ i."readableId" as "itemReadableId",
+ i."name" as "itemDescription",
+ CASE
+ WHEN rj."status" = 'Paused' THEN 'Paused'::"jobOperationStatus"
+ ELSE jo."status"
+ END AS "operationStatus",
+ jo."operationQuantity",
+ jo."quantityComplete",
+ jo."quantityScrapped",
+ fm."materialItemReadableId" as "materialItemReadableId",
+ fm."materialItemDescription" as "materialItemDescription",
+ fm."materialSubstance" as "materialSubstance",
+ fm."materialForm" as "materialForm",
+ fm."materialDimension" as "materialDimension",
+ fm."materialFinish" as "materialFinish",
+ fm."materialGrade" as "materialGrade"
+ FROM "jobOperation" jo
+ JOIN relevant_jobs rj ON rj.id = jo."jobId"
+ LEFT JOIN "jobMakeMethod" jmm ON jo."jobMakeMethodId" = jmm.id
+ LEFT JOIN (
+ SELECT
+ jm."jobMakeMethodId",
+ jm."itemId" AS "materialItemId",
+ mi."readableId" AS "materialItemReadableId",
+ mi."name" AS "materialItemDescription",
+ ms."name" AS "materialSubstance",
+ mf."name" AS "materialForm",
+ md."name" AS "materialDimension",
+ mf2."name" AS "materialFinish",
+ mg."name" AS "materialGrade"
+ FROM (
+ SELECT DISTINCT ON (jm."jobMakeMethodId")
+ jm."jobMakeMethodId",
+ jm."itemId",
+ jm."id"
+ FROM "jobMaterial" jm
+ WHERE jm."itemType" = 'Material'
+ AND jm."jobMakeMethodId" IN (
+ SELECT DISTINCT jo."jobMakeMethodId"
+ FROM "jobOperation" jo
+ JOIN relevant_jobs rj ON rj.id = jo."jobId"
+ WHERE jo."status" != 'Done'
+ AND jo."status" != 'Canceled'
+ AND CASE
+ WHEN array_length(processes, 1) > 0 THEN
+ jo."processId" = ANY(processes)
+ ELSE true
+ END
+ )
+ ORDER BY jm."jobMakeMethodId", jm."order" DESC
+ LIMIT 1
+ ) jm
+ INNER JOIN "item" mi ON mi."id" = jm."itemId"
+ LEFT JOIN "material" m ON m."id" = mi."readableId"
+ LEFT JOIN "materialSubstance" ms ON ms."id" = m."materialSubstanceId"
+ LEFT JOIN "materialForm" mf ON mf."id" = m."materialFormId"
+ LEFT JOIN "materialDimension" md ON md."id" = m."dimensionId"
+ LEFT JOIN "materialFinish" mf2 ON mf2."id" = m."finishId"
+ LEFT JOIN "materialGrade" mg ON mg."id" = m."gradeId"
+ ) fm ON fm."jobMakeMethodId" = jmm."id"
+ INNER JOIN "item" i ON jmm."itemId" = i.id
+
+ WHERE jo."status" != 'Done'
+ AND jo."status" != 'Canceled'
+ AND CASE
+ WHEN array_length(processes, 1) > 0 THEN
+ jo."processId" = ANY(processes)
+ ELSE true
+ END
+ ORDER BY jo."priority";
+END;
+$$ LANGUAGE plpgsql;
+
+
+DROP POLICY IF EXISTS "Authenticated users can view global material substances" ON "materialSubstance";
+
+DROP POLICY IF EXISTS "Employees can view material substances" ON "materialSubstance";
+
+DROP POLICY IF EXISTS "Employees with parts_create can insert material substances" ON "materialSubstance";
+
+DROP POLICY IF EXISTS "Employees with parts_update can update material substances" ON "materialSubstance";
+
+DROP POLICY IF EXISTS "Employees with parts_delete can delete material substances" ON "materialSubstance";
+
+DROP POLICY IF EXISTS "Requests with an API key can access material substances" ON "materialSubstance";
+
+-- RLS Policies for materialSubstance table
+CREATE POLICY "SELECT" ON "materialSubstance"
+FOR SELECT
+USING (
+ "companyId" IS NULL
+ OR "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_view')
+ )::text[]
+ )
+);
+
+CREATE POLICY "INSERT" ON "materialSubstance"
+FOR INSERT WITH CHECK (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_create')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "materialSubstance"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "materialSubstance"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_delete')
+ )::text[]
+ )
+);
+
+
+DROP POLICY IF EXISTS "Authenticated users can view global material forms" ON "materialForm";
+
+DROP POLICY IF EXISTS "Employees can view material forms" ON "materialForm";
+
+DROP POLICY IF EXISTS "Employees with parts_create can insert material forms" ON "materialForm";
+
+DROP POLICY IF EXISTS "Employees with parts_update can update material forms" ON "materialForm";
+
+DROP POLICY IF EXISTS "Employees with parts_delete can delete material forms" ON "materialForm";
+
+DROP POLICY IF EXISTS "Requests with an API key can access material forms" ON "materialForm";
+
+-- RLS Policies for materialForm table
+CREATE POLICY "SELECT" ON "materialForm"
+FOR SELECT
+USING (
+ "companyId" IS NULL
+ OR "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_view')
+ )::text[]
+ )
+);
+
+CREATE POLICY "INSERT" ON "materialForm"
+FOR INSERT WITH CHECK (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_create')
+ )::text[]
+ )
+);
+
+CREATE POLICY "UPDATE" ON "materialForm"
+FOR UPDATE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_update')
+ )::text[]
+ )
+);
+
+CREATE POLICY "DELETE" ON "materialForm"
+FOR DELETE USING (
+ "companyId" = ANY (
+ (
+ SELECT
+ get_companies_with_employee_permission('parts_delete')
+ )::text[]
+ )
+);
\ No newline at end of file
diff --git a/packages/ee/src/radan/config.tsx b/packages/ee/src/radan/config.tsx
index 176c80c382..ca0af8a362 100644
--- a/packages/ee/src/radan/config.tsx
+++ b/packages/ee/src/radan/config.tsx
@@ -18,9 +18,9 @@ export const Radan: IntegrationConfig = {
{
name: "processes",
label: "Processes",
- type: "text",
- required: false,
- value: "",
+ type: "processes",
+ required: true,
+ value: [],
},
],
schema: z.object({
@@ -45,18 +45,42 @@ export function Logo(props: SVGProps<SVGSVGElement>) {
return (
<svg
xmlns="http://www.w3.org/2000/svg"
- id="Artwork"
+ {...props}
version="1.1"
viewBox="0 0 592.17 166.51"
>
- <polygon points="222.49 50.54 222.49 76.12 195.66 76.12 195.66 50.54 183.75 50.54 183.75 115.97 195.66 115.97 195.66 87.47 222.49 87.47 222.49 115.97 234.41 115.97 234.41 50.54 222.49 50.54" />
- <polygon points="245.65 115.97 245.65 50.54 290.3 50.54 290.3 61.33 257.53 61.33 257.53 76.59 286.15 76.59 286.15 87.28 257.53 87.28 257.53 105.17 290.3 105.17 290.3 115.97 245.65 115.97" />
- <polygon points="339.48 115.97 324.82 92.17 310.15 115.97 297.34 115.97 317.9 82.65 297.5 50.54 310.51 50.54 325.17 73.44 339.41 50.54 352.32 50.54 332.2 82.75 352.58 115.97 339.48 115.97" />
- <path d="M383.61,65.13l-9.31,27.61h18.63l-9.32-27.61h0ZM400.88,115.97l-4.25-12.52h-26.02l-4.21,12.52h-11.98l22.97-65.42h12.98l22.97,65.42h-12.45Z" />
- <path d="M514,64.49c-2.59-2.76-6.6-4.32-10.38-4.32s-7.75,1.56-10.32,4.32c-4.51,4.72-4.71,12.84-4.71,18.84s.19,14.03,4.71,18.72c2.57,2.76,6.56,4.34,10.32,4.34s7.77-1.56,10.38-4.34c4.51-4.71,4.71-12.72,4.71-18.72s-.19-14.12-4.71-18.84h0ZM522.44,109.78c-4.95,4.99-11.81,7.38-18.8,7.38s-13.8-2.41-18.8-7.38c-7.1-7.1-8.31-15.76-8.31-26.47s1.21-19.47,8.31-26.58c5-4.99,11.82-7.38,18.8-7.38s13.85,2.41,18.8,7.38c7.1,7.1,8.31,15.87,8.31,26.58s-1.2,19.37-8.31,26.47Z" />
- <polygon points="579.92 115.97 551.59 71.03 551.59 115.97 539.88 115.97 539.88 50.54 552.51 50.54 580.46 94.83 580.46 50.54 592.17 50.54 592.17 115.97 579.92 115.97" />
- <path d="M468.33,80.09v12.55c0,14.81-10.72,24.52-25.45,24.52-10.27,0-18.46-3.73-23.56-12.98-3.53-6.53-4.27-13.63-4.27-20.93,0-9.98,1.1-18.85,8.49-26.26,5.02-5.02,12.38-7.64,19.44-7.64,11.09,0,19.88,5.48,23.57,14.52l-10.34,5.96c-.6-2.01-1.64-3.97-3.19-5.62-2.69-2.89-6-4.18-10.13-4.18-5.81,0-11,3.13-13.36,8.45-2.1,4.74-2.41,9.66-2.41,14.78,0,6.14.8,14.51,5.18,19.06,2.97,3.25,7.63,4.17,10.59,4.17,4.13,0,7.35-1.28,10.05-4.17,2.59-2.78,3.77-6.41,3.87-9.65.02-.86,0-1.77,0-2.69h-15.57v-9.88h27.1-.01Z" />
- <path d="M140.9,40.63c-15.06,8.7-65.56,37.83-65.56,37.83h0V2.81c0-2.15-2.32-3.5-4.19-2.42C56.82,8.65,10.12,35.58,1.43,40.59c-.88.52-1.4,1.4-1.4,2.42v80.48c0,1.55,1.27,2.79,2.79,2.79h44.82c2.75,4.73,17.78,30.73,22.48,38.83.76,1.34,2.48,1.78,3.8,1.02,11.54-6.64,60.82-35.09,69.75-40.25.88-.52,1.4-1.4,1.4-2.42V43.02c0-2.15-2.31-3.5-4.19-2.42v.02ZM5.61,120.74V53.47l38.81,67.27H5.61ZM69.76,153.33L6.65,44.08,69.76,7.67v145.66ZM75.34,158.91v-32.61h56.54s-56.54,32.61-56.54,32.61ZM139.5,120.71h-64.16v-35.81l64.16-37.02v72.84Z" />
+ <polygon
+ fill="currentColor"
+ points="222.49 50.54 222.49 76.12 195.66 76.12 195.66 50.54 183.75 50.54 183.75 115.97 195.66 115.97 195.66 87.47 222.49 87.47 222.49 115.97 234.41 115.97 234.41 50.54 222.49 50.54"
+ />
+ <polygon
+ fill="currentColor"
+ points="245.65 115.97 245.65 50.54 290.3 50.54 290.3 61.33 257.53 61.33 257.53 76.59 286.15 76.59 286.15 87.28 257.53 87.28 257.53 105.17 290.3 105.17 290.3 115.97 245.65 115.97"
+ />
+ <polygon
+ fill="currentColor"
+ points="339.48 115.97 324.82 92.17 310.15 115.97 297.34 115.97 317.9 82.65 297.5 50.54 310.51 50.54 325.17 73.44 339.41 50.54 352.32 50.54 332.2 82.75 352.58 115.97 339.48 115.97"
+ />
+ <path
+ fill="currentColor"
+ d="M383.61,65.13l-9.31,27.61h18.63l-9.32-27.61h0ZM400.88,115.97l-4.25-12.52h-26.02l-4.21,12.52h-11.98l22.97-65.42h12.98l22.97,65.42h-12.45Z"
+ />
+ <path
+ fill="currentColor"
+ d="M514,64.49c-2.59-2.76-6.6-4.32-10.38-4.32s-7.75,1.56-10.32,4.32c-4.51,4.72-4.71,12.84-4.71,18.84s.19,14.03,4.71,18.72c2.57,2.76,6.56,4.34,10.32,4.34s7.77-1.56,10.38-4.34c4.51-4.71,4.71-12.72,4.71-18.72s-.19-14.12-4.71-18.84h0ZM522.44,109.78c-4.95,4.99-11.81,7.38-18.8,7.38s-13.8-2.41-18.8-7.38c-7.1-7.1-8.31-15.76-8.31-26.47s1.21-19.47,8.31-26.58c5-4.99,11.82-7.38,18.8-7.38s13.85,2.41,18.8,7.38c7.1,7.1,8.31,15.87,8.31,26.58s-1.2,19.37-8.31,26.47Z"
+ />
+ <polygon
+ fill="currentColor"
+ points="579.92 115.97 551.59 71.03 551.59 115.97 539.88 115.97 539.88 50.54 552.51 50.54 580.46 94.83 580.46 50.54 592.17 50.54 592.17 115.97 579.92 115.97"
+ />
+ <path
+ fill="currentColor"
+ d="M468.33,80.09v12.55c0,14.81-10.72,24.52-25.45,24.52-10.27,0-18.46-3.73-23.56-12.98-3.53-6.53-4.27-13.63-4.27-20.93,0-9.98,1.1-18.85,8.49-26.26,5.02-5.02,12.38-7.64,19.44-7.64,11.09,0,19.88,5.48,23.57,14.52l-10.34,5.96c-.6-2.01-1.64-3.97-3.19-5.62-2.69-2.89-6-4.18-10.13-4.18-5.81,0-11,3.13-13.36,8.45-2.1,4.74-2.41,9.66-2.41,14.78,0,6.14.8,14.51,5.18,19.06,2.97,3.25,7.63,4.17,10.59,4.17,4.13,0,7.35-1.28,10.05-4.17,2.59-2.78,3.77-6.41,3.87-9.65.02-.86,0-1.77,0-2.69h-15.57v-9.88h27.1-.01Z"
+ />
+ <path
+ fill="currentColor"
+ d="M140.9,40.63c-15.06,8.7-65.56,37.83-65.56,37.83h0V2.81c0-2.15-2.32-3.5-4.19-2.42C56.82,8.65,10.12,35.58,1.43,40.59c-.88.52-1.4,1.4-1.4,2.42v80.48c0,1.55,1.27,2.79,2.79,2.79h44.82c2.75,4.73,17.78,30.73,22.48,38.83.76,1.34,2.48,1.78,3.8,1.02,11.54-6.64,60.82-35.09,69.75-40.25.88-.52,1.4-1.4,1.4-2.42V43.02c0-2.15-2.31-3.5-4.19-2.42v.02ZM5.61,120.74V53.47l38.81,67.27H5.61ZM69.76,153.33L6.65,44.08,69.76,7.67v145.66ZM75.34,158.91v-32.61h56.54s-56.54,32.61-56.54,32.61ZM139.5,120.71h-64.16v-35.81l64.16-37.02v72.84Z"
+ />
</svg>
);
}
diff --git a/packages/ee/src/types.ts b/packages/ee/src/types.ts
index ddc2f2e712..43b85db805 100644
--- a/packages/ee/src/types.ts
+++ b/packages/ee/src/types.ts
@@ -13,7 +13,7 @@ export type IntegrationConfig = {
settings: {
name: string;
label: string;
- type: "text" | "switch";
+ type: "text" | "switch" | "processes";
required: boolean;
value: unknown;
}[];