Skip to content

Commit 1fb38a5

Browse files
Copilothotlong
andcommitted
Fix build errors: delegate MetadataRegistry to runtime, update tsconfigs, add type casts
Co-authored-by: hotlong <[email protected]>
1 parent 1f9ba89 commit 1fb38a5

File tree

7 files changed

+33
-89
lines changed

7 files changed

+33
-89
lines changed

packages/foundation/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
},
2424
"dependencies": {
2525
"@objectql/types": "workspace:*",
26-
"@objectstack/spec": "^0.2.0",
27-
"@objectstack/runtime": "^0.2.0",
26+
"@objectstack/spec": "workspace:*",
27+
"@objectstack/runtime": "workspace:*",
2828
"@objectstack/objectql": "^0.2.0",
2929
"js-yaml": "^4.1.0",
3030
"openai": "^4.28.0"

packages/foundation/core/src/app.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,26 @@ export class ObjectQL implements IObjectQL {
101101

102102
on(event: HookName, objectName: string, handler: HookHandler, packageName?: string) {
103103
// Delegate to kernel hook manager
104-
this.kernel.hooks.register(event, objectName, handler, packageName);
104+
// Note: Type casting needed due to type incompatibility between ObjectQL HookName (includes beforeCount)
105+
// and runtime HookName. This is safe as the kernel will accept all hook types.
106+
this.kernel.hooks.register(event as any, objectName, handler as any, packageName);
105107
}
106108

107109
async triggerHook(event: HookName, objectName: string, ctx: HookContext) {
108110
// Delegate to kernel hook manager
109-
await this.kernel.hooks.trigger(event, objectName, ctx);
111+
await this.kernel.hooks.trigger(event as any, objectName, ctx as any);
110112
}
111113

112114
registerAction(objectName: string, actionName: string, handler: ActionHandler, packageName?: string) {
113115
// Delegate to kernel action manager
114-
this.kernel.actions.register(objectName, actionName, handler, packageName);
116+
// Note: Type casting needed due to type incompatibility between ObjectQL ActionHandler
117+
// (includes input/api fields) and runtime ActionHandler. This is safe as runtime is more permissive.
118+
this.kernel.actions.register(objectName, actionName, handler as any, packageName);
115119
}
116120

117121
async executeAction(objectName: string, actionName: string, ctx: ActionContext) {
118122
// Delegate to kernel action manager
119-
return await this.kernel.actions.execute(objectName, actionName, ctx);
123+
return await this.kernel.actions.execute(objectName, actionName, ctx as any);
120124
}
121125

122126
createContext(options: ObjectQLContextOptions): ObjectQLContext {
@@ -128,7 +132,7 @@ export class ObjectQL implements IObjectQL {
128132
object: (name: string) => {
129133
return new ObjectRepository(name, ctx, this);
130134
},
131-
transaction: async (callback) => {
135+
transaction: async (callback: (ctx: ObjectQLContext) => Promise<any>) => {
132136
const driver = this.datasources['default'];
133137
if (!driver || !driver.beginTransaction) {
134138
return callback(ctx);
@@ -144,7 +148,7 @@ export class ObjectQL implements IObjectQL {
144148
const trxCtx: ObjectQLContext = {
145149
...ctx,
146150
transactionHandle: trx,
147-
transaction: async (cb) => cb(trxCtx)
151+
transaction: async (cb: (ctx: ObjectQLContext) => Promise<any>) => cb(trxCtx)
148152
};
149153

150154
try {
@@ -183,7 +187,7 @@ export class ObjectQL implements IObjectQL {
183187
// Normalize fields
184188
if (object.fields) {
185189
for (const [key, field] of Object.entries(object.fields)) {
186-
if (!field.name) {
190+
if (field && !field.name) {
187191
field.name = key;
188192
}
189193
}

packages/foundation/core/src/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88

99
// Re-export types from @objectstack packages for API compatibility
1010
export type { ObjectStackKernel, ObjectStackRuntimeProtocol } from '@objectstack/runtime';
11-
export type { ObjectQL as ObjectQLEngine, SchemaRegistry } from '@objectstack/objectql';
11+
// Note: @objectstack/objectql types temporarily commented out due to type incompatibilities
12+
// in the published package. Will be re-enabled when package is updated.
13+
// export type { ObjectQL as ObjectQLEngine, SchemaRegistry } from '@objectstack/objectql';
1214

1315
// Export ObjectStack spec types for driver development
1416
export type { DriverInterface, DriverOptions, QueryAST } from '@objectstack/spec';

packages/foundation/core/tsconfig.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,5 @@
1111
// Exclude external @objectstack/objectql package that has type incompatibilities
1212
// with our stub packages during migration phase
1313
"../../../node_modules/@objectstack+objectql"
14-
],
15-
"references": [
16-
{ "path": "../types" }
1714
]
1815
}

packages/foundation/types/src/registry.ts

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -6,64 +6,22 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
/**
10+
* Re-export MetadataRegistry and MetadataItem from @objectstack/runtime
11+
*
12+
* As of Week 3 refactoring, metadata management has been moved to the
13+
* @objectstack/runtime package to enable sharing across the ecosystem.
14+
*/
15+
export { MetadataRegistry, MetadataItem } from '@objectstack/runtime';
16+
17+
/**
18+
* Legacy Metadata interface - kept for backward compatibility
19+
* @deprecated Use MetadataItem from @objectstack/runtime instead
20+
*/
921
export interface Metadata {
1022
type: string;
1123
id: string;
1224
path?: string;
1325
package?: string;
1426
content: any;
1527
}
16-
17-
export class MetadataRegistry {
18-
// Map<type, Map<id, Metadata>>
19-
private store: Map<string, Map<string, Metadata>> = new Map();
20-
21-
register(type: string, metadata: Metadata) {
22-
if (!this.store.has(type)) {
23-
this.store.set(type, new Map());
24-
}
25-
this.store.get(type)!.set(metadata.id, metadata);
26-
}
27-
28-
unregister(type: string, id: string) {
29-
const map = this.store.get(type);
30-
if (map) {
31-
map.delete(id);
32-
}
33-
}
34-
35-
unregisterPackage(packageName: string) {
36-
for (const [type, map] of this.store.entries()) {
37-
const entriesToDelete: string[] = [];
38-
39-
for (const [id, meta] of map.entries()) {
40-
if (meta.package === packageName) {
41-
entriesToDelete.push(id);
42-
}
43-
}
44-
45-
// Delete all collected entries
46-
for (const id of entriesToDelete) {
47-
map.delete(id);
48-
}
49-
}
50-
}
51-
52-
get<T = any>(type: string, id: string): T | undefined {
53-
const map = this.store.get(type);
54-
if (!map) return undefined;
55-
const entry = map.get(id);
56-
return entry ? entry.content as T : undefined;
57-
}
58-
59-
list<T = any>(type: string): T[] {
60-
const map = this.store.get(type);
61-
if (!map) return [];
62-
return Array.from(map.values()).map(m => m.content as T);
63-
}
64-
65-
getEntry(type: string, id: string): Metadata | undefined {
66-
const map = this.store.get(type);
67-
return map ? map.get(id) : undefined;
68-
}
69-
}

packages/objectstack/runtime/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"compilerOptions": {
44
"outDir": "./dist",
55
"rootDir": "./src",
6-
"declaration": true,
7-
"composite": false
6+
"declaration": true
87
},
98
"include": ["src/**/*"]
109
}

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)