refatoração do drive de pilão de dados
This commit is contained in:
parent
1ee3565d3d
commit
f6c203ee3e
31 changed files with 887 additions and 554 deletions
|
|
@ -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,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue