Skip to main content

fiberplane_models/providers/
request.rs

1use crate::blobs::Blob;
2#[cfg(feature = "fp-bindgen")]
3use fp_bindgen::prelude::Serializable;
4use serde::{Deserialize, Serialize};
5use typed_builder::TypedBuilder;
6
7pub type ProviderConfig = serde_json::Value;
8
9#[derive(Debug, Deserialize, Serialize, TypedBuilder)]
10#[cfg_attr(
11    feature = "fp-bindgen",
12    derive(Serializable),
13    fp(rust_module = "fiberplane_models::providers")
14)]
15#[non_exhaustive]
16#[serde(rename_all = "camelCase")]
17pub struct ProviderRequest {
18    /// Query type that is part of the
19    /// [Intent](https://www.notion.so/fiberplane/RFC-45-Provider-Protocol-2-0-Revised-4ec85a0233924b2db0010d8cdae75e16#c8ed5dfbfd764e6bbd5c5b79333f9d6e)
20    /// through which the provider is invoked.
21    #[builder(setter(into))]
22    pub query_type: String,
23
24    /// Query data.
25    ///
26    /// This is usually populated from the [ProviderCell::query_data] field,
27    /// meaning the MIME type will be `"application/x-www-form-urlencoded"`
28    /// when produced by Studio's Query Builder.
29    #[builder(setter(into))]
30    pub query_data: Blob,
31
32    /// Configuration for the data source.
33    pub config: ProviderConfig,
34
35    /// Optional response from a previous invocation.
36    /// May be used for implementing things like filtering without additional
37    /// server roundtrip.
38    #[builder(default, setter(into, strip_option))]
39    #[serde(default, skip_serializing_if = "Option::is_none")]
40    pub previous_response: Option<Blob>,
41}