melhorias de tipagem
This commit is contained in:
parent
1d5d3a48b4
commit
afa28a0699
32 changed files with 435 additions and 486 deletions
48
dist-import/pilao-de-dados/_serie_consultar.js
Normal file
48
dist-import/pilao-de-dados/_serie_consultar.js
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
import node_fetch from "cross-fetch";
|
||||
import { respostaComuns } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { PREFIXO, baseUrlPilao, tiposSeriesAgregacoes, } from "./variaveis";
|
||||
export const zp_serie_registrar = z.object({
|
||||
tabela: z.string(),
|
||||
colanuEixoX: z.string(),
|
||||
colunaAgrupamento: z.string().array().optional(),
|
||||
agregacao: tiposSeriesAgregacoes,
|
||||
});
|
||||
export const serie_consultar = (cliente) => (parametros) => {
|
||||
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const url = new URL(`${baseUrlPilao(cliente.emDesenvolvimento)}${`${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`}`);
|
||||
const resp = yield 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);
|
||||
return resp;
|
||||
});
|
||||
const url = () => {
|
||||
const pr = {
|
||||
cliente,
|
||||
parametros,
|
||||
};
|
||||
const vUrl = new URL(`${cliente.emDesenvolvimento
|
||||
? "http://127.0.0.1:5081"
|
||||
: "https://carro-de-boi.idz.one"}${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}`);
|
||||
const serie = encodeURIComponent(JSON.stringify(pr, null, 2));
|
||||
return `${vUrl.href}?serie=${serie}`;
|
||||
};
|
||||
return {
|
||||
dados,
|
||||
url,
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue