From 44782def29caa4bb4fc3d49b3151fed3e07497b5 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Thu, 25 Jan 2024 16:20:28 -0800 Subject: [PATCH 1/6] =?UTF-8?q?Atualiza=C3=A7=C3=B5es=20dos=20pacotes=20`d?= =?UTF-8?q?elegua-node`=20e=20`lmht-js`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- yarn.lock | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 4e22641..9cd652b 100644 --- a/package.json +++ b/package.json @@ -39,11 +39,11 @@ "swagger": "tsoa spec" }, "dependencies": { - "@designliquido/delegua-node": "^0.30.3", + "@designliquido/delegua-node": "^0.30.4", "@designliquido/flexoes": "^0.1.0", "@designliquido/foles": "^0.6.1", "@designliquido/lincones-sqlite": "^0.0.2", - "@designliquido/lmht-js": "^0.4.5", + "@designliquido/lmht-js": "^0.4.6", "body-parser": "^1.20.1", "commander": "^11.1.0", "cookie-parser": "^1.4.6", diff --git a/yarn.lock b/yarn.lock index 3abbaf2..32454d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,21 +304,21 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@designliquido/delegua-node@^0.30.3": - version "0.30.3" - resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.3.tgz#126569987b2b49d95e702d0d5d77743d22ae8e72" - integrity sha512-Fo7ZdRp3VW6E8UMY/+RGUUMeDu+3RlUGct37nfzbJuRgenlRFJEgvHL/P5GJBHjFFXyfsVe19nK3+F6kcVT9Zg== +"@designliquido/delegua-node@^0.30.4": + version "0.30.4" + resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.4.tgz#4e996ad955c929ffd80dbc856702ec038b373f8c" + integrity sha512-DLUhZtgckCC8oHTMj/2SLz5D2+GCF6KdKBp5p6xEjYK0FjdCql74WBjghKliRKMRc/SY9xZbFMLrXZdRJwMwAg== dependencies: - "@designliquido/delegua" "0.30.3" + "@designliquido/delegua" "0.30.4" chalk "4.1.2" commander "^9.4.1" json-colorizer "^2.2.2" lodash.clonedeep "^4.5.0" -"@designliquido/delegua@0.30.3": - version "0.30.3" - resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.3.tgz#c901c56c795df0a7822a363af643c7fff45d61cb" - integrity sha512-CGGHJrX/eW7ChdO2gFpDU6SP0Gls6i4YFeN4orU5PfOb9pN55Mu5PYPKZGbFfF/aS6klYzp4T1OXboxgsgWLDw== +"@designliquido/delegua@0.30.4": + version "0.30.4" + resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.4.tgz#a89f93e1f2911d017c7bae1bcd9c5c889d163b0d" + integrity sha512-6NbbiXoELSHgTehFYBveZCF6LcqAO5xMcMlLy7Sc45rOlKDhBmtMO0MZY7/K6AgTZDQ9w0FYUk3hwCj1eCs6Zg== dependencies: antlr4ts "^0.5.0-alpha.4" browser-process-hrtime "^1.0.0" @@ -348,10 +348,10 @@ sqlite "4.1.2" sqlite3 "^5.1.4" -"@designliquido/lmht-js@^0.4.5": - version "0.4.5" - resolved "https://registry.yarnpkg.com/@designliquido/lmht-js/-/lmht-js-0.4.5.tgz#5a31cb4a62a989d4cca97dd0a88035d5adf0cc0b" - integrity sha512-Y9DzF4XLjrxXtz6KDXBY3TJ9bUlepLJNUTKRT41OAh+5P8c2E7dYhVMZm2nvlq26IPmEwVwHNslEF4ueipgCgQ== +"@designliquido/lmht-js@^0.4.6": + version "0.4.6" + resolved "https://registry.yarnpkg.com/@designliquido/lmht-js/-/lmht-js-0.4.6.tgz#1749bdcf3fac9a138f7fa3dd00c2808e49c96e3c" + integrity sha512-qySduEh70ByJx4JXMSlmAKQ71gcP17cJz7FeFbpELZQYeNqwqWTyFSJDAncXO253o5z69jPxoTiTD49dr29m8w== dependencies: jsdom "^21.1.1" xslt-processor "^2.1.3" From 36462327d7aa6560df837237269a13e0dab1a6d6 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Sat, 27 Jan 2024 10:46:03 -0800 Subject: [PATCH 2/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20de=20`delegua-node`?= =?UTF-8?q?=20para=20a=20vers=C3=A3o=200.30.5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index 9cd652b..cdc0209 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "swagger": "tsoa spec" }, "dependencies": { - "@designliquido/delegua-node": "^0.30.4", + "@designliquido/delegua-node": "^0.30.5", "@designliquido/flexoes": "^0.1.0", "@designliquido/foles": "^0.6.1", "@designliquido/lincones-sqlite": "^0.0.2", diff --git a/yarn.lock b/yarn.lock index 32454d4..cd8f5e6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,21 +304,21 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@designliquido/delegua-node@^0.30.4": - version "0.30.4" - resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.4.tgz#4e996ad955c929ffd80dbc856702ec038b373f8c" - integrity sha512-DLUhZtgckCC8oHTMj/2SLz5D2+GCF6KdKBp5p6xEjYK0FjdCql74WBjghKliRKMRc/SY9xZbFMLrXZdRJwMwAg== +"@designliquido/delegua-node@^0.30.5": + version "0.30.5" + resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.5.tgz#022a9671661c96b40875d34a3a7a323ddd3e808b" + integrity sha512-nAhdQ1PfH/lv4GiTZVfMIBqIImH9wzmy0AaC4BdVlkS5yTNSxzdBpI1rXYEBMFO7fFTmyp57LvoglkvkLIwCow== dependencies: - "@designliquido/delegua" "0.30.4" + "@designliquido/delegua" "0.30.5" chalk "4.1.2" commander "^9.4.1" json-colorizer "^2.2.2" lodash.clonedeep "^4.5.0" -"@designliquido/delegua@0.30.4": - version "0.30.4" - resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.4.tgz#a89f93e1f2911d017c7bae1bcd9c5c889d163b0d" - integrity sha512-6NbbiXoELSHgTehFYBveZCF6LcqAO5xMcMlLy7Sc45rOlKDhBmtMO0MZY7/K6AgTZDQ9w0FYUk3hwCj1eCs6Zg== +"@designliquido/delegua@0.30.5": + version "0.30.5" + resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.5.tgz#abf032f542c3aee15cdf21a95fe23bb55628ce1d" + integrity sha512-wEcRrwL2+lPWJtNmUkgdtxpPPcmFHpf2CUewV/toDxDRVdxmaGyydcyK9laOegfLTi0QZ+5/EYyArjZ+XLMz6w== dependencies: antlr4ts "^0.5.0-alpha.4" browser-process-hrtime "^1.0.0" From f43fc3fbd0c063a6cdf221f2b57c0a44adc98641 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Sun, 28 Jan 2024 23:02:09 -0800 Subject: [PATCH 3/6] =?UTF-8?q?-=20Atualiza=C3=A7=C3=A3o=20de=20`lmht-js`?= =?UTF-8?q?=20para=20a=20vers=C3=A3o=200.4.8;=20-=20Atualiza=C3=A7=C3=A3o?= =?UTF-8?q?=20em=20vis=C3=B5es=20com=20formul=C3=A1rio.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gerar/gerador-visoes.ts | 12 ++++++------ package.json | 2 +- yarn.lock | 18 +++++++++--------- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/interface-linha-comando/gerar/gerador-visoes.ts b/interface-linha-comando/gerar/gerador-visoes.ts index aaeb6c6..2687915 100644 --- a/interface-linha-comando/gerar/gerador-visoes.ts +++ b/interface-linha-comando/gerar/gerador-visoes.ts @@ -140,7 +140,7 @@ export class GeradorVisoes { const listaPropriedades: string[] = []; for (const propriedade of declaracaoModelo.propriedades) { listaPropriedades.push(" ".repeat(this.indentacao * 4) + `${propriedade.nome.lexema}`); - listaPropriedades.push(" ".repeat(this.indentacao * 4) + ``); + listaPropriedades.push(" ".repeat(this.indentacao * 4) + ``); } return listaPropriedades.reduce( @@ -162,7 +162,7 @@ export class GeradorVisoes { const formulario = `${" ".repeat(this.indentacao * 2)}\n` + `${relacaoPropriedades}` + - `\n\n${" ".repeat(this.indentacao * 3)}Adicionar\n` + + `\n\n${" ".repeat(this.indentacao * 3)}\n` + `${" ".repeat(this.indentacao * 2)}\n`; return `${titulo}${formulario}`; } @@ -176,9 +176,9 @@ export class GeradorVisoes { const titulo = `${" ".repeat(this.indentacao * 2)}Editar ${declaracaoModelo.simbolo.lexema}\n`; const relacaoPropriedades = `${" ".repeat(this.indentacao * 3)}\n` + - `${" ".repeat(this.indentacao * 4)}\n` + + `${" ".repeat(this.indentacao * 4)}\n` + this.geracaoComumCamposFormulario(declaracaoModelo) + - `\n\n${" ".repeat(this.indentacao * 4)}Atualizar\n` + + `\n\n${" ".repeat(this.indentacao * 4)}\n` + `\n${" ".repeat(this.indentacao * 3)}\n`; const formulario = `${" ".repeat(this.indentacao * 2)}\n`+ @@ -201,8 +201,8 @@ export class GeradorVisoes { `\n${" ".repeat(this.indentacao * 2)}\n`; const formulario = `${" ".repeat(this.indentacao * 2)}\n`+ - `${" ".repeat(this.indentacao * 3)}\n` + - `${" ".repeat(this.indentacao * 3)}Confirmar Exclusão\n` + + `${" ".repeat(this.indentacao * 3)}\n` + + `${" ".repeat(this.indentacao * 3)}\n` + `${" ".repeat(this.indentacao * 2)}\n`; return `${titulo}${mensagemConfirmacaoExclusao}${relacaoPropriedades}${formulario}`; diff --git a/package.json b/package.json index cdc0209..d0b8760 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "@designliquido/flexoes": "^0.1.0", "@designliquido/foles": "^0.6.1", "@designliquido/lincones-sqlite": "^0.0.2", - "@designliquido/lmht-js": "^0.4.6", + "@designliquido/lmht-js": "^0.4.8", "body-parser": "^1.20.1", "commander": "^11.1.0", "cookie-parser": "^1.4.6", diff --git a/yarn.lock b/yarn.lock index cd8f5e6..7874818 100644 --- a/yarn.lock +++ b/yarn.lock @@ -348,13 +348,13 @@ sqlite "4.1.2" sqlite3 "^5.1.4" -"@designliquido/lmht-js@^0.4.6": - version "0.4.6" - resolved "https://registry.yarnpkg.com/@designliquido/lmht-js/-/lmht-js-0.4.6.tgz#1749bdcf3fac9a138f7fa3dd00c2808e49c96e3c" - integrity sha512-qySduEh70ByJx4JXMSlmAKQ71gcP17cJz7FeFbpELZQYeNqwqWTyFSJDAncXO253o5z69jPxoTiTD49dr29m8w== +"@designliquido/lmht-js@^0.4.8": + version "0.4.8" + resolved "https://registry.yarnpkg.com/@designliquido/lmht-js/-/lmht-js-0.4.8.tgz#4718c81c0b286574f69dac4d399a47e19e8e05fb" + integrity sha512-VvbAe9+TXSqV9+NJQB/WknOqkC5Rm2HlEddCrJVFnbKItv1XNRVG2Tz85zrrNVoSCCEKEZ7aHiioJkoKVAYfpw== dependencies: jsdom "^21.1.1" - xslt-processor "^2.1.3" + xslt-processor "^2.2.0" "@eslint/eslintrc@^1.3.3": version "1.3.3" @@ -6309,10 +6309,10 @@ xregexp@2.0.0: resolved "https://registry.yarnpkg.com/xregexp/-/xregexp-2.0.0.tgz#52a63e56ca0b84a7f3a5f3d61872f126ad7a5943" integrity sha512-xl/50/Cf32VsGq/1R8jJE5ajH1yMCQkpmoS10QbFZWl2Oor4H0Me64Pu2yxvsRWK3m6soJbmGfzSR7BYmDcWAA== -xslt-processor@^2.1.3: - version "2.1.3" - resolved "https://registry.yarnpkg.com/xslt-processor/-/xslt-processor-2.1.3.tgz#2380190f4ae383cc1f22173690ebc051d3f2e022" - integrity sha512-WiYeocbC/Y7SmRO7FAHUCx7mmGstd82CKiuWiJG3lYQYTbSHl/e1PVCuVuCVSY4ZHlGRkey48rgvCEEdAtlrjQ== +xslt-processor@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/xslt-processor/-/xslt-processor-2.2.0.tgz#ce4a91fcb3863c80b2b5c57854e8bc1d0a3a37bc" + integrity sha512-gmBVzwqWpVr72H/b71AK2LhNQARsj3RxPX8tQRXsLPJ0dagVmu6JmFzhsTm6kK0wuDJ5NLQQ2V1GzRKlK6zMfA== dependencies: he "^1.2.0" From c9173046dab3b7cbcbd067d63903f06e2c31103c Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Mon, 29 Jan 2024 12:00:24 -0800 Subject: [PATCH 4/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20de=20`delegua-node`?= =?UTF-8?q?=20para=20a=20vers=C3=A3o=200.30.7.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- yarn.lock | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package.json b/package.json index d0b8760..aaf09e0 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "swagger": "tsoa spec" }, "dependencies": { - "@designliquido/delegua-node": "^0.30.5", + "@designliquido/delegua-node": "^0.30.7", "@designliquido/flexoes": "^0.1.0", "@designliquido/foles": "^0.6.1", "@designliquido/lincones-sqlite": "^0.0.2", diff --git a/yarn.lock b/yarn.lock index 7874818..16d10b2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -304,21 +304,21 @@ dependencies: "@jridgewell/trace-mapping" "0.3.9" -"@designliquido/delegua-node@^0.30.5": - version "0.30.5" - resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.5.tgz#022a9671661c96b40875d34a3a7a323ddd3e808b" - integrity sha512-nAhdQ1PfH/lv4GiTZVfMIBqIImH9wzmy0AaC4BdVlkS5yTNSxzdBpI1rXYEBMFO7fFTmyp57LvoglkvkLIwCow== +"@designliquido/delegua-node@^0.30.7": + version "0.30.7" + resolved "https://registry.yarnpkg.com/@designliquido/delegua-node/-/delegua-node-0.30.7.tgz#c6bb323265aae071465c15aea3d4a767296b2663" + integrity sha512-3hc9ft3yWzHOoPBDDHytikKINBPmheupXvFkMws5GVlyqrICkoZG5+N377DHxwhDwpNSMgLLNeJl+R2w1PsJ/Q== dependencies: - "@designliquido/delegua" "0.30.5" + "@designliquido/delegua" "0.30.7" chalk "4.1.2" commander "^9.4.1" json-colorizer "^2.2.2" lodash.clonedeep "^4.5.0" -"@designliquido/delegua@0.30.5": - version "0.30.5" - resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.5.tgz#abf032f542c3aee15cdf21a95fe23bb55628ce1d" - integrity sha512-wEcRrwL2+lPWJtNmUkgdtxpPPcmFHpf2CUewV/toDxDRVdxmaGyydcyK9laOegfLTi0QZ+5/EYyArjZ+XLMz6w== +"@designliquido/delegua@0.30.7": + version "0.30.7" + resolved "https://registry.yarnpkg.com/@designliquido/delegua/-/delegua-0.30.7.tgz#7f4a97f5ef0d1583ba033ffe8c0fd0ea2e19bd6f" + integrity sha512-8kJ9lDoC/Ak0IkWOn4hjrMk4W8vwT8jcrpbSZp4Ql3DbXaykGZ2XZfZMehm0IiLNw/1UFW8YOnSS4/n5/14IaA== dependencies: antlr4ts "^0.5.0-alpha.4" browser-process-hrtime "^1.0.0" From 042c3eb6697d7b14823a87c12b3e8582bf5c7765 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:28:29 -0800 Subject: [PATCH 5/6] =?UTF-8?q?Fun=C3=A7=C3=A3o=20`redirecionar()`=20para?= =?UTF-8?q?=20classe=20`Resposta`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infraestrutura/resposta.ts | 54 +++++++++++--------------------------- liquido.ts | 35 +++++++++++++++--------- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/infraestrutura/resposta.ts b/infraestrutura/resposta.ts index 52e93f9..da2e26e 100644 --- a/infraestrutura/resposta.ts +++ b/infraestrutura/resposta.ts @@ -1,5 +1,5 @@ import { Simbolo } from '@designliquido/delegua/fontes/lexador'; -import { DefinirValor, FuncaoConstruto, Isto, Literal, Variavel } from '@designliquido/delegua/fontes/construtos'; +import { DefinirValor, FuncaoConstruto, Isto, Variavel } from '@designliquido/delegua/fontes/construtos'; import { Expressao, PropriedadeClasse, Retorna } from '@designliquido/delegua/fontes/declaracoes'; import { DeleguaClasse, DeleguaFuncao } from '@designliquido/delegua/fontes/estruturas'; import { ParametroInterface } from '@designliquido/delegua/fontes/interfaces'; @@ -15,6 +15,10 @@ export class Resposta extends DeleguaClasse { constructor() { const metodos = {}; const propriedades = [ + new PropriedadeClasse( + new Simbolo('IDENTIFICADOR', 'destino', null, -1, -1), + 'texto' + ), new PropriedadeClasse( new Simbolo('IDENTIFICADOR', 'mensagem', null, -1, -1), 'texto' @@ -163,46 +167,20 @@ export class Resposta extends DeleguaClasse { geradorExpressoes.gerarRetornoDeFuncao('isto') ]) ); - /* metodos['lmht'] = new DeleguaFuncao( - 'lmht', - new FuncaoConstruto( - -1, - -1, - [ - { - abrangencia: 'padrao', - tipo: 'numero', - nome: new Simbolo('IDENTIFICADOR', 'valores', null, -1, -1) - } as ParametroInterface - ], + + metodos['redirecionar'] = geradorExpressoes.gerarMetodo('redirecionar', + geradorExpressoes.gerarConstrutoFuncao( + [geradorExpressoes.gerarParametro('destino', 'texto')], [ - new Expressao( - new DefinirValor( - -1, - -1, - new Isto(-1, -1, new Simbolo('ISTO', 'isto', null, -1, -1)), - new Simbolo('IDENTIFICADOR', 'valores', null, -1, -1), - new Variavel(-1, new Simbolo('IDENTIFICADOR', 'valores', null, -1, -1)) - ) - ), - new Expressao( - new DefinirValor( - -1, - -1, - new Isto(-1, -1, new Simbolo('ISTO', 'isto', null, -1, -1)), - new Simbolo('IDENTIFICADOR', 'lmht', null, -1, -1), - new Literal(-1, -1, true) - ) + geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse( + 'destino', + geradorExpressoes.gerarReferenciaVariavel('destino') ), - new Retorna( - new Simbolo('IDENTIFICADOR', 'qualquerCoisa', null, -1, -1), - new Variavel(-1, new Simbolo('IDENTIFICADOR', 'isto', null, -1, -1)) - ) + geradorExpressoes.gerarRetornoDeFuncao('isto') ] - ), - null, - false - ); */ + ) + ); + super( new Simbolo('IDENTIFICADOR', 'Resposta', null, -1, -1), null, diff --git a/liquido.ts b/liquido.ts index f60db89..5273fb4 100644 --- a/liquido.ts +++ b/liquido.ts @@ -331,7 +331,7 @@ export class Liquido implements LiquidoInterface { private async logicaComumResultadoInterpretador( caminhoRota: string, retornoInterpretador: RetornoInterpretador - ): Promise<{ corpoRetorno: any; statusHttp: number }> { + ): Promise<{ corpoRetorno?: any; statusHttp?: number, redirecionamento?: string }> { // O resultado que interessa é sempre o último. // Ele vem como string, e precisa ser desserializado para ser usado. @@ -341,9 +341,14 @@ export class Liquido implements LiquidoInterface { if (valor.propriedades.statusHttp) { statusHttp = valor.propriedades.statusHttp; } - - try { - if (valor.propriedades.lmht) { + + if (valor.propriedades.destino) { + // Redirecionamento + return { redirecionamento: valor.propriedades.destino }; + } + + if (valor.propriedades.lmht) { + try { let visao: string = caminhoRota; // Verifica se foi definida uma preferência de visão. // Se não foi, usa o sufixo da rota como visão correspondente. @@ -359,14 +364,16 @@ export class Liquido implements LiquidoInterface { corpoRetorno: resultadoFormatacaoLmht, statusHttp: statusHttp }; - } else if (valor.propriedades.mensagem) { - return { - corpoRetorno: valor.propriedades.mensagem, - statusHttp: statusHttp - }; + } catch (erro: any) { + console.log(`Erro ao processar LMHT: ${erro}`); } - } catch (erro: any) { - console.log(`Erro ao processar LMHT: ${erro}`); + } + + if (valor.propriedades.mensagem) { + return { + corpoRetorno: valor.propriedades.mensagem, + statusHttp: statusHttp + }; } } @@ -387,7 +394,11 @@ export class Liquido implements LiquidoInterface { const retornoInterpretador = await this.chamarInterpretador(`funcaoRota${metodoRoteador}`); const corpoEStatus = await this.logicaComumResultadoInterpretador(caminhoRota, retornoInterpretador); - res.send(corpoEStatus.corpoRetorno).status(corpoEStatus.statusHttp); + if (corpoEStatus.redirecionamento) { + res.redirect(corpoEStatus.redirecionamento); + } else { + res.send(corpoEStatus.corpoRetorno).status(corpoEStatus.statusHttp); + } }); } } From 3c22da7340b64c0f5a229485a786fd4da91969a9 Mon Sep 17 00:00:00 2001 From: Leonel Sanches da Silva <53848829+leonelsanchesdasilva@users.noreply.github.com> Date: Mon, 29 Jan 2024 13:55:51 -0800 Subject: [PATCH 6/6] Gerando rotas com redirecionamentos. --- interface-linha-comando/gerar/gerador-rotas.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/interface-linha-comando/gerar/gerador-rotas.ts b/interface-linha-comando/gerar/gerador-rotas.ts index 431595a..518d1dd 100644 --- a/interface-linha-comando/gerar/gerador-rotas.ts +++ b/interface-linha-comando/gerar/gerador-rotas.ts @@ -45,7 +45,8 @@ export class GeradorRotas { */ private criarNovasRotasSemId(declaracaoModelo: Classe, diretorioRotas: string): string { const conteudoSelecionarTudo = this.criarRotaSelecionarTudo(declaracaoModelo); - const conteudoAdicionar = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.lmht({ "titulo": "Liquido" })\n})\n\n`; + const nomeModeloPlural = pluralizar(declaracaoModelo.simbolo.lexema.toLocaleLowerCase('pt')).toLocaleLowerCase('pt'); + const conteudoAdicionar = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.redirecionar("/${nomeModeloPlural}")\n})\n\n`; const conteudoRotas = `${conteudoSelecionarTudo}${conteudoAdicionar}`; const caminhoRotas = caminho.join(diretorioRotas, 'inicial.delegua'); @@ -64,11 +65,12 @@ export class GeradorRotas { * @returns O caminho do arquivo de rotas no sistema de arquivos. */ private criarNovasRotasComId(declaracaoModelo: Classe, diretorioRotas: string): string[] { + const nomeModeloPlural = pluralizar(declaracaoModelo.simbolo.lexema.toLocaleLowerCase('pt')).toLocaleLowerCase('pt'); const conteudoSelecionarUm = this.criarRotaSelecionarUm(declaracaoModelo); const conteudoSelecionarParaEdicao = this.criarRotaEditar(declaracaoModelo); - const conteudoAtualizar = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.lmht({ "titulo": "Liquido" })\n})\n\n`; + const conteudoAtualizar = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.redirecionar("/${nomeModeloPlural}")\n})\n\n`; const conteudoSelecionarParaExclusao = this.criarRotaConfirmarExclusao(declaracaoModelo); - const conteudoExcluir = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.lmht({ "titulo": "Liquido" })\n})\n\n`; + const conteudoExcluir = `liquido.rotaPost(funcao(requisicao, resposta) {\n resposta.redirecionar("/${nomeModeloPlural}")\n})\n\n`; const diretorioRotasComId = criarDiretorioComIdSeNaoExiste(diretorioRotas);