app_bridge 5.0.0 → 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/CHANGELOG.md +4 -0
- data/Cargo.lock +270 -536
- data/Cargo.toml +1 -1
- data/README.md +1 -1
- data/ext/app_bridge/Cargo.toml +4 -4
- data/ext/app_bridge/src/app_state.rs +2 -1
- data/ext/app_bridge/src/component.rs +97 -11
- data/ext/app_bridge/src/file_ops.rs +2 -1
- data/ext/app_bridge/src/lib.rs +2 -0
- data/ext/app_bridge/src/request_builder.rs +4 -1
- data/ext/app_bridge/src/wrappers/action_context.rs +1 -1
- data/ext/app_bridge/src/wrappers/app.rs +79 -0
- data/ext/app_bridge/wit/v6/world.wit +385 -0
- data/lib/app_bridge/app.rb +39 -0
- data/lib/app_bridge/version.rb +1 -1
- data/sig/app_bridge.rbs +3 -0
- data/tasks/fixtures.rake +8 -1
- metadata +2 -1
data/Cargo.toml
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
[workspace]
|
|
6
6
|
members = ["./ext/app_bridge"]
|
|
7
7
|
resolver = "2"
|
|
8
|
-
exclude = ["./spec/fixtures/components/rust_app", "./spec/fixtures/components/rust_app_v3", "./spec/fixtures/components/rust_app_v5"]
|
|
8
|
+
exclude = ["./spec/fixtures/components/rust_app", "./spec/fixtures/components/rust_app_v3", "./spec/fixtures/components/rust_app_v5", "./spec/fixtures/components/rust_app_v6"]
|
data/README.md
CHANGED
|
@@ -316,7 +316,7 @@ Connectors embed `connection-config.json` via `include_str!` and export it throu
|
|
|
316
316
|
To contribute or modify this gem, ensure you have the following dependencies installed:
|
|
317
317
|
|
|
318
318
|
- **Ruby 3.3.0** (or later)
|
|
319
|
-
- **Rust 1.
|
|
319
|
+
- **Rust 1.97.0** (or later)
|
|
320
320
|
|
|
321
321
|
### Setting Up the Development Environment
|
|
322
322
|
|
data/ext/app_bridge/Cargo.toml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
name = "app_bridge"
|
|
3
3
|
# When updating the version, please also update the version in the
|
|
4
4
|
# lib/app_bridge/version.rb file to keep them in sync.
|
|
5
|
-
version = "
|
|
5
|
+
version = "6.0.0"
|
|
6
6
|
edition = "2021"
|
|
7
7
|
authors = ["Alexander Ross <ross@standout.se>"]
|
|
8
8
|
publish = false
|
|
@@ -12,9 +12,9 @@ crate-type = ["cdylib"]
|
|
|
12
12
|
|
|
13
13
|
[dependencies]
|
|
14
14
|
magnus = { version = "0.8.2" }
|
|
15
|
-
wasmtime = "
|
|
16
|
-
wasmtime-wasi = "
|
|
17
|
-
wasmtime-wasi-io = "
|
|
15
|
+
wasmtime = "50.0.1"
|
|
16
|
+
wasmtime-wasi = "50.0.1"
|
|
17
|
+
wasmtime-wasi-io = "50.0.1"
|
|
18
18
|
reqwest = { version = "0.12", features = ["blocking", "json", "native-tls-vendored"] }
|
|
19
19
|
base64 = "0.22"
|
|
20
20
|
infer = "0.16"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
use crate::component::{v3, v4, v4_1, v5};
|
|
1
|
+
use crate::component::{v3, v4, v4_1, v5, v6};
|
|
2
2
|
use crate::component::v4::standout::app::http::Request;
|
|
3
3
|
use reqwest::blocking::Client;
|
|
4
4
|
use std::collections::HashMap;
|
|
@@ -58,6 +58,7 @@ impl_host_for_version!(v3);
|
|
|
58
58
|
impl_host_for_version!(v4);
|
|
59
59
|
impl_host_for_version!(v4_1);
|
|
60
60
|
impl_host_for_version!(v5);
|
|
61
|
+
impl_host_for_version!(v6);
|
|
61
62
|
|
|
62
63
|
// ============================================================================
|
|
63
64
|
// WASI implementations
|
|
@@ -48,6 +48,12 @@ pub mod v5 {
|
|
|
48
48
|
world: "bridge",
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
pub mod v6 {
|
|
52
|
+
wasmtime::component::bindgen!({
|
|
53
|
+
path: "./wit/v6",
|
|
54
|
+
world: "bridge",
|
|
55
|
+
});
|
|
56
|
+
}
|
|
51
57
|
|
|
52
58
|
// ============================================================================
|
|
53
59
|
// Version conversion macro - generates From impls for a version module
|
|
@@ -189,6 +195,14 @@ impl From<v5::standout::app::types::ReferenceObject> for ReferenceObject {
|
|
|
189
195
|
}
|
|
190
196
|
}
|
|
191
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
|
+
}
|
|
192
206
|
|
|
193
207
|
impl From<&ReferenceObject> for v4_1::standout::app::types::ReferenceObject {
|
|
194
208
|
fn from(r: &ReferenceObject) -> Self {
|
|
@@ -207,6 +221,32 @@ impl From<&ReferenceObject> for v5::standout::app::types::ReferenceObject {
|
|
|
207
221
|
}
|
|
208
222
|
}
|
|
209
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
|
+
}
|
|
210
250
|
|
|
211
251
|
// Generate conversions for all supported versions
|
|
212
252
|
impl_error_code_conversion!(v3,);
|
|
@@ -231,6 +271,13 @@ impl_error_code_conversion!(
|
|
|
231
271
|
impl_conversions!(v5);
|
|
232
272
|
impl_app_error_conversion!(v5);
|
|
233
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);
|
|
234
281
|
|
|
235
282
|
// ============================================================================
|
|
236
283
|
// BridgeWrapper - unified interface for all component versions
|
|
@@ -243,6 +290,7 @@ pub enum BridgeWrapper {
|
|
|
243
290
|
V4(v4::Bridge),
|
|
244
291
|
V4_1(v4_1::Bridge),
|
|
245
292
|
V5(v5::Bridge),
|
|
293
|
+
V6(v6::Bridge),
|
|
246
294
|
}
|
|
247
295
|
|
|
248
296
|
impl BridgeWrapper {
|
|
@@ -253,16 +301,32 @@ impl BridgeWrapper {
|
|
|
253
301
|
BridgeWrapper::V4(_) => "4.0.0",
|
|
254
302
|
BridgeWrapper::V4_1(_) => "4.1.0",
|
|
255
303
|
BridgeWrapper::V5(_) => "5.0.0",
|
|
304
|
+
BridgeWrapper::V6(_) => "6.0.0",
|
|
256
305
|
}
|
|
257
306
|
}
|
|
258
307
|
|
|
259
308
|
pub fn connections_supported(&self) -> bool {
|
|
260
|
-
matches!(self, BridgeWrapper::V5(_))
|
|
309
|
+
matches!(self, BridgeWrapper::V5(_) | BridgeWrapper::V6(_))
|
|
261
310
|
}
|
|
262
311
|
}
|
|
263
312
|
|
|
264
313
|
/// Macro to implement a bridge method that works across all versions.
|
|
265
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
|
+
|
|
266
330
|
macro_rules! bridge_method {
|
|
267
331
|
// Simple no-arg method (e.g., trigger_ids, action_ids)
|
|
268
332
|
(fn $name:ident() -> Result<$ok_type:ty> via $interface:ident . $method:ident) => {
|
|
@@ -284,11 +348,15 @@ macro_rules! bridge_method {
|
|
|
284
348
|
let r = b.$interface().$method(store)?;
|
|
285
349
|
Ok(r.map_err(Into::into))
|
|
286
350
|
}
|
|
351
|
+
BridgeWrapper::V6(b) => {
|
|
352
|
+
let r = b.$interface().$method(store)?;
|
|
353
|
+
Ok(r.map_err(Into::into))
|
|
354
|
+
}
|
|
287
355
|
}
|
|
288
356
|
}
|
|
289
357
|
};
|
|
290
358
|
// Method with TriggerContext
|
|
291
|
-
(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) => {
|
|
292
360
|
pub fn $name(&self, store: &mut Store<AppState>, ctx: &TriggerContext) -> Result<std::result::Result<$ok_type, AppError>> {
|
|
293
361
|
match self {
|
|
294
362
|
BridgeWrapper::V3(b) => {
|
|
@@ -307,11 +375,14 @@ macro_rules! bridge_method {
|
|
|
307
375
|
let r = b.$interface().$method(store, &ctx.into())?;
|
|
308
376
|
Ok(r.map(Into::into).map_err(Into::into))
|
|
309
377
|
}
|
|
378
|
+
BridgeWrapper::V6(b) => {
|
|
379
|
+
Ok(v6_schema_or_run!(b, store, ctx, $interface, $method, $mode))
|
|
380
|
+
}
|
|
310
381
|
}
|
|
311
382
|
}
|
|
312
383
|
};
|
|
313
384
|
// Method with ActionContext
|
|
314
|
-
(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) => {
|
|
315
386
|
pub fn $name(&self, store: &mut Store<AppState>, ctx: &ActionContext) -> Result<std::result::Result<$ok_type, AppError>> {
|
|
316
387
|
match self {
|
|
317
388
|
BridgeWrapper::V3(b) => {
|
|
@@ -330,6 +401,9 @@ macro_rules! bridge_method {
|
|
|
330
401
|
let r = b.$interface().$method(store, &ctx.into())?;
|
|
331
402
|
Ok(r.map(Into::into).map_err(Into::into))
|
|
332
403
|
}
|
|
404
|
+
BridgeWrapper::V6(b) => {
|
|
405
|
+
Ok(v6_schema_or_run!(b, store, ctx, $interface, $method, $mode))
|
|
406
|
+
}
|
|
333
407
|
}
|
|
334
408
|
}
|
|
335
409
|
};
|
|
@@ -338,15 +412,15 @@ macro_rules! bridge_method {
|
|
|
338
412
|
impl BridgeWrapper {
|
|
339
413
|
// Trigger methods
|
|
340
414
|
bridge_method!(fn call_trigger_ids() -> Result<Vec<String>> via standout_app_triggers . call_trigger_ids);
|
|
341
|
-
bridge_method!(fn call_trigger_input_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_input_schema);
|
|
342
|
-
bridge_method!(fn call_trigger_output_schema(&TriggerContext) -> Result<String> via standout_app_triggers . call_output_schema);
|
|
343
|
-
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);
|
|
344
418
|
|
|
345
419
|
// Action methods
|
|
346
420
|
bridge_method!(fn call_action_ids() -> Result<Vec<String>> via standout_app_actions . call_action_ids);
|
|
347
|
-
bridge_method!(fn call_action_input_schema(&ActionContext) -> Result<String> via standout_app_actions . call_input_schema);
|
|
348
|
-
bridge_method!(fn call_action_output_schema(&ActionContext) -> Result<String> via standout_app_actions . call_output_schema);
|
|
349
|
-
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);
|
|
350
424
|
|
|
351
425
|
pub fn call_connection_config(
|
|
352
426
|
&self,
|
|
@@ -356,6 +430,9 @@ impl BridgeWrapper {
|
|
|
356
430
|
BridgeWrapper::V5(b) => {
|
|
357
431
|
b.standout_app_connections().call_connection_config(store)
|
|
358
432
|
}
|
|
433
|
+
BridgeWrapper::V6(b) => {
|
|
434
|
+
b.standout_app_connections().call_connection_config(store)
|
|
435
|
+
}
|
|
359
436
|
_ => unreachable!("call_connection_config requires connections_supported"),
|
|
360
437
|
}
|
|
361
438
|
}
|
|
@@ -395,6 +472,11 @@ pub fn build_linker(engine: &Engine) -> Result<Linker<AppState>> {
|
|
|
395
472
|
v5::standout::app::environment::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
396
473
|
v5::standout::app::file::add_to_linker::<AppState, HasSelf<AppState>>(&mut linker, |s| s)?;
|
|
397
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)?;
|
|
479
|
+
|
|
398
480
|
Ok(linker)
|
|
399
481
|
}
|
|
400
482
|
|
|
@@ -421,7 +503,11 @@ pub fn app(
|
|
|
421
503
|
let component = Component::from_file(&engine, &file_path)?;
|
|
422
504
|
|
|
423
505
|
// Try versions newest-first. When adding vN, insert at the top.
|
|
424
|
-
|
|
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)
|
|
425
511
|
if let Ok(instance) = v5::Bridge::instantiate(&mut *store, &component, &linker) {
|
|
426
512
|
return Ok(BridgeWrapper::V5(instance));
|
|
427
513
|
}
|
|
@@ -442,6 +528,6 @@ pub fn app(
|
|
|
442
528
|
}
|
|
443
529
|
|
|
444
530
|
Err(wasmtime::Error::msg(
|
|
445
|
-
"Failed to instantiate component: no compatible WIT version found (tried v5, v4.1, v4, v3)",
|
|
531
|
+
"Failed to instantiate component: no compatible WIT version found (tried v6, v5, v4.1, v4, v3)",
|
|
446
532
|
))
|
|
447
533
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::app_state::AppState;
|
|
2
|
-
use crate::component::{v4, v4_1, v5};
|
|
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
|
|
@@ -258,6 +258,7 @@ macro_rules! impl_file_host {
|
|
|
258
258
|
impl_file_host!(v4);
|
|
259
259
|
impl_file_host!(v4_1);
|
|
260
260
|
impl_file_host!(v5);
|
|
261
|
+
impl_file_host!(v6);
|
|
261
262
|
|
|
262
263
|
#[cfg(test)]
|
|
263
264
|
mod tests {
|
data/ext/app_bridge/src/lib.rs
CHANGED
|
@@ -93,6 +93,8 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
|
|
|
93
93
|
app_class.define_method("connections_supported?", method!(MutRApp::connections_supported, 0))?;
|
|
94
94
|
app_class.define_method("trigger_ids", method!(MutRApp::trigger_ids, 0))?;
|
|
95
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))?;
|
|
96
98
|
app_class.define_method("action_input_schema", method!(MutRApp::action_input_schema, 1))?;
|
|
97
99
|
app_class.define_method("action_output_schema", method!(MutRApp::action_output_schema, 1))?;
|
|
98
100
|
app_class.define_method("trigger_input_schema", method!(MutRApp::trigger_input_schema, 1))?;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use crate::app_state::AppState;
|
|
2
|
-
use crate::component::{v3, v4, v4_1, v5};
|
|
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;
|
|
@@ -270,14 +270,17 @@ impl_host_request_builder!(v3, no);
|
|
|
270
270
|
impl_host_request_builder!(v4, no);
|
|
271
271
|
impl_host_request_builder!(v4_1, yes);
|
|
272
272
|
impl_host_request_builder!(v5, yes);
|
|
273
|
+
impl_host_request_builder!(v6, yes);
|
|
273
274
|
|
|
274
275
|
impl_http_type_conversions!(v3);
|
|
275
276
|
impl_http_type_conversions!(v4_1);
|
|
276
277
|
impl_http_type_conversions!(v5);
|
|
278
|
+
impl_http_type_conversions!(v6);
|
|
277
279
|
impl_http_response_conversion!(v3, no_bytes);
|
|
278
280
|
impl_http_response_conversion!(v4, no_bytes);
|
|
279
281
|
impl_http_response_conversion!(v4_1, with_bytes);
|
|
280
282
|
impl_http_response_conversion!(v5, with_bytes);
|
|
283
|
+
impl_http_response_conversion!(v6, with_bytes);
|
|
281
284
|
|
|
282
285
|
// ============================================================================
|
|
283
286
|
// Shared request sending logic
|
|
@@ -10,7 +10,7 @@ pub struct RActionContext {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
impl RActionContext {
|
|
13
|
-
fn parse_reference_object(value: Value) -> Result<ReferenceObject, Error> {
|
|
13
|
+
pub(super) fn parse_reference_object(value: Value) -> Result<ReferenceObject, Error> {
|
|
14
14
|
let reference: String = fetch_hash_string(value, "reference")?;
|
|
15
15
|
let status: String = fetch_hash_string(value, "status")?;
|
|
16
16
|
Ok(ReferenceObject {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
use crate::component::v6::{self, standout::app::types::{ActionSchemaContext, TriggerSchemaContext, SchemaResponse}};
|
|
2
|
+
use super::connection::RConnection;
|
|
1
3
|
use magnus::{Error, TryConvert, Value};
|
|
2
4
|
use std::cell::RefCell;
|
|
3
5
|
use std::collections::HashMap;
|
|
@@ -128,6 +130,83 @@ impl MutRApp {
|
|
|
128
130
|
}
|
|
129
131
|
}
|
|
130
132
|
|
|
133
|
+
fn read_v6_schema(
|
|
134
|
+
&self,
|
|
135
|
+
read: impl FnOnce(
|
|
136
|
+
&v6::Bridge,
|
|
137
|
+
&mut Store<AppState>,
|
|
138
|
+
) -> wasmtime::Result<
|
|
139
|
+
Result<SchemaResponse, v6::standout::app::types::AppError>,
|
|
140
|
+
>,
|
|
141
|
+
) -> Result<(String, Option<String>), Error> {
|
|
142
|
+
let binding = self.0.borrow();
|
|
143
|
+
let instance = binding.instance.borrow();
|
|
144
|
+
let mut store = binding.store.borrow_mut();
|
|
145
|
+
let (Some(BridgeWrapper::V6(app)), Some(store)) = (instance.as_ref(), store.as_mut())
|
|
146
|
+
else {
|
|
147
|
+
return Err(runtime_error("Expected a WIT v6 component"));
|
|
148
|
+
};
|
|
149
|
+
let response = read(app, store)
|
|
150
|
+
.map_err(|err| runtime_error(err.to_string()))?
|
|
151
|
+
.map_err(AppError::from)?;
|
|
152
|
+
Ok(match response {
|
|
153
|
+
SchemaResponse::Complete(json) => ("complete".into(), Some(json)),
|
|
154
|
+
SchemaResponse::Partial(json) => ("partial".into(), Some(json)),
|
|
155
|
+
SchemaResponse::ConnectionRequired => ("connection_required".into(), None),
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
pub fn action_schema_result(
|
|
160
|
+
&self,
|
|
161
|
+
output: bool,
|
|
162
|
+
action_id: String,
|
|
163
|
+
connection: Option<RConnection>,
|
|
164
|
+
serialized_input: String,
|
|
165
|
+
reference: Option<Value>,
|
|
166
|
+
) -> Result<(String, Option<String>), Error> {
|
|
167
|
+
let reference = reference
|
|
168
|
+
.map(RActionContext::parse_reference_object)
|
|
169
|
+
.transpose()?;
|
|
170
|
+
let ctx = ActionSchemaContext {
|
|
171
|
+
action_id,
|
|
172
|
+
connection: connection.map(|c| (&c.inner).into()),
|
|
173
|
+
serialized_input,
|
|
174
|
+
reference_object: reference.as_ref().map(Into::into),
|
|
175
|
+
};
|
|
176
|
+
self.read_v6_schema(|app, store| {
|
|
177
|
+
let actions = app.standout_app_actions();
|
|
178
|
+
if output {
|
|
179
|
+
actions.call_output_schema(store, &ctx)
|
|
180
|
+
} else {
|
|
181
|
+
actions.call_input_schema(store, &ctx)
|
|
182
|
+
}
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
pub fn trigger_schema_result(
|
|
187
|
+
&self,
|
|
188
|
+
output: bool,
|
|
189
|
+
trigger_id: String,
|
|
190
|
+
connection: Option<RConnection>,
|
|
191
|
+
serialized_input: String,
|
|
192
|
+
store: String,
|
|
193
|
+
) -> Result<(String, Option<String>), Error> {
|
|
194
|
+
let ctx = TriggerSchemaContext {
|
|
195
|
+
trigger_id,
|
|
196
|
+
connection: connection.map(|c| (&c.inner).into()),
|
|
197
|
+
serialized_input,
|
|
198
|
+
store,
|
|
199
|
+
};
|
|
200
|
+
self.read_v6_schema(|app, store| {
|
|
201
|
+
let triggers = app.standout_app_triggers();
|
|
202
|
+
if output {
|
|
203
|
+
triggers.call_output_schema(store, &ctx)
|
|
204
|
+
} else {
|
|
205
|
+
triggers.call_input_schema(store, &ctx)
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
}
|
|
209
|
+
|
|
131
210
|
pub fn trigger_input_schema(&self, context: RTriggerContext) -> Result<String, Error> {
|
|
132
211
|
let binding = self.0.borrow();
|
|
133
212
|
let mut instance = binding.instance.borrow_mut();
|