This commit is contained in:
Luiz H. R. Silva 2024-06-19 17:47:48 -03:00
parent a6205f1ab6
commit e580643abc
40 changed files with 329 additions and 507 deletions

View file

@ -4,10 +4,8 @@ import type { zAmbiente } from "../ts/ambiente";
type tipoPostCodigoContaSite = {
site: string;
};
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
export declare const codigoContaSite: ({ ambiente, post, }: {
ambiente: z.infer<typeof zAmbiente>;
post: tipoPostCodigoContaSite;
/** função que conecta com a API */
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
}) => Promise<tipoResposta<string>>;
export {};

View file

@ -9,10 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
};
import { respostaComuns } from "p-respostas";
import { urlAutenticacao } from "./_urlAutenticacao";
export const codigoContaSite = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () {
import node_fetch from "cross-fetch";
export const codigoContaSite = ({ ambiente, post, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = `${urlAutenticacao(ambiente)}/api/codigo_prefeitura_site`;
try {
const resp = yield buscar(url, post).catch((e) => respostaComuns.erro(`erro ao buscar código do site: ${e}`));
const resp = yield node_fetch(url, {
method: "POST",
body: JSON.stringify(post),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
.then((r) => r);
return resp;
}
catch (e) {

View file

@ -9,10 +9,7 @@ export type tipoUsuarioExterno = {
codigo_conta: string;
chave_produto: string;
};
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, }: {
ambiente: z.infer<typeof zAmbiente>;
token_produto: string;
buscar: (url: string, headers: {
[k: string]: string;
}) => Promise<tipoResposta<tipoUsuarioExterno[]>>;
}) => Promise<tipoResposta<tipoUsuarioExterno[]>>;

View file

@ -7,14 +7,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
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 = ({ token_produto, ambiente, buscar, }) => __awaiter(void 0, void 0, void 0, function* () {
export const usuarios_quipo_governo = ({ token_produto, ambiente, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = `${urlAutenticacao(ambiente)}/api/usuarios_quipo_governo`;
if (!token_produto)
return respostaComuns.erro("token_produto não informado");
const headers = {
token: token_produto,
};
return buscar(url, headers).catch((e) => respostaComuns.erro(`erro ao buscar usuários quipo governo: ${e}`));
return node_fetch(url, {
headers,
})
.then((r) => r.json())
.catch((e) => respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]))
.then((r) => r);
});

View file

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

View file

@ -8,11 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
import { urlAutenticacao } from "./_urlAutenticacao";
import node_fetch from "cross-fetch";
/** faz a validação do token */
export const validarToken = ({ ambiente, post, buscar, }) => __awaiter(void 0, void 0, void 0, function* () {
export const validarToken = ({ ambiente, post, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = `${urlAutenticacao(ambiente)}/api/validar_token`;
try {
const resposta = yield buscar(url, post)
const resposta = yield node_fetch(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;

View file

@ -2,30 +2,21 @@ import { type tipoUsuarioExterno } from "./_usuarios_quipo_governo";
export type { tipoUsuarioExterno };
/** todas as rotas de comunicação com autenticador partem dessa variável */
export declare const pAutenticacao: {
validarToken: ({ ambiente, post, buscar, }: {
validarToken: ({ ambiente, post, }: {
ambiente: "desenvolvimento" | "producao";
post: {
token: string;
};
buscar: (url: string, post: {
token: string;
}) => Promise<import("p-respostas").tipoResposta<any>>;
}) => Promise<"valido" | "erro">;
urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
codigoContaSite: ({ ambiente, post, buscar, }: {
codigoContaSite: ({ ambiente, post, }: {
ambiente: "desenvolvimento" | "producao";
post: {
site: string;
};
buscar: (url: string, post: {
site: string;
}) => Promise<import("p-respostas").tipoResposta<string>>;
}) => Promise<import("p-respostas").tipoResposta<string>>;
usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
usuarios_quipo_governo: ({ token_produto, ambiente, }: {
ambiente: "desenvolvimento" | "producao";
token_produto: string;
buscar: (url: string, headers: {
[k: string]: string;
}) => Promise<import("p-respostas").tipoResposta<tipoUsuarioExterno[]>>;
}) => Promise<import("p-respostas").tipoResposta<tipoUsuarioExterno[]>>;
};

View file

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

View file

@ -20,6 +20,8 @@ export const z_tipo_coluna_base_dados = z.enum([
"confirmacao",
"lista_texto",
"lista_numero",
"data",
"mes",
]);
export const tiposSeriesAgregacoes = z.enum(["contagem", "somatoria"]);
export const z_validar_colunna_base_dados = {

View file

@ -5,50 +5,50 @@ export declare const zp_registrar_base_dados: z.ZodObject<{
tabela: z.ZodString;
colunas: z.ZodArray<z.ZodObject<{
coluna: z.ZodString;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;
}, "strip", z.ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}>;
export declare const zp_enviar_registros: z.ZodObject<{
tabela: z.ZodString;
registros: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodObject<{
valor: z.ZodAny;
tipo: z.ZodNullable<z.ZodOptional<z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>>>;
tipo: z.ZodNullable<z.ZodOptional<z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>>>;
}, "strip", z.ZodTypeAny, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}>;
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {

View file

@ -5,25 +5,25 @@ export declare const pPilao: {
tabela: import("zod").ZodString;
colunas: import("zod").ZodArray<import("zod").ZodObject<{
coluna: import("zod").ZodString;
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;
}, "strip", import("zod").ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}>;
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
@ -36,7 +36,7 @@ export declare const pPilao: {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
@ -44,28 +44,44 @@ export declare const pPilao: {
tabela: import("zod").ZodString;
registros: import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
valor: import("zod").ZodAny;
tipo: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>>>;
tipo: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>>>;
}, "strip", import("zod").ZodTypeAny, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}>;
serie_registrar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
zp_serie_registrar: import("zod").ZodObject<{
tabela: import("zod").ZodString;
colanuEixoX: import("zod").ZodString;
colunaAgrupamento: import("zod").ZodString;
agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
serie_consultar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
@ -73,47 +89,16 @@ export declare const pPilao: {
};
parametros: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
zp_serie_registrar: import("zod").ZodObject<{
tabela: import("zod").ZodString;
identificador: import("zod").ZodString;
colanuEixoX: import("zod").ZodString;
colunaAgrupamento: import("zod").ZodString;
agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
serie_consultar: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
identificador: string;
};
}) => {
dados: () => Promise<import("p-respostas").tipoResposta<{
registros: any[];
legenda: string;
serie: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
@ -121,13 +106,6 @@ export declare const pPilao: {
}>>;
url: () => string;
};
zp_serie_consultar: import("zod").ZodObject<{
identificador: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
identificador: string;
}, {
identificador: string;
}>;
zp_produto_conta: import("zod").ZodObject<{
produto: import("zod").ZodString;
conta: import("zod").ZodString;

View file

@ -1,17 +1,14 @@
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_consultar } from "./serie_consultar";
import { serie_registrar, zp_serie_registrar } from "./serie_registrar";
import { serie_consultar, zp_serie_registrar } from "./serie_consultar";
export { tiposSeriesAgregacoes };
export const pPilao = {
zp_registrar_base_dados,
enviar_registros,
zp_enviar_registros,
serie_registrar,
zp_serie_registrar,
serie_consultar,
zp_serie_consultar,
zp_produto_conta,
validarZ,
deletar_registros,

View file

@ -1,19 +1,27 @@
import type { tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
import type { zp_serie_registrar } from "./serie_registrar";
export declare const zp_serie_consultar: z.ZodObject<{
identificador: z.ZodString;
export declare const zp_serie_registrar: z.ZodObject<{
tabela: z.ZodString;
colanuEixoX: z.ZodString;
colunaAgrupamento: z.ZodString;
agregacao: z.ZodEnum<["contagem", "somatoria"]>;
}, "strip", z.ZodTypeAny, {
identificador: string;
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
identificador: string;
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
export declare const serie_consultar: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
export declare const serie_consultar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
parametros: z.infer<typeof zp_serie_consultar>;
parametros: z.infer<typeof zp_serie_registrar>;
}) => {
dados: () => Promise<tipoResposta<{
registros: any[];

View file

@ -11,17 +11,22 @@ import node_fetch from "cross-fetch";
import { respostaComuns } from "p-respostas";
import { z } from "zod";
import { PREFIXO, baseUrlPilao, tiposSeriesAgregacoes, } from "./_variaveis";
//consultar compilação
export const zp_serie_consultar = z.object({
identificador: z.string(),
export const zp_serie_registrar = z.object({
tabela: z.string(),
colanuEixoX: z.string(),
colunaAgrupamento: z.string(),
agregacao: tiposSeriesAgregacoes,
});
export const serie_consultar = ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }) => {
export const serie_consultar = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela }, }) => {
const dados = () => __awaiter(void 0, void 0, void 0, function* () {
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${`${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}/${produto}/${conta}`}`);
const resp = yield node_fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
identificador,
agregacao,
colanuEixoX,
colunaAgrupamento,
tabela,
}),
headers: { "Content-Type": "application/json" },
})
@ -31,12 +36,20 @@ export const serie_consultar = ({ emDesenvolvimento, parametros: { identificador
return resp;
});
const url = () => {
const pr = {
produto,
conta,
agregacao,
colanuEixoX,
colunaAgrupamento,
tabela,
};
const vUrl = new URL(`${emDesenvolvimento
? "http://127.0.0.1:5081"
: "https://carro-de-boi.idz.one"}${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}`);
vUrl.searchParams.append("produto", produto);
vUrl.searchParams.append("conta", conta);
vUrl.searchParams.append("identificador", identificador);
for (const [k, v] of Object.entries(pr)) {
vUrl.searchParams.append(k, JSON.stringify(v));
}
return vUrl.href;
};
return {

View file

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

View file

@ -1,40 +0,0 @@
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import node_fetch from "cross-fetch";
import { respostaComuns } from "p-respostas";
import { z } from "zod";
import { PREFIXO, baseUrlPilao, tiposSeriesAgregacoes, } from "./_variaveis";
//registrar serie
export const zp_serie_registrar = z.object({
tabela: z.string(),
identificador: z.string(),
colanuEixoX: z.string(),
colunaAgrupamento: z.string(),
agregacao: tiposSeriesAgregacoes,
});
export const serie_registrar = ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }) => __awaiter(void 0, void 0, void 0, function* () {
const url = new URL(`${baseUrlPilao(emDesenvolvimento)}${`${PREFIXO}/${Object.keys({ serie_registrar })[0]}/${produto}/${conta}`}`);
const resp = yield node_fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
tabela,
agregacao,
emDesenvolvimento,
colanuEixoX,
colunaAgrupamento,
identificador,
}),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
.then((r) => r);
return resp;
});

View file

@ -4,10 +4,8 @@ import type { zAmbiente } from "../ts/ambiente";
type tipoPostCodigoContaSite = {
site: string;
};
export declare const codigoContaSite: ({ ambiente, post, buscar, }: {
export declare const codigoContaSite: ({ ambiente, post, }: {
ambiente: z.infer<typeof zAmbiente>;
post: tipoPostCodigoContaSite;
/** função que conecta com a API */
buscar: (url: string, post: tipoPostCodigoContaSite) => Promise<tipoResposta<string>>;
}) => Promise<tipoResposta<string>>;
export {};

View file

@ -35,12 +35,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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) {
var ambiente = _a.ambiente, post = _a.post, buscar = _a.buscar;
var ambiente = _a.ambiente, post = _a.post;
return __awaiter(void 0, void 0, void 0, function () {
var url, resp, e_1;
return __generator(this, function (_b) {
@ -50,9 +54,16 @@ var codigoContaSite = function (_a) {
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, buscar(url, post).catch(function (e) {
return p_respostas_1.respostaComuns.erro("erro ao buscar c\u00F3digo do site: ".concat(e));
})];
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 = _b.sent();
return [2 /*return*/, resp];

View file

@ -9,10 +9,7 @@ export type tipoUsuarioExterno = {
codigo_conta: string;
chave_produto: string;
};
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
export declare const usuarios_quipo_governo: ({ token_produto, ambiente, }: {
ambiente: z.infer<typeof zAmbiente>;
token_produto: string;
buscar: (url: string, headers: {
[k: string]: string;
}) => Promise<tipoResposta<tipoUsuarioExterno[]>>;
}) => Promise<tipoResposta<tipoUsuarioExterno[]>>;

View file

@ -35,12 +35,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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) {
var token_produto = _a.token_produto, ambiente = _a.ambiente, buscar = _a.buscar;
var token_produto = _a.token_produto, ambiente = _a.ambiente;
return __awaiter(void 0, void 0, void 0, function () {
var url, headers;
return __generator(this, function (_b) {
@ -50,9 +54,14 @@ var usuarios_quipo_governo = function (_a) {
headers = {
token: token_produto,
};
return [2 /*return*/, buscar(url, headers).catch(function (e) {
return p_respostas_1.respostaComuns.erro("erro ao buscar usu\u00E1rios quipo governo: ".concat(e));
})];
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ários quipo governo", [e.message]);
})
.then(function (r) { return r; })];
});
});
};

View file

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

View file

@ -35,12 +35,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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"));
/** faz a validação do token */
var validarToken = function (_a) {
var ambiente = _a.ambiente, post = _a.post, buscar = _a.buscar;
var ambiente = _a.ambiente, post = _a.post;
return __awaiter(void 0, void 0, void 0, function () {
var url, resposta, e_1;
return __generator(this, function (_b) {
@ -50,7 +54,13 @@ var validarToken = function (_a) {
_b.label = 1;
case 1:
_b.trys.push([1, 3, , 4]);
return [4 /*yield*/, buscar(url, post)
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";
})

View file

@ -2,30 +2,21 @@ import { type tipoUsuarioExterno } from "./_usuarios_quipo_governo";
export type { tipoUsuarioExterno };
/** todas as rotas de comunicação com autenticador partem dessa variável */
export declare const pAutenticacao: {
validarToken: ({ ambiente, post, buscar, }: {
validarToken: ({ ambiente, post, }: {
ambiente: "desenvolvimento" | "producao";
post: {
token: string;
};
buscar: (url: string, post: {
token: string;
}) => Promise<import("p-respostas").tipoResposta<any>>;
}) => Promise<"valido" | "erro">;
urlAutenticacao: (ambiente: "desenvolvimento" | "producao") => string;
codigoContaSite: ({ ambiente, post, buscar, }: {
codigoContaSite: ({ ambiente, post, }: {
ambiente: "desenvolvimento" | "producao";
post: {
site: string;
};
buscar: (url: string, post: {
site: string;
}) => Promise<import("p-respostas").tipoResposta<string>>;
}) => Promise<import("p-respostas").tipoResposta<string>>;
usuarios_quipo_governo: ({ token_produto, ambiente, buscar, }: {
usuarios_quipo_governo: ({ token_produto, ambiente, }: {
ambiente: "desenvolvimento" | "producao";
token_produto: string;
buscar: (url: string, headers: {
[k: string]: string;
}) => Promise<import("p-respostas").tipoResposta<tipoUsuarioExterno[]>>;
}) => Promise<import("p-respostas").tipoResposta<tipoUsuarioExterno[]>>;
};

View file

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

View file

@ -24,6 +24,8 @@ exports.z_tipo_coluna_base_dados = zod_1.z.enum([
"confirmacao",
"lista_texto",
"lista_numero",
"data",
"mes",
]);
exports.tiposSeriesAgregacoes = zod_1.z.enum(["contagem", "somatoria"]);
exports.z_validar_colunna_base_dados = {

View file

@ -5,50 +5,50 @@ export declare const zp_registrar_base_dados: z.ZodObject<{
tabela: z.ZodString;
colunas: z.ZodArray<z.ZodObject<{
coluna: z.ZodString;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
tipo: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;
}, "strip", z.ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}>;
export declare const zp_enviar_registros: z.ZodObject<{
tabela: z.ZodString;
registros: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodObject<{
valor: z.ZodAny;
tipo: z.ZodNullable<z.ZodOptional<z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>>>;
tipo: z.ZodNullable<z.ZodOptional<z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>>>;
}, "strip", z.ZodTypeAny, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>>, "many">;
}, "strip", z.ZodTypeAny, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}>;
export declare const enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {

View file

@ -5,25 +5,25 @@ export declare const pPilao: {
tabela: import("zod").ZodString;
colunas: import("zod").ZodArray<import("zod").ZodObject<{
coluna: import("zod").ZodString;
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>;
tipo: import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;
}, "strip", import("zod").ZodTypeAny, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}, {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}, {
tabela: string;
colunas: {
coluna: string;
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero";
tipo: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes";
}[];
}>;
enviar_registros: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { registros, tabela }, }: {
@ -36,7 +36,7 @@ export declare const pPilao: {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
@ -44,28 +44,44 @@ export declare const pPilao: {
tabela: import("zod").ZodString;
registros: import("zod").ZodArray<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
valor: import("zod").ZodAny;
tipo: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero"]>>>;
tipo: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>>>;
}, "strip", import("zod").ZodTypeAny, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>>, "many">;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}, {
tabela: string;
registros: Record<string, {
valor?: any;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | null | undefined;
tipo?: "texto" | "numero" | "confirmacao" | "lista_texto" | "lista_numero" | "data" | "mes" | null | undefined;
}>[];
}>;
serie_registrar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, identificador, tabela, }, }: {
zp_serie_registrar: import("zod").ZodObject<{
tabela: import("zod").ZodString;
colanuEixoX: import("zod").ZodString;
colunaAgrupamento: import("zod").ZodString;
agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
serie_consultar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
@ -73,47 +89,16 @@ export declare const pPilao: {
};
parametros: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
};
}) => Promise<import("p-respostas").tipoResposta<true>>;
zp_serie_registrar: import("zod").ZodObject<{
tabela: import("zod").ZodString;
identificador: import("zod").ZodString;
colanuEixoX: import("zod").ZodString;
colunaAgrupamento: import("zod").ZodString;
agregacao: import("zod").ZodEnum<["contagem", "somatoria"]>;
}, "strip", import("zod").ZodTypeAny, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
serie_consultar: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
emDesenvolvimento?: boolean | null | undefined;
cliente: {
produto: string;
conta: string;
};
parametros: {
identificador: string;
};
}) => {
dados: () => Promise<import("p-respostas").tipoResposta<{
registros: any[];
legenda: string;
serie: {
tabela: string;
identificador: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
@ -121,13 +106,6 @@ export declare const pPilao: {
}>>;
url: () => string;
};
zp_serie_consultar: import("zod").ZodObject<{
identificador: import("zod").ZodString;
}, "strip", import("zod").ZodTypeAny, {
identificador: string;
}, {
identificador: string;
}>;
zp_produto_conta: import("zod").ZodObject<{
produto: import("zod").ZodString;
conta: import("zod").ZodString;

View file

@ -6,15 +6,12 @@ Object.defineProperty(exports, "tiposSeriesAgregacoes", { enumerable: true, get:
var deletar_registros_1 = require("./deletar_registros");
var enviar_registros_1 = require("./enviar_registros");
var serie_consultar_1 = require("./serie_consultar");
var serie_registrar_1 = require("./serie_registrar");
exports.pPilao = {
zp_registrar_base_dados: enviar_registros_1.zp_registrar_base_dados,
enviar_registros: enviar_registros_1.enviar_registros,
zp_enviar_registros: enviar_registros_1.zp_enviar_registros,
serie_registrar: serie_registrar_1.serie_registrar,
zp_serie_registrar: serie_registrar_1.zp_serie_registrar,
zp_serie_registrar: serie_consultar_1.zp_serie_registrar,
serie_consultar: serie_consultar_1.serie_consultar,
zp_serie_consultar: serie_consultar_1.zp_serie_consultar,
zp_produto_conta: _variaveis_1.zp_produto_conta,
validarZ: _variaveis_1.validarZ,
deletar_registros: deletar_registros_1.deletar_registros,

View file

@ -1,19 +1,27 @@
import type { tipoResposta } from "p-respostas";
import { z } from "zod";
import { type zp_produto_conta } from "./_variaveis";
import type { zp_serie_registrar } from "./serie_registrar";
export declare const zp_serie_consultar: z.ZodObject<{
identificador: z.ZodString;
export declare const zp_serie_registrar: z.ZodObject<{
tabela: z.ZodString;
colanuEixoX: z.ZodString;
colunaAgrupamento: z.ZodString;
agregacao: z.ZodEnum<["contagem", "somatoria"]>;
}, "strip", z.ZodTypeAny, {
identificador: string;
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}, {
identificador: string;
tabela: string;
colanuEixoX: string;
colunaAgrupamento: string;
agregacao: "contagem" | "somatoria";
}>;
export declare const serie_consultar: ({ emDesenvolvimento, parametros: { identificador }, cliente: { conta, produto }, }: {
export declare const serie_consultar: ({ emDesenvolvimento, cliente: { conta, produto }, parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela }, }: {
emDesenvolvimento?: boolean | undefined | null;
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>;
parametros: z.infer<typeof zp_serie_consultar>;
parametros: z.infer<typeof zp_serie_registrar>;
}) => {
dados: () => Promise<tipoResposta<{
registros: any[];

View file

@ -35,21 +35,50 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
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;
};
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_consultar = void 0;
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");
//consultar compilação
exports.zp_serie_consultar = zod_1.z.object({
identificador: zod_1.z.string(),
exports.zp_serie_registrar = zod_1.z.object({
tabela: zod_1.z.string(),
colanuEixoX: zod_1.z.string(),
colunaAgrupamento: zod_1.z.string(),
agregacao: _variaveis_1.tiposSeriesAgregacoes,
});
var serie_consultar = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, identificador = _a.parametros.identificador, _b = _a.cliente, conta = _b.conta, produto = _b.produto;
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, agregacao = _c.agregacao, colanuEixoX = _c.colanuEixoX, colunaAgrupamento = _c.colunaAgrupamento, tabela = _c.tabela;
var dados = function () { return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_a) {
@ -59,7 +88,10 @@ var serie_consultar = function (_a) {
return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), {
method: "POST",
body: JSON.stringify({
identificador: identificador,
agregacao: agregacao,
colanuEixoX: colanuEixoX,
colunaAgrupamento: colunaAgrupamento,
tabela: tabela,
}),
headers: { "Content-Type": "application/json" },
})
@ -75,12 +107,31 @@ var serie_consultar = function (_a) {
});
}); };
var url = function () {
var e_1, _a;
var pr = {
produto: produto,
conta: conta,
agregacao: agregacao,
colanuEixoX: colanuEixoX,
colunaAgrupamento: colunaAgrupamento,
tabela: tabela,
};
var vUrl = new URL("".concat(emDesenvolvimento
? "http://127.0.0.1:5081"
: "https://carro-de-boi.idz.one").concat(_variaveis_1.PREFIXO, "/").concat(_variaveis_1.tiposSeriesAgregacoes.enum.contagem));
vUrl.searchParams.append("produto", produto);
vUrl.searchParams.append("conta", conta);
vUrl.searchParams.append("identificador", identificador);
try {
for (var _b = __values(Object.entries(pr)), _c = _b.next(); !_c.done; _c = _b.next()) {
var _d = __read(_c.value, 2), k = _d[0], v = _d[1];
vUrl.searchParams.append(k, JSON.stringify(v));
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
return vUrl.href;
};
return {

View file

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

View file

@ -1,85 +0,0 @@
"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.serie_registrar = 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");
//registrar serie
exports.zp_serie_registrar = zod_1.z.object({
tabela: zod_1.z.string(),
identificador: zod_1.z.string(),
colanuEixoX: zod_1.z.string(),
colunaAgrupamento: zod_1.z.string(),
agregacao: _variaveis_1.tiposSeriesAgregacoes,
});
var serie_registrar = function (_a) {
var emDesenvolvimento = _a.emDesenvolvimento, _b = _a.cliente, conta = _b.conta, produto = _b.produto, _c = _a.parametros, agregacao = _c.agregacao, colanuEixoX = _c.colanuEixoX, colunaAgrupamento = _c.colunaAgrupamento, identificador = _c.identificador, tabela = _c.tabela;
return __awaiter(void 0, void 0, void 0, function () {
var url, resp;
return __generator(this, function (_d) {
switch (_d.label) {
case 0:
url = new URL("".concat((0, _variaveis_1.baseUrlPilao)(emDesenvolvimento)).concat("".concat(_variaveis_1.PREFIXO, "/").concat(Object.keys({ serie_registrar: exports.serie_registrar })[0], "/").concat(produto, "/").concat(conta)));
return [4 /*yield*/, (0, cross_fetch_1.default)(url.toString(), {
method: "POST",
body: JSON.stringify({
tabela: tabela,
agregacao: agregacao,
emDesenvolvimento: emDesenvolvimento,
colanuEixoX: colanuEixoX,
colunaAgrupamento: colunaAgrupamento,
identificador: identificador,
}),
headers: { "Content-Type": "application/json" },
})
.then(function (r) { return r.json(); })
.catch(function (e) { return p_respostas_1.respostaComuns.erro("Erro ao enviar registros", [e.message]); })
.then(function (r) { return r; })];
case 1:
resp = _d.sent();
return [2 /*return*/, resp];
}
});
});
};
exports.serie_registrar = serie_registrar;

View file

@ -1,6 +1,6 @@
{
"name": "p-drives",
"version": "0.74.0",
"version": "0.77.0",
"description": "",
"main": "src/index.ts",
"exports": {

View file

@ -3,26 +3,28 @@ import type { z } from "zod"
import type { zAmbiente } from "../ts/ambiente"
import { urlAutenticacao } from "./_urlAutenticacao"
type tipoPostCodigoContaSite = { site: string }
import node_fetch from "cross-fetch"
export const codigoContaSite = async ({
ambiente,
post,
buscar,
}: {
ambiente: z.infer<typeof zAmbiente>
post: tipoPostCodigoContaSite
/** função que conecta com a API */
buscar: (
url: string,
post: tipoPostCodigoContaSite,
) => Promise<tipoResposta<string>>
}): Promise<tipoResposta<string>> => {
const url = `${urlAutenticacao(ambiente)}/api/codigo_prefeitura_site`
try {
const resp = await buscar(url, post).catch((e) =>
respostaComuns.erro(`erro ao buscar código do site: ${e}`),
)
const resp = await node_fetch(url, {
method: "POST",
body: JSON.stringify(post),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.catch((e) =>
respostaComuns.erro("Erro ao enviar registros", [e.message]),
)
.then((r) => r as tipoResposta<string>)
return resp
} catch (e) {

View file

@ -1,3 +1,4 @@
import node_fetch from "cross-fetch"
import { respostaComuns, type tipoResposta } from "p-respostas"
import type { z } from "zod"
import type { zAmbiente } from "../ts/ambiente"
@ -15,14 +16,9 @@ export type tipoUsuarioExterno = {
export const usuarios_quipo_governo = async ({
token_produto,
ambiente,
buscar,
}: {
ambiente: z.infer<typeof zAmbiente>
token_produto: string
buscar: (
url: string,
headers: { [k: string]: string },
) => Promise<tipoResposta<tipoUsuarioExterno[]>>
}): Promise<tipoResposta<tipoUsuarioExterno[]>> => {
const url = `${urlAutenticacao(ambiente)}/api/usuarios_quipo_governo`
@ -32,7 +28,12 @@ export const usuarios_quipo_governo = async ({
token: token_produto,
}
return buscar(url, headers).catch((e) =>
respostaComuns.erro(`erro ao buscar usuários quipo governo: ${e}`),
)
return node_fetch(url, {
headers,
})
.then((r) => r.json())
.catch((e) =>
respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]),
)
.then((r) => r as tipoResposta<tipoUsuarioExterno[]>)
}

View file

@ -1,6 +1,7 @@
import type { tipoResposta } from "p-respostas"
import { urlAutenticacao } from "./_urlAutenticacao"
type tipoPostValidarTokem = { token: string }
import node_fetch from "cross-fetch"
import type { z } from "zod"
import type { zAmbiente } from "../ts/ambiente"
@ -8,20 +9,20 @@ import type { zAmbiente } from "../ts/ambiente"
export const validarToken = async ({
ambiente,
post,
buscar,
}: {
ambiente: z.infer<typeof zAmbiente>
post: tipoPostValidarTokem
/** função que conecta com a API */
buscar: (
url: string,
post: tipoPostValidarTokem,
) => Promise<tipoResposta<any>>
}): Promise<"valido" | "erro"> => {
const url = `${urlAutenticacao(ambiente)}/api/validar_token`
try {
const resposta = await buscar(url, post)
const resposta = await node_fetch(url, {
method: "POST",
body: JSON.stringify(post),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.then((r) => r as tipoResposta<any>)
.then((resposta) =>
resposta.eCerto ? ("valido" as const) : ("erro" as const),
)

View file

@ -32,6 +32,8 @@ export const z_tipo_coluna_base_dados = z.enum([
"confirmacao",
"lista_texto",
"lista_numero",
"data",
"mes",
])
export const tiposSeriesAgregacoes = z.enum(["contagem", "somatoria"])

View file

@ -6,8 +6,7 @@ import {
zp_registrar_base_dados,
} from "./enviar_registros"
import { serie_consultar, zp_serie_consultar } from "./serie_consultar"
import { serie_registrar, zp_serie_registrar } from "./serie_registrar"
import { serie_consultar, zp_serie_registrar } from "./serie_consultar"
export { tiposSeriesAgregacoes }
@ -17,11 +16,9 @@ export const pPilao = {
enviar_registros,
zp_enviar_registros,
serie_registrar,
zp_serie_registrar,
serie_consultar,
zp_serie_consultar,
zp_produto_conta,
validarZ,

View file

@ -8,23 +8,24 @@ import {
tiposSeriesAgregacoes,
type zp_produto_conta,
} from "./_variaveis"
import type { zp_serie_registrar } from "./serie_registrar"
//consultar compilação
export const zp_serie_consultar = z.object({
identificador: z.string(),
export const zp_serie_registrar = z.object({
tabela: z.string(),
colanuEixoX: z.string(),
colunaAgrupamento: z.string(),
agregacao: tiposSeriesAgregacoes,
})
export const serie_consultar = ({
emDesenvolvimento,
parametros: { identificador },
cliente: { conta, produto },
parametros: { agregacao, colanuEixoX, colunaAgrupamento, tabela },
}: {
emDesenvolvimento?: boolean | undefined | null
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>
parametros: z.infer<typeof zp_serie_consultar>
parametros: z.infer<typeof zp_serie_registrar>
}) => {
const dados = async (): Promise<
tipoResposta<{
@ -42,7 +43,10 @@ export const serie_consultar = ({
const resp = await node_fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
identificador,
agregacao,
colanuEixoX,
colunaAgrupamento,
tabela,
}),
headers: { "Content-Type": "application/json" },
})
@ -56,6 +60,15 @@ export const serie_consultar = ({
}
const url = (): string => {
const pr = {
produto,
conta,
agregacao,
colanuEixoX,
colunaAgrupamento,
tabela,
}
const vUrl = new URL(
`${
emDesenvolvimento
@ -64,9 +77,9 @@ export const serie_consultar = ({
}${PREFIXO}/${tiposSeriesAgregacoes.enum.contagem}`,
)
vUrl.searchParams.append("produto", produto)
vUrl.searchParams.append("conta", conta)
vUrl.searchParams.append("identificador", identificador)
for (const [k, v] of Object.entries(pr)) {
vUrl.searchParams.append(k, JSON.stringify(v))
}
return vUrl.href
}

View file

@ -1,62 +0,0 @@
import node_fetch from "cross-fetch"
import { respostaComuns, type tipoResposta } from "p-respostas"
import { z } from "zod"
import {
PREFIXO,
baseUrlPilao,
tiposSeriesAgregacoes,
type zp_produto_conta,
} from "./_variaveis"
//registrar serie
export const zp_serie_registrar = z.object({
tabela: z.string(),
identificador: z.string(),
colanuEixoX: z.string(),
colunaAgrupamento: z.string(),
agregacao: tiposSeriesAgregacoes,
})
export const serie_registrar = async ({
emDesenvolvimento,
cliente: { conta, produto },
parametros: {
agregacao,
colanuEixoX,
colunaAgrupamento,
identificador,
tabela,
},
}: {
emDesenvolvimento?: boolean | undefined | null
/** Identificação do cliente */
cliente: z.infer<typeof zp_produto_conta>
/** Parametros da função */
parametros: z.infer<typeof zp_serie_registrar>
}): Promise<tipoResposta<true>> => {
const url = new URL(
`${baseUrlPilao(
emDesenvolvimento,
)}${`${PREFIXO}/${Object.keys({ serie_registrar })[0]}/${produto}/${conta}`}`,
)
const resp = await node_fetch(url.toString(), {
method: "POST",
body: JSON.stringify({
tabela,
agregacao,
emDesenvolvimento,
colanuEixoX,
colunaAgrupamento,
identificador,
}),
headers: { "Content-Type": "application/json" },
})
.then((r) => r.json())
.catch((e) => respostaComuns.erro("Erro ao enviar registros", [e.message]))
.then((r) => r as tipoResposta<true>)
return resp
}