remoção do filtro 26 por filtro delta
This commit is contained in:
parent
98a531dbd3
commit
b0b76562b7
12 changed files with 348 additions and 542 deletions
|
|
@ -1,14 +1,4 @@
|
|||
import z, { z as z$1 } from 'zod';
|
||||
import _dayjs from 'dayjs';
|
||||
export { Dayjs, ManipulateType } from 'dayjs';
|
||||
import _duration from 'dayjs/plugin/duration';
|
||||
import _isSameOrAfter from 'dayjs/plugin/isSameOrAfter';
|
||||
import _isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
|
||||
import _minMax from 'dayjs/plugin/minMax';
|
||||
import _relativeTime from 'dayjs/plugin/relativeTime';
|
||||
import _timezone from 'dayjs/plugin/timezone';
|
||||
import _utc from 'dayjs/plugin/utc';
|
||||
import _weekOfYear from 'dayjs/plugin/weekOfYear';
|
||||
import z from 'zod';
|
||||
import { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
|
@ -124,70 +114,6 @@ declare const zFiltro: z.ZodObject<{
|
|||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
/**
|
||||
* Utilitário de configuração do Dayjs focado em compatibilidade com SSR.
|
||||
*
|
||||
* PROBLEMA:
|
||||
* A importação direta do `dayjs` e seus plugins frequentemente causa conflitos em ambientes
|
||||
* de Renderização do Lado do Servidor (SSR), como Nuxt ou Next.js, devido a discrepâncias
|
||||
* na resolução de módulos (ESM vs CJS) e instabilidades de importação.
|
||||
*
|
||||
* SOLUÇÃO:
|
||||
* Este módulo utiliza o padrão de Injeção de Dependência. Ele expõe apenas tipagens e
|
||||
* uma função de configuração (`defineDayjsBr`). A responsabilidade de importar as
|
||||
* bibliotecas "vivas" é delegada à aplicação consumidora (o cliente da função).
|
||||
*
|
||||
* Isso permite que o bundler da aplicação principal (Vite, Webpack, etc.) gerencie as
|
||||
* instâncias, garantindo consistência e evitando erros de "module not found" ou
|
||||
* instâncias duplicadas/não inicializadas adequadamente.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Inicializa e configura o Dayjs com o locale 'pt-br' e plugins essenciais.
|
||||
*
|
||||
* MODO DE USO:
|
||||
* Importe os pacotes reais na sua aplicação e passe-os para esta função.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // Em seu arquivo de configuração (ex: plugins/dayjs.ts):
|
||||
* import dayjs from "dayjs"
|
||||
* import duration from "dayjs/plugin/duration"
|
||||
* import isSameOrAfter from "dayjs/plugin/isSameOrAfter"
|
||||
* import isSameOrBefore from "dayjs/plugin/isSameOrBefore"
|
||||
* import minMax from "dayjs/plugin/minMax"
|
||||
* import relativeTime from "dayjs/plugin/relativeTime"
|
||||
* import timezone from "dayjs/plugin/timezone"
|
||||
* import utc from "dayjs/plugin/utc"
|
||||
* import weekOfYear from "dayjs/plugin/weekOfYear"
|
||||
* import { defineDayjsBr } from "p-comuns"
|
||||
* import "dayjs/locale/pt-br" // Importante: importar o locale!
|
||||
|
||||
* export const dayjsbr = defineDayjsBr({
|
||||
* dayjs,
|
||||
* duration,
|
||||
* isSameOrAfter,
|
||||
* isSameOrBefore,
|
||||
* minMax,
|
||||
* relativeTime,
|
||||
* timezone,
|
||||
* utc,
|
||||
* weekOfYear,
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
declare const defineDayjsBr: ({ dayjs, duration, isSameOrAfter, isSameOrBefore, minMax, relativeTime, timezone, utc, weekOfYear, }: {
|
||||
dayjs: typeof _dayjs;
|
||||
duration: typeof _duration;
|
||||
isSameOrAfter: typeof _isSameOrAfter;
|
||||
isSameOrBefore: typeof _isSameOrBefore;
|
||||
minMax: typeof _minMax;
|
||||
relativeTime: typeof _relativeTime;
|
||||
timezone: typeof _timezone;
|
||||
utc: typeof _utc;
|
||||
weekOfYear: typeof _weekOfYear;
|
||||
}) => typeof _dayjs;
|
||||
|
||||
declare const link_paiol = "https://paiol.idz.one";
|
||||
|
||||
type tiposArquivo = "imagem" | "documento" | "vídeo" | "outros";
|
||||
|
|
@ -203,6 +129,67 @@ declare const extensoes: {
|
|||
*/
|
||||
declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArquivo;
|
||||
|
||||
/**
|
||||
* Operadores permitidos para comparação.
|
||||
*/
|
||||
declare const zOperadorFiltroDelta: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
/**
|
||||
* Coluna simples ou caminho aninhado de jsonb.
|
||||
*/
|
||||
declare const zColunaFiltroDelta: z.ZodString;
|
||||
/**
|
||||
* Estrutura individual de uma condição do filtro.
|
||||
*/
|
||||
declare const zCondicaoFiltroDelta: z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
coluna: z.ZodString;
|
||||
operador: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
valor: z.ZodAny;
|
||||
}, z.core.$strip>;
|
||||
/**
|
||||
* Estrutura principal do filtro delta.
|
||||
*/
|
||||
declare const zFiltroDelta: z.ZodObject<{
|
||||
condicoes: z.ZodArray<z.ZodObject<{
|
||||
id: z.ZodString;
|
||||
coluna: z.ZodString;
|
||||
operador: z.ZodEnum<{
|
||||
"=": "=";
|
||||
"!=": "!=";
|
||||
">": ">";
|
||||
">=": ">=";
|
||||
"<": "<";
|
||||
"<=": "<=";
|
||||
like: "like";
|
||||
in: "in";
|
||||
}>;
|
||||
valor: z.ZodAny;
|
||||
}, z.core.$strip>>;
|
||||
formula: z.ZodString;
|
||||
}, z.core.$strip>;
|
||||
type tipoOperadorFiltroDelta = z.infer<typeof zOperadorFiltroDelta>;
|
||||
type tipoColunaFiltroDelta = z.infer<typeof zColunaFiltroDelta>;
|
||||
type tipoCondicaoFiltroDelta = z.infer<typeof zCondicaoFiltroDelta>;
|
||||
type tipoFiltroDelta = z.infer<typeof zFiltroDelta>;
|
||||
|
||||
/**
|
||||
* LocalStorage Tipado
|
||||
* Lê ou grava um valor no localStorage, mantendo o tipo genérico <T>.
|
||||
|
|
@ -347,151 +334,6 @@ 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 há suporte automático a:
|
||||
* - null
|
||||
* - date
|
||||
* - jsonb
|
||||
* - arrays
|
||||
*
|
||||
* Essas extensões devem ser adicionadas explicitamente.
|
||||
*
|
||||
* =============================================================================
|
||||
*/
|
||||
declare enum operadores26 {
|
||||
"=" = "=",
|
||||
"!=" = "!=",
|
||||
">" = ">",
|
||||
">=" = ">=",
|
||||
"<" = "<",
|
||||
"<=" = "<=",
|
||||
like = "like",
|
||||
in = "in"
|
||||
}
|
||||
declare enum agrupadores26 {
|
||||
E = "E",
|
||||
OU = "OU"
|
||||
}
|
||||
type PgOpsNumber = {
|
||||
[K in Extract<operadores26, "=" | "!=" | ">" | ">=" | "<" | "<=">]?: number;
|
||||
} & {
|
||||
[K in Extract<operadores26, "in">]?: number[];
|
||||
};
|
||||
type PgOpsString = {
|
||||
[K in Extract<operadores26, "=" | "!=" | "like">]?: string;
|
||||
} & {
|
||||
[K in Extract<operadores26, "in">]?: string[];
|
||||
};
|
||||
type PgOpsBoolean = {
|
||||
[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;
|
||||
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>;
|
||||
declare const criarFiltro26: <T>(filtro: tipoFiltro26<T>) => tipoFiltro26<T>;
|
||||
|
||||
/**
|
||||
* Essa variável se conecta a tabela_lidades
|
||||
*
|
||||
|
|
@ -560,4 +402,4 @@ declare const nomeVariavel: (v: {
|
|||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { Produtos, TipagemRotas, type TipoPayloadAuditoria, agrupadores26, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, criarFiltro26, defineDayjsBr, 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 };
|
||||
export { Produtos, TipagemRotas, type TipoPayloadAuditoria, 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 tipoColunaFiltroDelta, type tipoCondicaoFiltroDelta, type tipoFiltro, type tipoFiltroDelta, type tipoOperadorFiltroDelta, tipoUsuarioResiduos, tiposSituacoesElicencie, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zColunaFiltroDelta, zCondicaoFiltroDelta, zFiltro, zFiltroDelta, zOperadorFiltroDelta, zOperadores };
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue