build
This commit is contained in:
parent
691387ff9a
commit
7a6d79fe12
16 changed files with 72 additions and 21 deletions
|
|
@ -98,7 +98,7 @@
|
|||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100,
|
||||
"lineWidth": 80,
|
||||
"lineEnding": "lf"
|
||||
},
|
||||
|
||||
|
|
@ -146,7 +146,7 @@
|
|||
"enabled": true,
|
||||
"indentStyle": "space",
|
||||
"indentWidth": 2,
|
||||
"lineWidth": 100
|
||||
"lineWidth": 80
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,17 @@ var operadores = /* @__PURE__ */ ((operadores2) => {
|
|||
operadores2["isNull"] = "isNull";
|
||||
return operadores2;
|
||||
})(operadores || {});
|
||||
const zOperadores = import_zod.default.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"]);
|
||||
const zOperadores = import_zod.default.enum([
|
||||
"=",
|
||||
"!=",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<=",
|
||||
"like",
|
||||
"in",
|
||||
"isNull"
|
||||
]);
|
||||
const zFiltro = import_zod.default.object({
|
||||
coluna: import_zod.default.string(),
|
||||
valor: import_zod.default.any(),
|
||||
|
|
|
|||
|
|
@ -97,7 +97,9 @@ class TipagemRotas {
|
|||
let queryObj = Object.fromEntries(query.entries());
|
||||
const hash = url.hash;
|
||||
if (hash) {
|
||||
const hashObj = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries());
|
||||
const hashObj = Object.fromEntries(
|
||||
new URLSearchParams(hash.slice(1)).entries()
|
||||
);
|
||||
queryObj = { ...queryObj, ...hashObj };
|
||||
}
|
||||
for (const chave in queryObj) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,9 @@ __export(variaveisComuns_exports, {
|
|||
nomeVariavel: () => nomeVariavel
|
||||
});
|
||||
module.exports = __toCommonJS(variaveisComuns_exports);
|
||||
const esperar = (ms) => new Promise((resolve) => setTimeout(() => resolve(true), ms));
|
||||
const esperar = (ms) => new Promise(
|
||||
(resolve) => setTimeout(() => resolve(true), ms)
|
||||
);
|
||||
const nomeVariavel = (v) => Object.keys(v).join("/");
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "p-comuns",
|
||||
"version": "0.333.0",
|
||||
"version": "0.334.0",
|
||||
"description": "",
|
||||
"main": "./dist-front/index.mjs",
|
||||
"module": "./dist-front/index.mjs",
|
||||
|
|
|
|||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
|
|
@ -12,7 +12,11 @@ const _cache: {
|
|||
|
||||
;(globalThis as any).cacheMemoria_cache = _cache
|
||||
|
||||
export const cacheM = <T>(chave: any, valor?: T, validadeSeg?: number): T | undefined => {
|
||||
export const cacheM = <T>(
|
||||
chave: any,
|
||||
valor?: T,
|
||||
validadeSeg?: number,
|
||||
): T | undefined => {
|
||||
// converte a chave e string
|
||||
const txChave: string =
|
||||
typeof chave == "string"
|
||||
|
|
|
|||
|
|
@ -30,7 +30,17 @@ export type interfaceConsulta = {
|
|||
apenasContagem?: boolean
|
||||
}
|
||||
|
||||
export const zOperadores = z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in", "isNull"])
|
||||
export const zOperadores = z.enum([
|
||||
"=",
|
||||
"!=",
|
||||
">",
|
||||
">=",
|
||||
"<",
|
||||
"<=",
|
||||
"like",
|
||||
"in",
|
||||
"isNull",
|
||||
])
|
||||
|
||||
export const zFiltro = z.object({
|
||||
coluna: z.string(),
|
||||
|
|
|
|||
|
|
@ -162,7 +162,9 @@ export const extensoes: {
|
|||
* @param nomeArquivo
|
||||
* @returns
|
||||
*/
|
||||
export const tipoArquivo = (nomeArquivo: string | null | undefined): tiposArquivo => {
|
||||
export const tipoArquivo = (
|
||||
nomeArquivo: string | null | undefined,
|
||||
): tiposArquivo => {
|
||||
// extenssão do arquivo
|
||||
const extArquivo = String(nomeArquivo || "")
|
||||
.toLocaleLowerCase()
|
||||
|
|
|
|||
|
|
@ -2,11 +2,18 @@
|
|||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
*/
|
||||
export const localValor = <T>(chave_: string | any, valor?: T | null): T | null => {
|
||||
const localStorage = "localStorage" in globalThis ? (globalThis as any).localStorage : undefined
|
||||
export const localValor = <T>(
|
||||
chave_: string | any,
|
||||
valor?: T | null,
|
||||
): T | null => {
|
||||
const localStorage =
|
||||
"localStorage" in globalThis ? (globalThis as any).localStorage : undefined
|
||||
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 {
|
||||
// Grava valor se fornecido
|
||||
|
|
|
|||
|
|
@ -14,7 +14,9 @@ export const paraObjetoRegistroPg = (entrada: {
|
|||
k,
|
||||
v === undefined || v == null
|
||||
? v
|
||||
: typeof v == "string" || typeof v == "number" || typeof v == "boolean"
|
||||
: typeof v == "string" ||
|
||||
typeof v == "number" ||
|
||||
typeof v == "boolean"
|
||||
? v
|
||||
: JSON.stringify(v, null, 2),
|
||||
]),
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
*/
|
||||
|
||||
endereco(query: T, usarComoHash?: boolean) {
|
||||
const win = (typeof globalThis !== "undefined" && (globalThis as any).window) || undefined
|
||||
const win =
|
||||
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
|
||||
undefined
|
||||
const url = new URL(win ? win.location.href : "http://localhost")
|
||||
|
||||
url.pathname = this.caminho
|
||||
|
|
@ -94,7 +96,9 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
if (this._acaoIr) {
|
||||
this._acaoIr(this.endereco({ ...query }))
|
||||
} else {
|
||||
const win = (typeof globalThis !== "undefined" && (globalThis as any).window) || undefined
|
||||
const win =
|
||||
(typeof globalThis !== "undefined" && (globalThis as any).window) ||
|
||||
undefined
|
||||
if (win) {
|
||||
win.location.href = this.endereco({ ...query })
|
||||
}
|
||||
|
|
@ -120,7 +124,9 @@ export class TipagemRotas<T extends { [q: string]: any }> {
|
|||
// pegar hash
|
||||
const hash = url.hash
|
||||
if (hash) {
|
||||
const hashObj = Object.fromEntries(new URLSearchParams(hash.slice(1)).entries())
|
||||
const hashObj = Object.fromEntries(
|
||||
new URLSearchParams(hash.slice(1)).entries(),
|
||||
)
|
||||
queryObj = { ...queryObj, ...hashObj } as T
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,9 @@ type IsPlainObject<T> = T extends object
|
|||
============================================================================= */
|
||||
|
||||
type FiltroCampos<T> = {
|
||||
[K in keyof T]?: IsPlainObject<T[K]> extends true ? tipoFiltro26<T[K]> : PgOpsFor<T[K]>
|
||||
[K in keyof T]?: IsPlainObject<T[K]> extends true
|
||||
? tipoFiltro26<T[K]>
|
||||
: PgOpsFor<T[K]>
|
||||
}
|
||||
|
||||
/* =============================================================================
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@ import { NIL, v3, v4 } from "uuid"
|
|||
* @param valor - A string que será validada.
|
||||
* @returns booleano indicando se é um UUID válido.
|
||||
*/
|
||||
export const erUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
||||
export const erUuid =
|
||||
/^[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) => {
|
||||
const retorno = erUuid.test(String(uuid || ""))
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
export const esperar = (ms: number): Promise<true> =>
|
||||
new Promise((resolve: (r: true) => void) => setTimeout(() => resolve(true), ms))
|
||||
new Promise((resolve: (r: true) => void) =>
|
||||
setTimeout(() => resolve(true), ms),
|
||||
)
|
||||
/**
|
||||
* Usado para retronat o no de uma variável, deve ser usado dentro de um objeto
|
||||
* const nomex = {a: 1, b: 2}
|
||||
|
|
@ -7,4 +9,5 @@ export const esperar = (ms: number): Promise<true> =>
|
|||
* @param v
|
||||
* @returns
|
||||
*/
|
||||
export const nomeVariavel = (v: { [key: string]: any }) => Object.keys(v).join("/")
|
||||
export const nomeVariavel = (v: { [key: string]: any }) =>
|
||||
Object.keys(v).join("/")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue