z_validar_colunna_base_dados

This commit is contained in:
Luiz H. R. Silva 2024-06-18 14:23:18 -03:00
parent 4d5de45443
commit f6f39d2d86
21 changed files with 221 additions and 300 deletions

View file

@ -12,9 +12,9 @@ export declare const zp_produto_conta: z.ZodObject<{
produto: string;
conta: string;
}>;
export declare const tiposColunasBasedados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
export declare const z_tipo_coluna_base_dados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
export declare const tiposSeriesAgregacoes: z.ZodEnum<["contagem", "somatoria"]>;
export declare const validarColuna: {
export declare const z_validar_colunna_base_dados: {
texto: z.ZodNullable<z.ZodString>;
numero: z.ZodNullable<z.ZodNumber>;
confirmacao: z.ZodNullable<z.ZodBoolean>;

View file

@ -14,7 +14,7 @@ export const zp_produto_conta = z.object({
produto: z.string(),
conta: z.string(),
});
export const tiposColunasBasedados = z.enum([
export const z_tipo_coluna_base_dados = z.enum([
"texto",
"numero",
"confirmacao",
@ -22,7 +22,7 @@ export const tiposColunasBasedados = z.enum([
"lista_numero",
]);
export const tiposSeriesAgregacoes = z.enum(["contagem", "somatoria"]);
export const validarColuna = {
export const z_validar_colunna_base_dados = {
texto: z.string().nullable(),
numero: z.number().nullable(),
confirmacao: z.boolean().nullable(),

View file

@ -1,15 +1,60 @@
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<{
export declare const zp_registrar_base_dados: z.ZodObject<{
tabela: z.ZodString;
registros: z.ZodArray<z.ZodAny, "many">;
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;
registros: any[];
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}, {
tabela: string;
registros: any[];
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
}[];
}>;
export declare const zp_enviar_registros: z.ZodObject<{
tabela: z.ZodString;
registros: z.ZodArray<z.ZodObject<{
coluna: z.ZodString;
valor: z.ZodAny;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
}, "strip", z.ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
registros: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}[];
}, {
tabela: string;
registros: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}[];
}>;
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
emDesenvolvimento?: boolean | undefined | null;

View file

@ -9,11 +9,22 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
import { respostaComuns } from "p-respostas";
import { z } from "zod";
import { PREFIXO, baseUrlPilao } from "./_variaveis";
import { PREFIXO, baseUrlPilao, z_tipo_coluna_base_dados, } 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,
})),
});
//enviar registros para base de dados
export const zp_enviar_registros = z.object({
tabela: z.string(),
registros: z.array(z.any()),
registros: z.array(z.object({
coluna: z.string(),
valor: z.any(),
tipo: z_tipo_coluna_base_dados,
})),
});
export const enviar_registros = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);

View file

@ -1,20 +1,6 @@
import { tiposSeriesAgregacoes } from "./_variaveis";
export { tiposSeriesAgregacoes };
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<{
@ -48,18 +34,42 @@ export declare const pPilao: {
};
parametros: {
tabela: string;
registros: any[];
registros: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: 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">;
registros: import("zod").ZodArray<import("zod").ZodObject<{
coluna: import("zod").ZodString;
valor: import("zod").ZodAny;
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";
valor?: any;
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
registros: any[];
registros: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}[];
}, {
tabela: string;
registros: any[];
registros: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
valor?: any;
}[];
}>;
serie_registrar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
emDesenvolvimento?: boolean | null | undefined;

View file

@ -1,12 +1,10 @@
import { tiposSeriesAgregacoes, validarZ, zp_produto_conta } from "./_variaveis";
import { deletar_registros, zp_deletar_registros } from "./deletar_registros";
import { enviar_registros, zp_enviar_registros } from "./enviar_registros";
import { registrar_base_dados, zp_registrar_base_dados, } from "./registrar_base_dados";
import { enviar_registros, zp_enviar_registros, zp_registrar_base_dados, } from "./enviar_registros";
import { serie_consultar, zp_serie_consultar } from "./serie_consultar";
import { serie_registrar, zp_serie_registrar } from "./serie_registrar";
export { tiposSeriesAgregacoes };
export const pPilao = {
registrar_base_dados,
zp_registrar_base_dados,
enviar_registros,
zp_enviar_registros,

View file

@ -1,36 +0,0 @@
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

@ -1,32 +0,0 @@
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, baseUrlPilao, tiposColunasBasedados, } from "./_variaveis";
/** Faz o registro de uma nova base de dados configurado a estrutura de colunas */
export const zp_registrar_base_dados = z.object({
tabela: z.string(),
colunas: z.array(z.object({
coluna: z.string(),
tipo: tiposColunasBasedados,
})),
});
export const registrar_base_dados = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { colunas, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${`${PREFIXO}/${Object.keys({ registrar_base_dados })[0]}/${produto}/${conta}`}`);
const resp = yield fetch(url.toString(), {
method: "POST",
body: JSON.stringify({ tabela, colunas }),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
.then((r) => r);
return resp;
});