feature: simple npm setup

This commit is contained in:
2026-01-11 19:54:09 +01:00
parent 43cf57b34a
commit 39a192e330
5 changed files with 149 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
from dataclasses import dataclass
from typing import Dict, Any
@dataclass(frozen=True)
class SurgePricingConfig:
high_threshold: int
surge_multiplier: float
window_size: int # seconds
def to_dict(self) -> Dict[str, Any]:
return {
"high_threshold": self.high_threshold,
"surge_multiplier": self.surge_multiplier,
"window_size": self.window_size,
}
@dataclass(frozen=True)
class SessionAwareConfig:
velocity_threshold: float
view_depth_threshold: int
cart_ratio_threshold: float
agent_multiplier: float
def to_dict(self) -> Dict[str, Any]:
return {
"velocity_threshold": self.velocity_threshold,
"view_depth_threshold": self.view_depth_threshold,
"cart_ratio_threshold": self.cart_ratio_threshold,
"agent_multiplier": self.agent_multiplier,
}
# Test-optimized configurations for deterministic results
AGGRESSIVE_SURGE = SurgePricingConfig(
high_threshold=3,
surge_multiplier=1.5,
window_size=10,
)
MODERATE_SURGE = SurgePricingConfig(
high_threshold=5,
surge_multiplier=1.3,
window_size=15,
)
STRICT_SESSION_AWARE = SessionAwareConfig(
velocity_threshold=2.0, # 2 events/sec is agent-like
view_depth_threshold=5,
cart_ratio_threshold=0.8,
agent_multiplier=1.4,
)

View File

@@ -0,0 +1,36 @@
import os
from dataclasses import dataclass
@dataclass(frozen=True)
class ServiceConfig:
web_url: str
backend_url: str
pricing_url: str
kafka_host: str
kafka_port: int
redis_port: int
@dataclass(frozen=True)
class TestConfig:
headless: bool
timeout: int
poll_interval: float
max_retries: int
kafka_consumer_timeout: int
def load_service_config() -> ServiceConfig:
return ServiceConfig(
web_url=os.getenv("WEB_URL", "http://localhost:3000"),
backend_url=os.getenv("BACKEND_URL", "http://localhost:5000"),
pricing_url=os.getenv("PRICING_PROVIDER_URL", "http://localhost:5001"),
kafka_host=os.getenv("KAFKA_HOST", "localhost"),
kafka_port=int(os.getenv("KAFKA_PORT", "9092")),
redis_port=int(os.getenv("REDIS_PORT", "6377")),
)
def load_test_config() -> TestConfig:
return TestConfig(
headless=os.getenv("HEADLESS", "true").lower() == "true",
timeout=int(os.getenv("TEST_TIMEOUT", "30000")),
poll_interval=float(os.getenv("POLL_INTERVAL", "0.5")),
max_retries=int(os.getenv("MAX_RETRIES", "10")),
kafka_consumer_timeout=int(os.getenv("KAFKA_TIMEOUT", "15")),
)