This commit is contained in:
Luiz Silva 2026-02-17 10:32:57 -03:00
parent fa8b8d6424
commit edcc14d0ad
6 changed files with 72 additions and 42 deletions

View file

@ -18,11 +18,24 @@ var __copyProps = (to, from, except, desc) => {
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var tipoFiltro_26_exports = {};
__export(tipoFiltro_26_exports, {
criarFiltro26: () => criarFiltro26,
operadores26: () => operadores26,
zFiltro26: () => zFiltro26
});
module.exports = __toCommonJS(tipoFiltro_26_exports);
var import_zod = require("zod");
const zOperadores = import_zod.z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in"]);
var operadores26 = /* @__PURE__ */ ((operadores262) => {
operadores262["="] = "=";
operadores262["!="] = "!=";
operadores262[">"] = ">";
operadores262[">="] = ">=";
operadores262["<"] = "<";
operadores262["<="] = "<=";
operadores262["like"] = "like";
operadores262["in"] = "in";
return operadores262;
})(operadores26 || {});
const zOperadores = import_zod.z.nativeEnum(operadores26);
const zValor = import_zod.z.any();
const zCondicao = import_zod.z.record(zOperadores, zValor);
const zFiltro26 = import_zod.z.lazy(
@ -32,18 +45,21 @@ const zFiltro26 = import_zod.z.lazy(
}).catchall(import_zod.z.union([zCondicao, zFiltro26]))
);
const _filtro = {
idade: { ">=": 18 },
idade: { [">=" /* >= */]: 18 },
OU: [
{ nome: { like: "%pa%" } },
{ nome: { ["like" /* like */]: "%pa%" } },
{
E: [
{ carro: { ano: { "=": 2020 } } },
{ carro: { modelo: { in: ["Civic", "Corolla"] } } }
{ carro: { ano: { ["=" /* = */]: 2020 } } },
{ carro: { modelo: { ["in" /* in */]: ["Civic", "Corolla"] } } }
]
}
]
};
const criarFiltro26 = (filtro) => filtro;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
criarFiltro26,
operadores26,
zFiltro26
});

View file

@ -355,25 +355,30 @@ declare class TipagemRotas<T extends {
*
* =============================================================================
*/
declare enum operadores26 {
"=" = "=",
"!=" = "!=",
">" = ">",
">=" = ">=",
"<" = "<",
"<=" = "<=",
like = "like",
in = "in"
}
type PgOpsNumber = {
"="?: number;
"!="?: number;
">"?: number;
">="?: number;
"<"?: number;
"<="?: number;
in?: number[];
[K in Extract<operadores26, "=" | "!=" | ">" | ">=" | "<" | "<=">]?: number;
} & {
[K in Extract<operadores26, "in">]?: number[];
};
type PgOpsString = {
"="?: string;
"!="?: string;
like?: string;
in?: string[];
[K in Extract<operadores26, "=" | "!=" | "like">]?: string;
} & {
[K in Extract<operadores26, "in">]?: string[];
};
type PgOpsBoolean = {
"="?: boolean;
"!="?: boolean;
in?: boolean[];
[K in Extract<operadores26, "=" | "!=">]?: boolean;
} & {
[K in Extract<operadores26, "in">]?: boolean[];
};
type PgOpsFor<V> = V extends number ? PgOpsNumber : V extends string ? PgOpsString : V extends boolean ? PgOpsBoolean : never;
type IsPlainObject<T> = T extends object ? T extends Function ? false : T extends readonly any[] ? false : true : false;
@ -393,6 +398,7 @@ type tipoFiltro26<T> = FiltroCampos<T> & {
OU?: tipoFiltro26<T>[];
};
declare const zFiltro26: z$1.ZodType<any>;
declare const criarFiltro26: <T>(filtro: tipoFiltro26<T>) => tipoFiltro26<T>;
/**
* Essa variável se conecta a tabela_lidades
@ -462,4 +468,4 @@ declare const nomeVariavel: (v: {
[key: string]: any;
}) => string;
export { Produtos, TipagemRotas, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, nomeVariavel, objetoPg, operadores, 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, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltro26, 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.307.0",
"version": "0.308.0",
"description": "",
"main": "./dist-front/index.mjs",
"module": "./dist-front/index.mjs",

Binary file not shown.

View file

@ -99,29 +99,35 @@ import { z } from "zod"
/* =============================================================================
OPERADORES POSTGRESQL POR TIPO
============================================================================= */
============================================================================= */
export enum operadores26 {
"=" = "=",
"!=" = "!=",
">" = ">",
">=" = ">=",
"<" = "<",
"<=" = "<=",
like = "like",
in = "in",
}
type PgOpsNumber = {
"="?: number
"!="?: number
">"?: number
">="?: number
"<"?: number
"<="?: number
in?: number[]
[K in Extract<operadores26, "=" | "!=" | ">" | ">=" | "<" | "<=">]?: number
} & {
[K in Extract<operadores26, "in">]?: number[]
}
type PgOpsString = {
"="?: string
"!="?: string
like?: string
in?: string[]
[K in Extract<operadores26, "=" | "!=" | "like">]?: string
} & {
[K in Extract<operadores26, "in">]?: string[]
}
type PgOpsBoolean = {
"="?: boolean
"!="?: boolean
in?: boolean[]
[K in Extract<operadores26, "=" | "!=">]?: boolean
} & {
[K in Extract<operadores26, "in">]?: boolean[]
}
/* =============================================================================
@ -180,7 +186,7 @@ export type tipoFiltro26<T> = FiltroCampos<T> & {
VALIDAÇÃO ESTRUTURAL (ZOD)
============================================================================= */
const zOperadores = z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in"])
const zOperadores = z.nativeEnum(operadores26)
const zValor = z.any()
const zCondicao = z.record(zOperadores, zValor)
@ -208,15 +214,17 @@ type Pessoa = {
}
const _filtro: tipoFiltro26<Pessoa> = {
idade: { ">=": 18 },
idade: { [operadores26[">="]]: 18 },
OU: [
{ nome: { like: "%pa%" } },
{ nome: { [operadores26.like]: "%pa%" } },
{
E: [
{ carro: { ano: { "=": 2020 } } },
{ carro: { modelo: { in: ["Civic", "Corolla"] } } },
{ carro: { ano: { [operadores26["="]]: 2020 } } },
{ carro: { modelo: { [operadores26.in]: ["Civic", "Corolla"] } } },
],
},
],
}
export const criarFiltro26 = <T>(filtro: tipoFiltro26<T>) => filtro