diff --git a/dist-import/pilao-de-dados/Pilao/index.d.ts b/dist-import/pilao-de-dados/Pilao/index.d.ts index b47e992..c788ccf 100644 --- a/dist-import/pilao-de-dados/Pilao/index.d.ts +++ b/dist-import/pilao-de-dados/Pilao/index.d.ts @@ -3,7 +3,7 @@ import { type tipoResposta } from "p-respostas"; import type { z } from "zod"; import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; -import type { visoes } from "../visoes"; +import type { visoes_pilao } from "../visoes/listaDeVisoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem"; declare class ClassPilao { @@ -20,11 +20,11 @@ declare class ClassPilao { rota: string; url: string; }; - rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rotaConsultarSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao"): { rota: string; url: string; }; - rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rotaIframeSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao"): { rota: string; url: string; }; @@ -40,7 +40,7 @@ declare class ClassPilao { adicionarCodigoParaDeletar(tabela: string, ...codigos: z.infer["codigos"]): this; private processarRegistros; salvarRegistros(): Promise>; - serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { + serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes_pilao)[T]>): { dados: () => Promise>>; url: () => string; }; diff --git a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts index 092b897..2b2a32c 100644 --- a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts @@ -1,11 +1,11 @@ import type { z } from "zod"; -import type { visoes } from "../visoes"; +import type { visoes_pilao } from "../visoes/listaDeVisoes"; export type tipoConstrutorPilao = { produto: string; conta: string; }; -export type tipoRetornoSerieconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[]; legenda: string; - serie: z.infer<(typeof visoes)[T]>; + serie: z.infer<(typeof visoes_pilao)[T]>; }; diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index e34bb4a..9c8d686 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -4,225 +4,10 @@ export * from "./Pilao/pilao-api"; export * from "./Pilao/tipagem"; export declare const pPilao: { extruturas_de_campos: { - z_contagem_em_barra_vertical: { - visao: "z_contagem_em_barra_vertical"; - rotulo: string; - tabela: (_: { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colanuEixoX: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaAgrupamento: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_contagem_em_pizza: { - visao: "z_contagem_em_pizza"; - rotulo: string; - tabela: (_: { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - classes: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_tabela: { - visao: "z_tabela"; - rotulo: string; - tabela: (_: { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }) => string; - descricao: (_: { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunas: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - coluna_ordem: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - direcao_ordem: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_soma_em_barra_vertical: { - visao: "z_soma_em_barra_vertical"; - rotulo: string; - tabela: (_: { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colanuEixoX: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaSoma: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaAgrupamento: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; + z_contagem_em_barra_vertical: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_contagem_em_barra_vertical">; + z_contagem_em_pizza: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_contagem_em_pizza">; + z_tabela: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_tabela">; + z_soma_em_barra_vertical: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_soma_em_barra_vertical">; }; z_contagem_em_barra_vertical: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -486,7 +271,7 @@ export declare const pPilao: { operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; - visoes: { + visoes_pilao: { z_contagem_em_barra_vertical: import("zod").ZodObject<{ tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index c9a02fc..7652c37 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -5,7 +5,8 @@ export * from "./Pilao"; export * from "./Pilao/pilao-api"; export * from "./Pilao/tipagem"; import { z_filtro } from "./_serie_consultar"; -import { extruturas_de_campos, visoes } from "./visoes"; +import { extruturas_de_campos } from "./visoes"; +import { visoes_pilao } from "./visoes/listaDeVisoes"; export const pPilao = { zp_deletar_registros, zp_registrar_base_dados, @@ -16,7 +17,7 @@ export const pPilao = { operadores_pilao, operadores_permitidos_por_tipo, z_filtro, - visoes, - ...visoes, + visoes_pilao, + ...visoes_pilao, extruturas_de_campos, }; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts new file mode 100644 index 0000000..5528f6c --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts @@ -0,0 +1,6 @@ +import type { visoes_pilao } from "../listaDeVisoes"; +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const extruturas_de_campos: { + [T in keyof typeof visoes_pilao]: tipo_estrutura_visao_grafico; +}; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.js b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.js new file mode 100644 index 0000000..26830b4 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.js @@ -0,0 +1,11 @@ +import { z_contagem_em_barra_vertical } from "./z_contagem_em_barra_vertical"; +import { z_contagem_em_pizza } from "./z_contagem_em_pizza"; +import { z_soma_em_barra_vertical } from "./z_soma_em_barra_vertical"; +import { z_tabela } from "./z_tabela"; +/** Cria a estrutura de campos para insersão de dados */ +export const extruturas_de_campos = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, + z_soma_em_barra_vertical, + z_tabela, +}; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts new file mode 100644 index 0000000..245eb35 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_contagem_em_barra_vertical: tipo_estrutura_visao_grafico<"z_contagem_em_barra_vertical">; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js new file mode 100644 index 0000000..a9d9658 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js @@ -0,0 +1,37 @@ +// usar describe para definir o tipo de campo para render do componente +/** Cria a estrutura de campos para insersão de dados */ +export const z_contagem_em_barra_vertical = { + visao: "z_contagem_em_barra_vertical", + rotulo: "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: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 2, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 3, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 4, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, +}; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts new file mode 100644 index 0000000..206a144 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_contagem_em_pizza: tipo_estrutura_visao_grafico<"z_contagem_em_pizza">; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js new file mode 100644 index 0000000..21d07ad --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js @@ -0,0 +1,26 @@ +// usar describe para definir o tipo de campo para render do componente +/** Cria a estrutura de campos para insersão de dados */ +export const z_contagem_em_pizza = { + visao: "z_contagem_em_pizza", + rotulo: "Contagem em Pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${classes}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, + }, +}; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts new file mode 100644 index 0000000..7049fd1 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_soma_em_barra_vertical: tipo_estrutura_visao_grafico<"z_soma_em_barra_vertical">; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js new file mode 100644 index 0000000..38113c6 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js @@ -0,0 +1,42 @@ +// usar describe para definir o tipo de campo para render do componente +/** Cria a estrutura de campos para insersão de dados */ +export const z_soma_em_barra_vertical = { + visao: "z_soma_em_barra_vertical", + rotulo: "Soma em Barra Vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ descricao_pelo_usuario, colanuEixoX, filtros, colunaAgrupamento, colunaSoma, }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Soma de ${colunaSoma} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}${!colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colunaSoma: { + rotulo: "Coluna de Somatória", + tipo_campo: "coluna", + order: 2, + }, + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 3, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 4, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 5, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, +}; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts new file mode 100644 index 0000000..66bead7 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_tabela: tipo_estrutura_visao_grafico<"z_tabela">; diff --git a/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js new file mode 100644 index 0000000..7b23797 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js @@ -0,0 +1,36 @@ +// usar describe para definir o tipo de campo para render do componente +/** Cria a estrutura de campos para insersão de dados */ +export const z_tabela = { + visao: "z_tabela", + rotulo: "Tabela", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Consulta na ${tabela} ${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + coluna_ordem: { + rotulo: "Coluna de Ordem", + tipo_campo: "coluna", + order: 4, + }, + direcao_ordem: { + rotulo: "Direção de Ordem", + tipo_campo: "ordem", + order: 5, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, + }, +}; diff --git a/dist-import/pilao-de-dados/visoes/index.d.ts b/dist-import/pilao-de-dados/visoes/index.d.ts index c6b4e06..4070a97 100644 --- a/dist-import/pilao-de-dados/visoes/index.d.ts +++ b/dist-import/pilao-de-dados/visoes/index.d.ts @@ -1,344 +1 @@ -import { z } from "zod"; -declare const z_tipos_campos: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros", "ordem"]>; -export declare const z_contagem_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_soma_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaSoma: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_contagem_em_pizza: z.ZodObject<{ - tabela: z.ZodString; - classes: z.ZodString; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_tabela: z.ZodObject<{ - tabela: z.ZodString; - colunas: z.ZodArray; - coluna_ordem: z.ZodOptional; - direcao_ordem: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; -}, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; -}>; -export declare const visoes: { - z_contagem_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; - z_contagem_em_pizza: z.ZodObject<{ - tabela: z.ZodString; - classes: z.ZodString; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; - z_tabela: z.ZodObject<{ - tabela: z.ZodString; - colunas: z.ZodArray; - coluna_ordem: z.ZodOptional; - direcao_ordem: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }>; - z_soma_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaSoma: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; -}; -/** 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; - /** Rotulo */ - rotulo: string; - /** 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 Required>]: { - rotulo: string; - tipo_campo: z.infer; - order: number; - }; - }; - }; -}; -export {}; +export * from "./estrutura_de_campos"; diff --git a/dist-import/pilao-de-dados/visoes/index.js b/dist-import/pilao-de-dados/visoes/index.js index 0a148f6..4070a97 100644 --- a/dist-import/pilao-de-dados/visoes/index.js +++ b/dist-import/pilao-de-dados/visoes/index.js @@ -1,182 +1 @@ -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", - "ordem", -]); -export const z_contagem_em_barra_vertical = z.object({ - tabela: z.string(), - colanuEixoX: z.string(), - colunaAgrupamento: z.string().array().optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}); -export const z_soma_em_barra_vertical = z.object({ - tabela: z.string(), - colanuEixoX: z.string(), - colunaSoma: z.string(), - colunaAgrupamento: z.string().array().optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}); -export const z_contagem_em_pizza = z.object({ - tabela: z.string(), - classes: z.string(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}); -export const z_tabela = z.object({ - tabela: z.string(), - colunas: z.string().array(), - coluna_ordem: z.string().optional(), - direcao_ordem: z.enum(["asc", "desc", "1", "-1"]).optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}); -export const visoes = { - z_contagem_em_barra_vertical, - z_contagem_em_pizza, - z_tabela, - z_soma_em_barra_vertical, -}; -/** 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", - rotulo: "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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 2, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 3, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 4, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_soma_em_barra_vertical: { - visao: "z_soma_em_barra_vertical", - rotulo: "Soma 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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colunaSoma: { - rotulo: "Coluna de Somatória", - tipo_campo: "coluna", - order: 2, - }, - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 3, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 4, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 5, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_contagem_em_pizza: { - visao: "z_contagem_em_pizza", - rotulo: "Contagem em Pizza", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim(); - return `Contagem de ${tabela} por ${classes}${!filtros?.length - ? "" - : `, quando ${filtros - .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) - .join(", ")}`}.`; - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, - }, - }, - z_tabela: { - visao: "z_tabela", - rotulo: "Tabela", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim(); - return `Consulta na ${tabela} ${!filtros?.length - ? "" - : `, quando ${filtros - .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) - .join(", ")}`}.`; - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - coluna_ordem: { - rotulo: "Coluna de Ordem", - tipo_campo: "coluna", - order: 4, - }, - direcao_ordem: { - rotulo: "Direção de Ordem", - tipo_campo: "ordem", - order: 5, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, - }, - }, -}; +export * from "./estrutura_de_campos"; diff --git a/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts b/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts new file mode 100644 index 0000000..31bc50e --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts @@ -0,0 +1,321 @@ +import { z } from "zod"; +export declare const z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_soma_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaSoma: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + classes: z.ZodString; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_tabela: z.ZodObject<{ + tabela: z.ZodString; + colunas: z.ZodArray; + coluna_ordem: z.ZodOptional; + direcao_ordem: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; +}, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; +}>; +export declare const visoes_pilao: { + z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; + z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + classes: z.ZodString; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; + z_tabela: z.ZodObject<{ + tabela: z.ZodString; + colunas: z.ZodArray; + coluna_ordem: z.ZodOptional; + direcao_ordem: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; + }, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; + }>; + z_soma_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaSoma: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; +}; diff --git a/dist-import/pilao-de-dados/visoes/listaDeVisoes.js b/dist-import/pilao-de-dados/visoes/listaDeVisoes.js new file mode 100644 index 0000000..cde2085 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/listaDeVisoes.js @@ -0,0 +1,37 @@ +import { z } from "zod"; +import { z_filtro } from "../_serie_consultar"; +export const z_contagem_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaAgrupamento: z.string().array().optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}); +export const z_soma_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaSoma: z.string(), + colunaAgrupamento: z.string().array().optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}); +export const z_contagem_em_pizza = z.object({ + tabela: z.string(), + classes: z.string(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}); +export const z_tabela = z.object({ + tabela: z.string(), + colunas: z.string().array(), + coluna_ordem: z.string().optional(), + direcao_ordem: z.enum(["asc", "desc", "1", "-1"]).optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}); +export const visoes_pilao = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, + z_tabela, + z_soma_em_barra_vertical, +}; diff --git a/dist-import/pilao-de-dados/visoes/tipagem.d.ts b/dist-import/pilao-de-dados/visoes/tipagem.d.ts new file mode 100644 index 0000000..0f9c98d --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/tipagem.d.ts @@ -0,0 +1,21 @@ +import { z } from "zod"; +import type { visoes_pilao } from "./listaDeVisoes"; +export declare const z_tipos_campos_reg_grafico: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros", "ordem"]>; +export type tipo_estrutura_visao_grafico = { + /** Nome da Visão */ + visao: T; + /** Rotulo */ + rotulo: string; + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes_pilao)[T]>) => string; + /** Descrição */ + descricao: (_: z.infer<(typeof visoes_pilao)[T]>) => string; + /** Lista os campos e suas configurações */ + campos: { + [c in keyof Required>]: { + rotulo: string; + tipo_campo: z.infer; + order: number; + }; + }; +}; diff --git a/dist-import/pilao-de-dados/visoes/tipagem.js b/dist-import/pilao-de-dados/visoes/tipagem.js new file mode 100644 index 0000000..26adb50 --- /dev/null +++ b/dist-import/pilao-de-dados/visoes/tipagem.js @@ -0,0 +1,9 @@ +import { z } from "zod"; +export const z_tipos_campos_reg_grafico = z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", + "ordem", +]); diff --git a/dist-require/pilao-de-dados/Pilao/index.d.ts b/dist-require/pilao-de-dados/Pilao/index.d.ts index b47e992..c788ccf 100644 --- a/dist-require/pilao-de-dados/Pilao/index.d.ts +++ b/dist-require/pilao-de-dados/Pilao/index.d.ts @@ -3,7 +3,7 @@ import { type tipoResposta } from "p-respostas"; import type { z } from "zod"; import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; -import type { visoes } from "../visoes"; +import type { visoes_pilao } from "../visoes/listaDeVisoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem"; declare class ClassPilao { @@ -20,11 +20,11 @@ declare class ClassPilao { rota: string; url: string; }; - rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rotaConsultarSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao"): { rota: string; url: string; }; - rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rotaIframeSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao"): { rota: string; url: string; }; @@ -40,7 +40,7 @@ declare class ClassPilao { adicionarCodigoParaDeletar(tabela: string, ...codigos: z.infer["codigos"]): this; private processarRegistros; salvarRegistros(): Promise>; - serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { + serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes_pilao)[T]>): { dados: () => Promise>>; url: () => string; }; diff --git a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts index 092b897..2b2a32c 100644 --- a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts @@ -1,11 +1,11 @@ import type { z } from "zod"; -import type { visoes } from "../visoes"; +import type { visoes_pilao } from "../visoes/listaDeVisoes"; export type tipoConstrutorPilao = { produto: string; conta: string; }; -export type tipoRetornoSerieconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[]; legenda: string; - serie: z.infer<(typeof visoes)[T]>; + serie: z.infer<(typeof visoes_pilao)[T]>; }; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index e34bb4a..9c8d686 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -4,225 +4,10 @@ export * from "./Pilao/pilao-api"; export * from "./Pilao/tipagem"; export declare const pPilao: { extruturas_de_campos: { - z_contagem_em_barra_vertical: { - visao: "z_contagem_em_barra_vertical"; - rotulo: string; - tabela: (_: { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colanuEixoX: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaAgrupamento: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_contagem_em_pizza: { - visao: "z_contagem_em_pizza"; - rotulo: string; - tabela: (_: { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - classes: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_tabela: { - visao: "z_tabela"; - rotulo: string; - tabela: (_: { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }) => string; - descricao: (_: { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunas: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - coluna_ordem: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - direcao_ordem: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; - z_soma_em_barra_vertical: { - visao: "z_soma_em_barra_vertical"; - rotulo: string; - tabela: (_: { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - descricao: (_: { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }) => string; - campos: { - tabela: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colanuEixoX: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaSoma: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - colunaAgrupamento: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - filtros: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - descricao_pelo_usuario: { - rotulo: string; - tipo_campo: import("zod").TypeOf>; - order: number; - }; - }; - }; + z_contagem_em_barra_vertical: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_contagem_em_barra_vertical">; + z_contagem_em_pizza: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_contagem_em_pizza">; + z_tabela: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_tabela">; + z_soma_em_barra_vertical: import("./visoes/tipagem").tipo_estrutura_visao_grafico<"z_soma_em_barra_vertical">; }; z_contagem_em_barra_vertical: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -486,7 +271,7 @@ export declare const pPilao: { operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; - visoes: { + visoes_pilao: { z_contagem_em_barra_vertical: import("zod").ZodObject<{ tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index b3165c1..5fb4413 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -25,6 +25,7 @@ __exportStar(require("./Pilao/pilao-api"), exports); __exportStar(require("./Pilao/tipagem"), exports); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); +const listaDeVisoes_1 = require("./visoes/listaDeVisoes"); exports.pPilao = { zp_deletar_registros: variaveis_2.zp_deletar_registros, zp_registrar_base_dados: _enviar_registros_1.zp_registrar_base_dados, @@ -35,7 +36,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, + visoes_pilao: listaDeVisoes_1.visoes_pilao, + ...listaDeVisoes_1.visoes_pilao, extruturas_de_campos: visoes_1.extruturas_de_campos, }; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts new file mode 100644 index 0000000..5528f6c --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts @@ -0,0 +1,6 @@ +import type { visoes_pilao } from "../listaDeVisoes"; +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const extruturas_de_campos: { + [T in keyof typeof visoes_pilao]: tipo_estrutura_visao_grafico; +}; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.js b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.js new file mode 100644 index 0000000..0dd2535 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.js @@ -0,0 +1,14 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.extruturas_de_campos = void 0; +const z_contagem_em_barra_vertical_1 = require("./z_contagem_em_barra_vertical"); +const z_contagem_em_pizza_1 = require("./z_contagem_em_pizza"); +const z_soma_em_barra_vertical_1 = require("./z_soma_em_barra_vertical"); +const z_tabela_1 = require("./z_tabela"); +/** Cria a estrutura de campos para insersão de dados */ +exports.extruturas_de_campos = { + z_contagem_em_barra_vertical: z_contagem_em_barra_vertical_1.z_contagem_em_barra_vertical, + z_contagem_em_pizza: z_contagem_em_pizza_1.z_contagem_em_pizza, + z_soma_em_barra_vertical: z_soma_em_barra_vertical_1.z_soma_em_barra_vertical, + z_tabela: z_tabela_1.z_tabela, +}; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts new file mode 100644 index 0000000..245eb35 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_contagem_em_barra_vertical: tipo_estrutura_visao_grafico<"z_contagem_em_barra_vertical">; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js new file mode 100644 index 0000000..9ab5add --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js @@ -0,0 +1,40 @@ +"use strict"; +// usar describe para definir o tipo de campo para render do componente +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z_contagem_em_barra_vertical = void 0; +/** Cria a estrutura de campos para insersão de dados */ +exports.z_contagem_em_barra_vertical = { + visao: "z_contagem_em_barra_vertical", + rotulo: "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: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 2, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 3, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 4, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, +}; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts new file mode 100644 index 0000000..206a144 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_contagem_em_pizza: tipo_estrutura_visao_grafico<"z_contagem_em_pizza">; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js new file mode 100644 index 0000000..bf651d8 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js @@ -0,0 +1,29 @@ +"use strict"; +// usar describe para definir o tipo de campo para render do componente +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z_contagem_em_pizza = void 0; +/** Cria a estrutura de campos para insersão de dados */ +exports.z_contagem_em_pizza = { + visao: "z_contagem_em_pizza", + rotulo: "Contagem em Pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Contagem de ${tabela} por ${classes}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, + }, +}; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts new file mode 100644 index 0000000..7049fd1 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_soma_em_barra_vertical: tipo_estrutura_visao_grafico<"z_soma_em_barra_vertical">; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js new file mode 100644 index 0000000..67001be --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js @@ -0,0 +1,45 @@ +"use strict"; +// usar describe para definir o tipo de campo para render do componente +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z_soma_em_barra_vertical = void 0; +/** Cria a estrutura de campos para insersão de dados */ +exports.z_soma_em_barra_vertical = { + visao: "z_soma_em_barra_vertical", + rotulo: "Soma em Barra Vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ descricao_pelo_usuario, colanuEixoX, filtros, colunaAgrupamento, colunaSoma, }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Soma de ${colunaSoma} por ${colanuEixoX}${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}${!colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colunaSoma: { + rotulo: "Coluna de Somatória", + tipo_campo: "coluna", + order: 2, + }, + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 3, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 4, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 5, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, +}; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts new file mode 100644 index 0000000..66bead7 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts @@ -0,0 +1,3 @@ +import type { tipo_estrutura_visao_grafico } from "../tipagem"; +/** Cria a estrutura de campos para insersão de dados */ +export declare const z_tabela: tipo_estrutura_visao_grafico<"z_tabela">; diff --git a/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js new file mode 100644 index 0000000..38dfdb0 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js @@ -0,0 +1,39 @@ +"use strict"; +// usar describe para definir o tipo de campo para render do componente +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z_tabela = void 0; +/** Cria a estrutura de campos para insersão de dados */ +exports.z_tabela = { + visao: "z_tabela", + rotulo: "Tabela", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim(); + return `Consulta na ${tabela} ${!filtros?.length + ? "" + : `, quando ${filtros + .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) + .join(", ")}`}.`; + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + coluna_ordem: { + rotulo: "Coluna de Ordem", + tipo_campo: "coluna", + order: 4, + }, + direcao_ordem: { + rotulo: "Direção de Ordem", + tipo_campo: "ordem", + order: 5, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, + }, +}; diff --git a/dist-require/pilao-de-dados/visoes/index.d.ts b/dist-require/pilao-de-dados/visoes/index.d.ts index c6b4e06..4070a97 100644 --- a/dist-require/pilao-de-dados/visoes/index.d.ts +++ b/dist-require/pilao-de-dados/visoes/index.d.ts @@ -1,344 +1 @@ -import { z } from "zod"; -declare const z_tipos_campos: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros", "ordem"]>; -export declare const z_contagem_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_soma_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaSoma: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_contagem_em_pizza: z.ZodObject<{ - tabela: z.ZodString; - classes: z.ZodString; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; -}>; -export declare const z_tabela: z.ZodObject<{ - tabela: z.ZodString; - colunas: z.ZodArray; - coluna_ordem: z.ZodOptional; - direcao_ordem: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; -}, "strip", z.ZodTypeAny, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; -}, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; -}>; -export declare const visoes: { - z_contagem_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - colanuEixoX: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; - z_contagem_em_pizza: z.ZodObject<{ - tabela: z.ZodString; - classes: z.ZodString; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - classes: string; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; - z_tabela: z.ZodObject<{ - tabela: z.ZodString; - colunas: z.ZodArray; - coluna_ordem: z.ZodOptional; - direcao_ordem: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }, { - tabela: string; - colunas: string[]; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - coluna_ordem?: string | undefined; - direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; - }>; - z_soma_em_barra_vertical: z.ZodObject<{ - tabela: z.ZodString; - colanuEixoX: z.ZodString; - colunaSoma: z.ZodString; - colunaAgrupamento: z.ZodOptional>; - filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; - }, "strip", z.ZodTypeAny, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }, { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }>, "many">>; - descricao_pelo_usuario: z.ZodOptional; - }, "strip", z.ZodTypeAny, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }, { - tabela: string; - colanuEixoX: string; - colunaSoma: string; - colunaAgrupamento?: string[] | undefined; - filtros?: { - coluna: string; - operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; - valor?: any; - }[] | undefined; - descricao_pelo_usuario?: string | undefined; - }>; -}; -/** 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; - /** Rotulo */ - rotulo: string; - /** 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 Required>]: { - rotulo: string; - tipo_campo: z.infer; - order: number; - }; - }; - }; -}; -export {}; +export * from "./estrutura_de_campos"; diff --git a/dist-require/pilao-de-dados/visoes/index.js b/dist-require/pilao-de-dados/visoes/index.js index 1f41b3e..6d92bf7 100644 --- a/dist-require/pilao-de-dados/visoes/index.js +++ b/dist-require/pilao-de-dados/visoes/index.js @@ -1,185 +1,17 @@ "use strict"; +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.extruturas_de_campos = exports.visoes = exports.z_tabela = exports.z_contagem_em_pizza = exports.z_soma_em_barra_vertical = 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", - "ordem", -]); -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().optional(), - filtros: _serie_consultar_1.z_filtro.array().optional(), - descricao_pelo_usuario: zod_1.z.string().optional(), -}); -exports.z_soma_em_barra_vertical = zod_1.z.object({ - tabela: zod_1.z.string(), - colanuEixoX: zod_1.z.string(), - colunaSoma: zod_1.z.string(), - colunaAgrupamento: zod_1.z.string().array().optional(), - filtros: _serie_consultar_1.z_filtro.array().optional(), - descricao_pelo_usuario: zod_1.z.string().optional(), -}); -exports.z_contagem_em_pizza = zod_1.z.object({ - tabela: zod_1.z.string(), - classes: zod_1.z.string(), - filtros: _serie_consultar_1.z_filtro.array().optional(), - descricao_pelo_usuario: zod_1.z.string().optional(), -}); -exports.z_tabela = zod_1.z.object({ - tabela: zod_1.z.string(), - colunas: zod_1.z.string().array(), - coluna_ordem: zod_1.z.string().optional(), - direcao_ordem: zod_1.z.enum(["asc", "desc", "1", "-1"]).optional(), - filtros: _serie_consultar_1.z_filtro.array().optional(), - descricao_pelo_usuario: zod_1.z.string().optional(), -}); -exports.visoes = { - z_contagem_em_barra_vertical: exports.z_contagem_em_barra_vertical, - z_contagem_em_pizza: exports.z_contagem_em_pizza, - z_tabela: exports.z_tabela, - z_soma_em_barra_vertical: exports.z_soma_em_barra_vertical, -}; -/** 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", - rotulo: "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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 2, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 3, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 4, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_soma_em_barra_vertical: { - visao: "z_soma_em_barra_vertical", - rotulo: "Soma 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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colunaSoma: { - rotulo: "Coluna de Somatória", - tipo_campo: "coluna", - order: 2, - }, - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 3, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 4, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 5, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_contagem_em_pizza: { - visao: "z_contagem_em_pizza", - rotulo: "Contagem em Pizza", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim(); - return `Contagem de ${tabela} por ${classes}${!filtros?.length - ? "" - : `, quando ${filtros - .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) - .join(", ")}`}.`; - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, - }, - }, - z_tabela: { - visao: "z_tabela", - rotulo: "Tabela", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim(); - return `Consulta na ${tabela} ${!filtros?.length - ? "" - : `, quando ${filtros - .map(({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`) - .join(", ")}`}.`; - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - coluna_ordem: { - rotulo: "Coluna de Ordem", - tipo_campo: "coluna", - order: 4, - }, - direcao_ordem: { - rotulo: "Direção de Ordem", - tipo_campo: "ordem", - order: 5, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, - }, - }, -}; +__exportStar(require("./estrutura_de_campos"), exports); diff --git a/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts b/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts new file mode 100644 index 0000000..31bc50e --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts @@ -0,0 +1,321 @@ +import { z } from "zod"; +export declare const z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_soma_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaSoma: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + classes: z.ZodString; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; +}>; +export declare const z_tabela: z.ZodObject<{ + tabela: z.ZodString; + colunas: z.ZodArray; + coluna_ordem: z.ZodOptional; + direcao_ordem: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; +}, "strip", z.ZodTypeAny, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; +}, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; +}>; +export declare const visoes_pilao: { + z_contagem_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + colanuEixoX: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; + z_contagem_em_pizza: z.ZodObject<{ + tabela: z.ZodString; + classes: z.ZodString; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + classes: string; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; + z_tabela: z.ZodObject<{ + tabela: z.ZodString; + colunas: z.ZodArray; + coluna_ordem: z.ZodOptional; + direcao_ordem: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; + }, { + tabela: string; + colunas: string[]; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + coluna_ordem?: string | undefined; + direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; + }>; + z_soma_em_barra_vertical: z.ZodObject<{ + tabela: z.ZodString; + colanuEixoX: z.ZodString; + colunaSoma: z.ZodString; + colunaAgrupamento: z.ZodOptional>; + filtros: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", z.ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: z.ZodOptional; + }, "strip", z.ZodTypeAny, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }, { + tabela: string; + colanuEixoX: string; + colunaSoma: string; + colunaAgrupamento?: string[] | undefined; + filtros?: { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }[] | undefined; + descricao_pelo_usuario?: string | undefined; + }>; +}; diff --git a/dist-require/pilao-de-dados/visoes/listaDeVisoes.js b/dist-require/pilao-de-dados/visoes/listaDeVisoes.js new file mode 100644 index 0000000..8caa9b8 --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/listaDeVisoes.js @@ -0,0 +1,40 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.visoes_pilao = exports.z_tabela = exports.z_contagem_em_pizza = exports.z_soma_em_barra_vertical = exports.z_contagem_em_barra_vertical = void 0; +const zod_1 = require("zod"); +const _serie_consultar_1 = require("../_serie_consultar"); +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().optional(), + filtros: _serie_consultar_1.z_filtro.array().optional(), + descricao_pelo_usuario: zod_1.z.string().optional(), +}); +exports.z_soma_em_barra_vertical = zod_1.z.object({ + tabela: zod_1.z.string(), + colanuEixoX: zod_1.z.string(), + colunaSoma: zod_1.z.string(), + colunaAgrupamento: zod_1.z.string().array().optional(), + filtros: _serie_consultar_1.z_filtro.array().optional(), + descricao_pelo_usuario: zod_1.z.string().optional(), +}); +exports.z_contagem_em_pizza = zod_1.z.object({ + tabela: zod_1.z.string(), + classes: zod_1.z.string(), + filtros: _serie_consultar_1.z_filtro.array().optional(), + descricao_pelo_usuario: zod_1.z.string().optional(), +}); +exports.z_tabela = zod_1.z.object({ + tabela: zod_1.z.string(), + colunas: zod_1.z.string().array(), + coluna_ordem: zod_1.z.string().optional(), + direcao_ordem: zod_1.z.enum(["asc", "desc", "1", "-1"]).optional(), + filtros: _serie_consultar_1.z_filtro.array().optional(), + descricao_pelo_usuario: zod_1.z.string().optional(), +}); +exports.visoes_pilao = { + z_contagem_em_barra_vertical: exports.z_contagem_em_barra_vertical, + z_contagem_em_pizza: exports.z_contagem_em_pizza, + z_tabela: exports.z_tabela, + z_soma_em_barra_vertical: exports.z_soma_em_barra_vertical, +}; diff --git a/dist-require/pilao-de-dados/visoes/tipagem.d.ts b/dist-require/pilao-de-dados/visoes/tipagem.d.ts new file mode 100644 index 0000000..0f9c98d --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/tipagem.d.ts @@ -0,0 +1,21 @@ +import { z } from "zod"; +import type { visoes_pilao } from "./listaDeVisoes"; +export declare const z_tipos_campos_reg_grafico: z.ZodEnum<["tabela", "coluna", "texto", "lista_colunas", "lista_filtros", "ordem"]>; +export type tipo_estrutura_visao_grafico = { + /** Nome da Visão */ + visao: T; + /** Rotulo */ + rotulo: string; + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes_pilao)[T]>) => string; + /** Descrição */ + descricao: (_: z.infer<(typeof visoes_pilao)[T]>) => string; + /** Lista os campos e suas configurações */ + campos: { + [c in keyof Required>]: { + rotulo: string; + tipo_campo: z.infer; + order: number; + }; + }; +}; diff --git a/dist-require/pilao-de-dados/visoes/tipagem.js b/dist-require/pilao-de-dados/visoes/tipagem.js new file mode 100644 index 0000000..0d7b4fd --- /dev/null +++ b/dist-require/pilao-de-dados/visoes/tipagem.js @@ -0,0 +1,12 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.z_tipos_campos_reg_grafico = void 0; +const zod_1 = require("zod"); +exports.z_tipos_campos_reg_grafico = zod_1.z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", + "ordem", +]); diff --git a/package.json b/package.json index b573697..395cc7c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.173.0", + "version": "0.176.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/Pilao/index.ts b/src/pilao-de-dados/Pilao/index.ts index ba075b6..56c05b6 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -8,7 +8,8 @@ import type { z } from "zod" import type { zp_enviar_registros } from "../_enviar_registros" import { PREFIXO_PILAO, type zp_deletar_registros } from "../variaveis" -import type { visoes } from "../visoes" + +import type { visoes_pilao } from "../visoes/listaDeVisoes" import type { tipo_pilao_api } from "./pilao-api.ts" import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem" @@ -54,11 +55,11 @@ class ClassPilao { return this.#gerarUrl("deletar-registros") } - rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { + rotaConsultarSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao") { return this.#gerarUrl("consultar-serie", tipoVisao) } - rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { + rotaIframeSerie(tipoVisao: keyof typeof visoes_pilao | ":tipoVisao") { const rota = `${PREFIXO_PILAO}/consultar-serie/${this.#produto}/${this.#conta}/${tipoVisao}` const url = `${this.baseUrlSite}${rota}` return { rota, url } @@ -219,9 +220,9 @@ class ClassPilao { return respostaComuns.valor(true) } - serieConsultar( + serieConsultar( tipoVisao: T, - parametros: z.infer<(typeof visoes)[T]>, + parametros: z.infer<(typeof visoes_pilao)[T]>, ) { const dados = async (): Promise< tipoResposta> diff --git a/src/pilao-de-dados/Pilao/tipagem.ts b/src/pilao-de-dados/Pilao/tipagem.ts index 30f3a6e..23c4794 100644 --- a/src/pilao-de-dados/Pilao/tipagem.ts +++ b/src/pilao-de-dados/Pilao/tipagem.ts @@ -1,10 +1,10 @@ import type { z } from "zod" -import type { visoes } from "../visoes" +import type { visoes_pilao } from "../visoes/listaDeVisoes" export type tipoConstrutorPilao = { produto: string; conta: string } -export type tipoRetornoSerieconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[] legenda: string - serie: z.infer<(typeof visoes)[T]> + serie: z.infer<(typeof visoes_pilao)[T]> } diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index b82b560..f27b4b0 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -17,7 +17,8 @@ export * from "./Pilao/pilao-api" export * from "./Pilao/tipagem" import { z_filtro } from "./_serie_consultar" -import { extruturas_de_campos, visoes } from "./visoes" +import { extruturas_de_campos } from "./visoes" +import { visoes_pilao } from "./visoes/listaDeVisoes" export const pPilao = { zp_deletar_registros, @@ -31,7 +32,7 @@ export const pPilao = { operadores_pilao, operadores_permitidos_por_tipo, z_filtro, - visoes, - ...visoes, + visoes_pilao, + ...visoes_pilao, extruturas_de_campos, } diff --git a/src/pilao-de-dados/visoes/estrutura_de_campos/index.ts b/src/pilao-de-dados/visoes/estrutura_de_campos/index.ts new file mode 100644 index 0000000..9aabdf9 --- /dev/null +++ b/src/pilao-de-dados/visoes/estrutura_de_campos/index.ts @@ -0,0 +1,16 @@ +import type { visoes_pilao } from "../listaDeVisoes" +import type { tipo_estrutura_visao_grafico } from "../tipagem" +import { z_contagem_em_barra_vertical } from "./z_contagem_em_barra_vertical" +import { z_contagem_em_pizza } from "./z_contagem_em_pizza" +import { z_soma_em_barra_vertical } from "./z_soma_em_barra_vertical" +import { z_tabela } from "./z_tabela" + +/** Cria a estrutura de campos para insersão de dados */ +export const extruturas_de_campos: { + [T in keyof typeof visoes_pilao]: tipo_estrutura_visao_grafico +} = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, + z_soma_em_barra_vertical, + z_tabela, +} diff --git a/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.ts b/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.ts new file mode 100644 index 0000000..7081ba1 --- /dev/null +++ b/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.ts @@ -0,0 +1,56 @@ +// usar describe para definir o tipo de campo para render do componente + +import type { tipo_estrutura_visao_grafico } from "../tipagem" + +/** Cria a estrutura de campos para insersão de dados */ +export const z_contagem_em_barra_vertical: tipo_estrutura_visao_grafico<"z_contagem_em_barra_vertical"> = + { + visao: "z_contagem_em_barra_vertical", + rotulo: "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: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 2, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 3, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 4, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, + } diff --git a/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.ts b/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.ts new file mode 100644 index 0000000..c8dce3f --- /dev/null +++ b/src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.ts @@ -0,0 +1,36 @@ +// usar describe para definir o tipo de campo para render do componente + +import type { tipo_estrutura_visao_grafico } from "../tipagem" + +/** Cria a estrutura de campos para insersão de dados */ +export const z_contagem_em_pizza: tipo_estrutura_visao_grafico<"z_contagem_em_pizza"> = + { + visao: "z_contagem_em_pizza", + rotulo: "Contagem em Pizza", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim() + + return `Contagem de ${tabela} por ${classes}${ + !filtros?.length + ? "" + : `, quando ${filtros + .map( + ({ coluna, operador, valor }) => + `${coluna} ${operador} ${valor}`, + ) + .join(", ")}` + }.` + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, + }, + } diff --git a/src/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.ts b/src/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.ts new file mode 100644 index 0000000..dca5661 --- /dev/null +++ b/src/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.ts @@ -0,0 +1,62 @@ +// usar describe para definir o tipo de campo para render do componente + +import type { tipo_estrutura_visao_grafico } from "../tipagem" + +/** Cria a estrutura de campos para insersão de dados */ +export const z_soma_em_barra_vertical: tipo_estrutura_visao_grafico<"z_soma_em_barra_vertical"> = + { + visao: "z_soma_em_barra_vertical", + rotulo: "Soma em Barra Vertical", + tabela: ({ tabela }) => tabela, + descricao: ({ + descricao_pelo_usuario, + colanuEixoX, + filtros, + colunaAgrupamento, + colunaSoma, + }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim() + + return `Soma de ${colunaSoma} por ${colanuEixoX}${ + !filtros?.length + ? "" + : `, quando ${filtros + .map( + ({ coluna, operador, valor }) => + `${coluna} ${operador} ${valor}`, + ) + .join(", ")}` + }${ + !colunaAgrupamento?.length + ? "" + : `, agrupado por ${colunaAgrupamento.join(", ")}` + }.` + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + + colunaSoma: { + rotulo: "Coluna de Somatória", + tipo_campo: "coluna", + order: 2, + }, + + colanuEixoX: { + rotulo: "Coluna do Eixo X", + tipo_campo: "coluna", + order: 3, + }, + colunaAgrupamento: { + rotulo: "Colunas de Agrupamento", + tipo_campo: "lista_colunas", + order: 4, + }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 5, + }, + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, + }, + } diff --git a/src/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.ts b/src/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.ts new file mode 100644 index 0000000..772b067 --- /dev/null +++ b/src/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.ts @@ -0,0 +1,45 @@ +// usar describe para definir o tipo de campo para render do componente + +import type { tipo_estrutura_visao_grafico } from "../tipagem" + +/** Cria a estrutura de campos para insersão de dados */ +export const z_tabela: tipo_estrutura_visao_grafico<"z_tabela"> = { + visao: "z_tabela", + rotulo: "Tabela", + tabela: ({ tabela }) => tabela, + descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { + if (String(descricao_pelo_usuario || "").trim()) + return String(descricao_pelo_usuario || "").trim() + + return `Consulta na ${tabela} ${ + !filtros?.length + ? "" + : `, quando ${filtros + .map( + ({ coluna, operador, valor }) => `${coluna} ${operador} ${valor}`, + ) + .join(", ")}` + }.` + }, + campos: { + tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, + colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, + descricao_pelo_usuario: { + rotulo: "Descrição (opcional)", + tipo_campo: "texto", + order: 3, + }, + coluna_ordem: { + rotulo: "Coluna de Ordem", + tipo_campo: "coluna", + order: 4, + }, + direcao_ordem: { + rotulo: "Direção de Ordem", + tipo_campo: "ordem", + order: 5, + }, + + filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, + }, +} diff --git a/src/pilao-de-dados/visoes/index.ts b/src/pilao-de-dados/visoes/index.ts index 8399342..41627b3 100644 --- a/src/pilao-de-dados/visoes/index.ts +++ b/src/pilao-de-dados/visoes/index.ts @@ -1,253 +1 @@ -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", - "ordem", -]) - -export const z_contagem_em_barra_vertical = z.object({ - tabela: z.string(), - colanuEixoX: z.string(), - colunaAgrupamento: z.string().array().optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}) - -export const z_soma_em_barra_vertical = z.object({ - tabela: z.string(), - colanuEixoX: z.string(), - colunaSoma: z.string(), - colunaAgrupamento: z.string().array().optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}) - -export const z_contagem_em_pizza = z.object({ - tabela: z.string(), - classes: z.string(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}) - -export const z_tabela = z.object({ - tabela: z.string(), - colunas: z.string().array(), - coluna_ordem: z.string().optional(), - direcao_ordem: z.enum(["asc", "desc", "1", "-1"]).optional(), - filtros: z_filtro.array().optional(), - descricao_pelo_usuario: z.string().optional(), -}) - -export const visoes = { - z_contagem_em_barra_vertical, - z_contagem_em_pizza, - z_tabela, - z_soma_em_barra_vertical, -} - -/** 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 - /** Rotulo */ - rotulo: string - /** 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 Required>]: { - rotulo: string - tipo_campo: z.infer - order: number - } - } - } -} = { - z_contagem_em_barra_vertical: { - visao: "z_contagem_em_barra_vertical", - rotulo: "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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 2, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 3, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 4, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_soma_em_barra_vertical: { - visao: "z_soma_em_barra_vertical", - rotulo: "Soma 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: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - - colunaSoma: { - rotulo: "Coluna de Somatória", - tipo_campo: "coluna", - order: 2, - }, - - colanuEixoX: { - rotulo: "Coluna do Eixo X", - tipo_campo: "coluna", - order: 3, - }, - colunaAgrupamento: { - rotulo: "Colunas de Agrupamento", - tipo_campo: "lista_colunas", - order: 4, - }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 5, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, - }, - }, - z_contagem_em_pizza: { - visao: "z_contagem_em_pizza", - rotulo: "Contagem em Pizza", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, classes, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim() - - return `Contagem de ${tabela} por ${classes}${ - !filtros?.length - ? "" - : `, quando ${filtros - .map( - ({ coluna, operador, valor }) => - `${coluna} ${operador} ${valor}`, - ) - .join(", ")}` - }.` - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - classes: { rotulo: "Classes", tipo_campo: "coluna", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 4 }, - }, - }, - - z_tabela: { - visao: "z_tabela", - rotulo: "Tabela", - tabela: ({ tabela }) => tabela, - descricao: ({ tabela, descricao_pelo_usuario, filtros }) => { - if (String(descricao_pelo_usuario || "").trim()) - return String(descricao_pelo_usuario || "").trim() - - return `Consulta na ${tabela} ${ - !filtros?.length - ? "" - : `, quando ${filtros - .map( - ({ coluna, operador, valor }) => - `${coluna} ${operador} ${valor}`, - ) - .join(", ")}` - }.` - }, - campos: { - tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, - colunas: { rotulo: "Colunas", tipo_campo: "lista_colunas", order: 2 }, - descricao_pelo_usuario: { - rotulo: "Descrição (opcional)", - tipo_campo: "texto", - order: 3, - }, - coluna_ordem: { - rotulo: "Coluna de Ordem", - tipo_campo: "coluna", - order: 4, - }, - direcao_ordem: { - rotulo: "Direção de Ordem", - tipo_campo: "ordem", - order: 5, - }, - - filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 6 }, - }, - }, -} +export * from "./estrutura_de_campos" diff --git a/src/pilao-de-dados/visoes/listaDeVisoes.ts b/src/pilao-de-dados/visoes/listaDeVisoes.ts new file mode 100644 index 0000000..9b8c857 --- /dev/null +++ b/src/pilao-de-dados/visoes/listaDeVisoes.ts @@ -0,0 +1,42 @@ +import { z } from "zod" +import { z_filtro } from "../_serie_consultar" + +export const z_contagem_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaAgrupamento: z.string().array().optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}) + +export const z_soma_em_barra_vertical = z.object({ + tabela: z.string(), + colanuEixoX: z.string(), + colunaSoma: z.string(), + colunaAgrupamento: z.string().array().optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}) + +export const z_contagem_em_pizza = z.object({ + tabela: z.string(), + classes: z.string(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}) + +export const z_tabela = z.object({ + tabela: z.string(), + colunas: z.string().array(), + coluna_ordem: z.string().optional(), + direcao_ordem: z.enum(["asc", "desc", "1", "-1"]).optional(), + filtros: z_filtro.array().optional(), + descricao_pelo_usuario: z.string().optional(), +}) + +export const visoes_pilao = { + z_contagem_em_barra_vertical, + z_contagem_em_pizza, + z_tabela, + z_soma_em_barra_vertical, +} diff --git a/src/pilao-de-dados/visoes/tipagem.ts b/src/pilao-de-dados/visoes/tipagem.ts new file mode 100644 index 0000000..dbda4f2 --- /dev/null +++ b/src/pilao-de-dados/visoes/tipagem.ts @@ -0,0 +1,31 @@ +import { z } from "zod" +import type { visoes_pilao } from "./listaDeVisoes" + +export const z_tipos_campos_reg_grafico = z.enum([ + "tabela", + "coluna", + "texto", + "lista_colunas", + "lista_filtros", + "ordem", +]) + +export type tipo_estrutura_visao_grafico = + { + /** Nome da Visão */ + visao: T + /** Rotulo */ + rotulo: string + /** Retorna a tabela Referente ao Registro */ + tabela: (_: z.infer<(typeof visoes_pilao)[T]>) => string + /** Descrição */ + descricao: (_: z.infer<(typeof visoes_pilao)[T]>) => string + /** Lista os campos e suas configurações */ + campos: { + [c in keyof Required>]: { + rotulo: string + tipo_campo: z.infer + order: number + } + } + }