@diia-inhouse/http 5.1.92 → 5.1.93
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/dist/index.d.ts +2 -0
- package/dist/interfaces/deps.d.ts +3 -5
- package/dist/interfaces/httpClient.d.ts +24 -27
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/services/errors/index.js +3 -3
- package/dist/services/errors/operationError.d.ts +2 -6
- package/dist/services/errors/operationError.js +1 -2
- package/dist/services/errors/requestError.d.ts +2 -5
- package/dist/services/errors/requestError.js +1 -2
- package/dist/services/httpClient.d.ts +2 -6
- package/dist/services/httpClient.js +1 -2
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +3 -3
- package/dist/services/utils.d.ts +1 -5
- package/dist/services/utils.js +2 -3
- package/package.json +18 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { FailureResponse, FullRequestOptions, HttpClientResponse, ObserveRequestBaseParams, ObserveRequestFailedParams, ReadonlyQuery, RequestHelperResponse, RequestOptions, SuccessfulResponse } from "./interfaces/httpClient.js";
|
|
2
2
|
import { HttpClientService } from "./services/httpClient.js";
|
|
3
3
|
import { checkServerIdentity } from "./services/utils.js";
|
|
4
|
+
import "./services/index.js";
|
|
4
5
|
import { HttpDeps } from "./interfaces/deps.js";
|
|
6
|
+
import "./interfaces/index.js";
|
|
5
7
|
export { FailureResponse, FullRequestOptions, HttpClientResponse, HttpClientService, HttpDeps, ObserveRequestBaseParams, ObserveRequestFailedParams, ReadonlyQuery, RequestHelperResponse, RequestOptions, SuccessfulResponse, checkServerIdentity };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { HttpClientService } from "../services/httpClient.js";
|
|
2
|
-
|
|
3
|
-
type HttpDeps<TMetricLabel extends string> = {
|
|
2
|
+
import "../services/index.js";
|
|
3
|
+
export type HttpDeps<TMetricLabel extends string> = {
|
|
4
4
|
http?: HttpClientService<TMetricLabel>;
|
|
5
|
-
};
|
|
6
|
-
//#endregion
|
|
7
|
-
export { HttpDeps };
|
|
5
|
+
};
|
|
@@ -6,15 +6,13 @@ import { ErrorType } from "@diia-inhouse/errors";
|
|
|
6
6
|
import { HttpMethod, HttpStatusCode } from "@diia-inhouse/types";
|
|
7
7
|
import { Agent } from "node:http";
|
|
8
8
|
import { Agent as Agent$1 } from "node:https";
|
|
9
|
-
|
|
10
|
-
//#region src/interfaces/httpClient.d.ts
|
|
11
|
-
type ReadonlyQuery = Readonly<object>;
|
|
9
|
+
export type ReadonlyQuery = Readonly<object>;
|
|
12
10
|
/**
|
|
13
|
-
* Enforces that T is a string literal or union of literals, not the broad `string` type.
|
|
14
|
-
* Resolves to `never` if T is exactly `string`, causing a compile error.
|
|
15
|
-
*/
|
|
11
|
+
* Enforces that T is a string literal or union of literals, not the broad `string` type.
|
|
12
|
+
* Resolves to `never` if T is exactly `string`, causing a compile error.
|
|
13
|
+
*/
|
|
16
14
|
type LowCardinality<T extends string> = string extends T ? never : T;
|
|
17
|
-
interface RequestOptions<TMetricLabel extends string> {
|
|
15
|
+
export interface RequestOptions<TMetricLabel extends string> {
|
|
18
16
|
baseUrl?: string;
|
|
19
17
|
timeout?: number;
|
|
20
18
|
retries?: number;
|
|
@@ -27,37 +25,37 @@ interface RequestOptions<TMetricLabel extends string> {
|
|
|
27
25
|
httpsAgent?: Agent$1;
|
|
28
26
|
httpAgent?: Agent;
|
|
29
27
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
28
|
+
* Label used to separate metrics on the same destination host.
|
|
29
|
+
*
|
|
30
|
+
* **Must have low cardinality** — use a finite set of known values, not dynamic strings
|
|
31
|
+
* like URLs, IDs, or user input. High-cardinality labels cause metric explosion and
|
|
32
|
+
* degrade monitoring system performance.
|
|
33
|
+
*
|
|
34
|
+
* Define as a string union type to enforce allowed values at compile time:
|
|
35
|
+
* @example
|
|
36
|
+
* type MyMetricLabel = 'getUserProfile' | 'createOrder' | 'validateDocument'
|
|
37
|
+
* const options: RequestOptions<MyMetricLabel> = { metricLabel: 'getUserProfile', ... }
|
|
38
|
+
*/
|
|
41
39
|
metricLabel: LowCardinality<TMetricLabel>;
|
|
42
40
|
}
|
|
43
|
-
interface FullRequestOptions<TMetricLabel extends string> extends RequestOptions<TMetricLabel> {
|
|
41
|
+
export interface FullRequestOptions<TMetricLabel extends string> extends RequestOptions<TMetricLabel> {
|
|
44
42
|
path: string;
|
|
45
43
|
method: HttpMethod;
|
|
46
44
|
}
|
|
47
|
-
interface SuccessfulResponse<T> {
|
|
45
|
+
export interface SuccessfulResponse<T> {
|
|
48
46
|
isOk: true;
|
|
49
47
|
statusCode: HttpStatusCode;
|
|
50
48
|
headers?: Record<string, string>;
|
|
51
49
|
body: T;
|
|
52
50
|
}
|
|
53
|
-
interface FailureResponse<TError> {
|
|
51
|
+
export interface FailureResponse<TError> {
|
|
54
52
|
isOk: false;
|
|
55
53
|
statusCode: HttpStatusCode;
|
|
56
54
|
headers?: Record<string, string>;
|
|
57
55
|
body: TError | undefined;
|
|
58
56
|
}
|
|
59
|
-
type HttpClientResponse<TResponse, TError = unknown> = SuccessfulResponse<TResponse> | FailureResponse<TError>;
|
|
60
|
-
interface ObserveRequestBaseParams {
|
|
57
|
+
export type HttpClientResponse<TResponse, TError = unknown> = SuccessfulResponse<TResponse> | FailureResponse<TError>;
|
|
58
|
+
export interface ObserveRequestBaseParams {
|
|
61
59
|
statusCode: number;
|
|
62
60
|
retryCount: number;
|
|
63
61
|
startTime: bigint;
|
|
@@ -65,13 +63,12 @@ interface ObserveRequestBaseParams {
|
|
|
65
63
|
baseUrl: string;
|
|
66
64
|
metricLabel: string;
|
|
67
65
|
}
|
|
68
|
-
interface ObserveRequestFailedParams extends ObserveRequestBaseParams {
|
|
66
|
+
export interface ObserveRequestFailedParams extends ObserveRequestBaseParams {
|
|
69
67
|
errorType: ErrorType;
|
|
70
68
|
}
|
|
71
|
-
interface RequestHelperResponse<TResponse> {
|
|
69
|
+
export interface RequestHelperResponse<TResponse> {
|
|
72
70
|
response?: AxiosResponse<TResponse>;
|
|
73
71
|
error?: RequestError | OperationError;
|
|
74
72
|
retryCount: number;
|
|
75
73
|
}
|
|
76
|
-
|
|
77
|
-
export { FailureResponse, FullRequestOptions, HttpClientResponse, ObserveRequestBaseParams, ObserveRequestFailedParams, ReadonlyQuery, RequestHelperResponse, RequestOptions, SuccessfulResponse };
|
|
74
|
+
export {};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { FailureResponse, FullRequestOptions, HttpClientResponse, ObserveRequestBaseParams, ObserveRequestFailedParams, ReadonlyQuery, RequestHelperResponse, RequestOptions, SuccessfulResponse } from "./httpClient.js";
|
|
2
|
-
import { HttpDeps } from "./deps.js";
|
|
2
|
+
import { HttpDeps } from "./deps.js";
|
|
3
|
+
export { FailureResponse, FullRequestOptions, HttpClientResponse, HttpDeps, ObserveRequestBaseParams, ObserveRequestFailedParams, ReadonlyQuery, RequestHelperResponse, RequestOptions, SuccessfulResponse };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./requestError.js";
|
|
2
|
-
import "./operationError.js";
|
|
3
|
-
export {};
|
|
1
|
+
import { RequestError } from "./requestError.js";
|
|
2
|
+
import { OperationError } from "./operationError.js";
|
|
3
|
+
export { OperationError, RequestError };
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { RequestError } from "./requestError.js";
|
|
2
|
-
|
|
3
|
-
//#region src/services/errors/operationError.d.ts
|
|
4
|
-
declare class OperationError extends RequestError {
|
|
2
|
+
export declare class OperationError extends RequestError {
|
|
5
3
|
constructor(message: string, originalError: Error);
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { OperationError };
|
|
4
|
+
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { RequestError } from "./requestError.js";
|
|
2
2
|
import { HttpStatusCode } from "@diia-inhouse/types";
|
|
3
|
-
|
|
3
|
+
// src/services/errors/operationError.ts
|
|
4
4
|
var OperationError = class extends RequestError {
|
|
5
5
|
constructor(message, originalError) {
|
|
6
6
|
super(message, HttpStatusCode.INTERNAL_SERVER_ERROR, originalError);
|
|
7
7
|
this.name = "OperationError";
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
//#endregion
|
|
11
10
|
export { OperationError };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
declare class RequestError extends Error {
|
|
1
|
+
export declare class RequestError extends Error {
|
|
3
2
|
readonly statusCode: number;
|
|
4
3
|
readonly originalError: Error;
|
|
5
4
|
constructor(message: string, statusCode: number, originalError: Error);
|
|
6
|
-
}
|
|
7
|
-
//#endregion
|
|
8
|
-
export { RequestError };
|
|
5
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/services/errors/requestError.ts
|
|
2
2
|
var RequestError = class extends Error {
|
|
3
3
|
statusCode;
|
|
4
4
|
originalError;
|
|
@@ -9,5 +9,4 @@ var RequestError = class extends Error {
|
|
|
9
9
|
this.originalError = originalError;
|
|
10
10
|
}
|
|
11
11
|
};
|
|
12
|
-
//#endregion
|
|
13
12
|
export { RequestError };
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { HttpClientResponse, RequestOptions } from "../interfaces/httpClient.js";
|
|
2
2
|
import { MetricsService } from "@diia-inhouse/diia-metrics";
|
|
3
3
|
import { Logger } from "@diia-inhouse/types";
|
|
4
|
-
|
|
5
|
-
//#region src/services/httpClient.d.ts
|
|
6
|
-
declare class HttpClientService<TMetricLabel extends string> {
|
|
4
|
+
export declare class HttpClientService<TMetricLabel extends string> {
|
|
7
5
|
private logger;
|
|
8
6
|
private metrics;
|
|
9
7
|
private readonly systemServiceName;
|
|
@@ -20,6 +18,4 @@ declare class HttpClientService<TMetricLabel extends string> {
|
|
|
20
18
|
private observeSuccessRequest;
|
|
21
19
|
private observeFailedRequest;
|
|
22
20
|
private getLabels;
|
|
23
|
-
}
|
|
24
|
-
//#endregion
|
|
25
|
-
export { HttpClientService };
|
|
21
|
+
}
|
|
@@ -8,7 +8,7 @@ import axios, { AxiosError } from "axios";
|
|
|
8
8
|
import { RequestMechanism, RequestStatus } from "@diia-inhouse/diia-metrics";
|
|
9
9
|
import { ErrorType } from "@diia-inhouse/errors";
|
|
10
10
|
import { DurationMs, HttpMethod, HttpStatusCode } from "@diia-inhouse/types";
|
|
11
|
-
|
|
11
|
+
// src/services/httpClient.ts
|
|
12
12
|
var HttpClientService = class {
|
|
13
13
|
logger;
|
|
14
14
|
metrics;
|
|
@@ -203,5 +203,4 @@ var HttpClientService = class {
|
|
|
203
203
|
};
|
|
204
204
|
}
|
|
205
205
|
};
|
|
206
|
-
//#endregion
|
|
207
206
|
export { HttpClientService };
|
package/dist/services/index.d.ts
CHANGED
package/dist/services/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import "./utils.js";
|
|
2
|
-
import "./httpClient.js";
|
|
3
|
-
export {};
|
|
1
|
+
import { checkServerIdentity } from "./utils.js";
|
|
2
|
+
import { HttpClientService } from "./httpClient.js";
|
|
3
|
+
export { HttpClientService, checkServerIdentity };
|
package/dist/services/utils.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
1
|
import { PeerCertificateWithSHA256 } from "@diia-inhouse/types";
|
|
2
|
-
|
|
3
|
-
//#region src/services/utils.d.ts
|
|
4
|
-
declare function checkServerIdentity(hostFingerprint: string): (host: string, cert: PeerCertificateWithSHA256) => Error | undefined;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { checkServerIdentity };
|
|
2
|
+
export declare function checkServerIdentity(hostFingerprint: string): (host: string, cert: PeerCertificateWithSHA256) => Error | undefined;
|
package/dist/services/utils.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { setTimeout } from "node:timers/promises";
|
|
2
|
-
|
|
2
|
+
// src/services/utils.ts
|
|
3
3
|
const sleep = (ms) => setTimeout(ms);
|
|
4
4
|
const waitAndRun = async (callback, ms) => {
|
|
5
5
|
await sleep(ms);
|
|
@@ -12,5 +12,4 @@ function checkServerIdentity(hostFingerprint) {
|
|
|
12
12
|
return /* @__PURE__ */ new Error(`Fingerprint for host ${host} does not match`);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
export { checkServerIdentity, waitAndRun };
|
|
15
|
+
export { checkServerIdentity, sleep, waitAndRun };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diia-inhouse/http",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.93",
|
|
4
4
|
"description": "Wrapper to make http requests",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "diia-team",
|
|
@@ -37,35 +37,35 @@
|
|
|
37
37
|
"await-to-js": "3.0.0",
|
|
38
38
|
"axios": "1.20.0",
|
|
39
39
|
"lodash": "4.18.1",
|
|
40
|
-
"qs": "6.16.
|
|
40
|
+
"qs": "6.16.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@commitlint/cli": "19.
|
|
43
|
+
"@commitlint/cli": "19.8.0",
|
|
44
44
|
"@diia-inhouse/configs": "7.2.2",
|
|
45
|
-
"@diia-inhouse/diia-logger": "4.7.
|
|
45
|
+
"@diia-inhouse/diia-logger": "4.7.23",
|
|
46
46
|
"@diia-inhouse/diia-metrics": "7.1.149",
|
|
47
47
|
"@diia-inhouse/errors": "2.3.25",
|
|
48
48
|
"@diia-inhouse/oxc-config": "5.0.2",
|
|
49
|
-
"@diia-inhouse/test": "8.3.
|
|
50
|
-
"@diia-inhouse/types": "14.
|
|
49
|
+
"@diia-inhouse/test": "8.3.42",
|
|
50
|
+
"@diia-inhouse/types": "14.7.1",
|
|
51
51
|
"@opentelemetry/api": "1.9.1",
|
|
52
|
-
"@opentelemetry/semantic-conventions": "1.
|
|
53
|
-
"@types/lodash": "4.17.
|
|
52
|
+
"@opentelemetry/semantic-conventions": "1.43.0",
|
|
53
|
+
"@types/lodash": "4.17.27",
|
|
54
54
|
"@types/node": "25.6.2",
|
|
55
|
-
"@vitest/coverage-v8": "4.1.
|
|
56
|
-
"@vitest/ui": "4.1.
|
|
57
|
-
"lockfile-lint": "5.
|
|
55
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
56
|
+
"@vitest/ui": "4.1.11",
|
|
57
|
+
"lockfile-lint": "5.1.0",
|
|
58
58
|
"madge": "8.0.0",
|
|
59
59
|
"nock": "14.0.15",
|
|
60
|
-
"oxfmt": "0.
|
|
61
|
-
"oxlint": "1.
|
|
62
|
-
"oxlint-tsgolint": "7.0.
|
|
60
|
+
"oxfmt": "0.74.0",
|
|
61
|
+
"oxlint": "1.89.0",
|
|
62
|
+
"oxlint-tsgolint": "7.0.2004",
|
|
63
63
|
"rimraf": "6.1.3",
|
|
64
|
-
"semantic-release": "25.0.
|
|
65
|
-
"tsdown": "0.
|
|
64
|
+
"semantic-release": "25.0.9",
|
|
65
|
+
"tsdown": "0.23.1",
|
|
66
66
|
"vite-tsconfig-paths": "6.1.1",
|
|
67
|
-
"vitest": "4.1.
|
|
68
|
-
"vitest-mock-extended": "
|
|
67
|
+
"vitest": "4.1.11",
|
|
68
|
+
"vitest-mock-extended": "5.1.1"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
71
|
"@diia-inhouse/diia-metrics": ">=4.0.0",
|