36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
export declare const codigosErros: {
|
|
400: string;
|
|
403: string;
|
|
500: string;
|
|
504: string;
|
|
};
|
|
export interface tipoRespostaSucesso<T> {
|
|
codigo: 200;
|
|
eErro: false;
|
|
valor: T;
|
|
erro: undefined;
|
|
detalhes?: any[];
|
|
}
|
|
export interface tipoRespostaErro {
|
|
codigo: keyof typeof codigosErros;
|
|
eErro: true;
|
|
erro: string;
|
|
valor: undefined;
|
|
detalhes?: any[];
|
|
}
|
|
export type tipoResposta<T> = tipoRespostaSucesso<T> | tipoRespostaErro;
|
|
export declare class Resposta<opcoesErroInterno extends any[]> {
|
|
funcaoErroInterno: (...opcoes: opcoesErroInterno) => void | Promise<void>;
|
|
detalhesErroInterno: boolean;
|
|
constructor(funcaoErroInterno: (...arg1: opcoesErroInterno) => void | Promise<void>, opcoes?: {
|
|
detalhesErroInterno?: boolean;
|
|
});
|
|
addResultado<T>(resultado: T): tipoResposta<T>;
|
|
addSucesso(resultado: string): tipoResposta<string>;
|
|
addTrue(): tipoResposta<true>;
|
|
addErro(erro: string, codigo?: keyof typeof codigosErros): tipoRespostaErro;
|
|
addErroEspera(erro?: string): tipoRespostaErro;
|
|
addErroInterno(...opcoes: opcoesErroInterno): tipoRespostaErro;
|
|
addPromise<T>(promise: () => Promise<T> | T, limiteEspera?: number): Promise<tipoResposta<T>>;
|
|
}
|
|
export declare const respostaCM: Resposta<[]>;
|