From 454ce84f80e60effb13398e26884501073328a0c Mon Sep 17 00:00:00 2001 From: zbeyens Date: Wed, 20 Nov 2024 16:54:10 +0100 Subject: [PATCH] docs --- apps/www/public/r/styles/default/api-ai.json | 7 ++-- .../r/styles/default/api-uploadthing.json | 5 +-- apps/www/scripts/build-registry.mts | 5 +-- .../default/app/api/ai/command/route.ts | 41 ------------------- .../default/app/api/uploadthing/route.ts | 21 ---------- apps/www/src/__registry__/index.tsx | 8 ++-- apps/www/src/registry/registry-app.ts | 10 ++--- apps/www/src/registry/schema.ts | 1 - 8 files changed, 16 insertions(+), 82 deletions(-) delete mode 100644 apps/www/src/__registry__/default/app/api/ai/command/route.ts delete mode 100644 apps/www/src/__registry__/default/app/api/uploadthing/route.ts diff --git a/apps/www/public/r/styles/default/api-ai.json b/apps/www/public/r/styles/default/api-ai.json index 2d38d22ec6..a54da9eaac 100644 --- a/apps/www/public/r/styles/default/api-ai.json +++ b/apps/www/public/r/styles/default/api-ai.json @@ -3,24 +3,23 @@ "@ai-sdk/openai", "ai" ], - "description": "", "files": [ { "content": "import type { NextRequest } from 'next/server';\n\nimport { createOpenAI } from '@ai-sdk/openai';\nimport { convertToCoreMessages, streamText } from 'ai';\nimport { NextResponse } from 'next/server';\n\nexport async function POST(req: NextRequest) {\n const {\n apiKey: key,\n messages,\n model = 'gpt-4o-mini',\n system,\n } = await req.json();\n\n const apiKey = key || process.env.OPENAI_API_KEY;\n\n if (!apiKey) {\n return NextResponse.json(\n { error: 'Missing OpenAI API key.' },\n { status: 401 }\n );\n }\n\n const openai = createOpenAI({ apiKey });\n\n try {\n const result = await streamText({\n maxTokens: 2048,\n messages: convertToCoreMessages(messages),\n model: openai(model),\n system: system,\n });\n\n return result.toDataStreamResponse();\n } catch {\n return NextResponse.json(\n { error: 'Failed to process AI request' },\n { status: 500 }\n );\n }\n}\n", "path": "app/api/ai/command/route.ts", "target": "app/api/ai/command/route.ts", - "type": "registry:block" + "type": "registry:lib" }, { "content": "import type { NextRequest } from 'next/server';\n\nimport { createOpenAI } from '@ai-sdk/openai';\nimport { generateText } from 'ai';\nimport { NextResponse } from 'next/server';\n\nexport async function POST(req: NextRequest) {\n const {\n apiKey: key,\n model = 'gpt-4o-mini',\n prompt,\n system,\n } = await req.json();\n\n const apiKey = key || process.env.OPENAI_API_KEY;\n\n if (!apiKey) {\n return NextResponse.json(\n { error: 'Missing OpenAI API key.' },\n { status: 401 }\n );\n }\n\n const openai = createOpenAI({ apiKey });\n\n try {\n const result = await generateText({\n abortSignal: req.signal,\n maxTokens: 50,\n model: openai(model),\n prompt: prompt,\n system,\n temperature: 0.7,\n });\n\n return NextResponse.json(result);\n } catch (error: any) {\n if (error.name === 'AbortError') {\n return NextResponse.json(null, { status: 408 });\n }\n\n return NextResponse.json(\n { error: 'Failed to process AI request' },\n { status: 500 }\n );\n }\n}\n", "path": "app/api/ai/copilot/route.ts", "target": "app/api/ai/copilot/route.ts", - "type": "registry:block" + "type": "registry:lib" } ], "name": "api-ai", "registryDependencies": [ "use-chat" ], - "type": "registry:block" + "type": "registry:lib" } \ No newline at end of file diff --git a/apps/www/public/r/styles/default/api-uploadthing.json b/apps/www/public/r/styles/default/api-uploadthing.json index f33c86464f..a58eea3a4b 100644 --- a/apps/www/public/r/styles/default/api-uploadthing.json +++ b/apps/www/public/r/styles/default/api-uploadthing.json @@ -2,16 +2,15 @@ "dependencies": [ "uploadthing@7.2.0" ], - "description": "", "files": [ { "content": "import type { FileRouter } from 'uploadthing/next';\n\nimport { createRouteHandler, createUploadthing } from 'uploadthing/next';\n\nconst f = createUploadthing();\n\nconst ourFileRouter = {\n editorUploader: f(['image', 'text', 'blob', 'pdf', 'video', 'audio'])\n .middleware(() => {\n return {};\n })\n .onUploadComplete(({ file }) => {\n return { file };\n }),\n} satisfies FileRouter;\n\nexport type OurFileRouter = typeof ourFileRouter;\n\nexport const { GET, POST } = createRouteHandler({\n router: ourFileRouter,\n});\n", "path": "app/api/uploadthing/route.ts", "target": "app/api/uploadthing/route.ts", - "type": "registry:block" + "type": "registry:lib" } ], "name": "api-uploadthing", "registryDependencies": [], - "type": "registry:block" + "type": "registry:lib" } \ No newline at end of file diff --git a/apps/www/scripts/build-registry.mts b/apps/www/scripts/build-registry.mts index 2a05cb7122..d7a3aa809f 100644 --- a/apps/www/scripts/build-registry.mts +++ b/apps/www/scripts/build-registry.mts @@ -24,7 +24,6 @@ import { fixImport } from "./fix-import.mts" const REGISTRY_PATH = path.join(process.cwd(), "public/r") const REGISTRY_INDEX_WHITELIST: z.infer[] = [ - "registry:app", "registry:ui", "registry:lib", "registry:hook", @@ -291,7 +290,7 @@ export const Index: Record = { type: "${item.type}", registryDependencies: ${JSON.stringify(item.registryDependencies)}, files: [${resolveFiles.map((file) => `"${file}"`)}], - ${item.type !== "registry:app" ? `component: ${componentImport},` : ""} + component: ${componentImport}, source: "${sourceFilename}", category: "${item.category ?? ''}", subcategory: "${item.subcategory ?? ''}", @@ -413,7 +412,7 @@ async function buildStyles(registry: Registry) { if (!target || target === "") { const fileName = file.path.split("/").pop() - if (file.type === "registry:component" || file.type === "registry:app") { + if (file.type === "registry:component") { target = file.path } if ( diff --git a/apps/www/src/__registry__/default/app/api/ai/command/route.ts b/apps/www/src/__registry__/default/app/api/ai/command/route.ts deleted file mode 100644 index 76175403d4..0000000000 --- a/apps/www/src/__registry__/default/app/api/ai/command/route.ts +++ /dev/null @@ -1,41 +0,0 @@ -import type { NextRequest } from 'next/server'; - -import { createOpenAI } from '@ai-sdk/openai'; -import { convertToCoreMessages, streamText } from 'ai'; -import { NextResponse } from 'next/server'; - -export async function POST(req: NextRequest) { - const { - apiKey: key, - messages, - model = 'gpt-4o-mini', - system, - } = await req.json(); - - const apiKey = key || process.env.OPENAI_API_KEY; - - if (!apiKey) { - return NextResponse.json( - { error: 'Missing OpenAI API key.' }, - { status: 401 } - ); - } - - const openai = createOpenAI({ apiKey }); - - try { - const result = await streamText({ - maxTokens: 2048, - messages: convertToCoreMessages(messages), - model: openai(model), - system: system, - }); - - return result.toDataStreamResponse(); - } catch { - return NextResponse.json( - { error: 'Failed to process AI request' }, - { status: 500 } - ); - } -} diff --git a/apps/www/src/__registry__/default/app/api/uploadthing/route.ts b/apps/www/src/__registry__/default/app/api/uploadthing/route.ts deleted file mode 100644 index f3d0c2d5b3..0000000000 --- a/apps/www/src/__registry__/default/app/api/uploadthing/route.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { FileRouter } from 'uploadthing/next'; - -import { createRouteHandler, createUploadthing } from 'uploadthing/next'; - -const f = createUploadthing(); - -const ourFileRouter = { - editorUploader: f(['image', 'text', 'blob', 'pdf', 'video', 'audio']) - .middleware(() => { - return {}; - }) - .onUploadComplete(({ file }) => { - return { file }; - }), -} satisfies FileRouter; - -export type OurFileRouter = typeof ourFileRouter; - -export const { GET, POST } = createRouteHandler({ - router: ourFileRouter, -}); diff --git a/apps/www/src/__registry__/index.tsx b/apps/www/src/__registry__/index.tsx index 2abf700cca..4e081dfbf9 100644 --- a/apps/www/src/__registry__/index.tsx +++ b/apps/www/src/__registry__/index.tsx @@ -2324,11 +2324,11 @@ export const Index: Record = { "api-ai": { name: "api-ai", description: "", - type: "registry:block", + type: "registry:lib", registryDependencies: ["use-chat"], files: ["registry/default/app/api/ai/command/route.ts","registry/default/app/api/ai/copilot/route.ts"], component: React.lazy(() => import("@/registry/default/app/api/ai/command/route.ts")), - source: "src/__registry__/default/app/api/ai/command/route.ts", + source: "", category: "", subcategory: "", chunks: [] @@ -2336,11 +2336,11 @@ export const Index: Record = { "api-uploadthing": { name: "api-uploadthing", description: "", - type: "registry:block", + type: "registry:lib", registryDependencies: [], files: ["registry/default/app/api/uploadthing/route.ts"], component: React.lazy(() => import("@/registry/default/app/api/uploadthing/route.ts")), - source: "src/__registry__/default/app/api/uploadthing/route.ts", + source: "", category: "", subcategory: "", chunks: [] diff --git a/apps/www/src/registry/registry-app.ts b/apps/www/src/registry/registry-app.ts index ad421144ac..7efdf71960 100644 --- a/apps/www/src/registry/registry-app.ts +++ b/apps/www/src/registry/registry-app.ts @@ -7,17 +7,17 @@ export const registryApp: Registry = [ { path: 'app/api/ai/command/route.ts', target: 'app/api/ai/command/route.ts', - type: 'registry:block', + type: 'registry:lib', }, { path: 'app/api/ai/copilot/route.ts', target: 'app/api/ai/copilot/route.ts', - type: 'registry:block', + type: 'registry:lib', }, ], name: 'api-ai', registryDependencies: ['use-chat'], - type: 'registry:block', + type: 'registry:lib', }, { dependencies: ['uploadthing@7.2.0'], @@ -25,11 +25,11 @@ export const registryApp: Registry = [ { path: 'app/api/uploadthing/route.ts', target: 'app/api/uploadthing/route.ts', - type: 'registry:block', + type: 'registry:lib', }, ], name: 'api-uploadthing', registryDependencies: [], - type: 'registry:block', + type: 'registry:lib', }, ]; diff --git a/apps/www/src/registry/schema.ts b/apps/www/src/registry/schema.ts index 6500032f1e..60f78fd26a 100644 --- a/apps/www/src/registry/schema.ts +++ b/apps/www/src/registry/schema.ts @@ -16,7 +16,6 @@ export const blockChunkSchema = z.object({ export const registryItemTypeSchema = z.enum([ 'registry:pro', - 'registry:app', 'registry:style', 'registry:lib', 'registry:example',