@kronos-integration/service 11.1.0 → 11.2.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/LICENSE +12 -24
- package/README.md +9 -26
- package/package.json +11 -11
- package/src/service-provider-mixin.mjs +13 -8
- package/types/endpoints-mixin.d.mts +1 -1
- package/types/service-provider-mixin.d.mts +5 -5
- package/types/service.d.mts +1 -1
- package/types/standalone-service-provider.d.mts +3 -3
package/LICENSE
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
Copyright (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
-
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
-
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
-
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
-
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
-
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
-
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
-
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
-
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
24
|
-
|
|
1
|
+
Copyright (C) 2015-2025 by darlenya & arlac77
|
|
2
|
+
|
|
3
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
4
|
+
purpose with or without fee is hereby granted.
|
|
5
|
+
|
|
6
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
7
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
8
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
9
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
10
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
11
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
12
|
+
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
[](https://opensource.org/licenses/BSD-3-Clause)
|
|
1
|
+
[](https://spdx.org/licenses/0BSD.html)
|
|
3
2
|
[](https://typescriptlang.org)
|
|
4
|
-
[](https://bundlejs.com/?q=@kronos-integration/service)
|
|
5
|
-
[](https://npmjs.org/package/@kronos-integration/service)
|
|
6
3
|
[](https://github.com/Kronos-Integration/service/issues)
|
|
7
4
|
[](https://actions-badge.atrox.dev/Kronos-Integration/service/goto)
|
|
8
5
|
[](https://github.com/prettier/prettier)
|
|
@@ -67,18 +64,16 @@ The transitions are:
|
|
|
67
64
|
* [autostart](#autostart-1)
|
|
68
65
|
* [name](#name-1)
|
|
69
66
|
* [endpoints](#endpoints-1)
|
|
70
|
-
* [ServiceProviderMixin](#serviceprovidermixin)
|
|
71
|
-
* [Parameters](#parameters-7)
|
|
72
67
|
* [Service](#service)
|
|
73
|
-
* [Parameters](#parameters-
|
|
68
|
+
* [Parameters](#parameters-7)
|
|
74
69
|
* [Properties](#properties-1)
|
|
75
70
|
* [extendetName](#extendetname)
|
|
76
71
|
* [stateChanged](#statechanged)
|
|
77
|
-
* [Parameters](#parameters-
|
|
72
|
+
* [Parameters](#parameters-8)
|
|
78
73
|
* [rejectWrongState](#rejectwrongstate)
|
|
79
|
-
* [Parameters](#parameters-
|
|
74
|
+
* [Parameters](#parameters-9)
|
|
80
75
|
* [timeoutForTransition](#timeoutfortransition)
|
|
81
|
-
* [Parameters](#parameters-
|
|
76
|
+
* [Parameters](#parameters-10)
|
|
82
77
|
* [\_start](#_start)
|
|
83
78
|
* [\_stop](#_stop)
|
|
84
79
|
* [\_restart](#_restart)
|
|
@@ -87,15 +82,15 @@ The transitions are:
|
|
|
87
82
|
* [isServiceProvider](#isserviceprovider)
|
|
88
83
|
* [toString](#tostring)
|
|
89
84
|
* [toJSONWithOptions](#tojsonwithoptions)
|
|
90
|
-
* [Parameters](#parameters-
|
|
85
|
+
* [Parameters](#parameters-11)
|
|
91
86
|
* [name](#name-2)
|
|
92
87
|
* [autostart](#autostart-2)
|
|
93
88
|
* [\_configure](#_configure)
|
|
94
|
-
* [Parameters](#parameters-
|
|
89
|
+
* [Parameters](#parameters-12)
|
|
95
90
|
* [configure](#configure-1)
|
|
96
|
-
* [Parameters](#parameters-
|
|
91
|
+
* [Parameters](#parameters-13)
|
|
97
92
|
* [log](#log)
|
|
98
|
-
* [Parameters](#parameters-
|
|
93
|
+
* [Parameters](#parameters-14)
|
|
99
94
|
* [configurationAttributes](#configurationattributes)
|
|
100
95
|
* [endpoints](#endpoints-2)
|
|
101
96
|
* [StandaloneServiceProvider](#standaloneserviceprovider)
|
|
@@ -215,18 +210,6 @@ Adds a log input endpoint to the set of Service endpoints.
|
|
|
215
210
|
|
|
216
211
|
Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** predefined endpoints
|
|
217
212
|
|
|
218
|
-
## ServiceProviderMixin
|
|
219
|
-
|
|
220
|
-
Provide services and hold service configuration.
|
|
221
|
-
By default a service provider has two build in services
|
|
222
|
-
'logger' and 'config'.
|
|
223
|
-
|
|
224
|
-
### Parameters
|
|
225
|
-
|
|
226
|
-
* `superclass`  
|
|
227
|
-
* `serviceLoggerClass` (optional, default `ServiceLogger`)
|
|
228
|
-
* `serviceConfigClass` (optional, default `ServiceConfig`)
|
|
229
|
-
|
|
230
213
|
## Service
|
|
231
214
|
|
|
232
215
|
**Extends EndpointsMixin(StateTransitionMixin(LogLevelMixin(class {}), prepareActions({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/service",
|
|
3
|
-
"version": "11.1
|
|
3
|
+
"version": "11.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
],
|
|
26
26
|
"license": "BSD-2-Clause",
|
|
27
27
|
"scripts": {
|
|
28
|
-
"prepare": "
|
|
29
|
-
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule
|
|
30
|
-
"test": "
|
|
28
|
+
"prepare": "node --run prepare:typescript",
|
|
29
|
+
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
|
|
30
|
+
"test": "node --run test:ava",
|
|
31
31
|
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
32
32
|
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
|
|
33
33
|
"docs": "documentation readme --section=API ./src/**/*.mjs",
|
|
34
|
-
"lint": "
|
|
34
|
+
"lint": "node --run lint:docs && node --run lint:typescript",
|
|
35
35
|
"lint:docs": "documentation lint ./src/**/*.mjs",
|
|
36
|
-
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule
|
|
36
|
+
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@kronos-integration/endpoint": "^9.5.
|
|
40
|
-
"@kronos-integration/interceptor": "^10.3.
|
|
39
|
+
"@kronos-integration/endpoint": "^9.5.6",
|
|
40
|
+
"@kronos-integration/interceptor": "^10.3.2",
|
|
41
41
|
"loglevel-mixin": "^7.2.2",
|
|
42
42
|
"model-attributes": "^4.2.2",
|
|
43
43
|
"remove-sensible-values": "^1.3.1",
|
|
@@ -47,11 +47,11 @@
|
|
|
47
47
|
"ava": "^6.1.3",
|
|
48
48
|
"c8": "^10.1.2",
|
|
49
49
|
"documentation": "^14.0.3",
|
|
50
|
-
"semantic-release": "^24.1.
|
|
51
|
-
"typescript": "^5.
|
|
50
|
+
"semantic-release": "^24.1.2",
|
|
51
|
+
"typescript": "^5.7.0-beta"
|
|
52
52
|
},
|
|
53
53
|
"engines": {
|
|
54
|
-
"node": ">=22.
|
|
54
|
+
"node": ">=22.11.0"
|
|
55
55
|
},
|
|
56
56
|
"repository": {
|
|
57
57
|
"type": "git",
|
|
@@ -89,15 +89,20 @@ export function ServiceProviderMixin(
|
|
|
89
89
|
/**
|
|
90
90
|
* Register service or interceptor factories.
|
|
91
91
|
*
|
|
92
|
-
* @param {Function
|
|
92
|
+
* @param {[Function|string]} factories
|
|
93
93
|
*/
|
|
94
|
-
registerFactories(factories) {
|
|
95
|
-
for (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
94
|
+
async registerFactories(factories) {
|
|
95
|
+
for (let factory of factories) {
|
|
96
|
+
if(typeof factory === 'string') {
|
|
97
|
+
const module = await import(factory);
|
|
98
|
+
factory = new module.default();
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const prototype = factory.prototype;
|
|
102
|
+
if (prototype instanceof Interceptor) {
|
|
103
|
+
this.registerInterceptorFactory(factory);
|
|
104
|
+
} else if (prototype instanceof Service) {
|
|
105
|
+
this.registerServiceFactory(factory);
|
|
101
106
|
}
|
|
102
107
|
}
|
|
103
108
|
}
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* @param {new() => superclass} superclass class to be extended
|
|
5
5
|
* @return {new() => superclass} extended class
|
|
6
6
|
*/
|
|
7
|
-
export function EndpointsMixin(superclass: new () => new () => any): new () => new () => any;
|
|
7
|
+
export function EndpointsMixin(superclass: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {new(Object,InitializationContext) => serviceLoggerClass} serviceLoggerClass where the logging houtd go
|
|
7
7
|
* @param {new(Object,InitializationContext) => serviceConfigClass} serviceConfigClass where the config comes from
|
|
8
8
|
*/
|
|
9
|
-
export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (Object: any, InitializationContext: any) => new (Object: any, InitializationContext: any) => any, serviceConfigClass?: new (Object: any, InitializationContext: any) => new (Object: any, InitializationContext: any) => any): {
|
|
9
|
+
export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (Object: any, InitializationContext: any) => new (Object: any, InitializationContext: any) => /*elided*/ any, serviceConfigClass?: new (Object: any, InitializationContext: any) => new (Object: any, InitializationContext: any) => /*elided*/ any): {
|
|
10
10
|
new (config: any, ic?: any): {
|
|
11
11
|
[x: string]: any;
|
|
12
12
|
listeners: {};
|
|
@@ -21,7 +21,7 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
21
21
|
* By default be our own owner.
|
|
22
22
|
* @return this
|
|
23
23
|
*/
|
|
24
|
-
readonly owner: any;
|
|
24
|
+
readonly owner: /*elided*/ any;
|
|
25
25
|
/**
|
|
26
26
|
* We are the service provider.
|
|
27
27
|
* @return {boolean} true
|
|
@@ -30,9 +30,9 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
30
30
|
/**
|
|
31
31
|
* Register service or interceptor factories.
|
|
32
32
|
*
|
|
33
|
-
* @param {Function
|
|
33
|
+
* @param {[Function|string]} factories
|
|
34
34
|
*/
|
|
35
|
-
registerFactories(factories: Function
|
|
35
|
+
registerFactories(factories: [Function | string]): Promise<void>;
|
|
36
36
|
/**
|
|
37
37
|
* Registers a interceptor factory for later use by
|
|
38
38
|
* @see {instantiateInterceptor}.
|
|
@@ -40,7 +40,7 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
40
40
|
* @param {new() => factory} factory
|
|
41
41
|
* @returns {new() => factory} factory
|
|
42
42
|
*/
|
|
43
|
-
registerInterceptorFactory(factory: new () => new () => any): new () => new () => any;
|
|
43
|
+
registerInterceptorFactory(factory: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
|
|
44
44
|
unregisterInterceptorFactory(factory: any): void;
|
|
45
45
|
/**
|
|
46
46
|
* Instanciates an interceptor from its definition data.
|
package/types/service.d.mts
CHANGED
|
@@ -9,10 +9,10 @@ declare const StandaloneServiceProvider_base: {
|
|
|
9
9
|
emit(name: any, ...args: any[]): void;
|
|
10
10
|
addListener(name: any, listener: any): void;
|
|
11
11
|
removeListener(name: any, listener: any): void;
|
|
12
|
-
readonly owner: any;
|
|
12
|
+
readonly owner: /*elided*/ any;
|
|
13
13
|
readonly isServiceProvider: boolean;
|
|
14
|
-
registerFactories(factories: Function
|
|
15
|
-
registerInterceptorFactory(factory: new () => new () => any): new () => new () => any;
|
|
14
|
+
registerFactories(factories: [Function | string]): Promise<void>;
|
|
15
|
+
registerInterceptorFactory(factory: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
|
|
16
16
|
unregisterInterceptorFactory(factory: any): void;
|
|
17
17
|
instantiateInterceptor(definition: any): import("@kronos-integration/interceptor").Interceptor;
|
|
18
18
|
serviceStateChanged(service: any, oldState: any, newState: any): void;
|