@objectstack/core 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/.turbo/turbo-build.log +58 -0
  2. package/CHANGELOG.md +25 -0
  3. package/dist/index.cjs +4294 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1777 -0
  6. package/dist/index.d.ts +1776 -21
  7. package/dist/index.js +4246 -23
  8. package/dist/index.js.map +1 -0
  9. package/package.json +4 -4
  10. package/tsconfig.json +1 -3
  11. package/dist/api-registry-plugin.d.ts +0 -54
  12. package/dist/api-registry-plugin.d.ts.map +0 -1
  13. package/dist/api-registry-plugin.js +0 -53
  14. package/dist/api-registry-plugin.test.d.ts +0 -2
  15. package/dist/api-registry-plugin.test.d.ts.map +0 -1
  16. package/dist/api-registry-plugin.test.js +0 -334
  17. package/dist/api-registry.d.ts +0 -259
  18. package/dist/api-registry.d.ts.map +0 -1
  19. package/dist/api-registry.js +0 -600
  20. package/dist/api-registry.test.d.ts +0 -2
  21. package/dist/api-registry.test.d.ts.map +0 -1
  22. package/dist/api-registry.test.js +0 -957
  23. package/dist/contracts/data-engine.d.ts +0 -62
  24. package/dist/contracts/data-engine.d.ts.map +0 -1
  25. package/dist/contracts/data-engine.js +0 -1
  26. package/dist/contracts/http-server.d.ts +0 -119
  27. package/dist/contracts/http-server.d.ts.map +0 -1
  28. package/dist/contracts/http-server.js +0 -11
  29. package/dist/contracts/logger.d.ts +0 -63
  30. package/dist/contracts/logger.d.ts.map +0 -1
  31. package/dist/contracts/logger.js +0 -1
  32. package/dist/dependency-resolver.d.ts +0 -62
  33. package/dist/dependency-resolver.d.ts.map +0 -1
  34. package/dist/dependency-resolver.js +0 -317
  35. package/dist/dependency-resolver.test.d.ts +0 -2
  36. package/dist/dependency-resolver.test.d.ts.map +0 -1
  37. package/dist/dependency-resolver.test.js +0 -241
  38. package/dist/health-monitor.d.ts +0 -65
  39. package/dist/health-monitor.d.ts.map +0 -1
  40. package/dist/health-monitor.js +0 -269
  41. package/dist/health-monitor.test.d.ts +0 -2
  42. package/dist/health-monitor.test.d.ts.map +0 -1
  43. package/dist/health-monitor.test.js +0 -68
  44. package/dist/hot-reload.d.ts +0 -79
  45. package/dist/hot-reload.d.ts.map +0 -1
  46. package/dist/hot-reload.js +0 -313
  47. package/dist/index.d.ts.map +0 -1
  48. package/dist/kernel-base.d.ts +0 -84
  49. package/dist/kernel-base.d.ts.map +0 -1
  50. package/dist/kernel-base.js +0 -219
  51. package/dist/kernel.d.ts +0 -113
  52. package/dist/kernel.d.ts.map +0 -1
  53. package/dist/kernel.js +0 -472
  54. package/dist/kernel.test.d.ts +0 -2
  55. package/dist/kernel.test.d.ts.map +0 -1
  56. package/dist/kernel.test.js +0 -414
  57. package/dist/lite-kernel.d.ts +0 -55
  58. package/dist/lite-kernel.d.ts.map +0 -1
  59. package/dist/lite-kernel.js +0 -112
  60. package/dist/lite-kernel.test.d.ts +0 -2
  61. package/dist/lite-kernel.test.d.ts.map +0 -1
  62. package/dist/lite-kernel.test.js +0 -161
  63. package/dist/logger.d.ts +0 -71
  64. package/dist/logger.d.ts.map +0 -1
  65. package/dist/logger.js +0 -312
  66. package/dist/logger.test.d.ts +0 -2
  67. package/dist/logger.test.d.ts.map +0 -1
  68. package/dist/logger.test.js +0 -92
  69. package/dist/plugin-loader.d.ts +0 -164
  70. package/dist/plugin-loader.d.ts.map +0 -1
  71. package/dist/plugin-loader.js +0 -319
  72. package/dist/plugin-loader.test.d.ts +0 -2
  73. package/dist/plugin-loader.test.d.ts.map +0 -1
  74. package/dist/plugin-loader.test.js +0 -348
  75. package/dist/qa/adapter.d.ts +0 -14
  76. package/dist/qa/adapter.d.ts.map +0 -1
  77. package/dist/qa/adapter.js +0 -1
  78. package/dist/qa/http-adapter.d.ts +0 -16
  79. package/dist/qa/http-adapter.d.ts.map +0 -1
  80. package/dist/qa/http-adapter.js +0 -107
  81. package/dist/qa/index.d.ts +0 -4
  82. package/dist/qa/index.d.ts.map +0 -1
  83. package/dist/qa/index.js +0 -3
  84. package/dist/qa/runner.d.ts +0 -27
  85. package/dist/qa/runner.d.ts.map +0 -1
  86. package/dist/qa/runner.js +0 -157
  87. package/dist/security/index.d.ts +0 -17
  88. package/dist/security/index.d.ts.map +0 -1
  89. package/dist/security/index.js +0 -17
  90. package/dist/security/permission-manager.d.ts +0 -96
  91. package/dist/security/permission-manager.d.ts.map +0 -1
  92. package/dist/security/permission-manager.js +0 -235
  93. package/dist/security/permission-manager.test.d.ts +0 -2
  94. package/dist/security/permission-manager.test.d.ts.map +0 -1
  95. package/dist/security/permission-manager.test.js +0 -220
  96. package/dist/security/plugin-config-validator.d.ts +0 -79
  97. package/dist/security/plugin-config-validator.d.ts.map +0 -1
  98. package/dist/security/plugin-config-validator.js +0 -166
  99. package/dist/security/plugin-config-validator.test.d.ts +0 -2
  100. package/dist/security/plugin-config-validator.test.d.ts.map +0 -1
  101. package/dist/security/plugin-config-validator.test.js +0 -223
  102. package/dist/security/plugin-permission-enforcer.d.ts +0 -154
  103. package/dist/security/plugin-permission-enforcer.d.ts.map +0 -1
  104. package/dist/security/plugin-permission-enforcer.js +0 -323
  105. package/dist/security/plugin-permission-enforcer.test.d.ts +0 -2
  106. package/dist/security/plugin-permission-enforcer.test.d.ts.map +0 -1
  107. package/dist/security/plugin-permission-enforcer.test.js +0 -205
  108. package/dist/security/plugin-signature-verifier.d.ts +0 -96
  109. package/dist/security/plugin-signature-verifier.d.ts.map +0 -1
  110. package/dist/security/plugin-signature-verifier.js +0 -250
  111. package/dist/security/sandbox-runtime.d.ts +0 -115
  112. package/dist/security/sandbox-runtime.d.ts.map +0 -1
  113. package/dist/security/sandbox-runtime.js +0 -311
  114. package/dist/security/security-scanner.d.ts +0 -92
  115. package/dist/security/security-scanner.d.ts.map +0 -1
  116. package/dist/security/security-scanner.js +0 -273
  117. package/dist/types.d.ts +0 -89
  118. package/dist/types.d.ts.map +0 -1
  119. package/dist/types.js +0 -1
  120. package/dist/utils/env.d.ts +0 -20
  121. package/dist/utils/env.d.ts.map +0 -1
  122. package/dist/utils/env.js +0 -46
  123. package/dist/utils/env.test.d.ts +0 -2
  124. package/dist/utils/env.test.d.ts.map +0 -1
  125. package/dist/utils/env.test.js +0 -52
@@ -1,219 +0,0 @@
1
- /**
2
- * ObjectKernelBase - Abstract Base Class for Microkernel
3
- *
4
- * Provides common functionality for ObjectKernel and LiteKernel:
5
- * - Plugin management (Map storage)
6
- * - Dependency resolution (topological sort)
7
- * - Hook/Event system
8
- * - Context creation
9
- * - State validation
10
- *
11
- * This eliminates code duplication between the implementations.
12
- */
13
- export class ObjectKernelBase {
14
- constructor(logger) {
15
- this.plugins = new Map();
16
- this.services = new Map();
17
- this.hooks = new Map();
18
- this.state = 'idle';
19
- this.logger = logger;
20
- }
21
- /**
22
- * Validate kernel state
23
- * @param requiredState - Required state for the operation
24
- * @throws Error if current state doesn't match
25
- */
26
- validateState(requiredState) {
27
- if (this.state !== requiredState) {
28
- throw new Error(`[Kernel] Invalid state: expected '${requiredState}', got '${this.state}'`);
29
- }
30
- }
31
- /**
32
- * Validate kernel is in idle state (for plugin registration)
33
- */
34
- validateIdle() {
35
- if (this.state !== 'idle') {
36
- throw new Error('[Kernel] Cannot register plugins after bootstrap has started');
37
- }
38
- }
39
- /**
40
- * Create the plugin context
41
- * Subclasses can override to customize context creation
42
- */
43
- createContext() {
44
- return {
45
- registerService: (name, service) => {
46
- if (this.services instanceof Map) {
47
- if (this.services.has(name)) {
48
- throw new Error(`[Kernel] Service '${name}' already registered`);
49
- }
50
- this.services.set(name, service);
51
- }
52
- else {
53
- // IServiceRegistry implementation
54
- this.services.register(name, service);
55
- }
56
- this.logger.info(`Service '${name}' registered`, { service: name });
57
- },
58
- getService: (name) => {
59
- if (this.services instanceof Map) {
60
- const service = this.services.get(name);
61
- if (!service) {
62
- throw new Error(`[Kernel] Service '${name}' not found`);
63
- }
64
- return service;
65
- }
66
- else {
67
- // IServiceRegistry implementation
68
- return this.services.get(name);
69
- }
70
- },
71
- hook: (name, handler) => {
72
- if (!this.hooks.has(name)) {
73
- this.hooks.set(name, []);
74
- }
75
- this.hooks.get(name).push(handler);
76
- },
77
- trigger: async (name, ...args) => {
78
- const handlers = this.hooks.get(name) || [];
79
- for (const handler of handlers) {
80
- await handler(...args);
81
- }
82
- },
83
- getServices: () => {
84
- if (this.services instanceof Map) {
85
- return new Map(this.services);
86
- }
87
- else {
88
- // For IServiceRegistry, we need to return the underlying Map
89
- // This is a compatibility method
90
- return new Map();
91
- }
92
- },
93
- logger: this.logger,
94
- getKernel: () => this,
95
- };
96
- }
97
- /**
98
- * Resolve plugin dependencies using topological sort
99
- * @returns Ordered list of plugins (dependencies first)
100
- */
101
- resolveDependencies() {
102
- const resolved = [];
103
- const visited = new Set();
104
- const visiting = new Set();
105
- const visit = (pluginName) => {
106
- if (visited.has(pluginName))
107
- return;
108
- if (visiting.has(pluginName)) {
109
- throw new Error(`[Kernel] Circular dependency detected: ${pluginName}`);
110
- }
111
- const plugin = this.plugins.get(pluginName);
112
- if (!plugin) {
113
- throw new Error(`[Kernel] Plugin '${pluginName}' not found`);
114
- }
115
- visiting.add(pluginName);
116
- // Visit dependencies first
117
- const deps = plugin.dependencies || [];
118
- for (const dep of deps) {
119
- if (!this.plugins.has(dep)) {
120
- throw new Error(`[Kernel] Dependency '${dep}' not found for plugin '${pluginName}'`);
121
- }
122
- visit(dep);
123
- }
124
- visiting.delete(pluginName);
125
- visited.add(pluginName);
126
- resolved.push(plugin);
127
- };
128
- // Visit all plugins
129
- for (const pluginName of this.plugins.keys()) {
130
- visit(pluginName);
131
- }
132
- return resolved;
133
- }
134
- /**
135
- * Run plugin init phase
136
- * @param plugin - Plugin to initialize
137
- */
138
- async runPluginInit(plugin) {
139
- const pluginName = plugin.name;
140
- this.logger.info(`Initializing plugin: ${pluginName}`);
141
- try {
142
- await plugin.init(this.context);
143
- this.logger.info(`Plugin initialized: ${pluginName}`);
144
- }
145
- catch (error) {
146
- this.logger.error(`Plugin init failed: ${pluginName}`, error);
147
- throw error;
148
- }
149
- }
150
- /**
151
- * Run plugin start phase
152
- * @param plugin - Plugin to start
153
- */
154
- async runPluginStart(plugin) {
155
- if (!plugin.start)
156
- return;
157
- const pluginName = plugin.name;
158
- this.logger.info(`Starting plugin: ${pluginName}`);
159
- try {
160
- await plugin.start(this.context);
161
- this.logger.info(`Plugin started: ${pluginName}`);
162
- }
163
- catch (error) {
164
- this.logger.error(`Plugin start failed: ${pluginName}`, error);
165
- throw error;
166
- }
167
- }
168
- /**
169
- * Run plugin destroy phase
170
- * @param plugin - Plugin to destroy
171
- */
172
- async runPluginDestroy(plugin) {
173
- if (!plugin.destroy)
174
- return;
175
- const pluginName = plugin.name;
176
- this.logger.info(`Destroying plugin: ${pluginName}`);
177
- try {
178
- await plugin.destroy();
179
- this.logger.info(`Plugin destroyed: ${pluginName}`);
180
- }
181
- catch (error) {
182
- this.logger.error(`Plugin destroy failed: ${pluginName}`, error);
183
- throw error;
184
- }
185
- }
186
- /**
187
- * Trigger a hook with all registered handlers
188
- * @param name - Hook name
189
- * @param args - Arguments to pass to handlers
190
- */
191
- async triggerHook(name, ...args) {
192
- const handlers = this.hooks.get(name) || [];
193
- this.logger.debug(`Triggering hook: ${name}`, {
194
- hook: name,
195
- handlerCount: handlers.length
196
- });
197
- for (const handler of handlers) {
198
- try {
199
- await handler(...args);
200
- }
201
- catch (error) {
202
- this.logger.error(`Hook handler failed: ${name}`, error);
203
- // Continue with other handlers even if one fails
204
- }
205
- }
206
- }
207
- /**
208
- * Get current kernel state
209
- */
210
- getState() {
211
- return this.state;
212
- }
213
- /**
214
- * Get all registered plugins
215
- */
216
- getPlugins() {
217
- return new Map(this.plugins);
218
- }
219
- }
package/dist/kernel.d.ts DELETED
@@ -1,113 +0,0 @@
1
- import { Plugin } from './types.js';
2
- import type { LoggerConfig } from '@objectstack/spec/system';
3
- import { ServiceLifecycle, ServiceFactory } from './plugin-loader.js';
4
- /**
5
- * Enhanced Kernel Configuration
6
- */
7
- export interface ObjectKernelConfig {
8
- logger?: Partial<LoggerConfig>;
9
- /** Default plugin startup timeout in milliseconds */
10
- defaultStartupTimeout?: number;
11
- /** Whether to enable graceful shutdown */
12
- gracefulShutdown?: boolean;
13
- /** Graceful shutdown timeout in milliseconds */
14
- shutdownTimeout?: number;
15
- /** Whether to rollback on startup failure */
16
- rollbackOnFailure?: boolean;
17
- /** Whether to skip strict system requirement validation (Critical for testing) */
18
- skipSystemValidation?: boolean;
19
- }
20
- /**
21
- * Enhanced ObjectKernel with Advanced Plugin Management
22
- *
23
- * Extends the basic ObjectKernel with:
24
- * - Async plugin loading with validation
25
- * - Version compatibility checking
26
- * - Plugin signature verification
27
- * - Configuration validation (Zod)
28
- * - Factory-based dependency injection
29
- * - Service lifecycle management (singleton/transient/scoped)
30
- * - Circular dependency detection
31
- * - Lazy loading services
32
- * - Graceful shutdown
33
- * - Plugin startup timeout control
34
- * - Startup failure rollback
35
- * - Plugin health checks
36
- */
37
- export declare class ObjectKernel {
38
- private plugins;
39
- private services;
40
- private hooks;
41
- private state;
42
- private logger;
43
- private context;
44
- private pluginLoader;
45
- private config;
46
- private startedPlugins;
47
- private pluginStartTimes;
48
- private shutdownHandlers;
49
- constructor(config?: ObjectKernelConfig);
50
- /**
51
- * Register a plugin with enhanced validation
52
- */
53
- use(plugin: Plugin): Promise<this>;
54
- /**
55
- * Register a service instance directly
56
- */
57
- registerService<T>(name: string, service: T): this;
58
- /**
59
- * Register a service factory with lifecycle management
60
- */
61
- registerServiceFactory<T>(name: string, factory: ServiceFactory<T>, lifecycle?: ServiceLifecycle, dependencies?: string[]): this;
62
- /**
63
- * Validate Critical System Requirements
64
- */
65
- private validateSystemRequirements;
66
- /**
67
- * Bootstrap the kernel with enhanced features
68
- */
69
- bootstrap(): Promise<void>;
70
- /**
71
- * Graceful shutdown with timeout
72
- */
73
- shutdown(): Promise<void>;
74
- /**
75
- * Check health of a specific plugin
76
- */
77
- checkPluginHealth(pluginName: string): Promise<any>;
78
- /**
79
- * Check health of all plugins
80
- */
81
- checkAllPluginsHealth(): Promise<Map<string, any>>;
82
- /**
83
- * Get plugin startup metrics
84
- */
85
- getPluginMetrics(): Map<string, number>;
86
- /**
87
- * Get a service (sync helper)
88
- */
89
- getService<T>(name: string): T;
90
- /**
91
- * Get a service asynchronously (supports factories)
92
- */
93
- getServiceAsync<T>(name: string, scopeId?: string): Promise<T>;
94
- /**
95
- * Check if kernel is running
96
- */
97
- isRunning(): boolean;
98
- /**
99
- * Get kernel state
100
- */
101
- getState(): string;
102
- private initPluginWithTimeout;
103
- private startPluginWithTimeout;
104
- private rollbackStartedPlugins;
105
- private performShutdown;
106
- private resolveDependencies;
107
- private registerShutdownSignals;
108
- /**
109
- * Register a custom shutdown handler
110
- */
111
- onShutdown(handler: () => Promise<void>): void;
112
- }
113
- //# sourceMappingURL=kernel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../src/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAiB,MAAM,YAAY,CAAC;AAEnD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAgC,gBAAgB,EAAE,cAAc,EAAuB,MAAM,oBAAoB,CAAC;AAGzH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;IAE/B,qDAAqD;IACrD,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAE/B,0CAA0C;IAC1C,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAE3B,gDAAgD;IAChD,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B,kFAAkF;IAClF,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAClC;AAED;;;;;;;;;;;;;;;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