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.
Files changed (207) hide show
  1. checksums.yaml +4 -4
  2. data/.ignore +2 -0
  3. data/CHANGELOG.md +205 -0
  4. data/README.md +270 -40
  5. data/SECURITY.md +27 -0
  6. data/lib/turbopuffer/client.rb +122 -16
  7. data/lib/turbopuffer/errors.rb +228 -0
  8. data/lib/turbopuffer/file_part.rb +55 -0
  9. data/lib/turbopuffer/internal/namespace_page.rb +86 -0
  10. data/lib/turbopuffer/internal/transport/base_client.rb +567 -0
  11. data/lib/turbopuffer/internal/transport/pooled_net_requester.rb +201 -0
  12. data/lib/turbopuffer/internal/type/array_of.rb +168 -0
  13. data/lib/turbopuffer/internal/type/base_model.rb +529 -0
  14. data/lib/turbopuffer/internal/type/base_page.rb +55 -0
  15. data/lib/turbopuffer/internal/type/boolean.rb +77 -0
  16. data/lib/turbopuffer/internal/type/converter.rb +327 -0
  17. data/lib/turbopuffer/internal/type/enum.rb +152 -0
  18. data/lib/turbopuffer/internal/type/file_input.rb +108 -0
  19. data/lib/turbopuffer/internal/type/hash_of.rb +188 -0
  20. data/lib/turbopuffer/internal/type/request_parameters.rb +42 -0
  21. data/lib/turbopuffer/internal/type/union.rb +254 -0
  22. data/lib/turbopuffer/internal/type/unknown.rb +81 -0
  23. data/lib/turbopuffer/internal/util.rb +914 -0
  24. data/lib/turbopuffer/internal.rb +20 -0
  25. data/lib/turbopuffer/models/aggregation_group.rb +8 -0
  26. data/lib/turbopuffer/models/attribute_schema.rb +19 -0
  27. data/lib/turbopuffer/models/attribute_schema_config.rb +56 -0
  28. data/lib/turbopuffer/models/attribute_type.rb +7 -0
  29. data/lib/turbopuffer/models/client_namespaces_params.rb +38 -0
  30. data/lib/turbopuffer/models/columns.rb +64 -0
  31. data/lib/turbopuffer/models/distance_metric.rb +19 -0
  32. data/lib/turbopuffer/models/full_text_search.rb +20 -0
  33. data/lib/turbopuffer/models/full_text_search_config.rb +83 -0
  34. data/lib/turbopuffer/models/id.rb +19 -0
  35. data/lib/turbopuffer/models/include_attributes.rb +22 -0
  36. data/lib/turbopuffer/models/language.rb +32 -0
  37. data/lib/turbopuffer/models/namespace_delete_all_params.rb +20 -0
  38. data/lib/turbopuffer/models/namespace_delete_all_response.rb +19 -0
  39. data/lib/turbopuffer/models/namespace_explain_query_params.rb +137 -0
  40. data/lib/turbopuffer/models/namespace_explain_query_response.rb +19 -0
  41. data/lib/turbopuffer/models/namespace_hint_cache_warm_params.rb +20 -0
  42. data/lib/turbopuffer/models/namespace_hint_cache_warm_response.rb +26 -0
  43. data/lib/turbopuffer/models/namespace_metadata.rb +43 -0
  44. data/lib/turbopuffer/models/namespace_metadata_params.rb +20 -0
  45. data/lib/turbopuffer/models/namespace_multi_query_params.rb +73 -0
  46. data/lib/turbopuffer/models/namespace_multi_query_response.rb +58 -0
  47. data/lib/turbopuffer/models/namespace_query_params.rb +137 -0
  48. data/lib/turbopuffer/models/namespace_query_response.rb +49 -0
  49. data/lib/turbopuffer/models/namespace_recall_params.rb +66 -0
  50. data/lib/turbopuffer/models/namespace_recall_response.rb +68 -0
  51. data/lib/turbopuffer/models/namespace_schema_params.rb +20 -0
  52. data/lib/turbopuffer/models/namespace_schema_response.rb +8 -0
  53. data/lib/turbopuffer/models/namespace_summary.rb +19 -0
  54. data/lib/turbopuffer/models/namespace_update_schema_params.rb +29 -0
  55. data/lib/turbopuffer/models/namespace_update_schema_response.rb +9 -0
  56. data/lib/turbopuffer/models/namespace_write_params.rb +158 -0
  57. data/lib/turbopuffer/models/namespace_write_response.rb +67 -0
  58. data/lib/turbopuffer/models/query.rb +81 -0
  59. data/lib/turbopuffer/models/query_billing.rb +26 -0
  60. data/lib/turbopuffer/models/query_performance.rb +63 -0
  61. data/lib/turbopuffer/models/row.rb +46 -0
  62. data/lib/turbopuffer/models/tokenizer.rb +19 -0
  63. data/lib/turbopuffer/models/vector.rb +22 -0
  64. data/lib/turbopuffer/models/vector_encoding.rb +16 -0
  65. data/lib/turbopuffer/models/write_billing.rb +26 -0
  66. data/lib/turbopuffer/models.rb +106 -0
  67. data/lib/turbopuffer/namespace.rb +14 -50
  68. data/lib/turbopuffer/request_options.rb +77 -0
  69. data/lib/turbopuffer/resources/namespaces.rb +366 -0
  70. data/lib/turbopuffer/version.rb +1 -1
  71. data/lib/turbopuffer.rb +92 -4
  72. data/manifest.yaml +15 -0
  73. data/rbi/turbopuffer/client.rbi +91 -0
  74. data/rbi/turbopuffer/errors.rbi +205 -0
  75. data/rbi/turbopuffer/file_part.rbi +37 -0
  76. data/rbi/turbopuffer/internal/namespace_page.rbi +22 -0
  77. data/rbi/turbopuffer/internal/transport/base_client.rbi +297 -0
  78. data/rbi/turbopuffer/internal/transport/pooled_net_requester.rbi +80 -0
  79. data/rbi/turbopuffer/internal/type/array_of.rbi +104 -0
  80. data/rbi/turbopuffer/internal/type/base_model.rbi +304 -0
  81. data/rbi/turbopuffer/internal/type/base_page.rbi +43 -0
  82. data/rbi/turbopuffer/internal/type/boolean.rbi +58 -0
  83. data/rbi/turbopuffer/internal/type/converter.rbi +216 -0
  84. data/rbi/turbopuffer/internal/type/enum.rbi +82 -0
  85. data/rbi/turbopuffer/internal/type/file_input.rbi +59 -0
  86. data/rbi/turbopuffer/internal/type/hash_of.rbi +104 -0
  87. data/rbi/turbopuffer/internal/type/request_parameters.rbi +31 -0
  88. data/rbi/turbopuffer/internal/type/union.rbi +128 -0
  89. data/rbi/turbopuffer/internal/type/unknown.rbi +58 -0
  90. data/rbi/turbopuffer/internal/util.rbi +487 -0
  91. data/rbi/turbopuffer/internal.rbi +18 -0
  92. data/rbi/turbopuffer/models/aggregation_group.rbi +13 -0
  93. data/rbi/turbopuffer/models/attribute_schema.rbi +17 -0
  94. data/rbi/turbopuffer/models/attribute_schema_config.rbi +103 -0
  95. data/rbi/turbopuffer/models/attribute_type.rbi +7 -0
  96. data/rbi/turbopuffer/models/client_namespaces_params.rbi +71 -0
  97. data/rbi/turbopuffer/models/columns.rbi +82 -0
  98. data/rbi/turbopuffer/models/distance_metric.rbi +27 -0
  99. data/rbi/turbopuffer/models/full_text_search.rbi +19 -0
  100. data/rbi/turbopuffer/models/full_text_search_config.rbi +133 -0
  101. data/rbi/turbopuffer/models/id.rbi +16 -0
  102. data/rbi/turbopuffer/models/include_attributes.rbi +24 -0
  103. data/rbi/turbopuffer/models/language.rbi +36 -0
  104. data/rbi/turbopuffer/models/namespace_delete_all_params.rbi +41 -0
  105. data/rbi/turbopuffer/models/namespace_delete_all_response.rbi +31 -0
  106. data/rbi/turbopuffer/models/namespace_explain_query_params.rbi +273 -0
  107. data/rbi/turbopuffer/models/namespace_explain_query_response.rbi +34 -0
  108. data/rbi/turbopuffer/models/namespace_hint_cache_warm_params.rbi +41 -0
  109. data/rbi/turbopuffer/models/namespace_hint_cache_warm_response.rbi +38 -0
  110. data/rbi/turbopuffer/models/namespace_metadata.rbi +62 -0
  111. data/rbi/turbopuffer/models/namespace_metadata_params.rbi +41 -0
  112. data/rbi/turbopuffer/models/namespace_multi_query_params.rbi +175 -0
  113. data/rbi/turbopuffer/models/namespace_multi_query_response.rbi +121 -0
  114. data/rbi/turbopuffer/models/namespace_query_params.rbi +267 -0
  115. data/rbi/turbopuffer/models/namespace_query_response.rbi +84 -0
  116. data/rbi/turbopuffer/models/namespace_recall_params.rbi +106 -0
  117. data/rbi/turbopuffer/models/namespace_recall_response.rbi +134 -0
  118. data/rbi/turbopuffer/models/namespace_schema_params.rbi +41 -0
  119. data/rbi/turbopuffer/models/namespace_schema_response.rbi +11 -0
  120. data/rbi/turbopuffer/models/namespace_summary.rbi +28 -0
  121. data/rbi/turbopuffer/models/namespace_update_schema_params.rbi +80 -0
  122. data/rbi/turbopuffer/models/namespace_update_schema_response.rbi +11 -0
  123. data/rbi/turbopuffer/models/namespace_write_params.rbi +290 -0
  124. data/rbi/turbopuffer/models/namespace_write_response.rbi +101 -0
  125. data/rbi/turbopuffer/models/query.rbi +132 -0
  126. data/rbi/turbopuffer/models/query_billing.rbi +46 -0
  127. data/rbi/turbopuffer/models/query_performance.rbi +82 -0
  128. data/rbi/turbopuffer/models/row.rbi +47 -0
  129. data/rbi/turbopuffer/models/tokenizer.rbi +24 -0
  130. data/rbi/turbopuffer/models/vector.rbi +22 -0
  131. data/rbi/turbopuffer/models/vector_encoding.rbi +22 -0
  132. data/rbi/turbopuffer/models/write_billing.rbi +49 -0
  133. data/rbi/turbopuffer/models.rbi +72 -0
  134. data/rbi/turbopuffer/namespace.rbi +8 -0
  135. data/rbi/turbopuffer/request_options.rbi +59 -0
  136. data/rbi/turbopuffer/resources/namespaces.rbi +304 -0
  137. data/rbi/turbopuffer/version.rbi +5 -0
  138. data/sig/turbopuffer/client.rbs +41 -0
  139. data/sig/turbopuffer/errors.rbs +117 -0
  140. data/sig/turbopuffer/file_part.rbs +21 -0
  141. data/sig/turbopuffer/internal/namespace_page.rbs +13 -0
  142. data/sig/turbopuffer/internal/transport/base_client.rbs +131 -0
  143. data/sig/turbopuffer/internal/transport/pooled_net_requester.rbs +45 -0
  144. data/sig/turbopuffer/internal/type/array_of.rbs +48 -0
  145. data/sig/turbopuffer/internal/type/base_model.rbs +102 -0
  146. data/sig/turbopuffer/internal/type/base_page.rbs +24 -0
  147. data/sig/turbopuffer/internal/type/boolean.rbs +26 -0
  148. data/sig/turbopuffer/internal/type/converter.rbs +79 -0
  149. data/sig/turbopuffer/internal/type/enum.rbs +32 -0
  150. data/sig/turbopuffer/internal/type/file_input.rbs +25 -0
  151. data/sig/turbopuffer/internal/type/hash_of.rbs +48 -0
  152. data/sig/turbopuffer/internal/type/request_parameters.rbs +19 -0
  153. data/sig/turbopuffer/internal/type/union.rbs +52 -0
  154. data/sig/turbopuffer/internal/type/unknown.rbs +26 -0
  155. data/sig/turbopuffer/internal/util.rbs +185 -0
  156. data/sig/turbopuffer/internal.rbs +9 -0
  157. data/sig/turbopuffer/models/aggregation_group.rbs +7 -0
  158. data/sig/turbopuffer/models/attribute_schema.rbs +11 -0
  159. data/sig/turbopuffer/models/attribute_schema_config.rbs +52 -0
  160. data/sig/turbopuffer/models/attribute_type.rbs +5 -0
  161. data/sig/turbopuffer/models/client_namespaces_params.rbs +38 -0
  162. data/sig/turbopuffer/models/columns.rbs +42 -0
  163. data/sig/turbopuffer/models/distance_metric.rbs +17 -0
  164. data/sig/turbopuffer/models/full_text_search.rbs +11 -0
  165. data/sig/turbopuffer/models/full_text_search_config.rbs +75 -0
  166. data/sig/turbopuffer/models/id.rbs +11 -0
  167. data/sig/turbopuffer/models/include_attributes.rbs +13 -0
  168. data/sig/turbopuffer/models/language.rbs +48 -0
  169. data/sig/turbopuffer/models/namespace_delete_all_params.rbs +25 -0
  170. data/sig/turbopuffer/models/namespace_delete_all_response.rbs +13 -0
  171. data/sig/turbopuffer/models/namespace_explain_query_params.rbs +141 -0
  172. data/sig/turbopuffer/models/namespace_explain_query_response.rbs +15 -0
  173. data/sig/turbopuffer/models/namespace_hint_cache_warm_params.rbs +25 -0
  174. data/sig/turbopuffer/models/namespace_hint_cache_warm_response.rbs +18 -0
  175. data/sig/turbopuffer/models/namespace_metadata.rbs +35 -0
  176. data/sig/turbopuffer/models/namespace_metadata_params.rbs +25 -0
  177. data/sig/turbopuffer/models/namespace_multi_query_params.rbs +86 -0
  178. data/sig/turbopuffer/models/namespace_multi_query_response.rbs +65 -0
  179. data/sig/turbopuffer/models/namespace_query_params.rbs +139 -0
  180. data/sig/turbopuffer/models/namespace_query_response.rbs +48 -0
  181. data/sig/turbopuffer/models/namespace_recall_params.rbs +63 -0
  182. data/sig/turbopuffer/models/namespace_recall_response.rbs +61 -0
  183. data/sig/turbopuffer/models/namespace_schema_params.rbs +25 -0
  184. data/sig/turbopuffer/models/namespace_schema_response.rbs +8 -0
  185. data/sig/turbopuffer/models/namespace_summary.rbs +13 -0
  186. data/sig/turbopuffer/models/namespace_update_schema_params.rbs +37 -0
  187. data/sig/turbopuffer/models/namespace_update_schema_response.rbs +8 -0
  188. data/sig/turbopuffer/models/namespace_write_params.rbs +156 -0
  189. data/sig/turbopuffer/models/namespace_write_response.rbs +56 -0
  190. data/sig/turbopuffer/models/query.rbs +75 -0
  191. data/sig/turbopuffer/models/query_billing.rbs +25 -0
  192. data/sig/turbopuffer/models/query_performance.rbs +45 -0
  193. data/sig/turbopuffer/models/row.rbs +24 -0
  194. data/sig/turbopuffer/models/tokenizer.rbs +16 -0
  195. data/sig/turbopuffer/models/vector.rbs +13 -0
  196. data/sig/turbopuffer/models/vector_encoding.rbs +14 -0
  197. data/sig/turbopuffer/models/write_billing.rbs +27 -0
  198. data/sig/turbopuffer/models.rbs +65 -0
  199. data/sig/turbopuffer/namespace.rbs +5 -0
  200. data/sig/turbopuffer/request_options.rbs +36 -0
  201. data/sig/turbopuffer/resources/namespaces.rbs +99 -0
  202. data/sig/turbopuffer/version.rbs +3 -0
  203. metadata +218 -29
  204. data/.standard.yml +0 -3
  205. data/LICENSE.txt +0 -21
  206. data/Rakefile +0 -10
  207. data/sig/turbopuffer.rbs +0 -4
@@ -0,0 +1,41 @@
1
+ module Turbopuffer
2
+ class Client < Turbopuffer::Internal::Transport::BaseClient
3
+ DEFAULT_MAX_RETRIES: 4
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,117 @@
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 headers: ::Hash[String, String]?
25
+
26
+ attr_accessor body: top?
27
+
28
+ def initialize: (
29
+ url: URI::Generic,
30
+ ?status: Integer?,
31
+ ?headers: ::Hash[String, String]?,
32
+ ?body: Object?,
33
+ ?request: nil,
34
+ ?response: nil,
35
+ ?message: String?
36
+ ) -> void
37
+ end
38
+
39
+ class APIConnectionError < Turbopuffer::Errors::APIError
40
+ def initialize: (
41
+ url: URI::Generic,
42
+ ?status: nil,
43
+ ?headers: ::Hash[String, String]?,
44
+ ?body: nil,
45
+ ?request: nil,
46
+ ?response: nil,
47
+ ?message: String?
48
+ ) -> void
49
+ end
50
+
51
+ class APITimeoutError < Turbopuffer::Errors::APIConnectionError
52
+ def initialize: (
53
+ url: URI::Generic,
54
+ ?status: nil,
55
+ ?headers: ::Hash[String, String]?,
56
+ ?body: nil,
57
+ ?request: nil,
58
+ ?response: nil,
59
+ ?message: String?
60
+ ) -> void
61
+ end
62
+
63
+ class APIStatusError < Turbopuffer::Errors::APIError
64
+ def self.for: (
65
+ url: URI::Generic,
66
+ status: Integer,
67
+ headers: ::Hash[String, String]?,
68
+ body: Object?,
69
+ request: nil,
70
+ response: nil,
71
+ ?message: String?
72
+ ) -> instance
73
+
74
+ def initialize: (
75
+ url: URI::Generic,
76
+ status: Integer,
77
+ headers: ::Hash[String, String]?,
78
+ body: Object?,
79
+ request: nil,
80
+ response: nil,
81
+ ?message: String?
82
+ ) -> void
83
+ end
84
+
85
+ class BadRequestError < Turbopuffer::Errors::APIStatusError
86
+ HTTP_STATUS: 400
87
+ end
88
+
89
+ class AuthenticationError < Turbopuffer::Errors::APIStatusError
90
+ HTTP_STATUS: 401
91
+ end
92
+
93
+ class PermissionDeniedError < Turbopuffer::Errors::APIStatusError
94
+ HTTP_STATUS: 403
95
+ end
96
+
97
+ class NotFoundError < Turbopuffer::Errors::APIStatusError
98
+ HTTP_STATUS: 404
99
+ end
100
+
101
+ class ConflictError < Turbopuffer::Errors::APIStatusError
102
+ HTTP_STATUS: 409
103
+ end
104
+
105
+ class UnprocessableEntityError < Turbopuffer::Errors::APIStatusError
106
+ HTTP_STATUS: 422
107
+ end
108
+
109
+ class RateLimitError < Turbopuffer::Errors::APIStatusError
110
+ HTTP_STATUS: 429
111
+ end
112
+
113
+ class InternalServerError < Turbopuffer::Errors::APIStatusError
114
+ HTTP_STATUS: Range[Integer]
115
+ end
116
+ end
117
+ 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,13 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ class NamespacePage[Elem]
4
+ include Turbopuffer::Internal::Type::BasePage[Elem]
5
+
6
+ attr_accessor namespaces: ::Array[Elem]?
7
+
8
+ attr_accessor next_cursor: String
9
+
10
+ def inspect: -> String
11
+ end
12
+ end
13
+ 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
+ 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
@@ -0,0 +1,102 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ module Type
4
+ class BaseModel
5
+ extend Turbopuffer::Internal::Type::Converter
6
+ extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
7
+
8
+ type known_field =
9
+ { mode: (:coerce | :dump)?, required: bool, nilable: bool }
10
+
11
+ def self.inherited: (self child) -> void
12
+
13
+ def self.known_fields: -> ::Hash[Symbol, (Turbopuffer::Internal::Type::BaseModel::known_field
14
+ & { type_fn: (^-> Turbopuffer::Internal::Type::Converter::input) })]
15
+
16
+ def self.fields: -> ::Hash[Symbol, (Turbopuffer::Internal::Type::BaseModel::known_field
17
+ & { type: Turbopuffer::Internal::Type::Converter::input })]
18
+
19
+ private def self.add_field: (
20
+ Symbol name_sym,
21
+ required: bool,
22
+ type_info: {
23
+ const: (nil | bool | Integer | Float | Symbol)?,
24
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
25
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?,
26
+ api_name: Symbol
27
+ }
28
+ | ^-> Turbopuffer::Internal::Type::Converter::input
29
+ | Turbopuffer::Internal::Type::Converter::input,
30
+ spec: ::Hash[Symbol, top]
31
+ ) -> void
32
+
33
+ def self.required: (
34
+ Symbol name_sym,
35
+ ::Hash[Symbol, top]
36
+ | ^-> Turbopuffer::Internal::Type::Converter::input
37
+ | Turbopuffer::Internal::Type::Converter::input type_info,
38
+ ?::Hash[Symbol, top] spec
39
+ ) -> void
40
+
41
+ def self.optional: (
42
+ Symbol name_sym,
43
+ ::Hash[Symbol, top]
44
+ | ^-> Turbopuffer::Internal::Type::Converter::input
45
+ | Turbopuffer::Internal::Type::Converter::input type_info,
46
+ ?::Hash[Symbol, top] spec
47
+ ) -> void
48
+
49
+ private def self.request_only: { -> void } -> void
50
+
51
+ private def self.response_only: { -> void } -> void
52
+
53
+ def self.==: (top other) -> bool
54
+
55
+ def self.hash: -> Integer
56
+
57
+ def ==: (top other) -> bool
58
+
59
+ def hash: -> Integer
60
+
61
+ def self.coerce: (
62
+ Turbopuffer::Internal::Type::BaseModel | ::Hash[top, top] | top value,
63
+ state: Turbopuffer::Internal::Type::Converter::coerce_state
64
+ ) -> (instance | top)
65
+
66
+ def self.dump: (
67
+ instance | top value,
68
+ state: Turbopuffer::Internal::Type::Converter::dump_state
69
+ ) -> (::Hash[top, top] | top)
70
+
71
+ def self.to_sorbet_type: -> top
72
+
73
+ def self.recursively_to_h: (
74
+ Turbopuffer::Internal::Type::BaseModel model,
75
+ convert: bool
76
+ ) -> ::Hash[Symbol, top]
77
+
78
+ def []: (Symbol key) -> top?
79
+
80
+ def to_h: -> ::Hash[Symbol, top]
81
+
82
+ alias to_hash to_h
83
+
84
+ def deep_to_h: -> ::Hash[Symbol, top]
85
+
86
+ def deconstruct_keys: (::Array[Symbol]? keys) -> ::Hash[Symbol, top]
87
+
88
+ def to_json: (*top a) -> String
89
+
90
+ def to_yaml: (*top a) -> String
91
+
92
+ def initialize: (?::Hash[Symbol, top] | instance data) -> void
93
+
94
+ def self.inspect: (?depth: Integer) -> String
95
+
96
+ def to_s: -> String
97
+
98
+ def inspect: -> String
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,24 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ module Type
4
+ module BasePage[Elem]
5
+ def next_page?: -> bool
6
+
7
+ def next_page: -> instance
8
+
9
+ def auto_paging_each: { (Elem arg0) -> void } -> void
10
+
11
+ def to_enum: -> Enumerable[Elem]
12
+
13
+ alias enum_for to_enum
14
+
15
+ def initialize: (
16
+ client: Turbopuffer::Internal::Transport::BaseClient,
17
+ req: Turbopuffer::Internal::Transport::BaseClient::request_components,
18
+ headers: ::Hash[String, String],
19
+ page_data: top
20
+ ) -> void
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,26 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ module Type
4
+ class Boolean
5
+ extend Turbopuffer::Internal::Type::Converter
6
+ extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
7
+
8
+ def self.===: (top other) -> bool
9
+
10
+ def self.==: (top other) -> bool
11
+
12
+ def self.coerce: (
13
+ bool | top value,
14
+ state: Turbopuffer::Internal::Type::Converter::coerce_state
15
+ ) -> (bool | top)
16
+
17
+ def self.dump: (
18
+ bool | top value,
19
+ state: Turbopuffer::Internal::Type::Converter::dump_state
20
+ ) -> (bool | top)
21
+
22
+ def self.to_sorbet_type: -> top
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,79 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ module Type
4
+ module Converter
5
+ extend Turbopuffer::Internal::Util::SorbetRuntimeSupport
6
+
7
+ type input = Turbopuffer::Internal::Type::Converter | Class
8
+
9
+ type coerce_state =
10
+ {
11
+ translate_names: bool,
12
+ strictness: bool,
13
+ exactness: { yes: Integer, no: Integer, maybe: Integer },
14
+ error: Class,
15
+ branched: Integer
16
+ }
17
+
18
+ type dump_state = { can_retry: bool }
19
+
20
+ def coerce: (
21
+ top value,
22
+ state: Turbopuffer::Internal::Type::Converter::coerce_state
23
+ ) -> top
24
+
25
+ def dump: (
26
+ top value,
27
+ state: Turbopuffer::Internal::Type::Converter::dump_state
28
+ ) -> top
29
+
30
+ def inspect: (?depth: Integer) -> String
31
+
32
+ def self.type_info: (
33
+ {
34
+ const: (nil | bool | Integer | Float | Symbol)?,
35
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
36
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?
37
+ }
38
+ | ^-> Turbopuffer::Internal::Type::Converter::input
39
+ | Turbopuffer::Internal::Type::Converter::input spec
40
+ ) -> (^-> top)
41
+
42
+ def self.meta_info: (
43
+ {
44
+ const: (nil | bool | Integer | Float | Symbol)?,
45
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
46
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?
47
+ }
48
+ | ^-> Turbopuffer::Internal::Type::Converter::input
49
+ | Turbopuffer::Internal::Type::Converter::input type_info,
50
+ {
51
+ const: (nil | bool | Integer | Float | Symbol)?,
52
+ enum: ^-> Turbopuffer::Internal::Type::Converter::input?,
53
+ union: ^-> Turbopuffer::Internal::Type::Converter::input?
54
+ }
55
+ | ^-> Turbopuffer::Internal::Type::Converter::input
56
+ | Turbopuffer::Internal::Type::Converter::input spec
57
+ ) -> ::Hash[Symbol, top]
58
+
59
+ def self.new_coerce_state: (
60
+ ?translate_names: bool
61
+ ) -> Turbopuffer::Internal::Type::Converter::coerce_state
62
+
63
+ def self.coerce: (
64
+ Turbopuffer::Internal::Type::Converter::input target,
65
+ top value,
66
+ ?state: Turbopuffer::Internal::Type::Converter::coerce_state
67
+ ) -> top
68
+
69
+ def self.dump: (
70
+ Turbopuffer::Internal::Type::Converter::input target,
71
+ top value,
72
+ ?state: Turbopuffer::Internal::Type::Converter::dump_state
73
+ ) -> top
74
+
75
+ def self.inspect: (top target, depth: Integer) -> String
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,32 @@
1
+ module Turbopuffer
2
+ module Internal
3
+ module Type
4
+ module Enum
5
+ include Turbopuffer::Internal::Type::Converter
6
+ include Turbopuffer::Internal::Util::SorbetRuntimeSupport
7
+
8
+ def self.values: -> ::Array[(nil | bool | Integer | Float | Symbol)]
9
+
10
+ def ===: (top other) -> bool
11
+
12
+ def ==: (top other) -> bool
13
+
14
+ def hash: -> Integer
15
+
16
+ def coerce: (
17
+ String | Symbol | top value,
18
+ state: Turbopuffer::Internal::Type::Converter::coerce_state
19
+ ) -> (Symbol | top)
20
+
21
+ def dump: (
22
+ Symbol | top value,
23
+ state: Turbopuffer::Internal::Type::Converter::dump_state
24
+ ) -> (Symbol | top)
25
+
26
+ def to_sorbet_type: -> top
27
+
28
+ def inspect: (?depth: Integer) -> String
29
+ end
30
+ end
31
+ end
32
+ end