The GraphQL, OData V4, and JSON-RPC protocol plugins were not formally implementing a standard RuntimePlugin interface, leading to architectural inconsistency issues.
We have successfully implemented the RuntimePlugin interface specification and updated all three protocol plugins to conform to it.
Created /packages/foundation/types/src/plugin.ts defining:
export interface RuntimePlugin {
name: string;
version?: string;
install?(ctx: RuntimeContext): void | Promise<void>;
onStart?(ctx: RuntimeContext): void | Promise<void>;
onStop?(ctx: RuntimeContext): void | Promise<void>;
}export interface RuntimeContext {
engine: any;
getKernel?: () => any;
}- ✅ Implements
RuntimePlugininterface - ✅ Removed dependency on
@objectstack/runtime - ✅ Added helper methods for metadata and CRUD operations
- ✅ Direct engine access via RuntimeContext
- ✅ Implements
RuntimePlugininterface - ✅ Removed dependency on
@objectstack/runtime - ✅ Added helper methods for metadata and CRUD operations
- ✅ Direct engine access via RuntimeContext
- ✅ Implements
RuntimePlugininterface - ✅ Removed dependency on
@objectstack/runtime - ✅ Added helper methods for metadata and CRUD operations
- ✅ Direct engine access via RuntimeContext
Updated all three plugin package.json files to:
- Remove
@objectstack/runtimedependency - Use only
@objectql/typesfor interface definitions
Added comprehensive test suite in /packages/foundation/types/test/plugin.test.ts:
- RuntimePlugin interface conformance tests
- RuntimeContext functionality tests
- Lifecycle hook execution order tests
- Sync/async hook support tests
Updated /packages/protocols/README.md:
- Documented RuntimePlugin interface
- Documented RuntimeContext
- Updated plugin implementation pattern
- Added Engine API documentation
- Removed references to deprecated ObjectStackRuntimeProtocol
All plugins now implement:
- install(ctx) - Called during kernel initialization
- onStart(ctx) - Called when kernel starts
- onStop(ctx) - Called when kernel stops
All plugins implement the same RuntimePlugin interface from @objectql/types, ensuring:
- Uniform plugin architecture
- Predictable lifecycle management
- Easy plugin discovery and validation
- Type-safe plugin development
Plugins no longer depend on a separate protocol bridge layer. Instead:
- They access the kernel/engine directly via RuntimeContext
- They implement their own helper methods for common operations
- They maintain full control over their data access patterns
- All protocol plugins follow the same interface
- Clear lifecycle management
- Consistent error handling
- Easy to add new protocol plugins
- Clear contract to implement
- Type-safe development
- Reduced dependency on non-existent packages
- Simpler architecture
- Better testability
- ✅ RuntimePlugin interface tests pass
- ✅ Existing plugin lifecycle tests remain valid
- ✅ No breaking changes to plugin APIs
- ✅ TypeScript compilation successful (modulo external dependencies)
The implementation is complete and ready for use. Protocol plugins can now be:
- Instantiated with their configuration
- Passed to the kernel/runtime
- Initialized via the install hook
- Started via the onStart hook
- Stopped via the onStop hook
All three plugins (GraphQL, OData V4, JSON-RPC) are now fully compliant with the ObjectStack RuntimePlugin specification.