@kronos-integration/service 15.2.5 → 15.4.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
@@ -63,19 +63,21 @@ The transitions are:
63
63
  * [defineServiceConsumerProperties](#defineserviceconsumerproperties)
64
64
  * [Parameters](#parameters-6)
65
65
  * [ServiceLogger](#servicelogger)
66
+ * [logEntry](#logentry)
67
+ * [Parameters](#parameters-7)
66
68
  * [autostart](#autostart-1)
67
69
  * [name](#name-1)
68
70
  * [endpoints](#endpoints-1)
69
71
  * [Service](#service)
70
- * [Parameters](#parameters-7)
72
+ * [Parameters](#parameters-8)
71
73
  * [Properties](#properties-1)
72
74
  * [extendetName](#extendetname)
73
75
  * [stateChanged](#statechanged)
74
- * [Parameters](#parameters-8)
75
- * [rejectWrongState](#rejectwrongstate)
76
76
  * [Parameters](#parameters-9)
77
- * [timeoutForTransition](#timeoutfortransition)
77
+ * [rejectWrongState](#rejectwrongstate)
78
78
  * [Parameters](#parameters-10)
79
+ * [timeoutForTransition](#timeoutfortransition)
80
+ * [Parameters](#parameters-11)
79
81
  * [\_start](#_start)
80
82
  * [\_stop](#_stop)
81
83
  * [\_restart](#_restart)
@@ -84,19 +86,20 @@ The transitions are:
84
86
  * [isServiceProvider](#isserviceprovider)
85
87
  * [toString](#tostring)
86
88
  * [toJSONWithOptions](#tojsonwithoptions)
87
- * [Parameters](#parameters-11)
89
+ * [Parameters](#parameters-12)
88
90
  * [name](#name-2)
89
91
  * [autostart](#autostart-2)
90
92
  * [\_configure](#_configure)
91
- * [Parameters](#parameters-12)
92
- * [configure](#configure-1)
93
93
  * [Parameters](#parameters-13)
94
- * [getCredential](#getcredential)
94
+ * [configure](#configure-1)
95
95
  * [Parameters](#parameters-14)
96
- * [getCredentials](#getcredentials)
96
+ * [getCredential](#getcredential)
97
97
  * [Parameters](#parameters-15)
98
- * [log](#log)
98
+ * [getCredentials](#getcredentials)
99
99
  * [Parameters](#parameters-16)
100
+ * [storePersistentCredentials](#storepersistentcredentials)
101
+ * [log](#log)
102
+ * [Parameters](#parameters-17)
100
103
  * [attributes](#attributes)
101
104
  * [endpoints](#endpoints-2)
102
105
  * [StandaloneServiceProvider](#standaloneserviceprovider)
@@ -202,6 +205,14 @@ Assign services based on a configuration.
202
205
 
203
206
  Log receiving service.
204
207
 
208
+ ### logEntry
209
+
210
+ #### Parameters
211
+
212
+ * `entry` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** 
213
+
214
+ * `entry.severity` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
215
+
205
216
  ### autostart
206
217
 
207
218
  We always start immediate.
@@ -309,14 +320,14 @@ Closes all endpoint connections.
309
320
  Restart action.
310
321
  default implementation does a \_stop() and a \_start()
311
322
 
312
- Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** fulfills after start
323
+ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>** fulfills after start
313
324
 
314
325
  ### restartIfRunning
315
326
 
316
327
  Restarts if in running mode.
317
328
  Otherwise does nothing.
318
329
 
319
- Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** resolves when restart is done (or immediate if no restart triggered)
330
+ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>** resolves when restart is done (or immediate if no restart triggered)
320
331
 
321
332
  ### toStringAttributes
322
333
 
@@ -402,14 +413,20 @@ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
402
413
 
403
414
  ### getCredentials
404
415
 
405
- Retrieve all credential attribute values.
416
+ Retrieve all (filtered) credential attribute values.
406
417
 
407
418
  #### Parameters
408
419
 
409
- * `filter` (optional, default `(name,attribute)=>attribute.credential`)
420
+ * `filter` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** (optional, default `(name,attribute)=>attribute.credential`)
410
421
 
411
422
  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)>**&#x20;
412
423
 
424
+ ### storePersistentCredentials
425
+
426
+ Load and store persistent credentials in the service attributes.
427
+
428
+ Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined)>**&#x20;
429
+
413
430
  ### log
414
431
 
415
432
  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.2.5",
3
+ "version": "15.4.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.5.0",
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|(new() => type)} type name if type
165
+ * @param {string|typeof Service} type name if type
166
166
  */
167
167
  async getServiceFactory(type) {
168
168
  const sp = this.serviceProvider;
@@ -27,6 +27,11 @@ export class ServiceLogger extends Service {
27
27
  return e;
28
28
  }
29
29
 
30
+ /**
31
+ *
32
+ * @param {Object} entry
33
+ * @param {string} entry.severity
34
+ */
30
35
  async logEntry(entry)
31
36
  {
32
37
  if (entry.severity === 'error') {
@@ -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 {new(Object,InitializationContext) => serviceLoggerClass} serviceLoggerClass where the logging houtd go
13
- * @param {new(Object,InitializationContext) => serviceConfigClass} serviceConfigClass where the config comes from
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,32 @@ 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
+
30
+ static get endpoints() {
31
+ return {
32
+ ...super.endpoints,
33
+ info: {
34
+ receive: "info"
35
+ }
36
+ };
37
+ }
38
+
21
39
  listeners = {};
22
40
  interceptorFactories = {};
23
41
  serviceFactories = {};
24
- services = {};
42
+ /** @typedef {Object} */ services = {};
25
43
 
44
+ /**
45
+ *
46
+ * @param {Object} config
47
+ * @param {InitializationContext} [ic]
48
+ */
26
49
  constructor(config, ic = new InitializationContext()) {
27
50
  super(Array.isArray(config) ? config[0] : config, ic);
28
51
 
@@ -47,6 +70,11 @@ export function ServiceProviderMixin(
47
70
  configService.configure(config);
48
71
  }
49
72
 
73
+ /**
74
+ *
75
+ * @param {string} name
76
+ * @param {...any} args
77
+ */
50
78
  emit(name, ...args) {
51
79
  const listeners = this.listeners[name];
52
80
  if (listeners) {
@@ -86,14 +114,24 @@ export function ServiceProviderMixin(
86
114
  return true;
87
115
  }
88
116
 
117
+ info() {
118
+ return this.toJSONWithOptions({
119
+ includeRuntimeInfo: false,
120
+ includeDefaults: true,
121
+ includeName: true,
122
+ includeConfig: true,
123
+ includePrivate: false
124
+ });
125
+ }
126
+
89
127
  /**
90
128
  * Register service or interceptor factories.
91
129
  *
92
- * @param {[Function|string]} factories
130
+ * @param {[typeof Service|string]} factories
93
131
  */
94
132
  async registerFactories(factories) {
95
133
  for (let factory of factories) {
96
- if(typeof factory === 'string') {
134
+ if (typeof factory === "string") {
97
135
  const module = await import(factory);
98
136
  factory = new module.default();
99
137
  }
@@ -111,8 +149,8 @@ export function ServiceProviderMixin(
111
149
  * Registers a interceptor factory for later use by
112
150
  * @see {instantiateInterceptor}.
113
151
  *
114
- * @param {new() => factory} factory
115
- * @returns {new() => factory} factory
152
+ * @param {typeof Interceptor} factory
153
+ * @returns {typeof Interceptor} factory
116
154
  */
117
155
  registerInterceptorFactory(factory) {
118
156
  this.interceptorFactories[factory.name] = factory;
@@ -120,6 +158,10 @@ export function ServiceProviderMixin(
120
158
  return factory;
121
159
  }
122
160
 
161
+ /**
162
+ *
163
+ * @param {typeof Interceptor} factory
164
+ */
123
165
  unregisterInterceptorFactory(factory) {
124
166
  delete this.interceptorFactories[factory.name];
125
167
  }
@@ -139,25 +181,51 @@ export function ServiceProviderMixin(
139
181
  }
140
182
  }
141
183
 
184
+ /**
185
+ *
186
+ * @param {Service} service
187
+ * @param {string} oldState
188
+ * @param {string} newState
189
+ */
142
190
  serviceStateChanged(service, oldState, newState) {
143
191
  this.emit("serviceStateChanged", service, oldState, newState);
144
192
  }
145
193
 
194
+ /**
195
+ *
196
+ * @param {typeof Service} factory
197
+ * @returns {Promise<typeof Service>}
198
+ */
146
199
  async registerServiceFactory(factory) {
147
200
  this.serviceFactories[factory.name] = factory;
148
201
  this.emit("serviceFactoryRegistered", factory);
149
202
  return factory;
150
203
  }
151
204
 
205
+ /**
206
+ *
207
+ * @param {typeof Service} factory
208
+ * @returns {Promise<any>}
209
+ */
152
210
  async unregisterServiceFactory(factory) {
153
211
  delete this.serviceFactories[factory.name];
154
212
  }
155
213
 
214
+ /**
215
+ *
216
+ * @param {Service} service
217
+ * @returns {Promise<Service>}
218
+ */
156
219
  async registerService(service) {
157
220
  this.services[service.name] = service;
158
221
  return service;
159
222
  }
160
223
 
224
+ /**
225
+ *
226
+ * @param {string} serviceName
227
+ * @returns {Promise<any>}
228
+ */
161
229
  async unregisterService(serviceName) {
162
230
  const service = this.services[serviceName];
163
231
 
@@ -171,10 +239,21 @@ export function ServiceProviderMixin(
171
239
  : Object.keys(this.services).sort();
172
240
  }
173
241
 
242
+ /**
243
+ *
244
+ * @param {string} name
245
+ * @returns {Service|undefined}
246
+ */
174
247
  getService(name) {
175
248
  return this.services?.[name];
176
249
  }
177
250
 
251
+ /**
252
+ *
253
+ * @param {Object} config
254
+ * @param {string} config.name
255
+ * @returns {Promise<Service>}
256
+ */
178
257
  async declareService(config) {
179
258
  const name = config.name;
180
259
  const services = await this.declareServices({ [name]: config });
@@ -223,7 +302,7 @@ export function ServiceProviderMixin(
223
302
 
224
303
  /**
225
304
  * Stop all services.
226
- * @return {Promise} that resolves when all services are stopped
305
+ * @return {Promise<any>} that resolves when all services are stopped
227
306
  */
228
307
  async _stop() {
229
308
  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
- logEntry(entry: any): Promise<void>;
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 {new(Object,InitializationContext) => serviceLoggerClass} serviceLoggerClass where the logging houtd go
7
- * @param {new(Object,InitializationContext) => serviceConfigClass} serviceConfigClass where the config comes from
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: 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
+ export function ServiceProviderMixin(superclass: typeof Service, serviceLoggerClass?: typeof ServiceLogger, serviceConfigClass?: typeof ServiceConfig): {
10
11
  new (config: any, ic?: any): {
11
- [x: string]: any;
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
- emit(name: any, ...args: any[]): void;
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
  /**
@@ -27,21 +33,26 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
27
33
  * @return {boolean} true
28
34
  */
29
35
  get isServiceProvider(): boolean;
36
+ info(): any;
30
37
  /**
31
38
  * Register service or interceptor factories.
32
39
  *
33
- * @param {[Function|string]} factories
40
+ * @param {[typeof Service|string]} factories
34
41
  */
35
- registerFactories(factories: [Function | string]): Promise<void>;
42
+ registerFactories(factories: [typeof Service | string]): Promise<void>;
36
43
  /**
37
44
  * Registers a interceptor factory for later use by
38
45
  * @see {instantiateInterceptor}.
39
46
  *
40
- * @param {new() => factory} factory
41
- * @returns {new() => factory} factory
47
+ * @param {typeof Interceptor} factory
48
+ * @returns {typeof Interceptor} factory
42
49
  */
43
- registerInterceptorFactory(factory: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
44
- unregisterInterceptorFactory(factory: any): void;
50
+ registerInterceptorFactory(factory: typeof Interceptor): typeof Interceptor;
51
+ /**
52
+ *
53
+ * @param {typeof Interceptor} factory
54
+ */
55
+ unregisterInterceptorFactory(factory: typeof Interceptor): void;
45
56
  /**
46
57
  * Instanciates an interceptor from its definition data.
47
58
  * @see {interceptorFactories}
@@ -49,14 +60,53 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
49
60
  * @returns {Interceptor|undefined}
50
61
  */
51
62
  instantiateInterceptor(definition: any): Interceptor | undefined;
52
- serviceStateChanged(service: any, oldState: any, newState: any): void;
53
- registerServiceFactory(factory: any): Promise<any>;
54
- unregisterServiceFactory(factory: any): Promise<void>;
55
- registerService(service: any): Promise<any>;
56
- unregisterService(serviceName: any): Promise<void>;
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>;
57
94
  get serviceNames(): string[];
58
- getService(name: any): any;
59
- declareService(config: any): Promise<any>;
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>;
60
110
  /**
61
111
  * Add a new service based on its configuration.
62
112
  * If a service for the name is already present and it has a matching type
@@ -74,10 +124,45 @@ export function ServiceProviderMixin(superclass: any, serviceLoggerClass?: new (
74
124
  _start(): Promise<any[]>;
75
125
  /**
76
126
  * Stop all services.
77
- * @return {Promise} that resolves when all services are stopped
127
+ * @return {Promise<any>} that resolves when all services are stopped
78
128
  */
79
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;
80
159
  };
81
- [x: string]: any;
160
+ attributes: any;
161
+ get endpoints(): any;
162
+ get description(): string;
163
+ get name(): string;
82
164
  };
165
+ import { Service } from "./service.mjs";
166
+ import { ServiceLogger } from "./service-logger.mjs";
167
+ import { ServiceConfig } from "./service-config.mjs";
83
168
  import { Interceptor } from "@kronos-integration/interceptor";
@@ -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: string;
41
- logLevel: string;
42
- autostart: boolean;
43
- description: string;
44
- endpoints: any;
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?: (name: any, attribute: any) => any): Promise<any>;
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<void>;
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,74 @@
1
1
  declare const StandaloneServiceProvider_base: {
2
2
  new (config: any, ic?: any): {
3
- [x: string]: any;
3
+ new (): new () => /*elided*/ any;
4
4
  listeners: {};
5
5
  interceptorFactories: {};
6
6
  serviceFactories: {};
7
7
  services: {};
8
8
  ic: any;
9
- emit(name: any, ...args: any[]): void;
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: [Function | string]): Promise<void>;
15
- registerInterceptorFactory(factory: new () => new () => /*elided*/ any): new () => new () => /*elided*/ any;
16
- unregisterInterceptorFactory(factory: any): void;
14
+ info(): 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;
17
18
  instantiateInterceptor(definition: any): import("@kronos-integration/interceptor").Interceptor | undefined;
18
- serviceStateChanged(service: any, oldState: any, newState: any): void;
19
- registerServiceFactory(factory: any): Promise<any>;
20
- unregisterServiceFactory(factory: any): Promise<void>;
21
- registerService(service: any): Promise<any>;
22
- unregisterService(serviceName: any): Promise<void>;
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>;
23
24
  get serviceNames(): string[];
24
- getService(name: any): any;
25
- declareService(config: any): Promise<any>;
25
+ getService(name: string): Service | undefined;
26
+ declareService(config: {
27
+ name: string;
28
+ }): Promise<Service>;
26
29
  declareServices(configs: object): Promise<any>;
27
30
  _start(): Promise<any[]>;
28
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;
29
61
  };
30
- [x: string]: any;
62
+ attributes: any;
63
+ get endpoints(): any;
64
+ get description(): string;
65
+ get name(): string;
31
66
  };
32
67
  /**
33
68
  * Simple service manager (for examples and testing only).
34
69
  */
35
70
  export class StandaloneServiceProvider extends StandaloneServiceProvider_base {
36
- static get description(): string;
37
71
  getCredential(key: any): Promise<void>;
38
72
  }
73
+ import { Service } from "./service.mjs";
39
74
  export {};