nsj-rest-lib2 0.0.22__tar.gz → 0.0.24__tar.gz

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.
Files changed (41) hide show
  1. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/PKG-INFO +1 -1
  2. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/property_compiler.py +49 -230
  3. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/controller/dynamic_controller.py +47 -8
  4. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/service/entity_loader.py +4 -0
  5. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2.egg-info/PKG-INFO +1 -1
  6. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/setup.cfg +1 -1
  7. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/README.md +0 -0
  8. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/__init__.py +0 -0
  9. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/__init__.py +0 -0
  10. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/ai_compiler.py +0 -0
  11. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/compiler.py +0 -0
  12. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/compiler_structures.py +0 -0
  13. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/dto_compiler.py +0 -0
  14. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/__init__.py +0 -0
  15. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/ai_entity_edl.py +0 -0
  16. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/api_model.py +0 -0
  17. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/column_meta_model.py +0 -0
  18. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/entity_model.py +0 -0
  19. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/entity_model_base.py +0 -0
  20. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/entity_model_root.py +0 -0
  21. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/index_model.py +0 -0
  22. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/primitives.py +0 -0
  23. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/property_meta_model.py +0 -0
  24. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/repository_model.py +0 -0
  25. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/edl_model/trait_property_meta_model.py +0 -0
  26. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/entity_compiler.py +0 -0
  27. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/model.py +0 -0
  28. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/util/__init__.py +0 -0
  29. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/util/str_util.py +0 -0
  30. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/util/type_naming_util.py +0 -0
  31. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/compiler/util/type_util.py +0 -0
  32. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/controller/__init__.py +0 -0
  33. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/exception.py +0 -0
  34. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/redis_config.py +0 -0
  35. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/service/__init__.py +0 -0
  36. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2/settings.py +0 -0
  37. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2.egg-info/SOURCES.txt +0 -0
  38. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2.egg-info/dependency_links.txt +0 -0
  39. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2.egg-info/requires.txt +0 -0
  40. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/nsj_rest_lib2.egg-info/top_level.txt +0 -0
  41. {nsj_rest_lib2-0.0.22 → nsj_rest_lib2-0.0.24}/pyproject.toml +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nsj_rest_lib2
3
- Version: 0.0.22
3
+ Version: 0.0.24
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
@@ -88,6 +88,10 @@ class EDLPropertyCompiler:
88
88
  if properties_structure.properties is None:
89
89
  return (ast_dto_attributes, ast_entity_attributes, props_pk, aux_classes)
90
90
 
91
+ trait_fixed_filters = self._merge_trait_extends_properties(
92
+ properties_structure
93
+ )
94
+
91
95
  composed_properties = properties_structure.composed_properties or {}
92
96
 
93
97
  aggregator_class_names: dict[str, str] = {}
@@ -151,6 +155,9 @@ class EDLPropertyCompiler:
151
155
  prefx_class_name,
152
156
  )
153
157
 
158
+ if pkey in trait_fixed_filters:
159
+ fixed_filters.append((pkey, trait_fixed_filters[pkey]))
160
+
154
161
  elif isinstance(prop.type, str):
155
162
  # Tratando propriedade de relacionamento
156
163
  external_match = re.match(REGEX_EXTERNAL_REF, prop.type)
@@ -193,40 +200,6 @@ class EDLPropertyCompiler:
193
200
  f"Tipo da propriedade '{pkey}' não suportado: {prop.type}"
194
201
  )
195
202
 
196
- for pkey in properties_structure.trait_properties:
197
- prop = properties_structure.trait_properties[pkey]
198
-
199
- self._compile_trait_extends_property(
200
- properties_structure,
201
- map_unique_by_property,
202
- pkey,
203
- prop,
204
- ast_dto_attributes,
205
- ast_entity_attributes,
206
- fixed_filters,
207
- escopo,
208
- entity_model,
209
- aux_classes,
210
- prefx_class_name,
211
- )
212
-
213
- for pkey in properties_structure.extends_properties:
214
- prop = properties_structure.extends_properties[pkey]
215
-
216
- self._compile_trait_extends_property(
217
- properties_structure,
218
- map_unique_by_property,
219
- pkey,
220
- prop,
221
- ast_dto_attributes,
222
- ast_entity_attributes,
223
- fixed_filters,
224
- escopo,
225
- entity_model,
226
- aux_classes,
227
- prefx_class_name,
228
- )
229
-
230
203
  for composed_key, class_name in aggregator_class_names.items():
231
204
  dto_attributes = aggregator_dto_attributes.get(composed_key, [])
232
205
 
@@ -254,199 +227,6 @@ class EDLPropertyCompiler:
254
227
  fixed_filters,
255
228
  )
256
229
 
257
- def _compile_trait_extends_property(
258
- self,
259
- properties_structure: PropertiesCompilerStructure,
260
- map_unique_by_property: dict[str, IndexCompilerStructure],
261
- pkey: str,
262
- prop: TraitPropertyMetaModel,
263
- ast_dto_attributes: list[ast.stmt],
264
- ast_entity_attributes: list[ast.stmt],
265
- fixed_filters: list[tuple[str, BasicTypes]],
266
- escopo: str,
267
- entity_model: EntityModelBase,
268
- aux_classes: list[ast.stmt],
269
- prefx_class_name: str,
270
- ):
271
- enum_class_name = None
272
- keywords = []
273
-
274
- if (
275
- properties_structure.main_properties
276
- and pkey in properties_structure.main_properties
277
- ):
278
- keywords.append(ast.keyword(arg="resume", value=ast.Constant(True)))
279
-
280
- if properties_structure.required and pkey in properties_structure.required:
281
- keywords.append(ast.keyword(arg="not_null", value=ast.Constant(True)))
282
-
283
- if (
284
- properties_structure.partition_data
285
- and pkey in properties_structure.partition_data
286
- ):
287
- keywords.append(ast.keyword(arg="partition_data", value=ast.Constant(True)))
288
-
289
- if pkey in map_unique_by_property:
290
- unique = map_unique_by_property[pkey].index_model
291
- keywords.append(
292
- ast.keyword(
293
- arg="unique",
294
- value=ast.Constant(unique.name),
295
- )
296
- )
297
-
298
- if (
299
- properties_structure.search_properties
300
- and pkey in properties_structure.search_properties
301
- ):
302
- keywords.append(ast.keyword(arg="search", value=ast.Constant(True)))
303
- else:
304
- keywords.append(ast.keyword(arg="search", value=ast.Constant(False)))
305
-
306
- if (
307
- properties_structure.metric_label
308
- and pkey in properties_structure.metric_label
309
- ):
310
- keywords.append(ast.keyword(arg="metric_label", value=ast.Constant(True)))
311
-
312
- if prop.type == PrimitiveTypes.CPF:
313
- keywords.append(
314
- ast.keyword(
315
- arg="validator",
316
- value=ast.Attribute(
317
- value=ast.Call(
318
- func=ast.Name(id="DTOFieldValidators", ctx=ast.Load()),
319
- args=[],
320
- keywords=[],
321
- ),
322
- attr="validate_cpf",
323
- ctx=ast.Load(),
324
- ),
325
- )
326
- )
327
- elif prop.type == PrimitiveTypes.CNPJ:
328
- keywords.append(
329
- ast.keyword(
330
- arg="validator",
331
- value=ast.Attribute(
332
- value=ast.Call(
333
- func=ast.Name(id="DTOFieldValidators", ctx=ast.Load()),
334
- args=[],
335
- keywords=[],
336
- ),
337
- attr="validate_cnpj",
338
- ctx=ast.Load(),
339
- ),
340
- )
341
- )
342
- elif prop.type == PrimitiveTypes.CPF_CNPJ:
343
- keywords.append(
344
- ast.keyword(
345
- arg="validator",
346
- value=ast.Attribute(
347
- value=ast.Call(
348
- func=ast.Name(id="DTOFieldValidators", ctx=ast.Load()),
349
- args=[],
350
- keywords=[],
351
- ),
352
- attr="validate_cpf_or_cnpj",
353
- ctx=ast.Load(),
354
- ),
355
- )
356
- )
357
- elif prop.type == PrimitiveTypes.EMAIL:
358
- keywords.append(
359
- ast.keyword(
360
- arg="validator",
361
- value=ast.Attribute(
362
- value=ast.Call(
363
- func=ast.Name(id="DTOFieldValidators", ctx=ast.Load()),
364
- args=[],
365
- keywords=[],
366
- ),
367
- attr="validate_email",
368
- ctx=ast.Load(),
369
- ),
370
- )
371
- )
372
-
373
- # Trtando de uma definição de enum
374
- if prop.domain_config:
375
- result = self._compile_domain_config(
376
- pkey, prop, escopo, entity_model, prefx_class_name
377
- )
378
- if not result:
379
- raise Exception(f"Erro desconhecido ao compilar a propriedade {pkey}")
380
-
381
- enum_class_name, ast_enum_class = result
382
- aux_classes.append(ast_enum_class)
383
-
384
- # Resolvendo o nome da propriedade no Entity
385
- if (
386
- properties_structure.entity_properties
387
- and pkey in properties_structure.entity_properties
388
- ):
389
- entity_field_name = properties_structure.entity_properties[pkey].column
390
- else:
391
- entity_field_name = pkey
392
-
393
- # Escrevendo, se necessário, o alias para o nome da entity
394
- if entity_field_name != pkey:
395
- keywords.append(
396
- ast.keyword(
397
- arg="entity_field",
398
- value=ast.Constant(value=entity_field_name),
399
- )
400
- )
401
-
402
- # Instanciando o atributo AST
403
- if not isinstance(prop.type, PrimitiveTypes):
404
- raise Exception(
405
- f"Tipo da trait_property '{pkey}' não suportado: {prop.type} (deveria ser um Tipo Primitivo)"
406
- )
407
-
408
- # Instanciando o atributo AST
409
- if enum_class_name:
410
- prop_type = enum_class_name
411
- else:
412
- prop_type = TypeUtil.property_type_to_python_type(prop.type)
413
-
414
- ast_attr = ast.AnnAssign(
415
- target=ast.Name(id=CompilerStrUtil.to_snake_case(pkey), ctx=ast.Store()),
416
- annotation=ast.Name(
417
- id=prop_type,
418
- ctx=ast.Load(),
419
- ),
420
- value=ast.Call(
421
- func=ast.Name(id="DTOField", ctx=ast.Load()),
422
- args=[],
423
- keywords=keywords,
424
- ),
425
- simple=1,
426
- )
427
-
428
- ast_dto_attributes.append(ast_attr)
429
-
430
- # Entity
431
- ast_entity_attr = ast.AnnAssign(
432
- target=ast.Name(
433
- id=CompilerStrUtil.to_snake_case(entity_field_name),
434
- ctx=ast.Store(),
435
- ),
436
- annotation=ast.Name(
437
- id=TypeUtil.property_type_to_python_type(prop.type),
438
- ctx=ast.Load(),
439
- ),
440
- value=ast.Constant(value=None),
441
- simple=1,
442
- )
443
-
444
- ast_entity_attributes.append(ast_entity_attr)
445
-
446
- # Guardando como um fixed_filter
447
- # TODO Pensar em validações para esse value (se está de acordo com o tipo ou enum)
448
- fixed_filters.append((pkey, prop.value))
449
-
450
230
  def _build_aggregator_class_ast(
451
231
  self,
452
232
  class_name: str,
@@ -1165,6 +945,47 @@ class EDLPropertyCompiler:
1165
945
  ctx=ast.Load(),
1166
946
  )
1167
947
 
948
+ def _merge_trait_extends_properties(
949
+ self, properties_structure: PropertiesCompilerStructure
950
+ ) -> dict[str, BasicTypes]:
951
+ fixed_filters: dict[str, BasicTypes] = {}
952
+
953
+ trait_sources = (
954
+ properties_structure.trait_properties or {},
955
+ properties_structure.extends_properties or {},
956
+ )
957
+
958
+ for prop_dict in trait_sources:
959
+ for pkey, tprop in prop_dict.items():
960
+ if not isinstance(tprop.type, PrimitiveTypes):
961
+ raise ValueError(
962
+ f"Propriedade '{pkey}' definida em trait/extends precisa ser um tipo primitivo."
963
+ )
964
+
965
+ base_prop = properties_structure.properties.get(pkey)
966
+
967
+ if base_prop:
968
+ if base_prop.type != tprop.type:
969
+ raise ValueError(
970
+ f"Tipo da propriedade '{pkey}' em trait/extends não coincide com a definição existente."
971
+ )
972
+
973
+ base_prop.default = tprop.value
974
+
975
+ if tprop.domain_config and not base_prop.domain_config:
976
+ base_prop.domain_config = tprop.domain_config
977
+ else:
978
+ base_prop = PropertyMetaModel(
979
+ type=tprop.type,
980
+ default=tprop.value,
981
+ domain_config=tprop.domain_config,
982
+ )
983
+ properties_structure.properties[pkey] = base_prop
984
+
985
+ fixed_filters[pkey] = tprop.value
986
+
987
+ return fixed_filters
988
+
1168
989
  def _build_primitive_default_value_ast(
1169
990
  self,
1170
991
  pkey: str,
@@ -1249,9 +1070,7 @@ class EDLPropertyCompiler:
1249
1070
  )
1250
1071
 
1251
1072
  value_to_convert = (
1252
- default_value.strip()
1253
- if isinstance(default_value, str)
1254
- else default_value
1073
+ default_value.strip() if isinstance(default_value, str) else default_value
1255
1074
  )
1256
1075
 
1257
1076
  if forbid_fraction and isinstance(value_to_convert, float):
@@ -53,10 +53,19 @@ def setup_dynamic_routes(
53
53
  multidb: bool = True,
54
54
  dynamic_root_path: str = "edl1",
55
55
  injector_factory: Any = None,
56
+ escopo_in_url: bool = False,
56
57
  ) -> None:
57
58
 
58
- COLLECTION_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>"
59
- ONE_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>/<id>"
59
+ if not escopo_in_url:
60
+ COLLECTION_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>"
61
+ ONE_DYNAMIC_ROUTE = f"/{APP_NAME}/{dynamic_root_path}/<entity_resource>/<id>"
62
+ else:
63
+ COLLECTION_DYNAMIC_ROUTE = (
64
+ f"/{APP_NAME}/{dynamic_root_path}/<entity_escopo>/<entity_resource>"
65
+ )
66
+ ONE_DYNAMIC_ROUTE = (
67
+ f"/{APP_NAME}/{dynamic_root_path}/<entity_escopo>/<entity_resource>/<id>"
68
+ )
60
69
 
61
70
  def list_dynamic_wrapper(injector_factory: Any, *args: Any, **kwargs: Any) -> Any:
62
71
 
@@ -67,6 +76,11 @@ def setup_dynamic_routes(
67
76
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
68
77
  entity_resource = kwargs.pop("entity_resource")
69
78
 
79
+ # Verificando se o identificador do escopo foi passado na URL
80
+ entity_escopo = ""
81
+ if "entity_escopo" in kwargs:
82
+ entity_escopo = kwargs.pop("entity_escopo")
83
+
70
84
  # Lendo tenant e grupo_empresarial
71
85
  tenant, grupo_empresarial = _get_tenant_grupo()
72
86
 
@@ -80,7 +94,7 @@ def setup_dynamic_routes(
80
94
  api_expose,
81
95
  api_verbs,
82
96
  ) = entity_loader.load_entity_source(
83
- entity_resource, tenant, grupo_empresarial
97
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
84
98
  )
85
99
 
86
100
  # Verificando se essa API deve ser exposta
@@ -112,6 +126,11 @@ def setup_dynamic_routes(
112
126
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
113
127
  entity_resource = kwargs.pop("entity_resource")
114
128
 
129
+ # Verificando se o identificador do escopo foi passado na URL
130
+ entity_escopo = ""
131
+ if "entity_escopo" in kwargs:
132
+ entity_escopo = kwargs.pop("entity_escopo")
133
+
115
134
  # Lendo tenant e grupo_empresarial
116
135
  tenant, grupo_empresarial = _get_tenant_grupo()
117
136
 
@@ -125,7 +144,7 @@ def setup_dynamic_routes(
125
144
  api_expose,
126
145
  api_verbs,
127
146
  ) = entity_loader.load_entity_source(
128
- entity_resource, tenant, grupo_empresarial
147
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
129
148
  )
130
149
 
131
150
  # Verificando se essa API deve ser exposta
@@ -156,6 +175,11 @@ def setup_dynamic_routes(
156
175
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
157
176
  entity_resource = kwargs.pop("entity_resource")
158
177
 
178
+ # Verificando se o identificador do escopo foi passado na URL
179
+ entity_escopo = ""
180
+ if "entity_escopo" in kwargs:
181
+ entity_escopo = kwargs.pop("entity_escopo")
182
+
159
183
  # Lendo tenant e grupo_empresarial
160
184
  tenant, grupo_empresarial = _get_tenant_grupo()
161
185
 
@@ -169,7 +193,7 @@ def setup_dynamic_routes(
169
193
  api_expose,
170
194
  api_verbs,
171
195
  ) = entity_loader.load_entity_source(
172
- entity_resource, tenant, grupo_empresarial
196
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
173
197
  )
174
198
 
175
199
  # Verificando se essa API deve ser exposta
@@ -200,6 +224,11 @@ def setup_dynamic_routes(
200
224
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
201
225
  entity_resource = kwargs.pop("entity_resource")
202
226
 
227
+ # Verificando se o identificador do escopo foi passado na URL
228
+ entity_escopo = ""
229
+ if "entity_escopo" in kwargs:
230
+ entity_escopo = kwargs.pop("entity_escopo")
231
+
203
232
  # Lendo tenant e grupo_empresarial
204
233
  tenant, grupo_empresarial = _get_tenant_grupo()
205
234
 
@@ -213,7 +242,7 @@ def setup_dynamic_routes(
213
242
  api_expose,
214
243
  api_verbs,
215
244
  ) = entity_loader.load_entity_source(
216
- entity_resource, tenant, grupo_empresarial
245
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
217
246
  )
218
247
 
219
248
  # Verificando se essa API deve ser exposta
@@ -244,6 +273,11 @@ def setup_dynamic_routes(
244
273
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
245
274
  entity_resource = kwargs.pop("entity_resource")
246
275
 
276
+ # Verificando se o identificador do escopo foi passado na URL
277
+ entity_escopo = ""
278
+ if "entity_escopo" in kwargs:
279
+ entity_escopo = kwargs.pop("entity_escopo")
280
+
247
281
  # Lendo tenant e grupo_empresarial
248
282
  tenant, grupo_empresarial = _get_tenant_grupo()
249
283
 
@@ -257,7 +291,7 @@ def setup_dynamic_routes(
257
291
  api_expose,
258
292
  api_verbs,
259
293
  ) = entity_loader.load_entity_source(
260
- entity_resource, tenant, grupo_empresarial
294
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
261
295
  )
262
296
 
263
297
  # Verificando se essa API deve ser exposta
@@ -288,6 +322,11 @@ def setup_dynamic_routes(
288
322
  return (format_json_error(msg), 400, {**DEFAULT_RESP_HEADERS})
289
323
  entity_resource = kwargs.pop("entity_resource")
290
324
 
325
+ # Verificando se o identificador do escopo foi passado na URL
326
+ entity_escopo = ""
327
+ if "entity_escopo" in kwargs:
328
+ entity_escopo = kwargs.pop("entity_escopo")
329
+
291
330
  # Lendo tenant e grupo_empresarial
292
331
  tenant, grupo_empresarial = _get_tenant_grupo()
293
332
 
@@ -301,7 +340,7 @@ def setup_dynamic_routes(
301
340
  api_expose,
302
341
  api_verbs,
303
342
  ) = entity_loader.load_entity_source(
304
- entity_resource, tenant, grupo_empresarial
343
+ entity_resource, tenant, grupo_empresarial, escopo=entity_escopo
305
344
  )
306
345
 
307
346
  # Verificando se essa API deve ser exposta
@@ -48,6 +48,10 @@ class EntityLoader:
48
48
  grupo_empresarial: str | None,
49
49
  escopo: str = ESCOPO_RESTLIB2,
50
50
  ) -> tuple[str, str, dict, bool, list[str]]:
51
+ # Assumind o escopo default se necessário
52
+ if not escopo:
53
+ escopo = ESCOPO_RESTLIB2
54
+
51
55
  # Montando as chaves dos namespaces
52
56
  grupo_key, tenant_key, default_key = compile_namespace_keys(
53
57
  tenant, grupo_empresarial
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nsj_rest_lib2
3
- Version: 0.0.22
3
+ Version: 0.0.24
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
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = nsj_rest_lib2
3
- version = 0.0.22
3
+ version = 0.0.24
4
4
  author = Nasajon Sistemas
5
5
  author_email = contact.dev@nasajon.com.br
6
6
  description = Biblioteca para permitir a distribuição de rotas dinâmicas numa API, configuradas por meio de EDLs declarativos (em formato JSON).
File without changes