Skip to content

Commit 88b09b9

Browse files
committed
Add core package and refactor imports across runtime modules
1 parent 589dc6e commit 88b09b9

File tree

11 files changed

+62
-33
lines changed

11 files changed

+62
-33
lines changed

packages/core/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "@objectstack/core",
3+
"version": "0.4.2",
4+
"description": "Microkernel Core for ObjectStack",
5+
"type": "module",
6+
"main": "dist/index.js",
7+
"types": "dist/index.d.ts",
8+
"scripts": {
9+
"build": "tsc"
10+
},
11+
"devDependencies": {
12+
"typescript": "^5.0.0"
13+
}
14+
}

packages/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './kernel.js';
2+
export * from './types.js';
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Plugin, PluginContext } from './types.js';
2-
import { SchemaRegistry, ObjectQL } from '@objectstack/objectql';
32

43
/**
54
* ObjectKernel - MiniKernel Architecture
Lines changed: 19 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ObjectKernel } from './mini-kernel.js';
1+
import { ObjectKernel } from './kernel.js';
22

33
/**
44
* PluginContext - Runtime context available to plugins
@@ -48,56 +48,48 @@ export interface PluginContext {
4848
* Get the kernel instance (for advanced use cases)
4949
* @returns Kernel instance
5050
*/
51-
getKernel?(): ObjectKernel;
51+
getKernel(): ObjectKernel;
5252
}
5353

5454
/**
55-
* Plugin - Standard plugin interface
55+
* Plugin Interface
5656
*
57-
* Plugins are independent modules with standard lifecycle hooks.
58-
* They can declare dependencies on other plugins and register services.
57+
* All ObjectStack plugins must implement this interface.
5958
*/
6059
export interface Plugin {
6160
/**
62-
* Plugin name (unique identifier)
61+
* Unique plugin name (e.g., 'com.objectstack.engine.objectql')
6362
*/
6463
name: string;
6564

6665
/**
67-
* Plugin version (optional)
66+
* Plugin version
6867
*/
6968
version?: string;
7069

7170
/**
72-
* Plugin type (optional, for special plugins like 'objectql')
73-
*/
74-
type?: string;
75-
76-
/**
77-
* Dependencies - list of plugin names this plugin depends on
78-
* Kernel will ensure dependencies are initialized first
71+
* List of other plugin names that this plugin depends on.
72+
* The kernel ensures these plugins are initialized before this one.
7973
*/
8074
dependencies?: string[];
8175

8276
/**
83-
* Init phase - Register services and prepare plugin
84-
* Called during kernel bootstrap, before start phase
85-
*
86-
* @param ctx - Plugin context
77+
* Init Phase: Register services
78+
* Called when kernel is initializing.
79+
* Use this to register services that other plugins might need.
8780
*/
88-
init(ctx: PluginContext): Promise<void>;
81+
init(ctx: PluginContext): Promise<void> | void;
8982

9083
/**
91-
* Start phase - Execute business logic, start servers, connect to databases
92-
* Called after all plugins have been initialized
93-
*
94-
* @param ctx - Plugin context
84+
* Start Phase: Execute business logic
85+
* Called after all plugins have been initialized.
86+
* Use this to start servers, connect to DBs, or execute main logic.
9587
*/
96-
start?(ctx: PluginContext): Promise<void>;
88+
start?(ctx: PluginContext): Promise<void> | void;
9789

9890
/**
99-
* Destroy phase - Cleanup resources, close connections
100-
* Called during kernel shutdown
91+
* Destroy Phase: Cleanup
92+
* Called when kernel is shutting down.
10193
*/
102-
destroy?(): Promise<void>;
94+
destroy?(): Promise<void> | void;
10395
}

packages/core/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./dist",
5+
"rootDir": "./src"
6+
},
7+
"include": ["src/**/*"],
8+
"exclude": []
9+
}

packages/runtime/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"dev": "tsc -w"
1111
},
1212
"dependencies": {
13+
"@objectstack/core": "workspace:*",
1314
"@objectstack/objectql": "workspace:*",
1415
"@objectstack/types": "workspace:*",
1516
"@objectstack/spec": "workspace:*"

packages/runtime/src/app-manifest-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Plugin, PluginContext } from './types.js';
1+
import { Plugin, PluginContext } from '@objectstack/core';
22
import { SchemaRegistry, ObjectQL } from '@objectstack/objectql';
33

44
/**

packages/runtime/src/driver-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Plugin, PluginContext } from './types.js';
1+
import { Plugin, PluginContext } from '@objectstack/core';
22

33
/**
44
* Driver Plugin

packages/runtime/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
export { ObjectQL, SchemaRegistry } from '@objectstack/objectql';
33

44
// Export Kernels
5-
export { ObjectKernel } from './mini-kernel.js';
5+
export { ObjectKernel } from '@objectstack/core';
66

77
// Export Plugins
88
export { ObjectQLPlugin } from '@objectstack/objectql';
@@ -13,7 +13,7 @@ export { AppManifestPlugin } from './app-manifest-plugin.js';
1313
export { ObjectStackRuntimeProtocol } from './protocol.js';
1414

1515
// Export Types
16-
export * from './types.js';
16+
export * from '@objectstack/core';
1717

1818
// Export Interfaces (Capability Contracts)
1919
export * from './interfaces/http-server.js';

packages/runtime/src/protocol.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { SchemaRegistry, ObjectQL } from '@objectstack/objectql';
2-
import { ObjectKernel } from './mini-kernel.js';
2+
import { ObjectKernel } from '@objectstack/core';
33

44
export interface ApiRequest {
55
params: Record<string, string>;

0 commit comments

Comments
 (0)