@kronos-integration/service 15.2.5 → 15.3.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 +5 -0
- package/package.json +2 -2
- package/src/initialization-context.mjs +1 -1
- package/src/service-logger.mjs +5 -0
- package/src/service-provider-mixin.mjs +68 -8
- package/src/service.mjs +10 -8
- package/types/service-logger.d.mts +8 -1
- package/types/service-provider-mixin.d.mts +105 -21
- package/types/service.d.mts +17 -15
- package/types/standalone-service-provider.d.mts +48 -14
package/README.md
CHANGED
|
@@ -95,6 +95,7 @@ The transitions are:
|
|
|
95
95
|
* [Parameters](#parameters-14)
|
|
96
96
|
* [getCredentials](#getcredentials)
|
|
97
97
|
* [Parameters](#parameters-15)
|
|
98
|
+
* [storePersistentCredentials](#storepersistentcredentials)
|
|
98
99
|
* [log](#log)
|
|
99
100
|
* [Parameters](#parameters-16)
|
|
100
101
|
* [attributes](#attributes)
|
|
@@ -410,6 +411,10 @@ Retrieve all credential attribute values.
|
|
|
410
411
|
|
|
411
412
|
Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** 
|
|
412
413
|
|
|
414
|
+
### storePersistentCredentials
|
|
415
|
+
|
|
416
|
+
Load and store persistent credentials in the service attributes.
|
|
417
|
+
|
|
413
418
|
### log
|
|
414
419
|
|
|
415
420
|
Adds service name to the log event.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/service",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@kronos-integration/endpoint": "^11.0.7",
|
|
41
41
|
"@kronos-integration/interceptor": "^13.1.2",
|
|
42
42
|
"loglevel-mixin": "^7.2.6",
|
|
43
|
-
"pacc": "^6.
|
|
43
|
+
"pacc": "^6.6.0",
|
|
44
44
|
"statetransition-mixin": "^8.1.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
@@ -162,7 +162,7 @@ export const InitializationContext = LogLevelMixin(
|
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
164
|
*
|
|
165
|
-
* @param {string|
|
|
165
|
+
* @param {string|typeof Service} type name if type
|
|
166
166
|
*/
|
|
167
167
|
async getServiceFactory(type) {
|
|
168
168
|
const sp = this.serviceProvider;
|
package/src/service-logger.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { prepareAttributesDefinitions, version_attribute } from "pacc";
|
|
1
2
|
import { Interceptor } from "@kronos-integration/interceptor";
|
|
2
3
|
import { Service } from "./service.mjs";
|
|
3
4
|
import { ServiceLogger } from "./service-logger.mjs";
|
|
@@ -9,8 +10,9 @@ import { InitializationContext } from "./initialization-context.mjs";
|
|
|
9
10
|
* By default a service provider has two build in services
|
|
10
11
|
* 'logger' and 'config'.
|
|
11
12
|
*
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
13
|
+
* @param {typeof Service} superclass
|
|
14
|
+
* @param {typeof ServiceLogger} serviceLoggerClass where the logging houtd go
|
|
15
|
+
* @param {typeof ServiceConfig} serviceConfigClass where the config comes from
|
|
14
16
|
*/
|
|
15
17
|
export function ServiceProviderMixin(
|
|
16
18
|
superclass,
|
|
@@ -18,11 +20,23 @@ export function ServiceProviderMixin(
|
|
|
18
20
|
serviceConfigClass = ServiceConfig
|
|
19
21
|
) {
|
|
20
22
|
return class ServiceProvider extends superclass {
|
|
23
|
+
static attributes = prepareAttributesDefinitions(
|
|
24
|
+
{
|
|
25
|
+
version: version_attribute
|
|
26
|
+
},
|
|
27
|
+
superclass.attributes
|
|
28
|
+
);
|
|
29
|
+
|
|
21
30
|
listeners = {};
|
|
22
31
|
interceptorFactories = {};
|
|
23
32
|
serviceFactories = {};
|
|
24
|
-
services = {};
|
|
33
|
+
/** @typedef {Object} */ services = {};
|
|
25
34
|
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @param {Object} config
|
|
38
|
+
* @param {InitializationContext} [ic]
|
|
39
|
+
*/
|
|
26
40
|
constructor(config, ic = new InitializationContext()) {
|
|
27
41
|
super(Array.isArray(config) ? config[0] : config, ic);
|
|
28
42
|
|
|
@@ -47,6 +61,11 @@ export function ServiceProviderMixin(
|
|
|
47
61
|
configService.configure(config);
|
|
48
62
|
}
|
|
49
63
|
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @param {string} name
|
|
67
|
+
* @param {...any} args
|
|
68
|
+
*/
|
|
50
69
|
emit(name, ...args) {
|
|
51
70
|
const listeners = this.listeners[name];
|
|
52
71
|
if (listeners) {
|
|
@@ -89,11 +108,11 @@ export function ServiceProviderMixin(
|
|
|
89
108
|
/**
|
|
90
109
|
* Register service or interceptor factories.
|
|
91
110
|
*
|
|
92
|
-
* @param {[
|
|
111
|
+
* @param {[typeof Service|string]} factories
|
|
93
112
|
*/
|
|
94
113
|
async registerFactories(factories) {
|
|
95
114
|
for (let factory of factories) {
|
|
96
|
-
if(typeof factory ===
|
|
115
|
+
if (typeof factory === "string") {
|
|
97
116
|
const module = await import(factory);
|
|
98
117
|
factory = new module.default();
|
|
99
118
|
}
|
|
@@ -111,8 +130,8 @@ export function ServiceProviderMixin(
|
|
|
111
130
|
* Registers a interceptor factory for later use by
|
|
112
131
|
* @see {instantiateInterceptor}.
|
|
113
132
|
*
|
|
114
|
-
* @param {
|
|
115
|
-
* @returns {
|
|
133
|
+
* @param {typeof Interceptor} factory
|
|
134
|
+
* @returns {typeof Interceptor} factory
|
|
116
135
|
*/
|
|
117
136
|
registerInterceptorFactory(factory) {
|
|
118
137
|
this.interceptorFactories[factory.name] = factory;
|
|
@@ -120,6 +139,10 @@ export function ServiceProviderMixin(
|
|
|
120
139
|
return factory;
|
|
121
140
|
}
|
|
122
141
|
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @param {typeof Interceptor} factory
|
|
145
|
+
*/
|
|
123
146
|
unregisterInterceptorFactory(factory) {
|
|
124
147
|
delete this.interceptorFactories[factory.name];
|
|
125
148
|
}
|
|
@@ -139,25 +162,51 @@ export function ServiceProviderMixin(
|
|
|
139
162
|
}
|
|
140
163
|
}
|
|
141
164
|
|
|
165
|
+
/**
|
|
166
|
+
*
|
|
167
|
+
* @param {Service} service
|
|
168
|
+
* @param {string} oldState
|
|
169
|
+
* @param {string} newState
|
|
170
|
+
*/
|
|
142
171
|
serviceStateChanged(service, oldState, newState) {
|
|
143
172
|
this.emit("serviceStateChanged", service, oldState, newState);
|
|
144
173
|
}
|
|
145
174
|
|
|
175
|
+
/**
|
|
176
|
+
*
|
|
177
|
+
* @param {typeof Service} factory
|
|
178
|
+
* @returns {Promise<typeof Service>}
|
|
179
|
+
*/
|
|
146
180
|
async registerServiceFactory(factory) {
|
|
147
181
|
this.serviceFactories[factory.name] = factory;
|
|
148
182
|
this.emit("serviceFactoryRegistered", factory);
|
|
149
183
|
return factory;
|
|
150
184
|
}
|
|
151
185
|
|
|
186
|
+
/**
|
|
187
|
+
*
|
|
188
|
+
* @param {typeof Service} factory
|
|
189
|
+
* @returns {Promise<any>}
|
|
190
|
+
*/
|
|
152
191
|
async unregisterServiceFactory(factory) {
|
|
153
192
|
delete this.serviceFactories[factory.name];
|
|
154
193
|
}
|
|
155
194
|
|
|
195
|
+
/**
|
|
196
|
+
*
|
|
197
|
+
* @param {Service} service
|
|
198
|
+
* @returns {Promise<Service>}
|
|
199
|
+
*/
|
|
156
200
|
async registerService(service) {
|
|
157
201
|
this.services[service.name] = service;
|
|
158
202
|
return service;
|
|
159
203
|
}
|
|
160
204
|
|
|
205
|
+
/**
|
|
206
|
+
*
|
|
207
|
+
* @param {string} serviceName
|
|
208
|
+
* @returns {Promise<any>}
|
|
209
|
+
*/
|
|
161
210
|
async unregisterService(serviceName) {
|
|
162
211
|
const service = this.services[serviceName];
|
|
163
212
|
|
|
@@ -171,10 +220,21 @@ export function ServiceProviderMixin(
|
|
|
171
220
|
: Object.keys(this.services).sort();
|
|
172
221
|
}
|
|
173
222
|
|
|
223
|
+
/**
|
|
224
|
+
*
|
|
225
|
+
* @param {string} name
|
|
226
|
+
* @returns {Service|undefined}
|
|
227
|
+
*/
|
|
174
228
|
getService(name) {
|
|
175
229
|
return this.services?.[name];
|
|
176
230
|
}
|
|
177
231
|
|
|
232
|
+
/**
|
|
233
|
+
*
|
|
234
|
+
* @param {Object} config
|
|
235
|
+
* @param {string} config.name
|
|
236
|
+
* @returns {Promise<Service>}
|
|
237
|
+
*/
|
|
178
238
|
async declareService(config) {
|
|
179
239
|
const name = config.name;
|
|
180
240
|
const services = await this.declareServices({ [name]: config });
|
|
@@ -223,7 +283,7 @@ export function ServiceProviderMixin(
|
|
|
223
283
|
|
|
224
284
|
/**
|
|
225
285
|
* Stop all services.
|
|
226
|
-
* @return {Promise} that resolves when all services are stopped
|
|
286
|
+
* @return {Promise<any>} that resolves when all services are stopped
|
|
227
287
|
*/
|
|
228
288
|
async _stop() {
|
|
229
289
|
await Promise.all(
|
package/src/service.mjs
CHANGED
|
@@ -133,11 +133,11 @@ export class Service extends EndpointsMixin(
|
|
|
133
133
|
|
|
134
134
|
/**
|
|
135
135
|
* @param {Object} config
|
|
136
|
-
* @param {string} config.name
|
|
137
|
-
* @param {string} config.logLevel
|
|
138
|
-
* @param {boolean} config.autostart defaults to false
|
|
139
|
-
* @param {string} config.description human readable description
|
|
140
|
-
* @param {Object} config.endpoints will be merged with the build in ones
|
|
136
|
+
* @param {string} [config.name]
|
|
137
|
+
* @param {string} [config.logLevel]
|
|
138
|
+
* @param {boolean} [config.autostart] defaults to false
|
|
139
|
+
* @param {string} [config.description] human readable description
|
|
140
|
+
* @param {Object} [config.endpoints] will be merged with the build in ones
|
|
141
141
|
* @param {InitializationContext} ic
|
|
142
142
|
*/
|
|
143
143
|
constructor(config, ic) {
|
|
@@ -265,7 +265,7 @@ export class Service extends EndpointsMixin(
|
|
|
265
265
|
/**
|
|
266
266
|
* Restart action.
|
|
267
267
|
* default implementation does a _stop() and a _start()
|
|
268
|
-
* @return {Promise} fulfills after start
|
|
268
|
+
* @return {Promise<any>} fulfills after start
|
|
269
269
|
*/
|
|
270
270
|
async _restart() {
|
|
271
271
|
await this._stop();
|
|
@@ -275,7 +275,7 @@ export class Service extends EndpointsMixin(
|
|
|
275
275
|
/**
|
|
276
276
|
* Restarts if in running mode.
|
|
277
277
|
* Otherwise does nothing.
|
|
278
|
-
* @returns {Promise} resolves when restart is done (or immediate if no restart triggered)
|
|
278
|
+
* @returns {Promise<any>} resolves when restart is done (or immediate if no restart triggered)
|
|
279
279
|
*/
|
|
280
280
|
async restartIfRunning() {
|
|
281
281
|
if (this.state === "running") {
|
|
@@ -448,7 +448,8 @@ export class Service extends EndpointsMixin(
|
|
|
448
448
|
}
|
|
449
449
|
|
|
450
450
|
/**
|
|
451
|
-
* Retrieve all credential attribute values.
|
|
451
|
+
* Retrieve all (filtered) credential attribute values.
|
|
452
|
+
* @param {Function} filter
|
|
452
453
|
* @returns {Promise<Object>}
|
|
453
454
|
*/
|
|
454
455
|
async getCredentials(filter = (name, attribute) => attribute.credential) {
|
|
@@ -466,6 +467,7 @@ export class Service extends EndpointsMixin(
|
|
|
466
467
|
|
|
467
468
|
/**
|
|
468
469
|
* Load and store persistent credentials in the service attributes.
|
|
470
|
+
* @return {Promise<undefined>}
|
|
469
471
|
*/
|
|
470
472
|
async storePersistentCredentials() {
|
|
471
473
|
for (const [path, attribute] of attributeIterator(
|
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
* Log receiving service.
|
|
3
3
|
*/
|
|
4
4
|
export class ServiceLogger extends Service {
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} entry
|
|
8
|
+
* @param {string} entry.severity
|
|
9
|
+
*/
|
|
10
|
+
logEntry(entry: {
|
|
11
|
+
severity: string;
|
|
12
|
+
}): Promise<void>;
|
|
6
13
|
}
|
|
7
14
|
import { Service } from './service.mjs';
|
|
@@ -3,18 +3,24 @@
|
|
|
3
3
|
* By default a service provider has two build in services
|
|
4
4
|
* 'logger' and 'config'.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {
|
|
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
|
|
8
9
|
*/
|
|
9
|
-
export function ServiceProviderMixin(superclass:
|
|
10
|
+
export function ServiceProviderMixin(superclass: typeof Service, serviceLoggerClass?: typeof ServiceLogger, serviceConfigClass?: typeof ServiceConfig): {
|
|
10
11
|
new (config: any, ic?: any): {
|
|
11
|
-
|
|
12
|
+
new (): new () => /*elided*/ any;
|
|
12
13
|
listeners: {};
|
|
13
14
|
interceptorFactories: {};
|
|
14
15
|
serviceFactories: {};
|
|
15
|
-
services: {};
|
|
16
|
+
/** @typedef {Object} */ services: {};
|
|
16
17
|
ic: any;
|
|
17
|
-
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
* @param {string} name
|
|
21
|
+
* @param {...any} args
|
|
22
|
+
*/
|
|
23
|
+
emit(name: string, ...args: any[]): void;
|
|
18
24
|
addListener(name: any, listener: any): void;
|
|
19
25
|
removeListener(name: any, listener: any): void;
|
|
20
26
|
/**
|
|
@@ -30,18 +36,22 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
30
36
|
/**
|
|
31
37
|
* Register service or interceptor factories.
|
|
32
38
|
*
|
|
33
|
-
* @param {[
|
|
39
|
+
* @param {[typeof Service|string]} factories
|
|
34
40
|
*/
|
|
35
|
-
registerFactories(factories: [
|
|
41
|
+
registerFactories(factories: [typeof Service | string]): Promise<void>;
|
|
36
42
|
/**
|
|
37
43
|
* Registers a interceptor factory for later use by
|
|
38
44
|
* @see {instantiateInterceptor}.
|
|
39
45
|
*
|
|
40
|
-
* @param {
|
|
41
|
-
* @returns {
|
|
46
|
+
* @param {typeof Interceptor} factory
|
|
47
|
+
* @returns {typeof Interceptor} factory
|
|
42
48
|
*/
|
|
43
|
-
registerInterceptorFactory(factory:
|
|
44
|
-
|
|
49
|
+
registerInterceptorFactory(factory: typeof Interceptor): typeof Interceptor;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param {typeof Interceptor} factory
|
|
53
|
+
*/
|
|
54
|
+
unregisterInterceptorFactory(factory: typeof Interceptor): void;
|
|
45
55
|
/**
|
|
46
56
|
* Instanciates an interceptor from its definition data.
|
|
47
57
|
* @see {interceptorFactories}
|
|
@@ -49,14 +59,53 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
49
59
|
* @returns {Interceptor|undefined}
|
|
50
60
|
*/
|
|
51
61
|
instantiateInterceptor(definition: any): Interceptor | undefined;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @param {Service} service
|
|
65
|
+
* @param {string} oldState
|
|
66
|
+
* @param {string} newState
|
|
67
|
+
*/
|
|
68
|
+
serviceStateChanged(service: Service, oldState: string, newState: string): void;
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {typeof Service} factory
|
|
72
|
+
* @returns {Promise<typeof Service>}
|
|
73
|
+
*/
|
|
74
|
+
registerServiceFactory(factory: typeof Service): Promise<typeof Service>;
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {typeof Service} factory
|
|
78
|
+
* @returns {Promise<any>}
|
|
79
|
+
*/
|
|
80
|
+
unregisterServiceFactory(factory: typeof Service): Promise<any>;
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param {Service} service
|
|
84
|
+
* @returns {Promise<Service>}
|
|
85
|
+
*/
|
|
86
|
+
registerService(service: Service): Promise<Service>;
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
* @param {string} serviceName
|
|
90
|
+
* @returns {Promise<any>}
|
|
91
|
+
*/
|
|
92
|
+
unregisterService(serviceName: string): Promise<any>;
|
|
57
93
|
get serviceNames(): string[];
|
|
58
|
-
|
|
59
|
-
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
* @param {string} name
|
|
97
|
+
* @returns {Service|undefined}
|
|
98
|
+
*/
|
|
99
|
+
getService(name: string): Service | undefined;
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* @param {Object} config
|
|
103
|
+
* @param {string} config.name
|
|
104
|
+
* @returns {Promise<Service>}
|
|
105
|
+
*/
|
|
106
|
+
declareService(config: {
|
|
107
|
+
name: string;
|
|
108
|
+
}): Promise<Service>;
|
|
60
109
|
/**
|
|
61
110
|
* Add a new service based on its configuration.
|
|
62
111
|
* If a service for the name is already present and it has a matching type
|
|
@@ -74,10 +123,45 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
|
|
|
74
123
|
_start(): Promise<any[]>;
|
|
75
124
|
/**
|
|
76
125
|
* Stop all services.
|
|
77
|
-
* @return {Promise} that resolves when all services are stopped
|
|
126
|
+
* @return {Promise<any>} that resolves when all services are stopped
|
|
78
127
|
*/
|
|
79
128
|
_stop(): Promise<any>;
|
|
129
|
+
"__#private@#description": any;
|
|
130
|
+
readonly attributes: any;
|
|
131
|
+
get type(): string;
|
|
132
|
+
description: any;
|
|
133
|
+
get extendetName(): string;
|
|
134
|
+
stateChanged(origin: any, oldState: string, newState: string): void;
|
|
135
|
+
stateTransitionRejection(rejected: any, newState: any): any;
|
|
136
|
+
rejectWrongState(action: string): Promise<void>;
|
|
137
|
+
timeoutForTransition(transition: any): number;
|
|
138
|
+
_restart(): Promise<any>;
|
|
139
|
+
restartIfRunning(): Promise<any>;
|
|
140
|
+
get toStringAttributes(): any;
|
|
141
|
+
toString(): string;
|
|
142
|
+
toJSON(): any;
|
|
143
|
+
toJSONWithOptions(options: {
|
|
144
|
+
includeRuntimeInfo: boolean;
|
|
145
|
+
includeDefaults: boolean;
|
|
146
|
+
includeName: boolean;
|
|
147
|
+
includeConfig: boolean;
|
|
148
|
+
includePrivate: boolean;
|
|
149
|
+
}): any;
|
|
150
|
+
get name(): string;
|
|
151
|
+
get autostart(): boolean;
|
|
152
|
+
_configure(config: any): Set<string>;
|
|
153
|
+
configure(config: any): Promise<undefined>;
|
|
154
|
+
getCredential(key: string): Promise<string | Uint8Array>;
|
|
155
|
+
getCredentials(filter?: Function): Promise<any>;
|
|
156
|
+
storePersistentCredentials(): Promise<undefined>;
|
|
157
|
+
log(level: string, arg: any): void;
|
|
80
158
|
};
|
|
81
|
-
|
|
159
|
+
attributes: any;
|
|
160
|
+
get description(): string;
|
|
161
|
+
get name(): string;
|
|
162
|
+
get endpoints(): any;
|
|
82
163
|
};
|
|
164
|
+
import { Service } from "./service.mjs";
|
|
165
|
+
import { ServiceLogger } from "./service-logger.mjs";
|
|
166
|
+
import { ServiceConfig } from "./service-config.mjs";
|
|
83
167
|
import { Interceptor } from "@kronos-integration/interceptor";
|
package/types/service.d.mts
CHANGED
|
@@ -29,19 +29,19 @@ export class Service extends Service_base {
|
|
|
29
29
|
static get endpoints(): any;
|
|
30
30
|
/**
|
|
31
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
|
|
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
37
|
* @param {InitializationContext} ic
|
|
38
38
|
*/
|
|
39
39
|
constructor(config: {
|
|
40
|
-
name
|
|
41
|
-
logLevel
|
|
42
|
-
autostart
|
|
43
|
-
description
|
|
44
|
-
endpoints
|
|
40
|
+
name?: string;
|
|
41
|
+
logLevel?: string;
|
|
42
|
+
autostart?: boolean;
|
|
43
|
+
description?: string;
|
|
44
|
+
endpoints?: any;
|
|
45
45
|
}, ic: any);
|
|
46
46
|
owner: any;
|
|
47
47
|
instantiateInterceptor(options: any): any;
|
|
@@ -87,13 +87,13 @@ export class Service extends Service_base {
|
|
|
87
87
|
/**
|
|
88
88
|
* Restart action.
|
|
89
89
|
* default implementation does a _stop() and a _start()
|
|
90
|
-
* @return {Promise} fulfills after start
|
|
90
|
+
* @return {Promise<any>} fulfills after start
|
|
91
91
|
*/
|
|
92
92
|
_restart(): Promise<any>;
|
|
93
93
|
/**
|
|
94
94
|
* Restarts if in running mode.
|
|
95
95
|
* Otherwise does nothing.
|
|
96
|
-
* @returns {Promise} resolves when restart is done (or immediate if no restart triggered)
|
|
96
|
+
* @returns {Promise<any>} resolves when restart is done (or immediate if no restart triggered)
|
|
97
97
|
*/
|
|
98
98
|
restartIfRunning(): Promise<any>;
|
|
99
99
|
/**
|
|
@@ -156,14 +156,16 @@ export class Service extends Service_base {
|
|
|
156
156
|
*/
|
|
157
157
|
getCredential(key: string): Promise<string | Uint8Array>;
|
|
158
158
|
/**
|
|
159
|
-
* Retrieve all credential attribute values.
|
|
159
|
+
* Retrieve all (filtered) credential attribute values.
|
|
160
|
+
* @param {Function} filter
|
|
160
161
|
* @returns {Promise<Object>}
|
|
161
162
|
*/
|
|
162
|
-
getCredentials(filter?:
|
|
163
|
+
getCredentials(filter?: Function): Promise<any>;
|
|
163
164
|
/**
|
|
164
165
|
* Load and store persistent credentials in the service attributes.
|
|
166
|
+
* @return {Promise<undefined>}
|
|
165
167
|
*/
|
|
166
|
-
storePersistentCredentials(): Promise<
|
|
168
|
+
storePersistentCredentials(): Promise<undefined>;
|
|
167
169
|
/**
|
|
168
170
|
* Adds service name to the log event.
|
|
169
171
|
* @param {string} level the log level
|
|
@@ -1,39 +1,73 @@
|
|
|
1
1
|
declare const StandaloneServiceProvider_base: {
|
|
2
2
|
new (config: any, ic?: any): {
|
|
3
|
-
|
|
3
|
+
new (): new () => /*elided*/ any;
|
|
4
4
|
listeners: {};
|
|
5
5
|
interceptorFactories: {};
|
|
6
6
|
serviceFactories: {};
|
|
7
7
|
services: {};
|
|
8
8
|
ic: any;
|
|
9
|
-
emit(name:
|
|
9
|
+
emit(name: string, ...args: any[]): void;
|
|
10
10
|
addListener(name: any, listener: any): void;
|
|
11
11
|
removeListener(name: any, listener: any): void;
|
|
12
12
|
get owner(): /*elided*/ any;
|
|
13
13
|
get isServiceProvider(): boolean;
|
|
14
|
-
registerFactories(factories: [
|
|
15
|
-
registerInterceptorFactory(factory:
|
|
16
|
-
unregisterInterceptorFactory(factory:
|
|
14
|
+
registerFactories(factories: [typeof Service | string]): Promise<void>;
|
|
15
|
+
registerInterceptorFactory(factory: typeof import("@kronos-integration/interceptor").Interceptor): typeof import("@kronos-integration/interceptor").Interceptor;
|
|
16
|
+
unregisterInterceptorFactory(factory: typeof import("@kronos-integration/interceptor").Interceptor): void;
|
|
17
17
|
instantiateInterceptor(definition: any): import("@kronos-integration/interceptor").Interceptor | undefined;
|
|
18
|
-
serviceStateChanged(service:
|
|
19
|
-
registerServiceFactory(factory:
|
|
20
|
-
unregisterServiceFactory(factory:
|
|
21
|
-
registerService(service:
|
|
22
|
-
unregisterService(serviceName:
|
|
18
|
+
serviceStateChanged(service: Service, oldState: string, newState: string): void;
|
|
19
|
+
registerServiceFactory(factory: typeof Service): Promise<typeof Service>;
|
|
20
|
+
unregisterServiceFactory(factory: typeof Service): Promise<any>;
|
|
21
|
+
registerService(service: Service): Promise<Service>;
|
|
22
|
+
unregisterService(serviceName: string): Promise<any>;
|
|
23
23
|
get serviceNames(): string[];
|
|
24
|
-
getService(name:
|
|
25
|
-
declareService(config:
|
|
24
|
+
getService(name: string): Service | undefined;
|
|
25
|
+
declareService(config: {
|
|
26
|
+
name: string;
|
|
27
|
+
}): Promise<Service>;
|
|
26
28
|
declareServices(configs: object): Promise<any>;
|
|
27
29
|
_start(): Promise<any[]>;
|
|
28
30
|
_stop(): Promise<any>;
|
|
31
|
+
"__#private@#description": any;
|
|
32
|
+
readonly attributes: any;
|
|
33
|
+
get type(): string;
|
|
34
|
+
description: any;
|
|
35
|
+
get extendetName(): string;
|
|
36
|
+
stateChanged(origin: any, oldState: string, newState: string): void;
|
|
37
|
+
stateTransitionRejection(rejected: any, newState: any): any;
|
|
38
|
+
rejectWrongState(action: string): Promise<void>;
|
|
39
|
+
timeoutForTransition(transition: any): number;
|
|
40
|
+
_restart(): Promise<any>;
|
|
41
|
+
restartIfRunning(): Promise<any>;
|
|
42
|
+
get toStringAttributes(): any;
|
|
43
|
+
toString(): string;
|
|
44
|
+
toJSON(): any;
|
|
45
|
+
toJSONWithOptions(options: {
|
|
46
|
+
includeRuntimeInfo: boolean;
|
|
47
|
+
includeDefaults: boolean;
|
|
48
|
+
includeName: boolean;
|
|
49
|
+
includeConfig: boolean;
|
|
50
|
+
includePrivate: boolean;
|
|
51
|
+
}): any;
|
|
52
|
+
get name(): string;
|
|
53
|
+
get autostart(): boolean;
|
|
54
|
+
_configure(config: any): Set<string>;
|
|
55
|
+
configure(config: any): Promise<undefined>;
|
|
56
|
+
getCredential(key: string): Promise<string | Uint8Array>;
|
|
57
|
+
getCredentials(filter?: Function): Promise<any>;
|
|
58
|
+
storePersistentCredentials(): Promise<undefined>;
|
|
59
|
+
log(level: string, arg: any): void;
|
|
29
60
|
};
|
|
30
|
-
|
|
61
|
+
attributes: any;
|
|
62
|
+
get description(): string;
|
|
63
|
+
get name(): string;
|
|
64
|
+
get endpoints(): any;
|
|
31
65
|
};
|
|
32
66
|
/**
|
|
33
67
|
* Simple service manager (for examples and testing only).
|
|
34
68
|
*/
|
|
35
69
|
export class StandaloneServiceProvider extends StandaloneServiceProvider_base {
|
|
36
|
-
static get description(): string;
|
|
37
70
|
getCredential(key: any): Promise<void>;
|
|
38
71
|
}
|
|
72
|
+
import { Service } from "./service.mjs";
|
|
39
73
|
export {};
|