nsj-rest-lib2 0.0.35__py3-none-any.whl → 0.0.37__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 +111 -3
- nsj_rest_lib2/compiler/dto_compiler.py +5 -1
- nsj_rest_lib2/compiler/edl_model/api_model.py +18 -6
- nsj_rest_lib2/compiler/model.py +12 -0
- nsj_rest_lib2/compiler/response_dto_compiler.py +104 -0
- nsj_rest_lib2/compiler/util/type_naming_util.py +83 -1
- nsj_rest_lib2/controller/dynamic_controller.py +87 -5
- nsj_rest_lib2/service/entity_config_writer.py +19 -44
- nsj_rest_lib2/service/entity_loader.py +421 -70
- nsj_rest_lib2/settings.py +10 -0
- nsj_rest_lib2-0.0.37.dist-info/METADATA +203 -0
- {nsj_rest_lib2-0.0.35.dist-info → nsj_rest_lib2-0.0.37.dist-info}/RECORD +14 -13
- nsj_rest_lib2-0.0.35.dist-info/METADATA +0 -27
- {nsj_rest_lib2-0.0.35.dist-info → nsj_rest_lib2-0.0.37.dist-info}/WHEEL +0 -0
- {nsj_rest_lib2-0.0.35.dist-info → nsj_rest_lib2-0.0.37.dist-info}/top_level.txt +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import hashlib
|
|
4
3
|
import json
|
|
5
|
-
from typing import Any, Dict
|
|
4
|
+
from typing import Any, Dict
|
|
6
5
|
|
|
7
6
|
from nsj_rest_lib2.compiler.edl_model.entity_model import EntityModel
|
|
8
7
|
from nsj_rest_lib2.compiler.edl_model.entity_model_base import EntityModelBase
|
|
9
8
|
from nsj_rest_lib2.compiler.model import CompilerResult
|
|
10
|
-
from nsj_rest_lib2.compiler.util.type_naming_util import
|
|
9
|
+
from nsj_rest_lib2.compiler.util.type_naming_util import (
|
|
10
|
+
build_entity_hash,
|
|
11
|
+
resolve_namespace_key,
|
|
12
|
+
)
|
|
11
13
|
from nsj_rest_lib2.redis_config import set_redis
|
|
12
14
|
from nsj_rest_lib2.settings import ESCOPO_RESTLIB2
|
|
13
15
|
|
|
@@ -86,6 +88,18 @@ class EntityConfigWriter:
|
|
|
86
88
|
"source_get_function_type": compiler_result.source_get_function_type,
|
|
87
89
|
"source_list_function_type": compiler_result.source_list_function_type,
|
|
88
90
|
"source_delete_function_type": compiler_result.source_delete_function_type,
|
|
91
|
+
"retrieve_after_insert": compiler_result.retrieve_after_insert,
|
|
92
|
+
"retrieve_after_update": compiler_result.retrieve_after_update,
|
|
93
|
+
"retrieve_after_partial_update": compiler_result.retrieve_after_partial_update,
|
|
94
|
+
"post_response_dto_class_name": compiler_result.post_response_dto_class_name,
|
|
95
|
+
"put_response_dto_class_name": compiler_result.put_response_dto_class_name,
|
|
96
|
+
"patch_response_dto_class_name": compiler_result.patch_response_dto_class_name,
|
|
97
|
+
"custom_json_post_response": compiler_result.custom_json_post_response,
|
|
98
|
+
"custom_json_put_response": compiler_result.custom_json_put_response,
|
|
99
|
+
"custom_json_patch_response": compiler_result.custom_json_patch_response,
|
|
100
|
+
"custom_json_get_response": compiler_result.custom_json_get_response,
|
|
101
|
+
"custom_json_list_response": compiler_result.custom_json_list_response,
|
|
102
|
+
"custom_json_delete_response": compiler_result.custom_json_delete_response,
|
|
89
103
|
"source_dto": compiler_result.dto_code,
|
|
90
104
|
"source_entity": compiler_result.entity_code,
|
|
91
105
|
"entity_hash": entity_hash
|
|
@@ -101,21 +115,7 @@ class EntityConfigWriter:
|
|
|
101
115
|
tenant = getattr(entity_model, "tenant", None)
|
|
102
116
|
grupo_empresarial = getattr(entity_model, "grupo_empresarial", None)
|
|
103
117
|
|
|
104
|
-
|
|
105
|
-
tenant,
|
|
106
|
-
grupo_empresarial,
|
|
107
|
-
)
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
tenant
|
|
111
|
-
and tenant != 0
|
|
112
|
-
and grupo_empresarial
|
|
113
|
-
and str(grupo_empresarial) != "00000000-0000-0000-0000-000000000000"
|
|
114
|
-
):
|
|
115
|
-
return grupo_key
|
|
116
|
-
if tenant and tenant != 0:
|
|
117
|
-
return tenant_key
|
|
118
|
-
return default_key
|
|
118
|
+
return resolve_namespace_key(tenant, grupo_empresarial)
|
|
119
119
|
|
|
120
120
|
def _resolve_resource(self, entity_model: EntityModelBase) -> str:
|
|
121
121
|
if not isinstance(entity_model, EntityModel) or not entity_model.api:
|
|
@@ -127,29 +127,4 @@ class EntityConfigWriter:
|
|
|
127
127
|
return entity_model.api.resource
|
|
128
128
|
|
|
129
129
|
def _build_entity_hash(self, compiler_result: CompilerResult) -> str:
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
for content in self._iter_hash_chunks(
|
|
133
|
-
compiler_result.dto_code,
|
|
134
|
-
compiler_result.entity_code,
|
|
135
|
-
compiler_result.insert_function_name,
|
|
136
|
-
compiler_result.update_function_name,
|
|
137
|
-
compiler_result.get_function_name,
|
|
138
|
-
compiler_result.list_function_name,
|
|
139
|
-
compiler_result.delete_function_name,
|
|
140
|
-
compiler_result.source_insert_function,
|
|
141
|
-
compiler_result.source_update_function,
|
|
142
|
-
compiler_result.source_get_function_type,
|
|
143
|
-
compiler_result.source_list_function_type,
|
|
144
|
-
compiler_result.source_delete_function_type,
|
|
145
|
-
compiler_result.service_account,
|
|
146
|
-
):
|
|
147
|
-
hasher.update(content)
|
|
148
|
-
|
|
149
|
-
return hasher.hexdigest()
|
|
150
|
-
|
|
151
|
-
@staticmethod
|
|
152
|
-
def _iter_hash_chunks(*chunks: Optional[str]) -> Iterator[bytes]:
|
|
153
|
-
for chunk in chunks:
|
|
154
|
-
if chunk:
|
|
155
|
-
yield chunk.encode("utf-8")
|
|
130
|
+
return build_entity_hash(compiler_result)
|