@kronos-integration/interceptor 12.1.20 → 12.2.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
@@ -60,8 +60,6 @@ const response = interceptor.receive(endpoint, arg1, arg2);
60
60
  * [name](#name-5)
61
61
  * [rejectUnlessResolvedWithin](#rejectunlessresolvedwithin)
62
62
  * [Parameters](#parameters-6)
63
- * [expand](#expand)
64
- * [Parameters](#parameters-7)
65
63
 
66
64
  ## Endpoint
67
65
 
@@ -242,17 +240,6 @@ Rejects promise when it is not resolved within given timeout.
242
240
 
243
241
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<any>**&#x20;
244
242
 
245
- ## expand
246
-
247
- Expands '{{exp}}' expressions.
248
-
249
- ### Parameters
250
-
251
- * `value` **any**&#x20;
252
- * `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;
253
-
254
- Returns **any** expanded value
255
-
256
243
  # install
257
244
 
258
245
  With [npm](http://npmjs.org) do:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kronos-integration/interceptor",
3
- "version": "12.1.20",
3
+ "version": "12.2.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,18 +39,18 @@
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": "^4.18.2"
42
+ "pacc": "^4.39.1"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@kronos-integration/test-interceptor": "^7.0.31",
46
46
  "ava": "^6.4.1",
47
47
  "c8": "^10.1.2",
48
48
  "documentation": "^14.0.3",
49
- "semantic-release": "^24.2.7",
49
+ "semantic-release": "^24.2.9",
50
50
  "typescript": "^5.9.2"
51
51
  },
52
52
  "engines": {
53
- "node": ">=22.19.0"
53
+ "node": ">=22.20.0"
54
54
  },
55
55
  "repository": {
56
56
  "type": "git",
@@ -39,11 +39,8 @@ export class LimitingInterceptor extends Interceptor {
39
39
  }
40
40
  ],
41
41
  attributes: {
42
- count: { ...count_attribute, default: 10 },
43
- delay: {
44
- ...duration_attribute,
45
- type: "duration"
46
- }
42
+ count: count_attribute,
43
+ delay: duration_attribute
47
44
  }
48
45
  }
49
46
  },
@@ -52,14 +49,7 @@ export class LimitingInterceptor extends Interceptor {
52
49
 
53
50
  constructor(config) {
54
51
  super(config);
55
-
56
- this.limits = config?.limits
57
- ? config.limits
58
- : [
59
- {
60
- count: 10
61
- }
62
- ];
52
+ this.limits = config?.limits || this.constructor.attributes.limits.default;
63
53
  }
64
54
 
65
55
  toJSON() {
@@ -1,6 +1,5 @@
1
1
  import { Interceptor } from "./interceptor.mjs";
2
- import { prepareAttributesDefinitions, default_attribute } from "pacc";
3
- import { expand } from "./util.mjs";
2
+ import { expand, prepareAttributesDefinitions, default_attribute } from "pacc";
4
3
 
5
4
  /**
6
5
  * Map params into requests.
@@ -26,6 +25,8 @@ export class TemplateInterceptor extends Interceptor {
26
25
  );
27
26
 
28
27
  async receive(endpoint, next, params) {
29
- return next(expand(this.request, params));
28
+ return next(
29
+ expand(this.request, { root: params, leadIn: "{{", leadOut: "}}" })
30
+ );
30
31
  }
31
32
  }
@@ -6,15 +6,17 @@ import { Interceptor } from "./interceptor.mjs";
6
6
  * @property {number} timeout
7
7
  */
8
8
  export class TimeoutInterceptor extends Interceptor {
9
- static attributes = prepareAttributesDefinitions({
10
- timeout: {
11
- ...default_attribute,
12
- description: "request timeout",
13
- default: 1,
14
- type: "duration"
9
+ static attributes = prepareAttributesDefinitions(
10
+ {
11
+ timeout: {
12
+ ...default_attribute,
13
+ description: "request timeout",
14
+ default: 1,
15
+ type: "duration"
16
+ }
15
17
  },
16
- ...Interceptor.attributes
17
- });
18
+ Interceptor.attributes
19
+ );
18
20
 
19
21
  /**
20
22
  * @return {string} 'timeout'
package/src/util.mjs DELETED
@@ -1,30 +0,0 @@
1
-
2
- /**
3
- * Expands '{{exp}}' expressions.
4
- * @param {any} value
5
- * @param {Object} params
6
- * @return {any} expanded value
7
- */
8
- export function expand(value, params) {
9
-
10
- if (Array.isArray(value)) {
11
- return value.map(e => expand(e, params));
12
- }
13
-
14
- if(value === undefined || value == null || typeof value === "number") {
15
- return value;
16
- }
17
-
18
- if (typeof value === "string") {
19
- return value.replace(/\{\{(\w+)\}\}/, (match, g1) =>
20
- params[g1] || g1
21
- );
22
- }
23
-
24
- return Object.fromEntries(
25
- Object.entries(value).map(([k, v]) => [
26
- expand(k, params),
27
- expand(v, params)
28
- ])
29
- );
30
- }
package/types/util.d.mts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * Expands '{{exp}}' expressions.
3
- * @param {any} value
4
- * @param {Object} params
5
- * @return {any} expanded value
6
- */
7
- export function expand(value: any, params: any): any;