@ancon/wildcat-utils 1.38.2 → 1.38.3

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,3 +1,4 @@
1
+ import { ErrorCode } from '@ancon/wildcat-types';
1
2
  import { SerializedAPIError } from './types';
2
- declare function isSerializedAPIError(error: unknown): error is SerializedAPIError;
3
+ declare function isSerializedAPIError(error: unknown, errorCode?: ErrorCode): error is SerializedAPIError;
3
4
  export default isSerializedAPIError;
@@ -1 +1 @@
1
- "use strict";const t=require("axios"),i=require("@ancon/wildcat-types");function a(o){var e,s;const r=o;return t.isAxiosError(r)||!((s=(e=r==null?void 0:r.response)==null?void 0:e.data)!=null&&s.errorCode)?!1:Object.values(i.ErrorCode).includes(r.response.data.errorCode)}module.exports=a;
1
+ "use strict";const u=require("axios"),l=require("@ancon/wildcat-types");function a(r,s){var o,t,i,n;const e=r;return s!=null?a(r)&&((t=(o=r.response)==null?void 0:o.data)==null?void 0:t.errorCode)===s:u.isAxiosError(e)||!((n=(i=e==null?void 0:e.response)==null?void 0:i.data)!=null&&n.errorCode)?!1:Object.values(l.ErrorCode).includes(e.response.data.errorCode)}module.exports=a;
@@ -1,10 +1,10 @@
1
- import { isAxiosError as t } from "axios";
2
- import { ErrorCode as a } from "@ancon/wildcat-types";
3
- function d(s) {
4
- var e, o;
5
- const r = s;
6
- return t(r) || !((o = (e = r == null ? void 0 : r.response) == null ? void 0 : e.data) != null && o.errorCode) ? !1 : Object.values(a).includes(r.response.data.errorCode);
1
+ import { isAxiosError as i } from "axios";
2
+ import { ErrorCode as u } from "@ancon/wildcat-types";
3
+ function l(e, o) {
4
+ var s, t, a, n;
5
+ const r = e;
6
+ return o != null ? l(e) && ((t = (s = e.response) == null ? void 0 : s.data) == null ? void 0 : t.errorCode) === o : i(r) || !((n = (a = r == null ? void 0 : r.response) == null ? void 0 : a.data) != null && n.errorCode) ? !1 : Object.values(u).includes(r.response.data.errorCode);
7
7
  }
8
8
  export {
9
- d as default
9
+ l as default
10
10
  };
@@ -1,3 +1,4 @@
1
+ import { ErrorCode } from '@ancon/wildcat-types';
1
2
  import { SerializedCodedError } from './types';
2
- declare function isSerializedCodedError(error: unknown): error is SerializedCodedError;
3
+ declare function isSerializedCodedError(error: unknown, errorCode?: ErrorCode): error is SerializedCodedError;
3
4
  export default isSerializedCodedError;
@@ -1 +1 @@
1
- "use strict";const s=require("axios"),o=require("@ancon/wildcat-types");function i(r){const e=r;return s.isAxiosError(e)||!(e!=null&&e.code)?!1:Object.values(o.ErrorCode).includes(e.code)}module.exports=i;
1
+ "use strict";const r=require("axios"),u=require("@ancon/wildcat-types");function t(s,i){const e=s;return i!=null?t(s)&&s.code===i:r.isAxiosError(e)||!(e!=null&&e.code)?!1:Object.values(u.ErrorCode).includes(e.code)}module.exports=t;
@@ -1,9 +1,9 @@
1
- import { isAxiosError as o } from "axios";
1
+ import { isAxiosError as r } from "axios";
2
2
  import { ErrorCode as s } from "@ancon/wildcat-types";
3
- function a(e) {
4
- const r = e;
5
- return o(r) || !(r != null && r.code) ? !1 : Object.values(s).includes(r.code);
3
+ function t(o, i) {
4
+ const e = o;
5
+ return i != null ? t(o) && o.code === i : r(e) || !(e != null && e.code) ? !1 : Object.values(s).includes(e.code);
6
6
  }
7
7
  export {
8
- a as default
8
+ t as default
9
9
  };
package/error/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { APIGenericError, ErrorCode } from '@ancon/wildcat-types';
2
2
  export declare type SerializedAxiosError = {
3
3
  message: string;
4
+ /** NOTE: HTTP status code */
4
5
  code?: string;
5
6
  response?: {
6
7
  status?: number;
@@ -9,6 +10,7 @@ export declare type SerializedAxiosError = {
9
10
  };
10
11
  export declare type SerializedAPIError<T = unknown> = {
11
12
  message: string;
13
+ /** NOTE: HTTP status code */
12
14
  code?: string;
13
15
  response: {
14
16
  status?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.38.2",
3
+ "version": "1.38.3",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",