@@ -27,12 +27,13 @@ export async function startMockServer() {
2727 driver = new InMemoryDriver ( ) ;
2828
2929 // Create kernel
30- kernel = new ObjectKernel ( ) ;
30+ kernel = new ObjectKernel ( {
31+ skipSystemValidation : true
32+ } ) ;
3133
32- kernel
33- . use ( new ObjectQLPlugin ( ) )
34- . use ( new DriverPlugin ( driver , 'memory' ) )
35- . use ( new AppPlugin ( appConfig ) ) ;
34+ await kernel . use ( new ObjectQLPlugin ( ) ) ;
35+ await kernel . use ( new DriverPlugin ( driver , 'memory' ) ) ;
36+ await kernel . use ( new AppPlugin ( appConfig ) ) ;
3637
3738 // Bootstrap kernel WITHOUT MSW plugin (we'll handle MSW separately for tests)
3839 await kernel . bootstrap ( ) ;
@@ -51,9 +52,10 @@ export async function startMockServer() {
5152 }
5253 }
5354
54- // Create MSW handlers manually
55- const baseUrl = 'http://localhost:3000/api/v1' ;
56- const handlers = createHandlers ( baseUrl , kernel , driver ! ) ;
55+ // Create MSW handlers manually for both paths to ensure compatibility with client defaults
56+ const v1Handlers = createHandlers ( 'http://localhost:3000/api/v1' , kernel , driver ! ) ;
57+ const legacyHandlers = createHandlers ( 'http://localhost:3000/api' , kernel , driver ! ) ;
58+ const handlers = [ ...v1Handlers , ...legacyHandlers ] ;
5759
5860 // Setup MSW server for Node.js environment
5961 server = setupServer ( ...handlers ) ;
@@ -179,14 +181,17 @@ function createHandlers(baseUrl: string, kernel: ObjectKernel, driver: InMemoryD
179181 http . get ( `${ baseUrl } /data/:objectName/:id` , async ( { params } ) => {
180182 try {
181183 console . log ( 'MSW: getData' , params . objectName , params . id ) ;
182- // Use driver directly
183- // Try simple find first
184- const records = await driver . find ( params . objectName as string , {
185- object : params . objectName as string ,
186- where : [ [ '_id' , '=' , params . id ] ]
184+
185+ // Fetch ALL records for the object to ensure we find it regardless of driver query syntax quirks
186+ const allRecords = await driver . find ( params . objectName as string , {
187+ object : params . objectName as string
187188 } ) ;
188- // Manual filter to ensure we get the correct record if driver ignores filters
189- const record = records ? records . find ( ( r : any ) => r . id === params . id || r . _id === params . id ) : null ;
189+
190+ // Manual filter
191+ const record = allRecords ? allRecords . find ( ( r : any ) =>
192+ String ( r . id ) === String ( params . id ) ||
193+ String ( r . _id ) === String ( params . id )
194+ ) : null ;
190195
191196 console . log ( 'MSW: getData result' , JSON . stringify ( record ) ) ;
192197 return HttpResponse . json ( record , { status : record ? 200 : 404 } ) ;
0 commit comments