@@ -31,21 +31,21 @@ function simpleHash(str: string): string {
3131 * Service Configuration for Discovery
3232 * Maps service names to their routes and plugin providers
3333 */
34- const SERVICE_CONFIG : Record < string , { route : string ; plugin : string ; capability ?: string } > = {
34+ const SERVICE_CONFIG : Record < string , { route : string ; plugin : string } > = {
3535 auth : { route : '/api/v1/auth' , plugin : 'plugin-auth' } ,
36- automation : { route : '/api/v1/automation' , plugin : 'plugin-automation' , capability : 'workflow' } ,
36+ automation : { route : '/api/v1/automation' , plugin : 'plugin-automation' } ,
3737 cache : { route : '/api/v1/cache' , plugin : 'plugin-redis' } ,
3838 queue : { route : '/api/v1/queue' , plugin : 'plugin-bullmq' } ,
3939 job : { route : '/api/v1/jobs' , plugin : 'job-scheduler' } ,
4040 ui : { route : '/api/v1/ui' , plugin : 'ui-plugin' } ,
41- workflow : { route : '/api/v1/workflow' , plugin : 'plugin-workflow' , capability : 'workflow' } ,
42- realtime : { route : '/api/v1/realtime' , plugin : 'plugin-realtime' , capability : 'websockets' } ,
43- notification : { route : '/api/v1/notifications' , plugin : 'plugin-notifications' , capability : 'notifications' } ,
44- ai : { route : '/api/v1/ai' , plugin : 'plugin-ai' , capability : 'ai' } ,
45- i18n : { route : '/api/v1/i18n' , plugin : 'plugin-i18n' , capability : 'i18n' } ,
46- graphql : { route : '/graphql' , plugin : 'plugin-graphql' , capability : ' graphql' } ,
47- 'file-storage' : { route : '/api/v1/storage' , plugin : 'plugin-storage' , capability : 'files' } ,
48- search : { route : '/api/v1/search' , plugin : 'plugin-search' , capability : 'search' } ,
41+ workflow : { route : '/api/v1/workflow' , plugin : 'plugin-workflow' } ,
42+ realtime : { route : '/api/v1/realtime' , plugin : 'plugin-realtime' } ,
43+ notification : { route : '/api/v1/notifications' , plugin : 'plugin-notifications' } ,
44+ ai : { route : '/api/v1/ai' , plugin : 'plugin-ai' } ,
45+ i18n : { route : '/api/v1/i18n' , plugin : 'plugin-i18n' } ,
46+ graphql : { route : '/graphql' , plugin : 'plugin-graphql' } , // GraphQL uses / graphql by convention (not versioned REST)
47+ 'file-storage' : { route : '/api/v1/storage' , plugin : 'plugin-storage' } ,
48+ search : { route : '/api/v1/search' , plugin : 'plugin-search' } ,
4949} ;
5050
5151export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
@@ -64,9 +64,9 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
6464 // Build dynamic service info with proper typing
6565 const services : Record < string , ServiceInfo > = {
6666 // --- Kernel-provided (objectql is an example kernel implementation) ---
67- metadata : { enabled : true , status : 'degraded' as const , route : '/api/meta' , provider : 'objectql' , message : 'In-memory registry only; DB persistence not yet implemented' } ,
68- data : { enabled : true , status : 'available' as const , route : '/api/data' , provider : 'objectql' } ,
69- analytics : { enabled : true , status : 'available' as const , route : '/api/analytics' , provider : 'objectql' } ,
67+ metadata : { enabled : true , status : 'degraded' as const , route : '/api/v1/ meta' , provider : 'objectql' , message : 'In-memory registry only; DB persistence not yet implemented' } ,
68+ data : { enabled : true , status : 'available' as const , route : '/api/v1/ data' , provider : 'objectql' } ,
69+ analytics : { enabled : true , status : 'available' as const , route : '/api/v1/ analytics' , provider : 'objectql' } ,
7070 } ;
7171
7272 // Check which services are actually registered
@@ -89,22 +89,8 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
8989 }
9090 }
9191
92- // Build capabilities based on available services
93- const capabilities = {
94- graphql : registeredServices . has ( 'graphql' ) ,
95- search : registeredServices . has ( 'search' ) ,
96- websockets : registeredServices . has ( 'realtime' ) ,
97- files : registeredServices . has ( 'file-storage' ) ,
98- analytics : true , // Always available via objectql
99- ai : registeredServices . has ( 'ai' ) ,
100- workflow : registeredServices . has ( 'workflow' ) || registeredServices . has ( 'automation' ) ,
101- notifications : registeredServices . has ( 'notification' ) ,
102- i18n : registeredServices . has ( 'i18n' ) ,
103- } ;
104-
105- // Build endpoints (only include available services)
106- // Map service names to ApiRoutes keys
107- const serviceToEndpointKey : Record < string , keyof ApiRoutes > = {
92+ // Build routes from services — a flat convenience map for client routing
93+ const serviceToRouteKey : Record < string , keyof ApiRoutes > = {
10894 auth : 'auth' ,
10995 automation : 'automation' ,
11096 ui : 'ui' ,
@@ -117,31 +103,30 @@ export class ObjectStackProtocolImplementation implements ObjectStackProtocol {
117103 'file-storage' : 'storage' ,
118104 } ;
119105
120- const optionalEndpoints : Partial < ApiRoutes > = {
121- analytics : '/api/analytics' ,
106+ const optionalRoutes : Partial < ApiRoutes > = {
107+ analytics : '/api/v1/ analytics' ,
122108 } ;
123109
124110 // Add routes for available plugin services
125111 for ( const [ serviceName , config ] of Object . entries ( SERVICE_CONFIG ) ) {
126112 if ( registeredServices . has ( serviceName ) ) {
127- const endpointKey = serviceToEndpointKey [ serviceName ] ;
128- if ( endpointKey ) {
129- optionalEndpoints [ endpointKey ] = config . route ;
113+ const routeKey = serviceToRouteKey [ serviceName ] ;
114+ if ( routeKey ) {
115+ optionalRoutes [ routeKey ] = config . route ;
130116 }
131117 }
132118 }
133119
134- const endpoints : ApiRoutes = {
135- data : '/api/data' ,
136- metadata : '/api/meta' ,
137- ...optionalEndpoints ,
120+ const routes : ApiRoutes = {
121+ data : '/api/v1/ data' ,
122+ metadata : '/api/v1/ meta' ,
123+ ...optionalRoutes ,
138124 } ;
139125
140126 return {
141127 version : '1.0' ,
142128 apiName : 'ObjectStack API' ,
143- capabilities,
144- endpoints,
129+ routes,
145130 services,
146131 } ;
147132 }
0 commit comments