@hkdigital/lib-core 0.3.3 → 0.3.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 (189) hide show
  1. package/dist/components/index.d.ts +11 -0
  2. package/dist/components/index.js +23 -2
  3. package/dist/{features → components}/presenter/Presenter.svelte +1 -1
  4. package/dist/logging/index.d.ts +4 -5
  5. package/dist/logging/index.js +5 -6
  6. package/dist/logging/{adapters → internal/adapters}/console.js +1 -1
  7. package/dist/logging/internal/adapters/index.d.ts +2 -0
  8. package/dist/logging/internal/adapters/index.js +2 -0
  9. package/dist/logging/{factories → internal/factories}/client.d.ts +1 -1
  10. package/dist/logging/{factories → internal/factories}/client.js +2 -2
  11. package/dist/logging/{factories → internal/factories}/server.d.ts +1 -1
  12. package/dist/logging/{factories → internal/factories}/server.js +2 -2
  13. package/dist/{classes/logging → logging/internal/unified-logger}/Logger.d.ts +3 -3
  14. package/dist/{classes/logging → logging/internal/unified-logger}/Logger.js +19 -12
  15. package/dist/{classes/logging → logging/internal/unified-logger}/constants.d.ts +1 -0
  16. package/dist/{classes/logging → logging/internal/unified-logger}/constants.js +8 -2
  17. package/dist/{classes/logging → logging/internal/unified-logger}/index.d.ts +1 -0
  18. package/dist/{classes/logging → logging/internal/unified-logger}/index.js +2 -0
  19. package/dist/{components → primitives}/buttons/button/Button.svelte.d.ts +1 -1
  20. package/dist/{components → primitives}/drag-drop/DropZoneArea.svelte.d.ts +1 -1
  21. package/dist/primitives/index.d.ts +0 -0
  22. package/dist/primitives/index.js +2 -0
  23. package/dist/{components → primitives}/layout/grid-layers/util.js +1 -1
  24. package/dist/{components → primitives}/rows/panel-grid-row/PanelGridRow.svelte.d.ts +1 -1
  25. package/dist/{components → primitives}/rows/panel-row-2/PanelRow2.svelte.d.ts +1 -1
  26. package/dist/services/index.d.ts +1 -0
  27. package/dist/services/index.js +1 -0
  28. package/dist/services/internal/index.d.ts +6 -0
  29. package/dist/services/internal/index.js +8 -0
  30. package/dist/{classes/services → services/internal/service-base}/ServiceBase.d.ts +6 -8
  31. package/dist/{classes/services → services/internal/service-base}/ServiceBase.js +5 -6
  32. package/dist/{classes/services/service-states.d.ts → services/internal/service-base/constants.d.ts} +0 -61
  33. package/dist/{classes/services/service-states.js → services/internal/service-base/constants.js} +0 -95
  34. package/dist/services/internal/service-base/index.d.ts +3 -0
  35. package/dist/services/internal/service-base/index.js +3 -0
  36. package/dist/{classes/services → services/internal/service-base}/typedef.d.ts +34 -147
  37. package/dist/services/internal/service-base/typedef.js +101 -0
  38. package/dist/{classes/services → services/internal/service-manager}/ServiceManager.d.ts +8 -9
  39. package/dist/{classes/services → services/internal/service-manager}/ServiceManager.js +7 -7
  40. package/dist/services/internal/service-manager/constants.d.ts +4 -0
  41. package/dist/services/internal/service-manager/constants.js +6 -0
  42. package/dist/services/internal/service-manager/typedef.d.ts +104 -0
  43. package/dist/services/internal/service-manager/typedef.js +90 -0
  44. package/package.json +1 -1
  45. package/dist/classes/services/index.d.ts +0 -4
  46. package/dist/classes/services/index.js +0 -5
  47. package/dist/classes/services/typedef.js +0 -179
  48. package/dist/features/index.d.ts +0 -11
  49. package/dist/features/index.js +0 -23
  50. package/dist/logging/constants.d.ts +0 -1
  51. package/dist/logging/constants.js +0 -1
  52. package/dist/server/index.d.ts +0 -1
  53. package/dist/server/index.js +0 -1
  54. package/dist/server/logger.d.ts +0 -25
  55. package/dist/server/logger.js +0 -94
  56. /package/dist/classes/{events → event-emitter}/EventEmitter.d.ts +0 -0
  57. /package/dist/classes/{events → event-emitter}/EventEmitter.js +0 -0
  58. /package/dist/classes/{events → event-emitter}/index.d.ts +0 -0
  59. /package/dist/classes/{events → event-emitter}/index.js +0 -0
  60. /package/dist/{features → components}/button-group/ButtonGroup.svelte +0 -0
  61. /package/dist/{features → components}/button-group/ButtonGroup.svelte.d.ts +0 -0
  62. /package/dist/{features → components}/button-group/typedef.d.ts +0 -0
  63. /package/dist/{features → components}/button-group/typedef.js +0 -0
  64. /package/dist/{features → components}/compare-left-right/CompareLeftRight.svelte +0 -0
  65. /package/dist/{features → components}/compare-left-right/CompareLeftRight.svelte.d.ts +0 -0
  66. /package/dist/{features → components}/compare-left-right/index.d.ts +0 -0
  67. /package/dist/{features → components}/compare-left-right/index.js +0 -0
  68. /package/dist/{features → components}/game-box/GameBox.svelte +0 -0
  69. /package/dist/{features → components}/game-box/GameBox.svelte.d.ts +0 -0
  70. /package/dist/{features → components}/game-box/gamebox.util.d.ts +0 -0
  71. /package/dist/{features → components}/game-box/gamebox.util.js +0 -0
  72. /package/dist/{features → components}/hk-app-layout/HkAppLayout.state.svelte.d.ts +0 -0
  73. /package/dist/{features → components}/hk-app-layout/HkAppLayout.state.svelte.js +0 -0
  74. /package/dist/{features → components}/hk-app-layout/HkAppLayout.svelte +0 -0
  75. /package/dist/{features → components}/hk-app-layout/HkAppLayout.svelte.d.ts +0 -0
  76. /package/dist/{features → components}/image-box/ImageBox.svelte +0 -0
  77. /package/dist/{features → components}/image-box/ImageBox.svelte.d.ts +0 -0
  78. /package/dist/{features → components}/image-box/index.d.ts +0 -0
  79. /package/dist/{features → components}/image-box/index.js +0 -0
  80. /package/dist/{features → components}/image-box/typedef.d.ts +0 -0
  81. /package/dist/{features → components}/image-box/typedef.js +0 -0
  82. /package/dist/{features → components}/presenter/ImageSlide.svelte +0 -0
  83. /package/dist/{features → components}/presenter/ImageSlide.svelte.d.ts +0 -0
  84. /package/dist/{features → components}/presenter/Presenter.state.svelte.d.ts +0 -0
  85. /package/dist/{features → components}/presenter/Presenter.state.svelte.js +0 -0
  86. /package/dist/{features → components}/presenter/Presenter.svelte.d.ts +0 -0
  87. /package/dist/{features → components}/presenter/constants.d.ts +0 -0
  88. /package/dist/{features → components}/presenter/constants.js +0 -0
  89. /package/dist/{features → components}/presenter/index.d.ts +0 -0
  90. /package/dist/{features → components}/presenter/index.js +0 -0
  91. /package/dist/{features → components}/presenter/typedef.d.ts +0 -0
  92. /package/dist/{features → components}/presenter/typedef.js +0 -0
  93. /package/dist/{features → components}/presenter/util.d.ts +0 -0
  94. /package/dist/{features → components}/presenter/util.js +0 -0
  95. /package/dist/{features → components}/virtual-viewport/VirtualViewport.svelte +0 -0
  96. /package/dist/{features → components}/virtual-viewport/VirtualViewport.svelte.d.ts +0 -0
  97. /package/dist/logging/{adapters → internal/adapters}/console.d.ts +0 -0
  98. /package/dist/logging/{adapters → internal/adapters}/pino.d.ts +0 -0
  99. /package/dist/logging/{adapters → internal/adapters}/pino.js +0 -0
  100. /package/dist/logging/{factories → internal/factories}/universal.d.ts +0 -0
  101. /package/dist/logging/{factories → internal/factories}/universal.js +0 -0
  102. /package/dist/{classes/logging → logging/internal/unified-logger}/typedef.d.ts +0 -0
  103. /package/dist/{classes/logging → logging/internal/unified-logger}/typedef.js +0 -0
  104. /package/dist/{components → primitives}/area/HkArea.svelte +0 -0
  105. /package/dist/{components → primitives}/area/HkArea.svelte.d.ts +0 -0
  106. /package/dist/{components → primitives}/area/HkGridArea.svelte +0 -0
  107. /package/dist/{components → primitives}/area/HkGridArea.svelte.d.ts +0 -0
  108. /package/dist/{components → primitives}/area/index.d.ts +0 -0
  109. /package/dist/{components → primitives}/area/index.js +0 -0
  110. /package/dist/{components → primitives}/buttons/button/Button.svelte +0 -0
  111. /package/dist/{components → primitives}/buttons/button-icon-steeze/SteezeIconButton.svelte +0 -0
  112. /package/dist/{components → primitives}/buttons/button-icon-steeze/SteezeIconButton.svelte.d.ts +0 -0
  113. /package/dist/{components → primitives}/buttons/button-text/TextButton.svelte +0 -0
  114. /package/dist/{components → primitives}/buttons/button-text/TextButton.svelte.d.ts +0 -0
  115. /package/dist/{components → primitives}/buttons/index.d.ts +0 -0
  116. /package/dist/{components → primitives}/buttons/index.js +0 -0
  117. /package/dist/{components → primitives}/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte +0 -0
  118. /package/dist/{components → primitives}/debug/debug-panel-design-scaling/DebugPanelDesignScaling.svelte.d.ts +0 -0
  119. /package/dist/{components → primitives}/debug/index.d.ts +0 -0
  120. /package/dist/{components → primitives}/debug/index.js +0 -0
  121. /package/dist/{components → primitives}/drag-drop/DragController.d.ts +0 -0
  122. /package/dist/{components → primitives}/drag-drop/DragController.js +0 -0
  123. /package/dist/{components → primitives}/drag-drop/DragDropContext.svelte +0 -0
  124. /package/dist/{components → primitives}/drag-drop/DragDropContext.svelte.d.ts +0 -0
  125. /package/dist/{components → primitives}/drag-drop/Draggable.svelte +0 -0
  126. /package/dist/{components → primitives}/drag-drop/Draggable.svelte.d.ts +0 -0
  127. /package/dist/{components → primitives}/drag-drop/DropZone.svelte +0 -0
  128. /package/dist/{components → primitives}/drag-drop/DropZone.svelte.d.ts +0 -0
  129. /package/dist/{components → primitives}/drag-drop/DropZoneArea.svelte +0 -0
  130. /package/dist/{components → primitives}/drag-drop/DropZoneList.svelte +0 -0
  131. /package/dist/{components → primitives}/drag-drop/DropZoneList.svelte.d.ts +0 -0
  132. /package/dist/{components → primitives}/drag-drop/actions.d.ts +0 -0
  133. /package/dist/{components → primitives}/drag-drop/actions.js +0 -0
  134. /package/dist/{components → primitives}/drag-drop/drag-state.svelte.d.ts +0 -0
  135. /package/dist/{components → primitives}/drag-drop/drag-state.svelte.js +0 -0
  136. /package/dist/{components → primitives}/drag-drop/index.d.ts +0 -0
  137. /package/dist/{components → primitives}/drag-drop/index.js +0 -0
  138. /package/dist/{components → primitives}/drag-drop/util.d.ts +0 -0
  139. /package/dist/{components → primitives}/drag-drop/util.js +0 -0
  140. /package/dist/{components → primitives}/hkdev/blocks/TextBlock.svelte +0 -0
  141. /package/dist/{components → primitives}/hkdev/blocks/TextBlock.svelte.d.ts +0 -0
  142. /package/dist/{components → primitives}/hkdev/buttons/CheckButton.svelte +0 -0
  143. /package/dist/{components → primitives}/hkdev/buttons/CheckButton.svelte.d.ts +0 -0
  144. /package/dist/{components → primitives}/icons/HkIcon.svelte +0 -0
  145. /package/dist/{components → primitives}/icons/HkIcon.svelte.d.ts +0 -0
  146. /package/dist/{components → primitives}/icons/HkTabIcon.svelte +0 -0
  147. /package/dist/{components → primitives}/icons/HkTabIcon.svelte.d.ts +0 -0
  148. /package/dist/{components → primitives}/icons/SteezeIcon.svelte +0 -0
  149. /package/dist/{components → primitives}/icons/SteezeIcon.svelte.d.ts +0 -0
  150. /package/dist/{components → primitives}/icons/index.d.ts +0 -0
  151. /package/dist/{components → primitives}/icons/index.js +0 -0
  152. /package/dist/{components → primitives}/icons/typedef.d.ts +0 -0
  153. /package/dist/{components → primitives}/icons/typedef.js +0 -0
  154. /package/dist/{components → primitives}/inputs/index.d.ts +0 -0
  155. /package/dist/{components → primitives}/inputs/index.js +0 -0
  156. /package/dist/{components → primitives}/inputs/text-input/TestTextInput.svelte__ +0 -0
  157. /package/dist/{components → primitives}/inputs/text-input/TextInput.svelte +0 -0
  158. /package/dist/{components → primitives}/inputs/text-input/TextInput.svelte.d.ts +0 -0
  159. /package/dist/{components → primitives}/inputs/text-input/TextInput.svelte___ +0 -0
  160. /package/dist/{components → primitives}/inputs/text-input/assets/IconInvalid.svelte +0 -0
  161. /package/dist/{components → primitives}/inputs/text-input/assets/IconInvalid.svelte.d.ts +0 -0
  162. /package/dist/{components → primitives}/inputs/text-input/assets/IconValid.svelte +0 -0
  163. /package/dist/{components → primitives}/inputs/text-input/assets/IconValid.svelte.d.ts +0 -0
  164. /package/dist/{components → primitives}/layout/grid-layers/GridLayers.svelte +0 -0
  165. /package/dist/{components → primitives}/layout/grid-layers/GridLayers.svelte.d.ts +0 -0
  166. /package/dist/{components → primitives}/layout/grid-layers/GridLayers.svelte__heightFrom__ +0 -0
  167. /package/dist/{components → primitives}/layout/grid-layers/util.d.ts +0 -0
  168. /package/dist/{components → primitives}/layout/index.d.ts +0 -0
  169. /package/dist/{components → primitives}/layout/index.js +0 -0
  170. /package/dist/{components → primitives}/panels/index.d.ts +0 -0
  171. /package/dist/{components → primitives}/panels/index.js +0 -0
  172. /package/dist/{components → primitives}/panels/panel/Panel.svelte +0 -0
  173. /package/dist/{components → primitives}/panels/panel/Panel.svelte.d.ts +0 -0
  174. /package/dist/{components → primitives}/rows/index.d.ts +0 -0
  175. /package/dist/{components → primitives}/rows/index.js +0 -0
  176. /package/dist/{components → primitives}/rows/panel-grid-row/PanelGridRow.svelte +0 -0
  177. /package/dist/{components → primitives}/rows/panel-row-2/PanelRow2.svelte +0 -0
  178. /package/dist/{components → primitives}/tab-bar/HkTabBar.state.svelte.d.ts +0 -0
  179. /package/dist/{components → primitives}/tab-bar/HkTabBar.state.svelte.js +0 -0
  180. /package/dist/{components → primitives}/tab-bar/HkTabBar.svelte +0 -0
  181. /package/dist/{components → primitives}/tab-bar/HkTabBar.svelte.d.ts +0 -0
  182. /package/dist/{components → primitives}/tab-bar/HkTabBarSelector.state.svelte.d.ts +0 -0
  183. /package/dist/{components → primitives}/tab-bar/HkTabBarSelector.state.svelte.js +0 -0
  184. /package/dist/{components → primitives}/tab-bar/HkTabBarSelector.svelte +0 -0
  185. /package/dist/{components → primitives}/tab-bar/HkTabBarSelector.svelte.d.ts +0 -0
  186. /package/dist/{components → primitives}/tab-bar/index.d.ts +0 -0
  187. /package/dist/{components → primitives}/tab-bar/index.js +0 -0
  188. /package/dist/{components → primitives}/tab-bar/typedef.d.ts +0 -0
  189. /package/dist/{components → primitives}/tab-bar/typedef.js +0 -0
@@ -1,12 +1,3 @@
1
- /**
2
- * Service configuration object passed to service initialization
3
- */
4
- export type ServiceConfig = {
5
- /**
6
- * - Service-specific configuration properties
7
- */
8
- key?: any;
9
- };
10
1
  /**
11
2
  * Options for creating a service instance
12
3
  */
@@ -62,6 +53,40 @@ export type HealthStatus = {
62
53
  */
63
54
  key?: any;
64
55
  };
56
+ /**
57
+ * Base class interface that services must implement
58
+ */
59
+ export type ServiceInstance = {
60
+ /**
61
+ * - Service name
62
+ */
63
+ name: string;
64
+ /**
65
+ * - Current state
66
+ */
67
+ state: string;
68
+ /**
69
+ * - Health status
70
+ */
71
+ healthy: boolean;
72
+ /**
73
+ * - Last error
74
+ */
75
+ error: Error | null;
76
+ /**
77
+ * - Service logger
78
+ */
79
+ logger: import("../../../logging/internal/unified-logger").Logger;
80
+ initialize: (config?: any) => Promise<boolean>;
81
+ start: () => Promise<boolean>;
82
+ stop: (options?: StopOptions) => Promise<boolean>;
83
+ recover: () => Promise<boolean>;
84
+ destroy: () => Promise<boolean>;
85
+ getHealth: () => Promise<HealthStatus>;
86
+ setLogLevel: (level: string) => boolean;
87
+ on: (event: string, handler: Function) => Function;
88
+ emit: (event: string, data: any) => boolean;
89
+ };
65
90
  export type StateChangeEvent = {
66
91
  /**
67
92
  * - Service name (added by ServiceManager)
@@ -107,141 +132,3 @@ export type ServiceErrorEvent = {
107
132
  */
108
133
  error: Error;
109
134
  };
110
- /**
111
- * Service class constructor type
112
- */
113
- export type ServiceConstructor = new (name: string, options?: ServiceOptions) => ServiceInstance;
114
- /**
115
- * Options for registering a service
116
- */
117
- export type ServiceRegistrationOptions = {
118
- /**
119
- * - Services this service depends on
120
- */
121
- dependencies?: string[];
122
- /**
123
- * - Tags for grouping services
124
- */
125
- tags?: string[];
126
- /**
127
- * - Startup priority (higher starts first)
128
- */
129
- priority?: number;
130
- };
131
- /**
132
- * Configuration for ServiceManager
133
- */
134
- export type ServiceManagerConfig = {
135
- /**
136
- * - Debug mode switch
137
- */
138
- debug?: boolean;
139
- /**
140
- * - Auto-start services on registration
141
- */
142
- autoStart?: boolean;
143
- /**
144
- * - Default timeout for stopping services
145
- */
146
- stopTimeout?: number;
147
- /**
148
- * - Initial log level for ServiceManager
149
- */
150
- logLevel?: string;
151
- /**
152
- * - Logging configuration
153
- */
154
- logConfig?: LogConfig;
155
- };
156
- /**
157
- * Logging configuration
158
- */
159
- export type LogConfig = {
160
- /**
161
- * - Default log level for services
162
- */
163
- defaultLevel?: string;
164
- /**
165
- * - Override level for all services
166
- */
167
- globalLevel?: string;
168
- /**
169
- * - Per-service log levels
170
- */
171
- serviceLevels?: {
172
- [x: string]: string;
173
- };
174
- };
175
- /**
176
- * Internal service registry entry
177
- */
178
- export type ServiceEntry = {
179
- /**
180
- * - Service class constructor
181
- */
182
- ServiceClass: ServiceConstructor;
183
- /**
184
- * - Service instance (lazy-created)
185
- */
186
- instance: ServiceInstance | null;
187
- /**
188
- * - Service configuration
189
- */
190
- config: ServiceConfig;
191
- /**
192
- * - Service dependencies
193
- */
194
- dependencies: string[];
195
- /**
196
- * - Services that depend on this one
197
- */
198
- dependents: Set<string>;
199
- /**
200
- * - Service tags
201
- */
202
- tags: string[];
203
- /**
204
- * - Startup priority
205
- */
206
- priority: number;
207
- };
208
- /**
209
- * Result of health check for all services
210
- */
211
- export type HealthCheckResult = {
212
- [x: string]: HealthStatus;
213
- };
214
- /**
215
- * Base class interface that services must implement
216
- */
217
- export type ServiceInstance = {
218
- /**
219
- * - Service name
220
- */
221
- name: string;
222
- /**
223
- * - Current state
224
- */
225
- state: string;
226
- /**
227
- * - Health status
228
- */
229
- healthy: boolean;
230
- /**
231
- * - Last error
232
- */
233
- error: Error | null;
234
- /**
235
- * - Service logger
236
- */
237
- logger: import("../logging").Logger;
238
- initialize: (config?: ServiceConfig) => Promise<boolean>;
239
- start: () => Promise<boolean>;
240
- stop: (options?: StopOptions) => Promise<boolean>;
241
- recover: () => Promise<boolean>;
242
- destroy: () => Promise<boolean>;
243
- getHealth: () => Promise<HealthStatus>;
244
- setLogLevel: (level: string) => boolean;
245
- on: (event: string, handler: Function) => Function;
246
- emit: (event: string, data: any) => boolean;
247
- };
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @fileoverview Type definitions for ServiceBase class.
3
+ *
4
+ * This file contains all TypeScript/JSDoc type definitions used by
5
+ * the ServiceBase class and service implementations.
6
+ *
7
+ * @example
8
+ * // In your service implementation
9
+ * import { ServiceBase } from './ServiceBase.js';
10
+ *
11
+ * class MyService extends ServiceBase {
12
+ * async _init(config) {
13
+ * }
14
+ *
15
+ * async _healthCheck() {
16
+ * // Return type is HealthStatus
17
+ * return { latency: 10 };
18
+ * }
19
+ * }
20
+ */
21
+
22
+ // ============================================================================
23
+ // PUBLIC TYPES
24
+ // ============================================================================
25
+
26
+ /**
27
+ * Options for creating a service instance
28
+ *
29
+ * @typedef {Object} ServiceOptions
30
+ * @property {string} [logLevel] - Initial log level for the service
31
+ * @property {number} [shutdownTimeout=5000] - Timeout for graceful shutdown
32
+ */
33
+
34
+ /**
35
+ * Options for stopping a service
36
+ *
37
+ * @typedef {Object} StopOptions
38
+ * @property {number} [timeout] - Override shutdown timeout
39
+ * @property {boolean} [force=false] - Force stop even if timeout exceeded
40
+ */
41
+
42
+ /**
43
+ * Health status returned by service health checks
44
+ *
45
+ * @typedef {Object} HealthStatus
46
+ * @property {string} name - Service name
47
+ * @property {string} state - Current service state
48
+ * @property {boolean} healthy - Whether the service is healthy
49
+ * @property {string} [error] - Error message if unhealthy
50
+ * @property {string} [checkError] - Error from health check itself
51
+ * @property {*} [key] - Additional health check properties
52
+ */
53
+
54
+ /**
55
+ * Base class interface that services must implement
56
+ *
57
+ * @typedef {Object} ServiceInstance
58
+ * @property {string} name - Service name
59
+ * @property {string} state - Current state
60
+ * @property {boolean} healthy - Health status
61
+ * @property {Error|null} error - Last error
62
+ * @property {import('../../../logging/internal/unified-logger').Logger} logger - Service logger
63
+ * @property {(config?: *) => Promise<boolean>} initialize
64
+ * @property {() => Promise<boolean>} start
65
+ * @property {(options?: StopOptions) => Promise<boolean>} stop
66
+ * @property {() => Promise<boolean>} recover
67
+ * @property {() => Promise<boolean>} destroy
68
+ * @property {() => Promise<HealthStatus>} getHealth
69
+ * @property {(level: string) => boolean} setLogLevel
70
+ * @property {(event: string, handler: Function) => Function} on
71
+ * @property {(event: string, data: any) => boolean} emit
72
+ */
73
+
74
+ // ============================================================================
75
+ // INTERNAL TYPES
76
+ // ============================================================================
77
+
78
+ /**
79
+ * @typedef {Object} StateChangeEvent
80
+ * @property {string} service - Service name (added by ServiceManager)
81
+ * @property {string} oldState - Previous state
82
+ * @property {string} newState - New state
83
+ */
84
+
85
+ /**
86
+ * @typedef {Object} HealthChangeEvent
87
+ * @property {string} service - Service name (added by ServiceManager)
88
+ * @property {boolean} healthy - Current health status
89
+ * @property {boolean} [wasHealthy] - Previous health status
90
+ */
91
+
92
+ /**
93
+ * Event emitted when service encounters an error
94
+ *
95
+ * @typedef {Object} ServiceErrorEvent
96
+ * @property {string} service - Service name
97
+ * @property {string} operation - Operation that failed
98
+ * @property {Error} error - Error that occurred
99
+ */
100
+
101
+ export {};
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * @typedef {import('./typedef.js').ServiceConstructor} ServiceConstructor
3
- * @typedef {import('./typedef.js').ServiceConfig} ServiceConfig
4
3
  * @typedef {import('./typedef.js').ServiceRegistrationOptions} ServiceRegistrationOptions
5
4
  * @typedef {import('./typedef.js').ServiceManagerConfig} ServiceManagerConfig
6
- * @typedef {import('./typedef.js').StopOptions} StopOptions
7
5
  * @typedef {import('./typedef.js').ServiceEntry} ServiceEntry
8
6
  * @typedef {import('./typedef.js').HealthCheckResult} HealthCheckResult
7
+ *
8
+ * @typedef {import('../service-base/typedef.js').StopOptions} StopOptions
9
9
  */
10
10
  /**
11
11
  * Service Manager for lifecycle and dependency management
@@ -29,12 +29,12 @@ export class ServiceManager extends EventEmitter {
29
29
  *
30
30
  * @param {string} name - Unique service identifier
31
31
  * @param {ServiceConstructor} ServiceClass - Service class constructor
32
- * @param {ServiceConfig} [config={}] - Service configuration
32
+ * @param {*} [config={}] - Service configuration
33
33
  * @param {ServiceRegistrationOptions} [options={}] - Registration options
34
34
  *
35
35
  * @throws {Error} If service name is already registered
36
36
  */
37
- register(name: string, ServiceClass: ServiceConstructor, config?: ServiceConfig, options?: ServiceRegistrationOptions): void;
37
+ register(name: string, ServiceClass: ServiceConstructor, config?: any, options?: ServiceRegistrationOptions): void;
38
38
  /**
39
39
  * Get or create a service instance
40
40
  *
@@ -153,7 +153,7 @@ export class ServiceManager extends EventEmitter {
153
153
  *
154
154
  * @private
155
155
  * @param {string} name - Service name
156
- * @param {import('./typedef.js').ServiceInstance} instance
156
+ * @param {import('../service-base/typedef.js').ServiceInstance} instance
157
157
  * Service instance
158
158
  */
159
159
  private _attachServiceEvents;
@@ -169,11 +169,10 @@ export class ServiceManager extends EventEmitter {
169
169
  }
170
170
  export default ServiceManager;
171
171
  export type ServiceConstructor = import("./typedef.js").ServiceConstructor;
172
- export type ServiceConfig = import("./typedef.js").ServiceConfig;
173
172
  export type ServiceRegistrationOptions = import("./typedef.js").ServiceRegistrationOptions;
174
173
  export type ServiceManagerConfig = import("./typedef.js").ServiceManagerConfig;
175
- export type StopOptions = import("./typedef.js").StopOptions;
176
174
  export type ServiceEntry = import("./typedef.js").ServiceEntry;
177
175
  export type HealthCheckResult = import("./typedef.js").HealthCheckResult;
178
- import { EventEmitter } from '../events';
179
- import { Logger } from '../logging';
176
+ export type StopOptions = import("../service-base/typedef.js").StopOptions;
177
+ import { EventEmitter } from '../../../classes/event-emitter';
178
+ import { Logger } from '../../../logging/index.js';
@@ -63,24 +63,24 @@
63
63
  * });
64
64
  */
65
65
 
66
- import { EventEmitter } from '../events';
67
- import { Logger, DEBUG, INFO, WARN } from '../logging';
66
+ import { EventEmitter } from '../../../classes/event-emitter';
67
+ import { Logger, DEBUG, INFO, WARN } from '../../../logging/index.js';
68
68
 
69
69
  import {
70
70
  NOT_CREATED,
71
71
  CREATED,
72
72
  RUNNING,
73
73
  DESTROYED
74
- } from './service-states.js';
74
+ } from '../service-base/constants.js';
75
75
 
76
76
  /**
77
77
  * @typedef {import('./typedef.js').ServiceConstructor} ServiceConstructor
78
- * @typedef {import('./typedef.js').ServiceConfig} ServiceConfig
79
78
  * @typedef {import('./typedef.js').ServiceRegistrationOptions} ServiceRegistrationOptions
80
79
  * @typedef {import('./typedef.js').ServiceManagerConfig} ServiceManagerConfig
81
- * @typedef {import('./typedef.js').StopOptions} StopOptions
82
80
  * @typedef {import('./typedef.js').ServiceEntry} ServiceEntry
83
81
  * @typedef {import('./typedef.js').HealthCheckResult} HealthCheckResult
82
+ *
83
+ * @typedef {import('../service-base/typedef.js').StopOptions} StopOptions
84
84
  */
85
85
 
86
86
  /**
@@ -118,7 +118,7 @@ export class ServiceManager extends EventEmitter {
118
118
  *
119
119
  * @param {string} name - Unique service identifier
120
120
  * @param {ServiceConstructor} ServiceClass - Service class constructor
121
- * @param {ServiceConfig} [config={}] - Service configuration
121
+ * @param {*} [config={}] - Service configuration
122
122
  * @param {ServiceRegistrationOptions} [options={}] - Registration options
123
123
  *
124
124
  * @throws {Error} If service name is already registered
@@ -545,7 +545,7 @@ export class ServiceManager extends EventEmitter {
545
545
  *
546
546
  * @private
547
547
  * @param {string} name - Service name
548
- * @param {import('./typedef.js').ServiceInstance} instance
548
+ * @param {import('../service-base/typedef.js').ServiceInstance} instance
549
549
  * Service instance
550
550
  */
551
551
  _attachServiceEvents(name, instance) {
@@ -0,0 +1,4 @@
1
+ export const SERVICE_STATE_CHANGED: "service:state-changed";
2
+ export const SERVICE_HEALTH_CHANGED: "service:health-changed";
3
+ export const SERVICE_ERROR: "service:error";
4
+ export const SERVICE_LOG: "service:log";
@@ -0,0 +1,6 @@
1
+
2
+ // Log event names
3
+ export const SERVICE_STATE_CHANGED = 'service:state-changed';
4
+ export const SERVICE_HEALTH_CHANGED = 'service:health-changed';
5
+ export const SERVICE_ERROR = 'service:error';
6
+ export const SERVICE_LOG = 'service:log';
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Options for registering a service
3
+ */
4
+ export type ServiceRegistrationOptions = {
5
+ /**
6
+ * - Services this service depends on
7
+ */
8
+ dependencies?: string[];
9
+ /**
10
+ * - Tags for grouping services
11
+ */
12
+ tags?: string[];
13
+ /**
14
+ * - Startup priority (higher starts first)
15
+ */
16
+ priority?: number;
17
+ };
18
+ /**
19
+ * Configuration for ServiceManager
20
+ */
21
+ export type ServiceManagerConfig = {
22
+ /**
23
+ * - Debug mode switch
24
+ */
25
+ debug?: boolean;
26
+ /**
27
+ * - Auto-start services on registration
28
+ */
29
+ autoStart?: boolean;
30
+ /**
31
+ * - Default timeout for stopping services
32
+ */
33
+ stopTimeout?: number;
34
+ /**
35
+ * - Initial log level for ServiceManager
36
+ */
37
+ logLevel?: string;
38
+ /**
39
+ * - Logging configuration
40
+ */
41
+ logConfig?: LogConfig;
42
+ };
43
+ /**
44
+ * Logging configuration
45
+ */
46
+ export type LogConfig = {
47
+ /**
48
+ * - Default log level for services
49
+ */
50
+ defaultLevel?: string;
51
+ /**
52
+ * - Override level for all services
53
+ */
54
+ globalLevel?: string;
55
+ /**
56
+ * - Per-service log levels
57
+ */
58
+ serviceLevels?: {
59
+ [x: string]: string;
60
+ };
61
+ };
62
+ /**
63
+ * Result of health check for all services
64
+ */
65
+ export type HealthCheckResult = {
66
+ [x: string]: HealthStatus;
67
+ };
68
+ /**
69
+ * Service class constructor type
70
+ */
71
+ export type ServiceConstructor = new (name: string, options?: ServiceOptions) => ServiceInstance;
72
+ /**
73
+ * Internal service registry entry
74
+ */
75
+ export type ServiceEntry = {
76
+ /**
77
+ * - Service class constructor
78
+ */
79
+ ServiceClass: ServiceConstructor;
80
+ /**
81
+ * - Service instance (lazy-created)
82
+ */
83
+ instance: ServiceInstance | null;
84
+ /**
85
+ * - Service configuration
86
+ */
87
+ config: any;
88
+ /**
89
+ * - Service dependencies
90
+ */
91
+ dependencies: string[];
92
+ /**
93
+ * - Services that depend on this one
94
+ */
95
+ dependents: Set<string>;
96
+ /**
97
+ * - Service tags
98
+ */
99
+ tags: string[];
100
+ /**
101
+ * - Startup priority
102
+ */
103
+ priority: number;
104
+ };
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @fileoverview Type definitions for ServiceManager class.
3
+ *
4
+ * This file contains all TypeScript/JSDoc type definitions used by
5
+ * the ServiceManager class and service registration.
6
+ *
7
+ * @example
8
+ * // When using ServiceManager
9
+ * import { ServiceManager } from './ServiceManager.js';
10
+ *
11
+ * // @ typedef {import('./typedef-service-manager.js').ServiceManagerConfig} ServiceManagerConfig
12
+ * // @ typedef {import('./typedef-service-manager.js').ServiceRegistrationOptions} ServiceRegistrationOptions
13
+ *
14
+ * const config = {
15
+ * environment: 'development',
16
+ * stopTimeout: 5000
17
+ * };
18
+ *
19
+ * const manager = new ServiceManager(config);
20
+ *
21
+ * const options = {
22
+ * dependencies: ['database'],
23
+ * tags: ['critical']
24
+ * };
25
+ *
26
+ * manager.register('auth', AuthService, {}, options);
27
+ */
28
+
29
+ // ============================================================================
30
+ // PUBLIC TYPES
31
+ // ============================================================================
32
+
33
+ /**
34
+ * Options for registering a service
35
+ *
36
+ * @typedef {Object} ServiceRegistrationOptions
37
+ * @property {string[]} [dependencies=[]] - Services this service depends on
38
+ * @property {string[]} [tags=[]] - Tags for grouping services
39
+ * @property {number} [priority=0] - Startup priority (higher starts first)
40
+ */
41
+
42
+ /**
43
+ * Configuration for ServiceManager
44
+ *
45
+ * @typedef {Object} ServiceManagerConfig
46
+ * @property {boolean} [debug=false] - Debug mode switch
47
+ * @property {boolean} [autoStart=false] - Auto-start services on registration
48
+ * @property {number} [stopTimeout=10000] - Default timeout for stopping services
49
+ * @property {string} [logLevel] - Initial log level for ServiceManager
50
+ * @property {LogConfig} [logConfig={}] - Logging configuration
51
+ */
52
+
53
+ /**
54
+ * Logging configuration
55
+ *
56
+ * @typedef {Object} LogConfig
57
+ * @property {string} [defaultLevel] - Default log level for services
58
+ * @property {string} [globalLevel] - Override level for all services
59
+ * @property {Object<string, string>} [serviceLevels] - Per-service log levels
60
+ */
61
+
62
+ /**
63
+ * Result of health check for all services
64
+ * @typedef {Object<string, HealthStatus>} HealthCheckResult
65
+ */
66
+
67
+ /**
68
+ * Service class constructor type
69
+ *
70
+ * @typedef {new (name: string, options?: ServiceOptions) => ServiceInstance} ServiceConstructor
71
+ */
72
+
73
+ // ============================================================================
74
+ // INTERNAL TYPES
75
+ // ============================================================================
76
+
77
+ /**
78
+ * Internal service registry entry
79
+ *
80
+ * @typedef {Object} ServiceEntry
81
+ * @property {ServiceConstructor} ServiceClass - Service class constructor
82
+ * @property {ServiceInstance|null} instance - Service instance (lazy-created)
83
+ * @property {*} config - Service configuration
84
+ * @property {string[]} dependencies - Service dependencies
85
+ * @property {Set<string>} dependents - Services that depend on this one
86
+ * @property {string[]} tags - Service tags
87
+ * @property {number} priority - Startup priority
88
+ */
89
+
90
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-core",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "author": {
5
5
  "name": "HKdigital",
6
6
  "url": "https://hkdigital.nl"
@@ -1,4 +0,0 @@
1
- export { default as ServiceBase } from "./ServiceBase.js";
2
- export { default as ServiceManager } from "./ServiceManager.js";
3
- export * from "./service-states.js";
4
- export * from "./typedef.js";
@@ -1,5 +0,0 @@
1
- export { default as ServiceBase } from './ServiceBase.js';
2
- export { default as ServiceManager } from './ServiceManager.js';
3
-
4
- export * from './service-states.js';
5
- export * from './typedef.js';