@kronos-integration/service 11.0.0 → 11.2.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.
package/README.md CHANGED
@@ -14,6 +14,30 @@
14
14
 
15
15
  Base service implementation
16
16
 
17
+ # Service states
18
+
19
+ ```mermaid
20
+ stateDiagram-v2
21
+ stopped --> starting [1]
22
+ starting --> failed: [2]
23
+ starting --> running: [3]
24
+ running --> stopping: [4]
25
+ running --> failed: [5]
26
+ stopping --> failed: [6]
27
+ stopping --> stopped: [7]
28
+ ```
29
+
30
+ The transitions are:
31
+ | Number | From | To | Condition |
32
+ | ------ | ---- | -- | --------- |
33
+ | 1 | `~stopped~` | `~starting~` | |
34
+ | 2 | `~starting~` | `~failed~` | |
35
+ | 3 | `~starting~` | `~running~` | |
36
+ | 4 | `~running~` | `~stopping~` | |
37
+ | 5 | `~running~` | `~failed~` | |
38
+ | 6 | `~stopping~` | `~failed~` | |
39
+ | 7 | `~stopping~` | `~stopped~` | |
40
+
17
41
  # API
18
42
 
19
43
  <!-- Generated by documentation.js. Update this documentation by updating the source code. -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "11.0.0",
3
+ "version": "11.2.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -36,7 +36,7 @@
36
36
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
37
37
  },
38
38
  "dependencies": {
39
- "@kronos-integration/endpoint": "^9.5.4",
39
+ "@kronos-integration/endpoint": "^9.5.5",
40
40
  "@kronos-integration/interceptor": "^10.3.0",
41
41
  "loglevel-mixin": "^7.2.2",
42
42
  "model-attributes": "^4.2.2",
@@ -45,13 +45,13 @@
45
45
  },
46
46
  "devDependencies": {
47
47
  "ava": "^6.1.3",
48
- "c8": "^9.1.0",
48
+ "c8": "^10.1.2",
49
49
  "documentation": "^14.0.3",
50
- "semantic-release": "^23.1.1",
51
- "typescript": "^5.4.5"
50
+ "semantic-release": "^24.1.1",
51
+ "typescript": "^5.6.2"
52
52
  },
53
53
  "engines": {
54
- "node": ">=22.2.0"
54
+ "node": ">=22.9.0"
55
55
  },
56
56
  "repository": {
57
57
  "type": "git",
@@ -232,7 +232,7 @@ export const InitializationContext = LogLevelMixin(
232
232
  * @param {string} name service name
233
233
  * @return {Promise<Service|undefined>}
234
234
  */
235
- async declareService(config, name) {
235
+ async declareService(config={}, name) {
236
236
  const sp = this.serviceProvider;
237
237
  let service = sp.getService(name);
238
238
 
@@ -89,15 +89,20 @@ export function ServiceProviderMixin(
89
89
  /**
90
90
  * Register service or interceptor factories.
91
91
  *
92
- * @param {Function[]} factories
92
+ * @param {[Function|string]} factories
93
93
  */
94
- registerFactories(factories) {
95
- for (const f of factories) {
96
- const p = f.prototype;
97
- if (p instanceof Interceptor) {
98
- this.registerInterceptorFactory(f);
99
- } else if (p instanceof Service) {
100
- this.registerServiceFactory(f);
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
  }
@@ -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, InitializationContext) => new (Object: any, InitializationContext: any) => any, serviceConfigClass?: new (Object, InitializationContext) => new (Object: any, InitializationContext: any) => any): {
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): {
10
10
  new (config: any, ic?: any): {
11
11
  [x: string]: any;
12
12
  listeners: {};
@@ -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[]} factories
33
+ * @param {[Function|string]} factories
34
34
  */
35
- registerFactories(factories: Function[]): void;
35
+ registerFactories(factories: [Function | string]): Promise<void>;
36
36
  /**
37
37
  * Registers a interceptor factory for later use by
38
38
  * @see {instantiateInterceptor}.
@@ -11,8 +11,8 @@ declare const StandaloneServiceProvider_base: {
11
11
  removeListener(name: any, listener: any): void;
12
12
  readonly owner: any;
13
13
  readonly isServiceProvider: boolean;
14
- registerFactories(factories: Function[]): void;
15
- registerInterceptorFactory(factory: new () => any): new () => new () => any;
14
+ registerFactories(factories: [Function | string]): Promise<void>;
15
+ registerInterceptorFactory(factory: new () => new () => any): new () => new () => 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;
@@ -23,7 +23,7 @@ declare const StandaloneServiceProvider_base: {
23
23
  readonly serviceNames: string[];
24
24
  getService(name: any): any;
25
25
  declareService(config: any): Promise<any>;
26
- declareServices(configs: any): Promise<any>;
26
+ declareServices(configs: object): Promise<any>;
27
27
  _start(): Promise<any[]>;
28
28
  _stop(): Promise<any>;
29
29
  };