build
This commit is contained in:
parent
214c18fae0
commit
9aa36bcba9
7 changed files with 271 additions and 303 deletions
|
|
@ -39,80 +39,24 @@ type tipoPrErroInterno = {
|
|||
*
|
||||
* @param registrarErroInterno callback para registrar/normalizar erros internos.
|
||||
*/
|
||||
interface InterfaceRespostas {
|
||||
valor: <T>(valor: T, detalhes?: string[]) => tipoRespostaSucesso<T>;
|
||||
valorTrue: (detalhes?: string[]) => tipoRespostaSucesso<true>;
|
||||
erro: (mensagem: string, detalhes?: string[]) => tipoRespostaErro;
|
||||
erroPermissao: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
erroInterno: (op: tipoPrErroInterno) => tipoRespostaErro;
|
||||
naoEncontrado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
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>) => {
|
||||
/**
|
||||
* Gera uma resposta de sucesso
|
||||
*/
|
||||
valor: <T>(valor: T, detalhes?: string[]) => tipoRespostaSucesso<T>;
|
||||
/**
|
||||
* Gera uma resposta de sucesso com valor true
|
||||
*/
|
||||
valorTrue: (detalhes?: string[]) => tipoRespostaSucesso<true>;
|
||||
/**
|
||||
* Gera uma resposta de erro conhecido
|
||||
*/
|
||||
erro: (mensagem: string, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro de permissão,será necessário fazer o login novamente
|
||||
*/
|
||||
erroPermissao: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro desconhecido, geralmente tem origem de um exception
|
||||
*/
|
||||
erroInterno: (op: tipoPrErroInterno) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando um registro não é encontrado ou sua execução depende de um registro existente
|
||||
*/
|
||||
naoEncontrado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando o tempo de resposta é esgotado
|
||||
*/
|
||||
tempoEsgotado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando o tempo de resposta é esgotado
|
||||
*/
|
||||
erroEspera: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
};
|
||||
registrarErroInterno: (op: tipoPrErroInterno) => Partial<tipoRespostaErro>) => InterfaceRespostas;
|
||||
/**
|
||||
* Instância default (sem handler de erro interno).
|
||||
*/
|
||||
declare const respostaComuns: {
|
||||
/**
|
||||
* Gera uma resposta de sucesso
|
||||
*/
|
||||
valor: <T>(valor: T, detalhes?: string[]) => tipoRespostaSucesso<T>;
|
||||
/**
|
||||
* Gera uma resposta de sucesso com valor true
|
||||
*/
|
||||
valorTrue: (detalhes?: string[]) => tipoRespostaSucesso<true>;
|
||||
/**
|
||||
* Gera uma resposta de erro conhecido
|
||||
*/
|
||||
erro: (mensagem: string, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro de permissão,será necessário fazer o login novamente
|
||||
*/
|
||||
erroPermissao: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro desconhecido, geralmente tem origem de um exception
|
||||
*/
|
||||
erroInterno: (op: tipoPrErroInterno) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando um registro não é encontrado ou sua execução depende de um registro existente
|
||||
*/
|
||||
naoEncontrado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando o tempo de resposta é esgotado
|
||||
*/
|
||||
tempoEsgotado: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
/**
|
||||
* Gera uma resposta de erro quando o tempo de resposta é esgotado
|
||||
*/
|
||||
erroEspera: (mensagem?: string | undefined | null, detalhes?: string[]) => tipoRespostaErro;
|
||||
};
|
||||
declare const respostaComuns: InterfaceRespostas;
|
||||
|
||||
export { codigosResposta, gerarRespostas, respostaComuns, type tipoPrErroInterno, type tipoResposta, type tipoRespostaErro, type tipoRespostaSucesso };
|
||||
export { type InterfaceRespostas, codigosResposta, gerarRespostas, respostaComuns, type tipoPrErroInterno, type tipoResposta, type tipoRespostaErro, type tipoRespostaSucesso };
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
var u=(e=>(e[e.sucesso=200]="sucesso",e[e.erroConhecido=400]="erroConhecido",e[e.erroPermissao=401]="erroPermissao",e[e.erroNaoEncontrado=404]="erroNaoEncontrado",e[e.erroDesconhecido=500]="erroDesconhecido",e[e.tempoEsgotado=504]="tempoEsgotado",e))(u||{}),c=t=>{let n=(o,r)=>({cod:200,valor:o,mensagem:void 0,eErro:!1,eCerto:!0,detalhes:r}),a=o=>({cod:200,valor:!0,mensagem:void 0,eErro:!1,eCerto:!0,detalhes:o}),i=(o,r)=>({cod:400,valor:void 0,mensagem:o,eErro:!0,eCerto:!1,detalhes:r}),d=(o,r)=>({cod:401,valor:void 0,mensagem:o||"Sem permiss\xE3o para esse recurso.",eErro:!0,eCerto:!1,detalhes:r}),p=(o,r)=>({cod:404,valor:void 0,mensagem:o||"Registro n\xE3o encontrado ou a execu\xE7\xE3o dessa a\xE7\xE3o depende de um registro existente.",eErro:!0,eCerto:!1,detalhes:r}),e=o=>{let r=t(o);return{cod:500,valor:void 0,mensagem:`${o.mensagem||"Erro interno"}`,eErro:!0,eCerto:!1,...r}},s=(o,r)=>({cod:504,valor:void 0,mensagem:o||"Tempo de resposta esgotado ao tentar acessar o recurso.",eErro:!0,eCerto:!1,detalhes:r});return{valor:n,valorTrue:a,erro:i,erroPermissao:d,erroInterno:e,naoEncontrado:p,tempoEsgotado:s,erroEspera:s}},l=c(()=>({}));export{u as codigosResposta,c as gerarRespostas,l as respostaComuns};
|
||||
var u=(e=>(e[e.sucesso=200]="sucesso",e[e.erroConhecido=400]="erroConhecido",e[e.erroPermissao=401]="erroPermissao",e[e.erroNaoEncontrado=404]="erroNaoEncontrado",e[e.erroDesconhecido=500]="erroDesconhecido",e[e.tempoEsgotado=504]="tempoEsgotado",e))(u||{}),g=t=>{let n=(o,r)=>({cod:200,valor:o,mensagem:void 0,eErro:!1,eCerto:!0,detalhes:r}),a=o=>({cod:200,valor:!0,mensagem:void 0,eErro:!1,eCerto:!0,detalhes:o}),i=(o,r)=>({cod:400,valor:void 0,mensagem:o,eErro:!0,eCerto:!1,detalhes:r}),p=(o,r)=>({cod:401,valor:void 0,mensagem:o||"Sem permiss\xE3o para esse recurso.",eErro:!0,eCerto:!1,detalhes:r}),d=(o,r)=>({cod:404,valor:void 0,mensagem:o||"Registro n\xE3o encontrado ou a execu\xE7\xE3o dessa a\xE7\xE3o depende de um registro existente.",eErro:!0,eCerto:!1,detalhes:r}),e=o=>{let r=t(o);return{cod:500,valor:void 0,mensagem:`${o.mensagem||"Erro interno"}`,eErro:!0,eCerto:!1,...r}},s=(o,r)=>({cod:504,valor:void 0,mensagem:o||"Tempo de resposta esgotado ao tentar acessar o recurso.",eErro:!0,eCerto:!1,detalhes:r});return{valor:n,valorTrue:a,erro:i,erroPermissao:p,erroInterno:e,naoEncontrado:d,tempoEsgotado:s,erroEspera:s}},l=g(()=>({}));export{u as codigosResposta,g as gerarRespostas,l as respostaComuns};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue