spikard 0.3.0 → 0.3.2

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 (182) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +659 -659
  4. data/ext/spikard_rb/Cargo.toml +17 -17
  5. data/ext/spikard_rb/extconf.rb +10 -10
  6. data/ext/spikard_rb/src/lib.rs +6 -6
  7. data/lib/spikard/app.rb +386 -386
  8. data/lib/spikard/background.rb +27 -27
  9. data/lib/spikard/config.rb +396 -396
  10. data/lib/spikard/converters.rb +13 -13
  11. data/lib/spikard/handler_wrapper.rb +113 -113
  12. data/lib/spikard/provide.rb +214 -214
  13. data/lib/spikard/response.rb +173 -173
  14. data/lib/spikard/schema.rb +243 -243
  15. data/lib/spikard/sse.rb +111 -111
  16. data/lib/spikard/streaming_response.rb +44 -44
  17. data/lib/spikard/testing.rb +221 -221
  18. data/lib/spikard/upload_file.rb +131 -131
  19. data/lib/spikard/version.rb +5 -5
  20. data/lib/spikard/websocket.rb +59 -59
  21. data/lib/spikard.rb +43 -43
  22. data/sig/spikard.rbs +360 -360
  23. data/vendor/crates/spikard-core/Cargo.toml +40 -0
  24. data/vendor/crates/spikard-core/src/bindings/mod.rs +3 -0
  25. data/vendor/crates/spikard-core/src/bindings/response.rs +133 -0
  26. data/vendor/crates/spikard-core/src/debug.rs +63 -0
  27. data/vendor/crates/spikard-core/src/di/container.rs +726 -0
  28. data/vendor/crates/spikard-core/src/di/dependency.rs +273 -0
  29. data/vendor/crates/spikard-core/src/di/error.rs +118 -0
  30. data/vendor/crates/spikard-core/src/di/factory.rs +538 -0
  31. data/vendor/crates/spikard-core/src/di/graph.rs +545 -0
  32. data/vendor/crates/spikard-core/src/di/mod.rs +192 -0
  33. data/vendor/crates/spikard-core/src/di/resolved.rs +411 -0
  34. data/vendor/crates/spikard-core/src/di/value.rs +283 -0
  35. data/vendor/crates/spikard-core/src/errors.rs +39 -0
  36. data/vendor/crates/spikard-core/src/http.rs +153 -0
  37. data/vendor/crates/spikard-core/src/lib.rs +29 -0
  38. data/vendor/crates/spikard-core/src/lifecycle.rs +422 -0
  39. data/vendor/crates/spikard-core/src/parameters.rs +722 -0
  40. data/vendor/crates/spikard-core/src/problem.rs +310 -0
  41. data/vendor/crates/spikard-core/src/request_data.rs +189 -0
  42. data/vendor/crates/spikard-core/src/router.rs +249 -0
  43. data/vendor/crates/spikard-core/src/schema_registry.rs +183 -0
  44. data/vendor/crates/spikard-core/src/type_hints.rs +304 -0
  45. data/vendor/crates/spikard-core/src/validation.rs +699 -0
  46. data/vendor/crates/spikard-http/Cargo.toml +58 -0
  47. data/vendor/crates/spikard-http/src/auth.rs +247 -0
  48. data/vendor/crates/spikard-http/src/background.rs +249 -0
  49. data/vendor/crates/spikard-http/src/bindings/mod.rs +3 -0
  50. data/vendor/crates/spikard-http/src/bindings/response.rs +1 -0
  51. data/vendor/crates/spikard-http/src/body_metadata.rs +8 -0
  52. data/vendor/crates/spikard-http/src/cors.rs +490 -0
  53. data/vendor/crates/spikard-http/src/debug.rs +63 -0
  54. data/vendor/crates/spikard-http/src/di_handler.rs +423 -0
  55. data/vendor/crates/spikard-http/src/handler_response.rs +190 -0
  56. data/vendor/crates/spikard-http/src/handler_trait.rs +228 -0
  57. data/vendor/crates/spikard-http/src/handler_trait_tests.rs +284 -0
  58. data/vendor/crates/spikard-http/src/lib.rs +529 -0
  59. data/vendor/crates/spikard-http/src/lifecycle/adapter.rs +149 -0
  60. data/vendor/crates/spikard-http/src/lifecycle.rs +428 -0
  61. data/vendor/crates/spikard-http/src/middleware/mod.rs +285 -0
  62. data/vendor/crates/spikard-http/src/middleware/multipart.rs +86 -0
  63. data/vendor/crates/spikard-http/src/middleware/urlencoded.rs +147 -0
  64. data/vendor/crates/spikard-http/src/middleware/validation.rs +287 -0
  65. data/vendor/crates/spikard-http/src/openapi/mod.rs +309 -0
  66. data/vendor/crates/spikard-http/src/openapi/parameter_extraction.rs +190 -0
  67. data/vendor/crates/spikard-http/src/openapi/schema_conversion.rs +308 -0
  68. data/vendor/crates/spikard-http/src/openapi/spec_generation.rs +195 -0
  69. data/vendor/crates/spikard-http/src/parameters.rs +1 -0
  70. data/vendor/crates/spikard-http/src/problem.rs +1 -0
  71. data/vendor/crates/spikard-http/src/query_parser.rs +369 -0
  72. data/vendor/crates/spikard-http/src/response.rs +399 -0
  73. data/vendor/crates/spikard-http/src/router.rs +1 -0
  74. data/vendor/crates/spikard-http/src/schema_registry.rs +1 -0
  75. data/vendor/crates/spikard-http/src/server/handler.rs +87 -0
  76. data/vendor/crates/spikard-http/src/server/lifecycle_execution.rs +98 -0
  77. data/vendor/crates/spikard-http/src/server/mod.rs +805 -0
  78. data/vendor/crates/spikard-http/src/server/request_extraction.rs +119 -0
  79. data/vendor/crates/spikard-http/src/sse.rs +447 -0
  80. data/vendor/crates/spikard-http/src/testing/form.rs +14 -0
  81. data/vendor/crates/spikard-http/src/testing/multipart.rs +60 -0
  82. data/vendor/crates/spikard-http/src/testing/test_client.rs +285 -0
  83. data/vendor/crates/spikard-http/src/testing.rs +377 -0
  84. data/vendor/crates/spikard-http/src/type_hints.rs +1 -0
  85. data/vendor/crates/spikard-http/src/validation.rs +1 -0
  86. data/vendor/crates/spikard-http/src/websocket.rs +324 -0
  87. data/vendor/crates/spikard-rb/Cargo.toml +42 -0
  88. data/vendor/crates/spikard-rb/build.rs +8 -0
  89. data/vendor/crates/spikard-rb/src/background.rs +63 -0
  90. data/vendor/crates/spikard-rb/src/config.rs +294 -0
  91. data/vendor/crates/spikard-rb/src/conversion.rs +453 -0
  92. data/vendor/crates/spikard-rb/src/di.rs +409 -0
  93. data/vendor/crates/spikard-rb/src/handler.rs +625 -0
  94. data/vendor/crates/spikard-rb/src/lib.rs +2771 -0
  95. data/vendor/crates/spikard-rb/src/lifecycle.rs +274 -0
  96. data/vendor/crates/spikard-rb/src/server.rs +283 -0
  97. data/vendor/crates/spikard-rb/src/sse.rs +231 -0
  98. data/vendor/crates/spikard-rb/src/test_client.rs +404 -0
  99. data/vendor/crates/spikard-rb/src/test_sse.rs +143 -0
  100. data/vendor/crates/spikard-rb/src/test_websocket.rs +221 -0
  101. data/vendor/crates/spikard-rb/src/websocket.rs +233 -0
  102. data/vendor/spikard-core/Cargo.toml +40 -0
  103. data/vendor/spikard-core/src/bindings/mod.rs +3 -0
  104. data/vendor/spikard-core/src/bindings/response.rs +133 -0
  105. data/vendor/spikard-core/src/debug.rs +63 -0
  106. data/vendor/spikard-core/src/di/container.rs +726 -0
  107. data/vendor/spikard-core/src/di/dependency.rs +273 -0
  108. data/vendor/spikard-core/src/di/error.rs +118 -0
  109. data/vendor/spikard-core/src/di/factory.rs +538 -0
  110. data/vendor/spikard-core/src/di/graph.rs +545 -0
  111. data/vendor/spikard-core/src/di/mod.rs +192 -0
  112. data/vendor/spikard-core/src/di/resolved.rs +411 -0
  113. data/vendor/spikard-core/src/di/value.rs +283 -0
  114. data/vendor/spikard-core/src/http.rs +153 -0
  115. data/vendor/spikard-core/src/lib.rs +28 -0
  116. data/vendor/spikard-core/src/lifecycle.rs +422 -0
  117. data/vendor/spikard-core/src/parameters.rs +719 -0
  118. data/vendor/spikard-core/src/problem.rs +310 -0
  119. data/vendor/spikard-core/src/request_data.rs +189 -0
  120. data/vendor/spikard-core/src/router.rs +249 -0
  121. data/vendor/spikard-core/src/schema_registry.rs +183 -0
  122. data/vendor/spikard-core/src/type_hints.rs +304 -0
  123. data/vendor/spikard-core/src/validation.rs +699 -0
  124. data/vendor/spikard-http/Cargo.toml +58 -0
  125. data/vendor/spikard-http/src/auth.rs +247 -0
  126. data/vendor/spikard-http/src/background.rs +249 -0
  127. data/vendor/spikard-http/src/bindings/mod.rs +3 -0
  128. data/vendor/spikard-http/src/bindings/response.rs +1 -0
  129. data/vendor/spikard-http/src/body_metadata.rs +8 -0
  130. data/vendor/spikard-http/src/cors.rs +490 -0
  131. data/vendor/spikard-http/src/debug.rs +63 -0
  132. data/vendor/spikard-http/src/di_handler.rs +423 -0
  133. data/vendor/spikard-http/src/handler_response.rs +190 -0
  134. data/vendor/spikard-http/src/handler_trait.rs +228 -0
  135. data/vendor/spikard-http/src/handler_trait_tests.rs +284 -0
  136. data/vendor/spikard-http/src/lib.rs +529 -0
  137. data/vendor/spikard-http/src/lifecycle/adapter.rs +149 -0
  138. data/vendor/spikard-http/src/lifecycle.rs +428 -0
  139. data/vendor/spikard-http/src/middleware/mod.rs +285 -0
  140. data/vendor/spikard-http/src/middleware/multipart.rs +86 -0
  141. data/vendor/spikard-http/src/middleware/urlencoded.rs +147 -0
  142. data/vendor/spikard-http/src/middleware/validation.rs +287 -0
  143. data/vendor/spikard-http/src/openapi/mod.rs +309 -0
  144. data/vendor/spikard-http/src/openapi/parameter_extraction.rs +190 -0
  145. data/vendor/spikard-http/src/openapi/schema_conversion.rs +308 -0
  146. data/vendor/spikard-http/src/openapi/spec_generation.rs +195 -0
  147. data/vendor/spikard-http/src/parameters.rs +1 -0
  148. data/vendor/spikard-http/src/problem.rs +1 -0
  149. data/vendor/spikard-http/src/query_parser.rs +369 -0
  150. data/vendor/spikard-http/src/response.rs +399 -0
  151. data/vendor/spikard-http/src/router.rs +1 -0
  152. data/vendor/spikard-http/src/schema_registry.rs +1 -0
  153. data/vendor/spikard-http/src/server/handler.rs +80 -0
  154. data/vendor/spikard-http/src/server/lifecycle_execution.rs +98 -0
  155. data/vendor/spikard-http/src/server/mod.rs +805 -0
  156. data/vendor/spikard-http/src/server/request_extraction.rs +119 -0
  157. data/vendor/spikard-http/src/sse.rs +447 -0
  158. data/vendor/spikard-http/src/testing/form.rs +14 -0
  159. data/vendor/spikard-http/src/testing/multipart.rs +60 -0
  160. data/vendor/spikard-http/src/testing/test_client.rs +285 -0
  161. data/vendor/spikard-http/src/testing.rs +377 -0
  162. data/vendor/spikard-http/src/type_hints.rs +1 -0
  163. data/vendor/spikard-http/src/validation.rs +1 -0
  164. data/vendor/spikard-http/src/websocket.rs +324 -0
  165. data/vendor/spikard-rb/Cargo.toml +42 -0
  166. data/vendor/spikard-rb/build.rs +8 -0
  167. data/vendor/spikard-rb/src/background.rs +63 -0
  168. data/vendor/spikard-rb/src/config.rs +294 -0
  169. data/vendor/spikard-rb/src/conversion.rs +392 -0
  170. data/vendor/spikard-rb/src/di.rs +409 -0
  171. data/vendor/spikard-rb/src/handler.rs +534 -0
  172. data/vendor/spikard-rb/src/lib.rs +2020 -0
  173. data/vendor/spikard-rb/src/lifecycle.rs +267 -0
  174. data/vendor/spikard-rb/src/server.rs +283 -0
  175. data/vendor/spikard-rb/src/sse.rs +231 -0
  176. data/vendor/spikard-rb/src/test_client.rs +404 -0
  177. data/vendor/spikard-rb/src/test_sse.rs +143 -0
  178. data/vendor/spikard-rb/src/test_websocket.rs +221 -0
  179. data/vendor/spikard-rb/src/websocket.rs +233 -0
  180. metadata +162 -8
  181. /data/vendor/bundle/ruby/{3.3.0 → 3.4.0}/gems/diff-lcs-1.6.2/mise.toml +0 -0
  182. /data/vendor/bundle/ruby/{3.3.0 → 3.4.0}/gems/rake-compiler-dock-1.10.0/build/buildkitd.toml +0 -0
data/sig/spikard.rbs CHANGED
@@ -1,360 +1,360 @@
1
- module Spikard
2
- VERSION: String
3
-
4
- module Background
5
- def self.run: () { () -> void } -> void
6
- end
7
-
8
- class CompressionConfig
9
- attr_accessor gzip: bool
10
- attr_accessor brotli: bool
11
- attr_accessor min_size: Integer
12
- attr_accessor quality: Integer
13
-
14
- def initialize: (?gzip: bool, ?brotli: bool, ?min_size: Integer, ?quality: Integer) -> void
15
- end
16
-
17
- class RateLimitConfig
18
- attr_accessor per_second: Integer
19
- attr_accessor burst: Integer
20
- attr_accessor ip_based: bool
21
-
22
- def initialize: (per_second: Integer, burst: Integer, ?ip_based: bool) -> void
23
- end
24
-
25
- class JwtConfig
26
- attr_accessor secret: String
27
- attr_accessor algorithm: String
28
- attr_accessor audience: Array[String]?
29
- attr_accessor issuer: String?
30
- attr_accessor leeway: Integer
31
-
32
- def initialize: (secret: String, ?algorithm: String, ?audience: Array[String]?, ?issuer: String?, ?leeway: Integer) -> void
33
- end
34
-
35
- class ApiKeyConfig
36
- attr_accessor keys: Array[String]
37
- attr_accessor header_name: String
38
-
39
- def initialize: (keys: Array[String], ?header_name: String) -> void
40
- end
41
-
42
- class StaticFilesConfig
43
- attr_accessor directory: String
44
- attr_accessor route_prefix: String
45
- attr_accessor index_file: bool
46
- attr_accessor cache_control: String?
47
-
48
- def initialize: (directory: String, route_prefix: String, ?index_file: bool, ?cache_control: String?) -> void
49
- end
50
-
51
- class ContactInfo
52
- attr_accessor name: String?
53
- attr_accessor email: String?
54
- attr_accessor url: String?
55
-
56
- def initialize: (?name: String?, ?email: String?, ?url: String?) -> void
57
- end
58
-
59
- class LicenseInfo
60
- attr_accessor name: String
61
- attr_accessor url: String?
62
-
63
- def initialize: (name: String, ?url: String?) -> void
64
- end
65
-
66
- class ServerInfo
67
- attr_accessor url: String
68
- attr_accessor description: String?
69
-
70
- def initialize: (url: String, ?description: String?) -> void
71
- end
72
-
73
- class SecuritySchemeInfo
74
- attr_accessor type: String
75
- attr_accessor scheme: String?
76
- attr_accessor bearer_format: String?
77
- attr_accessor location: String?
78
- attr_accessor name: String?
79
-
80
- def initialize: (type: String, ?scheme: String?, ?bearer_format: String?, ?location: String?, ?name: String?) -> void
81
- end
82
-
83
- class OpenApiConfig
84
- attr_accessor enabled: bool
85
- attr_accessor title: String
86
- attr_accessor version: String
87
- attr_accessor description: String?
88
- attr_accessor swagger_ui_path: String
89
- attr_accessor redoc_path: String
90
- attr_accessor openapi_json_path: String
91
- attr_accessor contact: ContactInfo?
92
- attr_accessor license: LicenseInfo?
93
- attr_accessor servers: Array[ServerInfo]
94
- attr_accessor security_schemes: Hash[String, SecuritySchemeInfo]
95
-
96
- def initialize: (
97
- ?enabled: bool,
98
- ?title: String,
99
- ?version: String,
100
- ?description: String?,
101
- ?swagger_ui_path: String,
102
- ?redoc_path: String,
103
- ?openapi_json_path: String,
104
- ?contact: ContactInfo?,
105
- ?license: LicenseInfo?,
106
- ?servers: Array[ServerInfo],
107
- ?security_schemes: Hash[String, SecuritySchemeInfo]
108
- ) -> void
109
- end
110
-
111
- class ServerConfig
112
- attr_accessor host: String
113
- attr_accessor port: Integer
114
- attr_accessor workers: Integer
115
- attr_accessor enable_request_id: bool
116
- attr_accessor max_body_size: Integer?
117
- attr_accessor request_timeout: Integer?
118
- attr_accessor compression: CompressionConfig
119
- attr_accessor rate_limit: RateLimitConfig?
120
- attr_accessor jwt_auth: JwtConfig?
121
- attr_accessor api_key_auth: ApiKeyConfig?
122
- attr_accessor static_files: Array[StaticFilesConfig]
123
- attr_accessor graceful_shutdown: bool
124
- attr_accessor shutdown_timeout: Integer
125
- attr_accessor openapi: OpenApiConfig?
126
-
127
- def initialize: (
128
- ?host: String,
129
- ?port: Integer,
130
- ?workers: Integer,
131
- ?enable_request_id: bool,
132
- ?max_body_size: Integer?,
133
- ?request_timeout: Integer?,
134
- ?compression: CompressionConfig,
135
- ?rate_limit: RateLimitConfig?,
136
- ?jwt_auth: JwtConfig?,
137
- ?api_key_auth: ApiKeyConfig?,
138
- ?static_files: Array[StaticFilesConfig],
139
- ?graceful_shutdown: bool,
140
- ?shutdown_timeout: Integer,
141
- ?openapi: OpenApiConfig?
142
- ) -> void
143
- end
144
-
145
- class Response
146
- attr_reader content: untyped
147
- attr_reader status_code: Integer
148
- attr_reader headers: Hash[String, String]
149
- attr_reader native_response: untyped
150
-
151
- def initialize: (
152
- ?content: untyped,
153
- ?body: untyped,
154
- ?status_code: Integer,
155
- ?headers: Hash[untyped, untyped]?,
156
- ?content_type: String?
157
- ) -> void
158
- def status: () -> Integer
159
- def status_code=: (Integer) -> Integer
160
- def headers=: (Hash[untyped, untyped]?) -> Hash[String, String]
161
- def content=: (untyped) -> untyped
162
- def set_header: (String, String) -> String
163
- def set_cookie: (
164
- String,
165
- String,
166
- ?max_age: Integer?,
167
- ?domain: String?,
168
- ?path: String?,
169
- ?secure: bool?,
170
- ?httponly: bool?,
171
- ?samesite: String?
172
- ) -> String
173
- def to_native_response: () -> untyped
174
- end
175
-
176
- class StreamingResponse
177
- attr_reader stream: Enumerable[untyped]
178
- attr_reader status_code: Integer
179
- attr_reader headers: Hash[String, String]
180
- attr_reader native_response: untyped
181
-
182
- def initialize: (Enumerable[untyped], ?status_code: Integer, ?headers: Hash[untyped, untyped]?) -> void
183
- def to_native_response: () -> untyped
184
- end
185
-
186
- module Testing
187
- end
188
-
189
- module LifecycleHooks
190
- def on_request: () { (untyped) -> untyped } -> Proc
191
- def pre_validation: () { (untyped) -> untyped } -> Proc
192
- def pre_handler: () { (untyped) -> untyped } -> Proc
193
- def on_response: () { (untyped) -> untyped } -> Proc
194
- def on_error: () { (untyped) -> untyped } -> Proc
195
- end
196
-
197
- module ProvideSupport
198
- def provide: (
199
- String | Symbol,
200
- ?untyped,
201
- ?depends_on: Array[String | Symbol],
202
- ?singleton: bool,
203
- ?cacheable: bool
204
- ) ?{ (**untyped) -> untyped } -> self
205
- def dependencies: () -> Spikard::Native::DependencyRegistry
206
- end
207
-
208
- class App
209
- include LifecycleHooks
210
- include ProvideSupport
211
-
212
- attr_reader routes: Array[untyped]
213
-
214
- def initialize: () -> void
215
- def register_route: (String, String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
216
- def get: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
217
- def post: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
218
- def put: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
219
- def patch: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
220
- def delete: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
221
- def options: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
222
- def head: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
223
- def trace: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
224
- def websocket: (String, ?handler_name: String?, **untyped) { () -> WebSocketHandler } -> Proc
225
- def sse: (String, ?handler_name: String?, **untyped) { () -> SseEventProducer } -> Proc
226
- def websocket_handlers: () -> Hash[String, Proc]
227
- def sse_producers: () -> Hash[String, Proc]
228
- def run: (?config: ServerConfig | Hash[Symbol, untyped]?, ?host: String?, ?port: Integer?) -> void
229
- end
230
-
231
- class WebSocketHandler
232
- def handle_message: (Hash[untyped, untyped]) -> Hash[untyped, untyped]?
233
- def on_connect: () -> void
234
- def on_disconnect: () -> void
235
- end
236
-
237
- class SseEvent
238
- attr_accessor data: Hash[untyped, untyped]
239
- attr_accessor event_type: String?
240
- attr_accessor id: String?
241
- attr_accessor retry_ms: Integer?
242
-
243
- def initialize: (data: Hash[untyped, untyped], ?event_type: String?, ?id: String?, ?retry_ms: Integer?) -> void
244
- def to_h: () -> Hash[Symbol, untyped]
245
- end
246
-
247
- class SseEventProducer
248
- def next_event: () -> SseEvent?
249
- def on_connect: () -> void
250
- def on_disconnect: () -> void
251
- end
252
-
253
- module Schema
254
- def self.extract_json_schema: (untyped) -> Hash[untyped, untyped]?
255
- end
256
-
257
- module Native
258
- def self.run_server: (
259
- String,
260
- Hash[Symbol, Proc],
261
- ServerConfig,
262
- Hash[Symbol, Array[Proc]],
263
- Hash[String, Proc],
264
- Hash[String, Proc],
265
- Hash[String, untyped]
266
- ) -> void
267
-
268
- class DependencyRegistry
269
- def initialize: () -> void
270
- end
271
-
272
- class TestClient
273
- def initialize: (
274
- String,
275
- Hash[Symbol, Proc],
276
- ServerConfig,
277
- Hash[String, Proc],
278
- Hash[String, Proc]
279
- ) -> void
280
- def request: (String, String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
281
- def websocket: (String) -> untyped
282
- def sse: (String) -> untyped
283
- def close: () -> void
284
- end
285
- end
286
-
287
- module Testing
288
- def self.create_test_client: (App, ?config: ServerConfig?) -> Testing::TestClient
289
-
290
- class Response
291
- attr_reader status_code: Integer
292
- attr_reader headers: Hash[String, String]
293
- attr_reader body: String?
294
-
295
- def initialize: (Hash[Symbol, untyped]) -> void
296
- def status: () -> Integer
297
- def body_bytes: () -> String
298
- def body_text: () -> String?
299
- def text: () -> String?
300
- def json: () -> untyped
301
- def bytes: () -> Array[Integer]
302
- end
303
-
304
- class TestClient
305
- def initialize: (Spikard::Native::TestClient) -> void
306
- def self.new: (App | Spikard::Native::TestClient, ?config: ServerConfig?) -> TestClient
307
- def request: (String, String, **Hash[Symbol, untyped]) -> Response
308
- def websocket: (String) -> WebSocketTestConnection
309
- def sse: (String) -> SseStream
310
- def close: () -> void
311
- def get: (String, **Hash[Symbol, untyped]) -> Response
312
- def post: (String, **Hash[Symbol, untyped]) -> Response
313
- def put: (String, **Hash[Symbol, untyped]) -> Response
314
- def patch: (String, **Hash[Symbol, untyped]) -> Response
315
- def delete: (String, **Hash[Symbol, untyped]) -> Response
316
- def head: (String, **Hash[Symbol, untyped]) -> Response
317
- def options: (String, **Hash[Symbol, untyped]) -> Response
318
- def trace: (String, **Hash[Symbol, untyped]) -> Response
319
- end
320
-
321
- class WebSocketTestConnection
322
- def initialize: (untyped) -> void
323
- def send_text: (untyped) -> void
324
- def send_json: (untyped) -> void
325
- def receive_text: () -> untyped
326
- def receive_json: () -> untyped
327
- def receive_bytes: () -> untyped
328
- def receive_message: () -> WebSocketMessage
329
- def close: () -> void
330
- end
331
-
332
- class WebSocketMessage
333
- def initialize: (untyped) -> void
334
- def as_text: () -> untyped
335
- def as_json: () -> untyped
336
- def as_binary: () -> untyped
337
- def close?: () -> bool
338
- end
339
-
340
- class SseStream
341
- def initialize: (untyped) -> void
342
- def body: () -> String?
343
- def events: () -> Array[InlineSseEvent]
344
- def events_as_json: () -> Array[untyped]
345
- end
346
-
347
- class SseEvent
348
- def initialize: (untyped) -> void
349
- def data: () -> untyped
350
- def as_json: () -> untyped
351
- end
352
-
353
- class InlineSseEvent
354
- attr_reader data: String
355
-
356
- def initialize: (String) -> void
357
- def as_json: () -> untyped
358
- end
359
- end
360
- end
1
+ module Spikard
2
+ VERSION: String
3
+
4
+ module Background
5
+ def self.run: () { () -> void } -> void
6
+ end
7
+
8
+ class CompressionConfig
9
+ attr_accessor gzip: bool
10
+ attr_accessor brotli: bool
11
+ attr_accessor min_size: Integer
12
+ attr_accessor quality: Integer
13
+
14
+ def initialize: (?gzip: bool, ?brotli: bool, ?min_size: Integer, ?quality: Integer) -> void
15
+ end
16
+
17
+ class RateLimitConfig
18
+ attr_accessor per_second: Integer
19
+ attr_accessor burst: Integer
20
+ attr_accessor ip_based: bool
21
+
22
+ def initialize: (per_second: Integer, burst: Integer, ?ip_based: bool) -> void
23
+ end
24
+
25
+ class JwtConfig
26
+ attr_accessor secret: String
27
+ attr_accessor algorithm: String
28
+ attr_accessor audience: Array[String]?
29
+ attr_accessor issuer: String?
30
+ attr_accessor leeway: Integer
31
+
32
+ def initialize: (secret: String, ?algorithm: String, ?audience: Array[String]?, ?issuer: String?, ?leeway: Integer) -> void
33
+ end
34
+
35
+ class ApiKeyConfig
36
+ attr_accessor keys: Array[String]
37
+ attr_accessor header_name: String
38
+
39
+ def initialize: (keys: Array[String], ?header_name: String) -> void
40
+ end
41
+
42
+ class StaticFilesConfig
43
+ attr_accessor directory: String
44
+ attr_accessor route_prefix: String
45
+ attr_accessor index_file: bool
46
+ attr_accessor cache_control: String?
47
+
48
+ def initialize: (directory: String, route_prefix: String, ?index_file: bool, ?cache_control: String?) -> void
49
+ end
50
+
51
+ class ContactInfo
52
+ attr_accessor name: String?
53
+ attr_accessor email: String?
54
+ attr_accessor url: String?
55
+
56
+ def initialize: (?name: String?, ?email: String?, ?url: String?) -> void
57
+ end
58
+
59
+ class LicenseInfo
60
+ attr_accessor name: String
61
+ attr_accessor url: String?
62
+
63
+ def initialize: (name: String, ?url: String?) -> void
64
+ end
65
+
66
+ class ServerInfo
67
+ attr_accessor url: String
68
+ attr_accessor description: String?
69
+
70
+ def initialize: (url: String, ?description: String?) -> void
71
+ end
72
+
73
+ class SecuritySchemeInfo
74
+ attr_accessor type: String
75
+ attr_accessor scheme: String?
76
+ attr_accessor bearer_format: String?
77
+ attr_accessor location: String?
78
+ attr_accessor name: String?
79
+
80
+ def initialize: (type: String, ?scheme: String?, ?bearer_format: String?, ?location: String?, ?name: String?) -> void
81
+ end
82
+
83
+ class OpenApiConfig
84
+ attr_accessor enabled: bool
85
+ attr_accessor title: String
86
+ attr_accessor version: String
87
+ attr_accessor description: String?
88
+ attr_accessor swagger_ui_path: String
89
+ attr_accessor redoc_path: String
90
+ attr_accessor openapi_json_path: String
91
+ attr_accessor contact: ContactInfo?
92
+ attr_accessor license: LicenseInfo?
93
+ attr_accessor servers: Array[ServerInfo]
94
+ attr_accessor security_schemes: Hash[String, SecuritySchemeInfo]
95
+
96
+ def initialize: (
97
+ ?enabled: bool,
98
+ ?title: String,
99
+ ?version: String,
100
+ ?description: String?,
101
+ ?swagger_ui_path: String,
102
+ ?redoc_path: String,
103
+ ?openapi_json_path: String,
104
+ ?contact: ContactInfo?,
105
+ ?license: LicenseInfo?,
106
+ ?servers: Array[ServerInfo],
107
+ ?security_schemes: Hash[String, SecuritySchemeInfo]
108
+ ) -> void
109
+ end
110
+
111
+ class ServerConfig
112
+ attr_accessor host: String
113
+ attr_accessor port: Integer
114
+ attr_accessor workers: Integer
115
+ attr_accessor enable_request_id: bool
116
+ attr_accessor max_body_size: Integer?
117
+ attr_accessor request_timeout: Integer?
118
+ attr_accessor compression: CompressionConfig
119
+ attr_accessor rate_limit: RateLimitConfig?
120
+ attr_accessor jwt_auth: JwtConfig?
121
+ attr_accessor api_key_auth: ApiKeyConfig?
122
+ attr_accessor static_files: Array[StaticFilesConfig]
123
+ attr_accessor graceful_shutdown: bool
124
+ attr_accessor shutdown_timeout: Integer
125
+ attr_accessor openapi: OpenApiConfig?
126
+
127
+ def initialize: (
128
+ ?host: String,
129
+ ?port: Integer,
130
+ ?workers: Integer,
131
+ ?enable_request_id: bool,
132
+ ?max_body_size: Integer?,
133
+ ?request_timeout: Integer?,
134
+ ?compression: CompressionConfig,
135
+ ?rate_limit: RateLimitConfig?,
136
+ ?jwt_auth: JwtConfig?,
137
+ ?api_key_auth: ApiKeyConfig?,
138
+ ?static_files: Array[StaticFilesConfig],
139
+ ?graceful_shutdown: bool,
140
+ ?shutdown_timeout: Integer,
141
+ ?openapi: OpenApiConfig?
142
+ ) -> void
143
+ end
144
+
145
+ class Response
146
+ attr_reader content: untyped
147
+ attr_reader status_code: Integer
148
+ attr_reader headers: Hash[String, String]
149
+ attr_reader native_response: untyped
150
+
151
+ def initialize: (
152
+ ?content: untyped,
153
+ ?body: untyped,
154
+ ?status_code: Integer,
155
+ ?headers: Hash[untyped, untyped]?,
156
+ ?content_type: String?
157
+ ) -> void
158
+ def status: () -> Integer
159
+ def status_code=: (Integer) -> Integer
160
+ def headers=: (Hash[untyped, untyped]?) -> Hash[String, String]
161
+ def content=: (untyped) -> untyped
162
+ def set_header: (String, String) -> String
163
+ def set_cookie: (
164
+ String,
165
+ String,
166
+ ?max_age: Integer?,
167
+ ?domain: String?,
168
+ ?path: String?,
169
+ ?secure: bool?,
170
+ ?httponly: bool?,
171
+ ?samesite: String?
172
+ ) -> String
173
+ def to_native_response: () -> untyped
174
+ end
175
+
176
+ class StreamingResponse
177
+ attr_reader stream: Enumerable[untyped]
178
+ attr_reader status_code: Integer
179
+ attr_reader headers: Hash[String, String]
180
+ attr_reader native_response: untyped
181
+
182
+ def initialize: (Enumerable[untyped], ?status_code: Integer, ?headers: Hash[untyped, untyped]?) -> void
183
+ def to_native_response: () -> untyped
184
+ end
185
+
186
+ module Testing
187
+ end
188
+
189
+ module LifecycleHooks
190
+ def on_request: () { (untyped) -> untyped } -> Proc
191
+ def pre_validation: () { (untyped) -> untyped } -> Proc
192
+ def pre_handler: () { (untyped) -> untyped } -> Proc
193
+ def on_response: () { (untyped) -> untyped } -> Proc
194
+ def on_error: () { (untyped) -> untyped } -> Proc
195
+ end
196
+
197
+ module ProvideSupport
198
+ def provide: (
199
+ String | Symbol,
200
+ ?untyped,
201
+ ?depends_on: Array[String | Symbol],
202
+ ?singleton: bool,
203
+ ?cacheable: bool
204
+ ) ?{ (**untyped) -> untyped } -> self
205
+ def dependencies: () -> Spikard::Native::DependencyRegistry
206
+ end
207
+
208
+ class App
209
+ include LifecycleHooks
210
+ include ProvideSupport
211
+
212
+ attr_reader routes: Array[untyped]
213
+
214
+ def initialize: () -> void
215
+ def register_route: (String, String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
216
+ def get: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
217
+ def post: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
218
+ def put: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
219
+ def patch: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
220
+ def delete: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
221
+ def options: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
222
+ def head: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
223
+ def trace: (String, ?handler_name: String?, **untyped) { (untyped) -> untyped } -> Proc
224
+ def websocket: (String, ?handler_name: String?, **untyped) { () -> WebSocketHandler } -> Proc
225
+ def sse: (String, ?handler_name: String?, **untyped) { () -> SseEventProducer } -> Proc
226
+ def websocket_handlers: () -> Hash[String, Proc]
227
+ def sse_producers: () -> Hash[String, Proc]
228
+ def run: (?config: ServerConfig | Hash[Symbol, untyped]?, ?host: String?, ?port: Integer?) -> void
229
+ end
230
+
231
+ class WebSocketHandler
232
+ def handle_message: (Hash[untyped, untyped]) -> Hash[untyped, untyped]?
233
+ def on_connect: () -> void
234
+ def on_disconnect: () -> void
235
+ end
236
+
237
+ class SseEvent
238
+ attr_accessor data: Hash[untyped, untyped]
239
+ attr_accessor event_type: String?
240
+ attr_accessor id: String?
241
+ attr_accessor retry_ms: Integer?
242
+
243
+ def initialize: (data: Hash[untyped, untyped], ?event_type: String?, ?id: String?, ?retry_ms: Integer?) -> void
244
+ def to_h: () -> Hash[Symbol, untyped]
245
+ end
246
+
247
+ class SseEventProducer
248
+ def next_event: () -> SseEvent?
249
+ def on_connect: () -> void
250
+ def on_disconnect: () -> void
251
+ end
252
+
253
+ module Schema
254
+ def self.extract_json_schema: (untyped) -> Hash[untyped, untyped]?
255
+ end
256
+
257
+ module Native
258
+ def self.run_server: (
259
+ String,
260
+ Hash[Symbol, Proc],
261
+ ServerConfig,
262
+ Hash[Symbol, Array[Proc]],
263
+ Hash[String, Proc],
264
+ Hash[String, Proc],
265
+ Hash[String, untyped]
266
+ ) -> void
267
+
268
+ class DependencyRegistry
269
+ def initialize: () -> void
270
+ end
271
+
272
+ class TestClient
273
+ def initialize: (
274
+ String,
275
+ Hash[Symbol, Proc],
276
+ ServerConfig,
277
+ Hash[String, Proc],
278
+ Hash[String, Proc]
279
+ ) -> void
280
+ def request: (String, String, Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
281
+ def websocket: (String) -> untyped
282
+ def sse: (String) -> untyped
283
+ def close: () -> void
284
+ end
285
+ end
286
+
287
+ module Testing
288
+ def self.create_test_client: (App, ?config: ServerConfig?) -> Testing::TestClient
289
+
290
+ class Response
291
+ attr_reader status_code: Integer
292
+ attr_reader headers: Hash[String, String]
293
+ attr_reader body: String?
294
+
295
+ def initialize: (Hash[Symbol, untyped]) -> void
296
+ def status: () -> Integer
297
+ def body_bytes: () -> String
298
+ def body_text: () -> String?
299
+ def text: () -> String?
300
+ def json: () -> untyped
301
+ def bytes: () -> Array[Integer]
302
+ end
303
+
304
+ class TestClient
305
+ def initialize: (Spikard::Native::TestClient) -> void
306
+ def self.new: (App | Spikard::Native::TestClient, ?config: ServerConfig?) -> TestClient
307
+ def request: (String, String, **Hash[Symbol, untyped]) -> Response
308
+ def websocket: (String) -> WebSocketTestConnection
309
+ def sse: (String) -> SseStream
310
+ def close: () -> void
311
+ def get: (String, **Hash[Symbol, untyped]) -> Response
312
+ def post: (String, **Hash[Symbol, untyped]) -> Response
313
+ def put: (String, **Hash[Symbol, untyped]) -> Response
314
+ def patch: (String, **Hash[Symbol, untyped]) -> Response
315
+ def delete: (String, **Hash[Symbol, untyped]) -> Response
316
+ def head: (String, **Hash[Symbol, untyped]) -> Response
317
+ def options: (String, **Hash[Symbol, untyped]) -> Response
318
+ def trace: (String, **Hash[Symbol, untyped]) -> Response
319
+ end
320
+
321
+ class WebSocketTestConnection
322
+ def initialize: (untyped) -> void
323
+ def send_text: (untyped) -> void
324
+ def send_json: (untyped) -> void
325
+ def receive_text: () -> untyped
326
+ def receive_json: () -> untyped
327
+ def receive_bytes: () -> untyped
328
+ def receive_message: () -> WebSocketMessage
329
+ def close: () -> void
330
+ end
331
+
332
+ class WebSocketMessage
333
+ def initialize: (untyped) -> void
334
+ def as_text: () -> untyped
335
+ def as_json: () -> untyped
336
+ def as_binary: () -> untyped
337
+ def close?: () -> bool
338
+ end
339
+
340
+ class SseStream
341
+ def initialize: (untyped) -> void
342
+ def body: () -> String?
343
+ def events: () -> Array[InlineSseEvent]
344
+ def events_as_json: () -> Array[untyped]
345
+ end
346
+
347
+ class SseEvent
348
+ def initialize: (untyped) -> void
349
+ def data: () -> untyped
350
+ def as_json: () -> untyped
351
+ end
352
+
353
+ class InlineSseEvent
354
+ attr_reader data: String
355
+
356
+ def initialize: (String) -> void
357
+ def as_json: () -> untyped
358
+ end
359
+ end
360
+ end