Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .storybook/msw-browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export async function startMockServer() {
}),

// Metadata endpoints
http.get('/api/v1/metadata/object/:objectName', async ({ params }) => {
http.get('/api/v1/meta/object/:objectName', async ({ params }) => {
console.log('[MSW] Get Meta:', params.objectName);
try {
const response = await protocol.getMetaItem({
Expand Down
18 changes: 18 additions & 0 deletions apps/console/src/mocks/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,24 @@ function createHandlers(baseUrl: string, kernel: ObjectKernel, driver: InMemoryD
}
}),

http.get(`${baseUrl}/meta/object/:objectName`, async ({ params }) => {
console.log('MSW: getting meta item for /meta/object', params.objectName);
try {
const response = await protocol.getMetaItem({
type: 'object',
name: params.objectName as string
});

// Unwrap item if present
const payload = (response && response.item) ? response.item : response;

return HttpResponse.json(payload || { error: 'Not found' }, { status: payload ? 200 : 404 });
} catch (e) {
Comment on lines +123 to +135

Copilot AI Feb 2, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new handler for ${baseUrl}/meta/object/:objectName duplicates almost the same logic as the existing ${baseUrl}/metadata/object/:objectName handler below (logging, getMetaItem call, payload unwrapping, and error handling). To reduce maintenance overhead and risk of future drift between these endpoints, consider extracting a shared helper (e.g., a function that takes the path or a common handler factory) and reuse it for both routes.

Copilot uses AI. Check for mistakes.
console.error('MSW: error getting meta item', e);
return HttpResponse.json({ error: String(e) }, { status: 500 });
}
}),

http.get(`${baseUrl}/metadata/object/:objectName`, async ({ params }) => {
console.log('MSW: getting meta item for', params.objectName);
try {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-calendar/src/ObjectCalendar.msw.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const handlers = [
}),

// Metadata Query
http.get(`${BASE_URL}/api/v1/metadata/object/events`, () => {
http.get(`${BASE_URL}/api/v1/meta/object/events`, () => {
return HttpResponse.json({ fields: {} });
})
];
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-form/src/ObjectForm.msw.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const handlers = [
return HttpResponse.json({ status: 'ok', version: '1.0.0' });
}),

// Mock Schema Fetch: GET /api/v1/metadata/object/:name
http.get(`${BASE_URL}/api/v1/metadata/object/:name`, ({ params }) => {
// Mock Schema Fetch: GET /api/v1/meta/object/:name
http.get(`${BASE_URL}/api/v1/meta/object/:name`, ({ params }) => {
const { name } = params;
if (name === 'contact') {
return HttpResponse.json(mockSchema);
Expand Down
4 changes: 2 additions & 2 deletions packages/plugin-grid/src/ObjectGrid.msw.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ const handlers = [
return HttpResponse.json({ status: 'ok', version: '1.0.0' });
}),

// Schema: /api/v1/metadata/object/:name
http.get(`${BASE_URL}/api/v1/metadata/object/contact`, () => {
// Schema: /api/v1/meta/object/:name
http.get(`${BASE_URL}/api/v1/meta/object/contact`, () => {
return HttpResponse.json(mockSchema);
}),

Expand Down
Loading