conduithub 0.1.0 → 1.0.1
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.
- package/dist/core/conduit-hub/index.cjs +188 -0
- package/dist/core/conduit-hub/index.d.cts +44 -0
- package/dist/core/conduit-hub/index.d.mts +44 -0
- package/dist/core/conduit-hub/index.d.ts +44 -0
- package/dist/core/conduit-hub/index.mjs +186 -0
- package/dist/core/config-manager/index.cjs +216 -0
- package/dist/core/config-manager/index.d.cts +7 -0
- package/dist/core/config-manager/index.d.mts +7 -0
- package/dist/core/config-manager/index.d.ts +7 -0
- package/dist/core/config-manager/index.mjs +214 -0
- package/dist/core/event-bus/index.cjs +154 -53
- package/dist/core/event-bus/index.d.cts +2 -42
- package/dist/core/event-bus/index.d.mts +2 -42
- package/dist/core/event-bus/index.d.ts +2 -42
- package/dist/core/event-bus/index.mjs +153 -52
- package/dist/core/hook/index.cjs +185 -148
- package/dist/core/hook/index.d.cts +28 -16
- package/dist/core/hook/index.d.mts +28 -16
- package/dist/core/hook/index.d.ts +28 -16
- package/dist/core/hook/index.mjs +183 -146
- package/dist/core/index.cjs +17 -1
- package/dist/core/index.d.cts +184 -3
- package/dist/core/index.d.mts +184 -3
- package/dist/core/index.d.ts +184 -3
- package/dist/core/index.mjs +12 -1
- package/dist/core/plugin/index.cjs +271 -0
- package/dist/core/plugin/index.d.cts +7 -0
- package/dist/core/plugin/index.d.mts +7 -0
- package/dist/core/plugin/index.d.ts +7 -0
- package/dist/core/plugin/index.mjs +268 -0
- package/dist/core/service-container/index.cjs +306 -0
- package/dist/core/service-container/index.d.cts +51 -0
- package/dist/core/service-container/index.d.mts +51 -0
- package/dist/core/service-container/index.d.ts +51 -0
- package/dist/core/service-container/index.mjs +304 -0
- package/dist/core/state-manager/index.cjs +195 -0
- package/dist/core/state-manager/index.d.cts +39 -0
- package/dist/core/state-manager/index.d.mts +39 -0
- package/dist/core/state-manager/index.d.ts +39 -0
- package/dist/core/state-manager/index.mjs +193 -0
- package/dist/error/index.cjs +71 -0
- package/dist/error/index.d.cts +47 -0
- package/dist/error/index.d.mts +47 -0
- package/dist/error/index.d.ts +47 -0
- package/dist/error/index.mjs +65 -0
- package/dist/index.cjs +38 -5
- package/dist/index.d.cts +8 -2
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.mjs +16 -1
- package/dist/plugins/index.cjs +12 -0
- package/dist/plugins/index.d.cts +8 -0
- package/dist/plugins/index.d.mts +8 -0
- package/dist/plugins/index.d.ts +8 -0
- package/dist/plugins/index.mjs +6 -0
- package/dist/plugins/redis/index.cjs +12 -0
- package/dist/plugins/redis/index.d.cts +109 -0
- package/dist/plugins/redis/index.d.mts +109 -0
- package/dist/plugins/redis/index.d.ts +109 -0
- package/dist/plugins/redis/index.mjs +6 -0
- package/dist/shared/conduithub.-bZD30_I.mjs +769 -0
- package/dist/shared/{conduithub.CvMLTa-R.cjs → conduithub.BNQsddJO.cjs} +2 -9
- package/dist/shared/{conduithub.74V0wiLi.mjs → conduithub.BNefRQsK.mjs} +3 -9
- package/dist/shared/conduithub.BZQmkQy7.d.cts +52 -0
- package/dist/shared/conduithub.Bq_7Xj0J.cjs +18 -0
- package/dist/shared/conduithub.BzLwccre.d.mts +52 -0
- package/dist/shared/conduithub.CkOQG3cD.mjs +14 -0
- package/dist/shared/conduithub.CmZo_Vuc.cjs +38 -0
- package/dist/shared/conduithub.DQO1dRnn.cjs +33 -0
- package/dist/shared/conduithub.DQOWQ-Bx.d.ts +52 -0
- package/dist/shared/conduithub.Dlvl2xGE.cjs +76 -0
- package/dist/shared/conduithub.DsOOeNwU.cjs +269 -0
- package/dist/shared/conduithub.DyQQrHW9.mjs +267 -0
- package/dist/shared/conduithub.G7ICpZIy.mjs +36 -0
- package/dist/shared/conduithub.Up0QYVao.mjs +59 -0
- package/dist/shared/conduithub.alPiaJax.mjs +29 -0
- package/dist/shared/conduithub.cvEjE62V.cjs +775 -0
- package/dist/utils/index.cjs +19 -5
- package/dist/utils/index.d.cts +33 -2
- package/dist/utils/index.d.mts +33 -2
- package/dist/utils/index.d.ts +33 -2
- package/dist/utils/index.mjs +8 -1
- package/package.json +55 -7
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const logger = require('../../shared/conduithub.BNQsddJO.cjs');
|
|
4
|
+
require('process');
|
|
5
|
+
require('readline');
|
|
6
|
+
require('uuid');
|
|
7
|
+
const core_configManager_index = require('../config-manager/index.cjs');
|
|
8
|
+
const core_eventBus_index = require('../event-bus/index.cjs');
|
|
9
|
+
const core_hook_index = require('../hook/index.cjs');
|
|
10
|
+
const manager = require('../../shared/conduithub.DsOOeNwU.cjs');
|
|
11
|
+
const core_serviceContainer_index = require('../service-container/index.cjs');
|
|
12
|
+
const core_stateManager_index = require('../state-manager/index.cjs');
|
|
13
|
+
require('../../shared/conduithub.CmZo_Vuc.cjs');
|
|
14
|
+
require('../../shared/conduithub.DQO1dRnn.cjs');
|
|
15
|
+
require('../../error/index.cjs');
|
|
16
|
+
require('../../shared/conduithub.Bq_7Xj0J.cjs');
|
|
17
|
+
|
|
18
|
+
class ConduitHub {
|
|
19
|
+
static instance;
|
|
20
|
+
pluginManager;
|
|
21
|
+
eventBus;
|
|
22
|
+
hookSystem;
|
|
23
|
+
stateManager;
|
|
24
|
+
serviceContainer;
|
|
25
|
+
configManager;
|
|
26
|
+
_isInitialized = false;
|
|
27
|
+
constructor() {
|
|
28
|
+
this.eventBus = new core_eventBus_index.EventBus();
|
|
29
|
+
this.hookSystem = new core_hook_index.Hook();
|
|
30
|
+
this.stateManager = new core_stateManager_index.StateManager();
|
|
31
|
+
this.serviceContainer = new core_serviceContainer_index.ServiceContainer();
|
|
32
|
+
this.configManager = new core_configManager_index.ConfigManager();
|
|
33
|
+
const pluginLogger = {
|
|
34
|
+
log: (level, message, ...args) => {
|
|
35
|
+
logger.logger[level](message, ...args);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
this.pluginManager = new manager.PluginManager(
|
|
39
|
+
this.eventBus,
|
|
40
|
+
pluginLogger,
|
|
41
|
+
this.serviceContainer,
|
|
42
|
+
this.stateManager,
|
|
43
|
+
this.hookSystem,
|
|
44
|
+
this.configManager
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
static getInstance() {
|
|
48
|
+
if (!ConduitHub.instance) {
|
|
49
|
+
ConduitHub.instance = new ConduitHub();
|
|
50
|
+
}
|
|
51
|
+
return ConduitHub.instance;
|
|
52
|
+
}
|
|
53
|
+
get isInitialized() {
|
|
54
|
+
return this._isInitialized;
|
|
55
|
+
}
|
|
56
|
+
async initialize(config) {
|
|
57
|
+
if (this._isInitialized) {
|
|
58
|
+
logger.logger.info("ConduitHub is already initialized");
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
try {
|
|
62
|
+
await this.eventBus.initialize();
|
|
63
|
+
await this.hookSystem.initialize();
|
|
64
|
+
await this.serviceContainer.initialize();
|
|
65
|
+
await this.stateManager.initialize();
|
|
66
|
+
await this.configManager.initialize(
|
|
67
|
+
config ?? {}
|
|
68
|
+
);
|
|
69
|
+
this.registerCoreServices();
|
|
70
|
+
this._isInitialized = true;
|
|
71
|
+
logger.logger.success("ConduitHub initialized successfully");
|
|
72
|
+
await this.eventBus.emit("conduithub:initialized", {
|
|
73
|
+
timestamp: Date.now()
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
logger.logger.error("Failed to initialize ConduitHub", error);
|
|
77
|
+
throw error;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async shutdown() {
|
|
81
|
+
if (!this._isInitialized) {
|
|
82
|
+
logger.logger.warn("ConduitHub is not initialized");
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
logger.logger.info("Shutting down ConduitHub...");
|
|
87
|
+
await this.pluginManager.shutdownAll();
|
|
88
|
+
await this.eventBus.shutdown();
|
|
89
|
+
await this.hookSystem.shutdown();
|
|
90
|
+
await this.serviceContainer.shutdown();
|
|
91
|
+
await this.stateManager.shutdown();
|
|
92
|
+
await this.configManager.shutdown();
|
|
93
|
+
this._isInitialized = false;
|
|
94
|
+
logger.logger.success("ConduitHub shutdown successfully");
|
|
95
|
+
} catch (error) {
|
|
96
|
+
logger.logger.error("Failed to shutdown ConduitHub", error);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
getPluginManager() {
|
|
101
|
+
return this.pluginManager;
|
|
102
|
+
}
|
|
103
|
+
getEventBus() {
|
|
104
|
+
return this.eventBus;
|
|
105
|
+
}
|
|
106
|
+
getLogger() {
|
|
107
|
+
return logger.logger;
|
|
108
|
+
}
|
|
109
|
+
getServiceContainer() {
|
|
110
|
+
return this.serviceContainer;
|
|
111
|
+
}
|
|
112
|
+
getStateManager() {
|
|
113
|
+
return this.stateManager;
|
|
114
|
+
}
|
|
115
|
+
getHookSystem() {
|
|
116
|
+
return this.hookSystem;
|
|
117
|
+
}
|
|
118
|
+
getConfigManager() {
|
|
119
|
+
return this.configManager;
|
|
120
|
+
}
|
|
121
|
+
registerCoreServices() {
|
|
122
|
+
this.serviceContainer.register("logger", () => logger.logger, true);
|
|
123
|
+
this.serviceContainer.register("eventBus", () => this.eventBus, true);
|
|
124
|
+
this.serviceContainer.register(
|
|
125
|
+
"serviceContainer",
|
|
126
|
+
() => this.serviceContainer,
|
|
127
|
+
true
|
|
128
|
+
);
|
|
129
|
+
this.serviceContainer.register(
|
|
130
|
+
"stateManager",
|
|
131
|
+
() => this.stateManager,
|
|
132
|
+
true
|
|
133
|
+
);
|
|
134
|
+
this.serviceContainer.register("hookSystem", () => this.hookSystem, true);
|
|
135
|
+
this.serviceContainer.register(
|
|
136
|
+
"configManager",
|
|
137
|
+
() => this.configManager,
|
|
138
|
+
true
|
|
139
|
+
);
|
|
140
|
+
this.serviceContainer.register(
|
|
141
|
+
"pluginManager",
|
|
142
|
+
() => this.pluginManager,
|
|
143
|
+
true
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
async registerPlugin(plugin, config) {
|
|
147
|
+
if (!this.isInitialized) {
|
|
148
|
+
throw new Error(
|
|
149
|
+
"ConduitHub must be initialized before registering plugins"
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
await this.pluginManager.registerPlugin(plugin, config);
|
|
153
|
+
}
|
|
154
|
+
async unregisterPlugin(pluginName) {
|
|
155
|
+
if (!this.isInitialized) {
|
|
156
|
+
throw new Error(
|
|
157
|
+
"ConduitHub must be initialized before unregistering plugins"
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
await this.pluginManager.unregisterPlugin(pluginName);
|
|
161
|
+
}
|
|
162
|
+
async startPlugin(pluginName) {
|
|
163
|
+
if (!this.isInitialized) {
|
|
164
|
+
throw new Error("ConduitHub must be initialized before starting plugins");
|
|
165
|
+
}
|
|
166
|
+
await this.pluginManager.startPlugin(pluginName);
|
|
167
|
+
}
|
|
168
|
+
async stopPlugin(pluginName) {
|
|
169
|
+
if (!this.isInitialized) {
|
|
170
|
+
throw new Error("ConduitHub must be initialized before stopping plugins");
|
|
171
|
+
}
|
|
172
|
+
await this.pluginManager.stopPlugin(pluginName);
|
|
173
|
+
}
|
|
174
|
+
isPluginRegistered(pluginName) {
|
|
175
|
+
return this.pluginManager.isPluginRegistered(pluginName);
|
|
176
|
+
}
|
|
177
|
+
isPluginRunning(pluginName) {
|
|
178
|
+
return this.pluginManager.isPluginRunning(pluginName);
|
|
179
|
+
}
|
|
180
|
+
getPluginStatus(pluginName) {
|
|
181
|
+
return this.pluginManager.getPluginStatus(pluginName);
|
|
182
|
+
}
|
|
183
|
+
listPlugins() {
|
|
184
|
+
return this.pluginManager.listPlugins();
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
exports.ConduitHub = ConduitHub;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { c as createLogger } from '../../shared/conduithub.B7aryjPG.cjs';
|
|
2
|
+
import { PluginManager, ConfigManager, BasePlugin, PluginConfig, PluginStatus } from '../index.cjs';
|
|
3
|
+
import { E as EventBus } from '../../shared/conduithub.BZQmkQy7.cjs';
|
|
4
|
+
import { Hook } from '../hook/index.cjs';
|
|
5
|
+
import { ServiceContainer } from '../service-container/index.cjs';
|
|
6
|
+
import { StateManager } from '../state-manager/index.cjs';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
declare class ConduitHub {
|
|
10
|
+
private static instance;
|
|
11
|
+
private pluginManager;
|
|
12
|
+
private eventBus;
|
|
13
|
+
private hookSystem;
|
|
14
|
+
private stateManager;
|
|
15
|
+
private serviceContainer;
|
|
16
|
+
private configManager;
|
|
17
|
+
private _isInitialized;
|
|
18
|
+
constructor();
|
|
19
|
+
static getInstance(): ConduitHub;
|
|
20
|
+
get isInitialized(): boolean;
|
|
21
|
+
initialize(config?: unknown): Promise<void>;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
23
|
+
getPluginManager(): PluginManager;
|
|
24
|
+
getEventBus(): EventBus<Record<string, unknown>>;
|
|
25
|
+
getLogger(): ReturnType<typeof createLogger>;
|
|
26
|
+
getServiceContainer(): ServiceContainer;
|
|
27
|
+
getStateManager(): StateManager;
|
|
28
|
+
getHookSystem(): Hook<Record<string, {
|
|
29
|
+
input: unknown;
|
|
30
|
+
output: unknown;
|
|
31
|
+
}>>;
|
|
32
|
+
getConfigManager(): ConfigManager;
|
|
33
|
+
private registerCoreServices;
|
|
34
|
+
registerPlugin(plugin: BasePlugin, config?: PluginConfig): Promise<void>;
|
|
35
|
+
unregisterPlugin(pluginName: string): Promise<void>;
|
|
36
|
+
startPlugin(pluginName: string): Promise<void>;
|
|
37
|
+
stopPlugin(pluginName: string): Promise<void>;
|
|
38
|
+
isPluginRegistered(pluginName: string): boolean;
|
|
39
|
+
isPluginRunning(pluginName: string): boolean;
|
|
40
|
+
getPluginStatus(pluginName: string): PluginStatus | undefined;
|
|
41
|
+
listPlugins(): string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { ConduitHub };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { c as createLogger } from '../../shared/conduithub.B7aryjPG.mjs';
|
|
2
|
+
import { PluginManager, ConfigManager, BasePlugin, PluginConfig, PluginStatus } from '../index.mjs';
|
|
3
|
+
import { E as EventBus } from '../../shared/conduithub.BzLwccre.mjs';
|
|
4
|
+
import { Hook } from '../hook/index.mjs';
|
|
5
|
+
import { ServiceContainer } from '../service-container/index.mjs';
|
|
6
|
+
import { StateManager } from '../state-manager/index.mjs';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
declare class ConduitHub {
|
|
10
|
+
private static instance;
|
|
11
|
+
private pluginManager;
|
|
12
|
+
private eventBus;
|
|
13
|
+
private hookSystem;
|
|
14
|
+
private stateManager;
|
|
15
|
+
private serviceContainer;
|
|
16
|
+
private configManager;
|
|
17
|
+
private _isInitialized;
|
|
18
|
+
constructor();
|
|
19
|
+
static getInstance(): ConduitHub;
|
|
20
|
+
get isInitialized(): boolean;
|
|
21
|
+
initialize(config?: unknown): Promise<void>;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
23
|
+
getPluginManager(): PluginManager;
|
|
24
|
+
getEventBus(): EventBus<Record<string, unknown>>;
|
|
25
|
+
getLogger(): ReturnType<typeof createLogger>;
|
|
26
|
+
getServiceContainer(): ServiceContainer;
|
|
27
|
+
getStateManager(): StateManager;
|
|
28
|
+
getHookSystem(): Hook<Record<string, {
|
|
29
|
+
input: unknown;
|
|
30
|
+
output: unknown;
|
|
31
|
+
}>>;
|
|
32
|
+
getConfigManager(): ConfigManager;
|
|
33
|
+
private registerCoreServices;
|
|
34
|
+
registerPlugin(plugin: BasePlugin, config?: PluginConfig): Promise<void>;
|
|
35
|
+
unregisterPlugin(pluginName: string): Promise<void>;
|
|
36
|
+
startPlugin(pluginName: string): Promise<void>;
|
|
37
|
+
stopPlugin(pluginName: string): Promise<void>;
|
|
38
|
+
isPluginRegistered(pluginName: string): boolean;
|
|
39
|
+
isPluginRunning(pluginName: string): boolean;
|
|
40
|
+
getPluginStatus(pluginName: string): PluginStatus | undefined;
|
|
41
|
+
listPlugins(): string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { ConduitHub };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { c as createLogger } from '../../shared/conduithub.B7aryjPG.js';
|
|
2
|
+
import { PluginManager, ConfigManager, BasePlugin, PluginConfig, PluginStatus } from '../index.js';
|
|
3
|
+
import { E as EventBus } from '../../shared/conduithub.DQOWQ-Bx.js';
|
|
4
|
+
import { Hook } from '../hook/index.js';
|
|
5
|
+
import { ServiceContainer } from '../service-container/index.js';
|
|
6
|
+
import { StateManager } from '../state-manager/index.js';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
declare class ConduitHub {
|
|
10
|
+
private static instance;
|
|
11
|
+
private pluginManager;
|
|
12
|
+
private eventBus;
|
|
13
|
+
private hookSystem;
|
|
14
|
+
private stateManager;
|
|
15
|
+
private serviceContainer;
|
|
16
|
+
private configManager;
|
|
17
|
+
private _isInitialized;
|
|
18
|
+
constructor();
|
|
19
|
+
static getInstance(): ConduitHub;
|
|
20
|
+
get isInitialized(): boolean;
|
|
21
|
+
initialize(config?: unknown): Promise<void>;
|
|
22
|
+
shutdown(): Promise<void>;
|
|
23
|
+
getPluginManager(): PluginManager;
|
|
24
|
+
getEventBus(): EventBus<Record<string, unknown>>;
|
|
25
|
+
getLogger(): ReturnType<typeof createLogger>;
|
|
26
|
+
getServiceContainer(): ServiceContainer;
|
|
27
|
+
getStateManager(): StateManager;
|
|
28
|
+
getHookSystem(): Hook<Record<string, {
|
|
29
|
+
input: unknown;
|
|
30
|
+
output: unknown;
|
|
31
|
+
}>>;
|
|
32
|
+
getConfigManager(): ConfigManager;
|
|
33
|
+
private registerCoreServices;
|
|
34
|
+
registerPlugin(plugin: BasePlugin, config?: PluginConfig): Promise<void>;
|
|
35
|
+
unregisterPlugin(pluginName: string): Promise<void>;
|
|
36
|
+
startPlugin(pluginName: string): Promise<void>;
|
|
37
|
+
stopPlugin(pluginName: string): Promise<void>;
|
|
38
|
+
isPluginRegistered(pluginName: string): boolean;
|
|
39
|
+
isPluginRunning(pluginName: string): boolean;
|
|
40
|
+
getPluginStatus(pluginName: string): PluginStatus | undefined;
|
|
41
|
+
listPlugins(): string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { ConduitHub };
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { a as logger } from '../../shared/conduithub.BNefRQsK.mjs';
|
|
2
|
+
import 'process';
|
|
3
|
+
import 'readline';
|
|
4
|
+
import 'uuid';
|
|
5
|
+
import { ConfigManager } from '../config-manager/index.mjs';
|
|
6
|
+
import { EventBus } from '../event-bus/index.mjs';
|
|
7
|
+
import { Hook } from '../hook/index.mjs';
|
|
8
|
+
import { P as PluginManager } from '../../shared/conduithub.DyQQrHW9.mjs';
|
|
9
|
+
import { ServiceContainer } from '../service-container/index.mjs';
|
|
10
|
+
import { StateManager } from '../state-manager/index.mjs';
|
|
11
|
+
import '../../shared/conduithub.G7ICpZIy.mjs';
|
|
12
|
+
import '../../shared/conduithub.alPiaJax.mjs';
|
|
13
|
+
import '../../error/index.mjs';
|
|
14
|
+
import '../../shared/conduithub.CkOQG3cD.mjs';
|
|
15
|
+
|
|
16
|
+
class ConduitHub {
|
|
17
|
+
static instance;
|
|
18
|
+
pluginManager;
|
|
19
|
+
eventBus;
|
|
20
|
+
hookSystem;
|
|
21
|
+
stateManager;
|
|
22
|
+
serviceContainer;
|
|
23
|
+
configManager;
|
|
24
|
+
_isInitialized = false;
|
|
25
|
+
constructor() {
|
|
26
|
+
this.eventBus = new EventBus();
|
|
27
|
+
this.hookSystem = new Hook();
|
|
28
|
+
this.stateManager = new StateManager();
|
|
29
|
+
this.serviceContainer = new ServiceContainer();
|
|
30
|
+
this.configManager = new ConfigManager();
|
|
31
|
+
const pluginLogger = {
|
|
32
|
+
log: (level, message, ...args) => {
|
|
33
|
+
logger[level](message, ...args);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
this.pluginManager = new PluginManager(
|
|
37
|
+
this.eventBus,
|
|
38
|
+
pluginLogger,
|
|
39
|
+
this.serviceContainer,
|
|
40
|
+
this.stateManager,
|
|
41
|
+
this.hookSystem,
|
|
42
|
+
this.configManager
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
static getInstance() {
|
|
46
|
+
if (!ConduitHub.instance) {
|
|
47
|
+
ConduitHub.instance = new ConduitHub();
|
|
48
|
+
}
|
|
49
|
+
return ConduitHub.instance;
|
|
50
|
+
}
|
|
51
|
+
get isInitialized() {
|
|
52
|
+
return this._isInitialized;
|
|
53
|
+
}
|
|
54
|
+
async initialize(config) {
|
|
55
|
+
if (this._isInitialized) {
|
|
56
|
+
logger.info("ConduitHub is already initialized");
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
try {
|
|
60
|
+
await this.eventBus.initialize();
|
|
61
|
+
await this.hookSystem.initialize();
|
|
62
|
+
await this.serviceContainer.initialize();
|
|
63
|
+
await this.stateManager.initialize();
|
|
64
|
+
await this.configManager.initialize(
|
|
65
|
+
config ?? {}
|
|
66
|
+
);
|
|
67
|
+
this.registerCoreServices();
|
|
68
|
+
this._isInitialized = true;
|
|
69
|
+
logger.success("ConduitHub initialized successfully");
|
|
70
|
+
await this.eventBus.emit("conduithub:initialized", {
|
|
71
|
+
timestamp: Date.now()
|
|
72
|
+
});
|
|
73
|
+
} catch (error) {
|
|
74
|
+
logger.error("Failed to initialize ConduitHub", error);
|
|
75
|
+
throw error;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async shutdown() {
|
|
79
|
+
if (!this._isInitialized) {
|
|
80
|
+
logger.warn("ConduitHub is not initialized");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
logger.info("Shutting down ConduitHub...");
|
|
85
|
+
await this.pluginManager.shutdownAll();
|
|
86
|
+
await this.eventBus.shutdown();
|
|
87
|
+
await this.hookSystem.shutdown();
|
|
88
|
+
await this.serviceContainer.shutdown();
|
|
89
|
+
await this.stateManager.shutdown();
|
|
90
|
+
await this.configManager.shutdown();
|
|
91
|
+
this._isInitialized = false;
|
|
92
|
+
logger.success("ConduitHub shutdown successfully");
|
|
93
|
+
} catch (error) {
|
|
94
|
+
logger.error("Failed to shutdown ConduitHub", error);
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
getPluginManager() {
|
|
99
|
+
return this.pluginManager;
|
|
100
|
+
}
|
|
101
|
+
getEventBus() {
|
|
102
|
+
return this.eventBus;
|
|
103
|
+
}
|
|
104
|
+
getLogger() {
|
|
105
|
+
return logger;
|
|
106
|
+
}
|
|
107
|
+
getServiceContainer() {
|
|
108
|
+
return this.serviceContainer;
|
|
109
|
+
}
|
|
110
|
+
getStateManager() {
|
|
111
|
+
return this.stateManager;
|
|
112
|
+
}
|
|
113
|
+
getHookSystem() {
|
|
114
|
+
return this.hookSystem;
|
|
115
|
+
}
|
|
116
|
+
getConfigManager() {
|
|
117
|
+
return this.configManager;
|
|
118
|
+
}
|
|
119
|
+
registerCoreServices() {
|
|
120
|
+
this.serviceContainer.register("logger", () => logger, true);
|
|
121
|
+
this.serviceContainer.register("eventBus", () => this.eventBus, true);
|
|
122
|
+
this.serviceContainer.register(
|
|
123
|
+
"serviceContainer",
|
|
124
|
+
() => this.serviceContainer,
|
|
125
|
+
true
|
|
126
|
+
);
|
|
127
|
+
this.serviceContainer.register(
|
|
128
|
+
"stateManager",
|
|
129
|
+
() => this.stateManager,
|
|
130
|
+
true
|
|
131
|
+
);
|
|
132
|
+
this.serviceContainer.register("hookSystem", () => this.hookSystem, true);
|
|
133
|
+
this.serviceContainer.register(
|
|
134
|
+
"configManager",
|
|
135
|
+
() => this.configManager,
|
|
136
|
+
true
|
|
137
|
+
);
|
|
138
|
+
this.serviceContainer.register(
|
|
139
|
+
"pluginManager",
|
|
140
|
+
() => this.pluginManager,
|
|
141
|
+
true
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
async registerPlugin(plugin, config) {
|
|
145
|
+
if (!this.isInitialized) {
|
|
146
|
+
throw new Error(
|
|
147
|
+
"ConduitHub must be initialized before registering plugins"
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
await this.pluginManager.registerPlugin(plugin, config);
|
|
151
|
+
}
|
|
152
|
+
async unregisterPlugin(pluginName) {
|
|
153
|
+
if (!this.isInitialized) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
"ConduitHub must be initialized before unregistering plugins"
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
await this.pluginManager.unregisterPlugin(pluginName);
|
|
159
|
+
}
|
|
160
|
+
async startPlugin(pluginName) {
|
|
161
|
+
if (!this.isInitialized) {
|
|
162
|
+
throw new Error("ConduitHub must be initialized before starting plugins");
|
|
163
|
+
}
|
|
164
|
+
await this.pluginManager.startPlugin(pluginName);
|
|
165
|
+
}
|
|
166
|
+
async stopPlugin(pluginName) {
|
|
167
|
+
if (!this.isInitialized) {
|
|
168
|
+
throw new Error("ConduitHub must be initialized before stopping plugins");
|
|
169
|
+
}
|
|
170
|
+
await this.pluginManager.stopPlugin(pluginName);
|
|
171
|
+
}
|
|
172
|
+
isPluginRegistered(pluginName) {
|
|
173
|
+
return this.pluginManager.isPluginRegistered(pluginName);
|
|
174
|
+
}
|
|
175
|
+
isPluginRunning(pluginName) {
|
|
176
|
+
return this.pluginManager.isPluginRunning(pluginName);
|
|
177
|
+
}
|
|
178
|
+
getPluginStatus(pluginName) {
|
|
179
|
+
return this.pluginManager.getPluginStatus(pluginName);
|
|
180
|
+
}
|
|
181
|
+
listPlugins() {
|
|
182
|
+
return this.pluginManager.listPlugins();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export { ConduitHub };
|