@kronos-integration/interceptor 11.0.3 → 11.0.4

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": "11.0.4",
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.7.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@kronos-integration/test-interceptor": "^7.0.30",
@@ -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 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
+
4
21
  /**
5
22
  * Limits the number of concurrent requests.
6
23
  * Requests can be delayed or rejected.
@@ -25,36 +42,19 @@ export class LimitingInterceptor extends Interceptor {
25
42
  }
26
43
 
27
44
  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
- );
45
+ return CONFIG_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 CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
6
+ request: {
7
+ description: "request template",
8
+ default: {},
9
+ type: "object"
10
+ },
11
+ ...Interceptor.configurationAttributes
12
+ });
13
+
8
14
  /**
9
15
  * Map params into requests.
10
16
  */
@@ -17,16 +23,7 @@ export class TemplateInterceptor extends Interceptor {
17
23
  }
18
24
 
19
25
  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
- );
26
+ return CONFIG_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 CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
5
+ timeout: {
6
+ description: "request timeout",
7
+ default: 1,
8
+ type: "duration"
9
+ },
10
+ ...Interceptor.configurationAttributes
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
18
  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
- );
19
+ return CONFIG_ATTRIBUTES;
23
20
  }
24
21
 
25
22
  /**