@credithub/harlan-components 1.40.1 → 1.40.3
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/@types/domain/index.d.ts +1 -0
- package/dist/components/chart/chartSystem.js +62 -19
- package/dist/components/chart/hooks/useCategoryProtestos.js +30 -24
- package/dist/components/chart/types/iChart.d.ts +2 -0
- package/dist/components/dossie/dossie.js +4 -4
- package/dist/components/dossie/generativeAi/dataUtils.d.ts +5 -0
- package/dist/components/dossie/generativeAi/dataUtils.js +136 -0
- package/dist/components/dossie/generativeAi/generativeAi.d.ts +6 -0
- package/dist/components/dossie/{llama/llama.js → generativeAi/generativeAi.js} +6 -4
- package/dist/components/dossie/{llama → generativeAi}/queryUtils.js +1 -5
- package/dist/components/dossie/{llama → generativeAi}/responseUtils.d.ts +1 -1
- package/lib/cjs/index.js +261 -148
- package/lib/esm/index.js +261 -148
- package/package.json +1 -1
- package/dist/components/dossie/llama/dataUtils.d.ts +0 -6
- package/dist/components/dossie/llama/dataUtils.js +0 -54
- package/dist/components/dossie/llama/llama.d.ts +0 -6
- /package/dist/components/dossie/{llama → generativeAi}/queryUtils.d.ts +0 -0
- /package/dist/components/dossie/{llama → generativeAi}/responseUtils.js +0 -0
- /package/dist/components/dossie/{llama → generativeAi}/styles.d.ts +0 -0
- /package/dist/components/dossie/{llama → generativeAi}/styles.js +0 -0
|
@@ -3,6 +3,7 @@ export type { BankAccount, BankAccountsState } from '@/@types/domain/bankAccount
|
|
|
3
3
|
export type { CCFData, CCFState } from '@/@types/domain/ccfTypes';
|
|
4
4
|
export type { Contact, ContactsState } from '@/@types/domain/contactsTypes';
|
|
5
5
|
export type { Divida, DividasPublicasState } from '@/@types/domain/dividasTypes';
|
|
6
|
+
export type { DocumentHistoryData } from '@/@types/domain/documentHistoryData';
|
|
6
7
|
export type { CarouselState, DossieState, SummaryState, TransactionTableState } from '@/@types/domain/dossieTypes';
|
|
7
8
|
export type { IPTUItem, ImoveisConsultaResponse } from '@/@types/domain/imoveisTypes';
|
|
8
9
|
export type { LiminarResponse } from '@/@types/domain/liminarTypes';
|
|
@@ -2,7 +2,19 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
|
|
|
2
2
|
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
3
|
return cooked;
|
|
4
4
|
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
5
16
|
import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
|
|
17
|
+
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
6
18
|
import { converterParaFormatoValido } from '../../utils/date';
|
|
7
19
|
import React, { useContext, useEffect, useState } from 'react';
|
|
8
20
|
import styled from 'styled-components';
|
|
@@ -20,33 +32,28 @@ var ChartSystem = function (_a) {
|
|
|
20
32
|
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
21
33
|
var documento = _a.documento;
|
|
22
34
|
var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
|
|
35
|
+
var setGlobalState = useGlobalData().setData;
|
|
36
|
+
var _k = useState(false), dataUpdated = _k[0], setDataUpdated = _k[1];
|
|
37
|
+
var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
|
|
23
38
|
var consultaSerasa = (_c = (_b = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _b === void 0 ? void 0 : _b.refinSerasa) === null || _c === void 0 ? void 0 : _c.data;
|
|
24
39
|
var consultaBoaVista = (_e = (_d = ctxConsultasComplementares === null || ctxConsultasComplementares === void 0 ? void 0 : ctxConsultasComplementares.consultasComplementares) === null || _d === void 0 ? void 0 : _d.refinBoaVista) === null || _e === void 0 ? void 0 : _e.data;
|
|
25
|
-
var
|
|
26
|
-
var _l = useState(false), refetchTriggered = _l[0], setRefetchTriggered = _l[1];
|
|
40
|
+
var _l = useChartData(documento, consultaSerasa, consultaBoaVista), chartData = _l.data, isLoadingChart = _l.isLoading, errorChart = _l.error, refetchChart = _l.refetch, chartDataProgress = _l.loadingProgress;
|
|
27
41
|
var _m = useDividasPublicas(), quantidadeDividas = _m.quantidade, valorTotalDividas = _m.valorTotal, ultimaOcorrenciaDividas = _m.ultimaOcorrencia, dividasProgress = _m.loadingProgress;
|
|
28
42
|
useEffect(function () {
|
|
29
43
|
if (consultaSerasa || consultaBoaVista) {
|
|
30
44
|
refetchChart();
|
|
31
|
-
setRefetchTriggered(true);
|
|
32
45
|
}
|
|
33
46
|
}, [consultaSerasa, consultaBoaVista, refetchChart]);
|
|
34
|
-
useEffect(function () {
|
|
35
|
-
if (refetchTriggered) {
|
|
36
|
-
setRefetchTriggered(false);
|
|
37
|
-
}
|
|
38
|
-
}, [refetchTriggered]);
|
|
39
47
|
var errorMessage = typeof errorChart === 'string' ? new Error(errorChart) : errorChart;
|
|
40
48
|
var isOpen = useToggle(true)[0];
|
|
41
|
-
var
|
|
42
|
-
var
|
|
43
|
-
var
|
|
44
|
-
var
|
|
45
|
-
var
|
|
46
|
-
var quantidadeCCFs = useCalculation((data === null || data === void 0 ? void 0 : data.ccfs) || []).quantidade;
|
|
49
|
+
var quantidadeProtestos = ((_g = (_f = chartData === null || chartData === void 0 ? void 0 : chartData.protestos) === null || _f === void 0 ? void 0 : _f[(chartData === null || chartData === void 0 ? void 0 : chartData.protestos.length) - 1]) === null || _g === void 0 ? void 0 : _g.quantidade) || 0;
|
|
50
|
+
var valorTotalProtestos = ((_j = (_h = chartData === null || chartData === void 0 ? void 0 : chartData.protestos) === null || _h === void 0 ? void 0 : _h[(chartData === null || chartData === void 0 ? void 0 : chartData.protestos.length) - 1]) === null || _j === void 0 ? void 0 : _j.valorTotal) || 0;
|
|
51
|
+
var _o = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.serasa) || []), quantidadeSerasa = _o.quantidade, valorTotalSerasa = _o.valorTotal, ultimaOcorrenciaSerasa = _o.dataMaisRecente;
|
|
52
|
+
var _p = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.boaVista) || []), quantidadeBoaVista = _p.quantidade, valorTotalBoaVista = _p.valorTotal, ultimaOcorrenciaBoaVista = _p.dataMaisRecente;
|
|
53
|
+
var quantidadeCCFs = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.ccfs) || []).quantidade;
|
|
47
54
|
var ultimaOcorrenciaProtestos = '';
|
|
48
|
-
if ((
|
|
49
|
-
var datasOcorrencias =
|
|
55
|
+
if ((chartData === null || chartData === void 0 ? void 0 : chartData.protestosCategory) && chartData.protestosCategory.length > 0) {
|
|
56
|
+
var datasOcorrencias = chartData.protestosCategory
|
|
50
57
|
.map(function (categoria) { return categoria.ultimaOcorrencia; })
|
|
51
58
|
.filter(Boolean)
|
|
52
59
|
.map(function (data) {
|
|
@@ -64,6 +71,42 @@ var ChartSystem = function (_a) {
|
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
var loadingProgress = (chartDataProgress + dividasProgress) / 2;
|
|
74
|
+
useEffect(function () {
|
|
75
|
+
if (!dataUpdated && chartData) {
|
|
76
|
+
setGlobalState(function (prevState) {
|
|
77
|
+
var _a;
|
|
78
|
+
return (__assign(__assign({}, prevState), { documentHistory: {
|
|
79
|
+
quantidadeProtestos: quantidadeProtestos,
|
|
80
|
+
quantidadeProcessos: ((_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos) || 0,
|
|
81
|
+
quantidadeDividas: quantidadeDividas,
|
|
82
|
+
quantidadeDividasSerasa: quantidadeSerasa,
|
|
83
|
+
quantidadeDividasBoaVista: quantidadeBoaVista,
|
|
84
|
+
quantidadeChequesSemFundos: quantidadeCCFs,
|
|
85
|
+
ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF,
|
|
86
|
+
valorTotalDividasSerasa: valorTotalSerasa,
|
|
87
|
+
valorTotalDividasBoaVista: valorTotalBoaVista,
|
|
88
|
+
valorTotalProtestos: valorTotalProtestos,
|
|
89
|
+
valorTotalDividas: valorTotalDividas,
|
|
90
|
+
ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos,
|
|
91
|
+
ultimaOcorrenciaDividas: ultimaOcorrenciaDividas,
|
|
92
|
+
ultimaOcorrenciaPefinBoaVista: quantidadeBoaVista > 0
|
|
93
|
+
? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
|
|
94
|
+
: undefined,
|
|
95
|
+
ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
|
|
96
|
+
? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
|
|
97
|
+
: undefined
|
|
98
|
+
} }));
|
|
99
|
+
});
|
|
100
|
+
setDataUpdated(true);
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
chartData,
|
|
104
|
+
quantidadeDividas,
|
|
105
|
+
valorTotalDividas,
|
|
106
|
+
ultimaOcorrenciaDividas,
|
|
107
|
+
setGlobalState,
|
|
108
|
+
ultimaOcorrenciaCCF
|
|
109
|
+
]);
|
|
67
110
|
return (React.createElement(Section, { ctx: {
|
|
68
111
|
response: undefined,
|
|
69
112
|
type: isLoadingChart
|
|
@@ -73,14 +116,14 @@ var ChartSystem = function (_a) {
|
|
|
73
116
|
: RequestStatus.Success,
|
|
74
117
|
error: errorMessage || null,
|
|
75
118
|
refetch: refetchChart,
|
|
76
|
-
document:
|
|
119
|
+
document: chartData,
|
|
77
120
|
progress: loadingProgress,
|
|
78
121
|
Section: Section
|
|
79
122
|
}, title: "Resumo de Negativa\u00E7\u00F5es", subtitle: "Veja a quantidade de ocorr\u00EAncias conforme o documento foi consultado ao longo do tempo", icon: ResumoDeNegativacoesIcon, onSuccess: function () {
|
|
80
123
|
var _a;
|
|
81
124
|
return (React.createElement(Content, { isOpen: isOpen },
|
|
82
|
-
|
|
83
|
-
React.createElement(QuantidadeResultados, { data:
|
|
125
|
+
chartData && React.createElement(ChartContent, { dataInput: chartData }),
|
|
126
|
+
React.createElement(QuantidadeResultados, { data: chartData, quantidadeProtestos: quantidadeProtestos, quantidadeProcessos: (_a = chartData === null || chartData === void 0 ? void 0 : chartData.pieChartTotalConfig) === null || _a === void 0 ? void 0 : _a.processosJuridicos, quantidadeDividas: quantidadeDividas, quantidadeDividasSerasa: quantidadeSerasa, quantidadeDividasBoaVista: quantidadeBoaVista, quantidadeChequesSemFundos: quantidadeCCFs, ultimaOcorrenciaChequesSemFundos: ultimaOcorrenciaCCF, valorTotalDividasSerasa: valorTotalSerasa, valorTotalDividasBoaVista: valorTotalBoaVista, valorTotalProtestos: valorTotalProtestos, valorTotalDividas: valorTotalDividas, ultimaOcorrenciaProtestos: ultimaOcorrenciaProtestos, ultimaOcorrenciaDividas: ultimaOcorrenciaDividas, ultimaOcorrenciaPefinBoaVista: quantidadeBoaVista > 0
|
|
84
127
|
? (ultimaOcorrenciaBoaVista !== null && ultimaOcorrenciaBoaVista !== void 0 ? ultimaOcorrenciaBoaVista : undefined)
|
|
85
128
|
: undefined, ultimaOcorrenciaPefinSerasa: quantidadeSerasa > 0
|
|
86
129
|
? (ultimaOcorrenciaSerasa !== null && ultimaOcorrenciaSerasa !== void 0 ? ultimaOcorrenciaSerasa : undefined)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
export var useCategoryProtestos = function (dataInput) {
|
|
3
|
-
var
|
|
3
|
+
var _a = useMemo(function () {
|
|
4
4
|
var safeDataInput = dataInput || [];
|
|
5
5
|
var categoryCounts = {
|
|
6
6
|
'Protestos de Crédito': 0,
|
|
@@ -8,38 +8,25 @@ export var useCategoryProtestos = function (dataInput) {
|
|
|
8
8
|
'Protestos Gerais': 0
|
|
9
9
|
};
|
|
10
10
|
safeDataInput.forEach(function (item) {
|
|
11
|
-
|
|
11
|
+
if (item.categoria in categoryCounts) {
|
|
12
|
+
categoryCounts[item.categoria] += item.quantidade;
|
|
13
|
+
}
|
|
12
14
|
});
|
|
13
|
-
var labels = Object.keys(categoryCounts);
|
|
14
|
-
var dataValues = Object.values(categoryCounts);
|
|
15
15
|
return {
|
|
16
|
-
labels:
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
data: dataValues,
|
|
20
|
-
backgroundColor: [
|
|
21
|
-
'rgba(255, 99, 132, 0.2)',
|
|
22
|
-
'rgba(255, 159, 64, 0.2)',
|
|
23
|
-
'rgba(54, 162, 235, 0.2)'
|
|
24
|
-
],
|
|
25
|
-
borderColor: [
|
|
26
|
-
'rgba(255, 99, 132, 1)',
|
|
27
|
-
'rgba(255, 159, 64, 1)',
|
|
28
|
-
'rgba(54, 162, 235, 1)'
|
|
29
|
-
],
|
|
30
|
-
borderWidth: 1
|
|
31
|
-
}
|
|
32
|
-
]
|
|
16
|
+
labels: Object.keys(categoryCounts),
|
|
17
|
+
dataValues: Object.values(categoryCounts)
|
|
33
18
|
};
|
|
34
|
-
}, [dataInput]);
|
|
19
|
+
}, [dataInput]), labels = _a.labels, dataValues = _a.dataValues;
|
|
35
20
|
var options = useMemo(function () {
|
|
21
|
+
var maxValue = Math.max.apply(Math, dataValues);
|
|
22
|
+
var stepSize = Math.ceil(maxValue / 10);
|
|
36
23
|
return {
|
|
37
24
|
scales: {
|
|
38
25
|
y: {
|
|
39
26
|
beginAtZero: true,
|
|
40
27
|
ticks: {
|
|
41
28
|
precision: 0,
|
|
42
|
-
stepSize: 1,
|
|
29
|
+
stepSize: stepSize > 1 ? stepSize : 1,
|
|
43
30
|
suggestedMin: 0,
|
|
44
31
|
callback: function (value) {
|
|
45
32
|
return Number.isInteger(value) ? value : null;
|
|
@@ -66,6 +53,25 @@ export var useCategoryProtestos = function (dataInput) {
|
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
55
|
};
|
|
69
|
-
}, []);
|
|
56
|
+
}, [dataValues]);
|
|
57
|
+
var data = useMemo(function () { return ({
|
|
58
|
+
labels: labels,
|
|
59
|
+
datasets: [
|
|
60
|
+
{
|
|
61
|
+
data: dataValues,
|
|
62
|
+
backgroundColor: [
|
|
63
|
+
'rgba(255, 99, 132, 0.2)',
|
|
64
|
+
'rgba(255, 159, 64, 0.2)',
|
|
65
|
+
'rgba(54, 162, 235, 0.2)'
|
|
66
|
+
],
|
|
67
|
+
borderColor: [
|
|
68
|
+
'rgba(255, 99, 132, 1)',
|
|
69
|
+
'rgba(255, 159, 64, 1)',
|
|
70
|
+
'rgba(54, 162, 235, 1)'
|
|
71
|
+
],
|
|
72
|
+
borderWidth: 1
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
}); }, [labels, dataValues]);
|
|
70
76
|
return { data: data, options: options };
|
|
71
77
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DocumentHistoryData } from '../../../@types/domain';
|
|
1
2
|
export interface Consulta {
|
|
2
3
|
data: string | Date;
|
|
3
4
|
categoria?: string;
|
|
@@ -25,6 +26,7 @@ export interface DataInput {
|
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
protestosCategory?: ProtestoData[];
|
|
29
|
+
documentHistory?: DocumentHistoryData;
|
|
28
30
|
}
|
|
29
31
|
export interface ProtestoData {
|
|
30
32
|
categoria: string;
|
|
@@ -24,12 +24,12 @@ import { Section } from '../section';
|
|
|
24
24
|
import { Queries, RequestStatus } from '../webservice';
|
|
25
25
|
import { Carrousel } from './carrousel/carrousel';
|
|
26
26
|
import { createDossieData } from './dossieData';
|
|
27
|
-
import
|
|
27
|
+
import GenerativeAI from './generativeAi/generativeAi';
|
|
28
28
|
import { Summary } from './summary/summary';
|
|
29
29
|
import { TransactionsTable } from './transactionTable/transactionTable';
|
|
30
30
|
var DossieContent = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"], ["\n display: grid;\n grid-template-columns: 1fr 2fr;\n justify-items: center;\n align-items: flex-start;\n margin-bottom: 20px;\n gap: 20px;\n\n @media screen and (max-width: 992px) {\n grid-template-columns: 1fr;\n }\n"])));
|
|
31
31
|
var DossieContainer = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n padding: 0px 70px;\n\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"], ["\n padding: 0px 70px;\n\n @media (max-width: 1000px) {\n padding: 0px 30px;\n }\n"])));
|
|
32
|
-
var
|
|
32
|
+
var GenerativeAIContainer = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n padding: 32px;\n background-color: ", ";\n"], ["\n padding: 32px;\n background-color: ", ";\n"])), function (_a) {
|
|
33
33
|
var theme = _a.theme;
|
|
34
34
|
return theme.colors.white;
|
|
35
35
|
});
|
|
@@ -71,8 +71,8 @@ var Dossie = function (_a) {
|
|
|
71
71
|
React.createElement(DossieCarrousel, null),
|
|
72
72
|
React.createElement(Summary, { finderResponse: data, rfbResponse: rfbResponse, document: document })),
|
|
73
73
|
React.createElement(TransactionsTable, { events: XPathUtils.select('//historico/consulta', data) || [] })),
|
|
74
|
-
React.createElement(
|
|
75
|
-
React.createElement(
|
|
74
|
+
React.createElement(GenerativeAIContainer, null,
|
|
75
|
+
React.createElement(GenerativeAI, { documento: document }))));
|
|
76
76
|
};
|
|
77
77
|
return (React.createElement(Section, { ctx: ctx, hideHeader: true, minimized: false, isError: function (e) { return response(e); }, onSuccess: response }));
|
|
78
78
|
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import { safeStringify } from './responseUtils';
|
|
3
|
+
export function flattenData(data) {
|
|
4
|
+
var flattened = {};
|
|
5
|
+
for (var key in data) {
|
|
6
|
+
if (typeof data[key] === 'object' && !Array.isArray(data[key])) {
|
|
7
|
+
var innerData = data[key];
|
|
8
|
+
for (var innerKey in innerData) {
|
|
9
|
+
flattened[innerKey] = innerData[innerKey];
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
flattened[key] = data[key];
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return safeStringify(flattened);
|
|
17
|
+
}
|
|
18
|
+
export function limitDataSize(items, maxItems) {
|
|
19
|
+
if (!Array.isArray(items))
|
|
20
|
+
return [];
|
|
21
|
+
return items.slice(0, maxItems).map(function (item) {
|
|
22
|
+
if (typeof item === 'object') {
|
|
23
|
+
return Object.keys(item).reduce(function (limitedItem, key, index) {
|
|
24
|
+
if (index < maxItems) {
|
|
25
|
+
limitedItem[key] = item[key];
|
|
26
|
+
}
|
|
27
|
+
return limitedItem;
|
|
28
|
+
}, {});
|
|
29
|
+
}
|
|
30
|
+
return item;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function isEmptyObject(obj) {
|
|
34
|
+
if (typeof obj !== 'object' || obj === null)
|
|
35
|
+
return false;
|
|
36
|
+
return Object.values(obj).every(function (value) { return isEmptyObject(value); });
|
|
37
|
+
}
|
|
38
|
+
function deepCleanData(data) {
|
|
39
|
+
if (typeof data !== 'object' || data === null)
|
|
40
|
+
return data;
|
|
41
|
+
if (Array.isArray(data)) {
|
|
42
|
+
var cleanedArray = data
|
|
43
|
+
.map(function (item) { return deepCleanData(item); })
|
|
44
|
+
.filter(function (item) {
|
|
45
|
+
return item !== null &&
|
|
46
|
+
item !== undefined &&
|
|
47
|
+
item !== '' &&
|
|
48
|
+
!(Array.isArray(item) && item.length === 0);
|
|
49
|
+
});
|
|
50
|
+
return cleanedArray.length > 0 ? cleanedArray : null;
|
|
51
|
+
}
|
|
52
|
+
var cleanedObject = Object.entries(data).reduce(function (acc, _a) {
|
|
53
|
+
var key = _a[0], value = _a[1];
|
|
54
|
+
if (key === 'props')
|
|
55
|
+
return acc;
|
|
56
|
+
var cleanedValue = deepCleanData(value);
|
|
57
|
+
if (cleanedValue !== null &&
|
|
58
|
+
cleanedValue !== undefined &&
|
|
59
|
+
cleanedValue !== '' &&
|
|
60
|
+
!(typeof cleanedValue === 'object' && isEmptyObject(cleanedValue))) {
|
|
61
|
+
acc[key] = cleanedValue;
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
return Object.keys(cleanedObject).length > 0 ? cleanedObject : null;
|
|
66
|
+
}
|
|
67
|
+
export var selectRelevantData = function (data) {
|
|
68
|
+
var _a, _b, _c, _d, _e;
|
|
69
|
+
var _f = data || {}, protestosDeCredito = _f.protestos, chequesSemFundo = _f.ccf, dividasPublicas = _f.dividasPublicas, contasBancarias = _f.bankAccounts, dadosDeChequesSemFundo = _f.ccfData, dividas = _f.divida, _g = _f.dossie, dossie = _g === void 0 ? {} : _g, liminar = _f.liminar, socios = _f.partners, dadosPessoasExpostasPoliticamente = _f.pepData, detalhesProcessosJuridicos = _f.processosJuridicosData, dadosReclameAqui = _f.reclameAqui, relatoriosRefinBoaVista = _f.refinBoaVista, relatoriosRefinSerasa = _f.refinSerasa, dadosScore = _f.scoreData, relatoriosSCR = _f.scr, registrosDeVeiculos = _f.veiculos, ResumoDosDados = _f.documentHistory;
|
|
70
|
+
var sociosAnonimizados = (_a = socios === null || socios === void 0 ? void 0 : socios.partners) === null || _a === void 0 ? void 0 : _a.map(function (socio, index) { return ({
|
|
71
|
+
nome: "S\u00F3cio ".concat(index + 1),
|
|
72
|
+
cargo: socio.cargo,
|
|
73
|
+
receitaStatus: socio.receitaStatus || {},
|
|
74
|
+
dividasPublicas: socio.dividasPublicas || {},
|
|
75
|
+
protestos: socio.protestos || {}
|
|
76
|
+
}); });
|
|
77
|
+
var processosPassivos = (_c = (_b = detalhesProcessosJuridicos === null || detalhesProcessosJuridicos === void 0 ? void 0 : detalhesProcessosJuridicos.empresa) === null || _b === void 0 ? void 0 : _b.filter(function (processo) {
|
|
78
|
+
var _a;
|
|
79
|
+
return (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
80
|
+
var _a, _b, _c;
|
|
81
|
+
return ((_a = envolvido.nome_sem_filtro) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
|
|
82
|
+
((_c = (_b = dossie.carousel) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.toLowerCase()) &&
|
|
83
|
+
envolvido.envolvido_tipo === 'Passivo';
|
|
84
|
+
});
|
|
85
|
+
})) === null || _c === void 0 ? void 0 : _c.map(function (processo) { return ({
|
|
86
|
+
assuntos: processo.assuntos,
|
|
87
|
+
classe_processual: processo.classe_processual,
|
|
88
|
+
diario_sigla: processo.diario_sigla,
|
|
89
|
+
updated_at: processo.updated_at
|
|
90
|
+
}); });
|
|
91
|
+
var processosAtivo = (_e = (_d = detalhesProcessosJuridicos === null || detalhesProcessosJuridicos === void 0 ? void 0 : detalhesProcessosJuridicos.empresa) === null || _d === void 0 ? void 0 : _d.filter(function (processo) {
|
|
92
|
+
var _a;
|
|
93
|
+
return (_a = processo.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (envolvido) {
|
|
94
|
+
var _a, _b, _c;
|
|
95
|
+
return ((_a = envolvido.nome_sem_filtro) === null || _a === void 0 ? void 0 : _a.toLowerCase()) ===
|
|
96
|
+
((_c = (_b = dossie.carousel) === null || _b === void 0 ? void 0 : _b.name) === null || _c === void 0 ? void 0 : _c.toLowerCase()) &&
|
|
97
|
+
envolvido.envolvido_tipo === 'Ativo';
|
|
98
|
+
});
|
|
99
|
+
})) === null || _e === void 0 ? void 0 : _e.map(function (processo) { return ({
|
|
100
|
+
assuntos: processo.assuntos,
|
|
101
|
+
classe_processual: processo.classe_processual,
|
|
102
|
+
diario_sigla: processo.diario_sigla,
|
|
103
|
+
updated_at: processo.updated_at
|
|
104
|
+
}); });
|
|
105
|
+
var resumoDaEmpresa = dossie.summary;
|
|
106
|
+
var dadosOrganizados = {
|
|
107
|
+
protestosDeCredito: protestosDeCredito,
|
|
108
|
+
processosJuridicosPassivos: processosPassivos,
|
|
109
|
+
processosJuridicosAtivos: processosAtivo,
|
|
110
|
+
detalhesProcessosJuridicos: detalhesProcessosJuridicos,
|
|
111
|
+
chequesSemFundo: chequesSemFundo,
|
|
112
|
+
dividasPublicas: dividasPublicas,
|
|
113
|
+
contasBancarias: contasBancarias,
|
|
114
|
+
dadosDeChequesSemFundo: dadosDeChequesSemFundo,
|
|
115
|
+
dividas: dividas,
|
|
116
|
+
resumoDaEmpresa: resumoDaEmpresa,
|
|
117
|
+
liminar: liminar
|
|
118
|
+
? liminar.totalProtestos === 'NADA CONSTA'
|
|
119
|
+
? 'Liminar para esconder protestos'
|
|
120
|
+
: 'NÃO TEM LIMINAR'
|
|
121
|
+
: undefined,
|
|
122
|
+
socios: sociosAnonimizados,
|
|
123
|
+
dadosPessoasExpostasPoliticamente: dadosPessoasExpostasPoliticamente,
|
|
124
|
+
dadosReclameAqui: dadosReclameAqui,
|
|
125
|
+
relatoriosRefinBoaVista: relatoriosRefinBoaVista,
|
|
126
|
+
relatoriosRefinSerasa: relatoriosRefinSerasa,
|
|
127
|
+
dadosScore: dadosScore,
|
|
128
|
+
relatoriosSCR: relatoriosSCR,
|
|
129
|
+
registrosDeVeiculos: registrosDeVeiculos,
|
|
130
|
+
ResumoDosDados: ResumoDosDados
|
|
131
|
+
};
|
|
132
|
+
var dadosFiltrados = deepCleanData(dadosOrganizados);
|
|
133
|
+
return {
|
|
134
|
+
dadosFiltrados: dadosFiltrados
|
|
135
|
+
};
|
|
136
|
+
};
|
|
@@ -34,7 +34,7 @@ import ReactMarkdown from 'react-markdown';
|
|
|
34
34
|
import { flattenData, selectRelevantData } from './dataUtils';
|
|
35
35
|
import { createQueryAndMessages } from './queryUtils';
|
|
36
36
|
import { BetaTag, ChatInput, ChatInputContainer, Container, ContainerInput, Header, HeaderContent, InitialMessageBox, InitialMessageContent, LoadingDots, Message, MessageHistory, SendButton, Title } from './styles';
|
|
37
|
-
var
|
|
37
|
+
var GenerativeAI = function (_a) {
|
|
38
38
|
var _b, _c, _d;
|
|
39
39
|
var documento = _a.documento;
|
|
40
40
|
var globalData = useGlobalData().data;
|
|
@@ -130,7 +130,7 @@ var Llama = function (_a) {
|
|
|
130
130
|
if (globalData && documento) {
|
|
131
131
|
timeoutId = setTimeout(function () {
|
|
132
132
|
try {
|
|
133
|
-
var relevantData = selectRelevantData(globalData
|
|
133
|
+
var relevantData = selectRelevantData(globalData);
|
|
134
134
|
var serialized = flattenData(relevantData);
|
|
135
135
|
setSerializedData(serialized);
|
|
136
136
|
setQueryEnabled(true);
|
|
@@ -153,7 +153,9 @@ var Llama = function (_a) {
|
|
|
153
153
|
var query = createQueryAndMessages(serializedData, messageHistory);
|
|
154
154
|
return query;
|
|
155
155
|
}, [queryEnabled, serializedData, messageHistory]);
|
|
156
|
-
var _r = useStreamQuery(
|
|
156
|
+
var _r = useStreamQuery(
|
|
157
|
+
// Trocar endpoint na API
|
|
158
|
+
"SELECT FROM 'LlamaApi'.'Consulta'", queryData, !!queryData), response = _r.response, error = _r.error, isLoading = _r.isLoading, refetch = _r.refetch;
|
|
157
159
|
useEffect(function () {
|
|
158
160
|
abortControllerRef.current = new AbortController();
|
|
159
161
|
return function () {
|
|
@@ -268,4 +270,4 @@ var Llama = function (_a) {
|
|
|
268
270
|
React.createElement(StopButton, null))) : (React.createElement(SendButton, { onClick: handleSendMessage },
|
|
269
271
|
React.createElement(BtnSend, null)))))))));
|
|
270
272
|
};
|
|
271
|
-
export default
|
|
273
|
+
export default GenerativeAI;
|
|
@@ -11,17 +11,13 @@ import { stringify } from 'yaml';
|
|
|
11
11
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
12
12
|
export var createQueryAndMessages = function (relevantData, messageHistory, extraMessage) {
|
|
13
13
|
var baseMessages = __spreadArray([
|
|
14
|
-
{
|
|
15
|
-
role: 'system',
|
|
16
|
-
content: "\n Voc\u00EA \u00E9 NostraCredit, um assistente de an\u00E1lise de cr\u00E9dito do CreditHub, especializado em fornecer insights para decis\u00F5es de cr\u00E9dito no Brasil. Sua fun\u00E7\u00E3o \u00E9 analisar dossi\u00EAs de cr\u00E9dito e destacar informa\u00E7\u00F5es que possam influenciar negativamente a concess\u00E3o de cr\u00E9dito, como:\n\n - Protestos (atrasos em pagamentos).\n - Cheques sem fundo (CCF).\n - D\u00EDvidas p\u00FAblicas (impostos n\u00E3o pagos).\n - Liminares (que ocultam informa\u00E7\u00F5es de risco).\n - Processos judiciais (conflitos pendentes).\n\n Sua resposta deve incluir:\n 1. Uma an\u00E1lise clara dos principais fatores de risco, priorizando processos judiciais e protestos.\n 2. Sugest\u00F5es sobre taxas de juros e condi\u00E7\u00F5es de pagamento, conforme o risco identificado.\n 3. Recomenda\u00E7\u00E3o final resumida, incluindo uma taxa de juros com base no risco.\n\n **Mantenha suas respostas diretas, objetivas e formatadas em portugu\u00EAs simples, sem jarg\u00F5es t\u00E9cnicos, nomes de chaves do YAML ou men\u00E7\u00E3o a IDs ou identificadores de qualquer tipo (ex.: n\u00FAmeros de documentos ou chaves t\u00E9cnicas). Evite qualquer refer\u00EAncia a valores booleanos ou irrelevantes. Use descri\u00E7\u00F5es amig\u00E1veis e compreens\u00EDveis.**\n Caso informa\u00E7\u00F5es essenciais estejam faltando, fa\u00E7a perguntas para garantir uma an\u00E1lise completa. Responda como um especialista acess\u00EDvel, auxiliando na tomada de decis\u00E3o de cr\u00E9dito.\n "
|
|
17
|
-
},
|
|
18
14
|
{
|
|
19
15
|
role: 'user',
|
|
20
16
|
content: "\n Analisar o dossi\u00EA da seguinte empresa:\n```yaml\n".concat(stringify(JSON.parse(relevantData)), "\n```\n\n 1. Identifique os protestos, processos judiciais e outros problemas financeiros da empresa, e os descreva com termos claros, como \"valor financeiro\" ou \"pend\u00EAncia judicial\", sem mencionar nomes t\u00E9cnicos, IDs, chaves ou valores booleanos.\n 2. Descreva os processos judiciais e protestos em termos simples, utilizando frases como \"protesto registrado\" ou \"processo judicial ativo\", garantindo que a linguagem seja compreens\u00EDvel para um usu\u00E1rio comum.\n 3. Resuma os pontos cr\u00EDticos de forma objetiva, explicando como esses fatores podem impactar a decis\u00E3o de cr\u00E9dito. Enfatize o risco que eles representam para a empresa.\n 4. Responda com uma recomenda\u00E7\u00E3o final objetiva, propondo uma taxa de juros ou condi\u00E7\u00F5es espec\u00EDficas com base no risco identificado, como garantias adicionais ou prazos diferenciados.\n\n **Responda sempre em portugu\u00EAs claro e evite mencionar qualquer nome de campo do YAML, IDs ou n\u00FAmeros de documentos nas suas respostas. Certifique-se de eliminar qualquer dado n\u00E3o intelig\u00EDvel ou irrelevante, como valores booleanos.**\n\n ").concat(extraMessage || '', "\n ")
|
|
21
17
|
}
|
|
22
18
|
], messageHistory, true);
|
|
23
19
|
return {
|
|
24
|
-
model: '
|
|
20
|
+
model: 'deepseek-chat',
|
|
25
21
|
messages: JSON.stringify(baseMessages)
|
|
26
22
|
};
|
|
27
23
|
};
|