-
Notifications
You must be signed in to change notification settings - Fork 0
feat(crm): add console plugin integration, CLI dev mode, and plugin export #506
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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
|
||
|
|
||
| /** | ||
| * 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
|
||
| } | ||
| } | ||
| } | ||
|
|
||
| export default CRMPlugin; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
objectstack.config.tsnow importsConsolePluginfrom@object-ui/consoleand 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.tsimports@object-ui/example-crm→objectstack.config.ts). This will make browser bundling/runtime fail. Consider keepingobjectstack.config.tsas pure metadata (objects/apps/manifest) and movingConsolePluginto a Node-only runtime config entrypoint (e.g. a separateobjectstack.runtime.config.tsused bypnpm dev/serve) or loading the console plugin conditionally so the metadata package remains browser-safe.