conduithub 0.1.0 → 1.0.0

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 (68) hide show
  1. package/dist/core/conduit-hub/index.cjs +188 -0
  2. package/dist/core/conduit-hub/index.d.cts +44 -0
  3. package/dist/core/conduit-hub/index.d.mts +44 -0
  4. package/dist/core/conduit-hub/index.d.ts +44 -0
  5. package/dist/core/conduit-hub/index.mjs +186 -0
  6. package/dist/core/config-manager/index.cjs +216 -0
  7. package/dist/core/config-manager/index.d.cts +7 -0
  8. package/dist/core/config-manager/index.d.mts +7 -0
  9. package/dist/core/config-manager/index.d.ts +7 -0
  10. package/dist/core/config-manager/index.mjs +214 -0
  11. package/dist/core/event-bus/index.cjs +154 -53
  12. package/dist/core/event-bus/index.d.cts +2 -42
  13. package/dist/core/event-bus/index.d.mts +2 -42
  14. package/dist/core/event-bus/index.d.ts +2 -42
  15. package/dist/core/event-bus/index.mjs +153 -52
  16. package/dist/core/hook/index.cjs +185 -148
  17. package/dist/core/hook/index.d.cts +28 -16
  18. package/dist/core/hook/index.d.mts +28 -16
  19. package/dist/core/hook/index.d.ts +28 -16
  20. package/dist/core/hook/index.mjs +183 -146
  21. package/dist/core/index.cjs +17 -1
  22. package/dist/core/index.d.cts +184 -3
  23. package/dist/core/index.d.mts +184 -3
  24. package/dist/core/index.d.ts +184 -3
  25. package/dist/core/index.mjs +12 -1
  26. package/dist/core/plugin/index.cjs +271 -0
  27. package/dist/core/plugin/index.d.cts +7 -0
  28. package/dist/core/plugin/index.d.mts +7 -0
  29. package/dist/core/plugin/index.d.ts +7 -0
  30. package/dist/core/plugin/index.mjs +268 -0
  31. package/dist/core/service-container/index.cjs +306 -0
  32. package/dist/core/service-container/index.d.cts +51 -0
  33. package/dist/core/service-container/index.d.mts +51 -0
  34. package/dist/core/service-container/index.d.ts +51 -0
  35. package/dist/core/service-container/index.mjs +304 -0
  36. package/dist/core/state-manager/index.cjs +195 -0
  37. package/dist/core/state-manager/index.d.cts +39 -0
  38. package/dist/core/state-manager/index.d.mts +39 -0
  39. package/dist/core/state-manager/index.d.ts +39 -0
  40. package/dist/core/state-manager/index.mjs +193 -0
  41. package/dist/index.cjs +34 -5
  42. package/dist/index.d.cts +54 -2
  43. package/dist/index.d.mts +54 -2
  44. package/dist/index.d.ts +54 -2
  45. package/dist/index.mjs +13 -1
  46. package/dist/shared/conduithub.BDwZXllF.mjs +63 -0
  47. package/dist/shared/{conduithub.CvMLTa-R.cjs → conduithub.BNQsddJO.cjs} +2 -9
  48. package/dist/shared/{conduithub.74V0wiLi.mjs → conduithub.BNefRQsK.mjs} +3 -9
  49. package/dist/shared/conduithub.BZQmkQy7.d.cts +52 -0
  50. package/dist/shared/conduithub.BqUYv04j.cjs +68 -0
  51. package/dist/shared/conduithub.Bq_7Xj0J.cjs +18 -0
  52. package/dist/shared/conduithub.BzLwccre.d.mts +52 -0
  53. package/dist/shared/conduithub.CkOQG3cD.mjs +14 -0
  54. package/dist/shared/conduithub.CmZo_Vuc.cjs +38 -0
  55. package/dist/shared/conduithub.DQO1dRnn.cjs +33 -0
  56. package/dist/shared/conduithub.DQOWQ-Bx.d.ts +52 -0
  57. package/dist/shared/conduithub.DsOOeNwU.cjs +269 -0
  58. package/dist/shared/conduithub.DyQQrHW9.mjs +267 -0
  59. package/dist/shared/conduithub.G7ICpZIy.mjs +36 -0
  60. package/dist/shared/conduithub.alPiaJax.mjs +29 -0
  61. package/dist/shared/conduithub.bsiNMTVD.mjs +59 -0
  62. package/dist/shared/conduithub.gF2DFc43.cjs +76 -0
  63. package/dist/utils/index.cjs +18 -5
  64. package/dist/utils/index.d.cts +33 -2
  65. package/dist/utils/index.d.mts +33 -2
  66. package/dist/utils/index.d.ts +33 -2
  67. package/dist/utils/index.mjs +7 -1
  68. package/package.json +55 -7
@@ -0,0 +1,216 @@
1
+ 'use strict';
2
+
3
+ const code = require('../../shared/conduithub.CmZo_Vuc.cjs');
4
+ const json = require('../../shared/conduithub.DQO1dRnn.cjs');
5
+ const logger = require('../../shared/conduithub.BNQsddJO.cjs');
6
+ require('process');
7
+ require('readline');
8
+ require('uuid');
9
+
10
+ class ConfigManager {
11
+ config = /* @__PURE__ */ new Map();
12
+ pluginConfigs = /* @__PURE__ */ new Map();
13
+ isInitialized = false;
14
+ async initialize(config) {
15
+ if (this.isInitialized) return;
16
+ logger.logger.info("Initializing ConfigManager....");
17
+ this.isInitialized = true;
18
+ if (config) {
19
+ this.loadConfig(config);
20
+ }
21
+ logger.logger.success("ConfigManager initialized successfully");
22
+ }
23
+ async shutdown() {
24
+ if (!this.isInitialized) {
25
+ return;
26
+ }
27
+ this.config.clear();
28
+ this.pluginConfigs.clear();
29
+ this.isInitialized = false;
30
+ logger.logger.success("ConfigManager shutdown successfully");
31
+ }
32
+ get(key, defaultValue) {
33
+ if (!this.isInitialized) {
34
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
35
+ }
36
+ return this.config.has(key) ? this.config.get(key) : defaultValue;
37
+ }
38
+ set(key, value) {
39
+ if (!this.isInitialized) {
40
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
41
+ }
42
+ this.config.set(key, value);
43
+ logger.logger.success(`Configuration set successfully for key: ${key}`);
44
+ }
45
+ has(key) {
46
+ if (!this.isInitialized) {
47
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
48
+ }
49
+ return this.config.has(key);
50
+ }
51
+ delete(key) {
52
+ if (!this.isInitialized) {
53
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
54
+ }
55
+ return this.config.delete(key);
56
+ }
57
+ loadConfig(config) {
58
+ if (!this.isInitialized) {
59
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
60
+ }
61
+ for (const [key, value] of Object.entries(config)) {
62
+ this.config.set(key, value);
63
+ }
64
+ logger.logger.success("Configuration loaded successfully");
65
+ }
66
+ clearConfig() {
67
+ if (!this.isInitialized) {
68
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
69
+ }
70
+ this.config.clear();
71
+ logger.logger.success("Configuration cleared successfully");
72
+ }
73
+ getPluginConfig(pluginName) {
74
+ if (!this.isInitialized) {
75
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
76
+ }
77
+ let config = this.pluginConfigs.get(pluginName);
78
+ if (!config) {
79
+ config = {
80
+ name: pluginName,
81
+ version: "1.0.0",
82
+ enabled: true,
83
+ dependencies: [],
84
+ config: {}
85
+ };
86
+ this.pluginConfigs.set(pluginName, config);
87
+ }
88
+ return config;
89
+ }
90
+ setPluginConfig(pluginName, config) {
91
+ if (!this.isInitialized) {
92
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
93
+ }
94
+ this.pluginConfigs.set(pluginName, config);
95
+ logger.logger.success(`Plugin config set successfully for plugin: ${pluginName}`);
96
+ }
97
+ updatePluginConfig(pluginName, updates) {
98
+ if (!this.isInitialized) {
99
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
100
+ }
101
+ const currentConfig = this.pluginConfigs.get(pluginName);
102
+ if (!currentConfig) {
103
+ throw new Error(`Plugin config not found for plugin: ${pluginName}`);
104
+ }
105
+ const updatedConfig = { ...currentConfig, ...updates };
106
+ this.pluginConfigs.set(pluginName, updatedConfig);
107
+ logger.logger.success(
108
+ `Plugin config updated successfully for plugin: ${pluginName}`
109
+ );
110
+ }
111
+ hasPluginConfig(pluginName) {
112
+ if (!this.isInitialized) {
113
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
114
+ }
115
+ return this.pluginConfigs.has(pluginName);
116
+ }
117
+ deletePluginConfig(pluginName) {
118
+ if (!this.isInitialized) {
119
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
120
+ }
121
+ const deleted = this.pluginConfigs.delete(pluginName);
122
+ if (deleted) {
123
+ logger.logger.success(
124
+ `Plugin config deleted successfully for plugin: ${pluginName}`
125
+ );
126
+ }
127
+ return deleted;
128
+ }
129
+ getAllPluginConfigs() {
130
+ if (!this.isInitialized) {
131
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
132
+ }
133
+ return Object.fromEntries(this.pluginConfigs);
134
+ }
135
+ loadPluginConfigs(configs) {
136
+ if (!this.isInitialized) {
137
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
138
+ }
139
+ for (const [pluginName, config] of Object.entries(configs)) {
140
+ this.pluginConfigs.set(pluginName, config);
141
+ }
142
+ logger.logger.success("Plugin configs loaded successfully");
143
+ }
144
+ validateConfig(schema, config) {
145
+ const result = schema.safeParse(config);
146
+ if (result.success) {
147
+ return { valid: true, errors: [] };
148
+ }
149
+ const errors = result.error.issues.map((issue) => {
150
+ const path = issue.path.join(".");
151
+ return path ? `${path}: ${issue.message}` : issue.message;
152
+ });
153
+ return { valid: false, errors };
154
+ }
155
+ exportConfig(format = "json") {
156
+ if (!this.isInitialized) {
157
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
158
+ }
159
+ const fullConfig = {
160
+ global: Object.fromEntries(this.config),
161
+ plugins: this.getAllPluginConfigs()
162
+ };
163
+ if (format === "json") {
164
+ return JSON.stringify(fullConfig, null, 2);
165
+ }
166
+ throw new Error(`Unsupported format: ${format}`);
167
+ }
168
+ importConfig(configJson) {
169
+ if (!this.isInitialized) {
170
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
171
+ }
172
+ try {
173
+ const fullConfig = json.parseJson(configJson);
174
+ if (fullConfig.global) {
175
+ this.loadConfig(fullConfig.global);
176
+ }
177
+ if (fullConfig.plugins) {
178
+ this.loadPluginConfigs(fullConfig.plugins);
179
+ }
180
+ logger.logger.success("Configuration imported successfully");
181
+ } catch (error) {
182
+ logger.logger.error("Failed to import configuration", error);
183
+ throw error;
184
+ }
185
+ }
186
+ getPluginConfigNames() {
187
+ if (!this.isInitialized) {
188
+ throw new Error("ConfigManager is not initialized");
189
+ }
190
+ return Array.from(this.pluginConfigs.keys());
191
+ }
192
+ getStats() {
193
+ return {
194
+ totalConfigKeys: this.config.size,
195
+ totalPluginConfigs: this.pluginConfigs.size,
196
+ configKeys: Array.from(this.config.keys()),
197
+ pluginConfigNames: this.getPluginConfigNames()
198
+ };
199
+ }
200
+ watchConfig(key, callback) {
201
+ if (!this.isInitialized) {
202
+ throw new Error(code.ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
203
+ }
204
+ const checkInterval = setInterval(() => {
205
+ const value = this.get(key);
206
+ callback(value);
207
+ }, 1e3);
208
+ logger.logger.info(`Configuration watch started for key: ${key}`);
209
+ return () => {
210
+ clearInterval(checkInterval);
211
+ logger.logger.info(`Configuration watch stopped for key: ${key}`);
212
+ };
213
+ }
214
+ }
215
+
216
+ exports.ConfigManager = ConfigManager;
@@ -0,0 +1,7 @@
1
+ import 'zod';
2
+ export { ConfigManager } from '../index.cjs';
3
+ import '../hook/index.cjs';
4
+ import '../../shared/conduithub.B7aryjPG.cjs';
5
+ import '../../shared/conduithub.BZQmkQy7.cjs';
6
+ import '../service-container/index.cjs';
7
+ import '../state-manager/index.cjs';
@@ -0,0 +1,7 @@
1
+ import 'zod';
2
+ export { ConfigManager } from '../index.mjs';
3
+ import '../hook/index.mjs';
4
+ import '../../shared/conduithub.B7aryjPG.mjs';
5
+ import '../../shared/conduithub.BzLwccre.mjs';
6
+ import '../service-container/index.mjs';
7
+ import '../state-manager/index.mjs';
@@ -0,0 +1,7 @@
1
+ import 'zod';
2
+ export { ConfigManager } from '../index.js';
3
+ import '../hook/index.js';
4
+ import '../../shared/conduithub.B7aryjPG.js';
5
+ import '../../shared/conduithub.DQOWQ-Bx.js';
6
+ import '../service-container/index.js';
7
+ import '../state-manager/index.js';
@@ -0,0 +1,214 @@
1
+ import { E as ERROR_CODE } from '../../shared/conduithub.G7ICpZIy.mjs';
2
+ import { p as parseJson } from '../../shared/conduithub.alPiaJax.mjs';
3
+ import { a as logger } from '../../shared/conduithub.BNefRQsK.mjs';
4
+ import 'process';
5
+ import 'readline';
6
+ import 'uuid';
7
+
8
+ class ConfigManager {
9
+ config = /* @__PURE__ */ new Map();
10
+ pluginConfigs = /* @__PURE__ */ new Map();
11
+ isInitialized = false;
12
+ async initialize(config) {
13
+ if (this.isInitialized) return;
14
+ logger.info("Initializing ConfigManager....");
15
+ this.isInitialized = true;
16
+ if (config) {
17
+ this.loadConfig(config);
18
+ }
19
+ logger.success("ConfigManager initialized successfully");
20
+ }
21
+ async shutdown() {
22
+ if (!this.isInitialized) {
23
+ return;
24
+ }
25
+ this.config.clear();
26
+ this.pluginConfigs.clear();
27
+ this.isInitialized = false;
28
+ logger.success("ConfigManager shutdown successfully");
29
+ }
30
+ get(key, defaultValue) {
31
+ if (!this.isInitialized) {
32
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
33
+ }
34
+ return this.config.has(key) ? this.config.get(key) : defaultValue;
35
+ }
36
+ set(key, value) {
37
+ if (!this.isInitialized) {
38
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
39
+ }
40
+ this.config.set(key, value);
41
+ logger.success(`Configuration set successfully for key: ${key}`);
42
+ }
43
+ has(key) {
44
+ if (!this.isInitialized) {
45
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
46
+ }
47
+ return this.config.has(key);
48
+ }
49
+ delete(key) {
50
+ if (!this.isInitialized) {
51
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
52
+ }
53
+ return this.config.delete(key);
54
+ }
55
+ loadConfig(config) {
56
+ if (!this.isInitialized) {
57
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
58
+ }
59
+ for (const [key, value] of Object.entries(config)) {
60
+ this.config.set(key, value);
61
+ }
62
+ logger.success("Configuration loaded successfully");
63
+ }
64
+ clearConfig() {
65
+ if (!this.isInitialized) {
66
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
67
+ }
68
+ this.config.clear();
69
+ logger.success("Configuration cleared successfully");
70
+ }
71
+ getPluginConfig(pluginName) {
72
+ if (!this.isInitialized) {
73
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
74
+ }
75
+ let config = this.pluginConfigs.get(pluginName);
76
+ if (!config) {
77
+ config = {
78
+ name: pluginName,
79
+ version: "1.0.0",
80
+ enabled: true,
81
+ dependencies: [],
82
+ config: {}
83
+ };
84
+ this.pluginConfigs.set(pluginName, config);
85
+ }
86
+ return config;
87
+ }
88
+ setPluginConfig(pluginName, config) {
89
+ if (!this.isInitialized) {
90
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
91
+ }
92
+ this.pluginConfigs.set(pluginName, config);
93
+ logger.success(`Plugin config set successfully for plugin: ${pluginName}`);
94
+ }
95
+ updatePluginConfig(pluginName, updates) {
96
+ if (!this.isInitialized) {
97
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
98
+ }
99
+ const currentConfig = this.pluginConfigs.get(pluginName);
100
+ if (!currentConfig) {
101
+ throw new Error(`Plugin config not found for plugin: ${pluginName}`);
102
+ }
103
+ const updatedConfig = { ...currentConfig, ...updates };
104
+ this.pluginConfigs.set(pluginName, updatedConfig);
105
+ logger.success(
106
+ `Plugin config updated successfully for plugin: ${pluginName}`
107
+ );
108
+ }
109
+ hasPluginConfig(pluginName) {
110
+ if (!this.isInitialized) {
111
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
112
+ }
113
+ return this.pluginConfigs.has(pluginName);
114
+ }
115
+ deletePluginConfig(pluginName) {
116
+ if (!this.isInitialized) {
117
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
118
+ }
119
+ const deleted = this.pluginConfigs.delete(pluginName);
120
+ if (deleted) {
121
+ logger.success(
122
+ `Plugin config deleted successfully for plugin: ${pluginName}`
123
+ );
124
+ }
125
+ return deleted;
126
+ }
127
+ getAllPluginConfigs() {
128
+ if (!this.isInitialized) {
129
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
130
+ }
131
+ return Object.fromEntries(this.pluginConfigs);
132
+ }
133
+ loadPluginConfigs(configs) {
134
+ if (!this.isInitialized) {
135
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
136
+ }
137
+ for (const [pluginName, config] of Object.entries(configs)) {
138
+ this.pluginConfigs.set(pluginName, config);
139
+ }
140
+ logger.success("Plugin configs loaded successfully");
141
+ }
142
+ validateConfig(schema, config) {
143
+ const result = schema.safeParse(config);
144
+ if (result.success) {
145
+ return { valid: true, errors: [] };
146
+ }
147
+ const errors = result.error.issues.map((issue) => {
148
+ const path = issue.path.join(".");
149
+ return path ? `${path}: ${issue.message}` : issue.message;
150
+ });
151
+ return { valid: false, errors };
152
+ }
153
+ exportConfig(format = "json") {
154
+ if (!this.isInitialized) {
155
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
156
+ }
157
+ const fullConfig = {
158
+ global: Object.fromEntries(this.config),
159
+ plugins: this.getAllPluginConfigs()
160
+ };
161
+ if (format === "json") {
162
+ return JSON.stringify(fullConfig, null, 2);
163
+ }
164
+ throw new Error(`Unsupported format: ${format}`);
165
+ }
166
+ importConfig(configJson) {
167
+ if (!this.isInitialized) {
168
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
169
+ }
170
+ try {
171
+ const fullConfig = parseJson(configJson);
172
+ if (fullConfig.global) {
173
+ this.loadConfig(fullConfig.global);
174
+ }
175
+ if (fullConfig.plugins) {
176
+ this.loadPluginConfigs(fullConfig.plugins);
177
+ }
178
+ logger.success("Configuration imported successfully");
179
+ } catch (error) {
180
+ logger.error("Failed to import configuration", error);
181
+ throw error;
182
+ }
183
+ }
184
+ getPluginConfigNames() {
185
+ if (!this.isInitialized) {
186
+ throw new Error("ConfigManager is not initialized");
187
+ }
188
+ return Array.from(this.pluginConfigs.keys());
189
+ }
190
+ getStats() {
191
+ return {
192
+ totalConfigKeys: this.config.size,
193
+ totalPluginConfigs: this.pluginConfigs.size,
194
+ configKeys: Array.from(this.config.keys()),
195
+ pluginConfigNames: this.getPluginConfigNames()
196
+ };
197
+ }
198
+ watchConfig(key, callback) {
199
+ if (!this.isInitialized) {
200
+ throw new Error(ERROR_CODE.CONFIG_MANAGER_NOT_INITIALIZED);
201
+ }
202
+ const checkInterval = setInterval(() => {
203
+ const value = this.get(key);
204
+ callback(value);
205
+ }, 1e3);
206
+ logger.info(`Configuration watch started for key: ${key}`);
207
+ return () => {
208
+ clearInterval(checkInterval);
209
+ logger.info(`Configuration watch stopped for key: ${key}`);
210
+ };
211
+ }
212
+ }
213
+
214
+ export { ConfigManager };