Skip to content

feat: Add global issues checkers that check across definition#801

Merged
kingston merged 6 commits into
mainfrom
kingston/eng-1052-add-global-issue-checkers-for-plugins
Mar 10, 2026
Merged

feat: Add global issues checkers that check across definition#801
kingston merged 6 commits into
mainfrom
kingston/eng-1052-add-global-issue-checkers-for-plugins

Conversation

@kingston

@kingston kingston commented Mar 10, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Definition warnings: new dialog and workflow to show/save project definition warnings and surface them before syncing.
  • Bug Fixes

    • Fixed action button alignment in toast notifications.
  • Improvements

    • Stricter GraphQL type definitions and stronger validation for schema/mutation/relation configurations exposed to the UI.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Mar 10, 2026

Copy link
Copy Markdown

Deploying baseplate-storybook with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2115730
Status: ✅  Deploy successful!
Preview URL: https://a7e11222.baseplate-storybook.pages.dev
Branch Preview URL: https://kingston-eng-1052-add-global.baseplate-storybook.pages.dev

View logs

@changeset-bot

changeset-bot Bot commented Mar 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8a949b3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6c1cc3bf-ab9f-41cd-87b1-a1f4925d9079

📥 Commits

Reviewing files that changed from the base of the PR and between 2115730 and 8a949b3.

⛔ Files ignored due to path filters (1)
  • examples/todo-with-better-auth/apps/admin/baseplate/generated/src/routes/admin/todos/todo-list/-components/todo-list-edit-form.tsx is excluded by !**/generated/**, !**/generated/**
📒 Files selected for processing (2)
  • examples/todo-with-better-auth/apps/admin/src/routes/admin/todos/todo-list/-components/todo-list-edit-form.tsx
  • packages/project-builder-server/src/core-modules/admin-crud-input-compiler.ts

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


📝 Walkthrough

Walkthrough

Introduces entity-scoped definition issues and warning support: propagates entity context through schema walking and ref visitors, adds built-in checkers (mutation-roles, relation-type-mismatch), refactors the issue collection pipeline to accept a ProjectDefinitionContainer, and surfaces non-blocking warnings in the web UI with a new dialog and hooks.

Changes

Cohort / File(s) Summary
UI Toaster Components
examples/blog-with-auth/apps/admin/src/components/ui/toaster.tsx, examples/todo-with-better-auth/apps/admin/src/components/ui/toaster.tsx, examples/todo-with-better-auth/apps/web/src/components/ui/toaster.tsx, packages/react-generators/src/generators/.../templates/components/ui/toaster.tsx, packages/ui-components/src/components/ui/toaster/toaster.tsx
Adjusted toast actionButton class composition to prefix ml-auto to buttonVariants(...) via template literals (styling/class construction change).
GraphQL Introspection Types
examples/blog-with-auth/apps/admin/src/graphql-env.d.ts, examples/todo-with-better-auth/apps/admin/src/graphql-env.d.ts, examples/todo-with-better-auth/apps/web/src/graphql-env.d.ts
Updated introspection declarations: added/expanded scalar entries (Int, Date, DateTime) and tightened nullable constraints (e.g., User.name to non-null, strengthened list element nullability).
Project Configuration
examples/blog-with-auth/baseplate/project-definition.json
Removed instanceRoles fields and simplified queries.list objects (removed count sub-object) for two models.
Definition Issue Types
packages/project-builder-lib/src/schema/creator/definition-issue-types.ts
Reworked issue typing: introduced base type and two exported variants (EntityDefinitionIssue scoped to entity; RootDefinitionIssue scoped to root) and replaced prior single DefinitionIssue export with a union.
Definition Issue Utilities
packages/project-builder-lib/src/parser/definition-issue-utils.ts
Added resolveIssuePath to convert issue paths to absolute references and createEntityIssue to build entity-scoped issues with validation.
Collect/Parser Pipeline
packages/project-builder-lib/src/parser/collect-definition-issues.ts, packages/project-builder-lib/src/parser/collect-definition-issues.unit.test.ts
Refactored to accept a ProjectDefinitionContainer, integrated built-in checkers collection, changed field-checker invocation to value-only, and adapted tests to the new expression-issues entrypoint.
Built-in Checkers & Tests
packages/project-builder-lib/src/parser/definition-issue-checkers/mutation-roles-checker.ts, .../mutation-roles-checker.unit.test.ts, packages/project-builder-lib/src/parser/definition-issue-checkers/relation-type-mismatch-checker.ts, .../relation-type-mismatch-checker.unit.test.ts
Added two new built-in checkers: checkMutationRoles (warns when exposed mutations lack role config when auth enabled) and checkRelationTypeMismatch (warns when local/foreign relation field types mismatch); included unit tests.
Schema Walker / Entity Context
packages/project-builder-lib/src/parser/walk-data-with-schema.ts
Extended SchemaWalkContext with entityId and entityRelativePath; added entity boundary detection and save/restore semantics to propagate entity-aware paths during traversal.
Ref Schema Visitor
packages/project-builder-lib/src/references/ref-schema-visitor.ts
Propagated entity context (entityId, entityRelativePath) into ref visitor RefWalkContext so collectors receive entity-scoped context.
Field Issue Checker Contracts
packages/project-builder-lib/src/schema/creator/definition-issue-registry.ts, packages/project-builder-lib/src/schema/creator/definition-issue-checker-spec.ts
Changed field-checker contract: introduced FieldIssueResult (pick of issue fields), removed per-field ctx param (checkers now accept only value), and updated DefinitionIssueChecker signature to accept ProjectDefinitionContainer.
Definition Issue Checkers Impl & Tests
packages/project-builder-lib/src/schema/creator/definition-issue-checkers.ts, .../definition-issue-checkers.unit.test.ts
Adapted checkers to new FieldIssueResult return type and value-only invocation; simplified path construction to index-relative paths; updated tests accordingly.
Model Checkers
packages/project-builder-lib/src/schema/models/models.ts
Updated checkServiceMethods and checkModelConstraints to return FieldIssueResult[] and simplified issue path literals (removed ctx path dependency).
Plugin Testing Utilities
packages/project-builder-lib/src/plugins/plugins.test-utils.ts
Added createTestPluginSpecStore(modules?) helper to create an initialized PluginSpecStore for tests.
Parser Exports
packages/project-builder-lib/src/parser/index.ts
Re-exported createEntityIssue and resolveIssuePath from parser barrel.
Web Hook & Provider API
packages/project-builder-lib/src/web/hooks/use-project-definition.ts, packages/project-builder-web/src/app/project-definition-provider/project-definition-provider.tsx
Added SaveDefinitionResult and changed saveDefinition to return warnings (Promise<{ warnings: DefinitionIssue[] }>); provider now computes and exposes definitionWarnings and integrates warnings into save flow/UI feedback.
Server Callsites
packages/project-builder-server/src/actions/definition/commit-draft.action.ts, packages/project-builder-server/src/actions/definition/validate-draft.ts
Updated calls to collectDefinitionIssues to pass the container object; added optional entityId to definitionIssueSchema and clarified path semantics.
Web UI: Warning Dialog & Hooks
packages/project-builder-web/src/components/definition-warning-dialog/definition-warning-dialog.tsx, packages/project-builder-web/src/hooks/use-definition-warning-dialog.ts, packages/project-builder-web/src/app/app-layout/app-layout.tsx, packages/project-builder-web/src/app/project-sync-modal/project-sync-modal.tsx
Added a DefinitionWarningDialog component and Zustand-based dialog hook, mounted dialog in AppLayout, integrated warnings in ProjectSyncModal (icons and pre-sync warning flow), and added showWarnings flow for UI to surface warnings before actions.
Other Small Changes
examples/todo-with-better-auth/apps/admin/src/routes/.../todo-list-edit-form.tsx, packages/project-builder-server/src/core-modules/admin-crud-input-compiler.ts
Minor adjustments: removed fallback label in owner option mapping; added helper to detect optional foreign label fields and pass defaultLabel conditionally in admin CRUD input generation.

Sequence Diagram

sequenceDiagram
    participant User
    participant Provider as ProjectDefinitionProvider
    participant Validator as collectDefinitionIssues
    participant Dialog as DefinitionWarningDialog
    participant Server as Server

    User->>Provider: saveDefinition()
    Provider->>Validator: collectDefinitionIssues(container)
    Validator->>Validator: Run built-in checkers<br/>(mutation-roles, relation-type-mismatch)
    Validator->>Validator: Partition issues<br/>(errors vs warnings)
    Validator-->>Provider: { errors[], warnings[] }
    
    alt Errors exist
        Provider->>User: Throw error<br/>(block save)
    else No errors
        Provider->>Server: Sync definition
        Server-->>Provider: Success
        Provider->>Provider: Update definitionWarnings
        
        alt Warnings exist
            Provider->>User: Show warning toast<br/>with "View" action
            User->>Dialog: Click "View"
            Dialog->>Dialog: Resolve entity paths<br/>from warnings
            Dialog->>User: Display warnings table<br/>(Entity, Path, Message)
        else No warnings
            Provider->>User: Show success toast
        end
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • #779 — Continues the refactor of definition issue collection and expression-derived issue integration; closely aligns with container-based checkers and parser changes.
  • #549 — Refactors auth into a plugin-backed authConfig and role retrieval; directly related to mutation-roles checker and auth-dependent validations.
  • #435 — Refactors project-definition parsing/container APIs and call sites (ProjectDefinitionContainer); overlaps with collectDefinitionIssues and container-driven flows.
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 65.22% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Add global issues checkers that check across definition' accurately describes the main purpose of the PR, which is to introduce new built-in checkers (relation-type-mismatch and mutation-roles) that validate definitions at a global level.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kingston/eng-1052-add-global-issue-checkers-for-plugins

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kingston kingston merged commit 44d21ac into main Mar 10, 2026
11 checks passed
@kingston kingston deleted the kingston/eng-1052-add-global-issue-checkers-for-plugins branch March 10, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant