|
3 | 3 | import { Plugin, PluginContext, IHttpServer } from '@objectstack/core'; |
4 | 4 | import { AuthConfig } from '@objectstack/spec/system'; |
5 | 5 | import { AuthManager } from './auth-manager.js'; |
| 6 | +import { |
| 7 | + SysUser, SysSession, SysAccount, SysVerification, |
| 8 | + SysOrganization, SysMember, SysInvitation, |
| 9 | + SysTeam, SysTeamMember, |
| 10 | + SysApiKey, SysTwoFactor, |
| 11 | +} from './objects/index.js'; |
6 | 12 |
|
7 | 13 | /** |
8 | 14 | * Auth Plugin Options |
@@ -43,6 +49,7 @@ export interface AuthPluginOptions extends Partial<AuthConfig> { |
43 | 49 | * |
44 | 50 | * This plugin registers: |
45 | 51 | * - `auth` service (auth manager instance) — always |
| 52 | + * - `app.com.objectstack.system` service (system object definitions) — always |
46 | 53 | * - HTTP routes for authentication endpoints — only when HTTP server is available |
47 | 54 | * |
48 | 55 | * Integrates with better-auth library to provide comprehensive |
@@ -88,7 +95,23 @@ export class AuthPlugin implements Plugin { |
88 | 95 |
|
89 | 96 | // Register auth service |
90 | 97 | ctx.registerService('auth', this.authManager); |
91 | | - |
| 98 | + |
| 99 | + // Register system objects as an app service so ObjectQLPlugin |
| 100 | + // auto-discovers them via the `app.*` convention. |
| 101 | + ctx.registerService('app.com.objectstack.system', { |
| 102 | + id: 'com.objectstack.system', |
| 103 | + name: 'System', |
| 104 | + version: '1.0.0', |
| 105 | + type: 'plugin', |
| 106 | + namespace: 'sys', |
| 107 | + objects: [ |
| 108 | + SysUser, SysSession, SysAccount, SysVerification, |
| 109 | + SysOrganization, SysMember, SysInvitation, |
| 110 | + SysTeam, SysTeamMember, |
| 111 | + SysApiKey, SysTwoFactor, |
| 112 | + ], |
| 113 | + }); |
| 114 | + |
92 | 115 | ctx.logger.info('Auth Plugin initialized successfully'); |
93 | 116 | } |
94 | 117 |
|
|
0 commit comments