app_bridge 4.1.1 → 6.0.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.
- checksums.yaml +4 -4
- data/.tool-versions +1 -1
- data/CHANGELOG.md +4 -0
- data/Cargo.lock +569 -801
- data/Cargo.toml +1 -1
- data/README.md +7 -1
- data/Rakefile +16 -13
- data/ext/app_bridge/Cargo.toml +6 -4
- data/ext/app_bridge/docs/connection-config-schema.json +500 -0
- data/ext/app_bridge/src/app_state.rs +14 -8
- data/ext/app_bridge/src/component.rs +177 -25
- data/ext/app_bridge/src/error_mapping.rs +5 -0
- data/ext/app_bridge/src/file_ops.rs +3 -1
- data/ext/app_bridge/src/lib.rs +5 -0
- data/ext/app_bridge/src/request_builder.rs +7 -1
- data/ext/app_bridge/src/wrappers/action_context.rs +9 -8
- data/ext/app_bridge/src/wrappers/app.rs +128 -37
- data/ext/app_bridge/src/wrappers/trigger_context.rs +5 -4
- data/ext/app_bridge/wit/v5/world.wit +363 -0
- data/ext/app_bridge/wit/v6/world.wit +385 -0
- data/lib/app_bridge/app.rb +49 -0
- data/lib/app_bridge/connection_config_validator.rb +101 -0
- data/lib/app_bridge/version.rb +1 -1
- data/lib/app_bridge.rb +2 -0
- data/sig/app_bridge.rbs +3 -0
- data/tasks/fixtures.rake +32 -4
- metadata +21 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
use std::collections::HashMap;
|
|
2
2
|
use std::result::Result::Ok;
|
|
3
|
-
use wasmtime::component::{Component, Linker};
|
|
3
|
+
use wasmtime::component::{Component, HasSelf, Linker};
|
|
4
4
|
use wasmtime::{Engine, Result, Store};
|
|
5
|
-
use wasmtime_wasi::
|
|
5
|
+
use wasmtime_wasi::WasiCtxBuilder;
|
|
6
6
|
|
|
7
7
|
use crate::app_state::AppState;
|
|
8
8
|
use crate::types::{
|
|
@@ -42,6 +42,19 @@ pub mod v4_1 {
|
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
pub mod v5 {
|
|
46
|
+
wasmtime::component::bindgen!({
|
|
47
|
+
path: "./wit/v5",
|
|
48
|
+
world: "bridge",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
pub mod v6 {
|
|
52
|
+
wasmtime::component::bindgen!({
|
|
53
|
+
path: "./wit/v6",
|
|
54
|
+
world: "bridge",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
45
58
|
// ============================================================================
|
|
46
59
|
// Version conversion macro - generates From impls for a version module
|
|
47
60
|
// ============================================================================
|
|
@@ -174,6 +187,23 @@ impl From<v4_1::standout::app::types::ReferenceObject> for ReferenceObject {
|
|
|
174
187
|
}
|
|
175
188
|
}
|
|
176
189
|
|
|
190
|
+
impl From<v5::standout::app::types::ReferenceObject> for ReferenceObject {
|
|
191
|
+
fn from(r: v5::standout::app::types::ReferenceObject) -> Self {
|
|
192
|
+
Self {
|
|
193
|
+
reference: r.reference,
|
|
194
|
+
status: r.status,
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
impl From<v6::standout::app::types::ReferenceObject> for ReferenceObject {
|
|
199
|
+
fn from(r: v6::standout::app::types::ReferenceObject) -> Self {
|
|
200
|
+
Self {
|
|
201
|
+
reference: r.reference,
|
|
202
|
+
status: r.status,
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
177
207
|
impl From<&ReferenceObject> for v4_1::standout::app::types::ReferenceObject {
|
|
178
208
|
fn from(r: &ReferenceObject) -> Self {
|
|
179
209
|
Self {
|
|
@@ -183,6 +213,41 @@ impl From<&ReferenceObject> for v4_1::standout::app::types::ReferenceObject {
|
|
|
183
213
|
}
|
|
184
214
|
}
|
|
185
215
|
|
|
216
|
+
impl From<&ReferenceObject> for v5::standout::app::types::ReferenceObject {
|
|
217
|
+
fn from(r: &ReferenceObject) -> Self {
|
|
218
|
+
Self {
|
|
219
|
+
reference: r.reference.clone(),
|
|
220
|
+
status: r.status.clone(),
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
impl From<&ReferenceObject> for v6::standout::app::types::ReferenceObject {
|
|
225
|
+
fn from(r: &ReferenceObject) -> Self {
|
|
226
|
+
Self {
|
|
227
|
+
reference: r.reference.clone(),
|
|
228
|
+
status: r.status.clone(),
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
impl From<&ActionContext> for v6::standout::app::types::ActionSchemaContext {
|
|
234
|
+
fn from(ctx: &ActionContext) -> Self {
|
|
235
|
+
Self {
|
|
236
|
+
action_id: ctx.action_id.clone(), connection: Some((&ctx.connection).into()),
|
|
237
|
+
serialized_input: ctx.serialized_input.clone(), reference_object: ctx.reference_object.as_ref().map(Into::into),
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
impl From<&TriggerContext> for v6::standout::app::types::TriggerSchemaContext {
|
|
243
|
+
fn from(ctx: &TriggerContext) -> Self {
|
|
244
|
+
Self {
|
|
245
|
+
trigger_id: ctx.trigger_id.clone(), connection: Some((&ctx.connection).into()),
|
|
246
|
+
serialized_input: ctx.serialized_input.clone(), store: ctx.store.clone(),
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
186
251
|
// Generate conversions for all supported versions
|
|
187
252
|
impl_error_code_conversion!(v3,);
|
|
188
253
|
impl_conversions!(v3);
|
|
@@ -199,6 +264,20 @@ impl_error_code_conversion!(
|
|
|
199
264
|
impl_conversions!(v4_1);
|
|
200
265
|
impl_app_error_conversion!(v4_1);
|
|
201
266
|
impl_action_context_conversion_retry!(v4_1);
|
|
267
|
+
impl_error_code_conversion!(
|
|
268
|
+
v5,
|
|
269
|
+
V::RetryWithReference(r) => Self::RetryWithReference(r.into()),
|
|
270
|
+
);
|
|
271
|
+
impl_conversions!(v5);
|
|
272
|
+
impl_app_error_conversion!(v5);
|
|
273
|
+
impl_action_context_conversion_retry!(v5);
|
|
274
|
+
impl_error_code_conversion!(
|
|
275
|
+
v6,
|
|
276
|
+
V::RetryWithReference(r) => Self::RetryWithReference(r.into()),
|
|
277
|
+
);
|
|
278
|
+
impl_conversions!(v6);
|
|
279
|
+
impl_app_error_conversion!(v6);
|
|
280
|
+
impl_action_context_conversion_retry!(v6);
|
|
202
281
|
|
|
203
282
|
// ============================================================================
|
|
204
283
|
// BridgeWrapper - unified interface for all component versions
|
|
@@ -210,6 +289,8 @@ pub enum BridgeWrapper {
|
|
|
210
289
|
V3(v3::Bridge),
|
|
211
290
|
V4(v4::Bridge),
|
|
212
291
|
V4_1(v4_1::Bridge),
|
|
292
|
+
V5(v5::Bridge),
|
|
293
|
+
V6(v6::Bridge),
|
|
213
294
|
}
|
|
214
295
|
|
|
215
296
|
impl BridgeWrapper {
|
|
@@ -219,12 +300,33 @@ impl BridgeWrapper {
|
|
|
219
300
|
BridgeWrapper::V3(_) => "3.0.0",
|
|
220
301
|
BridgeWrapper::V4(_) => "4.0.0",
|
|
221
302
|
BridgeWrapper::V4_1(_) => "4.1.0",
|
|
303
|
+
BridgeWrapper::V5(_) => "5.0.0",
|
|
304
|
+
BridgeWrapper::V6(_) => "6.0.0",
|
|
222
305
|
}
|
|
223
306
|
}
|
|
307
|
+
|
|
308
|
+
pub fn connections_supported(&self) -> bool {
|
|
309
|
+
matches!(self, BridgeWrapper::V5(_) | BridgeWrapper::V6(_))
|
|
310
|
+
}
|
|
224
311
|
}
|
|
225
312
|
|
|
226
313
|
/// Macro to implement a bridge method that works across all versions.
|
|
227
314
|
/// Each version's result is converted to canonical types.
|
|
315
|
+
macro_rules! v6_schema_or_run {
|
|
316
|
+
($b:ident, $store:ident, $ctx:ident, $interface:ident, $method:ident, runtime) => {
|
|
317
|
+
$b.$interface().$method($store, &$ctx.into())?.map(Into::into).map_err(Into::into)
|
|
318
|
+
};
|
|
319
|
+
($b:ident, $store:ident, $ctx:ident, $interface:ident, $method:ident, schema) => {
|
|
320
|
+
$b.$interface().$method($store, &$ctx.into())?.map_err(AppError::from).and_then(|response| {
|
|
321
|
+
use v6::standout::app::types::SchemaResponse;
|
|
322
|
+
match response {
|
|
323
|
+
SchemaResponse::Complete(json) | SchemaResponse::Partial(json) => Ok(json),
|
|
324
|
+
SchemaResponse::ConnectionRequired => Err(AppError::new(ErrorCode::Misconfigured, "Connection is required")),
|
|
325
|
+
}
|
|
326
|
+
})
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
228
330
|
macro_rules! bridge_method {
|
|
229
331
|
// Simple no-arg method (e.g., trigger_ids, action_ids)
|
|
230
332
|
(fn $name:ident() -> Result<$ok_type:ty> via $interface:ident . $method:ident) => {
|
|
@@ -242,11 +344,19 @@ macro_rules! bridge_method {
|
|
|
242
344
|
let r = b.$interface().$method(store)?;
|
|
243
345
|
Ok(r.map_err(Into::into))
|
|
244
346
|
}
|
|
347
|
+
BridgeWrapper::V5(b) => {
|
|
348
|
+
let r = b.$interface().$method(store)?;
|
|
349
|
+
Ok(r.map_err(Into::into))
|
|
350
|
+
}
|
|
351
|
+
BridgeWrapper::V6(b) => {
|
|
352
|
+
let r = b.$interface().$method(store)?;
|
|
353
|
+
Ok(r.map_err(Into::into))
|
|
354
|
+
}
|
|
245
355
|
}
|
|
246
356
|
}
|
|
247
357
|
};
|
|
248
358
|
// Method with TriggerContext
|
|
249
|
-
(fn $name:ident(&TriggerContext) -> Result<$ok_type:ty> via $interface:ident . $method:ident) => {
|
|
359
|
+
(fn $name:ident(&TriggerContext) -> Result<$ok_type:ty> via $interface:ident . $method:ident, $mode:ident) => {
|
|
250
360
|
pub fn $name(&self, store: &mut Store<AppState>, ctx: &TriggerContext) -> Result<std::result::Result<$ok_type, AppError>> {
|
|
251
361
|
match self {
|
|
252
362
|
BridgeWrapper::V3(b) => {
|
|
@@ -261,11 +371,18 @@ macro_rules! bridge_method {
|
|
|
261
371
|
let r = b.$interface().$method(store, &ctx.into())?;
|
|
262
372
|
Ok(r.map(Into::into).map_err(Into::into))
|
|
263
373
|
}
|
|
374
|
+
BridgeWrapper::V5(b) => {
|
|
375
|
+
let r = b.$interface().$method(store, &ctx.into())?;
|
|
376
|
+
Ok(r.map(Into::into).map_err(Into::into))
|
|
377
|
+
}
|
|
378
|
+
BridgeWrapper::V6(b) => {
|
|
379
|
+
Ok(v6_schema_or_run!(b, store, ctx, $interface, $method, $mode))
|
|
380
|
+
}
|
|
264
381
|
}
|
|
265
382
|
}
|
|
266
383
|
};
|
|
267
384
|
// Method with ActionContext
|
|
268
|
-
(fn $name:ident(&ActionContext) -> Result<$ok_type:ty> via $interface:ident . $method:ident) => {
|
|
385
|
+
(fn $name:ident(&ActionContext) -> Result<$ok_type:ty> via $interface:ident . $method:ident, $mode:ident) => {
|
|
269
386
|
pub fn $name(&self, store: &mut Store<AppState>, ctx: &ActionContext) -> Result<std::result::Result<$ok_type, AppError>> {
|
|
270
387
|
match self {
|
|
271
388
|
BridgeWrapper::V3(b) => {
|
|
@@ -280,6 +397,13 @@ macro_rules! bridge_method {
|
|
|
280
397
|
let r = b.$interface().$method(store, &ctx.into())?;
|
|
281
398
|
Ok(r.map(Into::into).map_err(Into::into))
|
|
282
399
|
}
|
|
400
|
+
BridgeWrapper::V5(b) => {
|
|
401
|
+
let r = b.$interface().$method(store, &ctx.into())?;
|
|
402
|
+
Ok(r.map(Into::into).map_err(Into::into))
|
|
403
|
+
}
|
|
404
|
+
BridgeWrapper::V6(b) => {
|
|
405
|
+
Ok(v6_schema_or_run!(b, store, ctx, $interface, $method, $mode))
|
|
406
|
+
}
|
|
283
407
|
}
|
|
284
408
|
}
|
|
285
409
|
};
|
|
@@ -288,15 +412,30 @@ macro_rules! bridge_method {
|
|
|
288
412
|
impl BridgeWrapper {
|
|
289
413
|
// Trigger methods
|
|
290
414
|
bridge_method!(fn call_trigger_ids() -> Result<Vec<String>> via standout_app_triggers . call_trigger_ids);
|
|
291
|
-
bridge_method!(fn call_trigger_input_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_input_schema);
|
|
292
|
-
bridge_method!(fn call_trigger_output_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_output_schema);
|
|
293
|
-
bridge_method!(fn call_fetch_events(&TriggerContext) -> Result<TriggerResponse> via standout_app_triggers . call_fetch_events);
|
|
415
|
+
bridge_method!(fn call_trigger_input_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_input_schema, schema);
|
|
416
|
+
bridge_method!(fn call_trigger_output_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_output_schema, schema);
|
|
417
|
+
bridge_method!(fn call_fetch_events(&TriggerContext) -> Result<TriggerResponse> via standout_app_triggers . call_fetch_events, runtime);
|
|
294
418
|
|
|
295
419
|
// Action methods
|
|
296
420
|
bridge_method!(fn call_action_ids() -> Result<Vec<String>> via standout_app_actions . call_action_ids);
|
|
297
|
-
bridge_method!(fn call_action_input_schema(&ActionContext) -> Result<String> via standout_app_actions . call_input_schema);
|
|
298
|
-
bridge_method!(fn call_action_output_schema(&ActionContext) -> Result<String> via standout_app_actions . call_output_schema);
|
|
299
|
-
bridge_method!(fn call_execute(&ActionContext) -> Result<ActionResponse> via standout_app_actions . call_execute);
|
|
421
|
+
bridge_method!(fn call_action_input_schema(&ActionContext) -> Result<String> via standout_app_actions . call_input_schema, schema);
|
|
422
|
+
bridge_method!(fn call_action_output_schema(&ActionContext) -> Result<String> via standout_app_actions . call_output_schema, schema);
|
|
423
|
+
bridge_method!(fn call_execute(&ActionContext) -> Result<ActionResponse> via standout_app_actions . call_execute, runtime);
|
|
424
|
+
|
|
425
|
+
pub fn call_connection_config(
|
|
426
|
+
&self,
|
|
427
|
+
store: &mut Store<AppState>,
|
|
428
|
+
) -> Result<String> {
|
|
429
|
+
match self {
|
|
430
|
+
BridgeWrapper::V5(b) => {
|
|
431
|
+
b.standout_app_connections().call_connection_config(store)
|
|
432
|
+
}
|
|
433
|
+
BridgeWrapper::V6(b) => {
|
|
434
|
+
b.standout_app_connections().call_connection_config(store)
|
|
435
|
+
}
|
|
436
|
+
_ => unreachable!("call_connection_config requires connections_supported"),
|
|
437
|
+
}
|
|
438
|
+
}
|
|
300
439
|
}
|
|
301
440
|
|
|
302
441
|
// ============================================================================
|
|
@@ -315,24 +454,28 @@ pub fn build_linker(engine: &Engine) -> Result<Linker<AppState>> {
|
|
|
315
454
|
|
|
316
455
|
// ---- Version-specific interfaces ----
|
|
317
456
|
// v3: http + environment
|
|
318
|
-
v3::standout::app::http::add_to_linker(&mut linker, |s| s)?;
|
|
319
|
-
v3::standout::app::environment::add_to_linker(&mut linker, |s| s)?;
|
|
457
|
+
v3::standout::app::http::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
458
|
+
v3::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
320
459
|
|
|
321
460
|
// v4: http + environment + file
|
|
322
|
-
v4::standout::app::http::add_to_linker(&mut linker, |s| s)?;
|
|
323
|
-
v4::standout::app::environment::add_to_linker(&mut linker, |s| s)?;
|
|
324
|
-
v4::standout::app::file::add_to_linker(&mut linker, |s| s)?;
|
|
461
|
+
v4::standout::app::http::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
462
|
+
v4::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
463
|
+
v4::standout::app::file::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
325
464
|
|
|
326
465
|
// v4.1: http + environment + file
|
|
327
|
-
v4_1::standout::app::http::add_to_linker(&mut linker, |s| s)?;
|
|
328
|
-
v4_1::standout::app::environment::add_to_linker(&mut linker, |s| s)?;
|
|
329
|
-
v4_1::standout::app::file::add_to_linker(&mut linker, |s| s)?;
|
|
466
|
+
v4_1::standout::app::http::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
467
|
+
v4_1::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
468
|
+
v4_1::standout::app::file::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
330
469
|
|
|
331
|
-
//
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
470
|
+
// v5: http + environment + file
|
|
471
|
+
v5::standout::app::http::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
472
|
+
v5::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
473
|
+
v5::standout::app::file::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
474
|
+
|
|
475
|
+
// v6: http + environment + file
|
|
476
|
+
v6::standout::app::http::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
477
|
+
v6::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
478
|
+
v6::standout::app::file::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
336
479
|
|
|
337
480
|
Ok(linker)
|
|
338
481
|
}
|
|
@@ -360,7 +503,16 @@ pub fn app(
|
|
|
360
503
|
let component = Component::from_file(&engine, &file_path)?;
|
|
361
504
|
|
|
362
505
|
// Try versions newest-first. When adding vN, insert at the top.
|
|
363
|
-
|
|
506
|
+
if let Ok(instance) = v6::Bridge::instantiate(&mut *store, &component, &linker) {
|
|
507
|
+
return Ok(BridgeWrapper::V6(instance));
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
// v5 (legacy - has connections interface)
|
|
511
|
+
if let Ok(instance) = v5::Bridge::instantiate(&mut *store, &component, &linker) {
|
|
512
|
+
return Ok(BridgeWrapper::V5(instance));
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// v4.1 (has file interface + retry-with-reference)
|
|
364
516
|
if let Ok(instance) = v4_1::Bridge::instantiate(&mut *store, &component, &linker) {
|
|
365
517
|
return Ok(BridgeWrapper::V4_1(instance));
|
|
366
518
|
}
|
|
@@ -376,6 +528,6 @@ pub fn app(
|
|
|
376
528
|
}
|
|
377
529
|
|
|
378
530
|
Err(wasmtime::Error::msg(
|
|
379
|
-
"Failed to instantiate component: no compatible WIT version found (tried v4.1, v4, v3)",
|
|
531
|
+
"Failed to instantiate component: no compatible WIT version found (tried v6, v5, v4.1, v4, v3)",
|
|
380
532
|
))
|
|
381
533
|
}
|
|
@@ -2,6 +2,11 @@ use crate::types::{AppError, ErrorCode};
|
|
|
2
2
|
use magnus::prelude::*;
|
|
3
3
|
use magnus::{Error, ExceptionClass, RObject, Ruby};
|
|
4
4
|
|
|
5
|
+
pub fn runtime_error(message: impl Into<String>) -> Error {
|
|
6
|
+
let ruby = Ruby::get().unwrap();
|
|
7
|
+
Error::new(ruby.exception_runtime_error(), message.into())
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
impl From<ErrorCode> for ExceptionClass {
|
|
6
11
|
fn from(value: ErrorCode) -> Self {
|
|
7
12
|
fn get_class(name: &str) -> ExceptionClass {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::app_state::AppState;
|
|
2
|
-
use crate::component::{v4, v4_1};
|
|
2
|
+
use crate::component::{v4, v4_1, v5, v6};
|
|
3
3
|
use base64::{engine::general_purpose::STANDARD as BASE64, Engine};
|
|
4
4
|
|
|
5
5
|
/// Detects the type of input string
|
|
@@ -257,6 +257,8 @@ macro_rules! impl_file_host {
|
|
|
257
257
|
// When adding v5, add: impl_file_host!(v5);
|
|
258
258
|
impl_file_host!(v4);
|
|
259
259
|
impl_file_host!(v4_1);
|
|
260
|
+
impl_file_host!(v5);
|
|
261
|
+
impl_file_host!(v6);
|
|
260
262
|
|
|
261
263
|
#[cfg(test)]
|
|
262
264
|
mod tests {
|
data/ext/app_bridge/src/lib.rs
CHANGED
|
@@ -90,13 +90,18 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
90
90
|
let app_class = module.define_class("App", ruby.class_object())?;
|
|
91
91
|
app_class.define_alloc_func::<MutRApp>();
|
|
92
92
|
app_class.define_method("wit_version", method!(MutRApp::wit_version, 0))?;
|
|
93
|
+
app_class.define_method("connections_supported?", method!(MutRApp::connections_supported, 0))?;
|
|
93
94
|
app_class.define_method("trigger_ids", method!(MutRApp::trigger_ids, 0))?;
|
|
94
95
|
app_class.define_method("action_ids", method!(MutRApp::action_ids, 0))?;
|
|
96
|
+
app_class.define_private_method("_action_schema_result", method!(MutRApp::action_schema_result, 5))?;
|
|
97
|
+
app_class.define_private_method("_trigger_schema_result", method!(MutRApp::trigger_schema_result, 5))?;
|
|
95
98
|
app_class.define_method("action_input_schema", method!(MutRApp::action_input_schema, 1))?;
|
|
96
99
|
app_class.define_method("action_output_schema", method!(MutRApp::action_output_schema, 1))?;
|
|
97
100
|
app_class.define_method("trigger_input_schema", method!(MutRApp::trigger_input_schema, 1))?;
|
|
98
101
|
app_class.define_method("trigger_output_schema", method!(MutRApp::trigger_output_schema, 1))?;
|
|
99
102
|
app_class.define_private_method("_rust_initialize", method!(MutRApp::initialize, 2))?;
|
|
103
|
+
app_class.define_private_method("_rust_connections_supported?", method!(MutRApp::connections_supported, 0))?;
|
|
104
|
+
app_class.define_private_method("_rust_connection_config", method!(MutRApp::connection_config, 0))?;
|
|
100
105
|
app_class.define_private_method("_rust_fetch_events", method!(MutRApp::rb_fetch_events, 1))?;
|
|
101
106
|
app_class.define_private_method("_rust_execute_action", method!(MutRApp::rb_execute_action, 1))?;
|
|
102
107
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::app_state::AppState;
|
|
2
|
-
use crate::component::{v3, v4, v4_1};
|
|
2
|
+
use crate::component::{v3, v4, v4_1, v5, v6};
|
|
3
3
|
use crate::component::v4::standout::app::http::{Method, Request, RequestError};
|
|
4
4
|
use reqwest::Method as ReqwestMethod;
|
|
5
5
|
use std::result::Result::Ok;
|
|
@@ -269,12 +269,18 @@ macro_rules! impl_http_response_conversion {
|
|
|
269
269
|
impl_host_request_builder!(v3, no);
|
|
270
270
|
impl_host_request_builder!(v4, no);
|
|
271
271
|
impl_host_request_builder!(v4_1, yes);
|
|
272
|
+
impl_host_request_builder!(v5, yes);
|
|
273
|
+
impl_host_request_builder!(v6, yes);
|
|
272
274
|
|
|
273
275
|
impl_http_type_conversions!(v3);
|
|
274
276
|
impl_http_type_conversions!(v4_1);
|
|
277
|
+
impl_http_type_conversions!(v5);
|
|
278
|
+
impl_http_type_conversions!(v6);
|
|
275
279
|
impl_http_response_conversion!(v3, no_bytes);
|
|
276
280
|
impl_http_response_conversion!(v4, no_bytes);
|
|
277
281
|
impl_http_response_conversion!(v4_1, with_bytes);
|
|
282
|
+
impl_http_response_conversion!(v5, with_bytes);
|
|
283
|
+
impl_http_response_conversion!(v6, with_bytes);
|
|
278
284
|
|
|
279
285
|
// ============================================================================
|
|
280
286
|
// Shared request sending logic
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
use magnus::{prelude::*, scan_args::scan_args, Error, RHash, Ruby,
|
|
1
|
+
use magnus::{prelude::*, scan_args::scan_args, Error, RHash, Ruby, TryConvert, Value};
|
|
2
|
+
use crate::error_mapping::runtime_error;
|
|
2
3
|
use crate::types::{ActionContext, ReferenceObject};
|
|
3
4
|
use super::connection::RConnection;
|
|
4
5
|
|
|
@@ -9,7 +10,7 @@ pub struct RActionContext {
|
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
impl RActionContext {
|
|
12
|
-
fn parse_reference_object(value: Value) -> Result<ReferenceObject, Error> {
|
|
13
|
+
pub(super) fn parse_reference_object(value: Value) -> Result<ReferenceObject, Error> {
|
|
13
14
|
let reference: String = fetch_hash_string(value, "reference")?;
|
|
14
15
|
let status: String = fetch_hash_string(value, "status")?;
|
|
15
16
|
Ok(ReferenceObject {
|
|
@@ -33,12 +34,12 @@ impl RActionContext {
|
|
|
33
34
|
retry: Option<Value>,
|
|
34
35
|
) -> Result<Self, Error> {
|
|
35
36
|
if connection.is_nil() {
|
|
36
|
-
return Err(
|
|
37
|
+
return Err(runtime_error("Connection is required"));
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
let wrapped_connection: RConnection = match TryConvert::try_convert(connection) {
|
|
40
41
|
Ok(conn) => conn,
|
|
41
|
-
Err(_) => return Err(
|
|
42
|
+
Err(_) => return Err(runtime_error("Connection is required")),
|
|
42
43
|
};
|
|
43
44
|
|
|
44
45
|
let reference_object = match retry {
|
|
@@ -99,12 +100,12 @@ impl TryConvert for RActionContext {
|
|
|
99
100
|
};
|
|
100
101
|
|
|
101
102
|
if connection_val.is_nil() {
|
|
102
|
-
return Err(
|
|
103
|
+
return Err(runtime_error("Connection is required"));
|
|
103
104
|
}
|
|
104
105
|
|
|
105
106
|
let wrapped_connection: RConnection = match TryConvert::try_convert(connection_val) {
|
|
106
107
|
Ok(conn) => conn,
|
|
107
|
-
Err(_) => return Err(
|
|
108
|
+
Err(_) => return Err(runtime_error("Connection is required")),
|
|
108
109
|
};
|
|
109
110
|
|
|
110
111
|
let inner = ActionContext {
|
|
@@ -124,8 +125,8 @@ impl TryConvert for RActionContext {
|
|
|
124
125
|
fn fetch_hash_string(hash: Value, key: &str) -> Result<String, Error> {
|
|
125
126
|
let value: Value = hash.funcall("[]", (key,))?;
|
|
126
127
|
let value = if value.is_nil() {
|
|
127
|
-
let
|
|
128
|
-
hash.funcall("[]", (
|
|
128
|
+
let ruby = Ruby::get().unwrap();
|
|
129
|
+
hash.funcall("[]", (ruby.to_symbol(key),))?
|
|
129
130
|
} else {
|
|
130
131
|
value
|
|
131
132
|
};
|