build
This commit is contained in:
parent
30a28b7ecc
commit
ac08b31b3d
13 changed files with 1 additions and 2230 deletions
600
dist/index.cjs
vendored
600
dist/index.cjs
vendored
|
|
@ -1,600 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
const z = require('zod');
|
|
||||||
const dayjs = require('dayjs');
|
|
||||||
const duration = require('dayjs/plugin/duration.js');
|
|
||||||
const isSameOrAfter = require('dayjs/plugin/isSameOrAfter.js');
|
|
||||||
const isSameOrBefore = require('dayjs/plugin/isSameOrBefore.js');
|
|
||||||
const minMax = require('dayjs/plugin/minMax.js');
|
|
||||||
const relativeTime = require('dayjs/plugin/relativeTime.js');
|
|
||||||
const timezone = require('dayjs/plugin/timezone.js');
|
|
||||||
const utc = require('dayjs/plugin/utc.js');
|
|
||||||
const weekOfYear = require('dayjs/plugin/weekOfYear.js');
|
|
||||||
require('dayjs/locale/pt-br.js');
|
|
||||||
const crossFetch = require('cross-fetch');
|
|
||||||
const uuid$1 = require('uuid');
|
|
||||||
|
|
||||||
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
||||||
|
|
||||||
const z__default = /*#__PURE__*/_interopDefaultCompat(z);
|
|
||||||
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
||||||
const duration__default = /*#__PURE__*/_interopDefaultCompat(duration);
|
|
||||||
const isSameOrAfter__default = /*#__PURE__*/_interopDefaultCompat(isSameOrAfter);
|
|
||||||
const isSameOrBefore__default = /*#__PURE__*/_interopDefaultCompat(isSameOrBefore);
|
|
||||||
const minMax__default = /*#__PURE__*/_interopDefaultCompat(minMax);
|
|
||||||
const relativeTime__default = /*#__PURE__*/_interopDefaultCompat(relativeTime);
|
|
||||||
const timezone__default = /*#__PURE__*/_interopDefaultCompat(timezone);
|
|
||||||
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
|
||||||
const weekOfYear__default = /*#__PURE__*/_interopDefaultCompat(weekOfYear);
|
|
||||||
const crossFetch__default = /*#__PURE__*/_interopDefaultCompat(crossFetch);
|
|
||||||
|
|
||||||
const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
||||||
const aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 }).map(() => alfabeto[(999 * Math.random() | 0) % alfabeto.length]).join("")}`;
|
|
||||||
|
|
||||||
const _cache = {};
|
|
||||||
globalThis.cacheMemoria_cache = _cache;
|
|
||||||
const cacheM = (chave, valor, validadeSeg) => {
|
|
||||||
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
|
|
||||||
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
|
|
||||||
if (valor !== void 0) {
|
|
||||||
_cache[txChave] = {
|
|
||||||
valor,
|
|
||||||
validade
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const busca = _cache[txChave];
|
|
||||||
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
|
|
||||||
return void 0;
|
|
||||||
}
|
|
||||||
return busca?.valor;
|
|
||||||
};
|
|
||||||
const verCacheM = () => _cache;
|
|
||||||
const cacheMemoria = cacheM;
|
|
||||||
const cacheMFixo = (chave) => (valor) => cacheM(chave, valor);
|
|
||||||
|
|
||||||
const uuid_null = "00000000-0000-0000-0000-000000000000";
|
|
||||||
var camposComuns = /* @__PURE__ */ ((camposComuns2) => {
|
|
||||||
camposComuns2["codigo"] = "codigo";
|
|
||||||
camposComuns2["excluido"] = "excluido";
|
|
||||||
camposComuns2["data_hora_criacao"] = "data_hora_criacao";
|
|
||||||
camposComuns2["data_hora_atualizacao"] = "data_hora_atualizacao";
|
|
||||||
camposComuns2["codigo_usuario_criacao"] = "codigo_usuario_criacao";
|
|
||||||
camposComuns2["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao";
|
|
||||||
camposComuns2["versao"] = "versao";
|
|
||||||
return camposComuns2;
|
|
||||||
})(camposComuns || {});
|
|
||||||
var tx = /* @__PURE__ */ ((tx2) => {
|
|
||||||
tx2["token"] = "token";
|
|
||||||
return tx2;
|
|
||||||
})(tx || {});
|
|
||||||
var tipoUsuarioResiduos = /* @__PURE__ */ ((tipoUsuarioResiduos2) => {
|
|
||||||
tipoUsuarioResiduos2["Usuario"] = "usuario";
|
|
||||||
tipoUsuarioResiduos2["Fornecedor"] = "fornecedor";
|
|
||||||
return tipoUsuarioResiduos2;
|
|
||||||
})(tipoUsuarioResiduos || {});
|
|
||||||
|
|
||||||
var operadores = /* @__PURE__ */ ((operadores2) => {
|
|
||||||
operadores2["="] = "=";
|
|
||||||
operadores2["!="] = "!=";
|
|
||||||
operadores2[">"] = ">";
|
|
||||||
operadores2[">="] = ">=";
|
|
||||||
operadores2["<"] = "<";
|
|
||||||
operadores2["<="] = "<=";
|
|
||||||
operadores2["like"] = "like";
|
|
||||||
operadores2["in"] = "in";
|
|
||||||
return operadores2;
|
|
||||||
})(operadores || {});
|
|
||||||
const zOperadores = z__default.enum([
|
|
||||||
"=",
|
|
||||||
"!=",
|
|
||||||
">",
|
|
||||||
">=",
|
|
||||||
"<",
|
|
||||||
"<=",
|
|
||||||
"like",
|
|
||||||
"in"
|
|
||||||
]);
|
|
||||||
const zFiltro = z__default.object({
|
|
||||||
coluna: z__default.string(),
|
|
||||||
valor: z__default.any(),
|
|
||||||
operador: zOperadores,
|
|
||||||
ou: z__default.boolean().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
dayjs__default.locale("pt-br");
|
|
||||||
dayjs__default.extend(utc__default);
|
|
||||||
dayjs__default.extend(timezone__default);
|
|
||||||
dayjs__default.extend(weekOfYear__default);
|
|
||||||
dayjs__default.extend(isSameOrBefore__default);
|
|
||||||
dayjs__default.extend(isSameOrAfter__default);
|
|
||||||
dayjs__default.extend(minMax__default);
|
|
||||||
dayjs__default.extend(relativeTime__default);
|
|
||||||
dayjs__default.extend(duration__default);
|
|
||||||
const dayjsbr = dayjs__default;
|
|
||||||
|
|
||||||
const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
|
||||||
|
|
||||||
const extensoes = [
|
|
||||||
{
|
|
||||||
ext: "gif",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "jpg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/jpeg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "jpeg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/jpeg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "png",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "bmp",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/bmp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "webp",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/webp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "tiff",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/tiff"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "svg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/svg+xml"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ico",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/x-icon"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "pdf",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/pdf"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "doc",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/msword"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "docx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "xls",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.ms-excel"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "xlsx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ppt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.ms-powerpoint"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "pptx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "txt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "text/plain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "odt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.oasis.opendocument.text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ods",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.oasis.opendocument.spreadsheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "rtf",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/rtf"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "csv",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "text/csv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mp4",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/mp4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "avi",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-msvideo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mkv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-matroska"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mov",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/quicktime"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "wmv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-ms-wmv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "flv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-flv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "webm",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/webm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "3gp",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/3gpp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mpeg",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/mpeg"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const tipoArquivo = (nomeArquivo) => {
|
|
||||||
const extArquivo = String(nomeArquivo || "").toLocaleLowerCase().split(".").pop();
|
|
||||||
const extensao = extensoes.find((extensao2) => extensao2.ext === extArquivo);
|
|
||||||
return extensao?.tipo || "outros";
|
|
||||||
};
|
|
||||||
|
|
||||||
const graficos_pilao = {
|
|
||||||
Condicionantes: {
|
|
||||||
grafico: "condicionantes-criadas",
|
|
||||||
titulo: "Condicionantes Criadas"
|
|
||||||
},
|
|
||||||
Licen\u00E7as: {
|
|
||||||
grafico: "licencas-criadas",
|
|
||||||
titulo: "Licen\xE7as Criadas"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const localValor = (chave_, valor) => {
|
|
||||||
const localStorage = globalThis.localStorage;
|
|
||||||
if (typeof localStorage == "undefined") return null;
|
|
||||||
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
|
||||||
try {
|
|
||||||
if (valor !== void 0) {
|
|
||||||
localStorage.setItem(chave, JSON.stringify(valor));
|
|
||||||
}
|
|
||||||
const v2 = localStorage.getItem(chave);
|
|
||||||
if (v2 === null) return null;
|
|
||||||
try {
|
|
||||||
return JSON.parse(v2);
|
|
||||||
} catch {
|
|
||||||
return v2;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const esperar = (ms) => new Promise(
|
|
||||||
(resolve) => setTimeout(() => resolve(true), ms)
|
|
||||||
);
|
|
||||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
|
||||||
|
|
||||||
const LOKI_BASE_URL = "https://log.idz.one";
|
|
||||||
const LOKI_ENDPOINT = "/loki/api/v1/push";
|
|
||||||
const postLogger = async ({
|
|
||||||
objeto
|
|
||||||
}) => {
|
|
||||||
const response = await crossFetch__default(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(objeto)
|
|
||||||
}).catch((a) => a);
|
|
||||||
if (!response.ok) {
|
|
||||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
|
||||||
}
|
|
||||||
return [objeto];
|
|
||||||
};
|
|
||||||
let cwd = "";
|
|
||||||
const defineCwd = (novoCwd) => {
|
|
||||||
cwd = novoCwd;
|
|
||||||
};
|
|
||||||
const logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => {
|
|
||||||
let {
|
|
||||||
__filename,
|
|
||||||
detalhes,
|
|
||||||
local,
|
|
||||||
parametros: parametrosLog
|
|
||||||
} = op_tipoLog || {};
|
|
||||||
const app = `${eProducao ? "" : "DEV-"}${app_e}`;
|
|
||||||
if (cwd && __filename) {
|
|
||||||
__filename = __filename.replace(cwd, "");
|
|
||||||
}
|
|
||||||
if (local) {
|
|
||||||
detalhes = [`${nomeVariavel({ local })}="${local}"`, ...detalhes || []];
|
|
||||||
}
|
|
||||||
if (__filename) {
|
|
||||||
detalhes = [
|
|
||||||
`${nomeVariavel({ __filename })}="${__filename}"`,
|
|
||||||
...detalhes || []
|
|
||||||
];
|
|
||||||
}
|
|
||||||
const timestamp = `${Date.now()}000000`;
|
|
||||||
const mainLog = detalhes?.length ? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}` : mensagem;
|
|
||||||
const payload = {
|
|
||||||
stream: {
|
|
||||||
app,
|
|
||||||
inquilino,
|
|
||||||
usuario,
|
|
||||||
level,
|
|
||||||
...parametrosAmbiente || {},
|
|
||||||
...parametrosSessao || {},
|
|
||||||
...parametrosLog || {}
|
|
||||||
},
|
|
||||||
values: [
|
|
||||||
[
|
|
||||||
timestamp,
|
|
||||||
mainLog
|
|
||||||
// Linha de log direta
|
|
||||||
]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
const objeto = { streams: [payload] };
|
|
||||||
const response = await postLogger({ objeto });
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
|
|
||||||
const paraObjetoRegistroPg = (entrada) => {
|
|
||||||
try {
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(entrada).map(([k, v]) => [
|
|
||||||
k,
|
|
||||||
v === void 0 || v == null ? v : typeof v == "string" || typeof v == "number" || typeof v == "boolean" ? v : JSON.stringify(v, null, 2)
|
|
||||||
])
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(
|
|
||||||
`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${error.message} ${error.stack}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const pgObjeto = paraObjetoRegistroPg;
|
|
||||||
const objetoPg = paraObjetoRegistroPg;
|
|
||||||
|
|
||||||
const umaFuncao = () => "Ol\xE1 Mundo! (fun\xE7\xE3o)";
|
|
||||||
|
|
||||||
const umaVariavel = "Ol\xE1 Mundo! (vari\xE1vel)";
|
|
||||||
|
|
||||||
const texto_busca = (...texto) => texto.map(
|
|
||||||
(txt) => txt === null || txt === void 0 ? "" : String(txt).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, " ").toLowerCase()
|
|
||||||
).join(" ");
|
|
||||||
|
|
||||||
class TipagemRotas {
|
|
||||||
_partesCaminho = [];
|
|
||||||
_acaoIr;
|
|
||||||
rotulo;
|
|
||||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
|
||||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
|
||||||
*/
|
|
||||||
constructor({
|
|
||||||
caminho,
|
|
||||||
acaoIr,
|
|
||||||
rotulo
|
|
||||||
}) {
|
|
||||||
this._acaoIr = acaoIr;
|
|
||||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho]).filter(Boolean).map((a) => String(a)).flatMap((a) => a.split("/")).filter(Boolean);
|
|
||||||
this.rotulo = rotulo;
|
|
||||||
}
|
|
||||||
/** Retorna o caminho completo da rota
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/caminho"
|
|
||||||
*/
|
|
||||||
get caminho() {
|
|
||||||
const ret = `/${this._partesCaminho.join("/")}`;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/** Define o caminho completo da rota
|
|
||||||
** mCaminho.caminho = "/novoCaminho"
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/novoCaminho"
|
|
||||||
** */
|
|
||||||
set caminho(caminhoParcial) {
|
|
||||||
this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte);
|
|
||||||
}
|
|
||||||
/** Retorna o caminho completo da rota com a query
|
|
||||||
** console.log(mCaminho.resolve({q:"query"}))
|
|
||||||
** "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
endereco(query, usarComoHash) {
|
|
||||||
const url = new URL(
|
|
||||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
|
||||||
);
|
|
||||||
url.pathname = this.caminho;
|
|
||||||
url.search = "";
|
|
||||||
const queryKeys = Object.entries(query);
|
|
||||||
for (const [key, value] of queryKeys) {
|
|
||||||
url.searchParams.set(String(key), JSON.stringify(value));
|
|
||||||
}
|
|
||||||
url.hash = "";
|
|
||||||
if (usarComoHash) {
|
|
||||||
url.hash = `#${url.search}`;
|
|
||||||
url.search = "";
|
|
||||||
}
|
|
||||||
return url.href;
|
|
||||||
}
|
|
||||||
/** Vai para a url
|
|
||||||
** mCaminho.ir({q:"query"})
|
|
||||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
ir(query) {
|
|
||||||
if (this._acaoIr) {
|
|
||||||
this._acaoIr(this.endereco({ ...query }));
|
|
||||||
} else {
|
|
||||||
if (typeof window != "undefined") {
|
|
||||||
window.location.href = this.endereco({ ...query });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Retorna os parametros da url
|
|
||||||
** console.log(mCaminho.parametros())
|
|
||||||
** {q:"query"}
|
|
||||||
*/
|
|
||||||
parametros(urlEntrada) {
|
|
||||||
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
|
||||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
|
||||||
);
|
|
||||||
const query = url.searchParams;
|
|
||||||
let queryObj = Object.fromEntries(query.entries());
|
|
||||||
const hash = url.hash;
|
|
||||||
if (hash) {
|
|
||||||
const hashObj = Object.fromEntries(
|
|
||||||
new URLSearchParams(hash.slice(1)).entries()
|
|
||||||
);
|
|
||||||
queryObj = { ...queryObj, ...hashObj };
|
|
||||||
}
|
|
||||||
for (const chave in queryObj) {
|
|
||||||
try {
|
|
||||||
queryObj[chave] = JSON.parse(queryObj[chave]);
|
|
||||||
} catch {
|
|
||||||
console.log(`[${chave}|${queryObj[chave]}] n\xE3o \xE9 um json v\xE1lido.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return queryObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var siglas_unidades_medida = /* @__PURE__ */ ((siglas_unidades_medida2) => {
|
|
||||||
siglas_unidades_medida2["UN"] = "UN";
|
|
||||||
siglas_unidades_medida2["KG"] = "KG";
|
|
||||||
siglas_unidades_medida2["TON"] = "TON";
|
|
||||||
siglas_unidades_medida2["g"] = "g";
|
|
||||||
siglas_unidades_medida2["M\xB3"] = "M\xB3";
|
|
||||||
siglas_unidades_medida2["Lt"] = "Lt";
|
|
||||||
return siglas_unidades_medida2;
|
|
||||||
})(siglas_unidades_medida || {});
|
|
||||||
const unidades_medida = [
|
|
||||||
{
|
|
||||||
sigla_unidade: "KG",
|
|
||||||
nome: "Quilograma",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "g",
|
|
||||||
nome: "Grama",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor / 1e3,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "TON",
|
|
||||||
nome: "Tonelada",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor * 1e3,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "Lt",
|
|
||||||
nome: "Litro",
|
|
||||||
sigla_normalizada: "Lt",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "volume"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "M\xB3",
|
|
||||||
nome: "Metro C\xFAbico",
|
|
||||||
sigla_normalizada: "Lt",
|
|
||||||
normalizar: (valor) => valor * 1e3,
|
|
||||||
tipo: "volume"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "UN",
|
|
||||||
nome: "Unidade",
|
|
||||||
sigla_normalizada: "UN",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "unidade"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
||||||
const validarUuid = (uuid2) => {
|
|
||||||
const retorno = erUuid.test(String(uuid2 || ""));
|
|
||||||
return retorno;
|
|
||||||
};
|
|
||||||
const uuidV3 = (chave, grupo) => {
|
|
||||||
return uuid$1.v3(
|
|
||||||
// Converte a chave para string (de forma segura)
|
|
||||||
typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave),
|
|
||||||
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
|
|
||||||
grupo ? uuidV3(grupo) : uuid$1.NIL
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const uuidV4 = uuid$1.v4;
|
|
||||||
const uuid = uuidV4;
|
|
||||||
|
|
||||||
exports.TipagemRotas = TipagemRotas;
|
|
||||||
exports.aleatorio = aleatorio;
|
|
||||||
exports.cacheM = cacheM;
|
|
||||||
exports.cacheMFixo = cacheMFixo;
|
|
||||||
exports.cacheMemoria = cacheMemoria;
|
|
||||||
exports.camposComuns = camposComuns;
|
|
||||||
exports.cdn_carro_de_boi = cdn_carro_de_boi;
|
|
||||||
exports.dayjsbr = dayjsbr;
|
|
||||||
exports.defineCwd = defineCwd;
|
|
||||||
exports.erUuid = erUuid;
|
|
||||||
exports.esperar = esperar;
|
|
||||||
exports.extensoes = extensoes;
|
|
||||||
exports.graficos_pilao = graficos_pilao;
|
|
||||||
exports.localValor = localValor;
|
|
||||||
exports.logger = logger;
|
|
||||||
exports.nomeVariavel = nomeVariavel;
|
|
||||||
exports.objetoPg = objetoPg;
|
|
||||||
exports.operadores = operadores;
|
|
||||||
exports.paraObjetoRegistroPg = paraObjetoRegistroPg;
|
|
||||||
exports.pgObjeto = pgObjeto;
|
|
||||||
exports.postLogger = postLogger;
|
|
||||||
exports.siglas_unidades_medida = siglas_unidades_medida;
|
|
||||||
exports.texto_busca = texto_busca;
|
|
||||||
exports.tipoArquivo = tipoArquivo;
|
|
||||||
exports.tipoUsuarioResiduos = tipoUsuarioResiduos;
|
|
||||||
exports.tx = tx;
|
|
||||||
exports.umaFuncao = umaFuncao;
|
|
||||||
exports.umaVariavel = umaVariavel;
|
|
||||||
exports.unidades_medida = unidades_medida;
|
|
||||||
exports.uuid = uuid;
|
|
||||||
exports.uuidV3 = uuidV3;
|
|
||||||
exports.uuidV4 = uuidV4;
|
|
||||||
exports.uuid_null = uuid_null;
|
|
||||||
exports.validarUuid = validarUuid;
|
|
||||||
exports.verCacheM = verCacheM;
|
|
||||||
exports.zFiltro = zFiltro;
|
|
||||||
exports.zOperadores = zOperadores;
|
|
||||||
315
dist/index.d.cts
vendored
315
dist/index.d.cts
vendored
|
|
@ -1,315 +0,0 @@
|
||||||
import z from 'zod';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
export { ManipulateType } from 'dayjs';
|
|
||||||
import { v4 } from 'uuid';
|
|
||||||
|
|
||||||
declare const aleatorio: (tamanho?: number) => string;
|
|
||||||
|
|
||||||
/** gerar uma função de cache para uso em memoria */
|
|
||||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
declare const verCacheM: () => {
|
|
||||||
[k: string]: {
|
|
||||||
/** new Date().getTime() */
|
|
||||||
validade?: number | undefined;
|
|
||||||
valor: any;
|
|
||||||
} | undefined;
|
|
||||||
};
|
|
||||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
/** para uso fixo dentro de uma função, trava a chave */
|
|
||||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
|
||||||
|
|
||||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
|
||||||
/** Colunas Presentes n maioria das tabelas */
|
|
||||||
declare enum camposComuns {
|
|
||||||
codigo = "codigo",
|
|
||||||
excluido = "excluido",
|
|
||||||
data_hora_criacao = "data_hora_criacao",
|
|
||||||
data_hora_atualizacao = "data_hora_atualizacao",
|
|
||||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
|
||||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
|
||||||
versao = "versao"
|
|
||||||
}
|
|
||||||
/** Palavras comumente usadas */
|
|
||||||
declare enum tx {
|
|
||||||
token = "token"
|
|
||||||
}
|
|
||||||
declare enum tipoUsuarioResiduos {
|
|
||||||
Usuario = "usuario",
|
|
||||||
Fornecedor = "fornecedor"
|
|
||||||
}
|
|
||||||
|
|
||||||
declare enum operadores {
|
|
||||||
"=" = "=",
|
|
||||||
"!=" = "!=",
|
|
||||||
">" = ">",
|
|
||||||
">=" = ">=",
|
|
||||||
"<" = "<",
|
|
||||||
"<=" = "<=",
|
|
||||||
like = "like",
|
|
||||||
in = "in"
|
|
||||||
}
|
|
||||||
type tipoFiltro = {
|
|
||||||
coluna: string;
|
|
||||||
valor: any;
|
|
||||||
operador: keyof typeof operadores | operadores;
|
|
||||||
ou?: boolean;
|
|
||||||
};
|
|
||||||
type interfaceConsulta = {
|
|
||||||
offset?: number;
|
|
||||||
limit?: number;
|
|
||||||
filtros?: tipoFiltro[];
|
|
||||||
ordem?: string;
|
|
||||||
ordemTipo?: "asc" | "desc";
|
|
||||||
colunas?: string[];
|
|
||||||
apenasConsulta?: boolean;
|
|
||||||
apenasContagem?: boolean;
|
|
||||||
};
|
|
||||||
declare const zOperadores: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
declare const zFiltro: z.ZodObject<{
|
|
||||||
coluna: z.ZodString;
|
|
||||||
valor: z.ZodAny;
|
|
||||||
operador: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
ou: z.ZodOptional<z.ZodBoolean>;
|
|
||||||
}, z.core.$strip>;
|
|
||||||
|
|
||||||
declare const dayjsbr: typeof dayjs;
|
|
||||||
|
|
||||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
|
||||||
|
|
||||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
|
||||||
declare const extensoes: {
|
|
||||||
ext: string;
|
|
||||||
tipo: tiposArquivo;
|
|
||||||
mime: string;
|
|
||||||
}[];
|
|
||||||
/**
|
|
||||||
* Função que retorna o tipo do arquivo
|
|
||||||
* @param nomeArquivo
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
|
||||||
|
|
||||||
declare const graficos_pilao: {
|
|
||||||
[k: string]: {
|
|
||||||
grafico: string;
|
|
||||||
titulo: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalStorage Tipado
|
|
||||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
|
||||||
*/
|
|
||||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
|
||||||
|
|
||||||
type tipoLokiObjeto = {
|
|
||||||
streams: {
|
|
||||||
stream: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
values: [string, string][];
|
|
||||||
}[];
|
|
||||||
};
|
|
||||||
declare const postLogger: ({ objeto, }: {
|
|
||||||
objeto: tipoLokiObjeto;
|
|
||||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
/** define a localização da pasta do projeto */
|
|
||||||
declare const defineCwd: (novoCwd: string) => void;
|
|
||||||
type tipoLevel = "info" | "warn" | "error";
|
|
||||||
type tipoOpSessao = {
|
|
||||||
inquilino: string;
|
|
||||||
usuario: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLog = {
|
|
||||||
detalhes?: unknown[];
|
|
||||||
__filename?: string;
|
|
||||||
local?: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
|
||||||
type tipoLogger = (amb: {
|
|
||||||
app: string;
|
|
||||||
eProducao: boolean;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
}) => TipoLoggerSessao;
|
|
||||||
declare const logger: tipoLogger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trata um objeto para ser imput para postgres
|
|
||||||
* @param entrada
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const paraObjetoRegistroPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const pgObjeto: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const objetoPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const umaFuncao: () => string;
|
|
||||||
|
|
||||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
|
||||||
|
|
||||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
|
||||||
declare const texto_busca: (...texto: any[]) => string;
|
|
||||||
|
|
||||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
|
||||||
*
|
|
||||||
* Definições:
|
|
||||||
*
|
|
||||||
* caminho = "/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* parametros = {nome:"José"}
|
|
||||||
*/
|
|
||||||
declare class TipagemRotas<T extends {
|
|
||||||
[q: string]: any;
|
|
||||||
}> {
|
|
||||||
_partesCaminho: string[];
|
|
||||||
_acaoIr?: (endereco: string) => undefined;
|
|
||||||
rotulo: string | undefined;
|
|
||||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
|
||||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
|
||||||
*/
|
|
||||||
constructor({ caminho, acaoIr, rotulo, }: {
|
|
||||||
caminho: (string | null | undefined)[] | string;
|
|
||||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
|
||||||
/** Rotulo da página
|
|
||||||
* Inicio | Controle
|
|
||||||
*/
|
|
||||||
rotulo?: string;
|
|
||||||
});
|
|
||||||
/** Retorna o caminho completo da rota
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/caminho"
|
|
||||||
*/
|
|
||||||
get caminho(): string;
|
|
||||||
/** Define o caminho completo da rota
|
|
||||||
** mCaminho.caminho = "/novoCaminho"
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/novoCaminho"
|
|
||||||
** */
|
|
||||||
set caminho(caminhoParcial: string);
|
|
||||||
/** Retorna o caminho completo da rota com a query
|
|
||||||
** console.log(mCaminho.resolve({q:"query"}))
|
|
||||||
** "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
endereco(query: T, usarComoHash?: boolean): string;
|
|
||||||
/** Vai para a url
|
|
||||||
** mCaminho.ir({q:"query"})
|
|
||||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
ir(query: T): void;
|
|
||||||
/** Retorna os parametros da url
|
|
||||||
** console.log(mCaminho.parametros())
|
|
||||||
** {q:"query"}
|
|
||||||
*/
|
|
||||||
parametros(urlEntrada?: string): Partial<T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Essa variável se conecta a tabela_lidades
|
|
||||||
*
|
|
||||||
* onde sigla se conecta com sigla
|
|
||||||
*
|
|
||||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
|
||||||
* usar a normalizada
|
|
||||||
*/
|
|
||||||
declare enum siglas_unidades_medida {
|
|
||||||
UN = "UN",
|
|
||||||
KG = "KG",
|
|
||||||
TON = "TON",
|
|
||||||
g = "g",
|
|
||||||
"M³" = "M\u00B3",
|
|
||||||
Lt = "Lt"
|
|
||||||
}
|
|
||||||
declare const unidades_medida: {
|
|
||||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
|
||||||
nome: string;
|
|
||||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
|
||||||
normalizar: (valor: number) => number;
|
|
||||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
|
||||||
}[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valida se uma string é um UUID válido (qualquer versão).
|
|
||||||
*
|
|
||||||
* @param valor - A string que será validada.
|
|
||||||
* @returns booleano indicando se é um UUID válido.
|
|
||||||
*/
|
|
||||||
declare const erUuid: RegExp;
|
|
||||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
|
||||||
/**
|
|
||||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
|
||||||
*
|
|
||||||
* - Usa o algoritmo MD5 (RFC 4122).
|
|
||||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
|
||||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
|
||||||
*
|
|
||||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
|
||||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
|
||||||
* @returns UUID v3 (determinístico)
|
|
||||||
*/
|
|
||||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
|
||||||
/**
|
|
||||||
* Gera um UUID v4 (aleatório, não determinístico).
|
|
||||||
*
|
|
||||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
|
||||||
*/
|
|
||||||
declare const uuidV4: typeof v4;
|
|
||||||
/**
|
|
||||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
|
||||||
* Use a função `uuidV4()` diretamente.
|
|
||||||
*/
|
|
||||||
declare const uuid: typeof v4;
|
|
||||||
|
|
||||||
declare const esperar: (ms: number) => Promise<true>;
|
|
||||||
/**
|
|
||||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
|
||||||
* const nomex = {a: 1, b: 2}
|
|
||||||
* nomeVariavel({nomex}) // retorna "nomex"
|
|
||||||
* @param v
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const nomeVariavel: (v: {
|
|
||||||
[key: string]: any;
|
|
||||||
}) => string;
|
|
||||||
|
|
||||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
|
||||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
|
||||||
315
dist/index.d.mts
vendored
315
dist/index.d.mts
vendored
|
|
@ -1,315 +0,0 @@
|
||||||
import z from 'zod';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
export { ManipulateType } from 'dayjs';
|
|
||||||
import { v4 } from 'uuid';
|
|
||||||
|
|
||||||
declare const aleatorio: (tamanho?: number) => string;
|
|
||||||
|
|
||||||
/** gerar uma função de cache para uso em memoria */
|
|
||||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
declare const verCacheM: () => {
|
|
||||||
[k: string]: {
|
|
||||||
/** new Date().getTime() */
|
|
||||||
validade?: number | undefined;
|
|
||||||
valor: any;
|
|
||||||
} | undefined;
|
|
||||||
};
|
|
||||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
/** para uso fixo dentro de uma função, trava a chave */
|
|
||||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
|
||||||
|
|
||||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
|
||||||
/** Colunas Presentes n maioria das tabelas */
|
|
||||||
declare enum camposComuns {
|
|
||||||
codigo = "codigo",
|
|
||||||
excluido = "excluido",
|
|
||||||
data_hora_criacao = "data_hora_criacao",
|
|
||||||
data_hora_atualizacao = "data_hora_atualizacao",
|
|
||||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
|
||||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
|
||||||
versao = "versao"
|
|
||||||
}
|
|
||||||
/** Palavras comumente usadas */
|
|
||||||
declare enum tx {
|
|
||||||
token = "token"
|
|
||||||
}
|
|
||||||
declare enum tipoUsuarioResiduos {
|
|
||||||
Usuario = "usuario",
|
|
||||||
Fornecedor = "fornecedor"
|
|
||||||
}
|
|
||||||
|
|
||||||
declare enum operadores {
|
|
||||||
"=" = "=",
|
|
||||||
"!=" = "!=",
|
|
||||||
">" = ">",
|
|
||||||
">=" = ">=",
|
|
||||||
"<" = "<",
|
|
||||||
"<=" = "<=",
|
|
||||||
like = "like",
|
|
||||||
in = "in"
|
|
||||||
}
|
|
||||||
type tipoFiltro = {
|
|
||||||
coluna: string;
|
|
||||||
valor: any;
|
|
||||||
operador: keyof typeof operadores | operadores;
|
|
||||||
ou?: boolean;
|
|
||||||
};
|
|
||||||
type interfaceConsulta = {
|
|
||||||
offset?: number;
|
|
||||||
limit?: number;
|
|
||||||
filtros?: tipoFiltro[];
|
|
||||||
ordem?: string;
|
|
||||||
ordemTipo?: "asc" | "desc";
|
|
||||||
colunas?: string[];
|
|
||||||
apenasConsulta?: boolean;
|
|
||||||
apenasContagem?: boolean;
|
|
||||||
};
|
|
||||||
declare const zOperadores: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
declare const zFiltro: z.ZodObject<{
|
|
||||||
coluna: z.ZodString;
|
|
||||||
valor: z.ZodAny;
|
|
||||||
operador: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
ou: z.ZodOptional<z.ZodBoolean>;
|
|
||||||
}, z.core.$strip>;
|
|
||||||
|
|
||||||
declare const dayjsbr: typeof dayjs;
|
|
||||||
|
|
||||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
|
||||||
|
|
||||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
|
||||||
declare const extensoes: {
|
|
||||||
ext: string;
|
|
||||||
tipo: tiposArquivo;
|
|
||||||
mime: string;
|
|
||||||
}[];
|
|
||||||
/**
|
|
||||||
* Função que retorna o tipo do arquivo
|
|
||||||
* @param nomeArquivo
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
|
||||||
|
|
||||||
declare const graficos_pilao: {
|
|
||||||
[k: string]: {
|
|
||||||
grafico: string;
|
|
||||||
titulo: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalStorage Tipado
|
|
||||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
|
||||||
*/
|
|
||||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
|
||||||
|
|
||||||
type tipoLokiObjeto = {
|
|
||||||
streams: {
|
|
||||||
stream: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
values: [string, string][];
|
|
||||||
}[];
|
|
||||||
};
|
|
||||||
declare const postLogger: ({ objeto, }: {
|
|
||||||
objeto: tipoLokiObjeto;
|
|
||||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
/** define a localização da pasta do projeto */
|
|
||||||
declare const defineCwd: (novoCwd: string) => void;
|
|
||||||
type tipoLevel = "info" | "warn" | "error";
|
|
||||||
type tipoOpSessao = {
|
|
||||||
inquilino: string;
|
|
||||||
usuario: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLog = {
|
|
||||||
detalhes?: unknown[];
|
|
||||||
__filename?: string;
|
|
||||||
local?: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
|
||||||
type tipoLogger = (amb: {
|
|
||||||
app: string;
|
|
||||||
eProducao: boolean;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
}) => TipoLoggerSessao;
|
|
||||||
declare const logger: tipoLogger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trata um objeto para ser imput para postgres
|
|
||||||
* @param entrada
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const paraObjetoRegistroPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const pgObjeto: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const objetoPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const umaFuncao: () => string;
|
|
||||||
|
|
||||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
|
||||||
|
|
||||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
|
||||||
declare const texto_busca: (...texto: any[]) => string;
|
|
||||||
|
|
||||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
|
||||||
*
|
|
||||||
* Definições:
|
|
||||||
*
|
|
||||||
* caminho = "/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* parametros = {nome:"José"}
|
|
||||||
*/
|
|
||||||
declare class TipagemRotas<T extends {
|
|
||||||
[q: string]: any;
|
|
||||||
}> {
|
|
||||||
_partesCaminho: string[];
|
|
||||||
_acaoIr?: (endereco: string) => undefined;
|
|
||||||
rotulo: string | undefined;
|
|
||||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
|
||||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
|
||||||
*/
|
|
||||||
constructor({ caminho, acaoIr, rotulo, }: {
|
|
||||||
caminho: (string | null | undefined)[] | string;
|
|
||||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
|
||||||
/** Rotulo da página
|
|
||||||
* Inicio | Controle
|
|
||||||
*/
|
|
||||||
rotulo?: string;
|
|
||||||
});
|
|
||||||
/** Retorna o caminho completo da rota
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/caminho"
|
|
||||||
*/
|
|
||||||
get caminho(): string;
|
|
||||||
/** Define o caminho completo da rota
|
|
||||||
** mCaminho.caminho = "/novoCaminho"
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/novoCaminho"
|
|
||||||
** */
|
|
||||||
set caminho(caminhoParcial: string);
|
|
||||||
/** Retorna o caminho completo da rota com a query
|
|
||||||
** console.log(mCaminho.resolve({q:"query"}))
|
|
||||||
** "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
endereco(query: T, usarComoHash?: boolean): string;
|
|
||||||
/** Vai para a url
|
|
||||||
** mCaminho.ir({q:"query"})
|
|
||||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
ir(query: T): void;
|
|
||||||
/** Retorna os parametros da url
|
|
||||||
** console.log(mCaminho.parametros())
|
|
||||||
** {q:"query"}
|
|
||||||
*/
|
|
||||||
parametros(urlEntrada?: string): Partial<T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Essa variável se conecta a tabela_lidades
|
|
||||||
*
|
|
||||||
* onde sigla se conecta com sigla
|
|
||||||
*
|
|
||||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
|
||||||
* usar a normalizada
|
|
||||||
*/
|
|
||||||
declare enum siglas_unidades_medida {
|
|
||||||
UN = "UN",
|
|
||||||
KG = "KG",
|
|
||||||
TON = "TON",
|
|
||||||
g = "g",
|
|
||||||
"M³" = "M\u00B3",
|
|
||||||
Lt = "Lt"
|
|
||||||
}
|
|
||||||
declare const unidades_medida: {
|
|
||||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
|
||||||
nome: string;
|
|
||||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
|
||||||
normalizar: (valor: number) => number;
|
|
||||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
|
||||||
}[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valida se uma string é um UUID válido (qualquer versão).
|
|
||||||
*
|
|
||||||
* @param valor - A string que será validada.
|
|
||||||
* @returns booleano indicando se é um UUID válido.
|
|
||||||
*/
|
|
||||||
declare const erUuid: RegExp;
|
|
||||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
|
||||||
/**
|
|
||||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
|
||||||
*
|
|
||||||
* - Usa o algoritmo MD5 (RFC 4122).
|
|
||||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
|
||||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
|
||||||
*
|
|
||||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
|
||||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
|
||||||
* @returns UUID v3 (determinístico)
|
|
||||||
*/
|
|
||||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
|
||||||
/**
|
|
||||||
* Gera um UUID v4 (aleatório, não determinístico).
|
|
||||||
*
|
|
||||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
|
||||||
*/
|
|
||||||
declare const uuidV4: typeof v4;
|
|
||||||
/**
|
|
||||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
|
||||||
* Use a função `uuidV4()` diretamente.
|
|
||||||
*/
|
|
||||||
declare const uuid: typeof v4;
|
|
||||||
|
|
||||||
declare const esperar: (ms: number) => Promise<true>;
|
|
||||||
/**
|
|
||||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
|
||||||
* const nomex = {a: 1, b: 2}
|
|
||||||
* nomeVariavel({nomex}) // retorna "nomex"
|
|
||||||
* @param v
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const nomeVariavel: (v: {
|
|
||||||
[key: string]: any;
|
|
||||||
}) => string;
|
|
||||||
|
|
||||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
|
||||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
|
||||||
315
dist/index.d.ts
vendored
315
dist/index.d.ts
vendored
|
|
@ -1,315 +0,0 @@
|
||||||
import z from 'zod';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
export { ManipulateType } from 'dayjs';
|
|
||||||
import { v4 } from 'uuid';
|
|
||||||
|
|
||||||
declare const aleatorio: (tamanho?: number) => string;
|
|
||||||
|
|
||||||
/** gerar uma função de cache para uso em memoria */
|
|
||||||
declare const cacheM: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
declare const verCacheM: () => {
|
|
||||||
[k: string]: {
|
|
||||||
/** new Date().getTime() */
|
|
||||||
validade?: number | undefined;
|
|
||||||
valor: any;
|
|
||||||
} | undefined;
|
|
||||||
};
|
|
||||||
declare const cacheMemoria: <T>(chave: any, valor?: T, validadeSeg?: number) => T | undefined;
|
|
||||||
/** para uso fixo dentro de uma função, trava a chave */
|
|
||||||
declare const cacheMFixo: (chave: any) => <T>(valor?: T) => T | undefined;
|
|
||||||
|
|
||||||
declare const uuid_null = "00000000-0000-0000-0000-000000000000";
|
|
||||||
/** Colunas Presentes n maioria das tabelas */
|
|
||||||
declare enum camposComuns {
|
|
||||||
codigo = "codigo",
|
|
||||||
excluido = "excluido",
|
|
||||||
data_hora_criacao = "data_hora_criacao",
|
|
||||||
data_hora_atualizacao = "data_hora_atualizacao",
|
|
||||||
codigo_usuario_criacao = "codigo_usuario_criacao",
|
|
||||||
codigo_usuario_atualizacao = "codigo_usuario_atualizacao",
|
|
||||||
versao = "versao"
|
|
||||||
}
|
|
||||||
/** Palavras comumente usadas */
|
|
||||||
declare enum tx {
|
|
||||||
token = "token"
|
|
||||||
}
|
|
||||||
declare enum tipoUsuarioResiduos {
|
|
||||||
Usuario = "usuario",
|
|
||||||
Fornecedor = "fornecedor"
|
|
||||||
}
|
|
||||||
|
|
||||||
declare enum operadores {
|
|
||||||
"=" = "=",
|
|
||||||
"!=" = "!=",
|
|
||||||
">" = ">",
|
|
||||||
">=" = ">=",
|
|
||||||
"<" = "<",
|
|
||||||
"<=" = "<=",
|
|
||||||
like = "like",
|
|
||||||
in = "in"
|
|
||||||
}
|
|
||||||
type tipoFiltro = {
|
|
||||||
coluna: string;
|
|
||||||
valor: any;
|
|
||||||
operador: keyof typeof operadores | operadores;
|
|
||||||
ou?: boolean;
|
|
||||||
};
|
|
||||||
type interfaceConsulta = {
|
|
||||||
offset?: number;
|
|
||||||
limit?: number;
|
|
||||||
filtros?: tipoFiltro[];
|
|
||||||
ordem?: string;
|
|
||||||
ordemTipo?: "asc" | "desc";
|
|
||||||
colunas?: string[];
|
|
||||||
apenasConsulta?: boolean;
|
|
||||||
apenasContagem?: boolean;
|
|
||||||
};
|
|
||||||
declare const zOperadores: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
declare const zFiltro: z.ZodObject<{
|
|
||||||
coluna: z.ZodString;
|
|
||||||
valor: z.ZodAny;
|
|
||||||
operador: z.ZodEnum<{
|
|
||||||
"=": "=";
|
|
||||||
"!=": "!=";
|
|
||||||
">": ">";
|
|
||||||
">=": ">=";
|
|
||||||
"<": "<";
|
|
||||||
"<=": "<=";
|
|
||||||
like: "like";
|
|
||||||
in: "in";
|
|
||||||
}>;
|
|
||||||
ou: z.ZodOptional<z.ZodBoolean>;
|
|
||||||
}, z.core.$strip>;
|
|
||||||
|
|
||||||
declare const dayjsbr: typeof dayjs;
|
|
||||||
|
|
||||||
declare const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
|
||||||
|
|
||||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
|
||||||
declare const extensoes: {
|
|
||||||
ext: string;
|
|
||||||
tipo: tiposArquivo;
|
|
||||||
mime: string;
|
|
||||||
}[];
|
|
||||||
/**
|
|
||||||
* Função que retorna o tipo do arquivo
|
|
||||||
* @param nomeArquivo
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
|
||||||
|
|
||||||
declare const graficos_pilao: {
|
|
||||||
[k: string]: {
|
|
||||||
grafico: string;
|
|
||||||
titulo: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* LocalStorage Tipado
|
|
||||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
|
||||||
*/
|
|
||||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
|
||||||
|
|
||||||
type tipoLokiObjeto = {
|
|
||||||
streams: {
|
|
||||||
stream: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
values: [string, string][];
|
|
||||||
}[];
|
|
||||||
};
|
|
||||||
declare const postLogger: ({ objeto, }: {
|
|
||||||
objeto: tipoLokiObjeto;
|
|
||||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
/** define a localização da pasta do projeto */
|
|
||||||
declare const defineCwd: (novoCwd: string) => void;
|
|
||||||
type tipoLevel = "info" | "warn" | "error";
|
|
||||||
type tipoOpSessao = {
|
|
||||||
inquilino: string;
|
|
||||||
usuario: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLog = {
|
|
||||||
detalhes?: unknown[];
|
|
||||||
__filename?: string;
|
|
||||||
local?: string;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
|
||||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
|
||||||
type tipoLogger = (amb: {
|
|
||||||
app: string;
|
|
||||||
eProducao: boolean;
|
|
||||||
parametros?: {
|
|
||||||
[k: string]: string;
|
|
||||||
};
|
|
||||||
}) => TipoLoggerSessao;
|
|
||||||
declare const logger: tipoLogger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trata um objeto para ser imput para postgres
|
|
||||||
* @param entrada
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const paraObjetoRegistroPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const pgObjeto: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
declare const objetoPg: (entrada: {
|
|
||||||
[k: string]: any;
|
|
||||||
}) => {
|
|
||||||
[k: string]: string | boolean | null | undefined | number;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare const umaFuncao: () => string;
|
|
||||||
|
|
||||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
|
||||||
|
|
||||||
/** gerar o texto de busca removendo caracteres especies e caixa alta */
|
|
||||||
declare const texto_busca: (...texto: any[]) => string;
|
|
||||||
|
|
||||||
/** Gerar uma classe que facilita a gestão de rotas com a tipagem das querys
|
|
||||||
*
|
|
||||||
* Definições:
|
|
||||||
*
|
|
||||||
* caminho = "/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* endereco = "http://localhost:3000/aplicacao/funcionalidade"
|
|
||||||
*
|
|
||||||
* parametros = {nome:"José"}
|
|
||||||
*/
|
|
||||||
declare class TipagemRotas<T extends {
|
|
||||||
[q: string]: any;
|
|
||||||
}> {
|
|
||||||
_partesCaminho: string[];
|
|
||||||
_acaoIr?: (endereco: string) => undefined;
|
|
||||||
rotulo: string | undefined;
|
|
||||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
|
||||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
|
||||||
*/
|
|
||||||
constructor({ caminho, acaoIr, rotulo, }: {
|
|
||||||
caminho: (string | null | undefined)[] | string;
|
|
||||||
acaoIr?: undefined | ((endereco: string) => undefined);
|
|
||||||
/** Rotulo da página
|
|
||||||
* Inicio | Controle
|
|
||||||
*/
|
|
||||||
rotulo?: string;
|
|
||||||
});
|
|
||||||
/** Retorna o caminho completo da rota
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/caminho"
|
|
||||||
*/
|
|
||||||
get caminho(): string;
|
|
||||||
/** Define o caminho completo da rota
|
|
||||||
** mCaminho.caminho = "/novoCaminho"
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/novoCaminho"
|
|
||||||
** */
|
|
||||||
set caminho(caminhoParcial: string);
|
|
||||||
/** Retorna o caminho completo da rota com a query
|
|
||||||
** console.log(mCaminho.resolve({q:"query"}))
|
|
||||||
** "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
endereco(query: T, usarComoHash?: boolean): string;
|
|
||||||
/** Vai para a url
|
|
||||||
** mCaminho.ir({q:"query"})
|
|
||||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
ir(query: T): void;
|
|
||||||
/** Retorna os parametros da url
|
|
||||||
** console.log(mCaminho.parametros())
|
|
||||||
** {q:"query"}
|
|
||||||
*/
|
|
||||||
parametros(urlEntrada?: string): Partial<T>;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Essa variável se conecta a tabela_lidades
|
|
||||||
*
|
|
||||||
* onde sigla se conecta com sigla
|
|
||||||
*
|
|
||||||
* Usuário terá mais opções de unidades, quando fazer o envio para o mtr, usar a opção fornecida pelo usuarios, caso não tenha
|
|
||||||
* usar a normalizada
|
|
||||||
*/
|
|
||||||
declare enum siglas_unidades_medida {
|
|
||||||
UN = "UN",
|
|
||||||
KG = "KG",
|
|
||||||
TON = "TON",
|
|
||||||
g = "g",
|
|
||||||
"M³" = "M\u00B3",
|
|
||||||
Lt = "Lt"
|
|
||||||
}
|
|
||||||
declare const unidades_medida: {
|
|
||||||
sigla_unidade: keyof typeof siglas_unidades_medida;
|
|
||||||
nome: string;
|
|
||||||
sigla_normalizada: keyof typeof siglas_unidades_medida;
|
|
||||||
normalizar: (valor: number) => number;
|
|
||||||
tipo: "massa" | "volume" | "comprimento" | "unidade";
|
|
||||||
}[];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Valida se uma string é um UUID válido (qualquer versão).
|
|
||||||
*
|
|
||||||
* @param valor - A string que será validada.
|
|
||||||
* @returns booleano indicando se é um UUID válido.
|
|
||||||
*/
|
|
||||||
declare const erUuid: RegExp;
|
|
||||||
declare const validarUuid: (uuid: string | number | undefined | null) => boolean;
|
|
||||||
/**
|
|
||||||
* Gera um UUID determinístico (versão 3) com base em uma chave e um grupo (namespace).
|
|
||||||
*
|
|
||||||
* - Usa o algoritmo MD5 (RFC 4122).
|
|
||||||
* - Sempre retorna o mesmo UUID para a mesma combinação chave + grupo.
|
|
||||||
* - Caso o grupo não seja informado, usa o UUID "nil" como namespace.
|
|
||||||
*
|
|
||||||
* @param chave - Qualquer valor que será convertido em string para gerar o UUID (ex: número, string ou objeto).
|
|
||||||
* @param grupo - Opcional. Namespace para separar domínios diferentes de UUIDs.
|
|
||||||
* @returns UUID v3 (determinístico)
|
|
||||||
*/
|
|
||||||
declare const uuidV3: (chave: any, grupo?: any) => string;
|
|
||||||
/**
|
|
||||||
* Gera um UUID v4 (aleatório, não determinístico).
|
|
||||||
*
|
|
||||||
* - Usado quando unicidade é necessária, mas não se exige que seja previsível.
|
|
||||||
*/
|
|
||||||
declare const uuidV4: typeof v4;
|
|
||||||
/**
|
|
||||||
* @deprecated Esta variável será descontinuada em versões futuras.
|
|
||||||
* Use a função `uuidV4()` diretamente.
|
|
||||||
*/
|
|
||||||
declare const uuid: typeof v4;
|
|
||||||
|
|
||||||
declare const esperar: (ms: number) => Promise<true>;
|
|
||||||
/**
|
|
||||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
|
||||||
* const nomex = {a: 1, b: 2}
|
|
||||||
* nomeVariavel({nomex}) // retorna "nomex"
|
|
||||||
* @param v
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
declare const nomeVariavel: (v: {
|
|
||||||
[key: string]: any;
|
|
||||||
}) => string;
|
|
||||||
|
|
||||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
|
||||||
export type { TipoLoggerSessao, interfaceConsulta, tipoFiltro, tipoLogger, tipoLoggerLog, tipoLokiObjeto };
|
|
||||||
548
dist/index.mjs
vendored
548
dist/index.mjs
vendored
|
|
@ -1,548 +0,0 @@
|
||||||
import z from 'zod';
|
|
||||||
import dayjs from 'dayjs';
|
|
||||||
import duration from 'dayjs/plugin/duration.js';
|
|
||||||
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter.js';
|
|
||||||
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore.js';
|
|
||||||
import minMax from 'dayjs/plugin/minMax.js';
|
|
||||||
import relativeTime from 'dayjs/plugin/relativeTime.js';
|
|
||||||
import timezone from 'dayjs/plugin/timezone.js';
|
|
||||||
import utc from 'dayjs/plugin/utc.js';
|
|
||||||
import weekOfYear from 'dayjs/plugin/weekOfYear.js';
|
|
||||||
import 'dayjs/locale/pt-br.js';
|
|
||||||
import crossFetch from 'cross-fetch';
|
|
||||||
import { v4, v3, NIL } from 'uuid';
|
|
||||||
|
|
||||||
const alfabeto = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
|
|
||||||
const aleatorio = (tamanho) => `eli-${Array.from({ length: tamanho || 8 }).map(() => alfabeto[(999 * Math.random() | 0) % alfabeto.length]).join("")}`;
|
|
||||||
|
|
||||||
const _cache = {};
|
|
||||||
globalThis.cacheMemoria_cache = _cache;
|
|
||||||
const cacheM = (chave, valor, validadeSeg) => {
|
|
||||||
const txChave = typeof chave == "string" ? chave : typeof chave == "number" ? String(chave) : encodeURIComponent(JSON.stringify(chave));
|
|
||||||
const validade = validadeSeg && (/* @__PURE__ */ new Date()).getTime() + validadeSeg * 1e3;
|
|
||||||
if (valor !== void 0) {
|
|
||||||
_cache[txChave] = {
|
|
||||||
valor,
|
|
||||||
validade
|
|
||||||
};
|
|
||||||
}
|
|
||||||
const busca = _cache[txChave];
|
|
||||||
if (busca?.validade && busca.validade < (/* @__PURE__ */ new Date()).getTime()) {
|
|
||||||
return void 0;
|
|
||||||
}
|
|
||||||
return busca?.valor;
|
|
||||||
};
|
|
||||||
const verCacheM = () => _cache;
|
|
||||||
const cacheMemoria = cacheM;
|
|
||||||
const cacheMFixo = (chave) => (valor) => cacheM(chave, valor);
|
|
||||||
|
|
||||||
const uuid_null = "00000000-0000-0000-0000-000000000000";
|
|
||||||
var camposComuns = /* @__PURE__ */ ((camposComuns2) => {
|
|
||||||
camposComuns2["codigo"] = "codigo";
|
|
||||||
camposComuns2["excluido"] = "excluido";
|
|
||||||
camposComuns2["data_hora_criacao"] = "data_hora_criacao";
|
|
||||||
camposComuns2["data_hora_atualizacao"] = "data_hora_atualizacao";
|
|
||||||
camposComuns2["codigo_usuario_criacao"] = "codigo_usuario_criacao";
|
|
||||||
camposComuns2["codigo_usuario_atualizacao"] = "codigo_usuario_atualizacao";
|
|
||||||
camposComuns2["versao"] = "versao";
|
|
||||||
return camposComuns2;
|
|
||||||
})(camposComuns || {});
|
|
||||||
var tx = /* @__PURE__ */ ((tx2) => {
|
|
||||||
tx2["token"] = "token";
|
|
||||||
return tx2;
|
|
||||||
})(tx || {});
|
|
||||||
var tipoUsuarioResiduos = /* @__PURE__ */ ((tipoUsuarioResiduos2) => {
|
|
||||||
tipoUsuarioResiduos2["Usuario"] = "usuario";
|
|
||||||
tipoUsuarioResiduos2["Fornecedor"] = "fornecedor";
|
|
||||||
return tipoUsuarioResiduos2;
|
|
||||||
})(tipoUsuarioResiduos || {});
|
|
||||||
|
|
||||||
var operadores = /* @__PURE__ */ ((operadores2) => {
|
|
||||||
operadores2["="] = "=";
|
|
||||||
operadores2["!="] = "!=";
|
|
||||||
operadores2[">"] = ">";
|
|
||||||
operadores2[">="] = ">=";
|
|
||||||
operadores2["<"] = "<";
|
|
||||||
operadores2["<="] = "<=";
|
|
||||||
operadores2["like"] = "like";
|
|
||||||
operadores2["in"] = "in";
|
|
||||||
return operadores2;
|
|
||||||
})(operadores || {});
|
|
||||||
const zOperadores = z.enum([
|
|
||||||
"=",
|
|
||||||
"!=",
|
|
||||||
">",
|
|
||||||
">=",
|
|
||||||
"<",
|
|
||||||
"<=",
|
|
||||||
"like",
|
|
||||||
"in"
|
|
||||||
]);
|
|
||||||
const zFiltro = z.object({
|
|
||||||
coluna: z.string(),
|
|
||||||
valor: z.any(),
|
|
||||||
operador: zOperadores,
|
|
||||||
ou: z.boolean().optional()
|
|
||||||
});
|
|
||||||
|
|
||||||
dayjs.locale("pt-br");
|
|
||||||
dayjs.extend(utc);
|
|
||||||
dayjs.extend(timezone);
|
|
||||||
dayjs.extend(weekOfYear);
|
|
||||||
dayjs.extend(isSameOrBefore);
|
|
||||||
dayjs.extend(isSameOrAfter);
|
|
||||||
dayjs.extend(minMax);
|
|
||||||
dayjs.extend(relativeTime);
|
|
||||||
dayjs.extend(duration);
|
|
||||||
const dayjsbr = dayjs;
|
|
||||||
|
|
||||||
const cdn_carro_de_boi = "https://carro-de-boi-idz-one.b-cdn.net";
|
|
||||||
|
|
||||||
const extensoes = [
|
|
||||||
{
|
|
||||||
ext: "gif",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/gif"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "jpg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/jpeg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "jpeg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/jpeg"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "png",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "bmp",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/bmp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "webp",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/webp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "tiff",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/tiff"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "svg",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/svg+xml"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ico",
|
|
||||||
tipo: "imagem",
|
|
||||||
mime: "image/x-icon"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "pdf",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/pdf"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "doc",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/msword"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "docx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "xls",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.ms-excel"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "xlsx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ppt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.ms-powerpoint"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "pptx",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.openxmlformats-officedocument.presentationml.presentation"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "txt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "text/plain"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "odt",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.oasis.opendocument.text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "ods",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/vnd.oasis.opendocument.spreadsheet"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "rtf",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "application/rtf"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "csv",
|
|
||||||
tipo: "documento",
|
|
||||||
mime: "text/csv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mp4",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/mp4"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "avi",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-msvideo"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mkv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-matroska"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mov",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/quicktime"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "wmv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-ms-wmv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "flv",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/x-flv"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "webm",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/webm"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "3gp",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/3gpp"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
ext: "mpeg",
|
|
||||||
tipo: "v\xEDdeo",
|
|
||||||
mime: "video/mpeg"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const tipoArquivo = (nomeArquivo) => {
|
|
||||||
const extArquivo = String(nomeArquivo || "").toLocaleLowerCase().split(".").pop();
|
|
||||||
const extensao = extensoes.find((extensao2) => extensao2.ext === extArquivo);
|
|
||||||
return extensao?.tipo || "outros";
|
|
||||||
};
|
|
||||||
|
|
||||||
const graficos_pilao = {
|
|
||||||
Condicionantes: {
|
|
||||||
grafico: "condicionantes-criadas",
|
|
||||||
titulo: "Condicionantes Criadas"
|
|
||||||
},
|
|
||||||
Licen\u00E7as: {
|
|
||||||
grafico: "licencas-criadas",
|
|
||||||
titulo: "Licen\xE7as Criadas"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const localValor = (chave_, valor) => {
|
|
||||||
const localStorage = globalThis.localStorage;
|
|
||||||
if (typeof localStorage == "undefined") return null;
|
|
||||||
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
|
||||||
try {
|
|
||||||
if (valor !== void 0) {
|
|
||||||
localStorage.setItem(chave, JSON.stringify(valor));
|
|
||||||
}
|
|
||||||
const v2 = localStorage.getItem(chave);
|
|
||||||
if (v2 === null) return null;
|
|
||||||
try {
|
|
||||||
return JSON.parse(v2);
|
|
||||||
} catch {
|
|
||||||
return v2;
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const esperar = (ms) => new Promise(
|
|
||||||
(resolve) => setTimeout(() => resolve(true), ms)
|
|
||||||
);
|
|
||||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
|
||||||
|
|
||||||
const LOKI_BASE_URL = "https://log.idz.one";
|
|
||||||
const LOKI_ENDPOINT = "/loki/api/v1/push";
|
|
||||||
const postLogger = async ({
|
|
||||||
objeto
|
|
||||||
}) => {
|
|
||||||
const response = await crossFetch(`${LOKI_BASE_URL}${LOKI_ENDPOINT}`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: { "Content-Type": "application/json" },
|
|
||||||
body: JSON.stringify(objeto)
|
|
||||||
}).catch((a) => a);
|
|
||||||
if (!response.ok) {
|
|
||||||
return [objeto, `Erro ${response.status}: ${await response?.text?.()}`];
|
|
||||||
}
|
|
||||||
return [objeto];
|
|
||||||
};
|
|
||||||
let cwd = "";
|
|
||||||
const defineCwd = (novoCwd) => {
|
|
||||||
cwd = novoCwd;
|
|
||||||
};
|
|
||||||
const logger = ({ app: app_e, eProducao, parametros: parametrosAmbiente }) => ({ inquilino, usuario, parametros: parametrosSessao }) => async (level, mensagem, op_tipoLog) => {
|
|
||||||
let {
|
|
||||||
__filename,
|
|
||||||
detalhes,
|
|
||||||
local,
|
|
||||||
parametros: parametrosLog
|
|
||||||
} = op_tipoLog || {};
|
|
||||||
const app = `${eProducao ? "" : "DEV-"}${app_e}`;
|
|
||||||
if (cwd && __filename) {
|
|
||||||
__filename = __filename.replace(cwd, "");
|
|
||||||
}
|
|
||||||
if (local) {
|
|
||||||
detalhes = [`${nomeVariavel({ local })}="${local}"`, ...detalhes || []];
|
|
||||||
}
|
|
||||||
if (__filename) {
|
|
||||||
detalhes = [
|
|
||||||
`${nomeVariavel({ __filename })}="${__filename}"`,
|
|
||||||
...detalhes || []
|
|
||||||
];
|
|
||||||
}
|
|
||||||
const timestamp = `${Date.now()}000000`;
|
|
||||||
const mainLog = detalhes?.length ? `${mensagem} | ${detalhes.map((d) => JSON.stringify(d)).join(" | ")}` : mensagem;
|
|
||||||
const payload = {
|
|
||||||
stream: {
|
|
||||||
app,
|
|
||||||
inquilino,
|
|
||||||
usuario,
|
|
||||||
level,
|
|
||||||
...parametrosAmbiente || {},
|
|
||||||
...parametrosSessao || {},
|
|
||||||
...parametrosLog || {}
|
|
||||||
},
|
|
||||||
values: [
|
|
||||||
[
|
|
||||||
timestamp,
|
|
||||||
mainLog
|
|
||||||
// Linha de log direta
|
|
||||||
]
|
|
||||||
]
|
|
||||||
};
|
|
||||||
const objeto = { streams: [payload] };
|
|
||||||
const response = await postLogger({ objeto });
|
|
||||||
return response;
|
|
||||||
};
|
|
||||||
|
|
||||||
const paraObjetoRegistroPg = (entrada) => {
|
|
||||||
try {
|
|
||||||
return Object.fromEntries(
|
|
||||||
Object.entries(entrada).map(([k, v]) => [
|
|
||||||
k,
|
|
||||||
v === void 0 || v == null ? v : typeof v == "string" || typeof v == "number" || typeof v == "boolean" ? v : JSON.stringify(v, null, 2)
|
|
||||||
])
|
|
||||||
);
|
|
||||||
} catch (error) {
|
|
||||||
throw new Error(
|
|
||||||
`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${error.message} ${error.stack}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const pgObjeto = paraObjetoRegistroPg;
|
|
||||||
const objetoPg = paraObjetoRegistroPg;
|
|
||||||
|
|
||||||
const umaFuncao = () => "Ol\xE1 Mundo! (fun\xE7\xE3o)";
|
|
||||||
|
|
||||||
const umaVariavel = "Ol\xE1 Mundo! (vari\xE1vel)";
|
|
||||||
|
|
||||||
const texto_busca = (...texto) => texto.map(
|
|
||||||
(txt) => txt === null || txt === void 0 ? "" : String(txt).normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/\s+/g, " ").toLowerCase()
|
|
||||||
).join(" ");
|
|
||||||
|
|
||||||
class TipagemRotas {
|
|
||||||
_partesCaminho = [];
|
|
||||||
_acaoIr;
|
|
||||||
rotulo;
|
|
||||||
/** Ao criar novo obijeto de tipagem de rota é necessário passar o caminho parcial
|
|
||||||
** export const mCaminho = new TipagemRotas<{q:string}>("aplicacao","funcionalidade")
|
|
||||||
*/
|
|
||||||
constructor({
|
|
||||||
caminho,
|
|
||||||
acaoIr,
|
|
||||||
rotulo
|
|
||||||
}) {
|
|
||||||
this._acaoIr = acaoIr;
|
|
||||||
this._partesCaminho = (Array.isArray(caminho) ? caminho : [caminho]).filter(Boolean).map((a) => String(a)).flatMap((a) => a.split("/")).filter(Boolean);
|
|
||||||
this.rotulo = rotulo;
|
|
||||||
}
|
|
||||||
/** Retorna o caminho completo da rota
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/caminho"
|
|
||||||
*/
|
|
||||||
get caminho() {
|
|
||||||
const ret = `/${this._partesCaminho.join("/")}`;
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
/** Define o caminho completo da rota
|
|
||||||
** mCaminho.caminho = "/novoCaminho"
|
|
||||||
** console.log(mCaminho.caminho)
|
|
||||||
** "/novoCaminho"
|
|
||||||
** */
|
|
||||||
set caminho(caminhoParcial) {
|
|
||||||
this._partesCaminho = caminhoParcial.split("/").filter((parte) => parte);
|
|
||||||
}
|
|
||||||
/** Retorna o caminho completo da rota com a query
|
|
||||||
** console.log(mCaminho.resolve({q:"query"}))
|
|
||||||
** "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
endereco(query, usarComoHash) {
|
|
||||||
const url = new URL(
|
|
||||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
|
||||||
);
|
|
||||||
url.pathname = this.caminho;
|
|
||||||
url.search = "";
|
|
||||||
const queryKeys = Object.entries(query);
|
|
||||||
for (const [key, value] of queryKeys) {
|
|
||||||
url.searchParams.set(String(key), JSON.stringify(value));
|
|
||||||
}
|
|
||||||
url.hash = "";
|
|
||||||
if (usarComoHash) {
|
|
||||||
url.hash = `#${url.search}`;
|
|
||||||
url.search = "";
|
|
||||||
}
|
|
||||||
return url.href;
|
|
||||||
}
|
|
||||||
/** Vai para a url
|
|
||||||
** mCaminho.ir({q:"query"})
|
|
||||||
** window.location.href = "http://localhost:3000/caminho?q=query"
|
|
||||||
*/
|
|
||||||
ir(query) {
|
|
||||||
if (this._acaoIr) {
|
|
||||||
this._acaoIr(this.endereco({ ...query }));
|
|
||||||
} else {
|
|
||||||
if (typeof window != "undefined") {
|
|
||||||
window.location.href = this.endereco({ ...query });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Retorna os parametros da url
|
|
||||||
** console.log(mCaminho.parametros())
|
|
||||||
** {q:"query"}
|
|
||||||
*/
|
|
||||||
parametros(urlEntrada) {
|
|
||||||
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
|
||||||
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
|
||||||
);
|
|
||||||
const query = url.searchParams;
|
|
||||||
let queryObj = Object.fromEntries(query.entries());
|
|
||||||
const hash = url.hash;
|
|
||||||
if (hash) {
|
|
||||||
const hashObj = Object.fromEntries(
|
|
||||||
new URLSearchParams(hash.slice(1)).entries()
|
|
||||||
);
|
|
||||||
queryObj = { ...queryObj, ...hashObj };
|
|
||||||
}
|
|
||||||
for (const chave in queryObj) {
|
|
||||||
try {
|
|
||||||
queryObj[chave] = JSON.parse(queryObj[chave]);
|
|
||||||
} catch {
|
|
||||||
console.log(`[${chave}|${queryObj[chave]}] n\xE3o \xE9 um json v\xE1lido.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return queryObj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var siglas_unidades_medida = /* @__PURE__ */ ((siglas_unidades_medida2) => {
|
|
||||||
siglas_unidades_medida2["UN"] = "UN";
|
|
||||||
siglas_unidades_medida2["KG"] = "KG";
|
|
||||||
siglas_unidades_medida2["TON"] = "TON";
|
|
||||||
siglas_unidades_medida2["g"] = "g";
|
|
||||||
siglas_unidades_medida2["M\xB3"] = "M\xB3";
|
|
||||||
siglas_unidades_medida2["Lt"] = "Lt";
|
|
||||||
return siglas_unidades_medida2;
|
|
||||||
})(siglas_unidades_medida || {});
|
|
||||||
const unidades_medida = [
|
|
||||||
{
|
|
||||||
sigla_unidade: "KG",
|
|
||||||
nome: "Quilograma",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "g",
|
|
||||||
nome: "Grama",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor / 1e3,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "TON",
|
|
||||||
nome: "Tonelada",
|
|
||||||
sigla_normalizada: "KG",
|
|
||||||
normalizar: (valor) => valor * 1e3,
|
|
||||||
tipo: "massa"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "Lt",
|
|
||||||
nome: "Litro",
|
|
||||||
sigla_normalizada: "Lt",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "volume"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "M\xB3",
|
|
||||||
nome: "Metro C\xFAbico",
|
|
||||||
sigla_normalizada: "Lt",
|
|
||||||
normalizar: (valor) => valor * 1e3,
|
|
||||||
tipo: "volume"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
sigla_unidade: "UN",
|
|
||||||
nome: "Unidade",
|
|
||||||
sigla_normalizada: "UN",
|
|
||||||
normalizar: (valor) => valor,
|
|
||||||
tipo: "unidade"
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
||||||
const validarUuid = (uuid2) => {
|
|
||||||
const retorno = erUuid.test(String(uuid2 || ""));
|
|
||||||
return retorno;
|
|
||||||
};
|
|
||||||
const uuidV3 = (chave, grupo) => {
|
|
||||||
return v3(
|
|
||||||
// Converte a chave para string (de forma segura)
|
|
||||||
typeof chave === "string" ? chave : typeof chave === "number" ? String(chave) : JSON.stringify(chave),
|
|
||||||
// Se um grupo foi fornecido, gera um UUID v3 recursivamente com base nele, senão usa NIL
|
|
||||||
grupo ? uuidV3(grupo) : NIL
|
|
||||||
);
|
|
||||||
};
|
|
||||||
const uuidV4 = v4;
|
|
||||||
const uuid = uuidV4;
|
|
||||||
|
|
||||||
export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
|
||||||
1
dist/situacoes/index.d.ts
vendored
1
dist/situacoes/index.d.ts
vendored
|
|
@ -1 +0,0 @@
|
||||||
export * from "./situacoes";
|
|
||||||
18
dist/situacoes/index.js
vendored
18
dist/situacoes/index.js
vendored
|
|
@ -1,18 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
||||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
||||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
||||||
}
|
|
||||||
Object.defineProperty(o, k2, desc);
|
|
||||||
}) : (function(o, m, k, k2) {
|
|
||||||
if (k2 === undefined) k2 = k;
|
|
||||||
o[k2] = m[k];
|
|
||||||
}));
|
|
||||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
||||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
__exportStar(require("./situacoes"), exports);
|
|
||||||
//# sourceMappingURL=index.js.map
|
|
||||||
1
dist/situacoes/index.js.map
vendored
1
dist/situacoes/index.js.map
vendored
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/situacoes/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B"}
|
|
||||||
51
dist/situacoes/situacoes.d.ts
vendored
51
dist/situacoes/situacoes.d.ts
vendored
|
|
@ -1,51 +0,0 @@
|
||||||
export declare enum tiposSituacoes {
|
|
||||||
vencida = "100_vencida",
|
|
||||||
expirado = "200_expirado",
|
|
||||||
alerta = "300_alerta",
|
|
||||||
protocoladafora = "350_protocoladafora",
|
|
||||||
protocolada = "400_protocolada",
|
|
||||||
protocoladaApenas = "430_protocolada",
|
|
||||||
protocolada_alteracao = "450_protocolada",
|
|
||||||
prazo = "500_prazo",
|
|
||||||
emitida = "515_emitida",
|
|
||||||
valida = "518_valida",
|
|
||||||
novo = "520_novo",
|
|
||||||
recebido = "521_recebido",
|
|
||||||
em_andamento = "530_em_andamento",
|
|
||||||
aguardando = "530_aguardando",
|
|
||||||
aguardandoresposta = "540_aguardandoresposta",
|
|
||||||
suspensaotemporaria = "540_suspensaotemporaria",
|
|
||||||
cancelada = "550_cancelada",
|
|
||||||
execucao = "560_execucao",
|
|
||||||
pendente = "570_pendente",
|
|
||||||
executadafora = "600_executadafora",
|
|
||||||
executada = "700_executada",
|
|
||||||
naoexecutada = "701_naoexecutada",
|
|
||||||
concluida = "730_concluida",
|
|
||||||
respondido_negado = "740_respondido_negado",
|
|
||||||
respondido_aceito = "741_respondido_aceito",
|
|
||||||
atendidoparcial = "742_atendidoparcial",
|
|
||||||
naoatendido = "743_naoatendido",
|
|
||||||
atendido = "744_atendido",
|
|
||||||
renovada = "760_renovada",
|
|
||||||
finalizada = "800_finalizada",
|
|
||||||
emitirnota = "101_emitirnota",
|
|
||||||
faturaatrasada = "301_faturaatrasada",
|
|
||||||
pagarfatura = "302_pagarfatura",
|
|
||||||
aguardandoconfirmacao = "531_aguardandoconfirmacao",
|
|
||||||
agendado = "701_agendado",
|
|
||||||
faturapaga = "801_faturapaga",
|
|
||||||
excluida = "999_excluida",
|
|
||||||
requerida = "401_requerida",
|
|
||||||
vigente = "516_vigente",
|
|
||||||
emrenovacao = "402_emrenovacao",
|
|
||||||
arquivada = "801_arquivada",
|
|
||||||
aguardando_sincronizacao = "999_aguardando_sincronizacao",
|
|
||||||
nao_conforme = "710_nao_conforme",
|
|
||||||
conforme = "720_conforme",
|
|
||||||
nao_aplicavel = "730_nao_aplicavel",
|
|
||||||
parcial = "715_parcial"
|
|
||||||
}
|
|
||||||
export declare const corSituacoes: {
|
|
||||||
[K in keyof typeof tiposSituacoes]?: string;
|
|
||||||
};
|
|
||||||
64
dist/situacoes/situacoes.js
vendored
64
dist/situacoes/situacoes.js
vendored
|
|
@ -1,64 +0,0 @@
|
||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.corSituacoes = exports.tiposSituacoes = void 0;
|
|
||||||
var tiposSituacoes;
|
|
||||||
(function (tiposSituacoes) {
|
|
||||||
tiposSituacoes["vencida"] = "100_vencida";
|
|
||||||
tiposSituacoes["expirado"] = "200_expirado";
|
|
||||||
tiposSituacoes["alerta"] = "300_alerta";
|
|
||||||
tiposSituacoes["protocoladafora"] = "350_protocoladafora";
|
|
||||||
tiposSituacoes["protocolada"] = "400_protocolada";
|
|
||||||
tiposSituacoes["protocoladaApenas"] = "430_protocolada";
|
|
||||||
tiposSituacoes["protocolada_alteracao"] = "450_protocolada";
|
|
||||||
tiposSituacoes["prazo"] = "500_prazo";
|
|
||||||
tiposSituacoes["emitida"] = "515_emitida";
|
|
||||||
tiposSituacoes["valida"] = "518_valida";
|
|
||||||
tiposSituacoes["novo"] = "520_novo";
|
|
||||||
tiposSituacoes["recebido"] = "521_recebido";
|
|
||||||
tiposSituacoes["em_andamento"] = "530_em_andamento";
|
|
||||||
tiposSituacoes["aguardando"] = "530_aguardando";
|
|
||||||
tiposSituacoes["aguardandoresposta"] = "540_aguardandoresposta";
|
|
||||||
tiposSituacoes["suspensaotemporaria"] = "540_suspensaotemporaria";
|
|
||||||
tiposSituacoes["cancelada"] = "550_cancelada";
|
|
||||||
tiposSituacoes["execucao"] = "560_execucao";
|
|
||||||
tiposSituacoes["pendente"] = "570_pendente";
|
|
||||||
tiposSituacoes["executadafora"] = "600_executadafora";
|
|
||||||
tiposSituacoes["executada"] = "700_executada";
|
|
||||||
tiposSituacoes["naoexecutada"] = "701_naoexecutada";
|
|
||||||
tiposSituacoes["concluida"] = "730_concluida";
|
|
||||||
tiposSituacoes["respondido_negado"] = "740_respondido_negado";
|
|
||||||
tiposSituacoes["respondido_aceito"] = "741_respondido_aceito";
|
|
||||||
tiposSituacoes["atendidoparcial"] = "742_atendidoparcial";
|
|
||||||
tiposSituacoes["naoatendido"] = "743_naoatendido";
|
|
||||||
tiposSituacoes["atendido"] = "744_atendido";
|
|
||||||
tiposSituacoes["renovada"] = "760_renovada";
|
|
||||||
tiposSituacoes["finalizada"] = "800_finalizada";
|
|
||||||
tiposSituacoes["emitirnota"] = "101_emitirnota";
|
|
||||||
tiposSituacoes["faturaatrasada"] = "301_faturaatrasada";
|
|
||||||
tiposSituacoes["pagarfatura"] = "302_pagarfatura";
|
|
||||||
tiposSituacoes["aguardandoconfirmacao"] = "531_aguardandoconfirmacao";
|
|
||||||
tiposSituacoes["agendado"] = "701_agendado";
|
|
||||||
tiposSituacoes["faturapaga"] = "801_faturapaga";
|
|
||||||
tiposSituacoes["excluida"] = "999_excluida";
|
|
||||||
// situacoes outorgas
|
|
||||||
// Requerido
|
|
||||||
// Vigente
|
|
||||||
// Em renovação
|
|
||||||
// Arquivado
|
|
||||||
tiposSituacoes["requerida"] = "401_requerida";
|
|
||||||
tiposSituacoes["vigente"] = "516_vigente";
|
|
||||||
tiposSituacoes["emrenovacao"] = "402_emrenovacao";
|
|
||||||
tiposSituacoes["arquivada"] = "801_arquivada";
|
|
||||||
tiposSituacoes["aguardando_sincronizacao"] = "999_aguardando_sincronizacao";
|
|
||||||
tiposSituacoes["nao_conforme"] = "710_nao_conforme";
|
|
||||||
tiposSituacoes["conforme"] = "720_conforme";
|
|
||||||
tiposSituacoes["nao_aplicavel"] = "730_nao_aplicavel";
|
|
||||||
tiposSituacoes["parcial"] = "715_parcial";
|
|
||||||
})(tiposSituacoes || (exports.tiposSituacoes = tiposSituacoes = {}));
|
|
||||||
exports.corSituacoes = {
|
|
||||||
pendente: "#CCC353",
|
|
||||||
nao_conforme: "#dc3545",
|
|
||||||
conforme: "#28a745",
|
|
||||||
alerta: "#FFDE59",
|
|
||||||
};
|
|
||||||
//# sourceMappingURL=situacoes.js.map
|
|
||||||
1
dist/situacoes/situacoes.js.map
vendored
1
dist/situacoes/situacoes.js.map
vendored
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"file":"situacoes.js","sourceRoot":"","sources":["../../src/situacoes/situacoes.ts"],"names":[],"mappings":";;;AAAA,IAAY,cA4DX;AA5DD,WAAY,cAAc;IACxB,yCAAuB,CAAA;IACvB,2CAAyB,CAAA;IACzB,uCAAqB,CAAA;IAErB,yDAAuC,CAAA;IACvC,iDAA+B,CAAA;IAC/B,uDAAqC,CAAA;IACrC,2DAAyC,CAAA;IAEzC,qCAAmB,CAAA;IACnB,yCAAuB,CAAA;IACvB,uCAAqB,CAAA;IACrB,mCAAiB,CAAA;IACjB,2CAAyB,CAAA;IACzB,mDAAiC,CAAA;IAEjC,+CAA6B,CAAA;IAC7B,+DAA6C,CAAA;IAC7C,iEAA+C,CAAA;IAC/C,6CAA2B,CAAA;IAC3B,2CAAyB,CAAA;IACzB,2CAAyB,CAAA;IACzB,qDAAmC,CAAA;IACnC,6CAA2B,CAAA;IAC3B,mDAAiC,CAAA;IACjC,6CAA2B,CAAA;IAC3B,6DAA2C,CAAA;IAC3C,6DAA2C,CAAA;IAE3C,yDAAuC,CAAA;IACvC,iDAA+B,CAAA;IAC/B,2CAAyB,CAAA;IAEzB,2CAAyB,CAAA;IACzB,+CAA6B,CAAA;IAC7B,+CAA6B,CAAA;IAC7B,uDAAqC,CAAA;IACrC,iDAA+B,CAAA;IAC/B,qEAAmD,CAAA;IACnD,2CAAyB,CAAA;IACzB,+CAA6B,CAAA;IAC7B,2CAAyB,CAAA;IAEzB,qBAAqB;IACrB,YAAY;IACZ,UAAU;IACV,eAAe;IACf,YAAY;IAEZ,6CAA2B,CAAA;IAC3B,yCAAuB,CAAA;IACvB,iDAA+B,CAAA;IAC/B,6CAA2B,CAAA;IAC3B,2EAAyD,CAAA;IAEzD,mDAAiC,CAAA;IACjC,2CAAyB,CAAA;IACzB,qDAAmC,CAAA;IACnC,yCAAuB,CAAA;AACzB,CAAC,EA5DW,cAAc,8BAAd,cAAc,QA4DzB;AAEY,QAAA,YAAY,GAAoD;IAC3E,QAAQ,EAAE,SAAS;IACnB,YAAY,EAAE,SAAS;IACvB,QAAQ,EAAE,SAAS;IACnB,MAAM,EAAE,SAAS;CAClB,CAAA"}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-comuns",
|
"name": "p-comuns",
|
||||||
"version": "0.280.0",
|
"version": "0.281.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./dist/index.cjs",
|
"main": "./dist/index.cjs",
|
||||||
"module": "./dist/index.mjs",
|
"module": "./dist/index.mjs",
|
||||||
|
|
|
||||||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue