diff --git a/dist-import/NPS/index.js b/dist-import/NPS/index.js index cfda4af..e7a23eb 100644 --- a/dist-import/NPS/index.js +++ b/dist-import/NPS/index.js @@ -1,16 +1,7 @@ // npm run build produz um arquivo abrirNps.js que é copiado para a pasta public -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"; // exibe o iframe em tela cheia -export const abrirNps = (emDesenvolvimento) => (parametros) => __awaiter(void 0, void 0, void 0, function* () { +export const abrirNps = (emDesenvolvimento) => async (parametros) => { const base_site = emDesenvolvimento ? "http://localhost:5040/nps" : "https://carro-de-boi.idz.one/nps"; @@ -23,7 +14,7 @@ export const abrirNps = (emDesenvolvimento) => (parametros) => __awaiter(void 0, for (const [chave, valor] of Object.entries(parametros)) { url_proxima_avaliacao.searchParams.append(chave, valor); } - const response = yield fetch(url_proxima_avaliacao.href) + const response = await fetch(url_proxima_avaliacao.href) .then((resposta) => resposta.json()) .catch((error) => respostaComuns.erro(error.message)); const proxima_avaliacao = response.valor; @@ -56,4 +47,4 @@ export const abrirNps = (emDesenvolvimento) => (parametros) => __awaiter(void 0, document.body.removeChild(iframe); } }); -}); +}; diff --git a/dist-import/autenticacao/_codigoContaSite.js b/dist-import/autenticacao/_codigoContaSite.js index 43fbee3..89124d0 100644 --- a/dist-import/autenticacao/_codigoContaSite.js +++ b/dist-import/autenticacao/_codigoContaSite.js @@ -1,19 +1,10 @@ -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 { urlAutenticacao } from "./_urlAutenticacao"; import node_fetch from "cross-fetch"; -export const codigoContaSite = (_a) => __awaiter(void 0, [_a], void 0, function* ({ ambiente, post, }) { +export const codigoContaSite = async ({ ambiente, post, }) => { const url = `${urlAutenticacao(ambiente)}/api/codigo_prefeitura_site`; try { - const resp = yield node_fetch(url, { + const resp = await node_fetch(url, { method: "POST", body: JSON.stringify(post), headers: { "Content-Type": "application/json" }, @@ -26,4 +17,4 @@ export const codigoContaSite = (_a) => __awaiter(void 0, [_a], void 0, function* catch (e) { return respostaComuns.erro(`erro ao buscar código do site: ${e}`); } -}); +}; diff --git a/dist-import/autenticacao/_usuarios_quipo_governo.js b/dist-import/autenticacao/_usuarios_quipo_governo.js index a357deb..01a955d 100644 --- a/dist-import/autenticacao/_usuarios_quipo_governo.js +++ b/dist-import/autenticacao/_usuarios_quipo_governo.js @@ -1,16 +1,7 @@ -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 { urlAutenticacao } from "./_urlAutenticacao"; -export const usuarios_quipo_governo = (_a) => __awaiter(void 0, [_a], void 0, function* ({ token_produto, ambiente, }) { +export const usuarios_quipo_governo = async ({ token_produto, ambiente, }) => { const url = `${urlAutenticacao(ambiente)}/api/usuarios_quipo_governo`; if (!token_produto) return respostaComuns.erro("token_produto não informado"); @@ -23,4 +14,4 @@ export const usuarios_quipo_governo = (_a) => __awaiter(void 0, [_a], void 0, fu .then((r) => r.json()) .catch((e) => respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`)) .then((r) => r); -}); +}; diff --git a/dist-import/autenticacao/_usuarios_quipo_vincular.js b/dist-import/autenticacao/_usuarios_quipo_vincular.js index 23ee790..f940fd4 100644 --- a/dist-import/autenticacao/_usuarios_quipo_vincular.js +++ b/dist-import/autenticacao/_usuarios_quipo_vincular.js @@ -1,16 +1,7 @@ -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 { urlAutenticacao } from "./_urlAutenticacao"; -export const usuarios_quipo_vincular = (_a) => __awaiter(void 0, [_a], void 0, function* ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }) { +export const usuarios_quipo_vincular = async ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }) => { const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`; if (!token_produto) return respostaComuns.erro("token_produto não informado"); @@ -22,11 +13,11 @@ export const usuarios_quipo_vincular = (_a) => __awaiter(void 0, [_a], void 0, f vinculos: { codigo_conta: conta, codigo_usuario, vinculo }, email: email, }; - return yield node_fetch(url, { + return await node_fetch(url, { headers, body: JSON.stringify(parametros), method: "POST", }) - .then((r) => __awaiter(void 0, void 0, void 0, function* () { return yield r.json(); })) + .then(async (r) => await r.json()) .catch((e) => respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`)); -}); +}; diff --git a/dist-import/autenticacao/_validarToken.js b/dist-import/autenticacao/_validarToken.js index 2dc27be..fd95507 100644 --- a/dist-import/autenticacao/_validarToken.js +++ b/dist-import/autenticacao/_validarToken.js @@ -1,19 +1,10 @@ -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 { urlAutenticacao } from "./_urlAutenticacao"; import node_fetch from "cross-fetch"; /** faz a validação do token */ -export const validarToken = (_a) => __awaiter(void 0, [_a], void 0, function* ({ ambiente, post, }) { +export const validarToken = async ({ ambiente, post, }) => { const url = `${urlAutenticacao(ambiente)}/api/validar_token`; try { - const resposta = yield node_fetch(url, { + const resposta = await node_fetch(url, { method: "POST", body: JSON.stringify(post), headers: { "Content-Type": "application/json" }, @@ -27,4 +18,4 @@ export const validarToken = (_a) => __awaiter(void 0, [_a], void 0, function* ({ catch (e) { return "erro"; } -}); +}; diff --git a/dist-import/pilao-de-dados/_deletar_registros.js b/dist-import/pilao-de-dados/_deletar_registros.js index f088507..e04c363 100644 --- a/dist-import/pilao-de-dados/_deletar_registros.js +++ b/dist-import/pilao-de-dados/_deletar_registros.js @@ -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); -}); +}; diff --git a/dist-import/pilao-de-dados/_enviar_registros.js b/dist-import/pilao-de-dados/_enviar_registros.js index b8118ad..27d16ca 100644 --- a/dist-import/pilao-de-dados/_enviar_registros.js +++ b/dist-import/pilao-de-dados/_enviar_registros.js @@ -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); -}); +}; diff --git a/dist-import/pilao-de-dados/_serie_consultar.d.ts b/dist-import/pilao-de-dados/_serie_consultar.d.ts index c763ce5..0734d6c 100644 --- a/dist-import/pilao-de-dados/_serie_consultar.d.ts +++ b/dist-import/pilao-de-dados/_serie_consultar.d.ts @@ -6,16 +6,39 @@ export declare const zp_serie_registrar: z.ZodObject<{ colanuEixoX: z.ZodString; colunaAgrupamento: z.ZodOptional>; agregacao: z.ZodEnum<["contagem", "somatoria"]>; + filtro: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "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) => (parametros: z.infer) => { dados: () => Promise (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)); diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 6bcb8ad..a342bab 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -61,16 +61,39 @@ export declare const pPilao: { colanuEixoX: import("zod").ZodString; colunaAgrupamento: import("zod").ZodOptional>; agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>; + filtro: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "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) => (parametros: import("zod").TypeOf) => { dados: () => Promise; + operadores_pilao: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; + operadores_permitidos_por_tipo: { + texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + confirmacao: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + lista_texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + lista_numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + data: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + mes: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + }; }; diff --git a/dist-import/pilao-de-dados/index.js b/dist-import/pilao-de-dados/index.js index 0940a1c..3eef326 100644 --- a/dist-import/pilao-de-dados/index.js +++ b/dist-import/pilao-de-dados/index.js @@ -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, }; diff --git a/dist-import/pilao-de-dados/variaveis.d.ts b/dist-import/pilao-de-dados/variaveis.d.ts index 7813069..55e2f5b 100644 --- a/dist-import/pilao-de-dados/variaveis.d.ts +++ b/dist-import/pilao-de-dados/variaveis.d.ts @@ -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]: z.infer[]; +}; export declare const tiposSeriesAgregacoes: z.ZodEnum<["contagem", "somatoria"]>; export declare const z_validar_colunna_base_dados: { texto: z.ZodNullable; diff --git a/dist-import/pilao-de-dados/variaveis.js b/dist-import/pilao-de-dados/variaveis.js index a49501c..563e2fc 100644 --- a/dist-import/pilao-de-dados/variaveis.js +++ b/dist-import/pilao-de-dados/variaveis.js @@ -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(), diff --git a/dist-require/NPS/index.js b/dist-require/NPS/index.js index f4f6ccb..96aa0cd 100644 --- a/dist-require/NPS/index.js +++ b/dist-require/NPS/index.js @@ -1,152 +1,54 @@ "use strict"; // npm run build produz um arquivo abrirNps.js que é copiado para a pasta public -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 }; - } -}; -var __values = (this && this.__values) || function(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function () { - if (o && i >= o.length) o = void 0; - return { value: o && o[i++], done: !o }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; Object.defineProperty(exports, "__esModule", { value: true }); exports.abrirNps = void 0; -var p_respostas_1 = require("p-respostas"); +const p_respostas_1 = require("p-respostas"); // exibe o iframe em tela cheia -var abrirNps = function (emDesenvolvimento) { - return function (parametros) { return __awaiter(void 0, void 0, void 0, function () { - var base_site, base_api, sistema, codigo_organizacao, codigo_usuario, nome_local_storage_proxima, proxima_avaliacao, url_proxima_avaliacao, _a, _b, _c, chave, valor, response, proxima_avaliacao_1, abrir_modal, urlIfrma, _d, _e, _f, chave, valor, iframe; - var e_1, _g, e_2, _h; - return __generator(this, function (_j) { - switch (_j.label) { - case 0: - base_site = emDesenvolvimento - ? "http://localhost:5040/nps" - : "https://carro-de-boi.idz.one/nps"; - base_api = "".concat(base_site, "/api"); - sistema = parametros.sistema, codigo_organizacao = parametros.codigo_organizacao, codigo_usuario = parametros.codigo_usuario; - nome_local_storage_proxima = "nps_proxima_avaliacao_".concat(sistema, "_").concat(codigo_usuario, "_").concat(codigo_organizacao, "_0"); - proxima_avaliacao = localStorage.getItem(nome_local_storage_proxima); - if (!!proxima_avaliacao) return [3 /*break*/, 2]; - url_proxima_avaliacao = new URL("".concat(base_api, "/").concat(sistema, "/proxima_avaliacao")); - try { - for (_a = __values(Object.entries(parametros)), _b = _a.next(); !_b.done; _b = _a.next()) { - _c = __read(_b.value, 2), chave = _c[0], valor = _c[1]; - url_proxima_avaliacao.searchParams.append(chave, valor); - } - } - catch (e_1_1) { e_1 = { error: e_1_1 }; } - finally { - try { - if (_b && !_b.done && (_g = _a.return)) _g.call(_a); - } - finally { if (e_1) throw e_1.error; } - } - return [4 /*yield*/, fetch(url_proxima_avaliacao.href) - .then(function (resposta) { - return resposta.json(); - }) - .catch(function (error) { return p_respostas_1.respostaComuns.erro(error.message); })]; - case 1: - response = _j.sent(); - proxima_avaliacao_1 = response.valor; - proxima_avaliacao_1 && - localStorage.setItem(nome_local_storage_proxima, proxima_avaliacao_1); - _j.label = 2; - case 2: - abrir_modal = proxima_avaliacao && - new Date().toISOString().slice(0, 10) >= proxima_avaliacao; - if (!abrir_modal) { - return [2 /*return*/]; - } - localStorage.removeItem(nome_local_storage_proxima); - urlIfrma = new URL(base_site); - try { - for (_d = __values(Object.entries(parametros)), _e = _d.next(); !_e.done; _e = _d.next()) { - _f = __read(_e.value, 2), chave = _f[0], valor = _f[1]; - urlIfrma.searchParams.append(chave, valor); - } - } - catch (e_2_1) { e_2 = { error: e_2_1 }; } - finally { - try { - if (_e && !_e.done && (_h = _d.return)) _h.call(_d); - } - finally { if (e_2) throw e_2.error; } - } - iframe = document.createElement("iframe"); - iframe.src = urlIfrma.href; - iframe.style.position = "fixed"; - iframe.style.top = "0"; - iframe.style.left = "0"; - iframe.style.width = "100%"; - iframe.style.height = "100%"; - iframe.style.border = "none"; - iframe.style.zIndex = "999999"; - document.body.appendChild(iframe); - // receber mensagem do iframe - window.addEventListener("message", function (event) { - if (event.data === "fechar") { - document.body.removeChild(iframe); - } - }); - return [2 /*return*/]; - } - }); - }); }; +const abrirNps = (emDesenvolvimento) => async (parametros) => { + const base_site = emDesenvolvimento + ? "http://localhost:5040/nps" + : "https://carro-de-boi.idz.one/nps"; + const base_api = `${base_site}/api`; + const { sistema, codigo_organizacao, codigo_usuario } = parametros; + const nome_local_storage_proxima = `nps_proxima_avaliacao_${sistema}_${codigo_usuario}_${codigo_organizacao}_0`; + const proxima_avaliacao = localStorage.getItem(nome_local_storage_proxima); + if (!proxima_avaliacao) { + const url_proxima_avaliacao = new URL(`${base_api}/${sistema}/proxima_avaliacao`); + for (const [chave, valor] of Object.entries(parametros)) { + url_proxima_avaliacao.searchParams.append(chave, valor); + } + const response = await fetch(url_proxima_avaliacao.href) + .then((resposta) => resposta.json()) + .catch((error) => p_respostas_1.respostaComuns.erro(error.message)); + const proxima_avaliacao = response.valor; + proxima_avaliacao && + localStorage.setItem(nome_local_storage_proxima, proxima_avaliacao); + } + const abrir_modal = proxima_avaliacao && + new Date().toISOString().slice(0, 10) >= proxima_avaliacao; + if (!abrir_modal) { + return; + } + localStorage.removeItem(nome_local_storage_proxima); + const urlIfrma = new URL(base_site); + for (const [chave, valor] of Object.entries(parametros)) { + urlIfrma.searchParams.append(chave, valor); + } + const iframe = document.createElement("iframe"); + iframe.src = urlIfrma.href; + iframe.style.position = "fixed"; + iframe.style.top = "0"; + iframe.style.left = "0"; + iframe.style.width = "100%"; + iframe.style.height = "100%"; + iframe.style.border = "none"; + iframe.style.zIndex = "999999"; + document.body.appendChild(iframe); + // receber mensagem do iframe + window.addEventListener("message", (event) => { + if (event.data === "fechar") { + document.body.removeChild(iframe); + } + }); }; exports.abrirNps = abrirNps; diff --git a/dist-require/autenticacao/_codigoContaSite.js b/dist-require/autenticacao/_codigoContaSite.js index 8a909eb..5a648c2 100644 --- a/dist-require/autenticacao/_codigoContaSite.js +++ b/dist-require/autenticacao/_codigoContaSite.js @@ -1,76 +1,27 @@ "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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.codigoContaSite = void 0; -var p_respostas_1 = require("p-respostas"); -var _urlAutenticacao_1 = require("./_urlAutenticacao"); -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var codigoContaSite = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, resp, e_1; - var ambiente = _b.ambiente, post = _b.post; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/codigo_prefeitura_site"); - _c.label = 1; - case 1: - _c.trys.push([1, 3, , 4]); - return [4 /*yield*/, (0, cross_fetch_1.default)(url, { - method: "POST", - body: JSON.stringify(post), - 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 2: - resp = _c.sent(); - return [2 /*return*/, resp]; - case 3: - e_1 = _c.sent(); - return [2 /*return*/, p_respostas_1.respostaComuns.erro("erro ao buscar c\u00F3digo do site: ".concat(e_1))]; - case 4: return [2 /*return*/]; - } - }); -}); }; +const p_respostas_1 = require("p-respostas"); +const _urlAutenticacao_1 = require("./_urlAutenticacao"); +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const codigoContaSite = async ({ ambiente, post, }) => { + const url = `${(0, _urlAutenticacao_1.urlAutenticacao)(ambiente)}/api/codigo_prefeitura_site`; + try { + const resp = await (0, cross_fetch_1.default)(url, { + method: "POST", + body: JSON.stringify(post), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + return resp; + } + catch (e) { + return p_respostas_1.respostaComuns.erro(`erro ao buscar código do site: ${e}`); + } +}; exports.codigoContaSite = codigoContaSite; diff --git a/dist-require/autenticacao/_urlAutenticacao.js b/dist-require/autenticacao/_urlAutenticacao.js index 01b95e1..2fa9fd7 100644 --- a/dist-require/autenticacao/_urlAutenticacao.js +++ b/dist-require/autenticacao/_urlAutenticacao.js @@ -1,9 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.urlAutenticacao = void 0; -var urlAutenticacao = function (ambiente) { - return "".concat(ambiente == "producao" - ? "https://carro-de-boi.idz.one" - : "http://localhost:5030", "/autenticacao"); -}; +const urlAutenticacao = (ambiente) => `${ambiente == "producao" + ? "https://carro-de-boi.idz.one" + : "http://localhost:5030"}/autenticacao`; exports.urlAutenticacao = urlAutenticacao; diff --git a/dist-require/autenticacao/_usuarios_quipo_governo.js b/dist-require/autenticacao/_usuarios_quipo_governo.js index 61399a9..f6cd83c 100644 --- a/dist-require/autenticacao/_usuarios_quipo_governo.js +++ b/dist-require/autenticacao/_usuarios_quipo_governo.js @@ -1,66 +1,24 @@ "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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.usuarios_quipo_governo = void 0; -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var p_respostas_1 = require("p-respostas"); -var _urlAutenticacao_1 = require("./_urlAutenticacao"); -var usuarios_quipo_governo = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, headers; - var token_produto = _b.token_produto, ambiente = _b.ambiente; - return __generator(this, function (_c) { - url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/usuarios_quipo_governo"); - if (!token_produto) - return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")]; - headers = { - token: token_produto, - }; - return [2 /*return*/, (0, cross_fetch_1.default)(url, { - headers: headers, - }) - .then(function (r) { return r.json(); }) - .catch(function (e) { - return p_respostas_1.respostaComuns.erro("Erro ao buscar usu\u00E1rios quipo governo ".concat(e.message)); - }) - .then(function (r) { return r; })]; - }); -}); }; +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_respostas_1 = require("p-respostas"); +const _urlAutenticacao_1 = require("./_urlAutenticacao"); +const usuarios_quipo_governo = async ({ token_produto, ambiente, }) => { + const url = `${(0, _urlAutenticacao_1.urlAutenticacao)(ambiente)}/api/usuarios_quipo_governo`; + if (!token_produto) + return p_respostas_1.respostaComuns.erro("token_produto não informado"); + const headers = { + token: token_produto, + }; + return (0, cross_fetch_1.default)(url, { + headers, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`)) + .then((r) => r); +}; exports.usuarios_quipo_governo = usuarios_quipo_governo; diff --git a/dist-require/autenticacao/_usuarios_quipo_vincular.js b/dist-require/autenticacao/_usuarios_quipo_vincular.js index 7955c29..dea1a09 100644 --- a/dist-require/autenticacao/_usuarios_quipo_vincular.js +++ b/dist-require/autenticacao/_usuarios_quipo_vincular.js @@ -1,81 +1,30 @@ "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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.usuarios_quipo_vincular = void 0; -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var p_respostas_1 = require("p-respostas"); -var _urlAutenticacao_1 = require("./_urlAutenticacao"); -var usuarios_quipo_vincular = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, headers, parametros; - var token_produto = _b.token_produto, ambiente = _b.ambiente, conta = _b.conta, vinculo = _b.vinculo, codigo_usuario = _b.codigo_usuario, email = _b.email; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/vinculos__criar"); - if (!token_produto) - return [2 /*return*/, p_respostas_1.respostaComuns.erro("token_produto não informado")]; - headers = { - token: token_produto, - "Content-Type": "application/json", - }; - parametros = { - vinculos: { codigo_conta: conta, codigo_usuario: codigo_usuario, vinculo: vinculo }, - email: email, - }; - return [4 /*yield*/, (0, cross_fetch_1.default)(url, { - headers: headers, - body: JSON.stringify(parametros), - method: "POST", - }) - .then(function (r) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) { - switch (_a.label) { - case 0: return [4 /*yield*/, r.json()]; - case 1: return [2 /*return*/, _a.sent()]; - } - }); }); }) - .catch(function (e) { - return p_respostas_1.respostaComuns.erro("Erro ao criar vinculo de usuario ".concat(e.message)); - })]; - case 1: return [2 /*return*/, _c.sent()]; - } - }); -}); }; +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_respostas_1 = require("p-respostas"); +const _urlAutenticacao_1 = require("./_urlAutenticacao"); +const usuarios_quipo_vincular = async ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }) => { + const url = `${(0, _urlAutenticacao_1.urlAutenticacao)(ambiente)}/api/vinculos__criar`; + if (!token_produto) + return p_respostas_1.respostaComuns.erro("token_produto não informado"); + const headers = { + token: token_produto, + "Content-Type": "application/json", + }; + const parametros = { + vinculos: { codigo_conta: conta, codigo_usuario, vinculo }, + email: email, + }; + return await (0, cross_fetch_1.default)(url, { + headers, + body: JSON.stringify(parametros), + method: "POST", + }) + .then(async (r) => await r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`)); +}; exports.usuarios_quipo_vincular = usuarios_quipo_vincular; diff --git a/dist-require/autenticacao/_validarToken.js b/dist-require/autenticacao/_validarToken.js index 5a00e0d..dbc3dfb 100644 --- a/dist-require/autenticacao/_validarToken.js +++ b/dist-require/autenticacao/_validarToken.js @@ -1,77 +1,28 @@ "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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.validarToken = void 0; -var _urlAutenticacao_1 = require("./_urlAutenticacao"); -var cross_fetch_1 = __importDefault(require("cross-fetch")); +const _urlAutenticacao_1 = require("./_urlAutenticacao"); +const cross_fetch_1 = __importDefault(require("cross-fetch")); /** faz a validação do token */ -var validarToken = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, resposta, e_1; - var ambiente = _b.ambiente, post = _b.post; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - url = "".concat((0, _urlAutenticacao_1.urlAutenticacao)(ambiente), "/api/validar_token"); - _c.label = 1; - case 1: - _c.trys.push([1, 3, , 4]); - return [4 /*yield*/, (0, cross_fetch_1.default)(url, { - method: "POST", - body: JSON.stringify(post), - headers: { "Content-Type": "application/json" }, - }) - .then(function (r) { return r.json(); }) - .then(function (r) { return r; }) - .then(function (resposta) { - return resposta.eCerto ? "valido" : "erro"; - }) - .catch(function () { return "erro"; })]; - case 2: - resposta = _c.sent(); - return [2 /*return*/, resposta]; - case 3: - e_1 = _c.sent(); - return [2 /*return*/, "erro"]; - case 4: return [2 /*return*/]; - } - }); -}); }; +const validarToken = async ({ ambiente, post, }) => { + const url = `${(0, _urlAutenticacao_1.urlAutenticacao)(ambiente)}/api/validar_token`; + try { + const resposta = await (0, cross_fetch_1.default)(url, { + method: "POST", + body: JSON.stringify(post), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .then((r) => r) + .then((resposta) => resposta.eCerto ? "valido" : "erro") + .catch(() => "erro"); + return resposta; + } + catch (e) { + return "erro"; + } +}; exports.validarToken = validarToken; diff --git a/dist-require/autenticacao/index.js b/dist-require/autenticacao/index.js index 911f237..91997a9 100644 --- a/dist-require/autenticacao/index.js +++ b/dist-require/autenticacao/index.js @@ -1,11 +1,11 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pAutenticacao = void 0; -var _codigoContaSite_1 = require("./_codigoContaSite"); -var _urlAutenticacao_1 = require("./_urlAutenticacao"); -var _usuarios_quipo_governo_1 = require("./_usuarios_quipo_governo"); -var _usuarios_quipo_vincular_1 = require("./_usuarios_quipo_vincular"); -var _validarToken_1 = require("./_validarToken"); +const _codigoContaSite_1 = require("./_codigoContaSite"); +const _urlAutenticacao_1 = require("./_urlAutenticacao"); +const _usuarios_quipo_governo_1 = require("./_usuarios_quipo_governo"); +const _usuarios_quipo_vincular_1 = require("./_usuarios_quipo_vincular"); +const _validarToken_1 = require("./_validarToken"); /** todas as rotas de comunicação com autenticador partem dessa variável */ exports.pAutenticacao = { validarToken: _validarToken_1.validarToken, diff --git a/dist-require/pilao-de-dados/_deletar_registros.js b/dist-require/pilao-de-dados/_deletar_registros.js index 9c18633..27fb855 100644 --- a/dist-require/pilao-de-dados/_deletar_registros.js +++ b/dist-require/pilao-de-dados/_deletar_registros.js @@ -1,87 +1,35 @@ "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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.deletar_registros = exports.zp_deletar_registros = void 0; -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var p_respostas_1 = require("p-respostas"); -var zod_1 = require("zod"); -var variaveis_1 = require("./variaveis"); +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_respostas_1 = require("p-respostas"); +const zod_1 = require("zod"); +const variaveis_1 = require("./variaveis"); //enviar registros para base de dados exports.zp_deletar_registros = zod_1.z.object({ tabela: zod_1.z.string(), codigos: zod_1.z.array(zod_1.z.string()), }); -var deletar_registros = function (_a) { - var conta = _a.conta, produto = _a.produto, emDesenvolvimento = _a.emDesenvolvimento; - return function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, tamanhoBlocos, bloco, resp; - var codigos = _b.codigos, tabela = _b.tabela; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - url = new URL("".concat((0, variaveis_1.urlPilao)(emDesenvolvimento).api, "/").concat(Object.keys({ deletar_registros: exports.deletar_registros })[0], "/").concat(produto, "/").concat(conta)); - tamanhoBlocos = 1000; - _c.label = 1; - case 1: - if (!(codigos.length > 0)) return [3 /*break*/, 3]; - bloco = codigos.splice(0, tamanhoBlocos); - return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: tabela, codigos: bloco }), - 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 2: - resp = _c.sent(); - if (resp.eErro) { - return [2 /*return*/, resp]; - } - return [3 /*break*/, 1]; - case 3: return [2 /*return*/, p_respostas_1.respostaComuns.valor(true)]; - } - }); - }); }; +const deletar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ codigos, tabela, }) => { + const url = new URL(`${(0, variaveis_1.urlPilao)(emDesenvolvimento).api}/${Object.keys({ deletar_registros: exports.deletar_registros })[0]}/${produto}/${conta}`); + const tamanhoBlocos = 1000; + while (codigos.length > 0) { + const bloco = codigos.splice(0, tamanhoBlocos); + const resp = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela, codigos: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + return p_respostas_1.respostaComuns.valor(true); }; exports.deletar_registros = deletar_registros; diff --git a/dist-require/pilao-de-dados/_enviar_registros.js b/dist-require/pilao-de-dados/_enviar_registros.js index b815567..5629b41 100644 --- a/dist-require/pilao-de-dados/_enviar_registros.js +++ b/dist-require/pilao-de-dados/_enviar_registros.js @@ -1,65 +1,13 @@ "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 }; - } -}; -var __read = (this && this.__read) || function (o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); - } - catch (error) { e = { error: error }; } - finally { - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } - finally { if (e) throw e.error; } - } - return ar; -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.enviar_registros = exports.zp_enviar_registros = exports.zp_registrar_base_dados = void 0; -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var p_respostas_1 = require("p-respostas"); -var zod_1 = require("zod"); -var variaveis_1 = require("./variaveis"); +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_respostas_1 = require("p-respostas"); +const zod_1 = require("zod"); +const variaveis_1 = require("./variaveis"); exports.zp_registrar_base_dados = zod_1.z.object({ tabela: zod_1.z.string(), colunas: zod_1.z.array(zod_1.z.object({ @@ -75,46 +23,25 @@ exports.zp_enviar_registros = zod_1.z.object({ tipo: variaveis_1.z_tipo_coluna_base_dados.optional().nullable(), }))), }); -var enviar_registros = function (_a) { - var conta = _a.conta, produto = _a.produto, emDesenvolvimento = _a.emDesenvolvimento; - return function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) { - var url, tamanhoBlocos, bloco, resp; - var registros = _b.registros, tabela = _b.tabela; - return __generator(this, function (_c) { - switch (_c.label) { - case 0: - url = new URL("".concat((0, variaveis_1.urlPilao)(emDesenvolvimento).api, "/").concat(Object.keys({ enviar_registros: exports.enviar_registros })[0], "/").concat(produto, "/").concat(conta)); - tamanhoBlocos = 1000; - _c.label = 1; - case 1: - if (!(registros.length > 0)) return [3 /*break*/, 3]; - bloco = registros - .splice(0, tamanhoBlocos) - .map(function (r) { - return Object.fromEntries(Object.entries(r).map(function (_a) { - var _b = __read(_a, 2), k = _b[0], v = _b[1]; - return [k, v === undefined ? null : v]; - })); - }); - return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify({ tabela: tabela, registros: bloco }), - 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 2: - resp = _c.sent(); - if (resp.eErro) { - return [2 /*return*/, resp]; - } - return [3 /*break*/, 1]; - case 3: return [2 /*return*/, p_respostas_1.respostaComuns.valor(true)]; - } - }); - }); }; +const enviar_registros = ({ conta, produto, emDesenvolvimento }) => async ({ registros, tabela, }) => { + const url = new URL(`${(0, variaveis_1.urlPilao)(emDesenvolvimento).api}/${Object.keys({ enviar_registros: exports.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 = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify({ tabela, registros: bloco }), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + if (resp.eErro) { + return resp; + } + } + return p_respostas_1.respostaComuns.valor(true); }; exports.enviar_registros = enviar_registros; diff --git a/dist-require/pilao-de-dados/_serie_consultar.d.ts b/dist-require/pilao-de-dados/_serie_consultar.d.ts index c763ce5..0734d6c 100644 --- a/dist-require/pilao-de-dados/_serie_consultar.d.ts +++ b/dist-require/pilao-de-dados/_serie_consultar.d.ts @@ -6,16 +6,39 @@ export declare const zp_serie_registrar: z.ZodObject<{ colanuEixoX: z.ZodString; colunaAgrupamento: z.ZodOptional>; agregacao: z.ZodEnum<["contagem", "somatoria"]>; + filtro: z.ZodOptional", "<", ">=", "<=", "∩"]>; + }, "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) => (parametros: z.infer) => { dados: () => Promise 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 }; - } -}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.serie_consultar = exports.zp_serie_registrar = void 0; -var cross_fetch_1 = __importDefault(require("cross-fetch")); -var p_respostas_1 = require("p-respostas"); -var zod_1 = require("zod"); -var variaveis_1 = require("./variaveis"); +const cross_fetch_1 = __importDefault(require("cross-fetch")); +const p_respostas_1 = require("p-respostas"); +const zod_1 = require("zod"); +const variaveis_1 = require("./variaveis"); +const filtro = zod_1.z.object({ + coluna: zod_1.z.string(), + valor: zod_1.z.string(), + operador: variaveis_1.operadores_pilao, +}); exports.zp_serie_registrar = zod_1.z.object({ tabela: zod_1.z.string(), colanuEixoX: zod_1.z.string(), colunaAgrupamento: zod_1.z.string().array().optional(), agregacao: variaveis_1.tiposSeriesAgregacoes, + filtro: filtro.array().optional(), }); -var serie_consultar = function (cliente) { - return function (parametros) { - 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((0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).api, "/").concat(variaveis_1.tiposSeriesAgregacoes.enum.contagem, "/").concat(cliente.produto, "/").concat(cliente.conta)); - return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), { - method: "POST", - body: JSON.stringify(parametros), - 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((0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).site, "/").concat(variaveis_1.tiposSeriesAgregacoes.enum.contagem, "/").concat(cliente.produto, "/").concat(cliente.conta)); - var serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); - return "".concat(vUrl.href, "?serie=").concat(serie); - }; - return { - dados: dados, - url: url, - }; +const serie_consultar = (cliente) => (parametros) => { + const dados = async () => { + const url = new URL(`${(0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).api}/${variaveis_1.tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`); + const resp = await (0, cross_fetch_1.default)(url.toString(), { + method: "POST", + body: JSON.stringify(parametros), + headers: { "Content-Type": "application/json" }, + }) + .then((r) => r.json()) + .catch((e) => p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message])) + .then((r) => r); + return resp; + }; + const url = () => { + const vUrl = new URL(`${(0, variaveis_1.urlPilao)(cliente.emDesenvolvimento).site}/${variaveis_1.tiposSeriesAgregacoes.enum.contagem}/${cliente.produto}/${cliente.conta}`); + const serie = encodeURIComponent(JSON.stringify(parametros, null, 2)); + return `${vUrl.href}?serie=${serie}`; + }; + return { + dados, + url, }; }; exports.serie_consultar = serie_consultar; diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 6bcb8ad..a342bab 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -61,16 +61,39 @@ export declare const pPilao: { colanuEixoX: import("zod").ZodString; colunaAgrupamento: import("zod").ZodOptional>; agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>; + filtro: import("zod").ZodOptional", "<", ">=", "<=", "∩"]>; + }, "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) => (parametros: import("zod").TypeOf) => { dados: () => Promise; + operadores_pilao: import("zod").ZodEnum<["=", "!=", ">", "<", ">=", "<=", "∩"]>; + operadores_permitidos_por_tipo: { + texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + confirmacao: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + lista_texto: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + lista_numero: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + data: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + mes: ("=" | "!=" | ">" | "<" | ">=" | "<=" | "∩")[]; + }; }; diff --git a/dist-require/pilao-de-dados/index.js b/dist-require/pilao-de-dados/index.js index 24520e4..ccf29d8 100644 --- a/dist-require/pilao-de-dados/index.js +++ b/dist-require/pilao-de-dados/index.js @@ -1,14 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pPilao = exports.tiposSeriesAgregacoes = exports.urlPilao = exports.PREFIXO_PILAO = void 0; -var _deletar_registros_1 = require("./_deletar_registros"); +const _deletar_registros_1 = require("./_deletar_registros"); var variaveis_1 = require("./variaveis"); Object.defineProperty(exports, "PREFIXO_PILAO", { enumerable: true, get: function () { return variaveis_1.PREFIXO_PILAO; } }); Object.defineProperty(exports, "urlPilao", { enumerable: true, get: function () { return variaveis_1.urlPilao; } }); -var _enviar_registros_1 = require("./_enviar_registros"); -var variaveis_2 = require("./variaveis"); +const _enviar_registros_1 = require("./_enviar_registros"); +const variaveis_2 = require("./variaveis"); Object.defineProperty(exports, "tiposSeriesAgregacoes", { enumerable: true, get: function () { return variaveis_2.tiposSeriesAgregacoes; } }); -var _serie_consultar_1 = require("./_serie_consultar"); +const _serie_consultar_1 = require("./_serie_consultar"); exports.pPilao = { zp_registrar_base_dados: _enviar_registros_1.zp_registrar_base_dados, enviar_registros: _enviar_registros_1.enviar_registros, @@ -19,4 +19,6 @@ exports.pPilao = { validarZ: variaveis_2.validarZ, deletar_registros: _deletar_registros_1.deletar_registros, zp_deletar_registros: _deletar_registros_1.zp_deletar_registros, + operadores_pilao: variaveis_2.operadores_pilao, + operadores_permitidos_por_tipo: variaveis_2.operadores_permitidos_por_tipo, }; diff --git a/dist-require/pilao-de-dados/variaveis.d.ts b/dist-require/pilao-de-dados/variaveis.d.ts index 7813069..55e2f5b 100644 --- a/dist-require/pilao-de-dados/variaveis.d.ts +++ b/dist-require/pilao-de-dados/variaveis.d.ts @@ -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]: z.infer[]; +}; export declare const tiposSeriesAgregacoes: z.ZodEnum<["contagem", "somatoria"]>; export declare const z_validar_colunna_base_dados: { texto: z.ZodNullable; diff --git a/dist-require/pilao-de-dados/variaveis.js b/dist-require/pilao-de-dados/variaveis.js index 54c7ce3..6adbf3a 100644 --- a/dist-require/pilao-de-dados/variaveis.js +++ b/dist-require/pilao-de-dados/variaveis.js @@ -1,14 +1,14 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); -exports.urlPilao = exports.z_validar_colunna_base_dados = exports.tiposSeriesAgregacoes = exports.z_tipo_coluna_base_dados = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = void 0; -var p_respostas_1 = require("p-respostas"); -var zod_1 = require("zod"); +exports.urlPilao = exports.z_validar_colunna_base_dados = exports.tiposSeriesAgregacoes = exports.operadores_permitidos_por_tipo = exports.operadores_pilao = exports.z_tipo_coluna_base_dados = exports.zp_produto_conta = exports.validarZ = exports.PREFIXO_PILAO = exports.zAmbiente = void 0; +const p_respostas_1 = require("p-respostas"); +const zod_1 = require("zod"); exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]); exports.PREFIXO_PILAO = "/pilao-de-dados"; -var validarZ = function (zodType, objeto, mensagem) { - var validar = zodType.safeParse(objeto); +const validarZ = (zodType, objeto, mensagem) => { + const validar = zodType.safeParse(objeto); if (!validar.success) { - 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.erro(mensagem, validar.error.errors.map((e) => `${e.path} ${e.message}`)); } return p_respostas_1.respostaComuns.valor(validar.data); }; @@ -27,6 +27,16 @@ exports.z_tipo_coluna_base_dados = zod_1.z.enum([ "data", "mes", ]); +exports.operadores_pilao = zod_1.z.enum(["=", "!=", ">", "<", ">=", "<=", "∩"]); +exports.operadores_permitidos_por_tipo = { + confirmacao: ["=", "!="], + data: ["=", "!=", ">", "<", ">=", "<="], + lista_numero: ["∩"], + lista_texto: ["∩"], + mes: ["=", "!=", ">", "<", ">=", "<="], + numero: ["=", "!=", ">", "<", ">=", "<="], + texto: ["=", "!="], +}; exports.tiposSeriesAgregacoes = zod_1.z.enum(["contagem", "somatoria"]); exports.z_validar_colunna_base_dados = { texto: zod_1.z.string().nullable(), @@ -35,12 +45,12 @@ exports.z_validar_colunna_base_dados = { lista_texto: zod_1.z.array(zod_1.z.string()).nullable(), lista_numero: zod_1.z.array(zod_1.z.number()).nullable(), }; -var urlPilao = function (emDesenvolvimento) { return ({ +const urlPilao = (emDesenvolvimento) => ({ api: (emDesenvolvimento ? "http://127.0.0.1:5080" : "https://carro-de-boi.idz.one") + exports.PREFIXO_PILAO, site: (emDesenvolvimento ? "http://127.0.0.1:5081" : "https://carro-de-boi.idz.one") + exports.PREFIXO_PILAO, -}); }; +}); exports.urlPilao = urlPilao; diff --git a/dist-require/produtos/index.js b/dist-require/produtos/index.js index 9c0364e..e89ff30 100644 --- a/dist-require/produtos/index.js +++ b/dist-require/produtos/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.chaves_produto = void 0; -var zod_1 = require("zod"); +const zod_1 = require("zod"); exports.chaves_produto = zod_1.z.enum([ "suporte", "betha-meio-ambiente", diff --git a/dist-require/residuos/index.js b/dist-require/residuos/index.js index f0db4a4..974fa52 100644 --- a/dist-require/residuos/index.js +++ b/dist-require/residuos/index.js @@ -1,7 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.zAuntenticacaoResiduos = void 0; -var zod_1 = require("zod"); +const zod_1 = require("zod"); exports.zAuntenticacaoResiduos = zod_1.z.object({ // usuários codigo_usuario: zod_1.z.string().uuid(), diff --git a/dist-require/tokenQuipo.js b/dist-require/tokenQuipo.js index fc67bea..473b6fa 100644 --- a/dist-require/tokenQuipo.js +++ b/dist-require/tokenQuipo.js @@ -1,8 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ztokenQuipo = exports.tipos_acesso_quipo = void 0; -var zod_1 = require("zod"); -var produtos_1 = require("./produtos"); +const zod_1 = require("zod"); +const produtos_1 = require("./produtos"); exports.tipos_acesso_quipo = zod_1.z.enum(["publico", "governo", "sociedade"]); exports.ztokenQuipo = zod_1.z.object({ provedor: zod_1.z.string(), diff --git a/dist-require/ts/ambiente.js b/dist-require/ts/ambiente.js index 38d7d9c..d520fff 100644 --- a/dist-require/ts/ambiente.js +++ b/dist-require/ts/ambiente.js @@ -1,5 +1,5 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.zAmbiente = void 0; -var zod_1 = require("zod"); +const zod_1 = require("zod"); exports.zAmbiente = zod_1.z.enum(["desenvolvimento", "producao"]); diff --git a/package.json b/package.json index a5759e3..7abad5c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.112.0", + "version": "0.114.0", "description": "", "main": "src/index.ts", "exports": { diff --git a/src/pilao-de-dados/_serie_consultar.ts b/src/pilao-de-dados/_serie_consultar.ts index 7b5e303..4ffd3f0 100644 --- a/src/pilao-de-dados/_serie_consultar.ts +++ b/src/pilao-de-dados/_serie_consultar.ts @@ -3,16 +3,24 @@ import type { tipoResposta } from "p-respostas" import { respostaComuns } from "p-respostas" import { z } from "zod" import { + operadores_pilao, tiposSeriesAgregacoes, urlPilao, type zp_produto_conta, } 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 = diff --git a/src/pilao-de-dados/index.ts b/src/pilao-de-dados/index.ts index 141ef57..70ce3af 100644 --- a/src/pilao-de-dados/index.ts +++ b/src/pilao-de-dados/index.ts @@ -5,7 +5,13 @@ import { 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" @@ -21,4 +27,6 @@ export const pPilao = { validarZ, deletar_registros, zp_deletar_registros, + operadores_pilao, + operadores_permitidos_por_tipo, } diff --git a/src/pilao-de-dados/variaveis.ts b/src/pilao-de-dados/variaveis.ts index d53ee47..be1d3c2 100644 --- a/src/pilao-de-dados/variaveis.ts +++ b/src/pilao-de-dados/variaveis.ts @@ -36,6 +36,22 @@ export const z_tipo_coluna_base_dados = z.enum([ "mes", ]) +export const operadores_pilao = z.enum(["=", "!=", ">", "<", ">=", "<=", "∩"]) + +export const operadores_permitidos_por_tipo: { + [key in z.infer]: z.infer< + typeof operadores_pilao + >[] +} = { + confirmacao: ["=", "!="], + data: ["=", "!=", ">", "<", ">=", "<="], + lista_numero: ["∩"], + lista_texto: ["∩"], + mes: ["=", "!=", ">", "<", ">=", "<="], + numero: ["=", "!=", ">", "<", ">=", "<="], + texto: ["=", "!="], +} + export const tiposSeriesAgregacoes = z.enum(["contagem", "somatoria"]) export const z_validar_colunna_base_dados = { diff --git a/tsconfig-import.json b/tsconfig-import.json index 48380f3..34d1f96 100644 --- a/tsconfig-import.json +++ b/tsconfig-import.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./dist-import", - "target": "ES2015", + "target": "ES2020", "module": "ES2015", "declaration": true, } diff --git a/tsconfig-require.json b/tsconfig-require.json index 46298e1..b1a09c3 100644 --- a/tsconfig-require.json +++ b/tsconfig-require.json @@ -2,7 +2,7 @@ "extends": "./tsconfig.json", "compilerOptions": { "module": "commonjs", - "target": "ES5", + "target": "ES2020", "outDir": "./dist-require", "declaration": true, }, diff --git a/tsconfig.json b/tsconfig.json index 90a7a0d..06f290a 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "lib": ["es5", "es6", "es7", "esnext", "dom"], - "target": "es2018", + "target": "ES2020", "removeComments": false, "esModuleInterop": true, "moduleResolution": "node",