build
This commit is contained in:
parent
f2562a37d1
commit
7032eb1329
39 changed files with 442 additions and 790 deletions
|
|
@ -1,12 +1,3 @@
|
|||
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";
|
||||
|
|
@ -16,12 +7,12 @@ export const zp_deletar_registros = z.object({
|
|||
tabela: z.string(),
|
||||
codigos: z.array(z.string()),
|
||||
});
|
||||
export const deletar_registros = ({ conta, produto, emDesenvolvimento }) => (_a) => __awaiter(void 0, [_a], void 0, function* ({ codigos, tabela, }) {
|
||||
export const deletar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ codigos, tabela, }) => {
|
||||
const url = new URL(`${urlPilao(emDesenvolvimento).api}/${Object.keys({ deletar_registros })[0]}/${produto}/${conta}`);
|
||||
const tamanhoBlocos = 1000;
|
||||
while (codigos.length > 0) {
|
||||
const bloco = codigos.splice(0, tamanhoBlocos);
|
||||
const resp = yield node_fetch(url.toString(), {
|
||||
const resp = await node_fetch(url.toString(), {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ tabela, codigos: bloco }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
|
@ -34,4 +25,4 @@ export const deletar_registros = ({ conta, produto, emDesenvolvimento }) => (_a)
|
|||
}
|
||||
}
|
||||
return respostaComuns.valor(true);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,12 +1,3 @@
|
|||
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";
|
||||
|
|
@ -26,14 +17,14 @@ export const zp_enviar_registros = z.object({
|
|||
tipo: z_tipo_coluna_base_dados.optional().nullable(),
|
||||
}))),
|
||||
});
|
||||
export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => (_a) => __awaiter(void 0, [_a], void 0, function* ({ registros, tabela, }) {
|
||||
export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ registros, tabela, }) => {
|
||||
const url = new URL(`${urlPilao(emDesenvolvimento).api}/${Object.keys({ enviar_registros })[0]}/${produto}/${conta}`);
|
||||
const tamanhoBlocos = 1000;
|
||||
while (registros.length > 0) {
|
||||
const bloco = registros
|
||||
.splice(0, tamanhoBlocos)
|
||||
.map((r) => Object.fromEntries(Object.entries(r).map(([k, v]) => [k, v === undefined ? null : v])));
|
||||
const resp = yield node_fetch(url.toString(), {
|
||||
const resp = await node_fetch(url.toString(), {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ tabela, registros: bloco }),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
|
@ -46,4 +37,4 @@ export const enviar_registros = ({ conta, produto, emDesenvolvimento }) => (_a)
|
|||
}
|
||||
}
|
||||
return respostaComuns.valor(true);
|
||||
});
|
||||
};
|
||||
|
|
|
|||
23
dist-import/pilao-de-dados/_serie_consultar.d.ts
vendored
23
dist-import/pilao-de-dados/_serie_consultar.d.ts
vendored
|
|
@ -6,16 +6,39 @@ export declare const zp_serie_registrar: z.ZodObject<{
|
|||
colanuEixoX: z.ZodString;
|
||||
colunaAgrupamento: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
||||
agregacao: z.ZodEnum<["contagem", "somatoria"]>;
|
||||
filtro: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
||||
coluna: z.ZodString;
|
||||
valor: z.ZodString;
|
||||
operador: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}, {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}>, "many">>;
|
||||
}, "strip", z.ZodTypeAny, {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
filtro?: {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}[] | undefined;
|
||||
}, {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
filtro?: {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}[] | undefined;
|
||||
}>;
|
||||
export declare const serie_consultar: (cliente: z.infer<typeof zp_produto_conta>) => (parametros: z.infer<typeof zp_serie_registrar>) => {
|
||||
dados: () => Promise<tipoResposta<{
|
||||
|
|
|
|||
|
|
@ -1,26 +1,23 @@
|
|||
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 { tiposSeriesAgregacoes, urlPilao, } from "./variaveis";
|
||||
import { operadores_pilao, tiposSeriesAgregacoes, urlPilao, } from "./variaveis";
|
||||
const filtro = z.object({
|
||||
coluna: z.string(),
|
||||
valor: z.string(),
|
||||
operador: operadores_pilao,
|
||||
});
|
||||
export const zp_serie_registrar = z.object({
|
||||
tabela: z.string(),
|
||||
colanuEixoX: z.string(),
|
||||
colunaAgrupamento: z.string().array().optional(),
|
||||
agregacao: tiposSeriesAgregacoes,
|
||||
filtro: filtro.array().optional(),
|
||||
});
|
||||
export const serie_consultar = (cliente) => (parametros) => {
|
||||
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
|
||||
const dados = async () => {
|
||||
const url = new URL(`${urlPilao(cliente.emDesenvolvimento).api}/${tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`);
|
||||
const resp = yield node_fetch(url.toString(), {
|
||||
const resp = await node_fetch(url.toString(), {
|
||||
method: "POST",
|
||||
body: JSON.stringify(parametros),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
|
|
@ -29,7 +26,7 @@ export const serie_consultar = (cliente) => (parametros) => {
|
|||
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
|
||||
.then((r) => r);
|
||||
return resp;
|
||||
});
|
||||
};
|
||||
const url = () => {
|
||||
const vUrl = new URL(`${urlPilao(cliente.emDesenvolvimento).site}/${tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`);
|
||||
const serie = encodeURIComponent(JSON.stringify(parametros, null, 2));
|
||||
|
|
|
|||
33
dist-import/pilao-de-dados/index.d.ts
vendored
33
dist-import/pilao-de-dados/index.d.ts
vendored
|
|
@ -61,16 +61,39 @@ export declare const pPilao: {
|
|||
colanuEixoX: import("zod").ZodString;
|
||||
colunaAgrupamento: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString, "many">>;
|
||||
agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>;
|
||||
filtro: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
||||
coluna: import("zod").ZodString;
|
||||
valor: import("zod").ZodString;
|
||||
operador: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>;
|
||||
}, "strip", import("zod").ZodTypeAny, {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}, {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}>, "many">>;
|
||||
}, "strip", import("zod").ZodTypeAny, {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
filtro?: {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}[] | undefined;
|
||||
}, {
|
||||
tabela: string;
|
||||
colanuEixoX: string;
|
||||
agregacao: "contagem" | "somatoria";
|
||||
colunaAgrupamento?: string[] | undefined;
|
||||
filtro?: {
|
||||
valor: string;
|
||||
coluna: string;
|
||||
operador: "=" | "!=" | ">" | "<" | ">=" | "<=" | "∩";
|
||||
}[] | undefined;
|
||||
}>;
|
||||
serie_consultar: (cliente: import("zod").TypeOf<typeof zp_produto_conta>) => (parametros: import("zod").TypeOf<typeof zp_serie_registrar>) => {
|
||||
dados: () => Promise<import("p-respostas").tipoResposta<{
|
||||
|
|
@ -105,4 +128,14 @@ export declare const pPilao: {
|
|||
tabela: string;
|
||||
codigos: string[];
|
||||
}>;
|
||||
operadores_pilao: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>;
|
||||
operadores_permitidos_por_tipo: {
|
||||
texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
confirmacao: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
lista_texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
lista_numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
data: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
mes: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[];
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { deletar_registros, zp_deletar_registros } from "./_deletar_registros";
|
||||
export { PREFIXO_PILAO, urlPilao } from "./variaveis";
|
||||
import { enviar_registros, zp_enviar_registros, zp_registrar_base_dados, } from "./_enviar_registros";
|
||||
import { tiposSeriesAgregacoes, validarZ, zp_produto_conta } from "./variaveis";
|
||||
import { operadores_permitidos_por_tipo, operadores_pilao, tiposSeriesAgregacoes, validarZ, zp_produto_conta, } from "./variaveis";
|
||||
import { serie_consultar, zp_serie_registrar } from "./_serie_consultar";
|
||||
export { tiposSeriesAgregacoes };
|
||||
export const pPilao = {
|
||||
|
|
@ -14,4 +14,6 @@ export const pPilao = {
|
|||
validarZ,
|
||||
deletar_registros,
|
||||
zp_deletar_registros,
|
||||
operadores_pilao,
|
||||
operadores_permitidos_por_tipo,
|
||||
};
|
||||
|
|
|
|||
4
dist-import/pilao-de-dados/variaveis.d.ts
vendored
4
dist-import/pilao-de-dados/variaveis.d.ts
vendored
|
|
@ -16,6 +16,10 @@ export declare const zp_produto_conta: z.ZodObject<{
|
|||
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 operadores_pilao: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>;
|
||||
export declare const operadores_permitidos_por_tipo: {
|
||||
[key in z.infer<typeof z_tipo_coluna_base_dados>]: z.infer<typeof operadores_pilao>[];
|
||||
};
|
||||
export declare const tiposSeriesAgregacoes: z.ZodEnum<["contagem", "somatoria"]>;
|
||||
export declare const z_validar_colunna_base_dados: {
|
||||
texto: z.ZodNullable<z.ZodString>;
|
||||
|
|
|
|||
|
|
@ -23,6 +23,16 @@ export const z_tipo_coluna_base_dados = z.enum([
|
|||
"data",
|
||||
"mes",
|
||||
]);
|
||||
export const operadores_pilao = z.enum(["=", "!=", ">", "<", ">=", "<=", "∩"]);
|
||||
export const operadores_permitidos_por_tipo = {
|
||||
confirmacao: ["=", "!="],
|
||||
data: ["=", "!=", ">", "<", ">=", "<="],
|
||||
lista_numero: ["∩"],
|
||||
lista_texto: ["∩"],
|
||||
mes: ["=", "!=", ">", "<", ">=", "<="],
|
||||
numero: ["=", "!=", ">", "<", ">=", "<="],
|
||||
texto: ["=", "!="],
|
||||
};
|
||||
export const tiposSeriesAgregacoes = z.enum(["contagem", "somatoria"]);
|
||||
export const z_validar_colunna_base_dados = {
|
||||
texto: z.string().nullable(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue