From 93d3caa378d649728b798a31e2a24a0ba49cac37 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 1 Oct 2024 13:38:40 -0300 Subject: [PATCH 01/24] =?UTF-8?q?refatora=C3=A7=C3=A3o=20PilaoEnviar?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pilao-de-dados/_enviar_registros.d.ts | 15 +++- .../pilao-de-dados/_enviar_registros.js | 64 ++++++++++------- dist-import/pilao-de-dados/index.d.ts | 12 +++- dist-import/pilao-de-dados/index.js | 4 +- .../pilao-de-dados/_enviar_registros.d.ts | 15 +++- .../pilao-de-dados/_enviar_registros.js | 68 ++++++++++++------- dist-require/pilao-de-dados/index.d.ts | 12 +++- dist-require/pilao-de-dados/index.js | 2 +- package.json | 2 +- src/pilao-de-dados/_enviar_registros.ts | 52 ++++++++++---- src/pilao-de-dados/index.ts | 4 +- 11 files changed, 179 insertions(+), 71 deletions(-) diff --git a/dist-import/pilao-de-dados/_enviar_registros.d.ts b/dist-import/pilao-de-dados/_enviar_registros.d.ts index 88a9f95..b293360 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-import/pilao-de-dados/_enviar_registros.d.ts @@ -51,4 +51,17 @@ export declare const zp_enviar_registros: z.ZodObject<{ tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data" | null | undefined; }>[]; }>; -export declare const enviar_registros: ({ conta, produto, emDesenvolvimento, ver_log, }: z.infer) => ({ registros: registros_entrada, tabela, }: z.infer) => Promise>; +declare class ClassPilaoEnviar { + __conta: string | undefined; + __produto: string | undefined; + __emDesenvolvimento: boolean | undefined; + __ver_log: boolean | undefined; + __tabela: string | undefined; + __registros: z.infer["registros"]; + constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); + tabela(tabela: string): this; + adicionarRegistro(...registro: z.infer["registros"]): this; + enviar(): Promise>; +} +export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; +export {}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index 2e567eb..8ee218c 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -17,27 +17,45 @@ export const zp_enviar_registros = z.object({ tipo: z_tipo_coluna_base_dados.optional().nullable(), }))), }); -export const enviar_registros = ({ conta, produto, emDesenvolvimento, ver_log, }) => async ({ registros: registros_entrada, tabela, }) => { - const registros = [...registros_entrada]; - const url = new URL(`${urlPilao(emDesenvolvimento).api}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`); - if (ver_log) - console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${tabela}" para "${url}".`); - const tamanhoBlocos = 1000; - while (registros.length > 0) { - const bloco = registros - .splice(0, tamanhoBlocos) - .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela, registros: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } +class ClassPilaoEnviar { + constructor({ conta, produto, emDesenvolvimento, ver_log, }) { + this.__registros = []; + this.__conta = conta; + this.__produto = produto; + this.__emDesenvolvimento = emDesenvolvimento; + this.__ver_log = ver_log; } - return respostaComuns.valor(true); -}; + tabela(tabela) { + this.__tabela = tabela; + return this; + } + adicionarRegistro(...registro) { + this.__registros.push(...registro); + return this; + } + async enviar() { + const registros = this.__registros; + const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); + if (this.__ver_log) + console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); + const tamanhoBlocos = 1000; + while (registros.length > 0) { + const bloco = registros + .splice(0, tamanhoBlocos) + .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); + const resp = await node_fetch(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + return respostaComuns.valor(true); + } +} +export const PilaoEnviar = (_) => new ClassPilaoEnviar(_); diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index e4ab599..dfd0f7f 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -307,7 +307,17 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; - enviar_registros: ({ conta, produto, emDesenvolvimento, ver_log, }: import("zod").TypeOf) => ({ registros: registros_entrada, tabela, }: import("zod").TypeOf) => Promise>; + PilaoEnviar: (_: import("zod").TypeOf) => { + __conta: string | undefined; + __produto: string | undefined; + __emDesenvolvimento: boolean | undefined; + __ver_log: boolean | undefined; + __tabela: string | undefined; + __registros: import("zod").TypeOf["registros"]; + tabela(tabela: string): any; + adicionarRegistro(...registro: import("zod").TypeOf["registros"]): any; + enviar(): Promise>; + }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray[]; }>; -export declare const enviar_registros: ({ conta, produto, emDesenvolvimento, ver_log, }: z.infer) => ({ registros: registros_entrada, tabela, }: z.infer) => Promise>; +declare class ClassPilaoEnviar { + __conta: string | undefined; + __produto: string | undefined; + __emDesenvolvimento: boolean | undefined; + __ver_log: boolean | undefined; + __tabela: string | undefined; + __registros: z.infer["registros"]; + constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); + tabela(tabela: string): this; + adicionarRegistro(...registro: z.infer["registros"]): this; + enviar(): Promise>; +} +export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; +export {}; diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index 037344c..c72ad4f 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.enviar_registros = exports.zp_enviar_registros = exports.zp_registrar_base_dados = void 0; +exports.PilaoEnviar = exports.zp_enviar_registros = exports.zp_registrar_base_dados = void 0; const cross_fetch_1 = __importDefault(require("cross-fetch")); const p_respostas_1 = require("p-respostas"); const zod_1 = require("zod"); @@ -23,28 +23,46 @@ exports.zp_enviar_registros = zod_1.z.object({ tipo: variaveis_1.z_tipo_coluna_base_dados.optional().nullable(), }))), }); -const enviar_registros = ({ conta, produto, emDesenvolvimento, ver_log, }) => async ({ registros: registros_entrada, tabela, }) => { - const registros = [...registros_entrada]; - const url = new URL(`${(0, variaveis_1.urlPilao)(emDesenvolvimento).api}/${Object.keys({ enviar_registros: exports.enviar_registros })[0]}/${produto}/${conta}`); - if (ver_log) - console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${tabela}" para "${url}".`); - const tamanhoBlocos = 1000; - while (registros.length > 0) { - const bloco = registros - .splice(0, tamanhoBlocos) - .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); - const resp = await (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela, registros: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } +class ClassPilaoEnviar { + constructor({ conta, produto, emDesenvolvimento, ver_log, }) { + this.__registros = []; + this.__conta = conta; + this.__produto = produto; + this.__emDesenvolvimento = emDesenvolvimento; + this.__ver_log = ver_log; } - return p_respostas_1.respostaComuns.valor(true); -}; -exports.enviar_registros = enviar_registros; + tabela(tabela) { + this.__tabela = tabela; + return this; + } + adicionarRegistro(...registro) { + this.__registros.push(...registro); + return this; + } + async enviar() { + const registros = this.__registros; + const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); + if (this.__ver_log) + console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); + const tamanhoBlocos = 1000; + while (registros.length > 0) { + const bloco = registros + .splice(0, tamanhoBlocos) + .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); + const resp = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + return p_respostas_1.respostaComuns.valor(true); + } +} +const PilaoEnviar = (_) => new ClassPilaoEnviar(_); +exports.PilaoEnviar = PilaoEnviar; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index e4ab599..dfd0f7f 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -307,7 +307,17 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; - enviar_registros: ({ conta, produto, emDesenvolvimento, ver_log, }: import("zod").TypeOf) => ({ registros: registros_entrada, tabela, }: import("zod").TypeOf) => Promise>; + PilaoEnviar: (_: import("zod").TypeOf) => { + __conta: string | undefined; + __produto: string | undefined; + __emDesenvolvimento: boolean | undefined; + __ver_log: boolean | undefined; + __tabela: string | undefined; + __registros: import("zod").TypeOf["registros"]; + tabela(tabela: string): any; + adicionarRegistro(...registro: import("zod").TypeOf["registros"]): any; + enviar(): Promise>; + }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray["registros"] = [] + + constructor({ conta, produto, emDesenvolvimento, ver_log, - }: z.infer) => - async ({ - registros: registros_entrada, - tabela, - }: z.infer): Promise> => { - const registros = [...registros_entrada] + }: z.infer) { + this.__conta = conta + this.__produto = produto + this.__emDesenvolvimento = emDesenvolvimento + this.__ver_log = ver_log + } + + tabela(tabela: string) { + this.__tabela = tabela + return this + } + + adicionarRegistro( + ...registro: z.infer["registros"] + ) { + this.__registros.push(...registro) + return this + } + + async enviar(): Promise> { + const registros = this.__registros const url = new URL( `${ - urlPilao(emDesenvolvimento).api - }/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`, + urlPilao(this.__emDesenvolvimento).api + }/enviar_registros/${this.__produto}/${this.__conta}`, ) - if (ver_log) + if (this.__ver_log) console.log( - `[PILÃO]: Enviando "${registros.length}" registros na tabela "${tabela}" para "${url}".`, + `[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`, ) const tamanhoBlocos = 1000 @@ -69,7 +91,7 @@ export const enviar_registros = const resp = await node_fetch(url.toString(), { method: "POST", - body: JSON.stringify({ tabela, registros: bloco }), + body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), headers: { "Content-Type": "application/json" }, }) .then((r) => r.json()) @@ -85,3 +107,7 @@ export const enviar_registros = return respostaComuns.valor(true) } +} + +export const PilaoEnviar = (_: z.infer) => + new ClassPilaoEnviar(_) diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 96206a1..31a3638 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -1,7 +1,7 @@ import { deletar_registros, zp_deletar_registros } from "./_deletar_registros" export { PREFIXO_PILAO, urlPilao } from "./variaveis" import { - enviar_registros, + PilaoEnviar, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros" @@ -17,7 +17,7 @@ import { extruturas_de_campos, visoes } from "./visoes" export const pPilao = { zp_registrar_base_dados, - enviar_registros, + PilaoEnviar, zp_enviar_registros, serie_consultar, zp_produto_conta, From 2cf1dfe75d4a6af0688f1568e9f24dc49f8c0ef0 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 1 Oct 2024 14:19:18 -0300 Subject: [PATCH 02/24] build --- .../pilao-de-dados/_deletar_registros.d.ts | 14 ----- .../pilao-de-dados/_deletar_registros.js | 29 ---------- .../pilao-de-dados/_enviar_registros.d.ts | 9 ++- .../pilao-de-dados/_enviar_registros.js | 41 ++++++++++++-- dist-import/pilao-de-dados/index.d.ts | 21 ++----- dist-import/pilao-de-dados/index.js | 3 - .../pilao-de-dados/_deletar_registros.d.ts | 14 ----- .../pilao-de-dados/_deletar_registros.js | 36 ------------ .../pilao-de-dados/_enviar_registros.d.ts | 9 ++- .../pilao-de-dados/_enviar_registros.js | 41 ++++++++++++-- dist-require/pilao-de-dados/index.d.ts | 21 ++----- dist-require/pilao-de-dados/index.js | 3 - package.json | 2 +- src/pilao-de-dados/_deletar_registros.ts | 47 ---------------- src/pilao-de-dados/_enviar_registros.ts | 55 +++++++++++++++++-- src/pilao-de-dados/index.ts | 5 +- 16 files changed, 149 insertions(+), 201 deletions(-) delete mode 100644 dist-import/pilao-de-dados/_deletar_registros.d.ts delete mode 100644 dist-import/pilao-de-dados/_deletar_registros.js delete mode 100644 dist-require/pilao-de-dados/_deletar_registros.d.ts delete mode 100644 dist-require/pilao-de-dados/_deletar_registros.js delete mode 100644 src/pilao-de-dados/_deletar_registros.ts diff --git a/dist-import/pilao-de-dados/_deletar_registros.d.ts b/dist-import/pilao-de-dados/_deletar_registros.d.ts deleted file mode 100644 index ef3fa21..0000000 --- a/dist-import/pilao-de-dados/_deletar_registros.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { tipoResposta } from "p-respostas"; -import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; -export declare const zp_deletar_registros: z.ZodObject<{ - tabela: z.ZodString; - codigos: z.ZodArray; -}, "strip", z.ZodTypeAny, { - tabela: string; - codigos: string[]; -}, { - tabela: string; - codigos: string[]; -}>; -export declare const deletar_registros: ({ conta, produto, emDesenvolvimento }: z.infer) => ({ codigos: codigos_entrada, tabela, }: z.infer) => Promise>; diff --git a/dist-import/pilao-de-dados/_deletar_registros.js b/dist-import/pilao-de-dados/_deletar_registros.js deleted file mode 100644 index 7a0ca13..0000000 --- a/dist-import/pilao-de-dados/_deletar_registros.js +++ /dev/null @@ -1,29 +0,0 @@ -import node_fetch from "cross-fetch"; -import { respostaComuns } from "p-respostas"; -import { z } from "zod"; -import { urlPilao } from "./variaveis"; -//enviar registros para base de dados -export const zp_deletar_registros = z.object({ - tabela: z.string(), - codigos: z.array(z.string()), -}); -export const deletar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ codigos: codigos_entrada, tabela, }) => { - const codigos = [...codigos_entrada]; - const url = new URL(`${urlPilao(emDesenvolvimento).api}/${Object.keys({ deletar_registros })[0]}/${produto}/${conta}`); - const tamanhoBlocos = 1000; - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos); - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - return respostaComuns.valor(true); -}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.d.ts b/dist-import/pilao-de-dados/_enviar_registros.d.ts index b293360..d355390 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-import/pilao-de-dados/_enviar_registros.d.ts @@ -57,11 +57,14 @@ declare class ClassPilaoEnviar { __emDesenvolvimento: boolean | undefined; __ver_log: boolean | undefined; __tabela: string | undefined; - __registros: z.infer["registros"]; + __registrosParaEnvio: z.infer["registros"]; + __codigosParaDeletar: string[]; constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); tabela(tabela: string): this; - adicionarRegistro(...registro: z.infer["registros"]): this; - enviar(): Promise>; + adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; + __salvar_enviar_registros(): Promise>; + __salvar_deletar_registros(): Promise>; + salvar(): Promise>; } export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; export {}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index 8ee218c..a3b0db8 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -19,7 +19,8 @@ export const zp_enviar_registros = z.object({ }); class ClassPilaoEnviar { constructor({ conta, produto, emDesenvolvimento, ver_log, }) { - this.__registros = []; + this.__registrosParaEnvio = []; + this.__codigosParaDeletar = []; this.__conta = conta; this.__produto = produto; this.__emDesenvolvimento = emDesenvolvimento; @@ -29,12 +30,12 @@ class ClassPilaoEnviar { this.__tabela = tabela; return this; } - adicionarRegistro(...registro) { - this.__registros.push(...registro); + adicionarRegistroParaEnviar(...registro) { + this.__registrosParaEnvio.push(...registro); return this; } - async enviar() { - const registros = this.__registros; + async __salvar_enviar_registros() { + const registros = this.__registrosParaEnvio; const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); if (this.__ver_log) console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); @@ -57,5 +58,35 @@ class ClassPilaoEnviar { } return respostaComuns.valor(true); } + async __salvar_deletar_registros() { + const codigos = [...this.__codigosParaDeletar]; + const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/deletar_registros/${this.__produto}/${this.__conta}`); + const tamanhoBlocos = 1000; + while (codigos.length > 0) { + const bloco = codigos.splice(0, tamanhoBlocos); + const resp = await node_fetch(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + this.__codigosParaDeletar; + return respostaComuns.valor(true); + } + async salvar() { + const re = await this.__salvar_enviar_registros(); + if (re.eErro) + return re; + const rd = await this.__salvar_deletar_registros(); + if (rd.eErro) + return rd; + return respostaComuns.valor(true); + } } export const PilaoEnviar = (_) => new ClassPilaoEnviar(_); diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index dfd0f7f..c11f8e9 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,4 +1,3 @@ -import { zp_deletar_registros } from "./_deletar_registros"; export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros } from "./_enviar_registros"; import { zp_produto_conta } from "./variaveis"; @@ -313,10 +312,13 @@ export declare const pPilao: { __emDesenvolvimento: boolean | undefined; __ver_log: boolean | undefined; __tabela: string | undefined; - __registros: import("zod").TypeOf["registros"]; + __registrosParaEnvio: import("zod").TypeOf["registros"]; + __codigosParaDeletar: string[]; tabela(tabela: string): any; - adicionarRegistro(...registro: import("zod").TypeOf["registros"]): any; - enviar(): Promise>; + adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; + __salvar_enviar_registros(): Promise>; + __salvar_deletar_registros(): Promise>; + salvar(): Promise>; }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -368,17 +370,6 @@ export declare const pPilao: { ver_log?: boolean | undefined; }>; validarZ: (zodType: import("zod").ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; - deletar_registros: ({ conta, produto, emDesenvolvimento }: import("zod").TypeOf) => ({ codigos: codigos_entrada, tabela, }: import("zod").TypeOf) => Promise>; - zp_deletar_registros: import("zod").ZodObject<{ - tabela: import("zod").ZodString; - codigos: import("zod").ZodArray; - }, "strip", import("zod").ZodTypeAny, { - tabela: string; - codigos: string[]; - }, { - tabela: string; - codigos: string[]; - }>; operadores_pilao: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; operadores_permitidos_por_tipo: { texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index e923830..de0c914 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -1,4 +1,3 @@ -import { deletar_registros, zp_deletar_registros } from "./_deletar_registros"; export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { PilaoEnviar, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_produto_conta, } from "./variaveis"; @@ -11,8 +10,6 @@ export const pPilao = { serie_consultar, zp_produto_conta, validarZ, - deletar_registros, - zp_deletar_registros, operadores_pilao, operadores_permitidos_por_tipo, z_filtro, diff --git a/dist-require/pilao-de-dados/_deletar_registros.d.ts b/dist-require/pilao-de-dados/_deletar_registros.d.ts deleted file mode 100644 index ef3fa21..0000000 --- a/dist-require/pilao-de-dados/_deletar_registros.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { tipoResposta } from "p-respostas"; -import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; -export declare const zp_deletar_registros: z.ZodObject<{ - tabela: z.ZodString; - codigos: z.ZodArray; -}, "strip", z.ZodTypeAny, { - tabela: string; - codigos: string[]; -}, { - tabela: string; - codigos: string[]; -}>; -export declare const deletar_registros: ({ conta, produto, emDesenvolvimento }: z.infer) => ({ codigos: codigos_entrada, tabela, }: z.infer) => Promise>; diff --git a/dist-require/pilao-de-dados/_deletar_registros.js b/dist-require/pilao-de-dados/_deletar_registros.js deleted file mode 100644 index 7dae1b6..0000000 --- a/dist-require/pilao-de-dados/_deletar_registros.js +++ /dev/null @@ -1,36 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.deletar_registros = exports.zp_deletar_registros = void 0; -const cross_fetch_1 = __importDefault(require("cross-fetch")); -const p_respostas_1 = require("p-respostas"); -const zod_1 = require("zod"); -const variaveis_1 = require("./variaveis"); -//enviar registros para base de dados -exports.zp_deletar_registros = zod_1.z.object({ - tabela: zod_1.z.string(), - codigos: zod_1.z.array(zod_1.z.string()), -}); -const deletar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ codigos: codigos_entrada, tabela, }) => { - const codigos = [...codigos_entrada]; - const url = new URL(`${(0, variaveis_1.urlPilao)(emDesenvolvimento).api}/${Object.keys({ deletar_registros: exports.deletar_registros })[0]}/${produto}/${conta}`); - const tamanhoBlocos = 1000; - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos); - const resp = await (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - return p_respostas_1.respostaComuns.valor(true); -}; -exports.deletar_registros = deletar_registros; diff --git a/dist-require/pilao-de-dados/_enviar_registros.d.ts b/dist-require/pilao-de-dados/_enviar_registros.d.ts index b293360..d355390 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-require/pilao-de-dados/_enviar_registros.d.ts @@ -57,11 +57,14 @@ declare class ClassPilaoEnviar { __emDesenvolvimento: boolean | undefined; __ver_log: boolean | undefined; __tabela: string | undefined; - __registros: z.infer["registros"]; + __registrosParaEnvio: z.infer["registros"]; + __codigosParaDeletar: string[]; constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); tabela(tabela: string): this; - adicionarRegistro(...registro: z.infer["registros"]): this; - enviar(): Promise>; + adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; + __salvar_enviar_registros(): Promise>; + __salvar_deletar_registros(): Promise>; + salvar(): Promise>; } export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; export {}; diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index c72ad4f..5ec56ba 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -25,7 +25,8 @@ exports.zp_enviar_registros = zod_1.z.object({ }); class ClassPilaoEnviar { constructor({ conta, produto, emDesenvolvimento, ver_log, }) { - this.__registros = []; + this.__registrosParaEnvio = []; + this.__codigosParaDeletar = []; this.__conta = conta; this.__produto = produto; this.__emDesenvolvimento = emDesenvolvimento; @@ -35,12 +36,12 @@ class ClassPilaoEnviar { this.__tabela = tabela; return this; } - adicionarRegistro(...registro) { - this.__registros.push(...registro); + adicionarRegistroParaEnviar(...registro) { + this.__registrosParaEnvio.push(...registro); return this; } - async enviar() { - const registros = this.__registros; + async __salvar_enviar_registros() { + const registros = this.__registrosParaEnvio; const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); if (this.__ver_log) console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); @@ -63,6 +64,36 @@ class ClassPilaoEnviar { } return p_respostas_1.respostaComuns.valor(true); } + async __salvar_deletar_registros() { + const codigos = [...this.__codigosParaDeletar]; + const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/deletar_registros/${this.__produto}/${this.__conta}`); + const tamanhoBlocos = 1000; + while (codigos.length > 0) { + const bloco = codigos.splice(0, tamanhoBlocos); + const resp = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + this.__codigosParaDeletar; + return p_respostas_1.respostaComuns.valor(true); + } + async salvar() { + const re = await this.__salvar_enviar_registros(); + if (re.eErro) + return re; + const rd = await this.__salvar_deletar_registros(); + if (rd.eErro) + return rd; + return p_respostas_1.respostaComuns.valor(true); + } } const PilaoEnviar = (_) => new ClassPilaoEnviar(_); exports.PilaoEnviar = PilaoEnviar; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index dfd0f7f..c11f8e9 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,4 +1,3 @@ -import { zp_deletar_registros } from "./_deletar_registros"; export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros } from "./_enviar_registros"; import { zp_produto_conta } from "./variaveis"; @@ -313,10 +312,13 @@ export declare const pPilao: { __emDesenvolvimento: boolean | undefined; __ver_log: boolean | undefined; __tabela: string | undefined; - __registros: import("zod").TypeOf["registros"]; + __registrosParaEnvio: import("zod").TypeOf["registros"]; + __codigosParaDeletar: string[]; tabela(tabela: string): any; - adicionarRegistro(...registro: import("zod").TypeOf["registros"]): any; - enviar(): Promise>; + adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; + __salvar_enviar_registros(): Promise>; + __salvar_deletar_registros(): Promise>; + salvar(): Promise>; }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -368,17 +370,6 @@ export declare const pPilao: { ver_log?: boolean | undefined; }>; validarZ: (zodType: import("zod").ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; - deletar_registros: ({ conta, produto, emDesenvolvimento }: import("zod").TypeOf) => ({ codigos: codigos_entrada, tabela, }: import("zod").TypeOf) => Promise>; - zp_deletar_registros: import("zod").ZodObject<{ - tabela: import("zod").ZodString; - codigos: import("zod").ZodArray; - }, "strip", import("zod").ZodTypeAny, { - tabela: string; - codigos: string[]; - }, { - tabela: string; - codigos: string[]; - }>; operadores_pilao: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; operadores_permitidos_por_tipo: { texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 33cf3f8..8c7d4e5 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -1,7 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pPilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; -const _deletar_registros_1 = require("./_deletar_registros"); var variaveis_1 = require("./variaveis"); Object.defineProperty(exports, "PREFIXO_PILAO", { enumerable: true, get: function () { return variaveis_1.PREFIXO_PILAO; } }); Object.defineProperty(exports, "urlPilao", { enumerable: true, get: function () { return variaveis_1.urlPilao; } }); @@ -16,8 +15,6 @@ exports.pPilao = { serie_consultar: _serie_consultar_1.serie_consultar, zp_produto_conta: variaveis_2.zp_produto_conta, validarZ: variaveis_2.validarZ, - deletar_registros: _deletar_registros_1.deletar_registros, - zp_deletar_registros: _deletar_registros_1.zp_deletar_registros, operadores_pilao: variaveis_2.operadores_pilao, operadores_permitidos_por_tipo: variaveis_2.operadores_permitidos_por_tipo, z_filtro: _serie_consultar_1.z_filtro, diff --git a/package.json b/package.json index 94349d0..6b6a100 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.151.0", + "version": "0.152.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/_deletar_registros.ts b/src/pilao-de-dados/_deletar_registros.ts deleted file mode 100644 index 2502b0a..0000000 --- a/src/pilao-de-dados/_deletar_registros.ts +++ /dev/null @@ -1,47 +0,0 @@ -import node_fetch from "cross-fetch" -import type { tipoResposta } from "p-respostas" -import { respostaComuns } from "p-respostas" -import { z } from "zod" -import { urlPilao, type zp_produto_conta } from "./variaveis" -//enviar registros para base de dados -export const zp_deletar_registros = z.object({ - tabela: z.string(), - codigos: z.array(z.string()), -}) - -export const deletar_registros = - ({ conta, produto, emDesenvolvimento }: z.infer) => - async ({ - codigos: codigos_entrada, - tabela, - }: z.infer): Promise> => { - const codigos = [...codigos_entrada] - - const url = new URL( - `${ - urlPilao(emDesenvolvimento).api - }/${Object.keys({ deletar_registros })[0]}/${produto}/${conta}`, - ) - - const tamanhoBlocos = 1000 - - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos) - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => - respostaComuns.erro("Erro ao enviar registros", [e.message]), - ) - .then((r) => r as tipoResposta) - - if (resp.eErro) { - return resp - } - } - - return respostaComuns.valor(true) - } diff --git a/src/pilao-de-dados/_enviar_registros.ts b/src/pilao-de-dados/_enviar_registros.ts index cebdf7d..35ea744 100644 --- a/src/pilao-de-dados/_enviar_registros.ts +++ b/src/pilao-de-dados/_enviar_registros.ts @@ -38,7 +38,8 @@ class ClassPilaoEnviar { __emDesenvolvimento: boolean | undefined __ver_log: boolean | undefined __tabela: string | undefined - __registros: z.infer["registros"] = [] + __registrosParaEnvio: z.infer["registros"] = [] + __codigosParaDeletar: string[] = [] constructor({ conta, @@ -57,15 +58,15 @@ class ClassPilaoEnviar { return this } - adicionarRegistro( + adicionarRegistroParaEnviar( ...registro: z.infer["registros"] ) { - this.__registros.push(...registro) + this.__registrosParaEnvio.push(...registro) return this } - async enviar(): Promise> { - const registros = this.__registros + async __salvar_enviar_registros(): Promise> { + const registros = this.__registrosParaEnvio const url = new URL( `${ @@ -107,6 +108,50 @@ class ClassPilaoEnviar { return respostaComuns.valor(true) } + + async __salvar_deletar_registros() { + const codigos = [...this.__codigosParaDeletar] + + const url = new URL( + `${ + urlPilao(this.__emDesenvolvimento).api + }/deletar_registros/${this.__produto}/${this.__conta}`, + ) + + const tamanhoBlocos = 1000 + + while (codigos.length > 0) { + const bloco = codigos.splice(0, tamanhoBlocos) + const resp = await node_fetch(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => + respostaComuns.erro("Erro ao enviar registros", [e.message]), + ) + .then((r) => r as tipoResposta) + + if (resp.eErro) { + return resp + } + } + + this.__codigosParaDeletar + + return respostaComuns.valor(true) + } + + async salvar() { + const re = await this.__salvar_enviar_registros() + if (re.eErro) return re + + const rd = await this.__salvar_deletar_registros() + if (rd.eErro) return rd + + return respostaComuns.valor(true) + } } export const PilaoEnviar = (_: z.infer) => diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 31a3638..507f159 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -1,4 +1,3 @@ -import { deletar_registros, zp_deletar_registros } from "./_deletar_registros" export { PREFIXO_PILAO, urlPilao } from "./variaveis" import { PilaoEnviar, @@ -18,12 +17,12 @@ import { extruturas_de_campos, visoes } from "./visoes" export const pPilao = { zp_registrar_base_dados, PilaoEnviar, + zp_enviar_registros, serie_consultar, zp_produto_conta, validarZ, - deletar_registros, - zp_deletar_registros, + operadores_pilao, operadores_permitidos_por_tipo, z_filtro, From aac9eb143b6c8a70e2d7489655ff3d7b81f8fb52 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 1 Oct 2024 14:22:59 -0300 Subject: [PATCH 03/24] build --- dist-import/pilao-de-dados/_enviar_registros.d.ts | 1 + dist-import/pilao-de-dados/_enviar_registros.js | 4 ++++ dist-import/pilao-de-dados/index.d.ts | 1 + dist-require/pilao-de-dados/_enviar_registros.d.ts | 1 + dist-require/pilao-de-dados/_enviar_registros.js | 4 ++++ dist-require/pilao-de-dados/index.d.ts | 1 + package.json | 2 +- src/pilao-de-dados/_enviar_registros.ts | 5 +++++ 8 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dist-import/pilao-de-dados/_enviar_registros.d.ts b/dist-import/pilao-de-dados/_enviar_registros.d.ts index d355390..9a630e4 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-import/pilao-de-dados/_enviar_registros.d.ts @@ -62,6 +62,7 @@ declare class ClassPilaoEnviar { constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); tabela(tabela: string): this; adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; + adicionarCodigoParaDeletar(...codigos: string[]): this; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index a3b0db8..64c337a 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -34,6 +34,10 @@ class ClassPilaoEnviar { this.__registrosParaEnvio.push(...registro); return this; } + adicionarCodigoParaDeletar(...codigos) { + this.__codigosParaDeletar.push(...codigos); + return this; + } async __salvar_enviar_registros() { const registros = this.__registrosParaEnvio; const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index c11f8e9..347936e 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -316,6 +316,7 @@ export declare const pPilao: { __codigosParaDeletar: string[]; tabela(tabela: string): any; adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; + adicionarCodigoParaDeletar(...codigos: string[]): any; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-require/pilao-de-dados/_enviar_registros.d.ts b/dist-require/pilao-de-dados/_enviar_registros.d.ts index d355390..9a630e4 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-require/pilao-de-dados/_enviar_registros.d.ts @@ -62,6 +62,7 @@ declare class ClassPilaoEnviar { constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); tabela(tabela: string): this; adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; + adicionarCodigoParaDeletar(...codigos: string[]): this; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index 5ec56ba..723c4c0 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -40,6 +40,10 @@ class ClassPilaoEnviar { this.__registrosParaEnvio.push(...registro); return this; } + adicionarCodigoParaDeletar(...codigos) { + this.__codigosParaDeletar.push(...codigos); + return this; + } async __salvar_enviar_registros() { const registros = this.__registrosParaEnvio; const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index c11f8e9..347936e 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -316,6 +316,7 @@ export declare const pPilao: { __codigosParaDeletar: string[]; tabela(tabela: string): any; adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; + adicionarCodigoParaDeletar(...codigos: string[]): any; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/package.json b/package.json index 6b6a100..c5ec231 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.152.0", + "version": "0.153.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/_enviar_registros.ts b/src/pilao-de-dados/_enviar_registros.ts index 35ea744..88693b3 100644 --- a/src/pilao-de-dados/_enviar_registros.ts +++ b/src/pilao-de-dados/_enviar_registros.ts @@ -65,6 +65,11 @@ class ClassPilaoEnviar { return this } + adicionarCodigoParaDeletar(...codigos: string[]) { + this.__codigosParaDeletar.push(...codigos) + return this + } + async __salvar_enviar_registros(): Promise> { const registros = this.__registrosParaEnvio From 102fa0c78bfb73bf8b61eff475d96ca1f3d2f487 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 1 Oct 2024 16:01:44 -0300 Subject: [PATCH 04/24] build --- dist-import/pilao-de-dados/_enviar_registros.d.ts | 4 ++-- dist-import/pilao-de-dados/index.d.ts | 14 ++++++++++++-- dist-import/pilao-de-dados/index.js | 3 ++- dist-import/pilao-de-dados/variaveis.d.ts | 10 ++++++++++ dist-import/pilao-de-dados/variaveis.js | 4 ++++ dist-require/pilao-de-dados/_enviar_registros.d.ts | 4 ++-- dist-require/pilao-de-dados/index.d.ts | 14 ++++++++++++-- dist-require/pilao-de-dados/index.js | 1 + dist-require/pilao-de-dados/variaveis.d.ts | 10 ++++++++++ dist-require/pilao-de-dados/variaveis.js | 6 +++++- package.json | 2 +- src/pilao-de-dados/_enviar_registros.ts | 5 ++++- src/pilao-de-dados/index.ts | 2 ++ src/pilao-de-dados/variaveis.ts | 5 +++++ 14 files changed, 72 insertions(+), 12 deletions(-) diff --git a/dist-import/pilao-de-dados/_enviar_registros.d.ts b/dist-import/pilao-de-dados/_enviar_registros.d.ts index 9a630e4..9ae8965 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-import/pilao-de-dados/_enviar_registros.d.ts @@ -1,6 +1,6 @@ import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; +import { type zp_deletar_registros, type zp_produto_conta } from "./variaveis"; export declare const zp_registrar_base_dados: z.ZodObject<{ tabela: z.ZodString; colunas: z.ZodArray); tabela(tabela: string): this; adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; - adicionarCodigoParaDeletar(...codigos: string[]): this; + adicionarCodigoParaDeletar(...codigos: z.infer["codigos"]): this; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 347936e..1651109 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,6 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros } from "./_enviar_registros"; -import { zp_produto_conta } from "./variaveis"; +import { zp_deletar_registros, zp_produto_conta } from "./variaveis"; import { visoes } from "./visoes"; export declare const pPilao: { extruturas_de_campos: { @@ -281,6 +281,16 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + zp_deletar_registros: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + codigos: import("zod").ZodArray; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + codigos: string[]; + }, { + tabela: string; + codigos: string[]; + }>; zp_registrar_base_dados: import("zod").ZodObject<{ tabela: import("zod").ZodString; colunas: import("zod").ZodArray["registros"]): any; - adicionarCodigoParaDeletar(...codigos: string[]): any; + adicionarCodigoParaDeletar(...codigos: import("zod").TypeOf["codigos"]): any; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index de0c914..740c8a8 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -1,9 +1,10 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { PilaoEnviar, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; -import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_produto_conta, } from "./variaveis"; +import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_deletar_registros, zp_produto_conta, } from "./variaveis"; import { serie_consultar, z_filtro } from "./_serie_consultar"; import { extruturas_de_campos, visoes } from "./visoes"; export const pPilao = { + zp_deletar_registros, zp_registrar_base_dados, PilaoEnviar, zp_enviar_registros, diff --git a/dist-import/pilao-de-dados/variaveis.d.ts b/dist-import/pilao-de-dados/variaveis.d.ts index 3183c96..fe513ff 100644 --- a/dist-import/pilao-de-dados/variaveis.d.ts +++ b/dist-import/pilao-de-dados/variaveis.d.ts @@ -1,4 +1,14 @@ import { z } from "zod"; +export declare const zp_deletar_registros: z.ZodObject<{ + tabela: z.ZodString; + codigos: z.ZodArray; +}, "strip", z.ZodTypeAny, { + tabela: string; + codigos: string[]; +}, { + tabela: string; + codigos: string[]; +}>; export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>; export declare const PREFIXO_PILAO = "/pilao-de-dados"; export declare const validarZ: (zodType: z.ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; diff --git a/dist-import/pilao-de-dados/variaveis.js b/dist-import/pilao-de-dados/variaveis.js index 044b39f..d5638d0 100644 --- a/dist-import/pilao-de-dados/variaveis.js +++ b/dist-import/pilao-de-dados/variaveis.js @@ -1,5 +1,9 @@ import { respostaComuns } from "p-respostas"; import { z } from "zod"; +export const zp_deletar_registros = z.object({ + tabela: z.string(), + codigos: z.array(z.string()), +}); export const zAmbiente = z.enum(["desenvolvimento", "producao"]); export const PREFIXO_PILAO = "/pilao-de-dados"; export const validarZ = (zodType, objeto, mensagem) => { diff --git a/dist-require/pilao-de-dados/_enviar_registros.d.ts b/dist-require/pilao-de-dados/_enviar_registros.d.ts index 9a630e4..9ae8965 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-require/pilao-de-dados/_enviar_registros.d.ts @@ -1,6 +1,6 @@ import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; +import { type zp_deletar_registros, type zp_produto_conta } from "./variaveis"; export declare const zp_registrar_base_dados: z.ZodObject<{ tabela: z.ZodString; colunas: z.ZodArray); tabela(tabela: string): this; adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; - adicionarCodigoParaDeletar(...codigos: string[]): this; + adicionarCodigoParaDeletar(...codigos: z.infer["codigos"]): this; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 347936e..1651109 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,6 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros } from "./_enviar_registros"; -import { zp_produto_conta } from "./variaveis"; +import { zp_deletar_registros, zp_produto_conta } from "./variaveis"; import { visoes } from "./visoes"; export declare const pPilao: { extruturas_de_campos: { @@ -281,6 +281,16 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + zp_deletar_registros: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + codigos: import("zod").ZodArray; + }, "strip", import("zod").ZodTypeAny, { + tabela: string; + codigos: string[]; + }, { + tabela: string; + codigos: string[]; + }>; zp_registrar_base_dados: import("zod").ZodObject<{ tabela: import("zod").ZodString; colunas: import("zod").ZodArray["registros"]): any; - adicionarCodigoParaDeletar(...codigos: string[]): any; + adicionarCodigoParaDeletar(...codigos: import("zod").TypeOf["codigos"]): any; __salvar_enviar_registros(): Promise>; __salvar_deletar_registros(): Promise>; salvar(): Promise>; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 8c7d4e5..4933627 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -9,6 +9,7 @@ const variaveis_2 = require("./variaveis"); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); exports.pPilao = { + zp_deletar_registros: variaveis_2.zp_deletar_registros, zp_registrar_base_dados: _enviar_registros_1.zp_registrar_base_dados, PilaoEnviar: _enviar_registros_1.PilaoEnviar, zp_enviar_registros: _enviar_registros_1.zp_enviar_registros, diff --git a/dist-require/pilao-de-dados/variaveis.d.ts b/dist-require/pilao-de-dados/variaveis.d.ts index 3183c96..fe513ff 100644 --- a/dist-require/pilao-de-dados/variaveis.d.ts +++ b/dist-require/pilao-de-dados/variaveis.d.ts @@ -1,4 +1,14 @@ import { z } from "zod"; +export declare const zp_deletar_registros: z.ZodObject<{ + tabela: z.ZodString; + codigos: z.ZodArray; +}, "strip", z.ZodTypeAny, { + tabela: string; + codigos: string[]; +}, { + tabela: string; + codigos: string[]; +}>; export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>; export declare const PREFIXO_PILAO = "/pilao-de-dados"; export declare const validarZ: (zodType: z.ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; diff --git a/dist-require/pilao-de-dados/variaveis.js b/dist-require/pilao-de-dados/variaveis.js index 92b2de0..5cc4676 100644 --- a/dist-require/pilao-de-dados/variaveis.js +++ b/dist-require/pilao-de-dados/variaveis.js @@ -1,8 +1,12 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.urlPilao = exports.z_validar_colunna_base_dados = exports.operadores_permitidos_por_tipo = exports.operadores_pilao = exports.z_tipo_coluna_base_dados = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = void 0; +exports.urlPilao = exports.z_validar_colunna_base_dados = exports.operadores_permitidos_por_tipo = exports.operadores_pilao = exports.z_tipo_coluna_base_dados = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = exports.zp_deletar_registros = void 0; const p_respostas_1 = require("p-respostas"); const zod_1 = require("zod"); +exports.zp_deletar_registros = zod_1.z.object({ + tabela: zod_1.z.string(), + codigos: zod_1.z.array(zod_1.z.string()), +}); exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]); exports.PREFIXO_PILAO = "/pilao-de-dados"; const validarZ = (zodType, objeto, mensagem) => { diff --git a/package.json b/package.json index c5ec231..2988f3d 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.153.0", + "version": "0.154.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/_enviar_registros.ts b/src/pilao-de-dados/_enviar_registros.ts index 88693b3..8fc8859 100644 --- a/src/pilao-de-dados/_enviar_registros.ts +++ b/src/pilao-de-dados/_enviar_registros.ts @@ -5,6 +5,7 @@ import { z } from "zod" import { urlPilao, z_tipo_coluna_base_dados, + type zp_deletar_registros, type zp_produto_conta, } from "./variaveis" @@ -65,7 +66,9 @@ class ClassPilaoEnviar { return this } - adicionarCodigoParaDeletar(...codigos: string[]) { + adicionarCodigoParaDeletar( + ...codigos: z.infer["codigos"] + ) { this.__codigosParaDeletar.push(...codigos) return this } diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 507f159..4867623 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -8,6 +8,7 @@ import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, + zp_deletar_registros, zp_produto_conta, } from "./variaveis" @@ -15,6 +16,7 @@ import { serie_consultar, z_filtro } from "./_serie_consultar" import { extruturas_de_campos, visoes } from "./visoes" export const pPilao = { + zp_deletar_registros, zp_registrar_base_dados, PilaoEnviar, diff --git a/src/pilao-de-dados/variaveis.ts b/src/pilao-de-dados/variaveis.ts index 6fc3e73..83d6ab4 100644 --- a/src/pilao-de-dados/variaveis.ts +++ b/src/pilao-de-dados/variaveis.ts @@ -1,6 +1,11 @@ import { respostaComuns } from "p-respostas" import { z } from "zod" +export const zp_deletar_registros = z.object({ + tabela: z.string(), + codigos: z.array(z.string()), +}) + export const zAmbiente = z.enum(["desenvolvimento", "producao"]) export const PREFIXO_PILAO = "/pilao-de-dados" From 1ee3565d3d0bd96a10266ab4d0f8e3fbe8a96122 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Tue, 1 Oct 2024 16:06:44 -0300 Subject: [PATCH 05/24] build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2988f3d..91affd9 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.154.0", + "version": "0.155.0", "description": "", "main": "src/index.ts", "exports": { From f6c203ee3ee590f2f751035924ee0a6c59f7525b Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:15:02 -0300 Subject: [PATCH 06/24] =?UTF-8?q?refatora=C3=A7=C3=A3o=20do=20drive=20de?= =?UTF-8?q?=20pil=C3=A3o=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist-import/pilao-de-dados/Pilao/index.d.ts | 60 ++++ dist-import/pilao-de-dados/Pilao/index.js | 182 ++++++++++++ .../pilao-de-dados/Pilao/pilao-api.ts.d.ts | 30 ++ .../pilao-de-dados/Pilao/pilao-api.ts.js | 1 + dist-import/pilao-de-dados/Pilao/tipagem.d.ts | 4 + dist-import/pilao-de-dados/Pilao/tipagem.js | 1 + .../pilao-de-dados/_enviar_registros.d.ts | 20 -- .../pilao-de-dados/_enviar_registros.js | 81 +----- .../pilao-de-dados/_serie_consultar.d.ts | 11 - .../pilao-de-dados/_serie_consultar.js | 31 +-- dist-import/pilao-de-dados/index.d.ts | 27 +- dist-import/pilao-de-dados/index.js | 7 +- dist-require/pilao-de-dados/Pilao/index.d.ts | 60 ++++ dist-require/pilao-de-dados/Pilao/index.js | 189 +++++++++++++ .../pilao-de-dados/Pilao/pilao-api.ts.d.ts | 30 ++ .../pilao-de-dados/Pilao/pilao-api.ts.js | 2 + .../pilao-de-dados/Pilao/tipagem.d.ts | 4 + dist-require/pilao-de-dados/Pilao/tipagem.js | 2 + .../pilao-de-dados/_enviar_registros.d.ts | 20 -- .../pilao-de-dados/_enviar_registros.js | 85 +----- .../pilao-de-dados/_serie_consultar.d.ts | 11 - .../pilao-de-dados/_serie_consultar.js | 35 +-- dist-require/pilao-de-dados/index.d.ts | 27 +- dist-require/pilao-de-dados/index.js | 17 +- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 258 ++++++++++++++++++ src/pilao-de-dados/Pilao/pilao-api.ts.ts | 32 +++ src/pilao-de-dados/Pilao/tipagem.ts | 1 + src/pilao-de-dados/_enviar_registros.ts | 142 +--------- src/pilao-de-dados/_serie_consultar.ts | 61 +---- src/pilao-de-dados/index.ts | 8 +- 31 files changed, 887 insertions(+), 554 deletions(-) create mode 100644 dist-import/pilao-de-dados/Pilao/index.d.ts create mode 100644 dist-import/pilao-de-dados/Pilao/index.js create mode 100644 dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts create mode 100644 dist-import/pilao-de-dados/Pilao/pilao-api.ts.js create mode 100644 dist-import/pilao-de-dados/Pilao/tipagem.d.ts create mode 100644 dist-import/pilao-de-dados/Pilao/tipagem.js create mode 100644 dist-require/pilao-de-dados/Pilao/index.d.ts create mode 100644 dist-require/pilao-de-dados/Pilao/index.js create mode 100644 dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts create mode 100644 dist-require/pilao-de-dados/Pilao/pilao-api.ts.js create mode 100644 dist-require/pilao-de-dados/Pilao/tipagem.d.ts create mode 100644 dist-require/pilao-de-dados/Pilao/tipagem.js create mode 100644 src/pilao-de-dados/Pilao/index.ts create mode 100755 src/pilao-de-dados/Pilao/pilao-api.ts.ts create mode 100644 src/pilao-de-dados/Pilao/tipagem.ts diff --git a/dist-import/pilao-de-dados/Pilao/index.d.ts b/dist-import/pilao-de-dados/Pilao/index.d.ts new file mode 100644 index 0000000..f842667 --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/index.d.ts @@ -0,0 +1,60 @@ +/** Drive completo do piilão de dados */ +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 { tipo_pilao_api } from "./pilao-api.ts"; +import type { tipoConstrutorPilao } from "./tipagem"; +declare class ClassPilao { + #private; + constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { + ver_log?: boolean; + emDesenvolvimento?: boolean; + }); + rotaEnviarRegistros(): { + rota: string; + url: string; + }; + rotaDeletarRegistro(): { + rota: string; + url: string; + }; + rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rota: string; + url: string; + }; + rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rota: string; + url: string; + }; + rotaFuncaoApi(funcao: keyof tipo_pilao_api | ":funcao"): { + rota: string; + url: string; + }; + consultarApi(funcao: T, parametros: tipo_pilao_api[T]["pr"]): Promise>; + get baseUrlApi(): "https://carro-de-boi.idz.one" | "http://localhost:5080"; + get baseUrlSite(): "https://carro-de-boi.idz.one" | "http://localhost:5081"; + validarCliente(_: any): tipoResposta; + adicionarRegistroParaEnviar(tabela: string, ...registros: z.infer["registros"]): this; + adicionarCodigoParaDeletar(tabela: string, ...codigos: z.infer["codigos"]): this; + private processarRegistros; + salvarRegistros(): Promise>; + serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { + dados: () => Promise; + }>>; + url: () => string; + }; + urlLaboratorio(): { + rota: string; + url: string; + }; +} +export declare const Pilao: (_: tipoConstrutorPilao & { + ver_log?: boolean; + emDesenvolvimento?: boolean; +}) => ClassPilao; +export {}; diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js new file mode 100644 index 0000000..090107b --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -0,0 +1,182 @@ +/** Drive completo do piilão de dados */ +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var _ClassPilao_instances, _ClassPilao_produto, _ClassPilao_conta, _ClassPilao_emDesenvolvimento, _ClassPilao_ver_log, _ClassPilao_registrosParaEnvio, _ClassPilao_codigosParaDeletar, _ClassPilao_gerarUrl, _ClassPilao_salvarEnviarRegistros, _ClassPilao_salvarDeletarRegistros; +import crossFetch from "cross-fetch"; +import { nomeVariavel } from "p-comuns"; +import { respostaComuns } from "p-respostas"; +import { PREFIXO_PILAO } from "../variaveis"; +class ClassPilao { + constructor({ conta, produto, emDesenvolvimento = false, ver_log = false, }) { + _ClassPilao_instances.add(this); + _ClassPilao_produto.set(this, void 0); + _ClassPilao_conta.set(this, void 0); + _ClassPilao_emDesenvolvimento.set(this, void 0); + _ClassPilao_ver_log.set(this, void 0); + _ClassPilao_registrosParaEnvio.set(this, {}); + _ClassPilao_codigosParaDeletar.set(this, {}); + __classPrivateFieldSet(this, _ClassPilao_produto, produto, "f"); + __classPrivateFieldSet(this, _ClassPilao_conta, conta, "f"); + __classPrivateFieldSet(this, _ClassPilao_emDesenvolvimento, emDesenvolvimento, "f"); + __classPrivateFieldSet(this, _ClassPilao_ver_log, ver_log, "f"); + } + rotaEnviarRegistros() { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "enviar-registros"); + } + rotaDeletarRegistro() { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "deletar-registros"); + } + rotaConsultarSerie(tipoVisao) { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); + } + rotaIframeSerie(tipoVisao) { + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/consultar-serie/${tipoVisao}`; + const url = `${this.baseUrlSite}${rota}`; + return { rota, url }; + } + rotaFuncaoApi(funcao) { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "API", funcao); + } + async consultarApi(funcao, parametros) { + try { + const response = await crossFetch(this.rotaFuncaoApi(funcao).url, { + body: JSON.stringify(parametros), + method: "POST", + headers: { "Content-Type": "application/json" }, + }); + return await response.json(); + } + catch (erro) { + console.error(erro); + return respostaComuns.erroInterno({ + erro, + local: nomeVariavel({ ClassPilao }), + }); + } + } + get baseUrlApi() { + return __classPrivateFieldGet(this, _ClassPilao_emDesenvolvimento, "f") + ? "http://localhost:5080" + : "https://carro-de-boi.idz.one"; + } + get baseUrlSite() { + return __classPrivateFieldGet(this, _ClassPilao_emDesenvolvimento, "f") + ? "http://localhost:5081" + : "https://carro-de-boi.idz.one"; + } + validarCliente(_) { + if (!_?.conta) + return respostaComuns.erro("Conta não informada"); + if (!_?.produto) + return respostaComuns.erro("Produto não informado"); + return respostaComuns.valor(_); + } + adicionarRegistroParaEnviar(tabela, ...registros) { + __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] = [ + ...(__classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] || []), + ...registros, + ]; + return this; + } + adicionarCodigoParaDeletar(tabela, ...codigos) { + __classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] = [ + ...(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] || []), + ...codigos, + ]; + return this; + } + async processarRegistros(url, registros, tabela, acao) { + const tamanhoBlocos = 1000; + while (registros.length > 0) { + const bloco = registros + .splice(0, tamanhoBlocos) + .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); + const resp = await crossFetch(url, { + method: "POST", + body: JSON.stringify({ tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => respostaComuns.erro(`Erro ao ${acao} registros`, [e.message])); + if (resp.eErro) + return resp; + } + return respostaComuns.valor(true); + } + async salvarRegistros() { + const re = await __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_salvarEnviarRegistros).call(this); + if (re.eErro) + return re; + const rd = await __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_salvarDeletarRegistros).call(this); + if (rd.eErro) + return rd; + return respostaComuns.valor(true); + } + serieConsultar(tipoVisao, parametros) { + const dados = async () => { + const url = this.rotaConsultarSerie(tipoVisao).url; + const resp = await crossFetch(url.toString(), { + method: "POST", + body: JSON.stringify(parametros), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])); + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`); + return resp; + }; + const url = () => { + const vUrl = this.rotaIframeSerie(tipoVisao).url; + const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl}".`); + return `${vUrl}?serie=${serie}`; + }; + return { + dados, + url, + }; + } + urlLaboratorio() { + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/laboratório`; + const url = `${this.baseUrlSite}${rota}`; + return { rota, url }; + } +} +_ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const url = `${this.baseUrlApi}${rota}`; + return { rota, url }; +}, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { + for (const tabela of Object.keys(__classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f"))) { + const registros = __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] || []; + const url = this.rotaEnviarRegistros().url; + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: Enviando ${registros.length} registros na tabela "${tabela}" para "${url}".`); + const resp = await this.processarRegistros(url, registros, tabela, "enviar"); + if (resp.eErro) + return resp; + __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] = []; + } + return respostaComuns.valor(true); +}, _ClassPilao_salvarDeletarRegistros = async function _ClassPilao_salvarDeletarRegistros() { + for (const tabela of Object.keys(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f"))) { + const codigos = [...(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] || [])]; + const url = this.rotaDeletarRegistro().url; + const resp = await this.processarRegistros(url, codigos, tabela, "deletar"); + if (resp.eErro) + return resp; + } + return respostaComuns.valor(true); +}; +export const Pilao = (_) => new ClassPilao(_); diff --git a/dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts b/dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts new file mode 100644 index 0000000..e2c4c75 --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts @@ -0,0 +1,30 @@ +import type { z } from "zod"; +import type { zp_registrar_base_dados } from "../_enviar_registros"; +/** + * { + * 'rota':{ + * pr:{}// paramentros de entrada + * rs:{}// resposta + * } + * } + */ +export type tipo_pilao_api = { + /** retorna da data e hora do servido em formato iso */ + estado_servidor: { + pr: {}; + rs: { + data_hora: string; + }; + }; + tabelas: { + pr: {}; + rs: z.infer[]; + }; + unicos: { + pr: { + tabela: string; + coluna: string; + }; + rs: any[]; + }; +}; diff --git a/dist-import/pilao-de-dados/Pilao/pilao-api.ts.js b/dist-import/pilao-de-dados/Pilao/pilao-api.ts.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/pilao-api.ts.js @@ -0,0 +1 @@ +export {}; diff --git a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts new file mode 100644 index 0000000..eb0ea76 --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts @@ -0,0 +1,4 @@ +export type tipoConstrutorPilao = { + produto: string; + conta: string; +}; diff --git a/dist-import/pilao-de-dados/Pilao/tipagem.js b/dist-import/pilao-de-dados/Pilao/tipagem.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/dist-import/pilao-de-dados/Pilao/tipagem.js @@ -0,0 +1 @@ +export {}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.d.ts b/dist-import/pilao-de-dados/_enviar_registros.d.ts index 9ae8965..e96f97f 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-import/pilao-de-dados/_enviar_registros.d.ts @@ -1,6 +1,4 @@ -import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_deletar_registros, type zp_produto_conta } from "./variaveis"; export declare const zp_registrar_base_dados: z.ZodObject<{ tabela: z.ZodString; colunas: z.ZodArray[]; }>; -declare class ClassPilaoEnviar { - __conta: string | undefined; - __produto: string | undefined; - __emDesenvolvimento: boolean | undefined; - __ver_log: boolean | undefined; - __tabela: string | undefined; - __registrosParaEnvio: z.infer["registros"]; - __codigosParaDeletar: string[]; - constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); - tabela(tabela: string): this; - adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; - adicionarCodigoParaDeletar(...codigos: z.infer["codigos"]): this; - __salvar_enviar_registros(): Promise>; - __salvar_deletar_registros(): Promise>; - salvar(): Promise>; -} -export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; -export {}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index 64c337a..3626b74 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -1,7 +1,5 @@ -import node_fetch from "cross-fetch"; -import { respostaComuns } from "p-respostas"; import { z } from "zod"; -import { urlPilao, z_tipo_coluna_base_dados, } from "./variaveis"; +import { z_tipo_coluna_base_dados } from "./variaveis"; export const zp_registrar_base_dados = z.object({ tabela: z.string(), colunas: z.array(z.object({ @@ -17,80 +15,3 @@ export const zp_enviar_registros = z.object({ tipo: z_tipo_coluna_base_dados.optional().nullable(), }))), }); -class ClassPilaoEnviar { - constructor({ conta, produto, emDesenvolvimento, ver_log, }) { - this.__registrosParaEnvio = []; - this.__codigosParaDeletar = []; - this.__conta = conta; - this.__produto = produto; - this.__emDesenvolvimento = emDesenvolvimento; - this.__ver_log = ver_log; - } - tabela(tabela) { - this.__tabela = tabela; - return this; - } - adicionarRegistroParaEnviar(...registro) { - this.__registrosParaEnvio.push(...registro); - return this; - } - adicionarCodigoParaDeletar(...codigos) { - this.__codigosParaDeletar.push(...codigos); - return this; - } - async __salvar_enviar_registros() { - const registros = this.__registrosParaEnvio; - const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); - if (this.__ver_log) - console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); - const tamanhoBlocos = 1000; - while (registros.length > 0) { - const bloco = registros - .splice(0, tamanhoBlocos) - .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - return respostaComuns.valor(true); - } - async __salvar_deletar_registros() { - const codigos = [...this.__codigosParaDeletar]; - const url = new URL(`${urlPilao(this.__emDesenvolvimento).api}/deletar_registros/${this.__produto}/${this.__conta}`); - const tamanhoBlocos = 1000; - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos); - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - this.__codigosParaDeletar; - return respostaComuns.valor(true); - } - async salvar() { - const re = await this.__salvar_enviar_registros(); - if (re.eErro) - return re; - const rd = await this.__salvar_deletar_registros(); - if (rd.eErro) - return rd; - return respostaComuns.valor(true); - } -} -export const PilaoEnviar = (_) => new ClassPilaoEnviar(_); diff --git a/dist-import/pilao-de-dados/_serie_consultar.d.ts b/dist-import/pilao-de-dados/_serie_consultar.d.ts index 3e5c048..24c591f 100644 --- a/dist-import/pilao-de-dados/_serie_consultar.d.ts +++ b/dist-import/pilao-de-dados/_serie_consultar.d.ts @@ -1,7 +1,4 @@ -import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; -import type { visoes } from "./visoes"; export declare const z_filtro: z.ZodObject<{ coluna: z.ZodString; valor: z.ZodAny; @@ -15,11 +12,3 @@ export declare const z_filtro: z.ZodObject<{ operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; -export declare const serie_consultar: (cliente: z.infer) => (tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>) => { - dados: () => Promise; - }>>; - url: () => string; -}; diff --git a/dist-import/pilao-de-dados/_serie_consultar.js b/dist-import/pilao-de-dados/_serie_consultar.js index c3b70bd..a6c4d2d 100644 --- a/dist-import/pilao-de-dados/_serie_consultar.js +++ b/dist-import/pilao-de-dados/_serie_consultar.js @@ -1,36 +1,7 @@ -import node_fetch from "cross-fetch"; -import { respostaComuns } from "p-respostas"; import { z } from "zod"; -import { operadores_pilao, urlPilao } from "./variaveis"; +import { operadores_pilao } from "./variaveis"; export const z_filtro = z.object({ coluna: z.string(), valor: z.any(), operador: operadores_pilao, }); -export const serie_consultar = (cliente) => (tipoVisao, parametros) => { - const dados = async () => { - const url = new URL(`${urlPilao(cliente.emDesenvolvimento).api}/${tipoVisao}/${cliente.produto}/${cliente.conta}`); - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify(parametros), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (cliente.ver_log) - console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url.href}".`); - return resp; - }; - const url = () => { - const vUrl = new URL(`${urlPilao(cliente.emDesenvolvimento).site}/${tipoVisao}/${cliente.produto}/${cliente.conta}`); - const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); - if (cliente.ver_log) - console.log(`[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl.href}".`); - return `${vUrl.href}?serie=${serie}`; - }; - return { - dados, - url, - }; -}; diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 1651109..7509667 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,7 +1,5 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -import { zp_enviar_registros } from "./_enviar_registros"; -import { zp_deletar_registros, zp_produto_conta } from "./variaveis"; -import { visoes } from "./visoes"; +export * from "./Pilao"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { @@ -316,21 +314,6 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; - PilaoEnviar: (_: import("zod").TypeOf) => { - __conta: string | undefined; - __produto: string | undefined; - __emDesenvolvimento: boolean | undefined; - __ver_log: boolean | undefined; - __tabela: string | undefined; - __registrosParaEnvio: import("zod").TypeOf["registros"]; - __codigosParaDeletar: string[]; - tabela(tabela: string): any; - adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; - adicionarCodigoParaDeletar(...codigos: import("zod").TypeOf["codigos"]): any; - __salvar_enviar_registros(): Promise>; - __salvar_deletar_registros(): Promise>; - salvar(): Promise>; - }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray[]; }>; - serie_consultar: (cliente: import("zod").TypeOf) => (tipoVisao: T, parametros: import("zod").TypeOf<(typeof visoes)[T]>) => { - dados: () => Promise; - }>>; - url: () => string; - }; zp_produto_conta: import("zod").ZodObject<{ produto: import("zod").ZodString; conta: import("zod").ZodString; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index 740c8a8..395d7b6 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -1,14 +1,13 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -import { PilaoEnviar, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; +import { zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_deletar_registros, zp_produto_conta, } from "./variaveis"; -import { serie_consultar, z_filtro } from "./_serie_consultar"; +export * from "./Pilao"; +import { z_filtro } from "./_serie_consultar"; import { extruturas_de_campos, visoes } from "./visoes"; export const pPilao = { zp_deletar_registros, zp_registrar_base_dados, - PilaoEnviar, zp_enviar_registros, - serie_consultar, zp_produto_conta, validarZ, operadores_pilao, diff --git a/dist-require/pilao-de-dados/Pilao/index.d.ts b/dist-require/pilao-de-dados/Pilao/index.d.ts new file mode 100644 index 0000000..f842667 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/index.d.ts @@ -0,0 +1,60 @@ +/** Drive completo do piilão de dados */ +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 { tipo_pilao_api } from "./pilao-api.ts"; +import type { tipoConstrutorPilao } from "./tipagem"; +declare class ClassPilao { + #private; + constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { + ver_log?: boolean; + emDesenvolvimento?: boolean; + }); + rotaEnviarRegistros(): { + rota: string; + url: string; + }; + rotaDeletarRegistro(): { + rota: string; + url: string; + }; + rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rota: string; + url: string; + }; + rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao"): { + rota: string; + url: string; + }; + rotaFuncaoApi(funcao: keyof tipo_pilao_api | ":funcao"): { + rota: string; + url: string; + }; + consultarApi(funcao: T, parametros: tipo_pilao_api[T]["pr"]): Promise>; + get baseUrlApi(): "https://carro-de-boi.idz.one" | "http://localhost:5080"; + get baseUrlSite(): "https://carro-de-boi.idz.one" | "http://localhost:5081"; + validarCliente(_: any): tipoResposta; + adicionarRegistroParaEnviar(tabela: string, ...registros: z.infer["registros"]): this; + adicionarCodigoParaDeletar(tabela: string, ...codigos: z.infer["codigos"]): this; + private processarRegistros; + salvarRegistros(): Promise>; + serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { + dados: () => Promise; + }>>; + url: () => string; + }; + urlLaboratorio(): { + rota: string; + url: string; + }; +} +export declare const Pilao: (_: tipoConstrutorPilao & { + ver_log?: boolean; + emDesenvolvimento?: boolean; +}) => ClassPilao; +export {}; diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js new file mode 100644 index 0000000..8d84818 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -0,0 +1,189 @@ +"use strict"; +/** Drive completo do piilão de dados */ +var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +}; +var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +var _ClassPilao_instances, _ClassPilao_produto, _ClassPilao_conta, _ClassPilao_emDesenvolvimento, _ClassPilao_ver_log, _ClassPilao_registrosParaEnvio, _ClassPilao_codigosParaDeletar, _ClassPilao_gerarUrl, _ClassPilao_salvarEnviarRegistros, _ClassPilao_salvarDeletarRegistros; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.Pilao = void 0; +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_comuns_1 = require("p-comuns"); +const p_respostas_1 = require("p-respostas"); +const variaveis_1 = require("../variaveis"); +class ClassPilao { + constructor({ conta, produto, emDesenvolvimento = false, ver_log = false, }) { + _ClassPilao_instances.add(this); + _ClassPilao_produto.set(this, void 0); + _ClassPilao_conta.set(this, void 0); + _ClassPilao_emDesenvolvimento.set(this, void 0); + _ClassPilao_ver_log.set(this, void 0); + _ClassPilao_registrosParaEnvio.set(this, {}); + _ClassPilao_codigosParaDeletar.set(this, {}); + __classPrivateFieldSet(this, _ClassPilao_produto, produto, "f"); + __classPrivateFieldSet(this, _ClassPilao_conta, conta, "f"); + __classPrivateFieldSet(this, _ClassPilao_emDesenvolvimento, emDesenvolvimento, "f"); + __classPrivateFieldSet(this, _ClassPilao_ver_log, ver_log, "f"); + } + rotaEnviarRegistros() { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "enviar-registros"); + } + rotaDeletarRegistro() { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "deletar-registros"); + } + rotaConsultarSerie(tipoVisao) { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); + } + rotaIframeSerie(tipoVisao) { + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/consultar-serie/${tipoVisao}`; + const url = `${this.baseUrlSite}${rota}`; + return { rota, url }; + } + rotaFuncaoApi(funcao) { + return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "API", funcao); + } + async consultarApi(funcao, parametros) { + try { + const response = await (0, cross_fetch_1.default)(this.rotaFuncaoApi(funcao).url, { + body: JSON.stringify(parametros), + method: "POST", + headers: { "Content-Type": "application/json" }, + }); + return await response.json(); + } + catch (erro) { + console.error(erro); + return p_respostas_1.respostaComuns.erroInterno({ + erro, + local: (0, p_comuns_1.nomeVariavel)({ ClassPilao }), + }); + } + } + get baseUrlApi() { + return __classPrivateFieldGet(this, _ClassPilao_emDesenvolvimento, "f") + ? "http://localhost:5080" + : "https://carro-de-boi.idz.one"; + } + get baseUrlSite() { + return __classPrivateFieldGet(this, _ClassPilao_emDesenvolvimento, "f") + ? "http://localhost:5081" + : "https://carro-de-boi.idz.one"; + } + validarCliente(_) { + if (!_?.conta) + return p_respostas_1.respostaComuns.erro("Conta não informada"); + if (!_?.produto) + return p_respostas_1.respostaComuns.erro("Produto não informado"); + return p_respostas_1.respostaComuns.valor(_); + } + adicionarRegistroParaEnviar(tabela, ...registros) { + __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] = [ + ...(__classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] || []), + ...registros, + ]; + return this; + } + adicionarCodigoParaDeletar(tabela, ...codigos) { + __classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] = [ + ...(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] || []), + ...codigos, + ]; + return this; + } + async processarRegistros(url, registros, tabela, acao) { + const tamanhoBlocos = 1000; + while (registros.length > 0) { + const bloco = registros + .splice(0, tamanhoBlocos) + .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); + const resp = await (0, cross_fetch_1.default)(url, { + method: "POST", + body: JSON.stringify({ tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro(`Erro ao ${acao} registros`, [e.message])); + if (resp.eErro) + return resp; + } + return p_respostas_1.respostaComuns.valor(true); + } + async salvarRegistros() { + const re = await __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_salvarEnviarRegistros).call(this); + if (re.eErro) + return re; + const rd = await __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_salvarDeletarRegistros).call(this); + if (rd.eErro) + return rd; + return p_respostas_1.respostaComuns.valor(true); + } + serieConsultar(tipoVisao, parametros) { + const dados = async () => { + const url = this.rotaConsultarSerie(tipoVisao).url; + const resp = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify(parametros), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])); + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`); + return resp; + }; + const url = () => { + const vUrl = this.rotaIframeSerie(tipoVisao).url; + const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl}".`); + return `${vUrl}?serie=${serie}`; + }; + return { + dados, + url, + }; + } + urlLaboratorio() { + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/laboratório`; + const url = `${this.baseUrlSite}${rota}`; + return { rota, url }; + } +} +_ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const url = `${this.baseUrlApi}${rota}`; + return { rota, url }; +}, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { + for (const tabela of Object.keys(__classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f"))) { + const registros = __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] || []; + const url = this.rotaEnviarRegistros().url; + if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) + console.log(`[PILÃO]: Enviando ${registros.length} registros na tabela "${tabela}" para "${url}".`); + const resp = await this.processarRegistros(url, registros, tabela, "enviar"); + if (resp.eErro) + return resp; + __classPrivateFieldGet(this, _ClassPilao_registrosParaEnvio, "f")[tabela] = []; + } + return p_respostas_1.respostaComuns.valor(true); +}, _ClassPilao_salvarDeletarRegistros = async function _ClassPilao_salvarDeletarRegistros() { + for (const tabela of Object.keys(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f"))) { + const codigos = [...(__classPrivateFieldGet(this, _ClassPilao_codigosParaDeletar, "f")[tabela] || [])]; + const url = this.rotaDeletarRegistro().url; + const resp = await this.processarRegistros(url, codigos, tabela, "deletar"); + if (resp.eErro) + return resp; + } + return p_respostas_1.respostaComuns.valor(true); +}; +const Pilao = (_) => new ClassPilao(_); +exports.Pilao = Pilao; diff --git a/dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts b/dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts new file mode 100644 index 0000000..e2c4c75 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts @@ -0,0 +1,30 @@ +import type { z } from "zod"; +import type { zp_registrar_base_dados } from "../_enviar_registros"; +/** + * { + * 'rota':{ + * pr:{}// paramentros de entrada + * rs:{}// resposta + * } + * } + */ +export type tipo_pilao_api = { + /** retorna da data e hora do servido em formato iso */ + estado_servidor: { + pr: {}; + rs: { + data_hora: string; + }; + }; + tabelas: { + pr: {}; + rs: z.infer[]; + }; + unicos: { + pr: { + tabela: string; + coluna: string; + }; + rs: any[]; + }; +}; diff --git a/dist-require/pilao-de-dados/Pilao/pilao-api.ts.js b/dist-require/pilao-de-dados/Pilao/pilao-api.ts.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/pilao-api.ts.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts new file mode 100644 index 0000000..eb0ea76 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts @@ -0,0 +1,4 @@ +export type tipoConstrutorPilao = { + produto: string; + conta: string; +}; diff --git a/dist-require/pilao-de-dados/Pilao/tipagem.js b/dist-require/pilao-de-dados/Pilao/tipagem.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist-require/pilao-de-dados/Pilao/tipagem.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist-require/pilao-de-dados/_enviar_registros.d.ts b/dist-require/pilao-de-dados/_enviar_registros.d.ts index 9ae8965..e96f97f 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.d.ts +++ b/dist-require/pilao-de-dados/_enviar_registros.d.ts @@ -1,6 +1,4 @@ -import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_deletar_registros, type zp_produto_conta } from "./variaveis"; export declare const zp_registrar_base_dados: z.ZodObject<{ tabela: z.ZodString; colunas: z.ZodArray[]; }>; -declare class ClassPilaoEnviar { - __conta: string | undefined; - __produto: string | undefined; - __emDesenvolvimento: boolean | undefined; - __ver_log: boolean | undefined; - __tabela: string | undefined; - __registrosParaEnvio: z.infer["registros"]; - __codigosParaDeletar: string[]; - constructor({ conta, produto, emDesenvolvimento, ver_log, }: z.infer); - tabela(tabela: string): this; - adicionarRegistroParaEnviar(...registro: z.infer["registros"]): this; - adicionarCodigoParaDeletar(...codigos: z.infer["codigos"]): this; - __salvar_enviar_registros(): Promise>; - __salvar_deletar_registros(): Promise>; - salvar(): Promise>; -} -export declare const PilaoEnviar: (_: z.infer) => ClassPilaoEnviar; -export {}; diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index 723c4c0..5ed9428 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -1,11 +1,6 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.PilaoEnviar = exports.zp_enviar_registros = exports.zp_registrar_base_dados = void 0; -const cross_fetch_1 = __importDefault(require("cross-fetch")); -const p_respostas_1 = require("p-respostas"); +exports.zp_enviar_registros = exports.zp_registrar_base_dados = void 0; const zod_1 = require("zod"); const variaveis_1 = require("./variaveis"); exports.zp_registrar_base_dados = zod_1.z.object({ @@ -23,81 +18,3 @@ exports.zp_enviar_registros = zod_1.z.object({ tipo: variaveis_1.z_tipo_coluna_base_dados.optional().nullable(), }))), }); -class ClassPilaoEnviar { - constructor({ conta, produto, emDesenvolvimento, ver_log, }) { - this.__registrosParaEnvio = []; - this.__codigosParaDeletar = []; - this.__conta = conta; - this.__produto = produto; - this.__emDesenvolvimento = emDesenvolvimento; - this.__ver_log = ver_log; - } - tabela(tabela) { - this.__tabela = tabela; - return this; - } - adicionarRegistroParaEnviar(...registro) { - this.__registrosParaEnvio.push(...registro); - return this; - } - adicionarCodigoParaDeletar(...codigos) { - this.__codigosParaDeletar.push(...codigos); - return this; - } - async __salvar_enviar_registros() { - const registros = this.__registrosParaEnvio; - const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/enviar_registros/${this.__produto}/${this.__conta}`); - if (this.__ver_log) - console.log(`[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`); - const tamanhoBlocos = 1000; - while (registros.length > 0) { - const bloco = registros - .splice(0, tamanhoBlocos) - .map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]))); - const resp = await (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - return p_respostas_1.respostaComuns.valor(true); - } - async __salvar_deletar_registros() { - const codigos = [...this.__codigosParaDeletar]; - const url = new URL(`${(0, variaveis_1.urlPilao)(this.__emDesenvolvimento).api}/deletar_registros/${this.__produto}/${this.__conta}`); - const tamanhoBlocos = 1000; - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos); - const resp = await (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (resp.eErro) { - return resp; - } - } - this.__codigosParaDeletar; - return p_respostas_1.respostaComuns.valor(true); - } - async salvar() { - const re = await this.__salvar_enviar_registros(); - if (re.eErro) - return re; - const rd = await this.__salvar_deletar_registros(); - if (rd.eErro) - return rd; - return p_respostas_1.respostaComuns.valor(true); - } -} -const PilaoEnviar = (_) => new ClassPilaoEnviar(_); -exports.PilaoEnviar = PilaoEnviar; diff --git a/dist-require/pilao-de-dados/_serie_consultar.d.ts b/dist-require/pilao-de-dados/_serie_consultar.d.ts index 3e5c048..24c591f 100644 --- a/dist-require/pilao-de-dados/_serie_consultar.d.ts +++ b/dist-require/pilao-de-dados/_serie_consultar.d.ts @@ -1,7 +1,4 @@ -import type { tipoResposta } from "p-respostas"; import { z } from "zod"; -import { type zp_produto_conta } from "./variaveis"; -import type { visoes } from "./visoes"; export declare const z_filtro: z.ZodObject<{ coluna: z.ZodString; valor: z.ZodAny; @@ -15,11 +12,3 @@ export declare const z_filtro: z.ZodObject<{ operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; valor?: any; }>; -export declare const serie_consultar: (cliente: z.infer) => (tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>) => { - dados: () => Promise; - }>>; - url: () => string; -}; diff --git a/dist-require/pilao-de-dados/_serie_consultar.js b/dist-require/pilao-de-dados/_serie_consultar.js index afcf53e..388b2e8 100644 --- a/dist-require/pilao-de-dados/_serie_consultar.js +++ b/dist-require/pilao-de-dados/_serie_consultar.js @@ -1,11 +1,6 @@ "use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; Object.defineProperty(exports, "__esModule", { value: true }); -exports.serie_consultar = exports.z_filtro = void 0; -const cross_fetch_1 = __importDefault(require("cross-fetch")); -const p_respostas_1 = require("p-respostas"); +exports.z_filtro = void 0; const zod_1 = require("zod"); const variaveis_1 = require("./variaveis"); exports.z_filtro = zod_1.z.object({ @@ -13,31 +8,3 @@ exports.z_filtro = zod_1.z.object({ valor: zod_1.z.any(), operador: variaveis_1.operadores_pilao, }); -const serie_consultar = (cliente) => (tipoVisao, parametros) => { - const dados = async () => { - const url = new URL(`${(0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).api}/${tipoVisao}/${cliente.produto}/${cliente.conta}`); - const resp = await (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify(parametros), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) - .then((r) => r); - if (cliente.ver_log) - console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url.href}".`); - return resp; - }; - const url = () => { - const vUrl = new URL(`${(0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).site}/${tipoVisao}/${cliente.produto}/${cliente.conta}`); - const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); - if (cliente.ver_log) - console.log(`[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl.href}".`); - return `${vUrl.href}?serie=${serie}`; - }; - return { - dados, - url, - }; -}; -exports.serie_consultar = serie_consultar; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 1651109..7509667 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,7 +1,5 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -import { zp_enviar_registros } from "./_enviar_registros"; -import { zp_deletar_registros, zp_produto_conta } from "./variaveis"; -import { visoes } from "./visoes"; +export * from "./Pilao"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { @@ -316,21 +314,6 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; - PilaoEnviar: (_: import("zod").TypeOf) => { - __conta: string | undefined; - __produto: string | undefined; - __emDesenvolvimento: boolean | undefined; - __ver_log: boolean | undefined; - __tabela: string | undefined; - __registrosParaEnvio: import("zod").TypeOf["registros"]; - __codigosParaDeletar: string[]; - tabela(tabela: string): any; - adicionarRegistroParaEnviar(...registro: import("zod").TypeOf["registros"]): any; - adicionarCodigoParaDeletar(...codigos: import("zod").TypeOf["codigos"]): any; - __salvar_enviar_registros(): Promise>; - __salvar_deletar_registros(): Promise>; - salvar(): Promise>; - }; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray[]; }>; - serie_consultar: (cliente: import("zod").TypeOf) => (tipoVisao: T, parametros: import("zod").TypeOf<(typeof visoes)[T]>) => { - dados: () => Promise; - }>>; - url: () => string; - }; zp_produto_conta: import("zod").ZodObject<{ produto: import("zod").ZodString; conta: import("zod").ZodString; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 4933627..be7ecfe 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -1,4 +1,18 @@ "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.pPilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; var variaveis_1 = require("./variaveis"); @@ -6,14 +20,13 @@ Object.defineProperty(exports, "PREFIXO_PILAO", { enumerable: true, get: functio Object.defineProperty(exports, "urlPilao", { enumerable: true, get: function () { return variaveis_1.urlPilao; } }); const _enviar_registros_1 = require("./_enviar_registros"); const variaveis_2 = require("./variaveis"); +__exportStar(require("./Pilao"), exports); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); exports.pPilao = { zp_deletar_registros: variaveis_2.zp_deletar_registros, zp_registrar_base_dados: _enviar_registros_1.zp_registrar_base_dados, - PilaoEnviar: _enviar_registros_1.PilaoEnviar, zp_enviar_registros: _enviar_registros_1.zp_enviar_registros, - serie_consultar: _serie_consultar_1.serie_consultar, zp_produto_conta: variaveis_2.zp_produto_conta, validarZ: variaveis_2.validarZ, operadores_pilao: variaveis_2.operadores_pilao, diff --git a/package.json b/package.json index 91affd9..0c2b368 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.155.0", + "version": "0.157.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 new file mode 100644 index 0000000..8060007 --- /dev/null +++ b/src/pilao-de-dados/Pilao/index.ts @@ -0,0 +1,258 @@ +/** Drive completo do piilão de dados */ + +import crossFetch from "cross-fetch" +import { nomeVariavel } from "p-comuns" + +import { respostaComuns, type tipoResposta } from "p-respostas" +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 { tipo_pilao_api } from "./pilao-api.ts" +import type { tipoConstrutorPilao } from "./tipagem" + +class ClassPilao { + #produto: string + #conta: string + #emDesenvolvimento: boolean + #ver_log: boolean + #registrosParaEnvio: Record< + string, + z.infer["registros"] + > = {} + #codigosParaDeletar: Record< + string, + z.infer["codigos"] + > = {} + + constructor({ + conta, + produto, + emDesenvolvimento = false, + ver_log = false, + }: tipoConstrutorPilao & { ver_log?: boolean; emDesenvolvimento?: boolean }) { + this.#produto = produto + this.#conta = conta + this.#emDesenvolvimento = emDesenvolvimento + this.#ver_log = ver_log + } + + #gerarUrl(acao: string, extraPath?: string): { rota: string; url: string } { + const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/${acao}${ + extraPath ? `/${extraPath}` : "" + }` + const url = `${this.baseUrlApi}${rota}` + return { rota, url } + } + + rotaEnviarRegistros() { + return this.#gerarUrl("enviar-registros") + } + + rotaDeletarRegistro() { + return this.#gerarUrl("deletar-registros") + } + + rotaConsultarSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { + return this.#gerarUrl("consultar-serie", tipoVisao) + } + + rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { + const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/consultar-serie/${tipoVisao}` + const url = `${this.baseUrlSite}${rota}` + return { rota, url } + } + + rotaFuncaoApi(funcao: keyof tipo_pilao_api | ":funcao") { + return this.#gerarUrl("API", funcao) + } + + async consultarApi( + funcao: T, + parametros: tipo_pilao_api[T]["pr"], + ): Promise> { + try { + const response = await crossFetch(this.rotaFuncaoApi(funcao).url, { + body: JSON.stringify(parametros), + method: "POST", + headers: { "Content-Type": "application/json" }, + }) + return await response.json() + } catch (erro) { + console.error(erro) + return respostaComuns.erroInterno({ + erro, + local: nomeVariavel({ ClassPilao }), + }) + } + } + + get baseUrlApi() { + return this.#emDesenvolvimento + ? "http://localhost:5080" + : "https://carro-de-boi.idz.one" + } + + get baseUrlSite() { + return this.#emDesenvolvimento + ? "http://localhost:5081" + : "https://carro-de-boi.idz.one" + } + + validarCliente(_: any): tipoResposta { + if (!_?.conta) return respostaComuns.erro("Conta não informada") + if (!_?.produto) return respostaComuns.erro("Produto não informado") + return respostaComuns.valor(_) + } + + adicionarRegistroParaEnviar( + tabela: string, + ...registros: z.infer["registros"] + ) { + this.#registrosParaEnvio[tabela] = [ + ...(this.#registrosParaEnvio[tabela] || []), + ...registros, + ] + return this + } + + adicionarCodigoParaDeletar( + tabela: string, + ...codigos: z.infer["codigos"] + ) { + this.#codigosParaDeletar[tabela] = [ + ...(this.#codigosParaDeletar[tabela] || []), + ...codigos, + ] + return this + } + + private async processarRegistros( + url: string, + registros: any[], + tabela: string, + acao: string, + ): Promise> { + const tamanhoBlocos = 1000 + while (registros.length > 0) { + const bloco = registros + .splice(0, tamanhoBlocos) + .map((r) => + Object.fromEntries( + Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]), + ), + ) + const resp = await crossFetch(url, { + method: "POST", + body: JSON.stringify({ tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => + respostaComuns.erro(`Erro ao ${acao} registros`, [e.message]), + ) + + if (resp.eErro) return resp + } + return respostaComuns.valor(true) + } + + async #salvarEnviarRegistros(): Promise> { + for (const tabela of Object.keys(this.#registrosParaEnvio)) { + const registros = this.#registrosParaEnvio[tabela] || [] + const url = this.rotaEnviarRegistros().url + if (this.#ver_log) + console.log( + `[PILÃO]: Enviando ${registros.length} registros na tabela "${tabela}" para "${url}".`, + ) + const resp = await this.processarRegistros( + url, + registros, + tabela, + "enviar", + ) + if (resp.eErro) return resp + this.#registrosParaEnvio[tabela] = [] + } + return respostaComuns.valor(true) + } + + async #salvarDeletarRegistros(): Promise> { + for (const tabela of Object.keys(this.#codigosParaDeletar)) { + const codigos = [...(this.#codigosParaDeletar[tabela] || [])] + const url = this.rotaDeletarRegistro().url + const resp = await this.processarRegistros( + url, + codigos, + tabela, + "deletar", + ) + if (resp.eErro) return resp + } + return respostaComuns.valor(true) + } + + async salvarRegistros(): Promise> { + const re = await this.#salvarEnviarRegistros() + if (re.eErro) return re + const rd = await this.#salvarDeletarRegistros() + if (rd.eErro) return rd + return respostaComuns.valor(true) + } + + serieConsultar( + tipoVisao: T, + parametros: z.infer<(typeof visoes)[T]>, + ) { + const dados = async (): Promise< + tipoResposta<{ + registros: any[] + legenda: string + serie: z.infer<(typeof visoes)[T]> + }> + > => { + const url = this.rotaConsultarSerie(tipoVisao).url + const resp = await crossFetch(url.toString(), { + method: "POST", + body: JSON.stringify(parametros), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => + respostaComuns.erro("Erro ao enviar registros", [e.message]), + ) + + if (this.#ver_log) + console.log( + `[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`, + ) + return resp + } + + const url = (): string => { + const vUrl = this.rotaIframeSerie(tipoVisao).url + const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)) + if (this.#ver_log) + console.log( + `[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl}".`, + ) + return `${vUrl}?serie=${serie}` + } + + return { + dados, + url, + } + } + + urlLaboratorio() { + const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/laboratório` + const url = `${this.baseUrlSite}${rota}` + return { rota, url } + } +} + +export const Pilao = ( + _: tipoConstrutorPilao & { ver_log?: boolean; emDesenvolvimento?: boolean }, +) => new ClassPilao(_) diff --git a/src/pilao-de-dados/Pilao/pilao-api.ts.ts b/src/pilao-de-dados/Pilao/pilao-api.ts.ts new file mode 100755 index 0000000..cce0fd6 --- /dev/null +++ b/src/pilao-de-dados/Pilao/pilao-api.ts.ts @@ -0,0 +1,32 @@ +import type { z } from "zod" +import type { zp_registrar_base_dados } from "../_enviar_registros" + +/** + * { + * 'rota':{ + * pr:{}// paramentros de entrada + * rs:{}// resposta + * } + * } + */ +export type tipo_pilao_api = { + /** retorna da data e hora do servido em formato iso */ + estado_servidor: { + pr: {} + rs: { + data_hora: string + } + } + tabelas: { + pr: {} + rs: z.infer[] + } + + unicos: { + pr: { + tabela: string + coluna: string + } + rs: any[] + } +} diff --git a/src/pilao-de-dados/Pilao/tipagem.ts b/src/pilao-de-dados/Pilao/tipagem.ts new file mode 100644 index 0000000..ca25a79 --- /dev/null +++ b/src/pilao-de-dados/Pilao/tipagem.ts @@ -0,0 +1 @@ +export type tipoConstrutorPilao = { produto: string; conta: string } diff --git a/src/pilao-de-dados/_enviar_registros.ts b/src/pilao-de-dados/_enviar_registros.ts index 8fc8859..7a44a26 100644 --- a/src/pilao-de-dados/_enviar_registros.ts +++ b/src/pilao-de-dados/_enviar_registros.ts @@ -1,13 +1,5 @@ -import node_fetch from "cross-fetch" -import type { tipoResposta } from "p-respostas" -import { respostaComuns } from "p-respostas" import { z } from "zod" -import { - urlPilao, - z_tipo_coluna_base_dados, - type zp_deletar_registros, - type zp_produto_conta, -} from "./variaveis" +import { z_tipo_coluna_base_dados } from "./variaveis" export const zp_registrar_base_dados = z.object({ tabela: z.string(), @@ -32,135 +24,3 @@ export const zp_enviar_registros = z.object({ ), ), }) - -class ClassPilaoEnviar { - __conta: string | undefined - __produto: string | undefined - __emDesenvolvimento: boolean | undefined - __ver_log: boolean | undefined - __tabela: string | undefined - __registrosParaEnvio: z.infer["registros"] = [] - __codigosParaDeletar: string[] = [] - - constructor({ - conta, - produto, - emDesenvolvimento, - ver_log, - }: z.infer) { - this.__conta = conta - this.__produto = produto - this.__emDesenvolvimento = emDesenvolvimento - this.__ver_log = ver_log - } - - tabela(tabela: string) { - this.__tabela = tabela - return this - } - - adicionarRegistroParaEnviar( - ...registro: z.infer["registros"] - ) { - this.__registrosParaEnvio.push(...registro) - return this - } - - adicionarCodigoParaDeletar( - ...codigos: z.infer["codigos"] - ) { - this.__codigosParaDeletar.push(...codigos) - return this - } - - async __salvar_enviar_registros(): Promise> { - const registros = this.__registrosParaEnvio - - const url = new URL( - `${ - urlPilao(this.__emDesenvolvimento).api - }/enviar_registros/${this.__produto}/${this.__conta}`, - ) - - if (this.__ver_log) - console.log( - `[PILÃO]: Enviando "${registros.length}" registros na tabela "${this.__tabela}" para "${url}".`, - ) - - const tamanhoBlocos = 1000 - - while (registros.length > 0) { - const bloco = registros - .splice(0, tamanhoBlocos) - .map((r) => - Object.fromEntries( - Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v]), - ), - ) - - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, registros: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => - respostaComuns.erro("Erro ao enviar registros", [e.message]), - ) - .then((r) => r as tipoResposta) - - if (resp.eErro) { - return resp - } - } - - return respostaComuns.valor(true) - } - - async __salvar_deletar_registros() { - const codigos = [...this.__codigosParaDeletar] - - const url = new URL( - `${ - urlPilao(this.__emDesenvolvimento).api - }/deletar_registros/${this.__produto}/${this.__conta}`, - ) - - const tamanhoBlocos = 1000 - - while (codigos.length > 0) { - const bloco = codigos.splice(0, tamanhoBlocos) - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: this.__tabela, codigos: bloco }), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => - respostaComuns.erro("Erro ao enviar registros", [e.message]), - ) - .then((r) => r as tipoResposta) - - if (resp.eErro) { - return resp - } - } - - this.__codigosParaDeletar - - return respostaComuns.valor(true) - } - - async salvar() { - const re = await this.__salvar_enviar_registros() - if (re.eErro) return re - - const rd = await this.__salvar_deletar_registros() - if (rd.eErro) return rd - - return respostaComuns.valor(true) - } -} - -export const PilaoEnviar = (_: z.infer) => - new ClassPilaoEnviar(_) diff --git a/src/pilao-de-dados/_serie_consultar.ts b/src/pilao-de-dados/_serie_consultar.ts index acba175..befdb74 100644 --- a/src/pilao-de-dados/_serie_consultar.ts +++ b/src/pilao-de-dados/_serie_consultar.ts @@ -1,67 +1,8 @@ -import node_fetch from "cross-fetch" -import type { tipoResposta } from "p-respostas" -import { respostaComuns } from "p-respostas" import { z } from "zod" -import { operadores_pilao, urlPilao, type zp_produto_conta } from "./variaveis" -import type { visoes } from "./visoes" +import { operadores_pilao } from "./variaveis" export const z_filtro = z.object({ coluna: z.string(), valor: z.any(), operador: operadores_pilao, }) - -export const serie_consultar = - (cliente: z.infer) => - ( - tipoVisao: T, - parametros: z.infer<(typeof visoes)[T]>, - ) => { - const dados = async (): Promise< - tipoResposta<{ - registros: any[] - legenda: string - serie: z.infer<(typeof visoes)[T]> - }> - > => { - const url = new URL( - `${urlPilao(cliente.emDesenvolvimento).api}/${ - tipoVisao - }/${cliente.produto}/${cliente.conta}`, - ) - - const resp = await node_fetch(url.toString(), { - method: "POST", - body: JSON.stringify(parametros), - headers: { "Content-Type": "application/json" }, - }) - .then((r) => r.json()) - .catch((e) => - respostaComuns.erro("Erro ao enviar registros", [e.message]), - ) - .then((r) => r as tipoResposta) - - if (cliente.ver_log) - console.log( - `[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url.href}".`, - ) - - return resp - } - - const url = (): string => { - const vUrl = new URL( - `${urlPilao(cliente.emDesenvolvimento).site}/${tipoVisao}/${cliente.produto}/${cliente.conta}`, - ) - const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)) - if (cliente.ver_log) - console.log( - `[PILÃO]: Serie Consultar url de "${JSON.stringify(serie)}" para "${vUrl.href}".`, - ) - return `${vUrl.href}?serie=${serie}` - } - return { - dados, - url, - } - } diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 4867623..227b758 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -1,6 +1,5 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis" import { - PilaoEnviar, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros" @@ -12,16 +11,17 @@ import { zp_produto_conta, } from "./variaveis" -import { serie_consultar, z_filtro } from "./_serie_consultar" +export * from "./Pilao" + +import { z_filtro } from "./_serie_consultar" import { extruturas_de_campos, visoes } from "./visoes" export const pPilao = { zp_deletar_registros, zp_registrar_base_dados, - PilaoEnviar, zp_enviar_registros, - serie_consultar, + zp_produto_conta, validarZ, From 7b2ba9afa8e9e385c357236f03870be202ecf017 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:20:48 -0300 Subject: [PATCH 07/24] build --- dist-import/pilao-de-dados/index.d.ts | 3 ++- dist-import/pilao-de-dados/index.js | 3 ++- dist-require/pilao-de-dados/index.d.ts | 3 ++- dist-require/pilao-de-dados/index.js | 19 +++---------------- package.json | 2 +- src/pilao-de-dados/index.ts | 4 +++- 6 files changed, 13 insertions(+), 21 deletions(-) diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 7509667..37689e5 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,5 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -export * from "./Pilao"; +import { Pilao } from "./Pilao"; +export { Pilao }; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index 395d7b6..bcd17cd 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -1,7 +1,8 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_deletar_registros, zp_produto_conta, } from "./variaveis"; -export * from "./Pilao"; +import { Pilao } from "./Pilao"; +export { Pilao }; import { z_filtro } from "./_serie_consultar"; import { extruturas_de_campos, visoes } from "./visoes"; export const pPilao = { diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 7509667..37689e5 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,5 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -export * from "./Pilao"; +import { Pilao } from "./Pilao"; +export { Pilao }; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index be7ecfe..bdbb44b 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -1,26 +1,13 @@ "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.pPilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; +exports.pPilao = exports.Pilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; var variaveis_1 = require("./variaveis"); Object.defineProperty(exports, "PREFIXO_PILAO", { enumerable: true, get: function () { return variaveis_1.PREFIXO_PILAO; } }); Object.defineProperty(exports, "urlPilao", { enumerable: true, get: function () { return variaveis_1.urlPilao; } }); const _enviar_registros_1 = require("./_enviar_registros"); const variaveis_2 = require("./variaveis"); -__exportStar(require("./Pilao"), exports); +const Pilao_1 = require("./Pilao"); +Object.defineProperty(exports, "Pilao", { enumerable: true, get: function () { return Pilao_1.Pilao; } }); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); exports.pPilao = { diff --git a/package.json b/package.json index 0c2b368..0f439c4 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.157.0", + "version": "0.158.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 227b758..e4ff03d 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -11,7 +11,9 @@ import { zp_produto_conta, } from "./variaveis" -export * from "./Pilao" +import { Pilao } from "./Pilao" + +export { Pilao } import { z_filtro } from "./_serie_consultar" import { extruturas_de_campos, visoes } from "./visoes" From 64ab623007708348606a6da3aa0a19ee634a8f0e Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:28:01 -0300 Subject: [PATCH 08/24] build --- .../{pilao-api.ts.d.ts => pilao-api.d.ts} | 0 .../Pilao/{pilao-api.ts.js => pilao-api.js} | 0 dist-import/pilao-de-dados/index.d.ts | 4 ++-- dist-import/pilao-de-dados/index.js | 4 ++-- .../{pilao-api.ts.d.ts => pilao-api.d.ts} | 0 .../Pilao/{pilao-api.ts.js => pilao-api.js} | 0 dist-require/pilao-de-dados/index.d.ts | 4 ++-- dist-require/pilao-de-dados/index.js | 20 ++++++++++++++++--- package.json | 2 +- .../Pilao/{pilao-api.ts.ts => pilao-api.ts} | 0 src/pilao-de-dados/index.ts | 5 ++--- 11 files changed, 26 insertions(+), 13 deletions(-) rename dist-import/pilao-de-dados/Pilao/{pilao-api.ts.d.ts => pilao-api.d.ts} (100%) rename dist-import/pilao-de-dados/Pilao/{pilao-api.ts.js => pilao-api.js} (100%) rename dist-require/pilao-de-dados/Pilao/{pilao-api.ts.d.ts => pilao-api.d.ts} (100%) rename dist-require/pilao-de-dados/Pilao/{pilao-api.ts.js => pilao-api.js} (100%) rename src/pilao-de-dados/Pilao/{pilao-api.ts.ts => pilao-api.ts} (100%) diff --git a/dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts b/dist-import/pilao-de-dados/Pilao/pilao-api.d.ts similarity index 100% rename from dist-import/pilao-de-dados/Pilao/pilao-api.ts.d.ts rename to dist-import/pilao-de-dados/Pilao/pilao-api.d.ts diff --git a/dist-import/pilao-de-dados/Pilao/pilao-api.ts.js b/dist-import/pilao-de-dados/Pilao/pilao-api.js similarity index 100% rename from dist-import/pilao-de-dados/Pilao/pilao-api.ts.js rename to dist-import/pilao-de-dados/Pilao/pilao-api.js diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 37689e5..09ea4bb 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,6 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -import { Pilao } from "./Pilao"; -export { Pilao }; +export * from "./Pilao"; +export * from "./Pilao/pilao-api"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index bcd17cd..25115ba 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -1,8 +1,8 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; import { zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros"; import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_deletar_registros, zp_produto_conta, } from "./variaveis"; -import { Pilao } from "./Pilao"; -export { Pilao }; +export * from "./Pilao"; +export * from "./Pilao/pilao-api"; import { z_filtro } from "./_serie_consultar"; import { extruturas_de_campos, visoes } from "./visoes"; export const pPilao = { diff --git a/dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts b/dist-require/pilao-de-dados/Pilao/pilao-api.d.ts similarity index 100% rename from dist-require/pilao-de-dados/Pilao/pilao-api.ts.d.ts rename to dist-require/pilao-de-dados/Pilao/pilao-api.d.ts diff --git a/dist-require/pilao-de-dados/Pilao/pilao-api.ts.js b/dist-require/pilao-de-dados/Pilao/pilao-api.js similarity index 100% rename from dist-require/pilao-de-dados/Pilao/pilao-api.ts.js rename to dist-require/pilao-de-dados/Pilao/pilao-api.js diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 37689e5..09ea4bb 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,6 +1,6 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; -import { Pilao } from "./Pilao"; -export { Pilao }; +export * from "./Pilao"; +export * from "./Pilao/pilao-api"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index bdbb44b..53bc4b6 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -1,13 +1,27 @@ "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.pPilao = exports.Pilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; +exports.pPilao = exports.urlPilao = exports.PREFIXO_PILAO = void 0; var variaveis_1 = require("./variaveis"); Object.defineProperty(exports, "PREFIXO_PILAO", { enumerable: true, get: function () { return variaveis_1.PREFIXO_PILAO; } }); Object.defineProperty(exports, "urlPilao", { enumerable: true, get: function () { return variaveis_1.urlPilao; } }); const _enviar_registros_1 = require("./_enviar_registros"); const variaveis_2 = require("./variaveis"); -const Pilao_1 = require("./Pilao"); -Object.defineProperty(exports, "Pilao", { enumerable: true, get: function () { return Pilao_1.Pilao; } }); +__exportStar(require("./Pilao"), exports); +__exportStar(require("./Pilao/pilao-api"), exports); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); exports.pPilao = { diff --git a/package.json b/package.json index 0f439c4..f944f8e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.158.0", + "version": "0.159.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/Pilao/pilao-api.ts.ts b/src/pilao-de-dados/Pilao/pilao-api.ts similarity index 100% rename from src/pilao-de-dados/Pilao/pilao-api.ts.ts rename to src/pilao-de-dados/Pilao/pilao-api.ts diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index e4ff03d..f9e1b68 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -11,9 +11,8 @@ import { zp_produto_conta, } from "./variaveis" -import { Pilao } from "./Pilao" - -export { Pilao } +export * from "./Pilao" +export * from "./Pilao/pilao-api" import { z_filtro } from "./_serie_consultar" import { extruturas_de_campos, visoes } from "./visoes" From 9c9570388fcb0e1c65f4f0b9a60d3559713275a1 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:47:56 -0300 Subject: [PATCH 09/24] build --- dist-import/pilao-de-dados/Pilao/index.d.ts | 8 ++------ dist-import/pilao-de-dados/Pilao/tipagem.d.ts | 7 +++++++ dist-require/pilao-de-dados/Pilao/index.d.ts | 8 ++------ dist-require/pilao-de-dados/Pilao/tipagem.d.ts | 7 +++++++ package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 8 ++------ src/pilao-de-dados/Pilao/tipagem.ts | 9 +++++++++ 7 files changed, 30 insertions(+), 19 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.d.ts b/dist-import/pilao-de-dados/Pilao/index.d.ts index f842667..14dcc10 100644 --- a/dist-import/pilao-de-dados/Pilao/index.d.ts +++ b/dist-import/pilao-de-dados/Pilao/index.d.ts @@ -5,7 +5,7 @@ import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; import type { visoes } from "../visoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; -import type { tipoConstrutorPilao } from "./tipagem"; +import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem"; declare class ClassPilao { #private; constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { @@ -41,11 +41,7 @@ declare class ClassPilao { private processarRegistros; salvarRegistros(): Promise>; serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { - dados: () => Promise; - }>>; + dados: () => Promise>>; url: () => string; }; urlLaboratorio(): { diff --git a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts index eb0ea76..f94c9ce 100644 --- a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts @@ -1,4 +1,11 @@ +import type { z } from "zod"; +import type { visoes } from "../visoes"; export type tipoConstrutorPilao = { produto: string; conta: string; }; +export type tipoRetornoSerirconsulta = { + registros: any[]; + legenda: string; + serie: z.infer<(typeof visoes)[T]>; +}; diff --git a/dist-require/pilao-de-dados/Pilao/index.d.ts b/dist-require/pilao-de-dados/Pilao/index.d.ts index f842667..14dcc10 100644 --- a/dist-require/pilao-de-dados/Pilao/index.d.ts +++ b/dist-require/pilao-de-dados/Pilao/index.d.ts @@ -5,7 +5,7 @@ import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; import type { visoes } from "../visoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; -import type { tipoConstrutorPilao } from "./tipagem"; +import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem"; declare class ClassPilao { #private; constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { @@ -41,11 +41,7 @@ declare class ClassPilao { private processarRegistros; salvarRegistros(): Promise>; serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { - dados: () => Promise; - }>>; + dados: () => Promise>>; url: () => string; }; urlLaboratorio(): { diff --git a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts index eb0ea76..f94c9ce 100644 --- a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts @@ -1,4 +1,11 @@ +import type { z } from "zod"; +import type { visoes } from "../visoes"; export type tipoConstrutorPilao = { produto: string; conta: string; }; +export type tipoRetornoSerirconsulta = { + registros: any[]; + legenda: string; + serie: z.infer<(typeof visoes)[T]>; +}; diff --git a/package.json b/package.json index f944f8e..cf5a50c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.159.0", + "version": "0.160.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 8060007..b24ebc1 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -10,7 +10,7 @@ import type { zp_enviar_registros } from "../_enviar_registros" import { PREFIXO_PILAO, type zp_deletar_registros } from "../variaveis" import type { visoes } from "../visoes" import type { tipo_pilao_api } from "./pilao-api.ts" -import type { tipoConstrutorPilao } from "./tipagem" +import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem" class ClassPilao { #produto: string @@ -206,11 +206,7 @@ class ClassPilao { parametros: z.infer<(typeof visoes)[T]>, ) { const dados = async (): Promise< - tipoResposta<{ - registros: any[] - legenda: string - serie: z.infer<(typeof visoes)[T]> - }> + tipoResposta> > => { const url = this.rotaConsultarSerie(tipoVisao).url const resp = await crossFetch(url.toString(), { diff --git a/src/pilao-de-dados/Pilao/tipagem.ts b/src/pilao-de-dados/Pilao/tipagem.ts index ca25a79..50cdeee 100644 --- a/src/pilao-de-dados/Pilao/tipagem.ts +++ b/src/pilao-de-dados/Pilao/tipagem.ts @@ -1 +1,10 @@ +import type { z } from "zod" +import type { visoes } from "../visoes" + export type tipoConstrutorPilao = { produto: string; conta: string } + +export type tipoRetornoSerirconsulta = { + registros: any[] + legenda: string + serie: z.infer<(typeof visoes)[T]> +} From efd8aaf87d5dc07b1eeb1d8290203935488f0ffe Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:48:48 -0300 Subject: [PATCH 10/24] build --- dist-import/pilao-de-dados/index.d.ts | 1 + dist-import/pilao-de-dados/index.js | 1 + dist-require/pilao-de-dados/index.d.ts | 1 + dist-require/pilao-de-dados/index.js | 1 + package.json | 2 +- src/pilao-de-dados/index.ts | 1 + 6 files changed, 6 insertions(+), 1 deletion(-) diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 09ea4bb..946c0bd 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -1,6 +1,7 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; export * from "./Pilao"; export * from "./Pilao/pilao-api"; +export * from "./Pilao/tipagem"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index 25115ba..0d9f871 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -3,6 +3,7 @@ import { zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registr import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, zp_deletar_registros, zp_produto_conta, } from "./variaveis"; 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"; export const pPilao = { diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 09ea4bb..946c0bd 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -1,6 +1,7 @@ export { PREFIXO_PILAO, urlPilao } from "./variaveis"; export * from "./Pilao"; export * from "./Pilao/pilao-api"; +export * from "./Pilao/tipagem"; export declare const pPilao: { extruturas_de_campos: { z_contagem_em_barra_vertical: { diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 53bc4b6..ae598ec 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -22,6 +22,7 @@ const _enviar_registros_1 = require("./_enviar_registros"); const variaveis_2 = require("./variaveis"); __exportStar(require("./Pilao"), exports); __exportStar(require("./Pilao/pilao-api"), exports); +__exportStar(require("./Pilao/tipagem"), exports); const _serie_consultar_1 = require("./_serie_consultar"); const visoes_1 = require("./visoes"); exports.pPilao = { diff --git a/package.json b/package.json index cf5a50c..f761c77 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.160.0", + "version": "0.161.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index f9e1b68..74ef534 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -13,6 +13,7 @@ import { 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" From b83125f06b90d38c64097492e74cc6900f6ff4d6 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:49:36 -0300 Subject: [PATCH 11/24] build --- dist-import/pilao-de-dados/Pilao/index.d.ts | 4 ++-- dist-import/pilao-de-dados/Pilao/tipagem.d.ts | 2 +- dist-require/pilao-de-dados/Pilao/index.d.ts | 4 ++-- dist-require/pilao-de-dados/Pilao/tipagem.d.ts | 2 +- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 4 ++-- src/pilao-de-dados/Pilao/tipagem.ts | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.d.ts b/dist-import/pilao-de-dados/Pilao/index.d.ts index 14dcc10..b47e992 100644 --- a/dist-import/pilao-de-dados/Pilao/index.d.ts +++ b/dist-import/pilao-de-dados/Pilao/index.d.ts @@ -5,7 +5,7 @@ import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; import type { visoes } from "../visoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; -import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem"; +import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem"; declare class ClassPilao { #private; constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { @@ -41,7 +41,7 @@ declare class ClassPilao { private processarRegistros; salvarRegistros(): Promise>; serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { - dados: () => Promise>>; + dados: () => Promise>>; url: () => string; }; urlLaboratorio(): { diff --git a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts index f94c9ce..092b897 100644 --- a/dist-import/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-import/pilao-de-dados/Pilao/tipagem.d.ts @@ -4,7 +4,7 @@ export type tipoConstrutorPilao = { produto: string; conta: string; }; -export type tipoRetornoSerirconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[]; legenda: string; serie: z.infer<(typeof visoes)[T]>; diff --git a/dist-require/pilao-de-dados/Pilao/index.d.ts b/dist-require/pilao-de-dados/Pilao/index.d.ts index 14dcc10..b47e992 100644 --- a/dist-require/pilao-de-dados/Pilao/index.d.ts +++ b/dist-require/pilao-de-dados/Pilao/index.d.ts @@ -5,7 +5,7 @@ import type { zp_enviar_registros } from "../_enviar_registros"; import { type zp_deletar_registros } from "../variaveis"; import type { visoes } from "../visoes"; import type { tipo_pilao_api } from "./pilao-api.ts"; -import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem"; +import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem"; declare class ClassPilao { #private; constructor({ conta, produto, emDesenvolvimento, ver_log, }: tipoConstrutorPilao & { @@ -41,7 +41,7 @@ declare class ClassPilao { private processarRegistros; salvarRegistros(): Promise>; serieConsultar(tipoVisao: T, parametros: z.infer<(typeof visoes)[T]>): { - dados: () => Promise>>; + dados: () => Promise>>; url: () => string; }; urlLaboratorio(): { diff --git a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts index f94c9ce..092b897 100644 --- a/dist-require/pilao-de-dados/Pilao/tipagem.d.ts +++ b/dist-require/pilao-de-dados/Pilao/tipagem.d.ts @@ -4,7 +4,7 @@ export type tipoConstrutorPilao = { produto: string; conta: string; }; -export type tipoRetornoSerirconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[]; legenda: string; serie: z.infer<(typeof visoes)[T]>; diff --git a/package.json b/package.json index f761c77..457ee0b 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.161.0", + "version": "0.162.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 b24ebc1..ab79700 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -10,7 +10,7 @@ import type { zp_enviar_registros } from "../_enviar_registros" import { PREFIXO_PILAO, type zp_deletar_registros } from "../variaveis" import type { visoes } from "../visoes" import type { tipo_pilao_api } from "./pilao-api.ts" -import type { tipoConstrutorPilao, tipoRetornoSerirconsulta } from "./tipagem" +import type { tipoConstrutorPilao, tipoRetornoSerieconsulta } from "./tipagem" class ClassPilao { #produto: string @@ -206,7 +206,7 @@ class ClassPilao { parametros: z.infer<(typeof visoes)[T]>, ) { const dados = async (): Promise< - tipoResposta> + tipoResposta> > => { const url = this.rotaConsultarSerie(tipoVisao).url const resp = await crossFetch(url.toString(), { diff --git a/src/pilao-de-dados/Pilao/tipagem.ts b/src/pilao-de-dados/Pilao/tipagem.ts index 50cdeee..30f3a6e 100644 --- a/src/pilao-de-dados/Pilao/tipagem.ts +++ b/src/pilao-de-dados/Pilao/tipagem.ts @@ -3,7 +3,7 @@ import type { visoes } from "../visoes" export type tipoConstrutorPilao = { produto: string; conta: string } -export type tipoRetornoSerirconsulta = { +export type tipoRetornoSerieconsulta = { registros: any[] legenda: string serie: z.infer<(typeof visoes)[T]> From 336926a7ef0764c271e5d95b271a7cab1495b8ca Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 09:51:20 -0300 Subject: [PATCH 12/24] build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 457ee0b..4184215 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.162.0", + "version": "0.163.0", "description": "", "main": "src/index.ts", "exports": { From db1cb22ee975c376f7a7b187b58968a1c89d933f Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 10:12:20 -0300 Subject: [PATCH 13/24] build --- dist-import/pilao-de-dados/index.d.ts | 144 ++++++++++++++++++ dist-import/pilao-de-dados/visoes/index.d.ts | 84 ++++++++++ dist-import/pilao-de-dados/visoes/index.js | 49 ++++++ dist-require/pilao-de-dados/index.d.ts | 144 ++++++++++++++++++ dist-require/pilao-de-dados/visoes/index.d.ts | 84 ++++++++++ dist-require/pilao-de-dados/visoes/index.js | 51 ++++++- package.json | 2 +- src/pilao-de-dados/visoes/index.ts | 66 ++++++++ 8 files changed, 622 insertions(+), 2 deletions(-) diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 946c0bd..4e2ab13 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -163,6 +163,66 @@ export declare const pPilao: { }; }; }; + 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("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -281,6 +341,48 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + z_soma_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaSoma: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodOptional>; + filtros: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: import("zod").ZodOptional; + }, "strip", import("zod").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; + }>; zp_deletar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; codigos: import("zod").ZodArray; @@ -501,5 +603,47 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + z_soma_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaSoma: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodOptional>; + filtros: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: import("zod").ZodOptional; + }, "strip", import("zod").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/index.d.ts b/dist-import/pilao-de-dados/visoes/index.d.ts index 7ff03ea..c6b4e06 100644 --- a/dist-import/pilao-de-dados/visoes/index.d.ts +++ b/dist-import/pilao-de-dados/visoes/index.d.ts @@ -39,6 +39,48 @@ export declare const z_contagem_em_barra_vertical: z.ZodObject<{ }[] | 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; @@ -235,6 +277,48 @@ export declare const visoes: { 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: { diff --git a/dist-import/pilao-de-dados/visoes/index.js b/dist-import/pilao-de-dados/visoes/index.js index ca35eaa..cec532a 100644 --- a/dist-import/pilao-de-dados/visoes/index.js +++ b/dist-import/pilao-de-dados/visoes/index.js @@ -16,6 +16,14 @@ export const z_contagem_em_barra_vertical = z.object({ 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(), @@ -34,6 +42,7 @@ 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 = { @@ -72,6 +81,46 @@ export const extruturas_de_campos = { 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 do Eixo X", + 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", diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 946c0bd..4e2ab13 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -163,6 +163,66 @@ export declare const pPilao: { }; }; }; + 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("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -281,6 +341,48 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + z_soma_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaSoma: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodOptional>; + filtros: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: import("zod").ZodOptional; + }, "strip", import("zod").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; + }>; zp_deletar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; codigos: import("zod").ZodArray; @@ -501,5 +603,47 @@ export declare const pPilao: { coluna_ordem?: string | undefined; direcao_ordem?: "1" | "asc" | "desc" | "-1" | undefined; }>; + z_soma_em_barra_vertical: import("zod").ZodObject<{ + tabela: import("zod").ZodString; + colanuEixoX: import("zod").ZodString; + colunaSoma: import("zod").ZodString; + colunaAgrupamento: import("zod").ZodOptional>; + filtros: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "strip", import("zod").ZodTypeAny, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }, { + coluna: string; + operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩"; + valor?: any; + }>, "many">>; + descricao_pelo_usuario: import("zod").ZodOptional; + }, "strip", import("zod").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/index.d.ts b/dist-require/pilao-de-dados/visoes/index.d.ts index 7ff03ea..c6b4e06 100644 --- a/dist-require/pilao-de-dados/visoes/index.d.ts +++ b/dist-require/pilao-de-dados/visoes/index.d.ts @@ -39,6 +39,48 @@ export declare const z_contagem_em_barra_vertical: z.ZodObject<{ }[] | 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; @@ -235,6 +277,48 @@ export declare const visoes: { 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: { diff --git a/dist-require/pilao-de-dados/visoes/index.js b/dist-require/pilao-de-dados/visoes/index.js index f63bae8..e1e426a 100644 --- a/dist-require/pilao-de-dados/visoes/index.js +++ b/dist-require/pilao-de-dados/visoes/index.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.extruturas_de_campos = exports.visoes = exports.z_tabela = exports.z_contagem_em_pizza = exports.z_contagem_em_barra_vertical = void 0; +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 @@ -19,6 +19,14 @@ exports.z_contagem_em_barra_vertical = zod_1.z.object({ 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(), @@ -37,6 +45,7 @@ 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 = { @@ -75,6 +84,46 @@ exports.extruturas_de_campos = { 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 do Eixo X", + 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", diff --git a/package.json b/package.json index 4184215..8156e78 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.163.0", + "version": "0.164.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/visoes/index.ts b/src/pilao-de-dados/visoes/index.ts index ec59528..aaa1d63 100644 --- a/src/pilao-de-dados/visoes/index.ts +++ b/src/pilao-de-dados/visoes/index.ts @@ -19,6 +19,15 @@ export const z_contagem_em_barra_vertical = z.object({ 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(), @@ -39,6 +48,7 @@ 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 */ @@ -112,6 +122,62 @@ export const extruturas_de_campos: { 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 do Eixo X", + 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", From cb61a8500e05beb45a98ca55ca1f5fec6f38a12f Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 10:19:56 -0300 Subject: [PATCH 14/24] buld --- dist-import/pilao-de-dados/visoes/index.js | 2 +- dist-require/pilao-de-dados/visoes/index.js | 2 +- package.json | 2 +- src/pilao-de-dados/visoes/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist-import/pilao-de-dados/visoes/index.js b/dist-import/pilao-de-dados/visoes/index.js index cec532a..0a148f6 100644 --- a/dist-import/pilao-de-dados/visoes/index.js +++ b/dist-import/pilao-de-dados/visoes/index.js @@ -99,7 +99,7 @@ export const extruturas_de_campos = { campos: { tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, colunaSoma: { - rotulo: "Coluna do Eixo X", + rotulo: "Coluna de Somatória", tipo_campo: "coluna", order: 2, }, diff --git a/dist-require/pilao-de-dados/visoes/index.js b/dist-require/pilao-de-dados/visoes/index.js index e1e426a..1f41b3e 100644 --- a/dist-require/pilao-de-dados/visoes/index.js +++ b/dist-require/pilao-de-dados/visoes/index.js @@ -102,7 +102,7 @@ exports.extruturas_de_campos = { campos: { tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, colunaSoma: { - rotulo: "Coluna do Eixo X", + rotulo: "Coluna de Somatória", tipo_campo: "coluna", order: 2, }, diff --git a/package.json b/package.json index 8156e78..5ac5a03 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.164.0", + "version": "0.165.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/visoes/index.ts b/src/pilao-de-dados/visoes/index.ts index aaa1d63..8399342 100644 --- a/src/pilao-de-dados/visoes/index.ts +++ b/src/pilao-de-dados/visoes/index.ts @@ -155,7 +155,7 @@ export const extruturas_de_campos: { tabela: { rotulo: "Tabela", tipo_campo: "tabela", order: 1 }, colunaSoma: { - rotulo: "Coluna do Eixo X", + rotulo: "Coluna de Somatória", tipo_campo: "coluna", order: 2, }, From 1d3c84ff9ac764c7d1e15fe1770dc4582fc7a89a Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 11:05:44 -0300 Subject: [PATCH 15/24] ajuste produto ocnta --- dist-import/pilao-de-dados/Pilao/index.js | 6 +++--- dist-require/pilao-de-dados/Pilao/index.js | 6 +++--- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index 090107b..4579872 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -39,7 +39,7 @@ class ClassPilao { return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); } rotaIframeSerie(tipoVisao) { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/consultar-serie/${tipoVisao}`; + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/consultar-serie/${tipoVisao}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } @@ -148,13 +148,13 @@ class ClassPilao { }; } urlLaboratorio() { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/laboratório`; + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/laboratório`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index 8d84818..16b51f0 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -45,7 +45,7 @@ class ClassPilao { return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); } rotaIframeSerie(tipoVisao) { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/consultar-serie/${tipoVisao}`; + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/consultar-serie/${tipoVisao}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } @@ -154,13 +154,13 @@ class ClassPilao { }; } urlLaboratorio() { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/laboratório`; + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/laboratório`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/package.json b/package.json index 5ac5a03..9a597de 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.165.0", + "version": "0.167.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 ab79700..9e415be 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -39,7 +39,7 @@ class ClassPilao { } #gerarUrl(acao: string, extraPath?: string): { rota: string; url: string } { - const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/${acao}${ + const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/${acao}${ extraPath ? `/${extraPath}` : "" }` const url = `${this.baseUrlApi}${rota}` @@ -59,7 +59,7 @@ class ClassPilao { } rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { - const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/consultar-serie/${tipoVisao}` + const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/consultar-serie/${tipoVisao}` const url = `${this.baseUrlSite}${rota}` return { rota, url } } @@ -243,7 +243,7 @@ class ClassPilao { } urlLaboratorio() { - const rota = `${PREFIXO_PILAO}/${this.#conta}/${this.#produto}/laboratório` + const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/laboratório` const url = `${this.baseUrlSite}${rota}` return { rota, url } } From 779ff305f01175492dc51fa7faef84408954a3cb Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 13:19:19 -0300 Subject: [PATCH 16/24] . --- dist-import/pilao-de-dados/Pilao/index.js | 2 +- dist-require/pilao-de-dados/Pilao/index.js | 2 +- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index 4579872..abafcad 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -154,7 +154,7 @@ class ClassPilao { } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${PREFIXO_PILAO}/api/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index 16b51f0..baf48b2 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -160,7 +160,7 @@ class ClassPilao { } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${variaveis_1.PREFIXO_PILAO}/api/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/package.json b/package.json index 9a597de..b853466 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.167.0", + "version": "0.168.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 9e415be..80c89af 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -39,7 +39,7 @@ class ClassPilao { } #gerarUrl(acao: string, extraPath?: string): { rota: string; url: string } { - const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/${acao}${ + const rota = `${PREFIXO_PILAO}/api/${this.#produto}/${this.#conta}/${acao}${ extraPath ? `/${extraPath}` : "" }` const url = `${this.baseUrlApi}${rota}` From d0808a86dc98657ac2f326ba5d82b3c9995a36b4 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 13:27:59 -0300 Subject: [PATCH 17/24] build --- dist-import/pilao-de-dados/Pilao/index.js | 6 +++--- dist-require/pilao-de-dados/Pilao/index.js | 6 +++--- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index abafcad..8d88b14 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -39,7 +39,7 @@ class ClassPilao { return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); } rotaIframeSerie(tipoVisao) { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/consultar-serie/${tipoVisao}`; + const rota = `${PREFIXO_PILAO}/consultar-serie/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${tipoVisao}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } @@ -148,13 +148,13 @@ class ClassPilao { }; } urlLaboratorio() { - const rota = `${PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/laboratório`; + const rota = `${PREFIXO_PILAO}/laboratório/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${PREFIXO_PILAO}/api/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${PREFIXO_PILAO}/api/${acao}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index baf48b2..b700444 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -45,7 +45,7 @@ class ClassPilao { return __classPrivateFieldGet(this, _ClassPilao_instances, "m", _ClassPilao_gerarUrl).call(this, "consultar-serie", tipoVisao); } rotaIframeSerie(tipoVisao) { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/consultar-serie/${tipoVisao}`; + const rota = `${variaveis_1.PREFIXO_PILAO}/consultar-serie/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${tipoVisao}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } @@ -154,13 +154,13 @@ class ClassPilao { }; } urlLaboratorio() { - const rota = `${variaveis_1.PREFIXO_PILAO}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/laboratório`; + const rota = `${variaveis_1.PREFIXO_PILAO}/laboratório/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}`; const url = `${this.baseUrlSite}${rota}`; return { rota, url }; } } _ClassPilao_produto = new WeakMap(), _ClassPilao_conta = new WeakMap(), _ClassPilao_emDesenvolvimento = new WeakMap(), _ClassPilao_ver_log = new WeakMap(), _ClassPilao_registrosParaEnvio = new WeakMap(), _ClassPilao_codigosParaDeletar = new WeakMap(), _ClassPilao_instances = new WeakSet(), _ClassPilao_gerarUrl = function _ClassPilao_gerarUrl(acao, extraPath) { - const rota = `${variaveis_1.PREFIXO_PILAO}/api/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}/${acao}${extraPath ? `/${extraPath}` : ""}`; + const rota = `${variaveis_1.PREFIXO_PILAO}/api/${acao}/${__classPrivateFieldGet(this, _ClassPilao_produto, "f")}/${__classPrivateFieldGet(this, _ClassPilao_conta, "f")}${extraPath ? `/${extraPath}` : ""}`; const url = `${this.baseUrlApi}${rota}`; return { rota, url }; }, _ClassPilao_salvarEnviarRegistros = async function _ClassPilao_salvarEnviarRegistros() { diff --git a/package.json b/package.json index b853466..cec5458 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.168.0", + "version": "0.169.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 80c89af..cf4b3eb 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -39,7 +39,7 @@ class ClassPilao { } #gerarUrl(acao: string, extraPath?: string): { rota: string; url: string } { - const rota = `${PREFIXO_PILAO}/api/${this.#produto}/${this.#conta}/${acao}${ + const rota = `${PREFIXO_PILAO}/api/${acao}/${this.#produto}/${this.#conta}${ extraPath ? `/${extraPath}` : "" }` const url = `${this.baseUrlApi}${rota}` @@ -59,7 +59,7 @@ class ClassPilao { } rotaIframeSerie(tipoVisao: keyof typeof visoes | ":tipoVisao") { - const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/consultar-serie/${tipoVisao}` + const rota = `${PREFIXO_PILAO}/consultar-serie/${this.#produto}/${this.#conta}/${tipoVisao}` const url = `${this.baseUrlSite}${rota}` return { rota, url } } @@ -243,7 +243,7 @@ class ClassPilao { } urlLaboratorio() { - const rota = `${PREFIXO_PILAO}/${this.#produto}/${this.#conta}/laboratório` + const rota = `${PREFIXO_PILAO}/laboratório/${this.#produto}/${this.#conta}` const url = `${this.baseUrlSite}${rota}` return { rota, url } } From ef9b4c746c353ee6d0bf97987387aa126eb4d871 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 14:34:15 -0300 Subject: [PATCH 18/24] build --- dist-import/pilao-de-dados/Pilao/index.js | 12 +++++++++++- dist-require/pilao-de-dados/Pilao/index.js | 12 +++++++++++- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 11 ++++++++++- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index 8d88b14..de60469 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -105,7 +105,17 @@ class ClassPilao { body: JSON.stringify({ tabela, registros: bloco }), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + try { + return await r.json(); + } + catch { + return respostaComuns.erro("Consulta não retornou json válido", [ + await r.text(), + r.statusText, + ]); + } + }) .catch((e) => respostaComuns.erro(`Erro ao ${acao} registros`, [e.message])); if (resp.eErro) return resp; diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index b700444..00ea63c 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -111,7 +111,17 @@ class ClassPilao { body: JSON.stringify({ tabela, registros: bloco }), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + try { + return await r.json(); + } + catch { + return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [ + await r.text(), + r.statusText, + ]); + } + }) .catch((e) => p_respostas_1.respostaComuns.erro(`Erro ao ${acao} registros`, [e.message])); if (resp.eErro) return resp; diff --git a/package.json b/package.json index cec5458..64800e3 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.169.0", + "version": "0.170.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 cf4b3eb..3776298 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -148,7 +148,16 @@ class ClassPilao { body: JSON.stringify({ tabela, registros: bloco }), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + try { + return await r.json() + } catch { + return respostaComuns.erro("Consulta não retornou json válido", [ + await r.text(), + r.statusText, + ]) + } + }) .catch((e) => respostaComuns.erro(`Erro ao ${acao} registros`, [e.message]), ) From 4e1b4156146180c6301134851131a7d0fe5ee93a Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 14:47:38 -0300 Subject: [PATCH 19/24] build --- dist-import/pilao-de-dados/Pilao/index.js | 29 +++++++++++++++++---- dist-require/pilao-de-dados/Pilao/index.js | 29 +++++++++++++++++---- package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 30 ++++++++++++++++++---- 4 files changed, 74 insertions(+), 16 deletions(-) diff --git a/dist-import/pilao-de-dados/Pilao/index.js b/dist-import/pilao-de-dados/Pilao/index.js index de60469..38c14d6 100644 --- a/dist-import/pilao-de-dados/Pilao/index.js +++ b/dist-import/pilao-de-dados/Pilao/index.js @@ -53,7 +53,14 @@ class ClassPilao { method: "POST", headers: { "Content-Type": "application/json" }, }); - return await response.json(); + const texto = await response.text(); + try { + const json = JSON.parse(texto); + return json; + } + catch { + return respostaComuns.erro("Consulta não retornou json válido", [texto]); + } } catch (erro) { console.error(erro); @@ -106,13 +113,14 @@ class ClassPilao { headers: { "Content-Type": "application/json" }, }) .then(async (r) => { + const texto = await r.text(); try { - return await r.json(); + const json = JSON.parse(texto); + return json; } catch { return respostaComuns.erro("Consulta não retornou json válido", [ - await r.text(), - r.statusText, + texto, ]); } }) @@ -139,7 +147,18 @@ class ClassPilao { body: JSON.stringify(parametros), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + const texto = await r.text(); + try { + const json = JSON.parse(texto); + return json; + } + catch { + return respostaComuns.erro("Consulta não retornou json válido", [ + texto, + ]); + } + }) .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message])); if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`); diff --git a/dist-require/pilao-de-dados/Pilao/index.js b/dist-require/pilao-de-dados/Pilao/index.js index 00ea63c..9bad062 100644 --- a/dist-require/pilao-de-dados/Pilao/index.js +++ b/dist-require/pilao-de-dados/Pilao/index.js @@ -59,7 +59,14 @@ class ClassPilao { method: "POST", headers: { "Content-Type": "application/json" }, }); - return await response.json(); + const texto = await response.text(); + try { + const json = JSON.parse(texto); + return json; + } + catch { + return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [texto]); + } } catch (erro) { console.error(erro); @@ -112,13 +119,14 @@ class ClassPilao { headers: { "Content-Type": "application/json" }, }) .then(async (r) => { + const texto = await r.text(); try { - return await r.json(); + const json = JSON.parse(texto); + return json; } catch { return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [ - await r.text(), - r.statusText, + texto, ]); } }) @@ -145,7 +153,18 @@ class ClassPilao { body: JSON.stringify(parametros), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + const texto = await r.text(); + try { + const json = JSON.parse(texto); + return json; + } + catch { + return p_respostas_1.respostaComuns.erro("Consulta não retornou json válido", [ + texto, + ]); + } + }) .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])); if (__classPrivateFieldGet(this, _ClassPilao_ver_log, "f")) console.log(`[PILÃO]: buscar dados de "${JSON.stringify(parametros)}" para "${url}".`); diff --git a/package.json b/package.json index 64800e3..7e7f301 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.170.0", + "version": "0.171.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 3776298..ba075b6 100644 --- a/src/pilao-de-dados/Pilao/index.ts +++ b/src/pilao-de-dados/Pilao/index.ts @@ -78,7 +78,15 @@ class ClassPilao { method: "POST", headers: { "Content-Type": "application/json" }, }) - return await response.json() + + const texto = await response.text() + + try { + const json = JSON.parse(texto) + return json + } catch { + return respostaComuns.erro("Consulta não retornou json válido", [texto]) + } } catch (erro) { console.error(erro) return respostaComuns.erroInterno({ @@ -149,12 +157,13 @@ class ClassPilao { headers: { "Content-Type": "application/json" }, }) .then(async (r) => { + const texto = await r.text() try { - return await r.json() + const json = JSON.parse(texto) + return json } catch { return respostaComuns.erro("Consulta não retornou json válido", [ - await r.text(), - r.statusText, + texto, ]) } }) @@ -223,7 +232,18 @@ class ClassPilao { body: JSON.stringify(parametros), headers: { "Content-Type": "application/json" }, }) - .then((r) => r.json()) + .then(async (r) => { + const texto = await r.text() + + try { + const json = JSON.parse(texto) + return json + } catch { + return respostaComuns.erro("Consulta não retornou json válido", [ + texto, + ]) + } + }) .catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]), ) From 33a89ac1f3d100c2edc016a3232afbedb1615c7c Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Wed, 2 Oct 2024 16:26:28 -0300 Subject: [PATCH 20/24] build --- dist-import/pilao-de-dados/_enviar_registros.js | 6 +++--- dist-import/pilao-de-dados/index.d.ts | 1 + dist-import/pilao-de-dados/index.js | 3 ++- dist-import/pilao-de-dados/variaveis.d.ts | 4 ++-- dist-import/pilao-de-dados/variaveis.js | 2 +- dist-require/pilao-de-dados/_enviar_registros.js | 4 ++-- dist-require/pilao-de-dados/index.d.ts | 1 + dist-require/pilao-de-dados/index.js | 1 + dist-require/pilao-de-dados/variaveis.d.ts | 4 ++-- dist-require/pilao-de-dados/variaveis.js | 4 ++-- package.json | 2 +- src/pilao-de-dados/_enviar_registros.ts | 6 +++--- src/pilao-de-dados/index.ts | 3 ++- src/pilao-de-dados/variaveis.ts | 4 ++-- 14 files changed, 25 insertions(+), 20 deletions(-) diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index 3626b74..688f1a6 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -1,10 +1,10 @@ import { z } from "zod"; -import { z_tipo_coluna_base_dados } from "./variaveis"; +import { z_tipos_dados_registro } from "./variaveis"; export const zp_registrar_base_dados = z.object({ tabela: z.string(), colunas: z.array(z.object({ coluna: z.string(), - tipo: z_tipo_coluna_base_dados, + tipo: z_tipos_dados_registro, })), }); //enviar registros para base de dados @@ -12,6 +12,6 @@ export const zp_enviar_registros = z.object({ tabela: z.string(), registros: z.array(z.record(z.string(), z.object({ valor: z.any(), - tipo: z_tipo_coluna_base_dados.optional().nullable(), + tipo: z_tipos_dados_registro.optional().nullable(), }))), }); diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 4e2ab13..e34bb4a 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -418,6 +418,7 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; + z_tipos_dados_registro: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray; -export declare const z_tipo_coluna_base_dados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; +export declare const z_tipos_dados_registro: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; export declare const operadores_pilao: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; export declare const operadores_permitidos_por_tipo: { - [key in z.infer]: z.infer[]; + [key in z.infer]: z.infer[]; }; export declare const z_validar_colunna_base_dados: { texto: z.ZodNullable; diff --git a/dist-import/pilao-de-dados/variaveis.js b/dist-import/pilao-de-dados/variaveis.js index d5638d0..d7fd163 100644 --- a/dist-import/pilao-de-dados/variaveis.js +++ b/dist-import/pilao-de-dados/variaveis.js @@ -19,7 +19,7 @@ export const zp_produto_conta = z.object({ emDesenvolvimento: z.boolean().optional(), ver_log: z.boolean().optional(), }); -export const z_tipo_coluna_base_dados = z.enum([ +export const z_tipos_dados_registro = z.enum([ "texto", "numero", "confirmacao", diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index 5ed9428..20b8e8d 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -7,7 +7,7 @@ exports.zp_registrar_base_dados = zod_1.z.object({ tabela: zod_1.z.string(), colunas: zod_1.z.array(zod_1.z.object({ coluna: zod_1.z.string(), - tipo: variaveis_1.z_tipo_coluna_base_dados, + tipo: variaveis_1.z_tipos_dados_registro, })), }); //enviar registros para base de dados @@ -15,6 +15,6 @@ exports.zp_enviar_registros = zod_1.z.object({ tabela: zod_1.z.string(), registros: zod_1.z.array(zod_1.z.record(zod_1.z.string(), zod_1.z.object({ valor: zod_1.z.any(), - tipo: variaveis_1.z_tipo_coluna_base_dados.optional().nullable(), + tipo: variaveis_1.z_tipos_dados_registro.optional().nullable(), }))), }); diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 4e2ab13..e34bb4a 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -418,6 +418,7 @@ export declare const pPilao: { tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "lista_mes" | "lista_data" | "mes" | "data"; }[]; }>; + z_tipos_dados_registro: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; zp_enviar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; registros: import("zod").ZodArray; -export declare const z_tipo_coluna_base_dados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; +export declare const z_tipos_dados_registro: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "lista_mes", "lista_data", "mes", "data"]>; export declare const operadores_pilao: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; export declare const operadores_permitidos_por_tipo: { - [key in z.infer]: z.infer[]; + [key in z.infer]: z.infer[]; }; export declare const z_validar_colunna_base_dados: { texto: z.ZodNullable; diff --git a/dist-require/pilao-de-dados/variaveis.js b/dist-require/pilao-de-dados/variaveis.js index 5cc4676..f6386c9 100644 --- a/dist-require/pilao-de-dados/variaveis.js +++ b/dist-require/pilao-de-dados/variaveis.js @@ -1,6 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.urlPilao = exports.z_validar_colunna_base_dados = exports.operadores_permitidos_por_tipo = exports.operadores_pilao = exports.z_tipo_coluna_base_dados = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = exports.zp_deletar_registros = void 0; +exports.urlPilao = exports.z_validar_colunna_base_dados = exports.operadores_permitidos_por_tipo = exports.operadores_pilao = exports.z_tipos_dados_registro = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = exports.zp_deletar_registros = void 0; const p_respostas_1 = require("p-respostas"); const zod_1 = require("zod"); exports.zp_deletar_registros = zod_1.z.object({ @@ -23,7 +23,7 @@ exports.zp_produto_conta = zod_1.z.object({ emDesenvolvimento: zod_1.z.boolean().optional(), ver_log: zod_1.z.boolean().optional(), }); -exports.z_tipo_coluna_base_dados = zod_1.z.enum([ +exports.z_tipos_dados_registro = zod_1.z.enum([ "texto", "numero", "confirmacao", diff --git a/package.json b/package.json index 7e7f301..b573697 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.171.0", + "version": "0.173.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/_enviar_registros.ts b/src/pilao-de-dados/_enviar_registros.ts index 7a44a26..04bd503 100644 --- a/src/pilao-de-dados/_enviar_registros.ts +++ b/src/pilao-de-dados/_enviar_registros.ts @@ -1,12 +1,12 @@ import { z } from "zod" -import { z_tipo_coluna_base_dados } from "./variaveis" +import { z_tipos_dados_registro } from "./variaveis" export const zp_registrar_base_dados = z.object({ tabela: z.string(), colunas: z.array( z.object({ coluna: z.string(), - tipo: z_tipo_coluna_base_dados, + tipo: z_tipos_dados_registro, }), ), }) @@ -19,7 +19,7 @@ export const zp_enviar_registros = z.object({ z.string(), z.object({ valor: z.any(), - tipo: z_tipo_coluna_base_dados.optional().nullable(), + tipo: z_tipos_dados_registro.optional().nullable(), }), ), ), diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 74ef534..b82b560 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -7,6 +7,7 @@ import { operadores_permitidos_por_tipo, operadores_pilao, validarZ, + z_tipos_dados_registro, zp_deletar_registros, zp_produto_conta, } from "./variaveis" @@ -21,7 +22,7 @@ import { extruturas_de_campos, visoes } from "./visoes" export const pPilao = { zp_deletar_registros, zp_registrar_base_dados, - + z_tipos_dados_registro, zp_enviar_registros, zp_produto_conta, diff --git a/src/pilao-de-dados/variaveis.ts b/src/pilao-de-dados/variaveis.ts index 83d6ab4..7462537 100644 --- a/src/pilao-de-dados/variaveis.ts +++ b/src/pilao-de-dados/variaveis.ts @@ -32,7 +32,7 @@ export const zp_produto_conta = z.object({ ver_log: z.boolean().optional(), }) -export const z_tipo_coluna_base_dados = z.enum([ +export const z_tipos_dados_registro = z.enum([ "texto", "numero", "confirmacao", @@ -47,7 +47,7 @@ export const z_tipo_coluna_base_dados = z.enum([ export const operadores_pilao = z.enum(["=", "!=", ">", "<", ">=", "<=", "∩"]) export const operadores_permitidos_por_tipo: { - [key in z.infer]: z.infer< + [key in z.infer]: z.infer< typeof operadores_pilao >[] } = { From fea1b3d96c0781b58f212ce004c1f3e6d5dba4e1 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Thu, 3 Oct 2024 12:04:01 -0300 Subject: [PATCH 21/24] =?UTF-8?q?Refatorado=20estrutura=20de=20vis=C3=B5es?= =?UTF-8?q?=20de=20gr=C3=A1ficos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist-import/pilao-de-dados/Pilao/index.d.ts | 8 +- dist-import/pilao-de-dados/Pilao/tipagem.d.ts | 6 +- dist-import/pilao-de-dados/index.d.ts | 225 +----------- dist-import/pilao-de-dados/index.js | 7 +- .../visoes/estrutura_de_campos/index.d.ts | 6 + .../visoes/estrutura_de_campos/index.js | 11 + .../z_contagem_em_barra_vertical.d.ts | 3 + .../z_contagem_em_barra_vertical.js | 37 ++ .../z_contagem_em_pizza.d.ts | 3 + .../z_contagem_em_pizza.js | 26 ++ .../z_soma_em_barra_vertical.d.ts | 3 + .../z_soma_em_barra_vertical.js | 42 +++ .../visoes/estrutura_de_campos/z_tabela.d.ts | 3 + .../visoes/estrutura_de_campos/z_tabela.js | 36 ++ dist-import/pilao-de-dados/visoes/index.d.ts | 345 +----------------- dist-import/pilao-de-dados/visoes/index.js | 183 +--------- .../pilao-de-dados/visoes/listaDeVisoes.d.ts | 321 ++++++++++++++++ .../pilao-de-dados/visoes/listaDeVisoes.js | 37 ++ .../pilao-de-dados/visoes/tipagem.d.ts | 21 ++ dist-import/pilao-de-dados/visoes/tipagem.js | 9 + dist-require/pilao-de-dados/Pilao/index.d.ts | 8 +- .../pilao-de-dados/Pilao/tipagem.d.ts | 6 +- dist-require/pilao-de-dados/index.d.ts | 225 +----------- dist-require/pilao-de-dados/index.js | 5 +- .../visoes/estrutura_de_campos/index.d.ts | 6 + .../visoes/estrutura_de_campos/index.js | 14 + .../z_contagem_em_barra_vertical.d.ts | 3 + .../z_contagem_em_barra_vertical.js | 40 ++ .../z_contagem_em_pizza.d.ts | 3 + .../z_contagem_em_pizza.js | 29 ++ .../z_soma_em_barra_vertical.d.ts | 3 + .../z_soma_em_barra_vertical.js | 45 +++ .../visoes/estrutura_de_campos/z_tabela.d.ts | 3 + .../visoes/estrutura_de_campos/z_tabela.js | 39 ++ dist-require/pilao-de-dados/visoes/index.d.ts | 345 +----------------- dist-require/pilao-de-dados/visoes/index.js | 198 +--------- .../pilao-de-dados/visoes/listaDeVisoes.d.ts | 321 ++++++++++++++++ .../pilao-de-dados/visoes/listaDeVisoes.js | 40 ++ .../pilao-de-dados/visoes/tipagem.d.ts | 21 ++ dist-require/pilao-de-dados/visoes/tipagem.js | 12 + package.json | 2 +- src/pilao-de-dados/Pilao/index.ts | 11 +- src/pilao-de-dados/Pilao/tipagem.ts | 6 +- src/pilao-de-dados/index.ts | 7 +- .../visoes/estrutura_de_campos/index.ts | 16 + .../z_contagem_em_barra_vertical.ts | 56 +++ .../z_contagem_em_pizza.ts | 36 ++ .../z_soma_em_barra_vertical.ts | 62 ++++ .../visoes/estrutura_de_campos/z_tabela.ts | 45 +++ src/pilao-de-dados/visoes/index.ts | 254 +------------ src/pilao-de-dados/visoes/listaDeVisoes.ts | 42 +++ src/pilao-de-dados/visoes/tipagem.ts | 31 ++ 52 files changed, 1489 insertions(+), 1777 deletions(-) create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/index.js create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js create mode 100644 dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/listaDeVisoes.js create mode 100644 dist-import/pilao-de-dados/visoes/tipagem.d.ts create mode 100644 dist-import/pilao-de-dados/visoes/tipagem.js create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/index.js create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.js create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.js create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.js create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.js create mode 100644 dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/listaDeVisoes.js create mode 100644 dist-require/pilao-de-dados/visoes/tipagem.d.ts create mode 100644 dist-require/pilao-de-dados/visoes/tipagem.js create mode 100644 src/pilao-de-dados/visoes/estrutura_de_campos/index.ts create mode 100644 src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_barra_vertical.ts create mode 100644 src/pilao-de-dados/visoes/estrutura_de_campos/z_contagem_em_pizza.ts create mode 100644 src/pilao-de-dados/visoes/estrutura_de_campos/z_soma_em_barra_vertical.ts create mode 100644 src/pilao-de-dados/visoes/estrutura_de_campos/z_tabela.ts create mode 100644 src/pilao-de-dados/visoes/listaDeVisoes.ts create mode 100644 src/pilao-de-dados/visoes/tipagem.ts 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 + } + } + } From eed4f248f3f930257120c416756aab0f721cf51f Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Thu, 3 Oct 2024 12:17:05 -0300 Subject: [PATCH 22/24] unidade de soma --- dist-import/pilao-de-dados/index.d.ts | 6 ++++++ .../estrutura_de_campos/z_soma_em_barra_vertical.js | 11 ++++++++--- dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts | 6 ++++++ dist-import/pilao-de-dados/visoes/listaDeVisoes.js | 1 + dist-require/pilao-de-dados/index.d.ts | 6 ++++++ .../estrutura_de_campos/z_soma_em_barra_vertical.js | 11 ++++++++--- .../pilao-de-dados/visoes/listaDeVisoes.d.ts | 6 ++++++ dist-require/pilao-de-dados/visoes/listaDeVisoes.js | 1 + package.json | 2 +- .../estrutura_de_campos/z_soma_em_barra_vertical.ts | 12 +++++++++--- src/pilao-de-dados/visoes/listaDeVisoes.ts | 1 + 11 files changed, 53 insertions(+), 10 deletions(-) diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 9c8d686..398076e 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -130,6 +130,7 @@ export declare const pPilao: { tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; colunaSoma: import("zod").ZodString; + unidadeSoma: import("zod").ZodOptional; colunaAgrupamento: import("zod").ZodOptional>; filtros: import("zod").ZodOptional; zp_deletar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -393,6 +396,7 @@ export declare const pPilao: { tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; colunaSoma: import("zod").ZodString; + unidadeSoma: import("zod").ZodOptional; colunaAgrupamento: import("zod").ZodOptional>; filtros: import("zod").ZodOptional; }; }; 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 index 38113c6..9ec4907 100644 --- 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 @@ -22,20 +22,25 @@ export const z_soma_em_barra_vertical = { tipo_campo: "coluna", order: 2, }, + unidadeSoma: { + rotulo: "Unidade de Somatória", + tipo_campo: "texto", + order: 3, + }, colanuEixoX: { rotulo: "Coluna do Eixo X", tipo_campo: "coluna", - order: 3, + order: 4, }, colunaAgrupamento: { rotulo: "Colunas de Agrupamento", tipo_campo: "lista_colunas", - order: 4, + order: 5, }, descricao_pelo_usuario: { rotulo: "Descrição (opcional)", tipo_campo: "texto", - order: 5, + order: 6, }, filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, }, diff --git a/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts b/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts index 31bc50e..5419ff9 100644 --- a/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts +++ b/dist-import/pilao-de-dados/visoes/listaDeVisoes.d.ts @@ -42,6 +42,7 @@ export declare const z_soma_em_barra_vertical: z.ZodObject<{ tabela: z.ZodString; colanuEixoX: z.ZodString; colunaSoma: z.ZodString; + unidadeSoma: z.ZodOptional; colunaAgrupamento: z.ZodOptional>; filtros: z.ZodOptional; export declare const z_contagem_em_pizza: z.ZodObject<{ tabela: z.ZodString; @@ -280,6 +283,7 @@ export declare const visoes_pilao: { tabela: z.ZodString; colanuEixoX: z.ZodString; colunaSoma: z.ZodString; + unidadeSoma: z.ZodOptional; colunaAgrupamento: z.ZodOptional>; filtros: z.ZodOptional; }; diff --git a/dist-import/pilao-de-dados/visoes/listaDeVisoes.js b/dist-import/pilao-de-dados/visoes/listaDeVisoes.js index cde2085..84130a5 100644 --- a/dist-import/pilao-de-dados/visoes/listaDeVisoes.js +++ b/dist-import/pilao-de-dados/visoes/listaDeVisoes.js @@ -11,6 +11,7 @@ export const z_soma_em_barra_vertical = z.object({ tabela: z.string(), colanuEixoX: z.string(), colunaSoma: z.string(), + unidadeSoma: z.string().optional(), colunaAgrupamento: z.string().array().optional(), filtros: z_filtro.array().optional(), descricao_pelo_usuario: z.string().optional(), diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 9c8d686..398076e 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -130,6 +130,7 @@ export declare const pPilao: { tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; colunaSoma: import("zod").ZodString; + unidadeSoma: import("zod").ZodOptional; colunaAgrupamento: import("zod").ZodOptional>; filtros: import("zod").ZodOptional; zp_deletar_registros: import("zod").ZodObject<{ tabela: import("zod").ZodString; @@ -393,6 +396,7 @@ export declare const pPilao: { tabela: import("zod").ZodString; colanuEixoX: import("zod").ZodString; colunaSoma: import("zod").ZodString; + unidadeSoma: import("zod").ZodOptional; colunaAgrupamento: import("zod").ZodOptional>; filtros: import("zod").ZodOptional; }; }; 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 index 67001be..1ec8b6b 100644 --- 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 @@ -25,20 +25,25 @@ exports.z_soma_em_barra_vertical = { tipo_campo: "coluna", order: 2, }, + unidadeSoma: { + rotulo: "Unidade de Somatória", + tipo_campo: "texto", + order: 3, + }, colanuEixoX: { rotulo: "Coluna do Eixo X", tipo_campo: "coluna", - order: 3, + order: 4, }, colunaAgrupamento: { rotulo: "Colunas de Agrupamento", tipo_campo: "lista_colunas", - order: 4, + order: 5, }, descricao_pelo_usuario: { rotulo: "Descrição (opcional)", tipo_campo: "texto", - order: 5, + order: 6, }, filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, }, diff --git a/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts b/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts index 31bc50e..5419ff9 100644 --- a/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts +++ b/dist-require/pilao-de-dados/visoes/listaDeVisoes.d.ts @@ -42,6 +42,7 @@ export declare const z_soma_em_barra_vertical: z.ZodObject<{ tabela: z.ZodString; colanuEixoX: z.ZodString; colunaSoma: z.ZodString; + unidadeSoma: z.ZodOptional; colunaAgrupamento: z.ZodOptional>; filtros: z.ZodOptional; export declare const z_contagem_em_pizza: z.ZodObject<{ tabela: z.ZodString; @@ -280,6 +283,7 @@ export declare const visoes_pilao: { tabela: z.ZodString; colanuEixoX: z.ZodString; colunaSoma: z.ZodString; + unidadeSoma: z.ZodOptional; colunaAgrupamento: z.ZodOptional>; filtros: z.ZodOptional; }; diff --git a/dist-require/pilao-de-dados/visoes/listaDeVisoes.js b/dist-require/pilao-de-dados/visoes/listaDeVisoes.js index 8caa9b8..e194d93 100644 --- a/dist-require/pilao-de-dados/visoes/listaDeVisoes.js +++ b/dist-require/pilao-de-dados/visoes/listaDeVisoes.js @@ -14,6 +14,7 @@ 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(), + unidadeSoma: zod_1.z.string().optional(), colunaAgrupamento: zod_1.z.string().array().optional(), filtros: _serie_consultar_1.z_filtro.array().optional(), descricao_pelo_usuario: zod_1.z.string().optional(), diff --git a/package.json b/package.json index 395cc7c..dc417f8 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.176.0", + "version": "0.177.0", "description": "", "main": "src/index.ts", "exports": { 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 index dca5661..72fd236 100644 --- 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 @@ -42,20 +42,26 @@ export const z_soma_em_barra_vertical: tipo_estrutura_visao_grafico<"z_soma_em_b order: 2, }, + unidadeSoma: { + rotulo: "Unidade de Somatória", + tipo_campo: "texto", + order: 3, + }, + colanuEixoX: { rotulo: "Coluna do Eixo X", tipo_campo: "coluna", - order: 3, + order: 4, }, colunaAgrupamento: { rotulo: "Colunas de Agrupamento", tipo_campo: "lista_colunas", - order: 4, + order: 5, }, descricao_pelo_usuario: { rotulo: "Descrição (opcional)", tipo_campo: "texto", - order: 5, + order: 6, }, filtros: { rotulo: "Filtros", tipo_campo: "lista_filtros", order: 5 }, }, diff --git a/src/pilao-de-dados/visoes/listaDeVisoes.ts b/src/pilao-de-dados/visoes/listaDeVisoes.ts index 9b8c857..10e525f 100644 --- a/src/pilao-de-dados/visoes/listaDeVisoes.ts +++ b/src/pilao-de-dados/visoes/listaDeVisoes.ts @@ -13,6 +13,7 @@ export const z_soma_em_barra_vertical = z.object({ tabela: z.string(), colanuEixoX: z.string(), colunaSoma: z.string(), + unidadeSoma: z.string().optional(), colunaAgrupamento: z.string().array().optional(), filtros: z_filtro.array().optional(), descricao_pelo_usuario: z.string().optional(), From 02c647a9dd8f8c39cb89b0584425329ecd8c7ad7 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Thu, 3 Oct 2024 12:42:22 -0300 Subject: [PATCH 23/24] build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index dc417f8..206a169 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.177.0", + "version": "0.178.0", "description": "", "main": "src/index.ts", "exports": { From 093ec6bef0d67c6efa7c106f10dd8b1462edd359 Mon Sep 17 00:00:00 2001 From: Luiz Silva Date: Thu, 17 Oct 2024 13:19:37 -0300 Subject: [PATCH 24/24] build --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 206a169..9acfb0c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.178.0", + "version": "0.180.0", "description": "", "main": "src/index.ts", "exports": { @@ -11,7 +11,7 @@ } }, "scripts": { - "postinstall": "pnpm up p-*", + "at": "pnpm up p-*", "build-back": "rm -fr dist-require && tsc -p ./tsconfig-require.json", "build-front": "rm -fr dist-import && tsc -p ./tsconfig-import.json", "build": "pnpm run biome && npm --no-git-tag-version version minor && pnpm run build-back && pnpm run build-front",