@kronos-integration/interceptor 13.0.6 → 13.1.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/README.md CHANGED
@@ -1,11 +1,13 @@
1
+ [![npm](https://img.shields.io/npm/v/@kronos-integration/interceptor.svg)](https://www.npmjs.com/package/@kronos-integration/interceptor)
1
2
  [![License](https://img.shields.io/badge/License-0BSD-blue.svg)](https://spdx.org/licenses/0BSD.html)
2
3
  [![Typed with TypeScript](https://flat.badgen.net/badge/icon/Typed?icon=typescript\&label\&labelColor=blue\&color=555555)](https://typescriptlang.org)
4
+ [![bundlejs](https://deno.bundlejs.com/?q=@kronos-integration/interceptor\&badge=detailed)](https://bundlejs.com/?q=@kronos-integration/interceptor)
5
+ [![downloads](http://img.shields.io/npm/dm/@kronos-integration/interceptor.svg?style=flat-square)](https://npmjs.org/package/@kronos-integration/interceptor)
3
6
  [![GitHub Issues](https://img.shields.io/github/issues/Kronos-Integration/interceptor.svg?style=flat-square)](https://github.com/Kronos-Integration/interceptor/issues)
4
7
  [![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2FKronos-Integration%2Finterceptor%2Fbadge\&style=flat)](https://actions-badge.atrox.dev/Kronos-Integration/interceptor/goto)
5
8
  [![Styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
6
9
  [![Commitizen friendly](https://img.shields.io/badge/commitizen-friendly-brightgreen.svg)](http://commitizen.github.io/cz-cli/)
7
10
  [![Known Vulnerabilities](https://snyk.io/test/github/Kronos-Integration/interceptor/badge.svg)](https://snyk.io/test/github/Kronos-Integration/interceptor)
8
- [![Coverage Status](https://coveralls.io/repos/Kronos-Integration/interceptor/badge.svg)](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.0.6",
3
+ "version": "13.1.0",
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
- "default": "./src/index.mjs",
12
- "types": "./types/index.d.mts"
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": "BSD-2-Clause",
30
+ "license": "0BSD",
30
31
  "scripts": {
31
32
  "prepare": "node --run prepare:typescript",
32
- "prepare:typescript": "tsc --allowJs --declaration --emitDeclarationOnly --declarationDir types --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext --rootDir src ./src**/*.mjs",
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/**/*.mjs",
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/**/*.mjs",
39
- "lint:typescript": "tsc --allowJs --checkJs --noEmit --resolveJsonModule --target es2024 --lib es2024 -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
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": "^5.1.0"
43
+ "pacc": "^6.1.0"
43
44
  },
44
45
  "devDependencies": {
45
46
  "@kronos-integration/test-interceptor": "^7.0.32",
46
47
  "ava": "^6.4.1",
47
- "c8": "^10.1.2",
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
  }
@@ -18,7 +18,7 @@ export class Interceptor {
18
18
 
19
19
  /**
20
20
  *
21
- * @param {Object?} config
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?} config
52
+ * @param {Object} [config]
53
53
  */
54
54
  configure(config) {
55
55
  setAttributes(this, config, this.attributes);
@@ -1,4 +1,4 @@
1
- import { prepareAttributesDefinitions, default_attribute } from "pacc";
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
- ...default_attribute,
12
+ ...duration_ms_attribute,
13
13
  description: "min interval between two requests",
14
- default: 60000,
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 * 1000) {
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
- duration_attribute,
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: duration_attribute
43
+ delay: duration_ms_attribute
44
44
  }
45
45
  }
46
46
  },
@@ -1,4 +1,4 @@
1
- import { prepareAttributesDefinitions, default_attribute } from "pacc";
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
- ...default_attribute,
12
+ ...duration_ms_attribute,
13
13
  description: "request timeout",
14
- default: 1,
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 * 1000, this);
28
+ return rejectUnlessResolvedWithin(next(...args), this.timeout, this);
30
29
  }
31
30
  }
32
31
 
@@ -14,9 +14,9 @@ export class Interceptor {
14
14
  static attributes: {};
15
15
  /**
16
16
  *
17
- * @param {Object?} config
17
+ * @param {Object} [config]
18
18
  */
19
- constructor(config: any | null);
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?} config
38
+ * @param {Object} [config]
39
39
  */
40
- configure(config: any | null): void;
40
+ configure(config?: any): void;
41
41
  toString(): string;
42
42
  toJSON(): any;
43
43
  /**
@@ -15,6 +15,11 @@
15
15
  */
16
16
  export class LimitingInterceptor extends Interceptor {
17
17
  static attributes: any;
18
+ /**
19
+ *
20
+ * @param {Object?} config
21
+ */
22
+ constructor(config: any | null);
18
23
  limits: any;
19
24
  ongoingResponses: Set<any>;
20
25
  ongoingRequests: number;