Skip to content

Commit f576069

Browse files
Copilothuangyiirene
andcommitted
Address code review feedback: improve type safety and error messages
Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
1 parent e3f0d23 commit f576069

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

packages/foundation/core/src/app.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export class ObjectQL implements IObjectQL {
221221
*
222222
* @private
223223
*/
224-
private createPluginContext(app: IObjectQL): any {
224+
private createPluginContext(app: IObjectQL): import('@objectstack/spec').PluginContextData {
225225
// TODO: Implement full PluginContext conversion
226226
// For now, provide a minimal adapter that maps IObjectQL to PluginContext
227227
return {
@@ -233,7 +233,12 @@ export class ObjectQL implements IObjectQL {
233233
},
234234
query: async (soql: string) => {
235235
// TODO: Implement SOQL query execution
236-
throw new Error('SOQL queries not yet implemented in adapter');
236+
// This requires implementing a SOQL parser and converter
237+
// For now, throw a descriptive error to guide users
238+
throw new Error(
239+
'SOQL queries are not yet supported in plugin context adapter. ' +
240+
'Please use context.ql.object(name).find() instead for data access.'
241+
);
237242
}
238243
},
239244
os: {
@@ -274,13 +279,13 @@ export class ObjectQL implements IObjectQL {
274279
},
275280
app: {
276281
router: {
277-
get: (path: string, handler: Function) => {
282+
get: (path: string, handler: (...args: unknown[]) => unknown, ...args: unknown[]) => {
278283
// TODO: Implement router registration
279284
},
280-
post: (path: string, handler: Function) => {
285+
post: (path: string, handler: (...args: unknown[]) => unknown, ...args: unknown[]) => {
281286
// TODO: Implement router registration
282287
},
283-
use: (pathOrHandler: string | Function, handler?: Function) => {
288+
use: (path: string | undefined, handler: (...args: unknown[]) => unknown, ...args: unknown[]) => {
284289
// TODO: Implement middleware registration
285290
}
286291
},

packages/foundation/platform-node/src/plugin.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ export function loadPlugin(packageName: string): ObjectQLPlugin | PluginDefiniti
2525
// Helper to check if candidate is a new PluginDefinition
2626
const isNewPlugin = (candidate: any): candidate is PluginDefinition => {
2727
return candidate && (
28+
// Check for any lifecycle method
2829
typeof candidate.onEnable === 'function' ||
2930
typeof candidate.onDisable === 'function' ||
3031
typeof candidate.onInstall === 'function' ||
3132
typeof candidate.onUninstall === 'function' ||
3233
typeof candidate.onUpgrade === 'function'
34+
) && (
35+
// Note: id is optional in PluginDefinition, so we don't require it
36+
// The spec allows plugins without id (it just defaults to package name)
37+
candidate.id === undefined || typeof candidate.id === 'string'
3338
);
3439
};
3540

0 commit comments

Comments
 (0)