turbopuffer-ruby 0.2.0.pre.alpha.1
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.
- checksums.yaml +7 -0
- data/.ignore +2 -0
- data/CHANGELOG.md +60 -0
- data/README.md +291 -0
- data/SECURITY.md +27 -0
- data/lib/turbopuffer/client.rb +130 -0
- data/lib/turbopuffer/errors.rb +214 -0
- data/lib/turbopuffer/file_part.rb +55 -0
- data/lib/turbopuffer/internal/namespace_page.rb +86 -0
- data/lib/turbopuffer/internal/transport/base_client.rb +563 -0
- data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +209 -0
- data/lib/turbopuffer/internal/type/array_of.rb +167 -0
- data/lib/turbopuffer/internal/type/base_model.rb +534 -0
- data/lib/turbopuffer/internal/type/base_page.rb +55 -0
- data/lib/turbopuffer/internal/type/boolean.rb +77 -0
- data/lib/turbopuffer/internal/type/converter.rb +300 -0
- data/lib/turbopuffer/internal/type/enum.rb +152 -0
- data/lib/turbopuffer/internal/type/file_input.rb +108 -0
- data/lib/turbopuffer/internal/type/hash_of.rb +187 -0
- data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
- data/lib/turbopuffer/internal/type/union.rb +252 -0
- data/lib/turbopuffer/internal/type/unknown.rb +81 -0
- data/lib/turbopuffer/internal/util.rb +914 -0
- data/lib/turbopuffer/internal.rb +20 -0
- data/lib/turbopuffer/models/attribute_schema.rb +19 -0
- data/lib/turbopuffer/models/attribute_schema_config.rb +48 -0
- data/lib/turbopuffer/models/attribute_type.rb +7 -0
- data/lib/turbopuffer/models/client_namespaces_params.rb +38 -0
- data/lib/turbopuffer/models/columns.rb +64 -0
- data/lib/turbopuffer/models/distance_metric.rb +19 -0
- data/lib/turbopuffer/models/full_text_search.rb +20 -0
- data/lib/turbopuffer/models/full_text_search_config.rb +72 -0
- data/lib/turbopuffer/models/id.rb +19 -0
- data/lib/turbopuffer/models/include_attributes.rb +22 -0
- data/lib/turbopuffer/models/language.rb +32 -0
- data/lib/turbopuffer/models/namespace_delete_all_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_delete_all_response.rb +19 -0
- data/lib/turbopuffer/models/namespace_hint_cache_warm_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_hint_cache_warm_response.rb +26 -0
- data/lib/turbopuffer/models/namespace_metadata.rb +35 -0
- data/lib/turbopuffer/models/namespace_metadata_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_multi_query_params.rb +73 -0
- data/lib/turbopuffer/models/namespace_multi_query_response.rb +51 -0
- data/lib/turbopuffer/models/namespace_query_params.rb +119 -0
- data/lib/turbopuffer/models/namespace_query_response.rb +41 -0
- data/lib/turbopuffer/models/namespace_recall_params.rb +57 -0
- data/lib/turbopuffer/models/namespace_recall_response.rb +39 -0
- data/lib/turbopuffer/models/namespace_schema_params.rb +20 -0
- data/lib/turbopuffer/models/namespace_schema_response.rb +8 -0
- data/lib/turbopuffer/models/namespace_summary.rb +19 -0
- data/lib/turbopuffer/models/namespace_update_schema_params.rb +29 -0
- data/lib/turbopuffer/models/namespace_update_schema_response.rb +9 -0
- data/lib/turbopuffer/models/namespace_write_params.rb +158 -0
- data/lib/turbopuffer/models/namespace_write_response.rb +67 -0
- data/lib/turbopuffer/models/query.rb +63 -0
- data/lib/turbopuffer/models/query_billing.rb +26 -0
- data/lib/turbopuffer/models/query_performance.rb +63 -0
- data/lib/turbopuffer/models/row.rb +38 -0
- data/lib/turbopuffer/models/tokenizer.rb +17 -0
- data/lib/turbopuffer/models/vector.rb +22 -0
- data/lib/turbopuffer/models/vector_encoding.rb +16 -0
- data/lib/turbopuffer/models/write_billing.rb +26 -0
- data/lib/turbopuffer/models.rb +101 -0
- data/lib/turbopuffer/namespace.rb +22 -0
- data/lib/turbopuffer/request_options.rb +77 -0
- data/lib/turbopuffer/resources/namespaces.rb +311 -0
- data/lib/turbopuffer/version.rb +5 -0
- data/lib/turbopuffer.rb +94 -0
- data/manifest.yaml +15 -0
- data/rbi/turbopuffer/client.rbi +91 -0
- data/rbi/turbopuffer/errors.rbi +178 -0
- data/rbi/turbopuffer/file_part.rbi +37 -0
- data/rbi/turbopuffer/internal/namespace_page.rbi +22 -0
- data/rbi/turbopuffer/internal/transport/base_client.rbi +298 -0
- data/rbi/turbopuffer/internal/transport/pooled_net_requester.rbi +80 -0
- data/rbi/turbopuffer/internal/type/array_of.rbi +104 -0
- data/rbi/turbopuffer/internal/type/base_model.rbi +304 -0
- data/rbi/turbopuffer/internal/type/base_page.rbi +43 -0
- data/rbi/turbopuffer/internal/type/boolean.rbi +58 -0
- data/rbi/turbopuffer/internal/type/converter.rbi +162 -0
- data/rbi/turbopuffer/internal/type/enum.rbi +82 -0
- data/rbi/turbopuffer/internal/type/file_input.rbi +59 -0
- data/rbi/turbopuffer/internal/type/hash_of.rbi +104 -0
- data/rbi/turbopuffer/internal/type/request_parameters.rbi +31 -0
- data/rbi/turbopuffer/internal/type/union.rbi +121 -0
- data/rbi/turbopuffer/internal/type/unknown.rbi +58 -0
- data/rbi/turbopuffer/internal/util.rbi +487 -0
- data/rbi/turbopuffer/internal.rbi +18 -0
- data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
- data/rbi/turbopuffer/models/attribute_schema_config.rbi +92 -0
- data/rbi/turbopuffer/models/attribute_type.rbi +7 -0
- data/rbi/turbopuffer/models/client_namespaces_params.rbi +71 -0
- data/rbi/turbopuffer/models/columns.rbi +82 -0
- data/rbi/turbopuffer/models/distance_metric.rbi +27 -0
- data/rbi/turbopuffer/models/full_text_search.rbi +19 -0
- data/rbi/turbopuffer/models/full_text_search_config.rbi +116 -0
- data/rbi/turbopuffer/models/id.rbi +16 -0
- data/rbi/turbopuffer/models/include_attributes.rbi +24 -0
- data/rbi/turbopuffer/models/language.rbi +36 -0
- data/rbi/turbopuffer/models/namespace_delete_all_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_delete_all_response.rbi +31 -0
- data/rbi/turbopuffer/models/namespace_hint_cache_warm_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_hint_cache_warm_response.rbi +38 -0
- data/rbi/turbopuffer/models/namespace_metadata.rbi +54 -0
- data/rbi/turbopuffer/models/namespace_metadata_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +175 -0
- data/rbi/turbopuffer/models/namespace_multi_query_response.rbi +111 -0
- data/rbi/turbopuffer/models/namespace_query_params.rbi +241 -0
- data/rbi/turbopuffer/models/namespace_query_response.rbi +73 -0
- data/rbi/turbopuffer/models/namespace_recall_params.rbi +93 -0
- data/rbi/turbopuffer/models/namespace_recall_response.rbi +59 -0
- data/rbi/turbopuffer/models/namespace_schema_params.rbi +41 -0
- data/rbi/turbopuffer/models/namespace_schema_response.rbi +11 -0
- data/rbi/turbopuffer/models/namespace_summary.rbi +28 -0
- data/rbi/turbopuffer/models/namespace_update_schema_params.rbi +80 -0
- data/rbi/turbopuffer/models/namespace_update_schema_response.rbi +11 -0
- data/rbi/turbopuffer/models/namespace_write_params.rbi +290 -0
- data/rbi/turbopuffer/models/namespace_write_response.rbi +101 -0
- data/rbi/turbopuffer/models/query.rbi +106 -0
- data/rbi/turbopuffer/models/query_billing.rbi +46 -0
- data/rbi/turbopuffer/models/query_performance.rbi +82 -0
- data/rbi/turbopuffer/models/row.rbi +47 -0
- data/rbi/turbopuffer/models/tokenizer.rbi +22 -0
- data/rbi/turbopuffer/models/vector.rbi +22 -0
- data/rbi/turbopuffer/models/vector_encoding.rbi +22 -0
- data/rbi/turbopuffer/models/write_billing.rbi +49 -0
- data/rbi/turbopuffer/models.rbi +64 -0
- data/rbi/turbopuffer/namespace.rbi +8 -0
- data/rbi/turbopuffer/request_options.rbi +59 -0
- data/rbi/turbopuffer/resources/namespaces.rbi +243 -0
- data/rbi/turbopuffer/version.rbi +5 -0
- data/sig/turbopuffer/client.rbs +41 -0
- data/sig/turbopuffer/errors.rbs +110 -0
- data/sig/turbopuffer/file_part.rbs +21 -0
- data/sig/turbopuffer/internal/namespace_page.rbs +13 -0
- data/sig/turbopuffer/internal/transport/base_client.rbs +131 -0
- data/sig/turbopuffer/internal/transport/pooled_net_requester.rbs +45 -0
- data/sig/turbopuffer/internal/type/array_of.rbs +48 -0
- data/sig/turbopuffer/internal/type/base_model.rbs +102 -0
- data/sig/turbopuffer/internal/type/base_page.rbs +24 -0
- data/sig/turbopuffer/internal/type/boolean.rbs +26 -0
- data/sig/turbopuffer/internal/type/converter.rbs +62 -0
- data/sig/turbopuffer/internal/type/enum.rbs +32 -0
- data/sig/turbopuffer/internal/type/file_input.rbs +25 -0
- data/sig/turbopuffer/internal/type/hash_of.rbs +48 -0
- data/sig/turbopuffer/internal/type/request_parameters.rbs +19 -0
- data/sig/turbopuffer/internal/type/union.rbs +52 -0
- data/sig/turbopuffer/internal/type/unknown.rbs +26 -0
- data/sig/turbopuffer/internal/util.rbs +185 -0
- data/sig/turbopuffer/internal.rbs +9 -0
- data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
- data/sig/turbopuffer/models/attribute_schema_config.rbs +45 -0
- data/sig/turbopuffer/models/attribute_type.rbs +5 -0
- data/sig/turbopuffer/models/client_namespaces_params.rbs +38 -0
- data/sig/turbopuffer/models/columns.rbs +42 -0
- data/sig/turbopuffer/models/distance_metric.rbs +17 -0
- data/sig/turbopuffer/models/full_text_search.rbs +11 -0
- data/sig/turbopuffer/models/full_text_search_config.rbs +68 -0
- data/sig/turbopuffer/models/id.rbs +11 -0
- data/sig/turbopuffer/models/include_attributes.rbs +13 -0
- data/sig/turbopuffer/models/language.rbs +48 -0
- data/sig/turbopuffer/models/namespace_delete_all_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_delete_all_response.rbs +13 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +17 -0
- data/sig/turbopuffer/models/namespace_metadata.rbs +30 -0
- data/sig/turbopuffer/models/namespace_metadata_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_multi_query_params.rbs +86 -0
- data/sig/turbopuffer/models/namespace_multi_query_response.rbs +53 -0
- data/sig/turbopuffer/models/namespace_query_params.rbs +125 -0
- data/sig/turbopuffer/models/namespace_query_response.rbs +39 -0
- data/sig/turbopuffer/models/namespace_recall_params.rbs +56 -0
- data/sig/turbopuffer/models/namespace_recall_response.rbs +26 -0
- data/sig/turbopuffer/models/namespace_schema_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_schema_response.rbs +8 -0
- data/sig/turbopuffer/models/namespace_summary.rbs +13 -0
- data/sig/turbopuffer/models/namespace_update_schema_params.rbs +37 -0
- data/sig/turbopuffer/models/namespace_update_schema_response.rbs +8 -0
- data/sig/turbopuffer/models/namespace_write_params.rbs +156 -0
- data/sig/turbopuffer/models/namespace_write_response.rbs +56 -0
- data/sig/turbopuffer/models/query.rbs +61 -0
- data/sig/turbopuffer/models/query_billing.rbs +25 -0
- data/sig/turbopuffer/models/query_performance.rbs +45 -0
- data/sig/turbopuffer/models/row.rbs +24 -0
- data/sig/turbopuffer/models/tokenizer.rbs +15 -0
- data/sig/turbopuffer/models/vector.rbs +13 -0
- data/sig/turbopuffer/models/vector_encoding.rbs +14 -0
- data/sig/turbopuffer/models/write_billing.rbs +27 -0
- data/sig/turbopuffer/models.rbs +61 -0
- data/sig/turbopuffer/namespace.rbs +5 -0
- data/sig/turbopuffer/request_options.rbs +36 -0
- data/sig/turbopuffer/resources/namespaces.rbs +81 -0
- data/sig/turbopuffer/version.rbs +3 -0
- metadata +251 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Resources
|
5
|
+
class Namespaces
|
6
|
+
# Delete namespace.
|
7
|
+
sig do
|
8
|
+
params(
|
9
|
+
namespace: T.nilable(String),
|
10
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
11
|
+
).returns(Turbopuffer::Models::NamespaceDeleteAllResponse)
|
12
|
+
end
|
13
|
+
def delete_all(
|
14
|
+
# The name of the namespace.
|
15
|
+
namespace: nil,
|
16
|
+
request_options: {}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Warm the cache for a namespace.
|
21
|
+
sig do
|
22
|
+
params(
|
23
|
+
namespace: T.nilable(String),
|
24
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
25
|
+
).returns(Turbopuffer::Models::NamespaceHintCacheWarmResponse)
|
26
|
+
end
|
27
|
+
def hint_cache_warm(
|
28
|
+
# The name of the namespace.
|
29
|
+
namespace: nil,
|
30
|
+
request_options: {}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Get metadata about a namespace.
|
35
|
+
sig do
|
36
|
+
params(
|
37
|
+
namespace: String,
|
38
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
39
|
+
).returns(Turbopuffer::NamespaceMetadata)
|
40
|
+
end
|
41
|
+
def metadata(
|
42
|
+
# The name of the namespace.
|
43
|
+
namespace: nil,
|
44
|
+
request_options: {}
|
45
|
+
)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Issue multiple concurrent queries filter or search documents.
|
49
|
+
sig do
|
50
|
+
params(
|
51
|
+
queries: T::Array[Turbopuffer::Query::OrHash],
|
52
|
+
namespace: String,
|
53
|
+
consistency:
|
54
|
+
Turbopuffer::NamespaceMultiQueryParams::Consistency::OrHash,
|
55
|
+
vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
|
56
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
57
|
+
).returns(Turbopuffer::Models::NamespaceMultiQueryResponse)
|
58
|
+
end
|
59
|
+
def multi_query(
|
60
|
+
# Body param:
|
61
|
+
queries:,
|
62
|
+
# Path param: The name of the namespace.
|
63
|
+
namespace: nil,
|
64
|
+
# Body param: The consistency level for a query.
|
65
|
+
consistency: nil,
|
66
|
+
# Body param: The encoding to use for vectors in the response.
|
67
|
+
vector_encoding: nil,
|
68
|
+
request_options: {}
|
69
|
+
)
|
70
|
+
end
|
71
|
+
|
72
|
+
# Query, filter, full-text search and vector search documents.
|
73
|
+
sig do
|
74
|
+
params(
|
75
|
+
namespace: T.nilable(String),
|
76
|
+
aggregate_by: T::Hash[Symbol, T.anything],
|
77
|
+
consistency: Turbopuffer::NamespaceQueryParams::Consistency::OrHash,
|
78
|
+
distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
|
79
|
+
filters: T.anything,
|
80
|
+
include_attributes: Turbopuffer::IncludeAttributes::Variants,
|
81
|
+
rank_by: T.anything,
|
82
|
+
top_k: Integer,
|
83
|
+
vector_encoding: Turbopuffer::VectorEncoding::OrSymbol,
|
84
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
85
|
+
).returns(Turbopuffer::Models::NamespaceQueryResponse)
|
86
|
+
end
|
87
|
+
def query(
|
88
|
+
# Path param: The name of the namespace.
|
89
|
+
namespace: nil,
|
90
|
+
# Body param: Aggregations to compute over all documents in the namespace that
|
91
|
+
# match the filters.
|
92
|
+
aggregate_by: nil,
|
93
|
+
# Body param: The consistency level for a query.
|
94
|
+
consistency: nil,
|
95
|
+
# Body param: A function used to calculate vector similarity.
|
96
|
+
distance_metric: nil,
|
97
|
+
# Body param: Exact filters for attributes to refine search results for. Think of
|
98
|
+
# it as a SQL WHERE clause.
|
99
|
+
filters: nil,
|
100
|
+
# Body param: Whether to include attributes in the response.
|
101
|
+
include_attributes: nil,
|
102
|
+
# Body param: How to rank the documents in the namespace.
|
103
|
+
rank_by: nil,
|
104
|
+
# Body param: The number of results to return.
|
105
|
+
top_k: nil,
|
106
|
+
# Body param: The encoding to use for vectors in the response.
|
107
|
+
vector_encoding: nil,
|
108
|
+
request_options: {}
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Evaluate recall.
|
113
|
+
sig do
|
114
|
+
params(
|
115
|
+
namespace: T.nilable(String),
|
116
|
+
filters: T.anything,
|
117
|
+
num: Integer,
|
118
|
+
queries: T::Array[Float],
|
119
|
+
top_k: Integer,
|
120
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
121
|
+
).returns(Turbopuffer::Models::NamespaceRecallResponse)
|
122
|
+
end
|
123
|
+
def recall(
|
124
|
+
# Path param: The name of the namespace.
|
125
|
+
namespace: nil,
|
126
|
+
# Body param: Filter by attributes. Same syntax as the query endpoint.
|
127
|
+
filters: nil,
|
128
|
+
# Body param: The number of searches to run.
|
129
|
+
num: nil,
|
130
|
+
# Body param: Use specific query vectors for the measurement. If omitted, sampled
|
131
|
+
# from the index.
|
132
|
+
queries: nil,
|
133
|
+
# Body param: Search for `top_k` nearest neighbors.
|
134
|
+
top_k: nil,
|
135
|
+
request_options: {}
|
136
|
+
)
|
137
|
+
end
|
138
|
+
|
139
|
+
# Get namespace schema.
|
140
|
+
sig do
|
141
|
+
params(
|
142
|
+
namespace: T.nilable(String),
|
143
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
144
|
+
).returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig])
|
145
|
+
end
|
146
|
+
def schema(
|
147
|
+
# The name of the namespace.
|
148
|
+
namespace: nil,
|
149
|
+
request_options: {}
|
150
|
+
)
|
151
|
+
end
|
152
|
+
|
153
|
+
# Update namespace schema.
|
154
|
+
sig do
|
155
|
+
params(
|
156
|
+
namespace: T.nilable(String),
|
157
|
+
schema:
|
158
|
+
T::Hash[
|
159
|
+
Symbol,
|
160
|
+
T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
|
161
|
+
],
|
162
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
163
|
+
).returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig])
|
164
|
+
end
|
165
|
+
def update_schema(
|
166
|
+
# Path param: The name of the namespace.
|
167
|
+
namespace: nil,
|
168
|
+
# Body param: The desired schema for the namespace.
|
169
|
+
schema: nil,
|
170
|
+
request_options: {}
|
171
|
+
)
|
172
|
+
end
|
173
|
+
|
174
|
+
# Create, update, or delete documents.
|
175
|
+
sig do
|
176
|
+
params(
|
177
|
+
namespace: T.nilable(String),
|
178
|
+
copy_from_namespace: String,
|
179
|
+
delete_by_filter: T.anything,
|
180
|
+
delete_condition: T.anything,
|
181
|
+
deletes: T::Array[Turbopuffer::ID::Variants],
|
182
|
+
distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
|
183
|
+
encryption: Turbopuffer::NamespaceWriteParams::Encryption::OrHash,
|
184
|
+
patch_columns: Turbopuffer::Columns::OrHash,
|
185
|
+
patch_condition: T.anything,
|
186
|
+
patch_rows: T::Array[Turbopuffer::Row::OrHash],
|
187
|
+
schema:
|
188
|
+
T::Hash[
|
189
|
+
Symbol,
|
190
|
+
T.any(String, Turbopuffer::AttributeSchemaConfig::OrHash)
|
191
|
+
],
|
192
|
+
upsert_columns: Turbopuffer::Columns::OrHash,
|
193
|
+
upsert_condition: T.anything,
|
194
|
+
upsert_rows: T::Array[Turbopuffer::Row::OrHash],
|
195
|
+
request_options: Turbopuffer::RequestOptions::OrHash
|
196
|
+
).returns(Turbopuffer::Models::NamespaceWriteResponse)
|
197
|
+
end
|
198
|
+
def write(
|
199
|
+
# Path param: The name of the namespace.
|
200
|
+
namespace: nil,
|
201
|
+
# Body param: The namespace to copy documents from.
|
202
|
+
copy_from_namespace: nil,
|
203
|
+
# Body param: The filter specifying which documents to delete.
|
204
|
+
delete_by_filter: nil,
|
205
|
+
# Body param: A condition evaluated against the current value of each document
|
206
|
+
# targeted by a delete write. Only documents that pass the condition are deleted.
|
207
|
+
delete_condition: nil,
|
208
|
+
# Body param:
|
209
|
+
deletes: nil,
|
210
|
+
# Body param: A function used to calculate vector similarity.
|
211
|
+
distance_metric: nil,
|
212
|
+
# Body param: The encryption configuration for a namespace.
|
213
|
+
encryption: nil,
|
214
|
+
# Body param: A list of documents in columnar format. Each key is a column name,
|
215
|
+
# mapped to an array of values for that column.
|
216
|
+
patch_columns: nil,
|
217
|
+
# Body param: A condition evaluated against the current value of each document
|
218
|
+
# targeted by a patch write. Only documents that pass the condition are patched.
|
219
|
+
patch_condition: nil,
|
220
|
+
# Body param:
|
221
|
+
patch_rows: nil,
|
222
|
+
# Body param: The schema of the attributes attached to the documents.
|
223
|
+
schema: nil,
|
224
|
+
# Body param: A list of documents in columnar format. Each key is a column name,
|
225
|
+
# mapped to an array of values for that column.
|
226
|
+
upsert_columns: nil,
|
227
|
+
# Body param: A condition evaluated against the current value of each document
|
228
|
+
# targeted by an upsert write. Only documents that pass the condition are
|
229
|
+
# upserted.
|
230
|
+
upsert_condition: nil,
|
231
|
+
# Body param:
|
232
|
+
upsert_rows: nil,
|
233
|
+
request_options: {}
|
234
|
+
)
|
235
|
+
end
|
236
|
+
|
237
|
+
# @api private
|
238
|
+
sig { params(client: Turbopuffer::Client).returns(T.attached_class) }
|
239
|
+
def self.new(client:)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
class Client < Turbopuffer::Internal::Transport::BaseClient
|
3
|
+
DEFAULT_MAX_RETRIES: 2
|
4
|
+
|
5
|
+
DEFAULT_TIMEOUT_IN_SECONDS: Float
|
6
|
+
|
7
|
+
DEFAULT_INITIAL_RETRY_DELAY: Float
|
8
|
+
|
9
|
+
DEFAULT_MAX_RETRY_DELAY: Float
|
10
|
+
|
11
|
+
attr_reader api_key: String
|
12
|
+
|
13
|
+
attr_reader region: String?
|
14
|
+
|
15
|
+
attr_reader default_namespace: String?
|
16
|
+
|
17
|
+
def namespace: (
|
18
|
+
?namespace: String
|
19
|
+
) -> Turbopuffer::Namespace
|
20
|
+
|
21
|
+
def namespaces: (
|
22
|
+
?cursor: String,
|
23
|
+
?page_size: Integer,
|
24
|
+
?prefix: String,
|
25
|
+
?request_options: Turbopuffer::request_opts
|
26
|
+
) -> Turbopuffer::Internal::NamespacePage[Turbopuffer::NamespaceSummary]
|
27
|
+
|
28
|
+
private def auth_headers: -> ::Hash[String, String]
|
29
|
+
|
30
|
+
def initialize: (
|
31
|
+
?api_key: String?,
|
32
|
+
?region: String?,
|
33
|
+
?default_namespace: String?,
|
34
|
+
?base_url: String?,
|
35
|
+
?max_retries: Integer,
|
36
|
+
?timeout: Float,
|
37
|
+
?initial_retry_delay: Float,
|
38
|
+
?max_retry_delay: Float
|
39
|
+
) -> void
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
module Errors
|
3
|
+
class Error < StandardError
|
4
|
+
attr_accessor cause: StandardError?
|
5
|
+
end
|
6
|
+
|
7
|
+
class ConversionError < Turbopuffer::Errors::Error
|
8
|
+
def cause: -> StandardError?
|
9
|
+
|
10
|
+
def initialize: (
|
11
|
+
on: Class,
|
12
|
+
method: Symbol,
|
13
|
+
target: top,
|
14
|
+
value: top,
|
15
|
+
?cause: StandardError?
|
16
|
+
) -> void
|
17
|
+
end
|
18
|
+
|
19
|
+
class APIError < Turbopuffer::Errors::Error
|
20
|
+
attr_accessor url: URI::Generic
|
21
|
+
|
22
|
+
attr_accessor status: Integer?
|
23
|
+
|
24
|
+
attr_accessor body: top?
|
25
|
+
|
26
|
+
def initialize: (
|
27
|
+
url: URI::Generic,
|
28
|
+
?status: Integer?,
|
29
|
+
?body: Object?,
|
30
|
+
?request: nil,
|
31
|
+
?response: nil,
|
32
|
+
?message: String?
|
33
|
+
) -> void
|
34
|
+
end
|
35
|
+
|
36
|
+
class APIConnectionError < Turbopuffer::Errors::APIError
|
37
|
+
def initialize: (
|
38
|
+
url: URI::Generic,
|
39
|
+
?status: nil,
|
40
|
+
?body: nil,
|
41
|
+
?request: nil,
|
42
|
+
?response: nil,
|
43
|
+
?message: String?
|
44
|
+
) -> void
|
45
|
+
end
|
46
|
+
|
47
|
+
class APITimeoutError < Turbopuffer::Errors::APIConnectionError
|
48
|
+
def initialize: (
|
49
|
+
url: URI::Generic,
|
50
|
+
?status: nil,
|
51
|
+
?body: nil,
|
52
|
+
?request: nil,
|
53
|
+
?response: nil,
|
54
|
+
?message: String?
|
55
|
+
) -> void
|
56
|
+
end
|
57
|
+
|
58
|
+
class APIStatusError < Turbopuffer::Errors::APIError
|
59
|
+
def self.for: (
|
60
|
+
url: URI::Generic,
|
61
|
+
status: Integer,
|
62
|
+
body: Object?,
|
63
|
+
request: nil,
|
64
|
+
response: nil,
|
65
|
+
?message: String?
|
66
|
+
) -> instance
|
67
|
+
|
68
|
+
def initialize: (
|
69
|
+
url: URI::Generic,
|
70
|
+
status: Integer,
|
71
|
+
body: Object?,
|
72
|
+
request: nil,
|
73
|
+
response: nil,
|
74
|
+
?message: String?
|
75
|
+
) -> void
|
76
|
+
end
|
77
|
+
|
78
|
+
class BadRequestError < Turbopuffer::Errors::APIStatusError
|
79
|
+
HTTP_STATUS: 400
|
80
|
+
end
|
81
|
+
|
82
|
+
class AuthenticationError < Turbopuffer::Errors::APIStatusError
|
83
|
+
HTTP_STATUS: 401
|
84
|
+
end
|
85
|
+
|
86
|
+
class PermissionDeniedError < Turbopuffer::Errors::APIStatusError
|
87
|
+
HTTP_STATUS: 403
|
88
|
+
end
|
89
|
+
|
90
|
+
class NotFoundError < Turbopuffer::Errors::APIStatusError
|
91
|
+
HTTP_STATUS: 404
|
92
|
+
end
|
93
|
+
|
94
|
+
class ConflictError < Turbopuffer::Errors::APIStatusError
|
95
|
+
HTTP_STATUS: 409
|
96
|
+
end
|
97
|
+
|
98
|
+
class UnprocessableEntityError < Turbopuffer::Errors::APIStatusError
|
99
|
+
HTTP_STATUS: 422
|
100
|
+
end
|
101
|
+
|
102
|
+
class RateLimitError < Turbopuffer::Errors::APIStatusError
|
103
|
+
HTTP_STATUS: 429
|
104
|
+
end
|
105
|
+
|
106
|
+
class InternalServerError < Turbopuffer::Errors::APIStatusError
|
107
|
+
HTTP_STATUS: Range[Integer]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
class FilePart
|
3
|
+
attr_reader content: Pathname | StringIO | IO | String
|
4
|
+
|
5
|
+
attr_reader content_type: String?
|
6
|
+
|
7
|
+
attr_reader filename: String?
|
8
|
+
|
9
|
+
private def read: -> String
|
10
|
+
|
11
|
+
def to_json: (*top a) -> String
|
12
|
+
|
13
|
+
def to_yaml: (*top a) -> String
|
14
|
+
|
15
|
+
def initialize: (
|
16
|
+
Pathname | StringIO | IO | String content,
|
17
|
+
?filename: String?,
|
18
|
+
?content_type: String?
|
19
|
+
) -> void
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
module Internal
|
3
|
+
module Transport
|
4
|
+
class BaseClient
|
5
|
+
extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
6
|
+
|
7
|
+
type request_components =
|
8
|
+
{
|
9
|
+
method: Symbol,
|
10
|
+
path: String | ::Array[String],
|
11
|
+
query: ::Hash[String, (::Array[String] | String)?]?,
|
12
|
+
headers: ::Hash[String, (String
|
13
|
+
| Integer
|
14
|
+
| ::Array[(String | Integer)?])?]?,
|
15
|
+
body: top?,
|
16
|
+
unwrap: (Symbol
|
17
|
+
| Integer
|
18
|
+
| ::Array[(Symbol | Integer)]
|
19
|
+
| (^(top arg0) -> top))?,
|
20
|
+
page: Class?,
|
21
|
+
stream: Class?,
|
22
|
+
model: Turbopuffer::Internal::Type::Converter::input?,
|
23
|
+
options: Turbopuffer::request_opts?
|
24
|
+
}
|
25
|
+
type request_input =
|
26
|
+
{
|
27
|
+
method: Symbol,
|
28
|
+
url: URI::Generic,
|
29
|
+
headers: ::Hash[String, String],
|
30
|
+
body: top,
|
31
|
+
max_retries: Integer,
|
32
|
+
timeout: Float
|
33
|
+
}
|
34
|
+
|
35
|
+
MAX_REDIRECTS: 20
|
36
|
+
|
37
|
+
PLATFORM_HEADERS: ::Hash[String, String]
|
38
|
+
|
39
|
+
def self.validate!: (
|
40
|
+
Turbopuffer::Internal::Transport::BaseClient::request_components req
|
41
|
+
) -> void
|
42
|
+
|
43
|
+
def self.should_retry?: (
|
44
|
+
Integer status,
|
45
|
+
headers: ::Hash[String, String]
|
46
|
+
) -> bool
|
47
|
+
|
48
|
+
def self.follow_redirect: (
|
49
|
+
Turbopuffer::Internal::Transport::BaseClient::request_input request,
|
50
|
+
status: Integer,
|
51
|
+
response_headers: ::Hash[String, String]
|
52
|
+
) -> Turbopuffer::Internal::Transport::BaseClient::request_input
|
53
|
+
|
54
|
+
def self.reap_connection!: (
|
55
|
+
Integer | Turbopuffer::Errors::APIConnectionError status,
|
56
|
+
stream: Enumerable[String]?
|
57
|
+
) -> void
|
58
|
+
|
59
|
+
attr_reader base_url: URI::Generic
|
60
|
+
|
61
|
+
attr_reader timeout: Float
|
62
|
+
|
63
|
+
attr_reader max_retries: Integer
|
64
|
+
|
65
|
+
attr_reader initial_retry_delay: Float
|
66
|
+
|
67
|
+
attr_reader max_retry_delay: Float
|
68
|
+
|
69
|
+
attr_reader headers: ::Hash[String, String]
|
70
|
+
|
71
|
+
attr_reader idempotency_header: String?
|
72
|
+
|
73
|
+
# @api private
|
74
|
+
attr_reader requester: Turbopuffer::Internal::Transport::PooledNetRequester
|
75
|
+
|
76
|
+
def initialize: (
|
77
|
+
base_url: String,
|
78
|
+
?timeout: Float,
|
79
|
+
?max_retries: Integer,
|
80
|
+
?initial_retry_delay: Float,
|
81
|
+
?max_retry_delay: Float,
|
82
|
+
?headers: ::Hash[String, (String
|
83
|
+
| Integer
|
84
|
+
| ::Array[(String | Integer)?])?],
|
85
|
+
?idempotency_header: String?
|
86
|
+
) -> void
|
87
|
+
|
88
|
+
private def auth_headers: -> ::Hash[String, String]
|
89
|
+
|
90
|
+
private def generate_idempotency_key: -> String
|
91
|
+
|
92
|
+
private def build_request: (
|
93
|
+
Turbopuffer::Internal::Transport::BaseClient::request_components req,
|
94
|
+
Turbopuffer::request_options opts
|
95
|
+
) -> Turbopuffer::Internal::Transport::BaseClient::request_input
|
96
|
+
|
97
|
+
private def retry_delay: (
|
98
|
+
::Hash[String, String] headers,
|
99
|
+
retry_count: Integer
|
100
|
+
) -> Float
|
101
|
+
|
102
|
+
private def send_request: (
|
103
|
+
Turbopuffer::Internal::Transport::BaseClient::request_input request,
|
104
|
+
redirect_count: Integer,
|
105
|
+
retry_count: Integer,
|
106
|
+
send_retry_header: bool
|
107
|
+
) -> [Integer, top, Enumerable[String]]
|
108
|
+
|
109
|
+
def request: (
|
110
|
+
Symbol method,
|
111
|
+
String | ::Array[String] path,
|
112
|
+
?query: ::Hash[String, (::Array[String] | String)?]?,
|
113
|
+
?headers: ::Hash[String, (String
|
114
|
+
| Integer
|
115
|
+
| ::Array[(String | Integer)?])?]?,
|
116
|
+
?body: top?,
|
117
|
+
?unwrap: (Symbol
|
118
|
+
| Integer
|
119
|
+
| ::Array[(Symbol | Integer)]
|
120
|
+
| (^(top arg0) -> top))?,
|
121
|
+
?page: Class?,
|
122
|
+
?stream: Class?,
|
123
|
+
?model: Turbopuffer::Internal::Type::Converter::input?,
|
124
|
+
?options: Turbopuffer::request_opts?
|
125
|
+
) -> top
|
126
|
+
|
127
|
+
def inspect: -> String
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
module Internal
|
3
|
+
module Transport
|
4
|
+
class PooledNetRequester
|
5
|
+
extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
6
|
+
|
7
|
+
type request =
|
8
|
+
{
|
9
|
+
method: Symbol,
|
10
|
+
url: URI::Generic,
|
11
|
+
headers: ::Hash[String, String],
|
12
|
+
body: top,
|
13
|
+
deadline: Float
|
14
|
+
}
|
15
|
+
|
16
|
+
KEEP_ALIVE_TIMEOUT: 30
|
17
|
+
|
18
|
+
DEFAULT_MAX_CONNECTIONS: Integer
|
19
|
+
|
20
|
+
def self.connect: (URI::Generic url) -> top
|
21
|
+
|
22
|
+
def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
|
23
|
+
|
24
|
+
def self.build_request: (
|
25
|
+
Turbopuffer::Internal::Transport::PooledNetRequester::request request
|
26
|
+
) {
|
27
|
+
(String arg0) -> void
|
28
|
+
} -> [top, (^-> void)]
|
29
|
+
|
30
|
+
private def with_pool: (
|
31
|
+
URI::Generic url,
|
32
|
+
deadline: Float
|
33
|
+
) {
|
34
|
+
(top arg0) -> void
|
35
|
+
} -> void
|
36
|
+
|
37
|
+
def execute: (
|
38
|
+
Turbopuffer::Internal::Transport::PooledNetRequester::request request
|
39
|
+
) -> [Integer, top, Enumerable[String]]
|
40
|
+
|
41
|
+
def initialize: (?size: Integer) -> void
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Turbopuffer
|
2
|
+
module Internal
|
3
|
+
module Type
|
4
|
+
class ArrayOf[Elem]
|
5
|
+
include Turbopuffer::Internal::Type::Converter
|
6
|
+
include Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
7
|
+
|
8
|
+
def self.[]: (
|
9
|
+
::Hash[Symbol, top]
|
10
|
+
| ^-> Turbopuffer::Internal::Type::Converter::input
|
11
|
+
| Turbopuffer::Internal::Type::Converter::input type_info,
|
12
|
+
?::Hash[Symbol, top] spec
|
13
|
+
) -> instance
|
14
|
+
|
15
|
+
def ===: (top other) -> bool
|
16
|
+
|
17
|
+
def ==: (top other) -> bool
|
18
|
+
|
19
|
+
def hash: -> Integer
|
20
|
+
|
21
|
+
def coerce: (
|
22
|
+
::Array[top] | top value,
|
23
|
+
state: Turbopuffer::Internal::Type::Converter::coerce_state
|
24
|
+
) -> (::Array[top] | top)
|
25
|
+
|
26
|
+
def dump: (
|
27
|
+
::Array[top] | top value,
|
28
|
+
state: Turbopuffer::Internal::Type::Converter::dump_state
|
29
|
+
) -> (::Array[top] | top)
|
30
|
+
|
31
|
+
def to_sorbet_type: -> top
|
32
|
+
|
33
|
+
def item_type: -> Elem
|
34
|
+
|
35
|
+
def nilable?: -> bool
|
36
|
+
|
37
|
+
def initialize: (
|
38
|
+
::Hash[Symbol, top]
|
39
|
+
| ^-> Turbopuffer::Internal::Type::Converter::input
|
40
|
+
| Turbopuffer::Internal::Type::Converter::input type_info,
|
41
|
+
?::Hash[Symbol, top] spec
|
42
|
+
) -> void
|
43
|
+
|
44
|
+
def inspect: (?depth: Integer) -> String
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|