@kronos-integration/interceptor 11.0.3 → 12.0.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,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/interceptor",
3
- "version": "11.0.3",
3
+ "version": "12.0.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,7 +39,7 @@
39
39
  "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
40
40
  },
41
41
  "dependencies": {
42
- "pacc": "^3.6.7"
42
+ "pacc": "^3.8.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@kronos-integration/test-interceptor": "^7.0.30",
@@ -14,7 +14,7 @@ export class Interceptor {
14
14
  * Meta description of the configuration
15
15
  * @return {Object}
16
16
  */
17
- static get configurationAttributes() {
17
+ static get attributes() {
18
18
  return {};
19
19
  }
20
20
 
@@ -36,21 +36,21 @@ export class Interceptor {
36
36
  * Meta description of the configuration.
37
37
  * @return {Object}
38
38
  */
39
- get configurationAttributes() {
40
- return this.constructor.configurationAttributes;
39
+ get attributes() {
40
+ return this.constructor.attributes;
41
41
  }
42
42
 
43
43
  /**
44
44
  * Takes attribute values from config parameters
45
45
  * and copies them over to the object.
46
- * Copying is done according to configurationAttributes.
46
+ * Copying is done according to attributes.
47
47
  * Which means we loop over all configuration attributes
48
48
  * and then for each attribute decide if we use the default, call
49
49
  * a setter function or simply assign the attribute value.
50
50
  * @param {Object?} config
51
51
  */
52
52
  configure(config) {
53
- setAttributes(this, config, this.configurationAttributes);
53
+ setAttributes(this, config, this.attributes);
54
54
  }
55
55
 
56
56
  toString() {
@@ -72,7 +72,7 @@ export class Interceptor {
72
72
  return { type: this.type };
73
73
  }
74
74
 
75
- let atts = getAttributes(this, this.configurationAttributes);
75
+ let atts = getAttributes(this, this.attributes);
76
76
 
77
77
  if (!options.includePrivate) {
78
78
  atts = Object.fromEntries(
@@ -1,6 +1,23 @@
1
- import { mergeAttributeDefinitions, prepareAttributesDefinitions } from "pacc";
1
+ import { prepareAttributesDefinitions } from "pacc";
2
2
  import { Interceptor } from "./interceptor.mjs";
3
3
 
4
+ const ATTRIBUTES = prepareAttributesDefinitions({
5
+ limits: {
6
+ default: [
7
+ {
8
+ count: 10
9
+ }
10
+ ],
11
+ count: {
12
+ type: "unsigned-integer"
13
+ },
14
+ delay: {
15
+ type: "duration"
16
+ }
17
+ },
18
+ ...Interceptor.attributes
19
+ });
20
+
4
21
  /**
5
22
  * Limits the number of concurrent requests.
6
23
  * Requests can be delayed or rejected.
@@ -24,37 +41,20 @@ export class LimitingInterceptor extends Interceptor {
24
41
  return "request-limit";
25
42
  }
26
43
 
27
- static get configurationAttributes() {
28
- return mergeAttributeDefinitions(
29
- prepareAttributesDefinitions({
30
- limits: {
31
- default: [
32
- {
33
- count: 10
34
- }
35
- ],
36
- count: {
37
- type: "unsigned-integer"
38
- },
39
- delay: {
40
- type: "duration"
41
- }
42
- }
43
- }),
44
- Interceptor.configurationAttributes
45
- );
44
+ static get attributes() {
45
+ return ATTRIBUTES;
46
46
  }
47
47
 
48
48
  constructor(config) {
49
49
  super(config);
50
50
 
51
51
  this.limits = config?.limits
52
- ? config.limits
53
- : [
54
- {
55
- count: 10
56
- }
57
- ];
52
+ ? config.limits
53
+ : [
54
+ {
55
+ count: 10
56
+ }
57
+ ];
58
58
  }
59
59
 
60
60
  toJSON() {
@@ -1,10 +1,16 @@
1
1
  import { Interceptor } from "./interceptor.mjs";
2
- import {
3
- mergeAttributeDefinitions,
4
- prepareAttributesDefinitions
5
- } from "pacc";
2
+ import { prepareAttributesDefinitions } from "pacc";
6
3
  import { expand } from "./util.mjs";
7
4
 
5
+ const ATTRIBUTES = prepareAttributesDefinitions({
6
+ request: {
7
+ description: "request template",
8
+ default: {},
9
+ type: "object"
10
+ },
11
+ ...Interceptor.attributes
12
+ });
13
+
8
14
  /**
9
15
  * Map params into requests.
10
16
  */
@@ -16,17 +22,8 @@ export class TemplateInterceptor extends Interceptor {
16
22
  return "template";
17
23
  }
18
24
 
19
- static get configurationAttributes() {
20
- return mergeAttributeDefinitions(
21
- prepareAttributesDefinitions({
22
- request: {
23
- description: "request template",
24
- default: {},
25
- type: "object"
26
- }
27
- }),
28
- Interceptor.configurationAttributes
29
- );
25
+ static get attributes() {
26
+ return ATTRIBUTES;
30
27
  }
31
28
 
32
29
  async receive(endpoint, next, params) {
@@ -1,25 +1,22 @@
1
- import {
2
- mergeAttributeDefinitions,
3
- prepareAttributesDefinitions
4
- } from "pacc";
1
+ import { prepareAttributesDefinitions } from "pacc";
5
2
  import { Interceptor } from "./interceptor.mjs";
6
3
 
4
+ const ATTRIBUTES = prepareAttributesDefinitions({
5
+ timeout: {
6
+ description: "request timeout",
7
+ default: 1,
8
+ type: "duration"
9
+ },
10
+ ...Interceptor.attributes
11
+ });
12
+
7
13
  /**
8
14
  * Rejects a request if it does not resolve in a given time.
9
15
  * @property {number} timeout
10
16
  */
11
17
  export class TimeoutInterceptor extends Interceptor {
12
- static get configurationAttributes() {
13
- return mergeAttributeDefinitions(
14
- prepareAttributesDefinitions({
15
- timeout: {
16
- description: "request timeout",
17
- default: 1,
18
- type: "duration"
19
- }
20
- }),
21
- Interceptor.configurationAttributes
22
- );
18
+ static get attributes() {
19
+ return ATTRIBUTES;
23
20
  }
24
21
 
25
22
  /**
@@ -11,7 +11,7 @@ export class Interceptor {
11
11
  * Meta description of the configuration
12
12
  * @return {Object}
13
13
  */
14
- static get configurationAttributes(): any;
14
+ static get attributes(): any;
15
15
  constructor(config: any);
16
16
  /**
17
17
  * The instance method returning the type.
@@ -23,11 +23,11 @@ export class Interceptor {
23
23
  * Meta description of the configuration.
24
24
  * @return {Object}
25
25
  */
26
- get configurationAttributes(): any;
26
+ get attributes(): any;
27
27
  /**
28
28
  * Takes attribute values from config parameters
29
29
  * and copies them over to the object.
30
- * Copying is done according to configurationAttributes.
30
+ * Copying is done according to attributes.
31
31
  * Which means we loop over all configuration attributes
32
32
  * and then for each attribute decide if we use the default, call
33
33
  * a setter function or simply assign the attribute value.