Uh oh!
There was an error while loading. Please reload this page.
Fix TypeScript compilation errors in adapters - add AuthService type parameter - #592
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Pull request overview
This PR fixes TypeScript compilation issues in the Hono, Next.js, and NestJS adapters by adding a local AuthService interface and using it as the type parameter to kernel.getService<AuthService>('auth'), enabling type-safe access to handleRequest().
Changes:
- Added an
AuthServiceinterface (per adapter) defininghandleRequest(request: Request): Promise<Response>. - Updated auth service lookups to
getService<AuthService>('auth')in all three adapters.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/adapters/nextjs/src/index.ts | Adds local AuthService type and uses typed getService<AuthService>('auth') for auth handling. |
| packages/adapters/nestjs/src/index.ts | Adds local AuthService type and uses typed getService<AuthService>('auth') in the controller auth route. |
| packages/adapters/hono/src/index.ts | Adds local AuthService type and uses typed getService<AuthService>('auth') in the auth route. |
| // Try AuthPlugin service first (preferred path) | ||
| const authService = typeof options.kernel.getService === 'function' | ||
| ? options.kernel.getService('auth') | ||
| ? options.kernel.getService<AuthService>('auth') | ||
| : null; |
There was a problem hiding this comment.
ObjectKernel.getService() throws when a service is missing (it does not return null/undefined). As written, calling getService<AuthService>('auth') will throw when the auth plugin/service isn’t registered, and the code will jump to the outer catch and return a 500, never reaching the legacy dispatcher fallback. Consider wrapping the getService call in a try/catch that treats the specific "service not found" error as a null authService so the fallback path can run.
| const kernel = this.service.getKernel(); | ||
| const authService = typeof kernel.getService === 'function' | ||
| ? kernel.getService('auth') | ||
| ? kernel.getService<AuthService>('auth') | ||
| : null; |
There was a problem hiding this comment.
ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the handler will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService lookup in a try/catch and treat the "service not found" case as null so the fallback can execute.
| // Try AuthPlugin service first (preferred path) | ||
| const authService = typeof options.kernel.getService === 'function' | ||
| ? options.kernel.getService('auth') | ||
| ? options.kernel.getService<AuthService>('auth') | ||
| : null; | ||
There was a problem hiding this comment.
ObjectKernel.getService() throws when a service is missing. If the auth plugin/service isn’t registered, getService<AuthService>('auth') will throw and the route will return a 500 from the catch block, never reaching the legacy dispatcher.handleAuth(...) fallback. Wrap the getService call in a try/catch and treat the "service not found" case as null so fallback behavior works.
…e name (objectstack-ai#5510) (objectstack-ai#5531) `naming/namespace-prefix` deduplicated every `PREFIXED_TYPES` entry on `items[i].name` alone. For actions that is not the key they occupy: the engine registers under `objectName:name` (`ObjectQLPlugin.actionObjectKey`, falling back to the canonical object-less key `global`, objectstack-ai#3913), so one package declaring one `log_call` per object holds one distinct key per object and nothing shadows anything. The bare-name dedup flagged that shape as an intra-package duplicate, with noise growing linearly in the object count — 12 fixed warnings per `objectstack lint` run on HotCRM (5 objects x 3 activity actions) — and its "rename one" prescription would have broken the shared i18n keys the objectstack-ai#592 shape depends on. Actions now dedup on `objectName:name`; the other six types keep bare-name dedup and their message text byte-for-byte. Only `objectName` is read: `ActionSchema` rejects `object`/`entity` outright with a rename prescription, so a `??` chain here would only fossilize a spelling the contract already refuses (Prime Directive objectstack-ai#12). Genuine shadowing still warns — same `objectName`, two object-less actions, and an action on an object literally named `global` meeting an object-less one (which is why the fallback is the real `global` literal rather than an inert sentinel). The action remedy now offers separating by `objectName` before renaming. Claude-Session: https://claude.ai/code/session_016FNvXhtSdnEGEfLEsMmvxh Co-authored-by: Claude <noreply@anthropic.com>
TypeScript compilation failed in Hono, Next.js, and NestJS adapters because
kernel.getService('auth')returned{}without a type parameter, preventing access tohandleRequest().Changes
AuthServiceinterface defininghandleRequest(request: Request): Promise<Response>getService()calls to use type parameter:getService<AuthService>('auth')Example
Note
The
AuthServiceinterface is currently duplicated across the three adapters. Consider extracting to a shared types package in a follow-up.Original prompt
Created from VS Code.
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.