41 lines
1.9 KiB
JavaScript
41 lines
1.9 KiB
JavaScript
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 { respostaComuns } from "p-respostas";
|
|
import { z } from "zod";
|
|
import { PREFIXO, tiposSeriesAgregacoes, } from "./_variaveis";
|
|
//registrar serie
|
|
export const zp_registrar_serie = z.object({
|
|
tabela: z.string(),
|
|
identificador: z.string(),
|
|
colanuEixoX: z.string(),
|
|
colunaAgrupamento: z.string(),
|
|
agregacao: tiposSeriesAgregacoes,
|
|
});
|
|
export const registrar_serie = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const url = new URL(`${emDesenvolvimento
|
|
? "http://127.0.0.1:5080"
|
|
: "https://carro-de-boi.idz.one"}${`${PREFIXO}/registar-serie/${produto}/${conta}`}`);
|
|
const resp = yield fetch(url.toString(), {
|
|
method: "POST",
|
|
body: JSON.stringify({
|
|
tabela,
|
|
agregacao,
|
|
emDesenvolvimento,
|
|
colanuEixoX,
|
|
colunaAgrupamento,
|
|
identificador,
|
|
}),
|
|
headers: { "Content-Type": "application/json" },
|
|
})
|
|
.then((r) => r.json())
|
|
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
|
.then((r) => r);
|
|
return resp;
|
|
});
|