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
feat: ui for api docs
Brad Barbin63bff5d7c871
diff --git a/apps/carbon/app/components/Contact.tsx b/apps/carbon/app/components/Contact.tsxindex 547ca0f485..f55fc94a1a 100644--- a/apps/carbon/app/components/Contact.tsx+++ b/apps/carbon/app/components/Contact.tsx@@ -53,13 +53,13 @@ const Contact = ({ contact, url, user, actions }: ContactProps) => {{userStatus === UserStatus.Active && (<spantitle="Active"- className="inline-block green-400 rounded-full w-3 h-3 ml-1.5"+ className="inline-block bg-green-400 rounded-full w-3 h-3 ml-1.5"/>)}{userStatus === UserStatus.Inactive && (<spantitle="Inactive"- className="inline-block red-400 rounded-full w-3 h-3 ml-1.5"+ className="inline-block bg-red-400 rounded-full w-3 h-3 ml-1.5"/>)}</HStack>diff --git a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsxindex 050c266476..328223c05d 100644--- a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx+++ b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx@@ -4,11 +4,17 @@ import { useOptimisticLocation } from "~/hooks";import type { RouteGroup } from "~/types";import { CollapsibleSidebar } from "./CollapsibleSidebar";-const GroupedContentSidebar = ({ groups }: { groups: RouteGroup[] }) => {+const GroupedContentSidebar = ({+ groups,+ width,+}: {+ groups: RouteGroup[];+ width?: number;+}) => {const location = useOptimisticLocation();return (- <CollapsibleSidebar>+ <CollapsibleSidebar width={width}><div className="overflow-y-auto h-full w-full pb-8"><VStack>{groups.map((group) => (@@ -21,7 +27,7 @@ const GroupedContentSidebar = ({ groups }: { groups: RouteGroup[] }) => {{group.name}</h4>{group.routes.map((route) => {- const isActive = location.pathname.includes(route.to);+ const isActive = location.pathname === route.to;return (<Buttonkey={route.name}diff --git a/apps/carbon/app/components/Layout/Navigation/useModules.tsx b/apps/carbon/app/components/Layout/Navigation/useModules.tsxindex 211466af45..2baaca2449 100644--- a/apps/carbon/app/components/Layout/Navigation/useModules.tsx+++ b/apps/carbon/app/components/Layout/Navigation/useModules.tsx@@ -103,6 +103,11 @@ export function useModules() {to: path.to.employeeAccounts,icon: LuShield,},+ {+ name: "API Docs",+ to: path.to.apiIntroduction,+ icon: LuFiles,+ },{permission: "settings",name: "Settings",diff --git a/apps/carbon/app/config/env.ts b/apps/carbon/app/config/env.tsindex 652e026648..f2b4bd0551 100644--- a/apps/carbon/app/config/env.ts+++ b/apps/carbon/app/config/env.ts@@ -35,7 +35,7 @@ type EnvOptions = {isRequired?: boolean;};-function getEnv(+export function getEnv(name: string,{ isRequired, isSecret }: EnvOptions = { isSecret: true, isRequired: true }) {diff --git a/apps/carbon/app/modules/api/index.ts b/apps/carbon/app/modules/api/index.tsnew file mode 100644index 0000000000..4aedf59360--- /dev/null+++ b/apps/carbon/app/modules/api/index.ts@@ -0,0 +1 @@+export * from "./ui";diff --git a/apps/carbon/app/modules/api/ui/CodeSnippet.tsx b/apps/carbon/app/modules/api/ui/CodeSnippet.tsxnew file mode 100644index 0000000000..efb830da08--- /dev/null+++ b/apps/carbon/app/modules/api/ui/CodeSnippet.tsx@@ -0,0 +1,24 @@+import { CodeBlock, useHydrated } from "@carbon/react";++interface CodeSnippetProps {+ selectedLang: "bash" | "js";+ snippet: {+ title?: string;+ bash: { language?: string; code: string };+ js?: { language?: string; code: string };+ };+}++const CodeSnippet = ({ selectedLang, snippet }: CodeSnippetProps) => {+ const hydrated = useHydrated();+ if (!hydrated || !snippet[selectedLang]) return null;+ return (+ <div className="codeblock-container">+ <h4>{snippet.title}</h4>+ <CodeBlock className={snippet[selectedLang]?.language}>+ {snippet[selectedLang]?.code}+ </CodeBlock>+ </div>+ );+};+export default CodeSnippet;diff --git a/apps/carbon/app/modules/api/ui/Snippets.tsx b/apps/carbon/app/modules/api/ui/Snippets.tsxnew file mode 100644index 0000000000..9b5e1e5433--- /dev/null+++ b/apps/carbon/app/modules/api/ui/Snippets.tsx@@ -0,0 +1,771 @@+const snippets = {+ endpoint: (endpoint: string) => ({+ title: "API URL",+ bash: {+ language: "bash",+ code: `${endpoint}`,+ },+ js: {+ language: "bash",+ code: `${endpoint}`,+ },+ }),+ install: () => ({+ title: "Install",+ bash: null,+ js: {+ language: "bash",+ code: `npm install --save @supabase/supabase-js`,+ },+ }),+ init: (endpoint: string) => ({+ title: "Initializing",+ bash: {+ language: "bash",+ code: `# No client library required for Bash.`,+ },+ js: {+ language: "js",+ code: `+import { createClient } from '@supabase/supabase-js'+const supabaseUrl = '${endpoint}'+const supabaseKey = process.env.SUPABASE_KEY+const supabase = createClient(supabaseUrl, supabaseKey)`,+ },+ python: {+ language: "python",+ code: `+import os+from supabase import create_client, Client+url: str = '${endpoint}'+key: str = os.environ.get("SUPABASE_KEY")+supabase: Client = create_client(url, key)+`,+ },+ dart: {+ language: "dart",+ code: `+const supabaseUrl = '${endpoint}';+const supabaseKey = String.fromEnvironment('SUPABASE_KEY');+Future<void> main() async {+ await Supabase.initialize(url: supabaseUrl, anonKey: supabaseKey);+ runApp(MyApp());+}`,+ },+ }),+ authKey: (title: string, varName: string, apikey: string) => ({+ title: `${title}`,+ bash: {+ language: "bash",+ code: `${apikey}`,+ },+ js: {+ language: "js",+ code: `const ${varName} = '${apikey}'`,+ },+ }),+ authKeyExample: (+ defaultApiKey: string,+ endpoint: string,+ { keyName, showBearer = true }: { keyName?: string; showBearer?: boolean }+ ) => ({+ title: "Example usage",+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/' \\+-H "apikey: ${defaultApiKey}" ${+ showBearer+ ? `\\+-H "Authorization: Bearer ${defaultApiKey}"`+ : ""+ }+`,+ },+ js: {+ language: "js",+ code: `+const SUPABASE_URL = "${endpoint}"+const supabase = createClient(SUPABASE_URL, process.env.${+ keyName || "SUPABASE_KEY"+ });+`,+ },+ }),+ rpcSingle: ({+ rpcName,+ rpcParams,+ endpoint,+ apiKey,+ showBearer = true,+ }: {+ rpcName: string;+ rpcParams: any[];+ endpoint: string;+ apiKey: string;+ showBearer: boolean;+ }) => {+ let rpcList = rpcParams.map((x) => `"${x.name}": "value"`).join(", ");+ let noParams = !rpcParams.length;+ let bashParams = noParams ? "" : `\n-d '{ ${rpcList} }' \\`;+ let jsParams = noParams+ ? ""+ : `, {${+ rpcParams.length+ ? rpcParams+ .map((x) => `\n ${x.name}`)+ .join(`, `)+ .concat("\n ")+ : ""+ }}`;+ return {+ title: "Invoke function ",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/rest/v1/rpc/${rpcName}' \\${bashParams}+-H "Content-Type: application/json" \\+-H "apikey: ${apiKey}" ${+ showBearer+ ? `\\+-H "Authorization: Bearer ${apiKey}"`+ : ""+ }+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase+ .rpc('${rpcName}'${jsParams})+if (error) console.error(error)+else console.log(data)+`,+ },+ };+ },+ subscribeAll: (listenerName: string, resourceId: string) => ({+ title: "Subscribe to all events",+ bash: {+ language: "bash",+ code: `# Realtime streams are only supported by our client libraries`,+ },+ js: {+ language: "js",+ code: `+const ${listenerName} = supabase.channel('custom-all-channel')+ .on(+ 'postgres_changes',+ { event: '*', schema: 'public', table: '${resourceId}' },+ (payload) => {+ console.log('Change received!', payload)+ }+ )+ .subscribe()`,+ },+ }),+ subscribeInserts: (listenerName: string, resourceId: string) => ({+ title: "Subscribe to inserts",+ bash: {+ language: "bash",+ code: `# Realtime streams are only supported by our client libraries`,+ },+ js: {+ language: "js",+ code: `+const ${listenerName} = supabase.channel('custom-insert-channel')+ .on(+ 'postgres_changes',+ { event: 'INSERT', schema: 'public', table: '${resourceId}' },+ (payload) => {+ console.log('Change received!', payload)+ }+ )+ .subscribe()`,+ },+ }),+ subscribeUpdates: (listenerName: string, resourceId: string) => ({+ title: "Subscribe to updates",+ bash: {+ language: "bash",+ code: `# Realtime streams are only supported by our client libraries`,+ },+ js: {+ language: "js",+ code: `+const ${listenerName} = supabase.channel('custom-update-channel')+ .on(+ 'postgres_changes',+ { event: 'UPDATE', schema: 'public', table: '${resourceId}' },+ (payload) => {+ console.log('Change received!', payload)+ }+ )+ .subscribe()`,+ },+ }),+ subscribeDeletes: (listenerName: string, resourceId: string) => ({+ title: "Subscribe to deletes",+ bash: {+ language: "bash",+ code: `# Realtime streams are only supported by our client libraries`,+ },+ js: {+ language: "js",+ code: `+const ${listenerName} = supabase.channel('custom-delete-channel')+ .on(+ 'postgres_changes',+ { event: 'DELETE', schema: 'public', table: '${resourceId}' },+ (payload) => {+ console.log('Change received!', payload)+ }+ )+ .subscribe()`,+ },+ }),+ subscribeEq: (+ listenerName: string,+ resourceId: string,+ columnName: string,+ value: string+ ) => ({+ title: "Subscribe to specific rows",+ bash: {+ language: "bash",+ code: `# Realtime streams are only supported by our client libraries`,+ },+ js: {+ language: "js",+ code: `+const ${listenerName} = supabase.channel('custom-filter-channel')+ .on(+ 'postgres_changes',+ { event: '*', schema: 'public', table: '${resourceId}', filter: '${columnName}=eq.${value}' },+ (payload) => {+ console.log('Change received!', payload)+ }+ )+ .subscribe()`,+ },+ }),+ readAll: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Read all rows",+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/${resourceId}?select=*' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}"+`,+ },+ js: {+ language: "js",+ code: `+let { data: ${resourceId}, error } = await supabase+ .from('${resourceId}')+ .select('*')+`,+ },+ }),+ readColumns: ({+ title = "Read specific columns",+ resourceId,+ endpoint,+ apiKey,+ columnName = "some_column,other_column",+ }: {+ title?: string;+ resourceId: string;+ endpoint: string;+ apiKey: string;+ columnName?: string;+ }) => ({+ title,+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/${resourceId}?select=${columnName}' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}"+`,+ },+ js: {+ language: "js",+ code: `+let { data: ${resourceId}, error } = await supabase+ .from('${resourceId}')+ .select('${columnName}')+`,+ },+ }),+ readForeignTables: (+ resourceId: string,+ endpoint: string,+ apiKey: string+ ) => ({+ title: "Read referenced tables",+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/${resourceId}?select=some_column,other_table(foreign_key)' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}"+`,+ },+ js: {+ language: "js",+ code: `+let { data: ${resourceId}, error } = await supabase+ .from('${resourceId}')+ .select(\`+ some_column,+ other_table (+ foreign_key+ )+ \`)+`,+ },+ }),+ readRange: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "With pagination",+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/${resourceId}?select=*' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Range: 0-9"+`,+ },+ js: {+ language: "js",+ code: `+let { data: ${resourceId}, error } = await supabase+ .from('${resourceId}')+ .select('*')+ .range(0, 9)+`,+ },+ }),+ readFilters: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "With filtering",+ bash: {+ language: "bash",+ code: `+curl '${endpoint}/rest/v1/${resourceId}?id=eq.1&select=*' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Range: 0-9"+`,+ },+ js: {+ language: "js",+ code: `+let { data: ${resourceId}, error } = await supabase+ .from('${resourceId}')+ .select("*")+ // Filters+ .eq('column', 'Equal to')+ .gt('column', 'Greater than')+ .lt('column', 'Less than')+ .gte('column', 'Greater than or equal to')+ .lte('column', 'Less than or equal to')+ .like('column', '%CaseSensitive%')+ .ilike('column', '%CaseInsensitive%')+ .is('column', null)+ .in('column', ['Array', 'Values'])+ .neq('column', 'Not equal to')+ // Arrays+ .contains('array_column', ['array', 'contains'])+ .containedBy('array_column', ['contained', 'by'])+`,+ },+ }),+ insertSingle: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Insert a row",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/rest/v1/${resourceId}' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Content-Type: application/json" \\+-H "Prefer: return=minimal" \\+-d '{ "some_column": "someValue", "other_column": "otherValue" }'+`,+ },+ js: {+ language: "js",+ code: `+const { data, error } = await supabase+ .from('${resourceId}')+ .insert([+ { some_column: 'someValue', other_column: 'otherValue' },+ ])+ .select()+`,+ },+ }),+ insertMany: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Insert many rows",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/rest/v1/${resourceId}' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '[{ "some_column": "someValue" }, { "other_column": "otherValue" }]'+`,+ },+ js: {+ language: "js",+ code: `+const { data, error } = await supabase+ .from('${resourceId}')+ .insert([+ { some_column: 'someValue' },+ { some_column: 'otherValue' },+ ])+ .select()+`,+ },+ }),+ upsert: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Upsert matching rows",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/rest/v1/${resourceId}' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Content-Type: application/json" \\+-H "Prefer: resolution=merge-duplicates" \\+-d '{ "some_column": "someValue", "other_column": "otherValue" }'+`,+ },+ js: {+ language: "js",+ code: `+const { data, error } = await supabase+ .from('${resourceId}')+ .upsert({ some_column: 'someValue' })+ .select()+`,+ },+ }),+ update: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Update matching rows",+ bash: {+ language: "bash",+ code: `+curl -X PATCH '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}" \\+-H "Content-Type: application/json" \\+-H "Prefer: return=minimal" \\+-d '{ "other_column": "otherValue" }'+`,+ },+ js: {+ language: "js",+ code: `+const { data, error } = await supabase+ .from('${resourceId}')+ .update({ other_column: 'otherValue' })+ .eq('some_column', 'someValue')+ .select()+`,+ },+ }),+ delete: (resourceId: string, endpoint: string, apiKey: string) => ({+ title: "Delete matching rows",+ bash: {+ language: "bash",+ code: `+curl -X DELETE '${endpoint}/rest/v1/${resourceId}?some_column=eq.someValue' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer ${apiKey}"+`,+ },+ js: {+ language: "js",+ code: `+const { error } = await supabase+ .from('${resourceId}')+ .delete()+ .eq('some_column', 'someValue')+`,+ },+ }),+ authSignup: (endpoint: string, apiKey: string, randomPassword: string) => ({+ title: "User signup",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/signup' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]",+ "password": "${randomPassword}"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signUp({+ email: '[email protected]',+ password: '${randomPassword}'+})+`,+ },+ }),+ authLogin: (endpoint: string, apiKey: string, randomPassword: string) => ({+ title: "User login",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/token?grant_type=password' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]",+ "password": "${randomPassword}"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signInWithPassword({+ email: '[email protected]',+ password: '${randomPassword}'+})+`,+ },+ }),+ authMagicLink: (endpoint: string, apiKey: string) => ({+ title: "User login",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/magiclink' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signInWithOtp({+ email: '[email protected]'+})+`,+ },+ }),+ authPhoneSignUp: (endpoint: string, apiKey: string) => ({+ title: "Phone Signup",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/signup' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "phone": "+13334445555",+ "password": "some-password"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signUp({+ phone: '+13334445555',+ password: 'some-password'+})+`,+ },+ }),+ authMobileOTPLogin: (endpoint: string, apiKey: string) => ({+ title: "Phone Login",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/otp' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "phone": "+13334445555"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signInWithOtp({+ phone: '+13334445555'+})+`,+ },+ }),+ authMobileOTPVerify: (endpoint: string, apiKey: string) => ({+ title: "Verify Pin",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/verify' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "type": "sms",+ "phone": "+13334445555",+ "token": "123456"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.verifyOtp({+ phone: '+13334445555',+ token: '123456',+ type: 'sms'+})+`,+ },+ }),+ authInvite: (endpoint: string, apiKey: string) => ({+ title: "Invite User",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/invite' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer USER_TOKEN" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.admin.inviteUserByEmail('[email protected]')+`,+ },+ }),+ authThirdPartyLogin: (endpoint: string, apiKey: string) => ({+ title: "Third Party Login",+ bash: {+ language: "bash",+ code: `+curl -X GET '${endpoint}/auth/v1/authorize?provider=github' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer USER_TOKEN" \\+-H "Content-Type: application/json"+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.signInWithOAuth({+ provider: 'github'+})+`,+ },+ }),+ authUser: (endpoint: string, apiKey: string) => ({+ title: "Get User",+ bash: {+ language: "bash",+ code: `+curl -X GET '${endpoint}/auth/v1/user' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer USER_TOKEN"+`,+ },+ js: {+ language: "js",+ code: `+const { data: { user } } = await supabase.auth.getUser()+`,+ },+ }),+ authRecover: (endpoint: string, apiKey: string) => ({+ title: "Password Recovery",+ bash: {+ language: "bash",+ code: `+ curl -X POST '${endpoint}/auth/v1/recover' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]"+}'+`,+ },+ js: {+ language: "js",+ code: `+let { data, error } = await supabase.auth.resetPasswordForEmail(email)+`,+ },+ }),+ authUpdate: (endpoint: string, apiKey: string) => ({+ title: "Update User",+ bash: {+ language: "bash",+ code: `+ curl -X PUT '${endpoint}/auth/v1/user' \\+-H "apikey: ${apiKey}" \\+-H "Authorization: Bearer USER_TOKEN" \\+-H "Content-Type: application/json" \\+-d '{+ "email": "[email protected]",+ "password": "new-password",+ "data": {+ "key": "value"+ }+}'+`,+ },+ js: {+ language: "js",+ code: `+const { data, error } = await supabase.auth.updateUser({+ email: "[email protected]",+ password: "new-password",+ data: { hello: 'world' }+})+`,+ },+ }),+ authLogout: (endpoint: string, apiKey: string) => ({+ title: "User logout",+ bash: {+ language: "bash",+ code: `+curl -X POST '${endpoint}/auth/v1/logout' \\+-H "apikey: ${apiKey}" \\+-H "Content-Type: application/json" \\+-H "Authorization: Bearer USER_TOKEN"+`,+ },+ js: {+ language: "js",+ code: `+let { error } = await supabase.auth.signOut()+`,+ },+ }),+};++export default snippets;diff --git a/apps/carbon/app/modules/api/ui/TableDocs.tsx b/apps/carbon/app/modules/api/ui/TableDocs.tsxnew file mode 100644index 0000000000..c7702aec17--- /dev/null+++ b/apps/carbon/app/modules/api/ui/TableDocs.tsx@@ -0,0 +1,461 @@+import { cn } from "@carbon/react";+import { LuTable2 } from "react-icons/lu";+import { getBrowserEnv } from "~/config/env";+import swaggerDocsSchema from "~/lib/swagger-docs-schema";+import type { ValidLang } from "~/modules/api";+import { CodeSnippet, Snippets } from "~/modules/api";++const { SUPABASE_ANON_PUBLIC } = getBrowserEnv();++type TableDocsProps = {+ endpoint: string;+ selectedLang: ValidLang;+ resourceId: string;+ resources: Record<+ string,+ { id: string; displayName: string; camelCase: string }+ >;+};++const TableDocs = ({+ endpoint,+ selectedLang,+ resourceId,+ resources,+}: TableDocsProps) => {+ const { paths, definitions } = swaggerDocsSchema;+ // @ts-ignore+ const resourcePaths = paths[`/${resourceId}`];+ // @ts-ignore+ const resourceDefinition = definitions?.[resourceId];+ const resourceMeta = resources[resourceId];+ const realtimeEnabled = true; // TODO: realtime is not available for a lot of tables (unless we enable it)++ const methods = Object.keys(resourcePaths ?? {}).map((x) => x.toUpperCase());+ const properties = Object.entries(resourceDefinition?.properties ?? []).map(+ ([id, val]: any) => ({+ ...val,+ id,+ required: resourceDefinition?.required?.includes(id),+ })+ );++ if (!paths || !definitions) return null;++ return (+ <>+ <h2 className="doc-section__table-name text-foreground mt-0 flex items-center px-6 gap-2">+ <span className="bg-muted p-2 rounded-lg">+ <LuTable2 size={18} />+ </span>+ <span className="text-2xl font-bold">{resourceId}</span>+ </h2>++ <div className="doc-section">+ <article className="code"></article>+ </div>+ {properties.length > 0 && (+ <div>+ {properties.map((x) => (+ <div className="doc-section py-4" key={x.id}>+ <div className="code-column text-foreground">+ <Param+ key={x.id}+ name={x.id}+ type={x.type}+ format={x.format}+ isOptional={!x.required}+ metadata={{+ table: resourceId,+ column: x.id,+ }}+ />+ </div>+ <div className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readColumns({+ title: `Select ${x.id}`,+ resourceId,+ endpoint: endpoint,+ apiKey: SUPABASE_ANON_PUBLIC,+ columnName: x.id,+ })}+ />+ </div>+ </div>+ ))}+ </div>+ )}+ {methods.includes("GET") && (+ <>+ <h3 className="text-foreground mt-4 px-6">Read rows</h3>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>+ To read rows in <code>{resourceId}</code>, use the{" "}+ <code>select</code> method.+ </p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/select"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readAll(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readColumns({+ resourceId,+ endpoint: endpoint,+ apiKey: SUPABASE_ANON_PUBLIC,+ })}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readForeignTables(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readRange(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ </article>+ </div>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <h4 className="mt-0 text-white">Filtering</h4>+ <p>Supabase provides a wide range of filters.</p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/using-filters"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.readFilters(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes("POST") && (+ <>+ <h3 className="text-foreground mt-4 px-6">Insert rows</h3>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>+ <code>insert</code> lets you insert into your tables. You can+ also insert in bulk and do UPSERT.+ </p>+ <p>+ <code>insert</code> will also return the replaced values for+ UPSERT.+ </p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/insert"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.insertSingle(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.insertMany(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.upsert(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes("PATCH") && (+ <>+ <h3 className="text-foreground mt-4 px-6">Update rows</h3>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>+ <code>update</code> lets you update rows. <code>update</code>{" "}+ will match all rows by default. You can update specific rows+ using horizontal filters, e.g. <code>eq</code>, <code>lt</code>,+ and <code>is</code>.+ </p>+ <p>+ <code>update</code> will also return the replaced values for+ UPDATE.+ </p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/update"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.update(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ </article>+ </div>+ </>+ )}+ {methods.includes("DELETE") && (+ <>+ <h3 className="text-foreground mt-4 px-6">Delete rows</h3>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>+ <code>delete</code> lets you delete rows. <code>delete</code>{" "}+ will match all rows by default, so remember to specify your+ filters!+ </p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/delete"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.delete(+ resourceId,+ endpoint,+ SUPABASE_ANON_PUBLIC+ )}+ />+ </article>+ </div>+ </>+ )}+ {realtimeEnabled &&+ (methods.includes("DELETE") ||+ methods.includes("POST") ||+ methods.includes("PATCH")) && (+ <>+ <h3 className="text-foreground mt-4 px-6">Subscribe to changes</h3>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>+ Supabase provides realtime functionality and broadcasts+ database changes to authorized users depending on Row Level+ Security (RLS) policies.+ </p>+ <p>+ <a+ href="https://supabase.com/docs/reference/javascript/subscribe"+ target="_blank"+ rel="noreferrer"+ >+ Learn more+ </a>+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeAll(+ resourceMeta.camelCase,+ resourceId+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeInserts(+ resourceMeta.camelCase,+ resourceId+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeUpdates(+ resourceMeta.camelCase,+ resourceId+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeDeletes(+ resourceMeta.camelCase,+ resourceId+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.subscribeEq(+ resourceMeta.camelCase,+ resourceId,+ "column_name",+ "someValue"+ )}+ />+ </article>+ </div>+ </>+ )}+ </>+ );+};++type ParamProps = {+ name?: string;+ type?: string;+ format?: string;+ required?: boolean;+ metadata?: { table: string; column: string };+ isOptional?: boolean;+ isPrimitive?: boolean;+ children?: React.ReactNode;+};++const Param = ({+ name,+ isOptional,+ type,+ format,+ children,+ isPrimitive,+}: ParamProps) => {+ return (+ <>+ <div className="mb-4 flex items-center justify-between ">+ <div className="flex gap-2 items-center">+ <div className="flex items-center gap-2">+ <label className="font-mono text-xs uppercase text-foreground-lighter min-w-[55px]">+ Column+ </label>+ <div className="flex items-center gap-4">+ <span className="text-md text-foreground pb-0.5">{name}</span>+ </div>+ </div>+ </div>+ <div+ className={cn(+ "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs",+ !isOptional && "border-amber-700 bg-amber-300 text-amber-900 "+ )}+ >+ {isOptional ? "Optional" : "Required"}+ </div>+ </div>+ <div className="grid gap-2 mt-6">+ <div className="mb-4 flex items-center gap-2">+ <label className="font-mono text-xs uppercase text-foreground-lighter min-w-[55px]">+ Type+ </label>+ <div>+ <span className="flex grow-0 bg-muted px-2 py-0.5 rounded-md text-foreground-light">+ <span className="flex items-center gap-2 text-sm">+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <polyline points="16 18 22 12 16 6"></polyline>+ <polyline points="8 6 2 12 8 18"></polyline>+ </svg>+ <span>{type}</span>+ </span>+ </span>+ </div>+ </div>+ <div className="mb-4 flex items-center gap-2">+ <label className="font-mono text-xs uppercase text-foreground-lighter min-w-[55px]">+ Format+ </label>+ <div>+ <span className="flex grow-0 bg-muted px-2 py-0.5 rounded-md text-foreground-light">+ <span className="flex items-center gap-2 text-sm">+ <svg+ xmlns="http://www.w3.org/2000/svg"+ width="14"+ height="14"+ viewBox="0 0 24 24"+ fill="none"+ stroke="currentColor"+ stroke-linecap="round"+ stroke-linejoin="round"+ >+ <ellipse cx="12" cy="5" rx="9" ry="3"></ellipse>+ <path d="M21 12c0 1.66-4 3-9 3s-9-1.34-9-3"></path>+ <path d="M3 5v14c0 1.66 4 3 9 3s9-1.34 9-3V5"></path>+ </svg>+ <span>{format}</span>+ </span>+ </span>+ </div>+ </div>+ </div>+ </>+ );+};++export default TableDocs;diff --git a/apps/carbon/app/modules/api/ui/index.ts b/apps/carbon/app/modules/api/ui/index.tsnew file mode 100644index 0000000000..f5bd8ead5c--- /dev/null+++ b/apps/carbon/app/modules/api/ui/index.ts@@ -0,0 +1,8 @@+import CodeSnippet from "./CodeSnippet";+import Snippets from "./Snippets";+import TableDocs from "./TableDocs";+import type { ValidLang } from "./useSelectedLang";+import { useSelectedLang } from "./useSelectedLang";++export { CodeSnippet, Snippets, TableDocs, useSelectedLang };+export type { ValidLang };diff --git a/apps/carbon/app/modules/api/ui/useSelectedLang.tsx b/apps/carbon/app/modules/api/ui/useSelectedLang.tsxnew file mode 100644index 0000000000..9fbfda504b--- /dev/null+++ b/apps/carbon/app/modules/api/ui/useSelectedLang.tsx@@ -0,0 +1,17 @@+import { useParams } from "@remix-run/react";++export type ValidLang = "js" | "bash";++export function useSelectedLang(): ValidLang {+ const { lang } = useParams();+ if (isValidLang(lang)) {+ return lang;+ } else {+ return "js";+ }+}++// write a typescript is function that verifies the lang is valid+function isValidLang(lang: unknown): lang is ValidLang {+ return lang === "js" || lang === "bash";+}diff --git a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsxindex e7966ae041..6e2ef46ee8 100644--- a/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Consumables/ConsumableProperties.tsx@@ -16,6 +16,7 @@ import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/modules/shared";import type { ListItem } from "~/types";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, Consumable, ItemFile, PickMethod } from "../../types";import { FileBadge } from "../Item";@@ -64,7 +65,7 @@ const ConsumableProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.consumable(itemId))}@@ -84,9 +85,7 @@ const ConsumableProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(- routeData?.consumableSummary?.id ?? ""- )+ copyToClipboard(routeData?.consumableSummary?.id ?? "")}><LuCopy className="w-3 h-3" />diff --git a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsxindex d67e8ea2f9..e287772c6a 100644--- a/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Fixtures/FixtureProperties.tsx@@ -20,6 +20,7 @@ import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/modules/shared";import type { ListItem } from "~/types";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, Fixture, ItemFile, PickMethod } from "../../types";import { FileBadge } from "../Item";@@ -68,7 +69,7 @@ const FixtureProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.fixture(itemId))}@@ -88,9 +89,7 @@ const FixtureProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(- routeData?.fixtureSummary?.id ?? ""- )+ copyToClipboard(routeData?.fixtureSummary?.id ?? "")}><LuCopy className="w-3 h-3" />diff --git a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsxindex 3c0d59b3ff..2a3c6baed7 100644--- a/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Materials/MaterialProperties.tsx@@ -16,6 +16,7 @@ import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/modules/shared";import type { ListItem } from "~/types";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, ItemFile, Material, PickMethod } from "../../types";import { FileBadge } from "../Item";@@ -64,7 +65,7 @@ const MaterialProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.material(itemId))}@@ -84,9 +85,7 @@ const MaterialProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(- routeData?.materialSummary?.id ?? ""- )+ copyToClipboard(routeData?.materialSummary?.id ?? "")}><LuCopy className="w-3 h-3" />diff --git a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsxindex 71f6f19755..9c681fcf33 100644--- a/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Parts/PartProperties.tsx@@ -17,6 +17,7 @@ import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/modules/shared";import type { ListItem } from "~/types";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, ItemFile, PartSummary, PickMethod } from "../../types";import { FileBadge } from "../Item";@@ -65,7 +66,7 @@ const PartProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.part(itemId))}@@ -85,9 +86,7 @@ const PartProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(- routeData?.partSummary?.id ?? ""- )+ copyToClipboard(routeData?.partSummary?.id ?? "")}><LuCopy className="w-3 h-3" />diff --git a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsxindex ce8bea810f..e1ab9ae08f 100644--- a/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Services/ServiceProperties.tsx@@ -15,6 +15,7 @@ import { Assignee, useOptimisticAssignment } from "~/components";import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon } from "~/modules/shared";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, ItemFile, PickMethod, Service } from "../../types";import { FileBadge } from "../Item";@@ -58,7 +59,7 @@ const ServiceProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.service(itemId))}@@ -77,9 +78,7 @@ const ServiceProperties = () => {aria-label="Copy"size="sm"className="p-1"- onClick={() =>- navigator.clipboard.writeText(routeData?.service?.id ?? "")- }+ onClick={() => copyToClipboard(routeData?.service?.id ?? "")}><LuCopy className="w-3 h-3" /></Button>diff --git a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsxindex dee99cd88e..1a4f32f94f 100644--- a/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx+++ b/apps/carbon/app/modules/items/ui/Tools/ToolProperties.tsx@@ -16,6 +16,7 @@ import { usePermissions, useRouteData } from "~/hooks";import { MethodBadge, MethodIcon, TrackingTypeIcon } from "~/modules/shared";import type { ListItem } from "~/types";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";import type { BuyMethod, ItemFile, PickMethod, Tool } from "../../types";import { FileBadge } from "../Item";@@ -64,7 +65,7 @@ const ToolProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(+ copyToClipboard(window.location.origin + path.to.tool(itemId))}@@ -84,9 +85,7 @@ const ToolProperties = () => {size="sm"className="p-1"onClick={() =>- navigator.clipboard.writeText(- routeData?.toolSummary?.id ?? ""- )+ copyToClipboard(routeData?.toolSummary?.id ?? "")}><LuCopy className="w-3 h-3" />diff --git a/apps/carbon/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx b/apps/carbon/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsxindex 503bd829e9..db6cb63b98 100644--- a/apps/carbon/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx+++ b/apps/carbon/app/modules/settings/ui/ApiKeys/ApiKeysForm.tsx@@ -24,6 +24,7 @@ import { Hidden, Input, Submit } from "~/components/Form";import { usePermissions } from "~/hooks";import { apiKeyValidator } from "~/modules/settings";import { path } from "~/utils/path";+import { copyToClipboard } from "~/utils/string";type ApiKeyFormProps = {initialValues: z.infer<typeof apiKeyValidator>;@@ -98,6 +99,12 @@ type ApiKeyViewProps = {function ApiKeyView({ apiKey, onClose }: ApiKeyViewProps) {const [copied, setCopied] = useState(false);+ useEffect(() => {+ if (!copied) return;+ const timer = setTimeout(() => setCopied(false), 2000);+ return () => clearTimeout(timer);+ }, [copied]);+return (<Modalopen@@ -125,8 +132,9 @@ function ApiKeyView({ apiKey, onClose }: ApiKeyViewProps) {icon={copied ? <LuCheck /> : <LuClipboard />}variant="ghost"onClick={() => {- navigator.clipboard.writeText(apiKey);- setCopied(true);+ copyToClipboard(apiKey, () => {+ setCopied(true);+ });}}/></InputRightElement>diff --git a/apps/carbon/app/routes/x+/api+/$lang.authentication.tsx b/apps/carbon/app/routes/x+/api+/$lang.authentication.tsxnew file mode 100644index 0000000000..cd964c1e8c--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/$lang.authentication.tsx@@ -0,0 +1,64 @@+import { getBrowserEnv } from "~/config/env";+import { CodeSnippet, Snippets, useSelectedLang } from "~/modules/api";++const { SUPABASE_ANON_PUBLIC, SUPABASE_API_URL } = getBrowserEnv();++export default function Authentication() {+ const selectedLang = useSelectedLang();++ return (+ <>+ <h2 className="doc-heading">Authentication</h2>+ <div className="doc-section">+ <article className="code-column text-foreground">+ <p>Supabase works through a mixture of JWT and Key auth.</p>+ <p>+ If no <code>Authorization</code> header is included, the API will+ assume that you are making a request with an anonymous user.+ </p>+ <p>+ If an <code>Authorization</code> header is included, the API will+ "switch" to the role of the user making the request. See the User+ Management section for more details.+ </p>+ <p>We recommend setting your keys as Environment Variables.</p>+ </article>+ </div>++ <h2 className="doc-heading">Client API Keys</h2>+ <div className="doc-section ">+ <article className="code-column text-foreground">+ <p>+ Client keys allow "anonymous access" to your database, until the+ user has logged in. After logging in the keys will switch to the+ user's own login token.+ </p>+ <p>+ In this documentation, we will refer to the key using the name{" "}+ <code>SUPABASE_KEY</code>.+ </p>+ </article>+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.authKey(+ "CLIENT API KEY",+ "SUPABASE_KEY",+ SUPABASE_ANON_PUBLIC+ )}+ />+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.authKeyExample(+ SUPABASE_ANON_PUBLIC,+ SUPABASE_API_URL,+ {+ showBearer: false,+ }+ )}+ />+ </article>+ </div>+ </>+ );+}diff --git a/apps/carbon/app/routes/x+/api+/$lang.intro.tsx b/apps/carbon/app/routes/x+/api+/$lang.intro.tsxnew file mode 100644index 0000000000..5059b02cee--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/$lang.intro.tsx@@ -0,0 +1,18 @@+import { getBrowserEnv } from "~/config/env";+import { CodeSnippet, Snippets, useSelectedLang } from "~/modules/api";++const { SUPABASE_API_URL } = getBrowserEnv();++export default function Route() {+ const selectedLang = useSelectedLang();+ return (+ <div className="doc-section doc-section--client-libraries">+ <article className="code">+ <CodeSnippet+ selectedLang={selectedLang}+ snippet={Snippets.init(SUPABASE_API_URL)}+ />+ </article>+ </div>+ );+}diff --git a/apps/carbon/app/routes/x+/api+/$lang.rpc.$id.tsx b/apps/carbon/app/routes/x+/api+/$lang.rpc.$id.tsxnew file mode 100644index 0000000000..6ad046ea64--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/$lang.rpc.$id.tsx@@ -0,0 +1,37 @@+import swaggerDocsSchema from "~/lib/swagger-docs-schema";+import { useSelectedLang } from "~/modules/api";+import { snakeToCamel } from "~/utils/string";++const functionPath = "rpc/";+const { rpcs } = Object.entries(swaggerDocsSchema.paths || {}).reduce(+ (a, [name]) => {+ const trimmedName = name.slice(1);+ const id = trimmedName.replace(functionPath, "");++ const displayName = id.replace(/_/g, " ");+ const camelCase = snakeToCamel(id);+ const enriched = { id, displayName, camelCase };++ if (!trimmedName.length) {+ return a;+ }++ return {+ rpcs: {+ ...a.rpcs,+ ...(trimmedName.includes(functionPath)+ ? {+ [id]: enriched,+ }+ : {}),+ },+ };+ },+ { rpcs: {} }+);++export default function Route() {+ const selectedLang = useSelectedLang();++ return null;+}diff --git a/apps/carbon/app/routes/x+/api+/$lang.table.$id.tsx b/apps/carbon/app/routes/x+/api+/$lang.table.$id.tsxnew file mode 100644index 0000000000..8cd2dd2a54--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/$lang.table.$id.tsx@@ -0,0 +1,50 @@+import { useParams } from "@remix-run/react";+import { getBrowserEnv } from "~/config/env";+import swaggerDocsSchema from "~/lib/swagger-docs-schema";+import { TableDocs, useSelectedLang } from "~/modules/api";+import { snakeToCamel } from "~/utils/string";++const { SUPABASE_API_URL } = getBrowserEnv();++const functionPath = "rpc/";+const { resources } = Object.entries(swaggerDocsSchema.paths || {}).reduce(+ (a, [name]) => {+ const trimmedName = name.slice(1);+ const id = trimmedName.replace(functionPath, "");++ const displayName = id.replace(/_/g, " ");+ const camelCase = snakeToCamel(id);+ const enriched = { id, displayName, camelCase };++ if (!trimmedName.length) {+ return a;+ }++ return {+ resources: {+ ...a.resources,+ ...(!trimmedName.includes(functionPath)+ ? {+ [id]: enriched,+ }+ : {}),+ },+ };+ },+ { resources: {} }+);++export default function Route() {+ const selectedLang = useSelectedLang();+ const { id } = useParams();+ if (!id) throw new Error("Table id not found");++ return (+ <TableDocs+ endpoint={SUPABASE_API_URL}+ selectedLang={selectedLang}+ resourceId={id}+ resources={resources}+ />+ );+}diff --git a/apps/carbon/app/routes/x+/api+/_index.tsx b/apps/carbon/app/routes/x+/api+/_index.tsxnew file mode 100644index 0000000000..4e53920080--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/_index.tsx@@ -0,0 +1,6 @@+import { redirect } from "@remix-run/node";+import { path } from "~/utils/path";++export async function loader() {+ throw redirect(path.to.apiIntroduction);+}diff --git a/apps/carbon/app/routes/x+/api+/_layout.tsx b/apps/carbon/app/routes/x+/api+/_layout.tsxnew file mode 100644index 0000000000..9a4b49505b--- /dev/null+++ b/apps/carbon/app/routes/x+/api+/_layout.tsx@@ -0,0 +1,73 @@+import type { MetaFunction } from "@remix-run/node";+import { Outlet } from "@remix-run/react";+import { GroupedContentSidebar } from "~/components/Layout";+import swaggerDocsSchema from "~/lib/swagger-docs-schema";+import { useSelectedLang } from "~/modules/api";+import DocsStyle from "~/styles/docs.css?url";+import type { RouteGroup } from "~/types";+import type { Handle } from "~/utils/handle";+import { path } from "~/utils/path";++export const meta: MetaFunction = () => {+ return [{ title: "Carbon | API Docs" }];+};++export const handle: Handle = {+ breadcrumb: "API Docs",+ to: path.to.apiIntroduction,+ module: "api",+};++export function links() {+ return [{ rel: "stylesheet", href: DocsStyle }];+}++export default function ApiDocsRoute() {+ const groups = useApiDocsMenu();++ return (+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} width={270} />+ <div className="Docs Docs--api-page w-full h-full overflow-y-auto">+ <div className="Docs--inner-wrapper pt-4">+ <Outlet />+ </div>+ </div>+ </div>+ );+}++const tableBlacklist = new Set(["apiKey"]);++function useApiDocsMenu(): RouteGroup[] {+ const selectedLang = useSelectedLang();+ const result: RouteGroup[] = [+ {+ name: "Getting Started",+ routes: [+ {+ name: "Introduction",+ to: path.to.apiIntro(selectedLang),+ },+ {+ name: "Authentication",+ to: path.to.apiAuthentication(selectedLang),+ },+ ],+ },+ ];++ const tables = Object.keys(swaggerDocsSchema.definitions).sort();++ result.push({+ name: "Tables and Views",+ routes: tables+ .filter((table) => !tableBlacklist.has(table))+ .map((table) => ({+ name: table,+ to: path.to.apiTable(selectedLang, table),+ })),+ });++ return result;+}diff --git a/apps/carbon/app/styles/docs.css b/apps/carbon/app/styles/docs.cssnew file mode 100644index 0000000000..13cecf88e8--- /dev/null+++ b/apps/carbon/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/carbon/app/utils/path.ts b/apps/carbon/app/utils/path.tsindex dc6d5d920a..7446c68964 100644--- a/apps/carbon/app/utils/path.ts+++ b/apps/carbon/app/utils/path.ts@@ -99,6 +99,11 @@ export const path = {generatePath(`${x}/accounting/subcategory/${id}`),attribute: (id: string) => generatePath(`${x}/people/attribute/${id}`),attributes: `${x}/people/attributes`,+ apiAuthentication: (lang: string) => `${x}/api/${lang}/authentication`,+ apiIntroduction: `${x}/api/js/intro`,+ apiIntro: (lang: string) => generatePath(`${x}/api/${lang}/intro/`),+ apiTable: (lang: string, table: string) =>+ generatePath(`${x}/api/${lang}/table/${table}`),apiKey: (id: string) => generatePath(`${x}/settings/api-keys/${id}`),apiKeys: `${x}/settings/api-keys`,attributeCategory: (id: string) =>diff --git a/apps/carbon/app/utils/string.ts b/apps/carbon/app/utils/string.tsindex 2a922f7497..16a83c9819 100644--- a/apps/carbon/app/utils/string.ts+++ b/apps/carbon/app/utils/string.ts@@ -3,6 +3,11 @@ export const capitalize = (words: string) => {return [first.toLocaleUpperCase(), ...otherLetters].join("");};+export const snakeToCamel = (str: string) =>+ str.replace(/([-_][a-z])/g, (group: string) =>+ group.toUpperCase().replace("-", "").replace("_", "")+ );+/*** Copy text content (string or Promise<string>) into Clipboard.* Safari doesn't support write text into clipboard async, so if you need to loaddiff --git a/package-lock.json b/package-lock.jsonindex eb24b56395..3fdcc1c148 100644--- a/package-lock.json+++ b/package-lock.json@@ -10813,6 +10813,11 @@"resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.3.tgz","integrity": "sha512-+68kP9yzs4LMp7VNh8gdzMSPZFL44MLGqiHWvttYJe+6qnuVr4Ek9wSBQoveqY/r+LwjCcU29kNVkidwim+kYA=="},+ "node_modules/@types/prismjs": {+ "version": "1.26.4",+ "resolved": "https://registry.npmjs.org/@types/prismjs/-/prismjs-1.26.4.tgz",+ "integrity": "sha512-rlAnzkW2sZOjbqZ743IHUhFcvzaGbqijwOu8QZnZCjfQzBqFE3s4lOTJEsxikImav9uzz/42I+O7YUs1mWgMlg=="+ },"node_modules/@types/prop-types": {"version": "15.7.12","resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.12.tgz",@@ -27848,6 +27853,18 @@"url": "https://github.com/sponsors/sindresorhus"}},+ "node_modules/prism-react-renderer": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/prism-react-renderer/-/prism-react-renderer-2.3.1.tgz",+ "integrity": "sha512-Rdf+HzBLR7KYjzpJ1rSoxT9ioO85nZngQEoFIhL07XhtJHlCU3SOz0GJ6+qvMyQe0Se+BV3qpe6Yd/NmQF5Juw==",+ "dependencies": {+ "@types/prismjs": "^1.26.0",+ "clsx": "^2.0.0"+ },+ "peerDependencies": {+ "react": ">=16.0.0"+ }+ },"node_modules/prismjs": {"version": "1.29.0","resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.29.0.tgz",@@ -35684,6 +35701,7 @@"intl-parse-accept-language": "^1.0.0","is-hotkey": "^0.2.0","novel": "0.4.2",+ "prism-react-renderer": "^2.3.1","react-aria-components": "1.0.1","react-colorful": "^5.6.1","react-resizable-panels": "^2.0.9",diff --git a/packages/react/package.json b/packages/react/package.jsonindex 2e3ef6b83a..f5a9bbbf9e 100644--- a/packages/react/package.json+++ b/packages/react/package.json@@ -50,6 +50,7 @@"intl-parse-accept-language": "^1.0.0","is-hotkey": "^0.2.0","novel": "0.4.2",+ "prism-react-renderer": "^2.3.1","react-aria-components": "1.0.1","react-colorful": "^5.6.1","react-resizable-panels": "^2.0.9",diff --git a/packages/react/src/CodeBlock.tsx b/packages/react/src/CodeBlock.tsxnew file mode 100644index 0000000000..74367235ac--- /dev/null+++ b/packages/react/src/CodeBlock.tsx@@ -0,0 +1,99 @@+/**+ * Copyright (c) 2017-present, Facebook, Inc.+ *+ * This source code is licensed under the MIT license found in the+ * LICENSE file in the root directory of this source tree.+ */+import type { Language } from "prism-react-renderer";+import { Highlight, themes } from "prism-react-renderer";+import type { PropsWithChildren } from "react";+import { useEffect, useRef, useState } from "react";+import { Button } from "./Button";++const prism = {+ defaultLanguage: "js",+ plugins: ["line-numbers", "show-language"],+};++interface CodeBlockProps {+ parentClassName?: string;+ className?: string;+ showCopy?: boolean;+}++const CodeBlock = ({+ children,+ parentClassName,+ className: languageClassName,+ showCopy = true,+}: PropsWithChildren<CodeBlockProps>) => {+ const [showCopied, setShowCopied] = useState(false);+ const target = useRef(null);+ let highlightLines: any = [];++ useEffect(() => {+ if (!showCopied) return;+ const timer = setTimeout(() => setShowCopied(false), 2000);+ return () => clearTimeout(timer);+ }, [showCopied]);++ let language =+ languageClassName && languageClassName.replace(/language-/, "");++ if (!language && prism.defaultLanguage) {+ language = prism.defaultLanguage;+ }++ const handleCopyCode = (code: any) => {+ window.navigator.clipboard.writeText(code);+ setShowCopied(true);+ };++ // html tag has dark className+ const isDarkMode =+ document?.documentElement.classList.contains("dark") ?? true;++ return (+ <Highlight+ theme={isDarkMode ? themes.nightOwl : themes.nightOwlLight}+ code={(children as string)?.trim() ?? ""}+ language={language as Language}+ >+ {({ className, tokens, getLineProps, getTokenProps }) => {+ return (+ <div className="Code codeBlockWrapper group">+ <pre+ ref={target}+ className={`codeBlock ${className} ${parentClassName}`}+ >+ {tokens.map((line, i) => {+ const lineProps = getLineProps({ line, key: i });++ if (highlightLines.includes(i + 1)) {+ lineProps.className = `${lineProps.className} docusaurus-highlight-code-line`;+ }++ return (+ <div key={i} {...lineProps}>+ {line.map((token, key) => (+ <span key={key} {...getTokenProps({ token, key })} />+ ))}+ </div>+ );+ })}+ </pre>+ {showCopy && (+ <div className="invisible absolute right-0 top-0 opacity-0 transition-opacity group-hover:visible group-hover:opacity-100">+ <Button size="sm" onClick={() => handleCopyCode(children)}>+ {showCopied ? "Copied" : "Copy"}+ </Button>+ </div>+ )}+ </div>+ );+ }}+ </Highlight>+ );+};++export { CodeBlock };diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsxindex c0f7e79a50..74fa7a61ae 100644--- a/packages/react/src/index.tsx+++ b/packages/react/src/index.tsx@@ -33,6 +33,7 @@ import {} from "./Card";import { Checkbox } from "./Checkbox";import { ClientOnly } from "./ClientOnly";+import { CodeBlock } from "./CodeBlock";import {Command,CommandDialog,@@ -285,6 +286,7 @@ export {CardTitle,Checkbox,ClientOnly,+ CodeBlock,Command,CommandDialog,CommandEmpty,diff --git a/scripts/generate-swagger-docs.ts b/scripts/generate-swagger-docs.tsindex 7f3279f70f..4568be88ab 100644--- a/scripts/generate-swagger-docs.ts+++ b/scripts/generate-swagger-docs.ts@@ -1,17 +1,17 @@import { writeFileSync } from "fs";(async () => {- try {- const response = await fetch(- "http://localhost:54323/api/projects/default/api/rest"- );- const data = await response.json();-- // write the data to a javascript file using node fs module- writeFileSync(- "apps/carbon/app/lib/swagger-docs-schema.ts",- `export default ${JSON.stringify(data, null, 2)}`- );- } catch (error) {- console.error(error);+ const response = await fetch(+ "http://localhost:54323/api/projects/default/api/rest"+ );+ if (!response.ok) {+ throw new Error(`HTTP error! status: ${response.status}`);}++ const data = await response.json();++ // write the data to a javascript file using node fs module+ writeFileSync(+ "apps/carbon/app/lib/swagger-docs-schema.ts",+ `export default ${JSON.stringify(data, null, 2)}`+ );})();