@m4l/core 1.1.0 → 2.0.0
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/AuthContext/{index.717a8c86.js → index.c8918b5a.js} +1 -1
- package/contexts/BaseContext/index.d.ts +0 -1
- package/contexts/DomainContext/index.d.ts +0 -1
- package/contexts/DomainCountryContext/index.d.ts +0 -1
- package/contexts/EnvironmentContext/index.d.ts +0 -1
- package/contexts/FlagsContext/index.d.ts +0 -1
- package/contexts/HostToolsContext/index.d.ts +0 -1
- package/contexts/ModuleDictionaryContext/index.d.ts +0 -1
- package/contexts/ModulePrivilegesContext/index.d.ts +0 -1
- package/contexts/ModuleSkeletonContext/index.d.ts +0 -1
- package/contexts/NetworkContext/index.d.ts +0 -1
- package/hooks/useAuth/{index.5356a5e9.js → index.bd0fb946.js} +1 -1
- package/hooks/useLocalStorage/{index.7dbb3411.js → index.91bc0791.js} +1 -3
- package/hooks/useLocalStorageWithListener/index.d.ts +2 -1
- package/hooks/usePaginate/index.d.ts +0 -1
- package/index.d.ts +1 -1
- package/index.js +4 -4
- package/package.json +2 -2
- package/types/index.d.ts +14 -3
- package/utils/{axiosOperation.ce4250d4.js → axiosOperation.ac6c8eef.js} +29 -28
|
@@ -4,7 +4,7 @@ import { jsx as v } from "react/jsx-runtime";
|
|
|
4
4
|
import { u as D } from "../../hooks/useHostTools/index.66d9a667.js";
|
|
5
5
|
import { u as N } from "../../hooks/useNetwork/index.3d79002b.js";
|
|
6
6
|
import { u as O } from "../../hooks/useEnvironment/index.25f83176.js";
|
|
7
|
-
import { u as S } from "../../hooks/useLocalStorage/index.
|
|
7
|
+
import { u as S } from "../../hooks/useLocalStorage/index.91bc0791.js";
|
|
8
8
|
import { g as U, s as u } from "../../utils/index.f9db04a8.js";
|
|
9
9
|
var s = /* @__PURE__ */ ((t) => (t.Initial = "INITIALIZE", t.Login = "LOGIN", t.Logout = "LOGOUT", t))(s || {});
|
|
10
10
|
const w = {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { DomainCountryContextType, DomainCountryProviderProps } from './types';
|
|
3
2
|
declare const DomainCountryContext: import("react").Context<DomainCountryContextType | null>;
|
|
4
3
|
declare function DomainCountryProvider(props: DomainCountryProviderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { EnvironmentContextType, EnvironmentProviderProps } from './types';
|
|
3
2
|
declare const EnvironmentContext: import("react").Context<EnvironmentContextType | null>;
|
|
4
3
|
declare function EnvironmentProvider(props: EnvironmentProviderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ModuleDictionaryContextProps, ModuleDictionaryProviderProps } from './types';
|
|
3
2
|
declare const ModuleDictionaryContext: import("react").Context<ModuleDictionaryContextProps | null>;
|
|
4
3
|
declare function ModuleDictionaryProvider(props: ModuleDictionaryProviderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ModulePrivilegesContextProps, ModulePrivilegesProviderProps } from './types';
|
|
3
2
|
declare const ModulePrivilegesContext: import("react").Context<ModulePrivilegesContextProps | null>;
|
|
4
3
|
declare function ModulePrivilegesProvider(props: ModulePrivilegesProviderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ModuleSkeletonContextProps, ModuleSkeletonProviderProps } from './types';
|
|
3
2
|
declare const ModuleSkeletonContext: import("react").Context<ModuleSkeletonContextProps | null>;
|
|
4
3
|
declare function ModuleSkeletonProvider(props: ModuleSkeletonProviderProps): import("react").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import type { NetworkProviderProps } from './types';
|
|
3
2
|
declare const NetworkContext: import("react").Context<import("./types").NetworkType | null>;
|
|
4
3
|
declare function NetworkProvider(props: NetworkProviderProps): import("react").JSX.Element;
|
|
@@ -31,9 +31,7 @@ function u(o, e) {
|
|
|
31
31
|
const t = (r) => {
|
|
32
32
|
if (r.storageArea === localStorage && r.key === o)
|
|
33
33
|
try {
|
|
34
|
-
r.newValue && s(
|
|
35
|
-
typeof e == "string" ? r.newValue : JSON.parse(r.newValue)
|
|
36
|
-
);
|
|
34
|
+
r.newValue && s(typeof e == "string" ? r.newValue : JSON.parse(r.newValue));
|
|
37
35
|
} catch {
|
|
38
36
|
}
|
|
39
37
|
};
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare type SetStateType<ValueType> = (newValue: ValueType) => void;
|
|
2
|
+
export declare function useLocalStorageWithListener<ValueType>(key: string, initialValue: ValueType): [ValueType, SetStateType<ValueType>];
|
|
2
3
|
export default useLocalStorageWithListener;
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from './contexts';
|
|
2
2
|
export * from './hooks';
|
|
3
3
|
export { EmmitEvents as EmitEvents, CommonFlags } from './types';
|
|
4
|
-
export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventListenerBase, EmmitEventsGuard, } from './types';
|
|
4
|
+
export type { Maybe, HostToolsType, NetworkProps, EnvironmentType, AxiosOperation, EventListenerBase, EmmitEventsGuard, ToasterFunctionProps, Toaster, } from './types';
|
|
5
5
|
export type { GetLabelType, Dictionary, ModuleDictionary, ComponentDictionary, } from './types/dictionary';
|
|
6
6
|
export * from './utils';
|
package/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { B as d, a as v } from "./contexts/BaseContext/index.f9cdc955.js";
|
|
|
3
3
|
import { E as P, a as C } from "./contexts/EnvironmentContext/index.b33784cd.js";
|
|
4
4
|
import { H as D, a as S } from "./contexts/HostToolsContext/index.499db832.js";
|
|
5
5
|
import { N as y, a as F } from "./contexts/NetworkContext/index.ec7405cd.js";
|
|
6
|
-
import { A as k, a as h } from "./contexts/AuthContext/index.
|
|
6
|
+
import { A as k, a as h } from "./contexts/AuthContext/index.c8918b5a.js";
|
|
7
7
|
import { F as L, a as A } from "./contexts/FlagsContext/index.5b096265.js";
|
|
8
8
|
import { D as N, a as w } from "./contexts/DomainContext/index.2ed56159.js";
|
|
9
9
|
import { M as W, a as O } from "./contexts/ModuleDictionaryContext/index.44448b0d.js";
|
|
@@ -15,16 +15,16 @@ import { u as X } from "./hooks/useEnvironment/index.25f83176.js";
|
|
|
15
15
|
import { a as Z, u as _ } from "./hooks/useFlagsStore/index.f7c613ac.js";
|
|
16
16
|
import { u as oo } from "./hooks/useHostTools/index.66d9a667.js";
|
|
17
17
|
import { u as ro, a as to } from "./hooks/useDomain/index.dd6909f6.js";
|
|
18
|
-
import { a as so, u as io } from "./hooks/useLocalStorage/index.
|
|
18
|
+
import { a as so, u as io } from "./hooks/useLocalStorage/index.91bc0791.js";
|
|
19
19
|
import { u as no } from "./hooks/useModuleDictionary/index.eec95f41.js";
|
|
20
20
|
import { u as xo } from "./hooks/useModulePrivileges/index.e93abed8.js";
|
|
21
21
|
import { u as lo } from "./hooks/useModuleSkeleton/index.a8238d1d.js";
|
|
22
22
|
import { u as vo } from "./hooks/useNetwork/index.3d79002b.js";
|
|
23
23
|
import { i as Po, u as Co } from "./hooks/usePaginate/index.1306b0de.js";
|
|
24
24
|
import { u as Do } from "./hooks/usePropageteMF/index.c440b829.js";
|
|
25
|
-
import { u as co } from "./hooks/useAuth/index.
|
|
25
|
+
import { u as co } from "./hooks/useAuth/index.bd0fb946.js";
|
|
26
26
|
import { e as Fo, g as Eo, a as ko, s as ho, v as Bo } from "./utils/index.f9db04a8.js";
|
|
27
|
-
import { a as Ao } from "./utils/axiosOperation.
|
|
27
|
+
import { a as Ao } from "./utils/axiosOperation.ac6c8eef.js";
|
|
28
28
|
import "react";
|
|
29
29
|
import "react/jsx-runtime";
|
|
30
30
|
import "zustand";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@m4l/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"author": "M4L Team",
|
|
6
6
|
"private": false,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"history": "5.3.0",
|
|
13
13
|
"qs": "^6.11.0",
|
|
14
14
|
"react": "^17.0.0 || ^18.0.0",
|
|
15
|
-
"react-toastify": "
|
|
15
|
+
"react-toastify": "10.0.5"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"*"
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { Id, ToastOptions } from 'react-toastify';
|
|
2
3
|
import type { BrowserHistory } from 'history';
|
|
3
4
|
import { ResponseType } from 'axios';
|
|
4
5
|
import { DomainCountry } from '../contexts';
|
|
@@ -58,7 +59,17 @@ export declare type NetworkProps = {
|
|
|
58
59
|
bodyToSnakeCase?: boolean;
|
|
59
60
|
responseToCamelCase?: boolean;
|
|
60
61
|
};
|
|
61
|
-
export
|
|
62
|
+
export interface ToasterFunctionProps {
|
|
63
|
+
title: ReactNode;
|
|
64
|
+
description?: ReactNode;
|
|
65
|
+
}
|
|
66
|
+
export declare type Toaster = {
|
|
67
|
+
(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
|
|
68
|
+
success(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
|
|
69
|
+
info(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
|
|
70
|
+
warning(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
|
|
71
|
+
error(props: ToasterFunctionProps, toastOptions?: ToastOptions): Id;
|
|
72
|
+
};
|
|
62
73
|
export declare enum EmmitEvents {
|
|
63
74
|
EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED = "netsevice_unauthorized",
|
|
64
75
|
EMMIT_EVENT_HOST_LOCALE_CHANGE = "host_locale_change",
|
|
@@ -86,7 +97,7 @@ export interface EmmitListenerGuard extends EmmitListenerBaseGuard {
|
|
|
86
97
|
export declare type EmmitEventListener = <E extends keyof EmmitListenerGuard>(event: E, handler: EmmitListenerGuard[E]) => void;
|
|
87
98
|
export declare interface HostToolsType {
|
|
88
99
|
history: BrowserHistory;
|
|
89
|
-
toast:
|
|
100
|
+
toast: Toaster;
|
|
90
101
|
startProgress: VoidFunction;
|
|
91
102
|
stopProgress: VoidFunction;
|
|
92
103
|
events_add_listener: EmmitEventListener;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import R from "axios";
|
|
2
|
+
import b from "qs";
|
|
3
|
+
import j from "camelcase-keys";
|
|
4
4
|
import v from "snakecase-keys";
|
|
5
5
|
import { E as h } from "../types/index.42c24946.js";
|
|
6
6
|
function x(e, t, a, i, o, s) {
|
|
7
7
|
const { toast: r } = a;
|
|
8
|
-
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.
|
|
8
|
+
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 && o && r({ title: t.data.message }, { type: "success", autoClose: 1e4 }), s ? j(t.data, { deep: !0 }) : t.data) : Promise.reject({
|
|
9
9
|
code: 1,
|
|
10
10
|
msg: `Incorrect endpoint: ${e}`,
|
|
11
11
|
status: t.status
|
|
@@ -18,11 +18,14 @@ function T(e, t, a = !0, i = !0) {
|
|
|
18
18
|
status: 1,
|
|
19
19
|
code: 0
|
|
20
20
|
};
|
|
21
|
-
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),
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
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(h.EMMIT_EVENT_NET_SERVICE_UNAUTHORIZED, {}), e?.response?.data?.error?.message && (s.message = e?.response?.data?.error.message), a && (s.message.indexOf("ERR_CANCELED") > -1 ? console.log(s.message) : i && o(
|
|
22
|
+
{ title: `${s.message} - status: ${s.status} - code: ${s.code}` },
|
|
23
|
+
{
|
|
24
|
+
type: "error"
|
|
25
|
+
}
|
|
26
|
+
)), s;
|
|
24
27
|
}
|
|
25
|
-
const
|
|
28
|
+
const L = async (e, t, a) => {
|
|
26
29
|
const {
|
|
27
30
|
method: i,
|
|
28
31
|
endPoint: o,
|
|
@@ -30,45 +33,43 @@ const D = async (e, t, a) => {
|
|
|
30
33
|
timeout: r = 6e4,
|
|
31
34
|
parms: g = {},
|
|
32
35
|
data: m = {},
|
|
33
|
-
isRemote:
|
|
36
|
+
isRemote: u = !0,
|
|
34
37
|
checkUnAuthorized: l = !0,
|
|
35
38
|
headers: p,
|
|
36
39
|
onDownloadProgress: E,
|
|
37
|
-
isExternalUrl:
|
|
40
|
+
isExternalUrl: c,
|
|
38
41
|
responseType: f = "json",
|
|
39
|
-
signal:
|
|
40
|
-
toastSuccess:
|
|
41
|
-
toastError:
|
|
42
|
-
bodyToSnakeCase:
|
|
43
|
-
responseToCamelCase:
|
|
42
|
+
signal: y,
|
|
43
|
+
toastSuccess: _ = !0,
|
|
44
|
+
toastError: P = !0,
|
|
45
|
+
bodyToSnakeCase: $ = !1,
|
|
46
|
+
responseToCamelCase: C = !1
|
|
44
47
|
} = e;
|
|
45
48
|
let d;
|
|
46
|
-
return
|
|
47
|
-
baseURL:
|
|
48
|
-
withCredentials:
|
|
49
|
+
return u ? d = t.host_api_remote : d = t.host_api_local, d = d + "/" + s, e?.options?.startProgress && e?.options?.startProgress(), R({
|
|
50
|
+
baseURL: c ? void 0 : d,
|
|
51
|
+
withCredentials: u,
|
|
49
52
|
method: i,
|
|
50
|
-
url:
|
|
51
|
-
data:
|
|
53
|
+
url: c ? o : `/${o}`,
|
|
54
|
+
data: $ ? v(m, { deep: !0 }) : m,
|
|
52
55
|
params: {},
|
|
53
|
-
paramsSerializer: () =>
|
|
56
|
+
paramsSerializer: () => b.stringify(g, { encode: !0 }),
|
|
54
57
|
headers: p,
|
|
55
58
|
timeout: r,
|
|
56
59
|
onDownloadProgress: E,
|
|
57
60
|
responseType: f,
|
|
58
|
-
signal:
|
|
61
|
+
signal: y
|
|
59
62
|
}).then((n) => x(
|
|
60
63
|
o,
|
|
61
64
|
n,
|
|
62
65
|
a,
|
|
63
66
|
f,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)).catch(
|
|
67
|
-
(n) => (console.log("Reject de la promesa"), Promise.reject(T(n, a, l, _)))
|
|
68
|
-
).finally(() => {
|
|
67
|
+
_,
|
|
68
|
+
C
|
|
69
|
+
)).catch((n) => Promise.reject(T(n, a, l, P))).finally(() => {
|
|
69
70
|
e?.options?.stopProgress && e?.options?.stopProgress();
|
|
70
71
|
});
|
|
71
72
|
};
|
|
72
73
|
export {
|
|
73
|
-
|
|
74
|
+
L as a
|
|
74
75
|
};
|