corebase 1.0.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.
- corebase/__init__.py +108 -0
- corebase/_async/__init__.py +1 -0
- corebase/_async/auth_client.py +55 -0
- corebase/_async/client.py +398 -0
- corebase/_sync/__init__.py +1 -0
- corebase/_sync/auth_client.py +55 -0
- corebase/_sync/client.py +393 -0
- corebase/auth/__init__.py +20 -0
- corebase/auth/_async/__init__.py +1 -0
- corebase/auth/_async/gotrue_admin_api.py +356 -0
- corebase/auth/_async/gotrue_admin_mfa_api.py +32 -0
- corebase/auth/_async/gotrue_admin_oauth_api.py +93 -0
- corebase/auth/_async/gotrue_base_api.py +78 -0
- corebase/auth/_async/gotrue_client.py +1404 -0
- corebase/auth/_async/gotrue_mfa_api.py +94 -0
- corebase/auth/_async/storage.py +31 -0
- corebase/auth/_sync/__init__.py +1 -0
- corebase/auth/_sync/gotrue_admin_api.py +356 -0
- corebase/auth/_sync/gotrue_admin_mfa_api.py +32 -0
- corebase/auth/_sync/gotrue_admin_oauth_api.py +93 -0
- corebase/auth/_sync/gotrue_base_api.py +78 -0
- corebase/auth/_sync/gotrue_client.py +1394 -0
- corebase/auth/_sync/gotrue_mfa_api.py +94 -0
- corebase/auth/_sync/storage.py +31 -0
- corebase/auth/constants.py +15 -0
- corebase/auth/errors.py +259 -0
- corebase/auth/helpers.py +288 -0
- corebase/auth/py.typed +0 -0
- corebase/auth/timer.py +53 -0
- corebase/auth/types.py +1021 -0
- corebase/auth/version.py +1 -0
- corebase/client.py +12 -0
- corebase/functions/__init__.py +47 -0
- corebase/functions/_async/__init__.py +1 -0
- corebase/functions/_async/functions_client.py +218 -0
- corebase/functions/_sync/__init__.py +1 -0
- corebase/functions/_sync/functions_client.py +218 -0
- corebase/functions/errors.py +62 -0
- corebase/functions/py.typed +0 -0
- corebase/functions/utils.py +33 -0
- corebase/functions/version.py +1 -0
- corebase/lib/__init__.py +3 -0
- corebase/lib/client_options.py +189 -0
- corebase/migrate/__init__.py +374 -0
- corebase/migrate/__main__.py +7 -0
- corebase/postgrest/__init__.py +62 -0
- corebase/postgrest/_async/__init__.py +1 -0
- corebase/postgrest/_async/client.py +206 -0
- corebase/postgrest/_async/request_builder.py +503 -0
- corebase/postgrest/_sync/__init__.py +1 -0
- corebase/postgrest/_sync/client.py +206 -0
- corebase/postgrest/_sync/request_builder.py +503 -0
- corebase/postgrest/base_client.py +61 -0
- corebase/postgrest/base_request_builder.py +787 -0
- corebase/postgrest/constants.py +6 -0
- corebase/postgrest/exceptions.py +115 -0
- corebase/postgrest/py.typed +0 -0
- corebase/postgrest/types.py +72 -0
- corebase/postgrest/utils.py +91 -0
- corebase/postgrest/version.py +1 -0
- corebase/py.typed +0 -0
- corebase/realtime/__init__.py +17 -0
- corebase/realtime/_async/__init__.py +0 -0
- corebase/realtime/_async/channel.py +766 -0
- corebase/realtime/_async/client.py +498 -0
- corebase/realtime/_async/presence.py +185 -0
- corebase/realtime/_async/push.py +162 -0
- corebase/realtime/_async/timer.py +41 -0
- corebase/realtime/_sync/__init__.py +0 -0
- corebase/realtime/_sync/channel.py +30 -0
- corebase/realtime/_sync/client.py +71 -0
- corebase/realtime/_sync/presence.py +10 -0
- corebase/realtime/exceptions.py +38 -0
- corebase/realtime/message.py +176 -0
- corebase/realtime/py.typed +0 -0
- corebase/realtime/transformers.py +9 -0
- corebase/realtime/types.py +246 -0
- corebase/realtime/utils.py +5 -0
- corebase/realtime/version.py +1 -0
- corebase/storage/__init__.py +56 -0
- corebase/storage/_async/__init__.py +1 -0
- corebase/storage/_async/analytics.py +82 -0
- corebase/storage/_async/bucket.py +142 -0
- corebase/storage/_async/client.py +106 -0
- corebase/storage/_async/file_api.py +630 -0
- corebase/storage/_async/request.py +32 -0
- corebase/storage/_async/vectors.py +213 -0
- corebase/storage/_sync/__init__.py +1 -0
- corebase/storage/_sync/analytics.py +80 -0
- corebase/storage/_sync/bucket.py +142 -0
- corebase/storage/_sync/client.py +106 -0
- corebase/storage/_sync/file_api.py +630 -0
- corebase/storage/_sync/request.py +32 -0
- corebase/storage/_sync/vectors.py +199 -0
- corebase/storage/constants.py +16 -0
- corebase/storage/exceptions.py +84 -0
- corebase/storage/py.typed +0 -0
- corebase/storage/types.py +313 -0
- corebase/storage/utils.py +26 -0
- corebase/storage/version.py +1 -0
- corebase/types.py +8 -0
- corebase/version.py +1 -0
- corebase-1.0.0.dist-info/METADATA +78 -0
- corebase-1.0.0.dist-info/RECORD +106 -0
- corebase-1.0.0.dist-info/WHEEL +4 -0
- corebase-1.0.0.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import builtins
|
|
4
|
+
|
|
5
|
+
from httpx import Client, Headers
|
|
6
|
+
from yarl import URL
|
|
7
|
+
|
|
8
|
+
from ..exceptions import StorageApiError, VectorBucketException
|
|
9
|
+
from ..types import (
|
|
10
|
+
JSON,
|
|
11
|
+
DistanceMetric,
|
|
12
|
+
GetVectorBucketResponse,
|
|
13
|
+
GetVectorIndexResponse,
|
|
14
|
+
GetVectorsResponse,
|
|
15
|
+
ListVectorBucketsResponse,
|
|
16
|
+
ListVectorIndexesResponse,
|
|
17
|
+
ListVectorsResponse,
|
|
18
|
+
MetadataConfiguration,
|
|
19
|
+
QueryVectorsResponse,
|
|
20
|
+
VectorData,
|
|
21
|
+
VectorFilter,
|
|
22
|
+
VectorObject,
|
|
23
|
+
)
|
|
24
|
+
from .request import SyncRequestBuilder
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# used to not send non-required values as `null`
|
|
28
|
+
# for they cannot be null
|
|
29
|
+
def remove_none(**kwargs: JSON) -> JSON:
|
|
30
|
+
return {key: val for key, val in kwargs.items() if val is not None}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class SyncVectorBucketScope:
|
|
34
|
+
def __init__(self, request: SyncRequestBuilder, bucket_name: str) -> None:
|
|
35
|
+
self._request = request
|
|
36
|
+
self._bucket_name = bucket_name
|
|
37
|
+
|
|
38
|
+
def with_metadata(self, **data: JSON) -> JSON:
|
|
39
|
+
return remove_none(vectorBucketName=self._bucket_name, **data)
|
|
40
|
+
|
|
41
|
+
def create_index(
|
|
42
|
+
self,
|
|
43
|
+
index_name: str,
|
|
44
|
+
dimension: int,
|
|
45
|
+
distance_metric: DistanceMetric,
|
|
46
|
+
data_type: str,
|
|
47
|
+
metadata: MetadataConfiguration | None = None,
|
|
48
|
+
) -> None:
|
|
49
|
+
metadata_configuration = (
|
|
50
|
+
metadata.model_dump(by_alias=True, exclude_none=True) if metadata else None
|
|
51
|
+
)
|
|
52
|
+
body = self.with_metadata(
|
|
53
|
+
indexName=index_name,
|
|
54
|
+
dimension=dimension,
|
|
55
|
+
distanceMetric=distance_metric,
|
|
56
|
+
dataType=data_type,
|
|
57
|
+
metadataConfiguration=metadata_configuration or None,
|
|
58
|
+
)
|
|
59
|
+
self._request.send(http_method="POST", path=["CreateIndex"], body=body)
|
|
60
|
+
|
|
61
|
+
def get_index(self, index_name: str) -> GetVectorIndexResponse | None:
|
|
62
|
+
body = self.with_metadata(indexName=index_name)
|
|
63
|
+
try:
|
|
64
|
+
data = self._request.send(http_method="POST", path=["GetIndex"], body=body)
|
|
65
|
+
return GetVectorIndexResponse.model_validate_json(data.content)
|
|
66
|
+
except StorageApiError:
|
|
67
|
+
return None
|
|
68
|
+
|
|
69
|
+
def list_indexes(
|
|
70
|
+
self,
|
|
71
|
+
next_token: str | None = None,
|
|
72
|
+
max_results: int | None = None,
|
|
73
|
+
prefix: str | None = None,
|
|
74
|
+
) -> ListVectorIndexesResponse:
|
|
75
|
+
body = self.with_metadata(
|
|
76
|
+
nextToken=next_token, maxResults=max_results, prefix=prefix
|
|
77
|
+
)
|
|
78
|
+
data = self._request.send(http_method="POST", path=["ListIndexes"], body=body)
|
|
79
|
+
return ListVectorIndexesResponse.model_validate_json(data.content)
|
|
80
|
+
|
|
81
|
+
def delete_index(self, index_name: str) -> None:
|
|
82
|
+
body = self.with_metadata(indexName=index_name)
|
|
83
|
+
self._request.send(http_method="POST", path=["DeleteIndex"], body=body)
|
|
84
|
+
|
|
85
|
+
def index(self, index_name: str) -> SyncVectorIndexScope:
|
|
86
|
+
return SyncVectorIndexScope(self._request, self._bucket_name, index_name)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class SyncVectorIndexScope:
|
|
90
|
+
def __init__(
|
|
91
|
+
self, request: SyncRequestBuilder, bucket_name: str, index_name: str
|
|
92
|
+
) -> None:
|
|
93
|
+
self._request = request
|
|
94
|
+
self._bucket_name = bucket_name
|
|
95
|
+
self._index_name = index_name
|
|
96
|
+
|
|
97
|
+
def with_metadata(self, **data: JSON) -> JSON:
|
|
98
|
+
return remove_none(
|
|
99
|
+
vectorBucketName=self._bucket_name,
|
|
100
|
+
indexName=self._index_name,
|
|
101
|
+
**data,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
def put(self, vectors: builtins.list[VectorObject]) -> None:
|
|
105
|
+
body = self.with_metadata(
|
|
106
|
+
vectors=[v.model_dump(exclude_none=True) for v in vectors]
|
|
107
|
+
)
|
|
108
|
+
self._request.send(http_method="POST", path=["PutVectors"], body=body)
|
|
109
|
+
|
|
110
|
+
def get(
|
|
111
|
+
self, *keys: str, return_data: bool = True, return_metadata: bool = True
|
|
112
|
+
) -> GetVectorsResponse:
|
|
113
|
+
body = self.with_metadata(
|
|
114
|
+
keys=keys, returnData=return_data, returnMetadata=return_metadata
|
|
115
|
+
)
|
|
116
|
+
data = self._request.send(http_method="POST", path=["GetVectors"], body=body)
|
|
117
|
+
return GetVectorsResponse.model_validate_json(data.content)
|
|
118
|
+
|
|
119
|
+
def list(
|
|
120
|
+
self,
|
|
121
|
+
max_results: int | None = None,
|
|
122
|
+
next_token: str | None = None,
|
|
123
|
+
return_data: bool = True,
|
|
124
|
+
return_metadata: bool = True,
|
|
125
|
+
segment_count: int | None = None,
|
|
126
|
+
segment_index: int | None = None,
|
|
127
|
+
) -> ListVectorsResponse:
|
|
128
|
+
body = self.with_metadata(
|
|
129
|
+
maxResults=max_results,
|
|
130
|
+
nextToken=next_token,
|
|
131
|
+
returnData=return_data,
|
|
132
|
+
returnMetadata=return_metadata,
|
|
133
|
+
segmentCount=segment_count,
|
|
134
|
+
segmentIndex=segment_index,
|
|
135
|
+
)
|
|
136
|
+
data = self._request.send(http_method="POST", path=["ListVectors"], body=body)
|
|
137
|
+
return ListVectorsResponse.model_validate_json(data.content)
|
|
138
|
+
|
|
139
|
+
def query(
|
|
140
|
+
self,
|
|
141
|
+
query_vector: VectorData,
|
|
142
|
+
topK: int,
|
|
143
|
+
filter: VectorFilter | None = None,
|
|
144
|
+
return_distance: bool = True,
|
|
145
|
+
return_metadata: bool = True,
|
|
146
|
+
) -> QueryVectorsResponse:
|
|
147
|
+
body = self.with_metadata(
|
|
148
|
+
queryVector=dict(query_vector),
|
|
149
|
+
topK=topK,
|
|
150
|
+
filter=filter,
|
|
151
|
+
returnDistance=return_distance,
|
|
152
|
+
returnMetadata=return_metadata,
|
|
153
|
+
)
|
|
154
|
+
data = self._request.send(http_method="POST", path=["QueryVectors"], body=body)
|
|
155
|
+
return QueryVectorsResponse.model_validate_json(data.content)
|
|
156
|
+
|
|
157
|
+
def delete(self, keys: builtins.list[str]) -> None:
|
|
158
|
+
if len(keys) < 1 or len(keys) > 500:
|
|
159
|
+
raise VectorBucketException("Keys batch size must be between 1 and 500.")
|
|
160
|
+
body = self.with_metadata(keys=keys)
|
|
161
|
+
self._request.send(http_method="POST", path=["DeleteVectors"], body=body)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
class SyncStorageVectorsClient:
|
|
165
|
+
def __init__(self, url: URL, headers: Headers, session: Client) -> None:
|
|
166
|
+
self._request = SyncRequestBuilder(session, base_url=URL(url), headers=headers)
|
|
167
|
+
|
|
168
|
+
def from_(self, bucket_name: str) -> SyncVectorBucketScope:
|
|
169
|
+
return SyncVectorBucketScope(self._request, bucket_name)
|
|
170
|
+
|
|
171
|
+
def create_bucket(self, bucket_name: str) -> None:
|
|
172
|
+
body = {"vectorBucketName": bucket_name}
|
|
173
|
+
self._request.send(http_method="POST", path=["CreateVectorBucket"], body=body)
|
|
174
|
+
|
|
175
|
+
def get_bucket(self, bucket_name: str) -> GetVectorBucketResponse | None:
|
|
176
|
+
body = {"vectorBucketName": bucket_name}
|
|
177
|
+
try:
|
|
178
|
+
data = self._request.send(
|
|
179
|
+
http_method="POST", path=["GetVectorBucket"], body=body
|
|
180
|
+
)
|
|
181
|
+
return GetVectorBucketResponse.model_validate_json(data.content)
|
|
182
|
+
except StorageApiError:
|
|
183
|
+
return None
|
|
184
|
+
|
|
185
|
+
def list_buckets(
|
|
186
|
+
self,
|
|
187
|
+
prefix: str | None = None,
|
|
188
|
+
max_results: int | None = None,
|
|
189
|
+
next_token: str | None = None,
|
|
190
|
+
) -> ListVectorBucketsResponse:
|
|
191
|
+
body = remove_none(prefix=prefix, maxResults=max_results, nextToken=next_token)
|
|
192
|
+
data = self._request.send(
|
|
193
|
+
http_method="POST", path=["ListVectorBuckets"], body=body
|
|
194
|
+
)
|
|
195
|
+
return ListVectorBucketsResponse.model_validate_json(data.content)
|
|
196
|
+
|
|
197
|
+
def delete_bucket(self, bucket_name: str) -> None:
|
|
198
|
+
body = {"vectorBucketName": bucket_name}
|
|
199
|
+
self._request.send(http_method="POST", path=["DeleteVectorBucket"], body=body)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
DEFAULT_SORT_BY = {
|
|
2
|
+
"column": "name",
|
|
3
|
+
"order": "asc",
|
|
4
|
+
}
|
|
5
|
+
DEFAULT_SEARCH_OPTIONS = {
|
|
6
|
+
"limit": 100,
|
|
7
|
+
"offset": 0,
|
|
8
|
+
"sortBy": DEFAULT_SORT_BY,
|
|
9
|
+
}
|
|
10
|
+
DEFAULT_FILE_OPTIONS = {
|
|
11
|
+
"cache-control": "3600",
|
|
12
|
+
"content-type": "text/plain;charset=UTF-8",
|
|
13
|
+
"x-upsert": "false",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
DEFAULT_TIMEOUT = 20
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
from typing import TypedDict
|
|
2
|
+
|
|
3
|
+
from httpx import Response
|
|
4
|
+
from pydantic import BaseModel, ValidationError
|
|
5
|
+
|
|
6
|
+
from .utils import StorageException
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class VectorBucketException(Exception):
|
|
10
|
+
def __init__(self, msg: str) -> None:
|
|
11
|
+
self.msg = msg
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class VectorBucketErrorMessage(BaseModel):
|
|
15
|
+
statusCode: str | int
|
|
16
|
+
error: str
|
|
17
|
+
message: str
|
|
18
|
+
code: str | None = None
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class _AnalyticsBucketErrorDetail(BaseModel):
|
|
22
|
+
message: str
|
|
23
|
+
type: str
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class _AnalyticsBucketErrorMessage(BaseModel):
|
|
27
|
+
error: _AnalyticsBucketErrorDetail
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class StorageApiErrorDict(TypedDict):
|
|
31
|
+
name: str
|
|
32
|
+
message: str
|
|
33
|
+
code: str
|
|
34
|
+
status: int | str
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class StorageApiError(StorageException):
|
|
38
|
+
"""Error raised when an operation on the storage API fails."""
|
|
39
|
+
|
|
40
|
+
def __init__(self, message: str, code: str, status: int | str) -> None:
|
|
41
|
+
error_message = (
|
|
42
|
+
f"{{'statusCode': {status}, 'error': {code}, 'message': {message}}}"
|
|
43
|
+
)
|
|
44
|
+
super().__init__(error_message)
|
|
45
|
+
self.name = "StorageApiError"
|
|
46
|
+
self.message = message
|
|
47
|
+
self.code = code
|
|
48
|
+
self.status = status
|
|
49
|
+
|
|
50
|
+
def to_dict(self) -> StorageApiErrorDict:
|
|
51
|
+
return {
|
|
52
|
+
"name": self.name,
|
|
53
|
+
"code": self.code,
|
|
54
|
+
"message": self.message,
|
|
55
|
+
"status": self.status,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def _parse_storage_api_error(response: Response) -> StorageApiError:
|
|
60
|
+
try:
|
|
61
|
+
error = VectorBucketErrorMessage.model_validate_json(response.content)
|
|
62
|
+
return StorageApiError(
|
|
63
|
+
message=error.message,
|
|
64
|
+
code=error.code or "400",
|
|
65
|
+
status=error.statusCode,
|
|
66
|
+
)
|
|
67
|
+
except ValidationError:
|
|
68
|
+
pass
|
|
69
|
+
try:
|
|
70
|
+
analytics_error = _AnalyticsBucketErrorMessage.model_validate_json(
|
|
71
|
+
response.content
|
|
72
|
+
)
|
|
73
|
+
return StorageApiError(
|
|
74
|
+
message=analytics_error.error.message,
|
|
75
|
+
code=analytics_error.error.type,
|
|
76
|
+
status=response.status_code,
|
|
77
|
+
)
|
|
78
|
+
except ValidationError:
|
|
79
|
+
pass
|
|
80
|
+
return StorageApiError(
|
|
81
|
+
message=f"The request failed, but could not parse error message response:'{response.text}'",
|
|
82
|
+
code="LibraryError",
|
|
83
|
+
status=response.status_code,
|
|
84
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from collections.abc import Mapping, Sequence
|
|
4
|
+
from dataclasses import asdict, dataclass
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Any, Literal, TypeAlias, TypedDict
|
|
7
|
+
|
|
8
|
+
from pydantic import AliasChoices, BaseModel, Field, TypeAdapter
|
|
9
|
+
from typing_extensions import ReadOnly, TypeAliasType
|
|
10
|
+
|
|
11
|
+
RequestMethod = Literal["GET", "POST", "DELETE", "PUT", "HEAD"]
|
|
12
|
+
|
|
13
|
+
# https://docs.pydantic.dev/2.11/concepts/types/#named-recursive-types
|
|
14
|
+
JSON = TypeAliasType(
|
|
15
|
+
"JSON", "None | bool | str | int | float | Sequence[JSON] | Mapping[str, JSON]"
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class BaseBucket(BaseModel, extra="ignore"):
|
|
20
|
+
"""Represents a file storage bucket."""
|
|
21
|
+
|
|
22
|
+
id: str
|
|
23
|
+
name: str
|
|
24
|
+
owner: str
|
|
25
|
+
public: bool
|
|
26
|
+
created_at: datetime
|
|
27
|
+
updated_at: datetime
|
|
28
|
+
file_size_limit: int | None
|
|
29
|
+
allowed_mime_types: list[str] | None
|
|
30
|
+
type: str | None = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# used in bucket.list method's option parameter
|
|
34
|
+
class _sortByType(TypedDict, total=False):
|
|
35
|
+
column: str
|
|
36
|
+
order: Literal["asc", "desc"]
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class SignedUploadURL(TypedDict):
|
|
40
|
+
signed_url: str
|
|
41
|
+
signedUrl: str
|
|
42
|
+
token: str
|
|
43
|
+
path: str
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class CreateOrUpdateBucketOptions(TypedDict, total=False):
|
|
47
|
+
public: bool
|
|
48
|
+
file_size_limit: int
|
|
49
|
+
allowed_mime_types: list[str]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class ListBucketFilesOptions(TypedDict, total=False):
|
|
53
|
+
limit: int
|
|
54
|
+
offset: int
|
|
55
|
+
sortBy: _sortByType
|
|
56
|
+
search: str
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
class TransformOptions(TypedDict, total=False):
|
|
60
|
+
height: ReadOnly[int]
|
|
61
|
+
width: ReadOnly[int]
|
|
62
|
+
resize: ReadOnly[Literal["cover", "contain", "fill"]]
|
|
63
|
+
format: ReadOnly[Literal["origin", "avif"]]
|
|
64
|
+
quality: ReadOnly[int]
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def transform_to_dict(t: TransformOptions) -> dict[str, str]:
|
|
68
|
+
return {key: str(val) for key, val in t.items()}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class URLOptions(TypedDict, total=False):
|
|
72
|
+
download: str | bool
|
|
73
|
+
transform: TransformOptions
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class CreateSignedURLsOptions(TypedDict, total=False):
|
|
77
|
+
download: str | bool
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class SortByV2(TypedDict, total=False):
|
|
81
|
+
column: Literal["name", "updated_at", "created_at"]
|
|
82
|
+
order: Literal["asc", "desc"]
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class SearchV2Options(TypedDict, total=False):
|
|
86
|
+
limit: int
|
|
87
|
+
prefix: str
|
|
88
|
+
cursor: str
|
|
89
|
+
with_delimiter: bool
|
|
90
|
+
sortBy: SortByV2
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class SearchV2Object(BaseModel):
|
|
94
|
+
id: str
|
|
95
|
+
name: str
|
|
96
|
+
updated_at: datetime
|
|
97
|
+
created_at: datetime
|
|
98
|
+
metadata: dict[str, Any] | None
|
|
99
|
+
key: str | None = None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
class SearchV2Folder(BaseModel):
|
|
103
|
+
key: str | None = None
|
|
104
|
+
name: str
|
|
105
|
+
created_at: datetime | None = None
|
|
106
|
+
updated_at: datetime | None = None
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class SearchV2Result(BaseModel):
|
|
110
|
+
hasNext: bool
|
|
111
|
+
folders: list[SearchV2Folder]
|
|
112
|
+
objects: list[SearchV2Object]
|
|
113
|
+
nextCursor: str | None = None
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class DownloadOptions(TypedDict, total=False):
|
|
117
|
+
transform: TransformOptions
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
FileOptions = TypedDict(
|
|
121
|
+
"FileOptions",
|
|
122
|
+
{
|
|
123
|
+
"cache-control": str,
|
|
124
|
+
"content-type": str,
|
|
125
|
+
"x-upsert": str,
|
|
126
|
+
"upsert": str,
|
|
127
|
+
"metadata": dict[str, Any],
|
|
128
|
+
"headers": dict[str, str],
|
|
129
|
+
},
|
|
130
|
+
total=False,
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
class UploadData(TypedDict, total=False):
|
|
135
|
+
Id: str
|
|
136
|
+
Key: str
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
@dataclass
|
|
140
|
+
class UploadResponse:
|
|
141
|
+
path: str
|
|
142
|
+
full_path: str
|
|
143
|
+
fullPath: str
|
|
144
|
+
|
|
145
|
+
def __init__(self, path: str, Key: str) -> None:
|
|
146
|
+
self.path = path
|
|
147
|
+
self.full_path = Key
|
|
148
|
+
self.fullPath = Key
|
|
149
|
+
|
|
150
|
+
dict = asdict
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
class SignedUrlResponse(TypedDict):
|
|
154
|
+
signedURL: str | None
|
|
155
|
+
signedUrl: str | None
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class CreateSignedUrlResponse(TypedDict):
|
|
159
|
+
error: str | None
|
|
160
|
+
path: str
|
|
161
|
+
signedURL: str | None
|
|
162
|
+
signedUrl: str | None
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
class SignedUrlJsonResponse(BaseModel, extra="ignore"):
|
|
166
|
+
signedURL: str
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class SignedUrlsJsonItem(BaseModel, extra="ignore"):
|
|
170
|
+
error: str | None
|
|
171
|
+
path: str
|
|
172
|
+
signedURL: str | None
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
SignedUrlsJsonResponse: TypeAdapter[list[SignedUrlsJsonItem]] = TypeAdapter(
|
|
176
|
+
list[SignedUrlsJsonItem]
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
class CreateSignedUploadUrlOptions(BaseModel, extra="ignore"):
|
|
181
|
+
upsert: str
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
UploadSignedUrlFileOptions = TypedDict(
|
|
185
|
+
"UploadSignedUrlFileOptions",
|
|
186
|
+
{
|
|
187
|
+
"cache-control": str,
|
|
188
|
+
"content-type": str,
|
|
189
|
+
"metadata": dict[str, Any],
|
|
190
|
+
"headers": dict[str, str],
|
|
191
|
+
},
|
|
192
|
+
total=False,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
DistanceMetric: TypeAlias = Literal["cosine", "euclidean"]
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
class MetadataConfiguration(BaseModel, extra="ignore"):
|
|
199
|
+
non_filterable_metadata_keys: list[str] | None = Field(
|
|
200
|
+
default=None,
|
|
201
|
+
validation_alias=AliasChoices(
|
|
202
|
+
"non_filterable_metadata_keys", "nonFilterableMetadataKeys"
|
|
203
|
+
),
|
|
204
|
+
serialization_alias="nonFilterableMetadataKeys",
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class ListIndexesOptions(BaseModel, extra="ignore"):
|
|
209
|
+
nextToken: str | None = None
|
|
210
|
+
maxResults: int | None = None
|
|
211
|
+
prefix: str | None = None
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class ListIndexesResponseItem(BaseModel, extra="ignore"):
|
|
215
|
+
indexName: str
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
class ListVectorIndexesResponse(BaseModel, extra="ignore"):
|
|
219
|
+
indexes: list[ListIndexesResponseItem]
|
|
220
|
+
nextToken: str | None = None
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class VectorIndex(BaseModel, extra="ignore"):
|
|
224
|
+
index_name: str = Field(alias="indexName")
|
|
225
|
+
bucket_name: str = Field(alias="vectorBucketName")
|
|
226
|
+
data_type: str = Field(alias="dataType")
|
|
227
|
+
dimension: int
|
|
228
|
+
distance_metric: DistanceMetric = Field(alias="distanceMetric")
|
|
229
|
+
metadata: MetadataConfiguration | None = Field(
|
|
230
|
+
alias="metadataConfiguration", default=None
|
|
231
|
+
)
|
|
232
|
+
creation_time: datetime | None = Field(alias="creationTime", default=None)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
class GetVectorIndexResponse(BaseModel, extra="ignore"):
|
|
236
|
+
index: VectorIndex
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
VectorFilter = dict[str, Any]
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
class VectorData(BaseModel, extra="ignore"):
|
|
243
|
+
float32: list[float]
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
class VectorObject(BaseModel, extra="ignore"):
|
|
247
|
+
key: str
|
|
248
|
+
data: VectorData
|
|
249
|
+
metadata: dict[str, JSON] | None = None
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class VectorMatch(BaseModel, extra="ignore"):
|
|
253
|
+
key: str
|
|
254
|
+
data: VectorData | None = None
|
|
255
|
+
distance: float | None = None
|
|
256
|
+
metadata: dict[str, Any] | None = None
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class GetVectorsResponse(BaseModel, extra="ignore"):
|
|
260
|
+
vectors: list[VectorMatch]
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
class ListVectorsResponse(BaseModel, extra="ignore"):
|
|
264
|
+
vectors: list[VectorMatch]
|
|
265
|
+
nextToken: str | None = None
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
class QueryVectorsResponse(BaseModel, extra="ignore"):
|
|
269
|
+
vectors: list[VectorMatch]
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class AnalyticsBucket(BaseModel, extra="ignore"):
|
|
273
|
+
name: str
|
|
274
|
+
type: Literal["ANALYTICS"] | None = None
|
|
275
|
+
format: str | None = None
|
|
276
|
+
created_at: datetime
|
|
277
|
+
updated_at: datetime
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
SortColumn = Literal["id", "name", "created_at", "updated_at"]
|
|
281
|
+
SortOrder = Literal["asc", "desc"]
|
|
282
|
+
|
|
283
|
+
AnalyticsBucketsParser: TypeAdapter[list[AnalyticsBucket]] = TypeAdapter(
|
|
284
|
+
list[AnalyticsBucket]
|
|
285
|
+
)
|
|
286
|
+
|
|
287
|
+
|
|
288
|
+
class AnalyticsBucketDeleteResponse(BaseModel, extra="ignore"):
|
|
289
|
+
message: str
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class VectorBucketEncryptionConfiguration(BaseModel, extra="ignore"):
|
|
293
|
+
kmsKeyArn: str | None = None
|
|
294
|
+
sseType: str | None = None
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
class VectorBucket(BaseModel, extra="ignore"):
|
|
298
|
+
vectorBucketName: str
|
|
299
|
+
creationTime: datetime | None = None
|
|
300
|
+
encryptionConfiguration: VectorBucketEncryptionConfiguration | None = None
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
class GetVectorBucketResponse(BaseModel, extra="ignore"):
|
|
304
|
+
vectorBucket: VectorBucket
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
class ListVectorBucketsItem(BaseModel, extra="ignore"):
|
|
308
|
+
vectorBucketName: str
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
class ListVectorBucketsResponse(BaseModel, extra="ignore"):
|
|
312
|
+
vectorBuckets: list[ListVectorBucketsItem]
|
|
313
|
+
nextToken: str | None = None
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from deprecation import deprecated
|
|
2
|
+
from httpx import AsyncClient as AsyncClient
|
|
3
|
+
from httpx import Client
|
|
4
|
+
|
|
5
|
+
from .version import __version__
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SyncClient(Client):
|
|
9
|
+
@deprecated(
|
|
10
|
+
"0.11.3", "3.0.0", __version__, "Use `Client` from the httpx package instead"
|
|
11
|
+
)
|
|
12
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
13
|
+
super().__init__(*args, **kwargs)
|
|
14
|
+
|
|
15
|
+
@deprecated(
|
|
16
|
+
"0.11.3",
|
|
17
|
+
"3.0.0",
|
|
18
|
+
__version__,
|
|
19
|
+
"Use `close` method from `Client` in the httpx package instead",
|
|
20
|
+
)
|
|
21
|
+
def aclose(self) -> None:
|
|
22
|
+
self.close()
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class StorageException(Exception):
|
|
26
|
+
"""Error raised when an operation on the storage API fails."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0" # {x-release-please-version}
|
corebase/types.py
ADDED
corebase/version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "1.0.0" # {x-release-please-version}
|