From 9300367948f27e0c236d9c7c9b367e99b99a4f7c Mon Sep 17 00:00:00 2001 From: "Luiz H. R. Silva" Date: Fri, 5 Jul 2024 09:52:27 -0300 Subject: [PATCH] add visoes --- dist-import/pilao-de-dados/index.d.ts | 233 ++++++++++++++++++ dist-import/pilao-de-dados/index.js | 4 + dist-import/pilao-de-dados/visoes/index.d.ts | 172 +++++++++++++ dist-import/pilao-de-dados/visoes/index.js | 71 ++++++ dist-require/pilao-de-dados/index.d.ts | 233 ++++++++++++++++++ dist-require/pilao-de-dados/index.js | 4 + dist-require/pilao-de-dados/visoes/index.d.ts | 172 +++++++++++++ dist-require/pilao-de-dados/visoes/index.js | 74 ++++++ package.json | 2 +- src/pilao-de-dados/index.ts | 4 + src/pilao-de-dados/visoes/index.ts | 111 +++++++++ 11 files changed, 1079 insertions(+), 1 deletion(-) create mode 100644 dist-import/pilao-de-dados/visoes/index.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/index.js create mode 100644 dist-require/pilao-de-dados/visoes/index.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/index.js create mode 100644 src/pilao-de-dados/visoes/index.ts diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index de7681c..cc9cd38 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -5,6 +5,162 @@ import { tiposSeriesAgregacoes, zp_produto_conta } from "./variaveis"; import { zp_serie_registrar } from "./_serie_consultar"; export { tiposSeriesAgregacoes }; export declare const pPilao: { + extruturas_de_campos: { + z_contagem_em_barra_vertical: { + visao: "z_contagem_em_barra_vertical"; + tabela: (_: { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + descricao: (_: { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + campos: { + tabela: { + tipo_campo: import("zod").TypeOf>; + }; + colanuEixoX: { + tipo_campo: import("zod").TypeOf>; + }; + colunaAgrupamento: { + tipo_campo: import("zod").TypeOf>; + }; + filtros: { + tipo_campo: import("zod").TypeOf>; + }; + descricao_pelo_usuario: { + tipo_campo: import("zod").TypeOf>; + }; + }; + }; + z_contagem_em_pizza: { + visao: "z_contagem_em_pizza"; + tabela: (_: { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + descricao: (_: { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + campos: { + tabela: { + tipo_campo: import("zod").TypeOf>; + }; + colanuEixoX: { + tipo_campo: import("zod").TypeOf>; + }; + filtros: { + tipo_campo: import("zod").TypeOf>; + }; + descricao_pelo_usuario: { + tipo_campo: import("zod").TypeOf>; + }; + }; + }; + }; + z_contagem_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodArray; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; zp_registrar_base_dados: import("zod").ZodObject<{ tabela: import("zod").ZodString; colunas: import("zod").ZodArray" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; + visoes: { + z_contagem_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodArray; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + }; }; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index 1650e56..ec28358 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -3,6 +3,7 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { enviar_registros, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; import { operadores_permitidos_por_tipo, operadores_pilao, tiposSeriesAgregacoes, validarZ, zp_produto_conta, } from "./variaveis"; import { serie_consultar, z_filtro, zp_serie_registrar, } from "./_serie_consultar"; +import { extruturas_de_campos, visoes } from "./visoes"; export { tiposSeriesAgregacoes }; export const pPilao = { zp_registrar_base_dados, @@ -17,4 +18,7 @@ export const pPilao = { operadores_pilao, operadores_permitidos_por_tipo, z_filtro, + visoes, + ...visoes, + extruturas_de_campos, }; diff --git a/dist-import/pilao-de-dados/visoes/index.d.ts b/dist-import/pilao-de-dados/visoes/index.d.ts new file mode 100644 index 0000000..5e5cdc6 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/index.d.ts @@ -0,0 +1,172 @@ +import { z } from "zod"; +declare const z_tipos_campos: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros"]>; +export declare const z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodArray; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}>; +export declare const z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}>; +export declare const visoes: { + z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodArray; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; +}; +/** Cria a estrutura de campos para insersão de dados */ +export declare const extruturas_de_campos: { + [z in keyof typeof visoes]: { + /** Nome da Visão */ + visao: z; + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes)[z]>) => string; + /** Descrição */ + descricao: (_: z.infer<(typeof visoes)[z]>) => string; + /** Lista os campos e suas configurações */ + campos: { + [c in keyof z.infer<(typeof visoes)[z]>]: { + tipo_campo: z.infer; + }; + }; + }; +}; +export {}; diff --git a/dist-import/pilao-de-dados/visoes/index.js b/dist-import/pilao-de-dados/visoes/index.js new file mode 100644 index 0000000..e0d34e7 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/index.js @@ -0,0 +1,71 @@ +import { z } from "zod"; +import { z_filtro } from "../_serie_consultar"; +// usar describe para definir o tipo de campo para render do componente +const z_tipos_campos = z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", +]); +export const z_contagem_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaAgrupamento: z.string().array(), + filtros: z_filtro.array(), + descricao_pelo_usuario: z.string(), +}); +export const z_contagem_em_pizza = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + filtros: z_filtro.array(), + descricao_pelo_usuario: z.string(), +}); +export const visoes = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, +}; +/** Cria a estrutura de campos para insersão de dados */ +export const extruturas_de_campos = { + z_contagem_em_barra_vertical: { + visao: "z_contagem_em_barra_vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, colanuEixoX, filtros, colunaAgrupamento, }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}${!colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}`}.`; + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + colunaAgrupamento: { tipo_campo: "lista_colunas" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, + z_contagem_em_pizza: { + visao: "z_contagem_em_pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, colanuEixoX, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, +}; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index de7681c..cc9cd38 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -5,6 +5,162 @@ import { tiposSeriesAgregacoes, zp_produto_conta } from "./variaveis"; import { zp_serie_registrar } from "./_serie_consultar"; export { tiposSeriesAgregacoes }; export declare const pPilao: { + extruturas_de_campos: { + z_contagem_em_barra_vertical: { + visao: "z_contagem_em_barra_vertical"; + tabela: (_: { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + descricao: (_: { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + campos: { + tabela: { + tipo_campo: import("zod").TypeOf>; + }; + colanuEixoX: { + tipo_campo: import("zod").TypeOf>; + }; + colunaAgrupamento: { + tipo_campo: import("zod").TypeOf>; + }; + filtros: { + tipo_campo: import("zod").TypeOf>; + }; + descricao_pelo_usuario: { + tipo_campo: import("zod").TypeOf>; + }; + }; + }; + z_contagem_em_pizza: { + visao: "z_contagem_em_pizza"; + tabela: (_: { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + descricao: (_: { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }) => string; + campos: { + tabela: { + tipo_campo: import("zod").TypeOf>; + }; + colanuEixoX: { + tipo_campo: import("zod").TypeOf>; + }; + filtros: { + tipo_campo: import("zod").TypeOf>; + }; + descricao_pelo_usuario: { + tipo_campo: import("zod").TypeOf>; + }; + }; + }; + }; + z_contagem_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodArray; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; zp_registrar_base_dados: import("zod").ZodObject<{ tabela: import("zod").ZodString; colunas: import("zod").ZodArray" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; + visoes: { + z_contagem_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodArray; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + filtros: import("zod").ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: import("zod").ZodString; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + }; }; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 581e2a9..94ba181 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -9,6 +9,7 @@ const _enviar_registros_1 = require("./_enviar_registros"); const variaveis_2 = require("./variaveis"); Object.defineProperty(exports, "tiposSeriesAgregacoes", { enumerable: true, get: function () { return variaveis_2.tiposSeriesAgregacoes; } }); const _serie_consultar_1 = require("./_serie_consultar"); +const visoes_1 = require("./visoes"); exports.pPilao = { zp_registrar_base_dados: _enviar_registros_1.zp_registrar_base_dados, enviar_registros: _enviar_registros_1.enviar_registros, @@ -22,4 +23,7 @@ exports.pPilao = { operadores_pilao: variaveis_2.operadores_pilao, operadores_permitidos_por_tipo: variaveis_2.operadores_permitidos_por_tipo, z_filtro: _serie_consultar_1.z_filtro, + visoes: visoes_1.visoes, + ...visoes_1.visoes, + extruturas_de_campos: visoes_1.extruturas_de_campos, }; diff --git a/dist-require/pilao-de-dados/visoes/index.d.ts b/dist-require/pilao-de-dados/visoes/index.d.ts new file mode 100644 index 0000000..5e5cdc6 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/index.d.ts @@ -0,0 +1,172 @@ +import { z } from "zod"; +declare const z_tipos_campos: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros"]>; +export declare const z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodArray; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}>; +export declare const z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; +}>; +export declare const visoes: { + z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodArray; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento: string[]; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; + z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + filtros: z.ZodArray", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">; + descricao_pelo_usuario: z.ZodString; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }, { + tabela: string; + colanuEixoX: string; + filtros: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[]; + descricao_pelo_usuario: string; + }>; +}; +/** Cria a estrutura de campos para insersão de dados */ +export declare const extruturas_de_campos: { + [z in keyof typeof visoes]: { + /** Nome da Visão */ + visao: z; + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes)[z]>) => string; + /** Descrição */ + descricao: (_: z.infer<(typeof visoes)[z]>) => string; + /** Lista os campos e suas configurações */ + campos: { + [c in keyof z.infer<(typeof visoes)[z]>]: { + tipo_campo: z.infer; + }; + }; + }; +}; +export {}; diff --git a/dist-require/pilao-de-dados/visoes/index.js b/dist-require/pilao-de-dados/visoes/index.js new file mode 100644 index 0000000..9b43ada --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/index.js @@ -0,0 +1,74 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.extruturas_de_campos = exports.visoes = exports.z_contagem_em_pizza = exports.z_contagem_em_barra_vertical = void 0; +const zod_1 = require("zod"); +const _serie_consultar_1 = require("../_serie_consultar"); +// usar describe para definir o tipo de campo para render do componente +const z_tipos_campos = zod_1.z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", +]); +exports.z_contagem_em_barra_vertical = zod_1.z.object({ + tabela: zod_1.z.string(), + colanuEixoX: zod_1.z.string(), + colunaAgrupamento: zod_1.z.string().array(), + filtros: _serie_consultar_1.z_filtro.array(), + descricao_pelo_usuario: zod_1.z.string(), +}); +exports.z_contagem_em_pizza = zod_1.z.object({ + tabela: zod_1.z.string(), + colanuEixoX: zod_1.z.string(), + filtros: _serie_consultar_1.z_filtro.array(), + descricao_pelo_usuario: zod_1.z.string(), +}); +exports.visoes = { + z_contagem_em_barra_vertical: exports.z_contagem_em_barra_vertical, + z_contagem_em_pizza: exports.z_contagem_em_pizza, +}; +/** Cria a estrutura de campos para insersão de dados */ +exports.extruturas_de_campos = { + z_contagem_em_barra_vertical: { + visao: "z_contagem_em_barra_vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, colanuEixoX, filtros, colunaAgrupamento, }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}${!colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}`}.`; + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + colunaAgrupamento: { tipo_campo: "lista_colunas" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, + z_contagem_em_pizza: { + visao: "z_contagem_em_pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, colanuEixoX, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, +}; diff --git a/package.json b/package.json index 483d5c7..6d764fb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.118.0", + "version": "0.119.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 54e9e10..f864c69 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -18,6 +18,7 @@ import { z_filtro, zp_serie_registrar, } from "./_serie_consultar" +import { extruturas_de_campos, visoes } from "./visoes" export { tiposSeriesAgregacoes } @@ -34,4 +35,7 @@ export const pPilao = { operadores_pilao, operadores_permitidos_por_tipo, z_filtro, + visoes, + ...visoes, + extruturas_de_campos, } diff --git a/src/pilao-de-dados/visoes/index.ts b/src/pilao-de-dados/visoes/index.ts new file mode 100644 index 0000000..cd9ff25 --- /dev/null +++ b/src/pilao-de-dados/visoes/index.ts @@ -0,0 +1,111 @@ +import { z } from "zod" +import { z_filtro } from "../_serie_consultar" +// usar describe para definir o tipo de campo para render do componente + +const z_tipos_campos = z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", +]) + +export const z_contagem_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaAgrupamento: z.string().array(), + filtros: z_filtro.array(), + descricao_pelo_usuario: z.string(), +}) + +export const z_contagem_em_pizza = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + filtros: z_filtro.array(), + descricao_pelo_usuario: z.string(), +}) + +export const visoes = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, +} + +/** Cria a estrutura de campos para insersão de dados */ +export const extruturas_de_campos: { + [z in keyof typeof visoes]: { + /** Nome da Visão */ + visao: z + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes)[z]>) => string + /** Descrição */ + descricao: (_: z.infer<(typeof visoes)[z]>) => string + /** Lista os campos e suas configurações */ + campos: { + [c in keyof z.infer<(typeof visoes)[z]>]: { + tipo_campo: z.infer + } + } + } +} = { + z_contagem_em_barra_vertical: { + visao: "z_contagem_em_barra_vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ + tabela, + descricao_pelo_usuario, + colanuEixoX, + filtros, + colunaAgrupamento, + }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim() + + return `Contagem de ${tabela} por ${colanuEixoX}${ + !filtros?.length + ? "" + : `, quando ${filtros + .map( + ({ coluna, operador, valor }) => + `${coluna} ${operador} ${valor}`, + ) + .join(", ")}` + }${ + !colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}` + }.` + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + colunaAgrupamento: { tipo_campo: "lista_colunas" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, + z_contagem_em_pizza: { + visao: "z_contagem_em_pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, colanuEixoX, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim() + + return `Contagem de ${tabela} por ${colanuEixoX}${ + !filtros?.length + ? "" + : `, quando ${filtros + .map( + ({ coluna, operador, valor }) => + `${coluna} ${operador} ${valor}`, + ) + .join(", ")}` + }.` + }, + campos: { + colanuEixoX: { tipo_campo: "coluna" }, + tabela: { tipo_campo: "tabela" }, + filtros: { tipo_campo: "lista_filtros" }, + descricao_pelo_usuario: { tipo_campo: "texto" }, + }, + }, +}