Skip to content

Commit e7a6f5d

Browse files
authored
Merge pull request #346 from objectstack-ai/copilot/fix-action-step-failure
2 parents 76ee9ca + fbd103b commit e7a6f5d

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

packages/foundation/core/src/app.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,24 @@ export class ObjectQL implements IObjectQL {
110110
return items.map(unwrapContent);
111111
},
112112
unregister: (type: string, name: string) => {
113-
// Access private static storage using any cast
114-
const metadata = (SchemaRegistry as any).metadata;
115-
if (metadata instanceof Map) {
116-
const collection = metadata.get(type);
117-
if (collection instanceof Map) {
118-
collection.delete(name);
113+
// Use the official unregisterItem API when available (added in @objectstack/objectql v0.9.2)
114+
// Fallback to direct metadata access for older versions or test mocks
115+
if (typeof SchemaRegistry.unregisterItem === 'function') {
116+
SchemaRegistry.unregisterItem(type, name);
117+
} else {
118+
// Fallback: try to access metadata Map directly
119+
const metadata = (SchemaRegistry as any).metadata;
120+
if (metadata && metadata instanceof Map) {
121+
const collection = metadata.get(type);
122+
if (collection && collection instanceof Map) {
123+
collection.delete(name);
124+
}
119125
}
120126
}
121127
},
122128
unregisterPackage: (packageName: string) => {
123129
const metadata = (SchemaRegistry as any).metadata;
124-
if (metadata instanceof Map) {
130+
if (metadata && metadata instanceof Map) {
125131
for (const [type, collection] of metadata.entries()) {
126132
if (collection instanceof Map) {
127133
for (const [key, item] of collection.entries()) {
@@ -395,6 +401,21 @@ export class ObjectQL implements IObjectQL {
395401
await (this.kernel as any).bootstrap();
396402
} else {
397403
console.warn('ObjectKernel does not have start() or bootstrap() method');
404+
405+
// Manually initialize plugins if kernel doesn't support lifecycle
406+
for (const plugin of this.kernelPlugins) {
407+
try {
408+
if (typeof (plugin as any).init === 'function') {
409+
await (plugin as any).init();
410+
}
411+
if (typeof (plugin as any).start === 'function') {
412+
await (plugin as any).start();
413+
}
414+
} catch (error) {
415+
console.error(`Failed to initialize plugin ${(plugin as any).name || 'unknown'}:`, error);
416+
// Continue with other plugins even if one fails
417+
}
418+
}
398419
}
399420

400421
// TEMPORARY: Set driver for backward compatibility during migration

packages/foundation/core/test/__mocks__/@objectstack/objectql.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,18 @@ export const SchemaRegistry = {
2828
const key = item[keyField];
2929
mockStore.get(type)!.set(key, item);
3030
}),
31+
unregisterItem: jest.fn((type: string, name: string) => {
32+
const collection = mockStore.get(type);
33+
if (collection) {
34+
collection.delete(name);
35+
}
36+
}),
3137
getItem: jest.fn((type: string, name: string) => {
3238
return mockStore.get(type)?.get(name);
3339
}),
3440
listItems: jest.fn((type: string) => {
3541
const items = mockStore.get(type);
3642
return items ? Array.from(items.values()) : [];
3743
}),
38-
metadata: {},
44+
metadata: mockStore,
3945
};

0 commit comments

Comments
 (0)