demo seed change

This commit is contained in:
Urtzi Alfaro
2025-12-13 23:57:54 +01:00
parent f3688dfb04
commit ff830a3415
299 changed files with 20328 additions and 19485 deletions

0
shared/clients/__init__.py Normal file → Executable file
View File

0
shared/clients/ai_insights_client.py Normal file → Executable file
View File

0
shared/clients/alert_processor_client.py Normal file → Executable file
View File

0
shared/clients/alerts_client.py Normal file → Executable file
View File

0
shared/clients/auth_client.py Normal file → Executable file
View File

1
shared/clients/base_service_client.py Normal file → Executable file
View File

@@ -105,6 +105,7 @@ class BaseServiceClient(ABC):
timeout=60,
success_threshold=2
)
@abstractmethod
def get_service_base_path(self) -> str:

0
shared/clients/circuit_breaker.py Normal file → Executable file
View File

0
shared/clients/distribution_client.py Normal file → Executable file
View File

0
shared/clients/external_client.py Normal file → Executable file
View File

0
shared/clients/forecast_client.py Normal file → Executable file
View File

99
shared/clients/inventory_client.py Normal file → Executable file
View File

@@ -759,6 +759,105 @@ class InventoryServiceClient(BaseServiceClient):
logger.error("Inventory service health check failed", error=str(e))
return False
async def trigger_inventory_alerts_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger inventory alerts for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
The endpoint should trigger alerts specifically for the given tenant.
Args:
tenant_id: Tenant ID to trigger alerts for
Returns:
Dict with trigger results or None if failed
"""
try:
# Call internal endpoint via gateway using tenant-scoped URL pattern
# Endpoint: /api/v1/tenants/{tenant_id}/inventory/internal/alerts/trigger
result = await self._make_request(
method="POST",
endpoint="inventory/internal/alerts/trigger",
tenant_id=tenant_id,
data={},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Inventory alerts triggered successfully via internal endpoint",
tenant_id=tenant_id,
alerts_generated=result.get("alerts_generated", 0)
)
else:
logger.warning(
"Inventory alerts internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering inventory alerts via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# ================================================================
# INTERNAL AI INSIGHTS METHODS
# ================================================================
async def trigger_safety_stock_insights_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger safety stock optimization insights for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
Args:
tenant_id: Tenant ID to trigger insights for
Returns:
Dict with trigger results or None if failed
"""
try:
result = await self._make_request(
method="POST",
endpoint="inventory/internal/ml/generate-safety-stock-insights",
tenant_id=tenant_id,
data={"tenant_id": tenant_id},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Safety stock insights triggered successfully via internal endpoint",
tenant_id=tenant_id,
insights_posted=result.get("insights_posted", 0)
)
else:
logger.warning(
"Safety stock insights internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering safety stock insights via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# Factory function for dependency injection
def create_inventory_client(config: BaseServiceSettings) -> InventoryServiceClient:

0
shared/clients/nominatim_client.py Normal file → Executable file
View File

0
shared/clients/notification_client.py Normal file → Executable file
View File

0
shared/clients/orders_client.py Normal file → Executable file
View File

0
shared/clients/payment_client.py Normal file → Executable file
View File

102
shared/clients/procurement_client.py Normal file → Executable file
View File

@@ -569,6 +569,108 @@ class ProcurementServiceClient(BaseServiceClient):
logger.error("Procurement service health check failed", error=str(e))
return False
# ================================================================
# INTERNAL TRIGGER METHODS
# ================================================================
async def trigger_delivery_tracking_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger delivery tracking for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
Args:
tenant_id: Tenant ID to trigger delivery tracking for
Returns:
Dict with trigger results or None if failed
"""
try:
# Call internal endpoint via gateway using tenant-scoped URL pattern
# Endpoint: /api/v1/tenants/{tenant_id}/procurement/internal/delivery-tracking/trigger
result = await self._make_request(
method="POST",
endpoint="procurement/internal/delivery-tracking/trigger",
tenant_id=tenant_id,
data={},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Delivery tracking triggered successfully via internal endpoint",
tenant_id=tenant_id,
alerts_generated=result.get("alerts_generated", 0)
)
else:
logger.warning(
"Delivery tracking internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering delivery tracking via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# ================================================================
# INTERNAL AI INSIGHTS METHODS
# ================================================================
async def trigger_price_insights_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger price forecasting insights for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
Args:
tenant_id: Tenant ID to trigger insights for
Returns:
Dict with trigger results or None if failed
"""
try:
result = await self._make_request(
method="POST",
endpoint="procurement/internal/ml/generate-price-insights",
tenant_id=tenant_id,
data={"tenant_id": tenant_id},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Price insights triggered successfully via internal endpoint",
tenant_id=tenant_id,
insights_posted=result.get("insights_posted", 0)
)
else:
logger.warning(
"Price insights internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering price insights via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# Factory function for dependency injection
def create_procurement_client(config: BaseServiceSettings, service_name: str = "unknown") -> ProcurementServiceClient:

103
shared/clients/production_client.py Normal file → Executable file
View File

@@ -619,6 +619,109 @@ class ProductionServiceClient(BaseServiceClient):
logger.error("Production service health check failed", error=str(e))
return False
# ================================================================
# INTERNAL TRIGGER METHODS
# ================================================================
async def trigger_production_alerts_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger production alerts for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
Includes both production alerts and equipment maintenance checks.
Args:
tenant_id: Tenant ID to trigger alerts for
Returns:
Dict with trigger results or None if failed
"""
try:
# Call internal endpoint via gateway using tenant-scoped URL pattern
# Endpoint: /api/v1/tenants/{tenant_id}/production/internal/alerts/trigger
result = await self._make_request(
method="POST",
endpoint="production/internal/alerts/trigger",
tenant_id=tenant_id,
data={},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Production alerts triggered successfully via internal endpoint",
tenant_id=tenant_id,
alerts_generated=result.get("alerts_generated", 0)
)
else:
logger.warning(
"Production alerts internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering production alerts via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# ================================================================
# INTERNAL AI INSIGHTS METHODS
# ================================================================
async def trigger_yield_insights_internal(
self,
tenant_id: str
) -> Optional[Dict[str, Any]]:
"""
Trigger yield improvement insights for a tenant (internal service use only).
This method calls the internal endpoint which is protected by X-Internal-Service header.
Args:
tenant_id: Tenant ID to trigger insights for
Returns:
Dict with trigger results or None if failed
"""
try:
result = await self._make_request(
method="POST",
endpoint="production/internal/ml/generate-yield-insights",
tenant_id=tenant_id,
data={"tenant_id": tenant_id},
headers={"X-Internal-Service": "demo-session"}
)
if result:
logger.info(
"Yield insights triggered successfully via internal endpoint",
tenant_id=tenant_id,
insights_posted=result.get("insights_posted", 0)
)
else:
logger.warning(
"Yield insights internal endpoint returned no result",
tenant_id=tenant_id
)
return result
except Exception as e:
logger.error(
"Error triggering yield insights via internal endpoint",
tenant_id=tenant_id,
error=str(e)
)
return None
# Factory function for dependency injection
def create_production_client(config: BaseServiceSettings) -> ProductionServiceClient:

0
shared/clients/recipes_client.py Normal file → Executable file
View File

0
shared/clients/sales_client.py Normal file → Executable file
View File

0
shared/clients/stripe_client.py Normal file → Executable file
View File

0
shared/clients/subscription_client.py Normal file → Executable file
View File

0
shared/clients/suppliers_client.py Normal file → Executable file
View File

0
shared/clients/tenant_client.py Normal file → Executable file
View File

0
shared/clients/training_client.py Normal file → Executable file
View File