This commit is contained in:
Luiz Silva 2026-04-15 12:24:38 -03:00
parent 7a6d79fe12
commit f5c4db0701
15 changed files with 21 additions and 72 deletions

View file

@ -98,7 +98,7 @@
"enabled": true, "enabled": true,
"indentStyle": "space", "indentStyle": "space",
"indentWidth": 2, "indentWidth": 2,
"lineWidth": 80, "lineWidth": 100,
"lineEnding": "lf" "lineEnding": "lf"
}, },
@ -133,7 +133,7 @@
"enabled": true, "enabled": true,
"indentStyle": "space", "indentStyle": "space",
"indentWidth": 2, "indentWidth": 2,
"lineWidth": 80, "lineWidth": 100,
"quoteStyle": "double" "quoteStyle": "double"
}, },
"linter": { "linter": {
@ -146,7 +146,7 @@
"enabled": true, "enabled": true,
"indentStyle": "space", "indentStyle": "space",
"indentWidth": 2, "indentWidth": 2,
"lineWidth": 80 "lineWidth": 100
} }
} }
} }

View file

@ -46,17 +46,7 @@ var operadores = /* @__PURE__ */ ((operadores2) => {
operadores2["isNull"] = "isNull"; operadores2["isNull"] = "isNull";
return operadores2; return operadores2;
})(operadores || {}); })(operadores || {});
const zOperadores = import_zod.default.enum([ const zOperadores = import_zod.default.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"]);
"=",
"!=",
">",
">=",
"<",
"<=",
"like",
"in",
"isNull"
]);
const zFiltro = import_zod.default.object({ const zFiltro = import_zod.default.object({
coluna: import_zod.default.string(), coluna: import_zod.default.string(),
valor: import_zod.default.any(), valor: import_zod.default.any(),

View file

@ -97,9 +97,7 @@ class TipagemRotas {
let queryObj = Object.fromEntries(query.entries()); let queryObj = Object.fromEntries(query.entries());
const hash = url.hash; const hash = url.hash;
if (hash) { if (hash) {
const hashObj = Object.fromEntries( const hashObj = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries());
new URLSearchParams(hash.slice(1)).entries()
);
queryObj = { ...queryObj, ...hashObj }; queryObj = { ...queryObj, ...hashObj };
} }
for (const chave in queryObj) { for (const chave in queryObj) {

View file

@ -22,9 +22,7 @@ __export(variaveisComuns_exports, {
nomeVariavel: () => nomeVariavel nomeVariavel: () => nomeVariavel
}); });
module.exports = __toCommonJS(variaveisComuns_exports); module.exports = __toCommonJS(variaveisComuns_exports);
const esperar = (ms) => new Promise( const esperar = (ms) => new Promise((resolve) => setTimeout(() => resolve(true), ms));
(resolve) => setTimeout(() => resolve(true), ms)
);
const nomeVariavel = (v) => Object.keys(v).join("/"); const nomeVariavel = (v) => Object.keys(v).join("/");
// Annotate the CommonJS export names for ESM import in node: // Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = { 0 && (module.exports = {

View file

@ -1,6 +1,6 @@
{ {
"name": "p-comuns", "name": "p-comuns",
"version": "0.334.0", "version": "0.335.0",
"description": "", "description": "",
"main": "./dist-front/index.mjs", "main": "./dist-front/index.mjs",
"module": "./dist-front/index.mjs", "module": "./dist-front/index.mjs",

Binary file not shown.

View file

@ -12,11 +12,7 @@ const _cache: {
;(globalThis as any).cacheMemoria_cache = _cache ;(globalThis as any).cacheMemoria_cache = _cache
export const cacheM = <T>( export const cacheM = <T>(chave: any, valor?: T, validadeSeg?: number): T | undefined => {
chave: any,
valor?: T,
validadeSeg?: number,
): T | undefined => {
// converte a chave e string // converte a chave e string
const txChave: string = const txChave: string =
typeof chave == "string" typeof chave == "string"

View file

@ -30,17 +30,7 @@ export type interfaceConsulta = {
apenasContagem?: boolean apenasContagem?: boolean
} }
export const zOperadores = z.enum([ export const zOperadores = z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"])
"=",
"!=",
">",
">=",
"<",
"<=",
"like",
"in",
"isNull",
])
export const zFiltro = z.object({ export const zFiltro = z.object({
coluna: z.string(), coluna: z.string(),

View file

@ -162,9 +162,7 @@ export const extensoes: {
* @param nomeArquivo * @param nomeArquivo
* @returns * @returns
*/ */
export const tipoArquivo = ( export const tipoArquivo = (nomeArquivo: string | null | undefined): tiposArquivo => {
nomeArquivo: string | null | undefined,
): tiposArquivo => {
// extenssão do arquivo // extenssão do arquivo
const extArquivo = String(nomeArquivo || "") const extArquivo = String(nomeArquivo || "")
.toLocaleLowerCase() .toLocaleLowerCase()

View file

@ -2,18 +2,11 @@
* LocalStorage Tipado * LocalStorage Tipado
* ou grava um valor no localStorage, mantendo o tipo genérico <T>. * ou grava um valor no localStorage, mantendo o tipo genérico <T>.
*/ */
export const localValor = <T>( export const localValor = <T>(chave_: string | any, valor?: T | null): T | null => {
chave_: string | any, const localStorage = "localStorage" in globalThis ? (globalThis as any).localStorage : undefined
valor?: T | null,
): T | null => {
const 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 = typeof chave_ === "string" ? chave_ : encodeURIComponent(JSON.stringify(chave_))
typeof chave_ === "string"
? chave_
: encodeURIComponent(JSON.stringify(chave_))
try { try {
// Grava valor se fornecido // Grava valor se fornecido

View file

@ -14,9 +14,7 @@ export const paraObjetoRegistroPg = (entrada: {
k, k,
v === undefined || v == null v === undefined || v == null
? v ? v
: typeof v == "string" || : typeof v == "string" || typeof v == "number" || typeof v == "boolean"
typeof v == "number" ||
typeof v == "boolean"
? v ? v
: JSON.stringify(v, null, 2), : JSON.stringify(v, null, 2),
]), ]),

View file

@ -63,9 +63,7 @@ export class TipagemRotas<T extends { [q: string]: any }> {
*/ */
endereco(query: T, usarComoHash?: boolean) { endereco(query: T, usarComoHash?: boolean) {
const win = const win = (typeof globalThis !== "undefined" && (globalThis as any).window) || undefined
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
undefined
const url = new URL(win ? win.location.href : "http://localhost") const url = new URL(win ? win.location.href : "http://localhost")
url.pathname = this.caminho url.pathname = this.caminho
@ -96,9 +94,7 @@ 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 = const win = (typeof globalThis !== "undefined" && (globalThis as any).window) || undefined
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
undefined
if (win) { if (win) {
win.location.href = this.endereco({ ...query }) win.location.href = this.endereco({ ...query })
} }
@ -124,9 +120,7 @@ export class TipagemRotas<T extends { [q: string]: any }> {
// pegar hash // pegar hash
const hash = url.hash const hash = url.hash
if (hash) { if (hash) {
const hashObj = Object.fromEntries( const hashObj = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries())
new URLSearchParams(hash.slice(1)).entries(),
)
queryObj = { ...queryObj, ...hashObj } as T queryObj = { ...queryObj, ...hashObj } as T
} }

View file

@ -164,9 +164,7 @@ type IsPlainObject<T> = T extends object
============================================================================= */ ============================================================================= */
type FiltroCampos<T> = { type FiltroCampos<T> = {
[K in keyof T]?: IsPlainObject<T[K]> extends true [K in keyof T]?: IsPlainObject<T[K]> extends true ? tipoFiltro26<T[K]> : PgOpsFor<T[K]>
? tipoFiltro26<T[K]>
: PgOpsFor<T[K]>
} }
/* ============================================================================= /* =============================================================================

View file

@ -6,8 +6,7 @@ import { NIL, v3, v4 } from "uuid"
* @param valor - A string que será validada. * @param valor - A string que será validada.
* @returns booleano indicando se é um UUID válido. * @returns booleano indicando se é um UUID válido.
*/ */
export const erUuid = export const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
export const validarUuid = (uuid: string | number | undefined | null) => { export const validarUuid = (uuid: string | number | undefined | null) => {
const retorno = erUuid.test(String(uuid || "")) const retorno = erUuid.test(String(uuid || ""))

View file

@ -1,7 +1,5 @@
export const esperar = (ms: number): Promise<true> => export const esperar = (ms: number): Promise<true> =>
new Promise((resolve: (r: true) => void) => new Promise((resolve: (r: true) => void) => setTimeout(() => resolve(true), ms))
setTimeout(() => resolve(true), ms),
)
/** /**
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto * Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
* const nomex = {a: 1, b: 2} * const nomex = {a: 1, b: 2}
@ -9,5 +7,4 @@ export const esperar = (ms: number): Promise<true> =>
* @param v * @param v
* @returns * @returns
*/ */
export const nomeVariavel = (v: { [key: string]: any }) => export const nomeVariavel = (v: { [key: string]: any }) => Object.keys(v).join("/")
Object.keys(v).join("/")