Skip to content

Commit 8474ee0

Browse files
Copilothotlong
andcommitted
feat: replace @objectql/core ObjectQLPlugin with @objectstack/objectql upstream
- Import ObjectQLPlugin from @objectstack/objectql (fixes app.* discovery chain) - Decompose deprecated aggregator: add QueryPlugin, ValidatorPlugin, FormulaPlugin separately - Register MemoryDriver as 'driver.default' service for upstream driver discovery - Add init/start adapter to QueryPlugin for @objectstack/core kernel compatibility - Add @objectstack/objectql, @objectql/plugin-formula, @objectql/plugin-query to root devDependencies - Update ROADMAP.md with migration completion tasks Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 2f3acd2 commit 8474ee0

File tree

5 files changed

+66
-13
lines changed

5 files changed

+66
-13
lines changed

ROADMAP.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,8 @@ const kernel = new ObjectStackKernel([
842842
| Extract validator wiring | Already in `@objectql/plugin-validator` — remove re-export from aggregator | ✅ |
843843
| Extract formula wiring | Already in `@objectql/plugin-formula` — remove re-export from aggregator | ✅ |
844844
| Deprecate `ObjectQLPlugin` aggregator class | Mark as deprecated with `console.warn`, point to explicit imports | ✅ |
845+
| Migrate `objectstack.config.ts` to upstream | Import `ObjectQLPlugin` from `@objectstack/objectql`, compose sub-plugins directly, register MemoryDriver as `driver.default` service — fixes `app.*` discovery chain for AuthPlugin | ✅ |
846+
| Add `init`/`start` adapter to `QueryPlugin` | Consistent with ValidatorPlugin / FormulaPlugin adapter pattern for `@objectstack/core` kernel compatibility | ✅ |
845847

846848
### Phase B: Dispose Bridge Class ✅
847849

objectstack.config.ts

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import { JSONRPCPlugin } from '@objectql/protocol-json-rpc';
2525
import { HonoServerPlugin } from '@objectstack/plugin-hono-server';
2626
import { AuthPlugin } from '@objectstack/plugin-auth';
2727
import { ConsolePlugin } from '@object-ui/console';
28-
import { ObjectQLPlugin } from '@objectql/core';
28+
import { ObjectQLPlugin } from '@objectstack/objectql';
29+
import { QueryPlugin } from '@objectql/plugin-query';
30+
import { ValidatorPlugin } from '@objectql/plugin-validator';
31+
import { FormulaPlugin } from '@objectql/plugin-formula';
2932
import { createApiRegistryPlugin } from '@objectstack/core';
3033
import { MemoryDriver } from '@objectql/driver-memory';
3134
import * as fs from 'fs';
@@ -55,6 +58,10 @@ function loadObjects(dir: string) {
5558

5659
const projectTrackerDir = path.join(__dirname, 'examples/showcase/project-tracker/src');
5760

61+
// Shared driver instance — registered as 'driver.default' service for
62+
// upstream ObjectQLPlugin discovery and passed to QueryPlugin for query execution.
63+
const defaultDriver = new MemoryDriver();
64+
5865
export default {
5966
metadata: {
6067
name: 'objectos',
@@ -66,25 +73,30 @@ export default {
6673
createApiRegistryPlugin(),
6774
new HonoServerPlugin({}),
6875
new ConsolePlugin(),
69-
new ObjectQLPlugin({
70-
enableRepository: true,
71-
enableQueryService: true,
72-
// Validator and Formula plugins are included by default
73-
enableValidator: true,
74-
enableFormulas: true,
75-
datasources: {
76-
default: new MemoryDriver()
77-
}
78-
}),
76+
// Register MemoryDriver as 'driver.default' service so upstream
77+
// ObjectQLPlugin can discover it during start() phase.
78+
{
79+
name: 'driver-memory',
80+
init: async (ctx: any) => {
81+
ctx.registerService('driver.default', defaultDriver);
82+
},
83+
start: async () => {},
84+
},
85+
// Upstream ObjectQLPlugin from @objectstack/objectql:
86+
// - Registers objectql, metadata, data, protocol services
87+
// - Discovers driver.* and app.* services (fixes auth plugin object registration)
88+
// - Registers audit hooks (created_by/updated_by) and tenant isolation middleware
89+
new ObjectQLPlugin(),
90+
new QueryPlugin({ datasources: { default: defaultDriver } }),
91+
new ValidatorPlugin(),
92+
new FormulaPlugin(),
7993
new ObjectQLSecurityPlugin({
8094
enableAudit: false
8195
}),
8296
new AuthPlugin({
8397
secret: process.env.AUTH_SECRET || 'objectql-dev-secret-change-me-in-production',
8498
trustedOrigins: ['http://localhost:*'],
8599
}),
86-
// ValidatorPlugin is managed by ObjectQLPlugin now
87-
// new ValidatorPlugin(),
88100
new GraphQLPlugin({
89101
basePath: '/graphql',
90102
introspection: true,

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@
3131
"@objectql/example-enterprise-erp": "workspace:*",
3232
"@objectql/example-project-tracker": "workspace:*",
3333
"@objectql/plugin-security": "workspace:*",
34+
"@objectql/plugin-formula": "workspace:*",
35+
"@objectql/plugin-query": "workspace:*",
3436
"@objectql/plugin-validator": "workspace:*",
3537
"@objectql/protocol-graphql": "workspace:*",
3638
"@objectql/protocol-json-rpc": "workspace:*",
3739
"@objectql/protocol-odata-v4": "workspace:*",
3840
"@object-ui/console": "^3.1.3",
3941
"@objectstack/cli": "^3.2.8",
4042
"@objectstack/core": "^3.2.8",
43+
"@objectstack/objectql": "^3.2.8",
4144
"@objectstack/plugin-auth": "^3.2.8",
4245
"@objectstack/plugin-hono-server": "^3.2.8",
4346
"@types/js-yaml": "^4.0.9",

packages/foundation/plugin-query/src/plugin.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,31 @@ export class QueryPlugin implements RuntimePlugin {
8888
async onStart(_ctx: RuntimeContext): Promise<void> {
8989
this.logger.debug('Query plugin started');
9090
}
91+
92+
// --- Adapter for @objectstack/core compatibility ---
93+
init = async (pluginCtx: any): Promise<void> => {
94+
const actualKernel = typeof pluginCtx.getKernel === 'function'
95+
? pluginCtx.getKernel()
96+
: pluginCtx;
97+
const ctx: any = {
98+
engine: actualKernel,
99+
getKernel: () => actualKernel,
100+
registerService: typeof pluginCtx.registerService === 'function'
101+
? pluginCtx.registerService.bind(pluginCtx)
102+
: undefined,
103+
};
104+
return this.install(ctx);
105+
}
106+
107+
start = async (pluginCtx: any): Promise<void> => {
108+
const actualKernel = typeof pluginCtx.getKernel === 'function'
109+
? pluginCtx.getKernel()
110+
: pluginCtx;
111+
const ctx: any = {
112+
engine: actualKernel,
113+
getKernel: () => actualKernel,
114+
};
115+
return this.onStart(ctx);
116+
}
117+
// ---------------------------------------------------
91118
}

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)