refactor: move getUserAccess method from ChaiBaseAction to CheckUserAccessAction#792
refactor: move getUserAccess method from ChaiBaseAction to CheckUserAccessAction#792
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ❌ Deployment failed View logs |
sdk-nextjs | e4c27e1 | Mar 04 2026, 05:50 PM |
There was a problem hiding this comment.
Pull request overview
This PR refactors access checking by moving the getUserAccess DB lookup out of ChaiBaseAction and into CheckUserAccessAction, and updates ChaiBaseAction.verifyAccess() to delegate authorization checks through the action registry.
Changes:
- Added
getUserAccess()implementation toCheckUserAccessAction(DB query + error handling). - Removed
getUserAccess()fromChaiBaseActionand rewiredverifyAccess()to callCHECK_USER_ACCESSviagetChaiAction. - Updated imports accordingly (DB/drizzle imports moved off of
base-action.ts).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/actions/builder/check-user-access.ts | Introduces getUserAccess() and makes execute() rely on it to validate app/user access. |
| src/actions/builder/base-action.ts | Removes inline DB access check and delegates authorization to the registry action CHECK_USER_ACCESS. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import { ActionError } from "./action-error"; | ||
| import { getChaiAction } from "./actions-registery"; | ||
| import { ChaiAction, ChaiActionContext } from "./chai-action-interface"; |
There was a problem hiding this comment.
verifyAccess() now depends on getChaiAction from actions-registery, which imports (and instantiates) actions that themselves extend ChaiBaseAction. This creates a circular module dependency (base-action -> actions-registery -> check-user-access -> base-action) that can break ESM module initialization (e.g., ChaiBaseAction being undefined when CheckUserAccessAction is evaluated). To avoid this, keep verifyAccess self-contained (DB check here) or invert the dependency (e.g., inject an access-check function/instance from the caller/handler rather than importing the registry in the base class).
There was a problem hiding this comment.
@copilot open a new pull request to apply changes based on this feedback
Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
Co-authored-by: surajair <9153560+surajair@users.noreply.github.com>
Fix circular ESM dependency in base-action while restoring CHECK_USER_ACCESS extensibility
No description provided.