@credithub/harlan-components 1.82.0 → 1.82.2
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/components/chart/chartSystem.js +12 -9
- package/dist/components/dossie/generativeAi/dataUtils.js +0 -2
- package/dist/components/liminar/liminar.js +5 -3
- package/dist/utils/isGlobalReady.d.ts +1 -0
- package/dist/utils/isGlobalReady.js +7 -0
- package/dist/utils/similarNames.d.ts +4 -0
- package/dist/utils/similarNames.js +72 -0
- package/lib/cjs/index.js +115 -34
- package/lib/esm/index.js +115 -34
- package/package.json +1 -1
|
@@ -53,10 +53,11 @@ import ResumoDeNegativacoesIcon from '../../assets/icones/resumoNegativacoes';
|
|
|
53
53
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
54
54
|
import { useConsultasComplementares } from '../../hooks/useConsultasComplementares';
|
|
55
55
|
import { converterParaFormatoValido } from '../../utils/date';
|
|
56
|
+
import { areModulesLoaded } from '../../utils/isGlobalReady';
|
|
56
57
|
import { formatMoney } from '../../utils/number';
|
|
57
58
|
import { isCpf } from '../../utils/string';
|
|
58
59
|
import { Spinner } from 'phosphor-react';
|
|
59
|
-
import React, { useContext, useEffect, useState } from 'react';
|
|
60
|
+
import React, { useContext, useEffect, useMemo, useState } from 'react';
|
|
60
61
|
import styled from 'styled-components';
|
|
61
62
|
import useToggle from '../../hooks/useToggle';
|
|
62
63
|
import { ConsultasComplementaresContext } from '../consultasComplementares';
|
|
@@ -90,12 +91,12 @@ var ChartSystem = function (_a) {
|
|
|
90
91
|
var documento = _a.documento;
|
|
91
92
|
var ctxConsultasComplementares = useContext(ConsultasComplementaresContext);
|
|
92
93
|
var _k = useConsultasComplementares(), consultasComplementares = _k.consultasComplementares, setConsultasComplementares = _k.setConsultasComplementares, hasCredits = _k.hasCredits;
|
|
93
|
-
var
|
|
94
|
-
var
|
|
94
|
+
var _l = useGlobalData(), globalData = _l.data, setGlobalState = _l.setData;
|
|
95
|
+
var _m = useState(false), dataUpdated = _m[0], setDataUpdated = _m[1];
|
|
95
96
|
var ultimaOcorrenciaCCF = useUltimaOcorrenciaCCF();
|
|
96
97
|
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;
|
|
97
98
|
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;
|
|
98
|
-
var
|
|
99
|
+
var _o = useState({}), loadingButtons = _o[0], setLoadingButtons = _o[1];
|
|
99
100
|
var productsPrices = getProductsPrices(isCpf(documento));
|
|
100
101
|
var handleOnClick = function (key) {
|
|
101
102
|
return function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -139,8 +140,8 @@ var ChartSystem = function (_a) {
|
|
|
139
140
|
});
|
|
140
141
|
}); };
|
|
141
142
|
};
|
|
142
|
-
var
|
|
143
|
-
var
|
|
143
|
+
var _p = useChartData(consultaSerasa, consultaBoaVista), chartData = _p.data, isLoadingChart = _p.isLoading, errorChart = _p.error, refetchChart = _p.refetch, chartDataProgress = _p.loadingProgress;
|
|
144
|
+
var _q = useDividasPublicas(), quantidadeDividas = _q.quantidade, valorTotalDividas = _q.valorTotal, ultimaOcorrenciaDividas = _q.ultimaOcorrencia, dividasProgress = _q.loadingProgress;
|
|
144
145
|
useEffect(function () {
|
|
145
146
|
if (consultaSerasa || consultaBoaVista) {
|
|
146
147
|
refetchChart();
|
|
@@ -150,8 +151,8 @@ var ChartSystem = function (_a) {
|
|
|
150
151
|
var isOpen = useToggle(true)[0];
|
|
151
152
|
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;
|
|
152
153
|
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;
|
|
153
|
-
var
|
|
154
|
-
var
|
|
154
|
+
var _r = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.serasa) || []), quantidadeSerasa = _r.quantidade, valorTotalSerasa = _r.valorTotal, ultimaOcorrenciaSerasa = _r.dataMaisRecente;
|
|
155
|
+
var _s = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.boaVista) || []), quantidadeBoaVista = _s.quantidade, valorTotalBoaVista = _s.valorTotal, ultimaOcorrenciaBoaVista = _s.dataMaisRecente;
|
|
155
156
|
var quantidadeCCFs = useCalculation((chartData === null || chartData === void 0 ? void 0 : chartData.ccfs) || []).quantidade;
|
|
156
157
|
var ultimaOcorrenciaProtestos = '';
|
|
157
158
|
if ((chartData === null || chartData === void 0 ? void 0 : chartData.protestosCategory) && chartData.protestosCategory.length > 0) {
|
|
@@ -173,9 +174,10 @@ var ChartSystem = function (_a) {
|
|
|
173
174
|
}
|
|
174
175
|
}
|
|
175
176
|
var loadingProgress = (chartDataProgress + dividasProgress) / 2;
|
|
177
|
+
var modulesReady = useMemo(function () { return areModulesLoaded(globalData); }, [globalData]);
|
|
176
178
|
useEffect(function () {
|
|
177
179
|
var _a, _b;
|
|
178
|
-
if (!dataUpdated && chartData) {
|
|
180
|
+
if (!dataUpdated && chartData && modulesReady) {
|
|
179
181
|
var protestoHistory_1 = (_b = (_a = chartData.protestos) === null || _a === void 0 ? void 0 : _a.map(function (p) {
|
|
180
182
|
var _a, _b;
|
|
181
183
|
return ({
|
|
@@ -217,6 +219,7 @@ var ChartSystem = function (_a) {
|
|
|
217
219
|
}
|
|
218
220
|
}, [
|
|
219
221
|
chartData,
|
|
222
|
+
modulesReady,
|
|
220
223
|
quantidadeDividas,
|
|
221
224
|
valorTotalDividas,
|
|
222
225
|
ultimaOcorrenciaDividas,
|
|
@@ -136,7 +136,6 @@ export var selectRelevantData = function (data) {
|
|
|
136
136
|
var processosAtivos = (_b = processar('Ativo')) !== null && _b !== void 0 ? _b : [];
|
|
137
137
|
var processosPassivos = (_c = processar('Passivo')) !== null && _c !== void 0 ? _c : [];
|
|
138
138
|
var ProcessosJuridicos = __spreadArray(__spreadArray([], processosAtivos, true), processosPassivos, true);
|
|
139
|
-
var quantidadeProcessosJuridicos = ProcessosJuridicos.length;
|
|
140
139
|
// ────────────────────────────────────────────────
|
|
141
140
|
// 3. Liminar
|
|
142
141
|
// ────────────────────────────────────────────────
|
|
@@ -173,7 +172,6 @@ export var selectRelevantData = function (data) {
|
|
|
173
172
|
dividasPublicas: dividasPublicas,
|
|
174
173
|
liminar: liminarInfo,
|
|
175
174
|
ProcessosJuridicos: ProcessosJuridicos,
|
|
176
|
-
quantidadeProcessosJuridicos: quantidadeProcessosJuridicos,
|
|
177
175
|
refinBoaVista: refinBoaVista !== null && refinBoaVista !== void 0 ? refinBoaVista : [],
|
|
178
176
|
refinSerasa: refinSerasa !== null && refinSerasa !== void 0 ? refinSerasa : [],
|
|
179
177
|
scr: scr,
|
|
@@ -50,7 +50,7 @@ import ProtestosIcon from '../../assets/icones/protestos';
|
|
|
50
50
|
import { useGlobalData } from '../../contexts/globalDataContext';
|
|
51
51
|
import theme from '../../styles/theme';
|
|
52
52
|
import { formatMoney } from '../../utils/number';
|
|
53
|
-
import { normalizeName,
|
|
53
|
+
import { normalizeName, normalizeNameStrong, similarCompanyNames } from '../../utils/similarNames';
|
|
54
54
|
import { hasOneOfTags } from '../../utils/tags';
|
|
55
55
|
import { WarningCircle } from 'phosphor-react';
|
|
56
56
|
import React, { useContext, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -120,14 +120,15 @@ var Liminar = function (_a) {
|
|
|
120
120
|
var _a, _b, _c, _d;
|
|
121
121
|
var carouselName = (_c = (_b = (_a = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _a === void 0 ? void 0 : _a.carousel) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : '';
|
|
122
122
|
var empresas = (_d = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _d === void 0 ? void 0 : _d.empresa;
|
|
123
|
-
var
|
|
123
|
+
var nomeNormTokens = normalizeNameStrong(carouselName);
|
|
124
|
+
console.log('nomeNormTokens', nomeNormTokens);
|
|
124
125
|
if (!Array.isArray(empresas))
|
|
125
126
|
return [];
|
|
126
127
|
return empresas.filter(function (proc) {
|
|
127
128
|
var _a;
|
|
128
129
|
var ativoMatch = (_a = proc.envolvidos_ultima_movimentacao) === null || _a === void 0 ? void 0 : _a.some(function (e) {
|
|
129
130
|
return e.envolvido_tipo === 'Ativo' &&
|
|
130
|
-
|
|
131
|
+
similarCompanyNames(e.nome_sem_filtro, carouselName);
|
|
131
132
|
});
|
|
132
133
|
if (!ativoMatch)
|
|
133
134
|
return false;
|
|
@@ -142,6 +143,7 @@ var Liminar = function (_a) {
|
|
|
142
143
|
(_d = globalData === null || globalData === void 0 ? void 0 : globalData.dossie) === null || _d === void 0 ? void 0 : _d.carousel,
|
|
143
144
|
(_e = globalData === null || globalData === void 0 ? void 0 : globalData.processosJuridicosData) === null || _e === void 0 ? void 0 : _e.empresa
|
|
144
145
|
]);
|
|
146
|
+
console.log('processosComAssuntoValido', processosComAssuntoValido);
|
|
145
147
|
/*
|
|
146
148
|
* Identifica as origens de liminares detectadas e verifica se existe liminar de protesto invertida
|
|
147
149
|
*/
|
|
@@ -7,3 +7,10 @@ export var isGlobalReady = function (g) {
|
|
|
7
7
|
((_d = g.ccfData) === null || _d === void 0 ? void 0 : _d.isLoaded) &&
|
|
8
8
|
((_e = g.divida) === null || _e === void 0 ? void 0 : _e.isLoaded);
|
|
9
9
|
};
|
|
10
|
+
export var areModulesLoaded = function (g) {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
return ((_a = g.processosJuridicosData) === null || _a === void 0 ? void 0 : _a.isLoaded) &&
|
|
13
|
+
((_b = g.protestosData) === null || _b === void 0 ? void 0 : _b.isLoaded) &&
|
|
14
|
+
((_c = g.ccfData) === null || _c === void 0 ? void 0 : _c.isLoaded) &&
|
|
15
|
+
((_d = g.divida) === null || _d === void 0 ? void 0 : _d.isLoaded);
|
|
16
|
+
};
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export declare const normalizeName: (name: string) => string;
|
|
2
2
|
export declare const similarNames: (name1: string, name2: string, threshold?: number) => boolean;
|
|
3
3
|
export declare const similarProcessos: (name1: string, name2: string) => boolean;
|
|
4
|
+
export declare const normalizeNameStrong: (name: string) => string[];
|
|
5
|
+
export declare const tokenCoverage: (a: string[], b: string[]) => number;
|
|
6
|
+
export declare const jaccard: (a: string[], b: string[]) => number;
|
|
7
|
+
export declare const similarCompanyNames: (raw1: string, raw2: string, jaccardThr?: number, coverThr?: number, charThr?: number) => boolean;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
+
if (ar || !(i in from)) {
|
|
4
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
+
ar[i] = from[i];
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
+
};
|
|
1
10
|
import { remove } from 'diacritics';
|
|
2
11
|
import stringSimilarity from 'string-similarity';
|
|
3
12
|
export var normalizeName = function (name) {
|
|
@@ -18,3 +27,66 @@ export var similarProcessos = function (name1, name2) {
|
|
|
18
27
|
var similarity = stringSimilarity.compareTwoStrings(name1, name2);
|
|
19
28
|
return similarity >= 0.8;
|
|
20
29
|
};
|
|
30
|
+
// palavras que quase nunca ajudam a distinguir empresas
|
|
31
|
+
var STOP_TOKENS = new Set([
|
|
32
|
+
'ltda',
|
|
33
|
+
'limitada',
|
|
34
|
+
'eireli',
|
|
35
|
+
'sa',
|
|
36
|
+
'me',
|
|
37
|
+
'ltda',
|
|
38
|
+
'empresa',
|
|
39
|
+
'sociedade',
|
|
40
|
+
'industrial',
|
|
41
|
+
'industria',
|
|
42
|
+
'industria',
|
|
43
|
+
'industries',
|
|
44
|
+
'comercio',
|
|
45
|
+
'comercial',
|
|
46
|
+
'comerc',
|
|
47
|
+
'servicos',
|
|
48
|
+
'serviço',
|
|
49
|
+
'produtos',
|
|
50
|
+
'de',
|
|
51
|
+
'da',
|
|
52
|
+
'do',
|
|
53
|
+
'dos',
|
|
54
|
+
'e'
|
|
55
|
+
]);
|
|
56
|
+
export var normalizeNameStrong = function (name) {
|
|
57
|
+
return remove(name) // tira acentos
|
|
58
|
+
.toLowerCase()
|
|
59
|
+
.replace(/[^\w\s]/g, ' ') // só letras/números
|
|
60
|
+
.split(/\s+/) // tokeniza
|
|
61
|
+
.filter(Boolean) // remove vazios
|
|
62
|
+
.filter(function (tok) { return !STOP_TOKENS.has(tok); }) // remove termos irrelevantes
|
|
63
|
+
.sort(); // deixa ordem irrelevante
|
|
64
|
+
};
|
|
65
|
+
// porcentagem do nome mais curto que aparece no mais longo
|
|
66
|
+
export var tokenCoverage = function (a, b) {
|
|
67
|
+
var _a = a.length < b.length ? [a, b] : [b, a], shorter = _a[0], longer = _a[1];
|
|
68
|
+
var inter = shorter.filter(function (t) { return longer.includes(t); }).length;
|
|
69
|
+
return shorter.length ? inter / shorter.length : 0;
|
|
70
|
+
};
|
|
71
|
+
export var jaccard = function (a, b) {
|
|
72
|
+
var setA = new Set(a);
|
|
73
|
+
var setB = new Set(b);
|
|
74
|
+
var inter = Array.from(setA).filter(function (x) { return setB.has(x); }).length;
|
|
75
|
+
var union = new Set(__spreadArray(__spreadArray([], a, true), b, true)).size;
|
|
76
|
+
return union ? inter / union : 0;
|
|
77
|
+
};
|
|
78
|
+
export var similarCompanyNames = function (raw1, raw2, jaccardThr, coverThr, charThr) {
|
|
79
|
+
if (jaccardThr === void 0) { jaccardThr = 0.7; }
|
|
80
|
+
if (coverThr === void 0) { coverThr = 0.8; }
|
|
81
|
+
if (charThr === void 0) { charThr = 0.85; }
|
|
82
|
+
var t1 = normalizeNameStrong(raw1);
|
|
83
|
+
var t2 = normalizeNameStrong(raw2);
|
|
84
|
+
// A) Jaccard sobre tokens “bons”
|
|
85
|
+
if (jaccard(t1, t2) >= jaccardThr)
|
|
86
|
+
return true;
|
|
87
|
+
// B) Cobertura total do nome mais curto
|
|
88
|
+
if (tokenCoverage(t1, t2) >= coverThr)
|
|
89
|
+
return true;
|
|
90
|
+
// C) Fallback de similaridade de caracteres
|
|
91
|
+
return (stringSimilarity.compareTwoStrings(t1.join(' '), t2.join(' ')) >= charThr);
|
|
92
|
+
};
|