-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathobjectstack.config.ts
More file actions
78 lines (71 loc) · 3.08 KB
/
objectstack.config.ts
File metadata and controls
78 lines (71 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Root Development Configuration
*
* Aggregates all example apps for `pnpm serve` / `pnpm dev:server`.
* This is NOT a deployable config — it's the monorepo dev entry point.
*
* Console supports two running modes:
* - MSW: `pnpm dev` — Vite dev server with MSW intercepting API calls in browser
* - Server: `pnpm dev:server` — Real ObjectStack API server + Vite console proxying to it
*
* Plugins: Each example app exports a plugin class (CRMPlugin, TodoPlugin,
* KitchenSinkPlugin) that implements the AppMetadataPlugin interface.
* For standalone use, each plugin can be loaded independently via
* `kernel.use(new CRMPlugin())`. In the dev workspace, we collect their
* configs via `getConfig()` and merge them with `composeStacks()`.
*/
import { AppPlugin, DriverPlugin } from '@objectstack/runtime';
import { ObjectQLPlugin } from '@objectstack/objectql';
import { InMemoryDriver } from '@objectstack/driver-memory';
import { HonoServerPlugin } from '@objectstack/plugin-hono-server';
import { AuthPlugin } from '@objectstack/plugin-auth';
import { ConsolePlugin } from '@object-ui/console';
import { composeStacks } from '@objectstack/spec';
import { mergeViewsIntoObjects } from '@object-ui/core';
import { CRMPlugin } from './examples/crm/plugin';
import { TodoPlugin } from './examples/todo/plugin';
import { KitchenSinkPlugin } from './examples/kitchen-sink/plugin';
// Instantiate example plugins
const plugins = [new CRMPlugin(), new TodoPlugin(), new KitchenSinkPlugin()];
// Collect raw configs from each plugin via getConfig()
const allConfigs = plugins.map((p) => {
const raw = p.getConfig();
return (raw as any).default || raw;
});
// Aggregate seed data from all manifest.data arrays (spec selects one manifest,
// so we collect data from all stacks before composing).
const allData = allConfigs.flatMap((c: any) => c.manifest?.data || c.data || []);
// Protocol-level composition via @objectstack/spec: handles object dedup,
// array concatenation, actions→objects mapping, and manifest selection.
const composed = composeStacks(allConfigs as any[], { objectConflict: 'override' }) as any;
// Adapter: merge views[].listViews into object definitions for the runtime.
if (composed.objects && composed.views) {
composed.objects = mergeViewsIntoObjects(composed.objects, composed.views);
}
const mergedApp = {
...composed,
manifest: {
id: 'dev-workspace',
name: 'dev_workspace',
version: '0.0.0',
description: 'ObjectUI monorepo development workspace',
type: 'app',
data: allData,
},
};
// Export only plugins — no top-level objects/manifest/apps.
// The CLI auto-creates an AppPlugin from the config if it detects objects/manifest/apps,
// which would conflict with our explicit AppPlugin and skip seed data loading.
export default {
plugins: [
new ObjectQLPlugin(),
new DriverPlugin(new InMemoryDriver()),
new AppPlugin(mergedApp),
new AuthPlugin({
secret: process.env.AUTH_SECRET || 'objectui-dev-secret',
baseUrl: 'http://localhost:3000',
}),
new HonoServerPlugin({ port: 3000 }),
new ConsolePlugin(),
],
};