-
-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathoverride.py
More file actions
116 lines (83 loc) · 3.3 KB
/
override.py
File metadata and controls
116 lines (83 loc) · 3.3 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
"""Override types for Typesense Python Client."""
import sys
if sys.version_info >= (3, 11):
import typing
else:
import typing_extensions as typing
_OverrideRuleT = typing.TypeVar(
"_OverrideRuleT",
bound=typing.Union["OverrideQueryRuleSchema", "OverrideFilterSchema"],
)
class OverrideQueryRuleSchema(typing.TypedDict):
"""
The schema for the rule field in the Overrides.upsert method.
Attributes:
query (str): The query string.
match (typing.Literal['contains', 'exact']): The match type.
filter_by (str): The filter string.
tags (list[str]): The tags list.
"""
query: str
match: typing.Literal["contains", "exact"]
filter_by: typing.NotRequired[str]
tags: typing.NotRequired[typing.List[str]]
class OverrideFilterSchema(typing.TypedDict):
"""
The schema for the rule field in the Overrides.upsert method.
Attributes:
filter_by (str): The filter string.
tags (list[str]): The tags list.
"""
filter_by: str
tags: typing.NotRequired[typing.List[str]]
class IncludesSchema(typing.TypedDict):
"""
The schema for the includes field in the Overrides.upsert method.
Attributes:
id (str): The ID of the document.
position (int): The position of the ID in the response.
"""
id: str
position: int
class OverrideCreateSchema(typing.Generic[_OverrideRuleT], typing.TypedDict):
"""
The schema for the request of the Overrides.upsert method.
Attributes:
rule (_OverrideRuleT): The rule.
sort_by (str): The sort by string.
filter_by (str): The filter by string.
excludes (list[str]): The excludes list.
replace_query (str): The replace query string.
includes (list[IncludesSchema]): The includes list.
metadata (dict[str, str]): The metadata dictionary.
filter_curated_hits (bool): Whether to filter curated hits.
effective_from_ts (int): The effective from timestamp.
effective_to_ts (int): The effective to timestamp.
stop_processing (bool): Whether to stop processing.
"""
rule: _OverrideRuleT
sort_by: typing.NotRequired[str]
filter_by: typing.NotRequired[str]
excludes: typing.NotRequired[typing.List[str]]
replace_query: typing.NotRequired[str]
includes: typing.NotRequired[typing.List[IncludesSchema]]
metadata: typing.NotRequired[typing.Dict[str, str]]
filter_curated_hits: typing.NotRequired[bool]
effective_from_ts: typing.NotRequired[int]
effective_to_ts: typing.NotRequired[int]
stop_processing: typing.NotRequired[bool]
OverrideCreateSchemaCompat = OverrideCreateSchema[
typing.Union[OverrideQueryRuleSchema, OverrideFilterSchema]
]
class OverrideSchema(OverrideCreateSchema[_OverrideRuleT]):
"""The schema for the response of the Overrides.upsert method."""
id: str
OverrideSchemaCompat = OverrideSchema[
typing.Union[OverrideQueryRuleSchema, OverrideFilterSchema]
]
class OverrideDeleteSchema(typing.TypedDict):
"""The schema for the response of the Overrides.delete method."""
id: str
class OverrideRetrieveSchema(typing.TypedDict):
"""The schema for the response of the Overrides.retrieve method."""
overrides: typing.List[OverrideSchema[typing.Union[OverrideQueryRuleSchema, OverrideFilterSchema]]]