inciado filtro 26

This commit is contained in:
Luiz Silva 2026-02-17 08:38:20 -03:00
parent 92300c8e3b
commit fa8b8d6424
8 changed files with 221 additions and 19 deletions

View file

@ -1,4 +1,4 @@
import z from 'zod';
import z, { z as z$1 } from 'zod';
export { Dayjs, ManipulateType, default as dayjsbr } from 'dayjs';
export { default as duration } from 'dayjs/plugin/duration';
export { default as isSameOrAfter } from 'dayjs/plugin/isSameOrAfter';
@ -259,6 +259,141 @@ declare class TipagemRotas<T extends {
parametros(urlEntrada?: string): Partial<T>;
}
/**
* =============================================================================
* tipoFiltro26<T>
* =============================================================================
*
* OBJETIVO
* -----------------------------------------------------------------------------
* Gerar automaticamente a tipagem de filtros compatíveis com operadores
* padrão do PostgreSQL, a partir de um tipo base T.
*
* Este tipo foi projetado para:
* - Construção de filtros dinâmicos
* - Geração posterior de WHERE (Knex / SQL)
* - Uso seguro por IA (evita filtros inválidos em nível de tipo)
*
*
* FORMATO DO FILTRO
* -----------------------------------------------------------------------------
* 1) Campos simples:
*
* {
* idade: { ">=": 18 }
* }
*
* 2) Campos aninhados:
*
* {
* carro: {
* ano: { "=": 2020 }
* }
* }
*
* 3) Operador E (AND):
*
* {
* E: [
* { idade: { ">=": 18 } },
* { nome: { like: "%pa%" } }
* ]
* }
*
* 4) Operador OU (OR):
*
* {
* OU: [
* { idade: { "<": 18 } },
* { idade: { ">=": 60 } }
* ]
* }
*
* 5) Combinação complexa:
*
* {
* idade: { ">=": 18 },
* OU: [
* { nome: { like: "%pa%" } },
* {
* E: [
* { carro: { ano: { "=": 2020 } } },
* { carro: { modelo: { in: ["Civic"] } } }
* ]
* }
* ]
* }
*
*
* REGRAS IMPORTANTES (PARA IA)
* -----------------------------------------------------------------------------
* - Apenas campos existentes em T podem ser usados.
* - Operadores são restritos por tipo do campo.
* - Objetos são tratados recursivamente.
* - Arrays NÃO são tratados como objeto recursivo.
* - Funções NÃO são consideradas campos filtráveis.
*
*
* OPERADORES SUPORTADOS
* -----------------------------------------------------------------------------
* number:
* =, !=, >, >=, <, <=, in
*
* string:
* =, !=, like, in
*
* boolean:
* =, !=, in
*
* Não suporte automático a:
* - null
* - date
* - jsonb
* - arrays
*
* Essas extensões devem ser adicionadas explicitamente.
*
* =============================================================================
*/
type PgOpsNumber = {
"="?: number;
"!="?: number;
">"?: number;
">="?: number;
"<"?: number;
"<="?: number;
in?: number[];
};
type PgOpsString = {
"="?: string;
"!="?: string;
like?: string;
in?: string[];
};
type PgOpsBoolean = {
"="?: boolean;
"!="?: boolean;
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;
type FiltroCampos<T> = {
[K in keyof T]?: IsPlainObject<T[K]> extends true ? tipoFiltro26<T[K]> : PgOpsFor<T[K]>;
};
type tipoFiltro26<T> = FiltroCampos<T> & {
/**
* E => AND lógico
* Todos os filtros dentro do array devem ser verdadeiros.
*/
E?: tipoFiltro26<T>[];
/**
* OU => OR lógico
* Pelo menos um filtro dentro do array deve ser verdadeiro.
*/
OU?: tipoFiltro26<T>[];
};
declare const zFiltro26: z$1.ZodType<any>;
/**
* Essa variável se conecta a tabela_lidades
*
@ -327,4 +462,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, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
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 };

File diff suppressed because one or more lines are too long