@yildizpay/http-adapter 3.0.0 → 3.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.
Files changed (51) hide show
  1. package/README.md +186 -9
  2. package/README.tr.md +221 -44
  3. package/dist/contracts/http-client.contract.d.ts +0 -9
  4. package/dist/contracts/http-client.contract.js +0 -17
  5. package/dist/contracts/http-client.contract.js.map +1 -1
  6. package/dist/contracts/http-interceptor.contract.d.ts +2 -1
  7. package/dist/core/default-http-client.js +7 -6
  8. package/dist/core/default-http-client.js.map +1 -1
  9. package/dist/core/error.converter.d.ts +5 -0
  10. package/dist/core/error.converter.js +31 -0
  11. package/dist/core/error.converter.js.map +1 -0
  12. package/dist/core/http.adapter.js +11 -4
  13. package/dist/core/http.adapter.js.map +1 -1
  14. package/dist/exceptions/base-adapter.exception.d.ts +7 -0
  15. package/dist/exceptions/base-adapter.exception.js +34 -0
  16. package/dist/exceptions/base-adapter.exception.js.map +1 -0
  17. package/dist/exceptions/circuit-breaker-open.exception.d.ts +2 -2
  18. package/dist/exceptions/circuit-breaker-open.exception.js +3 -3
  19. package/dist/exceptions/circuit-breaker-open.exception.js.map +1 -1
  20. package/dist/exceptions/exception.guards.d.ts +15 -0
  21. package/dist/exceptions/exception.guards.js +48 -0
  22. package/dist/exceptions/exception.guards.js.map +1 -0
  23. package/dist/exceptions/http-exception.factory.d.ts +5 -0
  24. package/dist/exceptions/http-exception.factory.js +59 -0
  25. package/dist/exceptions/http-exception.factory.js.map +1 -0
  26. package/dist/exceptions/http-status.exceptions.d.ts +134 -0
  27. package/dist/exceptions/http-status.exceptions.js +382 -0
  28. package/dist/exceptions/http-status.exceptions.js.map +1 -0
  29. package/dist/exceptions/network-exception.factory.d.ts +6 -0
  30. package/dist/exceptions/network-exception.factory.js +35 -0
  31. package/dist/exceptions/network-exception.factory.js.map +1 -0
  32. package/dist/exceptions/network.exceptions.d.ts +25 -0
  33. package/dist/exceptions/network.exceptions.js +69 -0
  34. package/dist/exceptions/network.exceptions.js.map +1 -0
  35. package/dist/exceptions/unknown.exception.d.ts +7 -0
  36. package/dist/exceptions/unknown.exception.js +20 -0
  37. package/dist/exceptions/unknown.exception.js.map +1 -0
  38. package/dist/index.d.ts +9 -1
  39. package/dist/index.js +9 -1
  40. package/dist/index.js.map +1 -1
  41. package/dist/models/request-context.d.ts +5 -0
  42. package/dist/models/request-context.js +3 -0
  43. package/dist/models/request-context.js.map +1 -0
  44. package/dist/models/response.d.ts +8 -5
  45. package/dist/models/response.js +9 -5
  46. package/dist/models/response.js.map +1 -1
  47. package/dist/tsconfig.tsbuildinfo +1 -1
  48. package/package.json +1 -1
  49. package/dist/exceptions/http.exception.d.ts +0 -5
  50. package/dist/exceptions/http.exception.js +0 -12
  51. package/dist/exceptions/http.exception.js.map +0 -1
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=request-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.js","sourceRoot":"","sources":["../../src/models/request-context.ts"],"names":[],"mappings":""}
@@ -1,14 +1,17 @@
1
- export declare class Response<T = any> {
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 systemCorrelationId: string;
6
+ readonly requestContext?: RequestContext | undefined;
6
7
  readonly timestamp: Date;
7
- constructor(data: T, status: number, headers: Record<string, string> | null, systemCorrelationId: string);
8
- static create<T = any>(data: T, status: number, headers: Record<string, string> | null, systemCorrelationId: string): Response<T>;
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
- data: T;
12
+ request?: RequestContext | undefined;
11
13
  status: number;
12
14
  headers: Record<string, string> | null;
15
+ data: T;
13
16
  };
14
17
  }
@@ -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, systemCorrelationId) {
5
+ constructor(data, status, headers, requestContext) {
6
6
  this.data = data;
7
7
  this.status = status;
8
8
  this.headers = headers;
9
- this.systemCorrelationId = systemCorrelationId;
9
+ this.requestContext = requestContext;
10
10
  this.timestamp = new Date();
11
11
  }
12
- static create(data, status, headers, systemCorrelationId) {
13
- return new Response(data, status, headers, systemCorrelationId);
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":";;;AASA,MAAa,QAAQ;IAcnB,YACkB,IAAO,EACP,MAAc,EACd,OAAsC,EACtC,mBAA2B;QAH3B,SAAI,GAAJ,IAAI,CAAG;QACP,WAAM,GAAN,MAAM,CAAQ;QACd,YAAO,GAAP,OAAO,CAA+B;QACtC,wBAAmB,GAAnB,mBAAmB,CAAQ;QAE3C,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IAYM,MAAM,CAAC,MAAM,CAClB,IAAO,EACP,MAAc,EACd,OAAsC,EACtC,mBAA2B;QAE3B,OAAO,IAAI,QAAQ,CAAI,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC;IACrE,CAAC;IAQM,aAAa;QAClB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;SAC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