nsj-rest-lib2 0.0.12__py3-none-any.whl → 0.0.13__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.
@@ -117,6 +117,7 @@ class EDLPropertyCompiler:
117
117
  entity_models,
118
118
  properties_structure,
119
119
  ast_dto_attributes,
120
+ ast_entity_attributes,
120
121
  related_imports,
121
122
  relations_dependencies,
122
123
  pkey,
@@ -353,6 +354,7 @@ class EDLPropertyCompiler:
353
354
  entity_models: dict[str, EntityModel],
354
355
  properties_structure: PropertiesCompilerStructure,
355
356
  ast_dto_attributes: list[ast.stmt],
357
+ ast_entity_attributes: list[ast.stmt],
356
358
  related_imports: list[tuple[str, str, str]],
357
359
  relations_dependencies: list[RelationDependency],
358
360
  pkey: str,
@@ -418,6 +420,7 @@ class EDLPropertyCompiler:
418
420
  self._build_ast_1_1(
419
421
  properties_structure,
420
422
  ast_dto_attributes,
423
+ ast_entity_attributes,
421
424
  pkey,
422
425
  related_dto_class_name,
423
426
  related_entity_class_name,
@@ -490,6 +493,7 @@ class EDLPropertyCompiler:
490
493
  self,
491
494
  properties_structure: PropertiesCompilerStructure,
492
495
  ast_dto_attributes: list[ast.stmt],
496
+ ast_entity_attributes: list[ast.stmt],
493
497
  pkey: str,
494
498
  related_dto_class_name: str,
495
499
  related_entity_class_name: str,
@@ -539,7 +543,18 @@ class EDLPropertyCompiler:
539
543
  ),
540
544
  )
541
545
  )
546
+ else:
547
+ # Adicionando propriedade, para o campo de relação, no DTO (quando for o dono da relação)
548
+ ast_dto_attributes.append(
549
+ self._build_dto_property_ast(relation_column, PrimitiveTypes.UUID)
550
+ )
551
+
552
+ # Adicionando propriedade, para o campo de relação, no Entity (quando for o dono da relação)
553
+ ast_entity_attributes.append(
554
+ self._build_entity_property_ast(relation_column, PrimitiveTypes.UUID)
555
+ )
542
556
 
557
+ # Adicionando a propriedade em si do relacionamento, no DTO
543
558
  ast_attr = ast.AnnAssign(
544
559
  target=ast.Name(id=CompilerStrUtil.to_snake_case(pkey), ctx=ast.Store()),
545
560
  annotation=ast.Name(
@@ -556,6 +571,52 @@ class EDLPropertyCompiler:
556
571
 
557
572
  ast_dto_attributes.append(ast_attr)
558
573
 
574
+ def _build_dto_property_ast(
575
+ self,
576
+ name: str,
577
+ type: PrimitiveTypes | str,
578
+ keywords: list[ast.keyword] = [],
579
+ ):
580
+ if isinstance(type, PrimitiveTypes):
581
+ type_str = TypeUtil.property_type_to_python_type(type)
582
+ else:
583
+ type_str = type
584
+
585
+ return ast.AnnAssign(
586
+ target=ast.Name(
587
+ id=CompilerStrUtil.to_snake_case(name),
588
+ ctx=ast.Store(),
589
+ ),
590
+ annotation=ast.Name(
591
+ id=type_str,
592
+ ctx=ast.Load(),
593
+ ),
594
+ value=ast.Call(
595
+ func=ast.Name(id="DTOField", ctx=ast.Load()),
596
+ args=[],
597
+ keywords=keywords,
598
+ ),
599
+ simple=1,
600
+ )
601
+
602
+ def _build_entity_property_ast(
603
+ self,
604
+ name: str,
605
+ type: PrimitiveTypes,
606
+ ):
607
+ return ast.AnnAssign(
608
+ target=ast.Name(
609
+ id=CompilerStrUtil.to_snake_case(name),
610
+ ctx=ast.Store(),
611
+ ),
612
+ annotation=ast.Name(
613
+ id=TypeUtil.property_type_to_python_type(type),
614
+ ctx=ast.Load(),
615
+ ),
616
+ value=ast.Constant(value=None),
617
+ simple=1,
618
+ )
619
+
559
620
  def _compile_simple_property(
560
621
  self,
561
622
  properties_structure,
@@ -766,35 +827,11 @@ class EDLPropertyCompiler:
766
827
  else:
767
828
  prop_type = TypeUtil.property_type_to_python_type(prop.type)
768
829
 
769
- ast_attr = ast.AnnAssign(
770
- target=ast.Name(id=CompilerStrUtil.to_snake_case(pkey), ctx=ast.Store()),
771
- annotation=ast.Name(
772
- id=prop_type,
773
- ctx=ast.Load(),
774
- ),
775
- value=ast.Call(
776
- func=ast.Name(id="DTOField", ctx=ast.Load()),
777
- args=[],
778
- keywords=keywords,
779
- ),
780
- simple=1,
781
- )
782
-
830
+ ast_attr = self._build_dto_property_ast(pkey, prop_type, keywords)
783
831
  ast_dto_attributes.append(ast_attr)
784
832
 
785
833
  # Entity
786
- ast_entity_attr = ast.AnnAssign(
787
- target=ast.Name(
788
- id=CompilerStrUtil.to_snake_case(entity_field_name),
789
- ctx=ast.Store(),
790
- ),
791
- annotation=ast.Name(
792
- id=TypeUtil.property_type_to_python_type(prop.type),
793
- ctx=ast.Load(),
794
- ),
795
- value=ast.Constant(value=None),
796
- simple=1,
797
- )
834
+ ast_entity_attr = self._build_entity_property_ast(entity_field_name, prop.type)
798
835
 
799
836
  ast_entity_attributes.append(ast_entity_attr)
800
837
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nsj_rest_lib2
3
- Version: 0.0.12
3
+ Version: 0.0.13
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
@@ -9,7 +9,7 @@ nsj_rest_lib2/compiler/compiler_structures.py,sha256=2bM4_7lG1fytDGxJl6SU9pLsbsp
9
9
  nsj_rest_lib2/compiler/dto_compiler.py,sha256=4e9_8EsNSHPCUEmiuEPdudj9_tFuw2O4ZTv6EYwJrGc,5333
10
10
  nsj_rest_lib2/compiler/entity_compiler.py,sha256=zLXO6USY4Rr0Hnk4wGep5K8DiHxJv-W-BBz_-g4OhCA,4307
11
11
  nsj_rest_lib2/compiler/model.py,sha256=QDBoM26qoZdiNcykl1nvXCrFDhg-6Q__QzVq6uY1QzE,1460
12
- nsj_rest_lib2/compiler/property_compiler.py,sha256=kr9Pi0kkIrvgEmxrmV_NEQuqekM1h6-jqvF85nZTUcY,29808
12
+ nsj_rest_lib2/compiler/property_compiler.py,sha256=AvJYY5vbmlodGjgyuCx6u17x0Qv3nEsAdMmBcSQP2f4,31153
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
@@ -28,7 +28,7 @@ nsj_rest_lib2/controller/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
28
28
  nsj_rest_lib2/controller/dynamic_controller.py,sha256=XMqxe1NW-NE5XwomXb4pSNdALQHpP74Hc26R4fnmXqg,15194
29
29
  nsj_rest_lib2/service/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
30
30
  nsj_rest_lib2/service/entity_loader.py,sha256=KVLFQSqj4DL-K-T29ksJE2or9QkekFmyAGUIKjQX6Qk,15372
31
- nsj_rest_lib2-0.0.12.dist-info/METADATA,sha256=CTk1vS9FJ_U2e6-Vz38wj3Ba2efwuKPW-iDpHlosHzk,1361
32
- nsj_rest_lib2-0.0.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
- nsj_rest_lib2-0.0.12.dist-info/top_level.txt,sha256=L6zh0EfH8_rur7OJ8_V-El-XEMf4qg3bkF8ADgqLVIA,14
34
- nsj_rest_lib2-0.0.12.dist-info/RECORD,,
31
+ nsj_rest_lib2-0.0.13.dist-info/METADATA,sha256=mR2ZDZ5jbP18qsS288vSwD0tWDPOhibp_iyP-CrQ0Hk,1361
32
+ nsj_rest_lib2-0.0.13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
33
+ nsj_rest_lib2-0.0.13.dist-info/top_level.txt,sha256=L6zh0EfH8_rur7OJ8_V-El-XEMf4qg3bkF8ADgqLVIA,14
34
+ nsj_rest_lib2-0.0.13.dist-info/RECORD,,