@m4l/core 0.1.56 → 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,5 +1,5 @@
1
1
  import { useContext as t } from "react";
2
- import { D as n } from "../../contexts/DomainContext/index.2339e0b7.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);
package/index.js CHANGED
@@ -4,7 +4,7 @@ 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
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.2339e0b7.js";
7
+ import { D as k, a as B } from "./contexts/DomainContext/index.b9fd4c7f.js";
8
8
  import { M as H, a as N } from "./contexts/ModuleDictionaryContext/index.848a0393.js";
9
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";
@@ -13,7 +13,7 @@ import { u as G } from "./hooks/useBase/index.4375dcef.js";
13
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.6ab40615.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
18
  import { u as ro } from "./hooks/useModuleDictionary/index.3305a123.js";
19
19
  import { u as to } from "./hooks/useModulePrivileges/index.cbe0c72f.js";
@@ -22,7 +22,7 @@ import { u as mo } from "./hooks/useNetwork/index.3d79002b.js";
22
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.56",
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.25f83176.js";
4
- import { u as v } from "../../hooks/useNetwork/index.3d79002b.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
- };