merge
This commit is contained in:
commit
95ceb92d9c
59 changed files with 1114 additions and 452 deletions
|
|
@ -1,6 +1,14 @@
|
|||
import z from 'zod';
|
||||
import dayjs from 'dayjs';
|
||||
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 { v4 } from 'uuid';
|
||||
|
||||
declare const aleatorio: (tamanho?: number) => string;
|
||||
|
|
@ -114,7 +122,69 @@ declare const zFiltro: z.ZodObject<{
|
|||
ou: z.ZodOptional<z.ZodBoolean>;
|
||||
}, z.core.$strip>;
|
||||
|
||||
declare const dayjsbr: typeof dayjs;
|
||||
/**
|
||||
* 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";
|
||||
|
||||
|
|
@ -137,46 +207,6 @@ declare const tipoArquivo: (nomeArquivo: string | null | undefined) => tiposArqu
|
|||
*/
|
||||
declare const localValor: <T>(chave_: string | any, valor?: T | null) => T | null;
|
||||
|
||||
type tipoLokiObjeto = {
|
||||
streams: {
|
||||
stream: {
|
||||
[k: string]: string;
|
||||
};
|
||||
values: [string, string][];
|
||||
}[];
|
||||
};
|
||||
declare const postLogger: ({ objeto, }: {
|
||||
objeto: tipoLokiObjeto;
|
||||
}) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
/** define a localização da pasta do projeto */
|
||||
declare const defineCwd: (novoCwd: string) => void;
|
||||
type tipoLevel = "info" | "warn" | "error";
|
||||
type tipoOpSessao = {
|
||||
inquilino: string;
|
||||
usuario: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLog = {
|
||||
detalhes?: unknown[];
|
||||
__filename?: string;
|
||||
local?: string;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
};
|
||||
type tipoLoggerLog = (level: tipoLevel, mensagem: string, op_tipoLog?: tipoLog) => Promise<[objeto: tipoLokiObjeto, erro?: string]>;
|
||||
type TipoLoggerSessao = (sess: tipoOpSessao) => tipoLoggerLog;
|
||||
type tipoLogger = (amb: {
|
||||
app: string;
|
||||
eProducao: boolean;
|
||||
parametros?: {
|
||||
[k: string]: string;
|
||||
};
|
||||
}) => TipoLoggerSessao;
|
||||
declare const logger: tipoLogger;
|
||||
|
||||
/**
|
||||
* Trata um objeto para ser imput para postgres
|
||||
* @param entrada
|
||||
|
|
@ -203,6 +233,56 @@ declare enum Produtos {
|
|||
"gov.e-licencie" = "gov.e-licencie"
|
||||
}
|
||||
|
||||
declare enum tiposSituacoesElicencie {
|
||||
modelo = "000_modelo",
|
||||
vencida = "100_vencida",
|
||||
expirado = "200_expirado",
|
||||
alerta = "300_alerta",
|
||||
protocoladafora = "350_protocoladafora",
|
||||
protocolada = "400_protocolada",
|
||||
protocoladaApenas = "430_protocolada",
|
||||
protocolada_alteracao = "450_protocolada",
|
||||
prazo = "500_prazo",
|
||||
emitida = "515_emitida",
|
||||
valida = "518_valida",
|
||||
novo = "520_novo",
|
||||
recebido = "521_recebido",
|
||||
em_andamento = "530_em_andamento",
|
||||
aguardando = "530_aguardando",
|
||||
aguardandoresposta = "540_aguardandoresposta",
|
||||
suspensaotemporaria = "540_suspensaotemporaria",
|
||||
cancelada = "550_cancelada",
|
||||
execucao = "560_execucao",
|
||||
pendente = "570_pendente",
|
||||
executadafora = "600_executadafora",
|
||||
executada = "700_executada",
|
||||
naoexecutada = "701_naoexecutada",
|
||||
concluida = "730_concluida",
|
||||
respondido_negado = "740_respondido_negado",
|
||||
respondido_aceito = "741_respondido_aceito",
|
||||
atendidoparcial = "742_atendidoparcial",
|
||||
naoatendido = "743_naoatendido",
|
||||
atendido = "744_atendido",
|
||||
renovada = "760_renovada",
|
||||
finalizada = "800_finalizada",
|
||||
emitirnota = "101_emitirnota",
|
||||
faturaatrasada = "301_faturaatrasada",
|
||||
pagarfatura = "302_pagarfatura",
|
||||
aguardandoconfirmacao = "531_aguardandoconfirmacao",
|
||||
agendado = "701_agendado",
|
||||
faturapaga = "801_faturapaga",
|
||||
excluida = "999_excluida",
|
||||
requerida = "401_requerida",
|
||||
vigente = "516_vigente",
|
||||
emrenovacao = "402_emrenovacao",
|
||||
arquivada = "801_arquivada",
|
||||
aguardando_sincronizacao = "999_aguardando_sincronizacao",
|
||||
nao_conforme = "710_nao_conforme",
|
||||
conforme = "720_conforme",
|
||||
nao_aplicavel = "730_nao_aplicavel",
|
||||
parcial = "715_parcial"
|
||||
}
|
||||
|
||||
declare const umaFuncao: () => string;
|
||||
|
||||
declare const umaVariavel = "Ol\u00E1 Mundo! (vari\u00E1vel)";
|
||||
|
|
@ -265,6 +345,151 @@ 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
|
||||
*
|
||||
|
|
@ -333,4 +558,4 @@ declare const nomeVariavel: (v: {
|
|||
[key: string]: any;
|
||||
}) => string;
|
||||
|
||||
export { Produtos, TipagemRotas, type TipoLoggerSessao, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, dayjsbr, defineCwd, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
export { Produtos, TipagemRotas, type TipoLoggerSessao, type TipoPayloadAuditoria, aleatorio, cacheM, cacheMFixo, cacheMemoria, camposComuns, dayjsbr, defineCwd, erUuid, esperar, extensoes, type interfaceConsulta, link_paiol, localValor, logger, nomeVariavel, objetoPg, operadores, paraObjetoRegistroPg, pgObjeto, postLogger, siglas_unidades_medida, texto_busca, tipoArquivo, type tipoFiltro, type tipoLogger, type tipoLoggerLog, type tipoLokiObjeto, tipoUsuarioResiduos, tx, umaFuncao, umaVariavel, unidades_medida, uuid, uuidV3, uuidV4, uuid_null, validarUuid, verCacheM, zFiltro, zOperadores };
|
||||
Loading…
Add table
Add a link
Reference in a new issue