Skip to content

Commit 6ad0234

Browse files
committed
Refactor app configuration to consolidate CRM and Todo settings, and introduce a new config structure for improved maintainability
1 parent 55f0ff6 commit 6ad0234

File tree

4 files changed

+132
-26
lines changed

4 files changed

+132
-26
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { defineConfig } from './src/config';
2+
import crmConfig from '@object-ui/example-crm/objectstack.config';
3+
import todoConfig from '@object-ui/example-todo/objectstack.config';
4+
5+
export default defineConfig({
6+
// ============================================================================
7+
// Project Metadata
8+
// ============================================================================
9+
10+
name: '@object-ui/example-msw-object-form',
11+
version: '0.1.0',
12+
description: 'ObjectUI Example: MSW Object Form (Wrapper)',
13+
14+
// ============================================================================
15+
// Build Settings
16+
// ============================================================================
17+
18+
build: {
19+
outDir: './dist',
20+
sourcemap: true,
21+
minify: true,
22+
target: 'node18',
23+
},
24+
25+
// ============================================================================
26+
// Database Configuration
27+
// ============================================================================
28+
29+
datasources: {
30+
default: {
31+
driver: 'memory', // Use memory driver for browser example
32+
},
33+
},
34+
35+
// ============================================================================
36+
// Plugin Configuration
37+
// ============================================================================
38+
39+
plugins: [
40+
'@objectstack/plugin-msw' // In core config
41+
],
42+
43+
// ============================================================================
44+
// Merged Stack Configuration (CRM + Todo)
45+
// ============================================================================
46+
objects: [
47+
...(crmConfig.objects || []),
48+
...(todoConfig.objects || [])
49+
],
50+
apps: [
51+
...(crmConfig.apps || []),
52+
...(todoConfig.apps || [])
53+
],
54+
manifest: {
55+
data: [
56+
...(crmConfig.manifest?.data || []),
57+
...(todoConfig.manifest?.data || [])
58+
]
59+
},
60+
61+
// ============================================================================
62+
// Development Server
63+
// ============================================================================
64+
65+
dev: {
66+
port: 3000,
67+
host: '0.0.0.0',
68+
watch: true,
69+
hotReload: true,
70+
},
71+
72+
// ============================================================================
73+
// Deployment
74+
// ============================================================================
75+
76+
deploy: {
77+
target: 'static', // This is a static SPA
78+
region: 'us-east-1',
79+
},
80+
});

examples/msw-object-form/src/App.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,24 @@ import { ObjectGrid } from '@object-ui/plugin-grid';
66
import { ObjectForm } from '@object-ui/plugin-form';
77
import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, Button } from '@object-ui/components';
88
import { ObjectStackDataSource } from './dataSource';
9-
import { LayoutDashboard, Users, Plus, Database } from 'lucide-react';
9+
import { LayoutDashboard, Users, Plus, Database, Settings } from 'lucide-react';
1010

11-
import crmConfig from '@object-ui/example-crm/objectstack.config';
12-
import todoConfig from '@object-ui/example-todo/objectstack.config';
11+
import appConfig from '../objectstack.config';
1312

1413
const APPS: any = {
15-
crm: { ...crmConfig, name: 'crm', label: 'CRM App' },
16-
todo: { ...todoConfig, name: 'todo', label: 'Todo App' }
14+
// Filter objects based on source config (heuristic: contacts->crm, todo->todo)
15+
crm: {
16+
...appConfig,
17+
name: 'crm',
18+
label: 'CRM App',
19+
objects: appConfig.objects?.filter((o: any) => ['account', 'contact', 'opportunity'].includes(o.name)) || []
20+
},
21+
todo: {
22+
...appConfig,
23+
name: 'todo',
24+
label: 'Todo App',
25+
objects: appConfig.objects?.filter((o: any) => ['todo_task'].includes(o.name)) || []
26+
}
1727
};
1828

1929
function ObjectView({ dataSource, config, onEdit }: any) {
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
export interface ObjectStackConfig {
2+
name?: string;
3+
version?: string;
4+
description?: string;
5+
build?: {
6+
outDir?: string;
7+
sourcemap?: boolean;
8+
minify?: boolean;
9+
target?: string;
10+
};
11+
datasources?: Record<string, {
12+
driver: string;
13+
[key: string]: any;
14+
}>;
15+
plugins?: (string | any)[];
16+
dev?: {
17+
port?: number;
18+
host?: string;
19+
watch?: boolean;
20+
hotReload?: boolean;
21+
};
22+
deploy?: {
23+
target: string;
24+
region?: string;
25+
};
26+
// Runtime config (merged from stack)
27+
objects?: any[];
28+
apps?: any[];
29+
manifest?: {
30+
data?: any[];
31+
};
32+
}
33+
34+
export function defineConfig(config: ObjectStackConfig) {
35+
return config;
36+
}

examples/msw-object-form/src/mocks/browser.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,7 @@ import { ObjectKernel, DriverPlugin, AppPlugin } from '@objectstack/runtime';
99
import { ObjectQLPlugin } from '@objectstack/objectql';
1010
import { InMemoryDriver } from '@objectstack/driver-memory';
1111
import { MSWPlugin } from '@objectstack/plugin-msw';
12-
import crmConfig from '@object-ui/example-crm/objectstack.config';
13-
import todoConfig from '@object-ui/example-todo/objectstack.config';
14-
15-
// Combine configurations
16-
const appConfig = {
17-
...crmConfig,
18-
objects: [
19-
...(crmConfig.objects || []),
20-
...(todoConfig.objects || [])
21-
],
22-
apps: [
23-
...(crmConfig.apps || []),
24-
...(todoConfig.apps || [])
25-
],
26-
manifest: {
27-
data: [
28-
...(crmConfig.manifest?.data || []),
29-
...(todoConfig.manifest?.data || [])
30-
]
31-
}
32-
};
12+
import appConfig from '../../objectstack.config';
3313

3414
let kernel: ObjectKernel | null = null;
3515
let driver: InMemoryDriver | null = null;

0 commit comments

Comments
 (0)