@binamik/js-providers 0.1.3 → 0.1.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.
- package/dist/IoProvider/IoProvider.d.ts +2 -2
- package/dist/SafeDate/SafeDate.d.ts +8 -1
- package/dist/SafeDate/i18n/localizedFormatString.d.ts +5 -0
- package/dist/SafeDate/i18n/safeLangCode.d.ts +1 -0
- package/dist/binamik-js-providers.es.js +110 -7
- package/dist/binamik-js-providers.umd.js +1 -1
- package/package.json +1 -1
|
@@ -21,8 +21,8 @@ export interface IoErrorProps {
|
|
|
21
21
|
export interface IoResponseMetaProps {
|
|
22
22
|
status: number;
|
|
23
23
|
}
|
|
24
|
-
declare type IOResponseType<T> = [T, null, IoResponseMetaProps];
|
|
25
|
-
declare type IOResponseErrorType = [null, IoErrorProps, IoResponseMetaProps];
|
|
24
|
+
declare type IOResponseType<T> = [T, null, IoResponseMetaProps?];
|
|
25
|
+
declare type IOResponseErrorType = [null, IoErrorProps, IoResponseMetaProps?];
|
|
26
26
|
export declare type ApiResponseDTO<T> = IOResponseType<T> | IOResponseErrorType;
|
|
27
27
|
declare type IoFn = <T>(url: string, payload?: Record<string, unknown>, config?: AxiosRequestConfig) => Promise<ApiResponseDTO<T>>;
|
|
28
28
|
interface IoInstanceProps {
|
|
@@ -21,15 +21,20 @@ interface SetToOptions {
|
|
|
21
21
|
export declare class SafeDate {
|
|
22
22
|
private value;
|
|
23
23
|
private isDateValid;
|
|
24
|
-
|
|
24
|
+
private locale;
|
|
25
25
|
private returnHandler;
|
|
26
|
+
private i18nFormat;
|
|
27
|
+
private getI18nCode;
|
|
28
|
+
static isValid(value?: Date | string | Dayjs): boolean;
|
|
26
29
|
get isValid(): boolean;
|
|
30
|
+
get lang(): string;
|
|
27
31
|
get jsDate(): Date;
|
|
28
32
|
get timestamp(): number;
|
|
29
33
|
get isoDate(): string;
|
|
30
34
|
get isoString(): string;
|
|
31
35
|
get dateString(): string;
|
|
32
36
|
get longDayMonth(): string;
|
|
37
|
+
get shortDayMonth(): string;
|
|
33
38
|
get longDateString(): string;
|
|
34
39
|
get timeString(): string;
|
|
35
40
|
get daysInMonth(): number;
|
|
@@ -56,6 +61,8 @@ export declare class SafeDate {
|
|
|
56
61
|
isBetween(startingDate: Date | string, endingDate: Date | string, unit?: DateTimeUnits): boolean;
|
|
57
62
|
getDiff(date: Date | string, unit: DateTimeUnits): number;
|
|
58
63
|
clone(): SafeDate;
|
|
64
|
+
format(format: string): string;
|
|
65
|
+
setLocale(locale: string): this;
|
|
59
66
|
constructor(pValue?: Date | string | Dayjs);
|
|
60
67
|
}
|
|
61
68
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getSafeLangCode: (langCode: string) => string;
|
|
@@ -23,25 +23,116 @@ import "dayjs/locale/pt-br";
|
|
|
23
23
|
import { parseCookies, setCookie, destroyCookie } from "nookies";
|
|
24
24
|
import axios from "axios";
|
|
25
25
|
import { object } from "yup";
|
|
26
|
+
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
|
27
|
+
var es = { exports: {} };
|
|
28
|
+
(function(module, exports) {
|
|
29
|
+
!function(e, o) {
|
|
30
|
+
module.exports = o(dayjs);
|
|
31
|
+
}(commonjsGlobal, function(e) {
|
|
32
|
+
function o(e2) {
|
|
33
|
+
return e2 && typeof e2 == "object" && "default" in e2 ? e2 : { default: e2 };
|
|
34
|
+
}
|
|
35
|
+
var s = o(e), d = { name: "es", monthsShort: "ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"), weekdays: "domingo_lunes_martes_mi\xE9rcoles_jueves_viernes_s\xE1bado".split("_"), weekdaysShort: "dom._lun._mar._mi\xE9._jue._vie._s\xE1b.".split("_"), weekdaysMin: "do_lu_ma_mi_ju_vi_s\xE1".split("_"), months: "enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"), weekStart: 1, formats: { LT: "H:mm", LTS: "H:mm:ss", L: "DD/MM/YYYY", LL: "D [de] MMMM [de] YYYY", LLL: "D [de] MMMM [de] YYYY H:mm", LLLL: "dddd, D [de] MMMM [de] YYYY H:mm" }, relativeTime: { future: "en %s", past: "hace %s", s: "unos segundos", m: "un minuto", mm: "%d minutos", h: "una hora", hh: "%d horas", d: "un d\xEDa", dd: "%d d\xEDas", M: "un mes", MM: "%d meses", y: "un a\xF1o", yy: "%d a\xF1os" }, ordinal: function(e2) {
|
|
36
|
+
return e2 + "\xBA";
|
|
37
|
+
} };
|
|
38
|
+
return s.default.locale(d, null, true), d;
|
|
39
|
+
});
|
|
40
|
+
})(es);
|
|
41
|
+
var en = { exports: {} };
|
|
42
|
+
(function(module, exports) {
|
|
43
|
+
!function(e, n) {
|
|
44
|
+
module.exports = n();
|
|
45
|
+
}(commonjsGlobal, function() {
|
|
46
|
+
return { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_") };
|
|
47
|
+
});
|
|
48
|
+
})(en);
|
|
49
|
+
var localizedFormat$1 = { exports: {} };
|
|
50
|
+
(function(module, exports) {
|
|
51
|
+
!function(e, t) {
|
|
52
|
+
module.exports = t();
|
|
53
|
+
}(commonjsGlobal, function() {
|
|
54
|
+
var e = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" };
|
|
55
|
+
return function(t, o, n) {
|
|
56
|
+
var r = o.prototype, i = r.format;
|
|
57
|
+
n.en.formats = e, r.format = function(t2) {
|
|
58
|
+
t2 === void 0 && (t2 = "YYYY-MM-DDTHH:mm:ssZ");
|
|
59
|
+
var o2 = this.$locale().formats, n2 = function(t3, o3) {
|
|
60
|
+
return t3.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, function(t4, n3, r2) {
|
|
61
|
+
var i2 = r2 && r2.toUpperCase();
|
|
62
|
+
return n3 || o3[r2] || e[r2] || o3[i2].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, function(e2, t5, o4) {
|
|
63
|
+
return t5 || o4.slice(1);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}(t2, o2 === void 0 ? {} : o2);
|
|
67
|
+
return i.call(this, n2);
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
})(localizedFormat$1);
|
|
72
|
+
var localizedFormat = localizedFormat$1.exports;
|
|
73
|
+
const localizedFormatString = {
|
|
74
|
+
en: {
|
|
75
|
+
shortDayAndMonth: "MMM DD",
|
|
76
|
+
longDayAndMonth: "MMMM DD"
|
|
77
|
+
},
|
|
78
|
+
es: {
|
|
79
|
+
shortDayAndMonth: "DD MMM",
|
|
80
|
+
longDayAndMonth: "DD [de] MMMM"
|
|
81
|
+
},
|
|
82
|
+
"pt-br": {
|
|
83
|
+
shortDayAndMonth: "DD MMM",
|
|
84
|
+
longDayAndMonth: "DD [de] MMMM"
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const safeLangCodes = {
|
|
88
|
+
pt: "pt-br",
|
|
89
|
+
pt_br: "pt-br",
|
|
90
|
+
"pt-br": "pt-br",
|
|
91
|
+
en: "en",
|
|
92
|
+
en_us: "en",
|
|
93
|
+
"en-us": "en",
|
|
94
|
+
en_gb: "en",
|
|
95
|
+
"en-gb": "en",
|
|
96
|
+
es: "es",
|
|
97
|
+
es_es: "es",
|
|
98
|
+
"es-es": "es"
|
|
99
|
+
};
|
|
100
|
+
const getSafeLangCode = (langCode) => {
|
|
101
|
+
const code = safeLangCodes[langCode.toLowerCase()];
|
|
102
|
+
return code || safeLangCodes.pt;
|
|
103
|
+
};
|
|
104
|
+
dayjs.extend(localizedFormat);
|
|
26
105
|
class SafeDate {
|
|
27
106
|
constructor(pValue) {
|
|
28
107
|
__publicField(this, "value", dayjs());
|
|
29
108
|
__publicField(this, "isDateValid", true);
|
|
109
|
+
__publicField(this, "locale", "pt-br");
|
|
110
|
+
this.locale = "pt-br";
|
|
30
111
|
this.value = dayjs(pValue).locale("pt-br");
|
|
31
112
|
this.isDateValid = this.value.isValid();
|
|
32
113
|
if (!this.isDateValid) {
|
|
33
114
|
console.error("Invalid date:", pValue);
|
|
34
115
|
}
|
|
35
116
|
}
|
|
36
|
-
static isValid(value) {
|
|
37
|
-
return dayjs(value || "").isValid();
|
|
38
|
-
}
|
|
39
117
|
returnHandler(value, onInvalid) {
|
|
40
118
|
return this.isDateValid ? value : onInvalid;
|
|
41
119
|
}
|
|
120
|
+
i18nFormat(key, fallback) {
|
|
121
|
+
var _a;
|
|
122
|
+
return ((_a = localizedFormatString[this.locale]) == null ? void 0 : _a[key]) || fallback;
|
|
123
|
+
}
|
|
124
|
+
getI18nCode(locale) {
|
|
125
|
+
return getSafeLangCode(locale);
|
|
126
|
+
}
|
|
127
|
+
static isValid(value) {
|
|
128
|
+
return dayjs(value || "").isValid();
|
|
129
|
+
}
|
|
42
130
|
get isValid() {
|
|
43
131
|
return this.isDateValid;
|
|
44
132
|
}
|
|
133
|
+
get lang() {
|
|
134
|
+
return this.locale;
|
|
135
|
+
}
|
|
45
136
|
get jsDate() {
|
|
46
137
|
return this.value.toDate();
|
|
47
138
|
}
|
|
@@ -55,16 +146,19 @@ class SafeDate {
|
|
|
55
146
|
return this.returnHandler(this.value.format("YYYY-MM-DDTHH:mm:ss"), "");
|
|
56
147
|
}
|
|
57
148
|
get dateString() {
|
|
58
|
-
return this.returnHandler(this.value.format("
|
|
149
|
+
return this.returnHandler(this.value.format("L"), "");
|
|
59
150
|
}
|
|
60
151
|
get longDayMonth() {
|
|
61
|
-
return this.returnHandler(this.value.format("DD [de] MMMM"), "");
|
|
152
|
+
return this.returnHandler(this.value.format(this.i18nFormat("longDayAndMonth", "DD [de] MMMM")), "");
|
|
153
|
+
}
|
|
154
|
+
get shortDayMonth() {
|
|
155
|
+
return this.returnHandler(this.value.format(this.i18nFormat("shortDayAndMonth", "DD MMM")), "");
|
|
62
156
|
}
|
|
63
157
|
get longDateString() {
|
|
64
|
-
return this.returnHandler(this.value.format("
|
|
158
|
+
return this.returnHandler(this.value.format("LL"), "");
|
|
65
159
|
}
|
|
66
160
|
get timeString() {
|
|
67
|
-
return this.returnHandler(this.value.format("
|
|
161
|
+
return this.returnHandler(this.value.format("LT"), "");
|
|
68
162
|
}
|
|
69
163
|
get daysInMonth() {
|
|
70
164
|
return this.returnHandler(this.value.daysInMonth(), 0);
|
|
@@ -173,6 +267,15 @@ class SafeDate {
|
|
|
173
267
|
clone() {
|
|
174
268
|
return new SafeDate(this.value);
|
|
175
269
|
}
|
|
270
|
+
format(format) {
|
|
271
|
+
return this.returnHandler(this.value.format(format), "");
|
|
272
|
+
}
|
|
273
|
+
setLocale(locale) {
|
|
274
|
+
const safeLocale = this.getI18nCode(locale);
|
|
275
|
+
this.value = this.value.locale(safeLocale);
|
|
276
|
+
this.locale = safeLocale;
|
|
277
|
+
return this;
|
|
278
|
+
}
|
|
176
279
|
}
|
|
177
280
|
const get = (_domain, prefix) => (key) => {
|
|
178
281
|
const cookies = parseCookies();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(o,d){typeof exports=="object"&&typeof module!="undefined"?d(exports,require("dayjs"),require("dayjs/locale/pt-br"),require("nookies"),require("axios"),require("yup")):typeof define=="function"&&define.amd?define(["exports","dayjs","dayjs/locale/pt-br","nookies","axios","yup"],d):(o=typeof globalThis!="undefined"?globalThis:o||self,d(o.BinamikJSProviders={},o.dayjs,null,o.nookies,o.axios,o.yup))})(this,function(o,d,r,g,E,V){"use strict";var tt=Object.defineProperty;var j=Object.getOwnPropertySymbols;var et=Object.prototype.hasOwnProperty,at=Object.prototype.propertyIsEnumerable;var L=(o,d,r)=>d in o?tt(o,d,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[d]=r,A=(o,d)=>{for(var r in d||(d={}))et.call(d,r)&&L(o,r,d[r]);if(j)for(var r of j(d))at.call(d,r)&&L(o,r,d[r]);return o};var D=(o,d,r)=>(L(o,typeof d!="symbol"?d+"":d,r),r);function S(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var v=S(d),I=S(E),Y=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},N={exports:{}};(function(e,t){(function(a,n){e.exports=n(v.default)})(Y,function(a){function n(s){return s&&typeof s=="object"&&"default"in s?s:{default:s}}var i=n(a),l={name:"es",monthsShort:"ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic".split("_"),weekdays:"domingo_lunes_martes_mi\xE9rcoles_jueves_viernes_s\xE1bado".split("_"),weekdaysShort:"dom._lun._mar._mi\xE9._jue._vie._s\xE1b.".split("_"),weekdaysMin:"do_lu_ma_mi_ju_vi_s\xE1".split("_"),months:"enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre".split("_"),weekStart:1,formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY H:mm",LLLL:"dddd, D [de] MMMM [de] YYYY H:mm"},relativeTime:{future:"en %s",past:"hace %s",s:"unos segundos",m:"un minuto",mm:"%d minutos",h:"una hora",hh:"%d horas",d:"un d\xEDa",dd:"%d d\xEDas",M:"un mes",MM:"%d meses",y:"un a\xF1o",yy:"%d a\xF1os"},ordinal:function(s){return s+"\xBA"}};return i.default.locale(l,null,!0),l})})(N);var k={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Y,function(){return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_")}})})(k);var H={exports:{}};(function(e,t){(function(a,n){e.exports=n()})(Y,function(){var a={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(n,i,l){var s=i.prototype,h=s.format;l.en.formats=a,s.format=function(f){f===void 0&&(f="YYYY-MM-DDTHH:mm:ssZ");var u=this.$locale().formats,c=function(m,w){return m.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(nt,W,_){var X=_&&_.toUpperCase();return W||w[_]||a[_]||w[X].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(st,Z,Q){return Z||Q.slice(1)})})}(f,u===void 0?{}:u);return h.call(this,c)}}})})(H);var C=H.exports;const P={en:{shortDayAndMonth:"MMM DD",longDayAndMonth:"MMMM DD"},es:{shortDayAndMonth:"DD MMM",longDayAndMonth:"DD [de] MMMM"},"pt-br":{shortDayAndMonth:"DD MMM",longDayAndMonth:"DD [de] MMMM"}},T={pt:"pt-br",pt_br:"pt-br","pt-br":"pt-br",en:"en",en_us:"en","en-us":"en",en_gb:"en","en-gb":"en",es:"es",es_es:"es","es-es":"es"},O=e=>T[e.toLowerCase()]||T.pt;v.default.extend(C);class b{constructor(t){D(this,"value",v.default());D(this,"isDateValid",!0);D(this,"locale","pt-br");this.locale="pt-br",this.value=v.default(t).locale("pt-br"),this.isDateValid=this.value.isValid(),this.isDateValid||console.error("Invalid date:",t)}returnHandler(t,a){return this.isDateValid?t:a}i18nFormat(t,a){var n;return((n=P[this.locale])==null?void 0:n[t])||a}getI18nCode(t){return O(t)}static isValid(t){return v.default(t||"").isValid()}get isValid(){return this.isDateValid}get lang(){return this.locale}get jsDate(){return this.value.toDate()}get timestamp(){return this.returnHandler(this.jsDate.getTime(),NaN)}get isoDate(){return this.returnHandler(this.value.format("YYYY-MM-DD"),"")}get isoString(){return this.returnHandler(this.value.format("YYYY-MM-DDTHH:mm:ss"),"")}get dateString(){return this.returnHandler(this.value.format("L"),"")}get longDayMonth(){return this.returnHandler(this.value.format(this.i18nFormat("longDayAndMonth","DD [de] MMMM")),"")}get shortDayMonth(){return this.returnHandler(this.value.format(this.i18nFormat("shortDayAndMonth","DD MMM")),"")}get longDateString(){return this.returnHandler(this.value.format("LL"),"")}get timeString(){return this.returnHandler(this.value.format("LT"),"")}get daysInMonth(){return this.returnHandler(this.value.daysInMonth(),0)}get dateObj(){return this.returnHandler({year:this.value.year(),month:this.value.month(),date:this.value.date(),weekday:this.value.day(),hours:this.value.hour(),minutes:this.value.minute(),seconds:this.value.second(),milliseconds:this.value.millisecond()},{year:0,month:0,date:0,weekday:0,hours:0,minutes:0,seconds:0,milliseconds:0})}setToStartOf(t){return this.value=this.value.startOf(t),this}addDays(t){return this.value=this.isDateValid?this.value.add(t,"day"):this.value,this}addMonths(t){return this.value=this.isDateValid?this.value.add(t,"month"):this.value,this}addYears(t){return this.value=this.isDateValid?this.value.add(t,"year"):this.value,this}addHours(t){return this.value=this.isDateValid?this.value.add(t,"hour"):this.value,this}addToDate({years:t=0,months:a=0,weeks:n=0,days:i=0,hours:l=0,minutes:s=0,seconds:h=0}){return this.value=this.isDateValid?this.value.add(t,"year").add(a,"month").add(n,"week").add(i,"day").add(l,"hour").add(s,"minute").add(h,"second"):this.value,this}setTo(t){const a=this.isDateValid?{year:this.value.year(),month:this.value.month(),day:this.value.date(),hour:this.value.hour(),minute:this.value.minute(),second:this.value.second(),milisecond:this.value.millisecond()}:{year:0,month:0,day:0,hour:0,minute:0,second:0,milisecond:0},{year:n=a.year,month:i=a.month,day:l=a.day,hour:s=a.hour,minute:h=a.minute,second:f=a.second,milisecond:u=a.milisecond}=t;return this.value=this.isDateValid?this.value.year(n).month(i).date(l).hour(s).minute(h).second(f).millisecond(u):this.value,this}isBefore(t,a){return this.returnHandler(this.value.isBefore(t,a),!1)}isAfter(t,a){return this.returnHandler(this.value.isAfter(t,a),!1)}isSame(t,a){return this.returnHandler(this.value.isSame(t,a),!1)}isBetween(t,a,n){const i=this.returnHandler(this.value.isAfter(t,n),!1),l=this.returnHandler(this.value.isBefore(a,n),!1),s=i&&l||!i&&!l;return this.returnHandler(s,!1)}getDiff(t,a){return this.returnHandler(this.value.diff(t,a),0)}clone(){return new b(this.value)}format(t){return this.returnHandler(this.value.format(t),"")}setLocale(t){const a=this.getI18nCode(t);return this.value=this.value.locale(a),this.locale=a,this}}const x=(e,t)=>a=>g.parseCookies()[`${t}-${a}`],$=(e,t)=>(a,n,i)=>{g.setCookie(null,`${t}-${a}`,n,{maxAge:(i==null?void 0:i.maxAge)||60*60*24*90,path:"/",domain:e,secure:!0,httpOnly:!0})},M=(e,t)=>(a,n)=>{g.destroyCookie(null,`${t}-${a}`,n)},q=(e,t)=>a=>{M(e,t)("auth-key",a),M(e,t)("user",a),M(e,t)("company",a),M(e,t)("orb-selected",a)},B=({cookieDomain:e,cookiePrefix:t})=>({get:x(e,t),set:$(e,t),remove:M(e,t),cleanAuth:q(e,t)}),F=typeof window=="undefined",R=e=>/(^(\d{1,3}\.){3}(\d{1,3})(:\d{1,5})?$)/.test(e),z=e=>({}.NEXT_PUBLIC_APP_ENV||{}.REACT_APP_ENVIRONMENT||{}.REACT_APP_ENV||"production")==="local"&&(e.includes("localhost")||R(e)),J=e=>{var a;const t={};return(a=e==null?void 0:e.inner)!=null&&a.length?e.inner.forEach(n=>{t[(n==null?void 0:n.path)||"unknown"]=n.message}):(e==null?void 0:e.path)&&(e==null?void 0:e.message)?t[e.path]=e.message:!(e!=null&&e.path)&&(e==null?void 0:e.type)==="typeError"&&(t.body=e.errors[0]),t},U=async({name:e="",url:t="",req:a={},res:n={},schema:i=V.object()})=>{var l;F||!z((l=window==null?void 0:window.location)==null?void 0:l.hostname)||i.validate(n,{abortEarly:!1}).catch(s=>{const h=J(s);console.warn(`PLEASE check the backend IO for >> ${e} <<, some discrepancies were found in the expected response`,{functionName:e,endPoint:t,request:a,response:n,validationErrors:h})})},G=e=>t=>{if(e&&(t==null?void 0:t.status)){const a=t.status,n=e[a];n&&n(t)}},p=e=>t=>{var a,n;return e&&e.name&&e.schema&&U({name:e.name,schema:e.schema,req:{body:((a=t==null?void 0:t.config)==null?void 0:a.data)||null,query:(n=t==null?void 0:t.config)==null?void 0:n.params},res:t==null?void 0:t.data,url:t==null?void 0:t.request.url}),[t.data,null,{status:t.status}]},y=e=>t=>{var i,l,s;const a=(i=t==null?void 0:t.response)==null?void 0:i.data,n=e?e(a||null):void 0;return[null,{status:((l=t==null?void 0:t.response)==null?void 0:l.status)||599,message:(a==null?void 0:a.message)||(a==null?void 0:a.msg)||"Unknown IO Error",errorData:a||null,errors:n},{status:((s=t==null?void 0:t.response)==null?void 0:s.status)||599}]},K=(e,t)=>{const{withAuth:a=!1,authKey:n="",ioIntegrityCheck:i,onStatusCode:l,errorParser:s}=t||{},h=I.default.create({baseURL:e,headers:a?{"Content-Type":"application/json",Authorization:n||"no_auth_key"}:{"Content-Type":"application/json"}}),f=G(l);return h.interceptors.response.use(u=>(f(u),u),u=>{throw u!=null&&u.response&&f(u.response),u}),{get:(u,c,m={})=>h.get(u,A({params:c},m)).then(p(i)).catch(y(s)),post:(u,c,m)=>h.post(u,c,m).then(p(i)).catch(y(s)),patch:(u,c,m)=>h.patch(u,c,m).then(p(i)).catch(y(s)),delete:(u,c,m={})=>h.delete(u,A({params:c},m)).then(p(i)).catch(y(s))}};o.AppStorageProvider=B,o.SafeDate=b,o.createIoInstance=K,Object.defineProperties(o,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|