spikard 0.17.1 → 0.17.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.
@@ -1,11 +1,11 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:35eddf0c1c2d5026810d7c6764f4a07eb6f6a4842f16e260e28a28acfe53d607
2
+ # alef:hash:fd5382b3b1e92ae2a36ce5590fbcc3ba3468732769e44f26fb14671d3dca8a1e
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
 
6
6
  [package]
7
7
  name = "spikard-rb"
8
- version = "0.17.1"
8
+ version = "0.17.2"
9
9
  edition = "2024"
10
10
  license = "MIT"
11
11
  description = "Codegen-first polyglot web toolkit with a Rust core and bindings for 14 languages"
@@ -26,14 +26,14 @@ default = ["di"]
26
26
  di = ["spikard/di"]
27
27
 
28
28
  [dependencies]
29
- magnus = "0.8"
29
+ magnus = "0.9"
30
30
  rb-sys = ">=0.9.130, <0.10"
31
31
  serde = { version = "1", features = ["derive"] }
32
32
  serde_json = "1"
33
- spikard = { version = "0.17.1", features = ["di"] }
34
- spikard-core = { version = "0.17.1" }
35
- spikard-graphql = { version = "0.17.1" }
36
- spikard-http = { version = "0.17.1" }
33
+ spikard = { version = "0.17.2", features = ["di"] }
34
+ spikard-core = { version = "0.17.2" }
35
+ spikard-graphql = { version = "0.17.2" }
36
+ spikard-http = { version = "0.17.2" }
37
37
  tokio = { version = "1", features = ["rt-multi-thread"] }
38
38
 
39
39
  # This crate deliberately does not use `[lints]` / `workspace = true`: its C-ABI /
@@ -1,5 +1,5 @@
1
1
  // This file is auto-generated by alef. DO NOT EDIT.
2
- // alef:hash:7dba771586f8d986a77beab2ac80f9b73fcf547adda43ac03babc4620d3871cf
2
+ // alef:hash:72cee06b09b03313dcc351fbc7c7b46dd974c59bdab5873558a75948a4cb32e4
3
3
  // Re-generate with: alef generate
4
4
  #![allow(dead_code, unused_imports, unused_variables)]
5
5
  #![allow(
@@ -1434,7 +1434,7 @@ unsafe impl TryConvertOwned for GraphQLSubscriptionSnapshot {}
1434
1434
  #[cfg(not(target_arch = "wasm32"))]
1435
1435
  impl Default for GraphQLSubscriptionSnapshot {
1436
1436
  fn default() -> Self {
1437
- spikard_http::testing::test_client::GraphQLSubscriptionSnapshot::default().into()
1437
+ spikard_http::testing::GraphQLSubscriptionSnapshot::default().into()
1438
1438
  }
1439
1439
  }
1440
1440
 
@@ -1703,6 +1703,25 @@ impl GrpcConfig {
1703
1703
  }
1704
1704
  }
1705
1705
 
1706
+ #[derive(Clone)]
1707
+ #[magnus::wrap(class = "Spikard::HookRegistry")]
1708
+ pub struct HookRegistry {
1709
+ inner: Arc<spikard_http::lifecycle::adapter::HookRegistry>,
1710
+ }
1711
+
1712
+ unsafe impl IntoValueFromNative for HookRegistry {}
1713
+
1714
+ impl magnus::TryConvert for HookRegistry {
1715
+ fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
1716
+ let r: &HookRegistry = magnus::TryConvert::try_convert(val)?;
1717
+ Ok(r.clone())
1718
+ }
1719
+ }
1720
+
1721
+ unsafe impl TryConvertOwned for HookRegistry {}
1722
+
1723
+ impl HookRegistry {}
1724
+
1706
1725
  #[derive(Clone, Debug, serde::Serialize)]
1707
1726
  #[serde(default)]
1708
1727
  #[magnus::wrap(class = "Spikard::JsonRpcConfig")]
@@ -5046,7 +5065,7 @@ impl StaticFilesConfig {
5046
5065
  #[derive(Clone)]
5047
5066
  #[magnus::wrap(class = "Spikard::TestClient")]
5048
5067
  pub struct TestClient {
5049
- inner: Arc<spikard_http::testing::test_client::TestClient>,
5068
+ inner: Arc<spikard_http::testing::TestClient>,
5050
5069
  }
5051
5070
 
5052
5071
  #[cfg(not(target_arch = "wasm32"))]
@@ -5644,7 +5663,7 @@ impl ValidationResponse {
5644
5663
  }
5645
5664
  }
5646
5665
 
5647
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
5666
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
5648
5667
  pub enum LifecycleHookPhase {
5649
5668
  OnRequest,
5650
5669
  PreValidation,
@@ -5674,7 +5693,14 @@ impl magnus::IntoValue for LifecycleHookPhase {
5674
5693
 
5675
5694
  impl magnus::TryConvert for LifecycleHookPhase {
5676
5695
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
5677
- let s: String = magnus::TryConvert::try_convert(val)?;
5696
+ // IntoValue emits Symbols, including when this enum is a Hash key.
5697
+ // Accept that exact representation as well as String inputs; do not
5698
+ // coerce arbitrary objects through to_s.
5699
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
5700
+ symbol.name()?.into_owned()
5701
+ } else {
5702
+ magnus::TryConvert::try_convert(val)?
5703
+ };
5678
5704
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
5679
5705
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
5680
5706
  // existing consumer code written in any of those styles keep working.
@@ -5695,7 +5721,7 @@ impl magnus::TryConvert for LifecycleHookPhase {
5695
5721
  unsafe impl IntoValueFromNative for LifecycleHookPhase {}
5696
5722
  unsafe impl TryConvertOwned for LifecycleHookPhase {}
5697
5723
 
5698
- #[derive(Clone, Copy, PartialEq, Eq, Debug, serde::Serialize, serde::Deserialize)]
5724
+ #[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, serde::Serialize, serde::Deserialize)]
5699
5725
  pub enum Method {
5700
5726
  Get,
5701
5727
  Post,
@@ -5733,7 +5759,14 @@ impl magnus::IntoValue for Method {
5733
5759
 
5734
5760
  impl magnus::TryConvert for Method {
5735
5761
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
5736
- let s: String = magnus::TryConvert::try_convert(val)?;
5762
+ // IntoValue emits Symbols, including when this enum is a Hash key.
5763
+ // Accept that exact representation as well as String inputs; do not
5764
+ // coerce arbitrary objects through to_s.
5765
+ let s: String = if let Some(symbol) = magnus::Symbol::from_value(val) {
5766
+ symbol.name()?.into_owned()
5767
+ } else {
5768
+ magnus::TryConvert::try_convert(val)?
5769
+ };
5737
5770
  // Accept the real serde wire value, the legacy always-snake_case symbol Magnus used to
5738
5771
  // emit unconditionally, and the verbatim PascalCase Rust variant name, so fixtures and
5739
5772
  // existing consumer code written in any of those styles keep working.
@@ -5791,7 +5824,8 @@ impl magnus::IntoValue for SecuritySchemeInfo {
5791
5824
 
5792
5825
  impl magnus::TryConvert for SecuritySchemeInfo {
5793
5826
  fn try_convert(val: magnus::Value) -> Result<Self, magnus::Error> {
5794
- // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
5827
+ // Generated Data variants carry native DTOs, not JSON-compatible display strings.
5828
+ let class_name: Option<String> = val.class().funcall("name", ())?; // For data enums with fields (e.g., PageAction), try to deserialize from JSON first.
5795
5829
  // For unit enums or when passed as a string, fall back to string-based conversion.
5796
5830
  let json_str: String = if let Ok(s) = <String as magnus::TryConvert>::try_convert(val) {
5797
5831
  s
@@ -5823,17 +5857,18 @@ impl magnus::TryConvert for SecuritySchemeInfo {
5823
5857
 
5824
5858
  unsafe impl IntoValueFromNative for SecuritySchemeInfo {}
5825
5859
  unsafe impl TryConvertOwned for SecuritySchemeInfo {}
5860
+
5826
5861
  impl SecuritySchemeInfo {}
5827
5862
 
5828
5863
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
5829
5864
  pub enum SnapshotError {
5830
- InvalidHeader { _0: String },
5831
- Decompression { _0: String },
5865
+ InvalidHeader(String),
5866
+ Decompression(String),
5832
5867
  }
5833
5868
 
5834
5869
  impl Default for SnapshotError {
5835
5870
  fn default() -> Self {
5836
- Self::InvalidHeader { _0: Default::default() }
5871
+ Self::InvalidHeader(Default::default())
5837
5872
  }
5838
5873
  }
5839
5874
 
@@ -5882,16 +5917,16 @@ unsafe impl TryConvertOwned for SnapshotError {}
5882
5917
 
5883
5918
  #[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
5884
5919
  pub enum WebSocketMessage {
5885
- Text { _0: String },
5886
- Binary { _0: Vec<u8> },
5920
+ Text(String),
5921
+ Binary(Vec<u8>),
5887
5922
  Close { code: u16, reason: Option<String> },
5888
- Ping { _0: Vec<u8> },
5889
- Pong { _0: Vec<u8> },
5923
+ Ping(Vec<u8>),
5924
+ Pong(Vec<u8>),
5890
5925
  }
5891
5926
 
5892
5927
  impl Default for WebSocketMessage {
5893
5928
  fn default() -> Self {
5894
- Self::Text { _0: Default::default() }
5929
+ Self::Text(Default::default())
5895
5930
  }
5896
5931
  }
5897
5932
 
@@ -6229,7 +6264,7 @@ impl From<spikard::FullSchemaConfig> for FullSchemaConfig {
6229
6264
  #[cfg(not(target_arch = "wasm32"))]
6230
6265
  #[allow(clippy::needless_update)]
6231
6266
  #[allow(clippy::redundant_closure)]
6232
- impl From<GraphQLSubscriptionSnapshot> for spikard_http::testing::test_client::GraphQLSubscriptionSnapshot {
6267
+ impl From<GraphQLSubscriptionSnapshot> for spikard_http::testing::GraphQLSubscriptionSnapshot {
6233
6268
  fn from(val: GraphQLSubscriptionSnapshot) -> Self {
6234
6269
  Self {
6235
6270
  operation_id: val.operation_id,
@@ -6247,8 +6282,8 @@ impl From<GraphQLSubscriptionSnapshot> for spikard_http::testing::test_client::G
6247
6282
  }
6248
6283
 
6249
6284
  #[cfg(not(target_arch = "wasm32"))]
6250
- impl From<spikard_http::testing::test_client::GraphQLSubscriptionSnapshot> for GraphQLSubscriptionSnapshot {
6251
- fn from(val: spikard_http::testing::test_client::GraphQLSubscriptionSnapshot) -> Self {
6285
+ impl From<spikard_http::testing::GraphQLSubscriptionSnapshot> for GraphQLSubscriptionSnapshot {
6286
+ fn from(val: spikard_http::testing::GraphQLSubscriptionSnapshot) -> Self {
6252
6287
  Self {
6253
6288
  operation_id: val.operation_id.to_string(),
6254
6289
  acknowledged: val.acknowledged,
@@ -6992,8 +7027,8 @@ impl From<spikard_http::SecuritySchemeInfo> for SecuritySchemeInfo {
6992
7027
  impl From<spikard_http::SnapshotError> for SnapshotError {
6993
7028
  fn from(val: spikard_http::SnapshotError) -> Self {
6994
7029
  match val {
6995
- spikard_http::SnapshotError::InvalidHeader(_0) => Self::InvalidHeader { _0: _0.to_string() },
6996
- spikard_http::SnapshotError::Decompression(_0) => Self::Decompression { _0: _0.to_string() },
7030
+ spikard_http::SnapshotError::InvalidHeader(_0) => Self::InvalidHeader(_0),
7031
+ spikard_http::SnapshotError::Decompression(_0) => Self::Decompression(_0),
6997
7032
  }
6998
7033
  }
6999
7034
  }
@@ -7002,14 +7037,14 @@ impl From<spikard_http::SnapshotError> for SnapshotError {
7002
7037
  impl From<spikard_http::testing::WebSocketMessage> for WebSocketMessage {
7003
7038
  fn from(val: spikard_http::testing::WebSocketMessage) -> Self {
7004
7039
  match val {
7005
- spikard_http::testing::WebSocketMessage::Text(_0) => Self::Text { _0: _0.to_string() },
7006
- spikard_http::testing::WebSocketMessage::Binary(_0) => Self::Binary { _0: _0.to_vec().into() },
7040
+ spikard_http::testing::WebSocketMessage::Text(_0) => Self::Text(_0),
7041
+ spikard_http::testing::WebSocketMessage::Binary(_0) => Self::Binary(_0.to_vec().into()),
7007
7042
  spikard_http::testing::WebSocketMessage::Close { code, reason } => Self::Close {
7008
7043
  code,
7009
7044
  reason: reason.map(|v| v.to_string()),
7010
7045
  },
7011
- spikard_http::testing::WebSocketMessage::Ping(_0) => Self::Ping { _0: _0.to_vec().into() },
7012
- spikard_http::testing::WebSocketMessage::Pong(_0) => Self::Pong { _0: _0.to_vec().into() },
7046
+ spikard_http::testing::WebSocketMessage::Ping(_0) => Self::Ping(_0.to_vec().into()),
7047
+ spikard_http::testing::WebSocketMessage::Pong(_0) => Self::Pong(_0.to_vec().into()),
7013
7048
  }
7014
7049
  }
7015
7050
  }
@@ -7021,9 +7056,9 @@ fn app_error_to_magnus_err(e: spikard::AppError) -> magnus::Error {
7021
7056
  magnus::Error::new(unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(), msg)
7022
7057
  }
7023
7058
 
7024
- /// Convert a `spikard_graphql::error::GraphQLError` error to a Magnus runtime error.
7059
+ /// Convert a `spikard_graphql::GraphQLError` error to a Magnus runtime error.
7025
7060
  #[allow(dead_code)]
7026
- fn graph_ql_error_to_magnus_err(e: spikard_graphql::error::GraphQLError) -> magnus::Error {
7061
+ fn graph_ql_error_to_magnus_err(e: spikard_graphql::GraphQLError) -> magnus::Error {
7027
7062
  let msg = e.to_string();
7028
7063
  magnus::Error::new(unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(), msg)
7029
7064
  }
@@ -7036,7 +7071,7 @@ pub struct GraphQLErrorInfo {
7036
7071
  }
7037
7072
 
7038
7073
  #[allow(dead_code)]
7039
- fn graph_ql_error_info(e: &spikard_graphql::error::GraphQLError) -> GraphQLErrorInfo {
7074
+ fn graph_ql_error_info(e: &spikard_graphql::GraphQLError) -> GraphQLErrorInfo {
7040
7075
  GraphQLErrorInfo {
7041
7076
  status_code: e.status_code(),
7042
7077
  is_transient: e.is_transient(),
@@ -7061,9 +7096,9 @@ impl GraphQLErrorInfo {
7061
7096
  }
7062
7097
  }
7063
7098
 
7064
- /// Convert a `spikard_graphql::schema::SchemaError` error to a Magnus runtime error.
7099
+ /// Convert a `spikard_graphql::SchemaError` error to a Magnus runtime error.
7065
7100
  #[allow(dead_code)]
7066
- fn schema_error_to_magnus_err(e: spikard_graphql::schema::SchemaError) -> magnus::Error {
7101
+ fn schema_error_to_magnus_err(e: spikard_graphql::SchemaError) -> magnus::Error {
7067
7102
  let msg = e.to_string();
7068
7103
  magnus::Error::new(unsafe { magnus::Ruby::get_unchecked() }.exception_runtime_error(), msg)
7069
7104
  }
@@ -7293,6 +7328,8 @@ fn ruby_init(ruby: &Ruby) -> Result<(), Error> {
7293
7328
  method!(GrpcConfig::max_stream_response_bytes, 0),
7294
7329
  )?;
7295
7330
 
7331
+ let class = module.define_class("HookRegistry", ruby.class_object())?;
7332
+
7296
7333
  let class = module.define_class("JsonRpcConfig", ruby.class_object())?;
7297
7334
 
7298
7335
  class.define_singleton_method("new", function!(JsonRpcConfig::new, -1))?;
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:c86304b735e529dcfe92286cd2ac55a41400bf26c6bad2f25cc5bf7a5d7dd7d5
2
+ # alef:hash:2532173fc0980492cdce787d5c6eb6b03728b2875dcbe95bab84bdad75239535
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true
@@ -66,12 +66,10 @@ module Spikard
66
66
 
67
67
  # @return [String]
68
68
  sig { returns(String) }
69
- # rubocop:disable Lint/UselessMethodDefinition
70
- def scheme = super
69
+ def scheme = Data.instance_method(:to_h).bind_call(self).fetch(:scheme)
71
70
  # @return [T.nilable(String)]
72
71
  sig { returns(T.nilable(String)) }
73
- # rubocop:disable Lint/UselessMethodDefinition
74
- def bearer_format = super
72
+ def bearer_format = Data.instance_method(:to_h).bind_call(self).fetch(:bearer_format)
75
73
  sig { returns(T::Boolean) }
76
74
  def http? = true
77
75
  sig { returns(T::Boolean) }
@@ -90,12 +88,10 @@ module Spikard
90
88
 
91
89
  # @return [String]
92
90
  sig { returns(String) }
93
- # rubocop:disable Lint/UselessMethodDefinition
94
- def location = super
91
+ def location = Data.instance_method(:to_h).bind_call(self).fetch(:location)
95
92
  # @return [String]
96
93
  sig { returns(String) }
97
- # rubocop:disable Lint/UselessMethodDefinition
98
- def name = super
94
+ def name = Data.instance_method(:to_h).bind_call(self).fetch(:name)
99
95
  sig { returns(T::Boolean) }
100
96
  def http? = false
101
97
  sig { returns(T::Boolean) }
@@ -1,10 +1,10 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:8b14200f72d25dd7608de928fff3642e64b622a90e38c7aa7709996697869a30
2
+ # alef:hash:f386c9cb541ad35e0ed41d33f9008fc4ea76ba41ce546c3f937f2a9992b09419
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
  # frozen_string_literal: true
6
6
 
7
7
  module Spikard
8
8
  ## The version string for this package.
9
- VERSION = "0.17.1"
9
+ VERSION = "0.17.2"
10
10
  end
data/sig/types.rbs CHANGED
@@ -1,5 +1,5 @@
1
1
  # This file is auto-generated by alef — DO NOT EDIT.
2
- # alef:hash:4f58a2c219b8a4dc9e1bac4f7e7c83ed13ae25f7a094a657596fb8d6dd62fcd2
2
+ # alef:hash:c8e2652b8aa83d8bfb2f8a4a9f625690fe073527382237a1b4c993332c153228
3
3
  # To regenerate: alef generate
4
4
  # To verify freshness: alef verify
5
5
 
@@ -30,8 +30,8 @@ def initialize: (keys: Array[String], header_name: String) -> void
30
30
  def pre_handler: (String hook) -> App
31
31
  def on_response: (String hook) -> App
32
32
  def on_error: (String hook) -> App
33
- def register_graphql_route: (String path, Method method, String schema_type, SchemaConfig config) -> App
34
- def register_graphql_sdl_route: (String path, Method method, String sdl, json_value response_data, DynamicSchemaConfig config) -> App
33
+ def register_graphql_route: (String path, enum_Method method, String schema_type, SchemaConfig config) -> App
34
+ def register_graphql_sdl_route: (String path, enum_Method method, String sdl, json_value response_data, DynamicSchemaConfig config) -> App
35
35
  def merge_axum_router: (String router) -> App
36
36
  def attach_axum_router: (String router) -> App
37
37
  def into_router: () -> String
@@ -164,6 +164,9 @@ def initialize: (?operation_id: String, ?acknowledged: bool, ?event: String, ?er
164
164
  class HandlerResult
165
165
  end
166
166
 
167
+ class HookRegistry
168
+ end
169
+
167
170
  class JsonRpcConfig
168
171
  attr_reader enabled: bool
169
172
  attr_reader endpoint_path: String
@@ -381,7 +384,7 @@ def initialize: (status: Integer, headers: Hash[String, String], body: String) -
381
384
  def openrpc_spec: (json_value spec) -> RouteBuilder
382
385
  def sync: () -> RouteBuilder
383
386
  def handler_dependencies: (Array[String] dependencies) -> RouteBuilder
384
- def self.new: (Method method, String path) -> RouteBuilder
387
+ def self.new: (enum_Method method, String path) -> RouteBuilder
385
388
  end
386
389
 
387
390
  class SchemaConfig
@@ -444,10 +447,10 @@ def initialize: (?host: String, ?port: Integer, ?workers: Integer, ?enable_reque
444
447
  end
445
448
 
446
449
  class TestClient
447
- def graphql_at: (String endpoint, String query, ?json_value variables, ?String operation_name) -> ResponseSnapshot
448
- def graphql: (String query, ?json_value variables, ?String operation_name) -> ResponseSnapshot
449
- def graphql_subscription_at: (String endpoint, String query, ?json_value variables, ?String operation_name) -> GraphQLSubscriptionSnapshot
450
- def graphql_subscription: (String query, ?json_value variables, ?String operation_name) -> GraphQLSubscriptionSnapshot
450
+ def graphql_at_async: (String endpoint, String query, ?json_value variables, ?String operation_name) -> ResponseSnapshot
451
+ def graphql_async: (String query, ?json_value variables, ?String operation_name) -> ResponseSnapshot
452
+ def graphql_subscription_at_async: (String endpoint, String query, ?json_value variables, ?String operation_name) -> GraphQLSubscriptionSnapshot
453
+ def graphql_subscription_async: (String query, ?json_value variables, ?String operation_name) -> GraphQLSubscriptionSnapshot
451
454
  end
452
455
 
453
456
  class TestingSseEvent
@@ -485,13 +488,9 @@ def initialize: (?host: String, ?port: Integer, ?workers: Integer, ?enable_reque
485
488
  def initialize: (valid: bool, errors: Array[String]) -> void
486
489
  end
487
490
 
488
- class LifecycleHookPhase
489
- type value = :OnRequest | :PreValidation | :PreHandler | :OnResponse | :OnError
490
- end
491
+ type enum_LifecycleHookPhase = :OnRequest | :PreValidation | :PreHandler | :OnResponse | :OnError
491
492
 
492
- class Method
493
- type value = :Get | :Post | :Put | :Patch | :Delete | :Head | :Options | :Connect | :Trace
494
- end
493
+ type enum_Method = :Get | :Post | :Put | :Patch | :Delete | :Head | :Options | :Connect | :Trace
495
494
 
496
495
  class SecuritySchemeInfo
497
496
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spikard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.1
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Na'aman Hirschfeld <nhirschfeld@gmail.com>