Compare commits
No commits in common. "336e3ffc480d8a2c21cb4514cb3f3bd43b04499d" and "d783fa12940a5b1bcafa5038bd1c49c3f5f9b7fc" have entirely different histories.
336e3ffc48
...
d783fa1294
52 changed files with 304 additions and 79 deletions
0
.gitignore
vendored
Executable file → Normal file
0
.gitignore
vendored
Executable file → Normal file
0
.npmignore
Executable file → Normal file
0
.npmignore
Executable file → Normal file
0
.npmrc
Executable file → Normal file
0
.npmrc
Executable file → Normal file
0
.vscode/settings.json
vendored
Executable file → Normal file
0
.vscode/settings.json
vendored
Executable file → Normal file
0
Documentos/biome.json
Executable file → Normal file
0
Documentos/biome.json
Executable file → Normal file
0
README.md
Executable file → Normal file
0
README.md
Executable file → Normal file
0
biome.json
Executable file → Normal file
0
biome.json
Executable file → Normal file
0
build.config.ts
Executable file → Normal file
0
build.config.ts
Executable file → Normal file
|
|
@ -1,37 +0,0 @@
|
||||||
"use strict";
|
|
||||||
var __defProp = Object.defineProperty;
|
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
||||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
||||||
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
||||||
var graficosPilao_exports = {};
|
|
||||||
__export(graficosPilao_exports, {
|
|
||||||
graficos_pilao: () => graficos_pilao
|
|
||||||
});
|
|
||||||
module.exports = __toCommonJS(graficosPilao_exports);
|
|
||||||
const graficos_pilao = {
|
|
||||||
Condicionantes: {
|
|
||||||
grafico: "condicionantes-criadas",
|
|
||||||
titulo: "Condicionantes Criadas"
|
|
||||||
},
|
|
||||||
Licen\u00E7as: {
|
|
||||||
grafico: "licencas-criadas",
|
|
||||||
titulo: "Licen\xE7as Criadas"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
// Annotate the CommonJS export names for ESM import in node:
|
|
||||||
0 && (module.exports = {
|
|
||||||
graficos_pilao
|
|
||||||
});
|
|
||||||
|
|
@ -24,6 +24,8 @@ __reExport(index_exports, require("./ecosistema"), module.exports);
|
||||||
__reExport(index_exports, require("./extensoes"), module.exports);
|
__reExport(index_exports, require("./extensoes"), module.exports);
|
||||||
__reExport(index_exports, require("./extensoes"), module.exports);
|
__reExport(index_exports, require("./extensoes"), module.exports);
|
||||||
__reExport(index_exports, require("./local"), 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("./postgres"), module.exports);
|
||||||
__reExport(index_exports, require("./produtos"), module.exports);
|
__reExport(index_exports, require("./produtos"), module.exports);
|
||||||
__reExport(index_exports, require("./situacoes"), module.exports);
|
__reExport(index_exports, require("./situacoes"), module.exports);
|
||||||
|
|
@ -45,6 +47,8 @@ __reExport(index_exports, require("./variaveisComuns"), module.exports);
|
||||||
...require("./extensoes"),
|
...require("./extensoes"),
|
||||||
...require("./extensoes"),
|
...require("./extensoes"),
|
||||||
...require("./local"),
|
...require("./local"),
|
||||||
|
...require("./logger"),
|
||||||
|
...require("./logger"),
|
||||||
...require("./postgres"),
|
...require("./postgres"),
|
||||||
...require("./produtos"),
|
...require("./produtos"),
|
||||||
...require("./situacoes"),
|
...require("./situacoes"),
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ __export(local_exports, {
|
||||||
});
|
});
|
||||||
module.exports = __toCommonJS(local_exports);
|
module.exports = __toCommonJS(local_exports);
|
||||||
const localValor = (chave_, valor) => {
|
const localValor = (chave_, valor) => {
|
||||||
const localStorage = "localStorage" in globalThis ? globalThis.localStorage : void 0;
|
const localStorage = globalThis.localStorage;
|
||||||
if (typeof localStorage == "undefined") return null;
|
if (typeof localStorage == "undefined") return null;
|
||||||
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
const chave = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_));
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
106
dist-back/logger.js
Normal file
106
dist-back/logger.js
Normal file
|
|
@ -0,0 +1,106 @@
|
||||||
|
"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
|
||||||
|
});
|
||||||
|
|
@ -56,8 +56,9 @@ class TipagemRotas {
|
||||||
** "http://localhost:3000/caminho?q=query"
|
** "http://localhost:3000/caminho?q=query"
|
||||||
*/
|
*/
|
||||||
endereco(query, usarComoHash) {
|
endereco(query, usarComoHash) {
|
||||||
const win = typeof globalThis !== "undefined" && globalThis.window || void 0;
|
const url = new URL(
|
||||||
const url = new URL(win ? win.location.href : "http://localhost");
|
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||||
|
);
|
||||||
url.pathname = this.caminho;
|
url.pathname = this.caminho;
|
||||||
url.search = "";
|
url.search = "";
|
||||||
const queryKeys = Object.entries(query);
|
const queryKeys = Object.entries(query);
|
||||||
|
|
@ -79,9 +80,8 @@ class TipagemRotas {
|
||||||
if (this._acaoIr) {
|
if (this._acaoIr) {
|
||||||
this._acaoIr(this.endereco({ ...query }));
|
this._acaoIr(this.endereco({ ...query }));
|
||||||
} else {
|
} else {
|
||||||
const win = typeof globalThis !== "undefined" && globalThis.window || void 0;
|
if (typeof window != "undefined") {
|
||||||
if (win) {
|
window.location.href = this.endereco({ ...query });
|
||||||
win.location.href = this.endereco({ ...query });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ class TipagemRotas {
|
||||||
*/
|
*/
|
||||||
parametros(urlEntrada) {
|
parametros(urlEntrada) {
|
||||||
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
const url = urlEntrada ? new URL(urlEntrada) : new URL(
|
||||||
typeof globalThis !== "undefined" && globalThis.window ? globalThis.window.location.href : "http://localhost"
|
typeof window !== "undefined" ? window.location.href : "http://localhost"
|
||||||
);
|
);
|
||||||
const query = url.searchParams;
|
const query = url.searchParams;
|
||||||
let queryObj = Object.fromEntries(query.entries());
|
let queryObj = Object.fromEntries(query.entries());
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,46 @@ declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArqu
|
||||||
*/
|
*/
|
||||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
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
|
* Trata um objeto para ser imput para postgres
|
||||||
* @param entrada
|
* @param entrada
|
||||||
|
|
@ -322,4 +362,4 @@ declare const nomeVariavel: (v: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}) => string;
|
}) => string;
|
||||||
|
|
||||||
export { Produtos, TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, dayjsbr, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
export { Produtos, TipagemRotas, type TipoLoggerSessao, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, dayjsbr, defineCwd, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
6
package.json
Executable file → Normal file
6
package.json
Executable file → Normal file
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-comuns",
|
"name": "p-comuns",
|
||||||
"version": "0.299.0",
|
"version": "0.298.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./dist-front/index.mjs",
|
"main": "./dist-front/index.mjs",
|
||||||
"module": "./dist-front/index.mjs",
|
"module": "./dist-front/index.mjs",
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-fetch": "4.1.0",
|
"cross-fetch": "4.1.0",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "^1.11.18",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"zod": "4.1.4"
|
"zod": "4.1.4"
|
||||||
},
|
},
|
||||||
|
|
@ -41,7 +41,7 @@
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"cross-fetch": "4.1.0",
|
"cross-fetch": "4.1.0",
|
||||||
"dayjs": "1.11.13",
|
"dayjs": "^1.11.18",
|
||||||
"uuid": "^11.1.0",
|
"uuid": "^11.1.0",
|
||||||
"zod": "4.1.4"
|
"zod": "4.1.4"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
10
pnpm-lock.yaml
generated
Executable file → Normal file
10
pnpm-lock.yaml
generated
Executable file → Normal file
|
|
@ -12,8 +12,8 @@ importers:
|
||||||
specifier: 4.1.0
|
specifier: 4.1.0
|
||||||
version: 4.1.0
|
version: 4.1.0
|
||||||
dayjs:
|
dayjs:
|
||||||
specifier: 1.11.13
|
specifier: ^1.11.18
|
||||||
version: 1.11.13
|
version: 1.11.18
|
||||||
uuid:
|
uuid:
|
||||||
specifier: ^11.1.0
|
specifier: ^11.1.0
|
||||||
version: 11.1.0
|
version: 11.1.0
|
||||||
|
|
@ -658,8 +658,8 @@ packages:
|
||||||
resolution: {integrity: sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==}
|
resolution: {integrity: sha512-0LrrStPOdJj+SPCCrGhzryycLjwcgUSHBtxNA8aIDxf0GLsRh1cKYhB00Gd1lDOS4yGH69+SNn13+TWbVHETFQ==}
|
||||||
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'}
|
engines: {node: ^10 || ^12.20.0 || ^14.13.0 || >=15.0.0, npm: '>=7.0.0'}
|
||||||
|
|
||||||
dayjs@1.11.13:
|
dayjs@1.11.18:
|
||||||
resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==}
|
resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==}
|
||||||
|
|
||||||
debug@4.4.3:
|
debug@4.4.3:
|
||||||
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
|
resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==}
|
||||||
|
|
@ -1971,7 +1971,7 @@ snapshots:
|
||||||
dependencies:
|
dependencies:
|
||||||
css-tree: 2.2.1
|
css-tree: 2.2.1
|
||||||
|
|
||||||
dayjs@1.11.13: {}
|
dayjs@1.11.18: {}
|
||||||
|
|
||||||
debug@4.4.3:
|
debug@4.4.3:
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
|
||||||
0
requisicoes.rest
Executable file → Normal file
0
requisicoes.rest
Executable file → Normal file
0
src/aleatorio.ts
Executable file → Normal file
0
src/aleatorio.ts
Executable file → Normal file
0
src/cacheMemoria.ts
Executable file → Normal file
0
src/cacheMemoria.ts
Executable file → Normal file
0
src/constantes.ts
Executable file → Normal file
0
src/constantes.ts
Executable file → Normal file
0
src/consulta.ts
Executable file → Normal file
0
src/consulta.ts
Executable file → Normal file
0
src/dayjs.ts
Executable file → Normal file
0
src/dayjs.ts
Executable file → Normal file
0
src/ecosistema/index.ts
Executable file → Normal file
0
src/ecosistema/index.ts
Executable file → Normal file
0
src/ecosistema/urls.ts
Executable file → Normal file
0
src/ecosistema/urls.ts
Executable file → Normal file
0
src/extensoes.ts
Executable file → Normal file
0
src/extensoes.ts
Executable file → Normal file
|
|
@ -1,12 +0,0 @@
|
||||||
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
Executable file → Normal file
2
src/index.ts
Executable file → Normal file
|
|
@ -7,6 +7,8 @@ export * from "./ecosistema"
|
||||||
export * from "./extensoes"
|
export * from "./extensoes"
|
||||||
export * from "./extensoes"
|
export * from "./extensoes"
|
||||||
export * from "./local"
|
export * from "./local"
|
||||||
|
export * from "./logger"
|
||||||
|
export * from "./logger"
|
||||||
export * from "./postgres"
|
export * from "./postgres"
|
||||||
export * from "./produtos"
|
export * from "./produtos"
|
||||||
export * from "./situacoes"
|
export * from "./situacoes"
|
||||||
|
|
|
||||||
0
src/instalarAmbiente.ts
Executable file → Normal file
0
src/instalarAmbiente.ts
Executable file → Normal file
4
src/local/index.ts
Executable file → Normal file
4
src/local/index.ts
Executable file → Normal file
|
|
@ -6,8 +6,8 @@ export const localValor = <T>(
|
||||||
chave_: string | any,
|
chave_: string | any,
|
||||||
valor?: T | null,
|
valor?: T | null,
|
||||||
): T | null => {
|
): T | null => {
|
||||||
const localStorage =
|
const localStorage = globalThis.localStorage
|
||||||
"localStorage" in globalThis ? (globalThis as any).localStorage : undefined
|
|
||||||
if (typeof localStorage == "undefined") return null
|
if (typeof localStorage == "undefined") return null
|
||||||
|
|
||||||
const chave =
|
const chave =
|
||||||
|
|
|
||||||
126
src/logger.ts
Normal file
126
src/logger.ts
Normal file
|
|
@ -0,0 +1,126 @@
|
||||||
|
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
Executable file → Normal file
0
src/postgres.ts
Executable file → Normal file
0
src/teste.ts
Executable file → Normal file
0
src/teste.ts
Executable file → Normal file
0
src/testes-de-variaveis/index.ts
Executable file → Normal file
0
src/testes-de-variaveis/index.ts
Executable file → Normal file
0
src/testes-de-variaveis/umaFuncao.ts
Executable file → Normal file
0
src/testes-de-variaveis/umaFuncao.ts
Executable file → Normal file
0
src/testes-de-variaveis/umaVariavel.ts
Executable file → Normal file
0
src/testes-de-variaveis/umaVariavel.ts
Executable file → Normal file
0
src/testes/TipagemRotas.test.ts
Executable file → Normal file
0
src/testes/TipagemRotas.test.ts
Executable file → Normal file
0
src/texto_busca.ts
Executable file → Normal file
0
src/texto_busca.ts
Executable file → Normal file
18
src/tipagemRotas.ts
Executable file → Normal file
18
src/tipagemRotas.ts
Executable file → Normal file
|
|
@ -63,10 +63,9 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
endereco(query: T, usarComoHash?: boolean) {
|
endereco(query: T, usarComoHash?: boolean) {
|
||||||
const win =
|
const url = new URL(
|
||||||
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
|
typeof window !== "undefined" ? window.location.href : "http://localhost",
|
||||||
undefined
|
)
|
||||||
const url = new URL(win ? win.location.href : "http://localhost")
|
|
||||||
|
|
||||||
url.pathname = this.caminho
|
url.pathname = this.caminho
|
||||||
|
|
||||||
|
|
@ -96,11 +95,8 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
||||||
if (this._acaoIr) {
|
if (this._acaoIr) {
|
||||||
this._acaoIr(this.endereco({ ...query }))
|
this._acaoIr(this.endereco({ ...query }))
|
||||||
} else {
|
} else {
|
||||||
const win =
|
if (typeof window != "undefined") {
|
||||||
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
|
window.location.href = this.endereco({ ...query })
|
||||||
undefined
|
|
||||||
if (win) {
|
|
||||||
win.location.href = this.endereco({ ...query })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -114,8 +110,8 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
||||||
const url = urlEntrada
|
const url = urlEntrada
|
||||||
? new URL(urlEntrada)
|
? new URL(urlEntrada)
|
||||||
: new URL(
|
: new URL(
|
||||||
typeof globalThis !== "undefined" && (globalThis as any).window
|
typeof window !== "undefined"
|
||||||
? (globalThis as any).window.location.href
|
? window.location.href
|
||||||
: "http://localhost",
|
: "http://localhost",
|
||||||
)
|
)
|
||||||
const query = url.searchParams
|
const query = url.searchParams
|
||||||
|
|
|
||||||
0
src/unidades_medida.ts
Executable file → Normal file
0
src/unidades_medida.ts
Executable file → Normal file
0
src/uuid.ts
Executable file → Normal file
0
src/uuid.ts
Executable file → Normal file
0
src/variaveisComuns.ts
Executable file → Normal file
0
src/variaveisComuns.ts
Executable file → Normal file
0
tsconfig-back.json
Executable file → Normal file
0
tsconfig-back.json
Executable file → Normal file
0
tsconfig-front.json
Executable file → Normal file
0
tsconfig-front.json
Executable file → Normal file
0
tsconfig.json
Executable file → Normal file
0
tsconfig.json
Executable file → Normal file
0
tsup/como usar.md
Executable file → Normal file
0
tsup/como usar.md
Executable file → Normal file
0
tsup/tsup.config.back.ts
Executable file → Normal file
0
tsup/tsup.config.back.ts
Executable file → Normal file
0
tsup/tsup.config.front.interno.ts
Executable file → Normal file
0
tsup/tsup.config.front.interno.ts
Executable file → Normal file
0
tsup/tsup.config.front.ts
Executable file → Normal file
0
tsup/tsup.config.front.ts
Executable file → Normal file
0
tsup/tsup.config.interno.ts
Executable file → Normal file
0
tsup/tsup.config.interno.ts
Executable file → Normal file
0
tsup/tsup.config.ts
Executable file → Normal file
0
tsup/tsup.config.ts
Executable file → Normal file
Loading…
Add table
Add a link
Reference in a new issue