turbopuffer 0.1.0 → 1.2.0
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 +4 -4
- data/.ignore +2 -0
- data/CHANGELOG.md +205 -0
- data/README.md +270 -40
- data/SECURITY.md +27 -0
- data/lib/turbopuffer/client.rb +122 -16
- data/lib/turbopuffer/errors.rb +228 -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 +567 -0
- data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +201 -0
- data/lib/turbopuffer/internal/type/array_of.rb +168 -0
- data/lib/turbopuffer/internal/type/base_model.rb +529 -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 +327 -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 +188 -0
- data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
- data/lib/turbopuffer/internal/type/union.rb +254 -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/aggregation_group.rb +8 -0
- data/lib/turbopuffer/models/attribute_schema.rb +19 -0
- data/lib/turbopuffer/models/attribute_schema_config.rb +56 -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 +83 -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_explain_query_params.rb +137 -0
- data/lib/turbopuffer/models/namespace_explain_query_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 +43 -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 +58 -0
- data/lib/turbopuffer/models/namespace_query_params.rb +137 -0
- data/lib/turbopuffer/models/namespace_query_response.rb +49 -0
- data/lib/turbopuffer/models/namespace_recall_params.rb +66 -0
- data/lib/turbopuffer/models/namespace_recall_response.rb +68 -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 +81 -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 +46 -0
- data/lib/turbopuffer/models/tokenizer.rb +19 -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 +106 -0
- data/lib/turbopuffer/namespace.rb +14 -50
- data/lib/turbopuffer/request_options.rb +77 -0
- data/lib/turbopuffer/resources/namespaces.rb +366 -0
- data/lib/turbopuffer/version.rb +1 -1
- data/lib/turbopuffer.rb +92 -4
- data/manifest.yaml +15 -0
- data/rbi/turbopuffer/client.rbi +91 -0
- data/rbi/turbopuffer/errors.rbi +205 -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 +297 -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 +216 -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 +128 -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/aggregation_group.rbi +13 -0
- data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
- data/rbi/turbopuffer/models/attribute_schema_config.rbi +103 -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 +133 -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_explain_query_params.rbi +273 -0
- data/rbi/turbopuffer/models/namespace_explain_query_response.rbi +34 -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 +62 -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 +121 -0
- data/rbi/turbopuffer/models/namespace_query_params.rbi +267 -0
- data/rbi/turbopuffer/models/namespace_query_response.rbi +84 -0
- data/rbi/turbopuffer/models/namespace_recall_params.rbi +106 -0
- data/rbi/turbopuffer/models/namespace_recall_response.rbi +134 -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 +132 -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 +24 -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 +72 -0
- data/rbi/turbopuffer/namespace.rbi +8 -0
- data/rbi/turbopuffer/request_options.rbi +59 -0
- data/rbi/turbopuffer/resources/namespaces.rbi +304 -0
- data/rbi/turbopuffer/version.rbi +5 -0
- data/sig/turbopuffer/client.rbs +41 -0
- data/sig/turbopuffer/errors.rbs +117 -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 +79 -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/aggregation_group.rbs +7 -0
- data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
- data/sig/turbopuffer/models/attribute_schema_config.rbs +52 -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 +75 -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_explain_query_params.rbs +141 -0
- data/sig/turbopuffer/models/namespace_explain_query_response.rbs +15 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
- data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +18 -0
- data/sig/turbopuffer/models/namespace_metadata.rbs +35 -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 +65 -0
- data/sig/turbopuffer/models/namespace_query_params.rbs +139 -0
- data/sig/turbopuffer/models/namespace_query_response.rbs +48 -0
- data/sig/turbopuffer/models/namespace_recall_params.rbs +63 -0
- data/sig/turbopuffer/models/namespace_recall_response.rbs +61 -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 +75 -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 +16 -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 +65 -0
- data/sig/turbopuffer/namespace.rbs +5 -0
- data/sig/turbopuffer/request_options.rbs +36 -0
- data/sig/turbopuffer/resources/namespaces.rbs +99 -0
- data/sig/turbopuffer/version.rbs +3 -0
- metadata +218 -29
- data/.standard.yml +0 -3
- data/LICENSE.txt +0 -21
- data/Rakefile +0 -10
- data/sig/turbopuffer.rbs +0 -4
@@ -0,0 +1,216 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
module Converter
|
8
|
+
extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
9
|
+
|
10
|
+
Input =
|
11
|
+
T.type_alias do
|
12
|
+
T.any(Turbopuffer::Internal::Type::Converter, T::Class[T.anything])
|
13
|
+
end
|
14
|
+
|
15
|
+
CoerceState =
|
16
|
+
T.type_alias do
|
17
|
+
{
|
18
|
+
translate_names: T::Boolean,
|
19
|
+
strictness: T::Boolean,
|
20
|
+
exactness: {
|
21
|
+
yes: Integer,
|
22
|
+
no: Integer,
|
23
|
+
maybe: Integer
|
24
|
+
},
|
25
|
+
error: T::Class[StandardError],
|
26
|
+
branched: Integer
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
DumpState = T.type_alias { { can_retry: T::Boolean } }
|
31
|
+
|
32
|
+
# @api private
|
33
|
+
sig do
|
34
|
+
overridable
|
35
|
+
.params(
|
36
|
+
value: T.anything,
|
37
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
38
|
+
)
|
39
|
+
.returns(T.anything)
|
40
|
+
end
|
41
|
+
def coerce(value, state:)
|
42
|
+
end
|
43
|
+
|
44
|
+
# @api private
|
45
|
+
sig do
|
46
|
+
overridable
|
47
|
+
.params(
|
48
|
+
value: T.anything,
|
49
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
50
|
+
)
|
51
|
+
.returns(T.anything)
|
52
|
+
end
|
53
|
+
def dump(value, state:)
|
54
|
+
end
|
55
|
+
|
56
|
+
# @api private
|
57
|
+
sig { params(depth: Integer).returns(String) }
|
58
|
+
def inspect(depth: 0)
|
59
|
+
end
|
60
|
+
|
61
|
+
class << self
|
62
|
+
# @api private
|
63
|
+
sig do
|
64
|
+
params(
|
65
|
+
spec:
|
66
|
+
T.any(
|
67
|
+
{
|
68
|
+
const:
|
69
|
+
T.nilable(
|
70
|
+
T.any(NilClass, T::Boolean, Integer, Float, Symbol)
|
71
|
+
),
|
72
|
+
enum:
|
73
|
+
T.nilable(
|
74
|
+
T.proc.returns(
|
75
|
+
Turbopuffer::Internal::Type::Converter::Input
|
76
|
+
)
|
77
|
+
),
|
78
|
+
union:
|
79
|
+
T.nilable(
|
80
|
+
T.proc.returns(
|
81
|
+
Turbopuffer::Internal::Type::Converter::Input
|
82
|
+
)
|
83
|
+
)
|
84
|
+
},
|
85
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
86
|
+
Turbopuffer::Internal::Type::Converter::Input
|
87
|
+
)
|
88
|
+
).returns(T.proc.returns(T.anything))
|
89
|
+
end
|
90
|
+
def self.type_info(spec)
|
91
|
+
end
|
92
|
+
|
93
|
+
# @api private
|
94
|
+
sig do
|
95
|
+
params(
|
96
|
+
type_info:
|
97
|
+
T.any(
|
98
|
+
{
|
99
|
+
const:
|
100
|
+
T.nilable(
|
101
|
+
T.any(NilClass, T::Boolean, Integer, Float, Symbol)
|
102
|
+
),
|
103
|
+
enum:
|
104
|
+
T.nilable(
|
105
|
+
T.proc.returns(
|
106
|
+
Turbopuffer::Internal::Type::Converter::Input
|
107
|
+
)
|
108
|
+
),
|
109
|
+
union:
|
110
|
+
T.nilable(
|
111
|
+
T.proc.returns(
|
112
|
+
Turbopuffer::Internal::Type::Converter::Input
|
113
|
+
)
|
114
|
+
)
|
115
|
+
},
|
116
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
117
|
+
Turbopuffer::Internal::Type::Converter::Input
|
118
|
+
),
|
119
|
+
spec:
|
120
|
+
T.any(
|
121
|
+
{
|
122
|
+
const:
|
123
|
+
T.nilable(
|
124
|
+
T.any(NilClass, T::Boolean, Integer, Float, Symbol)
|
125
|
+
),
|
126
|
+
enum:
|
127
|
+
T.nilable(
|
128
|
+
T.proc.returns(
|
129
|
+
Turbopuffer::Internal::Type::Converter::Input
|
130
|
+
)
|
131
|
+
),
|
132
|
+
union:
|
133
|
+
T.nilable(
|
134
|
+
T.proc.returns(
|
135
|
+
Turbopuffer::Internal::Type::Converter::Input
|
136
|
+
)
|
137
|
+
)
|
138
|
+
},
|
139
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
140
|
+
Turbopuffer::Internal::Type::Converter::Input
|
141
|
+
)
|
142
|
+
).returns(Turbopuffer::Internal::AnyHash)
|
143
|
+
end
|
144
|
+
def self.meta_info(type_info, spec)
|
145
|
+
end
|
146
|
+
|
147
|
+
# @api private
|
148
|
+
sig do
|
149
|
+
params(translate_names: T::Boolean).returns(
|
150
|
+
Turbopuffer::Internal::Type::Converter::CoerceState
|
151
|
+
)
|
152
|
+
end
|
153
|
+
def self.new_coerce_state(translate_names: true)
|
154
|
+
end
|
155
|
+
|
156
|
+
# @api private
|
157
|
+
#
|
158
|
+
# Based on `target`, transform `value` into `target`, to the extent possible:
|
159
|
+
#
|
160
|
+
# 1. if the given `value` conforms to `target` already, return the given `value`
|
161
|
+
# 2. if it's possible and safe to convert the given `value` to `target`, then the
|
162
|
+
# converted value
|
163
|
+
# 3. otherwise, the given `value` unaltered
|
164
|
+
#
|
165
|
+
# The coercion process is subject to improvement between minor release versions.
|
166
|
+
# See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
|
167
|
+
sig do
|
168
|
+
params(
|
169
|
+
target: Turbopuffer::Internal::Type::Converter::Input,
|
170
|
+
value: T.anything,
|
171
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
172
|
+
).returns(T.anything)
|
173
|
+
end
|
174
|
+
def self.coerce(
|
175
|
+
target,
|
176
|
+
value,
|
177
|
+
# The `strictness` is one of `true`, `false`. This informs the coercion strategy
|
178
|
+
# when we have to decide between multiple possible conversion targets:
|
179
|
+
#
|
180
|
+
# - `true`: the conversion must be exact, with minimum coercion.
|
181
|
+
# - `false`: the conversion can be approximate, with some coercion.
|
182
|
+
#
|
183
|
+
# The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
|
184
|
+
# any given conversion attempt, the exactness will be updated based on how closely
|
185
|
+
# the value recursively matches the target type:
|
186
|
+
#
|
187
|
+
# - `yes`: the value can be converted to the target type with minimum coercion.
|
188
|
+
# - `maybe`: the value can be converted to the target type with some reasonable
|
189
|
+
# coercion.
|
190
|
+
# - `no`: the value cannot be converted to the target type.
|
191
|
+
#
|
192
|
+
# See implementation below for more details.
|
193
|
+
state: Turbopuffer::Internal::Type::Converter.new_coerce_state
|
194
|
+
)
|
195
|
+
end
|
196
|
+
|
197
|
+
# @api private
|
198
|
+
sig do
|
199
|
+
params(
|
200
|
+
target: Turbopuffer::Internal::Type::Converter::Input,
|
201
|
+
value: T.anything,
|
202
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
203
|
+
).returns(T.anything)
|
204
|
+
end
|
205
|
+
def self.dump(target, value, state: { can_retry: true })
|
206
|
+
end
|
207
|
+
|
208
|
+
# @api private
|
209
|
+
sig { params(target: T.anything, depth: Integer).returns(String) }
|
210
|
+
def self.inspect(target, depth:)
|
211
|
+
end
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
216
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# A value from among a specified list of options. OpenAPI enum values map to Ruby
|
9
|
+
# values in the SDK as follows:
|
10
|
+
#
|
11
|
+
# 1. boolean => true | false
|
12
|
+
# 2. integer => Integer
|
13
|
+
# 3. float => Float
|
14
|
+
# 4. string => Symbol
|
15
|
+
#
|
16
|
+
# We can therefore convert string values to Symbols, but can't convert other
|
17
|
+
# values safely.
|
18
|
+
module Enum
|
19
|
+
include Turbopuffer::Internal::Type::Converter
|
20
|
+
include Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
21
|
+
|
22
|
+
# All of the valid Symbol values for this enum.
|
23
|
+
sig do
|
24
|
+
overridable.returns(
|
25
|
+
T::Array[T.any(NilClass, T::Boolean, Integer, Float, Symbol)]
|
26
|
+
)
|
27
|
+
end
|
28
|
+
def values
|
29
|
+
end
|
30
|
+
|
31
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
32
|
+
def ===(other)
|
33
|
+
end
|
34
|
+
|
35
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
36
|
+
def ==(other)
|
37
|
+
end
|
38
|
+
|
39
|
+
sig { returns(Integer) }
|
40
|
+
def hash
|
41
|
+
end
|
42
|
+
|
43
|
+
# @api private
|
44
|
+
#
|
45
|
+
# Unlike with primitives, `Enum` additionally validates that the value is a member
|
46
|
+
# of the enum.
|
47
|
+
sig do
|
48
|
+
override
|
49
|
+
.params(
|
50
|
+
value: T.any(String, Symbol, T.anything),
|
51
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
52
|
+
)
|
53
|
+
.returns(T.any(Symbol, T.anything))
|
54
|
+
end
|
55
|
+
def coerce(value, state:)
|
56
|
+
end
|
57
|
+
|
58
|
+
# @api private
|
59
|
+
sig do
|
60
|
+
override
|
61
|
+
.params(
|
62
|
+
value: T.any(Symbol, T.anything),
|
63
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
64
|
+
)
|
65
|
+
.returns(T.any(Symbol, T.anything))
|
66
|
+
end
|
67
|
+
def dump(value, state:)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
sig { returns(T.anything) }
|
72
|
+
def to_sorbet_type
|
73
|
+
end
|
74
|
+
|
75
|
+
# @api private
|
76
|
+
sig { params(depth: Integer).returns(String) }
|
77
|
+
def inspect(depth: 0)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# Either `Pathname` or `StringIO`, or `IO`, or
|
9
|
+
# `Turbopuffer::Internal::Type::FileInput`.
|
10
|
+
#
|
11
|
+
# Note: when `IO` is used, all retries are disabled, since many IO` streams are
|
12
|
+
# not rewindable.
|
13
|
+
class FileInput
|
14
|
+
extend Turbopuffer::Internal::Type::Converter
|
15
|
+
|
16
|
+
abstract!
|
17
|
+
|
18
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
19
|
+
def self.===(other)
|
20
|
+
end
|
21
|
+
|
22
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
23
|
+
def self.==(other)
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
# @api private
|
28
|
+
sig do
|
29
|
+
override
|
30
|
+
.params(
|
31
|
+
value: T.any(StringIO, String, T.anything),
|
32
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
33
|
+
)
|
34
|
+
.returns(T.any(StringIO, T.anything))
|
35
|
+
end
|
36
|
+
def coerce(value, state:)
|
37
|
+
end
|
38
|
+
|
39
|
+
# @api private
|
40
|
+
sig do
|
41
|
+
override
|
42
|
+
.params(
|
43
|
+
value: T.any(Pathname, StringIO, IO, String, T.anything),
|
44
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
45
|
+
)
|
46
|
+
.returns(T.any(Pathname, StringIO, IO, String, T.anything))
|
47
|
+
end
|
48
|
+
def dump(value, state:)
|
49
|
+
end
|
50
|
+
|
51
|
+
# @api private
|
52
|
+
sig { returns(T.anything) }
|
53
|
+
def to_sorbet_type
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# Hash of items of a given type.
|
9
|
+
class HashOf
|
10
|
+
include Turbopuffer::Internal::Type::Converter
|
11
|
+
include Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
12
|
+
|
13
|
+
abstract!
|
14
|
+
|
15
|
+
Elem = type_member(:out)
|
16
|
+
|
17
|
+
sig do
|
18
|
+
params(
|
19
|
+
type_info:
|
20
|
+
T.any(
|
21
|
+
Turbopuffer::Internal::AnyHash,
|
22
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
23
|
+
Turbopuffer::Internal::Type::Converter::Input
|
24
|
+
),
|
25
|
+
spec: Turbopuffer::Internal::AnyHash
|
26
|
+
).returns(T.attached_class)
|
27
|
+
end
|
28
|
+
def self.[](type_info, spec = {})
|
29
|
+
end
|
30
|
+
|
31
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
32
|
+
def ===(other)
|
33
|
+
end
|
34
|
+
|
35
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
36
|
+
def ==(other)
|
37
|
+
end
|
38
|
+
|
39
|
+
sig { returns(Integer) }
|
40
|
+
def hash
|
41
|
+
end
|
42
|
+
|
43
|
+
# @api private
|
44
|
+
sig do
|
45
|
+
override
|
46
|
+
.params(
|
47
|
+
value: T.any(T::Hash[T.anything, T.anything], T.anything),
|
48
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
49
|
+
)
|
50
|
+
.returns(T.any(Turbopuffer::Internal::AnyHash, T.anything))
|
51
|
+
end
|
52
|
+
def coerce(value, state:)
|
53
|
+
end
|
54
|
+
|
55
|
+
# @api private
|
56
|
+
sig do
|
57
|
+
override
|
58
|
+
.params(
|
59
|
+
value: T.any(T::Hash[T.anything, T.anything], T.anything),
|
60
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
61
|
+
)
|
62
|
+
.returns(T.any(Turbopuffer::Internal::AnyHash, T.anything))
|
63
|
+
end
|
64
|
+
def dump(value, state:)
|
65
|
+
end
|
66
|
+
|
67
|
+
# @api private
|
68
|
+
sig { returns(T.anything) }
|
69
|
+
def to_sorbet_type
|
70
|
+
end
|
71
|
+
|
72
|
+
# @api private
|
73
|
+
sig { returns(Elem) }
|
74
|
+
protected def item_type
|
75
|
+
end
|
76
|
+
|
77
|
+
# @api private
|
78
|
+
sig { returns(T::Boolean) }
|
79
|
+
protected def nilable?
|
80
|
+
end
|
81
|
+
|
82
|
+
# @api private
|
83
|
+
sig do
|
84
|
+
params(
|
85
|
+
type_info:
|
86
|
+
T.any(
|
87
|
+
Turbopuffer::Internal::AnyHash,
|
88
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
89
|
+
Turbopuffer::Internal::Type::Converter::Input
|
90
|
+
),
|
91
|
+
spec: Turbopuffer::Internal::AnyHash
|
92
|
+
).void
|
93
|
+
end
|
94
|
+
def initialize(type_info, spec = {})
|
95
|
+
end
|
96
|
+
|
97
|
+
# @api private
|
98
|
+
sig { params(depth: Integer).returns(String) }
|
99
|
+
def inspect(depth: 0)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
module RequestParameters
|
8
|
+
# Options to specify HTTP behaviour for this request.
|
9
|
+
sig { returns(Turbopuffer::RequestOptions) }
|
10
|
+
attr_reader :request_options
|
11
|
+
|
12
|
+
sig do
|
13
|
+
params(request_options: Turbopuffer::RequestOptions::OrHash).void
|
14
|
+
end
|
15
|
+
attr_writer :request_options
|
16
|
+
|
17
|
+
# @api private
|
18
|
+
module Converter
|
19
|
+
# @api private
|
20
|
+
sig do
|
21
|
+
params(params: T.anything).returns(
|
22
|
+
[T.anything, Turbopuffer::Internal::AnyHash]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
def dump_request(params)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
module Union
|
8
|
+
include Turbopuffer::Internal::Type::Converter
|
9
|
+
include Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
10
|
+
|
11
|
+
# @api private
|
12
|
+
#
|
13
|
+
# All of the specified variant info for this union.
|
14
|
+
sig do
|
15
|
+
returns(
|
16
|
+
T::Array[
|
17
|
+
[
|
18
|
+
T.nilable(Symbol),
|
19
|
+
T.proc.returns(Turbopuffer::Internal::Type::Converter::Input),
|
20
|
+
Turbopuffer::Internal::AnyHash
|
21
|
+
]
|
22
|
+
]
|
23
|
+
)
|
24
|
+
end
|
25
|
+
private def known_variants
|
26
|
+
end
|
27
|
+
|
28
|
+
# @api private
|
29
|
+
sig do
|
30
|
+
returns(
|
31
|
+
T::Array[
|
32
|
+
[T.nilable(Symbol), T.anything, Turbopuffer::Internal::AnyHash]
|
33
|
+
]
|
34
|
+
)
|
35
|
+
end
|
36
|
+
protected def derefed_variants
|
37
|
+
end
|
38
|
+
|
39
|
+
# All of the specified variants for this union.
|
40
|
+
sig { overridable.returns(T::Array[T.anything]) }
|
41
|
+
def variants
|
42
|
+
end
|
43
|
+
|
44
|
+
# @api private
|
45
|
+
sig { params(property: Symbol).void }
|
46
|
+
private def discriminator(property)
|
47
|
+
end
|
48
|
+
|
49
|
+
# @api private
|
50
|
+
sig do
|
51
|
+
params(
|
52
|
+
key:
|
53
|
+
T.any(
|
54
|
+
Symbol,
|
55
|
+
Turbopuffer::Internal::AnyHash,
|
56
|
+
T.proc.returns(T.anything),
|
57
|
+
T.anything
|
58
|
+
),
|
59
|
+
spec:
|
60
|
+
T.any(
|
61
|
+
Turbopuffer::Internal::AnyHash,
|
62
|
+
T.proc.returns(T.anything),
|
63
|
+
T.anything
|
64
|
+
)
|
65
|
+
).void
|
66
|
+
end
|
67
|
+
private def variant(key, spec = nil)
|
68
|
+
end
|
69
|
+
|
70
|
+
# @api private
|
71
|
+
sig { params(value: T.anything).returns(T.nilable(T.anything)) }
|
72
|
+
private def resolve_variant(value)
|
73
|
+
end
|
74
|
+
|
75
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
76
|
+
def ===(other)
|
77
|
+
end
|
78
|
+
|
79
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
80
|
+
def ==(other)
|
81
|
+
end
|
82
|
+
|
83
|
+
sig { returns(Integer) }
|
84
|
+
def hash
|
85
|
+
end
|
86
|
+
|
87
|
+
# @api private
|
88
|
+
#
|
89
|
+
# Tries to efficiently coerce the given value to one of the known variants.
|
90
|
+
#
|
91
|
+
# If the value cannot match any of the known variants, the coercion is considered
|
92
|
+
# non-viable and returns the original value.
|
93
|
+
sig do
|
94
|
+
override
|
95
|
+
.params(
|
96
|
+
value: T.anything,
|
97
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
98
|
+
)
|
99
|
+
.returns(T.anything)
|
100
|
+
end
|
101
|
+
def coerce(value, state:)
|
102
|
+
end
|
103
|
+
|
104
|
+
# @api private
|
105
|
+
sig do
|
106
|
+
override
|
107
|
+
.params(
|
108
|
+
value: T.anything,
|
109
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
110
|
+
)
|
111
|
+
.returns(T.anything)
|
112
|
+
end
|
113
|
+
def dump(value, state:)
|
114
|
+
end
|
115
|
+
|
116
|
+
# @api private
|
117
|
+
sig { returns(T.anything) }
|
118
|
+
def to_sorbet_type
|
119
|
+
end
|
120
|
+
|
121
|
+
# @api private
|
122
|
+
sig { params(depth: Integer).returns(String) }
|
123
|
+
def inspect(depth: 0)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# typed: strong
|
2
|
+
|
3
|
+
module Turbopuffer
|
4
|
+
module Internal
|
5
|
+
module Type
|
6
|
+
# @api private
|
7
|
+
#
|
8
|
+
# When we don't know what to expect for the value.
|
9
|
+
class Unknown
|
10
|
+
extend Turbopuffer::Internal::Type::Converter
|
11
|
+
extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
|
12
|
+
|
13
|
+
abstract!
|
14
|
+
|
15
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
16
|
+
def self.===(other)
|
17
|
+
end
|
18
|
+
|
19
|
+
sig { params(other: T.anything).returns(T::Boolean) }
|
20
|
+
def self.==(other)
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
# @api private
|
25
|
+
#
|
26
|
+
# No coercion needed for Unknown type.
|
27
|
+
sig do
|
28
|
+
override
|
29
|
+
.params(
|
30
|
+
value: T.anything,
|
31
|
+
state: Turbopuffer::Internal::Type::Converter::CoerceState
|
32
|
+
)
|
33
|
+
.returns(T.anything)
|
34
|
+
end
|
35
|
+
def coerce(value, state:)
|
36
|
+
end
|
37
|
+
|
38
|
+
# @api private
|
39
|
+
sig do
|
40
|
+
override
|
41
|
+
.params(
|
42
|
+
value: T.anything,
|
43
|
+
state: Turbopuffer::Internal::Type::Converter::DumpState
|
44
|
+
)
|
45
|
+
.returns(T.anything)
|
46
|
+
end
|
47
|
+
def dump(value, state:)
|
48
|
+
end
|
49
|
+
|
50
|
+
# @api private
|
51
|
+
sig { returns(T.anything) }
|
52
|
+
def to_sorbet_type
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|