diff --git a/dist-back/auditoria.js b/dist-back/auditoria.js new file mode 100644 index 0000000..afc970d --- /dev/null +++ b/dist-back/auditoria.js @@ -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); diff --git a/dist-back/index.js b/dist-back/index.js index 984f76c..23f287a 100644 --- a/dist-back/index.js +++ b/dist-back/index.js @@ -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"), diff --git a/dist-front/index.d.mts b/dist-front/index.d.mts index 586d1c0..3a20f9b 100644 --- a/dist-front/index.d.mts +++ b/dist-front/index.d.mts @@ -5,6 +5,27 @@ import { v4 } from 'uuid'; declare const aleatorio: (tamanho?: number) => string; +type TipoPayloadAuditoria = { + /** 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; + /** JSON contendo o snapshot das colunas antes da edição */ + anterior: Record; + /** 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: (chave: any, valor?: T, validadeSeg?: number) => T | undefined; declare const verCacheM: () => { @@ -312,4 +333,4 @@ declare const nomeVariavel: (v: { [key: string]: any; }) => string; -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, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores }; +export { Produtos, TipagemRotas, type TipoLoggerSessao, type TipoPayloadAuditoria, 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, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores }; diff --git a/package.json b/package.json index 166149b..fc3ca86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-comuns", - "version": "0.297.0", + "version": "0.298.0", "description": "", "main": "./dist-front/index.mjs", "module": "./dist-front/index.mjs", diff --git a/pacote.tgz b/pacote.tgz index 10a1e9e..cd70992 100644 Binary files a/pacote.tgz and b/pacote.tgz differ diff --git a/src/auditoria.ts b/src/auditoria.ts new file mode 100644 index 0000000..7640e61 --- /dev/null +++ b/src/auditoria.ts @@ -0,0 +1,28 @@ +export type TipoPayloadAuditoria = { + /** 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 + + /** JSON contendo o snapshot das colunas antes da edição */ + anterior: Record + + /** 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 +} diff --git a/src/index.ts b/src/index.ts index cd207f7..6c1aeb1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,5 @@ export * from "./aleatorio" +export * from "./auditoria" export * from "./cacheMemoria" export * from "./constantes" export * from "./consulta"