Skip to content

Commit c07c600

Browse files
committed
feat(plugin): enhance ObjectQLPlugin lifecycle management with init, start, and stop methods
1 parent c0aa74f commit c07c600

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

packages/services/service-cloud/src/objectos-stack.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,33 @@ async function createHostEnginePlugins(): Promise<Plugin[]> {
7070
version: '0.0.0',
7171
async init(ctx: PluginContext) {
7272
const plugin = new ObjectQLPlugin();
73-
oqlRef.ql = (plugin as any).ql ?? plugin;
7473
(this as any)._inner = plugin;
7574
if ((plugin as any).init) await (plugin as any).init(ctx);
75+
// Capture the engine instance AFTER init() — ObjectQLPlugin
76+
// creates its `ql` lazily inside init(), so reading `plugin.ql`
77+
// before that returns undefined and breaks the
78+
// datasource-mapping wiring below.
79+
oqlRef.ql = (plugin as any).ql ?? plugin;
80+
},
81+
async start(ctx: PluginContext) {
82+
const plugin = (this as any)._inner;
83+
// Forward start() so ObjectQLPlugin can discover `driver.*`
84+
// services (registered by DriverPlugin.init) and wire them
85+
// into the engine via `ql.registerDriver(...)`. Without this
86+
// the engine has zero drivers at request time, causing
87+
// `[ObjectQL] No driver available for object '...'` errors.
88+
if (plugin?.start) await plugin.start(ctx);
89+
},
90+
async stop(ctx: PluginContext) {
91+
const plugin = (this as any)._inner;
92+
if (plugin?.stop) await plugin.stop(ctx);
7693
},
7794
};
7895

7996
const datasourceMapping: Plugin = {
8097
name: 'objectos-host-datasource-mapping',
8198
version: '0.0.0',
99+
dependencies: ['com.objectstack.engine.objectql'],
82100
async init() {
83101
const ql = oqlRef.ql;
84102
if (ql?.setDatasourceMapping) {

0 commit comments

Comments
 (0)