@kronos-integration/service 15.1.4 → 15.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/package.json +2 -2
- package/src/service-config.mjs +1 -7
- package/src/service.mjs +24 -1
- package/types/service.d.mts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/service",
|
|
3
|
-
"version": "15.1
|
|
3
|
+
"version": "15.2.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@kronos-integration/endpoint": "^11.0.6",
|
|
41
41
|
"@kronos-integration/interceptor": "^13.1.0",
|
|
42
42
|
"loglevel-mixin": "^7.2.6",
|
|
43
|
-
"pacc": "^6.
|
|
43
|
+
"pacc": "^6.3.0",
|
|
44
44
|
"statetransition-mixin": "^8.1.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/service-config.mjs
CHANGED
|
@@ -70,13 +70,7 @@ export class ServiceConfig extends Service {
|
|
|
70
70
|
const service = this.owner.services[name];
|
|
71
71
|
if (service === undefined) {
|
|
72
72
|
delete c.name;
|
|
73
|
-
|
|
74
|
-
const merged = merge(this.preservedConfigs.get(name), c);
|
|
75
|
-
this.trace(
|
|
76
|
-
level => `Preserve config ${name} ${JSON.stringify(merged)}`
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
this.preservedConfigs.set(name, merged);
|
|
73
|
+
this.preservedConfigs.set(name, merge(this.preservedConfigs.get(name), c));
|
|
80
74
|
} else {
|
|
81
75
|
return service.configure(c);
|
|
82
76
|
}
|
package/src/service.mjs
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
prepareAttributesDefinitions,
|
|
6
6
|
getAttributes,
|
|
7
7
|
setAttributes,
|
|
8
|
+
setAttribute,
|
|
8
9
|
description_attribute,
|
|
9
10
|
default_attribute,
|
|
10
11
|
timeout_attribute,
|
|
@@ -196,13 +197,14 @@ export class Service extends EndpointsMixin(
|
|
|
196
197
|
/**
|
|
197
198
|
* Called when the service state changes.
|
|
198
199
|
* Emits a serviceStateChanged event to the owner.
|
|
200
|
+
* @param {any} origin
|
|
199
201
|
* @param {string} oldState
|
|
200
202
|
* @param {string} newState
|
|
201
203
|
*/
|
|
202
204
|
stateChanged(origin, oldState, newState) {
|
|
203
205
|
this.owner.serviceStateChanged(this, oldState, newState);
|
|
204
206
|
this.trace({
|
|
205
|
-
message: `${this.extendetName}:
|
|
207
|
+
message: `${this.extendetName}: ${oldState} -> ${newState}`,
|
|
206
208
|
from: oldState,
|
|
207
209
|
state: newState
|
|
208
210
|
});
|
|
@@ -244,6 +246,8 @@ export class Service extends EndpointsMixin(
|
|
|
244
246
|
* Opens all endpoint connections.
|
|
245
247
|
*/
|
|
246
248
|
async _start() {
|
|
249
|
+
await this.storePersistentCredentials();
|
|
250
|
+
|
|
247
251
|
for (const e of Object.values(this.endpoints)) {
|
|
248
252
|
e.openConnections();
|
|
249
253
|
}
|
|
@@ -460,6 +464,25 @@ export class Service extends EndpointsMixin(
|
|
|
460
464
|
return credentials;
|
|
461
465
|
}
|
|
462
466
|
|
|
467
|
+
async storePersistentCredentials() {
|
|
468
|
+
for (const [path, attribute] of attributeIterator(
|
|
469
|
+
this.attributes,
|
|
470
|
+
(name, attribute) => attribute.credential && attribute.persistent
|
|
471
|
+
)) {
|
|
472
|
+
try {
|
|
473
|
+
const name = path.join(".");
|
|
474
|
+
const credential = await this.getCredential(name);
|
|
475
|
+
|
|
476
|
+
if (credential) {
|
|
477
|
+
this.trace("store credential", name);
|
|
478
|
+
setAttribute(this, name, credential, attribute);
|
|
479
|
+
}
|
|
480
|
+
} catch (err) {
|
|
481
|
+
this.error(err);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
463
486
|
/**
|
|
464
487
|
* Adds service name to the log event.
|
|
465
488
|
* @param {string} level the log level
|
package/types/service.d.mts
CHANGED
|
@@ -58,6 +58,7 @@ export class Service extends Service_base {
|
|
|
58
58
|
/**
|
|
59
59
|
* Called when the service state changes.
|
|
60
60
|
* Emits a serviceStateChanged event to the owner.
|
|
61
|
+
* @param {any} origin
|
|
61
62
|
* @param {string} oldState
|
|
62
63
|
* @param {string} newState
|
|
63
64
|
*/
|
|
@@ -159,6 +160,7 @@ export class Service extends Service_base {
|
|
|
159
160
|
* @returns {Promise<Object>}
|
|
160
161
|
*/
|
|
161
162
|
getCredentials(filter?: (name: any, attribute: any) => any): Promise<any>;
|
|
163
|
+
storePersistentCredentials(): Promise<void>;
|
|
162
164
|
/**
|
|
163
165
|
* Adds service name to the log event.
|
|
164
166
|
* @param {string} level the log level
|