Skip to content

Commit d770dca

Browse files
Copilothotlong
andcommitted
Fix TypeScript type errors in objectql (endpoints type, listObjects)
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 2e5c106 commit d770dca

2 files changed

Lines changed: 28 additions & 8 deletions

File tree

packages/objectql/src/plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export class ObjectQLPlugin implements Plugin {
115115

116116
ctx.logger.info('ObjectQL engine started', {
117117
driversRegistered: this.ql?.['drivers']?.size || 0,
118-
objectsRegistered: this.ql?.registry?.listObjects?.()?.length || 0
118+
objectsRegistered: this.ql?.registry?.getAllObjects?.()?.length || 0
119119
});
120120
}
121121

packages/objectql/src/protocol.ts

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type {
88
UpdateManyDataRequest,
99
DeleteManyDataRequest
1010
} from '@objectstack/spec/api';
11-
import type { MetadataCacheRequest, MetadataCacheResponse, ServiceInfo } from '@objectstack/spec/api';
11+
import type { MetadataCacheRequest, MetadataCacheResponse, ServiceInfo, ApiRoutes } from '@objectstack/spec/api';
1212

1313
// We import SchemaRegistry directly since this class lives in the same package
1414
import { SchemaRegistry } from './registry.js';
@@ -103,21 +103,41 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
103103
};
104104

105105
// Build endpoints (only include available services)
106-
const endpoints: Record<string, string> = {
107-
data: '/api/data',
108-
metadata: '/api/meta',
106+
// Map service names to ApiRoutes keys
107+
const serviceToEndpointKey: Record<string, keyof ApiRoutes> = {
108+
auth: 'auth',
109+
automation: 'automation',
110+
ui: 'ui',
111+
workflow: 'workflow',
112+
realtime: 'realtime',
113+
notification: 'notifications',
114+
ai: 'ai',
115+
i18n: 'i18n',
116+
graphql: 'graphql',
117+
'file-storage': 'storage',
118+
search: 'analytics',
119+
};
120+
121+
const optionalEndpoints: Partial<ApiRoutes> = {
109122
analytics: '/api/analytics',
110123
};
111124

112125
// Add routes for available plugin services
113126
for (const [serviceName, config] of Object.entries(SERVICE_CONFIG)) {
114127
if (registeredServices.has(serviceName)) {
115-
// Map service name to endpoint key (some services use different names)
116-
const endpointKey = serviceName === 'file-storage' ? 'storage' : serviceName;
117-
endpoints[endpointKey] = config.route;
128+
const endpointKey = serviceToEndpointKey[serviceName];
129+
if (endpointKey) {
130+
optionalEndpoints[endpointKey] = config.route;
131+
}
118132
}
119133
}
120134

135+
const endpoints: ApiRoutes = {
136+
data: '/api/data',
137+
metadata: '/api/meta',
138+
...optionalEndpoints,
139+
};
140+
121141
return {
122142
version: '1.0',
123143
apiName: 'ObjectStack API',

0 commit comments

Comments
 (0)