@kronos-integration/interceptor 11.0.4 → 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": "
|
|
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.
|
|
42
|
+
"pacc": "^3.8.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@kronos-integration/test-interceptor": "^7.0.30",
|
package/src/interceptor.mjs
CHANGED
|
@@ -14,7 +14,7 @@ export class Interceptor {
|
|
|
14
14
|
* Meta description of the configuration
|
|
15
15
|
* @return {Object}
|
|
16
16
|
*/
|
|
17
|
-
static get
|
|
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
|
|
40
|
-
return this.constructor.
|
|
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
|
|
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.
|
|
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.
|
|
75
|
+
let atts = getAttributes(this, this.attributes);
|
|
76
76
|
|
|
77
77
|
if (!options.includePrivate) {
|
|
78
78
|
atts = Object.fromEntries(
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { prepareAttributesDefinitions } from "pacc";
|
|
2
2
|
import { Interceptor } from "./interceptor.mjs";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const ATTRIBUTES = prepareAttributesDefinitions({
|
|
5
5
|
limits: {
|
|
6
6
|
default: [
|
|
7
7
|
{
|
|
@@ -15,7 +15,7 @@ const CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
|
|
|
15
15
|
type: "duration"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
...Interceptor.
|
|
18
|
+
...Interceptor.attributes
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
/**
|
|
@@ -41,8 +41,8 @@ export class LimitingInterceptor extends Interceptor {
|
|
|
41
41
|
return "request-limit";
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
static get
|
|
45
|
-
return
|
|
44
|
+
static get attributes() {
|
|
45
|
+
return ATTRIBUTES;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
constructor(config) {
|
|
@@ -2,13 +2,13 @@ import { Interceptor } from "./interceptor.mjs";
|
|
|
2
2
|
import { prepareAttributesDefinitions } from "pacc";
|
|
3
3
|
import { expand } from "./util.mjs";
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const ATTRIBUTES = prepareAttributesDefinitions({
|
|
6
6
|
request: {
|
|
7
7
|
description: "request template",
|
|
8
8
|
default: {},
|
|
9
9
|
type: "object"
|
|
10
10
|
},
|
|
11
|
-
...Interceptor.
|
|
11
|
+
...Interceptor.attributes
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -22,8 +22,8 @@ export class TemplateInterceptor extends Interceptor {
|
|
|
22
22
|
return "template";
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
static get
|
|
26
|
-
return
|
|
25
|
+
static get attributes() {
|
|
26
|
+
return ATTRIBUTES;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
async receive(endpoint, next, params) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { prepareAttributesDefinitions } from "pacc";
|
|
2
2
|
import { Interceptor } from "./interceptor.mjs";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const ATTRIBUTES = prepareAttributesDefinitions({
|
|
5
5
|
timeout: {
|
|
6
6
|
description: "request timeout",
|
|
7
7
|
default: 1,
|
|
8
8
|
type: "duration"
|
|
9
9
|
},
|
|
10
|
-
...Interceptor.
|
|
10
|
+
...Interceptor.attributes
|
|
11
11
|
});
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -15,8 +15,8 @@ const CONFIG_ATTRIBUTES = prepareAttributesDefinitions({
|
|
|
15
15
|
* @property {number} timeout
|
|
16
16
|
*/
|
|
17
17
|
export class TimeoutInterceptor extends Interceptor {
|
|
18
|
-
static get
|
|
19
|
-
return
|
|
18
|
+
static get attributes() {
|
|
19
|
+
return ATTRIBUTES;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
package/types/interceptor.d.mts
CHANGED
|
@@ -11,7 +11,7 @@ export class Interceptor {
|
|
|
11
11
|
* Meta description of the configuration
|
|
12
12
|
* @return {Object}
|
|
13
13
|
*/
|
|
14
|
-
static get
|
|
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
|
|
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
|
|
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.
|