spikard 0.3.5 → 0.3.6

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