@kronos-integration/interceptor 13.0.6 → 13.1.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
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@kronos-integration/interceptor)
|
|
1
2
|
[](https://spdx.org/licenses/0BSD.html)
|
|
2
3
|
[](https://typescriptlang.org)
|
|
4
|
+
[](https://bundlejs.com/?q=@kronos-integration/interceptor)
|
|
5
|
+
[](https://npmjs.org/package/@kronos-integration/interceptor)
|
|
3
6
|
[](https://github.com/Kronos-Integration/interceptor/issues)
|
|
4
7
|
[](https://actions-badge.atrox.dev/Kronos-Integration/interceptor/goto)
|
|
5
8
|
[](https://github.com/prettier/prettier)
|
|
6
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
7
10
|
[](https://snyk.io/test/github/Kronos-Integration/interceptor)
|
|
8
|
-
[](https://coveralls.io/github/Kronos-Integration/interceptor)
|
|
9
11
|
|
|
10
12
|
# @kronos-integration/interceptor
|
|
11
13
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kronos-integration/interceptor",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
7
7
|
},
|
|
8
|
+
"packageManager": "npm@11.6.4+sha512.1118cab46a05a50aee6bff5b1b4fa1df18afff89d57465620a3518035026955db87c5bdf9d207b07b7487d99f2490d450cb774655ad63ec2cba7bf1d0ad25d45",
|
|
8
9
|
"types": "./types/index.d.mts",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
12
|
+
"types": "./types/index.d.mts",
|
|
13
|
+
"default": "./src/index.mjs"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
"description": "intercepects / modifies requests as they pass between endpoints",
|
|
@@ -26,25 +27,25 @@
|
|
|
26
27
|
"email": "markus.felten@gmx.de"
|
|
27
28
|
}
|
|
28
29
|
],
|
|
29
|
-
"license": "
|
|
30
|
+
"license": "0BSD",
|
|
30
31
|
"scripts": {
|
|
31
32
|
"prepare": "node --run prepare:typescript",
|
|
32
|
-
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target
|
|
33
|
+
"prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
|
|
33
34
|
"test": "node --run test:ava",
|
|
34
35
|
"test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
|
|
35
36
|
"cover": "c8 -x 'tests/**/*' --temp-directory build/tmp ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs && c8 report -r lcov -o build/coverage --temp-directory build/tmp",
|
|
36
|
-
"docs": "documentation readme --section=API ./src
|
|
37
|
+
"docs": "documentation readme --section=API ./src**/*.mjs",
|
|
37
38
|
"lint": "node --run lint:docs && node --run lint:typescript",
|
|
38
|
-
"lint:docs": "documentation lint ./src
|
|
39
|
-
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target
|
|
39
|
+
"lint:docs": "documentation lint ./src**/*.mjs",
|
|
40
|
+
"lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
|
|
40
41
|
},
|
|
41
42
|
"dependencies": {
|
|
42
|
-
"pacc": "^
|
|
43
|
+
"pacc": "^6.2.1"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"@kronos-integration/test-interceptor": "^7.0.32",
|
|
46
47
|
"ava": "^6.4.1",
|
|
47
|
-
"c8": "^10.1.
|
|
48
|
+
"c8": "^10.1.3",
|
|
48
49
|
"documentation": "^14.0.3",
|
|
49
50
|
"semantic-release": "^25.0.2",
|
|
50
51
|
"typescript": "^5.9.3"
|
|
@@ -66,6 +67,5 @@
|
|
|
66
67
|
"arlac77/template-kronos-component",
|
|
67
68
|
"arlac77/template-typescript"
|
|
68
69
|
]
|
|
69
|
-
}
|
|
70
|
-
"packageManager": "npm@11.6.4+sha512.1118cab46a05a50aee6bff5b1b4fa1df18afff89d57465620a3518035026955db87c5bdf9d207b07b7487d99f2490d450cb774655ad63ec2cba7bf1d0ad25d45"
|
|
70
|
+
}
|
|
71
71
|
}
|
package/src/interceptor.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export class Interceptor {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
*
|
|
21
|
-
* @param {Object
|
|
21
|
+
* @param {Object} [config]
|
|
22
22
|
*/
|
|
23
23
|
constructor(config) {
|
|
24
24
|
this.configure(config);
|
|
@@ -49,7 +49,7 @@ export class Interceptor {
|
|
|
49
49
|
* Which means we loop over all configuration attributes
|
|
50
50
|
* and then for each attribute decide if we use the default, call
|
|
51
51
|
* a setter function or simply assign the attribute value.
|
|
52
|
-
* @param {Object
|
|
52
|
+
* @param {Object} [config]
|
|
53
53
|
*/
|
|
54
54
|
configure(config) {
|
|
55
55
|
setAttributes(this, config, this.attributes);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prepareAttributesDefinitions,
|
|
1
|
+
import { prepareAttributesDefinitions, duration_ms_attribute } from "pacc";
|
|
2
2
|
import { Interceptor } from "./interceptor.mjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -9,10 +9,9 @@ export class IntervalInterceptor extends Interceptor {
|
|
|
9
9
|
static attributes = prepareAttributesDefinitions(
|
|
10
10
|
{
|
|
11
11
|
interval: {
|
|
12
|
-
...
|
|
12
|
+
...duration_ms_attribute,
|
|
13
13
|
description: "min interval between two requests",
|
|
14
|
-
default:
|
|
15
|
-
type: "duration"
|
|
14
|
+
default: "60s",
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
17
|
Interceptor.attributes
|
|
@@ -28,7 +27,7 @@ export class IntervalInterceptor extends Interceptor {
|
|
|
28
27
|
async receive(endpoint, next, ...args) {
|
|
29
28
|
const now = new Date();
|
|
30
29
|
|
|
31
|
-
if (!this.lastTime || now - this.lastTime > this.interval
|
|
30
|
+
if (!this.lastTime || now - this.lastTime > this.interval) {
|
|
32
31
|
this.lastTime = now;
|
|
33
32
|
return super.receive(endpoint, next, ...args);
|
|
34
33
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
prepareAttributesDefinitions,
|
|
3
3
|
object_attribute,
|
|
4
|
-
|
|
4
|
+
duration_ms_attribute,
|
|
5
5
|
count_attribute
|
|
6
6
|
} from "pacc";
|
|
7
7
|
import { Interceptor } from "./interceptor.mjs";
|
|
@@ -40,7 +40,7 @@ export class LimitingInterceptor extends Interceptor {
|
|
|
40
40
|
],
|
|
41
41
|
attributes: {
|
|
42
42
|
count: count_attribute,
|
|
43
|
-
delay:
|
|
43
|
+
delay: duration_ms_attribute
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
},
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { prepareAttributesDefinitions,
|
|
1
|
+
import { prepareAttributesDefinitions, duration_ms_attribute } from "pacc";
|
|
2
2
|
import { Interceptor } from "./interceptor.mjs";
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -9,10 +9,9 @@ export class TimeoutInterceptor extends Interceptor {
|
|
|
9
9
|
static attributes = prepareAttributesDefinitions(
|
|
10
10
|
{
|
|
11
11
|
timeout: {
|
|
12
|
-
...
|
|
12
|
+
...duration_ms_attribute,
|
|
13
13
|
description: "request timeout",
|
|
14
|
-
default:
|
|
15
|
-
type: "duration"
|
|
14
|
+
default: "10s",
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
17
|
Interceptor.attributes
|
|
@@ -26,7 +25,7 @@ export class TimeoutInterceptor extends Interceptor {
|
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
receive(endpoint, next, ...args) {
|
|
29
|
-
return rejectUnlessResolvedWithin(next(...args), this.timeout
|
|
28
|
+
return rejectUnlessResolvedWithin(next(...args), this.timeout, this);
|
|
30
29
|
}
|
|
31
30
|
}
|
|
32
31
|
|
package/types/interceptor.d.mts
CHANGED
|
@@ -14,9 +14,9 @@ export class Interceptor {
|
|
|
14
14
|
static attributes: {};
|
|
15
15
|
/**
|
|
16
16
|
*
|
|
17
|
-
* @param {Object
|
|
17
|
+
* @param {Object} [config]
|
|
18
18
|
*/
|
|
19
|
-
constructor(config
|
|
19
|
+
constructor(config?: any);
|
|
20
20
|
/**
|
|
21
21
|
* The instance method returning the type.
|
|
22
22
|
* Defaults to the constructors name (class name)
|
|
@@ -35,9 +35,9 @@ export class Interceptor {
|
|
|
35
35
|
* Which means we loop over all configuration attributes
|
|
36
36
|
* and then for each attribute decide if we use the default, call
|
|
37
37
|
* a setter function or simply assign the attribute value.
|
|
38
|
-
* @param {Object
|
|
38
|
+
* @param {Object} [config]
|
|
39
39
|
*/
|
|
40
|
-
configure(config
|
|
40
|
+
configure(config?: any): void;
|
|
41
41
|
toString(): string;
|
|
42
42
|
toJSON(): any;
|
|
43
43
|
/**
|