@credithub/harlan-components 1.117.0 → 1.118.0

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.
@@ -20,3 +20,4 @@ export type { ScoreResponse, ScoreSerasaState, ScoreState } from '@/@types/domai
20
20
  export type { SCRState } from '@/@types/domain/scrTypes';
21
21
  export type { RegistroVeiculo, VeiculosState } from '@/@types/domain/veiculosTypes';
22
22
  export type { EditalItem, EditalEletronico, EditalResponse } from '@/@types/domain/editalTypes';
23
+ export type { PDFProtestoDiscoverResponse } from '@/@types/domain/pdfProtestoTypes';
@@ -66,7 +66,7 @@ var useLiminarProtestosDoPassado = function (_a) {
66
66
  var posthog = useContext(PostHogContext).posthog;
67
67
  var _c = useGlobalData(), globalData = _c.data, setData = _c.setData;
68
68
  var fetch = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
69
- var data, parsedData, _a, _b, numerosChave, protestosDoPassado, ocultos;
69
+ var data, parsedData, _a, _b, normalizedData, numerosChave, protestosDoPassado, ocultos;
70
70
  return __generator(this, function (_c) {
71
71
  switch (_c.label) {
72
72
  case 0: return [4 /*yield*/, client.request("SELECT FROM 'Protestos'.'History'", {
@@ -78,10 +78,14 @@ var useLiminarProtestosDoPassado = function (_a) {
78
78
  return [4 /*yield*/, Client.WebService.parse(data)];
79
79
  case 2:
80
80
  parsedData = _b.apply(_a, [(_c.sent())]).flat();
81
- numerosChave = parsedData
81
+ normalizedData = parsedData.map(function (item) {
82
+ var _a;
83
+ return (__assign(__assign({}, item), { cpfCnpj: (_a = item.cpfCnpj) !== null && _a !== void 0 ? _a : documento }));
84
+ });
85
+ numerosChave = normalizedData
82
86
  .filter(function (item) { return item.missingAt; })
83
87
  .map(function (item) { return item.chave; });
84
- protestosDoPassado = parsedData.filter(function (item) { return item.missingAt; });
88
+ protestosDoPassado = normalizedData.filter(function (item) { return item.missingAt; });
85
89
  ocultos = protestosDoPassado.map(function (item) { return item.chave; });
86
90
  setData(function (prev) { return (__assign(__assign({}, prev), { protestosPagosBaixados: {
87
91
  isLoaded: true,
@@ -1,4 +1,5 @@
1
- import type { Client } from '@credithub/webservice';
1
+ import { Client } from '@credithub/webservice';
2
+ import type { PDFProtestoDiscoverResponse } from '../../../@types/domain';
2
3
  export type InstrumentoSendmailResponse = {
3
4
  message?: string;
4
5
  _warning?: string;
@@ -14,3 +15,13 @@ export declare function sendInstrumentoDiscoveryEmail(client: Client.WebService,
14
15
  documento: string;
15
16
  nm_chave: string;
16
17
  }): Promise<InstrumentoSendmailResponse>;
18
+ /**
19
+ * Consulta exploratória do PDF do Instrumento de Protesto
20
+ * Verifica cache do bipbop antes de exibir o modal
21
+ * Busca keys com prefixo PDF no db bipbop e retorna PDF em base64 se disponível
22
+ */
23
+ export declare function discoverPDFProtesto(client: Client.WebService, payload: {
24
+ nm_chave: string;
25
+ livro?: string;
26
+ folha?: string;
27
+ }): Promise<PDFProtestoDiscoverResponse>;
@@ -1,3 +1,14 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
1
12
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
13
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
14
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,6 +46,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
46
  }
36
47
  };
37
48
  import { parseBpqlResponse } from '../../../utils/bpqlResponse';
49
+ import { Client } from '@credithub/webservice';
38
50
  export function sendInstrumentoManualEmail(client, payload) {
39
51
  return __awaiter(this, void 0, void 0, function () {
40
52
  var response, parsed;
@@ -83,3 +95,24 @@ export function sendInstrumentoDiscoveryEmail(client, payload) {
83
95
  });
84
96
  });
85
97
  }
98
+ /**
99
+ * Consulta exploratória do PDF do Instrumento de Protesto
100
+ * Verifica cache do bipbop antes de exibir o modal
101
+ * Busca keys com prefixo PDF no db bipbop e retorna PDF em base64 se disponível
102
+ */
103
+ export function discoverPDFProtesto(client, payload) {
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var response, parsed;
106
+ return __generator(this, function (_a) {
107
+ switch (_a.label) {
108
+ case 0: return [4 /*yield*/, client.request("SELECT FROM 'PDFPROTESTO'.'PDFDISCOVER'", __assign(__assign({ nm_chave: payload.nm_chave }, (payload.livro && { livro: payload.livro })), (payload.folha && { folha: payload.folha })))];
109
+ case 1:
110
+ response = _a.sent();
111
+ return [4 /*yield*/, Client.WebService.parse(response)];
112
+ case 2:
113
+ parsed = _a.sent();
114
+ return [2 /*return*/, parsed];
115
+ }
116
+ });
117
+ });
118
+ }
@@ -46,6 +46,7 @@ import { ResultContent } from '../interface/result';
46
46
  import { WebService } from '../webservice';
47
47
  import InstrumentoDiscoveryConfirmModal from './instrumento/InstrumentoDiscoveryConfirmModal';
48
48
  import InstrumentoEmailStatusModal from './instrumento/InstrumentoEmailStatusModal';
49
+ import { discoverPDFProtesto } from './instrumento/ieptbInstrumento';
49
50
  import { useInstrumento } from './instrumento/useInstrumento';
50
51
  // Throttling mechanism for API requests
51
52
  var activeRequests = 0;
@@ -253,6 +254,7 @@ export var Instrumento = function (_a) {
253
254
  var _c = useState(false), isLoading = _c[0], setIsLoading = _c[1];
254
255
  var _d = useState(false), isDiscoveryConfirmOpen = _d[0], setIsDiscoveryConfirmOpen = _d[1];
255
256
  var _e = useState(false), isMissingKeyLoading = _e[0], setIsMissingKeyLoading = _e[1];
257
+ var _f = useState(false), isCheckingCache = _f[0], setIsCheckingCache = _f[1];
256
258
  useEffect(function () {
257
259
  setErrorKind(deriveErrorKind());
258
260
  }, [deriveErrorKind]);
@@ -298,18 +300,67 @@ export var Instrumento = function (_a) {
298
300
  React.createElement("span", { title: tooltipMessage, style: { display: 'inline-block' } },
299
301
  React.createElement(Button, { isLoading: isLoading ||
300
302
  instrumentoHook.isProcessandoDescoberta ||
301
- isMissingKeyLoading, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
303
+ isMissingKeyLoading ||
304
+ isCheckingCache, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
305
+ var pdfData, pdfBase64, byteCharacters, byteNumbers, i, byteArray, blob, url, link, error_1;
302
306
  return __generator(this, function (_a) {
303
- if (isDisabled)
304
- return [2 /*return*/];
305
- // Fluxo SP: abre modal para Livro/Folha
306
- if (isSP) {
307
- instrumentoHook.openModalSP();
308
- return [2 /*return*/];
307
+ switch (_a.label) {
308
+ case 0:
309
+ if (isDisabled)
310
+ return [2 /*return*/];
311
+ if (!(normalizedKey && cpfCnpj)) return [3 /*break*/, 5];
312
+ setIsCheckingCache(true);
313
+ setIsLoading(true);
314
+ _a.label = 1;
315
+ case 1:
316
+ _a.trys.push([1, 3, 4, 5]);
317
+ return [4 /*yield*/, discoverPDFProtesto(client, {
318
+ nm_chave: normalizedKey
319
+ })];
320
+ case 2:
321
+ pdfData = _a.sent();
322
+ // Se PDF estiver disponível no cache, fazer download
323
+ if (pdfData === null || pdfData === void 0 ? void 0 : pdfData.instrumentoProtesto) {
324
+ pdfBase64 = pdfData.instrumentoProtesto;
325
+ byteCharacters = atob(pdfBase64);
326
+ byteNumbers = new Array(byteCharacters.length);
327
+ for (i = 0; i < byteCharacters.length; i++) {
328
+ byteNumbers[i] = byteCharacters.charCodeAt(i);
329
+ }
330
+ byteArray = new Uint8Array(byteNumbers);
331
+ blob = new Blob([byteArray], { type: 'application/pdf' });
332
+ url = URL.createObjectURL(blob);
333
+ link = document.createElement('a');
334
+ link.href = url;
335
+ link.download = "instrumento-protesto-".concat(normalizedKey, ".pdf");
336
+ document.body.appendChild(link);
337
+ link.click();
338
+ document.body.removeChild(link);
339
+ URL.revokeObjectURL(url);
340
+ setIsLoading(false);
341
+ setIsCheckingCache(false);
342
+ return [2 /*return*/];
343
+ }
344
+ return [3 /*break*/, 5];
345
+ case 3:
346
+ error_1 = _a.sent();
347
+ // Em caso de erro na consulta exploratória, seguir fluxo normal
348
+ console.warn('Erro ao verificar cache do PDF:', error_1);
349
+ return [3 /*break*/, 5];
350
+ case 4:
351
+ setIsLoading(false);
352
+ setIsCheckingCache(false);
353
+ return [7 /*endfinally*/];
354
+ case 5:
355
+ // Fluxo SP: abre modal para Livro/Folha
356
+ if (isSP) {
357
+ instrumentoHook.openModalSP();
358
+ return [2 /*return*/];
359
+ }
360
+ // Fluxo não-SP: IEPTB.PDF foi depreciado. Vai direto para solicitação.
361
+ setIsDiscoveryConfirmOpen(true);
362
+ return [2 /*return*/];
309
363
  }
310
- // Fluxo não-SP: IEPTB.PDF foi depreciado. Vai direto para solicitação.
311
- setIsDiscoveryConfirmOpen(true);
312
- return [2 /*return*/];
313
364
  });
314
365
  }); }, disabled: isDisabled }, getButtonLabel())),
315
366
  React.createElement(ModalInstrumentoProtestoSP, { isOpen: instrumentoHook.isModalSPOpen, onClose: instrumentoHook.closeModalSP, onEnviarEmail: instrumentoHook.handleEnviarEmail, isEnviandoEmail: instrumentoHook.isEnviandoEmail }),
@@ -1,4 +1,4 @@
1
- import { EditalResponse, LiminarResponse, ProcessosJuridicosState } from '../@types/domain';
1
+ import { EditalResponse, LiminarResponse, PDFProtestoDiscoverResponse, ProcessosJuridicosState } from '../@types/domain';
2
2
  import { Client } from '@credithub/webservice';
3
3
  import React, { ComponentProps, ComponentType, Context, FC, PropsWithChildren, ReactNode } from 'react';
4
4
  import Header from './interface/header';
@@ -176,5 +176,21 @@ export declare const Queries: {
176
176
  urlData?: Client.Form;
177
177
  }>>;
178
178
  };
179
+ /**
180
+ * Consulta exploratória do PDF do Instrumento de Protesto
181
+ * Verifica cache do bipbop antes de exibir o modal
182
+ * Busca keys com prefixo PDF no db bipbop e retorna PDF em base64 se disponível
183
+ */
184
+ PDFProtestoDiscover: React.Context<RequestContext<PDFProtestoDiscoverResponse>> & {
185
+ Request: React.FC<React.PropsWithChildren<{
186
+ data?: {
187
+ nm_chave: string;
188
+ livro?: string;
189
+ folha?: string;
190
+ } | undefined;
191
+ depends?: RequestContext<unknown>[];
192
+ urlData?: Client.Form;
193
+ }>>;
194
+ };
179
195
  };
180
196
  export {};
@@ -512,5 +512,11 @@ export var Queries = {
512
512
  // Falencia: query<{ documento: string }, Document>(
513
513
  // "SELECT FROM 'ValorEconomico'.'Falencia'"
514
514
  // ),
515
- Edital: query("SELECT FROM 'APICENPROT'.'EDITAL'")
515
+ Edital: query("SELECT FROM 'APICENPROT'.'EDITAL'"),
516
+ /**
517
+ * Consulta exploratória do PDF do Instrumento de Protesto
518
+ * Verifica cache do bipbop antes de exibir o modal
519
+ * Busca keys com prefixo PDF no db bipbop e retorna PDF em base64 se disponível
520
+ */
521
+ PDFProtestoDiscover: query("SELECT FROM 'PDFPROTESTO'.'PDFDISCOVER'")
516
522
  };