Skip to content

Commit b9e8c25

Browse files
refactor: address code review feedback for client route type safety
- Replace 'type in routes' guard with direct property access + truthiness check - Remove unnecessary 'as string' type assertion - Add comments clarifying discovered vs client-specific route handling Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/283e383b-284b-40fe-af98-c11f61a4c8a8 Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
1 parent f08ffc3 commit b9e8c25

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/client/src/index.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,13 +1686,15 @@ export class ObjectStackClient {
16861686
* ObjectStack uses standard conventions: /api/v1/data, /api/v1/meta, /api/v1/ui
16871687
*/
16881688
private getRoute(type: ApiRouteType): string {
1689-
// 1. Use discovered routes if available
1689+
// 1. Use discovered routes if available (only for ApiRoutes keys, not client-specific keys)
16901690
const routes = this.discoveryInfo?.routes;
1691-
if (routes && type in routes) {
1692-
return routes[type as keyof ApiRoutes] as string;
1691+
if (routes) {
1692+
const key = type as keyof ApiRoutes;
1693+
const discovered = routes[key];
1694+
if (discovered) return discovered;
16931695
}
16941696

1695-
// 2. Fallback to conventions
1697+
// 2. Fallback to conventions (covers all ApiRoutes keys + client-specific virtual routes)
16961698
const routeMap: Record<ApiRouteType, string> = {
16971699
data: '/api/v1/data',
16981700
metadata: '/api/v1/meta',

0 commit comments

Comments
 (0)