Merge branch 'master-x'

This commit is contained in:
Luiz Silva 2026-02-08 20:33:27 -03:00
commit 336e3ffc48
52 changed files with 79 additions and 304 deletions

0
src/aleatorio.ts Normal file → Executable file
View file

0
src/cacheMemoria.ts Normal file → Executable file
View file

0
src/constantes.ts Normal file → Executable file
View file

0
src/consulta.ts Normal file → Executable file
View file

0
src/dayjs.ts Normal file → Executable file
View file

0
src/ecosistema/index.ts Normal file → Executable file
View file

0
src/ecosistema/urls.ts Normal file → Executable file
View file

0
src/extensoes.ts Normal file → Executable file
View file

12
src/graficosPilao.ts Executable file
View file

@ -0,0 +1,12 @@
export const graficos_pilao: {
[k: string]: { grafico: string; titulo: string }
} = {
Condicionantes: {
grafico: "condicionantes-criadas",
titulo: "Condicionantes Criadas",
},
Licenças: {
grafico: "licencas-criadas",
titulo: "Licenças Criadas",
},
}

2
src/index.ts Normal file → Executable file
View file

@ -7,8 +7,6 @@ export * from "./ecosistema"
export * from "./extensoes"
export * from "./extensoes"
export * from "./local"
export * from "./logger"
export * from "./logger"
export * from "./postgres"
export * from "./produtos"
export * from "./situacoes"

0
src/instalarAmbiente.ts Normal file → Executable file
View file

4
src/local/index.ts Normal file → Executable file
View file

@ -6,8 +6,8 @@ export const localValor = <T>(
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 =

View file

@ -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
}

0
src/postgres.ts Normal file → Executable file
View file

0
src/teste.ts Normal file → Executable file
View file

0
src/testes-de-variaveis/index.ts Normal file → Executable file
View file

0
src/testes-de-variaveis/umaFuncao.ts Normal file → Executable file
View file

0
src/testes-de-variaveis/umaVariavel.ts Normal file → Executable file
View file

0
src/testes/TipagemRotas.test.ts Normal file → Executable file
View file

0
src/texto_busca.ts Normal file → Executable file
View file

18
src/tipagemRotas.ts Normal file → Executable file
View file

@ -63,9 +63,10 @@ export class TipagemRotas<T extends { [q: string]: any }> {
*/
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<T extends { [q: string]: any }> {
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<T extends { [q: string]: any }> {
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

0
src/unidades_medida.ts Normal file → Executable file
View file

0
src/uuid.ts Normal file → Executable file
View file

0
src/variaveisComuns.ts Normal file → Executable file
View file