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.

12.3 KB
Raw Blame
// SPDX-License-Identifier: LicenseRef-Carbon-Commercial
// Carbon Enterprise file, licensed only under the Carbon Commercial License
// (packages/ee/LICENSE). Not AGPL. Running, modifying, or copying it beyond those terms requires a commercial license.

import { Copy, cn, Input, InputGroup, InputRightElement } from "@carbon/react";
import { isBrowser } from "@carbon/utils";
import type { SVGProps } from "react";
import { z } from "zod";
import { defineIntegration } from "../fns";

export const PaperlessParts = defineIntegration({
  name: "Paperless Parts",
  id: "paperless-parts",
  active: true,
  category: "Estimating & Quoting",
  logo: Logo,
  description:
    "Paperless Parts is an estimating and quoting platform that uses advanced geometric interrogation to generate accurate estimates for sheet metal fabrication, CNC machining, and more. This integration will sync data from Paperless Parts to Carbon.",
  shortDescription: "Sync data from Paperless Parts to Carbon.",
  setupInstructions: SetupInstructions,
  images: [],

  settings: [
    {
      name: "apiKey",
      label: "API Key",
      type: "secret",
      required: true,
      value: ""
    },
    {
      name: "secretKey",
      label: "Webhook Signing Secret",
      type: "secret",
      required: true,
      value: ""
    },
    {
      name: "methodType",
      label: "Material Method Type",
      type: "options",
      listOptions: ["Purchase to Order", "Pull from Inventory"],
      required: false,
      value: "Pull from Inventory"
    },
    {
      name: "trackingType",
      label: "Material Tracking Type",
      type: "options",
      listOptions: ["Inventory", "Non-Inventory", "Batch"],
      required: false,
      value: "Inventory"
    },
    {
      name: "billOfProcessBlackList",
      label: "Bill of Process Black List",
      type: "array",
      required: false,
      value: []
    },
    {
      name: "usePaperlessOrderNumber",
      label: "Use Paperless Order Number",
      type: "switch",
      required: false,
      value: false
    }
  ],
  schema: z.object({
    // Empty means "keep the existing vaulted secret"; presence is enforced at
    // install-time in the settings action.
    apiKey: z.string(),
    secretKey: z.string(),
    methodType: z.enum(["Purchase to Order", "Pull from Inventory"]),
    trackingType: z.enum(["Inventory", "Non-Inventory", "Batch"]),
    billOfProcessBlackList: z.array(z.string()).optional(),
    // `SwitchField` in the integration form always posts a literal
    // "true"/"false" string, which `zfd.checkbox()` (expects "on") rejects —
    // that rejection blocked every save. Preprocess the string into a boolean
    // the same way the email/onshape/xero configs do.
    usePaperlessOrderNumber: z
      .preprocess((v) => {
        if (typeof v === "boolean") return v;
        if (v === "true") return true;
        if (v === "false") return false;
        return v;
      }, z.boolean())
      .default(false)
  })
});

function SetupInstructions({ companyId }: { companyId: string }) {
  const webhookUrl = isBrowser
    ? `${window.location.origin}/api/webhook/paperless-parts/${companyId}`
    : "";
  return (
    <>
      <p className="text-sm text-muted-foreground">
        First, copy and paste the following URL into the Webhook URL field in
        your Paperless Parts account:
      </p>
      <InputGroup className="mb-8">
        <Input value={webhookUrl} />
        <InputRightElement>
          <Copy text={webhookUrl} />
        </InputRightElement>
      </InputGroup>
      <p className="text-sm text-muted-foreground">
        Next, copy the API Key and Webhook Signing Secret from your Paperless
        Parts account and paste them into the API Key and Webhook Signing Secret
        fields below:
      </p>
    </>
  );
}

function Logo(props: SVGProps<SVGSVGElement>) {
  return (
    <svg
      {...props}
      xmlns="http://www.w3.org/2000/svg"
      width="558.86"
      height="74.71"
      viewBox="0 0 558.86 74.71"
      fill="none"
      className={cn("text-foreground", props.className)}
    >
      <g xmlns="http://www.w3.org/2000/svg">
        <g>
          <path
            fill="#F9751A"
            d="M30.88,44.22a15.56,15.56,0,0,1-3.23,5.08A13.43,13.43,0,0,1,23,52.44a14.08,14.08,0,0,1-5.37,1.06,11.46,11.46,0,0,1-6.35-1.64A16.52,16.52,0,0,1,7.11,48l.06,14.22H0V21.83H7.17V27a15.54,15.54,0,0,1,4.22-4.14,11.06,11.06,0,0,1,6.27-1.68A14,14,0,0,1,23,22.24a13.6,13.6,0,0,1,4.6,3.15,15.77,15.77,0,0,1,3.25,5.08,18,18,0,0,1,1.23,6.87A18.4,18.4,0,0,1,30.88,44.22Zm-6.67-11a9.58,9.58,0,0,0-1.91-3.14,8.39,8.39,0,0,0-2.82-2A8.54,8.54,0,0,0,16,27.35a8.76,8.76,0,0,0-3.47.71,8.35,8.35,0,0,0-2.87,2,10,10,0,0,0-2,3.14,11.81,11.81,0,0,0,0,8.23,10,10,0,0,0,2,3.14,8.49,8.49,0,0,0,2.87,2,8.75,8.75,0,0,0,3.47.7,8.53,8.53,0,0,0,3.44-.7,8.39,8.39,0,0,0,2.82-2,9.58,9.58,0,0,0,1.91-3.14,12.62,12.62,0,0,0,0-8.29Z"
          />
          <path
            fill="#F9751A"
            d="M57.29,52.86V49a13.38,13.38,0,0,1-4,3.17,12.85,12.85,0,0,1-6,1.29A14,14,0,0,1,43,52.88a10.18,10.18,0,0,1-3.49-1.82,8.82,8.82,0,0,1-3.32-7.14v-.11a9.68,9.68,0,0,1,.94-4.41,8.57,8.57,0,0,1,2.61-3.12,12,12,0,0,1,4-1.85,19.51,19.51,0,0,1,5-.61,28.22,28.22,0,0,1,4.79.35,28.75,28.75,0,0,1,3.79.94v-.76a6.19,6.19,0,0,0-2-4.94,8.44,8.44,0,0,0-5.67-1.7,18.6,18.6,0,0,0-4.7.53,30.13,30.13,0,0,0-4.17,1.41L38.9,24a31.74,31.74,0,0,1,5.29-1.88,26.08,26.08,0,0,1,6.52-.71q6.93,0,10.28,3.44t3.35,9.66v18.4Zm.18-13.17a19.06,19.06,0,0,0-3.21-.88,21.19,21.19,0,0,0-3.9-.35,9.13,9.13,0,0,0-5.23,1.29,4.21,4.21,0,0,0-1.88,3.7v.12A3.85,3.85,0,0,0,45,47a7.44,7.44,0,0,0,4.26,1.17,10.62,10.62,0,0,0,3.26-.47,8.38,8.38,0,0,0,2.62-1.32,6.06,6.06,0,0,0,1.73-2,5.84,5.84,0,0,0,.62-2.68Z"
          />
          <path
            fill="#F9751A"
            d="M101.62,44.22a15.4,15.4,0,0,1-3.23,5.08,13.39,13.39,0,0,1-4.64,3.14,14.13,14.13,0,0,1-5.38,1.06A11.44,11.44,0,0,1,82,51.86,16.18,16.18,0,0,1,77.86,48l0,14.22H70.75V21.83h7.16V27a15.69,15.69,0,0,1,4.22-4.14,11.1,11.1,0,0,1,6.28-1.68,14,14,0,0,1,5.33,1.06,13.5,13.5,0,0,1,4.6,3.15,15.79,15.79,0,0,1,3.26,5.08,18,18,0,0,1,1.23,6.87A18.2,18.2,0,0,1,101.62,44.22ZM95,33.2A9.41,9.41,0,0,0,93,30.06a8.49,8.49,0,0,0-6.25-2.71,8.72,8.72,0,0,0-3.47.71,8.3,8.3,0,0,0-2.88,2,10.15,10.15,0,0,0-2,3.14,12,12,0,0,0,0,8.23,10.15,10.15,0,0,0,2,3.14,8.43,8.43,0,0,0,2.88,2,8.71,8.71,0,0,0,3.47.7A8.43,8.43,0,0,0,93,44.63,9.41,9.41,0,0,0,95,41.49a12.45,12.45,0,0,0,0-8.29Z"
          />
          <path
            fill="#F9751A"
            d="M117.34,45.72a8.84,8.84,0,0,0,5.88,2,10.34,10.34,0,0,0,4.58-.94A14.58,14.58,0,0,0,131.62,44l4.17,3.7A16.94,16.94,0,0,1,130.47,52a15.88,15.88,0,0,1-7.37,1.59,16.64,16.64,0,0,1-6.26-1.17A15.09,15.09,0,0,1,108.41,44a17.11,17.11,0,0,1-1.23-6.61,17.67,17.67,0,0,1,1.11-6.29A15.86,15.86,0,0,1,111.44,26a15.09,15.09,0,0,1,4.78-3.49,14.31,14.31,0,0,1,6.12-1.3,14.62,14.62,0,0,1,6.49,1.36,13.27,13.27,0,0,1,4.64,3.64,15.76,15.76,0,0,1,2.79,5.35,21.5,21.5,0,0,1,.94,6.4c0,.31,0,.63,0,.94s0,.65-.09,1H114.29A9.36,9.36,0,0,0,117.34,45.72Zm12.81-10.55a12.27,12.27,0,0,0-.76-3.2,8.17,8.17,0,0,0-1.59-2.59,7.63,7.63,0,0,0-2.38-1.73,7.34,7.34,0,0,0-3.14-.65,7.2,7.2,0,0,0-5.44,2.26,10.21,10.21,0,0,0-2.61,5.91Z"
          />
          <path
            fill="#F9751A"
            d="M150.89,52.86h-7.17v-31h7.17v7a13.68,13.68,0,0,1,4.17-5.64,10.06,10.06,0,0,1,6.82-1.94v7.52h-.41a11.58,11.58,0,0,0-4.29.77,9,9,0,0,0-3.35,2.29,10.36,10.36,0,0,0-2.17,3.85,17.18,17.18,0,0,0-.77,5.37Z"
          />
          <path fill="#F9751A" d="M168.4,52.86V10h7.17v42.9Z" />
          <path
            fill="#F9751A"
            d="M191.91,45.72a8.8,8.8,0,0,0,5.87,2,10.42,10.42,0,0,0,4.59-.94A14.54,14.54,0,0,0,206.18,44l4.18,3.7A17.05,17.05,0,0,1,205,52a16,16,0,0,1-7.38,1.59,16.58,16.58,0,0,1-6.25-1.17A15.06,15.06,0,0,1,183,44a17.11,17.11,0,0,1-1.23-6.61,17.46,17.46,0,0,1,1.12-6.29A15.83,15.83,0,0,1,186,26a15.13,15.13,0,0,1,4.79-3.49,14.27,14.27,0,0,1,6.11-1.3,14.59,14.59,0,0,1,6.49,1.36A13.4,13.4,0,0,1,208,26.18a15.94,15.94,0,0,1,2.79,5.35,21.83,21.83,0,0,1,.94,6.4c0,.31,0,.63,0,.94s-.05.65-.09,1h-22.8A9.37,9.37,0,0,0,191.91,45.72Zm12.81-10.55A12.28,12.28,0,0,0,204,32a8.33,8.33,0,0,0-1.58-2.59A7.63,7.63,0,0,0,200,27.65a7.39,7.39,0,0,0-3.15-.65,7.19,7.19,0,0,0-5.43,2.26,10.22,10.22,0,0,0-2.62,5.91Z"
          />
          <path
            fill="#F9751A"
            d="M240.21,48a8.38,8.38,0,0,1-2.44,3,11,11,0,0,1-3.68,1.83,16.08,16.08,0,0,1-4.52.61,21,21,0,0,1-6.79-1.17,21.63,21.63,0,0,1-6.37-3.47L219.58,44a20.24,20.24,0,0,0,5.14,2.85,14.39,14.39,0,0,0,5,1,6,6,0,0,0,3.55-.91,2.87,2.87,0,0,0,1.27-2.44v-.11a2.27,2.27,0,0,0-.56-1.53,5.07,5.07,0,0,0-1.53-1.15,14.2,14.2,0,0,0-2.23-.88L227.63,40c-1.13-.36-2.28-.75-3.44-1.18a12.68,12.68,0,0,1-3.11-1.67,8.56,8.56,0,0,1-2.26-2.53,7.23,7.23,0,0,1-.88-3.73v-.12a8.93,8.93,0,0,1,.85-3.94,8.8,8.8,0,0,1,2.35-3A10.52,10.52,0,0,1,224.66,22,14.15,14.15,0,0,1,229,21.3a20,20,0,0,1,5.94.94,21.13,21.13,0,0,1,5.46,2.59l-2.82,5.05A23.18,23.18,0,0,0,233,27.74a13,13,0,0,0-4.23-.8,5.21,5.21,0,0,0-3.21.88,2.73,2.73,0,0,0-1.14,2.24v.11a2,2,0,0,0,.59,1.44,5.58,5.58,0,0,0,1.55,1.12,17.62,17.62,0,0,0,2.23.94c.85.29,1.72.58,2.62.85,1.14.35,2.27.77,3.41,1.24a14.35,14.35,0,0,1,3.08,1.73,8.74,8.74,0,0,1,2.27,2.5,6.91,6.91,0,0,1,.88,3.58v.12A9.89,9.89,0,0,1,240.21,48Z"
          />
          <path
            fill="#F9751A"
            d="M269,48a8.38,8.38,0,0,1-2.44,3,11,11,0,0,1-3.67,1.83,16.16,16.16,0,0,1-4.53.61,20.94,20.94,0,0,1-6.78-1.17,21.56,21.56,0,0,1-6.38-3.47L248.37,44a20.29,20.29,0,0,0,5.15,2.85,14.3,14.3,0,0,0,5,1,6,6,0,0,0,3.55-.91,2.85,2.85,0,0,0,1.27-2.44v-.11a2.27,2.27,0,0,0-.56-1.53,5,5,0,0,0-1.53-1.15,14.2,14.2,0,0,0-2.23-.88L256.42,40c-1.13-.36-2.28-.75-3.43-1.18a12.57,12.57,0,0,1-3.12-1.67,8.56,8.56,0,0,1-2.26-2.53,7.23,7.23,0,0,1-.88-3.73v-.12a8.93,8.93,0,0,1,.85-3.94,8.8,8.8,0,0,1,2.35-3A10.57,10.57,0,0,1,253.46,22a14.15,14.15,0,0,1,4.32-.65,20,20,0,0,1,5.93.94,21.13,21.13,0,0,1,5.46,2.59l-2.82,5.05a22.91,22.91,0,0,0-4.52-2.14,13,13,0,0,0-4.23-.8,5.18,5.18,0,0,0-3.2.88,2.71,2.71,0,0,0-1.15,2.24v.11a2,2,0,0,0,.59,1.44,5.49,5.49,0,0,0,1.56,1.12,17,17,0,0,0,2.23.94c.84.29,1.71.58,2.61.85,1.14.35,2.27.77,3.41,1.24a14.43,14.43,0,0,1,3.09,1.73A8.7,8.7,0,0,1,269,40a6.81,6.81,0,0,1,.88,3.58v.12A9.75,9.75,0,0,1,269,48Z"
          />
          <path
            fill="#F9751A"
            d="M309.19,32.35a12.76,12.76,0,0,1-3.56,4.52,15.33,15.33,0,0,1-5.28,2.74,22.69,22.69,0,0,1-6.5.91H287V52.86h-9.05V11.72h16.81a19.94,19.94,0,0,1,6.61,1,14.19,14.19,0,0,1,4.93,2.91,12.73,12.73,0,0,1,3.12,4.5,15,15,0,0,1,1.08,5.78v.12A14.45,14.45,0,0,1,309.19,32.35Zm-7.87-6.23a5.61,5.61,0,0,0-2-4.64A8.33,8.33,0,0,0,294,19.89h-7V32.47h7.17a7.36,7.36,0,0,0,5.29-1.8,5.88,5.88,0,0,0,1.88-4.43Z"
          />
          <path
            fill="#F9751A"
            d="M343.62,52.86l-3.76-9.23H322.47l-3.76,9.23h-9.23l17.63-41.43h8.35l17.62,41.43ZM331.17,22.3,325.7,35.64h10.93Z"
          />
          <path
            fill="#F9751A"
            d="M383.46,52.86l-8.81-13.17h-7.11V52.86h-9.05V11.72h18.8q7.35,0,11.43,3.59t4.08,10v.11a12.92,12.92,0,0,1-2.43,8.14A14.18,14.18,0,0,1,384,38.17L394,52.86Zm.18-27.09a5.26,5.26,0,0,0-1.88-4.41,8.32,8.32,0,0,0-5.23-1.47h-9V31.7h9.16a7.57,7.57,0,0,0,5.15-1.58,5.4,5.4,0,0,0,1.79-4.24Z"
          />
          <path
            fill="#F9751A"
            d="M419.3,20.07V52.86h-9.05V20.07H397.74V11.72h34.08v8.35Z"
          />
          <path
            fill="#F9751A"
            d="M466.44,46.13a11.07,11.07,0,0,1-3.1,4,13.87,13.87,0,0,1-4.74,2.47,20.44,20.44,0,0,1-6.1.85,27.37,27.37,0,0,1-9.22-1.61,24.52,24.52,0,0,1-8.23-5l5.35-6.4a26.67,26.67,0,0,0,5.79,3.64,15.45,15.45,0,0,0,6.49,1.35,7.88,7.88,0,0,0,4.38-1,3.24,3.24,0,0,0,1.55-2.85v-.11a3.65,3.65,0,0,0-.32-1.56,3.28,3.28,0,0,0-1.24-1.26,12.39,12.39,0,0,0-2.53-1.18c-1.08-.39-2.49-.8-4.21-1.23a50.49,50.49,0,0,1-5.66-1.71,15.78,15.78,0,0,1-4.3-2.32,9.33,9.33,0,0,1-2.74-3.44,11.88,11.88,0,0,1-1-5.11v-.12a11.93,11.93,0,0,1,1.05-5.08,11.52,11.52,0,0,1,2.95-3.91A13.29,13.29,0,0,1,445.17,12a18.1,18.1,0,0,1,5.8-.88,24.65,24.65,0,0,1,8.32,1.35,23.83,23.83,0,0,1,7,3.88l-4.7,6.81a30.39,30.39,0,0,0-5.4-3,13.94,13.94,0,0,0-5.29-1.08,6.36,6.36,0,0,0-4,1,3.1,3.1,0,0,0-1.32,2.55v.12a3.74,3.74,0,0,0,.38,1.73,3.49,3.49,0,0,0,1.39,1.32A12.29,12.29,0,0,0,450.08,27c1.15.35,2.62.77,4.39,1.24A40.2,40.2,0,0,1,460,30.09a15.42,15.42,0,0,1,4.13,2.46,9.43,9.43,0,0,1,2.53,3.38,11.48,11.48,0,0,1,.85,4.64v.12A12.89,12.89,0,0,1,466.44,46.13Z"
          />
        </g>
      </g>
    </svg>
  );
}