UNPKG

@anpdgovbr/shared-types

Version:

Biblioteca central de tipos TypeScript compartilhados para os projetos da ANPD (BETA)

28 lines (27 loc) 987 B
/** * Enumeração de status de eventos/processos de integração. */ export var StatusIntegracao; (function (StatusIntegracao) { StatusIntegracao["PENDING"] = "pending"; StatusIntegracao["OK"] = "ok"; StatusIntegracao["ERROR"] = "error"; StatusIntegracao["RETRY"] = "retry"; })(StatusIntegracao || (StatusIntegracao = {})); export const STATUS_INTEGRACAO_VALUES = [ StatusIntegracao.PENDING, StatusIntegracao.OK, StatusIntegracao.ERROR, StatusIntegracao.RETRY, ]; const STATUS_INTEGRACAO_SET = new Set(STATUS_INTEGRACAO_VALUES); export function isStatusIntegracao(value) { return typeof value === "string" && STATUS_INTEGRACAO_SET.has(value); } export function assertStatusIntegracao(value) { if (!isStatusIntegracao(value)) throw new Error(`StatusIntegracao inválido: ${String(value)}`); } export function coerceStatusIntegracao(value, fallback = StatusIntegracao.PENDING) { return isStatusIntegracao(value) ? value : fallback; }