Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Era pra ser só a lógica de geração de rotas "selecionar um", mas... #34

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 117 additions & 40 deletions infraestrutura/resposta.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Simbolo } from '@designliquido/delegua/fontes/lexador';
import { DefinirValor, FuncaoConstruto, Isto, Literal, Variavel } from '@designliquido/delegua/fontes/construtos';
import { Expressao, Retorna } from '@designliquido/delegua/fontes/declaracoes';
import { Expressao, PropriedadeClasse, Retorna } from '@designliquido/delegua/fontes/declaracoes';
import { DeleguaClasse, DeleguaFuncao } from '@designliquido/delegua/fontes/estruturas';
import { ParametroInterface } from '@designliquido/delegua/fontes/interfaces';

import { GeradorExpressoes } from './utilidades/gerador-expressoes';

/**
Expand All @@ -13,53 +14,65 @@
export class Resposta extends DeleguaClasse {
constructor() {
const metodos = {};
const propriedades = [
new PropriedadeClasse(
new Simbolo('IDENTIFICADOR', 'mensagem', null, -1, -1),
'texto'
),
new PropriedadeClasse(
new Simbolo('IDENTIFICADOR', 'statusHttp', null, -1, -1),
'numero'
),
new PropriedadeClasse(
new Simbolo('IDENTIFICADOR', 'valores', null, -1, -1),
'dicionário'
),
new PropriedadeClasse(
new Simbolo('IDENTIFICADOR', 'visao', null, -1, -1),
'texto'
)
];

// Há duas formas de construção de métodos apenas usando
// estruturas de alto nível: declarando cada uma manualmente,
// ou usando o gerador de expressões.
// O exemplo abaixo utiliza o gerador de expressões.
// Seria o equivalente à seguinte implementação em Delégua:

// Todo @Italo: Verificar se isso é melhor para instrumentar métodos.
/* const geradorExpressoes = new GeradorExpressoes();
metodos['enviar'] = geradorExpressoes.gerarMetodo('enviar',
geradorExpressoes.gerarDeclaracao(
[geradorExpressoes.gerarParametro('mensagem', 'numero')],
// classe Resposta {
// // Outros método e propriedades aqui
// enviar(mensagem: texto) {
// isto.mensagem = mensagem
// retorna isto
// }
// }

const geradorExpressoes = new GeradorExpressoes();
metodos['enviar'] = geradorExpressoes.gerarMetodo('enviar',
geradorExpressoes.gerarConstrutoFuncao(
[geradorExpressoes.gerarParametro('mensagem', 'texto')],
[
geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse(
'mensagem',
geradorExpressoes.gerarReferenciaVariavel('mensagem')
),
geradorExpressoes.gerarRetornoDeFuncao('isto')
]
)
); */

metodos['enviar'] = new DeleguaFuncao(
'enviar',
new FuncaoConstruto(
-1,
-1,
[
{
abrangencia: 'padrao',
tipo: 'numero',
nome: new Simbolo('IDENTIFICADOR', 'mensagem', null, -1, -1)
} as ParametroInterface
],
[
new Expressao(
new DefinirValor(
-1,
-1,
new Isto(-1, -1, new Simbolo('ISTO', 'isto', null, -1, -1)),
new Simbolo('IDENTIFICADOR', 'mensagem', null, -1, -1),
new Variavel(-1, new Simbolo('IDENTIFICADOR', 'mensagem', null, -1, -1))
)
),
new Retorna(
new Simbolo('IDENTIFICADOR', 'qualquerCoisa', null, -1, -1),
new Variavel(-1, new Simbolo('IDENTIFICADOR', 'isto', null, -1, -1))
)
]
),
null,
false
);

Check warning on line 62 in infraestrutura/resposta.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

// O exemplo abaixo gera um método `status` declarando manualmente
// todas as estruturas de alto nível de Delégua.
// Seria o equivalente à seguinte implementação:

// classe Resposta {
// // Outros método e propriedades aqui
// status(statusHttp: numero) {
// isto.statusHttp = statusHttp
// retorna isto
// }
// }

metodos['status'] = new DeleguaFuncao(
'status',
new FuncaoConstruto(
Expand Down Expand Up @@ -91,7 +104,66 @@
null,
false
);
metodos['lmht'] = new DeleguaFuncao(

// O exemplo abaixo gera um método `lmht` utilizando o gerador de expressões.
// Seria o equivalente à seguinte implementação:

// classe Resposta {
// visao: texto
// valores: dicionário
//
// lmht(*visaoEValores) {
// se visaoEValores.tamanho() > 1 {
// isto.visao = visaoEValores[0]
// isto.valores = visaoEValores[1]
// } senão {
// isto.valores = visaoEValores[0]
// }
//
// retorna isto
// }
// }

metodos['lmht'] = geradorExpressoes.gerarMetodo('lmht',
geradorExpressoes.gerarConstrutoFuncao(
[geradorExpressoes.gerarParametro('visaoEValores', 'vetor', 'multiplo')],
[
geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse(
'lmht',
geradorExpressoes.gerarLiteral(true)
),
geradorExpressoes.gerarDeclaracaoSe(
geradorExpressoes.gerarConstrutoBinario(
geradorExpressoes.gerarChamada(
geradorExpressoes.gerarAcessoMetodoOuPropriedade(
geradorExpressoes.gerarReferenciaVariavel('visaoEValores'),
'tamanho'
)
),
geradorExpressoes.gerarOperadorComparacao('maior'),
geradorExpressoes.gerarLiteral(1)
),
geradorExpressoes.gerarBlocoEscopo([ // Se
geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse(
'visao',
geradorExpressoes.gerarAcessoIndiceVariavel('visaoEValores', 0)
),
geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse(
'valores',
geradorExpressoes.gerarAcessoIndiceVariavel('visaoEValores', 1)
)
]),
geradorExpressoes.gerarBlocoEscopo([ // Senão
geradorExpressoes.gerarAtribuicaoValorEmPropriedadeClasse(
'valores',
geradorExpressoes.gerarAcessoIndiceVariavel('visaoEValores', 0)
),
])
),
geradorExpressoes.gerarRetornoDeFuncao('isto')
])
);

Check warning on line 165 in infraestrutura/resposta.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
/* metodos['lmht'] = new DeleguaFuncao(
'lmht',
new FuncaoConstruto(
-1,
Expand Down Expand Up @@ -130,7 +202,12 @@
),
null,
false
); */
super(
new Simbolo('IDENTIFICADOR', 'Resposta', null, -1, -1),
null,
metodos,
propriedades
);
super(new Simbolo('IDENTIFICADOR', 'Resposta', null, -1, -1), null, metodos);
}
}
71 changes: 64 additions & 7 deletions infraestrutura/utilidades/gerador-expressoes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { DeleguaFuncao } from '@designliquido/delegua/fontes/estruturas';
import { DefinirValor, FuncaoConstruto, Isto, Construto, Variavel } from '@designliquido/delegua/fontes/construtos';
import { ParametroInterface } from '@designliquido/delegua/fontes/interfaces';
import { DefinirValor, FuncaoConstruto, Isto, Construto, Variavel, Binario, Literal, Chamada, AcessoMetodoOuPropriedade, AcessoIndiceVariavel } from '@designliquido/delegua/fontes/construtos';
import { ParametroInterface, SimboloInterface } from '@designliquido/delegua/fontes/interfaces';
import { Simbolo } from '@designliquido/delegua/fontes/lexador';
import { Expressao, Retorna, Declaracao } from '@designliquido/delegua/fontes/declaracoes';
import { Expressao, Retorna, Declaracao, Se, Bloco } from '@designliquido/delegua/fontes/declaracoes';

/**
* O gerador de expressões é uma classe facilitadora para a criação de
Expand All @@ -11,20 +11,77 @@
*/
export class GeradorExpressoes {

gerarAcessoIndiceVariavel(variavel: string, indice: number): AcessoIndiceVariavel {

Check warning on line 14 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new AcessoIndiceVariavel(
-1,
new Variavel(
-1,
new Simbolo('IDENTIFICADOR', variavel, null, -1, -1)
),
new Literal(-1, -1, indice),
new Simbolo('COLCHETE_DIREITO', ']', null, -1, -1)
);

Check warning on line 23 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarAcessoMetodoOuPropriedade(objeto: Variavel, metodoOuPropriedade: string): AcessoMetodoOuPropriedade {

Check warning on line 26 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new AcessoMetodoOuPropriedade(
-1,
objeto,
new Simbolo('IDENTIFICADOR', metodoOuPropriedade, null, -1, -1)
);

Check warning on line 31 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarBlocoEscopo(declaracoes: Declaracao[]): Bloco {

Check warning on line 34 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new Bloco(-1, -1, declaracoes);

Check warning on line 35 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarChamada(entidadeChamada: AcessoMetodoOuPropriedade, argumentos: any[] = []): Chamada {

Check warning on line 38 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 38 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new Chamada(-1, entidadeChamada, null, argumentos);

Check warning on line 39 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarConstrutoBinario(ladoEsquerdo: Construto, operador: SimboloInterface, ladoDireito: Construto) {

Check warning on line 42 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new Binario(-1, ladoEsquerdo, operador, ladoDireito);

Check warning on line 43 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarConstrutoFuncao(parametros: ParametroInterface[], corpo: Declaracao[]): FuncaoConstruto {

Check warning on line 46 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new FuncaoConstruto(-1, -1, parametros, corpo);

Check warning on line 47 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarDeclaracaoSe(condicao: Construto, caminhoEntao: Declaracao, caminhoSenao?: Declaracao) {

Check warning on line 50 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new Se(condicao, caminhoEntao, [], caminhoSenao);

Check warning on line 51 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarLiteral(valor: any) {

Check warning on line 54 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return new Literal(-1, -1, valor);

Check warning on line 55 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarMetodo(nomeMetodo: string, declaracao: FuncaoConstruto): DeleguaFuncao {
return new DeleguaFuncao(nomeMetodo, declaracao, null, false);
}

gerarDeclaracao(parametros: ParametroInterface[], corpo: Declaracao[]): FuncaoConstruto {
return new FuncaoConstruto(-1, -1, parametros, corpo);
gerarOperadorComparacao(tipo: 'maior' | 'menor' | 'maiorOuIgual' | 'menorOuIgual' | 'igual' | 'diferente'): SimboloInterface {

Check warning on line 62 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
switch (tipo) {
case 'maior':
return new Simbolo('MAIOR', '>', null, -1, -1);

Check warning on line 65 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 65 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case 'menor':
return new Simbolo('MENOR', '<', null, -1, -1);

Check warning on line 67 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 67 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case 'maiorOuIgual':
return new Simbolo('MAIOR_IGUAL', '>=', null, -1, -1);

Check warning on line 69 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 69 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case 'menorOuIgual':
return new Simbolo('MENOR_IGUAL', '<=', null, -1, -1);

Check warning on line 71 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 71 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case 'igual':
return new Simbolo('IGUAL_IGUAL', '==', null, -1, -1);

Check warning on line 73 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 73 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
case 'diferente':
return new Simbolo('DIFERENTE', '!=', null, -1, -1);

Check warning on line 75 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 75 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch
}

Check warning on line 76 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarParametro(nome: string, tipo: string): ParametroInterface {
gerarParametro(nome: string, tipo: string, abrangencia: 'padrao' | 'multiplo' = 'padrao'): ParametroInterface {

Check warning on line 79 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

Check warning on line 79 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🕹️ Function is not covered

Warning! Not covered function
return {
abrangencia: 'padrao',
abrangencia: abrangencia,
tipo: tipo,
nome: new Simbolo('IDENTIFICADOR', nome, null, -1, -1)
} as ParametroInterface;

Check warning on line 84 in infraestrutura/utilidades/gerador-expressoes.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

gerarReferenciaVariavel(nomeVariavel: string) {
Expand Down
19 changes: 18 additions & 1 deletion interface-linha-comando/gerar/gerador-rotas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export class GeradorRotas {
* @returns O caminho do arquivo de rotas no sistema de arquivos.
*/
private criarNovasRotasComId(declaracaoModelo: Classe, diretorioRotas: string): string {
const conteudoSelecionarUm = `liquido.rotaGet(funcao(requisicao, resposta) {\n resposta.enviar(requisicao.params.id)\n})\n\n`;
const conteudoSelecionarUm = this.criarRotaSelecionarUm(declaracaoModelo);
const conteudoAtualizar = `liquido.rotaPut(funcao(requisicao, resposta) {\n resposta.lmht({ "titulo": "Liquido" })\n})\n\n`;
const conteudoExcluir = `liquido.rotaDelete(funcao(requisicao, resposta) {\n resposta.lmht({ "titulo": "Liquido" })\n})\n\n`;
const conteudoRotas = `${conteudoSelecionarUm}${conteudoAtualizar}${conteudoExcluir}`;
Expand Down Expand Up @@ -95,4 +95,21 @@ export class GeradorRotas {
`${" ".repeat(this.indentacao)}})\n` +
`})\n\n`;
}

private criarRotaSelecionarUm(declaracaoModelo: Classe) {
// Isso aqui não vai ficar assim.
// É preciso montar as partes de dados antes.
const dadosTestes = [];
for (const propriedade of declaracaoModelo.propriedades) {
dadosTestes.push(`"${propriedade.nome.lexema}": "Teste"`);
}

return `liquido.rotaGet(funcao(requisicao, resposta) {\n` +
`${" ".repeat(this.indentacao)}resposta.lmht("detalhes", {\n` +
`${" ".repeat(this.indentacao * 2)}${dadosTestes.reduce(
(acumulador, elemento) => acumulador + ', ' + elemento
)}\n` +
`${" ".repeat(this.indentacao)}})\n` +
`})\n\n`;
}
}
25 changes: 24 additions & 1 deletion interface-linha-comando/gerar/gerador-visoes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class GeradorVisoes {
break;
case 'selecionarUm':
caminhoVisao = caminho.join(diretorioVisoes, 'detalhes.lmht');
corpo = ' <corpo>Teste</corpo>\n';
corpo = `${" ".repeat(this.indentacao)}<corpo>\n${this.corpoDetalhes(declaracaoModelo)}\n${" ".repeat(this.indentacao)}</corpo>\n`;
break;
case 'adicionar':
caminhoVisao = caminho.join(diretorioVisoes, 'adicionar.lmht');
Expand Down Expand Up @@ -94,4 +94,27 @@ export class GeradorVisoes {

return `${" ".repeat(this.indentacao * 2)}<tabela>\n${cabecaTabela}\n${corpoTabela}\n${" ".repeat(this.indentacao * 2)}</tabela>`;
}

/**
* Função que gera o corpo de `detalhes.lmht` de cada visão gerada por linha de comando.
* @param {Classe} declaracaoModelo A declaração do modelo de dados, com suas propriedades e definições.
* @returns {string} Um trecho em LMHT com a estrutura do corpo da página.
*/
private corpoDetalhes(declaracaoModelo: Classe): string {
const titulo = `${" ".repeat(this.indentacao * 2)}<titulo1>Detalhes de ${declaracaoModelo.simbolo.lexema}</titulo1>\n`;

const listaPropriedades: string[] = [];
for (const propriedade of declaracaoModelo.propriedades) {
listaPropriedades.push(" ".repeat(this.indentacao * 3) + `<divisão>${propriedade.nome.lexema}</divisão>`);
listaPropriedades.push(" ".repeat(this.indentacao * 3) + `<divisão>{{${propriedade.nome.lexema}}}</divisão>`);
}

const relacaoPropriedades = `${" ".repeat(this.indentacao * 2)}<lista-definições>\n` +
listaPropriedades.reduce(
(acumulador, elemento) => acumulador + '\n' + elemento
) +
`\n${" ".repeat(this.indentacao * 2)}</lista-definições>\n`;

return `${titulo}${relacaoPropriedades}`;
}
}
12 changes: 11 additions & 1 deletion liquido.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,19 @@
statusHttp = valor.propriedades.statusHttp;
}

try {
if (valor.propriedades.lmht) {
const resultadoFormatacaoLmht = await this.formatadorLmht.formatar(caminhoRota, valor.propriedades.valores);
let visao: string = caminhoRota;

Check warning on line 340 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
// Verifica se foi definida uma preferência de visão.
// Se não foi, usa o sufixo da rota como visão correspondente.
// Por exemplo, `/rotas/inicial.delegua` tem como visão correspondente `/visoes/inicial.lmht`.
if (valor.propriedades.visao) {
const partesRota = caminhoRota.split('/');

Check warning on line 345 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
partesRota.pop();

Check warning on line 346 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
visao = partesRota.join('/') + '/' + valor.propriedades.visao;

Check warning on line 347 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 348 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement

Check warning on line 348 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🌿 Branch is not covered

Warning! Not covered branch

const resultadoFormatacaoLmht = await this.formatadorLmht.formatar(visao, valor.propriedades.valores);

Check warning on line 350 in liquido.ts

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
return {
corpoRetorno: resultadoFormatacaoLmht,
statusHttp: statusHttp
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"swagger": "tsoa spec"
},
"dependencies": {
"@designliquido/delegua-node": "^0.29.1",
"@designliquido/delegua-node": "^0.29.2",
"@designliquido/flexoes": "^0.1.0",
"@designliquido/foles": "^0.6.1",
"@designliquido/lincones-sqlite": "^0.0.2",
Expand Down
2 changes: 1 addition & 1 deletion rotas/blog/inicial.delegua
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
liquido.rotaGet(funcao(requisicao, resposta) {
resposta.lmht({ "titulo": "Blog" })
})
})
Loading
Loading