@hkdigital/lib-core 0.4.49 → 0.4.51
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/network/http/json-request.js +1 -0
- package/dist/network/http/typedef.d.ts +3 -3
- package/dist/network/http/typedef.js +3 -3
- package/dist/network/loaders/image/ImageScene.svelte.js +0 -1
- package/dist/services/manager-plugins/ConfigPlugin.d.ts +1 -1
- package/dist/services/service-base/ServiceBase.d.ts +1 -1
- package/dist/services/service-base/ServiceBase.js +6 -4
- package/dist/services/service-base/typedef.d.ts +2 -1
- package/dist/services/service-base/typedef.js +2 -1
- package/dist/services/service-manager/ServiceManager.d.ts +4 -4
- package/dist/services/service-manager/ServiceManager.js +5 -3
- package/dist/services/service-manager/typedef.d.ts +5 -5
- package/dist/services/service-manager/typedef.js +10 -5
- package/dist/ui/primitives/icons/SteezeIcon.svelte +4 -3
- package/dist/ui/primitives/icons/SteezeIcon.svelte.d.ts +8 -6
- package/package.json +1 -1
|
@@ -165,6 +165,7 @@ export async function jsonPost(options) {
|
|
|
165
165
|
// Apply JSON-specific defaults and validation
|
|
166
166
|
expect.defined(body);
|
|
167
167
|
|
|
168
|
+
/** @type {Record<string, string>} */
|
|
168
169
|
const jsonHeaders = headers || {};
|
|
169
170
|
jsonHeaders[ACCEPT] = APPLICATION_JSON;
|
|
170
171
|
jsonHeaders[CONTENT_TYPE] = APPLICATION_JSON;
|
|
@@ -18,7 +18,7 @@ export type HttpRequestOptions = {
|
|
|
18
18
|
/**
|
|
19
19
|
* HTTP headers as name-value pairs
|
|
20
20
|
*/
|
|
21
|
-
headers?:
|
|
21
|
+
headers?: Record<string, string> | undefined;
|
|
22
22
|
/**
|
|
23
23
|
* Whether to include credentials
|
|
24
24
|
*/
|
|
@@ -79,7 +79,7 @@ export type JsonGetOptions = {
|
|
|
79
79
|
/**
|
|
80
80
|
* HTTP headers as name-value pairs
|
|
81
81
|
*/
|
|
82
|
-
headers?:
|
|
82
|
+
headers?: Record<string, string> | undefined;
|
|
83
83
|
/**
|
|
84
84
|
* Whether to include credentials
|
|
85
85
|
*/
|
|
@@ -129,7 +129,7 @@ export type JsonPostOptions = {
|
|
|
129
129
|
/**
|
|
130
130
|
* HTTP headers as name-value pairs
|
|
131
131
|
*/
|
|
132
|
-
headers?:
|
|
132
|
+
headers?: Record<string, string> | undefined;
|
|
133
133
|
/**
|
|
134
134
|
* Whether to include credentials
|
|
135
135
|
*/
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Parameters to add to the URL
|
|
8
8
|
*
|
|
9
9
|
* @property {*} [body] Request body (for POST, PUT, etc.)
|
|
10
|
-
* @property {
|
|
10
|
+
* @property {Record<string, string>} [headers] HTTP headers as name-value pairs
|
|
11
11
|
* @property {boolean} [withCredentials] Whether to include credentials
|
|
12
12
|
* @property {number} [timeoutMs] Request timeout in milliseconds
|
|
13
13
|
* @property {Function} [requestHandler] Handler for abort/timeout control
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
* @property {Object|URLSearchParams} [urlSearchParams]
|
|
42
42
|
* Parameters to add to the URL
|
|
43
43
|
*
|
|
44
|
-
* @property {
|
|
44
|
+
* @property {Record<string, string>} [headers] HTTP headers as name-value pairs
|
|
45
45
|
* @property {boolean} [withCredentials] Whether to include credentials
|
|
46
46
|
* @property {number} [timeoutMs] Request timeout in milliseconds
|
|
47
47
|
* @property {RequestHandler} [requestHandler] Handler for abort/timeout control
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
* @property {Object|URLSearchParams} [urlSearchParams]
|
|
61
61
|
* Parameters to add to the URL
|
|
62
62
|
*
|
|
63
|
-
* @property {
|
|
63
|
+
* @property {Record<string, string>} [headers] HTTP headers as name-value pairs
|
|
64
64
|
* @property {boolean} [withCredentials] Whether to include credentials
|
|
65
65
|
* @property {number} [timeoutMs] Request timeout in milliseconds
|
|
66
66
|
* @property {RequestHandler} [requestHandler] Handler for abort/timeout control
|
|
@@ -14,7 +14,7 @@ export class ServiceBase extends EventEmitter {
|
|
|
14
14
|
* Create a new service instance
|
|
15
15
|
*
|
|
16
16
|
* @param {string} name - Service name
|
|
17
|
-
* @param {import('./typedef.js').ServiceOptions} [options
|
|
17
|
+
* @param {import('./typedef.js').ServiceOptions} [options]
|
|
18
18
|
*/
|
|
19
19
|
constructor(name: string, options?: import("./typedef.js").ServiceOptions);
|
|
20
20
|
/** @type {string} */
|
|
@@ -93,9 +93,9 @@ export class ServiceBase extends EventEmitter {
|
|
|
93
93
|
* Create a new service instance
|
|
94
94
|
*
|
|
95
95
|
* @param {string} name - Service name
|
|
96
|
-
* @param {import('./typedef.js').ServiceOptions} [options
|
|
96
|
+
* @param {import('./typedef.js').ServiceOptions} [options]
|
|
97
97
|
*/
|
|
98
|
-
constructor(name, options
|
|
98
|
+
constructor(name, options) {
|
|
99
99
|
super();
|
|
100
100
|
|
|
101
101
|
if( typeof name !== 'string' )
|
|
@@ -119,10 +119,12 @@ export class ServiceBase extends EventEmitter {
|
|
|
119
119
|
this.error = null;
|
|
120
120
|
|
|
121
121
|
/** @type {Logger} */
|
|
122
|
-
this.logger = new Logger(name, options
|
|
122
|
+
this.logger = new Logger(name, options?.logLevel || INFO);
|
|
123
123
|
|
|
124
124
|
/** @private @type {number} */
|
|
125
|
-
this._shutdownTimeout = options
|
|
125
|
+
this._shutdownTimeout = options?.shutdownTimeout || 5000;
|
|
126
|
+
|
|
127
|
+
// this.manager = options.manager;
|
|
126
128
|
}
|
|
127
129
|
|
|
128
130
|
/**
|
|
@@ -19,10 +19,11 @@ export type ServiceState = "not-created" | "created" | "configuring" | "configur
|
|
|
19
19
|
* Options for creating a service instance
|
|
20
20
|
*/
|
|
21
21
|
export type ServiceOptions = {
|
|
22
|
+
manager: import("../service-manager/ServiceManager.js").default;
|
|
22
23
|
/**
|
|
23
24
|
* - Initial log level for the service
|
|
24
25
|
*/
|
|
25
|
-
logLevel?:
|
|
26
|
+
logLevel?: import("../../logging/typedef.js").LogLevel | undefined;
|
|
26
27
|
/**
|
|
27
28
|
* - Timeout for graceful shutdown
|
|
28
29
|
*/
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
* Options for creating a service instance
|
|
54
54
|
*
|
|
55
55
|
* @typedef {Object} ServiceOptions
|
|
56
|
-
* @property {
|
|
56
|
+
* @property {import('../service-manager/ServiceManager.js').default} manager
|
|
57
|
+
* @property {import('../../logging/typedef.js').LogLevel} [logLevel] - Initial log level for the service
|
|
57
58
|
* @property {number} [shutdownTimeout=5000] - Timeout for graceful shutdown
|
|
58
59
|
*/
|
|
59
60
|
|
|
@@ -78,12 +78,12 @@ export class ServiceManager extends EventEmitter {
|
|
|
78
78
|
/**
|
|
79
79
|
* Get or create a service instance
|
|
80
80
|
*
|
|
81
|
+
* @template {import('../service-base/typedef.js').ServiceInstance} T
|
|
81
82
|
* @param {string} name - Service name
|
|
82
83
|
*
|
|
83
|
-
* @returns {
|
|
84
|
-
* Service instance or null if not found
|
|
84
|
+
* @returns {T|null} Service instance or null if not found
|
|
85
85
|
*/
|
|
86
|
-
get
|
|
86
|
+
get<T extends import("../service-base/typedef.js").ServiceInstance>(name: string): T | null;
|
|
87
87
|
/**
|
|
88
88
|
* Configure a service
|
|
89
89
|
*
|
|
@@ -217,7 +217,7 @@ export type LogLevel = import("../../logging/typedef.js").LogLevel;
|
|
|
217
217
|
export type ServiceConstructor = import("./typedef.js").ServiceConstructor;
|
|
218
218
|
export type ServiceRegistrationOptions = import("./typedef.js").ServiceRegistrationOptions;
|
|
219
219
|
export type ServiceManagerConfig = import("./typedef.js").ServiceManagerConfig;
|
|
220
|
-
export type ServiceEntry =
|
|
220
|
+
export type ServiceEntry = any;
|
|
221
221
|
export type ServiceConfigOrLabel = import("./typedef.js").ServiceConfigOrLabel;
|
|
222
222
|
export type HealthCheckResult = import("./typedef.js").HealthCheckResult;
|
|
223
223
|
export type StopOptions = import("../service-base/typedef.js").StopOptions;
|
|
@@ -258,10 +258,10 @@ export class ServiceManager extends EventEmitter {
|
|
|
258
258
|
/**
|
|
259
259
|
* Get or create a service instance
|
|
260
260
|
*
|
|
261
|
+
* @template {import('../service-base/typedef.js').ServiceInstance} T
|
|
261
262
|
* @param {string} name - Service name
|
|
262
263
|
*
|
|
263
|
-
* @returns {
|
|
264
|
-
* Service instance or null if not found
|
|
264
|
+
* @returns {T|null} Service instance or null if not found
|
|
265
265
|
*/
|
|
266
266
|
get(name) {
|
|
267
267
|
// @throws service not found
|
|
@@ -269,7 +269,9 @@ export class ServiceManager extends EventEmitter {
|
|
|
269
269
|
|
|
270
270
|
if (!entry.instance) {
|
|
271
271
|
try {
|
|
272
|
-
|
|
272
|
+
const options = { manager: this };
|
|
273
|
+
|
|
274
|
+
entry.instance = new entry.ServiceClass(name, options);
|
|
273
275
|
|
|
274
276
|
// Apply log level
|
|
275
277
|
const logLevel = this.#getServiceLogLevel(name);
|
|
@@ -84,23 +84,23 @@ export type ServiceManagerPlugin = {
|
|
|
84
84
|
*/
|
|
85
85
|
detach: () => void;
|
|
86
86
|
/**
|
|
87
|
-
* - Optional config resolution
|
|
87
|
+
* - Optional config resolution
|
|
88
88
|
*/
|
|
89
|
-
resolveServiceConfig?: ((arg0: string, arg1: ServiceEntry
|
|
89
|
+
resolveServiceConfig?: ((arg0: string, arg1: ServiceEntry<import("../service-base/typedef.js").ServiceInstance>, arg2: any) => Promise<any | undefined>) | undefined;
|
|
90
90
|
};
|
|
91
91
|
/**
|
|
92
92
|
* Internal service registry entry, an internal registry entry that the
|
|
93
93
|
* ServiceManager uses to track each registered service.
|
|
94
94
|
*/
|
|
95
|
-
export type ServiceEntry = {
|
|
95
|
+
export type ServiceEntry<T extends import("../service-base/typedef.js").ServiceInstance> = {
|
|
96
96
|
/**
|
|
97
97
|
* - Service class constructor
|
|
98
98
|
*/
|
|
99
|
-
ServiceClass:
|
|
99
|
+
ServiceClass: new (name: string, options?: any) => T;
|
|
100
100
|
/**
|
|
101
101
|
* - Service instance (lazy-created)
|
|
102
102
|
*/
|
|
103
|
-
instance:
|
|
103
|
+
instance: T | null;
|
|
104
104
|
serviceConfigOrLabel: ServiceConfigOrLabel;
|
|
105
105
|
dependencies: string[];
|
|
106
106
|
/**
|
|
@@ -64,13 +64,15 @@
|
|
|
64
64
|
|
|
65
65
|
/**
|
|
66
66
|
* Result of health check for all services
|
|
67
|
-
* @typedef {Object<string,
|
|
67
|
+
* @typedef {Object<string,
|
|
68
|
+
* import('../service-base/typedef.js').HealthStatus>} HealthCheckResult
|
|
68
69
|
*/
|
|
69
70
|
|
|
70
71
|
/**
|
|
71
72
|
* Service class constructor type
|
|
72
73
|
*
|
|
73
|
-
* @typedef {new (name: string, options?: import('../service-base/typedef.js').ServiceOptions)
|
|
74
|
+
* @typedef {new (name: string, options?: import('../service-base/typedef.js').ServiceOptions)
|
|
75
|
+
* => import('../service-base/typedef.js').ServiceInstance} ServiceConstructor
|
|
74
76
|
*/
|
|
75
77
|
|
|
76
78
|
/**
|
|
@@ -81,7 +83,9 @@
|
|
|
81
83
|
* @property {import('./ServiceManager.js').ServiceManager|null} manager - ServiceManager reference
|
|
82
84
|
* @property {function(import('./ServiceManager.js').ServiceManager): void} attach - Attach to ServiceManager
|
|
83
85
|
* @property {function(): void} detach - Detach from ServiceManager
|
|
84
|
-
* @property {function(string,
|
|
86
|
+
* @property {function(string,
|
|
87
|
+
* ServiceEntry<import('../service-base/typedef.js').ServiceInstance>, *
|
|
88
|
+
* ): Promise<*|undefined>} [resolveServiceConfig] - Optional config resolution
|
|
85
89
|
*/
|
|
86
90
|
|
|
87
91
|
// ============================================================================
|
|
@@ -92,9 +96,10 @@
|
|
|
92
96
|
* Internal service registry entry, an internal registry entry that the
|
|
93
97
|
* ServiceManager uses to track each registered service.
|
|
94
98
|
*
|
|
99
|
+
* @template {import('../service-base/typedef.js').ServiceInstance} T
|
|
95
100
|
* @typedef {Object} ServiceEntry
|
|
96
|
-
* @property {
|
|
97
|
-
* @property {
|
|
101
|
+
* @property {new (name: string, options?: *) => T} ServiceClass - Service class constructor
|
|
102
|
+
* @property {T|null} instance - Service instance (lazy-created)
|
|
98
103
|
* @property {ServiceConfigOrLabel} serviceConfigOrLabel
|
|
99
104
|
* @property {string[]} dependencies
|
|
100
105
|
* @property {Set<string>} dependents - Services that depend on this service
|
|
@@ -23,11 +23,12 @@
|
|
|
23
23
|
* theme - name of the icon theme (e.g. 'solid' or 'outline')
|
|
24
24
|
*
|
|
25
25
|
* @type {{
|
|
26
|
-
* src: import('./typedef.js').IconSource,
|
|
27
|
-
* size?: string,
|
|
28
|
-
* theme?: string,
|
|
29
26
|
* base?: string,
|
|
30
27
|
* classes?: string
|
|
28
|
+
* size?: string,
|
|
29
|
+
* variant?: string,
|
|
30
|
+
* src: import('./typedef.js').IconSource,
|
|
31
|
+
* theme?: string,
|
|
31
32
|
* } & { [attr: string]: any }}
|
|
32
33
|
*/
|
|
33
34
|
let {
|
|
@@ -2,21 +2,23 @@ export default SteezeIcon;
|
|
|
2
2
|
type SteezeIcon = {
|
|
3
3
|
$on?(type: string, callback: (e: any) => void): () => void;
|
|
4
4
|
$set?(props: Partial<{
|
|
5
|
-
src: IconSource;
|
|
6
|
-
size?: string | undefined;
|
|
7
|
-
theme?: string | undefined;
|
|
8
5
|
base?: string | undefined;
|
|
9
6
|
classes?: string | undefined;
|
|
7
|
+
size?: string | undefined;
|
|
8
|
+
variant?: string | undefined;
|
|
9
|
+
src: IconSource;
|
|
10
|
+
theme?: string | undefined;
|
|
10
11
|
} & {
|
|
11
12
|
[attr: string]: any;
|
|
12
13
|
}>): void;
|
|
13
14
|
};
|
|
14
15
|
declare const SteezeIcon: import("svelte").Component<{
|
|
15
|
-
src: import("./typedef.js").IconSource;
|
|
16
|
-
size?: string;
|
|
17
|
-
theme?: string;
|
|
18
16
|
base?: string;
|
|
19
17
|
classes?: string;
|
|
18
|
+
size?: string;
|
|
19
|
+
variant?: string;
|
|
20
|
+
src: import("./typedef.js").IconSource;
|
|
21
|
+
theme?: string;
|
|
20
22
|
} & {
|
|
21
23
|
[attr: string]: any;
|
|
22
24
|
}, {}, "">;
|