turbopuffer 1.4.0 → 1.6.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.
@@ -11,11 +11,35 @@ module Turbopuffer
11
11
  )
12
12
  end
13
13
 
14
- # Whether to create an approximate nearest neighbor index for the attribute.
15
- sig { returns(T.nilable(T::Boolean)) }
14
+ # The data type of the attribute. Valid values: string, int, uint, float, uuid,
15
+ # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
16
+ # [DIMS]f16, [DIMS]f32.
17
+ sig { returns(String) }
18
+ attr_accessor :type
19
+
20
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
21
+ # be a boolean or a detailed configuration object.
22
+ sig do
23
+ returns(
24
+ T.nilable(
25
+ T.any(
26
+ T::Boolean,
27
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
28
+ )
29
+ )
30
+ )
31
+ end
16
32
  attr_reader :ann
17
33
 
18
- sig { params(ann: T::Boolean).void }
34
+ sig do
35
+ params(
36
+ ann:
37
+ T.any(
38
+ T::Boolean,
39
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig::OrHash
40
+ )
41
+ ).void
42
+ end
19
43
  attr_writer :ann
20
44
 
21
45
  # Whether or not the attributes can be used in filters.
@@ -48,28 +72,28 @@ module Turbopuffer
48
72
  sig { params(regex: T::Boolean).void }
49
73
  attr_writer :regex
50
74
 
51
- # The data type of the attribute. Valid values: string, int, uint, float, uuid,
52
- # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
53
- # [DIMS]f16, [DIMS]f32.
54
- sig { returns(T.nilable(String)) }
55
- attr_reader :type
56
-
57
- sig { params(type: String).void }
58
- attr_writer :type
59
-
60
75
  # Detailed configuration for an attribute attached to a document.
61
76
  sig do
62
77
  params(
63
- ann: T::Boolean,
78
+ type: String,
79
+ ann:
80
+ T.any(
81
+ T::Boolean,
82
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig::OrHash
83
+ ),
64
84
  filterable: T::Boolean,
65
85
  full_text_search:
66
86
  T.any(T::Boolean, Turbopuffer::FullTextSearchConfig::OrHash),
67
- regex: T::Boolean,
68
- type: String
87
+ regex: T::Boolean
69
88
  ).returns(T.attached_class)
70
89
  end
71
90
  def self.new(
72
- # Whether to create an approximate nearest neighbor index for the attribute.
91
+ # The data type of the attribute. Valid values: string, int, uint, float, uuid,
92
+ # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
93
+ # [DIMS]f16, [DIMS]f32.
94
+ type:,
95
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
96
+ # be a boolean or a detailed configuration object.
73
97
  ann: nil,
74
98
  # Whether or not the attributes can be used in filters.
75
99
  filterable: nil,
@@ -78,28 +102,89 @@ module Turbopuffer
78
102
  # filterable. You can override this by setting `filterable: true`.
79
103
  full_text_search: nil,
80
104
  # Whether to enable Regex filters on this attribute.
81
- regex: nil,
82
- # The data type of the attribute. Valid values: string, int, uint, float, uuid,
83
- # datetime, bool, []string, []int, []uint, []float, []uuid, []datetime, []bool,
84
- # [DIMS]f16, [DIMS]f32.
85
- type: nil
105
+ regex: nil
86
106
  )
87
107
  end
88
108
 
89
109
  sig do
90
110
  override.returns(
91
111
  {
92
- ann: T::Boolean,
112
+ type: String,
113
+ ann:
114
+ T.any(
115
+ T::Boolean,
116
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
117
+ ),
93
118
  filterable: T::Boolean,
94
119
  full_text_search:
95
120
  T.any(T::Boolean, Turbopuffer::FullTextSearchConfig),
96
- regex: T::Boolean,
97
- type: String
121
+ regex: T::Boolean
98
122
  }
99
123
  )
100
124
  end
101
125
  def to_hash
102
126
  end
127
+
128
+ # Whether to create an approximate nearest neighbor index for the attribute. Can
129
+ # be a boolean or a detailed configuration object.
130
+ module Ann
131
+ extend Turbopuffer::Internal::Type::Union
132
+
133
+ Variants =
134
+ T.type_alias do
135
+ T.any(
136
+ T::Boolean,
137
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
138
+ )
139
+ end
140
+
141
+ class AnnConfig < Turbopuffer::Internal::Type::BaseModel
142
+ OrHash =
143
+ T.type_alias do
144
+ T.any(
145
+ Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig,
146
+ Turbopuffer::Internal::AnyHash
147
+ )
148
+ end
149
+
150
+ # A function used to calculate vector similarity.
151
+ sig { returns(T.nilable(Turbopuffer::DistanceMetric::OrSymbol)) }
152
+ attr_reader :distance_metric
153
+
154
+ sig do
155
+ params(distance_metric: Turbopuffer::DistanceMetric::OrSymbol).void
156
+ end
157
+ attr_writer :distance_metric
158
+
159
+ # Configuration options for ANN (Approximate Nearest Neighbor) indexing.
160
+ sig do
161
+ params(
162
+ distance_metric: Turbopuffer::DistanceMetric::OrSymbol
163
+ ).returns(T.attached_class)
164
+ end
165
+ def self.new(
166
+ # A function used to calculate vector similarity.
167
+ distance_metric: nil
168
+ )
169
+ end
170
+
171
+ sig do
172
+ override.returns(
173
+ { distance_metric: Turbopuffer::DistanceMetric::OrSymbol }
174
+ )
175
+ end
176
+ def to_hash
177
+ end
178
+ end
179
+
180
+ sig do
181
+ override.returns(
182
+ T::Array[Turbopuffer::AttributeSchemaConfig::Ann::Variants]
183
+ )
184
+ end
185
+ def self.variants
186
+ end
187
+ end
103
188
  end
104
189
  end
105
190
  end
@@ -20,17 +20,40 @@ module Turbopuffer
20
20
  sig { returns(Time) }
21
21
  attr_accessor :created_at
22
22
 
23
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
24
+ # (CMEK).
25
+ sig { returns(Turbopuffer::NamespaceMetadata::Encryption::Variants) }
26
+ attr_accessor :encryption
27
+
28
+ sig { returns(Turbopuffer::NamespaceMetadata::Index::Variants) }
29
+ attr_accessor :index
30
+
23
31
  # The schema of the namespace.
24
32
  sig { returns(T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig]) }
25
33
  attr_accessor :schema
26
34
 
35
+ # The timestamp when the namespace was last modified by a write operation.
36
+ sig { returns(Time) }
37
+ attr_accessor :updated_at
38
+
27
39
  # Metadata about a namespace.
28
40
  sig do
29
41
  params(
30
42
  approx_logical_bytes: Integer,
31
43
  approx_row_count: Integer,
32
44
  created_at: Time,
33
- schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash]
45
+ encryption:
46
+ T.any(
47
+ Turbopuffer::NamespaceMetadata::Encryption::Sse::OrHash,
48
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek::OrHash
49
+ ),
50
+ index:
51
+ T.any(
52
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate::OrHash,
53
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating::OrHash
54
+ ),
55
+ schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig::OrHash],
56
+ updated_at: Time
34
57
  ).returns(T.attached_class)
35
58
  end
36
59
  def self.new(
@@ -40,8 +63,14 @@ module Turbopuffer
40
63
  approx_row_count:,
41
64
  # The timestamp when the namespace was created.
42
65
  created_at:,
66
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
67
+ # (CMEK).
68
+ encryption:,
69
+ index:,
43
70
  # The schema of the namespace.
44
- schema:
71
+ schema:,
72
+ # The timestamp when the namespace was last modified by a write operation.
73
+ updated_at:
45
74
  )
46
75
  end
47
76
 
@@ -51,12 +80,205 @@ module Turbopuffer
51
80
  approx_logical_bytes: Integer,
52
81
  approx_row_count: Integer,
53
82
  created_at: Time,
54
- schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig]
83
+ encryption: Turbopuffer::NamespaceMetadata::Encryption::Variants,
84
+ index: Turbopuffer::NamespaceMetadata::Index::Variants,
85
+ schema: T::Hash[Symbol, Turbopuffer::AttributeSchemaConfig],
86
+ updated_at: Time
55
87
  }
56
88
  )
57
89
  end
58
90
  def to_hash
59
91
  end
92
+
93
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
94
+ # (CMEK).
95
+ module Encryption
96
+ extend Turbopuffer::Internal::Type::Union
97
+
98
+ Variants =
99
+ T.type_alias do
100
+ T.any(
101
+ Turbopuffer::NamespaceMetadata::Encryption::Sse,
102
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek
103
+ )
104
+ end
105
+
106
+ class Sse < Turbopuffer::Internal::Type::BaseModel
107
+ OrHash =
108
+ T.type_alias do
109
+ T.any(
110
+ Turbopuffer::NamespaceMetadata::Encryption::Sse,
111
+ Turbopuffer::Internal::AnyHash
112
+ )
113
+ end
114
+
115
+ # Always true. Indicates that the namespace is encrypted with SSE.
116
+ sig { returns(T::Boolean) }
117
+ attr_accessor :sse
118
+
119
+ sig { params(sse: T::Boolean).returns(T.attached_class) }
120
+ def self.new(
121
+ # Always true. Indicates that the namespace is encrypted with SSE.
122
+ sse:
123
+ )
124
+ end
125
+
126
+ sig { override.returns({ sse: T::Boolean }) }
127
+ def to_hash
128
+ end
129
+ end
130
+
131
+ class Cmek < Turbopuffer::Internal::Type::BaseModel
132
+ OrHash =
133
+ T.type_alias do
134
+ T.any(
135
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek,
136
+ Turbopuffer::Internal::AnyHash
137
+ )
138
+ end
139
+
140
+ sig do
141
+ returns(Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek)
142
+ end
143
+ attr_reader :cmek
144
+
145
+ sig do
146
+ params(
147
+ cmek:
148
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek::OrHash
149
+ ).void
150
+ end
151
+ attr_writer :cmek
152
+
153
+ # Indicates that the namespace is encrypted with a customer-managed encryption key
154
+ # (CMEK).
155
+ sig do
156
+ params(
157
+ cmek:
158
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek::OrHash
159
+ ).returns(T.attached_class)
160
+ end
161
+ def self.new(cmek:)
162
+ end
163
+
164
+ sig do
165
+ override.returns(
166
+ { cmek: Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek }
167
+ )
168
+ end
169
+ def to_hash
170
+ end
171
+
172
+ class Cmek < Turbopuffer::Internal::Type::BaseModel
173
+ OrHash =
174
+ T.type_alias do
175
+ T.any(
176
+ Turbopuffer::NamespaceMetadata::Encryption::Cmek::Cmek,
177
+ Turbopuffer::Internal::AnyHash
178
+ )
179
+ end
180
+
181
+ # The name of the CMEK key in use.
182
+ sig { returns(String) }
183
+ attr_accessor :key_name
184
+
185
+ sig { params(key_name: String).returns(T.attached_class) }
186
+ def self.new(
187
+ # The name of the CMEK key in use.
188
+ key_name:
189
+ )
190
+ end
191
+
192
+ sig { override.returns({ key_name: String }) }
193
+ def to_hash
194
+ end
195
+ end
196
+ end
197
+
198
+ sig do
199
+ override.returns(
200
+ T::Array[Turbopuffer::NamespaceMetadata::Encryption::Variants]
201
+ )
202
+ end
203
+ def self.variants
204
+ end
205
+ end
206
+
207
+ module Index
208
+ extend Turbopuffer::Internal::Type::Union
209
+
210
+ Variants =
211
+ T.type_alias do
212
+ T.any(
213
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate,
214
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating
215
+ )
216
+ end
217
+
218
+ class IndexUpToDate < Turbopuffer::Internal::Type::BaseModel
219
+ OrHash =
220
+ T.type_alias do
221
+ T.any(
222
+ Turbopuffer::NamespaceMetadata::Index::IndexUpToDate,
223
+ Turbopuffer::Internal::AnyHash
224
+ )
225
+ end
226
+
227
+ sig { returns(Symbol) }
228
+ attr_accessor :status
229
+
230
+ sig { params(status: Symbol).returns(T.attached_class) }
231
+ def self.new(status: :"up-to-date")
232
+ end
233
+
234
+ sig { override.returns({ status: Symbol }) }
235
+ def to_hash
236
+ end
237
+ end
238
+
239
+ class IndexUpdating < Turbopuffer::Internal::Type::BaseModel
240
+ OrHash =
241
+ T.type_alias do
242
+ T.any(
243
+ Turbopuffer::NamespaceMetadata::Index::IndexUpdating,
244
+ Turbopuffer::Internal::AnyHash
245
+ )
246
+ end
247
+
248
+ sig { returns(Symbol) }
249
+ attr_accessor :status
250
+
251
+ # The number of bytes in the namespace that are in the write-ahead log but have
252
+ # not yet been indexed.
253
+ sig { returns(Integer) }
254
+ attr_accessor :unindexed_bytes
255
+
256
+ sig do
257
+ params(unindexed_bytes: Integer, status: Symbol).returns(
258
+ T.attached_class
259
+ )
260
+ end
261
+ def self.new(
262
+ # The number of bytes in the namespace that are in the write-ahead log but have
263
+ # not yet been indexed.
264
+ unindexed_bytes:,
265
+ status: :updating
266
+ )
267
+ end
268
+
269
+ sig { override.returns({ status: Symbol, unindexed_bytes: Integer }) }
270
+ def to_hash
271
+ end
272
+ end
273
+
274
+ sig do
275
+ override.returns(
276
+ T::Array[Turbopuffer::NamespaceMetadata::Index::Variants]
277
+ )
278
+ end
279
+ def self.variants
280
+ end
281
+ end
60
282
  end
61
283
  end
62
284
  end
@@ -75,6 +75,20 @@ module Turbopuffer
75
75
  end
76
76
  attr_writer :encryption
77
77
 
78
+ # The patch and filter specifying which documents to patch.
79
+ sig do
80
+ returns(T.nilable(Turbopuffer::NamespaceWriteParams::PatchByFilter))
81
+ end
82
+ attr_reader :patch_by_filter
83
+
84
+ sig do
85
+ params(
86
+ patch_by_filter:
87
+ Turbopuffer::NamespaceWriteParams::PatchByFilter::OrHash
88
+ ).void
89
+ end
90
+ attr_writer :patch_by_filter
91
+
78
92
  # A list of documents in columnar format. Each key is a column name, mapped to an
79
93
  # array of values for that column.
80
94
  sig { returns(T.nilable(Turbopuffer::Columns)) }
@@ -150,6 +164,8 @@ module Turbopuffer
150
164
  disable_backpressure: T::Boolean,
151
165
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
152
166
  encryption: Turbopuffer::NamespaceWriteParams::Encryption::OrHash,
167
+ patch_by_filter:
168
+ Turbopuffer::NamespaceWriteParams::PatchByFilter::OrHash,
153
169
  patch_columns: Turbopuffer::Columns::OrHash,
154
170
  patch_condition: T.anything,
155
171
  patch_rows: T::Array[Turbopuffer::Row::OrHash],
@@ -180,6 +196,8 @@ module Turbopuffer
180
196
  distance_metric: nil,
181
197
  # The encryption configuration for a namespace.
182
198
  encryption: nil,
199
+ # The patch and filter specifying which documents to patch.
200
+ patch_by_filter: nil,
183
201
  # A list of documents in columnar format. Each key is a column name, mapped to an
184
202
  # array of values for that column.
185
203
  patch_columns: nil,
@@ -211,6 +229,7 @@ module Turbopuffer
211
229
  disable_backpressure: T::Boolean,
212
230
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
213
231
  encryption: Turbopuffer::NamespaceWriteParams::Encryption,
232
+ patch_by_filter: Turbopuffer::NamespaceWriteParams::PatchByFilter,
214
233
  patch_columns: Turbopuffer::Columns,
215
234
  patch_condition: T.anything,
216
235
  patch_rows: T::Array[Turbopuffer::Row],
@@ -296,6 +315,45 @@ module Turbopuffer
296
315
  end
297
316
  end
298
317
  end
318
+
319
+ class PatchByFilter < Turbopuffer::Internal::Type::BaseModel
320
+ OrHash =
321
+ T.type_alias do
322
+ T.any(
323
+ Turbopuffer::NamespaceWriteParams::PatchByFilter,
324
+ Turbopuffer::Internal::AnyHash
325
+ )
326
+ end
327
+
328
+ # Filter by attributes. Same syntax as the query endpoint.
329
+ sig { returns(T.anything) }
330
+ attr_accessor :filters
331
+
332
+ sig { returns(T::Hash[Symbol, T.anything]) }
333
+ attr_accessor :patch
334
+
335
+ # The patch and filter specifying which documents to patch.
336
+ sig do
337
+ params(
338
+ filters: T.anything,
339
+ patch: T::Hash[Symbol, T.anything]
340
+ ).returns(T.attached_class)
341
+ end
342
+ def self.new(
343
+ # Filter by attributes. Same syntax as the query endpoint.
344
+ filters:,
345
+ patch:
346
+ )
347
+ end
348
+
349
+ sig do
350
+ override.returns(
351
+ { filters: T.anything, patch: T::Hash[Symbol, T.anything] }
352
+ )
353
+ end
354
+ def to_hash
355
+ end
356
+ end
299
357
  end
300
358
  end
301
359
  end
@@ -243,6 +243,8 @@ module Turbopuffer
243
243
  disable_backpressure: T::Boolean,
244
244
  distance_metric: Turbopuffer::DistanceMetric::OrSymbol,
245
245
  encryption: Turbopuffer::NamespaceWriteParams::Encryption::OrHash,
246
+ patch_by_filter:
247
+ Turbopuffer::NamespaceWriteParams::PatchByFilter::OrHash,
246
248
  patch_columns: Turbopuffer::Columns::OrHash,
247
249
  patch_condition: T.anything,
248
250
  patch_rows: T::Array[Turbopuffer::Row::OrHash],
@@ -276,6 +278,8 @@ module Turbopuffer
276
278
  distance_metric: nil,
277
279
  # Body param: The encryption configuration for a namespace.
278
280
  encryption: nil,
281
+ # Body param: The patch and filter specifying which documents to patch.
282
+ patch_by_filter: nil,
279
283
  # Body param: A list of documents in columnar format. Each key is a column name,
280
284
  # mapped to an array of values for that column.
281
285
  patch_columns: nil,
@@ -87,6 +87,8 @@ module Turbopuffer
87
87
 
88
88
  private def auth_headers: -> ::Hash[String, String]
89
89
 
90
+ private def user_agent: -> String
91
+
90
92
  private def generate_idempotency_key: -> String
91
93
 
92
94
  private def build_request: (
@@ -17,7 +17,10 @@ module Turbopuffer
17
17
 
18
18
  DEFAULT_MAX_CONNECTIONS: Integer
19
19
 
20
- def self.connect: (URI::Generic url) -> top
20
+ def self.connect: (
21
+ cert_store: OpenSSL::X509::Store,
22
+ url: URI::Generic
23
+ ) -> top
21
24
 
22
25
  def self.calibrate_socket_timeout: (top conn, Float deadline) -> void
23
26
 
@@ -2,17 +2,21 @@ module Turbopuffer
2
2
  module Models
3
3
  type attribute_schema_config =
4
4
  {
5
- ann: bool,
5
+ type: String,
6
+ ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
6
7
  filterable: bool,
7
8
  full_text_search: Turbopuffer::Models::full_text_search,
8
- regex: bool,
9
- type: String
9
+ regex: bool
10
10
  }
11
11
 
12
12
  class AttributeSchemaConfig < Turbopuffer::Internal::Type::BaseModel
13
- attr_reader ann: bool?
13
+ attr_accessor type: String
14
14
 
15
- def ann=: (bool) -> bool
15
+ attr_reader ann: Turbopuffer::Models::AttributeSchemaConfig::ann?
16
+
17
+ def ann=: (
18
+ Turbopuffer::Models::AttributeSchemaConfig::ann
19
+ ) -> Turbopuffer::Models::AttributeSchemaConfig::ann
16
20
 
17
21
  attr_reader filterable: bool?
18
22
 
@@ -28,25 +32,48 @@ module Turbopuffer
28
32
 
29
33
  def regex=: (bool) -> bool
30
34
 
31
- attr_reader type: String?
32
-
33
- def type=: (String) -> String
34
-
35
35
  def initialize: (
36
- ?ann: bool,
36
+ type: String,
37
+ ?ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
37
38
  ?filterable: bool,
38
39
  ?full_text_search: Turbopuffer::Models::full_text_search,
39
- ?regex: bool,
40
- ?type: String
40
+ ?regex: bool
41
41
  ) -> void
42
42
 
43
43
  def to_hash: -> {
44
- ann: bool,
44
+ type: String,
45
+ ann: Turbopuffer::Models::AttributeSchemaConfig::ann,
45
46
  filterable: bool,
46
47
  full_text_search: Turbopuffer::Models::full_text_search,
47
- regex: bool,
48
- type: String
48
+ regex: bool
49
49
  }
50
+
51
+ type ann = bool | Turbopuffer::AttributeSchemaConfig::Ann::AnnConfig
52
+
53
+ module Ann
54
+ extend Turbopuffer::Internal::Type::Union
55
+
56
+ type ann_config =
57
+ { distance_metric: Turbopuffer::Models::distance_metric }
58
+
59
+ class AnnConfig < Turbopuffer::Internal::Type::BaseModel
60
+ attr_reader distance_metric: Turbopuffer::Models::distance_metric?
61
+
62
+ def distance_metric=: (
63
+ Turbopuffer::Models::distance_metric
64
+ ) -> Turbopuffer::Models::distance_metric
65
+
66
+ def initialize: (
67
+ ?distance_metric: Turbopuffer::Models::distance_metric
68
+ ) -> void
69
+
70
+ def to_hash: -> {
71
+ distance_metric: Turbopuffer::Models::distance_metric
72
+ }
73
+ end
74
+
75
+ def self?.variants: -> ::Array[Turbopuffer::Models::AttributeSchemaConfig::ann]
76
+ end
50
77
  end
51
78
  end
52
79
  end