Skip to content

Commit 59c83ca

Browse files
committed
fix: update @objectstack/client dependency to version 0.6.1 and adjust fetch wrapper for improved request debugging
1 parent f4087d6 commit 59c83ca

5 files changed

Lines changed: 29 additions & 9 deletions

File tree

examples/crm-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@object-ui/react": "workspace:*",
2222
"@object-ui/types": "workspace:*",
2323
"@object-ui/example-crm": "workspace:*",
24-
"@objectstack/client": "^0.4.1",
24+
"@objectstack/client": "^0.6.1",
2525
"@objectstack/core": "^0.6.1",
2626
"@objectstack/runtime": "^0.6.1",
2727
"clsx": "^2.1.1",

examples/crm-app/src/client.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
import { ObjectStackClient } from '@objectstack/client';
22
import { ObjectStackAdapter } from '@object-ui/data-objectstack';
33

4-
// Use empty string to use current origin.
5-
// Matches MSW baseUrl: ''
6-
const BASE_URL = '/api/v1';
4+
// Wrapper to debug requests
5+
const fetchWrapper = async (input: RequestInfo | URL, init?: RequestInit) => {
6+
const url = input.toString();
7+
// Ignore vite hot reload or node module requests
8+
if (url.includes('/api/')) {
9+
console.log('[DEBUG-FETCH]', url);
10+
}
11+
return globalThis.fetch(input, init);
12+
};
13+
14+
// Use empty string to auto-detect or match MSW if it handles root
15+
const BASE_URL = '';
716

817
export const client = new ObjectStackClient({
918
baseUrl: BASE_URL,
10-
fetch: globalThis.fetch.bind(globalThis)
19+
fetch: fetchWrapper
1120
});
1221

1322
export const dataSource = new ObjectStackAdapter({
1423
baseUrl: BASE_URL,
1524
token: 'mock-token',
16-
fetch: globalThis.fetch.bind(globalThis)
25+
fetch: fetchWrapper
1726
});
1827

1928
export const initClient = async () => {

examples/crm-app/src/mocks/browser.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ export async function startMockServer() {
1313
console.log('[MSW] Starting ObjectStack Runtime (Browser Mode)...');
1414
console.log('[MSW] Loaded Config:', crmConfig ? 'Found' : 'Missing', crmConfig?.apps?.length);
1515

16+
if (crmConfig && crmConfig.objects) {
17+
console.log('[MSW] Objects in Config:', crmConfig.objects.map(o => o.name));
18+
} else {
19+
console.error('[MSW] No objects found in config!');
20+
}
21+
1622
const driver = new InMemoryDriver();
1723
kernel = new ObjectKernel();
1824

@@ -29,9 +35,13 @@ export async function startMockServer() {
2935

3036
kernel.use(new MSWPlugin({
3137
enableBrowser: true,
32-
baseUrl: '/api/v1', // Use root to match client
38+
baseUrl: '/api/v1',
3339
logRequests: true,
3440
customHandlers: [
41+
// Explicitly handle all metadata requests to prevent pass-through
42+
http.get('/api/v1/metadata/*', async () => {
43+
return HttpResponse.json({});
44+
}),
3545
http.get('/api/bootstrap', async () => {
3646
const contacts = await driver.find('contact', { object: 'contact' });
3747
const stats = { revenue: 125000, leads: 45, deals: 12 };

examples/crm-app/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export default defineConfig(({ mode }) => ({
2222
'@object-ui/plugin-form': path.resolve(__dirname, '../../packages/plugin-form/src'),
2323
'@object-ui/plugin-grid': path.resolve(__dirname, '../../packages/plugin-grid/src'),
2424
'@object-ui/data-objectstack': path.resolve(__dirname, '../../packages/data-objectstack/src'),
25+
'@object-ui/example-crm': path.resolve(__dirname, '../../examples/crm/src'),
2526
},
2627
},
2728
test: {

pnpm-lock.yaml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)