@hkdigital/lib-sveltekit 0.2.10 → 0.2.12
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/classes/services/ServiceBase.d.ts +83 -73
- package/dist/classes/services/ServiceBase.js +237 -181
- package/dist/classes/services/ServiceManager.d.ts +96 -267
- package/dist/classes/services/ServiceManager.js +367 -874
- package/dist/classes/services/_old/ServiceBase.d.ts +153 -0
- package/dist/classes/services/_old/ServiceBase.js +409 -0
- package/dist/classes/services/_old/ServiceManager.d.ts +350 -0
- package/dist/classes/services/_old/ServiceManager.js +1114 -0
- package/dist/classes/services/service-states.d.ts +154 -0
- package/dist/classes/services/service-states.js +199 -0
- package/dist/classes/services/typedef.d.ts +206 -0
- package/dist/classes/services/typedef.js +169 -0
- package/dist/components/drag-drop/Draggable.svelte +115 -98
- package/dist/components/drag-drop/Draggable.svelte.d.ts +2 -0
- package/package.json +1 -1
- package/dist/components/drag-drop/drag-state.svelte.js__ +0 -319
- /package/dist/classes/services/{constants.d.ts → _old/constants.d.ts} +0 -0
- /package/dist/classes/services/{constants.js → _old/constants.js} +0 -0
- /package/dist/classes/services/{index.d.ts → _old/index.d.ts} +0 -0
- /package/dist/classes/services/{index.js → _old/index.js} +0 -0
@@ -1,147 +1,149 @@
|
|
1
1
|
/**
|
2
|
-
*
|
2
|
+
* @typedef {import('./typedef.js').ServiceConfig} ServiceConfig
|
3
|
+
* @typedef {import('./typedef.js').ServiceOptions} ServiceOptions
|
4
|
+
* @typedef {import('./typedef.js').StopOptions} StopOptions
|
5
|
+
* @typedef {import('./typedef.js').HealthStatus} HealthStatus
|
6
|
+
* @typedef {import('./typedef.js').StateChangeEvent} StateChangeEvent
|
7
|
+
* @typedef {import('./typedef.js').HealthChangeEvent} HealthChangeEvent
|
8
|
+
* @typedef {import('./typedef.js').ServiceErrorEvent} ServiceErrorEvent
|
3
9
|
*/
|
4
|
-
|
10
|
+
/**
|
11
|
+
* Base class for all services with lifecycle management
|
12
|
+
* @extends EventEmitter
|
13
|
+
*/
|
14
|
+
export class ServiceBase extends EventEmitter {
|
5
15
|
/**
|
6
|
-
* Create a new service
|
16
|
+
* Create a new service instance
|
7
17
|
*
|
8
18
|
* @param {string} name - Service name
|
9
|
-
* @param {
|
10
|
-
* @param {string} [options.logLevel=INFO] - Initial log level
|
11
|
-
*/
|
12
|
-
constructor(name: string, options?: {
|
13
|
-
logLevel?: string;
|
14
|
-
});
|
15
|
-
/**
|
16
|
-
* Service name
|
17
|
-
* @type {string}
|
19
|
+
* @param {ServiceOptions} [options={}] - Service options
|
18
20
|
*/
|
21
|
+
constructor(name: string, options?: ServiceOptions);
|
22
|
+
/** @type {string} */
|
19
23
|
name: string;
|
20
|
-
/**
|
21
|
-
* Event emitter for service events
|
22
|
-
* @type {EventEmitter}
|
23
|
-
*/
|
24
|
-
events: EventEmitter;
|
25
|
-
/**
|
26
|
-
* Current service state
|
27
|
-
* @type {string}
|
28
|
-
*/
|
24
|
+
/** @type {string} */
|
29
25
|
state: string;
|
30
|
-
/**
|
31
|
-
|
32
|
-
|
33
|
-
*/
|
26
|
+
/** @type {boolean} */
|
27
|
+
healthy: boolean;
|
28
|
+
/** @type {Error|null} */
|
34
29
|
error: Error | null;
|
35
|
-
/**
|
36
|
-
* Last stable state before error
|
37
|
-
* @type {string|null}
|
38
|
-
* @private
|
39
|
-
*/
|
40
|
-
private _preErrorState;
|
41
|
-
/**
|
42
|
-
* Service logger
|
43
|
-
* @type {Logger}
|
44
|
-
*/
|
30
|
+
/** @type {Logger} */
|
45
31
|
logger: Logger;
|
32
|
+
/** @private @type {number} */
|
33
|
+
private _shutdownTimeout;
|
46
34
|
/**
|
47
|
-
*
|
35
|
+
* Initialize the service with configuration
|
48
36
|
*
|
49
|
-
* @param {
|
50
|
-
* @returns {boolean} True if level was set, false if invalid
|
51
|
-
*/
|
52
|
-
setLogLevel(level: string): boolean;
|
53
|
-
/**
|
54
|
-
* Initialize the service
|
37
|
+
* @param {ServiceConfig} [config={}] - Service-specific configuration
|
55
38
|
*
|
56
|
-
* @
|
57
|
-
* @returns {Promise<boolean>} True if initialized successfully
|
39
|
+
* @returns {Promise<boolean>} True if initialization succeeded
|
58
40
|
*/
|
59
|
-
initialize(config?:
|
41
|
+
initialize(config?: ServiceConfig): Promise<boolean>;
|
60
42
|
/**
|
61
43
|
* Start the service
|
62
44
|
*
|
63
|
-
* @returns {Promise<boolean>} True if started successfully
|
45
|
+
* @returns {Promise<boolean>} True if the service started successfully
|
64
46
|
*/
|
65
47
|
start(): Promise<boolean>;
|
66
48
|
/**
|
67
|
-
* Stop the service
|
49
|
+
* Stop the service with optional timeout
|
68
50
|
*
|
69
|
-
* @
|
51
|
+
* @param {StopOptions} [options={}] - Stop options
|
52
|
+
*
|
53
|
+
* @returns {Promise<boolean>} True if the service stopped successfully
|
70
54
|
*/
|
71
|
-
stop(): Promise<boolean>;
|
55
|
+
stop(options?: StopOptions): Promise<boolean>;
|
72
56
|
/**
|
73
|
-
* Recover the service
|
57
|
+
* Recover the service from error state
|
74
58
|
*
|
75
|
-
* @returns {Promise<boolean>} True if
|
59
|
+
* @returns {Promise<boolean>} True if recovery succeeded
|
76
60
|
*/
|
77
61
|
recover(): Promise<boolean>;
|
78
62
|
/**
|
79
|
-
* Destroy the service
|
63
|
+
* Destroy the service and cleanup resources
|
80
64
|
*
|
81
|
-
* @returns {Promise<boolean>} True if
|
65
|
+
* @returns {Promise<boolean>} True if destruction succeeded
|
82
66
|
*/
|
83
67
|
destroy(): Promise<boolean>;
|
84
68
|
/**
|
85
|
-
*
|
69
|
+
* Get the current health status of the service
|
86
70
|
*
|
87
|
-
* @
|
88
|
-
* @param {Function} handler - Event handler
|
89
|
-
* @returns {Function} Unsubscribe function
|
71
|
+
* @returns {Promise<HealthStatus>} Health status object
|
90
72
|
*/
|
91
|
-
|
73
|
+
getHealth(): Promise<HealthStatus>;
|
92
74
|
/**
|
93
|
-
*
|
75
|
+
* Set the service log level
|
94
76
|
*
|
95
|
-
* @param {string}
|
96
|
-
*
|
97
|
-
* @returns {boolean} True if
|
77
|
+
* @param {string} level - New log level
|
78
|
+
*
|
79
|
+
* @returns {boolean} True if the level was set successfully
|
98
80
|
*/
|
99
|
-
|
81
|
+
setLogLevel(level: string): boolean;
|
100
82
|
/**
|
101
|
-
* Initialize the service (
|
83
|
+
* Initialize the service (override in subclass)
|
102
84
|
*
|
103
85
|
* @protected
|
104
|
-
* @param {
|
86
|
+
* @param {ServiceConfig} config - Service configuration
|
87
|
+
*
|
105
88
|
* @returns {Promise<void>}
|
106
89
|
*/
|
107
|
-
protected _init(config:
|
90
|
+
protected _init(config: ServiceConfig): Promise<void>;
|
108
91
|
/**
|
109
|
-
* Start the service (
|
92
|
+
* Start the service (override in subclass)
|
110
93
|
*
|
111
94
|
* @protected
|
95
|
+
*
|
112
96
|
* @returns {Promise<void>}
|
113
97
|
*/
|
114
98
|
protected _start(): Promise<void>;
|
115
99
|
/**
|
116
|
-
* Stop the service (
|
100
|
+
* Stop the service (override in subclass)
|
117
101
|
*
|
118
102
|
* @protected
|
103
|
+
*
|
119
104
|
* @returns {Promise<void>}
|
120
105
|
*/
|
121
106
|
protected _stop(): Promise<void>;
|
122
107
|
/**
|
123
|
-
* Destroy the service (
|
108
|
+
* Destroy the service (optional override)
|
124
109
|
*
|
125
110
|
* @protected
|
111
|
+
*
|
126
112
|
* @returns {Promise<void>}
|
127
113
|
*/
|
128
114
|
protected _destroy(): Promise<void>;
|
129
115
|
/**
|
130
|
-
* Recover
|
116
|
+
* Recover from error state (optional override)
|
131
117
|
*
|
132
118
|
* @protected
|
119
|
+
*
|
133
120
|
* @returns {Promise<void>}
|
134
121
|
*/
|
135
122
|
protected _recover(): Promise<void>;
|
136
123
|
/**
|
137
|
-
*
|
124
|
+
* Perform health check (optional override)
|
125
|
+
*
|
126
|
+
* @protected
|
127
|
+
*
|
128
|
+
* @returns {Promise<Object>} Additional health information
|
129
|
+
*/
|
130
|
+
protected _healthCheck(): Promise<any>;
|
131
|
+
/**
|
132
|
+
* Set the service state and emit event
|
138
133
|
*
|
139
134
|
* @private
|
140
|
-
* @param {string}
|
135
|
+
* @param {string} newState - New state value
|
141
136
|
*/
|
142
137
|
private _setState;
|
143
138
|
/**
|
144
|
-
* Set
|
139
|
+
* Set the health status and emit event if changed
|
140
|
+
*
|
141
|
+
* @private
|
142
|
+
* @param {boolean} healthy - New health status
|
143
|
+
*/
|
144
|
+
private _setHealthy;
|
145
|
+
/**
|
146
|
+
* Set error state and emit error event
|
145
147
|
*
|
146
148
|
* @private
|
147
149
|
* @param {string} operation - Operation that failed
|
@@ -149,5 +151,13 @@ export default class ServiceBase {
|
|
149
151
|
*/
|
150
152
|
private _setError;
|
151
153
|
}
|
154
|
+
export default ServiceBase;
|
155
|
+
export type ServiceConfig = import("./typedef.js").ServiceConfig;
|
156
|
+
export type ServiceOptions = import("./typedef.js").ServiceOptions;
|
157
|
+
export type StopOptions = import("./typedef.js").StopOptions;
|
158
|
+
export type HealthStatus = import("./typedef.js").HealthStatus;
|
159
|
+
export type StateChangeEvent = import("./typedef.js").StateChangeEvent;
|
160
|
+
export type HealthChangeEvent = import("./typedef.js").HealthChangeEvent;
|
161
|
+
export type ServiceErrorEvent = import("./typedef.js").ServiceErrorEvent;
|
152
162
|
import { EventEmitter } from '../events';
|
153
163
|
import { Logger } from '../logging';
|