@m4l/core 0.1.36 → 0.1.38
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/contexts/DomainContext/{index.5da377f5.js → index.d34b500f.js} +1 -1
- package/contexts/DomainCountryContext/{index.ceb6320d.js → index.5f46a11a.js} +5 -5
- package/contexts/ModuleDictionaryContext/{index.527e0ae1.js → index.8ba9981b.js} +5 -5
- package/contexts/ModulePrivilegesContext/{index.bcfce88d.js → index.d1286210.js} +5 -5
- package/contexts/ModuleSkeletonContext/{index.4a9100d2.js → index.f3fbaa68.js} +4 -4
- package/hooks/useDomain/{index.77c85724.js → index.af32231a.js} +2 -2
- package/hooks/useModuleDictionary/{index.98161356.js → index.a3bb2d5e.js} +1 -1
- package/hooks/useModulePrivileges/{index.8afb47f4.js → index.5a1a1a1e.js} +1 -1
- package/hooks/useModuleSkeleton/{index.aa9264ca.js → index.8e948037.js} +1 -1
- package/hooks/usePropageteMF/index.d.ts +2 -1
- package/hooks/usePropageteMF/types.d.ts +4 -4
- package/index.d.ts +2 -2
- package/index.js +11 -11
- package/package.json +2 -2
- package/types/{index.d9c95d2a.js → index.42c24946.js} +1 -1
- package/types/index.d.ts +33 -13
- package/utils/axiosOperation.5a823aca.js +62 -0
- package/utils/axiosOperation.cc325182.js +0 -56
|
@@ -2,7 +2,7 @@ import { createContext as f, useState as s, useEffect as p } from "react";
|
|
|
2
2
|
import { u as g } from "../../hooks/useFlags/index.a986729d.js";
|
|
3
3
|
import { u as D } from "../../hooks/useEnvironment/index.04dca988.js";
|
|
4
4
|
import { u as v } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
5
|
-
import { C as y } from "../../types/index.
|
|
5
|
+
import { C as y } from "../../types/index.42c24946.js";
|
|
6
6
|
import { jsx as h } from "react/jsx-runtime";
|
|
7
7
|
const $ = f(null);
|
|
8
8
|
function A(e) {
|
|
@@ -3,13 +3,13 @@ import "../BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import "../EnvironmentContext/index.7045c64f.js";
|
|
4
4
|
import "../FlagsContext/index.5f795859.js";
|
|
5
5
|
import { u as T } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
6
|
-
import "../DomainContext/index.
|
|
7
|
-
import "../ModuleDictionaryContext/index.
|
|
8
|
-
import "../ModulePrivilegesContext/index.
|
|
9
|
-
import "../ModuleSkeletonContext/index.
|
|
6
|
+
import "../DomainContext/index.d34b500f.js";
|
|
7
|
+
import "../ModuleDictionaryContext/index.8ba9981b.js";
|
|
8
|
+
import "../ModulePrivilegesContext/index.d1286210.js";
|
|
9
|
+
import "../ModuleSkeletonContext/index.f3fbaa68.js";
|
|
10
10
|
import "../NetworkContext/index.d1dfbc3a.js";
|
|
11
11
|
import { u as f } from "../../hooks/usePropageteMF/index.c440b829.js";
|
|
12
|
-
import { E as i } from "../../types/index.
|
|
12
|
+
import { E as i } from "../../types/index.42c24946.js";
|
|
13
13
|
import { jsx as D } from "react/jsx-runtime";
|
|
14
14
|
const M = E(null);
|
|
15
15
|
function G(n) {
|
|
@@ -3,12 +3,12 @@ import "../BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import { u as M } from "../../hooks/useEnvironment/index.04dca988.js";
|
|
4
4
|
import { u as N } from "../../hooks/useFlags/index.a986729d.js";
|
|
5
5
|
import { u as P } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
6
|
-
import "../DomainContext/index.
|
|
7
|
-
import "../ModulePrivilegesContext/index.
|
|
8
|
-
import "../ModuleSkeletonContext/index.
|
|
6
|
+
import "../DomainContext/index.d34b500f.js";
|
|
7
|
+
import "../ModulePrivilegesContext/index.d1286210.js";
|
|
8
|
+
import "../ModuleSkeletonContext/index.f3fbaa68.js";
|
|
9
9
|
import { u as _ } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
10
|
-
import "../DomainCountryContext/index.
|
|
11
|
-
import { C as x } from "../../types/index.
|
|
10
|
+
import "../DomainCountryContext/index.5f46a11a.js";
|
|
11
|
+
import { C as x } from "../../types/index.42c24946.js";
|
|
12
12
|
import { jsx as A } from "react/jsx-runtime";
|
|
13
13
|
const E = y(null);
|
|
14
14
|
function Y(u) {
|
|
@@ -3,12 +3,12 @@ import "../BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import "../EnvironmentContext/index.7045c64f.js";
|
|
4
4
|
import { u as v } from "../../hooks/useFlags/index.a986729d.js";
|
|
5
5
|
import { u as E } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
6
|
-
import "../DomainContext/index.
|
|
7
|
-
import "../ModuleDictionaryContext/index.
|
|
8
|
-
import "../ModuleSkeletonContext/index.
|
|
6
|
+
import "../DomainContext/index.d34b500f.js";
|
|
7
|
+
import "../ModuleDictionaryContext/index.8ba9981b.js";
|
|
8
|
+
import "../ModuleSkeletonContext/index.f3fbaa68.js";
|
|
9
9
|
import { u as h } from "../../hooks/useNetwork/index.acbf28d5.js";
|
|
10
|
-
import "../DomainCountryContext/index.
|
|
11
|
-
import { C as i } from "../../types/index.
|
|
10
|
+
import "../DomainCountryContext/index.5f46a11a.js";
|
|
11
|
+
import { C as i } from "../../types/index.42c24946.js";
|
|
12
12
|
import { jsx as L } from "react/jsx-runtime";
|
|
13
13
|
const C = f(null);
|
|
14
14
|
function y(n) {
|
|
@@ -3,11 +3,11 @@ import "../BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import "../EnvironmentContext/index.7045c64f.js";
|
|
4
4
|
import { a as m } from "../../hooks/useFlags/index.a986729d.js";
|
|
5
5
|
import "../HostToolsContext/index.499db832.js";
|
|
6
|
-
import "../DomainContext/index.
|
|
7
|
-
import "../ModuleDictionaryContext/index.
|
|
8
|
-
import "../ModulePrivilegesContext/index.
|
|
6
|
+
import "../DomainContext/index.d34b500f.js";
|
|
7
|
+
import "../ModuleDictionaryContext/index.8ba9981b.js";
|
|
8
|
+
import "../ModulePrivilegesContext/index.d1286210.js";
|
|
9
9
|
import "../NetworkContext/index.d1dfbc3a.js";
|
|
10
|
-
import "../DomainCountryContext/index.
|
|
10
|
+
import "../DomainCountryContext/index.5f46a11a.js";
|
|
11
11
|
import { jsx as n } from "react/jsx-runtime";
|
|
12
12
|
const p = i(null);
|
|
13
13
|
function P(o) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useContext as t } from "react";
|
|
2
|
-
import { D as n } from "../../contexts/DomainContext/index.
|
|
3
|
-
import { D as e } from "../../contexts/DomainCountryContext/index.
|
|
2
|
+
import { D as n } from "../../contexts/DomainContext/index.d34b500f.js";
|
|
3
|
+
import { D as e } from "../../contexts/DomainCountryContext/index.5f46a11a.js";
|
|
4
4
|
const m = () => {
|
|
5
5
|
const o = t(n);
|
|
6
6
|
if (!o)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useState as n, useContext as s, useEffect as u } from "react";
|
|
2
|
-
import { M as r } from "../../contexts/ModuleSkeletonContext/index.
|
|
2
|
+
import { M as r } from "../../contexts/ModuleSkeletonContext/index.f3fbaa68.js";
|
|
3
3
|
const S = () => {
|
|
4
4
|
const [t, o] = n(!0), e = s(r);
|
|
5
5
|
if (!e)
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
+
import { EmmitListenerGuard } from '../../types';
|
|
1
2
|
import { usePropagateProps } from './types';
|
|
2
|
-
export declare function usePropageteMF<
|
|
3
|
+
export declare function usePropageteMF<E extends keyof EmmitListenerGuard>(props: usePropagateProps<E>): void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface usePropagateProps<
|
|
1
|
+
import { EmmitListenerGuard } from '../../types';
|
|
2
|
+
export interface usePropagateProps<E extends keyof EmmitListenerGuard> {
|
|
3
3
|
isMicroFrontEnd: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
event: E;
|
|
5
|
+
setHandler: EmmitListenerGuard[E];
|
|
6
6
|
}
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './contexts';
|
|
2
2
|
export * from './hooks';
|
|
3
|
-
export { EmitEvents, CommonFlags } from './types';
|
|
4
|
-
export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation,
|
|
3
|
+
export { EmmitEvents as EmitEvents, CommonFlags } from './types';
|
|
4
|
+
export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventListenerBase, EmmitEventsGuard, } from './types';
|
|
5
5
|
export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
|
|
6
6
|
export * from './utils';
|
package/index.js
CHANGED
|
@@ -3,27 +3,27 @@ import { B as i, a as n } from "./contexts/BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import { E as u, a as x } from "./contexts/EnvironmentContext/index.7045c64f.js";
|
|
4
4
|
import { F as l, a as f } from "./contexts/FlagsContext/index.5f795859.js";
|
|
5
5
|
import { H as g, a as v } from "./contexts/HostToolsContext/index.499db832.js";
|
|
6
|
-
import { D as C, a as M } from "./contexts/DomainContext/index.
|
|
7
|
-
import { M as S, a as c } from "./contexts/ModuleDictionaryContext/index.
|
|
8
|
-
import { M as F, a as E } from "./contexts/ModulePrivilegesContext/index.
|
|
9
|
-
import { M as B, a as L } from "./contexts/ModuleSkeletonContext/index.
|
|
6
|
+
import { D as C, a as M } from "./contexts/DomainContext/index.d34b500f.js";
|
|
7
|
+
import { M as S, a as c } from "./contexts/ModuleDictionaryContext/index.8ba9981b.js";
|
|
8
|
+
import { M as F, a as E } from "./contexts/ModulePrivilegesContext/index.d1286210.js";
|
|
9
|
+
import { M as B, a as L } from "./contexts/ModuleSkeletonContext/index.f3fbaa68.js";
|
|
10
10
|
import { N, a as w } from "./contexts/NetworkContext/index.d1dfbc3a.js";
|
|
11
|
-
import { D as h, a as O } from "./contexts/DomainCountryContext/index.
|
|
11
|
+
import { D as h, a as O } from "./contexts/DomainCountryContext/index.5f46a11a.js";
|
|
12
12
|
import { u as b } from "./hooks/useBase/index.4375dcef.js";
|
|
13
13
|
import { u as q } from "./hooks/useEnvironment/index.04dca988.js";
|
|
14
14
|
import { u as A, a as G } from "./hooks/useFlags/index.a986729d.js";
|
|
15
15
|
import { u as J } from "./hooks/useHostTools/index.66d9a667.js";
|
|
16
|
-
import { u as Q, a as R } from "./hooks/useDomain/index.
|
|
16
|
+
import { u as Q, a as R } from "./hooks/useDomain/index.af32231a.js";
|
|
17
17
|
import { u as V, a as X } from "./hooks/useLocalStorage/index.48b47dca.js";
|
|
18
|
-
import { u as Z } from "./hooks/useModuleDictionary/index.
|
|
19
|
-
import { u as $ } from "./hooks/useModulePrivileges/index.
|
|
20
|
-
import { u as eo } from "./hooks/useModuleSkeleton/index.
|
|
18
|
+
import { u as Z } from "./hooks/useModuleDictionary/index.a3bb2d5e.js";
|
|
19
|
+
import { u as $ } from "./hooks/useModulePrivileges/index.5a1a1a1e.js";
|
|
20
|
+
import { u as eo } from "./hooks/useModuleSkeleton/index.8e948037.js";
|
|
21
21
|
import { u as ao } from "./hooks/useNetwork/index.acbf28d5.js";
|
|
22
22
|
import { i as so, u as io } from "./hooks/usePaginate/index.7cb17527.js";
|
|
23
23
|
import { u as mo } from "./hooks/usePropageteMF/index.c440b829.js";
|
|
24
|
-
import { C as xo, E as po } from "./types/index.
|
|
24
|
+
import { C as xo, E as po } from "./types/index.42c24946.js";
|
|
25
25
|
import { a as fo, g as go, s as vo, v as Po } from "./utils/index.8c4b528d.js";
|
|
26
|
-
import { a as Mo } from "./utils/axiosOperation.
|
|
26
|
+
import { a as Mo } from "./utils/axiosOperation.5a823aca.js";
|
|
27
27
|
import "react/jsx-runtime";
|
|
28
28
|
import "axios";
|
|
29
29
|
import "qs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.38",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team",
|
|
6
6
|
"peerDependencies": {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"*"
|
|
18
18
|
],
|
|
19
|
-
"source": "
|
|
19
|
+
"source": "./index.js",
|
|
20
20
|
"main": "./index.js",
|
|
21
21
|
"module": "./index.js",
|
|
22
22
|
"type": "module",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var E = /* @__PURE__ */ ((_) => (_.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized", _.EMMIT_EVENT_HOST_LOCALE_CHANGE = "host_locale_change", _.EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change", _.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE = "domain_country_change", _.EMMIT_EVENT_HOST_FORMATTER_CHANGE = "formatter_change", _))(E || {}), T = /* @__PURE__ */ ((_) => (_.FLAG_PRIVILEGES_LOADED = "privileges_loaded", _.FLAG_DICTIONARY_LOADED = "dictionary_loaded", _.FLAG_DOMAIN_LOADED = "domain_loaded", _))(T || {});
|
|
1
|
+
var E = /* @__PURE__ */ ((_) => (_.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized", _.EMMIT_EVENT_HOST_LOCALE_CHANGE = "host_locale_change", _.EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change", _.EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE = "domain_country_change", _.EMMIT_EVENT_HOST_FORMATTER_CHANGE = "formatter_change", _.EMMIT_EVENT_HOST_EMERGE_WINDOW = "host_emerge_window", _))(E || {}), T = /* @__PURE__ */ ((_) => (_.FLAG_PRIVILEGES_LOADED = "privileges_loaded", _.FLAG_DICTIONARY_LOADED = "dictionary_loaded", _.FLAG_DOMAIN_LOADED = "domain_loaded", _.FLAG_FORM_LOADED = "form_loaded", _))(T || {});
|
|
2
2
|
export {
|
|
3
3
|
T as C,
|
|
4
4
|
E
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Id, ToastContent, ToastOptions } from 'react-toastify';
|
|
2
2
|
import type { BrowserHistory } from 'history';
|
|
3
3
|
import { ResponseType } from 'axios';
|
|
4
|
+
import { DomainCountry } from '../contexts';
|
|
4
5
|
export declare type Maybe<T> = T | undefined | null;
|
|
5
6
|
export declare interface EnvironmentType {
|
|
6
7
|
isLocalhost: boolean;
|
|
@@ -20,33 +21,52 @@ export declare type NetworkProps = {
|
|
|
20
21
|
headers?: Record<string, string | number | boolean>;
|
|
21
22
|
checkUnAuthorized?: boolean;
|
|
22
23
|
isRemote?: boolean;
|
|
23
|
-
|
|
24
|
+
toastSuccess?: boolean;
|
|
25
|
+
toastError?: boolean;
|
|
24
26
|
onDownloadProgress?: (progressEvent: any) => void;
|
|
25
27
|
isExternalUrl?: boolean;
|
|
26
28
|
responseType?: ResponseType;
|
|
27
29
|
signal?: AbortSignal;
|
|
28
30
|
};
|
|
29
31
|
export declare type ToastFunction = (content: ToastContent, options?: ToastOptions) => Id;
|
|
30
|
-
export declare
|
|
32
|
+
export declare enum EmmitEvents {
|
|
33
|
+
EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized",
|
|
34
|
+
EMMIT_EVENT_HOST_LOCALE_CHANGE = "host_locale_change",
|
|
35
|
+
EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change",
|
|
36
|
+
EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE = "domain_country_change",
|
|
37
|
+
EMMIT_EVENT_HOST_FORMATTER_CHANGE = "formatter_change",
|
|
38
|
+
EMMIT_EVENT_HOST_EMERGE_WINDOW = "host_emerge_window"
|
|
39
|
+
}
|
|
40
|
+
export declare type EmptyObject = Record<string, any>;
|
|
41
|
+
export declare type EmmitBaseGuard = {
|
|
42
|
+
[K in EmmitEvents]: any;
|
|
43
|
+
};
|
|
44
|
+
export interface EmmitEventsGuard extends EmmitBaseGuard {
|
|
45
|
+
domain_country_change: DomainCountry;
|
|
46
|
+
netsevice_unauthorized: EmptyObject;
|
|
47
|
+
}
|
|
48
|
+
export declare type EmmitFunction = <E extends keyof EmmitEventsGuard>(event: E, arg1: EmmitEventsGuard[E]) => void;
|
|
49
|
+
export declare type EventListenerBase = (...args: any[]) => void;
|
|
50
|
+
export declare type EmmitListenerBaseGuard = {
|
|
51
|
+
[K in EmmitEvents]: EventListenerBase;
|
|
52
|
+
};
|
|
53
|
+
export interface EmmitListenerGuard extends EmmitListenerBaseGuard {
|
|
54
|
+
domain_country_change: (newDomainCountry: DomainCountry) => void;
|
|
55
|
+
}
|
|
56
|
+
export declare type EmmitEventListener = <E extends keyof EmmitListenerGuard>(event: E, handler: EmmitListenerGuard[E]) => void;
|
|
31
57
|
export declare interface HostToolsType {
|
|
32
58
|
history: BrowserHistory;
|
|
33
59
|
toast: ToastFunction;
|
|
34
60
|
startProgress: VoidFunction;
|
|
35
61
|
stopProgress: VoidFunction;
|
|
36
|
-
events_add_listener:
|
|
37
|
-
events_remove_listener:
|
|
38
|
-
events_emit:
|
|
39
|
-
}
|
|
40
|
-
export declare enum EmitEvents {
|
|
41
|
-
EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized",
|
|
42
|
-
EMMIT_EVENT_HOST_LOCALE_CHANGE = "host_locale_change",
|
|
43
|
-
EMMIT_EVENT_HOST_THEME_CHANGE = "host_theme_change",
|
|
44
|
-
EMMIT_EVENT_HOST_DOMAIN_COUNTRY_CHANGE = "domain_country_change",
|
|
45
|
-
EMMIT_EVENT_HOST_FORMATTER_CHANGE = "formatter_change"
|
|
62
|
+
events_add_listener: EmmitEventListener;
|
|
63
|
+
events_remove_listener: EmmitEventListener;
|
|
64
|
+
events_emit: EmmitFunction;
|
|
46
65
|
}
|
|
47
66
|
export declare enum CommonFlags {
|
|
48
67
|
FLAG_PRIVILEGES_LOADED = "privileges_loaded",
|
|
49
68
|
FLAG_DICTIONARY_LOADED = "dictionary_loaded",
|
|
50
|
-
FLAG_DOMAIN_LOADED = "domain_loaded"
|
|
69
|
+
FLAG_DOMAIN_LOADED = "domain_loaded",
|
|
70
|
+
FLAG_FORM_LOADED = "form_loaded"
|
|
51
71
|
}
|
|
52
72
|
export declare type AxiosOperation = (props: NetworkProps, enviroment: EnvironmentType, hostTools: HostToolsType) => Promise<any>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import y from "axios";
|
|
2
|
+
import R from "qs";
|
|
3
|
+
import { E as j } from "../types/index.42c24946.js";
|
|
4
|
+
function v(e, s, a, i, o) {
|
|
5
|
+
const { toast: t } = a;
|
|
6
|
+
return i === "json" ? s && s.data && typeof s.data == "object" ? s.data.error && s.data.error?.code && s.data.error?.msg !== void 0 ? Promise.reject({ ...s.data.error, status: s.status }) : (s.data.messagen && o && t(s.data.message, { type: "success", autoClose: 1e4 }), s.data) : Promise.reject({
|
|
7
|
+
code: 1,
|
|
8
|
+
msg: `Incorrect endpoint: ${e}`,
|
|
9
|
+
status: s.status
|
|
10
|
+
}) : s.data;
|
|
11
|
+
}
|
|
12
|
+
function P(e, s, a = !0, i = !0) {
|
|
13
|
+
const { toast: o } = s;
|
|
14
|
+
let t = {
|
|
15
|
+
message: "",
|
|
16
|
+
status: 1,
|
|
17
|
+
code: 0
|
|
18
|
+
};
|
|
19
|
+
return e?.code !== void 0 && t.status !== void 0 && e.message !== void 0 && (t = { ...t, ...e }), e?.response ? e.response.data && typeof e.response.data == "object" && e.response.data.error && e.response.data.error?.code && e.response.data.error?.message !== void 0 ? t = { ...e.response.data.error, status: e.response.status } : (t.message = e.message, t.status = e.response.status, t.code = 0) : e?.request ? (t.message = `${e?.code} ${e.message}`, t.code = -1) : (t.message = `${e?.code} ${e.message}`, t.status = 0, t.code = -2), a && e?.response?.status === 401 && s.events_emit(j.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (t.message = e?.response?.data?.error.message), a && (t.message.indexOf("ERR_CANCELED") > -1 || i && o(`${t.message} - status: ${t.status} - code: ${t.code}`, {
|
|
20
|
+
type: "error"
|
|
21
|
+
})), t;
|
|
22
|
+
}
|
|
23
|
+
const b = async (e, s, a) => {
|
|
24
|
+
const {
|
|
25
|
+
method: i,
|
|
26
|
+
endPoint: o,
|
|
27
|
+
timeout: t = 6e4,
|
|
28
|
+
parms: c = {},
|
|
29
|
+
data: g = {},
|
|
30
|
+
isRemote: n = !0,
|
|
31
|
+
checkUnAuthorized: f = !0,
|
|
32
|
+
headers: p,
|
|
33
|
+
onDownloadProgress: E,
|
|
34
|
+
isExternalUrl: u,
|
|
35
|
+
responseType: m = "json",
|
|
36
|
+
signal: l,
|
|
37
|
+
toastSuccess: _ = !0,
|
|
38
|
+
toastError: $ = !0
|
|
39
|
+
} = e;
|
|
40
|
+
let d;
|
|
41
|
+
return n ? d = s.host_api_remote : d = s.host_api_local, a.startProgress(), y({
|
|
42
|
+
baseURL: u ? void 0 : d,
|
|
43
|
+
withCredentials: n,
|
|
44
|
+
method: i,
|
|
45
|
+
url: u ? o : `/${o}`,
|
|
46
|
+
data: g,
|
|
47
|
+
params: {},
|
|
48
|
+
paramsSerializer: () => R.stringify(c, { encode: !0 }),
|
|
49
|
+
headers: p,
|
|
50
|
+
timeout: t,
|
|
51
|
+
onDownloadProgress: E,
|
|
52
|
+
responseType: m,
|
|
53
|
+
signal: l
|
|
54
|
+
}).then((r) => v(o, r, a, m, _)).catch(
|
|
55
|
+
(r) => Promise.reject(P(r, a, f, $))
|
|
56
|
+
).finally(() => {
|
|
57
|
+
a.stopProgress();
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
b as a
|
|
62
|
+
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import _ from "axios";
|
|
2
|
-
import $ from "qs";
|
|
3
|
-
import { E as y } from "../types/index.d9c95d2a.js";
|
|
4
|
-
function R(e, t, a, i) {
|
|
5
|
-
const { toast: s } = a;
|
|
6
|
-
return i === "json" ? t && t.data && typeof t.data == "object" ? t.data.error && t.data.error?.code && t.data.error?.msg !== void 0 ? Promise.reject({ ...t.data.error, status: t.status }) : (t.data.message && s(t.data.message, { type: "success", autoClose: 1e4 }), t.data) : Promise.reject({
|
|
7
|
-
code: 1,
|
|
8
|
-
msg: `Incorrect endpoint: ${e}`,
|
|
9
|
-
status: t.status
|
|
10
|
-
}) : t.data;
|
|
11
|
-
}
|
|
12
|
-
function j(e, t, a = !0) {
|
|
13
|
-
const { toast: i } = t;
|
|
14
|
-
let s = {
|
|
15
|
-
message: "",
|
|
16
|
-
status: 1,
|
|
17
|
-
code: 0
|
|
18
|
-
};
|
|
19
|
-
return e?.code !== void 0 && s.status !== void 0 && e.message !== void 0 && (s = { ...s, ...e }), e?.response ? e.response.data && typeof e.response.data == "object" && e.response.data.error && e.response.data.error?.code && e.response.data.error?.message !== void 0 ? s = { ...e.response.data.error, status: e.response.status } : (s.message = e.message, s.status = e.response.status, s.code = 0) : e?.request ? (s.message = `${e?.code} ${e.message}`, s.code = -1) : (s.message = `${e?.code} ${e.message}`, s.status = 0, s.code = -2), a && e?.response?.status === 401 && t.events_emit(y.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (s.message = e?.response?.data?.error.message), a && (s.message.indexOf("ERR_CANCELED") > -1 || i(`${s.message} - status: ${s.status} - code: ${s.code}`, { type: "error" })), s;
|
|
20
|
-
}
|
|
21
|
-
const C = async (e, t, a) => {
|
|
22
|
-
const {
|
|
23
|
-
method: i,
|
|
24
|
-
endPoint: s,
|
|
25
|
-
timeout: u = 6e4,
|
|
26
|
-
parms: c = {},
|
|
27
|
-
data: g = {},
|
|
28
|
-
isRemote: n = !0,
|
|
29
|
-
checkUnAuthorized: f = !0,
|
|
30
|
-
headers: p,
|
|
31
|
-
onDownloadProgress: l,
|
|
32
|
-
isExternalUrl: m,
|
|
33
|
-
responseType: r = "json",
|
|
34
|
-
signal: E
|
|
35
|
-
} = e;
|
|
36
|
-
let o;
|
|
37
|
-
return n ? o = t.host_api_remote : o = t.host_api_local, a.startProgress(), _({
|
|
38
|
-
baseURL: m ? void 0 : o,
|
|
39
|
-
withCredentials: n,
|
|
40
|
-
method: i,
|
|
41
|
-
url: m ? s : `/${s}`,
|
|
42
|
-
data: g,
|
|
43
|
-
params: {},
|
|
44
|
-
paramsSerializer: () => $.stringify(c, { encode: !0 }),
|
|
45
|
-
headers: p,
|
|
46
|
-
timeout: u,
|
|
47
|
-
onDownloadProgress: l,
|
|
48
|
-
responseType: r,
|
|
49
|
-
signal: E
|
|
50
|
-
}).then((d) => R(s, d, a, r)).catch((d) => Promise.reject(j(d, a, f))).finally(() => {
|
|
51
|
-
a.stopProgress();
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
export {
|
|
55
|
-
C as a
|
|
56
|
-
};
|