Skip to content

Commit e4fd794

Browse files
committed
Refactor AppManifestPlugin and DriverPlugin documentation; clarify dependencies and service registration
1 parent 07f2f83 commit e4fd794

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed
Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
import { Plugin, PluginContext } from '@objectstack/core';
2-
import { SchemaRegistry, ObjectQL } from './index';
32

43
/**
54
* AppManifestPlugin
65
*
7-
* Wraps an ObjectStack app manifest (objectstack.config.ts export)
8-
* as a Plugin so it can be loaded in the MiniKernel architecture.
6+
* Adapts a static Manifest JSON into a dynamic Kernel Service.
7+
* This allows the ObjectQL Engine to "discover" this app during its start phase.
98
*
10-
* Handles:
11-
* - Registering the app/plugin in SchemaRegistry
12-
* - Registering all objects defined in the manifest
13-
* - Seeding data if provided
14-
*
15-
* Dependencies: ['com.objectstack.engine.objectql']
9+
* Flow:
10+
* 1. AppPlugin registers `app.<id>` service (init phase)
11+
* 2. ObjectQL Engine discovers `app.*` services (start phase)
1612
*/
1713
export class AppManifestPlugin implements Plugin {
1814
name: string;
1915
version?: string;
20-
dependencies = ['com.objectstack.engine.objectql'];
16+
17+
// Dependencies removed: This plugin produces data. It doesn't need to consume the engine to register itself.
18+
// Making it dependency-free allows it to initialize BEFORE the engine if needed.
2119

2220
private manifest: any;
2321

2422
constructor(manifest: any) {
2523
this.manifest = manifest;
2624
// Support both direct manifest (legacy) and Stack Definition (nested manifest)
2725
const sys = manifest.manifest || manifest;
28-
this.name = sys.id || sys.name || 'unnamed-app';
26+
const appId = sys.id || sys.name || 'unnamed-app';
27+
28+
this.name = `plugin.app.${appId}`; // Unique plugin name
2929
this.version = sys.version;
3030
}
3131

3232
async init(ctx: PluginContext) {
3333
// Support both direct manifest (legacy) and Stack Definition (nested manifest)
3434
const sys = this.manifest.manifest || this.manifest;
35-
ctx.logger.log(`[AppManifestPlugin] Loading App Manifest: ${sys.id || sys.name}`);
35+
const appId = sys.id || sys.name;
36+
37+
ctx.logger.log(`[AppManifestPlugin] Registering App Service: ${appId}`);
3638

3739
// Register the app manifest as a service
38-
const serviceName = `app.${sys.id || sys.name}`;
40+
const serviceName = `app.${appId}`;
3941
ctx.registerService(serviceName, this.manifest);
40-
ctx.logger.log(`[AppManifestPlugin] Registered App service: ${serviceName}`);
4142
}
4243

4344
async start(ctx: PluginContext) {
44-
// Data seeding logic will be handled by the engine when it detects the app
45+
// No logic needed here.
46+
// Logic is inverted: The Engine will pull data from this service.
4547
}
4648
}

packages/objectql/src/driver-plugin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { Plugin, PluginContext } from '@objectstack/core';
66
* Generic plugin wrapper for ObjectQL drivers.
77
* Registers a driver with the ObjectQL engine.
88
*
9-
* Dependencies: ['com.objectstack.engine.objectql']
10-
* Services: None (modifies objectql service)
9+
* Dependencies: None (Registers service for ObjectQL to discover)
10+
* Services: driver.{name}
1111
*
1212
* @example
1313
* const memoryDriver = new InMemoryDriver();
@@ -17,7 +17,7 @@ import { Plugin, PluginContext } from '@objectstack/core';
1717
export class DriverPlugin implements Plugin {
1818
name: string;
1919
version = '1.0.0';
20-
dependencies = ['com.objectstack.engine.objectql'];
20+
// dependencies = ['com.objectstack.engine.objectql']; // Removed: Driver is a producer, not strictly a consumer during init
2121

2222
private driver: any;
2323

0 commit comments

Comments
 (0)