@kronos-integration/service 12.0.5 → 13.0.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/README.md CHANGED
@@ -91,7 +91,7 @@ The transitions are:
91
91
  * [Parameters](#parameters-13)
92
92
  * [log](#log)
93
93
  * [Parameters](#parameters-14)
94
- * [configurationAttributes](#configurationattributes)
94
+ * [attributes](#attributes)
95
95
  * [endpoints](#endpoints-2)
96
96
  * [StandaloneServiceProvider](#standaloneserviceprovider)
97
97
  * [name](#name-3)
@@ -366,7 +366,7 @@ Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
366
366
 
367
367
  Takes attribute values from config parameters
368
368
  and copies them over to the object.
369
- Copying is done according to configurationAttributes.
369
+ Copying is done according to attributes.
370
370
  Which means we loop over all configuration attributes.
371
371
  and then for each attribute decide if we use the default, call a setter function
372
372
  or simply assign the attribute value.
@@ -399,7 +399,7 @@ Adds service name to the log event.
399
399
  * `level` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** the log level
400
400
  * `arg` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** log content
401
401
 
402
- ### configurationAttributes
402
+ ### attributes
403
403
 
404
404
  Meta information for the config attributes.
405
405
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/service",
3
- "version": "12.0.5",
3
+ "version": "13.0.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -36,10 +36,10 @@
36
36
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
37
37
  },
38
38
  "dependencies": {
39
- "@kronos-integration/endpoint": "^10.0.4",
40
- "@kronos-integration/interceptor": "^11.0.4",
39
+ "@kronos-integration/endpoint": "^10.0.5",
40
+ "@kronos-integration/interceptor": "^12.0.1",
41
41
  "loglevel-mixin": "^7.2.5",
42
- "pacc": "^3.7.0",
42
+ "pacc": "^3.9.0",
43
43
  "remove-sensible-values": "^1.3.1",
44
44
  "statetransition-mixin": "^8.1.3"
45
45
  },
package/src/service.mjs CHANGED
@@ -3,52 +3,12 @@ import { prepareActions, StateTransitionMixin } from "statetransition-mixin";
3
3
  import {
4
4
  prepareAttributesDefinitions,
5
5
  getAttributes,
6
- setAttributes
6
+ setAttributes,
7
+ description_attribute
7
8
  } from "pacc";
8
9
  import { EndpointsMixin } from "./endpoints-mixin.mjs";
9
10
  import { InitializationContext } from "./initialization-context.mjs";
10
11
 
11
- const CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
12
- description: {
13
- type: "string",
14
- description: "human readable description of the service"
15
- },
16
- logLevel: {
17
- description: `logging level one of: ${Object.keys(defaultLogLevels)}`,
18
- default: defaultLogLevels.info,
19
- type: "string",
20
- set(newValue) {
21
- if (newValue !== undefined) {
22
- this.logLevel = newValue;
23
- return true;
24
- }
25
- return false;
26
- },
27
- get() {
28
- return this.logLevel.name;
29
- }
30
- },
31
- timeout: {
32
- attributes: {
33
- start: {
34
- description: "service start timeout",
35
- type: "duration",
36
- default: 20
37
- },
38
- stop: {
39
- description: "service stop timeout",
40
- type: "duration",
41
- default: 20
42
- },
43
- restart: {
44
- description: "service restart timeout",
45
- type: "duration",
46
- default: 20
47
- }
48
- }
49
- }
50
- });
51
-
52
12
  const timeout = 30000;
53
13
 
54
14
  const rsfDefault = {
@@ -122,9 +82,43 @@ export class Service extends EndpointsMixin(
122
82
  * The Service class only defines the logLevel, and start/stop/restart timeout attribute
123
83
  * @return {Object}
124
84
  */
125
- static get configurationAttributes() {
126
- return CONFIG_ATTRIBUTES;
127
- }
85
+ static attributes = prepareAttributesDefinitions({
86
+ description: description_attribute,
87
+ logLevel: {
88
+ description: `logging level one of: ${Object.keys(defaultLogLevels)}`,
89
+ default: defaultLogLevels.info,
90
+ type: "string",
91
+ set(newValue) {
92
+ if (newValue !== undefined) {
93
+ this.logLevel = newValue;
94
+ return true;
95
+ }
96
+ return false;
97
+ },
98
+ get() {
99
+ return this.logLevel.name;
100
+ }
101
+ },
102
+ timeout: {
103
+ attributes: {
104
+ start: {
105
+ description: "service start timeout",
106
+ type: "duration",
107
+ default: 20
108
+ },
109
+ stop: {
110
+ description: "service stop timeout",
111
+ type: "duration",
112
+ default: 20
113
+ },
114
+ restart: {
115
+ description: "service restart timeout",
116
+ type: "duration",
117
+ default: 20
118
+ }
119
+ }
120
+ }
121
+ });
128
122
 
129
123
  /**
130
124
  * Definition of the predefined endpoints.
@@ -181,8 +175,8 @@ export class Service extends EndpointsMixin(
181
175
  return this.owner.instantiateInterceptor(options);
182
176
  }
183
177
 
184
- get configurationAttributes() {
185
- return this.constructor.configurationAttributes;
178
+ get attributes() {
179
+ return this.constructor.attributes;
186
180
  }
187
181
 
188
182
  get type() {
@@ -357,7 +351,7 @@ export class Service extends EndpointsMixin(
357
351
  }
358
352
 
359
353
  if (options.includeConfig) {
360
- let atts = getAttributes(this, this.configurationAttributes);
354
+ let atts = getAttributes(this, this.attributes);
361
355
 
362
356
  if (!options.includePrivate) {
363
357
  atts = Object.fromEntries(
@@ -406,7 +400,7 @@ export class Service extends EndpointsMixin(
406
400
  /**
407
401
  * Takes attribute values from config parameters
408
402
  * and copies them over to the object.
409
- * Copying is done according to configurationAttributes.
403
+ * Copying is done according to attributes.
410
404
  * Which means we loop over all configuration attributes.
411
405
  * and then for each attribute decide if we use the default, call a setter function
412
406
  * or simply assign the attribute value.
@@ -415,24 +409,19 @@ export class Service extends EndpointsMixin(
415
409
  */
416
410
  _configure(config) {
417
411
  const modified = new Set();
418
- setAttributes(
419
- this,
420
- config,
421
- this.configurationAttributes,
422
- (ca, path, value) => {
423
- this.trace(level => {
424
- if (ca.private) {
425
- value = "***";
426
- }
427
- return {
428
- message: `config ${this.name}.${path}: ${JSON.stringify(value)}`,
429
- attribute: path,
430
- value: value
431
- };
432
- });
433
- modified.add(ca);
434
- }
435
- );
412
+ setAttributes(this, config, this.attributes, (ca, path, value) => {
413
+ this.trace(level => {
414
+ if (ca.private) {
415
+ value = "***";
416
+ }
417
+ return {
418
+ message: `config ${this.name}.${path}: ${JSON.stringify(value)}`,
419
+ attribute: path,
420
+ value: value
421
+ };
422
+ });
423
+ modified.add(ca);
424
+ });
436
425
  return modified;
437
426
  }
438
427
 
@@ -26,7 +26,7 @@ export class Service extends Service_base {
26
26
  * The Service class only defines the logLevel, and start/stop/restart timeout attribute
27
27
  * @return {Object}
28
28
  */
29
- static get configurationAttributes(): any;
29
+ static attributes: any;
30
30
  /**
31
31
  * Definition of the predefined endpoints.
32
32
  * - log _out_
@@ -38,7 +38,7 @@ export class Service extends Service_base {
38
38
  owner: any;
39
39
  logLevel: any;
40
40
  instantiateInterceptor(options: any): any;
41
- get configurationAttributes(): any;
41
+ get attributes(): any;
42
42
  get type(): string;
43
43
  set description(desc: any);
44
44
  get description(): any;
@@ -124,7 +124,7 @@ export class Service extends Service_base {
124
124
  /**
125
125
  * Takes attribute values from config parameters
126
126
  * and copies them over to the object.
127
- * Copying is done according to configurationAttributes.
127
+ * Copying is done according to attributes.
128
128
  * Which means we loop over all configuration attributes.
129
129
  * and then for each attribute decide if we use the default, call a setter function
130
130
  * or simply assign the attribute value.