powerbi-mcp 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
src/validation.py ADDED
@@ -0,0 +1,40 @@
1
+ """
2
+ Validation utilities for PowerBI MCP Server
3
+
4
+ Shared validation logic to ensure consistency across the codebase.
5
+ """
6
+
7
+ from .constants import REFRESH_HISTORY_MIN, REFRESH_HISTORY_MAX
8
+
9
+
10
+ def validate_dax_query(query: str) -> None:
11
+ """
12
+ Validate that DAX query starts with EVALUATE keyword
13
+
14
+ Args:
15
+ query: DAX query string to validate
16
+
17
+ Raises:
18
+ ValueError: If query doesn't start with EVALUATE
19
+ """
20
+ if not query.strip().upper().startswith("EVALUATE"):
21
+ raise ValueError(
22
+ "DAX query must start with EVALUATE keyword. "
23
+ 'Example: "EVALUATE Sales" or "EVALUATE FILTER(Sales, Sales[Year] = 2024)"'
24
+ )
25
+
26
+
27
+ def validate_refresh_top(top: int) -> None:
28
+ """
29
+ Validate refresh history top parameter
30
+
31
+ Args:
32
+ top: Number of refresh records to return
33
+
34
+ Raises:
35
+ ValueError: If top is out of valid range
36
+ """
37
+ if not REFRESH_HISTORY_MIN <= top <= REFRESH_HISTORY_MAX:
38
+ raise ValueError(
39
+ f"top must be between {REFRESH_HISTORY_MIN} and {REFRESH_HISTORY_MAX}"
40
+ )