Feature/blog cms operations#10
Open
vH192Hv wants to merge 5 commits into
Open
Conversation
- Add Post model with title, slug, content, excerpt, coverImage, status, timestamps - Add Tag model with name and slug - Add PostTag join table for many-to-many relationship - Add PostStatus enum (DRAFT, PUBLISHED, ARCHIVED) - Add posts relation to User model Co-Authored-By: Claude <noreply@anthropic.com>
- Add seedBlogPosts function with sample posts and tags - Register seed in main.wasp.ts db.seeds array Co-Authored-By: Claude <noreply@anthropic.com>
- Define getAllPosts, getPost, getPostBySlug, getPublishedPosts queries - Define createPost, updatePost, deletePost actions - Define getAllTags, createTag, deleteTag tag operations - Register blogCmsSpec in main.wasp.ts Co-Authored-By: Claude <noreply@anthropic.com>
- Add isValidSlug, generateSlug with regex format + length checks - Add ALLOWED_TRANSITIONS map and transition validation helpers - File is browser+server safe (no wasp/server imports) Co-Authored-By: Claude <noreply@anthropic.com>
…rmissions) - Post queries: getAllPosts (admin, paginated, filters), getPost (admin, by ID), getPostBySlug (public, PUBLISHED only), getPublishedPosts (public, paginated) - Post mutations: createPost (slug gen/validate, status validation), updatePost (status transitions, tag replacement, publishedAt mgmt), deletePost (by ID with existence check) - Tag operations: getAllTags (with post count), createTag (name/slug uniqueness), deleteTag (cascade removes PostTag entries) - Permission guard: requireAdmin on all mutating + admin-read operations - Slug helpers imported from shared utils.ts - Status transitions validated via isAllowedTransition from utils.ts Co-Authored-By: Claude <noreply@anthropic.com>
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.
设计方案
Wasp Spec 声明
blog-cms.wasp.ts定义 10 个操作:操作矩阵
getAllPostsgetPostgetPostBySluggetPublishedPostscreatePostupdatePostdeletePostgetAllTagscreateTagdeleteTagSlug 校验规则
发布状态转换
isAllowedTransition()函数双端(服务端 + 客户端)校验转换合法性。权限控制
共享工具模块
utils.ts浏览器+服务端安全的纯函数模块:
generateSlug(title)— 从标题生成 slugisValidSlug(slug)— 格式 + 长度校验isAllowedTransition(from, to)— 状态转换校验getAllowedTransitions(status)— 获取允许的目标状态执行方案
blog-cms.wasp.ts+ 注册到main.wasp.tsutils.ts(shared slug helpers + status transitions)operations.ts(10 个操作 + 权限 guard + slug 校验)文件变更
template/app/src/blog-cms/blog-cms.wasp.tstemplate/app/src/blog-cms/utils.tstemplate/app/src/blog-cms/operations.tstemplate/app/main.wasp.ts🔽 依赖 PR1 (schema) — 合并顺序第 2