.
This commit is contained in:
parent
fa8b8d6424
commit
edcc14d0ad
6 changed files with 72 additions and 42 deletions
|
|
@ -18,11 +18,24 @@ var __copyProps = (to, from, except, desc) => {
|
||||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||||
var tipoFiltro_26_exports = {};
|
var tipoFiltro_26_exports = {};
|
||||||
__export(tipoFiltro_26_exports, {
|
__export(tipoFiltro_26_exports, {
|
||||||
|
criarFiltro26: () => criarFiltro26,
|
||||||
|
operadores26: () => operadores26,
|
||||||
zFiltro26: () => zFiltro26
|
zFiltro26: () => zFiltro26
|
||||||
});
|
});
|
||||||
module.exports = __toCommonJS(tipoFiltro_26_exports);
|
module.exports = __toCommonJS(tipoFiltro_26_exports);
|
||||||
var import_zod = require("zod");
|
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 zValor = import_zod.z.any();
|
||||||
const zCondicao = import_zod.z.record(zOperadores, zValor);
|
const zCondicao = import_zod.z.record(zOperadores, zValor);
|
||||||
const zFiltro26 = import_zod.z.lazy(
|
const zFiltro26 = import_zod.z.lazy(
|
||||||
|
|
@ -32,18 +45,21 @@ const zFiltro26 = import_zod.z.lazy(
|
||||||
}).catchall(import_zod.z.union([zCondicao, zFiltro26]))
|
}).catchall(import_zod.z.union([zCondicao, zFiltro26]))
|
||||||
);
|
);
|
||||||
const _filtro = {
|
const _filtro = {
|
||||||
idade: { ">=": 18 },
|
idade: { [">=" /* >= */]: 18 },
|
||||||
OU: [
|
OU: [
|
||||||
{ nome: { like: "%pa%" } },
|
{ nome: { ["like" /* like */]: "%pa%" } },
|
||||||
{
|
{
|
||||||
E: [
|
E: [
|
||||||
{ carro: { ano: { "=": 2020 } } },
|
{ carro: { ano: { ["=" /* = */]: 2020 } } },
|
||||||
{ carro: { modelo: { in: ["Civic", "Corolla"] } } }
|
{ carro: { modelo: { ["in" /* in */]: ["Civic", "Corolla"] } } }
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
const criarFiltro26 = (filtro) => filtro;
|
||||||
// Annotate the CommonJS export names for ESM import in node:
|
// Annotate the CommonJS export names for ESM import in node:
|
||||||
0 && (module.exports = {
|
0 && (module.exports = {
|
||||||
|
criarFiltro26,
|
||||||
|
operadores26,
|
||||||
zFiltro26
|
zFiltro26
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -355,25 +355,30 @@ declare class TipagemRotas<T extends {
|
||||||
*
|
*
|
||||||
* =============================================================================
|
* =============================================================================
|
||||||
*/
|
*/
|
||||||
|
declare enum operadores26 {
|
||||||
|
"=" = "=",
|
||||||
|
"!=" = "!=",
|
||||||
|
">" = ">",
|
||||||
|
">=" = ">=",
|
||||||
|
"<" = "<",
|
||||||
|
"<=" = "<=",
|
||||||
|
like = "like",
|
||||||
|
in = "in"
|
||||||
|
}
|
||||||
type PgOpsNumber = {
|
type PgOpsNumber = {
|
||||||
"="?: number;
|
[K in Extract<operadores26, "=" | "!=" | ">" | ">=" | "<" | "<=">]?: number;
|
||||||
"!="?: number;
|
} & {
|
||||||
">"?: number;
|
[K in Extract<operadores26, "in">]?: number[];
|
||||||
">="?: number;
|
|
||||||
"<"?: number;
|
|
||||||
"<="?: number;
|
|
||||||
in?: number[];
|
|
||||||
};
|
};
|
||||||
type PgOpsString = {
|
type PgOpsString = {
|
||||||
"="?: string;
|
[K in Extract<operadores26, "=" | "!=" | "like">]?: string;
|
||||||
"!="?: string;
|
} & {
|
||||||
like?: string;
|
[K in Extract<operadores26, "in">]?: string[];
|
||||||
in?: string[];
|
|
||||||
};
|
};
|
||||||
type PgOpsBoolean = {
|
type PgOpsBoolean = {
|
||||||
"="?: boolean;
|
[K in Extract<operadores26, "=" | "!=">]?: boolean;
|
||||||
"!="?: boolean;
|
} & {
|
||||||
in?: boolean[];
|
[K in Extract<operadores26, "in">]?: boolean[];
|
||||||
};
|
};
|
||||||
type PgOpsFor<V> = V extends number ? PgOpsNumber : V extends string ? PgOpsString : V extends boolean ? PgOpsBoolean : never;
|
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 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>[];
|
OU?: tipoFiltro26<T>[];
|
||||||
};
|
};
|
||||||
declare const zFiltro26: z$1.ZodType<any>;
|
declare const zFiltro26: z$1.ZodType<any>;
|
||||||
|
declare const criarFiltro26: <T>(filtro: tipoFiltro26<T>) => tipoFiltro26<T>;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Essa variável se conecta a tabela_lidades
|
* Essa variável se conecta a tabela_lidades
|
||||||
|
|
@ -462,4 +468,4 @@ declare const nomeVariavel: (v: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}) => string;
|
}) => 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
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "p-comuns",
|
"name": "p-comuns",
|
||||||
"version": "0.307.0",
|
"version": "0.308.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "./dist-front/index.mjs",
|
"main": "./dist-front/index.mjs",
|
||||||
"module": "./dist-front/index.mjs",
|
"module": "./dist-front/index.mjs",
|
||||||
|
|
|
||||||
BIN
pacote.tgz
BIN
pacote.tgz
Binary file not shown.
|
|
@ -99,29 +99,35 @@ import { z } from "zod"
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
OPERADORES POSTGRESQL POR TIPO
|
OPERADORES POSTGRESQL POR TIPO
|
||||||
============================================================================= */
|
============================================================================= */
|
||||||
|
|
||||||
|
export enum operadores26 {
|
||||||
|
"=" = "=",
|
||||||
|
"!=" = "!=",
|
||||||
|
">" = ">",
|
||||||
|
">=" = ">=",
|
||||||
|
"<" = "<",
|
||||||
|
"<=" = "<=",
|
||||||
|
like = "like",
|
||||||
|
in = "in",
|
||||||
|
}
|
||||||
|
|
||||||
type PgOpsNumber = {
|
type PgOpsNumber = {
|
||||||
"="?: number
|
[K in Extract<operadores26, "=" | "!=" | ">" | ">=" | "<" | "<=">]?: number
|
||||||
"!="?: number
|
} & {
|
||||||
">"?: number
|
[K in Extract<operadores26, "in">]?: number[]
|
||||||
">="?: number
|
|
||||||
"<"?: number
|
|
||||||
"<="?: number
|
|
||||||
in?: number[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PgOpsString = {
|
type PgOpsString = {
|
||||||
"="?: string
|
[K in Extract<operadores26, "=" | "!=" | "like">]?: string
|
||||||
"!="?: string
|
} & {
|
||||||
like?: string
|
[K in Extract<operadores26, "in">]?: string[]
|
||||||
in?: string[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PgOpsBoolean = {
|
type PgOpsBoolean = {
|
||||||
"="?: boolean
|
[K in Extract<operadores26, "=" | "!=">]?: boolean
|
||||||
"!="?: boolean
|
} & {
|
||||||
in?: boolean[]
|
[K in Extract<operadores26, "in">]?: boolean[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/* =============================================================================
|
/* =============================================================================
|
||||||
|
|
@ -180,7 +186,7 @@ export type tipoFiltro26<T> = FiltroCampos<T> & {
|
||||||
VALIDAÇÃO ESTRUTURAL (ZOD)
|
VALIDAÇÃO ESTRUTURAL (ZOD)
|
||||||
============================================================================= */
|
============================================================================= */
|
||||||
|
|
||||||
const zOperadores = z.enum(["=", "!=", ">", ">=", "<", "<=", "like", "in"])
|
const zOperadores = z.nativeEnum(operadores26)
|
||||||
const zValor = z.any()
|
const zValor = z.any()
|
||||||
const zCondicao = z.record(zOperadores, zValor)
|
const zCondicao = z.record(zOperadores, zValor)
|
||||||
|
|
||||||
|
|
@ -208,15 +214,17 @@ type Pessoa = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const _filtro: tipoFiltro26<Pessoa> = {
|
const _filtro: tipoFiltro26<Pessoa> = {
|
||||||
idade: { ">=": 18 },
|
idade: { [operadores26[">="]]: 18 },
|
||||||
|
|
||||||
OU: [
|
OU: [
|
||||||
{ nome: { like: "%pa%" } },
|
{ nome: { [operadores26.like]: "%pa%" } },
|
||||||
{
|
{
|
||||||
E: [
|
E: [
|
||||||
{ carro: { ano: { "=": 2020 } } },
|
{ carro: { ano: { [operadores26["="]]: 2020 } } },
|
||||||
{ carro: { modelo: { in: ["Civic", "Corolla"] } } },
|
{ carro: { modelo: { [operadores26.in]: ["Civic", "Corolla"] } } },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const criarFiltro26 = <T>(filtro: tipoFiltro26<T>) => filtro
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue