melhorias de tipagem
This commit is contained in:
parent
1d5d3a48b4
commit
afa28a0699
32 changed files with 435 additions and 486 deletions
14
dist-import/pilao-de-dados/_deletar_registros.d.ts
vendored
Normal file
14
dist-import/pilao-de-dados/_deletar_registros.d.ts
vendored
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import type { tipoResposta } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { type zp_produto_conta } from "./variaveis";
|
||||
export declare const zp_deletar_registros: z.ZodObject<{
|
||||
tabela: z.ZodString;
|
||||
codigos: z.ZodArray<z.ZodString, "many">;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
}, {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
}>;
|
||||
export declare const deletar_registros: ({ conta, produto, emDesenvolvimento }: z.infer<typeof zp_produto_conta>) => ({ codigos, tabela, }: z.infer<typeof zp_deletar_registros>) => Promise<tipoResposta<true>>;
|
||||
|
|
@ -10,13 +10,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
import node_fetch from "cross-fetch";
|
||||
import { respostaComuns } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { PREFIXO, baseUrlPilao } from "./_variaveis";
|
||||
import { PREFIXO, baseUrlPilao } from "./variaveis";
|
||||
//enviar registros para base de dados
|
||||
export const zp_deletar_registros = z.object({
|
||||
tabela: z.string(),
|
||||
codigos: z.array(z.string()),
|
||||
});
|
||||
export const deletar_registros = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { codigos, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
export const deletar_registros = ({ conta, produto, emDesenvolvimento }) => ({ codigos, tabela, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ deletar_registros })[0]}/${produto}/${conta}`);
|
||||
const tamanhoBlocos = 1000;
|
||||
while (codigos.length > 0) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { tipoResposta } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { type zp_produto_conta } from "./_variaveis";
|
||||
import { type zp_produto_conta } from "./variaveis";
|
||||
export declare const zp_registrar_base_dados: z.ZodObject<{
|
||||
tabela: z.ZodString;
|
||||
colunas: z.ZodArray<z.ZodObject<{
|
||||
|
|
@ -51,10 +51,4 @@ export declare const zp_enviar_registros: z.ZodObject<{
|
|||
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
|
||||
}>[];
|
||||
}>;
|
||||
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>>;
|
||||
export declare const enviar_registros: ({ conta, produto, emDesenvolvimento }: z.infer<typeof zp_produto_conta>) => ({ registros, tabela, }: z.infer<typeof zp_enviar_registros>) => Promise<tipoResposta<true>>;
|
||||
|
|
@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
import node_fetch from "cross-fetch";
|
||||
import { respostaComuns } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { PREFIXO, baseUrlPilao, z_tipo_coluna_base_dados, } 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({
|
||||
|
|
@ -26,7 +26,7 @@ export const zp_enviar_registros = z.object({
|
|||
tipo: z_tipo_coluna_base_dados.optional().nullable(),
|
||||
}))),
|
||||
});
|
||||
export const enviar_registros = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => ({ registros, tabela, }) => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${PREFIXO}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);
|
||||
const tamanhoBlocos = 1000;
|
||||
while (registros.length > 0) {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import type { tipoResposta } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { type zp_produto_conta } from "./_variaveis";
|
||||
import { type zp_produto_conta } from "./variaveis";
|
||||
export declare const zp_serie_registrar: z.ZodObject<{
|
||||
tabela: z.ZodString;
|
||||
colanuEixoX: z.ZodString;
|
||||
|
|
@ -17,12 +17,7 @@ export declare const zp_serie_registrar: z.ZodObject<{
|
|||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
}>;
|
||||
export declare const serie_consultar: ({ emDesenvolvimento, cliente, parametros, }: {
|
||||
emDesenvolvimento?: boolean | undefined | null;
|
||||
/** Identificação do cliente */
|
||||
cliente: z.infer<typeof zp_produto_conta>;
|
||||
parametros: z.infer<typeof zp_serie_registrar>;
|
||||
}) => {
|
||||
export declare const serie_consultar: (cliente: z.infer<typeof zp_produto_conta>) => (parametros: z.infer<typeof zp_serie_registrar>) => {
|
||||
dados: () => Promise<tipoResposta<{
|
||||
registros: any[];
|
||||
legenda: string;
|
||||
|
|
@ -10,16 +10,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
import node_fetch from "cross-fetch";
|
||||
import { respostaComuns } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { PREFIXO, baseUrlPilao, tiposSeriesAgregacoes, } from "./_variaveis";
|
||||
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 = ({ emDesenvolvimento, cliente, parametros, }) => {
|
||||
export const serie_consultar = (cliente) => (parametros) => {
|
||||
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${`${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`}`);
|
||||
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),
|
||||
|
|
@ -35,7 +35,7 @@ export const serie_consultar = ({ emDesenvolvimento, cliente, parametros, }) =>
|
|||
cliente,
|
||||
parametros,
|
||||
};
|
||||
const vUrl = new URL(`${emDesenvolvimento
|
||||
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));
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
import type { tipoResposta } from "p-respostas";
|
||||
import { z } from "zod";
|
||||
import { type zp_produto_conta } from "./_variaveis";
|
||||
export declare const zp_deletar_registros: z.ZodObject<{
|
||||
tabela: z.ZodString;
|
||||
codigos: z.ZodArray<z.ZodString, "many">;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
}, {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
}>;
|
||||
export declare const deletar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { codigos, 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_deletar_registros>;
|
||||
}) => Promise<tipoResposta<true>>;
|
||||
66
dist-import/pilao-de-dados/index.d.ts
vendored
66
dist-import/pilao-de-dados/index.d.ts
vendored
|
|
@ -1,4 +1,4 @@
|
|||
import { tiposSeriesAgregacoes } from "./_variaveis";
|
||||
import { tiposSeriesAgregacoes } from "./variaveis";
|
||||
export { tiposSeriesAgregacoes };
|
||||
export declare const pPilao: {
|
||||
zp_registrar_base_dados: import("zod").ZodObject<{
|
||||
|
|
@ -26,19 +26,16 @@ export declare const pPilao: {
|
|||
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
|
||||
}[];
|
||||
}>;
|
||||
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
|
||||
emDesenvolvimento?: boolean | null | undefined;
|
||||
cliente: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
};
|
||||
parametros: {
|
||||
tabela: string;
|
||||
registros: Record<string, {
|
||||
valor?: any;
|
||||
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
|
||||
}>[];
|
||||
};
|
||||
enviar_registros: ({ conta, produto, emDesenvolvimento }: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}) => ({ registros, tabela, }: {
|
||||
tabela: string;
|
||||
registros: Record<string, {
|
||||
valor?: any;
|
||||
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
|
||||
}>[];
|
||||
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||
zp_enviar_registros: import("zod").ZodObject<{
|
||||
tabela: import("zod").ZodString;
|
||||
|
|
@ -81,18 +78,15 @@ export declare const pPilao: {
|
|||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
}>;
|
||||
serie_consultar: ({ emDesenvolvimento, cliente, parametros, }: {
|
||||
emDesenvolvimento?: boolean | null | undefined;
|
||||
cliente: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
};
|
||||
parametros: {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
};
|
||||
serie_consultar: (cliente: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}) => (parametros: {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
}) => {
|
||||
dados: () => Promise<import("p-respostas").tipoResposta<{
|
||||
registros: any[];
|
||||
|
|
@ -109,24 +103,24 @@ export declare const pPilao: {
|
|||
zp_produto_conta: import("zod").ZodObject<{
|
||||
produto: import("zod").ZodString;
|
||||
conta: import("zod").ZodString;
|
||||
emDesenvolvimento: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
||||
}, "strip", import("zod").ZodTypeAny, {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}, {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}>;
|
||||
validarZ: <T>(zodType: import("zod").ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
|
||||
deletar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { codigos, tabela }, }: {
|
||||
emDesenvolvimento?: boolean | null | undefined;
|
||||
cliente: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
};
|
||||
parametros: {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
};
|
||||
deletar_registros: ({ conta, produto, emDesenvolvimento }: {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}) => ({ codigos, tabela, }: {
|
||||
tabela: string;
|
||||
codigos: string[];
|
||||
}) => Promise<import("p-respostas").tipoResposta<true>>;
|
||||
zp_deletar_registros: import("zod").ZodObject<{
|
||||
tabela: import("zod").ZodString;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { tiposSeriesAgregacoes, validarZ, zp_produto_conta } from "./_variaveis";
|
||||
import { deletar_registros, zp_deletar_registros } from "./deletar_registros";
|
||||
import { enviar_registros, zp_enviar_registros, zp_registrar_base_dados, } from "./enviar_registros";
|
||||
import { serie_consultar, zp_serie_registrar } from "./serie_consultar";
|
||||
import { deletar_registros, zp_deletar_registros } from "./_deletar_registros";
|
||||
import { enviar_registros, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros";
|
||||
import { tiposSeriesAgregacoes, validarZ, zp_produto_conta } from "./variaveis";
|
||||
import { serie_consultar, zp_serie_registrar } from "./_serie_consultar";
|
||||
export { tiposSeriesAgregacoes };
|
||||
export const pPilao = {
|
||||
zp_registrar_base_dados,
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ export declare const validarZ: <T>(zodType: z.ZodType<T, any, T>, objeto: any, m
|
|||
export declare const zp_produto_conta: z.ZodObject<{
|
||||
produto: z.ZodString;
|
||||
conta: z.ZodString;
|
||||
emDesenvolvimento: z.ZodOptional<z.ZodBoolean>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}, {
|
||||
produto: string;
|
||||
conta: string;
|
||||
emDesenvolvimento?: boolean | undefined;
|
||||
}>;
|
||||
export declare const z_tipo_coluna_base_dados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;
|
||||
export declare const tiposSeriesAgregacoes: z.ZodEnum<["contagem", "somatoria"]>;
|
||||
|
|
@ -13,6 +13,7 @@ export const validarZ = (zodType, objeto, mensagem) => {
|
|||
export const zp_produto_conta = z.object({
|
||||
produto: z.string(),
|
||||
conta: z.string(),
|
||||
emDesenvolvimento: z.boolean().optional(),
|
||||
});
|
||||
export const z_tipo_coluna_base_dados = z.enum([
|
||||
"texto",
|
||||
Loading…
Add table
Add a link
Reference in a new issue