@kronos-integration/service 15.5.4 → 15.6.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/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "15.5.4",
3
+ "version": "15.6.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
7
7
  },
8
- "packageManager": "npm@11.10.0",
8
+ "packageManager": "npm@11.16.0",
9
9
  "types": "./types/module.d.mts",
10
10
  "exports": {
11
11
  ".": {
@@ -26,32 +26,33 @@
26
26
  ],
27
27
  "license": "0BSD",
28
28
  "scripts": {
29
- "prepare": "node --run prepare:typescript",
30
- "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
31
29
  "test": "node --run test:ava",
32
30
  "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
33
31
  "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",
34
32
  "docs": "documentation readme --section=API ./src**/*.mjs",
35
- "lint": "node --run lint:docs && node --run lint:typescript",
36
- "lint:docs": "documentation lint ./src**/*.mjs",
37
- "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
33
+ "lint": "node --run lint:docs",
34
+ "lint:docs": "documentation lint ./src**/*.mjs"
38
35
  },
39
36
  "dependencies": {
40
- "@kronos-integration/endpoint": "^11.0.25",
41
- "@kronos-integration/interceptor": "^13.1.30",
37
+ "@kronos-integration/endpoint": "^11.1.2",
38
+ "@kronos-integration/interceptor": "^13.2.2",
42
39
  "loglevel-mixin": "^7.2.11",
43
- "pacc": "^9.2.6",
40
+ "pacc": "^9.2.13",
44
41
  "statetransition-mixin": "^8.1.4"
45
42
  },
46
43
  "devDependencies": {
47
- "ava": "^7.0.0",
44
+ "ava": "^8.0.1",
48
45
  "c8": "^11.0.0",
49
46
  "documentation": "^14.0.3",
50
- "semantic-release": "^25.0.3",
51
- "typescript": "^5.9.3"
47
+ "semantic-release": "^25.0.3"
48
+ },
49
+ "overrides": {
50
+ "c8": {
51
+ "yargs": "^18.0.0"
52
+ }
52
53
  },
53
54
  "engines": {
54
- "node": ">=24.13.1"
55
+ "node": ">=26.1.0"
55
56
  },
56
57
  "repository": {
57
58
  "type": "git",
@@ -64,8 +65,7 @@
64
65
  "template": {
65
66
  "inheritFrom": [
66
67
  "arlac77/template-arlac77-github",
67
- "arlac77/template-kronos-component",
68
- "arlac77/template-typescript"
68
+ "arlac77/template-kronos-component"
69
69
  ]
70
70
  }
71
71
  }
@@ -89,7 +89,7 @@ export const InitializationContext = LogLevelMixin(
89
89
  new DummyReceiveEndpoint(endpoint.name, endpoint.owner)
90
90
  );
91
91
 
92
- this.addOutstandingEndpointConnection(endpoint, connected);
92
+ this.outstandingEndpointConnections.set(endpoint, connected);
93
93
  }
94
94
  }
95
95
 
@@ -114,15 +114,6 @@ export const InitializationContext = LogLevelMixin(
114
114
  }
115
115
  }
116
116
 
117
- /**
118
- *
119
- * @param {Endpoint} endpoint
120
- * @param {string} connected
121
- */
122
- addOutstandingEndpointConnection(endpoint, connected) {
123
- this.outstandingEndpointConnections.set(endpoint, connected);
124
- }
125
-
126
117
  /**
127
118
  * Resolve any outstanding centdpoint connections.
128
119
  */
@@ -1,7 +0,0 @@
1
- /**
2
- * Endpoint accessor mixin.
3
- * Manages endpoints in a container.
4
- * @param {new() => superclass} superclass class to be extended
5
- * @return {new() => superclass} extended class
6
- */
7
- export function EndpointsMixin(superclass: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
@@ -1,4 +0,0 @@
1
- /**
2
- * Keeps track of all in flight object creations and loose ends during config initialization.
3
- */
4
- export const InitializationContext: any;
@@ -1,8 +0,0 @@
1
- export * from "./service.mjs";
2
- export * from "./service-logger.mjs";
3
- export * from "./service-config.mjs";
4
- export * from "./service-provider-mixin.mjs";
5
- export * from "./endpoints-mixin.mjs";
6
- export * from "./standalone-service-provider.mjs";
7
- export * from "./service-consumer-mixin.mjs";
8
- export * from "./initialization-context.mjs";
@@ -1,41 +0,0 @@
1
- /**
2
- * Merge from b into a.
3
- * When *a* and *b* are arrays of values only the none duplicates are appendend to *a*.
4
- * @param {any} a
5
- * @param {any} b
6
- * @return {any} merged b into a
7
- */
8
- export function merge(a: any, b: any): any;
9
- /**
10
- * Config providing service.
11
- * Dispatches config requests to services.
12
- * Also preserves them until a maching service becomes avaliable.
13
- * @property {Map<string,Object>} preservedConfigs values for services not already established
14
- */
15
- export class ServiceConfig extends Service {
16
- preservedConfigs: Map<any, any>;
17
- /**
18
- * Deliver configuration for a given service.
19
- * @param {string} name service name
20
- * @param {Object} config
21
- * @returns {Promise<Object>}
22
- */
23
- configFor(name: string, config: any): Promise<any>;
24
- /**
25
- * Forget about preserved config of a service.
26
- * @param {string} name service name
27
- */
28
- clearPreserved(name: string): void;
29
- /**
30
- * Set config entry.
31
- * @param {string} key path to the value
32
- * @param {any} value
33
- */
34
- configureValue(key: string, value: any): Promise<void>;
35
- /**
36
- *
37
- * @param {Array|Object} config
38
- */
39
- configure(config: any[] | any): Promise<void>;
40
- }
41
- import { Service } from "./service.mjs";
@@ -1,8 +0,0 @@
1
- /**
2
- * Assign services based on a configuration.
3
- * @param {Object} target object
4
- * @param {Object} config service defintion
5
- * @param {Object} provider service provider
6
- * @param {boolean} waitUntilFactoryPresent
7
- */
8
- export function defineServiceConsumerProperties(target: any, config: any, provider: any, waitUntilFactoryPresent: boolean): Promise<any[]>;
@@ -1,14 +0,0 @@
1
- /**
2
- * Log receiving service.
3
- */
4
- export class ServiceLogger extends Service {
5
- /**
6
- *
7
- * @param {Object} entry
8
- * @param {string} entry.severity
9
- */
10
- logEntry(entry: {
11
- severity: string;
12
- }): Promise<void>;
13
- }
14
- import { Service } from "./service.mjs";
@@ -1,168 +0,0 @@
1
- /**
2
- * Provide services and hold service configuration.
3
- * By default a service provider has two build in services
4
- * 'logger' and 'config'.
5
- *
6
- * @param {typeof Service} superclass
7
- * @param {typeof ServiceLogger} serviceLoggerClass where the logging houtd go
8
- * @param {typeof ServiceConfig} serviceConfigClass where the config comes from
9
- */
10
- export function ServiceProviderMixin(superclass: typeof Service, serviceLoggerClass?: typeof ServiceLogger, serviceConfigClass?: typeof ServiceConfig): {
11
- new (config: any, ic?: any): {
12
- new (): new () => /*elided*/ any;
13
- listeners: {};
14
- interceptorFactories: {};
15
- serviceFactories: {};
16
- /** @typedef {Object} */ services: {};
17
- ic: any;
18
- /**
19
- *
20
- * @param {string} name
21
- * @param {...any} args
22
- */
23
- emit(name: string, ...args: any[]): void;
24
- addListener(name: any, listener: any): void;
25
- removeListener(name: any, listener: any): void;
26
- /**
27
- * By default be our own owner.
28
- * @return this
29
- */
30
- get owner(): /*elided*/ any;
31
- /**
32
- * We are the service provider.
33
- * @return {boolean} true
34
- */
35
- get isServiceProvider(): boolean;
36
- serviceInfo(): any;
37
- /**
38
- * Register service or interceptor factories.
39
- *
40
- * @param {[typeof Service|string]} factories
41
- */
42
- registerFactories(factories: [typeof Service | string]): Promise<void>;
43
- /**
44
- * Registers a interceptor factory for later use by
45
- * @see {instantiateInterceptor}.
46
- *
47
- * @param {typeof Interceptor} factory
48
- * @returns {typeof Interceptor} factory
49
- */
50
- registerInterceptorFactory(factory: typeof Interceptor): typeof Interceptor;
51
- /**
52
- *
53
- * @param {typeof Interceptor} factory
54
- */
55
- unregisterInterceptorFactory(factory: typeof Interceptor): void;
56
- /**
57
- * Instanciates an interceptor from its definition data.
58
- * @see {interceptorFactories}
59
- * @param {Object} definition data
60
- * @returns {Interceptor|undefined}
61
- */
62
- instantiateInterceptor(definition: any): Interceptor | undefined;
63
- /**
64
- *
65
- * @param {Service} service
66
- * @param {string} oldState
67
- * @param {string} newState
68
- */
69
- serviceStateChanged(service: Service, oldState: string, newState: string): void;
70
- /**
71
- *
72
- * @param {typeof Service} factory
73
- * @returns {Promise<typeof Service>}
74
- */
75
- registerServiceFactory(factory: typeof Service): Promise<typeof Service>;
76
- /**
77
- *
78
- * @param {typeof Service} factory
79
- * @returns {Promise<any>}
80
- */
81
- unregisterServiceFactory(factory: typeof Service): Promise<any>;
82
- /**
83
- *
84
- * @param {Service} service
85
- * @returns {Promise<Service>}
86
- */
87
- registerService(service: Service): Promise<Service>;
88
- /**
89
- *
90
- * @param {string} serviceName
91
- * @returns {Promise<any>}
92
- */
93
- unregisterService(serviceName: string): Promise<any>;
94
- get serviceNames(): string[];
95
- /**
96
- *
97
- * @param {string} name
98
- * @returns {Service|undefined}
99
- */
100
- getService(name: string): Service | undefined;
101
- /**
102
- *
103
- * @param {Object} config
104
- * @param {string} config.name
105
- * @returns {Promise<Service>}
106
- */
107
- declareService(config: {
108
- name: string;
109
- }): Promise<Service>;
110
- /**
111
- * Add a new service based on its configuration.
112
- * If a service for the name is already present and it has a matching type
113
- * then its configure() is called and returned.
114
- * Otherwise a new service will be created eventually replacing an already existing service with the same name.
115
- * @param {object} configs with
116
- * name - the service name
117
- * type - the service factory name - defaults to config.name
118
- * @return {Promise<Object>} resolving to the declared services
119
- */
120
- declareServices(configs: object): Promise<any>;
121
- /**
122
- * Start all registered services which hanving autostart set.
123
- */
124
- _start(): Promise<any[]>;
125
- /**
126
- * Stop all services.
127
- * @return {Promise<any>} that resolves when all services are stopped
128
- */
129
- _stop(): Promise<any>;
130
- "__#private@#description": any;
131
- readonly attributes: any;
132
- get type(): string;
133
- description: any;
134
- get extendetName(): string;
135
- stateChanged(origin: any, oldState: string, newState: string): void;
136
- stateTransitionRejection(rejected: any, newState: any): any;
137
- rejectWrongState(action: string): Promise<void>;
138
- timeoutForTransition(transition: any): number;
139
- _restart(): Promise<any>;
140
- restartIfRunning(): Promise<any>;
141
- get toStringAttributes(): any;
142
- toString(): string;
143
- toJSON(): any;
144
- toJSONWithOptions(options: {
145
- includeRuntimeInfo: boolean;
146
- includeDefaults: boolean;
147
- includeName: boolean;
148
- includeConfig: boolean;
149
- includePrivate: boolean;
150
- }): any;
151
- get name(): string;
152
- get autostart(): boolean;
153
- _configure(config: any): Set<string>;
154
- configure(config: any): Promise<undefined>;
155
- getCredential(key: string): Promise<string | Uint8Array>;
156
- getCredentials(filter?: Function): Promise<any>;
157
- storePersistentCredentials(): Promise<undefined>;
158
- log(level: string, arg: any): void;
159
- };
160
- attributes: any;
161
- get endpoints(): any;
162
- get description(): string;
163
- get name(): string;
164
- };
165
- import { Service } from "./service.mjs";
166
- import { ServiceLogger } from "./service-logger.mjs";
167
- import { ServiceConfig } from "./service-config.mjs";
168
- import { Interceptor } from "@kronos-integration/interceptor";
@@ -1,177 +0,0 @@
1
- declare const Service_base: new () => new () => /*elided*/ any;
2
- /**
3
- * Service
4
- * The initial state is 'stopped'.
5
- * All services have at least three endpoints:
6
- * - log _out_: log events
7
- * - config _in_: configuration request
8
- * - command _in_: administrative actions to be executed by the step
9
- *
10
- * @property {Object} endpoints
11
- */
12
- export class Service extends Service_base {
13
- static get description(): string;
14
- /**
15
- * Meta information for the config attributes.
16
- * - default optional default value of the attribute
17
- * - needsRestart optional modification requires a service restart
18
- * - setter(newValue,attribute) optional function to be used if simple value assignment is not enough
19
- * The Service class only defines the logLevel, and start/stop/restart timeout attribute
20
- * @return {Object}
21
- */
22
- static attributes: any;
23
- /**
24
- * Definition of the predefined endpoints.
25
- * - log _out_
26
- * - config _in_
27
- * @return {Object} predefined endpoints
28
- */
29
- static get endpoints(): any;
30
- /**
31
- * @param {Object} config
32
- * @param {string} [config.name]
33
- * @param {string} [config.logLevel]
34
- * @param {boolean} [config.autostart] defaults to false
35
- * @param {string} [config.description] human readable description
36
- * @param {Object} [config.endpoints] will be merged with the build in ones
37
- * @param {InitializationContext} ic
38
- */
39
- constructor(config: {
40
- name?: string;
41
- logLevel?: string;
42
- autostart?: boolean;
43
- description?: string;
44
- endpoints?: any;
45
- }, ic: any);
46
- owner: any;
47
- instantiateInterceptor(options: any): any;
48
- get attributes(): any;
49
- get type(): string;
50
- set description(desc: any);
51
- get description(): any;
52
- /**
53
- * Used in human readable state messages.
54
- * Besides the actual service name it may contain additional short hints.
55
- * @return {string}
56
- */
57
- get extendetName(): string;
58
- /**
59
- * Called when the service state changes.
60
- * Emits a serviceStateChanged event to the owner.
61
- * @param {any} origin
62
- * @param {string} oldState
63
- * @param {string} newState
64
- */
65
- stateChanged(origin: any, oldState: string, newState: string): void;
66
- stateTransitionRejection(rejected: any, newState: any): any;
67
- /**
68
- * Called when state transition is not allowed.
69
- * @param {string} action originating action name
70
- * @throws always
71
- */
72
- rejectWrongState(action: string): Promise<void>;
73
- /**
74
- * Deliver transition timeout.
75
- * @param {Object} transition
76
- * @return {number} milliseconds before throwing for a long running transition
77
- */
78
- timeoutForTransition(transition: any): number;
79
- /**
80
- * Opens all endpoint connections.
81
- */
82
- _start(): Promise<void>;
83
- /**
84
- * Closes all endpoint connections.
85
- */
86
- _stop(): Promise<void>;
87
- /**
88
- * Restart action.
89
- * default implementation does a _stop() and a _start()
90
- * @return {Promise<any>} fulfills after start
91
- */
92
- _restart(): Promise<any>;
93
- /**
94
- * Restarts if in running mode.
95
- * Otherwise does nothing.
96
- * @returns {Promise<any>} resolves when restart is done (or immediate if no restart triggered)
97
- */
98
- restartIfRunning(): Promise<any>;
99
- /**
100
- * Mapping of properties used in toString.
101
- * @return {Object}
102
- */
103
- get toStringAttributes(): any;
104
- /**
105
- * Base service is not a provider.
106
- * @return {boolean} false
107
- */
108
- get isServiceProvider(): boolean;
109
- toJSON(): any;
110
- /**
111
- * Deliver json representation.
112
- * @param {Object} options
113
- * @param {boolean} options.includeRuntimeInfo include runtime informtion like state
114
- * @param {boolean} options.includeDefaults include default endpoints
115
- * @param {boolean} options.includeName include name of the service
116
- * @param {boolean} options.includeConfig include config attributes
117
- * @param {boolean} options.includePrivate include private config attributes
118
- * @return {Object} json representation
119
- */
120
- toJSONWithOptions(options: {
121
- includeRuntimeInfo: boolean;
122
- includeDefaults: boolean;
123
- includeName: boolean;
124
- includeConfig: boolean;
125
- includePrivate: boolean;
126
- }): any;
127
- /**
128
- * Should we start when beeing registered.
129
- * @return {boolean} false
130
- */
131
- get autostart(): boolean;
132
- /**
133
- * Takes attribute values from config parameters
134
- * and copies them over to the object.
135
- * Copying is done according to attributes.
136
- * Which means we loop over all configuration attributes.
137
- * and then for each attribute decide if we use the default, call a setter function
138
- * or simply assign the attribute value.
139
- * @param {Object} config
140
- * @return {Set<string>} of modified attributes
141
- */
142
- _configure(config: any): Set<string>;
143
- /**
144
- * Use new configuration.
145
- * Internally calls _configure(config) as the constructor does.
146
- * If attribute with needsRestart are touched the restartIfRunning method
147
- * will be called.
148
- * @param {Object} config
149
- * @return {Promise<undefined>} fillfills when config is applied
150
- */
151
- configure(config: any): Promise<undefined>;
152
- /**
153
- *
154
- * @param {string} key
155
- * @returns {Promise<string|Uint8Array>}
156
- */
157
- getCredential(key: string): Promise<string | Uint8Array>;
158
- /**
159
- * Retrieve all (filtered) credential attribute values.
160
- * @param {Function} filter
161
- * @returns {Promise<Object>}
162
- */
163
- getCredentials(filter?: Function): Promise<any>;
164
- /**
165
- * Load and store persistent credentials in the service attributes.
166
- * @return {Promise<undefined>}
167
- */
168
- storePersistentCredentials(): Promise<undefined>;
169
- /**
170
- * Adds service name to the log event.
171
- * @param {string} level the log level
172
- * @param {Object} arg log content
173
- */
174
- log(level: string, arg: any): void;
175
- #private;
176
- }
177
- export {};
@@ -1,74 +0,0 @@
1
- declare const StandaloneServiceProvider_base: {
2
- new (config: any, ic?: any): {
3
- new (): new () => /*elided*/ any;
4
- listeners: {};
5
- interceptorFactories: {};
6
- serviceFactories: {};
7
- services: {};
8
- ic: any;
9
- emit(name: string, ...args: any[]): void;
10
- addListener(name: any, listener: any): void;
11
- removeListener(name: any, listener: any): void;
12
- get owner(): /*elided*/ any;
13
- get isServiceProvider(): boolean;
14
- serviceInfo(): any;
15
- registerFactories(factories: [typeof Service | string]): Promise<void>;
16
- registerInterceptorFactory(factory: typeof import("@kronos-integration/interceptor").Interceptor): typeof import("@kronos-integration/interceptor").Interceptor;
17
- unregisterInterceptorFactory(factory: typeof import("@kronos-integration/interceptor").Interceptor): void;
18
- instantiateInterceptor(definition: any): import("@kronos-integration/interceptor").Interceptor | undefined;
19
- serviceStateChanged(service: Service, oldState: string, newState: string): void;
20
- registerServiceFactory(factory: typeof Service): Promise<typeof Service>;
21
- unregisterServiceFactory(factory: typeof Service): Promise<any>;
22
- registerService(service: Service): Promise<Service>;
23
- unregisterService(serviceName: string): Promise<any>;
24
- get serviceNames(): string[];
25
- getService(name: string): Service | undefined;
26
- declareService(config: {
27
- name: string;
28
- }): Promise<Service>;
29
- declareServices(configs: object): Promise<any>;
30
- _start(): Promise<any[]>;
31
- _stop(): Promise<any>;
32
- "__#private@#description": any;
33
- readonly attributes: any;
34
- get type(): string;
35
- description: any;
36
- get extendetName(): string;
37
- stateChanged(origin: any, oldState: string, newState: string): void;
38
- stateTransitionRejection(rejected: any, newState: any): any;
39
- rejectWrongState(action: string): Promise<void>;
40
- timeoutForTransition(transition: any): number;
41
- _restart(): Promise<any>;
42
- restartIfRunning(): Promise<any>;
43
- get toStringAttributes(): any;
44
- toString(): string;
45
- toJSON(): any;
46
- toJSONWithOptions(options: {
47
- includeRuntimeInfo: boolean;
48
- includeDefaults: boolean;
49
- includeName: boolean;
50
- includeConfig: boolean;
51
- includePrivate: boolean;
52
- }): any;
53
- get name(): string;
54
- get autostart(): boolean;
55
- _configure(config: any): Set<string>;
56
- configure(config: any): Promise<undefined>;
57
- getCredential(key: string): Promise<string | Uint8Array>;
58
- getCredentials(filter?: Function): Promise<any>;
59
- storePersistentCredentials(): Promise<undefined>;
60
- log(level: string, arg: any): void;
61
- };
62
- attributes: any;
63
- get endpoints(): any;
64
- get description(): string;
65
- get name(): string;
66
- };
67
- /**
68
- * Simple service manager (for examples and testing only).
69
- */
70
- export class StandaloneServiceProvider extends StandaloneServiceProvider_base {
71
- getCredential(key: any): Promise<void>;
72
- }
73
- import { Service } from "./service.mjs";
74
- export {};
package/types/util.d.mts DELETED
@@ -1 +0,0 @@
1
- export function keyValue2Object(key: any, value: any): {};