diff --git a/dist-import/autenticacao/_usuarios_quipo_governo.js b/dist-import/autenticacao/_usuarios_quipo_governo.js index e70528d..4423f56 100644 --- a/dist-import/autenticacao/_usuarios_quipo_governo.js +++ b/dist-import/autenticacao/_usuarios_quipo_governo.js @@ -21,6 +21,6 @@ export const usuarios_quipo_governo = ({ token_produto, ambiente, }) => __awaite headers, }) .then((r) => r.json()) - .catch((e) => respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message])) + .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.d.ts b/dist-import/autenticacao/_usuarios_quipo_vincular.d.ts new file mode 100644 index 0000000..3aa424c --- /dev/null +++ b/dist-import/autenticacao/_usuarios_quipo_vincular.d.ts @@ -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; + token_produto: string; + conta: string; + vinculo: string; + codigo_usuario?: string | undefined; + email: string; +}) => Promise>; diff --git a/dist-import/autenticacao/_usuarios_quipo_vincular.js b/dist-import/autenticacao/_usuarios_quipo_vincular.js new file mode 100644 index 0000000..1658e9a --- /dev/null +++ b/dist-import/autenticacao/_usuarios_quipo_vincular.js @@ -0,0 +1,32 @@ +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 = ({ token_produto, ambiente, conta, vinculo, codigo_usuario, email, }) => __awaiter(void 0, void 0, void 0, function* () { + const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar`; + if (!token_produto) + return 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 yield node_fetch(url, { + headers, + body: JSON.stringify(parametros), + method: "POST", + }) + .then((r) => __awaiter(void 0, void 0, void 0, function* () { return yield r.json(); })) + .catch((e) => respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`)); +}); diff --git a/dist-import/autenticacao/index.d.ts b/dist-import/autenticacao/index.d.ts index 779dca7..5371040 100644 --- a/dist-import/autenticacao/index.d.ts +++ b/dist-import/autenticacao/index.d.ts @@ -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>; + 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>; }; diff --git a/dist-import/autenticacao/index.js b/dist-import/autenticacao/index.js index 7f90783..0ec3e89 100644 --- a/dist-import/autenticacao/index.js +++ b/dist-import/autenticacao/index.js @@ -1,6 +1,7 @@ import { codigoContaSite } from "./_codigoContaSite"; import { urlAutenticacao } from "./_urlAutenticacao"; import { usuarios_quipo_governo, } from "./_usuarios_quipo_governo"; +import { usuarios_quipo_vincular } from "./_usuarios_quipo_vincular"; import { validarToken } from "./_validarToken"; /** todas as rotas de comunicação com autenticador partem dessa variável */ export const pAutenticacao = { @@ -8,4 +9,5 @@ export const pAutenticacao = { urlAutenticacao, codigoContaSite, usuarios_quipo_governo, + usuarios_quipo_vincular, }; diff --git a/dist-import/email/index.d.ts b/dist-import/email/index.d.ts new file mode 100644 index 0000000..bcd71af --- /dev/null +++ b/dist-import/email/index.d.ts @@ -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>; diff --git a/dist-import/email/index.js b/dist-import/email/index.js new file mode 100644 index 0000000..8580397 --- /dev/null +++ b/dist-import/email/index.js @@ -0,0 +1,58 @@ +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 nodemailer from "nodemailer"; +import { respostaComuns } from "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", +// }; +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@gestao-ambiental-brasil.idz.one", + nomeDe: "🌱 Betha Meio Ambiente", +}; +export const enviarEmail = ({ email, nome, assunto, texto, htlm, }) => __awaiter(void 0, void 0, void 0, function* () { + const info = yield nodemailer + .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(() => respostaComuns.valor(`Email "${assunto}" enviado para ${email}`)) + .catch((err) => { + console.error(err); + return respostaComuns.erro(`Erro ao enviar email para ${email}: ${err.message}`); + }); + return info; +}); diff --git a/dist-import/index.d.ts b/dist-import/index.d.ts index a527f79..ac14a51 100644 --- a/dist-import/index.d.ts +++ b/dist-import/index.d.ts @@ -4,3 +4,4 @@ export * from "./produtos"; export * from "./pilao-de-dados"; export * from "./residuos"; export * from "./NPS"; +export * from "./email"; diff --git a/dist-import/index.js b/dist-import/index.js index a527f79..ac14a51 100644 --- a/dist-import/index.js +++ b/dist-import/index.js @@ -4,3 +4,4 @@ export * from "./produtos"; export * from "./pilao-de-dados"; export * from "./residuos"; export * from "./NPS"; +export * from "./email"; diff --git a/dist-import/pilao-de-dados/index.d.ts b/dist-import/pilao-de-dados/index.d.ts index 67e5d81..4a9cec2 100644 --- a/dist-import/pilao-de-dados/index.d.ts +++ b/dist-import/pilao-de-dados/index.d.ts @@ -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; }, "strip", import("zod").ZodTypeAny, { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }, { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }>; validarZ: (zodType: import("zod").ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; deletar_registros: ({ conta, produto, emDesenvolvimento }: { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }) => ({ codigos, tabela, }: { tabela: string; diff --git a/dist-import/pilao-de-dados/variaveis.d.ts b/dist-import/pilao-de-dados/variaveis.d.ts index 350e148..1902f1e 100644 --- a/dist-import/pilao-de-dados/variaveis.d.ts +++ b/dist-import/pilao-de-dados/variaveis.d.ts @@ -7,12 +7,12 @@ export declare const zp_produto_conta: z.ZodObject<{ conta: z.ZodString; emDesenvolvimento: z.ZodOptional; }, "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"]>; diff --git a/dist-import/residuos/index.d.ts b/dist-import/residuos/index.d.ts index 7f378aa..2981dec 100644 --- a/dist-import/residuos/index.d.ts +++ b/dist-import/residuos/index.d.ts @@ -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; diff --git a/dist-import/residuos/index.js b/dist-import/residuos/index.js index 0deca91..084261c 100644 --- a/dist-import/residuos/index.js +++ b/dist-import/residuos/index.js @@ -7,6 +7,7 @@ export const zAuntenticacaoResiduos = z.object({ documento_usuario: z.string(), organizacao: z.string(), rotas: z.object({}), + tipo_usuario: z.string(), // Dados do sistema sistema: z.string(), sistema_cor: z.string(), diff --git a/dist-require/autenticacao/_usuarios_quipo_governo.js b/dist-require/autenticacao/_usuarios_quipo_governo.js index ac6bbf0..f3517cb 100644 --- a/dist-require/autenticacao/_usuarios_quipo_governo.js +++ b/dist-require/autenticacao/_usuarios_quipo_governo.js @@ -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; })]; }); diff --git a/dist-require/autenticacao/_usuarios_quipo_vincular.d.ts b/dist-require/autenticacao/_usuarios_quipo_vincular.d.ts new file mode 100644 index 0000000..3aa424c --- /dev/null +++ b/dist-require/autenticacao/_usuarios_quipo_vincular.d.ts @@ -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; + token_produto: string; + conta: string; + vinculo: string; + codigo_usuario?: string | undefined; + email: string; +}) => Promise>; diff --git a/dist-require/autenticacao/_usuarios_quipo_vincular.js b/dist-require/autenticacao/_usuarios_quipo_vincular.js new file mode 100644 index 0000000..84bf77c --- /dev/null +++ b/dist-require/autenticacao/_usuarios_quipo_vincular.js @@ -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; diff --git a/dist-require/autenticacao/index.d.ts b/dist-require/autenticacao/index.d.ts index 779dca7..5371040 100644 --- a/dist-require/autenticacao/index.d.ts +++ b/dist-require/autenticacao/index.d.ts @@ -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>; + 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>; }; diff --git a/dist-require/autenticacao/index.js b/dist-require/autenticacao/index.js index 064afda..911f237 100644 --- a/dist-require/autenticacao/index.js +++ b/dist-require/autenticacao/index.js @@ -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, }; diff --git a/dist-require/email/index.d.ts b/dist-require/email/index.d.ts new file mode 100644 index 0000000..bcd71af --- /dev/null +++ b/dist-require/email/index.d.ts @@ -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>; diff --git a/dist-require/email/index.js b/dist-require/email/index.js new file mode 100644 index 0000000..063ee66 --- /dev/null +++ b/dist-require/email/index.js @@ -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; diff --git a/dist-require/index.d.ts b/dist-require/index.d.ts index a527f79..ac14a51 100644 --- a/dist-require/index.d.ts +++ b/dist-require/index.d.ts @@ -4,3 +4,4 @@ export * from "./produtos"; export * from "./pilao-de-dados"; export * from "./residuos"; export * from "./NPS"; +export * from "./email"; diff --git a/dist-require/index.js b/dist-require/index.js index cb4fdcf..83d0523 100644 --- a/dist-require/index.js +++ b/dist-require/index.js @@ -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); diff --git a/dist-require/pilao-de-dados/index.d.ts b/dist-require/pilao-de-dados/index.d.ts index 67e5d81..4a9cec2 100644 --- a/dist-require/pilao-de-dados/index.d.ts +++ b/dist-require/pilao-de-dados/index.d.ts @@ -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; }, "strip", import("zod").ZodTypeAny, { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }, { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }>; validarZ: (zodType: import("zod").ZodType, objeto: any, mensagem: string) => import("p-respostas").tipoRespostaErro | import("p-respostas").tipoRespostaSucesso; deletar_registros: ({ conta, produto, emDesenvolvimento }: { - produto: string; conta: string; + produto: string; emDesenvolvimento?: boolean | undefined; }) => ({ codigos, tabela, }: { tabela: string; diff --git a/dist-require/pilao-de-dados/variaveis.d.ts b/dist-require/pilao-de-dados/variaveis.d.ts index 350e148..1902f1e 100644 --- a/dist-require/pilao-de-dados/variaveis.d.ts +++ b/dist-require/pilao-de-dados/variaveis.d.ts @@ -7,12 +7,12 @@ export declare const zp_produto_conta: z.ZodObject<{ conta: z.ZodString; emDesenvolvimento: z.ZodOptional; }, "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"]>; diff --git a/dist-require/residuos/index.d.ts b/dist-require/residuos/index.d.ts index 7f378aa..2981dec 100644 --- a/dist-require/residuos/index.d.ts +++ b/dist-require/residuos/index.d.ts @@ -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; diff --git a/dist-require/residuos/index.js b/dist-require/residuos/index.js index 66313ca..f0db4a4 100644 --- a/dist-require/residuos/index.js +++ b/dist-require/residuos/index.js @@ -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(), diff --git a/package.json b/package.json index b76d7c8..381062d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "p-drives", - "version": "0.90.0", + "version": "0.97.0", "description": "", "main": "src/index.ts", "exports": { @@ -37,4 +37,4 @@ "cross-fetch": "^4.0.0", "zod": "latest" } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 33b9139..2947a48 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,189 +1,44 @@ -lockfileVersion: '9.0' +lockfileVersion: '6.0' settings: autoInstallPeers: true excludeLinksFromLockfile: false -importers: +dependencies: + cross-fetch: + specifier: ^4.0.0 + version: 4.0.0 + zod: + specifier: latest + version: 3.23.8 - .: - dependencies: - cross-fetch: - specifier: ^4.0.0 - version: 4.0.0 - zod: - specifier: latest - version: 3.23.8 - devDependencies: - '@biomejs/biome': - specifier: latest - version: 1.8.1 - '@types/node': - specifier: ^20.14.1 - version: 20.14.2 - check-node-version: - specifier: ^4.2.1 - version: 4.2.1 - p-comuns: - specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao - version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#b01ceca6b840e3a30ee85a2dd98015ab0e8f298d(typescript@4.9.5) - p-respostas: - specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#producao - version: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#c10a2584e6f6ec5c87462c810cafb1dad243067d - typescript: - specifier: ^4.9.5 - version: 4.9.5 +devDependencies: + '@biomejs/biome': + specifier: latest + version: 1.8.1 + '@types/node': + specifier: ^20.14.1 + version: 20.14.2 + check-node-version: + specifier: ^4.2.1 + version: 4.2.1 + p-comuns: + specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#producao + version: leitura+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one+3000/git/multi-modulos-ambientais/_comuns/b01ceca6b840e3a30ee85a2dd98015ab0e8f298d(typescript@4.9.5) + p-respostas: + specifier: git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#producao + version: leitura+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one+3000/git/multi-modulos-ambientais/_respostas/c10a2584e6f6ec5c87462c810cafb1dad243067d + typescript: + specifier: ^4.9.5 + version: 4.9.5 packages: - '@biomejs/biome@1.8.1': + /@biomejs/biome@1.8.1: resolution: {integrity: sha512-fQXGfvq6DIXem12dGQCM2tNF+vsNHH1qs3C7WeOu75Pd0trduoTmoO7G4ntLJ2qDs5wuw981H+cxQhi1uHnAtA==} engines: {node: '>=14.21.3'} hasBin: true - - '@biomejs/cli-darwin-arm64@1.8.1': - resolution: {integrity: sha512-XLiB7Uu6GALIOBWzQ2aMD0ru4Ly5/qSeQF7kk3AabzJ/kwsEWSe33iVySBP/SS2qv25cgqNiLksjGcw2bHT3mw==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [darwin] - - '@biomejs/cli-darwin-x64@1.8.1': - resolution: {integrity: sha512-uMTSxVLMfqkBVqyc25hSn83jBbp+wtWjzM/pHFlKXt3htJuw7FErVGW0nmQ9Sxa9vJ7GcqoltLMl28VQRIMYzg==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [darwin] - - '@biomejs/cli-linux-arm64-musl@1.8.1': - resolution: {integrity: sha512-UQ8Wc01J0wQL+5AYOc7qkJn20B4PZmQL1KrmDZh7ot0DvD6aX4+8mmfd/dG5b6Zjo/44QvCKcvkFGCMRYuhWZA==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-arm64@1.8.1': - resolution: {integrity: sha512-3SzZRuC/9Oi2P2IBNPsEj0KXxSXUEYRR2kfRF/Ve8QAfGgrt4qnwuWd6QQKKN5R+oYH691qjm+cXBKEcrP1v/Q==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [linux] - - '@biomejs/cli-linux-x64-musl@1.8.1': - resolution: {integrity: sha512-fYbP/kNu/rtZ4kKzWVocIdqZOtBSUEg9qUhZaao3dy3CRzafR6u6KDtBeSCnt47O+iLnks1eOR1TUxzr5+QuqA==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-linux-x64@1.8.1': - resolution: {integrity: sha512-AeBycVdNrTzsyYKEOtR2R0Ph0hCD0sCshcp2aOnfGP0hCZbtFg09D0SdKLbyzKntisY41HxKVrydYiaApp+2uw==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [linux] - - '@biomejs/cli-win32-arm64@1.8.1': - resolution: {integrity: sha512-6tEd1H/iFKpgpE3OIB7oNgW5XkjiVMzMRPL8zYoZ036YfuJ5nMYm9eB9H/y81+8Z76vL48fiYzMPotJwukGPqQ==} - engines: {node: '>=14.21.3'} - cpu: [arm64] - os: [win32] - - '@biomejs/cli-win32-x64@1.8.1': - resolution: {integrity: sha512-g2H31jJzYmS4jkvl6TiyEjEX+Nv79a5km/xn+5DARTp5MBFzC9gwceusSSB2AkJKqZzY131AiACAWjKrVt5Ijw==} - engines: {node: '>=14.21.3'} - cpu: [x64] - os: [win32] - - '@types/node@20.14.2': - resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} - - ansi-styles@4.3.0: - resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} - engines: {node: '>=8'} - - chalk@3.0.0: - resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} - engines: {node: '>=8'} - - check-node-version@4.2.1: - resolution: {integrity: sha512-YYmFYHV/X7kSJhuN/QYHUu998n/TRuDe8UenM3+m5NrkiH670lb9ILqHIvBencvJc4SDh+XcbXMR4b+TtubJiw==} - engines: {node: '>=8.3.0'} - hasBin: true - - color-convert@2.0.1: - resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} - engines: {node: '>=7.0.0'} - - color-name@1.1.4: - resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} - - cross-fetch@4.0.0: - resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==} - - has-flag@4.0.0: - resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} - engines: {node: '>=8'} - - map-values@1.0.1: - resolution: {integrity: sha512-BbShUnr5OartXJe1GeccAWtfro11hhgNJg6G9/UtWKjVGvV5U4C09cg5nk8JUevhXODaXY+hQ3xxMUKSs62ONQ==} - - minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - - node-fetch@2.7.0: - resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} - engines: {node: 4.x || >=6.0.0} - peerDependencies: - encoding: ^0.1.0 - peerDependenciesMeta: - encoding: - optional: true - - object-filter@1.0.2: - resolution: {integrity: sha512-NahvP2vZcy1ZiiYah30CEPw0FpDcSkSePJBMpzl5EQgCmISijiGuJm3SPYp7U+Lf2TljyaIw3E5EgkEx/TNEVA==} - - p-comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#b01ceca6b840e3a30ee85a2dd98015ab0e8f298d: - resolution: {commit: b01ceca6b840e3a30ee85a2dd98015ab0e8f298d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git, type: git} - version: 0.31.0 - peerDependencies: - typescript: ^5.0.0 - - p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#c10a2584e6f6ec5c87462c810cafb1dad243067d: - resolution: {commit: c10a2584e6f6ec5c87462c810cafb1dad243067d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git, type: git} - version: 0.12.0 - - queue-microtask@1.2.3: - resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} - - run-parallel@1.2.0: - resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} - - semver@6.3.1: - resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} - hasBin: true - - supports-color@7.2.0: - resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} - engines: {node: '>=8'} - - tr46@0.0.3: - resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} - - typescript@4.9.5: - resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} - engines: {node: '>=4.2.0'} - hasBin: true - - undici-types@5.26.5: - resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - - webidl-conversions@3.0.1: - resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - - whatwg-url@5.0.0: - resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} - - zod@3.23.8: - resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} - -snapshots: - - '@biomejs/biome@1.8.1': + requiresBuild: true optionalDependencies: '@biomejs/cli-darwin-arm64': 1.8.1 '@biomejs/cli-darwin-x64': 1.8.1 @@ -193,45 +48,105 @@ snapshots: '@biomejs/cli-linux-x64-musl': 1.8.1 '@biomejs/cli-win32-arm64': 1.8.1 '@biomejs/cli-win32-x64': 1.8.1 + dev: true - '@biomejs/cli-darwin-arm64@1.8.1': + /@biomejs/cli-darwin-arm64@1.8.1: + resolution: {integrity: sha512-XLiB7Uu6GALIOBWzQ2aMD0ru4Ly5/qSeQF7kk3AabzJ/kwsEWSe33iVySBP/SS2qv25cgqNiLksjGcw2bHT3mw==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-darwin-x64@1.8.1': + /@biomejs/cli-darwin-x64@1.8.1: + resolution: {integrity: sha512-uMTSxVLMfqkBVqyc25hSn83jBbp+wtWjzM/pHFlKXt3htJuw7FErVGW0nmQ9Sxa9vJ7GcqoltLMl28VQRIMYzg==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-linux-arm64-musl@1.8.1': + /@biomejs/cli-linux-arm64-musl@1.8.1: + resolution: {integrity: sha512-UQ8Wc01J0wQL+5AYOc7qkJn20B4PZmQL1KrmDZh7ot0DvD6aX4+8mmfd/dG5b6Zjo/44QvCKcvkFGCMRYuhWZA==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-linux-arm64@1.8.1': + /@biomejs/cli-linux-arm64@1.8.1: + resolution: {integrity: sha512-3SzZRuC/9Oi2P2IBNPsEj0KXxSXUEYRR2kfRF/Ve8QAfGgrt4qnwuWd6QQKKN5R+oYH691qjm+cXBKEcrP1v/Q==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-linux-x64-musl@1.8.1': + /@biomejs/cli-linux-x64-musl@1.8.1: + resolution: {integrity: sha512-fYbP/kNu/rtZ4kKzWVocIdqZOtBSUEg9qUhZaao3dy3CRzafR6u6KDtBeSCnt47O+iLnks1eOR1TUxzr5+QuqA==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-linux-x64@1.8.1': + /@biomejs/cli-linux-x64@1.8.1: + resolution: {integrity: sha512-AeBycVdNrTzsyYKEOtR2R0Ph0hCD0sCshcp2aOnfGP0hCZbtFg09D0SdKLbyzKntisY41HxKVrydYiaApp+2uw==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-win32-arm64@1.8.1': + /@biomejs/cli-win32-arm64@1.8.1: + resolution: {integrity: sha512-6tEd1H/iFKpgpE3OIB7oNgW5XkjiVMzMRPL8zYoZ036YfuJ5nMYm9eB9H/y81+8Z76vL48fiYzMPotJwukGPqQ==} + engines: {node: '>=14.21.3'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true optional: true - '@biomejs/cli-win32-x64@1.8.1': + /@biomejs/cli-win32-x64@1.8.1: + resolution: {integrity: sha512-g2H31jJzYmS4jkvl6TiyEjEX+Nv79a5km/xn+5DARTp5MBFzC9gwceusSSB2AkJKqZzY131AiACAWjKrVt5Ijw==} + engines: {node: '>=14.21.3'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true optional: true - '@types/node@20.14.2': + /@types/node@20.14.2: + resolution: {integrity: sha512-xyu6WAMVwv6AKFLB+e/7ySZVr/0zLCzOa7rSpq6jNwpqOrUbcACDWC+53d4n2QHOnDou0fbIsg8wZu/sxrnI4Q==} dependencies: undici-types: 5.26.5 + dev: true - ansi-styles@4.3.0: + /ansi-styles@4.3.0: + resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==} + engines: {node: '>=8'} dependencies: color-convert: 2.0.1 + dev: true - chalk@3.0.0: + /chalk@3.0.0: + resolution: {integrity: sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==} + engines: {node: '>=8'} dependencies: ansi-styles: 4.3.0 supports-color: 7.2.0 + dev: true - check-node-version@4.2.1: + /check-node-version@4.2.1: + resolution: {integrity: sha512-YYmFYHV/X7kSJhuN/QYHUu998n/TRuDe8UenM3+m5NrkiH670lb9ILqHIvBencvJc4SDh+XcbXMR4b+TtubJiw==} + engines: {node: '>=8.3.0'} + hasBin: true dependencies: chalk: 3.0.0 map-values: 1.0.1 @@ -239,63 +154,123 @@ snapshots: object-filter: 1.0.2 run-parallel: 1.2.0 semver: 6.3.1 + dev: true - color-convert@2.0.1: + /color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} dependencies: color-name: 1.1.4 + dev: true - color-name@1.1.4: {} + /color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + dev: true - cross-fetch@4.0.0: + /cross-fetch@4.0.0: + resolution: {integrity: sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==} dependencies: node-fetch: 2.7.0 transitivePeerDependencies: - encoding + dev: false - has-flag@4.0.0: {} + /has-flag@4.0.0: + resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==} + engines: {node: '>=8'} + dev: true - map-values@1.0.1: {} + /map-values@1.0.1: + resolution: {integrity: sha512-BbShUnr5OartXJe1GeccAWtfro11hhgNJg6G9/UtWKjVGvV5U4C09cg5nk8JUevhXODaXY+hQ3xxMUKSs62ONQ==} + dev: true - minimist@1.2.8: {} + /minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + dev: true - node-fetch@2.7.0: + /node-fetch@2.7.0: + resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} + engines: {node: 4.x || >=6.0.0} + peerDependencies: + encoding: ^0.1.0 + peerDependenciesMeta: + encoding: + optional: true dependencies: whatwg-url: 5.0.0 + dev: false - object-filter@1.0.2: {} + /object-filter@1.0.2: + resolution: {integrity: sha512-NahvP2vZcy1ZiiYah30CEPw0FpDcSkSePJBMpzl5EQgCmISijiGuJm3SPYp7U+Lf2TljyaIw3E5EgkEx/TNEVA==} + dev: true - p-comuns@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git#b01ceca6b840e3a30ee85a2dd98015ab0e8f298d(typescript@4.9.5): - dependencies: - typescript: 4.9.5 - zod: 3.23.8 + /queue-microtask@1.2.3: + resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: true - p-respostas@git+http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git#c10a2584e6f6ec5c87462c810cafb1dad243067d: - dependencies: - zod: 3.23.8 - - queue-microtask@1.2.3: {} - - run-parallel@1.2.0: + /run-parallel@1.2.0: + resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: queue-microtask: 1.2.3 + dev: true - semver@6.3.1: {} + /semver@6.3.1: + resolution: {integrity: sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==} + hasBin: true + dev: true - supports-color@7.2.0: + /supports-color@7.2.0: + resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==} + engines: {node: '>=8'} dependencies: has-flag: 4.0.0 + dev: true - tr46@0.0.3: {} + /tr46@0.0.3: + resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} + dev: false - typescript@4.9.5: {} + /typescript@4.9.5: + resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} + engines: {node: '>=4.2.0'} + hasBin: true + dev: true - undici-types@5.26.5: {} + /undici-types@5.26.5: + resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} + dev: true - webidl-conversions@3.0.1: {} + /webidl-conversions@3.0.1: + resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} + dev: false - whatwg-url@5.0.0: + /whatwg-url@5.0.0: + resolution: {integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==} dependencies: tr46: 0.0.3 webidl-conversions: 3.0.1 + dev: false - zod@3.23.8: {} + /zod@3.23.8: + resolution: {integrity: sha512-XBx9AXhXktjUqnepgTiE5flcKIYWi/rme0Eaj+5Y0lftuGBq+jyRu/md4WnuxqgP1ubdpNCsYEYPxrzVHD8d6g==} + + leitura+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one+3000/git/multi-modulos-ambientais/_comuns/b01ceca6b840e3a30ee85a2dd98015ab0e8f298d(typescript@4.9.5): + resolution: {commit: b01ceca6b840e3a30ee85a2dd98015ab0e8f298d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_comuns.git, type: git} + id: leitura+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one+3000/git/multi-modulos-ambientais/_comuns/b01ceca6b840e3a30ee85a2dd98015ab0e8f298d + name: p-comuns + version: 0.31.0 + peerDependencies: + typescript: ^5.0.0 + dependencies: + typescript: 4.9.5 + zod: 3.23.8 + dev: true + + leitura+eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one+3000/git/multi-modulos-ambientais/_respostas/c10a2584e6f6ec5c87462c810cafb1dad243067d: + resolution: {commit: c10a2584e6f6ec5c87462c810cafb1dad243067d, repo: http://leitura:eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3MTQ3NTA1NzYsImlzcyI6IkdpdG5lc3MiLCJwaWQiOjgsInRrbiI6eyJ0eXAiOiJwYXQiLCJpZCI6MzJ9fQ.OYdExOVQm5UI3wfeTaWjmD0o65Y1hrjFz5EvMB1a__U@git.idz.one:3000/git/multi-modulos-ambientais/_respostas.git, type: git} + name: p-respostas + version: 0.12.0 + requiresBuild: true + dependencies: + zod: 3.23.8 + dev: true diff --git a/src/autenticacao/_usuarios_quipo_governo.ts b/src/autenticacao/_usuarios_quipo_governo.ts index 87caa47..b7cee02 100644 --- a/src/autenticacao/_usuarios_quipo_governo.ts +++ b/src/autenticacao/_usuarios_quipo_governo.ts @@ -33,7 +33,7 @@ export const usuarios_quipo_governo = async ({ }) .then((r) => r.json()) .catch((e) => - respostaComuns.erro("Erro ao buscar usuários quipo governo", [e.message]), + respostaComuns.erro(`Erro ao buscar usuários quipo governo ${e.message}`), ) .then((r) => r as tipoResposta) } diff --git a/src/autenticacao/_usuarios_quipo_vincular.ts b/src/autenticacao/_usuarios_quipo_vincular.ts new file mode 100644 index 0000000..14a6901 --- /dev/null +++ b/src/autenticacao/_usuarios_quipo_vincular.ts @@ -0,0 +1,43 @@ +import node_fetch from "cross-fetch" +import { respostaComuns, type tipoResposta } from "p-respostas" +import type { z } from "zod" +import type { zAmbiente } from "../ts/ambiente" +import { urlAutenticacao } from "./_urlAutenticacao" + +export const usuarios_quipo_vincular = async ({ + token_produto, + ambiente, + conta, + vinculo, + codigo_usuario, + email, +}: { + ambiente: z.infer + token_produto: string + conta: string + vinculo: string + codigo_usuario?: string + email: string +}): Promise> => { + const url = `${urlAutenticacao(ambiente)}/api/vinculos__criar` + + if (!token_produto) return 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 node_fetch(url, { + headers, + body: JSON.stringify(parametros), + method: "POST", + }) + .then(async (r) => await r.json()) + .catch((e) => + respostaComuns.erro(`Erro ao criar vinculo de usuario ${e.message}`), + ) +} diff --git a/src/autenticacao/index.ts b/src/autenticacao/index.ts index a965ebe..2ca5ea4 100644 --- a/src/autenticacao/index.ts +++ b/src/autenticacao/index.ts @@ -4,6 +4,7 @@ import { type tipoUsuarioExterno, usuarios_quipo_governo, } from "./_usuarios_quipo_governo" +import { usuarios_quipo_vincular } from "./_usuarios_quipo_vincular" import { validarToken } from "./_validarToken" export type { tipoUsuarioExterno } @@ -14,4 +15,5 @@ export const pAutenticacao = { urlAutenticacao, codigoContaSite, usuarios_quipo_governo, + usuarios_quipo_vincular, } diff --git a/src/email/index.ts b/src/email/index.ts new file mode 100644 index 0000000..17d1ef9 --- /dev/null +++ b/src/email/index.ts @@ -0,0 +1,69 @@ +import nodemailer from "nodemailer" +import { respostaComuns, type tipoResposta } from "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", +// }; +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@gestao-ambiental-brasil.idz.one", + nomeDe: "🌱 Betha Meio Ambiente", +} + +export const enviarEmail = async ({ + email, + nome, + assunto, + texto, + htlm, +}: { + email: string + nome?: string + assunto: string + /** Verão em texto do html, não obrigatório */ + texto?: string + htlm: string +}): Promise> => { + const info = await nodemailer + .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(() => + respostaComuns.valor(`Email "${assunto}" enviado para ${email}`), + ) + .catch((err) => { + console.error(err) + return respostaComuns.erro( + `Erro ao enviar email para ${email}: ${err.message}`, + ) + }) + + return info +} diff --git a/src/index.ts b/src/index.ts index 0a73418..424d70c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,3 +4,4 @@ export * from "./produtos" export * from "./pilao-de-dados" export * from "./residuos" export * from "./NPS" +export * from "./email" diff --git a/src/residuos/index.ts b/src/residuos/index.ts index 1df6a61..3cfa236 100644 --- a/src/residuos/index.ts +++ b/src/residuos/index.ts @@ -9,6 +9,7 @@ export const zAuntenticacaoResiduos = z.object({ documento_usuario: z.string(), organizacao: z.string(), rotas: z.object({}), + tipo_usuario: z.string(), // Dados do sistema sistema: z.string(),