@@ -133,21 +133,32 @@ export default defineManifest({
133133
134134``` typescript
135135// src/index.ts
136- import { PluginContext } from ' @objectstack/spec ' ;
136+ import { Plugin } from ' @objectstack/core ' ;
137137import { Account } from ' ./objects/account.object' ;
138138import { registerWebhooks } from ' ./routes/webhooks' ;
139139import { startSyncJob } from ' ./jobs/sync' ;
140140
141- export default {
141+ const myPlugin: Plugin = {
142+ name: ' my-crm-plugin' ,
143+ version: ' 1.0.0' ,
144+
142145 /**
143146 * Called when the plugin is enabled.
144147 * Register objects, routes, jobs, and event listeners here.
145148 */
146- onEnable : async (context : PluginContext ) => {
147- const { ql, os, logger, router, scheduler, storage } = context ;
149+ init : async (context ) => {
150+ // context comes from @objectstack/core
151+ const { logger } = context ;
148152
149153 logger .info (' My CRM Plugin enabled' );
150154
155+ /*
156+ Note: Accessing services like 'ql' or 'router' depends on
157+ what plugins are installed in the kernel.
158+ const ql = context.getService('objectql');
159+ */
160+ },
161+
151162 // Register custom objects
152163 await ql.registerObject(Account);
153164
@@ -343,7 +354,7 @@ Add custom HTTP endpoints for webhooks, integrations, or custom APIs:
343354
344355``` typescript
345356// src/routes/webhooks.ts
346- import { Router } from ' @objectstack/spec ' ;
357+ import { IHttpServer } from ' @objectstack/core ' ;
347358import { z } from ' zod' ;
348359
349360const WebhookPayloadSchema = z .object ({
@@ -352,13 +363,13 @@ const WebhookPayloadSchema = z.object({
352363 timestamp: z .string (),
353364});
354365
355- export function registerWebhooks(router : Router ) {
366+ export function registerWebhooks(server : IHttpServer ) {
356367
357368 // ============================================================================
358369 // POST /api/webhooks/account
359370 // ============================================================================
360371
361- router .post (' /api/webhooks/account' , async (req , res ) => {
372+ server .post (' /api/webhooks/account' , async (req , res ) => {
362373 try {
363374 // Validate webhook payload
364375 const payload = WebhookPayloadSchema .parse (req .body );
@@ -385,7 +396,7 @@ export function registerWebhooks(router: Router) {
385396 // GET /api/integrations/sync
386397 // ============================================================================
387398
388- router .get (' /api/integrations/sync' , async (req , res ) => {
399+ server .get (' /api/integrations/sync' , async (req , res ) => {
389400 const { ql, logger } = req .context ;
390401
391402 try {
@@ -439,7 +450,7 @@ Run tasks periodically using cron expressions:
439450
440451``` typescript
441452// src/jobs/sync.ts
442- import { PluginContext } from ' @objectstack/spec ' ;
453+ import { PluginContext } from ' @objectstack/core ' ;
443454
444455export async function startSyncJob(context : PluginContext ) {
445456 const { ql, os, logger, storage } = context ;
@@ -506,7 +517,7 @@ React to data changes in real-time:
506517
507518``` typescript
508519// src/events/account-created.ts
509- import { PluginContext } from ' @objectstack/spec ' ;
520+ import { PluginContext } from ' @objectstack/core ' ;
510521
511522export function registerEventListeners(context : PluginContext ) {
512523 const { ql, logger } = context ;
0 commit comments