implementado drive pilão de dados

This commit is contained in:
Luiz H. R. Silva 2024-06-14 12:30:08 -03:00
parent a1e543cfb8
commit daae40f4b2
54 changed files with 1476 additions and 19 deletions

View file

@ -1,9 +1,11 @@
import { type tipoResposta } from "p-respostas";
import type { z } from "zod";
import type { zAmbiente } from "../ts/ambiente";
type tipoPostCodigoContaSite = {
site: string;
};
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
ambiente: "desenvolvimento" | "producao";
ambiente: z.infer<typeof zAmbiente>;
post: tipoPostCodigoContaSite;
/** função que conecta com a API */
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;

View file

@ -1 +1,3 @@
export declare const urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
import type { z } from "zod";
import type { zAmbiente } from "../ts/ambiente";
export declare const urlAutenticacao: (ambiente: z.infer<typeof zAmbiente>) => string;

View file

@ -1,4 +1,6 @@
import { type tipoResposta } from "p-respostas";
import type { z } from "zod";
import type { zAmbiente } from "../ts/ambiente";
export type tipoUsuarioExterno = {
nome: string;
email: string;
@ -8,7 +10,7 @@ export type tipoUsuarioExterno = {
chave_produto: string;
};
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
ambiente: "desenvolvimento" | "producao";
ambiente: z.infer<typeof zAmbiente>;
token_produto: string;
buscar: (url: string, headers: {
[k: string]: string;

View file

@ -2,9 +2,11 @@ import type { tipoResposta } from "p-respostas";
type tipoPostValidarTokem = {
token: string;
};
import type { z } from "zod";
import type { zAmbiente } from "../ts/ambiente";
/** faz a validação do token */
export declare const validarToken: ({ ambiente, post, buscar, }: {
ambiente: "desenvolvimento" | "producao";
ambiente: z.infer<typeof zAmbiente>;
post: tipoPostValidarTokem;
/** função que conecta com a API */
buscar: (url: string, post: tipoPostValidarTokem) => Promise<tipoResposta<any>>;

View file

@ -1,3 +1,4 @@
export * from "./tokenQuipo";
export * from "./autenticacao";
export * from "./produtos";
export * from "./pilao-de-dados";

View file

@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./tokenQuipo"), exports);
__exportStar(require("./autenticacao"), exports);
__exportStar(require("./produtos"), exports);
__exportStar(require("./pilao-de-dados"), exports);

View file

@ -0,0 +1,22 @@
import { z } from "zod";
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;
export declare const PREFIXO = "/pilao-de-dados";
export declare const validarZ: <T>(zodType: z.ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
export declare const zp_produto_conta: z.ZodObject<{
produto: z.ZodString;
conta: z.ZodString;
}, "strip", z.ZodTypeAny, {
produto: string;
conta: string;
}, {
produto: string;
conta: string;
}>;
export declare const tiposColunas: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
export declare const validarColuna: {
texto: z.ZodNullable<z.ZodString>;
numero: z.ZodNullable<z.ZodNumber>;
confirmacao: z.ZodNullable<z.ZodBoolean>;
lista_texto: z.ZodNullable<z.ZodArray<z.ZodString, "many">>;
lista_numero: z.ZodNullable<z.ZodArray<z.ZodNumber, "many">>;
};

View file

@ -0,0 +1,34 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.validarColuna = exports.tiposColunas = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO = exports.zAmbiente = void 0;
var p_respostas_1 = require("p-respostas");
var zod_1 = require("zod");
exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]);
exports.PREFIXO = "/pilao-de-dados";
var validarZ = function (zodType, objeto, mensagem) {
var validar = zodType.safeParse(objeto);
if (!validar.success) {
debugger;
return p_respostas_1.respostaComuns.erro(mensagem, validar.error.errors.map(function (e) { return "".concat(e.path, " ").concat(e.message); }));
}
return p_respostas_1.respostaComuns.valor(validar.data);
};
exports.validarZ = validarZ;
exports.zp_produto_conta = zod_1.z.object({
produto: zod_1.z.string(),
conta: zod_1.z.string(),
});
exports.tiposColunas = zod_1.z.enum([
"texto",
"numero",
"confirmacao",
"lista_texto",
"lista_numero",
]);
exports.validarColuna = {
texto: zod_1.z.string().nullable(),
numero: zod_1.z.number().nullable(),
confirmacao: zod_1.z.boolean().nullable(),
lista_texto: zod_1.z.array(zod_1.z.string()).nullable(),
lista_numero: zod_1.z.array(zod_1.z.number()).nullable(),
};

View file

@ -0,0 +1,24 @@
import type { tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
import type { zp_registrar_serie } from "./registrar_serie";
export declare const zp_consultar_serie: z.ZodObject<{
identificador: z.ZodString;
}, "strip", z.ZodTypeAny, {
identificador: string;
}, {
identificador: string;
}>;
export declare const consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
parametros: z.infer<typeof zp_consultar_serie>;
}) => {
dados: () => Promise<tipoResposta<{
registros: any[];
legenda: string;
serie: z.infer<typeof zp_registrar_serie>;
}>>;
url: () => string;
};

View file

@ -0,0 +1,89 @@
"use strict";
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.consultar_serie = exports.zp_consultar_serie = void 0;
var p_respostas_1 = require("p-respostas");
var zod_1 = require("zod");
var _variaveis_1 = require("./_variaveis");
//consultar compilação
exports.zp_consultar_serie = zod_1.z.object({
identificador: zod_1.z.string(),
});
var consultar_serie = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, identificador = _a.parametros.identificador, _b = _a.cliente, conta = _b.conta, produto = _b.produto;
var dados = function () { return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
url = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5080"
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/consultar-serie/").concat(produto, "/").concat(conta)));
return [4 /*yield*/, fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
identificador: identificador,
}),
headers: { "Content-Type": "application/json" },
})
.then(function (r) { return r.json(); })
.catch(function (e) {
return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]);
})
.then(function (r) { return r; })];
case 1:
resp = _a.sent();
return [2 /*return*/, resp];
}
});
}); };
var url = function () {
var vUrl = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5081"
: "https://carro-de-boi.idz.one").concat(_variaveis_1.PREFIXO, "/grafico"));
vUrl.searchParams.append("produto", produto);
vUrl.searchParams.append("conta", conta);
vUrl.searchParams.append("identificador", identificador);
return vUrl.href;
};
return {
dados: dados,
url: url,
};
};
exports.consultar_serie = consultar_serie;

View file

@ -0,0 +1,20 @@
import type { tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
export declare const zp_enviar_registros: z.ZodObject<{
tabela: z.ZodString;
registros: z.ZodArray<z.ZodAny, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
registros: any[];
}, {
tabela: string;
registros: any[];
}>;
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
/** Parametros da função */
parametros: z.infer<typeof zp_enviar_registros>;
}) => Promise<tipoResposta<true>>;

View file

@ -0,0 +1,73 @@
"use strict";
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.enviar_registros = exports.zp_enviar_registros = void 0;
var p_respostas_1 = require("p-respostas");
var zod_1 = require("zod");
var _variaveis_1 = require("./_variaveis");
//enviar registros para base de dados
exports.zp_enviar_registros = zod_1.z.object({
tabela: zod_1.z.string(),
registros: zod_1.z.array(zod_1.z.any()),
});
var enviar_registros = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, registros = _c.registros, tabela = _c.tabela;
return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
url = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5080"
: "https://carro-de-boi.idz.one").concat(_variaveis_1.PREFIXO, "/enviar-registro/").concat(produto, "/").concat(conta));
return [4 /*yield*/, fetch(url.toString(), {
method: "POST",
body: JSON.stringify({ tabela: tabela, registros: registros }),
headers: { "Content-Type": "application/json" },
})
.then(function (r) { return r.json(); })
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
.then(function (r) { return r; })];
case 1:
resp = _d.sent();
return [2 /*return*/, resp];
}
});
});
};
exports.enviar_registros = enviar_registros;

138
dist-require/pilao-de-dados/index.d.ts vendored Normal file
View file

@ -0,0 +1,138 @@
import { tiposColunas } from "./_variaveis";
export { tiposColunas };
export declare const pPilao: {
registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
zp_registrar_base_dados: import("zod").ZodObject<{
tabela: import("zod").ZodString;
colunas: import("zod").ZodArray<import("zod").ZodObject<{
coluna: import("zod").ZodString;
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
}, "strip", import("zod").ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}>;
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
tabela: string;
registros: any[];
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
zp_enviar_registros: import("zod").ZodObject<{
tabela: import("zod").ZodString;
registros: import("zod").ZodArray<import("zod").ZodAny, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
registros: any[];
}, {
tabela: string;
registros: any[];
}>;
registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
zp_registrar_serie: import("zod").ZodObject<{
tabela: import("zod").ZodString;
identificador: import("zod").ZodString;
colanuEixoX: import("zod").ZodString;
colunaAgrupamento: import("zod").ZodString;
agregacao: import("zod").ZodEnum<["contagem"]>;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
}, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
}>;
consultar_serie: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
identificador: string;
};
}) => {
dados: () => Promise<import("p-respostas").tipoResposta<{
registros: any[];
legenda: string;
serie: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
};
}>>;
url: () => string;
};
zp_consultar_serie: import("zod").ZodObject<{
identificador: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
identificador: string;
}, {
identificador: string;
}>;
zp_produto_conta: import("zod").ZodObject<{
produto: import("zod").ZodString;
conta: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
produto: string;
conta: string;
}, {
produto: string;
conta: string;
}>;
validarZ: <T>(zodType: import("zod").ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
};

View file

@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.pPilao = exports.tiposColunas = void 0;
var _variaveis_1 = require("./_variaveis");
Object.defineProperty(exports, "tiposColunas", { enumerable: true, get: function () { return _variaveis_1.tiposColunas; } });
var consultar_serie_1 = require("./consultar_serie");
var enviar_registros_1 = require("./enviar_registros");
var registrar_base_dados_1 = require("./registrar_base_dados");
var registrar_serie_1 = require("./registrar_serie");
exports.pPilao = {
registrar_base_dados: registrar_base_dados_1.registrar_base_dados,
zp_registrar_base_dados: registrar_base_dados_1.zp_registrar_base_dados,
enviar_registros: enviar_registros_1.enviar_registros,
zp_enviar_registros: enviar_registros_1.zp_enviar_registros,
registrar_serie: registrar_serie_1.registrar_serie,
zp_registrar_serie: registrar_serie_1.zp_registrar_serie,
consultar_serie: consultar_serie_1.consultar_serie,
zp_consultar_serie: consultar_serie_1.zp_consultar_serie,
zp_produto_conta: _variaveis_1.zp_produto_conta,
validarZ: _variaveis_1.validarZ,
};

View file

@ -0,0 +1,36 @@
import type { tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
export declare const zp_registrar_base_dados: z.ZodObject<{
tabela: z.ZodString;
colunas: z.ZodArray<z.ZodObject<{
coluna: z.ZodString;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
}, "strip", z.ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}>;
export declare const registrar_base_dados: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
/** parametros da função */
parametros: z.infer<typeof zp_registrar_base_dados>;
}) => Promise<tipoResposta<true>>;

View file

@ -0,0 +1,76 @@
"use strict";
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registrar_base_dados = exports.zp_registrar_base_dados = void 0;
var p_respostas_1 = require("p-respostas");
var zod_1 = require("zod");
var _variaveis_1 = require("./_variaveis");
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
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.tiposColunas,
})),
});
var registrar_base_dados = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, colunas = _c.colunas, tabela = _c.tabela;
return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
url = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5080"
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/registar-base-dados/").concat(produto, "/").concat(conta)));
return [4 /*yield*/, fetch(url.toString(), {
method: "POST",
body: JSON.stringify({ tabela: tabela, colunas: colunas }),
headers: { "Content-Type": "application/json" },
})
.then(function (r) { return r.json(); })
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
.then(function (r) { return r; })];
case 1:
resp = _d.sent();
return [2 /*return*/, resp];
}
});
});
};
exports.registrar_base_dados = registrar_base_dados;

View file

@ -0,0 +1,29 @@
import { type tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
export declare const zp_registrar_serie: z.ZodObject<{
tabela: z.ZodString;
identificador: z.ZodString;
colanuEixoX: z.ZodString;
colunaAgrupamento: z.ZodString;
agregacao: z.ZodEnum<["contagem"]>;
}, "strip", z.ZodTypeAny, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
}, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem";
}>;
export declare const registrar_serie: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
/** Parametros da função */
parametros: z.infer<typeof zp_registrar_serie>;
}) => Promise<tipoResposta<true>>;

View file

@ -0,0 +1,83 @@
"use strict";
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());
});
};
var __generator = (this && this.__generator) || function (thisArg, body) {
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
function verb(n) { return function (v) { return step([n, v]); }; }
function step(op) {
if (f) throw new TypeError("Generator is already executing.");
while (g && (g = 0, op[0] && (_ = 0)), _) try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
if (y = 0, t) op = [op[0] & 2, t.value];
switch (op[0]) {
case 0: case 1: t = op; break;
case 4: _.label++; return { value: op[1], done: false };
case 5: _.label++; y = op[1]; op = [0]; continue;
case 7: op = _.ops.pop(); _.trys.pop(); continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
if (t[2]) _.ops.pop();
_.trys.pop(); continue;
}
op = body.call(thisArg, _);
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
}
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.registrar_serie = exports.zp_registrar_serie = void 0;
var p_respostas_1 = require("p-respostas");
var zod_1 = require("zod");
var _variaveis_1 = require("./_variaveis");
//registrar serie
exports.zp_registrar_serie = zod_1.z.object({
tabela: zod_1.z.string(),
identificador: zod_1.z.string(),
colanuEixoX: zod_1.z.string(),
colunaAgrupamento: zod_1.z.string(),
agregacao: zod_1.z.enum(["contagem"]),
});
var registrar_serie = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, agregacao = _c.agregacao, colanuEixoX = _c.colanuEixoX, colunaAgrupamento = _c.colunaAgrupamento, identificador = _c.identificador, tabela = _c.tabela;
return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
url = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5080"
: "https://carro-de-boi.idz.one").concat("".concat(_variaveis_1.PREFIXO, "/registar-serie/").concat(produto, "/").concat(conta)));
return [4 /*yield*/, fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
tabela: tabela,
agregacao: agregacao,
emDesenvolvimento: emDesenvolvimento,
colanuEixoX: colanuEixoX,
colunaAgrupamento: colunaAgrupamento,
identificador: identificador,
}),
headers: { "Content-Type": "application/json" },
})
.then(function (r) { return r.json(); })
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
.then(function (r) { return r; })];
case 1:
resp = _d.sent();
return [2 /*return*/, resp];
}
});
});
};
exports.registrar_serie = registrar_serie;

2
dist-require/ts/ambiente.d.ts vendored Normal file
View file

@ -0,0 +1,2 @@
import { z } from "zod";
export declare const zAmbiente: z.ZodEnum<["desenvolvimento", "producao"]>;

View file

@ -0,0 +1,5 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.zAmbiente = void 0;
var zod_1 = require("zod");
exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]);