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: scaffold new mes app with @carbon/auth
Brad Barbinf3752a7f2eb6
diff --git a/apps/carbon/app/routes/x+/_index.tsx b/apps/carbon/app/routes/x+/_index.tsxindex fed557c51c..0ada013d21 100644--- a/apps/carbon/app/routes/x+/_index.tsx+++ b/apps/carbon/app/routes/x+/_index.tsx@@ -53,7 +53,7 @@ const ModuleCard = ({ module }: { module: Authenticated<NavItem> }) => (prefetch="intent"className="flex flex-col gap-6 items-center justify-center py-8 border border-border shadow-md dark:border-0 dark:shadow-[0px_1px_0px_0px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_hsla(0,0%,100%,.03)_inset,0px_0px_0px_1px_rgba(0,0,0,.1),0px_2px_2px_0px_rgba(0,0,0,.1),0px_4px_4px_0px_rgba(0,0,0,.1),0px_8px_8px_0px_rgba(0,0,0,.1)] bg-gradient-to-bl from-card to-background rounded-lg text-center group ring-2 ring-transparent hover:ring-white/10 cursor-pointer">- <module.icon className="text-3xl" />+ <module.icon className="text-2xl" /><span className="text-sm py-1 px-4 border border-border rounded-full group-hover:bg-accent">{module.name}</span>diff --git a/apps/carbon/package.json b/apps/carbon/package.jsonindex f6052a8c4f..7bba98b3be 100644--- a/apps/carbon/package.json+++ b/apps/carbon/package.json@@ -101,7 +101,7 @@"build": "remix vite:build","clean": "rimraf .cache .turbo node_modules dist build","dev": "run-p dev:remix dev:trigger",- "dev:remix": "PORT=3000 remix vite:dev",+ "dev:remix": "remix vite:dev","dev:trigger": "npx --yes [email protected] dev","lint": "TIMING=1 eslint \"app/**/*.ts*\"","start": "remix-serve ./build/server/index.js",diff --git a/apps/developers/app/routes/_public+/request-access.tsx b/apps/developers/app/routes/_public+/request-access.tsxindex 4be0cb7c11..04278d8494 100644--- a/apps/developers/app/routes/_public+/request-access.tsx+++ b/apps/developers/app/routes/_public+/request-access.tsx@@ -2,7 +2,7 @@ import { VERCEL_URL } from "@carbon/auth";import { Button } from "@carbon/react";import type { MetaFunction } from "@vercel/remix";-export const APP_URL = VERCEL_URL?.includes("localhost")+export const ERP_URL = VERCEL_URL?.includes("localhost")? "http://localhost:3000": `https://app.carbonos.dev`;@@ -37,7 +37,7 @@ export default function RequestAccessRoute() {Request access to the developer portal by emailing [email protected]</p><Button size="lg" asChild>- <a href={APP_URL}>Return to App</a>+ <a href={ERP_URL}>Return to App</a></Button></div></>diff --git a/apps/developers/app/routes/x+/_layout.tsx b/apps/developers/app/routes/x+/_layout.tsxindex 7439e0c36b..63fcf80407 100644--- a/apps/developers/app/routes/x+/_layout.tsx+++ b/apps/developers/app/routes/x+/_layout.tsx@@ -20,7 +20,7 @@ import { PrimaryNavigation, Topbar } from "~/components";import { path } from "~/utils/path";-export const APP_URL = VERCEL_URL?.includes("localhost")+export const ERP_URL = VERCEL_URL?.includes("localhost")? "http://localhost:3000": `https://app.carbonos.dev`;@@ -47,7 +47,7 @@ export async function loader({ request }: LoaderFunctionArgs) {const company = companies.data?.find((c) => c.companyId === companyId);if (!company) {- throw redirect(APP_URL);+ throw redirect(ERP_URL);}return json({diff --git a/apps/developers/package.json b/apps/developers/package.jsonindex 1d11a0b37f..0095534224 100644--- a/apps/developers/package.json+++ b/apps/developers/package.json@@ -62,7 +62,7 @@"scripts": {"build": "remix vite:build","clean": "rimraf .cache .turbo node_modules dist build",- "dev": "PORT=3001 remix vite:dev",+ "dev": "remix vite:dev","lint": "TIMING=1 eslint \"app/**/*.ts*\"","start": "remix-serve ./build/server/index.js","types": "tsc"diff --git a/apps/mes/.env.example b/apps/mes-prototype/.env.examplesimilarity index 100%rename from apps/mes/.env.examplerename to apps/mes-prototype/.env.examplediff --git a/apps/mes/.eslintrc.cjs b/apps/mes-prototype/.eslintrc.cjssimilarity index 100%rename from apps/mes/.eslintrc.cjsrename to apps/mes-prototype/.eslintrc.cjsdiff --git a/apps/mes-prototype/.gitignore b/apps/mes-prototype/.gitignorenew file mode 100644index 0000000000..a547bf36d8--- /dev/null+++ b/apps/mes-prototype/.gitignore@@ -0,0 +1,24 @@+# Logs+logs+*.log+npm-debug.log*+yarn-debug.log*+yarn-error.log*+pnpm-debug.log*+lerna-debug.log*++node_modules+dist+dist-ssr+*.local++# Editor directories and files+.vscode/*+!.vscode/extensions.json+.idea+.DS_Store+*.suo+*.ntvs*+*.njsproj+*.sln+*.sw?diff --git a/apps/mes/index.html b/apps/mes-prototype/index.htmlsimilarity index 100%rename from apps/mes/index.htmlrename to apps/mes-prototype/index.htmldiff --git a/apps/mes-prototype/package.json b/apps/mes-prototype/package.jsonnew file mode 100644index 0000000000..82cf1de672--- /dev/null+++ b/apps/mes-prototype/package.json@@ -0,0 +1,41 @@+{+ "name": "mes-prototype",+ "private": true,+ "version": "0.0.0",+ "type": "module",+ "scripts": {+ "dev": "vite",+ "build": "tsc && vite build",+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",+ "preview": "vite preview"+ },+ "dependencies": {+ "@carbon/database": "*",+ "@carbon/react": "*",+ "@carbon/react-hook-form": "*",+ "@carbon/tsconfig": "*",+ "@hookform/resolvers": "^3.4.2",+ "@supabase/supabase-js": "^2.40.0",+ "class-variance-authority": "0.7.0",+ "localforage": "^1.10.0",+ "non.geist": "~1.0.3",+ "react": "^18.3.1",+ "react-dom": "^18.3.1",+ "react-icons": "^5.2.1",+ "react-router-dom": "^6.23.1",+ "react-hook-form": "7.51.2",+ "zod": "3.23.8"+ },+ "devDependencies": {+ "@types/react": "^18.2.66",+ "@types/react-dom": "^18.2.22",+ "@vitejs/plugin-react": "^4.2.1",+ "autoprefixer": "^10.4.14",+ "eslint": "^8.57.0",+ "eslint-config-carbon": "*",+ "postcss": "^8.4.33",+ "tailwindcss": "^3.3.2",+ "typescript": "^5.2.2",+ "vite": "^5.3.3"+ }+}diff --git a/apps/mes/postcss.config.js b/apps/mes-prototype/postcss.config.jssimilarity index 100%rename from apps/mes/postcss.config.jsrename to apps/mes-prototype/postcss.config.jsdiff --git a/apps/mes-prototype/public/carbon-logo-dark.png b/apps/mes-prototype/public/carbon-logo-dark.pngnew file mode 100644index 0000000000..75399c8d11Binary files /dev/null and b/apps/mes-prototype/public/carbon-logo-dark.png differdiff --git a/apps/mes-prototype/public/carbon-logo-light.png b/apps/mes-prototype/public/carbon-logo-light.pngnew file mode 100644index 0000000000..c0f93e6fe2Binary files /dev/null and b/apps/mes-prototype/public/carbon-logo-light.png differdiff --git a/apps/mes-prototype/public/favicon.ico b/apps/mes-prototype/public/favicon.iconew file mode 100644index 0000000000..ce92de6710Binary files /dev/null and b/apps/mes-prototype/public/favicon.ico differdiff --git a/apps/mes-prototype/public/grid.svg b/apps/mes-prototype/public/grid.svgnew file mode 100644index 0000000000..d9dc0423ed--- /dev/null+++ b/apps/mes-prototype/public/grid.svg@@ -0,0 +1,5 @@++<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">+ <path id="Path_3" data-name="Path 3" d="M96,95h4v1H96v4H95V96H86v4H85V96H76v4H75V96H66v4H65V96H56v4H55V96H46v4H45V96H36v4H35V96H26v4H25V96H16v4H15V96H0V95H15V86H0V85H15V76H0V75H15V66H0V65H15V56H0V55H15V46H0V45H15V36H0V35H15V26H0V25H15V16H0V15H15V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96Zm-1,0V86H86v9ZM85,95V86H76v9ZM75,95V86H66v9ZM65,95V86H56v9ZM55,95V86H46v9ZM45,95V86H36v9ZM35,95V86H26v9ZM25,95V86H16v9ZM16,85h9V76H16Zm10,0h9V76H26Zm10,0h9V76H36Zm10,0h9V76H46Zm10,0h9V76H56Zm10,0h9V76H66Zm10,0h9V76H76Zm10,0h9V76H86Zm9-10V66H86v9ZM85,75V66H76v9ZM75,75V66H66v9ZM65,75V66H56v9ZM55,75V66H46v9ZM45,75V66H36v9ZM35,75V66H26v9ZM25,75V66H16v9ZM16,65h9V56H16Zm10,0h9V56H26Zm10,0h9V56H36Zm10,0h9V56H46Zm10,0h9V56H56Zm10,0h9V56H66Zm10,0h9V56H76Zm10,0h9V56H86Zm9-10V46H86v9ZM85,55V46H76v9ZM75,55V46H66v9ZM65,55V46H56v9ZM55,55V46H46v9ZM45,55V46H36v9ZM35,55V46H26v9ZM25,55V46H16v9ZM16,45h9V36H16Zm10,0h9V36H26Zm10,0h9V36H36Zm10,0h9V36H46Zm10,0h9V36H56Zm10,0h9V36H66Zm10,0h9V36H76Zm10,0h9V36H86Zm9-10V26H86v9ZM85,35V26H76v9ZM75,35V26H66v9ZM65,35V26H56v9ZM55,35V26H46v9ZM45,35V26H36v9ZM35,35V26H26v9ZM25,35V26H16v9ZM16,25h9V16H16Zm10,0h9V16H26Zm10,0h9V16H36Zm10,0h9V16H46Zm10,0h9V16H56Zm10,0h9V16H66Zm10,0h9V16H76Zm10,0h9V16H86Z" fill="rgba(255,255,255,0.1)" fill-rule="evenodd" opacity="0.5"/>+ <path id="Path_4" data-name="Path 4" d="M6,5V0H5V5H0V6H5v94H6V6h94V5Z" fill="rgba(255,255,255,0.1)" fill-rule="evenodd"/>+</svg>diff --git a/apps/mes/src/assets/icons/AlmostDoneIcon.tsx b/apps/mes-prototype/src/assets/icons/AlmostDoneIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/AlmostDoneIcon.tsxrename to apps/mes-prototype/src/assets/icons/AlmostDoneIcon.tsxdiff --git a/apps/mes/src/assets/icons/AttemptIcon.tsx b/apps/mes-prototype/src/assets/icons/AttemptIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/AttemptIcon.tsxrename to apps/mes-prototype/src/assets/icons/AttemptIcon.tsxdiff --git a/apps/mes/src/assets/icons/HighPriorityIcon.tsx b/apps/mes-prototype/src/assets/icons/HighPriorityIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/HighPriorityIcon.tsxrename to apps/mes-prototype/src/assets/icons/HighPriorityIcon.tsxdiff --git a/apps/mes/src/assets/icons/InProgressStatusIcon.tsx b/apps/mes-prototype/src/assets/icons/InProgressStatusIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/InProgressStatusIcon.tsxrename to apps/mes-prototype/src/assets/icons/InProgressStatusIcon.tsxdiff --git a/apps/mes/src/assets/icons/LowPriorityIcon.tsx b/apps/mes-prototype/src/assets/icons/LowPriorityIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/LowPriorityIcon.tsxrename to apps/mes-prototype/src/assets/icons/LowPriorityIcon.tsxdiff --git a/apps/mes/src/assets/icons/MediumPriorityIcon.tsx b/apps/mes-prototype/src/assets/icons/MediumPriorityIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/MediumPriorityIcon.tsxrename to apps/mes-prototype/src/assets/icons/MediumPriorityIcon.tsxdiff --git a/apps/mes/src/assets/icons/ShowParentIcon.tsx b/apps/mes-prototype/src/assets/icons/ShowParentIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/ShowParentIcon.tsxrename to apps/mes-prototype/src/assets/icons/ShowParentIcon.tsxdiff --git a/apps/mes/src/assets/icons/TaskIcon.tsx b/apps/mes-prototype/src/assets/icons/TaskIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/TaskIcon.tsxrename to apps/mes-prototype/src/assets/icons/TaskIcon.tsxdiff --git a/apps/mes/src/assets/icons/TodoStatusIcon.tsx b/apps/mes-prototype/src/assets/icons/TodoStatusIcon.tsxsimilarity index 100%rename from apps/mes/src/assets/icons/TodoStatusIcon.tsxrename to apps/mes-prototype/src/assets/icons/TodoStatusIcon.tsxdiff --git a/apps/mes/src/components/Authentication.tsx b/apps/mes-prototype/src/components/Authentication.tsxsimilarity index 100%rename from apps/mes/src/components/Authentication.tsxrename to apps/mes-prototype/src/components/Authentication.tsxdiff --git a/apps/mes/src/components/Error.tsx b/apps/mes-prototype/src/components/Error.tsxsimilarity index 100%rename from apps/mes/src/components/Error.tsxrename to apps/mes-prototype/src/components/Error.tsxdiff --git a/apps/mes/src/components/Jobs/JobCard.tsx b/apps/mes-prototype/src/components/Jobs/JobCard.tsxsimilarity index 100%rename from apps/mes/src/components/Jobs/JobCard.tsxrename to apps/mes-prototype/src/components/Jobs/JobCard.tsxdiff --git a/apps/mes/src/components/Jobs/JobsList.tsx b/apps/mes-prototype/src/components/Jobs/JobsList.tsxsimilarity index 100%rename from apps/mes/src/components/Jobs/JobsList.tsxrename to apps/mes-prototype/src/components/Jobs/JobsList.tsxdiff --git a/apps/mes/src/components/Jobs/WorkCellSelect.tsx b/apps/mes-prototype/src/components/Jobs/WorkCellSelect.tsxsimilarity index 100%rename from apps/mes/src/components/Jobs/WorkCellSelect.tsxrename to apps/mes-prototype/src/components/Jobs/WorkCellSelect.tsxdiff --git a/apps/mes/src/components/Nav.tsx b/apps/mes-prototype/src/components/Nav.tsxsimilarity index 100%rename from apps/mes/src/components/Nav.tsxrename to apps/mes-prototype/src/components/Nav.tsxdiff --git a/apps/mes/src/config.ts b/apps/mes-prototype/src/config.tssimilarity index 100%rename from apps/mes/src/config.tsrename to apps/mes-prototype/src/config.tsdiff --git a/apps/mes/src/hooks/useRouteData.ts b/apps/mes-prototype/src/hooks/useRouteData.tssimilarity index 100%rename from apps/mes/src/hooks/useRouteData.tsrename to apps/mes-prototype/src/hooks/useRouteData.tsdiff --git a/apps/mes/src/index.css b/apps/mes-prototype/src/index.csssimilarity index 100%rename from apps/mes/src/index.cssrename to apps/mes-prototype/src/index.cssdiff --git a/apps/mes/src/lib/auth.ts b/apps/mes-prototype/src/lib/auth.tssimilarity index 100%rename from apps/mes/src/lib/auth.tsrename to apps/mes-prototype/src/lib/auth.tsdiff --git a/apps/mes/src/lib/data.tsx b/apps/mes-prototype/src/lib/data.tsxsimilarity index 100%rename from apps/mes/src/lib/data.tsxrename to apps/mes-prototype/src/lib/data.tsxdiff --git a/apps/mes/src/lib/supabase.ts b/apps/mes-prototype/src/lib/supabase.tssimilarity index 100%rename from apps/mes/src/lib/supabase.tsrename to apps/mes-prototype/src/lib/supabase.tsdiff --git a/apps/mes/src/main.tsx b/apps/mes-prototype/src/main.tsxsimilarity index 100%rename from apps/mes/src/main.tsxrename to apps/mes-prototype/src/main.tsxdiff --git a/apps/mes/src/routes/job.tsx b/apps/mes-prototype/src/routes/job.tsxsimilarity index 100%rename from apps/mes/src/routes/job.tsxrename to apps/mes-prototype/src/routes/job.tsxdiff --git a/apps/mes/src/routes/jobs.tsx b/apps/mes-prototype/src/routes/jobs.tsxsimilarity index 100%rename from apps/mes/src/routes/jobs.tsxrename to apps/mes-prototype/src/routes/jobs.tsxdiff --git a/apps/mes/src/routes/login.tsx b/apps/mes-prototype/src/routes/login.tsxsimilarity index 100%rename from apps/mes/src/routes/login.tsxrename to apps/mes-prototype/src/routes/login.tsxdiff --git a/apps/mes/src/services.tsx b/apps/mes-prototype/src/services.tsxsimilarity index 100%rename from apps/mes/src/services.tsxrename to apps/mes-prototype/src/services.tsxdiff --git a/apps/mes/src/types.ts b/apps/mes-prototype/src/types.tssimilarity index 100%rename from apps/mes/src/types.tsrename to apps/mes-prototype/src/types.tsdiff --git a/apps/mes/src/vite-env.d.ts b/apps/mes-prototype/src/vite-env.d.tssimilarity index 100%rename from apps/mes/src/vite-env.d.tsrename to apps/mes-prototype/src/vite-env.d.tsdiff --git a/apps/mes/tailwind.config.ts b/apps/mes-prototype/tailwind.config.tssimilarity index 100%rename from apps/mes/tailwind.config.tsrename to apps/mes-prototype/tailwind.config.tsdiff --git a/apps/mes-prototype/tsconfig.json b/apps/mes-prototype/tsconfig.jsonnew file mode 100644index 0000000000..72c0c3a59d--- /dev/null+++ b/apps/mes-prototype/tsconfig.json@@ -0,0 +1,13 @@+{+ "exclude": ["node_modules"],+ "extends": "@carbon/tsconfig/vite.json",+ "compilerOptions": {+ "rootDir": ".",+ "outDir": "dist",+ "baseUrl": ".",+ "paths": {+ "~/*": ["src/*"]+ }+ },+ "include": ["src", "vite.config.ts"]+}diff --git a/apps/mes-prototype/vite.config.ts b/apps/mes-prototype/vite.config.tsnew file mode 100644index 0000000000..413675e469--- /dev/null+++ b/apps/mes-prototype/vite.config.ts@@ -0,0 +1,19 @@+import react from "@vitejs/plugin-react";+import { resolve } from "path";+import { defineConfig } from "vite";++// https://vitejs.dev/config/+export default defineConfig({+ plugins: [react()],+ server: {+ port: 4000,+ },+ build: {+ sourcemap: true,+ },+ resolve: {+ alias: {+ "~": resolve(__dirname, "src"),+ },+ },+});diff --git a/apps/mes/.eslintrc.mjs b/apps/mes/.eslintrc.mjsnew file mode 100644index 0000000000..d6be4cb1c8--- /dev/null+++ b/apps/mes/.eslintrc.mjs@@ -0,0 +1,3 @@+module.exports = {+ extends: ["carbon"],+};diff --git a/apps/mes/.gitignore b/apps/mes/.gitignoreindex a547bf36d8..4a02fe5c58 100644--- a/apps/mes/.gitignore+++ b/apps/mes/.gitignore@@ -1,24 +1,10 @@-# Logs-logs-*.log-npm-debug.log*-yarn-debug.log*-yarn-error.log*-pnpm-debug.log*-lerna-debug.log*-node_modules-dist-dist-ssr-*.local-# Editor directories and files-.vscode/*-!.vscode/extensions.json-.idea-.DS_Store-*.suo-*.ntvs*-*.njsproj-*.sln-*.sw?+.cache+.vercel+.output++build+public/build+api/index.js*+api/_assets*diff --git a/apps/mes/README.md b/apps/mes/README.mdnew file mode 100644index 0000000000..43aec3697d--- /dev/null+++ b/apps/mes/README.md@@ -0,0 +1,27 @@+# Developers++ERP Application built with:++- [Remix](https://remix.run)+- [Supabase](https://supabase.com/)+- [Postgres](https://postgresql.org/)+- [shadcn](https://ui.shadcn.com/)+- [Redis](https://redis.io)++## Code Organization++### `app/components`++Reusable react components that are specific to this project (and remix). Shared components should live in `packages/react` if they don't rely on some application-specific library. For example, the `Table` relies on some remix internals, so it lives in `app/components`, but the `Date` component is framework agnostic, so it lives in `packages/react`.++### `app/modules`++Where services, ui and form validators are defined for each module.++### `app/routes`++File-based route definitions using `remix`. This is where the services and interfaces meet. Each route is loaded in parallel for performance, so each route is responsible for defining it's own authorization and data needs. Each route has three parts (none are required):++1. `export async function loader`: The data that the route returns, which can be accessed via `GET` or `useLoaderData` in the component (3)+2. `export async function action`: The actions (`POST` or `DELETE`) for the route, which can be accessed via http methods or through the `ValidatedForm` component.+3. `export default function`: The nested react component for the route. This renders inside the `<Outlet/>` component of the parent route.diff --git a/apps/mes/app/components/Avatar.tsx b/apps/mes/app/components/Avatar.tsxnew file mode 100644index 0000000000..2ebc4a9b7b--- /dev/null+++ b/apps/mes/app/components/Avatar.tsx@@ -0,0 +1,20 @@+import type { AvatarProps as AvatarBaseProps } from "@carbon/react";+import { Avatar as AvatarBase } from "@carbon/react";+import { forwardRef } from "react";+import { getStoragePath } from "~/utils/path";++type AvatarProps = AvatarBaseProps & {+ path?: string | null;+ bucket?: string;+};++const Avatar = forwardRef<HTMLSpanElement, AvatarProps>(+ ({ name, path, bucket = "avatars", ...props }, ref) => {+ const imagePath = path ? getStoragePath(bucket, path) : undefined;++ return <AvatarBase src={imagePath} name={name} ref={ref} {...props} />;+ }+);+Avatar.displayName = "Avatar";++export default Avatar;diff --git a/apps/mes/app/components/PrimaryNavigation.tsx b/apps/mes/app/components/PrimaryNavigation.tsxnew file mode 100644index 0000000000..46ed6efba1--- /dev/null+++ b/apps/mes/app/components/PrimaryNavigation.tsx@@ -0,0 +1,164 @@+import { Button, VStack, cn, useDisclosure } from "@carbon/react";+import { Link, useMatches } from "@remix-run/react";+import { noop } from "@tanstack/react-table";+import type { AnchorHTMLAttributes } from "react";+import { forwardRef } from "react";+import type { IconType } from "react-icons";+import { BsFillHexagonFill } from "react-icons/bs";+import { z } from "zod";+import { useOptimisticLocation, useUser } from "~/hooks";++export const ModuleHandle = z.object({+ module: z.string(),+});++type NavLink = {+ to: string;+ icon: IconType;+ name: string;+};++const links: NavLink[] = [];++const PrimaryNavigation = () => {+ const { company } = useUser();++ const navigationPanel = useDisclosure();+ const location = useOptimisticLocation();+ const currentModule = getModule(location.pathname);++ const matchedModules = useMatches().reduce((acc, match) => {+ if (match.handle) {+ const result = ModuleHandle.safeParse(match.handle);+ if (result.success) {+ acc.add(result.data.module);+ }+ }++ return acc;+ }, new Set<string>());++ return (+ <div className="w-14 h-full flex-col z-50 hidden sm:flex">+ <nav+ data-state={navigationPanel.isOpen ? "expanded" : "collapsed"}+ className={cn(+ "bg-background group py-2 z-10 h-full w-14 data-[state=expanded]:w-[13rem]",+ "border-r border-border data-[state=expanded]:shadow-xl",+ "transition-width duration-200",+ "hide-scrollbar flex flex-col justify-between overflow-y-auto"+ )}+ onMouseEnter={navigationPanel.onOpen}+ onMouseLeave={navigationPanel.onClose}+ >+ <VStack+ spacing={1}+ className="flex flex-col justify-between h-full px-2"+ >+ <VStack spacing={1}>+ <Button isIcon asChild variant="ghost" size="lg">+ <Link to="/">+ {company?.logo ? (+ <img+ src={company.logo}+ alt={`${company.name} logo`}+ className="w-full h-auto rounded"+ />+ ) : (+ <BsFillHexagonFill />+ )}+ </Link>+ </Button>+ {links.map((link) => {+ const m = getModule(link.to);++ const moduleMatches = matchedModules.has(m);++ const isActive = currentModule === m || moduleMatches;+ return (+ <NavigationIconLink+ key={link.name}+ link={link}+ isActive={isActive}+ isOpen={navigationPanel.isOpen}+ onClick={navigationPanel.onClose}+ />+ );+ })}+ </VStack>+ </VStack>+ </nav>+ </div>+ );+};++interface NavigationIconButtonProps+ extends AnchorHTMLAttributes<HTMLAnchorElement> {+ link: NavLink;+ isActive?: boolean;+ isOpen?: boolean;+}++const NavigationIconLink = forwardRef<+ HTMLAnchorElement,+ NavigationIconButtonProps+>(+ (+ { link, isActive = false, isOpen = false, onClick = noop, ...props },+ ref+ ) => {+ const iconClasses = [+ "absolute left-3 top-3 flex rounded-md items-center justify-center",+ // Layout and sizing+ ];++ const classes = [+ "group relative",+ "h-10 w-10 group-data-[state=expanded]:w-full",+ "transition-all duration-200",+ "flex items-center rounded-md",+ "group-data-[state=collapsed]:justify-center",+ "group-data-[state=expanded]:-space-x-2",+ "hover:bg-active/80 hover:text-active-foreground",+ `${+ isActive+ ? "bg-active text-active-foreground shadow-sm hover:text-active-foreground hover:bg-active/90"+ : "hover:text-active-foreground"+ }`,+ "group/item",+ ];++ return (+ <Link+ role="button"+ aria-current={isActive}+ ref={ref}+ to={link.to}+ {...props}+ onClick={onClick}+ className={cn(classes, props.className)}+ prefetch="intent"+ >+ <link.icon className={cn(...iconClasses)} />++ <span+ aria-hidden={isOpen || undefined}+ className={cn(+ "min-w-[128px] text-sm",+ "absolute left-7 group-data-[state=expanded]:left-12",+ "opacity-0 group-data-[state=expanded]:opacity-100"+ )}+ >+ {link.name}+ </span>+ </Link>+ );+ }+);+NavigationIconLink.displayName = "NavigationIconLink";++export default PrimaryNavigation;++function getModule(link: string) {+ return link.split("/")?.[2];+}diff --git a/apps/mes/app/components/index.ts b/apps/mes/app/components/index.tsnew file mode 100644index 0000000000..673f8d4ae4--- /dev/null+++ b/apps/mes/app/components/index.ts@@ -0,0 +1,4 @@+import Avatar from "./Avatar";+import PrimaryNavigation from "./PrimaryNavigation";++export { Avatar, PrimaryNavigation };diff --git a/apps/mes/app/entry.client.tsx b/apps/mes/app/entry.client.tsxnew file mode 100644index 0000000000..6ebc2c895e--- /dev/null+++ b/apps/mes/app/entry.client.tsx@@ -0,0 +1,34 @@+import { POSTHOG_API_HOST, POSTHOG_PROJECT_PUBLIC_KEY } from "@carbon/auth";+import { OperatingSystemContextProvider } from "@carbon/react";+import { I18nProvider } from "@react-aria/i18n";+import { RemixBrowser } from "@remix-run/react";+import posthog from "posthog-js";+import { startTransition, useEffect } from "react";+import { hydrateRoot } from "react-dom/client";++function PosthogInit() {+ useEffect(() => {+ posthog.init(POSTHOG_PROJECT_PUBLIC_KEY, {+ api_host: POSTHOG_API_HOST,+ autocapture: false,+ capture_pageview: false,+ });+ }, []);+ return null;+}++startTransition(() => {+ hydrateRoot(+ document,+ <OperatingSystemContextProvider+ platform={window.navigator.userAgent.includes("Mac") ? "mac" : "windows"}+ >+ <I18nProvider+ locale={navigator.language ?? navigator.languages?.[0] ?? "en-US"}+ >+ <RemixBrowser />+ </I18nProvider>+ <PosthogInit />+ </OperatingSystemContextProvider>+ );+});diff --git a/apps/mes/app/entry.server.tsx b/apps/mes/app/entry.server.tsxnew file mode 100644index 0000000000..0cb74d5a84--- /dev/null+++ b/apps/mes/app/entry.server.tsx@@ -0,0 +1,40 @@+import type { OperatingSystemPlatform } from "@carbon/react";+import { OperatingSystemContextProvider } from "@carbon/react";+import { I18nProvider } from "@react-aria/i18n";+import { RemixServer } from "@remix-run/react";+import type { EntryContext } from "@vercel/remix";+import { handleRequest } from "@vercel/remix";++import { parseAcceptLanguage } from "intl-parse-accept-language";++export default async function (+ request: Request,+ responseStatusCode: number,+ responseHeaders: Headers,+ remixContext: EntryContext+) {+ const acceptLanguage = request.headers.get("accept-language");+ const locales = parseAcceptLanguage(acceptLanguage, {+ validate: Intl.DateTimeFormat.supportedLocalesOf,+ });++ // get whether it's a mac or pc from the headers+ const platform: OperatingSystemPlatform = request.headers+ .get("user-agent")+ ?.includes("Mac")+ ? "mac"+ : "windows";+ let remixServer = (+ <OperatingSystemContextProvider platform={platform}>+ <I18nProvider locale={locales?.[0] ?? "en-US"}>+ <RemixServer context={remixContext} url={request.url} />+ </I18nProvider>+ </OperatingSystemContextProvider>+ );+ return handleRequest(+ request,+ responseStatusCode,+ responseHeaders,+ remixServer+ );+}diff --git a/apps/mes/app/hooks/index.ts b/apps/mes/app/hooks/index.tsnew file mode 100644index 0000000000..a3062fc453--- /dev/null+++ b/apps/mes/app/hooks/index.ts@@ -0,0 +1,6 @@+import { useMode } from "./useMode";+import { useOptimisticLocation } from "./useOptimisticLocation";+import { useRouteData } from "./useRouteData";+import { useUser } from "./useUser";++export { useMode, useOptimisticLocation, useRouteData, useUser };diff --git a/apps/mes/app/hooks/useMode.tsx b/apps/mes/app/hooks/useMode.tsxnew file mode 100644index 0000000000..619332f725--- /dev/null+++ b/apps/mes/app/hooks/useMode.tsx@@ -0,0 +1,32 @@+import { useFetchers } from "@remix-run/react";+import type { Mode } from "~/types/validators";+import { modeValidator } from "~/types/validators";+import { path } from "~/utils/path";+import { useRouteData } from "./useRouteData";++export function useOptimisticMode() {+ const fetchers = useFetchers();+ const modeFetcher = fetchers.find((f) => f.formAction === "/");++ if (modeFetcher && modeFetcher.formData) {+ const mode = { mode: modeFetcher.formData.get("mode") };+ const submission = modeValidator.safeParse(mode);++ if (submission.success) {+ return submission.data.mode;+ }+ }+}++export function useMode() {+ const optimisticMode = useOptimisticMode();+ const routeData = useRouteData<{ mode: Mode }>(path.to.root);++ let mode = routeData?.mode ?? "dark";++ if (optimisticMode && optimisticMode !== "system") {+ mode = optimisticMode;+ }++ return mode;+}diff --git a/apps/mes/app/hooks/useOptimisticLocation.ts b/apps/mes/app/hooks/useOptimisticLocation.tsnew file mode 100644index 0000000000..84eb784fa9--- /dev/null+++ b/apps/mes/app/hooks/useOptimisticLocation.ts@@ -0,0 +1,13 @@+// credit: Matt Aitken at trigger.dev+import { useLocation, useNavigation } from "@remix-run/react";++export function useOptimisticLocation() {+ const navigation = useNavigation();+ const location = useLocation();++ if (navigation.state === "idle" || !navigation.location) {+ return location;+ }++ return navigation.location;+}diff --git a/apps/mes/app/hooks/useRouteData.tsx b/apps/mes/app/hooks/useRouteData.tsxnew file mode 100644index 0000000000..9c6f2bf54a--- /dev/null+++ b/apps/mes/app/hooks/useRouteData.tsx@@ -0,0 +1,11 @@+import { useMatches } from "@remix-run/react";+import { useMemo } from "react";++export function useRouteData<T>(path: string): T | undefined {+ const matchingRoutes = useMatches();+ const route = useMemo(+ () => matchingRoutes.find((route) => route.pathname === path),+ [matchingRoutes, path]+ );+ return (route?.data as T) || undefined;+}diff --git a/apps/mes/app/hooks/useUrlParams.tsx b/apps/mes/app/hooks/useUrlParams.tsxnew file mode 100644index 0000000000..df815dfcaf--- /dev/null+++ b/apps/mes/app/hooks/useUrlParams.tsx@@ -0,0 +1,43 @@+import { useSearchParams, useSubmit } from "@remix-run/react";+import { useCallback } from "react";++export function useUrlParams(): [+ URLSearchParams,+ (+ params: Record<string, string | string[] | number | undefined | null>+ ) => void+] {+ const submit = useSubmit();+ const [searchParams] = useSearchParams();++ const setSearchParams = useCallback(+ (params: Record<string, string | string[] | number | undefined | null>) => {+ Object.entries(params).forEach(([name, value]) => {+ if (value) {+ if (Array.isArray(value)) {+ if (value.length === 0) {+ searchParams.delete(name);+ } else {+ value.forEach((v, i) => {+ if (i === 0) {+ searchParams.set(name, v.toString());+ } else {+ searchParams.append(name, v.toString());+ }+ });+ }+ } else {+ searchParams.set(name, value.toString());+ }+ } else {+ searchParams.delete(name);+ }+ });++ submit(searchParams);+ },+ [submit, searchParams]+ );++ return [searchParams, setSearchParams];+}diff --git a/apps/mes/app/hooks/useUser.tsx b/apps/mes/app/hooks/useUser.tsxnew file mode 100644index 0000000000..1de0128234--- /dev/null+++ b/apps/mes/app/hooks/useUser.tsx@@ -0,0 +1,62 @@+import { path } from "~/utils/path";+import { useRouteData } from "./useRouteData";++type PersonalData = {+ id: string;+ email: string;+ firstName: string;+ lastName: string;+ avatarUrl: string | null;+};++type Company = {+ id: string;+ name: string;+ logo: string | null;+};++type User = PersonalData & {+ company: Company;+};++export function useUser(): User {+ const data = useRouteData<{+ company: unknown;+ user: unknown;+ }>(path.to.authenticatedRoot);++ if (+ data?.company &&+ isCompany(data.company) &&+ data?.user &&+ isUser(data.user)+ ) {+ return {+ ...data.user,+ company: data.company,+ };+ }++ // TODO: force logout -- the likely cause is development changes+ throw new Error(+ "useUser must be used within an authenticated route. If you are seeing this error, you are likely in development and have changed the session variables. Try deleting the cookies."+ );+}++function isCompany(value: any): value is Company {+ return (+ typeof value.id === "string" &&+ typeof value.name === "string" &&+ (typeof value.logo === "string" || value.logo === null)+ );+}++function isUser(value: any): value is User {+ return (+ typeof value.id === "string" &&+ typeof value.email === "string" &&+ typeof value.firstName === "string" &&+ typeof value.lastName === "string" &&+ "avatarUrl" in value+ );+}diff --git a/apps/mes/app/root.tsx b/apps/mes/app/root.tsxnew file mode 100644index 0000000000..30ba504ba4--- /dev/null+++ b/apps/mes/app/root.tsx@@ -0,0 +1,181 @@+import { error, getBrowserEnv } from "@carbon/auth";+import { getSessionFlash } from "@carbon/auth/session.server";+import { validator } from "@carbon/form";+import { Button, Heading, toast } from "@carbon/react";+import {+ Links,+ Meta,+ Outlet,+ Scripts,+ ScrollRestoration,+ isRouteErrorResponse,+ useLoaderData,+ useRouteError,+} from "@remix-run/react";+import { Analytics } from "@vercel/analytics/react";+import type {+ ActionFunctionArgs,+ LoaderFunctionArgs,+ MetaFunction,+} from "@vercel/remix";+import { json } from "@vercel/remix";+import React, { useEffect } from "react";+import { getMode, setMode } from "~/services/mode.server";+import Background from "~/styles/background.css?url";+import NProgress from "~/styles/nprogress.css?url";+import Tailwind from "~/styles/tailwind.css?url";++import { useMode } from "./hooks/useMode";+import { modeValidator } from "./types/validators";++// export const config = { runtime: "edge" };++export function links() {+ return [+ { rel: "stylesheet", href: Tailwind },+ { rel: "stylesheet", href: Background },+ { rel: "stylesheet", href: NProgress },+ { rel: "stylesheet", href: "/assets/theme.css" },+ ];+}++export const meta: MetaFunction = () => {+ return [+ {+ title: "CarbonOS | MES",+ },+ ];+};++export async function loader({ request }: LoaderFunctionArgs) {+ const {+ POSTHOG_API_HOST,+ POSTHOG_PROJECT_PUBLIC_KEY,+ SUPABASE_API_URL,+ SUPABASE_ANON_PUBLIC,+ } = getBrowserEnv();++ const sessionFlash = await getSessionFlash(request);++ return json(+ {+ env: {+ POSTHOG_API_HOST,+ POSTHOG_PROJECT_PUBLIC_KEY,+ SUPABASE_API_URL,+ SUPABASE_ANON_PUBLIC,+ },+ mode: getMode(request),+ result: sessionFlash?.result,+ },+ {+ headers: sessionFlash?.headers,+ }+ );+}++export async function action({ request }: ActionFunctionArgs) {+ const validation = await validator(modeValidator).validate(+ await request.formData()+ );++ if (validation.error) {+ return json(error(validation.error, "Invalid mode"), {+ status: 400,+ });+ }++ return json(+ {},+ {+ headers: { "Set-Cookie": setMode(validation.data.mode) },+ }+ );+}++function Document({+ children,+ title = "CarbonOS",+ mode = "dark",+}: {+ children: React.ReactNode;+ title?: string;+ mode?: "light" | "dark";+}) {+ return (+ <html lang="en" className={`${mode} h-full overflow-x-hidden`}>+ <head>+ <meta charSet="utf-8" />+ <meta name="viewport" content="width=device-width, initial-scale=1" />+ <Meta />+ <title>{title}</title>+ <Links />+ </head>+ <body className="h-full bg-background antialiased selection:bg-[#00cc9937] selection:text-[#007763fd] dark:selection:bg-[#00fff61d] dark:selection:text-[#67ffded2]">+ {children}++ <ScrollRestoration />+ <Scripts />+ <Analytics />+ </body>+ </html>+ );+}++export default function App() {+ const loaderData = useLoaderData<typeof loader>();+ const env = loaderData?.env ?? {};+ const result = loaderData?.result;++ /* Toast Messages */+ useEffect(() => {+ if (result?.success === true) {+ toast.success(result.message);+ } else if (result?.message) {+ toast.error(result.message);+ }+ }, [result]);++ /* Dark/Light Mode */+ const mode = useMode();++ return (+ <Document mode={mode}>+ <Outlet />+ <script+ dangerouslySetInnerHTML={{+ __html: `window.env = ${JSON.stringify(env)}`,+ }}+ />+ </Document>+ );+}++export function ErrorBoundary() {+ const error = useRouteError();++ const message = isRouteErrorResponse(error)+ ? error.data.message ?? error.data+ : error instanceof Error+ ? error.message+ : String(error);++ return (+ <Document title="Error!">+ <div className="dark">+ <div className="flex flex-col w-full h-screen bg-zinc-900 items-center justify-center space-y-4 ">+ <img+ src="/carbon-logo-light.png"+ alt="Carbon Logo"+ className="block max-w-[60px]"+ />+ <Heading size="h1">Something went wrong</Heading>+ <p className="text-muted-foreground max-w-2xl">{message}</p>+ <Button onClick={() => (window.location.href = "/")}>+ Back Home+ </Button>+ </div>+ </div>+ </Document>+ );+}diff --git a/apps/mes/app/routes/_index.tsx b/apps/mes/app/routes/_index.tsxnew file mode 100644index 0000000000..b6351f7e23--- /dev/null+++ b/apps/mes/app/routes/_index.tsx@@ -0,0 +1,16 @@+import { requireAuthSession } from "@carbon/auth/session.server";+import { redirect, type LoaderFunctionArgs } from "@vercel/remix";+import { path } from "~/utils/path";++export async function loader({ request }: LoaderFunctionArgs) {+ await requireAuthSession(request);+ throw redirect(path.to.authenticatedRoot);+}++export default function IndexRoute() {+ return (+ <p>+ Oops. You shouldn't see this page. Eventually it will be a landing page.+ </p>+ );+}diff --git a/apps/mes/app/routes/_public+/_layout.tsx b/apps/mes/app/routes/_public+/_layout.tsxnew file mode 100644index 0000000000..023fb41efe--- /dev/null+++ b/apps/mes/app/routes/_public+/_layout.tsx@@ -0,0 +1,204 @@+import { Outlet, useLoaderData } from "@remix-run/react";+import { BsHexagonFill } from "react-icons/bs";++import type { LoaderFunctionArgs } from "@vercel/remix";++export async function loader({ request }: LoaderFunctionArgs) {+ return {+ data: getRandomQuote(),+ };+}++export default function PublicRoute() {+ const { data } = useLoaderData<typeof loader>();+ return (+ <div className="container relative h-full flex-col items-center justify-center grid lg:max-w-none lg:grid-cols-2 lg:px-0">+ <div className="relative hidden h-full flex-col bg-muted p-10 text-white lg:flex dark:border-r">+ <div className="absolute inset-0 bg-zinc-900" />+ <div className="relative z-20 flex items-center text-lg font-medium">+ <BsHexagonFill className="w-6 h-6 mr-2" />+ CarbonOS+ </div>+ {data && (+ <div className="relative z-20 mt-auto">+ <blockquote className="space-y-2">+ <p className="text-lg">“{data?.quote}”</p>+ <footer className="text-sm">{data?.source}</footer>+ </blockquote>+ </div>+ )}+ </div>+ <div className="lg:p-8">+ <div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">+ <Outlet />+ </div>+ </div>+ </div>+ );+}++function getRandomQuote() {+ const randomQuote = quotes[Math.floor(Math.random() * quotes.length)];+ return randomQuote;+}++const quotes = [+ {+ quote: "Nothing can be changed until it is faced.",+ source: "James Baldwin",+ },+ {+ quote:+ "The Sun will rise and set regardless. What we choose to do with the light while it's here is up to us. Journey wisely.",+ source: "Alex Elle",+ },+ {+ quote: "I am unfolding slowly because blooming takes time.",+ source: "Alex Elle",+ },+ {+ quote: "Someone once told me love isn’t perfect—or predictable.",+ source: "Lauren Morrill",+ },+ {+ quote:+ "Sometimes you climb out of bed in the morning and you think, I'm not going to make it, but you laugh inside — remembering all the times you've felt that way",+ source: "Charles Bukowski",+ },+ {+ quote: "If you can't beat the fear, just do it scared.",+ source: "Glennon Doyle",+ },+ {+ quote: "There is a crack in everything. That's how the light gets in.",+ source: "Rumi",+ },+ {+ quote: "We must bring our own light into the darkness.",+ source: "Charles Bukowski",+ },+ {+ quote: "You are not too old. And it is not too late.",+ source: "Rainer Maria Rilke",+ },+ {+ quote: "There is nothing holding you back in life more than yourself.",+ source: "Brianna Wiest",+ },+ {+ quote:+ "Another person's success is not the absence of your own. Another person's progress is not the absence of your own. Another person's happiness is not the absense of your own.",+ source: "Brianna Wiest",+ },+ {+ quote:+ "The things we lose are not losses. They are entry ways. They are the world saying, sometimes sharply, there is something else out there.",+ source: "Brianna Wiest",+ },+ {+ quote: "You are allowed to outgrow people.",+ source: "Mantra Magazine",+ },+ {+ quote:+ "Stop feeling bad for outgrowing people who had the chance to grow with you.",+ source: "Hunter Pauley",+ },+ {+ quote: "Don't let someone live rent-free in your head.",+ source: "Ann Landers",+ },+ {+ quote:+ "Not everything that is faced can be changed, but nothing can be changed until it is faced.",+ source: "James Baldwin",+ },+ {+ quote: "No force on earth can stop an idea whose time has come.",+ source: "Victor Hugo",+ },+ {+ quote: "Learning never exhausts the mind.",+ source: "Leonardo da Vinci",+ },+ {+ quote: "The journey of a thousand miles begins with one step.",+ source: "Lao Tzu",+ },+ {+ quote: "If opportunity doesn't knock, build a door.",+ source: "Milton Berle",+ },+ {+ quote: "Everything has beauty, but not everyone sees it.",+ source: "Confucius",+ },+ {+ quote:+ "The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart.",+ source: "Helen Keller",+ },+ {+ quote: "Simplicity is the ultimate sophistication.",+ source: "Leonardo da Vinci",+ },+ {+ quote: "The best revenge is massive success.",+ source: "Frank Sinatra",+ },+ {+ quote:+ "The distance between insanity and genius is measured only by success.",+ source: "Bruce Feirstein",+ },+ {+ quote: "Success is the sum of small efforts, repeated day-in and day-out.",+ source: "Robert Collier",+ },+ {+ quote: "The mind is everything. What you think you become.",+ source: "Gautama Buddha",+ },+ {+ quote: "Peace comes from within. Do not seek it without.",+ source: "Gautama Buddha",+ },+ {+ quote:+ "What you think, you become. What you feel, you attract. What you imagine, you create.",+ source: "The Buddha",+ },+ {+ quote: "Share your knowledge. It is a way to achieve immortality.",+ source: "The Dalai Lama",+ },+ {+ quote: "Man is made by his belief. As he believes, so he is.",+ source: "Bhagavad Gita",+ },+ {+ quote:+ "Life’s most persistent and urgent question is, ‘What are you doing for others?’",+ source: "Martin Luther King, Jr.",+ },+ {+ quote: "Once you choose hope, anythings possible.",+ source: "Christopher Reeve",+ },+ {+ quote: "Learn from yesterday, live for today, hope for tomorrow.",+ source: "Albert Einstein",+ },+ {+ quote: "Stay hungry, stay foolish.",+ source: "Steve Jobs",+ },+ {+ quote: "The only way to do great work is to love what you do.",+ source: "Steve Jobs",+ },+ {+ quote: "You are never too old to set another goal or to dream a new dream.",+ source: "C.S. Lewis",+ },+];diff --git a/apps/mes/app/routes/_public+/callback.tsx b/apps/mes/app/routes/_public+/callback.tsxnew file mode 100644index 0000000000..ca5a95bc32--- /dev/null+++ b/apps/mes/app/routes/_public+/callback.tsx@@ -0,0 +1,132 @@+import {+ assertIsPost,+ callbackValidator,+ carbonClient,+ error,+ getCarbonServiceRole,+} from "@carbon/auth";+import { refreshAccessToken } from "@carbon/auth/auth.server";+import {+ commitAuthSession,+ destroyAuthSession,+ flash,+ getAuthSession,+} from "@carbon/auth/session.server";+import { validator } from "@carbon/form";+import { useFetcher } from "@remix-run/react";+import type { ActionFunctionArgs, LoaderFunctionArgs } from "@vercel/remix";+import { json, redirect } from "@vercel/remix";+import { useEffect, useRef } from "react";++import { path } from "~/utils/path";++export async function loader({ request }: LoaderFunctionArgs) {+ const authSession = await getAuthSession(request);++ if (authSession) await destroyAuthSession(request);++ return json({});+}++export async function action({ request }: ActionFunctionArgs) {+ assertIsPost(request);++ const validation = await validator(callbackValidator).validate(+ await request.formData()+ );++ if (validation.error) {+ return json(error(validation.error, "Invalid callback form"), {+ status: 400,+ });+ }++ const { refreshToken, userId } = validation.data;+ const carbonServiceClient = getCarbonServiceRole();+ const companies = await carbonServiceClient+ .from("userToCompany")+ .select("companyId")+ .eq("userId", userId);+ if (!companies.data || companies.data.length < 1) {+ return json(error(companies.error, "No companies found for user"), {+ status: 500,+ });+ }+ const authSession = await refreshAccessToken(+ refreshToken,+ companies.data?.[0].companyId+ );+ if (!authSession) {+ return redirect(+ path.to.root,+ await flash(request, error(authSession, "Invalid refresh token"))+ );+ }++ return redirect(path.to.authenticatedRoot, {+ headers: {+ "Set-Cookie": await commitAuthSession(request, {+ authSession,+ }),+ },+ });+}++export default function AuthCallback() {+ const fetcher = useFetcher<{}>();+ const isAuthenticating = useRef(false);++ useEffect(() => {+ const {+ data: { subscription },+ } = carbonClient.auth.onAuthStateChange((event, carbonSession) => {+ if (+ ["SIGNED_IN", "INITIAL_SESSION"].includes(event) &&+ !isAuthenticating.current+ ) {+ isAuthenticating.current = true;++ // carbon sdk has ability to read url fragment that contains your token after third party provider redirects you here+ // this fragment url looks like https://.....#access_token=evxxxxxxxx&refresh_token=xxxxxx, and it's not readable server-side (Oauth security)+ // carbon auth listener gives us a user session, based on what it founds in this fragment url+ // we can't use it directly, client-side, because we can't access sessionStorage from here++ // we should not trust what's happen client side+ // so, we only pick the refresh token, and let's back-end getting user session from it+ const refreshToken = carbonSession?.refresh_token;+ const userId = carbonSession?.user.id;++ if (!refreshToken || !userId) return;++ const formData = new FormData();+ formData.append("refreshToken", refreshToken);+ formData.append("userId", userId);++ fetcher.submit(formData, { method: "post" });+ }+ });++ return () => {+ // prevent memory leak. Listener stays alive 👨🎤+ subscription.unsubscribe();+ };+ }, [fetcher]);++ return (+ <div className="flex flex-col items-center justify-center">+ <div>+ <img+ src="/carbon-logo-dark.png"+ alt="Carbon Logo"+ className="block dark:hidden max-w-[100px] mb-3"+ />+ <img+ src="/carbon-logo-light.png"+ alt="Carbon Logo"+ className="hidden dark:block max-w-[100px] mb-3"+ />+ </div>+ <p className="text-muted-foreground">Loading...</p>+ </div>+ );+}diff --git a/apps/mes/app/routes/_public+/forgot-password.tsx b/apps/mes/app/routes/_public+/forgot-password.tsxnew file mode 100644index 0000000000..658564450a--- /dev/null+++ b/apps/mes/app/routes/_public+/forgot-password.tsx@@ -0,0 +1,125 @@+import type { Result } from "@carbon/auth";+import {+ assertIsPost,+ error,+ forgotPasswordValidator,+ success,+} from "@carbon/auth";+import { sendMagicLink } from "@carbon/auth/auth.server";+import { getAuthSession } from "@carbon/auth/session.server";+import { getUserByEmail } from "@carbon/auth/users.server";+import {+ Input,+ Submit,+ ValidatedForm,+ validationError,+ validator,+} from "@carbon/form";+import {+ Alert,+ AlertDescription,+ AlertTitle,+ Button,+ VStack,+} from "@carbon/react";+import { Link, useActionData } from "@remix-run/react";+import type {+ ActionFunctionArgs,+ LoaderFunctionArgs,+ MetaFunction,+} from "@vercel/remix";+import { json, redirect } from "@vercel/remix";+import { LuAlertCircle, LuCheckCircle } from "react-icons/lu";++import { path } from "~/utils/path";++export const meta: MetaFunction = () => {+ return [+ {+ title: "Carbon Developers | Forgot Password",+ },+ ];+};++export async function loader({ request }: LoaderFunctionArgs) {+ const authSession = await getAuthSession(request);+ if (authSession) throw redirect(path.to.authenticatedRoot);+ return null;+}++export async function action({ request }: ActionFunctionArgs) {+ assertIsPost(request);+ const validation = await validator(forgotPasswordValidator).validate(+ await request.formData()+ );++ if (validation.error) {+ return validationError(validation.error);+ }++ const { email } = validation.data;+ const user = await getUserByEmail(email);++ if (user.data && user.data.active) {+ const authSession = await sendMagicLink(email);++ if (!authSession) {+ return json(error(authSession, "Failed to send magic link"), {+ status: 500,+ });+ }+ }++ return json(success("Success"));+}++export default function ForgotPasswordRoute() {+ const actionData = useActionData<Result>();++ return (+ <div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">+ <div className="flex space-y-2 justify-center">+ <img+ src="/carbon-logo-dark.png"+ alt="Carbon Logo"+ className="block dark:hidden max-w-[100px] mb-3"+ />+ <img+ src="/carbon-logo-light.png"+ alt="Carbon Logo"+ className="hidden dark:block max-w-[100px] mb-3"+ />+ </div>++ {actionData?.success ? (+ <Alert variant="success" className="[&>svg]:left-8 [&>svg]:top-8 p-8">+ <LuCheckCircle className="w-4 h-4" />+ <AlertTitle>Success</AlertTitle>+ <AlertDescription>+ If you have an account, you should receive an email shortly with a+ link to log in.+ </AlertDescription>+ </Alert>+ ) : (+ <ValidatedForm validator={forgotPasswordValidator} method="post">+ <VStack spacing={4}>+ <p>Please enter your email address to search for your account.</p>+ {actionData?.success === false && (+ <Alert variant="destructive">+ <LuAlertCircle className="w-4 h-4" />+ <AlertTitle>{actionData?.message}</AlertTitle>+ </Alert>+ )}+ <Input name="email" label="Email" />+ <Submit size="lg" className="w-full">+ Reset Password+ </Submit>+ <Button variant="link" asChild className="w-full">+ <Link to={path.to.login}>Back to login</Link>+ </Button>+ </VStack>+ </ValidatedForm>+ )}+ </div>+ );+}diff --git a/apps/mes/app/routes/_public+/healthcheck.tsx b/apps/mes/app/routes/_public+/healthcheck.tsxnew file mode 100644index 0000000000..a1f534da90--- /dev/null+++ b/apps/mes/app/routes/_public+/healthcheck.tsx@@ -0,0 +1,14 @@+import { getCarbonServiceRole } from "@carbon/auth";++export async function loader() {+ try {+ const client = getCarbonServiceRole();+ const test = await client.from("attributeDataType").select("*");+ if (test.error !== null) throw test.error;+ return new Response("OK");+ } catch (error: unknown) {+ // eslint-disable-next-line no-console+ console.log("healthcheck ❌", { error });+ return new Response("ERROR", { status: 500 });+ }+}diff --git a/apps/mes/app/routes/_public+/login.tsx b/apps/mes/app/routes/_public+/login.tsxnew file mode 100644index 0000000000..bcc1b88e7d--- /dev/null+++ b/apps/mes/app/routes/_public+/login.tsx@@ -0,0 +1,143 @@+import type { Result } from "@carbon/auth";+import {+ assertIsPost,+ error,+ loginValidator,+ safeRedirect,+} from "@carbon/auth";+import { signInWithEmail, verifyAuthSession } from "@carbon/auth/auth.server";+import { commitAuthSession, getAuthSession } from "@carbon/auth/session.server";+import {+ Hidden,+ Input,+ Password,+ Submit,+ ValidatedForm,+ validationError,+ validator,+} from "@carbon/form";+import { Alert, AlertTitle, Button, VStack } from "@carbon/react";+import { Link, useActionData, useSearchParams } from "@remix-run/react";+import type {+ ActionFunctionArgs,+ LoaderFunctionArgs,+ MetaFunction,+} from "@vercel/remix";+import { json, redirect } from "@vercel/remix";+import posthog from "posthog-js";+import { LuAlertCircle } from "react-icons/lu";++import { path } from "~/utils/path";++export const meta: MetaFunction = () => {+ return [{ title: "Carbon Developers | Login" }];+};++export async function loader({ request }: LoaderFunctionArgs) {+ const authSession = await getAuthSession(request);+ if (authSession && (await verifyAuthSession(authSession))) {+ if (authSession) throw redirect(path.to.authenticatedRoot);+ }++ return null;+}++export async function action({ request }: ActionFunctionArgs) {+ assertIsPost(request);+ const validation = await validator(loginValidator).validate(+ await request.formData()+ );++ if (validation.error) {+ return validationError(validation.error);+ }++ const { email, password, redirectTo } = validation.data;++ const authSession = await signInWithEmail(email, password);++ if (!authSession) {+ // delay on incorrect password as minimal brute force protection+ await new Promise((resolve) => setTimeout(resolve, 2000));+ return json(error(authSession, "Invalid email/password"), {+ status: 500,+ });+ }++ throw redirect(safeRedirect(redirectTo), {+ headers: {+ "Set-Cookie": await commitAuthSession(request, {+ authSession,+ }),+ },+ });+}++export default function LoginRoute() {+ const result = useActionData<Result>();+ const [searchParams] = useSearchParams();+ const redirectTo = searchParams.get("redirectTo") ?? undefined;++ const handleClick = () => {+ posthog.capture("sign_in_clicked");+ };++ return (+ <div className="mx-auto flex w-full flex-col justify-center space-y-6 sm:w-[350px]">+ <div className="flex space-y-2 justify-center">+ <img+ src="/carbon-logo-dark.png"+ alt="Carbon Logo"+ className="block dark:hidden max-w-[100px] mb-3"+ />+ <img+ src="/carbon-logo-light.png"+ alt="Carbon Logo"+ className="hidden dark:block max-w-[100px] mb-3"+ />+ </div>++ <ValidatedForm+ validator={loginValidator}+ defaultValues={{ redirectTo }}+ method="post"+ >+ <VStack spacing={4}>+ {result && result?.message && (+ <Alert variant="destructive">+ <LuAlertCircle className="w-4 h-4" />+ <AlertTitle>{result?.message}</AlertTitle>+ </Alert>+ )}++ <Input name="email" label="Email" />+ <Password name="password" label="Password" type="password" />+ <Hidden name="redirectTo" value={redirectTo} type="hidden" />+ <Submit size="lg" className="w-full" onClick={handleClick}>+ Sign In+ </Submit>+ <Button variant="link" asChild className="w-full">+ <Link to={path.to.forgotPassword}>Forgot Password</Link>+ </Button>+ </VStack>+ </ValidatedForm>+ <p className="px-10 text-center text-sm text-muted-foreground">+ By clicking continue, you agree to our{" "}+ <Link+ to="/terms"+ className="underline underline-offset-4 hover:text-primary"+ >+ Terms of Service+ </Link>{" "}+ and{" "}+ <Link+ to="/privacy"+ className="underline underline-offset-4 hover:text-primary"+ >+ Privacy Policy+ </Link>+ .+ </p>+ </div>+ );+}diff --git a/apps/mes/app/routes/_public+/logout.tsx b/apps/mes/app/routes/_public+/logout.tsxnew file mode 100644index 0000000000..53cc2b12b6--- /dev/null+++ b/apps/mes/app/routes/_public+/logout.tsx@@ -0,0 +1,16 @@+import { assertIsPost } from "@carbon/auth";+import { destroyAuthSession } from "@carbon/auth/session.server";+import type { ActionFunctionArgs } from "@vercel/remix";+import { redirect } from "@vercel/remix";++import { path } from "~/utils/path";++export async function action({ request }: ActionFunctionArgs) {+ assertIsPost(request);++ return destroyAuthSession(request);+}++export async function loader() {+ throw redirect(path.to.root);+}diff --git a/apps/mes/app/routes/_public+/refresh-session.tsx b/apps/mes/app/routes/_public+/refresh-session.tsxnew file mode 100644index 0000000000..9b512a3289--- /dev/null+++ b/apps/mes/app/routes/_public+/refresh-session.tsx@@ -0,0 +1,37 @@+import { assertIsPost } from "@carbon/auth";+import {+ commitAuthSession,+ refreshAuthSession,+} from "@carbon/auth/session.server";+import { useNavigate } from "@remix-run/react";+import type { ActionFunctionArgs } from "@vercel/remix";+import { json, redirect } from "@vercel/remix";++import { path } from "~/utils/path";++export async function loader() {+ throw redirect(path.to.authenticatedRoot);+}++export async function action({ request }: ActionFunctionArgs) {+ assertIsPost(request);++ const authSession = await refreshAuthSession(request);++ return json(+ { success: true },+ {+ headers: {+ "Set-Cookie": await commitAuthSession(request, {+ authSession,+ }),+ },+ }+ );+}++export function ErrorBoundary() {+ const navigate = useNavigate();+ navigate(path.to.authenticatedRoot);+ return null;+}diff --git a/apps/mes/app/routes/assets+/theme[.]css.ts b/apps/mes/app/routes/assets+/theme[.]css.tsnew file mode 100644index 0000000000..a6c9a8fe35--- /dev/null+++ b/apps/mes/app/routes/assets+/theme[.]css.ts@@ -0,0 +1,27 @@+import { getThemeCode, themes } from "@carbon/utils";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { getTheme } from "~/services/theme.server";++// export const config = { runtime: "nodejs" };++export async function loader({ request }: LoaderFunctionArgs) {+ const theme = getTheme(request) as string;++ const selectedTheme = themes.find((t) => t.name === theme);++ if (!selectedTheme) {+ return new Response("", {+ headers: {+ "Content-Type": "text/css",+ },+ });+ }++ const css = getThemeCode(selectedTheme);++ return new Response(css, {+ headers: {+ "Content-Type": "text/css",+ },+ });+}diff --git a/apps/mes/app/routes/x+/_index.tsx b/apps/mes/app/routes/x+/_index.tsxnew file mode 100644index 0000000000..d56e10f963--- /dev/null+++ b/apps/mes/app/routes/x+/_index.tsx@@ -0,0 +1,38 @@+import { Heading, cn } from "@carbon/react";+import { getLocalTimeZone } from "@internationalized/date";+import { useLocale } from "@react-aria/i18n";+import { useMemo, type ComponentProps } from "react";+import { useUser } from "~/hooks";++export default function AppIndexRoute() {+ const user = useUser();+ const { locale } = useLocale();+ const date = new Date();++ const formatter = useMemo(+ () =>+ new Intl.DateTimeFormat(locale, {+ dateStyle: "full",+ timeZone: getLocalTimeZone(),+ }),+ [locale]+ );++ return (+ <div className="p-8 w-full h-full bg-muted">+ <Heading size="h3">Hello, {user.firstName}</Heading>+ <Subheading>{formatter.format(date)}</Subheading>+ <Hr />+ </div>+ );+}++const Hr = () => (+ <hr className="h-px my-8 bg-black/10 border-0 dark:bg-white/10" />+);++const Subheading = ({ children, className }: ComponentProps<"p">) => (+ <p className={cn("text-muted-foreground text-base font-light", className)}>+ {children}+ </p>+);diff --git a/apps/mes/app/routes/x+/_layout.tsx b/apps/mes/app/routes/x+/_layout.tsxnew file mode 100644index 0000000000..9e417f9a52--- /dev/null+++ b/apps/mes/app/routes/x+/_layout.tsx@@ -0,0 +1,100 @@+import { Toaster, TooltipProvider } from "@carbon/react";+import { Outlet, useLoaderData, useNavigation } from "@remix-run/react";+import type { LoaderFunctionArgs } from "@vercel/remix";+import { json, redirect } from "@vercel/remix";+import NProgress from "nprogress";+import { useEffect } from "react";++import {+ CarbonProvider,+ getCarbon,+ getCompanies,+ getUser,+ VERCEL_URL,+} from "@carbon/auth";+import {+ destroyAuthSession,+ requireAuthSession,+} from "@carbon/auth/session.server";+import { PrimaryNavigation } from "~/components";++export const ERP_URL = VERCEL_URL?.includes("localhost")+ ? "http://localhost:3000"+ : `https://app.carbonos.dev`;++export async function loader({ request }: LoaderFunctionArgs) {+ const { accessToken, companyId, expiresAt, expiresIn, userId } =+ await requireAuthSession(request, { verify: true });++ // share a client between requests+ const client = getCarbon(accessToken);++ // parallelize the requests+ const [companies, user] = await Promise.all([+ getCompanies(client, userId),+ getUser(client, userId),+ ]);++ if (user.error || !user.data) {+ await destroyAuthSession(request);+ }++ const company = companies.data?.find((c) => c.companyId === companyId);+ if (!company) {+ throw redirect(ERP_URL);+ }++ return json({+ session: {+ accessToken,+ expiresIn,+ expiresAt,+ },+ company,+ companies: companies.data ?? [],+ user: user.data,+ });+}++export default function AuthenticatedRoute() {+ const { session } = useLoaderData<typeof loader>();++ const transition = useNavigation();++ /* NProgress */+ useEffect(() => {+ if (+ (transition.state === "loading" || transition.state === "submitting") &&+ !NProgress.isStarted()+ ) {+ NProgress.start();+ } else {+ NProgress.done();+ }+ }, [transition.state]);++ return (+ <CarbonProvider session={session}>+ <TooltipProvider>+ <div className="min-h-full flex flex-col">+ <div className="flex-none" />+ <div className="h-screen min-h-[0px] basis-0 flex-1">+ <div className="flex h-full">+ <PrimaryNavigation />+ <div className="flex w-full h-full">+ <div className="w-full h-full flex-1 overflow-hidden">+ <main className="h-full flex flex-col flex-1 max-w-[100vw] sm:max-w-[calc(100vw-56px)] overflow-x-hidden bg-muted">+ <main className="flex-1 overflow-y-auto max-h-[calc(100vh-49px)]">+ <Outlet />+ </main>+ </main>+ </div>+ </div>+ </div>+ </div>+ </div>+ <Toaster position="bottom-right" />+ </TooltipProvider>+ </CarbonProvider>+ );+}diff --git a/apps/mes/app/services/mode.server.ts b/apps/mes/app/services/mode.server.tsnew file mode 100644index 0000000000..7c772021f5--- /dev/null+++ b/apps/mes/app/services/mode.server.ts@@ -0,0 +1,21 @@+import * as cookie from "cookie";+import type { Mode } from "~/types/validators";++const cookieName = "mode";++export function getMode(request: Request): Mode | null {+ const cookieHeader = request.headers.get("cookie");+ const parsed = cookieHeader+ ? cookie.parse(cookieHeader)[cookieName]+ : "light";+ if (parsed === "light" || parsed === "dark") return parsed;+ return null;+}++export function setMode(mode: Mode | "system") {+ if (mode === "system") {+ return cookie.serialize(cookieName, "", { path: "/", maxAge: -1 });+ } else {+ return cookie.serialize(cookieName, mode, { path: "/", maxAge: 31536000 });+ }+}diff --git a/apps/mes/app/services/theme.server.ts b/apps/mes/app/services/theme.server.tsnew file mode 100644index 0000000000..6e24b6f0dc--- /dev/null+++ b/apps/mes/app/services/theme.server.ts@@ -0,0 +1,26 @@+import * as cookie from "cookie";++const cookieName = "theme";+const themes = [+ "zinc",+ "neutral",+ "red",+ "rose",+ "green",+ "blue",+ "yellow",+ "orange",+ "violet",+] as const;+type Theme = (typeof themes)[number];++export function getTheme(request: Request): Theme {+ const cookieHeader = request.headers.get("cookie");+ const parsed = cookieHeader ? cookie.parse(cookieHeader)[cookieName] : "zinc";+ if (themes.includes(parsed as Theme)) return parsed as Theme;+ return "zinc";+}++export function setTheme(theme: string) {+ return cookie.serialize(cookieName, theme, { path: "/", maxAge: 31536000 });+}diff --git a/apps/mes/app/styles/background.css b/apps/mes/app/styles/background.cssnew file mode 100644index 0000000000..0d626c7625--- /dev/null+++ b/apps/mes/app/styles/background.css@@ -0,0 +1,68 @@+/* Credit: https://cmdk.paco.me/ */++.background {+ width: 100vw;+ min-height: 100vh;+ position: fixed;+ display: flex;+ justify-content: center;+ padding: 120px 24px 160px 24px;+ pointer-events: none;+}++.background:before {+ background: radial-gradient(circle, rgba(2, 0, 36, 0) 0, #fafafa 100%);+ position: absolute;+ content: "";+ z-index: 2;+ width: 100%;+ height: 100%;+ top: 0;+}++.dark .background:before {+ background: radial-gradient(circle, rgba(2, 0, 36, 0) 0, #161616 100%);+}++.background:after {+ content: "";+ background-image: url("/grid.svg");+ z-index: 1;+ position: absolute;+ width: 100%;+ height: 100%;+ top: 0;+ opacity: 0.4;+ filter: invert(1);+}++.gradient {+ height: fit-content;+ z-index: 3;+ width: 100%;+ max-width: 640px;+ background-image: radial-gradient(+ at 27% 37%,+ hsla(215, 98%, 61%, 1) 0px,+ transparent 0%+ ),+ radial-gradient(at 97% 21%, hsla(125, 60%, 72%, 1) 0px, transparent 55%),+ radial-gradient(at 52% 99%, hsla(354, 40%, 61%, 1) 0px, transparent 55%),+ radial-gradient(at 10% 29%, hsla(256, 50%, 67%, 1) 0px, transparent 55%),+ radial-gradient(at 97% 96%, hsla(38, 40%, 74%, 1) 0px, transparent 55%),+ radial-gradient(at 33% 50%, hsla(222, 60%, 73%, 1) 0px, transparent 55%),+ radial-gradient(at 79% 53%, hsla(343, 20%, 79%, 1) 0px, transparent 55%);+ position: absolute;+ content: "";+ width: 100%;+ height: 100%;+ filter: blur(100px) saturate(150%);+ top: 80px;+ opacity: 0.15;+}++@media screen and (max-width: 640px) {+ .content {+ display: none;+ }+}diff --git a/apps/mes/app/styles/docs.css b/apps/mes/app/styles/docs.cssnew file mode 100644index 0000000000..13cecf88e8--- /dev/null+++ b/apps/mes/app/styles/docs.css@@ -0,0 +1,1592 @@+.Code {+ width: 100%;+}++.Code .prism-code {+ margin: 0;+ padding: 0.25rem;+ background-color: none;+ white-space: normal;+ word-break: break-word;+}++.Code .token-line {+ font-size: 0.875rem;+ line-height: 1.25rem;+}++.Code .token.function,+.Code .token.imports,+.Code .token.keyword.module,+.Code .token.property-access {+ --tw-text-opacity: 1 !important;+}++.Code .token.function,+.Code .token.keyword.module {+ font-style: normal !important;+}++.Code .token.console.class-name,+.Code .token.doc-comment.optional-parameter,+.Code .token.doc-comment.optional-parameter.punctuation,+.Code .token.doc-comment.parameter,+.Code .token.doc-comment.parameter.punctuation,+.Code .token.operator,+.Code .token.parameter,+.Code .token.plain,+.Code .token.punctuation {+ font-style: normal !important;+ --tw-text-opacity: 1 !important;+}++.Code .token.doc-comment.keyword,+.Code .token.keyword {+ font-style: normal !important;+}++.Code .token.string {+ font-style: normal !important;+ --tw-text-opacity: 1 !important;+}++.Code .token.constant {+ font-style: normal !important;+}++.Code .token.comment {+ font-style: normal !important;+ --tw-text-opacity: 1 !important;+}++.Code .token.number {+ --tw-text-opacity: 1 !important;+}++.Code .token.boolean,+.Code .token.doc-comment.class-name {+ --tw-text-opacity: 1;+}++.Code .codeBlock {+ margin-bottom: 0;+ overflow: hidden;+ overflow-wrap: break-word;+ white-space: pre-wrap;+}++.Code.codeBlockWrapper {+ position: relative;+}++.Code.codeBlockWrapper:hover .buttonContainer {+ visibility: visible;+ opacity: 1;+}++.Code .buttonContainer {+ right: 5px;+ top: 5px;+ opacity: 0;+ position: absolute;+ visibility: hidden;+ transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out,+ bottom 0.2s ease-in-out;+}++.Code .buttonContainer button {+ border-radius: 0.25rem;+ font-size: 0.75rem;+ line-height: 1rem;+ background: #011627;+ border: 1px solid #d6deeb;+ color: #d6deeb;+ cursor: pointer;+ line-height: 12px;+ outline: none;+ padding: 4px 8px;+}++.Code.codeBlockWrapper .sbui-btn-container {+ position: absolute;+ top: 2px;+ right: 3px;+ visibility: hidden;+ opacity: 0;+}++.Code.codeBlockWrapper:hover .sbui-btn-container {+ visibility: visible;+ opacity: 1;+}++.CustomCodeBlock {+ width: 100%;+}++.CustomCodeBlock .code-with-header pre {+ border-radius: 0 0 4px 4px;+}++.CustomCodeBlock .code-with-response pre {+ border-radius: 0;+}++.CustomCodeBlock .code-header {+ color: #ccc;+ padding: 5px 15px;+ border-radius: 4px 4px 0 0;+ font-size: 0.8rem;+ font-weight: 700;+ border-bottom: 1px solid #444;+}++.FunctionBlock h4 {+ margin-top: 36px;+ margin-bottom: 12px;+}++.FunctionBlock p {+ margin-top: 0;+ margin-bottom: 24px;+}++.Docs--inner-wrapper {+ background: linear-gradient(+ 90deg,+ hsl(var(--background)) 50%,+ hsl(var(--muted)) 50%+ );+ width: 100%;+}++.dark .Docs--inner-wrapper {+ background: linear-gradient(+ 90deg,+ hsl(var(--background)) 50%,+ hsl(var(--card)) 50%+ );+}++.Docs .doc-heading {+ font-weight: bold;+ margin-top: 1rem;+ width: 50%;+ padding-left: 1.5rem;+ padding-right: 1.5rem;+ text-transform: capitalize;+ --tw-text-opacity: 1;++ -webkit-hyphens: auto;+ hyphens: auto;+ max-width: 50%;+}++.Docs .doc-section {+ display: flex;+ border-bottom-width: 1px;+ --tw-border-opacity: 1;+ border-color: hsl(var(--border) / var(--tw-border-opacity));+}++.Docs.Docs--table-editor .doc-section--introduction .text {+ width: 85%;+}++.Docs.Docs--table-editor .doc-section--client-libraries {+ flex-direction: column;+ margin-bottom: 40px;+}++.Docs.Docs--table-editor .doc-section--client-libraries .code,+.Docs.Docs--table-editor .doc-section--client-libraries .text {+ width: 100%;+ max-width: none;+}++.Docs.Docs--table-editor .doc-section--client-libraries .code {+ margin-bottom: 20px;+}++.Docs .doc-section article:first-child {+ color: var(--tw-prose-body);+ max-width: 65ch;+}++.Docs+ .doc-section+ article:first-child+ :where(p):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.25em;+ margin-bottom: 1.25em;+ font-weight: 400;+}++.Docs+ .doc-section+ article:first-child+ :where([class~="lead"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ color: var(--tw-prose-lead);+ font-size: 1.25em;+ line-height: 1.6;+ margin-top: 1.2em;+ margin-bottom: 1.2em;+}++.Docs+ .doc-section+ article:first-child+ :where(a):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ text-decoration: underline;+ font-weight: 400;+ position: relative;+ transition: all 0.18s ease;+ padding-bottom: 2px;+ opacity: 1;+ text-decoration-line: underline;+ text-decoration-color: hsl(var(--muted-foreground));+ text-decoration-thickness: 1px;+ text-underline-offset: 2px;+}++.Docs+ .doc-section+ article:first-child+ :where(strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-bold);+ font-weight: 600;+}++.Docs+ .doc-section+ article:first-child+ :where(a strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote strong):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(thead th strong):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(ol):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ list-style-type: none;+ margin-top: 1.25em;+ margin-bottom: 3rem;+ padding-left: 1rem;+ counter-reset: item;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="A"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: upper-alpha;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="a"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: lower-alpha;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="A s"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: upper-alpha;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="a s"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: lower-alpha;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="I"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: upper-roman;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="i"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: lower-roman;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="I s"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: upper-roman;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="i s"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: lower-roman;+}++.Docs+ .doc-section+ article:first-child+ :where(ol[type="1"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ list-style-type: decimal;+}++.Docs+ .doc-section+ article:first-child+ :where(ul):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ list-style-type: none;+ margin-top: 1.25em;+ margin-bottom: 1.25em;+ padding-left: 1rem;+}++.Docs+ .doc-section+ article:first-child+ :where(ol > li):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ )::marker {+ font-weight: 400;+ color: var(--tw-prose-counters);+}++.Docs+ .doc-section+ article:first-child+ :where(ul > li):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ )::marker {+ color: var(--tw-prose-bullets);+}++.Docs+ .doc-section+ article:first-child+ :where(dt):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 600;+ margin-top: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(hr):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border-color: var(--tw-prose-hr);+ border-top-width: 1px;+ margin-top: 3em;+ margin-bottom: 3em;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 500;+ font-style: italic;+ color: var(--tw-prose-quotes);+ border-left-width: 0.25rem;+ border-left-color: var(--tw-prose-quote-borders);+ quotes: "\201C""\201D""\2018""\2019";+ margin-top: 1.6em;+ margin-bottom: 1.6em;+ padding-left: 1em;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote p:first-of-type):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):before {+ content: open-quote;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote p:last-of-type):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):after {+ content: close-quote;+}++.Docs+ .doc-section+ article:first-child+ :where(h1):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 800;+ font-size: 2.25em;+ margin-bottom: 0.8888889em;+ line-height: 1.1111111;+}++.Docs+ .doc-section+ article:first-child+ :where(h1 strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 900;+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(h2):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 700;+ font-size: 1.5em;+ margin-top: 2em;+ margin-bottom: 1em;+ line-height: 1.3333333;+}++.Docs+ .doc-section+ article:first-child+ :where(h2 strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 800;+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(h3):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 600;+ font-size: 1.25em;+ margin-top: 1.6em;+ margin-bottom: 0.6em;+ line-height: 1.6;+}++.Docs+ .doc-section+ article:first-child+ :where(h3 strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 700;+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(h4):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 600;+ margin-top: 1.5em;+ margin-bottom: 0.5em;+ line-height: 1.5;+ font-size: 1.15em;+}++.Docs+ .doc-section+ article:first-child+ :where(h4 strong):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 700;+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(img):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 2em;+ margin-bottom: 2em;+}++.Docs+ .doc-section+ article:first-child+ :where(picture):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ display: block;+ margin-top: 2em;+ margin-bottom: 2em;+}++.Docs+ .doc-section+ article:first-child+ :where(kbd):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-weight: 500;+ font-family: inherit;+ color: var(--tw-prose-kbd);+ box-shadow: 0 0 0 1px rgb(var(--tw-prose-kbd-shadows) / 10%),+ 0 3px 0 rgb(var(--tw-prose-kbd-shadows) / 10%);+ font-size: 0.875em;+ padding: 0.1875em 0.375em;+}++.Docs+ .doc-section+ article:first-child+ :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-code);+ font-weight: 400;+ font-size: 0.875em;+ padding: 0.2rem 0.4rem;+ background-color: hsl(var(--muted));+ border: 1px solid hsl(var(--muted));+ border-radius: 0.5rem;+}++.Docs+ .doc-section+ article:first-child+ :where(code):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):before {+ content: "";+}++.Docs+ .doc-section+ article:first-child+ :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *)):after {+ content: "";+}++.Docs+ .doc-section+ article:first-child+ :where(a code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(h1 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(h2 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+ font-size: 0.875em;+}++.Docs+ .doc-section+ article:first-child+ :where(h3 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+ font-size: 0.9em;+}++.Docs+ .doc-section+ article:first-child+ :where(h4 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote code):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(thead th code):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ color: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(pre):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-pre-code);+ background-color: var(--tw-prose-pre-bg);+ overflow-x: auto;+ font-weight: 400;+ font-size: 0.875em;+ line-height: 1.7142857;+ margin-top: 1.7142857em;+ margin-bottom: 32px;+ border-radius: 0.375rem;+ background: none;+ padding: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(pre code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ background-color: transparent;+ border-width: 0;+ border-radius: 0;+ padding: 0;+ font-weight: inherit;+ color: inherit;+ font-size: inherit;+ font-family: inherit;+ line-height: inherit;+}++.Docs+ .doc-section+ article:first-child+ :where(pre code):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):before {+ content: none;+}++.Docs+ .doc-section+ article:first-child+ :where(pre code):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):after {+ content: none;+}++.Docs+ .doc-section+ article:first-child+ :where(table):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ width: 100%;+ table-layout: auto;+ text-align: left;+ margin-top: 2em;+ margin-bottom: 2em;+ font-size: 0.875em;+ line-height: 1.7142857;+}++.Docs+ .doc-section+ article:first-child+ :where(thead):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border-bottom-width: 1px;+ border-bottom-color: var(--tw-prose-th-borders);+}++.Docs+ .doc-section+ article:first-child+ :where(thead th):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--tw-prose-headings);+ font-weight: 600;+ vertical-align: bottom;+ padding-right: 0.5714286em;+ padding-bottom: 0.5714286em;+ padding-left: 0.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody tr):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border-bottom-width: 1px;+ border-bottom-color: var(--tw-prose-td-borders);+}++.Docs+ .doc-section+ article:first-child+ :where(tbody tr:last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ border-bottom-width: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody td):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ vertical-align: baseline;+}++.Docs+ .doc-section+ article:first-child+ :where(tfoot):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border-top-width: 1px;+ border-top-color: var(--tw-prose-th-borders);+}++.Docs+ .doc-section+ article:first-child+ :where(tfoot td):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ vertical-align: top;+}++.Docs+ .doc-section+ article:first-child+ :where(figcaption):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: hsl(var(--muted-foreground));+ font-size: 0.875em;+ line-height: 1.4285714;+ margin-top: 0.8571429em;+ font-family: Office Code Pro, monospace;+}++.Docs .doc-section article:first-child {+ --tw-prose-links: hsl(var(--foreground));+ --tw-prose-kbd: #111827;+ --tw-prose-kbd-shadows: 17 24 39;+ --tw-prose-invert-kbd: #fff;+ --tw-prose-invert-kbd-shadows: 255 255 255;+ --tw-prose-invert-code: #fff;+ --tw-prose-invert-pre-code: #d1d5db;+ --tw-prose-invert-pre-bg: rgba(0, 0, 0, 0.5);+ --tw-prose-invert-th-borders: #4b5563;+ --tw-prose-invert-td-borders: #374151;+ font-size: 1rem;+ line-height: 1.75;+}++.Docs+ .doc-section+ article:first-child+ :where(video):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 2em;+ margin-bottom: 2em;+}++.Docs+ .doc-section+ article:first-child+ :where(li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0.5em;+ margin-bottom: 0.5em;+}++.Docs+ .doc-section+ article:first-child+ :where(ol > li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ padding-left: 0.375em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul > li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ padding-left: 0.375em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > ul > li p):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0.75em;+ margin-bottom: 0.75em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > ul > li > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > ul > li > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > ol > li > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > ol > li > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul ul, ul ol, ol ul, ol ol):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0.75em;+ margin-bottom: 0.75em;+}++.Docs+ .doc-section+ article:first-child+ :where(dl):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.25em;+ margin-bottom: 1.25em;+}++.Docs+ .doc-section+ article:first-child+ :where(dd):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0.5em;+ padding-left: 1.625em;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody td, tfoot td):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding: 0.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(figure):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin: 3rem 0;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(h5):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ color: var(--colors-scale12);+}++.Docs+ .doc-section+ article:first-child+ :where(h1, h2, h3, h4, h5, h6):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ font-weight: 400;+}++.Docs+ .doc-section+ article:first-child+ :where(article h2, article h3, article h4, article h5, article h6):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 2em;+ margin-bottom: 1em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ position: relative;+}++.Docs+ .doc-section+ article:first-child+ :where(ul li):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):before {+ position: absolute;+ top: 0.75rem;+ left: -1rem;+ height: 0.125rem;+ width: 0.5rem;+ border-radius: 0.25rem;+ background-color: hsl(var(--border));+ content: "";+}++.Docs+ .doc-section+ article:first-child+ :where(ol > li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ display: block;+ position: relative;+ padding-left: 1rem;+}++.Docs+ .doc-section+ article:first-child+ :where(ol > li):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ):before {+ position: absolute;+ top: 0.25rem;+ left: -1rem;+ height: 1.2rem;+ width: 1.2rem;+ border-radius: 0.25rem;+ background-color: hsl(var(--background));+ border: 1px solid hsl(var(--border));+ content: counter(item) " ";+ counter-increment: item;+ font-size: 12px;+ color: hsl(var(--muted-foreground));+ display: flex;+ align-items: center;+ justify-content: center;+}++.Docs+ .doc-section+ article:first-child+ :where(p img):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border: 1px solid hsl(var(--border));+ border-radius: 4px;+ overflow: hidden;+}++.Docs+ .doc-section+ article:first-child+ :where(iframe):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border: 1px solid hsl(var(--border) / 0.9);+ border-radius: 0.5rem;+}++.Docs+ .doc-section+ article:first-child+ :where(td):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ border-bottom: 1px solid hsl(var(--muted));+}++.Docs+ .doc-section+ article:first-child+ :where(a:hover):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+}++.Docs+ .doc-section+ article:first-child+ :where(figure.quote-figure p:first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(figure.quote-figure p:last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(figure img):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin: 0;+}++.Docs .doc-section article:first-child {+ font-size: 0.875rem;+ line-height: 1.7142857;+}++.Docs+ .doc-section+ article:first-child+ :where(p):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.1428571em;+ margin-bottom: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where([class~="lead"]):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ font-size: 1.2857143em;+ line-height: 1.5555556;+ margin-top: 0.8888889em;+ margin-bottom: 0.8888889em;+}++.Docs+ .doc-section+ article:first-child+ :where(blockquote):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.3333333em;+ margin-bottom: 1.3333333em;+ padding-left: 1.1111111em;+}++.Docs+ .doc-section+ article:first-child+ :where(h1):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 2.1428571em;+ margin-top: 0;+ margin-bottom: 0.8em;+ line-height: 1.2;+}++.Docs+ .doc-section+ article:first-child+ :where(h2):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 1.4285714em;+ margin-top: 1.6em;+ margin-bottom: 0.8em;+ line-height: 1.4;+}++.Docs+ .doc-section+ article:first-child+ :where(h3):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 1.2857143em;+ margin-top: 1.5555556em;+ margin-bottom: 0.4444444em;+ line-height: 1.5555556;+}++.Docs+ .doc-section+ article:first-child+ :where(h4):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.4285714em;+ margin-bottom: 0.5714286em;+ line-height: 1.4285714;+}++.Docs+ .doc-section+ article:first-child+ :where(img):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.7142857em;+ margin-bottom: 1.7142857em;+}++.Docs+ .doc-section+ article:first-child+ :where(picture):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.7142857em;+ margin-bottom: 1.7142857em;+}++.Docs+ .doc-section+ article:first-child+ :where(picture > img):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0;+ margin-bottom: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(video):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.7142857em;+ margin-bottom: 1.7142857em;+}++.Docs+ .doc-section+ article:first-child+ :where(kbd):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8571429em;+ border-radius: 0.3125rem;+ padding: 0.1428571em 0.3571429em;+}++.Docs+ .doc-section+ article:first-child+ :where(code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8571429em;+}++.Docs+ .doc-section+ article:first-child+ :where(h2 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.9em;+}++.Docs+ .doc-section+ article:first-child+ :where(h3 code):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8888889em;+}++.Docs+ .doc-section+ article:first-child+ :where(pre):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8571429em;+ line-height: 1.6666667;+ margin-top: 1.6666667em;+ margin-bottom: 1.6666667em;+ border-radius: 0.25rem;+ padding: 0.6666667em 1em;+}++.Docs+ .doc-section+ article:first-child+ :where(ol):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.1428571em;+ margin-bottom: 1.1428571em;+ padding-left: 1.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.1428571em;+ margin-bottom: 1.1428571em;+ padding-left: 1.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0.2857143em;+ margin-bottom: 0.2857143em;+}++.Docs+ .doc-section+ article:first-child+ :where(ol > li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ padding-left: 0.4285714em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul > li):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ padding-left: 0.4285714em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > ul > li p):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0.5714286em;+ margin-bottom: 0.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > ul > li > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > ul > li > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > ol > li > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > ol > li > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(ul ul, ul ol, ol ul, ol ol):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0.5714286em;+ margin-bottom: 0.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(dl):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.1428571em;+ margin-bottom: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(dt):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.1428571em;+}++.Docs+ .doc-section+ article:first-child+ :where(dd):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0.2857143em;+ padding-left: 1.5714286em;+}++.Docs+ .doc-section+ article:first-child+ :where(hr):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 2.8571429em;+ margin-bottom: 2.8571429em;+}++.Docs+ .doc-section+ article:first-child+ :where(hr + *):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(h2 + *):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(h3 + *):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(h4 + *):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(table):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8571429em;+ line-height: 1.5;+}++.Docs+ .doc-section+ article:first-child+ :where(thead th):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ padding-right: 1em;+ padding-bottom: 0.6666667em;+ padding-left: 1em;+}++.Docs+ .doc-section+ article:first-child+ :where(thead th:first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding-left: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(thead th:last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding-right: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody td, tfoot td):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding: 0.6666667em 1em;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody td:first-child, tfoot td:first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding-left: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(tbody td:last-child, tfoot td:last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ padding-right: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(figure):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 1.7142857em;+ margin-bottom: 1.7142857em;+}++.Docs+ .doc-section+ article:first-child+ :where(figure > *):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ margin-top: 0;+ margin-bottom: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(figcaption):not(:where([class~="not-prose"], [class~="not-prose"] *)) {+ font-size: 0.8571429em;+ line-height: 1.3333333;+ margin-top: 0.6666667em;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > :first-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-top: 0;+}++.Docs+ .doc-section+ article:first-child+ :where(.prose-sm > :last-child):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ margin-bottom: 0;+}++.Docs .doc-section article:first-child {+ --tw-prose-body: hsl(var(--foreground));+ --tw-prose-headings: hsl(var(--foreground));+ --tw-prose-lead: hsl(var(--foreground));+ --tw-prose-links: hsl(var(--primary));+ --tw-prose-bold: hsl(var(--foreground));+ --tw-prose-counters: hsl(var(--foreground));+ --tw-prose-bullets: hsl(var(--muted-foreground));+ --tw-prose-hr: hsl(var(--muted));+ --tw-prose-quotes: hsl(var(--foreground));+ --tw-prose-quote-borders: hsl(var(--muted));+ --tw-prose-captions: hsl(var(--border));+ --tw-prose-code: hsl(var(--foreground));+ --tw-prose-pre-code: hsl(var(--muted-foreground));+ --tw-prose-pre-bg: hsl(var(--muted));+ --tw-prose-th-borders: hsl(var(--muted));+ --tw-prose-td-borders: hsl(var(--background-default));+ --tw-prose-invert-body: hsl(var(--background-default));+ --tw-prose-invert-headings: #fff;+ --tw-prose-invert-lead: hsl(var(--muted));+ --tw-prose-invert-links: #fff;+ --tw-prose-invert-bold: #fff;+ --tw-prose-invert-counters: hsl(var(--muted));+ --tw-prose-invert-bullets: hsl(var(--primary));+ --tw-prose-invert-hr: hsl(var(--border));+ --tw-prose-invert-quotes: hsl(var(--background-alternative-default));+ --tw-prose-invert-quote-borders: hsl(var(--border));+ --tw-prose-invert-captions: hsl(var(--muted));+}++.Docs+ .doc-section+ article:first-child+ :where(h1, h2, h3, h4, h5):not(+ :where([class~="not-prose"], [class~="not-prose"] *)+ ) {+ font-weight: 400;+}++.Docs .doc-section article:first-child {+ max-width: none;+}++.Docs.Docs--table-editor .doc-section__table-name {+ margin-top: 1rem;+}++.Docs .code-column {+ width: 50%;+ padding: 1rem 1.5rem;+ max-width: 50%;+}++.Docs .code-column a {+ transition-property: color, background-color, border-color,+ text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter,+ -webkit-backdrop-filter;+ transition-property: color, background-color, border-color,+ text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter,+ backdrop-filter;+ transition-property: color, background-color, border-color,+ text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter,+ backdrop-filter, -webkit-backdrop-filter;+ transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);+ transition-duration: 0.15s;+}++.Docs .code-column a:hover {+ --tw-text-opacity: 1;+ color: hsl(var(--brand-600) / var(--tw-text-opacity));+}++.Docs .code-column p:last-child {+ padding-bottom: 0;+}++.Docs .code {+ width: 50%;+ flex: 1 1 0%;+ padding: 0.5rem 1.5rem 1rem;+ max-width: 50%;+}++.Docs .code h4 {+ margin: 0.25rem;+ padding: 0;+ font-size: 0.875rem;+ line-height: 1.25rem;+ font-weight: 400;+ text-transform: uppercase;+ --tw-text-opacity: 1;+}++.Docs .code h4:not(:first-child) {+ margin-top: 1.5rem;+}++.Docs .code code {+ margin: 0.25rem;+ padding: 0;+ background-color: none;+}++.Docs .code .is-highlighted {+ --tw-text-opacity: 1;+ color: hsl(var(--primary) / var(--tw-text-opacity));+}++.Docs .codeblock-container + .codeblock-container {+ margin-top: 3rem;+}diff --git a/apps/mes/app/styles/nprogress.css b/apps/mes/app/styles/nprogress.cssnew file mode 100644index 0000000000..7f31ea3f18--- /dev/null+++ b/apps/mes/app/styles/nprogress.css@@ -0,0 +1,16 @@+/* Make clicks pass-through */+#nprogress {+ pointer-events: none;+}++#nprogress .bar {+ background: #002aff99;++ position: fixed;+ z-index: 1031;+ top: 0;+ left: 0;++ width: 100%;+ height: 2px;+}diff --git a/apps/mes/app/styles/tailwind.css b/apps/mes/app/styles/tailwind.cssnew file mode 100644index 0000000000..08ab4f7ba2--- /dev/null+++ b/apps/mes/app/styles/tailwind.css@@ -0,0 +1,88 @@+@import url("non.geist");+@import url("non.geist/mono");++@tailwind base;+@tailwind components;+@tailwind utilities;++@layer base {+ :root {+ --background: 0 0% 100%;+ --foreground: 240 10% 3.9%;+ --card: 0 0% 100%;+ --card-foreground: 240 10% 3.9%;+ --popover: 0 0% 100%;+ --popover-foreground: 240 10% 3.9%;+ --active: 240 5.9% 10%;+ --active-foreground: 0 0% 98%;+ --primary: 240 5.9% 10%;+ --primary-foreground: 0 0% 98%;+ --secondary: 240 4.8% 95.9%;+ --secondary-foreground: 240 5.9% 10%;+ --muted: 240 4.8% 95.9%;+ --muted-foreground: 240 3.8% 46.1%;+ --accent: 240 4.8% 89.9%;+ --accent-foreground: 240 5.9% 10%;+ --destructive: 0 72.22% 50.59%;+ --destructive-foreground: 0 0% 98%;+ --border: 240 5.9% 90%;+ --input: 240 5.9% 90%;+ --ring: 240 5% 64.9%;+ --radius: 0.5rem;+ }++ .dark {+ --background: 240 10% 3.9%;+ --foreground: 0 0% 98%;+ --card: 240 10% 3.9%;+ --card-foreground: 0 0% 98%;+ --popover: 240 10% 3.9%;+ --popover-foreground: 0 0% 98%;+ --primary: 0 0% 98%;+ --primary-foreground: 240 5.9% 10%;+ --active: 0 0% 98%;+ --active-foreground: 240 5.9% 10%;+ --secondary: 240 3.7% 15.9%;+ --secondary-foreground: 0 0% 98%;+ --muted: 240 3.7% 15.9%;+ --muted-foreground: 240 5% 64.9%;+ --accent: 240 3.7% 15.9%;+ --accent-foreground: 0 0% 98%;+ --destructive: 0 62.8% 30.6%;+ --destructive-foreground: 0 85.7% 97.3%;+ --border: 240 3.7% 15.9%;+ --input: 240 3.7% 15.9%;+ --ring: 240 4.9% 83.9%;+ }+}++@layer base {+ * {+ @apply border-border;+ }+ body {+ @apply bg-background text-foreground;+ font-feature-settings: "rlig" 1, "calt" 1;+ font-synthesis-weight: none;+ text-rendering: optimizeLegibility;+ }+}++.forgeViewer {+ position: relative;+ width: 100%;+ height: 100%;+ min-height: 400px;+}++.forgeViewer > div {+ border-radius: var(--radius);+}++p.is-editor-empty:first-child:before {+ color: var(--muted-foreground);+ content: attr(data-placeholder);+ float: left;+ height: 0;+ pointer-events: none;+}diff --git a/apps/mes/app/types/validators.ts b/apps/mes/app/types/validators.tsnew file mode 100644index 0000000000..3c09f14aaf--- /dev/null+++ b/apps/mes/app/types/validators.ts@@ -0,0 +1,14 @@+import type { Validator } from "@carbon/form";+import { z } from "zod";++export type TypeOfValidator<U extends Validator<any>> = U extends Validator<+ infer T+>+ ? T+ : unknown;++export type Mode = "light" | "dark";++export const modeValidator = z.object({+ mode: z.enum(["light", "dark", "system"]),+});diff --git a/apps/mes/app/utils/dom.ts b/apps/mes/app/utils/dom.tsnew file mode 100644index 0000000000..d5aa965c86--- /dev/null+++ b/apps/mes/app/utils/dom.ts@@ -0,0 +1,6 @@+export function scrollIntoView(element: HTMLElement | undefined | null) {+ element?.scrollIntoView({+ inline: "nearest",+ block: "nearest",+ });+}diff --git a/apps/mes/app/utils/handle.ts b/apps/mes/app/utils/handle.tsnew file mode 100644index 0000000000..cdf10e457b--- /dev/null+++ b/apps/mes/app/utils/handle.ts@@ -0,0 +1,5 @@+export type Handle = {+ breadcrumb?: any;+ to?: string;+ module?: string;+};diff --git a/apps/mes/app/utils/path.ts b/apps/mes/app/utils/path.tsnew file mode 100644index 0000000000..0604a12cd8--- /dev/null+++ b/apps/mes/app/utils/path.ts@@ -0,0 +1,40 @@+import { SUPABASE_API_URL } from "@carbon/auth";++const x = "/x"; // from ~/routes/x+ folder++export const path = {+ to: {+ authenticatedRoot: x,+ callback: "/callback",+ forgotPassword: "/forgot-password",+ healthcheck: "/healthcheck",+ login: "/login",+ logout: "/logout",+ refreshSession: "/refresh-session",+ requestAccess: "/request-access",+ root: "/",+ },+} as const;++export const removeSubdomain = (url?: string): string => {+ if (!url) return "localhost:3000";+ const parts = url.split("/")[0].split(".");++ const domain = parts.slice(-2).join(".");++ return domain;+};++export const getStoragePath = (bucket: string, path: string) => {+ return `${SUPABASE_API_URL}/storage/v1/object/public/${bucket}/${path}`;+};++export const requestReferrer = (request: Request) => {+ return request.headers.get("referer");+};++export const getParams = (request: Request) => {+ const url = new URL(requestReferrer(request) ?? "");+ const searchParams = new URLSearchParams(url.search);+ return searchParams.toString();+};diff --git a/apps/mes/app/utils/supabase.ts b/apps/mes/app/utils/supabase.tsnew file mode 100644index 0000000000..4631ac61cb--- /dev/null+++ b/apps/mes/app/utils/supabase.ts@@ -0,0 +1,7 @@+export const sanitize = (input: Record<string, any>) => {+ const output = { ...input };+ Object.keys(output).forEach((key) => {+ if (output[key] === undefined && key !== "id") output[key] = null;+ });+ return output;+};diff --git a/apps/mes/env.d.ts b/apps/mes/env.d.tsnew file mode 100644index 0000000000..4a1bdb51fe--- /dev/null+++ b/apps/mes/env.d.ts@@ -0,0 +1,3 @@+/// <reference types="vite/client" />+/// <reference types="@vercel/remix/globals" />+/// <reference types="@vercel/remix" />diff --git a/apps/mes/package.json b/apps/mes/package.jsonindex 9457c69ffd..646512de59 100644--- a/apps/mes/package.json+++ b/apps/mes/package.json@@ -1,41 +1,71 @@{"name": "mes",- "private": true,- "version": "0.0.0","type": "module",- "scripts": {- "dev": "vite",- "build": "tsc && vite build",- "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",- "preview": "vite preview"- },"dependencies": {+ "@carbon/auth": "*","@carbon/database": "*",+ "@carbon/documents": "*",+ "@carbon/logger": "*","@carbon/react": "*",- "@carbon/react-hook-form": "*",- "@carbon/tsconfig": "*",- "@hookform/resolvers": "^3.4.2",+ "@carbon/kv": "*",+ "@carbon/form": "*",+ "@carbon/utils": "*",+ "@react-aria/i18n": "^3.11.0",+ "@remix-run/dev": "~2.10.2",+ "@remix-run/eslint-config": "~2.10.2",+ "@remix-run/react": "~2.10.2",+ "@remix-run/serve": "~2.10.2",+ "@supabase/functions-js": "2.1.5","@supabase/supabase-js": "^2.40.0",- "class-variance-authority": "0.7.0",- "localforage": "^1.10.0",+ "@tailwindcss/container-queries": "^0.1.1",+ "@tailwindcss/forms": "^0.5.7",+ "@tailwindcss/line-clamp": "^0.4.4",+ "@tailwindcss/typography": "^0.5.10",+ "@vercel/analytics": "^1.2.2",+ "@vercel/remix": "2.10.2",+ "framer-motion": "^11.1.7",+ "isbot": "3.6.13","non.geist": "~1.0.3","react": "^18.3.1","react-dom": "^18.3.1",+ "react-dropzone": "^14.2.3",+ "react-hotkeys-hook": "~4.5.0","react-icons": "^5.2.1",- "react-router-dom": "^6.23.1",- "react-hook-form": "7.51.2",- "zod": "3.23.8"+ "tailwind-merge": "^2.2.1",+ "tailwind-scrollbar": "^3.0.5",+ "tailwind-scrollbar-hide": "^1.1.7",+ "tailwindcss-animate": "^1.0.7",+ "zod": "^3.23.8",+ "zod-form-data": "*"},"devDependencies": {- "@types/react": "^18.2.66",- "@types/react-dom": "^18.2.22",- "@vitejs/plugin-react": "^4.2.1",- "autoprefixer": "^10.4.14",- "eslint": "^8.57.0",- "eslint-config-carbon": "*",+ "@carbon/tailwind": "*",+ "@carbon/tsconfig": "*",+ "@types/react": "^18.2.74",+ "@types/react-dom": "^18.2.24",+ "autoprefixer": "10.4.14",+ "cross-env": "7.0.3",+ "nodemon": "^3.0.1",+ "npm-run-all": "^4.1.5","postcss": "^8.4.33",- "tailwindcss": "^3.3.2",+ "tailwind-scrollbar": "^3.0.5",+ "tailwindcss": "3.3.2","typescript": "^5.2.2",- "vite": "^5.3.3"- }+ "vite": "^5.3.3",+ "vite-tsconfig-paths": "^4.3.2",+ "wait-on": "7.2.0"+ },+ "engines": {+ "node": ">=20"+ },+ "private": true,+ "scripts": {+ "build": "remix vite:build",+ "clean": "rimraf .cache .turbo node_modules dist build",+ "dev": "remix vite:dev",+ "lint": "TIMING=1 eslint \"app/**/*.ts*\"",+ "start": "remix-serve ./build/server/index.js",+ "types": "tsc"+ },+ "sideEffects": false}diff --git a/apps/mes/postcss.config.cjs b/apps/mes/postcss.config.cjsnew file mode 100644index 0000000000..4182e2b578--- /dev/null+++ b/apps/mes/postcss.config.cjs@@ -0,0 +1 @@+module.exports = require("@carbon/tailwind/postcss.config");diff --git a/apps/mes/public/android-chrome-192x192.png b/apps/mes/public/android-chrome-192x192.pngnew file mode 100644index 0000000000..777cc381efBinary files /dev/null and b/apps/mes/public/android-chrome-192x192.png differdiff --git a/apps/mes/public/android-chrome-512x512.png b/apps/mes/public/android-chrome-512x512.pngnew file mode 100644index 0000000000..bd3fb48e59Binary files /dev/null and b/apps/mes/public/android-chrome-512x512.png differdiff --git a/apps/mes/public/apple-touch-icon.png b/apps/mes/public/apple-touch-icon.pngnew file mode 100644index 0000000000..4f8712f2c1Binary files /dev/null and b/apps/mes/public/apple-touch-icon.png differdiff --git a/apps/mes/public/favicon-16x16.png b/apps/mes/public/favicon-16x16.pngnew file mode 100644index 0000000000..eb216e453fBinary files /dev/null and b/apps/mes/public/favicon-16x16.png differdiff --git a/apps/mes/public/favicon-32x32.png b/apps/mes/public/favicon-32x32.pngnew file mode 100644index 0000000000..a7064d2122Binary files /dev/null and b/apps/mes/public/favicon-32x32.png differdiff --git a/apps/mes/public/grid.svg b/apps/mes/public/grid.svgindex d9dc0423ed..76e3b29f0d 100644--- a/apps/mes/public/grid.svg+++ b/apps/mes/public/grid.svg@@ -1,5 +1,5 @@-<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100">+<svg id="download" xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><path id="Path_3" data-name="Path 3" d="M96,95h4v1H96v4H95V96H86v4H85V96H76v4H75V96H66v4H65V96H56v4H55V96H46v4H45V96H36v4H35V96H26v4H25V96H16v4H15V96H0V95H15V86H0V85H15V76H0V75H15V66H0V65H15V56H0V55H15V46H0V45H15V36H0V35H15V26H0V25H15V16H0V15H15V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h9V0h1V15h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96v9h4v1H96Zm-1,0V86H86v9ZM85,95V86H76v9ZM75,95V86H66v9ZM65,95V86H56v9ZM55,95V86H46v9ZM45,95V86H36v9ZM35,95V86H26v9ZM25,95V86H16v9ZM16,85h9V76H16Zm10,0h9V76H26Zm10,0h9V76H36Zm10,0h9V76H46Zm10,0h9V76H56Zm10,0h9V76H66Zm10,0h9V76H76Zm10,0h9V76H86Zm9-10V66H86v9ZM85,75V66H76v9ZM75,75V66H66v9ZM65,75V66H56v9ZM55,75V66H46v9ZM45,75V66H36v9ZM35,75V66H26v9ZM25,75V66H16v9ZM16,65h9V56H16Zm10,0h9V56H26Zm10,0h9V56H36Zm10,0h9V56H46Zm10,0h9V56H56Zm10,0h9V56H66Zm10,0h9V56H76Zm10,0h9V56H86Zm9-10V46H86v9ZM85,55V46H76v9ZM75,55V46H66v9ZM65,55V46H56v9ZM55,55V46H46v9ZM45,55V46H36v9ZM35,55V46H26v9ZM25,55V46H16v9ZM16,45h9V36H16Zm10,0h9V36H26Zm10,0h9V36H36Zm10,0h9V36H46Zm10,0h9V36H56Zm10,0h9V36H66Zm10,0h9V36H76Zm10,0h9V36H86Zm9-10V26H86v9ZM85,35V26H76v9ZM75,35V26H66v9ZM65,35V26H56v9ZM55,35V26H46v9ZM45,35V26H36v9ZM35,35V26H26v9ZM25,35V26H16v9ZM16,25h9V16H16Zm10,0h9V16H26Zm10,0h9V16H36Zm10,0h9V16H46Zm10,0h9V16H56Zm10,0h9V16H66Zm10,0h9V16H76Zm10,0h9V16H86Z" fill="rgba(255,255,255,0.1)" fill-rule="evenodd" opacity="0.5"/><path id="Path_4" data-name="Path 4" d="M6,5V0H5V5H0V6H5v94H6V6h94V5Z" fill="rgba(255,255,255,0.1)" fill-rule="evenodd"/></svg>diff --git a/apps/mes/public/serviceWorker.js b/apps/mes/public/serviceWorker.jsnew file mode 100644index 0000000000..790bcf811a--- /dev/null+++ b/apps/mes/public/serviceWorker.js@@ -0,0 +1,31 @@+self.addEventListener("fetch", (event) => {+ let url = new URL(event.request.url);+ let method = event.request.method;++ // any non GET request is ignored+ if (method.toLowerCase() !== "get") return;++ // If the request is for the favicons, fonts, or the built files (which are hashed in the name)+ if (+ url.pathname.includes("logo") ||+ url.pathname.includes("storage/v1/object/public/avatars")+ ) {+ event.respondWith(+ // we will open the assets cache+ caches.open("assets").then(async (cache) => {+ // if the request is cached we will use the cache+ let cacheResponse = await cache.match(event.request);+ if (cacheResponse) return cacheResponse;++ // if it's not cached we will run the fetch, cache it and return it+ // this way the next time this asset it's needed it will load from the cache+ let fetchResponse = await fetch(event.request);+ cache.put(event.request, fetchResponse.clone());++ return fetchResponse;+ })+ );+ }++ return;+});diff --git a/apps/mes/public/site.webmanifest b/apps/mes/public/site.webmanifestnew file mode 100644index 0000000000..4e209ea8a1--- /dev/null+++ b/apps/mes/public/site.webmanifest@@ -0,0 +1,19 @@+{+ "name": "Carbon",+ "short_name": "Carbon",+ "icons": [+ {+ "src": "/android-chrome-192x192.png",+ "sizes": "192x192",+ "type": "image/png"+ },+ {+ "src": "/android-chrome-512x512.png",+ "sizes": "512x512",+ "type": "image/png"+ }+ ],+ "theme_color": "#ffffff",+ "background_color": "#ffffff",+ "display": "standalone"+}diff --git a/apps/mes/tailwind.config.js b/apps/mes/tailwind.config.jsnew file mode 100644index 0000000000..5856bc01d7--- /dev/null+++ b/apps/mes/tailwind.config.js@@ -0,0 +1,4 @@+module.exports = {+ "tailwindcss/nesting": {},+ ...require("@carbon/tailwind/tailwind.config"),+};diff --git a/apps/mes/tsconfig.json b/apps/mes/tsconfig.jsonindex 72c0c3a59d..ac163dacdb 100644--- a/apps/mes/tsconfig.json+++ b/apps/mes/tsconfig.json@@ -1,13 +1,30 @@{- "exclude": ["node_modules"],- "extends": "@carbon/tsconfig/vite.json",+ "include": [+ "env.d.ts",+ "**/*.ts",+ "**/*.tsx",+ "app/modules/documents/documents.service.ts",+ "../carbon/app/components/Breadcrumb.tsx"+ ],"compilerOptions": {- "rootDir": ".",- "outDir": "dist",+ "lib": ["dom", "dom.iterable", "ESNext"],+ "esModuleInterop": true,+ "jsx": "react-jsx",+ "module": "ESNext",+ "moduleResolution": "Bundler",+ "resolveJsonModule": true,+ "target": "ES2019",+ "strict": true,+ "forceConsistentCasingInFileNames": true,+ "allowJs": true,"baseUrl": ".","paths": {- "~/*": ["src/*"]- }- },- "include": ["src", "vite.config.ts"]+ "~/*": ["./app/*"]+ },+ "types": ["@remix-run/react/future/single-fetch.d.ts"],+ "noEmit": true,+ "isolatedModules": true,+ "skipLibCheck": true,+ "noErrorTruncation": true+ }}diff --git a/apps/mes/vite.config.ts b/apps/mes/vite.config.tsindex 413675e469..774092ca6a 100644--- a/apps/mes/vite.config.ts+++ b/apps/mes/vite.config.ts@@ -1,19 +1,70 @@-import react from "@vitejs/plugin-react";-import { resolve } from "path";+import { vitePlugin as remix } from "@remix-run/dev";+import { vercelPreset } from "@vercel/remix/vite";+import path from "node:path";+import { flatRoutes } from "remix-flat-routes";import { defineConfig } from "vite";+import tsconfigPaths from "vite-tsconfig-paths";-// https://vitejs.dev/config/export default defineConfig({- plugins: [react()],- server: {- port: 4000,- },build: {- sourcemap: true,+ sourcemap: false,+ rollupOptions: {+ onwarn(warning, defaultHandler) {+ if (warning.code === "SOURCEMAP_ERROR") {+ return;+ }++ defaultHandler(warning);+ },+ },+ },+ ssr: {+ noExternal: [+ "react-tweet",+ "react-dropzone",+ "react-icons",+ "react-phone-number-input",+ "tailwind-merge",+ ],+ },+ server: {+ port: 3002,},+ plugins: [+ remix({+ presets: [vercelPreset()],+ future: {+ unstable_singleFetch: false,+ },+ ignoredRouteFiles: ["**/.*"],+ serverModuleFormat: "esm",+ routes: async (defineRoutes) => {+ return flatRoutes("routes", defineRoutes, {+ // eslint-disable-next-line no-undef+ appDir: path.resolve(__dirname, "app"),+ });+ },+ }),+ tsconfigPaths(),+ ],resolve: {alias: {- "~": resolve(__dirname, "src"),+ "@carbon/documents": path.resolve(+ __dirname,+ "../../packages/documents/src/index.tsx"+ ),+ "@carbon/utils": path.resolve(+ __dirname,+ "../../packages/utils/src/index.ts"+ ),+ "@carbon/form": path.resolve(+ __dirname,+ "../../packages/form/src/index.tsx"+ ),+ "@carbon/logger": path.resolve(+ __dirname,+ "../../packages/logger/src/index.ts"+ ),},},});diff --git a/package-lock.json b/package-lock.jsonindex cd6f91b0df..6e91eff99f 100644--- a/package-lock.json+++ b/package-lock.json@@ -227,6 +227,39 @@}},"apps/mes": {+ "version": "0.0.0",+ "extraneous": true,+ "dependencies": {+ "@carbon/database": "*",+ "@carbon/react": "*",+ "@carbon/react-hook-form": "*",+ "@carbon/tsconfig": "*",+ "@hookform/resolvers": "^3.4.2",+ "@supabase/supabase-js": "^2.40.0",+ "class-variance-authority": "0.7.0",+ "localforage": "^1.10.0",+ "non.geist": "~1.0.3",+ "react": "^18.3.1",+ "react-dom": "^18.3.1",+ "react-hook-form": "7.51.2",+ "react-icons": "^5.2.1",+ "react-router-dom": "^6.23.1",+ "zod": "3.23.8"+ },+ "devDependencies": {+ "@types/react": "^18.2.66",+ "@types/react-dom": "^18.2.22",+ "@vitejs/plugin-react": "^4.2.1",+ "autoprefixer": "^10.4.14",+ "eslint": "^8.57.0",+ "eslint-config-carbon": "*",+ "postcss": "^8.4.33",+ "tailwindcss": "^3.3.2",+ "typescript": "^5.2.2",+ "vite": "^5.3.3"+ }+ },+ "apps/mes-prototype": {"version": "0.0.0","dependencies": {"@carbon/database": "*",@@ -23342,7 +23375,7 @@}},"node_modules/mes": {- "resolved": "apps/mes",+ "resolved": "apps/mes-prototype","link": true},"node_modules/methods": {