Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions examples/crm/objectstack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OrderObject } from './src/objects/order.object';
import { UserObject } from './src/objects/user.object';
import { ProjectObject } from './src/objects/project.object';
import { EventObject } from './src/objects/event.object';
import { ConsolePlugin } from '@object-ui/console';

export default defineStack({
objects: [
Expand Down Expand Up @@ -686,5 +687,8 @@ export default defineStack({
}
]

}
});
},
plugins: [
new ConsolePlugin(),
],
Comment on lines +690 to +693
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

objectstack.config.ts now imports ConsolePlugin from @object-ui/console and instantiates it in the exported config. @object-ui/console's plugin implementation imports Node-only built-ins (fs, path, url), and this CRM config is imported in browser contexts (e.g. Storybook’s .storybook/msw-browser.ts imports @object-ui/example-crmobjectstack.config.ts). This will make browser bundling/runtime fail. Consider keeping objectstack.config.ts as pure metadata (objects/apps/manifest) and moving ConsolePlugin to a Node-only runtime config entrypoint (e.g. a separate objectstack.runtime.config.ts used by pnpm dev/serve) or loading the console plugin conditionally so the metadata package remains browser-safe.

Copilot uses AI. Check for mistakes.
} as any);
5 changes: 4 additions & 1 deletion examples/crm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"version": "1.0.0",
"description": "CRM Metadata Example using ObjectStack Protocol",
"private": true,
"type": "module",
"main": "dist/objectstack.json",
"types": "src/index.ts",
"exports": {
".": "./src/index.ts",
"./objectstack.config": "./objectstack.config.ts"
"./objectstack.config": "./objectstack.config.ts",
"./plugin": "./plugin.ts"
},
"scripts": {
"dev": "objectstack serve --dev objectstack.config.ts",
"serve": "objectstack serve objectstack.config.ts",
"build": "objectstack compile objectstack.config.ts",
"start": "tsx server.ts"
Expand Down
58 changes: 58 additions & 0 deletions examples/crm/plugin.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* CRM Example Plugin
*
* Exports the CRM configuration as an ObjectStack plugin that can be
* loaded by any ObjectStack application. Other projects can import
* the CRM metadata (objects, apps, dashboards, manifest) without
* needing to know the internal structure.
*
* Usage in another project:
*
* import { CRMPlugin } from '@object-ui/example-crm/plugin';
*
* const kernel = new ObjectKernel();
* kernel.use(new CRMPlugin());
*
* Or import the raw config for merging:
*
* import { crmConfig } from '@object-ui/example-crm/plugin';
*/

import config from './objectstack.config';

/** Raw CRM stack configuration for direct merging */
export const crmConfig = config;
Comment on lines +21 to +24
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

plugin.ts imports and re-exports objectstack.config.ts as crmConfig. Since objectstack.config.ts now includes new ConsolePlugin() (Node-only), any consumer that imports crmConfig/CRMPlugin will also pull in the console’s Node built-ins. If the goal is to share CRM metadata, consider exporting a metadata-only config (no runtime plugins) from ./plugin and keeping runtime UI plugins in a separate Node-only entrypoint.

Copilot uses AI. Check for mistakes.

/**
* CRM Plugin — wraps the CRM metadata as a kernel-compatible plugin.
*
* When loaded via `kernel.use(new CRMPlugin())`, ObjectStack's AppPlugin
* will register all CRM objects, apps, dashboards, and seed data.
*/
export class CRMPlugin {
readonly name = '@object-ui/example-crm';
readonly version = '1.0.0';
readonly type = 'app-metadata' as const;
readonly description = 'CRM application metadata (objects, apps, dashboards, seed data)';

async init() {
// No initialization needed
}

async start(ctx: any) {
const logger = ctx.logger || console;

try {
// Dynamically import AppPlugin to keep plugin.ts dependency-light
const { AppPlugin } = await import('@objectstack/runtime');
const appPlugin = new AppPlugin(config);
await ctx.kernel?.use?.(appPlugin);
logger.info('[CRM] Metadata loaded: objects, apps, dashboards, seed data');
} catch (e: any) {
logger.warn(`[CRM] Could not auto-register via AppPlugin: ${e.message}`);
logger.info('[CRM] Config is available via crmConfig export for manual merging');
Comment on lines +42 to +53
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In start(), await ctx.kernel?.use?.(appPlugin) will silently do nothing when ctx.kernel (or use) is missing, but the code still logs "Metadata loaded" as if registration succeeded. This can lead to false-positive startup logs and a non-functional plugin. Consider validating that ctx.kernel exists and supports use() before logging success; otherwise log a warning/error and return (or throw) so failures are visible.

Copilot uses AI. Check for mistakes.
}
}
}

export default CRMPlugin;
2 changes: 1 addition & 1 deletion examples/crm/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { InMemoryDriver } from '@objectstack/driver-memory';
import { AuthPlugin } from '@objectstack/plugin-auth';
import config from './objectstack.config';
import { pino } from 'pino';
import { ConsolePlugin } from './console-plugin';
import { ConsolePlugin } from '@object-ui/console';

async function startServer() {
const logger = pino({
Expand Down
2 changes: 1 addition & 1 deletion examples/crm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"strict": true,
"skipLibCheck": true
},
"include": ["src/**/*", "objectstack.config.ts", "server.ts", "console-plugin.ts"]
"include": ["src/**/*", "objectstack.config.ts", "server.ts", "console-plugin.ts", "plugin.ts"]
}