UNPKG

@designliquido/lincones-postgresql

Version:
56 lines 2.66 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.LinconesPostgreSQL = void 0; const dotenv = __importStar(require("dotenv")); const tradutor_1 = require("./tradutor"); const avaliador_sintatico_1 = require("./comum/fontes/avaliador-sintatico"); const lexador_1 = require("./comum/fontes/lexador"); const cliente_postgresql_1 = require("./infraestrutura/cliente-postgresql"); const infraestrutura_1 = require("./infraestrutura"); dotenv.config(); class LinconesPostgreSQL { constructor() { this.lexador = new lexador_1.Lexador(); this.avaliadorSintatico = new avaliador_sintatico_1.AvaliadorSintatico(); this.tradutor = new tradutor_1.Tradutor(); this.clientePostgreSQL = new cliente_postgresql_1.ClientePostgreSQL(); } async executar(_, comando) { if (!comando) return new infraestrutura_1.RetornoComando(null); const resultadoLexador = this.lexador.mapear([comando]); const resultadoAvaliacaoSintatica = this.avaliadorSintatico.analisar(resultadoLexador); if (resultadoAvaliacaoSintatica.erros.length > 0) { throw `O comando '${comando}' digitado não é válido, tente novamente.`; } const resultadoTraducao = this.tradutor.traduzir(resultadoAvaliacaoSintatica.comandos); const resultadoExecucao = await this.clientePostgreSQL.executarComando(resultadoTraducao); const retorno = new infraestrutura_1.RetornoComando(resultadoExecucao); return retorno; } } exports.LinconesPostgreSQL = LinconesPostgreSQL; //# sourceMappingURL=lincones-postgresql.js.map