diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.npmignore b/.npmignore old mode 100644 new mode 100755 diff --git a/.npmrc b/.npmrc old mode 100644 new mode 100755 diff --git a/.vscode/settings.json b/.vscode/settings.json old mode 100644 new mode 100755 diff --git a/Documentos/biome.json b/Documentos/biome.json old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/biome.json b/biome.json old mode 100644 new mode 100755 diff --git a/build.config.ts b/build.config.ts old mode 100644 new mode 100755 diff --git a/dist-back/index.js b/dist-back/index.js index 57e8fd0..518704e 100644 --- a/dist-back/index.js +++ b/dist-back/index.js @@ -25,8 +25,6 @@ __reExport(index_exports, require("./extensoes"), module.exports); __reExport(index_exports, require("./extensoes"), module.exports); __reExport(index_exports, require("./graficosPilao"), module.exports); __reExport(index_exports, require("./local"), module.exports); -__reExport(index_exports, require("./logger"), module.exports); -__reExport(index_exports, require("./logger"), module.exports); __reExport(index_exports, require("./postgres"), module.exports); __reExport(index_exports, require("./testes-de-variaveis"), module.exports); __reExport(index_exports, require("./texto_busca"), module.exports); @@ -47,8 +45,6 @@ __reExport(index_exports, require("./variaveisComuns"), module.exports); ...require("./extensoes"), ...require("./graficosPilao"), ...require("./local"), - ...require("./logger"), - ...require("./logger"), ...require("./postgres"), ...require("./testes-de-variaveis"), ...require("./texto_busca"), diff --git a/dist-back/local/index.js b/dist-back/local/index.js index 4b0c95a..475929f 100644 --- a/dist-back/local/index.js +++ b/dist-back/local/index.js @@ -22,7 +22,7 @@ __export(local_exports, { }); module.exports = __toCommonJS(local_exports); const localValor = (chave_, valor) => { - const localStorage = globalThis.localStorage; + const localStorage = "localStorage" in globalThis ? globalThis.localStorage : void 0; if (typeof localStorage == "undefined") return null; const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_)); try { diff --git a/dist-back/logger.js b/dist-back/logger.js deleted file mode 100644 index 8f5983c..0000000 --- a/dist-back/logger.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -var __create = Object.create; -var __defProp = Object.defineProperty; -var __getOwnPropDesc = Object.getOwnPropertyDescriptor; -var __getOwnPropNames = Object.getOwnPropertyNames; -var __getProtoOf = Object.getPrototypeOf; -var __hasOwnProp = Object.prototype.hasOwnProperty; -var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); -}; -var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { - for (let key of __getOwnPropNames(from)) - if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); - } - return to; -}; -var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( - // If the importer is in node compatibility mode or this is not an ESM - // file that has been converted to a CommonJS file using a Babel- - // compatible transform (i.e. "__esModule" has not been set), then set - // "default" to the CommonJS "module.exports" for node compatibility. - isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, - mod -)); -var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); -var logger_exports = {}; -__export(logger_exports, { - defineCwd: () => defineCwd, - logger: () => logger, - postLogger: () => postLogger -}); -module.exports = __toCommonJS(logger_exports); -var import_cross_fetch = __toESM(require("cross-fetch")); -var import_variaveisComuns = require("./variaveisComuns"); -const LOKI_BASE_URL = "https://log.idz.one"; -const LOKI_ENDPOINT = "/loki/api/v1/push"; -const postLogger = async ({ - objeto -}) => { - const response = await (0, import_cross_fetch.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 = [`${(0, import_variaveisComuns.nomeVariavel)({ local })}="${local}"`, ...detalhes || []]; - } - if (__filename) { - detalhes = [ - `${(0, import_variaveisComuns.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; -}; -// Annotate the CommonJS export names for ESM import in node: -0 && (module.exports = { - defineCwd, - logger, - postLogger -}); diff --git a/dist-back/tipagemRotas.js b/dist-back/tipagemRotas.js index 05c4f5b..ce1d130 100644 --- a/dist-back/tipagemRotas.js +++ b/dist-back/tipagemRotas.js @@ -56,9 +56,8 @@ class TipagemRotas { ** "http://localhost:3000/caminho?q=query" */ endereco(query, usarComoHash) { - const url = new URL( - typeof window !== "undefined" ? window.location.href : "http://localhost" - ); + const win = typeof globalThis !== "undefined" && globalThis.window || void 0; + const url = new URL(win ? win.location.href : "http://localhost"); url.pathname = this.caminho; url.search = ""; const queryKeys = Object.entries(query); @@ -80,8 +79,9 @@ class TipagemRotas { if (this._acaoIr) { this._acaoIr(this.endereco({ ...query })); } else { - if (typeof window != "undefined") { - window.location.href = this.endereco({ ...query }); + const win = typeof globalThis !== "undefined" && globalThis.window || void 0; + if (win) { + win.location.href = this.endereco({ ...query }); } } } @@ -91,7 +91,7 @@ class TipagemRotas { */ parametros(urlEntrada) { const url = urlEntrada ? new URL(urlEntrada) : new URL( - typeof window !== "undefined" ? window.location.href : "http://localhost" + typeof globalThis !== "undefined" && globalThis.window ? globalThis.window.location.href : "http://localhost" ); const query = url.searchParams; let queryObj = Object.fromEntries(query.entries()); diff --git a/dist-front/index.d.mts b/dist-front/index.d.mts index dea271a..024d151 100644 --- a/dist-front/index.d.mts +++ b/dist-front/index.d.mts @@ -120,46 +120,6 @@ declare const graficos_pilao: { */ declare const localValor: (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 @@ -311,4 +271,4 @@ declare const nomeVariavel: (v: { [key: string]: any; }) => string; -export { TipagemRotas, type TipoLoggerSessao, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, defineCwd, erUuid, esperar, extensoes, graficos_pilao, type interfaceConsulta, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores }; +export { TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, cdn_carro_de_boi, dayjsbr, erUuid, esperar, extensoes, graficos_pilao, type interfaceConsulta, localValor, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores }; diff --git a/dist-front/index.mjs b/dist-front/index.mjs index 2c0a70b..a3bc656 100644 --- a/dist-front/index.mjs +++ b/dist-front/index.mjs @@ -1 +1 @@ -var x="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),oo=o=>`eli-${Array.from({length:o||8}).map(()=>x[(999*Math.random()|0)%x.length]).join("")}`;var d={};globalThis.cacheMemoria_cache=d;var y=(o,e,t)=>{let r=typeof o=="string"?o:typeof o=="number"?String(o):encodeURIComponent(JSON.stringify(o)),i=t&&new Date().getTime()+t*1e3;e!==void 0&&(d[r]={valor:e,validade:i});let n=d[r];if(!(n?.validade&&n.validaded,ro=y,io=o=>e=>y(o,e);var ao="00000000-0000-0000-0000-000000000000",T=(s=>(s.codigo="codigo",s.excluido="excluido",s.data_hora_criacao="data_hora_criacao",s.data_hora_atualizacao="data_hora_atualizacao",s.codigo_usuario_criacao="codigo_usuario_criacao",s.codigo_usuario_atualizacao="codigo_usuario_atualizacao",s.versao="versao",s))(T||{}),S=(e=>(e.token="token",e))(S||{}),z=(t=>(t.Usuario="usuario",t.Fornecedor="fornecedor",t))(z||{});import l from"zod";var N=(t=>(t["="]="=",t["!="]="!=",t[">"]=">",t[">="]=">=",t["<"]="<",t["<="]="<=",t.like="like",t.in="in",t))(N||{}),$=l.enum(["=","!=",">",">=","<","<=","like","in"]),po=l.object({coluna:l.string(),valor:l.any(),operador:$,ou:l.boolean().optional()});import m from"dayjs";import M from"dayjs/plugin/duration.js";import P from"dayjs/plugin/isSameOrAfter.js";import C from"dayjs/plugin/isSameOrBefore.js";import I from"dayjs/plugin/minMax.js";import U from"dayjs/plugin/relativeTime.js";import A from"dayjs/plugin/timezone.js";import E from"dayjs/plugin/utc.js";import J from"dayjs/plugin/weekOfYear.js";import"dayjs/locale/pt-br.js";m.locale("pt-br");m.extend(E);m.extend(A);m.extend(J);m.extend(C);m.extend(P);m.extend(I);m.extend(U);m.extend(M);var Oo=m;var Lo="https://carro-de-boi-idz-one.b-cdn.net";var q=[{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"}],So=o=>{let e=String(o||"").toLocaleLowerCase().split(".").pop();return q.find(r=>r.ext===e)?.tipo||"outros"};var No={Condicionantes:{grafico:"condicionantes-criadas",titulo:"Condicionantes Criadas"},Licen\u00E7as:{grafico:"licencas-criadas",titulo:"Licen\xE7as Criadas"}};var Mo=(o,e)=>{let t=globalThis.localStorage;if(typeof t>"u")return null;let r=typeof o=="string"?o:encodeURIComponent(JSON.stringify(o));try{e!==void 0&&t.setItem(r,JSON.stringify(e));let i=t.getItem(r);if(i===null)return null;try{return JSON.parse(i)}catch{return i}}catch{return null}};import K from"cross-fetch";var Co=o=>new Promise(e=>setTimeout(()=>e(!0),o)),g=o=>Object.keys(o).join("/");var D="https://log.idz.one",F="/loki/api/v1/push",G=async({objeto:o})=>{let e=await K(`${D}${F}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}).catch(t=>t);return e.ok?[o]:[o,`Erro ${e.status}: ${await e?.text?.()}`]},f="",Eo=o=>{f=o},Jo=({app:o,eProducao:e,parametros:t})=>({inquilino:r,usuario:i,parametros:n})=>async(a,s,v)=>{let{__filename:p,detalhes:c,local:u,parametros:_}=v||{},O=`${e?"":"DEV-"}${o}`;f&&p&&(p=p.replace(f,"")),u&&(c=[`${g({local:u})}="${u}"`,...c||[]]),p&&(c=[`${g({__filename:p})}="${p}"`,...c||[]]);let w=`${Date.now()}000000`,L=c?.length?`${s} | ${c.map(k=>JSON.stringify(k)).join(" | ")}`:s,j={streams:[{stream:{app:O,inquilino:r,usuario:i,level:a,...t||{},...n||{},..._||{}},values:[[w,L]]}]};return await G({objeto:j})};var b=o=>{try{return Object.fromEntries(Object.entries(o).map(([e,t])=>[e,t===void 0||t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:JSON.stringify(t,null,2)]))}catch(e){throw new Error(`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${e.message} ${e.stack}`)}},Ko=b,Do=b;var Go=()=>"Ol\xE1 Mundo! (fun\xE7\xE3o)";var Ro="Ol\xE1 Mundo! (vari\xE1vel)";var Wo=(...o)=>o.map(e=>e==null?"":String(e).normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g," ").toLowerCase()).join(" ");var h=class{constructor({caminho:e,acaoIr:t,rotulo:r}){this._partesCaminho=[];this._acaoIr=t,this._partesCaminho=(Array.isArray(e)?e:[e]).filter(Boolean).map(i=>String(i)).flatMap(i=>i.split("/")).filter(Boolean),this.rotulo=r}get caminho(){return`/${this._partesCaminho.join("/")}`}set caminho(e){this._partesCaminho=e.split("/").filter(t=>t)}endereco(e,t){let r=new URL(typeof window<"u"?window.location.href:"http://localhost");r.pathname=this.caminho,r.search="";let i=Object.entries(e);for(let[n,a]of i)r.searchParams.set(String(n),JSON.stringify(a));return r.hash="",t&&(r.hash=`#${r.search}`,r.search=""),r.href}ir(e){this._acaoIr?this._acaoIr(this.endereco({...e})):typeof window<"u"&&(window.location.href=this.endereco({...e}))}parametros(e){let t=e?new URL(e):new URL(typeof window<"u"?window.location.href:"http://localhost"),r=t.searchParams,i=Object.fromEntries(r.entries()),n=t.hash;if(n){let a=Object.fromEntries(new URLSearchParams(n.slice(1)).entries());i={...i,...a}}for(let a in i)try{i[a]=JSON.parse(i[a])}catch{console.log(`[${a}|${i[a]}] n\xE3o \xE9 um json v\xE1lido.`)}return i}};var V=(n=>(n.UN="UN",n.KG="KG",n.TON="TON",n.g="g",n["M\xB3"]="M\xB3",n.Lt="Lt",n))(V||{}),oe=[{sigla_unidade:"KG",nome:"Quilograma",sigla_normalizada:"KG",normalizar:o=>o,tipo:"massa"},{sigla_unidade:"g",nome:"Grama",sigla_normalizada:"KG",normalizar:o=>o/1e3,tipo:"massa"},{sigla_unidade:"TON",nome:"Tonelada",sigla_normalizada:"KG",normalizar:o=>o*1e3,tipo:"massa"},{sigla_unidade:"Lt",nome:"Litro",sigla_normalizada:"Lt",normalizar:o=>o,tipo:"volume"},{sigla_unidade:"M\xB3",nome:"Metro C\xFAbico",sigla_normalizada:"Lt",normalizar:o=>o*1e3,tipo:"volume"},{sigla_unidade:"UN",nome:"Unidade",sigla_normalizada:"UN",normalizar:o=>o,tipo:"unidade"}];import{NIL as R,v3 as B,v4 as Q}from"uuid";var Y=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,re=o=>Y.test(String(o||"")),H=(o,e)=>B(typeof o=="string"?o:typeof o=="number"?String(o):JSON.stringify(o),e?H(e):R),W=Q,ie=W;export{h as TipagemRotas,oo as aleatorio,y as cacheM,io as cacheMFixo,ro as cacheMemoria,T as camposComuns,Lo as cdn_carro_de_boi,Oo as dayjsbr,Eo as defineCwd,Y as erUuid,Co as esperar,q as extensoes,No as graficos_pilao,Mo as localValor,Jo as logger,g as nomeVariavel,Do as objetoPg,N as operadores,b as paraObjetoRegistroPg,Ko as pgObjeto,G as postLogger,V as siglas_unidades_medida,Wo as texto_busca,So as tipoArquivo,z as tipoUsuarioResiduos,S as tx,Go as umaFuncao,Ro as umaVariavel,oe as unidades_medida,ie as uuid,H as uuidV3,W as uuidV4,ao as uuid_null,re as validarUuid,to as verCacheM,po as zFiltro,$ as zOperadores}; +var c="ABCDEFGHIJKLMNOPQRSTUVWXYZ".split(""),P=e=>`eli-${Array.from({length:e||8}).map(()=>c[(999*Math.random()|0)%c.length]).join("")}`;var l={};globalThis.cacheMemoria_cache=l;var d=(e,o,t)=>{let r=typeof e=="string"?e:typeof e=="number"?String(e):encodeURIComponent(JSON.stringify(e)),i=t&&new Date().getTime()+t*1e3;o!==void 0&&(l[r]={valor:o,validade:i});let n=l[r];if(!(n?.validade&&n.validadel,F=d,G=e=>o=>d(e,o);var $="00000000-0000-0000-0000-000000000000",g=(m=>(m.codigo="codigo",m.excluido="excluido",m.data_hora_criacao="data_hora_criacao",m.data_hora_atualizacao="data_hora_atualizacao",m.codigo_usuario_criacao="codigo_usuario_criacao",m.codigo_usuario_atualizacao="codigo_usuario_atualizacao",m.versao="versao",m))(g||{}),x=(o=>(o.token="token",o))(x||{}),h=(t=>(t.Usuario="usuario",t.Fornecedor="fornecedor",t))(h||{});import p from"zod";var y=(t=>(t["="]="=",t["!="]="!=",t[">"]=">",t[">="]=">=",t["<"]="<",t["<="]="<=",t.like="like",t.in="in",t))(y||{}),b=p.enum(["=","!=",">",">=","<","<=","like","in"]),R=p.object({coluna:p.string(),valor:p.any(),operador:b,ou:p.boolean().optional()});import a from"dayjs";import v from"dayjs/plugin/duration.js";import _ from"dayjs/plugin/isSameOrAfter.js";import T from"dayjs/plugin/isSameOrBefore.js";import w from"dayjs/plugin/minMax.js";import O from"dayjs/plugin/relativeTime.js";import j from"dayjs/plugin/timezone.js";import z from"dayjs/plugin/utc.js";import k from"dayjs/plugin/weekOfYear.js";import"dayjs/locale/pt-br.js";a.locale("pt-br");a.extend(z);a.extend(j);a.extend(k);a.extend(T);a.extend(_);a.extend(w);a.extend(O);a.extend(v);var ie=a;var re="https://carro-de-boi-idz-one.b-cdn.net";var S=[{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"}],pe=e=>{let o=String(e||"").toLocaleLowerCase().split(".").pop();return S.find(r=>r.ext===o)?.tipo||"outros"};var ce={Condicionantes:{grafico:"condicionantes-criadas",titulo:"Condicionantes Criadas"},Licen\u00E7as:{grafico:"licencas-criadas",titulo:"Licen\xE7as Criadas"}};var ue=(e,o)=>{let t="localStorage"in globalThis?globalThis.localStorage:void 0;if(typeof t>"u")return null;let r=typeof e=="string"?e:encodeURIComponent(JSON.stringify(e));try{o!==void 0&&t.setItem(r,JSON.stringify(o));let i=t.getItem(r);if(i===null)return null;try{return JSON.parse(i)}catch{return i}}catch{return null}};var u=e=>{try{return Object.fromEntries(Object.entries(e).map(([o,t])=>[o,t===void 0||t==null||typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:JSON.stringify(t,null,2)]))}catch(o){throw new Error(`Erro na fun\xE7\xE3o paraObjetoRegistroPg: ${o.message} ${o.stack}`)}},ge=u,xe=u;var ye=()=>"Ol\xE1 Mundo! (fun\xE7\xE3o)";var ve="Ol\xE1 Mundo! (vari\xE1vel)";var je=(...e)=>e.map(o=>o==null?"":String(o).normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/\s+/g," ").toLowerCase()).join(" ");var f=class{constructor({caminho:o,acaoIr:t,rotulo:r}){this._partesCaminho=[];this._acaoIr=t,this._partesCaminho=(Array.isArray(o)?o:[o]).filter(Boolean).map(i=>String(i)).flatMap(i=>i.split("/")).filter(Boolean),this.rotulo=r}get caminho(){return`/${this._partesCaminho.join("/")}`}set caminho(o){this._partesCaminho=o.split("/").filter(t=>t)}endereco(o,t){let r=typeof globalThis<"u"&&globalThis.window||void 0,i=new URL(r?r.location.href:"http://localhost");i.pathname=this.caminho,i.search="";let n=Object.entries(o);for(let[s,m]of n)i.searchParams.set(String(s),JSON.stringify(m));return i.hash="",t&&(i.hash=`#${i.search}`,i.search=""),i.href}ir(o){if(this._acaoIr)this._acaoIr(this.endereco({...o}));else{let t=typeof globalThis<"u"&&globalThis.window||void 0;t&&(t.location.href=this.endereco({...o}))}}parametros(o){let t=o?new URL(o):new URL(typeof globalThis<"u"&&globalThis.window?globalThis.window.location.href:"http://localhost"),r=t.searchParams,i=Object.fromEntries(r.entries()),n=t.hash;if(n){let s=Object.fromEntries(new URLSearchParams(n.slice(1)).entries());i={...i,...s}}for(let s in i)try{i[s]=JSON.parse(i[s])}catch{console.log(`[${s}|${i[s]}] n\xE3o \xE9 um json v\xE1lido.`)}return i}};var N=(n=>(n.UN="UN",n.KG="KG",n.TON="TON",n.g="g",n["M\xB3"]="M\xB3",n.Lt="Lt",n))(N||{}),Se=[{sigla_unidade:"KG",nome:"Quilograma",sigla_normalizada:"KG",normalizar:e=>e,tipo:"massa"},{sigla_unidade:"g",nome:"Grama",sigla_normalizada:"KG",normalizar:e=>e/1e3,tipo:"massa"},{sigla_unidade:"TON",nome:"Tonelada",sigla_normalizada:"KG",normalizar:e=>e*1e3,tipo:"massa"},{sigla_unidade:"Lt",nome:"Litro",sigla_normalizada:"Lt",normalizar:e=>e,tipo:"volume"},{sigla_unidade:"M\xB3",nome:"Metro C\xFAbico",sigla_normalizada:"Lt",normalizar:e=>e*1e3,tipo:"volume"},{sigla_unidade:"UN",nome:"Unidade",sigla_normalizada:"UN",normalizar:e=>e,tipo:"unidade"}];import{NIL as L,v3 as M,v4 as U}from"uuid";var C=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,Me=e=>C.test(String(e||"")),I=(e,o)=>M(typeof e=="string"?e:typeof e=="number"?String(e):JSON.stringify(e),o?I(o):L),A=U,Ue=A;var Ie=e=>new Promise(o=>setTimeout(()=>o(!0),e)),Ae=e=>Object.keys(e).join("/");export{f as TipagemRotas,P as aleatorio,d as cacheM,G as cacheMFixo,F as cacheMemoria,g as camposComuns,re as cdn_carro_de_boi,ie as dayjsbr,C as erUuid,Ie as esperar,S as extensoes,ce as graficos_pilao,ue as localValor,Ae as nomeVariavel,xe as objetoPg,y as operadores,u as paraObjetoRegistroPg,ge as pgObjeto,N as siglas_unidades_medida,je as texto_busca,pe as tipoArquivo,h as tipoUsuarioResiduos,x as tx,ye as umaFuncao,ve as umaVariavel,Se as unidades_medida,Ue as uuid,I as uuidV3,A as uuidV4,$ as uuid_null,Me as validarUuid,J as verCacheM,R as zFiltro,b as zOperadores}; diff --git a/package.json b/package.json old mode 100644 new mode 100755 index 164baac..84738c2 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-comuns", - "version": "0.292.0", + "version": "0.297.0", "description": "", "main": "./dist-front/index.mjs", "module": "./dist-front/index.mjs", @@ -27,7 +27,7 @@ "license": "ISC", "dependencies": { "cross-fetch": "4.1.0", - "dayjs": "^1.11.18", + "dayjs": "1.11.13", "uuid": "^11.1.0", "zod": "4.1.4" }, @@ -41,7 +41,7 @@ }, "peerDependencies": { "cross-fetch": "4.1.0", - "dayjs": "^1.11.18", + "dayjs": "1.11.13", "uuid": "^11.1.0", "zod": "4.1.4" } diff --git a/pacote.tgz b/pacote.tgz index 7b6064c..f755e00 100644 Binary files a/pacote.tgz and b/pacote.tgz differ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml old mode 100644 new mode 100755 index 138e2de..a9d2534 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ importers: specifier: 4.1.0 version: 4.1.0 dayjs: - specifier: ^1.11.18 - version: 1.11.18 + specifier: 1.11.13 + version: 1.11.13 uuid: specifier: ^11.1.0 version: 11.1.0 @@ -658,8 +658,8 @@ packages: resolution: {integrity: sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==} engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'} - dayjs@1.11.18: - resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==} + dayjs@1.11.13: + resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} debug@4.4.3: resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} @@ -1971,7 +1971,7 @@ snapshots: dependencies: css-tree: 2.2.1 - dayjs@1.11.18: {} + dayjs@1.11.13: {} debug@4.4.3: dependencies: diff --git a/requisicoes.rest b/requisicoes.rest old mode 100644 new mode 100755 diff --git a/src/aleatorio.ts b/src/aleatorio.ts old mode 100644 new mode 100755 diff --git a/src/cacheMemoria.ts b/src/cacheMemoria.ts old mode 100644 new mode 100755 diff --git a/src/constantes.ts b/src/constantes.ts old mode 100644 new mode 100755 diff --git a/src/consulta.ts b/src/consulta.ts old mode 100644 new mode 100755 diff --git a/src/dayjs.ts b/src/dayjs.ts old mode 100644 new mode 100755 diff --git a/src/ecosistema/index.ts b/src/ecosistema/index.ts old mode 100644 new mode 100755 diff --git a/src/ecosistema/urls.ts b/src/ecosistema/urls.ts old mode 100644 new mode 100755 diff --git a/src/extensoes.ts b/src/extensoes.ts old mode 100644 new mode 100755 diff --git a/src/graficosPilao.ts b/src/graficosPilao.ts old mode 100644 new mode 100755 diff --git a/src/index.ts b/src/index.ts old mode 100644 new mode 100755 index 870b6a7..603605a --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,6 @@ export * from "./extensoes" export * from "./extensoes" export * from "./graficosPilao" export * from "./local" -export * from "./logger" -export * from "./logger" export * from "./postgres" export * from "./testes-de-variaveis" export * from "./texto_busca" diff --git a/src/instalarAmbiente.ts b/src/instalarAmbiente.ts old mode 100644 new mode 100755 diff --git a/src/local/index.ts b/src/local/index.ts old mode 100644 new mode 100755 index 94a7eed..210f40e --- a/src/local/index.ts +++ b/src/local/index.ts @@ -6,8 +6,8 @@ export const localValor = ( chave_: string | any, valor?: T | null, ): T | null => { - const localStorage = globalThis.localStorage - + const localStorage = + "localStorage" in globalThis ? (globalThis as any).localStorage : undefined if (typeof localStorage == "undefined") return null const chave = diff --git a/src/logger.ts b/src/logger.ts deleted file mode 100644 index 7dec9f1..0000000 --- a/src/logger.ts +++ /dev/null @@ -1,126 +0,0 @@ -import crossFetch from "cross-fetch" -import { nomeVariavel } from "./variaveisComuns" - -const LOKI_BASE_URL = "https://log.idz.one" -const LOKI_ENDPOINT = "/loki/api/v1/push" -export type tipoLokiObjeto = { - streams: { - stream: { - [k: string]: string - } - values: [string, string][] - }[] -} - -export const postLogger = async ({ - objeto, -}: { - objeto: tipoLokiObjeto -}): Promise<[objeto: tipoLokiObjeto, erro?: string]> => { - 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 = "" - -/** define a localização da pasta do projeto */ -export const defineCwd = (novoCwd: string) => { - cwd = novoCwd -} - -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 } -} - -export type tipoLoggerLog = ( - level: tipoLevel, - mensagem: string, - op_tipoLog?: tipoLog, -) => Promise<[objeto: tipoLokiObjeto, erro?: string]> - -export type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog - -export type tipoLogger = (amb: { - app: string - eProducao: boolean - parametros?: { - [k: string]: string - } -}) => TipoLoggerSessao - -export const logger: tipoLogger = - ({ 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: tipoLokiObjeto["streams"][number] = { - stream: { - app, - inquilino, - usuario, - level, - ...(parametrosAmbiente || {}), - ...(parametrosSessao || {}), - ...(parametrosLog || {}), - }, - values: [ - [ - timestamp, - mainLog, // Linha de log direta - ], - ], - } - - const objeto: tipoLokiObjeto = { streams: [payload] } - - const response = await postLogger({ objeto }) - - return response - } diff --git a/src/postgres.ts b/src/postgres.ts old mode 100644 new mode 100755 diff --git a/src/teste.ts b/src/teste.ts old mode 100644 new mode 100755 diff --git a/src/testes-de-variaveis/index.ts b/src/testes-de-variaveis/index.ts old mode 100644 new mode 100755 diff --git a/src/testes-de-variaveis/umaFuncao.ts b/src/testes-de-variaveis/umaFuncao.ts old mode 100644 new mode 100755 diff --git a/src/testes-de-variaveis/umaVariavel.ts b/src/testes-de-variaveis/umaVariavel.ts old mode 100644 new mode 100755 diff --git a/src/testes/TipagemRotas.test.ts b/src/testes/TipagemRotas.test.ts old mode 100644 new mode 100755 diff --git a/src/texto_busca.ts b/src/texto_busca.ts old mode 100644 new mode 100755 diff --git a/src/tipagemRotas.ts b/src/tipagemRotas.ts old mode 100644 new mode 100755 index 8755a30..92ce985 --- a/src/tipagemRotas.ts +++ b/src/tipagemRotas.ts @@ -63,9 +63,10 @@ export class TipagemRotas { */ endereco(query: T, usarComoHash?: boolean) { - const url = new URL( - typeof window !== "undefined" ? window.location.href : "http://localhost", - ) + const win = + (typeof globalThis !== "undefined" && (globalThis as any).window) || + undefined + const url = new URL(win ? win.location.href : "http://localhost") url.pathname = this.caminho @@ -95,8 +96,11 @@ export class TipagemRotas { if (this._acaoIr) { this._acaoIr(this.endereco({ ...query })) } else { - if (typeof window != "undefined") { - window.location.href = this.endereco({ ...query }) + const win = + (typeof globalThis !== "undefined" && (globalThis as any).window) || + undefined + if (win) { + win.location.href = this.endereco({ ...query }) } } } @@ -110,8 +114,8 @@ export class TipagemRotas { const url = urlEntrada ? new URL(urlEntrada) : new URL( - typeof window !== "undefined" - ? window.location.href + typeof globalThis !== "undefined" && (globalThis as any).window + ? (globalThis as any).window.location.href : "http://localhost", ) const query = url.searchParams diff --git a/src/unidades_medida.ts b/src/unidades_medida.ts old mode 100644 new mode 100755 diff --git a/src/uuid.ts b/src/uuid.ts old mode 100644 new mode 100755 diff --git a/src/variaveisComuns.ts b/src/variaveisComuns.ts old mode 100644 new mode 100755 diff --git a/tsconfig-back.json b/tsconfig-back.json old mode 100644 new mode 100755 diff --git a/tsconfig-front.json b/tsconfig-front.json old mode 100644 new mode 100755 diff --git a/tsconfig.json b/tsconfig.json old mode 100644 new mode 100755 diff --git a/tsup/como usar.md b/tsup/como usar.md old mode 100644 new mode 100755 diff --git a/tsup/tsup.config.back.ts b/tsup/tsup.config.back.ts old mode 100644 new mode 100755 diff --git a/tsup/tsup.config.front.interno.ts b/tsup/tsup.config.front.interno.ts old mode 100644 new mode 100755 diff --git a/tsup/tsup.config.front.ts b/tsup/tsup.config.front.ts old mode 100644 new mode 100755 diff --git a/tsup/tsup.config.interno.ts b/tsup/tsup.config.interno.ts old mode 100644 new mode 100755 diff --git a/tsup/tsup.config.ts b/tsup/tsup.config.ts old mode 100644 new mode 100755