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.
- package/dist/axiosInstance.d.ts +2 -1
- package/dist/axiosInstance.js +8 -3
- package/dist/index.js +20 -7
- package/dist/services.js +23 -15
- package/dist/servicesData.js +367 -364
- package/dist/src/adapters/createApiAdapter.d.ts +2 -0
- package/dist/src/adapters/createApiAdapter.js +11 -7
- package/dist/src/adapters/financeAdapter.d.ts +2 -0
- package/dist/src/adapters/financeAdapter.js +9 -3
- package/dist/src/adapters/locationAdapter.js +8 -4
- package/dist/src/adapters/partyAdapter.js +10 -6
- package/dist/src/contexts/actionsContext.js +45 -8
- package/dist/src/contexts/apiContext.js +8 -4
- package/dist/src/contexts/translationContext.js +43 -6
- package/dist/src/mapper/Mapper.js +21 -13
- package/dist/src/mapper/endpointsConfig.d.ts +671 -656
- package/dist/src/mapper/endpointsConfig.js +169 -152
- package/dist/src/mapper/helpers/mappingHelpers.js +9 -3
- package/dist/src/mapper/modules/billing/index.js +13 -5
- package/dist/src/mapper/modules/claim/index.js +5 -1
- package/dist/src/mapper/modules/general/index.js +7 -2
- package/dist/src/mapper/modules/party/index.js +21 -9
- package/dist/src/mapper/modules/policy/index.js +24 -5
- package/dist/src/mapper/modules/quotation/index.js +35 -18
- package/dist/src/mapper/modules/request/index.js +7 -2
- package/package.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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,4 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
-
|
|
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
|
-
|
|
2
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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;
|