jordy 0.14.4 → 0.14.7

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.
@@ -1,4 +1,4 @@
1
- import { __read, __spreadArray } from "tslib";
1
+ import { __awaiter, __generator, __read, __spreadArray } from "tslib";
2
2
  import { throwHttpRestError } from './network.util';
3
3
  function isConstructor(val) {
4
4
  return typeof val === 'function';
@@ -14,15 +14,20 @@ export function ErrorParser(throwableParser) {
14
14
  for (var _i = 0; _i < arguments.length; _i++) {
15
15
  args[_i] = arguments[_i];
16
16
  }
17
+ var _this = this;
18
+ this.parse = function (error) { return __awaiter(_this, void 0, void 0, function () {
19
+ var nextError;
20
+ return __generator(this, function (_a) {
21
+ nextError = throwableParser(error);
22
+ if (nextError) {
23
+ throw nextError;
24
+ }
25
+ throwHttpRestError(error);
26
+ return [2];
27
+ });
28
+ }); };
17
29
  this.network = new ClassConstructor(args[0], args[1], args[2]);
18
30
  }
19
- ErrorParserDecoratedUnionHttpNetworkProvider.prototype.parse = function (error) {
20
- var nextError = throwableParser(error);
21
- if (nextError) {
22
- throw nextError;
23
- }
24
- throwHttpRestError(error);
25
- };
26
31
  ErrorParserDecoratedUnionHttpNetworkProvider.prototype.get = function () {
27
32
  var args = [];
28
33
  for (var _i = 0; _i < arguments.length; _i++) {
@@ -1,12 +1,21 @@
1
- import { HttpRestError } from '../../types';
1
+ import { HttpRestError, } from '../../types';
2
2
  import { isAxiosError } from './axios.util';
3
+ function tryGetMethod(method) {
4
+ try {
5
+ return method.toLocaleLowerCase();
6
+ }
7
+ catch (error) {
8
+ return undefined;
9
+ }
10
+ }
3
11
  export function throwableAxiosErrorParser(error) {
4
12
  var _a, _b;
5
13
  if (isAxiosError(error)) {
6
14
  var errorData = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
7
15
  var meta = {
8
16
  url: error.config.url || '',
9
- status: ((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 0,
17
+ method: tryGetMethod(error.config.method),
18
+ status: Number(((_b = error.response) === null || _b === void 0 ? void 0 : _b.status) || 0),
10
19
  rawData: errorData,
11
20
  };
12
21
  if (HttpRestError.isErrorLike(errorData)) {
@@ -4,8 +4,10 @@ var HttpRestError = (function (_super) {
4
4
  function HttpRestError(message, arg1) {
5
5
  if (message === void 0) { message = HttpRestError.DEFAULT_MESSAGE; }
6
6
  var _this = _super.call(this, message) || this;
7
+ _this.name = 'HttpRestError';
7
8
  _this._errorType = 'unknown';
8
9
  _this._url = '';
10
+ _this._method = undefined;
9
11
  _this._rawData = null;
10
12
  if (typeof arg1 === 'number') {
11
13
  _this._errorType = HttpRestError.toErrorType(arg1);
@@ -17,13 +19,15 @@ var HttpRestError = (function (_super) {
17
19
  }
18
20
  if (HttpRestError.isHttpRestErrorLike(arg1)) {
19
21
  _this._url = arg1.url;
22
+ _this._method = arg1.method;
20
23
  _this._errorType = arg1.errorType;
21
24
  _this._rawData = arg1.rawData;
22
25
  return _this;
23
26
  }
24
27
  if (typeof arg1 !== 'string' && arg1) {
25
28
  _this._url = arg1.url || '';
26
- _this._errorType = HttpRestError.toErrorType(arg1.status);
29
+ _this._method = arg1.method;
30
+ _this._errorType = HttpRestError.toErrorType(Number(arg1.status));
27
31
  _this._rawData = arg1.rawData;
28
32
  }
29
33
  return _this;
@@ -42,6 +46,13 @@ var HttpRestError = (function (_super) {
42
46
  enumerable: false,
43
47
  configurable: true
44
48
  });
49
+ Object.defineProperty(HttpRestError.prototype, "method", {
50
+ get: function () {
51
+ return this._method;
52
+ },
53
+ enumerable: false,
54
+ configurable: true
55
+ });
45
56
  Object.defineProperty(HttpRestError.prototype, "rawData", {
46
57
  get: function () {
47
58
  return this._rawData;
@@ -52,6 +63,7 @@ var HttpRestError = (function (_super) {
52
63
  HttpRestError.prototype.toPlainObject = function () {
53
64
  return {
54
65
  message: this.message,
66
+ method: this._method,
55
67
  errorType: this._errorType,
56
68
  url: this._url,
57
69
  rawData: this._rawData,
@@ -1,5 +1,5 @@
1
- import { HttpRestErrorLike } from '../types';
2
- import { HttpInterceptorConfig, RestHttpMethodType } from './network.type';
1
+ import { HttpRestErrorLike, RestHttpMethodType } from '../types';
2
+ import { HttpInterceptorConfig } from './network.type';
3
3
  export declare class BaseInterceptorHttpApi {
4
4
  paramsSerializer: (params: any) => string;
5
5
  private _interceptor;
@@ -1,4 +1,4 @@
1
- import { HttpRestErrorLike, MarshallingType } from '../types';
1
+ import { HttpRestErrorLike, MarshallingType, RestHttpMethodType } from '../types';
2
2
  /**
3
3
  * 업로드 상태를 확인할 수 있는 객체.
4
4
  */
@@ -108,7 +108,6 @@ export interface HttpFileApi {
108
108
  */
109
109
  export interface HttpApi extends HttpRestApi, HttpFileApi {
110
110
  }
111
- export declare type RestHttpMethodType = 'get' | 'post' | 'put' | 'patch' | 'delete';
112
111
  export interface HttpInterceptorConfig {
113
112
  /**
114
113
  * 요청 쿼리 파라미터에 특별한 값을 덧붙일 때 설정하는 인터셉터.
@@ -1,14 +1,17 @@
1
+ import { RestHttpMethodType } from './etc.type';
1
2
  export declare type HttpRestErrorType = 'unknown' | 'auth' | 'forbidden' | 'notFound' | 'badRequest' | 'server';
2
3
  export interface ErrorLike {
3
4
  message: string;
4
5
  }
5
6
  export interface HttpRestErrorMeta {
6
7
  url: string;
8
+ method?: RestHttpMethodType;
7
9
  rawData?: any;
8
10
  errorType: HttpRestErrorType;
9
11
  }
10
12
  export interface HttpRestErrorMetaArgs {
11
13
  url: string;
14
+ method?: RestHttpMethodType;
12
15
  rawData: any;
13
16
  status: number;
14
17
  }
@@ -16,10 +19,13 @@ export interface HttpRestErrorLike extends ErrorLike, HttpRestErrorMeta {
16
19
  }
17
20
  export declare class HttpRestError extends Error implements HttpRestErrorLike {
18
21
  static readonly DEFAULT_MESSAGE = "\uC54C \uC218 \uC5C6\uB294 \uC11C\uBC84 \uC624\uB958\uC785\uB2C8\uB2E4";
22
+ readonly name = "HttpRestError";
19
23
  private _errorType;
20
24
  get errorType(): HttpRestErrorType;
21
25
  private _url;
22
26
  get url(): string;
27
+ private _method;
28
+ get method(): RestHttpMethodType | undefined;
23
29
  private _rawData;
24
30
  get rawData(): any;
25
31
  constructor();
@@ -33,5 +39,6 @@ export declare class HttpRestError extends Error implements HttpRestErrorLike {
33
39
  static isHttpRestErrorType(value: unknown): value is HttpRestErrorType;
34
40
  static isErrorLike(error: unknown): error is ErrorLike;
35
41
  static isHttpRestErrorLike(error: unknown): error is HttpRestErrorLike;
36
- static from(error: any, errorType?: HttpRestErrorType): HttpRestError;
42
+ static from(error: ErrorLike | string | HttpRestErrorLike): HttpRestError;
43
+ static from(error: ErrorLike | string, errorType?: HttpRestErrorType): HttpRestError;
37
44
  }
@@ -3,3 +3,4 @@ export interface PromiseResolver<T, E = any> {
3
3
  resolve: (value: T | PromiseLike<T>) => void;
4
4
  reject: (reason?: E) => void;
5
5
  }
6
+ export declare type RestHttpMethodType = 'get' | 'post' | 'put' | 'patch' | 'delete';
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "jordy",
3
- "version": "0.14.4",
3
+ "version": "0.14.7",
4
4
  "description": "typescript based frontend toolkit",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/thesoncriel/jordy"
8
+ },
5
9
  "main": "./esm5/index.js",
6
10
  "module": "./esm5/index.js",
7
11
  "types": "./libs/index.d.ts",
@@ -50,7 +54,7 @@
50
54
  "rimraf": "^3.0.2",
51
55
  "ts-node": "^10.3.0",
52
56
  "tslib": "^2.3.1",
53
- "typescript": "^4.7.4",
57
+ "typescript": "^4.8.2",
54
58
  "vite": "^3.0.2",
55
59
  "vitest": "^0.22.1"
56
60
  },