-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtypes.ts
More file actions
103 lines (90 loc) · 2.6 KB
/
Copy pathtypes.ts
File metadata and controls
103 lines (90 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { ObjectKernel } from './mini-kernel.js';
/**
* PluginContext - Runtime context available to plugins
*
* Provides access to:
* - Service registry (registerService/getService)
* - Event/Hook system (hook/trigger)
* - Logger
* - Kernel instance (for advanced use cases)
*/
export interface PluginContext {
/**
* Register a service that can be consumed by other plugins
* @param name - Service name (e.g., 'db', 'http-server', 'objectql')
* @param service - Service instance
*/
registerService(name: string, service: any): void;
/**
* Get a service registered by another plugin
* @param name - Service name
* @returns Service instance
* @throws Error if service not found
*/
getService<T>(name: string): T;
/**
* Register a hook handler
* @param name - Hook name (e.g., 'kernel:ready', 'data:beforeInsert')
* @param handler - Hook handler function
*/
hook(name: string, handler: (...args: any[]) => void | Promise<void>): void;
/**
* Trigger a hook
* @param name - Hook name
* @param args - Arguments to pass to hook handlers
*/
trigger(name: string, ...args: any[]): Promise<void>;
/**
* Logger instance
*/
logger: Console;
/**
* Get the kernel instance (for advanced use cases)
* @returns Kernel instance
*/
getKernel?(): ObjectKernel;
}
/**
* Plugin - Standard plugin interface
*
* Plugins are independent modules with standard lifecycle hooks.
* They can declare dependencies on other plugins and register services.
*/
export interface Plugin {
/**
* Plugin name (unique identifier)
*/
name: string;
/**
* Plugin version (optional)
*/
version?: string;
/**
* Plugin type (optional, for special plugins like 'objectql')
*/
type?: string;
/**
* Dependencies - list of plugin names this plugin depends on
* Kernel will ensure dependencies are initialized first
*/
dependencies?: string[];
/**
* Init phase - Register services and prepare plugin
* Called during kernel bootstrap, before start phase
*
* @param ctx - Plugin context
*/
init(ctx: PluginContext): Promise<void>;
/**
* Start phase - Execute business logic, start servers, connect to databases
* Called after all plugins have been initialized
*
* @param ctx - Plugin context
*/
start?(ctx: PluginContext): Promise<void>;
/**
* Destroy phase - Cleanup resources, close connections
* Called during kernel shutdown
*/
destroy?(): Promise<void>;
}