diff --git a/api_services/api_builds/account_service/Dockerfile b/api_services/api_builds/account_service/Dockerfile new file mode 100644 index 0000000..287e29f --- /dev/null +++ b/api_services/api_builds/account_service/Dockerfile @@ -0,0 +1,31 @@ +FROM python:3.12-slim + +WORKDIR / + +# Install system dependencies and Poetry +RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry + +# Copy Poetry configuration +COPY /pyproject.toml ./pyproject.toml + +# Configure Poetry and install dependencies with optimizations +RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main && pip cache purge && rm -rf ~/.cache/pypoetry + +# Copy application code +COPY /api_services/api_initializer /api_initializer +COPY /api_services/api_controllers /api_controllers +COPY /api_services/api_validations /api_validations +COPY /api_services/schemas /schemas +COPY /api_services/api_modules /api_modules + +COPY /api_services/api_middlewares /api_middlewares +COPY /api_services/api_builds/account_service/endpoints /api_initializer/endpoints +COPY /api_services/api_builds/account_service/events /api_initializer/events +COPY /api_services/api_builds/account_service/validations /api_initializer/validations +COPY /api_services/api_builds/account_service/index.py /api_initializer/index.py + +# Set Python path to include app directory +ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 + +# Run the application using the configured uvicorn server +CMD ["poetry", "run", "python", "/api_initializer/app.py"] diff --git a/api_services/api_builds/account_service/endpoints/account_records/router.py b/api_services/api_builds/account_service/endpoints/account_records/router.py new file mode 100644 index 0000000..4a4a09f --- /dev/null +++ b/api_services/api_builds/account_service/endpoints/account_records/router.py @@ -0,0 +1,72 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.account_records.cluster import AccountRecordsRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +account_records_router = APIRouter(prefix="/account/records", tags=["Account Cluster"]) + + +account_records_list = "AccountRecordsList" +@account_records_router.post( + path="/list", + description="List all account records endpoint", + operation_id=endpoints_index[account_records_list], +) +def people_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AccountRecordsRouterCluster.get_event_cluster(account_records_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, header=headers) + + +account_records_create = "AccountRecordsCreate" +@account_records_router.post( + path="/create", + description="Create account records endpoint", + operation_id=endpoints_index[account_records_create], +) +def account_records_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AccountRecordsRouterCluster.get_event_cluster(account_records_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, header=headers) + + +account_records_update = "AccountRecordsUpdate" +@account_records_router.post( + path="/update/{uu_id}", + description="Update account records endpoint", + operation_id=endpoints_index[account_records_update], +) +def account_records_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AccountRecordsRouterCluster.get_event_cluster(account_records_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, header=headers) + + +account_records_delete = "AccountRecordsDelete" +@account_records_router.post( + path="/delete/{uu_id}", + description="Delete account records endpoint", + operation_id=endpoints_index[account_records_delete], +) +def account_records_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AccountRecordsRouterCluster.get_event_cluster(account_records_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, header=headers) diff --git a/api_services/api_builds/account_service/endpoints/routes.py b/api_services/api_builds/account_service/endpoints/routes.py new file mode 100644 index 0000000..982061e --- /dev/null +++ b/api_services/api_builds/account_service/endpoints/routes.py @@ -0,0 +1,15 @@ +from fastapi import APIRouter +from .account_records.router import account_records_router + +def get_routes() -> list[APIRouter]: + return [account_records_router] + + +def get_safe_endpoint_urls() -> list[tuple[str, str]]: + return [ + ("/", "GET"), + ("/docs", "GET"), + ("/redoc", "GET"), + ("/openapi.json", "GET"), + ("/metrics", "GET"), + ] diff --git a/api_services/api_builds/account_service/events/__init__.py b/api_services/api_builds/account_service/events/__init__.py new file mode 100644 index 0000000..4341b95 --- /dev/null +++ b/api_services/api_builds/account_service/events/__init__.py @@ -0,0 +1,5 @@ +from .account_records.cluster import AccountRecordsRouterCluster + +__all__ = [ + "AccountRecordsRouterCluster", +] diff --git a/web_services/management_frontend/src/languages/custom/management/a.txt b/api_services/api_builds/account_service/events/a.txt similarity index 100% rename from web_services/management_frontend/src/languages/custom/management/a.txt rename to api_services/api_builds/account_service/events/a.txt diff --git a/api_services/api_builds/account_service/events/account_records/cluster.py b/api_services/api_builds/account_service/events/account_records/cluster.py new file mode 100644 index 0000000..2c41b8b --- /dev/null +++ b/api_services/api_builds/account_service/events/account_records/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperAccountRecordsListEvent, + SuperAccountRecordsCreateEvent, + SuperAccountRecordsUpdateEvent, + SuperAccountRecordsDeleteEvent, +) + +AccountRecordsRouterCluster = RouterCluster(name="AccountRecordsRouterCluster") + +AccountRecordsListEventCluster = EventCluster(name="AccountRecordsListEventCluster", endpoint_uu_id=endpoints_index["AccountRecordsList"]) +AccountRecordsListEventCluster.add_event(SuperAccountRecordsListEvent) + +AccountRecordsCreateEventCluster = EventCluster(name="AccountRecordsCreateEventCluster", endpoint_uu_id=endpoints_index["AccountRecordsCreate"]) +AccountRecordsCreateEventCluster.add_event(SuperAccountRecordsCreateEvent) + +AccountRecordsUpdateEventCluster = EventCluster(name="AccountRecordsUpdateEventCluster", endpoint_uu_id=endpoints_index["AccountRecordsUpdate"]) +AccountRecordsUpdateEventCluster.add_event(SuperAccountRecordsUpdateEvent) + +AccountRecordsDeleteEventCluster = EventCluster(name="AccountRecordsDeleteEventCluster", endpoint_uu_id=endpoints_index["AccountRecordsDelete"]) +AccountRecordsDeleteEventCluster.add_event(SuperAccountRecordsDeleteEvent) + +AccountRecordsRouterCluster.set_event_cluster(AccountRecordsListEventCluster) +AccountRecordsRouterCluster.set_event_cluster(AccountRecordsCreateEventCluster) +AccountRecordsRouterCluster.set_event_cluster(AccountRecordsUpdateEventCluster) +AccountRecordsRouterCluster.set_event_cluster(AccountRecordsDeleteEventCluster) diff --git a/api_services/api_builds/account_service/events/account_records/supers_events.py b/api_services/api_builds/account_service/events/account_records/supers_events.py new file mode 100644 index 0000000..b7cae45 --- /dev/null +++ b/api_services/api_builds/account_service/events/account_records/supers_events.py @@ -0,0 +1,93 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from api_validations.defaults.validations import CommonHeaders +from schemas import AccountRecords + +# List all account records endpoint Super Users +SuperAccountRecordsListEvent = Event( + name="super_account_records_list", + key="c5b6d9c7-9115-4825-bcc1-16f409a7004a", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Account Records List all flat representative users endpoint", +) + +# Create account records endpoint Super Users +SuperAccountRecordsCreateEvent = Event( + name="super_account_records_create", + key="1ab5c778-5a25-49d0-8bf8-799a74f430ad", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Account Records Create endpoint", +) + +# Update account records endpoint Super Users +SuperAccountRecordsUpdateEvent = Event( + name="super_account_records_update", + key="137fca9b-110a-4a28-bddd-36fde7380e89", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Account Records Update endpoint", +) + +# Delete account records endpoint Super Users +SuperAccountRecordsDeleteEvent = Event( + name="super_account_records_delete", + key="8bf399a7-f79e-49d2-b481-f5974676599f", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Account Records Delete endpoint", +) + + +def super_account_records_list_callable(list_options: PaginateOnly, header: CommonHeaders): + return { + "message": "MSG0003-LIST", + "data": None, + "completed": True, + } + + +SuperAccountRecordsListEvent.event_callable = super_account_records_list_callable + + +def super_account_records_create_callable(data: AccountRecords, header: CommonHeaders): + return { + "message": "MSG0003-CREATE", + "data": None, + "completed": True, + } + + +SuperAccountRecordsCreateEvent.event_callable = super_account_records_create_callable + + +def super_account_records_update_callable(data: AccountRecords, header: CommonHeaders): + return { + "message": "MSG0003-UPDATE", + "data": None, + "completed": True, + } + + +SuperAccountRecordsUpdateEvent.event_callable = super_account_records_update_callable + + +def super_account_records_delete_callable(data: AccountRecords, header: CommonHeaders): + return { + "message": "MSG0003-DELETE", + "data": None, + "completed": True, + } + + +SuperAccountRecordsDeleteEvent.event_callable = super_account_records_delete_callable diff --git a/api_services/api_builds/account_service/index.py b/api_services/api_builds/account_service/index.py new file mode 100644 index 0000000..68b59a0 --- /dev/null +++ b/api_services/api_builds/account_service/index.py @@ -0,0 +1,8 @@ + + +endpoints_index: dict = { + "AccountRecordsList": "7552d270-0e2a-4a40-bfd5-ec3493bc63ab", + "AccountRecordsCreate": "ddb956fb-73ef-4eec-a51b-ff54c3d65552", + "AccountRecordsUpdate": "6f120aca-b5a7-43ea-8214-9c17f9333c8a", + "AccountRecordsDelete": "5cc1de2d-de11-4bbe-9c19-5b8eec69e4a1", +} diff --git a/api_services/api_builds/auth_service/events/auth/events.py b/api_services/api_builds/auth_service/events/auth/events.py index f56d9dd..78fd611 100644 --- a/api_services/api_builds/auth_service/events/auth/events.py +++ b/api_services/api_builds/auth_service/events/auth/events.py @@ -20,6 +20,8 @@ from schemas import ( Event2Occupant, Application2Employee, RelationshipEmployee2Build, + Events, + EndpointRestriction, ) from api_modules.token.password_module import PasswordModule from api_controllers.mongo.database import mongo_handler @@ -331,7 +333,11 @@ class LoginHandler: ValueError("EYS_0010") # Get reachable events - reachable_event_codes = Event2Employee.get_event_codes(employee_id=int(result_with_keys_dict['Employees.id']), db=db_session) + # reachable_event_codes = Event2Employee.get_event_codes(employee_id=int(result_with_keys_dict['Employees.id']), db=db_session) + # TODO: erase this bypass later + filter_endpoints_and_events = db_session.query(EndpointRestriction.operation_uu_id, Events.function_code + ).join(EndpointRestriction, EndpointRestriction.id == Events.endpoint_id).filter().all() + reachable_event_codes = {endpoint_name: function_code for endpoint_name, function_code in filter_endpoints_and_events} # Get reachable applications reachable_app_codes = Application2Employee.get_application_codes(employee_id=int(result_with_keys_dict['Employees.id']), db=db_session) diff --git a/api_services/api_builds/building_service/Dockerfile b/api_services/api_builds/building_service/Dockerfile new file mode 100644 index 0000000..00079fd --- /dev/null +++ b/api_services/api_builds/building_service/Dockerfile @@ -0,0 +1,31 @@ +FROM python:3.12-slim + +WORKDIR / + +# Install system dependencies and Poetry +RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry + +# Copy Poetry configuration +COPY /pyproject.toml ./pyproject.toml + +# Configure Poetry and install dependencies with optimizations +RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main && pip cache purge && rm -rf ~/.cache/pypoetry + +# Copy application code +COPY /api_services/api_initializer /api_initializer +COPY /api_services/api_controllers /api_controllers +COPY /api_services/api_validations /api_validations +COPY /api_services/schemas /schemas +COPY /api_services/api_modules /api_modules + +COPY /api_services/api_middlewares /api_middlewares +COPY /api_services/api_builds/building_service/endpoints /api_initializer/endpoints +COPY /api_services/api_builds/building_service/events /api_initializer/events +COPY /api_services/api_builds/building_service/validations /api_initializer/validations +COPY /api_services/api_builds/building_service/index.py /api_initializer/index.py + +# Set Python path to include app directory +ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 + +# Run the application using the configured uvicorn server +CMD ["poetry", "run", "python", "/api_initializer/app.py"] diff --git a/api_services/api_builds/building_service/endpoints/areas/router.py b/api_services/api_builds/building_service/endpoints/areas/router.py new file mode 100644 index 0000000..4fdc17b --- /dev/null +++ b/api_services/api_builds/building_service/endpoints/areas/router.py @@ -0,0 +1,71 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.areas.cluster import AreaRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +area_endpoint_route = APIRouter(prefix="/areas", tags=["Areas Cluster"]) + +area_list = "AreaList" +@area_endpoint_route.post( + path="/list", + description="List all areas endpoint", + operation_id=endpoints_index[area_list], +) +def area_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AreaRouterCluster.get_event_cluster(area_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +area_create = "AreaCreate" +@area_endpoint_route.post( + path="/create", + description="Create area endpoint", + operation_id=endpoints_index[area_create], +) +def area_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AreaRouterCluster.get_event_cluster(area_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +area_update = "AreaUpdate" +@area_endpoint_route.post( + path="/update/{uu_id}", + description="Update area endpoint", + operation_id=endpoints_index[area_update], +) +def area_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AreaRouterCluster.get_event_cluster(area_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers) + + +area_delete = "AreaDelete" +@area_endpoint_route.post( + path="/delete/{uu_id}", + description="Delete area endpoint", + operation_id=endpoints_index[area_delete], +) +def area_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = AreaRouterCluster.get_event_cluster(area_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) diff --git a/api_services/api_builds/building_service/endpoints/building_parts/router.py b/api_services/api_builds/building_service/endpoints/building_parts/router.py new file mode 100644 index 0000000..2529507 --- /dev/null +++ b/api_services/api_builds/building_service/endpoints/building_parts/router.py @@ -0,0 +1,72 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.building_parts.cluster import PartsRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +parts_endpoint_route = APIRouter(prefix="/parts", tags=["Parts Cluster"]) + + +parts_list = "PartsList" +@parts_endpoint_route.post( + path="/list", + description="List all parts endpoint", + operation_id=endpoints_index[parts_list], +) +def parts_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PartsRouterCluster.get_event_cluster(parts_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +parts_create = "PartsCreate" +@parts_endpoint_route.post( + path="/create", + description="Create part endpoint", + operation_id=endpoints_index[parts_create], +) +def parts_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PartsRouterCluster.get_event_cluster(parts_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +parts_update = "PartsUpdate" +@parts_endpoint_route.post( + path="/update/{uu_id}", + description="Update part endpoint", + operation_id=endpoints_index[parts_update], +) +def parts_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PartsRouterCluster.get_event_cluster(parts_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers) + + +parts_delete = "PartsDelete" +@parts_endpoint_route.post( + path="/delete/{uu_id}", + description="Delete part endpoint", + operation_id=endpoints_index[parts_delete], +) +def parts_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PartsRouterCluster.get_event_cluster(parts_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) \ No newline at end of file diff --git a/api_services/api_builds/building_service/endpoints/builds/router.py b/api_services/api_builds/building_service/endpoints/builds/router.py new file mode 100644 index 0000000..fa33a95 --- /dev/null +++ b/api_services/api_builds/building_service/endpoints/builds/router.py @@ -0,0 +1,71 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.builds.cluster import BuildRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +build_endpoint_route = APIRouter(prefix="/builds", tags=["Builds Cluster"]) + +build_list = "BuildList" +@build_endpoint_route.post( + path="/list", + description="List all builds endpoint", + operation_id=endpoints_index[build_list], +) +def build_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = BuildRouterCluster.get_event_cluster(build_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +build_create = "BuildCreate" +@build_endpoint_route.post( + path="/create", + description="Create build endpoint", + operation_id=endpoints_index[build_create], +) +def build_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = BuildRouterCluster.get_event_cluster(build_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +build_update = "BuildUpdate" +@build_endpoint_route.post( + path="/update/{uu_id}", + description="Update build endpoint", + operation_id=endpoints_index[build_update], +) +def build_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = BuildRouterCluster.get_event_cluster(build_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers) + + +build_delete = "BuildDelete" +@build_endpoint_route.post( + path="/delete/{uu_id}", + description="Delete build endpoint", + operation_id=endpoints_index[build_delete], +) +def build_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = BuildRouterCluster.get_event_cluster(build_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) diff --git a/api_services/api_builds/building_service/endpoints/living_space/router.py b/api_services/api_builds/building_service/endpoints/living_space/router.py new file mode 100644 index 0000000..c19ecd2 --- /dev/null +++ b/api_services/api_builds/building_service/endpoints/living_space/router.py @@ -0,0 +1,72 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.living_space.cluster import LivingSpaceRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +living_space_endpoint_route = APIRouter(prefix="/living-space", tags=["Living Space Cluster"]) + + +living_space_list = "LivingSpaceList" +@living_space_endpoint_route.post( + path="/list", + description="List all living spaces endpoint", + operation_id=endpoints_index[living_space_list], +) +def living_space_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = LivingSpaceRouterCluster.get_event_cluster(living_space_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +living_space_create = "LivingSpaceCreate" +@living_space_endpoint_route.post( + path="/create", + description="Create living space endpoint", + operation_id=endpoints_index[living_space_create], +) +def living_space_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = LivingSpaceRouterCluster.get_event_cluster(living_space_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +living_space_update = "LivingSpaceUpdate" +@living_space_endpoint_route.post( + path="/update/{uu_id}", + description="Update living space endpoint", + operation_id=endpoints_index[living_space_update], +) +def living_space_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = LivingSpaceRouterCluster.get_event_cluster(living_space_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers) + + +living_space_delete = "LivingSpaceDelete" +@living_space_endpoint_route.post( + path="/delete/{uu_id}", + description="Delete living space endpoint", + operation_id=endpoints_index[living_space_delete], +) +def living_space_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = LivingSpaceRouterCluster.get_event_cluster(living_space_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) diff --git a/api_services/api_builds/building_service/endpoints/routes.py b/api_services/api_builds/building_service/endpoints/routes.py new file mode 100644 index 0000000..5d9bc97 --- /dev/null +++ b/api_services/api_builds/building_service/endpoints/routes.py @@ -0,0 +1,19 @@ +from fastapi import APIRouter +from .builds.router import build_endpoint_route +from .building_parts.router import parts_endpoint_route +from .areas.router import area_endpoint_route +from .living_space.router import living_space_endpoint_route + + +def get_routes() -> list[APIRouter]: + return [build_endpoint_route, parts_endpoint_route, area_endpoint_route, living_space_endpoint_route] + + +def get_safe_endpoint_urls() -> list[tuple[str, str]]: + return [ + ("/", "GET"), + ("/docs", "GET"), + ("/redoc", "GET"), + ("/openapi.json", "GET"), + ("/metrics", "GET"), + ] diff --git a/api_services/api_builds/building_service/events/__init__.py b/api_services/api_builds/building_service/events/__init__.py new file mode 100644 index 0000000..5705c2f --- /dev/null +++ b/api_services/api_builds/building_service/events/__init__.py @@ -0,0 +1,11 @@ +from .builds.cluster import BuildRouterCluster +from .areas.cluster import AreaRouterCluster +from .living_space.cluster import LivingSpaceRouterCluster +from .building_parts.cluster import PartsRouterCluster + +__all__ = [ + "BuildRouterCluster", + "AreaRouterCluster", + "LivingSpaceRouterCluster", + "PartsRouterCluster", +] diff --git a/api_services/api_builds/building_service/events/areas/cluster.py b/api_services/api_builds/building_service/events/areas/cluster.py new file mode 100644 index 0000000..a4af6d1 --- /dev/null +++ b/api_services/api_builds/building_service/events/areas/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperAreaListEvent, + SuperAreaCreateEvent, + SuperAreaUpdateEvent, + SuperAreaDeleteEvent, +) + +AreaRouterCluster = RouterCluster(name="AreaRouterCluster") + +AreaListEventCluster = EventCluster(name="AreaListEventCluster", endpoint_uu_id=endpoints_index["AreaList"]) +AreaListEventCluster.add_event(SuperAreaListEvent) + +AreaCreateEventCluster = EventCluster(name="AreaCreateEventCluster", endpoint_uu_id=endpoints_index["AreaCreate"]) +AreaCreateEventCluster.add_event(SuperAreaCreateEvent) + +AreaUpdateEventCluster = EventCluster(name="AreaUpdateEventCluster", endpoint_uu_id=endpoints_index["AreaUpdate"]) +AreaUpdateEventCluster.add_event(SuperAreaUpdateEvent) + +AreaDeleteEventCluster = EventCluster(name="AreaDeleteEventCluster", endpoint_uu_id=endpoints_index["AreaDelete"]) +AreaDeleteEventCluster.add_event(SuperAreaDeleteEvent) + +AreaRouterCluster.set_event_cluster(AreaListEventCluster) +AreaRouterCluster.set_event_cluster(AreaCreateEventCluster) +AreaRouterCluster.set_event_cluster(AreaUpdateEventCluster) +AreaRouterCluster.set_event_cluster(AreaDeleteEventCluster) diff --git a/api_services/api_builds/building_service/events/areas/supers_events.py b/api_services/api_builds/building_service/events/areas/supers_events.py new file mode 100644 index 0000000..65401eb --- /dev/null +++ b/api_services/api_builds/building_service/events/areas/supers_events.py @@ -0,0 +1,122 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from schemas import ( + BuildArea, + Build, + BuildParts, + AccountRecords, +) +from api_validations.defaults.validations import CommonHeaders + + +# List all area Super User +SuperAreaListEvent = Event( + name="super_area_list", + key="0d5ba7be-028c-43ce-9a99-f495f812a835", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Area List all endpoint", +) + +# Create area Super User +SuperAreaCreateEvent = Event( + name="super_area_create", + key="0ba2a06d-f4fa-47b9-a305-2225414ffc4a", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Area Create endpoint", +) + +# Update area Super User +SuperAreaUpdateEvent = Event( + name="super_area_update", + key="ecec956a-eadf-4556-b4e1-4ee81a6b8fb2", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Area Update endpoint", +) + +# Delete area Super User +SuperAreaDeleteEvent = Event( + name="super_area_delete", + key="4b2ca548-4113-4942-8a76-1f4337fba98a", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Area Delete endpoint", +) + + +def super_area_list_callable(list_options: PaginateOnly, headers: CommonHeaders): + list_options = PaginateOnly(**list_options.model_dump()) + if token.is_employee: + raise Exception("Forbidden for employees") + + # TODO: Pydantic Model must be implemnted for list_options.query + with AccountRecords.new_session() as db_session: + AccountRecords.set_session(db_session) + list_of_fields = [ + AccountRecords.iban, + AccountRecords.bank_date, + AccountRecords.currency, + AccountRecords.currency_value, + AccountRecords.process_comment, + AccountRecords.add_comment_note, + AccountRecords.receive_debit, + AccountRecords.is_email_send, + AccountRecords.is_notification_send, + ] + account_records_query = db_session.query(*list_of_fields + ).join(BuildParts, BuildParts.id == AccountRecords.build_parts_id + ).filter(BuildParts.id == token.selected_occupant.build_part_id) + if list_options.query: + account_records_query = account_records_query.filter(*AccountRecords.convert(list_options.query)) + + pagination = Pagination(data=account_records_query) + pagination.change(**list_options.model_dump()) + pagination_result = PaginationResult(data=account_records_query, pagination=pagination) + return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response + + +SuperAreaListEvent.event_callable = super_area_list_callable + + +def super_area_create_callable(data, headers: CommonHeaders): + return { + "message": "MSG0001-INSERT", + "data": data, + "completed": True, + } + + +SuperAreaCreateEvent.event_callable = super_area_create_callable + + +def super_area_update_callable(data, headers: CommonHeaders): + return { + "message": "MSG0002-UPDATE", + "data": data, + "completed": True, + } + + +SuperAreaUpdateEvent.event_callable = super_area_update_callable + + +def super_area_delete_callable(uu_id: str, headers: CommonHeaders): + return { + "message": "MSG0003-DELETE", + "data": data, + "completed": True, + } + + +SuperAreaDeleteEvent.event_callable = super_area_delete_callable diff --git a/api_services/api_builds/building_service/events/building_parts/cluster.py b/api_services/api_builds/building_service/events/building_parts/cluster.py new file mode 100644 index 0000000..8589f84 --- /dev/null +++ b/api_services/api_builds/building_service/events/building_parts/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperPartsListEvent, + SuperPartsCreateEvent, + SuperPartsUpdateEvent, + SuperPartsDeleteEvent, +) + +PartsRouterCluster = RouterCluster(name="PartsRouterCluster") + +PartsListEventCluster = EventCluster(name="PartsListEventCluster", endpoint_uu_id=endpoints_index["PartsList"]) +PartsListEventCluster.add_event(SuperPartsListEvent) + +PartsCreateEventCluster = EventCluster(name="PartsCreateEventCluster", endpoint_uu_id=endpoints_index["PartsCreate"]) +PartsCreateEventCluster.add_event(SuperPartsCreateEvent) + +PartsUpdateEventCluster = EventCluster(name="PartsUpdateEventCluster", endpoint_uu_id=endpoints_index["PartsUpdate"]) +PartsUpdateEventCluster.add_event(SuperPartsUpdateEvent) + +PartsDeleteEventCluster = EventCluster(name="PartsDeleteEventCluster", endpoint_uu_id=endpoints_index["PartsDelete"]) +PartsDeleteEventCluster.add_event(SuperPartsDeleteEvent) + +PartsRouterCluster.set_event_cluster(PartsListEventCluster) +PartsRouterCluster.set_event_cluster(PartsCreateEventCluster) +PartsRouterCluster.set_event_cluster(PartsUpdateEventCluster) +PartsRouterCluster.set_event_cluster(PartsDeleteEventCluster) diff --git a/api_services/api_builds/building_service/events/building_parts/supers_events.py b/api_services/api_builds/building_service/events/building_parts/supers_events.py new file mode 100644 index 0000000..887cbfb --- /dev/null +++ b/api_services/api_builds/building_service/events/building_parts/supers_events.py @@ -0,0 +1,98 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from schemas import ( + Build, + BuildParts, + AccountRecords, +) +from api_validations.defaults.validations import CommonHeaders + + +# List all endpoint Super Parts +SuperPartsListEvent = Event( + name="super_parts_list", + key="018e659d-380d-4b2a-b5a4-d77530cb8de0", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Parts List all endpoint", +) + +# Create endpoint Super Parts +SuperPartsCreateEvent = Event( + name="super_parts_create", + key="fdfede54-f0e7-4d48-8eae-269479ad9abb", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Parts Create endpoint", +) + +# Update endpoint Super Parts +SuperPartsUpdateEvent = Event( + name="super_parts_update", + key="ace6137c-fe8e-45bd-ae51-bc1c293f8373", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Parts Update endpoint", +) + +# Delete endpoint Super Parts +SuperPartsDeleteEvent = Event( + name="super_parts_delete", + key="8fb7f505-7a3a-4260-9959-ae0e5c8f9bfe", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Parts Delete endpoint", +) + + +def super_parts_list_callable(list_options: PaginateOnly, headers: CommonHeaders): + return { + "message": "MSG0003-LIST", + "data": None, + "completed": True, + } + + +SuperPartsListEvent.event_callable = super_parts_list_callable + + +def super_parts_create_callable(data, headers: CommonHeaders): + return { + "message": "MSG0001-INSERT", + "data": None, + "completed": True, + } + + +SuperPartsCreateEvent.event_callable = super_parts_create_callable + + +def super_parts_update_callable(data, headers: CommonHeaders): + return { + "message": "MSG0002-UPDATE", + "data": None, + "completed": True, + } + + +SuperPartsUpdateEvent.event_callable = super_parts_update_callable + + +def super_parts_delete_callable(uu_id: str, headers: CommonHeaders): + return { + "message": "MSG0003-DELETE", + "data": None, + "completed": True, + } + + +SuperPartsDeleteEvent.event_callable = super_parts_delete_callable diff --git a/api_services/api_builds/building_service/events/builds/cluster.py b/api_services/api_builds/building_service/events/builds/cluster.py new file mode 100644 index 0000000..20a8aec --- /dev/null +++ b/api_services/api_builds/building_service/events/builds/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperBuildListEvent, + SuperBuildCreateEvent, + SuperBuildUpdateEvent, + SuperBuildDeleteEvent, +) + +BuildRouterCluster = RouterCluster(name="BuildRouterCluster") + +BuildListEventCluster = EventCluster(name="BuildListEventCluster", endpoint_uu_id=endpoints_index["BuildList"]) +BuildListEventCluster.add_event(SuperBuildListEvent) + +BuildCreateEventCluster = EventCluster(name="BuildCreateEventCluster", endpoint_uu_id=endpoints_index["BuildCreate"]) +BuildCreateEventCluster.add_event(SuperBuildCreateEvent) + +BuildUpdateEventCluster = EventCluster(name="BuildUpdateEventCluster", endpoint_uu_id=endpoints_index["BuildUpdate"]) +BuildUpdateEventCluster.add_event(SuperBuildUpdateEvent) + +BuildDeleteEventCluster = EventCluster(name="BuildDeleteEventCluster", endpoint_uu_id=endpoints_index["BuildDelete"]) +BuildDeleteEventCluster.add_event(SuperBuildDeleteEvent) + +BuildRouterCluster.set_event_cluster(BuildListEventCluster) +BuildRouterCluster.set_event_cluster(BuildCreateEventCluster) +BuildRouterCluster.set_event_cluster(BuildUpdateEventCluster) +BuildRouterCluster.set_event_cluster(BuildDeleteEventCluster) diff --git a/api_services/api_builds/building_service/events/builds/supers_events.py b/api_services/api_builds/building_service/events/builds/supers_events.py new file mode 100644 index 0000000..aece126 --- /dev/null +++ b/api_services/api_builds/building_service/events/builds/supers_events.py @@ -0,0 +1,118 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from schemas import ( + Build, + BuildParts, + AccountRecords, +) +from api_validations.defaults.validations import CommonHeaders + + +# List all endpoint FL-REP +SuperBuildListEvent = Event( + name="build_list", + key="e8586858-db39-4520-bb1a-338ab9c5f043", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Build List all endpoint", +) + +SuperBuildCreateEvent = Event( + name="build_create", + key="79519e0f-c4a6-4afc-a494-d0e547ba39bc", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Build Create endpoint", +) + +SuperBuildUpdateEvent = Event( + name="build_update", + key="ca51080e-11f2-46f7-a1ba-caa1c40b3fd6", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Build Update endpoint", +) + +SuperBuildDeleteEvent = Event( + name="build_delete", + key="a30d32cc-c931-41d6-8a66-d6c04479098f", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Build Delete endpoint", +) + + +def super_build_list_callable(list_options: PaginateOnly, headers: CommonHeaders): + list_options = PaginateOnly(**list_options.model_dump()) + if token.is_employee: + raise Exception("Forbidden for employees") + + # TODO: Pydantic Model must be implemnted for list_options.query + with AccountRecords.new_session() as db_session: + AccountRecords.set_session(db_session) + list_of_fields = [ + AccountRecords.iban, + AccountRecords.bank_date, + AccountRecords.currency, + AccountRecords.currency_value, + AccountRecords.process_comment, + AccountRecords.add_comment_note, + AccountRecords.receive_debit, + AccountRecords.is_email_send, + AccountRecords.is_notification_send, + ] + account_records_query = db_session.query(*list_of_fields + ).join(BuildParts, BuildParts.id == AccountRecords.build_parts_id + ).filter(BuildParts.id == token.selected_occupant.build_part_id) + if list_options.query: + account_records_query = account_records_query.filter(*AccountRecords.convert(list_options.query)) + + pagination = Pagination(data=account_records_query) + pagination.change(**list_options.model_dump()) + pagination_result = PaginationResult(data=account_records_query, pagination=pagination) + return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response + + +SuperBuildListEvent.event_callable = super_build_list_callable + + +def super_build_create_callable(data, headers: CommonHeaders): + return { + "message": "MSG0001-INSERT", + "data": None, + "completed": True, + } + + +SuperBuildCreateEvent.event_callable = super_build_create_callable + + +def super_build_update_callable(data, headers: CommonHeaders): + return { + "message": "MSG0002-UPDATE", + "data": None, + "completed": True, + } + + +SuperBuildUpdateEvent.event_callable = super_build_update_callable + + +def super_build_delete_callable(uu_id: str, headers: CommonHeaders): + return { + "message": "MSG0003-DELETE", + "data": None, + "completed": True, + } + + +SuperBuildDeleteEvent.event_callable = super_build_delete_callable diff --git a/api_services/api_builds/building_service/events/living_space/cluster.py b/api_services/api_builds/building_service/events/living_space/cluster.py new file mode 100644 index 0000000..9eeae5e --- /dev/null +++ b/api_services/api_builds/building_service/events/living_space/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperLivingSpaceListEvent, + SuperLivingSpaceCreateEvent, + SuperLivingSpaceUpdateEvent, + SuperLivingSpaceDeleteEvent, +) + +LivingSpaceRouterCluster = RouterCluster(name="LivingSpaceRouterCluster") + +LivingSpaceListEventCluster = EventCluster(name="LivingSpaceListEventCluster", endpoint_uu_id=endpoints_index["LivingSpaceList"]) +LivingSpaceListEventCluster.add_event(SuperLivingSpaceListEvent) + +LivingSpaceCreateEventCluster = EventCluster(name="LivingSpaceCreateEventCluster", endpoint_uu_id=endpoints_index["LivingSpaceCreate"]) +LivingSpaceCreateEventCluster.add_event(SuperLivingSpaceCreateEvent) + +LivingSpaceUpdateEventCluster = EventCluster(name="LivingSpaceUpdateEventCluster", endpoint_uu_id=endpoints_index["LivingSpaceUpdate"]) +LivingSpaceUpdateEventCluster.add_event(SuperLivingSpaceUpdateEvent) + +LivingSpaceDeleteEventCluster = EventCluster(name="LivingSpaceDeleteEventCluster", endpoint_uu_id=endpoints_index["LivingSpaceDelete"]) +LivingSpaceDeleteEventCluster.add_event(SuperLivingSpaceDeleteEvent) + +LivingSpaceRouterCluster.set_event_cluster(LivingSpaceListEventCluster) +LivingSpaceRouterCluster.set_event_cluster(LivingSpaceCreateEventCluster) +LivingSpaceRouterCluster.set_event_cluster(LivingSpaceUpdateEventCluster) +LivingSpaceRouterCluster.set_event_cluster(LivingSpaceDeleteEventCluster) diff --git a/api_services/api_builds/building_service/events/living_space/supers_events.py b/api_services/api_builds/building_service/events/living_space/supers_events.py new file mode 100644 index 0000000..72e39bc --- /dev/null +++ b/api_services/api_builds/building_service/events/living_space/supers_events.py @@ -0,0 +1,95 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from schemas import ( + Build, + BuildParts, + AccountRecords, +) +from api_validations.defaults.validations import CommonHeaders + + +# List all endpoint FL-REP +SuperLivingSpaceListEvent = Event( + name="super_living_space_list", + key="e3eced11-c464-4893-8b49-d2858c160ed0", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Living Space List all endpoint", +) + +SuperLivingSpaceCreateEvent = Event( + name="super_living_space_create", + key="9e26f770-3475-4831-9da9-4684119b13ae", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Living Space Create endpoint", +) + +SuperLivingSpaceUpdateEvent = Event( + name="super_living_space_update", + key="ecd15d27-e5e8-4bd1-972b-9b4508cfac77", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Living Space Update endpoint", +) + +SuperLivingSpaceDeleteEvent = Event( + name="super_living_space_delete", + key="4fcadb8c-2e26-4af3-acb5-bcbf87cae0c0", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Living Space Delete endpoint", +) + + +def super_living_space_list_callable(list_options: PaginateOnly, headers: CommonHeaders): + return { + "message": "MSG0003-LIST", + "data": None, + "completed": True, + } + + +SuperLivingSpaceListEvent.event_callable = super_living_space_list_callable + + +def super_living_space_create_callable(data, headers: CommonHeaders): + return { + "message": "MSG0001-INSERT", + "data": None, + "completed": True, + } + + +SuperLivingSpaceCreateEvent.event_callable = super_living_space_create_callable + + +def super_living_space_update_callable(data, headers: CommonHeaders): + return { + "message": "MSG0002-UPDATE", + "data": None, + "completed": True, + } + + +SuperLivingSpaceUpdateEvent.event_callable = super_living_space_update_callable + + +def super_living_space_delete_callable(uu_id: str, headers: CommonHeaders): + return { + "message": "MSG0003-DELETE", + "data": None, + "completed": True, + } + + +SuperLivingSpaceDeleteEvent.event_callable = super_living_space_delete_callable diff --git a/api_services/api_builds/building_service/index.py b/api_services/api_builds/building_service/index.py new file mode 100644 index 0000000..d559e34 --- /dev/null +++ b/api_services/api_builds/building_service/index.py @@ -0,0 +1,20 @@ + + +endpoints_index: dict = { + "AreaList": "31382497-e0fd-4574-9684-072a85ce8f29", + "AreaCreate": "e8b1c9ee-a25a-4434-a018-31866826f1ed", + "AreaUpdate": "c57093e1-0e0b-459b-bedf-87280c040ab1", + "AreaDelete": "e5239349-99c8-4fe1-8db9-4876abf25686", + "BuildList": "b34319e8-1829-426e-b0ab-9c6a1a3a8cbd", + "BuildCreate": "66c3ed83-ce3c-4c3c-a158-aa5bef20a3e8", + "BuildUpdate": "d0587d29-da23-4c11-a861-c27fe7f81761", + "BuildDelete": "13382948-d259-484e-b30f-3b42f9e20a42", + "LivingSpaceList": "98d9ac9e-fca4-4b0a-bf1e-ba2b3348c873", + "LivingSpaceCreate": "319e3777-4a19-4f32-b7bd-e7af3a9e541c", + "LivingSpaceUpdate": "e4873948-7aa5-46cd-9c41-42c33339f4d6", + "LivingSpaceDelete": "ead99b10-efad-4ddb-8b7c-3c9474238a20", + "PartsList": "d8bb7636-b768-4083-9313-af63fea1d1c3", + "PartsCreate": "755588f0-aabb-4be0-9a49-2be47ea4aaee", + "PartsUpdate": "44493fe1-367c-4eb9-afbf-bc7f7daca158", + "PartsDelete": "f2cea40b-295b-4a55-9b13-02c82979c53e", +} diff --git a/api_services/api_builds/identity_service/Dockerfile b/api_services/api_builds/identity_service/Dockerfile new file mode 100644 index 0000000..b1195f7 --- /dev/null +++ b/api_services/api_builds/identity_service/Dockerfile @@ -0,0 +1,31 @@ +FROM python:3.12-slim + +WORKDIR / + +# Install system dependencies and Poetry +RUN apt-get update && apt-get install -y --no-install-recommends gcc && rm -rf /var/lib/apt/lists/* && pip install --no-cache-dir poetry + +# Copy Poetry configuration +COPY /pyproject.toml ./pyproject.toml + +# Configure Poetry and install dependencies with optimizations +RUN poetry config virtualenvs.create false && poetry install --no-interaction --no-ansi --no-root --only main && pip cache purge && rm -rf ~/.cache/pypoetry + +# Copy application code +COPY /api_services/api_initializer /api_initializer +COPY /api_services/api_controllers /api_controllers +COPY /api_services/api_validations /api_validations +COPY /api_services/schemas /schemas +COPY /api_services/api_modules /api_modules + +COPY /api_services/api_middlewares /api_middlewares +COPY /api_services/api_builds/identity_service/endpoints /api_initializer/endpoints +COPY /api_services/api_builds/identity_service/events /api_initializer/events +COPY /api_services/api_builds/identity_service/validations /api_initializer/validations +COPY /api_services/api_builds/identity_service/index.py /api_initializer/index.py + +# Set Python path to include app directory +ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 + +# Run the application using the configured uvicorn server +CMD ["poetry", "run", "python", "/api_initializer/app.py"] diff --git a/api_services/api_builds/identity_service/endpoints/people/router.py b/api_services/api_builds/identity_service/endpoints/people/router.py new file mode 100644 index 0000000..f27041d --- /dev/null +++ b/api_services/api_builds/identity_service/endpoints/people/router.py @@ -0,0 +1,72 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.people.cluster import PeopleRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +people_endpoint_route = APIRouter(prefix="/people", tags=["People Cluster"]) + + +people_list = "PeopleList" +@people_endpoint_route.post( + path="/list", + description="List all people endpoint", + operation_id=endpoints_index[people_list], +) +def people_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PeopleRouterCluster.get_event_cluster(people_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +people_create = "PeopleCreate" +@people_endpoint_route.post( + path="/create", + description="Create people endpoint", + operation_id=endpoints_index[people_create], +) +def people_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PeopleRouterCluster.get_event_cluster(people_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +people_update = "PeopleUpdate" +@people_endpoint_route.post( + path="/update/{uu_id}", + description="Update people endpoint", + operation_id=endpoints_index[people_update], +) +def people_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PeopleRouterCluster.get_event_cluster(people_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, header=headers) + + +people_delete = "PeopleDelete" +@people_endpoint_route.delete( + path="/delete/{uu_id}", + description="Delete people endpoint", + operation_id=endpoints_index[people_delete], +) +def people_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = PeopleRouterCluster.get_event_cluster(people_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) diff --git a/api_services/api_builds/identity_service/endpoints/routes.py b/api_services/api_builds/identity_service/endpoints/routes.py new file mode 100644 index 0000000..4a5dae3 --- /dev/null +++ b/api_services/api_builds/identity_service/endpoints/routes.py @@ -0,0 +1,17 @@ +from fastapi import APIRouter +from .people.router import people_endpoint_route +from .user.router import user_endpoint_route + + +def get_routes() -> list[APIRouter]: + return [people_endpoint_route, user_endpoint_route] + + +def get_safe_endpoint_urls() -> list[tuple[str, str]]: + return [ + ("/", "GET"), + ("/docs", "GET"), + ("/redoc", "GET"), + ("/openapi.json", "GET"), + ("/metrics", "GET"), + ] diff --git a/api_services/api_builds/identity_service/endpoints/user/router.py b/api_services/api_builds/identity_service/endpoints/user/router.py new file mode 100644 index 0000000..17043fa --- /dev/null +++ b/api_services/api_builds/identity_service/endpoints/user/router.py @@ -0,0 +1,73 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +from events.user.cluster import UserRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +user_endpoint_route = APIRouter(prefix="/users", tags=["User Cluster"]) + + +user_list = "UserList" +@user_endpoint_route.post( + path="/list", + description="List all users endpoint", + operation_id=endpoints_index[user_list], +) +def user_list_route(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = UserRouterCluster.get_event_cluster(user_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data, headers=headers) + + +user_create = "UserCreate" +@user_endpoint_route.post( + path="/create", + description="Create user endpoint", + operation_id=endpoints_index[user_create], +) +def user_create_route(data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = UserRouterCluster.get_event_cluster(user_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(data=data, headers=headers) + + +user_update = "UserUpdate" +@user_endpoint_route.post( + path="/update/{uu_id}", + description="Update user endpoint", + operation_id=endpoints_index[user_update], +) +def user_update_route(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = UserRouterCluster.get_event_cluster(user_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, data=data, headers=headers) + + +user_delete = "UserDelete" +@user_endpoint_route.delete( + path="/delete/{uu_id}", + description="Delete user endpoint", + operation_id=endpoints_index[user_delete], +) +def user_delete_route(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders.as_dependency)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = UserRouterCluster.get_event_cluster(user_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(uu_id=uu_id, headers=headers) + diff --git a/api_services/api_builds/identity_service/events/__init__.py b/api_services/api_builds/identity_service/events/__init__.py new file mode 100644 index 0000000..df68ff9 --- /dev/null +++ b/api_services/api_builds/identity_service/events/__init__.py @@ -0,0 +1,7 @@ +from .people.cluster import PeopleRouterCluster +from .user.cluster import UserRouterCluster + +__all__ = [ + "PeopleRouterCluster", + "UserRouterCluster", +] diff --git a/api_services/api_builds/identity_service/events/people/cluster.py b/api_services/api_builds/identity_service/events/people/cluster.py new file mode 100644 index 0000000..941ff1c --- /dev/null +++ b/api_services/api_builds/identity_service/events/people/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperPeopleListEvent, + SuperPeopleCreateEvent, + SuperPeopleUpdateEvent, + SuperPeopleDeleteEvent, +) + +PeopleRouterCluster = RouterCluster(name="PeopleRouterCluster") + +PeopleListEventCluster = EventCluster(name="PeopleListEventCluster", endpoint_uu_id=endpoints_index["PeopleList"]) +PeopleListEventCluster.add_event(SuperPeopleListEvent) + +PeopleCreateEventCluster = EventCluster(name="PeopleCreateEventCluster", endpoint_uu_id=endpoints_index["PeopleCreate"]) +PeopleCreateEventCluster.add_event(SuperPeopleCreateEvent) + +PeopleUpdateEventCluster = EventCluster(name="PeopleUpdateEventCluster", endpoint_uu_id=endpoints_index["PeopleUpdate"]) +PeopleUpdateEventCluster.add_event(SuperPeopleUpdateEvent) + +PeopleDeleteEventCluster = EventCluster(name="PeopleDeleteEventCluster", endpoint_uu_id=endpoints_index["PeopleDelete"]) +PeopleDeleteEventCluster.add_event(SuperPeopleDeleteEvent) + +PeopleRouterCluster.set_event_cluster(PeopleListEventCluster) +PeopleRouterCluster.set_event_cluster(PeopleCreateEventCluster) +PeopleRouterCluster.set_event_cluster(PeopleUpdateEventCluster) +PeopleRouterCluster.set_event_cluster(PeopleDeleteEventCluster) diff --git a/api_services/api_builds/identity_service/events/people/supers_events.py b/api_services/api_builds/identity_service/events/people/supers_events.py new file mode 100644 index 0000000..1925bbb --- /dev/null +++ b/api_services/api_builds/identity_service/events/people/supers_events.py @@ -0,0 +1,114 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from api_validations.token.validations import TokenDictType +from schemas import ( + Build, + BuildLivingSpace, + BuildParts, + People, +) + + +# List all endpoint Super User +SuperPeopleListEvent = Event( + name="super_people_list", + key="0f8a8b7f-0615-4507-916b-030d48cb5c1d", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super People List all flat representative users endpoint", +) + +# Create endpoint Super User +SuperPeopleCreateEvent = Event( + name="super_people_create", + key="e18657b7-7a5a-43b8-b43a-422cbc783326", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super People Create flat representative users endpoint", +) + +# Update endpoint Super User +SuperPeopleUpdateEvent = Event( + name="super_people_update", + key="02a774aa-1f7d-472b-98f1-7b4a58d43e31", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super People Update flat representative users endpoint", +) + +# Delete endpoint Super User +SuperPeopleDeleteEvent = Event( + name="super_people_delete", + key="b56fd146-b11a-466a-84c9-4c72fb0b9ffa", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super People Delete flat representative users endpoint", +) + + +def super_people_list_callable(list_options: PaginateOnly, token: TokenDictType): + list_options = PaginateOnly(**list_options.model_dump()) + if token.is_employee: + raise Exception("Forbidden for employees") + + # TODO: Pydantic Model must be implemnted for list_options.query + with People.new_session() as db_session: + People.set_session(db_session) + db_session.query( + ).join(BuildParts, BuildParts.id == BuildLivingSpace.build_parts_id + ).join(People, People.person_id == BuildLivingSpace.people_id + ).filter() + if list_options.query: + people_list = People.query.filter(*People.convert(list_options.query)) + else: + people_list = People.query.filter() + + pagination = Pagination(data=people_list) + pagination.change(**list_options.model_dump()) + pagination_result = PaginationResult(data=people_list, pagination=pagination) + return EndpointResponse(message="MSG0003-LIST", pagination_result=pagination_result).response + + +SuperPeopleListEvent.event_callable = super_people_list_callable + + +def super_people_create_callable(data: People, token: TokenDictType): + return { + "message": "MSG0001-INSERT", + "data": None, + "completed": True, + } + + +SuperPeopleCreateEvent.event_callable = super_people_create_callable + + +def super_people_update_callable(data: People, token: TokenDictType): + return { + "message": "MSG0002-UPDATE", + "data": None, + "completed": True, + } + + +SuperPeopleUpdateEvent.event_callable = super_people_update_callable + + +def super_people_delete_callable(data: People, token: TokenDictType): + return { + "message": "MSG0004-DELETE", + "data": None, + "completed": True, + } + + +SuperPeopleDeleteEvent.event_callable = super_people_delete_callable diff --git a/api_services/api_builds/identity_service/events/user/cluster.py b/api_services/api_builds/identity_service/events/user/cluster.py new file mode 100644 index 0000000..269d2de --- /dev/null +++ b/api_services/api_builds/identity_service/events/user/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperUserListEvent, + SuperUserCreateEvent, + SuperUserUpdateEvent, + SuperUserDeleteEvent, +) + +UserRouterCluster = RouterCluster(name="UserRouterCluster") + +UserListAllEventCluster = EventCluster(name="UserListAllEventCluster", endpoint_uu_id=endpoints_index["UserList"]) +UserListAllEventCluster.add_event(SuperUserListEvent) + +UserCreateEventCluster = EventCluster(name="UserCreateEventCluster", endpoint_uu_id=endpoints_index["UserCreate"]) +UserCreateEventCluster.add_event(SuperUserCreateEvent) + +UserUpdateEventCluster = EventCluster(name="UserUpdateEventCluster", endpoint_uu_id=endpoints_index["UserUpdate"]) +UserUpdateEventCluster.add_event(SuperUserUpdateEvent) + +UserDeleteEventCluster = EventCluster(name="UserDeleteEventCluster", endpoint_uu_id=endpoints_index["UserDelete"]) +UserDeleteEventCluster.add_event(SuperUserDeleteEvent) + +UserRouterCluster.set_event_cluster(UserListAllEventCluster) +UserRouterCluster.set_event_cluster(UserCreateEventCluster) +UserRouterCluster.set_event_cluster(UserUpdateEventCluster) +UserRouterCluster.set_event_cluster(UserDeleteEventCluster) diff --git a/api_services/api_builds/identity_service/events/user/supers_events.py b/api_services/api_builds/identity_service/events/user/supers_events.py new file mode 100644 index 0000000..d3bdd59 --- /dev/null +++ b/api_services/api_builds/identity_service/events/user/supers_events.py @@ -0,0 +1,100 @@ +from typing import Any + +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from api_validations.token.validations import TokenDictType +from schemas import ( + Build, + BuildLivingSpace, + BuildParts, + Users, + UsersTokens, + People, +) + +# List all endpoint Super User +SuperUserListEvent = Event( + name="super_user_list", + key="202eec81-b382-4623-911b-709f1b841f3f", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users List all flat representative users endpoint", +) + +# Create endpoint Super User +SuperUserCreateEvent = Event( + name="super_user_create", + key="2f0a3691-114d-48b7-b166-9572fc889695", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Create flat representative users endpoint", +) + +# Update endpoint Super User +SuperUserUpdateEvent = Event( + name="super_user_update", + key="8a8c8dd6-43ad-40df-86bd-345488273f52", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Update flat representative users endpoint", +) + +# Delete endpoint Super User +SuperUserDeleteEvent = Event( + name="super_user_delete", + key="e8c77554-4b0e-491f-aab5-67a5ef670999", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Delete flat representative users endpoint", +) + + +def super_user_list_callable(list_options: PaginateOnly, token: TokenDictType): + return { + "message": "MSG0003-LIST", + "data": None, + "completed": True, + } + + +SuperUserListEvent.event_callable = super_user_list_callable + + +def super_user_create_callable(data: dict, token: TokenDictType): + return { + "message": "MSG0001-INSERT", + "data": None, + "completed": True, + } + + +SuperUserCreateEvent.event_callable = super_user_create_callable + + +def super_user_update_callable(data: dict, token: TokenDictType): + return { + "message": "MSG0002-UPDATE", + "data": None, + "completed": True, + } + + +SuperUserUpdateEvent.event_callable = super_user_update_callable + + +def super_user_delete_callable(data: dict, token: TokenDictType): + return { + "message": "MSG0004-DELETE", + "data": None, + "completed": True, + } + + +SuperUserDeleteEvent.event_callable = super_user_delete_callable diff --git a/api_services/api_builds/identity_service/index.py b/api_services/api_builds/identity_service/index.py new file mode 100644 index 0000000..a055d89 --- /dev/null +++ b/api_services/api_builds/identity_service/index.py @@ -0,0 +1,11 @@ + +endpoints_index: dict = { + "UserList": "5a4ebed3-f764-473c-bc80-57b14082b636", + "UserCreate": "4fb2e886-98b4-49c7-a388-7e0607893af7", + "UserUpdate": "d4b046ac-0a93-4804-a233-8ee616152c5a", + "UserDelete": "98d5deac-8517-42da-8ce8-6a0ed79ba915", + "PeopleList": "155d7d42-9f41-4126-be3a-c3367a507f95", + "PeopleCreate": "b4d785a7-aac7-4d55-9aa3-bac871fe7252", + "PeopleUpdate": "448e1b4e-60b4-467f-a5cc-02c37522d5cc", + "PeopleDelete": "72a59bcd-52e5-42ec-b491-59c21c5e4014", +} diff --git a/api_services/api_builds/management_service/endpoints/duty_types/router.py b/api_services/api_builds/management_service/endpoints/duty_types/router.py new file mode 100644 index 0000000..38b3b7b --- /dev/null +++ b/api_services/api_builds/management_service/endpoints/duty_types/router.py @@ -0,0 +1,13 @@ +from typing import Any +from fastapi import APIRouter, Depends + +from index import endpoints_index +# from events.services.cluster import ServicesEndpointRouterCluster + +from api_validations.defaults.validations import CommonHeaders +from api_validations.response.pagination import PaginateOnly +from api_middlewares.token_provider import TokenProvider + + +# Create API router +duty_types_route = APIRouter(prefix="/duty/types", tags=["Duty Types Cluster"]) diff --git a/api_services/api_builds/management_service/endpoints/services/router.py b/api_services/api_builds/management_service/endpoints/services/router.py index 54310d8..e8eac2c 100644 --- a/api_services/api_builds/management_service/endpoints/services/router.py +++ b/api_services/api_builds/management_service/endpoints/services/router.py @@ -2,7 +2,7 @@ from typing import Any from fastapi import APIRouter, Depends from index import endpoints_index -# from events.services.cluster import ServicesEndpointRouterCluster +from events.services.cluster import ServicesRouterCluster from api_validations.defaults.validations import CommonHeaders from api_validations.response.pagination import PaginateOnly @@ -10,4 +10,65 @@ from api_middlewares.token_provider import TokenProvider # Create API router -services_endpoint_route = APIRouter(prefix="/services", tags=["Service Cluster"]) +services_route = APIRouter(prefix="/services", tags=["Service Cluster"]) + + +services_list = "ServicesList" +@services_route.post( + path="/list", + description="List all services endpoint", + operation_id=endpoints_index[services_list], +) +def services_list(data: PaginateOnly, headers: CommonHeaders = Depends(CommonHeaders)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = ServicesRouterCluster.get_event_cluster(services_list) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data) + + +services_create = "ServicesCreate" +@services_route.post( + path="/create", + description="Create service endpoint", + operation_id=endpoints_index[services_create], +) +def services_create(data, headers: CommonHeaders = Depends(CommonHeaders)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = ServicesRouterCluster.get_event_cluster(services_create) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data) + + +services_update = "ServicesUpdate" +@services_route.post( + path="/update/{uu_id}", + description="Update service endpoint", + operation_id=endpoints_index[services_update], +) +def services_update(uu_id: str, data, headers: CommonHeaders = Depends(CommonHeaders)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = ServicesRouterCluster.get_event_cluster(services_update) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data) + + +services_delete = "ServicesDelete" +@services_route.post( + path="/delete/{uu_id}", + description="Delete service endpoint", + operation_id=endpoints_index[services_delete], +) +def services_delete(uu_id: str, headers: CommonHeaders = Depends(CommonHeaders)): + token_object = TokenProvider.get_dict_from_redis(token=headers.token) + event_founder_dict = dict(endpoint_code=headers.operation_id, token=token_object) + event_key = TokenProvider.retrieve_event_codes(**event_founder_dict) + FoundCluster = ServicesRouterCluster.get_event_cluster(services_delete) + event_cluster_matched = FoundCluster.match_event(event_key=event_key) + return event_cluster_matched.event_callable(list_options=data) + diff --git a/api_services/api_builds/management_service/events/__init__.py b/api_services/api_builds/management_service/events/__init__.py index 9015d41..5bc7106 100644 --- a/api_services/api_builds/management_service/events/__init__.py +++ b/api_services/api_builds/management_service/events/__init__.py @@ -1,3 +1,5 @@ +from .events.cluster import EventsEndpointRouterCluster +from .application.cluster import ApplicationRouterCluster +# from .services.cluster import ServicesEndpointRouterCluster - -__all__ = [] \ No newline at end of file +__all__ = ["EventsEndpointRouterCluster", "ApplicationRouterCluster"] \ No newline at end of file diff --git a/api_services/api_builds/management_service/events/application/supers_events.py b/api_services/api_builds/management_service/events/application/supers_events.py index d91970d..fa62565 100644 --- a/api_services/api_builds/management_service/events/application/supers_events.py +++ b/api_services/api_builds/management_service/events/application/supers_events.py @@ -103,10 +103,11 @@ ApplicationBindOccupantEvent = Event( def application_list_all_callable(list_options: PaginateOnly): list_options = PaginateOnly(**list_options.model_dump()) with Applications.new_session() as db_session: + Applications.set_session(db_session) if list_options.query: - applications_list = Applications.filter_all(*Applications.convert(list_options.query), db=db_session) + applications_list = Applications.query.filter(*Applications.convert(list_options.query)) else: - applications_list = Applications.filter_all(db=db_session) + applications_list = Applications.query.filter() pagination = Pagination(data=applications_list) pagination.change(**list_options.model_dump()) pagination_result = PaginationResult(data=applications_list, pagination=pagination) @@ -131,19 +132,13 @@ def application_list_available_callable(list_options: PaginateOnly): list_options.query.pop("service_uu_id__ilike", None) list_options.query.pop("service_uu_id", None) with Applications.new_session() as db_session: - service2applications = Service2Application.filter_all( - *Service2Application.convert({"service_uu_id__ilike": service_uu_id}), - db=db_session, - ) - already_events = [ - service_to_application.application_id for service_to_application in service2applications.data - ] + Service2Application.set_session(db_session) + service2applications = Service2Application.query.filter(*Service2Application.convert({"service_uu_id__ilike": service_uu_id})).all() + already_events = [service_to_application.application_id for service_to_application in service2applications] if list_options.query: - applications_list = Applications.filter_all( - *Applications.convert(list_options.query), Applications.id.not_in(already_events), db=db_session - ) + applications_list = Applications.query.filter(*Applications.convert(list_options.query), Applications.id.not_in(already_events)) else: - applications_list = Applications.filter_all(Applications.id.not_in(already_events), db=db_session) + applications_list = Applications.query.filter(Applications.id.not_in(already_events)) pagination = Pagination(data=applications_list) pagination.change(**list_options.model_dump()) pagination_result = PaginationResult(data=applications_list, pagination=pagination) @@ -167,21 +162,15 @@ def application_list_appended_callable(list_options: PaginateOnly): } list_options.query.pop("service_uu_id__ilike", None) list_options.query.pop("service_uu_id", None) - - with Applications.new_session() as db_session: - service2applications = Service2Application.filter_all( - *Service2Application.convert({"service_uu_id__ilike": service_uu_id}), - db=db_session, - ) - already_events = [ - service_to_application.application_id for service_to_application in service2applications.data - ] + with Service2Application.new_session() as db_session: + Service2Application.set_session(db_session) + Applications.set_session(db_session) + service2applications = Service2Application.query.filter(*Service2Application.convert({"service_uu_id__ilike": service_uu_id})).all() + already_events = [service_to_application.application_id for service_to_application in service2applications] if list_options.query: - applications_list = Applications.filter_all( - *Applications.convert(list_options.query), Applications.id.in_(already_events), db=db_session - ) + applications_list = Applications.query.filter(*Applications.convert(list_options.query), Applications.id.in_(already_events)) else: - applications_list = Applications.filter_all(Applications.id.in_(already_events), db=db_session) + applications_list = Applications.query.filter(Applications.id.in_(already_events)) pagination = Pagination(data=applications_list) pagination.change(**list_options.model_dump()) pagination_result = PaginationResult(data=applications_list, pagination=pagination) @@ -197,13 +186,10 @@ def application_create_callable(data: Any): """ with Applications.new_session() as db_session: created_application_dict = data.model_dump() - created_application = Applications.find_or_create( - db=db_session, - include_args=[Applications.application_for, Applications.application_code, Applications.site_url], - **created_application_dict, - ) - if created_application.meta_data.created: - created_application.save(db=db_session) + Applications.set_session(db_session) + created_application = Applications.create(**created_application_dict) + if created_application: + created_application.save() return { "completed": True, "message": "MSG0001-INSERT", @@ -224,22 +210,16 @@ def application_update_callable(data: Any, uu_id: str): Update an existing application """ with Applications.new_session() as db_session: - updated_application_dict = data.model_dump( - exclude_unset=True, exclude_none=True - ) - found_application = Applications.filter_one( - Applications.uu_id == uu_id, db=db_session - ).data + updated_application_dict = data.model_dump(exclude_unset=True, exclude_none=True) + found_application = Applications.query.filter(Applications.uu_id == uu_id).first() if not found_application: return { "completed": False, "message": "MSG0002-FOUND", "data": found_application, } - updated_application = found_application.update( - db=db_session, **updated_application_dict - ) - updated_application.save(db_session) + updated_application = found_application.update(**updated_application_dict) + updated_application.save() if updated_application.meta_data.updated: return { "completed": True, @@ -261,23 +241,32 @@ def application_register_service_callable(data: Any): Register an application to a service """ with Applications.new_session() as db_session: - event = Applications.filter_one_system(Applications.uu_id == data.application_uu_id, db=db_session) - if not event.data: + Applications.set_session(db_session) + event = Applications.query.filter(Applications.uu_id == data.application_uu_id).first() + if not event: return { "message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False, } - service = Services.filter_one_system(Services.uu_id == data.service_uu_id, db=db_session) - if not service.data: + service = Services.query.filter(Services.uu_id == data.service_uu_id).first() + if not service: return { "message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False, } - service_to_application = Service2Application.find_or_create( - db=db_session, - include_args=[Service2Application.service_uu_id, Service2Application.application_uu_id], + service_to_application = Service2Application.query.filter( + Service2Application.service_id == service.data.id, + Service2Application.application_id == event.data.id, + ).first() + if service_to_application: + return { + "message": "MSG0003-ALREADY-FOUND", + "data": data.model_dump(), + "completed": False, + } + service_to_application = Service2Application.create( service_id=service.data.id, service_uu_id=str(service.data.uu_id), application_id=event.data.id, @@ -286,13 +275,7 @@ def application_register_service_callable(data: Any): site_url=event.data.site_url, is_confirmed=True, ) - if not service_to_application.meta_data.created: - return { - "message": "MSG0003-ALREADY-FOUND", - "data": data.model_dump(), - "completed": False, - } - service_to_application.save(db=db_session) + service_to_application.save() return { "message": "MSG0003-REGISTER", "data": data.model_dump(), @@ -308,26 +291,26 @@ def application_unregister_service_callable(data: Any): Unregister an application from a service """ with Applications.new_session() as db_session: - application = Applications.filter_one_system(Applications.uu_id == data.application_uu_id, db=db_session) - if not application.data: + Applications.set_session(db_session) + application = Applications.query.filter(Applications.uu_id == data.application_uu_id).first() + if not application: return { "message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False, } - service = Services.filter_one_system(Services.uu_id == data.service_uu_id, db=db_session) - if not service.data: + service = Services.query.filter(Services.uu_id == data.service_uu_id).first() + if not service: return { "message": "MSG0003-NOT-FOUND", "data": data.model_dump(), "completed": False, } - service_to_application = Service2Application.filter_one_system( + service_to_application = Service2Application.query.filter( Service2Application.service_id == service.data.id, Service2Application.application_id == application.data.id, - db=db_session, - ) - if not service_to_application.data: + ).first() + if not service_to_application: return { "message": "MSG0003-NOT-FOUND", "data": data.model_dump(), diff --git a/api_services/api_builds/management_service/events/services/cluster.py b/api_services/api_builds/management_service/events/services/cluster.py new file mode 100644 index 0000000..68fbc11 --- /dev/null +++ b/api_services/api_builds/management_service/events/services/cluster.py @@ -0,0 +1,27 @@ +from api_initializer.event_clusters import EventCluster, RouterCluster +from index import endpoints_index +from .supers_events import ( + SuperServiceListEvent, + SuperServiceCreateEvent, + SuperServiceUpdateEvent, + SuperServiceDeleteEvent, +) + +ServicesRouterCluster = RouterCluster(name="ServicesRouterCluster") + +ServicesEventClusterList = EventCluster(name="ServicesList", endpoint_uu_id=endpoints_index["ServicesList"]) +ServicesEventClusterList.add_event(SuperServiceListEvent) + +ServicesEventClusterCreate = EventCluster(name="ServicesCreate", endpoint_uu_id=endpoints_index["ServicesCreate"]) +ServicesEventClusterCreate.add_event(SuperServiceCreateEvent) + +ServicesEventClusterUpdate = EventCluster(name="ServicesUpdate", endpoint_uu_id=endpoints_index["ServicesUpdate"]) +ServicesEventClusterUpdate.add_event(SuperServiceUpdateEvent) + +ServicesEventClusterDelete = EventCluster(name="ServicesDelete", endpoint_uu_id=endpoints_index["ServicesDelete"]) +ServicesEventClusterDelete.add_event(SuperServiceDeleteEvent) + +ServicesRouterCluster.set_event_cluster(ServicesEventClusterList) +ServicesRouterCluster.set_event_cluster(ServicesEventClusterCreate) +ServicesRouterCluster.set_event_cluster(ServicesEventClusterUpdate) +ServicesRouterCluster.set_event_cluster(ServicesEventClusterDelete) diff --git a/api_services/api_builds/management_service/events/services/supers_events.py b/api_services/api_builds/management_service/events/services/supers_events.py new file mode 100644 index 0000000..4981afe --- /dev/null +++ b/api_services/api_builds/management_service/events/services/supers_events.py @@ -0,0 +1,105 @@ +from typing import Any + +from api_validations.defaults.validations import CommonHeaders +from api_initializer.event_clusters import Event +from api_validations.response import ( + PaginateOnly, + Pagination, + PaginationResult, + PostgresResponseSingle, + PostgresResponse, + EndpointResponse +) +from schemas import ( + Events, + Event2Employee, + Event2Occupant, + Event2EmployeeExtra, + Event2OccupantExtra, + Service2Events, + Services, +) + +# List services endpoint +SuperServiceListEvent = Event( + name="super_service_list", + key="ea24f5e6-279a-47e7-a5bd-8a5c1bd72d05", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users List available events endpoint", +) + +# Create service endpoint +SuperServiceCreateEvent = Event( + name="super_service_create", + key="086051f4-f1ec-4d56-b706-09ce53d5e66c", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Create service endpoint", +) + +# Update service endpoint +SuperServiceUpdateEvent = Event( + name="super_service_update", + key="267956e5-32b7-4b60-ab75-3b56b935d5c1", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Update service endpoint", +) + +# Delete service endpoint +SuperServiceDeleteEvent = Event( + name="super_service_delete", + key="6c333122-272e-4690-9d71-7f5e14cc64c8", + request_validator=None, # TODO: Add request validator + response_validator=None, # TODO: Add response validator + description="Super Users Delete service endpoint", +) + + +def super_service_list_callable(list_options: PaginateOnly, headers: CommonHeaders): + """List available events with pagination and filtering options""" + return { + "message": "MSG0003-LIST", + "data": None, + "completed": True, + } + + +SuperServiceListEvent.event_callable = super_service_list_callable + + +def super_service_create_callable(data: Any, headers: CommonHeaders): + """Create service""" + return { + "message": "MSG0003-CREATE", + "data": None, + "completed": True, + } + + +SuperServiceCreateEvent.event_callable = super_service_create_callable + + +def super_service_update_callable(data: Any, headers: CommonHeaders): + """Update service""" + return { + "message": "MSG0003-UPDATE", + "data": None, + "completed": True, + } + + +SuperServiceUpdateEvent.event_callable = super_service_update_callable + + +def super_service_delete_callable(data: Any, headers: CommonHeaders): + """Delete service""" + return { + "message": "MSG0003-DELETE", + "data": None, + "completed": True, + } + + +SuperServiceDeleteEvent.event_callable = super_service_delete_callable diff --git a/api_services/api_builds/management_service/index.py b/api_services/api_builds/management_service/index.py index aa22357..103b2da 100644 --- a/api_services/api_builds/management_service/index.py +++ b/api_services/api_builds/management_service/index.py @@ -1,3 +1,4 @@ + endpoints_index: dict = { "AccountRecordsAll": "d538deb4-38f4-4913-a1af-bbef14cf6873", "AccountRecordsMonthly": "c0f5ccb1-1e56-4653-af13-ec0bf5e6aa51", @@ -16,4 +17,8 @@ endpoints_index: dict = { "ApplicationUpdate": "83281757-696a-41ed-9706-e145ac54c3a9", "ApplicationBindEmployee": "80427237-5ab6-4d17-8084-cdb87bda22a3", "ApplicationBindOccupant": "ae0fb101-cb13-47ab-86bd-233a5dbef269", -} \ No newline at end of file + "ServicesList": "7af16881-2c0f-463f-859f-7aca475e65eb", + "ServicesCreate": "effca319-2074-4862-bb80-dde77f0e8407", + "ServicesUpdate": "24dc83e9-c159-4bb3-8982-a8adf6555029", + "ServicesDelete": "f4c9b2c4-d18a-43c6-abf9-030f71a1c381", +} diff --git a/api_services/api_builds/restriction_service/Dockerfile b/api_services/api_builds/restriction_service/Dockerfile index 9c633a4..85d9695 100644 --- a/api_services/api_builds/restriction_service/Dockerfile +++ b/api_services/api_builds/restriction_service/Dockerfile @@ -19,10 +19,10 @@ COPY /api_services/api_modules /api_modules COPY /api_services/schemas /schemas COPY /api_services/api_middlewares /api_middlewares -COPY /api_services/api_builds/restriction-service/endpoints /api_initializer/endpoints -COPY /api_services/api_builds/restriction-service/events /api_initializer/events -COPY /api_services/api_builds/restriction-service/validations /api_initializer/validations -COPY /api_services/api_builds/restriction-service/index.py /api_initializer/index.py +COPY /api_services/api_builds/restriction_service/endpoints /api_initializer/endpoints +COPY /api_services/api_builds/restriction_service/events /api_initializer/events +COPY /api_services/api_builds/restriction_service/validations /api_initializer/validations +COPY /api_services/api_builds/restriction_service/index.py /api_initializer/index.py # Set Python path to include app directory ENV PYTHONPATH=/ PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1 diff --git a/api_services/api_builds/restriction_service/events/__init__.py b/api_services/api_builds/restriction_service/events/__init__.py index 9015d41..f809361 100644 --- a/api_services/api_builds/restriction_service/events/__init__.py +++ b/api_services/api_builds/restriction_service/events/__init__.py @@ -1,3 +1,2 @@ - __all__ = [] \ No newline at end of file diff --git a/api_services/api_initializer/config.py b/api_services/api_initializer/config.py index a9c0ea3..56e5f13 100644 --- a/api_services/api_initializer/config.py +++ b/api_services/api_initializer/config.py @@ -22,7 +22,7 @@ class Configs(BaseSettings): EMAIL_HOST: str = "" DATETIME_FORMAT: str = "" FORGOT_LINK: str = "" - ALLOW_ORIGINS: list = ["http://localhost:3000", "http://localhost:3001"] + ALLOW_ORIGINS: list = ["http://localhost:3000", "http://localhost:3001", "http://localhost:3001/api", "http://localhost:3001/api/"] VERSION: str = "0.1.001" DESCRIPTION: str = "" diff --git a/api_services/api_initializer/event_clusters.py b/api_services/api_initializer/event_clusters.py index f40c464..110fcb5 100644 --- a/api_services/api_initializer/event_clusters.py +++ b/api_services/api_initializer/event_clusters.py @@ -35,10 +35,6 @@ class EventCluster: from schemas import Events, EndpointRestriction with Events.new_session() as db_session: - # if to_save_endpoint := EndpointRestriction.filter_one( - # EndpointRestriction.operation_uu_id == self.endpoint_uu_id, - # db=db_session, - # ).data: Events.set_session(db_session) EndpointRestriction.set_session(db_session) @@ -55,27 +51,14 @@ class EventCluster: is_confirmed=True, ) print('set_events_to_database event_dict_to_save', event_dict_to_save) - - # event_found = Events.filter_one( - # Events.function_code == event_dict_to_save["function_code"], - # db=db_session, - # ).data - # if event_found: - # event_found.update(**event_dict_to_save) - # event_found.save(db=db_session) - # else: - # event_to_save_database = Events.find_or_create( - # **event_dict_to_save, - # include_args=[ - # Events.function_code, - # Events.function_class, - # Events.endpoint_code, - # Events.endpoint_uu_id, - # ] - # ) - # if event_to_save_database.meta_data.created: - # print(f"UUID: {event_to_save_database.uu_id} event is saved to {to_save_endpoint.uu_id}") - # event_to_save_database.save(db=db_session) + check_event = Events.query.filter(Events.endpoint_uu_id == event_dict_to_save["endpoint_uu_id"]).first() + if check_event: + check_event.update(**event_dict_to_save) + check_event.save() + else: + event_created = Events.create(**event_dict_to_save) + print(f"UUID: {event_created.uu_id} event is saved to {to_save_endpoint.uu_id}") + event_created.save() def match_event(self, event_key: str) -> "Event": """ diff --git a/api_services/api_middlewares/token_middleware.py b/api_services/api_middlewares/token_middleware.py index cfac8a9..950dc6a 100644 --- a/api_services/api_middlewares/token_middleware.py +++ b/api_services/api_middlewares/token_middleware.py @@ -13,12 +13,7 @@ async def token_middleware(request: Request, call_next): token = request.headers.get(api_config.ACCESS_TOKEN_TAG, None) if not token: - return JSONResponse( - content={ - "error": "EYS_0002", - }, - status_code=status.HTTP_401_UNAUTHORIZED, - ) + return JSONResponse(content={"error": "EYS_0002"}, status_code=status.HTTP_401_UNAUTHORIZED) response = await call_next(request) return response diff --git a/api_services/api_validations/response/result.py b/api_services/api_validations/response/result.py index e0cf0a5..418c8db 100644 --- a/api_services/api_validations/response/result.py +++ b/api_services/api_validations/response/result.py @@ -1,9 +1,11 @@ from typing import Optional, Union, Type, Any, Dict, TypeVar from pydantic import BaseModel from sqlalchemy.orm import Query +from sqlalchemy import asc, desc from .pagination import default_paginate_config from .base import PostgresResponse +from .pagination import PaginationConfig T = TypeVar("T") @@ -25,7 +27,7 @@ class Pagination: MAX_SIZE = default_paginate_config.MAX_SIZE def __init__(self, data: PostgresResponse): - self.data = data + self.query = data self.size: int = self.DEFAULT_SIZE self.page: int = 1 self.orderField: Optional[Union[tuple[str], list[str]]] = ["uu_id"] @@ -45,20 +47,20 @@ class Pagination: else self.DEFAULT_SIZE ) self.page = config.page - self.orderField = config.order_field - self.orderType = config.order_type + self.orderField = config.orderField + self.orderType = config.orderType self._update_page_counts() def feed(self, data: PostgresResponse) -> None: """Calculate pagination based on data source.""" - self.data = data + self.query = data self._update_page_counts() def _update_page_counts(self) -> None: """Update page counts and validate current page.""" - if self.data: - self.total_count = self.data.count - self.all_count = self.data.total_count + if self.query: + self.total_count = self.query.count() + self.all_count = self.query.count() self.size = ( self.size @@ -131,11 +133,12 @@ class PaginationResult: self, data: PostgresResponse, pagination: Pagination, + is_list: bool = True, response_model: Type[T] = None, ): - self._query = data.query + self._query = data self.pagination = pagination - self.response_type = data.is_list + self.response_type = is_list self.limit = self.pagination.size self.offset = self.pagination.size * (self.pagination.page - 1) self.order_by = self.pagination.orderField diff --git a/docker-compose.yml b/docker-compose.yml index e24512a..a9f1d44 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,35 +1,102 @@ services: - client_frontend: - container_name: client_frontend - build: - context: . - dockerfile: web_services/client_frontend/Dockerfile - networks: - - wag-services - ports: - - "3000:3000" - environment: - - NODE_ENV=development - - WEB_BASE_URL=http://localhost:3000 - - API_BASE_URL=http://localhost:3000/api - cpus: 1 - mem_limit: 2048m - management_frontend: - container_name: management_frontend + # client_frontend: + # container_name: client_frontend + # build: + # context: . + # dockerfile: web_services/client_frontend/Dockerfile + # networks: + # - wag-services + # ports: + # - "3000:3000" + # environment: + # - NODE_ENV=development + # - WEB_BASE_URL=http://localhost:3000 + # - API_BASE_URL=http://localhost:3000/api + # cpus: 1.5 + # mem_limit: 2048m + + # management_frontend: + # container_name: management_frontend + # build: + # context: . + # dockerfile: web_services/management_frontend/Dockerfile + # networks: + # - wag-services + # ports: + # - "3001:3000" + # environment: + # - NODE_ENV=development + # - WEB_BASE_URL=http://localhost:3001 + # - API_BASE_URL=http://localhost:3001/api + # cpus: 1 + # mem_limit: 2048m + + account_service: + container_name: account_service build: context: . - dockerfile: web_services/management_frontend/Dockerfile + dockerfile: api_services/api_builds/account_service/Dockerfile + env_file: + - api_env.env networks: - wag-services - ports: - - "3001:3000" environment: - - NODE_ENV=development - - WEB_BASE_URL=http://localhost:3000 - - API_BASE_URL=http://localhost:3000/api - cpus: 1 - mem_limit: 2048m + - API_PATH=app:app + - API_HOST=0.0.0.0 + - API_PORT=8004 + - API_LOG_LEVEL=info + - API_RELOAD=1 + - API_APP_NAME=evyos-account-api-gateway + - API_TITLE=WAG API Account Api Gateway + - API_DESCRIPTION=This api is serves as web account api gateway only to evyos web services. + - API_APP_URL=https://account_service + ports: + - "8004:8004" + + building_service: + container_name: building_service + build: + context: . + dockerfile: api_services/api_builds/building_service/Dockerfile + env_file: + - api_env.env + networks: + - wag-services + environment: + - API_PATH=app:app + - API_HOST=0.0.0.0 + - API_PORT=8006 + - API_LOG_LEVEL=info + - API_RELOAD=1 + - API_APP_NAME=evyos-building-api-gateway + - API_TITLE=WAG API Building Api Gateway + - API_DESCRIPTION=This api is serves as web building api gateway only to evyos web services. + - API_APP_URL=https://building_service + ports: + - "8006:8006" + + identity_service: + container_name: identity_service + build: + context: . + dockerfile: api_services/api_builds/identity_service/Dockerfile + env_file: + - api_env.env + networks: + - wag-services + environment: + - API_PATH=app:app + - API_HOST=0.0.0.0 + - API_PORT=8009 + - API_LOG_LEVEL=info + - API_RELOAD=1 + - API_APP_NAME=evyos-identity-api-gateway + - API_TITLE=WAG API Identity Api Gateway + - API_DESCRIPTION=This api is serves as web identity api gateway only to evyos web services. + - API_APP_URL=https://identity_service + ports: + - "8009:8009" auth_service: container_name: auth_service @@ -101,19 +168,107 @@ services: - "8003:8003" # restart: unless-stopped - initializer_service: - container_name: initializer_service - build: - context: . - dockerfile: api_services/api_builds/initial_service/Dockerfile - environment: - - SET_ALEMBIC=0 - networks: - - wag-services - env_file: - - api_env.env - mem_limit: 512m - cpus: 0.5 + # initializer_service: + # container_name: initializer_service + # build: + # context: . + # dockerfile: api_services/api_builds/initial_service/Dockerfile + # environment: + # - SET_ALEMBIC=0 + # networks: + # - wag-services + # env_file: + # - api_env.env + # mem_limit: 512m + # cpus: 0.5 + + # address_service: + # container_name: address_service + # build: + # context: . + # dockerfile: api_services/api_builds/address_service/Dockerfile + # env_file: + # - api_env.env + # networks: + # - wag-services + # environment: + # - API_PATH=app:app + # - API_HOST=0.0.0.0 + # - API_PORT=8009 + # - API_LOG_LEVEL=info + # - API_RELOAD=1 + # - API_APP_NAME=evyos-address-api-gateway + # - API_TITLE=WAG API Address Api Gateway + # - API_DESCRIPTION=This api is serves as web address api gateway only to evyos web services. + # - API_APP_URL=https://address_service + # ports: + # - "8009:8009" + + # decision_book_service: + # container_name: decision_book_service + # build: + # context: . + # dockerfile: api_services/api_builds/decision_book_service/Dockerfile + # env_file: + # - api_env.env + # networks: + # - wag-services + # environment: + # - API_PATH=app:app + # - API_HOST=0.0.0.0 + # - API_PORT=8007 + # - API_LOG_LEVEL=info + # - API_RELOAD=1 + # - API_APP_NAME=evyos-decision-book-api-gateway + # - API_TITLE=WAG API Decision Book Api Gateway + # - API_DESCRIPTION=This api is serves as web decision book api gateway only to evyos web services. + # - API_APP_URL=https://decision_book_service + # ports: + # - "8007:8007" + + # project_decision_book_service: + # container_name: project_decision_book_service + # build: + # context: . + # dockerfile: api_services/api_builds/project_decision_book_service/Dockerfile + # env_file: + # - api_env.env + # networks: + # - wag-services + # environment: + # - API_PATH=app:app + # - API_HOST=0.0.0.0 + # - API_PORT=8008 + # - API_LOG_LEVEL=info + # - API_RELOAD=1 + # - API_APP_NAME=evyos-project-decision-book-api-gateway + # - API_TITLE=WAG API Project Decision Book Api Gateway + # - API_DESCRIPTION=This api is serves as web project decision book api gateway only to evyos web services. + # - API_APP_URL=https://project_decision_book_service + # ports: + # - "8008:8008" + + # company_service: + # container_name: company_service + # build: + # context: . + # dockerfile: api_services/api_builds/company_service/Dockerfile + # env_file: + # - api_env.env + # networks: + # - wag-services + # environment: + # - API_PATH=app:app + # - API_HOST=0.0.0.0 + # - API_PORT=8005 + # - API_LOG_LEVEL=info + # - API_RELOAD=1 + # - API_APP_NAME=evyos-company-api-gateway + # - API_TITLE=WAG API Company Api Gateway + # - API_DESCRIPTION=This api is serves as web company api gateway only to evyos web services. + # - API_APP_URL=https://company_service + # ports: + # - "8005:8005" networks: wag-services: diff --git a/menuSchema.tsx b/menuSchema.tsx new file mode 100644 index 0000000..f0e8221 --- /dev/null +++ b/menuSchema.tsx @@ -0,0 +1,99 @@ + +// Toplanti Başkani Toplanti Başkani MT-PRS +// Toplanti Katip Toplantida tutanak tutan kişi MT-WRT +// Toplanti Katilimcisi Toplantida sadece katilan kişi MT-ATT +// Toplanti Danişman Toplantida danişmanlik yapan kişi MT-ADV +// Toplanti Seçilmiş Başkani Toplanti Seçilmiş Başkani MT-VPR +// Daire Sahibi Daire Sahibi FL-OWN +// Daire Kiracisi Daire Kiracisi FL-TEN +// Daire Sakini Daire Sakini FL-RES +// Daire Sakini Vekili Daire Sakini Vekili FL-REP +// Bina Avukati Bina Avukati BU-ATT +// Bina Avukati Yardimcisi Bina Avukati Yardimcisi BU-ATA +// Bina Denetmen Yardimcisi Bina Denetmen Yardimcisi BU-SPA +// Bina Denetmeni Bina Denetmeni BU-SPV +// Bina Yönetici Yardimcisi Bina Yönetici Yardimcisi BU-MNA +// Bina Yöneticisi Bina Yöneticisi BU-MNG +// Bina Muhasabecisi Bina Muhasabecisi BU-ACC +// Proje Lideri Proje Lideri PRJ-LDR +// Proje Sorumlusu Proje Sorumlusu PRJ-RES +// Proje Ekibi Proje Ekibi PRJ-EMP +// Proje Finans Sorumlusu Proje Finans Sorumlusu PRJ-FIN +// Proje Teknik Sorumlusu Proje Teknik Sorumlusu PRJ-TEC +// Daire Mülkiyet Vekili Daire Mülkiyet Vekili FL-DEP +// Bina Teknik Sorumlusu Bina Teknik Sorumlusu BU-TEC +// Bina Teknik Elemani Bina Teknik Elemani BU-EMP +// Bina Teknik Freelancer Bina Teknik Freelancer BU-FLC + + +const occ_types = { + "MT-PRS": "Toplanti Başkani", + "MT-WRT": "Toplanti Katip", + "MT-ATT": "Toplanti Katilimcisi", + "MT-ADV": "Toplanti Danişman", + "MT-VPR": "Toplanti Seçilmiş Başkani", + "FL-OWN": "Daire Sahibi", + "FL-TEN": "Daire Kiracisi", + "FL-RES": "Daire Sakini", + "FL-REP": "Daire Sakini Vekili", + "BU-ATT": "Bina Avukati", + "BU-ATA": "Bina Avukati Yardimcisi", + "BU-SPA": "Bina Denetmen Yardimcisi", + "BU-SPV": "Bina Denetmeni", + "BU-MNA": "Bina Yönetici Yardimcisi", + "BU-MNG": "Bina Yöneticisi", + "BU-ACC": "Bina Muhasabecisi", + "PRJ-LDR": "Proje Lideri", + "PRJ-RES": "Proje Sorumlusu", + "PRJ-EMP": "Proje Ekibi", + "PRJ-FIN": "Proje Finans Sorumlusu", + "PRJ-TEC": "Proje Teknik Sorumlusu", + "FL-DEP": "Daire Mülkiyet Vekili", + "BU-TEC": "Bina Teknik Sorumlusu", + "BU-EMP": "Bina Teknik Elemani", + "BU-FLC": "Bina Teknik Freelancer", +} + + +const thirdMenuItems = { + "Birey": { + + }, + "Yetki": [ + + ], + "Apartman": [ + + ], + "Daire": [ + + ], + "Alan": [ + + ], + "Yönetim Cari Hareketler": [ + + ], + "Yönetim Bütçe işlemleri": [ + + ], + "Daire cari Hareketler": [ + + ], + "Yillik Olağan Toplanti Tanimlama ve Davet": [ + + ], + "Yillik Olağan Toplanti kapatma ve Cari Yaratma": [ + + ], + "Acil Toplanti Tanimlama ve Davet": [ + + ], + "Acil Olağan Toplanti kapatma ve Cari Yaratma": [ + + ], + "Toplanti Katilim İşlemleri": [ + + ], +} + diff --git a/web_services/client_frontend/src/apicalls/basics.ts b/web_services/client_frontend/src/apicalls/basics.ts index b74f7a2..76caca8 100644 --- a/web_services/client_frontend/src/apicalls/basics.ts +++ b/web_services/client_frontend/src/apicalls/basics.ts @@ -6,11 +6,20 @@ const formatServiceUrl = (url: string) => { const baseUrlAuth = formatServiceUrl( process.env.NEXT_PUBLIC_AUTH_SERVICE_URL || "auth_service:8001" ); -const baseUrlPeople = formatServiceUrl( - process.env.NEXT_PUBLIC_VALIDATION_SERVICE_URL || "identity_service:8002" +const baseUrlRestriction = formatServiceUrl( + process.env.NEXT_PUBLIC_RESTRICTION_SERVICE_URL || "restriction_service:8002" ); const baseUrlApplication = formatServiceUrl( - process.env.NEXT_PUBLIC_MANAGEMENT_SERVICE_URL || "management_service:8004" + process.env.NEXT_PUBLIC_MANAGEMENT_SERVICE_URL || "management_service:8003" +); +const baseUrlAccount = formatServiceUrl( + process.env.NEXT_PUBLIC_ACCOUNT_SERVICE_URL || "account_service:8004" +); +const baseUrlBuilding = formatServiceUrl( + process.env.NEXT_PUBLIC_BUILDING_SERVICE_URL || "building_service:8006" +); +const baseUrlPeople = formatServiceUrl( + process.env.NEXT_PUBLIC_VALIDATION_SERVICE_URL || "identity_service:8009" ); // Types for better type safety @@ -62,6 +71,9 @@ export { baseUrlAuth, baseUrlPeople, baseUrlApplication, + baseUrlAccount, + baseUrlBuilding, + baseUrlRestriction, tokenSecret, cookieObject, }; diff --git a/web_services/client_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx b/web_services/client_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx index fa0144b..4cf93a8 100644 --- a/web_services/client_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx +++ b/web_services/client_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx @@ -2,12 +2,12 @@ import { ContentProps } from "@/validations/mutual/dashboard/props"; import ContentToRenderNoPage from "@/pages/mutual/noContent/page"; import { resolveWhichPageToRenderSingle } from "@/pages/resolver/resolver"; -const PageToBeChildrendSingle: React.FC = ({ lang, translations, activePageUrl }) => { - const ApplicationToRender = resolveWhichPageToRenderSingle({ activePageUrl }) +const PageToBeChildrendSingle: React.FC = async ({ lang, translations, activePageUrl, mode }) => { + const ApplicationToRender = await resolveWhichPageToRenderSingle({ activePageUrl }) if (ApplicationToRender) { - return + return } - else { return } + return } export default PageToBeChildrendSingle diff --git a/web_services/client_frontend/src/components/custom/content/component.tsx b/web_services/client_frontend/src/components/custom/content/component.tsx index f993788..144b836 100644 --- a/web_services/client_frontend/src/components/custom/content/component.tsx +++ b/web_services/client_frontend/src/components/custom/content/component.tsx @@ -6,7 +6,7 @@ import PageToBeChildrendSingle from "./PageToBeChildrendSingle"; import PageToBeChildrendMulti from "./PageToBeChildrendMulti"; const ContentComponent: FC = async ({ lang, translations, activePageUrl, isMulti, mode }) => { - const modeFromQuery = ModeTypesList.includes(mode || '') ? mode : 'list' + const modeFromQuery = ModeTypesList.includes(mode || '') ? mode : 'shortList' const renderProps = { lang, translations, activePageUrl, mode: modeFromQuery as ModeTypes } const PageToBeChildrend = isMulti ? PageToBeChildrendMulti : PageToBeChildrendSingle const loadingContent = diff --git a/web_services/client_frontend/src/pages/resolver/resolver.tsx b/web_services/client_frontend/src/pages/resolver/resolver.tsx index e066f99..4edac01 100644 --- a/web_services/client_frontend/src/pages/resolver/resolver.tsx +++ b/web_services/client_frontend/src/pages/resolver/resolver.tsx @@ -5,17 +5,18 @@ import { ContentProps } from "@/validations/mutual/dashboard/props"; import pageIndexMulti from "@/pages/multi/index"; import pageIndexSingle from "@/pages/single/index"; +import ContentToRenderNoPage from "@/pages/mutual/noContent/page"; -function resolveWhichPageToRenderSingle({ - activePageUrl, -}: ResolverProps): React.FC { - const ApplicationToRender = pageIndexSingle[activePageUrl] - return ApplicationToRender +async function resolveWhichPageToRenderSingle({ activePageUrl }: ResolverProps): Promise | null> { + try { + return `${activePageUrl}` in pageIndexSingle ? pageIndexSingle[`${activePageUrl}`] : ContentToRenderNoPage + } catch (error) { + console.error(error) + } + return ContentToRenderNoPage } -async function resolveWhichPageToRenderMulti({ - activePageUrl, -}: ResolverProps): Promise | null> { +async function resolveWhichPageToRenderMulti({ activePageUrl }: ResolverProps): Promise | null> { const pageToRender = await retrievePageToRender(activePageUrl) // TODO: Retrieve page to render try { const ApplicationToRender = pageIndexMulti[activePageUrl][pageToRender] @@ -23,7 +24,7 @@ async function resolveWhichPageToRenderMulti({ } catch (error) { console.error(error) } - return null + return ContentToRenderNoPage } export { resolveWhichPageToRenderSingle, resolveWhichPageToRenderMulti }; diff --git a/web_services/management_frontend/src/apicalls/basics.ts b/web_services/management_frontend/src/apicalls/basics.ts index b74f7a2..76caca8 100644 --- a/web_services/management_frontend/src/apicalls/basics.ts +++ b/web_services/management_frontend/src/apicalls/basics.ts @@ -6,11 +6,20 @@ const formatServiceUrl = (url: string) => { const baseUrlAuth = formatServiceUrl( process.env.NEXT_PUBLIC_AUTH_SERVICE_URL || "auth_service:8001" ); -const baseUrlPeople = formatServiceUrl( - process.env.NEXT_PUBLIC_VALIDATION_SERVICE_URL || "identity_service:8002" +const baseUrlRestriction = formatServiceUrl( + process.env.NEXT_PUBLIC_RESTRICTION_SERVICE_URL || "restriction_service:8002" ); const baseUrlApplication = formatServiceUrl( - process.env.NEXT_PUBLIC_MANAGEMENT_SERVICE_URL || "management_service:8004" + process.env.NEXT_PUBLIC_MANAGEMENT_SERVICE_URL || "management_service:8003" +); +const baseUrlAccount = formatServiceUrl( + process.env.NEXT_PUBLIC_ACCOUNT_SERVICE_URL || "account_service:8004" +); +const baseUrlBuilding = formatServiceUrl( + process.env.NEXT_PUBLIC_BUILDING_SERVICE_URL || "building_service:8006" +); +const baseUrlPeople = formatServiceUrl( + process.env.NEXT_PUBLIC_VALIDATION_SERVICE_URL || "identity_service:8009" ); // Types for better type safety @@ -62,6 +71,9 @@ export { baseUrlAuth, baseUrlPeople, baseUrlApplication, + baseUrlAccount, + baseUrlBuilding, + baseUrlRestriction, tokenSecret, cookieObject, }; diff --git a/web_services/management_frontend/src/apicalls/custom/application/apicall.tsx b/web_services/management_frontend/src/apicalls/custom/application/apicall.tsx index 3ed0cfb..adc7fcd 100644 --- a/web_services/management_frontend/src/apicalls/custom/application/apicall.tsx +++ b/web_services/management_frontend/src/apicalls/custom/application/apicall.tsx @@ -26,7 +26,6 @@ interface AppendApplicationToService { interface RemoveApplicationFromService extends AppendApplicationToService { } - async function listApplicationsAvailable(payload: PaginationParams): Promise> { if (!payload.query.service_uu_id__ilike) { console.warn('Missing service_uu_id in query parameters'); @@ -135,8 +134,8 @@ async function listAllApplications(payload: PaginationParams): Promise; - console.log('list_events_available responseData:', JSON.stringify(responseData, null, 2)); return { data: responseData.data || [], pagination: collectPaginationFromApiResponse(responseData) diff --git a/web_services/management_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx b/web_services/management_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx index fa0144b..c08e6bd 100644 --- a/web_services/management_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx +++ b/web_services/management_frontend/src/components/custom/content/PageToBeChildrendSingle.tsx @@ -2,12 +2,10 @@ import { ContentProps } from "@/validations/mutual/dashboard/props"; import ContentToRenderNoPage from "@/pages/mutual/noContent/page"; import { resolveWhichPageToRenderSingle } from "@/pages/resolver/resolver"; -const PageToBeChildrendSingle: React.FC = ({ lang, translations, activePageUrl }) => { - const ApplicationToRender = resolveWhichPageToRenderSingle({ activePageUrl }) - if (ApplicationToRender) { - return - } - else { return } +const PageToBeChildrendSingle: React.FC = async ({ lang, translations, activePageUrl, mode }) => { + const ApplicationToRender = await resolveWhichPageToRenderSingle({ activePageUrl }) + if (!ApplicationToRender) return + return } export default PageToBeChildrendSingle diff --git a/web_services/management_frontend/src/components/custom/content/component.tsx b/web_services/management_frontend/src/components/custom/content/component.tsx index dd7db2d..d640ecc 100644 --- a/web_services/management_frontend/src/components/custom/content/component.tsx +++ b/web_services/management_frontend/src/components/custom/content/component.tsx @@ -6,12 +6,14 @@ import PageToBeChildrendSingle from "./PageToBeChildrendSingle"; import PageToBeChildrendMulti from "./PageToBeChildrendMulti"; const ContentComponent: FC = async ({ lang, translations, activePageUrl, isMulti, mode }) => { - const modeFromQuery = ModeTypesList.includes(mode || '') ? mode : 'list' + const modeFromQuery = ModeTypesList.includes(mode || '') ? mode : 'shortList' const renderProps = { lang, translations, activePageUrl, mode: modeFromQuery as ModeTypes } const PageToBeChildrend = isMulti ? PageToBeChildrendMulti : PageToBeChildrendSingle const loadingContent = const classNameDiv = "fixed top-24 left-80 right-0 py-10 px-15 border-emerald-150 border-l-2 overflow-y-auto h-[calc(100vh-64px)]" return
; + + // return
; }; export default ContentComponent; diff --git a/web_services/management_frontend/src/components/custom/menu/single/component.tsx b/web_services/management_frontend/src/components/custom/menu/single/component.tsx index 00f56e2..e112688 100644 --- a/web_services/management_frontend/src/components/custom/menu/single/component.tsx +++ b/web_services/management_frontend/src/components/custom/menu/single/component.tsx @@ -6,7 +6,6 @@ import { MenuSingleProps, SingleLayerItemProps } from "@/validations/mutual/dash import { langGetKey } from "@/lib/langGet"; const SingleLayerItem: FC = ({ isActive, innerText, url }) => { - console.log({ isActive, innerText, url }) let className = "py-3 px-4 text-sm rounded-xl cursor-pointer transition-colors duration-200 flex justify-between items-center w-full"; if (isActive) { className += " bg-black text-white font-medium" } else { className += " bg-emerald-800 text-white hover:bg-emerald-700" } diff --git a/web_services/management_frontend/src/components/mutual/tableView/FullTableComp/component.tsx b/web_services/management_frontend/src/components/mutual/tableView/FullTableComp/component.tsx index ef3b873..735fb2d 100644 --- a/web_services/management_frontend/src/components/mutual/tableView/FullTableComp/component.tsx +++ b/web_services/management_frontend/src/components/mutual/tableView/FullTableComp/component.tsx @@ -44,7 +44,9 @@ const TableComponent: React.FC = ({ setPagination({ ...pagination, page: pagination.page < apiPagination.totalPage ? pagination.page + 1 : pagination.page }); await fetchData(); } + const fetchData = async () => { + console.log('urls', urls) const response = await apiPostFetcher({ url: urls.list, isNoCache: true, @@ -56,8 +58,9 @@ const TableComponent: React.FC = ({ query: pagination.query, }, }); - if (response && response.data) { - const oldData = response.data.data + console.log('response.data', response) + if (response.success && response.data) { + const oldData = response.data setOrgTableData(oldData) if (schemas.table) { const newData = Object.entries(oldData).map(([key]) => { diff --git a/web_services/management_frontend/src/components/mutual/tableView/mutual/CreateForm.tsx b/web_services/management_frontend/src/components/mutual/tableView/mutual/CreateForm.tsx index 7e33fd1..75c666b 100644 --- a/web_services/management_frontend/src/components/mutual/tableView/mutual/CreateForm.tsx +++ b/web_services/management_frontend/src/components/mutual/tableView/mutual/CreateForm.tsx @@ -18,7 +18,7 @@ const CreateForm: React.FC = ({ schemas, labels, selectedRow }) const handleSubmit = (data: any) => { console.log(data) } - const form = useForm({ + const form = useForm({ resolver: zodResolver(createSchema), defaultValues: {}, }); diff --git a/web_services/management_frontend/src/components/mutual/tableView/mutual/TablePlain.tsx b/web_services/management_frontend/src/components/mutual/tableView/mutual/TablePlain.tsx index b0b9468..152050d 100644 --- a/web_services/management_frontend/src/components/mutual/tableView/mutual/TablePlain.tsx +++ b/web_services/management_frontend/src/components/mutual/tableView/mutual/TablePlain.tsx @@ -11,30 +11,18 @@ const ComponentTablePlain: React.FC = ({ setTableData(data); }, [data]); - const renderColumns = () => { - return [translations?.rows, ...columns].map((column, index) => { - return ( - {column} - ) - }) - } + const renderColumns = () => [translations?.rows, ...columns].map((column, index) => {column}) const renderRows = () => ( <>{tableData?.map((item: any, index: number) => { return ( {index + 1} { - Object.entries(item).map(([key, value]: [string, any]) => ( - {value} - )) + Object.entries(item).map(([key, value]: [string, any]) => ({value})) } - { Object.values(redirectUrls?.table || {}).map((redirectUrl: any, index: number) => { - return ( - setSelectedRow?.(orgData[index])}>{redirectUrl} - ) + return setSelectedRow?.(orgData[index])}>{redirectUrl} }) } @@ -48,9 +36,7 @@ const ComponentTablePlain: React.FC = ({ return ( <>
- {Object.values(redirectUrls?.page || {}).map((action, index) => ( -
{action}
- ))} + {Object.values(redirectUrls?.page || {}).map((action, index) => (
{action}
))}
{tableData ? renderTable : noDataFound} diff --git a/web_services/management_frontend/src/components/mutual/tableView/mutual/UpdateForm.tsx b/web_services/management_frontend/src/components/mutual/tableView/mutual/UpdateForm.tsx index 3b6799f..31d9990 100644 --- a/web_services/management_frontend/src/components/mutual/tableView/mutual/UpdateForm.tsx +++ b/web_services/management_frontend/src/components/mutual/tableView/mutual/UpdateForm.tsx @@ -26,7 +26,7 @@ const UpdateForm: React.FC = ({ schemas, selectedRow, rollbackT const handleSubmit = (data: any) => { console.log(data) } - const form = useForm({ + const form = useForm({ resolver: zodResolver(updateSchema), defaultValues: selectedRow, }); diff --git a/web_services/management_frontend/src/config/config.ts b/web_services/management_frontend/src/config/config.ts index 766d82e..ed229f3 100644 --- a/web_services/management_frontend/src/config/config.ts +++ b/web_services/management_frontend/src/config/config.ts @@ -1,4 +1,4 @@ -const BASE_URL = "http://localhost:3000"; -const API_URL = "http://localhost:3000/api"; +const BASE_URL = "http://localhost:3001"; +const API_URL = "http://localhost:3001/api"; export const WEB_BASE_URL = process.env.WEB_BASE_URL || BASE_URL; export const API_BASE_URL = process.env.API_BASE_URL || API_URL; diff --git a/web_services/management_frontend/src/languages/custom/application/english.ts b/web_services/management_frontend/src/languages/custom/application/english.ts new file mode 100644 index 0000000..508d4dc --- /dev/null +++ b/web_services/management_frontend/src/languages/custom/application/english.ts @@ -0,0 +1,52 @@ +import { footerDefaultEn } from "@/languages/mutual/footer/english"; +import { headerDefaultEn } from "@/languages/mutual/header/english"; +import { contentDefaultEn } from "@/languages/mutual/content/english"; + +const contentApplicationEn = { + ...contentDefaultEn, + title: "Application", + content: "Application Content", + button: "Application Button", +}; +const footerApplicationEn = { + ...footerDefaultEn, + page: "Application Footer", +}; +const headerApplicationEn = { + ...headerDefaultEn, + page: "Application Header", +}; + +const menuApplicationEn = { + application: "Application", +}; + +const applicationEn = { + header: headerApplicationEn, + menu: menuApplicationEn, + content: contentApplicationEn, + footer: footerApplicationEn, +}; + +const applicationFieldsEn = { + uu_id: "UUID", + name: "Name", + application_code: "Application Code", + site_url: "Site URL", + application_type: "Application Type", + application_for: "Application For", + description: "Description", + active: "Active", + deleted: "Deleted", + created_at: "Created At", + updated_at: "Updated At", +}; + +export { + contentApplicationEn, + footerApplicationEn, + headerApplicationEn, + menuApplicationEn, + applicationEn, + applicationFieldsEn, +}; diff --git a/web_services/management_frontend/src/languages/custom/application/index.ts b/web_services/management_frontend/src/languages/custom/application/index.ts new file mode 100644 index 0000000..eecfe8c --- /dev/null +++ b/web_services/management_frontend/src/languages/custom/application/index.ts @@ -0,0 +1,9 @@ +import { applicationTr } from "./turkish"; +import { applicationEn } from "./english"; + +const application = { + tr: applicationTr, + en: applicationEn, +}; + +export { application }; diff --git a/web_services/management_frontend/src/languages/custom/application/turkish.ts b/web_services/management_frontend/src/languages/custom/application/turkish.ts new file mode 100644 index 0000000..e255fbe --- /dev/null +++ b/web_services/management_frontend/src/languages/custom/application/turkish.ts @@ -0,0 +1,51 @@ +import { footerDefaultTr } from "@/languages/mutual/footer/turkish"; +import { headerDefaultTr } from "@/languages/mutual/header/turkish"; +import { contentDefaultTr } from "@/languages/mutual/content/turkish"; + +const contentApplicationTr = { + ...contentDefaultTr, + title: "Uygulama", + description: "Uygulama", + button: "Uygulama Buton", +}; +const footerApplicationTr = { + ...footerDefaultTr, + page: "Uygulama Footer", +}; +const headerApplicationTr = { + ...headerDefaultTr, + page: "Uygulama Header", +}; + +const menuApplicationTr = { + application: "Uygulama", +}; +const applicationTr = { + header: headerApplicationTr, + menu: menuApplicationTr, + content: contentApplicationTr, + footer: footerApplicationTr, +}; + +const applicationFieldsTr = { + uu_id: "UUID", + name: "İsim", + application_code: "Uygulama Kodu", + site_url: "Site URL", + application_type: "Uygulama Tipi", + application_for: "Uygulama için", + description: "Açıklama", + active: "Aktif", + deleted: "Silindi", + created_at: "Oluşturulma Tarihi", + updated_at: "Güncellenme Tarihi", +}; + +export { + contentApplicationTr, + footerApplicationTr, + headerApplicationTr, + menuApplicationTr, + applicationTr, + applicationFieldsTr, +}; diff --git a/web_services/management_frontend/src/languages/custom/building/english.ts b/web_services/management_frontend/src/languages/custom/building/english.ts deleted file mode 100644 index e38d477..0000000 --- a/web_services/management_frontend/src/languages/custom/building/english.ts +++ /dev/null @@ -1,24 +0,0 @@ -const buildingEn = { - building: "Building First Layer Label", -}; - -const buildingPartsEn = { - ...buildingEn, - parts: "Parts Second Layer Label", -}; - -const buildingPartsFieldsEn = { - "Users.uuid": "UUID", - "Users.firstName": "First Name", - "Users.lastName": "Last Name", - "Users.email": "Email", - "Users.phoneNumber": "Phone Number", - "Users.country": "Country", - "Users.description": "Description", - "Users.isDeleted": "Is Deleted", - "Users.isConfirmed": "Is Confirmed", - "Users.createdAt": "Created At", - "Users.updatedAt": "Updated At", -}; - -export { buildingEn, buildingPartsEn, buildingPartsFieldsEn }; diff --git a/web_services/management_frontend/src/languages/custom/building/turkish.ts b/web_services/management_frontend/src/languages/custom/building/turkish.ts deleted file mode 100644 index bd65725..0000000 --- a/web_services/management_frontend/src/languages/custom/building/turkish.ts +++ /dev/null @@ -1,23 +0,0 @@ -const buildingTr = { - building: "Bina Birinci Seviye", -}; -const buildingPartsTr = { - ...buildingTr, - parts: "Parçalar İkinci Seviye", -}; - -const buildingPartsFieldsTr = { - "Users.uuid": "UUID", - "Users.firstName": "Ad", - "Users.lastName": "Soyad", - "Users.email": "Email", - "Users.phoneNumber": "Telefon Numarası", - "Users.country": "Ülke", - "Users.description": "Açıklama", - "Users.isDeleted": "Silindi", - "Users.isConfirmed": "Onaylandı", - "Users.createdAt": "Oluşturulma Tarihi", - "Users.updatedAt": "Güncellenme Tarihi", -}; - -export { buildingTr, buildingPartsTr, buildingPartsFieldsTr }; diff --git a/web_services/management_frontend/src/languages/custom/index.ts b/web_services/management_frontend/src/languages/custom/index.ts index 2595e14..936f98c 100644 --- a/web_services/management_frontend/src/languages/custom/index.ts +++ b/web_services/management_frontend/src/languages/custom/index.ts @@ -1,12 +1,11 @@ import { LanguageTypes } from "@/validations/mutual/language/validations"; import { DynamicPage } from "@/validations/mutual/menu/menu"; -import { managementAccountTenantMain } from "./management/account/tenantSomething/index"; -import { managementAccountTenantMainSecond } from "./management/account/tenantSomethingSecond/index"; +import { application } from "./application"; const dynamicPagesIndex: Record> = { - dashboard: managementAccountTenantMain, - application: managementAccountTenantMain, - services: managementAccountTenantMainSecond, + dashboard: application, + application: application, + services: application, }; export { dynamicPagesIndex }; diff --git a/web_services/management_frontend/src/languages/custom/management/account/a copy.txt b/web_services/management_frontend/src/languages/custom/management/account/a copy.txt deleted file mode 100644 index e69de29..0000000 diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/english.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/english.ts deleted file mode 100644 index 4b7f805..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/english.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { footerDefaultEn } from "@/languages/mutual/footer/english"; -import { headerDefaultEn } from "@/languages/mutual/header/english"; -import { managementAccountEn, managementAccountFieldsEn } from "../../english"; -import { contentDefaultEn } from "@/languages/mutual/content/english"; - -const contentManagementAccountTenantSomethingEn = { - ...managementAccountFieldsEn, - title: "Management Account Tenant Something", - content: "Management Account Tenant Something Content", - button: "Management Account Tenant Something Button", -}; -const footerManagementAccountTenantSomethingEn = { - ...footerDefaultEn, - page: "Management Account Tenant Something Footer", -}; -const headerManagementAccountTenantSomethingEn = { - ...headerDefaultEn, - page: "Management Account Tenant Something Header", -}; - -const menuManagementAccountTenantSomethingEn = { - ...managementAccountEn, - "tenant/something": "Tenant Info", -}; - -const managementAccountTenantMainEn = { - header: headerManagementAccountTenantSomethingEn, - menu: menuManagementAccountTenantSomethingEn, - content: contentManagementAccountTenantSomethingEn, - footer: footerManagementAccountTenantSomethingEn, -}; - -export { - contentManagementAccountTenantSomethingEn, - footerManagementAccountTenantSomethingEn, - headerManagementAccountTenantSomethingEn, - menuManagementAccountTenantSomethingEn, - managementAccountTenantMainEn, -}; diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/index.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/index.ts deleted file mode 100644 index c9da0fe..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { managementAccountTenantMainTr } from "./turkish"; -import { managementAccountTenantMainEn } from "./english"; - -const managementAccountTenantMain = { - tr: managementAccountTenantMainTr, - en: managementAccountTenantMainEn, -} - -export { managementAccountTenantMain } diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/turkish.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/turkish.ts deleted file mode 100644 index 7253171..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomething/turkish.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { footerDefaultTr } from "@/languages/mutual/footer/turkish"; -import { headerDefaultTr } from "@/languages/mutual/header/turkish"; -import { managementAccountTr } from "../../turkish"; - -const contentManagementAccountTenantSomethingTr = { - title: "Yönetim Hesap Kiracı Bilgileri", - description: "Yönetim Hesap Kiracı Bilgileri", - button: "Yönetim Hesap Kiracı Bilgileri Buton", -}; -const footerManagementAccountTenantSomethingTr = { - ...footerDefaultTr, - page: "Yönetim Hesap Kiracı Bilgileri Footer", -}; -const headerManagementAccountTenantSomethingTr = { - ...headerDefaultTr, - page: "Yönetim Hesap Kiracı Bilgileri Header", -}; - -const menuManagementAccountTenantSomethingTr = { - ...managementAccountTr, - "tenant/something": "Kiracı Bilgileri", -}; -const managementAccountTenantMainTr = { - header: headerManagementAccountTenantSomethingTr, - menu: menuManagementAccountTenantSomethingTr, - content: contentManagementAccountTenantSomethingTr, - footer: footerManagementAccountTenantSomethingTr, -}; - -export { - contentManagementAccountTenantSomethingTr, - footerManagementAccountTenantSomethingTr, - headerManagementAccountTenantSomethingTr, - menuManagementAccountTenantSomethingTr, - managementAccountTenantMainTr, -}; diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/english.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/english.ts deleted file mode 100644 index 3c4a97b..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/english.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { footerDefaultEn } from "@/languages/mutual/footer/english"; -import { headerDefaultEn } from "@/languages/mutual/header/english"; -import { contentDefaultEn } from "@/languages/mutual/content/english"; -import { managementAccountEn, managementAccountFieldsEn } from "../../english"; - -const contentManagementAccountTenantSomethingSecondEn = { - ...contentDefaultEn, - ...managementAccountFieldsEn, - title: "Management Account Tenant Something", - content: "Management Account Tenant Something Content", - button: "Management Account Tenant Something Button", -}; -const footerManagementAccountTenantSomethingSecondEn = { - ...footerDefaultEn, - page: "Management Account Tenant Something Second Footer", -}; -const headerManagementAccountTenantSomethingSecondEn = { - ...headerDefaultEn, - page: "Management Account Tenant Something Second Header", -}; - -const menuManagementAccountTenantSomethingSecondEn = { - ...managementAccountEn, - "tenant/somethingSecond": "Tenant Info Second", -}; - -const managementAccountTenantMainSecondEn = { - header: headerManagementAccountTenantSomethingSecondEn, - menu: menuManagementAccountTenantSomethingSecondEn, - content: contentManagementAccountTenantSomethingSecondEn, - footer: footerManagementAccountTenantSomethingSecondEn, -}; - -export { - contentManagementAccountTenantSomethingSecondEn, - footerManagementAccountTenantSomethingSecondEn, - headerManagementAccountTenantSomethingSecondEn, - menuManagementAccountTenantSomethingSecondEn, - managementAccountTenantMainSecondEn, -}; diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/index.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/index.ts deleted file mode 100644 index 2fb2256..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { managementAccountTenantMainSecondTr } from "./turkish"; -import { managementAccountTenantMainSecondEn } from "./english"; - -const managementAccountTenantMainSecond = { - tr: managementAccountTenantMainSecondTr, - en: managementAccountTenantMainSecondEn, -}; - -export { managementAccountTenantMainSecond }; diff --git a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/turkish.ts b/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/turkish.ts deleted file mode 100644 index 5b29633..0000000 --- a/web_services/management_frontend/src/languages/custom/management/account/tenantSomethingSecond/turkish.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { footerDefaultTr } from "@/languages/mutual/footer/turkish"; -import { headerDefaultTr } from "@/languages/mutual/header/turkish"; -import { managementAccountTr, managementAccountFieldsTr } from "../../turkish"; - -const contentManagementAccountTenantSomethingSecondTr = { - ...managementAccountFieldsTr, - title: "Yönetim Hesap Kiracı Bilgileri", - description: "Yönetim Hesap Kiracı Bilgileri", - button: "Yönetim Hesap Kiracı Bilgileri Buton", -}; -const footerManagementAccountTenantSomethingSecondTr = { - ...footerDefaultTr, - page: "Yönetim Hesap Kiracı Bilgileri Footer", -}; -const headerManagementAccountTenantSomethingSecondTr = { - ...headerDefaultTr, - page: "Yönetim Hesap Kiracı Bilgileri Header", -}; - -const menuManagementAccountTenantSomethingSecondTr = { - ...managementAccountTr, - "tenant/somethingSecond": "İkinci Kiracı Bilgileri", -}; -const managementAccountTenantMainSecondTr = { - header: headerManagementAccountTenantSomethingSecondTr, - menu: menuManagementAccountTenantSomethingSecondTr, - content: contentManagementAccountTenantSomethingSecondTr, - footer: footerManagementAccountTenantSomethingSecondTr, -}; - -export { - contentManagementAccountTenantSomethingSecondTr, - footerManagementAccountTenantSomethingSecondTr, - headerManagementAccountTenantSomethingSecondTr, - menuManagementAccountTenantSomethingSecondTr, - managementAccountTenantMainSecondTr, -}; diff --git a/web_services/management_frontend/src/languages/custom/management/english.ts b/web_services/management_frontend/src/languages/custom/management/english.ts deleted file mode 100644 index d511705..0000000 --- a/web_services/management_frontend/src/languages/custom/management/english.ts +++ /dev/null @@ -1,23 +0,0 @@ -const managementEn = { - management: "Management First Layer Label", -}; - -const managementAccountEn = { - ...managementEn, - account: "Account Second Layer Label", -}; - -const managementAccountFieldsEn = { - "User.firstName": "First Name", - "User.lastName": "Last Name", - "User.email": "Email", - "User.phoneNumber": "Phone Number", - "User.country": "Country", - "User.description": "Description", - "User.isDeleted": "Is Deleted", - "User.isConfirmed": "Is Confirmed", - "User.createdAt": "Created At", - "User.updatedAt": "Updated At", -}; - -export { managementEn, managementAccountEn, managementAccountFieldsEn }; diff --git a/web_services/management_frontend/src/languages/custom/management/turkish.ts b/web_services/management_frontend/src/languages/custom/management/turkish.ts deleted file mode 100644 index eda9cac..0000000 --- a/web_services/management_frontend/src/languages/custom/management/turkish.ts +++ /dev/null @@ -1,22 +0,0 @@ -const managementTr = { - management: "Management Birinci Seviye", -}; -const managementAccountTr = { - ...managementTr, - account: "Account İkinci Seviye", -}; - -const managementAccountFieldsTr = { - "User.firstName": "Ad", - "User.lastName": "Soyad", - "User.email": "Email", - "User.phoneNumber": "Telefon Numarası", - "User.country": "Ülke", - "User.description": "Açıklama", - "User.isDeleted": "Silindi", - "User.isConfirmed": "Onaylandı", - "User.createdAt": "Oluşturulma Tarihi", - "User.updatedAt": "Güncellenme Tarihi", -}; - -export { managementTr, managementAccountTr, managementAccountFieldsTr }; diff --git a/web_services/management_frontend/src/pages/multi/index.ts b/web_services/management_frontend/src/pages/multi/index.ts index e251290..ce5986d 100644 --- a/web_services/management_frontend/src/pages/multi/index.ts +++ b/web_services/management_frontend/src/pages/multi/index.ts @@ -1,18 +1,8 @@ import { ContentProps } from "@/validations/mutual/dashboard/props"; -import superUserTenantSomething from "./management/account/tenantSomething/page"; -import superUserTenantSomethingSecond from "./management/account/tenantSomethingSecond/page"; -import superUserBuildingPartsTenantSomething from "./building/parts/tenantSomething/page"; -const pageIndexMulti: Record>> = { - "management/account/tenant/something": { - superUserTenantSomething: superUserTenantSomething, - }, - "management/account/tenant/somethingSecond": { - superUserTenantSomething: superUserTenantSomethingSecond, - }, - "building/parts/tenant/something": { - superUserTenantSomething: superUserBuildingPartsTenantSomething, - }, -}; +const pageIndexMulti: Record< + string, + Record> +> = {}; export default pageIndexMulti; diff --git a/web_services/management_frontend/src/pages/multi/management/account/tenantSomething/page.tsx b/web_services/management_frontend/src/pages/multi/management/account/tenantSomething/page.tsx deleted file mode 100644 index 3a3eda8..0000000 --- a/web_services/management_frontend/src/pages/multi/management/account/tenantSomething/page.tsx +++ /dev/null @@ -1,85 +0,0 @@ -'use client'; -import React, { useState } from "react"; -import TableComponent from "@/components/mutual/tableView/FullTableComp/component"; -import { ContentProps } from "@/validations/mutual/dashboard/props"; -import { EyeIcon, PencilIcon, PlusCircle, ArrowLeftFromLineIcon } from "lucide-react"; -import Link from "next/link"; -import CreateForm from "@/components/mutual/tableView/mutual/CreateForm"; -import UpdateForm from "@/components/mutual/tableView/mutual/UpdateForm"; -import ViewForm from "@/components/mutual/tableView/mutual/ViewForm"; -import { useRouter } from "next/navigation"; - -// This is a mock page dont use it -const superUserTenantSomething: React.FC = ({ lang, translations, activePageUrl, mode }) => { - const router = useRouter() - const [selectedRow, setSelectedRow] = useState(null); - const pageUrl = `/${lang}/${activePageUrl}?mode=list` - const urls = { list: "http://localhost:3000/api/tst" } - const initPaginationDefault = { page: 1, size: 10, orderFields: [], orderTypes: [], query: {} } - const renderLastRowComponent = (reDirectUrl: string, IconToWrap: any) => { - return () - } - const redirectUrls = { - table: { - update: renderLastRowComponent(`/${lang}/${activePageUrl}?mode=update`, PencilIcon), - view: renderLastRowComponent(`/${lang}/${activePageUrl}?mode=view`, EyeIcon), - }, - page: { - create: renderLastRowComponent(`/${lang}/${activePageUrl}?mode=create`, PlusCircle), - } - } - const schemas = { list: {} } - const columns = [ - "firstName", - "lastName", - "email", - "phoneNumber", - "country", - "description", - "isDeleted", - "isConfirmed", - "createdAt", - "updatedAt", - ] - const ListWithTableProps = { - urls: { - list: "http://localhost:3000/api/tst", - }, - schemas: schemas, - translations: translations, - columns: columns, - redirectUrls: redirectUrls, - initPagination: initPaginationDefault, - setSelectedRow: setSelectedRow, - } - const CreateFormProps = { - schemas: schemas, - selectedRow: selectedRow, - } - const UpdateFormProps = { - rollbackTo: pageUrl, - schemas: schemas, - selectedRow: selectedRow, - } - const ViewFormProps = { - rollbackTo: pageUrl, - schemas: schemas, - selectedRow: selectedRow, - } - - const RenderBackToList =
setSelectedRow(null)}> - {renderLastRowComponent(pageUrl, ArrowLeftFromLineIcon)} -
- return ( - <> - {JSON.stringify(translations)} - {mode !== 'list' ? RenderBackToList : } - {mode === 'create' && } - {mode === 'update' && } - {mode === 'view' && } - - ); -} - - -export default superUserTenantSomething \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/multi/management/account/tenantSomethingSecond/page.tsx b/web_services/management_frontend/src/pages/multi/management/account/tenantSomethingSecond/page.tsx deleted file mode 100644 index afafea0..0000000 --- a/web_services/management_frontend/src/pages/multi/management/account/tenantSomethingSecond/page.tsx +++ /dev/null @@ -1,46 +0,0 @@ -import FullCardTableComp from "@/components/mutual/tableView/FullCardTableComp/component"; -import { ContentProps } from "@/validations/mutual/dashboard/props"; - -// This is a mock page dont use it -const superUserTenantSomethingSecond: React.FC = ({ lang, translations, activePageUrl }) => { - const urls = { - list: "http://localhost:3000/api/tst", - } - const tableTranslations = { - firstName: "First Name", - lastName: "Last Name", - email: "Email", - phoneNumber: "Phone Number", - country: "Country", - description: "Description", - isDeleted: "Is Deleted", - isConfirmed: "Is Confirmed", - createdAt: "Created At", - updatedAt: "Updated At", - } - const columns = [ - "firstName", - "lastName", - "email", - "phoneNumber", - "country", - "description", - "isDeleted", - "isConfirmed", - "createdAt", - "updatedAt", - ] - const redirectUrls = {} - const schemas = {} - const initPaginationDefault = { page: 1, size: 10, orderFields: [], orderTypes: [], query: {} } - return ( - <> - {JSON.stringify(translations)} - - - ); -} - - -export default superUserTenantSomethingSecond \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/resolver/resolver.tsx b/web_services/management_frontend/src/pages/resolver/resolver.tsx index de5b1f3..b04c323 100644 --- a/web_services/management_frontend/src/pages/resolver/resolver.tsx +++ b/web_services/management_frontend/src/pages/resolver/resolver.tsx @@ -7,21 +7,24 @@ import pageIndexMulti from "@/pages/multi/index"; import pageIndexSingle from "@/pages/single/index"; import ContentToRenderNoPage from "@/pages/mutual/noContent/page"; -function resolveWhichPageToRenderSingle({ - activePageUrl, -}: ResolverProps): React.FC { - return activePageUrl in pageIndexSingle ? pageIndexSingle[activePageUrl] : ContentToRenderNoPage -} - -async function resolveWhichPageToRenderMulti({ - activePageUrl, -}: ResolverProps): Promise | null> { - const pageToRender = await retrievePageToRender(activePageUrl) // TODO: Retrieve page to render +async function resolveWhichPageToRenderSingle({ activePageUrl }: ResolverProps): Promise | null> { try { - const ApplicationToRender = pageIndexMulti[activePageUrl][pageToRender] + console.log('activePageUrl', activePageUrl) + const ApplicationToRender = pageIndexSingle[`/${activePageUrl}`] return ApplicationToRender } catch (error) { - console.error(error) + console.error('resolveWhichPageToRenderSingle', error) + } + return ContentToRenderNoPage +} + +async function resolveWhichPageToRenderMulti({ activePageUrl }: ResolverProps): Promise | null> { + const pageToRender = await retrievePageToRender(activePageUrl) + try { + const ApplicationToRender = pageIndexMulti[`${activePageUrl}`][pageToRender] + return ApplicationToRender + } catch (error) { + console.error('resolveWhichPageToRenderMulti', error) } return ContentToRenderNoPage } diff --git a/web_services/management_frontend/src/pages/single/application/page.tsx b/web_services/management_frontend/src/pages/single/application/page.tsx index f0f89e7..acb9671 100644 --- a/web_services/management_frontend/src/pages/single/application/page.tsx +++ b/web_services/management_frontend/src/pages/single/application/page.tsx @@ -11,9 +11,8 @@ import { getSchemaByLanguage } from "@/schemas/custom/application/schemas"; import { API_BASE_URL } from "@/config/config"; import { renderLastRowComponent } from "@/components/mutual/navigators/component"; - // This is a mock page dont use it -const superUserApplicationRegister: React.FC = ({ lang, translations, activePageUrl, mode }) => { +const SuperUserApplicationPage: React.FC = ({ lang, translations, activePageUrl, mode }) => { const [selectedRow, setSelectedRow] = useState(null); const getSchema = getSchemaByLanguage(lang) @@ -33,7 +32,8 @@ const superUserApplicationRegister: React.FC = ({ lang, translatio } } const listWithTableProps = { - urls: { list: `${API_BASE_URL}/application/register` }, + urls: { list: `${API_BASE_URL}/applications/pages` }, + schemas: { table: getSchema.shortSchema }, translations: translations, redirectUrls: redirectUrls, initPagination: { page: 1, size: 10, orderFields: [], orderTypes: [], query: {} }, @@ -70,4 +70,4 @@ const superUserApplicationRegister: React.FC = ({ lang, translatio ); } -export default superUserApplicationRegister \ No newline at end of file +export default SuperUserApplicationPage \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/single/dashboard/page.tsx b/web_services/management_frontend/src/pages/single/dashboard/page.tsx new file mode 100644 index 0000000..70d8943 --- /dev/null +++ b/web_services/management_frontend/src/pages/single/dashboard/page.tsx @@ -0,0 +1,74 @@ +'use client'; +import React, { useState } from "react"; +import TableComponent from "@/components/mutual/tableView/FullTableComp/component"; +import CreateForm from "@/components/mutual/tableView/mutual/CreateForm"; +import UpdateForm from "@/components/mutual/tableView/mutual/UpdateForm"; +import ViewForm from "@/components/mutual/tableView/mutual/ViewForm"; + +import { EyeIcon, PencilIcon, PlusCircle, ArrowLeftFromLineIcon, ExpandIcon } from "lucide-react"; +import { ContentProps } from "@/validations/mutual/dashboard/props"; +import { getSchemaByLanguage } from "@/schemas/custom/application/schemas"; +import { API_BASE_URL } from "@/config/config"; +import { renderLastRowComponent } from "@/components/mutual/navigators/component"; + + +// This is a mock page dont use it +const SuperUserDashboardPage: React.FC = ({ lang, translations, activePageUrl, mode }) => { + const [selectedRow, setSelectedRow] = useState(null); + + const getSchema = getSchemaByLanguage(lang) + const basePageUrl = `/panel/${lang}/${activePageUrl}?mode=` + const isList = mode === 'shortList' || mode === 'fullList' + const changeList = mode === 'shortList' ? `${basePageUrl}fullList` : `${basePageUrl}shortList` + + const RenderBackToList = renderLastRowComponent(`${basePageUrl}shortList`, ArrowLeftFromLineIcon, "backToList") + const redirectUrls = { + table: { + update: renderLastRowComponent(`${basePageUrl}update`, PencilIcon, "update"), + view: renderLastRowComponent(`${basePageUrl}view`, EyeIcon, "view"), + }, + page: { + create: renderLastRowComponent(`${basePageUrl}create`, PlusCircle, "create"), + size: renderLastRowComponent(changeList, ExpandIcon, "size-table"), + } + } + const listWithTableProps = { + urls: { list: `${API_BASE_URL}/applications/pages` }, + schemas: { table: getSchema.shortSchema }, + translations: translations, + redirectUrls: redirectUrls, + initPagination: { page: 1, size: 10, orderFields: [], orderTypes: [], query: {} }, + setSelectedRow: setSelectedRow, + } + const CreateFormProps = { + schemas: { create: getSchema.createSchema }, + labels: getSchema.labels, + selectedRow: selectedRow, + } + const UpdateFormProps = { + rollbackTo: changeList, + schemas: { update: getSchema.updateSchema }, + labels: getSchema.labels, + selectedRow: selectedRow, + } + const ViewFormProps = { + rollbackTo: changeList, + schemas: { view: getSchema.detailSchema }, + selectedRow: selectedRow, + labels: getSchema.labels, + } + const shortAddProps = { ...listWithTableProps, schemas: { table: getSchema.shortSchema }, columns: { table: getSchema.shortColumns } } + const fullAddProps = { ...listWithTableProps, schemas: { table: getSchema.detailSchema }, columns: { table: getSchema.columns } } + return ( +
+ {!isList && RenderBackToList} + {isList && mode === 'shortList' && } + {isList && mode === 'fullList' && } + {mode === 'create' && } + {mode === 'update' && } + {mode === 'view' && } +
+ ); +} + +export default SuperUserDashboardPage \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/single/index.ts b/web_services/management_frontend/src/pages/single/index.ts index d113732..dfa0fca 100644 --- a/web_services/management_frontend/src/pages/single/index.ts +++ b/web_services/management_frontend/src/pages/single/index.ts @@ -1,12 +1,12 @@ import { ContentProps } from "@/validations/mutual/dashboard/props"; -import superUserTenantSomething from "./management/account/tenantSomething/page"; -import superUserTenantSomethingSecond from "./management/account/tenantSomethingSecond/page"; -import superUserBuildingPartsTenantSomething from "./building/parts/tenantSomething/page"; +import SuperUserApplicationPage from "./application/page"; +import SuperUserServicePage from "./services/page"; +import SuperUserDashboardPage from "./dashboard/page"; const pageIndexSingle: Record> = { - dashboard: superUserTenantSomething, - application: superUserTenantSomethingSecond, - service: superUserBuildingPartsTenantSomething, + "/dashboard": SuperUserDashboardPage, + "/application": SuperUserApplicationPage, + "/service": SuperUserServicePage, }; export default pageIndexSingle; diff --git a/web_services/management_frontend/src/pages/single/management/account/tenantSomething/page.tsx b/web_services/management_frontend/src/pages/single/management/account/tenantSomething/page.tsx deleted file mode 100644 index 979c2ee..0000000 --- a/web_services/management_frontend/src/pages/single/management/account/tenantSomething/page.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { ContentProps } from "@/validations/mutual/dashboard/props"; - -// This is a mock page dont use it -const superUserTenantSomething: React.FC = ({ lang, translations, activePageUrl }) => { - return <> -

{JSON.stringify(translations)}{" "}{lang}{" "}{activePageUrl}

-
Some Content 1
-
Some Content 2
-
Some Content 3
-
Some Content 4
-
Some Content 5
-
Some Content 6
-
Some Content 7
-
Some Content 8
-
Some Content 9
-
Some Content 10
-
Some Content 11
-
Some Content 12
-
Some Content 13
-
Some Content 14
-
Some Content 15
-
Some Content 16
- -} - - -export default superUserTenantSomething \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/single/management/account/tenantSomethingSecond/page.tsx b/web_services/management_frontend/src/pages/single/management/account/tenantSomethingSecond/page.tsx deleted file mode 100644 index d00d2e3..0000000 --- a/web_services/management_frontend/src/pages/single/management/account/tenantSomethingSecond/page.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import { ContentProps } from "@/validations/mutual/dashboard/props"; - -// This is a mock page dont use it -const superUserTenantSomethingSecond: React.FC = ({ lang, translations, activePageUrl }) => { - return <> -

{JSON.stringify(translations)}{" "}{lang}{" "}{activePageUrl}

-
Some Content 1
-
Some Content 2
-
Some Content 3
-
Some Content 4
-
Some Content 5
-
Some Content 6
-
Some Content 7
-
Some Content 8
-
Some Content 9
-
Some Content 10
-
Some Content 11
-
Some Content 12
-
Some Content 13
-
Some Content 14
-
Some Content 15
-
Some Content 16
- -} - - -export default superUserTenantSomethingSecond \ No newline at end of file diff --git a/web_services/management_frontend/src/pages/single/services/page.tsx b/web_services/management_frontend/src/pages/single/services/page.tsx new file mode 100644 index 0000000..d26f22b --- /dev/null +++ b/web_services/management_frontend/src/pages/single/services/page.tsx @@ -0,0 +1,74 @@ +'use client'; +import React, { useState } from "react"; +import TableComponent from "@/components/mutual/tableView/FullTableComp/component"; +import CreateForm from "@/components/mutual/tableView/mutual/CreateForm"; +import UpdateForm from "@/components/mutual/tableView/mutual/UpdateForm"; +import ViewForm from "@/components/mutual/tableView/mutual/ViewForm"; + +import { EyeIcon, PencilIcon, PlusCircle, ArrowLeftFromLineIcon, ExpandIcon } from "lucide-react"; +import { ContentProps } from "@/validations/mutual/dashboard/props"; +import { getSchemaByLanguage } from "@/schemas/custom/application/schemas"; +import { API_BASE_URL } from "@/config/config"; +import { renderLastRowComponent } from "@/components/mutual/navigators/component"; + + +// This is a mock page dont use it +const SuperUserServicePage: React.FC = ({ lang, translations, activePageUrl, mode }) => { + const [selectedRow, setSelectedRow] = useState(null); + + const getSchema = getSchemaByLanguage(lang) + const basePageUrl = `/panel/${lang}/${activePageUrl}?mode=` + const isList = mode === 'shortList' || mode === 'fullList' + const changeList = mode === 'shortList' ? `${basePageUrl}fullList` : `${basePageUrl}shortList` + + const RenderBackToList = renderLastRowComponent(`${basePageUrl}shortList`, ArrowLeftFromLineIcon, "backToList") + const redirectUrls = { + table: { + update: renderLastRowComponent(`${basePageUrl}update`, PencilIcon, "update"), + view: renderLastRowComponent(`${basePageUrl}view`, EyeIcon, "view"), + }, + page: { + create: renderLastRowComponent(`${basePageUrl}create`, PlusCircle, "create"), + size: renderLastRowComponent(changeList, ExpandIcon, "size-table"), + } + } + const listWithTableProps = { + urls: { list: `${API_BASE_URL}/applications/pages` }, + schemas: { table: getSchema.shortSchema }, + translations: translations, + redirectUrls: redirectUrls, + initPagination: { page: 1, size: 10, orderFields: [], orderTypes: [], query: {} }, + setSelectedRow: setSelectedRow, + } + const CreateFormProps = { + schemas: { create: getSchema.createSchema }, + labels: getSchema.labels, + selectedRow: selectedRow, + } + const UpdateFormProps = { + rollbackTo: changeList, + schemas: { update: getSchema.updateSchema }, + labels: getSchema.labels, + selectedRow: selectedRow, + } + const ViewFormProps = { + rollbackTo: changeList, + schemas: { view: getSchema.detailSchema }, + selectedRow: selectedRow, + labels: getSchema.labels, + } + const shortAddProps = { ...listWithTableProps, schemas: { table: getSchema.shortSchema }, columns: { table: getSchema.shortColumns } } + const fullAddProps = { ...listWithTableProps, schemas: { table: getSchema.detailSchema }, columns: { table: getSchema.columns } } + return ( +
+ {!isList && RenderBackToList} + {isList && mode === 'shortList' && } + {isList && mode === 'fullList' && } + {mode === 'create' && } + {mode === 'update' && } + {mode === 'view' && } +
+ ); +} + +export default SuperUserServicePage \ No newline at end of file diff --git a/web_services/management_frontend/src/schemas/custom/application/schemas.ts b/web_services/management_frontend/src/schemas/custom/application/schemas.ts index e609590..e5bbf71 100644 --- a/web_services/management_frontend/src/schemas/custom/application/schemas.ts +++ b/web_services/management_frontend/src/schemas/custom/application/schemas.ts @@ -1,7 +1,7 @@ import { z } from "zod"; import { LanguageTypes } from "@/validations/mutual/language/validations"; -import { buildingPartsFieldsTr } from "@/languages/custom/building/turkish"; -import { buildingPartsFieldsEn } from "@/languages/custom/building/english"; +import { applicationFieldsTr } from "@/languages/custom/application/turkish"; +import { applicationFieldsEn } from "@/languages/custom/application/english"; interface ApplicationData { uu_id: string; @@ -18,8 +18,8 @@ interface ApplicationData { } const labelTranslations = { - tr: buildingPartsFieldsTr, - en: buildingPartsFieldsEn, + tr: applicationFieldsTr, + en: applicationFieldsEn, }; const errorMessages = { diff --git a/web_services/management_frontend/src/validations/mutual/forms/type.ts b/web_services/management_frontend/src/validations/mutual/forms/type.ts index 3499ccd..6039036 100644 --- a/web_services/management_frontend/src/validations/mutual/forms/type.ts +++ b/web_services/management_frontend/src/validations/mutual/forms/type.ts @@ -2,19 +2,19 @@ interface UpdateFormProps { schemas: Record; selectedRow: Record; rollbackTo: string; - labels: Record; + labels: any; } interface CreateFormProps { schemas: Record; selectedRow: Record; - labels: Record; + labels: any; } interface ViewFormProps { schemas: Record; selectedRow: Record; rollbackTo: string; - labels: Record; + labels: any; } export type { UpdateFormProps, CreateFormProps, ViewFormProps }; diff --git a/web_services/web-controllers/config/config.ts b/web_services/web-controllers/config/config.ts index 7c8dc65..766d82e 100644 --- a/web_services/web-controllers/config/config.ts +++ b/web_services/web-controllers/config/config.ts @@ -1,2 +1,4 @@ -export const WEB_BASE_URL = process.env.WEB_BASE_URL; -export const API_BASE_URL = process.env.API_BASE_URL; +const BASE_URL = "http://localhost:3000"; +const API_URL = "http://localhost:3000/api"; +export const WEB_BASE_URL = process.env.WEB_BASE_URL || BASE_URL; +export const API_BASE_URL = process.env.API_BASE_URL || API_URL; diff --git a/z-templates/a-service/a.txt b/z-templates/a-service/a.txt deleted file mode 100644 index e69de29..0000000 diff --git a/z-templates/a-service/events/index.py b/z-templates/a-service/events/index.py deleted file mode 100644 index 6bf28aa..0000000 --- a/z-templates/a-service/events/index.py +++ /dev/null @@ -1,9 +0,0 @@ - - -events_index: dict = { - "Slot1": "", - "Slot2": "", - "Slot3": "", - "Slot4": "", - "Slot5": "", -} diff --git a/z-templates/a-service/endpoints/index.py b/z-templates/a-service/index.py similarity index 100% rename from z-templates/a-service/endpoints/index.py rename to z-templates/a-service/index.py