mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-05-07 08:23:51 +02:00
Compare commits
5 Commits
yaak-cli-0
...
gschier/cl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2439ffd28c | ||
|
|
ad31755dbb | ||
|
|
b01b3a4c57 | ||
|
|
ef63b88710 | ||
|
|
fb5ad8c7f7 |
@@ -36,72 +36,72 @@ pub struct CliContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl CliContext {
|
impl CliContext {
|
||||||
pub fn new(data_dir: PathBuf, app_id: &str) -> Self {
|
pub async fn new(
|
||||||
let db_path = data_dir.join("db.sqlite");
|
data_dir: PathBuf,
|
||||||
let blob_path = data_dir.join("blobs.sqlite");
|
query_manager: QueryManager,
|
||||||
let (query_manager, blob_manager, _rx) =
|
blob_manager: BlobManager,
|
||||||
match yaak_models::init_standalone(&db_path, &blob_path) {
|
encryption_manager: Arc<EncryptionManager>,
|
||||||
Ok(v) => v,
|
with_plugins: bool,
|
||||||
|
execution_context: CliExecutionContext,
|
||||||
|
) -> Self {
|
||||||
|
let plugin_manager = if with_plugins {
|
||||||
|
let vendored_plugin_dir = data_dir.join("vendored-plugins");
|
||||||
|
let installed_plugin_dir = data_dir.join("installed-plugins");
|
||||||
|
let node_bin_path = PathBuf::from("node");
|
||||||
|
|
||||||
|
prepare_embedded_vendored_plugins(&vendored_plugin_dir)
|
||||||
|
.expect("Failed to prepare bundled plugins");
|
||||||
|
|
||||||
|
let plugin_runtime_main =
|
||||||
|
std::env::var("YAAK_PLUGIN_RUNTIME").map(PathBuf::from).unwrap_or_else(|_| {
|
||||||
|
prepare_embedded_plugin_runtime(&data_dir)
|
||||||
|
.expect("Failed to prepare embedded plugin runtime")
|
||||||
|
});
|
||||||
|
|
||||||
|
match PluginManager::new(
|
||||||
|
vendored_plugin_dir,
|
||||||
|
installed_plugin_dir,
|
||||||
|
node_bin_path,
|
||||||
|
plugin_runtime_main,
|
||||||
|
&query_manager,
|
||||||
|
&PluginContext::new_empty(),
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(plugin_manager) => Some(Arc::new(plugin_manager)),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: Failed to initialize database: {err}");
|
eprintln!("Warning: Failed to initialize plugins: {err}");
|
||||||
std::process::exit(1);
|
None
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
let encryption_manager =
|
} else {
|
||||||
Arc::new(EncryptionManager::new(query_manager.clone(), app_id));
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let plugin_event_bridge = if let Some(plugin_manager) = &plugin_manager {
|
||||||
|
Some(
|
||||||
|
CliPluginEventBridge::start(
|
||||||
|
plugin_manager.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager.clone(),
|
||||||
|
encryption_manager.clone(),
|
||||||
|
data_dir.clone(),
|
||||||
|
execution_context.clone(),
|
||||||
|
)
|
||||||
|
.await,
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
data_dir,
|
data_dir,
|
||||||
query_manager,
|
query_manager,
|
||||||
blob_manager,
|
blob_manager,
|
||||||
encryption_manager,
|
encryption_manager,
|
||||||
plugin_manager: None,
|
plugin_manager,
|
||||||
plugin_event_bridge: Mutex::new(None),
|
plugin_event_bridge: Mutex::new(plugin_event_bridge),
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn init_plugins(&mut self, execution_context: CliExecutionContext) {
|
|
||||||
let vendored_plugin_dir = self.data_dir.join("vendored-plugins");
|
|
||||||
let installed_plugin_dir = self.data_dir.join("installed-plugins");
|
|
||||||
let node_bin_path = PathBuf::from("node");
|
|
||||||
|
|
||||||
prepare_embedded_vendored_plugins(&vendored_plugin_dir)
|
|
||||||
.expect("Failed to prepare bundled plugins");
|
|
||||||
|
|
||||||
let plugin_runtime_main =
|
|
||||||
std::env::var("YAAK_PLUGIN_RUNTIME").map(PathBuf::from).unwrap_or_else(|_| {
|
|
||||||
prepare_embedded_plugin_runtime(&self.data_dir)
|
|
||||||
.expect("Failed to prepare embedded plugin runtime")
|
|
||||||
});
|
|
||||||
|
|
||||||
match PluginManager::new(
|
|
||||||
vendored_plugin_dir,
|
|
||||||
installed_plugin_dir,
|
|
||||||
node_bin_path,
|
|
||||||
plugin_runtime_main,
|
|
||||||
&self.query_manager,
|
|
||||||
&PluginContext::new_empty(),
|
|
||||||
false,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(plugin_manager) => {
|
|
||||||
let plugin_manager = Arc::new(plugin_manager);
|
|
||||||
let plugin_event_bridge = CliPluginEventBridge::start(
|
|
||||||
plugin_manager.clone(),
|
|
||||||
self.query_manager.clone(),
|
|
||||||
self.blob_manager.clone(),
|
|
||||||
self.encryption_manager.clone(),
|
|
||||||
self.data_dir.clone(),
|
|
||||||
execution_context,
|
|
||||||
)
|
|
||||||
.await;
|
|
||||||
self.plugin_manager = Some(plugin_manager);
|
|
||||||
*self.plugin_event_bridge.lock().await = Some(plugin_event_bridge);
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Warning: Failed to initialize plugins: {err}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ mod version_check;
|
|||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use cli::{Cli, Commands, PluginCommands, RequestCommands};
|
use cli::{Cli, Commands, PluginCommands, RequestCommands};
|
||||||
use context::{CliContext, CliExecutionContext};
|
use context::{CliContext, CliExecutionContext};
|
||||||
|
use std::sync::Arc;
|
||||||
|
use yaak_crypto::manager::EncryptionManager;
|
||||||
use yaak_models::queries::any_request::AnyRequest;
|
use yaak_models::queries::any_request::AnyRequest;
|
||||||
|
use yaak_models::query_manager::QueryManager;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
@@ -36,6 +39,17 @@ async fn main() {
|
|||||||
|
|
||||||
version_check::maybe_check_for_updates().await;
|
version_check::maybe_check_for_updates().await;
|
||||||
|
|
||||||
|
let db_path = data_dir.join("db.sqlite");
|
||||||
|
let blob_path = data_dir.join("blobs.sqlite");
|
||||||
|
let (query_manager, blob_manager, _rx) =
|
||||||
|
match yaak_models::init_standalone(&db_path, &blob_path) {
|
||||||
|
Ok(v) => v,
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: Failed to initialize database: {err}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
let exit_code = match command {
|
let exit_code = match command {
|
||||||
Commands::Auth(args) => commands::auth::run(args).await,
|
Commands::Auth(args) => commands::auth::run(args).await,
|
||||||
Commands::Plugin(args) => match args.command {
|
Commands::Plugin(args) => match args.command {
|
||||||
@@ -44,8 +58,18 @@ async fn main() {
|
|||||||
PluginCommands::Generate(args) => commands::plugin::run_generate(args).await,
|
PluginCommands::Generate(args) => commands::plugin::run_generate(args).await,
|
||||||
PluginCommands::Publish(args) => commands::plugin::run_publish(args).await,
|
PluginCommands::Publish(args) => commands::plugin::run_publish(args).await,
|
||||||
PluginCommands::Install(install_args) => {
|
PluginCommands::Install(install_args) => {
|
||||||
let mut context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
context.init_plugins(CliExecutionContext::default()).await;
|
let blob_manager = blob_manager.clone();
|
||||||
|
let execution_context = CliExecutionContext::default();
|
||||||
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
true,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let exit_code = commands::plugin::run_install(&context, install_args).await;
|
let exit_code = commands::plugin::run_install(&context, install_args).await;
|
||||||
context.shutdown().await;
|
context.shutdown().await;
|
||||||
exit_code
|
exit_code
|
||||||
@@ -56,15 +80,27 @@ async fn main() {
|
|||||||
Commands::Generate(args) => commands::plugin::run_generate(args).await,
|
Commands::Generate(args) => commands::plugin::run_generate(args).await,
|
||||||
Commands::Publish(args) => commands::plugin::run_publish(args).await,
|
Commands::Publish(args) => commands::plugin::run_publish(args).await,
|
||||||
Commands::Send(args) => {
|
Commands::Send(args) => {
|
||||||
let mut context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
match resolve_send_execution_context(
|
let blob_manager = blob_manager.clone();
|
||||||
&context,
|
|
||||||
|
let execution_context_result = resolve_send_execution_context(
|
||||||
|
&query_manager,
|
||||||
&args.id,
|
&args.id,
|
||||||
environment.as_deref(),
|
environment.as_deref(),
|
||||||
cookie_jar.as_deref(),
|
cookie_jar.as_deref(),
|
||||||
) {
|
);
|
||||||
|
match execution_context_result {
|
||||||
Ok(execution_context) => {
|
Ok(execution_context) => {
|
||||||
context.init_plugins(execution_context).await;
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
true,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
let exit_code = commands::send::run(
|
let exit_code = commands::send::run(
|
||||||
&context,
|
&context,
|
||||||
args,
|
args,
|
||||||
@@ -83,22 +119,48 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commands::CookieJar(args) => {
|
Commands::CookieJar(args) => {
|
||||||
let context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
|
let blob_manager = blob_manager.clone();
|
||||||
|
let execution_context = CliExecutionContext::default();
|
||||||
|
|
||||||
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
false,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let exit_code = commands::cookie_jar::run(&context, args);
|
let exit_code = commands::cookie_jar::run(&context, args);
|
||||||
context.shutdown().await;
|
context.shutdown().await;
|
||||||
exit_code
|
exit_code
|
||||||
}
|
}
|
||||||
Commands::Workspace(args) => {
|
Commands::Workspace(args) => {
|
||||||
let context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
|
let blob_manager = blob_manager.clone();
|
||||||
|
let execution_context = CliExecutionContext::default();
|
||||||
|
|
||||||
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
false,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let exit_code = commands::workspace::run(&context, args);
|
let exit_code = commands::workspace::run(&context, args);
|
||||||
context.shutdown().await;
|
context.shutdown().await;
|
||||||
exit_code
|
exit_code
|
||||||
}
|
}
|
||||||
Commands::Request(args) => {
|
Commands::Request(args) => {
|
||||||
let mut context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
|
let blob_manager = blob_manager.clone();
|
||||||
|
|
||||||
let execution_context_result = match &args.command {
|
let execution_context_result = match &args.command {
|
||||||
RequestCommands::Send { request_id } => resolve_request_execution_context(
|
RequestCommands::Send { request_id } => resolve_request_execution_context(
|
||||||
&context,
|
&query_manager,
|
||||||
request_id,
|
request_id,
|
||||||
environment.as_deref(),
|
environment.as_deref(),
|
||||||
cookie_jar.as_deref(),
|
cookie_jar.as_deref(),
|
||||||
@@ -111,9 +173,16 @@ async fn main() {
|
|||||||
&args.command,
|
&args.command,
|
||||||
RequestCommands::Send { .. } | RequestCommands::Schema { .. }
|
RequestCommands::Send { .. } | RequestCommands::Schema { .. }
|
||||||
);
|
);
|
||||||
if with_plugins {
|
let context = CliContext::new(
|
||||||
context.init_plugins(execution_context).await;
|
data_dir.clone(),
|
||||||
}
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
with_plugins,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
let exit_code = commands::request::run(
|
let exit_code = commands::request::run(
|
||||||
&context,
|
&context,
|
||||||
args,
|
args,
|
||||||
@@ -132,13 +201,37 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Commands::Folder(args) => {
|
Commands::Folder(args) => {
|
||||||
let context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
|
let blob_manager = blob_manager.clone();
|
||||||
|
let execution_context = CliExecutionContext::default();
|
||||||
|
|
||||||
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
false,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let exit_code = commands::folder::run(&context, args);
|
let exit_code = commands::folder::run(&context, args);
|
||||||
context.shutdown().await;
|
context.shutdown().await;
|
||||||
exit_code
|
exit_code
|
||||||
}
|
}
|
||||||
Commands::Environment(args) => {
|
Commands::Environment(args) => {
|
||||||
let context = CliContext::new(data_dir.clone(), app_id);
|
let query_manager = query_manager.clone();
|
||||||
|
let blob_manager = blob_manager.clone();
|
||||||
|
let execution_context = CliExecutionContext::default();
|
||||||
|
|
||||||
|
let context = CliContext::new(
|
||||||
|
data_dir.clone(),
|
||||||
|
query_manager.clone(),
|
||||||
|
blob_manager,
|
||||||
|
Arc::new(EncryptionManager::new(query_manager, app_id)),
|
||||||
|
false,
|
||||||
|
execution_context,
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let exit_code = commands::environment::run(&context, args);
|
let exit_code = commands::environment::run(&context, args);
|
||||||
context.shutdown().await;
|
context.shutdown().await;
|
||||||
exit_code
|
exit_code
|
||||||
@@ -151,19 +244,19 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_send_execution_context(
|
fn resolve_send_execution_context(
|
||||||
context: &CliContext,
|
query_manager: &QueryManager,
|
||||||
id: &str,
|
id: &str,
|
||||||
environment: Option<&str>,
|
environment: Option<&str>,
|
||||||
explicit_cookie_jar_id: Option<&str>,
|
explicit_cookie_jar_id: Option<&str>,
|
||||||
) -> Result<CliExecutionContext, String> {
|
) -> Result<CliExecutionContext, String> {
|
||||||
if let Ok(request) = context.db().get_any_request(id) {
|
if let Ok(request) = query_manager.connect().get_any_request(id) {
|
||||||
let (request_id, workspace_id) = match request {
|
let (request_id, workspace_id) = match request {
|
||||||
AnyRequest::HttpRequest(r) => (Some(r.id), r.workspace_id),
|
AnyRequest::HttpRequest(r) => (Some(r.id), r.workspace_id),
|
||||||
AnyRequest::GrpcRequest(r) => (Some(r.id), r.workspace_id),
|
AnyRequest::GrpcRequest(r) => (Some(r.id), r.workspace_id),
|
||||||
AnyRequest::WebsocketRequest(r) => (Some(r.id), r.workspace_id),
|
AnyRequest::WebsocketRequest(r) => (Some(r.id), r.workspace_id),
|
||||||
};
|
};
|
||||||
let cookie_jar_id =
|
let cookie_jar_id =
|
||||||
resolve_cookie_jar_id(context, &workspace_id, explicit_cookie_jar_id)?;
|
resolve_cookie_jar_id(query_manager, &workspace_id, explicit_cookie_jar_id)?;
|
||||||
return Ok(CliExecutionContext {
|
return Ok(CliExecutionContext {
|
||||||
request_id,
|
request_id,
|
||||||
workspace_id: Some(workspace_id),
|
workspace_id: Some(workspace_id),
|
||||||
@@ -172,9 +265,9 @@ fn resolve_send_execution_context(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(folder) = context.db().get_folder(id) {
|
if let Ok(folder) = query_manager.connect().get_folder(id) {
|
||||||
let cookie_jar_id =
|
let cookie_jar_id =
|
||||||
resolve_cookie_jar_id(context, &folder.workspace_id, explicit_cookie_jar_id)?;
|
resolve_cookie_jar_id(query_manager, &folder.workspace_id, explicit_cookie_jar_id)?;
|
||||||
return Ok(CliExecutionContext {
|
return Ok(CliExecutionContext {
|
||||||
request_id: None,
|
request_id: None,
|
||||||
workspace_id: Some(folder.workspace_id),
|
workspace_id: Some(folder.workspace_id),
|
||||||
@@ -183,9 +276,9 @@ fn resolve_send_execution_context(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Ok(workspace) = context.db().get_workspace(id) {
|
if let Ok(workspace) = query_manager.connect().get_workspace(id) {
|
||||||
let cookie_jar_id =
|
let cookie_jar_id =
|
||||||
resolve_cookie_jar_id(context, &workspace.id, explicit_cookie_jar_id)?;
|
resolve_cookie_jar_id(query_manager, &workspace.id, explicit_cookie_jar_id)?;
|
||||||
return Ok(CliExecutionContext {
|
return Ok(CliExecutionContext {
|
||||||
request_id: None,
|
request_id: None,
|
||||||
workspace_id: Some(workspace.id),
|
workspace_id: Some(workspace.id),
|
||||||
@@ -198,13 +291,13 @@ fn resolve_send_execution_context(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_request_execution_context(
|
fn resolve_request_execution_context(
|
||||||
context: &CliContext,
|
query_manager: &QueryManager,
|
||||||
request_id: &str,
|
request_id: &str,
|
||||||
environment: Option<&str>,
|
environment: Option<&str>,
|
||||||
explicit_cookie_jar_id: Option<&str>,
|
explicit_cookie_jar_id: Option<&str>,
|
||||||
) -> Result<CliExecutionContext, String> {
|
) -> Result<CliExecutionContext, String> {
|
||||||
let request = context
|
let request = query_manager
|
||||||
.db()
|
.connect()
|
||||||
.get_any_request(request_id)
|
.get_any_request(request_id)
|
||||||
.map_err(|e| format!("Failed to get request: {e}"))?;
|
.map_err(|e| format!("Failed to get request: {e}"))?;
|
||||||
|
|
||||||
@@ -214,7 +307,7 @@ fn resolve_request_execution_context(
|
|||||||
AnyRequest::WebsocketRequest(r) => r.workspace_id,
|
AnyRequest::WebsocketRequest(r) => r.workspace_id,
|
||||||
};
|
};
|
||||||
let cookie_jar_id =
|
let cookie_jar_id =
|
||||||
resolve_cookie_jar_id(context, &workspace_id, explicit_cookie_jar_id)?;
|
resolve_cookie_jar_id(query_manager, &workspace_id, explicit_cookie_jar_id)?;
|
||||||
|
|
||||||
Ok(CliExecutionContext {
|
Ok(CliExecutionContext {
|
||||||
request_id: Some(request_id.to_string()),
|
request_id: Some(request_id.to_string()),
|
||||||
@@ -225,7 +318,7 @@ fn resolve_request_execution_context(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn resolve_cookie_jar_id(
|
fn resolve_cookie_jar_id(
|
||||||
context: &CliContext,
|
query_manager: &QueryManager,
|
||||||
workspace_id: &str,
|
workspace_id: &str,
|
||||||
explicit_cookie_jar_id: Option<&str>,
|
explicit_cookie_jar_id: Option<&str>,
|
||||||
) -> Result<Option<String>, String> {
|
) -> Result<Option<String>, String> {
|
||||||
@@ -233,8 +326,8 @@ fn resolve_cookie_jar_id(
|
|||||||
return Ok(Some(cookie_jar_id.to_string()));
|
return Ok(Some(cookie_jar_id.to_string()));
|
||||||
}
|
}
|
||||||
|
|
||||||
let default_cookie_jar = context
|
let default_cookie_jar = query_manager
|
||||||
.db()
|
.connect()
|
||||||
.list_cookie_jars(workspace_id)
|
.list_cookie_jars(workspace_id)
|
||||||
.map_err(|e| format!("Failed to list cookie jars: {e}"))?
|
.map_err(|e| format!("Failed to list cookie jars: {e}"))?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ use yaak::send::{SendHttpRequestWithPluginsParams, send_http_request_with_plugin
|
|||||||
use yaak_crypto::manager::EncryptionManager;
|
use yaak_crypto::manager::EncryptionManager;
|
||||||
use yaak_models::blob_manager::BlobManager;
|
use yaak_models::blob_manager::BlobManager;
|
||||||
use yaak_models::models::{Environment, GrpcRequest, HttpRequestHeader};
|
use yaak_models::models::{Environment, GrpcRequest, HttpRequestHeader};
|
||||||
use yaak_models::queries::any_request::AnyRequest;
|
|
||||||
use yaak_models::query_manager::QueryManager;
|
use yaak_models::query_manager::QueryManager;
|
||||||
use yaak_models::render::make_vars_hashmap;
|
use yaak_models::render::make_vars_hashmap;
|
||||||
use yaak_models::util::UpdateSource;
|
use yaak_models::util::UpdateSource;
|
||||||
@@ -362,19 +361,10 @@ async fn build_plugin_reply(
|
|||||||
..event.context.clone()
|
..event.context.clone()
|
||||||
};
|
};
|
||||||
|
|
||||||
let folder_id = execution_context.request_id.as_ref().and_then(|rid| {
|
|
||||||
match host_context.query_manager.connect().get_any_request(rid) {
|
|
||||||
Ok(AnyRequest::HttpRequest(r)) => r.folder_id,
|
|
||||||
Ok(AnyRequest::GrpcRequest(r)) => r.folder_id,
|
|
||||||
Ok(AnyRequest::WebsocketRequest(r)) => r.folder_id,
|
|
||||||
Err(_) => None,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
let environment_chain =
|
let environment_chain =
|
||||||
match host_context.query_manager.connect().resolve_environments(
|
match host_context.query_manager.connect().resolve_environments(
|
||||||
&workspace_id,
|
&workspace_id,
|
||||||
folder_id.as_deref(),
|
None,
|
||||||
execution_context.environment_id.as_deref(),
|
execution_context.environment_id.as_deref(),
|
||||||
) {
|
) {
|
||||||
Ok(chain) => chain,
|
Ok(chain) => chain,
|
||||||
|
|||||||
Reference in New Issue
Block a user