This commit is contained in:
Luiz H. R. Silva 2024-06-26 10:29:02 -03:00
commit e498c967be
34 changed files with 674 additions and 232 deletions

View file

@ -59,7 +59,7 @@ var usuarios_quipo_governo = function (_a) {
})
.then(function (r) { return r.json(); })
.catch(function (e) {
return p_respostas_1.respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]);
return p_respostas_1.respostaComuns.erro("Erro ao buscar usu\u00E1rios quipo governo ".concat(e.message));
})
.then(function (r) { return r; })];
});

View file

@ -0,0 +1,11 @@
import { type tipoResposta } from "p-respostas";
import type { z } from "zod";
import type { zAmbiente } from "../ts/ambiente";
export declare const usuarios_quipo_vincular: ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }: {
ambiente: z.infer<typeof zAmbiente>;
token_produto: string;
conta: string;
vinculo: string;
codigo_usuario?: string | undefined;
email: string;
}) => Promise<tipoResposta<string>>;

View file

@ -0,0 +1,83 @@
"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) {
var token_produto = _a.token_produto, ambiente = _a.ambiente, conta = _a.conta, vinculo = _a.vinculo, codigo_usuario = _a.codigo_usuario, email = _a.email;
return __awaiter(void 0, void 0, void 0, function () {
var url, headers, parametros;
return __generator(this, function (_b) {
switch (_b.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*/, _b.sent()];
}
});
});
};
exports.usuarios_quipo_vincular = usuarios_quipo_vincular;

View file

@ -3,6 +3,7 @@ export type { tipoUsuarioExterno };
/** todas as rotas de comunicação com autenticador partem dessa variável */
export declare const pAutenticacao: {
validarToken: ({ ambiente, post, }: {
/** todas as rotas de comunicação com autenticador partem dessa variável */
ambiente: "desenvolvimento" | "producao";
post: {
token: string;
@ -19,4 +20,12 @@ export declare const pAutenticacao: {
ambiente: "desenvolvimento" | "producao";
token_produto: string;
}) => Promise<import("p-respostas").tipoResposta<tipoUsuarioExterno[]>>;
usuarios_quipo_vincular: ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }: {
ambiente: "desenvolvimento" | "producao";
token_produto: string;
conta: string;
vinculo: string;
codigo_usuario?: string | undefined;
email: string;
}) => Promise<import("p-respostas").tipoResposta<string>>;
};

View file

@ -4,6 +4,7 @@ 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");
/** todas as rotas de comunicação com autenticador partem dessa variável */
exports.pAutenticacao = {
@ -11,4 +12,5 @@ exports.pAutenticacao = {
urlAutenticacao: _urlAutenticacao_1.urlAutenticacao,
codigoContaSite: _codigoContaSite_1.codigoContaSite,
usuarios_quipo_governo: _usuarios_quipo_governo_1.usuarios_quipo_governo,
usuarios_quipo_vincular: _usuarios_quipo_vincular_1.usuarios_quipo_vincular,
};

9
dist-require/email/index.d.ts vendored Normal file
View file

@ -0,0 +1,9 @@
import { type tipoResposta } from "p-respostas";
export declare const enviarEmail: ({ email, nome, assunto, texto, htlm, }: {
email: string;
nome?: string | undefined;
assunto: string;
/** Verão em texto do html, não obrigatório */
texto?: string | undefined;
htlm: string;
}) => Promise<tipoResposta<string>>;

104
dist-require/email/index.js Normal file
View file

@ -0,0 +1,104 @@
"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.enviarEmail = void 0;
var nodemailer_1 = __importDefault(require("nodemailer"));
var p_respostas_1 = require("p-respostas");
// const confEmail = {
// host: "email-smtp.us-east-1.amazonaws.com",
// port: 587,
// secure: false,
// user: "AKIA2LGJTHGX2ZKMMYHG",
// pass: "BFuchUwoUYYDJK8l+pd1NvZxk70PjhMX+KbQy+5HfPDl",
// requireTLS: true,
// ignoreTLS: false,
// emailDe: "nao-responder@e-licencie.com.br",
// nomeDe: "🌱 Betha Meio Ambiente",
// };
var confEmail = {
host: "email-smtp.us-east-1.amazonaws.com",
port: 587,
secure: false,
user: "AKIA2LGJTHGX2ZKMMYHG",
pass: "BFuchUwoUYYDJK8l+pd1NvZxk70PjhMX+KbQy+5HfPDl",
requireTLS: true,
ignoreTLS: false,
emailDe: "nao-responder@gestao-ambiental-brasil.idz.one",
nomeDe: "🌱 Betha Meio Ambiente",
};
var enviarEmail = function (_a) {
var email = _a.email, nome = _a.nome, assunto = _a.assunto, texto = _a.texto, htlm = _a.htlm;
return __awaiter(void 0, void 0, void 0, function () {
var info;
return __generator(this, function (_b) {
switch (_b.label) {
case 0: return [4 /*yield*/, nodemailer_1.default
.createTransport({
host: confEmail.host,
port: confEmail.port,
secure: confEmail.secure,
auth: {
user: confEmail.user,
pass: confEmail.pass,
},
})
.sendMail({
from: { address: confEmail.emailDe, name: confEmail.nomeDe },
to: nome ? { address: email, name: nome } : email,
subject: assunto,
text: texto,
html: htlm,
})
.then(function () {
return p_respostas_1.respostaComuns.valor("Email \"".concat(assunto, "\" enviado para ").concat(email));
})
.catch(function (err) {
console.error(err);
return p_respostas_1.respostaComuns.erro("Erro ao enviar email para ".concat(email, ": ").concat(err.message));
})];
case 1:
info = _b.sent();
return [2 /*return*/, info];
}
});
});
};
exports.enviarEmail = enviarEmail;

View file

@ -4,3 +4,4 @@ export * from "./produtos";
export * from "./pilao-de-dados";
export * from "./residuos";
export * from "./NPS";
export * from "./email";

View file

@ -20,3 +20,4 @@ __exportStar(require("./produtos"), exports);
__exportStar(require("./pilao-de-dados"), exports);
__exportStar(require("./residuos"), exports);
__exportStar(require("./NPS"), exports);
__exportStar(require("./email"), exports);

View file

@ -27,8 +27,8 @@ export declare const pPilao: {
}[];
}>;
enviar_registros: ({ conta, produto, emDesenvolvimento }: {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}) => ({ registros, tabela, }: {
tabela: string;
@ -79,8 +79,8 @@ export declare const pPilao: {
colunaAgrupamento?: string[] | undefined;
}>;
serie_consultar: (cliente: {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}) => (parametros: {
tabela: string;
@ -105,18 +105,18 @@ export declare const pPilao: {
conta: import("zod").ZodString;
emDesenvolvimento: import("zod").ZodOptional<import("zod").ZodBoolean>;
}, "strip", import("zod").ZodTypeAny, {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}, {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}>;
validarZ: <T>(zodType: import("zod").ZodType<T, any, T>, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso<T>;
deletar_registros: ({ conta, produto, emDesenvolvimento }: {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}) => ({ codigos, tabela, }: {
tabela: string;

View file

@ -7,12 +7,12 @@ export declare const zp_produto_conta: z.ZodObject<{
conta: z.ZodString;
emDesenvolvimento: z.ZodOptional<z.ZodBoolean>;
}, "strip", z.ZodTypeAny, {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}, {
produto: string;
conta: string;
produto: string;
emDesenvolvimento?: boolean | undefined;
}>;
export declare const z_tipo_coluna_base_dados: z.ZodEnum<["texto", "numero", "confirmacao", "lista_texto", "lista_numero", "data", "mes"]>;

View file

@ -6,6 +6,7 @@ export declare const zAuntenticacaoResiduos: z.ZodObject<{
documento_usuario: z.ZodString;
organizacao: z.ZodString;
rotas: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
tipo_usuario: z.ZodString;
sistema: z.ZodString;
sistema_cor: z.ZodString;
sistema_nome: z.ZodString;
@ -22,6 +23,7 @@ export declare const zAuntenticacaoResiduos: z.ZodObject<{
documento_usuario: string;
organizacao: string;
rotas: {};
tipo_usuario: string;
sistema: string;
sistema_cor: string;
sistema_nome: string;
@ -37,6 +39,7 @@ export declare const zAuntenticacaoResiduos: z.ZodObject<{
documento_usuario: string;
organizacao: string;
rotas: {};
tipo_usuario: string;
sistema: string;
sistema_cor: string;
sistema_nome: string;

View file

@ -10,6 +10,7 @@ exports.zAuntenticacaoResiduos = zod_1.z.object({
documento_usuario: zod_1.z.string(),
organizacao: zod_1.z.string(),
rotas: zod_1.z.object({}),
tipo_usuario: zod_1.z.string(),
// Dados do sistema
sistema: zod_1.z.string(),
sistema_cor: zod_1.z.string(),