build
This commit is contained in:
parent
a6205f1ab6
commit
e580643abc
40 changed files with 329 additions and 507 deletions
|
|
@ -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 {};
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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[]>>;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
5
dist-import/autenticacao/_validarToken.d.ts
vendored
5
dist-import/autenticacao/_validarToken.d.ts
vendored
|
|
@ -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 {};
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
15
dist-import/autenticacao/index.d.ts
vendored
15
dist-import/autenticacao/index.d.ts
vendored
|
|
@ -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[]>>;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue