sysone-api-mapper 1.0.148 → 1.0.150

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.
Files changed (60) hide show
  1. package/dist/axiosInstance.d.ts +2 -1
  2. package/dist/axiosInstance.js +10 -0
  3. package/dist/index.d.ts +2 -2
  4. package/dist/index.js +20 -0
  5. package/dist/services.js +100 -0
  6. package/dist/servicesData.js +999 -0
  7. package/dist/src/adapters/createApiAdapter.d.ts +1 -0
  8. package/dist/src/adapters/createApiAdapter.js +12 -0
  9. package/dist/src/adapters/financeAdapter.d.ts +1 -0
  10. package/dist/src/adapters/financeAdapter.js +9 -0
  11. package/dist/src/adapters/locationAdapter.js +9 -0
  12. package/dist/src/adapters/partyAdapter.js +11 -0
  13. package/{src → dist/src}/components/notificationToast.js +35 -37
  14. package/dist/src/contexts/actionsContext.js +80 -0
  15. package/dist/src/contexts/apiContext.js +12 -0
  16. package/dist/src/contexts/translationContext.js +56 -0
  17. package/dist/src/mapper/Mapper.js +106 -0
  18. package/{src → dist/src}/mapper/endpointsConfig.js +824 -915
  19. package/dist/src/mapper/helpers/mappingHelpers.js +30 -0
  20. package/dist/src/mapper/modules/billing/index.js +136 -0
  21. package/dist/src/mapper/modules/claim/index.js +19 -0
  22. package/dist/src/mapper/modules/general/index.js +11 -0
  23. package/dist/src/mapper/modules/party/index.js +131 -0
  24. package/dist/src/mapper/modules/policy/index.js +592 -0
  25. package/dist/src/mapper/modules/quotation/index.js +494 -0
  26. package/{src → dist/src}/mapper/modules/request/index.js +65 -67
  27. package/dist/src/public/index.js +7 -0
  28. package/{src → dist/src}/server.js +18 -23
  29. package/package.json +3 -3
  30. package/.babelrc +0 -4
  31. package/.gitlab-ci.yml +0 -42
  32. package/axiosInstance.js +0 -7
  33. package/config/dist/index.js +0 -307
  34. package/config/dist/index.js.LICENSE.txt +0 -1
  35. package/config/dist/index.ts +0 -319
  36. package/config/webpack.dev.js +0 -63
  37. package/config/webpack.prod.js +0 -63
  38. package/index.d.ts +0 -5
  39. package/index.ts +0 -20
  40. package/services.js +0 -105
  41. package/servicesData.js +0 -1013
  42. package/src/adapters/createApiAdapter.ts +0 -29
  43. package/src/adapters/financeAdapter.js +0 -5
  44. package/src/adapters/locationAdapter.js +0 -6
  45. package/src/adapters/partyAdapter.js +0 -8
  46. package/src/contexts/actionsContext.js +0 -54
  47. package/src/contexts/apiContext.js +0 -9
  48. package/src/contexts/translationContext.js +0 -29
  49. package/src/mapper/Mapper.js +0 -141
  50. package/src/mapper/helpers/mappingHelpers.js +0 -26
  51. package/src/mapper/modules/billing/index.js +0 -131
  52. package/src/mapper/modules/claim/index.js +0 -17
  53. package/src/mapper/modules/general/index.js +0 -7
  54. package/src/mapper/modules/party/index.js +0 -128
  55. package/src/mapper/modules/policy/index.js +0 -613
  56. package/src/mapper/modules/quotation/index.js +0 -480
  57. package/src/public/index.html +0 -15
  58. package/src/public/index.js +0 -9
  59. package/test/script.js +0 -0
  60. package/tsconfig.json +0 -9
@@ -1,29 +0,0 @@
1
- import { financeAdapter } from "./financeAdapter";
2
- import { locationAdapter } from "./locationAdapter";
3
- import { partyAdapter } from "./partyAdapter";
4
-
5
- export interface Api {
6
- finance: {
7
- getCurrencies: () => Promise<any>;
8
- };
9
-
10
- party: {
11
- getGenders: () => Promise<any>,
12
- getMaritalStatus: () => Promise<any>,
13
- getActivity: () => Promise<any>,
14
- getIdentificationTypes: (country: string) => Promise<any>,
15
- };
16
-
17
- location: {
18
- getCountries: () => Promise<any>;
19
- getProvinces: (country: string) => Promise<any>;
20
- };
21
- }
22
-
23
- export const createApiAdapter = (tenant = 'default'): Api => ({
24
- finance: financeAdapter(tenant),
25
- party: partyAdapter(tenant),
26
- location: locationAdapter(tenant)
27
- });
28
-
29
-
@@ -1,5 +0,0 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
-
3
- export const financeAdapter = (tenant) => ({
4
- getCurrencies: () => apiMapper("GET_CURRENCIES", tenant),
5
- });
@@ -1,6 +0,0 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
-
3
- export const locationAdapter = (tenant) => ({
4
- getCountries: () => apiMapper("GET_COUNTRIES", tenant,),
5
- getProvinces: (countryCode) => apiMapper("GET_PROVINCES", tenant, [countryCode]),
6
- });
@@ -1,8 +0,0 @@
1
- import { apiMapper } from "../mapper/Mapper";
2
-
3
- export const partyAdapter = (tenant) => ({
4
- getGenders: () => apiMapper("GET_GENDERS", tenant),
5
- getMaritalStatus: () => apiMapper("GET_MARITAL_STATUS", tenant),
6
- getActivity: () => apiMapper("GET_ACTIVITY", tenant),
7
- getIdentificationTypes: (countryCode) => apiMapper("GET_IDENTIFICATION_TYPES", tenant, [countryCode]),
8
- });
@@ -1,54 +0,0 @@
1
- import React, { createContext, useContext, useState, useEffect } from "react";
2
-
3
- const ActionsContext = createContext();
4
-
5
- export function useActions() {
6
- return useContext(ActionsContext);
7
- }
8
-
9
- export function ActionsProvider({ initialData, children }) {
10
- const [actions, setActions] = useState([]);
11
- const [ready, setReady] = useState(false);
12
-
13
- let actns = [];
14
- const extractActions = (menus) => {
15
- menus.map((m) => {
16
- if (m.actions) {
17
- actns = [
18
- ...actns,
19
- ...m.actions.map((a) => {
20
- return {
21
- code: a.code,
22
- name: a.name,
23
- path: a.path,
24
- menuCode: m.code,
25
- };
26
- }),
27
- ];
28
- }
29
- if (m.menus) extractActions(m.menus);
30
- });
31
-
32
- return actns;
33
- };
34
-
35
- useEffect(() => {
36
- extractActions(initialData.menus);
37
- setActions(actns);
38
- setReady(true);
39
- }, []);
40
-
41
- const hasAction = (key) => {
42
- const menuCode = key.split(".")[0];
43
- const actionCode = key.split(".")[1];
44
- return actions.some(
45
- (el) => el.menuCode === menuCode && el.code === actionCode
46
- );
47
- };
48
-
49
- return (
50
- <ActionsContext.Provider value={{ actions, hasAction, ready }}>
51
- {children}
52
- </ActionsContext.Provider>
53
- );
54
- }
@@ -1,9 +0,0 @@
1
- import { createContext, useContext } from 'react';
2
-
3
- export const ApiContext = createContext(null);
4
-
5
- export const useApi = () => {
6
- const ctx = useContext(ApiContext);
7
- if (!ctx) throw new Error("ApiContext not found");
8
- return ctx;
9
- };
@@ -1,29 +0,0 @@
1
- import React, { createContext, useContext, useState } from "react";
2
-
3
- const TranslationContext = createContext();
4
-
5
- export function useTranslation() {
6
- return useContext(TranslationContext);
7
- }
8
-
9
- export function TranslationProvider({ initialData, children }) {
10
- const [translations, setTranslationes] = useState(initialData);
11
-
12
- const t = (key, ...args) => {
13
- if (!translations) return key;
14
- let translation =
15
- translations.find(
16
- (el) => el.code.toLowerCase().trim() === key.toLowerCase().trim()
17
- )?.content || key;
18
- args.forEach(
19
- (a, index) => (translation = translation.replace(`#${index}#`, a))
20
- );
21
- return translation;
22
- };
23
-
24
- return (
25
- <TranslationContext.Provider value={{ translations, t }}>
26
- {children}
27
- </TranslationContext.Provider>
28
- );
29
- }
@@ -1,141 +0,0 @@
1
- import axiosInstance from "../../axiosInstance";
2
- import { methods, tenantsConfig } from "./endpointsConfig";
3
-
4
-
5
- let apiConfig = null;
6
-
7
- export const configureApiMapper = (config) => {
8
- apiConfig = {
9
- ...apiConfig,
10
- ...config,
11
- headers: {
12
- ...(apiConfig?.headers || {}),
13
- ...(config?.headers || {}),
14
- },
15
- };
16
- };
17
-
18
- const getConfig = () => {
19
- if (!apiConfig) {
20
- throw new Error(
21
- "apiMapper not configured. Call configureApiMapper() first."
22
- );
23
- }
24
- return apiConfig;
25
- };
26
-
27
- /**
28
- * Normaliza tenant (ej: "cnp/foo" → "cnp")
29
- */
30
- const normalizeTenant = (tenant) => {
31
- if (!tenant || typeof tenant !== "string") return tenant;
32
- return tenant.split("/")[0];
33
- };
34
-
35
- const getUrl = (serviceUrl, routeParams) => {
36
- if (!routeParams || routeParams.length === 0) return serviceUrl;
37
-
38
- return serviceUrl.replace(/{(\d+)}/g, (match, index) =>
39
- routeParams[index] !== undefined ? routeParams[index] : match
40
- );
41
- };
42
-
43
-
44
- export const apiMapper = async (
45
- endpointCode,
46
- tenant,
47
- routeParams,
48
- params = null,
49
- additionalHeaders = {}
50
- ) => {
51
- /* -------- Endpoint config -------- */
52
-
53
- const configData = tenantsConfig[endpointCode];
54
- if (!configData) {
55
- throw new Error(`Endpoint no configurado: ${endpointCode}`);
56
- }
57
-
58
- const normalizedTenant = normalizeTenant(tenant);
59
-
60
- const endpointData =
61
- configData[normalizedTenant] ?? configData.default;
62
-
63
- if (!endpointData) {
64
- throw new Error(
65
- `No hay configuración para endpoint ${endpointCode} y tenant ${normalizedTenant}`
66
- );
67
- }
68
-
69
- /* -------- Axios config -------- */
70
-
71
- const { baseURL, headers } = getConfig();
72
-
73
- const axiosConfig = {
74
- baseURL,
75
- headers: {
76
- ...headers,
77
- ...additionalHeaders,
78
- },
79
- validateStatus: (s) => s < 500,
80
- };
81
-
82
- const url = getUrl(endpointData.url, routeParams);
83
-
84
- /* -------- Request -------- */
85
-
86
- switch (endpointData.method) {
87
- case methods.GET: {
88
- const {
89
- mappedParams,
90
- responseType,
91
- headers: requestHeaders,
92
- ...otherOptions
93
- } = endpointData.requestMapper(params);
94
-
95
- const response = await axiosInstance.get(url, {
96
- ...axiosConfig,
97
- params: mappedParams,
98
- responseType,
99
- headers: {
100
- ...axiosConfig.headers,
101
- ...requestHeaders,
102
- },
103
- ...otherOptions,
104
- });
105
-
106
- return endpointData.responseMapper(response);
107
- }
108
-
109
- case methods.POST: {
110
- const { mappedPostParams, mappedBody, headers: requestHeaders } =
111
- endpointData.requestMapper(params);
112
-
113
- const response = await axiosInstance.post(url, mappedBody, {
114
- ...axiosConfig,
115
- params: mappedPostParams,
116
- headers: {
117
- ...axiosConfig.headers,
118
- ...requestHeaders,
119
- },
120
- });
121
-
122
- return endpointData.responseMapper(response.data);
123
- }
124
-
125
- case methods.PUT: {
126
- const response = await axiosInstance.put(url, params, axiosConfig);
127
- return endpointData.responseMapper(response.data);
128
- }
129
-
130
- case methods.DELETE: {
131
- const response = await axiosInstance.delete(url, {
132
- ...axiosConfig,
133
- data: params,
134
- });
135
- return endpointData.responseMapper(response.data);
136
- }
137
-
138
- default:
139
- throw new Error("HTTP method not supported");
140
- }
141
- };
@@ -1,26 +0,0 @@
1
- export const mapPaymentFrequency = (frequencyCode) => {
2
- const mapping = {
3
- 'ANNUAL': 6,
4
- 'MONTHLY': 1,
5
- 'QUARTERLY': 3,
6
- 'SEMI_ANNUAL': 5
7
- };
8
- return mapping[frequencyCode] || 6;
9
- };
10
-
11
- export const mapProductCode = (productCode) => {
12
- const mapping = {
13
- 'SC_SC': 534,
14
- 'VI_VI_VIDA_IND_1': 120,
15
- 'OTRO_CODIGO': 0,
16
- };
17
- return mapping[productCode] || 404;
18
- };
19
-
20
- export const mapProvinceCode = (provinceCode) => {
21
- const mapping = {
22
- 'BS_AS': 1,
23
- 'CABA': 2,
24
- }
25
- return mapping[provinceCode] || 0
26
- }
@@ -1,131 +0,0 @@
1
- export const getBillingsParams = (i) => {
2
- return {}
3
- }
4
-
5
- export const getBillingsResponse = (data) => {
6
- const values = data.paymentsEndorsement.flatMap((endorsement, index) => {
7
-
8
- return endorsement.payments.map((payment, pIndex) => ({
9
- id: `${index + 1}-${pIndex + 1}`, // No tiene ID propio, uso el index + 1
10
- code: `${index + 1}-${pIndex + 1}`, // No tiene código propio, uso el index + 1
11
- billingNumber: payment.installmentNumber,
12
- billingDate: payment.paymentDate,
13
- billingExpirationDate: payment.expiration ?? payment.expirationDate,
14
- totalAmount: payment.amount,
15
- remainingAmount: payment.debt,
16
- paymentStatus: {
17
- code: payment.amount < 0 ? "UNPAID" : "PAID", // ---- Si el monto es negativo esta pago???
18
- name: payment.amount < 0 ? "Sin Pagar" : "Pagado" // ---- Si el monto es negativo esta pago???
19
- },
20
- status: {}, // ----- NO HAY STATUS
21
- name: "Sin nombre del pagador", // ----- NO HAY NOMBRE DEL PAGADOR
22
- policy: {}, // ----- NO HAY DATOS DE POLIZA
23
- billingValuesGrouping: [
24
- {
25
- type: { name: "Prima", code: "PRIME" },
26
- value: payment.amount // ----- SOLO LLEGA LA PRIMA
27
- }
28
- ],
29
- type: {
30
- name: "Factura",
31
- code: "INVOICE",
32
- },
33
- subtype: {},
34
- exchangeRate: null,
35
- billingDateFrom: "N/A",
36
- billingDateTo: "N/A",
37
- invoiceBarcode: payment.invoiceBarcode || null
38
- }));
39
- });
40
-
41
- return {
42
- values,
43
- total: values.length
44
- };
45
- };
46
- export const getDebtorsResponse = (data) => {
47
- const values = data.paymentsEndorsement
48
- .flatMap((endorsement, index) => {
49
- return endorsement.payments.map((payment, pIndex) => ({
50
- id: `${index + 1}-${pIndex + 1}`,
51
- code: `${index + 1}-${pIndex + 1}`,
52
- billingNumber: payment.installmentNumber,
53
- billingDate: payment.paymentDate,
54
- billingExpirationDate: payment.expiration ?? payment.expirationDate,
55
- totalAmount: payment.amount,
56
- remainingAmount: payment.debt,
57
- paymentStatus: {
58
- code: payment.debt < 0 ? "UNPAID" : "PAID",
59
- name: payment.debt < 0 ? "Sin Pagar" : "Pagado"
60
- },
61
- status: {},
62
- name: "Sin nombre del pagador",
63
- policy: {},
64
- billingValuesGrouping: [
65
- {
66
- type: { name: "Prima", code: "PRIME" },
67
- value: payment.amount
68
- }
69
- ],
70
- type: {
71
- name: "Factura",
72
- code: "INVOICE",
73
- },
74
- subtype: {},
75
- exchangeRate: null,
76
- billingDateFrom: "N/A",
77
- billingDateTo: "N/A",
78
- invoiceBarcode: payment.invoiceBarcode || null
79
- }));
80
- })
81
- .filter(payment => payment?.debt > 0 || payment?.remainingAmount > 0);
82
-
83
- return {
84
- values,
85
- total: values.length
86
- };
87
- };
88
-
89
- export const getCollecionsResponse = (data) => {
90
- const values = data.paymentsEndorsement.flatMap((endorsement, index) => {
91
-
92
- return endorsement.payments.map((payment, pIndex) => ({
93
- code: `${index + 1}-${pIndex + 1}`,
94
- amount: payment.amount,
95
- applyAmount: payment.debt,
96
- collectionDate: payment.paymentDate,
97
- collectionNumber: payment.installmentNumber,
98
- currency: {
99
- name: "Peso Argentino",
100
- code: "PESO_ARG",
101
- mnemonic: "ARS",
102
- symbol: "$"
103
- },
104
- name: "Sin nombre del pagador",
105
- paymentType: null,
106
- policy: {},
107
- status: {},
108
- invoiceBarcode: payment.invoiceBarcode || null,
109
- rejectionReason: payment.rejectionReason || null,
110
- expirationDate: payment.expirationDate || null,
111
- }));
112
- });
113
-
114
- return {
115
- values,
116
- total: values.length
117
- };
118
- };
119
-
120
-
121
- export const getBillingTypeResponse = () => {
122
- return {
123
- types: [
124
- {
125
- name: "Factura",
126
- code: "INVOICE",
127
- operator: null
128
- },
129
- ]
130
- }
131
- }
@@ -1,17 +0,0 @@
1
-
2
- export const getClaims_CNP = async (response) => {
3
- const objectMapped = {
4
- values: response?.claims?.map((claim) => ({
5
- claimNumber: claim.claimNumber.toString(),
6
- policyNumber: claim.policyNumber,
7
- creationDate: claim.claimDate,
8
- status: {
9
- name: claim.status,
10
- code: "N/A"
11
- }
12
- })
13
- ),
14
- };
15
-
16
- return objectMapped;
17
- }
@@ -1,7 +0,0 @@
1
- export const getModules = () => { }
2
-
3
- export const getModules_Request = (params) => {
4
- return {
5
- roles: params.roles,
6
- }
7
- }
@@ -1,128 +0,0 @@
1
-
2
-
3
- export const getIdentificationTypes = async (response) => {
4
- const objectMapped = {
5
- values: response.types.map(a => ({
6
- code: a.code,
7
- name: a.name,
8
- })),
9
- }
10
- return objectMapped;
11
- }
12
-
13
- export const getCountries = async (response) => {
14
- const objectMapped = {
15
- countries: response.countries.map(a => ({
16
- code: a.code,
17
- name: a.name,
18
- areaCode: 'N/A'
19
- })),
20
- }
21
- return objectMapped;
22
- }
23
-
24
- export const getProvinces = async (response) => {
25
- const objectMapped = {
26
- provinces: response.provinces.map(a => ({
27
- name: a.name,
28
- code: a.code,
29
- country: {
30
- code: a.country.code,
31
- name: a.country.name,
32
- areaCode: "N/A"
33
- }
34
- })),
35
- }
36
- return objectMapped;
37
- }
38
-
39
- export const getMaritalStatuses = async (response) => {
40
- const objectMapped = {
41
- values: response.statuses.map(a => ({
42
- name: a.name,
43
- code: a.code,
44
- })),
45
- }
46
- return objectMapped;
47
- }
48
-
49
- export const getGenders = async (response) => {
50
- const objectMapped = {
51
- values: response.genders.map(a => ({
52
- name: a.name,
53
- code: a.code,
54
- })),
55
- }
56
- return objectMapped;
57
- }
58
-
59
- export const getProductsBySubsections_Request = (params) => {
60
- return {
61
- subsectionCode: null
62
- }
63
- }
64
-
65
- export const partySearchParams = (params) => {
66
- return {
67
- firstName: params.firstName || params.name || null,
68
- lastName: params.lastName || null,
69
- identification: params.identificationValue || null,
70
- }
71
- }
72
-
73
- export const partySearch = (res) => {
74
- const objectMapped = {
75
- values: res?.parties?.map(party => {
76
-
77
- // Separación por doble espacio
78
- const [lastNamePart, firstNamePart] = party?.fullName?.split(" ") || [];
79
-
80
- return {
81
- activeDate: party?.activeDate || null,
82
- partyCode: party?.code || null,
83
- code: party?.identification?.value || null,
84
- firstName: firstNamePart || null,
85
- lastName: lastNamePart || null,
86
- identifications: {
87
- values: [
88
- {
89
- default: true,
90
- type: {
91
- code: "",
92
- name: "",
93
- },
94
- value: party?.identification?.value || null,
95
- }
96
- ]
97
- },
98
- birthDate: party?.birthDate,
99
- insuredCode: party?.insuredCode
100
- };
101
- })
102
- };
103
-
104
- return objectMapped;
105
- };
106
-
107
-
108
- export const getCoverages = (p) => {
109
- const objectMapped = {
110
- coverages: p.coverages?.map(c => ({
111
- calculatorTypes: [],
112
- active: c.active,
113
- coverage: {
114
- code: c.coverage?.code,
115
- name: c.coverage?.description,
116
- description: c.coverage?.name,
117
- },
118
- coverageValues: c.coverageValues,
119
- type: c.type,
120
- deductibles: null,
121
- requiredDeductible: null,
122
- taxPlan: null,
123
- wordings: []
124
- }))
125
- }
126
-
127
- return objectMapped;
128
- }