sysone-api-mapper 1.0.149 → 1.0.151

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.
@@ -1,6 +1,8 @@
1
1
  export interface Api {
2
2
  finance: {
3
3
  getCurrencies: () => Promise<any>;
4
+ getPaymentFrecuencies: () => Promise<any>;
5
+ getBanks: () => Promise<any>;
4
6
  };
5
7
  party: {
6
8
  getGenders: () => Promise<any>;
@@ -1,8 +1,12 @@
1
- import { financeAdapter } from "./financeAdapter";
2
- import { locationAdapter } from "./locationAdapter";
3
- import { partyAdapter } from "./partyAdapter";
4
- export const createApiAdapter = (tenant = 'default') => ({
5
- finance: financeAdapter(tenant),
6
- party: partyAdapter(tenant),
7
- location: locationAdapter(tenant)
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createApiAdapter = void 0;
4
+ const financeAdapter_1 = require("./financeAdapter");
5
+ const locationAdapter_1 = require("./locationAdapter");
6
+ const partyAdapter_1 = require("./partyAdapter");
7
+ const createApiAdapter = (tenant = 'default') => ({
8
+ finance: (0, financeAdapter_1.financeAdapter)(tenant),
9
+ party: (0, partyAdapter_1.partyAdapter)(tenant),
10
+ location: (0, locationAdapter_1.locationAdapter)(tenant)
8
11
  });
12
+ exports.createApiAdapter = createApiAdapter;
@@ -1,3 +1,5 @@
1
1
  export function financeAdapter(tenant: any): {
2
2
  getCurrencies: () => Promise<any>;
3
+ getPaymentFrecuencies: () => Promise<any>;
4
+ getBanks: () => Promise<any>;
3
5
  };
@@ -1,4 +1,10 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
- export const financeAdapter = (tenant) => ({
3
- getCurrencies: () => apiMapper("GET_CURRENCIES", tenant),
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.financeAdapter = void 0;
4
+ const Mapper_1 = require("../mapper/Mapper");
5
+ const financeAdapter = (tenant) => ({
6
+ getCurrencies: () => (0, Mapper_1.apiMapper)("GET_CURRENCIES", tenant),
7
+ getPaymentFrecuencies: () => (0, Mapper_1.apiMapper)("GET_PAYMENT_FRECUENCIES", tenant),
8
+ getBanks: () => (0, Mapper_1.apiMapper)("GET_BANKS", tenant)
4
9
  });
10
+ exports.financeAdapter = financeAdapter;
@@ -1,5 +1,9 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
- export const locationAdapter = (tenant) => ({
3
- getCountries: () => apiMapper("GET_COUNTRIES", tenant),
4
- getProvinces: (countryCode) => apiMapper("GET_PROVINCES", tenant, [countryCode]),
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.locationAdapter = void 0;
4
+ const Mapper_1 = require("../mapper/Mapper");
5
+ const locationAdapter = (tenant) => ({
6
+ getCountries: () => (0, Mapper_1.apiMapper)("GET_COUNTRIES", tenant),
7
+ getProvinces: (countryCode) => (0, Mapper_1.apiMapper)("GET_PROVINCES", tenant, [countryCode]),
5
8
  });
9
+ exports.locationAdapter = locationAdapter;
@@ -1,7 +1,11 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
- export const partyAdapter = (tenant) => ({
3
- getGenders: () => apiMapper("GET_GENDERS", tenant),
4
- getMaritalStatus: () => apiMapper("GET_MARITAL_STATUS", tenant),
5
- getActivity: () => apiMapper("GET_ACTIVITY", tenant),
6
- getIdentificationTypes: (countryCode) => apiMapper("GET_IDENTIFICATION_TYPES", tenant, [countryCode]),
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.partyAdapter = void 0;
4
+ const Mapper_1 = require("../mapper/Mapper");
5
+ const partyAdapter = (tenant) => ({
6
+ getGenders: () => (0, Mapper_1.apiMapper)("GET_GENDERS", tenant),
7
+ getMaritalStatus: () => (0, Mapper_1.apiMapper)("GET_MARITAL_STATUS", tenant),
8
+ getActivity: () => (0, Mapper_1.apiMapper)("GET_ACTIVITY", tenant),
9
+ getIdentificationTypes: (countryCode) => (0, Mapper_1.apiMapper)("GET_IDENTIFICATION_TYPES", tenant, [countryCode]),
7
10
  });
11
+ exports.partyAdapter = partyAdapter;
@@ -1,11 +1,48 @@
1
- import React, { createContext, useContext, useState, useEffect } from "react";
2
- const ActionsContext = createContext();
3
- export function useActions() {
4
- return useContext(ActionsContext);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useActions = useActions;
37
+ exports.ActionsProvider = ActionsProvider;
38
+ const react_1 = __importStar(require("react"));
39
+ const ActionsContext = (0, react_1.createContext)();
40
+ function useActions() {
41
+ return (0, react_1.useContext)(ActionsContext);
5
42
  }
6
- export function ActionsProvider({ initialData, children }) {
7
- const [actions, setActions] = useState([]);
8
- const [ready, setReady] = useState(false);
43
+ function ActionsProvider({ initialData, children }) {
44
+ const [actions, setActions] = (0, react_1.useState)([]);
45
+ const [ready, setReady] = (0, react_1.useState)(false);
9
46
  let actns = [];
10
47
  const extractActions = (menus) => {
11
48
  menus.map((m) => {
@@ -27,7 +64,7 @@ export function ActionsProvider({ initialData, children }) {
27
64
  });
28
65
  return actns;
29
66
  };
30
- useEffect(() => {
67
+ (0, react_1.useEffect)(() => {
31
68
  extractActions(initialData.menus);
32
69
  setActions(actns);
33
70
  setReady(true);
@@ -1,8 +1,12 @@
1
- import { createContext, useContext } from 'react';
2
- export const ApiContext = createContext(null);
3
- export const useApi = () => {
4
- const ctx = useContext(ApiContext);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useApi = exports.ApiContext = void 0;
4
+ const react_1 = require("react");
5
+ exports.ApiContext = (0, react_1.createContext)(null);
6
+ const useApi = () => {
7
+ const ctx = (0, react_1.useContext)(exports.ApiContext);
5
8
  if (!ctx)
6
9
  throw new Error("ApiContext not found");
7
10
  return ctx;
8
11
  };
12
+ exports.useApi = useApi;
@@ -1,10 +1,47 @@
1
- import React, { createContext, useContext, useState } from "react";
2
- const TranslationContext = createContext();
3
- export function useTranslation() {
4
- return useContext(TranslationContext);
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.useTranslation = useTranslation;
37
+ exports.TranslationProvider = TranslationProvider;
38
+ const react_1 = __importStar(require("react"));
39
+ const TranslationContext = (0, react_1.createContext)();
40
+ function useTranslation() {
41
+ return (0, react_1.useContext)(TranslationContext);
5
42
  }
6
- export function TranslationProvider({ initialData, children }) {
7
- const [translations, setTranslationes] = useState(initialData);
43
+ function TranslationProvider({ initialData, children }) {
44
+ const [translations, setTranslationes] = (0, react_1.useState)(initialData);
8
45
  const t = (key, ...args) => {
9
46
  var _a;
10
47
  if (!translations)
@@ -1,7 +1,13 @@
1
- import axiosInstance from "../../axiosInstance";
2
- import { methods, tenantsConfig } from "./endpointsConfig";
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.apiMapper = exports.configureApiMapper = void 0;
7
+ const axiosInstance_1 = __importDefault(require("../../axiosInstance"));
8
+ const endpointsConfig_1 = require("./endpointsConfig");
3
9
  let apiConfig = null;
4
- export const configureApiMapper = (config) => {
10
+ const configureApiMapper = (config) => {
5
11
  apiConfig = {
6
12
  ...apiConfig,
7
13
  ...config,
@@ -11,6 +17,7 @@ export const configureApiMapper = (config) => {
11
17
  },
12
18
  };
13
19
  };
20
+ exports.configureApiMapper = configureApiMapper;
14
21
  const getConfig = () => {
15
22
  if (!apiConfig) {
16
23
  throw new Error("apiMapper not configured. Call configureApiMapper() first.");
@@ -30,10 +37,10 @@ const getUrl = (serviceUrl, routeParams) => {
30
37
  return serviceUrl;
31
38
  return serviceUrl.replace(/{(\d+)}/g, (match, index) => routeParams[index] !== undefined ? routeParams[index] : match);
32
39
  };
33
- export const apiMapper = async (endpointCode, tenant, routeParams, params = null, additionalHeaders = {}) => {
40
+ const apiMapper = async (endpointCode, tenant, routeParams, params = null, additionalHeaders = {}) => {
34
41
  /* -------- Endpoint config -------- */
35
42
  var _a;
36
- const configData = tenantsConfig[endpointCode];
43
+ const configData = endpointsConfig_1.tenantsConfig[endpointCode];
37
44
  if (!configData) {
38
45
  throw new Error(`Endpoint no configurado: ${endpointCode}`);
39
46
  }
@@ -55,9 +62,9 @@ export const apiMapper = async (endpointCode, tenant, routeParams, params = null
55
62
  const url = getUrl(endpointData.url, routeParams);
56
63
  /* -------- Request -------- */
57
64
  switch (endpointData.method) {
58
- case methods.GET: {
65
+ case endpointsConfig_1.methods.GET: {
59
66
  const { mappedParams, responseType, headers: requestHeaders, ...otherOptions } = endpointData.requestMapper(params);
60
- const response = await axiosInstance.get(url, {
67
+ const response = await axiosInstance_1.default.get(url, {
61
68
  ...axiosConfig,
62
69
  params: mappedParams,
63
70
  responseType,
@@ -69,9 +76,9 @@ export const apiMapper = async (endpointCode, tenant, routeParams, params = null
69
76
  });
70
77
  return endpointData.responseMapper(response);
71
78
  }
72
- case methods.POST: {
79
+ case endpointsConfig_1.methods.POST: {
73
80
  const { mappedPostParams, mappedBody, headers: requestHeaders } = endpointData.requestMapper(params);
74
- const response = await axiosInstance.post(url, mappedBody, {
81
+ const response = await axiosInstance_1.default.post(url, mappedBody, {
75
82
  ...axiosConfig,
76
83
  params: mappedPostParams,
77
84
  headers: {
@@ -81,12 +88,12 @@ export const apiMapper = async (endpointCode, tenant, routeParams, params = null
81
88
  });
82
89
  return endpointData.responseMapper(response.data);
83
90
  }
84
- case methods.PUT: {
85
- const response = await axiosInstance.put(url, params, axiosConfig);
91
+ case endpointsConfig_1.methods.PUT: {
92
+ const response = await axiosInstance_1.default.put(url, params, axiosConfig);
86
93
  return endpointData.responseMapper(response.data);
87
94
  }
88
- case methods.DELETE: {
89
- const response = await axiosInstance.delete(url, {
95
+ case endpointsConfig_1.methods.DELETE: {
96
+ const response = await axiosInstance_1.default.delete(url, {
90
97
  ...axiosConfig,
91
98
  data: params,
92
99
  });
@@ -96,3 +103,4 @@ export const apiMapper = async (endpointCode, tenant, routeParams, params = null
96
103
  throw new Error("HTTP method not supported");
97
104
  }
98
105
  };
106
+ exports.apiMapper = apiMapper;