@kronos-integration/interceptor 10.2.37 → 10.2.38

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2016-2023 by darlenya & arlac77
1
+ Copyright (c) 2016-2024 by darlenya & arlac77
2
2
  All rights reserved.
3
3
 
4
4
  Redistribution and use in source and binary forms, with or without
package/README.md CHANGED
@@ -54,6 +54,7 @@ const response = interceptor.receive(endpoint, arg1, arg2);
54
54
  * [TemplateInterceptor](#templateinterceptor)
55
55
  * [name](#name-3)
56
56
  * [TimeoutInterceptor](#timeoutinterceptor)
57
+ * [Properties](#properties)
57
58
  * [name](#name-4)
58
59
  * [rejectUnlessResolvedWithin](#rejectunlessresolvedwithin)
59
60
  * [Parameters](#parameters-6)
@@ -200,6 +201,10 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
200
201
 
201
202
  Rejects a request if it does not resolve in a given time.
202
203
 
204
+ ### Properties
205
+
206
+ * `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** 
207
+
203
208
  ### name
204
209
 
205
210
  Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 'timeout'
@@ -212,7 +217,7 @@ Rejects promise when it is not resolved within given timeout.
212
217
 
213
218
  * `promise` **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** 
214
219
  * `timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** in miliseconds
215
- * `name` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
220
+ * `source` **[Interceptor](#interceptor)** 
216
221
 
217
222
  Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)** 
218
223
 
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@kronos-integration/interceptor",
3
- "version": "10.2.37",
3
+ "version": "10.2.38",
4
4
  "publishConfig": {
5
- "access": "public"
5
+ "access": "public",
6
+ "provenance": true
6
7
  },
7
8
  "exports": {
8
9
  ".": "./src/index.mjs"
@@ -24,28 +25,30 @@
24
25
  "license": "BSD-2-Clause",
25
26
  "scripts": {
26
27
  "test": "npm run test:ava",
27
- "test:ava": "ava --timeout 2m tests/*-ava.mjs tests/*-ava-node.mjs && ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
28
+ "test:ava": "ava --timeout 4m tests/*-ava.mjs tests/*-ava-node.mjs",
28
29
  "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",
29
30
  "docs": "documentation readme --section=API ./src/**/*.mjs",
30
- "lint": "npm run lint:docs",
31
- "lint:docs": "documentation lint ./src/**/*.mjs"
31
+ "lint": "npm run lint:docs && npm run lint:tsc",
32
+ "lint:docs": "documentation lint ./src/**/*.mjs",
33
+ "lint:tsc": "tsc --allowJs --checkJs --noEmit -t esnext -m esnext --module nodenext --moduleResolution nodenext ./src**/*.mjs"
32
34
  },
33
35
  "dependencies": {
34
36
  "model-attributes": "^4.2.2"
35
37
  },
36
38
  "devDependencies": {
37
39
  "@kronos-integration/test-interceptor": "^7.0.27",
38
- "ava": "^5.3.1",
39
- "c8": "^8.0.1",
40
- "documentation": "^14.0.2",
41
- "semantic-release": "^22.0.6"
40
+ "ava": "^6.1.1",
41
+ "c8": "^9.1.0",
42
+ "documentation": "^14.0.3",
43
+ "semantic-release": "^23.0.2",
44
+ "typescript": "^5.3.3"
42
45
  },
43
46
  "engines": {
44
- "node": ">=20.9.0"
47
+ "node": ">=20.11.0"
45
48
  },
46
49
  "repository": {
47
50
  "type": "git",
48
- "url": "https://github.com/Kronos-Integration/interceptor"
51
+ "url": "git+https://github.com/Kronos-Integration/interceptor.git"
49
52
  },
50
53
  "bugs": {
51
54
  "url": "https://github.com/Kronos-Integration/interceptor/issues"
@@ -54,7 +57,8 @@
54
57
  "template": {
55
58
  "inheritFrom": [
56
59
  "arlac77/template-arlac77-github",
57
- "arlac77/template-kronos-component"
60
+ "arlac77/template-kronos-component",
61
+ "arlac77/template-typescript"
58
62
  ]
59
63
  }
60
64
  }
@@ -93,7 +93,7 @@ export class Interceptor {
93
93
  * @param {Endpoint} endpoint
94
94
  * @param {Function} next
95
95
  * @param {any[]} args the request from the leading interceptor
96
- * @return {Promise}
96
+ * @return {Promise<any>}
97
97
  */
98
98
  async receive(endpoint, next, ...args) {
99
99
  // This is a dummy implementation. Must be overwritten by the derived object.
@@ -52,11 +52,11 @@ export class StatsCollectorInterceptor extends Interceptor {
52
52
  async receive(endpoint,...args) {
53
53
  this.#numberOfRequests += 1;
54
54
 
55
- const start = new Date();
55
+ const start = Date.now();
56
56
 
57
57
  try {
58
58
  const response = await this.connected.receive(...args);
59
- const now = new Date();
59
+ const now = Date.now();
60
60
  const pt = now - start;
61
61
  this.#totalRequestProcessingTime += pt;
62
62
 
@@ -3,6 +3,7 @@ import { Interceptor } from "./interceptor.mjs";
3
3
 
4
4
  /**
5
5
  * Rejects a request if it does not resolve in a given time.
6
+ * @property {number} timeout
6
7
  */
7
8
  export class TimeoutInterceptor extends Interceptor {
8
9
  static get configurationAttributes() {
@@ -34,16 +35,16 @@ export class TimeoutInterceptor extends Interceptor {
34
35
  * Rejects promise when it is not resolved within given timeout.
35
36
  * @param {Promise} promise
36
37
  * @param {number} timeout in miliseconds
37
- * @param {string} name
38
- * @return {Promise}
38
+ * @param {Interceptor} source
39
+ * @return {Promise<any>}
39
40
  */
40
- function rejectUnlessResolvedWithin(promise, timeout, name) {
41
+ function rejectUnlessResolvedWithin(promise, timeout, source) {
41
42
  if (timeout === 0) return promise;
42
43
 
43
44
  return new Promise((resolve, reject) => {
44
45
  const th = setTimeout(
45
46
  () =>
46
- reject(new Error(`${name} request not resolved within ${timeout}ms`)),
47
+ reject(new Error(`${source} request not resolved within ${timeout}ms`)),
47
48
  timeout
48
49
  );
49
50