@ancon/wildcat-utils 1.42.4 → 1.42.6
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/error/isAPIError.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { APIError, APIGenericError, ErrorCode } from '@ancon/wildcat-types';
|
|
|
2
2
|
/** Whether provided error is an API error */
|
|
3
3
|
declare function isAPIError<AdditionalDataType = unknown, ErrorType = APIGenericError<AdditionalDataType>>(error: unknown): error is APIError<AdditionalDataType, ErrorType>;
|
|
4
4
|
/** Whether provided error is an API error with the provided `errorCode` */
|
|
5
|
-
declare function isAPIError<AdditionalDataType = unknown, ErrorType = APIGenericError<AdditionalDataType>>(error: unknown, errorCode: ErrorCode): error is APIError<AdditionalDataType, ErrorType>;
|
|
5
|
+
declare function isAPIError<AdditionalDataType = unknown, ErrorType = APIGenericError<AdditionalDataType>>(error: unknown, errorCode: ErrorCode | ErrorCode[]): error is APIError<AdditionalDataType, ErrorType>;
|
|
6
6
|
export default isAPIError;
|
package/error/isAPIError.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const p=require("@ancon/wildcat-types"),u=require("axios");function d(s,e){var t,r,i,n,o,a;const c=Object.values(p.ErrorCode);return e!=null?Array.isArray(e)?u.isAxiosError(s)&&typeof((r=(t=s.response)==null?void 0:t.data)==null?void 0:r.errorCode)=="string"&&e.includes((i=s.response)==null?void 0:i.data.errorCode):d(s)&&((n=s.response)==null?void 0:n.data.errorCode)===e:u.isAxiosError(s)&&typeof((a=(o=s.response)==null?void 0:o.data)==null?void 0:a.errorCode)=="string"&&c.includes(s.response.data.errorCode)}module.exports=d;
|
package/error/isAPIError.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { ErrorCode as
|
|
2
|
-
import { isAxiosError as
|
|
3
|
-
function
|
|
4
|
-
var
|
|
5
|
-
const
|
|
6
|
-
return
|
|
1
|
+
import { ErrorCode as u } from "@ancon/wildcat-types";
|
|
2
|
+
import { isAxiosError as d } from "axios";
|
|
3
|
+
function f(s, e) {
|
|
4
|
+
var t, a, n, o, r, i;
|
|
5
|
+
const p = Object.values(u);
|
|
6
|
+
return e != null ? Array.isArray(e) ? d(s) && typeof ((a = (t = s.response) == null ? void 0 : t.data) == null ? void 0 : a.errorCode) == "string" && e.includes((n = s.response) == null ? void 0 : n.data.errorCode) : f(s) && ((o = s.response) == null ? void 0 : o.data.errorCode) === e : d(s) && typeof ((i = (r = s.response) == null ? void 0 : r.data) == null ? void 0 : i.errorCode) == "string" && p.includes(s.response.data.errorCode);
|
|
7
7
|
}
|
|
8
8
|
export {
|
|
9
|
-
|
|
9
|
+
f as default
|
|
10
10
|
};
|
|
@@ -3,4 +3,4 @@ import { LicenseUIState } from './types';
|
|
|
3
3
|
export declare function isLicenseTerminated(licenseStatus: LicenseStatus): boolean;
|
|
4
4
|
export declare function isLicenseExpired(licenseStatus: LicenseStatus): boolean;
|
|
5
5
|
export declare function isLicenseExtended(licenseStatus: LicenseStatus): boolean;
|
|
6
|
-
export default function getLicenseUIState(licenseState: LicenseStatus, endDate?: string, deleted?: string,
|
|
6
|
+
export default function getLicenseUIState(licenseState: LicenseStatus, startDate: string, endDate?: string, deleted?: string, warnThreshold?: number): LicenseUIState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("moment"),i=require("@ancon/wildcat-types"),t=require("./types.js");function d(e){return(e&i.LicenseStatus.Terminated)===i.LicenseStatus.Terminated}function u(e){return(e&i.LicenseStatus.Expired)===i.LicenseStatus.Expired}function o(e){return(e&i.LicenseStatus.Extended)===i.LicenseStatus.Extended}function E(e,f,s,L,m=.25){if(L)return t.LicenseUIState.Deleted;if(d(e))return t.LicenseUIState.Terminated;if(u(e))return t.LicenseUIState.Expired;if(o(e))return t.LicenseUIState.Extended;if(s){const r=n(s),c=n(f);if(c.isSameOrBefore(n())){const a=r.diff(n(),"day");if(a>=0){const S=r.diff(c,"day"),x=a/S;if(m>=x)return t.LicenseUIState.AboutToExpire}}}return t.LicenseUIState.Valid}exports.default=E;exports.isLicenseExpired=u;exports.isLicenseExtended=o;exports.isLicenseTerminated=d;
|
|
@@ -1,21 +1,40 @@
|
|
|
1
|
-
import
|
|
1
|
+
import t from "moment";
|
|
2
2
|
import { LicenseStatus as r } from "@ancon/wildcat-types";
|
|
3
|
-
import { LicenseUIState as
|
|
4
|
-
function
|
|
3
|
+
import { LicenseUIState as n } from "./types.mjs";
|
|
4
|
+
function x(e) {
|
|
5
5
|
return (e & r.Terminated) === r.Terminated;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function p(e) {
|
|
8
8
|
return (e & r.Expired) === r.Expired;
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function E(e) {
|
|
11
11
|
return (e & r.Extended) === r.Extended;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
13
|
+
function I(e, m, i, s, a = 0.25) {
|
|
14
|
+
if (s)
|
|
15
|
+
return n.Deleted;
|
|
16
|
+
if (x(e))
|
|
17
|
+
return n.Terminated;
|
|
18
|
+
if (p(e))
|
|
19
|
+
return n.Expired;
|
|
20
|
+
if (E(e))
|
|
21
|
+
return n.Extended;
|
|
22
|
+
if (i) {
|
|
23
|
+
const d = t(i), o = t(m);
|
|
24
|
+
if (o.isSameOrBefore(t())) {
|
|
25
|
+
const f = d.diff(t(), "day");
|
|
26
|
+
if (f >= 0) {
|
|
27
|
+
const u = d.diff(o, "day"), c = f / u;
|
|
28
|
+
if (a >= c)
|
|
29
|
+
return n.AboutToExpire;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return n.Valid;
|
|
15
34
|
}
|
|
16
35
|
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
36
|
+
I as default,
|
|
37
|
+
p as isLicenseExpired,
|
|
38
|
+
E as isLicenseExtended,
|
|
39
|
+
x as isLicenseTerminated
|
|
21
40
|
};
|