-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtypes.py
More file actions
78 lines (54 loc) · 1.77 KB
/
types.py
File metadata and controls
78 lines (54 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# generated by datamodel-codegen:
# filename: https://raw.githubusercontent.com/Flagsmith/flagsmith/main/sdk/evaluation-context.json
# timestamp: 2025-10-10T16:01:57+00:00
from __future__ import annotations
from typing import Any, Dict, Generic, List, Literal, Optional, Union
from typing_extensions import NotRequired, TypedDict
from flag_engine.segments.types import (
ConditionOperator,
ContextValue,
MetadataT,
RuleType,
)
class EnvironmentContext(TypedDict):
key: str
name: str
class FeatureValue(TypedDict):
value: Any
weight: float
class IdentityContext(TypedDict):
identifier: str
key: str
traits: NotRequired[Dict[str, ContextValue]]
class StrValueSegmentCondition(TypedDict):
property: str
operator: ConditionOperator
value: str
class InOperatorSegmentCondition(TypedDict):
property: str
operator: Literal["IN"]
value: List[str]
SegmentCondition = Union[StrValueSegmentCondition, InOperatorSegmentCondition]
class SegmentRule(TypedDict):
type: RuleType
conditions: NotRequired[List[SegmentCondition]]
rules: NotRequired[List[SegmentRule]]
class FeatureContext(TypedDict):
key: str
feature_key: str
name: str
enabled: bool
value: Any
variants: NotRequired[List[FeatureValue]]
priority: NotRequired[float]
class SegmentContext(TypedDict, Generic[MetadataT]):
key: str
name: str
rules: List[SegmentRule]
overrides: NotRequired[List[FeatureContext]]
metadata: NotRequired[MetadataT]
class EvaluationContext(TypedDict, Generic[MetadataT]):
environment: EnvironmentContext
identity: NotRequired[Optional[IdentityContext]]
segments: NotRequired[Dict[str, SegmentContext[MetadataT]]]
features: NotRequired[Dict[str, FeatureContext]]