feat: add @focus-reactive/payload-plugin-ai-page-builder#17
Open
dogfrogfog wants to merge 3 commits into
Open
Conversation
Implements a new Payload CMS plugin that lets editors generate complete pages from a natural-language prompt. - POST /api/ai-page-builder/generate endpoint — uses Vercel AI SDK generateObject with a Zod discriminated-union schema built from the caller's block definitions; creates a draft document and returns its id - "✨ Generate with AI" panel injected into beforeListTable for every configured collection; expands into a textarea, calls the endpoint, then navigates to the new draft in the editor - Schema-first design: the same Zod schemas drive both Payload type safety and the structured-output constraint passed to the AI model, ensuring generated content always matches the block field shapes - Wired into apps/dev with Hero + Copy block definitions for local testing Closes #16
- Guard req.json possibly-undefined call with null check - Cast schema and model through any to avoid deep type-instantiation error in generateObject invocation - Cast blockSchemas through unknown to satisfy ZodDiscriminatedUnion option constraint that expects blockType in the shape
- turbo.json: add '^build' to check-types dependsOn so workspace package dist/ is present before apps run tsgo — fixes cms:check-types failing with 'Cannot find module' when packages haven't been built yet - payload-plugin-translator: cast zodResolver call through any to silence TS2589 deep-instantiation error from tsgo with computed-key zod schemas
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements a new published plugin that generates complete Payload CMS pages from a natural-language prompt, using the Vercel AI SDK and Zod schemas.
generateObjectstructured-output constraint passed to the AI model, so generated content always matches block field shapes.POST /api/ai-page-builder/generateendpoint — accepts{ prompt, collectionSlug }, builds a Zod discriminated-union schema from the configured block definitions, callsgenerateObject, creates a draft document, and returns itsid.✨ Generate with AIbutton is injected viabeforeListTableinto every configured collection; expanding it shows a textarea, submits to the endpoint, then navigates the editor to the newly created draft.apps/devis configured with Hero + Copy block definitions so the plugin can be tested locally with anOPENAI_API_KEY.turbo.jsoncheck-typesnow depends on^buildso workspace package dist/ is present before apps runtsgo; pre-existingTS2589depth error inpayload-plugin-translator'szodResolvercalls is resolved with a targeted cast.Closes #16
Test plan
OPENAI_API_KEYinapps/dev/.envbun run dev— navigate to/admin/collections/pagesbunx turbo run build --filter='@focus-reactive/payload-plugin-ai-page-builder'— build succeedsbun run linton the plugin directory — 0 errorsGenerated by Claude Code