This commit is contained in:
Luiz Silva 2026-06-19 16:48:18 -03:00
parent e884cdd3d8
commit 9f8aa2299a
7 changed files with 97 additions and 42 deletions

View file

@ -34,6 +34,13 @@ type tipoPrErroInterno = {
local: string;
__filename?: string;
};
/**
* Tipo do callback opcional de interceptação de respostas.
*
* Quando fornecido, é invocado após a construção de toda resposta,
* permitindo side-effects (ex.: logging, telemetria) sem alterar o tipo.
*/
type tipoCallbackResposta = <X>(resposta: tipoResposta<X>) => tipoResposta<X>;
/**
* Cria um conjunto de geradores de respostas.
*
@ -49,14 +56,16 @@ interface InterfaceRespostas {
tempoEsgotado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
erroEspera: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
}
declare const gerarRespostas: (
/** Faz um processamento quando erro interno
* Recebe o erro gerado, mensagem personalizada e detalhes
*/
registrarErroInterno: (op: tipoPrErroInterno) => Partial<tipoRespostaErro>) => InterfaceRespostas;
declare const IniciarRespostas: (
/** Callback opcional de interceptação — invocado após a construção de cada resposta */
callback?: tipoCallbackResposta) => InterfaceRespostas;
/**
* Instância default (sem handler de erro interno).
* @deprecated Use IniciarRespostas em seu lugar
*/
declare const gerarRespostas: (callback?: tipoCallbackResposta) => InterfaceRespostas;
/**
* Instância default (sem handler de interceptação).
*/
declare const respostaComuns: InterfaceRespostas;
export { type InterfaceRespostas, codigosResposta, gerarRespostas, respostaComuns, type tipoPrErroInterno, type tipoResposta, type tipoRespostaErro, type tipoRespostaSucesso };
export { IniciarRespostas, type InterfaceRespostas, codigosResposta, gerarRespostas, respostaComuns, type tipoCallbackResposta, type tipoPrErroInterno, type tipoResposta, type tipoRespostaErro, type tipoRespostaSucesso };