Skip to content

Commit 1506349

Browse files
committed
fix: enhance schema handling in TaskForm and improve data format handling in TaskList
chore: add logging for config loading and manifest checks in browser mock server
1 parent 04236f6 commit 1506349

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

examples/app-react-crud/src/components/TaskForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function TaskForm({ client, editingTask, onSuccess, onCancel }: TaskFormP
3131

3232
// In Protocol v1 (protocol.ts), getMetaItem returns { type: 'object', name: 'todo_task', item: { ...fields... } }
3333
// So we need res.item (the schema definition) or res (if it's direct)
34-
const schemaDef = res.item || res;
34+
const schemaDef = res.data || res.item || res;
3535

3636
setSchema(schemaDef);
3737
} catch (err) {

examples/app-react-crud/src/components/TaskList.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ export function TaskList({ client, onEdit, refreshTrigger }: TaskListProps) {
3636
sort: ['priority', '-created_at']
3737
});
3838

39-
// Handle { value: [] } (PaginatedResult) and [] (Raw) formats
40-
const rawValues = Array.isArray(result) ? result : (result.value || []);
39+
// Handle { value: [] } (PaginatedResult), { data: [] } (Standard Envelope) and [] (Raw) formats
40+
// The ObjectStack Client returns the raw JSON body, so we need to handle the envelope
41+
const rawValues = Array.isArray(result) ? result : (result.value || (result as any).data || []);
4142
const fetchedTasks = [...rawValues] as Task[];
4243

4344
// Client-side sort fallback (since InMemoryDriver has limited sort support)

examples/app-react-crud/src/mocks/browser.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export async function startMockServer() {
2121

2222
// Handle CommonJS/ESM interop for config loading
2323
const appConfig = (todoConfig as any).default || todoConfig;
24+
console.log('[MSW] Loaded Config:', appConfig);
2425

2526
const driver = new InMemoryDriver();
2627

@@ -90,6 +91,7 @@ export async function startMockServer() {
9091
}
9192

9293
// HttpDispatcher expects { data, count } for query/list
94+
console.log(`[BrokerShim] find/query(${params.object}) -> count: ${all.length}`, all);
9395
return { data: all, count: all.length };
9496
}
9597
}
@@ -136,8 +138,10 @@ export async function startMockServer() {
136138

137139
// Initialize default data from manifest if available
138140
const manifest = appConfig.manifest;
141+
console.log('[MSW] Checking manifest for data...', manifest);
142+
139143
if (manifest && Array.isArray(manifest.data)) {
140-
console.log('[MSW] Loading initial data...');
144+
console.log(`[MSW] Found ${manifest.data.length} datasets.`);
141145
for (const dataset of manifest.data) {
142146
if (dataset.object && Array.isArray(dataset.records)) {
143147
for (const record of dataset.records) {

0 commit comments

Comments
 (0)