@kronos-integration/interceptor 11.0.4 → 12.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
@@ -32,7 +32,7 @@ const response = interceptor.receive(endpoint, arg1, arg2);
32
32
  * [Interceptor](#interceptor)
33
33
  * [Parameters](#parameters)
34
34
  * [type](#type)
35
- * [configurationAttributes](#configurationattributes)
35
+ * [attributes](#attributes)
36
36
  * [configure](#configure)
37
37
  * [Parameters](#parameters-1)
38
38
  * [toJSONWithOptions](#tojsonwithoptions)
@@ -40,7 +40,7 @@ const response = interceptor.receive(endpoint, arg1, arg2);
40
40
  * [reset](#reset)
41
41
  * [receive](#receive)
42
42
  * [Parameters](#parameters-3)
43
- * [configurationAttributes](#configurationattributes-1)
43
+ * [attributes](#attributes-1)
44
44
  * [LimitingInterceptor](#limitinginterceptor)
45
45
  * [Parameters](#parameters-4)
46
46
  * [name](#name)
@@ -80,7 +80,7 @@ Defaults to the constructors name (class name)
80
80
 
81
81
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
82
82
 
83
- ### configurationAttributes
83
+ ### attributes
84
84
 
85
85
  Meta description of the configuration.
86
86
 
@@ -90,7 +90,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
90
90
 
91
91
  Takes attribute values from config parameters
92
92
  and copies them over to the object.
93
- Copying is done according to configurationAttributes.
93
+ Copying is done according to attributes.
94
94
  Which means we loop over all configuration attributes
95
95
  and then for each attribute decide if we use the default, call
96
96
  a setter function or simply assign the attribute value.
@@ -126,7 +126,7 @@ and calls the trailing interceptor.
126
126
 
127
127
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>**&#x20;
128
128
 
129
- ### configurationAttributes
129
+ ### attributes
130
130
 
131
131
  Meta description of the configuration
132
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/interceptor",
3
- "version": "11.0.4",
3
+ "version": "12.0.1",
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.7.0"
42
+ "pacc": "^3.8.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@kronos-integration/test-interceptor": "^7.0.30",
@@ -14,9 +14,7 @@ export class Interceptor {
14
14
  * Meta description of the configuration
15
15
  * @return {Object}
16
16
  */
17
- static get configurationAttributes() {
18
- return {};
19
- }
17
+ static attributes = {};
20
18
 
21
19
  constructor(config) {
22
20
  this.configure(config);
@@ -36,21 +34,21 @@ export class Interceptor {
36
34
  * Meta description of the configuration.
37
35
  * @return {Object}
38
36
  */
39
- get configurationAttributes() {
40
- return this.constructor.configurationAttributes;
37
+ get attributes() {
38
+ return this.constructor.attributes;
41
39
  }
42
40
 
43
41
  /**
44
42
  * Takes attribute values from config parameters
45
43
  * and copies them over to the object.
46
- * Copying is done according to configurationAttributes.
44
+ * Copying is done according to attributes.
47
45
  * Which means we loop over all configuration attributes
48
46
  * and then for each attribute decide if we use the default, call
49
47
  * a setter function or simply assign the attribute value.
50
48
  * @param {Object?} config
51
49
  */
52
50
  configure(config) {
53
- setAttributes(this, config, this.configurationAttributes);
51
+ setAttributes(this, config, this.attributes);
54
52
  }
55
53
 
56
54
  toString() {
@@ -72,7 +70,7 @@ export class Interceptor {
72
70
  return { type: this.type };
73
71
  }
74
72
 
75
- let atts = getAttributes(this, this.configurationAttributes);
73
+ let atts = getAttributes(this, this.attributes);
76
74
 
77
75
  if (!options.includePrivate) {
78
76
  atts = Object.fromEntries(
@@ -1,23 +1,6 @@
1
1
  import { prepareAttributesDefinitions } from "pacc";
2
2
  import { Interceptor } from "./interceptor.mjs";
3
3
 
4
- const CONFIG_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.configurationAttributes
19
- });
20
-
21
4
  /**
22
5
  * Limits the number of concurrent requests.
23
6
  * Requests can be delayed or rejected.
@@ -41,9 +24,22 @@ export class LimitingInterceptor extends Interceptor {
41
24
  return "request-limit";
42
25
  }
43
26
 
44
- static get configurationAttributes() {
45
- return CONFIG_ATTRIBUTES;
46
- }
27
+ static attributes = prepareAttributesDefinitions({
28
+ limits: {
29
+ default: [
30
+ {
31
+ count: 10
32
+ }
33
+ ],
34
+ count: {
35
+ type: "unsigned-integer"
36
+ },
37
+ delay: {
38
+ type: "duration"
39
+ }
40
+ },
41
+ ...Interceptor.attributes
42
+ });
47
43
 
48
44
  constructor(config) {
49
45
  super(config);
@@ -2,15 +2,6 @@ import { Interceptor } from "./interceptor.mjs";
2
2
  import { prepareAttributesDefinitions } from "pacc";
3
3
  import { expand } from "./util.mjs";
4
4
 
5
- const CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
6
- request: {
7
- description: "request template",
8
- default: {},
9
- type: "object"
10
- },
11
- ...Interceptor.configurationAttributes
12
- });
13
-
14
5
  /**
15
6
  * Map params into requests.
16
7
  */
@@ -22,9 +13,14 @@ export class TemplateInterceptor extends Interceptor {
22
13
  return "template";
23
14
  }
24
15
 
25
- static get configurationAttributes() {
26
- return CONFIG_ATTRIBUTES;
27
- }
16
+ static attributes = prepareAttributesDefinitions({
17
+ request: {
18
+ description: "request template",
19
+ default: {},
20
+ type: "object"
21
+ },
22
+ ...Interceptor.attributes
23
+ });
28
24
 
29
25
  async receive(endpoint, next, params) {
30
26
  return next(expand(this.request, params));
@@ -1,23 +1,19 @@
1
1
  import { prepareAttributesDefinitions } from "pacc";
2
2
  import { Interceptor } from "./interceptor.mjs";
3
3
 
4
- const CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
5
- timeout: {
6
- description: "request timeout",
7
- default: 1,
8
- type: "duration"
9
- },
10
- ...Interceptor.configurationAttributes
11
- });
12
-
13
4
  /**
14
5
  * Rejects a request if it does not resolve in a given time.
15
6
  * @property {number} timeout
16
7
  */
17
8
  export class TimeoutInterceptor extends Interceptor {
18
- static get configurationAttributes() {
19
- return CONFIG_ATTRIBUTES;
20
- }
9
+ static attributes = prepareAttributesDefinitions({
10
+ timeout: {
11
+ description: "request timeout",
12
+ default: 1,
13
+ type: "duration"
14
+ },
15
+ ...Interceptor.attributes
16
+ });
21
17
 
22
18
  /**
23
19
  * @return {string} 'timeout'
@@ -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 attributes: {};
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.
@@ -14,6 +14,7 @@
14
14
  * default is to reject when more than 10 requests are on the way
15
15
  */
16
16
  export class LimitingInterceptor extends Interceptor {
17
+ static attributes: any;
17
18
  limits: any;
18
19
  ongoingResponses: Set<any>;
19
20
  ongoingRequests: number;
@@ -2,6 +2,7 @@
2
2
  * Map params into requests.
3
3
  */
4
4
  export class TemplateInterceptor extends Interceptor {
5
+ static attributes: any;
5
6
  receive(endpoint: any, next: any, params: any): Promise<any>;
6
7
  }
7
8
  import { Interceptor } from "./interceptor.mjs";
@@ -3,6 +3,7 @@
3
3
  * @property {number} timeout
4
4
  */
5
5
  export class TimeoutInterceptor extends Interceptor {
6
+ static attributes: any;
6
7
  receive(endpoint: any, next: any, ...args: any[]): Promise<any>;
7
8
  }
8
9
  import { Interceptor } from "./interceptor.mjs";