remove ducjdb extension from postgres
This commit is contained in:
parent
3bcec2abff
commit
980da5a085
|
|
@ -83,18 +83,14 @@ class RedisCategoryPageInfoKeysAction:
|
|||
page_index: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||
)
|
||||
|
||||
page_mapper_key: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_URL}"
|
||||
)
|
||||
page_mapper_key: str = (
|
||||
f"{page_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_LANGUAGE}"
|
||||
page_mapper_key_language: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}:{RedisCategoryPageInfoKeys.PAGE_LANGUAGE}"
|
||||
)
|
||||
menu_mapper_key: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_URL}:{RedisCategoryPageInfoKeys.PAGE_MENU_INDEX}"
|
||||
)
|
||||
menu_mapper_key: str = (
|
||||
f"{menu_mapper_key}:{RedisCategoryPageInfoKeys.PAGE_MENU_COMPONENT}"
|
||||
menu_mapper_key_component: str = (
|
||||
f"{RedisCategoryPageInfoKeys.PAGE_URL}:{RedisCategoryPageInfoKeys.PAGE_MENU_COMPONENT}"
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@ from Events.Engine.abstract_class import PageInfo
|
|||
authentication_page_info = PageInfo(
|
||||
name="Authentication",
|
||||
url="",
|
||||
language_models={},
|
||||
endpoints={},
|
||||
icon="Authentication",
|
||||
language_models=None,
|
||||
endpoints=None,
|
||||
info=None,
|
||||
instructions=None,
|
||||
sub_components=[],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ class KeyValidations:
|
|||
data = "data"
|
||||
validation = "validations"
|
||||
|
||||
# Keys for Validation TYPES
|
||||
class KeyTypeValidations:
|
||||
HEADERS = "HEADERS"
|
||||
DATA = "DATA"
|
||||
MODIFY = "MODIFY"
|
||||
VALIDATION = "VALIDATION"
|
||||
BOTH = "BOTH"
|
||||
|
||||
# Types of keys
|
||||
class KeyTypes:
|
||||
REQUEST = "REQUEST"
|
||||
|
|
@ -37,16 +45,17 @@ class KeyURLs:
|
|||
|
||||
# "data": {"event_code": f"{KeyBases.list_key}", "asked_field": KeyValidations.headers, "type": KeyTypes.RESPONSE},
|
||||
class ValidationRequest:
|
||||
event_code: str
|
||||
asked_field: str
|
||||
type: Optional[str] = "REQUEST"
|
||||
|
||||
@classmethod
|
||||
def dump(cls) -> Dict[str, Any]:
|
||||
def __init__(self, event_code: str, asked_field: str, type_: Optional[str] = "REQUEST"):
|
||||
self.event_code = event_code
|
||||
self.asked_field = asked_field
|
||||
self.type = type_
|
||||
|
||||
def dump(self) -> Dict[str, Any]:
|
||||
return {
|
||||
"event_code": cls.event_code,
|
||||
"asked_field": cls.asked_field,
|
||||
"type": cls.type,
|
||||
"event_code": self.event_code,
|
||||
"asked_field": self.asked_field,
|
||||
"type": self.type,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ AccountCluster = CategoryCluster(
|
|||
},
|
||||
mapping=page_2_keys,
|
||||
include_in_schema=True,
|
||||
template_ui="LCU",
|
||||
sub_category=[],
|
||||
is_client=True,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
from Events.Engine.abstract_class import PageInfo
|
||||
from .bases import Components, KeyTypes, ValidationRequest, icon, cluster_name
|
||||
from .bases import KeyValidations, KeyBases, PageBases, KeyURLs
|
||||
from Events.base_request_model import AUTH_URL_EXTENSION, EVENTS_URL_EXTENSION, VALID_URL_EXTENSION
|
||||
from .account_records import (
|
||||
AccountRecordsUpdateEventMethods,
|
||||
AccountRecordsCreateEventMethods,
|
||||
AccountRecordsListEventMethods,
|
||||
)
|
||||
from .bases import Components, KeyTypeValidations, KeyTypes, ValidationRequest, icon, cluster_name
|
||||
from .bases import KeyValidations, KeyBases, PageBases, KeyURLs
|
||||
from .lang_models import (
|
||||
account_language_list_models_as_dict,
|
||||
account_language_create_form_models_as_dict,
|
||||
|
|
@ -84,10 +85,11 @@ RedisValidation = dict(
|
|||
class ClustersPageInfo:
|
||||
|
||||
# Cluster Page Infos that are available for the client
|
||||
dashboard_page_info = PageInfo(
|
||||
DASHBOARD = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.DASHBOARD,
|
||||
icon=icon,
|
||||
template_ui="LCU",
|
||||
info={
|
||||
"en": {
|
||||
"page": "Account Records for reaching user all types account information",
|
||||
|
|
@ -124,18 +126,18 @@ class ClustersPageInfo:
|
|||
"ENDPOINTS": AccountRecordsListEventMethods.retrieve_all_event_keys(),
|
||||
"LANGUAGE_MODELS": account_language_list_models_as_dict,
|
||||
"INSTRUCTIONS": {
|
||||
"HEADERS": {
|
||||
KeyTypeValidations.HEADERS: {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||||
"data": ValidationRequest(
|
||||
event_code=f"{KeyBases.list_key}",
|
||||
asked_field=KeyValidations.headers,
|
||||
type=KeyTypes.RESPONSE
|
||||
type_=KeyTypes.RESPONSE
|
||||
).dump(),
|
||||
},
|
||||
"DATA": {
|
||||
KeyTypeValidations.DATA: {
|
||||
"store": True,
|
||||
"url": f"{KeyBases.list_key}",
|
||||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.list_key}",
|
||||
"params": None,
|
||||
"data": dict(page=1, limit=1, order_by="uu_id", order_type="desc", query=None),
|
||||
},
|
||||
|
|
@ -144,10 +146,11 @@ class ClustersPageInfo:
|
|||
},
|
||||
)
|
||||
|
||||
create_page_info = PageInfo(
|
||||
CREATE = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.CREATE,
|
||||
icon=icon,
|
||||
template_ui="LCU",
|
||||
info={
|
||||
"en": {
|
||||
"page": "Create Account Records for reaching user all types account information",
|
||||
|
|
@ -168,33 +171,40 @@ class ClustersPageInfo:
|
|||
"ENDPOINTS": AccountRecordsCreateEventMethods.retrieve_all_event_keys(),
|
||||
"LANGUAGE_MODELS": account_language_create_form_models_as_dict,
|
||||
"INSTRUCTIONS": {
|
||||
"VALIDATION": {
|
||||
KeyTypeValidations.VALIDATION: {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||||
"data": ValidationRequest(
|
||||
event_code=f"{KeyBases.create_key}",
|
||||
asked_field=KeyValidations.validation,
|
||||
type=KeyTypes.REQUEST
|
||||
type_=KeyTypes.REQUEST
|
||||
).dump(),
|
||||
},
|
||||
"HEADERS": {
|
||||
KeyTypeValidations.HEADERS: {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||||
"data": ValidationRequest(
|
||||
event_code=f"{KeyBases.create_key}",
|
||||
asked_field=KeyValidations.headers,
|
||||
type=KeyTypes.REQUEST
|
||||
type_=KeyTypes.REQUEST
|
||||
).dump(),
|
||||
},
|
||||
KeyTypeValidations.MODIFY: {
|
||||
"store": False,
|
||||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.create_key}",
|
||||
"params": None,
|
||||
"data": None,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
)
|
||||
|
||||
update_page_info = PageInfo(
|
||||
UPDATE = PageInfo(
|
||||
name=f"{cluster_name}",
|
||||
url=PageBases.UPDATE,
|
||||
icon=icon,
|
||||
template_ui="LCU",
|
||||
info={
|
||||
"en": {
|
||||
"page": "Update Account Records via all types account information",
|
||||
|
|
@ -215,29 +225,29 @@ class ClustersPageInfo:
|
|||
"ENDPOINTS": AccountRecordsUpdateEventMethods.retrieve_all_event_keys(),
|
||||
"LANGUAGE_MODELS": account_language_update_form_models_as_dict,
|
||||
"INSTRUCTIONS": {
|
||||
"VALIDATION": {
|
||||
KeyTypeValidations.VALIDATION: {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||||
"data": ValidationRequest(
|
||||
event_code=f"{KeyBases.update_key}",
|
||||
asked_field=KeyValidations.validation,
|
||||
type=KeyTypes.REQUEST
|
||||
type_=KeyTypes.REQUEST
|
||||
).dump(),
|
||||
},
|
||||
"HEADERS": {
|
||||
KeyTypeValidations.HEADERS: {
|
||||
"store": True,
|
||||
"url": KeyURLs.validations,
|
||||
"url": f"{VALID_URL_EXTENSION}{KeyURLs.validations}",
|
||||
"data": ValidationRequest(
|
||||
event_code=f"{KeyBases.update_key}",
|
||||
asked_field=KeyValidations.headers,
|
||||
type=KeyTypes.REQUEST
|
||||
type_=KeyTypes.REQUEST
|
||||
).dump(),
|
||||
},
|
||||
"DATA": {
|
||||
"store": True,
|
||||
"url": f"{KeyBases.list_key}",
|
||||
"params": {"uu_id": "SomeUUID"},
|
||||
"data": dict(page=1, size=1, limit=1, order_by="uu_id", order_type="desc", query={"uu_id": "SomeUUID"}),
|
||||
KeyTypeValidations.MODIFY: {
|
||||
"store": False,
|
||||
"url": f"{EVENTS_URL_EXTENSION}{KeyBases.update_key}",
|
||||
"params": None,
|
||||
"data": None,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
@ -246,9 +256,9 @@ class ClustersPageInfo:
|
|||
|
||||
# Page Variations of the cluster
|
||||
page_infos = {
|
||||
ClustersPageInfo.dashboard_page_info.URL: ClustersPageInfo.dashboard_page_info,
|
||||
ClustersPageInfo.create_page_info.URL: ClustersPageInfo.create_page_info,
|
||||
ClustersPageInfo.update_page_info.URL: ClustersPageInfo.update_page_info,
|
||||
ClustersPageInfo.DASHBOARD.URL: ClustersPageInfo.DASHBOARD,
|
||||
ClustersPageInfo.CREATE.URL: ClustersPageInfo.CREATE,
|
||||
ClustersPageInfo.UPDATE.URL: ClustersPageInfo.UPDATE,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ cluster_event.endpoint_callable = get_cluster_by_event_function_code
|
|||
# Page Event
|
||||
page_event = Event(
|
||||
name="page_event",
|
||||
key="",
|
||||
key="2a43bff2-3720-4427-b226-9b2f6ef00b57",
|
||||
request_validator=PagePydantic,
|
||||
language_models=[],
|
||||
statics=None,
|
||||
|
|
|
|||
|
|
@ -6,9 +6,12 @@ from typing import Dict, Any, Optional
|
|||
from fastapi import Request
|
||||
|
||||
from ApiLayers.AllConfigs.Redis.configs import (
|
||||
RedisValidationKeysAction,
|
||||
RedisCategoryKeys,
|
||||
RedisValidationKeysAction,
|
||||
RedisCategoryPageInfoKeysAction,
|
||||
)
|
||||
from ApiLayers.ApiLibrary.common.line_number import get_line_number_for_error
|
||||
from ApiLayers.ErrorHandlers.Exceptions.api_exc import HTTPExceptionApi
|
||||
from Services.Redis.Actions.actions import RedisActions
|
||||
from Events.base_request_model import BaseRouteModel
|
||||
|
||||
|
|
@ -163,6 +166,12 @@ class RetrievePage(BaseRouteModel):
|
|||
Context Token Retriever to get user information from ACCESS_TOKEN
|
||||
CategoryCluster Retrieve Cluster Retrieve cluster by name
|
||||
Check available instructions of page and info user with it
|
||||
Args:
|
||||
request: FastAPI request object
|
||||
data.page: Request body containing login credentials
|
||||
{
|
||||
"page": "/dashboard?site=AccountCluster"
|
||||
}
|
||||
Returns:
|
||||
NAME=cluster_name.name,
|
||||
PREFIX=cluster_name.PREFIX,
|
||||
|
|
@ -174,8 +183,7 @@ class RetrievePage(BaseRouteModel):
|
|||
from Events.Engine import CategoryCluster
|
||||
from Events.JustEvents.events_file import retrieve_cluster_by_name
|
||||
|
||||
reachable_codes = []
|
||||
page_name = getattr(data, "page", None)
|
||||
reachable_codes, page_name = [], getattr(data, "page", None)
|
||||
if cls.context_retriever.token.is_employee:
|
||||
reachable_codes = (
|
||||
cls.context_retriever.token.selected_company.reachable_event_codes
|
||||
|
|
@ -184,25 +192,43 @@ class RetrievePage(BaseRouteModel):
|
|||
reachable_codes = (
|
||||
cls.context_retriever.token.selected_occupant.reachable_event_codes
|
||||
)
|
||||
cluster_from_all_events = cls.get_site_cluster(page_name=page_name)
|
||||
if not cluster_from_all_events:
|
||||
raise ValueError(f"Cluster not found : {page_name}")
|
||||
cluster_name = str(page_name).split("?")[1].split("=")[1]
|
||||
print("page_name", f"{RedisCategoryPageInfoKeysAction.page_index}:{page_name}")
|
||||
page_info_from_redis = RedisActions.get_json(
|
||||
list_keys=[
|
||||
RedisCategoryPageInfoKeysAction.page_index,
|
||||
cluster_name,
|
||||
]
|
||||
)
|
||||
page_info_all = page_info_from_redis.first
|
||||
if not page_info_all:
|
||||
return dict(
|
||||
NAME=f"{cluster_name}",
|
||||
PREFIX=f"NOT IMPLEMENTED",
|
||||
URL=f"{page_name}",
|
||||
MESSAGE="Cluster not found"
|
||||
)
|
||||
|
||||
cluster_name: CategoryCluster = retrieve_cluster_by_name(cluster_from_all_events)
|
||||
if not cluster_name:
|
||||
raise ValueError("Cluster not found")
|
||||
page_info = page_info_all.get(page_name, {})
|
||||
sub_components = dict(page_info).get("SUB_COMPONENTS", {})
|
||||
|
||||
page_info = cluster_name.retrieve_page_info().get(page_name, None)
|
||||
if not page_info:
|
||||
raise ValueError("Page not found")
|
||||
|
||||
sub_components: dict = dict(page_info).get("SUB_COMPONENTS", {})
|
||||
if not sub_components:
|
||||
raise ValueError("Sub components not found")
|
||||
|
||||
new_page_info_dict = dict(
|
||||
NAME=cluster_name.name,
|
||||
PREFIX=cluster_name.PREFIX,
|
||||
print("PAGE INFO : ", dict(
|
||||
page_name=page_name,
|
||||
page_info=page_info,
|
||||
sub_components=sub_components,
|
||||
NAME=cluster_name,
|
||||
PREFIX=page_info_all.get("prefix", ""),
|
||||
TEMPLATE_UI=dict(page_info).get("TEMPLATE_UI", ""),
|
||||
URL=dict(page_info).get("URL", None),
|
||||
ICON=dict(page_info).get("ICON", None),
|
||||
INFO=dict(page_info).get("INFO", None),
|
||||
SUB_COMPONENTS=sub_components,
|
||||
# MAPPING=cluster_name.MAPPING,
|
||||
))
|
||||
new_page_info = dict(
|
||||
NAME=cluster_name,
|
||||
PREFIX=page_info_all.get("prefix", ""),
|
||||
TEMPLATE_UI=dict(page_info).get("TEMPLATE_UI", ""),
|
||||
URL=dict(page_info).get("URL", None),
|
||||
ICON=dict(page_info).get("ICON", None),
|
||||
INFO=dict(page_info).get("INFO", None),
|
||||
|
|
@ -210,10 +236,17 @@ class RetrievePage(BaseRouteModel):
|
|||
# MAPPING=cluster_name.MAPPING,
|
||||
)
|
||||
for key, events in dict(sub_components).items():
|
||||
# Meaning client can reach this endpoint [] & [] intersection
|
||||
# Meaning client can reach this endpoint [] & [] intersection in reachable_codes
|
||||
endpoint_event_codes = dict(events).get("ENDPOINTS", [])
|
||||
new_page_info_dict["SUB_COMPONENTS"][key].pop("ENDPOINTS")
|
||||
if not set(endpoint_event_codes) & set(reachable_codes):
|
||||
new_page_info_dict["SUB_COMPONENTS"].pop(key)
|
||||
|
||||
return new_page_info_dict
|
||||
if not len(list(set(endpoint_event_codes) & set(reachable_codes))) == 1:
|
||||
print(f"{endpoint_event_codes} :||: Endpoint is not available for the current user")
|
||||
new_page_info["SUB_COMPONENTS"].pop(key, None)
|
||||
for key in new_page_info["SUB_COMPONENTS"].keys():
|
||||
new_page_info["SUB_COMPONENTS"][key].pop("ENDPOINTS", None)
|
||||
if len(new_page_info["SUB_COMPONENTS"]) == 0:
|
||||
return dict(
|
||||
NAME=cluster_name,
|
||||
PREFIX=page_info_all.get("prefix", ""),
|
||||
MESSAGE="This cluster is not registered or not accessible for the current user"
|
||||
)
|
||||
return new_page_info
|
||||
|
|
|
|||
|
|
@ -128,6 +128,7 @@ class PageInfo:
|
|||
LANGUAGE_MODELS: Dict[str, Any]
|
||||
SUB_COMPONENTS: Optional[list["PageComponent"]] = None
|
||||
INSTRUCTIONS: Optional[Dict[str, Any]] = None
|
||||
TEMPLATE_UI: Optional[str] = "LCU"
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
|
@ -139,6 +140,7 @@ class PageInfo:
|
|||
language_models: Optional[Dict[str, Any]] = None,
|
||||
sub_components: Optional[list[Dict[str, Any]]] = None,
|
||||
instructions: Optional[Dict[str, Any]] = None,
|
||||
template_ui: Optional[str] = "LCU",
|
||||
):
|
||||
self.NAME = name
|
||||
self.LANGUAGE_MODELS = language_models
|
||||
|
|
@ -148,6 +150,7 @@ class PageInfo:
|
|||
self.ENDPOINTS = endpoints
|
||||
self.INFO = info
|
||||
self.INSTRUCTIONS = instructions
|
||||
self.TEMPLATE_UI = template_ui
|
||||
|
||||
@property
|
||||
def endpoints(self):
|
||||
|
|
@ -163,6 +166,7 @@ class PageInfo:
|
|||
"NAME": self.NAME,
|
||||
"ICON": self.ICON,
|
||||
"URL": self.URL,
|
||||
"TEMPLATE_UI": self.TEMPLATE_UI,
|
||||
"LANGUAGE_MODELS": self.LANGUAGE_MODELS,
|
||||
"INFO": self.INFO,
|
||||
"SUB_COMPONENTS": self.SUB_COMPONENTS,
|
||||
|
|
@ -329,6 +333,7 @@ class CategoryCluster:
|
|||
DESCRIPTION: str
|
||||
ENDPOINTS: dict[str, MethodToEvent] # {"MethodToEvent": MethodToEvent, ...}
|
||||
SUBCATEGORY: Optional[List["CategoryCluster"]] # [CategoryCluster, ...]
|
||||
TEMPLATE_UI: Optional[str] = "LCU" # LCU as List/Create/Update
|
||||
MAPPING: Optional[List[Dict[str, Any]]] # [{"key": "value"}, ...]
|
||||
INCLUDE_IN_SCHEMA: Optional[bool] = True
|
||||
IS_CLIENT: Optional[bool] = False
|
||||
|
|
@ -343,6 +348,7 @@ class CategoryCluster:
|
|||
sub_category: list,
|
||||
mapping: Optional[List[Dict[str, Any]]] = None,
|
||||
pageinfo: Optional[Dict["str", PageInfo]] = None,
|
||||
template_ui: Optional[str] = "LCU",
|
||||
include_in_schema: Optional[bool] = True,
|
||||
is_client: Optional[bool] = False,
|
||||
):
|
||||
|
|
@ -355,6 +361,7 @@ class CategoryCluster:
|
|||
self.SUBCATEGORY = sub_category or []
|
||||
self.INCLUDE_IN_SCHEMA = include_in_schema
|
||||
self.MAPPING = mapping
|
||||
self.TEMPLATE_UI = template_ui
|
||||
self.IS_CLIENT = is_client
|
||||
|
||||
@property
|
||||
|
|
@ -408,6 +415,7 @@ class CategoryCluster:
|
|||
return {"prefix": self.PREFIX, "mapping": self.MAPPING, **page_infos}
|
||||
"""
|
||||
page_infos = {}
|
||||
print('def retrieve_page_info self.PAGEINFO',self.PAGEINFO)
|
||||
if isinstance(self.PAGEINFO, dict):
|
||||
for page_key, page_info in dict(self.PAGEINFO).items():
|
||||
if page_info_dict := getattr(page_info, "as_dict", None):
|
||||
|
|
@ -415,7 +423,7 @@ class CategoryCluster:
|
|||
return {"prefix": self.PREFIX, "mapping": self.MAPPING, **page_infos}
|
||||
if hasattr(self.PAGEINFO, "as_dict"):
|
||||
return {"prefix": self.PREFIX, "mapping": self.MAPPING, **self.PAGEINFO.as_dict}
|
||||
raise ValueError("PAGE_INFO not found")
|
||||
return {"prefix": self.PREFIX, "mapping": self.MAPPING}
|
||||
|
||||
|
||||
class LanguageModels:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ from Services.PostgresDb.Models.pagination import (
|
|||
TokenDictType = Union[EmployeeTokenObject, OccupantTokenObject]
|
||||
|
||||
STATIC_PATH = "events"
|
||||
AUTH_URL_EXTENSION = "http://auth-service:8888"
|
||||
EVENTS_URL_EXTENSION = "http://events-service:8888"
|
||||
VALID_URL_EXTENSION = "http://validation-service:8888"
|
||||
|
||||
|
||||
class EndpointBaseRequestModel(BaseModel):
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
services:
|
||||
|
||||
initservice:
|
||||
container_name: initservice
|
||||
build:
|
||||
|
|
|
|||
Loading…
Reference in New Issue