Repository navigation
feat: adapt better-auth adapter and objects for sys_ prefix naming convention - #745
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…nvention - Add AUTH_MODEL_TO_PROTOCOL mapping and resolveProtocolName() in objectql-adapter.ts - Update all auth object definitions to use sys_ prefixed names (sys_user, sys_session, sys_account, sys_verification) - Add comprehensive adapter mapping tests (11 tests) Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…x adaptation - Update plugin-auth README.md with sys_ prefixed object names and adapter mapping docs - Update authentication.mdx guide with protocol name mapping explanation - Update ROADMAP.md migration notes for better-auth adapter Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adapts the @objectstack/plugin-auth to align with the new sys_ prefix naming convention for system kernel objects (issue #738). The change bridges the gap between better-auth's hardcoded model names (user, session, account, verification) and ObjectStack's protocol-layer naming convention that requires sys_ prefixes for system objects.
Changes:
- Introduced
AUTH_MODEL_TO_PROTOCOLmapping andresolveProtocolName()function to translate better-auth model names to protocol names - Updated all four auth object definitions to use
sys_prefixed names - Added comprehensive test coverage for the mapping layer and adapter operations
- Updated documentation (README, authentication.mdx, ROADMAP) to explain the adapter mapping pattern
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/plugins/plugin-auth/src/objects/auth-user.object.ts | Updated object name from user to sys_user |
| packages/plugins/plugin-auth/src/objects/auth-session.object.ts | Updated object name from session to sys_session |
| packages/plugins/plugin-auth/src/objects/auth-account.object.ts | Updated object name from account to sys_account |
| packages/plugins/plugin-auth/src/objects/auth-verification.object.ts | Updated object name from verification to sys_verification |
| packages/plugins/plugin-auth/src/objectql-adapter.ts | Added AUTH_MODEL_TO_PROTOCOL mapping and resolveProtocolName() function; updated all 8 adapter operations to use the mapping |
| packages/plugins/plugin-auth/src/objectql-adapter.test.ts | Added 11 new tests covering mapping constants, resolver fallback, and adapter operations |
| packages/plugins/plugin-auth/README.md | Updated documentation to explain the model-to-protocol name mapping pattern |
| content/docs/guides/authentication.mdx | Updated guide with sys_ prefix convention and upgrade notes |
| ROADMAP.md | Added migration note about AUTH_MODEL_TO_PROTOCOL mapping requirement |
| it('should pass through unknown model names unchanged', async () => { | ||
| const adapter = createObjectQLAdapter(mockEngine); | ||
| await adapter.create({ model: 'organization', data: { name: 'Acme' } }); | ||
| expect(mockEngine.insert).toHaveBeenCalledWith('organization', { name: 'Acme' }); | ||
| }); |
There was a problem hiding this comment.
The test suite is missing coverage for updateMany and deleteMany adapter operations. While the implementation correctly uses resolveProtocolName() in both operations (lines 148 and 185 of objectql-adapter.ts), there are no tests to verify that these operations properly map model names to protocol names. Consider adding test cases similar to the existing ones for these two operations to ensure complete adapter coverage.
better-auth hardcodes model names (
user,session,account,verification) but the protocol layer now requiressys_prefixed names. The adapter layer couldn't resolve the correct object definitions, breaking auth flows.Adapter mapping (
objectql-adapter.ts)AUTH_MODEL_TO_PROTOCOLmapping andresolveProtocolName()to translate better-auth model names → protocol namesresolveProtocolName(model)instead of passing raw model namesObject definitions
auth-user.object.ts→name: 'sys_user'auth-session.object.ts→name: 'sys_session'auth-account.object.ts→name: 'sys_account'auth-verification.object.ts→name: 'sys_verification'Tests
resolveProtocolNamefallback, and all adapter operations confirmingsys_names reachIDataEngineDocumentation
README.md,authentication.mdx, andROADMAP.mdmigration notesOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.