nsj-rest-lib2 0.0.13__py3-none-any.whl → 0.0.14__py3-none-any.whl
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.
- nsj_rest_lib2/compiler/compiler.py +91 -13
- nsj_rest_lib2/compiler/compiler_structures.py +6 -0
- nsj_rest_lib2/compiler/dto_compiler.py +4 -3
- nsj_rest_lib2/compiler/edl_model/entity_model.py +5 -56
- nsj_rest_lib2/compiler/edl_model/entity_model_base.py +69 -0
- nsj_rest_lib2/compiler/edl_model/primitives.py +1 -1
- nsj_rest_lib2/compiler/entity_compiler.py +9 -4
- nsj_rest_lib2/compiler/property_compiler.py +159 -33
- nsj_rest_lib2/compiler/util/type_naming_util.py +4 -4
- nsj_rest_lib2/service/entity_loader.py +1 -1
- {nsj_rest_lib2-0.0.13.dist-info → nsj_rest_lib2-0.0.14.dist-info}/METADATA +1 -1
- {nsj_rest_lib2-0.0.13.dist-info → nsj_rest_lib2-0.0.14.dist-info}/RECORD +14 -13
- {nsj_rest_lib2-0.0.13.dist-info → nsj_rest_lib2-0.0.14.dist-info}/WHEEL +0 -0
- {nsj_rest_lib2-0.0.13.dist-info → nsj_rest_lib2-0.0.14.dist-info}/top_level.txt +0 -0
|
@@ -3,10 +3,12 @@ import re
|
|
|
3
3
|
from typing import Any
|
|
4
4
|
|
|
5
5
|
from nsj_rest_lib2.compiler.compiler_structures import (
|
|
6
|
+
ComponentsCompilerStructure,
|
|
6
7
|
IndexCompilerStructure,
|
|
7
8
|
PropertiesCompilerStructure,
|
|
8
9
|
)
|
|
9
10
|
from nsj_rest_lib2.compiler.dto_compiler import DTOCompiler
|
|
11
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
10
12
|
from nsj_rest_lib2.compiler.edl_model.primitives import REGEX_EXTERNAL_REF
|
|
11
13
|
from nsj_rest_lib2.compiler.entity_compiler import EntityCompiler
|
|
12
14
|
from nsj_rest_lib2.compiler.model import CompilerResult
|
|
@@ -16,16 +18,18 @@ from nsj_rest_lib2.compiler.edl_model.entity_model import EntityModel
|
|
|
16
18
|
|
|
17
19
|
from nsj_rest_lib2.settings import get_logger
|
|
18
20
|
|
|
21
|
+
# TODO Revisar compilação de valores default (sensível a tipos)
|
|
22
|
+
# TODO Implementar suporte a conjuntos
|
|
19
23
|
# TODO Autenticação nas rotas
|
|
20
|
-
# TODO Carregar, dinamicamente, em memória, o código compilado das dependÊncias por relacionamento
|
|
21
24
|
# TODO Atualizar o status da entidade pelo worker de compilação (e talvez parar uma compilação, quando se delete uma entidade)
|
|
22
|
-
# TODO
|
|
25
|
+
# TODO Mixins
|
|
23
26
|
# TODO Classes Abstratas
|
|
24
27
|
# TODO Partial Classes
|
|
25
28
|
# TODO Migrations
|
|
26
|
-
# TODO Adicionar autenticação aos endpoints dinâmicos
|
|
27
29
|
# TODO Criar imagem docker base para as aplicações, usando venv (para poderem atualizar o pydantic)
|
|
28
30
|
|
|
31
|
+
# TODO Suporte ao "min_items" dos relacionamentos no RestLib1
|
|
32
|
+
|
|
29
33
|
|
|
30
34
|
class EDLCompiler:
|
|
31
35
|
def __init__(self) -> None:
|
|
@@ -76,10 +80,18 @@ class EDLCompiler:
|
|
|
76
80
|
|
|
77
81
|
def _compile_model(
|
|
78
82
|
self,
|
|
79
|
-
entity_model:
|
|
83
|
+
entity_model: EntityModelBase,
|
|
80
84
|
entity_models: dict[str, EntityModel],
|
|
85
|
+
escopo: str | None = None,
|
|
86
|
+
prefx_class_name: str = "",
|
|
81
87
|
) -> CompilerResult:
|
|
82
88
|
|
|
89
|
+
if escopo is None and isinstance(entity_model, EntityModel):
|
|
90
|
+
escopo = entity_model.escopo
|
|
91
|
+
|
|
92
|
+
if not escopo:
|
|
93
|
+
raise Exception(f"Escopo não definido para a entidade: {entity_model.id}.")
|
|
94
|
+
|
|
83
95
|
# Criando um mapa de índices por nome de property
|
|
84
96
|
# TODO Implementar tratamento dos índices de apoio às query (não de unicidade)
|
|
85
97
|
map_indexes_by_property: dict[str, list[IndexCompilerStructure]] = {}
|
|
@@ -109,10 +121,43 @@ class EDLCompiler:
|
|
|
109
121
|
) = self._properties_compiler.compile(
|
|
110
122
|
properties_structure,
|
|
111
123
|
map_unique_by_property,
|
|
124
|
+
escopo,
|
|
112
125
|
entity_model,
|
|
113
126
|
entity_models,
|
|
127
|
+
prefx_class_name,
|
|
114
128
|
)
|
|
115
129
|
|
|
130
|
+
# Gerando o buffer para os códigos de DTO e Entity
|
|
131
|
+
dto_code = ""
|
|
132
|
+
entity_code = ""
|
|
133
|
+
relations_dependencies_complete = []
|
|
134
|
+
|
|
135
|
+
# Carregando a estrutura de compilação dos components
|
|
136
|
+
components_structure = ComponentsCompilerStructure()
|
|
137
|
+
self._make_components_structures(
|
|
138
|
+
components_structure, entity_model, entity_models
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Gerando o código das entidades filhas (components)
|
|
142
|
+
for component_key in components_structure.components:
|
|
143
|
+
component = components_structure.components[component_key]
|
|
144
|
+
component_compiled = self._compile_model(
|
|
145
|
+
component,
|
|
146
|
+
entity_models,
|
|
147
|
+
escopo,
|
|
148
|
+
prefx_class_name=f"{prefx_class_name}_{entity_model.id}",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
# Guardando o código gerado no buffer
|
|
152
|
+
if component_compiled.dto_code:
|
|
153
|
+
dto_code += component_compiled.dto_code + "\n\n"
|
|
154
|
+
if component_compiled.entity_code:
|
|
155
|
+
entity_code += component_compiled.entity_code + "\n\n"
|
|
156
|
+
if component_compiled.relations_dependencies:
|
|
157
|
+
relations_dependencies_complete.extend(
|
|
158
|
+
component_compiled.relations_dependencies
|
|
159
|
+
)
|
|
160
|
+
|
|
116
161
|
# Gerando o código do DTO
|
|
117
162
|
dto_class_name, code_dto = self._dto_compiler.compile(
|
|
118
163
|
entity_model,
|
|
@@ -120,32 +165,65 @@ class EDLCompiler:
|
|
|
120
165
|
enum_classes,
|
|
121
166
|
related_imports,
|
|
122
167
|
fixed_filters,
|
|
168
|
+
prefx_class_name,
|
|
123
169
|
)
|
|
124
170
|
|
|
125
171
|
# Gerando o código da Entity
|
|
126
172
|
entity_class_name, code_entity = self._entity_compiler.compile(
|
|
127
|
-
entity_model,
|
|
173
|
+
entity_model,
|
|
174
|
+
ast_entity_attributes,
|
|
175
|
+
props_pk,
|
|
176
|
+
prefx_class_name,
|
|
128
177
|
)
|
|
129
178
|
|
|
179
|
+
# Extendendo os buffers com os códigos gerados
|
|
180
|
+
dto_code += code_dto
|
|
181
|
+
entity_code += code_entity
|
|
182
|
+
relations_dependencies_complete.extend(relations_dependencies)
|
|
183
|
+
|
|
130
184
|
# Construindo o resultado
|
|
131
185
|
compiler_result = CompilerResult()
|
|
132
186
|
compiler_result.entity_class_name = entity_class_name
|
|
133
|
-
compiler_result.entity_code =
|
|
187
|
+
compiler_result.entity_code = entity_code
|
|
134
188
|
compiler_result.dto_class_name = dto_class_name
|
|
135
|
-
compiler_result.dto_code =
|
|
189
|
+
compiler_result.dto_code = dto_code
|
|
136
190
|
|
|
137
191
|
# Compilando questões das APIs
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
192
|
+
if isinstance(entity_model, EntityModel):
|
|
193
|
+
compiler_result.api_expose = entity_model.api.expose
|
|
194
|
+
compiler_result.api_resource = entity_model.api.resource
|
|
195
|
+
compiler_result.api_verbs = entity_model.api.verbs
|
|
196
|
+
compiler_result.relations_dependencies = relations_dependencies_complete
|
|
142
197
|
|
|
143
198
|
return compiler_result
|
|
144
199
|
|
|
200
|
+
def _make_components_structures(
|
|
201
|
+
self,
|
|
202
|
+
components_structure: ComponentsCompilerStructure,
|
|
203
|
+
entity_model: EntityModelBase,
|
|
204
|
+
entity_models: dict[str, EntityModel],
|
|
205
|
+
):
|
|
206
|
+
if not entity_model:
|
|
207
|
+
return
|
|
208
|
+
|
|
209
|
+
# Populando com os components do trait
|
|
210
|
+
if entity_model.trait_from:
|
|
211
|
+
trait_model = entity_models[entity_model.trait_from]
|
|
212
|
+
|
|
213
|
+
self._make_components_structures(
|
|
214
|
+
components_structure,
|
|
215
|
+
trait_model,
|
|
216
|
+
entity_models,
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
# Populando com os components da entidade atual
|
|
220
|
+
if entity_model.components:
|
|
221
|
+
components_structure.components.update(entity_model.components)
|
|
222
|
+
|
|
145
223
|
def _make_properties_structures(
|
|
146
224
|
self,
|
|
147
225
|
properties_structure: PropertiesCompilerStructure,
|
|
148
|
-
entity_model:
|
|
226
|
+
entity_model: EntityModelBase,
|
|
149
227
|
entity_models: dict[str, EntityModel],
|
|
150
228
|
):
|
|
151
229
|
if not entity_model:
|
|
@@ -188,7 +266,7 @@ class EDLCompiler:
|
|
|
188
266
|
self,
|
|
189
267
|
map_indexes_by_property: dict[str, list[IndexCompilerStructure]],
|
|
190
268
|
map_unique_by_property: dict[str, IndexCompilerStructure],
|
|
191
|
-
entity_model:
|
|
269
|
+
entity_model: EntityModelBase,
|
|
192
270
|
entity_models: dict[str, EntityModel],
|
|
193
271
|
deep: int = 1,
|
|
194
272
|
):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from nsj_rest_lib2.compiler.edl_model.column_meta_model import ColumnMetaModel
|
|
2
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
2
3
|
from nsj_rest_lib2.compiler.edl_model.index_model import IndexModel
|
|
3
4
|
from nsj_rest_lib2.compiler.edl_model.property_meta_model import PropertyMetaModel
|
|
4
5
|
from nsj_rest_lib2.compiler.edl_model.trait_property_meta_model import (
|
|
@@ -22,3 +23,8 @@ class PropertiesCompilerStructure:
|
|
|
22
23
|
self.metric_label: list[str] = []
|
|
23
24
|
self.entity_properties: dict[str, ColumnMetaModel] = {}
|
|
24
25
|
self.trait_properties: dict[str, TraitPropertyMetaModel] = {}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class ComponentsCompilerStructure:
|
|
29
|
+
def __init__(self) -> None:
|
|
30
|
+
self.components: dict[str, EntityModelBase] = {}
|
|
@@ -3,8 +3,8 @@ import ast
|
|
|
3
3
|
import black
|
|
4
4
|
|
|
5
5
|
from nsj_rest_lib2.compiler.edl_model.entity_model import EntityModel
|
|
6
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
6
7
|
from nsj_rest_lib2.compiler.edl_model.primitives import BasicTypes
|
|
7
|
-
from nsj_rest_lib2.compiler.util.str_util import CompilerStrUtil
|
|
8
8
|
from nsj_rest_lib2.compiler.util.type_naming_util import compile_dto_class_name
|
|
9
9
|
|
|
10
10
|
|
|
@@ -14,11 +14,12 @@ class DTOCompiler:
|
|
|
14
14
|
|
|
15
15
|
def compile(
|
|
16
16
|
self,
|
|
17
|
-
entity_model:
|
|
17
|
+
entity_model: EntityModelBase,
|
|
18
18
|
ast_dto_attributes: list[ast.stmt],
|
|
19
19
|
enum_classes: list[ast.stmt],
|
|
20
20
|
related_imports: list[tuple[str, str, str]],
|
|
21
21
|
fixed_filters: list[tuple[str, BasicTypes]],
|
|
22
|
+
prefx_class_name: str,
|
|
22
23
|
) -> tuple[str, str]:
|
|
23
24
|
"""
|
|
24
25
|
Compila o código do DTO a partir do AST e retorna o código compilado.
|
|
@@ -117,7 +118,7 @@ class DTOCompiler:
|
|
|
117
118
|
)
|
|
118
119
|
|
|
119
120
|
# Criando o ast da classe
|
|
120
|
-
class_name = compile_dto_class_name(entity_model.id)
|
|
121
|
+
class_name = compile_dto_class_name(entity_model.id, prefx_class_name)
|
|
121
122
|
ast_class = ast.ClassDef(
|
|
122
123
|
name=class_name,
|
|
123
124
|
bases=[ast.Name(id="DTOBase", ctx=ast.Load())],
|
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from pydantic import
|
|
4
|
-
from typing import
|
|
3
|
+
from pydantic import Field
|
|
4
|
+
from typing import Optional
|
|
5
5
|
|
|
6
|
-
from nsj_rest_lib2.compiler.edl_model.property_meta_model import PropertyMetaModel
|
|
7
|
-
from nsj_rest_lib2.compiler.edl_model.repository_model import RepositoryModel
|
|
8
6
|
from nsj_rest_lib2.compiler.edl_model.api_model import APIModel
|
|
9
|
-
from nsj_rest_lib2.compiler.edl_model.
|
|
10
|
-
TraitPropertyMetaModel,
|
|
11
|
-
)
|
|
7
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
12
8
|
|
|
13
9
|
|
|
14
|
-
class EntityModel(
|
|
10
|
+
class EntityModel(EntityModelBase):
|
|
15
11
|
edl_version: Optional[str] = Field(default="1.0", description="Versão do EDL")
|
|
16
12
|
escopo: str = Field(..., description="Escopo do EDL (define a aplicação).")
|
|
17
|
-
description: str = Field(..., description="Descrição da entidade.")
|
|
18
|
-
id: str = Field(
|
|
19
|
-
...,
|
|
20
|
-
description="Identificador único da entidade, dentro de um determinado escopo (podendo ser sobreescrito para um tenant ou grupo _empresarial).",
|
|
21
|
-
)
|
|
22
|
-
trait_from: Optional[str] = Field(
|
|
23
|
-
None, description="Identificador da entidade que a trait estende."
|
|
24
|
-
)
|
|
25
13
|
version: Optional[str] = Field(
|
|
26
14
|
default="1.0", description="Versão da entidade (padrão: 1.0)."
|
|
27
15
|
)
|
|
@@ -29,46 +17,7 @@ class EntityModel(BaseModel):
|
|
|
29
17
|
default=False,
|
|
30
18
|
description="Indica se a entidade é abstrata (padrão: False). Caso positivo, não gera código, mas pode ser usada na geração de código de outras entidades.",
|
|
31
19
|
)
|
|
32
|
-
mixins: Optional[List[str]] = Field(
|
|
33
|
-
None,
|
|
34
|
-
description="Lista de mixins (blocos reutilizáveis) aplicados ao modelo.",
|
|
35
|
-
)
|
|
36
|
-
required: Optional[List[str]] = Field(
|
|
37
|
-
None, description="Lista de campos obrigatórios no modelo."
|
|
38
|
-
)
|
|
39
|
-
partition_data: Optional[List[str]] = Field(
|
|
40
|
-
None,
|
|
41
|
-
description="Lista de propriedades da entidade, que serã usadas para particionamento dos dados no banco (sendo obrigatórias em todas as chamadas, inclusive como um tipo de filtro obrigatório).",
|
|
42
|
-
)
|
|
43
|
-
main_properties: Optional[List[str]] = Field(
|
|
44
|
-
None,
|
|
45
|
-
description="Lista de propriedades resumo do modelo (retornadas em qualquer chamada GET, mesmo que não pedidas por meio do parâmetro 'fields').",
|
|
46
|
-
)
|
|
47
|
-
search_properties: Optional[List[str]] = Field(
|
|
48
|
-
None,
|
|
49
|
-
description="Lista de propriedades do modelo que serão utilizadas nas chamadas de query do usuário (suportando também campos das entidades relacionadas). Sugere-se que a biblioteca crie automaticamente os índices para fulltext search.",
|
|
50
|
-
)
|
|
51
|
-
metric_label: Optional[List[str]] = Field(
|
|
52
|
-
None,
|
|
53
|
-
description="Lista de campos incluídos no agrupamento das métricas enviadas ao OpenTelemetry.",
|
|
54
|
-
)
|
|
55
|
-
trait_properties: Optional[Dict[str, TraitPropertyMetaModel]] = Field(
|
|
56
|
-
None,
|
|
57
|
-
description="Dicionário de propriedades condicionais da trait (isso é, especifica propriedades, e seus valores fixos, que serão usados como um tipo de filtro fixo usado como condição para que a propridade principal assum o papel daquele tipo de trait).",
|
|
58
|
-
)
|
|
59
|
-
properties: Dict[str, PropertyMetaModel] = Field(
|
|
60
|
-
..., description="Dicionário de propriedades do modelo."
|
|
61
|
-
)
|
|
62
|
-
repository: RepositoryModel = Field(
|
|
63
|
-
..., description="Configurações de mapeamento para o banco de dados."
|
|
64
|
-
)
|
|
65
20
|
api: APIModel = Field(
|
|
66
21
|
...,
|
|
67
22
|
description="Definição da API REST associada ao modelo, com todos os seus endpoints.",
|
|
68
23
|
)
|
|
69
|
-
|
|
70
|
-
# Propriedades de controle da compilação (não fazem parte do JSON de representação das entidades)
|
|
71
|
-
tenant: int = Field(default=0, exclude=True)
|
|
72
|
-
grupo_empresarial: uuid.UUID = Field(
|
|
73
|
-
default=uuid.UUID("00000000-0000-0000-0000-000000000000"), exclude=True
|
|
74
|
-
)
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import uuid
|
|
4
|
+
|
|
5
|
+
from pydantic import BaseModel, Field
|
|
6
|
+
from typing import Dict, List, Optional
|
|
7
|
+
|
|
8
|
+
from nsj_rest_lib2.compiler.edl_model.property_meta_model import PropertyMetaModel
|
|
9
|
+
from nsj_rest_lib2.compiler.edl_model.repository_model import RepositoryModel
|
|
10
|
+
from nsj_rest_lib2.compiler.edl_model.trait_property_meta_model import (
|
|
11
|
+
TraitPropertyMetaModel,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class EntityModelBase(BaseModel):
|
|
16
|
+
description: str = Field(..., description="Descrição da entidade.")
|
|
17
|
+
id: str = Field(
|
|
18
|
+
...,
|
|
19
|
+
description="Identificador único da entidade, dentro de um determinado escopo (podendo ser sobreescrito para um tenant ou grupo _empresarial).",
|
|
20
|
+
)
|
|
21
|
+
trait_from: Optional[str] = Field(
|
|
22
|
+
None, description="Identificador da entidade que a trait estende."
|
|
23
|
+
)
|
|
24
|
+
mixins: Optional[List[str]] = Field(
|
|
25
|
+
None,
|
|
26
|
+
description="Lista de mixins (blocos reutilizáveis) aplicados ao modelo.",
|
|
27
|
+
)
|
|
28
|
+
required: Optional[List[str]] = Field(
|
|
29
|
+
None, description="Lista de campos obrigatórios no modelo."
|
|
30
|
+
)
|
|
31
|
+
partition_data: Optional[List[str]] = Field(
|
|
32
|
+
None,
|
|
33
|
+
description="Lista de propriedades da entidade, que serã usadas para particionamento dos dados no banco (sendo obrigatórias em todas as chamadas, inclusive como um tipo de filtro obrigatório).",
|
|
34
|
+
)
|
|
35
|
+
main_properties: Optional[List[str]] = Field(
|
|
36
|
+
None,
|
|
37
|
+
description="Lista de propriedades resumo do modelo (retornadas em qualquer chamada GET, mesmo que não pedidas por meio do parâmetro 'fields').",
|
|
38
|
+
)
|
|
39
|
+
search_properties: Optional[List[str]] = Field(
|
|
40
|
+
None,
|
|
41
|
+
description="Lista de propriedades do modelo que serão utilizadas nas chamadas de query do usuário (suportando também campos das entidades relacionadas). Sugere-se que a biblioteca crie automaticamente os índices para fulltext search.",
|
|
42
|
+
)
|
|
43
|
+
metric_label: Optional[List[str]] = Field(
|
|
44
|
+
None,
|
|
45
|
+
description="Lista de campos incluídos no agrupamento das métricas enviadas ao OpenTelemetry.",
|
|
46
|
+
)
|
|
47
|
+
trait_properties: Optional[Dict[str, TraitPropertyMetaModel]] = Field(
|
|
48
|
+
None,
|
|
49
|
+
description="Dicionário de propriedades condicionais da trait (isso é, especifica propriedades, e seus valores fixos, que serão usados como um tipo de filtro fixo usado como condição para que a propridade principal assum o papel daquele tipo de trait).",
|
|
50
|
+
)
|
|
51
|
+
properties: Dict[str, PropertyMetaModel] = Field(
|
|
52
|
+
..., description="Dicionário de propriedades do modelo."
|
|
53
|
+
)
|
|
54
|
+
components: Optional[Dict[str, "EntityModelBase"]] = Field(
|
|
55
|
+
None,
|
|
56
|
+
description="Entidades filhas, relacionadas por composição e definidas inline (evitando a criação de novos arquivos EDL para a definição de entidades componentes da entidade atual).",
|
|
57
|
+
)
|
|
58
|
+
repository: RepositoryModel = Field(
|
|
59
|
+
..., description="Configurações de mapeamento para o banco de dados."
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
# Propriedades de controle da compilação (não fazem parte do JSON de representação das entidades)
|
|
63
|
+
tenant: int = Field(default=0, exclude=True)
|
|
64
|
+
grupo_empresarial: uuid.UUID = Field(
|
|
65
|
+
default=uuid.UUID("00000000-0000-0000-0000-000000000000"), exclude=True
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
EntityModelBase.model_rebuild()
|
|
@@ -4,7 +4,7 @@ from typing import Annotated, List, Union
|
|
|
4
4
|
from pydantic import StringConstraints
|
|
5
5
|
|
|
6
6
|
REGEX_EXTERNAL_REF = r"^(\w+)\/(\w+)$"
|
|
7
|
-
REGEX_INTERNAL_REF = r"^#\/
|
|
7
|
+
REGEX_INTERNAL_REF = r"^#\/components\/(\w+)$"
|
|
8
8
|
|
|
9
9
|
ExternalRefType = Annotated[str, StringConstraints(pattern=REGEX_EXTERNAL_REF)]
|
|
10
10
|
InternalRefType = Annotated[str, StringConstraints(pattern=REGEX_INTERNAL_REF)]
|
|
@@ -3,7 +3,7 @@ import ast
|
|
|
3
3
|
import black
|
|
4
4
|
|
|
5
5
|
from nsj_rest_lib2.compiler.edl_model.entity_model import EntityModel
|
|
6
|
-
from nsj_rest_lib2.compiler.edl_model.
|
|
6
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
7
7
|
from nsj_rest_lib2.compiler.util.str_util import CompilerStrUtil
|
|
8
8
|
from nsj_rest_lib2.compiler.util.type_naming_util import compile_entity_class_name
|
|
9
9
|
|
|
@@ -14,9 +14,10 @@ class EntityCompiler:
|
|
|
14
14
|
|
|
15
15
|
def compile(
|
|
16
16
|
self,
|
|
17
|
-
entity_model:
|
|
17
|
+
entity_model: EntityModelBase,
|
|
18
18
|
ast_entity_attributes: list[ast.stmt],
|
|
19
19
|
props_pk: list[str],
|
|
20
|
+
prefix_class_name: str,
|
|
20
21
|
) -> tuple[str, str]:
|
|
21
22
|
# Imports
|
|
22
23
|
imports = [
|
|
@@ -49,7 +50,11 @@ class EntityCompiler:
|
|
|
49
50
|
)
|
|
50
51
|
|
|
51
52
|
default_order_props = []
|
|
52
|
-
if
|
|
53
|
+
if (
|
|
54
|
+
isinstance(entity_model, EntityModel)
|
|
55
|
+
and entity_model.api
|
|
56
|
+
and entity_model.api.default_sort
|
|
57
|
+
):
|
|
53
58
|
default_order_props = entity_model.api.default_sort
|
|
54
59
|
|
|
55
60
|
default_order_fields = []
|
|
@@ -67,7 +72,7 @@ class EntityCompiler:
|
|
|
67
72
|
if CompilerStrUtil.to_snake_case(props_pk[0]) not in default_order_fields:
|
|
68
73
|
default_order_fields.append(CompilerStrUtil.to_snake_case(props_pk[0]))
|
|
69
74
|
|
|
70
|
-
class_name = compile_entity_class_name(entity_model.id)
|
|
75
|
+
class_name = compile_entity_class_name(entity_model.id, prefix_class_name)
|
|
71
76
|
ast_class = ast.ClassDef(
|
|
72
77
|
name=class_name,
|
|
73
78
|
bases=[ast.Name(id="EntityBase", ctx=ast.Load())],
|
|
@@ -6,6 +6,7 @@ from nsj_rest_lib2.compiler.compiler_structures import (
|
|
|
6
6
|
PropertiesCompilerStructure,
|
|
7
7
|
)
|
|
8
8
|
from nsj_rest_lib2.compiler.edl_model.entity_model import EntityModel
|
|
9
|
+
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
9
10
|
from nsj_rest_lib2.compiler.edl_model.primitives import (
|
|
10
11
|
BasicTypes,
|
|
11
12
|
CardinalityTypes,
|
|
@@ -29,16 +30,18 @@ from nsj_rest_lib2.compiler.util.type_util import TypeUtil
|
|
|
29
30
|
# TODO pattern
|
|
30
31
|
# TODO lowercase
|
|
31
32
|
# TODO uppercase
|
|
32
|
-
# TODO Adicionar o nome da entidade, no nome das classes de enum (para evitar conflitos no caso das traits)
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
class EDLPropertyCompiler:
|
|
36
|
+
|
|
36
37
|
def compile(
|
|
37
38
|
self,
|
|
38
39
|
properties_structure: PropertiesCompilerStructure,
|
|
39
40
|
map_unique_by_property: dict[str, IndexCompilerStructure],
|
|
40
|
-
|
|
41
|
+
escopo: str,
|
|
42
|
+
entity_model: EntityModelBase,
|
|
41
43
|
entity_models: dict[str, EntityModel],
|
|
44
|
+
prefx_class_name: str,
|
|
42
45
|
) -> tuple[
|
|
43
46
|
list[ast.stmt],
|
|
44
47
|
list[ast.stmt],
|
|
@@ -52,22 +55,23 @@ class EDLPropertyCompiler:
|
|
|
52
55
|
# TODO Criar opção de campo calculado?
|
|
53
56
|
|
|
54
57
|
# Descobrindo os atributos marcados como PK (e recuperando a chave primária)
|
|
55
|
-
#
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
# TODO Verificar se devemos manter essa verificação
|
|
59
|
+
pk_keys = []
|
|
60
|
+
for pkey in properties_structure.properties:
|
|
61
|
+
prop = properties_structure.properties[pkey]
|
|
62
|
+
|
|
63
|
+
if isinstance(prop.type, PrimitiveTypes):
|
|
64
|
+
if prop.pk:
|
|
65
|
+
pk_keys.append(pkey)
|
|
66
|
+
|
|
67
|
+
if len(pk_keys) > 1:
|
|
68
|
+
raise Exception(
|
|
69
|
+
f"Entidade '{entity_model.id}' possui mais de uma chave primária (ainda não suportado): {pk_keys}"
|
|
70
|
+
)
|
|
71
|
+
elif len(pk_keys) == 0:
|
|
72
|
+
raise Exception(
|
|
73
|
+
f"Entidade '{entity_model.id}' não tem nenhuma chave primária (ainda não suportado)"
|
|
74
|
+
)
|
|
71
75
|
|
|
72
76
|
# pk_key = pk_keys[0]
|
|
73
77
|
|
|
@@ -87,11 +91,12 @@ class EDLPropertyCompiler:
|
|
|
87
91
|
prop = properties_structure.properties[pkey]
|
|
88
92
|
|
|
89
93
|
# DTO
|
|
90
|
-
## Tratando propriedade simples (não array, não object)
|
|
91
94
|
if isinstance(prop.type, PrimitiveTypes):
|
|
95
|
+
# Tratando propriedade simples (não array, não object)
|
|
92
96
|
self._compile_simple_property(
|
|
93
97
|
properties_structure,
|
|
94
98
|
map_unique_by_property,
|
|
99
|
+
escopo,
|
|
95
100
|
entity_model,
|
|
96
101
|
ast_dto_attributes,
|
|
97
102
|
ast_entity_attributes,
|
|
@@ -99,9 +104,11 @@ class EDLPropertyCompiler:
|
|
|
99
104
|
enum_classes,
|
|
100
105
|
pkey,
|
|
101
106
|
prop,
|
|
107
|
+
prefx_class_name,
|
|
102
108
|
)
|
|
103
109
|
|
|
104
110
|
elif isinstance(prop.type, str):
|
|
111
|
+
# Tratando propriedade de relacionamento
|
|
105
112
|
external_match = re.match(REGEX_EXTERNAL_REF, prop.type)
|
|
106
113
|
internal_match = re.match(REGEX_INTERNAL_REF, prop.type)
|
|
107
114
|
|
|
@@ -125,8 +132,18 @@ class EDLPropertyCompiler:
|
|
|
125
132
|
)
|
|
126
133
|
|
|
127
134
|
elif internal_match:
|
|
128
|
-
|
|
129
|
-
|
|
135
|
+
related_entity_id = internal_match.group(1)
|
|
136
|
+
|
|
137
|
+
self._compile_internal_relation(
|
|
138
|
+
related_entity_id,
|
|
139
|
+
entity_model,
|
|
140
|
+
properties_structure,
|
|
141
|
+
ast_dto_attributes,
|
|
142
|
+
ast_entity_attributes,
|
|
143
|
+
pkey,
|
|
144
|
+
prop,
|
|
145
|
+
prefx_class_name,
|
|
146
|
+
)
|
|
130
147
|
else:
|
|
131
148
|
raise Exception(
|
|
132
149
|
f"Tipo da propriedade '{pkey}' não suportado: {prop.type}"
|
|
@@ -143,8 +160,10 @@ class EDLPropertyCompiler:
|
|
|
143
160
|
ast_dto_attributes,
|
|
144
161
|
ast_entity_attributes,
|
|
145
162
|
fixed_filters,
|
|
163
|
+
escopo,
|
|
146
164
|
entity_model,
|
|
147
165
|
enum_classes,
|
|
166
|
+
prefx_class_name,
|
|
148
167
|
)
|
|
149
168
|
|
|
150
169
|
return (
|
|
@@ -166,8 +185,10 @@ class EDLPropertyCompiler:
|
|
|
166
185
|
ast_dto_attributes: list[ast.stmt],
|
|
167
186
|
ast_entity_attributes: list[ast.stmt],
|
|
168
187
|
fixed_filters: list[tuple[str, BasicTypes]],
|
|
169
|
-
|
|
188
|
+
escopo: str,
|
|
189
|
+
entity_model: EntityModelBase,
|
|
170
190
|
enum_classes: list[ast.stmt],
|
|
191
|
+
prefx_class_name: str,
|
|
171
192
|
):
|
|
172
193
|
enum_class_name = None
|
|
173
194
|
keywords = []
|
|
@@ -273,7 +294,9 @@ class EDLPropertyCompiler:
|
|
|
273
294
|
|
|
274
295
|
# Trtando de uma definição de enum
|
|
275
296
|
if prop.domain_config:
|
|
276
|
-
result = self._compile_domain_config(
|
|
297
|
+
result = self._compile_domain_config(
|
|
298
|
+
pkey, prop, escopo, entity_model, prefx_class_name
|
|
299
|
+
)
|
|
277
300
|
if not result:
|
|
278
301
|
raise Exception(f"Erro desconhecido ao compilar a propriedade {pkey}")
|
|
279
302
|
|
|
@@ -343,14 +366,14 @@ class EDLPropertyCompiler:
|
|
|
343
366
|
ast_entity_attributes.append(ast_entity_attr)
|
|
344
367
|
|
|
345
368
|
# Guardando como um fixed_filter
|
|
346
|
-
# TODO
|
|
369
|
+
# TODO Pensar em validações para esse value (se está de acordo com o tipo ou enum)
|
|
347
370
|
fixed_filters.append((pkey, prop.value))
|
|
348
371
|
|
|
349
372
|
def _compile_external_relation(
|
|
350
373
|
self,
|
|
351
374
|
related_entity_id: str,
|
|
352
375
|
related_entity_key: str,
|
|
353
|
-
entity_model:
|
|
376
|
+
entity_model: EntityModelBase,
|
|
354
377
|
entity_models: dict[str, EntityModel],
|
|
355
378
|
properties_structure: PropertiesCompilerStructure,
|
|
356
379
|
ast_dto_attributes: list[ast.stmt],
|
|
@@ -414,6 +437,57 @@ class EDLPropertyCompiler:
|
|
|
414
437
|
pkey,
|
|
415
438
|
related_dto_class_name,
|
|
416
439
|
related_entity_class_name,
|
|
440
|
+
prop,
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
elif prop.cardinality == CardinalityTypes.C1_1:
|
|
444
|
+
self._build_ast_1_1(
|
|
445
|
+
properties_structure,
|
|
446
|
+
ast_dto_attributes,
|
|
447
|
+
ast_entity_attributes,
|
|
448
|
+
pkey,
|
|
449
|
+
related_dto_class_name,
|
|
450
|
+
related_entity_class_name,
|
|
451
|
+
prop,
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
elif prop.cardinality == CardinalityTypes.CN_N:
|
|
455
|
+
# TODO
|
|
456
|
+
pass
|
|
457
|
+
else:
|
|
458
|
+
raise Exception(
|
|
459
|
+
f"Propriedade '{pkey}' da entidade '{entity_model.id}' possui cardinalidade inválida ou não suportada: {prop.cardinality}"
|
|
460
|
+
)
|
|
461
|
+
|
|
462
|
+
def _compile_internal_relation(
|
|
463
|
+
self,
|
|
464
|
+
related_entity_id: str,
|
|
465
|
+
entity_model: EntityModelBase,
|
|
466
|
+
properties_structure: PropertiesCompilerStructure,
|
|
467
|
+
ast_dto_attributes: list[ast.stmt],
|
|
468
|
+
ast_entity_attributes: list[ast.stmt],
|
|
469
|
+
pkey: str,
|
|
470
|
+
prop: PropertyMetaModel,
|
|
471
|
+
prefx_class_name: str,
|
|
472
|
+
):
|
|
473
|
+
# Resolvendo o nome das classes de DTO e Entity
|
|
474
|
+
related_dto_class_name = compile_dto_class_name(
|
|
475
|
+
related_entity_id, f"{prefx_class_name}_{entity_model.id}"
|
|
476
|
+
)
|
|
477
|
+
related_entity_class_name = compile_entity_class_name(
|
|
478
|
+
related_entity_id, f"{prefx_class_name}_{entity_model.id}"
|
|
479
|
+
)
|
|
480
|
+
|
|
481
|
+
# Instanciando o ast
|
|
482
|
+
if prop.cardinality == CardinalityTypes.C1_N:
|
|
483
|
+
# Para relacionamentos 1_N
|
|
484
|
+
self._build_ast_1_N(
|
|
485
|
+
properties_structure,
|
|
486
|
+
ast_dto_attributes,
|
|
487
|
+
pkey,
|
|
488
|
+
related_dto_class_name,
|
|
489
|
+
related_entity_class_name,
|
|
490
|
+
prop,
|
|
417
491
|
)
|
|
418
492
|
|
|
419
493
|
elif prop.cardinality == CardinalityTypes.C1_1:
|
|
@@ -424,6 +498,7 @@ class EDLPropertyCompiler:
|
|
|
424
498
|
pkey,
|
|
425
499
|
related_dto_class_name,
|
|
426
500
|
related_entity_class_name,
|
|
501
|
+
prop,
|
|
427
502
|
)
|
|
428
503
|
|
|
429
504
|
elif prop.cardinality == CardinalityTypes.CN_N:
|
|
@@ -441,7 +516,10 @@ class EDLPropertyCompiler:
|
|
|
441
516
|
pkey: str,
|
|
442
517
|
related_dto_class_name: str,
|
|
443
518
|
related_entity_class_name: str,
|
|
519
|
+
prop: PropertyMetaModel,
|
|
444
520
|
):
|
|
521
|
+
# TODO Verificar uso da propriedade relation_key_field do Rest_lib_1
|
|
522
|
+
|
|
445
523
|
# Propriedade do property descriptor
|
|
446
524
|
keywords = [
|
|
447
525
|
ast.keyword(
|
|
@@ -454,6 +532,23 @@ class EDLPropertyCompiler:
|
|
|
454
532
|
),
|
|
455
533
|
]
|
|
456
534
|
|
|
535
|
+
# Tratando das opções básicas do descritor de propriedade
|
|
536
|
+
if properties_structure.required and pkey in properties_structure.required:
|
|
537
|
+
keywords.append(ast.keyword(arg="not_null", value=ast.Constant(True)))
|
|
538
|
+
|
|
539
|
+
if prop.max_length:
|
|
540
|
+
keywords.append(ast.keyword(arg="max", value=ast.Constant(prop.max_length)))
|
|
541
|
+
if prop.min_length:
|
|
542
|
+
keywords.append(ast.keyword(arg="min", value=ast.Constant(prop.min_length)))
|
|
543
|
+
|
|
544
|
+
if prop.validator:
|
|
545
|
+
keywords.append(
|
|
546
|
+
ast.keyword(
|
|
547
|
+
arg="validator",
|
|
548
|
+
value=ast.Name(prop.validator, ctx=ast.Load()),
|
|
549
|
+
)
|
|
550
|
+
)
|
|
551
|
+
|
|
457
552
|
# Resolvendo a coluna usada no relacionamento
|
|
458
553
|
if (
|
|
459
554
|
not properties_structure.entity_properties
|
|
@@ -464,7 +559,10 @@ class EDLPropertyCompiler:
|
|
|
464
559
|
f"Propriedade '{pkey}' possui um relacionamento, mas nenhuma coluna de relacioanamento foi apontada na propriedade correspondente no repository."
|
|
465
560
|
)
|
|
466
561
|
|
|
467
|
-
|
|
562
|
+
relation_column_ref = properties_structure.entity_properties[
|
|
563
|
+
pkey
|
|
564
|
+
].relation_column
|
|
565
|
+
relation_column = str(relation_column_ref).split("/")[-1]
|
|
468
566
|
|
|
469
567
|
keywords.append(
|
|
470
568
|
ast.keyword(
|
|
@@ -497,6 +595,7 @@ class EDLPropertyCompiler:
|
|
|
497
595
|
pkey: str,
|
|
498
596
|
related_dto_class_name: str,
|
|
499
597
|
related_entity_class_name: str,
|
|
598
|
+
prop: PropertyMetaModel,
|
|
500
599
|
):
|
|
501
600
|
# Propriedade do property descriptor
|
|
502
601
|
keywords = [
|
|
@@ -506,6 +605,24 @@ class EDLPropertyCompiler:
|
|
|
506
605
|
),
|
|
507
606
|
]
|
|
508
607
|
|
|
608
|
+
# Tratando das opções básicas do descritor de propriedade
|
|
609
|
+
if properties_structure.required and pkey in properties_structure.required:
|
|
610
|
+
keywords.append(ast.keyword(arg="not_null", value=ast.Constant(True)))
|
|
611
|
+
|
|
612
|
+
if (
|
|
613
|
+
properties_structure.main_properties
|
|
614
|
+
and pkey in properties_structure.main_properties
|
|
615
|
+
):
|
|
616
|
+
keywords.append(ast.keyword(arg="resume", value=ast.Constant(True)))
|
|
617
|
+
|
|
618
|
+
if prop.validator:
|
|
619
|
+
keywords.append(
|
|
620
|
+
ast.keyword(
|
|
621
|
+
arg="validator",
|
|
622
|
+
value=ast.Name(prop.validator, ctx=ast.Load()),
|
|
623
|
+
)
|
|
624
|
+
)
|
|
625
|
+
|
|
509
626
|
# Resolvendo a coluna usada no relacionamento
|
|
510
627
|
if (
|
|
511
628
|
not properties_structure.entity_properties
|
|
@@ -525,6 +642,9 @@ class EDLPropertyCompiler:
|
|
|
525
642
|
owner_relation = True
|
|
526
643
|
relation_column = relation_column.split("/")[-1]
|
|
527
644
|
|
|
645
|
+
# TODO Verificar, porque desconfio que o apontamento para a coluna de relacionamento
|
|
646
|
+
# para o caso do relacionamento OTHER, não é suportado pelo RestLib (acho que, quando
|
|
647
|
+
# o dono é OTHER, o RestLib sempre aponta para a PK da entidade corrente).
|
|
528
648
|
keywords.append(
|
|
529
649
|
ast.keyword(
|
|
530
650
|
arg="relation_field",
|
|
@@ -621,6 +741,7 @@ class EDLPropertyCompiler:
|
|
|
621
741
|
self,
|
|
622
742
|
properties_structure,
|
|
623
743
|
map_unique_by_property,
|
|
744
|
+
escopo,
|
|
624
745
|
entity_model,
|
|
625
746
|
ast_dto_attributes,
|
|
626
747
|
ast_entity_attributes,
|
|
@@ -628,6 +749,7 @@ class EDLPropertyCompiler:
|
|
|
628
749
|
enum_classes,
|
|
629
750
|
pkey,
|
|
630
751
|
prop,
|
|
752
|
+
prefx_class_name: str,
|
|
631
753
|
):
|
|
632
754
|
enum_class_name = None
|
|
633
755
|
keywords = []
|
|
@@ -681,18 +803,18 @@ class EDLPropertyCompiler:
|
|
|
681
803
|
if prop.type in [PrimitiveTypes.STRING, PrimitiveTypes.EMAIL]:
|
|
682
804
|
if prop.max_length:
|
|
683
805
|
max = prop.max_length
|
|
684
|
-
|
|
806
|
+
if prop.min_length:
|
|
685
807
|
min = prop.min_length
|
|
686
808
|
elif prop.type in [PrimitiveTypes.INTEGER, PrimitiveTypes.NUMBER]:
|
|
687
809
|
if prop.minimum:
|
|
688
810
|
min = prop.minimum
|
|
689
|
-
|
|
811
|
+
if prop.maximum:
|
|
690
812
|
max = prop.maximum
|
|
691
813
|
|
|
692
814
|
if max:
|
|
693
|
-
keywords.append(ast.keyword(arg="max", value=ast.Constant(
|
|
815
|
+
keywords.append(ast.keyword(arg="max", value=ast.Constant(max)))
|
|
694
816
|
if min:
|
|
695
|
-
keywords.append(ast.keyword(arg="min", value=ast.Constant(
|
|
817
|
+
keywords.append(ast.keyword(arg="min", value=ast.Constant(min)))
|
|
696
818
|
|
|
697
819
|
if (
|
|
698
820
|
properties_structure.search_properties
|
|
@@ -796,7 +918,9 @@ class EDLPropertyCompiler:
|
|
|
796
918
|
)
|
|
797
919
|
|
|
798
920
|
if prop.domain_config:
|
|
799
|
-
result = self._compile_domain_config(
|
|
921
|
+
result = self._compile_domain_config(
|
|
922
|
+
pkey, prop, escopo, entity_model, prefx_class_name
|
|
923
|
+
)
|
|
800
924
|
if not result:
|
|
801
925
|
raise Exception(f"Erro desconhecido ao compilar a propriedade {pkey}")
|
|
802
926
|
|
|
@@ -839,7 +963,9 @@ class EDLPropertyCompiler:
|
|
|
839
963
|
self,
|
|
840
964
|
pkey: str,
|
|
841
965
|
prop: PropertyMetaModel | TraitPropertyMetaModel,
|
|
842
|
-
|
|
966
|
+
escopo: str,
|
|
967
|
+
entity_model: EntityModelBase,
|
|
968
|
+
prefx_class_name: str,
|
|
843
969
|
) -> tuple[str, ast.stmt] | None:
|
|
844
970
|
if not prop.domain_config:
|
|
845
971
|
return None
|
|
@@ -881,7 +1007,7 @@ class EDLPropertyCompiler:
|
|
|
881
1007
|
ast_values.append(ast_value)
|
|
882
1008
|
|
|
883
1009
|
# Instanciando o atributo AST
|
|
884
|
-
enum_class_name = f"{CompilerStrUtil.to_pascal_case(
|
|
1010
|
+
enum_class_name = f"{CompilerStrUtil.to_pascal_case(escopo)}{CompilerStrUtil.to_pascal_case(prefx_class_name)}{CompilerStrUtil.to_pascal_case(entity_model.id)}{CompilerStrUtil.to_pascal_case(pkey)}Enum"
|
|
885
1011
|
ast_enum_class = ast.ClassDef(
|
|
886
1012
|
name=enum_class_name,
|
|
887
1013
|
bases=[
|
|
@@ -13,9 +13,9 @@ def compile_namespace_keys(
|
|
|
13
13
|
return (grupo_key, tenant_key, default_key)
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
def compile_dto_class_name(entity_id: str) -> str:
|
|
17
|
-
return f"{CompilerStrUtil.to_pascal_case(entity_id)}DTO"
|
|
16
|
+
def compile_dto_class_name(entity_id: str, prefx_class_name: str = "") -> str:
|
|
17
|
+
return f"{CompilerStrUtil.to_pascal_case(prefx_class_name)}{CompilerStrUtil.to_pascal_case(entity_id)}DTO"
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def compile_entity_class_name(entity_id: str) -> str:
|
|
21
|
-
return f"{CompilerStrUtil.to_pascal_case(entity_id)}Entity"
|
|
20
|
+
def compile_entity_class_name(entity_id: str, prefx_class_name: str = "") -> str:
|
|
21
|
+
return f"{CompilerStrUtil.to_pascal_case(prefx_class_name)}{CompilerStrUtil.to_pascal_case(entity_id)}Entity"
|
|
@@ -317,8 +317,8 @@ class EntityLoader:
|
|
|
317
317
|
namespace.module = module
|
|
318
318
|
namespace.entities_dict = module.__dict__
|
|
319
319
|
|
|
320
|
-
self._safe_exec(source_dto, namespace.entities_dict, "DTO source")
|
|
321
320
|
self._safe_exec(source_entity, namespace.entities_dict, "Entity source")
|
|
321
|
+
self._safe_exec(source_dto, namespace.entities_dict, "DTO source")
|
|
322
322
|
|
|
323
323
|
# Gravando a entidade no dict de entidades carregadas
|
|
324
324
|
loaded_entity = LoadedEntity()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: nsj_rest_lib2
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.14
|
|
4
4
|
Summary: Biblioteca para permitir a distribuição de rotas dinâmicas numa API, configuradas por meio de EDLs declarativos (em formato JSON).
|
|
5
5
|
Home-page: https://github.com/Nasajon/nsj_rest_lib2
|
|
6
6
|
Author: Nasajon Sistemas
|
|
@@ -4,31 +4,32 @@ nsj_rest_lib2/redis_config.py,sha256=4KLcvYS3nJO7PMQgF6F9_j6r-TyqcS7TBbd3LEQuKDU
|
|
|
4
4
|
nsj_rest_lib2/settings.py,sha256=Hn_o1HZmievnYb8D1kNT2Nq-OEjxbyNjOiOpbnFsMwE,367
|
|
5
5
|
nsj_rest_lib2/compiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
nsj_rest_lib2/compiler/ai_compiler.py,sha256=shAtN4T0ai_52qh15L3mK1QbeC6glHOR6C3J3gj14II,9029
|
|
7
|
-
nsj_rest_lib2/compiler/compiler.py,sha256=
|
|
8
|
-
nsj_rest_lib2/compiler/compiler_structures.py,sha256=
|
|
9
|
-
nsj_rest_lib2/compiler/dto_compiler.py,sha256=
|
|
10
|
-
nsj_rest_lib2/compiler/entity_compiler.py,sha256=
|
|
7
|
+
nsj_rest_lib2/compiler/compiler.py,sha256=zyHaP2Vi-ONkfc6F59DXtVDgdQ_EOFcWAURUPdJBfx4,15171
|
|
8
|
+
nsj_rest_lib2/compiler/compiler_structures.py,sha256=ZUeWnO-23f3JHq4bOfTcqszMDDXwuFEtMRhqMN7GeWQ,1214
|
|
9
|
+
nsj_rest_lib2/compiler/dto_compiler.py,sha256=KDdfzoghbsO0RpWAhuhZ4gsb11aoxgci-93dwxWNMuY,5400
|
|
10
|
+
nsj_rest_lib2/compiler/entity_compiler.py,sha256=7LypMMlgXnUIkpO7rEYtc2V1sKi9Nv1IxlXkgObX25s,4453
|
|
11
11
|
nsj_rest_lib2/compiler/model.py,sha256=QDBoM26qoZdiNcykl1nvXCrFDhg-6Q__QzVq6uY1QzE,1460
|
|
12
|
-
nsj_rest_lib2/compiler/property_compiler.py,sha256=
|
|
12
|
+
nsj_rest_lib2/compiler/property_compiler.py,sha256=EP-EnszasIKaCgz-_HzBliNA5L7cilixwnhrJD68iJI,35720
|
|
13
13
|
nsj_rest_lib2/compiler/edl_model/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
nsj_rest_lib2/compiler/edl_model/ai_entity_edl.py,sha256=664QBDcOgVnyfwtUOXO1W7AKaZhueBG335x5DuogruY,7644
|
|
15
15
|
nsj_rest_lib2/compiler/edl_model/api_model.py,sha256=pH0Uiq_64AGvkHqwY44TrulWWZXbi6M0EKJWUhSqKj0,837
|
|
16
16
|
nsj_rest_lib2/compiler/edl_model/column_meta_model.py,sha256=s0sEVkoW1hV2_hto1mws4XhzKGH_b4NzhaOiwFH25Ks,694
|
|
17
|
-
nsj_rest_lib2/compiler/edl_model/entity_model.py,sha256=
|
|
17
|
+
nsj_rest_lib2/compiler/edl_model/entity_model.py,sha256=tkx76ldDS5iFr3CbPi4mmq6y5F55LcgAhqCsrqfdzkc,936
|
|
18
|
+
nsj_rest_lib2/compiler/edl_model/entity_model_base.py,sha256=cUpbNUat7GJgJv14-8R2XYPc0vrcLXC6KPoVaXYZZ5A,3291
|
|
18
19
|
nsj_rest_lib2/compiler/edl_model/index_model.py,sha256=cXWlu0hxtro5vvYoirkDW4R3PCnBW5oCCWjRJ6AX5zE,508
|
|
19
|
-
nsj_rest_lib2/compiler/edl_model/primitives.py,sha256=
|
|
20
|
+
nsj_rest_lib2/compiler/edl_model/primitives.py,sha256=GTo8e1mf9munvl_J1-fmaXgSJ8yQvGX56f2rwS85M1Y,1459
|
|
20
21
|
nsj_rest_lib2/compiler/edl_model/property_meta_model.py,sha256=x2SApvI-5MZTErAHeOXnR6qfjflhSs8r6Y9KMtCykV0,3960
|
|
21
22
|
nsj_rest_lib2/compiler/edl_model/repository_model.py,sha256=Vt1HxlaoifP4w5ij1laKDkD1-COBihE8EX1HkdEDUSo,977
|
|
22
23
|
nsj_rest_lib2/compiler/edl_model/trait_property_meta_model.py,sha256=SBSfiu4v0PMsWRsGDySR3P2tkabLbDZxx_FFy_3rGXA,605
|
|
23
24
|
nsj_rest_lib2/compiler/util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
24
25
|
nsj_rest_lib2/compiler/util/str_util.py,sha256=lVP1yHhj1pOd6ULtTnkcfX6Gqrpe4yCBratHUhBNGcI,843
|
|
25
|
-
nsj_rest_lib2/compiler/util/type_naming_util.py,sha256=
|
|
26
|
+
nsj_rest_lib2/compiler/util/type_naming_util.py,sha256=wTfxPCezCTt-ltSg_hkaYNH7Z05k-mlJKZd-9AMA9ac,768
|
|
26
27
|
nsj_rest_lib2/compiler/util/type_util.py,sha256=HTKOH4uRTOY0YgoM8oUv_6cEcReE_bgKYXFBsQCb-3A,357
|
|
27
28
|
nsj_rest_lib2/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
28
29
|
nsj_rest_lib2/controller/dynamic_controller.py,sha256=XMqxe1NW-NE5XwomXb4pSNdALQHpP74Hc26R4fnmXqg,15194
|
|
29
30
|
nsj_rest_lib2/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
|
-
nsj_rest_lib2/service/entity_loader.py,sha256=
|
|
31
|
-
nsj_rest_lib2-0.0.
|
|
32
|
-
nsj_rest_lib2-0.0.
|
|
33
|
-
nsj_rest_lib2-0.0.
|
|
34
|
-
nsj_rest_lib2-0.0.
|
|
31
|
+
nsj_rest_lib2/service/entity_loader.py,sha256=cv34rNuSOOz4_l5ouW_X-IIDiRtEkN44Dn3quNBDZJE,15372
|
|
32
|
+
nsj_rest_lib2-0.0.14.dist-info/METADATA,sha256=aYvlmJGdy6qZxzyAij9JKvOYIBNawhmVY3SeX8kwkSE,1361
|
|
33
|
+
nsj_rest_lib2-0.0.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
34
|
+
nsj_rest_lib2-0.0.14.dist-info/top_level.txt,sha256=L6zh0EfH8_rur7OJ8_V-El-XEMf4qg3bkF8ADgqLVIA,14
|
|
35
|
+
nsj_rest_lib2-0.0.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|