Skip to content

Commit 530ac36

Browse files
committed
fix: update dataSource handling in components and tests for consistency
1 parent bd43cac commit 530ac36

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

apps/console/src/App.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { RecordDetailView } from './components/RecordDetailView';
1717
import { DashboardView } from './components/DashboardView';
1818
import { PageView } from './components/PageView';
1919
import { ReportView } from './components/ReportView';
20-
import { MetadataToggle, MetadataPanel, useMetadataInspector } from './components/MetadataInspector';
2120
import { ExpressionProvider } from './context/ExpressionProvider';
2221

2322
/**
@@ -164,7 +163,7 @@ export function AppContent() {
164163
<Routes>
165164
<Route path="/" element={
166165
// Redirect to first route within the app
167-
<Navigate to={findFirstRoute(activeApp.navigation)} replace />
166+
<Navigate to={findFirstRoute(activeApp.navigation || [])} replace />
168167
} />
169168

170169
{/* List View */}
@@ -199,7 +198,7 @@ export function AppContent() {
199198
<ReportView dataSource={dataSource} />
200199
} />
201200
<Route path="page/:pageName" element={
202-
<PageView dataSource={dataSource} />
201+
<PageView />
203202
} />
204203
</Routes>
205204
</ErrorBoundary>

apps/console/src/__tests__/ObjectForm.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ describe('ObjectForm with MSW Integration', () => {
2525
await startMockServer();
2626

2727
// Initialize client - use localhost to match MSW handlers
28-
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' });
28+
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' } as any);
2929
await client.connect();
3030

31-
dataSource = new ObjectStackDataSource(client);
31+
dataSource = new ObjectStackDataSource(client as any);
3232

3333
// Get a valid contact ID for edit tests
3434
const driver = getDriver();

apps/console/src/__tests__/ObjectGrid.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ describe('ObjectGrid MSW Integration', () => {
1818

1919
beforeAll(async () => {
2020
await startMockServer();
21-
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' });
21+
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' } as any);
2222
await client.connect();
23-
dataSource = new ObjectStackDataSource(client);
23+
dataSource = new ObjectStackDataSource(client as any);
2424
});
2525

2626
afterAll(() => {

apps/console/src/__tests__/ObjectGridInteractions.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ describe('ObjectGrid Interactions', () => {
2828

2929
beforeAll(async () => {
3030
await startMockServer();
31-
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' });
31+
client = new ObjectStackClient({ baseUrl: 'http://localhost:3000' } as any);
3232
await client.connect();
33-
dataSource = new ObjectStackDataSource(client);
33+
dataSource = new ObjectStackDataSource(client as any);
3434
});
3535

3636
afterAll(() => {

apps/console/src/components/PageView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Empty, EmptyTitle, EmptyDescription } from '@object-ui/components';
99
import { MetadataToggle, MetadataPanel, useMetadataInspector } from './MetadataInspector';
1010
import appConfig from '../../objectstack.shared';
1111

12-
export function PageView({ dataSource }: { dataSource?: any }) {
12+
export function PageView() {
1313
const { pageName } = useParams<{ pageName: string }>();
1414
const [searchParams] = useSearchParams();
1515
const { showDebug, toggleDebug } = useMetadataInspector();
@@ -42,7 +42,7 @@ export function PageView({ dataSource }: { dataSource?: any }) {
4242
schema={{
4343
type: 'page',
4444
...page,
45-
context: { ...page.context, params }
45+
context: { ...(page as any).context, params }
4646
}}
4747
/>
4848
</div>

apps/console/src/components/ReportView.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const MOCK_FIELDS = [
1818
{ name: 'amount', label: 'Amount', type: 'currency' },
1919
];
2020

21-
export function ReportView({ dataSource }: { dataSource?: any }) {
21+
export function ReportView({ dataSource: _dataSource }: { dataSource?: any }) {
2222
const { reportName } = useParams<{ reportName: string }>();
2323
const { showDebug, toggleDebug } = useMetadataInspector();
2424
const [isEditing, setIsEditing] = useState(false);
@@ -99,7 +99,7 @@ export function ReportView({ dataSource }: { dataSource?: any }) {
9999
<div className="flex-1 overflow-hidden flex flex-row relative">
100100
<div className="flex-1 overflow-auto p-8 bg-muted/5">
101101
<div className="max-w-5xl mx-auto shadow-sm border rounded-xl bg-background overflow-hidden min-h-150">
102-
<ReportViewer schema={viewerSchema} dataSource={dataSource} />
102+
<ReportViewer schema={viewerSchema} />
103103
</div>
104104
</div>
105105

packages/data-objectstack/src/errors.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ describe('Error Helpers', () => {
270270

271271
expect(error).toBeInstanceOf(MetadataNotFoundError);
272272
expect(error.statusCode).toBe(404);
273-
expect((error as MetadataNotFoundError).details.objectName).toBe('users');
273+
expect((error as MetadataNotFoundError).details?.objectName).toBe('users');
274274
});
275275

276276
it('should create generic error for 404 without metadata context', () => {

packages/data-objectstack/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
599599
const cacheKey = `view:${objectName}:${viewId}`;
600600
return await this.metadataCache.get(cacheKey, async () => {
601601
// Try meta.getItem for view metadata
602-
const result: any = await this.client.meta.getItem(`${objectName}/views/${viewId}`);
602+
const result: any = await this.client.meta.getItem(objectName, `views/${viewId}`);
603603
if (result && result.item) return result.item;
604604
return result ?? null;
605605
});
@@ -624,7 +624,7 @@ export class ObjectStackAdapter<T = unknown> implements DataSource<T> {
624624
try {
625625
const cacheKey = `app:${appId}`;
626626
return await this.metadataCache.get(cacheKey, async () => {
627-
const result: any = await this.client.meta.getItem(`apps/${appId}`);
627+
const result: any = await this.client.meta.getItem('apps', appId);
628628
if (result && result.item) return result.item;
629629
return result ?? null;
630630
});

0 commit comments

Comments
 (0)