@yildizpay/http-adapter 3.0.0 → 3.2.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 +253 -9
- package/README.tr.md +288 -44
- package/dist/builders/request.builder.d.ts +3 -0
- package/dist/builders/request.builder.js +6 -1
- package/dist/builders/request.builder.js.map +1 -1
- package/dist/contracts/http-client.contract.d.ts +0 -9
- package/dist/contracts/http-client.contract.js +0 -17
- package/dist/contracts/http-client.contract.js.map +1 -1
- package/dist/contracts/http-interceptor.contract.d.ts +6 -2
- package/dist/contracts/response-validator.contract.d.ts +4 -0
- package/dist/contracts/response-validator.contract.js +3 -0
- package/dist/contracts/response-validator.contract.js.map +1 -0
- package/dist/core/default-http-client.js +7 -6
- package/dist/core/default-http-client.js.map +1 -1
- package/dist/core/error.converter.d.ts +5 -0
- package/dist/core/error.converter.js +31 -0
- package/dist/core/error.converter.js.map +1 -0
- package/dist/core/http.adapter.js +28 -4
- package/dist/core/http.adapter.js.map +1 -1
- package/dist/exceptions/base-adapter.exception.d.ts +7 -0
- package/dist/exceptions/base-adapter.exception.js +34 -0
- package/dist/exceptions/base-adapter.exception.js.map +1 -0
- package/dist/exceptions/circuit-breaker-open.exception.d.ts +2 -2
- package/dist/exceptions/circuit-breaker-open.exception.js +3 -3
- package/dist/exceptions/circuit-breaker-open.exception.js.map +1 -1
- package/dist/exceptions/exception.guards.d.ts +17 -0
- package/dist/exceptions/exception.guards.js +53 -0
- package/dist/exceptions/exception.guards.js.map +1 -0
- package/dist/exceptions/http-exception.factory.d.ts +5 -0
- package/dist/exceptions/http-exception.factory.js +59 -0
- package/dist/exceptions/http-exception.factory.js.map +1 -0
- package/dist/exceptions/http-status.exceptions.d.ts +134 -0
- package/dist/exceptions/http-status.exceptions.js +382 -0
- package/dist/exceptions/http-status.exceptions.js.map +1 -0
- package/dist/exceptions/network-exception.factory.d.ts +6 -0
- package/dist/exceptions/network-exception.factory.js +35 -0
- package/dist/exceptions/network-exception.factory.js.map +1 -0
- package/dist/exceptions/network.exceptions.d.ts +25 -0
- package/dist/exceptions/network.exceptions.js +69 -0
- package/dist/exceptions/network.exceptions.js.map +1 -0
- package/dist/exceptions/unknown.exception.d.ts +7 -0
- package/dist/exceptions/unknown.exception.js +20 -0
- package/dist/exceptions/unknown.exception.js.map +1 -0
- package/dist/exceptions/validation.exception.d.ts +9 -0
- package/dist/exceptions/validation.exception.js +25 -0
- package/dist/exceptions/validation.exception.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/models/request-context.d.ts +5 -0
- package/dist/models/request-context.js +3 -0
- package/dist/models/request-context.js.map +1 -0
- package/dist/models/request.d.ts +3 -1
- package/dist/models/request.js +2 -1
- package/dist/models/request.js.map +1 -1
- package/dist/models/response.d.ts +8 -5
- package/dist/models/response.js +9 -5
- package/dist/models/response.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +17 -3
- package/dist/exceptions/http.exception.d.ts +0 -5
- package/dist/exceptions/http.exception.js +0 -12
- package/dist/exceptions/http.exception.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,23 @@ export * from './builders/request.builder';
|
|
|
4
4
|
export * from './models/request';
|
|
5
5
|
export * from './models/response';
|
|
6
6
|
export * from './models/request-options';
|
|
7
|
+
export * from './models/request-context';
|
|
7
8
|
export * from './contracts/http-interceptor.contract';
|
|
8
9
|
export * from './contracts/retry-policy.contract';
|
|
10
|
+
export * from './contracts/response-validator.contract';
|
|
9
11
|
export * from './resilience/retry.policies';
|
|
10
12
|
export * from './resilience/circuit-breaker/circuit-state.enum';
|
|
11
13
|
export * from './resilience/circuit-breaker/circuit-breaker-options';
|
|
12
14
|
export * from './resilience/circuit-breaker/circuit-breaker';
|
|
13
15
|
export * from './common/enums/http-method.enum';
|
|
14
16
|
export * from './common/types/http.types';
|
|
15
|
-
export * from './exceptions/http.exception';
|
|
16
17
|
export * from './exceptions/circuit-breaker-open.exception';
|
|
18
|
+
export * from './exceptions/base-adapter.exception';
|
|
19
|
+
export * from './exceptions/http-status.exceptions';
|
|
20
|
+
export * from './exceptions/http-exception.factory';
|
|
21
|
+
export * from './exceptions/network.exceptions';
|
|
22
|
+
export * from './exceptions/network-exception.factory';
|
|
23
|
+
export * from './exceptions/unknown.exception';
|
|
24
|
+
export * from './exceptions/validation.exception';
|
|
25
|
+
export * from './exceptions/exception.guards';
|
|
26
|
+
export * from './core/error.converter';
|
package/dist/index.js
CHANGED
|
@@ -20,14 +20,24 @@ __exportStar(require("./builders/request.builder"), exports);
|
|
|
20
20
|
__exportStar(require("./models/request"), exports);
|
|
21
21
|
__exportStar(require("./models/response"), exports);
|
|
22
22
|
__exportStar(require("./models/request-options"), exports);
|
|
23
|
+
__exportStar(require("./models/request-context"), exports);
|
|
23
24
|
__exportStar(require("./contracts/http-interceptor.contract"), exports);
|
|
24
25
|
__exportStar(require("./contracts/retry-policy.contract"), exports);
|
|
26
|
+
__exportStar(require("./contracts/response-validator.contract"), exports);
|
|
25
27
|
__exportStar(require("./resilience/retry.policies"), exports);
|
|
26
28
|
__exportStar(require("./resilience/circuit-breaker/circuit-state.enum"), exports);
|
|
27
29
|
__exportStar(require("./resilience/circuit-breaker/circuit-breaker-options"), exports);
|
|
28
30
|
__exportStar(require("./resilience/circuit-breaker/circuit-breaker"), exports);
|
|
29
31
|
__exportStar(require("./common/enums/http-method.enum"), exports);
|
|
30
32
|
__exportStar(require("./common/types/http.types"), exports);
|
|
31
|
-
__exportStar(require("./exceptions/http.exception"), exports);
|
|
32
33
|
__exportStar(require("./exceptions/circuit-breaker-open.exception"), exports);
|
|
34
|
+
__exportStar(require("./exceptions/base-adapter.exception"), exports);
|
|
35
|
+
__exportStar(require("./exceptions/http-status.exceptions"), exports);
|
|
36
|
+
__exportStar(require("./exceptions/http-exception.factory"), exports);
|
|
37
|
+
__exportStar(require("./exceptions/network.exceptions"), exports);
|
|
38
|
+
__exportStar(require("./exceptions/network-exception.factory"), exports);
|
|
39
|
+
__exportStar(require("./exceptions/unknown.exception"), exports);
|
|
40
|
+
__exportStar(require("./exceptions/validation.exception"), exports);
|
|
41
|
+
__exportStar(require("./exceptions/exception.guards"), exports);
|
|
42
|
+
__exportStar(require("./core/error.converter"), exports);
|
|
33
43
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,sDAAoC;AACpC,6DAA2C;AAG3C,6DAA2C;AAG3C,mDAAiC;AACjC,oDAAkC;AAClC,2DAAyC;AAGzC,wEAAsD;AACtD,oEAAkD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,sDAAoC;AACpC,6DAA2C;AAG3C,6DAA2C;AAG3C,mDAAiC;AACjC,oDAAkC;AAClC,2DAAyC;AACzC,2DAAyC;AAGzC,wEAAsD;AACtD,oEAAkD;AAClD,0EAAwD;AAGxD,8DAA4C;AAC5C,kFAAgE;AAChE,uFAAqE;AACrE,+EAA6D;AAG7D,kEAAgD;AAChD,4DAA0C;AAG1C,8EAA4D;AAC5D,sEAAoD;AACpD,sEAAoD;AACpD,sEAAoD;AACpD,kEAAgD;AAChD,yEAAuD;AACvD,iEAA+C;AAC/C,oEAAkD;AAClD,gEAA8C;AAC9C,yDAAuC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/models/request-context.ts"],"names":[],"mappings":""}
|
package/dist/models/request.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { HttpMethod } from '../common/enums/http-method.enum';
|
|
2
2
|
import { HttpBody } from '../common/types/http.types';
|
|
3
3
|
import { RequestOptions } from './request-options';
|
|
4
|
+
import { ResponseValidator } from '../contracts/response-validator.contract';
|
|
4
5
|
export declare class Request {
|
|
5
6
|
readonly baseUrl: string;
|
|
6
7
|
readonly endpoint: string;
|
|
@@ -9,9 +10,10 @@ export declare class Request {
|
|
|
9
10
|
readonly queryParams: Record<string, string>;
|
|
10
11
|
readonly body: HttpBody | null;
|
|
11
12
|
readonly options: RequestOptions;
|
|
13
|
+
readonly validators: ResponseValidator[];
|
|
12
14
|
readonly systemCorrelationId: string;
|
|
13
15
|
timestamp: Date;
|
|
14
|
-
constructor(baseUrl: string, endpoint: string, method?: HttpMethod, headers?: Record<string, string>, queryParams?: Record<string, string>, body?: HttpBody | null, options?: RequestOptions);
|
|
16
|
+
constructor(baseUrl: string, endpoint: string, method?: HttpMethod, headers?: Record<string, string>, queryParams?: Record<string, string>, body?: HttpBody | null, options?: RequestOptions, validators?: ResponseValidator[]);
|
|
15
17
|
addParam(key: string, value: string | number | Record<string, any>): void;
|
|
16
18
|
addHeader(key: string, value: string): void;
|
|
17
19
|
addQueryParam(key: string, value: string): void;
|
package/dist/models/request.js
CHANGED
|
@@ -5,7 +5,7 @@ const str_util_1 = require("../common/utils/str.util");
|
|
|
5
5
|
const http_method_enum_1 = require("../common/enums/http-method.enum");
|
|
6
6
|
const request_options_1 = require("./request-options");
|
|
7
7
|
class Request {
|
|
8
|
-
constructor(baseUrl, endpoint, method = http_method_enum_1.HttpMethod.POST, headers = {}, queryParams = {}, body = null, options = new request_options_1.RequestOptions()) {
|
|
8
|
+
constructor(baseUrl, endpoint, method = http_method_enum_1.HttpMethod.POST, headers = {}, queryParams = {}, body = null, options = new request_options_1.RequestOptions(), validators = []) {
|
|
9
9
|
this.baseUrl = baseUrl;
|
|
10
10
|
this.endpoint = endpoint;
|
|
11
11
|
this.method = method;
|
|
@@ -13,6 +13,7 @@ class Request {
|
|
|
13
13
|
this.queryParams = queryParams;
|
|
14
14
|
this.body = body;
|
|
15
15
|
this.options = options;
|
|
16
|
+
this.validators = validators;
|
|
16
17
|
this.systemCorrelationId = str_util_1.StrUtil.generateUuid();
|
|
17
18
|
this.timestamp = new Date();
|
|
18
19
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/models/request.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,uEAA8D;AAE9D,uDAAmD;
|
|
1
|
+
{"version":3,"file":"request.js","sourceRoot":"","sources":["../../src/models/request.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,uEAA8D;AAE9D,uDAAmD;AAUnD,MAAa,OAAO;IAsBlB,YACkB,OAAe,EACf,QAAgB,EAChB,SAAqB,6BAAU,CAAC,IAAI,EACpC,UAAkC,EAAE,EACpC,cAAsC,EAAE,EACxC,OAAwB,IAAI,EAC5B,UAA0B,IAAI,gCAAc,EAAE,EAC9C,aAAkC,EAAE;QAPpC,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAA8B;QACpC,YAAO,GAAP,OAAO,CAA6B;QACpC,gBAAW,GAAX,WAAW,CAA6B;QACxC,SAAI,GAAJ,IAAI,CAAwB;QAC5B,YAAO,GAAP,OAAO,CAAuC;QAC9C,eAAU,GAAV,UAAU,CAA0B;QAEpD,IAAI,CAAC,mBAAmB,GAAG,kBAAO,CAAC,YAAY,EAAE,CAAC;QAClD,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IASM,QAAQ,CAAC,GAAW,EAAE,KAA4C;QACvE,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC9D,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACzB,CAAC;IAQM,SAAS,CAAC,GAAW,EAAE,KAAa;QACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC5B,CAAC;IAQM,aAAa,CAAC,GAAW,EAAE,KAAa;QAC7C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAChC,CAAC;IAOM,YAAY,CAAC,SAAe;QACjC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAOM,aAAa;QAClB,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;SACtB,CAAC;IACJ,CAAC;CACF;AA7FD,0BA6FC"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { RequestContext } from './request-context';
|
|
2
|
+
export declare class Response<T = unknown> {
|
|
2
3
|
readonly data: T;
|
|
3
4
|
readonly status: number;
|
|
4
5
|
readonly headers: Record<string, string> | null;
|
|
5
|
-
readonly
|
|
6
|
+
readonly requestContext?: RequestContext | undefined;
|
|
6
7
|
readonly timestamp: Date;
|
|
7
|
-
constructor(
|
|
8
|
-
|
|
8
|
+
private constructor();
|
|
9
|
+
get systemCorrelationId(): string;
|
|
10
|
+
static create<T = unknown>(data: T, status: number, headers: Record<string, string> | null, requestContext?: RequestContext): Response<T>;
|
|
9
11
|
toDebugObject(): {
|
|
10
|
-
|
|
12
|
+
request?: RequestContext | undefined;
|
|
11
13
|
status: number;
|
|
12
14
|
headers: Record<string, string> | null;
|
|
15
|
+
data: T;
|
|
13
16
|
};
|
|
14
17
|
}
|
package/dist/models/response.js
CHANGED
|
@@ -2,21 +2,25 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Response = void 0;
|
|
4
4
|
class Response {
|
|
5
|
-
constructor(data, status, headers,
|
|
5
|
+
constructor(data, status, headers, requestContext) {
|
|
6
6
|
this.data = data;
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.headers = headers;
|
|
9
|
-
this.
|
|
9
|
+
this.requestContext = requestContext;
|
|
10
10
|
this.timestamp = new Date();
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
return
|
|
12
|
+
get systemCorrelationId() {
|
|
13
|
+
return this.requestContext?.correlationId ?? '';
|
|
14
|
+
}
|
|
15
|
+
static create(data, status, headers, requestContext) {
|
|
16
|
+
return new Response(data, status, headers, requestContext);
|
|
14
17
|
}
|
|
15
18
|
toDebugObject() {
|
|
16
19
|
return {
|
|
17
|
-
data: this.data,
|
|
18
20
|
status: this.status,
|
|
19
21
|
headers: this.headers,
|
|
22
|
+
data: this.data,
|
|
23
|
+
...(this.requestContext && { request: this.requestContext }),
|
|
20
24
|
};
|
|
21
25
|
}
|
|
22
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/models/response.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"response.js","sourceRoot":"","sources":["../../src/models/response.ts"],"names":[],"mappings":";;;AAWA,MAAa,QAAQ;IAcnB,YACkB,IAAO,EACP,MAAc,EACd,OAAsC,EACtC,cAA+B;QAH/B,SAAI,GAAJ,IAAI,CAAG;QACP,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAA+B;QACtC,mBAAc,GAAd,cAAc,CAAiB;QAE/C,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IAMD,IAAW,mBAAmB;QAC5B,OAAO,IAAI,CAAC,cAAc,EAAE,aAAa,IAAI,EAAE,CAAC;IAClD,CAAC;IAYM,MAAM,CAAC,MAAM,CAClB,IAAO,EACP,MAAc,EACd,OAAsC,EACtC,cAA+B;QAE/B,OAAO,IAAI,QAAQ,CAAI,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;IAChE,CAAC;IAMM,aAAa;QAClB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;SAC7D,CAAC;IACJ,CAAC;CACF;AA9DD,4BA8DC"}
|