Compare commits

...
Sign in to create a new pull request.

24 commits

Author SHA1 Message Date
f5c4db0701 . 2026-04-15 12:24:38 -03:00
7a6d79fe12 build 2026-04-15 11:55:17 -03:00
691387ff9a melhoria de quebra 2026-04-15 10:46:32 -03:00
b4d005fdae atualização de biome 2026-04-15 09:45:25 -03:00
8684840a05 correçẽos 2026-04-15 09:42:15 -03:00
d029faf8f0 Merge branch 'master-biome' 2026-04-15 09:40:31 -03:00
c4e83f5157 atualização de biome 2026-04-15 09:38:29 -03:00
1767c5d39e build 2026-04-14 14:07:23 -03:00
91c872ea90 pacote 2026-04-14 14:00:37 -03:00
ade38e70b9 pacote 2026-04-14 13:58:09 -03:00
8bc2127e6c merge 2026-04-14 13:57:56 -03:00
52dcec90ef fix: ajuste tipagem para auditoria 2026-04-14 13:57:21 -03:00
eeb4b12386 . 2026-04-14 10:38:46 -03:00
ed62e06056 . 2026-04-14 10:32:47 -03:00
02d47d893a build 2026-04-13 17:31:05 -03:00
9d400be402 Merge branch 'master-xs' 2026-04-13 17:30:38 -03:00
8b47aa470e pacote 2026-04-13 17:28:47 -03:00
4d82c1abea Merge branch 'master-biome-ia' 2026-04-13 17:28:22 -03:00
11f18a1b19 Merge branch 'master-dayjs' 2026-04-13 17:27:56 -03:00
2fa311f9ca pacote 2026-04-13 17:26:47 -03:00
f0c9f770aa pacote 2026-04-13 15:56:45 -03:00
95ceb92d9c merge 2026-04-13 15:56:34 -03:00
b60bd3eef6 tipagem audioria 2026-04-13 15:55:48 -03:00
e4662fe240 definirDayjsbr 2026-02-19 10:39:01 -03:00
15 changed files with 1103 additions and 1031 deletions

View file

@ -45,7 +45,7 @@
"noExplicitAny": "off",
"noApproximativeNumericConstant": "off",
"noAsyncPromiseExecutor": "off",
"noEmptyBlockStatements": "warn",
"noEmptyBlockStatements": "off",
"noConsole": "off",
"noArrayIndexKey": "warn"
},
@ -62,7 +62,7 @@
"performance": {
"noAccumulatingSpread": "off",
"noDelete": "warn"
"noDelete": "off"
},
"a11y": {

16
dist-back/auditoria.js Normal file
View file

@ -0,0 +1,16 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
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 auditoria_exports = {};
module.exports = __toCommonJS(auditoria_exports);

58
dist-back/dayjs.js Normal file
View file

@ -0,0 +1,58 @@
"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 dayjs_exports = {};
__export(dayjs_exports, {
definirDayjsbr: () => definirDayjsbr
});
module.exports = __toCommonJS(dayjs_exports);
var import_duration = __toESM(require("dayjs/plugin/duration"));
var import_isSameOrAfter = __toESM(require("dayjs/plugin/isSameOrAfter"));
var import_isSameOrBefore = __toESM(require("dayjs/plugin/isSameOrBefore"));
var import_minMax = __toESM(require("dayjs/plugin/minMax"));
var import_relativeTime = __toESM(require("dayjs/plugin/relativeTime"));
var import_timezone = __toESM(require("dayjs/plugin/timezone"));
var import_utc = __toESM(require("dayjs/plugin/utc"));
var import_weekOfYear = __toESM(require("dayjs/plugin/weekOfYear"));
var import_pt_br = require("dayjs/locale/pt-br");
const definirDayjsbr = (dayjsEntrada) => {
dayjsEntrada.locale("pt-br");
dayjsEntrada.extend(import_utc.default);
dayjsEntrada.extend(import_timezone.default);
dayjsEntrada.extend(import_weekOfYear.default);
dayjsEntrada.extend(import_isSameOrBefore.default);
dayjsEntrada.extend(import_isSameOrAfter.default);
dayjsEntrada.extend(import_minMax.default);
dayjsEntrada.extend(import_relativeTime.default);
dayjsEntrada.extend(import_duration.default);
return dayjsEntrada;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
definirDayjsbr
});

View file

@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
var index_exports = {};
module.exports = __toCommonJS(index_exports);
__reExport(index_exports, require("./aleatorio"), module.exports);
__reExport(index_exports, require("./auditoria"), module.exports);
__reExport(index_exports, require("./cacheMemoria"), module.exports);
__reExport(index_exports, require("./constantes"), module.exports);
__reExport(index_exports, require("./consulta"), module.exports);
@ -38,6 +39,7 @@ __reExport(index_exports, require("./variaveisComuns"), module.exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
...require("./aleatorio"),
...require("./auditoria"),
...require("./cacheMemoria"),
...require("./constantes"),
...require("./consulta"),

View file

@ -13,6 +13,29 @@ import { v4 } from 'uuid';
declare const aleatorio: (tamanho?: number) => string;
type TipoPayloadAuditoria = {
/** UUID do registro de auditoria */
codigo?: string | null;
/** UUID do usuario da acao (pode ser null se for processo do sistema que não registrou) */
usuario_criacao: string | null;
/** Timestamp ou data de criacao / execucao */
data_criacao: string | Date;
/** Nome exato da tabela no banco que originou o registro */
tabela_origem: string;
/** Código único (UUID) do registro na tabela original */
codigo_origem: string;
/** JSON contendo o snapshot das colunas novas / editadas */
novo: Record<string, any>;
/** JSON contendo o snapshot das colunas antes da edição */
anterior: Record<string, any>;
/** Hash ou controle de versao do item, usualmente preenchido por new.ver_seg */
__versao: string;
/** Tipo de operação que gerou a auditoria */
acao: "criar" | "atualizar" | "deletar" | string;
/** Versão do sistema no momento em que a ação ocorreu */
versao_sistema: 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: () => {
@ -537,4 +560,4 @@ declare const nomeVariavel: (v: {
[key: string]: any;
}) => string;
export { Produtos, TipagemRotas, agrupadores26, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltro26, defineDayjsBr, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadores, operadores26, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoFiltro26, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zFiltro26, zOperadores };
export { Produtos, TipagemRotas, type TipoPayloadAuditoria, agrupadores26, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltro26, defineDayjsBr, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadores, operadores26, paraObjetoRegistroPg, pgObjeto, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoFiltro26, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zFiltro26, zOperadores };

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,6 @@
{
"name": "p-comuns",
"version": "0.323.0",
"version": "0.335.0",
"description": "",
"main": "./dist-front/index.mjs",
"module": "./dist-front/index.mjs",
@ -17,7 +17,8 @@
"check": "pnpm run biome && npx tsc --noEmit",
"build": "npm --no-git-tag-version version minor && pnpm run biome && tsup --config ./tsup/tsup.config.ts && pnpm run pacote",
"teste": "npx vitest run src/testes/TipagemRotas.test.ts",
"pacote": "npm pack && npm pack && mv $(npm pack --silent) pacote.tgz"
"pacote": "npm pack && npm pack && mv $(npm pack --silent) pacote.tgz",
"postinstall": "node ./scripts/atualizar-biome.js"
},
"author": {
"name": "AZTECA SOFTWARE LTDA",
@ -27,11 +28,10 @@
"license": "ISC",
"dependencies": {},
"devDependencies": {
"cross-fetch": "4.1.0",
"uuid": "^11.1.0",
"zod": "4.3.6",
"dayjs": "^1.11.18",
"@biomejs/biome": "2.4.0",
"@biomejs/biome": "2.4.12",
"@types/node": "^22",
"tsup": "8.5.1",
"typescript": "^6",
@ -39,7 +39,6 @@
"vitest": "^3.2.4"
},
"peerDependencies": {
"cross-fetch": "4.1.0",
"dayjs": "^1.11.18",
"uuid": "^11.1.0",
"zod": "4.3.6"

Binary file not shown.

1854
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,96 @@
const fs = require('node:fs');
const path = require('node:path');
const initCwd = process.env.INIT_CWD;
// Se não tiver INIT_CWD, não foi chamado pelo npm/pnpm install
if (!initCwd) {
process.exit(0);
}
// O próprio p-comuns não precisa se atualizar na sua pasta interna
if (initCwd === process.cwd()) {
process.exit(0);
}
const me = require('../package.json');
const biomeVersion = me.devDependencies && me.devDependencies['@biomejs/biome'];
if (!biomeVersion) {
process.exit(0);
}
/**
* os arquivos do diretório em busca de package.json
*/
function findPackageJson(dir) {
let results = [];
try {
const list = fs.readdirSync(dir);
for (const file of list) {
const filePath = path.join(dir, file);
const stat = fs.statSync(filePath);
if (stat && stat.isDirectory()) {
// Ignora pastas que não devemos varrer
if (
![
'node_modules',
'.git',
'dist',
'build',
'.nuxt',
'.output',
'.vscode',
'.idea',
].includes(file)
) {
results = results.concat(findPackageJson(filePath));
}
} else if (file === 'package.json') {
results.push(filePath);
}
}
} catch (err) {
// ignora pastas sem acesso
}
return results;
}
const files = findPackageJson(initCwd);
let updated = 0;
for (const file of files) {
try {
const content = fs.readFileSync(file, 'utf8');
// Detecta se usa tab ou espaço
const indent = content.match(/^[ \t]+/m) ? content.match(/^[ \t]+/m)[0] : '\t';
const json = JSON.parse(content);
let changed = false;
const updateDeps = (tipo) => {
if (json[tipo] && json[tipo]['@biomejs/biome']) {
if (json[tipo]['@biomejs/biome'] !== biomeVersion) {
json[tipo]['@biomejs/biome'] = biomeVersion;
changed = true;
}
}
};
updateDeps('dependencies');
updateDeps('devDependencies');
updateDeps('peerDependencies');
if (changed) {
fs.writeFileSync(file, JSON.stringify(json, null, indent) + '\n', 'utf8');
updated++;
console.log(`[p-comuns] @biomejs/biome atualizado para ${biomeVersion} em: ${path.relative(initCwd, file)}`);
}
} catch (e) {
console.error(`[p-comuns] Erro ao atualizar ${file}: ${e.message}`);
}
}
if (updated > 0) {
console.log(`[p-comuns] Total de package.json atualizados: ${updated}`);
}

31
src/auditoria.ts Normal file
View file

@ -0,0 +1,31 @@
export type TipoPayloadAuditoria = {
/** UUID do registro de auditoria */
codigo?: string | null
/** UUID do usuario da acao (pode ser null se for processo do sistema que não registrou) */
usuario_criacao: string | null
/** Timestamp ou data de criacao / execucao */
data_criacao: string | Date
/** Nome exato da tabela no banco que originou o registro */
tabela_origem: string
/** Código único (UUID) do registro na tabela original */
codigo_origem: string
/** JSON contendo o snapshot das colunas novas / editadas */
novo: Record<string, any>
/** JSON contendo o snapshot das colunas antes da edição */
anterior: Record<string, any>
/** Hash ou controle de versao do item, usualmente preenchido por new.ver_seg */
__versao: string
/** Tipo de operação que gerou a auditoria */
acao: "criar" | "atualizar" | "deletar" | string
/** Versão do sistema no momento em que a ação ocorreu */
versao_sistema: string
}

29
src/dayjs.ts Executable file
View file

@ -0,0 +1,29 @@
import type dayjs from "dayjs"
import type { Dayjs } from "dayjs"
export type { ManipulateType } from "dayjs"
import duration from "dayjs/plugin/duration"
import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
import minMax from "dayjs/plugin/minMax"
import relativeTime from "dayjs/plugin/relativeTime"
import timezone from "dayjs/plugin/timezone"
import utc from "dayjs/plugin/utc"
import weekOfYear from "dayjs/plugin/weekOfYear"
import "dayjs/locale/pt-br"
export const definirDayjsbr = (dayjsEntrada: typeof dayjs) => {
dayjsEntrada.locale("pt-br")
dayjsEntrada.extend(utc)
dayjsEntrada.extend(timezone)
dayjsEntrada.extend(weekOfYear)
dayjsEntrada.extend(isSameOrBefore)
dayjsEntrada.extend(isSameOrAfter)
dayjsEntrada.extend(minMax)
dayjsEntrada.extend(relativeTime)
dayjsEntrada.extend(duration)
return dayjsEntrada
}
export type { Dayjs }

View file

@ -102,6 +102,5 @@ const defineDayjsBr = ({
return dayjs
}
export { defineDayjsBr }
export type { Dayjs }
export { defineDayjsBr }

View file

@ -1,4 +1,5 @@
export * from "./aleatorio"
export * from "./auditoria"
export * from "./cacheMemoria"
export * from "./constantes"
export * from "./consulta"

View file

@ -15,7 +15,6 @@
/* Módulos */
"moduleResolution": "bundler" /* Define como o TypeScript resolve módulos. */,
"ignoreDeprecations": "6.0" /* Ignora avisos de depreciação do TS 6.0 */,
"rootDir": "./src" /* Define a pasta raiz para os arquivos de origem. */,
/* Emissão */
@ -26,7 +25,8 @@
/* Verificação de Tipos */
"strict": true /* Habilita todas as opções de verificação estrita de tipos. */,
"skipLibCheck": true /* Ignora a verificação de tipos em arquivos de declaração de bibliotecas. */
"skipLibCheck": true /* Ignora a verificação de tipos em arquivos de declaração de bibliotecas. */,
"ignoreDeprecations": "6.0"
},
"include": [
"src/**/*"