-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtypedefs.py
More file actions
204 lines (157 loc) · 5.51 KB
/
typedefs.py
File metadata and controls
204 lines (157 loc) · 5.51 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
from typing import Any, List, Literal, Dict, Union
from typing_extensions import NotRequired, TypedDict
class PropertySpecification(TypedDict):
name: str
description: str
required: bool
nullable: NotRequired[bool]
type: "PropertyType"
class PropertyType(TypedDict):
kind: Literal['void', 'primitive', 'array', 'object', 'function', 'plain', 'any']
spec: NotRequired[Dict]
name: NotRequired[str]
type: NotRequired[str]
items: NotRequired['PropertyType']
schema: NotRequired[Dict]
properties: NotRequired[List[PropertySpecification]]
typeName: NotRequired[str]
value: NotRequired[str]
class FunctionSpecification(TypedDict):
arguments: List[PropertySpecification]
returnType: Dict[str, Any]
synchronous: NotRequired[bool]
class SpecificationDto(TypedDict):
id: str
context: str
name: str
description: str
# function is none (or function key not present) if this is actually VariableSpecDto
function: NotRequired[FunctionSpecification | None]
type: Literal['apiFunction', 'customFunction', 'serverFunction', 'authFunction', 'webhookHandle', 'serverVariable', 'table']
code: NotRequired[str]
language: str
# Enum for variable secrecy levels
Secrecy = Literal['SECRET', 'OBSCURED', 'NONE']
class VariableSpecification(TypedDict):
environmentId: str
value: Any
valueType: PropertyType
secrecy: Secrecy
class VariableSpecDto(TypedDict):
id: str
context: str
name: str
description: str
variable: VariableSpecification
type: Literal['serverVariable']
class SchemaSpecDto(TypedDict):
id: str
context: str
name: str
contextName: str
type: Literal['schema']
definition: Dict[Any, Any]
visibilityMetadata: object
unresolvedPolySchemaRefs: List
# TODO add more
class TableSpecDto(TypedDict):
id: str
context: str
name: str
contextName: str
description: str
type: Literal['table']
schema: Dict[Any, Any]
unresolvedPolySchemaRefs: List
Visibility = Union[Literal['PUBLIC'], Literal['TENANT'], Literal['ENVIRONMENT']]
class PolyDeployable(TypedDict, total=False):
context: str
name: str
description: NotRequired[str]
disable_ai: NotRequired[bool] # Optional field to disable AI
class PolyServerFunction(PolyDeployable):
logs_enabled: NotRequired[bool]
always_on: NotRequired[bool]
visibility: NotRequired[Visibility]
class PolyClientFunction(PolyDeployable):
logs_enabled: NotRequired[bool]
visibility: NotRequired[Visibility]
class Table(TypedDict):
id: str
createdAt: str
updatedAt: str
class PolyCountResult(TypedDict):
count: int
class PolyDeleteResults(TypedDict):
deleted: int
class PolyDeleteResult(TypedDict):
deleted: bool
QueryMode = Literal["default", "insensitive"]
SortOrder = Literal["asc", "desc"]
# Using functional form because of use of reserved keywords
StringFilter = TypedDict("StringFilter", {
"equals": NotRequired[str],
"in": NotRequired[List[str]],
"not_in": NotRequired[List[str]],
"lt": NotRequired[str],
"lte": NotRequired[str],
"gt": NotRequired[str],
"gte": NotRequired[str],
"contains": NotRequired[str],
"starts_with": NotRequired[str],
"ends_with": NotRequired[str],
"mode": NotRequired[QueryMode],
"not": NotRequired[Union[str, "StringFilter"]],
})
# Using functional form because of use of reserved keywords
NullableStringFilter = TypedDict("NullableStringFilter", {
"equals": NotRequired[Union[str, None]],
"in": NotRequired[List[str]],
"not_in": NotRequired[List[str]],
"lt": NotRequired[str],
"lte": NotRequired[str],
"gt": NotRequired[str],
"gte": NotRequired[str],
"contains": NotRequired[str],
"starts_with": NotRequired[str],
"ends_with": NotRequired[str],
"mode": NotRequired[QueryMode],
"not": NotRequired[Union[str, None, "NullableStringFilter"]],
})
# Using functional form because of use of reserved keywords
NumberFilter = TypedDict("NumberFilter", {
"equals": NotRequired[Union[int, float]],
"in": NotRequired[List[Union[int, float]]],
"not_in": NotRequired[List[Union[int, float]]],
"lt": NotRequired[Union[int, float]],
"lte": NotRequired[Union[int, float]],
"gt": NotRequired[Union[int, float]],
"gte": NotRequired[Union[int, float]],
"not": NotRequired[Union[int, float, "NumberFilter"]],
})
# Using functional form because of use of reserved keywords
NullableNumberFilter = TypedDict("NullableNumberFilter", {
"equals": NotRequired[Union[int, float, None]],
"in": NotRequired[List[Union[int, float]]],
"not_in": NotRequired[List[Union[int, float]]],
"lt": NotRequired[Union[int, float]],
"lte": NotRequired[Union[int, float]],
"gt": NotRequired[Union[int, float]],
"gte": NotRequired[Union[int, float]],
"not": NotRequired[Union[int, float, None, "NullableNumberFilter"]],
})
# Using functional form because of use of reserved keywords
BooleanFilter = TypedDict("BooleanFilter", {
"equals": NotRequired[bool],
"not": NotRequired[Union[bool, "BooleanFilter"]],
})
# Using functional form because of use of reserved keywords
NullableBooleanFilter = TypedDict("NullableBooleanFilter", {
"equals": NotRequired[Union[bool, None]],
"not": NotRequired[Union[bool, None, "NullableBooleanFilter"]],
})
# Using functional form because of use of reserved keywords
NullableObjectFilter = TypedDict("NullableObjectFilter", {
"equals": NotRequired[None],
"not": NotRequired[Union[None, "NullableObjectFilter"]],
})