@semacode/cli 1.5.36 → 1.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENT_CONTEXT_PACK.json +76 -8
- package/LICENSE +1 -2
- package/SEMA_BRIEF.curto.txt +8 -6
- package/SEMA_BRIEF.md +240 -204
- package/SEMA_BRIEF.micro.txt +9 -6
- package/SEMA_INDEX.json +2079 -1907
- package/dist/agentContext.d.ts +19 -0
- package/dist/agentContext.js +26 -0
- package/dist/agentContext.js.map +1 -0
- package/dist/agentContextPack.d.ts +3 -0
- package/dist/agentContextPack.js +403 -0
- package/dist/agentContextPack.js.map +1 -0
- package/dist/agentContextTipos.d.ts +96 -0
- package/dist/agentContextTipos.js +55 -0
- package/dist/agentContextTipos.js.map +1 -0
- package/dist/agentEntryPoints.d.ts +13 -0
- package/dist/agentEntryPoints.js +422 -0
- package/dist/agentEntryPoints.js.map +1 -0
- package/dist/authorAnalise.d.ts +15 -0
- package/dist/authorAnalise.js +210 -0
- package/dist/authorAnalise.js.map +1 -0
- package/dist/authorPoliticas.d.ts +37 -0
- package/dist/authorPoliticas.js +340 -0
- package/dist/authorPoliticas.js.map +1 -0
- package/dist/billing/index.d.ts +1 -1
- package/dist/billing/index.js +6 -2
- package/dist/billing/index.js.map +1 -1
- package/dist/bridge.js +2 -0
- package/dist/bridge.js.map +1 -1
- package/dist/carregarModulos.d.ts +2 -0
- package/dist/carregarModulos.js +9 -0
- package/dist/carregarModulos.js.map +1 -0
- package/dist/cliArgs.d.ts +6 -0
- package/dist/cliArgs.js +70 -0
- package/dist/cliArgs.js.map +1 -0
- package/dist/contexto.js +2 -0
- package/dist/contexto.js.map +1 -1
- package/dist/controleComercialSupabase.js.map +1 -1
- package/dist/controleComercialSupabaseAdmin.js.map +1 -1
- package/dist/controleComercialSupabaseCadastro.js.map +1 -1
- package/dist/controleComercialSupabaseConsumo.js.map +1 -1
- package/dist/controleComercialSupabaseConta.js.map +1 -1
- package/dist/controleComercialSupabaseProfiles.js.map +1 -1
- package/dist/dev/index.js +2 -0
- package/dist/dev/index.js.map +1 -1
- package/dist/dev/watcher.d.ts +1 -0
- package/dist/dev/watcher.js +4 -0
- package/dist/dev/watcher.js.map +1 -0
- package/dist/docs/resolver.d.ts +1 -0
- package/dist/docs/resolver.js +4 -0
- package/dist/docs/resolver.js.map +1 -0
- package/dist/docs.d.ts +2 -56
- package/dist/docs.js +5 -502
- package/dist/docs.js.map +1 -1
- package/dist/docs.part01.d.ts +78 -0
- package/dist/docs.part01.js +347 -0
- package/dist/docs.part01.js.map +1 -0
- package/dist/docs.part02.d.ts +20 -0
- package/dist/docs.part02.js +181 -0
- package/dist/docs.part02.js.map +1 -0
- package/dist/doctorCommand.d.ts +27 -0
- package/dist/doctorCommand.js +160 -0
- package/dist/doctorCommand.js.map +1 -0
- package/dist/drift.contrato.d.ts +23 -0
- package/dist/drift.contrato.js +33 -0
- package/dist/drift.contrato.js.map +1 -0
- package/dist/drift.d.ts +13 -227
- package/dist/drift.js +16 -3924
- package/dist/drift.js.map +1 -1
- package/dist/drift.part01.d.ts +252 -0
- package/dist/drift.part01.js +183 -0
- package/dist/drift.part01.js.map +1 -0
- package/dist/drift.part02.d.ts +30 -0
- package/dist/drift.part02.js +342 -0
- package/dist/drift.part02.js.map +1 -0
- package/dist/drift.part03.d.ts +26 -0
- package/dist/drift.part03.js +343 -0
- package/dist/drift.part03.js.map +1 -0
- package/dist/drift.part04.d.ts +46 -0
- package/dist/drift.part04.js +354 -0
- package/dist/drift.part04.js.map +1 -0
- package/dist/drift.part05.d.ts +47 -0
- package/dist/drift.part05.js +353 -0
- package/dist/drift.part05.js.map +1 -0
- package/dist/drift.part06.d.ts +17 -0
- package/dist/drift.part06.js +381 -0
- package/dist/drift.part06.js.map +1 -0
- package/dist/drift.part07.d.ts +48 -0
- package/dist/drift.part07.js +377 -0
- package/dist/drift.part07.js.map +1 -0
- package/dist/drift.part08.d.ts +26 -0
- package/dist/drift.part08.js +333 -0
- package/dist/drift.part08.js.map +1 -0
- package/dist/drift.part09.d.ts +22 -0
- package/dist/drift.part09.js +322 -0
- package/dist/drift.part09.js.map +1 -0
- package/dist/drift.part10.d.ts +11 -0
- package/dist/drift.part10.js +116 -0
- package/dist/drift.part10.js.map +1 -0
- package/dist/drift.part11.d.ts +3 -0
- package/dist/drift.part11.js +320 -0
- package/dist/drift.part11.js.map +1 -0
- package/dist/drift.part12.d.ts +17 -0
- package/dist/drift.part12.js +289 -0
- package/dist/drift.part12.js.map +1 -0
- package/dist/drift.part13.d.ts +17 -0
- package/dist/drift.part13.js +86 -0
- package/dist/drift.part13.js.map +1 -0
- package/dist/drift.part14.d.ts +44 -0
- package/dist/drift.part14.js +402 -0
- package/dist/drift.part14.js.map +1 -0
- package/dist/driftOrcamento.d.ts +69 -0
- package/dist/driftOrcamento.js +280 -0
- package/dist/driftOrcamento.js.map +1 -0
- package/dist/execucoesExternas.d.ts +10 -0
- package/dist/execucoesExternas.js +51 -0
- package/dist/execucoesExternas.js.map +1 -0
- package/dist/exemplosOficiais.d.ts +10 -0
- package/dist/exemplosOficiais.js +63 -0
- package/dist/exemplosOficiais.js.map +1 -0
- package/dist/fsGovernado.d.ts +10 -0
- package/dist/fsGovernado.js +50 -0
- package/dist/fsGovernado.js.map +1 -0
- package/dist/geracaoCore.d.ts +64 -0
- package/dist/geracaoCore.js +381 -0
- package/dist/geracaoCore.js.map +1 -0
- package/dist/iaPrompts.d.ts +6 -0
- package/dist/iaPrompts.js +318 -0
- package/dist/iaPrompts.js.map +1 -0
- package/dist/importador.d.ts +9 -31
- package/dist/importador.js +11 -2938
- package/dist/importador.js.map +1 -1
- package/dist/importador.part01.d.ts +150 -0
- package/dist/importador.part01.js +256 -0
- package/dist/importador.part01.js.map +1 -0
- package/dist/importador.part02.d.ts +25 -0
- package/dist/importador.part02.js +359 -0
- package/dist/importador.part02.js.map +1 -0
- package/dist/importador.part03.d.ts +53 -0
- package/dist/importador.part03.js +366 -0
- package/dist/importador.part03.js.map +1 -0
- package/dist/importador.part04.d.ts +26 -0
- package/dist/importador.part04.js +374 -0
- package/dist/importador.part04.js.map +1 -0
- package/dist/importador.part05.d.ts +28 -0
- package/dist/importador.part05.js +340 -0
- package/dist/importador.part05.js.map +1 -0
- package/dist/importador.part06.d.ts +8 -0
- package/dist/importador.part06.js +327 -0
- package/dist/importador.part06.js.map +1 -0
- package/dist/importador.part07.d.ts +23 -0
- package/dist/importador.part07.js +300 -0
- package/dist/importador.part07.js.map +1 -0
- package/dist/importador.part08.d.ts +12 -0
- package/dist/importador.part08.js +378 -0
- package/dist/importador.part08.js.map +1 -0
- package/dist/importador.part09.d.ts +16 -0
- package/dist/importador.part09.js +319 -0
- package/dist/importador.part09.js.map +1 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.js +16 -7945
- package/dist/index.js.map +1 -1
- package/dist/index.part01.d.ts +148 -0
- package/dist/index.part01.js +252 -0
- package/dist/index.part01.js.map +1 -0
- package/dist/index.part02.d.ts +17 -0
- package/dist/index.part02.js +344 -0
- package/dist/index.part02.js.map +1 -0
- package/dist/index.part03.d.ts +59 -0
- package/dist/index.part03.js +352 -0
- package/dist/index.part03.js.map +1 -0
- package/dist/index.part04.d.ts +20 -0
- package/dist/index.part04.js +358 -0
- package/dist/index.part04.js.map +1 -0
- package/dist/index.part05.d.ts +10 -0
- package/dist/index.part05.js +370 -0
- package/dist/index.part05.js.map +1 -0
- package/dist/index.part06.d.ts +14 -0
- package/dist/index.part06.js +336 -0
- package/dist/index.part06.js.map +1 -0
- package/dist/index.part07.d.ts +9 -0
- package/dist/index.part07.js +287 -0
- package/dist/index.part07.js.map +1 -0
- package/dist/index.part08.d.ts +1 -0
- package/dist/index.part08.js +206 -0
- package/dist/index.part08.js.map +1 -0
- package/dist/init/index.js +2 -0
- package/dist/init/index.js.map +1 -1
- package/dist/init/templates.d.ts +2 -11
- package/dist/init/templates.js +4 -659
- package/dist/init/templates.js.map +1 -1
- package/dist/init/templates.part01.d.ts +11 -0
- package/dist/init/templates.part01.js +399 -0
- package/dist/init/templates.part01.js.map +1 -0
- package/dist/init/templates.part02.d.ts +8 -0
- package/dist/init/templates.part02.js +265 -0
- package/dist/init/templates.part02.js.map +1 -0
- package/dist/initCommand.d.ts +3 -0
- package/dist/initCommand.js +41 -0
- package/dist/initCommand.js.map +1 -0
- package/dist/initTemplatesBackend.d.ts +2 -0
- package/dist/initTemplatesBackend.js +127 -0
- package/dist/initTemplatesBackend.js.map +1 -0
- package/dist/initTemplatesBase.d.ts +9 -0
- package/dist/initTemplatesBase.js +79 -0
- package/dist/initTemplatesBase.js.map +1 -0
- package/dist/initTemplatesFlutter.d.ts +2 -0
- package/dist/initTemplatesFlutter.js +185 -0
- package/dist/initTemplatesFlutter.js.map +1 -0
- package/dist/initTemplatesRuntime.d.ts +2 -0
- package/dist/initTemplatesRuntime.js +494 -0
- package/dist/initTemplatesRuntime.js.map +1 -0
- package/dist/initTemplatesWeb.d.ts +2 -0
- package/dist/initTemplatesWeb.js +429 -0
- package/dist/initTemplatesWeb.js.map +1 -0
- package/dist/mcpInstalarChaveCommand.d.ts +1 -0
- package/dist/mcpInstalarChaveCommand.js +141 -0
- package/dist/mcpInstalarChaveCommand.js.map +1 -0
- package/dist/mcpRemoto.js.map +1 -1
- package/dist/mcp_chave.d.ts +1 -0
- package/dist/mcp_chave.js +4 -0
- package/dist/mcp_chave.js.map +1 -0
- package/dist/profileArtefatoBase.d.ts +30 -0
- package/dist/profileArtefatoBase.js +129 -0
- package/dist/profileArtefatoBase.js.map +1 -0
- package/dist/profileArtefatoValidadores.d.ts +9 -0
- package/dist/profileArtefatoValidadores.js +287 -0
- package/dist/profileArtefatoValidadores.js.map +1 -0
- package/dist/profileAuthorCommand.d.ts +6 -0
- package/dist/profileAuthorCommand.js +442 -0
- package/dist/profileAuthorCommand.js.map +1 -0
- package/dist/profileAuthorTipos.d.ts +225 -0
- package/dist/profileAuthorTipos.js +6 -0
- package/dist/profileAuthorTipos.js.map +1 -0
- package/dist/profileCatalogo.d.ts +8 -0
- package/dist/profileCatalogo.js +235 -0
- package/dist/profileCatalogo.js.map +1 -0
- package/dist/profileCommand.d.ts +33 -0
- package/dist/profileCommand.js +256 -0
- package/dist/profileCommand.js.map +1 -0
- package/dist/profileOrquestracao.d.ts +33 -0
- package/dist/profileOrquestracao.js +53 -0
- package/dist/profileOrquestracao.js.map +1 -0
- package/dist/profileRegras.d.ts +19 -0
- package/dist/profileRegras.js +219 -0
- package/dist/profileRegras.js.map +1 -0
- package/dist/profileRulePacks.d.ts +3 -0
- package/dist/profileRulePacks.js +334 -0
- package/dist/profileRulePacks.js.map +1 -0
- package/dist/profiles/validate.d.ts +1 -0
- package/dist/profiles/validate.js +4 -0
- package/dist/profiles/validate.js.map +1 -0
- package/dist/projeto.d.ts +4 -53
- package/dist/projeto.js +5 -649
- package/dist/projeto.js.map +1 -1
- package/dist/projetoBusca.d.ts +7 -0
- package/dist/projetoBusca.js +142 -0
- package/dist/projetoBusca.js.map +1 -0
- package/dist/projetoCarregar.d.ts +2 -0
- package/dist/projetoCarregar.js +50 -0
- package/dist/projetoCarregar.js.map +1 -0
- package/dist/projetoConfig.d.ts +10 -0
- package/dist/projetoConfig.js +89 -0
- package/dist/projetoConfig.js.map +1 -0
- package/dist/projetoLegado.d.ts +3 -0
- package/dist/projetoLegado.js +175 -0
- package/dist/projetoLegado.js.map +1 -0
- package/dist/projetoOrigens.d.ts +6 -0
- package/dist/projetoOrigens.js +185 -0
- package/dist/projetoOrigens.js.map +1 -0
- package/dist/projetoResolucao.d.ts +8 -0
- package/dist/projetoResolucao.js +43 -0
- package/dist/projetoResolucao.js.map +1 -0
- package/dist/projetoTipos.d.ts +43 -0
- package/dist/projetoTipos.js +4 -0
- package/dist/projetoTipos.js.map +1 -0
- package/dist/runnerValidacaoRemota.js.map +1 -1
- package/dist/runnerValidacaoRemotaBateria.js +2 -0
- package/dist/runnerValidacaoRemotaBateria.js.map +1 -1
- package/dist/runnerValidacaoRemotaExecucao.js +2 -0
- package/dist/runnerValidacaoRemotaExecucao.js.map +1 -1
- package/dist/runnerValidacaoRemotaRelatorio.js +2 -0
- package/dist/runnerValidacaoRemotaRelatorio.js.map +1 -1
- package/dist/runnerValidacaoRemotaSnapshot.js +2 -0
- package/dist/runnerValidacaoRemotaSnapshot.js.map +1 -1
- package/dist/runnerValidacaoRemotaWorkspace.js +2 -0
- package/dist/runnerValidacaoRemotaWorkspace.js.map +1 -1
- package/dist/sync/index.js +2 -0
- package/dist/sync/index.js.map +1 -1
- package/dist/textoListas.d.ts +4 -0
- package/dist/textoListas.js +22 -0
- package/dist/textoListas.js.map +1 -0
- package/dist/typescript-http-body.d.ts +12 -0
- package/dist/typescript-http-body.js +145 -0
- package/dist/typescript-http-body.js.map +1 -0
- package/dist/typescript-http-expressoes.d.ts +17 -0
- package/dist/typescript-http-expressoes.js +194 -0
- package/dist/typescript-http-expressoes.js.map +1 -0
- package/dist/typescript-http-modelos.d.ts +45 -0
- package/dist/typescript-http-modelos.js +82 -0
- package/dist/typescript-http-modelos.js.map +1 -0
- package/dist/typescript-http-rotas.d.ts +9 -0
- package/dist/typescript-http-rotas.js +129 -0
- package/dist/typescript-http-rotas.js.map +1 -0
- package/dist/typescript-http-semantica.d.ts +11 -0
- package/dist/typescript-http-semantica.js +329 -0
- package/dist/typescript-http-semantica.js.map +1 -0
- package/dist/typescript-http.d.ts +3 -35
- package/dist/typescript-http.js +4 -853
- package/dist/typescript-http.js.map +1 -1
- package/docs/AGENT_STARTER.md +1 -1
- package/docs/agentes-por-capacidade.md +46 -3
- package/docs/documentacao.md +1 -1
- package/docs/fluxo-pratico-ia-sema.md +1 -1
- package/docs/mcp.md +12 -0
- package/docs/pagamento-ponta-a-ponta.md +1 -1
- package/docs/persistencia-vendor-first.md +1 -1
- package/docs/prompt-base-ia-sema.md +1 -1
- package/docs/repositories.md +2 -2
- package/docs/seguranca.md +1 -1
- package/docs/sintaxe.md +1 -1
- package/exemplos/agendamento.sema +1 -1
- package/exemplos/assinatura.sema +1 -1
- package/exemplos/auditoria.sema +1 -1
- package/exemplos/autenticacao.sema +1 -1
- package/exemplos/author_obra_comum.sema +1 -1
- package/exemplos/author_tema_sensivel.sema +1 -1
- package/exemplos/automacao.sema +1 -1
- package/exemplos/cadastro_usuario.sema +1 -1
- package/exemplos/calculadora.sema +1 -1
- package/exemplos/crud_simples.sema +1 -1
- package/exemplos/estoque.sema +1 -1
- package/exemplos/exportacao.sema +1 -1
- package/exemplos/fila.sema +1 -1
- package/exemplos/integracao_externa.sema +1 -1
- package/exemplos/multi_tenant.sema +1 -1
- package/exemplos/notificacao.sema +1 -1
- package/exemplos/operacao_estrategia.sema +132 -633
- package/exemplos/operacao_estrategia_discovery.sema +220 -0
- package/exemplos/operacao_estrategia_fluxo.sema +114 -0
- package/exemplos/operacao_estrategia_gates.sema +106 -0
- package/exemplos/operacao_estrategia_quarentena.sema +133 -0
- package/exemplos/operacao_estrategia_rollout.sema +124 -0
- package/exemplos/pagamento.sema +1 -1
- package/exemplos/pagamento_dominio.sema +1 -1
- package/exemplos/pedido.sema +1 -1
- package/exemplos/permissao.sema +1 -1
- package/exemplos/persistencia_vendor_first.sema +1 -1
- package/exemplos/profile_game.sema +1 -1
- package/exemplos/profile_legal.sema +1 -1
- package/exemplos/profile_ops.sema +1 -1
- package/exemplos/profile_research.sema +1 -1
- package/exemplos/profile_software.sema +1 -1
- package/exemplos/profile_workflow_n8n.sema +1 -1
- package/exemplos/relatorio.sema +1 -1
- package/exemplos/replica_analitica_erp.sema +1 -1
- package/exemplos/testes_embutidos.sema +1 -1
- package/exemplos/tratamento_erro.sema +1 -1
- package/exemplos/upload_arquivo.sema +1 -1
- package/exemplos/webhook.sema +1 -1
- package/llms-full.txt +13 -8
- package/llms.txt +12 -7
- package/node_modules/@sema/gerador-css/dist/index.d.ts +2 -3
- package/node_modules/@sema/gerador-css/dist/index.js +4 -599
- package/node_modules/@sema/gerador-css/dist/index.js.map +1 -1
- package/node_modules/@sema/gerador-css/dist/index.part01.d.ts +6 -0
- package/node_modules/@sema/gerador-css/dist/index.part01.js +49 -0
- package/node_modules/@sema/gerador-css/dist/index.part01.js.map +1 -0
- package/node_modules/@sema/gerador-css/dist/index.part02.d.ts +3 -0
- package/node_modules/@sema/gerador-css/dist/index.part02.js +471 -0
- package/node_modules/@sema/gerador-css/dist/index.part02.js.map +1 -0
- package/node_modules/@sema/gerador-python/dist/index.d.ts +2 -6
- package/node_modules/@sema/gerador-python/dist/index.js +4 -771
- package/node_modules/@sema/gerador-python/dist/index.js.map +1 -1
- package/node_modules/@sema/gerador-python/dist/index.part01.d.ts +28 -0
- package/node_modules/@sema/gerador-python/dist/index.part01.js +383 -0
- package/node_modules/@sema/gerador-python/dist/index.part01.js.map +1 -0
- package/node_modules/@sema/gerador-python/dist/index.part02.d.ts +20 -0
- package/node_modules/@sema/gerador-python/dist/index.part02.js +396 -0
- package/node_modules/@sema/gerador-python/dist/index.part02.js.map +1 -0
- package/node_modules/@sema/gerador-typescript/dist/index.d.ts +3 -6
- package/node_modules/@sema/gerador-typescript/dist/index.js +5 -810
- package/node_modules/@sema/gerador-typescript/dist/index.js.map +1 -1
- package/node_modules/@sema/gerador-typescript/dist/index.part01.d.ts +25 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part01.js +358 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part01.js.map +1 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part02.d.ts +14 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js +405 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part02.js.map +1 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part03.d.ts +5 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part03.js +60 -0
- package/node_modules/@sema/gerador-typescript/dist/index.part03.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js +2 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/melhorador.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.d.ts +6 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js +40 -0
- package/node_modules/@sema/nucleo/dist/diagnosticos/snippets.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.d.ts +2 -9
- package/node_modules/@sema/nucleo/dist/formatador/index.js +4 -467
- package/node_modules/@sema/nucleo/dist/formatador/index.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/formatador/index.part01.d.ts +38 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.part01.js +382 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.part01.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.part02.d.ts +4 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.part02.js +92 -0
- package/node_modules/@sema/nucleo/dist/formatador/index.part02.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/index.d.ts +2 -0
- package/node_modules/@sema/nucleo/dist/index.js +6 -0
- package/node_modules/@sema/nucleo/dist/index.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.d.ts +3 -5
- package/node_modules/@sema/nucleo/dist/ir/conversor.js +5 -880
- package/node_modules/@sema/nucleo/dist/ir/conversor.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.d.ts +30 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js +398 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part01.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part02.d.ts +41 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js +184 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part02.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part03.d.ts +5 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js +310 -0
- package/node_modules/@sema/nucleo/dist/ir/conversor.part03.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.d.ts +3 -9
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.d.ts +11 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js +150 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.declaracoes.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.js +5 -768
- package/node_modules/@sema/nucleo/dist/parser/parser.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.d.ts +3 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js +222 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.modulo.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part01.d.ts +9 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part01.js +61 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part01.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.d.ts +40 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.js +373 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part02.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.d.ts +4 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.js +9 -0
- package/node_modules/@sema/nucleo/dist/parser/parser.part03.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/persistencia/contratos.js +2 -0
- package/node_modules/@sema/nucleo/dist/persistencia/contratos.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.d.ts +3 -59
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js +2 -1682
- package/node_modules/@sema/nucleo/dist/semantico/analisador.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.d.ts +89 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js +292 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part01.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.d.ts +29 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js +168 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part02.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.d.ts +11 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js +185 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part03.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.d.ts +30 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js +200 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part04.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.d.ts +6 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js +193 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part05.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.d.ts +11 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js +208 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part06.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.d.ts +11 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js +247 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part07.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.d.ts +3 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js +249 -0
- package/node_modules/@sema/nucleo/dist/semantico/analisador.part08.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.d.ts +2 -106
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.js +4 -474
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.js.map +1 -1
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.d.ts +109 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js +259 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part01.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.d.ts +9 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js +223 -0
- package/node_modules/@sema/nucleo/dist/semantico/estruturas.part02.js.map +1 -0
- package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.d.ts +21 -0
- package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js +40 -0
- package/node_modules/@sema/nucleo/dist/semantico/orcamentoSemantico.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.governanca_ia_contexto
|
|
2
|
+
// Descricao: CLI particionada; consulte contratos/sema/governanca_ia_contexto.sema antes de editar.
|
|
3
|
+
import { readdir } from "node:fs/promises";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import { normalizarSegmentoModulo } from "@sema/padroes";
|
|
7
|
+
export const DIRETORIOS_IGNORADOS = new Set([
|
|
8
|
+
".git",
|
|
9
|
+
".hg",
|
|
10
|
+
".svn",
|
|
11
|
+
".gradle",
|
|
12
|
+
".cargo",
|
|
13
|
+
"node_modules",
|
|
14
|
+
"dist",
|
|
15
|
+
"build",
|
|
16
|
+
"bin",
|
|
17
|
+
"obj",
|
|
18
|
+
".next",
|
|
19
|
+
".nuxt",
|
|
20
|
+
".dart_tool",
|
|
21
|
+
"__pycache__",
|
|
22
|
+
".venv",
|
|
23
|
+
"venv",
|
|
24
|
+
"coverage",
|
|
25
|
+
".tmp",
|
|
26
|
+
"generated",
|
|
27
|
+
"vendor",
|
|
28
|
+
"ephemeral",
|
|
29
|
+
]);
|
|
30
|
+
export const SUFIXOS_WRAPPER = ["Entrada", "Saida", "Dto", "Request", "Response", "Payload", "Body", "Input", "Output"];
|
|
31
|
+
export const NOMES_RESERVADOS_CAMPO = new Set([
|
|
32
|
+
"module",
|
|
33
|
+
"use",
|
|
34
|
+
"type",
|
|
35
|
+
"entity",
|
|
36
|
+
"enum",
|
|
37
|
+
"task",
|
|
38
|
+
"input",
|
|
39
|
+
"output",
|
|
40
|
+
"rules",
|
|
41
|
+
"effects",
|
|
42
|
+
"impl",
|
|
43
|
+
"guarantees",
|
|
44
|
+
"state",
|
|
45
|
+
"flow",
|
|
46
|
+
"route",
|
|
47
|
+
"tests",
|
|
48
|
+
"error",
|
|
49
|
+
"docs",
|
|
50
|
+
"comments",
|
|
51
|
+
"fields",
|
|
52
|
+
"invariants",
|
|
53
|
+
"transitions",
|
|
54
|
+
"given",
|
|
55
|
+
"when",
|
|
56
|
+
"expect",
|
|
57
|
+
"caso",
|
|
58
|
+
"required",
|
|
59
|
+
]);
|
|
60
|
+
export function escaparTexto(texto) {
|
|
61
|
+
return texto.replace(/\\/g, "\\\\").replace(/"/g, '\\"');
|
|
62
|
+
}
|
|
63
|
+
export function paraSnakeCase(valor) {
|
|
64
|
+
return valor
|
|
65
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1_$2")
|
|
66
|
+
.replace(/[^A-Za-z0-9_]+/g, "_")
|
|
67
|
+
.replace(/_{2,}/g, "_")
|
|
68
|
+
.replace(/^_+|_+$/g, "")
|
|
69
|
+
.toLowerCase();
|
|
70
|
+
}
|
|
71
|
+
export function paraIdentificadorModulo(valor) {
|
|
72
|
+
return normalizarSegmentoModulo(valor).replace(/_+/g, "_").replace(/^_+|_+$/g, "").toLowerCase();
|
|
73
|
+
}
|
|
74
|
+
export function normalizarNomeCampoImportado(valor) {
|
|
75
|
+
const normalizado = paraSnakeCase(valor);
|
|
76
|
+
return NOMES_RESERVADOS_CAMPO.has(normalizado)
|
|
77
|
+
? `${normalizado}_campo`
|
|
78
|
+
: normalizado;
|
|
79
|
+
}
|
|
80
|
+
export function nomeProjetoPadrao(diretorio) {
|
|
81
|
+
const base = path.basename(diretorio);
|
|
82
|
+
if (["src", "app", "api", "backend", "server"].includes(base.toLowerCase())) {
|
|
83
|
+
return `${path.basename(path.dirname(diretorio))}.${base}`;
|
|
84
|
+
}
|
|
85
|
+
return base;
|
|
86
|
+
}
|
|
87
|
+
export function inferirNamespaceBase(diretorio, namespaceExplicito) {
|
|
88
|
+
if (namespaceExplicito) {
|
|
89
|
+
return namespaceExplicito
|
|
90
|
+
.split(".")
|
|
91
|
+
.map((segmento) => paraIdentificadorModulo(segmento))
|
|
92
|
+
.filter(Boolean)
|
|
93
|
+
.join(".");
|
|
94
|
+
}
|
|
95
|
+
return ["legado", ...nomeProjetoPadrao(diretorio).split(/[\\/._-]+/g)]
|
|
96
|
+
.map((segmento) => paraIdentificadorModulo(segmento))
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.join(".");
|
|
99
|
+
}
|
|
100
|
+
export async function listarArquivosRecursivos(diretorio, extensoes) {
|
|
101
|
+
const entradas = await readdir(diretorio, { withFileTypes: true });
|
|
102
|
+
const encontrados = [];
|
|
103
|
+
for (const entrada of entradas) {
|
|
104
|
+
if (DIRETORIOS_IGNORADOS.has(entrada.name)) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
const caminhoAtual = path.join(diretorio, entrada.name);
|
|
108
|
+
if (entrada.isDirectory()) {
|
|
109
|
+
encontrados.push(...await listarArquivosRecursivos(caminhoAtual, extensoes));
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (extensoes.some((extensao) => entrada.name.endsWith(extensao))) {
|
|
113
|
+
encontrados.push(caminhoAtual);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return encontrados.sort((a, b) => a.localeCompare(b, "pt-BR"));
|
|
117
|
+
}
|
|
118
|
+
export function inferirContextoPorArquivo(relacao, opcoes) {
|
|
119
|
+
const semExtensao = relacao.replace(/\.[^.]+$/, "");
|
|
120
|
+
const segmentosOriginais = semExtensao.split(path.sep).filter(Boolean);
|
|
121
|
+
const segmentos = segmentosOriginais.map((segmento) => paraIdentificadorModulo(segmento)).filter(Boolean);
|
|
122
|
+
if (segmentos[0] === "src" || segmentos[0] === "app") {
|
|
123
|
+
segmentos.shift();
|
|
124
|
+
segmentosOriginais.shift();
|
|
125
|
+
}
|
|
126
|
+
const ultimo = segmentos.at(-1) ?? "";
|
|
127
|
+
const semSufixo = ultimo
|
|
128
|
+
.replace(/(\.controller|\.service|\.module|_router|_service|_schemas|_contract)$/g, "")
|
|
129
|
+
.replace(/(controller|service|module|router|schemas|contract)$/g, "")
|
|
130
|
+
.replace(/_+$/g, "");
|
|
131
|
+
if (segmentos.length === 0) {
|
|
132
|
+
return ["importado"];
|
|
133
|
+
}
|
|
134
|
+
if (!opcoes?.preservarUltimo && semSufixo && semSufixo !== ultimo) {
|
|
135
|
+
segmentos[segmentos.length - 1] = semSufixo;
|
|
136
|
+
}
|
|
137
|
+
if (opcoes?.snakeCaseUltimo && segmentos.length > 0) {
|
|
138
|
+
segmentos[segmentos.length - 1] = paraSnakeCase(segmentosOriginais[segmentosOriginais.length - 1] ?? ultimo);
|
|
139
|
+
}
|
|
140
|
+
if (segmentos.length > 1 && segmentos[segmentos.length - 1] === segmentos[segmentos.length - 2]) {
|
|
141
|
+
segmentos.pop();
|
|
142
|
+
}
|
|
143
|
+
return segmentos;
|
|
144
|
+
}
|
|
145
|
+
export function juntarCaminhoHttp(base, sufixo) {
|
|
146
|
+
const partes = [base ?? "", sufixo ?? ""]
|
|
147
|
+
.map((item) => item.trim())
|
|
148
|
+
.filter(Boolean)
|
|
149
|
+
.map((item) => item.replace(/^\/+|\/+$/g, ""));
|
|
150
|
+
const caminho = `/${partes.join("/")}`.replace(/\/+/g, "/");
|
|
151
|
+
return caminho === "//" ? "/" : caminho;
|
|
152
|
+
}
|
|
153
|
+
export function extrairTextoLiteral(expr) {
|
|
154
|
+
if (!expr) {
|
|
155
|
+
return undefined;
|
|
156
|
+
}
|
|
157
|
+
if (ts.isStringLiteralLike(expr) || ts.isNoSubstitutionTemplateLiteral(expr)) {
|
|
158
|
+
return expr.text;
|
|
159
|
+
}
|
|
160
|
+
if (ts.isNumericLiteral(expr)) {
|
|
161
|
+
return expr.text;
|
|
162
|
+
}
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
export function listarDecoradores(node) {
|
|
166
|
+
return ts.canHaveDecorators(node) ? ts.getDecorators(node) ?? [] : [];
|
|
167
|
+
}
|
|
168
|
+
export function lerDecorator(node, nomes) {
|
|
169
|
+
for (const decorator of listarDecoradores(node)) {
|
|
170
|
+
const expressao = decorator.expression;
|
|
171
|
+
if (ts.isCallExpression(expressao)) {
|
|
172
|
+
const alvo = expressao.expression;
|
|
173
|
+
if (ts.isIdentifier(alvo) && nomes.includes(alvo.text)) {
|
|
174
|
+
return { nome: alvo.text, argumentos: expressao.arguments };
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
else if (ts.isIdentifier(expressao) && nomes.includes(expressao.text)) {
|
|
178
|
+
return { nome: expressao.text, argumentos: ts.factory.createNodeArray() };
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return undefined;
|
|
182
|
+
}
|
|
183
|
+
export function mapearTipoPrimitivo(tipo) {
|
|
184
|
+
const limpo = tipo.trim().replace(/\s+/g, "");
|
|
185
|
+
const base = limpo
|
|
186
|
+
.replace(/^Promise<(.*)>$/, "$1")
|
|
187
|
+
.replace(/^Future<(.*)>$/, "$1")
|
|
188
|
+
.replace(/\|undefined/g, "")
|
|
189
|
+
.replace(/\|null/g, "")
|
|
190
|
+
.replace(/\bundefined\|/g, "")
|
|
191
|
+
.replace(/\bnull\|/g, "")
|
|
192
|
+
.trim();
|
|
193
|
+
const minusculo = base.toLowerCase();
|
|
194
|
+
if (minusculo === "string" || minusculo === "texto") {
|
|
195
|
+
return "Texto";
|
|
196
|
+
}
|
|
197
|
+
if (minusculo === "number" || minusculo === "float" || minusculo === "double") {
|
|
198
|
+
return "Decimal";
|
|
199
|
+
}
|
|
200
|
+
if (minusculo === "int" || minusculo === "integer" || minusculo === "inteiro") {
|
|
201
|
+
return "Inteiro";
|
|
202
|
+
}
|
|
203
|
+
if (minusculo === "boolean" || minusculo === "bool") {
|
|
204
|
+
return "Booleano";
|
|
205
|
+
}
|
|
206
|
+
if (minusculo === "date") {
|
|
207
|
+
return "Data";
|
|
208
|
+
}
|
|
209
|
+
if (minusculo === "datetime" || minusculo === "timestamp") {
|
|
210
|
+
return "DataHora";
|
|
211
|
+
}
|
|
212
|
+
if (minusculo === "id" || minusculo.endsWith("id")) {
|
|
213
|
+
return "Id";
|
|
214
|
+
}
|
|
215
|
+
if (minusculo.includes("[]")
|
|
216
|
+
|| minusculo.startsWith("array<")
|
|
217
|
+
|| minusculo.startsWith("record<")
|
|
218
|
+
|| minusculo.startsWith("map<")
|
|
219
|
+
|| minusculo.startsWith("list<")
|
|
220
|
+
|| minusculo.startsWith("list[")
|
|
221
|
+
|| minusculo.startsWith("dict[")) {
|
|
222
|
+
return "Json";
|
|
223
|
+
}
|
|
224
|
+
if (minusculo === "json"
|
|
225
|
+
|| minusculo === "object"
|
|
226
|
+
|| minusculo === "unknown"
|
|
227
|
+
|| minusculo === "any"
|
|
228
|
+
|| minusculo === "dynamic"
|
|
229
|
+
|| minusculo === "void"
|
|
230
|
+
|| minusculo === "none") {
|
|
231
|
+
return minusculo === "void" || minusculo === "none" ? "Vazio" : "Json";
|
|
232
|
+
}
|
|
233
|
+
return tipo.trim();
|
|
234
|
+
}
|
|
235
|
+
export function limparTipoBackend(tipo) {
|
|
236
|
+
if (!tipo) {
|
|
237
|
+
return undefined;
|
|
238
|
+
}
|
|
239
|
+
return tipo
|
|
240
|
+
.trim()
|
|
241
|
+
.replace(/^Task<(.+)>$/i, "$1")
|
|
242
|
+
.replace(/^ActionResult<(.+)>$/i, "$1")
|
|
243
|
+
.replace(/^IActionResult$/i, "Json")
|
|
244
|
+
.replace(/^Results<(.+)>$/i, "$1")
|
|
245
|
+
.replace(/^ResponseEntity<(.+)>$/i, "$1")
|
|
246
|
+
.replace(/^Optional<(.+)>$/i, "$1")
|
|
247
|
+
.replace(/^Result<(.+)>$/i, "$1")
|
|
248
|
+
.replace(/^impl\s+IntoResponse$/i, "Json")
|
|
249
|
+
.replace(/^Json<(.+)>$/i, "$1")
|
|
250
|
+
.replace(/^Option<(.+)>$/i, "$1")
|
|
251
|
+
.replace(/^Vec<(.+)>$/i, "Json")
|
|
252
|
+
.replace(/^List<(.+)>$/i, "Json")
|
|
253
|
+
.replace(/^Map<(.+)>$/i, "Json")
|
|
254
|
+
.replace(/^Dictionary<(.+)>$/i, "Json");
|
|
255
|
+
}
|
|
256
|
+
//# sourceMappingURL=importador.part01.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"importador.part01.js","sourceRoot":"","sources":["../src/importador.part01.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,oGAAoG;AAEpG,OAAO,EAAU,OAAO,EAAY,MAAM,kBAAkB,CAAC;AAC7D,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,YAAY,CAAC;AAE5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAyKzD,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IAC1C,MAAM;IACN,KAAK;IACL,MAAM;IACN,SAAS;IACT,QAAQ;IACR,cAAc;IACd,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,OAAO;IACP,OAAO;IACP,YAAY;IACZ,aAAa;IACb,OAAO;IACP,MAAM;IACN,UAAU;IACV,MAAM;IACN,WAAW;IACX,QAAQ;IACR,WAAW;CACZ,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AAExH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,GAAG,CAAC;IAC5C,QAAQ;IACR,KAAK;IACL,MAAM;IACN,QAAQ;IACR,MAAM;IACN,MAAM;IACN,OAAO;IACP,QAAQ;IACR,OAAO;IACP,SAAS;IACT,MAA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AAI,EAAE;SACN,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;SAC9B,OAAO,CAAC,uBAAuB,EAAE,IAAI,CAAC;SACtC,OAAO,CAAC,kBAAkB,EAAE,MAAM,CAAC;SACnC,OAAO,CAAC,kBAAkB,EAAE,IAAI,CAAC;SACjC,OAAO,CAAC,yBAAyB,EAAE,IAAI,CAAC;SACxC,OAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC;SAClC,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC;SAChC,OAAO,CAAC,wBAAwB,EAAE,MAAM,CAAC;SACzC,OAAO,CAAC,eAAe,EAAE,IAAI,CAAC;SAC9B,OAAO,CAAC,iBAAiB,EAAE,IAAI,CAAC;SAChC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC;SAC/B,OAAO,CAAC,eAAe,EAAE,MAAM,CAAC;SAChC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC;SAC/B,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import { type CampoInferidoTypeScriptHttp } from "./typescript-http.js";
|
|
3
|
+
import { CampoImportado, DatabaseImportado, EfeitoImportado, EntidadeImportada, EnumImportado, ErroImportado, TipoDescoberto } from "./importador.part01.js";
|
|
4
|
+
export declare function mapearTipoBackendParaSema(tipo: string | undefined): string;
|
|
5
|
+
export declare function criarCampoResultadoBackend(tipo: string | undefined): CampoImportado[];
|
|
6
|
+
export declare function camposDeParametrosRotaBackend(parametros: Array<{
|
|
7
|
+
nome: string;
|
|
8
|
+
tipoSema: "Texto" | "Inteiro" | "Decimal" | "Id";
|
|
9
|
+
}>): CampoImportado[];
|
|
10
|
+
export declare function pareceWrapperTipo(nome: string): boolean;
|
|
11
|
+
export declare function descreverEfeitosPorHeuristica(codigo: string): EfeitoImportado[];
|
|
12
|
+
export declare function deduplicarDatabases(databases: DatabaseImportado[]): DatabaseImportado[];
|
|
13
|
+
export declare function inferirDatabasesPorHeuristica(codigo: string, relacao: string): DatabaseImportado[];
|
|
14
|
+
export declare function normalizarNomeErroBruto(nome: string): string;
|
|
15
|
+
export declare function extrairErrosTs(node: ts.Node, sourceFile: ts.SourceFile): ErroImportado[];
|
|
16
|
+
export declare function extrairTiposTs(sourceFile: ts.SourceFile): Map<string, TipoDescoberto>;
|
|
17
|
+
export declare function mapearTipoTsParaSema(tipoTexto: string | undefined, tipos: Map<string, TipoDescoberto>, entidadesReferenciadas: Set<string>, enumsReferenciados: Set<string>): string;
|
|
18
|
+
export declare function expandirCamposTs(nomeParametro: string, tipoTexto: string | undefined, tipos: Map<string, TipoDescoberto>, entidadesReferenciadas: Set<string>, enumsReferenciados: Set<string>, obrigatorio: boolean): CampoImportado[];
|
|
19
|
+
export declare function criarEntidadesReferenciadas(tipos: Map<string, TipoDescoberto>, entidadesReferenciadas: Set<string>, enumsReferenciados: Set<string>): {
|
|
20
|
+
entities: EntidadeImportada[];
|
|
21
|
+
enums: EnumImportado[];
|
|
22
|
+
};
|
|
23
|
+
export declare function caminhoImplTs(diretorioBase: string, arquivo: string, simbolo: string): string;
|
|
24
|
+
export declare function mapearCampoInferidoTypeScriptHttp(campo: CampoInferidoTypeScriptHttp, tipos: Map<string, TipoDescoberto>, entidadesReferenciadas: Set<string>, enumsReferenciados: Set<string>): CampoImportado;
|
|
25
|
+
export declare function camposDeSemanticaTypeScriptHttp(campos: CampoInferidoTypeScriptHttp[], tipos: Map<string, TipoDescoberto>, entidadesReferenciadas: Set<string>, enumsReferenciados: Set<string>): CampoImportado[];
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
// SEMA-GOVERNED: sema.governanca_ia_contexto
|
|
2
|
+
// Descricao: CLI particionada; consulte contratos/sema/governanca_ia_contexto.sema antes de editar.
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import ts from "typescript";
|
|
5
|
+
import { SUFIXOS_WRAPPER, extrairTextoLiteral, limparTipoBackend, mapearTipoPrimitivo, normalizarNomeCampoImportado, paraIdentificadorModulo, paraSnakeCase } from "./importador.part01.js";
|
|
6
|
+
import { deduplicarEntidades } from "./importador.part05.js";
|
|
7
|
+
export function mapearTipoBackendParaSema(tipo) {
|
|
8
|
+
const limpo = limparTipoBackend(tipo);
|
|
9
|
+
if (!limpo) {
|
|
10
|
+
return "Json";
|
|
11
|
+
}
|
|
12
|
+
const basico = mapearTipoPrimitivo(limpo);
|
|
13
|
+
if (basico !== limpo) {
|
|
14
|
+
return basico;
|
|
15
|
+
}
|
|
16
|
+
if (/\[\]$/.test(limpo) || /^(IEnumerable|IReadOnlyList|List|Vec|HashMap|Map|Dictionary)</.test(limpo)) {
|
|
17
|
+
return "Json";
|
|
18
|
+
}
|
|
19
|
+
if (/^(void|unit|\(\)|nil)$/i.test(limpo)) {
|
|
20
|
+
return "Vazio";
|
|
21
|
+
}
|
|
22
|
+
if (/\b(uuid|guid)\b/i.test(limpo)) {
|
|
23
|
+
return "Id";
|
|
24
|
+
}
|
|
25
|
+
return "Json";
|
|
26
|
+
}
|
|
27
|
+
export function criarCampoResultadoBackend(tipo) {
|
|
28
|
+
const tipoSema = mapearTipoBackendParaSema(tipo);
|
|
29
|
+
return tipoSema === "Vazio"
|
|
30
|
+
? []
|
|
31
|
+
: [{ nome: "resultado", tipo: tipoSema, obrigatorio: false }];
|
|
32
|
+
}
|
|
33
|
+
export function camposDeParametrosRotaBackend(parametros) {
|
|
34
|
+
return parametros.map((parametro) => ({
|
|
35
|
+
nome: normalizarNomeCampoImportado(parametro.nome),
|
|
36
|
+
tipo: parametro.tipoSema,
|
|
37
|
+
obrigatorio: true,
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
export function pareceWrapperTipo(nome) {
|
|
41
|
+
return SUFIXOS_WRAPPER.some((sufixo) => nome.endsWith(sufixo)) || /(entrada|saida|dto|request|response|payload|body|input|output)/i.test(nome);
|
|
42
|
+
}
|
|
43
|
+
export function descreverEfeitosPorHeuristica(codigo) {
|
|
44
|
+
const texto = codigo.toLowerCase();
|
|
45
|
+
const efeitos = [];
|
|
46
|
+
const adicionar = (categoria, alvo, criticidade) => {
|
|
47
|
+
if (!efeitos.some((efeito) => efeito.categoria === categoria && efeito.alvo === alvo)) {
|
|
48
|
+
efeitos.push({ categoria, alvo, criticidade });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
if (/(prisma\.|repository\.|\.create\(|\.update\(|\.delete\(|\.save\()/i.test(codigo)) {
|
|
52
|
+
adicionar("persistencia", "banco", "alta");
|
|
53
|
+
}
|
|
54
|
+
if (/(findmany|findunique|findfirst|\.find\(|\.select\(|\.query\(|\.get\()/i.test(texto)) {
|
|
55
|
+
adicionar("consulta", "dados", "media");
|
|
56
|
+
}
|
|
57
|
+
if (/(emit\(|publish\(|dispatch\(|eventbus|event_emitter)/i.test(texto)) {
|
|
58
|
+
adicionar("evento", "dominio", "media");
|
|
59
|
+
}
|
|
60
|
+
if (/(notify|notification|sendmessage|send_email|telegram|smtp|mail)/i.test(texto)) {
|
|
61
|
+
adicionar("notificacao", "usuarios", "media");
|
|
62
|
+
}
|
|
63
|
+
if (/(audit|logger|logging|log\.|trace|observability)/i.test(texto)) {
|
|
64
|
+
adicionar("auditoria", "operacao", "baixa");
|
|
65
|
+
}
|
|
66
|
+
return efeitos;
|
|
67
|
+
}
|
|
68
|
+
export function deduplicarDatabases(databases) {
|
|
69
|
+
const mapa = new Map();
|
|
70
|
+
for (const database of databases) {
|
|
71
|
+
const chave = `${database.engine}:${database.nome}`;
|
|
72
|
+
const existente = mapa.get(chave);
|
|
73
|
+
if (!existente) {
|
|
74
|
+
mapa.set(chave, {
|
|
75
|
+
...database,
|
|
76
|
+
resources: [...database.resources],
|
|
77
|
+
diagnostics: [...(database.diagnostics ?? [])],
|
|
78
|
+
});
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const recursos = new Map();
|
|
82
|
+
for (const recurso of [...existente.resources, ...database.resources]) {
|
|
83
|
+
recursos.set(`${recurso.tipo}:${recurso.nome}`, recurso);
|
|
84
|
+
}
|
|
85
|
+
existente.resources = [...recursos.values()];
|
|
86
|
+
existente.diagnostics = [...new Set([...(existente.diagnostics ?? []), ...(database.diagnostics ?? [])])];
|
|
87
|
+
}
|
|
88
|
+
return [...mapa.values()];
|
|
89
|
+
}
|
|
90
|
+
export function inferirDatabasesPorHeuristica(codigo, relacao) {
|
|
91
|
+
const databases = [];
|
|
92
|
+
const adicionar = (database) => {
|
|
93
|
+
databases.push(database);
|
|
94
|
+
};
|
|
95
|
+
const texto = codigo.toLowerCase();
|
|
96
|
+
if (/(postgresql|postgres\b|node-postgres|pg\.pool|pgclient|typeorm.+postgres|sequelize.+postgres|provider\s*=\s*["']postgresql["'])/i.test(codigo)) {
|
|
97
|
+
adicionar({
|
|
98
|
+
nome: "principal_postgres",
|
|
99
|
+
resumo: `Persistencia PostgreSQL inferida automaticamente de ${relacao}.`,
|
|
100
|
+
engine: "postgres",
|
|
101
|
+
queryModel: "sql",
|
|
102
|
+
transactionModel: "mvcc",
|
|
103
|
+
resources: [
|
|
104
|
+
{ tipo: "table", nome: "tabelas_relacionais", table: "legado_principal" },
|
|
105
|
+
{ tipo: "query", nome: "consultas_sql", mode: "sql" },
|
|
106
|
+
],
|
|
107
|
+
diagnostics: ["inferido_por_heuristica"],
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
if (/(mysql\b|mariadb|mysql2|typeorm.+mysql|sequelize.+mysql|provider\s*=\s*["']mysql["'])/i.test(codigo)) {
|
|
111
|
+
adicionar({
|
|
112
|
+
nome: "principal_mysql",
|
|
113
|
+
resumo: `Persistencia MySQL inferida automaticamente de ${relacao}.`,
|
|
114
|
+
engine: "mysql",
|
|
115
|
+
queryModel: "sql",
|
|
116
|
+
transactionModel: "bloqueio",
|
|
117
|
+
resources: [
|
|
118
|
+
{ tipo: "table", nome: "tabelas_relacionais", table: "legado_principal" },
|
|
119
|
+
{ tipo: "query", nome: "consultas_sql", mode: "sql" },
|
|
120
|
+
],
|
|
121
|
+
diagnostics: ["inferido_por_heuristica"],
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
if (/(sqlite\b|better-sqlite3|provider\s*=\s*["']sqlite["'])/i.test(codigo)) {
|
|
125
|
+
adicionar({
|
|
126
|
+
nome: "principal_sqlite",
|
|
127
|
+
resumo: `Persistencia SQLite inferida automaticamente de ${relacao}.`,
|
|
128
|
+
engine: "sqlite",
|
|
129
|
+
queryModel: "sql",
|
|
130
|
+
transactionModel: "single_thread",
|
|
131
|
+
resources: [
|
|
132
|
+
{ tipo: "table", nome: "tabelas_locais", table: "legado_local" },
|
|
133
|
+
{ tipo: "query", nome: "consultas_locais", mode: "sql" },
|
|
134
|
+
],
|
|
135
|
+
diagnostics: ["inferido_por_heuristica"],
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (/(mongodb|mongoose|mongo\.collection|mongoclient|prisma.+mongodb|provider\s*=\s*["']mongodb["'])/i.test(codigo)) {
|
|
139
|
+
adicionar({
|
|
140
|
+
nome: "principal_mongodb",
|
|
141
|
+
resumo: `Persistencia MongoDB inferida automaticamente de ${relacao}.`,
|
|
142
|
+
engine: "mongodb",
|
|
143
|
+
queryModel: "documento",
|
|
144
|
+
transactionModel: "documento",
|
|
145
|
+
resources: [
|
|
146
|
+
{ tipo: "collection", nome: "colecoes_documentais", collection: "documentos" },
|
|
147
|
+
{ tipo: "document", nome: "documentos_agregados", mode: /aggregate|\$match|\$group/i.test(codigo) ? "pipeline" : "documento" },
|
|
148
|
+
],
|
|
149
|
+
diagnostics: ["inferido_por_heuristica"],
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
if (/(redis\b|ioredis|upstash|bullmq|xadd|xreadgroup)/i.test(codigo)) {
|
|
153
|
+
adicionar({
|
|
154
|
+
nome: "principal_redis",
|
|
155
|
+
resumo: `Persistencia Redis inferida automaticamente de ${relacao}.`,
|
|
156
|
+
engine: "redis",
|
|
157
|
+
queryModel: "chave_valor",
|
|
158
|
+
transactionModel: "single_thread",
|
|
159
|
+
resources: [
|
|
160
|
+
{ tipo: "keyspace", nome: "estado_chaves", ttl: /\bttl\b|expire\(/i.test(codigo) ? "300s" : undefined },
|
|
161
|
+
{ tipo: "stream", nome: "eventos_stream", surface: /bullmq|queue|worker/i.test(codigo) ? "fila" : "evento" },
|
|
162
|
+
],
|
|
163
|
+
diagnostics: ["inferido_por_heuristica"],
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
return deduplicarDatabases(databases);
|
|
167
|
+
}
|
|
168
|
+
export function normalizarNomeErroBruto(nome) {
|
|
169
|
+
return paraSnakeCase(nome.replace(/(Error|Erro|Exception)$/i, "")) || "erro_importado";
|
|
170
|
+
}
|
|
171
|
+
export function extrairErrosTs(node, sourceFile) {
|
|
172
|
+
const encontrados = new Map();
|
|
173
|
+
const visitar = (atual) => {
|
|
174
|
+
if (ts.isThrowStatement(atual) && atual.expression) {
|
|
175
|
+
const expressao = atual.expression;
|
|
176
|
+
if (ts.isNewExpression(expressao)) {
|
|
177
|
+
const nomeErro = expressao.expression.getText(sourceFile);
|
|
178
|
+
const mensagem = extrairTextoLiteral(expressao.arguments?.[0]) ?? `Erro importado automaticamente de ${nomeErro}.`;
|
|
179
|
+
encontrados.set(normalizarNomeErroBruto(nomeErro), mensagem);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
atual.forEachChild(visitar);
|
|
183
|
+
};
|
|
184
|
+
node.forEachChild(visitar);
|
|
185
|
+
return [...encontrados.entries()].map(([nome, mensagem]) => ({ nome, mensagem }));
|
|
186
|
+
}
|
|
187
|
+
export function extrairTiposTs(sourceFile) {
|
|
188
|
+
const tipos = new Map();
|
|
189
|
+
const adicionarObjeto = (nome, campos) => {
|
|
190
|
+
if (!campos.length || tipos.has(nome)) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
tipos.set(nome, { tipo: "objeto", nome, campos });
|
|
194
|
+
};
|
|
195
|
+
const adicionarEnum = (nome, valores) => {
|
|
196
|
+
if (!valores.length || tipos.has(nome)) {
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
tipos.set(nome, { tipo: "enum", nome, valores });
|
|
200
|
+
};
|
|
201
|
+
sourceFile.forEachChild((node) => {
|
|
202
|
+
if (ts.isInterfaceDeclaration(node) && node.name) {
|
|
203
|
+
const campos = node.members
|
|
204
|
+
.filter(ts.isPropertySignature)
|
|
205
|
+
.map((member) => ({
|
|
206
|
+
nome: member.name.getText(sourceFile),
|
|
207
|
+
tipoTexto: member.type?.getText(sourceFile),
|
|
208
|
+
obrigatorio: !member.questionToken,
|
|
209
|
+
}));
|
|
210
|
+
adicionarObjeto(node.name.text, campos);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
if (ts.isClassDeclaration(node) && node.name) {
|
|
214
|
+
const campos = node.members
|
|
215
|
+
.filter((member) => ts.isPropertyDeclaration(member) && Boolean(member.name))
|
|
216
|
+
.map((member) => ({
|
|
217
|
+
nome: member.name.getText(sourceFile),
|
|
218
|
+
tipoTexto: member.type?.getText(sourceFile),
|
|
219
|
+
obrigatorio: !member.questionToken,
|
|
220
|
+
}));
|
|
221
|
+
adicionarObjeto(node.name.text, campos);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
if (ts.isTypeAliasDeclaration(node) && node.name) {
|
|
225
|
+
if (ts.isUnionTypeNode(node.type) && node.type.types.every((tipo) => ts.isLiteralTypeNode(tipo) && ts.isStringLiteralLike(tipo.literal))) {
|
|
226
|
+
adicionarEnum(node.name.text, node.type.types
|
|
227
|
+
.map((tipo) => ts.isLiteralTypeNode(tipo) && ts.isStringLiteralLike(tipo.literal) ? tipo.literal.text : undefined)
|
|
228
|
+
.filter((valor) => Boolean(valor)));
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
if (ts.isTypeLiteralNode(node.type)) {
|
|
232
|
+
const campos = node.type.members
|
|
233
|
+
.filter(ts.isPropertySignature)
|
|
234
|
+
.map((member) => ({
|
|
235
|
+
nome: member.name.getText(sourceFile),
|
|
236
|
+
tipoTexto: member.type?.getText(sourceFile),
|
|
237
|
+
obrigatorio: !member.questionToken,
|
|
238
|
+
}));
|
|
239
|
+
adicionarObjeto(node.name.text, campos);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
});
|
|
243
|
+
return tipos;
|
|
244
|
+
}
|
|
245
|
+
export function mapearTipoTsParaSema(tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados) {
|
|
246
|
+
if (!tipoTexto) {
|
|
247
|
+
return "Json";
|
|
248
|
+
}
|
|
249
|
+
const basico = mapearTipoPrimitivo(tipoTexto);
|
|
250
|
+
if (basico !== tipoTexto.trim()) {
|
|
251
|
+
return basico;
|
|
252
|
+
}
|
|
253
|
+
const limpo = tipoTexto
|
|
254
|
+
.trim()
|
|
255
|
+
.replace(/^Promise<(.*)>$/, "$1")
|
|
256
|
+
.replace(/\| undefined/g, "")
|
|
257
|
+
.replace(/\| null/g, "")
|
|
258
|
+
.replace(/Readonly<(.+)>/, "$1")
|
|
259
|
+
.replace(/Partial<(.+)>/, "$1")
|
|
260
|
+
.trim();
|
|
261
|
+
if (tipos.has(limpo)) {
|
|
262
|
+
const encontrado = tipos.get(limpo);
|
|
263
|
+
if (encontrado.tipo === "enum") {
|
|
264
|
+
enumsReferenciados.add(encontrado.nome);
|
|
265
|
+
return encontrado.nome;
|
|
266
|
+
}
|
|
267
|
+
if (!pareceWrapperTipo(encontrado.nome)) {
|
|
268
|
+
entidadesReferenciadas.add(encontrado.nome);
|
|
269
|
+
return encontrado.nome;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return "Json";
|
|
273
|
+
}
|
|
274
|
+
export function expandirCamposTs(nomeParametro, tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados, obrigatorio) {
|
|
275
|
+
if (!tipoTexto) {
|
|
276
|
+
return [{ nome: normalizarNomeCampoImportado(nomeParametro), tipo: "Json", obrigatorio }];
|
|
277
|
+
}
|
|
278
|
+
const limpo = tipoTexto
|
|
279
|
+
.trim()
|
|
280
|
+
.replace(/^Promise<(.*)>$/, "$1")
|
|
281
|
+
.replace(/\| undefined/g, "")
|
|
282
|
+
.replace(/\| null/g, "")
|
|
283
|
+
.replace(/Readonly<(.+)>/, "$1")
|
|
284
|
+
.replace(/Partial<(.+)>/, "$1")
|
|
285
|
+
.trim();
|
|
286
|
+
const descoberto = tipos.get(limpo);
|
|
287
|
+
if (descoberto?.tipo === "objeto" && pareceWrapperTipo(descoberto.nome)) {
|
|
288
|
+
return descoberto.campos.map((campo) => ({
|
|
289
|
+
nome: normalizarNomeCampoImportado(campo.nome),
|
|
290
|
+
tipo: mapearTipoTsParaSema(campo.tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados),
|
|
291
|
+
obrigatorio: campo.obrigatorio,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
return [{
|
|
295
|
+
nome: normalizarNomeCampoImportado(nomeParametro),
|
|
296
|
+
tipo: mapearTipoTsParaSema(tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados),
|
|
297
|
+
obrigatorio,
|
|
298
|
+
}];
|
|
299
|
+
}
|
|
300
|
+
export function criarEntidadesReferenciadas(tipos, entidadesReferenciadas, enumsReferenciados) {
|
|
301
|
+
const fila = [...entidadesReferenciadas];
|
|
302
|
+
const processadas = new Set();
|
|
303
|
+
const entities = [];
|
|
304
|
+
while (fila.length > 0) {
|
|
305
|
+
const nomeAtual = fila.shift();
|
|
306
|
+
if (processadas.has(nomeAtual)) {
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
processadas.add(nomeAtual);
|
|
310
|
+
const tipo = tipos.get(nomeAtual);
|
|
311
|
+
if (!tipo || tipo.tipo !== "objeto") {
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
const entidade = {
|
|
315
|
+
nome: tipo.nome,
|
|
316
|
+
campos: tipo.campos.map((campo) => ({
|
|
317
|
+
nome: normalizarNomeCampoImportado(campo.nome),
|
|
318
|
+
tipo: mapearTipoTsParaSema(campo.tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados),
|
|
319
|
+
obrigatorio: campo.obrigatorio,
|
|
320
|
+
})),
|
|
321
|
+
};
|
|
322
|
+
entities.push(entidade);
|
|
323
|
+
for (const referenciado of entidadesReferenciadas) {
|
|
324
|
+
if (!processadas.has(referenciado) && !fila.includes(referenciado)) {
|
|
325
|
+
fila.push(referenciado);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const enums = [...enumsReferenciados]
|
|
330
|
+
.map((nome) => tipos.get(nome))
|
|
331
|
+
.filter((item) => Boolean(item && item.tipo === "enum"))
|
|
332
|
+
.map((tipo) => ({
|
|
333
|
+
nome: tipo.nome,
|
|
334
|
+
valores: tipo.valores,
|
|
335
|
+
}))
|
|
336
|
+
.filter((enumItem, indice, lista) => lista.findIndex((item) => item.nome === enumItem.nome) === indice);
|
|
337
|
+
return { entities: deduplicarEntidades(entities), enums };
|
|
338
|
+
}
|
|
339
|
+
export function caminhoImplTs(diretorioBase, arquivo, simbolo) {
|
|
340
|
+
const relativo = path.relative(diretorioBase, arquivo).replace(/\.[^.]+$/, "");
|
|
341
|
+
const segmentos = relativo.split(path.sep).map((segmento) => paraIdentificadorModulo(segmento)).filter(Boolean);
|
|
342
|
+
return [...segmentos, simbolo].join(".");
|
|
343
|
+
}
|
|
344
|
+
export function mapearCampoInferidoTypeScriptHttp(campo, tipos, entidadesReferenciadas, enumsReferenciados) {
|
|
345
|
+
const tipoBasico = campo.tipoTexto ? mapearTipoPrimitivo(campo.tipoTexto) : "Json";
|
|
346
|
+
return {
|
|
347
|
+
nome: paraSnakeCase(campo.nome),
|
|
348
|
+
tipo: ["Texto", "Decimal", "Inteiro", "Booleano", "Data", "DataHora", "Id", "Json", "Vazio"].includes(tipoBasico)
|
|
349
|
+
? tipoBasico
|
|
350
|
+
: campo.tipoTexto
|
|
351
|
+
? mapearTipoTsParaSema(campo.tipoTexto, tipos, entidadesReferenciadas, enumsReferenciados)
|
|
352
|
+
: "Json",
|
|
353
|
+
obrigatorio: campo.obrigatorio,
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
export function camposDeSemanticaTypeScriptHttp(campos, tipos, entidadesReferenciadas, enumsReferenciados) {
|
|
357
|
+
return campos.map((campo) => mapearCampoInferidoTypeScriptHttp(campo, tipos, entidadesReferenciadas, enumsReferenciados));
|
|
358
|
+
}
|
|
359
|
+
//# sourceMappingURL=importador.part02.js.map
|