@m4l/core 0.1.55 → 0.1.57

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.
@@ -0,0 +1,57 @@
1
+ import { createContext as f, useState as l, useEffect as p } from "react";
2
+ import { u as D } from "../../hooks/useFlags/index.a986729d.js";
3
+ import { u as v } from "../../hooks/useEnvironment/index.25f83176.js";
4
+ import { u as y } from "../../hooks/useNetwork/index.3d79002b.js";
5
+ import { C as r } from "../../types/index.42c24946.js";
6
+ import { jsx as $ } from "react/jsx-runtime";
7
+ const h = f(null);
8
+ function x(i) {
9
+ const {
10
+ children: _
11
+ } = i, {
12
+ domain_token: c,
13
+ host_static_assets: o,
14
+ environment_assets: n
15
+ } = v(), {
16
+ addFlag: s
17
+ } = D(), [u, t] = l(!1), [d, m] = l({
18
+ company_logo_small_url: "",
19
+ company_logo_normal_url: "",
20
+ name: "",
21
+ slogan: ""
22
+ }), {
23
+ networkOperation: g
24
+ } = y();
25
+ return p(() => {
26
+ let e = !0;
27
+ return g({
28
+ method: "GET",
29
+ endPoint: `na/info/${c}`
30
+ }).then((a) => {
31
+ e && (m({
32
+ ...a.data,
33
+ company_logo_normal_url: a.data.company_logo_normal_url ?? `${o}/${n}/frontend/commons/assets/icons/isologo.svg`,
34
+ company_logo_small_url: a.data.company_logo_small_url ?? `${o}/${n}/frontend/commons/assets/icons/isotipo_m4l.svg`
35
+ }), s(r.FLAG_DOMAIN_LOADED), t(!0));
36
+ }).catch(() => {
37
+ m({
38
+ company_logo_normal_url: `${o}/${n}/frontend/commons/assets/icons/isologo.svg`,
39
+ company_logo_small_url: `${o}/${n}/frontend/commons/assets/icons/isotipo_m4l.svg`,
40
+ name: "Pending",
41
+ slogan: "Pending"
42
+ }), s(r.FLAG_DOMAIN_LOADED), t(!0);
43
+ }).finally(() => {
44
+ }), function() {
45
+ e = !1;
46
+ };
47
+ }, []), /* @__PURE__ */ $(h.Provider, {
48
+ value: {
49
+ ...d
50
+ },
51
+ children: u && _
52
+ });
53
+ }
54
+ export {
55
+ h as D,
56
+ x as a
57
+ };
@@ -1,7 +1,7 @@
1
1
  import { createContext as i, useCallback as l, useState as u } from "react";
2
- import { jsx as a } from "react/jsx-runtime";
3
- const m = i(null);
4
- function d(e) {
2
+ import { jsx as m } from "react/jsx-runtime";
3
+ const a = i(null);
4
+ function c(e) {
5
5
  const {
6
6
  children: o,
7
7
  ...s
@@ -11,19 +11,19 @@ function d(e) {
11
11
  if (e?.isMicroFrontend) {
12
12
  if (!e.mfProps)
13
13
  throw new Error("mfProps is required");
14
- return e?.isLocalhost ? `https://${window.location.hostname}:${e.mfProps.debugPort}/module/assets/icons/${t}` : `mf/${e.mfProps.moduleId}/assets/icons/${t}`;
14
+ return e?.isLocalhost ? `https://${window.location.hostname}:${e.mfProps.debugPort}/module/assets/icons/${t}` : `mf/${e.mfProps.moduleId}/module/assets/icons/${t}`;
15
15
  } else
16
16
  return `mf/module/assets/icons/${t}`;
17
17
  }, []), [r] = u({
18
18
  ...s,
19
19
  getModuleUrlIconAsset: n
20
20
  });
21
- return /* @__PURE__ */ a(m.Provider, {
21
+ return /* @__PURE__ */ m(a.Provider, {
22
22
  value: r,
23
23
  children: o
24
24
  });
25
25
  }
26
26
  export {
27
- m as E,
28
- d as a
27
+ a as E,
28
+ c as a
29
29
  };
@@ -2,9 +2,9 @@ import { createContext as y, useState as F, useEffect as L, useCallback as u } f
2
2
  import { C as M } from "../../types/index.42c24946.js";
3
3
  import { jsx as N } from "react/jsx-runtime";
4
4
  import { u as P } from "../../hooks/useFlags/index.a986729d.js";
5
- import { u as _ } from "../../hooks/useEnvironment/index.a2e0af14.js";
5
+ import { u as _ } from "../../hooks/useEnvironment/index.25f83176.js";
6
6
  import { u as x } from "../../hooks/useHostTools/index.66d9a667.js";
7
- import { u as A } from "../../hooks/useNetwork/index.65526925.js";
7
+ import { u as A } from "../../hooks/useNetwork/index.3d79002b.js";
8
8
  const E = y(null);
9
9
  function j(l) {
10
10
  const {
@@ -3,7 +3,7 @@ import { C as i } from "../../types/index.42c24946.js";
3
3
  import { jsx as v } from "react/jsx-runtime";
4
4
  import { u as E } from "../../hooks/useFlags/index.a986729d.js";
5
5
  import { u as h } from "../../hooks/useHostTools/index.66d9a667.js";
6
- import { u as L } from "../../hooks/useNetwork/index.65526925.js";
6
+ import { u as L } from "../../hooks/useNetwork/index.3d79002b.js";
7
7
  const C = g(null);
8
8
  function _(n) {
9
9
  const {
@@ -1,5 +1,5 @@
1
1
  import { createContext as i, useCallback as c } from "react";
2
- import { u as m } from "../../hooks/useEnvironment/index.a2e0af14.js";
2
+ import { u as m } from "../../hooks/useEnvironment/index.25f83176.js";
3
3
  import { u } from "../../hooks/useHostTools/index.66d9a667.js";
4
4
  import { jsx as l } from "react/jsx-runtime";
5
5
  const p = i(null);
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { D as n } from "../../contexts/DomainContext/index.e24c22eb.js";
2
+ import { D as n } from "../../contexts/DomainContext/index.b9fd4c7f.js";
3
3
  import { D as e } from "../../contexts/DomainCountryContext/index.3cdf9462.js";
4
4
  const m = () => {
5
5
  const o = t(n);
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { E as e } from "../../contexts/EnvironmentContext/index.7a3e7832.js";
2
+ import { E as e } from "../../contexts/EnvironmentContext/index.b33784cd.js";
3
3
  const s = () => {
4
4
  const n = t(e);
5
5
  if (!n)
@@ -1,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { M as e } from "../../contexts/ModuleDictionaryContext/index.02bf4808.js";
2
+ import { M as e } from "../../contexts/ModuleDictionaryContext/index.848a0393.js";
3
3
  const n = () => {
4
4
  const o = t(e);
5
5
  if (!o)
@@ -1,5 +1,5 @@
1
1
  import { useContext as o } from "react";
2
- import { M as t } from "../../contexts/ModulePrivilegesContext/index.d3520d63.js";
2
+ import { M as t } from "../../contexts/ModulePrivilegesContext/index.f1988b13.js";
3
3
  const i = () => {
4
4
  const e = o(t);
5
5
  if (!e)
@@ -1,5 +1,5 @@
1
1
  import { useContext as e } from "react";
2
- import { N as o } from "../../contexts/NetworkContext/index.611d762f.js";
2
+ import { N as o } from "../../contexts/NetworkContext/index.ec7405cd.js";
3
3
  const s = () => {
4
4
  const t = e(o);
5
5
  if (!t)
@@ -1,6 +1,6 @@
1
1
  import { useState as s, useRef as G, useCallback as H, useEffect as p } from "react";
2
2
  import { u as L } from "../useHostTools/index.66d9a667.js";
3
- import { u as N } from "../useNetwork/index.65526925.js";
3
+ import { u as N } from "../useNetwork/index.3d79002b.js";
4
4
  const a = {
5
5
  page: 0,
6
6
  rowsPerPage: 25,
package/index.js CHANGED
@@ -1,28 +1,28 @@
1
1
  import { C as m, E as u } from "./types/index.42c24946.js";
2
2
  import { B as p, a as l } from "./contexts/BaseContext/index.f9cdc955.js";
3
- import { E as d, a as v } from "./contexts/EnvironmentContext/index.7a3e7832.js";
3
+ import { E as d, a as v } from "./contexts/EnvironmentContext/index.b33784cd.js";
4
4
  import { H as P, a as C } from "./contexts/HostToolsContext/index.499db832.js";
5
- import { N as D, a as S } from "./contexts/NetworkContext/index.611d762f.js";
5
+ import { N as D, a as S } from "./contexts/NetworkContext/index.ec7405cd.js";
6
6
  import { F as y, a as F } from "./contexts/FlagsContext/index.5f795859.js";
7
- import { D as k, a as B } from "./contexts/DomainContext/index.e24c22eb.js";
8
- import { M as H, a as N } from "./contexts/ModuleDictionaryContext/index.02bf4808.js";
9
- import { M as T, a as h } from "./contexts/ModulePrivilegesContext/index.d3520d63.js";
7
+ import { D as k, a as B } from "./contexts/DomainContext/index.b9fd4c7f.js";
8
+ import { M as H, a as N } from "./contexts/ModuleDictionaryContext/index.848a0393.js";
9
+ import { M as T, a as h } from "./contexts/ModulePrivilegesContext/index.f1988b13.js";
10
10
  import { M as O, a as b } from "./contexts/ModuleSkeletonContext/index.45963775.js";
11
11
  import { D as q, a as z } from "./contexts/DomainCountryContext/index.3cdf9462.js";
12
12
  import { u as G } from "./hooks/useBase/index.4375dcef.js";
13
- import { u as J } from "./hooks/useEnvironment/index.a2e0af14.js";
13
+ import { u as J } from "./hooks/useEnvironment/index.25f83176.js";
14
14
  import { u as Q, a as R } from "./hooks/useFlags/index.a986729d.js";
15
15
  import { u as V } from "./hooks/useHostTools/index.66d9a667.js";
16
- import { u as Y, a as Z } from "./hooks/useDomain/index.4bcd994f.js";
16
+ import { u as Y, a as Z } from "./hooks/useDomain/index.38a2a89e.js";
17
17
  import { u as $, a as oo } from "./hooks/useLocalStorage/index.48b47dca.js";
18
- import { u as ro } from "./hooks/useModuleDictionary/index.b4e028ef.js";
19
- import { u as to } from "./hooks/useModulePrivileges/index.4a679647.js";
18
+ import { u as ro } from "./hooks/useModuleDictionary/index.3305a123.js";
19
+ import { u as to } from "./hooks/useModulePrivileges/index.cbe0c72f.js";
20
20
  import { u as io } from "./hooks/useModuleSkeleton/index.739fd422.js";
21
- import { u as mo } from "./hooks/useNetwork/index.65526925.js";
22
- import { i as xo, u as po } from "./hooks/usePaginate/index.cb46986d.js";
21
+ import { u as mo } from "./hooks/useNetwork/index.3d79002b.js";
22
+ import { i as xo, u as po } from "./hooks/usePaginate/index.1306b0de.js";
23
23
  import { u as fo } from "./hooks/usePropageteMF/index.c440b829.js";
24
24
  import { e as go, a as Po, g as Co, s as Mo, v as Do } from "./utils/index.c7370abf.js";
25
- import { a as co } from "./utils/axiosOperation.30c7cc9d.js";
25
+ import { a as co } from "./utils/axiosOperation.ce4250d4.js";
26
26
  import "react";
27
27
  import "react/jsx-runtime";
28
28
  import "axios";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m4l/core",
3
- "version": "0.1.55",
3
+ "version": "0.1.57",
4
4
  "license": "UNLICENSED",
5
5
  "author": "M4L Team",
6
6
  "private": false,
package/types/index.d.ts CHANGED
@@ -24,6 +24,10 @@ export declare type EnvironmentType = {
24
24
  isLocalhost: boolean;
25
25
  host: string;
26
26
  domain_token: string;
27
+ /**
28
+ * Base de datos a la que la plataforma se conectará
29
+ */
30
+ database: string;
27
31
  host_api_remote: string;
28
32
  host_api_local: string;
29
33
  host_static_assets: string;
@@ -32,6 +36,12 @@ export declare type EnvironmentType = {
32
36
  export declare type NetworkProps = {
33
37
  method: any;
34
38
  endPoint: string;
39
+ /**
40
+ * "database" Indica la base de datos a la que se conectara. Cuando se instancia axiosOperation se pone el valor por defecto.
41
+ * Para made4Labs es domain
42
+ * Para guardian es operative
43
+ */
44
+ database?: string;
35
45
  timeout?: number;
36
46
  parms?: object;
37
47
  data?: Record<string, any>;
@@ -1,73 +1,74 @@
1
- import $ from "axios";
2
- import j from "qs";
3
- import C from "camelcase-keys";
1
+ import j from "axios";
2
+ import C from "qs";
3
+ import b from "camelcase-keys";
4
4
  import v from "snakecase-keys";
5
- import { E as b } from "../types/index.42c24946.js";
6
- function h(e, t, a, i, o, s) {
7
- const { toast: d } = 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.messagen && o && d(t.data.message, { type: "success", autoClose: 1e4 }), s ? C(t.data, { deep: !0 }) : t.data) : Promise.reject({
5
+ import { E as h } from "../types/index.42c24946.js";
6
+ function x(e, t, a, i, o, s) {
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.messagen && o && r(t.data.message, { type: "success", autoClose: 1e4 }), s ? b(t.data, { deep: !0 }) : t.data) : Promise.reject({
9
9
  code: 1,
10
10
  msg: `Incorrect endpoint: ${e}`,
11
11
  status: t.status
12
12
  }) : t.data;
13
13
  }
14
- function x(e, t, a = !0, i = !0) {
14
+ function T(e, t, a = !0, i = !0) {
15
15
  const { toast: o } = t;
16
16
  let s = {
17
17
  message: "",
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), console.log("ERROR", e), console.log("err", s), a && e?.response?.status === 401 && t.events_emit(b.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 && o(`${s.message} - status: ${s.status} - code: ${s.code}`, {
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), console.log("ERROR", e), console.log("err", s), 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 || i && o(`${s.message} - status: ${s.status} - code: ${s.code}`, {
22
22
  type: "error"
23
23
  })), s;
24
24
  }
25
- const S = async (e, t, a) => {
25
+ const D = async (e, t, a) => {
26
26
  const {
27
27
  method: i,
28
28
  endPoint: o,
29
- timeout: s = 6e4,
30
- parms: d = {},
29
+ database: s = t.database,
30
+ timeout: r = 6e4,
31
+ parms: g = {},
31
32
  data: m = {},
32
33
  isRemote: c = !0,
33
- checkUnAuthorized: g = !0,
34
- headers: l,
35
- onDownloadProgress: p,
34
+ checkUnAuthorized: l = !0,
35
+ headers: p,
36
+ onDownloadProgress: E,
36
37
  isExternalUrl: u,
37
38
  responseType: f = "json",
38
- signal: E,
39
- toastSuccess: R = !0,
40
- toastError: y = !0,
41
- bodyToSnakeCase: _ = !1,
42
- responseToCamelCase: P = !1
39
+ signal: R,
40
+ toastSuccess: y = !0,
41
+ toastError: _ = !0,
42
+ bodyToSnakeCase: P = !1,
43
+ responseToCamelCase: $ = !1
43
44
  } = e;
44
- let r;
45
- return c ? r = t.host_api_remote : r = t.host_api_local, e?.options?.startProgress && e?.options?.startProgress(), $({
46
- baseURL: u ? void 0 : r,
45
+ let d;
46
+ return c ? d = t.host_api_remote : d = t.host_api_local, d = d + "/" + s, e?.options?.startProgress && e?.options?.startProgress(), j({
47
+ baseURL: u ? void 0 : d,
47
48
  withCredentials: c,
48
49
  method: i,
49
50
  url: u ? o : `/${o}`,
50
- data: _ ? v(m, { deep: !0 }) : m,
51
+ data: P ? v(m, { deep: !0 }) : m,
51
52
  params: {},
52
- paramsSerializer: () => j.stringify(d, { encode: !0 }),
53
- headers: l,
54
- timeout: s,
55
- onDownloadProgress: p,
53
+ paramsSerializer: () => C.stringify(g, { encode: !0 }),
54
+ headers: p,
55
+ timeout: r,
56
+ onDownloadProgress: E,
56
57
  responseType: f,
57
- signal: E
58
- }).then((n) => h(
58
+ signal: R
59
+ }).then((n) => x(
59
60
  o,
60
61
  n,
61
62
  a,
62
63
  f,
63
- R,
64
- P
64
+ y,
65
+ $
65
66
  )).catch(
66
- (n) => (console.log("Reject de la promesa"), Promise.reject(x(n, a, g, y)))
67
+ (n) => (console.log("Reject de la promesa"), Promise.reject(T(n, a, l, _)))
67
68
  ).finally(() => {
68
69
  e?.options?.stopProgress && e?.options?.stopProgress();
69
70
  });
70
71
  };
71
72
  export {
72
- S as a
73
+ D as a
73
74
  };
@@ -1,50 +0,0 @@
1
- import { createContext as f, useState as s, useEffect as p } from "react";
2
- import { u as g } from "../../hooks/useFlags/index.a986729d.js";
3
- import { u as D } from "../../hooks/useEnvironment/index.a2e0af14.js";
4
- import { u as v } from "../../hooks/useNetwork/index.65526925.js";
5
- import { C as y } from "../../types/index.42c24946.js";
6
- import { jsx as h } from "react/jsx-runtime";
7
- const $ = f(null);
8
- function A(e) {
9
- const {
10
- children: m
11
- } = e, {
12
- domain_token: r,
13
- host_static_assets: n,
14
- environment_assets: a
15
- } = D(), {
16
- addFlag: l
17
- } = g(), [i, c] = s(!1), [_, u] = s({
18
- company_logo_small_url: "",
19
- company_logo_normal_url: "",
20
- name: "",
21
- slogan: ""
22
- }), {
23
- networkOperation: d
24
- } = v();
25
- return p(() => {
26
- let t = !0;
27
- return d({
28
- method: "GET",
29
- endPoint: `na/info/${r}`
30
- }).then((o) => {
31
- t && (u({
32
- ...o.data,
33
- company_logo_normal_url: o.data.company_logo_normal_url ?? `${n}/${a}/frontend/commons/assets/icons/isologo.svg`,
34
- company_logo_small_url: o.data.company_logo_small_url ?? `${n}/${a}/frontend/commons/assets/icons/isotipo_m4l.svg`
35
- }), l(y.FLAG_DOMAIN_LOADED), c(!0));
36
- }).finally(() => {
37
- }), function() {
38
- t = !1;
39
- };
40
- }, []), /* @__PURE__ */ h($.Provider, {
41
- value: {
42
- ..._
43
- },
44
- children: i && m
45
- });
46
- }
47
- export {
48
- $ as D,
49
- A as a
50
- };